Skip to content

Commit

Permalink
Merge pull request #15 from Moumirrai/main
Browse files Browse the repository at this point in the history
Wintermute saves
  • Loading branch information
FINDarkside authored Jan 22, 2023
2 parents 7c2b6a8 + 56740eb commit 9bda2a0
Show file tree
Hide file tree
Showing 10 changed files with 1,568 additions and 962 deletions.
1 change: 1 addition & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@
"GEAR_RevolverAmmoBox": "Revolver Ammunition",
"GEAR_RevolverAmmoCasing": "Revolver Shell Casing",
"GEAR_Rifle": "Hunting Rifle",
"GEAR_Rifle_Vaughns": "Vaughn's Rifle",
"GEAR_RifleAmmoBox": "Rifle Ammunition",
"GEAR_RifleAmmoCasing": "Rifle Shell Casing",
"GEAR_RifleCleaningKit": "Firearm Cleaning Kit",
Expand Down
2,482 changes: 1,528 additions & 954 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"dependencies": {
"@mdi/font": "5.9.55",
"async": "^3.2.4",
"json-bigint": "^1.0.0",
"json-bigint": "github:sidorares/json-bigint",
"json5": "^2.2.1",
"lzfjs": "^1.0.1",
"roboto-fontface": "*",
Expand Down
4 changes: 4 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
item-title="name"
item-value="file"
label="Current save"
append-icon="mdi-refresh"
@click:append="store.refreshAvailableSaves();"
variant="plain"
flat
:loading="store.loadingSaves"
:disabled="store.loadingSaves"
hide-details
></v-select>
<v-btn
Expand Down
1 change: 1 addition & 0 deletions src/components/TabSwitch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ const tabs = shallowRef([
.tabs {
border-bottom: 1px solid #333;
overflow: initial !important;
}
</style>
26 changes: 22 additions & 4 deletions src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import lzf from 'lzfjs';
import { reactive, toRaw } from 'vue';
import tldParser, { slotParser } from './tldSave/tldParser';
import parser from './tldSave/tldParser';
import async from 'async';
import async, { forEach } from 'async';
import path from 'path';

interface GameSave {
Expand All @@ -21,35 +21,53 @@ const store = {

availableSaves: [] as SaveSlot[],
currentSave: undefined as undefined | GameSave,
loadingSaves: false,

get global() {
return this.currentSave?.data?.m_Dict?.global;
},

async refreshAvailableSaves() {
this.loadingSaves = true;
this.availableSaves = [];
const saveFileRegex =
/^(ep[0-9])?(sandbox|challenge|story|relentless)[0-9]+$/;

if (!process.env.LOCALAPPDATA) throw new Error('LOCALAPPDATA is not set');

const saveFolder = path.join(
process.env.LOCALAPPDATA,
'Hinterland',
'TheLongDark',
'Survival'
'TheLongDark'
);
const files = (await readdir(saveFolder)).filter((file) =>
saveFileRegex.test(file)
);
const survivalFiles = (
await readdir(path.join(saveFolder, 'Survival'))
).filter((file) => saveFileRegex.test(file));

const slots = await async.mapSeries(files, async (file: string) => {
const fileFullPath = path.join(saveFolder, file);
const buf = await readFile(fileFullPath);
const slotData = slotParser.parse(buf);
return {
file: fileFullPath,
name: slotData?.m_Name || '',
name: slotData?.m_DisplayName || "Unnkown"
};
});

await forEach(survivalFiles, async (file: string) => {
const fileFullPath = path.join(saveFolder, 'Survival', file);
const buf = await readFile(fileFullPath);
const slotData = slotParser.parse(buf);
slots.unshift({
file: fileFullPath,
name: slotData?.m_DisplayName || "Unnkown"
});
});

this.loadingSaves = false;
this.availableSaves = slots;
},
async loadSave(file: string) {
Expand Down
1 change: 1 addition & 0 deletions src/tldSave/availableItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ const availableItems: ItemInfo[] = [
createTool('GEAR_RevolverAmmoBox', { stackable: { m_UnitsProxy: 12 } }),
createTool('GEAR_RevolverAmmoCasing', { stackable: { m_UnitsProxy: 1 } }),
createTool('GEAR_Rifle', { weapon: { m_Clip: [] } }),
createTool('GEAR_Rifle_Vaughns', { weapon: { m_Clip: [] } }),
createTool('GEAR_RifleAmmoBox', { stackable: { m_UnitsProxy: 6 } }),
createTool('GEAR_RifleAmmoCasing', { stackable: { m_UnitsProxy: 1 } }),
createTool('GEAR_RifleCleaningKit'),
Expand Down
2 changes: 1 addition & 1 deletion src/tldSave/tldParser/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ const globalParser = parseObject({
headache: parseObject().from('m_HeadacheSerialized').json().withFields<HeadacheParams>(),
musicEvent: parseObject().from('m_MusicEventManagerSerialized').json().withFields<MusicEventSaveData>(),
chimney: parseObject({
data: parseArray(parseObject().json().withFields<LinkedChimneySaveData>()).from('m_SerializedChimneyData'),
data: parseArray(parseObject().withFields<LinkedChimneySaveData>()).from('m_SerializedChimneyData'),
})
.from('m_ChimneyDataSerialized')
.json()
Expand Down
7 changes: 5 additions & 2 deletions src/tldSave/types/generated/SlotData.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import type SaveSlotType from './enums/SaveSlotType';
import type DLC from './enums/DLC';
import type Episode from './enums/Episode';

export default interface SlotData {
m_Name?: string | null;
m_BaseName?: string | null;
m_InternalName?: string | null; //NEW
m_DisplayName?: string | null;
m_Timestamp?: string | null;
m_GameMode?: SaveSlotType;
m_GameId?: number;
m_Episode?: Episode;
m_InstalledOptionalContent?: Array<DLC>;
m_Dict?: Record<(string), (Array<number> | null)> | null;
m_IsPS4Compliant?: boolean;
m_VersionChangelistNumber?: number;
}
m_Version?: number;
}
4 changes: 4 additions & 0 deletions src/tldSave/types/generated/enums/DLC.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
enum DLC {
DLC01 = 'DLC01'
}
export default DLC;

0 comments on commit 9bda2a0

Please sign in to comment.