From 1786288765edb99711ec0eb06520969879d62cc2 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Thu, 19 Oct 2006 00:37:14 +0200 Subject: [PATCH] rnd-20061019-1-src * added configuration directives for the remaining main menu items --- ChangeLog | 3 + src/conf_gfx.c | 30 +++++++- src/conftime.h | 2 +- src/libgame/misc.c | 7 ++ src/libgame/system.h | 13 +++- src/libgame/text.c | 12 ++++ src/libgame/text.h | 2 + src/main.c | 46 +++++++++--- src/main.h | 65 ++++++++++------- src/screens.c | 168 ++++++++++++++++++++++++++++--------------- src/tools.c | 68 +++++++++++++----- 11 files changed, 303 insertions(+), 113 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9b9c4949..cf03757a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2006-10-18 + * added configuration directives for the remaining main menu items + 2006-10-17 * added additional configuration directives for info screen draw offset: menu.draw_{x,y}offset.INFO[{ELEMENTS,MUSIC,CREDITS,PROGRAM,LEVELSET}] diff --git a/src/conf_gfx.c b/src/conf_gfx.c index c05b068b..3340c89e 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -4584,6 +4584,7 @@ struct ConfigInfo image_config[] = { "main.button.setup.y", "256" }, { "main.button.quit.x", "0" }, { "main.button.quit.y", "288" }, + { "main.button.prev_level.x", "320" }, { "main.button.prev_level.y", "96" }, { "main.button.next_level.x", "448" }, @@ -4593,51 +4594,75 @@ struct ConfigInfo image_config[] = { "main.text.name.y", "-1" }, { "main.text.name.width", "-1" }, { "main.text.name.height", "-1" }, + { "main.text.name.align", "left" }, { "main.text.levels.x", "-1" }, { "main.text.levels.y", "-1" }, { "main.text.levels.width", "-1" }, { "main.text.levels.height", "-1" }, + { "main.text.levels.align", "left" }, { "main.text.scores.x", "-1" }, { "main.text.scores.y", "-1" }, { "main.text.scores.width", "-1" }, { "main.text.scores.height", "-1" }, + { "main.text.scores.align", "left" }, { "main.text.editor.x", "-1" }, { "main.text.editor.y", "-1" }, { "main.text.editor.width", "-1" }, { "main.text.editor.height", "-1" }, + { "main.text.editor.align", "left" }, { "main.text.info.x", "-1" }, { "main.text.info.y", "-1" }, { "main.text.info.width", "-1" }, { "main.text.info.height", "-1" }, + { "main.text.info.align", "left" }, { "main.text.game.x", "-1" }, { "main.text.game.y", "-1" }, { "main.text.game.width", "-1" }, { "main.text.game.height", "-1" }, + { "main.text.game.align", "left" }, { "main.text.setup.x", "-1" }, { "main.text.setup.y", "-1" }, { "main.text.setup.width", "-1" }, { "main.text.setup.height", "-1" }, + { "main.text.setup.align", "left" }, { "main.text.quit.x", "-1" }, { "main.text.quit.y", "-1" }, { "main.text.quit.width", "-1" }, { "main.text.quit.height", "-1" }, + { "main.text.quit.align", "left" }, { "main.text.current_level.x", "352" }, { "main.text.current_level.y", "96" }, + { "main.text.current_level.align", "left" }, { "main.text.first_level.x", "488" }, { "main.text.first_level.y", "98" }, + { "main.text.first_level.align", "left" }, { "main.text.last_level.x", "488" }, { "main.text.last_level.y", "112" }, + { "main.text.last_level.align", "left" }, { "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_2.x", "272" }, { "main.text.level_info_2.y", "523" }, + { "main.text.level_info_2.align", "center" }, + { "main.text.title_1.x", "272" }, + { "main.text.title_1.y", "8" }, + { "main.text.title_1.align", "center" }, + { "main.text.title_2.x", "272" }, + { "main.text.title_2.y", "46" }, + { "main.text.title_2.align", "center" }, + { "main.text.title_3.x", "272" }, + { "main.text.title_3.y", "326" }, + { "main.text.title_3.align", "center" }, { "main.input.name.x", "-1" }, { "main.input.name.y", "-1" }, + { "main.input.name.align", "left" }, - { "preview.x", "148" }, - { "preview.y", "388" }, + { "preview.x", "272" }, + { "preview.y", "380" }, + { "preview.align", "center" }, { "preview.xsize", "66" }, { "preview.ysize", "34" }, { "preview.xoffset", "0" }, @@ -4645,6 +4670,7 @@ struct ConfigInfo image_config[] = { "preview.tile_size", "4" }, { "preview.step_offset", "1" }, { "preview.step_delay", "50" }, + { "preview.anim_mode", "default" }, { "door_1.width", "-1" }, { "door_1.height", "-1" }, diff --git a/src/conftime.h b/src/conftime.h index 5cd11bed..02614da5 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2006-10-18 01:10]" +#define COMPILE_DATE_STRING "[2006-10-19 00:36]" diff --git a/src/libgame/misc.c b/src/libgame/misc.c index ae54541f..ec16eeee 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -1761,6 +1761,12 @@ int get_parameter_value(char *value_raw, char *suffix, int type) strEqual(value, "up") ? MV_UP : strEqual(value, "down") ? MV_DOWN : MV_NONE); } + else if (strEqual(suffix, ".align")) + { + result = (strEqual(value, "left") ? ALIGN_LEFT : + strEqual(value, "right") ? ALIGN_RIGHT : + strEqual(value, "center") ? ALIGN_CENTER : ALIGN_DEFAULT); + } else if (strEqual(suffix, ".anim_mode")) { result = (string_has_parameter(value, "none") ? ANIM_NONE : @@ -1774,6 +1780,7 @@ int get_parameter_value(char *value_raw, char *suffix, int type) string_has_parameter(value, "ce_delay") ? ANIM_CE_DELAY : string_has_parameter(value, "horizontal") ? ANIM_HORIZONTAL : string_has_parameter(value, "vertical") ? ANIM_VERTICAL : + string_has_parameter(value, "centered") ? ANIM_CENTERED : ANIM_DEFAULT); if (string_has_parameter(value, "reverse")) diff --git a/src/libgame/system.h b/src/libgame/system.h index 6a50cea0..6fa176b4 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -194,10 +194,21 @@ /* values for special (non game element) animation modes */ #define ANIM_HORIZONTAL (1 << 10) #define ANIM_VERTICAL (1 << 11) -#define ANIM_STATIC_PANEL (1 << 12) +#define ANIM_CENTERED (1 << 12) +#define ANIM_STATIC_PANEL (1 << 13) #define ANIM_DEFAULT ANIM_LOOP +/* values for text alignment */ +#define ALIGN_LEFT (1 << 0) +#define ALIGN_RIGHT (1 << 1) +#define ALIGN_CENTER (1 << 2) + +#define ALIGN_DEFAULT ALIGN_LEFT + +#define ALIGNED_XPOS(x,w,a) ((a) == ALIGN_CENTER ? (x) - (w) / 2 : \ + (a) == ALIGN_RIGHT ? (x) - (w) : (x)) + /* values for redraw_mask */ #define REDRAW_NONE (0) #define REDRAW_ALL (1 << 0) diff --git a/src/libgame/text.c b/src/libgame/text.c index bfd2a7c4..59c2ba3a 100644 --- a/src/libgame/text.c +++ b/src/libgame/text.c @@ -240,6 +240,18 @@ void DrawTextSCentered(int y, int font_nr, char *text) gfx.sy + y, text, font_nr); } +void DrawTextSAligned(int x, int y, char *text, int font_nr, int align) +{ + DrawText(gfx.sx + ALIGNED_XPOS(x, getTextWidth(text, font_nr), align), + gfx.sx + y, text, font_nr); +} + +void DrawTextAligned(int x, int y, char *text, int font_nr, int align) +{ + DrawText(ALIGNED_XPOS(x, getTextWidth(text, font_nr), align), + y, text, font_nr); +} + void DrawText(int x, int y, char *text, int font_nr) { int mask_mode = BLIT_OPAQUE; diff --git a/src/libgame/text.h b/src/libgame/text.h index f49346e4..b518c562 100644 --- a/src/libgame/text.h +++ b/src/libgame/text.h @@ -68,6 +68,8 @@ void DrawTextF(int, int, int, char *, ...); void DrawTextFCentered(int, int, char *, ...); void DrawTextS(int, int, int, char *); void DrawTextSCentered(int, int, char *); +void DrawTextSAligned(int, int, char *, int, int); +void DrawTextAligned(int, int, char *, int, int); void DrawText(int, int, char *, int); void DrawTextExt(DrawBuffer *, int, int, char *, int, int); void DrawTextToTextArea(int, int, char *, int, int, int, int, int); diff --git a/src/main.c b/src/main.c index 747debeb..ac42d28c 100644 --- a/src/main.c +++ b/src/main.c @@ -4710,6 +4710,7 @@ struct TokenIntPtrInfo image_config_vars[] = { "main.button.setup.y", &menu.main.button.setup.y }, { "main.button.quit.x", &menu.main.button.quit.x }, { "main.button.quit.y", &menu.main.button.quit.y }, + { "main.button.prev_level.x", &menu.main.button.prev_level.x }, { "main.button.prev_level.y", &menu.main.button.prev_level.y }, { "main.button.next_level.x", &menu.main.button.next_level.x }, @@ -4719,51 +4720,75 @@ struct TokenIntPtrInfo image_config_vars[] = { "main.text.name.y", &menu.main.text.name.y }, { "main.text.name.width", &menu.main.text.name.width }, { "main.text.name.height", &menu.main.text.name.height }, + { "main.text.name.align", &menu.main.text.name.align }, { "main.text.levels.x", &menu.main.text.levels.x }, { "main.text.levels.y", &menu.main.text.levels.y }, { "main.text.levels.width", &menu.main.text.levels.width }, { "main.text.levels.height", &menu.main.text.levels.height }, + { "main.text.levels.align", &menu.main.text.levels.align }, { "main.text.scores.x", &menu.main.text.scores.x }, { "main.text.scores.y", &menu.main.text.scores.y }, { "main.text.scores.width", &menu.main.text.scores.width }, { "main.text.scores.height", &menu.main.text.scores.height }, + { "main.text.scores.align", &menu.main.text.scores.align }, { "main.text.editor.x", &menu.main.text.editor.x }, { "main.text.editor.y", &menu.main.text.editor.y }, { "main.text.editor.width", &menu.main.text.editor.width }, { "main.text.editor.height", &menu.main.text.editor.height }, + { "main.text.editor.align", &menu.main.text.editor.align }, { "main.text.info.x", &menu.main.text.info.x }, { "main.text.info.y", &menu.main.text.info.y }, { "main.text.info.width", &menu.main.text.info.width }, { "main.text.info.height", &menu.main.text.info.height }, + { "main.text.info.align", &menu.main.text.info.align }, { "main.text.game.x", &menu.main.text.game.x }, { "main.text.game.y", &menu.main.text.game.y }, { "main.text.game.width", &menu.main.text.game.width }, { "main.text.game.height", &menu.main.text.game.height }, + { "main.text.game.align", &menu.main.text.game.align }, { "main.text.setup.x", &menu.main.text.setup.x }, { "main.text.setup.y", &menu.main.text.setup.y }, { "main.text.setup.width", &menu.main.text.setup.width }, { "main.text.setup.height", &menu.main.text.setup.height }, + { "main.text.setup.align", &menu.main.text.setup.align }, { "main.text.quit.x", &menu.main.text.quit.x }, { "main.text.quit.y", &menu.main.text.quit.y }, { "main.text.quit.width", &menu.main.text.quit.width }, { "main.text.quit.height", &menu.main.text.quit.height }, + { "main.text.quit.align", &menu.main.text.quit.align }, - { "main.text.current_level.x",&menu.main.text.current_level.x }, - { "main.text.current_level.y",&menu.main.text.current_level.y }, - { "main.text.first_level.x", &menu.main.text.first_level.x }, - { "main.text.first_level.y", &menu.main.text.first_level.y }, - { "main.text.last_level.x", &menu.main.text.last_level.x }, - { "main.text.last_level.y", &menu.main.text.last_level.y }, - { "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_2.x", &menu.main.text.level_info_2.x }, - { "main.text.level_info_2.y", &menu.main.text.level_info_2.y }, + { "main.text.current_level.x", &menu.main.text.current_level.x }, + { "main.text.current_level.y", &menu.main.text.current_level.y }, + { "main.text.current_level.align", &menu.main.text.current_level.align }, + { "main.text.first_level.x", &menu.main.text.first_level.x }, + { "main.text.first_level.y", &menu.main.text.first_level.y }, + { "main.text.first_level.align", &menu.main.text.first_level.align }, + { "main.text.last_level.x", &menu.main.text.last_level.x }, + { "main.text.last_level.y", &menu.main.text.last_level.y }, + { "main.text.last_level.align", &menu.main.text.last_level.align }, + { "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_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.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 }, + { "main.text.title_2.x", &menu.main.text.title_2.x }, + { "main.text.title_2.y", &menu.main.text.title_2.y }, + { "main.text.title_2.align", &menu.main.text.title_2.align }, + { "main.text.title_3.x", &menu.main.text.title_3.x }, + { "main.text.title_3.y", &menu.main.text.title_3.y }, + { "main.text.title_3.align", &menu.main.text.title_3.align }, { "main.input.name.x", &menu.main.input.name.x }, { "main.input.name.y", &menu.main.input.name.y }, + { "main.input.name.align", &menu.main.input.name.align }, { "preview.x", &preview.x }, { "preview.y", &preview.y }, + { "preview.align", &preview.align }, { "preview.xsize", &preview.xsize }, { "preview.ysize", &preview.ysize }, { "preview.xoffset", &preview.xoffset }, @@ -4771,6 +4796,7 @@ struct TokenIntPtrInfo image_config_vars[] = { "preview.tile_size", &preview.tile_size }, { "preview.step_offset", &preview.step_offset }, { "preview.step_delay", &preview.step_delay }, + { "preview.anim_mode", &preview.anim_mode }, { "door_1.width", &door_1.width }, { "door_1.height", &door_1.height }, diff --git a/src/main.h b/src/main.h index 3dee9b39..4ef25ab1 100644 --- a/src/main.h +++ b/src/main.h @@ -1761,6 +1761,7 @@ #define PROGRAM_COPYRIGHT_STRING "Copyright ©1995-2006 by Holger Schemel" #define PROGRAM_EMAIL_STRING "info@artsoft.org" #define PROGRAM_WEBSITE_STRING "http://www.artsoft.org/" +#define PROGRAM_GAME_BY_STRING "A Game by Artsoft Entertainment" #define ICON_TITLE_STRING PROGRAM_TITLE_STRING #define COOKIE_PREFIX "ROCKSNDIAMONDS" @@ -1846,42 +1847,52 @@ struct BorderInfo int draw_masked[NUM_SPECIAL_GFX_ARGS]; }; +struct MenuPosInfo +{ + int x, y; + int width, height; + int align; +}; + struct MenuMainButtonInfo { - struct Rect name; - struct Rect levels; - struct Rect scores; - struct Rect editor; - struct Rect info; - struct Rect game; - struct Rect setup; - struct Rect quit; - - struct Rect prev_level; - struct Rect next_level; + 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 prev_level; + struct MenuPosInfo next_level; }; struct MenuMainTextInfo { - struct Rect name; - struct Rect levels; - struct Rect scores; - struct Rect editor; - struct Rect info; - struct Rect game; - struct Rect setup; - struct Rect quit; - - struct Rect current_level; - struct Rect first_level; - struct Rect last_level; - struct Rect level_info_1; - struct Rect level_info_2; + 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 MenuMainInputInfo { - struct Rect name; + struct MenuPosInfo name; }; struct MenuMainInfo @@ -1923,11 +1934,13 @@ struct DoorInfo struct PreviewInfo { int x, y; + int align; int xsize, ysize; int xoffset, yoffset; int tile_size; int step_offset; int step_delay; + int anim_mode; }; struct HiScore diff --git a/src/screens.c b/src/screens.c index eb785c54..ce3bbe47 100644 --- a/src/screens.c +++ b/src/screens.c @@ -213,8 +213,11 @@ static Bitmap *scrollbar_bitmap[NUM_SCROLLBAR_BITMAPS]; #define MAIN_CONTROL_CURRENT_LEVEL 10 #define MAIN_CONTROL_FIRST_LEVEL 11 #define MAIN_CONTROL_LAST_LEVEL 12 -#define MAIN_CONTROL_LEVELSET_INFO 13 -#define MAIN_CONTROL_LEVEL_INFO 14 +#define MAIN_CONTROL_LEVEL_INFO_1 13 +#define MAIN_CONTROL_LEVEL_INFO_2 14 +#define MAIN_CONTROL_TITLE_1 15 +#define MAIN_CONTROL_TITLE_2 16 +#define MAIN_CONTROL_TITLE_3 17 static char main_text_name[10]; static char main_text_current_level[10]; @@ -226,14 +229,14 @@ static struct { int nr; - struct Rect *pos_button; + struct MenuPosInfo *pos_button; int button_graphic; - struct Rect *pos_text; + struct MenuPosInfo *pos_text; char *text; int font_text; - struct Rect *pos_input; + struct MenuPosInfo *pos_input; char *input; int font_input; } @@ -320,17 +323,35 @@ main_controls[] = NULL, NULL, -1, }, { - MAIN_CONTROL_LEVELSET_INFO, + MAIN_CONTROL_LEVEL_INFO_1, NULL, -1, &menu.main.text.level_info_1, NULL, -1, NULL, NULL, -1, }, { - MAIN_CONTROL_LEVEL_INFO, + MAIN_CONTROL_LEVEL_INFO_2, NULL, -1, &menu.main.text.level_info_2, NULL, -1, NULL, NULL, -1, }, + { + MAIN_CONTROL_TITLE_1, + NULL, -1, + &menu.main.text.title_1, PROGRAM_TITLE_STRING, FONT_TITLE_1, + NULL, NULL, -1, + }, + { + MAIN_CONTROL_TITLE_2, + NULL, -1, + &menu.main.text.title_2, PROGRAM_COPYRIGHT_STRING, FONT_TITLE_2, + NULL, NULL, -1, + }, + { + MAIN_CONTROL_TITLE_3, + NULL, -1, + &menu.main.text.title_3, PROGRAM_GAME_BY_STRING, FONT_TITLE_2, + NULL, NULL, -1, + }, { -1, @@ -356,15 +377,15 @@ static void InitializeMainControls() /* set main control screen positions to dynamically determined values */ for (i = 0; main_controls[i].nr != -1; i++) { - int nr = main_controls[i].nr; - struct Rect *pos_button = main_controls[i].pos_button; - struct Rect *pos_text = main_controls[i].pos_text; - struct Rect *pos_input = main_controls[i].pos_input; - char *text = main_controls[i].text; - char *input = main_controls[i].input; - int button_graphic = main_controls[i].button_graphic; - int font_text = main_controls[i].font_text; - int font_input = main_controls[i].font_input; + int nr = main_controls[i].nr; + struct MenuPosInfo *pos_button = main_controls[i].pos_button; + struct MenuPosInfo *pos_text = main_controls[i].pos_text; + struct MenuPosInfo *pos_input = main_controls[i].pos_input; + char *text = main_controls[i].text; + char *input = main_controls[i].input; + int button_graphic = main_controls[i].button_graphic; + int font_text = main_controls[i].font_text; + int font_input = main_controls[i].font_input; int font_text_width = (font_text != -1 ? getFontWidth(font_text) : 0); int font_text_height = (font_text != -1 ? getFontHeight(font_text) : 0); @@ -405,12 +426,15 @@ static void InitializeMainControls() if (pos_text != NULL) { + /* calculate width for non-clickable text -- needed for text alignment */ + boolean calculate_text_width = (pos_button == NULL && text != NULL); + if (pos_text->x == -1 && pos_button != NULL) pos_text->x = pos_button->x + pos_button->width; if (pos_text->y == -1 && pos_button != NULL) pos_text->y = pos_button->y; - if (pos_text->width == -1) + if (pos_text->width == -1 || calculate_text_width) pos_text->width = text_width; if (pos_text->height == -1) pos_text->height = text_height; @@ -437,17 +461,16 @@ static void DrawCursorAndText_Main(int pos, boolean active) for (i = 0; main_controls[i].nr != -1; i++) { - if (main_controls[i].nr == pos) + if (main_controls[i].nr == pos || pos == -1) { - struct Rect *pos_button = main_controls[i].pos_button; - struct Rect *pos_text = main_controls[i].pos_text; - char *text = main_controls[i].text; - int font_text = main_controls[i].font_text; - int button_graphic = main_controls[i].button_graphic; - int button_x = mSX + pos_button->x; - int button_y = mSY + pos_button->y; - int text_x = mSX + pos_text->x; - int text_y = mSY + pos_text->y; + struct MenuPosInfo *pos_button = main_controls[i].pos_button; + struct MenuPosInfo *pos_text = main_controls[i].pos_text; + struct MenuPosInfo *pos_input = main_controls[i].pos_input; + char *text = main_controls[i].text; + char *input = main_controls[i].input; + int button_graphic = main_controls[i].button_graphic; + int font_text = main_controls[i].font_text; + int font_input = main_controls[i].font_input; if (active) { @@ -455,22 +478,46 @@ static void DrawCursorAndText_Main(int pos, boolean active) font_text = FONT_ACTIVE(font_text); } - DrawBackground(button_x, button_y, pos_button->width, pos_button->height); - DrawGraphicThruMaskExt(drawto, button_x, button_y, button_graphic, 0); + if (pos_button != NULL) + { + int button_x = mSX + pos_button->x; + int button_y = mSY + pos_button->y; + + DrawBackground(button_x,button_y, pos_button->width,pos_button->height); + DrawGraphicThruMaskExt(drawto, button_x, button_y, button_graphic, 0); + } + + if (pos_text != NULL && text != NULL) + { + int text_x = mSX + ALIGNED_XPOS(pos_text->x, pos_text->width, + pos_text->align); + int text_y = mSY + pos_text->y; - DrawBackground(text_x, text_y, pos_text->width, pos_text->height); - DrawText(text_x, text_y, text, font_text); + DrawBackground(text_x, text_y, pos_text->width, pos_text->height); + DrawText(text_x, text_y, text, font_text); + } - break; + if (pos_input != NULL && input != NULL) + { + int input_x = mSX + ALIGNED_XPOS(pos_input->x, pos_input->width, + pos_input->align); + int input_y = mSY + pos_input->y; + + DrawBackground(input_x, input_y, pos_input->width, pos_input->height); + DrawText(input_x, input_y, input, font_input); + } } } } -static boolean insideRect(struct Rect *rect, int x, int y) +static boolean insideMenuPosRect(struct MenuPosInfo *rect, int x, int y) { + int rect_x = ALIGNED_XPOS(rect->x, rect->width, rect->align); + int rect_y = rect->y; + return (rect != NULL && - x >= rect->x && x < rect->x + rect->width && - y >= rect->y && y < rect->y + rect->height); + 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) @@ -516,7 +563,7 @@ static void drawChooseTreeCursor(int ypos, boolean active) /* force LEVELS draw offset on artwork setup screen */ game_status = GAME_MODE_LEVELS; - drawCursorExt(0, ypos, active, 0); + drawCursorExt(0, ypos, active, -1); game_status = last_game_status; /* restore current game status */ } @@ -608,7 +655,9 @@ void DrawMainMenuExt(int redraw_mask, boolean do_fading) char *name_text = (local_team_mode ? "Team:" : "Name:"); int name_width, level_width; #endif +#if 0 int i; +#endif UnmapAllGadgets(); FadeSoundsAndMusic(); @@ -675,21 +724,22 @@ void DrawMainMenuExt(int redraw_mask, boolean do_fading) SetMainBackgroundImage(IMG_BACKGROUND_MAIN); ClearWindow(); - DrawHeadline(); - #if 1 InitializeMainControls(); +#if 1 + DrawCursorAndText_Main(-1, FALSE); +#else for (i = 0; main_controls[i].nr != -1; i++) { - struct Rect *pos_button = main_controls[i].pos_button; - struct Rect *pos_text = main_controls[i].pos_text; - struct Rect *pos_input = main_controls[i].pos_input; - char *text = main_controls[i].text; - char *input = main_controls[i].input; - int button_graphic = main_controls[i].button_graphic; - int font_text = main_controls[i].font_text; - int font_input = main_controls[i].font_input; + struct MenuPosInfo *pos_button = main_controls[i].pos_button; + struct MenuPosInfo *pos_text = main_controls[i].pos_text; + struct MenuPosInfo *pos_input = main_controls[i].pos_input; + char *text = main_controls[i].text; + char *input = main_controls[i].input; + int button_graphic = main_controls[i].button_graphic; + int font_text = main_controls[i].font_text; + int font_input = main_controls[i].font_input; if (pos_button != NULL) DrawGraphicThruMaskExt(drawto, mSX + pos_button->x, mSY + pos_button->y, @@ -701,9 +751,12 @@ void DrawMainMenuExt(int redraw_mask, boolean do_fading) if (pos_input != NULL && input != NULL) DrawText(mSX + pos_input->x, mSY + pos_input->y, input, font_input); } +#endif #else + DrawHeadline(); + DrawText(mSX + 32, mSY + 2 * 32, name_text, FONT_MENU_1); DrawText(mSX + 32, mSY + 3 * 32, "Levelset", FONT_MENU_1); DrawText(mSX + 32, mSY + 4 * 32, "Hall Of Fame", FONT_MENU_1); @@ -738,12 +791,12 @@ void DrawMainMenuExt(int redraw_mask, boolean do_fading) for (i = 0; i < 8; i++) initCursor(i, (i == 1 || i == 4 || i == 6 ? IMG_MENU_BUTTON_ENTER_MENU : IMG_MENU_BUTTON)); + + DrawTextSCentered(326, FONT_TITLE_2, PROGRAM_GAME_BY_STRING); #endif DrawPreviewLevel(TRUE); - DrawTextSCentered(326, FONT_TITLE_2, "A Game by Artsoft Entertainment"); - HandleMainMenu(0, 0, 0, 0, MB_MENU_INITIALIZE); TapeStop(); @@ -985,9 +1038,9 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) for (i = 0; main_controls[i].nr != -1; i++) { - if (insideRect(main_controls[i].pos_button, mx - mSX, my - mSY) || - insideRect(main_controls[i].pos_text, mx - mSX, my - mSY) || - insideRect(main_controls[i].pos_input, mx - mSX, my - mSY)) + if (insideMenuPosRect(main_controls[i].pos_button, mx - mSX, my - mSY) || + insideMenuPosRect(main_controls[i].pos_text, mx - mSX, my - mSY) || + insideMenuPosRect(main_controls[i].pos_input, mx - mSX, my - mSY)) { pos = main_controls[i].nr; @@ -2530,7 +2583,7 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, drawChooseTreeList(ti->cl_first, num_page_entries, ti); drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti); - drawChooseTreeCursor(ti->cl_cursor, FC_RED); + drawChooseTreeCursor(ti->cl_cursor, TRUE); return; } @@ -2598,7 +2651,8 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, drawChooseTreeList(ti->cl_first, num_page_entries, ti); drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti); - drawChooseTreeCursor(ti->cl_cursor, FC_RED); + drawChooseTreeCursor(ti->cl_cursor, TRUE); + AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, ti->cl_first, ti); } @@ -2612,7 +2666,8 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, drawChooseTreeList(ti->cl_first, num_page_entries, ti); drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti); - drawChooseTreeCursor(ti->cl_cursor, FC_RED); + drawChooseTreeCursor(ti->cl_cursor, TRUE); + AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, ti->cl_first, ti); } @@ -2659,9 +2714,10 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, { if (y != ti->cl_cursor) { - drawChooseTreeCursor(y, FC_RED); - drawChooseTreeCursor(ti->cl_cursor, FC_BLUE); + drawChooseTreeCursor(ti->cl_cursor, FALSE); + drawChooseTreeCursor(y, TRUE); drawChooseTreeInfo(ti->cl_first + y, ti); + ti->cl_cursor = y; } } diff --git a/src/tools.c b/src/tools.c index 85cee1dd..41ed06d6 100644 --- a/src/tools.c +++ b/src/tools.c @@ -1670,8 +1670,6 @@ void DrawMiniLevel(int size_x, int size_y, int scroll_x, int scroll_y) static void DrawPreviewLevelExt(int from_x, int from_y) { boolean show_level_border = (BorderElement != EL_EMPTY); - int dst_x = preview.x; - int dst_y = preview.y; int level_xsize = lev_fieldx + (show_level_border ? 2 : 0); int level_ysize = lev_fieldy + (show_level_border ? 2 : 0); int tile_size = preview.tile_size; @@ -1679,6 +1677,8 @@ static void DrawPreviewLevelExt(int from_x, int from_y) int preview_height = preview.ysize * tile_size; int real_preview_xsize = MIN(level_xsize, preview.xsize); int real_preview_ysize = MIN(level_ysize, preview.ysize); + int dst_x = SX + ALIGNED_XPOS(preview.x, preview_width, preview.align); + int dst_y = SY + preview.y; int x, y; DrawBackground(dst_x, dst_y, preview_width, preview_height); @@ -1712,8 +1712,24 @@ static void DrawPreviewLevelExt(int from_x, int from_y) #define MICROLABEL_IMPORTED_BY_HEAD 6 #define MICROLABEL_IMPORTED_BY 7 +static int getMaxTextLength(struct MenuPosInfo *pos, int font_nr) +{ + int max_text_width = SXSIZE; + int font_width = getFontWidth(font_nr); + + if (pos->align == ALIGN_CENTER) + max_text_width = (pos->x < SXSIZE / 2 ? pos->x * 2 : (SXSIZE - pos->x) * 2); + else if (pos->align == ALIGN_RIGHT) + max_text_width = pos->x; + else + max_text_width = SXSIZE - pos->x; + + return max_text_width / font_width; +} + static void DrawPreviewLevelLabelExt(int mode) { + struct MenuPosInfo *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; @@ -1724,7 +1740,11 @@ static void DrawPreviewLevelLabelExt(int mode) mode == MICROLABEL_IMPORTED_BY_HEAD) font_nr = FONT_TEXT_3; +#if 1 + max_len_label_text = getMaxTextLength(pos, font_nr); +#else max_len_label_text = SXSIZE / getFontWidth(font_nr); +#endif for (i = 0; i < max_len_label_text; i++) label_text[i] = ' '; @@ -1733,15 +1753,13 @@ static void DrawPreviewLevelLabelExt(int mode) if (strlen(label_text) > 0) { #if 1 - int text_width = getTextWidth(label_text, font_nr); - int lxpos = SX + menu.main.text.level_info_2.x - text_width / 2; - int lypos = SY + menu.main.text.level_info_2.y; + DrawTextSAligned(pos->x, pos->y, label_text, font_nr, pos->align); #else int lxpos = SX + (SXSIZE - getTextWidth(label_text, font_nr)) / 2; int lypos = MICROLABEL2_YPOS; -#endif DrawText(lxpos, lypos, label_text, font_nr); +#endif } strncpy(label_text, @@ -1758,15 +1776,13 @@ static void DrawPreviewLevelLabelExt(int mode) if (strlen(label_text) > 0) { #if 1 - int text_width = getTextWidth(label_text, font_nr); - int lxpos = SX + menu.main.text.level_info_2.x - text_width / 2; - int lypos = SY + menu.main.text.level_info_2.y; + DrawTextSAligned(pos->x, pos->y, label_text, font_nr, pos->align); #else int lxpos = SX + (SXSIZE - getTextWidth(label_text, font_nr)) / 2; int lypos = MICROLABEL2_YPOS; -#endif DrawText(lxpos, lypos, label_text, font_nr); +#endif } redraw_mask |= REDRAW_MICROLEVEL; @@ -1789,8 +1805,20 @@ void DrawPreviewLevel(boolean restart) if (restart) { - from_x = preview.xoffset; - from_y = preview.yoffset; + from_x = 0; + from_y = 0; + + if (preview.anim_mode == ANIM_CENTERED) + { + if (level_xsize > preview.xsize) + from_x = (level_xsize - preview.xsize) / 2; + if (level_ysize > preview.ysize) + from_y = (level_ysize - preview.ysize) / 2; + } + + from_x += preview.xoffset; + from_y += preview.yoffset; + scroll_direction = MV_RIGHT; label_state = 1; label_counter = 0; @@ -1804,25 +1832,30 @@ void DrawPreviewLevel(boolean restart) if (leveldir_current->name) { + struct MenuPosInfo *pos = &menu.main.text.level_info_1; char label_text[MAX_OUTPUT_LINESIZE + 1]; int font_nr = FONT_TEXT_1; +#if 1 + int max_len_label_text = getMaxTextLength(pos, font_nr); +#else int max_len_label_text = SXSIZE / getFontWidth(font_nr); +#endif +#if 0 int text_width; int lxpos, lypos; +#endif strncpy(label_text, leveldir_current->name, max_len_label_text); label_text[max_len_label_text] = '\0'; #if 1 - text_width = getTextWidth(label_text, font_nr); - lxpos = SX + menu.main.text.level_info_1.x - text_width / 2; - lypos = SY + menu.main.text.level_info_1.y; + DrawTextSAligned(pos->x, pos->y, label_text, font_nr, pos->align); #else lxpos = SX + (SXSIZE - getTextWidth(label_text, font_nr)) / 2; lypos = SY + MICROLABEL1_YPOS; -#endif DrawText(lxpos, lypos, label_text, font_nr); +#endif } game_status = last_game_status; /* restore current game status */ @@ -1831,7 +1864,8 @@ void DrawPreviewLevel(boolean restart) } /* scroll preview level, if needed */ - if ((level_xsize > preview.xsize || level_ysize > preview.ysize) && + if (preview.anim_mode != ANIM_NONE && + (level_xsize > preview.xsize || level_ysize > preview.ysize) && DelayReached(&scroll_delay, scroll_delay_value)) { switch (scroll_direction) -- 2.34.1