JNR
stageEdit.h
1 /*
2 
3 Jump'n'Run Engine
4 http://www.atanaslaskov.com/jnr/
5 
6 BSD LICENSE
7 Copyright (c) 2007-2013, Atanas Laskov
8 All rights reserved.
9 
10 Redistribution and use in source and binary forms, with or without
11 modification, are permitted provided that the following conditions are met:
12 1. Redistributions of source code must retain the above copyright notice,
13 this list of conditions and the following disclaimer.
14 2. Redistributions in binary form must reproduce the above copyright notice,
15 this list of conditions and the following disclaimer in the documentation
16 and/or other materials provided with the distribution.
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL ATANAS LASKOV BE LIABLE FOR ANY
21 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 */
30 
31 
37 
38 // Editor drawing canvas
39 //
40 class uiEditorCanvas: public uiWindow
41 {
42 public:
43  //Editor pointer
44  class stageEdit* pEditor;
45 
46  //Blueprint postiton
47  int nBlueprintX;
48  int nBlueprintY;
49 
50  //Create canvas window
51  uiEditorCanvas();
52 
53  virtual void reply();
54  virtual void draw();
55 };
56 
57 // Editor Palette
58 //
59 class uiPalette: public uiContainer{
60 
61  uiButton* arBtn[20];
62 
63 public:
64  class stageEdit* pEditor;
65  unsigned nBrushType;
66 
67  uiPalette(): uiContainer("ui\\dialogs\\edit-palette.cui"){
68 
69  nBrushType = 0;
70  pEditor = NULL;
71 
72  arBtn[0] = (uiButton*)get(3);
73  arBtn[1] = (uiButton*)get(4);
74  arBtn[2] = (uiButton*)get(6);
75  arBtn[3] = (uiButton*)get(8);
76  arBtn[4] = (uiButton*)get(9);
77  arBtn[5] = (uiButton*)get(10);
78  arBtn[6] = (uiButton*)get(11);
79 
80  for(unsigned n=0; n<=6; n++) arBtn[n]->togglePersistent(M_TRUE);
81  arBtn[0]->press();
82  }
83 
84  // Handle button commands
85  void onCommand(unsigned long uID, unsigned long nCmd);
86 };
87 
88 // New level Dialog
89 //
90 class uiNewLevelDlg: public uiContainer{
91 
92  //Control pointers
93  uiEdit *_pEdName;
94  uiEdit *_pEdTileset;
95  uiSlider *_pSliderLenght;
96 
97  class genParameters* _pParams;
98 
99 public:
100  class stageEdit* pEditor;
101 
102  uiNewLevelDlg(): uiContainer("ui\\dialogs\\edit-new.cui"){
103 
104  _pEdName = (uiEdit*)(get(3));
105  _pEdTileset = (uiEdit*)(get(5));
106  _pSliderLenght = (uiSlider*)(get(7));
107 
108  pEditor = NULL;
109 
110  _pParams = NULL;
111  }
112 
113  // Handle button commands
114  void onCommand(unsigned long uID, unsigned long nCmd);
115 
116  virtual void show();
117  virtual void hide();
118 };
119 
120 class stageEdit :
121  public laStage
122 {
123 public:
124  //GUI
125  uiDesktop _uiDesktop;
126  uiMenu_JR* _pMenu;
127  uiPalette* _pPalette;
128 
129  uiEditorCanvas* pCanvas;
130 
131  uiNewLevelDlg* pNewLevelDlg;
132  uiFileDialog* pSaveDlg;
133  uiFileDialog* pOpenDlg;
134 
135 
136  //Level objects
137  class genBlueprint *pBlueprint;
138  double dScroll;
139 
140 public:
141  stageEdit(void);
142  ~stageEdit(void);
143 
144  //Message handlers
145  //
146  virtual void onInit();
147  virtual void onFini();
148  virtual void onFrame(laRenderer *pr, laInputManager *pi, laTimer *pt);
149 
150  virtual void onActivate();
151  virtual void onDeactivate();
152 };
GUI Container Window.
Definition: uiContainer.h:42
JR Main Menu, and in-game Menu.
Definition: uiMenu_JR.h:43
GUI Slider.
Definition: uiSlider.h:71
GUI Push-button.
Definition: uiButton.h:41
GUI Editbox.
Definition: uiEdit.h:44
Level Editor Stage.
Definition: stageEdit.h:120
Base class for GUI windows.
Definition: uiWindow.h:45
Base Class for Stages.
Definition: laStage.h:48
GUI Topmost Window.
Definition: uiDesktop.h:44
File Selection Dialog.
Definition: uiFileDialog.h:39
Virtual interface for the Engine graphics renderer.
Definition: laRenderer.h:98
virtual void reply()
Handle input message.
Definition: uiWindow.cpp:130
virtual void draw()
Display the window.
Definition: uiWindow.cpp:198
virtual void onCommand(unsigned long uID, unsigned long nCmd)
Command event handler.
Definition: uiWindow.cpp:263