#include "cartoons.h"
#include "network.h"
#include "init.h"
+#include "config.h"
/* screens in the setup menu */
#define SETUP_MODE_MAIN 0
#define INFO_MODE_MUSIC 3
#define INFO_MODE_CREDITS 4
#define INFO_MODE_PROGRAM 5
-#define INFO_MODE_LEVELSET 6
+#define INFO_MODE_VERSION 6
+#define INFO_MODE_LEVELSET 7
-#define MAX_INFO_MODES 7
+#define MAX_INFO_MODES 8
/* for various menu stuff */
#define MENU_SCREEN_START_XPOS 1
static void HandleInfoScreen_Music(int);
static void HandleInfoScreen_Credits(int);
static void HandleInfoScreen_Program(int);
+static void HandleInfoScreen_Version(int);
static void MapScreenMenuGadgets(int);
static void MapScreenTreeGadgets(TreeInfo *);
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];
/* needed if last screen (level choice) changed graphics, sounds or music */
ReloadCustomArtwork(0);
-#ifdef TARGET_SDL
+#if defined(TARGET_SDL)
SetDrawtoField(DRAW_BACKBUFFER);
#endif
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;
DrawInfoScreen();
}
+static void execInfoVersion()
+{
+ info_mode = INFO_MODE_VERSION;
+ DrawInfoScreen();
+}
+
static void execInfoLevelSet()
{
info_mode = INFO_MODE_LEVELSET;
{ TYPE_ENTER_SCREEN, execInfoMusic, "Music Info" },
{ TYPE_ENTER_SCREEN, execInfoCredits, "Credits" },
{ TYPE_ENTER_SCREEN, execInfoProgram, "Program Info" },
+ { TYPE_ENTER_SCREEN, execInfoVersion, "Version Info" },
{ TYPE_ENTER_SCREEN, execInfoLevelSet, "Level Set Info" },
{ TYPE_EMPTY, NULL, "" },
{ TYPE_LEAVE_MENU, execExitInfo, "Exit" },
}
}
+void DrawInfoScreen_Version()
+{
+ int font_header = FONT_TEXT_3;
+ int font_text = FONT_TEXT_2;
+ int xstep = getFontWidth(font_text);
+ int ystep = getFontHeight(font_text);
+ 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
+
+ SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_PROGRAM);
+
+ FadeOut(REDRAW_FIELD);
+
+ ClearWindow();
+ DrawHeadline();
+
+ DrawTextSCentered(100, FONT_TEXT_1, "Version Information:");
+
+ DrawTextF(xstart1, ystart, font_header, "Name");
+ DrawTextF(xstart2, ystart, font_text, PROGRAM_TITLE_STRING);
+
+ ystart += ystep;
+ DrawTextF(xstart1, ystart, font_header, "Version");
+ DrawTextF(xstart2, ystart, font_text, getProgramFullVersionString());
+
+ ystart += ystep;
+ DrawTextF(xstart1, ystart, font_header, "Platform");
+ DrawTextF(xstart2, ystart, font_text, PLATFORM_STRING);
+
+ ystart += ystep;
+ DrawTextF(xstart1, ystart, font_header, "Target");
+ DrawTextF(xstart2, ystart, font_text, TARGET_STRING);
+
+ ystart += ystep;
+ DrawTextF(xstart1, ystart, font_header, "Compile time");
+ DrawTextF(xstart2, ystart, font_text, getCompileDateString());
+
+#if defined(TARGET_SDL)
+ ystart += 3 * ystep;
+ DrawTextF(xstart1, ystart, font_header, "Library");
+ DrawTextF(xstart2, ystart, font_header, "compiled");
+ DrawTextF(xstart3, ystart, font_header, "linked");
+
+ SDL_VERSION(&sdl_version_compiled);
+ sdl_version_linked = SDL_Linked_Version();
+
+ ystart += 2 * ystep;
+ DrawTextF(xstart1, ystart, font_text, "SDL");
+ 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);
+
+ SDL_IMAGE_VERSION(&sdl_version_compiled);
+ sdl_version_linked = IMG_Linked_Version();
+
+ ystart += ystep;
+ DrawTextF(xstart1, ystart, font_text, "SDL_image");
+ 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);
+
+ SDL_MIXER_VERSION(&sdl_version_compiled);
+ sdl_version_linked = Mix_Linked_Version();
+
+ ystart += ystep;
+ DrawTextF(xstart1, ystart, font_text, "SDL_mixer");
+ 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);
+
+ 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, "%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,
+ "Press any key or button for info menu");
+
+ FadeIn(REDRAW_FIELD);
+}
+
+void HandleInfoScreen_Version(int button)
+{
+ if (button == MB_MENU_LEAVE)
+ {
+ PlaySound(SND_MENU_ITEM_SELECTING);
+
+ info_mode = INFO_MODE_MAIN;
+ DrawInfoScreen();
+
+ return;
+ }
+ else if (button == MB_MENU_CHOICE)
+ {
+ PlaySound(SND_MENU_ITEM_SELECTING);
+
+ FadeSoundsAndMusic();
+ FadeOut(REDRAW_FIELD);
+
+ info_mode = INFO_MODE_MAIN;
+ DrawAndFadeInInfoScreen(REDRAW_FIELD);
+ }
+ else
+ {
+ PlayMenuSoundIfLoop();
+ }
+}
+
void DrawInfoScreen_LevelSet()
{
int ystart = 150;
DrawInfoScreen_Credits();
else if (info_mode == INFO_MODE_PROGRAM)
DrawInfoScreen_Program();
+ else if (info_mode == INFO_MODE_VERSION)
+ DrawInfoScreen_Version();
else if (info_mode == INFO_MODE_LEVELSET)
DrawInfoScreen_LevelSet();
else
HandleInfoScreen_Credits(button);
else if (info_mode == INFO_MODE_PROGRAM)
HandleInfoScreen_Program(button);
+ else if (info_mode == INFO_MODE_VERSION)
+ HandleInfoScreen_Version(button);
else if (info_mode == INFO_MODE_LEVELSET)
HandleInfoScreen_LevelSet(button);
else
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);
+ }
}