Added some of the new script functions (NewSprite, LoadSprite,

SaveSprite, SetSprite, NewLayer)
This commit is contained in:
David Capello 2007-12-13 15:55:01 +00:00
parent ece7c72b0f
commit 37be418a5a
24 changed files with 597 additions and 4249 deletions

View File

@ -1,5 +1,11 @@
2007-12-13 David A. Capello <dacap@users.sourceforge.net>
* src/dialogs/scrsaver.c: Removed.
2007-12-11 David A. Capello <dacap@users.sourceforge.net>
* src/script/functions.c (NewSprite): Added.
* src/raster/sprite.c (sprite_set_imgtype): Added convertion of
the background color.

View File

@ -2,10 +2,10 @@
COMPILATION
===================================
Before compile, you must configure what ASE should use, what
libraries are available, etc. You can run the "fix.sh" script,
answer some questions and done: the main makefile is created,
just do
Before compile, you have to configure how to compile ASE, what
libraries are available, release-debug-profile mode, etc. You can
run the "fix.sh" script, answer some questions and done: the main
makefile is created, just do
make

1
all.h
View File

@ -164,6 +164,7 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <assert.h>
#if 0
#include "ft2build.h"

Binary file not shown.

BIN
data/aseicon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 408 B

View File

@ -8,13 +8,9 @@
<box horizontal>
<box vertical homogeneous>
<label text="Name:" />
<label text="Width:" />
<label text="Height:" />
</box>
<box vertical homogeneous>
<entry maxsize=256 text="New Layer" name="name" />
<entry maxsize=4 name="width" />
<entry maxsize=4 name="height" />
</box>
</box>
<box horizontal homogeneous>

View File

@ -29,9 +29,9 @@ function MakeASELogo(color_bg, color_a, color_s, color_e)
undo_disable(sprite.undo)
image_bg = GetImage()
layer_a = NewLayer("A", 0, 0, 0, 0) image_a = GetImage()
layer_s = NewLayer("S", 0, 0, 0, 0) image_s = GetImage()
layer_e = NewLayer("E", 0, 0, 0, 0) image_e = GetImage()
layer_a = NewLayer() image_a = GetImage()
layer_s = NewLayer() image_s = GetImage()
layer_e = NewLayer() image_e = GetImage()
-- clear the images
image_clear(image_bg, get_color_for_image(sprite.imgtype, color_bg))

View File

@ -1,12 +1,9 @@
-- ASE - Allegro Sprite Editor
-- Copyright (C) 2001-2005, 2007 by David A. Capello
local x, y, points, sprite
local x, y, points
ResetConfig()
sprite = NewSprite(IMAGE_RGB, 128, 128)
undo_disable(sprite.undo)
NewSprite(IMAGE_RGB, 128, 128)
ClearMask()
points = ""
@ -19,8 +16,3 @@ ToolTrace("floodfill 127,127")
ConvolutionMatrixRGBA("smooth-5x5")
ColorCurveRGBA({ 0,0, 128-32,16, 128+32,256-16, 255,255 })
undo_enable(sprite.undo)
sprite_show(sprite)
RestoreConfig()

View File

@ -5,14 +5,7 @@ local function MakeDacap()
local x, y, sprite, image, render
local w, h = 256, 128
sprite = sprite_new_with_layer(IMAGE_RGB, w, h)
sprite_mount(sprite)
set_current_sprite(sprite)
-- disable undo
undo_disable(sprite.undo)
sprite_set_filename(sprite, "dacap")
sprite = NewSprite(IMAGE_RGB, w, h)
-- Background layer
image = GetImage()
@ -28,7 +21,7 @@ local function MakeDacap()
end
-- Foreground layer
NewLayer("Foreground", 0, 0, 0, 0)
NewLayer()
image = GetImage()
image_clear(image, _rgba(0,0,0,0))
@ -44,8 +37,6 @@ local function MakeDacap()
-- flatten both layers
FlattenLayers()
-- enable undo
undo_enable(sprite.undo)
return sprite
end

View File

@ -28,8 +28,8 @@ ifdef DEBUGMODE
CFLAGS += -g3
LFLAGS += -g3
else
CFLAGS += -s -O3
LFLAGS += -s -O3
CFLAGS += -s -O3 -DNDEBUG
LFLAGS += -s -O3 -DNDEBUG
endif
endif

View File

@ -91,7 +91,6 @@ COMMON_SOURCES = \
src/dialogs/playfli.c \
src/dialogs/quick.c \
src/dialogs/repo.c \
src/dialogs/scrsaver.c \
src/dialogs/tips.c \
src/dialogs/vectmap.c \
src/effect/colcurve.c \

View File

@ -1,73 +1,63 @@
#! /bin/sh
dir="`pwd`"
version=0.6
version=0.6beta
distdir=ase-$version
freetype_files="jinete/freetype/ChangeLog \
jinete/freetype/descrip.mms \
jinete/freetype/INSTALL \
jinete/freetype/README \
jinete/freetype/README.UNX \
jinete/freetype/docs/* \
jinete/freetype/include/*.h \
jinete/freetype/include/freetype/*.h \
jinete/freetype/include/freetype/cache/*.h \
jinete/freetype/include/freetype/config/*.h \
jinete/freetype/include/freetype/internal/*.h \
jinete/freetype/src/autohint/*.[ch] \
jinete/freetype/src/autohint/*.py \
jinete/freetype/src/autohint/*.txt \
jinete/freetype/src/base/*.[ch] \
jinete/freetype/src/cache/*.[ch] \
jinete/freetype/src/cff/*.[ch] \
jinete/freetype/src/cid/*.[ch] \
jinete/freetype/src/pcf/*.[ch] \
jinete/freetype/src/psaux/*.[ch] \
jinete/freetype/src/pshinter/*.[ch] \
jinete/freetype/src/psnames/*.[ch] \
jinete/freetype/src/raster/*.[ch] \
jinete/freetype/src/sfnt/*.[ch] \
jinete/freetype/src/smooth/*.[ch] \
jinete/freetype/src/truetype/*.[ch] \
jinete/freetype/src/type1/*.[ch] \
jinete/freetype/src/winfonts/*.[ch]"
jinete_files="jinete/*.txt \
jinete/makefile.dj \
jinete/makefile.gcc \
jinete/makefile.lnx \
jinete/makefile.lst \
jinete/makefile.mgw \
jinete/docs/*.html \
jinete/docs/*.info \
jinete/docs/*.texi \
jinete/docs/*.txt \
jinete/examples/*.[ch] \
jinete/examples/*.jid \
jinete/examples/*.pcx \
jinete/examples/*.ttf \
jinete/examples/*.txt \
jinete/include/*.h \
jinete/include/jinete/*.h \
jinete/lib/*.txt \
jinete/lib/djgpp/*.txt \
jinete/lib/mingw32/*.txt \
jinete/lib/unix/*.txt \
jinete/obj/*.txt \
jinete/obj/djgpp/*.txt \
jinete/obj/mingw32/*.txt \
jinete/obj/unix/*.txt \
jinete/src/*.c \
jinete/src/themes/*.c \
jinete/src/themes/Makefile.icons \
jinete/src/themes/stand/*.pcx \
$freetype_files"
freetype_files="third_party/freetype/ChangeLog \
third_party/freetype/descrip.mms \
third_party/freetype/INSTALL \
third_party/freetype/README \
third_party/freetype/README.UNX \
third_party/freetype/docs/* \
third_party/freetype/include/*.h \
third_party/freetype/include/freetype/*.h \
third_party/freetype/include/freetype/cache/*.h \
third_party/freetype/include/freetype/config/*.h \
third_party/freetype/include/freetype/internal/*.h \
third_party/freetype/src/autohint/*.[ch] \
third_party/freetype/src/autohint/*.py \
third_party/freetype/src/autohint/*.txt \
third_party/freetype/src/base/*.[ch] \
third_party/freetype/src/cache/*.[ch] \
third_party/freetype/src/cff/*.[ch] \
third_party/freetype/src/cid/*.[ch] \
third_party/freetype/src/pcf/*.[ch] \
third_party/freetype/src/psaux/*.[ch] \
third_party/freetype/src/pshinter/*.[ch] \
third_party/freetype/src/psnames/*.[ch] \
third_party/freetype/src/raster/*.[ch] \
third_party/freetype/src/sfnt/*.[ch] \
third_party/freetype/src/smooth/*.[ch] \
third_party/freetype/src/truetype/*.[ch] \
third_party/freetype/src/type1/*.[ch] \
third_party/freetype/src/winfonts/*.[ch]"
gfli_files="third_party/gfli/*.[ch] \
third_party/gfli/README \
third_party/gfli/TODO"
jpeg_files="third_party/jpeg/*.[ch] \
third_party/jpeg/*.log \
third_party/jpeg/*.doc \
third_party/jpeg/*.asm \
third_party/jpeg/*.txt"
libart_files="third_party/libart_lgpl/AUTHORS \
third_party/libart_lgpl/ChangeLog \
third_party/libart_lgpl/COPYING \
third_party/libart_lgpl/INSTALL \
third_party/libart_lgpl/NEWS \
third_party/libart_lgpl/README \
third_party/libart_lgpl/*.[ch]"
libpng_files="third_party/libpng/*.[ch] \
third_party/libpng/*.txt \
third_party/libpng/LICENSE \
third_party/libpng/README \
third_party/libpng/TODO \
third_party/libpng/Y2KINFO"
lua_files="third_party/lua/COPYRIGHT \
third_party/lua/HISTORY \
third_party/lua/README \
@ -79,89 +69,94 @@ lua_files="third_party/lua/COPYRIGHT \
third_party/lua/src/lib/*.[ch] \
third_party/lua/src/lib/README"
libart_files="third_party/libart_lgpl/AUTHORS \
third_party/libart_lgpl/ChangeLog \
third_party/libart_lgpl/COPYING \
third_party/libart_lgpl/INSTALL \
third_party/libart_lgpl/NEWS \
third_party/libart_lgpl/README \
third_party/libart_lgpl/*.[ch]"
zlib_files="third_party/zlib/*.[ch] \
third_party/zlib/*.txt \
third_party/zlib/README"
ase_files="all.h \
config.h \
ChangeLog \
COPYING \
fix.bat \
fix.sh \
makefile.cfg \
makefile.dj \
makefile.gcc \
makefile.lnx \
makefile.lst \
makefile.mgw \
*.txt \
data/aseicon.* \
data/convmatr.def \
data/gui-en.xml \
data/gui-es.xml \
data/fonts/*.pcx \
data/jids/*.jid \
data/palettes/*.col \
data/po/*.po \
data/scripts/*.lua \
data/scripts/examples/*.lua \
data/tips/*.pcx \
data/tips/tips.en \
data/tips/tips.es \
docs/*.html \
docs/*.info \
docs/*.pdf \
docs/*.texi \
docs/*.txt \
docs/files/*.txt \
docs/licenses/*.txt \
obj/*.txt \
obj/djgpp/*.txt \
obj/mingw32/*.txt \
obj/unix/*.txt \
src/*.[ch] \
src/*.rc \
src/commands/*.[ch] \
src/console/*.[ch] \
src/core/*.[ch] \
src/dialogs/*.[ch] \
src/dialogs/effect/*.[ch] \
src/effect/*.[ch] \
src/file/*.[ch] \
src/file/gif/*.[ch] \
src/intl/*.[ch] \
src/modules/*.[ch] \
src/raster/*.[ch] \
src/raster/examples/*.c \
src/raster/x86/*.s \
src/script/*.[ch] \
src/script/bindings.py \
src/util/*.[ch] \
src/widgets/*.[ch] \
src/widgets/editor/*.[ch] \
src/widgets/editor/*.txt \
ase_files="all.h \
config.h \
ChangeLog \
COPYING \
fix.bat \
fix.sh \
makefile.cfg \
makefile.dj \
makefile.gcc \
makefile.lnx \
makefile.lst \
makefile.mgw \
*.txt \
data/aseicon.* \
data/convmatr.def \
data/gui-en.xml \
data/fonts/*.pcx \
data/jids/*.jid \
data/palettes/*.col \
data/tips/*.pcx \
data/tips/tips.en \
data/tips/tips.es \
docs/*.html \
docs/*.info \
docs/*.pdf \
docs/*.texi \
docs/*.txt \
docs/files/*.txt \
docs/licenses/*.txt \
obj/*.txt \
obj/djgpp/*.txt \
obj/mingw32/*.txt \
obj/unix/*.txt \
src/*.[ch] \
src/*.rc \
src/commands/*.[ch] \
src/commands/fx/*.[ch] \
src/console/*.[ch] \
src/core/*.[ch] \
src/dialogs/*.[ch] \
src/effect/*.[ch] \
src/file/*.[ch] \
src/file/gif/*.[ch] \
src/intl/*.[ch] \
src/jinete/*.[ch] \
src/jinete/themes/*.[ch] \
src/jinete/themes/Makefile.icons \
src/jinete/themes/stand/*.pcx \
src/modules/*.[ch] \
src/raster/*.[ch] \
src/raster/x86/*.s \
src/script/*.[ch] \
src/script/*.py \
src/test/jinete/*.[ch] \
src/test/jinete/*.jid \
src/test/jinete/*.pcx \
src/test/jinete/*.ttf \
src/test/jinete/*.txt \
src/test/raster/*.[ch] \
src/util/*.[ch] \
src/widgets/*.[ch] \
src/widgets/editor/*.[ch] \
src/widgets/editor/*.txt \
third_party/*.txt"
######################################################################
# Source Distribution
# if [ ! -f $distdir.tar.gz ] ; then
if [ ! -f $distdir.zip ] ; then
cd "$dir/.."
mkdir "$dir/$distdir"
cp --parents \
$jinete_files \
$gfli_files \
$lua_files \
$libart_files \
$ase_files \
cp --parents \
$freetype_files \
$gfli_files \
$jpeg_files \
$libart_files \
$libpng_files \
$lua_files \
$zlib_files \
$ase_files \
"$dir/$distdir"
cd "$dir"
# tar vczf $distdir.tar.gz $distdir
@ -171,8 +166,6 @@ rm -fr $distdir
fi
exit
######################################################################
# Files for binary distributions
@ -182,13 +175,8 @@ function def_common_files()
$1/*.txt \
$1/COPYING \
$1/data/convmatr.def \
$1/data/fonts/*.txt \
$1/data/jids/*.jid \
$1/data/menus.en \
$1/data/menus.es \
$1/data/po/es.po \
$1/data/scripts/*.lua \
$1/data/scripts/examples/*.lua \
$1/data/gui-en.xml \
$1/data/tips/*.en \
$1/data/tips/*.es \
$1/docs/*.html \
@ -201,71 +189,28 @@ $1/docs/licenses/*.txt"
bin_files=" \
$1/data/aseicon.* \
$1/data/fonts/*.pcx \
$1/data/fonts/*.ttf \
$1/data/palettes/*.col \
$1/data/tips/*.pcx \
$1/docs/*.pdf"
}
######################################################################
# Unix Distribution
# if [ ! -f $distdir-unix.tar.gz ] ; then
# cd $dir/..
# rm ase
# make -f makefile.lnx CONFIGURED=1
# strip ase
# def_common_files .
# mkdir $dir/$distdir-unix
# cp -r --parents $txt_files $bin_files ase $dir/$distdir-unix
# cd $dir
# tar vczf $distdir-unix.tar.gz $distdir-unix
# rm -fr $distdir-unix
# fi
######################################################################
# DOS Distribution
# if [ ! -f $distdir-dos.zip ] ; then
# cd $dir/..
# rm ase.exe
# djgpp make -f makefile.dj CONFIGURED=1
# djgpp strip ase.exe
# def_common_files .
# mkdir $dir/$distdir-dos
# cp -r --parents $txt_files $bin_files ase.exe cwsdpmi.doc cwsdpmi.exe $dir/$distdir-dos
# cd $dir
# def_common_files $distdir-dos
# zip -l -9 $distdir-dos.zip $txt_files
# zip -9 $distdir-dos.zip $bin_files \
# $distdir-dos/ase.exe \
# $distdir-dos/cwsdpmi.*
# rm -fr $distdir-dos
# fi
######################################################################
# Win32 Distribution
if [ ! -f $distdir-win32.zip ] ; then
cd "$dir/.."
rm ase
mingw32 make -f makefile.mgw CONFIGURED=1
mingw32 strip ase.exe
make -f makefile.mgw CONFIGURED=1 clean
make -f makefile.mgw CONFIGURED=1
strip -s ase.exe
def_common_files .
mkdir "$dir/$distdir-win32"
cp -r --parents $txt_files $bin_files ase.exe "$dir/$distdir-win32"
cp alleg42.dll "$dir/$distdir-win32"
cd "$dir"
cp alleg42.dll "$dir/$distdir-win32"
def_common_files $distdir-win32
zip -l -9 $distdir-win32.zip $txt_files
zip -9 $distdir-win32.zip $txt_files
zip -9 $distdir-win32.zip $bin_files \
$distdir-win32/ase.exe \
$distdir-win32/alleg42.dll

View File

@ -20,6 +20,7 @@
#ifndef USE_PRECOMPILED_HEADER
#include <assert.h>
#include <allegro/config.h>
#include <allegro/unicode.h>
@ -34,6 +35,8 @@
#include "modules/sprites.h"
#include "raster/image.h"
#include "raster/sprite.h"
#include "raster/undo.h"
#include "script/functions.h"
#include "util/misc.h"
#endif
@ -47,8 +50,6 @@ static const char *bg_table[] = {
static int _sprite_counter = 0;
static Sprite *new_sprite(int imgtype, int w, int h);
/**
* Shows the "New Sprite" dialog.
*/
@ -134,7 +135,7 @@ static void cmd_new_file_execute(const char *argument)
set_config_int("NewSprite", "Background", bg);
/* create the new sprite */
sprite = new_sprite(imgtype, w, h);
sprite = NewSprite(imgtype, w, h);
if (!sprite) {
console_printf("Not enough memory to allocate the sprite\n");
}
@ -145,6 +146,14 @@ static void cmd_new_file_execute(const char *argument)
/* image_clear(GetImage(), get_color_for_image(imgtype, color)); */
sprite->bgcolor = get_color_for_image(imgtype, color);
/* the undo should be disabled because we use NewSprite to
create it (a function for scripts) */
assert(undo_is_disabled(sprite->undo));
/* enable undo */
undo_enable(sprite->undo);
/* show the sprite to the user */
sprite_show(sprite);
}
@ -155,18 +164,6 @@ static void cmd_new_file_execute(const char *argument)
jwidget_free(window);
}
static Sprite *new_sprite(int imgtype, int w, int h)
{
/* new sprite */
Sprite *sprite = sprite_new_with_layer(imgtype, w, h);
if (!sprite)
return NULL;
sprite_mount(sprite);
set_current_sprite(sprite);
return sprite;
}
Command cmd_new_file = {
CMD_NEW_FILE,
NULL,

View File

@ -28,6 +28,7 @@
#include "modules/sprites.h"
#include "raster/layer.h"
#include "raster/sprite.h"
#include "raster/undo.h"
#include "script/functions.h"
#endif
@ -41,7 +42,6 @@ static void cmd_new_layer_execute(const char *argument)
{
JWidget window, name_widget;
Sprite *sprite = current_sprite; /* get current sprite */
char buf[512];
/* load the window widget */
window = load_widget("newlay.jid", "new_layer");
@ -52,28 +52,18 @@ static void cmd_new_layer_execute(const char *argument)
jwidget_set_text(name_widget, GetUniqueLayerName());
jwidget_set_min_size(name_widget, 128, 0);
sprintf(buf, "%d", sprite->w);
jwidget_set_text(jwidget_find_name(window, "width"), buf);
sprintf(buf, "%d", sprite->h);
jwidget_set_text(jwidget_find_name(window, "height"), buf);
jwindow_open_fg(window);
if (jwindow_get_killer(window) == jwidget_find_name(window, "ok")) {
const char *name = jwidget_get_text(jwidget_find_name(window, "name"));
Layer *layer;
int w, h;
w = strtol(jwidget_get_text(jwidget_find_name(window, "width")), NULL, 10);
h = strtol(jwidget_get_text(jwidget_find_name(window, "height")), NULL, 10);
w = MID(1, w, 9999);
h = MID(1, h, 9999);
layer = NewLayer(name, 0, 0, w, h);
Layer *layer = NewLayer();
if (!layer) {
jalert(_("Error<<Not enough memory||&Close"));
if (undo_is_enabled(sprite->undo))
undo_close(sprite->undo);
return;
}
layer_set_name(layer, name);
update_screen_for_sprite(sprite);
}

View File

@ -51,11 +51,12 @@ static void cmd_new_layer_set_execute(const char *argument)
if (jwindow_get_killer(window) == jwidget_find_name(window, "ok")) {
const char *name = jwidget_get_text(jwidget_find_name(window, "name"));
Layer *layer = NewLayerSet(name);
Layer *layer = NewLayerSet();
if (!layer) {
jalert(_("Error<<Not enough memory||&Close"));
return;
}
layer_set_name(layer, name);
update_screen_for_sprite(sprite);
}

View File

@ -1,139 +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 <allegro.h>
#include "jinete/jmanager.h"
#include "jinete/jsystem.h"
#include "core/core.h"
#include "modules/gui.h"
#endif
void dialogs_screen_saver(void)
{
int r_value, g_value, b_value;
int r_delta, g_delta, b_delta;
V3D_f v1, v2, v3;
PALETTE palette;
PALETTE backup;
int c;
if (!is_interactive())
return;
/* hide the mouse */
jmouse_set_cursor(JI_CURSOR_NULL);
/* get the current color palette */
get_palette(backup);
/* flush drawing messages (useful when we are using double-buffering) */
gui_feedback();
/* clear the screen */
clear(ji_screen);
/* start the values */
r_value = (rand() & 0x3F);
g_value = (rand() & 0x3F);
b_value = (rand() & 0x3F);
r_delta = (rand() & 5) + 1;
g_delta = (rand() & 5) + 1;
b_delta = (rand() & 5) + 1;
/* clear the keyboard buffer */
clear_keybuf ();
do {
/* generate the palette */
palette[0].r = palette[0].g = palette[0].b = 0;
for (c=1; c<PAL_SIZE; c++) {
palette[c].r = (r_value & 0x3F) * c / (PAL_SIZE-1);
palette[c].g = (g_value & 0x3F) * c / (PAL_SIZE-1);
palette[c].b = (b_value & 0x3F) * c / (PAL_SIZE-1);
}
/* update values */
r_value += r_delta;
g_value += g_delta;
b_value += b_delta;
if ((r_value < 0) || (r_value > 0x3F)) {
r_value -= r_delta;
r_delta = -SGN(r_delta) * ((rand() & 5) + 1);
}
if ((g_value < 0) || (g_value > 0x3F)) {
g_value -= g_delta;
g_delta = -SGN(g_delta) * ((rand() & 5) + 1);
}
if ((b_value < 0) || (b_value > 0x3F)) {
b_value -= b_delta;
b_delta = -SGN(b_delta) * ((rand() & 5) + 1);
}
/* vertices */
v1.x = (rand()%(JI_SCREEN_W+64)) - 32;
v1.y = (rand()%(JI_SCREEN_H+64)) - 32;
v2.x = (rand()%(JI_SCREEN_W+64)) - 32;
v2.y = (rand()%(JI_SCREEN_H+64)) - 32;
v3.x = (rand()%(JI_SCREEN_W+64)) - 32;
v3.y = (rand()%(JI_SCREEN_H+64)) - 32;
/* vertical-retrace */
vsync();
set_palette_range(palette, 0, PAL_SIZE-1, FALSE);
/* colors */
v1.c = palette_color[rand()%256];
v2.c = palette_color[rand()%256];
v3.c = palette_color[rand()%256];
/* draw a triangle */
triangle3d_f(ji_screen,
(bitmap_color_depth(ji_screen) == 8)?
POLYTYPE_GCOL: POLYTYPE_GRGB, NULL, &v1, &v2, &v3);
/* poll GUI */
jmouse_poll();
gui_feedback();
} while ((!keypressed()) && (!jmouse_b(0)));
/* clear the screen */
clear(ji_screen);
/* restore the color palette */
set_palette(backup);
/* wait while the user has pushed some mouse button */
do {
jmouse_poll();
gui_feedback();
} while (jmouse_b(0));
jmanager_refresh_screen();
jmouse_set_cursor(JI_CURSOR_NORMAL);
/* clear again the keyboard buffer */
clear_keybuf();
}

View File

@ -1,25 +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
*/
#ifndef DIALOGS_SCRSAVER_H
#define DIALOGS_SCRSAVER_H
void dialogs_screen_saver(void);
#endif /* DIALOGS_SCRSAVER_H */

View File

@ -46,6 +46,7 @@
#include "modules/tools2.h"
#include "raster/raster.h"
#include "script/bindings.h"
#include "script/functions.h"
#endif
@ -90,13 +91,13 @@ typedef struct UserData
} UserData;
static int metatable;
static int metatable_index (lua_State *L);
static int metatable_newindex (lua_State *L);
static int metatable_gc (lua_State *L);
static int metatable_eq (lua_State *L);
static int metatable_index(lua_State *L);
static int metatable_newindex(lua_State *L);
static int metatable_gc(lua_State *L);
static int metatable_eq(lua_State *L);
static void push_userdata (lua_State *L, int type, void *ptr);
static void *to_userdata (lua_State *L, int type, int idx);
static void push_userdata(lua_State *L, int type, void *ptr);
static void *to_userdata(lua_State *L, int type, int idx);
/********************************************************************/
@ -113,9 +114,9 @@ void register_lua_object_metatable(void)
/* class metatable */
lua_newtable(L);
metatable = lua_ref (L, 1);
metatable = lua_ref(L, 1);
lua_getref (L, metatable);
lua_getref(L, metatable);
lua_pushliteral(L, "__index");
lua_pushcfunction(L, metatable_index);
@ -151,7 +152,7 @@ void unregister_lua_object_metatable(void)
/* for (c=0; c<Types; c++) */
/* r_hash_free (hash_index_tables[c], NULL); */
lua_unref (get_lua_state (), metatable);
lua_unref(get_lua_state(), metatable);
}
/**
@ -159,22 +160,22 @@ void unregister_lua_object_metatable(void)
*/
void update_global_script_variables(void)
{
lua_State *L = get_lua_state ();
lua_State *L = get_lua_state();
lua_pushstring (L, VERSION);
lua_setglobal (L, "VERSION");
lua_pushstring(L, VERSION);
lua_setglobal(L, "VERSION");
push_userdata (L, Type_Sprite, current_sprite);
lua_setglobal (L, "current_sprite");
push_userdata(L, Type_Sprite, current_sprite);
lua_setglobal(L, "current_sprite");
push_userdata (L, Type_JWidget, current_editor);
lua_setglobal (L, "current_editor");
push_userdata(L, Type_JWidget, current_editor);
lua_setglobal(L, "current_editor");
lua_pushnumber (L, ji_screen ? JI_SCREEN_W: 0);
lua_setglobal (L, "SCREEN_W");
lua_pushnumber(L, ji_screen ? JI_SCREEN_W: 0);
lua_setglobal(L, "SCREEN_W");
lua_pushnumber (L, ji_screen ? JI_SCREEN_H: 0);
lua_setglobal (L, "SCREEN_H");
lua_pushnumber(L, ji_screen ? JI_SCREEN_H: 0);
lua_setglobal(L, "SCREEN_H");
}
static void push_userdata(lua_State *L, int type, void *ptr)
@ -530,50 +531,23 @@ static int bind_rand(lua_State *L)
return 1;
}
static int bind_GetImage2(lua_State *L)
{
Sprite *sprite;
Image *image;
int x, y, opacity;
sprite = to_userdata(L, Type_Sprite, 1);
image = GetImage2(sprite, &x, &y, &opacity);
push_userdata(L, Type_Image, image);
lua_pushnumber(L, x);
lua_pushnumber(L, y);
lua_pushnumber(L, opacity);
return 4;
}
/* static int bind_GetImage2(lua_State *L) */
/* { */
/* Sprite *sprite; */
/* Image *image; */
/* int x, y, opacity; */
/* sprite = to_userdata(L, Type_Sprite, 1); */
/* image = GetImage2(sprite, &x, &y, &opacity); */
/* push_userdata(L, Type_Image, image); */
/* lua_pushnumber(L, x); */
/* lua_pushnumber(L, y); */
/* lua_pushnumber(L, opacity); */
/* return 4; */
/* } */
/********************************************************************/
/* Include generated bindings file */
#ifndef USE_PRECOMPILED_HEADER
#include "dialogs/canvasze.h"
#include "dialogs/dmapgen.h"
#include "dialogs/drawtext.h"
#include "dialogs/filmedit.h"
#include "dialogs/maskcol.h"
#include "dialogs/options.h"
#include "dialogs/playfli.h"
#include "dialogs/quick.h"
#include "dialogs/scrsaver.h"
#include "dialogs/tips.h"
#include "dialogs/vectmap.h"
#include "file/file.h"
#include "intl/intl.h"
#include "modules/rootmenu.h"
#include "util/autocrop.h"
#include "util/celmove.h"
#include "util/clipbrd.h"
#include "util/crop.h"
#include "util/mapgen.h"
#include "util/msk_file.h"
#include "util/quantize.h"
#include "util/recscr.h"
#endif
#define file_exists exists
#include "script/genbinds.c"

View File

@ -55,546 +55,47 @@ bool file_exists(const char *filename);
char *get_filename(const char *filename);
/*===================================================================*/
/* Miscellaneous routines */
/* Sprite */
/*===================================================================*/
/* console/console.c */
void do_progress(int progress);
void add_progress(int max);
void del_progress(void);
/* core/core.c */
bool is_interactive(void);
/* core/app.c */
void app_refresh_screen(void);
int app_get_current_image_type(void);
JWidget app_get_top_window(void);
JWidget app_get_menu_bar(void);
JWidget app_get_status_bar(void);
JWidget app_get_color_bar(void);
JWidget app_get_tool_bar(void);
/* intl/intl.c */
void intl_load_lang(void);
const char *intl_get_lang(void);
void intl_set_lang(const char *lang);
/* modules/rootmenu.c */
void show_fx_popup_menu(void);
/* Brush *get_brush (void); */
int get_brush_type(void);
int get_brush_size(void);
int get_brush_angle(void);
int get_brush_mode(void);
int get_glass_dirty(void);
int get_spray_width(void);
int get_air_speed(void);
bool get_filled_mode(void);
bool get_tiled_mode(void);
bool get_use_grid(void);
bool get_view_grid(void);
JRect get_grid(void);
bool get_onionskin(void);
void set_brush_type(int type);
void set_brush_size(int size);
void set_brush_angle(int angle);
void set_brush_mode(int mode);
void set_glass_dirty(int glass_dirty);
void set_spray_width(int spray_width);
void set_air_speed(int air_speed);
void set_filled_mode(bool status);
void set_tiled_mode(bool status);
void set_use_grid(bool status);
void set_view_grid(bool status);
void set_grid(JRect rect);
void set_onionskin(bool status);
/* modules/tools2.c */
void SetBrush(const char *string);
void SetDrawMode(const char *string);
void ToolTrace(const char *string);
/* modules/color.c */
const char *get_fg_color(void);
const char *get_bg_color(void);
void set_fg_color(const char *string);
void set_bg_color(const char *string);
int get_color_for_image(int image_type, const char *color);
char *image_getpixel_color(Image *image, int x, int y);
/* modules/sprites.c */
/* JList get_sprite_list (void); */
Sprite *get_first_sprite(void);
Sprite *get_next_sprite(Sprite *sprite);
Sprite *get_clipboard_sprite(void);
void set_clipboard_sprite(Sprite *sprite);
void sprite_mount(Sprite *sprite);
void sprite_unmount(Sprite *sprite);
void set_current_sprite(Sprite *sprite);
void sprite_show(Sprite *sprite);
void sprite_generate_mask_boundaries(Sprite *sprite);
/* file/file.c */
Sprite *sprite_load(const char *filename);
int sprite_save(Sprite *sprite);
char *get_readable_extensions(void);
char *get_writable_extensions(void);
/* modules/editors.c */
void set_current_editor(JWidget editor);
void update_editors_with_sprite(Sprite *sprite);
void editors_draw_sprite(Sprite *sprite, int x1, int y1, int x2, int y2);
void replace_sprite_in_editors(Sprite *old_sprite, Sprite *new_sprite);
void set_sprite_in_current_editor(Sprite *sprite);
void set_sprite_in_more_reliable_editor(Sprite *sprite);
void split_editor(JWidget editor, int align);
void close_editor(JWidget editor);
void make_unique_editor(JWidget editor);
/* core/recent.c */
void recent_file(const char *filename);
void unrecent_file(const char *filename);
/* modules/palette.c */
void use_current_sprite_rgb_map(void);
void use_sprite_rgb_map(Sprite *sprite);
void restore_rgb_map(void);
/* util/autocrop.c */
void autocrop_sprite(void);
/* util/canvasze.c */
void canvas_resize(void);
/* util/clipbrd.c */
void cut_to_clipboard(void);
void copy_to_clipboard(void);
void paste_from_clipboard(void);
/* util/crop.c */
void crop_sprite(void);
void crop_layer(void);
void crop_cel(void);
/* util/celmove.c */
void set_cel_to_handle(Layer *layer, Cel *cel);
void move_cel(void);
void copy_cel(void);
void link_cel(void);
/* util/mapgen.c */
void mapgen(Image *image, int seed, float fractal_factor);
/* util/misc.c */
Image *GetImage(void);
Image *GetImage2(Sprite *sprite, int *x, int *y, int *opacity); /* CODE */
void LoadPalette(const char *filename);
void ClearMask(void);
Layer *NewLayerFromMask(Sprite *src_sprite, Sprite *dst_sprite);
/* util/msk_file.c */
Mask *load_msk_file(const char *filename);
int save_msk_file(Mask *mask, const char *filename);
/* util/quantize.c */
void sprite_quantize(Sprite *sprite);
/* modules/gui.c */
void update_screen_for_sprite(Sprite *sprite);
void rebuild_root_menu(void);
void rebuild_sprite_list(void);
void rebuild_recent_list(void);
/* dialogs/quick.c */
void quick_move(void);
void quick_copy(void);
void quick_swap(void);
/* dialogs/playfli.c */
void play_fli_animation(const char *filename, bool loop, bool fullscreen);
/* dialogs/... */
void dialogs_draw_text(void);
void switch_between_film_and_sprite_editor(void);
void dialogs_mapgen(void);
void dialogs_mask_color(void);
void dialogs_options(void);
void dialogs_palette_editor(void);
void dialogs_screen_saver(void);
void dialogs_select_language(bool force);
void dialogs_tips(bool forced);
void dialogs_vector_map(void);
/* dialogs/drawtext.c */
Image *RenderText(const char *fontname, int size, int color, const char *text);
/*===================================================================*/
/* Graphics routines */
/*===================================================================*/
/* GfxObj ***********************************************************/
#define GFXOBJ_IMAGE
#define GFXOBJ_STOCK
#define GFXOBJ_CEL
#define GFXOBJ_LAYER_IMAGE
#define GFXOBJ_LAYER_SET
#define GFXOBJ_SPRITE
#define GFXOBJ_MASK
#define GFXOBJ_PATH
#define GFXOBJ_UNDO
/* Blend ************************************************************/
#define BLEND_MODE_NORMAL
#define BLEND_MODE_DISSOLVE
#define BLEND_MODE_MULTIPLY
#define BLEND_MODE_SCREEN
#define BLEND_MODE_OVERLAY
#define BLEND_MODE_HARD_LIGHT
#define BLEND_MODE_DODGE
#define BLEND_MODE_BURN
#define BLEND_MODE_DARKEN
#define BLEND_MODE_LIGHTEN
#define BLEND_MODE_ADDITION
#define BLEND_MODE_SUBTRACT
#define BLEND_MODE_DIFFERENCE
#define BLEND_MODE_HUE
#define BLEND_MODE_SATURATION
#define BLEND_MODE_COLOR
#define BLEND_MODE_LUMINOSITY
/* Image ************************************************************/
#define _rgba_r_shift
#define _rgba_g_shift
#define _rgba_b_shift
#define _rgba_a_shift
int _rgba_getr(int c);
int _rgba_getg(int c);
int _rgba_getb(int c);
int _rgba_geta(int c);
int _rgba(int r, int g, int b, int a);
#define _graya_k_shift
#define _graya_a_shift
int _graya_getk(int c);
int _graya_geta(int c);
int _graya(int k, int a);
#define IMAGE_RGB
#define IMAGE_GRAYSCALE
#define IMAGE_INDEXED
#define IMAGE_BITMAP
Image *image_new(int imgtype, int w, int h);
Image *image_new_copy(Image *image);
void image_free(Image *image);
Sprite *NewSprite(int imgtype, int w, int h);
Sprite *LoadSprite(const char *filename);
void SaveSprite(const char *filename);
int image_getpixel(Image *image, int x, int y);
void image_putpixel(Image *image, int x, int y, int color);
void SetSprite(Sprite *sprite);
void image_clear(Image *image, int color);
/*===================================================================*/
/* Layer */
/*===================================================================*/
void image_copy(Image *dst, Image *src, int x, int y);
void image_merge(Image *dst, Image *src, int x, int y, int opacity, int blend_mode);
Image *image_crop(Image *image, int x, int y, int w, int h);
Layer *NewLayer(void);
Layer *NewLayerSet(void);
void RemoveLayer(void);
void image_hline(Image *image, int x1, int y, int x2, int color);
void image_vline(Image *image, int x, int y1, int y2, int color);
void image_rect(Image *image, int x1, int y1, int x2, int y2, int color);
void image_rectfill(Image *image, int x1, int y1, int x2, int y2, int color);
void image_line(Image *image, int x1, int y1, int x2, int y2, int color);
void image_ellipse(Image *image, int x1, int y1, int x2, int y2, int color);
void image_ellipsefill(Image *image, int x1, int y1, int x2, int y2, int color);
void image_convert(Image *dst, Image *src);
int image_count_diff(Image *i1, Image *i2);
/* rotate */
void image_scale(Image *dst, Image *src, int x, int y, int w, int h);
void image_rotate(Image *dst, Image *src, int x, int y, int w, int h, int cx, int cy, double angle);
void image_parallelogram(Image *bmp, Image *sprite, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
/* Cel ************************************************************/
Cel *cel_new(int frame, int image);
Cel *cel_new_copy(Cel *cel);
void cel_free(Cel *cel);
Cel *cel_is_link(Cel *cel, Layer *layer);
/* #define BLEND_MODE_NORMAL */
/* #define BLEND_MODE_DISSOLVE */
/* #define BLEND_MODE_MULTIPLY */
/* #define BLEND_MODE_SCREEN */
/* #define BLEND_MODE_OVERLAY */
/* #define BLEND_MODE_HARD_LIGHT */
/* #define BLEND_MODE_DODGE */
/* #define BLEND_MODE_BURN */
/* #define BLEND_MODE_DARKEN */
/* #define BLEND_MODE_LIGHTEN */
/* #define BLEND_MODE_ADDITION */
/* #define BLEND_MODE_SUBTRACT */
/* #define BLEND_MODE_DIFFERENCE */
/* #define BLEND_MODE_HUE */
/* #define BLEND_MODE_SATURATION */
/* #define BLEND_MODE_COLOR */
/* #define BLEND_MODE_LUMINOSITY */
void cel_set_frame(Cel *cel, int frame);
void cel_set_image(Cel *cel, int image);
void cel_set_position(Cel *cel, int x, int y);
void cel_set_opacity(Cel *cel, int opacity);
/* Layer ************************************************************/
Layer *layer_new(Sprite *sprite);
Layer *layer_set_new(Sprite *sprite);
/* Layer *layer_text_new(const char *text); */
Layer *layer_new_copy(Layer *layer);
void layer_free(Layer *layer);
bool layer_is_image(Layer *layer);
bool layer_is_set(Layer *layer);
Layer *layer_get_prev(Layer *layer);
Layer *layer_get_next(Layer *layer);
void layer_set_name(Layer *layer, const char *name);
void layer_set_blend_mode(Layer *layer, int blend_mode);
/* void layer_set_parent(Layer *layer, GfxObj *gfxobj); */
/* for LAYER_IMAGE */
void layer_add_cel(Layer *layer, Cel *cel);
void layer_remove_cel(Layer *layer, Cel *cel);
Cel *layer_get_cel(Layer *layer, int frame);
/* for LAYER_SET */
void layer_add_layer(Layer *set, Layer *layer);
void layer_remove_layer(Layer *set, Layer *layer);
void layer_move_layer(Layer *set, Layer *layer, Layer *after);
void layer_render(Layer *layer, Image *image, int x, int y, int frame);
Layer *layer_flatten(Layer *layer, int x, int y, int w, int h, int frmin, int frmax);
/* Mask *************************************************************/
Mask *mask_new(void);
Mask *mask_new_copy(Mask *mask);
void mask_free(Mask *mask);
bool mask_is_empty(Mask *mask);
void mask_set_name(Mask *mask, const char *name);
void mask_move(Mask *mask, int x, int y);
void mask_none(Mask *mask);
void mask_invert(Mask *mask);
void mask_replace(Mask *mask, int x, int y, int w, int h);
void mask_union(Mask *mask, int x, int y, int w, int h);
void mask_subtract(Mask *mask, int x, int y, int w, int h);
void mask_intersect(Mask *mask, int x, int y, int w, int h);
void mask_merge(Mask *dst, Mask *src);
void mask_by_color(Mask *mask, Image *image, int color, int fuzziness);
void mask_crop(Mask *mask, Image *image);
/* Path *************************************************************/
#define PATH_JOIN_MITER
#define PATH_JOIN_ROUND
#define PATH_JOIN_BEVEL
#define PATH_CAP_BUTT
#define PATH_CAP_ROUND
#define PATH_CAP_SQUARE
Path *path_new(const char *name);
void path_free(Path *path);
void path_set_join(Path *path, int join);
void path_set_cap(Path *path, int cap);
void path_moveto(Path *path, double x, double y);
void path_lineto(Path *path, double x, double y);
void path_curveto(Path *path, double control_x1, double control_y1, double control_x2, double control_y2, double end_x, double end_y);
void path_close(Path *path);
void path_move(Path *path, double x, double y);
void path_stroke(Path *path, Image *image, int color, double brush_size);
void path_fill(Path *path, Image *image, int color);
/* Sprite ***********************************************************/
#define DITHERING_NONE
#define DITHERING_ORDERED
Sprite *sprite_new(int imgtype, int w, int h);
Sprite *sprite_new_copy(Sprite *sprite);
Sprite *sprite_new_flatten_copy(Sprite *sprite);
Sprite *sprite_new_with_layer(int imgtype, int w, int h);
void sprite_free(Sprite *sprite);
bool sprite_is_modified(Sprite *sprite);
bool sprite_is_associated_to_file(Sprite *sprite);
void sprite_mark_as_saved(Sprite *sprite);
void sprite_set_filename(Sprite *sprite, const char *filename);
void sprite_set_size(Sprite *sprite, int w, int h);
void sprite_set_frames(Sprite *sprite, int frames);
void sprite_set_frlen(Sprite *sprite, int msecs, int frame);
int sprite_get_frlen(Sprite *sprite, int frame);
void sprite_set_speed(Sprite *sprite, int speed);
void sprite_set_path(Sprite *sprite, Path *path);
void sprite_set_mask(Sprite *sprite, Mask *mask);
void sprite_set_layer(Sprite *sprite, Layer *layer);
void sprite_set_frame(Sprite *sprite, int frame);
void sprite_set_imgtype(Sprite *sprite, int imgtype, int dithering_method);
void sprite_add_path(Sprite *sprite, Path *path);
void sprite_remove_path(Sprite *sprite, Path *path);
void sprite_add_mask(Sprite *sprite, Mask *mask);
void sprite_remove_mask(Sprite *sprite, Mask *mask);
Mask *sprite_request_mask(Sprite *sprite, const char *name);
void sprite_render(Sprite *sprite, Image *image, int x, int y);
/* Stock ************************************************************/
Stock *stock_new(int imgtype);
Stock *stock_new_copy(Stock *stock);
void stock_free(Stock *stock);
int stock_add_image(Stock *stock, Image *image);
void stock_remove_image(Stock *stock, Image *image);
void stock_replace_image(Stock *stock, int index, Image *image);
Image *stock_get_image(Stock *stock, int index);
/* Undo *************************************************************/
Undo *undo_new(Sprite *sprite);
void undo_free(Undo *undo);
void undo_enable(Undo *undo);
void undo_disable(Undo *undo);
bool undo_is_enabled(Undo *undo);
bool undo_is_disabled(Undo *undo);
bool undo_can_undo(Undo *undo);
bool undo_can_redo(Undo *undo);
void undo_undo(Undo *undo);
void undo_redo(Undo *undo);
void undo_open(Undo *undo);
void undo_close(Undo *undo);
/* void undo_data(Undo *undo, GfxObj *gfxobj, void *data, int size); */
void undo_image(Undo *undo, Image *image, int x, int y, int w, int h);
void undo_flip(Undo *undo, Image *image, int x1, int y1, int x2, int y2, int horz);
/* void undo_dirty(Undo *undo, Dirty *dirty); */
void undo_add_image(Undo *undo, Stock *stock, Image *image);
void undo_remove_image(Undo *undo, Stock *stock, Image *image);
void undo_replace_image(Undo *undo, Stock *stock, int index);
void undo_add_cel(Undo *undo, Layer *layer, Cel *cel);
void undo_remove_cel(Undo *undo, Layer *layer, Cel *cel);
void undo_add_layer(Undo *undo, Layer *set, Layer *layer);
void undo_remove_layer(Undo *undo, Layer *layer);
void undo_move_layer(Undo *undo, Layer *layer);
void undo_set_layer(Undo *undo, Sprite *sprite);
void undo_set_mask(Undo *undo, Sprite *sprite);
/*===================================================================*/
/* Effect routines */
/*===================================================================*/
Effect *effect_new(Sprite *sprite, const char *name);
void effect_free(Effect *effect);
void effect_load_target(Effect *effect);
void effect_set_target(Effect *effect, bool r, bool g, bool b, bool k, bool a, bool index);
void effect_set_target_rgb(Effect *effect, bool r, bool g, bool b, bool a);
void effect_set_target_grayscale(Effect *effect, bool k, bool a);
void effect_set_target_indexed(Effect *effect, bool r, bool g, bool b, bool index);
void effect_begin(Effect *effect);
void effect_begin_for_preview(Effect *effect);
int effect_apply_step(Effect *effect);
void effect_apply(Effect *effect);
void effect_flush(Effect *effect);
void effect_apply_to_image(Effect *effect, Image *image, int x, int y);
void effect_apply_to_target(Effect *effect);
/* effect/colcurve.c */
#define CURVE_LINEAR
#define CURVE_SPLINE
CurvePoint *curve_point_new(int x, int y);
void curve_point_free(CurvePoint *point);
Curve *curve_new(int type);
void curve_free(Curve *curve);
void curve_add_point(Curve *curve, CurvePoint *point);
void curve_remove_point(Curve *curve, CurvePoint *point);
void set_color_curve(Curve *curve);
/* effect/convmatr.c */
ConvMatr *convmatr_new(int w, int h);
ConvMatr *convmatr_new_string(const char *format);
void convmatr_free(ConvMatr *convmatr);
void set_convmatr(ConvMatr *convmatr);
ConvMatr *get_convmatr(void);
ConvMatr *get_convmatr_by_name(const char *name);
/* void reload_matrices_stock(void); */
/* void clean_matrices_stock(void); */
/* JList get_convmatr_stock(void); */
/* effect/replcol.c */
void set_replace_colors(int from, int to, int fuzziness);
/* effect/median.c */
void set_median_size(int w, int h);
/* #define DITHERING_NONE */
/* #define DITHERING_ORDERED */
/*===================================================================*/
/* End */

View File

@ -20,9 +20,11 @@
#ifndef USE_PRECOMPILED_HEADER
#include <assert.h>
#include "jinete/jinete.h"
#include "console/console.h"
#include "file/file.h"
#include "modules/gui.h"
#include "modules/sprites.h"
#include "raster/blend.h"
@ -35,155 +37,234 @@
#endif
/* ======================================= */
/* Sprite */
/* ======================================= */
/*===================================================================*/
/* Sprite */
/*===================================================================*/
/* ======================================= */
/* Layer */
/* ======================================= */
/* internal routine */
static int count_layers(Layer *layer)
/**
* Creates a new sprite with the given dimension.
*
* @param imgtype Color mode, one of the following values: IMAGE_RGB, IMAGE_GRAYSCALE, IMAGE_INDEXED
* @param w Width of the sprite
* @param h Height of the sprite
*/
Sprite *NewSprite(int imgtype, int w, int h)
{
int count;
Sprite *sprite;
if (layer->parent->type == GFXOBJ_SPRITE)
count = 0;
else
count = 1;
if (layer_is_set(layer)) {
JLink link;
JI_LIST_FOR_EACH(layer->layers, link) {
count += count_layers(link->data);
}
}
return count;
}
/* internal routine */
static void undo_remove_stock_images(Layer *layer)
{
JLink link;
if (layer_is_set(layer)) {
JI_LIST_FOR_EACH(layer->layers, link)
undo_remove_stock_images(link->data);
}
else if (layer_is_image(layer)) {
JI_LIST_FOR_EACH(layer->cels, link) {
Cel *cel = link->data;
if (!cel_is_link(cel, layer))
undo_remove_image(layer->sprite->undo,
layer->sprite->stock,
stock_get_image(layer->sprite->stock,
cel->image));
}
}
}
char *GetUniqueLayerName(void)
{
Sprite *sprite = current_sprite;
if (sprite) {
char buf[1024];
sprintf(buf, "%s %d", _("Layer"), count_layers(sprite->set));
return jstrdup(buf);
}
else
if (imgtype != IMAGE_RGB &&
imgtype != IMAGE_GRAYSCALE &&
imgtype != IMAGE_INDEXED) {
console_printf("NewSprite: argument 'imgtype' should be IMAGE_RGB, IMAGE_GRAYSCALE or IMAGE_INDEXED\n");
return NULL;
}
if (w < 1 || w > 9999) {
console_printf("NewSprite: argument 'w' should be between 1 and 9999\n");
return NULL;
}
if (h < 1 || h > 9999) {
console_printf("NewSprite: argument 'h' should be between 1 and 9999\n");
return NULL;
}
sprite = sprite_new_with_layer(imgtype, w, h);
if (!sprite)
return NULL;
undo_disable(sprite->undo);
sprite_mount(sprite);
set_current_sprite(sprite);
assert(undo_is_disabled(sprite->undo));
return sprite;
}
/**
* Creates a new layer with the "name" in the current sprite(in the
* current frame) with the specified position and size(if w=h=0 the
* Loads a sprite from the specified file.
*
* If the sprite is succefully loaded it'll be selected as the current
* sprite (@ref SetSprite) automatically.
*
* @param filename The name of the file. Can be absolute or relative
* to the location which ASE was executed.
*
* @return The loaded sprite or nil if it couldn't be read.
*/
Sprite *LoadSprite(const char *filename)
{
Sprite *sprite;
if (filename == NULL) {
console_printf("LoadSprite: filename can't be NULL\n");
return NULL;
}
sprite = sprite_load(filename);
if (sprite) {
undo_disable(sprite->undo);
sprite_mount(sprite);
set_current_sprite(sprite);
}
assert(undo_is_disabled(sprite->undo));
return sprite;
}
/**
* Saves the current sprite.
*/
void SaveSprite(const char *filename)
{
if (current_sprite == NULL) {
console_printf("SaveSprite: No current sprite\n");
return;
}
if (filename == NULL) {
console_printf("SaveSprite: filename can't be NULL\n");
return;
}
sprite_set_filename(current_sprite, filename);
rebuild_sprite_list();
if (sprite_save(current_sprite) == 0)
sprite_mark_as_saved(current_sprite);
else
console_printf("SaveSprite: Error saving sprite file %s\n", filename);
}
/**
* Sets the specified sprite as the current sprite to apply all next
* operations.
*/
void SetSprite(Sprite *sprite)
{
set_current_sprite(sprite);
}
/*===================================================================*/
/* Layer */
/*===================================================================*/
static int count_layers(Layer *layer);
static void undo_remove_stock_images(Layer *layer);
/**
* Creates a new layer with one cel in the current frame of the
* sprite.
*
* @param name Name of the layer (could be NULL)
* @param x Horizontal position of the first cel
* @param y Vertical position of the first cel
* @param w
* @param h
*
* with the specified position and size (if w=h=0 the
* routine will use the sprite dimension)
*/
Layer *NewLayer(const char *name, int x, int y, int w, int h)
Layer *NewLayer(void)
{
Sprite *sprite = current_sprite;
Layer *layer = NULL;
Layer *layer;
Image *image;
Cel *cel;
int index;
if (sprite && name) {
if (w == 0) w = sprite->w;
if (h == 0) h = sprite->h;
/* new image */
image = image_new(sprite->imgtype, w, h);
if (!image)
return NULL;
/* new layer */
layer = layer_new(sprite);
if (!layer) {
image_free(image);
return NULL;
}
/* clear with mask color */
image_clear(image, 0);
/* configure layer name and blend mode */
layer_set_name(layer, name);
layer_set_blend_mode(layer, BLEND_MODE_NORMAL);
/* add image in the layer stock */
index = stock_add_image(sprite->stock, image);
/* create a new cel in the current frame */
cel = cel_new(sprite->frame, index);
cel_set_position(cel, x, y);
/* add cel */
layer_add_cel(layer, cel);
/* undo stuff */
if (undo_is_enabled(sprite->undo)) {
undo_open(sprite->undo);
undo_add_layer(sprite->undo, sprite->set, layer);
undo_set_layer(sprite->undo, sprite);
undo_close(sprite->undo);
}
/* add the layer in the sprite set */
layer_add_layer(sprite->set, layer);
/* select the new layer */
sprite_set_layer(sprite, layer);
if (sprite == NULL) {
console_printf("NewLayer: No current sprite\n");
return NULL;
}
/* new image */
image = image_new(sprite->imgtype, sprite->w, sprite->h);
if (!image) {
console_printf("NewLayer: Not enough memory\n");
return NULL;
}
/* new layer */
layer = layer_new(sprite);
if (!layer) {
image_free(image);
console_printf("NewLayer: Not enough memory\n");
return NULL;
}
/* clear with mask color */
image_clear(image, 0);
/* configure layer name and blend mode */
/* TODO */
/* { */
/* char *name; */
/* name = GetUniqueLayerName(); */
/* layer_set_name(layer, name); */
/* jfree(name); */
/* } */
layer_set_blend_mode(layer, BLEND_MODE_NORMAL);
/* add image in the layer stock */
index = stock_add_image(sprite->stock, image);
/* create a new cel in the current frame */
cel = cel_new(sprite->frame, index);
/* add cel */
layer_add_cel(layer, cel);
/* undo stuff */
if (undo_is_enabled(sprite->undo)) {
undo_open(sprite->undo);
undo_add_layer(sprite->undo, sprite->set, layer);
undo_set_layer(sprite->undo, sprite);
undo_close(sprite->undo);
}
/* add the layer in the sprite set */
layer_add_layer(sprite->set, layer);
/* select the new layer */
sprite_set_layer(sprite, layer);
return layer;
}
/**
* Creates a new layer set with the "name" in the current sprite
*/
Layer *NewLayerSet(const char *name)
Layer *NewLayerSet(void)
{
Sprite *sprite = current_sprite;
Layer *layer = NULL;
if (sprite && name) {
/* new layer */
layer = layer_set_new(sprite);
if (!layer)
return NULL;
/* configure layer name and blend mode */
layer_set_name(layer, name);
/* add the layer in the sprite set */
layer_add_layer(sprite->set, layer);
/* select the new layer */
sprite_set_layer(sprite, layer);
if (sprite == NULL) {
console_printf("NewLayer: No current sprite\n");
return NULL;
}
/* new layer */
layer = layer_set_new(sprite);
if (!layer)
return NULL;
/* configure layer name and blend mode */
/* TODO */
/* { */
/* char *name; */
/* name = GetUniqueLayerName(); */
/* layer_set_name(layer, name); */
/* jfree(name); */
/* } */
/* add the layer in the sprite set */
layer_add_layer(sprite->set, layer);
/* select the new layer */
sprite_set_layer(sprite, layer);
return layer;
}
@ -236,6 +317,18 @@ void RemoveLayer(void)
}
}
char *GetUniqueLayerName(void)
{
Sprite *sprite = current_sprite;
if (sprite) {
char buf[1024];
sprintf(buf, "%s %d", _("Layer"), count_layers(sprite->set));
return jstrdup(buf);
}
else
return NULL;
}
Layer *FlattenLayers(void)
{
JLink link, next;
@ -293,6 +386,47 @@ Layer *FlattenLayers(void)
return flat_layer;
}
/* internal routine */
static int count_layers(Layer *layer)
{
int count;
if (layer->parent->type == GFXOBJ_SPRITE)
count = 0;
else
count = 1;
if (layer_is_set(layer)) {
JLink link;
JI_LIST_FOR_EACH(layer->layers, link) {
count += count_layers(link->data);
}
}
return count;
}
/* internal routine */
static void undo_remove_stock_images(Layer *layer)
{
JLink link;
if (layer_is_set(layer)) {
JI_LIST_FOR_EACH(layer->layers, link)
undo_remove_stock_images(link->data);
}
else if (layer_is_image(layer)) {
JI_LIST_FOR_EACH(layer->cels, link) {
Cel *cel = link->data;
if (!cel_is_link(cel, layer))
undo_remove_image(layer->sprite->undo,
layer->sprite->stock,
stock_get_image(layer->sprite->stock,
cel->image));
}
}
}
/* ======================================= */
/* Cel */
/* ======================================= */

View File

@ -23,20 +23,26 @@ struct Sprite;
struct Layer;
struct Cel;
/* ======================================= */
/* Sprite */
/* ======================================= */
/*===================================================================*/
/* Sprite */
/*===================================================================*/
/* ======================================= */
/* Layer */
/* ======================================= */
struct Sprite *NewSprite(int imgtype, int w, int h);
struct Sprite *LoadSprite(const char *filename);
void SaveSprite(const char *filename);
void SetSprite(struct Sprite *sprite);
/*===================================================================*/
/* Layer */
/*===================================================================*/
struct Layer *NewLayer(void);
struct Layer *NewLayerSet(void);
void RemoveLayer(void);
char *GetUniqueLayerName(void);
struct Layer *NewLayer(const char *name, int x, int y, int w, int h);
struct Layer *NewLayerSet(const char *name);
void RemoveLayer(void);
struct Layer *FlattenLayers(void);
/* ======================================= */

File diff suppressed because it is too large Load Diff

View File

@ -20,14 +20,19 @@
#ifndef USE_PRECOMPILED_HEADER
#include <assert.h>
#include <allegro.h>
#include "jinete/jlist.h"
#include "console/console.h"
#include "core/core.h"
#include "core/dirs.h"
#include "modules/editors.h"
#include "modules/sprites.h"
#include "modules/tools2.h"
#include "raster/sprite.h"
#include "raster/undo.h"
#include "script/bindings.h"
#include "script/script.h"
#include "widgets/editor.h"
@ -43,6 +48,8 @@ static lua_State *L;
static int running = 0;
static JList sprites_of_users = NULL;
static void prepare(void);
static void release(void);
@ -143,7 +150,7 @@ int do_script_expr(const char *exp)
{
int err = luaL_loadbuffer(L, exp, ustrlen(exp), exp);
prepare ();
prepare();
if (err == 0)
err = lua_pcall(L, 0, LUA_MULTRET, 0);
@ -210,9 +217,20 @@ int do_script_file(const char *filename)
static void prepare(void)
{
if (running == 0) {
JList all_sprites = get_sprite_list();
/* reset configuration of tools for the script */
ResetConfig();
/* open console */
console_open();
/* update variables */
update_global_script_variables();
/* make a copy of the list of sprites to known which sprites where
created with the script */
sprites_of_users = jlist_copy(all_sprites);
}
running++;
}
@ -225,9 +243,36 @@ static void release(void)
{
running--;
if (running == 0) {
JList all_sprites = get_sprite_list();
JLink link;
/* restore tools configuration for the user */
RestoreConfig();
/* close the console */
console_close();
/* set current sprite */
if (current_editor)
set_current_sprite(editor_get_sprite(current_editor));
/* check what sprites are new (to enable Undo support), to do this
we must to */
JI_LIST_FOR_EACH(all_sprites, link) {
Sprite *sprite = link->data;
/* if the sprite isn't in the old list of sprites ... */
if (!jlist_find(sprites_of_users, sprite)) {
/* ...the sprite was created by the script, so the undo is
disabled */
assert(undo_is_disabled(sprite->undo));
/* this is a sprite created in the script... see the functions
NewSprite or LoadSprite to known where the undo is
disabled */
undo_enable(sprite->undo);
}
}
jlist_free(sprites_of_users);
}
}

View File

@ -42,28 +42,28 @@ Mask *load_msk_file(const char *filename)
Mask *mask = NULL;
PACKFILE *f;
f = pack_fopen (filename, F_READ);
f = pack_fopen(filename, F_READ);
if (!f)
return NULL;
size = pack_igetl (f);
magic = pack_igetw (f);
size = pack_igetl(f);
magic = pack_igetw(f);
/* Animator Pro MSK format */
if ((size == orig_size) && (magic == 0x9500)) {
Image *image;
int x, y;
pack_fclose (f);
pack_fclose(f);
/* just load an Animator Pro PIC file */
image = load_pic_file (filename, &x, &y, NULL);
image = load_pic_file(filename, &x, &y, NULL);
if ((!image) || (image->imgtype != IMAGE_BITMAP)) {
if (image)
image_free (image);
image_free(image);
}
else {
mask = mask_new ();
mask = mask_new();
mask->x = x;
mask->y = y;
mask->w = image->w;
@ -73,14 +73,14 @@ Mask *load_msk_file(const char *filename)
}
/* Animator MSK format */
else if (orig_size == 8000) {
mask = mask_new ();
mask_replace (mask, 0, 0, 320, 200);
mask = mask_new();
mask_replace(mask, 0, 0, 320, 200);
u = v = 0;
for (i=0; i<8000; i++) {
byte = pack_getc (f);
for (c=0; c<8; c++) {
mask->bitmap->method->putpixel (mask->bitmap, u, v, byte & (1<<(7-c)));
mask->bitmap->method->putpixel(mask->bitmap, u, v, byte & (1<<(7-c)));
u++;
if (u == 320) {
u = 0;
@ -88,10 +88,10 @@ Mask *load_msk_file(const char *filename)
}
}
}
pack_fclose (f);
pack_fclose(f);
}
else {
pack_fclose (f);
pack_fclose(f);
}
return mask;