Renamed "frame" to "cel"

This commit is contained in:
David Capello 2007-11-16 20:49:40 +00:00
parent 40e3a27ce7
commit 429d6a83ef
69 changed files with 1285 additions and 1495 deletions

View File

@ -1,3 +1,10 @@
2007-11-16 David A. Capello <dacap@users.sourceforge.net>
* 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 <dacap@users.sourceforge.net> 2007-11-14 David A. Capello <dacap@users.sourceforge.net>
* INSTALL.txt: Clarified "COMPILATION" section (thanks to Manuel * INSTALL.txt: Clarified "COMPILATION" section (thanks to Manuel

View File

@ -1,7 +1,7 @@
ASE - Allegro Sprite Editor 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 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 http://sourceforge.net/project/showfiles.php?group_id=20848
También, si desea obtener la última versión en desarrollo de ASE desde el 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 es la que más actualizada está con respecto a las herramientas, la puede
explorar archivo por archivo en esta dirección: 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: de la siguiente forma:
1) Debemos ingresar al repositorio de forma anónima (cuando le pregunte svn checkout svn co https://ase.svn.sourceforge.net/svnroot/ase/trunk ase
por la contraseña, solamente presione <enter>):
cvs -d :pserver:anonymous@cvs.ase.sourceforge.net:/cvsroot/ase login AVISO: Cuando obtenga la versión SVN, no borre los directorios .svn
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
ni el contenido dentro de ellos, ya que es para uso interno del 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

View File

@ -1,7 +1,7 @@
ASE - Allegro Sprite Editor 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 See the "AUTHORS.txt" file for a complete list of contributors
@ -126,25 +126,12 @@ UPDATES
http://ase.svn.sourceforge.net/viewvc/ase/ http://ase.svn.sourceforge.net/viewvc/ase/
Or you can download it completelly to your disk with a program which 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 svn checkout svn co https://ase.svn.sourceforge.net/svnroot/ase/trunk ase
asked for the password, just press <enter>):
cvs -d :pserver:anonymous@cvs.ase.sourceforge.net:/cvsroot/ase login WARNING: When you obtain the SVN version, don't remove the .svn
directories, they are for exclusive use of the svn program.
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.
=================================== ===================================
@ -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

View File

@ -45,13 +45,17 @@ High priority work
Wish-list Wish-list
--------- ---------
- my wish-list: - dacap wish-list:
+ keyboard shortcuts for snap-to-grid and view-grid + keyboard shortcuts for snap-to-grid and view-grid
+ different snap-to-grid for paste operation + different snap-to-grid for paste operation
+ better dialogs: widder buttons, more borders. + better dialogs: widder buttons, more borders.
+ better film editor + better film editor
+ "middle mouse button" for the film editor. + "middle mouse button" for the film editor.
+ don't use LINKs when load a sequence of bitmaps. + 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). - add menu customization through UI (Tools/Customize).
- Mateusz Czaplinski ideas: - Mateusz Czaplinski ideas:
+ when move selections, will be good the possibility to see relative + when move selections, will be good the possibility to see relative

2
all.h
View File

@ -80,7 +80,6 @@
#include "modules/gui.h" #include "modules/gui.h"
#include "modules/palette.h" #include "modules/palette.h"
#include "modules/recent.h" #include "modules/recent.h"
#include "modules/render.h"
#include "modules/rootmenu.h" #include "modules/rootmenu.h"
#include "modules/sprites.h" #include "modules/sprites.h"
#include "modules/tools.h" #include "modules/tools.h"
@ -120,6 +119,7 @@
#include "util/pic_file.h" #include "util/pic_file.h"
#include "util/quantize.h" #include "util/quantize.h"
#include "util/recscr.h" #include "util/recscr.h"
#include "util/render.h"
#include "util/scrshot.h" #include "util/scrshot.h"
#include "util/setgfx.h" #include "util/setgfx.h"
#include "util/thmbnail.h" #include "util/thmbnail.h"

View File

@ -25,7 +25,7 @@
/* general information */ /* general information */
#define PACKAGE "ase" #define PACKAGE "ase"
#define VERSION "0.6" #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 BUGREPORT "ase-help@lists.sourceforge.net"
#define COPYRIGHT "Copyright (C) 2001-2005, 2007 David A. Capello" #define COPYRIGHT "Copyright (C) 2001-2005, 2007 David A. Capello"

View File

@ -40,9 +40,9 @@
<!-- layer --> <!-- layer -->
<key command="layer_properties" shortcut="Shift+P" /> <key command="layer_properties" shortcut="Shift+P" />
<key command="new_layer" shortcut="Shift+N" /> <key command="new_layer" shortcut="Shift+N" />
<!-- frame --> <!-- cel -->
<key command="frame_properties" shortcut="Shift+Ctrl+P" /> <key command="cel_properties" shortcut="Shift+Ctrl+P" />
<key command="new_frame" shortcut="Ctrl+Shift+N" /> <key command="new_cel" shortcut="Ctrl+Shift+N" />
<!-- mask --> <!-- mask -->
<key command="mask_all" shortcut="Ctrl+A" /> <key command="mask_all" shortcut="Ctrl+A" />
<key command="deselect_mask" shortcut="Ctrl+D" /> <key command="deselect_mask" shortcut="Ctrl+D" />
@ -122,7 +122,7 @@
<item command="preview_tiled" name="&Tiled" /> <item command="preview_tiled" name="&Tiled" />
</menu> </menu>
</menu> </menu>
<menu name="Spr&ite"> <menu name="&Sprite">
<item command="sprite_properties" name="&Properties" /> <item command="sprite_properties" name="&Properties" />
<separator /> <separator />
<item command="duplicate_sprite" name="&Duplicate" /> <item command="duplicate_sprite" name="&Duplicate" />
@ -143,18 +143,18 @@
<item command="flatten_layers" name="&Flatten" /> <item command="flatten_layers" name="&Flatten" />
<item command="crop_layer" name="Cr&op" /> <item command="crop_layer" name="Cr&op" />
</menu> </menu>
<menu name="F&rame" id="frame_popup"> <menu name="&Cel" id="cel_popup">
<item command="frame_properties" name="&Properties" /> <item command="cel_properties" name="&Properties" />
<item command="remove_frame" name="&Remove" /> <item command="remove_cel" name="&Remove" />
<separator /> <separator />
<item command="new_frame" name="&New" /> <item command="new_cel" name="&New" />
<item command="move_frame" name="&Move" /> <item command="move_cel" name="&Move" />
<item command="copy_frame" name="&Copy" /> <item command="copy_cel" name="&Copy" />
<item command="link_frame" name="&Link" /> <item command="link_cel" name="&Link" />
<separator /> <separator />
<item command="crop_frame" name="Cr&op" /> <item command="crop_cel" name="Cr&op" />
</menu> </menu>
<menu name="&Select"> <menu name="&Mask">
<item command="mask_all" name="&All" /> <item command="mask_all" name="&All" />
<item command="deselect_mask" name="&Deselect" /> <item command="deselect_mask" name="&Deselect" />
<item command="reselect_mask" name="&Reselect" /> <item command="reselect_mask" name="&Reselect" />

View File

@ -1,211 +0,0 @@
<!-- Copyright (C) 2007 by David A. Capello -->
<gui>
<keyboard>
<!-- file -->
<key command="new_file" shortcut="Ctrl+N" />
<key command="open_file" shortcut="Ctrl+O" />
<key command="open_file" shortcut="F3" />
<key command="save_file" shortcut="Ctrl+S" />
<key command="save_file" shortcut="F2" />
<key command="save_file_as" shortcut="Shift+Ctrl+S" />
<key command="save_file_as" shortcut="Shift+F2" />
<key command="close_file" shortcut="Ctrl+W" />
<key command="close_all_files" shortcut="Shift+Ctrl+W" />
<key command="screen_shot" shortcut="F12" />
<key command="exit" shortcut="Ctrl+Q" />
<key command="exit" shortcut="Esc" />
<!-- edit -->
<key command="undo" shortcut="Ctrl+Z" /> <key command="undo" shortcut="Ctrl+U" />
<key command="redo" shortcut="Ctrl+R" />
<key command="cut" shortcut="Ctrl+X" /> <key command="cut" shortcut="Shift+Del" />
<key command="copy" shortcut="Ctrl+C" /> <key command="copy" shortcut="Ctrl+Ins" />
<key command="paste" shortcut="Ctrl+V" /> <key command="paste" shortcut="Shift+Ins" />
<key command="clear" shortcut="Ctrl+B" /> <key command="clear" shortcut="Ctrl+Del" />
<key command="quick_move" shortcut="Shift+M" />
<key command="quick_copy" shortcut="Shift+C" />
<key command="flip_horizontal" shortcut="Shift+H" />
<key command="flip_vertical" shortcut="Shift+V" />
<key command="replace_color" shortcut="Shift+R" />
<key command="invert_color" shortcut="Ctrl+I" />
<!-- view -->
<key command="refresh" shortcut="F5" />
<key command="advanced_mode" shortcut="A" />
<key command="make_unique_editor" shortcut="Ctrl+1" />
<key command="split_editor_vertically" shortcut="Ctrl+2" />
<key command="split_editor_horizontally" shortcut="Ctrl+3" />
<key command="close_editor" shortcut="Ctrl+4" />
<key command="preview_fit_to_screen" shortcut="F6" />
<key command="preview_normal" shortcut="F7" />
<key command="preview_tiled" shortcut="F8" />
<!-- sprite -->
<key command="sprite_properties" shortcut="Ctrl+P" />
<!-- layer -->
<key command="layer_properties" shortcut="Shift+P" />
<key command="new_layer" shortcut="Shift+N" />
<!-- frame -->
<key command="frame_properties" shortcut="Shift+Ctrl+P" />
<key command="new_frame" shortcut="Ctrl+Shift+N" />
<!-- mask -->
<key command="mask_all" shortcut="Ctrl+A" />
<key command="deselect_mask" shortcut="Ctrl+D" />
<key command="reselect_mask" shortcut="Shift+Ctrl+D" />
<key command="invert_mask" shortcut="Shift+Ctrl+I" />
<!-- tools -->
<key command="configure_tools" shortcut="C" />
<key command="marker_tool" shortcut="M" />
<key command="dots_tool" shortcut="D" />
<key command="pencil_tool" shortcut="P" />
<key command="brush_tool" shortcut="B" />
<key command="spray_tool" shortcut="S" />
<key command="floodfill_tool" shortcut="F" />
<key command="line_tool" shortcut="L" />
<key command="bezier_tool" shortcut="V" />
<key command="rectangle_tool" shortcut="R" />
<key command="ellipse_tool" shortcut="E" />
<key command="film_editor" shortcut="Tab" />
<key command="palette_editor" shortcut="F4" />
<key command="convolution_matrix" shortcut="F9" />
<key command="color_curve" shortcut="Ctrl+M" />
<key command="color_curve" shortcut="F10" />
<key command="run_script" shortcut="Ctrl+0" />
<key command="tips" shortcut="F1" />
<key command="options" shortcut="Shift+Ctrl+O" />
</keyboard>
<menu id="main_menu">
<menu name="&File">
<item command="new_file" name="&New" />
<item command="open_file" name="&Open" />
<item id="recent_list" name="Open &Recent" />
<separator />
<item command="save_file" name="&Save" />
<item command="save_file_as" name="Save &As..." />
<item command="close_file" name="&Close" />
<item command="close_all_files" name="Close All" />
<separator />
<menu name="Ca&pture">
<item command="screen_shot" name="Screen Shot" />
<item command="record_screen" name="Record Screen" />
</menu>
<separator />
<item command="about" name="About" />
<item command="exit" name="E&xit" />
</menu>
<menu name="&Edit">
<item command="undo" name="&Undo" />
<item command="redo" name="&Redo" />
<separator />
<item command="cut" name="Cu&t" />
<item command="copy" name="&Copy" />
<item command="paste" name="&Paste" />
<item command="clear" name="C&lear" />
<separator />
<item command="quick_move" name="Quick &Move" />
<item command="quick_copy" name="Quick C&opy" />
<separator />
<item command="flip_horizontal" name="Flip &Horizontal" />
<item command="flip_vertical" name="Flip &Vertical" />
<separator />
<item command="replace_color" name="R&eplace Color" />
<item command="invert_color" name="&Invert" />
</menu>
<menu name="&View">
<item command="refresh" name="&Refresh" />
<item command="configure_screen" name="Configure &Screen" />
<item command="advanced_mode" name="&Advanced Mode" />
<menu name="&Editor">
<item command="make_unique_editor" name="Make &Unique" />
<separator />
<item command="split_editor_vertically" name="Split &Vertically" />
<item command="split_editor_horizontally" name="Split &Horizontally" />
<separator />
<item command="close_editor" name="&Close" />
</menu>
<separator />
<menu name="&Preview">
<item command="preview_fit_to_screen" name="&Fit to screen" />
<item command="preview_normal" name="&Normal" />
<item command="preview_tiled" name="&Tiled" />
</menu>
</menu>
<menu name="Spr&ite">
<item command="sprite_properties" name="&Properties" />
<separator />
<item command="duplicate_sprite" name="&Duplicate" />
<item command="change_image_type" name="Image &Type" />
<separator />
<item command="crop_sprite" name="Cr&op" />
<item command="autocrop_sprite" name="&Autocrop" />
</menu>
<menu name="&Layer" id="layer_popup">
<item command="layer_properties" name="&Properties" />
<separator />
<item command="new_layer" name="&New" />
<item command="new_layer_set" name="New &Set" />
<item command="remove_layer" name="&Remove" />
<separator />
<item command="duplicate_layer" name="&Duplicate" />
<item command="merge_down_layer" name="&Merge Down" />
<item command="flatten_layers" name="&Flatten" />
<item command="crop_layer" name="Cr&op" />
</menu>
<menu name="F&rame" id="frame_popup">
<item command="frame_properties" name="&Properties" />
<item command="remove_frame" name="&Remove" />
<separator />
<item command="new_frame" name="&New" />
<item command="move_frame" name="&Move" />
<item command="copy_frame" name="&Copy" />
<item command="link_frame" name="&Link" />
<separator />
<item command="crop_frame" name="Cr&op" />
</menu>
<menu name="&Select">
<item command="mask_all" name="&All" />
<item command="deselect_mask" name="&Deselect" />
<item command="reselect_mask" name="&Reselect" />
<item command="invert_mask" name="&Inverse" />
<separator />
<item command="mask_by_color" name="&Color Range" />
<separator />
<item command="load_mask" name="&Load from MSK file" />
<item command="save_mask" name="&Save to MSK file" />
</menu>
<menu name="&Tools">
<menu name="&Drawing Tool">
<item command="configure_tools" name="&Configure" />
<separator />
<item command="marker_tool" name="&Marker" />
<item command="dots_tool" name="&Dots" />
<item command="pencil_tool" name="&Pencil" />
<item command="brush_tool" name="&Brush" />
<item command="spray_tool" name="&Spray" />
<item command="floodfill_tool" name="&Floodfill" />
<separator />
<item command="line_tool" name="&Line" />
<!-- <item command="bezier_tool" name="&Bezier" /> -->
<item command="rectangle_tool" name="&Rectangle" />
<item command="ellipse_tool" name="&Ellipse" />
<!-- <item command="oval_tool" name="&Oval" /> -->
</menu>
<item command="film_editor" name="&Film Editor" />
<item command="palette_editor" name="&Palette Editor" />
<separator />
<menu name="F&X" id="fx_popup">
<item command="convolution_matrix" name="Convolution &Matrix" />
<item command="color_curve" name="&Color Curve" />
<separator />
<item command="despeckle" name="&Despeckle (median filter)" />
</menu>
<!-- <item command="draw_text" name="Draw &Text" /> -->
<!-- <item command="play_flic" name="Pla&y FLI/FLC File" /> -->
<!-- <item command="mapgen" name="&MapGen" /> -->
<menu name="Scripting">
<item command="run_script" name="Run &Script" />
</menu>
<separator />
<item command="tips" name="T&ips" />
<item command="options" name="&Options" />
</menu>
<item id="sprite_list" name="L&ist" />
</menu>
</gui>

View File

@ -31,14 +31,24 @@ STRING length=WORD (how many characters to read next)
2. Introduction 2. Introduction
======================================== ========================================
The format is the same as FLI/FLC files, with a different magic number The format is much like FLI/FLC files, but with different magic number
and a different set of chunks (but the new chunks doesn't collided and differents chunks. Also, the color depth can be 8, 16 or 32 for
with the FLI/FLC ones). Also, the color depth can be 8, 16 or 32 for Indexed, Grayscale and RGB respectively, and the images are more easy
Indexed, Grayscale and RGB respectively. The palette isn't included to read (there aren't differences with old frames). The palette isn't
for color depths more than 8, but when the sprite is 8 bpp, the included for color depths more than 8, but when the sprite is 8 bpp,
palette is in an old FLI color chunk (type=11). See fli.txt for the palette is in an old FLI color chunk (type=11). See fli.txt for
details. 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 3. Header
@ -55,8 +65,8 @@ WORD Height in pixels
WORD Color depth (bits per pixel) WORD Color depth (bits per pixel)
DWORD Flags (must be 0) DWORD Flags (must be 0)
WORD Speed (milliseconds between frame, like in FLC files) WORD Speed (milliseconds between frame, like in FLC files)
!!! This field is deprecated, you should use the DEPRECATED!!!: you should use the frame duration
frame duration field from each frame header. field from each frame header
DWORD Set be 0 DWORD Set be 0
DWORD Set be 0 DWORD Set be 0
BYTE[100] For future (set to zero) BYTE[100] For future (set to zero)
@ -71,8 +81,8 @@ header of 16 bytes:
DWORD Bytes in this frame DWORD Bytes in this frame
WORD Magic number (always 0xF1FA) WORD Magic number (always 0xF1FA)
WORD Number of "chunks" in frame WORD Number of "chunks" in this frame
WORD Frame duration (in milliseconds) [NEW FIELD!!!] WORD Frame duration (in milliseconds) [NEW FIELD!!!]
BYTE[6] For future (set to zero) BYTE[6] For future (set to zero)
Then each chunk format is: Then each chunk format is:
@ -120,37 +130,37 @@ Layer Chunk (0x2004)
STRING Layer name STRING Layer name
Frame Chunk (0x2005) Cel Chunk (0x2005)
---------------------------------------- ----------------------------------------
This chunk determine where to put a real ASE frame in the specified This chunk determine where to put a cel in the specified
layer. layer/frame.
WORD Layer index (see NOTE.2) WORD Layer index (see NOTE.2)
WORD X position WORD X position
WORD Y position WORD Y position
BYTE Opacity level BYTE Opacity level
WORD Frame type WORD Cel type
BYTE[7] For future (set to zero) BYTE[7] For future (set to zero)
+ For frame type = 0 (raw image): + For cel type = 0 (Raw Cel):
WORD Width in pixels WORD Width in pixels
WORD Height in pixels WORD Height in pixels
BYTE[] Pixel data (see NOTE.3) BYTE[] Pixel data (see NOTE.3)
+ For frame type = 1 (linked image): + For cel type = 1 (Linked Cel):
WORD Frame position to link with 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 Width in pixels
WORD Height in pixels WORD Height in pixels
XXXXX -todo- XXXXX -todo-
Mask Chunk (0x2016) Mask Chunk (0x2016) DEPRECATED!!!
---------------------------------------- ----------------------------------------
WORD X position WORD X position
@ -213,5 +223,5 @@ File Format Changes
How to read both formats (old and new one)? You should set all How to read both formats (old and new one)? You should set all
frames durations to the "speed" field read from the main ASE frames durations to the "speed" field read from the main ASE
header. Then, if you found a frame with the frame-duration header. Then, if you found a frame with the frame-duration
field > 0, you should update the frame's duration with that field > 0, you should update the duration of the frame with
value. that value.

View File

@ -119,7 +119,6 @@ ASE_SOURCES = \
src/modules/gui.c \ src/modules/gui.c \
src/modules/palette.c \ src/modules/palette.c \
src/modules/recent.c \ src/modules/recent.c \
src/modules/render.c \
src/modules/rootmenu.c \ src/modules/rootmenu.c \
src/modules/sprites.c \ src/modules/sprites.c \
src/modules/tools.c \ src/modules/tools.c \
@ -128,8 +127,8 @@ ASE_SOURCES = \
src/raster/algofill.c \ src/raster/algofill.c \
src/raster/blend.c \ src/raster/blend.c \
src/raster/brush.c \ src/raster/brush.c \
src/raster/cel.c \
src/raster/dirty.c \ src/raster/dirty.c \
src/raster/frame.c \
src/raster/gfxobj.c \ src/raster/gfxobj.c \
src/raster/image.c \ src/raster/image.c \
src/raster/layer.c \ src/raster/layer.c \
@ -145,11 +144,11 @@ ASE_SOURCES = \
src/script/script.c \ src/script/script.c \
src/util/autocrop.c \ src/util/autocrop.c \
src/util/boundary.c \ src/util/boundary.c \
src/util/celmove.c \
src/util/clipbrd.c \ src/util/clipbrd.c \
src/util/col_file.c \ src/util/col_file.c \
src/util/crop.c \ src/util/crop.c \
src/util/filetoks.c \ src/util/filetoks.c \
src/util/frmove.c \
src/util/hash.c \ src/util/hash.c \
src/util/mapgen.c \ src/util/mapgen.c \
src/util/misc.c \ src/util/misc.c \
@ -157,6 +156,7 @@ ASE_SOURCES = \
src/util/pic_file.c \ src/util/pic_file.c \
src/util/quantize.c \ src/util/quantize.c \
src/util/recscr.c \ src/util/recscr.c \
src/util/render.c \
src/util/setgfx.c \ src/util/setgfx.c \
src/util/thmbnail.c \ src/util/thmbnail.c \
src/widgets/colbar.c \ src/widgets/colbar.c \

View File

@ -28,11 +28,11 @@
#endif #endif
bool command_enabled_copy_frame(const char *argument) bool command_enabled_copy_cel(const char *argument)
{ {
return FALSE; return FALSE;
} }
void command_execute_copy_frame(const char *argument) void command_execute_copy_cel(const char *argument)
{ {
} }

View File

@ -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); 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();
} }
/**********************************************************************/ /**********************************************************************/

View File

@ -25,24 +25,24 @@
#include "core/app.h" #include "core/app.h"
#include "modules/gui.h" #include "modules/gui.h"
#include "modules/sprites.h" #include "modules/sprites.h"
#include "raster/frame.h" #include "raster/cel.h"
#include "raster/layer.h" #include "raster/layer.h"
#include "raster/sprite.h" #include "raster/sprite.h"
#include "raster/undo.h" #include "raster/undo.h"
#endif #endif
bool command_enabled_frame_properties(const char *argument) bool command_enabled_cel_properties(const char *argument)
{ {
return current_sprite != NULL; 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; JWidget window, entry_frpos, entry_xpos, entry_ypos, slider_opacity, button_ok;
Sprite *sprite; Sprite *sprite;
Layer *layer; Layer *layer;
Frame *frame; Cel *cel;
char buf[1024]; char buf[1024];
/* get current sprite */ /* get current sprite */
@ -55,9 +55,9 @@ void command_execute_frame_properties(const char *argument)
if (!layer) if (!layer)
return; return;
/* get current frame */ /* get current cel */
frame = layer_get_frame(layer, sprite->frpos); cel = layer_get_cel(layer, sprite->frpos);
if (!frame) if (!cel)
return; return;
window = load_widget("frmprop.jid", "frame_properties"); 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"); slider_opacity = jwidget_find_name(window, "opacity");
button_ok = jwidget_find_name(window, "ok"); button_ok = jwidget_find_name(window, "ok");
sprintf(buf, "%d", frame->frpos); jwidget_set_text(entry_frpos, buf); sprintf(buf, "%d", cel->frpos); jwidget_set_text(entry_frpos, buf);
sprintf(buf, "%d", frame->x); jwidget_set_text(entry_xpos, buf); sprintf(buf, "%d", cel->x); jwidget_set_text(entry_xpos, buf);
sprintf(buf, "%d", frame->y); jwidget_set_text(entry_ypos, buf); sprintf(buf, "%d", cel->y); jwidget_set_text(entry_ypos, buf);
jslider_set_value(slider_opacity, frame->opacity); jslider_set_value(slider_opacity, cel->opacity);
while (TRUE) { while (TRUE) {
jwindow_open_fg(window); jwindow_open_fg(window);
if (jwindow_get_killer(window) == button_ok) { if (jwindow_get_killer(window) == button_ok) {
int new_frpos, new_xpos, new_ypos; 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 = strtol(jwidget_get_text(entry_frpos), NULL, 10);
new_frpos = MID(0, new_frpos, sprite->frames-1); 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) { if (new_frpos != cel->frpos && existent_cel) {
jalert("Error<<You can't change frpos to %d" jalert(_("Error"
"<<Already there is a frame in that pos.||&OK", "<<You can't change frame position to %d."
new_frpos); "<<Already there is a cel in that position."
"||&OK"), new_frpos);
} }
else { else {
/* WE MUST REMOVE THE FRAME BEFORE CALL frame_set_frpos() */ /* WE MUST REMOVE THE FRAME BEFORE CALL frame_set_frpos() */
if (undo_is_enabled(sprite->undo)) { if (undo_is_enabled(sprite->undo)) {
undo_open(sprite->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 */ /* change frame properties */
new_xpos = strtol(jwidget_get_text(entry_xpos), NULL, 10); new_xpos = strtol(jwidget_get_text(entry_xpos), NULL, 10);
new_ypos = strtol(jwidget_get_text(entry_ypos), NULL, 10); new_ypos = strtol(jwidget_get_text(entry_ypos), NULL, 10);
frame_set_frpos(frame, new_frpos); cel_set_frpos(cel, new_frpos);
frame_set_position(frame, cel_set_position(cel,
MID(-9999, new_xpos, 9999), MID(-9999, new_xpos, 9999),
MID(-9999, new_ypos, 9999)); MID(-9999, new_ypos, 9999));
frame_set_opacity(frame, jslider_get_value(slider_opacity)); cel_set_opacity(cel, jslider_get_value(slider_opacity));
/* add again the same frame */ /* add again the same frame */
if (undo_is_enabled(sprite->undo)) { if (undo_is_enabled(sprite->undo)) {
undo_add_frame(sprite->undo, layer, frame); undo_add_cel(sprite->undo, layer, cel);
undo_close(sprite->undo); undo_close(sprite->undo);
} }
layer_add_frame(layer, frame); layer_add_cel(layer, cel);
/* set the sprite position, refresh and break the loop */ /* set the sprite position, refresh and break the loop */
sprite_set_frpos(sprite, new_frpos); sprite_set_frpos(sprite, new_frpos);

View File

@ -28,11 +28,11 @@
#endif #endif
bool command_enabled_link_frame(const char *argument) bool command_enabled_link_cel(const char *argument)
{ {
return FALSE; return FALSE;
} }
void command_execute_link_frame(const char *argument) void command_execute_link_cel(const char *argument)
{ {
} }

View File

@ -25,7 +25,7 @@
#include "core/app.h" #include "core/app.h"
#include "modules/gui.h" #include "modules/gui.h"
#include "modules/sprites.h" #include "modules/sprites.h"
#include "raster/frame.h" #include "raster/cel.h"
#include "raster/image.h" #include "raster/image.h"
#include "raster/layer.h" #include "raster/layer.h"
#include "raster/sprite.h" #include "raster/sprite.h"
@ -58,7 +58,7 @@ void command_execute_merge_down_layer(const char *argument)
{ {
Sprite *sprite = current_sprite; Sprite *sprite = current_sprite;
Layer *src_layer, *dst_layer; Layer *src_layer, *dst_layer;
Frame *src_frame, *dst_frame; Cel *src_cel, *dst_cel;
Image *src_image, *dst_image; Image *src_image, *dst_image;
int frpos, index; int frpos, index;
@ -70,17 +70,17 @@ void command_execute_merge_down_layer(const char *argument)
for (frpos=0; frpos<sprite->frames; ++frpos) { for (frpos=0; frpos<sprite->frames; ++frpos) {
/* get frames */ /* get frames */
src_frame = layer_get_frame(src_layer, frpos); src_cel = layer_get_cel(src_layer, frpos);
dst_frame = layer_get_frame(dst_layer, frpos); dst_cel = layer_get_cel(dst_layer, frpos);
/* get images */ /* get images */
if (src_frame) if (src_cel)
src_image = stock_get_image(src_layer->stock, src_frame->image); src_image = stock_get_image(src_layer->stock, src_cel->image);
else else
src_image = NULL; src_image = NULL;
if (dst_frame) if (dst_cel)
dst_image = stock_get_image(dst_layer->stock, dst_frame->image); dst_image = stock_get_image(dst_layer->stock, dst_cel->image);
else else
dst_image = NULL; dst_image = NULL;
@ -88,43 +88,43 @@ void command_execute_merge_down_layer(const char *argument)
if (src_image) { if (src_image) {
/* no destination image */ /* no destination image */
if (!dst_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); dst_image = image_new_copy(src_image);
index = stock_add_image(dst_layer->stock, dst_image); index = stock_add_image(dst_layer->stock, dst_image);
if (undo_is_enabled(sprite->undo)) { if (undo_is_enabled(sprite->undo)) {
undo_add_image(sprite->undo, dst_layer->stock, dst_image); undo_add_image(sprite->undo, dst_layer->stock, dst_image);
} }
dst_frame = frame_new(frpos, index); dst_cel = cel_new(frpos, index);
frame_set_position(dst_frame, src_frame->x, src_frame->y); cel_set_position(dst_cel, src_cel->x, src_cel->y);
frame_set_opacity(dst_frame, src_frame->opacity); cel_set_opacity(dst_cel, src_cel->opacity);
if (undo_is_enabled(sprite->undo)) { 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 */ /* with destination */
else { else {
int x1 = MIN(src_frame->x, dst_frame->x); int x1 = MIN(src_cel->x, dst_cel->x);
int y1 = MIN(src_frame->y, dst_frame->y); int y1 = MIN(src_cel->y, dst_cel->y);
int x2 = MAX(src_frame->x+src_image->w-1, dst_frame->x+dst_image->w-1); int x2 = MAX(src_cel->x+src_image->w-1, dst_cel->x+dst_image->w-1);
int y2 = MAX(src_frame->y+src_image->h-1, dst_frame->y+dst_image->h-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, Image *new_image = image_crop(dst_image,
x1-dst_frame->x, x1-dst_cel->x,
y1-dst_frame->y, y1-dst_cel->y,
x2-x1+1, y2-y1+1); x2-x1+1, y2-y1+1);
/* merge src_image in new_image */ /* merge src_image in new_image */
image_merge(new_image, src_image, image_merge(new_image, src_image,
src_frame->x-x1, src_cel->x-x1,
src_frame->y-y1, src_cel->y-y1,
src_frame->opacity, src_cel->opacity,
src_layer->blend_mode); src_layer->blend_mode);
frame_set_position(dst_frame, x1, y1); cel_set_position(dst_cel, x1, y1);
if (undo_is_enabled(sprite->undo)) { 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); image_free(dst_image);
} }

View File

@ -28,11 +28,11 @@
#endif #endif
bool command_enabled_move_frame(const char *argument) bool command_enabled_move_cel(const char *argument)
{ {
return FALSE; return FALSE;
} }
void command_execute_move_frame(const char *argument) void command_execute_move_cel(const char *argument)
{ {
} }

View File

@ -27,8 +27,8 @@
#include "modules/gui.h" #include "modules/gui.h"
#include "modules/color.h" #include "modules/color.h"
#include "modules/sprites.h" #include "modules/sprites.h"
#include "raster/cel.h"
#include "raster/image.h" #include "raster/image.h"
#include "raster/frame.h"
#include "raster/layer.h" #include "raster/layer.h"
#include "raster/sprite.h" #include "raster/sprite.h"
#include "raster/stock.h" #include "raster/stock.h"
@ -37,7 +37,7 @@
#endif #endif
bool command_enabled_new_frame(const char *argument) bool command_enabled_new_cel(const char *argument)
{ {
return return
current_sprite && current_sprite &&
@ -47,18 +47,18 @@ bool command_enabled_new_frame(const char *argument)
layer_is_image(current_sprite->layer); 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; int bg, image_index;
Frame *frame; Cel *cel;
Image *image; Image *image;
int frpos; int frpos;
frpos = current_sprite->frpos; frpos = current_sprite->frpos;
while (layer_get_frame(current_sprite->layer, frpos)) while (layer_get_cel(current_sprite->layer, frpos))
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, image = image_new(current_sprite->imgtype,
current_sprite->w, current_sprite->w,
current_sprite->h); current_sprite->h);
@ -87,10 +87,10 @@ void command_execute_new_frame(const char *argument)
undo_add_image(current_sprite->undo, undo_add_image(current_sprite->undo,
current_sprite->layer->stock, image); current_sprite->layer->stock, image);
/* add the frame in the layer */ /* add the cel in the layer */
frame = frame_new(current_sprite->frpos, image_index); cel = cel_new(current_sprite->frpos, image_index);
undo_add_frame(current_sprite->undo, current_sprite->layer, frame); undo_add_cel(current_sprite->undo, current_sprite->layer, cel);
layer_add_frame(current_sprite->layer, frame); layer_add_cel(current_sprite->layer, cel);
undo_close(current_sprite->undo); undo_close(current_sprite->undo);

View File

@ -27,6 +27,7 @@
#include "modules/sprites.h" #include "modules/sprites.h"
#include "raster/layer.h" #include "raster/layer.h"
#include "raster/sprite.h" #include "raster/sprite.h"
#include "script/functions.h"
#endif #endif

View File

@ -27,6 +27,7 @@
#include "modules/sprites.h" #include "modules/sprites.h"
#include "raster/layer.h" #include "raster/layer.h"
#include "raster/sprite.h" #include "raster/sprite.h"
#include "script/functions.h"
#endif #endif

View File

@ -30,9 +30,9 @@
#include "modules/editors.h" #include "modules/editors.h"
#include "modules/gfx.h" #include "modules/gfx.h"
#include "modules/gui.h" #include "modules/gui.h"
#include "modules/render.h"
#include "raster/image.h" #include "raster/image.h"
#include "raster/sprite.h" #include "raster/sprite.h"
#include "util/render.h"
#include "widgets/editor.h" #include "widgets/editor.h"
#include "widgets/statebar.h" #include "widgets/statebar.h"

View File

@ -20,7 +20,10 @@
#ifndef USE_PRECOMPILED_HEADER #ifndef USE_PRECOMPILED_HEADER
#include <allegro/gfx.h>
#include "jinete/base.h" #include "jinete/base.h"
#include "jinete/alert.h"
#include "util/recscr.h" #include "util/recscr.h"
@ -35,6 +38,13 @@ void command_execute_record_screen(const char *argument)
{ {
if (is_rec_screen()) if (is_rec_screen())
rec_screen_off(); rec_screen_off();
else else if (bitmap_color_depth(screen) == 8
|| jalert(_("Warning"
"<<The display isn't in a 8 bpp resolution, the recording."
"<<process can be really slow. It's recommended to use a"
"<<8 bpp to make it faster."
"<<Do you want to continue anyway?"
"||Yes||No")) == 1) {
rec_screen_on(); rec_screen_on();
}
} }

View File

@ -22,24 +22,24 @@
#include "modules/gui.h" #include "modules/gui.h"
#include "modules/sprites.h" #include "modules/sprites.h"
#include "raster/frame.h" #include "raster/cel.h"
#include "raster/layer.h" #include "raster/layer.h"
#include "raster/sprite.h" #include "raster/sprite.h"
#include "script/functions.h" #include "script/functions.h"
#endif #endif
bool command_enabled_remove_frame(const char *argument) bool command_enabled_remove_cel(const char *argument)
{ {
return current_sprite != NULL; return current_sprite != NULL;
} }
void command_execute_remove_frame(const char *argument) void command_execute_remove_cel(const char *argument)
{ {
Sprite *sprite = current_sprite; Sprite *sprite = current_sprite;
Frame *frame = layer_get_frame(sprite->layer, sprite->frpos); Cel *cel = layer_get_cel(sprite->layer, sprite->frpos);
if (frame) { if (cel) {
RemoveFrame(sprite->layer, frame); RemoveCel(sprite->layer, cel);
GUI_Refresh(sprite); GUI_Refresh(sprite);
} }
} }

View File

@ -23,6 +23,7 @@
#include "modules/gui.h" #include "modules/gui.h"
#include "modules/sprites.h" #include "modules/sprites.h"
#include "raster/sprite.h" #include "raster/sprite.h"
#include "script/functions.h"
#endif #endif

View File

@ -110,21 +110,21 @@ bool command_enabled_flatten_layers(const char *argument);
void command_execute_flatten_layers(const char *argument); void command_execute_flatten_layers(const char *argument);
bool command_enabled_crop_layer(const char *argument); bool command_enabled_crop_layer(const char *argument);
void command_execute_crop_layer(const char *argument); void command_execute_crop_layer(const char *argument);
/* frame */ /* cel */
bool command_enabled_frame_properties(const char *argument); bool command_enabled_cel_properties(const char *argument);
void command_execute_frame_properties(const char *argument); void command_execute_cel_properties(const char *argument);
bool command_enabled_remove_frame(const char *argument); bool command_enabled_remove_cel(const char *argument);
void command_execute_remove_frame(const char *argument); void command_execute_remove_cel(const char *argument);
bool command_enabled_new_frame(const char *argument); bool command_enabled_new_cel(const char *argument);
void command_execute_new_frame(const char *argument); void command_execute_new_cel(const char *argument);
bool command_enabled_move_frame(const char *argument); bool command_enabled_move_cel(const char *argument);
void command_execute_move_frame(const char *argument); void command_execute_move_cel(const char *argument);
bool command_enabled_copy_frame(const char *argument); bool command_enabled_copy_cel(const char *argument);
void command_execute_copy_frame(const char *argument); void command_execute_copy_cel(const char *argument);
bool command_enabled_link_frame(const char *argument); bool command_enabled_link_cel(const char *argument);
void command_execute_link_frame(const char *argument); void command_execute_link_cel(const char *argument);
bool command_enabled_crop_frame(const char *argument); bool command_enabled_crop_cel(const char *argument);
void command_execute_crop_frame(const char *argument); void command_execute_crop_cel(const char *argument);
/* select */ /* select */
bool command_enabled_mask_all(const char *argument); bool command_enabled_mask_all(const char *argument);
void command_execute_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(merge_down_layer),
CMD_EXE_ENA(flatten_layers), CMD_EXE_ENA(flatten_layers),
CMD_EXE_ENA(crop_layer), CMD_EXE_ENA(crop_layer),
CMD_EXE_ENA(frame_properties), CMD_EXE_ENA(cel_properties),
CMD_EXE_ENA(remove_frame), CMD_EXE_ENA(remove_cel),
CMD_EXE_ENA(new_frame), CMD_EXE_ENA(new_cel),
CMD_EXE_ENA(move_frame), CMD_EXE_ENA(move_cel),
CMD_EXE_ENA(copy_frame), CMD_EXE_ENA(copy_cel),
CMD_EXE_ENA(link_frame), CMD_EXE_ENA(link_cel),
CMD_EXE_ENA(crop_frame), CMD_EXE_ENA(crop_cel),
CMD_EXE_ENA(mask_all), CMD_EXE_ENA(mask_all),
CMD_EXE_ENA(deselect_mask), CMD_EXE_ENA(deselect_mask),
CMD_EXE_ENA(reselect_mask), CMD_EXE_ENA(reselect_mask),

View File

@ -69,14 +69,14 @@
#define CMD_MERGE_DOWN_LAYER "merge_down_layer" #define CMD_MERGE_DOWN_LAYER "merge_down_layer"
#define CMD_FLATTEN_LAYERS "flatten_layers" #define CMD_FLATTEN_LAYERS "flatten_layers"
#define CMD_CROP_LAYER "crop_layer" #define CMD_CROP_LAYER "crop_layer"
/* frame */ /* cel */
#define CMD_FRAME_PROPERTIES "frame_properties" #define CMD_CEL_PROPERTIES "cel_properties"
#define CMD_REMOVE_FRAME "remove_frame" #define CMD_REMOVE_CEL "remove_cel"
#define CMD_NEW_FRAME "new_frame" #define CMD_NEW_CEL "new_cel"
#define CMD_MOVE_FRAME "move_frame" #define CMD_MOVE_CEL "move_cel"
#define CMD_COPY_FRAME "copy_frame" #define CMD_COPY_CEL "copy_cel"
#define CMD_LINK_FRAME "link_frame" #define CMD_LINK_CEL "link_cel"
#define CMD_CROP_FRAME "crop_frame" #define CMD_CROP_CEL "crop_cel"
/* select */ /* select */
#define CMD_MASK_ALL "mask_all" #define CMD_MASK_ALL "mask_all"
#define CMD_DESELECT_MASK "deselect_mask" #define CMD_DESELECT_MASK "deselect_mask"

View File

@ -29,7 +29,6 @@
#include "modules/gui.h" #include "modules/gui.h"
#include "modules/palette.h" #include "modules/palette.h"
#include "modules/recent.h" #include "modules/recent.h"
#include "modules/render.h"
#include "modules/rootmenu.h" #include "modules/rootmenu.h"
#include "modules/sprites.h" #include "modules/sprites.h"
#include "modules/tools.h" #include "modules/tools.h"
@ -61,7 +60,6 @@ static Module module[] =
DEF_MODULE(effect, REQUIRE_INTERFACE | REQUIRE_SCRIPTING), DEF_MODULE(effect, REQUIRE_INTERFACE | REQUIRE_SCRIPTING),
DEF_MODULE(tools, REQUIRE_INTERFACE | REQUIRE_SCRIPTING), DEF_MODULE(tools, REQUIRE_INTERFACE | REQUIRE_SCRIPTING),
DEF_MODULE(graphics, REQUIRE_INTERFACE), DEF_MODULE(graphics, REQUIRE_INTERFACE),
DEF_MODULE(render, REQUIRE_INTERFACE),
DEF_MODULE(gui, REQUIRE_INTERFACE), DEF_MODULE(gui, REQUIRE_INTERFACE),
DEF_MODULE(recent, REQUIRE_INTERFACE), DEF_MODULE(recent, REQUIRE_INTERFACE),
DEF_MODULE(rootmenu, REQUIRE_INTERFACE), DEF_MODULE(rootmenu, REQUIRE_INTERFACE),

View File

@ -34,13 +34,13 @@
#include "modules/palette.h" #include "modules/palette.h"
#include "modules/rootmenu.h" #include "modules/rootmenu.h"
#include "modules/sprites.h" #include "modules/sprites.h"
#include "raster/frame.h" #include "raster/cel.h"
#include "raster/image.h" #include "raster/image.h"
#include "raster/layer.h" #include "raster/layer.h"
#include "raster/sprite.h" #include "raster/sprite.h"
#include "raster/stock.h" #include "raster/stock.h"
#include "raster/undo.h" #include "raster/undo.h"
#include "util/frmove.h" #include "util/celmove.h"
#include "util/thmbnail.h" #include "util/thmbnail.h"
#endif #endif
@ -56,26 +56,26 @@ enum {
STATE_SELECTING, STATE_SELECTING,
}; };
struct FrameBox; struct CelBox;
typedef struct LayerBox { typedef struct LayerBox {
JWidget widget; JWidget widget;
struct FrameBox *frame_box; struct CelBox *cel_box;
/* for layer movement */ /* for layer movement */
Layer *layer; Layer *layer;
struct jrect rect; struct jrect rect;
void *rect_data; void *rect_data;
} LayerBox; } LayerBox;
typedef struct FrameBox { typedef struct CelBox {
JWidget widget; JWidget widget;
LayerBox *layer_box; LayerBox *layer_box;
/* for frame movement */ /* for frame movement */
Layer *layer; Layer *layer;
Frame *frame; Cel *cel;
struct jrect rect; struct jrect rect;
void *rect_data; void *rect_data;
} FrameBox; } CelBox;
static int state = STATE_NONE; 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 void layer_box_request_size (JWidget widget, int *w, int *h);
static bool layer_box_msg_proc (JWidget widget, JMessage msg); static bool layer_box_msg_proc (JWidget widget, JMessage msg);
static JWidget frame_box_new (void); static JWidget cel_box_new (void);
static int frame_box_type (void); static int cel_box_type (void);
static FrameBox *frame_box_data (JWidget widget); static CelBox *cel_box_data (JWidget widget);
static void frame_box_request_size (JWidget widget, int *w, int *h); static void cel_box_request_size (JWidget widget, int *w, int *h);
static bool frame_box_msg_proc (JWidget widget, JMessage msg); static bool cel_box_msg_proc (JWidget widget, JMessage msg);
static Layer *select_prev_layer(Layer *layer, int enter_in_sets); static Layer *select_prev_layer(Layer *layer, int enter_in_sets);
static Layer *select_next_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 int get_layer_pos(Layer *layer, Layer *current, int *pos);
static Layer *get_layer_in_pos(Layer *layer, int pos); static Layer *get_layer_in_pos(Layer *layer, int pos);
static void select_frpos_motion (JWidget widget); static void select_frpos_motion(JWidget widget);
static void select_layer_motion (JWidget widget, LayerBox *layer_box, FrameBox *frame_box); static void select_layer_motion(JWidget widget, LayerBox *layer_box, CelBox *cel_box);
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);
static void get_frame_rect (JWidget widget, JRect rect); static void get_cel_rect(JWidget widget, JRect rect);
bool is_movingframe (void) bool is_movingframe (void)
{ {
@ -112,7 +112,7 @@ void switch_between_film_and_sprite_editor (void)
Sprite *sprite = current_sprite; Sprite *sprite = current_sprite;
JWidget window, box1, panel1; JWidget window, box1, panel1;
JWidget layer_view, frame_view; JWidget layer_view, frame_view;
JWidget layer_box, frame_box; JWidget layer_box, cel_box;
if (!is_interactive ()) if (!is_interactive ())
return; return;
@ -123,15 +123,15 @@ void switch_between_film_and_sprite_editor (void)
layer_view = jview_new(); layer_view = jview_new();
frame_view = jview_new(); frame_view = jview_new();
layer_box = layer_box_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); layer_box_data(layer_box)->cel_box = cel_box_data(cel_box);
frame_box_data(frame_box)->layer_box = layer_box_data(layer_box); cel_box_data(cel_box)->layer_box = layer_box_data(layer_box);
jwidget_expansive(panel1, TRUE); jwidget_expansive(panel1, TRUE);
jview_attach(layer_view, layer_box); 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(layer_view);
jview_without_bars(frame_view); jview_without_bars(frame_view);
@ -369,7 +369,7 @@ static bool layer_box_msg_proc (JWidget widget, JMessage msg)
state = STATE_MOVING; state = STATE_MOVING;
jmouse_set_cursor(JI_CURSOR_MOVE); 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->layer = current_sprite->layer;
/* layer_box->rect = rect; */ /* layer_box->rect = rect; */
/* layer_box->rect_data = NULL; */ /* layer_box->rect_data = NULL; */
@ -379,10 +379,10 @@ static bool layer_box_msg_proc (JWidget widget, JMessage msg)
if (jwidget_has_capture (widget)) { if (jwidget_has_capture (widget)) {
/* scroll */ /* scroll */
if (state == STATE_SCROLLING) 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 */ /* move */
else if (state == STATE_MOVING) { 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; return TRUE;
} }
@ -405,7 +405,7 @@ static bool layer_box_msg_proc (JWidget widget, JMessage msg)
msg->mouse.x, msg->mouse.y); msg->mouse.x, msg->mouse.y);
jview_update (jwidget_get_view (layer_box->widget)); 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 */ /* move */
@ -416,7 +416,7 @@ static bool layer_box_msg_proc (JWidget widget, JMessage msg)
current_sprite->layer = layer_box->layer; current_sprite->layer = layer_box->layer;
jview_update (jwidget_get_view (layer_box->widget)); 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 else
jwidget_dirty (widget); 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 ()); JWidget widget = jwidget_new (cel_box_type ());
FrameBox *frame_box = jnew (FrameBox, 1); CelBox *cel_box = jnew (CelBox, 1);
frame_box->widget = widget; cel_box->widget = widget;
jwidget_add_hook (widget, frame_box_type (), jwidget_add_hook (widget, cel_box_type (),
frame_box_msg_proc, frame_box); cel_box_msg_proc, cel_box);
jwidget_focusrest (widget, TRUE); jwidget_focusrest (widget, TRUE);
return widget; return widget;
} }
static int frame_box_type (void) static int cel_box_type (void)
{ {
static int type = 0; static int type = 0;
if (!type) if (!type)
@ -456,12 +456,12 @@ static int frame_box_type (void)
return type; 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; 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); *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; Sprite *sprite = current_sprite;
switch (msg->type) { switch (msg->type) {
case JM_DESTROY: case JM_DESTROY:
jfree (frame_box); jfree (cel_box);
break; break;
case JM_REQSIZE: 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; return TRUE;
case JM_DRAW: { case JM_DRAW: {
@ -568,22 +568,22 @@ static bool frame_box_msg_proc (JWidget widget, JMessage msg)
case GFXOBJ_LAYER_SET: case GFXOBJ_LAYER_SET:
break; break;
case GFXOBJ_LAYER_IMAGE: { case GFXOBJ_LAYER_IMAGE: {
Frame *frame, *frame_link; Cel *cel, *cel_link;
int k_frpos, k_image; int k_frpos, k_image;
JLink link; JLink link;
JI_LIST_FOR_EACH(layer->frames, link) { JI_LIST_FOR_EACH(layer->cels, link) {
frame = link->data; cel = link->data;
k_frpos = frame->frpos; k_frpos = cel->frpos;
if (k_frpos < first_viewable_frame || if (k_frpos < first_viewable_frame ||
k_frpos > last_viewable_frame) k_frpos > last_viewable_frame)
continue; continue;
k_image = frame->image; k_image = cel->image;
frame_link = frame_is_link(frame, layer); cel_link = cel_is_link(cel, layer);
thumbnail = generate_thumbnail(frame_link ? frame_link: frame, thumbnail = generate_thumbnail(cel_link ? cel_link: cel,
layer); layer);
x1 = k_frpos*FRMSIZE-scroll_x+FRMSIZE/2-THUMBSIZE/2; 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) if (thumbnail)
draw_sprite(bmp, thumbnail, x1, y1); draw_sprite(bmp, thumbnail, x1, y1);
if (frame_link) { if (cel_link) {
BITMAP *sprite = get_gfx(GFX_LINKFRAME); BITMAP *sprite = get_gfx(GFX_LINKFRAME);
draw_sprite(bmp, sprite, x1, y2-sprite->h+1); 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); jmouse_set_cursor(JI_CURSOR_MOVE);
} }
else { else {
Frame *frame; Cel *cel;
state = STATE_SELECTING; /* by default we will be selecting state = STATE_SELECTING; /* by default we will be selecting
frames */ frames */
select_frpos_motion (widget); select_frpos_motion(widget);
select_layer_motion (widget, frame_box->layer_box, frame_box); select_layer_motion(widget, cel_box->layer_box, cel_box);
/* show the dialog to change the frlen (frame duration time)? */ /* show the dialog to change the frlen (frame duration time)? */
if (msg->mouse.y < FRMSIZE) { if (msg->mouse.y < FRMSIZE) {
@ -643,26 +643,25 @@ static bool frame_box_msg_proc (JWidget widget, JMessage msg)
return TRUE; return TRUE;
} }
frame = layer_get_frame (current_sprite->layer, cel = layer_get_cel(current_sprite->layer,
current_sprite->frpos); current_sprite->frpos);
if (frame) { if (cel) {
state = STATE_MOVING; /* now we will moving a frame */ state = STATE_MOVING; /* now we will moving a cel */
jmouse_set_cursor(JI_CURSOR_MOVE); jmouse_set_cursor(JI_CURSOR_MOVE);
frame_box->layer = current_sprite->layer; cel_box->layer = current_sprite->layer;
frame_box->frame = frame; cel_box->cel = cel;
frame_box->rect_data = NULL; cel_box->rect_data = NULL;
get_frame_rect (widget, &frame_box->rect); get_cel_rect(widget, &cel_box->rect);
jmouse_hide(); jmouse_hide();
frame_box->rect_data = rectsave cel_box->rect_data = rectsave(ji_screen,
(ji_screen, cel_box->rect.x1, cel_box->rect.y1,
frame_box->rect.x1, frame_box->rect.y1, cel_box->rect.x2-1, cel_box->rect.y2-1);
frame_box->rect.x2-1, frame_box->rect.y2-1);
rectdotted(ji_screen, rectdotted(ji_screen,
frame_box->rect.x1, frame_box->rect.y1, cel_box->rect.x1, cel_box->rect.y1,
frame_box->rect.x2-1, frame_box->rect.y2-1, cel_box->rect.x2-1, cel_box->rect.y2-1,
makecol (0, 0, 0), makecol (255, 255, 255)); makecol (0, 0, 0), makecol (255, 255, 255));
jmouse_show(); jmouse_show();
} }
@ -672,29 +671,28 @@ static bool frame_box_msg_proc (JWidget widget, JMessage msg)
if (jwidget_has_capture (widget)) { if (jwidget_has_capture (widget)) {
/* scroll */ /* scroll */
if (state == STATE_SCROLLING) 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 */ /* move */
else if (state == STATE_MOVING) { else if (state == STATE_MOVING) {
jmouse_hide(); jmouse_hide();
rectrestore(frame_box->rect_data); rectrestore(cel_box->rect_data);
rectdiscard(frame_box->rect_data); rectdiscard(cel_box->rect_data);
select_frpos_motion(widget); 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); jwidget_flush_redraw(widget);
frame_box->rect_data = rectsave cel_box->rect_data = rectsave(ji_screen,
(ji_screen, cel_box->rect.x1, cel_box->rect.y1,
frame_box->rect.x1, frame_box->rect.y1, cel_box->rect.x2-1, cel_box->rect.y2-1);
frame_box->rect.x2-1, frame_box->rect.y2-1);
rectdotted(ji_screen, rectdotted(ji_screen,
frame_box->rect.x1, frame_box->rect.y1, cel_box->rect.x1, cel_box->rect.y1,
frame_box->rect.x2-1, frame_box->rect.y2-1, cel_box->rect.x2-1, cel_box->rect.y2-1,
makecol(0, 0, 0), makecol(255, 255, 255)); makecol(0, 0, 0), makecol(255, 255, 255));
jmouse_show(); jmouse_show();
@ -702,7 +700,7 @@ static bool frame_box_msg_proc (JWidget widget, JMessage msg)
/* select */ /* select */
else if (state == STATE_SELECTING) { else if (state == STATE_SELECTING) {
select_frpos_motion(widget); 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; 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_SELECTING) || (state == STATE_MOVING)) {
if (state == STATE_MOVING) { if (state == STATE_MOVING) {
jmouse_hide(); jmouse_hide();
rectrestore(frame_box->rect_data); rectrestore(cel_box->rect_data);
rectdiscard(frame_box->rect_data); rectdiscard(cel_box->rect_data);
jmouse_show(); 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) { if (msg->mouse.right) {
JWidget popup_menuitem = get_frame_popup_menuitem(); 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), jmenu_popup(jmenuitem_get_submenu(popup_menuitem),
msg->mouse.x, msg->mouse.y); msg->mouse.x, msg->mouse.y);
jview_update(jwidget_get_view (frame_box->widget)); jview_update(jwidget_get_view (cel_box->widget));
jview_update(jwidget_get_view (frame_box->layer_box->widget)); jview_update(jwidget_get_view (cel_box->layer_box->widget));
} }
} }
else if (state == STATE_MOVING) { else if (state == STATE_MOVING) {
move_frame(); move_cel();
jwidget_dirty(widget); 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) */ /* select the layer depending of mouse motion (also adjust the scroll) */
static void select_layer_motion(JWidget widget, static void select_layer_motion(JWidget widget,
LayerBox *layer_box, FrameBox *frame_box) LayerBox *layer_box, CelBox *cel_box)
{ {
Sprite *sprite = current_sprite; Sprite *sprite = current_sprite;
int layer, current_layer; int layer, current_layer;
@ -919,7 +917,7 @@ static void select_layer_motion(JWidget widget,
/* the layer change? */ /* the layer change? */
if (layer != current_layer) { if (layer != current_layer) {
JWidget view1 = jwidget_get_view(layer_box->widget); 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)); JRect vp = jview_get_viewport_position(jwidget_get_view(widget));
int scroll1_x, scroll1_y, scroll_change; int scroll1_x, scroll1_y, scroll_change;
int scroll2_x, scroll2_y; int scroll2_x, scroll2_y;
@ -947,19 +945,19 @@ static void select_layer_motion(JWidget widget,
widget->rc->y1+LAYSIZE+layer*LAYSIZE+LAYSIZE/2); widget->rc->y1+LAYSIZE+layer*LAYSIZE+LAYSIZE/2);
jwidget_dirty(layer_box->widget); jwidget_dirty(layer_box->widget);
jwidget_dirty(frame_box->widget); jwidget_dirty(cel_box->widget);
jrect_free(vp); 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 */ scroll individually and vertical scroll jointly */
static void control_scroll_motion (JWidget widget, static void control_scroll_motion(JWidget widget,
LayerBox *layer_box, FrameBox *frame_box) LayerBox *layer_box, CelBox *cel_box)
{ {
JWidget view1 = jwidget_get_view(layer_box->widget); 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)); JRect vp = jview_get_viewport_position(jwidget_get_view (widget));
int scroll1_x, scroll1_y; int scroll1_x, scroll1_y;
int scroll2_x, scroll2_y; int scroll2_x, scroll2_y;
@ -970,7 +968,7 @@ static void control_scroll_motion (JWidget widget,
/* horizontal scroll for layer_box */ /* horizontal scroll for layer_box */
if (widget == layer_box->widget) if (widget == layer_box->widget)
scroll1_x += jmouse_x(1)-jmouse_x(0); scroll1_x += jmouse_x(1)-jmouse_x(0);
/* horizontal scroll for frame_box */ /* horizontal scroll for cel_box */
else else
scroll2_x += jmouse_x(1)-jmouse_x(0); scroll2_x += jmouse_x(1)-jmouse_x(0);
@ -988,7 +986,7 @@ static void control_scroll_motion (JWidget widget,
jrect_free(vp); 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); JWidget view = jwidget_get_view(widget);
JRect vp = jview_get_viewport_position(view); JRect vp = jview_get_viewport_position(view);

View File

@ -28,8 +28,8 @@
#include "modules/sprites.h" #include "modules/sprites.h"
#include "modules/tools2.h" #include "modules/tools2.h"
#include "raster/blend.h" #include "raster/blend.h"
#include "raster/cel.h"
#include "raster/dirty.h" #include "raster/dirty.h"
#include "raster/frame.h"
#include "raster/image.h" #include "raster/image.h"
#include "raster/layer.h" #include "raster/layer.h"
#include "raster/mask.h" #include "raster/mask.h"

View File

@ -36,13 +36,13 @@
#define ASE_FILE_CHUNK_FLI_COLOR 11 #define ASE_FILE_CHUNK_FLI_COLOR 11
#define ASE_FILE_CHUNK_LAYER 0x2004 #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_MASK 0x2016
#define ASE_FILE_CHUNK_PATH 0x2017 #define ASE_FILE_CHUNK_PATH 0x2017
#define ASE_FILE_RAW_FRAME 0 #define ASE_FILE_RAW_CEL 0
#define ASE_FILE_LINK_FRAME 1 #define ASE_FILE_LINK_CEL 1
#define ASE_FILE_RLE_COMPRESSED_FRAME 2 #define ASE_FILE_RLE_COMPRESSED_CEL 2
typedef struct ASE_Header 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_frame_header(FILE *f, ASE_FrameHeader *frame_header);
static void ase_file_write_layers(FILE *f, Layer *layer); 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_read_padding(FILE *f, int bytes);
static void ase_file_write_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 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 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 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 Cel *ase_file_read_cel_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 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 Mask *ase_file_read_mask_chunk(FILE *f);
static void ase_file_write_mask_chunk(FILE *f, Mask *mask); static void ase_file_write_mask_chunk(FILE *f, Mask *mask);
@ -162,7 +162,7 @@ static int ase_file_write(Sprite *sprite)
return ret; return ret;
} }
Sprite *ase_file_read_f (FILE *f) Sprite *ase_file_read_f(FILE *f)
{ {
Sprite *sprite = NULL; Sprite *sprite = NULL;
ASE_Header header; ASE_Header header;
@ -175,17 +175,17 @@ Sprite *ase_file_read_f (FILE *f)
int chunk_type; int chunk_type;
int c, frpos; int c, frpos;
if (ase_file_read_header (f, &header) != 0) { if (ase_file_read_header(f, &header) != 0) {
console_printf (_("Error reading header\n")); console_printf(_("Error reading header\n"));
return NULL; return NULL;
} }
/* create the new sprite */ /* create the new sprite */
sprite = sprite_new (header.depth == 32 ? IMAGE_RGB: sprite = sprite_new(header.depth == 32 ? IMAGE_RGB:
header.depth == 16 ? IMAGE_GRAYSCALE: IMAGE_INDEXED, header.depth == 16 ? IMAGE_GRAYSCALE: IMAGE_INDEXED,
header.width, header.height); header.width, header.height);
if (!sprite) { if (!sprite) {
console_printf (_("Error creating sprite with file spec\n")); console_printf(_("Error creating sprite with file spec\n"));
return NULL; return NULL;
} }
@ -203,11 +203,11 @@ Sprite *ase_file_read_f (FILE *f)
/* read frame by frame to end-of-file */ /* read frame by frame to end-of-file */
for (frpos=0; frpos<sprite->frames; frpos++) { for (frpos=0; frpos<sprite->frames; frpos++) {
/* start frame position */ /* start frame position */
frame_pos = ftell (f); frame_pos = ftell(f);
do_progress (frame_pos); do_progress(frame_pos);
/* read frame header */ /* read frame header */
ase_file_read_frame_header (f, &frame_header); ase_file_read_frame_header(f, &frame_header);
/* correct frame type */ /* correct frame type */
if (frame_header.magic == ASE_FILE_FRAME_MAGIC) { if (frame_header.magic == ASE_FILE_FRAME_MAGIC) {
@ -218,12 +218,12 @@ Sprite *ase_file_read_f (FILE *f)
/* read chunks */ /* read chunks */
for (c=0; c<frame_header.chunks; c++) { for (c=0; c<frame_header.chunks; c++) {
/* start chunk position */ /* start chunk position */
chunk_pos = ftell (f); chunk_pos = ftell(f);
do_progress (chunk_pos); do_progress(chunk_pos);
/* read chunk information */ /* read chunk information */
chunk_size = fgetl (f); chunk_size = fgetl(f);
chunk_type = fgetw (f); chunk_type = fgetw(f);
switch (chunk_type) { switch (chunk_type) {
@ -250,10 +250,10 @@ Sprite *ase_file_read_f (FILE *f)
break; break;
} }
case ASE_FILE_CHUNK_FRAME: { case ASE_FILE_CHUNK_CEL: {
/* console_printf ("Frame chunk\n"); */ /* console_printf ("Cel chunk\n"); */
ase_file_read_frame_chunk (f, sprite, frpos, sprite->imgtype); ase_file_read_cel_chunk(f, sprite, frpos, sprite->imgtype);
break; break;
} }
@ -286,15 +286,15 @@ Sprite *ase_file_read_f (FILE *f)
} }
/* skip frame size */ /* 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; return sprite;
} }
int ase_file_write_f (FILE *f, Sprite *sprite) int ase_file_write_f(FILE *f, Sprite *sprite)
{ {
ASE_Header header; ASE_Header header;
ASE_FrameHeader frame_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); ase_file_write_mask_chunk(f, link->data);
} }
/* write frames chunks */ /* write cel chunks */
ase_file_write_frames(f, sprite, sprite->set, frpos); ase_file_write_cels(f, sprite, sprite->set, frpos);
/* write the frame header */ /* write the frame header */
ase_file_write_frame_header(f, &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); 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->size = fgetl (f);
frame_header->magic = fgetw (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); 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); 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); 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 pos = frame_header->size;
int end = ftell (f); 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)) { if (layer_is_image(layer)) {
Frame *frame = layer_get_frame(layer, frpos); Cel *cel = layer_get_cel(layer, frpos);
if (frame) { if (cel) {
/* console_printf ("New frame in frpos %d, in layer %d\n", */ /* console_printf ("New cel in frpos %d, in layer %d\n", */
/* frpos, sprite_layer2index (sprite, layer)); */ /* frpos, sprite_layer2index (sprite, layer)); */
ase_file_write_frame_chunk(f, frame, layer, /* index_count */ ase_file_write_cel_chunk(f, cel, layer, /* index_count */
sprite_layer2index(sprite, layer)); sprite_layer2index(sprite, layer));
} }
} }
if (layer_is_set(layer)) { if (layer_is_set(layer)) {
JLink link; JLink link;
JI_LIST_FOR_EACH(layer->layers, 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; int c;
@ -494,7 +494,7 @@ static void ase_file_read_padding (FILE *f, int bytes)
fgetc (f); fgetc (f);
} }
static void ase_file_write_padding (FILE *f, int bytes) static void ase_file_write_padding(FILE *f, int bytes)
{ {
int c; int c;
@ -502,7 +502,7 @@ static void ase_file_write_padding (FILE *f, int bytes)
fputc (0, f); fputc (0, f);
} }
static char *ase_file_read_string (FILE *f) static char *ase_file_read_string(FILE *f)
{ {
char *string; char *string;
int c, length; int c, length;
@ -522,7 +522,7 @@ static char *ase_file_read_string (FILE *f)
return string; 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; 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); */ /* 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 */ /* read chunk data */
int layer_index = fgetw (f); int layer_index = fgetw(f);
int x = ((short)fgetw (f)); int x = ((short)fgetw(f));
int y = ((short)fgetw (f)); int y = ((short)fgetw(f));
int opacity = fgetc (f); int opacity = fgetc(f);
int frame_type = fgetw (f); int cel_type = fgetw(f);
Layer *layer; 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) { if (!layer) {
console_printf (_("Frame %d didn't found layer with index %d\n"), console_printf(_("Frame %d didn't found layer with index %d\n"),
frpos, layer_index); frpos, layer_index);
return NULL; return NULL;
} }
/* console_printf ("Layer found: %d -> %s\n", layer_index, layer->name); */ /* console_printf ("Layer found: %d -> %s\n", layer_index, layer->name); */
/* create the new frame */ /* create the new frame */
frame = frame_new(frpos, 0); cel = cel_new(frpos, 0);
frame_set_position(frame, x, y); cel_set_position(cel, x, y);
frame_set_opacity(frame, opacity); 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; int x, y, r, g, b, a, k;
Image *image; Image *image;
/* read width and height */ /* 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) { if (w > 0 && h > 0) {
image = image_new (imgtype, w, h); image = image_new (imgtype, w, h);
if (!image) { if (!image) {
frame_free (frame); cel_free(cel);
/* not enough memory for frame's image */ /* not enough memory for frame's image */
return NULL; return NULL;
} }
@ -771,64 +771,62 @@ static Frame *ase_file_read_frame_chunk (FILE *f, Sprite *sprite, int frpos, int
break; break;
} }
frame->image = stock_add_image (layer->stock, image); cel->image = stock_add_image(layer->stock, image);
} }
break; break;
} }
case ASE_FILE_LINK_FRAME: { case ASE_FILE_LINK_CEL: {
/* read link position */ /* read link position */
int link_frpos = fgetw (f); int link_frpos = fgetw (f);
Frame *link = layer_get_frame (layer, link_frpos); Cel *link = layer_get_cel(layer, link_frpos);
if (link) if (link)
frame->image = link->image; cel->image = link->image;
else { else {
frame_free (frame); cel_free(cel);
/* linked frame doesn't found */ /* linked cel doesn't found */
return NULL; return NULL;
} }
break; break;
} }
case ASE_FILE_RLE_COMPRESSED_FRAME: case ASE_FILE_RLE_COMPRESSED_CEL:
/* XXXX */ /* XXXX */
break; break;
} }
layer_add_frame (layer, frame); layer_add_cel(layer, cel);
return frame; 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); Cel *link = cel_is_link(cel, layer);
int frame_type = link ? ASE_FILE_LINK_FRAME: ASE_FILE_RAW_FRAME; 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); switch (cel_type) {
fputw (frame->x, f);
fputw (frame->y, f);
fputc (frame->opacity, f);
fputw (frame_type, f);
ase_file_write_padding (f, 7);
switch (frame_type) { case ASE_FILE_RAW_CEL: {
Image *image = stock_get_image(layer->stock, cel->image);
case ASE_FILE_RAW_FRAME: {
Image *image = stock_get_image (layer->stock, frame->image);
int x, y, c; int x, y, c;
if (image) { if (image) {
/* width and height */ /* width and height */
fputw (image->w, f); fputw(image->w, f);
fputw (image->h, f); fputw(image->h, f);
/* XXXX */ /* XXXX */
/* add_progress (image->h); */ /* add_progress(image->h); */
/* pixel data */ /* pixel data */
switch (image->imgtype) { switch (image->imgtype) {
@ -837,122 +835,122 @@ static void ase_file_write_frame_chunk (FILE *f, Frame *frame, Layer *layer, int
for (y=0; y<image->h; y++) { for (y=0; y<image->h; y++) {
for (x=0; x<image->w; x++) { for (x=0; x<image->w; x++) {
c = image->method->getpixel (image, x, y); c = image->method->getpixel (image, x, y);
fputc (_rgba_getr (c), f); fputc(_rgba_getr(c), f);
fputc (_rgba_getg (c), f); fputc(_rgba_getg(c), f);
fputc (_rgba_getb (c), f); fputc(_rgba_getb(c), f);
fputc (_rgba_geta (c), f); fputc(_rgba_geta(c), f);
} }
/* do_progress (y); */ /* do_progress(y); */
} }
break; break;
case IMAGE_GRAYSCALE: case IMAGE_GRAYSCALE:
for (y=0; y<image->h; y++) { for (y=0; y<image->h; y++) {
for (x=0; x<image->w; x++) { for (x=0; x<image->w; x++) {
c = image->method->getpixel (image, x, y); c = image->method->getpixel(image, x, y);
fputc (_graya_getk (c), f); fputc(_graya_getk(c), f);
fputc (_graya_geta (c), f); fputc(_graya_geta(c), f);
} }
/* do_progress (y); */ /* do_progress(y); */
} }
break; break;
case IMAGE_INDEXED: case IMAGE_INDEXED:
for (y=0; y<image->h; y++) { for (y=0; y<image->h; y++) {
for (x=0; x<image->w; x++) for (x=0; x<image->w; x++)
fputc (image->method->getpixel (image, x, y), f); fputc(image->method->getpixel(image, x, y), f);
/* do_progress (y); */ /* do_progress(y); */
} }
break; break;
} }
/* del_progress (); */ /* del_progress(); */
} }
else { else {
/* width and height */ /* width and height */
fputw (0, f); fputw(0, f);
fputw (0, f); fputw(0, f);
} }
break; break;
} }
case ASE_FILE_LINK_FRAME: case ASE_FILE_LINK_CEL:
/* linked frame position */ /* linked frame position */
fputw (link->frpos, f); fputw(link->frpos, f);
break; break;
case ASE_FILE_RLE_COMPRESSED_FRAME: case ASE_FILE_RLE_COMPRESSED_CEL:
/* XXXX */ /* TODO */
break; 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; int c, u, v, byte;
Mask *mask; Mask *mask;
/* read chunk data */ /* read chunk data */
int x = fgetw (f); int x = fgetw(f);
int y = fgetw (f); int y = fgetw(f);
int w = fgetw (f); int w = fgetw(f);
int h = fgetw (f); int h = fgetw(f);
char *name; char *name;
ase_file_read_padding (f, 8); ase_file_read_padding(f, 8);
name = ase_file_read_string (f); name = ase_file_read_string(f);
mask = mask_new (); mask = mask_new();
if (!mask) if (!mask)
return NULL; return NULL;
if (name) 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 */ /* read image data */
for (v=0; v<h; v++) for (v=0; v<h; v++)
for (u=0; u<(w+7)/8; u++) { for (u=0; u<(w+7)/8; u++) {
byte = fgetc (f); byte = fgetc (f);
for (c=0; c<8; c++) for (c=0; c<8; c++)
image_putpixel (mask->bitmap, u*8+c, v, byte & (1<<(7-c))); image_putpixel(mask->bitmap, u*8+c, v, byte & (1<<(7-c)));
} }
return mask; 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; 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->x, f);
fputw (mask->y, f); fputw(mask->y, f);
fputw (mask->w, f); fputw(mask->w, f);
fputw (mask->h, f); fputw(mask->h, f);
ase_file_write_padding (f, 8); ase_file_write_padding(f, 8);
/* name */ /* name */
ase_file_write_string (f, mask->name); ase_file_write_string(f, mask->name);
/* bit map */ /* bit map */
for (v=0; v<mask->h; v++) for (v=0; v<mask->h; v++)
for (u=0; u<(mask->w+7)/8; u++) { for (u=0; u<(mask->w+7)/8; u++) {
byte = 0; byte = 0;
for (c=0; c<8; c++) 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)); 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) */ /* returns a word (16 bits) */
int fgetw (FILE *file) int fgetw(FILE *file)
{ {
int b1, b2; int b1, b2;
@ -969,7 +967,7 @@ int fgetw (FILE *file)
} }
/* returns a dword (32 bits) */ /* returns a dword (32 bits) */
long fgetl (FILE *file) long fgetl(FILE *file)
{ {
int b1, b2, b3, b4; int b1, b2, b3, b4;
@ -994,7 +992,7 @@ long fgetl (FILE *file)
} }
/* returns 0 in success or -1 in error */ /* returns 0 in success or -1 in error */
int fputw (int w, FILE *file) int fputw(int w, FILE *file)
{ {
int b1, b2; int b1, b2;
@ -1010,7 +1008,7 @@ int fputw (int w, FILE *file)
} }
/* returns 0 in success or -1 in error */ /* 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; int b1, b2, b3, b4;
@ -1031,7 +1029,7 @@ int fputl (long l, FILE *file)
#if 0 #if 0
/* returns a floating point (32 bits) */ /* returns a floating point (32 bits) */
static float fgetf (FILE *file) static float fgetf(FILE *file)
{ {
union { union {
float f; float f;
@ -1044,7 +1042,7 @@ static float fgetf (FILE *file)
} }
/* returns a floating point with double precision (64 bits) */ /* returns a floating point with double precision (64 bits) */
static double fgetd (FILE *file) static double fgetd(FILE *file)
{ {
union { union {
double d; double d;
@ -1058,7 +1056,7 @@ static double fgetd (FILE *file)
} }
/* returns 0 in success or -1 in error */ /* returns 0 in success or -1 in error */
static int fputf (float c, FILE *file) static int fputf(float c, FILE *file)
{ {
union { union {
float f; float f;
@ -1070,7 +1068,7 @@ static int fputf (float c, FILE *file)
} }
/* returns 0 in success or -1 in error */ /* returns 0 in success or -1 in error */
static int fputd (double c, FILE *file) static int fputd(double c, FILE *file)
{ {
union { union {
double d; double d;

View File

@ -45,7 +45,7 @@ static struct {
Layer *layer; Layer *layer;
int frpos; int frpos;
Image *last_image; Image *last_image;
Frame *last_frame; Cel *last_cel;
/* to save */ /* to save */
Image *image; Image *image;
} file_sequence; } file_sequence;
@ -106,7 +106,7 @@ Image *file_sequence_image(int imgtype, int w, int h)
/* create a bitmap */ /* create a bitmap */
if (file_sequence.last_frame) { if (file_sequence.last_cel) {
console_printf(_("Error: called two times \"file_sequence_image ()\".\n")); console_printf(_("Error: called two times \"file_sequence_image ()\".\n"));
return NULL; return NULL;
} }
@ -118,7 +118,7 @@ Image *file_sequence_image(int imgtype, int w, int h)
} }
file_sequence.last_image = image; 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; return image;
} }
@ -198,17 +198,17 @@ Sprite *sprite_load(const char *filename)
index = stock_add_image(file_sequence.layer->stock, \ index = stock_add_image(file_sequence.layer->stock, \
file_sequence.last_image); \ file_sequence.last_image); \
\ \
file_sequence.last_frame->image = index; \ file_sequence.last_cel->image = index; \
\ \
layer_add_frame(file_sequence.layer, \ layer_add_cel(file_sequence.layer, \
file_sequence.last_frame); \ file_sequence.last_cel); \
\ \
sprite_set_palette(file_sequence.sprite, file_palette, c); \ sprite_set_palette(file_sequence.sprite, file_palette, c); \
\ \
old_image = file_sequence.last_image; \ old_image = file_sequence.last_image; \
\ \
file_sequence.last_image = NULL; \ file_sequence.last_image = NULL; \
file_sequence.last_frame = NULL; \ file_sequence.last_cel = NULL; \
} while (0) } while (0)
char buf[512], left[512], right[512]; char buf[512], left[512], right[512];
@ -264,7 +264,7 @@ Sprite *sprite_load(const char *filename)
file_sequence.layer = NULL; file_sequence.layer = NULL;
file_sequence.frpos = 0; file_sequence.frpos = 0;
file_sequence.last_image = NULL; file_sequence.last_image = NULL;
file_sequence.last_frame = NULL; file_sequence.last_cel = NULL;
/* load the sequence */ /* load the sequence */
c = 0; c = 0;
@ -281,12 +281,12 @@ Sprite *sprite_load(const char *filename)
/* for the first frame */ /* for the first frame */
if (!old_image) { if (!old_image) {
/* error reading the first frame */ /* error reading the first frame */
if ((!sprite) || (!file_sequence.last_frame)) { if ((!sprite) || (!file_sequence.last_cel)) {
if (file_sequence.last_image) if (file_sequence.last_image)
image_free(file_sequence.last_image); image_free(file_sequence.last_image);
if (file_sequence.last_frame) if (file_sequence.last_cel)
frame_free(file_sequence.last_frame); cel_free(file_sequence.last_cel);
if (file_sequence.sprite) { if (file_sequence.sprite) {
sprite_free(file_sequence.sprite); sprite_free(file_sequence.sprite);
@ -307,12 +307,12 @@ Sprite *sprite_load(const char *filename)
/* for other frames */ /* for other frames */
else { else {
/* all done (or maybe not enough memory) */ /* all done (or maybe not enough memory) */
if ((!sprite) || (!file_sequence.last_frame)) { if ((!sprite) || (!file_sequence.last_cel)) {
if (file_sequence.last_image) if (file_sequence.last_image)
image_free (file_sequence.last_image); image_free(file_sequence.last_image);
if (file_sequence.last_frame) if (file_sequence.last_cel)
frame_free (file_sequence.last_frame); cel_free(file_sequence.last_cel);
break; break;
} }
@ -327,12 +327,12 @@ Sprite *sprite_load(const char *filename)
image_free(file_sequence.last_image); image_free(file_sequence.last_image);
/* but add a link frame */ /* but add a link frame */
file_sequence.last_frame->image = index; file_sequence.last_cel->image = index;
layer_add_frame(file_sequence.layer, layer_add_frame(file_sequence.layer,
file_sequence.last_frame); file_sequence.last_cel);
file_sequence.last_image = NULL; file_sequence.last_image = NULL;
file_sequence.last_frame = NULL; file_sequence.last_cel = NULL;
} }
#else #else
SEQUENCE_IMAGE(); SEQUENCE_IMAGE();

View File

@ -130,7 +130,7 @@ static Sprite *load_FLI(const char *filename)
/* add the new frame */ /* add the new frame */
index = stock_add_image(layer->stock, image_new_copy(bmp)); 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 */ /* first frame or the palette changes */
if ((frpos_in == 0) || (memcmp(omap, cmap, 768) != 0)) if ((frpos_in == 0) || (memcmp(omap, cmap, 768) != 0))
@ -142,7 +142,7 @@ static Sprite *load_FLI(const char *filename)
SETPAL(); SETPAL();
/* add link */ /* 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 */ /* the palette and the image don't change: add duration to the last added frame */
else { else {

View File

@ -82,8 +82,8 @@ static Sprite *load_GIF(const char *filename)
{ {
GIF_ANIMATION *gif = NULL; GIF_ANIMATION *gif = NULL;
Sprite *sprite = NULL; Sprite *sprite = NULL;
Frame *frame = NULL;
Layer *layer = NULL; Layer *layer = NULL;
Cel *cel = NULL;
Image *image = NULL; Image *image = NULL;
Image *current_image_old = NULL; Image *current_image_old = NULL;
Image *current_image = NULL; Image *current_image = NULL;
@ -168,7 +168,7 @@ static Sprite *load_GIF(const char *filename)
/* copy new palette to old palette */ /* copy new palette to old palette */
palette_copy(opal, npal); palette_copy(opal, npal);
frame = frame_new(i, 0); cel = cel_new(i, 0);
image = image_new(IMAGE_INDEXED, image = image_new(IMAGE_INDEXED,
#ifdef LOAD_GIF_STRUCTURE #ifdef LOAD_GIF_STRUCTURE
gif->frames[i].w, gif->frames[i].w,
@ -177,21 +177,21 @@ static Sprite *load_GIF(const char *filename)
sprite->w, sprite->h sprite->w, sprite->h
#endif #endif
); );
if (!frame || !image) { if (!cel || !image) {
if (frame) frame_free(frame); if (cel) cel_free(cel);
if (image) image_free(image); if (image) image_free(image);
console_printf(_("Error creating frame %d.\n"), i); console_printf(_("Error creating cel %d.\n"), i);
break; break;
} }
frame_set_position(frame, cel_set_position(cel,
#ifdef LOAD_GIF_STRUCTURE #ifdef LOAD_GIF_STRUCTURE
gif->frames[i].xoff, gif->frames[i].xoff,
gif->frames[i].yoff gif->frames[i].yoff
#else #else
0, 0 0, 0
#endif #endif
); );
image_copy(current_image_old, current_image, 0, 0); image_copy(current_image_old, current_image, 0, 0);
render_gif_frame(gif->frames+i, current_image, render_gif_frame(gif->frames+i, current_image,
@ -207,8 +207,8 @@ static Sprite *load_GIF(const char *filename)
0, 0 0, 0
#endif #endif
); );
frame->image = stock_add_image(layer->stock, image); cel->image = stock_add_image(layer->stock, image);
layer_add_frame(layer, frame); layer_add_cel(layer, cel);
#ifdef LOAD_GIF_STRUCTURE #ifdef LOAD_GIF_STRUCTURE
/* when load the GIF structure, the disposal method is ever /* when load the GIF structure, the disposal method is ever

View File

@ -369,7 +369,7 @@ static Sprite *load_TGA (const char *filename)
} }
else { else {
if (compressed) { if (compressed) {
rle_tga_read16 (image->line[yc], image_width, f); rle_tga_read16(image->line[yc], image_width, f);
} }
else { else {
for (x=0; x<image_width; x++) { for (x=0; x<image_width; x++) {

View File

@ -52,7 +52,7 @@ int init_module_editors(void)
return 0; return 0;
} }
void exit_module_editors (void) void exit_module_editors(void)
{ {
jlist_free(editors); jlist_free(editors);
} }
@ -391,7 +391,7 @@ void make_unique_editor(JWidget editor)
editor_update(editor); editor_update(editor);
} }
static int is_sprite_in_some_editor (Sprite *sprite) static int is_sprite_in_some_editor(Sprite *sprite)
{ {
JWidget widget; JWidget widget;
JLink link; JLink link;

View File

@ -691,7 +691,7 @@ static bool manager_msg_proc(JWidget widget, JMessage msg)
case JM_IDLE: case JM_IDLE:
gui_feedback(); gui_feedback();
/* don't eat CPU... rest some time */ /* don't eat CPU... rest some time */
rest(0); rest(1);
break; break;
case JM_CHAR: { case JM_CHAR: {

View File

@ -120,13 +120,13 @@ void SetDrawMode (const char *string)
rectangle, ellipse rectangle, ellipse
uses the current FG color uses the current FG color
*/ */
void ToolTrace (const char *string) void ToolTrace(const char *string)
{ {
Sprite *sprite = current_sprite; Sprite *sprite = current_sprite;
if (sprite) { if (sprite) {
Tool *old_current_tool = current_tool; Tool *old_current_tool = current_tool;
char *copy = jstrdup (string); char *copy = jstrdup(string);
char *tok; char *tok;
int count; int count;
int npoints = 0; int npoints = 0;
@ -137,19 +137,19 @@ void ToolTrace (const char *string)
tok=strtok (NULL, " "), count++) { tok=strtok (NULL, " "), count++) {
switch (count) { switch (count) {
case 0: case 0:
select_tool (tok); select_tool(tok);
break; break;
default: { default: {
int u, v; int u, v;
char *s; char *s;
u = (int)strtod (tok, &s); u = (int)strtod(tok, &s);
if (s && *s == ',') { if (s && *s == ',') {
v = (int)strtod (s+1, &s); v = (int)strtod(s+1, &s);
npoints++; npoints++;
x = jrealloc (x, sizeof (int)*npoints); x = jrealloc(x, sizeof (int)*npoints);
y = jrealloc (y, sizeof (int)*npoints); y = jrealloc(y, sizeof (int)*npoints);
x[npoints-1] = u; x[npoints-1] = u;
y[npoints-1] = v; y[npoints-1] = v;
} }
@ -159,14 +159,14 @@ void ToolTrace (const char *string)
} }
if (npoints > 0) { if (npoints > 0) {
do_tool_points (sprite, current_tool, get_fg_color (), npoints, x, y); do_tool_points(sprite, current_tool, get_fg_color(), npoints, x, y);
jfree (x); jfree(x);
jfree (y); 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_quality;
static int cfg_jpeg_method; static int cfg_jpeg_method;
void ResetConfig (void) void ResetConfig(void)
{ {
JRect rect; JRect rect;

97
src/raster/cel.c Normal file
View File

@ -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; frpos<cel->frpos; 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;
}

View File

@ -16,16 +16,16 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifndef RASTER_FRAME_H #ifndef RASTER_CEL_H
#define RASTER_FRAME_H #define RASTER_CEL_H
#include "raster/gfxobj.h" #include "raster/gfxobj.h"
struct Layer; struct Layer;
typedef struct Frame Frame; typedef struct Cel Cel;
struct Frame struct Cel
{ {
GfxObj gfxobj; GfxObj gfxobj;
int frpos; /* frame position */ int frpos; /* frame position */
@ -34,15 +34,15 @@ struct Frame
int opacity; /* opacity level */ int opacity; /* opacity level */
}; };
Frame *frame_new (int frpos, int image); Cel *cel_new(int frpos, int image);
Frame *frame_new_copy (const Frame *frame); Cel *cel_new_copy(const Cel *cel);
void frame_free (Frame *frame); 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 cel_set_frpos(Cel *cel, int frpos);
void frame_set_image (Frame *frame, int image); void cel_set_image(Cel *cel, int image);
void frame_set_position (Frame *frame, int x, int y); void cel_set_position(Cel *cel, int x, int y);
void frame_set_opacity (Frame *frame, int opacity); void cel_set_opacity(Cel *cel, int opacity);
#endif /* RASTER_FRAME_H */ #endif /* RASTER_FRAME_H */

View File

@ -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; frpos<frame->frpos; 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;
}

View File

@ -22,7 +22,7 @@
#include "jinete/base.h" #include "jinete/base.h"
enum { enum {
GFXOBJ_FRAME, GFXOBJ_CEL,
GFXOBJ_IMAGE, GFXOBJ_IMAGE,
GFXOBJ_LAYER_IMAGE, GFXOBJ_LAYER_IMAGE,
GFXOBJ_LAYER_SET, GFXOBJ_LAYER_SET,

View File

@ -75,17 +75,18 @@ struct Image
/* struct BITMAP *bmp; */ /* struct BITMAP *bmp; */
}; };
typedef struct ImageMethods { typedef struct ImageMethods
int (*init) (Image *image); {
int (*getpixel) (const Image *image, int x, int y); int (*init)(Image *image);
void (*putpixel) (Image *image, int x, int y, int color); int (*getpixel)(const Image *image, int x, int y);
void (*clear) (Image *image, int color); void (*putpixel)(Image *image, int x, int y, int color);
void (*copy) (Image *dst, const Image *src, int x, int y); void (*clear)(Image *image, int color);
void (*merge) (Image *dst, const Image *src, int x, int y, int opacity, void (*copy)(Image *dst, const Image *src, int x, int y);
int blend_mode); void (*merge)(Image *dst, const Image *src, int x, int y, int opacity,
void (*hline) (Image *image, int x1, int y, int x2, int color); int blend_mode);
void (*rectfill) (Image *image, int x1, int y1, int x2, int y2, int color); void (*hline)(Image *image, int x1, int y, int x2, int color);
void (*to_allegro) (const Image *image, struct BITMAP *bmp, int x, int y); 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; } ImageMethods;
Image *image_new(int imgtype, int w, int h); Image *image_new(int imgtype, int w, int h);

View File

@ -25,14 +25,14 @@
#include "jinete/list.h" #include "jinete/list.h"
#include "raster/blend.h" #include "raster/blend.h"
#include "raster/frame.h" #include "raster/cel.h"
#include "raster/image.h" #include "raster/image.h"
#include "raster/layer.h" #include "raster/layer.h"
#include "raster/stock.h" #include "raster/stock.h"
#endif #endif
static int has_frames (Layer *layer, int frpos); static int has_cels(Layer *layer, int frpos);
#define LAYER_INIT(name_string) \ #define LAYER_INIT(name_string) \
do { \ do { \
@ -45,7 +45,7 @@ static int has_frames (Layer *layer, int frpos);
layer->imgtype = 0; \ layer->imgtype = 0; \
layer->blend_mode = 0; \ layer->blend_mode = 0; \
layer->stock = NULL; \ layer->stock = NULL; \
layer->frames = NULL; \ layer->cels = NULL; \
\ \
layer->layers = NULL; \ layer->layers = NULL; \
} while (0); } while (0);
@ -62,7 +62,7 @@ Layer *layer_new(int imgtype)
layer->imgtype = imgtype; layer->imgtype = imgtype;
layer->blend_mode = BLEND_MODE_NORMAL; layer->blend_mode = BLEND_MODE_NORMAL;
layer->stock = stock_new(imgtype); layer->stock = stock_new(imgtype);
layer->frames = jlist_new(); layer->cels = jlist_new();
return layer; return layer;
} }
@ -110,7 +110,7 @@ Layer *layer_new_copy(const Layer *layer)
switch (layer->gfxobj.type) { switch (layer->gfxobj.type) {
case GFXOBJ_LAYER_IMAGE: { case GFXOBJ_LAYER_IMAGE: {
Frame *frame_copy; Cel *cel_copy;
JLink link; JLink link;
layer_copy = layer_new(layer->imgtype); layer_copy = layer_new(layer->imgtype);
@ -127,14 +127,14 @@ Layer *layer_new_copy(const Layer *layer)
return NULL; return NULL;
} }
/* copy frames */ /* copy cels */
JI_LIST_FOR_EACH(layer->frames, link) { JI_LIST_FOR_EACH(layer->cels, link) {
frame_copy = frame_new_copy(link->data); cel_copy = cel_new_copy(link->data);
if (!frame_copy) { if (!cel_copy) {
layer_free(layer_copy); layer_free(layer_copy);
return NULL; return NULL;
} }
layer_add_frame(layer_copy, frame_copy); layer_add_cel(layer_copy, cel_copy);
} }
break; 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_new_with_image(int imgtype, int x, int y, int w, int h, int frpos)
{ {
Layer *layer; Layer *layer;
Frame *frame; Cel *cel;
Image *image; Image *image;
int index; 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 */ /* add image in the layer stock */
index = stock_add_image(layer->stock, image); index = stock_add_image(layer->stock, image);
/* create the frame */ /* create the cel */
frame = frame_new(frpos, index); cel = cel_new(frpos, index);
frame_set_position (frame, x, y); cel_set_position(cel, x, y);
/* add the frame in the layer */ /* add the cel in the layer */
layer_add_frame(layer, frame); layer_add_cel(layer, cel);
return layer; return layer;
} }
@ -227,11 +227,11 @@ void layer_free (Layer *layer)
if (layer->stock) if (layer->stock)
stock_free(layer->stock); stock_free(layer->stock);
/* remove frames */ /* remove cels */
JI_LIST_FOR_EACH(layer->frames, link) JI_LIST_FOR_EACH(layer->cels, link)
frame_free(link->data); cel_free(link->data);
jlist_free(layer->frames); jlist_free(layer->cels);
break; break;
} }
@ -243,6 +243,7 @@ void layer_free (Layer *layer)
} }
case GFXOBJ_LAYER_TEXT: case GFXOBJ_LAYER_TEXT:
/* TODO */
/* if (layer->text) */ /* if (layer->text) */
/* r_free (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) */ /* 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; return (layer->gfxobj.type == GFXOBJ_LAYER_IMAGE) ? TRUE: FALSE;
} }
/* returns TRUE if "layer" is a set of layers */ /* 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; return (layer->gfxobj.type == GFXOBJ_LAYER_SET) ? TRUE: FALSE;
} }
@ -290,51 +291,51 @@ Layer *layer_get_next(Layer *layer)
return NULL; 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) if (layer->gfxobj.type == GFXOBJ_LAYER_IMAGE)
layer->blend_mode = blend_mode; layer->blend_mode = blend_mode;
} }
void layer_set_parent (Layer *layer, GfxObj *gfxobj) void layer_set_parent(Layer *layer, GfxObj *gfxobj)
{ {
layer->parent = 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)) { if (layer_is_image(layer)) {
JLink link; JLink link;
JI_LIST_FOR_EACH(layer->frames, link) JI_LIST_FOR_EACH(layer->cels, link)
if (((Frame *)link->data)->frpos >= frame->frpos) if (((Cel *)link->data)->frpos >= cel->frpos)
break; 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)) 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)) { if (layer_is_image(layer)) {
Frame *frame; Cel *cel;
JLink link; JLink link;
JI_LIST_FOR_EACH(layer->frames, link) { JI_LIST_FOR_EACH(layer->cels, link) {
frame = link->data; cel = link->data;
if (frame->frpos == frpos) if (cel->frpos == frpos)
return frame; return cel;
} }
} }
@ -379,21 +380,21 @@ void layer_render(Layer *layer, Image *image, int x, int y, int frpos)
switch (layer->gfxobj.type) { switch (layer->gfxobj.type) {
case GFXOBJ_LAYER_IMAGE: { case GFXOBJ_LAYER_IMAGE: {
Frame *frame = layer_get_frame (layer, frpos); Cel *cel = layer_get_cel(layer, frpos);
Image *src_image; Image *src_image;
if (frame) { if (cel) {
if ((frame->image >= 0) && if ((cel->image >= 0) &&
(frame->image < layer->stock->nimage)) (cel->image < layer->stock->nimage))
src_image = layer->stock->image[frame->image]; src_image = layer->stock->image[cel->image];
else else
src_image = NULL; src_image = NULL;
if (src_image) { if (src_image) {
image_merge(image, src_image, image_merge(image, src_image,
frame->x + x, cel->x + x,
frame->y + y, cel->y + y,
MID (0, frame->opacity, 255), MID (0, cel->opacity, 255),
layer->blend_mode); 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 * Returns a new layer (flat_layer) with all "layer" rendered frame
of layers, so the routines flatten all childs to the unique output * by frame from "frmin" to "frmax" (inclusive). "layer" can be a set
layer */ * of layers, so the routines flatten all childs to the unique output
* layer.
*/
Layer *layer_flatten(Layer *layer, int imgtype, Layer *layer_flatten(Layer *layer, int imgtype,
int x, int y, int w, int h, int frmin, int frmax) int x, int y, int w, int h, int frmin, int frmax)
{ {
Layer *flat_layer; Layer *flat_layer;
Image *image; Image *image;
Frame *frame; Cel *cel;
int frpos; int frpos;
flat_layer = layer_new(imgtype); flat_layer = layer_new(imgtype);
@ -432,8 +435,8 @@ Layer *layer_flatten(Layer *layer, int imgtype,
layer_set_name(flat_layer, "Flat Layer"); layer_set_name(flat_layer, "Flat Layer");
for (frpos=frmin; frpos<=frmax; frpos++) { for (frpos=frmin; frpos<=frmax; frpos++) {
/* this "frpos" has frames to render */ /* does this "frpos" have cels to render? */
if (has_frames(layer, frpos)) { if (has_cels(layer, frpos)) {
/* create a new image */ /* create a new image */
image = image_new(imgtype, w, h); image = image_new(imgtype, w, h);
if (!image) { if (!image) {
@ -441,11 +444,11 @@ Layer *layer_flatten(Layer *layer, int imgtype,
return NULL; 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) */ stock too) */
frame = frame_new(frpos, stock_add_image(flat_layer->stock, image)); cel = cel_new(frpos, stock_add_image(flat_layer->stock, image));
frame_set_position(frame, x, y); cel_set_position(cel, x, y);
if (!frame) { if (!cel) {
layer_free(flat_layer); layer_free(flat_layer);
image_free(image); image_free(image);
return NULL; return NULL;
@ -454,15 +457,15 @@ Layer *layer_flatten(Layer *layer, int imgtype,
/* clear the image and render this frame */ /* clear the image and render this frame */
image_clear(image, 0); image_clear(image, 0);
layer_render(layer, image, -x, -y, frpos); layer_render(layer, image, -x, -y, frpos);
layer_add_frame(flat_layer, frame); layer_add_cel(flat_layer, cel);
} }
} }
return flat_layer; return flat_layer;
} }
/* returns TRUE if the "layer" (or him childs) has frames to render in frpos */ /* returns TRUE if the "layer" (or him childs) has cels to render in frpos */
static int has_frames(Layer *layer, int frpos) static int has_cels(Layer *layer, int frpos)
{ {
if (!layer->readable) if (!layer->readable)
return FALSE; return FALSE;
@ -470,18 +473,19 @@ static int has_frames(Layer *layer, int frpos)
switch (layer->gfxobj.type) { switch (layer->gfxobj.type) {
case GFXOBJ_LAYER_IMAGE: case GFXOBJ_LAYER_IMAGE:
return layer_get_frame(layer, frpos) ? TRUE: FALSE; return layer_get_cel(layer, frpos) ? TRUE: FALSE;
case GFXOBJ_LAYER_SET: { case GFXOBJ_LAYER_SET: {
JLink link; JLink link;
JI_LIST_FOR_EACH(layer->layers, link) JI_LIST_FOR_EACH(layer->layers, link) {
if (has_frames(link->data, frpos)) if (has_cels(link->data, frpos))
return TRUE; return TRUE;
}
break; break;
} }
case GFXOBJ_LAYER_TEXT: case GFXOBJ_LAYER_TEXT:
/* XXX */ /* TODO */
break; break;
} }

View File

@ -22,7 +22,7 @@
#include "jinete/base.h" #include "jinete/base.h"
#include "raster/gfxobj.h" #include "raster/gfxobj.h"
struct Frame; struct Cel;
struct Image; struct Image;
struct Stock; struct Stock;
@ -40,7 +40,7 @@ struct Layer
int imgtype; /* image type */ int imgtype; /* image type */
int blend_mode; /* constant blend mode */ int blend_mode; /* constant blend mode */
struct Stock *stock; /* stock to get images */ struct Stock *stock; /* stock to get images */
JList frames; /* list of frames */ JList cels; /* list of cels */
/* for GFXOBJ_LAYER_SET */ /* for GFXOBJ_LAYER_SET */
JList layers; JList layers;
@ -72,9 +72,9 @@ void layer_set_blend_mode(Layer *layer, int blend_mode);
void layer_set_parent(Layer *layer, GfxObj *gfxobj); void layer_set_parent(Layer *layer, GfxObj *gfxobj);
/* for LAYER_IMAGE */ /* for LAYER_IMAGE */
void layer_add_frame(Layer *layer, struct Frame *frame); void layer_add_cel(Layer *layer, struct Cel *cel);
void layer_remove_frame(Layer *layer, struct Frame *frame); void layer_remove_cel(Layer *layer, struct Cel *cel);
struct Frame *layer_get_frame(Layer *layer, int frpos); struct Cel *layer_get_cel(Layer *layer, int frpos);
/* for LAYER_SET */ /* for LAYER_SET */
void layer_add_layer(Layer *set, Layer *layer); void layer_add_layer(Layer *set, Layer *layer);

View File

@ -22,8 +22,8 @@
#include "raster/algo.h" #include "raster/algo.h"
#include "raster/blend.h" #include "raster/blend.h"
#include "raster/brush.h" #include "raster/brush.h"
#include "raster/cel.h"
#include "raster/dirty.h" #include "raster/dirty.h"
#include "raster/frame.h"
#include "raster/gfxobj.h" #include "raster/gfxobj.h"
#include "raster/image.h" #include "raster/image.h"
#include "raster/layer.h" #include "raster/layer.h"

View File

@ -459,14 +459,14 @@ void sprite_add_mask (Sprite *sprite, Mask *mask)
} }
/* removes a mask from the sprites's repository */ /* 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 */ /* remove the mask from the repository */
jlist_remove(sprite->repository.masks, mask); jlist_remove(sprite->repository.masks, mask);
} }
/* returns a mask from the sprite's repository searching it by its name */ /* 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; Mask *mask;
JLink link; JLink link;

View File

@ -26,8 +26,8 @@
#include "jinete/list.h" #include "jinete/list.h"
#include "raster/cel.h"
#include "raster/dirty.h" #include "raster/dirty.h"
#include "raster/frame.h"
#include "raster/image.h" #include "raster/image.h"
#include "raster/layer.h" #include "raster/layer.h"
#include "raster/mask.h" #include "raster/mask.h"
@ -62,9 +62,9 @@ enum {
UNDO_TYPE_REMOVE_IMAGE, UNDO_TYPE_REMOVE_IMAGE,
UNDO_TYPE_REPLACE_IMAGE, UNDO_TYPE_REPLACE_IMAGE,
/* frame management */ /* cel management */
UNDO_TYPE_ADD_FRAME, UNDO_TYPE_ADD_CEL,
UNDO_TYPE_REMOVE_FRAME, UNDO_TYPE_REMOVE_CEL,
/* layer management */ /* layer management */
UNDO_TYPE_ADD_LAYER, 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 chunk_replace_image(UndoStream *stream, Stock *stock, int index);
static void redo_replace_image(UndoStream *stream, UndoChunk *chunk, int state); static void redo_replace_image(UndoStream *stream, UndoChunk *chunk, int state);
static void chunk_add_frame(UndoStream *stream, Layer *layer, Frame *frame); static void chunk_add_cel(UndoStream *stream, Layer *layer, Cel *cel);
static void redo_add_frame(UndoStream *stream, UndoChunk *chunk, int state); static void redo_add_cel(UndoStream *stream, UndoChunk *chunk, int state);
static void chunk_remove_frame(UndoStream *stream, Layer *layer, Frame *frame); static void chunk_remove_cel(UndoStream *stream, Layer *layer, Cel *cel);
static void redo_remove_frame(UndoStream *stream, UndoChunk *chunk, int state); static void redo_remove_cel(UndoStream *stream, UndoChunk *chunk, int state);
static void chunk_add_layer(UndoStream *stream, Layer *set, Layer *layer); static void chunk_add_layer(UndoStream *stream, Layer *set, Layer *layer);
static void redo_add_layer(UndoStream *stream, UndoChunk *chunk, int state); 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 }, { "Add image", redo_add_image },
{ "Remove image", redo_remove_image }, { "Remove image", redo_remove_image },
{ "Replace image", redo_replace_image }, { "Replace image", redo_replace_image },
{ "Add frame", redo_add_frame }, { "Add cel", redo_add_cel },
{ "Remove frame", redo_remove_frame }, { "Remove cel", redo_remove_cel },
{ "Add layer", redo_add_layer }, { "Add layer", redo_add_layer },
{ "Remove layer", redo_remove_layer }, { "Remove layer", redo_remove_layer },
{ "Move layer", redo_move_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 char *undo_chunk_read_string(UndoChunk *chunk);
static void undo_chunk_write_string(UndoChunk *chunk, const char *string); static void undo_chunk_write_string(UndoChunk *chunk, const char *string);
static Frame *undo_chunk_read_frame(UndoChunk *chunk); static Cel *undo_chunk_read_cel(UndoChunk *chunk);
static void undo_chunk_write_frame(UndoChunk *chunk, Frame *frame); static void undo_chunk_write_cel(UndoChunk *chunk, Cel *cel);
static Layer *undo_chunk_read_layer(UndoChunk *chunk); static Layer *undo_chunk_read_layer(UndoChunk *chunk);
static void undo_chunk_write_layer(UndoChunk *chunk, Layer *layer); 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 stock ID
DWORD index 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 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); 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, layer->gfxobj.id);
undo_chunk_put32(chunk, frame->gfxobj.id); undo_chunk_put32(chunk, cel->gfxobj.id);
undo_stream_push_chunk(stream, chunk); 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 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); Layer *layer = (Layer *)gfxobj_find(layer_id);
Frame *frame = (Frame *)gfxobj_find(frame_id); Cel *cel = (Cel *)gfxobj_find(cel_id);
if (layer && frame) { if (layer && cel) {
chunk_remove_frame(stream, layer, frame); chunk_remove_cel(stream, layer, cel);
layer_remove_frame(layer, frame); layer_remove_cel(layer, cel);
frame_free(frame); cel_free(cel);
} }
} }
/*********************************************************************** /***********************************************************************
"remove_frame" "remove_cel"
DWORD layer ID 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); 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_put32(chunk, layer->gfxobj.id);
undo_chunk_write_frame(chunk, frame); undo_chunk_write_cel(chunk, cel);
undo_stream_push_chunk(stream, chunk); 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); unsigned long layer_id = undo_chunk_get32(chunk);
Layer *layer = (Layer *)gfxobj_find(layer_id); Layer *layer = (Layer *)gfxobj_find(layer_id);
if (layer) { 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); chunk_add_cel(stream, layer, cel);
layer_add_frame(layer, frame); 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); 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 frpos = undo_chunk_get16(chunk);
int image = undo_chunk_get16(chunk); int image = undo_chunk_get16(chunk);
int x = (short)undo_chunk_get16(chunk); int x = (short)undo_chunk_get16(chunk);
int y = (short)undo_chunk_get16(chunk); int y = (short)undo_chunk_get16(chunk);
int opacity = undo_chunk_get8(chunk); int opacity = undo_chunk_get8(chunk);
Frame *frame = frame_new(frpos, image); Cel *cel = cel_new(frpos, image);
frame_set_position(frame, x, y); cel_set_position(cel, x, y);
frame_set_opacity(frame, opacity); cel_set_opacity(cel, opacity);
_gfxobj_set_id ((GfxObj *)frame, frame_id); _gfxobj_set_id((GfxObj *)cel, cel_id);
return frame; 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_put32(chunk, cel->gfxobj.id);
undo_chunk_put16(chunk, frame->frpos); undo_chunk_put16(chunk, cel->frpos);
undo_chunk_put16(chunk, frame->image); undo_chunk_put16(chunk, cel->image);
undo_chunk_put16(chunk, frame->x); undo_chunk_put16(chunk, cel->x);
undo_chunk_put16(chunk, frame->y); undo_chunk_put16(chunk, cel->y);
undo_chunk_put8(chunk, frame->opacity); undo_chunk_put8(chunk, cel->opacity);
} }
static Layer *undo_chunk_read_layer(UndoChunk *chunk) 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 imgtype = undo_chunk_get8(chunk); /* imgtype */
int blend_mode = undo_chunk_get8(chunk); /* blend mode */ int blend_mode = undo_chunk_get8(chunk); /* blend mode */
Stock *stock = undo_chunk_read_stock(chunk); /* stock */ 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 */ /* create layer */
layer = layer_new(imgtype); layer = layer_new(imgtype);
@ -1435,9 +1435,9 @@ static Layer *undo_chunk_read_layer(UndoChunk *chunk)
stock_free(layer->stock); stock_free(layer->stock);
layer->stock = stock; layer->stock = stock;
/* read frames */ /* read cels */
for (c=0; c<frames; c++) for (c=0; c<cels; c++)
layer_add_frame(layer, undo_chunk_read_frame(chunk)); layer_add_cel(layer, undo_chunk_read_cel(chunk));
break; break;
} }
@ -1498,10 +1498,10 @@ static void undo_chunk_write_layer(UndoChunk *chunk, Layer *layer)
undo_chunk_put8(chunk, layer->blend_mode); /* blend mode */ undo_chunk_put8(chunk, layer->blend_mode); /* blend mode */
/* stock */ /* stock */
undo_chunk_write_stock(chunk, layer->stock); /* stock */ undo_chunk_write_stock(chunk, layer->stock); /* stock */
/* frames */ /* cels */
undo_chunk_put16(chunk, jlist_length(layer->frames)); undo_chunk_put16(chunk, jlist_length(layer->cels));
JI_LIST_FOR_EACH(layer->frames, link) JI_LIST_FOR_EACH(layer->cels, link)
undo_chunk_write_frame(chunk, link->data); undo_chunk_write_cel(chunk, link->data);
break; break;
case GFXOBJ_LAYER_SET: case GFXOBJ_LAYER_SET:

View File

@ -23,8 +23,8 @@
#include "raster/gfxobj.h" #include "raster/gfxobj.h"
struct Cel;
struct Dirty; struct Dirty;
struct Frame;
struct Image; struct Image;
struct Layer; struct Layer;
struct Mask; 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_add_image(Undo *undo, struct Stock *stock, struct Image *image);
void undo_remove_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_replace_image(Undo *undo, struct Stock *stock, int index);
void undo_add_frame(Undo *undo, struct Layer *layer, struct Frame *frame); void undo_add_cel(Undo *undo, struct Layer *layer, struct Cel *cel);
void undo_remove_frame(Undo *undo, struct Layer *layer, struct Frame *frame); 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_add_layer(Undo *undo, struct Layer *set, struct Layer *layer);
void undo_remove_layer(Undo *undo, struct Layer *layer); void undo_remove_layer(Undo *undo, struct Layer *layer);
void undo_move_layer(Undo *undo, struct Layer *layer); void undo_move_layer(Undo *undo, struct Layer *layer);

View File

@ -54,7 +54,7 @@ enum {
/* graphic objects */ /* graphic objects */
Type_Image, Type_Image,
Type_Frame, Type_Cel,
Type_Layer, Type_Layer,
Type_Mask, Type_Mask,
Type_Path, Type_Path,
@ -249,20 +249,20 @@ static int metatable_index(lua_State *L)
break; break;
} }
case Type_Frame: { case Type_Cel: {
Frame *frame = userdata->ptr; Cel *cel = userdata->ptr;
if (strcmp (index, "frpos") == 0) if (strcmp (index, "frpos") == 0)
lua_pushnumber (L, frame->frpos); lua_pushnumber (L, cel->frpos);
else if (strcmp (index, "image") == 0) else if (strcmp (index, "image") == 0)
lua_pushnumber (L, frame->image); lua_pushnumber (L, cel->image);
else if (strcmp (index, "x") == 0) else if (strcmp (index, "x") == 0)
lua_pushnumber (L, frame->x); lua_pushnumber (L, cel->x);
else if (strcmp (index, "y") == 0) else if (strcmp (index, "y") == 0)
lua_pushnumber (L, frame->y); lua_pushnumber (L, cel->y);
else if (strcmp (index, "opacity") == 0) else if (strcmp (index, "opacity") == 0)
lua_pushnumber (L, frame->opacity); lua_pushnumber (L, cel->opacity);
/* XXXX */ /* TODO */
/* else if (strcmp (index, "next") == 0) */ /* else if (strcmp (index, "next") == 0) */
/* lua_pushnumber (L, ); */ /* lua_pushnumber (L, ); */
/* else if (strcmp (index, "prev") == 0) */ /* else if (strcmp (index, "prev") == 0) */
@ -303,9 +303,9 @@ static int metatable_index(lua_State *L)
lua_pushnumber (L, layer->blend_mode); lua_pushnumber (L, layer->blend_mode);
else if (strcmp (index, "stock") == 0) else if (strcmp (index, "stock") == 0)
push_userdata (L, Type_Stock, layer->stock); push_userdata (L, Type_Stock, layer->stock);
else if (strcmp (index, "frames") == 0) else if (strcmp (index, "cels") == 0)
push_userdata (L, Type_Frame, push_userdata(L, Type_Cel,
jlist_first_data(layer->frames)); jlist_first_data(layer->cels));
else else
return 0; return 0;
break; break;
@ -731,9 +731,9 @@ static int bind_jwidget_hook_signal (lua_State *L)
#include "intl/intl.h" #include "intl/intl.h"
#include "modules/rootmenu.h" #include "modules/rootmenu.h"
#include "util/autocrop.h" #include "util/autocrop.h"
#include "util/celmove.h"
#include "util/clipbrd.h" #include "util/clipbrd.h"
#include "util/crop.h" #include "util/crop.h"
#include "util/frmove.h"
#include "util/mapgen.h" #include "util/mapgen.h"
#include "util/msk_file.h" #include "util/msk_file.h"
#include "util/quantize.h" #include "util/quantize.h"

View File

@ -223,15 +223,15 @@ void paste_from_clipboard(void);
void crop_sprite(void); void crop_sprite(void);
void crop_layer(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 move_cel(void);
void copy_frame(void); void copy_cel(void);
void link_frame(void); void link_cel(void);
/* util/mapgen.c */ /* util/mapgen.c */
@ -303,7 +303,7 @@ Image *RenderText(const char *fontname, int size, int color, const char *text);
#define GFXOBJ_IMAGE #define GFXOBJ_IMAGE
#define GFXOBJ_STOCK #define GFXOBJ_STOCK
#define GFXOBJ_FRAME #define GFXOBJ_CEL
#define GFXOBJ_LAYER_IMAGE #define GFXOBJ_LAYER_IMAGE
#define GFXOBJ_LAYER_SET #define GFXOBJ_LAYER_SET
#define GFXOBJ_LAYER_TEXT #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_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); 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); Cel *cel_new(int frpos, int image);
Frame *frame_new_copy(Frame *frame); Cel *cel_new_copy(Cel *cel);
void frame_free(Frame *frame); 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 cel_set_frpos(Cel *cel, int frpos);
void frame_set_image(Frame *frame, int image); void cel_set_image(Cel *cel, int image);
void frame_set_position(Frame *frame, int x, int y); void cel_set_position(Cel *cel, int x, int y);
void frame_set_opacity(Frame *frame, int opacity); void cel_set_opacity(Cel *cel, int opacity);
/* Layer ************************************************************/ /* Layer ************************************************************/
@ -420,9 +420,9 @@ void layer_set_blend_mode(Layer *layer, int blend_mode);
/* void layer_set_parent(Layer *layer, GfxObj *gfxobj); */ /* void layer_set_parent(Layer *layer, GfxObj *gfxobj); */
/* for LAYER_IMAGE */ /* for LAYER_IMAGE */
void layer_add_frame(Layer *layer, Frame *frame); void layer_add_cel(Layer *layer, Cel *cel);
void layer_remove_frame(Layer *layer, Frame *frame); void layer_remove_cel(Layer *layer, Cel *cel);
Frame *layer_get_frame(Layer *layer, int frpos); Cel *layer_get_cel(Layer *layer, int frpos);
/* for LAYER_SET */ /* for LAYER_SET */
void layer_add_layer(Layer *set, Layer *layer); 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_add_image(Undo *undo, Stock *stock, Image *image);
void undo_remove_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_replace_image(Undo *undo, Stock *stock, int index);
void undo_add_frame(Undo *undo, Layer *layer, Frame *frame); void undo_add_cel(Undo *undo, Layer *layer, Cel *cel);
void undo_remove_frame(Undo *undo, Layer *layer, Frame *frame); void undo_remove_cel(Undo *undo, Layer *layer, Cel *cel);
void undo_add_layer(Undo *undo, Layer *set, Layer *layer); void undo_add_layer(Undo *undo, Layer *set, Layer *layer);
void undo_remove_layer(Undo *undo, Layer *layer); void undo_remove_layer(Undo *undo, Layer *layer);
void undo_move_layer(Undo *undo, Layer *layer); void undo_move_layer(Undo *undo, Layer *layer);

View File

@ -26,8 +26,8 @@
#include "modules/gui.h" #include "modules/gui.h"
#include "modules/sprites.h" #include "modules/sprites.h"
#include "raster/blend.h" #include "raster/blend.h"
#include "raster/cel.h"
#include "raster/image.h" #include "raster/image.h"
#include "raster/frame.h"
#include "raster/layer.h" #include "raster/layer.h"
#include "raster/sprite.h" #include "raster/sprite.h"
#include "raster/stock.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; Sprite *sprite = current_sprite;
Layer *layer = NULL; Layer *layer = NULL;
Image *image; Image *image;
Frame *frame; Cel *cel;
int index; int index;
if (sprite && name) { 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 */ /* add image in the layer stock */
index = stock_add_image(layer->stock, image); index = stock_add_image(layer->stock, image);
/* create a new frame in the current frpos */ /* create a new cel in the current frame */
frame = frame_new(sprite->frpos, index); cel = cel_new(sprite->frpos, index);
frame_set_position(frame, x, y); cel_set_position(cel, x, y);
/* add frame */ /* add cel */
layer_add_frame(layer, frame); layer_add_cel(layer, cel);
/* undo stuff */ /* undo stuff */
if (undo_is_enabled(sprite->undo)) { if (undo_is_enabled(sprite->undo)) {
@ -244,13 +244,15 @@ Layer *FlattenLayers(void)
JI_LIST_FOR_EACH_SAFE(sprite->set->layers, link, next) { JI_LIST_FOR_EACH_SAFE(sprite->set->layers, link, next) {
if (link->data != flat_layer) { if (link->data != flat_layer) {
Layer *old_layer = link->data;
/* undo */ /* undo */
if (undo_is_enabled(sprite->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 */ /* remove and destroy this layer */
layer_remove_layer(sprite->set, link->data); layer_remove_layer(sprite->set, old_layer);
layer_free(link->data); 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; Sprite *sprite = current_sprite;
Image *image; Image *image;
Frame *it; Cel *it;
int frpos; int frpos;
bool used; bool used;
if (sprite != NULL && layer_is_image(layer) && frame != NULL) { if (sprite != NULL && layer_is_image(layer) && cel != NULL) {
/* find if the image that use the frame to remove, is used by /* find if the image that use the cel to remove, is used by
another frames */ another cels */
used = FALSE; used = FALSE;
for (frpos=0; frpos<sprite->frames; ++frpos) { for (frpos=0; frpos<sprite->frames; ++frpos) {
it = layer_get_frame(layer, frpos); it = layer_get_cel(layer, frpos);
if (it != NULL && it != frame && it->image == frame->image) { if (it != NULL && it != cel && it->image == cel->image) {
used = TRUE; used = TRUE;
break; break;
} }
@ -289,18 +291,18 @@ void RemoveFrame(Layer *layer, Frame *frame)
undo_open(sprite->undo); undo_open(sprite->undo);
if (!used) { 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 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); undo_remove_image(sprite->undo, layer->stock, image);
stock_remove_image(layer->stock, image); stock_remove_image(layer->stock, image);
image_free(image); image_free(image);
} }
undo_remove_frame(sprite->undo, layer, frame); undo_remove_cel(sprite->undo, layer, cel);
undo_close(sprite->undo); undo_close(sprite->undo);
/* remove the frame */ /* remove the cel */
layer_remove_frame(layer, frame); layer_remove_cel(layer, cel);
frame_free(frame); cel_free(cel);
} }
} }

View File

@ -21,7 +21,7 @@
struct Sprite; struct Sprite;
struct Layer; struct Layer;
struct Frame; struct Cel;
/* ======================================= */ /* ======================================= */
/* Sprite */ /* Sprite */
@ -40,9 +40,9 @@ void RemoveLayer(void);
struct Layer *FlattenLayers(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 */ #endif /* SCRIPT_FUNCTIONS_H */

View File

@ -1127,37 +1127,37 @@ static int bind_crop_layer(lua_State *L)
return 0; return 0;
} }
static int bind_crop_frame(lua_State *L) static int bind_crop_cel(lua_State *L)
{ {
crop_frame(); crop_cel();
return 0; return 0;
} }
static int bind_set_frame_to_handle(lua_State *L) static int bind_set_cel_to_handle(lua_State *L)
{ {
Layer *layer; Layer *layer;
Frame *frame; Cel *cel;
GetUD(1, layer, Layer); GetUD(1, layer, Layer);
GetUD(2, frame, Frame); GetUD(2, cel, Cel);
set_frame_to_handle(layer, frame); set_cel_to_handle(layer, cel);
return 0; return 0;
} }
static int bind_move_frame(lua_State *L) static int bind_move_cel(lua_State *L)
{ {
move_frame(); move_cel();
return 0; return 0;
} }
static int bind_copy_frame(lua_State *L) static int bind_copy_cel(lua_State *L)
{ {
copy_frame(); copy_cel();
return 0; return 0;
} }
static int bind_link_frame(lua_State *L) static int bind_link_cel(lua_State *L)
{ {
link_frame(); link_cel();
return 0; return 0;
} }
@ -1805,87 +1805,87 @@ static int bind_image_parallelogram(lua_State *L)
return 0; 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 frpos;
int image; int image;
GetArg(1, frpos, int, number); GetArg(1, frpos, int, number);
GetArg(2, image, int, number); GetArg(2, image, int, number);
return_value = frame_new(frpos, image); return_value = cel_new(frpos, image);
push_userdata(L, Type_Frame, return_value); push_userdata(L, Type_Cel, return_value);
return 1; return 1;
} }
static int bind_frame_new_copy(lua_State *L) static int bind_cel_new_copy(lua_State *L)
{ {
Frame *return_value; Cel *return_value;
Frame *frame; Cel *cel;
GetUD(1, frame, Frame); GetUD(1, cel, Cel);
return_value = frame_new_copy(frame); return_value = cel_new_copy(cel);
push_userdata(L, Type_Frame, return_value); push_userdata(L, Type_Cel, return_value);
return 1; return 1;
} }
static int bind_frame_free(lua_State *L) static int bind_cel_free(lua_State *L)
{ {
Frame *frame; Cel *cel;
GetUD(1, frame, Frame); GetUD(1, cel, Cel);
frame_free(frame); cel_free(cel);
return 0; return 0;
} }
static int bind_frame_is_link(lua_State *L) static int bind_cel_is_link(lua_State *L)
{ {
Frame *return_value; Cel *return_value;
Frame *frame; Cel *cel;
Layer *layer; Layer *layer;
GetUD(1, frame, Frame); GetUD(1, cel, Cel);
GetUD(2, layer, Layer); GetUD(2, layer, Layer);
return_value = frame_is_link(frame, layer); return_value = cel_is_link(cel, layer);
push_userdata(L, Type_Frame, return_value); push_userdata(L, Type_Cel, return_value);
return 1; 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; int frpos;
GetUD(1, frame, Frame); GetUD(1, cel, Cel);
GetArg(2, frpos, int, number); GetArg(2, frpos, int, number);
frame_set_frpos(frame, frpos); cel_set_frpos(cel, frpos);
return 0; 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; int image;
GetUD(1, frame, Frame); GetUD(1, cel, Cel);
GetArg(2, image, int, number); GetArg(2, image, int, number);
frame_set_image(frame, image); cel_set_image(cel, image);
return 0; 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 x;
int y; int y;
GetUD(1, frame, Frame); GetUD(1, cel, Cel);
GetArg(2, x, int, number); GetArg(2, x, int, number);
GetArg(3, y, int, number); GetArg(3, y, int, number);
frame_set_position(frame, x, y); cel_set_position(cel, x, y);
return 0; 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; int opacity;
GetUD(1, frame, Frame); GetUD(1, cel, Cel);
GetArg(2, opacity, int, number); GetArg(2, opacity, int, number);
frame_set_opacity(frame, opacity); cel_set_opacity(cel, opacity);
return 0; return 0;
} }
@ -2005,35 +2005,35 @@ static int bind_layer_set_blend_mode(lua_State *L)
return 0; return 0;
} }
static int bind_layer_add_frame(lua_State *L) static int bind_layer_add_cel(lua_State *L)
{ {
Layer *layer; Layer *layer;
Frame *frame; Cel *cel;
GetUD(1, layer, Layer); GetUD(1, layer, Layer);
GetUD(2, frame, Frame); GetUD(2, cel, Cel);
layer_add_frame(layer, frame); layer_add_cel(layer, cel);
return 0; return 0;
} }
static int bind_layer_remove_frame(lua_State *L) static int bind_layer_remove_cel(lua_State *L)
{ {
Layer *layer; Layer *layer;
Frame *frame; Cel *cel;
GetUD(1, layer, Layer); GetUD(1, layer, Layer);
GetUD(2, frame, Frame); GetUD(2, cel, Cel);
layer_remove_frame(layer, frame); layer_remove_cel(layer, cel);
return 0; 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; Layer *layer;
int frpos; int frpos;
GetUD(1, layer, Layer); GetUD(1, layer, Layer);
GetArg(2, frpos, int, number); GetArg(2, frpos, int, number);
return_value = layer_get_frame(layer, frpos); return_value = layer_get_cel(layer, frpos);
push_userdata(L, Type_Frame, return_value); push_userdata(L, Type_Cel, return_value);
return 1; return 1;
} }
@ -2931,27 +2931,27 @@ static int bind_undo_replace_image(lua_State *L)
return 0; return 0;
} }
static int bind_undo_add_frame(lua_State *L) static int bind_undo_add_cel(lua_State *L)
{ {
Undo *undo; Undo *undo;
Layer *layer; Layer *layer;
Frame *frame; Cel *cel;
GetUD(1, undo, Undo); GetUD(1, undo, Undo);
GetUD(2, layer, Layer); GetUD(2, layer, Layer);
GetUD(3, frame, Frame); GetUD(3, cel, Cel);
undo_add_frame(undo, layer, frame); undo_add_cel(undo, layer, cel);
return 0; return 0;
} }
static int bind_undo_remove_frame(lua_State *L) static int bind_undo_remove_cel(lua_State *L)
{ {
Undo *undo; Undo *undo;
Layer *layer; Layer *layer;
Frame *frame; Cel *cel;
GetUD(1, undo, Undo); GetUD(1, undo, Undo);
GetUD(2, layer, Layer); GetUD(2, layer, Layer);
GetUD(3, frame, Frame); GetUD(3, cel, Cel);
undo_remove_frame(undo, layer, frame); undo_remove_cel(undo, layer, cel);
return 0; return 0;
} }
@ -5682,11 +5682,11 @@ const luaL_reg bindings_routines[] = {
{ "paste_from_clipboard", bind_paste_from_clipboard }, { "paste_from_clipboard", bind_paste_from_clipboard },
{ "crop_sprite", bind_crop_sprite }, { "crop_sprite", bind_crop_sprite },
{ "crop_layer", bind_crop_layer }, { "crop_layer", bind_crop_layer },
{ "crop_frame", bind_crop_frame }, { "crop_cel", bind_crop_cel },
{ "set_frame_to_handle", bind_set_frame_to_handle }, { "set_cel_to_handle", bind_set_cel_to_handle },
{ "move_frame", bind_move_frame }, { "move_cel", bind_move_cel },
{ "copy_frame", bind_copy_frame }, { "copy_cel", bind_copy_cel },
{ "link_frame", bind_link_frame }, { "link_cel", bind_link_cel },
{ "mapgen", bind_mapgen }, { "mapgen", bind_mapgen },
{ "GetImage", bind_GetImage }, { "GetImage", bind_GetImage },
{ "GetImage2", bind_GetImage2 }, { "GetImage2", bind_GetImage2 },
@ -5745,14 +5745,14 @@ const luaL_reg bindings_routines[] = {
{ "image_scale", bind_image_scale }, { "image_scale", bind_image_scale },
{ "image_rotate", bind_image_rotate }, { "image_rotate", bind_image_rotate },
{ "image_parallelogram", bind_image_parallelogram }, { "image_parallelogram", bind_image_parallelogram },
{ "frame_new", bind_frame_new }, { "cel_new", bind_cel_new },
{ "frame_new_copy", bind_frame_new_copy }, { "cel_new_copy", bind_cel_new_copy },
{ "frame_free", bind_frame_free }, { "cel_free", bind_cel_free },
{ "frame_is_link", bind_frame_is_link }, { "cel_is_link", bind_cel_is_link },
{ "frame_set_frpos", bind_frame_set_frpos }, { "cel_set_frpos", bind_cel_set_frpos },
{ "frame_set_image", bind_frame_set_image }, { "cel_set_image", bind_cel_set_image },
{ "frame_set_position", bind_frame_set_position }, { "cel_set_position", bind_cel_set_position },
{ "frame_set_opacity", bind_frame_set_opacity }, { "cel_set_opacity", bind_cel_set_opacity },
{ "layer_new", bind_layer_new }, { "layer_new", bind_layer_new },
{ "layer_set_new", bind_layer_set_new }, { "layer_set_new", bind_layer_set_new },
{ "layer_new_copy", bind_layer_new_copy }, { "layer_new_copy", bind_layer_new_copy },
@ -5764,9 +5764,9 @@ const luaL_reg bindings_routines[] = {
{ "layer_get_next", bind_layer_get_next }, { "layer_get_next", bind_layer_get_next },
{ "layer_set_name", bind_layer_set_name }, { "layer_set_name", bind_layer_set_name },
{ "layer_set_blend_mode", bind_layer_set_blend_mode }, { "layer_set_blend_mode", bind_layer_set_blend_mode },
{ "layer_add_frame", bind_layer_add_frame }, { "layer_add_cel", bind_layer_add_cel },
{ "layer_remove_frame", bind_layer_remove_frame }, { "layer_remove_cel", bind_layer_remove_cel },
{ "layer_get_frame", bind_layer_get_frame }, { "layer_get_cel", bind_layer_get_cel },
{ "layer_add_layer", bind_layer_add_layer }, { "layer_add_layer", bind_layer_add_layer },
{ "layer_remove_layer", bind_layer_remove_layer }, { "layer_remove_layer", bind_layer_remove_layer },
{ "layer_move_layer", bind_layer_move_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_add_image", bind_undo_add_image },
{ "undo_remove_image", bind_undo_remove_image }, { "undo_remove_image", bind_undo_remove_image },
{ "undo_replace_image", bind_undo_replace_image }, { "undo_replace_image", bind_undo_replace_image },
{ "undo_add_frame", bind_undo_add_frame }, { "undo_add_cel", bind_undo_add_cel },
{ "undo_remove_frame", bind_undo_remove_frame }, { "undo_remove_cel", bind_undo_remove_cel },
{ "undo_add_layer", bind_undo_add_layer }, { "undo_add_layer", bind_undo_add_layer },
{ "undo_remove_layer", bind_undo_remove_layer }, { "undo_remove_layer", bind_undo_remove_layer },
{ "undo_move_layer", bind_undo_move_layer }, { "undo_move_layer", bind_undo_move_layer },
@ -6120,7 +6120,7 @@ struct _bindings_constants bindings_constants[] = {
{ "PI", PI }, { "PI", PI },
{ "GFXOBJ_IMAGE", GFXOBJ_IMAGE }, { "GFXOBJ_IMAGE", GFXOBJ_IMAGE },
{ "GFXOBJ_STOCK", GFXOBJ_STOCK }, { "GFXOBJ_STOCK", GFXOBJ_STOCK },
{ "GFXOBJ_FRAME", GFXOBJ_FRAME }, { "GFXOBJ_CEL", GFXOBJ_CEL },
{ "GFXOBJ_LAYER_IMAGE", GFXOBJ_LAYER_IMAGE }, { "GFXOBJ_LAYER_IMAGE", GFXOBJ_LAYER_IMAGE },
{ "GFXOBJ_LAYER_SET", GFXOBJ_LAYER_SET }, { "GFXOBJ_LAYER_SET", GFXOBJ_LAYER_SET },
{ "GFXOBJ_LAYER_TEXT", GFXOBJ_LAYER_TEXT }, { "GFXOBJ_LAYER_TEXT", GFXOBJ_LAYER_TEXT },

View File

@ -5,7 +5,7 @@
#include "jinete/base.h" #include "jinete/base.h"
#include "effect/colcurve.h" #include "effect/colcurve.h"
#include "raster/frame.h" #include "raster/cel.h"
#include "raster/image.h" #include "raster/image.h"
#include "raster/layer.h" #include "raster/layer.h"
#include "raster/sprite.h" #include "raster/sprite.h"

148
src/util/celmove.c Normal file
View File

@ -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;
}

View File

@ -16,15 +16,18 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifndef UTIL_FRMOVE_H #ifndef UTIL_CELMOVE_H
#define UTIL_FRMOVE_H #define UTIL_CELMOVE_H
void set_frame_to_handle (Layer *layer, Frame *frame); struct Cel;
struct Layer;
void new_frame (void); void set_cel_to_handle(struct Layer *layer, struct Cel *cel);
void move_frame (void);
void copy_frame (void);
void link_frame (void);
#endif /* UTIL_FRMOVE_H */ void new_cel(void);
void move_cel(void);
void copy_cel(void);
void link_cel(void);
#endif /* UTIL_CELMOVE_H */

View File

@ -35,7 +35,7 @@
#include "modules/sprites.h" #include "modules/sprites.h"
#include "modules/tools.h" #include "modules/tools.h"
#include "modules/tools2.h" #include "modules/tools2.h"
#include "raster/frame.h" #include "raster/cel.h"
#include "raster/image.h" #include "raster/image.h"
#include "raster/layer.h" #include "raster/layer.h"
#include "raster/rotate.h" #include "raster/rotate.h"
@ -97,12 +97,12 @@ bool has_clipboard_image(int *w, int *h)
{ {
Sprite *clipboard = get_clipboard_sprite (); Sprite *clipboard = get_clipboard_sprite ();
Image *image = NULL; Image *image = NULL;
Frame *frame; Cel *cel;
if (clipboard) { if (clipboard) {
frame = layer_get_frame (clipboard->layer, clipboard->frpos); cel = layer_get_cel(clipboard->layer, clipboard->frpos);
if (frame) if (cel)
image = stock_get_image (clipboard->layer->stock, frame->image); image = stock_get_image(clipboard->layer->stock, cel->image);
} }
if (image) { if (image) {
@ -158,7 +158,7 @@ void copy_to_clipboard(void)
void paste_from_clipboard(void) void paste_from_clipboard(void)
{ {
Sprite *clipboard = get_clipboard_sprite(); Sprite *clipboard = get_clipboard_sprite();
Frame *frame; Cel *cel;
Image *image; Image *image;
Image *dest_image; Image *dest_image;
int xout[4], yout[4]; int xout[4], yout[4];
@ -173,11 +173,11 @@ void paste_from_clipboard(void)
return; return;
} }
frame = layer_get_frame(clipboard->layer, clipboard->frpos); cel = layer_get_cel(clipboard->layer, clipboard->frpos);
if (!frame) if (!cel)
return; return;
image = stock_get_image(clipboard->layer->stock, frame->image); image = stock_get_image(clipboard->layer->stock, cel->image);
if (!image) if (!image)
return; return;

View File

@ -25,7 +25,7 @@
#include "console/console.h" #include "console/console.h"
#include "modules/gui.h" #include "modules/gui.h"
#include "modules/sprites.h" #include "modules/sprites.h"
#include "raster/frame.h" #include "raster/cel.h"
#include "raster/image.h" #include "raster/image.h"
#include "raster/layer.h" #include "raster/layer.h"
#include "raster/mask.h" #include "raster/mask.h"
@ -77,10 +77,10 @@ void crop_layer(void)
if ((sprite) && (!mask_is_empty(sprite->mask)) && if ((sprite) && (!mask_is_empty(sprite->mask)) &&
(sprite->layer) && (layer_is_image(sprite->layer))) { (sprite->layer) && (layer_is_image(sprite->layer))) {
Layer *layer = sprite->layer; Layer *layer = sprite->layer;
Frame *frame; Cel *cel;
Image *image; Image *image;
Layer *new_layer; Layer *new_layer;
Frame *new_frame; Cel *new_cel;
Image *new_image; Image *new_image;
Layer *set = (Layer *)layer->parent; Layer *set = (Layer *)layer->parent;
JLink link; JLink link;
@ -94,36 +94,36 @@ void crop_layer(void)
layer_set_name (new_layer, layer->name); layer_set_name (new_layer, layer->name);
layer_set_blend_mode (new_layer, layer->blend_mode); layer_set_blend_mode (new_layer, layer->blend_mode);
JI_LIST_FOR_EACH(layer->frames, link) { JI_LIST_FOR_EACH(layer->cels, link) {
frame = link->data; cel = link->data;
image = stock_get_image(layer->stock, frame->image); image = stock_get_image(layer->stock, cel->image);
if (!image) if (!image)
continue; continue;
new_frame = frame_new_copy(frame); new_cel = cel_new_copy(cel);
if (!new_frame) { if (!new_cel) {
layer_free(new_layer); layer_free(new_layer);
console_printf(_("Not enough memory\n")); console_printf(_("Not enough memory\n"));
return; return;
} }
new_image = image_crop(image, new_image = image_crop(image,
sprite->mask->x-frame->x, sprite->mask->x-cel->x,
sprite->mask->y-frame->y, sprite->mask->y-cel->y,
sprite->mask->w, sprite->mask->w,
sprite->mask->h); sprite->mask->h);
if (!new_image) { if (!new_image) {
layer_free(new_layer); layer_free(new_layer);
frame_free(new_frame); cel_free(new_cel);
console_printf(_("Not enough memory\n")); console_printf(_("Not enough memory\n"));
return; return;
} }
new_frame->image = stock_add_image(new_layer->stock, new_image); new_cel->image = stock_add_image(new_layer->stock, new_image);
new_frame->x = sprite->mask->x; new_cel->x = sprite->mask->x;
new_frame->y = sprite->mask->y; new_cel->y = sprite->mask->y;
layer_add_frame(new_layer, new_frame); layer_add_cel(new_layer, new_cel);
} }
/* add the new layer */ /* add the new layer */
@ -160,34 +160,34 @@ void crop_layer(void)
} }
} }
void crop_frame(void) void crop_cel(void)
{ {
Sprite *sprite = current_sprite; Sprite *sprite = current_sprite;
Image *image = GetImage (); Image *image = GetImage();
if ((sprite) && (!mask_is_empty (sprite->mask)) && (image)) { 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 */
undo_open(sprite->undo); undo_open(sprite->undo);
undo_int(sprite->undo, (GfxObj *)frame, &frame->x); undo_int(sprite->undo, (GfxObj *)cel, &cel->x);
undo_int(sprite->undo, (GfxObj *)frame, &frame->y); undo_int(sprite->undo, (GfxObj *)cel, &cel->y);
undo_replace_image(sprite->undo, sprite->layer->stock, frame->image); undo_replace_image(sprite->undo, sprite->layer->stock, cel->image);
undo_close(sprite->undo); undo_close(sprite->undo);
/* replace the image */ /* replace the image */
sprite->layer->stock->image[frame->image] = sprite->layer->stock->image[cel->image] =
image_crop(image, image_crop(image,
sprite->mask->x-frame->x, sprite->mask->x-cel->x,
sprite->mask->y-frame->y, sprite->mask->y-cel->y,
sprite->mask->w, sprite->mask->w,
sprite->mask->h); sprite->mask->h);
image_free(image); /* destroy the old image */ image_free(image); /* destroy the old image */
/* change the frame position */ /* change the cel position */
frame->x = sprite->mask->x; cel->x = sprite->mask->x;
frame->y = sprite->mask->y; cel->y = sprite->mask->y;
GUI_Refresh(sprite); GUI_Refresh(sprite);
} }
@ -200,19 +200,19 @@ static void displace_layers(Undo *undo, Layer *layer, int x, int y)
switch (layer->gfxobj.type) { switch (layer->gfxobj.type) {
case GFXOBJ_LAYER_IMAGE: { case GFXOBJ_LAYER_IMAGE: {
Frame *frame; Cel *cel;
JLink link; JLink link;
JI_LIST_FOR_EACH(layer->frames, link) { JI_LIST_FOR_EACH(layer->cels, link) {
frame = link->data; cel = link->data;
if (undo_is_enabled(undo)) { if (undo_is_enabled(undo)) {
undo_int(undo, (GfxObj *)frame, &frame->x); undo_int(undo, (GfxObj *)cel, &cel->x);
undo_int(undo, (GfxObj *)frame, &frame->y); undo_int(undo, (GfxObj *)cel, &cel->y);
} }
frame->x += x; cel->x += x;
frame->y += y; cel->y += y;
} }
break; break;
} }
@ -225,7 +225,7 @@ static void displace_layers(Undo *undo, Layer *layer, int x, int y)
} }
case GFXOBJ_LAYER_TEXT: case GFXOBJ_LAYER_TEXT:
/* XXX */ /* TODO */
break; break;
} }
} }

View File

@ -21,7 +21,7 @@
void crop_sprite(void); void crop_sprite(void);
void crop_layer(void); void crop_layer(void);
void crop_frame(void); void crop_cel(void);
#endif /* UTIL_CROP_H */ #endif /* UTIL_CROP_H */

View File

@ -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;
}

View File

@ -38,7 +38,7 @@
#include "modules/sprites.h" #include "modules/sprites.h"
#include "modules/tools2.h" #include "modules/tools2.h"
#include "raster/blend.h" #include "raster/blend.h"
#include "raster/frame.h" #include "raster/cel.h"
#include "raster/image.h" #include "raster/image.h"
#include "raster/layer.h" #include "raster/layer.h"
#include "raster/mask.h" #include "raster/mask.h"
@ -51,39 +51,39 @@
#endif #endif
Image *GetImage (void) Image *GetImage(void)
{ {
Sprite *sprite = current_sprite; Sprite *sprite = current_sprite;
Image *image = NULL; Image *image = NULL;
if (sprite && sprite->layer && layer_is_image (sprite->layer)) { 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 (cel) {
if ((frame->image >= 0) && if ((cel->image >= 0) &&
(frame->image < sprite->layer->stock->nimage)) (cel->image < sprite->layer->stock->nimage))
image = sprite->layer->stock->image[frame->image]; image = sprite->layer->stock->image[cel->image];
} }
} }
return 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; Image *image = NULL;
if (sprite && sprite->layer && layer_is_image (sprite->layer)) { 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 (cel) {
if ((frame->image >= 0) && if ((cel->image >= 0) &&
(frame->image < sprite->layer->stock->nimage)) (cel->image < sprite->layer->stock->nimage))
image = sprite->layer->stock->image[frame->image]; image = sprite->layer->stock->image[cel->image];
if (x) *x = frame->x; if (x) *x = cel->x;
if (y) *y = frame->y; if (y) *y = cel->y;
if (opacity) *opacity = MID (0, frame->opacity, 255); 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 */ /* clears the mask region in the current sprite with the BG color */
void ClearMask (void) void ClearMask(void)
{ {
Sprite *sprite = current_sprite; Sprite *sprite = current_sprite;
int x, y, u, v, putx, puty; 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 /* returns a new layer created from the current mask in the current
sprite, the layer isn't added to the sprite */ sprite, the layer isn't added to the sprite */
Layer *NewLayerFromMask (void) Layer *NewLayerFromMask(void)
{ {
Sprite *sprite = current_sprite; Sprite *sprite = current_sprite;
unsigned char *address; unsigned char *address;
int x, y, u, v, getx, gety; int x, y, u, v, getx, gety;
Image *dst, *src = GetImage2 (sprite, &x, &y, NULL); Image *dst, *src = GetImage2 (sprite, &x, &y, NULL);
Layer *layer; Layer *layer;
Frame *frame; Cel *cel;
div_t d; div_t d;
if (!sprite || !sprite->mask || !sprite->mask->bitmap || !src) if (!sprite || !sprite->mask || !sprite->mask->bitmap || !src)
return NULL; 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) if (!dst)
return NULL; return NULL;
/* clear the new image */ /* clear the new image */
image_clear (dst, 0); image_clear(dst, 0);
/* copy the masked zones */ /* copy the masked zones */
for (v=0; v<sprite->mask->h; v++) { for (v=0; v<sprite->mask->h; v++) {
@ -224,37 +224,36 @@ Layer *NewLayerFromMask (void)
} }
} }
layer = layer_new (sprite->imgtype); layer = layer_new(sprite->imgtype);
if (!layer) { if (!layer) {
image_free (dst); image_free (dst);
return NULL; return NULL;
} }
layer_set_blend_mode (layer, BLEND_MODE_NORMAL); layer_set_blend_mode(layer, BLEND_MODE_NORMAL);
frame = frame_new (sprite->frpos, cel = cel_new(sprite->frpos, stock_add_image(layer->stock, dst));
stock_add_image (layer->stock, dst)); cel_set_position(cel, sprite->mask->x, sprite->mask->y);
frame_set_position (frame, sprite->mask->x, sprite->mask->y);
layer_add_frame (layer, frame); layer_add_cel(layer, cel);
return layer; 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; Image *image = NULL;
if (layer_is_image (layer)) { if (layer_is_image (layer)) {
Frame *frame = layer_get_frame (layer, frpos); Cel *cel = layer_get_cel(layer, frpos);
if (frame) { if (cel) {
if ((frame->image >= 0) && if ((cel->image >= 0) &&
(frame->image < layer->stock->nimage)) (cel->image < layer->stock->nimage))
image = layer->stock->image[frame->image]; image = layer->stock->image[cel->image];
if (x) *x = frame->x; if (x) *x = cel->x;
if (y) *y = frame->y; 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; JWidget editor = current_editor;
Sprite *sprite = editor_get_sprite (editor); Sprite *sprite = editor_get_sprite (editor);
Layer *layer = sprite->layer; 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_x, new_x;
int start_y, new_y; int start_y, new_y;
int start_b; int start_b;
@ -281,11 +280,11 @@ int interactive_move_layer (int mode, int use_undo, int (*callback) (void))
int begin_y; int begin_y;
int delay; int delay;
if (!frame) if (!cel)
return FALSE; return FALSE;
begin_x = frame->x; begin_x = cel->x;
begin_y = frame->y; begin_y = cel->y;
delay = get_config_int ("Options", "MoveDelay", 250); delay = get_config_int ("Options", "MoveDelay", 250);
delay = MID (0, delay, 1000); delay = MID (0, delay, 1000);
@ -298,8 +297,8 @@ int interactive_move_layer (int mode, int use_undo, int (*callback) (void))
do { do {
if (update) { if (update) {
frame->x = begin_x - start_x + new_x; cel->x = begin_x - start_x + new_x;
frame->y = begin_y - start_y + new_y; cel->y = begin_y - start_y + new_y;
/* update layer-bounds */ /* update layer-bounds */
jmouse_hide(); jmouse_hide();
@ -311,10 +310,10 @@ int interactive_move_layer (int mode, int use_undo, int (*callback) (void))
status_bar_set_text status_bar_set_text
(app_get_status_bar(), 0, (app_get_status_bar(), 0,
"Pos %3d %3d Offset %3d %3d", "Pos %3d %3d Offset %3d %3d",
(int)frame->x, (int)cel->x,
(int)frame->y, (int)cel->y,
(int)(frame->x - begin_x), (int)(cel->x - begin_x),
(int)(frame->y - begin_y)); (int)(cel->y - begin_y));
jwidget_flush_redraw(app_get_status_bar()); jwidget_flush_redraw(app_get_status_bar());
jmanager_dispatch_messages(); jmanager_dispatch_messages();
@ -344,16 +343,16 @@ int interactive_move_layer (int mode, int use_undo, int (*callback) (void))
/* the position was changed */ /* the position was changed */
if (!editor_click_cancel(editor)) { if (!editor_click_cancel(editor)) {
if (use_undo && undo_is_enabled(sprite->undo)) { if (use_undo && undo_is_enabled(sprite->undo)) {
new_x = frame->x; new_x = cel->x;
new_y = frame->y; new_y = cel->y;
undo_open(sprite->undo); undo_open(sprite->undo);
frame->x = begin_x; cel->x = begin_x;
frame->y = begin_y; cel->y = begin_y;
undo_int(sprite->undo, (GfxObj *)frame, &frame->x); undo_int(sprite->undo, (GfxObj *)cel, &cel->x);
undo_int(sprite->undo, (GfxObj *)frame, &frame->y); undo_int(sprite->undo, (GfxObj *)cel, &cel->y);
frame->x = new_x; cel->x = new_x;
frame->y = new_y; cel->y = new_y;
undo_close(sprite->undo); 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 */ /* the position wasn't changed */
else { else {
frame->x = begin_x; cel->x = begin_x;
frame->y = begin_y; cel->y = begin_y;
ret = FALSE; ret = FALSE;
} }

View File

@ -41,6 +41,7 @@ static int rec_clock;
static s_fli_header *fli_header; static s_fli_header *fli_header;
static unsigned char *omap; static unsigned char *omap;
static unsigned char *cmap; static unsigned char *cmap;
static BITMAP *new_bmp;
static BITMAP *old_bmp; static BITMAP *old_bmp;
bool is_rec_screen(void) bool is_rec_screen(void)
@ -76,11 +77,11 @@ void rec_screen_on(void)
fseek(rec_file, 128, SEEK_SET); fseek(rec_file, 128, SEEK_SET);
/* prepare fli header */ /* prepare fli header */
fli_header = jnew (s_fli_header, 1); fli_header = jnew(s_fli_header, 1);
fli_header->filesize = 0; fli_header->filesize = 0;
fli_header->frames = 0; fli_header->frames = 0;
fli_header->width = JI_SCREEN_W; fli_header->width = SCREEN_W;
fli_header->height = JI_SCREEN_H; fli_header->height = SCREEN_H;
fli_header->magic = HEADER_FLC; fli_header->magic = HEADER_FLC;
fli_header->depth = 8; fli_header->depth = 8;
fli_header->flags = 3; fli_header->flags = 3;
@ -96,6 +97,7 @@ void rec_screen_on(void)
cmap = jmalloc(768); cmap = jmalloc(768);
/* prepare old bitmap */ /* prepare old bitmap */
new_bmp = NULL;
old_bmp = NULL; old_bmp = NULL;
/* set the position of the mouse in the center of the screen */ /* set the position of the mouse in the center of the screen */
@ -114,8 +116,8 @@ void rec_screen_off(void)
rec_file = NULL; rec_file = NULL;
/* free memory */ /* free memory */
if (old_bmp) if (new_bmp) destroy_bitmap(new_bmp);
destroy_bitmap(old_bmp); if (old_bmp) destroy_bitmap(old_bmp);
jfree(fli_header); jfree(fli_header);
jfree(cmap); 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) if (!is_interactive() || !rec_file)
return; return;
else if (ji_clock-rec_clock > JI_TICKS_PER_SEC/FRAMES_PER_SECOND) { else if (ji_clock-rec_clock > JI_TICKS_PER_SEC/FRAMES_PER_SECOND) {
BITMAP *t;
int old_flag; int old_flag;
BITMAP *bmp;
int c, i; int c, i;
/* save the active flag which indicate if the mouse is freeze or not */ /* 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 */ /* save in a bitmap the visible screen portion */
bmp = create_bitmap_ex(8, JI_SCREEN_W, JI_SCREEN_H); if (!new_bmp) new_bmp = create_bitmap_ex(8, SCREEN_W, SCREEN_H);
if (ji_screen != screen) /* if (ji_screen != screen) */
jmouse_draw_cursor(); /* jmouse_draw_cursor(); */
blit(ji_screen, bmp, 0, 0, 0, 0, JI_SCREEN_W, JI_SCREEN_H); blit(screen, new_bmp, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
/* write the frame in FLC file */ /* write the frame in FLC file */
if (old_bmp) if (old_bmp)
fli_write_frame(rec_file, fli_header, fli_write_frame(rec_file, fli_header,
(unsigned char *)old_bmp->dat, omap, (unsigned char *)old_bmp->dat, omap,
(unsigned char *)bmp->dat, cmap, W_ALL); (unsigned char *)new_bmp->dat, cmap, W_ALL);
else else
fli_write_frame(rec_file, fli_header, NULL, NULL, 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 */ /* copy this palette to the old one */
memcpy(omap, cmap, 768); memcpy(omap, cmap, 768);
/* fixup old bitmap */ /* fixup old bitmap */
if (old_bmp) /* if (old_bmp) */
destroy_bitmap(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 */ /* restore the freeze flag by the previous value */
freeze_mouse_flag = old_flag; freeze_mouse_flag = old_flag;

View File

@ -37,24 +37,15 @@ static int global_opacity = 255;
static Layer *selected_layer = NULL; static Layer *selected_layer = NULL;
static Image *rastering_image = NULL; static Image *rastering_image = NULL;
static void render_layer (Layer *layer, Image *image, static void render_layer(Layer *layer, Image *image,
int source_x, int source_y, int source_x, int source_y,
int zoom, int zoom,
int frpos, int frpos,
void (*zoomed_func)(Image *, Image *, int, int, int, int, int)); 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_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_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); 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)
{
}
void set_preview_image (Layer *layer, Image *image) 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 return image, all positions must have the zoom applied
(sorce_x<<zoom, dest_x<<zoom, width<<zoom, etc.) (sorce_x<<zoom, dest_x<<zoom, width<<zoom, etc.)
*/ */
Image *render_sprite (Sprite *sprite, Image *render_sprite(Sprite *sprite,
int source_x, int source_y, int source_x, int source_y,
int width, int height, int width, int height,
int frpos, int zoom) int frpos, int zoom)
{ {
void (*zoomed_func)(Image *, Image *, int, int, int, int, int); void (*zoomed_func)(Image *, Image *, int, int, int, int, int);
int need_grid, depth; int need_grid, depth;
@ -172,11 +163,11 @@ Image *render_sprite (Sprite *sprite,
return image; return image;
} }
static void render_layer (Layer *layer, Image *image, static void render_layer(Layer *layer, Image *image,
int source_x, int source_y, int source_x, int source_y,
int zoom, int zoom,
int frpos, int frpos,
void (*zoomed_func)(Image *, Image *, int, int, int, int, int)) void (*zoomed_func)(Image *, Image *, int, int, int, int, int))
{ {
/* we can't read from this layer */ /* we can't read from this layer */
if (!layer->readable) if (!layer->readable)
@ -200,13 +191,13 @@ static void render_layer (Layer *layer, Image *image,
switch (layer->gfxobj.type) { switch (layer->gfxobj.type) {
case GFXOBJ_LAYER_IMAGE: { case GFXOBJ_LAYER_IMAGE: {
Frame *frame = layer_get_frame (layer, frpos); Cel *cel = layer_get_cel(layer, frpos);
Image *src_image; Image *src_image;
if (frame) { if (cel) {
if ((frame->image >= 0) && if ((cel->image >= 0) &&
(frame->image < layer->stock->nimage)) (cel->image < layer->stock->nimage))
src_image = layer->stock->image[frame->image]; src_image = layer->stock->image[cel->image];
else else
src_image = NULL; src_image = NULL;
@ -217,22 +208,20 @@ static void render_layer (Layer *layer, Image *image,
if ((selected_layer == layer) && (rastering_image)) if ((selected_layer == layer) && (rastering_image))
src_image = rastering_image; src_image = rastering_image;
output_opacity = MID (0, frame->opacity, 255); output_opacity = MID(0, cel->opacity, 255);
output_opacity = INT_MULT (output_opacity, global_opacity, t); output_opacity = INT_MULT(output_opacity, global_opacity, t);
if (zoom == 0) { if (zoom == 0) {
image_merge image_merge (image, src_image,
(image, src_image, cel->x - source_x,
frame->x - source_x, cel->y - source_y,
frame->y - source_y, output_opacity, layer->blend_mode);
output_opacity, layer->blend_mode);
} }
else { else {
(*zoomed_func) (*zoomed_func) (image, src_image,
(image, src_image, (cel->x << zoom) - source_x,
(frame->x << zoom) - source_x, (cel->y << zoom) - source_y,
(frame->y << zoom) - source_y, output_opacity, layer->blend_mode, zoom);
output_opacity, layer->blend_mode, zoom);
} }
} }
} }

View File

@ -16,21 +16,18 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifndef MODULES_RENDER_H #ifndef UTIL_RENDER_H
#define MODULES_RENDER_H #define UTIL_RENDER_H
struct Image; struct Image;
struct Layer; struct Layer;
struct Sprite; struct Sprite;
int init_module_render (void); void set_preview_image(struct Layer *layer, struct Image *drawable);
void exit_module_render (void);
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, #endif /* UTIL_RENDER_H */
int source_x, int source_y,
int width, int height,
int frpos, int zoom);
#endif /* MODULES_RENDER_H */

View File

@ -19,7 +19,7 @@
#ifndef UTIL_SETGFX_H #ifndef UTIL_SETGFX_H
#define 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 */ #endif /* UTIL_SETGFX_H */

View File

@ -27,7 +27,7 @@
#include "jinete/list.h" #include "jinete/list.h"
#include "modules/palette.h" #include "modules/palette.h"
#include "raster/frame.h" #include "raster/cel.h"
#include "raster/image.h" #include "raster/image.h"
#include "raster/layer.h" #include "raster/layer.h"
#include "raster/stock.h" #include "raster/stock.h"
@ -37,7 +37,7 @@
static JList thumbnails = NULL; 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_free(Thumbnail *thumbnail);
static void thumbnail_create_bitmap(BITMAP *bmp, Image *image); 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; Thumbnail *thumbnail;
BITMAP *bmp; BITMAP *bmp;
@ -65,19 +65,17 @@ BITMAP *generate_thumbnail(Frame *frame, Layer *layer)
#if 0 /* this must be done by the caller */ #if 0 /* this must be done by the caller */
{ {
Frame *link_frame; /* search original cel */
Cel *link_cel = cel_is_link(cel, layer);
/* search original frame */ if (link_cel)
link_frame = frame_is_link(frame, layer); cel = link_cel;
if (link_frame)
frame = link_frame;
} }
#endif #endif
/* find the thumbnail */ /* find the thumbnail */
JI_LIST_FOR_EACH(thumbnails, link) { JI_LIST_FOR_EACH(thumbnails, link) {
thumbnail = link->data; thumbnail = link->data;
if (thumbnail->frame == frame) if (thumbnail->cel == cel)
return thumbnail->bmp; return thumbnail->bmp;
} }
@ -85,9 +83,9 @@ BITMAP *generate_thumbnail(Frame *frame, Layer *layer)
if (!bmp) if (!bmp)
return NULL; 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) { if (!thumbnail) {
destroy_bitmap(bmp); destroy_bitmap(bmp);
return NULL; return NULL;
@ -97,15 +95,15 @@ BITMAP *generate_thumbnail(Frame *frame, Layer *layer)
return thumbnail->bmp; return thumbnail->bmp;
} }
static Thumbnail *thumbnail_new(Frame *frame, BITMAP *bmp) static Thumbnail *thumbnail_new(Cel *cel, BITMAP *bmp)
{ {
Thumbnail *thumbnail; Thumbnail *thumbnail;
thumbnail = jnew (Thumbnail, 1); thumbnail = jnew(Thumbnail, 1);
if (!thumbnail) if (!thumbnail)
return NULL; return NULL;
thumbnail->frame = frame; thumbnail->cel = cel;
thumbnail->bmp = bmp; thumbnail->bmp = bmp;
return thumbnail; return thumbnail;
@ -113,16 +111,16 @@ static Thumbnail *thumbnail_new(Frame *frame, BITMAP *bmp)
static void thumbnail_free(Thumbnail *thumbnail) static void thumbnail_free(Thumbnail *thumbnail)
{ {
destroy_bitmap (thumbnail->bmp); destroy_bitmap(thumbnail->bmp);
jfree (thumbnail); jfree(thumbnail);
} }
static void thumbnail_create_bitmap(BITMAP *bmp, Image *image) static void thumbnail_create_bitmap(BITMAP *bmp, Image *image)
{ {
if (!image) { if (!image) {
clear_to_color (bmp, makecol (128, 128, 128)); 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, 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)); line(bmp, 0, bmp->h-1, bmp->w-1, 0, makecol(0, 0, 0));
} }
else { else {
int c, x, y, w, h, x1, y1; 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; sx = (double)image->w / (double)bmp->w;
sy = (double)image->h / (double)bmp->h; sy = (double)image->h / (double)bmp->h;
scale = MAX (sx, sy); scale = MAX(sx, sy);
w = image->w / scale; w = image->w / scale;
h = image->h / scale; h = image->h / scale;
w = MIN (bmp->w, w); w = MIN(bmp->w, w);
h = MIN (bmp->h, h); h = MIN(bmp->h, h);
x1 = bmp->w/2 - w/2; x1 = bmp->w/2 - w/2;
y1 = bmp->h/2 - h/2; y1 = bmp->h/2 - h/2;
x1 = MAX (0, x1); x1 = MAX(0, x1);
y1 = MAX (0, y1); y1 = MAX(0, y1);
clear_to_color (bmp, makecol (128, 128, 128)); clear_to_color(bmp, makecol(128, 128, 128));
switch (image->imgtype) { switch (image->imgtype) {
case IMAGE_RGB: case IMAGE_RGB:
for (y=0; y<h; y++) for (y=0; y<h; y++)
for (x=0; x<w; x++) { for (x=0; x<w; x++) {
c = image_getpixel (image, x*scale, y*scale); c = image_getpixel(image, x*scale, y*scale);
putpixel (bmp, x1+x, y1+y, makecol (_rgba_getr (c), putpixel(bmp, x1+x, y1+y, makecol(_rgba_getr(c),
_rgba_getg (c), _rgba_getg(c),
_rgba_getb (c))); _rgba_getb(c)));
} }
break; break;
case IMAGE_GRAYSCALE: case IMAGE_GRAYSCALE:
for (y=0; y<h; y++) for (y=0; y<h; y++)
for (x=0; x<w; x++) { for (x=0; x<w; x++) {
c = image_getpixel (image, x*scale, y*scale); c = image_getpixel(image, x*scale, y*scale);
putpixel (bmp, x1+x, y1+y, makecol (_graya_getk (c), putpixel(bmp, x1+x, y1+y, makecol(_graya_getk(c),
_graya_getk (c), _graya_getk(c),
_graya_getk (c))); _graya_getk(c)));
} }
break; break;
case IMAGE_INDEXED: { case IMAGE_INDEXED: {
for (y=0; y<h; y++) for (y=0; y<h; y++)
for (x=0; x<w; x++) { for (x=0; x<w; x++) {
c = image_getpixel (image, x*scale, y*scale); c = image_getpixel(image, x*scale, y*scale);
putpixel (bmp, x1+x, y1+y, putpixel(bmp, x1+x, y1+y,
makecol (_rgb_scale_6[current_palette[c].r], makecol(_rgb_scale_6[current_palette[c].r],
_rgb_scale_6[current_palette[c].g], _rgb_scale_6[current_palette[c].g],
_rgb_scale_6[current_palette[c].b])); _rgb_scale_6[current_palette[c].b]));
} }
break; break;
} }

View File

@ -19,19 +19,19 @@
#ifndef UTIL_THMBNAIL_H #ifndef UTIL_THMBNAIL_H
#define UTIL_THMBNAIL_H #define UTIL_THMBNAIL_H
struct Frame; struct Cel;
struct BITMAP; struct BITMAP;
#define THUMBNAIL_W 32 #define THUMBNAIL_W 32
#define THUMBNAIL_H 32 #define THUMBNAIL_H 32
typedef struct Thumbnail { typedef struct Thumbnail {
struct Frame *frame; struct Cel *cel;
struct BITMAP *bmp; struct BITMAP *bmp;
} Thumbnail; } Thumbnail;
void destroy_thumbnails (void); void destroy_thumbnails(void);
struct BITMAP *generate_thumbnail (struct Frame *frame, struct Layer *layer); struct BITMAP *generate_thumbnail(struct Cel *cel, struct Layer *layer);
#endif /* UTIL_THMBNAIL_H */ #endif /* UTIL_THMBNAIL_H */

View File

@ -42,7 +42,6 @@
#include "modules/gfx.h" #include "modules/gfx.h"
#include "modules/gui.h" #include "modules/gui.h"
#include "modules/palette.h" #include "modules/palette.h"
#include "modules/render.h"
#include "modules/sprites.h" #include "modules/sprites.h"
#include "modules/tools.h" #include "modules/tools.h"
#include "raster/brush.h" #include "raster/brush.h"
@ -56,6 +55,7 @@
#include "util/boundary.h" #include "util/boundary.h"
#include "util/misc.h" #include "util/misc.h"
#include "util/recscr.h" #include "util/recscr.h"
#include "util/render.h"
#include "widgets/colbar.h" #include "widgets/colbar.h"
#include "widgets/editor.h" #include "widgets/editor.h"
#include "widgets/statebar.h" #include "widgets/statebar.h"

View File

@ -24,8 +24,8 @@
#include "jinete/widget.h" #include "jinete/widget.h"
#include "effect/effect.h" #include "effect/effect.h"
#include "modules/render.h"
#include "raster/sprite.h" #include "raster/sprite.h"
#include "util/render.h"
#include "widgets/preview.h" #include "widgets/preview.h"
#endif #endif
@ -35,61 +35,61 @@ typedef struct Preview
Effect *effect; Effect *effect;
} Preview; } Preview;
static bool preview_msg_proc (JWidget widget, JMessage msg); static bool preview_msg_proc(JWidget widget, JMessage msg);
JWidget preview_new (Effect *effect) JWidget preview_new(Effect *effect)
{ {
JWidget widget = jwidget_new (preview_type ()); JWidget widget = jwidget_new(preview_type());
Preview *preview = jnew (Preview, 1); Preview *preview = jnew(Preview, 1);
preview->effect = effect; preview->effect = effect;
jwidget_add_hook (widget, preview_type (), preview_msg_proc, preview); jwidget_add_hook(widget, preview_type(), preview_msg_proc, preview);
jwidget_hide (widget); jwidget_hide(widget);
return widget; return widget;
} }
int preview_type (void) int preview_type(void)
{ {
static int type = 0; static int type = 0;
if (!type) if (!type)
type = ji_register_widget_type (); type = ji_register_widget_type();
return 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) { switch (msg->type) {
case JM_DESTROY: case JM_DESTROY:
jfree (jwidget_get_data (widget, preview_type ())); jfree(jwidget_get_data(widget, preview_type()));
break; break;
case JM_OPEN: case JM_OPEN:
set_preview_image (effect->sprite->layer, effect->dst); set_preview_image(effect->sprite->layer, effect->dst);
break; break;
case JM_CLOSE: case JM_CLOSE:
set_preview_image (NULL, NULL); set_preview_image(NULL, NULL);
break; break;
case JM_IDLE: case JM_IDLE:
if (effect) { if (effect) {
if (effect_apply_step (effect)) if (effect_apply_step(effect))
effect_flush (effect); effect_flush(effect);
} }
break; break;
} }

View File

@ -33,7 +33,7 @@
#include "modules/gui.h" #include "modules/gui.h"
#include "modules/palette.h" #include "modules/palette.h"
#include "modules/sprites.h" #include "modules/sprites.h"
#include "raster/frame.h" #include "raster/cel.h"
#include "raster/layer.h" #include "raster/layer.h"
#include "raster/sprite.h" #include "raster/sprite.h"
#include "script/script.h" #include "script/script.h"
@ -349,11 +349,11 @@ static int slider_change_signal(JWidget widget, int user_data)
if (sprite) { if (sprite) {
if ((sprite->layer) && if ((sprite->layer) &&
(sprite->layer->gfxobj.type == GFXOBJ_LAYER_IMAGE)) { (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 */ /* update the opacity */
frame->opacity = jslider_get_value (widget); cel->opacity = jslider_get_value(widget);
/* update the editors */ /* update the editors */
GUI_Refresh(sprite); GUI_Refresh(sprite);
@ -410,30 +410,30 @@ static void button_command(JWidget widget, void *data)
static void update_from_layer(StatusBar *status_bar) static void update_from_layer(StatusBar *status_bar)
{ {
Sprite *sprite = current_sprite; Sprite *sprite = current_sprite;
Frame *frame; Cel *cel;
/* layer button */ /* layer button */
if (sprite && sprite->layer) { if (sprite && sprite->layer) {
char buf[512]; char buf[512];
usprintf (buf, "[%d] %s", sprite->frpos, sprite->layer->name); usprintf(buf, "[%d] %s", sprite->frpos, sprite->layer->name);
jwidget_set_text (status_bar->b_layer, buf); jwidget_set_text(status_bar->b_layer, buf);
jwidget_enable (status_bar->b_layer); jwidget_enable(status_bar->b_layer);
} }
else { else {
jwidget_set_text (status_bar->b_layer, "Nothing"); jwidget_set_text(status_bar->b_layer, "Nothing");
jwidget_disable (status_bar->b_layer); jwidget_disable(status_bar->b_layer);
} }
/* opacity layer */ /* opacity layer */
if (sprite && sprite->layer && if (sprite && sprite->layer &&
sprite->layer->gfxobj.type == GFXOBJ_LAYER_IMAGE && sprite->layer->gfxobj.type == GFXOBJ_LAYER_IMAGE &&
(frame = layer_get_frame (sprite->layer, sprite->frpos))) { (cel = layer_get_cel(sprite->layer, sprite->frpos))) {
jslider_set_value (status_bar->slider, MID (0, frame->opacity, 255)); jslider_set_value(status_bar->slider, MID(0, cel->opacity, 255));
jwidget_enable (status_bar->slider); jwidget_enable(status_bar->slider);
} }
else { else {
jslider_set_value (status_bar->slider, 0); jslider_set_value(status_bar->slider, 0);
jwidget_disable (status_bar->slider); jwidget_disable(status_bar->slider);
} }
} }