This repository has been archived by the owner on Nov 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
main.lua
114 lines (77 loc) · 2.49 KB
/
main.lua
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
aboutWindow = Dialog("About FormulaPro :", 50, 20, 280, 180)
local aboutstr = [[FormulaPro v1.42b
--------------------
Jim Bauwens, Adrien "Adriweb" Bertrand
Thanks also to Levak.
LGPL3 License.
More info and contact :
tiplanet.org - inspired-lua.org
Tip : Press [Tab] for Reference !]]
local aboutButton = sButton("OK")
for i, line in ipairs(aboutstr:split("\n")) do
local aboutlabel = sLabel(line)
aboutWindow:appendWidget(aboutlabel, 10, 27 + i*14-12)
end
aboutWindow:appendWidget(aboutButton,-10,-5)
function aboutWindow:postPaint(gc)
nativeBar(gc, self, self.h-40)
on.help = function() return 0 end
end
aboutButton:giveFocus()
function aboutButton:action()
remove_screen(aboutWindow)
on.help = function() push_screen_direct(aboutWindow) end
end
----------------------------------------
function on.help()
push_screen_direct(aboutWindow)
end
----------------------------------------
function errorPopup(gc)
errorHandler.display = false
errorDialog = Dialog("Oops...", 50, 20, "85", "80")
local textMessage = [[FormulaPro has encountered an error
-----------------------------
Sorry for the inconvenience.
Please report this bug to [email protected]
How/where/when it happened etc.
(bug at line ]] .. errorHandler.errorLine .. ")"
local errorOKButton = sButton("OK")
for i, line in ipairs(textMessage:split("\n")) do
local errorLabel = sLabel(line)
errorDialog:appendWidget(errorLabel, 10, 27 + i*14-12)
end
errorDialog:appendWidget(errorOKButton,-10,-5)
function errorDialog:postPaint(gc)
nativeBar(gc, self, self.h-40)
end
errorOKButton:giveFocus()
function errorOKButton:action()
remove_screen(errorDialog)
errorHandler.errorMessage = nil
end
push_screen_direct(errorDialog)
end
---------------------------------------------------------------
function on.create()
platform.os = "3.1"
end
function on.construction()
platform.os = "3.2"
end
errorHandler = {}
function handleError(line, errMsg, callStack, locals)
print("Error handled !", errMsg)
errorHandler.display = true
errorHandler.errorMessage = errMsg
errorHandler.errorLine = line
errorHandler.callStack = callStack
errorHandler.locals = locals
platform.window:invalidate()
return true -- go on....
end
if platform.registerErrorHandler then
platform.registerErrorHandler( handleError )
end
---------------------------------------------- Launch !
push_screen_direct(CategorySel)