HelpButtonDialog.cpp

Go to the documentation of this file.
00001 ////////////////////////////////////////////////////////////////////////////////
00002 //    Scorched3D (c) 2000-2009
00003 //
00004 //    This file is part of Scorched3D.
00005 //
00006 //    Scorched3D is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    Scorched3D is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with Scorched3D; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 ////////////////////////////////////////////////////////////////////////////////
00020 
00021 #include <stdio.h>
00022 #include <graph/FrameTimer.h>
00023 #include <graph/OptionsDisplay.h>
00024 #include <graph/MainCamera.h>
00025 #include <graph/ParticleEngine.h>
00026 #include <dialogs/MainMenuDialog.h>
00027 #include <dialogs/HelpButtonDialog.h>
00028 #include <dialogs/SoundDialog.h>
00029 #include <common/Defines.h>
00030 #include <sound/Sound.h>
00031 #include <GLEXT/GLInfo.h>
00032 #include <GLEXT/GLState.h>
00033 #include <GLEXT/GLMenu.h>
00034 #include <client/ScorchedClient.h>
00035 #include <client/ClientChannelManager.h>
00036 #include <tankgraph/RenderTargets.h>
00037 #include <engine/ActionController.h>
00038 #include <image/ImageFactory.h>
00039 #include <landscape/Landscape.h>
00040 #include <landscape/ShadowMap.h>
00041 #include <land/VisibilityPatchGrid.h>
00042 #include <GLW/GLWWindowManager.h>
00043 
00044 HelpButtonDialog *HelpButtonDialog::instance_ = 0;
00045 
00046 HelpButtonDialog *HelpButtonDialog::instance()
00047 {
00048         if (!instance_)
00049         {
00050                 instance_ = new HelpButtonDialog();
00051         }
00052         return instance_;
00053 }
00054 
00055 HelpButtonDialog::HelpButtonDialog() : 
00056         performanceMenu_(), volumeMenu_(), helpMenu_()
00057 {
00058 }
00059 
00060 HelpButtonDialog::~HelpButtonDialog()
00061 {
00062 }
00063 
00064 HelpButtonDialog::HelpMenu::HelpMenu()
00065 {
00066         Image *map = 
00067                 ImageFactory::loadImage(
00068                         S3D::getDataFile("data/windows/help.bmp"),
00069                         S3D::getDataFile("data/windows/helpa.bmp"),
00070                         false);
00071         DIALOG_ASSERT(map->getBits());
00072         MainMenuDialog::instance()->
00073                 addMenu(LANG_RESOURCE("HELP", "Help"), 
00074                         "Help", 
00075                         LANG_RESOURCE("HELP_MENU", "Launch an external web browser containing the\n"
00076                         "Scorched3D online help."),
00077                         32.0f, 0, this, map,
00078                         GLMenu::eMenuAlignRight);
00079 }
00080 
00081 bool HelpButtonDialog::HelpMenu::getMenuItems(const char* menuName, std::list<GLMenuItem> &result)
00082 {
00083         result.push_back(GLMenuItem(LANG_RESOURCE("SHOW_ONLINE_HELP", "Show Online Help")));
00084         return true;
00085 }
00086 
00087 void HelpButtonDialog::HelpMenu::menuSelection(const char* menuName, 
00088         const int position, GLMenuItem &item)
00089 {
00090         S3D::showURL("http://www.scorched3d.co.uk/wiki");
00091 }
00092 
00093 HelpButtonDialog::VolumeMenu::VolumeMenu()
00094 {
00095         Image *map = ImageFactory::loadImage(
00096                 S3D::getDataFile("data/windows/sound.bmp"),
00097                 S3D::getDataFile("data/windows/sounda.bmp"),
00098                 false);
00099         DIALOG_ASSERT(map->getBits());
00100         MainMenuDialog::instance()->
00101                 addMenu(LANG_RESOURCE("VOLUME", "Volume"), 
00102                         "Volume",
00103                         LANG_RESOURCE("VOLUME_MENU", "Change the sound and volume settings"),
00104                         32.0f, 0, this, map,
00105                         GLMenu::eMenuAlignRight);
00106 }
00107 
00108 bool HelpButtonDialog::VolumeMenu::menuOpened(const char* menuName)
00109 {
00110         GLWWindowManager::instance()->showWindow(
00111                 SoundDialog::instance()->getId());
00112         return false;
00113 }
00114 
00115 HelpButtonDialog::PerformanceMenu::PerformanceMenu()
00116 {
00117         Image *map = 
00118                 ImageFactory::loadImage(
00119                         S3D::getDataFile("data/windows/perf.bmp"),
00120                         S3D::getDataFile("data/windows/perfa.bmp"),
00121                         false);
00122         DIALOG_ASSERT(map->getBits());
00123         MainMenuDialog::instance()->
00124                 addMenu(LANG_RESOURCE("PERFORMANCE", "Perofmance"),
00125                         "Performance", 
00126                         LANG_STRING(""),
00127                         32.0f, 0, this, map,
00128                         GLMenu::eMenuAlignRight);
00129 }
00130 
00131 bool HelpButtonDialog::PerformanceMenu::getMenuItems(const char* menuName, std::list<GLMenuItem> &result)
00132 {
00133         return true;
00134 }
00135 
00136 void HelpButtonDialog::PerformanceMenu::menuSelection(const char* menuName, 
00137         const int position, GLMenuItem &item)
00138 {
00139 }
00140 
00141 LangStringStorage *HelpButtonDialog::PerformanceMenu::getMenuToolTip(const char* menuName)
00142 {
00143         static LangString result;
00144 
00145         unsigned int pOnScreen = 
00146                 ScorchedClient::instance()->
00147                         getParticleEngine().getParticlesOnScreen() +
00148                 MainCamera::instance()->getTarget().
00149                         getPrecipitationEngine().getParticlesOnScreen();
00150 
00151         result = LANG_STRING(S3D::formatStringBuffer(
00152                 "%.2f Frames Per Second\n"
00153                 "  %i Triangles Drawn\n"
00154                 "  %i Particles Drawn\n"
00155                 "  %i Land and %i Water Patches Visible\n"
00156                 "  %i Trees Drawn\n"
00157                 "  %i Targets Drawn\n"
00158                 "  %i Playing Sound Channels\n"
00159                 "  %u Shadows Drawn\n"
00160                 "  %u OpenGL State Changes\n"
00161                 "  %u OpenGL Texture Changes\n", 
00162 
00163                 FrameTimer::instance()->getFPS(),
00164                 FrameTimer::instance()->getLastTris(),
00165                 pOnScreen,
00166                 VisibilityPatchGrid::instance()->getVisibleLandPatchesCount(),
00167                 VisibilityPatchGrid::instance()->getVisibleWaterPatchesCount(),
00168                 RenderTargets::instance()->getTreesDrawn(),
00169                 RenderTargets::instance()->getTargetsDrawn(),
00170                 Sound::instance()->getPlayingChannels(),
00171                 Landscape::instance()->getShadowMap().getShadowCount(), 
00172                 FrameTimer::instance()->getLastStateCount(),
00173                 FrameTimer::instance()->getLastTextureSets()));
00174 
00175         return (LangStringStorage *) result.c_str();
00176 }

Generated on Mon Feb 16 15:14:37 2009 for Scorched3D by  doxygen 1.5.3