Skip to content

Commit 149910c

Browse files
committed
add 'All' style option for player times page & update ai generated code to use the style enum
1 parent a45380c commit 149910c

11 files changed

Lines changed: 22 additions & 15 deletions

File tree

src/api/offstylesApi.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class OffstylesApi extends Api {
4343
static offstylesApiUrl = import.meta.env.DEV ? '/api' : 'https://offstyles.tommyy.dev/api';
4444

4545
// Fixed method signature to require style parameter
46-
static async getTimesByMap(mapName: string, style: number = 190, steamid?: string, limit: number = 50, page: number = 1): Promise<RankAwareRecord[]> {
46+
static async getTimesByMap(mapName: string, style: number = Style.normal, steamid?: string, limit: number = 50, page: number = 1): Promise<RankAwareRecord[]> {
4747
const params = new URLSearchParams({
4848
map: mapName,
4949
style: style.toString(),
@@ -59,7 +59,7 @@ class OffstylesApi extends Api {
5959
return await this.fetchFromUrl();
6060
}
6161

62-
static async getTimesByPlayer(steamID: string, map?: string, style: number = 190, limit: number = 50, page: number = 1, best: boolean = false): Promise<WRAwareRecord[]> {
62+
static async getTimesByPlayer(steamID: string, map?: string, style: number = Style.all, limit: number = 50, page: number = 1, best: boolean = false): Promise<WRAwareRecord[]> {
6363
const params = new URLSearchParams({
6464
steamid: steamID,
6565
limit: limit.toString(),
@@ -71,7 +71,7 @@ class OffstylesApi extends Api {
7171
params.append('map', map);
7272
}
7373

74-
if (style !== undefined) {
74+
if (style !== undefined && style !== Style.all) {
7575
params.append('style', style.toString());
7676
}
7777

src/components/CustomDropdown.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99
const emit = defineEmits(['dropdown-Changed']);
1010
1111
const props = defineProps<{
12-
options: number[],
12+
options: (number)[],
1313
name: string,
14-
format: (value: number) => string
14+
format: (value: number) => string,
15+
default: number
1516
}>()
1617
17-
const currentInput : Ref<number> = ref(urlParams.getAsObject().style ? Number(urlParams.getAsObject().style) : Style.normal);
18+
const currentInput : Ref<number> = ref(urlParams.getAsObject().style ? Number(urlParams.getAsObject().style) : props.default);
1819
1920
watch(currentInput, async() => {
2021
emit('dropdown-Changed', props.name, currentInput.value);

src/components/MapDetails.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<h1 class="text-2xl mb-3">{{ mapName }}</h1>
3636
<div class="flex py-2">
3737
<CustomDropdown :options="[Style.normal, Style.sideways, Style.wonly, Style.legit_scroll, Style.half_sideways, Style.a_d_only, Style.segmented]"
38-
:name="'style'" :format="styleFormat.name" @dropdown-Changed="dropdownChanged"></CustomDropdown>
38+
:name="'style'" :format="styleFormat.name" :default="Style.normal" @dropdown-Changed="dropdownChanged"></CustomDropdown>
3939
</div>
4040
<TimesList v-if="props.mapTimes" :times="props.mapTimes" :cols="[{
4141
label: 'Player',

src/components/PlayerDetails.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@
155155
</button>
156156
</div>
157157
<div class="flex py-2">
158-
<CustomDropdown :options="[Style.normal, Style.sideways, Style.wonly, Style.legit_scroll, Style.half_sideways, Style.a_d_only, Style.segmented]"
159-
:name="'style'" :format="styleFormat.name" @dropdown-Changed="dropdownChanged"></CustomDropdown>
158+
<CustomDropdown :options="[Style.all, Style.normal, Style.sideways, Style.wonly, Style.legit_scroll, Style.half_sideways, Style.a_d_only, Style.segmented]"
159+
:name="'style'" :format="styleFormat.name" :default="Style.all" @dropdown-Changed="dropdownChanged"></CustomDropdown>
160160
</div>
161161
<TimesList v-if="props.playerTimes" :times="props.playerTimes" :cols="[
162162
{

src/components/RecentTimes.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<p class="text-sm text-gray-400 mb-4">Displaying records from the last 2 weeks</p>
3737
<div class="flex py-2 justify-between flex-wrap gap-3">
3838
<CustomDropdown :options="[Style.normal, Style.sideways, Style.wonly, Style.legit_scroll, Style.half_sideways, Style.a_d_only, Style.segmented]"
39-
:name="'style'" :format="styleFormat.name" @dropdown-Changed="dropdownChanged"></CustomDropdown>
39+
:name="'style'" :format="styleFormat.name" :default="Style.normal" @dropdown-Changed="dropdownChanged"></CustomDropdown>
4040
<CheckboxInput @checkbox-Changed="dropdownChanged" :name="'wr'" :label="'Only show WR times'"></CheckboxInput>
4141
</div>
4242
<TimesList v-if="props.recentTimes" :times="props.recentTimes" :cols="[{

src/types/Style.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export enum Style {
2+
all = 0,
23
normal = 190,
34
sideways = 191,
45
wonly = 192,

src/utils/styleFormat.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Style } from "@/types/Style";
22

33
const name = function(style : Style) {
44
switch(style){
5+
case Style.all: return 'All';
56
case Style.normal: return 'Normal';
67
case Style.sideways: return 'Sideways';
78
case Style.wonly: return 'W-Only';
@@ -15,6 +16,7 @@ const name = function(style : Style) {
1516

1617
const styleFromName = function(name : string) {
1718
switch(name.toLowerCase()){
19+
case 'all': return Style.all;
1820
case 'normal': return Style.normal;
1921
case 'sideways': return Style.sideways;
2022
case 'w-only': return Style.wonly;

src/utils/urlParams.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Style } from "@/types/Style";
22
const update = function(name: string, value : number | string) {
33
const params = new URLSearchParams(window.location.search);
44
params.set(name, String(value));
5-
if(name === 'style' && value === Style.normal){
5+
if(name === 'style' && value === Style.all){
66
params.delete(name);
77
}
88
//cant use router outside of setup component, so need to return the new query and use there instead

src/views/MapsView.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import MapDetails from '@/components/MapDetails.vue';
99
import type { Time } from '@/types/Time';
1010
import SearchBoxMap from '@/components/SearchBoxMap.vue';
11+
import { Style } from '@/types/Style';
1112
1213
const props = defineProps({
1314
mapName: {
@@ -44,7 +45,7 @@
4445
const paramsObj = urlParams.getAsObject();
4546
4647
// Convert string params to numbers with defaults
47-
const style = paramsObj.style ? parseInt(paramsObj.style) : 190;
48+
const style = paramsObj.style ? parseInt(paramsObj.style) : Style.normal;
4849
const page = paramsObj.page ? parseInt(paramsObj.page) : 1;
4950
5051
const apiMapTimes = await OffstylesApi.getTimesByMap(name, style, undefined, undefined, page);

src/views/PlayersView.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import PlayerDetails from '@/components/PlayerDetails.vue';
99
import type { Time } from '@/types/Time';
1010
import SearchBoxPlayer from '@/components/SearchBoxPlayer.vue';
11+
import { Style } from '@/types/Style';
1112
1213
const props = defineProps({
1314
playerSteamId: {
@@ -77,7 +78,7 @@
7778
const paramsObj = urlParams.getAsObject();
7879
7980
// Convert string params to numbers with defaults
80-
const style = paramsObj.style ? parseInt(paramsObj.style) : 190;
81+
const style = paramsObj.style ? parseInt(paramsObj.style) : Style.all;
8182
const page = paramsObj.page ? parseInt(paramsObj.page) : 1;
8283
8384
const apiPlayerTimes = await OffstylesApi.getTimesByPlayer(playerId, undefined, style, undefined, page);

0 commit comments

Comments
 (0)