Accessory sorting due to price.
[scorched3d.git] / src / client / dialogs / HelpButtonDialog.cpp
blob3d4ddea309d183f495737929e3587f271683a5f7
1 ////////////////////////////////////////////////////////////////////////////////
2 // Scorched3D (c) 2000-2009
3 //
4 // This file is part of Scorched3D.
5 //
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 <stdio.h>
22 #include <graph/FrameTimer.h>
23 #include <graph/OptionsDisplay.h>
24 #include <graph/MainCamera.h>
25 #include <graph/ParticleEngine.h>
26 #include <dialogs/MainMenuDialog.h>
27 #include <dialogs/HelpButtonDialog.h>
28 #include <dialogs/SoundDialog.h>
29 #include <common/Defines.h>
30 #include <sound/Sound.h>
31 #include <GLEXT/GLInfo.h>
32 #include <GLEXT/GLState.h>
33 #include <GLEXT/GLMenu.h>
34 #include <client/ScorchedClient.h>
35 #include <client/ClientChannelManager.h>
36 #include <tankgraph/RenderTargets.h>
37 #include <engine/ActionController.h>
38 #include <image/ImageFactory.h>
39 #include <landscape/Landscape.h>
40 #include <landscape/ShadowMap.h>
41 #include <land/VisibilityPatchGrid.h>
42 #include <GLW/GLWWindowManager.h>
44 HelpButtonDialog *HelpButtonDialog::instance_ = 0;
46 HelpButtonDialog *HelpButtonDialog::instance()
48 if (!instance_)
50 instance_ = new HelpButtonDialog();
52 return instance_;
55 HelpButtonDialog::HelpButtonDialog() :
56 performanceMenu_(), volumeMenu_(), helpMenu_()
60 HelpButtonDialog::~HelpButtonDialog()
64 HelpButtonDialog::HelpMenu::HelpMenu()
66 Image *map =
67 ImageFactory::loadImage(
68 S3D::getDataFile("data/windows/help.bmp"),
69 S3D::getDataFile("data/windows/helpa.bmp"),
70 false);
71 DIALOG_ASSERT(map->getBits());
72 MainMenuDialog::instance()->
73 addMenu(LANG_RESOURCE("HELP", "Help"),
74 "Help",
75 LANG_RESOURCE("HELP_MENU", "Launch an external web browser containing the\n"
76 "Scorched3D online help."),
77 32.0f, 0, this, map,
78 GLMenu::eMenuAlignRight);
81 bool HelpButtonDialog::HelpMenu::getMenuItems(const char* menuName, std::list<GLMenuItem> &result)
83 result.push_back(GLMenuItem(LANG_RESOURCE("SHOW_ONLINE_HELP", "Show Online Help")));
84 return true;
87 void HelpButtonDialog::HelpMenu::menuSelection(const char* menuName,
88 const int position, GLMenuItem &item)
90 S3D::showURL("http://www.scorched3d.co.uk/wiki");
93 HelpButtonDialog::VolumeMenu::VolumeMenu()
95 Image *map = ImageFactory::loadImage(
96 S3D::getDataFile("data/windows/sound.bmp"),
97 S3D::getDataFile("data/windows/sounda.bmp"),
98 false);
99 DIALOG_ASSERT(map->getBits());
100 MainMenuDialog::instance()->
101 addMenu(LANG_RESOURCE("VOLUME", "Volume"),
102 "Volume",
103 LANG_RESOURCE("VOLUME_MENU", "Change the sound and volume settings"),
104 32.0f, 0, this, map,
105 GLMenu::eMenuAlignRight);
108 bool HelpButtonDialog::VolumeMenu::menuOpened(const char* menuName)
110 GLWWindowManager::instance()->showWindow(
111 SoundDialog::instance()->getId());
112 return false;
115 HelpButtonDialog::PerformanceMenu::PerformanceMenu()
117 Image *map =
118 ImageFactory::loadImage(
119 S3D::getDataFile("data/windows/perf.bmp"),
120 S3D::getDataFile("data/windows/perfa.bmp"),
121 false);
122 DIALOG_ASSERT(map->getBits());
123 MainMenuDialog::instance()->
124 addMenu(LANG_RESOURCE("PERFORMANCE", "Perofmance"),
125 "Performance",
126 LANG_STRING(""),
127 32.0f, 0, this, map,
128 GLMenu::eMenuAlignRight);
131 bool HelpButtonDialog::PerformanceMenu::getMenuItems(const char* menuName, std::list<GLMenuItem> &result)
133 return true;
136 void HelpButtonDialog::PerformanceMenu::menuSelection(const char* menuName,
137 const int position, GLMenuItem &item)
141 LangStringStorage *HelpButtonDialog::PerformanceMenu::getMenuToolTip(const char* menuName)
143 static LangString result;
145 unsigned int pOnScreen =
146 ScorchedClient::instance()->
147 getParticleEngine().getParticlesOnScreen() +
148 MainCamera::instance()->getTarget().
149 getPrecipitationEngine().getParticlesOnScreen();
151 result = LANG_STRING(S3D::formatStringBuffer(
152 "%.2f Frames Per Second\n"
153 " %i Triangles Drawn\n"
154 " %i Particles Drawn\n"
155 " %i Land and %i Water Patches Visible\n"
156 " %i Trees Drawn\n"
157 " %i Targets Drawn\n"
158 " %i Playing Sound Channels\n"
159 " %u Shadows Drawn\n"
160 " %u OpenGL State Changes\n"
161 " %u OpenGL Texture Changes\n",
163 FrameTimer::instance()->getFPS(),
164 FrameTimer::instance()->getLastTris(),
165 pOnScreen,
166 VisibilityPatchGrid::instance()->getVisibleLandPatchesCount(),
167 VisibilityPatchGrid::instance()->getVisibleWaterPatchesCount(),
168 RenderTargets::instance()->getTreesDrawn(),
169 RenderTargets::instance()->getTargetsDrawn(),
170 Sound::instance()->getPlayingChannels(),
171 Landscape::instance()->getShadowMap().getShadowCount(),
172 FrameTimer::instance()->getLastStateCount(),
173 FrameTimer::instance()->getLastTextureSets()));
175 return (LangStringStorage *) result.c_str();