forked from jamesthejellyfish/isaac-save-edit-script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgui_support.py
250 lines (218 loc) · 9.66 KB
/
gui_support.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Support module generated by PAGE version 8.0
# in conjunction with Tcl version 8.6
# Feb 10, 2024 09:53:26 AM EST platform: Windows NT
import sys
import tkinter as tk
import tkinter.ttk as ttk
from tkinter import filedialog as fd
from tkinter.constants import *
import gui
import script
import os
_debug = False # False to eliminate debug printing from callback functions.
global_info = {"filename": "", "data": None, "current_character": "", "character_widget": None, "secrets_widget": None, "items_widget": None, "challenges_widget": None, "donation_widget": None, "greed_widget": None, "streak_widget": None, "eden_widget": None}
current_character = ""
characters = ["Isaac", "Maggy", "Cain", "Judas", "???", "Eve", "Samson", "Azazel",
"Lazarus", "Eden", "The Lost", "Lilith", "Keeper", "Apollyon", "Forgotten", "Bethany",
"Jacob & Esau", "T Isaac", "T Maggy", "T Cain", "T Judas", "T ???", "T Eve", "T Samson", "T Azazel",
"T Lazarus", "T Eden", "T Lost", "T Lilith", "T Keeper", "T Apollyon", "T Forgotten", "T Bethany",
"T Jacob"]
def main(*args):
'''Main entry point for the application.'''
global root
root = tk.Tk()
root.protocol( 'WM_DELETE_WINDOW' , root.destroy)
# Creates a toplevel widget.
global _top1, _w1
_top1 = root
_w1 = gui.Toplevel1(_top1)
root.mainloop()
def setInfo(key, value):
global_info[key] = value
def unlockAll(*args):
if _debug:
print('gui_support.unlockAll')
for arg in args:
print (' another arg:', arg)
sys.stdout.flush()
global_info["data"] = script.updateCheckListUnlocks(global_info["data"], characters.index(global_info["current_character"]), [2] * 12)
saveFile()
populateAllInfo()
def openSaveFile(*args):
if _debug:
print('gui_support.openSaveFile')
for arg in args:
print (' another arg:', arg)
sys.stdout.flush()
initpath = os.getcwd()
if os.path.exists(os.environ["ProgramFiles(x86)"] + "/Steam/userdata"):
initpath = os.environ["ProgramFiles(x86)"] + "/Steam/userdata"
elif os.path.exists(os.environ["ProgramFiles"] + "/Steam/userdata"):
initpath = os.environ["ProgramFiles"] + "/Steam/userdata"
filename = fd.askopenfilename(initialdir=initpath, filetypes = (('dat files', '*.dat'), ('all files', '*.*')))
with open(filename, "rb") as file:
global_info["data"] = file.read()
global_info["filename"] = filename
populateAllInfo()
def updateData(*args):
if _debug:
print('gui_support.updateData')
for arg in args:
print (' another arg:', arg)
sys.stdout.flush()
arg = args[0]
if arg.widget is not None:
checkbox = arg.widget
match str(checkbox):
case ".!notebook.!frame2.!frame3.!frame":
if _debug:
print("Completion mark page")
checked = checkbox.get_checked()
current_character = global_info["current_character"]
if current_character != "":
new_data = [0] * 12
for mark in checked:
new_data[int(mark)] = 2
global_info["data"] = script.updateCheckListUnlocks(global_info["data"],characters.index(current_character), new_data)
if _debug:
print(checked)
print(new_data)
case ".!notebook.!frame3.!frame.!frame":
if _debug:
print("Secrets page")
global_info["data"] = script.updateSecrets(global_info["data"], checkbox.get_checked())
case ".!notebook.!frame4.!frame":
if _debug:
print("Items page")
print(checkbox.get_checked())
global_info["data"] = script.updateItems(global_info["data"], checkbox.get_checked())
case ".!notebook.!frame5.!frame":
if _debug:
print("Challenges page")
print(checkbox.get_checked())
global_info["data"] = script.updateChallenges(global_info["data"], checkbox.get_checked())
saveFile()
def saveFile():
with open(global_info["filename"], 'wb') as file:
file.write(script.updateChecksum(global_info["data"]))
def populateAllInfo(*args):
if _debug:
print('gui_support.populateAllInfo')
print(f"current_character:{global_info['current_character']}")
print(global_info["challenges_widget"])
#global_info["challenges_widget"].change_state("3", "checked")
if global_info["current_character"] != "":
char_data = script.getChecklistUnlocks(global_info["data"], characters.index(global_info["current_character"]))
for num, name in enumerate(char_data):
val = "checked"
if name == 0:
val = "unchecked"
global_info["character_widget"].change_state(str(num), val)
global_info["streak_widget"].set(str(script.getInt(global_info["data"], script.getSectionOffsets(global_info["data"])[1] + 0x4 + 0x54)))
global_info["donation_widget"].set(str(script.getInt(global_info["data"], script.getSectionOffsets(global_info["data"])[1] + 0x4 + 0x4C)))
global_info["eden_widget"].set(str(script.getInt(global_info["data"], script.getSectionOffsets(global_info["data"])[1] + 0x4 + 0x50)))
global_info["greed_widget"].set(str(script.getInt(global_info["data"], script.getSectionOffsets(global_info["data"])[1] + 0x4 + 0x1B0)))
item_data = script.getItems(global_info["data"])
bad_entries = [43,59,61,235,587,613,620,630,648,656,662,666,718]
for num, name in enumerate(item_data):
if num + 1 in bad_entries:
continue
val = "checked"
if name == 0:
val = "unchecked"
global_info["items_widget"].change_state(str(num+1), val)
challenge_data = script.getChallenges(global_info["data"])
for num, name in enumerate(challenge_data):
val = "checked"
if name == 0:
val = "unchecked"
global_info["challenges_widget"].change_state(str(num+1), val)
secret_data = script.getSecrets(global_info["data"])
for num, name in enumerate(secret_data):
val = "checked"
if name == 0:
val = "unchecked"
global_info["secrets_widget"].change_state(str(num+1), val)
def unlockAllChallenges(*args):
if _debug:
print('gui_support.unlockAllChallenges')
for arg in args:
print (' another arg:', arg)
sys.stdout.flush()
global_info["data"] = script.updateChallenges(global_info["data"], [str(i) for i in range(1, 46)])
saveFile()
populateAllInfo()
def unlockAllChars(*args):
if _debug:
print('gui_support.unlockAllChars')
for arg in args:
print (' another arg:', arg)
sys.stdout.flush()
for character in range(34):
global_info["data"] = script.updateCheckListUnlocks(global_info["data"], character, [2] * 12)
saveFile()
populateAllInfo()
def unlockAllItems(*args):
if _debug:
print('gui_support.unlockAllItems')
for arg in args:
print (' another arg:', arg)
sys.stdout.flush()
global_info["data"] = script.updateItems(global_info["data"], [str(i) for i in range(1, 733)])
saveFile()
populateAllInfo()
def unlockAllSecrets(*args):
if _debug:
print('gui_support.unlockAllSecrets')
for arg in args:
print (' another arg:', arg)
sys.stdout.flush()
global_info["data"] = script.updateSecrets(global_info["data"], [str(i) for i in range(1, 641)])
saveFile()
populateAllInfo()
def updateDonationMachine(*args):
if _debug:
print('gui_support.updateDonationMachine')
for arg in args:
print (' another arg:', arg)
sys.stdout.flush()
global_info["data"] = script.alterInt(global_info["data"], script.getSectionOffsets(global_info["data"])[1] + 0x4 + 0X4C, int(args[0]))
saveFile()
def updateEdenTokens(*args):
if _debug:
print('gui_support.updateEdenTokens')
for arg in args:
print (' another arg:', arg)
sys.stdout.flush()
global_info["data"] = script.alterInt(global_info["data"], script.getSectionOffsets(global_info["data"])[1] + 0x4 + 0X50, int(args[0]))
saveFile()
def updateGreedMachine(*args):
if _debug:
print('gui_support.updateGreedMachine')
for arg in args:
print (' another arg:', arg)
sys.stdout.flush()
global_info["data"] = script.alterInt(global_info["data"], script.getSectionOffsets(global_info["data"])[1] + 0x4 + 0x1B0, int(args[0]))
saveFile()
def updateCharacter(*args):
if _debug:
print('gui_support.updateCharacter')
for arg in args:
print (' another arg:', arg)
sys.stdout.flush()
arg = args[0]
global_info["current_character"] = arg
populateAllInfo()
def updateWinStreak(*args):
if _debug:
print('gui_support.updateWinStreak')
for arg in args:
print (' another arg:', arg)
sys.stdout.flush()
global_info["data"] = script.alterInt(global_info["data"], script.getSectionOffsets(global_info["data"])[1] + 0x4 + 0x54, int(args[0]))
saveFile()
if __name__ == '__main__':
gui.start_up()