00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 #ifndef GAME_WINDOW_H
00014 #define GAME_WINDOW_H
00015 
00016 #include <gtkmm.h>
00017 #include <libglademm.h>
00018 #include <gtkmm/drawingarea.h>
00019 #include "../general/channel.h"
00020 
00021 #define slen_x 7
00022 #define slen_y 5
00023 
00024 class game_window;
00025 
00026 class draw_area : public Gtk::DrawingArea {
00027   public:
00028     draw_area(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& refGlade) :
00029       Gtk::DrawingArea(cobject), m_refGlade(refGlade) {}
00030     virtual ~draw_area() {};
00031     game_window *curr;
00032 
00033   protected:
00034     Glib::RefPtr<Gdk::Pixmap> background;
00035     void bg_image(string name, int x, int y);
00036     void calc_background();
00037     void move_background(int dir);
00038     void image(string name, int x, int y);
00039     virtual bool on_expose_event(GdkEventExpose* event);
00040     Glib::RefPtr<Gnome::Glade::Xml> m_refGlade;
00041 };
00042 
00043 class tile {
00044   public:
00045     tile() {
00046         terrain=0;
00047         fields=0;
00048         name="";
00049         citysize=0;
00050         wallsize=0;
00051         wall=0;
00052         moat=0;
00053     }
00054     unsigned int terrain : 4;
00055     unsigned char add[8];
00056     unsigned int fields: 8;
00057     std::string name;
00058     unsigned int citysize: 8;
00059     unsigned int castlesize: 8;
00060     unsigned int wallsize: 8;
00061     unsigned int wall: 2;
00062     unsigned int moat: 2;
00063 };
00064 
00065 class game_window : public Gtk::Window {
00066   public:
00067     game_window(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml> refGlade); 
00068     virtual ~game_window(); 
00069   private:
00070     tile map[slen_x*6+1][slen_y*6+1];
00071     int cx; 
00072     int cy; 
00073     int sx; 
00074     int sy; 
00075     void set_map(int x,int y,tile t);
00076     tile get_map(int x,int y);
00077   protected:
00078     Glib::RefPtr<Gnome::Glade::Xml> m_refGlade;
00079     draw_area* area;
00080     Gtk::TreeView* game_tree;
00081     void file_handler(std::string f);
00082     void game_handler(channel *ch);
00083     channel *ch;
00084 
00086     struct ModelColumns : public Gtk::TreeModelColumnRecord {
00087         Gtk::TreeModelColumn<Glib::ustring> name;
00088         Gtk::TreeModelColumn<Glib::ustring> descr;
00089         Gtk::TreeModelColumn<int> item_nr;
00090         ModelColumns()
00091         {
00092             add(name); add(descr);
00093             add(item_nr);
00094         }
00095     };
00096     const ModelColumns cols;
00097 };
00098 
00099 #endif //GAME_WINDOW_H
00100