Added "save_file_as" and "options" commands.

Added some dirty tricks to handle the mouse capture in Windows.
This commit is contained in:
David Capello 2007-09-27 20:13:06 +00:00
parent f7657bb2dd
commit a198e43b7e
12 changed files with 159 additions and 87 deletions

View File

@ -1,5 +1,12 @@
2007-09-27 David A. Capello <dacap@users.sourceforge.net> 2007-09-27 David A. Capello <dacap@users.sourceforge.net>
* jinete/src/jsystem.c (jmouse_poll): Now (in Windows) we continue
getting mouse feedback even when the cursor is outside of the
window.
* src/commands/cmd_close_file.c (command_execute_close_all_files):
Fixed.
* src/commands/cmd_drawing_tools.c: Added. All change of * src/commands/cmd_drawing_tools.c: Added. All change of
drawing-tool is in this file. drawing-tool is in this file.
@ -16,6 +23,10 @@
2007-09-26 David A. Capello <dacap@users.sourceforge.net> 2007-09-26 David A. Capello <dacap@users.sourceforge.net>
* jinete/src/jwidget.c (jwidget_hard_capture_mouse): Added usage
of SetCapture() (in Windows, to really capture the mouse in OS
level).
* src/commands/cmd_preview.c: Added. * src/commands/cmd_preview.c: Added.
* src/dialogs/viewspr.c: Removed. * src/dialogs/viewspr.c: Removed.

View File

@ -2,17 +2,18 @@
NEWS NEWS
=================================== ===================================
0.6 0.9
--- ---
+ New XML format for the menus. Restructured all the menus (more user + Restructured all the menus (more user friendly options).
friendly?) + New XML format for the menus.
+ Added menu customization through UI (Tools/Customize).
- Removed menu scripting customization. - Removed menu scripting customization.
- Removed screen saver. - Removed screen saver.
+ GUI enhanced: more borders for windows, and more spacing between + GUI enhanced:
widgets. + more borders for windows and more spacing between widgets.
+ better mouse behavior (in Windows).
+ Added support for PNG files (through libpng). + Added support for PNG files (through libpng).
+ Finished the support for ICO files.
+ Finally screen scaling supported (with double-buffering). This means + Finally screen scaling supported (with double-buffering). This means
that you can use a screen of 320x240 between a window of 640x480 that you can use a screen of 320x240 between a window of 640x480
(screen-scaling x2). This is the new default video mode for ASE. (screen-scaling x2). This is the new default video mode for ASE.

View File

@ -44,6 +44,7 @@ High priority work
Wish-list Wish-list
--------- ---------
- Add menu customization through UI (Tools/Customize).
- Mateusz Czaplinski ideas: - Mateusz Czaplinski ideas:
+ when move selections, will be good the possibility to see relative + when move selections, will be good the possibility to see relative
position from the starting point of movement; position from the starting point of movement;

View File

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

View File

@ -1,50 +0,0 @@
-- ase -- allegro-sprite-editor: the ultimate sprites factory
-- Copyright (C) 2001-2005 by David A. Capello
function GUI_SaveSprite()
if not current_sprite then
return
end
local filename = current_sprite.filename
local ret
while true do
filename = ji_file_select(_("Save Sprite"), filename,
get_writeable_extensions())
if not filename then
return
end
-- does the file exist?
if file_exists(filename) then
-- ask if the user wants overwrite the file?
ret = jalert(_("Warning")..
"<<".._("File exists, overwrite it?")..
"<<"..get_filename(filename)..
"||".._("&Yes||&No||&Cancel"))
else
break
end
-- "yes": we must continue with the operation...
if ret == 1 then
break
-- "cancel" or <esc> per example: we back doing nothing
elseif ret != 2 then
return
end
-- "no": we must back to select other file-name */
end
sprite_set_filename(current_sprite, filename)
rebuild_sprite_list()
if sprite_save(current_sprite) == 0 then
recent_file(filename)
sprite_was_saved(current_sprite)
else
unrecent_file(filename)
print(_("Error saving sprite file: ")..current_sprite.filename)
end
end

View File

@ -30,6 +30,9 @@
*/ */
#include <allegro.h> #include <allegro.h>
#ifdef ALLEGRO_WINDOWS
#include <winalleg.h>
#endif
#include "jinete/intern.h" #include "jinete/intern.h"
#include "jinete/manager.h" #include "jinete/manager.h"
@ -78,6 +81,7 @@ static volatile int click_mouse_b = 0;
static void set_cursor(BITMAP *bmp, int x, int y); static void set_cursor(BITMAP *bmp, int x, int y);
static void clock_inc(void); static void clock_inc(void);
static void check_click(void); static void check_click(void);
static void update_mouse_position(void);
static void clock_inc(void) static void clock_inc(void)
{ {
@ -297,8 +301,11 @@ bool jmouse_is_shown()
return mouse_scares == 0; return mouse_scares == 0;
} }
/* Returns TRUE if the mouse moved. */ /**
* Updates the mouse information (position, wheel and buttons).
*
* @return Returns TRUE if the mouse moved.
*/
bool jmouse_poll(void) bool jmouse_poll(void)
{ {
m_b[1] = m_b[0]; m_b[1] = m_b[0];
@ -311,25 +318,11 @@ bool jmouse_poll(void)
m_b[0] = mouse_b; m_b[0] = mouse_b;
m_z[0] = mouse_z; m_z[0] = mouse_z;
if (ji_screen == screen) { update_mouse_position();
m_x[0] = mouse_x;
m_y[0] = mouse_y;
}
else {
m_x[0] = JI_SCREEN_W * mouse_x / SCREEN_W;
m_y[0] = JI_SCREEN_H * mouse_y / SCREEN_H;
}
if ((m_x[0] != m_x[1]) || (m_y[0] != m_y[1])) { if ((m_x[0] != m_x[1]) || (m_y[0] != m_y[1])) {
poll_mouse(); poll_mouse();
if (ji_screen == screen) { update_mouse_position();
m_x[0] = mouse_x;
m_y[0] = mouse_y;
}
else {
m_x[0] = JI_SCREEN_W * mouse_x / SCREEN_W;
m_y[0] = JI_SCREEN_H * mouse_y / SCREEN_H;
}
moved = TRUE; moved = TRUE;
} }
@ -409,3 +402,55 @@ void jmouse_set_click_level(int level)
click_mouse_b = m_b[0]; click_mouse_b = m_b[0];
} }
} }
static void update_mouse_position(void)
{
if (ji_screen == screen) {
m_x[0] = mouse_x;
m_y[0] = mouse_y;
}
else {
m_x[0] = JI_SCREEN_W * mouse_x / SCREEN_W;
m_y[0] = JI_SCREEN_H * mouse_y / SCREEN_H;
}
#ifdef ALLEGRO_WINDOWS
/* this help us (in windows) to get mouse feedback when we capture
the mouse but we are outside the Allegro window */
{
POINT pt;
RECT rc;
if (GetCursorPos(&pt) && GetClientRect(win_get_window(), &rc)) {
MapWindowPoints(win_get_window(), NULL, (POINT *)&rc, 2);
if (!PtInRect(&rc, pt)) {
/* if the mouse is free we can hide the cursor putting the
mouse outside the screen (right-bottom corder) */
if (!jmanager_get_capture()) {
m_x[0] = JI_SCREEN_W+focus_x;
m_y[0] = JI_SCREEN_H+focus_y;
}
/* if the mouse is captured we can put it in the edges of the screen */
else {
pt.x -= rc.left;
pt.y -= rc.top;
if (ji_screen == screen) {
m_x[0] = pt.x;
m_y[0] = pt.y;
}
else {
m_x[0] = JI_SCREEN_W * pt.x / SCREEN_W;
m_y[0] = JI_SCREEN_H * pt.y / SCREEN_H;
}
m_x[0] = MID(0, m_x[0], JI_SCREEN_W-1);
m_y[0] = MID(0, m_y[0], JI_SCREEN_H-1);
}
}
}
}
#endif
}

View File

@ -1,7 +1,7 @@
#! /bin/sh #! /bin/sh
dir="`pwd`" dir="`pwd`"
version=0.6 version=0.9
distdir=ase-$version distdir=ase-$version
freetype_files="jinete/freetype/ChangeLog \ freetype_files="jinete/freetype/ChangeLog \
@ -177,7 +177,7 @@ exit
###################################################################### ######################################################################
# Files for binary distributions # Files for binary distributions
function def_common_files () function def_common_files()
{ {
txt_files=" \ txt_files=" \
$1/*.txt \ $1/*.txt \

View File

@ -57,7 +57,11 @@ bool command_enabled_close_all_files(const char *argument)
void command_execute_close_all_files(const char *argument) void command_execute_close_all_files(const char *argument)
{ {
while (close_current_sprite()) if (!current_sprite)
sprite_show(get_first_sprite());
while (current_sprite != NULL &&
close_current_sprite())
; ;
} }

View File

@ -30,4 +30,5 @@
void command_execute_customize(const char *argument) void command_execute_customize(const char *argument)
{ {
jalert("Customize<<This functionality will be available in ASE 1.0||&OK");
} }

View File

@ -20,14 +20,13 @@
#ifndef USE_PRECOMPILED_HEADER #ifndef USE_PRECOMPILED_HEADER
#include "jinete.h" #include "jinete/base.h"
#include "core/app.h" #include "dialogs/options.h"
#include "modules/sprites.h"
#include "raster/sprite.h"
#endif #endif
void command_execute_options(const char *argument) void command_execute_options(const char *argument)
{ {
dialogs_options();
} }

View File

@ -20,14 +20,73 @@
#ifndef USE_PRECOMPILED_HEADER #ifndef USE_PRECOMPILED_HEADER
#include "jinete.h" #include <allegro.h>
#include "core/app.h" #include "jinete/alert.h"
#include "console/console.h"
/* #include "core/app.h" */
#include "dialogs/filesel.h"
#include "file/file.h"
#include "modules/recent.h"
#include "modules/gui.h"
#include "modules/sprites.h" #include "modules/sprites.h"
#include "raster/sprite.h" #include "raster/sprite.h"
#endif #endif
bool command_enabled_save_file_as(const char *argument)
{
return current_sprite != NULL;
}
void command_execute_save_file_as(const char *argument) void command_execute_save_file_as(const char *argument)
{ {
char filename[4096];
char *newfilename;
int ret;
ustrcpy(filename, current_sprite->filename);
for (;;) {
newfilename = GUI_FileSelect(_("Save Sprite"), filename,
get_writeable_extensions());
if (!newfilename)
return;
ustrcpy(filename, newfilename);
jfree(newfilename);
/* does the file exist? */
if (exists(filename)) {
/* ask if the user wants overwrite the file? */
ret = jalert("%s<<%s<<%s||%s||%s||%s",
_("Warning"),
_("File exists, overwrite it?"),
get_filename(filename),
_("&Yes"), _("&No"), _("&Cancel"));
}
else
break;
/* "yes": we must continue with the operation... */
if (ret == 1)
break;
/* "cancel" or <esc> per example: we back doing nothing */
else if (ret != 2)
return;
/* "no": we must back to select other file-name */
}
sprite_set_filename(current_sprite, filename);
rebuild_sprite_list();
if (sprite_save(current_sprite) == 0) {
recent_file(filename);
sprite_was_saved(current_sprite);
}
else {
unrecent_file(filename);
console_printf("%s: %s", _("Error saving sprite file"), filename);
}
} }

View File

@ -114,6 +114,7 @@ void command_execute_replace_color(const char *argument);
void command_execute_reselect_mask(const char *argument); void command_execute_reselect_mask(const char *argument);
void command_execute_run_script(const char *argument); void command_execute_run_script(const char *argument);
void command_execute_save_file(const char *argument); void command_execute_save_file(const char *argument);
bool command_enabled_save_file_as(const char *argument);
void command_execute_save_file_as(const char *argument); void command_execute_save_file_as(const char *argument);
void command_execute_save_mask(const char *argument); void command_execute_save_mask(const char *argument);
void command_execute_save_session(const char *argument); void command_execute_save_session(const char *argument);
@ -132,7 +133,7 @@ static Command commands[] = {
CMD0(new_file), CMD0(new_file),
CMD0(open_file), CMD0(open_file),
{ CMD_SAVE_FILE, NULL, NULL, NULL, NULL }, { CMD_SAVE_FILE, NULL, NULL, NULL, NULL },
{ CMD_SAVE_FILE_AS, NULL, NULL, NULL, NULL }, CMD1(save_file_as),
CMD1(close_file), CMD1(close_file),
CMD1(close_all_files), CMD1(close_all_files),
{ CMD_SCREEN_SHOT, NULL, NULL, NULL, NULL }, { CMD_SCREEN_SHOT, NULL, NULL, NULL, NULL },
@ -211,8 +212,8 @@ static Command commands[] = {
{ CMD_MAPGEN, NULL, NULL, NULL, NULL }, { CMD_MAPGEN, NULL, NULL, NULL, NULL },
{ CMD_RUN_SCRIPT, NULL, NULL, NULL, NULL }, { CMD_RUN_SCRIPT, NULL, NULL, NULL, NULL },
CMD0(tips), CMD0(tips),
{ CMD_CUSTOMIZE, NULL, NULL, NULL, NULL }, CMD0(customize),
{ CMD_OPTIONS, NULL, NULL, NULL, NULL }, CMD0(options),
CMD3(select_file), CMD3(select_file),
{ NULL, NULL, NULL, NULL, NULL } { NULL, NULL, NULL, NULL, NULL }