CombatStats_gump.cc

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2001-2002 The Exult Team
00003 
00004 This program is free software; you can redistribute it and/or
00005 modify it under the terms of the GNU General Public License
00006 as published by the Free Software Foundation; either version 2
00007 of the License, or (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 #ifdef HAVE_CONFIG_H
00020 #  include <config.h>
00021 #endif
00022 
00023 #include "actors.h"
00024 #include "game.h"
00025 #include "gamewin.h"
00026 #include "misc_buttons.h"
00027 #include "CombatStats_gump.h"
00028 #include "Paperdoll_gump.h"
00029 #include "Gump_manager.h"
00030 
00031 
00032 /*
00033  *  Statics:
00034  */
00035 
00036 static const int colx = 110;
00037 static const int coldx = 29;
00038 static const int rowy[7] = {15, 29, 42, 73, 87, 93, 106};
00039 
00040 /*
00041  *  Create stats display.
00042  */
00043 CombatStats_gump::CombatStats_gump(int initx, int inity) : 
00044   Gump(0, initx, inity, game->get_shape("gumps/cstats/1"))
00045 {
00046   set_object_area(Rectangle(0,0,0,0), 7, 95);
00047 
00048 
00049   party_size = gwin->get_party(party, 1);
00050 
00051   Gump::shapenum = game->get_shape("gumps/cstats/1") + party_size - 1;
00052   ShapeID::set_shape(Gump::shapenum, 0);
00053 
00054   int i;  // Blame MSVC
00055   for (i = 0; i < party_size; i++) {
00056     halo_btn[i] = new Halo_button(this, colx + i*coldx, rowy[4], party[i]);
00057     cmb_btn[i] = new Combat_mode_button(this, colx + i*coldx + 1, rowy[3],
00058                       party[i]);
00059     face_btn[i] = new Face_button(this, colx + i*coldx - 13, rowy[0],
00060                     party[i]);
00061   }
00062   for (i = party_size; i < 9; i++) {
00063     halo_btn[i] = 0;
00064     cmb_btn[i] = 0;
00065     face_btn[i] = 0;
00066   }
00067 }
00068 
00069 CombatStats_gump::~CombatStats_gump()
00070 {
00071   for (int i = 0; i < 9; i++) {
00072     delete halo_btn[i];
00073     delete cmb_btn[i];
00074     delete face_btn[i];
00075   }
00076 }
00077 
00078 /*
00079  *  Paint on screen.
00080  */
00081 
00082 void CombatStats_gump::paint()
00083 {
00084   Gump_manager* gman = gumpman;
00085 
00086   Gump::paint();
00087 
00088   // stats for all party members
00089   for (int i = 0; i < party_size; i++) {
00090     face_btn[i]->paint();
00091 
00092     gman->paint_num(party[i]->get_effective_prop(Actor::combat),
00093           x + colx + i*coldx, y + rowy[1]);   
00094     gman->paint_num(party[i]->get_property(Actor::health),
00095           x + colx + i*coldx, y + rowy[2]);
00096 
00097     halo_btn[i]->paint();
00098     cmb_btn[i]->paint();
00099   }
00100 
00101   // magic stats only for Avatar
00102     gman->paint_num(party[0]->get_property(Actor::magic),
00103             x + colx, y + rowy[5]);
00104     gman->paint_num(party[0]->get_property(Actor::mana),
00105             x + colx, y + rowy[6]); 
00106 }
00107 
00108 Gump_button* CombatStats_gump::on_button(int mx, int my)
00109 {
00110   Gump_button *btn = Gump::on_button(mx, my);
00111   if (btn)
00112     return btn;
00113   for (int i = 0; i < party_size; i++) {
00114     if (halo_btn[i]->on_button(mx, my))
00115       return halo_btn[i];
00116     if (cmb_btn[i]->on_button(mx, my))
00117       return cmb_btn[i];
00118     if (face_btn[i]->on_button(mx, my))
00119       return face_btn[i];
00120   }
00121   return 0;
00122 }

Generated on Mon Jul 9 14:42:46 2007 for ExultEngine by  doxygen 1.5.1