-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.lua
203 lines (152 loc) · 5.13 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
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
require( 'scripts.dmc.dmc_kolor' )
require ( 'scripts.patches.refPointConversions' )
local funx = require( "funx" )
--------------------------------------------
local screenW, screenH = display.contentWidth, display.contentHeight
local viewableScreenW, viewableScreenH = display.viewableContentWidth, display.viewableContentHeight
local screenOffsetW, screenOffsetH = display.contentWidth - display.viewableContentWidth, display.contentHeight - display.viewableContentHeight
local midscreenX = screenW*(0.5)
local midscreenY = screenH*(0.5)
local storyboard = require "storyboard"
storyboard.isDebug = true
-- This is the specialized module to handle the app settings GUI
local settings_gui = require("scripts.dialog.settings_gui")
-- Local settings for an app, e.g. current user, etc.
local system_settings = {
user = {
authorized = true,
username = "iggie",
password = "nookie",
displayname = "David Gross",
bookstore = "My Bookstore",
adultpassword = "abc",
},
}
system_settings = {
user = {
authorized = false,
username = "iggie",
password = "nookie",
displayname = "David Gross",
bookstore = "My Bookstore",
adultpassword = "abc",
},
}
-- THIS IS FOR TESTING:
------------------------------------------------
local scene = storyboard.newScene("main")
local widget = require "widget"
local settingsDialogName = "settingsDialog"
local signInDialogName = "signinDialog"
local newAccountDialogName = "createAccountDialog"
function scene:createScene( event )
local group = self.view
-----------------------------------------------------------------------------
local r = display.newRect(group, 0,0,screenW,screenH)
funx.anchorTopLeftZero(r)
--- Show a dialog based on a button id.
local function OpenDialogButtonRelease(event)
settings_gui.showDialog(event.target.id)
end
-- Testing open dialog #1 button
local openButton = widget.newButton{
id = signInDialogName,
defaultFile = "_ui/button-gear-gray.png",
overFile = "_ui/button-gear-gray-over.png",
width = 44,
height = 44,
onRelease = OpenDialogButtonRelease,
}
group:insert(openButton)
openButton.x = 40
openButton.y = 80
openButton:toFront()
-- Testing open dialog #2 button
local openButtonB = widget.newButton{
id = newAccountDialogName,
defaultFile = "_ui/button-gear-gray.png",
overFile = "_ui/button-gear-gray-over.png",
width = 44,
height = 44,
onRelease = OpenDialogButtonRelease,
}
group:insert(openButtonB)
openButtonB.x = 100
openButtonB.y = 80
openButtonB:toFront()
openButtonB:setFillColor( 250,50,50, 250 )
-- Testing open dialog #2 button
local openButtonC = widget.newButton{
id = settingsDialogName,
defaultFile = "_ui/button-gear-gray.png",
overFile = "_ui/button-gear-gray-over.png",
width = 44,
height = 44,
onRelease = OpenDialogButtonRelease,
}
group:insert(openButtonC)
openButtonC.x = 160
openButtonC.y = 80
openButtonC:toFront()
openButtonC:setFillColor( 50,50,250, 250 )
-----------------------------------------------------------------------------
end
scene:addEventListener( "createScene" )
-- the following event is dispatched once the overlay is in place
function scene:overlayBegan( event )
--print( "Main scene says, showing overlay: " .. event.sceneName )
end
scene:addEventListener( "overlayBegan" )
-- the following event is dispatched once overlay is removed
function scene:overlayEnded( event )
--print( "Main scene says, Overlay removed: " .. event.sceneName )
--funx.dump(storyboard.dialogResults)
--print( "----" )
end
scene:addEventListener( "overlayEnded" )
storyboard.gotoScene("main")
--------------------------------------------
local function onUpdateSettings(values)
print ("Main: onUpdateSettings(values)")
funx.dump (values)
-- Things to do:
-- We can check for the status, or not.
-- If we want 'cancel' to be a 'close', which is how iOS seems to do things,
-- we don't care what the status is. We assume, in iOS fashion, that all
-- changes are good changes. If you don't believe me, try the iOS System Settings
-- and see!
-- To check status:
--[[
if (values.status == "ok") then
-- Save new settings to disk
else
-- do nothing, changes were cancelled or error happened
end
--]]
end
settings_gui.init(system_settings, onUpdateSettings)
--settings_gui.showSettingsDialog()
settings_gui.showDialog("signinDialog")
local testing = true
if (testing) then
local widget = require ( "widget" )
local wf = false
local function toggleWireframe()
wf = not wf
display.setDrawMode( "wireframe", wf )
if (not wf) then
display.setDrawMode( "forceRender" )
end
print ("WF = ",wf)
end
local wfb = widget.newButton{
label = "WIREFRAME",
labelColor = { default={ 200, 1, 1 }, over={ 250, 0, 0, 0.5 } },
fontSize = 20,
x =10,
y=10,
onRelease = toggleWireframe,
}
wfb:toFront()
funx.anchorTopLeft(wfb)
end