1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
/*=======================================*\
| ____ ____ |
| / \ /\ | |
| \____ / \ |____ |
| \ /____\ | |
| \____/prite / \nimation |____ditor |
| |
| Copyleft Vasily_Makarov 2011 |
| |
\*=======================================*/
#include <stdlib.h>
#include <gtk/gtk.h>
#include <gtksourceview/gtksourceview.h>
#include <gtksourceview/gtksourcelanguagemanager.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 *BACKGROUNDS_DIR = "backgrounds";
const gchar *ICON_FILE = "icon.svg";
const gchar *CONFIG_FILE = "/saedit/config.ini";
const gchar *FOLDER_POSTFIX = "/...";
const gchar *SLASH_SEPARATOR = "/";
const gchar *OPTION_SPRITES_DEFAULT = "graphics/sprites/";
typedef struct {
XMLNode *node;
GList *next;
guint delay;
} sequence;
typedef struct {
int index;
int offsetX;
int offsetY;
} sprite_info;
static sprite_info *sprite_info_new(int index, int offsetX, int offsetY);
typedef struct {
gchar *sprites;
} options;
typedef struct {
XMLNode *node;
int offsetX;
int offsetY;
GdkPixbuf *spriteset;
GdkPixbuf *ground;
} imageset_info;
static imageset_info *imageset_info_new() {
imageset_info *res = g_new0(imageset_info, 1);
res->ground = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, GRID_SIZE * 3, GRID_SIZE * 3);
gdk_pixbuf_fill(res->ground, 0x00000000);
return res;
}
int sprite_width = 64, sprite_height = 64;
int spriteset_width, spriteset_height;
int offsetX = 0, offsetY = 0;
GtkWidget *win = NULL;
GtkWidget *darea = NULL;
GtkWidget *data_folder_chooser_button = NULL;
GtkWidget *xml_file_chooser_button = NULL;
GtkWidget *xml_file_open_button = NULL;
GtkWidget *xml_file_save_button = NULL;
GtkWidget *imagesets_combo_box = NULL;
GtkWidget *actions_combo_box = NULL;
GtkWidget *animations_combo_box = NULL;
GtkSourceBuffer *sbuf = NULL;
GList *imagesets = NULL;
GList *actions = NULL;
GList *animations = NULL;
GdkPixbuf *icon = NULL;
XMLNode *root = NULL;
imageset_info *imageset = NULL;
sprite_info *current_sprite;
guint running_animation = 0;
options *paths;
static gboolean show_animation_by_sub_nodes (GList *sub_nodes);
static gchar *markup_bold(gchar *str);
static void format_src_string(gchar *src);
static void open_xml_file(GtkButton *button, gpointer buffer);
static void free_imagesets();
static void free_actions();
static void free_animations();
static void save_to_xml_file(GtkButton *button, gpointer buffer);
static void data_folder_set_handler(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);
static void set_sprite_by_index(size_t index);
static void set_up_actions_by_imageset_name(gchar *imageset_name);
static gboolean set_up_imagesets(const XMLNode *root);
static gboolean sequence_source_func(sequence *seq);
static gboolean show_general_animation();
static gboolean set_up_action_by_name(const gchar *name);
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 set_up_imageset_by_node(XMLNode *node);
static void imagesets_combo_box_changed_handler(GtkComboBox *widget, gpointer user_data);
static void parse_xml_buffer(GtkWidget *button, GtkSourceBuffer *buffer);
static void set_up_interface();
static void show_about_dialog();
static void show_imageset_window();
static gboolean frame_image_button_press_event(GtkWidget *widget, GdkEventButton *button, int index);
static cairo_surface_t *get_grid_surface(int w, int h);
static gboolean darea_expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data);
static void load_config();
static void save_config_and_quit();
static void load_options();
|