Added all mask/selection commands.

Added all commands to select a tool.
Fixed a bug when setting the grid.
The about dialog shows AUTHORS.txt
This commit is contained in:
David Capello 2007-09-30 15:32:21 +00:00
parent 5097767564
commit ce25bfaac4
71 changed files with 1350 additions and 1609 deletions

View File

@ -3,8 +3,7 @@ AUTHOR
===================================
David A. Capello <dacap@users.sourceforge.net>
Programmer, design, graphics, tester, and the maintainer of the package.
Releases the DOS, Windows, and source distributions.
Programmer, design, graphics, tester and the maintainer.
===================================
THANKFULNESS
@ -135,7 +134,7 @@ THANKFULNESS
Jorge Ramírez Flores
Juraj Michalek
Manuel De Miguel Moreno
Manuel Quiñones
Manuel Quiñones (manuq)
Mateusz Czaplinski
Nathan Smith (whitedoor)
Peter Wang (tjaden)

View File

@ -1,5 +1,69 @@
2007-09-30 David A. Capello <dacap@users.sourceforge.net>
* data/scripts/edit.lua: Removed.
* src/commands/cmd_refresh.c (command_execute_refresh): Added.
2007-09-29 David A. Capello <dacap@users.sourceforge.net>
* src/dialogs/toolconf.c (dialogs_tools_configuration):
Removed (now all the code is in cmd_configure_tools.c).
* src/commands/cmd_about.c (command_execute_about): Now it show
the AUTHORS.txt file.
* data/scripts/selspr.lua: Removed.
* data/scripts/rootmenu.lua: Removed.
* src/util/scrshot.c: Removed.
* src/commands/cmd_screen_shot.c (command_execute_screen_shot): Done.
* src/commands/cmd_clear.c (command_execute_clear): Done.
* data/scripts/mask.lua: Removed.
* src/commands/cmd_invert_mask.c (command_execute_invert_mask): Added.
* src/commands/cmd_reselect_mask.c (command_execute_reselect_mask): Added.
* src/commands/cmd_deselect_mask.c (command_execute_deselect_mask): Added.
* src/commands/cmd_mask_all.c (command_execute_mask_all): Added.
* src/commands/cmd_mask_by_color.c (command_execute_mask_by_color): Added.
* src/dialogs/toolconf.c (set_grid_button_select_hook): Fixed a
bug using an invalid rectangle for set_grid().
* src/commands/cmd_drawing_tools.c: Added all commands to select
each tool.
2007-09-28 David A. Capello <dacap@users.sourceforge.net>
* src/commands/cmd_load_mask.c (command_execute_load_mask): Added.
* src/commands/cmd_save_mask.c (command_execute_save_mask): Added.
* src/commands/cmd_copy.c (command_execute_copy): Added.
* src/commands/cmd_cut.c (command_execute_cut): Added.
* src/file/gif.c (save_GIF): Better progress bar.
* src/core/shutdown.c: Removed (it was only for sessions).
* src/util/session.c: Removed all session stuff.
* src/commands/cmd_save_file.c (command_execute_save_file): Added.
2007-09-27 David A. Capello <dacap@users.sourceforge.net>
* src/commands/cmd_undo.c (command_execute_undo): Added.
* src/commands/cmd_redo.c (command_execute_redo): Added.
* jinete/src/jsystem.c (jmouse_poll): Now (in Windows) we continue
getting mouse feedback even when the cursor is outside of the
window.

View File

@ -2,13 +2,17 @@
NEWS
===================================
0.9
0.6
---
+ Restructured all the menus (more user friendly options).
- Temporaly removed a lot of complex functionality:
Mask-Repository (but you can use .msk files yet), Draw-Text,
Play-FLI/FLC.
+ New XML format for the menus.
- Removed menu scripting customization.
- Removed screen saver.
- Removed sessions.
+ GUI enhanced:
+ more borders for windows and more spacing between widgets.
+ better mouse behavior (in Windows).

View File

@ -71,8 +71,6 @@ FEATURES
- Unique tiled drawing mode to draw patterns and textures in seconds.
- Save and load entire work's sessions (in `.ses' files).
- Scripting capabilities with Lua language (http://www.lua.org).

1
all.h
View File

@ -121,7 +121,6 @@
#include "util/quantize.h"
#include "util/recscr.h"
#include "util/scrshot.h"
#include "util/session.h"
#include "util/setgfx.h"
#include "util/thmbnail.h"
#include "widgets/colbar.h"

View File

@ -24,7 +24,7 @@
/* general information */
#define PACKAGE "ase"
#define VERSION "0.9"
#define VERSION "0.6"
#define WEBSITE "http://ase.sourceforge.net/"
#define BUGREPORT "ase-help@lists.sourceforge.net"
#define COPYRIGHT "Copyright (C) 2001-2005, 2007 David A. Capello"

View File

@ -59,6 +59,7 @@
<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" />
@ -85,10 +86,6 @@
<item command="screen_shot" name="Screen Shot" />
<item command="record_screen" name="Record Screen" />
</menu>
<menu name="Sessions">
<item command="load_session" name="Load Session" />
<item command="save_session" name="Save Session" />
</menu>
<separator />
<item command="about" name="About" />
<item command="exit" name="E&xit" />
@ -170,9 +167,8 @@
<separator />
<item command="mask_by_color" name="&Color Range" />
<separator />
<item command="mask_repository" name="Repositor&y" />
<item command="load_mask" name="&Load" />
<item command="save_mask" name="&Save" />
<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">
@ -186,10 +182,10 @@
<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 name=# "&Oval" command=# "oval_tool" /> -->
<!-- <item name=# "&Bezier" command=# "bezier_tool" /> -->
<!-- <item command="oval_tool" name="&Oval" /> -->
</menu>
<item command="film_editor" name="&Film Editor" />
<item command="palette_editor" name="&Palette Editor" />
@ -200,13 +196,14 @@
<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" />
<item command="run_script" name="Run &Script" />
<!-- <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="customize" name="&Customize" />
<item command="options" name="&Options" />
</menu>
<item id="sprite_list" name="L&ist" />

View File

@ -1,5 +1,5 @@
<!-- ase -- allegro-sprite-editor: the ultimate sprites factory -->
<!-- Copyright (C) 2001-2005 by David A. Capello -->
<!-- Copyright (C) 2001-2005, 2007 by David A. Capello -->
<!-- Read "LEGAL.txt" for more information. -->
@ -42,9 +42,6 @@
</box>
</box>
<separator horizontal />
<check text=_("Ask to load backed up sessions") name="askbkpses" />
<box horizontal homogeneous>
<button text=_("&OK") name="button_ok" magnetic />
<button text=_("&Save") name="button_save" />

View File

@ -1,14 +0,0 @@
-- ase -- allegro-sprite-editor: the ultimate sprites factory
-- Copyright (C) 2001-2005 by David A. Capello
function GUI_EditClear()
-- get current sprite
local sprite = current_sprite
if not sprite then return end
-- clear the mask
ClearMask()
-- refresh the sprite
GUI_Refresh(sprite)
end

View File

@ -1,229 +0,0 @@
-- ase -- allegro-sprite-editor: the ultimate sprites factory
-- Copyright (C) 2001-2005 by David A. Capello
function MaskAll()
local sprite = current_sprite
if not sprite then return end
-- undo
if undo_is_enabled(sprite.undo) then
undo_set_mask(sprite.undo, sprite)
end
-- change the selection
mask_replace(sprite.mask, 0, 0, sprite.w, sprite.h)
sprite_generate_mask_boundaries(sprite)
GUI_Refresh(sprite)
end
function DeselectMask()
local sprite = current_sprite
if not sprite or mask_is_empty(sprite.mask) then return end
-- destroy the *deselected* mask
local mask = sprite_request_mask(sprite, "*deselected*")
if mask then
sprite_remove_mask(sprite, mask)
mask_free(mask)
end
-- save the selection in the repository
local mask = mask_new_copy(sprite.mask)
mask_set_name(mask, "*deselected*")
sprite_add_mask(sprite, mask)
-- undo
if undo_is_enabled(sprite.undo) then
undo_set_mask(sprite.undo, sprite)
end
-- deselect the mask
mask_none(sprite.mask)
sprite_generate_mask_boundaries(sprite)
GUI_Refresh(sprite)
end
function ReselectMask()
local sprite = current_sprite
if not sprite then return end
-- request *deselected* mask
local mask = sprite_request_mask(sprite, "*deselected*")
if mask then
-- undo
if undo_is_enabled(sprite.undo) then
undo_set_mask(sprite.undo, sprite)
end
-- set the mask
sprite_set_mask(sprite, mask)
-- remove the *deselected* mask
sprite_remove_mask(sprite, mask)
mask_free(mask)
sprite_generate_mask_boundaries(sprite)
GUI_Refresh(sprite)
end
end
function InvertMask()
local sprite = current_sprite
if not sprite then return end
-- change the selection
if not sprite.mask.bitmap then
MaskAll()
else
-- undo
if undo_is_enabled(sprite.undo) then
undo_set_mask(sprite.undo, sprite)
end
-- create a new mask
local mask = mask_new()
-- select all the sprite area
mask_replace(mask, 0, 0, sprite.w, sprite.h)
-- remove in the new mask the current sprite marked region
image_rectfill(mask.bitmap,
sprite.mask.x, sprite.mask.y,
sprite.mask.x + sprite.mask.w-1,
sprite.mask.y + sprite.mask.h-1, 0)
-- invert the current mask in the sprite
mask_invert(sprite.mask)
if sprite.mask.bitmap then
-- copy the inverted region in the new mask
image_copy(mask.bitmap, sprite.mask.bitmap,
sprite.mask.x, sprite.mask.y)
end
-- we need only need the area inside the sprite
mask_intersect(mask, 0, 0, sprite.w, sprite.h)
-- set the new mask
sprite_set_mask(sprite, mask)
mask_free(mask)
sprite_generate_mask_boundaries(sprite)
GUI_Refresh(sprite)
end
end
function StretchMaskBottom()
local sprite = current_sprite
if not sprite or not sprite.mask.bitmap then return end
-- undo
if undo_is_enabled(sprite.undo) then
undo_set_mask(sprite.undo, sprite)
end
local x, y, bitmap, modified
bitmap = sprite.mask.bitmap
for y = 0, bitmap.h-2 do
modified = false
for x = 0, bitmap.w-1 do
if image_getpixel(bitmap, x, y) == 1 and
image_getpixel(bitmap, x, y+1) == 0 then
image_putpixel(bitmap, x, y+1, 1)
modified = true
end
end
if modified then
y = y+1
end
end
mask_union(sprite.mask,
sprite.mask.x, sprite.mask.y+sprite.mask.h, sprite.mask.w, 1)
bitmap = sprite.mask.bitmap -- the bitmap could change in the union operation
y = bitmap.h-2
for x = 0, bitmap.w-1 do
if image_getpixel(bitmap, x, y) == 0 then
image_putpixel(bitmap, x, y+1, 0)
end
end
sprite_generate_mask_boundaries(sprite)
GUI_Refresh(sprite)
end
function GUI_LoadMask()
-- get current sprite
local sprite = current_sprite
if not sprite then
return
end
local filename = ji_file_select(_("Load .msk File"), "", "msk")
if filename then
local mask = load_msk_file(filename)
if not mask then
jalert(_("Error<<Error loading .msk file").."<<"
..filename.."||".._("&Close"))
return
end
-- undo
if undo_is_enabled(sprite.undo) then
undo_set_mask(sprite.undo, sprite)
end
sprite_set_mask(sprite, mask)
mask_free(mask)
sprite_generate_mask_boundaries(sprite)
GUI_Refresh(sprite)
end
end
function GUI_SaveMask()
-- get current sprite
local sprite = current_sprite
if not sprite then
return
end
local filename = "default.msk"
local ret
while true do
filename = ji_file_select(_("Save .msk File"), filename, "msk")
if not filename then
return
end
-- does the file exist?
if file_exists(filename) then
-- ask if the user wants overwrite the file?
ret = jalert(_("Warning").."<<".._("File exists, overwrite it?")
.."<<"..get_filename(filename)
.."||".._("&Yes||&No||&Cancel"))
else
break
end
-- "yes": we must continue with the operation...
if ret == 1 then
break
-- "cancel" or <esc> per example: we back doing nothing
elseif ret != 2 then
return
end
-- "no": we must back to select other file-name */
end
if save_msk_file(sprite.mask, filename) != 0 then
jalert("Error<<Error saving .msk file<<"..filename.."||&Close")
end
end

View File

@ -1,9 +0,0 @@
-- ase -- allegro-sprite-editor: the ultimate sprites factory
-- Copyright (C) 2001-2005, 2007 by David A. Capello
function rebuild_root_menu_with_alert()
if jalert(_("Warning<<If you try to reload the root-menu<<you will lost the current one.<<Do you want continue?||&Load||&Cancel"))
== 1 then
rebuild_root_menu()
end
end

View File

@ -1,29 +0,0 @@
-- ase -- allegro-sprite-editor: the ultimate sprites factory
-- Copyright (C) 2001-2005 by David A. Capello
-- shows a sprite by its ID
function ShowSpriteByID(sprite_id)
local sprite = nil
-- is not the null sprite?
if sprite_id != 0 then
local clipboard = get_clipboard_sprite()
-- the clipboard?
if clipboard and sprite_id == clipboard.id then
sprite = clipboard
-- some sprite in the list?
else
sprite = get_first_sprite()
while sprite do
if sprite.id == sprite_id then
break
end
sprite = get_next_sprite(sprite)
end
end
end
set_sprite_in_current_editor(sprite)
end

View File

@ -687,7 +687,9 @@ Sprite
@@bool @sprite_is_modified (Sprite *sprite);
@@void @sprite_was_saved (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);

View File

@ -417,7 +417,7 @@ static void update_mouse_position(void)
#ifdef ALLEGRO_WINDOWS
/* this help us (in windows) to get mouse feedback when we capture
the mouse but we are outside the Allegro window */
{
if (is_windowed_mode()) {
POINT pt;
RECT rc;

View File

@ -1184,9 +1184,9 @@ static void theme_draw_slider (JWidget widget)
#endif
}
static void theme_draw_textbox (JWidget widget)
static void theme_draw_textbox(JWidget widget)
{
_ji_theme_textbox_draw (ji_screen, widget, NULL, NULL);
_ji_theme_textbox_draw(ji_screen, widget, NULL, NULL);
}
static void theme_draw_view(JWidget widget)

View File

@ -1,4 +1,4 @@
# Copyright (C) 2001-2005 by David A. Capello -*-Makefile-*-
# Copyright (C) 2001-2005, 2007 by David A. Capello -*-Makefile-*-
ifndef CONFIGURED
include makefile.cfg
@ -49,6 +49,7 @@ distclean: clean
install:
cp ase $(DEFAULT_PREFIX)/bin
cp -r data $(DEFAULT_PREFIX)/share/ase
cp AUTHORS.txt $(DEFAULT_PREFIX)/share/ase
uninstall:
-rm -vf $(DEFAULT_PREFIX)/bin/ase

View File

@ -21,7 +21,6 @@ ASE_SOURCES = \
src/commands/cmd_crop_frame.c \
src/commands/cmd_crop_layer.c \
src/commands/cmd_crop_sprite.c \
src/commands/cmd_customize.c \
src/commands/cmd_cut.c \
src/commands/cmd_deselect_mask.c \
src/commands/cmd_despeckle.c \
@ -41,11 +40,9 @@ ASE_SOURCES = \
src/commands/cmd_layer_properties.c \
src/commands/cmd_link_frame.c \
src/commands/cmd_load_mask.c \
src/commands/cmd_load_session.c \
src/commands/cmd_mapgen.c \
src/commands/cmd_mask_all.c \
src/commands/cmd_mask_by_color.c \
src/commands/cmd_mask_repository.c \
src/commands/cmd_merge_down_layer.c \
src/commands/cmd_move_frame.c \
src/commands/cmd_new_file.c \
@ -71,7 +68,6 @@ ASE_SOURCES = \
src/commands/cmd_save_file.c \
src/commands/cmd_save_file_as.c \
src/commands/cmd_save_mask.c \
src/commands/cmd_save_session.c \
src/commands/cmd_screen_shot.c \
src/commands/cmd_select_file.c \
src/commands/cmd_sprite_properties.c \
@ -85,7 +81,6 @@ ASE_SOURCES = \
src/core/core.c \
src/core/dirs.c \
src/core/modules.c \
src/core/shutdown.c \
src/dialogs/canvasze.c \
src/dialogs/colsel.c \
src/dialogs/dfrlen.c \
@ -101,7 +96,6 @@ ASE_SOURCES = \
src/dialogs/filmedit.c \
src/dialogs/gfxsel.c \
src/dialogs/maskcol.c \
src/dialogs/maskrepo.c \
src/dialogs/minipal.c \
src/dialogs/options.c \
src/dialogs/playfli.c \
@ -109,7 +103,6 @@ ASE_SOURCES = \
src/dialogs/repo.c \
src/dialogs/scrsaver.c \
src/dialogs/tips.c \
src/dialogs/toolconf.c \
src/dialogs/vectmap.c \
src/effect/colcurve.c \
src/effect/convmatr.c \
@ -176,8 +169,6 @@ ASE_SOURCES = \
src/util/pic_file.c \
src/util/quantize.c \
src/util/recscr.c \
src/util/scrshot.c \
src/util/session.c \
src/util/setgfx.c \
src/util/thmbnail.c \
src/widgets/colbar.c \

View File

@ -15,7 +15,8 @@ endif
# Flags for MinGW
CFLAGS =
LFLAGS = -mwindows
# LFLAGS = -mwindows
LFLAGS = -mconsole
ifdef DEBUGMODE
LFLAGS_LAST = -lalld
else

View File

@ -1,7 +1,7 @@
#! /bin/sh
dir="`pwd`"
version=0.9
version=0.6
distdir=ase-$version
freetype_files="jinete/freetype/ChangeLog \
@ -110,7 +110,6 @@ ase_files="all.h \
data/po/*.po \
data/scripts/*.lua \
data/scripts/examples/*.lua \
data/session/*.txt \
data/tips/*.pcx \
data/tips/tips.en \
data/tips/tips.es \
@ -190,7 +189,6 @@ $1/data/menus.es \
$1/data/po/es.po \
$1/data/scripts/*.lua \
$1/data/scripts/examples/*.lua \
$1/data/session/*.txt \
$1/data/tips/*.en \
$1/data/tips/*.es \
$1/docs/*.html \

View File

@ -20,32 +20,112 @@
#ifndef USE_PRECOMPILED_HEADER
#include <allegro.h>
#include "jinete.h"
#include "core/core.h"
#include "core/dirs.h"
#endif
static char *read_authors_txt(const char *filename);
void command_execute_about(const char *argument)
{
JWidget window, box1, label1, label2, label3, label4;
JWidget separator1, button1;
JWidget window, box1, label1, label2, separator1;
JWidget textbox, view, separator2;
JWidget label3, label4, box2, box3, box4, button1;
char *authors_txt = read_authors_txt("AUTHORS.txt");
if (authors_txt)
window = jwindow_new_desktop();
else
window = jwindow_new(_("About ASE"));
window = jwindow_new(_("About ASE"));
box1 = jbox_new(JI_VERTICAL);
label1 = jlabel_new("Allegro Sprite Editor - " VERSION);
label2 = jlabel_new(_("The Ultimate Sprites Factory"));
separator1 = ji_separator_new(NULL, JI_HORIZONTAL);
if (authors_txt) {
view = jview_new();
textbox = jtextbox_new(authors_txt, JI_LEFT);
separator2 = ji_separator_new(NULL, JI_HORIZONTAL);
jfree(authors_txt);
}
else {
view = textbox = NULL;
}
label3 = jlabel_new(COPYRIGHT);
label4 = jlabel_new("http://ase.sourceforge.net/");
box2 = jbox_new(JI_HORIZONTAL);
box3 = jbox_new(JI_HORIZONTAL);
box4 = jbox_new(JI_HORIZONTAL);
button1 = jbutton_new(_("&Close"));
jwidget_magnetic(button1, TRUE);
jwidget_add_childs(box1, label1, label2, separator1, label3, label4,
button1, NULL);
jwidget_add_childs(box1, label1, label2, separator1, NULL);
if (textbox) {
jview_attach(view, textbox);
jwidget_expansive(view, TRUE);
jwidget_set_static_size(view, JI_SCREEN_W/3, JI_SCREEN_H/4);
jwidget_add_childs(box1, view, separator2, NULL);
}
jwidget_expansive(box3, TRUE);
jwidget_expansive(box4, TRUE);
jwidget_add_childs(box2, box3, button1, box4, NULL);
jwidget_add_childs(box1, label3, label4, NULL);
jwidget_add_child(box1, box2);
jwidget_add_child(window, box1);
jwidget_set_border(button1,
button1->border_width.l+16,
button1->border_width.t,
button1->border_width.r+16,
button1->border_width.b);
jwindow_open_fg(window);
jwidget_free(window);
}
static char *read_authors_txt(const char *filename)
{
DIRS *dirs, *dir;
char *txt = NULL;
dirs = filename_in_bindir(filename);
dirs_cat_dirs(dirs, filename_in_datadir(filename));
/* search the configuration file from first to last path */
for (dir=dirs; dir && !txt; dir=dir->next) {
PRINTF("Triying opening %s\n", dir->path);
if ((dir->path) && exists(dir->path)) {
int size;
FILE *f;
#if (MAKE_VERSION(4, 2, 0) < MAKE_VERSION(ALLEGRO_VERSION, \
ALLEGRO_SUB_VERSION, \
ALLEGRO_WIP_VERSION))
size = file_size(dir->path);
#else
size = file_size_ex(dir->path);
#endif
if (size > 0) {
f = fopen(dir->path, "r");
if (f) {
txt = jmalloc0(size+2);
fread(txt, 1, size, f);
fclose(f);
}
}
}
}
dirs_free(dirs);
return txt;
}

View File

@ -20,14 +20,26 @@
#ifndef USE_PRECOMPILED_HEADER
#include "jinete.h"
#include "core/app.h"
#include "modules/gui.h"
#include "modules/sprites.h"
#include "raster/sprite.h"
#include "util/misc.h"
#endif
bool command_enabled_clear(const char *argument)
{
return current_sprite != NULL;
}
void command_execute_clear(const char *argument)
{
/* get current sprite */
Sprite *sprite = current_sprite;
/* clear the mask */
ClearMask();
/* refresh the sprite */
GUI_Refresh(sprite);
}

View File

@ -1,55 +0,0 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 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 "jinete.h"
#include "core/app.h"
#include "modules/sprites.h"
#include "raster/sprite.h"
#endif
bool command_enabled_close_all_file(const char *argument)
{
return !jlist_empty(get_sprite_list());
}
void command_execute_close_all_files(const char *argument)
{
Sprite *sprite = get_first_sprite();
Sprite *clipboard = get_clipboard_sprite();
while (sprite) {
sprite = current_sprite;
/* check if this sprite is modified */
if (sprite_is_modified(sprite) &&
(!clipboard || sprite->gfxobj.id != clipboard->gfxobj.id)) {
command_execute_close_file();
break;
}
sprite = get_next_sprite(sprite);
}
/* close the window */
jwindow_close(app_get_top_window(), 0);
}

View File

@ -20,14 +20,311 @@
#ifndef USE_PRECOMPILED_HEADER
#include <allegro.h>
#include "jinete.h"
#include "core/app.h"
#include "modules/editors.h"
#include "modules/gfx.h"
#include "modules/gui.h"
#include "modules/rootmenu.h"
#include "modules/sprites.h"
#include "modules/tools.h"
#include "raster/brush.h"
#include "raster/image.h"
#include "raster/mask.h"
#include "raster/sprite.h"
#include "widgets/colbut.h"
#include "widgets/editor.h"
#include "widgets/groupbut.h"
#include "widgets/statebar.h"
#endif
static JWidget window = NULL;
static bool brush_preview_msg_proc(JWidget widget, JMessage msg);
static int window_close_hook(JWidget widget, int user_data);
static int brush_size_slider_change_hook(JWidget widget, int user_data);
static int brush_angle_slider_change_hook(JWidget widget, int user_data);
static int brush_type_change_hook(JWidget widget, int user_data);
static int brush_mode_change_hook(JWidget widget, int user_data);
static int glass_dirty_slider_change_hook(JWidget widget, int user_data);
static int spray_width_slider_change_hook(JWidget widget, int user_data);
static int air_speed_slider_change_hook(JWidget widget, int user_data);
static int filled_check_change_hook(JWidget widget, int user_data);
static int tiled_check_change_hook(JWidget widget, int user_data);
static int use_grid_check_change_hook(JWidget widget, int user_data);
static int view_grid_check_change_hook(JWidget widget, int user_data);
static int set_grid_button_select_hook(JWidget widget, int user_data);
static int cursor_button_change_hook(JWidget widget, int user_data);
static int onionskin_check_change_hook(JWidget widget, int user_data);
void command_execute_configure_tools(const char *argument)
{
JWidget filled, tiled, use_grid, view_grid, set_grid;
JWidget brush_size, brush_angle, glass_dirty;
JWidget spray_width, air_speed;
JWidget cursor_color, cursor_color_box;
JWidget brush_preview_box;
JWidget brush_type_box, brush_type;
JWidget brush_mode_box, brush_mode;
JWidget check_onionskin;
JWidget brush_preview;
/* if the window is opened, close it */
if (window) {
jwindow_close (window, NULL);
return;
}
/* if the window is closed, open it */
window = load_widget ("toolconf.jid", "configure_tool");
if (!window)
return;
if (!get_widgets (window,
"filled", &filled,
"tiled", &tiled,
"use_grid", &use_grid,
"view_grid", &view_grid,
"set_grid", &set_grid,
"brush_size", &brush_size,
"brush_angle", &brush_angle,
"glass_dirty", &glass_dirty,
"spray_width", &spray_width,
"air_speed", &air_speed,
"cursor_color_box", &cursor_color_box,
"brush_preview_box", &brush_preview_box,
"brush_type_box", &brush_type_box,
"brush_mode_box", &brush_mode_box,
"onionskin", &check_onionskin, NULL)) {
jwidget_free (window);
return;
}
/* cursor-color */
cursor_color = color_button_new (get_cursor_color (), IMAGE_INDEXED);
/* brush-preview */
brush_preview = jwidget_new (JI_WIDGET);
brush_preview->static_w = 32 + 4;
brush_preview->static_h = 32 + 4;
jwidget_add_hook (brush_preview, JI_WIDGET,
brush_preview_msg_proc, NULL);
/* brush-type */
brush_type = group_button_new (3, 1, get_brush_type (),
GFX_BRUSH_CIRCLE,
GFX_BRUSH_SQUARE,
GFX_BRUSH_LINE);
/* brush-type */
brush_mode = group_button_new (3, 1, get_brush_mode (),
GFX_DRAWMODE_OPAQUE,
GFX_DRAWMODE_GLASS,
GFX_DRAWMODE_SEMI);
/* append children */
jwidget_add_child (cursor_color_box, cursor_color);
jwidget_add_child (brush_preview_box, brush_preview);
jwidget_add_child (brush_type_box, brush_type);
jwidget_add_child (brush_mode_box, brush_mode);
if (get_filled_mode ()) jwidget_select (filled);
if (get_tiled_mode ()) jwidget_select (tiled);
if (get_use_grid ()) jwidget_select (use_grid);
if (get_view_grid ()) jwidget_select (view_grid);
jslider_set_value (brush_size, get_brush_size ());
jslider_set_value (brush_angle, get_brush_angle ());
jslider_set_value (glass_dirty, get_glass_dirty ());
jslider_set_value (spray_width, get_spray_width ());
jslider_set_value (air_speed, get_air_speed ());
if (get_onionskin ()) jwidget_select (check_onionskin);
HOOK (window, JI_SIGNAL_WINDOW_CLOSE, window_close_hook, 0);
HOOK (filled, JI_SIGNAL_CHECK_CHANGE, filled_check_change_hook, 0);
HOOK (tiled, JI_SIGNAL_CHECK_CHANGE, tiled_check_change_hook, 0);
HOOK (use_grid, JI_SIGNAL_CHECK_CHANGE, use_grid_check_change_hook, 0);
HOOK (view_grid, JI_SIGNAL_CHECK_CHANGE, view_grid_check_change_hook, 0);
HOOK (set_grid, JI_SIGNAL_BUTTON_SELECT, set_grid_button_select_hook, 0);
HOOK (brush_size, JI_SIGNAL_SLIDER_CHANGE, brush_size_slider_change_hook, brush_preview);
HOOK (brush_angle, JI_SIGNAL_SLIDER_CHANGE, brush_angle_slider_change_hook, brush_preview);
HOOK (brush_type, SIGNAL_GROUP_BUTTON_CHANGE, brush_type_change_hook, brush_preview);
HOOK (brush_mode, SIGNAL_GROUP_BUTTON_CHANGE, brush_mode_change_hook, 0);
HOOK (glass_dirty, JI_SIGNAL_SLIDER_CHANGE, glass_dirty_slider_change_hook, 0);
HOOK (air_speed, JI_SIGNAL_SLIDER_CHANGE, air_speed_slider_change_hook, 0);
HOOK (spray_width, JI_SIGNAL_SLIDER_CHANGE, spray_width_slider_change_hook, 0);
HOOK (cursor_color, SIGNAL_COLOR_BUTTON_CHANGE, cursor_button_change_hook, 0);
HOOK (check_onionskin, JI_SIGNAL_CHECK_CHANGE, onionskin_check_change_hook, 0);
/* default position */
jwindow_remap (window);
jwindow_center (window);
/* load window configuration */
load_window_pos (window, "ConfigureTool");
/* open the window */
jwindow_open_bg (window);
}
static bool brush_preview_msg_proc(JWidget widget, JMessage msg)
{
switch (msg->type) {
case JM_DRAW: {
BITMAP *bmp = create_bitmap(jrect_w(widget->rc),
jrect_h(widget->rc));
Brush *brush = get_brush();
clear_to_color(bmp, makecol(0, 0, 0));
image_to_allegro(brush->image, bmp,
bmp->w/2 - brush->size/2,
bmp->h/2 - brush->size/2);
blit(bmp, ji_screen, 0, 0, widget->rc->x1, widget->rc->y1,
bmp->w, bmp->h);
destroy_bitmap(bmp);
return TRUE;
}
}
return FALSE;
}
static int window_close_hook(JWidget widget, int user_data)
{
/* isn't running anymore */
window = NULL;
/* save window configuration */
save_window_pos(widget, "ConfigureTool");
return FALSE;
}
static int brush_size_slider_change_hook(JWidget widget, int user_data)
{
set_brush_size(jslider_get_value(widget));
jwidget_dirty((JWidget)user_data);
return FALSE;
}
static int brush_angle_slider_change_hook(JWidget widget, int user_data)
{
set_brush_angle(jslider_get_value(widget));
jwidget_dirty((JWidget)user_data);
return FALSE;
}
static int brush_type_change_hook(JWidget widget, int user_data)
{
int type = group_button_get_selected(widget);
set_brush_type(type);
jwidget_dirty((JWidget)user_data);
status_bar_set_text(app_get_status_bar(), 250,
"Brush type: %s",
type == BRUSH_CIRCLE ? "Circle":
type == BRUSH_SQUARE ? "Square":
type == BRUSH_LINE ? "Line": "Unknown");
return TRUE;
}
static int brush_mode_change_hook(JWidget widget, int user_data)
{
int mode = group_button_get_selected(widget);
set_brush_mode(mode);
status_bar_set_text(app_get_status_bar(), 250,
"Brush mode: %s",
mode == DRAWMODE_OPAQUE ? "Opaque":
mode == DRAWMODE_GLASS ? "Glass":
mode == DRAWMODE_SEMI ? "Semi": "Unknown");
return TRUE;
}
static int glass_dirty_slider_change_hook(JWidget widget, int user_data)
{
set_glass_dirty(jslider_get_value(widget));
return FALSE;
}
static int spray_width_slider_change_hook(JWidget widget, int user_data)
{
set_spray_width(jslider_get_value(widget));
return FALSE;
}
static int air_speed_slider_change_hook(JWidget widget, int user_data)
{
set_air_speed(jslider_get_value(widget));
return FALSE;
}
static int filled_check_change_hook(JWidget widget, int user_data)
{
set_filled_mode(jwidget_is_selected(widget));
return FALSE;
}
static int tiled_check_change_hook(JWidget widget, int user_data)
{
set_tiled_mode(jwidget_is_selected(widget));
return FALSE;
}
static int use_grid_check_change_hook(JWidget widget, int user_data)
{
set_use_grid(jwidget_is_selected(widget));
return FALSE;
}
static int view_grid_check_change_hook(JWidget widget, int user_data)
{
set_view_grid(jwidget_is_selected(widget));
refresh_all_editors();
return FALSE;
}
static int set_grid_button_select_hook(JWidget widget, int user_data)
{
Sprite *sprite = current_sprite;
if (sprite && sprite->mask && sprite->mask->bitmap) {
JRect rect = jrect_new(sprite->mask->x,
sprite->mask->y,
sprite->mask->x+sprite->mask->w,
sprite->mask->y+sprite->mask->h);
set_grid(rect);
jrect_free(rect);
if (get_view_grid())
refresh_all_editors();
}
else {
jalert(_("Error"
"<<You must select a sprite with mask."
"<<The boundaries of the mask will be used"
"<<to specify the grid area.||&OK"));
}
return TRUE;
}
static int cursor_button_change_hook(JWidget widget, int user_data)
{
set_cursor_color(color_button_get_color(widget));
return TRUE;
}
static int onionskin_check_change_hook(JWidget widget, int user_data)
{
set_onionskin(jwidget_is_selected(widget));
refresh_all_editors();
return FALSE;
}

View File

@ -20,14 +20,31 @@
#ifndef USE_PRECOMPILED_HEADER
#include "jinete.h"
#include "jinete/base.h"
#include "core/app.h"
#include "modules/sprites.h"
#include "raster/layer.h"
#include "raster/mask.h"
#include "raster/sprite.h"
#include "util/clipbrd.h"
#include "util/misc.h"
#endif
bool command_enabled_copy(const char *argument)
{
if ((!current_sprite) ||
(!current_sprite->layer) ||
(!current_sprite->layer->readable) ||
(!current_sprite->layer->writeable) ||
(!current_sprite->mask) ||
(!current_sprite->mask->bitmap))
return FALSE;
else
return GetImage() ? TRUE: FALSE;
}
void command_execute_copy(const char *argument)
{
copy_to_clipboard();
}

View File

@ -1,34 +0,0 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 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 "jinete.h"
#include "core/app.h"
#include "modules/sprites.h"
#include "raster/sprite.h"
#endif
void command_execute_customize(const char *argument)
{
jalert("Customize<<This functionality will be available in ASE 1.0||&OK");
}

View File

@ -20,14 +20,31 @@
#ifndef USE_PRECOMPILED_HEADER
#include "jinete.h"
#include "jinete/base.h"
#include "core/app.h"
#include "modules/sprites.h"
#include "raster/layer.h"
#include "raster/mask.h"
#include "raster/sprite.h"
#include "util/clipbrd.h"
#include "util/misc.h"
#endif
bool command_enabled_cut(const char *argument)
{
if ((!current_sprite) ||
(!current_sprite->layer) ||
(!current_sprite->layer->readable) ||
(!current_sprite->layer->writeable) ||
(!current_sprite->mask) ||
(!current_sprite->mask->bitmap))
return FALSE;
else
return GetImage() ? TRUE: FALSE;
}
void command_execute_cut(const char *argument)
{
cut_to_clipboard();
}

View File

@ -20,14 +20,45 @@
#ifndef USE_PRECOMPILED_HEADER
#include "jinete.h"
#include "core/app.h"
#include "modules/gui.h"
#include "modules/sprites.h"
#include "raster/mask.h"
#include "raster/sprite.h"
#include "raster/undo.h"
#endif
bool command_enabled_deselect_mask(const char *argument)
{
return
current_sprite != NULL &&
!mask_is_empty(current_sprite->mask);
}
void command_execute_deselect_mask(const char *argument)
{
Sprite *sprite = current_sprite;
Mask *mask;
/* destroy the *deselected* mask */
mask = sprite_request_mask(sprite, "*deselected*");
if (mask) {
sprite_remove_mask(sprite, mask);
mask_free(mask);
}
/* save the selection in the repository */
mask = mask_new_copy(sprite->mask);
mask_set_name(mask, "*deselected*");
sprite_add_mask(sprite, mask);
/* undo */
if (undo_is_enabled(sprite->undo))
undo_set_mask(sprite->undo, sprite);
/* deselect the mask */
mask_none(sprite->mask);
sprite_generate_mask_boundaries(sprite);
GUI_Refresh(sprite);
}

View File

@ -20,11 +20,11 @@
#ifndef USE_PRECOMPILED_HEADER
#include "jinete.h"
#include <allegro/unicode.h>
#include "core/app.h"
#include "modules/sprites.h"
#include "raster/sprite.h"
#include "jinete/base.h"
#include "modules/tools.h"
#endif
@ -32,70 +32,124 @@
/* brush_tool */
/* ======================== */
bool command_checked_brush_tool(const char *argument)
{
return current_tool && current_tool == &ase_tool_brush;
}
void command_execute_brush_tool(const char *argument)
{
select_tool(&ase_tool_brush);
}
/* ======================== */
/* dots_tool */
/* ======================== */
bool command_checked_dots_tool(const char *argument)
{
return current_tool && current_tool == &ase_tool_dots;
}
void command_execute_dots_tool(const char *argument)
{
select_tool(&ase_tool_dots);
}
/* ======================== */
/* ellipse_tool */
/* ======================== */
bool command_checked_ellipse_tool(const char *argument)
{
return current_tool && current_tool == &ase_tool_ellipse;
}
void command_execute_ellipse_tool(const char *argument)
{
select_tool(&ase_tool_ellipse);
}
/* ======================== */
/* floodfill_tool */
/* ======================== */
bool command_checked_floodfill_tool(const char *argument)
{
return current_tool && current_tool == &ase_tool_floodfill;
}
void command_execute_floodfill_tool(const char *argument)
{
select_tool(&ase_tool_floodfill);
}
/* ======================== */
/* line_tool */
/* ======================== */
bool command_checked_line_tool(const char *argument)
{
return current_tool && current_tool == &ase_tool_line;
}
void command_execute_line_tool(const char *argument)
{
select_tool(&ase_tool_line);
}
/* ======================== */
/* marker_tool */
/* ======================== */
bool command_checked_marker_tool(const char *argument)
{
return current_tool && current_tool == &ase_tool_marker;
}
void command_execute_marker_tool(const char *argument)
{
select_tool(&ase_tool_marker);
}
/* ======================== */
/* pencil_tool */
/* ======================== */
bool command_checked_pencil_tool(const char *argument)
{
return current_tool && current_tool == &ase_tool_pencil;
}
void command_execute_pencil_tool(const char *argument)
{
select_tool(&ase_tool_pencil);
}
/* ======================== */
/* rectangle_tool */
/* ======================== */
bool command_checked_rectangle_tool(const char *argument)
{
return current_tool && current_tool == &ase_tool_rectangle;
}
void command_execute_rectangle_tool(const char *argument)
{
select_tool(&ase_tool_rectangle);
}
/* ======================== */
/* spray_tool */
/* ======================== */
bool command_checked_spray_tool(const char *argument)
{
return current_tool && current_tool == &ase_tool_spray;
}
void command_execute_spray_tool(const char *argument)
{
select_tool(&ase_tool_spray);
}

View File

@ -20,14 +20,63 @@
#ifndef USE_PRECOMPILED_HEADER
#include "jinete.h"
#include "core/app.h"
#include "commands/commands.h"
#include "modules/gui.h"
#include "modules/sprites.h"
#include "raster/image.h"
#include "raster/mask.h"
#include "raster/sprite.h"
#include "raster/undo.h"
#endif
bool command_enabled_invert_mask(const char *argument)
{
return current_sprite != NULL;
}
void command_execute_invert_mask(const char *argument)
{
Sprite *sprite = current_sprite;
Mask *mask;
/* change the selection */
if (!sprite->mask->bitmap) {
command_execute(command_get_by_name(CMD_MASK_ALL), argument);
}
else {
/* undo */
if (undo_is_enabled(sprite->undo))
undo_set_mask(sprite->undo, sprite);
/* create a new mask */
mask = mask_new();
/* select all the sprite area */
mask_replace(mask, 0, 0, sprite->w, sprite->h);
/* remove in the new mask the current sprite marked region */
image_rectfill(mask->bitmap,
sprite->mask->x, sprite->mask->y,
sprite->mask->x + sprite->mask->w-1,
sprite->mask->y + sprite->mask->h-1, 0);
/* invert the current mask in the sprite */
mask_invert(sprite->mask);
if (sprite->mask->bitmap) {
/* copy the inverted region in the new mask */
image_copy(mask->bitmap, sprite->mask->bitmap,
sprite->mask->x, sprite->mask->y);
}
/* we need only need the area inside the sprite */
mask_intersect(mask, 0, 0, sprite->w, sprite->h);
/* set the new mask */
sprite_set_mask(sprite, mask);
mask_free(mask);
sprite_generate_mask_boundaries(sprite);
GUI_Refresh(sprite);
}
}

View File

@ -20,14 +20,48 @@
#ifndef USE_PRECOMPILED_HEADER
#include "jinete.h"
#include "jinete/alert.h"
#include "core/app.h"
#include "dialogs/filesel.h"
#include "modules/gui.h"
#include "modules/sprites.h"
#include "raster/mask.h"
#include "raster/sprite.h"
#include "raster/undo.h"
#include "util/msk_file.h"
#endif
bool command_enabled_load_mask(const char *argument)
{
return current_sprite != NULL;
}
void command_execute_load_mask(const char *argument)
{
/* get current sprite */
Sprite *sprite = current_sprite;
char *filename = GUI_FileSelect(_("Load .msk File"), "", "msk");
if (filename) {
Mask *mask = load_msk_file(filename);
if (!mask) {
jalert("%s<<%s<<%s||%s",
_("Error"), _("Error loading .msk file"),
filename, _("&Close"));
jfree(filename);
return;
}
/* undo */
if (undo_is_enabled(sprite->undo))
undo_set_mask(sprite->undo, sprite);
sprite_set_mask(sprite, mask);
mask_free(mask);
sprite_generate_mask_boundaries(sprite);
GUI_Refresh(sprite);
jfree(filename);
}
}

View File

@ -20,14 +20,30 @@
#ifndef USE_PRECOMPILED_HEADER
#include "jinete.h"
#include "core/app.h"
#include "modules/gui.h"
#include "modules/sprites.h"
#include "raster/mask.h"
#include "raster/sprite.h"
#include "raster/undo.h"
#endif
bool command_enabled_mask_all(const char *argument)
{
return current_sprite != NULL;
}
void command_execute_mask_all(const char *argument)
{
Sprite *sprite = current_sprite;
/* undo */
if (undo_is_enabled(sprite->undo))
undo_set_mask(sprite->undo, sprite);
/* change the selection */
mask_replace(sprite->mask, 0, 0, sprite->w, sprite->h);
sprite_generate_mask_boundaries(sprite);
GUI_Refresh(sprite);
}

View File

@ -20,14 +20,19 @@
#ifndef USE_PRECOMPILED_HEADER
#include "jinete.h"
#include "jinete/base.h"
#include "core/app.h"
#include "dialogs/maskcol.h"
#include "modules/sprites.h"
#include "raster/sprite.h"
#endif
bool command_enabled_mask_by_color(const char *argument)
{
return current_sprite != NULL;
}
void command_execute_mask_by_color(const char *argument)
{
dialogs_mask_color();
}

View File

@ -1,33 +0,0 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 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 "jinete.h"
#include "core/app.h"
#include "modules/sprites.h"
#include "raster/sprite.h"
#endif
void command_execute_mask_repository(const char *argument)
{
}

View File

@ -20,14 +20,21 @@
#ifndef USE_PRECOMPILED_HEADER
#include "jinete.h"
#include "core/app.h"
#include "modules/sprites.h"
#include "raster/sprite.h"
#include "util/clipbrd.h"
#endif
bool command_enabled_paste(const char *argument)
{
Sprite *sprite = current_sprite;
Sprite *clipboard = get_clipboard_sprite();
return (sprite && clipboard && (clipboard != sprite));
}
void command_execute_paste(const char *argument)
{
paste_from_clipboard();
}

View File

@ -20,14 +20,21 @@
#ifndef USE_PRECOMPILED_HEADER
#include "jinete.h"
#include "jinete/base.h"
#include "core/app.h"
#include "modules/sprites.h"
#include "raster/sprite.h"
#include "util/recscr.h"
#endif
bool command_checked_record_screen(const char *argument)
{
return is_rec_screen();
}
void command_execute_record_screen(const char *argument)
{
if (is_rec_screen())
rec_screen_off();
else
rec_screen_on();
}

View File

@ -20,14 +20,11 @@
#ifndef USE_PRECOMPILED_HEADER
#include "jinete.h"
#include "core/app.h"
#include "modules/sprites.h"
#include "raster/sprite.h"
#endif
void command_execute_refresh(const char *argument)
{
app_refresh_screen();
}

View File

@ -20,14 +20,40 @@
#ifndef USE_PRECOMPILED_HEADER
#include "jinete.h"
#include "core/app.h"
#include "modules/gui.h"
#include "modules/sprites.h"
#include "raster/mask.h"
#include "raster/sprite.h"
#include "raster/undo.h"
#endif
bool command_enabled_reselect_mask(const char *argument)
{
return
current_sprite != NULL &&
sprite_request_mask(current_sprite, "*deselected*") != NULL;
}
void command_execute_reselect_mask(const char *argument)
{
Sprite *sprite = current_sprite;
Mask *mask;
/* request *deselected* mask */
mask = sprite_request_mask(sprite, "*deselected*");
/* undo */
if (undo_is_enabled(sprite->undo))
undo_set_mask(sprite->undo, sprite);
/* set the mask */
sprite_set_mask(sprite, mask);
/* remove the *deselected* mask */
sprite_remove_mask(sprite, mask);
mask_free(mask);
sprite_generate_mask_boundaries(sprite);
GUI_Refresh(sprite);
}

View File

@ -20,14 +20,42 @@
#ifndef USE_PRECOMPILED_HEADER
#include "jinete.h"
#include "jinete/base.h"
#include "core/app.h"
#include "commands/commands.h"
#include "console/console.h"
#include "file/file.h"
#include "modules/recent.h"
#include "modules/sprites.h"
#include "raster/sprite.h"
#endif
bool command_enabled_save_file(const char *argument)
{
return current_sprite != NULL;
}
void command_execute_save_file(const char *argument)
{
/* if the sprite is associated to a file in the file-system, we can
save it directly without user interaction */
if (sprite_is_associated_to_file(current_sprite)) {
if (sprite_save(current_sprite) == 0) {
recent_file(current_sprite->filename);
sprite_mark_as_saved(current_sprite);
}
else {
unrecent_file(current_sprite->filename);
console_printf("%s: %s",
_("Error saving sprite file"),
current_sprite->filename);
}
}
/* if the sprite isn't associated to a file, we must to show the
save-as dialog to the user to select for first time the file-name
for this sprite */
else {
command_execute(command_get_by_name(CMD_SAVE_FILE), argument);
}
}

View File

@ -47,7 +47,7 @@ void command_execute_save_file_as(const char *argument)
int ret;
ustrcpy(filename, current_sprite->filename);
for (;;) {
newfilename = GUI_FileSelect(_("Save Sprite"), filename,
get_writeable_extensions());
@ -83,10 +83,12 @@ void command_execute_save_file_as(const char *argument)
if (sprite_save(current_sprite) == 0) {
recent_file(filename);
sprite_was_saved(current_sprite);
sprite_mark_as_saved(current_sprite);
}
else {
unrecent_file(filename);
console_printf("%s: %s", _("Error saving sprite file"), filename);
console_printf("%s: %s",
_("Error saving sprite file"),
filename);
}
}

View File

@ -20,14 +20,62 @@
#ifndef USE_PRECOMPILED_HEADER
#include "jinete.h"
#include <allegro/file.h>
#include "core/app.h"
#include "jinete/alert.h"
#include "dialogs/filesel.h"
#include "modules/sprites.h"
#include "raster/mask.h"
#include "raster/sprite.h"
#include "util/msk_file.h"
#endif
bool command_enabled_save_mask(const char *argument)
{
if (!current_sprite)
return FALSE;
else
return (current_sprite->mask &&
current_sprite->mask->bitmap) ? TRUE: FALSE;
}
void command_execute_save_mask(const char *argument)
{
/* get current sprite */
Sprite *sprite = current_sprite;
char *filename = "default.msk";
int ret;
for (;;) {
char *filename = GUI_FileSelect(_("Save .msk File"), filename, "msk");
if (!filename)
return;
/* does the file exist? */
if (exists(filename)) {
/* ask if the user wants overwrite the file? */
ret = jalert("%s<<%s<<%s||%s||%s||%s",
_("Warning"), _("File exists, overwrite it?"),
get_filename(filename),
_("&Yes"), _("&No"), _("&Cancel"));
}
else
break;
/* "yes": we must continue with the operation... */
if (ret == 1)
break;
/* "cancel" or <esc> per example: we back doing nothing */
else if (ret != 2)
return;
/* "no": we must back to select other file-name */
}
if (save_msk_file(sprite->mask, filename) != 0)
jalert("%s<<%s<<%s||%s",
_("Error"), _("Error saving .msk file"),
_(filename), _("&Close"));
}

View File

@ -20,14 +20,46 @@
#ifndef USE_PRECOMPILED_HEADER
#include "jinete.h"
#include <allegro.h>
#include "core/app.h"
#include "modules/sprites.h"
#include "raster/sprite.h"
#include "jinete/system.h"
#include "core/core.h"
#endif
void command_execute_screen_shot(const char *argument)
{
int old_flag;
char buf[512];
PALETTE pal;
BITMAP *bmp;
int c;
/* save the active flag which indicate if the mouse is freeze or not */
old_flag = freeze_mouse_flag;
/* freeze the mouse obligatory */
freeze_mouse_flag = TRUE;
/* get the active palette color */
get_palette(pal);
/* get a file name for the capture */
for (c=0; c<10000; c++) {
usprintf(buf, "shot%04d.%s", c, "pcx");
if (!exists(buf))
break;
}
if (ji_screen != screen)
jmouse_draw_cursor();
/* save in a bitmap the visible screen portion */
bmp = create_sub_bitmap(ji_screen, 0, 0, JI_SCREEN_W, JI_SCREEN_H);
save_bitmap(buf, bmp, pal);
destroy_bitmap(bmp);
/* restore the freeze flag by the previous value */
freeze_mouse_flag = old_flag;
}

View File

@ -33,17 +33,18 @@
bool command_enabled_select_file(const char *argument)
{
/* with argument, the argument specified the ID of the GfxObj */
if (argument) {
int sprite_id = ustrtol(argument, NULL, 10);
GfxObj *gfxobj = gfxobj_find(sprite_id);
return
gfxobj && gfxobj->type == GFXOBJ_SPRITE;
return gfxobj && gfxobj->type == GFXOBJ_SPRITE;
}
/* argument=NULL, means the select "Nothing" option */
else
return TRUE;
}
bool command_selected_select_file(const char *argument)
bool command_checked_select_file(const char *argument)
{
if (argument) {
int sprite_id = ustrtol(argument, NULL, 10);

View File

@ -30,142 +30,170 @@
#endif
#define CMD0(name) { #name, NULL, NULL, command_execute_##name, NULL }
#define CMD1(name) { #name, command_enabled_##name, NULL, command_execute_##name, NULL }
#define CMD2(name,name2) { #name, command_enabled_##name2, NULL, command_execute_##name, NULL }
#define CMD3(name) { #name, command_enabled_##name, command_selected_##name, command_execute_##name, NULL }
/* #define CMD4(name) { #name, NULL, NULL, NULL, NULL } */
/********************************************************************/
/* All commands */
void command_execute_about(const char *argument);
void command_execute_advanced_mode(const char *argument);
void command_execute_auto_crop_sprite(const char *argument);
void command_execute_brush_tool(const char *argument);
void command_execute_change_image_type(const char *argument);
void command_execute_clear(const char *argument);
bool command_enabled_close_all_files(const char *argument);
void command_execute_close_all_files(const char *argument);
void command_execute_close_editor(const char *argument);
/* file */
void command_execute_new_file(const char *argument);
void command_execute_new_file(const char *argument);
void command_execute_open_file(const char *argument);
bool command_enabled_save_file(const char *argument);
void command_execute_save_file(const char *argument);
bool command_enabled_save_file_as(const char *argument);
void command_execute_save_file_as(const char *argument);
bool command_enabled_close_file(const char *argument);
void command_execute_close_file(const char *argument);
void command_execute_color_curve(const char *argument);
void command_execute_configure_screen(const char *argument);
void command_execute_configure_tools(const char *argument);
void command_execute_convolution_matrix(const char *argument);
void command_execute_copy(const char *argument);
void command_execute_copy_frame(const char *argument);
void command_execute_crop_frame(const char *argument);
void command_execute_crop_layer(const char *argument);
void command_execute_crop_sprite(const char *argument);
void command_execute_customize(const char *argument);
void command_execute_cut(const char *argument);
void command_execute_deselect_mask(const char *argument);
void command_execute_despeckle(const char *argument);
void command_execute_dots_tool(const char *argument);
void command_execute_draw_text(const char *argument);
void command_execute_duplicate_layer(const char *argument);
void command_execute_duplicate_sprite(const char *argument);
void command_execute_ellipse_tool(const char *argument);
bool command_enabled_close_all_files(const char *argument);
void command_execute_close_all_files(const char *argument);
void command_execute_screen_shot(const char *argument);
bool command_checked_record_screen(const char *argument);
void command_execute_record_screen(const char *argument);
void command_execute_about(const char *argument);
void command_execute_exit(const char *argument);
void command_execute_film_editor(const char *argument);
void command_execute_flatten_layers(const char *argument);
/* edit */
bool command_enabled_undo(const char *argument);
void command_execute_undo(const char *argument);
bool command_enabled_redo(const char *argument);
void command_execute_redo(const char *argument);
bool command_enabled_cut(const char *argument);
void command_execute_cut(const char *argument);
bool command_enabled_copy(const char *argument);
void command_execute_copy(const char *argument);
bool command_enabled_paste(const char *argument);
void command_execute_paste(const char *argument);
bool command_enabled_clear(const char *argument);
void command_execute_clear(const char *argument);
void command_execute_quick_move(const char *argument);
void command_execute_quick_copy(const char *argument);
void command_execute_flip_horizontal(const char *argument);
void command_execute_flip_vertical(const char *argument);
void command_execute_floodfill_tool(const char *argument);
void command_execute_frame_properties(const char *argument);
void command_execute_replace_color(const char *argument);
void command_execute_invert_color(const char *argument);
void command_execute_invert_mask(const char *argument);
void command_execute_layer_properties(const char *argument);
void command_execute_line_tool(const char *argument);
void command_execute_link_frame(const char *argument);
void command_execute_load_mask(const char *argument);
void command_execute_load_session(const char *argument);
void command_execute_refresh(const char *argument);
void command_execute_configure_screen(const char *argument);
void command_execute_advanced_mode(const char *argument);
void command_execute_make_unique_editor(const char *argument);
void command_execute_mapgen(const char *argument);
void command_execute_marker_tool(const char *argument);
void command_execute_mask_all(const char *argument);
void command_execute_mask_by_color(const char *argument);
void command_execute_mask_repository(const char *argument);
void command_execute_merge_down_layer(const char *argument);
void command_execute_move_frame(const char *argument);
void command_execute_new_file(const char *argument);
void command_execute_new_file(const char *argument);
void command_execute_new_frame(const char *argument);
void command_execute_new_layer(const char *argument);
void command_execute_new_layer_set(const char *argument);
void command_execute_open_file(const char *argument);
void command_execute_options(const char *argument);
void command_execute_palette_editor(const char *argument);
void command_execute_paste(const char *argument);
void command_execute_pencil_tool(const char *argument);
void command_execute_play_flic(const char *argument);
void command_execute_split_editor_vertically(const char *argument);
void command_execute_split_editor_horizontally(const char *argument);
void command_execute_close_editor(const char *argument);
bool command_enabled_preview(const char *argument);
void command_execute_preview_fit_to_screen(const char *argument);
void command_execute_preview_normal(const char *argument);
void command_execute_preview_tiled(const char *argument);
void command_execute_quick_copy(const char *argument);
void command_execute_quick_move(const char *argument);
void command_execute_record_screen(const char *argument);
void command_execute_rectangle_tool(const char *argument);
bool command_enabled_redo(const char *argument);
void command_execute_redo(const char *argument);
void command_execute_refresh(const char *argument);
void command_execute_remove_frame(const char *argument);
void command_execute_remove_layer(const char *argument);
void command_execute_replace_color(const char *argument);
void command_execute_reselect_mask(const char *argument);
void command_execute_run_script(const char *argument);
void command_execute_save_file(const char *argument);
bool command_enabled_save_file_as(const char *argument);
void command_execute_save_file_as(const char *argument);
void command_execute_save_mask(const char *argument);
void command_execute_save_session(const char *argument);
void command_execute_screen_shot(const char *argument);
bool command_enabled_select_file(const char *argument);
bool command_selected_select_file(const char *argument);
void command_execute_select_file(const char *argument);
void command_execute_split_editor_horizontally(const char *argument);
void command_execute_split_editor_vertically(const char *argument);
void command_execute_spray_tool(const char *argument);
/* sprite */
void command_execute_sprite_properties(const char *argument);
void command_execute_duplicate_sprite(const char *argument);
void command_execute_change_image_type(const char *argument);
void command_execute_crop_sprite(const char *argument);
void command_execute_auto_crop_sprite(const char *argument);
/* layer */
void command_execute_layer_properties(const char *argument);
void command_execute_new_layer(const char *argument);
void command_execute_new_layer_set(const char *argument);
void command_execute_remove_layer(const char *argument);
void command_execute_duplicate_layer(const char *argument);
void command_execute_merge_down_layer(const char *argument);
void command_execute_flatten_layers(const char *argument);
void command_execute_crop_layer(const char *argument);
/* frame */
void command_execute_frame_properties(const char *argument);
void command_execute_remove_frame(const char *argument);
void command_execute_new_frame(const char *argument);
void command_execute_move_frame(const char *argument);
void command_execute_copy_frame(const char *argument);
void command_execute_link_frame(const char *argument);
void command_execute_crop_frame(const char *argument);
/* select */
bool command_enabled_mask_all(const char *argument);
void command_execute_mask_all(const char *argument);
bool command_enabled_deselect_mask(const char *argument);
void command_execute_deselect_mask(const char *argument);
bool command_enabled_reselect_mask(const char *argument);
void command_execute_reselect_mask(const char *argument);
bool command_enabled_invert_mask(const char *argument);
void command_execute_invert_mask(const char *argument);
bool command_enabled_mask_by_color(const char *argument);
void command_execute_mask_by_color(const char *argument);
bool command_enabled_load_mask(const char *argument);
void command_execute_load_mask(const char *argument);
bool command_enabled_save_mask(const char *argument);
void command_execute_save_mask(const char *argument);
/* tools */
void command_execute_configure_tools(const char *argument);
bool command_checked_marker_tool(const char *argument);
void command_execute_marker_tool(const char *argument);
bool command_checked_dots_tool(const char *argument);
void command_execute_dots_tool(const char *argument);
bool command_checked_pencil_tool(const char *argument);
void command_execute_pencil_tool(const char *argument);
bool command_checked_brush_tool(const char *argument);
void command_execute_brush_tool(const char *argument);
bool command_checked_spray_tool(const char *argument);
void command_execute_spray_tool(const char *argument);
bool command_checked_floodfill_tool(const char *argument);
void command_execute_floodfill_tool(const char *argument);
bool command_checked_line_tool(const char *argument);
void command_execute_line_tool(const char *argument);
bool command_checked_rectangle_tool(const char *argument);
void command_execute_rectangle_tool(const char *argument);
bool command_checked_ellipse_tool(const char *argument);
void command_execute_ellipse_tool(const char *argument);
void command_execute_film_editor(const char *argument);
void command_execute_palette_editor(const char *argument);
void command_execute_convolution_matrix(const char *argument);
void command_execute_color_curve(const char *argument);
void command_execute_despeckle(const char *argument);
/* void command_execute_draw_text(const char *argument); */
/* void command_execute_play_flic(const char *argument); */
/* void command_execute_mapgen(const char *argument); */
void command_execute_run_script(const char *argument);
void command_execute_tips(const char *argument);
bool command_enabled_undo(const char *argument);
void command_execute_undo(const char *argument);
void command_execute_options(const char *argument);
/* internal commands */
bool command_enabled_select_file(const char *argument);
bool command_checked_select_file(const char *argument);
void command_execute_select_file(const char *argument);
/* EXE=execute, ENA=enabled, CHK=checked */
#define CMD_EXE(name) { #name, NULL, NULL, command_execute_##name, NULL }
#define CMD_EXE_ENA(name) { #name, command_enabled_##name, NULL, command_execute_##name, NULL }
#define CMD_EXE_ENA2(name,name2){ #name, command_enabled_##name2, NULL, command_execute_##name, NULL }
#define CMD_EXE_ENA_CHK(name) { #name, command_enabled_##name, command_checked_##name, command_execute_##name, NULL }
#define CMD_EXE_CHK(name) { #name, NULL, command_checked_##name, command_execute_##name, NULL }
static Command commands[] = {
CMD0(new_file),
CMD0(open_file),
{ CMD_SAVE_FILE, NULL, NULL, NULL, NULL },
CMD1(save_file_as),
CMD1(close_file),
CMD1(close_all_files),
{ CMD_SCREEN_SHOT, NULL, NULL, NULL, NULL },
{ CMD_RECORD_SCREEN, NULL, NULL, NULL, NULL },
{ CMD_LOAD_SESSION, NULL, NULL, NULL, NULL },
{ CMD_SAVE_SESSION, NULL, NULL, NULL, NULL },
CMD0(about),
CMD0(exit),
CMD1(undo),
CMD1(redo),
{ CMD_CUT, NULL, NULL, NULL, NULL },
{ CMD_COPY, NULL, NULL, NULL, NULL },
{ CMD_PASTE, NULL, NULL, NULL, NULL },
{ CMD_CLEAR, NULL, NULL, NULL, NULL },
CMD_EXE(new_file),
CMD_EXE(open_file),
CMD_EXE_ENA(save_file),
CMD_EXE_ENA(save_file_as),
CMD_EXE_ENA(close_file),
CMD_EXE_ENA(close_all_files),
CMD_EXE(screen_shot),
CMD_EXE_CHK(record_screen),
CMD_EXE(about),
CMD_EXE(exit),
CMD_EXE_ENA(undo),
CMD_EXE_ENA(redo),
CMD_EXE_ENA(cut),
CMD_EXE_ENA(copy),
CMD_EXE_ENA(paste),
CMD_EXE_ENA(clear),
{ CMD_QUICK_MOVE, NULL, NULL, NULL, NULL },
{ CMD_QUICK_COPY, NULL, NULL, NULL, NULL },
{ CMD_FLIP_HORIZONTAL, NULL, NULL, NULL, NULL },
{ CMD_FLIP_VERTICAL, NULL, NULL, NULL, NULL },
{ CMD_REPLACE_COLOR, NULL, NULL, NULL, NULL },
{ CMD_INVERT_COLOR, NULL, NULL, NULL, NULL },
{ CMD_REFRESH, NULL, NULL, NULL, NULL },
CMD_EXE(refresh),
{ CMD_CONFIGURE_SCREEN, NULL, NULL, NULL, NULL },
CMD0(advanced_mode),
CMD0(make_unique_editor),
CMD0(split_editor_vertically),
CMD0(split_editor_horizontally),
CMD0(close_editor),
CMD2(preview_tiled,preview),
CMD2(preview_normal,preview),
CMD2(preview_fit_to_screen,preview),
CMD_EXE(advanced_mode),
CMD_EXE(make_unique_editor),
CMD_EXE(split_editor_vertically),
CMD_EXE(split_editor_horizontally),
CMD_EXE(close_editor),
CMD_EXE_ENA2(preview_tiled, preview),
CMD_EXE_ENA2(preview_normal, preview),
CMD_EXE_ENA2(preview_fit_to_screen, preview),
{ CMD_SPRITE_PROPERTIES, NULL, NULL, NULL, NULL },
{ CMD_DUPLICATE_SPRITE, NULL, NULL, NULL, NULL },
{ CMD_CHANGE_IMAGE_TYPE, NULL, NULL, NULL, NULL },
@ -186,37 +214,35 @@ static Command commands[] = {
{ CMD_COPY_FRAME, NULL, NULL, NULL, NULL },
{ CMD_LINK_FRAME, NULL, NULL, NULL, NULL },
{ CMD_CROP_FRAME, NULL, NULL, NULL, NULL },
{ CMD_MASK_ALL, NULL, NULL, NULL, NULL },
{ CMD_DESELECT_MASK, NULL, NULL, NULL, NULL },
{ CMD_RESELECT_MASK, NULL, NULL, NULL, NULL },
{ CMD_INVERT_MASK, NULL, NULL, NULL, NULL },
{ CMD_MASK_BY_COLOR, NULL, NULL, NULL, NULL },
{ CMD_MASK_REPOSITORY, NULL, NULL, NULL, NULL },
{ CMD_LOAD_MASK, NULL, NULL, NULL, NULL },
{ CMD_SAVE_MASK, NULL, NULL, NULL, NULL },
{ CMD_CONFIGURE_TOOLS, NULL, NULL, NULL, NULL },
{ CMD_MARKER_TOOL, NULL, NULL, NULL, NULL },
{ CMD_DOTS_TOOL, NULL, NULL, NULL, NULL },
{ CMD_PENCIL_TOOL, NULL, NULL, NULL, NULL },
{ CMD_BRUSH_TOOL, NULL, NULL, NULL, NULL },
{ CMD_SPRAY_TOOL, NULL, NULL, NULL, NULL },
{ CMD_FLOODFILL_TOOL, NULL, NULL, NULL, NULL },
{ CMD_LINE_TOOL, NULL, NULL, NULL, NULL },
{ CMD_RECTANGLE_TOOL, NULL, NULL, NULL, NULL },
{ CMD_ELLIPSE_TOOL, NULL, NULL, NULL, NULL },
CMD_EXE_ENA(mask_all),
CMD_EXE_ENA(deselect_mask),
CMD_EXE_ENA(reselect_mask),
CMD_EXE_ENA(invert_mask),
CMD_EXE_ENA(mask_by_color),
CMD_EXE_ENA(load_mask),
CMD_EXE_ENA(save_mask),
CMD_EXE(configure_tools),
CMD_EXE_CHK(marker_tool),
CMD_EXE_CHK(dots_tool),
CMD_EXE_CHK(pencil_tool),
CMD_EXE_CHK(brush_tool),
CMD_EXE_CHK(spray_tool),
CMD_EXE_CHK(floodfill_tool),
CMD_EXE_CHK(line_tool),
CMD_EXE_CHK(rectangle_tool),
CMD_EXE_CHK(ellipse_tool),
{ CMD_FILM_EDITOR, NULL, NULL, NULL, NULL },
{ CMD_PALETTE_EDITOR, NULL, NULL, NULL, NULL },
{ CMD_CONVOLUTION_MATRIX, NULL, NULL, NULL, NULL },
{ CMD_COLOR_CURVE, NULL, NULL, NULL, NULL },
{ CMD_DESPECKLE, NULL, NULL, NULL, NULL },
{ CMD_DRAW_TEXT, NULL, NULL, NULL, NULL },
{ CMD_PLAY_FLIC, NULL, NULL, NULL, NULL },
{ CMD_MAPGEN, NULL, NULL, NULL, NULL },
/* { CMD_DRAW_TEXT, NULL, NULL, NULL, NULL }, */
/* { CMD_PLAY_FLIC, NULL, NULL, NULL, NULL }, */
/* { CMD_MAPGEN, NULL, NULL, NULL, NULL }, */
{ CMD_RUN_SCRIPT, NULL, NULL, NULL, NULL },
CMD0(tips),
CMD0(customize),
CMD0(options),
CMD3(select_file),
CMD_EXE(tips),
CMD_EXE(options),
CMD_EXE_ENA_CHK(select_file),
{ NULL, NULL, NULL, NULL, NULL }
};
@ -248,6 +274,10 @@ Command *command_get_by_key(JMessage msg)
return NULL;
}
/**
* Returns true if the current state of the program fulfills the
* preconditions to execute this command.
*/
bool command_is_enabled(Command *command, const char *argument)
{
if (command && command->enabled)
@ -256,18 +286,22 @@ bool command_is_enabled(Command *command, const char *argument)
return TRUE;
}
bool command_is_selected(Command *command, const char *argument)
bool command_is_checked(Command *command, const char *argument)
{
if (command && command->selected)
return (*command->selected)(argument);
if (command && command->checked)
return (*command->checked)(argument);
else
return FALSE;
}
/**
* Executes the command. You can be sure that the command will be
* executed only if it is enabled.
*/
void command_execute(Command *command, const char *argument)
{
if (command && command->execute) {
PRINTF("Executing command \"%s\"\n", command->name);
if (command && command->execute &&
command_is_enabled(command, argument)) {
(*command->execute)(argument);
}
}

View File

@ -21,6 +21,7 @@
#include "jinete/base.h"
/* file */
#define CMD_NEW_FILE "new_file"
#define CMD_OPEN_FILE "open_file"
#define CMD_SAVE_FILE "save_file"
@ -29,10 +30,9 @@
#define CMD_CLOSE_ALL_FILES "close_all_files"
#define CMD_SCREEN_SHOT "screen_shot"
#define CMD_RECORD_SCREEN "record_screen"
#define CMD_LOAD_SESSION "load_session"
#define CMD_SAVE_SESSION "save_session"
#define CMD_ABOUT "about"
#define CMD_EXIT "exit"
/* edit */
#define CMD_UNDO "undo"
#define CMD_REDO "redo"
#define CMD_CUT "cut"
@ -45,6 +45,7 @@
#define CMD_FLIP_VERTICAL "flip_vertical"
#define CMD_REPLACE_COLOR "replace_color"
#define CMD_INVERT_COLOR "invert_color"
/* view */
#define CMD_REFRESH "refresh"
#define CMD_CONFIGURE_SCREEN "configure_screen"
#define CMD_ADVANCED_MODE "advanced_mode"
@ -55,11 +56,13 @@
#define CMD_PREVIEW_TILED "preview_tiled"
#define CMD_PREVIEW_NORMAL "preview_normal"
#define CMD_PREVIEW_FIT_TO_SCREEN "preview_fit_to_screen"
/* sprite */
#define CMD_SPRITE_PROPERTIES "sprite_properties"
#define CMD_DUPLICATE_SPRITE "duplicate_sprite"
#define CMD_CHANGE_IMAGE_TYPE "change_image_type"
#define CMD_CROP_SPRITE "crop_sprite"
#define CMD_AUTO_CROP_SPRITE "auto_crop_sprite"
/* layer */
#define CMD_LAYER_PROPERTIES "layer_properties"
#define CMD_NEW_LAYER "new_layer"
#define CMD_NEW_LAYER_SET "new_layer_set"
@ -68,6 +71,7 @@
#define CMD_MERGE_DOWN_LAYER "merge_down_layer"
#define CMD_FLATTEN_LAYERS "flatten_layers"
#define CMD_CROP_LAYER "crop_layer"
/* frame */
#define CMD_FRAME_PROPERTIES "frame_properties"
#define CMD_REMOVE_FRAME "remove_frame"
#define CMD_NEW_FRAME "new_frame"
@ -75,14 +79,15 @@
#define CMD_COPY_FRAME "copy_frame"
#define CMD_LINK_FRAME "link_frame"
#define CMD_CROP_FRAME "crop_frame"
/* select */
#define CMD_MASK_ALL "mask_all"
#define CMD_DESELECT_MASK "deselect_mask"
#define CMD_RESELECT_MASK "reselect_mask"
#define CMD_INVERT_MASK "invert_mask"
#define CMD_MASK_BY_COLOR "mask_by_color"
#define CMD_MASK_REPOSITORY "mask_repository"
#define CMD_LOAD_MASK "load_mask"
#define CMD_SAVE_MASK "save_mask"
/* tools */
#define CMD_CONFIGURE_TOOLS "configure_tools"
#define CMD_MARKER_TOOL "marker_tool"
#define CMD_DOTS_TOOL "dots_tool"
@ -98,23 +103,24 @@
#define CMD_CONVOLUTION_MATRIX "convolution_matrix"
#define CMD_COLOR_CURVE "color_curve"
#define CMD_DESPECKLE "despeckle"
#define CMD_DRAW_TEXT "draw_text"
#define CMD_PLAY_FLIC "play_flic"
#define CMD_MAPGEN "mapgen"
/* #define CMD_DRAW_TEXT "draw_text" */
/* #define CMD_PLAY_FLIC "play_flic" */
/* #define CMD_MAPGEN "mapgen" */
#define CMD_RUN_SCRIPT "run_script"
#define CMD_TIPS "tips"
#define CMD_CUSTOMIZE "customize"
#define CMD_OPTIONS "options"
/* internal commands */
#define CMD_SELECT_FILE "select_file"
typedef struct Command Command;
struct Command
{
const char *name;
bool (*enabled)(const char *argument);
bool (*selected)(const char *argument);
void (*execute)(const char *argument);
bool (*enabled)(const char *argument); /* preconditions to execute the command */
bool (*checked)(const char *argument); /* should the menu-item be checked? */
void (*execute)(const char *argument); /* execute the command (after check the preconditions) */
JAccel accel;
};
@ -122,7 +128,7 @@ Command *command_get_by_name(const char *name);
Command *command_get_by_key(JMessage msg);
bool command_is_enabled(Command *command, const char *argument);
bool command_is_selected(Command *command, const char *argument);
bool command_is_checked(Command *command, const char *argument);
void command_execute(Command *command, const char *argument);
bool command_is_key_pressed(Command *command, JMessage msg);

View File

@ -28,6 +28,7 @@
#include "core/app.h"
#include "core/core.h"
#include "modules/gui.h"
#include "widgets/statebar.h"
#endif
@ -104,7 +105,7 @@ void console_close (void)
}
}
void console_printf (const char *format, ...)
void console_printf(const char *format, ...)
{
char buf[1024];
va_list ap;
@ -168,29 +169,35 @@ void user_printf (const char *format, ...)
allegro_message (buf);
}
void do_progress (int progress)
void do_progress(int progress)
{
JWidget status_bar = app_get_status_bar ();
JWidget status_bar = app_get_status_bar();
if (status_bar) {
status_bar_do_progress (status_bar, progress);
jwidget_flush_redraw (status_bar);
jmanager_dispatch_messages ();
status_bar_do_progress(status_bar, progress);
jwidget_flush_redraw(status_bar);
jmanager_dispatch_messages();
gui_feedback();
}
}
void add_progress (int max)
void add_progress(int max)
{
JWidget status_bar = app_get_status_bar ();
JWidget status_bar = app_get_status_bar();
if (status_bar)
status_bar_add_progress (status_bar, max);
status_bar_add_progress(status_bar, max);
jmouse_hide();
}
void del_progress (void)
void del_progress(void)
{
JWidget status_bar = app_get_status_bar();
if (status_bar)
status_bar_del_progress(status_bar);
jmouse_show();
}

View File

@ -37,7 +37,6 @@
#include "core/cfg.h"
#include "core/core.h"
#include "core/modules.h"
#include "core/shutdown.h"
#include "dialogs/options.h"
#include "dialogs/tips.h"
#include "file/file.h"
@ -153,9 +152,6 @@ int app_init(int argc, char *argv[])
/* set system palette to the default one */
set_current_palette (NULL, TRUE);
/* add the abnormal program exit handler */
init_shutdown_handler ();
/* ok */
return 0;
}
@ -238,8 +234,9 @@ void app_loop(void)
load_all_scripts();
/* set background mode for non-GUI modes */
if (!(ase_mode & MODE_GUI))
set_display_switch_mode(SWITCH_BACKAMNESIA);
/* if (!(ase_mode & MODE_GUI)) */
/* set_display_switch_mode(SWITCH_BACKAMNESIA); */
set_display_switch_mode(SWITCH_BACKGROUND);
/* procress options */
PRINTF("Processing options...\n");
@ -334,9 +331,6 @@ void app_exit(void)
core_exit();
_ji_font_exit();
/* remove the shutdown handler */
remove_shutdown_handler();
/* final copyright message */
if (ase_mode & MODE_GUI) {
set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);

View File

@ -1,185 +0,0 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* 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 <stdio.h>
#include "jinete/alert.h"
#include "jinete/box.h"
#include "jinete/button.h"
#include "jinete/entry.h"
#include "jinete/label.h"
#include "jinete/list.h"
#include "jinete/listbox.h"
#include "jinete/widget.h"
#include "jinete/window.h"
#include "core/core.h"
#include "dialogs/repo.h"
#include "modules/editors.h"
#include "modules/gui.h"
#include "modules/sprites.h"
#include "raster/mask.h"
#include "raster/sprite.h"
#endif
static JWidget new_listitem (Mask *mask);
static void load_listbox (RepoDlg *repo_dlg);
static bool use_listitem (RepoDlg *repo_dlg);
static bool add_listitem (RepoDlg *repo_dlg, int *added);
static bool delete_listitem (RepoDlg *repo_dlg, int *kill);
void dialogs_mask_repository(void)
{
RepoDlg repo_dlg = {
"MaskRepository",
_("Mask Repository"),
_("&Replace"),
load_listbox,
NULL,
NULL,
use_listitem,
add_listitem,
delete_listitem,
{ NULL, NULL, NULL, NULL }
};
Sprite *sprite = current_sprite;
if (!is_interactive () || !sprite)
return;
ji_show_repo_dlg (&repo_dlg);
}
static JWidget new_listitem (Mask *mask)
{
char buf[256];
JWidget listitem;
sprintf (buf, "%s (%d %d)", mask->name, mask->w, mask->h);
listitem = jlistitem_new (buf);
listitem->user_data[0] = mask;
return listitem;
}
static void load_listbox (RepoDlg *repo_dlg)
{
Sprite *sprite = current_sprite;
JLink link;
/* disable "Add" button if there isn't a current mask */
if (!sprite->mask->bitmap)
jwidget_disable (repo_dlg->button_add);
/* add new items to the list-box */
JI_LIST_FOR_EACH(sprite->repository.masks, link)
jwidget_add_child (repo_dlg->listbox, new_listitem (link->data));
}
static bool use_listitem(RepoDlg *repo_dlg)
{
JWidget listitem = repo_dlg->listitem;
Mask *mask = listitem->user_data[0];
Sprite *sprite = current_sprite;
/* XXXX undo stuff */
sprite_set_mask(sprite, mask);
sprite_generate_mask_boundaries(sprite);
GUI_Refresh(sprite);
return TRUE;
}
static bool add_listitem (RepoDlg *repo_dlg, int *added)
{
JWidget window, box1, box2, box3;
JWidget label_name, entry_name, button_ok, button_cancel;
window = jwindow_new (_("New Mask"));
box1 = jbox_new (JI_VERTICAL);
box2 = jbox_new (JI_HORIZONTAL);
box3 = jbox_new (JI_HORIZONTAL | JI_HOMOGENEOUS);
label_name = jlabel_new (_("Name:"));
entry_name = jentry_new (256, _("Current Mask"));
button_ok = jbutton_new (_("&OK"));
button_cancel = jbutton_new (_("&Cancel"));
jwidget_magnetic (button_ok, TRUE);
jwidget_expansive (entry_name, TRUE);
jwidget_expansive (box3, TRUE);
jwidget_add_child (box2, label_name);
jwidget_add_child (box2, entry_name);
jwidget_add_child (box1, box2);
jwidget_add_child (box3, button_ok);
jwidget_add_child (box3, button_cancel);
jwidget_add_child (box1, box3);
jwidget_add_child (window, box1);
jwindow_open_fg (window);
if (jwindow_get_killer (window) == button_ok) {
const char *name = jwidget_get_text (entry_name);
Sprite *sprite = current_sprite;
Mask *mask;
/* if the mask already exists */
if (sprite_request_mask (sprite, name)) {
jalert (_("Error"
"<<You can't have two masks with"
"<<the same name in the repository||&OK"));
}
else {
mask = mask_new_copy (sprite->mask);
/* set the mask's name */
mask_set_name (mask, name);
/* append the mask */
sprite_add_mask (sprite, mask);
/* we added the new mask */
jwidget_add_child (repo_dlg->listbox, new_listitem (mask));
*added = TRUE;
}
}
jwidget_free (window);
return TRUE;
}
static bool delete_listitem (RepoDlg *repo_dlg, int *kill)
{
JWidget listitem = repo_dlg->listitem;
Sprite *sprite = current_sprite;
Mask *mask = listitem->user_data[0];
sprite_remove_mask (sprite, mask);
mask_free (mask);
*kill = TRUE;
return TRUE;
}

View File

@ -1,25 +0,0 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* 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_MASKREPO_H
#define DIALOGS_MASKREPO_H
void dialogs_mask_repository(void);
#endif /* DIALOGS_MASKREPO_H */

View File

@ -81,7 +81,7 @@ void dialogs_options(void)
{
JWidget window, move_delay, check_smooth, check_dither;
JWidget button_font, button_lang, button_ok, button_save;
JWidget move_click2, draw_click2, askbkpses, killer;
JWidget move_click2, draw_click2, killer;
int x, y, old_x, old_y;
char *default_font;
@ -109,7 +109,6 @@ void dialogs_options(void)
"draw_click2", &draw_click2,
"button_font", &button_font,
"button_lang", &button_lang,
"askbkpses", &askbkpses,
"button_ok", &button_ok,
"button_save", &button_save, NULL)) {
jwidget_free (window);
@ -124,8 +123,6 @@ void dialogs_options(void)
jwidget_select (move_click2);
if (get_config_bool ("Options", "DrawClick2", FALSE))
jwidget_select (draw_click2);
if (get_config_bool ("Options", "AskBkpSes", TRUE))
jwidget_select (askbkpses);
jslider_set_value (move_delay,
get_config_int ("Options", "MoveDelay", 250));
@ -154,7 +151,6 @@ void dialogs_options(void)
set_config_bool ("Options", "MoveSmooth", jwidget_is_selected (check_smooth));
set_config_bool ("Options", "MoveClick2", jwidget_is_selected (move_click2));
set_config_bool ("Options", "DrawClick2", jwidget_is_selected (draw_click2));
set_config_bool ("Options", "AskBkpSes", jwidget_is_selected (askbkpses));
if (get_config_bool ("Options", "Dither", FALSE)
!= jwidget_is_selected (check_dither)) {

View File

@ -1,330 +0,0 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* 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.h"
#include "core/app.h"
#include "modules/editors.h"
#include "modules/gfx.h"
#include "modules/gui.h"
#include "modules/rootmenu.h"
#include "modules/sprites.h"
#include "modules/tools.h"
#include "raster/brush.h"
#include "raster/image.h"
#include "raster/mask.h"
#include "raster/sprite.h"
#include "widgets/colbut.h"
#include "widgets/editor.h"
#include "widgets/groupbut.h"
#include "widgets/statebar.h"
#endif
static JWidget window = NULL;
static bool brush_preview_msg_proc(JWidget widget, JMessage msg);
static int window_close_hook(JWidget widget, int user_data);
static int brush_size_slider_change_hook(JWidget widget, int user_data);
static int brush_angle_slider_change_hook(JWidget widget, int user_data);
static int brush_type_change_hook(JWidget widget, int user_data);
static int brush_mode_change_hook(JWidget widget, int user_data);
static int glass_dirty_slider_change_hook(JWidget widget, int user_data);
static int spray_width_slider_change_hook(JWidget widget, int user_data);
static int air_speed_slider_change_hook(JWidget widget, int user_data);
static int filled_check_change_hook(JWidget widget, int user_data);
static int tiled_check_change_hook(JWidget widget, int user_data);
static int use_grid_check_change_hook(JWidget widget, int user_data);
static int view_grid_check_change_hook(JWidget widget, int user_data);
static int set_grid_button_select_hook(JWidget widget, int user_data);
static int cursor_button_change_hook(JWidget widget, int user_data);
static int onionskin_check_change_hook(JWidget widget, int user_data);
void dialogs_tools_configuration(void)
{
JWidget filled, tiled, use_grid, view_grid, set_grid;
JWidget brush_size, brush_angle, glass_dirty;
JWidget spray_width, air_speed;
JWidget cursor_color, cursor_color_box;
JWidget brush_preview_box;
JWidget brush_type_box, brush_type;
JWidget brush_mode_box, brush_mode;
JWidget check_onionskin;
JWidget brush_preview;
/* if the window is opened, close it */
if (window) {
jwindow_close (window, NULL);
return;
}
/* if the window is closed, open it */
window = load_widget ("toolconf.jid", "configure_tool");
if (!window)
return;
if (!get_widgets (window,
"filled", &filled,
"tiled", &tiled,
"use_grid", &use_grid,
"view_grid", &view_grid,
"set_grid", &set_grid,
"brush_size", &brush_size,
"brush_angle", &brush_angle,
"glass_dirty", &glass_dirty,
"spray_width", &spray_width,
"air_speed", &air_speed,
"cursor_color_box", &cursor_color_box,
"brush_preview_box", &brush_preview_box,
"brush_type_box", &brush_type_box,
"brush_mode_box", &brush_mode_box,
"onionskin", &check_onionskin, NULL)) {
jwidget_free (window);
return;
}
/* cursor-color */
cursor_color = color_button_new (get_cursor_color (), IMAGE_INDEXED);
/* brush-preview */
brush_preview = jwidget_new (JI_WIDGET);
brush_preview->static_w = 32 + 4;
brush_preview->static_h = 32 + 4;
jwidget_add_hook (brush_preview, JI_WIDGET,
brush_preview_msg_proc, NULL);
/* brush-type */
brush_type = group_button_new (3, 1, get_brush_type (),
GFX_BRUSH_CIRCLE,
GFX_BRUSH_SQUARE,
GFX_BRUSH_LINE);
/* brush-type */
brush_mode = group_button_new (3, 1, get_brush_mode (),
GFX_DRAWMODE_OPAQUE,
GFX_DRAWMODE_GLASS,
GFX_DRAWMODE_SEMI);
/* append children */
jwidget_add_child (cursor_color_box, cursor_color);
jwidget_add_child (brush_preview_box, brush_preview);
jwidget_add_child (brush_type_box, brush_type);
jwidget_add_child (brush_mode_box, brush_mode);
if (get_filled_mode ()) jwidget_select (filled);
if (get_tiled_mode ()) jwidget_select (tiled);
if (get_use_grid ()) jwidget_select (use_grid);
if (get_view_grid ()) jwidget_select (view_grid);
jslider_set_value (brush_size, get_brush_size ());
jslider_set_value (brush_angle, get_brush_angle ());
jslider_set_value (glass_dirty, get_glass_dirty ());
jslider_set_value (spray_width, get_spray_width ());
jslider_set_value (air_speed, get_air_speed ());
if (get_onionskin ()) jwidget_select (check_onionskin);
HOOK (window, JI_SIGNAL_WINDOW_CLOSE, window_close_hook, 0);
HOOK (filled, JI_SIGNAL_CHECK_CHANGE, filled_check_change_hook, 0);
HOOK (tiled, JI_SIGNAL_CHECK_CHANGE, tiled_check_change_hook, 0);
HOOK (use_grid, JI_SIGNAL_CHECK_CHANGE, use_grid_check_change_hook, 0);
HOOK (view_grid, JI_SIGNAL_CHECK_CHANGE, view_grid_check_change_hook, 0);
HOOK (set_grid, JI_SIGNAL_BUTTON_SELECT, set_grid_button_select_hook, 0);
HOOK (brush_size, JI_SIGNAL_SLIDER_CHANGE, brush_size_slider_change_hook, brush_preview);
HOOK (brush_angle, JI_SIGNAL_SLIDER_CHANGE, brush_angle_slider_change_hook, brush_preview);
HOOK (brush_type, SIGNAL_GROUP_BUTTON_CHANGE, brush_type_change_hook, brush_preview);
HOOK (brush_mode, SIGNAL_GROUP_BUTTON_CHANGE, brush_mode_change_hook, 0);
HOOK (glass_dirty, JI_SIGNAL_SLIDER_CHANGE, glass_dirty_slider_change_hook, 0);
HOOK (air_speed, JI_SIGNAL_SLIDER_CHANGE, air_speed_slider_change_hook, 0);
HOOK (spray_width, JI_SIGNAL_SLIDER_CHANGE, spray_width_slider_change_hook, 0);
HOOK (cursor_color, SIGNAL_COLOR_BUTTON_CHANGE, cursor_button_change_hook, 0);
HOOK (check_onionskin, JI_SIGNAL_CHECK_CHANGE, onionskin_check_change_hook, 0);
/* default position */
jwindow_remap (window);
jwindow_center (window);
/* load window configuration */
load_window_pos (window, "ConfigureTool");
/* open the window */
jwindow_open_bg (window);
}
static bool brush_preview_msg_proc(JWidget widget, JMessage msg)
{
switch (msg->type) {
case JM_DRAW: {
BITMAP *bmp = create_bitmap(jrect_w(widget->rc),
jrect_h(widget->rc));
Brush *brush = get_brush();
clear_to_color(bmp, makecol(0, 0, 0));
image_to_allegro(brush->image, bmp,
bmp->w/2 - brush->size/2,
bmp->h/2 - brush->size/2);
blit(bmp, ji_screen, 0, 0, widget->rc->x1, widget->rc->y1,
bmp->w, bmp->h);
destroy_bitmap(bmp);
return TRUE;
}
}
return FALSE;
}
static int window_close_hook(JWidget widget, int user_data)
{
/* isn't running anymore */
window = NULL;
/* save window configuration */
save_window_pos(widget, "ConfigureTool");
return FALSE;
}
static int brush_size_slider_change_hook(JWidget widget, int user_data)
{
set_brush_size(jslider_get_value(widget));
jwidget_dirty((JWidget)user_data);
return FALSE;
}
static int brush_angle_slider_change_hook(JWidget widget, int user_data)
{
set_brush_angle(jslider_get_value(widget));
jwidget_dirty((JWidget)user_data);
return FALSE;
}
static int brush_type_change_hook(JWidget widget, int user_data)
{
int type = group_button_get_selected(widget);
set_brush_type(type);
jwidget_dirty((JWidget)user_data);
status_bar_set_text(app_get_status_bar(), 250,
"Brush type: %s",
type == BRUSH_CIRCLE ? "Circle":
type == BRUSH_SQUARE ? "Square":
type == BRUSH_LINE ? "Line": "Unknown");
return TRUE;
}
static int brush_mode_change_hook(JWidget widget, int user_data)
{
int mode = group_button_get_selected(widget);
set_brush_mode(mode);
status_bar_set_text(app_get_status_bar(), 250,
"Brush mode: %s",
mode == DRAWMODE_OPAQUE ? "Opaque":
mode == DRAWMODE_GLASS ? "Glass":
mode == DRAWMODE_SEMI ? "Semi": "Unknown");
return TRUE;
}
static int glass_dirty_slider_change_hook(JWidget widget, int user_data)
{
set_glass_dirty(jslider_get_value(widget));
return FALSE;
}
static int spray_width_slider_change_hook(JWidget widget, int user_data)
{
set_spray_width(jslider_get_value(widget));
return FALSE;
}
static int air_speed_slider_change_hook(JWidget widget, int user_data)
{
set_air_speed(jslider_get_value(widget));
return FALSE;
}
static int filled_check_change_hook(JWidget widget, int user_data)
{
set_filled_mode(jwidget_is_selected(widget));
return FALSE;
}
static int tiled_check_change_hook(JWidget widget, int user_data)
{
set_tiled_mode(jwidget_is_selected(widget));
return FALSE;
}
static int use_grid_check_change_hook(JWidget widget, int user_data)
{
set_use_grid(jwidget_is_selected(widget));
return FALSE;
}
static int view_grid_check_change_hook(JWidget widget, int user_data)
{
set_view_grid(jwidget_is_selected(widget));
refresh_all_editors();
return FALSE;
}
static int set_grid_button_select_hook(JWidget widget, int user_data)
{
Sprite *sprite = current_sprite;
if (sprite && sprite->mask && sprite->mask->bitmap) {
JRect rect = jrect_new(sprite->mask->x,
sprite->mask->y,
sprite->mask->x+sprite->mask->w,
sprite->mask->y+sprite->mask->h);
set_grid(rect);
jrect_free(rect);
if (get_view_grid())
refresh_all_editors();
}
else {
jalert(_("Error"
"<<You must select a sprite with mask."
"<<The boundaries of the mask will be used"
"<<to specify the grid area.||&OK"));
}
return TRUE;
}
static int cursor_button_change_hook(JWidget widget, int user_data)
{
set_cursor_color(color_button_get_color(widget));
return TRUE;
}
static int onionskin_check_change_hook(JWidget widget, int user_data)
{
set_onionskin(jwidget_is_selected(widget));
refresh_all_editors();
return FALSE;
}

View File

@ -1,25 +0,0 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* 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_TOOLCONF_H
#define DIALOGS_TOOLCONF_H
void dialogs_tools_configuration(void);
#endif /* DIALOGS_TOOLCONF_H */

View File

@ -27,11 +27,13 @@
#include "jinete/list.h"
#include "console/console.h"
#include "core/app.h"
#include "core/core.h"
#include "file/file.h"
#include "modules/gui.h"
#include "modules/palette.h"
#include "raster/raster.h"
#include "widgets/statebar.h"
#endif
@ -250,7 +252,7 @@ Sprite *sprite_load(const char *filename)
get_filename(filename)) != 1)) {
/* if the user replies "Skip", we need just one file name */
while (jlist_length(file_names) > 1)
jlist_delete_link (file_names, jlist_last (file_names));
jlist_delete_link(file_names, jlist_last(file_names));
}
}
@ -281,13 +283,13 @@ Sprite *sprite_load(const char *filename)
/* error reading the first frame */
if ((!sprite) || (!file_sequence.last_frame)) {
if (file_sequence.last_image)
image_free (file_sequence.last_image);
image_free(file_sequence.last_image);
if (file_sequence.last_frame)
frame_free (file_sequence.last_frame);
frame_free(file_sequence.last_frame);
if (file_sequence.sprite) {
sprite_free (file_sequence.sprite);
sprite_free(file_sequence.sprite);
file_sequence.sprite = NULL;
}
@ -296,10 +298,10 @@ Sprite *sprite_load(const char *filename)
/* read ok */
else {
/* add the keyframe */
SEQUENCE_IMAGE ();
SEQUENCE_IMAGE();
/* the first palette will be the palette to use */
/* memcpy (first_palette, file_palette, sizeof (PALETTE)); */
/* memcpy(first_palette, file_palette, sizeof(PALETTE)); */
}
}
/* for other frames */
@ -333,10 +335,10 @@ Sprite *sprite_load(const char *filename)
}
}
if (frames > 1)
do_progress (c);
c++;
if (frames > 1)
do_progress(c);
}
if (frames > 1)
@ -375,6 +377,7 @@ Sprite *sprite_load(const char *filename)
/* set the filename */
sprite_set_filename(sprite, filename);
sprite_mark_as_saved(sprite);
rebuild_sprite_list();
}
@ -485,17 +488,17 @@ int sprite_save(Sprite *sprite)
}
/* show the confirmation alert */
if (ugetc (buf)) {
if (is_interactive ()) {
if (ugetc(buf)) {
if (is_interactive()) {
if (fatal)
ret = jalert (_("Error<<File type \"%s\" doesn't support:%s"
"||&Close"),
file->name, buf);
ret = jalert(_("Error<<File type \"%s\" doesn't support:%s"
"||&Close"),
file->name, buf);
else
ret = jalert (_("Warning<<File type \"%s\" doesn't support:%s"
"<<Do you want continue?"
"||&Yes||&No"),
file->name, buf);
ret = jalert(_("Warning<<File type \"%s\" doesn't support:%s"
"<<Do you want continue?"
"||&Yes||&No"),
file->name, buf);
if ((fatal) || (ret != 1))
return 0;
@ -548,15 +551,15 @@ int sprite_save(Sprite *sprite)
for (sprite->frpos=0; sprite->frpos<sprite->frames; sprite->frpos++) {
/* draw all the sprite in this frame in the image */
image_clear (image, 0);
sprite_render (sprite, image, 0, 0);
image_clear(image, 0);
sprite_render(sprite, image, 0, 0);
/* get the name for this image */
usprintf (buf, "%s%0*d%s", left, width, start_from+sprite->frpos, right);
usprintf(buf, "%s%0*d%s", left, width, start_from+sprite->frpos, right);
/* save the image */
file_sequence.image = image;
ustrcpy (sprite->filename, buf);
ustrcpy(sprite->filename, buf);
palette_copy(file_palette, sprite_get_palette(sprite, sprite->frpos));
@ -568,10 +571,10 @@ int sprite_save(Sprite *sprite)
if (ret != 0)
break;
do_progress (sprite->frpos);
do_progress(sprite->frpos);
}
del_progress ();
del_progress();
}
/* destroy the image */
@ -593,6 +596,9 @@ int sprite_save(Sprite *sprite)
if (ret != 0)
console_printf(_("Error saving \"%s\"\n"), sprite->filename);
else
status_bar_set_text(app_get_status_bar(), 1000,
"File saved: %s", get_filename(sprite->filename));
return ret;
}

View File

@ -327,6 +327,8 @@ static int save_GIF(Sprite *sprite)
/* avoid compilation warnings */
x1 = y1 = x2 = y2 = 0;
add_progress(2);
add_progress(sprite->frames);
for (i = 0; i < sprite->frames; i++) {
/* frame palette */
palette_copy(npal, sprite_get_palette(sprite, i));
@ -440,12 +442,19 @@ static int save_GIF(Sprite *sprite)
/* update the old image and color-map to the new ones to compare later */
image_copy(old, bmp, 0, 0);
palette_copy(opal, npal);
do_progress(i);
}
del_progress();
do_progress(1);
add_progress(100);
ret = gif_save_animation(sprite->filename, gif, do_progress);
del_progress();
do_progress(2);
del_progress();
gif_destroy_animation(gif);
return ret;
}

View File

@ -103,64 +103,64 @@ static DATA gfx_data[GFX_BITMAP_COUNT] =
"## ## ##" },
/* GFX_TOOL_DOTS */
{ 8, 8,
" # "
" # "
" # "
" # # "
" # # "
" "
" # "
" # "
" # " },
" # "
" "
" # "
" "
" # " },
/* GFX_TOOL_PENCIL */
{ 8, 8,
" ## "
" ## "
" # "
" #### "
" # "
" ## "
" ## "
" "
" ### "
" # ## "
" # ### "
" # ### "
" #### "
"# ## "
"## " },
/* GFX_TOOL_BRUSH */
{ 8, 8,
" ### "
" ### "
"## "
" ###### "
" ##"
" ### "
"### "
" ### "
"### " },
" ## "
" ## "
" ##"
" ##"
" ###"
" #### " },
/* GFX_TOOL_FLOODFILL */
{ 8, 8,
" #### "
" ###### "
" ###### "
" "
" ##### "
"# # "
"# ## ## "
"# ##### "
"#### ## "
"####### "
"####### "
" ###### "
" ##### "
" ## " },
" ##### " },
/* GFX_TOOL_SPRAY */
{ 8, 8,
"# "
" # # "
"# # ## "
" # # "
"# ### "
" ### "
" ### "
" ### " },
"# # ### "
" # # #"
"# ### #"
" ### #"
" ### #"
" #####" },
/* GFX_TOOL_LINE */
{ 8, 8,
" #"
" # "
" # "
" # "
" # "
" # "
" # "
"# " },
" ##"
" ## "
" ## "
" ## "
" ## "
" ## "
"## " },
/* GFX_TOOL_RECTANGLE */
{ 8, 8,
"########"
@ -169,8 +169,8 @@ static DATA gfx_data[GFX_BITMAP_COUNT] =
"# #"
"# #"
"# #"
"# #"
"########" },
"########"
" " },
/* GFX_TOOL_ELLIPSE */
{ 8, 8,
" #### "
@ -178,9 +178,9 @@ static DATA gfx_data[GFX_BITMAP_COUNT] =
"# #"
"# #"
"# #"
"# #"
" # # "
" #### " },
" #### "
" " },
/* GFX_TOOL_CONFIGURATION */
{ 8, 8,
" # # "

View File

@ -45,7 +45,6 @@
#include "raster/sprite.h"
#include "script/script.h"
#include "util/recscr.h"
#include "util/scrshot.h"
#include "widgets/editor.h"
#endif
@ -306,9 +305,6 @@ void gui_feedback(void)
/* jmanager_dispatch_draw_messages(); */
}
/* don't eat CPU... rest some time */
rest(1);
}
void gui_setup_screen(void)
@ -690,6 +686,7 @@ static bool manager_msg_proc(JWidget widget, JMessage msg)
case JM_IDLE:
gui_feedback();
rest(1); /* don't eat CPU... rest some time */
break;
case JM_CHAR: {
@ -699,8 +696,10 @@ static bool manager_msg_proc(JWidget widget, JMessage msg)
/* the screen shot is available in everywhere */
if (strcmp(command->name, CMD_SCREEN_SHOT) == 0) {
screen_shot();
return TRUE;
if (command_is_enabled(command, NULL)) {
command_execute(command, NULL);
return TRUE;
}
}
/* all other keys are only available in the main-window */
else {

View File

@ -229,8 +229,8 @@ static JWidget convert_xmlelem_to_menu(JXmlElem elem)
JI_LIST_FOR_EACH(((JXmlNode)elem)->children, link) {
JXmlNode child = (JXmlNode)link->data;
PRINTF("convert_xmlelem_to_menu: child->value = %p (%s)\n",
child->value, child->value ? child->value: "");
/* PRINTF("convert_xmlelem_to_menu: child->value = %p (%s)\n", */
/* child->value, child->value ? child->value: ""); */
if (child->type == JI_XML_ELEM) {
menuitem = convert_xmlelem_to_menuitem((JXmlElem)child);

View File

@ -79,7 +79,7 @@ static int _cursor_mask;
static Image *tool_image = NULL;
static int tool_color;
static void update_cursor_color (void)
static void update_cursor_color(void)
{
if (cursor_color) {
if (ji_screen)
@ -126,6 +126,7 @@ int init_module_tools(void)
grid = jrect_new(0, 0, 16, 16);
get_config_rect("Tools", "GridRect", grid);
set_grid(grid);
glass_dirty = MID(0, glass_dirty, 255);
spray_width = MID(1, spray_width, 320);
@ -137,7 +138,7 @@ int init_module_tools(void)
return 0;
}
void exit_module_tools (void)
void exit_module_tools(void)
{
set_config_string("Tools", "CursorColor", cursor_color);
set_config_int("Tools", "GlassDirty", glass_dirty);
@ -162,7 +163,7 @@ void exit_module_tools (void)
unhook_palette_changes(update_cursor_color);
}
void refresh_tools_names (void)
void refresh_tools_names(void)
{
int c;
@ -170,26 +171,33 @@ void refresh_tools_names (void)
ase_tools_list[c]->translated_name = _(ase_tools_list[c]->name);
}
void select_tool (const char *tool_name)
void select_tool(Tool *tool)
{
ASSERT(tool != NULL);
current_tool = tool;
/* update status-bar */
if (app_get_status_bar() &&
jwidget_is_visible(app_get_status_bar()))
status_bar_set_text(app_get_status_bar(), 500, "%s: %s",
_("Tool"), current_tool->translated_name);
/* update tool-bar */
if (app_get_tool_bar())
tool_bar_update(app_get_tool_bar());
}
void select_tool_by_name(const char *tool_name)
{
int c;
for (c=0; ase_tools_list[c]; c++) {
if (ustricmp (ase_tools_list[c]->name, tool_name) == 0) {
if (ustricmp(ase_tools_list[c]->name, tool_name) == 0) {
if (current_tool == ase_tools_list[c])
return;
current_tool = ase_tools_list[c];
/* update status-bar */
if (app_get_status_bar () &&
jwidget_is_visible (app_get_status_bar ()))
status_bar_set_text (app_get_status_bar (), 500, "%s: %s",
_("Tool"), current_tool->translated_name);
/* update tool-bar */
if (app_get_tool_bar ())
tool_bar_update (app_get_tool_bar ());
select_tool(ase_tools_list[c]);
break;
}
}
@ -207,8 +215,16 @@ bool get_filled_mode(void) { return filled_mode; }
bool get_tiled_mode(void) { return tiled_mode; }
bool get_use_grid(void) { return use_grid; }
bool get_view_grid(void) { return view_grid; }
JRect get_grid(void) { return jrect_new_copy (grid); }
bool get_onionskin(void) { return onionskin; }
JRect get_grid(void)
{
return jrect_new_copy (grid);
}
bool get_onionskin(void)
{
return onionskin;
}
void set_brush_type(int type) { brush_set_type (brush, type); }
void set_brush_size(int size) { brush_set_size (brush, size); }
@ -221,8 +237,18 @@ void set_filled_mode(bool status) { filled_mode = status; }
void set_tiled_mode(bool status) { tiled_mode = status; }
void set_use_grid(bool status) { use_grid = status; }
void set_view_grid(bool status) { view_grid = status; }
void set_grid(JRect rect) { jrect_copy (grid, rect); }
void set_onionskin(bool status) { onionskin = status; }
void set_grid(JRect rect)
{
jrect_copy(grid, rect);
if (grid->x2 <= grid->x1) grid->x2 = grid->x1+1;
if (grid->y2 <= grid->y1) grid->y2 = grid->y1+1;
}
void set_onionskin(bool status)
{
onionskin = status;
}
int get_raw_cursor_color(void)
{

View File

@ -74,7 +74,8 @@ int init_module_tools(void);
void exit_module_tools(void);
void refresh_tools_names(void);
void select_tool(const char *tool_name);
void select_tool(Tool *tool);
void select_tool_by_name(const char *tool_name);
struct Brush *get_brush(void);
int get_brush_type(void);

View File

@ -1,5 +1,5 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 David A. Capello
* 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
@ -56,6 +56,7 @@ Sprite *sprite_new(int imgtype, int w, int h)
/* main properties */
strcpy(sprite->filename, "Sprite");
sprite->associated_to_file = FALSE;
sprite->imgtype = imgtype;
sprite->w = w;
sprite->h = h;
@ -241,15 +242,21 @@ void sprite_free(Sprite *sprite)
gfxobj_free((GfxObj *)sprite);
}
int sprite_is_modified(Sprite *sprite)
bool sprite_is_modified(Sprite *sprite)
{
return (sprite->undo->diff_count ==
sprite->undo->diff_saved) ? FALSE: TRUE;
}
void sprite_was_saved(Sprite *sprite)
bool sprite_is_associated_to_file(Sprite *sprite)
{
return sprite->associated_to_file;
}
void sprite_mark_as_saved(Sprite *sprite)
{
sprite->undo->diff_saved = sprite->undo->diff_count;
sprite->associated_to_file = TRUE;
}
RGB *sprite_get_palette(Sprite *sprite, int frpos)

View File

@ -1,5 +1,5 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 David A. Capello
* 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
@ -35,6 +35,8 @@ struct Sprite
{
GfxObj gfxobj;
char filename[512]; /* sprite's file name */
bool associated_to_file; /* true if this sprite is associated
to a file in the file-system */
int imgtype; /* image type */
int w, h; /* image width/height size (in pixels) */
int frames; /* how many frames has this sprite */
@ -68,8 +70,9 @@ Sprite *sprite_new_flatten_copy(const Sprite *sprite);
Sprite *sprite_new_with_layer(int imgtype, int w, int h);
void sprite_free(Sprite *sprite);
int sprite_is_modified(Sprite *sprite);
void sprite_was_saved(Sprite *sprite);
bool sprite_is_modified(Sprite *sprite);
bool sprite_is_associated_to_file(Sprite *sprite);
void sprite_mark_as_saved(Sprite *sprite);
RGB *sprite_get_palette(Sprite *sprite, int frpos);
void sprite_set_palette(Sprite *sprite, RGB *rgb, int frpos);

View File

@ -723,13 +723,11 @@ static int bind_jwidget_hook_signal (lua_State *L)
#include "dialogs/effect.h"
#include "dialogs/filmedit.h"
#include "dialogs/maskcol.h"
#include "dialogs/maskrepo.h"
#include "dialogs/options.h"
#include "dialogs/playfli.h"
#include "dialogs/quick.h"
#include "dialogs/scrsaver.h"
#include "dialogs/tips.h"
#include "dialogs/toolconf.h"
#include "dialogs/vectmap.h"
#include "file/file.h"
#include "intl/intl.h"
@ -743,8 +741,6 @@ static int bind_jwidget_hook_signal (lua_State *L)
#include "util/msk_file.h"
#include "util/quantize.h"
#include "util/recscr.h"
#include "util/scrshot.h"
#include "util/session.h"
#include "util/setgfx.h"
#endif

View File

@ -107,10 +107,6 @@ void intl_set_lang(const char *lang);
void show_fx_popup_menu(void);
/* modules/tools.c */
void select_tool(const char *tool_name);
/* Brush *get_brush (void); */
int get_brush_type(void);
int get_brush_size(void);
@ -266,13 +262,6 @@ int save_msk_file(Mask *mask, const char *filename);
void sprite_quantize(Sprite *sprite);
/* util/session.c */
bool load_session(const char *filename);
bool save_session(const char *filename);
bool is_backup_session(void);
/* modules/gui.c */
void GUI_Refresh(Sprite *sprite);
@ -291,16 +280,6 @@ void quick_swap(void);
void play_fli_animation(const char *filename, bool loop, bool fullscreen);
/* util/recscr.c */
bool is_rec_screen(void);
void rec_screen_on(void);
void rec_screen_off(void);
/* util/scrshot.c */
void screen_shot(void);
/* util/setgfx.c */
int set_gfx(const char *card, int w, int h, int depth);
@ -315,7 +294,6 @@ void dialogs_frame_length (int frpos);
void dialogs_invert_color(void);
void dialogs_mapgen(void);
void dialogs_mask_color(void);
void dialogs_mask_repository(void);
void dialogs_median_filter(void);
void dialogs_options(void);
void dialogs_palette_editor(void);
@ -323,15 +301,8 @@ void dialogs_replace_color(void);
void dialogs_screen_saver(void);
void dialogs_select_language(bool force);
void dialogs_tips(bool forced);
void dialogs_tools_configuration(void);
void dialogs_vector_map(void);
/* dialogs/view.c */
void view_tiled(void);
void view_normal(void);
void view_fullscreen(void);
/* dialogs/drawtext.c */
Image *RenderText(const char *fontname, int size, int color, const char *text);
@ -533,7 +504,8 @@ Sprite *sprite_new_with_layer(int imgtype, int w, int h);
void sprite_free(Sprite *sprite);
bool sprite_is_modified(Sprite *sprite);
void sprite_was_saved(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);

View File

@ -553,14 +553,6 @@ static int bind_show_fx_popup_menu(lua_State *L)
return 0;
}
static int bind_select_tool(lua_State *L)
{
const char *tool_name;
GetArg(1, tool_name, const char *, string);
select_tool(tool_name);
return 0;
}
static int bind_get_brush_type(lua_State *L)
{
int return_value;
@ -1259,34 +1251,6 @@ static int bind_sprite_quantize(lua_State *L)
return 0;
}
static int bind_load_session(lua_State *L)
{
bool return_value;
const char *filename;
GetArg(1, filename, const char *, string);
return_value = load_session(filename);
lua_pushboolean(L, return_value);
return 1;
}
static int bind_save_session(lua_State *L)
{
bool return_value;
const char *filename;
GetArg(1, filename, const char *, string);
return_value = save_session(filename);
lua_pushboolean(L, return_value);
return 1;
}
static int bind_is_backup_session(lua_State *L)
{
bool return_value;
return_value = is_backup_session();
lua_pushboolean(L, return_value);
return 1;
}
static int bind_GUI_Refresh(lua_State *L)
{
Sprite *sprite;
@ -1343,32 +1307,6 @@ static int bind_play_fli_animation(lua_State *L)
return 0;
}
static int bind_is_rec_screen(lua_State *L)
{
bool return_value;
return_value = is_rec_screen();
lua_pushboolean(L, return_value);
return 1;
}
static int bind_rec_screen_on(lua_State *L)
{
rec_screen_on();
return 0;
}
static int bind_rec_screen_off(lua_State *L)
{
rec_screen_off();
return 0;
}
static int bind_screen_shot(lua_State *L)
{
screen_shot();
return 0;
}
static int bind_set_gfx(lua_State *L)
{
int return_value;
@ -1427,12 +1365,6 @@ static int bind_dialogs_mask_color(lua_State *L)
return 0;
}
static int bind_dialogs_mask_repository(lua_State *L)
{
dialogs_mask_repository();
return 0;
}
static int bind_dialogs_median_filter(lua_State *L)
{
dialogs_median_filter();
@ -1479,12 +1411,6 @@ static int bind_dialogs_tips(lua_State *L)
return 0;
}
static int bind_dialogs_tools_configuration(lua_State *L)
{
dialogs_tools_configuration();
return 0;
}
static int bind_dialogs_vector_map(lua_State *L)
{
dialogs_vector_map();
@ -2597,11 +2523,21 @@ static int bind_sprite_is_modified(lua_State *L)
return 1;
}
static int bind_sprite_was_saved(lua_State *L)
static int bind_sprite_is_associated_to_file(lua_State *L)
{
bool return_value;
Sprite *sprite;
GetUD(1, sprite, Sprite);
return_value = sprite_is_associated_to_file(sprite);
lua_pushboolean(L, return_value);
return 1;
}
static int bind_sprite_mark_as_saved(lua_State *L)
{
Sprite *sprite;
GetUD(1, sprite, Sprite);
sprite_was_saved(sprite);
sprite_mark_as_saved(sprite);
return 0;
}
@ -5723,7 +5659,6 @@ const luaL_reg bindings_routines[] = {
{ "intl_get_lang", bind_intl_get_lang },
{ "intl_set_lang", bind_intl_set_lang },
{ "show_fx_popup_menu", bind_show_fx_popup_menu },
{ "select_tool", bind_select_tool },
{ "get_brush_type", bind_get_brush_type },
{ "get_brush_size", bind_get_brush_size },
{ "get_brush_angle", bind_get_brush_angle },
@ -5812,9 +5747,6 @@ const luaL_reg bindings_routines[] = {
{ "load_msk_file", bind_load_msk_file },
{ "save_msk_file", bind_save_msk_file },
{ "sprite_quantize", bind_sprite_quantize },
{ "load_session", bind_load_session },
{ "save_session", bind_save_session },
{ "is_backup_session", bind_is_backup_session },
{ "GUI_Refresh", bind_GUI_Refresh },
{ "rebuild_root_menu", bind_rebuild_root_menu },
{ "rebuild_sprite_list", bind_rebuild_sprite_list },
@ -5823,10 +5755,6 @@ const luaL_reg bindings_routines[] = {
{ "quick_copy", bind_quick_copy },
{ "quick_swap", bind_quick_swap },
{ "play_fli_animation", bind_play_fli_animation },
{ "is_rec_screen", bind_is_rec_screen },
{ "rec_screen_on", bind_rec_screen_on },
{ "rec_screen_off", bind_rec_screen_off },
{ "screen_shot", bind_screen_shot },
{ "set_gfx", bind_set_gfx },
{ "dialogs_color_curve", bind_dialogs_color_curve },
{ "dialogs_convolution_matrix", bind_dialogs_convolution_matrix },
@ -5835,7 +5763,6 @@ const luaL_reg bindings_routines[] = {
{ "dialogs_invert_color", bind_dialogs_invert_color },
{ "dialogs_mapgen", bind_dialogs_mapgen },
{ "dialogs_mask_color", bind_dialogs_mask_color },
{ "dialogs_mask_repository", bind_dialogs_mask_repository },
{ "dialogs_median_filter", bind_dialogs_median_filter },
{ "dialogs_options", bind_dialogs_options },
{ "dialogs_palette_editor", bind_dialogs_palette_editor },
@ -5843,7 +5770,6 @@ const luaL_reg bindings_routines[] = {
{ "dialogs_screen_saver", bind_dialogs_screen_saver },
{ "dialogs_select_language", bind_dialogs_select_language },
{ "dialogs_tips", bind_dialogs_tips },
{ "dialogs_tools_configuration", bind_dialogs_tools_configuration },
{ "dialogs_vector_map", bind_dialogs_vector_map },
{ "RenderText", bind_RenderText },
{ "_rgba_getr", bind__rgba_getr },
@ -5934,7 +5860,8 @@ const luaL_reg bindings_routines[] = {
{ "sprite_new_with_layer", bind_sprite_new_with_layer },
{ "sprite_free", bind_sprite_free },
{ "sprite_is_modified", bind_sprite_is_modified },
{ "sprite_was_saved", bind_sprite_was_saved },
{ "sprite_is_associated_to_file", bind_sprite_is_associated_to_file },
{ "sprite_mark_as_saved", bind_sprite_mark_as_saved },
{ "sprite_set_filename", bind_sprite_set_filename },
{ "sprite_set_size", bind_sprite_set_size },
{ "sprite_set_frames", bind_sprite_set_frames },

View File

@ -53,20 +53,22 @@ void rec_screen_on(void)
char buf[512];
int c;
if (!is_interactive ()
|| (bitmap_color_depth (ji_screen) != 8)
|| (rec_file))
return;
/* if (!is_interactive() */
/* /\* || (bitmap_color_depth(ji_screen) != 8) *\/ */
/* || (rec_file)) */
/* return; */
ASSERT(rec_file == NULL);
/* get a file name for the record */
for (c=0; c<10000; c++) {
usprintf (buf, "rec%04d.%s", c, "flc");
if (!exists (buf))
usprintf(buf, "rec%04d.%s", c, "flc");
if (!exists(buf))
break;
}
/* open the file */
rec_file = fopen (buf, "wb");
rec_file = fopen(buf, "wb");
if (!rec_file)
return;
@ -90,8 +92,8 @@ void rec_screen_on(void)
fli_header->oframe1 = fli_header->oframe2 = 0;
/* prepare maps */
omap = jmalloc (768);
cmap = jmalloc (768);
omap = jmalloc(768);
cmap = jmalloc(768);
/* prepare old bitmap */
old_bmp = NULL;
@ -107,23 +109,23 @@ void rec_screen_off(void)
{
if (rec_file) {
/* write the header and close the file */
fli_write_header (rec_file, fli_header);
fclose (rec_file);
fli_write_header(rec_file, fli_header);
fclose(rec_file);
rec_file = NULL;
/* free memory */
if (old_bmp)
destroy_bitmap (old_bmp);
destroy_bitmap(old_bmp);
jfree (fli_header);
jfree (cmap);
jfree (omap);
jfree(fli_header);
jfree(cmap);
jfree(omap);
}
}
void rec_screen_poll (void)
{
if (!is_interactive () || !rec_file)
if (!is_interactive() || !rec_file)
return;
else if (ji_clock-rec_clock > JI_TICKS_PER_SEC/FRAMES_PER_SECOND) {
int old_flag;
@ -144,24 +146,26 @@ void rec_screen_poll (void)
}
/* save in a bitmap the visible screen portion */
bmp = create_bitmap (JI_SCREEN_W, JI_SCREEN_H);
blit (ji_screen, bmp, 0, 0, 0, 0, JI_SCREEN_W, JI_SCREEN_H);
bmp = create_bitmap_ex(8, JI_SCREEN_W, JI_SCREEN_H);
if (ji_screen != screen)
jmouse_draw_cursor();
blit(ji_screen, bmp, 0, 0, 0, 0, JI_SCREEN_W, JI_SCREEN_H);
/* write the frame in FLC file */
if (old_bmp)
fli_write_frame (rec_file, fli_header,
(unsigned char *)old_bmp->dat, omap,
(unsigned char *)bmp->dat, cmap, W_ALL);
fli_write_frame(rec_file, fli_header,
(unsigned char *)old_bmp->dat, omap,
(unsigned char *)bmp->dat, cmap, W_ALL);
else
fli_write_frame (rec_file, fli_header, NULL, NULL,
(unsigned char *)bmp->dat, cmap, W_ALL);
fli_write_frame(rec_file, fli_header, NULL, NULL,
(unsigned char *)bmp->dat, cmap, W_ALL);
/* copy this palette to the old one */
memcpy (omap, cmap, 768);
memcpy(omap, cmap, 768);
/* fixup old bitmap */
if (old_bmp)
destroy_bitmap (old_bmp);
destroy_bitmap(old_bmp);
old_bmp = bmp;

View File

@ -1,65 +0,0 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 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/system.h"
#include "core/core.h"
#endif
void screen_shot (void)
{
int old_flag;
char buf[512];
PALETTE pal;
BITMAP *bmp;
int c;
if (!is_interactive ())
return;
/* save the active flag which indicate if the mouse is freeze or not */
old_flag = freeze_mouse_flag;
/* freeze the mouse obligatory */
freeze_mouse_flag = TRUE;
/* get the active palette color */
get_palette (pal);
/* get a file name for the capture */
for (c=0; c<10000; c++) {
usprintf (buf, "shot%04d.%s", c, "pcx");
if (!exists (buf))
break;
}
/* save in a bitmap the visible screen portion */
bmp = create_sub_bitmap (ji_screen, 0, 0, JI_SCREEN_W, JI_SCREEN_H);
save_bitmap (buf, bmp, pal);
destroy_bitmap (bmp);
/* restore the freeze flag by the previous value */
freeze_mouse_flag = old_flag;
}

View File

@ -1,25 +0,0 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 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 UTIL_SCRSHOT_H
#define UTIL_SCRSHOT_H
void screen_shot (void);
#endif /* UTIL_SCRSHOT_H */

View File

@ -64,6 +64,7 @@ enum { CURSOR_CROSS_ONE = 1,
CURSOR_BRUSH = 2 };
static int cursor_type;
static int cursor_negative;
static int saved_pixel[MAX_SAVED];
static int saved_pixel_n;
@ -102,10 +103,8 @@ void editor_draw_cursor(JWidget widget, int x, int y)
limit_region = jwidget_get_drawable_region(widget, JI_GDR_CUTTOPWINDOWS);
/* get cursor color */
if (is_cursor_mask())
color = -1;
else
color = get_raw_cursor_color();
cursor_negative = is_cursor_mask();
color = get_raw_cursor_color();
/* cursor in the screen (view) */
editor->cursor_screen_x = x;
@ -328,7 +327,7 @@ static void savepixel(BITMAP *bmp, int x, int y, int color)
static void drawpixel(BITMAP *bmp, int x, int y, int color)
{
if (saved_pixel_n < MAX_SAVED && point_inside_region(x, y)) {
if (color < 0) {
if (cursor_negative) {
int r, g, b, c = saved_pixel[saved_pixel_n++];
r = getr(c);

View File

@ -560,8 +560,8 @@ void editor_draw_grid(JWidget widget)
screen_to_editor(widget, x2, y2, &u2, &v2);
jrect_moveto(grid,
(grid->x1 % jrect_w(grid)) - jrect_w(grid),
(grid->y1 % jrect_h(grid)) - jrect_h(grid));
(grid->x1 % jrect_w(grid)) - jrect_w(grid),
(grid->y1 % jrect_h(grid)) - jrect_h(grid));
u1 = ((u1-grid->x1) / jrect_w(grid)) - 1;
v1 = ((v1-grid->y1) / jrect_h(grid)) - 1;

View File

@ -103,15 +103,13 @@ static bool menuitem_msg_proc(JWidget widget, JMessage msg)
if (menuitem->command) {
/* enabled? */
if (command_is_enabled(menuitem->command,
menuitem->argument))
if (command_is_enabled(menuitem->command, menuitem->argument))
jwidget_enable(widget);
else
jwidget_disable(widget);
/* selected? */
if (command_is_selected(menuitem->command,
menuitem->argument))
if (command_is_checked(menuitem->command, menuitem->argument))
jwidget_select(widget);
else
jwidget_deselect(widget);
@ -134,8 +132,7 @@ static bool menuitem_msg_proc(JWidget widget, JMessage msg)
if (menuitem->command && command_is_enabled(menuitem->command,
menuitem->argument)) {
command_execute(menuitem->command,
menuitem->argument);
command_execute(menuitem->command, menuitem->argument);
return TRUE;
}
}

View File

@ -386,7 +386,7 @@ static void button_command(JWidget widget, void *data)
break;
case ACTION_PLAY:
play_animation ();
play_animation();
break;
case ACTION_NEXT:
@ -465,7 +465,7 @@ static void play_animation(void)
LOCK_VARIABLE(speed_timer);
LOCK_FUNCTION(speed_timer_callback);
clear_keybuf ();
clear_keybuf();
/* clear all the screen */
clear_bitmap(ji_screen);
@ -480,10 +480,11 @@ static void play_animation(void)
editor_draw_sprite_safe(current_editor, 0, 0, sprite->w, sprite->h);
do {
poll_mouse ();
poll_keyboard ();
poll_mouse();
poll_keyboard();
if (keypressed() || mouse_b)
done = TRUE;
gui_feedback();
} while (!done && (speed_timer <= 0));
if (!done) {
@ -493,6 +494,7 @@ static void play_animation(void)
speed_timer--;
}
gui_feedback();
}
/* if right-click or ESC */
@ -503,6 +505,7 @@ static void play_animation(void)
/* refresh all */
set_current_palette(sprite_get_palette(sprite, sprite->frpos), TRUE);
jmanager_refresh_screen();
gui_feedback();
while (mouse_b)
poll_mouse();

View File

@ -25,7 +25,7 @@
#include "jinete/hook.h"
#include "jinete/widget.h"
#include "dialogs/toolconf.h"
#include "commands/commands.h"
#include "modules/gfx.h"
#include "modules/gui.h"
#include "modules/tools.h"
@ -71,8 +71,10 @@ JWidget tool_bar_new(int align)
if (align == JI_HORIZONTAL)
group = group_button_new(len, 1, c, ICONS_LIST);
else
else {
/* group = group_button_new(1, len, c, ICONS_LIST); */
group = group_button_new(1, len, c, ICONS_LIST);
}
jwidget_expansive(box, TRUE);
jwidget_expansive(fillbox, TRUE);
@ -106,12 +108,12 @@ static int group_change_signal(JWidget widget, int user_data)
int c = group_button_get_selected(widget);
if (current_tool != ase_tools_list[c])
select_tool(ase_tools_list[c]->name);
select_tool(ase_tools_list[c]);
return FALSE;
}
static void conf_command(JWidget widget)
{
dialogs_tools_configuration();
command_execute(command_get_by_name(CMD_CONFIGURE_TOOLS), NULL);
}