mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-09 18:44:46 +00:00
Internal refactoring of commands to support record/play macros in the near future.
This commit is contained in:
parent
33baa4fd5c
commit
5455136f35
@ -1,3 +1,8 @@
|
|||||||
|
2009-10-08 David Capello <davidcapello@gmail.com>
|
||||||
|
|
||||||
|
* Completelly refactored all the commands related stuff. This is
|
||||||
|
the beginning to implement macro recording.
|
||||||
|
|
||||||
2009-09-03 David Capello <davidcapello@gmail.com>
|
2009-09-03 David Capello <davidcapello@gmail.com>
|
||||||
|
|
||||||
* Version 0.7.2 released.
|
* Version 0.7.2 released.
|
||||||
|
35
HACKING.txt
35
HACKING.txt
@ -2,14 +2,34 @@
|
|||||||
ASE Hacking Notes
|
ASE Hacking Notes
|
||||||
======================================================================
|
======================================================================
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
Change the name of a command
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Rename the file "src/commands/cmd_OLD_NAME.cpp" to
|
||||||
|
"src/commands/cmd_NEW_NAME.cpp".
|
||||||
|
|
||||||
|
Update the file name in the COMMON_SOURCES variable inside
|
||||||
|
makefile.lst.
|
||||||
|
|
||||||
|
Update the command name in "src/commands/commands_list.h" file.
|
||||||
|
|
||||||
|
Find "get_command_by_name" in the whole source code, you have to
|
||||||
|
update the command id (anyway you will get a compiler error).
|
||||||
|
|
||||||
|
Change in the Command() constructor call, the name of the command.
|
||||||
|
E.g. MyCmd::MyCmd() : Command("new_name", ...) { }
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
Add a new file to compile
|
Add a new file to compile
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Remember that if you add a new file to compile, it should have a
|
Remember that if you add a new file to compile, it should have a
|
||||||
different name of any other file name in the source code tree. Also,
|
different name of any other file name in the source code tree. Also,
|
||||||
you must add it in the ASE_SOURCES variable of the makefile.lst.
|
you must add it in the COMMON_SOURCES or ASE_SOURCES variable of the
|
||||||
|
makefile.lst.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
Add a new load/save file type
|
Add a new load/save file type
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
@ -29,7 +49,7 @@ Add a new load/save file type
|
|||||||
(src/raster/) if your format support animation or layers, like FLI,
|
(src/raster/) if your format support animation or layers, like FLI,
|
||||||
or GIF formats.
|
or GIF formats.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
Hook palette's changes
|
Hook palette's changes
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
@ -45,7 +65,7 @@ Hook palette's changes
|
|||||||
"call_palette_hooks" will call the hooks from the first to the last
|
"call_palette_hooks" will call the hooks from the first to the last
|
||||||
one.
|
one.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
Update the icon of buttons when the bitmap is destroyed in palette changes
|
Update the icon of buttons when the bitmap is destroyed in palette changes
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
@ -70,7 +90,7 @@ Update the icon of buttons when the bitmap is destroyed in palette changes
|
|||||||
automatically this button from the "list of buttons to fixup"
|
automatically this button from the "list of buttons to fixup"
|
||||||
("icon_buttons" in "src/modules/gui.c").
|
("icon_buttons" in "src/modules/gui.c").
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
Reload the fonts
|
Reload the fonts
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
@ -83,7 +103,7 @@ Reload the fonts
|
|||||||
This routine uses the "_ji_set_font_of_all_widgets" to change the
|
This routine uses the "_ji_set_font_of_all_widgets" to change the
|
||||||
"text_font" property of EVERY widget.
|
"text_font" property of EVERY widget.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
Undo
|
Undo
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
@ -98,6 +118,5 @@ Undo
|
|||||||
stock_add_image(stock, image);
|
stock_add_image(stock, image);
|
||||||
undo_add_image(undo, stock, image);
|
undo_add_image(undo, stock, image);
|
||||||
|
|
||||||
|
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
Copyright (C) 2003-2005 by David A. Capello
|
Copyright (C) 2001-2009 David Capello
|
||||||
|
6
NEWS.txt
6
NEWS.txt
@ -2,6 +2,12 @@
|
|||||||
NEWS
|
NEWS
|
||||||
===================================
|
===================================
|
||||||
|
|
||||||
|
0.8
|
||||||
|
---
|
||||||
|
|
||||||
|
+ Internal refactoring of commands to support record/play macros in
|
||||||
|
the near future.
|
||||||
|
|
||||||
0.7.2
|
0.7.2
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
2
config.h
2
config.h
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
/* general information */
|
/* general information */
|
||||||
#define PACKAGE "ASE"
|
#define PACKAGE "ASE"
|
||||||
#define VERSION "0.7.2"
|
#define VERSION "0.8"
|
||||||
#define WEBSITE "http://www.aseprite.org/"
|
#define WEBSITE "http://www.aseprite.org/"
|
||||||
#define COPYRIGHT "Copyright (C) 2001-2009 David Capello"
|
#define COPYRIGHT "Copyright (C) 2001-2009 David Capello"
|
||||||
|
|
||||||
|
@ -22,8 +22,14 @@
|
|||||||
<key command="copy" shortcut="Ctrl+C" /> <key command="copy" shortcut="Ctrl+Ins" />
|
<key command="copy" shortcut="Ctrl+C" /> <key command="copy" shortcut="Ctrl+Ins" />
|
||||||
<key command="paste" shortcut="Ctrl+V" /> <key command="paste" shortcut="Shift+Ins" />
|
<key command="paste" shortcut="Ctrl+V" /> <key command="paste" shortcut="Shift+Ins" />
|
||||||
<key command="clear" shortcut="Ctrl+B" /> <key command="clear" shortcut="Ctrl+Del" />
|
<key command="clear" shortcut="Ctrl+B" /> <key command="clear" shortcut="Ctrl+Del" />
|
||||||
<key command="flip" shortcut="Shift+H" argument="mask horizontal" />
|
<key command="flip" shortcut="Shift+H">
|
||||||
<key command="flip" shortcut="Shift+V" argument="mask vertical" />
|
<param name="target" value="mask" />
|
||||||
|
<param name="orientation" value="horizontal" />
|
||||||
|
</key>
|
||||||
|
<key command="flip" shortcut="Shift+V">
|
||||||
|
<param name="target" value="mask" />
|
||||||
|
<param name="orientation" value="vertical" />
|
||||||
|
</key>
|
||||||
<key command="replace_color" shortcut="Shift+R" />
|
<key command="replace_color" shortcut="Shift+R" />
|
||||||
<key command="invert_color" shortcut="Ctrl+I" />
|
<key command="invert_color" shortcut="Ctrl+I" />
|
||||||
<!-- sprite -->
|
<!-- sprite -->
|
||||||
@ -118,8 +124,14 @@
|
|||||||
<item command="paste" name="&Paste" />
|
<item command="paste" name="&Paste" />
|
||||||
<item command="clear" name="C&lear" />
|
<item command="clear" name="C&lear" />
|
||||||
<separator />
|
<separator />
|
||||||
<item command="flip" name="Flip &Horizontal" argument="mask horizontal" />
|
<item command="flip" name="Flip &Horizontal">
|
||||||
<item command="flip" name="Flip &Vertical" argument="mask vertical" />
|
<param name="target" value="mask" />
|
||||||
|
<param name="orientation" value="horizontal" />
|
||||||
|
</item>
|
||||||
|
<item command="flip" name="Flip &Vertical">
|
||||||
|
<param name="target" value="mask" />
|
||||||
|
<param name="orientation" value="vertical" />
|
||||||
|
</item>
|
||||||
<separator />
|
<separator />
|
||||||
<item command="replace_color" name="R&eplace Color..." />
|
<item command="replace_color" name="R&eplace Color..." />
|
||||||
<item command="invert_color" name="&Invert" />
|
<item command="invert_color" name="&Invert" />
|
||||||
@ -127,10 +139,19 @@
|
|||||||
<menu name="&Sprite">
|
<menu name="&Sprite">
|
||||||
<item command="sprite_properties" name="&Properties..." />
|
<item command="sprite_properties" name="&Properties..." />
|
||||||
<menu name name="Color &Mode">
|
<menu name name="Color &Mode">
|
||||||
<item command="change_image_type" name="&RGB Color" argument="rgb" />
|
<item command="change_image_type" name="&RGB Color">
|
||||||
<item command="change_image_type" name="&Grayscale" argument="grayscale" />
|
<param name="imgtype" value="rgb" />
|
||||||
<item command="change_image_type" name="&Indexed (No Dithering)" argument="indexed" />
|
</item>
|
||||||
<item command="change_image_type" name="Indexed (Ordered &Dither)" argument="indexed-dither" />
|
<item command="change_image_type" name="&Grayscale">
|
||||||
|
<param name="imgtype" value="grayscale" />
|
||||||
|
</item>
|
||||||
|
<item command="change_image_type" name="&Indexed (No Dithering)">
|
||||||
|
<param name="imgtype" value="indexed" />
|
||||||
|
</item>
|
||||||
|
<item command="change_image_type" name="Indexed (Ordered &Dither)">
|
||||||
|
<param name="imgtype" value="indexed" />
|
||||||
|
<param name="dithering" value="on" />
|
||||||
|
</item>
|
||||||
</menu>
|
</menu>
|
||||||
<separator />
|
<separator />
|
||||||
<item command="duplicate_sprite" name="&Duplicate..." />
|
<item command="duplicate_sprite" name="&Duplicate..." />
|
||||||
@ -138,12 +159,24 @@
|
|||||||
<item command="sprite_size" name="&Sprite Size..." />
|
<item command="sprite_size" name="&Sprite Size..." />
|
||||||
<item command="canvas_size" name="&Canvas Size..." />
|
<item command="canvas_size" name="&Canvas Size..." />
|
||||||
<menu name name="&Rotate Canvas">
|
<menu name name="&Rotate Canvas">
|
||||||
<item command="rotate_canvas" name="180" argument="180" />
|
<item command="rotate_canvas" name="180">
|
||||||
<item command="rotate_canvas" name="90 CW" argument="90" />
|
<param name="angle" value="180" />
|
||||||
<item command="rotate_canvas" name="90 CCW" argument="-90" />
|
</item>
|
||||||
|
<item command="rotate_canvas" name="90 CW">
|
||||||
|
<param name="angle" value="90" />
|
||||||
|
</item>
|
||||||
|
<item command="rotate_canvas" name="90 CCW">
|
||||||
|
<param name="angle" value="-90" />
|
||||||
|
</item>
|
||||||
<separator />
|
<separator />
|
||||||
<item command="flip" name="Flip Canvas &Horizontal" argument="canvas horizontal" />
|
<item command="flip" name="Flip Canvas &Horizontal">
|
||||||
<item command="flip" name="Flip Canvas &Vertical" argument="canvas vertical" />
|
<param name="target" value="canvas" />
|
||||||
|
<param name="orientation" value="horizontal" />
|
||||||
|
</item>
|
||||||
|
<item command="flip" name="Flip Canvas &Vertical">
|
||||||
|
<param name="target" value="canvas" />
|
||||||
|
<param name="orientation" value="vertical" />
|
||||||
|
</item>
|
||||||
</menu>
|
</menu>
|
||||||
<separator />
|
<separator />
|
||||||
<item command="crop_sprite" name="Cr&op" />
|
<item command="crop_sprite" name="Cr&op" />
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
\palette ase.pcx
|
\palette ase.pcx
|
||||||
\image ase.pcx
|
\image ase.pcx
|
||||||
|
|
||||||
Welcome to ASE 0.7.2
|
Welcome to ASE 0.8
|
||||||
|
|
||||||
READ THIS!
|
READ THIS!
|
||||||
|
|
||||||
|
@ -71,6 +71,7 @@ COMMON_SOURCES = \
|
|||||||
src/commands/cmd_switch_colors.cpp \
|
src/commands/cmd_switch_colors.cpp \
|
||||||
src/commands/cmd_tips.cpp \
|
src/commands/cmd_tips.cpp \
|
||||||
src/commands/cmd_undo.cpp \
|
src/commands/cmd_undo.cpp \
|
||||||
|
src/commands/command.cpp \
|
||||||
src/commands/commands.cpp \
|
src/commands/commands.cpp \
|
||||||
src/commands/fx/cmd_color_curve.cpp \
|
src/commands/fx/cmd_color_curve.cpp \
|
||||||
src/commands/fx/cmd_convolution_matrix.cpp \
|
src/commands/fx/cmd_convolution_matrix.cpp \
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
|
|
||||||
dir="`pwd`"
|
dir="`pwd`"
|
||||||
version=0.7.2
|
version=0.8
|
||||||
distdir=ase-$version
|
distdir=ase-$version
|
||||||
|
|
||||||
freetype_files="third_party/freetype/ChangeLog \
|
freetype_files="third_party/freetype/ChangeLog \
|
||||||
|
@ -22,14 +22,35 @@
|
|||||||
|
|
||||||
#include "jinete/jinete.h"
|
#include "jinete/jinete.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
#include "core/dirs.h"
|
#include "core/dirs.h"
|
||||||
#include "modules/gui.h"
|
#include "modules/gui.h"
|
||||||
|
|
||||||
static char *read_authors_txt(const char *filename);
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// about
|
||||||
|
|
||||||
static void cmd_about_execute(const char *argument)
|
class AboutCommand : public Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AboutCommand();
|
||||||
|
Command* clone() const { return new AboutCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void execute(Context* context);
|
||||||
|
|
||||||
|
private:
|
||||||
|
static char* read_authors_txt(const char *filename);
|
||||||
|
};
|
||||||
|
|
||||||
|
AboutCommand::AboutCommand()
|
||||||
|
: Command("about",
|
||||||
|
"About",
|
||||||
|
CmdUIOnlyFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void AboutCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
JWidget box1, label1, label2, separator1;
|
JWidget box1, label1, label2, separator1;
|
||||||
JWidget textbox, view, separator2;
|
JWidget textbox, view, separator2;
|
||||||
@ -90,7 +111,7 @@ static void cmd_about_execute(const char *argument)
|
|||||||
jwindow_open_fg(window);
|
jwindow_open_fg(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *read_authors_txt(const char *filename)
|
char* AboutCommand::read_authors_txt(const char *filename)
|
||||||
{
|
{
|
||||||
DIRS *dirs, *dir;
|
DIRS *dirs, *dir;
|
||||||
char *txt = NULL;
|
char *txt = NULL;
|
||||||
@ -128,9 +149,10 @@ static char *read_authors_txt(const char *filename)
|
|||||||
return txt;
|
return txt;
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_about = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_ABOUT,
|
// CommandFactory
|
||||||
NULL,
|
|
||||||
NULL,
|
Command* CommandFactory::create_about_command()
|
||||||
cmd_about_execute,
|
{
|
||||||
};
|
return new AboutCommand;
|
||||||
|
}
|
||||||
|
@ -20,14 +20,34 @@
|
|||||||
|
|
||||||
#include "jinete/jinete.h"
|
#include "jinete/jinete.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "core/app.h"
|
#include "core/app.h"
|
||||||
#include "core/cfg.h"
|
#include "core/cfg.h"
|
||||||
#include "modules/gui.h"
|
#include "modules/gui.h"
|
||||||
|
|
||||||
static bool advanced_mode = FALSE;
|
class AdvancedModeCommand : public Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AdvancedModeCommand();
|
||||||
|
Command* clone() const { return new AdvancedModeCommand(*this); }
|
||||||
|
|
||||||
static void cmd_advanced_mode_execute(const char *argument)
|
protected:
|
||||||
|
void execute(Context* context);
|
||||||
|
|
||||||
|
private:
|
||||||
|
static bool advanced_mode;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool AdvancedModeCommand::advanced_mode = false;
|
||||||
|
|
||||||
|
AdvancedModeCommand::AdvancedModeCommand()
|
||||||
|
: Command("advanced_mode",
|
||||||
|
"Advanced Mode",
|
||||||
|
CmdUIOnlyFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void AdvancedModeCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
advanced_mode = !advanced_mode;
|
advanced_mode = !advanced_mode;
|
||||||
|
|
||||||
@ -51,8 +71,7 @@ static void cmd_advanced_mode_execute(const char *argument)
|
|||||||
|
|
||||||
if (advanced_mode &&
|
if (advanced_mode &&
|
||||||
get_config_bool("AdvancedMode", "Warning", true)) {
|
get_config_bool("AdvancedMode", "Warning", true)) {
|
||||||
Command* cmd_advanced_mode = command_get_by_name(CMD_ADVANCED_MODE);
|
JAccel accel = get_accel_to_execute_command(short_name());
|
||||||
JAccel accel = get_accel_to_execute_command(cmd_advanced_mode, NULL);
|
|
||||||
if (accel != NULL) {
|
if (accel != NULL) {
|
||||||
char warning[1024];
|
char warning[1024];
|
||||||
char key[1024];
|
char key[1024];
|
||||||
@ -76,9 +95,10 @@ static void cmd_advanced_mode_execute(const char *argument)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_advanced_mode = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_ADVANCED_MODE,
|
// CommandFactory
|
||||||
NULL,
|
|
||||||
NULL,
|
Command* CommandFactory::create_advanced_mode_command()
|
||||||
cmd_advanced_mode_execute,
|
{
|
||||||
};
|
return new AdvancedModeCommand;
|
||||||
|
}
|
||||||
|
@ -18,17 +18,35 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "core/app.h"
|
|
||||||
#include "modules/gui.h"
|
#include "modules/gui.h"
|
||||||
#include "raster/layer.h"
|
#include "raster/layer.h"
|
||||||
#include "raster/sprite.h"
|
#include "raster/sprite.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
#include "undoable.h"
|
#include "undoable.h"
|
||||||
#include "widgets/colbar.h"
|
#include "widgets/colbar.h"
|
||||||
|
|
||||||
static bool cmd_background_from_layer_enabled(const char *argument)
|
class BackgroundFromLayerCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
BackgroundFromLayerCommand();
|
||||||
|
Command* clone() const { return new BackgroundFromLayerCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
BackgroundFromLayerCommand::BackgroundFromLayerCommand()
|
||||||
|
: Command("background_from_layer",
|
||||||
|
"BackgroundFromLayer",
|
||||||
|
CmdRecordableFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BackgroundFromLayerCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return
|
return
|
||||||
sprite != NULL &&
|
sprite != NULL &&
|
||||||
sprite->layer != NULL &&
|
sprite->layer != NULL &&
|
||||||
@ -38,13 +56,13 @@ static bool cmd_background_from_layer_enabled(const char *argument)
|
|||||||
layer_is_writable(sprite->layer);
|
layer_is_writable(sprite->layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_background_from_layer_execute(const char *argument)
|
void BackgroundFromLayerCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
CurrentSpriteWriter sprite;
|
CurrentSpriteWriter sprite(context);
|
||||||
|
|
||||||
// each frame of the layer to be converted as `Background' must be
|
// each frame of the layer to be converted as `Background' must be
|
||||||
// cleared using the selected background color in the color-bar
|
// cleared using the selected background color in the color-bar
|
||||||
int bgcolor = app_get_bg_color(sprite);
|
int bgcolor = context->get_bg_color();
|
||||||
bgcolor = fixup_color_for_background(sprite->imgtype, bgcolor);
|
bgcolor = fixup_color_for_background(sprite->imgtype, bgcolor);
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -55,9 +73,10 @@ static void cmd_background_from_layer_execute(const char *argument)
|
|||||||
update_screen_for_sprite(sprite);
|
update_screen_for_sprite(sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_background_from_layer = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_BACKGROUND_FROM_LAYER,
|
// CommandFactory
|
||||||
cmd_background_from_layer_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_background_from_layer_command()
|
||||||
cmd_background_from_layer_execute,
|
{
|
||||||
};
|
return new BackgroundFromLayerCommand;
|
||||||
|
}
|
||||||
|
@ -22,67 +22,104 @@
|
|||||||
|
|
||||||
#include "jinete/jinete.h"
|
#include "jinete/jinete.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "core/app.h"
|
|
||||||
#include "modules/gui.h"
|
#include "modules/gui.h"
|
||||||
#include "raster/image.h"
|
#include "raster/image.h"
|
||||||
#include "raster/mask.h"
|
#include "raster/mask.h"
|
||||||
#include "raster/sprite.h"
|
#include "raster/sprite.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
#include "undoable.h"
|
#include "undoable.h"
|
||||||
#include "widgets/colbar.h"
|
#include "widgets/colbar.h"
|
||||||
|
|
||||||
static bool cmd_canvas_size_enabled(const char *argument)
|
class CanvasSizeCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
int m_left, m_right, m_top, m_bottom;
|
||||||
|
|
||||||
|
public:
|
||||||
|
CanvasSizeCommand();
|
||||||
|
Command* clone() const { return new CanvasSizeCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
CanvasSizeCommand::CanvasSizeCommand()
|
||||||
|
: Command("canvas_size",
|
||||||
|
"Canvas Size",
|
||||||
|
CmdRecordableFlag)
|
||||||
|
{
|
||||||
|
m_left = m_right = m_top = m_bottom = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CanvasSizeCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return sprite != NULL;
|
return sprite != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_canvas_size_execute(const char *argument)
|
void CanvasSizeCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
JWidget left, top, right, bottom, ok;
|
CurrentSpriteWriter sprite(context);
|
||||||
CurrentSpriteWriter sprite;
|
|
||||||
|
|
||||||
// load the window widget
|
if (context->is_ui_available()) {
|
||||||
JWidgetPtr window(load_widget("canvas.jid", "canvas_size"));
|
JWidget left, top, right, bottom, ok;
|
||||||
get_widgets(window,
|
|
||||||
"left", &left,
|
|
||||||
"top", &top,
|
|
||||||
"right", &right,
|
|
||||||
"bottom", &bottom,
|
|
||||||
"ok", &ok, NULL);
|
|
||||||
|
|
||||||
jwindow_remap(window);
|
// load the window widget
|
||||||
jwindow_center(window);
|
JWidgetPtr window(load_widget("canvas.jid", "canvas_size"));
|
||||||
|
get_widgets(window,
|
||||||
|
"left", &left,
|
||||||
|
"top", &top,
|
||||||
|
"right", &right,
|
||||||
|
"bottom", &bottom,
|
||||||
|
"ok", &ok, NULL);
|
||||||
|
|
||||||
load_window_pos(window, "CanvasSize");
|
jwindow_remap(window);
|
||||||
jwidget_show(window);
|
jwindow_center(window);
|
||||||
jwindow_open_fg(window);
|
|
||||||
save_window_pos(window, "CanvasSize");
|
|
||||||
|
|
||||||
if (jwindow_get_killer(window) == ok) {
|
left->textf("%d", m_left);
|
||||||
int x1 = -left->text_int();
|
right->textf("%d", m_right);
|
||||||
int y1 = -top->text_int();
|
top->textf("%d", m_top);
|
||||||
int x2 = sprite->w + right->text_int();
|
bottom->textf("%d", m_bottom);
|
||||||
int y2 = sprite->h + bottom->text_int();
|
|
||||||
|
|
||||||
if (x2 <= x1) x2 = x1+1;
|
load_window_pos(window, "CanvasSize");
|
||||||
if (y2 <= y1) y2 = y1+1;
|
jwidget_show(window);
|
||||||
|
jwindow_open_fg(window);
|
||||||
|
save_window_pos(window, "CanvasSize");
|
||||||
|
|
||||||
{
|
if (jwindow_get_killer(window) != ok)
|
||||||
Undoable undoable(sprite, "Canvas Size");
|
return;
|
||||||
int bgcolor = get_color_for_image(sprite->imgtype,
|
|
||||||
colorbar_get_bg_color(app_get_colorbar()));
|
m_left = left->text_int();
|
||||||
undoable.crop_sprite(x1, y1, x2-x1, y2-y1, bgcolor);
|
m_right = right->text_int();
|
||||||
undoable.commit();
|
m_top = top->text_int();
|
||||||
}
|
m_bottom = bottom->text_int();
|
||||||
sprite_generate_mask_boundaries(sprite);
|
|
||||||
update_screen_for_sprite(sprite);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// resize canvas
|
||||||
|
|
||||||
|
int x1 = -m_left;
|
||||||
|
int y1 = -m_top;
|
||||||
|
int x2 = sprite->w + m_right;
|
||||||
|
int y2 = sprite->h + m_bottom;
|
||||||
|
|
||||||
|
if (x2 <= x1) x2 = x1+1;
|
||||||
|
if (y2 <= y1) y2 = y1+1;
|
||||||
|
|
||||||
|
{
|
||||||
|
Undoable undoable(sprite, "Canvas Size");
|
||||||
|
int bgcolor = context->get_bg_color();
|
||||||
|
undoable.crop_sprite(x1, y1, x2-x1, y2-y1, bgcolor);
|
||||||
|
undoable.commit();
|
||||||
|
}
|
||||||
|
sprite_generate_mask_boundaries(sprite);
|
||||||
|
update_screen_for_sprite(sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_canvas_size = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_CANVAS_SIZE,
|
// CommandFactory
|
||||||
cmd_canvas_size_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_canvas_size_command()
|
||||||
cmd_canvas_size_execute,
|
{
|
||||||
};
|
return new CanvasSizeCommand;
|
||||||
|
}
|
||||||
|
@ -22,7 +22,8 @@
|
|||||||
|
|
||||||
#include "jinete/jinete.h"
|
#include "jinete/jinete.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
#include "core/app.h"
|
#include "core/app.h"
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
#include "modules/gui.h"
|
#include "modules/gui.h"
|
||||||
@ -33,13 +34,31 @@
|
|||||||
#include "raster/stock.h"
|
#include "raster/stock.h"
|
||||||
#include "raster/undo.h"
|
#include "raster/undo.h"
|
||||||
|
|
||||||
static bool cmd_cel_properties_enabled(const char *argument)
|
class CelPropertiesCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
CelPropertiesCommand();
|
||||||
|
Command* clone() const { return new CelPropertiesCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
CelPropertiesCommand::CelPropertiesCommand()
|
||||||
|
: Command("cel_properties",
|
||||||
|
"Cel Properties",
|
||||||
|
CmdUIOnlyFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CelPropertiesCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return sprite && sprite->layer;
|
return sprite && sprite->layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_cel_properties_execute(const char *argument)
|
void CelPropertiesCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
JWidget label_frame, label_pos, label_size;
|
JWidget label_frame, label_pos, label_size;
|
||||||
JWidget slider_opacity, button_ok;
|
JWidget slider_opacity, button_ok;
|
||||||
@ -49,7 +68,7 @@ static void cmd_cel_properties_execute(const char *argument)
|
|||||||
int memsize;
|
int memsize;
|
||||||
|
|
||||||
/* get current sprite */
|
/* get current sprite */
|
||||||
const CurrentSpriteReader sprite;
|
const CurrentSpriteReader sprite(context);
|
||||||
if (!sprite)
|
if (!sprite)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -135,9 +154,10 @@ static void cmd_cel_properties_execute(const char *argument)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_cel_properties = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_CEL_PROPERTIES,
|
// CommandFactory
|
||||||
cmd_cel_properties_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_cel_properties_command()
|
||||||
cmd_cel_properties_execute,
|
{
|
||||||
};
|
return new CelPropertiesCommand;
|
||||||
|
}
|
||||||
|
@ -20,58 +20,77 @@
|
|||||||
|
|
||||||
#include <allegro/unicode.h>
|
#include <allegro/unicode.h>
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
|
#include "commands/params.h"
|
||||||
#include "core/app.h"
|
#include "core/app.h"
|
||||||
#include "modules/gui.h"
|
#include "modules/gui.h"
|
||||||
#include "modules/palettes.h"
|
#include "modules/palettes.h"
|
||||||
#include "raster/image.h"
|
#include "raster/image.h"
|
||||||
#include "raster/quant.h"
|
#include "raster/quant.h"
|
||||||
#include "raster/sprite.h"
|
#include "raster/sprite.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
#include "undoable.h"
|
#include "undoable.h"
|
||||||
|
|
||||||
static bool cmd_change_image_type_enabled(const char *argument)
|
class ChangeImageTypeCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
int m_imgtype;
|
||||||
return
|
bool m_dithering;
|
||||||
sprite != NULL &&
|
public:
|
||||||
((ustrcmp(argument, "rgb") == 0 && sprite->imgtype != IMAGE_RGB) ||
|
ChangeImageTypeCommand();
|
||||||
(ustrcmp(argument, "grayscale") == 0 && sprite->imgtype != IMAGE_GRAYSCALE) ||
|
Command* clone() const { return new ChangeImageTypeCommand(*this); }
|
||||||
(ustrncmp(argument, "indexed", 7) == 0 && sprite->imgtype != IMAGE_INDEXED));
|
|
||||||
|
protected:
|
||||||
|
void load_params(Params* params);
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
ChangeImageTypeCommand::ChangeImageTypeCommand()
|
||||||
|
: Command("change_image_type",
|
||||||
|
"Change Image Type",
|
||||||
|
CmdUIOnlyFlag)
|
||||||
|
{
|
||||||
|
m_imgtype = IMAGE_RGB;
|
||||||
|
m_dithering = DITHERING_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_change_image_type_execute(const char *argument)
|
void ChangeImageTypeCommand::load_params(Params* params)
|
||||||
{
|
{
|
||||||
CurrentSpriteWriter sprite;
|
std::string imgtype = params->get("imgtype");
|
||||||
int destimgtype = sprite->imgtype;
|
if (imgtype == "rgb") m_imgtype = IMAGE_RGB;
|
||||||
int dithermethod = DITHERING_NONE;
|
else if (imgtype == "grayscale") m_imgtype = IMAGE_GRAYSCALE;
|
||||||
|
else if (imgtype == "indexed") m_imgtype = IMAGE_INDEXED;
|
||||||
|
|
||||||
if (ustrcmp(argument, "rgb") == 0) {
|
std::string dithering = params->get("dithering");
|
||||||
destimgtype = IMAGE_RGB;
|
if (dithering == "ordered")
|
||||||
}
|
m_dithering = DITHERING_ORDERED;
|
||||||
else if (ustrcmp(argument, "grayscale") == 0) {
|
else
|
||||||
destimgtype = IMAGE_GRAYSCALE;
|
m_dithering = DITHERING_NONE;
|
||||||
}
|
}
|
||||||
else if (ustrcmp(argument, "indexed") == 0) {
|
|
||||||
destimgtype = IMAGE_INDEXED;
|
|
||||||
}
|
|
||||||
else if (ustrcmp(argument, "indexed-dither") == 0) {
|
|
||||||
destimgtype = IMAGE_INDEXED;
|
|
||||||
dithermethod = DITHERING_ORDERED;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
bool ChangeImageTypeCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
|
return
|
||||||
|
sprite != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChangeImageTypeCommand::execute(Context* context)
|
||||||
|
{
|
||||||
|
CurrentSpriteWriter sprite(context);
|
||||||
{
|
{
|
||||||
CurrentSpriteRgbMap rgbmap;
|
CurrentSpriteRgbMap rgbmap;
|
||||||
Undoable undoable(sprite, "Color Mode Change");
|
Undoable undoable(sprite, "Color Mode Change");
|
||||||
undoable.set_imgtype(destimgtype, dithermethod);
|
undoable.set_imgtype(m_imgtype, m_dithering);
|
||||||
undoable.commit();
|
undoable.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
app_refresh_screen(sprite);
|
app_refresh_screen(sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_change_image_type = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_CHANGE_IMAGE_TYPE,
|
// CommandFactory
|
||||||
cmd_change_image_type_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_change_image_type_command()
|
||||||
cmd_change_image_type_execute,
|
{
|
||||||
};
|
return new ChangeImageTypeCommand;
|
||||||
|
}
|
||||||
|
@ -18,7 +18,8 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
#include "core/app.h"
|
#include "core/app.h"
|
||||||
#include "modules/gui.h"
|
#include "modules/gui.h"
|
||||||
#include "raster/layer.h"
|
#include "raster/layer.h"
|
||||||
@ -27,9 +28,30 @@
|
|||||||
#include "undoable.h"
|
#include "undoable.h"
|
||||||
#include "widgets/colbar.h"
|
#include "widgets/colbar.h"
|
||||||
|
|
||||||
static bool cmd_clear_enabled(const char *argument)
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// ClearCommand
|
||||||
|
|
||||||
|
class ClearCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
ClearCommand();
|
||||||
|
Command* clone() const { return new ClearCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
ClearCommand::ClearCommand()
|
||||||
|
: Command("clear",
|
||||||
|
"Clear",
|
||||||
|
CmdUIOnlyFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ClearCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return
|
return
|
||||||
sprite != NULL &&
|
sprite != NULL &&
|
||||||
sprite->layer != NULL &&
|
sprite->layer != NULL &&
|
||||||
@ -38,9 +60,9 @@ static bool cmd_clear_enabled(const char *argument)
|
|||||||
layer_is_writable(sprite->layer);
|
layer_is_writable(sprite->layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_clear_execute(const char *argument)
|
void ClearCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
CurrentSpriteWriter sprite;
|
CurrentSpriteWriter sprite(context);
|
||||||
{
|
{
|
||||||
Undoable undoable(sprite, "Clear");
|
Undoable undoable(sprite, "Clear");
|
||||||
undoable.clear_mask(app_get_color_to_clear_layer(sprite->layer));
|
undoable.clear_mask(app_get_color_to_clear_layer(sprite->layer));
|
||||||
@ -49,9 +71,10 @@ static void cmd_clear_execute(const char *argument)
|
|||||||
update_screen_for_sprite(sprite);
|
update_screen_for_sprite(sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_clear = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_CLEAR,
|
// CommandFactory
|
||||||
cmd_clear_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_clear_command()
|
||||||
cmd_clear_execute,
|
{
|
||||||
};
|
return new ClearCommand;
|
||||||
|
}
|
||||||
|
@ -18,61 +18,98 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
#include <allegro.h>
|
#include <allegro.h>
|
||||||
#include "jinete/jinete.h"
|
#include "jinete/jinete.h"
|
||||||
|
|
||||||
#include "ui_context.h"
|
#include "commands/command.h"
|
||||||
#include "commands/commands.h"
|
#include "commands/commands.h"
|
||||||
#include "core/app.h"
|
#include "core/app.h"
|
||||||
|
#include "modules/editors.h"
|
||||||
#include "raster/sprite.h"
|
#include "raster/sprite.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
#include "ui_context.h"
|
||||||
|
|
||||||
static bool close_current_sprite();
|
static bool close_current_sprite(Context* context);
|
||||||
|
|
||||||
/* ======================== */
|
//////////////////////////////////////////////////////////////////////
|
||||||
/* close_file */
|
// close_file
|
||||||
/* ======================== */
|
|
||||||
|
|
||||||
static bool cmd_close_file_enabled(const char *argument)
|
class CloseFileCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
return sprite != NULL;
|
CloseFileCommand()
|
||||||
}
|
: Command("close_file",
|
||||||
|
"Close File",
|
||||||
|
CmdUIOnlyFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
static void cmd_close_file_execute(const char *argument)
|
Command* clone() const { return new CloseFileCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
bool enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
|
return sprite != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void execute(Context* context)
|
||||||
|
{
|
||||||
|
close_current_sprite(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
static char* read_authors_txt(const char *filename);
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// close_all_files
|
||||||
|
|
||||||
|
class CloseAllFilesCommand : public Command
|
||||||
{
|
{
|
||||||
close_current_sprite();
|
public:
|
||||||
}
|
CloseAllFilesCommand()
|
||||||
|
: Command("close_all_files",
|
||||||
|
"Close All Files",
|
||||||
|
CmdRecordableFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/* ======================== */
|
Command* clone() const { return new CloseAllFilesCommand(*this); }
|
||||||
/* close_all_files */
|
|
||||||
/* ======================== */
|
|
||||||
|
|
||||||
static bool cmd_close_all_files_enabled(const char *argument)
|
protected:
|
||||||
{
|
|
||||||
return !UIContext::instance()->get_sprite_list().empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void cmd_close_all_files_execute(const char *argument)
|
bool enabled(Context* context)
|
||||||
{
|
{
|
||||||
UIContext* context = UIContext::instance();
|
return !context->get_sprite_list().empty();
|
||||||
if (!context->get_current_sprite())
|
}
|
||||||
context->show_sprite(context->get_first_sprite());
|
|
||||||
|
|
||||||
while (true) {
|
void execute(Context* context)
|
||||||
if (context->get_current_sprite() != NULL) {
|
{
|
||||||
if (!close_current_sprite())
|
if (!context->get_current_sprite())
|
||||||
|
set_sprite_in_more_reliable_editor(context->get_first_sprite());
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
if (context->get_current_sprite() != NULL) {
|
||||||
|
if (!close_current_sprite(context))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Closes the current sprite, asking to the user if to save it if it's
|
* Closes the current sprite, asking to the user if to save it if it's
|
||||||
* modified.
|
* modified.
|
||||||
*/
|
*/
|
||||||
static bool close_current_sprite()
|
static bool close_current_sprite(Context* context)
|
||||||
{
|
{
|
||||||
bool save_it;
|
bool save_it;
|
||||||
|
|
||||||
@ -81,27 +118,27 @@ try_again:;
|
|||||||
save_it = false;
|
save_it = false;
|
||||||
{
|
{
|
||||||
// The sprite is locked as reader temporaly
|
// The sprite is locked as reader temporaly
|
||||||
CurrentSpriteReader sprite;
|
CurrentSpriteReader sprite(context);
|
||||||
|
|
||||||
/* see if the sprite has changes */
|
// see if the sprite has changes
|
||||||
while (sprite_is_modified(sprite)) {
|
while (sprite_is_modified(sprite)) {
|
||||||
/* ask what want to do the user with the changes in the sprite */
|
// ask what want to do the user with the changes in the sprite
|
||||||
int ret = jalert("%s<<%s<<%s||%s||%s||%s",
|
int ret = jalert("%s<<%s<<%s||%s||%s||%s",
|
||||||
_("Warning"), _("Saving changes in:"),
|
_("Warning"), _("Saving changes in:"),
|
||||||
get_filename(sprite->filename),
|
get_filename(sprite->filename),
|
||||||
_("&Save"), _("&Discard"), _("&Cancel"));
|
_("&Save"), _("&Discard"), _("&Cancel"));
|
||||||
|
|
||||||
if (ret == 1) {
|
if (ret == 1) {
|
||||||
/* "save": save the changes */
|
// "save": save the changes
|
||||||
save_it = true;
|
save_it = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (ret != 2) {
|
else if (ret != 2) {
|
||||||
/* "cancel" or "ESC" */
|
// "cancel" or "ESC" */
|
||||||
return false; /* we back doing nothing */
|
return false; // we back doing nothing
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* "discard" */
|
// "discard"
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -109,29 +146,30 @@ try_again:;
|
|||||||
|
|
||||||
// Does we need to save the sprite?
|
// Does we need to save the sprite?
|
||||||
if (save_it) {
|
if (save_it) {
|
||||||
// TODO we have to pass the sprite to the save file command
|
Command* save_command =
|
||||||
command_execute(command_get_by_name(CMD_SAVE_FILE), NULL);
|
CommandsModule::instance()->get_command_by_name(CommandId::save_file);
|
||||||
|
context->execute_command(save_command);
|
||||||
|
|
||||||
goto try_again;
|
goto try_again;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destroy the sprite (locking it as writer)
|
// Destroy the sprite (locking it as writer)
|
||||||
{
|
{
|
||||||
CurrentSpriteWriter sprite;
|
CurrentSpriteWriter sprite(context);
|
||||||
sprite.destroy();
|
sprite.destroy();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_close_file = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_CLOSE_FILE,
|
// CommandFactory
|
||||||
cmd_close_file_enabled,
|
|
||||||
NULL,
|
|
||||||
cmd_close_file_execute,
|
|
||||||
};
|
|
||||||
|
|
||||||
Command cmd_close_all_files = {
|
Command* CommandFactory::create_close_file_command()
|
||||||
CMD_CLOSE_ALL_FILES,
|
{
|
||||||
cmd_close_all_files_enabled,
|
return new CloseFileCommand;
|
||||||
NULL,
|
}
|
||||||
cmd_close_all_files_execute,
|
|
||||||
};
|
Command* CommandFactory::create_close_all_files_command()
|
||||||
|
{
|
||||||
|
return new CloseAllFilesCommand;
|
||||||
|
}
|
||||||
|
@ -22,11 +22,12 @@
|
|||||||
|
|
||||||
#include "jinete/jinete.h"
|
#include "jinete/jinete.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "core/app.h"
|
#include "core/app.h"
|
||||||
#include "dialogs/options.h"
|
#include "dialogs/options.h"
|
||||||
#include "modules/gui.h"
|
#include "modules/gui.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
#include "modules/palettes.h"
|
#include "modules/palettes.h"
|
||||||
|
|
||||||
#define DEPTH_TO_INDEX(bpp) \
|
#define DEPTH_TO_INDEX(bpp) \
|
||||||
@ -49,11 +50,30 @@ static int old_card, old_w, old_h, old_depth, old_scaling;
|
|||||||
static int timer_to_accept;
|
static int timer_to_accept;
|
||||||
static int seconds_to_accept;
|
static int seconds_to_accept;
|
||||||
|
|
||||||
static void show_dialog();
|
static void show_dialog(Context* context);
|
||||||
static bool try_new_gfx_mode();
|
static bool try_new_gfx_mode(Context* context);
|
||||||
static bool alert_msg_proc(JWidget widget, JMessage msg);
|
static bool alert_msg_proc(JWidget widget, JMessage msg);
|
||||||
|
|
||||||
static void cmd_configure_screen_execute(const char *argument)
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class ConfigureScreen : public Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ConfigureScreen();
|
||||||
|
Command* clone() const { return new ConfigureScreen(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
ConfigureScreen::ConfigureScreen()
|
||||||
|
: Command("configure_screen",
|
||||||
|
"Configure Screen",
|
||||||
|
CmdUIOnlyFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConfigureScreen::execute(Context* context)
|
||||||
{
|
{
|
||||||
/* get the active status */
|
/* get the active status */
|
||||||
old_card = gfx_driver->id;
|
old_card = gfx_driver->id;
|
||||||
@ -69,10 +89,10 @@ static void cmd_configure_screen_execute(const char *argument)
|
|||||||
new_depth = old_depth;
|
new_depth = old_depth;
|
||||||
new_scaling = old_scaling;
|
new_scaling = old_scaling;
|
||||||
|
|
||||||
show_dialog();
|
show_dialog(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void show_dialog()
|
static void show_dialog(Context* context)
|
||||||
{
|
{
|
||||||
JWidget resolution, color_depth, pixel_scale, fullscreen;
|
JWidget resolution, color_depth, pixel_scale, fullscreen;
|
||||||
char buf[512];
|
char buf[512];
|
||||||
@ -132,7 +152,7 @@ static void show_dialog()
|
|||||||
new_scaling = jcombobox_get_selected_index(pixel_scale)+1;
|
new_scaling = jcombobox_get_selected_index(pixel_scale)+1;
|
||||||
|
|
||||||
/* setup graphics mode */
|
/* setup graphics mode */
|
||||||
if (try_new_gfx_mode()) {
|
if (try_new_gfx_mode(context)) {
|
||||||
JWidgetPtr alert_window(jalert_new("Confirm Screen"
|
JWidgetPtr alert_window(jalert_new("Confirm Screen"
|
||||||
"<<Do you want to keep this screen resolution?"
|
"<<Do you want to keep this screen resolution?"
|
||||||
"<<In 10 seconds the screen will be restored."
|
"<<In 10 seconds the screen will be restored."
|
||||||
@ -157,13 +177,13 @@ static void show_dialog()
|
|||||||
new_depth = old_depth;
|
new_depth = old_depth;
|
||||||
new_scaling = old_scaling;
|
new_scaling = old_scaling;
|
||||||
|
|
||||||
try_new_gfx_mode();
|
try_new_gfx_mode(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool try_new_gfx_mode()
|
static bool try_new_gfx_mode(Context* context)
|
||||||
{
|
{
|
||||||
/* try change the new graphics mode */
|
/* try change the new graphics mode */
|
||||||
set_color_depth(new_depth);
|
set_color_depth(new_depth);
|
||||||
@ -187,7 +207,7 @@ static bool try_new_gfx_mode()
|
|||||||
|
|
||||||
/* restore palette all screen stuff */
|
/* restore palette all screen stuff */
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
const CurrentSpriteReader sprite(context);
|
||||||
app_refresh_screen(sprite);
|
app_refresh_screen(sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,7 +227,7 @@ static bool try_new_gfx_mode()
|
|||||||
|
|
||||||
// restore palette all screen stuff
|
// restore palette all screen stuff
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
const CurrentSpriteReader sprite(context);
|
||||||
app_refresh_screen(sprite);
|
app_refresh_screen(sprite);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -248,9 +268,10 @@ static bool alert_msg_proc(JWidget widget, JMessage msg)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_configure_screen = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_CONFIGURE_SCREEN,
|
// CommandFactory
|
||||||
NULL,
|
|
||||||
NULL,
|
Command* CommandFactory::create_configure_screen_command()
|
||||||
cmd_configure_screen_execute,
|
{
|
||||||
};
|
return new ConfigureScreen;
|
||||||
|
}
|
||||||
|
@ -22,8 +22,9 @@
|
|||||||
|
|
||||||
#include "jinete/jinete.h"
|
#include "jinete/jinete.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "core/app.h"
|
#include "core/app.h"
|
||||||
|
#include "ui_context.h"
|
||||||
#include "modules/editors.h"
|
#include "modules/editors.h"
|
||||||
#include "modules/gfx.h"
|
#include "modules/gfx.h"
|
||||||
#include "modules/gui.h"
|
#include "modules/gui.h"
|
||||||
@ -37,6 +38,7 @@
|
|||||||
#include "widgets/editor.h"
|
#include "widgets/editor.h"
|
||||||
#include "widgets/groupbut.h"
|
#include "widgets/groupbut.h"
|
||||||
#include "widgets/statebar.h"
|
#include "widgets/statebar.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
|
||||||
static JWidget window = NULL;
|
static JWidget window = NULL;
|
||||||
|
|
||||||
@ -58,7 +60,26 @@ static bool set_grid_button_select_hook(JWidget widget, void *data);
|
|||||||
static bool cursor_button_change_hook(JWidget widget, void *data);
|
static bool cursor_button_change_hook(JWidget widget, void *data);
|
||||||
static bool onionskin_check_change_hook(JWidget widget, void *data);
|
static bool onionskin_check_change_hook(JWidget widget, void *data);
|
||||||
|
|
||||||
static void cmd_configure_tools_execute(const char *argument)
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class ConfigureTools : public Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ConfigureTools();
|
||||||
|
Command* clone() const { return new ConfigureTools(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
ConfigureTools::ConfigureTools()
|
||||||
|
: Command("configure_tools",
|
||||||
|
"Configure Tools",
|
||||||
|
CmdUIOnlyFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConfigureTools::execute(Context* context)
|
||||||
{
|
{
|
||||||
JWidget filled, tiled, tiled_x, tiled_y, use_grid, view_grid, set_grid;
|
JWidget filled, tiled, tiled_x, tiled_y, use_grid, view_grid, set_grid;
|
||||||
JWidget brush_size, brush_angle, glass_dirty;
|
JWidget brush_size, brush_angle, glass_dirty;
|
||||||
@ -325,7 +346,8 @@ static bool view_grid_check_change_hook(JWidget widget, void *data)
|
|||||||
static bool set_grid_button_select_hook(JWidget widget, void *data)
|
static bool set_grid_button_select_hook(JWidget widget, void *data)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
const CurrentSpriteReader sprite;
|
// TODO use the same context as in ConfigureTools::execute
|
||||||
|
const CurrentSpriteReader sprite(UIContext::instance());
|
||||||
|
|
||||||
if (sprite && sprite->mask && sprite->mask->bitmap) {
|
if (sprite && sprite->mask && sprite->mask->bitmap) {
|
||||||
JRect rect = jrect_new(sprite->mask->x,
|
JRect rect = jrect_new(sprite->mask->x,
|
||||||
@ -365,9 +387,10 @@ static bool onionskin_check_change_hook(JWidget widget, void *data)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_configure_tools = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_CONFIGURE_TOOLS,
|
// CommandFactory
|
||||||
NULL,
|
|
||||||
NULL,
|
Command* CommandFactory::create_configure_tools_command()
|
||||||
cmd_configure_tools_execute,
|
{
|
||||||
};
|
return new ConfigureTools;
|
||||||
|
}
|
||||||
|
@ -20,16 +20,35 @@
|
|||||||
|
|
||||||
#include "jinete/jbase.h"
|
#include "jinete/jbase.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "raster/layer.h"
|
#include "raster/layer.h"
|
||||||
#include "raster/mask.h"
|
#include "raster/mask.h"
|
||||||
#include "raster/sprite.h"
|
#include "raster/sprite.h"
|
||||||
#include "util/clipboard.h"
|
#include "util/clipboard.h"
|
||||||
#include "util/misc.h"
|
#include "util/misc.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
|
||||||
static bool cmd_copy_enabled(const char *argument)
|
class CopyCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
CopyCommand();
|
||||||
|
Command* clone() const { return new CopyCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
CopyCommand::CopyCommand()
|
||||||
|
: Command("copy",
|
||||||
|
"Copy",
|
||||||
|
CmdUIOnlyFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CopyCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
|
|
||||||
if ((!sprite) ||
|
if ((!sprite) ||
|
||||||
(!sprite->layer) ||
|
(!sprite->layer) ||
|
||||||
@ -42,15 +61,16 @@ static bool cmd_copy_enabled(const char *argument)
|
|||||||
return GetImage(sprite) ? true: false;
|
return GetImage(sprite) ? true: false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_copy_execute(const char *argument)
|
void CopyCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
const CurrentSpriteReader sprite(context);
|
||||||
clipboard::copy(sprite);
|
clipboard::copy(sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_copy = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_COPY,
|
// CommandFactory
|
||||||
cmd_copy_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_copy_command()
|
||||||
cmd_copy_execute,
|
{
|
||||||
};
|
return new CopyCommand;
|
||||||
|
}
|
||||||
|
@ -20,24 +20,44 @@
|
|||||||
|
|
||||||
#include "jinete/jbase.h"
|
#include "jinete/jbase.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
#include "dialogs/aniedit.h"
|
#include "dialogs/aniedit.h"
|
||||||
#include "util/celmove.h"
|
#include "util/celmove.h"
|
||||||
|
|
||||||
static bool cmd_copy_cel_enabled(const char *argument)
|
class CopyCelCommand : public Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CopyCelCommand();
|
||||||
|
Command* clone() const { return new CopyCelCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
CopyCelCommand::CopyCelCommand()
|
||||||
|
: Command("copy_cel",
|
||||||
|
"Copy Cel",
|
||||||
|
CmdUIOnlyFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CopyCelCommand::enabled(Context* context)
|
||||||
{
|
{
|
||||||
return animation_editor_is_movingcel();
|
return animation_editor_is_movingcel();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_copy_cel_execute(const char *argument)
|
void CopyCelCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
CurrentSpriteWriter sprite;
|
CurrentSpriteWriter sprite(context);
|
||||||
copy_cel(sprite);
|
copy_cel(sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_copy_cel = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_COPY_CEL,
|
// CommandFactory
|
||||||
cmd_copy_cel_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_copy_cel_command()
|
||||||
cmd_copy_cel_execute,
|
{
|
||||||
};
|
return new CopyCelCommand;
|
||||||
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "core/app.h"
|
#include "core/app.h"
|
||||||
#include "modules/gui.h"
|
#include "modules/gui.h"
|
||||||
#include "raster/image.h"
|
#include "raster/image.h"
|
||||||
@ -29,23 +29,41 @@
|
|||||||
#include "widgets/colbar.h"
|
#include "widgets/colbar.h"
|
||||||
#include "util/autocrop.h"
|
#include "util/autocrop.h"
|
||||||
#include "util/misc.h"
|
#include "util/misc.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
|
||||||
/* ======================== */
|
//////////////////////////////////////////////////////////////////////
|
||||||
/* crop_sprite */
|
// crop_sprite
|
||||||
/* ======================== */
|
|
||||||
|
|
||||||
static bool cmd_crop_sprite_enabled(const char *argument)
|
class CropSpriteCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
CropSpriteCommand();
|
||||||
|
Command* clone() const { return new CropSpriteCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
CropSpriteCommand::CropSpriteCommand()
|
||||||
|
: Command("crop_sprite",
|
||||||
|
"Crop Sprite",
|
||||||
|
CmdRecordableFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CropSpriteCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return
|
return
|
||||||
sprite != NULL &&
|
sprite != NULL &&
|
||||||
sprite->mask != NULL &&
|
sprite->mask != NULL &&
|
||||||
sprite->mask->bitmap != NULL;
|
sprite->mask->bitmap != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_crop_sprite_execute(const char *argument)
|
void CropSpriteCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
CurrentSpriteWriter sprite;
|
CurrentSpriteWriter sprite(context);
|
||||||
{
|
{
|
||||||
Undoable undoable(sprite, "Sprite Crop");
|
Undoable undoable(sprite, "Sprite Crop");
|
||||||
int bgcolor = get_color_for_image(sprite->imgtype,
|
int bgcolor = get_color_for_image(sprite->imgtype,
|
||||||
@ -61,19 +79,36 @@ static void cmd_crop_sprite_execute(const char *argument)
|
|||||||
update_screen_for_sprite(sprite);
|
update_screen_for_sprite(sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ======================== */
|
//////////////////////////////////////////////////////////////////////
|
||||||
/* autocrop_sprite */
|
// autocrop_sprite
|
||||||
/* ======================== */
|
|
||||||
|
|
||||||
static bool cmd_autocrop_sprite_enabled(const char *argument)
|
class AutocropSpriteCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
AutocropSpriteCommand();
|
||||||
|
Command* clone() const { return new AutocropSpriteCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
AutocropSpriteCommand::AutocropSpriteCommand()
|
||||||
|
: Command("autocrop_sprite",
|
||||||
|
"Autocrop Sprite",
|
||||||
|
CmdRecordableFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AutocropSpriteCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return sprite != NULL;
|
return sprite != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_autocrop_sprite_execute(const char *argument)
|
void AutocropSpriteCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
CurrentSpriteWriter sprite;
|
CurrentSpriteWriter sprite(context);
|
||||||
{
|
{
|
||||||
Undoable undoable(sprite, "Sprite Autocrop");
|
Undoable undoable(sprite, "Sprite Autocrop");
|
||||||
undoable.autocrop_sprite(colorbar_get_bg_color(app_get_colorbar()));
|
undoable.autocrop_sprite(colorbar_get_bg_color(app_get_colorbar()));
|
||||||
@ -83,19 +118,15 @@ static void cmd_autocrop_sprite_execute(const char *argument)
|
|||||||
update_screen_for_sprite(sprite);
|
update_screen_for_sprite(sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************/
|
//////////////////////////////////////////////////////////////////////
|
||||||
/* local */
|
// CommandFactory
|
||||||
|
|
||||||
Command cmd_crop_sprite = {
|
Command* CommandFactory::create_crop_sprite_command()
|
||||||
CMD_CROP_SPRITE,
|
{
|
||||||
cmd_crop_sprite_enabled,
|
return new CropSpriteCommand;
|
||||||
NULL,
|
}
|
||||||
cmd_crop_sprite_execute,
|
|
||||||
};
|
|
||||||
|
|
||||||
Command cmd_autocrop_sprite = {
|
Command* CommandFactory::create_autocrop_sprite_command()
|
||||||
CMD_AUTOCROP_SPRITE,
|
{
|
||||||
cmd_autocrop_sprite_enabled,
|
return new AutocropSpriteCommand;
|
||||||
NULL,
|
}
|
||||||
cmd_autocrop_sprite_execute,
|
|
||||||
};
|
|
||||||
|
@ -20,16 +20,35 @@
|
|||||||
|
|
||||||
#include "jinete/jbase.h"
|
#include "jinete/jbase.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "raster/layer.h"
|
#include "raster/layer.h"
|
||||||
#include "raster/mask.h"
|
#include "raster/mask.h"
|
||||||
#include "raster/sprite.h"
|
#include "raster/sprite.h"
|
||||||
#include "util/clipboard.h"
|
#include "util/clipboard.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
#include "util/misc.h"
|
#include "util/misc.h"
|
||||||
|
|
||||||
static bool cmd_cut_enabled(const char *argument)
|
class CutCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
CutCommand();
|
||||||
|
Command* clone() const { return new CutCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
CutCommand::CutCommand()
|
||||||
|
: Command("cut",
|
||||||
|
"Cut",
|
||||||
|
CmdUIOnlyFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CutCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
if ((!sprite) ||
|
if ((!sprite) ||
|
||||||
(!sprite->layer) ||
|
(!sprite->layer) ||
|
||||||
(!layer_is_readable(sprite->layer)) ||
|
(!layer_is_readable(sprite->layer)) ||
|
||||||
@ -41,15 +60,16 @@ static bool cmd_cut_enabled(const char *argument)
|
|||||||
return GetImage(sprite) ? true: false;
|
return GetImage(sprite) ? true: false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_cut_execute(const char *argument)
|
void CutCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
CurrentSpriteWriter sprite;
|
CurrentSpriteWriter sprite(context);
|
||||||
clipboard::cut(sprite);
|
clipboard::cut(sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_cut = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_CUT,
|
// CommandFactory
|
||||||
cmd_cut_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_cut_command()
|
||||||
cmd_cut_execute,
|
{
|
||||||
};
|
return new CutCommand;
|
||||||
|
}
|
||||||
|
@ -18,21 +18,43 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "modules/gui.h"
|
#include "modules/gui.h"
|
||||||
#include "raster/mask.h"
|
#include "raster/mask.h"
|
||||||
#include "raster/sprite.h"
|
#include "raster/sprite.h"
|
||||||
#include "raster/undo.h"
|
#include "raster/undo.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
|
||||||
static bool cmd_deselect_mask_enabled(const char *argument)
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// deselect_mask
|
||||||
|
|
||||||
|
class DeselectMaskCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
DeselectMaskCommand();
|
||||||
|
Command* clone() const { return new DeselectMaskCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
DeselectMaskCommand::DeselectMaskCommand()
|
||||||
|
: Command("deselect_mask",
|
||||||
|
"Deselect Mask",
|
||||||
|
CmdRecordableFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DeselectMaskCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return sprite && !mask_is_empty(sprite->mask);
|
return sprite && !mask_is_empty(sprite->mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_deselect_mask_execute(const char *argument)
|
void DeselectMaskCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
CurrentSpriteWriter sprite;
|
CurrentSpriteWriter sprite(context);
|
||||||
Mask *mask;
|
Mask *mask;
|
||||||
|
|
||||||
/* destroy the *deselected* mask */
|
/* destroy the *deselected* mask */
|
||||||
@ -60,9 +82,10 @@ static void cmd_deselect_mask_execute(const char *argument)
|
|||||||
update_screen_for_sprite(sprite);
|
update_screen_for_sprite(sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_deselect_mask = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_DESELECT_MASK,
|
// CommandFactory
|
||||||
cmd_deselect_mask_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_deselect_mask_command()
|
||||||
cmd_deselect_mask_execute,
|
{
|
||||||
};
|
return new DeselectMaskCommand;
|
||||||
|
}
|
||||||
|
@ -18,20 +18,4 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "jinete/jinete.h"
|
// TODO remove me
|
||||||
|
|
||||||
#include "commands/commands.h"
|
|
||||||
#include "core/app.h"
|
|
||||||
#include "raster/sprite.h"
|
|
||||||
|
|
||||||
/* static void cmd_draw_text_execute(const char *argument) */
|
|
||||||
/* { */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* Command cmd_draw_text = { */
|
|
||||||
/* CMD_DRAW_TEXT, */
|
|
||||||
/* cmd_draw_text_enabled, */
|
|
||||||
/* NULL, */
|
|
||||||
/* cmd_draw_text_execute, */
|
|
||||||
/* NULL */
|
|
||||||
/* }; */
|
|
||||||
|
@ -18,222 +18,4 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <allegro/unicode.h>
|
// remove this file
|
||||||
|
|
||||||
#include "jinete/jbase.h"
|
|
||||||
|
|
||||||
#include "commands/commands.h"
|
|
||||||
#include "modules/tools.h"
|
|
||||||
|
|
||||||
/* ======================== */
|
|
||||||
/* blur_tool */
|
|
||||||
/* ======================== */
|
|
||||||
|
|
||||||
static bool cmd_blur_tool_checked(const char *argument)
|
|
||||||
{
|
|
||||||
return current_tool == tools_list[TOOL_BLUR];
|
|
||||||
}
|
|
||||||
|
|
||||||
static void cmd_blur_tool_execute(const char *argument)
|
|
||||||
{
|
|
||||||
select_tool(tools_list[TOOL_BLUR]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ======================== */
|
|
||||||
/* brush_tool */
|
|
||||||
/* ======================== */
|
|
||||||
|
|
||||||
static bool cmd_brush_tool_checked(const char *argument)
|
|
||||||
{
|
|
||||||
return current_tool == tools_list[TOOL_BRUSH];
|
|
||||||
}
|
|
||||||
|
|
||||||
static void cmd_brush_tool_execute(const char *argument)
|
|
||||||
{
|
|
||||||
select_tool(tools_list[TOOL_BRUSH]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ======================== */
|
|
||||||
/* eraser_tool */
|
|
||||||
/* ======================== */
|
|
||||||
|
|
||||||
static bool cmd_eraser_tool_checked(const char *argument)
|
|
||||||
{
|
|
||||||
return current_tool == tools_list[TOOL_ERASER];
|
|
||||||
}
|
|
||||||
|
|
||||||
static void cmd_eraser_tool_execute(const char *argument)
|
|
||||||
{
|
|
||||||
select_tool(tools_list[TOOL_ERASER]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ======================== */
|
|
||||||
/* ellipse_tool */
|
|
||||||
/* ======================== */
|
|
||||||
|
|
||||||
static bool cmd_ellipse_tool_checked(const char *argument)
|
|
||||||
{
|
|
||||||
return current_tool == tools_list[TOOL_ELLIPSE];
|
|
||||||
}
|
|
||||||
|
|
||||||
static void cmd_ellipse_tool_execute(const char *argument)
|
|
||||||
{
|
|
||||||
select_tool(tools_list[TOOL_ELLIPSE]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ======================== */
|
|
||||||
/* floodfill_tool */
|
|
||||||
/* ======================== */
|
|
||||||
|
|
||||||
static bool cmd_floodfill_tool_checked(const char *argument)
|
|
||||||
{
|
|
||||||
return current_tool == tools_list[TOOL_FLOODFILL];
|
|
||||||
}
|
|
||||||
|
|
||||||
static void cmd_floodfill_tool_execute(const char *argument)
|
|
||||||
{
|
|
||||||
select_tool(tools_list[TOOL_FLOODFILL]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ======================== */
|
|
||||||
/* line_tool */
|
|
||||||
/* ======================== */
|
|
||||||
|
|
||||||
static bool cmd_line_tool_checked(const char *argument)
|
|
||||||
{
|
|
||||||
return current_tool == tools_list[TOOL_LINE];
|
|
||||||
}
|
|
||||||
|
|
||||||
static void cmd_line_tool_execute(const char *argument)
|
|
||||||
{
|
|
||||||
select_tool(tools_list[TOOL_LINE]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ======================== */
|
|
||||||
/* marker_tool */
|
|
||||||
/* ======================== */
|
|
||||||
|
|
||||||
static bool cmd_marker_tool_checked(const char *argument)
|
|
||||||
{
|
|
||||||
return current_tool == tools_list[TOOL_MARKER];
|
|
||||||
}
|
|
||||||
|
|
||||||
static void cmd_marker_tool_execute(const char *argument)
|
|
||||||
{
|
|
||||||
select_tool(tools_list[TOOL_MARKER]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ======================== */
|
|
||||||
/* pencil_tool */
|
|
||||||
/* ======================== */
|
|
||||||
|
|
||||||
static bool cmd_pencil_tool_checked(const char *argument)
|
|
||||||
{
|
|
||||||
return current_tool == tools_list[TOOL_PENCIL];
|
|
||||||
}
|
|
||||||
|
|
||||||
static void cmd_pencil_tool_execute(const char *argument)
|
|
||||||
{
|
|
||||||
select_tool(tools_list[TOOL_PENCIL]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ======================== */
|
|
||||||
/* rectangle_tool */
|
|
||||||
/* ======================== */
|
|
||||||
|
|
||||||
static bool cmd_rectangle_tool_checked(const char *argument)
|
|
||||||
{
|
|
||||||
return current_tool == tools_list[TOOL_RECTANGLE];
|
|
||||||
}
|
|
||||||
|
|
||||||
static void cmd_rectangle_tool_execute(const char *argument)
|
|
||||||
{
|
|
||||||
select_tool(tools_list[TOOL_RECTANGLE]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ======================== */
|
|
||||||
/* spray_tool */
|
|
||||||
/* ======================== */
|
|
||||||
|
|
||||||
static bool cmd_spray_tool_checked(const char *argument)
|
|
||||||
{
|
|
||||||
return current_tool == tools_list[TOOL_SPRAY];
|
|
||||||
}
|
|
||||||
|
|
||||||
static void cmd_spray_tool_execute(const char *argument)
|
|
||||||
{
|
|
||||||
select_tool(tools_list[TOOL_SPRAY]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ================================================ */
|
|
||||||
/* Commands */
|
|
||||||
|
|
||||||
Command cmd_blur_tool = {
|
|
||||||
CMD_BLUR_TOOL,
|
|
||||||
NULL,
|
|
||||||
cmd_blur_tool_checked,
|
|
||||||
cmd_blur_tool_execute,
|
|
||||||
};
|
|
||||||
|
|
||||||
Command cmd_brush_tool = {
|
|
||||||
CMD_BRUSH_TOOL,
|
|
||||||
NULL,
|
|
||||||
cmd_brush_tool_checked,
|
|
||||||
cmd_brush_tool_execute,
|
|
||||||
};
|
|
||||||
|
|
||||||
Command cmd_ellipse_tool = {
|
|
||||||
CMD_ELLIPSE_TOOL,
|
|
||||||
NULL,
|
|
||||||
cmd_ellipse_tool_checked,
|
|
||||||
cmd_ellipse_tool_execute,
|
|
||||||
};
|
|
||||||
|
|
||||||
Command cmd_eraser_tool = {
|
|
||||||
CMD_ERASER_TOOL,
|
|
||||||
NULL,
|
|
||||||
cmd_eraser_tool_checked,
|
|
||||||
cmd_eraser_tool_execute,
|
|
||||||
};
|
|
||||||
|
|
||||||
Command cmd_floodfill_tool = {
|
|
||||||
CMD_FLOODFILL_TOOL,
|
|
||||||
NULL,
|
|
||||||
cmd_floodfill_tool_checked,
|
|
||||||
cmd_floodfill_tool_execute,
|
|
||||||
};
|
|
||||||
|
|
||||||
Command cmd_line_tool = {
|
|
||||||
CMD_LINE_TOOL,
|
|
||||||
NULL,
|
|
||||||
cmd_line_tool_checked,
|
|
||||||
cmd_line_tool_execute,
|
|
||||||
};
|
|
||||||
|
|
||||||
Command cmd_marker_tool = {
|
|
||||||
CMD_MARKER_TOOL,
|
|
||||||
NULL,
|
|
||||||
cmd_marker_tool_checked,
|
|
||||||
cmd_marker_tool_execute,
|
|
||||||
};
|
|
||||||
|
|
||||||
Command cmd_pencil_tool = {
|
|
||||||
CMD_PENCIL_TOOL,
|
|
||||||
NULL,
|
|
||||||
cmd_pencil_tool_checked,
|
|
||||||
cmd_pencil_tool_execute,
|
|
||||||
};
|
|
||||||
|
|
||||||
Command cmd_rectangle_tool = {
|
|
||||||
CMD_RECTANGLE_TOOL,
|
|
||||||
NULL,
|
|
||||||
cmd_rectangle_tool_checked,
|
|
||||||
cmd_rectangle_tool_execute,
|
|
||||||
};
|
|
||||||
|
|
||||||
Command cmd_spray_tool = {
|
|
||||||
CMD_SPRAY_TOOL,
|
|
||||||
NULL,
|
|
||||||
cmd_spray_tool_checked,
|
|
||||||
cmd_spray_tool_execute,
|
|
||||||
};
|
|
||||||
|
@ -20,25 +20,47 @@
|
|||||||
|
|
||||||
#include "jinete/jinete.h"
|
#include "jinete/jinete.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "core/app.h"
|
#include "core/app.h"
|
||||||
#include "modules/gui.h"
|
#include "modules/gui.h"
|
||||||
#include "raster/layer.h"
|
#include "raster/layer.h"
|
||||||
#include "raster/sprite.h"
|
#include "raster/sprite.h"
|
||||||
#include "raster/undo.h"
|
#include "raster/undo.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
|
||||||
static Layer *duplicate_layer(Sprite* sprite);
|
static Layer *duplicate_layer(Sprite* sprite);
|
||||||
|
|
||||||
static bool cmd_duplicate_layer_enabled(const char *argument)
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// duplicate_layer
|
||||||
|
|
||||||
|
class DuplicateLayerCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
DuplicateLayerCommand();
|
||||||
|
Command* clone() const { return new DuplicateLayerCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
DuplicateLayerCommand::DuplicateLayerCommand()
|
||||||
|
: Command("duplicate_layer",
|
||||||
|
"Duplicate Layer",
|
||||||
|
CmdRecordableFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DuplicateLayerCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return sprite && sprite->layer;
|
return sprite && sprite->layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_duplicate_layer_execute(const char *argument)
|
void DuplicateLayerCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
CurrentSpriteWriter sprite;
|
CurrentSpriteWriter sprite(context);
|
||||||
if (duplicate_layer(sprite) != NULL)
|
if (duplicate_layer(sprite) != NULL)
|
||||||
update_screen_for_sprite(sprite);
|
update_screen_for_sprite(sprite);
|
||||||
}
|
}
|
||||||
@ -90,9 +112,10 @@ static Layer *duplicate_layer(Sprite* sprite)
|
|||||||
return layer_copy;
|
return layer_copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_duplicate_layer = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_DUPLICATE_LAYER,
|
// CommandFactory
|
||||||
cmd_duplicate_layer_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_duplicate_layer_command()
|
||||||
cmd_duplicate_layer_execute,
|
{
|
||||||
};
|
return new DuplicateLayerCommand;
|
||||||
|
}
|
||||||
|
@ -23,22 +23,45 @@
|
|||||||
#include "jinete/jinete.h"
|
#include "jinete/jinete.h"
|
||||||
|
|
||||||
#include "ui_context.h"
|
#include "ui_context.h"
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "core/app.h"
|
#include "core/app.h"
|
||||||
#include "core/cfg.h"
|
#include "core/cfg.h"
|
||||||
|
#include "modules/editors.h"
|
||||||
#include "modules/gui.h"
|
#include "modules/gui.h"
|
||||||
#include "raster/sprite.h"
|
#include "raster/sprite.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
|
||||||
static bool cmd_duplicate_sprite_enabled(const char *argument)
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// duplicate_sprite
|
||||||
|
|
||||||
|
class DuplicateSpriteCommand : public Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DuplicateSpriteCommand();
|
||||||
|
Command* clone() { return new DuplicateSpriteCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
DuplicateSpriteCommand::DuplicateSpriteCommand()
|
||||||
|
: Command("duplicate_sprite",
|
||||||
|
"Duplicate Sprite",
|
||||||
|
CmdUIOnlyFlag)
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
|
||||||
return sprite.is_valid();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_duplicate_sprite_execute(const char *argument)
|
bool DuplicateSpriteCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
|
return sprite != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DuplicateSpriteCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
JWidget src_name, dst_name, flatten;
|
JWidget src_name, dst_name, flatten;
|
||||||
const CurrentSpriteReader sprite;
|
const CurrentSpriteReader sprite(context);
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
|
||||||
/* load the window widget */
|
/* load the window widget */
|
||||||
@ -73,18 +96,16 @@ static void cmd_duplicate_sprite_execute(const char *argument)
|
|||||||
if (sprite_copy != NULL) {
|
if (sprite_copy != NULL) {
|
||||||
sprite_set_filename(sprite_copy, jwidget_get_text(dst_name));
|
sprite_set_filename(sprite_copy, jwidget_get_text(dst_name));
|
||||||
|
|
||||||
UIContext* context = UIContext::instance();
|
|
||||||
|
|
||||||
context->add_sprite(sprite_copy);
|
context->add_sprite(sprite_copy);
|
||||||
context->set_current_sprite(sprite_copy);
|
set_sprite_in_more_reliable_editor(sprite_copy);
|
||||||
context->show_sprite(sprite_copy);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_duplicate_sprite = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_DUPLICATE_SPRITE,
|
// CommandFactory
|
||||||
cmd_duplicate_sprite_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_duplicate_sprite_command()
|
||||||
cmd_duplicate_sprite_execute,
|
{
|
||||||
};
|
return new DuplicateSpriteCommand;
|
||||||
|
}
|
||||||
|
@ -20,14 +20,33 @@
|
|||||||
|
|
||||||
#include "jinete/jinete.h"
|
#include "jinete/jinete.h"
|
||||||
|
|
||||||
#include "ui_context.h"
|
#include "commands/command.h"
|
||||||
#include "commands/commands.h"
|
#include "context.h"
|
||||||
#include "core/app.h"
|
#include "core/app.h"
|
||||||
#include "raster/sprite.h"
|
#include "raster/sprite.h"
|
||||||
|
|
||||||
static void cmd_exit_execute(const char *argument)
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// exit
|
||||||
|
|
||||||
|
class ExitCommand : public Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ExitCommand();
|
||||||
|
Command* clone() { return new ExitCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
ExitCommand::ExitCommand()
|
||||||
|
: Command("exit",
|
||||||
|
"Exit",
|
||||||
|
CmdUIOnlyFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExitCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
UIContext* context = UIContext::instance();
|
|
||||||
Sprite *sprite = context->get_first_sprite();
|
Sprite *sprite = context->get_first_sprite();
|
||||||
|
|
||||||
while (sprite) {
|
while (sprite) {
|
||||||
@ -45,9 +64,11 @@ static void cmd_exit_execute(const char *argument)
|
|||||||
jwindow_close(app_get_top_window(), 0);
|
jwindow_close(app_get_top_window(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_exit = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_EXIT,
|
// CommandFactory
|
||||||
NULL,
|
|
||||||
NULL,
|
Command* CommandFactory::create_exit_command()
|
||||||
cmd_exit_execute,
|
{
|
||||||
};
|
return new ExitCommand;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,8 @@
|
|||||||
|
|
||||||
#include "jinete/jinete.h"
|
#include "jinete/jinete.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
|
#include "commands/params.h"
|
||||||
#include "core/app.h"
|
#include "core/app.h"
|
||||||
#include "modules/editors.h"
|
#include "modules/editors.h"
|
||||||
#include "raster/sprite.h"
|
#include "raster/sprite.h"
|
||||||
@ -30,7 +31,41 @@
|
|||||||
#include "widgets/colbar.h"
|
#include "widgets/colbar.h"
|
||||||
#include "widgets/editor.h"
|
#include "widgets/editor.h"
|
||||||
|
|
||||||
static void cmd_eyedropper_tool_execute(const char *argument)
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// eyedropper_tool
|
||||||
|
|
||||||
|
class EyedropperToolCommand : public Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* True means "pick background color", false the foreground color.
|
||||||
|
*/
|
||||||
|
bool m_background;
|
||||||
|
|
||||||
|
public:
|
||||||
|
EyedropperToolCommand();
|
||||||
|
Command* clone() const { return new EyedropperToolCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void load_params(Params* params);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
EyedropperToolCommand::EyedropperToolCommand()
|
||||||
|
: Command("eyedropper_tool",
|
||||||
|
"Eyedropper",
|
||||||
|
CmdUIOnlyFlag)
|
||||||
|
{
|
||||||
|
m_background = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EyedropperToolCommand::load_params(Params* params)
|
||||||
|
{
|
||||||
|
std::string target = params->get("target");
|
||||||
|
if (target == "foreground") m_background = false;
|
||||||
|
else if (target == "background") m_background = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EyedropperToolCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
JWidget widget;
|
JWidget widget;
|
||||||
Editor *editor;
|
Editor *editor;
|
||||||
@ -53,17 +88,20 @@ static void cmd_eyedropper_tool_execute(const char *argument)
|
|||||||
sprite_getpixel(editor->sprite, x, y));
|
sprite_getpixel(editor->sprite, x, y));
|
||||||
|
|
||||||
if (color_type(color) != COLOR_TYPE_MASK) {
|
if (color_type(color) != COLOR_TYPE_MASK) {
|
||||||
/* set the color of the color-bar */
|
// TODO replace the color in the "context", not directly from the color-bar
|
||||||
if (ustrcmp(argument, "background") == 0)
|
|
||||||
|
// set the color of the color-bar
|
||||||
|
if (m_background)
|
||||||
colorbar_set_bg_color(app_get_colorbar(), color);
|
colorbar_set_bg_color(app_get_colorbar(), color);
|
||||||
else
|
else
|
||||||
colorbar_set_fg_color(app_get_colorbar(), color);
|
colorbar_set_fg_color(app_get_colorbar(), color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_eyedropper_tool = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_EYEDROPPER_TOOL,
|
// CommandFactory
|
||||||
NULL,
|
|
||||||
NULL,
|
Command* CommandFactory::create_eyedropper_tool_command()
|
||||||
cmd_eyedropper_tool_execute,
|
{
|
||||||
};
|
return new EyedropperToolCommand;
|
||||||
|
}
|
||||||
|
@ -20,23 +20,47 @@
|
|||||||
|
|
||||||
#include "jinete/jinete.h"
|
#include "jinete/jinete.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "dialogs/aniedit.h"
|
#include "dialogs/aniedit.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
|
||||||
static bool cmd_film_editor_enabled(const char *argument)
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// film_editor
|
||||||
|
|
||||||
|
class FilmEditorCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
FilmEditorCommand();
|
||||||
|
Command* clone() { return new FilmEditorCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
FilmEditorCommand::FilmEditorCommand()
|
||||||
|
: Command("film_editor",
|
||||||
|
"Animation Editor",
|
||||||
|
CmdUIOnlyFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FilmEditorCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return sprite != NULL;
|
return sprite != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_film_editor_execute(const char *argument)
|
void FilmEditorCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
switch_between_animation_and_sprite_editor();
|
switch_between_animation_and_sprite_editor();
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_film_editor = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_FILM_EDITOR,
|
// CommandFactory
|
||||||
cmd_film_editor_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_film_editor_command()
|
||||||
cmd_film_editor_execute,
|
{
|
||||||
};
|
return new FilmEditorCommand;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -18,22 +18,44 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "core/app.h"
|
#include "core/app.h"
|
||||||
#include "modules/gui.h"
|
#include "modules/gui.h"
|
||||||
#include "raster/sprite.h"
|
#include "raster/sprite.h"
|
||||||
#include "undoable.h"
|
#include "undoable.h"
|
||||||
#include "widgets/colbar.h"
|
#include "widgets/colbar.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
|
||||||
static bool cmd_flatten_layers_enabled(const char *argument)
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// flatten_layers
|
||||||
|
|
||||||
|
class FlattenLayersCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
FlattenLayersCommand();
|
||||||
|
Command* clone() { return new FlattenLayersCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
FlattenLayersCommand::FlattenLayersCommand()
|
||||||
|
: Command("flatten_layers",
|
||||||
|
"Flatten Layers",
|
||||||
|
CmdUIOnlyFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FlattenLayersCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return sprite != NULL;
|
return sprite != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_flatten_layers_execute(const char *argument)
|
void FlattenLayersCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
CurrentSpriteWriter sprite;
|
CurrentSpriteWriter sprite(context);
|
||||||
int bgcolor = get_color_for_image(sprite->imgtype,
|
int bgcolor = get_color_for_image(sprite->imgtype,
|
||||||
colorbar_get_bg_color(app_get_colorbar()));
|
colorbar_get_bg_color(app_get_colorbar()));
|
||||||
{
|
{
|
||||||
@ -44,9 +66,10 @@ static void cmd_flatten_layers_execute(const char *argument)
|
|||||||
update_screen_for_sprite(sprite);
|
update_screen_for_sprite(sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_flatten_layers = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_FLATTEN_LAYERS,
|
// CommandFactory
|
||||||
cmd_flatten_layers_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_flatten_layers_command()
|
||||||
cmd_flatten_layers_execute,
|
{
|
||||||
};
|
return new FlattenLayersCommand;
|
||||||
|
}
|
||||||
|
@ -22,7 +22,8 @@
|
|||||||
|
|
||||||
#include "jinete/jlist.h"
|
#include "jinete/jlist.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
|
#include "commands/params.h"
|
||||||
#include "modules/editors.h"
|
#include "modules/editors.h"
|
||||||
#include "modules/gui.h"
|
#include "modules/gui.h"
|
||||||
#include "raster/cel.h"
|
#include "raster/cel.h"
|
||||||
@ -33,31 +34,66 @@
|
|||||||
#include "raster/undo.h"
|
#include "raster/undo.h"
|
||||||
#include "util/misc.h"
|
#include "util/misc.h"
|
||||||
#include "undoable.h"
|
#include "undoable.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
|
||||||
static bool cmd_flip_enabled(const char *argument)
|
class FlipCommand : public Command
|
||||||
{
|
{
|
||||||
assert(argument);
|
bool m_flip_mask;
|
||||||
const CurrentSpriteReader sprite;
|
bool m_flip_horizontal;
|
||||||
|
bool m_flip_vertical;
|
||||||
|
|
||||||
|
public:
|
||||||
|
FlipCommand();
|
||||||
|
Command* clone() const { return new FlipCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void load_params(Params* params);
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
|
||||||
|
private:
|
||||||
|
static char* read_authors_txt(const char *filename);
|
||||||
|
};
|
||||||
|
|
||||||
|
FlipCommand::FlipCommand()
|
||||||
|
: Command("flip",
|
||||||
|
"Flip",
|
||||||
|
CmdRecordableFlag)
|
||||||
|
{
|
||||||
|
m_flip_mask = false;
|
||||||
|
m_flip_horizontal = false;
|
||||||
|
m_flip_vertical = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlipCommand::load_params(Params* params)
|
||||||
|
{
|
||||||
|
std::string target = params->get("target");
|
||||||
|
m_flip_mask = (target == "mask");
|
||||||
|
|
||||||
|
std::string orientation = params->get("orientation");
|
||||||
|
m_flip_horizontal = (orientation == "horizontal");
|
||||||
|
m_flip_vertical = (orientation == "vertical");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FlipCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return
|
return
|
||||||
sprite != NULL;
|
sprite != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_flip_execute(const char *argument)
|
void FlipCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
CurrentSpriteWriter sprite;
|
CurrentSpriteWriter sprite(context);
|
||||||
bool flip_mask = ustrstr(argument, "mask") != NULL;
|
|
||||||
bool flip_canvas = ustrstr(argument, "canvas") != NULL;
|
|
||||||
bool flip_horizontal = ustrstr(argument, "horizontal") != NULL;
|
|
||||||
bool flip_vertical = ustrstr(argument, "vertical") != NULL;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
Undoable undoable(sprite,
|
Undoable undoable(sprite, m_flip_mask ?
|
||||||
flip_mask ? (flip_horizontal ? "Flip Horizontal":
|
(m_flip_horizontal ? "Flip Horizontal":
|
||||||
"Flip Vertical"):
|
"Flip Vertical"):
|
||||||
(flip_horizontal ? "Flip Canvas Horizontal":
|
(m_flip_horizontal ? "Flip Canvas Horizontal":
|
||||||
"Flip Canvas Vertical"));
|
"Flip Canvas Vertical"));
|
||||||
|
|
||||||
if (flip_mask) {
|
if (m_flip_mask) {
|
||||||
Image* image;
|
Image* image;
|
||||||
int x1, y1, x2, y2;
|
int x1, y1, x2, y2;
|
||||||
int x, y;
|
int x, y;
|
||||||
@ -88,9 +124,10 @@ static void cmd_flip_execute(const char *argument)
|
|||||||
y2 = MID(0, y2, image->h-1);
|
y2 = MID(0, y2, image->h-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
undoable.flip_image(image, x1, y1, x2, y2, flip_horizontal, flip_vertical);
|
undoable.flip_image(image, x1, y1, x2, y2,
|
||||||
|
m_flip_horizontal, m_flip_vertical);
|
||||||
}
|
}
|
||||||
else if (flip_canvas) {
|
else {
|
||||||
// get all sprite cels
|
// get all sprite cels
|
||||||
JList cels = jlist_new();
|
JList cels = jlist_new();
|
||||||
sprite_get_cels(sprite, cels);
|
sprite_get_cels(sprite, cels);
|
||||||
@ -102,23 +139,25 @@ static void cmd_flip_execute(const char *argument)
|
|||||||
Image* image = stock_get_image(sprite->stock, cel->image);
|
Image* image = stock_get_image(sprite->stock, cel->image);
|
||||||
|
|
||||||
undoable.set_cel_position(cel,
|
undoable.set_cel_position(cel,
|
||||||
flip_horizontal ? sprite->w - image->w - cel->x: cel->x,
|
m_flip_horizontal ? sprite->w - image->w - cel->x: cel->x,
|
||||||
flip_vertical ? sprite->h - image->h - cel->y: cel->y);
|
m_flip_vertical ? sprite->h - image->h - cel->y: cel->y);
|
||||||
|
|
||||||
undoable.flip_image(image, 0, 0, image->w-1, image->h-1,
|
undoable.flip_image(image, 0, 0, image->w-1, image->h-1,
|
||||||
flip_horizontal, flip_vertical);
|
m_flip_horizontal, m_flip_vertical);
|
||||||
}
|
}
|
||||||
jlist_free(cels);
|
jlist_free(cels);
|
||||||
}
|
}
|
||||||
|
|
||||||
undoable.commit();
|
undoable.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
update_screen_for_sprite(sprite);
|
update_screen_for_sprite(sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_flip = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_FLIP,
|
// CommandFactory
|
||||||
cmd_flip_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_flip_command()
|
||||||
cmd_flip_execute,
|
{
|
||||||
};
|
return new FlipCommand;
|
||||||
|
}
|
||||||
|
@ -20,24 +20,46 @@
|
|||||||
|
|
||||||
#include "jinete/jinete.h"
|
#include "jinete/jinete.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "modules/gui.h"
|
#include "modules/gui.h"
|
||||||
#include "raster/sprite.h"
|
#include "raster/sprite.h"
|
||||||
#include "undoable.h"
|
#include "undoable.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// frame_properties
|
||||||
|
|
||||||
|
class FramePropertiesCommand : public Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FramePropertiesCommand();
|
||||||
|
Command* clone() { return new FramePropertiesCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
class SpriteReader;
|
class SpriteReader;
|
||||||
void dialogs_frame_length(const SpriteReader& sprite, int sprite_frame);
|
void dialogs_frame_length(const SpriteReader& sprite, int sprite_frame);
|
||||||
|
|
||||||
static bool cmd_frame_properties_enabled(const char *argument)
|
FramePropertiesCommand::FramePropertiesCommand()
|
||||||
|
: Command("frame_properties",
|
||||||
|
"Frame Properties",
|
||||||
|
CmdUIOnlyFlag)
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
}
|
||||||
|
|
||||||
|
bool FramePropertiesCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return
|
return
|
||||||
sprite != NULL;
|
sprite != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_frame_properties_execute(const char *argument)
|
void FramePropertiesCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
const CurrentSpriteReader sprite(context);
|
||||||
dialogs_frame_length(sprite, sprite->frame);
|
dialogs_frame_length(sprite, sprite->frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,9 +107,10 @@ void dialogs_frame_length(const SpriteReader& sprite, int sprite_frame)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_frame_properties = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_FRAME_PROPERTIES,
|
// CommandFactory
|
||||||
cmd_frame_properties_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_frame_properties_command()
|
||||||
cmd_frame_properties_execute,
|
{
|
||||||
};
|
return new FramePropertiesCommand;
|
||||||
|
}
|
||||||
|
@ -18,45 +18,81 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "modules/gui.h"
|
#include "modules/gui.h"
|
||||||
#include "modules/editors.h"
|
#include "modules/editors.h"
|
||||||
#include "raster/sprite.h"
|
#include "raster/sprite.h"
|
||||||
#include "widgets/editor.h"
|
#include "widgets/editor.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
|
||||||
/* ======================== */
|
//////////////////////////////////////////////////////////////////////
|
||||||
/* goto_first_frame */
|
// goto_first_frame
|
||||||
/* ======================== */
|
|
||||||
|
|
||||||
static bool cmd_goto_first_frame_enabled(const char *argument)
|
class GotoFirstFrameCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
GotoFirstFrameCommand();
|
||||||
|
Command* clone() { return new GotoFirstFrameCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
GotoFirstFrameCommand::GotoFirstFrameCommand()
|
||||||
|
: Command("goto_first_frame",
|
||||||
|
"Goto First Frame",
|
||||||
|
CmdRecordableFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GotoFirstFrameCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return sprite != NULL;
|
return sprite != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_goto_first_frame_execute(const char *argument)
|
void GotoFirstFrameCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
CurrentSpriteWriter sprite;
|
CurrentSpriteWriter sprite(context);
|
||||||
sprite->frame = 0;
|
sprite->frame = 0;
|
||||||
|
|
||||||
update_screen_for_sprite(sprite);
|
update_screen_for_sprite(sprite);
|
||||||
editor_update_statusbar_for_standby(current_editor);
|
editor_update_statusbar_for_standby(current_editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ======================== */
|
//////////////////////////////////////////////////////////////////////
|
||||||
/* goto_previous_frame */
|
// goto_previous_frame
|
||||||
/* ======================== */
|
|
||||||
|
class GotoPreviousFrameCommand : public Command
|
||||||
|
|
||||||
static bool cmd_goto_previous_frame_enabled(const char *argument)
|
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
GotoPreviousFrameCommand();
|
||||||
|
Command* clone() { return new GotoPreviousFrameCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
GotoPreviousFrameCommand::GotoPreviousFrameCommand()
|
||||||
|
: Command("goto_previous_frame",
|
||||||
|
"Goto Previous Frame",
|
||||||
|
CmdRecordableFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GotoPreviousFrameCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return
|
return
|
||||||
sprite != NULL;
|
sprite != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_goto_previous_frame_execute(const char *argument)
|
void GotoPreviousFrameCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
CurrentSpriteWriter sprite;
|
CurrentSpriteWriter sprite(context);
|
||||||
|
|
||||||
if (sprite->frame > 0)
|
if (sprite->frame > 0)
|
||||||
sprite->frame--;
|
sprite->frame--;
|
||||||
@ -67,20 +103,38 @@ static void cmd_goto_previous_frame_execute(const char *argument)
|
|||||||
editor_update_statusbar_for_standby(current_editor);
|
editor_update_statusbar_for_standby(current_editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ======================== */
|
//////////////////////////////////////////////////////////////////////
|
||||||
/* goto_next_frame */
|
// goto_next_frame
|
||||||
/* ======================== */
|
|
||||||
|
class GotoNextFrameCommand : public Command
|
||||||
|
|
||||||
static bool cmd_goto_next_frame_enabled(const char *argument)
|
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
GotoNextFrameCommand();
|
||||||
|
Command* clone() { return new GotoNextFrameCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
GotoNextFrameCommand::GotoNextFrameCommand()
|
||||||
|
: Command("goto_next_frame",
|
||||||
|
"Goto Next Frame",
|
||||||
|
CmdRecordableFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GotoNextFrameCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return
|
return
|
||||||
sprite != NULL;
|
sprite != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_goto_next_frame_execute(const char *argument)
|
void GotoNextFrameCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
CurrentSpriteWriter sprite;
|
CurrentSpriteWriter sprite(context);
|
||||||
|
|
||||||
if (sprite->frame < sprite->frames-1)
|
if (sprite->frame < sprite->frames-1)
|
||||||
sprite->frame++;
|
sprite->frame++;
|
||||||
@ -91,50 +145,63 @@ static void cmd_goto_next_frame_execute(const char *argument)
|
|||||||
editor_update_statusbar_for_standby(current_editor);
|
editor_update_statusbar_for_standby(current_editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ======================== */
|
//////////////////////////////////////////////////////////////////////
|
||||||
/* goto_last_frame */
|
// goto_last_frame
|
||||||
/* ======================== */
|
|
||||||
|
class GotoLastFrameCommand : public Command
|
||||||
|
|
||||||
static bool cmd_goto_last_frame_enabled(const char *argument)
|
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
GotoLastFrameCommand();
|
||||||
|
Command* clone() { return new GotoLastFrameCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
GotoLastFrameCommand::GotoLastFrameCommand()
|
||||||
|
: Command("goto_last_frame",
|
||||||
|
"Goto Last Frame",
|
||||||
|
CmdRecordableFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GotoLastFrameCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return
|
return
|
||||||
sprite != NULL;
|
sprite != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_goto_last_frame_execute(const char *argument)
|
void GotoLastFrameCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
CurrentSpriteWriter sprite;
|
CurrentSpriteWriter sprite(context);
|
||||||
sprite->frame = sprite->frames-1;
|
sprite->frame = sprite->frames-1;
|
||||||
|
|
||||||
update_screen_for_sprite(sprite);
|
update_screen_for_sprite(sprite);
|
||||||
editor_update_statusbar_for_standby(current_editor);
|
editor_update_statusbar_for_standby(current_editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_goto_first_frame = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_GOTO_FIRST_FRAME,
|
// CommandFactory
|
||||||
cmd_goto_first_frame_enabled,
|
|
||||||
NULL,
|
|
||||||
cmd_goto_first_frame_execute,
|
|
||||||
};
|
|
||||||
|
|
||||||
Command cmd_goto_previous_frame = {
|
Command* CommandFactory::create_goto_first_frame_command()
|
||||||
CMD_GOTO_PREVIOUS_FRAME,
|
{
|
||||||
cmd_goto_previous_frame_enabled,
|
return new GotoFirstFrameCommand;
|
||||||
NULL,
|
}
|
||||||
cmd_goto_previous_frame_execute,
|
|
||||||
};
|
|
||||||
|
|
||||||
Command cmd_goto_next_frame = {
|
Command* CommandFactory::create_goto_previous_frame_command()
|
||||||
CMD_GOTO_NEXT_FRAME,
|
{
|
||||||
cmd_goto_next_frame_enabled,
|
return new GotoPreviousFrameCommand;
|
||||||
NULL,
|
}
|
||||||
cmd_goto_next_frame_execute,
|
|
||||||
};
|
|
||||||
|
|
||||||
Command cmd_goto_last_frame = {
|
Command* CommandFactory::create_goto_next_frame_command()
|
||||||
CMD_GOTO_LAST_FRAME,
|
{
|
||||||
cmd_goto_last_frame_enabled,
|
return new GotoNextFrameCommand;
|
||||||
NULL,
|
}
|
||||||
cmd_goto_last_frame_execute,
|
|
||||||
};
|
Command* CommandFactory::create_goto_last_frame_command()
|
||||||
|
{
|
||||||
|
return new GotoLastFrameCommand;
|
||||||
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "core/app.h"
|
#include "core/app.h"
|
||||||
#include "modules/gui.h"
|
#include "modules/gui.h"
|
||||||
#include "modules/editors.h"
|
#include "modules/editors.h"
|
||||||
@ -26,21 +26,39 @@
|
|||||||
#include "raster/sprite.h"
|
#include "raster/sprite.h"
|
||||||
#include "widgets/editor.h"
|
#include "widgets/editor.h"
|
||||||
#include "widgets/statebar.h"
|
#include "widgets/statebar.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
|
||||||
/* ======================== */
|
//////////////////////////////////////////////////////////////////////
|
||||||
/* goto_previous_layer */
|
// goto_previous_layer
|
||||||
/* ======================== */
|
|
||||||
|
|
||||||
static bool cmd_goto_previous_layer_enabled(const char *argument)
|
class GotoPreviousLayerCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
GotoPreviousLayerCommand();
|
||||||
|
Command* clone() { return new GotoPreviousLayerCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
GotoPreviousLayerCommand::GotoPreviousLayerCommand()
|
||||||
|
: Command("goto_previous_layer",
|
||||||
|
"Goto Previous Layer",
|
||||||
|
CmdUIOnlyFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GotoPreviousLayerCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return
|
return
|
||||||
sprite != NULL;
|
sprite != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_goto_previous_layer_execute(const char *argument)
|
void GotoPreviousLayerCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
CurrentSpriteWriter sprite;
|
CurrentSpriteWriter sprite(context);
|
||||||
int i = sprite_layer2index(sprite, sprite->layer);
|
int i = sprite_layer2index(sprite, sprite->layer);
|
||||||
|
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
@ -58,20 +76,37 @@ static void cmd_goto_previous_layer_execute(const char *argument)
|
|||||||
sprite->layer->name);
|
sprite->layer->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ======================== */
|
//////////////////////////////////////////////////////////////////////
|
||||||
/* goto_next_layer */
|
// goto_next_layer
|
||||||
/* ======================== */
|
|
||||||
|
|
||||||
static bool cmd_goto_next_layer_enabled(const char *argument)
|
class GotoNextLayerCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
GotoNextLayerCommand();
|
||||||
|
Command* clone() { return new GotoNextLayerCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
GotoNextLayerCommand::GotoNextLayerCommand()
|
||||||
|
: Command("goto_next_layer",
|
||||||
|
"Goto Next Layer",
|
||||||
|
CmdUIOnlyFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GotoNextLayerCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return
|
return
|
||||||
sprite != NULL;
|
sprite != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_goto_next_layer_execute(const char *argument)
|
void GotoNextLayerCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
CurrentSpriteWriter sprite;
|
CurrentSpriteWriter sprite(context);
|
||||||
int i = sprite_layer2index(sprite, sprite->layer);
|
int i = sprite_layer2index(sprite, sprite->layer);
|
||||||
|
|
||||||
if (i < sprite_count_layers(sprite)-1)
|
if (i < sprite_count_layers(sprite)-1)
|
||||||
@ -89,16 +124,15 @@ static void cmd_goto_next_layer_execute(const char *argument)
|
|||||||
sprite->layer->name);
|
sprite->layer->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_goto_previous_layer = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_GOTO_PREVIOUS_LAYER,
|
// CommandFactory
|
||||||
cmd_goto_previous_layer_enabled,
|
|
||||||
NULL,
|
|
||||||
cmd_goto_previous_layer_execute,
|
|
||||||
};
|
|
||||||
|
|
||||||
Command cmd_goto_next_layer = {
|
Command* CommandFactory::create_goto_previous_layer_command()
|
||||||
CMD_GOTO_NEXT_LAYER,
|
{
|
||||||
cmd_goto_next_layer_enabled,
|
return new GotoPreviousLayerCommand;
|
||||||
NULL,
|
}
|
||||||
cmd_goto_next_layer_execute,
|
|
||||||
};
|
Command* CommandFactory::create_goto_next_layer_command()
|
||||||
|
{
|
||||||
|
return new GotoNextLayerCommand;
|
||||||
|
}
|
||||||
|
@ -20,60 +20,85 @@
|
|||||||
|
|
||||||
#include <allegro/unicode.h>
|
#include <allegro/unicode.h>
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "core/app.h"
|
#include "core/app.h"
|
||||||
#include "modules/editors.h"
|
#include "modules/editors.h"
|
||||||
#include "modules/tools.h"
|
#include "modules/tools.h"
|
||||||
#include "widgets/statebar.h"
|
#include "widgets/statebar.h"
|
||||||
|
|
||||||
/* ======================== */
|
//////////////////////////////////////////////////////////////////////
|
||||||
/* show_grid */
|
// show_grid
|
||||||
/* ======================== */
|
|
||||||
|
|
||||||
static bool cmd_show_grid_checked(const char *argument)
|
class ShowGridCommand : public Command
|
||||||
{
|
{
|
||||||
return get_view_grid();
|
public:
|
||||||
}
|
ShowGridCommand()
|
||||||
|
: Command("show_grid",
|
||||||
|
"Show Grid",
|
||||||
|
CmdUIOnlyFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
static void cmd_show_grid_execute(const char *argument)
|
Command* clone() const { return new ShowGridCommand(*this); }
|
||||||
{
|
|
||||||
set_view_grid(get_view_grid() ? false: true);
|
|
||||||
refresh_all_editors();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ======================== */
|
protected:
|
||||||
/* snap_to_grid */
|
bool checked(Context* context)
|
||||||
/* ======================== */
|
{
|
||||||
|
return get_view_grid();
|
||||||
static bool cmd_snap_to_grid_checked(const char *argument)
|
}
|
||||||
{
|
|
||||||
return get_use_grid();
|
void execute(Context* context)
|
||||||
}
|
{
|
||||||
|
set_view_grid(get_view_grid() ? false: true);
|
||||||
static void cmd_snap_to_grid_execute(const char *argument)
|
refresh_all_editors();
|
||||||
{
|
}
|
||||||
char buf[512];
|
|
||||||
|
|
||||||
set_use_grid(get_use_grid() ? false: true);
|
|
||||||
refresh_all_editors();
|
|
||||||
|
|
||||||
usprintf(buf, _("Snap to grid: %s"),
|
|
||||||
get_use_grid() ? _("On"):
|
|
||||||
_("Off"));
|
|
||||||
|
|
||||||
statusbar_set_text(app_get_statusbar(), 250, buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
Command cmd_show_grid = {
|
|
||||||
CMD_SHOW_GRID,
|
|
||||||
NULL,
|
|
||||||
cmd_show_grid_checked,
|
|
||||||
cmd_show_grid_execute,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Command cmd_snap_to_grid = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_SNAP_TO_GRID,
|
// snap_to_grid
|
||||||
NULL,
|
|
||||||
cmd_snap_to_grid_checked,
|
class SnapToGridCommand : public Command
|
||||||
cmd_snap_to_grid_execute,
|
{
|
||||||
|
public:
|
||||||
|
SnapToGridCommand()
|
||||||
|
: Command("snap_to_grid",
|
||||||
|
"Snap to Grid",
|
||||||
|
CmdUIOnlyFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Command* clone() const { return new SnapToGridCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool checked(Context* context)
|
||||||
|
{
|
||||||
|
return get_use_grid();
|
||||||
|
}
|
||||||
|
|
||||||
|
void execute(Context* context)
|
||||||
|
{
|
||||||
|
char buf[512];
|
||||||
|
|
||||||
|
set_use_grid(get_use_grid() ? false: true);
|
||||||
|
refresh_all_editors();
|
||||||
|
|
||||||
|
usprintf(buf, _("Snap to grid: %s"),
|
||||||
|
get_use_grid() ? _("On"):
|
||||||
|
_("Off"));
|
||||||
|
|
||||||
|
statusbar_set_text(app_get_statusbar(), 250, buf);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// CommandFactory
|
||||||
|
|
||||||
|
Command* CommandFactory::create_show_grid_command()
|
||||||
|
{
|
||||||
|
return new ShowGridCommand;
|
||||||
|
}
|
||||||
|
|
||||||
|
Command* CommandFactory::create_snap_to_grid_command()
|
||||||
|
{
|
||||||
|
return new SnapToGridCommand;
|
||||||
|
}
|
||||||
|
@ -18,29 +18,62 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "commands/command.h"
|
||||||
#include "commands/commands.h"
|
#include "commands/commands.h"
|
||||||
#include "modules/gui.h"
|
#include "modules/gui.h"
|
||||||
#include "raster/image.h"
|
#include "raster/image.h"
|
||||||
#include "raster/mask.h"
|
#include "raster/mask.h"
|
||||||
#include "raster/sprite.h"
|
#include "raster/sprite.h"
|
||||||
#include "raster/undo.h"
|
#include "raster/undo.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
|
||||||
static bool cmd_invert_mask_enabled(const char *argument)
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// invert_mask
|
||||||
|
|
||||||
|
class InvertMaskCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
InvertMaskCommand();
|
||||||
|
Command* clone() { return new InvertMaskCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
InvertMaskCommand::InvertMaskCommand()
|
||||||
|
: Command("invert_mask",
|
||||||
|
"Invert Mask",
|
||||||
|
CmdRecordableFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool InvertMaskCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return sprite != NULL;
|
return sprite != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_invert_mask_execute(const char *argument)
|
void InvertMaskCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
CurrentSpriteWriter sprite;
|
bool has_mask = false;
|
||||||
Mask *mask;
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
/* change the selection */
|
if (sprite->mask->bitmap)
|
||||||
if (!sprite->mask->bitmap) {
|
has_mask = true;
|
||||||
command_execute(command_get_by_name(CMD_MASK_ALL), argument);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// without mask?...
|
||||||
|
if (!has_mask) {
|
||||||
|
// so we select all
|
||||||
|
Command* mask_all_cmd =
|
||||||
|
CommandsModule::instance()->get_command_by_name(CommandId::mask_all);
|
||||||
|
context->execute_command(mask_all_cmd);
|
||||||
|
}
|
||||||
|
// invert the current mask
|
||||||
else {
|
else {
|
||||||
|
CurrentSpriteWriter sprite(context);
|
||||||
|
|
||||||
/* undo */
|
/* undo */
|
||||||
if (undo_is_enabled(sprite->undo)) {
|
if (undo_is_enabled(sprite->undo)) {
|
||||||
undo_set_label(sprite->undo, "Mask Invert");
|
undo_set_label(sprite->undo, "Mask Invert");
|
||||||
@ -48,7 +81,7 @@ static void cmd_invert_mask_execute(const char *argument)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* create a new mask */
|
/* create a new mask */
|
||||||
mask = mask_new();
|
Mask* mask = mask_new();
|
||||||
|
|
||||||
/* select all the sprite area */
|
/* select all the sprite area */
|
||||||
mask_replace(mask, 0, 0, sprite->w, sprite->h);
|
mask_replace(mask, 0, 0, sprite->w, sprite->h);
|
||||||
@ -79,9 +112,10 @@ static void cmd_invert_mask_execute(const char *argument)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_invert_mask = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_INVERT_MASK,
|
// CommandFactory
|
||||||
cmd_invert_mask_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_invert_mask_command()
|
||||||
cmd_invert_mask_execute,
|
{
|
||||||
};
|
return new InvertMaskCommand;
|
||||||
|
}
|
||||||
|
@ -20,14 +20,36 @@
|
|||||||
|
|
||||||
#include "jinete/jinete.h"
|
#include "jinete/jinete.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "modules/gui.h"
|
#include "modules/gui.h"
|
||||||
#include "raster/layer.h"
|
#include "raster/layer.h"
|
||||||
#include "undoable.h"
|
#include "undoable.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
|
||||||
static bool cmd_layer_from_background_enabled(const char *argument)
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// layer_from_background
|
||||||
|
|
||||||
|
class LayerFromBackgroundCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
LayerFromBackgroundCommand();
|
||||||
|
Command* clone() { return new LayerFromBackgroundCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
LayerFromBackgroundCommand::LayerFromBackgroundCommand()
|
||||||
|
: Command("layer_from_background",
|
||||||
|
"Layer From Background",
|
||||||
|
CmdRecordableFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LayerFromBackgroundCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return
|
return
|
||||||
sprite != NULL &&
|
sprite != NULL &&
|
||||||
sprite->layer != NULL &&
|
sprite->layer != NULL &&
|
||||||
@ -37,9 +59,9 @@ static bool cmd_layer_from_background_enabled(const char *argument)
|
|||||||
layer_is_background(sprite->layer);
|
layer_is_background(sprite->layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_layer_from_background_execute(const char *argument)
|
void LayerFromBackgroundCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
CurrentSpriteWriter sprite;
|
CurrentSpriteWriter sprite(context);
|
||||||
{
|
{
|
||||||
Undoable undoable(sprite, "Layer from Background");
|
Undoable undoable(sprite, "Layer from Background");
|
||||||
undoable.layer_from_background();
|
undoable.layer_from_background();
|
||||||
@ -48,9 +70,11 @@ static void cmd_layer_from_background_execute(const char *argument)
|
|||||||
update_screen_for_sprite(sprite);
|
update_screen_for_sprite(sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_layer_from_background = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_LAYER_FROM_BACKGROUND,
|
// CommandFactory
|
||||||
cmd_layer_from_background_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_layer_from_background_command()
|
||||||
cmd_layer_from_background_execute,
|
{
|
||||||
};
|
return new LayerFromBackgroundCommand;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -20,25 +20,47 @@
|
|||||||
|
|
||||||
#include "jinete/jinete.h"
|
#include "jinete/jinete.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "core/app.h"
|
#include "core/app.h"
|
||||||
#include "modules/gui.h"
|
#include "modules/gui.h"
|
||||||
#include "raster/layer.h"
|
#include "raster/layer.h"
|
||||||
#include "raster/sprite.h"
|
#include "raster/sprite.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
|
||||||
static bool cmd_layer_properties_enabled(const char *argument)
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// layer_properties
|
||||||
|
|
||||||
|
class LayerPropertiesCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
LayerPropertiesCommand();
|
||||||
|
Command* clone() { return new LayerPropertiesCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
LayerPropertiesCommand::LayerPropertiesCommand()
|
||||||
|
: Command("layer_properties",
|
||||||
|
"Layer Properties",
|
||||||
|
CmdRecordableFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LayerPropertiesCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return
|
return
|
||||||
sprite != NULL &&
|
sprite != NULL &&
|
||||||
sprite->layer != NULL;
|
sprite->layer != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_layer_properties_execute(const char *argument)
|
void LayerPropertiesCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
JWidget box1, box2, box3, label_name, entry_name;
|
JWidget box1, box2, box3, label_name, entry_name;
|
||||||
JWidget button_ok, button_cancel, label_bm, view_bm, list_bm;
|
JWidget button_ok, button_cancel, label_bm, view_bm, list_bm;
|
||||||
CurrentSpriteWriter sprite;
|
CurrentSpriteWriter sprite(context);
|
||||||
Layer *layer = sprite->layer;
|
Layer *layer = sprite->layer;
|
||||||
|
|
||||||
JWidgetPtr window(jwindow_new(_("Layer Properties")));
|
JWidgetPtr window(jwindow_new(_("Layer Properties")));
|
||||||
@ -107,9 +129,10 @@ static void cmd_layer_properties_execute(const char *argument)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_layer_properties = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_LAYER_PROPERTIES,
|
// CommandFactory
|
||||||
cmd_layer_properties_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_layer_properties_command()
|
||||||
cmd_layer_properties_execute,
|
{
|
||||||
};
|
return new LayerPropertiesCommand;
|
||||||
|
}
|
||||||
|
@ -20,50 +20,85 @@
|
|||||||
|
|
||||||
#include "jinete/jalert.h"
|
#include "jinete/jalert.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
|
#include "commands/params.h"
|
||||||
#include "dialogs/filesel.h"
|
#include "dialogs/filesel.h"
|
||||||
#include "modules/gui.h"
|
#include "modules/gui.h"
|
||||||
#include "raster/mask.h"
|
#include "raster/mask.h"
|
||||||
#include "raster/sprite.h"
|
#include "raster/sprite.h"
|
||||||
#include "raster/undo.h"
|
#include "raster/undo.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
#include "util/msk_file.h"
|
#include "util/msk_file.h"
|
||||||
|
|
||||||
static bool cmd_load_mask_enabled(const char *argument)
|
class LoadMaskCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
std::string m_filename;
|
||||||
|
|
||||||
|
public:
|
||||||
|
LoadMaskCommand();
|
||||||
|
Command* clone() const { return new LoadMaskCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void load_params(Params* params);
|
||||||
|
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
LoadMaskCommand::LoadMaskCommand()
|
||||||
|
: Command("load_mask",
|
||||||
|
"LoadMask",
|
||||||
|
CmdRecordableFlag)
|
||||||
|
{
|
||||||
|
m_filename = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadMaskCommand::load_params(Params* params)
|
||||||
|
{
|
||||||
|
m_filename = params->get("filename");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LoadMaskCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return sprite != NULL;
|
return sprite != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_load_mask_execute(const char *argument)
|
void LoadMaskCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
CurrentSpriteWriter sprite;
|
CurrentSpriteWriter sprite(context);
|
||||||
jstring filename = ase_file_selector(_("Load .msk File"), "", "msk");
|
|
||||||
if (!filename.empty()) {
|
jstring filename = m_filename;
|
||||||
Mask *mask = load_msk_file(filename.c_str());
|
|
||||||
if (!mask) {
|
if (context->is_ui_available()) {
|
||||||
jalert("%s<<%s<<%s||%s",
|
filename = ase_file_selector(_("Load .msk File"), filename, "msk");
|
||||||
_("Error"), _("Error loading .msk file"),
|
if (filename.empty())
|
||||||
filename.c_str(), _("&Close"));
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
/* undo */
|
m_filename = filename;
|
||||||
if (undo_is_enabled(sprite->undo)) {
|
|
||||||
undo_set_label(sprite->undo, "Mask Load");
|
|
||||||
undo_set_mask(sprite->undo, sprite);
|
|
||||||
}
|
|
||||||
|
|
||||||
sprite_set_mask(sprite, mask);
|
|
||||||
mask_free(mask);
|
|
||||||
|
|
||||||
sprite_generate_mask_boundaries(sprite);
|
|
||||||
update_screen_for_sprite(sprite);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Mask *mask = load_msk_file(m_filename.c_str());
|
||||||
|
if (!mask)
|
||||||
|
throw ase_exception("Error loading .msk file: " + m_filename);
|
||||||
|
|
||||||
|
// undo
|
||||||
|
if (undo_is_enabled(sprite->undo)) {
|
||||||
|
undo_set_label(sprite->undo, "Mask Load");
|
||||||
|
undo_set_mask(sprite->undo, sprite);
|
||||||
|
}
|
||||||
|
|
||||||
|
sprite_set_mask(sprite, mask);
|
||||||
|
mask_free(mask);
|
||||||
|
|
||||||
|
sprite_generate_mask_boundaries(sprite);
|
||||||
|
update_screen_for_sprite(sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_load_mask = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_LOAD_MASK,
|
// CommandFactory
|
||||||
cmd_load_mask_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_load_mask_command()
|
||||||
cmd_load_mask_execute,
|
{
|
||||||
};
|
return new LoadMaskCommand;
|
||||||
|
}
|
||||||
|
@ -18,21 +18,43 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "modules/gui.h"
|
#include "modules/gui.h"
|
||||||
#include "raster/mask.h"
|
#include "raster/mask.h"
|
||||||
#include "raster/sprite.h"
|
#include "raster/sprite.h"
|
||||||
#include "raster/undo.h"
|
#include "raster/undo.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
|
||||||
static bool cmd_mask_all_enabled(const char *argument)
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// mask_all
|
||||||
|
|
||||||
|
class MaskAllCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
MaskAllCommand();
|
||||||
|
Command* clone() { return new MaskAllCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
MaskAllCommand::MaskAllCommand()
|
||||||
|
: Command("mask_all",
|
||||||
|
"Mask All",
|
||||||
|
CmdRecordableFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MaskAllCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return sprite != NULL;
|
return sprite != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_mask_all_execute(const char *argument)
|
void MaskAllCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
CurrentSpriteWriter sprite;
|
CurrentSpriteWriter sprite(context);
|
||||||
|
|
||||||
/* undo */
|
/* undo */
|
||||||
if (undo_is_enabled(sprite->undo)) {
|
if (undo_is_enabled(sprite->undo)) {
|
||||||
@ -47,9 +69,10 @@ static void cmd_mask_all_execute(const char *argument)
|
|||||||
update_screen_for_sprite(sprite);
|
update_screen_for_sprite(sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_mask_all = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_MASK_ALL,
|
// CommandFactory
|
||||||
cmd_mask_all_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_mask_all_command()
|
||||||
cmd_mask_all_execute,
|
{
|
||||||
};
|
return new MaskAllCommand;
|
||||||
|
}
|
||||||
|
@ -20,25 +20,48 @@
|
|||||||
|
|
||||||
#include "jinete/jbase.h"
|
#include "jinete/jbase.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "dialogs/maskcol.h"
|
#include "dialogs/maskcol.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
|
||||||
static bool cmd_mask_by_color_enabled(const char *argument)
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// mask_by_color
|
||||||
|
|
||||||
|
class MaskByColorCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
MaskByColorCommand();
|
||||||
|
Command* clone() { return new MaskByColorCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
MaskByColorCommand::MaskByColorCommand()
|
||||||
|
: Command("mask_by_color",
|
||||||
|
"Mask By Color",
|
||||||
|
CmdUIOnlyFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MaskByColorCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return
|
return
|
||||||
sprite != NULL;
|
sprite != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_mask_by_color_execute(const char *argument)
|
void MaskByColorCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
CurrentSpriteWriter sprite;
|
CurrentSpriteWriter sprite(context);
|
||||||
dialogs_mask_color(sprite);
|
dialogs_mask_color(sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_mask_by_color = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_MASK_BY_COLOR,
|
// CommandFactory
|
||||||
cmd_mask_by_color_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_mask_by_color_command()
|
||||||
cmd_mask_by_color_execute,
|
{
|
||||||
};
|
return new MaskByColorCommand;
|
||||||
|
}
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#include "jinete/jinete.h"
|
#include "jinete/jinete.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "core/app.h"
|
#include "core/app.h"
|
||||||
#include "modules/gui.h"
|
#include "modules/gui.h"
|
||||||
#include "raster/cel.h"
|
#include "raster/cel.h"
|
||||||
@ -29,10 +29,32 @@
|
|||||||
#include "raster/sprite.h"
|
#include "raster/sprite.h"
|
||||||
#include "raster/stock.h"
|
#include "raster/stock.h"
|
||||||
#include "raster/undo.h"
|
#include "raster/undo.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
|
||||||
static bool cmd_merge_down_layer_enabled(const char *argument)
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// merge_down_layer
|
||||||
|
|
||||||
|
class MergeDownLayerCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
MergeDownLayerCommand();
|
||||||
|
Command* clone() { return new MergeDownLayerCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
MergeDownLayerCommand::MergeDownLayerCommand()
|
||||||
|
: Command("merge_down_layer",
|
||||||
|
"Merge Down Layer",
|
||||||
|
CmdRecordableFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MergeDownLayerCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
if (!sprite)
|
if (!sprite)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -47,9 +69,9 @@ static bool cmd_merge_down_layer_enabled(const char *argument)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_merge_down_layer_execute(const char *argument)
|
void MergeDownLayerCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
CurrentSpriteWriter sprite;
|
CurrentSpriteWriter sprite(context);
|
||||||
Layer *src_layer, *dst_layer;
|
Layer *src_layer, *dst_layer;
|
||||||
Cel *src_cel, *dst_cel;
|
Cel *src_cel, *dst_cel;
|
||||||
Image *src_image, *dst_image;
|
Image *src_image, *dst_image;
|
||||||
@ -167,9 +189,10 @@ static void cmd_merge_down_layer_execute(const char *argument)
|
|||||||
update_screen_for_sprite(sprite);
|
update_screen_for_sprite(sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_merge_down_layer = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_MERGE_DOWN_LAYER,
|
// CommandFactory
|
||||||
cmd_merge_down_layer_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_merge_down_layer_command()
|
||||||
cmd_merge_down_layer_execute,
|
{
|
||||||
};
|
return new MergeDownLayerCommand;
|
||||||
|
}
|
||||||
|
@ -20,24 +20,44 @@
|
|||||||
|
|
||||||
#include "jinete/jbase.h"
|
#include "jinete/jbase.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "dialogs/aniedit.h"
|
#include "dialogs/aniedit.h"
|
||||||
#include "util/celmove.h"
|
#include "util/celmove.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
|
||||||
static bool cmd_move_cel_enabled(const char *argument)
|
class MoveCelCommand : public Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MoveCelCommand();
|
||||||
|
Command* clone() const { return new MoveCelCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
MoveCelCommand::MoveCelCommand()
|
||||||
|
: Command("move_cel",
|
||||||
|
"Move Cel",
|
||||||
|
CmdUIOnlyFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MoveCelCommand::enabled(Context* context)
|
||||||
{
|
{
|
||||||
return animation_editor_is_movingcel();
|
return animation_editor_is_movingcel();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_move_cel_execute(const char *argument)
|
void MoveCelCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
CurrentSpriteWriter sprite;
|
CurrentSpriteWriter sprite(context);
|
||||||
move_cel(sprite);
|
move_cel(sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_move_cel = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_MOVE_CEL,
|
// CommandFactory
|
||||||
cmd_move_cel_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_move_cel_command()
|
||||||
cmd_move_cel_execute,
|
{
|
||||||
};
|
return new MoveCelCommand;
|
||||||
|
}
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#include "jinete/jinete.h"
|
#include "jinete/jinete.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "core/color.h"
|
#include "core/color.h"
|
||||||
#include "modules/gui.h"
|
#include "modules/gui.h"
|
||||||
@ -31,7 +31,21 @@
|
|||||||
#include "raster/stock.h"
|
#include "raster/stock.h"
|
||||||
#include "raster/undo.h"
|
#include "raster/undo.h"
|
||||||
|
|
||||||
static bool cmd_new_cel_enabled(const char *argument)
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// new_cel
|
||||||
|
|
||||||
|
class NewCelCommand : public Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NewCelCommand();
|
||||||
|
Command* clone() { return new NewCelCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
bool NewCelCommand::enabled(Context* context)
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
current_sprite &&
|
current_sprite &&
|
||||||
@ -42,7 +56,7 @@ static bool cmd_new_cel_enabled(const char *argument)
|
|||||||
!layer_get_cel(current_sprite->layer, current_sprite->frame);
|
!layer_get_cel(current_sprite->layer, current_sprite->frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_new_cel_execute(const char *argument)
|
void NewCelCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
int image_index;
|
int image_index;
|
||||||
Image *image;
|
Image *image;
|
||||||
@ -85,10 +99,10 @@ static void cmd_new_cel_execute(const char *argument)
|
|||||||
update_screen_for_sprite(current_sprite);
|
update_screen_for_sprite(current_sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_new_cel = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_NEW_CEL,
|
// CommandFactory
|
||||||
cmd_new_cel_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_new_cel_command()
|
||||||
cmd_new_cel_execute,
|
{
|
||||||
NULL
|
return new NewCelCommand;
|
||||||
};
|
}
|
||||||
|
@ -25,11 +25,12 @@
|
|||||||
#include "jinete/jinete.h"
|
#include "jinete/jinete.h"
|
||||||
|
|
||||||
#include "ui_context.h"
|
#include "ui_context.h"
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "core/app.h"
|
#include "core/app.h"
|
||||||
#include "core/cfg.h"
|
#include "core/cfg.h"
|
||||||
#include "core/color.h"
|
#include "core/color.h"
|
||||||
|
#include "modules/editors.h"
|
||||||
#include "modules/gui.h"
|
#include "modules/gui.h"
|
||||||
#include "raster/image.h"
|
#include "raster/image.h"
|
||||||
#include "raster/layer.h"
|
#include "raster/layer.h"
|
||||||
@ -38,14 +39,34 @@
|
|||||||
#include "util/misc.h"
|
#include "util/misc.h"
|
||||||
#include "widgets/colbar.h"
|
#include "widgets/colbar.h"
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// new_file
|
||||||
|
|
||||||
|
class NewFileCommand : public Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NewFileCommand();
|
||||||
|
Command* clone() { return new NewFileCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
static int _sprite_counter = 0;
|
static int _sprite_counter = 0;
|
||||||
|
|
||||||
static Sprite *new_sprite(Context* context, int imgtype, int w, int h);
|
static Sprite *new_sprite(Context* context, int imgtype, int w, int h);
|
||||||
|
|
||||||
|
NewFileCommand::NewFileCommand()
|
||||||
|
: Command("new_file",
|
||||||
|
"New File",
|
||||||
|
CmdRecordableFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows the "New Sprite" dialog.
|
* Shows the "New Sprite" dialog.
|
||||||
*/
|
*/
|
||||||
static void cmd_new_file_execute(const char *argument)
|
void NewFileCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
JWidget width, height, radio1, radio2, radio3, ok, bg_box;
|
JWidget width, height, radio1, radio2, radio3, ok, bg_box;
|
||||||
int imgtype, w, h, bg;
|
int imgtype, w, h, bg;
|
||||||
@ -143,8 +164,8 @@ static void cmd_new_file_execute(const char *argument)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* show the sprite to the user */
|
/* show the sprite to the user */
|
||||||
UIContext* context = UIContext::instance();
|
context->add_sprite(sprite);
|
||||||
context->show_sprite(sprite);
|
set_sprite_in_more_reliable_editor(sprite);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -164,19 +185,13 @@ static Sprite *new_sprite(Context* context, int imgtype, int w, int h)
|
|||||||
assert(w >= 1 && w <= 9999);
|
assert(w >= 1 && w <= 9999);
|
||||||
assert(h >= 1 && h <= 9999);
|
assert(h >= 1 && h <= 9999);
|
||||||
|
|
||||||
Sprite *sprite = sprite_new_with_layer(imgtype, w, h);
|
return sprite_new_with_layer(imgtype, w, h);
|
||||||
if (!sprite)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
context->add_sprite(sprite);
|
|
||||||
context->set_current_sprite(sprite);
|
|
||||||
|
|
||||||
return sprite;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_new_file = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_NEW_FILE,
|
// CommandFactory
|
||||||
NULL,
|
|
||||||
NULL,
|
Command* CommandFactory::create_new_file_command()
|
||||||
cmd_new_file_execute,
|
{
|
||||||
};
|
return new NewFileCommand;
|
||||||
|
}
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "jinete/jinete.h"
|
#include "jinete/jinete.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "core/color.h"
|
#include "core/color.h"
|
||||||
#include "core/app.h"
|
#include "core/app.h"
|
||||||
@ -32,12 +32,34 @@
|
|||||||
#include "raster/sprite.h"
|
#include "raster/sprite.h"
|
||||||
#include "undoable.h"
|
#include "undoable.h"
|
||||||
#include "widgets/statebar.h"
|
#include "widgets/statebar.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
static bool cmd_new_frame_enabled(const char *argument)
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// new_frame
|
||||||
|
|
||||||
|
class NewFrameCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
NewFrameCommand();
|
||||||
|
Command* clone() { return new NewFrameCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
NewFrameCommand::NewFrameCommand()
|
||||||
|
: Command("new_frame",
|
||||||
|
"New Frame",
|
||||||
|
CmdRecordableFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NewFrameCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return
|
return
|
||||||
sprite != NULL &&
|
sprite != NULL &&
|
||||||
sprite->layer != NULL &&
|
sprite->layer != NULL &&
|
||||||
@ -46,9 +68,9 @@ static bool cmd_new_frame_enabled(const char *argument)
|
|||||||
layer_is_image(sprite->layer);
|
layer_is_image(sprite->layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_new_frame_execute(const char *argument)
|
void NewFrameCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
CurrentSpriteWriter sprite;
|
CurrentSpriteWriter sprite(context);
|
||||||
{
|
{
|
||||||
Undoable undoable(sprite, "New Frame");
|
Undoable undoable(sprite, "New Frame");
|
||||||
undoable.new_frame();
|
undoable.new_frame();
|
||||||
@ -61,9 +83,10 @@ static void cmd_new_frame_execute(const char *argument)
|
|||||||
sprite->frames);
|
sprite->frames);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_new_frame = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_NEW_FRAME,
|
// CommandFactory
|
||||||
cmd_new_frame_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_new_frame_command()
|
||||||
cmd_new_frame_execute,
|
{
|
||||||
};
|
return new NewFrameCommand;
|
||||||
|
}
|
||||||
|
@ -20,25 +20,48 @@
|
|||||||
|
|
||||||
#include "jinete/jinete.h"
|
#include "jinete/jinete.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "core/app.h"
|
#include "core/app.h"
|
||||||
#include "modules/gui.h"
|
#include "modules/gui.h"
|
||||||
#include "raster/layer.h"
|
#include "raster/layer.h"
|
||||||
#include "raster/sprite.h"
|
#include "raster/sprite.h"
|
||||||
#include "undoable.h"
|
#include "undoable.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// new_layer
|
||||||
|
|
||||||
|
class NewLayerCommand : public Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NewLayerCommand();
|
||||||
|
Command* clone() { return new NewLayerCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
static char* get_unique_layer_name(Sprite* sprite);
|
static char* get_unique_layer_name(Sprite* sprite);
|
||||||
static int get_max_layer_num(Layer* layer);
|
static int get_max_layer_num(Layer* layer);
|
||||||
|
|
||||||
static bool cmd_new_layer_enabled(const char* argument)
|
NewLayerCommand::NewLayerCommand()
|
||||||
|
: Command("new_layer",
|
||||||
|
"New Layer",
|
||||||
|
CmdRecordableFlag)
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
|
||||||
return sprite.is_valid();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_new_layer_execute(const char* argument)
|
bool NewLayerCommand::enabled(Context* context)
|
||||||
{
|
{
|
||||||
CurrentSpriteWriter sprite;
|
const CurrentSpriteReader sprite(context);
|
||||||
|
return
|
||||||
|
sprite != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NewLayerCommand::execute(Context* context)
|
||||||
|
{
|
||||||
|
CurrentSpriteWriter sprite(context);
|
||||||
|
|
||||||
JWidgetPtr window(load_widget("newlay.jid", "new_layer"));
|
JWidgetPtr window(load_widget("newlay.jid", "new_layer"));
|
||||||
JWidget name_widget = find_widget(window, "name");
|
JWidget name_widget = find_widget(window, "name");
|
||||||
@ -93,9 +116,10 @@ static int get_max_layer_num(Layer* layer)
|
|||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_new_layer = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_NEW_LAYER,
|
// CommandFactory
|
||||||
cmd_new_layer_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_new_layer_command()
|
||||||
cmd_new_layer_execute,
|
{
|
||||||
};
|
return new NewLayerCommand;
|
||||||
|
}
|
||||||
|
@ -20,22 +20,44 @@
|
|||||||
|
|
||||||
#include "jinete/jinete.h"
|
#include "jinete/jinete.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "core/app.h"
|
#include "core/app.h"
|
||||||
#include "modules/gui.h"
|
#include "modules/gui.h"
|
||||||
#include "raster/layer.h"
|
#include "raster/layer.h"
|
||||||
#include "raster/sprite.h"
|
#include "raster/sprite.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
|
||||||
static bool cmd_new_layer_set_enabled(const char *argument)
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// new_layer_set
|
||||||
|
|
||||||
|
class NewLayerSetCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
NewLayerSetCommand();
|
||||||
|
Command* clone() { return new NewLayerSetCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
NewLayerSetCommand::NewLayerSetCommand()
|
||||||
|
: Command("new_layer_set",
|
||||||
|
"New Layer Set",
|
||||||
|
CmdRecordableFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NewLayerSetCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return
|
return
|
||||||
sprite != NULL;
|
sprite != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_new_layer_set_execute(const char *argument)
|
void NewLayerSetCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
CurrentSpriteWriter sprite;
|
CurrentSpriteWriter sprite(context);
|
||||||
|
|
||||||
// load the window widget
|
// load the window widget
|
||||||
JWidgetPtr window(load_widget("newlay.jid", "new_layer_set"));
|
JWidgetPtr window(load_widget("newlay.jid", "new_layer_set"));
|
||||||
@ -54,9 +76,10 @@ static void cmd_new_layer_set_execute(const char *argument)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_new_layer_set = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_NEW_LAYER_SET,
|
// CommandFactory
|
||||||
cmd_new_layer_set_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_new_layer_set_command()
|
||||||
cmd_new_layer_set_execute,
|
{
|
||||||
};
|
return new NewLayerSetCommand;
|
||||||
|
}
|
||||||
|
@ -24,7 +24,8 @@
|
|||||||
#include "jinete/jinete.h"
|
#include "jinete/jinete.h"
|
||||||
|
|
||||||
#include "ui_context.h"
|
#include "ui_context.h"
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
|
#include "commands/params.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "core/app.h"
|
#include "core/app.h"
|
||||||
#include "dialogs/filesel.h"
|
#include "dialogs/filesel.h"
|
||||||
@ -35,6 +36,22 @@
|
|||||||
#include "modules/recent.h"
|
#include "modules/recent.h"
|
||||||
#include "widgets/statebar.h"
|
#include "widgets/statebar.h"
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// open_file
|
||||||
|
|
||||||
|
class OpenFileCommand : public Command
|
||||||
|
{
|
||||||
|
std::string m_filename;
|
||||||
|
|
||||||
|
public:
|
||||||
|
OpenFileCommand();
|
||||||
|
Command* clone() { return new OpenFileCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void load_params(Params* params);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct OpenFileData
|
typedef struct OpenFileData
|
||||||
{
|
{
|
||||||
Monitor *monitor;
|
Monitor *monitor;
|
||||||
@ -134,29 +151,37 @@ static void monitor_free(void* _data)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OpenFileCommand::OpenFileCommand()
|
||||||
|
: Command("open_file",
|
||||||
|
"Open Sprite",
|
||||||
|
CmdRecordableFlag)
|
||||||
|
{
|
||||||
|
m_filename = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenFileCommand::load_params(Params* params)
|
||||||
|
{
|
||||||
|
m_filename = params->get("filename");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command to open a file.
|
* Command to open a file.
|
||||||
*
|
*
|
||||||
* [main thread]
|
* [main thread]
|
||||||
*/
|
*/
|
||||||
static void cmd_open_file_execute(const char *argument)
|
void OpenFileCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
Console console;
|
Console console;
|
||||||
jstring filename;
|
|
||||||
|
|
||||||
// interactive
|
// interactive
|
||||||
if (ustrlen(argument) == 0) {
|
if (context->is_ui_available() && m_filename.empty()) {
|
||||||
char exts[4096];
|
char exts[4096];
|
||||||
get_readable_extensions(exts, sizeof(exts));
|
get_readable_extensions(exts, sizeof(exts));
|
||||||
filename = ase_file_selector(_("Open Sprite"), "", exts);
|
m_filename = ase_file_selector(friendly_name(), "", exts);
|
||||||
}
|
|
||||||
// load the file specified in the argument
|
|
||||||
else {
|
|
||||||
filename = argument;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!filename.empty()) {
|
if (!m_filename.empty()) {
|
||||||
FileOp *fop = fop_to_load_sprite(filename.c_str(), FILE_LOAD_SEQUENCE_ASK);
|
FileOp *fop = fop_to_load_sprite(m_filename.c_str(), FILE_LOAD_SEQUENCE_ASK);
|
||||||
|
|
||||||
if (fop) {
|
if (fop) {
|
||||||
if (fop->error) {
|
if (fop->error) {
|
||||||
@ -173,7 +198,7 @@ static void cmd_open_file_execute(const char *argument)
|
|||||||
data->thread = thread;
|
data->thread = thread;
|
||||||
data->alert_window = jalert_new(PACKAGE
|
data->alert_window = jalert_new(PACKAGE
|
||||||
"<<Loading file:<<%s||&Cancel",
|
"<<Loading file:<<%s||&Cancel",
|
||||||
get_filename(filename.c_str()));
|
get_filename(m_filename.c_str()));
|
||||||
|
|
||||||
/* add a monitor to check the loading (FileOp) progress */
|
/* add a monitor to check the loading (FileOp) progress */
|
||||||
data->monitor = add_gui_monitor(monitor_openfile_bg,
|
data->monitor = add_gui_monitor(monitor_openfile_bg,
|
||||||
@ -199,7 +224,8 @@ static void cmd_open_file_execute(const char *argument)
|
|||||||
|
|
||||||
recent_file(fop->filename);
|
recent_file(fop->filename);
|
||||||
context->add_sprite(sprite);
|
context->add_sprite(sprite);
|
||||||
context->show_sprite(sprite);
|
|
||||||
|
set_sprite_in_more_reliable_editor(sprite);
|
||||||
}
|
}
|
||||||
/* if the sprite isn't NULL and the file-operation wasn't
|
/* if the sprite isn't NULL and the file-operation wasn't
|
||||||
stopped by the user... */
|
stopped by the user... */
|
||||||
@ -227,9 +253,10 @@ static void cmd_open_file_execute(const char *argument)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_open_file = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_OPEN_FILE,
|
// CommandFactory
|
||||||
NULL,
|
|
||||||
NULL,
|
Command* CommandFactory::create_open_file_command()
|
||||||
cmd_open_file_execute,
|
{
|
||||||
};
|
return new OpenFileCommand;
|
||||||
|
}
|
||||||
|
@ -20,17 +20,38 @@
|
|||||||
|
|
||||||
#include "jinete/jbase.h"
|
#include "jinete/jbase.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "dialogs/options.h"
|
#include "dialogs/options.h"
|
||||||
|
|
||||||
static void cmd_options_execute(const char *argument)
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// options
|
||||||
|
|
||||||
|
class OptionsCommand : public Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
OptionsCommand();
|
||||||
|
Command* clone() { return new OptionsCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
OptionsCommand::OptionsCommand()
|
||||||
|
: Command("options",
|
||||||
|
"Options",
|
||||||
|
CmdUIOnlyFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void OptionsCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
dialogs_options();
|
dialogs_options();
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_options = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_OPTIONS,
|
// CommandFactory
|
||||||
NULL,
|
|
||||||
NULL,
|
Command* CommandFactory::create_options_command()
|
||||||
cmd_options_execute,
|
{
|
||||||
};
|
return new OptionsCommand;
|
||||||
|
}
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#include "jinete/jinete.h"
|
#include "jinete/jinete.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "core/cfg.h"
|
#include "core/cfg.h"
|
||||||
#include "core/color.h"
|
#include "core/color.h"
|
||||||
#include "dialogs/filesel.h"
|
#include "dialogs/filesel.h"
|
||||||
@ -38,6 +38,20 @@
|
|||||||
#include "util/quantize.h"
|
#include "util/quantize.h"
|
||||||
#include "widgets/colview.h"
|
#include "widgets/colview.h"
|
||||||
#include "widgets/paledit.h"
|
#include "widgets/paledit.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// palette_editor
|
||||||
|
|
||||||
|
class PaletteEditorCommand : public Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PaletteEditorCommand();
|
||||||
|
Command* clone() { return new PaletteEditorCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
#define get_sprite(wgt) (*(const SpriteReader*)(jwidget_get_window(wgt))->user_data[0])
|
#define get_sprite(wgt) (*(const SpriteReader*)(jwidget_get_window(wgt))->user_data[0])
|
||||||
|
|
||||||
@ -65,7 +79,14 @@ static bool palette_editor_change_hook(JWidget widget, void *data);
|
|||||||
|
|
||||||
static void set_new_palette(Palette *palette);
|
static void set_new_palette(Palette *palette);
|
||||||
|
|
||||||
static void cmd_palette_editor_execute(const char *argument)
|
PaletteEditorCommand::PaletteEditorCommand()
|
||||||
|
: Command("palette_editor",
|
||||||
|
"PaletteEditor",
|
||||||
|
CmdRecordableFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void PaletteEditorCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
JWidget colorviewer_box, palette_editor_view;
|
JWidget colorviewer_box, palette_editor_view;
|
||||||
JWidget slider_columns, button_ok;
|
JWidget slider_columns, button_ok;
|
||||||
@ -75,7 +96,7 @@ static void cmd_palette_editor_execute(const char *argument)
|
|||||||
JWidget button_ramp, button_quantize;
|
JWidget button_ramp, button_quantize;
|
||||||
int frame, columns;
|
int frame, columns;
|
||||||
Palette *palette = NULL;
|
Palette *palette = NULL;
|
||||||
const CurrentSpriteReader sprite;
|
const CurrentSpriteReader sprite(context);
|
||||||
int imgtype = sprite ? sprite->imgtype: IMAGE_INDEXED;
|
int imgtype = sprite ? sprite->imgtype: IMAGE_INDEXED;
|
||||||
int frame_bak = sprite ? sprite->frame : 0;
|
int frame_bak = sprite ? sprite->frame : 0;
|
||||||
bool all_frames_same_palette = TRUE;
|
bool all_frames_same_palette = TRUE;
|
||||||
@ -532,9 +553,10 @@ static void set_new_palette(Palette *palette)
|
|||||||
jmanager_refresh_screen();
|
jmanager_refresh_screen();
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_palette_editor = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_PALETTE_EDITOR,
|
// CommandFactory
|
||||||
NULL,
|
|
||||||
NULL,
|
Command* CommandFactory::create_palette_editor_command()
|
||||||
cmd_palette_editor_execute,
|
{
|
||||||
};
|
return new PaletteEditorCommand;
|
||||||
|
}
|
||||||
|
@ -18,22 +18,44 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "raster/sprite.h"
|
#include "raster/sprite.h"
|
||||||
#include "raster/undo.h"
|
#include "raster/undo.h"
|
||||||
#include "util/clipboard.h"
|
#include "util/clipboard.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
|
||||||
static bool cmd_paste_enabled(const char *argument)
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// paste
|
||||||
|
|
||||||
|
class PasteCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
PasteCommand();
|
||||||
|
Command* clone() { return new PasteCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
PasteCommand::PasteCommand()
|
||||||
|
: Command("paste",
|
||||||
|
"Paste",
|
||||||
|
CmdUIOnlyFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PasteCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return
|
return
|
||||||
sprite != NULL &&
|
sprite != NULL &&
|
||||||
clipboard::can_paste();
|
clipboard::can_paste();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_paste_execute(const char *argument)
|
void PasteCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
CurrentSpriteWriter sprite;
|
CurrentSpriteWriter sprite(context);
|
||||||
|
|
||||||
if (undo_is_enabled(sprite->undo))
|
if (undo_is_enabled(sprite->undo))
|
||||||
undo_set_label(sprite->undo, "Paste");
|
undo_set_label(sprite->undo, "Paste");
|
||||||
@ -41,9 +63,10 @@ static void cmd_paste_execute(const char *argument)
|
|||||||
clipboard::paste(sprite);
|
clipboard::paste(sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_paste = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_PASTE,
|
// CommandFactory
|
||||||
cmd_paste_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_paste_command()
|
||||||
cmd_paste_execute,
|
{
|
||||||
};
|
return new PasteCommand;
|
||||||
|
}
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include "jinete/jinete.h"
|
#include "jinete/jinete.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "modules/editors.h"
|
#include "modules/editors.h"
|
||||||
#include "modules/gui.h"
|
#include "modules/gui.h"
|
||||||
#include "modules/palettes.h"
|
#include "modules/palettes.h"
|
||||||
@ -30,6 +30,21 @@
|
|||||||
#include "raster/palette.h"
|
#include "raster/palette.h"
|
||||||
#include "raster/sprite.h"
|
#include "raster/sprite.h"
|
||||||
#include "widgets/editor.h"
|
#include "widgets/editor.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// play_animation
|
||||||
|
|
||||||
|
class PlayAnimationCommand : public Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PlayAnimationCommand();
|
||||||
|
Command* clone() { return new PlayAnimationCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
static int speed_timer;
|
static int speed_timer;
|
||||||
|
|
||||||
@ -40,16 +55,23 @@ static void speed_timer_callback()
|
|||||||
|
|
||||||
END_OF_STATIC_FUNCTION(speed_timer_callback);
|
END_OF_STATIC_FUNCTION(speed_timer_callback);
|
||||||
|
|
||||||
static bool cmd_play_animation_enabled(const char *argument)
|
PlayAnimationCommand::PlayAnimationCommand()
|
||||||
|
: Command("play_animation",
|
||||||
|
"Play Animation",
|
||||||
|
CmdUIOnlyFlag)
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
}
|
||||||
|
|
||||||
|
bool PlayAnimationCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return
|
return
|
||||||
sprite != NULL;
|
sprite != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_play_animation_execute(const char *argument)
|
void PlayAnimationCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
CurrentSpriteWriter sprite;
|
CurrentSpriteWriter sprite(context);
|
||||||
int old_frame, msecs;
|
int old_frame, msecs;
|
||||||
bool done = FALSE;
|
bool done = FALSE;
|
||||||
bool onionskin = get_onionskin();
|
bool onionskin = get_onionskin();
|
||||||
@ -129,9 +151,10 @@ static void cmd_play_animation_execute(const char *argument)
|
|||||||
jmouse_show();
|
jmouse_show();
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_play_animation = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_PLAY_ANIMATION,
|
// CommandFactory
|
||||||
cmd_play_animation_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_play_animation_command()
|
||||||
cmd_play_animation_execute,
|
{
|
||||||
};
|
return new PlayAnimationCommand;
|
||||||
|
}
|
||||||
|
@ -18,20 +18,4 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "jinete/jinete.h"
|
// TODO remove me
|
||||||
|
|
||||||
#include "commands/commands.h"
|
|
||||||
#include "core/app.h"
|
|
||||||
#include "raster/sprite.h"
|
|
||||||
|
|
||||||
/* static void cmd_play_flic_execute(const char *argument) */
|
|
||||||
/* { */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* Command cmd_play_flic = { */
|
|
||||||
/* CMD_PLAY_FLIC, */
|
|
||||||
/* cmd_play_flic_enabled, */
|
|
||||||
/* NULL, */
|
|
||||||
/* cmd_play_flic_execute, */
|
|
||||||
/* NULL */
|
|
||||||
/* }; */
|
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include "jinete/jinete.h"
|
#include "jinete/jinete.h"
|
||||||
|
|
||||||
|
#include "commands/command.h"
|
||||||
#include "commands/commands.h"
|
#include "commands/commands.h"
|
||||||
#include "core/app.h"
|
#include "core/app.h"
|
||||||
#include "modules/editors.h"
|
#include "modules/editors.h"
|
||||||
@ -34,50 +35,45 @@
|
|||||||
#include "util/render.h"
|
#include "util/render.h"
|
||||||
#include "widgets/editor.h"
|
#include "widgets/editor.h"
|
||||||
#include "widgets/statebar.h"
|
#include "widgets/statebar.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
|
||||||
#define PREVIEW_TILED 1
|
#define PREVIEW_TILED 1
|
||||||
#define PREVIEW_FIT_ON_SCREEN 2
|
#define PREVIEW_FIT_ON_SCREEN 2
|
||||||
|
|
||||||
static void preview_sprite(int flags);
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// base class
|
||||||
|
|
||||||
static bool cmd_preview_enabled(const char *argument)
|
class PreviewCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
PreviewCommand(const char* short_name, const char* friendly_name);
|
||||||
|
Command* clone() { return new PreviewCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
|
||||||
|
void preview_sprite(Context* context, int flags);
|
||||||
|
};
|
||||||
|
|
||||||
|
PreviewCommand::PreviewCommand(const char* short_name, const char* friendly_name)
|
||||||
|
: Command(short_name,
|
||||||
|
friendly_name,
|
||||||
|
CmdUIOnlyFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PreviewCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return
|
return
|
||||||
sprite != NULL;
|
sprite != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ======================== */
|
|
||||||
/* preview_fit_to_screen */
|
|
||||||
/* ======================== */
|
|
||||||
|
|
||||||
static void cmd_preview_fit_to_screen_execute(const char *argument)
|
|
||||||
{
|
|
||||||
preview_sprite(PREVIEW_FIT_ON_SCREEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ======================== */
|
|
||||||
/* preview_normal */
|
|
||||||
/* ======================== */
|
|
||||||
|
|
||||||
static void cmd_preview_normal_execute(const char *argument)
|
|
||||||
{
|
|
||||||
preview_sprite(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ======================== */
|
|
||||||
/* preview_tiled */
|
|
||||||
/* ======================== */
|
|
||||||
|
|
||||||
static void cmd_preview_tiled_execute(const char *argument)
|
|
||||||
{
|
|
||||||
preview_sprite(PREVIEW_TILED);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows the sprite using the complete screen.
|
* Shows the sprite using the complete screen.
|
||||||
*/
|
*/
|
||||||
static void preview_sprite(int flags)
|
void PreviewCommand::preview_sprite(Context* context, int flags)
|
||||||
{
|
{
|
||||||
JWidget widget = current_editor;
|
JWidget widget = current_editor;
|
||||||
|
|
||||||
@ -253,13 +249,13 @@ static void preview_sprite(int flags)
|
|||||||
jmessage_free(msg);
|
jmessage_free(msg);
|
||||||
|
|
||||||
/* change frame */
|
/* change frame */
|
||||||
if (command &&
|
if (command != NULL &&
|
||||||
(strcmp(command->name, CMD_GOTO_FIRST_FRAME) == 0 ||
|
(strcmp(command->short_name(), CommandId::goto_first_frame) == 0 ||
|
||||||
strcmp(command->name, CMD_GOTO_PREVIOUS_FRAME) == 0 ||
|
strcmp(command->short_name(), CommandId::goto_previous_frame) == 0 ||
|
||||||
strcmp(command->name, CMD_GOTO_NEXT_FRAME) == 0 ||
|
strcmp(command->short_name(), CommandId::goto_next_frame) == 0 ||
|
||||||
strcmp(command->name, CMD_GOTO_LAST_FRAME) == 0)) {
|
strcmp(command->short_name(), CommandId::goto_last_frame) == 0)) {
|
||||||
/* execute the command */
|
/* execute the command */
|
||||||
command_execute(command, NULL);
|
context->execute_command(command);
|
||||||
|
|
||||||
/* redraw */
|
/* redraw */
|
||||||
redraw = TRUE;
|
redraw = TRUE;
|
||||||
@ -273,8 +269,8 @@ static void preview_sprite(int flags)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* play the animation */
|
/* play the animation */
|
||||||
else if (command &&
|
else if (command != NULL &&
|
||||||
strcmp(command->name, CMD_PLAY_ANIMATION) == 0) {
|
strcmp(command->short_name(), CommandId::play_animation) == 0) {
|
||||||
/* TODO */
|
/* TODO */
|
||||||
}
|
}
|
||||||
/* change background color */
|
/* change background color */
|
||||||
@ -312,23 +308,92 @@ static void preview_sprite(int flags)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_preview_fit_to_screen = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_PREVIEW_FIT_TO_SCREEN,
|
// preview_fit_to_screen
|
||||||
cmd_preview_enabled,
|
|
||||||
NULL,
|
class PreviewFitToScreenCommand : public PreviewCommand
|
||||||
cmd_preview_fit_to_screen_execute,
|
{
|
||||||
|
public:
|
||||||
|
PreviewFitToScreenCommand();
|
||||||
|
Command* clone() { return new PreviewFitToScreenCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void execute(Context* context);
|
||||||
};
|
};
|
||||||
|
|
||||||
Command cmd_preview_normal = {
|
PreviewFitToScreenCommand::PreviewFitToScreenCommand()
|
||||||
CMD_PREVIEW_NORMAL,
|
: PreviewCommand("preview_fit_to_screen",
|
||||||
cmd_preview_enabled,
|
"Preview Fit to Screen")
|
||||||
NULL,
|
{
|
||||||
cmd_preview_normal_execute,
|
}
|
||||||
|
|
||||||
|
void PreviewFitToScreenCommand::execute(Context* context)
|
||||||
|
{
|
||||||
|
preview_sprite(context, PREVIEW_FIT_ON_SCREEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// preview_normal
|
||||||
|
|
||||||
|
class PreviewNormalCommand : public PreviewCommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PreviewNormalCommand();
|
||||||
|
Command* clone() { return new PreviewNormalCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void execute(Context* context);
|
||||||
};
|
};
|
||||||
|
|
||||||
Command cmd_preview_tiled = {
|
PreviewNormalCommand::PreviewNormalCommand()
|
||||||
CMD_PREVIEW_TILED,
|
: PreviewCommand("preview_normal",
|
||||||
cmd_preview_enabled,
|
"Preview Normal")
|
||||||
NULL,
|
{
|
||||||
cmd_preview_tiled_execute,
|
}
|
||||||
|
|
||||||
|
void PreviewNormalCommand::execute(Context* context)
|
||||||
|
{
|
||||||
|
preview_sprite(context, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// preview_tiled
|
||||||
|
|
||||||
|
class PreviewTiledCommand : public PreviewCommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PreviewTiledCommand();
|
||||||
|
Command* clone() { return new PreviewTiledCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void execute(Context* context);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
PreviewTiledCommand::PreviewTiledCommand()
|
||||||
|
: PreviewCommand("preview_tiled",
|
||||||
|
"Preview Tiled")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreviewTiledCommand::execute(Context* context)
|
||||||
|
{
|
||||||
|
preview_sprite(context, PREVIEW_TILED);
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// CommandFactory
|
||||||
|
|
||||||
|
Command* CommandFactory::create_preview_fit_to_screen_command()
|
||||||
|
{
|
||||||
|
return new PreviewFitToScreenCommand;
|
||||||
|
}
|
||||||
|
|
||||||
|
Command* CommandFactory::create_preview_normal_command()
|
||||||
|
{
|
||||||
|
return new PreviewNormalCommand;
|
||||||
|
}
|
||||||
|
|
||||||
|
Command* CommandFactory::create_preview_tiled_command()
|
||||||
|
{
|
||||||
|
return new PreviewTiledCommand;
|
||||||
|
}
|
||||||
|
@ -23,15 +23,36 @@
|
|||||||
#include "jinete/jbase.h"
|
#include "jinete/jbase.h"
|
||||||
#include "jinete/jalert.h"
|
#include "jinete/jalert.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "util/recscr.h"
|
#include "util/recscr.h"
|
||||||
|
|
||||||
static bool cmd_record_screen_checked(const char *argument)
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// record_screen
|
||||||
|
|
||||||
|
class RecordScreenCommand : public Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RecordScreenCommand();
|
||||||
|
Command* clone() { return new RecordScreenCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool checked(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
RecordScreenCommand::RecordScreenCommand()
|
||||||
|
: Command("record_screen",
|
||||||
|
"Record Screen",
|
||||||
|
CmdUIOnlyFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RecordScreenCommand::checked(Context* context)
|
||||||
{
|
{
|
||||||
return is_rec_screen();
|
return is_rec_screen();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_record_screen_execute(const char *argument)
|
void RecordScreenCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
if (is_rec_screen())
|
if (is_rec_screen())
|
||||||
rec_screen_off();
|
rec_screen_off();
|
||||||
@ -46,9 +67,10 @@ static void cmd_record_screen_execute(const char *argument)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_record_screen = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_RECORD_SCREEN,
|
// CommandFactory
|
||||||
NULL,
|
|
||||||
cmd_record_screen_checked,
|
Command* CommandFactory::create_record_screen_command()
|
||||||
cmd_record_screen_execute,
|
{
|
||||||
};
|
return new RecordScreenCommand;
|
||||||
|
}
|
||||||
|
@ -18,24 +18,43 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "core/app.h"
|
#include "core/app.h"
|
||||||
#include "modules/gui.h"
|
#include "modules/gui.h"
|
||||||
#include "raster/sprite.h"
|
#include "raster/sprite.h"
|
||||||
#include "raster/undo.h"
|
#include "raster/undo.h"
|
||||||
#include "widgets/statebar.h"
|
#include "widgets/statebar.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
|
||||||
static bool cmd_redo_enabled(const char *argument)
|
class RedoCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
RedoCommand();
|
||||||
|
Command* clone() { return new RedoCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
RedoCommand::RedoCommand()
|
||||||
|
: Command("redo",
|
||||||
|
"Redo",
|
||||||
|
CmdUIOnlyFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RedoCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return
|
return
|
||||||
sprite != NULL &&
|
sprite != NULL &&
|
||||||
undo_can_redo(sprite->undo);
|
undo_can_redo(sprite->undo);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_redo_execute(const char *argument)
|
void RedoCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
CurrentSpriteWriter sprite;
|
CurrentSpriteWriter sprite(context);
|
||||||
|
|
||||||
statusbar_show_tip(app_get_statusbar(), 1000,
|
statusbar_show_tip(app_get_statusbar(), 1000,
|
||||||
_("Redid %s"),
|
_("Redid %s"),
|
||||||
@ -46,9 +65,10 @@ static void cmd_redo_execute(const char *argument)
|
|||||||
update_screen_for_sprite(sprite);
|
update_screen_for_sprite(sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_redo = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_REDO,
|
// CommandFactory
|
||||||
cmd_redo_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_redo_command()
|
||||||
cmd_redo_execute,
|
{
|
||||||
};
|
return new RedoCommand;
|
||||||
|
}
|
||||||
|
@ -27,18 +27,39 @@
|
|||||||
|
|
||||||
#include "jinete/jsystem.h"
|
#include "jinete/jsystem.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "core/app.h"
|
#include "core/app.h"
|
||||||
#include "widgets/statebar.h"
|
#include "widgets/statebar.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
|
||||||
static void cmd_refresh_execute(const char *argument)
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// refresh
|
||||||
|
|
||||||
|
class RefreshCommand : public Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RefreshCommand();
|
||||||
|
Command* clone() { return new RefreshCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
RefreshCommand::RefreshCommand()
|
||||||
|
: Command("refresh",
|
||||||
|
"Refresh",
|
||||||
|
CmdUIOnlyFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void RefreshCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
jmouse_hide();
|
jmouse_hide();
|
||||||
clear_to_color(screen, makecol(0, 0, 0));
|
clear_to_color(screen, makecol(0, 0, 0));
|
||||||
jmouse_show();
|
jmouse_show();
|
||||||
|
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
const CurrentSpriteReader sprite(context);
|
||||||
app_refresh_screen(sprite);
|
app_refresh_screen(sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,9 +78,10 @@ static void cmd_refresh_execute(const char *argument)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_refresh = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_REFRESH,
|
// CommandFactory
|
||||||
NULL,
|
|
||||||
NULL,
|
Command* CommandFactory::create_refresh_command()
|
||||||
cmd_refresh_execute,
|
{
|
||||||
};
|
return new RefreshCommand;
|
||||||
|
}
|
||||||
|
@ -18,16 +18,38 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "modules/gui.h"
|
#include "modules/gui.h"
|
||||||
#include "raster/cel.h"
|
#include "raster/cel.h"
|
||||||
#include "raster/layer.h"
|
#include "raster/layer.h"
|
||||||
#include "raster/sprite.h"
|
#include "raster/sprite.h"
|
||||||
#include "undoable.h"
|
#include "undoable.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
|
||||||
static bool cmd_remove_cel_enabled(const char *argument)
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// remove_cel
|
||||||
|
|
||||||
|
class RemoveCelCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
RemoveCelCommand();
|
||||||
|
Command* clone() { return new RemoveCelCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
RemoveCelCommand::RemoveCelCommand()
|
||||||
|
: Command("remove_cel",
|
||||||
|
"Remove Cel",
|
||||||
|
CmdRecordableFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RemoveCelCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return
|
return
|
||||||
sprite != NULL &&
|
sprite != NULL &&
|
||||||
sprite->layer != NULL &&
|
sprite->layer != NULL &&
|
||||||
@ -37,9 +59,9 @@ static bool cmd_remove_cel_enabled(const char *argument)
|
|||||||
layer_get_cel(sprite->layer, sprite->frame);
|
layer_get_cel(sprite->layer, sprite->frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_remove_cel_execute(const char *argument)
|
void RemoveCelCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
CurrentSpriteWriter sprite;
|
CurrentSpriteWriter sprite(context);
|
||||||
Cel* cel = layer_get_cel(sprite->layer, sprite->frame);
|
Cel* cel = layer_get_cel(sprite->layer, sprite->frame);
|
||||||
{
|
{
|
||||||
Undoable undoable(sprite, "Remove Cel");
|
Undoable undoable(sprite, "Remove Cel");
|
||||||
@ -49,9 +71,10 @@ static void cmd_remove_cel_execute(const char *argument)
|
|||||||
update_screen_for_sprite(sprite);
|
update_screen_for_sprite(sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_remove_cel = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_REMOVE_CEL,
|
// CommandFactory
|
||||||
cmd_remove_cel_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_remove_cel_command()
|
||||||
cmd_remove_cel_execute,
|
{
|
||||||
};
|
return new RemoveCelCommand;
|
||||||
|
}
|
||||||
|
@ -20,22 +20,44 @@
|
|||||||
|
|
||||||
#include "jinete/jinete.h"
|
#include "jinete/jinete.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "modules/gui.h"
|
#include "modules/gui.h"
|
||||||
#include "raster/sprite.h"
|
#include "raster/sprite.h"
|
||||||
#include "undoable.h"
|
#include "undoable.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
|
||||||
static bool cmd_remove_frame_enabled(const char *argument)
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// remove_frame
|
||||||
|
|
||||||
|
class RemoveFrameCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
RemoveFrameCommand();
|
||||||
|
Command* clone() { return new RemoveFrameCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
RemoveFrameCommand::RemoveFrameCommand()
|
||||||
|
: Command("remove_frame",
|
||||||
|
"Remove Frame",
|
||||||
|
CmdRecordableFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RemoveFrameCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return
|
return
|
||||||
sprite != NULL &&
|
sprite != NULL &&
|
||||||
sprite->frames > 1;
|
sprite->frames > 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_remove_frame_execute(const char *argument)
|
void RemoveFrameCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
CurrentSpriteWriter sprite;
|
CurrentSpriteWriter sprite(context);
|
||||||
{
|
{
|
||||||
Undoable undoable(sprite, "Remove Frame");
|
Undoable undoable(sprite, "Remove Frame");
|
||||||
undoable.remove_frame(sprite->frame);
|
undoable.remove_frame(sprite->frame);
|
||||||
@ -44,9 +66,10 @@ static void cmd_remove_frame_execute(const char *argument)
|
|||||||
update_screen_for_sprite(sprite);
|
update_screen_for_sprite(sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_remove_frame = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_REMOVE_FRAME,
|
// CommandFactory
|
||||||
cmd_remove_frame_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_remove_frame_command()
|
||||||
cmd_remove_frame_execute,
|
{
|
||||||
};
|
return new RemoveFrameCommand;
|
||||||
|
}
|
||||||
|
@ -18,23 +18,45 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "modules/gui.h"
|
#include "modules/gui.h"
|
||||||
#include "raster/sprite.h"
|
#include "raster/sprite.h"
|
||||||
#include "raster/undo.h"
|
#include "raster/undo.h"
|
||||||
#include "undoable.h"
|
#include "undoable.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
|
||||||
static bool cmd_remove_layer_enabled(const char *argument)
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// remove_layer
|
||||||
|
|
||||||
|
class RemoveLayerCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
RemoveLayerCommand();
|
||||||
|
Command* clone() { return new RemoveLayerCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
RemoveLayerCommand::RemoveLayerCommand()
|
||||||
|
: Command("remove_layer",
|
||||||
|
"Remove Layer",
|
||||||
|
CmdRecordableFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RemoveLayerCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return
|
return
|
||||||
sprite != NULL &&
|
sprite != NULL &&
|
||||||
sprite->layer != NULL;
|
sprite->layer != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_remove_layer_execute(const char *argument)
|
void RemoveLayerCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
CurrentSpriteWriter sprite;
|
CurrentSpriteWriter sprite(context);
|
||||||
{
|
{
|
||||||
Undoable undoable(sprite, "Remove Layer");
|
Undoable undoable(sprite, "Remove Layer");
|
||||||
undoable.remove_layer(sprite->layer);
|
undoable.remove_layer(sprite->layer);
|
||||||
@ -43,9 +65,10 @@ static void cmd_remove_layer_execute(const char *argument)
|
|||||||
update_screen_for_sprite(sprite);
|
update_screen_for_sprite(sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_remove_layer = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_REMOVE_LAYER,
|
// CommandFactory
|
||||||
cmd_remove_layer_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_remove_layer_command()
|
||||||
cmd_remove_layer_execute,
|
{
|
||||||
};
|
return new RemoveLayerCommand;
|
||||||
|
}
|
||||||
|
@ -18,23 +18,45 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "modules/gui.h"
|
#include "modules/gui.h"
|
||||||
#include "raster/mask.h"
|
#include "raster/mask.h"
|
||||||
#include "raster/sprite.h"
|
#include "raster/sprite.h"
|
||||||
#include "raster/undo.h"
|
#include "raster/undo.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
|
||||||
static bool cmd_reselect_mask_enabled(const char *argument)
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// reselect_mask
|
||||||
|
|
||||||
|
class ReselectMaskCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
ReselectMaskCommand();
|
||||||
|
Command* clone() { return new ReselectMaskCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
ReselectMaskCommand::ReselectMaskCommand()
|
||||||
|
: Command("reselect_mask",
|
||||||
|
"Reselect Mask",
|
||||||
|
CmdRecordableFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ReselectMaskCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return
|
return
|
||||||
sprite != NULL &&
|
sprite != NULL &&
|
||||||
sprite_request_mask(sprite, "*deselected*") != NULL;
|
sprite_request_mask(sprite, "*deselected*") != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_reselect_mask_execute(const char *argument)
|
void ReselectMaskCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
CurrentSpriteWriter sprite;
|
CurrentSpriteWriter sprite(context);
|
||||||
Mask *mask;
|
Mask *mask;
|
||||||
|
|
||||||
/* request *deselected* mask */
|
/* request *deselected* mask */
|
||||||
@ -57,9 +79,10 @@ static void cmd_reselect_mask_execute(const char *argument)
|
|||||||
update_screen_for_sprite(sprite);
|
update_screen_for_sprite(sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_reselect_mask = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_RESELECT_MASK,
|
// CommandFactory
|
||||||
cmd_reselect_mask_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_reselect_mask_command()
|
||||||
cmd_reselect_mask_execute,
|
{
|
||||||
};
|
return new ReselectMaskCommand;
|
||||||
|
}
|
||||||
|
@ -22,7 +22,8 @@
|
|||||||
|
|
||||||
#include "jinete/jinete.h"
|
#include "jinete/jinete.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
|
#include "commands/params.h"
|
||||||
#include "core/app.h"
|
#include "core/app.h"
|
||||||
#include "core/job.h"
|
#include "core/job.h"
|
||||||
#include "modules/gui.h"
|
#include "modules/gui.h"
|
||||||
@ -33,6 +34,24 @@
|
|||||||
#include "raster/stock.h"
|
#include "raster/stock.h"
|
||||||
#include "undoable.h"
|
#include "undoable.h"
|
||||||
#include "widgets/colbar.h"
|
#include "widgets/colbar.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// rotate_canvas
|
||||||
|
|
||||||
|
class RotateCanvasCommand : public Command
|
||||||
|
{
|
||||||
|
int m_angle;
|
||||||
|
|
||||||
|
public:
|
||||||
|
RotateCanvasCommand();
|
||||||
|
Command* clone() { return new RotateCanvasCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void load_params(Params* params);
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
class RotateCanvasJob : public Job
|
class RotateCanvasJob : public Job
|
||||||
{
|
{
|
||||||
@ -149,29 +168,42 @@ protected:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool cmd_rotate_canvas_enabled(const char *argument)
|
RotateCanvasCommand::RotateCanvasCommand()
|
||||||
|
: Command("rotate_canvas",
|
||||||
|
"Rotate Canvas",
|
||||||
|
CmdRecordableFlag)
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
m_angle = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RotateCanvasCommand::load_params(Params* params)
|
||||||
|
{
|
||||||
|
if (params->has_param("angle")) {
|
||||||
|
m_angle = ustrtol(params->get("angle").c_str(), NULL, 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RotateCanvasCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return sprite != NULL;
|
return sprite != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_rotate_canvas_execute(const char *argument)
|
void RotateCanvasCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
int angle = ustrtol(argument, NULL, 10);
|
CurrentSpriteReader sprite(context);
|
||||||
CurrentSpriteReader sprite;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
RotateCanvasJob job(sprite, angle);
|
RotateCanvasJob job(sprite, m_angle);
|
||||||
job.do_job();
|
job.do_job();
|
||||||
}
|
}
|
||||||
|
|
||||||
sprite_generate_mask_boundaries(sprite);
|
sprite_generate_mask_boundaries(sprite);
|
||||||
update_screen_for_sprite(sprite);
|
update_screen_for_sprite(sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_rotate_canvas = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_ROTATE_CANVAS,
|
// CommandFactory
|
||||||
cmd_rotate_canvas_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_rotate_canvas_command()
|
||||||
cmd_rotate_canvas_execute,
|
{
|
||||||
};
|
return new RotateCanvasCommand;
|
||||||
|
}
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include "jinete/jinete.h"
|
#include "jinete/jinete.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "core/app.h"
|
#include "core/app.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "dialogs/filesel.h"
|
#include "dialogs/filesel.h"
|
||||||
@ -31,6 +31,7 @@
|
|||||||
#include "modules/recent.h"
|
#include "modules/recent.h"
|
||||||
#include "raster/sprite.h"
|
#include "raster/sprite.h"
|
||||||
#include "widgets/statebar.h"
|
#include "widgets/statebar.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
|
||||||
typedef struct SaveFileData
|
typedef struct SaveFileData
|
||||||
{
|
{
|
||||||
@ -186,19 +187,37 @@ static void save_as_dialog(Sprite* sprite, const char* dlg_title, bool mark_as_s
|
|||||||
save_sprite_in_background(sprite, mark_as_saved);
|
save_sprite_in_background(sprite, mark_as_saved);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************
|
//////////////////////////////////////////////////////////////////////
|
||||||
Save File
|
// save_file
|
||||||
*********************************************************************/
|
|
||||||
|
class SaveFileCommand : public Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SaveFileCommand();
|
||||||
|
Command* clone() { return new SaveFileCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
SaveFileCommand::SaveFileCommand()
|
||||||
|
: Command("save_file",
|
||||||
|
"Save File",
|
||||||
|
CmdRecordableFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if there is a current sprite to save.
|
* Returns true if there is a current sprite to save.
|
||||||
*
|
*
|
||||||
* [main thread]
|
* [main thread]
|
||||||
*/
|
*/
|
||||||
static bool cmd_save_file_enabled(const char *argument)
|
bool SaveFileCommand::enabled(Context* context)
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
const CurrentSpriteReader sprite(context);
|
||||||
return sprite.is_valid();
|
return
|
||||||
|
sprite != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -206,9 +225,9 @@ static bool cmd_save_file_enabled(const char *argument)
|
|||||||
*
|
*
|
||||||
* [main thread]
|
* [main thread]
|
||||||
*/
|
*/
|
||||||
static void cmd_save_file_execute(const char *argument)
|
void SaveFileCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
CurrentSpriteWriter sprite;
|
CurrentSpriteWriter sprite(context);
|
||||||
|
|
||||||
/* if the sprite is associated to a file in the file-system, we can
|
/* if the sprite is associated to a file in the file-system, we can
|
||||||
save it directly without user interaction */
|
save it directly without user interaction */
|
||||||
@ -223,37 +242,71 @@ static void cmd_save_file_execute(const char *argument)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************
|
//////////////////////////////////////////////////////////////////////
|
||||||
Save File As
|
// save_file_as
|
||||||
*********************************************************************/
|
|
||||||
|
|
||||||
static bool cmd_save_file_as_enabled(const char *argument)
|
class SaveFileAsCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
SaveFileAsCommand();
|
||||||
|
Command* clone() { return new SaveFileAsCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
SaveFileAsCommand::SaveFileAsCommand()
|
||||||
|
: Command("save_file_as",
|
||||||
|
"Save File As",
|
||||||
|
CmdRecordableFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SaveFileAsCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return
|
return
|
||||||
sprite != NULL;
|
sprite != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_save_file_as_execute(const char *argument)
|
void SaveFileAsCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
CurrentSpriteWriter sprite;
|
CurrentSpriteWriter sprite(context);
|
||||||
save_as_dialog(sprite, _("Save Sprite As"), true);
|
save_as_dialog(sprite, _("Save Sprite As"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************
|
//////////////////////////////////////////////////////////////////////
|
||||||
Save File Copy As
|
// save_file_copy_as
|
||||||
*********************************************************************/
|
|
||||||
|
|
||||||
static bool cmd_save_file_copy_as_enabled(const char *argument)
|
class SaveFileCopyAsCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
SaveFileCopyAsCommand();
|
||||||
|
Command* clone() { return new SaveFileCopyAsCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
SaveFileCopyAsCommand::SaveFileCopyAsCommand()
|
||||||
|
: Command("save_file_copy_as",
|
||||||
|
"Save File Copy As",
|
||||||
|
CmdRecordableFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SaveFileCopyAsCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return
|
return
|
||||||
sprite != NULL;
|
sprite != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_save_file_copy_as_execute(const char *argument)
|
void SaveFileCopyAsCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
CurrentSpriteWriter sprite;
|
CurrentSpriteWriter sprite(context);
|
||||||
jstring old_filename = sprite->filename;
|
jstring old_filename = sprite->filename;
|
||||||
|
|
||||||
// show "Save As" dialog
|
// show "Save As" dialog
|
||||||
@ -264,32 +317,20 @@ static void cmd_save_file_copy_as_execute(const char *argument)
|
|||||||
app_realloc_sprite_list();
|
app_realloc_sprite_list();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
//////////////////////////////////////////////////////////////////////
|
||||||
* Command to save the current sprite in its associated file.
|
// CommandFactory
|
||||||
*/
|
|
||||||
Command cmd_save_file = {
|
|
||||||
CMD_SAVE_FILE,
|
|
||||||
cmd_save_file_enabled,
|
|
||||||
NULL,
|
|
||||||
cmd_save_file_execute,
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
Command* CommandFactory::create_save_file_command()
|
||||||
* Command to save the current sprite in another file.
|
{
|
||||||
*/
|
return new SaveFileCommand;
|
||||||
Command cmd_save_file_as = {
|
}
|
||||||
CMD_SAVE_FILE_AS,
|
|
||||||
cmd_save_file_as_enabled,
|
|
||||||
NULL,
|
|
||||||
cmd_save_file_as_execute,
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
Command* CommandFactory::create_save_file_as_command()
|
||||||
* Command to save a copy of the current sprite in another file.
|
{
|
||||||
*/
|
return new SaveFileAsCommand;
|
||||||
Command cmd_save_file_copy_as = {
|
}
|
||||||
CMD_SAVE_FILE_COPY_AS,
|
|
||||||
cmd_save_file_copy_as_enabled,
|
Command* CommandFactory::create_save_file_copy_as_command()
|
||||||
NULL,
|
{
|
||||||
cmd_save_file_copy_as_execute,
|
return new SaveFileCopyAsCommand;
|
||||||
};
|
}
|
||||||
|
@ -22,15 +22,37 @@
|
|||||||
|
|
||||||
#include "jinete/jalert.h"
|
#include "jinete/jalert.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "dialogs/filesel.h"
|
#include "dialogs/filesel.h"
|
||||||
#include "raster/mask.h"
|
#include "raster/mask.h"
|
||||||
#include "raster/sprite.h"
|
#include "raster/sprite.h"
|
||||||
#include "util/msk_file.h"
|
#include "util/msk_file.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
|
||||||
static bool cmd_save_mask_enabled(const char *argument)
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// save_mask
|
||||||
|
|
||||||
|
class SaveMaskCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
SaveMaskCommand();
|
||||||
|
Command* clone() { return new SaveMaskCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
SaveMaskCommand::SaveMaskCommand()
|
||||||
|
: Command("save_mask",
|
||||||
|
"Save Mask",
|
||||||
|
CmdUIOnlyFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SaveMaskCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
if (!sprite)
|
if (!sprite)
|
||||||
return false;
|
return false;
|
||||||
else
|
else
|
||||||
@ -38,9 +60,9 @@ static bool cmd_save_mask_enabled(const char *argument)
|
|||||||
sprite->mask->bitmap) ? true: false;
|
sprite->mask->bitmap) ? true: false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_save_mask_execute(const char *argument)
|
void SaveMaskCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
const CurrentSpriteReader sprite(context);
|
||||||
jstring filename = "default.msk";
|
jstring filename = "default.msk";
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -76,9 +98,10 @@ static void cmd_save_mask_execute(const char *argument)
|
|||||||
filename.c_str(), _("&Close"));
|
filename.c_str(), _("&Close"));
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_save_mask = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_SAVE_MASK,
|
// CommandFactory
|
||||||
cmd_save_mask_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_save_mask_command()
|
||||||
cmd_save_mask_execute,
|
{
|
||||||
};
|
return new SaveMaskCommand;
|
||||||
|
}
|
||||||
|
@ -22,13 +22,33 @@
|
|||||||
|
|
||||||
#include "jinete/jsystem.h"
|
#include "jinete/jsystem.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
#include "file/file.h"
|
#include "file/file.h"
|
||||||
#include "raster/raster.h"
|
#include "raster/raster.h"
|
||||||
#include "util/misc.h"
|
#include "util/misc.h"
|
||||||
|
|
||||||
static void cmd_screen_shot_execute(const char *argument)
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// screen_shot
|
||||||
|
|
||||||
|
class ScreenShotCommand : public Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ScreenShotCommand();
|
||||||
|
Command* clone() { return new ScreenShotCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
ScreenShotCommand::ScreenShotCommand()
|
||||||
|
: Command("screen_shot",
|
||||||
|
"Screen Shot",
|
||||||
|
CmdUIOnlyFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScreenShotCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
int c, old_flag;
|
int c, old_flag;
|
||||||
char buf[512];
|
char buf[512];
|
||||||
@ -110,9 +130,10 @@ static void cmd_screen_shot_execute(const char *argument)
|
|||||||
freeze_mouse_flag = old_flag;
|
freeze_mouse_flag = old_flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_screen_shot = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_SCREEN_SHOT,
|
// CommandFactory
|
||||||
NULL,
|
|
||||||
NULL,
|
Command* CommandFactory::create_screen_shot_command()
|
||||||
cmd_screen_shot_execute,
|
{
|
||||||
};
|
return new ScreenShotCommand;
|
||||||
|
}
|
||||||
|
@ -25,30 +25,64 @@
|
|||||||
#include "jinete/jinete.h"
|
#include "jinete/jinete.h"
|
||||||
|
|
||||||
#include "ui_context.h"
|
#include "ui_context.h"
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
|
#include "commands/params.h"
|
||||||
#include "core/app.h"
|
#include "core/app.h"
|
||||||
|
#include "modules/editors.h"
|
||||||
#include "raster/sprite.h"
|
#include "raster/sprite.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
|
||||||
static bool cmd_select_file_enabled(const char *argument)
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// select_file
|
||||||
|
|
||||||
|
class SelectFileCommand : public Command
|
||||||
{
|
{
|
||||||
/* with argument, the argument specified the ID of the GfxObj */
|
gfxobj_id m_sprite_id;
|
||||||
if (ustrlen(argument) > 0) {
|
|
||||||
int sprite_id = ustrtol(argument, NULL, 10);
|
public:
|
||||||
GfxObj *gfxobj = gfxobj_find(sprite_id);
|
SelectFileCommand();
|
||||||
return gfxobj && gfxobj->type == GFXOBJ_SPRITE;
|
Command* clone() { return new SelectFileCommand(*this); }
|
||||||
}
|
|
||||||
/* argument=NULL, means the select "Nothing" option */
|
protected:
|
||||||
else
|
void load_params(Params* params);
|
||||||
return TRUE;
|
bool enabled(Context* context);
|
||||||
|
bool checked(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
SelectFileCommand::SelectFileCommand()
|
||||||
|
: Command("select_file",
|
||||||
|
"Select File",
|
||||||
|
CmdUIOnlyFlag)
|
||||||
|
{
|
||||||
|
m_sprite_id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool cmd_select_file_checked(const char *argument)
|
void SelectFileCommand::load_params(Params* params)
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
if (params->has_param("sprite_id")) {
|
||||||
|
m_sprite_id = ustrtol(params->get("sprite_id").c_str(), NULL, 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ustrlen(argument) > 0) {
|
bool SelectFileCommand::enabled(Context* context)
|
||||||
int sprite_id = ustrtol(argument, NULL, 10);
|
{
|
||||||
GfxObj *gfxobj = gfxobj_find(sprite_id);
|
/* m_sprite_id != 0, the ID specifies a GfxObj */
|
||||||
|
if (m_sprite_id > 0) {
|
||||||
|
GfxObj *gfxobj = gfxobj_find(m_sprite_id);
|
||||||
|
return gfxobj && gfxobj->type == GFXOBJ_SPRITE;
|
||||||
|
}
|
||||||
|
/* m_sprite_id=0, means the select "Nothing" option */
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SelectFileCommand::checked(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
|
|
||||||
|
if (m_sprite_id > 0) {
|
||||||
|
GfxObj *gfxobj = gfxobj_find(m_sprite_id);
|
||||||
return
|
return
|
||||||
gfxobj && gfxobj->type == GFXOBJ_SPRITE &&
|
gfxobj && gfxobj->type == GFXOBJ_SPRITE &&
|
||||||
sprite == (Sprite *)gfxobj;
|
sprite == (Sprite *)gfxobj;
|
||||||
@ -57,25 +91,23 @@ static bool cmd_select_file_checked(const char *argument)
|
|||||||
return sprite == NULL;
|
return sprite == NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_select_file_execute(const char *argument)
|
void SelectFileCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
UIContext* context = UIContext::instance();
|
if (m_sprite_id > 0) {
|
||||||
|
GfxObj* gfxobj = gfxobj_find(m_sprite_id);
|
||||||
if (ustrlen(argument) > 0) {
|
|
||||||
int sprite_id = ustrtol(argument, NULL, 10);
|
|
||||||
GfxObj* gfxobj = gfxobj_find(sprite_id);
|
|
||||||
assert(gfxobj != NULL);
|
assert(gfxobj != NULL);
|
||||||
|
|
||||||
context->show_sprite((Sprite*)gfxobj);
|
set_sprite_in_more_reliable_editor((Sprite*)gfxobj);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
context->show_sprite(NULL);
|
set_sprite_in_more_reliable_editor(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_select_file = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_SELECT_FILE,
|
// CommandFactory
|
||||||
cmd_select_file_enabled,
|
|
||||||
cmd_select_file_checked,
|
Command* CommandFactory::create_select_file_command()
|
||||||
cmd_select_file_execute,
|
{
|
||||||
};
|
return new SelectFileCommand;
|
||||||
|
}
|
||||||
|
@ -18,53 +18,128 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "modules/editors.h"
|
#include "modules/editors.h"
|
||||||
|
|
||||||
static void cmd_close_editor_execute(const char *argument)
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// close_editor
|
||||||
|
|
||||||
|
class CloseEditorCommand : public Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CloseEditorCommand();
|
||||||
|
Command* clone() { return new CloseEditorCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
CloseEditorCommand::CloseEditorCommand()
|
||||||
|
: Command("close_editor",
|
||||||
|
"Close Editor",
|
||||||
|
CmdUIOnlyFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CloseEditorCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
close_editor(current_editor);
|
close_editor(current_editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_make_unique_editor_execute(const char *argument)
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// make_unique_editor
|
||||||
|
|
||||||
|
class MakeUniqueEditorCommand : public Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MakeUniqueEditorCommand();
|
||||||
|
Command* clone() { return new MakeUniqueEditorCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
MakeUniqueEditorCommand::MakeUniqueEditorCommand()
|
||||||
|
: Command("make_unique_editor",
|
||||||
|
"Make Unique Editor",
|
||||||
|
CmdUIOnlyFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void MakeUniqueEditorCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
make_unique_editor(current_editor);
|
make_unique_editor(current_editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_split_editor_horizontally_execute(const char *argument)
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// split_editor_horizontally
|
||||||
|
|
||||||
|
class SplitEditorHorizontallyCommand : public Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SplitEditorHorizontallyCommand();
|
||||||
|
Command* clone() { return new SplitEditorHorizontallyCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
SplitEditorHorizontallyCommand::SplitEditorHorizontallyCommand()
|
||||||
|
: Command("split_editor_horizontally",
|
||||||
|
"Split Editor Horizontally",
|
||||||
|
CmdUIOnlyFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void SplitEditorHorizontallyCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
split_editor(current_editor, JI_HORIZONTAL);
|
split_editor(current_editor, JI_HORIZONTAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_split_editor_vertically_execute(const char *argument)
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// split_editor_vertically
|
||||||
|
|
||||||
|
class SplitEditorVerticallyCommand : public Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SplitEditorVerticallyCommand();
|
||||||
|
Command* clone() { return new SplitEditorVerticallyCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
SplitEditorVerticallyCommand::SplitEditorVerticallyCommand()
|
||||||
|
: Command("split_editor_vertically",
|
||||||
|
"Split Editor Vertically",
|
||||||
|
CmdUIOnlyFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void SplitEditorVerticallyCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
split_editor(current_editor, JI_VERTICAL);
|
split_editor(current_editor, JI_VERTICAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_close_editor = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_CLOSE_EDITOR,
|
// CommandFactory
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
cmd_close_editor_execute,
|
|
||||||
};
|
|
||||||
|
|
||||||
Command cmd_make_unique_editor = {
|
Command* CommandFactory::create_close_editor_command()
|
||||||
CMD_MAKE_UNIQUE_EDITOR,
|
{
|
||||||
NULL,
|
return new CloseEditorCommand;
|
||||||
NULL,
|
}
|
||||||
cmd_make_unique_editor_execute,
|
|
||||||
};
|
|
||||||
|
|
||||||
Command cmd_split_editor_horizontally = {
|
Command* CommandFactory::create_make_unique_editor_command()
|
||||||
CMD_SPLIT_EDITOR_HORIZONTALLY,
|
{
|
||||||
NULL,
|
return new MakeUniqueEditorCommand;
|
||||||
NULL,
|
}
|
||||||
cmd_split_editor_horizontally_execute,
|
|
||||||
};
|
|
||||||
|
|
||||||
Command cmd_split_editor_vertically = {
|
Command* CommandFactory::create_split_editor_horizontally_command()
|
||||||
CMD_SPLIT_EDITOR_VERTICALLY,
|
{
|
||||||
NULL,
|
return new SplitEditorHorizontallyCommand;
|
||||||
NULL,
|
}
|
||||||
cmd_split_editor_vertically_execute,
|
|
||||||
};
|
Command* CommandFactory::create_split_editor_vertically_command()
|
||||||
|
{
|
||||||
|
return new SplitEditorVerticallyCommand;
|
||||||
|
}
|
||||||
|
@ -22,28 +22,50 @@
|
|||||||
|
|
||||||
#include "jinete/jinete.h"
|
#include "jinete/jinete.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
#include "core/color.h"
|
#include "core/color.h"
|
||||||
#include "modules/gui.h"
|
#include "modules/gui.h"
|
||||||
#include "raster/image.h"
|
#include "raster/image.h"
|
||||||
#include "raster/sprite.h"
|
#include "raster/sprite.h"
|
||||||
#include "widgets/colbut.h"
|
#include "widgets/colbut.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
|
||||||
/* TODO remove this */
|
/* TODO remove this */
|
||||||
void dialogs_frame_length(const SpriteReader& sprite, int sprite_frpos);
|
void dialogs_frame_length(const SpriteReader& sprite, int sprite_frpos);
|
||||||
|
|
||||||
static bool cmd_sprite_properties_enabled(const char *argument)
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// sprite_properties
|
||||||
|
|
||||||
|
class SpritePropertiesCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
SpritePropertiesCommand();
|
||||||
|
Command* clone() { return new SpritePropertiesCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
SpritePropertiesCommand::SpritePropertiesCommand()
|
||||||
|
: Command("sprite_properties",
|
||||||
|
"Sprite Properties",
|
||||||
|
CmdUIOnlyFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SpritePropertiesCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return
|
return
|
||||||
sprite != NULL;
|
sprite != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_sprite_properties_execute(const char *argument)
|
void SpritePropertiesCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
JWidget killer, name, type, size, frames, speed, ok;
|
JWidget killer, name, type, size, frames, speed, ok;
|
||||||
const CurrentSpriteReader sprite;
|
const CurrentSpriteReader sprite(context);
|
||||||
jstring imgtype_text;
|
jstring imgtype_text;
|
||||||
char buf[256];
|
char buf[256];
|
||||||
|
|
||||||
@ -111,9 +133,10 @@ static void cmd_sprite_properties_execute(const char *argument)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_sprite_properties = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_SPRITE_PROPERTIES,
|
// CommandFactory
|
||||||
cmd_sprite_properties_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_sprite_properties_command()
|
||||||
cmd_sprite_properties_execute,
|
{
|
||||||
};
|
return new SpritePropertiesCommand;
|
||||||
|
}
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
#include "core/cfg.h"
|
#include "core/cfg.h"
|
||||||
#include "core/job.h"
|
#include "core/job.h"
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "modules/gui.h"
|
#include "modules/gui.h"
|
||||||
#include "modules/palettes.h"
|
#include "modules/palettes.h"
|
||||||
#include "raster/cel.h"
|
#include "raster/cel.h"
|
||||||
@ -33,6 +33,8 @@
|
|||||||
#include "raster/sprite.h"
|
#include "raster/sprite.h"
|
||||||
#include "raster/stock.h"
|
#include "raster/stock.h"
|
||||||
#include "undoable.h"
|
#include "undoable.h"
|
||||||
|
#include "ui_context.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
|
||||||
#define PERC_FORMAT "%.1f%%"
|
#define PERC_FORMAT "%.1f%%"
|
||||||
|
|
||||||
@ -152,17 +154,39 @@ static bool height_px_change_hook(JWidget widget, void *data);
|
|||||||
static bool width_perc_change_hook(JWidget widget, void *data);
|
static bool width_perc_change_hook(JWidget widget, void *data);
|
||||||
static bool height_perc_change_hook(JWidget widget, void *data);
|
static bool height_perc_change_hook(JWidget widget, void *data);
|
||||||
|
|
||||||
static bool cmd_sprite_size_enabled(const char *argument)
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// sprite_size
|
||||||
|
|
||||||
|
class SpriteSizeCommand : public Command
|
||||||
|
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
SpriteSizeCommand();
|
||||||
|
Command* clone() { return new SpriteSizeCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
SpriteSizeCommand::SpriteSizeCommand()
|
||||||
|
: Command("sprite_size",
|
||||||
|
"Sprite Size",
|
||||||
|
CmdRecordableFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SpriteSizeCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return
|
return
|
||||||
sprite != NULL;
|
sprite != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_sprite_size_execute(const char *argument)
|
void SpriteSizeCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
JWidget width_px, height_px, width_perc, height_perc, lock_ratio, method, ok;
|
JWidget width_px, height_px, width_perc, height_perc, lock_ratio, method, ok;
|
||||||
const CurrentSpriteReader sprite;
|
const CurrentSpriteReader sprite(context);
|
||||||
|
|
||||||
// load the window widget
|
// load the window widget
|
||||||
JWidgetPtr window(load_widget("sprsize.jid", "sprite_size"));
|
JWidgetPtr window(load_widget("sprsize.jid", "sprite_size"));
|
||||||
@ -215,7 +239,7 @@ static void cmd_sprite_size_execute(const char *argument)
|
|||||||
|
|
||||||
static bool lock_ratio_change_hook(JWidget widget, void *data)
|
static bool lock_ratio_change_hook(JWidget widget, void *data)
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
const CurrentSpriteReader sprite(UIContext::instance()); // TODO use the context in sprite size command
|
||||||
|
|
||||||
if (widget->selected())
|
if (widget->selected())
|
||||||
width_px_change_hook(widget->find_sibling("width_px"), NULL);
|
width_px_change_hook(widget->find_sibling("width_px"), NULL);
|
||||||
@ -225,7 +249,7 @@ static bool lock_ratio_change_hook(JWidget widget, void *data)
|
|||||||
|
|
||||||
static bool width_px_change_hook(JWidget widget, void *data)
|
static bool width_px_change_hook(JWidget widget, void *data)
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
const CurrentSpriteReader sprite(UIContext::instance()); // TODO use the context in sprite size command
|
||||||
int width = widget->text_int();
|
int width = widget->text_int();
|
||||||
double perc = 100.0 * width / sprite->w;
|
double perc = 100.0 * width / sprite->w;
|
||||||
|
|
||||||
@ -241,7 +265,7 @@ static bool width_px_change_hook(JWidget widget, void *data)
|
|||||||
|
|
||||||
static bool height_px_change_hook(JWidget widget, void *data)
|
static bool height_px_change_hook(JWidget widget, void *data)
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
const CurrentSpriteReader sprite(UIContext::instance()); // TODO use the context in sprite size command
|
||||||
int height = widget->text_int();
|
int height = widget->text_int();
|
||||||
double perc = 100.0 * height / sprite->h;
|
double perc = 100.0 * height / sprite->h;
|
||||||
|
|
||||||
@ -257,7 +281,7 @@ static bool height_px_change_hook(JWidget widget, void *data)
|
|||||||
|
|
||||||
static bool width_perc_change_hook(JWidget widget, void *data)
|
static bool width_perc_change_hook(JWidget widget, void *data)
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
const CurrentSpriteReader sprite(UIContext::instance()); // TODO use the context in sprite size command
|
||||||
double width = widget->text_double();
|
double width = widget->text_double();
|
||||||
|
|
||||||
widget->find_sibling("width_px")->textf("%d", (int)(sprite->w * width / 100));
|
widget->find_sibling("width_px")->textf("%d", (int)(sprite->w * width / 100));
|
||||||
@ -272,7 +296,7 @@ static bool width_perc_change_hook(JWidget widget, void *data)
|
|||||||
|
|
||||||
static bool height_perc_change_hook(JWidget widget, void *data)
|
static bool height_perc_change_hook(JWidget widget, void *data)
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
const CurrentSpriteReader sprite(UIContext::instance()); // TODO use the context in sprite size command
|
||||||
double height = widget->text_double();
|
double height = widget->text_double();
|
||||||
|
|
||||||
widget->find_sibling("height_px")->textf("%d", (int)(sprite->h * height / 100));
|
widget->find_sibling("height_px")->textf("%d", (int)(sprite->h * height / 100));
|
||||||
@ -285,9 +309,10 @@ static bool height_perc_change_hook(JWidget widget, void *data)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_sprite_size = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_SPRITE_SIZE,
|
// CommandFactory
|
||||||
cmd_sprite_size_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_sprite_size_command()
|
||||||
cmd_sprite_size_execute,
|
{
|
||||||
};
|
return new SpriteSizeCommand;
|
||||||
|
}
|
||||||
|
@ -22,11 +22,27 @@
|
|||||||
|
|
||||||
#include "jinete/jbase.h"
|
#include "jinete/jbase.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "core/app.h"
|
#include "core/app.h"
|
||||||
#include "widgets/colbar.h"
|
#include "widgets/colbar.h"
|
||||||
|
|
||||||
static void cmd_switch_colors_execute(const char *argument)
|
class SwitchColorsCommand : public Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SwitchColorsCommand();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
SwitchColorsCommand::SwitchColorsCommand()
|
||||||
|
: Command("switch_colors",
|
||||||
|
"SwitchColors",
|
||||||
|
CmdUIOnlyFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void SwitchColorsCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
JWidget colorbar = app_get_colorbar();
|
JWidget colorbar = app_get_colorbar();
|
||||||
color_t fg = colorbar_get_fg_color(colorbar);
|
color_t fg = colorbar_get_fg_color(colorbar);
|
||||||
@ -36,9 +52,10 @@ static void cmd_switch_colors_execute(const char *argument)
|
|||||||
colorbar_set_bg_color(colorbar, fg);
|
colorbar_set_bg_color(colorbar, fg);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_switch_colors = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_SWITCH_COLORS,
|
// CommandFactory
|
||||||
NULL,
|
|
||||||
NULL,
|
Command* CommandFactory::create_switch_colors_command()
|
||||||
cmd_switch_colors_execute,
|
{
|
||||||
};
|
return new SwitchColorsCommand;
|
||||||
|
}
|
||||||
|
@ -20,17 +20,34 @@
|
|||||||
|
|
||||||
#include "jinete/jbase.h"
|
#include "jinete/jbase.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "dialogs/tips.h"
|
#include "dialogs/tips.h"
|
||||||
|
|
||||||
static void cmd_tips_execute(const char *argument)
|
class TipsCommand : public Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TipsCommand();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
TipsCommand::TipsCommand()
|
||||||
|
: Command("tips",
|
||||||
|
"Tips",
|
||||||
|
CmdUIOnlyFlag)
|
||||||
{
|
{
|
||||||
dialogs_tips(TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_tips = {
|
void TipsCommand::execute(Context* context)
|
||||||
CMD_TIPS,
|
{
|
||||||
NULL,
|
dialogs_tips(true);
|
||||||
NULL,
|
}
|
||||||
cmd_tips_execute,
|
|
||||||
};
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// CommandFactory
|
||||||
|
|
||||||
|
Command* CommandFactory::create_tips_command()
|
||||||
|
{
|
||||||
|
return new TipsCommand;
|
||||||
|
}
|
||||||
|
@ -18,24 +18,43 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "core/app.h"
|
#include "core/app.h"
|
||||||
#include "modules/gui.h"
|
#include "modules/gui.h"
|
||||||
#include "raster/sprite.h"
|
#include "raster/sprite.h"
|
||||||
#include "raster/undo.h"
|
#include "raster/undo.h"
|
||||||
#include "widgets/statebar.h"
|
#include "widgets/statebar.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
|
||||||
static bool cmd_undo_enabled(const char *argument)
|
class UndoCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
UndoCommand();
|
||||||
|
Command* clone() { return new UndoCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
UndoCommand::UndoCommand()
|
||||||
|
: Command("undo",
|
||||||
|
"Undo",
|
||||||
|
CmdUIOnlyFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UndoCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return
|
return
|
||||||
sprite != NULL &&
|
sprite != NULL &&
|
||||||
undo_can_undo(sprite->undo);
|
undo_can_undo(sprite->undo);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_undo_execute(const char *argument)
|
void UndoCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
CurrentSpriteWriter sprite;
|
CurrentSpriteWriter sprite(context);
|
||||||
|
|
||||||
statusbar_show_tip(app_get_statusbar(), 1000,
|
statusbar_show_tip(app_get_statusbar(), 1000,
|
||||||
_("Undid %s"),
|
_("Undid %s"),
|
||||||
@ -46,9 +65,10 @@ static void cmd_undo_execute(const char *argument)
|
|||||||
update_screen_for_sprite(sprite);
|
update_screen_for_sprite(sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_undo = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_UNDO,
|
// CommandFactory
|
||||||
cmd_undo_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_undo_command()
|
||||||
cmd_undo_execute,
|
{
|
||||||
};
|
return new UndoCommand;
|
||||||
|
}
|
||||||
|
66
src/commands/command.cpp
Normal file
66
src/commands/command.cpp
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
/* ASE - Allegro Sprite Editor
|
||||||
|
* Copyright (C) 2001-2009 David 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"
|
||||||
|
|
||||||
|
#include "console.h"
|
||||||
|
#include "commands/command.h"
|
||||||
|
#include "commands/params.h"
|
||||||
|
|
||||||
|
Command::Command(const char* short_name, const char* friendly_name, CommandFlags flags)
|
||||||
|
{
|
||||||
|
m_short_name = short_name;
|
||||||
|
m_friendly_name = friendly_name;
|
||||||
|
m_flags = flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
Command::~Command()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts specified parameters to class members.
|
||||||
|
*/
|
||||||
|
void Command::load_params(Params* params)
|
||||||
|
{
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Preconditions to execute the command
|
||||||
|
*/
|
||||||
|
bool Command::enabled(Context* context)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Should the menu-item be checked?
|
||||||
|
*/
|
||||||
|
bool Command::checked(Context* context)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the command (after checking the preconditions).
|
||||||
|
*/
|
||||||
|
void Command::execute(Context* context)
|
||||||
|
{
|
||||||
|
// do nothing
|
||||||
|
}
|
71
src/commands/command.h
Normal file
71
src/commands/command.h
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
/* ASE - Allegro Sprite Editor
|
||||||
|
* Copyright (C) 2001-2009 David 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 COMMANDS_COMMAND_H_INCLUDED
|
||||||
|
#define COMMANDS_COMMAND_H_INCLUDED
|
||||||
|
|
||||||
|
enum CommandFlags {
|
||||||
|
CmdUIOnlyFlag = 0x00000001,
|
||||||
|
CmdRecordableFlag = 0x00000002,
|
||||||
|
};
|
||||||
|
|
||||||
|
class Context;
|
||||||
|
class Params;
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// Command
|
||||||
|
|
||||||
|
class Command
|
||||||
|
{
|
||||||
|
const char* m_short_name;
|
||||||
|
const char* m_friendly_name;
|
||||||
|
CommandFlags m_flags;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
Command(const char* short_name, const char* friendly_name, CommandFlags flags);
|
||||||
|
virtual ~Command();
|
||||||
|
|
||||||
|
virtual Command* clone() const { return new Command(*this); }
|
||||||
|
|
||||||
|
const char* short_name() const { return m_short_name; }
|
||||||
|
const char* friendly_name() const { return m_friendly_name; }
|
||||||
|
|
||||||
|
virtual void load_params(Params* params);
|
||||||
|
|
||||||
|
virtual bool enabled(Context* context);
|
||||||
|
virtual bool checked(Context* context);
|
||||||
|
virtual void execute(Context* context);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// CommandFactory
|
||||||
|
|
||||||
|
class CommandFactory
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
#undef FOR_EACH_COMMAND
|
||||||
|
#define FOR_EACH_COMMAND(name) \
|
||||||
|
static Command* create_##name##_command();
|
||||||
|
|
||||||
|
#include "commands/commands_list.h"
|
||||||
|
#undef FOR_EACH_COMMAND
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -26,265 +26,58 @@
|
|||||||
#include "jinete/jinete.h"
|
#include "jinete/jinete.h"
|
||||||
|
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
|
#include "commands/command.h"
|
||||||
#include "commands/commands.h"
|
#include "commands/commands.h"
|
||||||
|
|
||||||
extern Command cmd_about;
|
#undef FOR_EACH_COMMAND
|
||||||
extern Command cmd_advanced_mode;
|
#define FOR_EACH_COMMAND(name) \
|
||||||
extern Command cmd_autocrop_sprite;
|
const char* CommandId::name = #name;
|
||||||
extern Command cmd_background_from_layer;
|
#include "commands/commands_list.h"
|
||||||
extern Command cmd_blur_tool;
|
#undef FOR_EACH_COMMAND
|
||||||
extern Command cmd_brush_tool;
|
|
||||||
extern Command cmd_canvas_size;
|
|
||||||
extern Command cmd_cel_properties;
|
|
||||||
extern Command cmd_change_image_type;
|
|
||||||
extern Command cmd_clear;
|
|
||||||
extern Command cmd_close_all_files;
|
|
||||||
extern Command cmd_close_editor;
|
|
||||||
extern Command cmd_close_file;
|
|
||||||
extern Command cmd_color_curve;
|
|
||||||
extern Command cmd_configure_screen;
|
|
||||||
extern Command cmd_configure_tools;
|
|
||||||
extern Command cmd_convolution_matrix;
|
|
||||||
extern Command cmd_copy;
|
|
||||||
extern Command cmd_copy_cel;
|
|
||||||
extern Command cmd_crop_sprite;
|
|
||||||
extern Command cmd_cut;
|
|
||||||
extern Command cmd_deselect_mask;
|
|
||||||
extern Command cmd_despeckle;
|
|
||||||
extern Command cmd_duplicate_layer;
|
|
||||||
extern Command cmd_duplicate_sprite;
|
|
||||||
extern Command cmd_ellipse_tool;
|
|
||||||
extern Command cmd_eraser_tool;
|
|
||||||
extern Command cmd_exit;
|
|
||||||
extern Command cmd_eyedropper_tool;
|
|
||||||
extern Command cmd_film_editor;
|
|
||||||
extern Command cmd_flatten_layers;
|
|
||||||
extern Command cmd_flip;
|
|
||||||
extern Command cmd_floodfill_tool;
|
|
||||||
extern Command cmd_frame_properties;
|
|
||||||
extern Command cmd_goto_first_frame;
|
|
||||||
extern Command cmd_goto_last_frame;
|
|
||||||
extern Command cmd_goto_next_frame;
|
|
||||||
extern Command cmd_goto_next_layer;
|
|
||||||
extern Command cmd_goto_previous_frame;
|
|
||||||
extern Command cmd_goto_previous_layer;
|
|
||||||
extern Command cmd_invert_color;
|
|
||||||
extern Command cmd_invert_mask;
|
|
||||||
extern Command cmd_layer_from_background;
|
|
||||||
extern Command cmd_layer_properties;
|
|
||||||
extern Command cmd_line_tool;
|
|
||||||
extern Command cmd_load_mask;
|
|
||||||
extern Command cmd_make_unique_editor;
|
|
||||||
extern Command cmd_marker_tool;
|
|
||||||
extern Command cmd_mask_all;
|
|
||||||
extern Command cmd_mask_by_color;
|
|
||||||
extern Command cmd_merge_down_layer;
|
|
||||||
extern Command cmd_move_cel;
|
|
||||||
extern Command cmd_new_file;
|
|
||||||
extern Command cmd_new_frame;
|
|
||||||
extern Command cmd_new_layer;
|
|
||||||
extern Command cmd_new_layer_set;
|
|
||||||
extern Command cmd_open_file;
|
|
||||||
extern Command cmd_options;
|
|
||||||
extern Command cmd_palette_editor;
|
|
||||||
extern Command cmd_paste;
|
|
||||||
extern Command cmd_pencil_tool;
|
|
||||||
extern Command cmd_play_animation;
|
|
||||||
extern Command cmd_preview_fit_to_screen;
|
|
||||||
extern Command cmd_preview_normal;
|
|
||||||
extern Command cmd_preview_tiled;
|
|
||||||
extern Command cmd_record_screen;
|
|
||||||
extern Command cmd_rectangle_tool;
|
|
||||||
extern Command cmd_redo;
|
|
||||||
extern Command cmd_refresh;
|
|
||||||
extern Command cmd_remove_cel;
|
|
||||||
extern Command cmd_remove_frame;
|
|
||||||
extern Command cmd_remove_layer;
|
|
||||||
extern Command cmd_replace_color;
|
|
||||||
extern Command cmd_reselect_mask;
|
|
||||||
extern Command cmd_rotate_canvas;
|
|
||||||
extern Command cmd_save_file;
|
|
||||||
extern Command cmd_save_file_as;
|
|
||||||
extern Command cmd_save_file_copy_as;
|
|
||||||
extern Command cmd_save_mask;
|
|
||||||
extern Command cmd_screen_shot;
|
|
||||||
extern Command cmd_select_file;
|
|
||||||
extern Command cmd_show_grid;
|
|
||||||
extern Command cmd_snap_to_grid;
|
|
||||||
extern Command cmd_split_editor_horizontally;
|
|
||||||
extern Command cmd_split_editor_vertically;
|
|
||||||
extern Command cmd_spray_tool;
|
|
||||||
extern Command cmd_sprite_properties;
|
|
||||||
extern Command cmd_sprite_size;
|
|
||||||
extern Command cmd_switch_colors;
|
|
||||||
extern Command cmd_tips;
|
|
||||||
extern Command cmd_undo;
|
|
||||||
|
|
||||||
static Command *commands[] = {
|
CommandsModule* CommandsModule::m_instance = NULL;
|
||||||
|
|
||||||
&cmd_about,
|
CommandsModule::CommandsModule()
|
||||||
&cmd_advanced_mode,
|
|
||||||
&cmd_autocrop_sprite,
|
|
||||||
&cmd_background_from_layer,
|
|
||||||
&cmd_blur_tool,
|
|
||||||
&cmd_brush_tool,
|
|
||||||
&cmd_canvas_size,
|
|
||||||
&cmd_cel_properties,
|
|
||||||
&cmd_change_image_type,
|
|
||||||
&cmd_clear,
|
|
||||||
&cmd_close_all_files,
|
|
||||||
&cmd_close_editor,
|
|
||||||
&cmd_close_file,
|
|
||||||
&cmd_color_curve,
|
|
||||||
&cmd_configure_screen,
|
|
||||||
&cmd_configure_tools,
|
|
||||||
&cmd_convolution_matrix,
|
|
||||||
&cmd_copy,
|
|
||||||
&cmd_copy_cel,
|
|
||||||
&cmd_crop_sprite,
|
|
||||||
&cmd_cut,
|
|
||||||
&cmd_deselect_mask,
|
|
||||||
&cmd_despeckle,
|
|
||||||
&cmd_duplicate_layer,
|
|
||||||
&cmd_duplicate_sprite,
|
|
||||||
&cmd_ellipse_tool,
|
|
||||||
&cmd_eraser_tool,
|
|
||||||
&cmd_exit,
|
|
||||||
&cmd_eyedropper_tool,
|
|
||||||
&cmd_film_editor,
|
|
||||||
&cmd_flatten_layers,
|
|
||||||
&cmd_flip,
|
|
||||||
&cmd_floodfill_tool,
|
|
||||||
&cmd_frame_properties,
|
|
||||||
&cmd_goto_first_frame,
|
|
||||||
&cmd_goto_last_frame,
|
|
||||||
&cmd_goto_next_frame,
|
|
||||||
&cmd_goto_next_layer,
|
|
||||||
&cmd_goto_previous_frame,
|
|
||||||
&cmd_goto_previous_layer,
|
|
||||||
&cmd_invert_color,
|
|
||||||
&cmd_invert_mask,
|
|
||||||
&cmd_layer_from_background,
|
|
||||||
&cmd_layer_properties,
|
|
||||||
&cmd_line_tool,
|
|
||||||
&cmd_load_mask,
|
|
||||||
&cmd_make_unique_editor,
|
|
||||||
&cmd_marker_tool,
|
|
||||||
&cmd_mask_all,
|
|
||||||
&cmd_mask_by_color,
|
|
||||||
&cmd_merge_down_layer,
|
|
||||||
&cmd_move_cel,
|
|
||||||
&cmd_new_file,
|
|
||||||
&cmd_new_frame,
|
|
||||||
&cmd_new_layer,
|
|
||||||
&cmd_new_layer_set,
|
|
||||||
&cmd_open_file,
|
|
||||||
&cmd_options,
|
|
||||||
&cmd_palette_editor,
|
|
||||||
&cmd_paste,
|
|
||||||
&cmd_pencil_tool,
|
|
||||||
&cmd_play_animation,
|
|
||||||
&cmd_preview_fit_to_screen,
|
|
||||||
&cmd_preview_normal,
|
|
||||||
&cmd_preview_tiled,
|
|
||||||
&cmd_record_screen,
|
|
||||||
&cmd_rectangle_tool,
|
|
||||||
&cmd_redo,
|
|
||||||
&cmd_refresh,
|
|
||||||
&cmd_remove_cel,
|
|
||||||
&cmd_remove_frame,
|
|
||||||
&cmd_remove_layer,
|
|
||||||
&cmd_replace_color,
|
|
||||||
&cmd_reselect_mask,
|
|
||||||
&cmd_rotate_canvas,
|
|
||||||
&cmd_save_file,
|
|
||||||
&cmd_save_file_as,
|
|
||||||
&cmd_save_file_copy_as,
|
|
||||||
&cmd_save_mask,
|
|
||||||
&cmd_screen_shot,
|
|
||||||
&cmd_select_file,
|
|
||||||
&cmd_show_grid,
|
|
||||||
&cmd_snap_to_grid,
|
|
||||||
&cmd_split_editor_horizontally,
|
|
||||||
&cmd_split_editor_vertically,
|
|
||||||
&cmd_spray_tool,
|
|
||||||
&cmd_sprite_properties,
|
|
||||||
&cmd_sprite_size,
|
|
||||||
&cmd_switch_colors,
|
|
||||||
&cmd_tips,
|
|
||||||
&cmd_undo,
|
|
||||||
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
Command *command_get_by_name(const char *name)
|
|
||||||
{
|
{
|
||||||
Command **cmd;
|
assert(m_instance == NULL);
|
||||||
|
m_instance = this;
|
||||||
|
|
||||||
|
#undef FOR_EACH_COMMAND
|
||||||
|
#define FOR_EACH_COMMAND(name) \
|
||||||
|
m_commands.push_back(CommandFactory::create_##name##_command());
|
||||||
|
|
||||||
|
#include "commands/commands_list.h"
|
||||||
|
#undef FOR_EACH_COMMAND
|
||||||
|
}
|
||||||
|
|
||||||
|
CommandsModule::~CommandsModule()
|
||||||
|
{
|
||||||
|
assert(m_instance == this);
|
||||||
|
|
||||||
|
for (CommandsList::iterator
|
||||||
|
it = m_commands.begin(); it != m_commands.end(); ++it) {
|
||||||
|
delete *it;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_commands.clear();
|
||||||
|
m_instance = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
CommandsModule* CommandsModule::instance()
|
||||||
|
{
|
||||||
|
return m_instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
Command* CommandsModule::get_command_by_name(const char* name)
|
||||||
|
{
|
||||||
if (!name)
|
if (!name)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
for (cmd=commands; *cmd; cmd++) {
|
for (CommandsList::iterator
|
||||||
if (strcmp((*cmd)->name, name) == 0)
|
it = m_commands.begin(); it != m_commands.end(); ++it) {
|
||||||
return *cmd;
|
if (ustricmp((*it)->short_name(), name) == 0)
|
||||||
|
return *it;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
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)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
if (command && command->enabled)
|
|
||||||
return (*command->enabled)(argument);
|
|
||||||
else
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (...) {
|
|
||||||
// did the "is_enabled" throw an exception? disabled this command so...
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool command_is_checked(Command *command, const char *argument)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
if (command && command->checked)
|
|
||||||
return (*command->checked)(argument);
|
|
||||||
}
|
|
||||||
catch (...) {
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
Console console;
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (command && command->execute &&
|
|
||||||
command_is_enabled(command, argument)) {
|
|
||||||
(*command->execute)(argument);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (ase_exception& e) {
|
|
||||||
e.show();
|
|
||||||
}
|
|
||||||
catch (std::exception& e) {
|
|
||||||
console.printf("An error ocurred executing the command.\n\nDetails:\n%s", e.what());
|
|
||||||
}
|
|
||||||
catch (...) {
|
|
||||||
console.printf("An unknown error ocurred executing the command.\n"
|
|
||||||
"Please try again or report this bug.\n\n"
|
|
||||||
"Details: Unknown exception caught.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -20,114 +20,34 @@
|
|||||||
#define COMMANDS_COMMANDS_H_INCLUDED
|
#define COMMANDS_COMMANDS_H_INCLUDED
|
||||||
|
|
||||||
#include "jinete/jbase.h"
|
#include "jinete/jbase.h"
|
||||||
#include "sprite_wrappers.h"
|
|
||||||
|
|
||||||
#define CMD_ABOUT "about"
|
struct CommandId
|
||||||
#define CMD_ADVANCED_MODE "advanced_mode"
|
|
||||||
#define CMD_AUTOCROP_SPRITE "autocrop_sprite"
|
|
||||||
#define CMD_BACKGROUND_FROM_LAYER "background_from_layer"
|
|
||||||
#define CMD_BLUR_TOOL "blur_tool"
|
|
||||||
#define CMD_BRUSH_TOOL "brush_tool"
|
|
||||||
#define CMD_CANVAS_SIZE "canvas_size"
|
|
||||||
#define CMD_CEL_PROPERTIES "cel_properties"
|
|
||||||
#define CMD_CHANGE_IMAGE_TYPE "change_image_type"
|
|
||||||
#define CMD_CLEAR "clear"
|
|
||||||
#define CMD_CLOSE_ALL_FILES "close_all_files"
|
|
||||||
#define CMD_CLOSE_EDITOR "close_editor"
|
|
||||||
#define CMD_CLOSE_FILE "close_file"
|
|
||||||
#define CMD_COLOR_CURVE "color_curve"
|
|
||||||
#define CMD_CONFIGURE_SCREEN "configure_screen"
|
|
||||||
#define CMD_CONFIGURE_TOOLS "configure_tools"
|
|
||||||
#define CMD_CONVOLUTION_MATRIX "convolution_matrix"
|
|
||||||
#define CMD_COPY "copy"
|
|
||||||
#define CMD_COPY_CEL "copy_cel"
|
|
||||||
#define CMD_CROP_SPRITE "crop_sprite"
|
|
||||||
#define CMD_CUT "cut"
|
|
||||||
#define CMD_DESELECT_MASK "deselect_mask"
|
|
||||||
#define CMD_DESPECKLE "despeckle"
|
|
||||||
#define CMD_DUPLICATE_LAYER "duplicate_layer"
|
|
||||||
#define CMD_DUPLICATE_SPRITE "duplicate_sprite"
|
|
||||||
#define CMD_ELLIPSE_TOOL "ellipse_tool"
|
|
||||||
#define CMD_ERASER_TOOL "eraser_tool"
|
|
||||||
#define CMD_EXIT "exit"
|
|
||||||
#define CMD_EYEDROPPER_TOOL "eyedropper_tool"
|
|
||||||
#define CMD_FILM_EDITOR "film_editor"
|
|
||||||
#define CMD_FLATTEN_LAYERS "flatten_layers"
|
|
||||||
#define CMD_FLIP "flip"
|
|
||||||
#define CMD_FLOODFILL_TOOL "floodfill_tool"
|
|
||||||
#define CMD_FRAME_PROPERTIES "frame_properties"
|
|
||||||
#define CMD_GOTO_FIRST_FRAME "goto_first_frame"
|
|
||||||
#define CMD_GOTO_LAST_FRAME "goto_last_frame"
|
|
||||||
#define CMD_GOTO_NEXT_FRAME "goto_next_frame"
|
|
||||||
#define CMD_GOTO_NEXT_LAYER "goto_next_layer"
|
|
||||||
#define CMD_GOTO_PREVIOUS_FRAME "goto_previous_frame"
|
|
||||||
#define CMD_GOTO_PREVIOUS_LAYER "goto_previous_layer"
|
|
||||||
#define CMD_INVERT_COLOR "invert_color"
|
|
||||||
#define CMD_INVERT_MASK "invert_mask"
|
|
||||||
#define CMD_LAYER_FROM_BACKGROUND "layer_from_background"
|
|
||||||
#define CMD_LAYER_PROPERTIES "layer_properties"
|
|
||||||
#define CMD_LINE_TOOL "line_tool"
|
|
||||||
#define CMD_LOAD_MASK "load_mask"
|
|
||||||
#define CMD_MAKE_UNIQUE_EDITOR "make_unique_editor"
|
|
||||||
#define CMD_MARKER_TOOL "marker_tool"
|
|
||||||
#define CMD_MASK_ALL "mask_all"
|
|
||||||
#define CMD_MASK_BY_COLOR "mask_by_color"
|
|
||||||
#define CMD_MERGE_DOWN_LAYER "merge_down_layer"
|
|
||||||
#define CMD_MOVE_CEL "move_cel"
|
|
||||||
#define CMD_NEW_FILE "new_file"
|
|
||||||
#define CMD_NEW_FRAME "new_frame"
|
|
||||||
#define CMD_NEW_LAYER "new_layer"
|
|
||||||
#define CMD_NEW_LAYER_SET "new_layer_set"
|
|
||||||
#define CMD_OPEN_FILE "open_file"
|
|
||||||
#define CMD_OPTIONS "options"
|
|
||||||
#define CMD_PALETTE_EDITOR "palette_editor"
|
|
||||||
#define CMD_PASTE "paste"
|
|
||||||
#define CMD_PENCIL_TOOL "pencil_tool"
|
|
||||||
#define CMD_PLAY_ANIMATION "play_animation"
|
|
||||||
#define CMD_PREVIEW_FIT_TO_SCREEN "preview_fit_to_screen"
|
|
||||||
#define CMD_PREVIEW_NORMAL "preview_normal"
|
|
||||||
#define CMD_PREVIEW_TILED "preview_tiled"
|
|
||||||
#define CMD_RECORD_SCREEN "record_screen"
|
|
||||||
#define CMD_RECTANGLE_TOOL "rectangle_tool"
|
|
||||||
#define CMD_REDO "redo"
|
|
||||||
#define CMD_REFRESH "refresh"
|
|
||||||
#define CMD_REMOVE_CEL "remove_cel"
|
|
||||||
#define CMD_REMOVE_FRAME "remove_frame"
|
|
||||||
#define CMD_REMOVE_LAYER "remove_layer"
|
|
||||||
#define CMD_REPLACE_COLOR "replace_color"
|
|
||||||
#define CMD_RESELECT_MASK "reselect_mask"
|
|
||||||
#define CMD_ROTATE_CANVAS "rotate_canvas"
|
|
||||||
#define CMD_SAVE_FILE "save_file"
|
|
||||||
#define CMD_SAVE_FILE_AS "save_file_as"
|
|
||||||
#define CMD_SAVE_FILE_COPY_AS "save_file_copy_as"
|
|
||||||
#define CMD_SAVE_MASK "save_mask"
|
|
||||||
#define CMD_SCREEN_SHOT "screen_shot"
|
|
||||||
#define CMD_SELECT_FILE "select_file"
|
|
||||||
#define CMD_SHOW_GRID "show_grid"
|
|
||||||
#define CMD_SNAP_TO_GRID "snap_to_grid"
|
|
||||||
#define CMD_SPLIT_EDITOR_HORIZONTALLY "split_editor_horizontally"
|
|
||||||
#define CMD_SPLIT_EDITOR_VERTICALLY "split_editor_vertically"
|
|
||||||
#define CMD_SPRAY_TOOL "spray_tool"
|
|
||||||
#define CMD_SPRITE_PROPERTIES "sprite_properties"
|
|
||||||
#define CMD_SPRITE_SIZE "sprite_size"
|
|
||||||
#define CMD_SWITCH_COLORS "switch_colors"
|
|
||||||
#define CMD_TIPS "tips"
|
|
||||||
#define CMD_UNDO "undo"
|
|
||||||
|
|
||||||
typedef struct Command Command;
|
|
||||||
|
|
||||||
struct Command
|
|
||||||
{
|
{
|
||||||
const char *name;
|
#undef FOR_EACH_COMMAND
|
||||||
bool (*enabled)(const char *argument); /* preconditions to execute the command */
|
#define FOR_EACH_COMMAND(name) \
|
||||||
bool (*checked)(const char *argument); /* should the menu-item be checked? */
|
static const char* name;
|
||||||
void (*execute)(const char *argument); /* execute the command (after check the preconditions) */
|
#include "commands/commands_list.h"
|
||||||
|
#undef FOR_EACH_COMMAND
|
||||||
};
|
};
|
||||||
|
|
||||||
Command *command_get_by_name(const char *name);
|
#include <vector>
|
||||||
|
|
||||||
bool command_is_enabled(Command *command, const char *argument);
|
class Command;
|
||||||
bool command_is_checked(Command *command, const char *argument);
|
|
||||||
void command_execute(Command *command, const char *argument);
|
typedef std::vector<Command*> CommandsList;
|
||||||
|
|
||||||
|
class CommandsModule
|
||||||
|
{
|
||||||
|
static CommandsModule* m_instance;
|
||||||
|
CommandsList m_commands;
|
||||||
|
|
||||||
|
public:
|
||||||
|
CommandsModule();
|
||||||
|
~CommandsModule();
|
||||||
|
|
||||||
|
static CommandsModule* instance();
|
||||||
|
|
||||||
|
Command* get_command_by_name(const char* name);
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
109
src/commands/commands_list.h
Normal file
109
src/commands/commands_list.h
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
/* ASE - Allegro Sprite Editor
|
||||||
|
* Copyright (C) 2001-2009 David 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
FOR_EACH_COMMAND(about)
|
||||||
|
FOR_EACH_COMMAND(advanced_mode)
|
||||||
|
FOR_EACH_COMMAND(autocrop_sprite)
|
||||||
|
FOR_EACH_COMMAND(background_from_layer)
|
||||||
|
// FOR_EACH_COMMAND(blur_tool)
|
||||||
|
// FOR_EACH_COMMAND(brush_tool)
|
||||||
|
FOR_EACH_COMMAND(canvas_size)
|
||||||
|
FOR_EACH_COMMAND(cel_properties)
|
||||||
|
FOR_EACH_COMMAND(change_image_type)
|
||||||
|
FOR_EACH_COMMAND(clear)
|
||||||
|
FOR_EACH_COMMAND(close_all_files)
|
||||||
|
FOR_EACH_COMMAND(close_editor)
|
||||||
|
FOR_EACH_COMMAND(close_file)
|
||||||
|
FOR_EACH_COMMAND(color_curve)
|
||||||
|
FOR_EACH_COMMAND(configure_screen)
|
||||||
|
FOR_EACH_COMMAND(configure_tools)
|
||||||
|
FOR_EACH_COMMAND(convolution_matrix)
|
||||||
|
FOR_EACH_COMMAND(copy)
|
||||||
|
FOR_EACH_COMMAND(copy_cel)
|
||||||
|
FOR_EACH_COMMAND(crop_sprite)
|
||||||
|
FOR_EACH_COMMAND(cut)
|
||||||
|
FOR_EACH_COMMAND(deselect_mask)
|
||||||
|
FOR_EACH_COMMAND(despeckle)
|
||||||
|
FOR_EACH_COMMAND(duplicate_layer)
|
||||||
|
FOR_EACH_COMMAND(duplicate_sprite)
|
||||||
|
// FOR_EACH_COMMAND(ellipse_tool)
|
||||||
|
// FOR_EACH_COMMAND(eraser_tool)
|
||||||
|
FOR_EACH_COMMAND(exit)
|
||||||
|
FOR_EACH_COMMAND(eyedropper_tool)
|
||||||
|
FOR_EACH_COMMAND(film_editor)
|
||||||
|
FOR_EACH_COMMAND(flatten_layers)
|
||||||
|
FOR_EACH_COMMAND(flip)
|
||||||
|
// FOR_EACH_COMMAND(floodfill_tool)
|
||||||
|
FOR_EACH_COMMAND(frame_properties)
|
||||||
|
FOR_EACH_COMMAND(goto_first_frame)
|
||||||
|
FOR_EACH_COMMAND(goto_last_frame)
|
||||||
|
FOR_EACH_COMMAND(goto_next_frame)
|
||||||
|
FOR_EACH_COMMAND(goto_next_layer)
|
||||||
|
FOR_EACH_COMMAND(goto_previous_frame)
|
||||||
|
FOR_EACH_COMMAND(goto_previous_layer)
|
||||||
|
FOR_EACH_COMMAND(invert_color)
|
||||||
|
FOR_EACH_COMMAND(invert_mask)
|
||||||
|
FOR_EACH_COMMAND(layer_from_background)
|
||||||
|
FOR_EACH_COMMAND(layer_properties)
|
||||||
|
// FOR_EACH_COMMAND(line_tool)
|
||||||
|
FOR_EACH_COMMAND(load_mask)
|
||||||
|
FOR_EACH_COMMAND(make_unique_editor)
|
||||||
|
// FOR_EACH_COMMAND(marker_tool)
|
||||||
|
FOR_EACH_COMMAND(mask_all)
|
||||||
|
FOR_EACH_COMMAND(mask_by_color)
|
||||||
|
FOR_EACH_COMMAND(merge_down_layer)
|
||||||
|
FOR_EACH_COMMAND(move_cel)
|
||||||
|
FOR_EACH_COMMAND(new_file)
|
||||||
|
FOR_EACH_COMMAND(new_frame)
|
||||||
|
FOR_EACH_COMMAND(new_layer)
|
||||||
|
FOR_EACH_COMMAND(new_layer_set)
|
||||||
|
FOR_EACH_COMMAND(open_file)
|
||||||
|
FOR_EACH_COMMAND(options)
|
||||||
|
FOR_EACH_COMMAND(palette_editor)
|
||||||
|
FOR_EACH_COMMAND(paste)
|
||||||
|
// FOR_EACH_COMMAND(pencil_tool)
|
||||||
|
FOR_EACH_COMMAND(play_animation)
|
||||||
|
FOR_EACH_COMMAND(preview_fit_to_screen)
|
||||||
|
FOR_EACH_COMMAND(preview_normal)
|
||||||
|
FOR_EACH_COMMAND(preview_tiled)
|
||||||
|
FOR_EACH_COMMAND(record_screen)
|
||||||
|
// FOR_EACH_COMMAND(rectangle_tool)
|
||||||
|
FOR_EACH_COMMAND(redo)
|
||||||
|
FOR_EACH_COMMAND(refresh)
|
||||||
|
FOR_EACH_COMMAND(remove_cel)
|
||||||
|
FOR_EACH_COMMAND(remove_frame)
|
||||||
|
FOR_EACH_COMMAND(remove_layer)
|
||||||
|
FOR_EACH_COMMAND(replace_color)
|
||||||
|
FOR_EACH_COMMAND(reselect_mask)
|
||||||
|
FOR_EACH_COMMAND(rotate_canvas)
|
||||||
|
FOR_EACH_COMMAND(save_file)
|
||||||
|
FOR_EACH_COMMAND(save_file_as)
|
||||||
|
FOR_EACH_COMMAND(save_file_copy_as)
|
||||||
|
FOR_EACH_COMMAND(save_mask)
|
||||||
|
FOR_EACH_COMMAND(screen_shot)
|
||||||
|
FOR_EACH_COMMAND(select_file)
|
||||||
|
FOR_EACH_COMMAND(show_grid)
|
||||||
|
FOR_EACH_COMMAND(snap_to_grid)
|
||||||
|
FOR_EACH_COMMAND(split_editor_horizontally)
|
||||||
|
FOR_EACH_COMMAND(split_editor_vertically)
|
||||||
|
// FOR_EACH_COMMAND(spray_tool)
|
||||||
|
FOR_EACH_COMMAND(sprite_properties)
|
||||||
|
FOR_EACH_COMMAND(sprite_size)
|
||||||
|
FOR_EACH_COMMAND(switch_colors)
|
||||||
|
FOR_EACH_COMMAND(tips)
|
||||||
|
FOR_EACH_COMMAND(undo)
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#include "jinete/jinete.h"
|
#include "jinete/jinete.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "commands/fx/effectbg.h"
|
#include "commands/fx/effectbg.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "core/app.h"
|
#include "core/app.h"
|
||||||
@ -44,16 +44,37 @@ static JWidget check_preview, preview;
|
|||||||
static bool window_msg_proc(JWidget widget, JMessage msg);
|
static bool window_msg_proc(JWidget widget, JMessage msg);
|
||||||
static void make_preview();
|
static void make_preview();
|
||||||
|
|
||||||
static bool cmd_color_curve_enabled(const char *argument)
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// ColorCurveCommand
|
||||||
|
|
||||||
|
class ColorCurveCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
ColorCurveCommand();
|
||||||
|
Command* clone() const { return new ColorCurveCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
ColorCurveCommand::ColorCurveCommand()
|
||||||
|
: Command("color_curve",
|
||||||
|
"Color Curve",
|
||||||
|
CmdRecordableFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ColorCurveCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return
|
return
|
||||||
sprite != NULL;
|
sprite != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_color_curve_execute(const char *argument)
|
void ColorCurveCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
const CurrentSpriteReader sprite(context);
|
||||||
JWidget button_ok;
|
JWidget button_ok;
|
||||||
JWidget view_curve, curve_editor;
|
JWidget view_curve, curve_editor;
|
||||||
JWidget box_target, target_button;
|
JWidget box_target, target_button;
|
||||||
@ -154,9 +175,10 @@ static void make_preview()
|
|||||||
preview_restart(preview);
|
preview_restart(preview);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_color_curve = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_COLOR_CURVE,
|
// CommandFactory
|
||||||
cmd_color_curve_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_color_curve_command()
|
||||||
cmd_color_curve_execute,
|
{
|
||||||
};
|
return new ColorCurveCommand;
|
||||||
|
}
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#include "jinete/jwidget.h"
|
#include "jinete/jwidget.h"
|
||||||
#include "jinete/jwindow.h"
|
#include "jinete/jwindow.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "commands/fx/effectbg.h"
|
#include "commands/fx/effectbg.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "core/cfg.h"
|
#include "core/cfg.h"
|
||||||
@ -66,16 +66,37 @@ static bool preview_change_hook(JWidget widget, void *data);
|
|||||||
static bool tiled_change_hook(JWidget widget, void *data);
|
static bool tiled_change_hook(JWidget widget, void *data);
|
||||||
static void make_preview();
|
static void make_preview();
|
||||||
|
|
||||||
static bool cmd_convolution_matrix_enabled(const char *argument)
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// convolution_matrix
|
||||||
|
|
||||||
|
class ConvolutionMatrixCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
ConvolutionMatrixCommand();
|
||||||
|
Command* clone() const { return new ConvolutionMatrixCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
ConvolutionMatrixCommand::ConvolutionMatrixCommand()
|
||||||
|
: Command("convolution_matrix",
|
||||||
|
"Convolution Matrix",
|
||||||
|
CmdRecordableFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ConvolutionMatrixCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return
|
return
|
||||||
sprite != NULL;
|
sprite != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_convolution_matrix_execute(const char *argument)
|
void ConvolutionMatrixCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
const CurrentSpriteReader sprite(context);
|
||||||
JWidget button_ok;
|
JWidget button_ok;
|
||||||
JWidget view_convmatr, list_convmatr;
|
JWidget view_convmatr, list_convmatr;
|
||||||
JWidget box_target;
|
JWidget box_target;
|
||||||
@ -312,9 +333,11 @@ static void make_preview()
|
|||||||
preview_restart(preview);
|
preview_restart(preview);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_convolution_matrix = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_CONVOLUTION_MATRIX,
|
// CommandFactory
|
||||||
cmd_convolution_matrix_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_convolution_matrix_command()
|
||||||
cmd_convolution_matrix_execute,
|
{
|
||||||
};
|
return new ConvolutionMatrixCommand;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include "jinete/jwidget.h"
|
#include "jinete/jwidget.h"
|
||||||
#include "jinete/jwindow.h"
|
#include "jinete/jwindow.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "commands/fx/effectbg.h"
|
#include "commands/fx/effectbg.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "core/cfg.h"
|
#include "core/cfg.h"
|
||||||
@ -53,16 +53,37 @@ static bool preview_change_hook(JWidget widget, void *data);
|
|||||||
static bool tiled_change_hook(JWidget widget, void *data);
|
static bool tiled_change_hook(JWidget widget, void *data);
|
||||||
static void make_preview();
|
static void make_preview();
|
||||||
|
|
||||||
static bool cmd_despeckle_enabled(const char *argument)
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// despeckle
|
||||||
|
|
||||||
|
class DespeckleCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
DespeckleCommand();
|
||||||
|
Command* clone() const { return new DespeckleCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
DespeckleCommand::DespeckleCommand()
|
||||||
|
: Command("despeckle",
|
||||||
|
"Despeckle",
|
||||||
|
CmdRecordableFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DespeckleCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return
|
return
|
||||||
sprite != NULL;
|
sprite != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_despeckle_execute(const char *argument)
|
void DespeckleCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
const CurrentSpriteReader sprite(context);
|
||||||
JWidget box_target, target_button, button_ok;
|
JWidget box_target, target_button, button_ok;
|
||||||
char buf[32];
|
char buf[32];
|
||||||
|
|
||||||
@ -179,9 +200,10 @@ static void make_preview()
|
|||||||
preview_restart(preview);
|
preview_restart(preview);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_despeckle = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_DESPECKLE,
|
// CommandFactory
|
||||||
cmd_despeckle_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_despeckle_command()
|
||||||
cmd_despeckle_execute,
|
{
|
||||||
};
|
return new DespeckleCommand;
|
||||||
|
}
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#include "jinete/jwidget.h"
|
#include "jinete/jwidget.h"
|
||||||
#include "jinete/jwindow.h"
|
#include "jinete/jwindow.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "commands/fx/effectbg.h"
|
#include "commands/fx/effectbg.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "core/cfg.h"
|
#include "core/cfg.h"
|
||||||
@ -48,18 +48,38 @@ static bool target_change_hook(JWidget widget, void *data);
|
|||||||
static bool preview_change_hook(JWidget widget, void *data);
|
static bool preview_change_hook(JWidget widget, void *data);
|
||||||
static void make_preview();
|
static void make_preview();
|
||||||
|
|
||||||
static bool cmd_invert_color_enabled(const char *argument)
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// invert_color
|
||||||
|
|
||||||
|
class InvertColorCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
InvertColorCommand();
|
||||||
|
Command* clone() const { return new InvertColorCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
InvertColorCommand::InvertColorCommand()
|
||||||
|
: Command("invert_color",
|
||||||
|
"Invert Color",
|
||||||
|
CmdRecordableFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool InvertColorCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return
|
return
|
||||||
sprite != NULL;
|
sprite != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_invert_color_execute(const char *argument)
|
void InvertColorCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
JWidget box_target, target_button, button_ok;
|
JWidget box_target, target_button, button_ok;
|
||||||
const CurrentSpriteReader sprite;
|
|
||||||
|
|
||||||
JWidgetPtr window(load_widget("invrtcol.jid", "invert_color"));
|
JWidgetPtr window(load_widget("invrtcol.jid", "invert_color"));
|
||||||
get_widgets(window,
|
get_widgets(window,
|
||||||
"target", &box_target,
|
"target", &box_target,
|
||||||
@ -128,9 +148,10 @@ static void make_preview()
|
|||||||
preview_restart(preview);
|
preview_restart(preview);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_invert_color = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_INVERT_COLOR,
|
// CommandFactory
|
||||||
cmd_invert_color_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_invert_color_command()
|
||||||
cmd_invert_color_execute,
|
{
|
||||||
};
|
return new InvertColorCommand;
|
||||||
|
}
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include "jinete/jinete.h"
|
#include "jinete/jinete.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/command.h"
|
||||||
#include "commands/fx/effectbg.h"
|
#include "commands/fx/effectbg.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "core/app.h"
|
#include "core/app.h"
|
||||||
@ -51,16 +51,37 @@ static bool slider_change_hook(JWidget widget, void *data);
|
|||||||
static bool preview_change_hook(JWidget widget, void *data);
|
static bool preview_change_hook(JWidget widget, void *data);
|
||||||
static void make_preview();
|
static void make_preview();
|
||||||
|
|
||||||
static bool cmd_replace_color_enabled(const char *argument)
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// replace_color
|
||||||
|
|
||||||
|
class ReplaceColorCommand : public Command
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
public:
|
||||||
|
ReplaceColorCommand();
|
||||||
|
Command* clone() const { return new ReplaceColorCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled(Context* context);
|
||||||
|
void execute(Context* context);
|
||||||
|
};
|
||||||
|
|
||||||
|
ReplaceColorCommand::ReplaceColorCommand()
|
||||||
|
: Command("replace_color",
|
||||||
|
"Replace Color",
|
||||||
|
CmdRecordableFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ReplaceColorCommand::enabled(Context* context)
|
||||||
|
{
|
||||||
|
const CurrentSpriteReader sprite(context);
|
||||||
return
|
return
|
||||||
sprite != NULL;
|
sprite != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_replace_color_execute(const char *argument)
|
void ReplaceColorCommand::execute(Context* context)
|
||||||
{
|
{
|
||||||
const CurrentSpriteReader sprite;
|
const CurrentSpriteReader sprite(context);
|
||||||
JWidget color_buttons_box;
|
JWidget color_buttons_box;
|
||||||
JWidget box_target, target_button;
|
JWidget box_target, target_button;
|
||||||
JWidget button_ok;
|
JWidget button_ok;
|
||||||
@ -183,9 +204,10 @@ static void make_preview()
|
|||||||
preview_restart(preview);
|
preview_restart(preview);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_replace_color = {
|
//////////////////////////////////////////////////////////////////////
|
||||||
CMD_REPLACE_COLOR,
|
// CommandFactory
|
||||||
cmd_replace_color_enabled,
|
|
||||||
NULL,
|
Command* CommandFactory::create_replace_color_command()
|
||||||
cmd_replace_color_execute,
|
{
|
||||||
};
|
return new ReplaceColorCommand;
|
||||||
|
}
|
||||||
|
82
src/commands/params.h
Normal file
82
src/commands/params.h
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
/* ASE - Allegro Sprite Editor
|
||||||
|
* Copyright (C) 2001-2009 David 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 COMMANDS_PARAMS_H
|
||||||
|
#define COMMANDS_PARAMS_H
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
class Params
|
||||||
|
{
|
||||||
|
std::map<std::string, std::string> m_params;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
Params() { }
|
||||||
|
Params(const Params& copy) : m_params(copy.m_params) { }
|
||||||
|
virtual ~Params() { }
|
||||||
|
|
||||||
|
Params* clone()
|
||||||
|
{
|
||||||
|
return new Params(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool empty() const
|
||||||
|
{
|
||||||
|
return m_params.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool has_param(const char* name) const
|
||||||
|
{
|
||||||
|
return m_params.find(name) != m_params.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator==(const Params& params) const
|
||||||
|
{
|
||||||
|
return m_params == params.m_params;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator!=(const Params& params) const
|
||||||
|
{
|
||||||
|
return m_params != params.m_params;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string& set(const char* name, const char* value)
|
||||||
|
{
|
||||||
|
return m_params[name] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string& get(const char* name)
|
||||||
|
{
|
||||||
|
return m_params[name];
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
T get_as(const char* name)
|
||||||
|
{
|
||||||
|
std::istringstream stream(m_params[name]);
|
||||||
|
T value;
|
||||||
|
stream >> value;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -22,6 +22,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "context.h"
|
#include "context.h"
|
||||||
|
#include "commands/command.h"
|
||||||
#include "raster/sprite.h"
|
#include "raster/sprite.h"
|
||||||
|
|
||||||
Context::Context()
|
Context::Context()
|
||||||
@ -39,6 +40,16 @@ Context::~Context()
|
|||||||
m_sprites.clear();
|
m_sprites.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Context::get_fg_color()
|
||||||
|
{
|
||||||
|
return 0; // TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
int Context::get_bg_color()
|
||||||
|
{
|
||||||
|
return 0; // TODO
|
||||||
|
}
|
||||||
|
|
||||||
const SpriteList& Context::get_sprite_list() const
|
const SpriteList& Context::get_sprite_list() const
|
||||||
{
|
{
|
||||||
return m_sprites;
|
return m_sprites;
|
||||||
@ -123,6 +134,32 @@ void Context::set_current_sprite(Sprite* sprite)
|
|||||||
on_set_current_sprite(sprite);
|
on_set_current_sprite(sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Context::execute_command(Command* command, Params* params)
|
||||||
|
{
|
||||||
|
Console console;
|
||||||
|
|
||||||
|
assert(command != NULL);
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (params)
|
||||||
|
command->load_params(params);
|
||||||
|
|
||||||
|
if (command->enabled(this))
|
||||||
|
command->execute(this);
|
||||||
|
}
|
||||||
|
catch (ase_exception& e) {
|
||||||
|
e.show();
|
||||||
|
}
|
||||||
|
catch (std::exception& e) {
|
||||||
|
console.printf("An error ocurred executing the command.\n\nDetails:\n%s", e.what());
|
||||||
|
}
|
||||||
|
catch (...) {
|
||||||
|
console.printf("An unknown error ocurred executing the command.\n"
|
||||||
|
"Please try again or report this bug.\n\n"
|
||||||
|
"Details: Unknown exception caught.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Context::on_add_sprite(Sprite* sprite)
|
void Context::on_add_sprite(Sprite* sprite)
|
||||||
{
|
{
|
||||||
// do nothing
|
// do nothing
|
||||||
|
@ -20,12 +20,22 @@
|
|||||||
#define CONTEXT_H_INCLUDED
|
#define CONTEXT_H_INCLUDED
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include "ase_exception.h"
|
||||||
|
|
||||||
class Sprite;
|
class Sprite;
|
||||||
class SpriteReader;
|
class SpriteReader;
|
||||||
|
class Command;
|
||||||
|
class Params;
|
||||||
|
|
||||||
typedef std::list<Sprite*> SpriteList;
|
typedef std::list<Sprite*> SpriteList;
|
||||||
|
|
||||||
|
class Command_precondition_exception : public ase_exception
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Command_precondition_exception() throw()
|
||||||
|
: ase_exception("Cannot execute the command because its pre-conditions are false.") { }
|
||||||
|
};
|
||||||
|
|
||||||
class Context
|
class Context
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -48,6 +58,9 @@ public:
|
|||||||
virtual bool is_executing_macro() const { return false; }
|
virtual bool is_executing_macro() const { return false; }
|
||||||
virtual bool is_executing_script() const { return false; }
|
virtual bool is_executing_script() const { return false; }
|
||||||
|
|
||||||
|
virtual int get_fg_color();
|
||||||
|
virtual int get_bg_color();
|
||||||
|
|
||||||
const SpriteList& get_sprite_list() const;
|
const SpriteList& get_sprite_list() const;
|
||||||
Sprite* get_first_sprite() const;
|
Sprite* get_first_sprite() const;
|
||||||
Sprite* get_next_sprite(Sprite* sprite) const;
|
Sprite* get_next_sprite(Sprite* sprite) const;
|
||||||
@ -59,6 +72,8 @@ public:
|
|||||||
Sprite* get_current_sprite() const;
|
Sprite* get_current_sprite() const;
|
||||||
void set_current_sprite(Sprite* sprite);
|
void set_current_sprite(Sprite* sprite);
|
||||||
|
|
||||||
|
virtual void execute_command(Command* command, Params* params = NULL);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual void on_add_sprite(Sprite* sprite);
|
virtual void on_add_sprite(Sprite* sprite);
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include "ase_exception.h"
|
#include "ase_exception.h"
|
||||||
#include "ui_context.h"
|
#include "ui_context.h"
|
||||||
#include "commands/commands.h"
|
#include "commands/commands.h"
|
||||||
|
#include "commands/params.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "core/app.h"
|
#include "core/app.h"
|
||||||
#include "core/cfg.h"
|
#include "core/cfg.h"
|
||||||
@ -89,6 +90,8 @@ struct AppHook
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
App* App::m_instance = NULL;
|
||||||
|
|
||||||
static char *exe_name; /* name of the program */
|
static char *exe_name; /* name of the program */
|
||||||
|
|
||||||
static JList apphooks[APP_EVENTS];
|
static JList apphooks[APP_EVENTS];
|
||||||
@ -116,12 +119,24 @@ static void usage(int status);
|
|||||||
static Option *option_new(int type, const char *data);
|
static Option *option_new(int type, const char *data);
|
||||||
static void option_free(Option *option);
|
static void option_free(Option *option);
|
||||||
|
|
||||||
|
class App::Pimpl
|
||||||
|
{
|
||||||
|
CommandsModule m_commands_modules;
|
||||||
|
UIContext m_ui_context;
|
||||||
|
public:
|
||||||
|
Pimpl() { }
|
||||||
|
~Pimpl() { }
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the application loading the modules, setting the
|
* Initializes the application loading the modules, setting the
|
||||||
* graphics mode, loading the configuration and resources, etc.
|
* graphics mode, loading the configuration and resources, etc.
|
||||||
*/
|
*/
|
||||||
Application::Application(int argc, char *argv[])
|
App::App(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
assert(m_instance == NULL);
|
||||||
|
m_instance = this;
|
||||||
|
|
||||||
exe_name = argv[0];
|
exe_name = argv[0];
|
||||||
|
|
||||||
/* initialize application hooks */
|
/* initialize application hooks */
|
||||||
@ -153,7 +168,10 @@ Application::Application(int argc, char *argv[])
|
|||||||
/* install 'raster' stuff */
|
/* install 'raster' stuff */
|
||||||
gfxobj_init();
|
gfxobj_init();
|
||||||
|
|
||||||
/* install the modules */
|
// create singletons
|
||||||
|
m_pimpl = new Pimpl;
|
||||||
|
|
||||||
|
// install the modules
|
||||||
modules_init(REQUIRE_INTERFACE);
|
modules_init(REQUIRE_INTERFACE);
|
||||||
|
|
||||||
/* custom default palette? */
|
/* custom default palette? */
|
||||||
@ -179,7 +197,7 @@ Application::Application(int argc, char *argv[])
|
|||||||
* Runs the ASE application. In GUI mode it's the top-level window, in
|
* Runs the ASE application. In GUI mode it's the top-level window, in
|
||||||
* console/scripting it just runs the specified scripts.
|
* console/scripting it just runs the specified scripts.
|
||||||
*/
|
*/
|
||||||
void Application::run()
|
void App::run()
|
||||||
{
|
{
|
||||||
Option *option;
|
Option *option;
|
||||||
JLink link;
|
JLink link;
|
||||||
@ -344,10 +362,9 @@ void Application::run()
|
|||||||
/**
|
/**
|
||||||
* Finishes the ASE application.
|
* Finishes the ASE application.
|
||||||
*/
|
*/
|
||||||
Application::~Application()
|
App::~App()
|
||||||
{
|
{
|
||||||
JLink link;
|
assert(m_instance == this);
|
||||||
int c;
|
|
||||||
|
|
||||||
// remove ase handlers
|
// remove ase handlers
|
||||||
PRINTF("Uninstalling ASE\n");
|
PRINTF("Uninstalling ASE\n");
|
||||||
@ -355,8 +372,9 @@ Application::~Application()
|
|||||||
app_trigger_event(APP_EXIT);
|
app_trigger_event(APP_EXIT);
|
||||||
|
|
||||||
// destroy application hooks
|
// destroy application hooks
|
||||||
for (c=0; c<APP_EVENTS; ++c) {
|
for (int c=0; c<APP_EVENTS; ++c) {
|
||||||
if (apphooks[c] != NULL) {
|
if (apphooks[c] != NULL) {
|
||||||
|
JLink link;
|
||||||
JI_LIST_FOR_EACH(apphooks[c], link) {
|
JI_LIST_FOR_EACH(apphooks[c], link) {
|
||||||
AppHook* apphook = reinterpret_cast<AppHook*>(link->data);
|
AppHook* apphook = reinterpret_cast<AppHook*>(link->data);
|
||||||
delete apphook;
|
delete apphook;
|
||||||
@ -366,9 +384,9 @@ Application::~Application()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* finalize modules, configuration and core */
|
// finalize modules, configuration and core
|
||||||
modules_exit();
|
modules_exit();
|
||||||
UIContext::destroy_instance();
|
delete m_pimpl;
|
||||||
editor_cursor_exit();
|
editor_cursor_exit();
|
||||||
boundary_exit();
|
boundary_exit();
|
||||||
|
|
||||||
@ -377,6 +395,8 @@ Application::~Application()
|
|||||||
file_system_exit();
|
file_system_exit();
|
||||||
core_exit();
|
core_exit();
|
||||||
intl_exit();
|
intl_exit();
|
||||||
|
|
||||||
|
m_instance = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void app_add_hook(int app_event, void (*proc)(void *data), void *data)
|
void app_add_hook(int app_event, void (*proc)(void *data), void *data)
|
||||||
@ -450,15 +470,12 @@ bool app_realloc_recent_list()
|
|||||||
|
|
||||||
/* update the recent file list menu item */
|
/* update the recent file list menu item */
|
||||||
if (list_menuitem) {
|
if (list_menuitem) {
|
||||||
Command *cmd_open_file;
|
|
||||||
JWidget submenu;
|
|
||||||
|
|
||||||
if (jmenuitem_has_submenu_opened(list_menuitem))
|
if (jmenuitem_has_submenu_opened(list_menuitem))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
cmd_open_file = command_get_by_name(CMD_OPEN_FILE);
|
Command *cmd_open_file = CommandsModule::instance()->get_command_by_name(CommandId::open_file);
|
||||||
|
|
||||||
submenu = jmenuitem_get_submenu(list_menuitem);
|
JWidget submenu = jmenuitem_get_submenu(list_menuitem);
|
||||||
if (submenu) {
|
if (submenu) {
|
||||||
jmenuitem_set_submenu(list_menuitem, NULL);
|
jmenuitem_set_submenu(list_menuitem, NULL);
|
||||||
jwidget_free(submenu);
|
jwidget_free(submenu);
|
||||||
@ -469,14 +486,15 @@ bool app_realloc_recent_list()
|
|||||||
|
|
||||||
if (jlist_first(get_recent_files_list())) {
|
if (jlist_first(get_recent_files_list())) {
|
||||||
const char *filename;
|
const char *filename;
|
||||||
|
Params params;
|
||||||
JLink link;
|
JLink link;
|
||||||
|
|
||||||
JI_LIST_FOR_EACH(get_recent_files_list(), link) {
|
JI_LIST_FOR_EACH(get_recent_files_list(), link) {
|
||||||
filename = reinterpret_cast<const char*>(link->data);
|
filename = reinterpret_cast<const char*>(link->data);
|
||||||
|
|
||||||
menuitem = menuitem_new(get_filename(filename),
|
params.set("filename", filename);
|
||||||
cmd_open_file,
|
|
||||||
filename);
|
menuitem = menuitem_new(get_filename(filename), cmd_open_file, ¶ms);
|
||||||
jwidget_add_child(submenu, menuitem);
|
jwidget_add_child(submenu, menuitem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -557,12 +575,15 @@ static void tabsbar_select_callback(JWidget tabs, void *data, int button)
|
|||||||
Sprite* sprite = (Sprite*)data;
|
Sprite* sprite = (Sprite*)data;
|
||||||
|
|
||||||
// put as current sprite
|
// put as current sprite
|
||||||
UIContext* context = UIContext::instance();
|
set_sprite_in_more_reliable_editor(sprite);
|
||||||
context->show_sprite(sprite);
|
|
||||||
|
|
||||||
// middle button: close the sprite
|
// middle-button: close the sprite
|
||||||
if (data && (button & 4))
|
if (data && (button & 4)) {
|
||||||
command_execute(command_get_by_name(CMD_CLOSE_FILE), NULL);
|
Command* close_file_cmd =
|
||||||
|
CommandsModule::instance()->get_command_by_name(CommandId::close_file);
|
||||||
|
|
||||||
|
UIContext::instance()->execute_command(close_file_cmd, NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,12 +30,22 @@ enum {
|
|||||||
|
|
||||||
class Layer;
|
class Layer;
|
||||||
class Sprite;
|
class Sprite;
|
||||||
|
class Params;
|
||||||
|
class Command;
|
||||||
|
class CommandsModule;
|
||||||
|
|
||||||
class Application
|
class App
|
||||||
{
|
{
|
||||||
|
static App* m_instance;
|
||||||
|
|
||||||
|
class Pimpl;
|
||||||
|
Pimpl* m_pimpl;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Application(int argc, char *argv[]);
|
App(int argc, char *argv[]);
|
||||||
~Application();
|
~App();
|
||||||
|
|
||||||
|
static App* instance() { return m_instance; }
|
||||||
|
|
||||||
void run();
|
void run();
|
||||||
};
|
};
|
||||||
|
@ -26,7 +26,9 @@
|
|||||||
#include "jinete/jwindow.h"
|
#include "jinete/jwindow.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/commands.h"
|
||||||
|
#include "commands/params.h"
|
||||||
#include "core/app.h"
|
#include "core/app.h"
|
||||||
|
#include "ui_context.h"
|
||||||
|
|
||||||
#ifdef ALLEGRO_WINDOWS
|
#ifdef ALLEGRO_WINDOWS
|
||||||
#include <winalleg.h>
|
#include <winalleg.h>
|
||||||
@ -74,9 +76,16 @@ void check_for_dropped_files()
|
|||||||
dropped_files->clear();
|
dropped_files->clear();
|
||||||
|
|
||||||
// open all files
|
// open all files
|
||||||
Command* cmd_open_file = command_get_by_name(CMD_OPEN_FILE);
|
|
||||||
for (std::vector<jstring>::iterator it = files.begin(); it != files.end(); ++it)
|
Command* cmd_open_file =
|
||||||
command_execute(cmd_open_file, it->c_str());
|
CommandsModule::instance()->get_command_by_name(CommandId::open_file);
|
||||||
|
Params params;
|
||||||
|
|
||||||
|
for (std::vector<jstring>::iterator
|
||||||
|
it = files.begin(); it != files.end(); ++it) {
|
||||||
|
params.set("filename", it->c_str());
|
||||||
|
UIContext::instance()->execute_command(cmd_open_file, ¶ms);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
jmutex_unlock(dropped_files_mutex);
|
jmutex_unlock(dropped_files_mutex);
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
/* #include "jinete/jintern.h" */
|
/* #include "jinete/jintern.h" */
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/commands.h"
|
||||||
|
#include "commands/command.h"
|
||||||
/* #include "core/app.h" */
|
/* #include "core/app.h" */
|
||||||
/* #include "core/cfg.h" */
|
/* #include "core/cfg.h" */
|
||||||
/* #include "core/core.h" */
|
/* #include "core/core.h" */
|
||||||
@ -36,6 +37,8 @@
|
|||||||
#include "undoable.h"
|
#include "undoable.h"
|
||||||
#include "util/celmove.h"
|
#include "util/celmove.h"
|
||||||
#include "util/thmbnail.h"
|
#include "util/thmbnail.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
#include "ui_context.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Animator Editor
|
Animator Editor
|
||||||
@ -535,8 +538,11 @@ static bool anieditor_msg_proc(JWidget widget, JMessage msg)
|
|||||||
}
|
}
|
||||||
/* show the frame's properties dialog */
|
/* show the frame's properties dialog */
|
||||||
else if (msg->mouse.left) {
|
else if (msg->mouse.left) {
|
||||||
if (anieditor->clk_frame == anieditor->hot_frame)
|
if (anieditor->clk_frame == anieditor->hot_frame) {
|
||||||
command_execute(command_get_by_name(CMD_FRAME_PROPERTIES), NULL);
|
UIContext::instance()
|
||||||
|
->execute_command(CommandsModule::instance()
|
||||||
|
->get_command_by_name(CommandId::frame_properties));
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
const SpriteReader sprite((Sprite*)anieditor->sprite);
|
const SpriteReader sprite((Sprite*)anieditor->sprite);
|
||||||
|
|
||||||
@ -687,14 +693,14 @@ static bool anieditor_msg_proc(JWidget widget, JMessage msg)
|
|||||||
Command *command = get_command_from_key_message(msg);
|
Command *command = get_command_from_key_message(msg);
|
||||||
|
|
||||||
/* close animation editor */
|
/* close animation editor */
|
||||||
if ((command && (strcmp(command->name, CMD_FILM_EDITOR) == 0)) ||
|
if ((command && (strcmp(command->short_name(), CommandId::film_editor) == 0)) ||
|
||||||
(msg->key.scancode == KEY_ESC)) {
|
(msg->key.scancode == KEY_ESC)) {
|
||||||
jwidget_close_window(widget);
|
jwidget_close_window(widget);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* undo */
|
/* undo */
|
||||||
if (command && strcmp(command->name, CMD_UNDO) == 0) {
|
if (command && strcmp(command->short_name(), CommandId::undo) == 0) {
|
||||||
const SpriteReader sprite((Sprite*)anieditor->sprite);
|
const SpriteReader sprite((Sprite*)anieditor->sprite);
|
||||||
if (undo_can_undo(sprite->undo)) {
|
if (undo_can_undo(sprite->undo)) {
|
||||||
SpriteWriter sprite_writer(sprite);
|
SpriteWriter sprite_writer(sprite);
|
||||||
@ -709,7 +715,7 @@ static bool anieditor_msg_proc(JWidget widget, JMessage msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* redo */
|
/* redo */
|
||||||
if (command && strcmp(command->name, CMD_REDO) == 0) {
|
if (command && strcmp(command->short_name(), CommandId::redo) == 0) {
|
||||||
const SpriteReader sprite((Sprite*)anieditor->sprite);
|
const SpriteReader sprite((Sprite*)anieditor->sprite);
|
||||||
if (undo_can_redo(sprite->undo)) {
|
if (undo_can_redo(sprite->undo)) {
|
||||||
SpriteWriter sprite_writer(sprite);
|
SpriteWriter sprite_writer(sprite);
|
||||||
@ -725,25 +731,27 @@ static bool anieditor_msg_proc(JWidget widget, JMessage msg)
|
|||||||
|
|
||||||
/* new_frame, remove_frame, new_cel, remove_cel */
|
/* new_frame, remove_frame, new_cel, remove_cel */
|
||||||
if (command != NULL) {
|
if (command != NULL) {
|
||||||
if (strcmp(command->name, CMD_NEW_FRAME) == 0 ||
|
if (strcmp(command->short_name(), CommandId::new_frame) == 0 ||
|
||||||
strcmp(command->name, CMD_REMOVE_CEL) == 0 ||
|
strcmp(command->short_name(), CommandId::remove_cel) == 0 ||
|
||||||
strcmp(command->name, CMD_REMOVE_FRAME) == 0 ||
|
strcmp(command->short_name(), CommandId::remove_frame) == 0 ||
|
||||||
strcmp(command->name, CMD_GOTO_FIRST_FRAME) == 0 ||
|
strcmp(command->short_name(), CommandId::goto_first_frame) == 0 ||
|
||||||
strcmp(command->name, CMD_GOTO_PREVIOUS_FRAME) == 0 ||
|
strcmp(command->short_name(), CommandId::goto_previous_frame) == 0 ||
|
||||||
strcmp(command->name, CMD_GOTO_PREVIOUS_LAYER) == 0 ||
|
strcmp(command->short_name(), CommandId::goto_previous_layer) == 0 ||
|
||||||
strcmp(command->name, CMD_GOTO_NEXT_FRAME) == 0 ||
|
strcmp(command->short_name(), CommandId::goto_next_frame) == 0 ||
|
||||||
strcmp(command->name, CMD_GOTO_NEXT_LAYER) == 0 ||
|
strcmp(command->short_name(), CommandId::goto_next_layer) == 0 ||
|
||||||
strcmp(command->name, CMD_GOTO_LAST_FRAME) == 0) {
|
strcmp(command->short_name(), CommandId::goto_last_frame) == 0) {
|
||||||
command_execute(command, NULL);
|
// execute the command
|
||||||
|
UIContext::instance()->execute_command(command);
|
||||||
|
|
||||||
anieditor_show_current_cel(widget);
|
anieditor_show_current_cel(widget);
|
||||||
jwidget_dirty(widget);
|
jwidget_dirty(widget);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(command->name, CMD_NEW_LAYER) == 0 ||
|
if (strcmp(command->short_name(), CommandId::new_layer) == 0 ||
|
||||||
strcmp(command->name, CMD_REMOVE_LAYER) == 0) {
|
strcmp(command->short_name(), CommandId::remove_layer) == 0) {
|
||||||
command_execute(command, NULL);
|
// execute the command
|
||||||
|
UIContext::instance()->execute_command(command);
|
||||||
|
|
||||||
anieditor_regenerate_layers(widget);
|
anieditor_regenerate_layers(widget);
|
||||||
anieditor_show_current_cel(widget);
|
anieditor_show_current_cel(widget);
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <allegro.h>
|
#include <allegro.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "ase_exception.h"
|
#include "ase_exception.h"
|
||||||
#include "core/app.h"
|
#include "core/app.h"
|
||||||
@ -55,16 +56,19 @@ int main(int argc, char *argv[])
|
|||||||
Allegro allegro;
|
Allegro allegro;
|
||||||
try {
|
try {
|
||||||
Jinete jinete;
|
Jinete jinete;
|
||||||
Application app(argc, argv);
|
App app(argc, argv);
|
||||||
|
|
||||||
app.run();
|
app.run();
|
||||||
}
|
}
|
||||||
catch (std::exception& e) {
|
catch (std::exception& e) {
|
||||||
allegro_message(e.what());
|
allegro_message(e.what());
|
||||||
}
|
}
|
||||||
|
catch (...) {
|
||||||
|
allegro_message("Uncaught exception");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
// do nothing
|
printf("Uncaught exception");
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -231,7 +231,7 @@ void set_sprite_in_current_editor(Sprite *sprite)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_sprite_in_more_reliable_editor(Sprite *sprite)
|
void set_sprite_in_more_reliable_editor(Sprite* sprite)
|
||||||
{
|
{
|
||||||
JWidget editor, best;
|
JWidget editor, best;
|
||||||
JLink link;
|
JLink link;
|
||||||
|
@ -33,7 +33,9 @@
|
|||||||
#include "jinete/jintern.h"
|
#include "jinete/jintern.h"
|
||||||
|
|
||||||
#include "ui_context.h"
|
#include "ui_context.h"
|
||||||
|
#include "commands/command.h"
|
||||||
#include "commands/commands.h"
|
#include "commands/commands.h"
|
||||||
|
#include "commands/params.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "core/app.h"
|
#include "core/app.h"
|
||||||
#include "core/cfg.h"
|
#include "core/cfg.h"
|
||||||
@ -52,6 +54,7 @@
|
|||||||
#include "util/recscr.h"
|
#include "util/recscr.h"
|
||||||
#include "widgets/editor.h"
|
#include "widgets/editor.h"
|
||||||
#include "widgets/statebar.h"
|
#include "widgets/statebar.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
|
||||||
#define REBUILD_RECENT_LIST 2
|
#define REBUILD_RECENT_LIST 2
|
||||||
#define REFRESH_FULL_SCREEN 4
|
#define REFRESH_FULL_SCREEN 4
|
||||||
@ -93,7 +96,7 @@ struct Shortcut
|
|||||||
Command* command;
|
Command* command;
|
||||||
Tool* tool;
|
Tool* tool;
|
||||||
};
|
};
|
||||||
std::string argument;
|
Params* params;
|
||||||
|
|
||||||
Shortcut(ShortcutType type);
|
Shortcut(ShortcutType type);
|
||||||
~Shortcut();
|
~Shortcut();
|
||||||
@ -103,7 +106,7 @@ struct Shortcut
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static Shortcut* get_keyboard_shortcut_for_command(Command* command, const char* argument);
|
static Shortcut* get_keyboard_shortcut_for_command(const char* command_name, Params* params);
|
||||||
static Shortcut* get_keyboard_shortcut_for_tool(Tool* tool);
|
static Shortcut* get_keyboard_shortcut_for_tool(Tool* tool);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
@ -441,7 +444,7 @@ void gui_feedback()
|
|||||||
if (next_idle_flags & REFRESH_FULL_SCREEN) {
|
if (next_idle_flags & REFRESH_FULL_SCREEN) {
|
||||||
next_idle_flags ^= REFRESH_FULL_SCREEN;
|
next_idle_flags ^= REFRESH_FULL_SCREEN;
|
||||||
|
|
||||||
const CurrentSpriteReader sprite;
|
const CurrentSpriteReader sprite(UIContext::instance());
|
||||||
update_screen_for_sprite(sprite);
|
update_screen_for_sprite(sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -773,14 +776,14 @@ JWidget check_button_new(const char *text, int b1, int b2, int b3, int b4)
|
|||||||
// Keyboard shortcuts
|
// Keyboard shortcuts
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
JAccel add_keyboard_shortcut_to_execute_command(const char* shortcut_string, Command* command, const char* argument)
|
JAccel add_keyboard_shortcut_to_execute_command(const char* shortcut_string, const char* command_name, Params* params)
|
||||||
{
|
{
|
||||||
Shortcut* shortcut = get_keyboard_shortcut_for_command(command, argument);
|
Shortcut* shortcut = get_keyboard_shortcut_for_command(command_name, params);
|
||||||
|
|
||||||
if (!shortcut) {
|
if (!shortcut) {
|
||||||
shortcut = new Shortcut(Shortcut_ExecuteCommand);
|
shortcut = new Shortcut(Shortcut_ExecuteCommand);
|
||||||
shortcut->command = command;
|
shortcut->command = CommandsModule::instance()->get_command_by_name(command_name);
|
||||||
shortcut->argument = argument ? argument: "";
|
shortcut->params = params ? params->clone(): new Params;
|
||||||
|
|
||||||
shortcuts->push_back(shortcut);
|
shortcuts->push_back(shortcut);
|
||||||
}
|
}
|
||||||
@ -811,7 +814,8 @@ Command* get_command_from_key_message(JMessage msg)
|
|||||||
Shortcut* shortcut = *it;
|
Shortcut* shortcut = *it;
|
||||||
|
|
||||||
if (shortcut->type == Shortcut_ExecuteCommand &&
|
if (shortcut->type == Shortcut_ExecuteCommand &&
|
||||||
shortcut->argument.empty() &&
|
// TODO why?
|
||||||
|
// shortcut->argument.empty() &&
|
||||||
shortcut->is_key_pressed(msg)) {
|
shortcut->is_key_pressed(msg)) {
|
||||||
return shortcut->command;
|
return shortcut->command;
|
||||||
}
|
}
|
||||||
@ -819,9 +823,9 @@ Command* get_command_from_key_message(JMessage msg)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
JAccel get_accel_to_execute_command(Command* command, const char* argument)
|
JAccel get_accel_to_execute_command(const char* command_name, Params* params)
|
||||||
{
|
{
|
||||||
Shortcut* shortcut = get_keyboard_shortcut_for_command(command, argument);
|
Shortcut* shortcut = get_keyboard_shortcut_for_command(command_name, params);
|
||||||
if (shortcut)
|
if (shortcut)
|
||||||
return shortcut->accel;
|
return shortcut->accel;
|
||||||
else
|
else
|
||||||
@ -841,10 +845,14 @@ Shortcut::Shortcut(ShortcutType type)
|
|||||||
{
|
{
|
||||||
this->type = type;
|
this->type = type;
|
||||||
this->accel = jaccel_new();
|
this->accel = jaccel_new();
|
||||||
|
this->command = NULL;
|
||||||
|
this->tool = NULL;
|
||||||
|
this->params = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Shortcut::~Shortcut()
|
Shortcut::~Shortcut()
|
||||||
{
|
{
|
||||||
|
delete params;
|
||||||
jaccel_free(accel);
|
jaccel_free(accel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -866,10 +874,11 @@ bool Shortcut::is_key_pressed(JMessage msg)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Shortcut* get_keyboard_shortcut_for_command(Command* command, const char* argument)
|
static Shortcut* get_keyboard_shortcut_for_command(const char* command_name, Params* params)
|
||||||
{
|
{
|
||||||
if (!argument)
|
Command* command = CommandsModule::instance()->get_command_by_name(command_name);
|
||||||
argument = "";
|
if (!command)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
for (std::vector<Shortcut*>::iterator
|
for (std::vector<Shortcut*>::iterator
|
||||||
it = shortcuts->begin(); it != shortcuts->end(); ++it) {
|
it = shortcuts->begin(); it != shortcuts->end(); ++it) {
|
||||||
@ -877,7 +886,8 @@ static Shortcut* get_keyboard_shortcut_for_command(Command* command, const char*
|
|||||||
|
|
||||||
if (shortcut->type == Shortcut_ExecuteCommand &&
|
if (shortcut->type == Shortcut_ExecuteCommand &&
|
||||||
shortcut->command == command &&
|
shortcut->command == command &&
|
||||||
shortcut->argument == argument) {
|
((!params && shortcut->params->empty()) ||
|
||||||
|
(params && *shortcut->params == *params))) {
|
||||||
return shortcut;
|
return shortcut;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1020,11 +1030,9 @@ static bool manager_msg_proc(JWidget widget, JMessage msg)
|
|||||||
Command* command = shortcut->command;
|
Command* command = shortcut->command;
|
||||||
|
|
||||||
// the screen shot is available in everywhere
|
// the screen shot is available in everywhere
|
||||||
if (strcmp(command->name, CMD_SCREEN_SHOT) == 0) {
|
if (strcmp(command->short_name(), CommandId::screen_shot) == 0) {
|
||||||
if (command_is_enabled(command, NULL)) {
|
UIContext::instance()->execute_command(command, shortcut->params);
|
||||||
command_execute(command, shortcut->argument.c_str());
|
return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// all other keys are only available in the main-window
|
// all other keys are only available in the main-window
|
||||||
else {
|
else {
|
||||||
@ -1042,12 +1050,8 @@ static bool manager_msg_proc(JWidget widget, JMessage msg)
|
|||||||
else if (jwindow_is_desktop(child) && child == app_get_top_window()) {
|
else if (jwindow_is_desktop(child) && child == app_get_top_window()) {
|
||||||
/* ok, so we can execute the command represented by the
|
/* ok, so we can execute the command represented by the
|
||||||
pressed-key in the message... */
|
pressed-key in the message... */
|
||||||
if (command_is_enabled(command, shortcut->argument.c_str())) {
|
UIContext::instance()->execute_command(command, shortcut->params);
|
||||||
// if a menu is open, close everything
|
return true;
|
||||||
command_execute(command, shortcut->argument.c_str());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,8 @@
|
|||||||
#include "jinete/jaccel.h"
|
#include "jinete/jaccel.h"
|
||||||
#include "jinete/jwidget.h"
|
#include "jinete/jwidget.h"
|
||||||
|
|
||||||
struct Command;
|
class Command;
|
||||||
|
class Params;
|
||||||
struct Tool;
|
struct Tool;
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
@ -101,11 +102,11 @@ JWidget check_button_new(const char *text, int b1, int b2, int b3, int b4);
|
|||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Keyboard shortcuts
|
// Keyboard shortcuts
|
||||||
|
|
||||||
JAccel add_keyboard_shortcut_to_execute_command(const char* shortcut, Command* command, const char* argument);
|
JAccel add_keyboard_shortcut_to_execute_command(const char* shortcut, const char* command_name, Params* params);
|
||||||
JAccel add_keyboard_shortcut_to_change_tool(const char* shortcut, Tool* tool);
|
JAccel add_keyboard_shortcut_to_change_tool(const char* shortcut, Tool* tool);
|
||||||
|
|
||||||
Command* get_command_from_key_message(JMessage msg);
|
Command* get_command_from_key_message(JMessage msg);
|
||||||
JAccel get_accel_to_execute_command(Command* command, const char* argument);
|
JAccel get_accel_to_execute_command(const char* command, Params* params = NULL);
|
||||||
JAccel get_accel_to_change_tool(Tool* tool);
|
JAccel get_accel_to_change_tool(Tool* tool);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
#include "jinete/jinete.h"
|
#include "jinete/jinete.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/commands.h"
|
||||||
|
#include "commands/command.h"
|
||||||
|
#include "commands/params.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "core/app.h"
|
#include "core/app.h"
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
@ -49,7 +51,7 @@ static int load_root_menu();
|
|||||||
static JWidget load_menu_by_id(JXml xml, const char *id, const char *filename);
|
static JWidget load_menu_by_id(JXml xml, const char *id, const char *filename);
|
||||||
static JWidget convert_xmlelem_to_menu(JXmlElem elem);
|
static JWidget convert_xmlelem_to_menu(JXmlElem elem);
|
||||||
static JWidget convert_xmlelem_to_menuitem(JXmlElem elem);
|
static JWidget convert_xmlelem_to_menuitem(JXmlElem elem);
|
||||||
static void apply_shortcut_to_menuitems_with_command(JWidget menu, Command* command, const char* argument, JAccel accel);
|
static void apply_shortcut_to_menuitems_with_command(JWidget menu, Command* command, Params* params, JAccel accel);
|
||||||
|
|
||||||
int init_module_rootmenu()
|
int init_module_rootmenu()
|
||||||
{
|
{
|
||||||
@ -170,29 +172,40 @@ static int load_root_menu()
|
|||||||
/* finally, we can read the <key /> */
|
/* finally, we can read the <key /> */
|
||||||
const char *command_name = jxmlelem_get_attr((JXmlElem)child2, "command");
|
const char *command_name = jxmlelem_get_attr((JXmlElem)child2, "command");
|
||||||
const char *command_key = jxmlelem_get_attr((JXmlElem)child2, "shortcut");
|
const char *command_key = jxmlelem_get_attr((JXmlElem)child2, "shortcut");
|
||||||
const char *argument = jxmlelem_get_attr((JXmlElem)child2, "argument");
|
|
||||||
|
|
||||||
if (command_name && command_key) {
|
if (command_name && command_key) {
|
||||||
Command *command = command_get_by_name(command_name);
|
Command *command = CommandsModule::instance()->get_command_by_name(command_name);
|
||||||
if (command) {
|
if (command) {
|
||||||
if (!argument)
|
// Read params
|
||||||
argument = "";
|
Params params;
|
||||||
|
{
|
||||||
|
JLink link3;
|
||||||
|
JI_LIST_FOR_EACH(((JXmlElem)child2)->head.children, link3) {
|
||||||
|
JXmlNode child3 = (JXmlNode)link3->data;
|
||||||
|
|
||||||
|
if (child3->type == JI_XML_ELEM &&
|
||||||
|
strcmp(jxmlelem_get_name((JXmlElem)child3), "param") == 0) {
|
||||||
|
const char* param_name = jxmlelem_get_attr((JXmlElem)child3, "name");
|
||||||
|
const char* param_value = jxmlelem_get_attr((JXmlElem)child3, "value");
|
||||||
|
params.set(param_name, param_value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool first_shortcut =
|
bool first_shortcut =
|
||||||
(get_accel_to_execute_command(command, argument) == NULL);
|
(get_accel_to_execute_command(command_name, ¶ms) == NULL);
|
||||||
|
|
||||||
PRINTF("- Shortcut for command `%s' with argument `%s': <%s>\n",
|
PRINTF("- Shortcut for command `%s' <%s>\n", command_name, command_key);
|
||||||
command_name, argument, command_key);
|
|
||||||
|
|
||||||
// add the keyboard shortcut to the command
|
// add the keyboard shortcut to the command
|
||||||
JAccel accel =
|
JAccel accel =
|
||||||
add_keyboard_shortcut_to_execute_command(command_key, command, argument);
|
add_keyboard_shortcut_to_execute_command(command_key, command_name, ¶ms);
|
||||||
|
|
||||||
// add the shortcut to the menuitems with this
|
// add the shortcut to the menuitems with this
|
||||||
// command (this is only visual, the "manager_msg_proc"
|
// command (this is only visual, the "manager_msg_proc"
|
||||||
// is the only one that process keyboard shortcuts)
|
// is the only one that process keyboard shortcuts)
|
||||||
if (first_shortcut)
|
if (first_shortcut)
|
||||||
apply_shortcut_to_menuitems_with_command(root_menu, command, argument, accel);
|
apply_shortcut_to_menuitems_with_command(root_menu, command, ¶ms, accel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -268,6 +281,8 @@ static JWidget load_menu_by_id(JXml xml, const char *id, const char *filename)
|
|||||||
JWidget menu = NULL;
|
JWidget menu = NULL;
|
||||||
JXmlElem elem;
|
JXmlElem elem;
|
||||||
|
|
||||||
|
assert(id != NULL);
|
||||||
|
|
||||||
/* get the <menu> element with the specified id */
|
/* get the <menu> element with the specified id */
|
||||||
elem = jxml_get_elem_by_id(xml, id);
|
elem = jxml_get_elem_by_id(xml, id);
|
||||||
if (elem) {
|
if (elem) {
|
||||||
@ -321,13 +336,32 @@ static JWidget convert_xmlelem_to_menuitem(JXmlElem elem)
|
|||||||
if (strcmp(jxmlelem_get_name(elem), "separator") == 0)
|
if (strcmp(jxmlelem_get_name(elem), "separator") == 0)
|
||||||
return ji_separator_new(NULL, JI_HORIZONTAL);
|
return ji_separator_new(NULL, JI_HORIZONTAL);
|
||||||
|
|
||||||
|
const char* command_name = jxmlelem_get_attr(elem, "command");
|
||||||
|
Command* command =
|
||||||
|
command_name ? CommandsModule::instance()->get_command_by_name(command_name):
|
||||||
|
NULL;
|
||||||
|
|
||||||
|
// load params
|
||||||
|
Params params;
|
||||||
|
if (command) {
|
||||||
|
JLink link3;
|
||||||
|
JI_LIST_FOR_EACH(((JXmlElem)elem)->head.children, link3) {
|
||||||
|
JXmlNode child3 = (JXmlNode)link3->data;
|
||||||
|
|
||||||
|
if (child3->type == JI_XML_ELEM &&
|
||||||
|
strcmp(jxmlelem_get_name((JXmlElem)child3), "param") == 0) {
|
||||||
|
const char* param_name = jxmlelem_get_attr((JXmlElem)child3, "name");
|
||||||
|
const char* param_value = jxmlelem_get_attr((JXmlElem)child3, "value");
|
||||||
|
params.set(param_name, param_value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* create the item */
|
/* create the item */
|
||||||
menuitem = menuitem_new(jxmlelem_get_attr(elem, "name"),
|
menuitem = menuitem_new(jxmlelem_get_attr(elem, "name"),
|
||||||
command_get_by_name(jxmlelem_get_attr(elem,
|
command, command ? ¶ms: NULL);
|
||||||
"command")),
|
|
||||||
jxmlelem_get_attr(elem, "argument"));
|
|
||||||
if (!menuitem)
|
if (!menuitem)
|
||||||
return 0;
|
return NULL;
|
||||||
|
|
||||||
/* has it a ID? */
|
/* has it a ID? */
|
||||||
id = jxmlelem_get_attr(elem, "id");
|
id = jxmlelem_get_attr(elem, "id");
|
||||||
@ -355,7 +389,7 @@ static JWidget convert_xmlelem_to_menuitem(JXmlElem elem)
|
|||||||
return menuitem;
|
return menuitem;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void apply_shortcut_to_menuitems_with_command(JWidget menu, Command *command, const char* argument, JAccel accel)
|
static void apply_shortcut_to_menuitems_with_command(JWidget menu, Command *command, Params* params, JAccel accel)
|
||||||
{
|
{
|
||||||
JList children = jwidget_get_children(menu);
|
JList children = jwidget_get_children(menu);
|
||||||
JWidget menuitem, submenu;
|
JWidget menuitem, submenu;
|
||||||
@ -365,13 +399,20 @@ static void apply_shortcut_to_menuitems_with_command(JWidget menu, Command *comm
|
|||||||
menuitem = (JWidget)link->data;
|
menuitem = (JWidget)link->data;
|
||||||
|
|
||||||
if (jwidget_get_type(menuitem) == JI_MENUITEM) {
|
if (jwidget_get_type(menuitem) == JI_MENUITEM) {
|
||||||
if (menuitem_get_command(menuitem) == command &&
|
Command* mi_command = menuitem_get_command(menuitem);
|
||||||
ustrcmp(menuitem_get_argument(menuitem), argument) == 0)
|
Params* mi_params = menuitem_get_params(menuitem);
|
||||||
|
|
||||||
|
if (mi_command &&
|
||||||
|
ustricmp(mi_command->short_name(), command->short_name()) == 0 &&
|
||||||
|
((mi_params && *mi_params == *params) ||
|
||||||
|
(Params() == *params))) {
|
||||||
|
// Set the accelerator to be shown in this menu-item
|
||||||
jmenuitem_set_accel(menuitem, jaccel_new_copy(accel));
|
jmenuitem_set_accel(menuitem, jaccel_new_copy(accel));
|
||||||
|
}
|
||||||
|
|
||||||
submenu = jmenuitem_get_submenu(menuitem);
|
submenu = jmenuitem_get_submenu(menuitem);
|
||||||
if (submenu)
|
if (submenu)
|
||||||
apply_shortcut_to_menuitems_with_command(submenu, command, argument, accel);
|
apply_shortcut_to_menuitems_with_command(submenu, command, params, accel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,11 +22,9 @@
|
|||||||
#include <list>
|
#include <list>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include "ase_exception.h"
|
#include "ase_exception.h"
|
||||||
#include "ui_context.h"
|
#include "context.h"
|
||||||
#include "raster/sprite.h"
|
#include "raster/sprite.h"
|
||||||
|
|
||||||
class Context;
|
|
||||||
|
|
||||||
class locked_sprite_exception : public ase_exception
|
class locked_sprite_exception : public ase_exception
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -52,24 +50,23 @@ public:
|
|||||||
explicit SpriteWrapper(Sprite* sprite) : m_sprite(sprite) { }
|
explicit SpriteWrapper(Sprite* sprite) : m_sprite(sprite) { }
|
||||||
~SpriteWrapper() { }
|
~SpriteWrapper() { }
|
||||||
|
|
||||||
SpriteWrapper& operator=(const SpriteWrapper& copy) {
|
SpriteWrapper& operator=(const SpriteWrapper& copy)
|
||||||
|
{
|
||||||
m_sprite = copy.m_sprite;
|
m_sprite = copy.m_sprite;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_valid() const {
|
|
||||||
return m_sprite != NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
operator Sprite* () { return m_sprite; }
|
operator Sprite* () { return m_sprite; }
|
||||||
operator const Sprite* () const { return m_sprite; }
|
operator const Sprite* () const { return m_sprite; }
|
||||||
|
|
||||||
Sprite* operator->() {
|
Sprite* operator->()
|
||||||
|
{
|
||||||
assert(m_sprite != NULL);
|
assert(m_sprite != NULL);
|
||||||
return m_sprite;
|
return m_sprite;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Sprite* operator->() const {
|
const Sprite* operator->() const
|
||||||
|
{
|
||||||
assert(m_sprite != NULL);
|
assert(m_sprite != NULL);
|
||||||
return m_sprite;
|
return m_sprite;
|
||||||
}
|
}
|
||||||
@ -116,7 +113,8 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
~SpriteReader() {
|
~SpriteReader()
|
||||||
|
{
|
||||||
// unlock the sprite
|
// unlock the sprite
|
||||||
if (m_sprite)
|
if (m_sprite)
|
||||||
m_sprite->unlock();
|
m_sprite->unlock();
|
||||||
@ -170,7 +168,8 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
~SpriteWriter() {
|
~SpriteWriter()
|
||||||
|
{
|
||||||
unlock_writer();
|
unlock_writer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,12 +210,13 @@ class CurrentSpriteReader : public SpriteReader
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
CurrentSpriteReader(Context* context = UIContext::instance())
|
CurrentSpriteReader(Context* context)
|
||||||
: SpriteReader(context->get_current_sprite())
|
: SpriteReader(context->get_current_sprite())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
~CurrentSpriteReader() {
|
~CurrentSpriteReader()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -227,13 +227,14 @@ class CurrentSpriteWriter : public SpriteWriter
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
CurrentSpriteWriter(Context* context = UIContext::instance())
|
CurrentSpriteWriter(Context* context)
|
||||||
: SpriteWriter(context->get_current_sprite())
|
: SpriteWriter(context->get_current_sprite())
|
||||||
, m_context(context)
|
, m_context(context)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
~CurrentSpriteWriter() {
|
~CurrentSpriteWriter()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void destroy()
|
void destroy()
|
||||||
|
@ -27,37 +27,28 @@
|
|||||||
#include "raster/sprite.h"
|
#include "raster/sprite.h"
|
||||||
#include "widgets/tabs.h"
|
#include "widgets/tabs.h"
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
UIContext* UIContext::m_instance = NULL;
|
||||||
// UIContext singleton
|
|
||||||
|
|
||||||
static UIContext* g_instance = NULL;
|
|
||||||
|
|
||||||
UIContext* UIContext::instance()
|
|
||||||
{
|
|
||||||
if (!g_instance)
|
|
||||||
g_instance = new UIContext;
|
|
||||||
return g_instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UIContext::destroy_instance()
|
|
||||||
{
|
|
||||||
delete g_instance;
|
|
||||||
g_instance = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
UIContext::UIContext()
|
UIContext::UIContext()
|
||||||
{
|
{
|
||||||
|
assert(m_instance == NULL);
|
||||||
|
m_instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
UIContext::~UIContext()
|
UIContext::~UIContext()
|
||||||
{
|
{
|
||||||
|
assert(m_instance == this);
|
||||||
|
m_instance = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UIContext::show_sprite(Sprite* sprite) const
|
int UIContext::get_fg_color()
|
||||||
{
|
{
|
||||||
set_sprite_in_more_reliable_editor(sprite);
|
return app_get_fg_color(get_current_sprite());
|
||||||
|
}
|
||||||
|
|
||||||
|
int UIContext::get_bg_color()
|
||||||
|
{
|
||||||
|
return app_get_bg_color(get_current_sprite());
|
||||||
}
|
}
|
||||||
|
|
||||||
void UIContext::on_add_sprite(Sprite* sprite)
|
void UIContext::on_add_sprite(Sprite* sprite)
|
||||||
|
@ -23,17 +23,18 @@
|
|||||||
|
|
||||||
class UIContext : public Context
|
class UIContext : public Context
|
||||||
{
|
{
|
||||||
public:
|
static UIContext* m_instance;
|
||||||
|
|
||||||
static UIContext* instance();
|
public:
|
||||||
static void destroy_instance();
|
static UIContext* instance() { return m_instance; }
|
||||||
|
|
||||||
UIContext();
|
UIContext();
|
||||||
virtual ~UIContext();
|
virtual ~UIContext();
|
||||||
|
|
||||||
virtual bool is_ui_available() const { return true; }
|
virtual bool is_ui_available() const { return true; }
|
||||||
|
|
||||||
void show_sprite(Sprite* sprite) const;
|
virtual int get_fg_color();
|
||||||
|
virtual int get_bg_color();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#define UNDOABLE_H_INCLUDED
|
#define UNDOABLE_H_INCLUDED
|
||||||
|
|
||||||
class Cel;
|
class Cel;
|
||||||
|
class Mask;
|
||||||
class Layer;
|
class Layer;
|
||||||
class Sprite;
|
class Sprite;
|
||||||
class SpriteWriter;
|
class SpriteWriter;
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user