summaryrefslogtreecommitdiff
path: root/designer.bmx
diff options
context:
space:
mode:
Diffstat (limited to 'designer.bmx')
-rw-r--r--designer.bmx94
1 files changed, 86 insertions, 8 deletions
diff --git a/designer.bmx b/designer.bmx
index 7546823..b6f12de 100644
--- a/designer.bmx
+++ b/designer.bmx
@@ -33,43 +33,76 @@ Type Designer
Global gui:TGUIHandler
- Global fname_lab:TLabel
Global fname_txt:TText
+ Global fname_load:TButton
+ Global fname_save:TButton
- Global setname_lab:TLabel
Global setname_txt:TText
- Global levname_lab:TLabel
Global levname_txt:TText
+ Global levadd_but:TButton
+ Global levins_but:TButton
+ Global levdel_but:TButton
+ Global levinv_check:TCheckbox
+ Global levnum:TNumberInt
Global hide_check:TCheckbox
Global validbut:TButton
Global helpbut:TButton
Global quitbut:TButton
+
+ Global mdialog:TGUIHandler
+ Global md_panel:TPanel
+ Global md_friendly:TCheckbox
+ Global md_invert:TCheckbox
+ Global md_mass:TText
+ Global md_ok:TButton
+ Global md_cancel:TButton
+
+ Global pdialog:TGUIHandler
+ Global pd_panel:TPanel
+ Global pd_gap:TNumberInt
+ Global pd_vx:TText
+ Global pd_vy:TText
+ Global pd_ok:TButton
+ Global pd_cancel:TButton
Function Initialise()
If Not init
+ Local l:TLabel
+
TGUIFont.font = GameGFX.guifont
levelset = New TLevelSet
level = New TLevel
levelsetfname = "Default.ppinch"
- done = False
levelindex = 0
gui = TGUIHandler.Create()
- fname_lab = TLabel.Create(gui,0,0,"File")
+ TLabel.Create(gui,0,0,"File")
fname_txt = TText.Create(gui,TEXTX,0,"",32)
+ fname_load = TButton.Create(gui,fname_txt.x+fname_txt.w+10,0,50,12,"Load",LoadCallback)
+ fname_save = TButton.Create(gui,fname_load.x+fname_load.w+10,0,50,fname_load.h,"Save",SaveCallback)
- setname_lab = TLabel.Create(gui,0,10,"Levelset name")
+ TLabel.Create(gui,0,10,"Levelset name")
setname_txt = TText.Create(gui,TEXTX,10,"",32)
- levname_lab = TLabel.Create(gui,0,20,"Level name")
+ TLabel.Create(gui,0,20,"Level name")
levname_txt = TText.Create(gui,TEXTX,20,"",32)
+ levadd_but = TButton.Create(gui,levname_txt.x+levname_txt.w+10,levname_txt.y,50,12,"Add",AddLevelCallback)
+ levins_but = TButton.Create(gui,levadd_but.x+levadd_but.w+10,levname_txt.y,50,12,"Insert",InsertLevelCallback)
+ levdel_but = TButton.Create(gui,levins_but.x+levins_but.w+10,levname_txt.y,50,12,"Delete",DeleteLevelCallback)
+
+ levinv_check = TCheckbox.Create(gui,0,35,"Invert placed masses",InvertPlacedCallback)
+ l=TLabel.Create(gui,levinv_check.w+50,35,"Level:")
+ levnum = TNumberInt.Create(gui,l.x+l.w+10,35,LevelNumberCallback)
+ levnum.value=0
+ levnum.minval=0
+ levnum.maxval=0
- hide_check = TCheckbox.Create(gui,700,0,"Hide GUI",HideCallback)
+ hide_check = TCheckbox.Create(gui,750,0,"Hide",HideCallback)
validbut = TButton.Create(gui,650,570,49,29,"Check",CheckCallback)
helpbut = TButton.Create(gui,700,570,49,29,"Test",TestCallback)
@@ -78,6 +111,7 @@ Type Designer
init=True
EndIf
+ done = False
fname_txt.text = levelsetfname
setname_txt.text = levelset.name
levname_txt.text = level.name
@@ -95,6 +129,7 @@ Function DoDesigner()
While Not Designer.done
Cls
Designer.gui.EventLoop()
+ SetColor(255,255,255)
DrawImage(GameGFX.pointer,MouseX(),MouseY())
Flip
FlushMem
@@ -127,3 +162,46 @@ End Function
Function CheckCallback(w:TWidget)
End Function
+
+Function LoadCallback(w:TWidget)
+ Try
+ Local load:TLevelSet=TLevelSet.Load(Designer.fname_txt.text)
+ Designer.levelset=load
+ Catch e:TLevelException
+ GUINotify("Failed to load '" + Designer.fname_txt.text + "'||"+e.message,GameGFX.pointer)
+ EndTry
+End Function
+
+Function SaveCallback(w:TWidget)
+ If Not Designer.levelset.Save(Designer.fname_txt.text)
+ GUINotify("Failed to save '" + Designer.fname_txt.text + "'",GameGFX.pointer)
+ EndIf
+End Function
+
+Function InvertPlacedCallback(w:TWidget)
+ Local c:TCheckbox=TCheckbox(w)
+ Designer.level.invmass=c.checked
+End Function
+
+Function LevelNumberCallback(w:TWidget)
+ Local c:TNumberInt=TNumberInt(w)
+ SaveLevel()
+ Designer.levelindex=c.value
+ LoadLevel()
+End Function
+
+Function AddLevelCallback(w:TWidget)
+End Function
+
+Function InsertLevelCallback(w:TWidget)
+End Function
+
+Function DeleteLevelCallback(w:TWidget)
+ If Designer.levelset.level.Count()<2
+ GUINotify("Must have at least one level!",GameGFX.pointer)
+ Return
+ EndIf
+
+ If GUIYesNo("Delete this level:|"+Designer.levname_txt.text,GameGFX.pointer)
+ EndIf
+End Function \ No newline at end of file