1 //  Copyright (C) 2007, 2008, Ole Laursen
2 //  Copyright (C) 2007, 2008, 2009, 2014, 2015 Ben Asselstine
3 //
4 //  This program is free software; you can redistribute it and/or modify
5 //  it under the terms of the GNU General Public License as published by
6 //  the Free Software Foundation; either version 3 of the License, or
7 //  (at your option) any later version.
8 //
9 //  This program is distributed in the hope that it will be useful,
10 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 //  GNU Library General Public License for more details.
13 //
14 //  You should have received a copy of the GNU General Public License
15 //  along with this program; if not, write to the Free Software
16 //  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 //  02110-1301, USA.
18 
19 #pragma once
20 #ifndef FIGHT_WINDOW_H
21 #define FIGHT_WINDOW_H
22 
23 #include <memory>
24 #include <vector>
25 #include <list>
26 #include <sigc++/trackable.h>
27 #include <glibmm/main.h>
28 #include <gtkmm.h>
29 
30 #include "game-parameters.h"
31 #include "fight.h"
32 
33 class Fight;
34 class Army;
35 
36 // window for displaying the course of a fight
37 class FightWindow: public sigc::trackable
38 {
39  public:
40 
41     static bool s_quick_all;
42 
43     FightWindow(Gtk::Window &parent, Fight &fight);
44     ~FightWindow();
45 
hide()46     void hide() {window->hide();};
47     void run(bool *quick);
48 
49  private:
50     Gtk::Window* window;
51     static const int max_cols = 8;
52 
53     struct ArmyItem
54     {
55 	Army *army;
56 	int hp;
57         Gtk::Image *water_image;
58 	Gtk::Image *image;
59         bool exploding;
60     };
61 
62     typedef std::vector<ArmyItem> army_items_type;
63     army_items_type army_items;
64 
65     typedef std::list<FightItem> actions_type;
66     actions_type actions;
67 
68     typedef std::vector<Army *> armies_type; // for convenience
69 
70     Glib::RefPtr<Glib::MainLoop> main_loop;
71 
72     int round;
73     actions_type::iterator action_iterator;
74 
75     // add an army to the window
76     void add_army(Army *army, int initial_hp,
77                   std::vector<Gtk::Box *> &hboxes,
78 		  Gtk::Box *vbox, int current_no);
79 
80     void on_key_release_event(GdkEventKey *ev);
81 
82     bool do_round();
83     bool d_quick;
84     int normal_round_speed;
85     int fast_round_speed;
86 };
87 
88 #endif
89