studio.h

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2000-2001 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 #ifndef STUDIO_H
00020 
00021 #include <gtk/gtk.h>
00022 #include <glade/glade.h>
00023 #include <vector>
00024 #include "vgafile.h"
00025 #include "servemsg.h"
00026 
00027 class Shape_info;
00028 class Shapes_vga_file;
00029 class Equip_row_widgets;
00030 class Shape_file_set;
00031 class Shape_file_info;
00032 class Shape_group_file;
00033 class Shape_draw;
00034 class Object_browser;
00035 class Shape_group;
00036 class Locator;
00037 class Combo_editor;
00038 class Exec_box;
00039           // Callback for msgs.
00040 typedef void (*Msg_callback)(Exult_server::Msg_type id, 
00041       unsigned char *data, int datalen, void *client);
00042 
00043 #ifndef WIN32
00044 #define C_EXPORT extern "C"
00045 #else
00046 #ifndef WIN32_LEAN_AND_MEAN
00047 #define WIN32_LEAN_AND_MEAN
00048 #endif
00049 #include <windows.h>
00050 #include "windrag.h"
00051 #define C_EXPORT extern "C" __declspec(dllexport)
00052 #endif
00053 
00054 class ExultStudio {
00055 private:
00056   char      *glade_path;  // Where our .glade file is.
00057   GtkWidget   *app;
00058   GladeXML    *app_xml;
00059   char      *static_path;
00060   char      *image_editor;
00061   char      *default_game;
00062   guint32     background_color;
00063   static ExultStudio  *self;
00064             // Modified one of the .dat's?
00065   bool      shape_info_modified, shape_names_modified;
00066   Shape_file_set    *files;   // All the shape files.
00067   std::vector<GtkWindow*> group_windows;  // All 'group' windows.
00068   Shape_file_info   *curfile; // Current browser file info.
00069   Shape_file_info   *vgafile; // Main 'shapes.vga'.
00070   Shape_file_info   *facefile;  // 'faces.vga'.
00071   std::vector<char *> names;
00072   Object_browser    *browser;
00073   unsigned char     *palbuf;  // 3*256 rgb's, each 0-63.
00074           // Egg editor:
00075   GtkWidget   *eggwin;// Egg window.
00076   Shape_draw    *egg_monster_draw;
00077   int     egg_ctx;
00078           // Npc editor:
00079   GtkWidget   *npcwin;
00080   Shape_draw    *npc_draw, *npc_face_draw;
00081   int     npc_ctx;
00082   guint     npc_status_id;
00083           // Object editor:
00084   GtkWidget   *objwin;
00085   Shape_draw    *obj_draw;
00086           // Shape info. editor:
00087   GtkWidget   *shapewin;
00088   Shape_draw    *shape_draw;
00089   GtkWidget   *equipwin;
00090           // Map locator:
00091   Locator     *locwin;
00092           // Combo editor:
00093   Combo_editor    *combowin;
00094           // Compile window:
00095   GtkWidget   *compilewin;
00096   Exec_box    *compile_box;
00097   // For Win32 DND
00098 #ifdef WIN32
00099   HWND      egghwnd;
00100   Windnd      *eggdnd;
00101   HWND      npchwnd;
00102   Windnd      *npcdnd;
00103   HWND      objhwnd;
00104   Windnd      *objdnd;
00105   HWND      shphwnd;
00106   Windnd      *shpdnd;
00107 #endif
00108           // Server data.
00109   int     server_socket;
00110   gint      server_input_tag;
00111   Msg_callback    waiting_for_server;
00112   void      *waiting_client;
00113 public:
00114   ExultStudio(int argc, char **argv);
00115   ~ExultStudio();
00116   bool okay_to_close();
00117   
00118   static ExultStudio *get_instance()
00119     { return self; }
00120   GladeXML *get_xml() 
00121     { return app_xml; }
00122   int get_server_socket() const
00123     { return server_socket; }
00124   guint32 get_background_color() const
00125     { return background_color; }
00126   char *get_shape_name(int shnum)
00127     { return shnum >= 0 && shnum < names.size() ?names[shnum] : 0;}
00128   const char *get_image_editor()
00129     { return image_editor; }
00130   Shape_file_set *get_files()
00131     { return files; }
00132   Object_browser *get_browser()
00133     { return browser; }
00134   unsigned char *get_palbuf()
00135     { return palbuf; }
00136   Shape_file_info *get_vgafile()  // 'shapes.vga'.
00137     { return vgafile; }
00138   Combo_editor *get_combowin()
00139     { return combowin; }
00140   void set_msg_callback(Msg_callback cb, void *client)
00141     { waiting_for_server = cb; waiting_client = client; }
00142   Shape_group_file *get_cur_groups();
00143   void set_browser(const char *name, Object_browser *obj);
00144   bool has_focus();   // Any of our windows has focus?
00145 
00146   void create_new_game(const char *dir);
00147   void new_game();
00148   void choose_game_path();
00149   Object_browser  *create_browser(const char *fname);
00150   void set_game_path(const char *path, const char *patchpath = 0);
00151   void setup_file_list();
00152   void save_all();    // Write out everything.
00153   bool need_to_save();    // Anything modified?
00154   void write_map();
00155   void read_map();
00156   void write_shape_info(bool force = false);
00157   void reload_usecode();
00158   void set_play(gboolean play);
00159   void set_tile_grid(gboolean grid);
00160   void set_edit_lift(int lift);
00161   void set_hide_lift(int lift);
00162   void set_edit_terrain(gboolean terrain);
00163   void set_edit_mode(int md);
00164   void show_unused_shapes(unsigned char *data, int datalen);
00165           // Open/create shape files:
00166   Shape_file_info *open_shape_file(const char *fname);
00167   void new_shape_file(bool single);
00168   static void create_shape_file(char *nm, gpointer udata);
00169           // Groups:
00170   void setup_groups();
00171   void setup_group_controls();
00172   void add_group();
00173   void del_group();
00174   void groups_changed(GtkTreeModel *model, GtkTreePath *path,
00175           GtkTreeIter *loc, bool value = false);
00176   void open_group_window();
00177   void close_group_window(GtkWidget *gtkwin);
00178   void save_groups();
00179   bool groups_modified();
00180   void update_group_windows(Shape_group *grp);
00181           // Objects:
00182   void open_obj_window(unsigned char *data, int datalen);
00183   void close_obj_window();
00184   int init_obj_window(unsigned char *data, int datalen);
00185   int save_obj_window();
00186   void show_obj_shape(int x = 0, int y = 0, int w = -1, int h = -1);
00187   void set_obj_shape(int shape, int frame);
00188           // Eggs:
00189   void open_egg_window(unsigned char *data = 0, int datalen = 0);
00190   void close_egg_window();
00191   int init_egg_window(unsigned char *data, int datalen);
00192   int save_egg_window();
00193   void show_egg_monster(int x = 0, int y = 0, int w = -1, int h = -1);
00194   void set_egg_monster(int shape, int frame);
00195           // NPC's:
00196   void open_npc_window(unsigned char *data = 0, int datalen = 0);
00197   void close_npc_window();
00198   void init_new_npc();
00199   int init_npc_window(unsigned char *data, int datalen);
00200   int save_npc_window();
00201   void show_npc_shape(int x = 0, int y = 0, int w = -1, int h = -1);
00202   void set_npc_shape(int shape, int frame);
00203   void show_npc_face(int x = 0, int y = 0, int w = -1, int h = -1);
00204   void set_npc_face(int shape, int frame);
00205   static void schedule_btn_clicked(GtkWidget *btn, gpointer data);
00206           // Shapes:
00207   void init_equip_window(int recnum);
00208   void save_equip_window();
00209   void open_equip_window(int recnum);
00210   void close_equip_window();
00211   void show_equip_shape(Equip_row_widgets *eq,
00212       int x = 0, int y = 0, int w = -1, int h = -1);
00213   void set_shape_notebook_frame(int frnum);
00214   void init_shape_notebook(Shape_info& info, GtkWidget *book, 
00215               int shnum, int frnum);
00216   void save_shape_notebook(Shape_info& info, int shnum, int frnum);
00217   void open_shape_window(int shnum, int frnum, 
00218       Shape_file_info *file_info,
00219           char *shname, Shape_info *info = 0);
00220   void save_shape_window();
00221   void close_shape_window();
00222   void show_shinfo_shape(int x = 0, int y = 0, int w = -1, int h = -1);
00223           // Map locator.
00224   void open_locator_window();
00225   void open_combo_window(); // Combo-object editor.
00226   void save_combos();
00227           // Compile.
00228   void open_compile_window();
00229   void compile(bool if_needed = false);
00230   void halt_compile();
00231   void run();
00232   bool send_to_server(Exult_server::Msg_type id,
00233         unsigned char *data = 0, int datalen = 0);
00234   void read_from_server();
00235   bool connect_to_server();
00236           // Message from Exult.
00237   void info_received(unsigned char *data, int datalen);
00238   void set_edit_menu(bool sel, bool clip);
00239           // Preferences.
00240   static void background_color_okay(GtkWidget *dlg, gpointer data);
00241   void open_preferences();
00242   void save_preferences();
00243           // GTK/Glade utils:
00244   bool get_toggle(char *name);
00245   void set_toggle(char *name, bool val);
00246   void set_bit_toggles(char **names, int num, unsigned char bits);
00247   unsigned char get_bit_toggles(char **names, int num);
00248   int get_optmenu(char *name);
00249   void set_optmenu(char *name, int val);
00250   int get_spin(char *name);
00251   void set_spin(char *name, int val, bool sensitive = true);
00252   void set_spin(char *name, int val, int low, int high);
00253   int get_num_entry(char *name);
00254   const gchar *get_text_entry(char *name);
00255   void set_entry(char *name, int val, bool hex = false,
00256             bool sensitive = true);
00257   void set_entry(char *name, const char *val, bool sensitive = true);
00258   guint set_statusbar(char *name, int context, char *msg);
00259   void remove_statusbar(char *name, int context, guint msgid);
00260   void set_button(char *name, const char *text);
00261   void set_visible(char *name, bool vis);
00262   void set_sensitive(char *name, bool vis);
00263   int prompt(const char *msg, const char *choice0, 
00264       const char *choice1 = 0,const char *choice2 = 0);
00265 };
00266 
00267           // Utilities:
00268 namespace EStudio {
00269 int Prompt(const char *msg, const char *choice0, 
00270       const char *choice1 = 0,const char *choice2 = 0);
00271 void Alert(const char *msg, ...);
00272 GtkWidget *Add_menu_item(GtkWidget *menu, const char *label = 0,
00273       GtkSignalFunc func = 0, gpointer func_data = 0);
00274 GtkWidget *Create_arrow_button(GtkArrowType dir, GtkSignalFunc clicked,
00275               gpointer func_data);
00276 }
00277 
00278 #endif

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