From: Holger Schemel Date: Wed, 19 Apr 2006 22:15:36 +0000 (+0200) Subject: rnd-20060420-1-src X-Git-Tag: 3.2.0^2~30 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=479bba3c31872d0bf11756a6380988bf787ce5ef;p=rocksndiamonds.git rnd-20060420-1-src * added compatibility code for Juergen Bonhagen's menu artwork settings --- diff --git a/ChangeLog b/ChangeLog index a83ebd68..85e95fc4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2006-04-19 + * added compatibility code for Juergen Bonhagen's menu artwork settings + 2006-04-15 * fixed bug with displaying wrong animation frame 0 after CE changes * fixed bug with creating invisible elements when light switch is on diff --git a/src/conftime.h b/src/conftime.h index 6084c1f0..790fb63b 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2006-04-15 10:02]" +#define COMPILE_DATE_STRING "[2006-04-20 00:14]" diff --git a/src/init.c b/src/init.c index d9de7cfc..9b487df0 100644 --- a/src/init.c +++ b/src/init.c @@ -295,8 +295,11 @@ void InitFontGraphicInfo() font_bitmap_info[font_bitmap_id].src_y = graphic_info[graphic].src_y; font_bitmap_info[font_bitmap_id].width = graphic_info[graphic].width; font_bitmap_info[font_bitmap_id].height = graphic_info[graphic].height; - font_bitmap_info[font_bitmap_id].draw_x = graphic_info[graphic].draw_x; - font_bitmap_info[font_bitmap_id].draw_y = graphic_info[graphic].draw_y; + + font_bitmap_info[font_bitmap_id].draw_xoffset = + graphic_info[graphic].draw_xoffset; + font_bitmap_info[font_bitmap_id].draw_yoffset = + graphic_info[graphic].draw_yoffset; font_bitmap_info[font_bitmap_id].num_chars = graphic_info[graphic].anim_frames; @@ -1063,8 +1066,8 @@ static void set_graphic_parameters(int graphic) graphic_info[graphic].step_delay = parameter[GFX_ARG_STEP_DELAY]; /* this is only used for drawing font characters */ - graphic_info[graphic].draw_x = parameter[GFX_ARG_DRAW_XOFFSET]; - graphic_info[graphic].draw_y = parameter[GFX_ARG_DRAW_YOFFSET]; + graphic_info[graphic].draw_xoffset = parameter[GFX_ARG_DRAW_XOFFSET]; + graphic_info[graphic].draw_yoffset = parameter[GFX_ARG_DRAW_YOFFSET]; /* this is only used for drawing envelope graphics */ graphic_info[graphic].draw_masked = parameter[GFX_ARG_DRAW_MASKED]; diff --git a/src/libgame/system.h b/src/libgame/system.h index 40783a5c..8eb5d9ab 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -561,9 +561,13 @@ struct AudioSystemInfo struct FontBitmapInfo { Bitmap *bitmap; + int src_x, src_y; /* start position of animation frames */ int width, height; /* width/height of each animation frame */ - int draw_x, draw_y; /* offset for drawing font characters */ + + int draw_xoffset; /* offset for drawing font characters */ + int draw_yoffset; /* offset for drawing font characters */ + int num_chars; int num_chars_per_line; diff --git a/src/libgame/text.c b/src/libgame/text.c index 94e4c3c9..45de4987 100644 --- a/src/libgame/text.c +++ b/src/libgame/text.c @@ -130,6 +130,13 @@ void FreeFontInfo(struct FontBitmapInfo *font_bitmap_info) free(font_bitmap_info); } +struct FontBitmapInfo *getFontBitmapInfo(int font_nr) +{ + int font_bitmap_id = gfx.select_font_function(font_nr); + + return &gfx.font_bitmap_info[font_bitmap_id]; +} + int getFontWidth(int font_nr) { int font_bitmap_id = gfx.select_font_function(font_nr); @@ -272,8 +279,8 @@ void DrawTextExt(DrawBuffer *dst_bitmap, int dst_x, int dst_y, char *text, return; /* add offset for drawing font characters */ - dst_x += font->draw_x; - dst_y += font->draw_y; + dst_x += font->draw_xoffset; + dst_y += font->draw_yoffset; while (*text_ptr) { diff --git a/src/libgame/text.h b/src/libgame/text.h index 0c5c7586..7c331d57 100644 --- a/src/libgame/text.h +++ b/src/libgame/text.h @@ -55,6 +55,8 @@ void InitFontInfo(struct FontBitmapInfo *, int, int (*function)(int)); void FreeFontInfo(struct FontBitmapInfo *); +struct FontBitmapInfo *getFontBitmapInfo(int); + int getFontWidth(int); int getFontHeight(int); int getTextWidth(char *, int); diff --git a/src/main.h b/src/main.h index 0f07442c..48f6561a 100644 --- a/src/main.h +++ b/src/main.h @@ -2156,7 +2156,8 @@ struct GraphicInfo int step_offset; /* optional step offset of toon animations */ int step_delay; /* optional step delay of toon animations */ - int draw_x, draw_y; /* optional offset for drawing fonts chars */ + int draw_xoffset; /* optional offset for drawing font chars */ + int draw_yoffset; /* optional offset for drawing font chars */ int draw_masked; /* optional setting for drawing envelope gfx */ diff --git a/src/screens.c b/src/screens.c index 2a59fee7..5fd02c71 100644 --- a/src/screens.c +++ b/src/screens.c @@ -57,13 +57,17 @@ #define MAX_INFO_MODES 6 /* for various menu stuff */ -#define MAX_INFO_ELEMENTS_ON_SCREEN 10 -#define MAX_MENU_ENTRIES_ON_SCREEN (SCR_FIELDY - 2) +#define MENU_SCREEN_START_XPOS 1 #define MENU_SCREEN_START_YPOS 2 #define MENU_SCREEN_VALUE_XPOS 14 #define MENU_SCREEN_MAX_XPOS (SCR_FIELDX - 1) #define MENU_TITLE1_YPOS 8 #define MENU_TITLE2_YPOS 46 +#define MAX_INFO_ELEMENTS_ON_SCREEN 10 +#define MAX_MENU_ENTRIES_ON_SCREEN (SCR_FIELDY - MENU_SCREEN_START_YPOS) +#define MAX_MENU_TEXT_LENGTH_BIG (MENU_SCREEN_VALUE_XPOS - \ + MENU_SCREEN_START_XPOS) +#define MAX_MENU_TEXT_LENGTH_MEDIUM (MAX_MENU_TEXT_LENGTH_BIG * 2) /* buttons and scrollbars identifiers */ #define SCREEN_CTRL_ID_SCROLL_UP 0 @@ -74,6 +78,30 @@ #define NUM_SCREEN_SCROLLBARS 1 #define NUM_SCREEN_GADGETS 3 +/* graphic position and size values for buttons and scrollbars */ +#define SC_SCROLLBUTTON_XSIZE TILEX +#define SC_SCROLLBUTTON_YSIZE TILEY + +#define SC_SCROLLBAR_XPOS (SXSIZE - SC_SCROLLBUTTON_XSIZE) + +#define SC_SCROLL_VERTICAL_XSIZE SC_SCROLLBUTTON_XSIZE +#define SC_SCROLL_VERTICAL_YSIZE ((MAX_MENU_ENTRIES_ON_SCREEN - 2) * \ + SC_SCROLLBUTTON_YSIZE) + +#define SC_SCROLL_UP_XPOS SC_SCROLLBAR_XPOS +#define SC_SCROLL_UP_YPOS (2 * SC_SCROLLBUTTON_YSIZE) + +#define SC_SCROLL_VERTICAL_XPOS SC_SCROLLBAR_XPOS +#define SC_SCROLL_VERTICAL_YPOS (SC_SCROLL_UP_YPOS + \ + SC_SCROLLBUTTON_YSIZE) + +#define SC_SCROLL_DOWN_XPOS SC_SCROLLBAR_XPOS +#define SC_SCROLL_DOWN_YPOS (SC_SCROLL_VERTICAL_YPOS + \ + SC_SCROLL_VERTICAL_YSIZE) + +#define SC_BORDER_SIZE 14 + + /* forward declarations of internal functions */ static void HandleScreenGadgets(struct GadgetInfo *); static void HandleSetupScreen_Generic(int, int, int, int, int); @@ -711,10 +739,11 @@ static void DrawInfoScreen_Main() for (i = 0; info_info[i].type != 0 && i < NUM_MENU_ENTRIES_ON_SCREEN; i++) { + int xpos = MENU_SCREEN_START_XPOS; int ypos = MENU_SCREEN_START_YPOS + i; int font_nr = FONT_MENU_1; - DrawText(mSX + 32, mSY + ypos * 32, info_info[i].text, font_nr); + DrawText(mSX + xpos * 32, mSY + ypos * 32, info_info[i].text, font_nr); if (info_info[i].type & TYPE_ENTER_MENU) initCursor(i, IMG_MENU_BUTTON_ENTER_MENU); @@ -1503,8 +1532,6 @@ static void drawChooseTreeList(int first_entry, int num_page_entries, TreeInfo *ti) { int i; - char buffer[SCR_FIELDX * 2]; - int max_buffer_len = (SCR_FIELDX - 2) * 2; char *title_string = NULL; #if 0 int xoffset_sets = 16; @@ -1544,14 +1571,24 @@ static void drawChooseTreeList(int first_entry, int num_page_entries, /* clear tree list area, but not title or scrollbar */ DrawBackground(mSX, mSY + MENU_SCREEN_START_YPOS * 32, - SXSIZE - 32 + menu.scrollbar_xoffset, + SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset, MAX_MENU_ENTRIES_ON_SCREEN * 32); for (i = 0; i < num_page_entries; i++) { TreeInfo *node, *node_first; int entry_pos = first_entry + i; + int xpos = MENU_SCREEN_START_XPOS; int ypos = MENU_SCREEN_START_YPOS + i; + int startx = mSX + xpos * 32; + int starty = mSY + ypos * 32; + int font_nr = FONT_TEXT_1; + int font_xoffset = getFontBitmapInfo(font_nr)->draw_xoffset; + int startx_text = startx + font_xoffset; + int startx_scrollbar = mSX + SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset; + int text_size = startx_scrollbar - startx_text; + int max_buffer_len = text_size / getFontWidth(font_nr); + char buffer[max_buffer_len + 1]; node_first = getTreeInfoFirstGroupEntry(ti); node = getTreeInfoFromPos(node_first, entry_pos); @@ -1559,7 +1596,7 @@ static void drawChooseTreeList(int first_entry, int num_page_entries, strncpy(buffer, node->name, max_buffer_len); buffer[max_buffer_len] = '\0'; - DrawText(mSX + 32, mSY + ypos * 32, buffer, FONT_TEXT_1 + node->color); + DrawText(startx, starty, buffer, font_nr + node->color); if (node->parent_link) initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU); @@ -2265,12 +2302,41 @@ static Key getSetupKey() return key; } +static int getSetupTextFont(int type) +{ + if (type & (TYPE_SWITCH | + TYPE_YES_NO | + TYPE_STRING | + TYPE_ECS_AGA | + TYPE_KEYTEXT)) + return FONT_MENU_2; + else + return FONT_MENU_1; +} + +static int getSetupValueFont(int type, void *value) +{ + if (type & TYPE_KEY) + return (type & TYPE_QUERY ? FONT_INPUT_1_ACTIVE : FONT_VALUE_1); + else if (type & TYPE_STRING) + return FONT_VALUE_2; + else if (type & TYPE_ECS_AGA) + return FONT_VALUE_1; + else if (type & TYPE_BOOLEAN_STYLE) + return (*(boolean *)value ? FONT_OPTION_ON : FONT_OPTION_OFF); + else + return FONT_VALUE_1; +} + static void drawSetupValue(int pos) { + boolean font_draw_xoffset_modified = FALSE; + int font_draw_xoffset_old = -1; int xpos = MENU_SCREEN_VALUE_XPOS; int ypos = MENU_SCREEN_START_YPOS + pos; - int font_nr = FONT_VALUE_1; - int font_width = getFontWidth(font_nr); + int startx = mSX + xpos * 32; + int starty = mSY + ypos * 32; + int font_nr, font_width; int type = setup_info[pos].type; void *value = setup_info[pos].value; char *value_string = getSetupValue(type, value); @@ -2282,7 +2348,7 @@ static void drawSetupValue(int pos) if (type & TYPE_KEY) { #if 1 - xpos = 1; + xpos = MENU_SCREEN_START_XPOS; #else xpos = 3; #endif @@ -2290,42 +2356,99 @@ static void drawSetupValue(int pos) if (type & TYPE_QUERY) { value_string = ""; +#if 0 font_nr = FONT_INPUT_1_ACTIVE; +#endif } } else if (type & TYPE_STRING) { int max_value_len = (SCR_FIELDX - 2) * 2; - xpos = 1; + xpos = MENU_SCREEN_START_XPOS; +#if 0 font_nr = FONT_VALUE_2; +#endif if (strlen(value_string) > max_value_len) value_string[max_value_len] = '\0'; } else if (type & TYPE_ECS_AGA) { +#if 0 font_nr = FONT_VALUE_1; +#endif } else if (type & TYPE_BOOLEAN_STYLE) { +#if 0 font_nr = (*(boolean *)value ? FONT_OPTION_ON : FONT_OPTION_OFF); +#endif + } + + startx = mSX + xpos * 32; + starty = mSY + ypos * 32; + font_nr = getSetupValueFont(type, value); + font_width = getFontWidth(font_nr); + + /* downward compatibility correction for Juergen Bonhagen's menu settings */ + if (setup_mode != SETUP_MODE_INPUT) + { + int check_font_nr = FONT_OPTION_ON; /* known font that needs correction */ + int font1_xoffset = getFontBitmapInfo(font_nr)->draw_xoffset; + int font2_xoffset = getFontBitmapInfo(check_font_nr)->draw_xoffset; + int text_startx = mSX + MENU_SCREEN_START_XPOS * 32; + int text_font_nr = getSetupTextFont(FONT_MENU_2); + int text_font_xoffset = getFontBitmapInfo(text_font_nr)->draw_xoffset; + int text_width = MAX_MENU_TEXT_LENGTH_MEDIUM * getFontWidth(text_font_nr); + boolean correct_font_draw_xoffset = FALSE; + + if (xpos == MENU_SCREEN_START_XPOS && + startx + font1_xoffset < text_startx + text_font_xoffset) + correct_font_draw_xoffset = TRUE; + + if (xpos == MENU_SCREEN_VALUE_XPOS && + startx + font2_xoffset < text_startx + text_width + text_font_xoffset) + correct_font_draw_xoffset = TRUE; + +#if 0 + printf("::: %d + %d < %d + %d + %d\n", + startx, font_xoffset, text_startx, text_width, text_font_xoffset); + printf("::: => need correction == %d\n", correct_font_draw_xoffset); +#endif + + /* check if setup value would overlap with setup text when printed */ + /* (this can happen for extreme/wrong values for font draw offset) */ + if (correct_font_draw_xoffset) + { + font_draw_xoffset_old = getFontBitmapInfo(font_nr)->draw_xoffset; + font_draw_xoffset_modified = TRUE; + + if (type & TYPE_KEY) + getFontBitmapInfo(font_nr)->draw_xoffset += 2 * getFontWidth(font_nr); + else if (!(type & TYPE_STRING)) + getFontBitmapInfo(font_nr)->draw_xoffset = text_font_xoffset + 20 - + MAX_MENU_TEXT_LENGTH_MEDIUM * (16 - getFontWidth(text_font_nr)); + } } #if 1 for (i = 0; i <= MENU_SCREEN_MAX_XPOS - xpos; i++) - DrawText(mSX + xpos * 32 + i * font_width, mSY + ypos * 32, " ", font_nr); + DrawText(startx + i * font_width, starty, " ", font_nr); #else #if 1 for (i = xpos; i <= MENU_SCREEN_MAX_XPOS; i++) - DrawText(mSX + i * 32, mSY + ypos * 32, " ", font_nr); + DrawText(mSX + i * 32, starty, " ", font_nr); #else - DrawText(mSX + xpos * 32, mSY + ypos * 32, + DrawText(startx, starty, (xpos == 3 ? " " : " "), font_nr); #endif #endif - DrawText(mSX + xpos * 32, mSY + ypos * 32, value_string, font_nr); + DrawText(startx, starty, value_string, font_nr); + + if (font_draw_xoffset_modified) + getFontBitmapInfo(font_nr)->draw_xoffset = font_draw_xoffset_old; } static void changeSetupValue(int pos) @@ -2411,8 +2534,13 @@ static void DrawSetupScreen_Generic() for (i = 0; setup_info[i].type != 0 && i < NUM_MENU_ENTRIES_ON_SCREEN; i++) { void *value_ptr = setup_info[i].value; + int xpos = MENU_SCREEN_START_XPOS; int ypos = MENU_SCREEN_START_YPOS + i; +#if 1 + int font_nr; +#else int font_nr = FONT_MENU_1; +#endif /* set some entries to "unchangeable" according to other variables */ if ((value_ptr == &setup.sound_simple && !audio.sound_available) || @@ -2421,6 +2549,9 @@ static void DrawSetupScreen_Generic() (value_ptr == &setup.fullscreen && !video.fullscreen_available)) setup_info[i].type |= TYPE_GHOSTED; +#if 1 + font_nr = getSetupTextFont(setup_info[i].type); +#else #if 1 if (setup_info[i].type & (TYPE_SWITCH | TYPE_YES_NO | @@ -2431,9 +2562,10 @@ static void DrawSetupScreen_Generic() #else if (setup_info[i].type & TYPE_STRING) font_nr = FONT_MENU_2; +#endif #endif - DrawText(mSX + 32, mSY + ypos * 32, setup_info[i].text, font_nr); + DrawText(mSX + xpos * 32, mSY + ypos * 32, setup_info[i].text, font_nr); if (setup_info[i].type & TYPE_ENTER_MENU) initCursor(i, IMG_MENU_BUTTON_ENTER_MENU); @@ -3194,25 +3326,8 @@ void HandleGameActions() AutoPlayTape(); /* continue automatically playing next tape */ } -/* ---------- new screen button stuff -------------------------------------- */ - -/* graphic position and size values for buttons and scrollbars */ -#define SC_SCROLLBUTTON_XSIZE TILEX -#define SC_SCROLLBUTTON_YSIZE TILEY -#define SC_SCROLL_VERTICAL_XSIZE SC_SCROLLBUTTON_XSIZE -#define SC_SCROLL_VERTICAL_YSIZE ((MAX_MENU_ENTRIES_ON_SCREEN - 2) * \ - SC_SCROLLBUTTON_YSIZE) -#define SC_SCROLL_UP_XPOS (SXSIZE - SC_SCROLLBUTTON_XSIZE) -#define SC_SCROLL_UP_YPOS (2 * SC_SCROLLBUTTON_YSIZE) -#define SC_SCROLL_VERTICAL_XPOS SC_SCROLL_UP_XPOS -#define SC_SCROLL_VERTICAL_YPOS (SC_SCROLL_UP_YPOS + \ - SC_SCROLLBUTTON_YSIZE) -#define SC_SCROLL_DOWN_XPOS SC_SCROLL_UP_XPOS -#define SC_SCROLL_DOWN_YPOS (SC_SCROLL_VERTICAL_YPOS + \ - SC_SCROLL_VERTICAL_YSIZE) - -#define SC_BORDER_SIZE 14 +/* ---------- new screen button stuff -------------------------------------- */ static struct {