1 ////////////////////////////////////////////////////////////////////////////////
2 // Scorched3D (c) 2000-2009
4 // This file is part of Scorched3D.
6 // Scorched3D is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
11 // Scorched3D is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with Scorched3D; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 ////////////////////////////////////////////////////////////////////////////////
21 #include <dialogs/StartDialog.h>
22 #include <dialogs/ModSelectDialog.h>
23 #include <dialogs/ModSubSelectDialog.h>
24 #include <dialogs/SaveSelectDialog.h>
25 #include <dialogs/NetworkSelectDialog.h>
26 #include <dialogs/SettingsSelectDialog.h>
27 #include <dialogs/SettingsSubSelectDialog.h>
28 #include <client/ScorchedClient.h>
29 #include <client/ClientParams.h>
30 #include <client/ClientMain.h>
31 #include <engine/GameState.h>
32 #include <engine/MainLoop.h>
33 #include <GLW/GLWColors.h>
34 #include <GLW/GLWFont.h>
35 #include <GLW/GLWTranslate.h>
36 #include <GLW/GLWWindowManager.h>
37 #include <lang/LangResource.h>
39 StartDialog
*StartDialog::instance_
= 0;
41 StartDialog
*StartDialog::instance()
45 instance_
= new StartDialog
;
50 StartDialog::StartDialog() :
51 GLWWindow("", 10.0f
, 10.0f
, 640.0f
, 480.0f
, eNoTitle
),
54 OptionDefinition defs
[] =
56 LANG_RESOURCE("TUTORIAL", "Tutorial"), "- Start the tutorial to learn how to play.", 50.0f
, 60.0f
, 0.0f
,
57 LANG_RESOURCE("LOCAL_GAME", "Local Game"), "- Play a game against the computer or other local players.", 50.0f
, 100.0f
, 0.0f
,
58 LANG_RESOURCE("Network Game", "Network Game"), "- Play an online game against remote players.", 50.0f
, 140.0f
, 0.0f
,
59 LANG_RESOURCE("LOAD SAVE", "Load Save"), "- Continue playing a saved game.", 50.0f
, 180.0f
, 0.0f
,
60 LANG_RESOURCE("HELP", "Help"), "- View the online help.", 50.0f
, 250.0f
, 0.0f
,
61 LANG_RESOURCE("DONATE", "Donate"), "- Show support for Scorched3D.", 50.0f
, 290.0f
, 0.0f
,
62 LANG_RESOURCE("QUIT", "Quit"), "- Exit the game.", 50.0f
, 360.0f
, 0.0f
64 for (int i
=0; i
<sizeof(defs
) / sizeof(OptionDefinition
); i
++)
66 definitions_
.push_back(defs
[i
]);
70 StartDialog::~StartDialog()
74 void StartDialog::draw()
76 int mouseX
= ScorchedClient::instance()->getGameState().getMouseX();
77 int mouseY
= ScorchedClient::instance()->getGameState().getMouseY();
79 GLState
state(GLState::DEPTH_OFF
);
83 float smallSize
= 14.0f
;
84 Vector
white(0.8f
, 0.8f
, 0.8f
);
85 for (int i
=0; i
<(int) definitions_
.size(); i
++)
87 OptionDefinition
&definition
= definitions_
[i
];
90 GLWFont::instance()->getNormalShadowFont()->draw(
91 GLWColors::black
, size
,
92 definition
.x
- 2, h_
- definition
.y
+ 2, 0.0f
,
95 // Check if option is selected
96 Vector
*color
= &white
;
98 mouseX
- GLWTranslate::getPosX(),
99 mouseY
- GLWTranslate::getPosY(),
100 definition
.x
, (h_
- definition
.y
),
101 definition
.width
, 20.0f
))
103 color
= &GLWColors::white
;
108 GLWFont::instance()->getNormalFont()->draw(
110 definition
.x
, h_
- definition
.y
, 0.0f
,
113 GLWFont::instance()->getNormalFont()->getWidth(
114 size
, definition
.option
);
119 GLWFont::instance()->getNormalShadowFont()->draw(
120 GLWColors::black
, smallSize
,
121 definition
.x
+ 200.0f
- 1.5f
, h_
- definition
.y
+ 1.5f
, 0.0f
,
122 definition
.description
);
124 GLWFont::instance()->getNormalFont()->draw(
126 definition
.x
+ 200.0f
, h_
- definition
.y
, 0.0f
,
127 definition
.description
);
132 void StartDialog::mouseDown(int button
, float x
, float y
, bool &skipRest
)
138 // Make sure all other options are hidden
139 GLWWindowManager::instance()->hideWindow(
140 ModSelectDialog::instance()->getId());
141 GLWWindowManager::instance()->hideWindow(
142 ModSubSelectDialog::instance()->getId());
143 GLWWindowManager::instance()->hideWindow(
144 SaveSelectDialog::instance()->getId());
145 GLWWindowManager::instance()->hideWindow(
146 NetworkSelectDialog::instance()->getId());
147 GLWWindowManager::instance()->hideWindow(
148 SettingsSelectDialog::instance()->getId());
149 GLWWindowManager::instance()->hideWindow(
150 SettingsSubSelectDialog::instance()->getId());
157 std::string targetFilePath
= S3D::getDataFile("data/singletutorial.xml");
158 ClientParams::instance()->reset();
159 ClientParams::instance()->setClientFile(targetFilePath
.c_str());
160 ClientMain::startClient();
164 GLWWindowManager::instance()->showWindow(
165 ModSelectDialog::instance()->getId());
168 GLWWindowManager::instance()->showWindow(
169 NetworkSelectDialog::instance()->getId());
172 GLWWindowManager::instance()->showWindow(
173 SaveSelectDialog::instance()->getId());
177 S3D::showURL("http://www.scorched3d.co.uk/wiki");
183 "\"https://www.paypal.com/xclick/business=donations%40"
184 "scorched3d.co.uk&item_name=Scorched3D&no_note=1&tax=0¤cy_code=GBP\"";
189 ScorchedClient::instance()->getMainLoop().exitLoop();