From 429d6a83ef36acb08b49760d1e647f2928d6514d Mon Sep 17 00:00:00 2001 From: David Capello Date: Fri, 16 Nov 2007 20:49:40 +0000 Subject: [PATCH] Renamed "frame" to "cel" --- ChangeLog | 7 + README-es.txt | 31 +--- README.txt | 27 +-- TODO.txt | 6 +- all.h | 2 +- config.h | 2 +- data/gui-en.xml | 26 +-- data/gui-es.xml | 211 ---------------------- docs/files/ase.txt | 50 +++--- makefile.lst | 6 +- src/commands/cmd_copy_frame.c | 4 +- src/commands/cmd_crop.c | 8 +- src/commands/cmd_frame_properties.c | 53 +++--- src/commands/cmd_link_frame.c | 4 +- src/commands/cmd_merge_down_layer.c | 52 +++--- src/commands/cmd_move_frame.c | 4 +- src/commands/cmd_new_frame.c | 20 +-- src/commands/cmd_new_layer.c | 1 + src/commands/cmd_new_layer_set.c | 1 + src/commands/cmd_preview.c | 2 +- src/commands/cmd_record_screen.c | 12 +- src/commands/cmd_remove_frame.c | 12 +- src/commands/cmd_remove_layer.c | 1 + src/commands/commands.c | 44 ++--- src/commands/commands.h | 16 +- src/core/modules.c | 2 - src/dialogs/filmedit.c | 184 ++++++++++--------- src/dialogs/quick.c | 2 +- src/file/ase.c | 270 ++++++++++++++-------------- src/file/file.c | 36 ++-- src/file/fli.c | 4 +- src/file/gif.c | 24 +-- src/file/tga.c | 2 +- src/modules/editors.c | 4 +- src/modules/gui.c | 2 +- src/modules/tools2.c | 26 +-- src/raster/cel.c | 97 ++++++++++ src/raster/{frame.h => cel.h} | 24 +-- src/raster/frame.c | 97 ---------- src/raster/gfxobj.h | 2 +- src/raster/image.h | 23 +-- src/raster/layer.c | 132 +++++++------- src/raster/layer.h | 10 +- src/raster/raster.h | 2 +- src/raster/sprite.c | 4 +- src/raster/undo.c | 122 ++++++------- src/raster/undo.h | 6 +- src/script/bindings.c | 26 +-- src/script/export.h | 42 ++--- src/script/functions.c | 50 +++--- src/script/functions.h | 6 +- src/script/genbinds.c | 174 +++++++++--------- src/script/import.h | 2 +- src/util/celmove.c | 148 +++++++++++++++ src/util/{frmove.h => celmove.h} | 19 +- src/util/clipbrd.c | 18 +- src/util/crop.c | 70 ++++---- src/util/crop.h | 2 +- src/util/frmove.c | 148 --------------- src/util/misc.c | 109 ++++++----- src/util/recscr.c | 37 ++-- src/{modules => util}/render.c | 75 ++++---- src/{modules => util}/render.h | 19 +- src/util/setgfx.h | 2 +- src/util/thmbnail.c | 76 ++++---- src/util/thmbnail.h | 8 +- src/widgets/editor/editor.c | 2 +- src/widgets/preview.c | 40 ++--- src/widgets/statebar.c | 30 ++-- 69 files changed, 1285 insertions(+), 1495 deletions(-) delete mode 100644 data/gui-es.xml create mode 100644 src/raster/cel.c rename src/raster/{frame.h => cel.h} (69%) delete mode 100644 src/raster/frame.c create mode 100644 src/util/celmove.c rename src/util/{frmove.h => celmove.h} (76%) delete mode 100644 src/util/frmove.c rename src/{modules => util}/render.c (90%) rename src/{modules => util}/render.h (70%) diff --git a/ChangeLog b/ChangeLog index b7bef9bdc..0e04e319f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-11-16 David A. Capello + + * src/raster/cel.c: Renamed "frame" to "cel" to avoid + confusion (Manuel Quiñones advice) + + * src/modules/render.[ch]: Moved to util/. + 2007-11-14 David A. Capello * INSTALL.txt: Clarified "COMPILATION" section (thanks to Manuel diff --git a/README-es.txt b/README-es.txt index 230dfe68f..cffb5a78d 100644 --- a/README-es.txt +++ b/README-es.txt @@ -1,7 +1,7 @@ ASE - Allegro Sprite Editor - Copyright (C) 2001-2005, 2007 por David A. Capello - ------------------------------------------------------------------------ + Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007 por David A. Capello + --------------------------------------------------------------------- Mire el fichero "AUTHORS.txt" para la lista completa de colaboradores @@ -125,33 +125,20 @@ ACTUALIZACIONES http://sourceforge.net/project/showfiles.php?group_id=20848 También, si desea obtener la última versión en desarrollo de ASE desde el - repositorio CVS, la cual por sierto es la más propensa a tener errores pero + repositorio SVN, la cual por sierto es la más propensa a tener errores pero es la que más actualizada está con respecto a las herramientas, la puede explorar archivo por archivo en esta dirección: - http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/ase + http://ase.svn.sourceforge.net/viewvc/ase/ - O la puede bajar completamente a su disco con un programa que controle CVS, + O la puede bajar completamente a su disco con un programa que controle SVN, de la siguiente forma: - 1) Debemos ingresar al repositorio de forma anónima (cuando le pregunte - por la contraseña, solamente presione ): + svn checkout svn co https://ase.svn.sourceforge.net/svnroot/ase/trunk ase - cvs -d :pserver:anonymous@cvs.ase.sourceforge.net:/cvsroot/ase login - - 2) Realizamos el primer checkout, lo que significa que sacaremos una - copia "fresca" de ASE: - - cvs -z3 -d :pserver:anonymous@cvs.ase.sourceforge.net:/cvsroot/ase checkout gnuase - - 3) Una vez esto, cada vez que quiera actualizar la copia local con la - del repositorio, deberá ejecutar en el directorio gnuase/: - - cvs update -Pd - - AVISO: Cuando obtenga la versión CVS, no borre los directorios CVS + AVISO: Cuando obtenga la versión SVN, no borre los directorios .svn ni el contenido dentro de ellos, ya que es para uso interno del - programa cvs. + programa svn. =================================== @@ -177,4 +164,4 @@ INFORMACI ---------------------------------------------------------------------------- - Copyright (C) 2001-2005 por David A. Capello + Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007 por David A. Capello diff --git a/README.txt b/README.txt index 7446e5e7b..82d6c199d 100644 --- a/README.txt +++ b/README.txt @@ -1,7 +1,7 @@ ASE - Allegro Sprite Editor - Copyright (C) 2001-2005, 2007 by David A. Capello - -------------------------------------------------------------- + Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007 by David A. Capello + -------------------------------------------------------------------- See the "AUTHORS.txt" file for a complete list of contributors @@ -126,25 +126,12 @@ UPDATES http://ase.svn.sourceforge.net/viewvc/ase/ Or you can download it completelly to your disk with a program which - control CVS, as follow-up: + control SVN, as follow-up: - 1) We must input to the repository in anonymous form (when you be - asked for the password, just press ): + svn checkout svn co https://ase.svn.sourceforge.net/svnroot/ase/trunk ase - cvs -d :pserver:anonymous@cvs.ase.sourceforge.net:/cvsroot/ase login - - 2) We make the first checkout, which means that we fetch a "fresh" - copy of ASE: - - cvs -z3 -d :pserver:anonymous@cvs.ase.sourceforge.net:/cvsroot/ase checkout gnuase - - 3) Then, whenever you want update your copy with the repository - one, you will must execute in the gnuase/ directory: - - cvs update -Pd - - WARNING: When you obtain the CVS version, don't remove the CVS - directories, they are for exclusive use of the cvs program. + WARNING: When you obtain the SVN version, don't remove the .svn + directories, they are for exclusive use of the svn program. =================================== @@ -170,4 +157,4 @@ CONTACT INFO ---------------------------------------------------------------------------- - Copyright (C) 2001-2005 by David A. Capello + Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007 by David A. Capello diff --git a/TODO.txt b/TODO.txt index 883ee3464..a9ebb61c5 100644 --- a/TODO.txt +++ b/TODO.txt @@ -45,13 +45,17 @@ High priority work Wish-list --------- -- my wish-list: +- dacap wish-list: + keyboard shortcuts for snap-to-grid and view-grid + different snap-to-grid for paste operation + better dialogs: widder buttons, more borders. + better film editor + "middle mouse button" for the film editor. + don't use LINKs when load a sequence of bitmaps. +- manuq wish-list: + + sprite/layer/frame/cel (distintion between "frame" and "cel") + + layer-with-constant-cel + + onion skin for all layers in a frame - add menu customization through UI (Tools/Customize). - Mateusz Czaplinski ideas: + when move selections, will be good the possibility to see relative diff --git a/all.h b/all.h index 901c6ee9b..1022b3137 100644 --- a/all.h +++ b/all.h @@ -80,7 +80,6 @@ #include "modules/gui.h" #include "modules/palette.h" #include "modules/recent.h" -#include "modules/render.h" #include "modules/rootmenu.h" #include "modules/sprites.h" #include "modules/tools.h" @@ -120,6 +119,7 @@ #include "util/pic_file.h" #include "util/quantize.h" #include "util/recscr.h" +#include "util/render.h" #include "util/scrshot.h" #include "util/setgfx.h" #include "util/thmbnail.h" diff --git a/config.h b/config.h index 56d2434a3..e1f7addc6 100644 --- a/config.h +++ b/config.h @@ -25,7 +25,7 @@ /* general information */ #define PACKAGE "ase" #define VERSION "0.6" -#define WEBSITE "http://ase.sourceforge.net/" +#define WEBSITE "http://www.allegrospriteeditor.com.ar/" #define BUGREPORT "ase-help@lists.sourceforge.net" #define COPYRIGHT "Copyright (C) 2001-2005, 2007 David A. Capello" diff --git a/data/gui-en.xml b/data/gui-en.xml index b6747beb6..56b68b251 100644 --- a/data/gui-en.xml +++ b/data/gui-en.xml @@ -40,9 +40,9 @@ - - - + + + @@ -122,7 +122,7 @@ - + @@ -143,18 +143,18 @@ - - - + + + - - - - + + + + - + - + diff --git a/data/gui-es.xml b/data/gui-es.xml deleted file mode 100644 index 02dfe5cb5..000000000 --- a/data/gui-es.xml +++ /dev/null @@ -1,211 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/docs/files/ase.txt b/docs/files/ase.txt index 80a946a62..5c08ba114 100644 --- a/docs/files/ase.txt +++ b/docs/files/ase.txt @@ -31,14 +31,24 @@ STRING length=WORD (how many characters to read next) 2. Introduction ======================================== -The format is the same as FLI/FLC files, with a different magic number -and a different set of chunks (but the new chunks doesn't collided -with the FLI/FLC ones). Also, the color depth can be 8, 16 or 32 for -Indexed, Grayscale and RGB respectively. The palette isn't included -for color depths more than 8, but when the sprite is 8 bpp, the -palette is in an old FLI color chunk (type=11). See fli.txt for +The format is much like FLI/FLC files, but with different magic number +and differents chunks. Also, the color depth can be 8, 16 or 32 for +Indexed, Grayscale and RGB respectively, and the images are more easy +to read (there aren't differences with old frames). The palette isn't +included for color depths more than 8, but when the sprite is 8 bpp, +the palette is in an old FLI color chunk (type=11). See fli.txt for details. +To read the sprite, just do this: +* Read the ASE header (section 3) +* For each frame do (how many frames? the ASE header has that + information): + + Read the frame header (section 4) + + For each chunk in this frame (how many chunks? the frame header + has that information) + - Read the chunk (it should be layer information, a cel or a + palette) + ======================================== 3. Header @@ -55,8 +65,8 @@ WORD Height in pixels WORD Color depth (bits per pixel) DWORD Flags (must be 0) WORD Speed (milliseconds between frame, like in FLC files) - !!! This field is deprecated, you should use the - frame duration field from each frame header. + DEPRECATED!!!: you should use the frame duration + field from each frame header DWORD Set be 0 DWORD Set be 0 BYTE[100] For future (set to zero) @@ -71,8 +81,8 @@ header of 16 bytes: DWORD Bytes in this frame WORD Magic number (always 0xF1FA) - WORD Number of "chunks" in frame - WORD Frame duration (in milliseconds) [NEW FIELD!!!] + WORD Number of "chunks" in this frame + WORD Frame duration (in milliseconds) [NEW FIELD!!!] BYTE[6] For future (set to zero) Then each chunk format is: @@ -120,37 +130,37 @@ Layer Chunk (0x2004) STRING Layer name -Frame Chunk (0x2005) +Cel Chunk (0x2005) ---------------------------------------- - This chunk determine where to put a real ASE frame in the specified - layer. + This chunk determine where to put a cel in the specified + layer/frame. WORD Layer index (see NOTE.2) WORD X position WORD Y position BYTE Opacity level - WORD Frame type + WORD Cel type BYTE[7] For future (set to zero) - + For frame type = 0 (raw image): + + For cel type = 0 (Raw Cel): WORD Width in pixels WORD Height in pixels BYTE[] Pixel data (see NOTE.3) - + For frame type = 1 (linked image): + + For cel type = 1 (Linked Cel): WORD Frame position to link with - + For frame type = 2 (RLE compressed image, only for Indexed images): + + For cel type = 2 (RLE compressed image, only for Indexed images): WORD Width in pixels WORD Height in pixels XXXXX -todo- -Mask Chunk (0x2016) +Mask Chunk (0x2016) DEPRECATED!!! ---------------------------------------- WORD X position @@ -213,5 +223,5 @@ File Format Changes How to read both formats (old and new one)? You should set all frames durations to the "speed" field read from the main ASE header. Then, if you found a frame with the frame-duration - field > 0, you should update the frame's duration with that - value. + field > 0, you should update the duration of the frame with + that value. diff --git a/makefile.lst b/makefile.lst index 8aa224c80..36341ba10 100644 --- a/makefile.lst +++ b/makefile.lst @@ -119,7 +119,6 @@ ASE_SOURCES = \ src/modules/gui.c \ src/modules/palette.c \ src/modules/recent.c \ - src/modules/render.c \ src/modules/rootmenu.c \ src/modules/sprites.c \ src/modules/tools.c \ @@ -128,8 +127,8 @@ ASE_SOURCES = \ src/raster/algofill.c \ src/raster/blend.c \ src/raster/brush.c \ + src/raster/cel.c \ src/raster/dirty.c \ - src/raster/frame.c \ src/raster/gfxobj.c \ src/raster/image.c \ src/raster/layer.c \ @@ -145,11 +144,11 @@ ASE_SOURCES = \ src/script/script.c \ src/util/autocrop.c \ src/util/boundary.c \ + src/util/celmove.c \ src/util/clipbrd.c \ src/util/col_file.c \ src/util/crop.c \ src/util/filetoks.c \ - src/util/frmove.c \ src/util/hash.c \ src/util/mapgen.c \ src/util/misc.c \ @@ -157,6 +156,7 @@ ASE_SOURCES = \ src/util/pic_file.c \ src/util/quantize.c \ src/util/recscr.c \ + src/util/render.c \ src/util/setgfx.c \ src/util/thmbnail.c \ src/widgets/colbar.c \ diff --git a/src/commands/cmd_copy_frame.c b/src/commands/cmd_copy_frame.c index 47bc263e3..5edd02e9c 100644 --- a/src/commands/cmd_copy_frame.c +++ b/src/commands/cmd_copy_frame.c @@ -28,11 +28,11 @@ #endif -bool command_enabled_copy_frame(const char *argument) +bool command_enabled_copy_cel(const char *argument) { return FALSE; } -void command_execute_copy_frame(const char *argument) +void command_execute_copy_cel(const char *argument) { } diff --git a/src/commands/cmd_crop.c b/src/commands/cmd_crop.c index 60cb89648..be96ca94c 100644 --- a/src/commands/cmd_crop.c +++ b/src/commands/cmd_crop.c @@ -76,17 +76,17 @@ void command_execute_crop_layer(const char *argument) } /* ======================== */ -/* crop_frame */ +/* crop_cel */ /* ======================== */ -bool command_enabled_crop_frame(const char *argument) +bool command_enabled_crop_cel(const char *argument) { return command_enabled_crop(argument); } -void command_execute_crop_frame(const char *argument) +void command_execute_crop_cel(const char *argument) { - crop_frame(); + crop_cel(); } /**********************************************************************/ diff --git a/src/commands/cmd_frame_properties.c b/src/commands/cmd_frame_properties.c index 479119ea0..31d364087 100644 --- a/src/commands/cmd_frame_properties.c +++ b/src/commands/cmd_frame_properties.c @@ -25,24 +25,24 @@ #include "core/app.h" #include "modules/gui.h" #include "modules/sprites.h" -#include "raster/frame.h" +#include "raster/cel.h" #include "raster/layer.h" #include "raster/sprite.h" #include "raster/undo.h" #endif -bool command_enabled_frame_properties(const char *argument) +bool command_enabled_cel_properties(const char *argument) { return current_sprite != NULL; } -void command_execute_frame_properties(const char *argument) +void command_execute_cel_properties(const char *argument) { JWidget window, entry_frpos, entry_xpos, entry_ypos, slider_opacity, button_ok; Sprite *sprite; Layer *layer; - Frame *frame; + Cel *cel; char buf[1024]; /* get current sprite */ @@ -55,9 +55,9 @@ void command_execute_frame_properties(const char *argument) if (!layer) return; - /* get current frame */ - frame = layer_get_frame(layer, sprite->frpos); - if (!frame) + /* get current cel */ + cel = layer_get_cel(layer, sprite->frpos); + if (!cel) return; window = load_widget("frmprop.jid", "frame_properties"); @@ -70,53 +70,54 @@ void command_execute_frame_properties(const char *argument) slider_opacity = jwidget_find_name(window, "opacity"); button_ok = jwidget_find_name(window, "ok"); - sprintf(buf, "%d", frame->frpos); jwidget_set_text(entry_frpos, buf); - sprintf(buf, "%d", frame->x); jwidget_set_text(entry_xpos, buf); - sprintf(buf, "%d", frame->y); jwidget_set_text(entry_ypos, buf); - jslider_set_value(slider_opacity, frame->opacity); + sprintf(buf, "%d", cel->frpos); jwidget_set_text(entry_frpos, buf); + sprintf(buf, "%d", cel->x); jwidget_set_text(entry_xpos, buf); + sprintf(buf, "%d", cel->y); jwidget_set_text(entry_ypos, buf); + jslider_set_value(slider_opacity, cel->opacity); while (TRUE) { jwindow_open_fg(window); if (jwindow_get_killer(window) == button_ok) { int new_frpos, new_xpos, new_ypos; - Frame *existent_frame; + Cel *existent_cel; new_frpos = strtol(jwidget_get_text(entry_frpos), NULL, 10); new_frpos = MID(0, new_frpos, sprite->frames-1); - existent_frame = layer_get_frame(layer, new_frpos); + existent_cel = layer_get_cel(layer, new_frpos); - if (new_frpos != frame->frpos && existent_frame) { - jalert("Error<frpos && existent_cel) { + jalert(_("Error" + "<undo)) { undo_open(sprite->undo); - undo_remove_frame(sprite->undo, layer, frame); + undo_remove_cel(sprite->undo, layer, cel); } - layer_remove_frame(layer, frame); + layer_remove_cel(layer, cel); /* change frame properties */ new_xpos = strtol(jwidget_get_text(entry_xpos), NULL, 10); new_ypos = strtol(jwidget_get_text(entry_ypos), NULL, 10); - frame_set_frpos(frame, new_frpos); - frame_set_position(frame, - MID(-9999, new_xpos, 9999), - MID(-9999, new_ypos, 9999)); - frame_set_opacity(frame, jslider_get_value(slider_opacity)); + cel_set_frpos(cel, new_frpos); + cel_set_position(cel, + MID(-9999, new_xpos, 9999), + MID(-9999, new_ypos, 9999)); + cel_set_opacity(cel, jslider_get_value(slider_opacity)); /* add again the same frame */ if (undo_is_enabled(sprite->undo)) { - undo_add_frame(sprite->undo, layer, frame); + undo_add_cel(sprite->undo, layer, cel); undo_close(sprite->undo); } - layer_add_frame(layer, frame); + layer_add_cel(layer, cel); /* set the sprite position, refresh and break the loop */ sprite_set_frpos(sprite, new_frpos); diff --git a/src/commands/cmd_link_frame.c b/src/commands/cmd_link_frame.c index 2b964e91f..5e390ef02 100644 --- a/src/commands/cmd_link_frame.c +++ b/src/commands/cmd_link_frame.c @@ -28,11 +28,11 @@ #endif -bool command_enabled_link_frame(const char *argument) +bool command_enabled_link_cel(const char *argument) { return FALSE; } -void command_execute_link_frame(const char *argument) +void command_execute_link_cel(const char *argument) { } diff --git a/src/commands/cmd_merge_down_layer.c b/src/commands/cmd_merge_down_layer.c index d1e33581e..3963a00e1 100644 --- a/src/commands/cmd_merge_down_layer.c +++ b/src/commands/cmd_merge_down_layer.c @@ -25,7 +25,7 @@ #include "core/app.h" #include "modules/gui.h" #include "modules/sprites.h" -#include "raster/frame.h" +#include "raster/cel.h" #include "raster/image.h" #include "raster/layer.h" #include "raster/sprite.h" @@ -58,7 +58,7 @@ void command_execute_merge_down_layer(const char *argument) { Sprite *sprite = current_sprite; Layer *src_layer, *dst_layer; - Frame *src_frame, *dst_frame; + Cel *src_cel, *dst_cel; Image *src_image, *dst_image; int frpos, index; @@ -70,17 +70,17 @@ void command_execute_merge_down_layer(const char *argument) for (frpos=0; frposframes; ++frpos) { /* get frames */ - src_frame = layer_get_frame(src_layer, frpos); - dst_frame = layer_get_frame(dst_layer, frpos); + src_cel = layer_get_cel(src_layer, frpos); + dst_cel = layer_get_cel(dst_layer, frpos); /* get images */ - if (src_frame) - src_image = stock_get_image(src_layer->stock, src_frame->image); + if (src_cel) + src_image = stock_get_image(src_layer->stock, src_cel->image); else src_image = NULL; - if (dst_frame) - dst_image = stock_get_image(dst_layer->stock, dst_frame->image); + if (dst_cel) + dst_image = stock_get_image(dst_layer->stock, dst_cel->image); else dst_image = NULL; @@ -88,43 +88,43 @@ void command_execute_merge_down_layer(const char *argument) if (src_image) { /* no destination image */ if (!dst_image) { - /* copy this frame to the destination layer */ + /* copy this cel to the destination layer */ dst_image = image_new_copy(src_image); index = stock_add_image(dst_layer->stock, dst_image); if (undo_is_enabled(sprite->undo)) { undo_add_image(sprite->undo, dst_layer->stock, dst_image); } - dst_frame = frame_new(frpos, index); - frame_set_position(dst_frame, src_frame->x, src_frame->y); - frame_set_opacity(dst_frame, src_frame->opacity); + dst_cel = cel_new(frpos, index); + cel_set_position(dst_cel, src_cel->x, src_cel->y); + cel_set_opacity(dst_cel, src_cel->opacity); if (undo_is_enabled(sprite->undo)) { - undo_add_frame(sprite->undo, dst_layer, dst_frame); + undo_add_cel(sprite->undo, dst_layer, dst_cel); } - layer_add_frame(dst_layer, dst_frame); + layer_add_cel(dst_layer, dst_cel); } /* with destination */ else { - int x1 = MIN(src_frame->x, dst_frame->x); - int y1 = MIN(src_frame->y, dst_frame->y); - int x2 = MAX(src_frame->x+src_image->w-1, dst_frame->x+dst_image->w-1); - int y2 = MAX(src_frame->y+src_image->h-1, dst_frame->y+dst_image->h-1); + int x1 = MIN(src_cel->x, dst_cel->x); + int y1 = MIN(src_cel->y, dst_cel->y); + int x2 = MAX(src_cel->x+src_image->w-1, dst_cel->x+dst_image->w-1); + int y2 = MAX(src_cel->y+src_image->h-1, dst_cel->y+dst_image->h-1); Image *new_image = image_crop(dst_image, - x1-dst_frame->x, - y1-dst_frame->y, + x1-dst_cel->x, + y1-dst_cel->y, x2-x1+1, y2-y1+1); /* merge src_image in new_image */ image_merge(new_image, src_image, - src_frame->x-x1, - src_frame->y-y1, - src_frame->opacity, + src_cel->x-x1, + src_cel->y-y1, + src_cel->opacity, src_layer->blend_mode); - frame_set_position(dst_frame, x1, y1); + cel_set_position(dst_cel, x1, y1); if (undo_is_enabled(sprite->undo)) { - undo_replace_image(sprite->undo, dst_layer->stock, dst_frame->image); + undo_replace_image(sprite->undo, dst_layer->stock, dst_cel->image); } - stock_replace_image(dst_layer->stock, dst_frame->image, new_image); + stock_replace_image(dst_layer->stock, dst_cel->image, new_image); image_free(dst_image); } diff --git a/src/commands/cmd_move_frame.c b/src/commands/cmd_move_frame.c index 82fe097e1..61e8a706a 100644 --- a/src/commands/cmd_move_frame.c +++ b/src/commands/cmd_move_frame.c @@ -28,11 +28,11 @@ #endif -bool command_enabled_move_frame(const char *argument) +bool command_enabled_move_cel(const char *argument) { return FALSE; } -void command_execute_move_frame(const char *argument) +void command_execute_move_cel(const char *argument) { } diff --git a/src/commands/cmd_new_frame.c b/src/commands/cmd_new_frame.c index 3a5a92481..28b22d97f 100644 --- a/src/commands/cmd_new_frame.c +++ b/src/commands/cmd_new_frame.c @@ -27,8 +27,8 @@ #include "modules/gui.h" #include "modules/color.h" #include "modules/sprites.h" +#include "raster/cel.h" #include "raster/image.h" -#include "raster/frame.h" #include "raster/layer.h" #include "raster/sprite.h" #include "raster/stock.h" @@ -37,7 +37,7 @@ #endif -bool command_enabled_new_frame(const char *argument) +bool command_enabled_new_cel(const char *argument) { return current_sprite && @@ -47,18 +47,18 @@ bool command_enabled_new_frame(const char *argument) layer_is_image(current_sprite->layer); } -void command_execute_new_frame(const char *argument) +void command_execute_new_cel(const char *argument) { int bg, image_index; - Frame *frame; + Cel *cel; Image *image; int frpos; frpos = current_sprite->frpos; - while (layer_get_frame(current_sprite->layer, frpos)) + while (layer_get_cel(current_sprite->layer, frpos)) frpos++; - /* create a new empty frame with a new clean image */ + /* create a new empty cel with a new clean image */ image = image_new(current_sprite->imgtype, current_sprite->w, current_sprite->h); @@ -87,10 +87,10 @@ void command_execute_new_frame(const char *argument) undo_add_image(current_sprite->undo, current_sprite->layer->stock, image); - /* add the frame in the layer */ - frame = frame_new(current_sprite->frpos, image_index); - undo_add_frame(current_sprite->undo, current_sprite->layer, frame); - layer_add_frame(current_sprite->layer, frame); + /* add the cel in the layer */ + cel = cel_new(current_sprite->frpos, image_index); + undo_add_cel(current_sprite->undo, current_sprite->layer, cel); + layer_add_cel(current_sprite->layer, cel); undo_close(current_sprite->undo); diff --git a/src/commands/cmd_new_layer.c b/src/commands/cmd_new_layer.c index f68b25cc2..2d927532e 100644 --- a/src/commands/cmd_new_layer.c +++ b/src/commands/cmd_new_layer.c @@ -27,6 +27,7 @@ #include "modules/sprites.h" #include "raster/layer.h" #include "raster/sprite.h" +#include "script/functions.h" #endif diff --git a/src/commands/cmd_new_layer_set.c b/src/commands/cmd_new_layer_set.c index 7402bd3e3..06c6ca500 100644 --- a/src/commands/cmd_new_layer_set.c +++ b/src/commands/cmd_new_layer_set.c @@ -27,6 +27,7 @@ #include "modules/sprites.h" #include "raster/layer.h" #include "raster/sprite.h" +#include "script/functions.h" #endif diff --git a/src/commands/cmd_preview.c b/src/commands/cmd_preview.c index c98bc85ce..dc0981f24 100644 --- a/src/commands/cmd_preview.c +++ b/src/commands/cmd_preview.c @@ -30,9 +30,9 @@ #include "modules/editors.h" #include "modules/gfx.h" #include "modules/gui.h" -#include "modules/render.h" #include "raster/image.h" #include "raster/sprite.h" +#include "util/render.h" #include "widgets/editor.h" #include "widgets/statebar.h" diff --git a/src/commands/cmd_record_screen.c b/src/commands/cmd_record_screen.c index 32db80ff6..9edc0c4d4 100644 --- a/src/commands/cmd_record_screen.c +++ b/src/commands/cmd_record_screen.c @@ -20,7 +20,10 @@ #ifndef USE_PRECOMPILED_HEADER +#include + #include "jinete/base.h" +#include "jinete/alert.h" #include "util/recscr.h" @@ -35,6 +38,13 @@ void command_execute_record_screen(const char *argument) { if (is_rec_screen()) rec_screen_off(); - else + else if (bitmap_color_depth(screen) == 8 + || jalert(_("Warning" + "<layer, sprite->frpos); - if (frame) { - RemoveFrame(sprite->layer, frame); + Cel *cel = layer_get_cel(sprite->layer, sprite->frpos); + if (cel) { + RemoveCel(sprite->layer, cel); GUI_Refresh(sprite); } } diff --git a/src/commands/cmd_remove_layer.c b/src/commands/cmd_remove_layer.c index b5368896c..16f08f867 100644 --- a/src/commands/cmd_remove_layer.c +++ b/src/commands/cmd_remove_layer.c @@ -23,6 +23,7 @@ #include "modules/gui.h" #include "modules/sprites.h" #include "raster/sprite.h" +#include "script/functions.h" #endif diff --git a/src/commands/commands.c b/src/commands/commands.c index fd92ad057..4850b6990 100644 --- a/src/commands/commands.c +++ b/src/commands/commands.c @@ -110,21 +110,21 @@ bool command_enabled_flatten_layers(const char *argument); void command_execute_flatten_layers(const char *argument); bool command_enabled_crop_layer(const char *argument); void command_execute_crop_layer(const char *argument); -/* frame */ -bool command_enabled_frame_properties(const char *argument); -void command_execute_frame_properties(const char *argument); -bool command_enabled_remove_frame(const char *argument); -void command_execute_remove_frame(const char *argument); -bool command_enabled_new_frame(const char *argument); -void command_execute_new_frame(const char *argument); -bool command_enabled_move_frame(const char *argument); -void command_execute_move_frame(const char *argument); -bool command_enabled_copy_frame(const char *argument); -void command_execute_copy_frame(const char *argument); -bool command_enabled_link_frame(const char *argument); -void command_execute_link_frame(const char *argument); -bool command_enabled_crop_frame(const char *argument); -void command_execute_crop_frame(const char *argument); +/* cel */ +bool command_enabled_cel_properties(const char *argument); +void command_execute_cel_properties(const char *argument); +bool command_enabled_remove_cel(const char *argument); +void command_execute_remove_cel(const char *argument); +bool command_enabled_new_cel(const char *argument); +void command_execute_new_cel(const char *argument); +bool command_enabled_move_cel(const char *argument); +void command_execute_move_cel(const char *argument); +bool command_enabled_copy_cel(const char *argument); +void command_execute_copy_cel(const char *argument); +bool command_enabled_link_cel(const char *argument); +void command_execute_link_cel(const char *argument); +bool command_enabled_crop_cel(const char *argument); +void command_execute_crop_cel(const char *argument); /* select */ bool command_enabled_mask_all(const char *argument); void command_execute_mask_all(const char *argument); @@ -230,13 +230,13 @@ static Command commands[] = { CMD_EXE_ENA(merge_down_layer), CMD_EXE_ENA(flatten_layers), CMD_EXE_ENA(crop_layer), - CMD_EXE_ENA(frame_properties), - CMD_EXE_ENA(remove_frame), - CMD_EXE_ENA(new_frame), - CMD_EXE_ENA(move_frame), - CMD_EXE_ENA(copy_frame), - CMD_EXE_ENA(link_frame), - CMD_EXE_ENA(crop_frame), + CMD_EXE_ENA(cel_properties), + CMD_EXE_ENA(remove_cel), + CMD_EXE_ENA(new_cel), + CMD_EXE_ENA(move_cel), + CMD_EXE_ENA(copy_cel), + CMD_EXE_ENA(link_cel), + CMD_EXE_ENA(crop_cel), CMD_EXE_ENA(mask_all), CMD_EXE_ENA(deselect_mask), CMD_EXE_ENA(reselect_mask), diff --git a/src/commands/commands.h b/src/commands/commands.h index 2295e3a5e..872afc276 100644 --- a/src/commands/commands.h +++ b/src/commands/commands.h @@ -69,14 +69,14 @@ #define CMD_MERGE_DOWN_LAYER "merge_down_layer" #define CMD_FLATTEN_LAYERS "flatten_layers" #define CMD_CROP_LAYER "crop_layer" -/* frame */ -#define CMD_FRAME_PROPERTIES "frame_properties" -#define CMD_REMOVE_FRAME "remove_frame" -#define CMD_NEW_FRAME "new_frame" -#define CMD_MOVE_FRAME "move_frame" -#define CMD_COPY_FRAME "copy_frame" -#define CMD_LINK_FRAME "link_frame" -#define CMD_CROP_FRAME "crop_frame" +/* cel */ +#define CMD_CEL_PROPERTIES "cel_properties" +#define CMD_REMOVE_CEL "remove_cel" +#define CMD_NEW_CEL "new_cel" +#define CMD_MOVE_CEL "move_cel" +#define CMD_COPY_CEL "copy_cel" +#define CMD_LINK_CEL "link_cel" +#define CMD_CROP_CEL "crop_cel" /* select */ #define CMD_MASK_ALL "mask_all" #define CMD_DESELECT_MASK "deselect_mask" diff --git a/src/core/modules.c b/src/core/modules.c index dec94c7b1..e74b9c50a 100644 --- a/src/core/modules.c +++ b/src/core/modules.c @@ -29,7 +29,6 @@ #include "modules/gui.h" #include "modules/palette.h" #include "modules/recent.h" -#include "modules/render.h" #include "modules/rootmenu.h" #include "modules/sprites.h" #include "modules/tools.h" @@ -61,7 +60,6 @@ static Module module[] = DEF_MODULE(effect, REQUIRE_INTERFACE | REQUIRE_SCRIPTING), DEF_MODULE(tools, REQUIRE_INTERFACE | REQUIRE_SCRIPTING), DEF_MODULE(graphics, REQUIRE_INTERFACE), - DEF_MODULE(render, REQUIRE_INTERFACE), DEF_MODULE(gui, REQUIRE_INTERFACE), DEF_MODULE(recent, REQUIRE_INTERFACE), DEF_MODULE(rootmenu, REQUIRE_INTERFACE), diff --git a/src/dialogs/filmedit.c b/src/dialogs/filmedit.c index 0d4d3120d..e3c33969e 100644 --- a/src/dialogs/filmedit.c +++ b/src/dialogs/filmedit.c @@ -34,13 +34,13 @@ #include "modules/palette.h" #include "modules/rootmenu.h" #include "modules/sprites.h" -#include "raster/frame.h" +#include "raster/cel.h" #include "raster/image.h" #include "raster/layer.h" #include "raster/sprite.h" #include "raster/stock.h" #include "raster/undo.h" -#include "util/frmove.h" +#include "util/celmove.h" #include "util/thmbnail.h" #endif @@ -56,26 +56,26 @@ enum { STATE_SELECTING, }; -struct FrameBox; +struct CelBox; typedef struct LayerBox { JWidget widget; - struct FrameBox *frame_box; + struct CelBox *cel_box; /* for layer movement */ Layer *layer; struct jrect rect; void *rect_data; } LayerBox; -typedef struct FrameBox { +typedef struct CelBox { JWidget widget; LayerBox *layer_box; /* for frame movement */ Layer *layer; - Frame *frame; + Cel *cel; struct jrect rect; void *rect_data; -} FrameBox; +} CelBox; static int state = STATE_NONE; @@ -85,11 +85,11 @@ static LayerBox *layer_box_data (JWidget widget); static void layer_box_request_size (JWidget widget, int *w, int *h); static bool layer_box_msg_proc (JWidget widget, JMessage msg); -static JWidget frame_box_new (void); -static int frame_box_type (void); -static FrameBox *frame_box_data (JWidget widget); -static void frame_box_request_size (JWidget widget, int *w, int *h); -static bool frame_box_msg_proc (JWidget widget, JMessage msg); +static JWidget cel_box_new (void); +static int cel_box_type (void); +static CelBox *cel_box_data (JWidget widget); +static void cel_box_request_size (JWidget widget, int *w, int *h); +static bool cel_box_msg_proc (JWidget widget, JMessage msg); static Layer *select_prev_layer(Layer *layer, int enter_in_sets); static Layer *select_next_layer(Layer *layer, int enter_in_sets); @@ -97,10 +97,10 @@ static int count_layers(Layer *layer); static int get_layer_pos(Layer *layer, Layer *current, int *pos); static Layer *get_layer_in_pos(Layer *layer, int pos); -static void select_frpos_motion (JWidget widget); -static void select_layer_motion (JWidget widget, LayerBox *layer_box, FrameBox *frame_box); -static void control_scroll_motion (JWidget widget, LayerBox *layer_box, FrameBox *frame_box); -static void get_frame_rect (JWidget widget, JRect rect); +static void select_frpos_motion(JWidget widget); +static void select_layer_motion(JWidget widget, LayerBox *layer_box, CelBox *cel_box); +static void control_scroll_motion(JWidget widget, LayerBox *layer_box, CelBox *cel_box); +static void get_cel_rect(JWidget widget, JRect rect); bool is_movingframe (void) { @@ -112,7 +112,7 @@ void switch_between_film_and_sprite_editor (void) Sprite *sprite = current_sprite; JWidget window, box1, panel1; JWidget layer_view, frame_view; - JWidget layer_box, frame_box; + JWidget layer_box, cel_box; if (!is_interactive ()) return; @@ -123,15 +123,15 @@ void switch_between_film_and_sprite_editor (void) layer_view = jview_new(); frame_view = jview_new(); layer_box = layer_box_new(); - frame_box = frame_box_new(); + cel_box = cel_box_new(); - layer_box_data(layer_box)->frame_box = frame_box_data(frame_box); - frame_box_data(frame_box)->layer_box = layer_box_data(layer_box); + layer_box_data(layer_box)->cel_box = cel_box_data(cel_box); + cel_box_data(cel_box)->layer_box = layer_box_data(layer_box); jwidget_expansive(panel1, TRUE); jview_attach(layer_view, layer_box); - jview_attach(frame_view, frame_box); + jview_attach(frame_view, cel_box); jview_without_bars(layer_view); jview_without_bars(frame_view); @@ -369,7 +369,7 @@ static bool layer_box_msg_proc (JWidget widget, JMessage msg) state = STATE_MOVING; jmouse_set_cursor(JI_CURSOR_MOVE); - select_layer_motion(widget, layer_box, layer_box->frame_box); + select_layer_motion(widget, layer_box, layer_box->cel_box); layer_box->layer = current_sprite->layer; /* layer_box->rect = rect; */ /* layer_box->rect_data = NULL; */ @@ -379,10 +379,10 @@ static bool layer_box_msg_proc (JWidget widget, JMessage msg) if (jwidget_has_capture (widget)) { /* scroll */ if (state == STATE_SCROLLING) - control_scroll_motion (widget, layer_box, layer_box->frame_box); + control_scroll_motion (widget, layer_box, layer_box->cel_box); /* move */ else if (state == STATE_MOVING) { - select_layer_motion (widget, layer_box, layer_box->frame_box); + select_layer_motion (widget, layer_box, layer_box->cel_box); } return TRUE; } @@ -405,7 +405,7 @@ static bool layer_box_msg_proc (JWidget widget, JMessage msg) msg->mouse.x, msg->mouse.y); jview_update (jwidget_get_view (layer_box->widget)); - jview_update (jwidget_get_view (layer_box->frame_box->widget)); + jview_update (jwidget_get_view (layer_box->cel_box->widget)); } } /* move */ @@ -416,7 +416,7 @@ static bool layer_box_msg_proc (JWidget widget, JMessage msg) current_sprite->layer = layer_box->layer; jview_update (jwidget_get_view (layer_box->widget)); - jview_update (jwidget_get_view (layer_box->frame_box->widget)); + jview_update (jwidget_get_view (layer_box->cel_box->widget)); } else jwidget_dirty (widget); @@ -431,24 +431,24 @@ static bool layer_box_msg_proc (JWidget widget, JMessage msg) } /*********************************************************************** - FrameBox + CelBox ***********************************************************************/ -static JWidget frame_box_new (void) +static JWidget cel_box_new (void) { - JWidget widget = jwidget_new (frame_box_type ()); - FrameBox *frame_box = jnew (FrameBox, 1); + JWidget widget = jwidget_new (cel_box_type ()); + CelBox *cel_box = jnew (CelBox, 1); - frame_box->widget = widget; + cel_box->widget = widget; - jwidget_add_hook (widget, frame_box_type (), - frame_box_msg_proc, frame_box); + jwidget_add_hook (widget, cel_box_type (), + cel_box_msg_proc, cel_box); jwidget_focusrest (widget, TRUE); return widget; } -static int frame_box_type (void) +static int cel_box_type (void) { static int type = 0; if (!type) @@ -456,12 +456,12 @@ static int frame_box_type (void) return type; } -static FrameBox *frame_box_data (JWidget widget) +static CelBox *cel_box_data (JWidget widget) { - return jwidget_get_data (widget, frame_box_type ()); + return jwidget_get_data (widget, cel_box_type ()); } -static void frame_box_request_size (JWidget widget, int *w, int *h) +static void cel_box_request_size (JWidget widget, int *w, int *h) { Sprite *sprite = current_sprite; @@ -469,19 +469,19 @@ static void frame_box_request_size (JWidget widget, int *w, int *h) *h = LAYSIZE*(count_layers (sprite->set)+1); } -static bool frame_box_msg_proc (JWidget widget, JMessage msg) +static bool cel_box_msg_proc (JWidget widget, JMessage msg) { - FrameBox *frame_box = frame_box_data (widget); + CelBox *cel_box = cel_box_data (widget); Sprite *sprite = current_sprite; switch (msg->type) { case JM_DESTROY: - jfree (frame_box); + jfree (cel_box); break; case JM_REQSIZE: - frame_box_request_size (widget, &msg->reqsize.w, &msg->reqsize.h); + cel_box_request_size (widget, &msg->reqsize.w, &msg->reqsize.h); return TRUE; case JM_DRAW: { @@ -568,22 +568,22 @@ static bool frame_box_msg_proc (JWidget widget, JMessage msg) case GFXOBJ_LAYER_SET: break; case GFXOBJ_LAYER_IMAGE: { - Frame *frame, *frame_link; + Cel *cel, *cel_link; int k_frpos, k_image; JLink link; - JI_LIST_FOR_EACH(layer->frames, link) { - frame = link->data; - k_frpos = frame->frpos; + JI_LIST_FOR_EACH(layer->cels, link) { + cel = link->data; + k_frpos = cel->frpos; if (k_frpos < first_viewable_frame || k_frpos > last_viewable_frame) continue; - k_image = frame->image; + k_image = cel->image; - frame_link = frame_is_link(frame, layer); - thumbnail = generate_thumbnail(frame_link ? frame_link: frame, + cel_link = cel_is_link(cel, layer); + thumbnail = generate_thumbnail(cel_link ? cel_link: cel, layer); x1 = k_frpos*FRMSIZE-scroll_x+FRMSIZE/2-THUMBSIZE/2; @@ -598,7 +598,7 @@ static bool frame_box_msg_proc (JWidget widget, JMessage msg) if (thumbnail) draw_sprite(bmp, thumbnail, x1, y1); - if (frame_link) { + if (cel_link) { BITMAP *sprite = get_gfx(GFX_LINKFRAME); draw_sprite(bmp, sprite, x1, y2-sprite->h+1); } @@ -626,13 +626,13 @@ static bool frame_box_msg_proc (JWidget widget, JMessage msg) jmouse_set_cursor(JI_CURSOR_MOVE); } else { - Frame *frame; + Cel *cel; state = STATE_SELECTING; /* by default we will be selecting frames */ - select_frpos_motion (widget); - select_layer_motion (widget, frame_box->layer_box, frame_box); + select_frpos_motion(widget); + select_layer_motion(widget, cel_box->layer_box, cel_box); /* show the dialog to change the frlen (frame duration time)? */ if (msg->mouse.y < FRMSIZE) { @@ -643,26 +643,25 @@ static bool frame_box_msg_proc (JWidget widget, JMessage msg) return TRUE; } - frame = layer_get_frame (current_sprite->layer, - current_sprite->frpos); - if (frame) { - state = STATE_MOVING; /* now we will moving a frame */ + cel = layer_get_cel(current_sprite->layer, + current_sprite->frpos); + if (cel) { + state = STATE_MOVING; /* now we will moving a cel */ jmouse_set_cursor(JI_CURSOR_MOVE); - frame_box->layer = current_sprite->layer; - frame_box->frame = frame; - frame_box->rect_data = NULL; + cel_box->layer = current_sprite->layer; + cel_box->cel = cel; + cel_box->rect_data = NULL; - get_frame_rect (widget, &frame_box->rect); + get_cel_rect(widget, &cel_box->rect); jmouse_hide(); - frame_box->rect_data = rectsave - (ji_screen, - frame_box->rect.x1, frame_box->rect.y1, - frame_box->rect.x2-1, frame_box->rect.y2-1); + cel_box->rect_data = rectsave(ji_screen, + cel_box->rect.x1, cel_box->rect.y1, + cel_box->rect.x2-1, cel_box->rect.y2-1); rectdotted(ji_screen, - frame_box->rect.x1, frame_box->rect.y1, - frame_box->rect.x2-1, frame_box->rect.y2-1, + cel_box->rect.x1, cel_box->rect.y1, + cel_box->rect.x2-1, cel_box->rect.y2-1, makecol (0, 0, 0), makecol (255, 255, 255)); jmouse_show(); } @@ -672,29 +671,28 @@ static bool frame_box_msg_proc (JWidget widget, JMessage msg) if (jwidget_has_capture (widget)) { /* scroll */ if (state == STATE_SCROLLING) - control_scroll_motion (widget, frame_box->layer_box, frame_box); + control_scroll_motion (widget, cel_box->layer_box, cel_box); /* move */ else if (state == STATE_MOVING) { jmouse_hide(); - rectrestore(frame_box->rect_data); - rectdiscard(frame_box->rect_data); + rectrestore(cel_box->rect_data); + rectdiscard(cel_box->rect_data); select_frpos_motion(widget); - select_layer_motion(widget, frame_box->layer_box, frame_box); + select_layer_motion(widget, cel_box->layer_box, cel_box); - get_frame_rect(widget, &frame_box->rect); + get_cel_rect(widget, &cel_box->rect); jwidget_flush_redraw(widget); - frame_box->rect_data = rectsave - (ji_screen, - frame_box->rect.x1, frame_box->rect.y1, - frame_box->rect.x2-1, frame_box->rect.y2-1); + cel_box->rect_data = rectsave(ji_screen, + cel_box->rect.x1, cel_box->rect.y1, + cel_box->rect.x2-1, cel_box->rect.y2-1); rectdotted(ji_screen, - frame_box->rect.x1, frame_box->rect.y1, - frame_box->rect.x2-1, frame_box->rect.y2-1, + cel_box->rect.x1, cel_box->rect.y1, + cel_box->rect.x2-1, cel_box->rect.y2-1, makecol(0, 0, 0), makecol(255, 255, 255)); jmouse_show(); @@ -702,7 +700,7 @@ static bool frame_box_msg_proc (JWidget widget, JMessage msg) /* select */ else if (state == STATE_SELECTING) { select_frpos_motion(widget); - select_layer_motion(widget, frame_box->layer_box, frame_box); + select_layer_motion(widget, cel_box->layer_box, cel_box); } return TRUE; } @@ -718,12 +716,12 @@ static bool frame_box_msg_proc (JWidget widget, JMessage msg) if ((state == STATE_SELECTING) || (state == STATE_MOVING)) { if (state == STATE_MOVING) { jmouse_hide(); - rectrestore(frame_box->rect_data); - rectdiscard(frame_box->rect_data); + rectrestore(cel_box->rect_data); + rectdiscard(cel_box->rect_data); jmouse_show(); } - set_frame_to_handle(frame_box->layer, frame_box->frame); + set_cel_to_handle(cel_box->layer, cel_box->cel); if (msg->mouse.right) { JWidget popup_menuitem = get_frame_popup_menuitem(); @@ -733,12 +731,12 @@ static bool frame_box_msg_proc (JWidget widget, JMessage msg) jmenu_popup(jmenuitem_get_submenu(popup_menuitem), msg->mouse.x, msg->mouse.y); - jview_update(jwidget_get_view (frame_box->widget)); - jview_update(jwidget_get_view (frame_box->layer_box->widget)); + jview_update(jwidget_get_view (cel_box->widget)); + jview_update(jwidget_get_view (cel_box->layer_box->widget)); } } else if (state == STATE_MOVING) { - move_frame(); + move_cel(); jwidget_dirty(widget); } } @@ -904,7 +902,7 @@ static void select_frpos_motion(JWidget widget) /* select the layer depending of mouse motion (also adjust the scroll) */ static void select_layer_motion(JWidget widget, - LayerBox *layer_box, FrameBox *frame_box) + LayerBox *layer_box, CelBox *cel_box) { Sprite *sprite = current_sprite; int layer, current_layer; @@ -919,7 +917,7 @@ static void select_layer_motion(JWidget widget, /* the layer change? */ if (layer != current_layer) { JWidget view1 = jwidget_get_view(layer_box->widget); - JWidget view2 = jwidget_get_view(frame_box->widget); + JWidget view2 = jwidget_get_view(cel_box->widget); JRect vp = jview_get_viewport_position(jwidget_get_view(widget)); int scroll1_x, scroll1_y, scroll_change; int scroll2_x, scroll2_y; @@ -947,19 +945,19 @@ static void select_layer_motion(JWidget widget, widget->rc->y1+LAYSIZE+layer*LAYSIZE+LAYSIZE/2); jwidget_dirty(layer_box->widget); - jwidget_dirty(frame_box->widget); + jwidget_dirty(cel_box->widget); jrect_free(vp); } } -/* controls scroll for "layer_box" and "frame_box" handling horizontal +/* controls scroll for "layer_box" and "cel_box" handling horizontal scroll individually and vertical scroll jointly */ -static void control_scroll_motion (JWidget widget, - LayerBox *layer_box, FrameBox *frame_box) +static void control_scroll_motion(JWidget widget, + LayerBox *layer_box, CelBox *cel_box) { JWidget view1 = jwidget_get_view(layer_box->widget); - JWidget view2 = jwidget_get_view(frame_box->widget); + JWidget view2 = jwidget_get_view(cel_box->widget); JRect vp = jview_get_viewport_position(jwidget_get_view (widget)); int scroll1_x, scroll1_y; int scroll2_x, scroll2_y; @@ -970,7 +968,7 @@ static void control_scroll_motion (JWidget widget, /* horizontal scroll for layer_box */ if (widget == layer_box->widget) scroll1_x += jmouse_x(1)-jmouse_x(0); - /* horizontal scroll for frame_box */ + /* horizontal scroll for cel_box */ else scroll2_x += jmouse_x(1)-jmouse_x(0); @@ -988,7 +986,7 @@ static void control_scroll_motion (JWidget widget, jrect_free(vp); } -static void get_frame_rect (JWidget widget, JRect rect) +static void get_cel_rect(JWidget widget, JRect rect) { JWidget view = jwidget_get_view(widget); JRect vp = jview_get_viewport_position(view); diff --git a/src/dialogs/quick.c b/src/dialogs/quick.c index fb9ed27df..26b79b27b 100644 --- a/src/dialogs/quick.c +++ b/src/dialogs/quick.c @@ -28,8 +28,8 @@ #include "modules/sprites.h" #include "modules/tools2.h" #include "raster/blend.h" +#include "raster/cel.h" #include "raster/dirty.h" -#include "raster/frame.h" #include "raster/image.h" #include "raster/layer.h" #include "raster/mask.h" diff --git a/src/file/ase.c b/src/file/ase.c index 313167579..952899857 100644 --- a/src/file/ase.c +++ b/src/file/ase.c @@ -36,13 +36,13 @@ #define ASE_FILE_CHUNK_FLI_COLOR 11 #define ASE_FILE_CHUNK_LAYER 0x2004 -#define ASE_FILE_CHUNK_FRAME 0x2005 +#define ASE_FILE_CHUNK_CEL 0x2005 #define ASE_FILE_CHUNK_MASK 0x2016 #define ASE_FILE_CHUNK_PATH 0x2017 -#define ASE_FILE_RAW_FRAME 0 -#define ASE_FILE_LINK_FRAME 1 -#define ASE_FILE_RLE_COMPRESSED_FRAME 2 +#define ASE_FILE_RAW_CEL 0 +#define ASE_FILE_LINK_CEL 1 +#define ASE_FILE_RLE_COMPRESSED_CEL 2 typedef struct ASE_Header { @@ -87,7 +87,7 @@ static void ase_file_prepare_frame_header(FILE *f, ASE_FrameHeader *frame_header static void ase_file_write_frame_header(FILE *f, ASE_FrameHeader *frame_header); static void ase_file_write_layers(FILE *f, Layer *layer); -static void ase_file_write_frames(FILE *f, Sprite *sprite, Layer *layer, int frpos); +static void ase_file_write_cels(FILE *f, Sprite *sprite, Layer *layer, int frpos); static void ase_file_read_padding(FILE *f, int bytes); static void ase_file_write_padding(FILE *f, int bytes); @@ -101,8 +101,8 @@ static void ase_file_read_color_chunk(FILE *f, RGB *pal); static void ase_file_write_color_chunk(FILE *f, RGB *pal); static Layer *ase_file_read_layer_chunk(FILE *f, int imgtype, Layer **previous_layer, int *current_level); static void ase_file_write_layer_chunk(FILE *f, Layer *layer); -static Frame *ase_file_read_frame_chunk(FILE *f, Sprite *sprite, int frpos, int imgtype); -static void ase_file_write_frame_chunk(FILE *f, Frame *frame, Layer *layer, int layer_index); +static Cel *ase_file_read_cel_chunk(FILE *f, Sprite *sprite, int frpos, int imgtype); +static void ase_file_write_cel_chunk(FILE *f, Cel *cel, Layer *layer, int layer_index); static Mask *ase_file_read_mask_chunk(FILE *f); static void ase_file_write_mask_chunk(FILE *f, Mask *mask); @@ -162,7 +162,7 @@ static int ase_file_write(Sprite *sprite) return ret; } -Sprite *ase_file_read_f (FILE *f) +Sprite *ase_file_read_f(FILE *f) { Sprite *sprite = NULL; ASE_Header header; @@ -175,17 +175,17 @@ Sprite *ase_file_read_f (FILE *f) int chunk_type; int c, frpos; - if (ase_file_read_header (f, &header) != 0) { - console_printf (_("Error reading header\n")); + if (ase_file_read_header(f, &header) != 0) { + console_printf(_("Error reading header\n")); return NULL; } /* create the new sprite */ - sprite = sprite_new (header.depth == 32 ? IMAGE_RGB: - header.depth == 16 ? IMAGE_GRAYSCALE: IMAGE_INDEXED, - header.width, header.height); + sprite = sprite_new(header.depth == 32 ? IMAGE_RGB: + header.depth == 16 ? IMAGE_GRAYSCALE: IMAGE_INDEXED, + header.width, header.height); if (!sprite) { - console_printf (_("Error creating sprite with file spec\n")); + console_printf(_("Error creating sprite with file spec\n")); return NULL; } @@ -203,11 +203,11 @@ Sprite *ase_file_read_f (FILE *f) /* read frame by frame to end-of-file */ for (frpos=0; frposframes; frpos++) { /* start frame position */ - frame_pos = ftell (f); - do_progress (frame_pos); + frame_pos = ftell(f); + do_progress(frame_pos); /* read frame header */ - ase_file_read_frame_header (f, &frame_header); + ase_file_read_frame_header(f, &frame_header); /* correct frame type */ if (frame_header.magic == ASE_FILE_FRAME_MAGIC) { @@ -218,12 +218,12 @@ Sprite *ase_file_read_f (FILE *f) /* read chunks */ for (c=0; cimgtype); + ase_file_read_cel_chunk(f, sprite, frpos, sprite->imgtype); break; } @@ -286,15 +286,15 @@ Sprite *ase_file_read_f (FILE *f) } /* skip frame size */ - fseek (f, frame_pos+frame_header.size, SEEK_SET); + fseek(f, frame_pos+frame_header.size, SEEK_SET); } - del_progress (); + del_progress(); return sprite; } -int ase_file_write_f (FILE *f, Sprite *sprite) +int ase_file_write_f(FILE *f, Sprite *sprite) { ASE_Header header; ASE_FrameHeader frame_header; @@ -334,8 +334,8 @@ int ase_file_write_f (FILE *f, Sprite *sprite) ase_file_write_mask_chunk(f, link->data); } - /* write frames chunks */ - ase_file_write_frames(f, sprite, sprite->set, frpos); + /* write cel chunks */ + ase_file_write_cels(f, sprite, sprite->set, frpos); /* write the frame header */ ase_file_write_frame_header(f, &frame_header); @@ -411,7 +411,7 @@ static void ase_file_write_header (FILE *f, ASE_Header *header) fseek (f, header->pos+header->size, SEEK_SET); } -static void ase_file_read_frame_header (FILE *f, ASE_FrameHeader *frame_header) +static void ase_file_read_frame_header(FILE *f, ASE_FrameHeader *frame_header) { frame_header->size = fgetl (f); frame_header->magic = fgetw (f); @@ -420,7 +420,7 @@ static void ase_file_read_frame_header (FILE *f, ASE_FrameHeader *frame_header) ase_file_read_padding (f, 6); } -static void ase_file_prepare_frame_header (FILE *f, ASE_FrameHeader *frame_header) +static void ase_file_prepare_frame_header(FILE *f, ASE_FrameHeader *frame_header) { int pos = ftell (f); @@ -434,7 +434,7 @@ static void ase_file_prepare_frame_header (FILE *f, ASE_FrameHeader *frame_heade fseek (f, pos+16, SEEK_SET); } -static void ase_file_write_frame_header (FILE *f, ASE_FrameHeader *frame_header) +static void ase_file_write_frame_header(FILE *f, ASE_FrameHeader *frame_header) { int pos = frame_header->size; int end = ftell (f); @@ -465,28 +465,28 @@ static void ase_file_write_layers(FILE *f, Layer *layer) } } -static void ase_file_write_frames(FILE *f, Sprite *sprite, Layer *layer, int frpos) +static void ase_file_write_cels(FILE *f, Sprite *sprite, Layer *layer, int frpos) { if (layer_is_image(layer)) { - Frame *frame = layer_get_frame(layer, frpos); + Cel *cel = layer_get_cel(layer, frpos); - if (frame) { -/* console_printf ("New frame in frpos %d, in layer %d\n", */ + if (cel) { +/* console_printf ("New cel in frpos %d, in layer %d\n", */ /* frpos, sprite_layer2index (sprite, layer)); */ - ase_file_write_frame_chunk(f, frame, layer, /* index_count */ - sprite_layer2index(sprite, layer)); + ase_file_write_cel_chunk(f, cel, layer, /* index_count */ + sprite_layer2index(sprite, layer)); } } if (layer_is_set(layer)) { JLink link; JI_LIST_FOR_EACH(layer->layers, link) - ase_file_write_frames(f, sprite, link->data, frpos); + ase_file_write_cels(f, sprite, link->data, frpos); } } -static void ase_file_read_padding (FILE *f, int bytes) +static void ase_file_read_padding(FILE *f, int bytes) { int c; @@ -494,7 +494,7 @@ static void ase_file_read_padding (FILE *f, int bytes) fgetc (f); } -static void ase_file_write_padding (FILE *f, int bytes) +static void ase_file_write_padding(FILE *f, int bytes) { int c; @@ -502,7 +502,7 @@ static void ase_file_write_padding (FILE *f, int bytes) fputc (0, f); } -static char *ase_file_read_string (FILE *f) +static char *ase_file_read_string(FILE *f) { char *string; int c, length; @@ -522,7 +522,7 @@ static char *ase_file_read_string (FILE *f) return string; } -static void ase_file_write_string (FILE *f, const char *string) +static void ase_file_write_string(FILE *f, const char *string) { const char *p; @@ -691,35 +691,35 @@ static void ase_file_write_layer_chunk (FILE *f, Layer *layer) /* console_printf ("Layer name \"%s\" child level: %d\n", layer->name, child_level); */ } -static Frame *ase_file_read_frame_chunk (FILE *f, Sprite *sprite, int frpos, int imgtype) +static Cel *ase_file_read_cel_chunk(FILE *f, Sprite *sprite, int frpos, int imgtype) { - Frame *frame; + Cel *cel; /* read chunk data */ - int layer_index = fgetw (f); - int x = ((short)fgetw (f)); - int y = ((short)fgetw (f)); - int opacity = fgetc (f); - int frame_type = fgetw (f); + int layer_index = fgetw(f); + int x = ((short)fgetw(f)); + int y = ((short)fgetw(f)); + int opacity = fgetc(f); + int cel_type = fgetw(f); Layer *layer; - ase_file_read_padding (f, 7); + ase_file_read_padding(f, 7); - layer = sprite_index2layer (sprite, layer_index); + layer = sprite_index2layer(sprite, layer_index); if (!layer) { - console_printf (_("Frame %d didn't found layer with index %d\n"), - frpos, layer_index); + console_printf(_("Frame %d didn't found layer with index %d\n"), + frpos, layer_index); return NULL; } /* console_printf ("Layer found: %d -> %s\n", layer_index, layer->name); */ /* create the new frame */ - frame = frame_new(frpos, 0); - frame_set_position(frame, x, y); - frame_set_opacity(frame, opacity); + cel = cel_new(frpos, 0); + cel_set_position(cel, x, y); + cel_set_opacity(cel, opacity); - switch (frame_type) { + switch (cel_type) { - case ASE_FILE_RAW_FRAME: { + case ASE_FILE_RAW_CEL: { int x, y, r, g, b, a, k; Image *image; /* read width and height */ @@ -729,7 +729,7 @@ static Frame *ase_file_read_frame_chunk (FILE *f, Sprite *sprite, int frpos, int if (w > 0 && h > 0) { image = image_new (imgtype, w, h); if (!image) { - frame_free (frame); + cel_free(cel); /* not enough memory for frame's image */ return NULL; } @@ -771,64 +771,62 @@ static Frame *ase_file_read_frame_chunk (FILE *f, Sprite *sprite, int frpos, int break; } - frame->image = stock_add_image (layer->stock, image); + cel->image = stock_add_image(layer->stock, image); } break; } - case ASE_FILE_LINK_FRAME: { + case ASE_FILE_LINK_CEL: { /* read link position */ int link_frpos = fgetw (f); - Frame *link = layer_get_frame (layer, link_frpos); + Cel *link = layer_get_cel(layer, link_frpos); if (link) - frame->image = link->image; + cel->image = link->image; else { - frame_free (frame); - /* linked frame doesn't found */ + cel_free(cel); + /* linked cel doesn't found */ return NULL; } break; } - case ASE_FILE_RLE_COMPRESSED_FRAME: + case ASE_FILE_RLE_COMPRESSED_CEL: /* XXXX */ break; } - layer_add_frame (layer, frame); - return frame; + layer_add_cel(layer, cel); + return cel; } -static void ase_file_write_frame_chunk (FILE *f, Frame *frame, Layer *layer, int layer_index) +static void ase_file_write_cel_chunk(FILE *f, Cel *cel, Layer *layer, int layer_index) { - Frame *link = frame_is_link (frame, layer); - int frame_type = link ? ASE_FILE_LINK_FRAME: ASE_FILE_RAW_FRAME; + Cel *link = cel_is_link(cel, layer); + int cel_type = link ? ASE_FILE_LINK_CEL: ASE_FILE_RAW_CEL; - /* ASE_FILE_RLE_COMPRESSED_FRAME */ + ase_file_write_start_chunk(f, ASE_FILE_CHUNK_CEL); - ase_file_write_start_chunk (f, ASE_FILE_CHUNK_FRAME); + fputw(layer_index, f); + fputw(cel->x, f); + fputw(cel->y, f); + fputc(cel->opacity, f); + fputw(cel_type, f); + ase_file_write_padding(f, 7); - fputw (layer_index, f); - fputw (frame->x, f); - fputw (frame->y, f); - fputc (frame->opacity, f); - fputw (frame_type, f); - ase_file_write_padding (f, 7); + switch (cel_type) { - switch (frame_type) { - - case ASE_FILE_RAW_FRAME: { - Image *image = stock_get_image (layer->stock, frame->image); + case ASE_FILE_RAW_CEL: { + Image *image = stock_get_image(layer->stock, cel->image); int x, y, c; if (image) { /* width and height */ - fputw (image->w, f); - fputw (image->h, f); + fputw(image->w, f); + fputw(image->h, f); /* XXXX */ -/* add_progress (image->h); */ +/* add_progress(image->h); */ /* pixel data */ switch (image->imgtype) { @@ -837,122 +835,122 @@ static void ase_file_write_frame_chunk (FILE *f, Frame *frame, Layer *layer, int for (y=0; yh; y++) { for (x=0; xw; x++) { c = image->method->getpixel (image, x, y); - fputc (_rgba_getr (c), f); - fputc (_rgba_getg (c), f); - fputc (_rgba_getb (c), f); - fputc (_rgba_geta (c), f); + fputc(_rgba_getr(c), f); + fputc(_rgba_getg(c), f); + fputc(_rgba_getb(c), f); + fputc(_rgba_geta(c), f); } -/* do_progress (y); */ +/* do_progress(y); */ } break; case IMAGE_GRAYSCALE: for (y=0; yh; y++) { for (x=0; xw; x++) { - c = image->method->getpixel (image, x, y); - fputc (_graya_getk (c), f); - fputc (_graya_geta (c), f); + c = image->method->getpixel(image, x, y); + fputc(_graya_getk(c), f); + fputc(_graya_geta(c), f); } -/* do_progress (y); */ +/* do_progress(y); */ } break; case IMAGE_INDEXED: for (y=0; yh; y++) { for (x=0; xw; x++) - fputc (image->method->getpixel (image, x, y), f); + fputc(image->method->getpixel(image, x, y), f); -/* do_progress (y); */ +/* do_progress(y); */ } break; } -/* del_progress (); */ +/* del_progress(); */ } else { /* width and height */ - fputw (0, f); - fputw (0, f); + fputw(0, f); + fputw(0, f); } break; } - case ASE_FILE_LINK_FRAME: + case ASE_FILE_LINK_CEL: /* linked frame position */ - fputw (link->frpos, f); + fputw(link->frpos, f); break; - case ASE_FILE_RLE_COMPRESSED_FRAME: - /* XXXX */ + case ASE_FILE_RLE_COMPRESSED_CEL: + /* TODO */ break; } - ase_file_write_close_chunk (f); + ase_file_write_close_chunk(f); } -static Mask *ase_file_read_mask_chunk (FILE *f) +static Mask *ase_file_read_mask_chunk(FILE *f) { int c, u, v, byte; Mask *mask; /* read chunk data */ - int x = fgetw (f); - int y = fgetw (f); - int w = fgetw (f); - int h = fgetw (f); + int x = fgetw(f); + int y = fgetw(f); + int w = fgetw(f); + int h = fgetw(f); char *name; - ase_file_read_padding (f, 8); - name = ase_file_read_string (f); + ase_file_read_padding(f, 8); + name = ase_file_read_string(f); - mask = mask_new (); + mask = mask_new(); if (!mask) return NULL; if (name) - mask_set_name (mask, name); + mask_set_name(mask, name); - mask_replace (mask, x, y, w, h); + mask_replace(mask, x, y, w, h); /* read image data */ for (v=0; vbitmap, u*8+c, v, byte & (1<<(7-c))); + image_putpixel(mask->bitmap, u*8+c, v, byte & (1<<(7-c))); } return mask; } -static void ase_file_write_mask_chunk (FILE *f, Mask *mask) +static void ase_file_write_mask_chunk(FILE *f, Mask *mask) { int c, u, v, byte; - ase_file_write_start_chunk (f, ASE_FILE_CHUNK_MASK); + ase_file_write_start_chunk(f, ASE_FILE_CHUNK_MASK); - fputw (mask->x, f); - fputw (mask->y, f); - fputw (mask->w, f); - fputw (mask->h, f); - ase_file_write_padding (f, 8); + fputw(mask->x, f); + fputw(mask->y, f); + fputw(mask->w, f); + fputw(mask->h, f); + ase_file_write_padding(f, 8); /* name */ - ase_file_write_string (f, mask->name); + ase_file_write_string(f, mask->name); /* bit map */ for (v=0; vh; v++) for (u=0; u<(mask->w+7)/8; u++) { byte = 0; for (c=0; c<8; c++) - if (image_getpixel (mask->bitmap, u*8+c, v)) + if (image_getpixel(mask->bitmap, u*8+c, v)) byte |= (1<<(7-c)); - fputc (byte, f); + fputc(byte, f); } - ase_file_write_close_chunk (f); + ase_file_write_close_chunk(f); } /* returns a word (16 bits) */ -int fgetw (FILE *file) +int fgetw(FILE *file) { int b1, b2; @@ -969,7 +967,7 @@ int fgetw (FILE *file) } /* returns a dword (32 bits) */ -long fgetl (FILE *file) +long fgetl(FILE *file) { int b1, b2, b3, b4; @@ -994,7 +992,7 @@ long fgetl (FILE *file) } /* returns 0 in success or -1 in error */ -int fputw (int w, FILE *file) +int fputw(int w, FILE *file) { int b1, b2; @@ -1010,7 +1008,7 @@ int fputw (int w, FILE *file) } /* returns 0 in success or -1 in error */ -int fputl (long l, FILE *file) +int fputl(long l, FILE *file) { int b1, b2, b3, b4; @@ -1031,7 +1029,7 @@ int fputl (long l, FILE *file) #if 0 /* returns a floating point (32 bits) */ -static float fgetf (FILE *file) +static float fgetf(FILE *file) { union { float f; @@ -1044,7 +1042,7 @@ static float fgetf (FILE *file) } /* returns a floating point with double precision (64 bits) */ -static double fgetd (FILE *file) +static double fgetd(FILE *file) { union { double d; @@ -1058,7 +1056,7 @@ static double fgetd (FILE *file) } /* returns 0 in success or -1 in error */ -static int fputf (float c, FILE *file) +static int fputf(float c, FILE *file) { union { float f; @@ -1070,7 +1068,7 @@ static int fputf (float c, FILE *file) } /* returns 0 in success or -1 in error */ -static int fputd (double c, FILE *file) +static int fputd(double c, FILE *file) { union { double d; diff --git a/src/file/file.c b/src/file/file.c index 62f64cd3d..eec9c4023 100644 --- a/src/file/file.c +++ b/src/file/file.c @@ -45,7 +45,7 @@ static struct { Layer *layer; int frpos; Image *last_image; - Frame *last_frame; + Cel *last_cel; /* to save */ Image *image; } file_sequence; @@ -106,7 +106,7 @@ Image *file_sequence_image(int imgtype, int w, int h) /* create a bitmap */ - if (file_sequence.last_frame) { + if (file_sequence.last_cel) { console_printf(_("Error: called two times \"file_sequence_image ()\".\n")); return NULL; } @@ -118,7 +118,7 @@ Image *file_sequence_image(int imgtype, int w, int h) } file_sequence.last_image = image; - file_sequence.last_frame = frame_new(file_sequence.frpos++, 0); + file_sequence.last_cel = cel_new(file_sequence.frpos++, 0); return image; } @@ -198,17 +198,17 @@ Sprite *sprite_load(const char *filename) index = stock_add_image(file_sequence.layer->stock, \ file_sequence.last_image); \ \ - file_sequence.last_frame->image = index; \ + file_sequence.last_cel->image = index; \ \ - layer_add_frame(file_sequence.layer, \ - file_sequence.last_frame); \ + layer_add_cel(file_sequence.layer, \ + file_sequence.last_cel); \ \ sprite_set_palette(file_sequence.sprite, file_palette, c); \ \ old_image = file_sequence.last_image; \ \ file_sequence.last_image = NULL; \ - file_sequence.last_frame = NULL; \ + file_sequence.last_cel = NULL; \ } while (0) char buf[512], left[512], right[512]; @@ -264,7 +264,7 @@ Sprite *sprite_load(const char *filename) file_sequence.layer = NULL; file_sequence.frpos = 0; file_sequence.last_image = NULL; - file_sequence.last_frame = NULL; + file_sequence.last_cel = NULL; /* load the sequence */ c = 0; @@ -281,12 +281,12 @@ Sprite *sprite_load(const char *filename) /* for the first frame */ if (!old_image) { /* error reading the first frame */ - if ((!sprite) || (!file_sequence.last_frame)) { + if ((!sprite) || (!file_sequence.last_cel)) { if (file_sequence.last_image) image_free(file_sequence.last_image); - if (file_sequence.last_frame) - frame_free(file_sequence.last_frame); + if (file_sequence.last_cel) + cel_free(file_sequence.last_cel); if (file_sequence.sprite) { sprite_free(file_sequence.sprite); @@ -307,12 +307,12 @@ Sprite *sprite_load(const char *filename) /* for other frames */ else { /* all done (or maybe not enough memory) */ - if ((!sprite) || (!file_sequence.last_frame)) { + if ((!sprite) || (!file_sequence.last_cel)) { if (file_sequence.last_image) - image_free (file_sequence.last_image); + image_free(file_sequence.last_image); - if (file_sequence.last_frame) - frame_free (file_sequence.last_frame); + if (file_sequence.last_cel) + cel_free(file_sequence.last_cel); break; } @@ -327,12 +327,12 @@ Sprite *sprite_load(const char *filename) image_free(file_sequence.last_image); /* but add a link frame */ - file_sequence.last_frame->image = index; + file_sequence.last_cel->image = index; layer_add_frame(file_sequence.layer, - file_sequence.last_frame); + file_sequence.last_cel); file_sequence.last_image = NULL; - file_sequence.last_frame = NULL; + file_sequence.last_cel = NULL; } #else SEQUENCE_IMAGE(); diff --git a/src/file/fli.c b/src/file/fli.c index 395db863c..5e056a57a 100644 --- a/src/file/fli.c +++ b/src/file/fli.c @@ -130,7 +130,7 @@ static Sprite *load_FLI(const char *filename) /* add the new frame */ index = stock_add_image(layer->stock, image_new_copy(bmp)); - layer_add_frame(layer, frame_new(frpos_out, index)); + layer_add_cel(layer, cel_new(frpos_out, index)); /* first frame or the palette changes */ if ((frpos_in == 0) || (memcmp(omap, cmap, 768) != 0)) @@ -142,7 +142,7 @@ static Sprite *load_FLI(const char *filename) SETPAL(); /* add link */ - layer_add_frame(layer, frame_new(frpos_out, index)); + layer_add_cel(layer, cel_new(frpos_out, index)); } /* the palette and the image don't change: add duration to the last added frame */ else { diff --git a/src/file/gif.c b/src/file/gif.c index 6169bdd5e..d0a165c67 100644 --- a/src/file/gif.c +++ b/src/file/gif.c @@ -82,8 +82,8 @@ static Sprite *load_GIF(const char *filename) { GIF_ANIMATION *gif = NULL; Sprite *sprite = NULL; - Frame *frame = NULL; Layer *layer = NULL; + Cel *cel = NULL; Image *image = NULL; Image *current_image_old = NULL; Image *current_image = NULL; @@ -168,7 +168,7 @@ static Sprite *load_GIF(const char *filename) /* copy new palette to old palette */ palette_copy(opal, npal); - frame = frame_new(i, 0); + cel = cel_new(i, 0); image = image_new(IMAGE_INDEXED, #ifdef LOAD_GIF_STRUCTURE gif->frames[i].w, @@ -177,21 +177,21 @@ static Sprite *load_GIF(const char *filename) sprite->w, sprite->h #endif ); - if (!frame || !image) { - if (frame) frame_free(frame); + if (!cel || !image) { + if (cel) cel_free(cel); if (image) image_free(image); - console_printf(_("Error creating frame %d.\n"), i); + console_printf(_("Error creating cel %d.\n"), i); break; } - frame_set_position(frame, + cel_set_position(cel, #ifdef LOAD_GIF_STRUCTURE - gif->frames[i].xoff, - gif->frames[i].yoff + gif->frames[i].xoff, + gif->frames[i].yoff #else - 0, 0 + 0, 0 #endif - ); + ); image_copy(current_image_old, current_image, 0, 0); render_gif_frame(gif->frames+i, current_image, @@ -207,8 +207,8 @@ static Sprite *load_GIF(const char *filename) 0, 0 #endif ); - frame->image = stock_add_image(layer->stock, image); - layer_add_frame(layer, frame); + cel->image = stock_add_image(layer->stock, image); + layer_add_cel(layer, cel); #ifdef LOAD_GIF_STRUCTURE /* when load the GIF structure, the disposal method is ever diff --git a/src/file/tga.c b/src/file/tga.c index e554fa40a..77bce968c 100644 --- a/src/file/tga.c +++ b/src/file/tga.c @@ -369,7 +369,7 @@ static Sprite *load_TGA (const char *filename) } else { if (compressed) { - rle_tga_read16 (image->line[yc], image_width, f); + rle_tga_read16(image->line[yc], image_width, f); } else { for (x=0; x 0) { - do_tool_points (sprite, current_tool, get_fg_color (), npoints, x, y); - jfree (x); - jfree (y); + do_tool_points(sprite, current_tool, get_fg_color(), npoints, x, y); + jfree(x); + jfree(y); } - select_tool (old_current_tool->name); + select_tool(old_current_tool->name); - jfree (copy); + jfree(copy); } } @@ -198,7 +198,7 @@ static int cfg_jpeg_smooth; static int cfg_jpeg_quality; static int cfg_jpeg_method; -void ResetConfig (void) +void ResetConfig(void) { JRect rect; diff --git a/src/raster/cel.c b/src/raster/cel.c new file mode 100644 index 000000000..664dbe907 --- /dev/null +++ b/src/raster/cel.c @@ -0,0 +1,97 @@ +/* ASE - Allegro Sprite Editor + * Copyright (C) 2001-2005, 2007 David A. Capello + * + * 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 + */ + +#include "config.h" + +#ifndef USE_PRECOMPILED_HEADER + +#include "raster/cel.h" +#include "raster/layer.h" + +#endif + +Cel *cel_new(int frpos, int image) +{ + Cel *cel = (Cel *)gfxobj_new(GFXOBJ_CEL, sizeof(Cel)); + if (!cel) + return NULL; + + cel->frpos = frpos; + cel->image = image; + cel->x = 0; + cel->y = 0; + cel->opacity = 255; + + return cel; +} + +Cel *cel_new_copy(const Cel *cel) +{ + Cel *cel_copy; + + cel_copy = cel_new(cel->frpos, cel->image); + if (!cel_copy) + return NULL; + cel_set_position(cel_copy, cel->x, cel->y); + cel_set_opacity(cel_copy, cel->opacity); + + return cel_copy; +} + +void cel_free(Cel *cel) +{ + gfxobj_free((GfxObj *)cel); +} + +Cel *cel_is_link(Cel *cel, Layer *layer) +{ + Cel *link; + int frpos; + + for (frpos=0; frposfrpos; frpos++) { + link = layer_get_cel(layer, frpos); + if (link && link->image == cel->image) + return link; + } + + return NULL; +} + +/* warning, you must remove the cel from parent layer before to change + the frpos */ +void cel_set_frpos(Cel *cel, int frpos) +{ + cel->frpos = frpos; +} + +void cel_set_image(Cel *cel, int image) +{ + cel->image = image; +} + +void cel_set_position(Cel *cel, int x, int y) +{ + cel->x = x; + cel->y = y; +} + +void cel_set_opacity(Cel *cel, int opacity) +{ + cel->opacity = opacity; +} + diff --git a/src/raster/frame.h b/src/raster/cel.h similarity index 69% rename from src/raster/frame.h rename to src/raster/cel.h index cbbeea7c8..c401dd298 100644 --- a/src/raster/frame.h +++ b/src/raster/cel.h @@ -16,16 +16,16 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef RASTER_FRAME_H -#define RASTER_FRAME_H +#ifndef RASTER_CEL_H +#define RASTER_CEL_H #include "raster/gfxobj.h" struct Layer; -typedef struct Frame Frame; +typedef struct Cel Cel; -struct Frame +struct Cel { GfxObj gfxobj; int frpos; /* frame position */ @@ -34,15 +34,15 @@ struct Frame int opacity; /* opacity level */ }; -Frame *frame_new (int frpos, int image); -Frame *frame_new_copy (const Frame *frame); -void frame_free (Frame *frame); +Cel *cel_new(int frpos, int image); +Cel *cel_new_copy(const Cel *cel); +void cel_free(Cel *cel); -Frame *frame_is_link (Frame *frame, struct Layer *layer); +Cel *cel_is_link(Cel *cel, struct Layer *layer); -void frame_set_frpos (Frame *frame, int frpos); -void frame_set_image (Frame *frame, int image); -void frame_set_position (Frame *frame, int x, int y); -void frame_set_opacity (Frame *frame, int opacity); +void cel_set_frpos(Cel *cel, int frpos); +void cel_set_image(Cel *cel, int image); +void cel_set_position(Cel *cel, int x, int y); +void cel_set_opacity(Cel *cel, int opacity); #endif /* RASTER_FRAME_H */ diff --git a/src/raster/frame.c b/src/raster/frame.c deleted file mode 100644 index 13741a0af..000000000 --- a/src/raster/frame.c +++ /dev/null @@ -1,97 +0,0 @@ -/* ASE - Allegro Sprite Editor - * Copyright (C) 2001-2005, 2007 David A. Capello - * - * 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 - */ - -#include "config.h" - -#ifndef USE_PRECOMPILED_HEADER - -#include "raster/frame.h" -#include "raster/layer.h" - -#endif - -Frame *frame_new (int frpos, int image) -{ - Frame *frame = (Frame *)gfxobj_new (GFXOBJ_FRAME, sizeof(Frame)); - if (!frame) - return NULL; - - frame->frpos = frpos; - frame->image = image; - frame->x = 0; - frame->y = 0; - frame->opacity = 255; - - return frame; -} - -Frame *frame_new_copy (const Frame *frame) -{ - Frame *frame_copy; - - frame_copy = frame_new (frame->frpos, frame->image); - if (!frame_copy) - return NULL; - frame_set_position (frame_copy, frame->x, frame->y); - frame_set_opacity (frame_copy, frame->opacity); - - return frame_copy; -} - -void frame_free (Frame *frame) -{ - gfxobj_free ((GfxObj *)frame); -} - -Frame *frame_is_link (Frame *frame, Layer *layer) -{ - Frame *link; - int frpos; - - for (frpos=0; frposfrpos; frpos++) { - link = layer_get_frame (layer, frpos); - if (link && link->image == frame->image) - return link; - } - - return NULL; -} - -/* warning, you must remove the frame from parent layer before to - change the frpos */ -void frame_set_frpos (Frame *frame, int frpos) -{ - frame->frpos = frpos; -} - -void frame_set_image (Frame *frame, int image) -{ - frame->image = image; -} - -void frame_set_position (Frame *frame, int x, int y) -{ - frame->x = x; - frame->y = y; -} - -void frame_set_opacity (Frame *frame, int opacity) -{ - frame->opacity = opacity; -} - diff --git a/src/raster/gfxobj.h b/src/raster/gfxobj.h index eb0c238b5..a11b236a3 100644 --- a/src/raster/gfxobj.h +++ b/src/raster/gfxobj.h @@ -22,7 +22,7 @@ #include "jinete/base.h" enum { - GFXOBJ_FRAME, + GFXOBJ_CEL, GFXOBJ_IMAGE, GFXOBJ_LAYER_IMAGE, GFXOBJ_LAYER_SET, diff --git a/src/raster/image.h b/src/raster/image.h index c0635b0b8..81e3856cc 100644 --- a/src/raster/image.h +++ b/src/raster/image.h @@ -75,17 +75,18 @@ struct Image /* struct BITMAP *bmp; */ }; -typedef struct ImageMethods { - int (*init) (Image *image); - int (*getpixel) (const Image *image, int x, int y); - void (*putpixel) (Image *image, int x, int y, int color); - void (*clear) (Image *image, int color); - void (*copy) (Image *dst, const Image *src, int x, int y); - void (*merge) (Image *dst, const Image *src, int x, int y, int opacity, - int blend_mode); - void (*hline) (Image *image, int x1, int y, int x2, int color); - void (*rectfill) (Image *image, int x1, int y1, int x2, int y2, int color); - void (*to_allegro) (const Image *image, struct BITMAP *bmp, int x, int y); +typedef struct ImageMethods +{ + int (*init)(Image *image); + int (*getpixel)(const Image *image, int x, int y); + void (*putpixel)(Image *image, int x, int y, int color); + void (*clear)(Image *image, int color); + void (*copy)(Image *dst, const Image *src, int x, int y); + void (*merge)(Image *dst, const Image *src, int x, int y, int opacity, + int blend_mode); + void (*hline)(Image *image, int x1, int y, int x2, int color); + void (*rectfill)(Image *image, int x1, int y1, int x2, int y2, int color); + void (*to_allegro)(const Image *image, struct BITMAP *bmp, int x, int y); } ImageMethods; Image *image_new(int imgtype, int w, int h); diff --git a/src/raster/layer.c b/src/raster/layer.c index 89bac4653..080834be2 100644 --- a/src/raster/layer.c +++ b/src/raster/layer.c @@ -25,14 +25,14 @@ #include "jinete/list.h" #include "raster/blend.h" -#include "raster/frame.h" +#include "raster/cel.h" #include "raster/image.h" #include "raster/layer.h" #include "raster/stock.h" #endif -static int has_frames (Layer *layer, int frpos); +static int has_cels(Layer *layer, int frpos); #define LAYER_INIT(name_string) \ do { \ @@ -45,7 +45,7 @@ static int has_frames (Layer *layer, int frpos); layer->imgtype = 0; \ layer->blend_mode = 0; \ layer->stock = NULL; \ - layer->frames = NULL; \ + layer->cels = NULL; \ \ layer->layers = NULL; \ } while (0); @@ -62,7 +62,7 @@ Layer *layer_new(int imgtype) layer->imgtype = imgtype; layer->blend_mode = BLEND_MODE_NORMAL; layer->stock = stock_new(imgtype); - layer->frames = jlist_new(); + layer->cels = jlist_new(); return layer; } @@ -110,7 +110,7 @@ Layer *layer_new_copy(const Layer *layer) switch (layer->gfxobj.type) { case GFXOBJ_LAYER_IMAGE: { - Frame *frame_copy; + Cel *cel_copy; JLink link; layer_copy = layer_new(layer->imgtype); @@ -127,14 +127,14 @@ Layer *layer_new_copy(const Layer *layer) return NULL; } - /* copy frames */ - JI_LIST_FOR_EACH(layer->frames, link) { - frame_copy = frame_new_copy(link->data); - if (!frame_copy) { + /* copy cels */ + JI_LIST_FOR_EACH(layer->cels, link) { + cel_copy = cel_new_copy(link->data); + if (!cel_copy) { layer_free(layer_copy); return NULL; } - layer_add_frame(layer_copy, frame_copy); + layer_add_cel(layer_copy, cel_copy); } break; } @@ -180,7 +180,7 @@ Layer *layer_new_copy(const Layer *layer) Layer *layer_new_with_image(int imgtype, int x, int y, int w, int h, int frpos) { Layer *layer; - Frame *frame; + Cel *cel; Image *image; int index; @@ -206,12 +206,12 @@ Layer *layer_new_with_image(int imgtype, int x, int y, int w, int h, int frpos) /* add image in the layer stock */ index = stock_add_image(layer->stock, image); - /* create the frame */ - frame = frame_new(frpos, index); - frame_set_position (frame, x, y); + /* create the cel */ + cel = cel_new(frpos, index); + cel_set_position(cel, x, y); - /* add the frame in the layer */ - layer_add_frame(layer, frame); + /* add the cel in the layer */ + layer_add_cel(layer, cel); return layer; } @@ -227,11 +227,11 @@ void layer_free (Layer *layer) if (layer->stock) stock_free(layer->stock); - /* remove frames */ - JI_LIST_FOR_EACH(layer->frames, link) - frame_free(link->data); + /* remove cels */ + JI_LIST_FOR_EACH(layer->cels, link) + cel_free(link->data); - jlist_free(layer->frames); + jlist_free(layer->cels); break; } @@ -243,6 +243,7 @@ void layer_free (Layer *layer) } case GFXOBJ_LAYER_TEXT: + /* TODO */ /* if (layer->text) */ /* r_free (layer->text); */ @@ -256,13 +257,13 @@ void layer_free (Layer *layer) } /* returns TRUE if "layer" is a normal layer type (an image layer) */ -int layer_is_image (const Layer *layer) +int layer_is_image(const Layer *layer) { return (layer->gfxobj.type == GFXOBJ_LAYER_IMAGE) ? TRUE: FALSE; } /* returns TRUE if "layer" is a set of layers */ -int layer_is_set (const Layer *layer) +int layer_is_set(const Layer *layer) { return (layer->gfxobj.type == GFXOBJ_LAYER_SET) ? TRUE: FALSE; } @@ -290,51 +291,51 @@ Layer *layer_get_next(Layer *layer) return NULL; } -void layer_set_name (Layer *layer, const char *name) +void layer_set_name(Layer *layer, const char *name) { - strcpy (layer->name, name); + strcpy(layer->name, name); } -void layer_set_blend_mode (Layer *layer, int blend_mode) +void layer_set_blend_mode(Layer *layer, int blend_mode) { if (layer->gfxobj.type == GFXOBJ_LAYER_IMAGE) layer->blend_mode = blend_mode; } -void layer_set_parent (Layer *layer, GfxObj *gfxobj) +void layer_set_parent(Layer *layer, GfxObj *gfxobj) { layer->parent = gfxobj; } -void layer_add_frame(Layer *layer, Frame *frame) +void layer_add_cel(Layer *layer, Cel *cel) { if (layer_is_image(layer)) { JLink link; - JI_LIST_FOR_EACH(layer->frames, link) - if (((Frame *)link->data)->frpos >= frame->frpos) + JI_LIST_FOR_EACH(layer->cels, link) + if (((Cel *)link->data)->frpos >= cel->frpos) break; - jlist_insert_before(layer->frames, link, frame); + jlist_insert_before(layer->cels, link, cel); } } -void layer_remove_frame(Layer *layer, Frame *frame) +void layer_remove_cel(Layer *layer, Cel *cel) { if (layer_is_image(layer)) - jlist_remove(layer->frames, frame); + jlist_remove(layer->cels, cel); } -Frame *layer_get_frame(Layer *layer, int frpos) +Cel *layer_get_cel(Layer *layer, int frpos) { if (layer_is_image(layer)) { - Frame *frame; + Cel *cel; JLink link; - JI_LIST_FOR_EACH(layer->frames, link) { - frame = link->data; - if (frame->frpos == frpos) - return frame; + JI_LIST_FOR_EACH(layer->cels, link) { + cel = link->data; + if (cel->frpos == frpos) + return cel; } } @@ -379,21 +380,21 @@ void layer_render(Layer *layer, Image *image, int x, int y, int frpos) switch (layer->gfxobj.type) { case GFXOBJ_LAYER_IMAGE: { - Frame *frame = layer_get_frame (layer, frpos); + Cel *cel = layer_get_cel(layer, frpos); Image *src_image; - if (frame) { - if ((frame->image >= 0) && - (frame->image < layer->stock->nimage)) - src_image = layer->stock->image[frame->image]; + if (cel) { + if ((cel->image >= 0) && + (cel->image < layer->stock->nimage)) + src_image = layer->stock->image[cel->image]; else src_image = NULL; if (src_image) { image_merge(image, src_image, - frame->x + x, - frame->y + y, - MID (0, frame->opacity, 255), + cel->x + x, + cel->y + y, + MID (0, cel->opacity, 255), layer->blend_mode); } } @@ -413,16 +414,18 @@ void layer_render(Layer *layer, Image *image, int x, int y, int frpos) } } -/* returns a new layer (flat_layer) with all "layer" rendered frames - by frame from "frmin" to "frmax" (inclusive). "layer" can be a set - of layers, so the routines flatten all childs to the unique output - layer */ +/** + * Returns a new layer (flat_layer) with all "layer" rendered frame + * by frame from "frmin" to "frmax" (inclusive). "layer" can be a set + * of layers, so the routines flatten all childs to the unique output + * layer. + */ Layer *layer_flatten(Layer *layer, int imgtype, int x, int y, int w, int h, int frmin, int frmax) { Layer *flat_layer; Image *image; - Frame *frame; + Cel *cel; int frpos; flat_layer = layer_new(imgtype); @@ -432,8 +435,8 @@ Layer *layer_flatten(Layer *layer, int imgtype, layer_set_name(flat_layer, "Flat Layer"); for (frpos=frmin; frpos<=frmax; frpos++) { - /* this "frpos" has frames to render */ - if (has_frames(layer, frpos)) { + /* does this "frpos" have cels to render? */ + if (has_cels(layer, frpos)) { /* create a new image */ image = image_new(imgtype, w, h); if (!image) { @@ -441,11 +444,11 @@ Layer *layer_flatten(Layer *layer, int imgtype, return NULL; } - /* create the new frame for the output layer (add the image to + /* create the new cel for the output layer (add the image to stock too) */ - frame = frame_new(frpos, stock_add_image(flat_layer->stock, image)); - frame_set_position(frame, x, y); - if (!frame) { + cel = cel_new(frpos, stock_add_image(flat_layer->stock, image)); + cel_set_position(cel, x, y); + if (!cel) { layer_free(flat_layer); image_free(image); return NULL; @@ -454,15 +457,15 @@ Layer *layer_flatten(Layer *layer, int imgtype, /* clear the image and render this frame */ image_clear(image, 0); layer_render(layer, image, -x, -y, frpos); - layer_add_frame(flat_layer, frame); + layer_add_cel(flat_layer, cel); } } return flat_layer; } -/* returns TRUE if the "layer" (or him childs) has frames to render in frpos */ -static int has_frames(Layer *layer, int frpos) +/* returns TRUE if the "layer" (or him childs) has cels to render in frpos */ +static int has_cels(Layer *layer, int frpos) { if (!layer->readable) return FALSE; @@ -470,18 +473,19 @@ static int has_frames(Layer *layer, int frpos) switch (layer->gfxobj.type) { case GFXOBJ_LAYER_IMAGE: - return layer_get_frame(layer, frpos) ? TRUE: FALSE; + return layer_get_cel(layer, frpos) ? TRUE: FALSE; case GFXOBJ_LAYER_SET: { JLink link; - JI_LIST_FOR_EACH(layer->layers, link) - if (has_frames(link->data, frpos)) + JI_LIST_FOR_EACH(layer->layers, link) { + if (has_cels(link->data, frpos)) return TRUE; + } break; } case GFXOBJ_LAYER_TEXT: - /* XXX */ + /* TODO */ break; } diff --git a/src/raster/layer.h b/src/raster/layer.h index cca61eb51..8d632212e 100644 --- a/src/raster/layer.h +++ b/src/raster/layer.h @@ -22,7 +22,7 @@ #include "jinete/base.h" #include "raster/gfxobj.h" -struct Frame; +struct Cel; struct Image; struct Stock; @@ -40,7 +40,7 @@ struct Layer int imgtype; /* image type */ int blend_mode; /* constant blend mode */ struct Stock *stock; /* stock to get images */ - JList frames; /* list of frames */ + JList cels; /* list of cels */ /* for GFXOBJ_LAYER_SET */ JList layers; @@ -72,9 +72,9 @@ void layer_set_blend_mode(Layer *layer, int blend_mode); void layer_set_parent(Layer *layer, GfxObj *gfxobj); /* for LAYER_IMAGE */ -void layer_add_frame(Layer *layer, struct Frame *frame); -void layer_remove_frame(Layer *layer, struct Frame *frame); -struct Frame *layer_get_frame(Layer *layer, int frpos); +void layer_add_cel(Layer *layer, struct Cel *cel); +void layer_remove_cel(Layer *layer, struct Cel *cel); +struct Cel *layer_get_cel(Layer *layer, int frpos); /* for LAYER_SET */ void layer_add_layer(Layer *set, Layer *layer); diff --git a/src/raster/raster.h b/src/raster/raster.h index d6b44c909..7cab7bb28 100644 --- a/src/raster/raster.h +++ b/src/raster/raster.h @@ -22,8 +22,8 @@ #include "raster/algo.h" #include "raster/blend.h" #include "raster/brush.h" +#include "raster/cel.h" #include "raster/dirty.h" -#include "raster/frame.h" #include "raster/gfxobj.h" #include "raster/image.h" #include "raster/layer.h" diff --git a/src/raster/sprite.c b/src/raster/sprite.c index 401b3926c..e03d1725c 100644 --- a/src/raster/sprite.c +++ b/src/raster/sprite.c @@ -459,14 +459,14 @@ void sprite_add_mask (Sprite *sprite, Mask *mask) } /* removes a mask from the sprites's repository */ -void sprite_remove_mask (Sprite *sprite, Mask *mask) +void sprite_remove_mask(Sprite *sprite, Mask *mask) { /* remove the mask from the repository */ jlist_remove(sprite->repository.masks, mask); } /* returns a mask from the sprite's repository searching it by its name */ -Mask *sprite_request_mask (Sprite *sprite, const char *name) +Mask *sprite_request_mask(Sprite *sprite, const char *name) { Mask *mask; JLink link; diff --git a/src/raster/undo.c b/src/raster/undo.c index 9255d614d..4acccf361 100644 --- a/src/raster/undo.c +++ b/src/raster/undo.c @@ -26,8 +26,8 @@ #include "jinete/list.h" +#include "raster/cel.h" #include "raster/dirty.h" -#include "raster/frame.h" #include "raster/image.h" #include "raster/layer.h" #include "raster/mask.h" @@ -62,9 +62,9 @@ enum { UNDO_TYPE_REMOVE_IMAGE, UNDO_TYPE_REPLACE_IMAGE, - /* frame management */ - UNDO_TYPE_ADD_FRAME, - UNDO_TYPE_REMOVE_FRAME, + /* cel management */ + UNDO_TYPE_ADD_CEL, + UNDO_TYPE_REMOVE_CEL, /* layer management */ UNDO_TYPE_ADD_LAYER, @@ -131,11 +131,11 @@ static void redo_remove_image(UndoStream *stream, UndoChunk *chunk, int state); static void chunk_replace_image(UndoStream *stream, Stock *stock, int index); static void redo_replace_image(UndoStream *stream, UndoChunk *chunk, int state); -static void chunk_add_frame(UndoStream *stream, Layer *layer, Frame *frame); -static void redo_add_frame(UndoStream *stream, UndoChunk *chunk, int state); +static void chunk_add_cel(UndoStream *stream, Layer *layer, Cel *cel); +static void redo_add_cel(UndoStream *stream, UndoChunk *chunk, int state); -static void chunk_remove_frame(UndoStream *stream, Layer *layer, Frame *frame); -static void redo_remove_frame(UndoStream *stream, UndoChunk *chunk, int state); +static void chunk_remove_cel(UndoStream *stream, Layer *layer, Cel *cel); +static void redo_remove_cel(UndoStream *stream, UndoChunk *chunk, int state); static void chunk_add_layer(UndoStream *stream, Layer *set, Layer *layer); static void redo_add_layer(UndoStream *stream, UndoChunk *chunk, int state); @@ -165,8 +165,8 @@ static UndoAction undo_actions[] = { /* in UNDO_TYPEs order */ { "Add image", redo_add_image }, { "Remove image", redo_remove_image }, { "Replace image", redo_replace_image }, - { "Add frame", redo_add_frame }, - { "Remove frame", redo_remove_frame }, + { "Add cel", redo_add_cel }, + { "Remove cel", redo_remove_cel }, { "Add layer", redo_add_layer }, { "Remove layer", redo_remove_layer }, { "Move layer", redo_move_layer }, @@ -198,8 +198,8 @@ static void undo_chunk_write(UndoChunk *chunk, const unsigned char *buf, int siz static char *undo_chunk_read_string(UndoChunk *chunk); static void undo_chunk_write_string(UndoChunk *chunk, const char *string); -static Frame *undo_chunk_read_frame(UndoChunk *chunk); -static void undo_chunk_write_frame(UndoChunk *chunk, Frame *frame); +static Cel *undo_chunk_read_cel(UndoChunk *chunk); +static void undo_chunk_write_cel(UndoChunk *chunk, Cel *cel); static Layer *undo_chunk_read_layer(UndoChunk *chunk); static void undo_chunk_write_layer(UndoChunk *chunk, Layer *layer); @@ -746,7 +746,7 @@ static void redo_dirty(UndoStream *stream, UndoChunk *chunk, int state) /*********************************************************************** - "add_frame" + "add_image" DWORD stock ID DWORD index @@ -887,80 +887,80 @@ static void redo_replace_image(UndoStream *stream, UndoChunk *chunk, int state) /*********************************************************************** - "add_frame" + "add_cel" DWORD layer ID - DWORD frame ID + DWORD cel ID ***********************************************************************/ -void undo_add_frame(Undo *undo, Layer *layer, Frame *frame) +void undo_add_cel(Undo *undo, Layer *layer, Cel *cel) { - chunk_add_frame(undo->undo_stream, layer, frame); + chunk_add_cel(undo->undo_stream, layer, cel); update_undo(undo); } -static void chunk_add_frame(UndoStream *stream, Layer *layer, Frame *frame) +static void chunk_add_cel(UndoStream *stream, Layer *layer, Cel *cel) { - UndoChunk *chunk = undo_chunk_new(UNDO_TYPE_ADD_FRAME); + UndoChunk *chunk = undo_chunk_new(UNDO_TYPE_ADD_CEL); undo_chunk_put32(chunk, layer->gfxobj.id); - undo_chunk_put32(chunk, frame->gfxobj.id); + undo_chunk_put32(chunk, cel->gfxobj.id); undo_stream_push_chunk(stream, chunk); } -static void redo_add_frame(UndoStream *stream, UndoChunk *chunk, int state) +static void redo_add_cel(UndoStream *stream, UndoChunk *chunk, int state) { unsigned long layer_id = undo_chunk_get32(chunk); - unsigned long frame_id = undo_chunk_get32(chunk); + unsigned long cel_id = undo_chunk_get32(chunk); Layer *layer = (Layer *)gfxobj_find(layer_id); - Frame *frame = (Frame *)gfxobj_find(frame_id); + Cel *cel = (Cel *)gfxobj_find(cel_id); - if (layer && frame) { - chunk_remove_frame(stream, layer, frame); - layer_remove_frame(layer, frame); - frame_free(frame); + if (layer && cel) { + chunk_remove_cel(stream, layer, cel); + layer_remove_cel(layer, cel); + cel_free(cel); } } /*********************************************************************** - "remove_frame" + "remove_cel" DWORD layer ID - FRAME_DATA see undo_chunk_read/write_frame + CEL_DATA see undo_chunk_read/write_cel ***********************************************************************/ -void undo_remove_frame(Undo *undo, Layer *layer, Frame *frame) +void undo_remove_cel(Undo *undo, Layer *layer, Cel *cel) { - chunk_remove_frame(undo->undo_stream, layer, frame); + chunk_remove_cel(undo->undo_stream, layer, cel); update_undo(undo); } -static void chunk_remove_frame(UndoStream *stream, Layer *layer, Frame *frame) +static void chunk_remove_cel(UndoStream *stream, Layer *layer, Cel *cel) { - UndoChunk *chunk = undo_chunk_new(UNDO_TYPE_REMOVE_FRAME); + UndoChunk *chunk = undo_chunk_new(UNDO_TYPE_REMOVE_CEL); undo_chunk_put32(chunk, layer->gfxobj.id); - undo_chunk_write_frame(chunk, frame); + undo_chunk_write_cel(chunk, cel); undo_stream_push_chunk(stream, chunk); } -static void redo_remove_frame(UndoStream *stream, UndoChunk *chunk, int state) +static void redo_remove_cel(UndoStream *stream, UndoChunk *chunk, int state) { unsigned long layer_id = undo_chunk_get32(chunk); Layer *layer = (Layer *)gfxobj_find(layer_id); if (layer) { - Frame *frame = undo_chunk_read_frame(chunk); + Cel *cel = undo_chunk_read_cel(chunk); - /* ji_assert (frame); */ + /* ji_assert (cel); */ - chunk_add_frame(stream, layer, frame); - layer_add_frame(layer, frame); + chunk_add_cel(stream, layer, cel); + layer_add_cel(layer, cel); } } @@ -1383,30 +1383,30 @@ static void undo_chunk_write_string(UndoChunk *chunk, const char *string) undo_chunk_write(chunk, string, count); } -static Frame *undo_chunk_read_frame(UndoChunk *chunk) +static Cel *undo_chunk_read_cel(UndoChunk *chunk) { - unsigned long frame_id = undo_chunk_get32(chunk); + unsigned long cel_id = undo_chunk_get32(chunk); int frpos = undo_chunk_get16(chunk); int image = undo_chunk_get16(chunk); int x = (short)undo_chunk_get16(chunk); int y = (short)undo_chunk_get16(chunk); int opacity = undo_chunk_get8(chunk); - Frame *frame = frame_new(frpos, image); - frame_set_position(frame, x, y); - frame_set_opacity(frame, opacity); + Cel *cel = cel_new(frpos, image); + cel_set_position(cel, x, y); + cel_set_opacity(cel, opacity); - _gfxobj_set_id ((GfxObj *)frame, frame_id); - return frame; + _gfxobj_set_id((GfxObj *)cel, cel_id); + return cel; } -static void undo_chunk_write_frame(UndoChunk *chunk, Frame *frame) +static void undo_chunk_write_cel(UndoChunk *chunk, Cel *cel) { - undo_chunk_put32(chunk, frame->gfxobj.id); - undo_chunk_put16(chunk, frame->frpos); - undo_chunk_put16(chunk, frame->image); - undo_chunk_put16(chunk, frame->x); - undo_chunk_put16(chunk, frame->y); - undo_chunk_put8(chunk, frame->opacity); + undo_chunk_put32(chunk, cel->gfxobj.id); + undo_chunk_put16(chunk, cel->frpos); + undo_chunk_put16(chunk, cel->image); + undo_chunk_put16(chunk, cel->x); + undo_chunk_put16(chunk, cel->y); + undo_chunk_put8(chunk, cel->opacity); } static Layer *undo_chunk_read_layer(UndoChunk *chunk) @@ -1423,7 +1423,7 @@ static Layer *undo_chunk_read_layer(UndoChunk *chunk) int imgtype = undo_chunk_get8(chunk); /* imgtype */ int blend_mode = undo_chunk_get8(chunk); /* blend mode */ Stock *stock = undo_chunk_read_stock(chunk); /* stock */ - int c, frames = undo_chunk_get16(chunk); /* how many frames */ + int c, cels = undo_chunk_get16(chunk); /* how many cels */ /* create layer */ layer = layer_new(imgtype); @@ -1435,9 +1435,9 @@ static Layer *undo_chunk_read_layer(UndoChunk *chunk) stock_free(layer->stock); layer->stock = stock; - /* read frames */ - for (c=0; cblend_mode); /* blend mode */ /* stock */ undo_chunk_write_stock(chunk, layer->stock); /* stock */ - /* frames */ - undo_chunk_put16(chunk, jlist_length(layer->frames)); - JI_LIST_FOR_EACH(layer->frames, link) - undo_chunk_write_frame(chunk, link->data); + /* cels */ + undo_chunk_put16(chunk, jlist_length(layer->cels)); + JI_LIST_FOR_EACH(layer->cels, link) + undo_chunk_write_cel(chunk, link->data); break; case GFXOBJ_LAYER_SET: diff --git a/src/raster/undo.h b/src/raster/undo.h index 57947d412..d9e864a00 100644 --- a/src/raster/undo.h +++ b/src/raster/undo.h @@ -23,8 +23,8 @@ #include "raster/gfxobj.h" +struct Cel; struct Dirty; -struct Frame; struct Image; struct Layer; struct Mask; @@ -70,8 +70,8 @@ void undo_dirty(Undo *undo, struct Dirty *dirty); void undo_add_image(Undo *undo, struct Stock *stock, struct Image *image); void undo_remove_image(Undo *undo, struct Stock *stock, struct Image *image); void undo_replace_image(Undo *undo, struct Stock *stock, int index); -void undo_add_frame(Undo *undo, struct Layer *layer, struct Frame *frame); -void undo_remove_frame(Undo *undo, struct Layer *layer, struct Frame *frame); +void undo_add_cel(Undo *undo, struct Layer *layer, struct Cel *cel); +void undo_remove_cel(Undo *undo, struct Layer *layer, struct Cel *cel); void undo_add_layer(Undo *undo, struct Layer *set, struct Layer *layer); void undo_remove_layer(Undo *undo, struct Layer *layer); void undo_move_layer(Undo *undo, struct Layer *layer); diff --git a/src/script/bindings.c b/src/script/bindings.c index c205df739..8b1a7aa58 100644 --- a/src/script/bindings.c +++ b/src/script/bindings.c @@ -54,7 +54,7 @@ enum { /* graphic objects */ Type_Image, - Type_Frame, + Type_Cel, Type_Layer, Type_Mask, Type_Path, @@ -249,20 +249,20 @@ static int metatable_index(lua_State *L) break; } - case Type_Frame: { - Frame *frame = userdata->ptr; + case Type_Cel: { + Cel *cel = userdata->ptr; if (strcmp (index, "frpos") == 0) - lua_pushnumber (L, frame->frpos); + lua_pushnumber (L, cel->frpos); else if (strcmp (index, "image") == 0) - lua_pushnumber (L, frame->image); + lua_pushnumber (L, cel->image); else if (strcmp (index, "x") == 0) - lua_pushnumber (L, frame->x); + lua_pushnumber (L, cel->x); else if (strcmp (index, "y") == 0) - lua_pushnumber (L, frame->y); + lua_pushnumber (L, cel->y); else if (strcmp (index, "opacity") == 0) - lua_pushnumber (L, frame->opacity); - /* XXXX */ + lua_pushnumber (L, cel->opacity); + /* TODO */ /* else if (strcmp (index, "next") == 0) */ /* lua_pushnumber (L, ); */ /* else if (strcmp (index, "prev") == 0) */ @@ -303,9 +303,9 @@ static int metatable_index(lua_State *L) lua_pushnumber (L, layer->blend_mode); else if (strcmp (index, "stock") == 0) push_userdata (L, Type_Stock, layer->stock); - else if (strcmp (index, "frames") == 0) - push_userdata (L, Type_Frame, - jlist_first_data(layer->frames)); + else if (strcmp (index, "cels") == 0) + push_userdata(L, Type_Cel, + jlist_first_data(layer->cels)); else return 0; break; @@ -731,9 +731,9 @@ static int bind_jwidget_hook_signal (lua_State *L) #include "intl/intl.h" #include "modules/rootmenu.h" #include "util/autocrop.h" +#include "util/celmove.h" #include "util/clipbrd.h" #include "util/crop.h" -#include "util/frmove.h" #include "util/mapgen.h" #include "util/msk_file.h" #include "util/quantize.h" diff --git a/src/script/export.h b/src/script/export.h index 367434cba..5c494910b 100644 --- a/src/script/export.h +++ b/src/script/export.h @@ -223,15 +223,15 @@ void paste_from_clipboard(void); void crop_sprite(void); void crop_layer(void); -void crop_frame(void); +void crop_cel(void); -/* util/frame.c */ +/* util/celmove.c */ -void set_frame_to_handle(Layer *layer, Frame *frame); +void set_cel_to_handle(Layer *layer, Cel *cel); -void move_frame(void); -void copy_frame(void); -void link_frame(void); +void move_cel(void); +void copy_cel(void); +void link_cel(void); /* util/mapgen.c */ @@ -303,7 +303,7 @@ Image *RenderText(const char *fontname, int size, int color, const char *text); #define GFXOBJ_IMAGE #define GFXOBJ_STOCK -#define GFXOBJ_FRAME +#define GFXOBJ_CEL #define GFXOBJ_LAYER_IMAGE #define GFXOBJ_LAYER_SET #define GFXOBJ_LAYER_TEXT @@ -387,18 +387,18 @@ void image_scale(Image *dst, Image *src, int x, int y, int w, int h); void image_rotate(Image *dst, Image *src, int x, int y, int w, int h, int cx, int cy, double angle); void image_parallelogram(Image *bmp, Image *sprite, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4); -/* Frame ************************************************************/ +/* Cel ************************************************************/ -Frame *frame_new(int frpos, int image); -Frame *frame_new_copy(Frame *frame); -void frame_free(Frame *frame); +Cel *cel_new(int frpos, int image); +Cel *cel_new_copy(Cel *cel); +void cel_free(Cel *cel); -Frame *frame_is_link(Frame *frame, Layer *layer); +Cel *cel_is_link(Cel *cel, Layer *layer); -void frame_set_frpos(Frame *frame, int frpos); -void frame_set_image(Frame *frame, int image); -void frame_set_position(Frame *frame, int x, int y); -void frame_set_opacity(Frame *frame, int opacity); +void cel_set_frpos(Cel *cel, int frpos); +void cel_set_image(Cel *cel, int image); +void cel_set_position(Cel *cel, int x, int y); +void cel_set_opacity(Cel *cel, int opacity); /* Layer ************************************************************/ @@ -420,9 +420,9 @@ void layer_set_blend_mode(Layer *layer, int blend_mode); /* void layer_set_parent(Layer *layer, GfxObj *gfxobj); */ /* for LAYER_IMAGE */ -void layer_add_frame(Layer *layer, Frame *frame); -void layer_remove_frame(Layer *layer, Frame *frame); -Frame *layer_get_frame(Layer *layer, int frpos); +void layer_add_cel(Layer *layer, Cel *cel); +void layer_remove_cel(Layer *layer, Cel *cel); +Cel *layer_get_cel(Layer *layer, int frpos); /* for LAYER_SET */ void layer_add_layer(Layer *set, Layer *layer); @@ -554,8 +554,8 @@ void undo_flip(Undo *undo, Image *image, int x1, int y1, int x2, int y2, int hor void undo_add_image(Undo *undo, Stock *stock, Image *image); void undo_remove_image(Undo *undo, Stock *stock, Image *image); void undo_replace_image(Undo *undo, Stock *stock, int index); -void undo_add_frame(Undo *undo, Layer *layer, Frame *frame); -void undo_remove_frame(Undo *undo, Layer *layer, Frame *frame); +void undo_add_cel(Undo *undo, Layer *layer, Cel *cel); +void undo_remove_cel(Undo *undo, Layer *layer, Cel *cel); void undo_add_layer(Undo *undo, Layer *set, Layer *layer); void undo_remove_layer(Undo *undo, Layer *layer); void undo_move_layer(Undo *undo, Layer *layer); diff --git a/src/script/functions.c b/src/script/functions.c index 572a7fffa..8d2c53c07 100644 --- a/src/script/functions.c +++ b/src/script/functions.c @@ -26,8 +26,8 @@ #include "modules/gui.h" #include "modules/sprites.h" #include "raster/blend.h" +#include "raster/cel.h" #include "raster/image.h" -#include "raster/frame.h" #include "raster/layer.h" #include "raster/sprite.h" #include "raster/stock.h" @@ -85,7 +85,7 @@ Layer *NewLayer(const char *name, int x, int y, int w, int h) Sprite *sprite = current_sprite; Layer *layer = NULL; Image *image; - Frame *frame; + Cel *cel; int index; if (sprite && name) { @@ -114,12 +114,12 @@ Layer *NewLayer(const char *name, int x, int y, int w, int h) /* add image in the layer stock */ index = stock_add_image(layer->stock, image); - /* create a new frame in the current frpos */ - frame = frame_new(sprite->frpos, index); - frame_set_position(frame, x, y); + /* create a new cel in the current frame */ + cel = cel_new(sprite->frpos, index); + cel_set_position(cel, x, y); - /* add frame */ - layer_add_frame(layer, frame); + /* add cel */ + layer_add_cel(layer, cel); /* undo stuff */ if (undo_is_enabled(sprite->undo)) { @@ -244,13 +244,15 @@ Layer *FlattenLayers(void) JI_LIST_FOR_EACH_SAFE(sprite->set->layers, link, next) { if (link->data != flat_layer) { + Layer *old_layer = link->data; + /* undo */ if (undo_is_enabled(sprite->undo)) - undo_remove_layer(sprite->undo, link->data); + undo_remove_layer(sprite->undo, old_layer); /* remove and destroy this layer */ - layer_remove_layer(sprite->set, link->data); - layer_free(link->data); + layer_remove_layer(sprite->set, old_layer); + layer_free(old_layer); } } @@ -264,24 +266,24 @@ Layer *FlattenLayers(void) } /* ======================================= */ -/* Frame */ +/* Cel */ /* ======================================= */ -void RemoveFrame(Layer *layer, Frame *frame) +void RemoveCel(Layer *layer, Cel *cel) { Sprite *sprite = current_sprite; Image *image; - Frame *it; + Cel *it; int frpos; bool used; - if (sprite != NULL && layer_is_image(layer) && frame != NULL) { - /* find if the image that use the frame to remove, is used by - another frames */ + if (sprite != NULL && layer_is_image(layer) && cel != NULL) { + /* find if the image that use the cel to remove, is used by + another cels */ used = FALSE; for (frpos=0; frposframes; ++frpos) { - it = layer_get_frame(layer, frpos); - if (it != NULL && it != frame && it->image == frame->image) { + it = layer_get_cel(layer, frpos); + if (it != NULL && it != cel && it->image == cel->image) { used = TRUE; break; } @@ -289,18 +291,18 @@ void RemoveFrame(Layer *layer, Frame *frame) undo_open(sprite->undo); if (!used) { - /* if the image is only used by this frame, we can remove the + /* if the image is only used by this cel, we can remove the image from the stock */ - image = stock_get_image(layer->stock, frame->image); + image = stock_get_image(layer->stock, cel->image); undo_remove_image(sprite->undo, layer->stock, image); stock_remove_image(layer->stock, image); image_free(image); } - undo_remove_frame(sprite->undo, layer, frame); + undo_remove_cel(sprite->undo, layer, cel); undo_close(sprite->undo); - /* remove the frame */ - layer_remove_frame(layer, frame); - frame_free(frame); + /* remove the cel */ + layer_remove_cel(layer, cel); + cel_free(cel); } } diff --git a/src/script/functions.h b/src/script/functions.h index 502a3b751..4cbc87e82 100644 --- a/src/script/functions.h +++ b/src/script/functions.h @@ -21,7 +21,7 @@ struct Sprite; struct Layer; -struct Frame; +struct Cel; /* ======================================= */ /* Sprite */ @@ -40,9 +40,9 @@ void RemoveLayer(void); struct Layer *FlattenLayers(void); /* ======================================= */ -/* Frame */ +/* Cel */ /* ======================================= */ -void RemoveFrame(struct Layer *layer, struct Frame *frame); +void RemoveCel(struct Layer *layer, struct Cel *cel); #endif /* SCRIPT_FUNCTIONS_H */ diff --git a/src/script/genbinds.c b/src/script/genbinds.c index 31db128ee..3a80c3f6e 100644 --- a/src/script/genbinds.c +++ b/src/script/genbinds.c @@ -1127,37 +1127,37 @@ static int bind_crop_layer(lua_State *L) return 0; } -static int bind_crop_frame(lua_State *L) +static int bind_crop_cel(lua_State *L) { - crop_frame(); + crop_cel(); return 0; } -static int bind_set_frame_to_handle(lua_State *L) +static int bind_set_cel_to_handle(lua_State *L) { Layer *layer; - Frame *frame; + Cel *cel; GetUD(1, layer, Layer); - GetUD(2, frame, Frame); - set_frame_to_handle(layer, frame); + GetUD(2, cel, Cel); + set_cel_to_handle(layer, cel); return 0; } -static int bind_move_frame(lua_State *L) +static int bind_move_cel(lua_State *L) { - move_frame(); + move_cel(); return 0; } -static int bind_copy_frame(lua_State *L) +static int bind_copy_cel(lua_State *L) { - copy_frame(); + copy_cel(); return 0; } -static int bind_link_frame(lua_State *L) +static int bind_link_cel(lua_State *L) { - link_frame(); + link_cel(); return 0; } @@ -1805,87 +1805,87 @@ static int bind_image_parallelogram(lua_State *L) return 0; } -static int bind_frame_new(lua_State *L) +static int bind_cel_new(lua_State *L) { - Frame *return_value; + Cel *return_value; int frpos; int image; GetArg(1, frpos, int, number); GetArg(2, image, int, number); - return_value = frame_new(frpos, image); - push_userdata(L, Type_Frame, return_value); + return_value = cel_new(frpos, image); + push_userdata(L, Type_Cel, return_value); return 1; } -static int bind_frame_new_copy(lua_State *L) +static int bind_cel_new_copy(lua_State *L) { - Frame *return_value; - Frame *frame; - GetUD(1, frame, Frame); - return_value = frame_new_copy(frame); - push_userdata(L, Type_Frame, return_value); + Cel *return_value; + Cel *cel; + GetUD(1, cel, Cel); + return_value = cel_new_copy(cel); + push_userdata(L, Type_Cel, return_value); return 1; } -static int bind_frame_free(lua_State *L) +static int bind_cel_free(lua_State *L) { - Frame *frame; - GetUD(1, frame, Frame); - frame_free(frame); + Cel *cel; + GetUD(1, cel, Cel); + cel_free(cel); return 0; } -static int bind_frame_is_link(lua_State *L) +static int bind_cel_is_link(lua_State *L) { - Frame *return_value; - Frame *frame; + Cel *return_value; + Cel *cel; Layer *layer; - GetUD(1, frame, Frame); + GetUD(1, cel, Cel); GetUD(2, layer, Layer); - return_value = frame_is_link(frame, layer); - push_userdata(L, Type_Frame, return_value); + return_value = cel_is_link(cel, layer); + push_userdata(L, Type_Cel, return_value); return 1; } -static int bind_frame_set_frpos(lua_State *L) +static int bind_cel_set_frpos(lua_State *L) { - Frame *frame; + Cel *cel; int frpos; - GetUD(1, frame, Frame); + GetUD(1, cel, Cel); GetArg(2, frpos, int, number); - frame_set_frpos(frame, frpos); + cel_set_frpos(cel, frpos); return 0; } -static int bind_frame_set_image(lua_State *L) +static int bind_cel_set_image(lua_State *L) { - Frame *frame; + Cel *cel; int image; - GetUD(1, frame, Frame); + GetUD(1, cel, Cel); GetArg(2, image, int, number); - frame_set_image(frame, image); + cel_set_image(cel, image); return 0; } -static int bind_frame_set_position(lua_State *L) +static int bind_cel_set_position(lua_State *L) { - Frame *frame; + Cel *cel; int x; int y; - GetUD(1, frame, Frame); + GetUD(1, cel, Cel); GetArg(2, x, int, number); GetArg(3, y, int, number); - frame_set_position(frame, x, y); + cel_set_position(cel, x, y); return 0; } -static int bind_frame_set_opacity(lua_State *L) +static int bind_cel_set_opacity(lua_State *L) { - Frame *frame; + Cel *cel; int opacity; - GetUD(1, frame, Frame); + GetUD(1, cel, Cel); GetArg(2, opacity, int, number); - frame_set_opacity(frame, opacity); + cel_set_opacity(cel, opacity); return 0; } @@ -2005,35 +2005,35 @@ static int bind_layer_set_blend_mode(lua_State *L) return 0; } -static int bind_layer_add_frame(lua_State *L) +static int bind_layer_add_cel(lua_State *L) { Layer *layer; - Frame *frame; + Cel *cel; GetUD(1, layer, Layer); - GetUD(2, frame, Frame); - layer_add_frame(layer, frame); + GetUD(2, cel, Cel); + layer_add_cel(layer, cel); return 0; } -static int bind_layer_remove_frame(lua_State *L) +static int bind_layer_remove_cel(lua_State *L) { Layer *layer; - Frame *frame; + Cel *cel; GetUD(1, layer, Layer); - GetUD(2, frame, Frame); - layer_remove_frame(layer, frame); + GetUD(2, cel, Cel); + layer_remove_cel(layer, cel); return 0; } -static int bind_layer_get_frame(lua_State *L) +static int bind_layer_get_cel(lua_State *L) { - Frame *return_value; + Cel *return_value; Layer *layer; int frpos; GetUD(1, layer, Layer); GetArg(2, frpos, int, number); - return_value = layer_get_frame(layer, frpos); - push_userdata(L, Type_Frame, return_value); + return_value = layer_get_cel(layer, frpos); + push_userdata(L, Type_Cel, return_value); return 1; } @@ -2931,27 +2931,27 @@ static int bind_undo_replace_image(lua_State *L) return 0; } -static int bind_undo_add_frame(lua_State *L) +static int bind_undo_add_cel(lua_State *L) { Undo *undo; Layer *layer; - Frame *frame; + Cel *cel; GetUD(1, undo, Undo); GetUD(2, layer, Layer); - GetUD(3, frame, Frame); - undo_add_frame(undo, layer, frame); + GetUD(3, cel, Cel); + undo_add_cel(undo, layer, cel); return 0; } -static int bind_undo_remove_frame(lua_State *L) +static int bind_undo_remove_cel(lua_State *L) { Undo *undo; Layer *layer; - Frame *frame; + Cel *cel; GetUD(1, undo, Undo); GetUD(2, layer, Layer); - GetUD(3, frame, Frame); - undo_remove_frame(undo, layer, frame); + GetUD(3, cel, Cel); + undo_remove_cel(undo, layer, cel); return 0; } @@ -5682,11 +5682,11 @@ const luaL_reg bindings_routines[] = { { "paste_from_clipboard", bind_paste_from_clipboard }, { "crop_sprite", bind_crop_sprite }, { "crop_layer", bind_crop_layer }, - { "crop_frame", bind_crop_frame }, - { "set_frame_to_handle", bind_set_frame_to_handle }, - { "move_frame", bind_move_frame }, - { "copy_frame", bind_copy_frame }, - { "link_frame", bind_link_frame }, + { "crop_cel", bind_crop_cel }, + { "set_cel_to_handle", bind_set_cel_to_handle }, + { "move_cel", bind_move_cel }, + { "copy_cel", bind_copy_cel }, + { "link_cel", bind_link_cel }, { "mapgen", bind_mapgen }, { "GetImage", bind_GetImage }, { "GetImage2", bind_GetImage2 }, @@ -5745,14 +5745,14 @@ const luaL_reg bindings_routines[] = { { "image_scale", bind_image_scale }, { "image_rotate", bind_image_rotate }, { "image_parallelogram", bind_image_parallelogram }, - { "frame_new", bind_frame_new }, - { "frame_new_copy", bind_frame_new_copy }, - { "frame_free", bind_frame_free }, - { "frame_is_link", bind_frame_is_link }, - { "frame_set_frpos", bind_frame_set_frpos }, - { "frame_set_image", bind_frame_set_image }, - { "frame_set_position", bind_frame_set_position }, - { "frame_set_opacity", bind_frame_set_opacity }, + { "cel_new", bind_cel_new }, + { "cel_new_copy", bind_cel_new_copy }, + { "cel_free", bind_cel_free }, + { "cel_is_link", bind_cel_is_link }, + { "cel_set_frpos", bind_cel_set_frpos }, + { "cel_set_image", bind_cel_set_image }, + { "cel_set_position", bind_cel_set_position }, + { "cel_set_opacity", bind_cel_set_opacity }, { "layer_new", bind_layer_new }, { "layer_set_new", bind_layer_set_new }, { "layer_new_copy", bind_layer_new_copy }, @@ -5764,9 +5764,9 @@ const luaL_reg bindings_routines[] = { { "layer_get_next", bind_layer_get_next }, { "layer_set_name", bind_layer_set_name }, { "layer_set_blend_mode", bind_layer_set_blend_mode }, - { "layer_add_frame", bind_layer_add_frame }, - { "layer_remove_frame", bind_layer_remove_frame }, - { "layer_get_frame", bind_layer_get_frame }, + { "layer_add_cel", bind_layer_add_cel }, + { "layer_remove_cel", bind_layer_remove_cel }, + { "layer_get_cel", bind_layer_get_cel }, { "layer_add_layer", bind_layer_add_layer }, { "layer_remove_layer", bind_layer_remove_layer }, { "layer_move_layer", bind_layer_move_layer }, @@ -5847,8 +5847,8 @@ const luaL_reg bindings_routines[] = { { "undo_add_image", bind_undo_add_image }, { "undo_remove_image", bind_undo_remove_image }, { "undo_replace_image", bind_undo_replace_image }, - { "undo_add_frame", bind_undo_add_frame }, - { "undo_remove_frame", bind_undo_remove_frame }, + { "undo_add_cel", bind_undo_add_cel }, + { "undo_remove_cel", bind_undo_remove_cel }, { "undo_add_layer", bind_undo_add_layer }, { "undo_remove_layer", bind_undo_remove_layer }, { "undo_move_layer", bind_undo_move_layer }, @@ -6120,7 +6120,7 @@ struct _bindings_constants bindings_constants[] = { { "PI", PI }, { "GFXOBJ_IMAGE", GFXOBJ_IMAGE }, { "GFXOBJ_STOCK", GFXOBJ_STOCK }, - { "GFXOBJ_FRAME", GFXOBJ_FRAME }, + { "GFXOBJ_CEL", GFXOBJ_CEL }, { "GFXOBJ_LAYER_IMAGE", GFXOBJ_LAYER_IMAGE }, { "GFXOBJ_LAYER_SET", GFXOBJ_LAYER_SET }, { "GFXOBJ_LAYER_TEXT", GFXOBJ_LAYER_TEXT }, diff --git a/src/script/import.h b/src/script/import.h index 2f2fef263..b82341366 100644 --- a/src/script/import.h +++ b/src/script/import.h @@ -5,7 +5,7 @@ #include "jinete/base.h" #include "effect/colcurve.h" -#include "raster/frame.h" +#include "raster/cel.h" #include "raster/image.h" #include "raster/layer.h" #include "raster/sprite.h" diff --git a/src/util/celmove.c b/src/util/celmove.c new file mode 100644 index 000000000..bcb394bfd --- /dev/null +++ b/src/util/celmove.c @@ -0,0 +1,148 @@ +/* ASE - Allegro Sprite Editor + * Copyright (C) 2001-2005, 2007 David A. Capello + * + * 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 + */ + +#include "config.h" + +#ifndef USE_PRECOMPILED_HEADER + +#include "console/console.h" +#include "core/app.h" +#include "core/core.h" +#include "modules/color.h" +#include "modules/gui.h" +#include "modules/sprites.h" +#include "raster/cel.h" +#include "raster/image.h" +#include "raster/layer.h" +#include "raster/sprite.h" +#include "raster/stock.h" +#include "raster/undo.h" +#include "script/functions.h" +#include "util/celmove.h" +#include "widgets/colbar.h" + +#endif + +/* these variables indicate what cel to move (and the current_sprite + frame indicates to where move it) */ +static Layer *handle_layer = NULL; +static Cel *handle_cel = NULL; + +void set_cel_to_handle(Layer *layer, Cel *cel) +{ + handle_layer = layer; + handle_cel = cel; +} + +void move_cel(void) +{ + if (handle_layer && handle_cel && + !layer_get_cel(current_sprite->layer, + current_sprite->frpos)) { + /* move a cel in the same layer */ + if (handle_layer == current_sprite->layer) { + undo_open (current_sprite->undo); + undo_remove_cel (current_sprite->undo, handle_layer, handle_cel); + + handle_cel->frpos = current_sprite->frpos; + + undo_add_cel (current_sprite->undo, handle_layer, handle_cel); + undo_close (current_sprite->undo); + } + /* move a cel from "handle_layer" to "current_sprite->layer" */ + else { + Layer *handle_layer_bkp = handle_layer; + Cel *handle_cel_bkp = handle_cel; + + undo_open(current_sprite->undo); + copy_cel(); + RemoveCel(handle_layer_bkp, handle_cel_bkp); + undo_close(current_sprite->undo); + } + } + + handle_layer = NULL; + handle_cel = NULL; +} + +void copy_cel(void) +{ + if (handle_layer && handle_cel && + !layer_get_cel(current_sprite->layer, + current_sprite->frpos)) { + Cel *cel; + Image *image; + int image_index = 0; + + /* create a new cel with a new image (a copy of the + "handle_cel" one) from "handle_layer" to "current_sprite->layer" */ + + undo_open(current_sprite->undo); + + cel = cel_new_copy(handle_cel); + + if (stock_get_image(handle_layer->stock, handle_cel->image)) { + /* create a copy of the image */ + image = image_new_copy(stock_get_image(handle_layer->stock, + handle_cel->image)); + + /* add the image in the stock of current layer */ + image_index = stock_add_image(current_sprite->layer->stock, image); + undo_add_image(current_sprite->undo, + current_sprite->layer->stock, image); + } + + /* setup the cel */ + cel_set_frpos(cel, current_sprite->frpos); + cel_set_image(cel, image_index); + + /* add the cel in the current layer */ + undo_add_cel(current_sprite->undo, current_sprite->layer, cel); + layer_add_cel(current_sprite->layer, cel); + + undo_close(current_sprite->undo); + } + + handle_layer = NULL; + handle_cel = NULL; +} + +void link_cel(void) +{ + if (handle_layer && handle_cel && + !layer_get_cel (current_sprite->layer, + current_sprite->frpos)) { + if (handle_layer == current_sprite->layer) { + Cel *new_cel; + + /* create a new copy of the cel with the same image index but in + the new frame */ + new_cel = cel_new_copy(handle_cel); + cel_set_frpos(new_cel, current_sprite->frpos); + + undo_add_cel(current_sprite->undo, handle_layer, new_cel); + layer_add_cel(handle_layer, new_cel); + } + else { + console_printf(_("Error: You can't link a cel from other layer\n")); + } + } + + handle_layer = NULL; + handle_cel = NULL; +} diff --git a/src/util/frmove.h b/src/util/celmove.h similarity index 76% rename from src/util/frmove.h rename to src/util/celmove.h index de95418be..07093c8b2 100644 --- a/src/util/frmove.h +++ b/src/util/celmove.h @@ -16,15 +16,18 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef UTIL_FRMOVE_H -#define UTIL_FRMOVE_H +#ifndef UTIL_CELMOVE_H +#define UTIL_CELMOVE_H -void set_frame_to_handle (Layer *layer, Frame *frame); +struct Cel; +struct Layer; -void new_frame (void); -void move_frame (void); -void copy_frame (void); -void link_frame (void); +void set_cel_to_handle(struct Layer *layer, struct Cel *cel); -#endif /* UTIL_FRMOVE_H */ +void new_cel(void); +void move_cel(void); +void copy_cel(void); +void link_cel(void); + +#endif /* UTIL_CELMOVE_H */ diff --git a/src/util/clipbrd.c b/src/util/clipbrd.c index 7c07e87ce..14ea3465a 100644 --- a/src/util/clipbrd.c +++ b/src/util/clipbrd.c @@ -35,7 +35,7 @@ #include "modules/sprites.h" #include "modules/tools.h" #include "modules/tools2.h" -#include "raster/frame.h" +#include "raster/cel.h" #include "raster/image.h" #include "raster/layer.h" #include "raster/rotate.h" @@ -97,12 +97,12 @@ bool has_clipboard_image(int *w, int *h) { Sprite *clipboard = get_clipboard_sprite (); Image *image = NULL; - Frame *frame; + Cel *cel; if (clipboard) { - frame = layer_get_frame (clipboard->layer, clipboard->frpos); - if (frame) - image = stock_get_image (clipboard->layer->stock, frame->image); + cel = layer_get_cel(clipboard->layer, clipboard->frpos); + if (cel) + image = stock_get_image(clipboard->layer->stock, cel->image); } if (image) { @@ -158,7 +158,7 @@ void copy_to_clipboard(void) void paste_from_clipboard(void) { Sprite *clipboard = get_clipboard_sprite(); - Frame *frame; + Cel *cel; Image *image; Image *dest_image; int xout[4], yout[4]; @@ -173,11 +173,11 @@ void paste_from_clipboard(void) return; } - frame = layer_get_frame(clipboard->layer, clipboard->frpos); - if (!frame) + cel = layer_get_cel(clipboard->layer, clipboard->frpos); + if (!cel) return; - image = stock_get_image(clipboard->layer->stock, frame->image); + image = stock_get_image(clipboard->layer->stock, cel->image); if (!image) return; diff --git a/src/util/crop.c b/src/util/crop.c index 9ce3dd86d..ffb3eed19 100644 --- a/src/util/crop.c +++ b/src/util/crop.c @@ -25,7 +25,7 @@ #include "console/console.h" #include "modules/gui.h" #include "modules/sprites.h" -#include "raster/frame.h" +#include "raster/cel.h" #include "raster/image.h" #include "raster/layer.h" #include "raster/mask.h" @@ -77,10 +77,10 @@ void crop_layer(void) if ((sprite) && (!mask_is_empty(sprite->mask)) && (sprite->layer) && (layer_is_image(sprite->layer))) { Layer *layer = sprite->layer; - Frame *frame; + Cel *cel; Image *image; Layer *new_layer; - Frame *new_frame; + Cel *new_cel; Image *new_image; Layer *set = (Layer *)layer->parent; JLink link; @@ -94,36 +94,36 @@ void crop_layer(void) layer_set_name (new_layer, layer->name); layer_set_blend_mode (new_layer, layer->blend_mode); - JI_LIST_FOR_EACH(layer->frames, link) { - frame = link->data; - image = stock_get_image(layer->stock, frame->image); + JI_LIST_FOR_EACH(layer->cels, link) { + cel = link->data; + image = stock_get_image(layer->stock, cel->image); if (!image) continue; - new_frame = frame_new_copy(frame); - if (!new_frame) { + new_cel = cel_new_copy(cel); + if (!new_cel) { layer_free(new_layer); console_printf(_("Not enough memory\n")); return; } new_image = image_crop(image, - sprite->mask->x-frame->x, - sprite->mask->y-frame->y, + sprite->mask->x-cel->x, + sprite->mask->y-cel->y, sprite->mask->w, sprite->mask->h); if (!new_image) { layer_free(new_layer); - frame_free(new_frame); + cel_free(new_cel); console_printf(_("Not enough memory\n")); return; } - new_frame->image = stock_add_image(new_layer->stock, new_image); - new_frame->x = sprite->mask->x; - new_frame->y = sprite->mask->y; + new_cel->image = stock_add_image(new_layer->stock, new_image); + new_cel->x = sprite->mask->x; + new_cel->y = sprite->mask->y; - layer_add_frame(new_layer, new_frame); + layer_add_cel(new_layer, new_cel); } /* add the new layer */ @@ -160,34 +160,34 @@ void crop_layer(void) } } -void crop_frame(void) +void crop_cel(void) { Sprite *sprite = current_sprite; - Image *image = GetImage (); + Image *image = GetImage(); if ((sprite) && (!mask_is_empty (sprite->mask)) && (image)) { - Frame *frame = layer_get_frame (sprite->layer, sprite->frpos); + Cel *cel = layer_get_cel(sprite->layer, sprite->frpos); /* undo */ undo_open(sprite->undo); - undo_int(sprite->undo, (GfxObj *)frame, &frame->x); - undo_int(sprite->undo, (GfxObj *)frame, &frame->y); - undo_replace_image(sprite->undo, sprite->layer->stock, frame->image); + undo_int(sprite->undo, (GfxObj *)cel, &cel->x); + undo_int(sprite->undo, (GfxObj *)cel, &cel->y); + undo_replace_image(sprite->undo, sprite->layer->stock, cel->image); undo_close(sprite->undo); /* replace the image */ - sprite->layer->stock->image[frame->image] = + sprite->layer->stock->image[cel->image] = image_crop(image, - sprite->mask->x-frame->x, - sprite->mask->y-frame->y, + sprite->mask->x-cel->x, + sprite->mask->y-cel->y, sprite->mask->w, sprite->mask->h); image_free(image); /* destroy the old image */ - /* change the frame position */ - frame->x = sprite->mask->x; - frame->y = sprite->mask->y; + /* change the cel position */ + cel->x = sprite->mask->x; + cel->y = sprite->mask->y; GUI_Refresh(sprite); } @@ -200,19 +200,19 @@ static void displace_layers(Undo *undo, Layer *layer, int x, int y) switch (layer->gfxobj.type) { case GFXOBJ_LAYER_IMAGE: { - Frame *frame; + Cel *cel; JLink link; - JI_LIST_FOR_EACH(layer->frames, link) { - frame = link->data; + JI_LIST_FOR_EACH(layer->cels, link) { + cel = link->data; if (undo_is_enabled(undo)) { - undo_int(undo, (GfxObj *)frame, &frame->x); - undo_int(undo, (GfxObj *)frame, &frame->y); + undo_int(undo, (GfxObj *)cel, &cel->x); + undo_int(undo, (GfxObj *)cel, &cel->y); } - frame->x += x; - frame->y += y; + cel->x += x; + cel->y += y; } break; } @@ -225,7 +225,7 @@ static void displace_layers(Undo *undo, Layer *layer, int x, int y) } case GFXOBJ_LAYER_TEXT: - /* XXX */ + /* TODO */ break; } } diff --git a/src/util/crop.h b/src/util/crop.h index c369266e2..f9559578d 100644 --- a/src/util/crop.h +++ b/src/util/crop.h @@ -21,7 +21,7 @@ void crop_sprite(void); void crop_layer(void); -void crop_frame(void); +void crop_cel(void); #endif /* UTIL_CROP_H */ diff --git a/src/util/frmove.c b/src/util/frmove.c deleted file mode 100644 index cd9f0bf95..000000000 --- a/src/util/frmove.c +++ /dev/null @@ -1,148 +0,0 @@ -/* ASE - Allegro Sprite Editor - * Copyright (C) 2001-2005, 2007 David A. Capello - * - * 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 - */ - -#include "config.h" - -#ifndef USE_PRECOMPILED_HEADER - -#include "console/console.h" -#include "core/app.h" -#include "core/core.h" -#include "modules/color.h" -#include "modules/gui.h" -#include "modules/sprites.h" -#include "raster/frame.h" -#include "raster/image.h" -#include "raster/layer.h" -#include "raster/sprite.h" -#include "raster/stock.h" -#include "raster/undo.h" -#include "script/functions.h" -#include "util/frmove.h" -#include "widgets/colbar.h" - -#endif - -/* these variables indicate what frame to move (and the current_sprite - frame indicates to where move it) */ -static Layer *handle_layer = NULL; -static Frame *handle_frame = NULL; - -void set_frame_to_handle (Layer *layer, Frame *frame) -{ - handle_layer = layer; - handle_frame = frame; -} - -void move_frame (void) -{ - if (handle_layer && handle_frame && - !layer_get_frame (current_sprite->layer, - current_sprite->frpos)) { - /* move a frame in the same layer */ - if (handle_layer == current_sprite->layer) { - undo_open (current_sprite->undo); - undo_remove_frame (current_sprite->undo, handle_layer, handle_frame); - - handle_frame->frpos = current_sprite->frpos; - - undo_add_frame (current_sprite->undo, handle_layer, handle_frame); - undo_close (current_sprite->undo); - } - /* move a frame from "handle_layer" to "current_sprite->layer" */ - else { - Layer *handle_layer_bkp = handle_layer; - Frame *handle_frame_bkp = handle_frame; - - undo_open (current_sprite->undo); - copy_frame (); - RemoveFrame (handle_layer_bkp, handle_frame_bkp); - undo_close (current_sprite->undo); - } - } - - handle_layer = NULL; - handle_frame = NULL; -} - -void copy_frame (void) -{ - if (handle_layer && handle_frame && - !layer_get_frame (current_sprite->layer, - current_sprite->frpos)) { - Frame *frame; - Image *image; - int image_index = 0; - - /* create a new frame with a new image (a copy of the - "handle_frame" one) from "handle_layer" to "current_sprite->layer" */ - - undo_open (current_sprite->undo); - - frame = frame_new_copy (handle_frame); - - if (stock_get_image (handle_layer->stock, handle_frame->image)) { - /* create a copy of the image */ - image = image_new_copy (stock_get_image (handle_layer->stock, - handle_frame->image)); - - /* add the image in the stock of current layer */ - image_index = stock_add_image (current_sprite->layer->stock, image); - undo_add_image (current_sprite->undo, - current_sprite->layer->stock, image); - } - - /* setup the frame */ - frame_set_frpos (frame, current_sprite->frpos); - frame_set_image (frame, image_index); - - /* add the frame in the current layer */ - undo_add_frame (current_sprite->undo, current_sprite->layer, frame); - layer_add_frame (current_sprite->layer, frame); - - undo_close (current_sprite->undo); - } - - handle_layer = NULL; - handle_frame = NULL; -} - -void link_frame (void) -{ - if (handle_layer && handle_frame && - !layer_get_frame (current_sprite->layer, - current_sprite->frpos)) { - if (handle_layer == current_sprite->layer) { - Frame *new_frame; - - /* create a new copy of the frame with the same image index but in - the new frame position */ - new_frame = frame_new_copy (handle_frame); - frame_set_frpos (new_frame, current_sprite->frpos); - - undo_add_frame (current_sprite->undo, handle_layer, new_frame); - layer_add_frame (handle_layer, new_frame); - } - else { - console_printf (_("Error: You can't link a frame from other layer\n")); - } - } - - handle_layer = NULL; - handle_frame = NULL; -} diff --git a/src/util/misc.c b/src/util/misc.c index 7ee31748a..bb593e792 100644 --- a/src/util/misc.c +++ b/src/util/misc.c @@ -38,7 +38,7 @@ #include "modules/sprites.h" #include "modules/tools2.h" #include "raster/blend.h" -#include "raster/frame.h" +#include "raster/cel.h" #include "raster/image.h" #include "raster/layer.h" #include "raster/mask.h" @@ -51,39 +51,39 @@ #endif -Image *GetImage (void) +Image *GetImage(void) { Sprite *sprite = current_sprite; Image *image = NULL; if (sprite && sprite->layer && layer_is_image (sprite->layer)) { - Frame *frame = layer_get_frame (sprite->layer, sprite->frpos); + Cel *cel = layer_get_cel(sprite->layer, sprite->frpos); - if (frame) { - if ((frame->image >= 0) && - (frame->image < sprite->layer->stock->nimage)) - image = sprite->layer->stock->image[frame->image]; + if (cel) { + if ((cel->image >= 0) && + (cel->image < sprite->layer->stock->nimage)) + image = sprite->layer->stock->image[cel->image]; } } return image; } -Image *GetImage2 (Sprite *sprite, int *x, int *y, int *opacity) +Image *GetImage2(Sprite *sprite, int *x, int *y, int *opacity) { Image *image = NULL; if (sprite && sprite->layer && layer_is_image (sprite->layer)) { - Frame *frame = layer_get_frame (sprite->layer, sprite->frpos); + Cel *cel = layer_get_cel (sprite->layer, sprite->frpos); - if (frame) { - if ((frame->image >= 0) && - (frame->image < sprite->layer->stock->nimage)) - image = sprite->layer->stock->image[frame->image]; + if (cel) { + if ((cel->image >= 0) && + (cel->image < sprite->layer->stock->nimage)) + image = sprite->layer->stock->image[cel->image]; - if (x) *x = frame->x; - if (y) *y = frame->y; - if (opacity) *opacity = MID (0, frame->opacity, 255); + if (x) *x = cel->x; + if (y) *y = cel->y; + if (opacity) *opacity = MID(0, cel->opacity, 255); } } @@ -128,7 +128,7 @@ void LoadPalette(const char *filename) } /* clears the mask region in the current sprite with the BG color */ -void ClearMask (void) +void ClearMask(void) { Sprite *sprite = current_sprite; int x, y, u, v, putx, puty; @@ -184,25 +184,25 @@ void ClearMask (void) /* returns a new layer created from the current mask in the current sprite, the layer isn't added to the sprite */ -Layer *NewLayerFromMask (void) +Layer *NewLayerFromMask(void) { Sprite *sprite = current_sprite; unsigned char *address; int x, y, u, v, getx, gety; Image *dst, *src = GetImage2 (sprite, &x, &y, NULL); Layer *layer; - Frame *frame; + Cel *cel; div_t d; if (!sprite || !sprite->mask || !sprite->mask->bitmap || !src) return NULL; - dst = image_new (sprite->imgtype, sprite->mask->w, sprite->mask->h); + dst = image_new(sprite->imgtype, sprite->mask->w, sprite->mask->h); if (!dst) return NULL; /* clear the new image */ - image_clear (dst, 0); + image_clear(dst, 0); /* copy the masked zones */ for (v=0; vmask->h; v++) { @@ -224,37 +224,36 @@ Layer *NewLayerFromMask (void) } } - layer = layer_new (sprite->imgtype); + layer = layer_new(sprite->imgtype); if (!layer) { image_free (dst); return NULL; } - layer_set_blend_mode (layer, BLEND_MODE_NORMAL); + layer_set_blend_mode(layer, BLEND_MODE_NORMAL); - frame = frame_new (sprite->frpos, - stock_add_image (layer->stock, dst)); - frame_set_position (frame, sprite->mask->x, sprite->mask->y); + cel = cel_new(sprite->frpos, stock_add_image(layer->stock, dst)); + cel_set_position(cel, sprite->mask->x, sprite->mask->y); - layer_add_frame (layer, frame); + layer_add_cel(layer, cel); return layer; } -Image *GetLayerImage (Layer *layer, int *x, int *y, int frpos) +Image *GetLayerImage(Layer *layer, int *x, int *y, int frpos) { Image *image = NULL; if (layer_is_image (layer)) { - Frame *frame = layer_get_frame (layer, frpos); + Cel *cel = layer_get_cel(layer, frpos); - if (frame) { - if ((frame->image >= 0) && - (frame->image < layer->stock->nimage)) - image = layer->stock->image[frame->image]; + if (cel) { + if ((cel->image >= 0) && + (cel->image < layer->stock->nimage)) + image = layer->stock->image[cel->image]; - if (x) *x = frame->x; - if (y) *y = frame->y; + if (x) *x = cel->x; + if (y) *y = cel->y; } } @@ -269,7 +268,7 @@ int interactive_move_layer (int mode, int use_undo, int (*callback) (void)) JWidget editor = current_editor; Sprite *sprite = editor_get_sprite (editor); Layer *layer = sprite->layer; - Frame *frame = layer_get_frame (layer, sprite->frpos); + Cel *cel = layer_get_cel(layer, sprite->frpos); int start_x, new_x; int start_y, new_y; int start_b; @@ -281,11 +280,11 @@ int interactive_move_layer (int mode, int use_undo, int (*callback) (void)) int begin_y; int delay; - if (!frame) + if (!cel) return FALSE; - begin_x = frame->x; - begin_y = frame->y; + begin_x = cel->x; + begin_y = cel->y; delay = get_config_int ("Options", "MoveDelay", 250); delay = MID (0, delay, 1000); @@ -298,8 +297,8 @@ int interactive_move_layer (int mode, int use_undo, int (*callback) (void)) do { if (update) { - frame->x = begin_x - start_x + new_x; - frame->y = begin_y - start_y + new_y; + cel->x = begin_x - start_x + new_x; + cel->y = begin_y - start_y + new_y; /* update layer-bounds */ jmouse_hide(); @@ -311,10 +310,10 @@ int interactive_move_layer (int mode, int use_undo, int (*callback) (void)) status_bar_set_text (app_get_status_bar(), 0, "Pos %3d %3d Offset %3d %3d", - (int)frame->x, - (int)frame->y, - (int)(frame->x - begin_x), - (int)(frame->y - begin_y)); + (int)cel->x, + (int)cel->y, + (int)(cel->x - begin_x), + (int)(cel->y - begin_y)); jwidget_flush_redraw(app_get_status_bar()); jmanager_dispatch_messages(); @@ -344,16 +343,16 @@ int interactive_move_layer (int mode, int use_undo, int (*callback) (void)) /* the position was changed */ if (!editor_click_cancel(editor)) { if (use_undo && undo_is_enabled(sprite->undo)) { - new_x = frame->x; - new_y = frame->y; + new_x = cel->x; + new_y = cel->y; undo_open(sprite->undo); - frame->x = begin_x; - frame->y = begin_y; - undo_int(sprite->undo, (GfxObj *)frame, &frame->x); - undo_int(sprite->undo, (GfxObj *)frame, &frame->y); - frame->x = new_x; - frame->y = new_y; + cel->x = begin_x; + cel->y = begin_y; + undo_int(sprite->undo, (GfxObj *)cel, &cel->x); + undo_int(sprite->undo, (GfxObj *)cel, &cel->y); + cel->x = new_x; + cel->y = new_y; undo_close(sprite->undo); } @@ -361,8 +360,8 @@ int interactive_move_layer (int mode, int use_undo, int (*callback) (void)) } /* the position wasn't changed */ else { - frame->x = begin_x; - frame->y = begin_y; + cel->x = begin_x; + cel->y = begin_y; ret = FALSE; } diff --git a/src/util/recscr.c b/src/util/recscr.c index b277194d0..7744670f6 100644 --- a/src/util/recscr.c +++ b/src/util/recscr.c @@ -41,6 +41,7 @@ static int rec_clock; static s_fli_header *fli_header; static unsigned char *omap; static unsigned char *cmap; +static BITMAP *new_bmp; static BITMAP *old_bmp; bool is_rec_screen(void) @@ -76,11 +77,11 @@ void rec_screen_on(void) fseek(rec_file, 128, SEEK_SET); /* prepare fli header */ - fli_header = jnew (s_fli_header, 1); + fli_header = jnew(s_fli_header, 1); fli_header->filesize = 0; fli_header->frames = 0; - fli_header->width = JI_SCREEN_W; - fli_header->height = JI_SCREEN_H; + fli_header->width = SCREEN_W; + fli_header->height = SCREEN_H; fli_header->magic = HEADER_FLC; fli_header->depth = 8; fli_header->flags = 3; @@ -96,6 +97,7 @@ void rec_screen_on(void) cmap = jmalloc(768); /* prepare old bitmap */ + new_bmp = NULL; old_bmp = NULL; /* set the position of the mouse in the center of the screen */ @@ -114,8 +116,8 @@ void rec_screen_off(void) rec_file = NULL; /* free memory */ - if (old_bmp) - destroy_bitmap(old_bmp); + if (new_bmp) destroy_bitmap(new_bmp); + if (old_bmp) destroy_bitmap(old_bmp); jfree(fli_header); jfree(cmap); @@ -123,13 +125,13 @@ void rec_screen_off(void) } } -void rec_screen_poll (void) +void rec_screen_poll(void) { if (!is_interactive() || !rec_file) return; else if (ji_clock-rec_clock > JI_TICKS_PER_SEC/FRAMES_PER_SECOND) { + BITMAP *t; int old_flag; - BITMAP *bmp; int c, i; /* save the active flag which indicate if the mouse is freeze or not */ @@ -146,28 +148,31 @@ void rec_screen_poll (void) } /* save in a bitmap the visible screen portion */ - bmp = create_bitmap_ex(8, JI_SCREEN_W, JI_SCREEN_H); - if (ji_screen != screen) - jmouse_draw_cursor(); - blit(ji_screen, bmp, 0, 0, 0, 0, JI_SCREEN_W, JI_SCREEN_H); + if (!new_bmp) new_bmp = create_bitmap_ex(8, SCREEN_W, SCREEN_H); +/* if (ji_screen != screen) */ +/* jmouse_draw_cursor(); */ + blit(screen, new_bmp, 0, 0, 0, 0, SCREEN_W, SCREEN_H); /* write the frame in FLC file */ if (old_bmp) fli_write_frame(rec_file, fli_header, (unsigned char *)old_bmp->dat, omap, - (unsigned char *)bmp->dat, cmap, W_ALL); + (unsigned char *)new_bmp->dat, cmap, W_ALL); else fli_write_frame(rec_file, fli_header, NULL, NULL, - (unsigned char *)bmp->dat, cmap, W_ALL); + (unsigned char *)new_bmp->dat, cmap, W_ALL); /* copy this palette to the old one */ memcpy(omap, cmap, 768); /* fixup old bitmap */ - if (old_bmp) - destroy_bitmap(old_bmp); +/* if (old_bmp) */ +/* destroy_bitmap(old_bmp); */ - old_bmp = bmp; + /* swap bitmaps */ + t = old_bmp; + old_bmp = new_bmp; + new_bmp = t; /* restore the freeze flag by the previous value */ freeze_mouse_flag = old_flag; diff --git a/src/modules/render.c b/src/util/render.c similarity index 90% rename from src/modules/render.c rename to src/util/render.c index e4e755004..9ab9918b7 100644 --- a/src/modules/render.c +++ b/src/util/render.c @@ -37,24 +37,15 @@ static int global_opacity = 255; static Layer *selected_layer = NULL; static Image *rastering_image = NULL; -static void render_layer (Layer *layer, Image *image, - int source_x, int source_y, - int zoom, - int frpos, - void (*zoomed_func)(Image *, Image *, int, int, int, int, int)); +static void render_layer(Layer *layer, Image *image, + int source_x, int source_y, + int zoom, + int frpos, + void (*zoomed_func)(Image *, Image *, int, int, int, int, int)); -static void merge_zoomed_image1 (Image *dst, Image *src, int x, int y, int opacity, int blend_mode, int zoom); -static void merge_zoomed_image2 (Image *dst, Image *src, int x, int y, int opacity, int blend_mode, int zoom); -static void merge_zoomed_image4 (Image *dst, Image *src, int x, int y, int opacity, int blend_mode, int zoom); - -int init_module_render (void) -{ - return 0; -} - -void exit_module_render (void) -{ -} +static void merge_zoomed_image1(Image *dst, Image *src, int x, int y, int opacity, int blend_mode, int zoom); +static void merge_zoomed_image2(Image *dst, Image *src, int x, int y, int opacity, int blend_mode, int zoom); +static void merge_zoomed_image4(Image *dst, Image *src, int x, int y, int opacity, int blend_mode, int zoom); void set_preview_image (Layer *layer, Image *image) { @@ -66,10 +57,10 @@ void set_preview_image (Layer *layer, Image *image) return image, all positions must have the zoom applied (sorce_x<readable) @@ -200,13 +191,13 @@ static void render_layer (Layer *layer, Image *image, switch (layer->gfxobj.type) { case GFXOBJ_LAYER_IMAGE: { - Frame *frame = layer_get_frame (layer, frpos); + Cel *cel = layer_get_cel(layer, frpos); Image *src_image; - if (frame) { - if ((frame->image >= 0) && - (frame->image < layer->stock->nimage)) - src_image = layer->stock->image[frame->image]; + if (cel) { + if ((cel->image >= 0) && + (cel->image < layer->stock->nimage)) + src_image = layer->stock->image[cel->image]; else src_image = NULL; @@ -217,22 +208,20 @@ static void render_layer (Layer *layer, Image *image, if ((selected_layer == layer) && (rastering_image)) src_image = rastering_image; - output_opacity = MID (0, frame->opacity, 255); - output_opacity = INT_MULT (output_opacity, global_opacity, t); + output_opacity = MID(0, cel->opacity, 255); + output_opacity = INT_MULT(output_opacity, global_opacity, t); if (zoom == 0) { - image_merge - (image, src_image, - frame->x - source_x, - frame->y - source_y, - output_opacity, layer->blend_mode); + image_merge (image, src_image, + cel->x - source_x, + cel->y - source_y, + output_opacity, layer->blend_mode); } else { - (*zoomed_func) - (image, src_image, - (frame->x << zoom) - source_x, - (frame->y << zoom) - source_y, - output_opacity, layer->blend_mode, zoom); + (*zoomed_func) (image, src_image, + (cel->x << zoom) - source_x, + (cel->y << zoom) - source_y, + output_opacity, layer->blend_mode, zoom); } } } diff --git a/src/modules/render.h b/src/util/render.h similarity index 70% rename from src/modules/render.h rename to src/util/render.h index 83ac72ce2..1e1067bcc 100644 --- a/src/modules/render.h +++ b/src/util/render.h @@ -16,21 +16,18 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef MODULES_RENDER_H -#define MODULES_RENDER_H +#ifndef UTIL_RENDER_H +#define UTIL_RENDER_H struct Image; struct Layer; struct Sprite; -int init_module_render (void); -void exit_module_render (void); +void set_preview_image(struct Layer *layer, struct Image *drawable); -void set_preview_image (struct Layer *layer, struct Image *drawable); +struct Image *render_sprite(struct Sprite *sprite, + int source_x, int source_y, + int width, int height, + int frpos, int zoom); -struct Image *render_sprite (struct Sprite *sprite, - int source_x, int source_y, - int width, int height, - int frpos, int zoom); - -#endif /* MODULES_RENDER_H */ +#endif /* UTIL_RENDER_H */ diff --git a/src/util/setgfx.h b/src/util/setgfx.h index ee2d0f801..76d4a4584 100644 --- a/src/util/setgfx.h +++ b/src/util/setgfx.h @@ -19,7 +19,7 @@ #ifndef UTIL_SETGFX_H #define UTIL_SETGFX_H -int set_gfx (const char *card, int w, int h, int depth); +int set_gfx(const char *card, int w, int h, int depth); #endif /* UTIL_SETGFX_H */ diff --git a/src/util/thmbnail.c b/src/util/thmbnail.c index 58c30b45f..eefec84db 100644 --- a/src/util/thmbnail.c +++ b/src/util/thmbnail.c @@ -27,7 +27,7 @@ #include "jinete/list.h" #include "modules/palette.h" -#include "raster/frame.h" +#include "raster/cel.h" #include "raster/image.h" #include "raster/layer.h" #include "raster/stock.h" @@ -37,7 +37,7 @@ static JList thumbnails = NULL; -static Thumbnail *thumbnail_new(Frame *frame, BITMAP *bmp); +static Thumbnail *thumbnail_new(Cel *cel, BITMAP *bmp); static void thumbnail_free(Thumbnail *thumbnail); static void thumbnail_create_bitmap(BITMAP *bmp, Image *image); @@ -54,7 +54,7 @@ void destroy_thumbnails(void) } } -BITMAP *generate_thumbnail(Frame *frame, Layer *layer) +BITMAP *generate_thumbnail(Cel *cel, Layer *layer) { Thumbnail *thumbnail; BITMAP *bmp; @@ -65,19 +65,17 @@ BITMAP *generate_thumbnail(Frame *frame, Layer *layer) #if 0 /* this must be done by the caller */ { - Frame *link_frame; - - /* search original frame */ - link_frame = frame_is_link(frame, layer); - if (link_frame) - frame = link_frame; + /* search original cel */ + Cel *link_cel = cel_is_link(cel, layer); + if (link_cel) + cel = link_cel; } #endif /* find the thumbnail */ JI_LIST_FOR_EACH(thumbnails, link) { thumbnail = link->data; - if (thumbnail->frame == frame) + if (thumbnail->cel == cel) return thumbnail->bmp; } @@ -85,9 +83,9 @@ BITMAP *generate_thumbnail(Frame *frame, Layer *layer) if (!bmp) return NULL; - thumbnail_create_bitmap(bmp, stock_get_image(layer->stock, frame->image)); + thumbnail_create_bitmap(bmp, stock_get_image(layer->stock, cel->image)); - thumbnail = thumbnail_new(frame, bmp); + thumbnail = thumbnail_new(cel, bmp); if (!thumbnail) { destroy_bitmap(bmp); return NULL; @@ -97,15 +95,15 @@ BITMAP *generate_thumbnail(Frame *frame, Layer *layer) return thumbnail->bmp; } -static Thumbnail *thumbnail_new(Frame *frame, BITMAP *bmp) +static Thumbnail *thumbnail_new(Cel *cel, BITMAP *bmp) { Thumbnail *thumbnail; - thumbnail = jnew (Thumbnail, 1); + thumbnail = jnew(Thumbnail, 1); if (!thumbnail) return NULL; - thumbnail->frame = frame; + thumbnail->cel = cel; thumbnail->bmp = bmp; return thumbnail; @@ -113,16 +111,16 @@ static Thumbnail *thumbnail_new(Frame *frame, BITMAP *bmp) static void thumbnail_free(Thumbnail *thumbnail) { - destroy_bitmap (thumbnail->bmp); - jfree (thumbnail); + destroy_bitmap(thumbnail->bmp); + jfree(thumbnail); } static void thumbnail_create_bitmap(BITMAP *bmp, Image *image) { if (!image) { - clear_to_color (bmp, makecol (128, 128, 128)); - line (bmp, 0, 0, bmp->w-1, bmp->h-1, makecol (0, 0, 0)); - line (bmp, 0, bmp->h-1, bmp->w-1, 0, makecol (0, 0, 0)); + clear_to_color(bmp, makecol(128, 128, 128)); + line(bmp, 0, 0, bmp->w-1, bmp->h-1, makecol(0, 0, 0)); + line(bmp, 0, bmp->h-1, bmp->w-1, 0, makecol(0, 0, 0)); } else { int c, x, y, w, h, x1, y1; @@ -130,47 +128,47 @@ static void thumbnail_create_bitmap(BITMAP *bmp, Image *image) sx = (double)image->w / (double)bmp->w; sy = (double)image->h / (double)bmp->h; - scale = MAX (sx, sy); + scale = MAX(sx, sy); w = image->w / scale; h = image->h / scale; - w = MIN (bmp->w, w); - h = MIN (bmp->h, h); + w = MIN(bmp->w, w); + h = MIN(bmp->h, h); x1 = bmp->w/2 - w/2; y1 = bmp->h/2 - h/2; - x1 = MAX (0, x1); - y1 = MAX (0, y1); + x1 = MAX(0, x1); + y1 = MAX(0, y1); - clear_to_color (bmp, makecol (128, 128, 128)); + clear_to_color(bmp, makecol(128, 128, 128)); switch (image->imgtype) { case IMAGE_RGB: for (y=0; yeffect = effect; - jwidget_add_hook (widget, preview_type (), preview_msg_proc, preview); - jwidget_hide (widget); + jwidget_add_hook(widget, preview_type(), preview_msg_proc, preview); + jwidget_hide(widget); return widget; } -int preview_type (void) +int preview_type(void) { static int type = 0; if (!type) - type = ji_register_widget_type (); + type = ji_register_widget_type(); return type; } -void preview_restart (JWidget widget) +void preview_restart(JWidget widget) { - effect_begin_for_preview (preview_get_effect (widget)); + effect_begin_for_preview(preview_get_effect(widget)); } -Effect *preview_get_effect (JWidget widget) +Effect *preview_get_effect(JWidget widget) { - return ((Preview *)jwidget_get_data (widget, preview_type ()))->effect; + return ((Preview *)jwidget_get_data(widget, preview_type()))->effect; } -static bool preview_msg_proc (JWidget widget, JMessage msg) +static bool preview_msg_proc(JWidget widget, JMessage msg) { - Effect *effect = preview_get_effect (widget); + Effect *effect = preview_get_effect(widget); switch (msg->type) { case JM_DESTROY: - jfree (jwidget_get_data (widget, preview_type ())); + jfree(jwidget_get_data(widget, preview_type())); break; case JM_OPEN: - set_preview_image (effect->sprite->layer, effect->dst); + set_preview_image(effect->sprite->layer, effect->dst); break; case JM_CLOSE: - set_preview_image (NULL, NULL); + set_preview_image(NULL, NULL); break; case JM_IDLE: if (effect) { - if (effect_apply_step (effect)) - effect_flush (effect); + if (effect_apply_step(effect)) + effect_flush(effect); } break; } diff --git a/src/widgets/statebar.c b/src/widgets/statebar.c index 056596a8f..f4667a3f8 100644 --- a/src/widgets/statebar.c +++ b/src/widgets/statebar.c @@ -33,7 +33,7 @@ #include "modules/gui.h" #include "modules/palette.h" #include "modules/sprites.h" -#include "raster/frame.h" +#include "raster/cel.h" #include "raster/layer.h" #include "raster/sprite.h" #include "script/script.h" @@ -349,11 +349,11 @@ static int slider_change_signal(JWidget widget, int user_data) if (sprite) { if ((sprite->layer) && (sprite->layer->gfxobj.type == GFXOBJ_LAYER_IMAGE)) { - Frame *frame = layer_get_frame (sprite->layer, sprite->frpos); + Cel *cel = layer_get_cel(sprite->layer, sprite->frpos); - if (frame) { + if (cel) { /* update the opacity */ - frame->opacity = jslider_get_value (widget); + cel->opacity = jslider_get_value(widget); /* update the editors */ GUI_Refresh(sprite); @@ -410,30 +410,30 @@ static void button_command(JWidget widget, void *data) static void update_from_layer(StatusBar *status_bar) { Sprite *sprite = current_sprite; - Frame *frame; + Cel *cel; /* layer button */ if (sprite && sprite->layer) { char buf[512]; - usprintf (buf, "[%d] %s", sprite->frpos, sprite->layer->name); - jwidget_set_text (status_bar->b_layer, buf); - jwidget_enable (status_bar->b_layer); + usprintf(buf, "[%d] %s", sprite->frpos, sprite->layer->name); + jwidget_set_text(status_bar->b_layer, buf); + jwidget_enable(status_bar->b_layer); } else { - jwidget_set_text (status_bar->b_layer, "Nothing"); - jwidget_disable (status_bar->b_layer); + jwidget_set_text(status_bar->b_layer, "Nothing"); + jwidget_disable(status_bar->b_layer); } /* opacity layer */ if (sprite && sprite->layer && sprite->layer->gfxobj.type == GFXOBJ_LAYER_IMAGE && - (frame = layer_get_frame (sprite->layer, sprite->frpos))) { - jslider_set_value (status_bar->slider, MID (0, frame->opacity, 255)); - jwidget_enable (status_bar->slider); + (cel = layer_get_cel(sprite->layer, sprite->frpos))) { + jslider_set_value(status_bar->slider, MID(0, cel->opacity, 255)); + jwidget_enable(status_bar->slider); } else { - jslider_set_value (status_bar->slider, 0); - jwidget_disable (status_bar->slider); + jslider_set_value(status_bar->slider, 0); + jwidget_disable(status_bar->slider); } }