+2007-01-31
+ * fixed displaying and typing of player name when it is centered
+ * added special characters to be allowed for player name (not only A-Z)
+
+2007-01-25
+ * fixed blit in ScrollLevel() to same bitmap to not overlap anymore
+ (newer versions of the SDL library seem to not like this anymore)
+
2007-01-23
* added code for configuration directives for control of game panel
endif
ifeq ($(PLATFORM),macosx)
+EXTRA_LDFLAGS = -lstdc++
PLATFORM = unix
TARGET = sdl
endif
{ "main.text.level_info_1.x", "272" },
{ "main.text.level_info_1.y", "352" },
{ "main.text.level_info_1.align", "center" },
+ { "main.text.level_info_1.chars", "-1" },
{ "main.text.level_info_2.x", "272" },
{ "main.text.level_info_2.y", "523" },
{ "main.text.level_info_2.align", "center" },
+ { "main.text.level_info_2.chars", "-1" },
{ "main.text.title_1.x", "272" },
{ "main.text.title_1.y", "8" },
{ "main.text.title_1.align", "center" },
-#define COMPILE_DATE_STRING "2007-01-26 02:51"
+#define COMPILE_DATE_STRING "2007-01-31 23:47"
FX + TILEX * (dx != 0 ? i : 0),
FY + TILEY * (dy != 0 ? i : 0));
}
+
#else
int softscroll_offset = (setup.soft_scrolling ? TILEX : 0);
-#if 1
- BlitBitmap(drawto_field, bitmap_db_field2,
- FX + TILEX * (dx == -1) - softscroll_offset,
- FY + TILEY * (dy == -1) - softscroll_offset,
- SXSIZE - TILEX * (dx != 0) + 2 * softscroll_offset,
- SYSIZE - TILEY * (dy != 0) + 2 * softscroll_offset,
- FX + TILEX * (dx == 1) - softscroll_offset,
- FY + TILEY * (dy == 1) - softscroll_offset);
- BlitBitmap(bitmap_db_field2, drawto_field,
- FX + TILEX * (dx == 1) - softscroll_offset,
- FY + TILEY * (dy == 1) - softscroll_offset,
- SXSIZE - TILEX * (dx != 0) + 2 * softscroll_offset,
- SYSIZE - TILEY * (dy != 0) + 2 * softscroll_offset,
- FX + TILEX * (dx == 1) - softscroll_offset,
- FY + TILEY * (dy == 1) - softscroll_offset);
-#else
BlitBitmap(drawto_field, drawto_field,
FX + TILEX * (dx == -1) - softscroll_offset,
FY + TILEY * (dy == -1) - softscroll_offset,
SYSIZE - TILEY * (dy != 0) + 2 * softscroll_offset,
FX + TILEX * (dx == 1) - softscroll_offset,
FY + TILEY * (dy == 1) - softscroll_offset);
-#endif
#endif
if (dx != 0)
{ KSYM_asciitilde, "XK_asciitilde", "~" },
/* special (non-ASCII) keys */
+ { KSYM_degree, "XK_degree", "°" },
{ KSYM_Adiaeresis, "XK_Adiaeresis", "Ä" },
{ KSYM_Odiaeresis, "XK_Odiaeresis", "Ö" },
{ KSYM_Udiaeresis, "XK_Udiaeresis", "Ü" },
char getCharFromKey(Key key)
{
char *keyname = getKeyNameFromKey(key);
- char letter = 0;
+ char c = 0;
if (strlen(keyname) == 1)
- letter = keyname[0];
+ c = keyname[0];
else if (strEqual(keyname, "space"))
- letter = ' ';
- else if (strEqual(keyname, "circumflex"))
- letter = '^';
+ c = ' ';
- return letter;
+ return c;
+}
+
+char getValidConfigValueChar(char c)
+{
+ if (c == '#' || /* used to mark comments */
+ c == '\\') /* used to mark continued lines */
+ c = 0;
+
+ return c;
}
Key getKeyFromKeyName(char *);
Key getKeyFromX11KeyName(char *);
char getCharFromKey(Key);
+char getValidConfigValueChar(char);
int get_integer_from_string(char *);
boolean get_boolean_from_string(char *);
int width, height;
int hot_x, hot_y;
- char data[CURSOR_MAX_WIDTH * CURSOR_MAX_HEIGHT / 8];
- char mask[CURSOR_MAX_WIDTH * CURSOR_MAX_HEIGHT / 8];
+ byte data[CURSOR_MAX_WIDTH * CURSOR_MAX_HEIGHT / 8];
+ byte mask[CURSOR_MAX_WIDTH * CURSOR_MAX_HEIGHT / 8];
};
#define KSYM_braceright KSYM_UNDEFINED /* undefined */
#define KSYM_asciitilde KSYM_UNDEFINED /* undefined */
+#define KSYM_degree SDLK_WORLD_16
#define KSYM_Adiaeresis SDLK_WORLD_36
#define KSYM_Odiaeresis SDLK_WORLD_54
#define KSYM_Udiaeresis SDLK_WORLD_60
{
char *source_filename;
- int width, height;
+ unsigned int width, height;
Drawable drawable;
Drawable clip_mask;
GC gc; /* GC for normal drawing (inheritated from 'window') */
#define KSYM_braceright XK_braceright
#define KSYM_asciitilde XK_asciitilde
+#define KSYM_degree XK_degree
#define KSYM_Adiaeresis XK_Adiaeresis
#define KSYM_Odiaeresis XK_Odiaeresis
#define KSYM_Udiaeresis XK_Udiaeresis
{ "main.text.level_info_1.x", &menu.main.text.level_info_1.x },
{ "main.text.level_info_1.y", &menu.main.text.level_info_1.y },
{ "main.text.level_info_1.align", &menu.main.text.level_info_1.align },
+ { "main.text.level_info_1.chars", &menu.main.text.level_info_1.chars },
{ "main.text.level_info_2.x", &menu.main.text.level_info_2.x },
{ "main.text.level_info_2.y", &menu.main.text.level_info_2.y },
{ "main.text.level_info_2.align", &menu.main.text.level_info_2.align },
+ { "main.text.level_info_2.chars", &menu.main.text.level_info_2.chars },
{ "main.text.title_1.x", &menu.main.text.title_1.x },
{ "main.text.title_1.y", &menu.main.text.title_1.y },
{ "main.text.title_1.align", &menu.main.text.title_1.align },
struct MenuMainTextInfo
{
- struct MenuPosInfo name;
- struct MenuPosInfo levels;
- struct MenuPosInfo scores;
- struct MenuPosInfo editor;
- struct MenuPosInfo info;
- struct MenuPosInfo game;
- struct MenuPosInfo setup;
- struct MenuPosInfo quit;
-
- struct MenuPosInfo current_level;
- struct MenuPosInfo first_level;
- struct MenuPosInfo last_level;
- struct MenuPosInfo level_info_1;
- struct MenuPosInfo level_info_2;
- struct MenuPosInfo title_1;
- struct MenuPosInfo title_2;
- struct MenuPosInfo title_3;
+ struct TextPosInfo name;
+ struct TextPosInfo levels;
+ struct TextPosInfo scores;
+ struct TextPosInfo editor;
+ struct TextPosInfo info;
+ struct TextPosInfo game;
+ struct TextPosInfo setup;
+ struct TextPosInfo quit;
+
+ struct TextPosInfo current_level;
+ struct TextPosInfo first_level;
+ struct TextPosInfo last_level;
+ struct TextPosInfo level_info_1;
+ struct TextPosInfo level_info_2;
+ struct TextPosInfo title_1;
+ struct TextPosInfo title_2;
+ struct TextPosInfo title_3;
};
struct MenuMainInputInfo
if (FD_ISSET(lfd, &fds))
{
- int newfd, slen;
+ int newfd;
+ socklen_t slen;
slen = sizeof(saddr);
newfd = accept(lfd, (struct sockaddr *)&saddr, &slen);
struct MenuPosInfo *pos_button;
int button_graphic;
- struct MenuPosInfo *pos_text;
+ struct TextPosInfo *pos_text;
char *text;
int font_text;
struct MainControlInfo *mci = &main_controls[i];
int nr = mci->nr;
struct MenuPosInfo *pos_button = mci->pos_button;
- struct MenuPosInfo *pos_text = mci->pos_text;
+ struct TextPosInfo *pos_text = mci->pos_text;
struct MenuPosInfo *pos_input = mci->pos_input;
char *text = mci->text;
char *input = mci->input;
menu.main.input.name.y = menu.main.text.name.y;
#endif
+#if 1
+ menu.main.input.name.width = input_width;
+ menu.main.input.name.height = input_height;
+#else
menu.main.input.name.width = font_input_width * MAX_PLAYER_NAME_LEN;
menu.main.input.name.height = font_input_height;
+#endif
}
if (pos_button != NULL)
if (mci->nr == nr || nr == -1)
{
struct MenuPosInfo *pos_button = mci->pos_button;
- struct MenuPosInfo *pos_text = mci->pos_text;
+ struct TextPosInfo *pos_text = mci->pos_text;
struct MenuPosInfo *pos_input = mci->pos_input;
char *text = mci->text;
char *input = mci->input;
if (pos_text != NULL && text != NULL)
{
- struct MenuPosInfo *pos = pos_text;
+ struct TextPosInfo *pos = pos_text;
int x = mSX + ALIGNED_MENU_XPOS(pos);
int y = mSY + ALIGNED_MENU_YPOS(pos);
y >= rect_y && y < rect_y + rect->height);
}
+static boolean insideTextPosRect(struct TextPosInfo *rect, int x, int y)
+{
+ if (rect == NULL)
+ return FALSE;
+
+ int rect_x = ALIGNED_MENU_XPOS(rect);
+ int rect_y = ALIGNED_MENU_YPOS(rect);
+
+ return (x >= rect_x && x < rect_x + rect->width &&
+ y >= rect_y && y < rect_y + rect->height);
+}
+
static void drawCursorExt(int xpos, int ypos, boolean active, int graphic)
{
static int cursor_array[SCR_FIELDY];
for (i = 0; main_controls[i].nr != -1; i++)
{
if (insideMenuPosRect(main_controls[i].pos_button, mx - mSX, my - mSY) ||
- insideMenuPosRect(main_controls[i].pos_text, mx - mSX, my - mSY) ||
+ insideTextPosRect(main_controls[i].pos_text, mx - mSX, my - mSY) ||
insideMenuPosRect(main_controls[i].pos_input, mx - mSX, my - mSY))
{
pos = main_controls[i].nr;
int font_text = FONT_TEXT_2;
int xstep = getFontWidth(font_text);
int ystep = getFontHeight(font_text);
- int xstart1 = SX + 2 * xstep;
- int xstart2 = SX + 18 * xstep;
- int xstart3 = SX + 28 * xstep;
int ystart = 150;
int ybottom = SYSIZE - 20;
+ int xstart1 = SX + 2 * xstep;
+ int xstart2 = SX + 18 * xstep;
#if defined(TARGET_SDL)
+ int xstart3 = SX + 28 * xstep;
SDL_version sdl_version_compiled;
const SDL_version *sdl_version_linked;
#endif
sdl_version_linked->patch);
SDL_IMAGE_VERSION(&sdl_version_compiled);
-#if 0
sdl_version_linked = IMG_Linked_Version();
-#else
-#endif
ystart += ystep;
DrawTextF(xstart1, ystart, font_text, "SDL_image");
sdl_version_compiled.major,
sdl_version_compiled.minor,
sdl_version_compiled.patch);
-#if 0
DrawTextF(xstart3, ystart, font_text, "%d.%d.%d",
sdl_version_linked->major,
sdl_version_linked->minor,
sdl_version_linked->patch);
-#else
- DrawTextF(xstart3, ystart, font_text, "?.?.?");
-#endif
SDL_MIXER_VERSION(&sdl_version_compiled);
sdl_version_linked = Mix_Linked_Version();
sdl_version_linked->minor,
sdl_version_linked->patch);
+ SDL_NET_VERSION(&sdl_version_compiled);
+ sdl_version_linked = SDLNet_Linked_Version();
+
ystart += ystep;
DrawTextF(xstart1, ystart, font_text, "SDL_net");
- DrawTextF(xstart2, ystart, font_text, "?.?.?");
- DrawTextF(xstart3, ystart, font_text, "?.?.?");
+ DrawTextF(xstart2, ystart, font_text, "%d.%d.%d",
+ sdl_version_compiled.major,
+ sdl_version_compiled.minor,
+ sdl_version_compiled.patch);
+ DrawTextF(xstart3, ystart, font_text, "%d.%d.%d",
+ sdl_version_linked->major,
+ sdl_version_linked->minor,
+ sdl_version_linked->patch);
#endif
DrawTextSCentered(ybottom, FONT_TEXT_4,
void HandleTypeName(int newxpos, Key key)
{
+ static char last_player_name[MAX_PLAYER_NAME_LEN + 1];
struct MainControlInfo *mci = getMainControlInfo(MAIN_CONTROL_NAME);
#if 1
struct MenuPosInfo *pos = mci->pos_input;
int startx = mSX + 32 + name_width;
int starty = mSY + ypos * 32;
#endif
+ char key_char = getValidConfigValueChar(getCharFromKey(key));
+ boolean is_valid_key_char = (key_char != 0 && (key_char != ' ' || xpos > 0));
+ boolean is_active = TRUE;
+
+ DrawBackgroundForFont(startx,starty, pos->width, pos->height, font_active_nr);
if (newxpos)
{
+ strcpy(last_player_name, setup.player_name);
+
xpos = newxpos;
+#if 0
+ /* add one character width for added cursor character */
+ pos->width += font_width;
+ startx = mSX + ALIGNED_MENU_XPOS(pos);
+
DrawText(startx, starty, setup.player_name, font_active_nr);
DrawText(startx + xpos * font_width, starty, "_", font_active_nr);
-
- return;
+#endif
}
-
- if (((key >= KSYM_A && key <= KSYM_Z) ||
- (key >= KSYM_a && key <= KSYM_z)) &&
- xpos < MAX_PLAYER_NAME_LEN)
+ else if (is_valid_key_char && xpos < MAX_PLAYER_NAME_LEN)
{
- char ascii;
-
- if (key >= KSYM_A && key <= KSYM_Z)
- ascii = 'A' + (char)(key - KSYM_A);
- else
- ascii = 'a' + (char)(key - KSYM_a);
-
- setup.player_name[xpos] = ascii;
+ setup.player_name[xpos] = key_char;
setup.player_name[xpos + 1] = 0;
xpos++;
+#if 0
+ /* add one character width for added name text character */
+ pos->width += font_width;
+ startx = mSX + ALIGNED_MENU_XPOS(pos);
+
DrawText(startx, starty, setup.player_name, font_active_nr);
DrawText(startx + xpos * font_width, starty, "_", font_active_nr);
+#endif
}
else if ((key == KSYM_Delete || key == KSYM_BackSpace) && xpos > 0)
{
setup.player_name[xpos] = 0;
+#if 0
+ /* remove one character width for removed name text character */
+ pos->width -= font_width;
+ startx = mSX + ALIGNED_MENU_XPOS(pos);
+
+ DrawText(startx, starty, setup.player_name, font_active_nr);
DrawText(startx + xpos * font_width, starty, "_ ", font_active_nr);
+#endif
}
else if (key == KSYM_Return && xpos > 0)
{
+#if 0
+ /* remove one character width for removed cursor text character */
+ pos->width -= font_width;
+ startx = mSX + ALIGNED_MENU_XPOS(pos);
+
DrawText(startx, starty, setup.player_name, font_nr);
DrawText(startx + xpos * font_width, starty, " ", font_active_nr);
+#endif
SaveSetup();
+ is_active = FALSE;
+
game_status = GAME_MODE_MAIN;
}
+ else if (key == KSYM_Escape)
+ {
+ strcpy(setup.player_name, last_player_name);
+
+ is_active = FALSE;
+
+ game_status = GAME_MODE_MAIN;
+ }
+
+ if (is_active)
+ {
+ pos->width = (strlen(setup.player_name) + 1) * font_width;
+ startx = mSX + ALIGNED_MENU_XPOS(pos);
+
+ DrawText(startx, starty, setup.player_name, font_active_nr);
+ DrawText(startx + xpos * font_width, starty, "_", font_active_nr);
+ }
+ else
+ {
+ pos->width = strlen(setup.player_name) * font_width;
+ startx = mSX + ALIGNED_MENU_XPOS(pos);
+
+ DrawText(startx, starty, setup.player_name, font_nr);
+ }
}
#define MICROLABEL_IMPORTED_BY_HEAD 6
#define MICROLABEL_IMPORTED_BY 7
-static int getMaxTextLength(struct MenuPosInfo *pos, int font_nr)
+static int getMaxTextLength(struct TextPosInfo *pos, int font_nr)
{
int max_text_width = SXSIZE;
int font_width = getFontWidth(font_nr);
static void DrawPreviewLevelLabelExt(int mode)
{
- struct MenuPosInfo *pos = &menu.main.text.level_info_2;
+ struct TextPosInfo *pos = &menu.main.text.level_info_2;
char label_text[MAX_OUTPUT_LINESIZE + 1];
int max_len_label_text;
int font_nr = FONT_TEXT_2;
max_len_label_text = SXSIZE / getFontWidth(font_nr);
#endif
+#if 1
+ if (pos->chars != -1)
+ max_len_label_text = pos->chars;
+#endif
+
for (i = 0; i < max_len_label_text; i++)
label_text[i] = ' ';
label_text[max_len_label_text] = '\0';
if (leveldir_current->name)
{
- struct MenuPosInfo *pos = &menu.main.text.level_info_1;
+ struct TextPosInfo *pos = &menu.main.text.level_info_1;
char label_text[MAX_OUTPUT_LINESIZE + 1];
int font_nr = FONT_TEXT_1;
#if 1
int lxpos, lypos;
#endif
+#if 1
+ if (pos->chars != -1)
+ max_len_label_text = pos->chars;
+#endif
+
strncpy(label_text, leveldir_current->name, max_len_label_text);
label_text[max_len_label_text] = '\0';