diff options
author | David Walter Seikel | 2013-01-13 18:54:10 +1000 |
---|---|---|
committer | David Walter Seikel | 2013-01-13 18:54:10 +1000 |
commit | 959831f4ef5a3e797f576c3de08cd65032c997ad (patch) | |
tree | e7351908be5995f0b325b2ebeaa02d5a34b82583 /libraries/irrlicht-1.8/examples/Demo/CMainMenu.cpp | |
parent | Add info about changes to Irrlicht. (diff) | |
download | SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.zip SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.gz SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.bz2 SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.xz |
Remove damned ancient DOS line endings from Irrlicht. Hopefully I did not go overboard.
Diffstat (limited to 'libraries/irrlicht-1.8/examples/Demo/CMainMenu.cpp')
-rw-r--r-- | libraries/irrlicht-1.8/examples/Demo/CMainMenu.cpp | 756 |
1 files changed, 378 insertions, 378 deletions
diff --git a/libraries/irrlicht-1.8/examples/Demo/CMainMenu.cpp b/libraries/irrlicht-1.8/examples/Demo/CMainMenu.cpp index aa963e5..8e68f7b 100644 --- a/libraries/irrlicht-1.8/examples/Demo/CMainMenu.cpp +++ b/libraries/irrlicht-1.8/examples/Demo/CMainMenu.cpp | |||
@@ -1,378 +1,378 @@ | |||
1 | // This is a Demo of the Irrlicht Engine (c) 2005-2009 by N.Gebhardt. | 1 | // This is a Demo of the Irrlicht Engine (c) 2005-2009 by N.Gebhardt. |
2 | // This file is not documented. | 2 | // This file is not documented. |
3 | 3 | ||
4 | #include "CMainMenu.h" | 4 | #include "CMainMenu.h" |
5 | 5 | ||
6 | 6 | ||
7 | 7 | ||
8 | CMainMenu::CMainMenu() | 8 | CMainMenu::CMainMenu() |
9 | : startButton(0), MenuDevice(0), selected(2), start(false), fullscreen(true), | 9 | : startButton(0), MenuDevice(0), selected(2), start(false), fullscreen(true), |
10 | music(true), shadows(false), additive(false), transparent(true), vsync(false), aa(false) | 10 | music(true), shadows(false), additive(false), transparent(true), vsync(false), aa(false) |
11 | { | 11 | { |
12 | } | 12 | } |
13 | 13 | ||
14 | 14 | ||
15 | bool CMainMenu::run(bool& outFullscreen, bool& outMusic, bool& outShadows, | 15 | bool CMainMenu::run(bool& outFullscreen, bool& outMusic, bool& outShadows, |
16 | bool& outAdditive, bool& outVSync, bool& outAA, | 16 | bool& outAdditive, bool& outVSync, bool& outAA, |
17 | video::E_DRIVER_TYPE& outDriver) | 17 | video::E_DRIVER_TYPE& outDriver) |
18 | { | 18 | { |
19 | //video::E_DRIVER_TYPE driverType = video::EDT_DIRECT3D9; | 19 | //video::E_DRIVER_TYPE driverType = video::EDT_DIRECT3D9; |
20 | //video::E_DRIVER_TYPE driverType = video::EDT_OPENGL; | 20 | //video::E_DRIVER_TYPE driverType = video::EDT_OPENGL; |
21 | video::E_DRIVER_TYPE driverType = video::EDT_BURNINGSVIDEO; | 21 | video::E_DRIVER_TYPE driverType = video::EDT_BURNINGSVIDEO; |
22 | //video::E_DRIVER_TYPE driverType = video::EDT_SOFTWARE; | 22 | //video::E_DRIVER_TYPE driverType = video::EDT_SOFTWARE; |
23 | 23 | ||
24 | MenuDevice = createDevice(driverType, | 24 | MenuDevice = createDevice(driverType, |
25 | core::dimension2d<u32>(512, 384), 16, false, false, false, this); | 25 | core::dimension2d<u32>(512, 384), 16, false, false, false, this); |
26 | 26 | ||
27 | if (MenuDevice->getFileSystem()->existFile("irrlicht.dat")) | 27 | if (MenuDevice->getFileSystem()->existFile("irrlicht.dat")) |
28 | MenuDevice->getFileSystem()->addFileArchive("irrlicht.dat"); | 28 | MenuDevice->getFileSystem()->addFileArchive("irrlicht.dat"); |
29 | else | 29 | else |
30 | MenuDevice->getFileSystem()->addFileArchive("../../media/irrlicht.dat"); | 30 | MenuDevice->getFileSystem()->addFileArchive("../../media/irrlicht.dat"); |
31 | 31 | ||
32 | video::IVideoDriver* driver = MenuDevice->getVideoDriver(); | 32 | video::IVideoDriver* driver = MenuDevice->getVideoDriver(); |
33 | scene::ISceneManager* smgr = MenuDevice->getSceneManager(); | 33 | scene::ISceneManager* smgr = MenuDevice->getSceneManager(); |
34 | gui::IGUIEnvironment* guienv = MenuDevice->getGUIEnvironment(); | 34 | gui::IGUIEnvironment* guienv = MenuDevice->getGUIEnvironment(); |
35 | 35 | ||
36 | core::stringw str = "Irrlicht Engine Demo v"; | 36 | core::stringw str = "Irrlicht Engine Demo v"; |
37 | str += MenuDevice->getVersion(); | 37 | str += MenuDevice->getVersion(); |
38 | MenuDevice->setWindowCaption(str.c_str()); | 38 | MenuDevice->setWindowCaption(str.c_str()); |
39 | 39 | ||
40 | // set new Skin | 40 | // set new Skin |
41 | gui::IGUISkin* newskin = guienv->createSkin(gui::EGST_BURNING_SKIN); | 41 | gui::IGUISkin* newskin = guienv->createSkin(gui::EGST_BURNING_SKIN); |
42 | guienv->setSkin(newskin); | 42 | guienv->setSkin(newskin); |
43 | newskin->drop(); | 43 | newskin->drop(); |
44 | 44 | ||
45 | // load font | 45 | // load font |
46 | gui::IGUIFont* font = guienv->getFont("../../media/fonthaettenschweiler.bmp"); | 46 | gui::IGUIFont* font = guienv->getFont("../../media/fonthaettenschweiler.bmp"); |
47 | if (font) | 47 | if (font) |
48 | guienv->getSkin()->setFont(font); | 48 | guienv->getSkin()->setFont(font); |
49 | 49 | ||
50 | // add images | 50 | // add images |
51 | 51 | ||
52 | const s32 leftX = 260; | 52 | const s32 leftX = 260; |
53 | 53 | ||
54 | // add tab control | 54 | // add tab control |
55 | gui::IGUITabControl* tabctrl = guienv->addTabControl(core::rect<int>(leftX,10,512-10,384-10), | 55 | gui::IGUITabControl* tabctrl = guienv->addTabControl(core::rect<int>(leftX,10,512-10,384-10), |
56 | 0, true, true); | 56 | 0, true, true); |
57 | gui::IGUITab* optTab = tabctrl->addTab(L"Demo"); | 57 | gui::IGUITab* optTab = tabctrl->addTab(L"Demo"); |
58 | gui::IGUITab* aboutTab = tabctrl->addTab(L"About"); | 58 | gui::IGUITab* aboutTab = tabctrl->addTab(L"About"); |
59 | 59 | ||
60 | // add list box | 60 | // add list box |
61 | 61 | ||
62 | gui::IGUIListBox* box = guienv->addListBox(core::rect<int>(10,10,220,120), optTab, 1); | 62 | gui::IGUIListBox* box = guienv->addListBox(core::rect<int>(10,10,220,120), optTab, 1); |
63 | box->addItem(L"OpenGL 1.5"); | 63 | box->addItem(L"OpenGL 1.5"); |
64 | box->addItem(L"Direct3D 8.1"); | 64 | box->addItem(L"Direct3D 8.1"); |
65 | box->addItem(L"Direct3D 9.0c"); | 65 | box->addItem(L"Direct3D 9.0c"); |
66 | box->addItem(L"Burning's Video 0.47"); | 66 | box->addItem(L"Burning's Video 0.47"); |
67 | box->addItem(L"Irrlicht Software Renderer 1.0"); | 67 | box->addItem(L"Irrlicht Software Renderer 1.0"); |
68 | box->setSelected(selected); | 68 | box->setSelected(selected); |
69 | 69 | ||
70 | // add button | 70 | // add button |
71 | 71 | ||
72 | startButton = guienv->addButton(core::rect<int>(30,295,200,324), optTab, 2, L"Start Demo"); | 72 | startButton = guienv->addButton(core::rect<int>(30,295,200,324), optTab, 2, L"Start Demo"); |
73 | 73 | ||
74 | // add checkbox | 74 | // add checkbox |
75 | 75 | ||
76 | const s32 d = 50; | 76 | const s32 d = 50; |
77 | 77 | ||
78 | guienv->addCheckBox(fullscreen, core::rect<int>(20,85+d,130,110+d), | 78 | guienv->addCheckBox(fullscreen, core::rect<int>(20,85+d,130,110+d), |
79 | optTab, 3, L"Fullscreen"); | 79 | optTab, 3, L"Fullscreen"); |
80 | guienv->addCheckBox(music, core::rect<int>(135,85+d,245,110+d), | 80 | guienv->addCheckBox(music, core::rect<int>(135,85+d,245,110+d), |
81 | optTab, 4, L"Music & Sfx"); | 81 | optTab, 4, L"Music & Sfx"); |
82 | guienv->addCheckBox(shadows, core::rect<int>(20,110+d,135,135+d), | 82 | guienv->addCheckBox(shadows, core::rect<int>(20,110+d,135,135+d), |
83 | optTab, 5, L"Realtime shadows"); | 83 | optTab, 5, L"Realtime shadows"); |
84 | guienv->addCheckBox(additive, core::rect<int>(20,135+d,230,160+d), | 84 | guienv->addCheckBox(additive, core::rect<int>(20,135+d,230,160+d), |
85 | optTab, 6, L"Old HW compatible blending"); | 85 | optTab, 6, L"Old HW compatible blending"); |
86 | guienv->addCheckBox(vsync, core::rect<int>(20,160+d,230,185+d), | 86 | guienv->addCheckBox(vsync, core::rect<int>(20,160+d,230,185+d), |
87 | optTab, 7, L"Vertical synchronisation"); | 87 | optTab, 7, L"Vertical synchronisation"); |
88 | guienv->addCheckBox(aa, core::rect<int>(20,185+d,230,210+d), | 88 | guienv->addCheckBox(aa, core::rect<int>(20,185+d,230,210+d), |
89 | optTab, 8, L"Antialiasing"); | 89 | optTab, 8, L"Antialiasing"); |
90 | 90 | ||
91 | // add about text | 91 | // add about text |
92 | 92 | ||
93 | const wchar_t* text2 = L"This is the tech demo of the Irrlicht engine. To start, "\ | 93 | const wchar_t* text2 = L"This is the tech demo of the Irrlicht engine. To start, "\ |
94 | L"select a video driver which works best with your hardware and press 'Start Demo'.\n"\ | 94 | L"select a video driver which works best with your hardware and press 'Start Demo'.\n"\ |
95 | L"What you currently see is displayed using the Burning Software Renderer (Thomas Alten).\n"\ | 95 | L"What you currently see is displayed using the Burning Software Renderer (Thomas Alten).\n"\ |
96 | L"The Irrlicht Engine was written by me, Nikolaus Gebhardt. The models, "\ | 96 | L"The Irrlicht Engine was written by me, Nikolaus Gebhardt. The models, "\ |
97 | L"maps and textures were placed at my disposal by B.Collins, M.Cook and J.Marton. The music was created by "\ | 97 | L"maps and textures were placed at my disposal by B.Collins, M.Cook and J.Marton. The music was created by "\ |
98 | L"M.Rohde and is played back by irrKlang.\n"\ | 98 | L"M.Rohde and is played back by irrKlang.\n"\ |
99 | L"For more informations, please visit the homepage of the Irrlicht engine:\nhttp://irrlicht.sourceforge.net"; | 99 | L"For more informations, please visit the homepage of the Irrlicht engine:\nhttp://irrlicht.sourceforge.net"; |
100 | 100 | ||
101 | guienv->addStaticText(text2, core::rect<int>(10, 10, 230, 320), | 101 | guienv->addStaticText(text2, core::rect<int>(10, 10, 230, 320), |
102 | true, true, aboutTab); | 102 | true, true, aboutTab); |
103 | 103 | ||
104 | // add md2 model | 104 | // add md2 model |
105 | 105 | ||
106 | scene::IAnimatedMesh* mesh = smgr->getMesh("../../media/faerie.md2"); | 106 | scene::IAnimatedMesh* mesh = smgr->getMesh("../../media/faerie.md2"); |
107 | scene::IAnimatedMeshSceneNode* modelNode = smgr->addAnimatedMeshSceneNode(mesh); | 107 | scene::IAnimatedMeshSceneNode* modelNode = smgr->addAnimatedMeshSceneNode(mesh); |
108 | if (modelNode) | 108 | if (modelNode) |
109 | { | 109 | { |
110 | modelNode->setPosition( core::vector3df(0.f, 0.f, -5.f) ); | 110 | modelNode->setPosition( core::vector3df(0.f, 0.f, -5.f) ); |
111 | modelNode->setMaterialTexture(0, driver->getTexture("../../media/faerie2.bmp")); | 111 | modelNode->setMaterialTexture(0, driver->getTexture("../../media/faerie2.bmp")); |
112 | modelNode->setMaterialFlag(video::EMF_LIGHTING, true); | 112 | modelNode->setMaterialFlag(video::EMF_LIGHTING, true); |
113 | modelNode->getMaterial(0).Shininess = 50.f; | 113 | modelNode->getMaterial(0).Shininess = 50.f; |
114 | modelNode->getMaterial(0).NormalizeNormals = true; | 114 | modelNode->getMaterial(0).NormalizeNormals = true; |
115 | modelNode->setMD2Animation(scene::EMAT_STAND); | 115 | modelNode->setMD2Animation(scene::EMAT_STAND); |
116 | } | 116 | } |
117 | 117 | ||
118 | // set ambient light (no sun light in the catacombs) | 118 | // set ambient light (no sun light in the catacombs) |
119 | smgr->setAmbientLight( video::SColorf(0.2f, 0.2f, 0.2f) ); | 119 | smgr->setAmbientLight( video::SColorf(0.2f, 0.2f, 0.2f) ); |
120 | 120 | ||
121 | scene::ILightSceneNode *light; | 121 | scene::ILightSceneNode *light; |
122 | scene::ISceneNodeAnimator* anim; | 122 | scene::ISceneNodeAnimator* anim; |
123 | scene::ISceneNode* bill; | 123 | scene::ISceneNode* bill; |
124 | 124 | ||
125 | enum eLightParticle | 125 | enum eLightParticle |
126 | { | 126 | { |
127 | LIGHT_NONE, | 127 | LIGHT_NONE, |
128 | LIGHT_GLOBAL, | 128 | LIGHT_GLOBAL, |
129 | LIGHT_RED, | 129 | LIGHT_RED, |
130 | LIGHT_BLUE | 130 | LIGHT_BLUE |
131 | }; | 131 | }; |
132 | core::vector3df lightDir[2] = { | 132 | core::vector3df lightDir[2] = { |
133 | core::vector3df(0.f, 0.1f, 0.4f), | 133 | core::vector3df(0.f, 0.1f, 0.4f), |
134 | core::vector3df(0.f, 0.1f, -0.4f), | 134 | core::vector3df(0.f, 0.1f, -0.4f), |
135 | }; | 135 | }; |
136 | 136 | ||
137 | struct SLightParticle | 137 | struct SLightParticle |
138 | { | 138 | { |
139 | eLightParticle type; | 139 | eLightParticle type; |
140 | u32 dir; | 140 | u32 dir; |
141 | }; | 141 | }; |
142 | const SLightParticle lightParticle[] = | 142 | const SLightParticle lightParticle[] = |
143 | { | 143 | { |
144 | //LIGHT_GLOBAL,0, | 144 | //LIGHT_GLOBAL,0, |
145 | {LIGHT_RED,0}, | 145 | {LIGHT_RED,0}, |
146 | {LIGHT_BLUE,0}, | 146 | {LIGHT_BLUE,0}, |
147 | {LIGHT_RED,1}, | 147 | {LIGHT_RED,1}, |
148 | {LIGHT_BLUE,1}, | 148 | {LIGHT_BLUE,1}, |
149 | {LIGHT_NONE,0} | 149 | {LIGHT_NONE,0} |
150 | }; | 150 | }; |
151 | 151 | ||
152 | const SLightParticle *l = lightParticle; | 152 | const SLightParticle *l = lightParticle; |
153 | while ( l->type != LIGHT_NONE ) | 153 | while ( l->type != LIGHT_NONE ) |
154 | { | 154 | { |
155 | switch ( l->type ) | 155 | switch ( l->type ) |
156 | { | 156 | { |
157 | case LIGHT_GLOBAL: | 157 | case LIGHT_GLOBAL: |
158 | // add illumination from the background | 158 | // add illumination from the background |
159 | light = smgr->addLightSceneNode(0, core::vector3df(10.f,40.f,-5.f), | 159 | light = smgr->addLightSceneNode(0, core::vector3df(10.f,40.f,-5.f), |
160 | video::SColorf(0.2f, 0.2f, 0.2f), 90.f); | 160 | video::SColorf(0.2f, 0.2f, 0.2f), 90.f); |
161 | break; | 161 | break; |
162 | case LIGHT_RED: | 162 | case LIGHT_RED: |
163 | // add light nearly red | 163 | // add light nearly red |
164 | light = smgr->addLightSceneNode(0, core::vector3df(0,1,0), | 164 | light = smgr->addLightSceneNode(0, core::vector3df(0,1,0), |
165 | video::SColorf(0.8f, 0.f, 0.f, 0.0f), 30.0f); | 165 | video::SColorf(0.8f, 0.f, 0.f, 0.0f), 30.0f); |
166 | // attach red billboard to the light | 166 | // attach red billboard to the light |
167 | bill = smgr->addBillboardSceneNode(light, core::dimension2d<f32>(10, 10)); | 167 | bill = smgr->addBillboardSceneNode(light, core::dimension2d<f32>(10, 10)); |
168 | if ( bill ) | 168 | if ( bill ) |
169 | { | 169 | { |
170 | bill->setMaterialFlag(video::EMF_LIGHTING, false); | 170 | bill->setMaterialFlag(video::EMF_LIGHTING, false); |
171 | bill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR); | 171 | bill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR); |
172 | bill->setMaterialTexture(0, driver->getTexture("../../media/particlered.bmp")); | 172 | bill->setMaterialTexture(0, driver->getTexture("../../media/particlered.bmp")); |
173 | } | 173 | } |
174 | // add fly circle animator to the light | 174 | // add fly circle animator to the light |
175 | anim = smgr->createFlyCircleAnimator(core::vector3df(0.f,0.f,-5.f),20.f, | 175 | anim = smgr->createFlyCircleAnimator(core::vector3df(0.f,0.f,-5.f),20.f, |
176 | 0.002f, lightDir [l->dir] ); | 176 | 0.002f, lightDir [l->dir] ); |
177 | light->addAnimator(anim); | 177 | light->addAnimator(anim); |
178 | anim->drop(); | 178 | anim->drop(); |
179 | break; | 179 | break; |
180 | case LIGHT_BLUE: | 180 | case LIGHT_BLUE: |
181 | // add light nearly blue | 181 | // add light nearly blue |
182 | light = smgr->addLightSceneNode(0, core::vector3df(0,1,0), | 182 | light = smgr->addLightSceneNode(0, core::vector3df(0,1,0), |
183 | video::SColorf(0.f, 0.0f, 0.8f, 0.0f), 30.0f); | 183 | video::SColorf(0.f, 0.0f, 0.8f, 0.0f), 30.0f); |
184 | // attach blue billboard to the light | 184 | // attach blue billboard to the light |
185 | bill = smgr->addBillboardSceneNode(light, core::dimension2d<f32>(10, 10)); | 185 | bill = smgr->addBillboardSceneNode(light, core::dimension2d<f32>(10, 10)); |
186 | if (bill) | 186 | if (bill) |
187 | { | 187 | { |
188 | bill->setMaterialFlag(video::EMF_LIGHTING, false); | 188 | bill->setMaterialFlag(video::EMF_LIGHTING, false); |
189 | bill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR); | 189 | bill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR); |
190 | bill->setMaterialTexture(0, driver->getTexture("../../media/portal1.bmp")); | 190 | bill->setMaterialTexture(0, driver->getTexture("../../media/portal1.bmp")); |
191 | } | 191 | } |
192 | // add fly circle animator to the light | 192 | // add fly circle animator to the light |
193 | anim = smgr->createFlyCircleAnimator(core::vector3df(0.f,0.f,-5.f),20.f, | 193 | anim = smgr->createFlyCircleAnimator(core::vector3df(0.f,0.f,-5.f),20.f, |
194 | -0.002f, lightDir [l->dir], 0.5f); | 194 | -0.002f, lightDir [l->dir], 0.5f); |
195 | light->addAnimator(anim); | 195 | light->addAnimator(anim); |
196 | anim->drop(); | 196 | anim->drop(); |
197 | break; | 197 | break; |
198 | case LIGHT_NONE: | 198 | case LIGHT_NONE: |
199 | break; | 199 | break; |
200 | } | 200 | } |
201 | l += 1; | 201 | l += 1; |
202 | } | 202 | } |
203 | 203 | ||
204 | // create a fixed camera | 204 | // create a fixed camera |
205 | smgr->addCameraSceneNode(0, core::vector3df(45,0,0), core::vector3df(0,0,10)); | 205 | smgr->addCameraSceneNode(0, core::vector3df(45,0,0), core::vector3df(0,0,10)); |
206 | 206 | ||
207 | 207 | ||
208 | // irrlicht logo and background | 208 | // irrlicht logo and background |
209 | // add irrlicht logo | 209 | // add irrlicht logo |
210 | bool oldMipMapState = driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS); | 210 | bool oldMipMapState = driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS); |
211 | driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false); | 211 | driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false); |
212 | 212 | ||
213 | guienv->addImage(driver->getTexture("../../media/irrlichtlogo3.png"), | 213 | guienv->addImage(driver->getTexture("../../media/irrlichtlogo3.png"), |
214 | core::position2d<s32>(5,5)); | 214 | core::position2d<s32>(5,5)); |
215 | 215 | ||
216 | video::ITexture* irrlichtBack = driver->getTexture("../../media/demoback.jpg"); | 216 | video::ITexture* irrlichtBack = driver->getTexture("../../media/demoback.jpg"); |
217 | 217 | ||
218 | driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, oldMipMapState); | 218 | driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, oldMipMapState); |
219 | 219 | ||
220 | // query original skin color | 220 | // query original skin color |
221 | getOriginalSkinColor(); | 221 | getOriginalSkinColor(); |
222 | 222 | ||
223 | // set transparency | 223 | // set transparency |
224 | setTransparency(); | 224 | setTransparency(); |
225 | 225 | ||
226 | // draw all | 226 | // draw all |
227 | 227 | ||
228 | while(MenuDevice->run()) | 228 | while(MenuDevice->run()) |
229 | { | 229 | { |
230 | if (MenuDevice->isWindowActive()) | 230 | if (MenuDevice->isWindowActive()) |
231 | { | 231 | { |
232 | driver->beginScene(false, true, video::SColor(0,0,0,0)); | 232 | driver->beginScene(false, true, video::SColor(0,0,0,0)); |
233 | 233 | ||
234 | if (irrlichtBack) | 234 | if (irrlichtBack) |
235 | driver->draw2DImage(irrlichtBack, | 235 | driver->draw2DImage(irrlichtBack, |
236 | core::position2d<int>(0,0)); | 236 | core::position2d<int>(0,0)); |
237 | 237 | ||
238 | smgr->drawAll(); | 238 | smgr->drawAll(); |
239 | guienv->drawAll(); | 239 | guienv->drawAll(); |
240 | driver->endScene(); | 240 | driver->endScene(); |
241 | } | 241 | } |
242 | } | 242 | } |
243 | 243 | ||
244 | MenuDevice->drop(); | 244 | MenuDevice->drop(); |
245 | 245 | ||
246 | outFullscreen = fullscreen; | 246 | outFullscreen = fullscreen; |
247 | outMusic = music; | 247 | outMusic = music; |
248 | outShadows = shadows; | 248 | outShadows = shadows; |
249 | outAdditive = additive; | 249 | outAdditive = additive; |
250 | outVSync = vsync; | 250 | outVSync = vsync; |
251 | outAA = aa; | 251 | outAA = aa; |
252 | 252 | ||
253 | switch(selected) | 253 | switch(selected) |
254 | { | 254 | { |
255 | case 0: outDriver = video::EDT_OPENGL; break; | 255 | case 0: outDriver = video::EDT_OPENGL; break; |
256 | case 1: outDriver = video::EDT_DIRECT3D8; break; | 256 | case 1: outDriver = video::EDT_DIRECT3D8; break; |
257 | case 2: outDriver = video::EDT_DIRECT3D9; break; | 257 | case 2: outDriver = video::EDT_DIRECT3D9; break; |
258 | case 3: outDriver = video::EDT_BURNINGSVIDEO; break; | 258 | case 3: outDriver = video::EDT_BURNINGSVIDEO; break; |
259 | case 4: outDriver = video::EDT_SOFTWARE; break; | 259 | case 4: outDriver = video::EDT_SOFTWARE; break; |
260 | } | 260 | } |
261 | 261 | ||
262 | return start; | 262 | return start; |
263 | } | 263 | } |
264 | 264 | ||
265 | 265 | ||
266 | bool CMainMenu::OnEvent(const SEvent& event) | 266 | bool CMainMenu::OnEvent(const SEvent& event) |
267 | { | 267 | { |
268 | if (event.EventType == EET_KEY_INPUT_EVENT && | 268 | if (event.EventType == EET_KEY_INPUT_EVENT && |
269 | event.KeyInput.Key == KEY_F9 && | 269 | event.KeyInput.Key == KEY_F9 && |
270 | event.KeyInput.PressedDown == false) | 270 | event.KeyInput.PressedDown == false) |
271 | { | 271 | { |
272 | video::IImage* image = MenuDevice->getVideoDriver()->createScreenShot(); | 272 | video::IImage* image = MenuDevice->getVideoDriver()->createScreenShot(); |
273 | if (image) | 273 | if (image) |
274 | { | 274 | { |
275 | MenuDevice->getVideoDriver()->writeImageToFile(image, "screenshot_main.jpg"); | 275 | MenuDevice->getVideoDriver()->writeImageToFile(image, "screenshot_main.jpg"); |
276 | image->drop(); | 276 | image->drop(); |
277 | } | 277 | } |
278 | } | 278 | } |
279 | else | 279 | else |
280 | if (event.EventType == irr::EET_MOUSE_INPUT_EVENT && | 280 | if (event.EventType == irr::EET_MOUSE_INPUT_EVENT && |
281 | event.MouseInput.Event == EMIE_RMOUSE_LEFT_UP ) | 281 | event.MouseInput.Event == EMIE_RMOUSE_LEFT_UP ) |
282 | { | 282 | { |
283 | core::rect<s32> r(event.MouseInput.X, event.MouseInput.Y, 0, 0); | 283 | core::rect<s32> r(event.MouseInput.X, event.MouseInput.Y, 0, 0); |
284 | gui::IGUIContextMenu* menu = MenuDevice->getGUIEnvironment()->addContextMenu(r, 0, 45); | 284 | gui::IGUIContextMenu* menu = MenuDevice->getGUIEnvironment()->addContextMenu(r, 0, 45); |
285 | menu->addItem(L"transparent menus", 666, transparent == false); | 285 | menu->addItem(L"transparent menus", 666, transparent == false); |
286 | menu->addItem(L"solid menus", 666, transparent == true); | 286 | menu->addItem(L"solid menus", 666, transparent == true); |
287 | menu->addSeparator(); | 287 | menu->addSeparator(); |
288 | menu->addItem(L"Cancel"); | 288 | menu->addItem(L"Cancel"); |
289 | } | 289 | } |
290 | else | 290 | else |
291 | if (event.EventType == EET_GUI_EVENT) | 291 | if (event.EventType == EET_GUI_EVENT) |
292 | { | 292 | { |
293 | s32 id = event.GUIEvent.Caller->getID(); | 293 | s32 id = event.GUIEvent.Caller->getID(); |
294 | switch(id) | 294 | switch(id) |
295 | { | 295 | { |
296 | case 45: // context menu | 296 | case 45: // context menu |
297 | if (event.GUIEvent.EventType == gui::EGET_MENU_ITEM_SELECTED) | 297 | if (event.GUIEvent.EventType == gui::EGET_MENU_ITEM_SELECTED) |
298 | { | 298 | { |
299 | s32 s = ((gui::IGUIContextMenu*)event.GUIEvent.Caller)->getSelectedItem(); | 299 | s32 s = ((gui::IGUIContextMenu*)event.GUIEvent.Caller)->getSelectedItem(); |
300 | if (s == 0 || s == 1) | 300 | if (s == 0 || s == 1) |
301 | { | 301 | { |
302 | transparent = !transparent; | 302 | transparent = !transparent; |
303 | setTransparency(); | 303 | setTransparency(); |
304 | } | 304 | } |
305 | } | 305 | } |
306 | break; | 306 | break; |
307 | case 1: | 307 | case 1: |
308 | if (event.GUIEvent.EventType == gui::EGET_LISTBOX_CHANGED || | 308 | if (event.GUIEvent.EventType == gui::EGET_LISTBOX_CHANGED || |
309 | event.GUIEvent.EventType == gui::EGET_LISTBOX_SELECTED_AGAIN) | 309 | event.GUIEvent.EventType == gui::EGET_LISTBOX_SELECTED_AGAIN) |
310 | { | 310 | { |
311 | selected = ((gui::IGUIListBox*)event.GUIEvent.Caller)->getSelected(); | 311 | selected = ((gui::IGUIListBox*)event.GUIEvent.Caller)->getSelected(); |
312 | //startButton->setEnabled(selected != 4); | 312 | //startButton->setEnabled(selected != 4); |
313 | startButton->setEnabled(true); | 313 | startButton->setEnabled(true); |
314 | } | 314 | } |
315 | break; | 315 | break; |
316 | case 2: | 316 | case 2: |
317 | if (event.GUIEvent.EventType == gui::EGET_BUTTON_CLICKED ) | 317 | if (event.GUIEvent.EventType == gui::EGET_BUTTON_CLICKED ) |
318 | { | 318 | { |
319 | MenuDevice->closeDevice(); | 319 | MenuDevice->closeDevice(); |
320 | start = true; | 320 | start = true; |
321 | } | 321 | } |
322 | case 3: | 322 | case 3: |
323 | if (event.GUIEvent.EventType == gui::EGET_CHECKBOX_CHANGED ) | 323 | if (event.GUIEvent.EventType == gui::EGET_CHECKBOX_CHANGED ) |
324 | fullscreen = ((gui::IGUICheckBox*)event.GUIEvent.Caller)->isChecked(); | 324 | fullscreen = ((gui::IGUICheckBox*)event.GUIEvent.Caller)->isChecked(); |
325 | break; | 325 | break; |
326 | case 4: | 326 | case 4: |
327 | if (event.GUIEvent.EventType == gui::EGET_CHECKBOX_CHANGED ) | 327 | if (event.GUIEvent.EventType == gui::EGET_CHECKBOX_CHANGED ) |
328 | music = ((gui::IGUICheckBox*)event.GUIEvent.Caller)->isChecked(); | 328 | music = ((gui::IGUICheckBox*)event.GUIEvent.Caller)->isChecked(); |
329 | break; | 329 | break; |
330 | case 5: | 330 | case 5: |
331 | if (event.GUIEvent.EventType == gui::EGET_CHECKBOX_CHANGED ) | 331 | if (event.GUIEvent.EventType == gui::EGET_CHECKBOX_CHANGED ) |
332 | shadows = ((gui::IGUICheckBox*)event.GUIEvent.Caller)->isChecked(); | 332 | shadows = ((gui::IGUICheckBox*)event.GUIEvent.Caller)->isChecked(); |
333 | break; | 333 | break; |
334 | case 6: | 334 | case 6: |
335 | if (event.GUIEvent.EventType == gui::EGET_CHECKBOX_CHANGED ) | 335 | if (event.GUIEvent.EventType == gui::EGET_CHECKBOX_CHANGED ) |
336 | additive = ((gui::IGUICheckBox*)event.GUIEvent.Caller)->isChecked(); | 336 | additive = ((gui::IGUICheckBox*)event.GUIEvent.Caller)->isChecked(); |
337 | break; | 337 | break; |
338 | case 7: | 338 | case 7: |
339 | if (event.GUIEvent.EventType == gui::EGET_CHECKBOX_CHANGED ) | 339 | if (event.GUIEvent.EventType == gui::EGET_CHECKBOX_CHANGED ) |
340 | vsync = ((gui::IGUICheckBox*)event.GUIEvent.Caller)->isChecked(); | 340 | vsync = ((gui::IGUICheckBox*)event.GUIEvent.Caller)->isChecked(); |
341 | break; | 341 | break; |
342 | case 8: | 342 | case 8: |
343 | if (event.GUIEvent.EventType == gui::EGET_CHECKBOX_CHANGED ) | 343 | if (event.GUIEvent.EventType == gui::EGET_CHECKBOX_CHANGED ) |
344 | aa = ((gui::IGUICheckBox*)event.GUIEvent.Caller)->isChecked(); | 344 | aa = ((gui::IGUICheckBox*)event.GUIEvent.Caller)->isChecked(); |
345 | break; | 345 | break; |
346 | } | 346 | } |
347 | } | 347 | } |
348 | 348 | ||
349 | return false; | 349 | return false; |
350 | } | 350 | } |
351 | 351 | ||
352 | 352 | ||
353 | void CMainMenu::getOriginalSkinColor() | 353 | void CMainMenu::getOriginalSkinColor() |
354 | { | 354 | { |
355 | irr::gui::IGUISkin * skin = MenuDevice->getGUIEnvironment()->getSkin(); | 355 | irr::gui::IGUISkin * skin = MenuDevice->getGUIEnvironment()->getSkin(); |
356 | for (s32 i=0; i<gui::EGDC_COUNT ; ++i) | 356 | for (s32 i=0; i<gui::EGDC_COUNT ; ++i) |
357 | { | 357 | { |
358 | SkinColor[i] = skin->getColor( (gui::EGUI_DEFAULT_COLOR)i ); | 358 | SkinColor[i] = skin->getColor( (gui::EGUI_DEFAULT_COLOR)i ); |
359 | } | 359 | } |
360 | 360 | ||
361 | } | 361 | } |
362 | 362 | ||
363 | 363 | ||
364 | void CMainMenu::setTransparency() | 364 | void CMainMenu::setTransparency() |
365 | { | 365 | { |
366 | irr::gui::IGUISkin * skin = MenuDevice->getGUIEnvironment()->getSkin(); | 366 | irr::gui::IGUISkin * skin = MenuDevice->getGUIEnvironment()->getSkin(); |
367 | 367 | ||
368 | for (u32 i=0; i<gui::EGDC_COUNT ; ++i) | 368 | for (u32 i=0; i<gui::EGDC_COUNT ; ++i) |
369 | { | 369 | { |
370 | video::SColor col = SkinColor[i]; | 370 | video::SColor col = SkinColor[i]; |
371 | 371 | ||
372 | if (false == transparent) | 372 | if (false == transparent) |
373 | col.setAlpha(255); | 373 | col.setAlpha(255); |
374 | 374 | ||
375 | skin->setColor((gui::EGUI_DEFAULT_COLOR)i, col); | 375 | skin->setColor((gui::EGUI_DEFAULT_COLOR)i, col); |
376 | } | 376 | } |
377 | } | 377 | } |
378 | 378 | ||