JNR
stageJRMenu.cpp
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 */
29 
30 //
31 // FILE: stageJRMenu.cpp
32 //
33 // Main Menu stage
34 //
35 // Copyright (C) 2007-2013 Atanas Laskov, <latanas@gmail.com>, 2009
36 //
37 #include "stdafx.h"
38 #include "laStagesJR.h"
39 
40 stageJRMenu::stageJRMenu(void) {
41  _dCamRotSpeed *= 0.1;
42  //_dCamRotMul
43  //_dCamDirAngle
44  //_dCamLimit
45 }
46 
47 stageJRMenu::~stageJRMenu(void) {
48 }
49 
50 
51 void stageJRMenu::_init_gui()
52 {
53  _uiDesktop.create("ui\\desktop-mm.dsk");
54 
55  _pMenu = new uiMenu_JR();
56  _uiDesktop.insert(_pMenu);
57 
58  uiLabel* pLabel = new uiLabel();
59  pLabel->setText(M_COPYRIGHT_STRING);
60  pLabel->move(laPoint3(20,40), M_AL, M_AB);
61  pLabel->align(M_AL, M_AB);
62  pLabel->size(14);
63  _uiDesktop.insert(pLabel);
64 
65  pLabel = new uiLabel();
66  char str[128] = M_VERSION_STRING;
67  strcat(str, "#This version is for testing purposes only. Please do not redistribute.");
68 
69  pLabel->setText(str);
70  pLabel->move(laPoint3(20,20), M_AL, M_AT);
71  pLabel->align(M_AL, M_AT);
72  pLabel->size(10);
73  _uiDesktop.insert(pLabel);
74 
75  /*pLabel = new uiLabel();
76  pLabel->setText("Jumping RONIN");
77  pLabel->move(laPoint3(20,20), M_AL, M_AT);
78  pLabel->align(M_AL, M_AT);
79  pLabel->size(30);
80  _uiDesktop.insert(pLabel);*/
81 }
82 
83 void stageJRMenu::_draw_UI(laRenderer *pr, laTimer *pt) {
84  PROFILE(stageJRMenu__draw_UI);
85  _uiDesktop.draw();
86 }
87 
88 void stageJRMenu::_animate(laInputManager *pi, laTimer *pt) {
89  PROFILE(stageJRMenu__animate);
90  _uiDesktop.reply();
91  _animate_Dynamics(pi, pt);
92 }
93 
94 
95 void uiAboutDlg::reply()
96 {
97  laInputManager *pi = ::laSystemIntegrator::getInput();
98 
99  if(in::key(KEY_ESCAPE))
100  {
101  ((stageJRMenu*)(laSystemIntegrator::getGame()->getStage(M_STAGE_MENU)))->getMenu()->show();
102  hide();
103  }
104 }
105 
106 /*void uiAboutDlg::onCommand(unsigned long uID, unsigned long nCmd)
107 {
108  ((stageJRMenu*)(laSystemIntegrator::getGame()->getStage(M_STAGE_MENU)))->getMenu()->show();
109  hide();
110 }*/
111 
112 void uiStartEditorDlg::onCommand(unsigned long uID, unsigned long nCmd)
113 {
114  //Identify the button
115  uiButton* pb = (uiButton*)get(uID);
116  char title[64];
117  pb->getText(title);
118 
119  if(strstr(title, "Cancel"))
120  {
121  ((stageJRMenu*)(laSystemIntegrator::getGame()->getStage(M_STAGE_MENU)))->getMenu()->enable();
122  hide();
123  }
124  else if(strstr(title, "AUTO"))
125  {
126  ((stageJRMenu*)(laSystemIntegrator::getGame()->getStage(M_STAGE_MENU)))->getMenu()->enable();
127  hide();
128 
129  laSystemIntegrator::getGame()->setStage(M_STAGE_GEN);
130 
131  }
132  else if(strstr(title, "EMPTY"))
133  {
134  ((stageJRMenu*)(laSystemIntegrator::getGame()->getStage(M_STAGE_MENU)))->getMenu()->enable();
135  hide();
136 
137  laSystemIntegrator::getGame()->setStage(M_STAGE_EDIT);
138  }
139 }
JR Main Menu, and in-game Menu.
Definition: uiMenu_JR.h:43
#define M_AB
Text align bottom.
virtual void move(laPoint3 ptNewPos, unsigned nHReference=M_AL, unsigned nVReference=M_AT)
Change window position.
Definition: uiWindow.cpp:51
#define M_AL
Text align left.
#define M_AT
Text align top.
GUI Push-button.
Definition: uiButton.h:41
Virtual interface for the Engine graphics renderer.
Definition: laRenderer.h:98
Text Label.
Definition: uiLabel.h:41
Main Menu Stage.
Definition: stageJRMenu.h:63