diff options
author | Vasily_Makarov <danilka.pro@gmail.com> | 2011-06-15 18:24:14 +0400 |
---|---|---|
committer | Vasily_Makarov <danilka.pro@gmail.com> | 2011-06-15 18:24:14 +0400 |
commit | 6c0a4a2bc3809ee49d55fdff7c55c25d3e6ad4a5 (patch) | |
tree | 8a43922891e4f5eb7909d8d2b80f64235760e18d /saedit/main.h | |
parent | 34dbe2ca8daae2595ee6ff37632a15e68fcc7fc2 (diff) | |
download | evol-tools-6c0a4a2bc3809ee49d55fdff7c55c25d3e6ad4a5.tar.gz evol-tools-6c0a4a2bc3809ee49d55fdff7c55c25d3e6ad4a5.tar.bz2 evol-tools-6c0a4a2bc3809ee49d55fdff7c55c25d3e6ad4a5.tar.xz evol-tools-6c0a4a2bc3809ee49d55fdff7c55c25d3e6ad4a5.zip |
saedit: Review code and add some features
Diffstat (limited to 'saedit/main.h')
-rw-r--r-- | saedit/main.h | 148 |
1 files changed, 4 insertions, 144 deletions
diff --git a/saedit/main.h b/saedit/main.h index 3afe623..7cd67b3 100644 --- a/saedit/main.h +++ b/saedit/main.h @@ -9,150 +9,17 @@ | | \*=======================================*/ -#include <stdlib.h> -#include <gtk/gtk.h> -#include <gtksourceview/gtksourceview.h> -#include <gtksourceview/gtksourcelanguagemanager.h> -#include <gtksourceview/gtksourceiter.h> -#include <ibusxml.h> -#include <cairo.h> -#include <glib/gi18n.h> - const int MIN_WIDTH = 600; const int MIN_HEIGHT = 600; -const int SPRITE_WIDTH_DEFAULT = 64; -const int SPRITE_HEIGHT_DEFAULT = 64; -const int GRID_SIZE = 32; const gchar *DIR_GROUNDS = "grounds"; const gchar *DIR_PLAYERS = "players/"; const gchar *FILE_ICON = "icon.svg"; -const gchar *FILE_CONFIG = "saedit/config.ini"; -const gchar *POSTFIX_FOLDER = "..."; -const gchar *SEPARATOR_SLASH = "/"; -const gchar *OPTION_SPRITES_DEFAULT = "graphics/sprites/"; - -const gboolean KEY_SHOW_GRID_DEFAULT = TRUE; -const gchar *KEY_CLIENTDATA_FOLDER_DEFAULT = ""; const int IMAGESET_PREVIEW_WINDOW_WIDTH = 200; const int IMAGESET_PREVIEW_WINDOW_HEIGHT = 300; -typedef struct { - XMLNode *node; - int offsetX; - int offsetY; - int width; - int height; - int spriteset_width; - int spriteset_height; - GdkPixbuf *spriteset; -} ImagesetInfo; - -typedef struct { - int index; - int offsetX; - int offsetY; - int delay; - GdkPixbuf *pixbuf; - cairo_surface_t *surface; -} Frame; -static Frame *frame_new(int index, int offsetX, int offsetY, int delay); - -static ImagesetInfo *imageset_info_new() { - ImagesetInfo *res = g_new0(ImagesetInfo, 1); - res->width = SPRITE_WIDTH_DEFAULT; - res->height = SPRITE_HEIGHT_DEFAULT; - return res; -} - -typedef struct { - GList *imagesets; - GList *actions; - GList *animations; - GList *animation; - ImagesetInfo *imageset; - Frame *sprite; - guint anim_tag; - XMLNode *root; - GtkWidget *imagesets_combo_box; - GtkWidget *actions_combo_box; - GtkWidget *animations_combo_box; - GdkPixbuf *ground; - int offsetX; - int offsetY; -} SAEInfo; - -static GdkPixbuf *sae_info_ground_new() { - GdkPixbuf *ground = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, GRID_SIZE * 3, GRID_SIZE * 3); - gdk_pixbuf_fill(ground, 0x00000000); - return ground; -} - -static SAEInfo *sae_info_new() { - SAEInfo *res = g_new0(SAEInfo, 1); - res->ground = sae_info_ground_new(); - res->sprite = frame_new(-1, 0, 0, 0); - res->imageset = imageset_info_new(); - return res; -} - - -typedef struct { - GList *sub_nodes; - guint *anim_tag; - SAEInfo *sae_info; -} AnimationInfo; - -static AnimationInfo *animation_info_new() { - return g_new0(AnimationInfo, 1); -} - -static AnimationInfo *animation_info_new_with_params(GList *sub_nodes_new, guint *anim_tag_new, SAEInfo *sae_info) { - AnimationInfo *res = animation_info_new(); - res->sub_nodes = sub_nodes_new; - res->anim_tag = anim_tag_new; - res->sae_info = sae_info; - return res; -} - -typedef struct { - XMLNode *node; - int start; - int end; - guint delay; - AnimationInfo *anim_info; - int repeat; -} SequenceInfo; - -static SequenceInfo *sequence_info_new(XMLNode *node, int start, int end, guint delay, AnimationInfo *anim_info, int repeat) { - SequenceInfo *res = g_new0(SequenceInfo, 1); - res->start = start; - res->end = end; - res->node = node; - res->delay = delay; - res->anim_info = anim_info; - res->repeat = repeat; - return res; -} - -typedef struct { - gchar *sprites; -} Options; - -typedef struct { - gchar *clientdata_folder; - gboolean show_grid; -} Keys; - -static Keys *keys_new() { - Keys *res = g_new0(Keys, 1); - res->clientdata_folder = KEY_CLIENTDATA_FOLDER_DEFAULT; - res->show_grid = KEY_SHOW_GRID_DEFAULT; - return res; -} - GtkWidget *win = NULL; GtkWidget *darea = NULL; GtkWidget *data_folder_chooser_button = NULL; @@ -173,7 +40,6 @@ GdkPixbuf *icon = NULL; Options *paths; Keys *config; -static gboolean show_animation_by_info(AnimationInfo *anim_info); static gchar *markup_bold(gchar *str); static void format_src_string(gchar *src); static void open_xml_file(GtkButton *button, gpointer buffer); @@ -181,24 +47,18 @@ static void free_imagesets(SAEInfo *sae_info); static void free_actions(SAEInfo *sae_info); static void free_animations(SAEInfo *sae_info); static void save_to_xml_file(GtkButton *button, gpointer buffer); -static void data_folder_set_handler(GtkFileChooserButton *widget, gpointer data); +static void data_folder_set_callback(GtkFileChooserButton *widget, gpointer data); static void show_wrong_source_buffer_dialog(); -static gchar* xml_node_get_attr_value(const XMLNode *node, const gchar *attr_name); -static gint xml_node_compare_with_name(gconstpointer a, gconstpointer b); -static gint xml_node_compare_with_action_node_by_imageset_name_func(gconstpointer a, gconstpointer b); -static gint xml_node_compare_with_direction_attr(gconstpointer node, gconstpointer direction); -static gint xml_node_compare_with_name_attr(gconstpointer node, gconstpointer name); static GdkPixbuf* get_sprite_by_index(size_t index, SAEInfo *sae_info); static void set_sprite_by_index(size_t index, SAEInfo *sae_info); static void set_up_actions_by_imageset_name(gchar *imageset_name, SAEInfo *sae_info); static gboolean set_up_imagesets(SAEInfo *sae_info); -static gboolean sequence_source_func(SequenceInfo *seq); static gboolean show_general_animation(SAEInfo *sae_info); static gboolean set_up_action_by_name(const gchar *name, SAEInfo *sae_info); -static void actions_combo_box_changed_handler(GtkComboBox *widget, gpointer user_data); -static void animations_combo_box_changed_handler(GtkComboBox *widget, gpointer user_data); +static void actions_combo_box_changed_callback(GtkComboBox *widget, gpointer user_data); +static void animations_combo_box_changed_callback(GtkComboBox *widget, gpointer user_data); static void set_up_imageset_by_name(const gchar* name, SAEInfo *sae_info); -static void imagesets_combo_box_changed_handler(GtkComboBox *widget, gpointer user_data); +static void imagesets_combo_box_changed_callback(GtkComboBox *widget, gpointer user_data); static void parse_xml_buffer(GtkWidget *button, GtkSourceBuffer *buffer); static void set_up_interface(); static void show_about_dialog(); |