diff --git a/src/components/DriverEntryInlineForm.vue b/src/components/DriverEntryInlineForm.vue new file mode 100644 index 0000000..af49f77 --- /dev/null +++ b/src/components/DriverEntryInlineForm.vue @@ -0,0 +1,106 @@ + + + + + diff --git a/src/components/EntryOptionToggle.vue b/src/components/EntryOptionToggle.vue new file mode 100644 index 0000000..4dd3059 --- /dev/null +++ b/src/components/EntryOptionToggle.vue @@ -0,0 +1,17 @@ + + + + + diff --git a/src/components/FilePicker.vue b/src/components/FilePicker.vue index 0f1d185..015df99 100644 --- a/src/components/FilePicker.vue +++ b/src/components/FilePicker.vue @@ -14,48 +14,50 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ -import download from "downloadjs"; -import { cloneDeep } from "lodash-es"; -import { ref, watch } from "vue"; +import download from 'downloadjs' +import { clone, cloneDeep } from 'lodash-es' +import { ref, watch } from 'vue' const props = defineProps<{ - fileName: string, + fileName: string default?: T -}>(); +}>() -const jsonError = ref(); +const jsonError = ref() //#region File parsing -const file = defineModel(); -const fileText = ref(); +const file = defineModel() +const fileText = ref() -watch(file, (value) => { - try { - if (value !== undefined && value !== null) - fileText.value = JSON.stringify(value, null, 2); - else - fileText.value = undefined; - } catch (e: any) { - jsonError.value = e.message; - } -}, { deep: true }); +watch( + file, + (value) => { + try { + if (value != undefined) { + fileText.value = JSON.stringify(value, null, 2) + } else fileText.value = undefined + } catch (e: any) { + jsonError.value = e.message + } + }, + { deep: true }, +) watch(fileText, (newValue) => { try { if (newValue) file.value = JSON.parse(newValue) - else file.value = undefined; + else file.value = undefined } catch (e: any) { - jsonError.value = e.message; + jsonError.value = e.message } }) //#endregion function onNew() { - file.value = cloneDeep(props.default); + file.value = cloneDeep(props.default) } function downloadFile() { - if (fileText.value) - download(fileText.value, `${props.fileName}.json`, "application/json"); + if (fileText.value) download(fileText.value, `${props.fileName}.json`, 'application/json') } @@ -64,19 +66,14 @@ function downloadFile() { {{ jsonError }} - +
- - New {{ fileName }}.json - + New {{ fileName }}.json
- - Download {{ fileName }}.json - + Download {{ fileName }}.json
- \ No newline at end of file + diff --git a/src/composables/gameData.ts b/src/composables/gameData.ts index 88e2153..1ef6b1f 100644 --- a/src/composables/gameData.ts +++ b/src/composables/gameData.ts @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -import { CupCategories, DriverCategories, SessionTypes } from '@/lib/gameData' +import { Cars, CupCategories, DriverCategories, SessionTypes } from '@/lib/gameData' export function useGameData() { //#region Session types @@ -23,7 +23,7 @@ export function useGameData() { for (const item of SessionTypes) { result.push({ text: item.name, - value: item.value + value: item.value, }) } return result @@ -36,7 +36,7 @@ export function useGameData() { for (const item of CupCategories) { result.push({ text: item.name, - value: item.value + value: item.value, }) } return result @@ -49,7 +49,7 @@ export function useGameData() { for (const item of DriverCategories) { result.push({ text: item.name, - value: item.value + value: item.value, }) } return result @@ -57,10 +57,25 @@ export function useGameData() { //#endregion Driver categories //#region Cars + function carOptions() { + const result = [ + { + text: 'Any car', + value: -1, + }, + ] + for (const item of Cars) { + result.push({ + text: item.name, + value: item.value, + }) + } + return result + } //#endregion Cars //#region Tracks //#endregion Tracks - return { sessionTypeOptions, cupCategoryOptions, driverCategoryOptions } + return { sessionTypeOptions, cupCategoryOptions, driverCategoryOptions, carOptions } } diff --git a/src/lib/gameFiles.ts b/src/lib/gameFiles.ts index 75b554c..34c337d 100644 --- a/src/lib/gameFiles.ts +++ b/src/lib/gameFiles.ts @@ -15,6 +15,7 @@ along with this program. If not, see . */ import { DriverCategory, SettingsCarGroup, SettingsFormationLapType } from './gameData' +import { randomString } from './utils' //#region eventRules.json export class EventRules { @@ -61,27 +62,23 @@ export class EntryList { entries: EntryListEntry[] = [] forceEntryList: 0 | 1 = 0 } -export type EntryListEntry = { - drivers: EntryListDriver[] - raceNumber: number - forcedCarModel: number - overrideDriverInfo: number - isServerAdmin: number +export class EntryListEntry { + drivers: EntryListDriver[] = [] + raceNumber: number = 0 + forcedCarModel: number = -1 + overrideDriverInfo: number = 0 + isServerAdmin: number = 0 defaultGridPosition?: number ballastKg?: number restrictor?: number customCar?: string overrideCarModelForCustomCar?: number } -export type EntryListDriver = { - playerID: string +export class EntryListDriver { + playerID: string = '' firstName?: string lastName?: string shortName?: string driverCategory?: DriverCategory } -// Defaults -export const EntryListDriverDefault: EntryListDriver = { - playerID: '', -} //#endregion diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 42d7e8c..b6d5e3e 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -15,7 +15,6 @@ along with this program. If not, see . */ import { Platform } from '@/stores/settings' -import type { EntryListEntry } from './gameFiles' export function isNullOrWhitespace(input: string | null | undefined) { return !input || !input.trim() @@ -52,8 +51,8 @@ export function randomString(length: number = 6) { for (let i = length; i > 0; --i) result += chars[Math.floor(Math.random() * chars.length)] return result } -export function parsePlayerId(playerId: string) { - let platform = Platform.Steam +export function parsePlayerId(playerId: string, defaultPlatform: Platform = Platform.Steam) { + let platform = defaultPlatform if (playerId.startsWith('S')) platform = Platform.Steam else if (playerId.startsWith('M')) platform = Platform.Xbox else if (playerId.startsWith('P')) platform = Platform.PlayStation diff --git a/src/stores/settings.ts b/src/stores/settings.ts index 278fdb7..c3db107 100644 --- a/src/stores/settings.ts +++ b/src/stores/settings.ts @@ -12,6 +12,11 @@ export const PlatformOptions = [ { value: Platform.Xbox, text: 'Xbox' }, { value: Platform.PlayStation, text: 'PlayStation' }, ] as SelectOption[] +export const PlatformOptionsSmall = [ + { value: Platform.Steam, text: 'S' }, + { value: Platform.Xbox, text: 'X' }, + { value: Platform.PlayStation, text: 'PS' }, +] as SelectOption[] export const useSettingsStore = defineStore('settings', () => { // #region Platform diff --git a/src/views/EntryListView.vue b/src/views/EntryListView.vue new file mode 100644 index 0000000..99f1624 --- /dev/null +++ b/src/views/EntryListView.vue @@ -0,0 +1,213 @@ + + + + +