misc_buttons.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 "Gamemenu_gump.h"
00025 #include "game.h"
00026 #include "gamewin.h"
00027 #include "misc_buttons.h"
00028 #include "Modal_gump.h"
00029 #include "mouse.h"
00030 #include "party.h"
00031 #include "Gump_manager.h"
00032 
00033 /*
00034  *  A checkmark for closing its parent:
00035  */
00036 Checkmark_button::Checkmark_button(Gump *par, int px, int py)
00037   : Gump_button(par, game->get_shape("gumps/check"), px, py)
00038 {
00039 }
00040 
00041 /*
00042  *  Handle click on a 'checkmark'.
00043  */
00044 
00045 void Checkmark_button::activate
00046   (
00047   )
00048 {
00049   parent->close();
00050 }
00051 
00052 /*
00053  *  A 'heart' button for bringing up stats.
00054  */
00055 
00056 Heart_button::Heart_button(Gump *par, int px, int py)
00057   : Gump_button(par, game->get_shape("gumps/heart"), px, py)
00058 {
00059 }
00060 
00061 /*
00062  *  Handle click on a heart.
00063  */
00064 
00065 void Heart_button::activate
00066   (
00067   )
00068 {
00069   gumpman->add_gump(parent->get_container(), game->get_shape("gumps/statsdisplay"));
00070 }
00071 
00072 /*
00073  *  A diskette for bringing up the 'save' box.
00074  */
00075 
00076 Disk_button::Disk_button(Gump *par, int px, int py)
00077   : Gump_button(par, game->get_shape("gumps/disk"), px, py)
00078 {
00079 }
00080 
00081 /*
00082  *  Handle click on a diskette.
00083  */
00084 
00085 void Disk_button::activate
00086   (
00087   )
00088 {
00089   Gamemenu_gump *menu = new Gamemenu_gump();
00090   gumpman->do_modal_gump(menu, Mouse::hand);
00091   delete menu;
00092 }
00093 
00094 /*
00095  *  The combat toggle button.
00096  */
00097 
00098 Combat_button::Combat_button(Gump *par, int px, int py)
00099   : Gump_button(par, game->get_shape("gumps/combat"),
00100     px, py)
00101 {
00102   pushed = gwin->in_combat();
00103 }
00104 
00105 /*
00106  *  Handle click on a combat toggle button.
00107  */
00108 
00109 void Combat_button::activate
00110   (
00111   )
00112 {
00113   gwin->toggle_combat();
00114   pushed = gwin->in_combat();
00115   parent->paint();
00116 }
00117 
00118 /*
00119  *  Check combat mode before painting.
00120  */
00121 
00122 void Combat_button::paint
00123   (
00124   )
00125   {
00126   pushed = gwin->in_combat();
00127   Gump_button::paint();
00128   }
00129 
00130 /*
00131  *  The halo button.
00132  */
00133 
00134 Halo_button::Halo_button(Gump *par, int px, int py, Actor *a)
00135   : Gump_button(par, game->get_shape("gumps/halo"), px, py), actor(a)
00136 {
00137   pushed = actor->is_combat_protected();
00138 }
00139 
00140 /*
00141  *  Handle click on a halo toggle button.
00142  */
00143 
00144 void Halo_button::activate
00145   (
00146   )
00147 {
00148           // Want to toggle it.
00149   bool prot = !actor->is_combat_protected();
00150   pushed = prot;
00151   parent->paint();
00152   actor->set_combat_protected(prot);
00153   if (!prot)      // Toggled off?
00154     return;
00155           // On?  Got to turn off others.
00156   Actor *party[9];    // Get entire party, including Avatar.
00157   int cnt = gwin->get_party(party, 1);
00158   for (int i = 0; i < cnt; i++)
00159     {
00160     if (party[i] != actor && party[i]->is_combat_protected())
00161       party[i]->set_combat_protected(false);
00162           // +++++Should also update gumps.
00163     }
00164 }
00165 
00166 /*
00167  *  Combat mode.  Has 10 frames corresponding to Actor::Attack_mode.
00168  */
00169 
00170 Combat_mode_button::Combat_mode_button(Gump *par, int px, int py, Actor *a)
00171   : Gump_button(par, game->get_shape("gumps/combatmode"), px, py), 
00172     actor(a)
00173 {
00174   set_frame((int) actor->get_attack_mode());
00175 }
00176 
00177 /*
00178  *  Handle click on a combat toggle button.
00179  */
00180 
00181 void Combat_mode_button::activate
00182   (
00183   )
00184 {
00185           // Only Avatar gets last frame (manual)
00186   int nframes = actor == gwin->get_main_actor() ? 10 : 9;
00187   set_frame((get_framenum() + 1)%nframes);
00188           // Flag that player set the mode.
00189   actor->set_attack_mode((Actor::Attack_mode) get_framenum(), true);
00190   paint();
00191   gwin->set_painted();
00192 }
00193 
00194 
00195 /*
00196  *  The Serpent Isle Combat Stats Button.
00197  */
00198 
00199 Cstats_button::Cstats_button(Gump *par, int px, int py)
00200   : Gump_button(par, game->get_shape("gumps/combat_stats"), px, py)
00201 
00202 {
00203 }
00204 
00205 /*
00206  *  Handle click on a combat stats button
00207  */
00208 
00209 void Cstats_button::activate
00210   (
00211   )
00212 {
00213   int cnt = partyman->get_count();
00214   gumpman->add_gump(0, game->get_shape("gumps/cstats/1") + cnt);
00215 }

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