00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "pent_include.h"
00020 #include "GameWidget.h"
00021
00022 #include "GUIApp.h"
00023 #include "GameInfo.h"
00024 #include "RenderSurface.h"
00025 #include "TextWidget.h"
00026 #include "ButtonWidget.h"
00027 #include "PentagramMenuGump.h"
00028
00029 DEFINE_RUNTIME_CLASSTYPE_CODE(GameWidget,Gump);
00030
00031
00032 GameWidget::GameWidget(int X, int Y, Pentagram::istring& game)
00033 : Gump(X, Y, 443, 109), highlight(false)
00034 {
00035 info = GUIApp::get_instance()->getGameInfo(game);
00036 assert(info);
00037 }
00038
00039 GameWidget::~GameWidget()
00040 {
00041
00042 }
00043
00044 Pentagram::istring GameWidget::getGameName()
00045 {
00046 return info->name;
00047 }
00048 void GameWidget::InitGump(Gump* newparent, bool take_focus)
00049 {
00050 Gump::InitGump(newparent, take_focus);
00051
00052
00053 Gump* w = new TextWidget(65, 2, info->getGameTitle(),
00054 false, 0, 350, 180);
00055 w->InitGump(this, false);
00056
00057
00058 std::string gamename = "Game:";
00059 gamename += " ";
00060 gamename += info->name;
00061 w = new TextWidget(65, 29, gamename, false, 0, 350, 180);
00062 w->InitGump(this, false);
00063
00064 std::string path = "Path:";
00065 path += " ";
00066 w = new TextWidget(65, 50, path, false, 0, 350, 180);
00067 w->InitGump(this, false);
00068
00069 std::string version = info->getPrintableVersion();
00070 w = new TextWidget(360, 70, version, false, 2, 70, 0, Font::TEXT_RIGHT);
00071 w->InitGump(this, false);
00072
00073 w = new ButtonWidget(13, 86, "Play Game", false, 1, 0x80D000D0);
00074 w->SetIndex(static_cast<sint32>(GAME_PLAY));
00075 w->InitGump(this, false);
00076
00077 w = new ButtonWidget(122, 86, "Load Savegame", false, 1, 0x80D000D0);
00078 w->SetIndex(static_cast<sint32>(GAME_LOAD));
00079 w->InitGump(this, false);
00080
00081 w = new ButtonWidget(270, 86, "Settings", false, 1, 0x80D000D0);
00082 w->SetIndex(static_cast<sint32>(GAME_SETTINGS));
00083 w->InitGump(this, false);
00084
00085 w = new ButtonWidget(361, 86, "Remove", false, 1, 0x80D000D0);
00086 w->SetIndex(static_cast<sint32>(GAME_REMOVE));
00087 w->InitGump(this, false);
00088 }
00089
00090 void GameWidget::ChildNotify(Gump *child, uint32 message)
00091 {
00092 if (child->IsOfType<ButtonWidget>() &&
00093 message == ButtonWidget::BUTTON_CLICK)
00094 {
00095 sint32 index = child->GetIndex();
00096
00097 if (parent)
00098 parent->ChildNotify(this, static_cast<uint32>(index));
00099 }
00100 }
00101
00102 uint16 GameWidget::TraceObjId(int mx, int my)
00103 {
00104 uint16 objid = Gump::TraceObjId(mx, my);
00105 if (!objid) objid = getObjId();
00106 return objid;
00107 }
00108
00109 Gump* GameWidget::OnMouseDown(int button, int mx, int my)
00110 {
00111 Gump *g = Gump::OnMouseDown(button, mx, my);
00112 if (!g) g = this;
00113 return g;
00114 }
00115
00116 void GameWidget::OnMouseOver()
00117 {
00118 highlight = true;
00119 }
00120
00121 void GameWidget::OnMouseLeft()
00122 {
00123 highlight = false;
00124 }
00125
00126
00127 void GameWidget::PaintThis(RenderSurface* surf, sint32 lerp_factor, bool )
00128 {
00129 PentagramMenuGump* p = p_dynamic_cast<PentagramMenuGump*>(GetParent());
00130 Texture* coversImage = p->getCovers();
00131 Texture* flagsImage = p->getFlags();
00132
00133
00134
00135
00136 surf->Fill32(0xFFFFFFFF,0,0,443,1);
00137 surf->Fill32(0xFFFFFFFF,0,0,1,109);
00138 surf->Fill32(0xFFFFFFFF,0,108,443,1);
00139 surf->Fill32(0xFFFFFFFF,442,0,1,109);
00140
00141
00142 surf->Fill32(0xFFFFFFFF,0,81,443,1);
00143
00144
00145 surf->Fill32(0xFFFFFFFF,57,0,1,81);
00146
00147
00148 surf->Fill32(0xFFFFFFFF,57,23,443-57,1);
00149
00150
00151
00152 surf->Blit(coversImage, (info->type-1)*56,0, 56,80, 1,1);
00153
00154 if (highlight)
00155 surf->Fill32(0xFF30308F,58,1,443-57-2,22);
00156
00157
00158
00159 surf->Blit(flagsImage, (info->language-1)*24,0, 24,16, 415,4);
00160
00161
00162 #if 0
00163 Pentagram::Font* font = FontManager::get_instance()->getTTFont(1);
00164 assert(font);
00165
00166
00167
00168 surf->Fill32(0xFFE0E0E0,13,85,87,1);
00169 surf->Fill32(0xFFC0C0C0,13,86,1,18);
00170 surf->Fill32(0xFF808080,99,86,1,18);
00171 surf->Fill32(0xFF404040,13,104,87,1);
00172
00173 unsigned int rem;
00174 std::string button = "Play Game";
00175 RenderedText* t = font->renderText(button, rem, 0, 0);
00176 t->draw(surf, 19, 99);
00177 delete t;
00178
00179 surf->Fill32(0xFFE0E0E0,122,85,126,1);
00180 surf->Fill32(0xFFC0C0C0,122,86,1,18);
00181 surf->Fill32(0xFF808080,247,86,1,18);
00182 surf->Fill32(0xFF404040,122,104,126,1);
00183
00184 button = "Load Savegame";
00185 t = font->renderText(button, rem, 0, 0);
00186 t->draw(surf, 128, 99);
00187 delete t;
00188
00189 surf->Fill32(0xFFE0E0E0,270,85,69,1);
00190 surf->Fill32(0xFFC0C0C0,270,86,1,18);
00191 surf->Fill32(0xFF808080,338,86,1,18);
00192 surf->Fill32(0xFF404040,270,104,69,1);
00193
00194 button = "Settings";
00195 t = font->renderText(button, rem, 0, 0);
00196 t->draw(surf, 276, 99);
00197 delete t;
00198
00199 surf->Fill32(0xFFE0E0E0,361,85,67,1);
00200 surf->Fill32(0xFFC0C0C0,361,86,1,18);
00201 surf->Fill32(0xFF808080,427,86,1,18);
00202 surf->Fill32(0xFF404040,361,104,67,1);
00203
00204 button = "Remove";
00205 t = font->renderText(button, rem, 0, 0);
00206 t->draw(surf, 367, 99);
00207 delete t;
00208 #endif
00209 }