-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOptionState.cpp
More file actions
154 lines (112 loc) · 4.13 KB
/
OptionState.cpp
File metadata and controls
154 lines (112 loc) · 4.13 KB
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
//|||||||||||||||||||||||||||||||||||||||||||||||
#include "OptionState.hpp"
//|||||||||||||||||||||||||||||||||||||||||||||||
using namespace Ogre;
//|||||||||||||||||||||||||||||||||||||||||||||||
OptionState::OptionState()
{
m_bQuit = false;
m_bQuestionActive = false;
m_FrameEvent = Ogre::FrameEvent();
}
//|||||||||||||||||||||||||||||||||||||||||||||||
void OptionState::enter()
{
OgreFramework::getSingletonPtr()->m_pLog->logMessage("Entering OptionState...");
m_pSceneMgr = OgreFramework::getSingletonPtr()->m_pRoot->createSceneManager(ST_GENERIC, "OptionSceneMgr");
m_pSceneMgr->setAmbientLight(Ogre::ColourValue(0.7f, 0.7f, 0.7f));
m_pCamera = m_pSceneMgr->createCamera("OptionCam");
m_pCamera->setPosition(Vector3(0, 25, -50));
m_pCamera->lookAt(Vector3(0, 0, 0));
m_pCamera->setNearClipDistance(1);
m_pCamera->setAspectRatio(Real(OgreFramework::getSingletonPtr()->m_pViewport->getActualWidth()) /
Real(OgreFramework::getSingletonPtr()->m_pViewport->getActualHeight()));
OgreFramework::getSingletonPtr()->m_pViewport->setCamera(m_pCamera);
OgreFramework::getSingletonPtr()->m_pTrayMgr->destroyAllWidgets();
OgreFramework::getSingletonPtr()->m_pTrayMgr->showCursor();
OgreFramework::getSingletonPtr()->m_pTrayMgr->createButton(OgreBites::TL_CENTER, "BackToMenuBtn", "Return to Menu", 250);
OgreFramework::getSingletonPtr()->m_pTrayMgr->createLabel(OgreBites::TL_TOP, "PauseLbl", "Options", 250);
m_bQuit = false;
createScene();
}
//|||||||||||||||||||||||||||||||||||||||||||||||
void OptionState::createScene()
{
}
//|||||||||||||||||||||||||||||||||||||||||||||||
void OptionState::exit()
{
OgreFramework::getSingletonPtr()->m_pLog->logMessage("Leaving OptionState...");
m_pSceneMgr->destroyCamera(m_pCamera);
if(m_pSceneMgr)
OgreFramework::getSingletonPtr()->m_pRoot->destroySceneManager(m_pSceneMgr);
OgreFramework::getSingletonPtr()->m_pTrayMgr->clearAllTrays();
OgreFramework::getSingletonPtr()->m_pTrayMgr->destroyAllWidgets();
OgreFramework::getSingletonPtr()->m_pTrayMgr->setListener(0);
}
//|||||||||||||||||||||||||||||||||||||||||||||||
bool OptionState::keyPressed(const OIS::KeyEvent &keyEventRef)
{
if(OgreFramework::getSingletonPtr()->m_pKeyboard->isKeyDown(OIS::KC_ESCAPE) && !m_bQuestionActive)
{
m_bQuit = true;
return true;
}
OgreFramework::getSingletonPtr()->keyPressed(keyEventRef);
return true;
}
//|||||||||||||||||||||||||||||||||||||||||||||||
bool OptionState::keyReleased(const OIS::KeyEvent &keyEventRef)
{
OgreFramework::getSingletonPtr()->keyReleased(keyEventRef);
return true;
}
//|||||||||||||||||||||||||||||||||||||||||||||||
bool OptionState::mouseMoved(const OIS::MouseEvent &evt)
{
if(OgreFramework::getSingletonPtr()->m_pTrayMgr->injectMouseMove(evt)) return true;
return true;
}
//|||||||||||||||||||||||||||||||||||||||||||||||
bool OptionState::mousePressed(const OIS::MouseEvent &evt, OIS::MouseButtonID id)
{
if(OgreFramework::getSingletonPtr()->m_pTrayMgr->injectMouseDown(evt, id)) return true;
return true;
}
//|||||||||||||||||||||||||||||||||||||||||||||||
bool OptionState::mouseReleased(const OIS::MouseEvent &evt, OIS::MouseButtonID id)
{
if(OgreFramework::getSingletonPtr()->m_pTrayMgr->injectMouseUp(evt, id)) return true;
return true;
}
//|||||||||||||||||||||||||||||||||||||||||||||||
void OptionState::update(double timeSinceLastFrame)
{
m_FrameEvent.timeSinceLastFrame = timeSinceLastFrame;
OgreFramework::getSingletonPtr()->m_pTrayMgr->frameRenderingQueued(m_FrameEvent);
if(m_bQuit == true)
{
popAppState();
//pushAppState(findByName("MenuState"));
return;
}
}
//|||||||||||||||||||||||||||||||||||||||||||||||
void OptionState::buttonHit(OgreBites::Button *button)
{
if(button->getName() == "BackToMenuBtn")
m_bQuit=true;
//popAppState();
//m_bQuit=true;
//popAllAndPushAppState(findByName("MenuState"));
}
//|||||||||||||||||||||||||||||||||||||||||||||||
void OptionState::yesNoDialogClosed(const Ogre::DisplayString& question, bool yesHit)
{
if(yesHit == true)
shutdown();
else
OgreFramework::getSingletonPtr()->m_pTrayMgr->closeDialog();
m_bQuestionActive = false;
}
//|||||||||||||||||||||||||||||||||||||||||||||||