-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
138 lines (123 loc) · 3.66 KB
/
Copy pathmain.py
File metadata and controls
138 lines (123 loc) · 3.66 KB
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
import subprocess
import threading
from tkinter import *
from tkinter.ttk import *
import lib
from rom import ROM
from patch import Patch
class Application(Frame):
def __init__(self, master=None):
super().__init__(master)
self.patch_file_name = StringVar()
self.patch_description = StringVar()
self.pack()
self.create_widgets()
def create_widgets(self):
self.patch_file_name_entry = Entry(
self,
textvariable=self.patch_file_name
)
self.patch_file_name_label = Label(self, text='File name:')
self.patch_description_entry = Entry(
self,
textvariable=self.patch_description
)
self.patch_description_label = Label(self, text='Description:')
self.separator = Separator(self)
self.edit_button = Button(self)
self.edit_button['text'] = 'Edit ROM'
self.edit_button['command'] = self.edit_rom
self.save_patch_button = Button(self)
self.save_patch_button['text'] = 'Save Patch'
self.save_patch_button['command'] = self.save_patch
self.rebuild_button = Button(self)
self.rebuild_button['text'] = 'Rebuild From Patch List'
self.rebuild_button['command'] = self.rebuild_rom
self.launch_button = Button(self)
self.launch_button['text'] = 'Launch Game'
self.launch_button['command'] = self.launch_emulator
self.patch_file_name_label.grid(
row=0,
column=0,
padx=2,
pady=5
)
self.patch_file_name_entry.grid(
row=0,
column=1,
columnspan=2,
)
self.patch_description_label.grid(
row=1,
column=0,
padx=2,
pady=5
)
self.patch_description_entry.grid(
row=1,
column=1,
columnspan=2,
)
self.separator.grid(row=2, column=0, ipady=5)
self.edit_button.grid(
row=3,
column=0,
pady=5,
ipady=5
)
self.save_patch_button.grid(
row=3,
column=1,
pady=5,
ipady=5
)
self.rebuild_button.grid(
row=3,
column=2,
pady=5,
ipady=5
)
self.launch_button.grid(
row=4,
column=0,
columnspan=3,
pady=5,
ipady=5
)
def run_editor(self):
config = lib.get_config()
subprocess.run([config['editor'], config['project_rom']])
def launch_emulator(self):
config = lib.get_config()
subprocess.run([config['emulator'], config['project_rom']])
def edit_rom(self):
threading.Thread(target=self.run_editor).start()
def save_patch(self):
config = lib.get_config()
base_rom = lib.build_rom()
project_rom = ROM.from_file(config['project_rom'])
patch = Patch.from_roms(
self.patch_file_name.get(),
False,
True,
self.patch_description.get(),
base_rom,
project_rom
)
patch.save()
patched_rom = lib.build_rom()
patched_rom.save_to_file(config['project_rom'])
def rebuild_rom(self):
config = lib.get_config()
rom = lib.build_rom()
rom.save_to_file(config['project_rom'])
def emulate(self):
threading.Thread(target=self.launch_emulator).start()
def main():
root = Tk()
root.title('FF3 ROM Builder')
root.minsize(240, 100)
app = Application(master=root)
app.mainloop()
main()
# vi: et sw=4 ts=4 tw=79