Skip to content

Commit

Permalink
fix some visual inconsistencies in the menu
Browse files Browse the repository at this point in the history
  • Loading branch information
rsn8887 committed Jan 10, 2019
1 parent 061004a commit 77dbd7d
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 102 deletions.
101 changes: 14 additions & 87 deletions src/gp2x/menu/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ static Uint32 menu_inv_color=0, menu_win0_color=0, menu_win1_color=0;
static Uint32 menu_barra0_color=0, menu_barra1_color=0;
static Uint32 menu_win0_color_base=0, menu_win1_color_base=0;

void write_text_pos(int x, int y, char * str);
void write_text_pos(int x, int y, const char * str);
void write_num(int x, int y, int v);
int menu_msg_pos=330;
int menu_moving=1;
Expand Down Expand Up @@ -614,85 +614,12 @@ void quit_text(void)
window_screen = NULL;
}

void write_text_pos(int x, int y, char * str)
void write_text(int x, int y, const char * str)
{
int i, c;
SDL_Rect src, dest;
SDL_Surface *text_image;

for (i = 0; i < strlen(str); i++)
{
c = -1;

if (str[i] >= '0' && str[i] <= '9')
c = str[i] - '0';
else if (str[i] >= 'A' && str[i] <= 'Z')
c = str[i] - 'A' + 10;
else if (str[i] >= 'a' && str[i] <= 'z')
c = str[i] - 'a' + 36;
else if (str[i] == '#')
c = 62;
else if (str[i] == '=')
c = 63;
else if (str[i] == '.')
c = 64;
else if (str[i] == '_')
c = -2;
else if (str[i] == '-')
c = -3;
else if (str[i] == '(')
c = 65;
else if (str[i] == ')')
c = 66;

if (c >= 0)
{
src.x = c * 7;
src.y = 0;
src.w = 7;
src.h = 8;

dest.x = x + (i * 7);
dest.y = y;
dest.w = 7;
dest.h = 8;
switch (mainMenu_font) {
case 0:
text_image = text_image_0;
break;
case 1:
text_image = text_image_1;
break;
case 2:
text_image = text_image_2;
break;
default:
text_image = text_image_0;
}
if (text_image == NULL) {
text_image = text_image_0;
}
SDL_BlitSurface(text_image, &src,
text_screen, &dest);
}
else if (c == -2 || c == -3)
{
dest.x = x + (i * 8);

if (c == -2)
dest.y = y + 7;
else if (c == -3)
dest.y = y + 3;

dest.w = 7;
dest.h = 1;

SDL_FillRect(text_screen, &dest, menu_barra0_color);
}
}
write_text_pos(x * 7, y * 7, str);
}

void write_text(int x, int y, const char * str)
void write_text_pos(int x, int y, const char * str)
{
int i, c;
SDL_Rect src, dest;
Expand Down Expand Up @@ -731,8 +658,8 @@ void write_text(int x, int y, const char * str)
src.w = 7;
src.h = 8;

dest.x = (x + i) * 7;
dest.y = y * 7; //10;
dest.x = x + i * 7;
dest.y = y; //10;
dest.w = 7;
dest.h = 8;
switch (mainMenu_font) {
Expand All @@ -756,12 +683,12 @@ void write_text(int x, int y, const char * str)
}
else if (c == -2 || c == -3)
{
dest.x = (x + i) * 7;
dest.x = x + i * 7;

if (c == -2)
dest.y = y * 7 /*10*/ + 7;
dest.y = y /*10*/ + 7;
else if (c == -3)
dest.y = y * 7 /*10*/ + 3;
dest.y = y /*10*/ + 3;
dest.w = 7;
dest.h = 1;

Expand Down Expand Up @@ -823,12 +750,12 @@ void text_draw_window(int x, int y, int w, int h, const char *title)
{
int i,j;
int x_screen = x * 7;
int y_screen = y * 8;
int y_screen = y * 7 + 2;

int x_corn = x_screen-2;
int y_corn = y_screen-12;
int y_corn = y_screen-13;
int w_corn = (w*7)+4;
int h_corn = (h*8)+4+12;
int h_corn = (h*8)+4+13;

int x_shadow = x_corn+w_corn;
int y_shadow = y_corn+6;
Expand Down Expand Up @@ -859,8 +786,8 @@ void text_draw_window(int x, int y, int w, int h, const char *title)
dest.x = x_corn;
dest.y = y_corn;
dest.w = w_corn;

dest.h = h_corn;

SDL_FillRect(text_screen, &dest, menu_win1_color);

dest.x=x_screen;
Expand All @@ -869,7 +796,7 @@ void text_draw_window(int x, int y, int w, int h, const char *title)
dest.h=h*8;
SDL_BlitSurface(window_screen,&dest,text_screen,&dest);

write_text(x + ((w-strlen(title)) / 2), y-1, title);
write_text_pos((x + ((w - strlen(title)) / 2)) * 7, (y - 1) * 7 - 1, title);
}

void _text_draw_window(SDL_Surface *sf, int x, int y, int w, int h, const char *title)
Expand Down
6 changes: 3 additions & 3 deletions src/gp2x/menu/menu_controls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#define MIN_CUSTOM_ID -28

const char *text_str_controls_separator="---------------------------------------";
const char *text_str_controls_title= " Custom Controls -";
const char *text_str_controls_title= "Custom Controls";
char tmpchar[256];
char mapping[32]="";
int menuControls = 0;
Expand Down Expand Up @@ -356,7 +356,7 @@ static void draw_controlsMenu(int c)
#endif
int ctrlNr = mainMenu_custom_currentlyEditingControllerNr;

int leftMargin=3;
int leftMargin = 3;
int tabstop1 = 17;
int tabstop2 = 19;
int tabstop3 = 21;
Expand All @@ -375,7 +375,7 @@ static void draw_controlsMenu(int c)
r.x=80-64; r.y=0; r.w=110+64+64; r.h=240;

text_draw_background();
text_draw_window(2,2,41,30,text_str_controls_title);
text_draw_window(2,2,41,29,text_str_controls_title);

// MENUCONTROLS_RETURNMAIN
if (menuControls == MENUCONTROLS_RETURNMAIN && bb)
Expand Down
2 changes: 1 addition & 1 deletion src/gp2x/menu/menu_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#endif

const char *text_str_display_separator="--------------------------------------";
const char *text_str_display_title= " Display and Sound Settings ";
const char *text_str_display_title= "Display and Sound Settings";
static const char *text_str_sound="Sound";
static const char *text_str_fast="Fast";
static const char *text_str_accurate="Accurate";
Expand Down
2 changes: 1 addition & 1 deletion src/gp2x/menu/menu_fileinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "sound.h"
#include "gp2x.h"

static const char *text_str_fileinfo_title= " File info -";
static const char *text_str_fileinfo_title= "File info";
char* fileInfo_fileName;

static void draw_fileinfoMenu(int c)
Expand Down
4 changes: 2 additions & 2 deletions src/gp2x/menu/menu_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,8 @@ static void draw_mainMenu(int c)

void showWarning(const char *msg)
{
text_draw_window(54/7,91/8,255/7,64/8,"--- Message ---");
write_text(12,14,msg);
text_draw_window(4,9,37,6,"Message");
write_text(5,12,msg);
//write_text(11,16,"Press any button to continue");
text_flip();
SDL_Event ev;
Expand Down
2 changes: 1 addition & 1 deletion src/gp2x/menu/menu_memory_disk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#endif

const char *text_str_memdisk_separator="--------------------------------------";
static const char *text_str_memdisk_title= " Memory and Disk Options -";
static const char *text_str_memdisk_title= "Memory and Disk Options";
const char *text_str_off="off";
const char *text_str_on="on";
const char *text_str_512K="512K";
Expand Down
8 changes: 4 additions & 4 deletions src/gp2x/menu/menu_misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
static int justSwitchedSingleJoycons = 0;
#endif

const char *text_str_misc_separator="-------------------------------------";
static const char *text_str_misc_title= " Miscellanous -";
const char *text_str_misc_separator="--------------------------------------";
static const char *text_str_misc_title= "Miscellanous";
static const char *text_str_stylus_offset="StylusOffset";
static const char *text_str_0px="0px";
static const char *text_str_1px="1px";
Expand Down Expand Up @@ -110,7 +110,7 @@ static void draw_miscMenu(int c)
int tabstop8 = 31;
int tabstop9 = 33;

int menuLine = 2;
int menuLine = 3;
static int b=0;
int bb=(b%6)/3;
SDL_Rect r;
Expand All @@ -121,7 +121,7 @@ static void draw_miscMenu(int c)
r.x=80-64; r.y=0; r.w=110+64+64; r.h=240;

text_draw_background();
text_draw_window(2,1,40,30,text_str_misc_title);
text_draw_window(2,2,40,30,text_str_misc_title);

// MENUMISC_RETURNMAIN
if (menuMisc == MENUMISC_RETURNMAIN && bb)
Expand Down
8 changes: 5 additions & 3 deletions src/gp2x/menu/menu_savestates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ static inline void cp(char* source_name, char* dest_name)

static inline void draw_savestatesMenu(int c)
{
int menuLine = 6;
int menuLine = 3;
static int b=0;
int bb=(b%6)/3;
SDL_Rect r;
extern SDL_Surface *text_screen;
r.x=80-64; r.y=0; r.w=110+64+64; r.h=240;

text_draw_background();
text_draw_window(3,4,39,20,text_str_title);
text_draw_window(3,2,39,20,text_str_title);

if ((c==0)&&(bb))
write_text_inv(leftMargin,menuLine,text_str_exit);
Expand Down Expand Up @@ -649,7 +649,7 @@ int run_menuSavestates()

if (!emulating)
{
showWarning("Emulation hasn't started yet.");
showWarning("Emulation has not started yet.");
return 0;
}

Expand Down Expand Up @@ -702,6 +702,8 @@ int run_menuSavestates()
snprintf(save_export_filename, 255, "%s%s%s", SAVE_PREFIX, buf, ".asf");
cp(savestate_filename, save_export_filename);
showWarning("File exported.");
} else {
showWarning("Invalid filename. File not exported.");
}
#else
saveMenu_case=-1;
Expand Down

0 comments on commit 77dbd7d

Please sign in to comment.