Skip to content

Commit ddb7530

Browse files
author
MaximDude
committed
Prep for saving fully functional
Added "Help" text Added input file template Minor changes to "About" text Minor refactoring
1 parent 9f3623b commit ddb7530

File tree

2 files changed

+73
-43
lines changed

2 files changed

+73
-43
lines changed

assets/input-template.bmp

13.6 KB
Binary file not shown.

cccp-bender-main.bmx

Lines changed: 73 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
Rem
2-
---------------------------------------------------------------
3-
CORTEX COMMAND COMMUNITY PROJECT BENDER v0.1 :
4-
---------------------------------------------------------------
5-
TBA
2+
------- CORTEX COMMAND COMMUNITY PROJECT BENDER -----------------------------------------------------------------------
63
EndRem
74

85
SuperStrict
@@ -17,24 +14,23 @@ Import BRL.PNGLoader
1714
Global appVersion:String = "0.1"
1815
Global appVersionDate:String = "17 Aug 2019"
1916

20-
'Output Window Title
21-
AppTitle = "CCCP Bender v"+appVersion+" - Output"
22-
23-
'Bools
24-
Global quitResult:Int = False
17+
Rem
18+
------- FILE IO -------------------------------------------------------------------------------------------------------
19+
EndRem
2520

2621
'Filepaths
2722
Global importedFile:String = Null
2823
Global exportedFile:String = Null
2924

30-
'File IO
3125
Type TAppFileIO
3226
'Save Bools
3327
Global prepForSave:Int = False
3428
Global rdyForSave:Int = False
3529
Global runOnce:Int = False
3630
'File Filters
3731
Global fileFilers:String = "Image Files:png,jpg,bmp"
32+
'Output copy for saving
33+
Global tempOutputImage:TPixmap
3834

3935
'Load Source Image
4036
Function FLoadFile()
@@ -71,23 +67,28 @@ Type TAppFileIO
7167

7268
'Save Output Content To File
7369
Function FSaveFile()
74-
Local tempOutputImage:TPixmap = GrabPixmap(0,96,768,384)
75-
exportedFile = RequestFile("Save graphic file",fileFilers,True)
70+
exportedFile = RequestFile("Save graphic output",fileFilers,True)
7671
'Foolproofing
7772
If exportedFile = importedFile Then
78-
Notify("Can't overwrite source image!",True)
73+
Notify("Cannot overwrite source image!",True)
7974
ElseIf exportedFile <> importedFile Then
8075
'Writing new file
8176
SavePixmapPNG(tempOutputImage,exportedFile)
82-
FRevertPrep()
77+
FRevertPrep()
8378
Else
8479
'On Cancel
8580
FRevertPrep()
8681
EndIf
8782
EndFunction
8883
EndType
8984

90-
'App Output Elements
85+
Rem
86+
------- OUTPUT ELEMENTS -----------------------------------------------------------------------------------------------
87+
EndRem
88+
89+
'Output Window Title
90+
AppTitle = "CCCP Bender v"+appVersion+" - Output"
91+
9192
Type TAppOutput
9293
'Output Window
9394
Global outputWindow:TGraphics
@@ -154,25 +155,25 @@ Type TAppOutput
154155
If ym < (TILESIZE/2-2) And ym > 0 And xm > 0 And xm < TILESIZE*BONES Then
155156
Local b:Int = xm/TILESIZE
156157
jointX[b] = TILESIZE/2 'X is always at center, so kinda pointless to even bother - at the moment
157-
jointY[b] = ym 'Determines length
158+
jointY[b] = ym 'Determines length
158159
boneLength[b] = (TILESIZE/2 -ym)*2
159160
SetImageHandle(boneImage[b],jointX[b]/ZOOM,jointY[b]/ZOOM) 'Rotation handle.
160161
EndIf
161162
EndFunction
162163

163164
'Bending
164165
Function FLimbBend()
165-
Local maxExtend:Float = 0.99 'Possibly make definable in settings (slider) -- maybe not, because large number of frames can be rendered and you can just take the ones you need
166-
Local minExtend:Float = 0.30 'Possibly make definable in settings (slider) -- maybe not, because large number of frames can be rendered and you can just take the ones you need
166+
Local maxExtend:Float = 0.99 'Possibly make definable in settings (slider)
167+
Local minExtend:Float = 0.30 'Possibly make definable in settings (slider)
167168
Local stepSize:Float = (maxExtend-minExtend)/(FRAMES-1) ' -1 to make inclusive of last value (full range)
168169
Local b:Int, f:Int, l:Float, x:Float, y:Float, airLength:Float, upperLength:Float, lowerLength:Float
169170
For l = 0 To LIMBS-1
170171
For f = 0 To FRAMES-1
171172
b = l*2
172173
x = (f * 32) + 80 'Drawing position X
173174
y = ((l * 32) * 1.5 ) + 144 'Drawing position Y
174-
upperLength = boneLength[b]/ZOOM 'e.g. upper leg
175-
lowerLength = boneLength[b+1]/ZOOM 'e.g. lower leg
175+
upperLength = boneLength[b]/ZOOM
176+
lowerLength = boneLength[b+1]/ZOOM
176177
airLength = (stepSize * f + minExtend) * (upperLength + lowerLength) 'Sum of the two bones * step scaler for frame (hip-ankle)
177178
FLawOfCosines(airLength,upperLength,lowerLength)
178179
angle[b,f] = angB
@@ -233,8 +234,8 @@ Type TAppOutput
233234
Next
234235
'Draw footer image and text
235236
DrawImage(logoImage,0,480-ImageHeight(logoImage))
236-
SetColor(255,230,80)
237-
DrawText("TBA",ImageWidth(logoImage)+7,480-18)
237+
'SetColor(255,230,80)
238+
'DrawText("TBA",ImageWidth(logoImage)+7,480-18)
238239
'Draw bent limbs
239240
FLimbBend()
240241
SetColor(255,255,255)
@@ -250,6 +251,8 @@ Type TAppOutput
250251
b = 7 SetRotation(angle[b,f]) DrawImageRect(boneImage[b],xBone[b,f],yBone[b,f],ImageWidth(boneImage[b])/ZOOM,ImageHeight(boneImage[b])/ZOOM)
251252
Next
252253
SetRotation(0)
254+
'Output copy for saving
255+
TAppFileIO.tempOutputImage = GrabPixmap(0,96,768,384)
253256
Flip(1)
254257
If TAppFileIO.prepForSave
255258
TAppFileIO.FPrepForSave()
@@ -258,7 +261,7 @@ Type TAppOutput
258261

259262
'Create output window and draw assets
260263
Function FOutputBoot()
261-
SetGraphicsDriver GLMax2DDriver()
264+
'SetGraphicsDriver GLMax2DDriver()
262265
outputWindow = Graphics(768,480,0,0,0)
263266
'Window background color
264267
SetClsColor(BACKGROUND_RED,BACKGROUND_GREEN,BACKGROUND_BLUE)
@@ -271,13 +274,19 @@ Type TAppOutput
271274
EndFunction
272275
EndType
273276

274-
'GUI Elements
277+
Rem
278+
------- GUI ELEMENTS --------------------------------------------------------------------------------------------------
279+
EndRem
280+
281+
'Bool For Quitting
282+
Global quitResult:Int = False
283+
275284
Type TAppGUI
276285
'Window Transition Bool
277286
Global mainToEdit:Int = False
278287
'Main Window
279288
Global mainWindow:TGadget
280-
'Footer Label
289+
'Main Window Footer Label
281290
Global mainWindowFooterLabel:TGadget
282291
'Main Window Buttons
283292
Global mainWindowButtonPanel:TGadget
@@ -306,12 +315,12 @@ Type TAppGUI
306315
Global editSettingsColorRLabel:TGadget
307316
Global editSettingsColorGLabel:TGadget
308317
Global editSettingsColorBLabel:TGadget
309-
'Workspace Window Instructions
318+
'Editor Window Help
310319
Global editHelpPanel:TGadget
311320
Global editHelpTextbox:TGadget
312321
'Textboxes content
313-
Global aboutTextboxContent:String[8]
314-
Global helpTextboxContent:String[]
322+
Global aboutTextboxContent:String[7]
323+
Global helpTextboxContent:String[15]
315324

316325
'Create Main App Window
317326
Function FAppMain()
@@ -321,17 +330,16 @@ Type TAppGUI
321330
mainQuitButton = CreateButton("Quit",GadgetWidth(mainWindowButtonPanel)/2-69,40,130,30,mainWindowButtonPanel,BUTTON_PUSH)
322331
mainAboutPanel = CreatePanel(GadgetWidth(mainWindow)/2-140,GadgetHeight(mainWindowButtonPanel)+15,280,200,mainWindow,PANEL_GROUP," About : ")
323332
mainAboutTextbox = CreateTextArea(7,3,GadgetWidth(mainAboutPanel)-21,GadgetHeight(mainAboutPanel)-30,mainAboutPanel,TEXTAREA_WORDWRAP|TEXTAREA_READONLY)
324-
mainWindowFooterLabel = CreateLabel("CCCP Bender v"+appVersion+" by MaximDude",10,GadgetHeight(mainWindow)-20,GadgetWidth(mainWindow),15,mainWindow,LABEL_LEFT)
333+
mainWindowFooterLabel = CreateLabel("CCCP Bender v"+appVersion+" - "+appVersionDate,10,GadgetHeight(mainWindow)-20,GadgetWidth(mainWindow),15,mainWindow,LABEL_LEFT)
325334
'About textbox Content
326-
aboutTextboxContent[0] = "Welcome to the CCCP Bender utility!~n~n"
327-
aboutTextboxContent[1] = "It's purpose is to make the life of modders easier by automagically generating bent limb frames.~n~n"
328-
aboutTextboxContent[2] = "The CC Bender was originally created by Arne Jansson (AndroidArts), the man behind all the Cortex Command artwork.~n"
329-
aboutTextboxContent[3] = "The CCCommunityProject Bender, however, is a brand new tool that allows more control and convenience for the modder (hopefully).~n~n"
330-
aboutTextboxContent[4] = "Arne's original bend code was used as base for this utility, and has been modified and improved to enable the new features.~n~n"
331-
aboutTextboxContent[5] = "Created by MaximDude using BlitzMax MaxIDE 1.52~n"
332-
aboutTextboxContent[6] = "Bender logo image by Arne Jansson - Edited by MaximDude"
333-
aboutTextboxContent[7] = "CCCP Bender version "+appVersion+" - "+appVersionDate
334-
SetGadgetText(mainAboutTextbox,aboutTextboxContent[0]+aboutTextboxContent[1]+aboutTextboxContent[2]+aboutTextboxContent[3]+aboutTextboxContent[4]+aboutTextboxContent[5]+aboutTextboxContent[6]+aboutTextboxContent[7])
335+
aboutTextboxContent[0] = "Welcome to the CCCP Bender utility! ~n~n"
336+
aboutTextboxContent[1] = "It's purpose is to make the life of modders easier by automagically generating bent limb frames. ~n~n"
337+
aboutTextboxContent[2] = "The CC Bender was originally created by Arne Jansson (AndroidArts), the man behind all the Cortex Command artwork. ~n"
338+
aboutTextboxContent[3] = "The CCCommunityProject Bender, however, is a brand new tool that allows more control and convenience for the modder (hopefully). ~n~n"
339+
aboutTextboxContent[4] = "Arne's original bend code was used as base for this utility, and has been modified and improved to enable the new features. ~n~n"
340+
aboutTextboxContent[5] = "Created by MaximDude using BlitzMax 0.105.3.35 and MaxIDE 1.52 ~n"
341+
aboutTextboxContent[6] = "Bender logo image by Arne Jansson - Edited by MaximDude ~n"
342+
SetGadgetText(mainAboutTextbox,aboutTextboxContent[0]+aboutTextboxContent[1]+aboutTextboxContent[2]+aboutTextboxContent[3]+aboutTextboxContent[4]+aboutTextboxContent[5]+aboutTextboxContent[6])
335343
EndFunction
336344

337345
'Create Editor Window
@@ -353,15 +361,30 @@ Type TAppGUI
353361
editSettingsColorRLabel = CreateLabel("R:",65,45,50,20,editSettingsPalel,LABEL_LEFT)
354362
editSettingsColorGLabel = CreateLabel("G:",120,45,50,20,editSettingsPalel,LABEL_LEFT)
355363
editSettingsColorBLabel = CreateLabel("B:",175,45,50,20,editSettingsPalel,LABEL_LEFT)
356-
editHelpPanel = CreatePanel(10,170,280,250,editWindow,PANEL_GROUP," Instructions : ")
364+
editHelpPanel = CreatePanel(10,170,280,250,editWindow,PANEL_GROUP," Help : ")
357365
editHelpTextbox = CreateTextArea(7,5,GadgetWidth(editHelpPanel)-21,GadgetHeight(editHelpPanel)-32,editHelpPanel,TEXTAREA_WORDWRAP|TEXTAREA_READONLY)
358366
SetGadgetText(editSettingsZoomTextbox,TAppOutput.ZOOM)
359367
SetGadgetText(editSettingsFramesTextbox,TAppOutput.FRAMES)
360368
SetGadgetText(editSettingsColorRTextbox,TAppOutput.BACKGROUND_RED)
361369
SetGadgetText(editSettingsColorGTextbox,TAppOutput.BACKGROUND_GREEN)
362370
SetGadgetText(editSettingsColorBTextbox,TAppOutput.BACKGROUND_BLUE)
363-
'Instructions textbox content
364-
SetGadgetText(TAppGUI.editHelpTextbox,"TBA");
371+
'Help textbox content
372+
helpTextboxContent[0] = "-------------------------- GUI -------------------------- ~n~n"
373+
helpTextboxContent[1] = "LOAD: ~nThis loads an image file and starts bending. Supported formats are bmp, png and jpg. ~n~n"
374+
helpTextboxContent[2] = "- Note: ~nThe loaded file is being cut to 24x24px tiles internally. For best results, use provided template to create correct input files. ~n~n"
375+
helpTextboxContent[3] = "SAVE: ~nThis saves the bended limbs into a file or creates a new file with specified name. ~n~n"
376+
helpTextboxContent[4] = "- Note: ~nFiles are saved in .png format, typing in the extension is not needed. Currently loaded file cannot be overwritten. ~n~n"
377+
helpTextboxContent[5] = "----------------- ADJUSTING JOINTS ---------------- ~n~n"
378+
helpTextboxContent[6] = "To adjust the joint positing on a limb part, click the upper joint marker on and drag it up/down, or click at desired point to set it there. Output will update automatically as you adjust the markers.~n~n"
379+
helpTextboxContent[7] = "- Note: Joint markers cannot be adjusted on the X axis, and will adjust equally on the Y axis. For best results, please position the limb parts as close to dead center as possible for each tile in the input file. ~n~n"
380+
helpTextboxContent[8] = "---------------------- SETTINGS ----------------------- ~n~n"
381+
helpTextboxContent[9] = "ZOOM : ~nThis magnifies the source image For easier placement of joint markers. Zooming does Not magnify the output. ~n~nAccepts values from 1 To 4. ~n~n"
382+
helpTextboxContent[10] = "- Warning : ~nChanging zoom level will reset the joint markers to initial positions. Zoom first, adjust markers later. ~n~n"
383+
helpTextboxContent[11] = "FRAMES: ~nThis sets the amount of frames output will generate. ~n~nAccepts values from 1 to 20. ~n~n"
384+
helpTextboxContent[12] = "- Note : ~nLimb bending will automatically adjust to number of frames. ~n~n"
385+
helpTextboxContent[13] = "BG COLOR R,G,B: ~nThis changes the background color of the output. ~n~nAccepts values from 0 to 255. ~n~n"
386+
helpTextboxContent[14] = "- Note : ~nWhen saving file, the output will automatically set background to magenta, so no manual setting before saving is needed."
387+
SetGadgetText(TAppGUI.editHelpTextbox,helpTextboxContent[0]+helpTextboxContent[1]+helpTextboxContent[2]+helpTextboxContent[3]+helpTextboxContent[4]+helpTextboxContent[5]+helpTextboxContent[6]+helpTextboxContent[7]+helpTextboxContent[8]+helpTextboxContent[9]+helpTextboxContent[10]+helpTextboxContent[11]+helpTextboxContent[12]+helpTextboxContent[13]+helpTextboxContent[14]);
365388
'Delete no longer used MainWindow
366389
FreeGadget(mainWindow)
367390
EndFunction
@@ -376,12 +399,19 @@ Type TAppGUI
376399
EndFunction
377400
EndType
378401

379-
'Everything set up, run app
402+
Rem
403+
------- BOOT ----------------------------------------------------------------------------------------------------------
404+
EndRem
405+
380406
New TAppGUI
381407
New TAppOutput
382408
New TAppFileIO
383409
TAppGUI.FAppMain()
384410

411+
Rem
412+
------- EVENT HANDLING ------------------------------------------------------------------------------------------------
413+
EndRem
414+
385415
While True
386416
If Not TAppGUI.mainToEdit Then
387417
TAppGUI.FAppUpdate()
@@ -390,7 +420,7 @@ While True
390420
EndIf
391421

392422
WaitEvent
393-
Print CurrentEvent.ToString()
423+
'Print CurrentEvent.ToString()
394424

395425
'Event Responses
396426
'In Main Window

0 commit comments

Comments
 (0)