Tilemap effect: Added a menu to set options. Options saved and reloaded in .INI. Added support for shortcuts (but no helpfile so far, so you can't set them)

git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1870 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Yves Rizoud 2011-11-13 23:21:59 +00:00
parent d60a4441d1
commit 496148d485
12 changed files with 168 additions and 32 deletions

View File

@ -4538,7 +4538,7 @@ void Button_Effects(void)
Window_set_normal_button( 83,131,104,14,"Feedback: ",1,1,SDLK_f); // 13
Window_set_normal_button(177, 19, 16,16,"",0,1,Config_Key[SPECIAL_FORMAT_CHECKER_MENU][0]); // 14
Window_set_normal_button(177, 38, 16,16,"",0,1,KEY_NONE); // 15
Window_set_normal_button(177, 38, 16,16,"",0,1,Config_Key[SPECIAL_TILEMAP_MODE][0]); // 15
Display_feedback_state();
Display_effect_sprite(EFFECTS_SPRITE_SHADE, 8,20);
@ -4800,10 +4800,20 @@ void Button_Effects(void)
}
break;
case 15: // Tilemap
if (Window_attribute1==LEFT_SIDE)
{
Button_Tilemap_mode();
Hide_cursor();
Display_effect_state(177+23,43, "Tilemap" ,Main_tilemap_mode);
Display_cursor();
}
else
{
Close_window();
Display_cursor();
Button_Tilemap_menu();
clicked_button=11;
}
break;
}
}

View File

@ -199,7 +199,71 @@ void Button_Tilemap_mode(void)
void Button_Tilemap_menu(void)
{
short clicked_button;
byte flip_x=Config.Tilemap_allow_flipped_x;
byte flip_y=Config.Tilemap_allow_flipped_y;
byte count=Config.Tilemap_show_count;
Open_window(166,138,"Tilemap options");
Window_set_normal_button(6,120,51,14,"Cancel",0,1,KEY_ESC); // 1
Window_set_normal_button(110,120,51,14,"OK" ,0,1,SDLK_RETURN); // 2
Print_in_window(24,21, "Detect mirrored",MC_Dark,MC_Light);
Window_display_frame(5,17,155,74);
Print_in_window(37,37, "Horizontally",MC_Black,MC_Light);
Window_set_normal_button(18,34,13,13,flip_x?"X":"",0,1,0); // 3
Print_in_window(37,55, "Vertically",MC_Black,MC_Light);
Window_set_normal_button(18,52,13,13,flip_y?"X":"",0,1,0); // 4
Print_in_window(27,99, "Show count",MC_Black,MC_Light);
Window_set_normal_button(7,96,13,13,count?"X":"",0,1,0); // 5
Update_window_area(0,0,Window_width, Window_height);
Display_cursor();
do
{
clicked_button=Window_clicked_button();
switch (clicked_button)
{
case 3 :
flip_x=!flip_x;
Hide_cursor();
Print_in_window(21,37,flip_x?"X":" ", MC_Black, MC_Light);
Display_cursor();
break;
case 4 :
flip_y=!flip_y;
Hide_cursor();
Print_in_window(21,55,flip_y?"X":" ", MC_Black, MC_Light);
Display_cursor();
break;
case 5 :
count=!count;
Hide_cursor();
Print_in_window(10,99,count?"X":" ", MC_Black, MC_Light);
Display_cursor();
break;
}
if (Is_shortcut(Key,0x100+BUTTON_HELP))
Window_help(BUTTON_EFFECTS, "TILEMAP");
}
while ( (clicked_button!=1) && (clicked_button!=2) );
if (clicked_button==2) // OK
{
Config.Tilemap_allow_flipped_x=flip_x;
Config.Tilemap_allow_flipped_y=flip_y;
Config.Tilemap_show_count=count;
}
Close_window();
Display_cursor();
}
//--------------------------------- Stencil ----------------------------------

View File

@ -465,6 +465,8 @@ enum SPECIAL_ACTIONS
SPECIAL_TRANSPARENCY_8,
SPECIAL_TRANSPARENCY_9,
SPECIAL_TRANSPARENCY_0,
SPECIAL_TILEMAP_MODE,
SPECIAL_TILEMAP_MENU,
SPECIAL_TILING_MENU, ///< This must be the last of the "effects" family
SPECIAL_ZOOM_1,
SPECIAL_ZOOM_2,

View File

@ -1169,6 +1169,16 @@ void Main_handler(void)
Button_Tiling_menu();
action++;
break;
case SPECIAL_TILEMAP_MODE :
Button_Tilemap_mode();
effect_modified = 1;
action++;
break;
case SPECIAL_TILEMAP_MENU :
effect_modified = 1;
Button_Tilemap_menu();
action++;
break;
case SPECIAL_EFFECTS_OFF :
Effects_off();
effect_modified = 1;

View File

@ -597,6 +597,22 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = {
true,
SDLK_b|MOD_SHIFT|MOD_ALT, // Shift + Alt + B
0},
{206,
"Tilemap mode",
"Enables or disables the Tilemap",
"mode.",
"",
true,
0, // No key
0},
{207,
"Tilemap menu",
"Opens a menu where you can configure",
"the tilemap settings.",
"",
true,
0, // No key
0},
{67,
"Classical brush grabbing",
"Allows you to pick a brush defined",
@ -1780,6 +1796,8 @@ word Ordering[NB_SHORTCUTS]=
SPECIAL_SMEAR_MODE, // Smear mode
SPECIAL_TILING_MODE, // Tiling mode
SPECIAL_TILING_MENU, // Tiling menu
SPECIAL_TILEMAP_MODE, // Tilemap mode
SPECIAL_TILEMAP_MENU, // Tilemap menu
0x100+BUTTON_BRUSH, // Pick brush
0x100+BUTTON_POLYBRUSH, // Pick polyform brush
0x200+BUTTON_BRUSH, // Restore brush

View File

@ -33,7 +33,7 @@
#endif
#include <SDL.h>
#define NB_SHORTCUTS 206 ///< Number of actions that can have a key combination associated to it.
#define NB_SHORTCUTS 208 ///< Number of actions that can have a key combination associated to it.
/*** Types definitions and structs ***/

View File

@ -954,6 +954,29 @@ int Load_INI(T_Config * conf)
{
conf->Allow_multi_shortcuts=(values[0]!=0);
}
conf->Tilemap_allow_flipped_x=0;
// Optional, makes tilemap effect detect x-flipped tiles (>=2.4)
if (!Load_INI_get_values (file,buffer,"Tilemap_detect_mirrored_x",1,values))
{
conf->Tilemap_allow_flipped_x=(values[0]!=0);
}
conf->Tilemap_allow_flipped_y=0;
// Optional, makes tilemap effect detect y-flipped tiles (>=2.4)
if (!Load_INI_get_values (file,buffer,"Tilemap_detect_mirrored_y",1,values))
{
conf->Tilemap_allow_flipped_y=(values[0]!=0);
}
conf->Tilemap_show_count=0;
// Optional, makes tilemap effect display tile count (>=2.4)
if (!Load_INI_get_values (file,buffer,"Tilemap_count",1,values))
{
conf->Tilemap_show_count=(values[0]!=0);
}
// Insert new values here

View File

@ -705,6 +705,19 @@ int Save_INI(T_Config * conf)
values[0]=(conf->Allow_multi_shortcuts);
if ((return_code=Save_INI_set_values (old_file,new_file,buffer,"Allow_multi_shortcuts",1,values,1)))
goto Erreur_Retour;
values[0]=conf->Tilemap_allow_flipped_x;
if ((return_code=Save_INI_set_values (old_file,new_file,buffer,"Tilemap_detect_mirrored_x",1,values,1)))
goto Erreur_Retour;
values[0]=conf->Tilemap_allow_flipped_y;
if ((return_code=Save_INI_set_values (old_file,new_file,buffer,"Tilemap_detect_mirrored_y",1,values,1)))
goto Erreur_Retour;
values[0]=conf->Tilemap_show_count;
if ((return_code=Save_INI_set_values (old_file,new_file,buffer,"Tilemap_count",1,values,1)))
goto Erreur_Retour;
// Insert new values here

View File

@ -370,6 +370,12 @@ typedef struct
word Swap_buttons; ///< Sets which key swaps mouse buttons : 0=none, or MOD_CTRL, or MOD_ALT.
char Scripts_directory[MAX_PATH_CHARACTERS];///< Full pathname of directory for Lua scripts
byte Allow_multi_shortcuts; ///< Boolean, true if the same key combination can trigger multiple shortcuts.
byte Tilemap_allow_flipped_x; ///< Boolean, true if the Tilemap tool should detect x-flipped tiles.
byte Tilemap_allow_flipped_y; ///< Boolean, true if the Tilemap tool should detect y-flipped tiles.
byte Tilemap_show_count; ///< Boolean, true if the Tilemap tool should display tile count after analysis.
} T_Config;
// Structures utilisées pour les descriptions de pages et de liste de pages.

View File

@ -46,8 +46,6 @@ T_Tile * Spare_tilemap;
short Spare_tilemap_width;
short Spare_tilemap_height;
T_Tilemap_settings Tilemap_settings = { 0, 0, 0, 0};
//
/// Build the tile-area from the current picture
@ -313,7 +311,7 @@ void Tilemap_update(void)
Main_tilemap_width=width;
Main_tilemap_height=height;
if (width*height > 1000 || Tilemap_settings.Show_tile_count)
if (width*height > 1000 || Config.Tilemap_show_count)
{
wait_window=1;
Open_window(180,36,"Creating tileset");
@ -362,7 +360,7 @@ void Tilemap_update(void)
}
// Try flipped-y comparison
if (Tilemap_settings.Allow_flipped_y)
if (Config.Tilemap_allow_flipped_y)
{
for (ref_tile=0; ref_tile<tile; ref_tile++)
{
@ -386,7 +384,7 @@ void Tilemap_update(void)
}
// Try flipped-x comparison
if (Tilemap_settings.Allow_flipped_x)
if (Config.Tilemap_allow_flipped_x)
{
for (ref_tile=0; ref_tile<tile; ref_tile++)
{
@ -410,7 +408,7 @@ void Tilemap_update(void)
}
// Try flipped-xy comparison
if (Tilemap_settings.Allow_flipped_xy)
if (Config.Tilemap_allow_flipped_x && Config.Tilemap_allow_flipped_y)
{
for (ref_tile=0; ref_tile<tile; ref_tile++)
{
@ -444,18 +442,21 @@ void Tilemap_update(void)
char str[8];
Uint32 end;
Num2str(count,str,7);
Hide_cursor();
Print_in_window(6, 20, "Unique tiles: ",MC_Black,MC_Light);
Print_in_window(6+8*14,20,str,MC_Black,MC_Light);
Display_cursor();
// Wait a moment to display count
end = SDL_GetTicks()+750;
do
if (Config.Tilemap_show_count)
{
Get_input(20);
} while (SDL_GetTicks()<end);
Num2str(count,str,7);
Hide_cursor();
Print_in_window(6, 20, "Unique tiles: ",MC_Black,MC_Light);
Print_in_window(6+8*14,20,str,MC_Black,MC_Light);
Display_cursor();
// Wait a moment to display count
end = SDL_GetTicks()+750;
do
{
Get_input(20);
} while (SDL_GetTicks()<end);
}
Close_window();
Cursor_shape=old_cursor;

View File

@ -42,19 +42,6 @@ void Disable_spare_tilemap(void);
#define TILE_X(t) (((t)%Main_tilemap_width)*Snap_width+Snap_offset_X)
#define TILE_Y(t) (((t)/Main_tilemap_width)*Snap_height+Snap_offset_Y)
typedef struct
{
byte Allow_flipped_x;
byte Allow_flipped_y;
byte Allow_flipped_xy;
byte Show_tile_count;
} T_Tilemap_settings;
extern T_Tilemap_settings Tilemap_settings;
/// Tilemap for the main screen
extern T_Tile * Main_tilemap;

View File

@ -34,6 +34,8 @@
#include "readline.h"
#include "buttons.h" // Message_out_of_memory()
#include "pages.h" // Backup_with_new_dimensions()
#include "tiles.h"
/// Reduces a fraction A/B to its smallest representation. ie (40,60) becomes (2/3)
void Factorize(short *a, short *b)