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 "MiniStatsGump.h"
00021
00022 #include "GameData.h"
00023 #include "GumpShapeArchive.h"
00024 #include "Shape.h"
00025 #include "ShapeFrame.h"
00026 #include "MainActor.h"
00027 #include "RenderSurface.h"
00028 #include "Mouse.h"
00029 #include "PaperdollGump.h"
00030 #include "getObject.h"
00031
00032 #include "IDataSource.h"
00033 #include "ODataSource.h"
00034
00035 DEFINE_RUNTIME_CLASSTYPE_CODE(MiniStatsGump,Gump);
00036
00037 static const int gumpshape = 33;
00038 static const int hpx = 6;
00039 static const int manax = 13;
00040 static const int bary = 19;
00041 static const int barheight = 14;
00042
00043 static const uint32 hpcolour[] = { 0x980404, 0xBC0C0C, 0xD43030 };
00044 static const uint32 manacolour[] = { 0x4050FC, 0x1C28FC, 0x0C0CCC };
00045
00046
00047 MiniStatsGump::MiniStatsGump() : Gump()
00048 {
00049
00050 }
00051
00052 MiniStatsGump::MiniStatsGump(int x, int y, uint32 _Flags, sint32 layer)
00053 : Gump(x, y, 5, 5, 0, _Flags, layer)
00054 {
00055
00056 }
00057
00058 MiniStatsGump::~MiniStatsGump()
00059 {
00060
00061 }
00062
00063 void MiniStatsGump::InitGump(Gump* newparent, bool take_focus)
00064 {
00065 Gump::InitGump(newparent, take_focus);
00066
00067 shape = GameData::get_instance()->getGumps()->getShape(gumpshape);
00068 ShapeFrame* sf = shape->getFrame(0);
00069 assert(sf);
00070
00071 dims.w = sf->width;
00072 dims.h = sf->height;
00073 }
00074
00075 void MiniStatsGump::PaintThis(RenderSurface* surf, sint32 lerp_factor, bool scaled)
00076 {
00077 Gump::PaintThis(surf, lerp_factor, scaled);
00078
00079 Actor *a = getMainActor();
00080 assert(a);
00081
00082 sint16 maxmana = a->getMaxMana();
00083 sint16 mana = a->getMana();
00084
00085 uint16 maxhp = a->getMaxHP();
00086 uint16 hp = a->getHP();
00087
00088 int manaheight, hpheight;
00089
00090
00091 if (maxmana == 0)
00092 manaheight = 0;
00093 else
00094 manaheight = (mana * barheight) / maxmana;
00095
00096 if (maxhp == 0)
00097 hpheight = 0;
00098 else
00099 hpheight = (hp * barheight) / maxhp;
00100
00101 for (int i = 0; i < 3; ++i) {
00102 surf->Fill32(hpcolour[i], hpx+i, bary-hpheight+1, 1, hpheight);
00103 surf->Fill32(manacolour[i], manax+i, bary-manaheight+1, 1, manaheight);
00104 }
00105 }
00106
00107 uint16 MiniStatsGump::TraceObjId(int mx, int my)
00108 {
00109 uint16 objid = Gump::TraceObjId(mx, my);
00110 if (objid && objid != 65535) return objid;
00111
00112 if (PointOnGump(mx, my)) return getObjId();
00113
00114 return 0;
00115 }
00116
00117 Gump* MiniStatsGump::OnMouseDown(int button, int mx, int my)
00118 {
00119 if (button == BUTTON_LEFT)
00120 return this;
00121
00122 return 0;
00123 }
00124
00125 void MiniStatsGump::OnMouseDouble(int button, int mx, int my)
00126 {
00127
00128 MainActor* av = getMainActor();
00129 if (!av->getGump()) {
00130 av->callUsecodeEvent_use();
00131 }
00132
00133 Close();
00134 }
00135
00136 void MiniStatsGump::saveData(ODataSource* ods)
00137 {
00138 Gump::saveData(ods);
00139 }
00140
00141 bool MiniStatsGump::loadData(IDataSource* ids, uint32 version)
00142 {
00143 if (!Gump::loadData(ids, version)) return false;
00144
00145 return true;
00146 }