Instead of using large negative values for the on-screen keyboard and
score board widget tokens, this patch introduces a "GUI bit" (the low
bit of the most significant byte of a 4-byte integer) which is ORed
with small integer values to obtain the final token values. This is
done mainly to allow some of these tokens to be ORed with each other.
git-svn-id: https://s.snth.net/svn/neverball/trunk@2460
78b8d119-cf0a-0410-b17c-
f493084dd1d7
/*---------------------------------------------------------------------------*/
-#define NAME_OK 1
-#define NAME_CANCEL 2
+#define NAME_OK -1
+#define NAME_CANCEL -2
static int name_id;
{
int c = gui_token(gui_click());
- /* Ugh. This is such a hack. */
-
- return name_action(isupper(c) ? gui_keyboard_char(c) : c);
+ if (c >= 0 && !GUI_ISMSK(c))
+ return name_action(gui_keyboard_char(c));
+ else
+ return name_action(c);
}
if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
name_action(NAME_CANCEL);
static int file_id;
-#define SAVE_SAVE 1
-#define SAVE_CANCEL 2
+#define SAVE_SAVE -1
+#define SAVE_CANCEL -2
static int save_action(int i)
{
{
int c = gui_token(gui_click());
- /* Ugh. This is such a hack. */
-
- return save_action(isupper(c) ? gui_keyboard_char(c) : c);
+ if (c >= 0 && !GUI_ISMSK(c))
+ return save_action(gui_keyboard_char(c));
+ else
+ return save_action(c);
}
if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
return save_action(SAVE_CANCEL);
set_time_score(curr_set()), -1);
}
- if (i >= 0)
+ if (i >= 0 && !GUI_ISMSK(i))
start_over_level(i);
}
/*---------------------------------------------------------------------------*/
-#define GUI_NULL -100
-#define GUI_BACK -101
-#define GUI_PREV -102
-#define GUI_NEXT -103
-#define GUI_BS -104
-#define GUI_CL -105
-
-#define GUI_MOST_COINS -106
-#define GUI_BEST_TIMES -107
-#define GUI_UNLOCK_GOAL -108
-
-#define GUI_NAME -109
+#define GUI_BIT (1 << 24)
+
+#define GUI_MSK(i) ((i) | GUI_BIT)
+#define GUI_UNMSK(i) ((i) & ~GUI_BIT)
+#define GUI_ISMSK(i) ((i) & GUI_BIT ? 1 : 0)
+
+#define GUI_NULL GUI_MSK(0)
+#define GUI_BACK GUI_MSK(1)
+#define GUI_PREV GUI_MSK(2)
+#define GUI_NEXT GUI_MSK(3)
+#define GUI_BS GUI_MSK(4)
+#define GUI_CL GUI_MSK(5)
+#define GUI_NAME GUI_MSK(6)
+
+#define GUI_MOST_COINS GUI_MSK(8)
+#define GUI_BEST_TIMES GUI_MSK(16)
+#define GUI_UNLOCK_GOAL GUI_MSK(32)
void gui_score_set(int);
int gui_score_get(void);