Add local save selection and editing
This commit is contained in:
1 parent
900eb90b42
commit
d19baec90b
18 files changed
+634
-4
No files matched your search
@@ -17,6 +17,13 @@ export const APP_ERROR_CODES = [
|
||||
'logs_folder_open_failed',
|
||||
'diagnostics_export_failed',
|
||||
'copy_not_found',
|
||||
'save_not_found',
|
||||
'save_read_only',
|
||||
'save_operation_failed',
|
||||
'save_login_invalid',
|
||||
'save_login_exists',
|
||||
'save_password_invalid',
|
||||
'save_nick_invalid',
|
||||
'copies_write_failed',
|
||||
'maintenance_busy',
|
||||
'maintenance_location',
|
||||
|
||||
@@ -14,6 +14,8 @@ export const IPC_CHANNEL_PREFIXES = [
|
||||
'install:',
|
||||
/** Listing and managing installed copies. */
|
||||
'copies:',
|
||||
/** Local account and save management. */
|
||||
'saves:',
|
||||
/** Starting and stopping the active copy. */
|
||||
'launch:',
|
||||
/** The launcher's own settings. */
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
} from '../schemas/install.ts';
|
||||
import { LabInfoSchema, LaunchStateSchema } from '../schemas/launch.ts';
|
||||
import { MaintenanceInfoSchema, MaintenanceProgressSchema, MaintenanceRequestSchema } from '../schemas/maintenance.ts';
|
||||
import { CurrencyEditsSchema, SaveDetailsSchema, SaveKeysSchema, SaveListSchema, SaveRegistrationSchema } from '../schemas/saves.ts';
|
||||
import { SettingsPatchSchema, SettingsSchema } from '../schemas/settings.ts';
|
||||
|
||||
/**
|
||||
@@ -127,6 +128,26 @@ export const ipcContract = {
|
||||
input: z.void(),
|
||||
output: z.void(),
|
||||
},
|
||||
'saves:list': {
|
||||
input: z.object({ copyId: CopyIdSchema }),
|
||||
output: SaveListSchema,
|
||||
},
|
||||
'saves:details': {
|
||||
input: SaveKeysSchema,
|
||||
output: SaveDetailsSchema,
|
||||
},
|
||||
'saves:setCurrent': {
|
||||
input: SaveKeysSchema,
|
||||
output: SaveListSchema,
|
||||
},
|
||||
'saves:create': {
|
||||
input: SaveRegistrationSchema,
|
||||
output: SaveListSchema,
|
||||
},
|
||||
'saves:editCurrencies': {
|
||||
input: SaveKeysSchema.extend({ values: CurrencyEditsSchema }),
|
||||
output: SaveDetailsSchema,
|
||||
},
|
||||
'launch:getState': {
|
||||
input: z.void(),
|
||||
output: LaunchStateSchema,
|
||||
|
||||
@@ -134,6 +134,7 @@ export const InstallRecordSchema = z.object({
|
||||
unavailablePatches: z.array(UnavailablePatchSchema),
|
||||
installedAt: z.string(),
|
||||
lastCheckedAt: z.string().optional(),
|
||||
currentSaveId: z.string().regex(/^\d+$/).optional(),
|
||||
/** Relative paths read from the installation source during the last copy or update. */
|
||||
sourceFiles: z.array(z.string().min(1)).optional(),
|
||||
});
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
import { z } from 'zod';
|
||||
import { CopyIdSchema } from './install.ts';
|
||||
|
||||
export const LocalUserIdSchema = z.string().regex(/^\d+$/);
|
||||
|
||||
export const SaveKeysSchema = z.object({ copyId: CopyIdSchema, userId: LocalUserIdSchema });
|
||||
export const CurrencyEditsSchema = z.object({
|
||||
silverLions: z.number().int().nonnegative().optional(),
|
||||
goldenEagles: z.number().int().min(0).max(0x7fffffff).optional(),
|
||||
gjnCents: z.number().int().nonnegative().optional(),
|
||||
freeRp: z.number().int().nonnegative().optional(),
|
||||
});
|
||||
const SaveSummarySchema = z.object({
|
||||
userId: LocalUserIdSchema,
|
||||
login: z.string(),
|
||||
nick: z.string(),
|
||||
created: z.string(),
|
||||
currencies: z.object({
|
||||
silverLions: z.number(),
|
||||
goldenEagles: z.number(),
|
||||
gjnCents: z.number(),
|
||||
freeRp: z.number(),
|
||||
}).nullable(),
|
||||
vehicleCount: z.number().int().nonnegative(),
|
||||
battleCount: z.number().int().nonnegative(),
|
||||
lastBattle: z.number().nullable(),
|
||||
premiumDays: z.number(),
|
||||
});
|
||||
export const SaveListSchema = z.object({ saves: z.array(SaveSummarySchema), current: LocalUserIdSchema.nullable() });
|
||||
export const SaveDetailsSchema = z.object({
|
||||
save: SaveSummarySchema,
|
||||
battles: z.array(z.object({
|
||||
id: z.string(), time: z.number(), won: z.boolean().nullable(), mission: z.string(), mode: z.string(),
|
||||
vehicles: z.array(z.string()), silverLions: z.number(), researchPoints: z.number(),
|
||||
})),
|
||||
owned: z.array(z.string()),
|
||||
research: z.array(z.object({ name: z.string(), points: z.number() })),
|
||||
});
|
||||
export const SaveRegistrationSchema = z.object({
|
||||
copyId: CopyIdSchema, login: z.string(), password: z.string(), nick: z.string(),
|
||||
});
|
||||
|
||||
export type SaveList = z.output<typeof SaveListSchema>;
|
||||
export type SaveDetails = z.output<typeof SaveDetailsSchema>;
|
||||
export type CurrencyEdits = z.output<typeof CurrencyEditsSchema>;
|
||||
export type SaveRegistration = z.output<typeof SaveRegistrationSchema>;
|
||||
Reference in new issue
Block a user