-
Notifications
You must be signed in to change notification settings - Fork 8
/
win.txt
370 lines (339 loc) · 8.76 KB
/
win.txt
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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
____×Ó³ÌÐò_0(s)
print(s)
____½áÊø
____×Ó³ÌÐò_1()
tn = _com(1, 0)
print("dbgtime tn ," .. tn)
____½áÊø
____×Ó³ÌÐò_2()
dbglog("DoNothing()")
____½áÊø
____×Ó³ÌÐò_3(t, param1, param2)
if t == 8 then
nesExit()
else
winEvent(t, param1, param2)
end
____½áÊø
____×Ó³ÌÐò_4(param, event)
dbglog("win.new in!!")
local tmp = {}
if param then
dbglog("param in!!type: " .. type(param))
tmp.refresh = DoNothing
if type(param) == "function" then
dbglog("function")
tmp.refresh = param
else
if type(param) == "table" then
dbglog("table")
tmp.window = param
end
end
if event then
dbglog("have event")
tmp.dealevent = event
winEvent = event
end
table.insert(winStack, tmp)
win.top = tmp
dbglog("win.new out")
____½áÊø
____×Ó³ÌÐò_5(noExit)
dbglog(table.getn(winStack))
local destroyWin = table.remove(winStack)
if destroyWin.window then
destroyWin.window:close()
end
local currentWin = winStack[table.getn(winStack)]
win.top = currentWin
if currentWin then
if currentWin.refresh then
currentWin.refresh()
end
upper = currentWin.dealevent
dbglog("1 mem top =" .. TestCom(101, 0) .. ",min =" .. TestCom(100, 0))
_gc()
dbglog("2 mem top =" .. TestCom(101, 0) .. ",min =" .. TestCom(100, 0))
elseif noExit then
do break end
end
dbglog("winclosed -----exit ()" .. _com(101, 0))
nesExit()
Exit()
____½áÊø
____×Ó³ÌÐò_6()
dbglog("win.refresh()")
if not win.disRef and win.top then
dbglog("##########refresh in###########")
if win.top.refresh then
win.top.refresh()
else
if win.top.window and win.top.window.refresh then
win.top.window.refresh()
end
end
end
dbglog("1 mem top =" .. TestCom(101, 0) .. ",min =" .. TestCom(100, 0))
_gc()
dbglog("2 mem top =" .. TestCom(101, 0) .. ",min =" .. TestCom(100, 0))
____½áÊø
____×Ó³ÌÐò_7(n)
win.disRef = true
for i = 1, n do
win.close()
end
win.disRef = nil
____½áÊø
____×Ó³ÌÐò_9()
DispUpEx(0, 0, SCR_W, SCR_H)
____½áÊø
____×Ó³ÌÐò_10(self, item, index)
if index then
table.insert(self.items, index, item)
else
table.insert(self.items, item)
end
self.count = self.count + 1
____½áÊø
____×Ó³ÌÐò_11(self)
dbglog("menuShowFunc in, num: " .. self.count)
self.wnd = gui.m_create(charToUnicode(self.title), self.count)
for index, item in self.items do
dbglog("m_setitem: " .. index)
gui.m_setitem(self.wnd, charToUnicode(item[1]), index - 1)
end
gui.m_show(self.wnd)
dbglog("menuShowFunc out")
____½áÊø
____×Ó³ÌÐò_12(self)
dbglog("menuupdateFunc()")
for index, item in self.items do
gui.m_setitem(self.wnd, charToUnicode(item[1]), index - 1)
end
gui.m_update(self.wnd)
dbglog("menuupdateFunc()out")
____½áÊø
____×Ó³ÌÐò_13(self)
dbglog("menuClose()")
if self.wnd then
gui.m_release(self.wnd)
end
dbglog("menuClose()out")
____½áÊø
____×Ó³ÌÐò_14(menu, kind, param1, param2)
dbglog("kind=" .. kind .. ",param1=" .. param1)
if kind == 4 then
local item = menu.items[param1 + 1]
local d = item[2]
dbglog("type(d): " .. type(d))
if type(d) == "function" then
d(item, menu)
else
if type(d) == "table" then
dbglog("create new menu " .. item[1])
ugui.Menu(item)
elseif d == nil then
NesFunc(item)
elseif kind == 5 then
if type(menu.cancelFunc) == "function" then
menu.cancelFunc(menu)
else
win.close()
end
end
end
end
____½áÊø
____×Ó³ÌÐò_15(self)
return function(type, param1, param2)
_menuEvent(self, type, param1, param2)
end
____½áÊø
____×Ó³ÌÐò_16(title)
dbglog("ugui.MenuEx in")
local newMenu = {}
newMenu.items = {}
newMenu.count = 0
if not title then
newMenu.title = txt[6]
end
newMenu.add = menuAddFunc
newMenu.show = menuShowFunc
newMenu.update = menuupdateFunc
newMenu.close = menuClose
newMenu.cancelFunc = win.close
win.new(newMenu, menuEvent(newMenu))
dbglog("ugui.MenuEx out")
return newMenu
____½áÊø
____×Ó³ÌÐò_17(items)
local menu = ugui.MenuEx(items[1])
for index, data in items[2] do
menu:add(data)
end
if menu.count == 0 then
dbglog("menu item number == 0 !!!")
menu.wnd = nil
menu = nil
win.close()
else
menu:show()
end
return menu
____½áÊø
____×Ó³ÌÐò_18(self)
if self.wnd then
if self.isText then
gui.t_release(self.wnd)
else
gui.d_release(self.wnd)
end
end
____½áÊø
____×Ó³ÌÐò_19(dialog, type, param1, param2)
dbglog("_dialogEvent:" .. type .. ", pa1:" .. param1)
if type == 6 then
if param1 == 0 and dialog.kind ~= 2 then
dialog.func1(dialog)
elseif param1 == 1 and dialog.kind ~= 0 then
dialog.func2(dialog)
end
end
____½áÊø
____×Ó³ÌÐò_20(self)
return function(type, param1, param2)
_dialogEvent(self, type, param1, param2)
end
____½áÊø
____×Ó³ÌÐò_21(self, title, text)
if not title then
self.title = self.title
end
if not text then
self.text = self.text
end
if self.wnd then
if self.isText then
gui.t_update(self.wnd, charToUnicode(self.title), charToUnicode(self.text))
else
gui.d_update(self.wnd, charToUnicode(self.title), charToUnicode(self.text))
end
end
____½áÊø
____×Ó³ÌÐò_22(title, text, kind, lCap, rCap, func1, func2, isText)
dbglog("dialog. come in!!")
local newDialog = {}
if not title then
newDialog.title = txt[5]
end
if not text then
newDialog.text = ""
end
if not kind then
newDialog.kind = 0
end
if newDialog.kind == 2 or newDialog.kind == 100 then
newDialog.func1 = DoNothing
elseif not func1 then
newDialog.func1 = win.close
end
if newDialog.kind == 0 or newDialog.kind == 100 then
newDialog.func2 = DoNothing
elseif not func2 then
newDialog.func2 = win.close
end
newDialog.isText = not isText
newDialog.wnd = gui.t_create(charToUnicode(newDialog.title), charToUnicode(newDialog.text), newDialog.kind)
do break end
newDialog.wnd = gui.d_create(charToUnicode(newDialog.title), charToUnicode(newDialog.text), newDialog.kind)
newDialog.close = dialogClose
newDialog.update = dialogupdate
win.new(newDialog, dialogEvent(newDialog))
dbglog("dialog. created return!!")
return newDialog
____½áÊø
____×Ó³ÌÐò_23(self)
_platEx(1406, "")
____½áÊø
____×Ó³ÌÐò_24(self)
____½áÊø
____×Ó³ÌÐò_25(s)
local path = _platEx(1220, "")
local path_l = string.len(path) + 5
local ret = string.sub(s, path_l)
return ret
____½áÊø
____×Ó³ÌÐò_26(kind, param1, param2)
if kind == 10 then
if param1 == 0 then
local s, ret = _platEx(1405, "")
if ret == 0 then
local name = nil
name, nes_path = nes_relative(s), s
if string.lower(string.sub(name, -3)) == "zpk" then
_platEx(1204, nes_path)
name = nesExpack(name)
_platEx(1204, "Z:\\")
if not name then
ugui.TextEx(txt[5], txt[22], 2, "", txt[2])
return
end
end
NesFuncReal(name)
else
NesFuncReal(" ")
end
elseif param1 == 1 then
win.close()
end
end
____½áÊø
____×Ó³ÌÐò_27()
local newDialog = {}
_platEx(1401, "")
_platEx(1402, string.pack("I", 40))
_platEx(1402, string.pack("I", 42))
local s, ret = _platEx(1404, string.pack("I", 4))
if ret == 0 then
newDialog.close = explClose
newDialog.update = explUpdate
win.new(newDialog, de_expl)
return newDialog
else
return
end
____½áÊø
____×Ó³ÌÐò_28(self)
dbglog("ExWinClose()")
if self.wnd then
gui.w_release(self.wnd)
end
dbglog("ExWinClose() out")
____½áÊø
____×Ó³ÌÐò_29(showFunc, eventFunc)
local newExwin = {}
newExwin.show = showFunc
newExwin.close = ExWinClose
newExwin.wnd = gui.w_create()
win.new(newExwin, eventFunc)
return newExwin
____½áÊø
____×Ó³ÌÐò_30(str)
if string.byte(str, 1) == 27 then
return string.sub(str, 2)
else
return c2u(str)
end
____½áÊø
____×Ó³ÌÐò_31()
local wtw, wth = _textWidth(txt[28])
if wth == nil then
wth = 20
end
sysinfo = GetSysInfo()
SCR_W, SCR_H = sysinfo.ScreenW, sysinfo.ScreenH
_effSetCon((SCR_W - wtw - 20) / 2, (SCR_H - wth - 8) / 2, wtw + 20, wth + 8, 64, 64, 64)
DrawText(txt[28], (SCR_W - wtw) / 2, (SCR_H - wth) / 2, 0, 255, 255)
DispUpdate()
____½áÊø