-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBender.bmx
130 lines (117 loc) · 7.97 KB
/
Bender.bmx
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
Rem
██████ ██████ ██████ ████████ ███████ ██ ██ ██████ ██████ ███ ███ ███ ███ █████ ███ ██ ██████ ██████ ███████ ███ ██ ██████ ███████ ██████
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ████ ████ ████ ██ ██ ████ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██
██ ██ ██ ██████ ██ █████ ███ ██ ██ ██ ██ ████ ██ ██ ████ ██ ███████ ██ ██ ██ ██ ██ ██████ █████ ██ ██ ██ ██ ██ █████ ██████
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██████ ██████ ██ ██ ██ ███████ ██ ██ ██████ ██████ ██ ██ ██ ██ ██ ██ ██ ████ ██████ ██████ ███████ ██ ████ ██████ ███████ ██ ██
EndRem
SuperStrict
Import "EmbeddedAssets.bmx"
Import "Types/UserInterface.bmx"
Import "Types/FileIO.bmx"
Import "Types/GraphicsOutput.bmx"
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
AppTitle = "CC Bender 2.0.1" '28 Apr 2021
Global g_SettingsManager:SettingsManager = Null
Global g_UserInterface:UserInterface = Null
Global g_FileIO:FileIO = Null
Global g_GraphicsOutput:GraphicsOutput = Null
'//// MAIN LOOP AND EVENT HANDLING //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Repeat
g_SettingsManager = New SettingsManager()
g_UserInterface = New UserInterface(g_DefaultMaximizeWindow)
g_FileIO = New FileIO()
g_GraphicsOutput = New GraphicsOutput(g_UserInterface.GetMaxWorkspaceWidth(), g_UserInterface.GetCanvasVisibleArea())
'Apply user settings/defaults.
g_UserInterface.SetColorTextboxValues(g_GraphicsOutput.SetBackgroundColor(Int[][g_DefaultBackgroundRed, g_DefaultBackgroundGreen, g_DefaultBackgroundBlue]))
g_UserInterface.SetInputZoomTextboxValue(g_GraphicsOutput.SetInputZoom(g_DefaultInputZoom))
g_UserInterface.SetOutputZoomTextboxValue(g_GraphicsOutput.SetOutputZoom(g_DefaultOutputZoom))
g_UserInterface.SetFramesTextboxValue(g_GraphicsOutput.SetFrameCount(g_DefaultFrameCount))
g_UserInterface.SetSaveAsFramesCheckboxValue(g_GraphicsOutput.SetDrawOutputFrameBounds(g_FileIO.SetSaveAsFrames(g_DefaultSaveAsFrames)))
g_UserInterface.SetFileTypeComboBoxVisible(g_UserInterface.SetSaveAsIndexedCheckboxValue(g_FileIO.SetSaveAsIndexed(g_DefaultSaveAsIndexed)))
g_UserInterface.SetFileTypeComboBoxSelectedItem(g_FileIO.SetIndexedFileType(g_DefaultIndexedFileType))
Local refreshTimer:TTimer = CreateTimer(g_DefaultOutputRefreshRate)
Local refreshOutput:Int = False
EnablePolledInput()
Repeat
refreshOutput = False
PollEvent()
Select EventID()
Case EVENT_TIMERTICK
Select EventSource()
Case refreshTimer
refreshOutput = True
EndSelect
Case EVENT_APPRESUME
ActivateWindow(g_UserInterface.m_MainWindow)
ActivateGadget(g_UserInterface.m_CanvasGraphics)
Case EVENT_WINDOWSIZE
g_GraphicsOutput.SetCanvasVisibleArea(g_UserInterface.ProcessWindowResize())
Case EVENT_WINDOWACCEPT
g_GraphicsOutput.LoadFile(g_FileIO.SetFileToLoad(EventExtra().ToString()))
Case EVENT_MENUACTION
Select EventData()
Case g_UserInterface.c_SaveSettingsMenuTag
g_SettingsManager.WriteSettingsFile(g_UserInterface.GetSettingsValuesForSaving())
Case g_UserInterface.c_HelpMenuTag
Notify(g_UserInterface.m_HelpMenuText, False)
Case g_UserInterface.c_AboutMenuTag
Notify(g_UserInterface.m_AboutMenuText, False)
EndSelect
Case EVENT_GADGETACTION
Select EventSource()
'Loading.
Case g_UserInterface.m_LoadButton
g_UserInterface.SetSaveButtonEnabled(g_GraphicsOutput.LoadFile(g_FileIO.SetFileToLoad()))
'Saving.
Case g_UserInterface.m_SaveButton
If g_FileIO.GetSaveAsFrames() Then
g_GraphicsOutput.RevertBackgroundColorAfterSave(g_FileIO.SaveFileAsFrames(g_GraphicsOutput.GrabOutputFramesForSaving(), g_GraphicsOutput.GetFrameCount()))
Else
g_GraphicsOutput.RevertBackgroundColorAfterSave(g_FileIO.SaveFile(g_GraphicsOutput.GrabOutputForSaving()))
EndIf
Continue
'Input Scale.
Case g_UserInterface.m_SettingsInputZoomTextbox
g_UserInterface.SetInputZoomTextboxValue(g_GraphicsOutput.SetInputZoom(g_UserInterface.GetInputZoomTextboxValue()))
'Output Scale.
Case g_UserInterface.m_SettingsOutputZoomTextbox
g_UserInterface.SetOutputZoomTextboxValue(g_GraphicsOutput.SetOutputZoom(g_UserInterface.GetOutputZoomTextboxValue()))
'Frames.
Case g_UserInterface.m_SettingsFramesTextbox
g_UserInterface.SetFramesTextboxValue(g_GraphicsOutput.SetFrameCount(g_UserInterface.GetFramesTextboxValue()))
'BG Color.
Case g_UserInterface.m_SettingsColorRTextbox, g_UserInterface.m_SettingsColorGTextbox, g_UserInterface.m_SettingsColorBTextbox
g_UserInterface.SetColorTextboxValues(g_GraphicsOutput.SetBackgroundColor(g_UserInterface.GetColorTextboxValues()))
'Save as Frames.
Case g_UserInterface.m_SettingsSaveAsFramesCheckbox
g_GraphicsOutput.SetDrawOutputFrameBounds(g_FileIO.SetSaveAsFrames(g_UserInterface.GetSaveAsFramesCheckboxValue()))
'Save as Indexed.
Case g_UserInterface.m_SettingsIndexedCheckbox
g_UserInterface.SetFileTypeComboBoxVisible(g_FileIO.SetSaveAsIndexed(g_UserInterface.GetSaveAsIndexedCheckboxValue()))
'Indexed Filetype.
Case g_UserInterface.m_SettingsIndexedFileTypeComboBox
g_FileIO.SetIndexedFileType(GadgetText(g_UserInterface.m_SettingsIndexedFileTypeComboBox))
'Layering Controls.
Case g_UserInterface.m_LayeringArmFGCheckbox, g_UserInterface.m_LayeringArmBGCheckbox, g_UserInterface.m_LayeringLegFGCheckbox, g_UserInterface.m_LayeringLegBGCheckbox
g_GraphicsOutput.SetBentLimbPartDrawOrder(g_UserInterface.SetLayerCheckboxLabels(g_UserInterface.GetLayerCheckboxValues()))
EndSelect
Case EVENT_KEYDOWN
If g_UserInterface.GetSaveButtonEnabled() And (KeyDown(KEY_LCONTROL) Or KeyDown(KEY_RCONTROL)) And KeyDown(KEY_S) Then
If g_FileIO.GetSaveAsFrames() Then
g_GraphicsOutput.RevertBackgroundColorAfterSave(g_FileIO.SaveFileAsFrames(g_GraphicsOutput.GrabOutputFramesForSaving(), g_GraphicsOutput.GetFrameCount()))
Else
g_GraphicsOutput.RevertBackgroundColorAfterSave(g_FileIO.SaveFile(g_GraphicsOutput.GrabOutputForSaving()))
EndIf
FlushKeys()
Continue
EndIf
Case EVENT_WINDOWCLOSE, EVENT_APPTERMINATE
If Confirm("Quit program?") Then End
EndSelect
g_GraphicsOutput.Update()
If refreshOutput Then
g_GraphicsOutput.Draw()
EndIf
Forever
Forever