-
Notifications
You must be signed in to change notification settings - Fork 0
/
gui.rb
165 lines (137 loc) · 3.31 KB
/
gui.rb
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
require 'tk'
require 'tkextlib/tile'
load './extract.rb'
load './createPatch.rb'
def updateStatus(title, fPercent, tPercent)
if title != nil
$statusVar.value = title
end
if fPercent != nil
$pFile.value = fPercent
end
if tPercent != nil
$pTotal.value = tPercent
end
end
def updatedLoc
if $origLoc.value.length > 0
$extractButton.state = "normal"
if $patchLoc.value.length > 0
$patchButton.state = "normal"
else
$patchButton.state = "disabled"
end
else
$extractButton.state = "disabled"
$patchButton.state = "disabled"
end
end
def extractDone
updatedLoc
end
def callPatch
Thread.new {
createPatch($origLoc.value, $patchLoc.value)
}
end
def callExtract(dir)
Thread.new {
$extractButton.state = "disabled"
$patchButton.state = "disabled"
puts "THREAD: #{dir}"
extract dir
}
end
def browse(loc)
lv = Tk.chooseDirectory.force_encoding('SHIFT_JIS')
loc.value = lv.encode('SHIFT_JIS')
end
window = TkRoot.new() do
title "Patch tool"
geometry "360x247"
end
window['resizable'] = false, false
$pTotal = TkVariable.new
$pFile = TkVariable.new
isOrig = true
if isOrig
yOffs = 140
$origLoc = TkVariable.new
$origLoc.trace('w', proc{ updatedLoc })
TkButton.new(window) do
place('height' => 25, 'width' => 80, 'x' => 275, 'y' => 10 )
text "Browse..."
command (proc {browse $origLoc})
end
$patchLoc = TkVariable.new
$patchLoc.trace('w', proc{ updatedLoc })
TkButton.new(window) do
place('height' => 25, 'width' => 80, 'x' => 275, 'y' => 50 )
text "Browse..."
command (proc {browse patchLoc})
end
TkEntry.new(window) do
textvariable $origLoc
place('width' => 180, 'x' => 80, 'y' => 10)
end
TkEntry.new(window) do
textvariable $patchLoc
place('width' => 180, 'x' => 80, 'y' => 50)
end
TkLabel.new(window) do
text "Original:"
justify "left"
place('width' => 70, 'x' => 5, 'y' => 10)
end
TkLabel.new(window) do
text "Patched:"
justify "left"
place('width' => 70, 'x' => 5, 'y' => 50)
end
$extractButton = TkButton.new(window) do
place('height' => 35, 'width' => 130, 'x' => 33, 'y' => 90 )
text "Extract"
state "disabled"
command (proc {callExtract $origLoc.value})
end
$patchButton = TkButton.new(window) do
place('height' => 35, 'width' => 130, 'x' => 197, 'y' => 90 )
text "Create Patch"
state "disabled"
command (proc {callPatch})
end
end
totalBar = Tk::Tile::Progressbar.new(window) do
place('height' => 25, 'width' => 300, 'x' => 50, 'y' => 10 + yOffs)
maximum 100
variable $pTotal
end
fileBar = Tk::Tile::Progressbar.new(window) do
place('height' => 25, 'width' => 300, 'x' => 50, 'y' => 50 + yOffs)
maximum 100
variable $pFile
end
$statusVar = TkVariable.new
x = TkLabel.new(window) do
textvariable $statusVar
borderwidth 3
relief "groove"
place('height' => 25, 'width' => 362, 'x' => -1, 'y' => 85 + yOffs)
justify 'left'
end
$statusVar.value = "Status"
Tk::Tile::Separator.new(window) do
orient 'horizontal'
place('width' => 350, 'x' => 5, 'y' => 140)
end
TkLabel.new(window) do
text "Total:"
justify "left"
place('width' => 40, 'x' => 5, 'y' => 10 + yOffs)
end
TkLabel.new(window) do
text "File:"
justify "left"
place('width' => 40, 'x' => 5, 'y' => 50 + yOffs)
end
Tk.mainloop