Skip to content

Commit 2976e33

Browse files
committed
Get rid of greeting window and load directly into editor
1 parent b92eec4 commit 2976e33

File tree

5 files changed

+173
-213
lines changed

5 files changed

+173
-213
lines changed

bender.bmx

Lines changed: 112 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -33,151 +33,130 @@ New TAppGUI
3333
New TAppOutput
3434
New TAppFileIO
3535
New TBitmapIndex
36-
TAppGUI.FAppMain()
36+
TAppGUI.FAppEditor()
37+
TAppOutput.FOutputBoot()
3738

3839
Rem
3940
------- EVENT HANDLING ------------------------------------------------------------------------------------------------
4041
EndRem
4142

4243
While True
43-
If Not TAppGUI.mainToEdit Then
44-
TAppGUI.FAppUpdate()
44+
TAppOutput.FOutputUpdate()
45+
46+
If ButtonState(TAppGUI.editSettingsIndexedCheckbox) = True Then
47+
fileFilters = "Image Files:bmp"
48+
TAppFileIO.saveAsIndexed = True
4549
Else
46-
TAppOutput.FOutputUpdate()
47-
If ButtonState(TAppGUI.editSettingsIndexedCheckbox) = True Then
48-
fileFilters = "Image Files:bmp"
49-
TAppFileIO.saveAsIndexed = True
50-
Else
51-
fileFilters = "Image Files:png"
52-
TAppFileIO.saveAsIndexed = False
53-
EndIf
50+
fileFilters = "Image Files:png"
51+
TAppFileIO.saveAsIndexed = False
5452
EndIf
5553

5654
WaitEvent
5755
'Print CurrentEvent.ToString()
5856
'Print GCMemAlloced()
5957

6058
'Event Responses
61-
'In Main Window
62-
If Not TAppGUI.mainToEdit Then
63-
Select EventID()
64-
Case EVENT_GADGETACTION
65-
Select EventSource()
66-
'Quitting
67-
Case TAppGUI.mainQuitButton
68-
Exit
69-
'Loading
70-
Case TAppGUI.mainLoadButton
71-
TAppFileIO.FLoadFile()
72-
EndSelect
73-
'Quitting
74-
Case EVENT_WINDOWCLOSE, EVENT_APPTERMINATE
75-
Exit
76-
EndSelect
77-
'In Editor Window
78-
ElseIf TAppGUI.mainToEdit Then
79-
Select EventID()
80-
Case EVENT_APPRESUME
81-
ActivateWindow(TAppGUI.editWindow)
82-
TAppOutput.FOutputUpdate()
83-
Case EVENT_WINDOWACTIVATE
84-
TAppOutput.FOutputUpdate()
85-
Case EVENT_GADGETLOSTFOCUS
86-
TAppOutput.FOutputUpdate()
87-
Case EVENT_MENUACTION
88-
Select EventData()
89-
Case TAppGUI.ABOUT_MENU
90-
AppTitle = "CCCP Bender v"+appversion
91-
Notify(LoadText("Incbin::assets/about-textbox-content"),false)
92-
EndSelect
93-
Case EVENT_GADGETACTION
94-
Select EventSource()
95-
'Quitting confirm
96-
Case TAppGUI.editQuitButton
97-
quitResult = Confirm("Quit program?")
98-
'Loading
99-
Case TAppGUI.editLoadButton
100-
TAppFileIO.FLoadFile()
101-
TAppOutput.FOutputUpdate()
102-
'Saving
103-
Case TAppGUI.editSaveButton
104-
TAppFileIO.prepForSave = True
105-
TAppOutput.FOutputUpdate()
106-
'Settings textbox inputs
107-
'Scale
108-
Case TAppGUI.editSettingsZoomTextbox
109-
Local userInputValue:Int = GadgetText(TAppGUI.editSettingsZoomTextbox).ToInt()
110-
'Foolproofing
111-
If userInputValue > 4 Then
112-
TAppOutput.INPUTZOOM = 4
113-
ElseIf userInputValue <= 0 Then
114-
TAppOutput.INPUTZOOM = 1
115-
Else
116-
TAppOutput.INPUTZOOM = userInputValue
117-
EndIf
118-
SetGadgetText(TAppGUI.editSettingsZoomTextbox,TAppOutput.INPUTZOOM)
119-
TAppOutput.TILESIZE = 24 * TAppOutput.INPUTZOOM
120-
TAppOutput.redoLimbTiles = True
121-
TAppOutput.FOutputUpdate()
122-
'Frames
123-
Case TAppGUI.editSettingsFramesTextbox
124-
Local userInputValue:Int = GadgetText(TAppGUI.editSettingsFramesTextbox).ToInt()
125-
'Foolproofing
126-
If userInputValue > 20 Then
127-
TAppOutput.FRAMES = 20
128-
ElseIf userInputValue <= 0 Then
129-
TAppOutput.FRAMES = 1
130-
Else
131-
TAppOutput.FRAMES = userInputValue
132-
EndIf
133-
SetGadgetText(TAppGUI.editSettingsFramesTextbox,TAppOutput.FRAMES)
134-
TAppOutput.FOutputUpdate()
135-
'Bacground Color
136-
'Red
137-
Case TAppGUI.editSettingsColorRTextbox
138-
Local userInputValue:Int = GadgetText(TAppGUI.editSettingsColorRTextbox).ToInt()
139-
'Foolproofing
140-
If userInputValue > 255 Then
141-
TAppOutput.BACKGROUND_RED = 255
142-
ElseIf userInputValue < 0 Then
143-
TAppOutput.BACKGROUND_RED = 0
144-
Else
145-
TAppOutput.BACKGROUND_RED = userInputValue
146-
EndIf
147-
SetGadgetText(TAppGUI.editSettingsColorRTextbox,TAppOutput.BACKGROUND_RED)
148-
TAppOutput.FOutputUpdate()
149-
'Green
150-
Case TAppGUI.editSettingsColorGTextbox
151-
Local userInputValue:Int = GadgetText(TAppGUI.editSettingsColorGTextbox).ToInt()
152-
'Foolproofing
153-
If userInputValue > 255 Then
154-
TAppOutput.BACKGROUND_GREEN = 255
155-
ElseIf userInputValue < 0 Then
156-
TAppOutput.BACKGROUND_GREEN = 0
157-
Else
158-
TAppOutput.BACKGROUND_GREEN = userInputValue
159-
EndIf
160-
SetGadgetText(TAppGUI.editSettingsColorGTextbox,TAppOutput.BACKGROUND_GREEN)
161-
TAppOutput.FOutputUpdate()
162-
'Blue
163-
Case TAppGUI.editSettingsColorBTextbox
164-
Local userInputValue:Int = GadgetText(TAppGUI.editSettingsColorBTextbox).ToInt()
165-
'Foolproofing
166-
If userInputValue > 255 Then
167-
TAppOutput.BACKGROUND_BLUE = 255
168-
ElseIf userInputValue < 0 Then
169-
TAppOutput.BACKGROUND_BLUE = 0
170-
Else
171-
TAppOutput.BACKGROUND_BLUE = userInputValue
172-
EndIf
173-
SetGadgetText(TAppGUI.editSettingsColorBTextbox,TAppOutput.BACKGROUND_BLUE)
174-
TAppOutput.FOutputUpdate()
175-
EndSelect
176-
'Quitting confirm
177-
Case EVENT_WINDOWCLOSE, EVENT_APPTERMINATE
178-
quitResult = Confirm("Quit program?")
179-
EndSelect
180-
'Quitting
181-
If quitResult Then Exit
182-
EndIf
59+
Select EventID()
60+
Case EVENT_APPRESUME
61+
ActivateWindow(TAppGUI.editWindow)
62+
TAppOutput.FOutputUpdate()
63+
Case EVENT_WINDOWACTIVATE
64+
TAppOutput.FOutputUpdate()
65+
Case EVENT_GADGETLOSTFOCUS
66+
TAppOutput.FOutputUpdate()
67+
Case EVENT_MENUACTION
68+
Select EventData()
69+
Case TAppGUI.ABOUT_MENU
70+
AppTitle = "CCCP Bender v"+appversion
71+
Notify(LoadText("Incbin::assets/about-textbox-content"),False)
72+
EndSelect
73+
Case EVENT_GADGETACTION
74+
Select EventSource()
75+
'Quitting confirm
76+
Case TAppGUI.editQuitButton
77+
quitResult = Confirm("Quit program?")
78+
'Loading
79+
Case TAppGUI.editLoadButton
80+
TAppFileIO.FLoadFile()
81+
TAppOutput.FOutputUpdate()
82+
'Saving
83+
Case TAppGUI.editSaveButton
84+
TAppFileIO.prepForSave = True
85+
TAppOutput.FOutputUpdate()
86+
'Settings textbox inputs
87+
'Scale
88+
Case TAppGUI.editSettingsZoomTextbox
89+
Local userInputValue:Int = GadgetText(TAppGUI.editSettingsZoomTextbox).ToInt()
90+
'Foolproofing
91+
If userInputValue > 4 Then
92+
TAppOutput.INPUTZOOM = 4
93+
ElseIf userInputValue <= 0 Then
94+
TAppOutput.INPUTZOOM = 1
95+
Else
96+
TAppOutput.INPUTZOOM = userInputValue
97+
EndIf
98+
SetGadgetText(TAppGUI.editSettingsZoomTextbox,TAppOutput.INPUTZOOM)
99+
TAppOutput.TILESIZE = 24 * TAppOutput.INPUTZOOM
100+
TAppOutput.redoLimbTiles = True
101+
TAppOutput.FOutputUpdate()
102+
'Frames
103+
Case TAppGUI.editSettingsFramesTextbox
104+
Local userInputValue:Int = GadgetText(TAppGUI.editSettingsFramesTextbox).ToInt()
105+
'Foolproofing
106+
If userInputValue > 20 Then
107+
TAppOutput.FRAMES = 20
108+
ElseIf userInputValue <= 0 Then
109+
TAppOutput.FRAMES = 1
110+
Else
111+
TAppOutput.FRAMES = userInputValue
112+
EndIf
113+
SetGadgetText(TAppGUI.editSettingsFramesTextbox,TAppOutput.FRAMES)
114+
TAppOutput.FOutputUpdate()
115+
'Bacground Color
116+
'Red
117+
Case TAppGUI.editSettingsColorRTextbox
118+
Local userInputValue:Int = GadgetText(TAppGUI.editSettingsColorRTextbox).ToInt()
119+
'Foolproofing
120+
If userInputValue > 255 Then
121+
TAppOutput.BACKGROUND_RED = 255
122+
ElseIf userInputValue < 0 Then
123+
TAppOutput.BACKGROUND_RED = 0
124+
Else
125+
TAppOutput.BACKGROUND_RED = userInputValue
126+
EndIf
127+
SetGadgetText(TAppGUI.editSettingsColorRTextbox,TAppOutput.BACKGROUND_RED)
128+
TAppOutput.FOutputUpdate()
129+
'Green
130+
Case TAppGUI.editSettingsColorGTextbox
131+
Local userInputValue:Int = GadgetText(TAppGUI.editSettingsColorGTextbox).ToInt()
132+
'Foolproofing
133+
If userInputValue > 255 Then
134+
TAppOutput.BACKGROUND_GREEN = 255
135+
ElseIf userInputValue < 0 Then
136+
TAppOutput.BACKGROUND_GREEN = 0
137+
Else
138+
TAppOutput.BACKGROUND_GREEN = userInputValue
139+
EndIf
140+
SetGadgetText(TAppGUI.editSettingsColorGTextbox,TAppOutput.BACKGROUND_GREEN)
141+
TAppOutput.FOutputUpdate()
142+
'Blue
143+
Case TAppGUI.editSettingsColorBTextbox
144+
Local userInputValue:Int = GadgetText(TAppGUI.editSettingsColorBTextbox).ToInt()
145+
'Foolproofing
146+
If userInputValue > 255 Then
147+
TAppOutput.BACKGROUND_BLUE = 255
148+
ElseIf userInputValue < 0 Then
149+
TAppOutput.BACKGROUND_BLUE = 0
150+
Else
151+
TAppOutput.BACKGROUND_BLUE = userInputValue
152+
EndIf
153+
SetGadgetText(TAppGUI.editSettingsColorBTextbox,TAppOutput.BACKGROUND_BLUE)
154+
TAppOutput.FOutputUpdate()
155+
EndSelect
156+
'Quitting confirm
157+
Case EVENT_WINDOWCLOSE, EVENT_APPTERMINATE
158+
quitResult = Confirm("Quit program?")
159+
EndSelect
160+
'Quitting
161+
If quitResult Then Exit
183162
EndWhile

types/bitmap-index.bmx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ Type TBitmapIndex
1414
'Load color table file
1515
Function FLoadPalette()
1616
Local index:Int
17-
If IncbinLen("assets/palette.act") = 768
18-
Local paletteStream:TStream = ReadFile("Incbin::assets/palette.act")
17+
If IncbinLen("assets/palette") = 768
18+
Local paletteStream:TStream = ReadFile("Incbin::assets/palette")
1919
For index = 0 To 255
2020
palR[index] = ReadByte(paletteStream)
2121
palG[index] = ReadByte(paletteStream)

types/editor-output.bmx

Lines changed: 44 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -130,40 +130,43 @@ Type TAppOutput
130130
Else
131131
SetClsColor(BACKGROUND_RED,BACKGROUND_GREEN,BACKGROUND_BLUE)
132132
EndIf
133-
'Draw source image
133+
'Draw footer image
134134
SetColor(255,255,255)
135-
DrawImageRect(sourceImage,0,0,ImageWidth(sourceImage)*INPUTZOOM,ImageHeight(sourceImage)*INPUTZOOM)
136-
If redoLimbTiles Then
137-
FCreateLimbTiles()
138-
redoLimbTiles = False
139-
EndIf
140-
For i = 0 To BONES-1
141-
'Draw limb tile dividers
142-
SetColor(120,0,120)
143-
DrawLine(i*TILESIZE,0,i*TILESIZE,TILESIZE-1,True)
144-
'Draw the joint markers
145-
FCreateJointMarker(jointX[i]+i*TILESIZE,jointY[i])
146-
FCreateJointMarker(jointX[i]+i*TILESIZE,jointY[i]+boneLength[i])
147-
Next
148-
'Draw footer image and text
149135
DrawImage(logoImage,0,480-ImageHeight(logoImage))
150-
'SetColor(255,230,80)
151-
'DrawText("TBA",ImageWidth(logoImage)+7,480-18)
152-
'Draw bent limbs
153-
FLimbBend()
154-
SetColor(255,255,255)
155-
For f = 0 To FRAMES-1
156-
'These might be in a specific draw-order for joint overlapping purposes
157-
b = 0 SetRotation(angle[b,f]) DrawImageRect(boneImage[b],xBone[b,f],yBone[b,f],ImageWidth(boneImage[b])/INPUTZOOM,ImageHeight(boneImage[b])/INPUTZOOM)
158-
b = 1 SetRotation(angle[b,f]) DrawImageRect(boneImage[b],xBone[b,f],yBone[b,f],ImageWidth(boneImage[b])/INPUTZOOM,ImageHeight(boneImage[b])/INPUTZOOM)
159-
b = 2 SetRotation(angle[b,f]) DrawImageRect(boneImage[b],xBone[b,f],yBone[b,f],ImageWidth(boneImage[b])/INPUTZOOM,ImageHeight(boneImage[b])/INPUTZOOM)
160-
b = 3 SetRotation(angle[b,f]) DrawImageRect(boneImage[b],xBone[b,f],yBone[b,f],ImageWidth(boneImage[b])/INPUTZOOM,ImageHeight(boneImage[b])/INPUTZOOM)
161-
b = 4 SetRotation(angle[b,f]) DrawImageRect(boneImage[b],xBone[b,f],yBone[b,f],ImageWidth(boneImage[b])/INPUTZOOM,ImageHeight(boneImage[b])/INPUTZOOM)
162-
b = 5 SetRotation(angle[b,f]) DrawImageRect(boneImage[b],xBone[b,f],yBone[b,f],ImageWidth(boneImage[b])/INPUTZOOM,ImageHeight(boneImage[b])/INPUTZOOM)
163-
b = 6 SetRotation(angle[b,f]) DrawImageRect(boneImage[b],xBone[b,f],yBone[b,f],ImageWidth(boneImage[b])/INPUTZOOM,ImageHeight(boneImage[b])/INPUTZOOM)
164-
b = 7 SetRotation(angle[b,f]) DrawImageRect(boneImage[b],xBone[b,f],yBone[b,f],ImageWidth(boneImage[b])/INPUTZOOM,ImageHeight(boneImage[b])/INPUTZOOM)
165-
Next
166-
SetRotation(0)
136+
'Draw source image
137+
If sourceImage <> Null Then
138+
DrawImageRect(sourceImage,0,0,ImageWidth(sourceImage)*INPUTZOOM,ImageHeight(sourceImage)*INPUTZOOM)
139+
If redoLimbTiles Then
140+
FCreateLimbTiles()
141+
redoLimbTiles = False
142+
EndIf
143+
For i = 0 To BONES-1
144+
'Draw limb tile dividers
145+
SetColor(120,0,120)
146+
DrawLine(i*TILESIZE,0,i*TILESIZE,TILESIZE-1,True)
147+
'Draw the joint markers
148+
FCreateJointMarker(jointX[i]+i*TILESIZE,jointY[i])
149+
FCreateJointMarker(jointX[i]+i*TILESIZE,jointY[i]+boneLength[i])
150+
Next
151+
'Draw bent limbs
152+
FLimbBend()
153+
SetColor(255,255,255)
154+
For f = 0 To FRAMES-1
155+
'These might be in a specific draw-order for joint overlapping purposes
156+
b = 0 SetRotation(angle[b,f]) DrawImageRect(boneImage[b],xBone[b,f],yBone[b,f],ImageWidth(boneImage[b])/INPUTZOOM,ImageHeight(boneImage[b])/INPUTZOOM)
157+
b = 1 SetRotation(angle[b,f]) DrawImageRect(boneImage[b],xBone[b,f],yBone[b,f],ImageWidth(boneImage[b])/INPUTZOOM,ImageHeight(boneImage[b])/INPUTZOOM)
158+
b = 2 SetRotation(angle[b,f]) DrawImageRect(boneImage[b],xBone[b,f],yBone[b,f],ImageWidth(boneImage[b])/INPUTZOOM,ImageHeight(boneImage[b])/INPUTZOOM)
159+
b = 3 SetRotation(angle[b,f]) DrawImageRect(boneImage[b],xBone[b,f],yBone[b,f],ImageWidth(boneImage[b])/INPUTZOOM,ImageHeight(boneImage[b])/INPUTZOOM)
160+
b = 4 SetRotation(angle[b,f]) DrawImageRect(boneImage[b],xBone[b,f],yBone[b,f],ImageWidth(boneImage[b])/INPUTZOOM,ImageHeight(boneImage[b])/INPUTZOOM)
161+
b = 5 SetRotation(angle[b,f]) DrawImageRect(boneImage[b],xBone[b,f],yBone[b,f],ImageWidth(boneImage[b])/INPUTZOOM,ImageHeight(boneImage[b])/INPUTZOOM)
162+
b = 6 SetRotation(angle[b,f]) DrawImageRect(boneImage[b],xBone[b,f],yBone[b,f],ImageWidth(boneImage[b])/INPUTZOOM,ImageHeight(boneImage[b])/INPUTZOOM)
163+
b = 7 SetRotation(angle[b,f]) DrawImageRect(boneImage[b],xBone[b,f],yBone[b,f],ImageWidth(boneImage[b])/INPUTZOOM,ImageHeight(boneImage[b])/INPUTZOOM)
164+
Next
165+
SetRotation(0)
166+
Else
167+
SetColor(255,230,80)
168+
DrawText("NO IMAGE LOADED!",(GraphicsWidth()/2)-(TextWidth("NO IMAGE LOADED!")/2),GraphicsHeight()/2)
169+
EndIf
167170
'Output copy for saving
168171
If TAppFileIO.saveAsIndexed = True Then
169172
'If saving indexed grab a smaller pixmap to speed up indexing
@@ -181,13 +184,21 @@ Type TAppOutput
181184
Function FOutputBoot()
182185
SetGraphicsDriver GLMax2DDriver()
183186
SetGraphics CanvasGraphics(TAppGUI.editCanvas)
187+
'Load palette
188+
TBitmapIndex.FLoadPalette()
184189
'Window background color
185190
SetClsColor(BACKGROUND_RED,BACKGROUND_GREEN,BACKGROUND_BLUE)
186191
SetMaskColor(255,0,255)
187192
DrawImage(logoImage,0,480-ImageHeight(logoImage))
193+
SetColor(255,230,80)
194+
DrawText("NO IMAGE LOADED!",(GraphicsWidth()/2)-(TextWidth("NO IMAGE LOADED!")/2),GraphicsHeight()/2)
195+
FOutputUpdate()
196+
EndFunction
197+
198+
'Have to do all this so first loaded source image is zoomed in and has correct limb tiles and markers.
199+
Function FLoadingFirstTime()
188200
DrawImageRect(sourceImage,0,0,ImageWidth(sourceImage)*INPUTZOOM,ImageHeight(sourceImage)*INPUTZOOM)
189201
FCreateLimbTiles()
190-
'Have to do all this to start editor window with source image zoomed in otherwise markers and tiles don't scale properly.
191202
INPUTZOOM = 4
192203
SetGadgetText(TAppGUI.editSettingsZoomTextbox,TAppOutput.INPUTZOOM)
193204
TILESIZE = 24 * TAppOutput.INPUTZOOM

types/file-io.bmx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ Global exportedFile:String = Null
1010
Global fileFilters:String
1111

1212
Type TAppFileIO
13+
'Load Bools
14+
Global loadingFirstTime:Int = True
15+
1316
'Save Bools
1417
Global saveAsIndexed:Int = False
1518
Global prepForSave:Int = False
@@ -29,7 +32,12 @@ Type TAppFileIO
2932
TAppOutput.sourceImage = TAppOutput.sourceImage
3033
Else
3134
TAppOutput.sourceImage = LoadImage(importedFile,0)
32-
TAppOutput.redoLimbTiles = True
35+
If loadingFirstTime = True Then
36+
TAppOutput.FLoadingFirstTime()
37+
loadingFirstTime = False
38+
Else
39+
TAppOutput.redoLimbTiles = True
40+
EndIf
3341
EndIf
3442
EndFunction
3543

0 commit comments

Comments
 (0)