OptionsGump.cpp

Go to the documentation of this file.
00001 /*
00002  *  Copyright (C) 2004-2005  The Pentagram Team
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  */
00018 
00019 #include "pent_include.h"
00020 #include "OptionsGump.h"
00021 
00022 #include "RenderSurface.h"
00023 #include "DesktopGump.h"
00024 #include "ButtonWidget.h"
00025 #include "TextWidget.h"
00026 #include "ControlsGump.h"
00027 #include "PagedGump.h"
00028 
00029 #include "IDataSource.h"
00030 #include "ODataSource.h"
00031 
00032 #include <SDL.h>
00033 
00034 static const int font = 0;
00035 
00036 DEFINE_RUNTIME_CLASSTYPE_CODE(OptionsGump,Gump);
00037 
00038 OptionsGump::OptionsGump(): Gump(0, 0, 5, 5)
00039 {
00040 }
00041 
00042 OptionsGump::~OptionsGump()
00043 {
00044 }
00045 
00046 void OptionsGump::InitGump(Gump* newparent, bool take_focus)
00047 {
00048         Gump::InitGump(newparent, take_focus);
00049 
00050         dims.w = 220;
00051         dims.h = 120;
00052 
00053         int x = dims.w / 2 + 14;
00054         int y = 4;
00055         Gump * widget;
00056 
00057 #if 0
00058         widget = new ButtonWidget(x, y, "1. Video", true, font, 0x804000B0);
00059         widget->InitGump(this);
00060         widget->SetIndex(1);
00061 #endif
00062         y+= 14;
00063 
00064 #if 0
00065         widget = new ButtonWidget(x, y, "2. Audio", true, font, 0x804000B0);
00066         widget->InitGump(this);
00067         widget->SetIndex(2);
00068 #endif
00069         y+= 14;
00070 
00071         widget = new ButtonWidget(x, y, "3. Controls", true, font, 0x804000B0);
00072         widget->InitGump(this);
00073         widget->SetIndex(3);
00074         y+= 14;
00075 
00076 #if 0
00077         widget = new ButtonWidget(x, y, "4. Gameplay", true, font, 0x804000B0);
00078         widget->InitGump(this);
00079         widget->SetIndex(4);
00080 #endif
00081         y+= 14;
00082 }
00083 
00084 void OptionsGump::ChildNotify(Gump *child, uint32 message)
00085 {
00086         if (message == ButtonWidget::BUTTON_CLICK)
00087         {
00088                 selectEntry(child->GetIndex());
00089         }
00090 }
00091 
00092 void OptionsGump::PaintThis(RenderSurface* surf, sint32 lerp_factor, bool scaled)
00093 {
00094         Gump::PaintThis(surf, lerp_factor, scaled);
00095 }
00096 
00097 static const int gumpShape = 35;
00098 
00099 bool OptionsGump::OnKeyDown(int key, int mod)
00100 {
00101         if (key == SDLK_ESCAPE)
00102         {
00103                 parent->Close();
00104         }
00105         else if (key >= SDLK_1 && key <=SDLK_9)
00106         {
00107                 // Minor hack.
00108                 selectEntry(key - SDLK_1 + 1);
00109                 return true;
00110         }
00111         return true;
00112 }
00113 
00114 void OptionsGump::selectEntry(int entry)
00115 {
00116         switch (entry)
00117         {
00118         case 1:
00119         {       // Video
00120         } break;
00121         case 2:
00122         {       // Audio
00123         } break;
00124         case 3:
00125         {       // Controls
00126                 PagedGump * gump = new PagedGump(34, -38, 3, gumpShape);
00127                 gump->InitGump(this);
00128 
00129                 ControlsGump::showEngineMenu(gump);
00130                 ControlsGump::showU8Menu(gump);
00131 
00132                 // The parent to this gump is actually  a PagedGump,
00133                 // and this gump does not cover the entire parent.
00134                 gump->setRelativePosition(CENTER);
00135         } break;        
00136         case 4:
00137         {       // Gameplay
00138         } break;
00139         case 5:
00140         {
00141         } break;
00142         case 6:
00143         {
00144         } break;
00145         default:
00146                 break;
00147         }
00148 }
00149 
00150 bool OptionsGump::loadData(IDataSource* ids)
00151 {
00152         return true;
00153 }
00154 
00155 void OptionsGump::saveData(ODataSource* ods)
00156 {
00157 }
00158 

Generated on Fri Jul 27 22:27:28 2007 for pentagram by  doxygen 1.4.7