mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-16 14:42:44 +00:00
Added sprite_properties command.
This commit is contained in:
parent
122217c227
commit
c1879f7c07
@ -1,5 +1,11 @@
|
||||
2007-09-30 David A. Capello <dacap@users.sourceforge.net>
|
||||
|
||||
* src/commands/cmd_sprite_properties.c (command_execute_sprite_properties): Done.
|
||||
|
||||
* src/dialogs/dfrlen.c: Removed (all in cmd_sprite_properties).
|
||||
|
||||
* data/scripts/sprprop.lua: Removed.
|
||||
|
||||
* data/scripts/edit.lua: Removed.
|
||||
|
||||
* src/commands/cmd_refresh.c (command_execute_refresh): Added.
|
||||
|
@ -1,70 +0,0 @@
|
||||
-- ase -- allegro-sprite-editor: the ultimate sprites factory
|
||||
-- Copyright (C) 2001-2005, 2007 by David A. Capello
|
||||
|
||||
function GUI_SpriteProperties()
|
||||
-- get current sprite
|
||||
local sprite = current_sprite
|
||||
if not sprite then return end
|
||||
|
||||
-- load the window widget
|
||||
local window = ji_load_widget("sprprop.jid", "sprite_properties")
|
||||
if not window then return end
|
||||
|
||||
-- update widgets values
|
||||
do
|
||||
local imgtype_text
|
||||
|
||||
if sprite.imgtype == IMAGE_RGB then
|
||||
imgtype_text = "RGB"
|
||||
elseif sprite.imgtype == IMAGE_GRAYSCALE then
|
||||
imgtype_text = "Grayscale"
|
||||
elseif sprite.imgtype == IMAGE_INDEXED then
|
||||
imgtype_text = "Indexed"
|
||||
else
|
||||
imgtype_text = "Unknown"
|
||||
end
|
||||
|
||||
jwidget_set_text(jwidget_find_name(window, "name"), sprite.filename)
|
||||
jwidget_set_text(jwidget_find_name(window, "type"), imgtype_text)
|
||||
jwidget_set_text(jwidget_find_name(window, "size"),
|
||||
sprite.w .. "x" .. sprite.h)
|
||||
jwidget_set_text(jwidget_find_name(window, "frames"),
|
||||
tostring(sprite.frames))
|
||||
end
|
||||
|
||||
jwindow_remap(window)
|
||||
jwindow_center(window)
|
||||
|
||||
while true do
|
||||
load_window_pos(window, "SpriteProperties")
|
||||
jwindow_open_fg(window)
|
||||
save_window_pos(window, "SpriteProperties")
|
||||
|
||||
local killer = jwindow_get_killer(window)
|
||||
|
||||
if killer == jwidget_find_name(window, "ok") then
|
||||
local filename = jwidget_get_text(jwidget_find_name(window, "name"))
|
||||
local frames = tonumber(jwidget_get_text(jwidget_find_name(window, "frames")))
|
||||
|
||||
frames = MID(1, frames, 9999)
|
||||
|
||||
-- does filename change?
|
||||
if filename != sprite.filename then
|
||||
sprite_set_filename(sprite, filename)
|
||||
rebuild_sprite_list()
|
||||
end
|
||||
|
||||
sprite_set_frames(sprite, frames)
|
||||
|
||||
-- update sprite in editors
|
||||
GUI_Refresh(sprite)
|
||||
break
|
||||
elseif killer == jwidget_find_name(window, "speed") then
|
||||
dialogs_frame_length(-1)
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
jwidget_free(window)
|
||||
end
|
@ -83,7 +83,6 @@ ASE_SOURCES = \
|
||||
src/core/modules.c \
|
||||
src/dialogs/canvasze.c \
|
||||
src/dialogs/colsel.c \
|
||||
src/dialogs/dfrlen.c \
|
||||
src/dialogs/dmapgen.c \
|
||||
src/dialogs/dpaledit.c \
|
||||
src/dialogs/drawtext.c \
|
||||
|
@ -20,14 +20,149 @@
|
||||
|
||||
#ifndef USE_PRECOMPILED_HEADER
|
||||
|
||||
#include <allegro/unicode.h>
|
||||
|
||||
#include "jinete.h"
|
||||
|
||||
#include "core/app.h"
|
||||
/* #include "core/app.h" */
|
||||
#include "modules/gui.h"
|
||||
#include "modules/sprites.h"
|
||||
#include "raster/image.h"
|
||||
#include "raster/sprite.h"
|
||||
|
||||
#endif
|
||||
|
||||
/* TODO remove this */
|
||||
void dialogs_frame_length(int sprite_frpos);
|
||||
|
||||
bool command_enabled_sprite_properties(const char *argument)
|
||||
{
|
||||
return current_sprite != NULL;
|
||||
}
|
||||
|
||||
void command_execute_sprite_properties(const char *argument)
|
||||
{
|
||||
JWidget window, killer, name, type, size, frames, speed, ok;
|
||||
Sprite *sprite = current_sprite;
|
||||
char *imgtype_text;
|
||||
char buf[256];
|
||||
|
||||
/* load the window widget */
|
||||
window = load_widget("sprprop.jid", "sprite_properties");
|
||||
if (!window)
|
||||
return;
|
||||
|
||||
if (!get_widgets(window,
|
||||
"name", &name,
|
||||
"type", &type,
|
||||
"size", &size,
|
||||
"frames", &frames,
|
||||
"speed", &speed,
|
||||
"ok", &ok, NULL)) {
|
||||
jwidget_free(window);
|
||||
return;
|
||||
}
|
||||
|
||||
/* update widgets values */
|
||||
switch (sprite->imgtype) {
|
||||
case IMAGE_RGB:
|
||||
imgtype_text = "RGB";
|
||||
break;
|
||||
case IMAGE_GRAYSCALE:
|
||||
imgtype_text = "Grayscale";
|
||||
break;
|
||||
case IMAGE_INDEXED:
|
||||
imgtype_text = "Indexed";
|
||||
break;
|
||||
default:
|
||||
imgtype_text = "Unknown";
|
||||
break;
|
||||
}
|
||||
|
||||
jwidget_set_text(name, sprite->filename);
|
||||
jwidget_set_text(type, imgtype_text);
|
||||
usprintf(buf, "%dx%d", sprite->w, sprite->h);
|
||||
jwidget_set_text(size, buf);
|
||||
usprintf(buf, "%d", sprite->frames);
|
||||
jwidget_set_text(frames, buf);
|
||||
|
||||
jwindow_remap(window);
|
||||
jwindow_center(window);
|
||||
|
||||
for (;;) {
|
||||
load_window_pos(window, "SpriteProperties");
|
||||
jwindow_open_fg(window);
|
||||
save_window_pos(window, "SpriteProperties");
|
||||
|
||||
killer = jwindow_get_killer(window);
|
||||
if (killer == ok) {
|
||||
const char *filename = jwidget_get_text(name);
|
||||
int nframes = ustrtol(jwidget_get_text(frames), NULL, 10);
|
||||
|
||||
nframes = MID(1, nframes, 9999);
|
||||
|
||||
/* does filename change? */
|
||||
if (filename != sprite->filename) {
|
||||
sprite_set_filename(sprite, filename);
|
||||
rebuild_sprite_list();
|
||||
}
|
||||
|
||||
sprite_set_frames(sprite, nframes);
|
||||
|
||||
/* update sprite in editors */
|
||||
GUI_Refresh(sprite);
|
||||
break;
|
||||
}
|
||||
else if (killer == speed) {
|
||||
dialogs_frame_length(-1);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
jwidget_free(window);
|
||||
}
|
||||
|
||||
/* if sprite_frpos < 0, set the frame length of all frames */
|
||||
void dialogs_frame_length(int sprite_frpos)
|
||||
{
|
||||
JWidget window, frpos, frlen, ok;
|
||||
char buf[64];
|
||||
|
||||
window = load_widget("frlen.jid", "frame_duration");
|
||||
if (!window)
|
||||
return;
|
||||
|
||||
if (!get_widgets(window,
|
||||
"frpos", &frpos,
|
||||
"frlen", &frlen,
|
||||
"ok", &ok, NULL)) {
|
||||
jwidget_free(window);
|
||||
return;
|
||||
}
|
||||
|
||||
if (sprite_frpos < 0)
|
||||
strcpy(buf, "All");
|
||||
else
|
||||
sprintf(buf, "%d", sprite_frpos);
|
||||
jwidget_set_text(frpos, buf);
|
||||
|
||||
sprintf(buf, "%d", sprite_get_frlen(current_sprite, current_sprite->frpos));
|
||||
jwidget_set_text(frlen, buf);
|
||||
|
||||
jwindow_open_fg(window);
|
||||
if (jwindow_get_killer(window) == ok) {
|
||||
int num = strtol(jwidget_get_text(frlen), NULL, 10);
|
||||
|
||||
if (sprite_frpos < 0) {
|
||||
if (jalert("Warning"
|
||||
"<<Do you want change the frame-rate of all frames?"
|
||||
"<<(this operation can\'t be undoed)"
|
||||
"||&Yes||&No") == 1)
|
||||
sprite_set_speed(current_sprite, num);
|
||||
}
|
||||
else
|
||||
sprite_set_frlen(current_sprite, num, sprite_frpos);
|
||||
}
|
||||
jwidget_free(window);
|
||||
}
|
||||
|
@ -81,6 +81,7 @@ void command_execute_preview_fit_to_screen(const char *argument);
|
||||
void command_execute_preview_normal(const char *argument);
|
||||
void command_execute_preview_tiled(const char *argument);
|
||||
/* sprite */
|
||||
bool command_enabled_sprite_properties(const char *argument);
|
||||
void command_execute_sprite_properties(const char *argument);
|
||||
void command_execute_duplicate_sprite(const char *argument);
|
||||
void command_execute_change_image_type(const char *argument);
|
||||
@ -194,7 +195,7 @@ static Command commands[] = {
|
||||
CMD_EXE_ENA2(preview_tiled, preview),
|
||||
CMD_EXE_ENA2(preview_normal, preview),
|
||||
CMD_EXE_ENA2(preview_fit_to_screen, preview),
|
||||
{ CMD_SPRITE_PROPERTIES, NULL, NULL, NULL, NULL },
|
||||
CMD_EXE_ENA(sprite_properties),
|
||||
{ CMD_DUPLICATE_SPRITE, NULL, NULL, NULL, NULL },
|
||||
{ CMD_CHANGE_IMAGE_TYPE, NULL, NULL, NULL, NULL },
|
||||
{ CMD_CROP_SPRITE, NULL, NULL, NULL, NULL },
|
||||
|
@ -1,82 +0,0 @@
|
||||
/* ase -- allegro-sprite-editor: the ultimate sprites factory
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifndef USE_PRECOMPILED_HEADER
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "jinete/alert.h"
|
||||
#include "jinete/widget.h"
|
||||
#include "jinete/window.h"
|
||||
|
||||
#include "core/core.h"
|
||||
#include "modules/gui.h"
|
||||
#include "modules/sprites.h"
|
||||
#include "raster/sprite.h"
|
||||
|
||||
#endif
|
||||
|
||||
/* if sprite_frpos < 0, set the frame length of all frames */
|
||||
void dialogs_frame_length(int sprite_frpos)
|
||||
{
|
||||
JWidget window, frpos, frlen, ok;
|
||||
char buf[64];
|
||||
|
||||
if (!is_interactive() || !current_sprite)
|
||||
return;
|
||||
|
||||
window = load_widget ("frlen.jid", "frame_duration");
|
||||
if (!window)
|
||||
return;
|
||||
|
||||
if (!get_widgets(window,
|
||||
"frpos", &frpos,
|
||||
"frlen", &frlen,
|
||||
"ok", &ok, NULL)) {
|
||||
jwidget_free(window);
|
||||
return;
|
||||
}
|
||||
|
||||
if (sprite_frpos < 0)
|
||||
strcpy(buf, "All");
|
||||
else
|
||||
sprintf(buf, "%d", sprite_frpos);
|
||||
jwidget_set_text(frpos, buf);
|
||||
|
||||
sprintf(buf, "%d", sprite_get_frlen(current_sprite, current_sprite->frpos));
|
||||
jwidget_set_text(frlen, buf);
|
||||
|
||||
jwindow_open_fg(window);
|
||||
if (jwindow_get_killer(window) == ok) {
|
||||
int num = strtol(jwidget_get_text(frlen), NULL, 10);
|
||||
|
||||
if (sprite_frpos < 0) {
|
||||
if (jalert("Warning"
|
||||
"<<Do you want change the frame-rate of all frames?"
|
||||
"<<(this operation can\'t be undoed)"
|
||||
"||&Yes||&No") == 1)
|
||||
sprite_set_speed(current_sprite, num);
|
||||
}
|
||||
else
|
||||
sprite_set_frlen(current_sprite, num, sprite_frpos);
|
||||
}
|
||||
jwidget_free(window);
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
/* ase -- allegro-sprite-editor: the ultimate sprites factory
|
||||
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef DIALOGS_DFRLEN_H
|
||||
#define DIALOGS_DFRLEN_H
|
||||
|
||||
void dialogs_frame_length(int frpos);
|
||||
|
||||
#endif /* DIALOGS_DFRLEN_H */
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include "core/app.h"
|
||||
#include "core/cfg.h"
|
||||
#include "core/core.h"
|
||||
#include "dialogs/dfrlen.h"
|
||||
#include "modules/gfx.h"
|
||||
#include "modules/gui.h"
|
||||
#include "modules/palette.h"
|
||||
@ -638,6 +637,7 @@ static bool frame_box_msg_proc (JWidget widget, JMessage msg)
|
||||
/* show the dialog to change the frlen (frame duration time)? */
|
||||
if (msg->mouse.y < FRMSIZE) {
|
||||
jwidget_release_mouse (widget);
|
||||
/* TODO remove this, make a better UI */
|
||||
dialogs_frame_length(current_sprite->frpos);
|
||||
jwidget_dirty(widget);
|
||||
return TRUE;
|
||||
|
@ -717,7 +717,6 @@ static int bind_jwidget_hook_signal (lua_State *L)
|
||||
#ifndef USE_PRECOMPILED_HEADER
|
||||
|
||||
#include "dialogs/canvasze.h"
|
||||
#include "dialogs/dfrlen.h"
|
||||
#include "dialogs/dmapgen.h"
|
||||
#include "dialogs/drawtext.h"
|
||||
#include "dialogs/effect.h"
|
||||
|
@ -290,7 +290,6 @@ void dialogs_color_curve(void);
|
||||
void dialogs_convolution_matrix(void);
|
||||
void dialogs_draw_text(void);
|
||||
void switch_between_film_and_sprite_editor(void);
|
||||
void dialogs_frame_length (int frpos);
|
||||
void dialogs_invert_color(void);
|
||||
void dialogs_mapgen(void);
|
||||
void dialogs_mask_color(void);
|
||||
|
Loading…
x
Reference in New Issue
Block a user