Stats_gump.cc

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2000-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 "Stats_gump.h"
00028 #include "Gump_manager.h"
00029 
00030 
00031 /*
00032  *  Some gump shape numbers:
00033  */
00034 
00035 const int ASLEEP = 0, POISONED = 1, CHARMED = 2, HUNGRY = 3,
00036       PROTECTED = 4, CURSED = 5, PARALYZED = 6;
00037 
00038 /*
00039  *  Statics:
00040  */
00041 
00042 short Stats_gump::textx = 123;
00043 short Stats_gump::texty[10] = {17, 26, 35, 46, 55, 67, 76, 86,
00044               95, 104};
00045 
00046 /*
00047  *  Show one of the atts.
00048  *
00049  *  Output: Amount to increment x-pos for the next one.
00050  */
00051 
00052 static int Show_atts
00053   (
00054   int x, int y,     // Pos. on screen.
00055   int framenum
00056   )
00057 {
00058   Shape_manager *sman = Shape_manager::get_instance();
00059   ShapeID sid(game->get_shape("gumps/statatts"), framenum, SF_GUMPS_VGA);
00060   Shape_frame *s = sid.get_shape();
00061   sman->paint_shape(x + s->get_xleft(),
00062          y + s->get_ybelow(), s, 1);
00063   return s->get_width() + 2;
00064 }
00065 
00066 /*
00067  *  Create stats display.
00068  */
00069 Stats_gump::Stats_gump
00070   (
00071   Container_game_object *cont, 
00072   int initx, int inity
00073   ) : Gump(cont, initx, inity, game->get_shape("gumps/statsdisplay"))
00074 {
00075   set_object_area(Rectangle(0,0,0,0), 6, 136);
00076 }
00077 
00078 /*
00079  *  Paint on screen.
00080  */
00081 
00082 void Stats_gump::paint
00083   (
00084   )
00085 {
00086   Gump_manager* gman = gumpman;
00087 
00088           // Area to print name in.
00089   const int namex = 30, namey = 6, namew = 95;
00090   Actor *act = get_actor(); // Check for freezing (SI).
00091   if (gwin->get_main_actor()->get_flag(Obj_flags::freeze))
00092     {
00093     int temp = act->get_temperature();
00094     int framenum = temp/10; // Want it 1-5.
00095     if (framenum <= 0)
00096       framenum = 1;
00097     else if (framenum > 5)
00098       framenum = 5;
00099     set_frame(framenum);
00100     }
00101           // Paint the gump itself.
00102   paint_shape(x, y);
00103           // Paint red "checkmark".
00104   check_button->paint();
00105           // Show statistics.
00106   std::string nm = act->get_name();
00107   sman->paint_text(2, nm.c_str(), x + namex +
00108     (namew - sman->get_text_width(2, nm.c_str()))/2, y + namey);
00109   gman->paint_num(act->get_effective_prop(Actor::strength),
00110             x + textx, y + texty[0]);
00111   gman->paint_num(act->get_effective_prop(Actor::dexterity),
00112             x + textx, y + texty[1]);
00113   gman->paint_num(act->get_effective_prop(Actor::intelligence),
00114             x + textx, y + texty[2]);
00115     gman->paint_num(act->get_effective_prop(Actor::combat),
00116             x + textx, y + texty[3]);
00117     gman->paint_num(act->get_property(Actor::magic),
00118             x + textx, y + texty[4]);
00119     gman->paint_num(act->get_property(Actor::health),
00120             x + textx, y + texty[5]);
00121     gman->paint_num(act->get_property(Actor::mana),
00122             x + textx, y + texty[6]);
00123     gman->paint_num(act->get_property(Actor::exp),
00124             x + textx, y + texty[7]);
00125   gman->paint_num(act->get_level(), x + textx, y + texty[8]);
00126     gman->paint_num(act->get_property(Actor::training),
00127             x + textx, y + texty[9]);
00128           // Now show atts. at bottom.
00129   const int attsy = 130, attsx0 = 29;
00130   int attsx = attsx0;
00131   if (act->get_flag(Obj_flags::asleep))
00132     attsx += Show_atts(x + attsx, y + attsy, ASLEEP);
00133   if (act->get_flag(Obj_flags::poisoned))
00134     attsx += Show_atts(x + attsx, y + attsy, POISONED);
00135   if (act->get_flag(Obj_flags::charmed))
00136     attsx += Show_atts(x + attsx, y + attsy, CHARMED);
00137   if (act->get_property((int) Actor::food_level) <= 4)
00138     attsx += Show_atts(x + attsx, y + attsy, HUNGRY);
00139   if (act->get_flag(Obj_flags::protection))
00140     attsx += Show_atts(x + attsx, y + attsy, PROTECTED);
00141   if (act->get_flag(Obj_flags::cursed))
00142     attsx += Show_atts(x + attsx, y + attsy, CURSED);
00143   if (act->get_flag(Obj_flags::paralyzed))
00144     attsx += Show_atts(x + attsx, y + attsy, PARALYZED);
00145 }

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