From a0c410d5ac8eeeeb4d7295c8f54931fa32664f4d Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Tue, 22 Feb 2022 07:08:17 -0300 Subject: Remove saedit --- saedit/COPYING | 340 ------------------- saedit/Makefile | 33 -- saedit/bmake | 28 -- saedit/common.h | 24 -- saedit/config.c | 82 ----- saedit/config.h | 51 --- saedit/grounds/earth.png | Bin 4193 -> 0 bytes saedit/grounds/grass.png | Bin 5142 -> 0 bytes saedit/grounds/sand.png | Bin 5205 -> 0 bytes saedit/grounds/water.png | Bin 7945 -> 0 bytes saedit/icon.svg | 654 ------------------------------------ saedit/interface.c | 124 ------- saedit/interface.ui | 852 ----------------------------------------------- saedit/main.c | 609 --------------------------------- saedit/main.h | 119 ------- saedit/sae.c | 212 ------------ saedit/sae.h | 69 ---- saedit/search.c | 74 ---- saedit/search.h | 26 -- saedit/template.xml | 6 - saedit/valg | 2 - saedit/xml.c | 316 ------------------ saedit/xml.h | 42 --- 23 files changed, 3663 deletions(-) delete mode 100644 saedit/COPYING delete mode 100644 saedit/Makefile delete mode 100755 saedit/bmake delete mode 100644 saedit/common.h delete mode 100644 saedit/config.c delete mode 100644 saedit/config.h delete mode 100644 saedit/grounds/earth.png delete mode 100644 saedit/grounds/grass.png delete mode 100644 saedit/grounds/sand.png delete mode 100644 saedit/grounds/water.png delete mode 100644 saedit/icon.svg delete mode 100644 saedit/interface.c delete mode 100644 saedit/interface.ui delete mode 100644 saedit/main.c delete mode 100644 saedit/main.h delete mode 100644 saedit/sae.c delete mode 100644 saedit/sae.h delete mode 100644 saedit/search.c delete mode 100644 saedit/search.h delete mode 100644 saedit/template.xml delete mode 100755 saedit/valg delete mode 100644 saedit/xml.c delete mode 100644 saedit/xml.h diff --git a/saedit/COPYING b/saedit/COPYING deleted file mode 100644 index e8b00c2..0000000 --- a/saedit/COPYING +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/saedit/Makefile b/saedit/Makefile deleted file mode 100644 index 8d033f3..0000000 --- a/saedit/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -ifndef CFLAGS - CFLAGS = -O2 -pipe -endif - -ifndef LDFLAGS - LDFLAGS = -endif - -ifndef OUTPUT - OUTPUT = saedit -endif - -LDFLAGS += -export-dynamic - -CFLAGS += `pkg-config --cflags gtk+-3.0 gtksourceview-3.0` - -LDFLAGS += `pkg-config --libs gtk+-3.0 gtksourceview-3.0` - -all:main.o search.o config.o xml.o sae.o compile clean -compile: main.o search.o config.o xml.o - gcc ${CFLAGS} -o '${OUTPUT}' main.o search.o config.o xml.o sae.o ${LDFLAGS} -main.o: main.c main.h search.h config.h common.h xml.h - gcc ${CFLAGS}-c -o main.o main.c -search.o: search.c search.h common.h - gcc ${CFLAGS} -c -o search.o search.c -xml.o: xml.c xml.h common.h - gcc ${CFLAGS} -c -o xml.o xml.c -config.o: config.c config.h common.h - gcc ${CFLAGS} -c -o config.o config.c -sae.o: sae.c sae.h common.h - gcc ${CFLAGS} -c -o sae.o sae.c -clean: - rm -rfv *.o *~ diff --git a/saedit/bmake b/saedit/bmake deleted file mode 100755 index a1ecd7f..0000000 --- a/saedit/bmake +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh - -dir=`pwd` - -export LANG=C - -make clean - -#export CFLAGS="-std=c99 -Wvariadic-macros -Wvla -Wredundant-decls - -export CFLAGS="-std=gnu99 -Wvariadic-macros -Wvla -Wredundant-decls \ --Wpacked-bitfield-compat -Wtrampolines \ --Wsuggest-attribute=noreturn -Wstrict-aliasing=2 \ --fstrict-aliasing -Wunreachable-code -Wabi -Wdisabled-optimization \ --Wvolatile-register-var -Winvalid-pch -Wredundant-decls \ --Wnormalized=nfkc -Wmissing-format-attribute -Wmissing-noreturn \ --Wswitch-default -Waddress \ --Wlogical-op -Wcast-align -Wpointer-arith -Wundef \ --Wmissing-include-dirs -Winit-self -pedantic -Wall -ggdb3 -O2 -pipe \ --Wpacked -Wstrict-overflow=1 -Wunknown-pragmas -Wwrite-strings \ --Wstack-protector -Wshadow -Wunused-macros \ --Wbuiltin-macro-redefined -Wdeprecated \ --Wendif-labels -Wformat=1 -Wimport -Wpsabi \ --Wmissing-field-initializers -Wuninitialized \ --Wignored-qualifiers -Winit-self -Wempty-body -Wclobbered -Wtype-limits \ --Wsign-compare -Wwrite-strings" - -make 2>make.log diff --git a/saedit/common.h b/saedit/common.h deleted file mode 100644 index 21e6526..0000000 --- a/saedit/common.h +++ /dev/null @@ -1,24 +0,0 @@ -/*=======================================*\ -| ____ ____ | -| / \ /\ | | -| \____ / \ |____ | -| \ /____\ | | -| \____/prite / \nimation |____ditor | -| | -| Copyleft Vasily_Makarov 2011 | -| | -\*=======================================*/ - -#ifndef COMMON_H -#define COMMON_H - -#include - -#define POSTFIX_FOLDER "..." -#define SEPARATOR_SLASH "/" -#define GRID_SIZE 32 -#define SPRITE_WIDTH_DEFAULT 64 -#define SPRITE_HEIGHT_DEFAULT 64 -#define FILE_TEMPLATE "template.xml" - -#endif diff --git a/saedit/config.c b/saedit/config.c deleted file mode 100644 index 67bb63d..0000000 --- a/saedit/config.c +++ /dev/null @@ -1,82 +0,0 @@ -/*=======================================*\ -| ____ ____ | -| / \ /\ | | -| \____ / \ |____ | -| \ /____\ | | -| \____/prite / \nimation |____ditor | -| | -| Copyleft Vasily_Makarov 2011 | -| | -\*=======================================*/ - -#include "config.h" - -Options *config_options_new() { - return g_new0(Options, 1); -} - -void config_options_load_from_file(Options *options, - gchar *file, - gchar *data_folder) { - options->sprites = NULL; - - XMLNode *node = xml_parse_file(file); - - if (node != NULL) { - GList *list = node->sub_nodes; - while (TRUE) { - list = g_list_find_custom(list, "option", xml_node_compare_with_name_func); - if (list == NULL) - break; - gchar *name_attr = xml_node_get_attr_value(list->data, "name"); - if (name_attr != NULL) { - if (g_strcmp0(name_attr, "sprites") == 0) - options->sprites = xml_node_get_attr_value(list->data, "value"); - } - list = list->next; - } - } - - if (options->sprites == NULL) options->sprites = (gchar *)OPTION_SPRITES_DEFAULT; - options->sprites = g_strjoin(SEPARATOR_SLASH, data_folder, options->sprites, NULL); -} - -Keys *config_keys_new() { - Keys *keys = g_new0(Keys, 1); - keys->clientdata_folder = (gchar *)KEY_CLIENTDATA_FOLDER_DEFAULT; - keys->show_grid = KEY_SHOW_GRID_DEFAULT; - return keys; -} - -void config_keys_save(Keys *keys) { - GKeyFile *key_file = g_key_file_new(); - g_key_file_set_value(key_file, "General", "ClientdataFolder", - g_strjoin(SEPARATOR_SLASH, - keys->clientdata_folder, - POSTFIX_FOLDER, - NULL)); - g_key_file_set_boolean(key_file, "General", "ShowGrid", keys->show_grid); - - mkdir(KEYS_CONFIG_DIR, S_IRWXU); - int fd = g_creat(KEYS_CONFIG_FILE, S_IREAD | S_IWRITE); - gchar *buf = g_key_file_to_data(key_file, NULL, NULL); - write(fd, buf, strlen(buf)); - close(fd); - - g_key_file_free(key_file); -} - -void config_keys_load(Keys *keys) { - GKeyFile *key_file = g_key_file_new(); - - g_key_file_load_from_file(key_file, - KEYS_CONFIG_FILE, - 0, - NULL); - if (g_key_file_has_key(key_file, "General", "ClientdataFolder", NULL)) - keys->clientdata_folder = g_key_file_get_value(key_file, "General", "ClientdataFolder", NULL); - if (g_key_file_has_key(key_file, "General", "ShowGrid", NULL)) - keys->show_grid = g_key_file_get_boolean(key_file, "General", "ShowGrid", NULL); - - g_key_file_free(key_file); -} diff --git a/saedit/config.h b/saedit/config.h deleted file mode 100644 index ca43eed..0000000 --- a/saedit/config.h +++ /dev/null @@ -1,51 +0,0 @@ -/*=======================================*\ -| ____ ____ | -| / \ /\ | | -| \____ / \ |____ | -| \ /____\ | | -| \____/prite / \nimation |____ditor | -| | -| Copyleft Vasily_Makarov 2011 | -| | -\*=======================================*/ - -#ifndef CONFIG_H -#define CONFIG_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include "common.h" -#include "xml.h" - -#define OPTION_SPRITES_DEFAULT "graphics/sprites/" - -#define KEY_SHOW_GRID_DEFAULT TRUE -#define KEY_CLIENTDATA_FOLDER_DEFAULT "" -#define KEYS_CONFIG_DIR g_strjoin(SEPARATOR_SLASH, g_get_user_config_dir(), "saedit", NULL) -#define KEYS_CONFIG_FILE g_strjoin(SEPARATOR_SLASH, KEYS_CONFIG_DIR, "config.ini", NULL) - -typedef struct { - gchar *sprites; -} Options; - -Options *config_options_new(); -void config_options_load_from_file(Options *options, - gchar *file, - gchar *data_folder); - -typedef struct { - gchar *clientdata_folder; - gboolean show_grid; -} Keys; - -Keys *config_keys_new(); -void config_keys_load(Keys *keys); -void config_keys_save(Keys *keys); - -#endif diff --git a/saedit/grounds/earth.png b/saedit/grounds/earth.png deleted file mode 100644 index 9bdb25a..0000000 Binary files a/saedit/grounds/earth.png and /dev/null differ diff --git a/saedit/grounds/grass.png b/saedit/grounds/grass.png deleted file mode 100644 index a0f3ab5..0000000 Binary files a/saedit/grounds/grass.png and /dev/null differ diff --git a/saedit/grounds/sand.png b/saedit/grounds/sand.png deleted file mode 100644 index 31be5db..0000000 Binary files a/saedit/grounds/sand.png and /dev/null differ diff --git a/saedit/grounds/water.png b/saedit/grounds/water.png deleted file mode 100644 index 20da6b4..0000000 Binary files a/saedit/grounds/water.png and /dev/null differ diff --git a/saedit/icon.svg b/saedit/icon.svg deleted file mode 100644 index 6a3bf35..0000000 --- a/saedit/icon.svg +++ /dev/null @@ -1,654 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - diff --git a/saedit/interface.c b/saedit/interface.c deleted file mode 100644 index 0984cbd..0000000 --- a/saedit/interface.c +++ /dev/null @@ -1,124 +0,0 @@ -/*=======================================*\ -| ____ ____ | -| / \ /\ | | -| \____ / \ |____ | -| \ /____\ | | -| \____/prite / \nimation |____ditor | -| | -| Copyleft Vasily_Makarov 2011 | -| | -\*=======================================*/ - -GtkWidget *reload_menu_item = NULL; -GtkWidget *find_dialog = NULL; -GtkWidget *toolbar = NULL; - -void find_menu_item_activate_callback(GtkWidget *menuitem, gpointer user_data) { - gtk_dialog_run(GTK_DIALOG(find_dialog)); -} - -void save_dialog_response_callback(GtkWidget *dialog, gint response_id, gpointer user_data) { - if (response_id == GTK_RESPONSE_ACCEPT) { - gchar *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); - if (filename != NULL) { - save_to_xml_file(filename); - gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(xml_file_chooser_button), filename); - } - } - gtk_widget_destroy(dialog); -} - -void save_dialog_show() { - GtkDialog *dialog = GTK_DIALOG(gtk_file_chooser_dialog_new(_("Save file as..."), GTK_WINDOW(win), GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL)); - g_signal_connect(dialog, "response", G_CALLBACK(save_dialog_response_callback), NULL); - gtk_dialog_run(dialog); -} - -void save_menu_item_activate_callback(GtkWidget *menuitem, GtkWidget *fsdialog) { - gchar *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(xml_file_chooser_button)); - if (filename != NULL) - save_to_xml_file(filename); - else - save_dialog_show(); -} - -void xml_file_save_button_callback(GtkWidget *button, gpointer user_data) { - gchar *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(xml_file_chooser_button)); - if (filename != NULL) - save_to_xml_file(filename); -} - -void file_new() { - GtkTextIter start, end; - gtk_text_buffer_get_bounds(GTK_TEXT_BUFFER(source_buffer), &start, &end); - gtk_text_buffer_delete(GTK_TEXT_BUFFER(source_buffer), &start, &end); - gchar *temp; - if (g_file_get_contents(FILE_TEMPLATE, &temp, NULL, NULL)) - gtk_text_buffer_set_text(GTK_TEXT_BUFFER(source_buffer), temp, -1); - gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(xml_file_chooser_button), ""); - gtk_widget_set_sensitive(reload_menu_item, FALSE); - - free_current_info(); -} - -void set_up_interface() { - - GtkBuilder *builder = gtk_builder_new(); - gtk_builder_add_from_file(builder, "interface.ui", NULL); - gtk_builder_connect_signals(builder, NULL); - - //Setup main window - win = GTK_WIDGET(gtk_builder_get_object(builder, "win_main")); - - //Setup GtkSourceView - GtkSourceLanguageManager *langman = gtk_source_language_manager_get_default(); - source_buffer = gtk_source_buffer_new_with_language(gtk_source_language_manager_get_language(langman, "xml")); - - source_view = GTK_WIDGET(gtk_builder_get_object(builder, "source_view")); - gtk_text_view_set_buffer(GTK_TEXT_VIEW(source_view), GTK_TEXT_BUFFER(source_buffer)); - search_init(source_view); - - //Setup GtkScrolledWindow - GtkWidget *scrolled_window = NULL; - scrolled_window = GTK_WIDGET(gtk_builder_get_object(builder, "scrolledwindow1")); - gtk_scrolled_window_set_hadjustment(GTK_SCROLLED_WINDOW(scrolled_window), - gtk_text_view_get_hadjustment(GTK_TEXT_VIEW(source_view))); - gtk_scrolled_window_set_vadjustment(GTK_SCROLLED_WINDOW(scrolled_window), - gtk_text_view_get_vadjustment(GTK_TEXT_VIEW(source_view))); - - //Setup GtkDrawingArea - darea = GTK_WIDGET(gtk_builder_get_object(builder, "darea1")); - - //Setup GtkToolbar - toolbar = GTK_WIDGET(gtk_builder_get_object(builder, "toolbar")); - - reload_menu_item = GTK_WIDGET(gtk_builder_get_object(builder, "menuitem6")); - show_grid_menu_item = GTK_WIDGET(gtk_builder_get_object(builder, "menuitem11")); - imageset_preview_menu_item = GTK_WIDGET(gtk_builder_get_object(builder, "menuitem12")); - - data_folder_chooser_button = GTK_WIDGET(gtk_builder_get_object(builder, "datafcbutton")); - xml_file_chooser_button = GTK_WIDGET(gtk_builder_get_object(builder, "xmlfcbutton")); - xml_file_open_button = GTK_WIDGET(gtk_builder_get_object(builder, "xmlfobutton")); - xml_file_save_button = GTK_WIDGET(gtk_builder_get_object(builder, "xmlfsbutton")); - - gen_sae_info->imagesets_combo_box = GTK_WIDGET(gtk_builder_get_object(builder, "imagesetscbox")); - gen_sae_info->actions_combo_box = GTK_WIDGET(gtk_builder_get_object(builder, "actionscbox")); - gen_sae_info->animations_combo_box = GTK_WIDGET(gtk_builder_get_object(builder, "animationscbox")); - - //Setup GtkAboutDialog - about_dialog = GTK_WIDGET(gtk_builder_get_object(builder, "about_dialog")); - - //Setup GtkMessageDialog - parsing_error_dialog = GTK_WIDGET(gtk_builder_get_object(builder, "parsing-error-dialog")); - - //Setup Find dialog - find_dialog = GTK_WIDGET(gtk_builder_get_object(builder, "find_dialog")); - gtk_widget_hide(find_dialog); - - file_new(); - - gtk_widget_show_all(win); - gtk_widget_show_all(source_view); - - g_object_unref(builder); -} diff --git a/saedit/interface.ui b/saedit/interface.ui deleted file mode 100644 index dc83601..0000000 --- a/saedit/interface.ui +++ /dev/null @@ -1,852 +0,0 @@ - - - - - - - - False - 5 - Open file - dialog - - - True - False - 2 - - - True - False - end - - - gtk-open - False - True - True - True - True - - - False - False - 0 - - - - - gtk-cancel - False - True - True - True - True - - - False - False - 1 - - - - - False - True - end - 0 - - - - - - - - - button1 - button2 - - - - 600 - 600 - False - Sprite Animation Editor - center - 600 - 600 - icon.svg - - - - True - False - - - True - False - - - False - True - False - _File - True - - - True - False - accelgroup - - - False - True - False - _New - True - - - - - - - False - True - False - _Open... - True - - - - - - - False - True - False - _Reload - True - - - - - - - False - True - False - - - - - False - True - False - _Save - True - - - - - - - False - True - False - Save _as... - True - - - - - - - - - - - False - True - False - _Search - True - - - True - False - - - False - True - False - _Find... - True - - - - - - - False - True - False - Find _Next - True - - - - - - - - - - - False - True - False - _View - True - - - True - False - - - False - True - False - Show _Grid - True - - - - - - - False - True - False - _Imageset view - True - - - - - - - - - - - False - True - False - _Help - True - - - True - False - - - False - True - False - _About - True - - - - - - - - - - False - True - 0 - - - - - True - False - - - True - False - - - 24 - True - False - Clientdata folder - - - - - - False - False - 0 - - - - - True - False - select-folder - Clientdata folder - - - - False - False - 1 - - - - - 24 - True - False - XML source file - - - - - - False - False - 2 - - - - - True - False - False - fcdialog1 - Select XML file - - - - False - False - 3 - - - - - gtk-open - False - True - True - True - True - - - - False - False - 4 - - - - - gtk-save - False - True - True - True - True - - - - False - False - 5 - - - - - Parse XML Buffer - False - True - True - True - - - - False - False - 6 - - - - - 30 - False - - - False - False - 7 - - - - - 24 - True - False - Imagesets - - - - - - False - False - 8 - - - - - True - False - 0 - - - - False - False - 9 - - - - - 24 - True - False - Actions - - - - - - False - False - 10 - - - - - True - False - 0 - - - - False - False - 11 - - - - - 24 - True - False - Directions - - - - - - False - False - 12 - - - - - True - False - 0 - - - - False - False - 13 - - - - - False - False - 0 - - - - - 1 - False - vertical - - - False - False - 1 - - - - - True - True - - - False - - - 120 - True - False - - - - True - True - 0 - - - - - True - False - False - - - False - True - False - First frame - True - gtk-goto-first - - - - True - True - - - - - False - True - False - Previous frame - True - gtk-go-back - - - - True - True - - - - - False - True - False - Continue sequencing - True - gtk-media-play - - - - True - True - - - - - False - True - False - Pause sequencing - True - gtk-media-pause - - - - True - True - - - - - False - True - False - Next frame - True - gtk-go-forward - - - - True - True - - - - - False - True - False - Last frame - True - gtk-goto-last - - - - True - True - - - - - False - True - 1 - - - - - False - True - - - - - True - True - - - True - True - 2 - 2 - True - 4 - True - True - False - - - - - True - True - - - - - True - True - 2 - - - - - True - True - 1 - - - - - - - False - 5 - center - icon.svg - dialog - win_main - Sprite Animation Editor - ⍺0.1.1 - Copyleft ↄ Vasily_Makarov 2011-2015 - A simple tool to edit eAthena-based XML animation files - Vasily_Makarov <danilka.pro@gmail.com> -Reid Yaro <reidyaro@gmail.com> - icon.svg - gpl-2-0 - - - True - False - 2 - - - True - False - end - - - False - True - end - 0 - - - - - - - - - - 240 - 80 - False - 5 - Find - False - normal - True - True - win_main - - - - True - False - 2 - - - True - False - end - - - gtk-find - False - True - True - True - True - - - False - False - 0 - - - - - gtk-cancel - False - True - True - True - True - - - False - False - 1 - - - - - False - True - end - 0 - - - - - True - True - - False - False - - - True - True - 1 - - - - - - - - - button4 - button5 - - - - - - - - - - - - - - - - - - - - - - False - 5 - Parsing error - dialog - True - True - error - close - <b>Bad source buffer!</b> - True - - - - False - vertical - 14 - - - False - end - - - - - - - - - False - True - end - 0 - - - - - - diff --git a/saedit/main.c b/saedit/main.c deleted file mode 100644 index d6c147a..0000000 --- a/saedit/main.c +++ /dev/null @@ -1,609 +0,0 @@ -/*=======================================*\ -| ____ ____ | -| / \ /\ | | -| \____ / \ |____ | -| \ /____\ | | -| \____/prite / \nimation |____ditor | -| | -| Copyleft Vasily_Makarov 2011 | -| | -\*=======================================*/ - -#include "main.h" -#include "interface.c" - -//Cairo functions - -cairo_surface_t *get_grid_surface(int w, int h) { - cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, (w + 2) * GRID_SIZE, (h + 2) * GRID_SIZE); - cairo_t *cr = cairo_create(surface); - int x, y; - - for (x = 0; x < w; x++) - for (y = 0; y < h; y++) { - gdk_cairo_set_source_pixbuf(cr, gen_sae_info->ground, x * GRID_SIZE, y * GRID_SIZE); - cairo_paint(cr); - } - - if (config->show_grid) { - cairo_surface_t *gridsurf = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w * GRID_SIZE + 1, h * GRID_SIZE + 1); - cairo_t *scr = cairo_create(gridsurf); - cairo_set_line_width(scr, 1); - cairo_set_source_rgba(scr, 0.5, 0.5, 0.5, 1); - for (x = 0; x < w; x++) - for (y = 0; y < h; y++) { - cairo_rectangle(scr, x*GRID_SIZE+0.5, y*GRID_SIZE+0.5, GRID_SIZE, GRID_SIZE); - cairo_stroke(scr); - } - cairo_set_source_surface(cr, gridsurf, GRID_SIZE, GRID_SIZE); - cairo_paint(cr); - cairo_destroy(scr); - cairo_surface_destroy(gridsurf); - } - - cairo_destroy(cr); - return surface; -} - -gboolean darea_draw_event(GtkWidget *widget, cairo_t *cr, SAEInfo *sae_info) { - - if (sae_info == NULL) - sae_info = gen_sae_info; - - int width = gtk_widget_get_allocated_width(widget), - height = gtk_widget_get_allocated_height(widget); - - int w = 3, h = 3; - - //cairo_t *cr = gdk_cairo_create(gtk_widget_get_parent_window(widget)); - - cairo_surface_t *surface = get_grid_surface(w, h); - cairo_set_source_surface(cr, surface, width/2 - GRID_SIZE * (w + 2) * 0.5, height/2 - GRID_SIZE * (h + 2) * 0.5); - cairo_paint(cr); - - if (player != NULL) { - GdkPixbuf *pbuf = player->sprite->pixbuf; - if (pbuf == NULL) return FALSE; - gdk_cairo_set_source_pixbuf(cr, pbuf, - width/2 - player->imageset->width/2 + player->offsetX + player->sprite->offsetX + player->imageset->offsetX, - height/2 + GRID_SIZE/2 - player->imageset->height + player->offsetY + player->sprite->offsetY + player->imageset->offsetY); - cairo_paint(cr); - } - - GdkPixbuf *pbuf = sae_info->sprite->pixbuf; - if (pbuf == NULL) return FALSE; - gdk_cairo_set_source_pixbuf(cr, pbuf, - width/2 - sae_info->imageset->width/2 + sae_info->offsetX + sae_info->sprite->offsetX + sae_info->imageset->offsetX, - height/2 +GRID_SIZE/2 - sae_info->imageset->height + sae_info->offsetY + sae_info->sprite->offsetY + sae_info->imageset->offsetY); - cairo_paint(cr); - - cairo_surface_destroy(surface); - return FALSE; -} - -//Common functions - -gchar *markup_bold(gchar *str) { - return g_strconcat("", str, "", NULL); -} - -void format_src_string(gchar *src) { - gchar *str = g_strrstr(src, "|"); - if (str == NULL) return; - strncpy(str, "\0", 1); -} - -GtkTextIter *gtk_source_buffer_highlight_line(GtkSourceBuffer *buffer, int line_number) { - GtkTextIter start; - gtk_text_buffer_get_start_iter(GTK_TEXT_BUFFER(buffer), &start); - gtk_text_iter_set_line(&start, line_number); - gtk_text_buffer_place_cursor(GTK_TEXT_BUFFER(buffer), &start); - return gtk_text_iter_copy(&start); -} - -//File working - -void open_xml_file(GtkButton *button) { - gtk_widget_set_sensitive(xml_file_open_button, TRUE); - gtk_widget_set_sensitive(reload_menu_item, TRUE); - gchar *buf; - size_t len; - g_file_get_contents(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(xml_file_chooser_button)), &buf, &len, NULL); - if (g_utf8_validate(buf, len, NULL)) { - gtk_text_buffer_set_text(GTK_TEXT_BUFFER(source_buffer), buf, len); - gtk_widget_set_sensitive(xml_file_save_button, TRUE); - } else { - gtk_file_chooser_unselect_all(GTK_FILE_CHOOSER(xml_file_chooser_button)); - } - - free_current_info(); -} - -void save_to_xml_file(gchar *filename) { - GtkTextIter start, end; - gtk_text_buffer_get_start_iter(GTK_TEXT_BUFFER(source_buffer), &start); - gtk_text_buffer_get_end_iter(GTK_TEXT_BUFFER(source_buffer), &end); - g_file_set_contents(filename, gtk_text_buffer_get_text(GTK_TEXT_BUFFER(source_buffer), &start, &end, TRUE), -1, NULL); -} - -//SAEInfo functions (must be ported to sae.c) - -void free_imagesets(SAEInfo *sae_info) { - free_imageset(sae_info); - sae_info->imagesets = NULL; - gtk_list_store_clear(GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(sae_info->imagesets_combo_box)))); -} - -void free_imageset(SAEInfo *sae_info) { - sae_info->imageset = imageset_new(); - sae_info->ground = sae_info_ground_new(); - gtk_widget_set_sensitive(imageset_preview_menu_item, FALSE); - gtk_widget_set_sensitive(toolbar, FALSE); -} - -void free_actions(SAEInfo *sae_info) { - sae_info->actions = NULL; - if (sae_info->actions_combo_box != NULL) - gtk_list_store_clear(GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(sae_info->actions_combo_box)))); -} - -void free_animations(SAEInfo *sae_info) { - sae_info->animations = NULL; - - if (sae_info->animations_combo_box != NULL) - gtk_list_store_clear(GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(sae_info->animations_combo_box)))); - - kill_timeout(sae_info->anim_tag); - sae_info->anim_tag = 0; - sae_info->sprite = frame_new(-1, 0, 0, 0); - set_sprite_by_index(0, sae_info); -} - -void free_lists(SAEInfo *sae_info) { - free_imagesets(sae_info); - free_actions(sae_info); - free_animations(sae_info); -} - -void free_current_info() { - free_lists(gen_sae_info); - player = NULL; -} - -//Callbacks - -void data_folder_set_callback(GtkFileChooserButton *widget, gpointer data) { - config->clientdata_folder = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(data_folder_chooser_button)); - gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(xml_file_chooser_button), gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget))); -} - -void show_grid_menu_item_toggled_callback(GtkCheckMenuItem *checkmenuitem, gpointer user_data) { - config->show_grid = gtk_check_menu_item_get_active(checkmenuitem); - gtk_widget_queue_draw(darea); -} - -void parsing_error_warning(SAEInfo *sae_info, const gchar *message) { - free_lists(sae_info); - gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(parsing_error_dialog), "%s", message); - gtk_dialog_run(GTK_DIALOG(parsing_error_dialog)); -} - -void actions_combo_box_changed_callback(GtkComboBoxText *widget, gpointer user_data) { - if (player != NULL) - set_up_action_by_name(gtk_combo_box_text_get_active_text(widget), player); - set_up_action_by_name(gtk_combo_box_text_get_active_text(widget), gen_sae_info); -} - -void animations_combo_box_changed_callback(GtkComboBoxText *widget, gpointer user_data) { - set_up_animation_by_direction(gen_sae_info, gtk_combo_box_text_get_active_text(widget)); - if (player != NULL) { - set_up_animation_by_direction(player, gtk_combo_box_text_get_active_text(widget)); - show_animation(player); - } - show_animation(gen_sae_info); -} - -void imagesets_combo_box_changed_callback(GtkComboBoxText *widget, gpointer user_data) { - if (gtk_combo_box_text_get_active_text(widget) != NULL) - set_up_imageset_by_name(gtk_combo_box_text_get_active_text(widget), gen_sae_info); -} - -gboolean frame_image_button_press_event_callback(GtkWidget *widget, GdkEventButton *button, int idx) { - gchar buf[10]; - gint len = g_sprintf(buf, "%d", idx); - gtk_text_buffer_insert_at_cursor(GTK_TEXT_BUFFER(source_buffer), buf, len); - return FALSE; -} - -void open_menu_item_activate_callback(GtkMenuItem *menuitem, GtkFileChooserDialog *fcdialog) { - gtk_dialog_run(GTK_DIALOG(fcdialog)); -} - -//>Toolbar callbacks -void toolbar_to_first_clicked_callback(GtkToolButton *toolbutton, gpointer user_data) { - toolbar_pause_clicked_callback(toolbutton, user_data); - gen_sae_info->animation = g_list_first(gen_sae_info->animation); - show_sprite(gen_sae_info); -} - -void toolbar_prev_frame_clicked_callback(GtkToolButton *toolbutton, gpointer user_data) { - toolbar_pause_clicked_callback(toolbutton, user_data); - GList *prev = g_list_previous(gen_sae_info->animation); - if (prev == NULL) - return; - gen_sae_info->animation = prev; - show_sprite(gen_sae_info); -} - -void toolbar_play_clicked_callback(GtkToolButton *toolbutton, gpointer user_data) { - show_animation(gen_sae_info); -} - -void toolbar_pause_clicked_callback(GtkToolButton *toolbutton, gpointer user_data) { - int tag = gen_sae_info->anim_tag; - if (tag > 0) { - kill_timeout(tag); - GList *prev = g_list_previous(gen_sae_info->animation); - if (prev == NULL) - prev = g_list_last(gen_sae_info->animation); - gen_sae_info->animation = prev; - } - gen_sae_info->anim_tag = 0; -} - -void toolbar_next_frame_clicked_callback(GtkToolButton *toolbutton, gpointer user_data) { - toolbar_pause_clicked_callback(toolbutton, user_data); - GList *next = g_list_next(gen_sae_info->animation); - if (next == NULL) - return; - gen_sae_info->animation = next; - show_sprite(gen_sae_info); -} - -void toolbar_to_last_clicked_callback(GtkToolButton *toolbutton, gpointer user_data) { - toolbar_pause_clicked_callback(toolbutton, user_data); - gen_sae_info->animation = g_list_last(gen_sae_info->animation); - show_sprite(gen_sae_info); -} - -//Dialogs - -void show_about_dialog() { - gtk_dialog_run(GTK_DIALOG(about_dialog)); - gtk_widget_hide(about_dialog); -} - -void show_imageset_dialog() { - if (gen_sae_info->imageset->spriteset == NULL) return; - GtkWidget *dialog = gtk_dialog_new(); - GtkWidget *content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); - gtk_window_set_title(GTK_WINDOW(dialog), _("Imageset preview")); - gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(win)); - - int w = gen_sae_info->imageset->spriteset_width / gen_sae_info->imageset->width; - int h = gen_sae_info->imageset->spriteset_height / gen_sae_info->imageset->height; - - GtkWidget *hbox = NULL; - GtkWidget *image = NULL; - GtkWidget *event_box = NULL; - - int x, y; - for (y = 0; y < h; y++) { - hbox = gtk_hbox_new(TRUE, 2); - gtk_box_pack_start(GTK_BOX(content_area), hbox, TRUE, TRUE, 2); - for (x = 0; x < w; x++) { - unsigned long int id = w * y + x; - event_box = gtk_event_box_new(); - g_signal_connect(G_OBJECT(event_box), "button-press-event", G_CALLBACK(frame_image_button_press_event_callback), (gpointer)id); - gtk_box_pack_start(GTK_BOX(hbox), event_box, TRUE, TRUE, 0); - - image = gtk_image_new_from_pixbuf(get_sprite_by_index(w * y + x, gen_sae_info)); - gtk_widget_add_events(image, GDK_BUTTON_PRESS_MASK); - gtk_container_add(GTK_CONTAINER(event_box), image); - } - } - gtk_widget_show_all(dialog); -} - -//Main functions - -void set_sprite_by_index(size_t idx, SAEInfo *sae_info) { - sae_info->sprite->pixbuf = get_sprite_by_index(idx, sae_info); - gtk_widget_queue_draw(darea); -} - -void set_up_actions_by_imageset_name(gchar *imageset_name, SAEInfo *sae_info) { - free_actions(sae_info); - free_animations(sae_info); - GList *_actions_list = NULL; - GList *list = sae_info->root->sub_nodes; - XMLNode *node = NULL; - while (TRUE) { - list = g_list_find_custom(list, imageset_name, xml_node_compare_with_action_node_by_imageset_name_func); - if (list == NULL) - break; - if (_actions_list == NULL) { - _actions_list = g_list_alloc(); - sae_info->actions = _actions_list; - _actions_list->data = list->data; - } else - _actions_list = g_list_append(_actions_list, list->data); - node = list->data; - if (sae_info->actions_combo_box != NULL) - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(sae_info->actions_combo_box), xml_node_get_attr_value(node, "name")); - list = g_list_next(list); - } - if (sae_info->actions_combo_box != NULL) - gtk_combo_box_set_active(GTK_COMBO_BOX(sae_info->actions_combo_box), 0); -} - -gboolean set_up_imagesets(SAEInfo *sae_info) { - GList *_imagesets_list = NULL; - free_lists(sae_info); - GList *list = sae_info->root->sub_nodes; - XMLNode *node = NULL; - while (TRUE) { - list = g_list_find_custom(list, "imageset", xml_node_compare_with_name_func); - if (list == NULL) - break; - if (_imagesets_list == NULL) { - _imagesets_list = g_list_alloc(); - _imagesets_list->data = list->data; - sae_info->imagesets = _imagesets_list; - } else - _imagesets_list = g_list_append(_imagesets_list, list->data); - node = list->data; - if (sae_info->imagesets_combo_box != NULL) - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(sae_info->imagesets_combo_box), xml_node_get_attr_value(node, "name")); - list = g_list_next(list); - } - if (_imagesets_list == NULL) - return FALSE; - if (sae_info->imagesets_combo_box != NULL) - gtk_combo_box_set_active(GTK_COMBO_BOX(sae_info->imagesets_combo_box), 0); - return TRUE; -} - -void show_sprite(SAEInfo *sae_info) { - Frame *sprite = sae_info->animation->data; - gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(source_view), - gtk_source_buffer_highlight_line(source_buffer, sprite->line_number-1), - 0.25, - FALSE, - 0.0, - 0.0); - sae_info->sprite = sprite; - gtk_widget_queue_draw(darea); -} - -void show_animation(SAEInfo *sae_info) { - kill_timeout(sae_info->anim_tag); - if (sae_info->animation == NULL) - return; - - show_sprite(sae_info); - Frame *sprite = sae_info->animation->data; - - GList *next = g_list_next(sae_info->animation); - if (next == NULL) - next = g_list_first(sae_info->animation); - - if (!sprite->delay) - { - free_animations(sae_info); - return; - } - sae_info->animation = next; - sae_info->anim_tag = g_timeout_add(sprite->delay, (GSourceFunc)show_animation, sae_info); -} - -gboolean show_general_animation(SAEInfo *sae_info) { - XMLNode *node = sae_info->animations->data; - if (node == NULL) - return FALSE; - animations_combo_box_changed_callback(NULL, NULL); - return TRUE; -} - -gboolean set_up_action_by_name(const gchar *name, SAEInfo *sae_info) { - free_animations(sae_info); - GList *list = g_list_find_custom(sae_info->actions, - xml_attr_new("name", name), - (GCompareFunc)xml_node_compare_with_attr_func); - if (list == NULL) return FALSE; - list = ((XMLNode *)list->data)->sub_nodes; - gboolean was_direction = FALSE; - while (TRUE) { - list = g_list_find_custom(list, "animation", xml_node_compare_with_name_func); - if (list == NULL) - break; - if (sae_info->animations == NULL) { - sae_info->animations = g_list_alloc(); - sae_info->animations->data = list->data; - } else - sae_info->animations = g_list_append(sae_info->animations, list->data); - XMLNode *node = list->data; - gchar *direction = xml_node_get_attr_value(node, "direction"); - if (direction != NULL) { - if (sae_info->animations_combo_box != NULL) - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(sae_info->animations_combo_box), direction); - was_direction = TRUE; - } - list = g_list_next(list); - } - if (sae_info->animations == NULL) - return FALSE; - if (!was_direction) - show_general_animation(sae_info); - else if (sae_info->animations_combo_box != NULL) - gtk_combo_box_set_active(GTK_COMBO_BOX(sae_info->animations_combo_box), 0); - return TRUE; -} - -void set_up_imageset_by_name(const gchar *name, SAEInfo *sae_info) { - free_imageset(sae_info); - free_actions(sae_info); - free_animations(sae_info); - - GList *list = g_list_find_custom(sae_info->imagesets, - xml_attr_new("name", name), - (GCompareFunc)xml_node_compare_with_attr_func); - - if (list == NULL) - return; - - XMLNode *node = list->data; - if (node == NULL) - return; - - sae_info->imageset->node = node; - sae_info->imageset->offsetX = 0; - sae_info->imageset->offsetY = 0; - - gchar *offset_attr = xml_node_get_attr_value(sae_info->imageset->node, "offsetX"); - if (offset_attr != NULL) - sscanf(offset_attr, "%d", &sae_info->imageset->offsetX); - - offset_attr = xml_node_get_attr_value(sae_info->imageset->node, "offsetY"); - if (offset_attr != NULL) - sscanf(offset_attr, "%d", &sae_info->imageset->offsetY); - - gchar *imageset_name = xml_node_get_attr_value(sae_info->imageset->node, "name"); - - gchar *src = xml_node_get_attr_value(sae_info->imageset->node, "src"); - format_src_string(src); - gchar *datapath = config->clientdata_folder; - gchar *path = g_strjoin(SEPARATOR_SLASH, datapath, src, NULL); - - sae_info->imageset->spriteset = gdk_pixbuf_new_from_file(path, NULL); - if (sae_info->imageset->spriteset == NULL) { - parsing_error_warning(sae_info, "Wrong spriteset path!"); - return; - } - - gtk_widget_set_sensitive(imageset_preview_menu_item, TRUE); - gtk_widget_set_sensitive(toolbar, TRUE); - sae_info->imageset->spriteset_width = gdk_pixbuf_get_width(sae_info->imageset->spriteset); - sae_info->imageset->spriteset_height = gdk_pixbuf_get_height(sae_info->imageset->spriteset); - - gchar *width = xml_node_get_attr_value(sae_info->imageset->node, "width"); - sscanf(width, "%d", &sae_info->imageset->width); - gchar *height = xml_node_get_attr_value(sae_info->imageset->node, "height"); - sscanf(height, "%d", &sae_info->imageset->height); - - list = g_list_find_custom(sae_info->root->sub_nodes, "sae", xml_node_compare_with_name_func); - if (list != NULL) { - gchar *ground_attr = xml_node_get_attr_value((XMLNode *)list->data, "ground"); - if (ground_attr != NULL) { - ground_attr = g_strjoin(NULL, DIR_GROUNDS, SEPARATOR_SLASH, ground_attr, ".png", NULL); - GdkPixbuf *pbuf = gdk_pixbuf_new_from_file(ground_attr, NULL); - if(pbuf != NULL) - sae_info->ground = pbuf; - } - gchar *player_attr = xml_node_get_attr_value((XMLNode *)list->data, "player"); - if (player_attr != NULL && player == NULL) { - gchar *text; - gchar *sprites_path = paths->sprites; - gchar *player_file = g_strjoin(NULL, sprites_path, DIR_PLAYERS, player_attr, ".xml", NULL); - if (g_file_get_contents(player_file, &text, NULL, NULL)) { - player = sae_info_new(); - parse_xml_text(text, player); - set_up_imageset_by_name("base", player); - } - } - } - set_up_actions_by_imageset_name(imageset_name, sae_info); - if (sae_info->actions == NULL) - return; - set_sprite_by_index(0, sae_info); -} - -void load_options() { - gchar *datapath = config->clientdata_folder; - gchar *path = g_strjoin(SEPARATOR_SLASH, datapath, "paths.xml", NULL); - config_options_load_from_file(paths, path, datapath); -} - -void parse_xml_text(gchar *text, SAEInfo *sae_info) { - GError *error = NULL; - - free_lists(sae_info); - - XMLNode *_root_node = xml_parse_buffer(text, &error); - sae_info->root = _root_node; - if (_root_node == NULL) { - parsing_error_warning(sae_info, error->message); - g_error_free(error); - return; - } - - GList *list = g_list_find_custom(_root_node->sub_nodes, "include", xml_node_compare_with_name_func); - while (list != NULL) { - XMLNode *node = list->data; - gchar *file_attr = xml_node_get_attr_value(node, "file"); - if (file_attr != NULL) { - file_attr = g_strjoin(NULL, paths->sprites, file_attr, NULL); - gchar *buf; - if (g_file_get_contents(file_attr, &buf, NULL, NULL)) - _root_node->sub_nodes = g_list_concat(_root_node->sub_nodes, xml_parse_buffer(buf, &error)->sub_nodes); - } - GList *next = g_list_next(list); - if (next != NULL) - list = g_list_find_custom(next, "include", xml_node_compare_with_name_func); - else - list = NULL; - } - - sae_info->offsetX = 0; - sae_info->offsetY = 0; - - if (error != NULL) - g_error_free(error); - - if (!set_up_imagesets(sae_info)) { - parsing_error_warning(sae_info, "Bad data!"); - return; - } -} - -void parse_xml_buffer(GtkWidget *button, GtkSourceBuffer *buffer) { - if (buffer == NULL) - buffer = source_buffer; - - player = NULL; - load_options(); - - GtkTextIter beg, end; - gtk_text_buffer_get_start_iter(GTK_TEXT_BUFFER(buffer), &beg); - gtk_text_buffer_get_end_iter(GTK_TEXT_BUFFER(buffer), &end); - parse_xml_text(gtk_text_iter_get_text(&beg, &end), gen_sae_info); -} - -void load_config() { - config_keys_load(config); - gtk_file_chooser_select_filename(GTK_FILE_CHOOSER(data_folder_chooser_button), config->clientdata_folder); - gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(show_grid_menu_item), config->show_grid); -} - -void save_config_and_quit() { - config_keys_save(config); - gtk_main_quit(); -} - -int main(int argc, char *argv[]) { - - gtk_init(&argc, &argv); - - icon = gdk_pixbuf_new_from_file(FILE_ICON, NULL); - - gen_sae_info = sae_info_new(); - config = config_keys_new(); - paths = config_options_new(); - - set_up_interface(); - load_config(); - - gtk_main(); - - return 0; -} diff --git a/saedit/main.h b/saedit/main.h deleted file mode 100644 index 27367bd..0000000 --- a/saedit/main.h +++ /dev/null @@ -1,119 +0,0 @@ -/*=======================================*\ -| ____ ____ | -| / \ /\ | | -| \____ / \ |____ | -| \ /____\ | | -| \____/prite / \nimation |____ditor | -| | -| Copyleft Vasily_Makarov 2011 | -| | -\*=======================================*/ - -#ifndef MAIN_H -#define MAIN_H - -#include -#include -#include -#include -#include -#include - -#include "common.h" -#include "xml.h" -#include "config.h" -#include "sae.h" -#include "search.h" - -const int MIN_WIDTH = 600; -const int MIN_HEIGHT = 600; - -const gchar *DIR_GROUNDS = "grounds"; -const gchar *DIR_PLAYERS = "races/"; - -const gchar *FILE_ICON = "icon.svg"; - -const int IMAGESET_PREVIEW_WINDOW_WIDTH = 200; -const int IMAGESET_PREVIEW_WINDOW_HEIGHT = 300; - -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 *imageset_preview_menu_item = NULL; -GtkWidget *show_grid_menu_item = NULL; -GtkWidget *source_view = NULL; -GtkWidget *about_dialog = NULL; -GtkWidget *parsing_error_dialog = NULL; - -GtkSourceBuffer *source_buffer = NULL; - -SAEInfo *gen_sae_info = NULL; -SAEInfo *player = NULL; - -GdkPixbuf *icon = NULL; - -Options *paths; -Keys *config; - -//Cairo functions -cairo_surface_t *get_grid_surface(int w, int h); -gboolean darea_draw_event(GtkWidget *widget, cairo_t *cr, SAEInfo *sae_info); - -//Common functions -gchar *markup_bold(gchar *str); -void format_src_string(gchar *src); -GtkTextIter *gtk_source_buffer_highlight_line(GtkSourceBuffer *buffer, int line_number); - -//File working -void open_xml_file(GtkButton *button); -void save_to_xml_file(gchar *filename); - -//SAEInfo functions -void free_imagesets(SAEInfo *sae_info); -void free_actions(SAEInfo *sae_info); -void free_animations(SAEInfo *sae_info); -void free_imageset(SAEInfo *sae_info); -void free_lists(SAEInfo *sae_info); - -void free_current_info(); - -//Callbacks -void data_folder_set_callback(GtkFileChooserButton *widget, gpointer data); -void parsing_error_warning(SAEInfo *sae_info, const gchar *message); -void show_grid_menu_item_toggled_callback(GtkCheckMenuItem *checkmenuitem, gpointer user_data); -void actions_combo_box_changed_callback(GtkComboBoxText *widget, gpointer user_data); -void imagesets_combo_box_changed_callback(GtkComboBoxText *widget, gpointer user_data); -void animations_combo_box_changed_callback(GtkComboBoxText *widget, gpointer user_data); -void open_menu_item_activate_callback(GtkMenuItem *menuitem, GtkFileChooserDialog *fcdialog); -gboolean frame_image_button_press_event_callback(GtkWidget *widget, GdkEventButton *button, int index); -//>Toolbar callbacks -void toolbar_to_first_clicked_callback(GtkToolButton *toolbutton, gpointer user_data); -void toolbar_prev_frame_clicked_callback(GtkToolButton *toolbutton, gpointer user_data); -void toolbar_play_clicked_callback(GtkToolButton *toolbutton, gpointer user_data); -void toolbar_pause_clicked_callback(GtkToolButton *toolbutton, gpointer user_data); -void toolbar_next_frame_clicked_callback(GtkToolButton *toolbutton, gpointer user_data); -void toolbar_to_last_clicked_callback(GtkToolButton *toolbutton, gpointer user_data); - -//Dialogs -void show_imageset_dialog(); -void show_about_dialog(); - -void set_sprite_by_index(size_t index, SAEInfo *sae_info); -void set_up_actions_by_imageset_name(gchar *imageset_name, SAEInfo *sae_info); -gboolean set_up_imagesets(SAEInfo *sae_info); -gboolean show_general_animation(SAEInfo *sae_info); -gboolean set_up_action_by_name(const gchar *name, SAEInfo *sae_info); -void set_up_imageset_by_name(const gchar* name, SAEInfo *sae_info); -void parse_xml_buffer(GtkWidget *button, GtkSourceBuffer *buffer); -void set_up_interface(); -void load_config(); -void save_config_and_quit(); -void load_options(); -void parse_xml_text(gchar *text, SAEInfo *sae_info); -void show_sprite(SAEInfo *sae_info); -void show_animation(SAEInfo *sae_info); - -#endif diff --git a/saedit/sae.c b/saedit/sae.c deleted file mode 100644 index 70e7c7d..0000000 --- a/saedit/sae.c +++ /dev/null @@ -1,212 +0,0 @@ -/*=======================================*\ -| ____ ____ | -| / \ /\ | | -| \____ / \ |____ | -| \ /____\ | | -| \____/prite / \nimation |____ditor | -| | -| Copyleft Vasily_Makarov 2011 | -| | -\*=======================================*/ - -#include "sae.h" - -void kill_timeout(guint tag) { - if (tag > 0) - g_source_remove(tag); -} - -Frame *frame_new(int index1, int offsetX, int offsetY, int delay) { - Frame *res = g_new0(Frame, 1); - res->index = index1; - res->offsetX = offsetX; - res->offsetY = offsetY; - res->delay = delay; - return res; -} - -Imageset *imageset_new() { - Imageset *res = g_new0(Imageset, 1); - res->width = SPRITE_WIDTH_DEFAULT; - res->height = SPRITE_HEIGHT_DEFAULT; - return res; -} - -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_new(); - return res; -} - -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; -} - -GdkPixbuf* get_sprite_by_index(int index1, SAEInfo *sae_info) { - if (index1 == -1) { - GdkPixbuf *res = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, - sae_info->imageset->width, - sae_info->imageset->height); - gdk_pixbuf_fill(res, 0x00000000); - return res; - } - - if (index1 >= 0) { - size_t w = sae_info->imageset->spriteset_width/sae_info->imageset->width; - if (sae_info->imageset->spriteset == NULL) return NULL; - - return gdk_pixbuf_new_subpixbuf(sae_info->imageset->spriteset, - index1%w*sae_info->imageset->width, - index1/w*sae_info->imageset->height, - sae_info->imageset->width, - sae_info->imageset->height); - } - - return NULL; -} - -inline void _add_frame(SAEInfo *sae_info, int index1, int offsetX, int offsetY, int delay, int line) { - - Frame *sprite = frame_new(index1, offsetX, offsetY, delay); - sprite->line_number = line; - sprite->pixbuf = get_sprite_by_index(index1, sae_info); - - if (sae_info->animation != NULL) - sae_info->animation = g_list_append(sae_info->animation, sprite); - else { - sae_info->animation = g_list_alloc(); - sae_info->animation->data = sprite; - } -} - -gboolean set_up_animation_by_direction(SAEInfo *sae_info, const gchar *direction) { - if (sae_info->imageset->spriteset == NULL) - return FALSE; - sae_info->animation = NULL; - - GList *list = g_list_find_custom(sae_info->animations, - xml_attr_new("direction", direction), - (GCompareFunc)xml_node_compare_with_attr_func); - if (list == NULL) - return FALSE; - - XMLNode *anode = list->data; - list = anode->sub_nodes; - - while (list != NULL) { - XMLNode *node = list->data; - - //sequence tag attributes - int offsetX = 0, offsetY = 0, - delay = 0, - start = -1, end = -1, - repeat = 1; - gchar *value = NULL; - - gchar *ofX_attr, *ofY_attr; - ofX_attr = xml_node_get_attr_value(node, "offsetX"); - if (ofX_attr != NULL) - sscanf(ofX_attr, "%d", &offsetX); - - ofY_attr = xml_node_get_attr_value(node, "offsetY"); - if (ofY_attr != NULL) - sscanf(ofY_attr, "%d", &offsetY); - - gchar *delay_attr = xml_node_get_attr_value(node, "delay"); - if (delay_attr != NULL) - sscanf(delay_attr, "%d", &delay); - - if (g_str_equal(node->name, "frame")) { - - gchar *index_attr = xml_node_get_attr_value(node, "index"); - if (index_attr != NULL) { - sscanf(index_attr, "%d", &start); - end = start; - } - - } else if (g_str_equal(node->name, "sequence")) { - - gchar *start_attr = xml_node_get_attr_value(node, "start"); - if (start_attr != NULL) - sscanf(start_attr, "%d", &start); - - gchar *end_attr = xml_node_get_attr_value(node, "end"); - if (end_attr != NULL) - sscanf(end_attr, "%d", &end); - - value = xml_node_get_attr_value(node, "value"); - - gchar *repeat_attr = xml_node_get_attr_value(node, "repeat"); - if (repeat_attr != NULL) - sscanf(repeat_attr, "%d", &repeat); - - } else if (g_str_equal(node->name, "pause")) { - - value = (gchar *)"p"; - - gchar *repeat_attr = xml_node_get_attr_value(node, "repeat"); - if (repeat_attr != NULL) - sscanf(repeat_attr, "%d", &repeat); - - } - - if (start >= 0) { //start-end case - - int r = 0, i = 0; - for (r = 1; r <= repeat; r++) { - for (i = start; i <= end; i++) { - _add_frame(sae_info, i, offsetX, offsetY, delay, node->line_number); - } - } - - } else - if (value != NULL) { //value case - - gchar **values = g_strsplit(value, ",", 0); - - int r; - for (r = 0; r < repeat; r++) { //TODO: remove multiparsing - gchar **iter = values; - while (*iter != NULL) { - - if (g_str_equal(*iter, "p")) { //pause - - _add_frame(sae_info, -1, 0, 0, delay, node->line_number); - - } else { - - unsigned f, s; - - if (sscanf(*iter, "%u-%u", &f, &s) == 2) { - - int i; - for (i = f; i <= s; i++) { - _add_frame(sae_info, i, offsetX, offsetY, delay, node->line_number); - } - - } else if (sscanf(*iter, "%u", &f) == 1) { - - _add_frame(sae_info, f, offsetX, offsetY, delay, node->line_number); - - } - - } - iter++; - } - } - - g_strfreev(values); - - } - - list = g_list_next(list); - } - if (sae_info->animation == NULL) - return FALSE; - - return TRUE; -} diff --git a/saedit/sae.h b/saedit/sae.h deleted file mode 100644 index 51f45c1..0000000 --- a/saedit/sae.h +++ /dev/null @@ -1,69 +0,0 @@ -/*=======================================*\ -| ____ ____ | -| / \ /\ | | -| \____ / \ |____ | -| \ /____\ | | -| \____/prite / \nimation |____ditor | -| | -| Copyleft Vasily_Makarov 2011 | -| | -\*=======================================*/ - -#ifndef SAE_H -#define SAE_H - -#include -#include "common.h" -#include "xml.h" - -void kill_timeout(guint tag); - -typedef struct { - int index; - int offsetX; - int offsetY; - int delay; - int line_number; - GdkPixbuf *pixbuf; - cairo_surface_t *surface; -} Frame; - -Frame *frame_new(int index, int offsetX, int offsetY, int delay); - -typedef struct { - XMLNode *node; - int offsetX; - int offsetY; - int width; - int height; - int spriteset_width; - int spriteset_height; - GdkPixbuf *spriteset; -} Imageset; - -Imageset *imageset_new(); - -typedef struct { - GList *imagesets; - GList *actions; - GList *animations; - GList *animation; - Imageset *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; - -SAEInfo *sae_info_new(); -GdkPixbuf *sae_info_ground_new(); - -GdkPixbuf* get_sprite_by_index(int index, SAEInfo *sae_info); -gboolean set_up_animation_by_direction(SAEInfo *sae_info, const gchar *direction); - -#endif diff --git a/saedit/search.c b/saedit/search.c deleted file mode 100644 index df2970e..0000000 --- a/saedit/search.c +++ /dev/null @@ -1,74 +0,0 @@ -/*=======================================*\ -| ____ ____ | -| / \ /\ | | -| \____ / \ |____ | -| \ /____\ | | -| \____/prite / \nimation |____ditor | -| | -| Copyleft Vasily_Makarov 2011 | -| | -\*=======================================*/ - -#include "search.h" - -GtkWidget *search_text_view = NULL; -gchar *search_last_text = NULL; - -gboolean search_find_text(gchar *text) { - search_last_text = text; - - GtkTextBuffer *text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(search_text_view)); - if (!GTK_IS_TEXT_BUFFER(text_buffer)) - return FALSE; - - gboolean found; - - GtkTextIter m_start, m_end, start; - gtk_text_buffer_get_selection_bounds(text_buffer, NULL, &start); - found = gtk_text_iter_forward_search(&start, text, 4, &m_start, &m_end, NULL); - - if (!found) { - gtk_text_buffer_get_start_iter(text_buffer, &start); - found = gtk_text_iter_forward_search(&start, text, 4, &m_start, &m_end, NULL); - } - - if (found) { - gtk_text_buffer_place_cursor(text_buffer, &m_start); - gtk_text_buffer_move_mark_by_name(text_buffer, "selection_bound", &m_end); - gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW(search_text_view), - gtk_text_buffer_get_insert(text_buffer), - 0.25, - FALSE, - 0.0, - 0.0); - return TRUE; - } else - return FALSE; -} - -gboolean search_find_next() { - if (search_last_text != NULL) - search_find_text(search_last_text); - // here must return some thing -} - -void search_find_dialog_response_callback(GtkWidget *dialog, - gint response_id, - gpointer entry) { - - if (response_id == GTK_RESPONSE_CANCEL || response_id == GTK_RESPONSE_DELETE_EVENT) - gtk_widget_hide(dialog); - else { - - g_return_if_fail(response_id == GTK_RESPONSE_ACCEPT); - g_return_if_fail(GTK_IS_TEXT_VIEW(search_text_view)); - g_return_if_fail(GTK_IS_ENTRY(GTK_ENTRY(entry))); - - search_find_text(g_strdup(gtk_entry_get_text(GTK_ENTRY(entry)))); - - } -} - -void search_init(GtkWidget *text_view) { - search_text_view = text_view; -} diff --git a/saedit/search.h b/saedit/search.h deleted file mode 100644 index faf412e..0000000 --- a/saedit/search.h +++ /dev/null @@ -1,26 +0,0 @@ -/*=======================================*\ -| ____ ____ | -| / \ /\ | | -| \____ / \ |____ | -| \ /____\ | | -| \____/prite / \nimation |____ditor | -| | -| Copyleft Vasily_Makarov 2011 | -| | -\*=======================================*/ - -#ifndef SEARCH_H -#define SEARCH_H - -#include -#include -#include "common.h" - -void search_init(GtkWidget *text_view); -gboolean search_find_text(gchar *text); -gboolean search_find_next(); -void search_find_dialog_response_callback(GtkWidget *dialog, - gint response_id, - gpointer entry); - -#endif diff --git a/saedit/template.xml b/saedit/template.xml deleted file mode 100644 index 3747c31..0000000 --- a/saedit/template.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - diff --git a/saedit/valg b/saedit/valg deleted file mode 100755 index 8726b81..0000000 --- a/saedit/valg +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -valgrind --read-var-info=yes --track-origins=yes --malloc-fill=11 --free-fill=55 --show-reachable=yes --leak-check=full --leak-resolution=high --partial-loads-ok=yes --error-limit=no --num-callers=30 "./saedit" 2>./valg.log diff --git a/saedit/xml.c b/saedit/xml.c deleted file mode 100644 index eefc536..0000000 --- a/saedit/xml.c +++ /dev/null @@ -1,316 +0,0 @@ -/*=======================================*\ -| ____ ____ | -| / \ /\ | | -| \____ / \ |____ | -| \ /____\ | | -| \____/prite / \nimation |____ditor | -| | -| Copyleft Vasily_Makarov 2011 | -| | -\*=======================================*/ - -#include "xml.h" - -gchar** xml_attr_new(const gchar *name, const gchar *value) { - gchar **attr = g_new0(gchar*, 2); - attr[0] = g_strdup(name); - attr[1] = g_strdup(value); - return attr; -} - -gchar* xml_node_get_attr_value(const XMLNode *node, const gchar *attr_name) { - gchar **attr = node->attributes; - guint i; - for (i = 0; i < g_strv_length(attr); i += 2) - if (g_str_equal(attr[i], attr_name)) - return attr[i + 1]; - return NULL; -} - - -gint xml_node_compare_with_name_func(gconstpointer a, gconstpointer b) { - return g_strcmp0((gchar *)b, ((XMLNode *)a)->name); -} - -gint xml_node_compare_with_action_node_by_imageset_name_func(gconstpointer a, gconstpointer b) { - return g_strcmp0("action", ((XMLNode *)a)->name) || - g_strcmp0((gchar *)b, xml_node_get_attr_value((XMLNode *)a, "imageset")); -} - -gint xml_node_compare_with_attr_func(const XMLNode *node, const gchar **attr) { - return g_strcmp0(attr[1], - xml_node_get_attr_value(node, attr[0])); -} - -static GMarkupParser parser; - -void xml_free (XMLNode *node) { - g_free (node->name); - - g_free (node->text); - - g_strfreev (node->attributes); - - g_list_foreach (node->sub_nodes, (GFunc) xml_free, NULL); - g_list_free (node->sub_nodes); - - g_slice_free (XMLNode, node); -} - -static void _start_root_element_cb ( GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, - gpointer user_data, - GError **error) { - XMLNode **node = (XMLNode **) user_data; - g_assert (node != NULL); - - XMLNode *p = g_slice_new0 (XMLNode); - - - p->name = g_strdup (element_name); - - GArray *attributes = g_array_new (TRUE, TRUE, sizeof (gchar *)); - while (*attribute_names != NULL && *attribute_values != NULL) { - gchar *p2; - p2 = g_strdup (*attribute_names++); - g_array_append_val (attributes, p2); - p2 = g_strdup (*attribute_values++); - g_array_append_val (attributes, p2); - } - - p->attributes = (gchar **) g_array_free (attributes, FALSE); - - g_markup_parse_context_push (context, &parser, p); - *node = p; -} - - -static void _start_element_cb ( GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, - gpointer user_data, - GError **error) { - - XMLNode *node = (XMLNode *) user_data; - - if (node->text) { - g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, " "); - return; - } - - XMLNode *p = g_slice_new0 (XMLNode); - - node->sub_nodes = g_list_append (node->sub_nodes, p); - g_markup_parse_context_push (context, &parser, p); - - p->name = g_strdup (element_name); - - GArray *attributes = g_array_new (TRUE, TRUE, sizeof (gchar *)); - while (*attribute_names != NULL && *attribute_values != NULL) { - gchar *p2; - p2 = g_strdup (*attribute_names++); - g_array_append_val (attributes, p2); - p2 = g_strdup (*attribute_values++); - g_array_append_val (attributes, p2); - } - - p->attributes = (gchar **)g_array_free (attributes, FALSE); - - gint char_n, line_n; - g_markup_parse_context_get_position(context, &line_n, &char_n); - p->line_number = line_n - (char_n <= 1 ? 1 : 0); -} - -static void _end_element_cb ( GMarkupParseContext *context, - const gchar *element_name, - gpointer user_data, - GError **error) { - XMLNode *p = (XMLNode *) g_markup_parse_context_pop (context); - - if (p->text && p->sub_nodes) { - g_warning ("Error"); - } - - if (p->text == NULL && p->sub_nodes == NULL) { - p->text = g_strdup (""); - } -} - -static gboolean _is_space ( const gchar *text, - gsize text_len) { - gsize i = 0; - - for (i = 0; text[i] != '\0' && i < text_len; i++) { - switch (text[i]) { - case '\t': - case ' ': - case '\n': - case '\r': - continue; - default: - return FALSE; - } - } - - return TRUE; -} - -static void _text_cb ( GMarkupParseContext *context, - const gchar *text, - gsize text_len, - gpointer user_data, - GError **error) { - XMLNode *p = (XMLNode *)user_data; - - if (_is_space (text, text_len)) { - return; - } - - if (p->sub_nodes || p->text) { - g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, " "); - return; - } - - p->text = g_strndup (text, text_len); -} - -static GMarkupParser parser = { - _start_element_cb, - _end_element_cb, - _text_cb, - 0, - 0, -}; - -XMLNode *xml_parse_file (const gchar *filename) { - gboolean retval = FALSE; - GError *error = NULL; - FILE *pf = fopen (filename, "r"); - - if (pf == NULL) { - return NULL; - } - - GMarkupParseContext *context; - XMLNode *node; - - static const GMarkupParser root_parser = { - _start_root_element_cb, - _end_element_cb, - _text_cb, - 0, - 0, - }; - - do { - context = g_markup_parse_context_new (&root_parser, 0, &node, 0); - - while (!feof (pf)) { - gchar buf[1024]; - gssize len = 0; - - len = fread (buf, 1, sizeof (buf), pf); - retval = g_markup_parse_context_parse (context, buf, len, &error); - - if (!retval) - break; - } - fclose (pf); - - if (!retval) - break; - - retval = g_markup_parse_context_end_parse (context, &error); - if (!retval) - break; - - g_markup_parse_context_free (context); - - return node; - } while (0); - - g_warning ("Parse %s failed: %s", filename, error->message); - g_error_free (error); - g_markup_parse_context_free (context); - return NULL; -} - -XMLNode *xml_parse_buffer (const gchar *buffer, GError **error) { - gboolean retval; - - GMarkupParseContext *context; - XMLNode *node; - - static const GMarkupParser root_parser = { - _start_root_element_cb, - _end_element_cb, - _text_cb, - 0, - 0, - }; - - context = g_markup_parse_context_new (&root_parser, 0, &node, 0); - - do { - retval = g_markup_parse_context_parse (context, buffer, strlen (buffer), error); - if (!retval) - break; - - retval = g_markup_parse_context_end_parse (context, error); - if (!retval) - break; - g_markup_parse_context_free (context); - return node; - } while (0); - - //g_warning ("Parse buffer failed: %s", (*error)->message); - g_markup_parse_context_free (context); - return NULL; -} - - -static void output_indent (int level, GString *output) { - gint i; - for (i = 0; i < level; i++) { - g_string_append (output, " "); - } -} - -static void xml_output_indent (const XMLNode *node, int level, GString *output) { - gchar **attrs; - - output_indent (level, output); - g_string_append_printf (output, "<%s", node->name); - - attrs = node->attributes; - - while (attrs != NULL && *attrs != NULL) { - g_string_append_printf (output, " %s", *(attrs++)); - g_string_append_printf (output, "=\"%s\"", *(attrs++)); - } - - if (node->sub_nodes != NULL) { - g_string_append (output, ">\n"); - GList *sub_node; - - for (sub_node = node->sub_nodes; sub_node != NULL; sub_node = sub_node->next) { - xml_output_indent (sub_node->data, level + 1, output); - } - output_indent (level, output); - g_string_append_printf (output, "\n",node->name); - } else if (node->text != NULL) { - gchar *text = g_markup_escape_text (node->text, -1); - g_string_append_printf (output, ">%s\n", text, node->name); - g_free (text); - } else { - g_string_append (output, "/>\n"); - } -} - -void xml_output (const XMLNode *node, GString *output) { - xml_output_indent (node, 0, output); -} - diff --git a/saedit/xml.h b/saedit/xml.h deleted file mode 100644 index 584c568..0000000 --- a/saedit/xml.h +++ /dev/null @@ -1,42 +0,0 @@ -/*=======================================*\ -| ____ ____ | -| / \ /\ | | -| \____ / \ |____ | -| \ /____\ | | -| \____/prite / \nimation |____ditor | -| | -| Copyleft Vasily_Makarov 2011 | -| | -\*=======================================*/ -#ifndef XML_H -#define XML_H - -#include -#include -#include "common.h" - -typedef struct { - gchar *name; - gchar *text; - gchar **attributes; - int line_number; - GList *sub_nodes; -} XMLNode; - - -XMLNode *xml_parse_file (const gchar *name); - -XMLNode *xml_parse_buffer (const gchar *buffer, GError **error); - -void xml_free (XMLNode *node); - -void xml_output (const XMLNode *node, - GString *output); - -gchar **xml_attr_new(const gchar *name, const gchar *value); -gchar *xml_node_get_attr_value(const XMLNode *node, const gchar *attr_name); -gint xml_node_compare_with_name_func(gconstpointer a, gconstpointer b); -gint xml_node_compare_with_action_node_by_imageset_name_func(gconstpointer a, gconstpointer b); -gint xml_node_compare_with_attr_func(const XMLNode *node, const gchar **attr); - -#endif -- cgit v1.2.3-60-g2f50