Skip to content

Commit 2063017

Browse files
committed
v3b.2.0 - Support for other Telltale Games added, Priority Settings added
1 parent c14b57e commit 2063017

File tree

10 files changed

+143
-24
lines changed

10 files changed

+143
-24
lines changed

src/main/EditorMenu.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export const getEditorMenu = (window: BrowserWindow, state: Readonly<AppState>)
129129
{
130130
//Mawrak Tweaks - changed links to my fork
131131
label: 'Docs',
132-
click: () => shell.openExternal('https://github.com/Mawrak/Telltale-Script-Editor-Tweaks/wiki')
132+
click: () => shell.openExternal('https://github.com/Mawrak/Telltale-Script-Editor-Tweaks')
133133
},
134134
{
135135
label: 'About',

src/main/handlers/BuildProject.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ import {
1010
ResourceDescription
1111
} from './ResdescUtils';
1212
import crypto from 'crypto';
13+
import {BrowserWindow, dialog, shell, Menu} from 'electron';
14+
import { getFiles, getFilesInDirectory, getIPCMainChannelSource, openBuildsDirectory } from '../utils';
15+
1316

1417
const generateHash = (string: string) => {
1518
const hash = crypto.createHash('md5');
@@ -28,18 +31,23 @@ type Hash = string;
2831
type Cache = { tseproj?: Hash } & Record<string, Record<string, Hash>>;
2932
export type Logger = (message: string) => void;
3033

31-
const writeResourceDescription = async (project: Project, resdesc: ResourceDescription, cachePath: string, log: Logger) => {
34+
35+
36+
const writeResourceDescription = async (project: Project, resdesc: ResourceDescription, cachePath: string, log: Logger, gameNumber:number, PrioritySetting:number) => {
37+
38+
3239
const resdescOutputPath = path.join(cachePath, generateResourceDescriptionName(project, resdesc));
3340

3441
await fs.mkdir(path.dirname(resdescOutputPath), {recursive: true});
35-
36-
await fs.writeFile(resdescOutputPath, generateResourceDescriptionContents(project, resdesc));
37-
const process = exec(`resources\\ttarchext.exe -V 7 -e 0 -o 67 "${resdescOutputPath}" "${cachePath}"`, (e, out, err) => {
42+
//const gameNumber = useAppSelector(state => state.storage.gameNumber);
43+
await fs.writeFile(resdescOutputPath, generateResourceDescriptionContents(project, resdesc, PrioritySetting));
44+
const process = exec(`resources\\ttarchext.exe -V 7 -e 0 -o ${gameNumber} "${resdescOutputPath}" "${cachePath}"`, (e, out, err) => {
3845
log(out);
3946
log(err);
4047
});
4148

4249
await new Promise(resolve => process.addListener('close', resolve));
50+
4351
};
4452

4553
const compileLua = async (filePath: string, projectPath: string, cachePath: string, log: Logger) => {
@@ -59,10 +67,10 @@ const compileLua = async (filePath: string, projectPath: string, cachePath: stri
5967
if (error) throw new Error(error);
6068
};
6169

62-
export const buildProject = async (log: Logger, state: AppState, { projectPath, project }: { projectPath: string, project: Project }): Promise<ModInfo | void> => {
70+
export const buildProject = async (log: Logger, state: AppState, { projectPath, project}: { projectPath: string, project: Project, gameNumber: number}, gameNumber : number, PrioritySetting : number): Promise<ModInfo | void> => {
6371
const buildsPath = path.join(projectPath, 'Builds');
6472
const cachePath = path.join(buildsPath, 'cache');
65-
73+
//const gameNumberConst = projectPath.gameNumber;
6674
let previousCache: Cache;
6775

6876
try {
@@ -130,7 +138,7 @@ export const buildProject = async (log: Logger, state: AppState, { projectPath,
130138

131139
log(`============== Generating ${resdescName}...`);
132140

133-
tasks.push(writeResourceDescription(project, resdesc, cachePath, log));
141+
tasks.push(writeResourceDescription(project, resdesc, cachePath, log, gameNumber, PrioritySetting));
134142
continue;
135143
}
136144

@@ -179,7 +187,7 @@ export const buildProject = async (log: Logger, state: AppState, { projectPath,
179187

180188
log(`============== Generating ${ttarchFilePath} from ${archivePath}...`);
181189

182-
const process = exec(`resources\\ttarchext.exe -b -o 67 "${ttarchFilePath}" "${archivePath}"`, (error, stdout, stderr) => {
190+
const process = exec(`resources\\ttarchext.exe -b -o ${gameNumber} "${ttarchFilePath}" "${archivePath}"`, (error, stdout, stderr) => {
183191
log(stdout);
184192
log(stderr);
185193
});

src/main/handlers/IPCHandlers.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ export const registerIPCHandlers = (window: BrowserWindow) => {
194194
GetGamePathChannel(source).handle(async () => {
195195
await dialog.showMessageBox({
196196
title: 'Select executable',
197-
message: 'Please select the executable file for Telltale\'s The Walking Dead: Definitive Edition',
197+
message: 'Please select the executable file for the target game.',
198198
type: 'warning'
199199
});
200200

@@ -223,12 +223,13 @@ export const registerIPCHandlers = (window: BrowserWindow) => {
223223
}
224224

225225
BuildProjectChannel(source).handle(async data => {
226-
const modInfo = await buildProject(log, state, data);
226+
const modInfo = await buildProject(log, state, data, data.gameNumber, data.PrioritySetting);
227227

228228
if (!modInfo) return;
229229

230230
const buildsPath = path.join(data.projectPath, 'Builds');
231231
const cachePath = path.join(buildsPath, 'cache');
232+
//const gameNumberConst = data.gameNumber;
232233

233234
const zipFileName = `build-${format(new Date(), "yyyy-MM-dd'T'HH-mm-ss")}.zip`;
234235
log(`============== Creating ${zipFileName}...`);
@@ -274,7 +275,7 @@ export const registerIPCHandlers = (window: BrowserWindow) => {
274275
modinfo?: string
275276
};
276277

277-
RunProjectChannel(source).handle(async ({ project, projectPath, gamePath, modBuildPath }) => {
278+
RunProjectChannel(source).handle(async ({ project, projectPath, gamePath, modBuildPath, gameNumber, PrioritySetting }) => {
278279
//Mawrak tweaks - added ability to choose mod folder
279280

280281
let archivesPath = path.join(path.dirname(gamePath), 'Archives');
@@ -286,7 +287,7 @@ export const registerIPCHandlers = (window: BrowserWindow) => {
286287

287288
const cachePath = path.join(projectPath, 'Builds', 'cache');
288289

289-
const modInfo = await buildProject(log, state, {project, projectPath});
290+
const modInfo = await buildProject(log, state, {project, projectPath, gameNumber}, gameNumber, PrioritySetting);
290291

291292
if (!modInfo) return;
292293

src/main/handlers/ResdescUtils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export const createResourceDescription = (project: Project, archive: string): Re
4343
};
4444
};
4545

46-
export const generateResourceDescriptionContents = (project: Project, { setName, enableMode, setVersion, ttarchName }: ResourceDescription) => `
46+
export const generateResourceDescriptionContents = (project: Project, { setName, enableMode, setVersion, ttarchName }: ResourceDescription, PrioritySetting: number) => `
4747
--This file was automatically generated by the Telltale Script Editor, available at https://github.com/Telltale-Modding-Group/Telltale-Script-Editor"
4848
--File associated with '${project.mod.name}' by ${project.mod.author}, version ${project.mod.version}
4949
local set = {}
@@ -52,13 +52,13 @@ set.setName = "${setName}"
5252
set.descriptionFilenameOverride = ""
5353
set.logicalName = "<>" --Empty for now, band-aid fix for later.
5454
set.logicalDestination = "<>"
55-
set.priority = 30
55+
set.priority = ${PrioritySetting}
5656
set.localDir = _currentDirectory
5757
set.enableMode = "${enableMode}"
5858
set.version = "${setVersion}"
5959
set.descriptionPriority = 0
6060
set.gameDataName = "${setName} Game Data"
61-
set.gameDataPriority = 30
61+
set.gameDataPriority = ${PrioritySetting}
6262
set.gameDataEnableMode = "constant"
6363
set.localDirIncludeBase = true
6464
set.localDirRecurse = false

src/renderer/components/Builds.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export const Builds = () => {
6363
</Code>
6464

6565
<Group position="right" p="xs">
66-
<Button onClick={handleClearBuildArchives} color="red">Clear Build Archives</Button>
66+
<Button onClick={handleClearBuildArchives} color="red">Clear Cached Build Archives</Button>
6767
<Button onClick={handleOpenBuildsDirectory}>Open Builds Directory</Button>
6868
</Group>
6969
</Stack>

src/renderer/components/modals/AboutModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export const AboutModal = () => {
55
return <Container>
66
<Stack align="center">
77
<Title order={1}>Telltale Script Editor + Tweaks</Title>
8-
<Text>Version 3b.1.0</Text>
8+
<Text>Version 3b.2.0</Text>
99
</Stack>
1010
</Container>
1111
};

src/renderer/components/modals/SettingsModal.tsx

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ import {OverlayActions} from '../../slices/OverlaySlice';
99

1010
export const SettingsModal = ({context, id}: ContextModalProps) => {
1111
const dispatch = useAppDispatch();
12+
//Mawrak Tweaks - new setting - Game number
13+
const gameNumber = useAppSelector(state => state.storage.gameNumber);
14+
//Mawrak Tweaks - new setting - Priority
15+
const PrioritySetting = useAppSelector(state => state.storage.PrioritySetting)
1216
const gameExePath = useAppSelector(state => state.storage.gamePath);
1317
const maximumBuildsToKeep = useAppSelector(state => state.storage.maximumBuildsToKeep);
1418
const saveFilesOnBuild = useAppSelector(state => state.storage.saveFilesOnBuild);
@@ -42,6 +46,98 @@ export const SettingsModal = ({context, id}: ContextModalProps) => {
4246
return <Container>
4347
<Stack>
4448
<Title order={1}>Settings</Title>
49+
<Select
50+
required
51+
label="Select Target Game"
52+
placeholder="Pick a game to set Game number."
53+
description="Most games from 58 to 67 should work. Support for older games is untested."
54+
defaultValue={String(gameNumber)}
55+
data={[
56+
{ value: '0', label: '0 Wallace & Gromit: Episode 1: Fright of the Bumblebees' },
57+
{ value: '1', label: '1 Wallace & Gromit: Episode 2: The Last Resort' },
58+
{ value: '2', label: '2 Wallace & Gromit: Episode 3: Muzzled' },
59+
{ value: '3', label: '3 Telltale Texas Hold-em' },
60+
{ value: '4', label: '4 Bone: Out From Boneville' },
61+
{ value: '5', label: '5 Bone: The Great Cow Race' },
62+
{ value: '6', label: '6 Sam & Max: Episode 101 - Culture Shock' },
63+
{ value: '7', label: '7 Sam & Max: Episode 102 - Situation: Comedy' },
64+
{ value: '8', label: '8 Sam & Max: Episode 103 - The Mole, The Mob, and the Meatball' },
65+
{ value: '9', label: '9 Sam & Max: Episode 104 - Abe Lincoln Must Die!' },
66+
{ value: '10', label: '10 Sam & Max: Episode 105 - Reality 2.0' },
67+
{ value: '11', label: '11 Sam & Max: Episode 106 - Bright Side of the Moon' },
68+
{ value: '12', label: '12 Sam & Max: Episode 201 - Ice Station Santa' },
69+
{ value: '13', label: '13 Sam & Max: Episode 202 - Moai Better Blues' },
70+
{ value: '14', label: '14 Sam & Max: Episode 203 - Night of the Raving Dead' },
71+
{ value: '15', label: '15 Sam & Max: Episode 204 - Chariots of the Dogs' },
72+
{ value: '16', label: '16 Sam & Max: Episode 205 - Whats New, Beelzebub' },
73+
{ value: '17', label: '17 Strong Bad: Episode 1 - Homestar Ruiner' },
74+
{ value: '18', label: '18 Strong Bad: Episode 2 - Strong Badia the Free' },
75+
{ value: '19', label: '19 Strong Bad: Episode 3 - Baddest of the Bands' },
76+
{ value: '20', label: '20 Strong Bad: Episode 4 - Daneresque 3' },
77+
{ value: '21', label: '21 Strong Bad: Episode 5 - 8-Bit Is Enough' },
78+
{ value: '22', label: '22 CSI 3 - Dimensions of Murder / Bone demo' },
79+
{ value: '23', label: '23 CSI 4 - Hard Evidence (demo)' },
80+
{ value: '24', label: '24 Tales of Monkey Island 101: Launch of the Screaming Narwhal' },
81+
{ value: '25', label: '25 Wallace & Gromit: Episode 4: The Bogey Man' },
82+
{ value: '26', label: '26 Tales of Monkey Island 102: The Siege of Spinner Cay' },
83+
{ value: '27', label: '27 Tales of Monkey Island 103: Lair of the Leviathan' },
84+
{ value: '28', label: '28 CSI 5 - Deadly Intent' },
85+
{ value: '29', label: '29 Tales of Monkey Island 104: The Trial and Execution of Guybrush Threepwood' },
86+
{ value: '30', label: '30 CSI 4 - Hard Evidence' },
87+
{ value: '31', label: '31 Tales of Monkey Island 105: Rise of the Pirate God' },
88+
{ value: '32', label: '32 CSI 5 - Deadly Intent (demo)' },
89+
{ value: '33', label: '33 Sam & Max: Episode 301 - The Penal Zone' },
90+
{ value: '34', label: '34 Sam & Max: Episode 302 - The Tomb of Sammun-Mak' },
91+
{ value: '35', label: '35 Sam & Max: Episode 303 - They Stole Maxs Brain!' },
92+
{ value: '36', label: '36 Puzzle Agent - The Mystery of Scoggins' },
93+
{ value: '37', label: '37 Sam & Max: Episode 304 - Beyond the Alley of the Dolls' },
94+
{ value: '38', label: '38 Sam & Max: Episode 305 - The City That Dares Not Sleep' },
95+
{ value: '39', label: '39 Poker Night at the Inventory' },
96+
{ value: '40', label: '40 CSI 6 - Fatal Conspiracy' },
97+
{ value: '41', label: '41 Back To The Future: Episode 1 - Its About Time' },
98+
{ value: '42', label: '42 Back To The Future: Episode 2 - Get Tannen!' },
99+
{ value: '43', label: '43 Back To The Future: Episode 3 - Citizen Brown' },
100+
{ value: '44', label: '44 Hector: Episode 1 - We Negotiate with Terrorists' },
101+
{ value: '45', label: '45 Back To The Future: Episode 4 - Double Visions' },
102+
{ value: '46', label: '46 Back To The Future: Episode 5 - OUTATIME' },
103+
{ value: '47', label: '47 Puzzle Agent 2' },
104+
{ value: '48', label: '48 Jurassik Park: The Game' },
105+
{ value: '49', label: '49 Hector: Episode 2 - Senseless Act of Justice' },
106+
{ value: '50', label: '50 Hector: Episode 3 - Beyond Reasonable Doom' },
107+
{ value: '51', label: '51 Law and Order: Legacies' },
108+
{ value: '52', label: '52 Walking Dead: A New Day' },
109+
{ value: '53', label: '53 Poker Night 2' },
110+
{ value: '54', label: '54 The Wolf Among Us' },
111+
{ value: '55', label: '55 The Walking Dead: Season 2' },
112+
{ value: '56', label: '56 Tales from the Borderlands' },
113+
{ value: '57', label: '57 Game of Thrones' },
114+
{ value: '58', label: '58 Minecraft: Story Mode' },
115+
{ value: '59', label: '59 The Walking Dead: Michonne' },
116+
{ value: '60', label: '60 Batman: The Telltale Series' },
117+
{ value: '61', label: '61 The Walking Dead: A New Frontier' },
118+
{ value: '62', label: '62 Marvels Guardians of the Galaxy' },
119+
{ value: '63', label: '63 Minecraft: Story Mode - Season Two' },
120+
{ value: '64', label: '64 Batman: The Enemy Within' },
121+
{ value: '65', label: '65 Bone: Out From Boneville 2.0' },
122+
{ value: '66', label: '66 Bone: The Great Cow Race 2.0' },
123+
{ value: '67', label: '67 The Walking Dead: The Telltale Definitive Series' },
124+
]}
125+
onChange={e => dispatch(StorageActions.setGameNumber(Number(e) ?? Number('67')))}
126+
/>
127+
<NumberInput
128+
required
129+
label="ttarchext Game number"
130+
description="Default is 67 (TWDTTDS)."
131+
value={gameNumber}
132+
onChange={e => dispatch(StorageActions.setGameNumber(e ?? 67))}
133+
/>
134+
<NumberInput
135+
required
136+
label="Priority"
137+
description="Set to 30 if editing TWDTTDS's main menu. Set to 1100 if overwriting existing Telltale assets. Default is 30."
138+
value={PrioritySetting}
139+
onChange={e => dispatch(StorageActions.setPrioritySetting(e ?? 30))}
140+
/>
45141
<TextInput
46142
required
47143
label="Game Executable"

src/renderer/hooks.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ export const useBuildProject = () => {
1111
const dispatch = useAppDispatch();
1212
const projectPath = useAppSelector(state => state.filetree.root?.path);
1313
const project = useAppSelector(state => state.project.currentProject);
14+
const gameNumber = useAppSelector(state => state.storage.gameNumber);
15+
const PrioritySetting = useAppSelector(state => state.storage.PrioritySetting);
1416
const gameExePath = useAppSelector(state => state.storage.gamePath);
1517
const saveFilesOnBuild = useAppSelector(state => state.storage.saveFilesOnBuild);
1618
const modBuildPath2 = useAppSelector(state => state.storage.modBuildPath);
@@ -22,7 +24,7 @@ export const useBuildProject = () => {
2224

2325
dispatch(BuildsActions.clearLogs());
2426
dispatch(SidebarActions.setActiveTab('logs'));
25-
const buildZipPath = await MainProcess.buildProject({ projectPath, project });
27+
const buildZipPath = await MainProcess.buildProject({ projectPath, project, gameNumber, PrioritySetting });
2628
dispatch(FileTreeAsyncActions.refreshRootDirectory());
2729

2830
if (!buildZipPath) {
@@ -62,7 +64,7 @@ export const useBuildProject = () => {
6264
}
6365

6466
try {
65-
await MainProcess.runProject({ projectPath, project, gamePath, modBuildPath});
67+
await MainProcess.runProject({ projectPath, project, gamePath, modBuildPath, gameNumber, PrioritySetting});
6668
} catch {
6769
showNotification({
6870
title: 'Unexpected Error',

src/renderer/slices/StorageSlice.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import {setSelectedTheme} from '../renderer';
88

99
interface StorageState {
1010
initialised: boolean,
11+
gameNumber: number,
12+
PrioritySetting: number,
1113
gamePath?: string,
1214
modBuildPath?: string,
1315
sidebarWidth: number,
@@ -19,26 +21,35 @@ interface StorageState {
1921

2022
const initialState: StorageState = {
2123
initialised: false,
24+
gameNumber: 67,
2225
sidebarWidth: 250,
2326
recentProjects: [],
2427
maximumBuildsToKeep: 5,
2528
saveFilesOnBuild: true,
26-
selectedTheme: "light"
29+
selectedTheme: "light",
30+
PrioritySetting: 30
2731
};
2832

2933
// NOTE: This is automatically synchronised with a config file on disk to persist data between application restarts.
3034
export const StorageSlice = createSlice({
3135
name: 'storage',
3236
initialState,
3337
reducers: {
38+
//Mawrak Tweaks - new setting - Game number
39+
setGameNumber: (state, {payload}: PayloadAction<number>) => {
40+
state.gameNumber = payload
41+
},
42+
//Mawrak Tweaks - new setting - Priority
43+
setPrioritySetting: (state, {payload}: PayloadAction<number>) => {
44+
state.PrioritySetting = payload
45+
},
3446
setGamePath: (state, {payload}: PayloadAction<string | undefined>) => {
3547
state.gamePath = payload
3648
},
3749
//Mawrak Tweaks - new setting - Mod Folder
3850
setModPath: (state, {payload}: PayloadAction<string | undefined>) => {
3951
state.modBuildPath = payload
4052
},
41-
4253
setSidebarWidth: (state, {payload}: PayloadAction<number>) => {
4354
state.sidebarWidth = Math.round(Math.max(payload, initialState.sidebarWidth));
4455
},

src/shared/Channels.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@ export const RenameFileChannel = createInvokableChannel<{ file: EditorFile, newN
3939
export const DeleteFileChannel = createInvokableChannel<EditorFile, void>('deletefile');
4040
export const CreateFileChannel = createInvokableChannel<{ directoryPath: string, extension: string }, string>('createfile');
4141
export const CreateDirectoryChannel = createInvokableChannel<string, string>('createdirectory');
42-
export const BuildProjectChannel = createInvokableChannel<{ projectPath: string, project: Project }, string | undefined>('buildproject');
42+
export const BuildProjectChannel = createInvokableChannel<{ projectPath: string, project: Project, gameNumber: number, PrioritySetting: number}, string | undefined>('buildproject');
4343
export const GetGamePathChannel = createInvokableChannel<void, string | undefined>('getgamepath');
4444
export const GetLocalStoreChannel = createInvokableChannel<void, AppState["storage"]>('getlocalstore');
45-
export const RunProjectChannel = createInvokableChannel<{ projectPath: string, project: Project, gamePath: string, modBuildPath: string}, void>('runproject');
45+
export const RunProjectChannel = createInvokableChannel<{ projectPath: string, project: Project, gamePath: string, modBuildPath: string, gameNumber: number, PrioritySetting: number}, void>('runproject');
46+
4647

4748
export const OpenInExplorerChannel = createChannel<string>('openinexplorer');
4849
export const MenuNewProjectChannel = createChannel('menu:newproject');

0 commit comments

Comments
 (0)