Skip to content

Commit

Permalink
Merge pull request #183 from AliceLR/pal-ed-improvements
Browse files Browse the repository at this point in the history
Palette editor improvements
  • Loading branch information
AliceLR committed Jul 9, 2019
2 parents 5c4e62b + b1785ed commit e8128a4
Show file tree
Hide file tree
Showing 7 changed files with 649 additions and 191 deletions.
21 changes: 21 additions & 0 deletions docs/changelog.txt
Expand Up @@ -77,6 +77,27 @@ FEATURES
+ Added the 'softscale' renderer. This renderer is a generalized
rewrite of the former SDL 2 overlay renderer implementation.
It should perform significantly better and be more portable.
+ Added several palette editor usability improvements:
+ The current color stored with F2 is now displayed in the
bottom-right corner of the palette editor help menu.
+ In SMZX mode 2 or 3 editing, the four colors of the current
subpalette can be stored with F5. Stored subpalette colors
can be placed at the current subpalette with F6. These are
stored independently of the stored current color. The help
menu color display will cycle through the stored colors.
+ In SMZX mode 3 editing, the current subpalette's indices can
be stored with F7 and placed at the current subpalette with
F8. The stored indices are displayed in the help menu next
to the stored color display.
+ The shortcut for toggling the subpalette cursors has been
changed to Insert. The subpalette cursors are now displayed
in SMZX mode 3 editing and are enabled by default.
+ Palettes (and/or indices) can be imported into and exported
from the palette editor with Alt+I and Alt+X, respectively.
+ Added a secondary editor-only palette which can be switched
to with Tab. This palette is not saved with any world, but
can be edited and imported to/exported from and can be used
to copy colors/subpalettes between different sources.
+ checkres now displays the board, sfx, and robot (with line and
position on the board) each file was referenced in.
+ checkres can now be used with a directory as the base file.
Expand Down
47 changes: 4 additions & 43 deletions src/editor/edit.c
Expand Up @@ -85,8 +85,6 @@ static const char *const mzb_ext[] = { ".MZB", NULL };
static const char *const mzm_ext[] = { ".MZM", NULL };
static const char *const sfx_ext[] = { ".SFX", NULL };
static const char *const chr_ext[] = { ".CHR", NULL };
static const char *const pal_ext[] = { ".PAL", NULL };
static const char *const idx_ext[] = { ".PALIDX", NULL };
static const char *const mod_ext[] =
{ ".ogg", ".mod", ".s3m", ".xm", ".it",
".669", ".amf", ".dsm", ".far", ".gdm",
Expand All @@ -108,8 +106,6 @@ struct editor_context
char mzb_name_buffer[MAX_PATH];
char mzm_name_buffer[MAX_PATH];
char chr_name_buffer[MAX_PATH];
char pal_name_buffer[MAX_PATH];
char idx_name_buffer[MAX_PATH];
char current_listening_dir[MAX_PATH];
char current_listening_mod[MAX_PATH];

Expand Down Expand Up @@ -2632,27 +2628,8 @@ static boolean editor_key(context *ctx, int *key)

case 3:
{
// Palette
strcpy(import_name, editor->pal_name_buffer);
if(!choose_file(mzx_world, pal_ext, import_name,
"Choose palette to import", 1))
{
strcpy(editor->pal_name_buffer, import_name);
load_palette(import_name);
editor->modified = true;
}

// Indices (mode 3 only)
strcpy(import_name, editor->idx_name_buffer);
if((get_screen_mode() == 3) &&
!choose_file(mzx_world, idx_ext, import_name,
"Choose indices to import (.PALIDX)", 1))
{
strcpy(editor->idx_name_buffer, import_name);
load_index_file(import_name);
editor->modified = true;
}

// Palette (let the palette editor handle this one)
import_palette(ctx);
break;
}

Expand Down Expand Up @@ -3256,24 +3233,8 @@ static boolean editor_key(context *ctx, int *key)

case 2:
{
// Palette
strcpy(export_name, editor->pal_name_buffer);
if(!new_file(mzx_world, pal_ext, ".pal", export_name,
"Export palette", 1))
{
strcpy(editor->pal_name_buffer, export_name);
save_palette(export_name);
}

strcpy(export_name, editor->idx_name_buffer);
if((get_screen_mode() == 3) &&
!new_file(mzx_world, idx_ext, ".palidx", export_name,
"Export indices (.PALIDX)", 1))
{
strcpy(editor->idx_name_buffer, export_name);
save_index_file(export_name);
}

// Palette (let the palette editor handle this one)
export_palette(ctx);
break;
}

Expand Down
31 changes: 25 additions & 6 deletions src/editor/graphics.c
Expand Up @@ -36,16 +36,35 @@ static Uint8 ascii_charset[CHAR_SIZE * CHARSET_SIZE];
static Uint8 blank_charset[CHAR_SIZE * CHARSET_SIZE];
static Uint8 smzx_charset[CHAR_SIZE * CHARSET_SIZE];

void save_editor_indices(void)
void store_backup_palette(char dest[SMZX_PAL_SIZE])
{
memcpy(graphics.editor_backup_indices, graphics.smzx_indices,
SMZX_PAL_SIZE * 4);
Uint32 i;
Uint8 *r;
Uint8 *g;
Uint8 *b;

for(i = 0; i < graphics.protected_pal_position; i++)
{
r = (Uint8 *)(dest++);
g = (Uint8 *)(dest++);
b = (Uint8 *)(dest++);
get_rgb(i, r, g, b);
}
}

void load_backup_palette(char src[SMZX_PAL_SIZE * 3])
{
load_palette_mem(src, SMZX_PAL_SIZE * 3);
}

void store_backup_indices(char dest[SMZX_PAL_SIZE * 4])
{
memcpy(dest, graphics.smzx_indices, SMZX_PAL_SIZE * 4);
}

void load_editor_indices(void)
void load_backup_indices(char src[SMZX_PAL_SIZE * 4])
{
memcpy(graphics.smzx_indices, graphics.editor_backup_indices,
SMZX_PAL_SIZE * 4);
memcpy(graphics.smzx_indices, src, SMZX_PAL_SIZE * 4);
}

void save_palette(char *fname)
Expand Down
8 changes: 6 additions & 2 deletions src/editor/graphics.h
Expand Up @@ -25,9 +25,13 @@
__M_BEGIN_DECLS

#include "../platform.h"
#include "../graphics.h"

void store_backup_palette(char dest[SMZX_PAL_SIZE * 3]);
void load_backup_palette(char src[SMZX_PAL_SIZE * 3]);
void store_backup_indices(char dest[SMZX_PAL_SIZE * 4]);
void load_backup_indices(char src[SMZX_PAL_SIZE * 4]);

void save_editor_indices(void);
void load_editor_indices(void);
void save_palette(char *fname);
void save_index_file(char *fname);
void draw_char_mixed_pal(Uint8 chr, Uint8 bg_color, Uint8 fg_color,
Expand Down

0 comments on commit e8128a4

Please sign in to comment.