Skip to content

Commit e6a492c

Browse files
committed
Get all UI element values set correctly when loading user settings
1 parent ddc95ce commit e6a492c

File tree

4 files changed

+51
-19
lines changed

4 files changed

+51
-19
lines changed

Bender.bmx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,19 @@ Global g_GraphicsOutput:GraphicsOutput = Null
2626

2727
Repeat
2828
g_SettingsManager = New SettingsManager()
29-
g_UserInterface = New UserInterface(g_DefaultInputZoom, g_DefaultOutputZoom, g_DefaultFrameCount, g_DefaultBackgroundRed, g_DefaultBackgroundGreen, g_DefaultBackgroundBlue)
29+
g_UserInterface = New UserInterface()
3030
g_FileIO = New FileIO()
3131
g_GraphicsOutput = New GraphicsOutput(g_UserInterface.GetMaxWorkspaceWidth())
3232
EnablePolledInput()
3333

34-
'Set user settings/defaults
34+
'Apply user settings/defaults
35+
g_UserInterface.SetColorTextboxValues(g_GraphicsOutput.SetBackgroundColor(Int[][g_DefaultBackgroundRed, g_DefaultBackgroundGreen, g_DefaultBackgroundBlue]))
3536
g_UserInterface.SetInputZoomTextboxValue(g_GraphicsOutput.SetInputZoom(g_DefaultInputZoom))
3637
g_UserInterface.SetOutputZoomTextboxValue(g_GraphicsOutput.SetOutputZoom(g_DefaultOutputZoom))
3738
g_UserInterface.SetFramesTextboxValue(g_GraphicsOutput.SetFrameCount(g_DefaultFrameCount))
38-
g_UserInterface.SetColorTextboxValues(g_GraphicsOutput.SetBackgroundColor(Int[][g_DefaultBackgroundRed, g_DefaultBackgroundGreen, g_DefaultBackgroundBlue]))
39-
g_GraphicsOutput.SetDrawOutputFrameBounds(g_FileIO.SetSaveAsFrames(g_DefaultSaveAsFrames))
40-
g_UserInterface.SetFileTypeComboBoxVisible(g_FileIO.SetSaveAsIndexed(g_DefaultSaveAsIndexed))
41-
g_FileIO.SetIndexedFileType(g_DefaultIndexedFileType)
39+
g_UserInterface.SetSaveAsFramesCheckboxValue(g_GraphicsOutput.SetDrawOutputFrameBounds(g_FileIO.SetSaveAsFrames(g_DefaultSaveAsFrames)))
40+
g_UserInterface.SetFileTypeComboBoxVisible(g_UserInterface.SetSaveAsIndexedCheckboxValue(g_FileIO.SetSaveAsIndexed(g_DefaultSaveAsIndexed)))
41+
g_UserInterface.SetFileTypeComboBoxSelectedItem(g_FileIO.SetIndexedFileType(g_DefaultIndexedFileType))
4242

4343
Repeat
4444
PollEvent()
@@ -90,10 +90,10 @@ Repeat
9090
g_UserInterface.SetColorTextboxValues(g_GraphicsOutput.SetBackgroundColor(g_UserInterface.GetColorTextboxValues()))
9191
'Save as Frames
9292
Case g_UserInterface.m_SettingsSaveAsFramesCheckbox
93-
g_GraphicsOutput.SetDrawOutputFrameBounds(g_FileIO.SetSaveAsFrames(ButtonState(g_UserInterface.m_SettingsSaveAsFramesCheckbox)))
93+
g_GraphicsOutput.SetDrawOutputFrameBounds(g_FileIO.SetSaveAsFrames(g_UserInterface.GetSaveAsFramesCheckboxValue()))
9494
'Save as Indexed
9595
Case g_UserInterface.m_SettingsIndexedCheckbox
96-
g_UserInterface.SetFileTypeComboBoxVisible(g_FileIO.SetSaveAsIndexed(ButtonState(g_UserInterface.m_SettingsIndexedCheckbox)))
96+
g_UserInterface.SetFileTypeComboBoxVisible(g_FileIO.SetSaveAsIndexed(g_UserInterface.GetSaveAsIndexedCheckboxValue()))
9797
'Indexed Filetype
9898
Case g_UserInterface.m_SettingsIndexedFileTypeComboBox
9999
g_FileIO.SetIndexedFileType(GadgetText(g_UserInterface.m_SettingsIndexedFileTypeComboBox))

Types/FileIO.bmx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,10 @@ Type FileIO
6161

6262
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6363

64-
Method SetIndexedFileType(fileType:String)
64+
Method SetIndexedFileType:String(fileType:String)
6565
m_IndexedFileType = fileType.ToLower()
6666
m_FileFilters = "Image Files:" + m_IndexedFileType
67+
Return m_IndexedFileType
6768
EndMethod
6869

6970
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Types/GraphicsOutput.bmx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,9 @@ Type GraphicsOutput
122122

123123
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
124124

125-
Method SetDrawOutputFrameBounds(drawOrNot:Int)
125+
Method SetDrawOutputFrameBounds:Int(drawOrNot:Int)
126126
m_DrawOutputFrameBounds = drawOrNot
127+
Return m_DrawOutputFrameBounds
127128
EndMethod
128129

129130
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Types/UserInterface.bmx

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ Type UserInterface
7878

7979
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
8080

81-
Method New(inputZoomValue:Int, outputZoomValue:Int, framesValue:Int, bgRedValue:Int, bgGreenValue:Int, bgBlueValue:Int)
82-
InitializeUserInterface(inputZoomValue, outputZoomValue, framesValue, bgRedValue, bgGreenValue, bgBlueValue)
81+
Method New()
82+
InitializeUserInterface()
8383
InitializeCanvasGraphics()
8484
EndMethod
8585

8686
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
8787

88-
Method InitializeUserInterface(inputZoomValue:Int, outputZoomValue:Int, framesValue:Int, bgRedValue:Int, bgGreenValue:Int, bgBlueValue:Int)
88+
Method InitializeUserInterface()
8989
m_MainWindow = CreateWindow(AppTitle, (DesktopWidth() / 2) - ((m_CanvasGraphicsAnchor[0] + m_CanvasGraphicsSize[0]) / 2), (DesktopHeight() / 2) - (m_CanvasGraphicsSize[1] / 2), m_CanvasGraphicsAnchor[0] + m_CanvasGraphicsSize[0], m_CanvasGraphicsSize[1], Null, WINDOW_TITLEBAR | WINDOW_MENU | WINDOW_RESIZABLE | WINDOW_CLIENTCOORDS | WINDOW_ACCEPTFILES)
9090
SetMinWindowSize(m_MainWindow, m_LeftColumnSize[0] + m_CanvasGraphicsSize[0], m_CanvasGraphicsSize[1])
9191

@@ -122,27 +122,21 @@ Type UserInterface
122122

123123
m_SettingsColorRLabel = CreateLabel("R", GadgetWidth(m_SettingsColorLabel) + 15, GadgetY(m_SettingsColorLabel), 10, labelHeight, m_SettingsPanel, LABEL_LEFT)
124124
m_SettingsColorRTextbox = CreateTextField(GadgetX(m_SettingsColorRLabel) + 15, GadgetY(m_SettingsColorRLabel) + textboxVertOffset, textboxSize[0], textboxSize[1], m_SettingsPanel)
125-
SetGadgetText(m_SettingsColorRTextbox, bgRedValue)
126125

127126
m_SettingsColorGLabel = CreateLabel("G", 122, GadgetY(m_SettingsColorLabel), 10, labelHeight, m_SettingsPanel, LABEL_LEFT)
128127
m_SettingsColorGTextbox = CreateTextField(137, GadgetY(m_SettingsColorGLabel) + textboxVertOffset, textboxSize[0], textboxSize[1], m_SettingsPanel)
129-
SetGadgetText(m_SettingsColorGTextbox, bgGreenValue)
130128

131129
m_SettingsColorBLabel = CreateLabel("B", 180, GadgetY(m_SettingsColorLabel), 10, labelHeight, m_SettingsPanel, LABEL_LEFT)
132130
m_SettingsColorBTextbox = CreateTextField(195, GadgetY(m_SettingsColorBLabel) + textboxVertOffset, textboxSize[0], textboxSize[1], m_SettingsPanel)
133-
SetGadgetText(m_SettingsColorBTextbox, bgBlueValue)
134131

135132
m_SettingsInputZoomLabel = CreateLabel("Input Zoom", horizMargin, GadgetY(m_SettingsColorLabel) + labelVertOffset, 70, labelHeight + 4, m_SettingsPanel, LABEL_LEFT)
136133
m_SettingsInputZoomTextbox = CreateTextField(vertMargin + GadgetWidth(m_SettingsInputZoomLabel), GadgetY(m_SettingsInputZoomLabel) + textboxVertOffset, textboxSize[0], textboxSize[1], m_SettingsPanel)
137-
SetGadgetText(m_SettingsInputZoomTextbox, inputZoomValue)
138134

139135
m_SettingsOutputZoomLabel = CreateLabel("Output Zoom", 117, GadgetY(m_SettingsInputZoomLabel), 75, labelHeight + 4, m_SettingsPanel, LABEL_LEFT)
140136
m_SettingsOutputZoomTextbox = CreateTextField(horizMargin + GadgetX(m_SettingsOutputZoomLabel) + GadgetWidth(m_SettingsOutputZoomLabel) - 2, GadgetY(m_SettingsOutputZoomLabel) + textboxVertOffset, textboxSize[0], textboxSize[1], m_SettingsPanel)
141-
SetGadgetText(m_SettingsOutputZoomTextbox, outputZoomValue)
142137

143138
m_SettingsFramesLabel = CreateLabel("Frame Count", horizMargin, GadgetY(m_SettingsInputZoomLabel) + labelVertOffset, 70, labelHeight, m_SettingsPanel, LABEL_LEFT)
144139
m_SettingsFramesTextbox = CreateTextField(vertMargin + GadgetWidth(m_SettingsFramesLabel), GadgetY(m_SettingsFramesLabel) + textboxVertOffset, textboxSize[0], textboxSize[1], m_SettingsPanel)
145-
SetGadgetText(m_SettingsFramesTextbox, framesValue)
146140

147141
m_SettingsSaveAsFramesLabel = CreateLabel("Save as Frames", horizMargin, GadgetY(m_SettingsFramesLabel) + labelVertOffset, 87, labelHeight, m_SettingsPanel, LABEL_LEFT)
148142
m_SettingsSaveAsFramesCheckbox = CreateButton(Null, vertMargin + GadgetWidth(m_SettingsSaveAsFramesLabel), GadgetY(m_SettingsSaveAsFramesLabel), 20, 20, m_SettingsPanel, BUTTON_CHECKBOX)
@@ -242,6 +236,42 @@ Type UserInterface
242236
SetGadgetText(m_SettingsOutputZoomTextbox, newValue)
243237
EndMethod
244238

239+
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
240+
241+
Method GetSaveAsFramesCheckboxValue:Int()
242+
Return ButtonState(m_SettingsSaveAsFramesCheckbox)
243+
EndMethod
244+
245+
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
246+
247+
Method SetSaveAsFramesCheckboxValue:Int(newValue:Int)
248+
SetButtonState(m_SettingsSaveAsFramesCheckbox, newValue)
249+
Return newValue
250+
EndMethod
251+
252+
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
253+
254+
Method GetSaveAsIndexedCheckboxValue:Int()
255+
Return ButtonState(m_SettingsIndexedCheckbox)
256+
EndMethod
257+
258+
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
259+
260+
Method SetSaveAsIndexedCheckboxValue:Int(newValue:Int)
261+
SetButtonState(m_SettingsIndexedCheckbox, newValue)
262+
Return newValue
263+
EndMethod
264+
265+
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
266+
267+
Method SetFileTypeComboBoxSelectedItem(fileType:String)
268+
If fileType = "png" Then
269+
SelectGadgetItem(m_SettingsIndexedFileTypeComboBox, 0)
270+
ElseIf fileType = "bmp" Then
271+
SelectGadgetItem(m_SettingsIndexedFileTypeComboBox, 1)
272+
EndIf
273+
EndMethod
274+
245275
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
246276

247277
Method GetLayerCheckboxValues:Int[,]()

0 commit comments

Comments
 (0)