From 150ddded12f89d95a8c14a159270f42069ec4084 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Fri, 26 Jan 2018 04:34:51 +0000 Subject: [PATCH] New userdef structure: "statusbarflags", "statusbarrange", "statusbarcustom" "statusbarflags" is a bitfield. Values are: STATUSBAR_NONONE = 1 STATUSBAR_NOMINI = 2 STATUSBAR_NOFULL = 4 STATUSBAR_NOSHRINK = 8 STATUSBAR_NOFRAGBAR = 16 STATUSBAR_NOOVERLAY = 32 STATUSBAR_NOMODERN = 64 Default value is 8. In case you modify it, you also have to set the other status bar related userdefs in EVENT_SETDEFAULTS. Default values in EDuke32 are: screen_size = 4; statusbarmode = 1; althud = 1; "statusbarrange" is used to add more alternatives for the status bar without breaking the option in the menu. If used, the mini status bar (screen_size = 4) will cycle through "statusbarcustom" when changing the screen size. Also fix the size of the viewport when the screen is shrunk and the scale of the status bar is not 100%. Patch from Fox. git-svn-id: https://svn.eduke32.com/eduke32@6587 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/duke3d/src/config.cpp | 1 + source/duke3d/src/game.cpp | 56 +++++++++++++++++++++++----- source/duke3d/src/game.h | 11 ++++++ source/duke3d/src/gamedef.cpp | 3 ++ source/duke3d/src/gamedef.h | 3 ++ source/duke3d/src/gamestructures.cpp | 6 +++ source/duke3d/src/menus.cpp | 21 +++++++++-- source/duke3d/src/premap.cpp | 42 ++++++++++++--------- source/duke3d/src/premap.h | 1 + source/duke3d/src/sbar.cpp | 16 +++----- source/duke3d/src/screentext.cpp | 2 +- 11 files changed, 120 insertions(+), 42 deletions(-) diff --git a/source/duke3d/src/config.cpp b/source/duke3d/src/config.cpp index d6e471f4b..a89a0845d 100644 --- a/source/duke3d/src/config.cpp +++ b/source/duke3d/src/config.cpp @@ -228,6 +228,7 @@ void CONFIG_SetDefaults(void) ud.screen_size = 4; ud.screen_tilting = 1; ud.shadows = 1; + ud.statusbarflags = STATUSBAR_NOSHRINK; ud.statusbarmode = 1; ud.statusbarscale = 100; ud.team = 0; diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index 9cbb2ce2a..7ce057703 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -4408,13 +4408,38 @@ void G_SetViewportShrink(int32_t dir) { if (dir!=0) { - if (ud.screen_size == 8 && (dir>0)==(int32_t)ud.statusbarmode) - ud.statusbarmode = !ud.statusbarmode; - else - if (ud.screen_size == 4 && (dir>0)==(int32_t)ud.althud) - ud.althud = !ud.althud; - else - ud.screen_size += dir; + if (dir > 0) // shrinking + { + if (ud.screen_size < 4 && (!(ud.statusbarflags & STATUSBAR_NOMINI) || !(ud.statusbarflags & STATUSBAR_NOMODERN))) + ud.screen_size = 4; + else if (ud.screen_size == 4 && ud.althud == 1 && !(ud.statusbarflags & STATUSBAR_NOMINI)) + ud.althud = 0; + else if (ud.screen_size == 4 && ud.statusbarcustom < ud.statusbarrange && !(ud.statusbarflags & STATUSBAR_NOMINI)) + ud.statusbarcustom += 1; + else if (ud.screen_size < 8 && (!(ud.statusbarflags & STATUSBAR_NOFULL) || !(ud.statusbarflags & STATUSBAR_NOOVERLAY))) + ud.screen_size = 8; + else if (ud.screen_size == 8 && ud.statusbarmode == 1 && !(ud.statusbarflags & STATUSBAR_NOFULL)) + ud.statusbarmode = 0; + else if (ud.screen_size < 64 && !(ud.statusbarflags & STATUSBAR_NOSHRINK)) + ud.screen_size += dir; + } + else // enlarging + { + if (ud.screen_size > 12) + ud.screen_size += dir; + else if (ud.screen_size > 8 && (!(ud.statusbarflags & STATUSBAR_NOFULL) || !(ud.statusbarflags & STATUSBAR_NOOVERLAY))) + ud.screen_size = 8; + else if (ud.screen_size == 8 && ud.statusbarmode == 0 && !(ud.statusbarflags & STATUSBAR_NOOVERLAY)) + ud.statusbarmode = 1; + else if (ud.screen_size > 4 && (!(ud.statusbarflags & STATUSBAR_NOMINI) || !(ud.statusbarflags & STATUSBAR_NOMODERN))) + ud.screen_size = 4; + else if (ud.screen_size == 4 && ud.statusbarcustom > 0) + ud.statusbarcustom -= 1; + else if (ud.screen_size == 4 && ud.althud == 0 && !(ud.statusbarflags & STATUSBAR_NOMODERN)) + ud.althud = 1; + else if (ud.screen_size > 0 && !(ud.statusbarflags & STATUSBAR_NONONE)) + ud.screen_size = 0; + } } G_UpdateScreenArea(); } @@ -4491,7 +4516,14 @@ void G_HandleLocalKeys(void) if (!SHIFTS_IS_PRESSED) { - if (ud.screen_size > 0) + // conditions copied from G_SetViewportShrink + if ((ud.screen_size > 12) || + (ud.screen_size > 8 && (!(ud.statusbarflags & STATUSBAR_NOFULL) || !(ud.statusbarflags & STATUSBAR_NOOVERLAY))) || + (ud.screen_size == 8 && ud.statusbarmode == 0 && !(ud.statusbarflags & STATUSBAR_NOOVERLAY)) || + (ud.screen_size > 4 && (!(ud.statusbarflags & STATUSBAR_NOMINI) || !(ud.statusbarflags & STATUSBAR_NOMODERN))) || + (ud.screen_size == 4 && ud.statusbarcustom > 0) || + (ud.screen_size == 4 && ud.althud == 0 && !(ud.statusbarflags & STATUSBAR_NOMODERN)) || + (ud.screen_size > 0 && !(ud.statusbarflags & STATUSBAR_NONONE))) { S_PlaySound(THUD); G_SetViewportShrink(-4); @@ -4511,7 +4543,13 @@ void G_HandleLocalKeys(void) if (!SHIFTS_IS_PRESSED) { - if (ud.screen_size < 8 || (ud.screen_size == 8 && ud.statusbarmode)) + // conditions copied from G_SetViewportShrink + if ((ud.screen_size < 4 && (!(ud.statusbarflags & STATUSBAR_NOMINI) || !(ud.statusbarflags & STATUSBAR_NOMODERN))) || + (ud.screen_size == 4 && ud.althud == 1 && !(ud.statusbarflags & STATUSBAR_NOMINI)) || + (ud.screen_size == 4 && ud.statusbarcustom < ud.statusbarrange && !(ud.statusbarflags & STATUSBAR_NOMINI)) || + (ud.screen_size < 8 && (!(ud.statusbarflags & STATUSBAR_NOFULL) || !(ud.statusbarflags & STATUSBAR_NOOVERLAY))) || + (ud.screen_size == 8 && ud.statusbarmode == 1 && !(ud.statusbarflags & STATUSBAR_NOFULL)) || + (ud.screen_size < 64 && !(ud.statusbarflags & STATUSBAR_NOSHRINK))) { S_PlaySound(THUD); G_SetViewportShrink(+4); diff --git a/source/duke3d/src/game.h b/source/duke3d/src/game.h index bd3549d8d..3370da2fb 100644 --- a/source/duke3d/src/game.h +++ b/source/duke3d/src/game.h @@ -98,6 +98,16 @@ enum LogoFlags_t { LOGO_NOTITLEBAR = 0x00800000, }; +enum { + STATUSBAR_NONONE = 0x00000001, + STATUSBAR_NOMINI = 0x00000002, + STATUSBAR_NOFULL = 0x00000004, + STATUSBAR_NOSHRINK = 0x00000008, + STATUSBAR_NOFRAGBAR = 0x00000010, + STATUSBAR_NOOVERLAY = 0x00000020, + STATUSBAR_NOMODERN = 0x00000040, +}; + void A_DeleteSprite(int spriteNum); static inline int32_t G_GetLogoFlags(void) @@ -150,6 +160,7 @@ typedef struct { int32_t democams,color,msgdisptime,statusbarmode; int32_t m_noexits,noexits,autovote,automsg,idplayers; int32_t team, viewbob, weaponsway, althud, weaponscale, textscale; + int32_t statusbarflags, statusbarrange, statusbarcustom; int32_t screenarea_x1, screenarea_y1, screenarea_x2, screenarea_y2; int32_t entered_name,screen_tilting,shadows,fta_on,executions,auto_run; diff --git a/source/duke3d/src/gamedef.cpp b/source/duke3d/src/gamedef.cpp index 90eee258b..ec44cdd11 100644 --- a/source/duke3d/src/gamedef.cpp +++ b/source/duke3d/src/gamedef.cpp @@ -1236,6 +1236,9 @@ const memberlabel_t UserdefsLabels[]= { "screenarea_y2", USERDEFS_SCREENAREA_Y2, 0, 0 }, { "screenfade", USERDEFS_SCREENFADE, 0, 0 }, { "menubackground", USERDEFS_MENUBACKGROUND, 0, 0 }, + { "statusbarflags", USERDEFS_STATUSBARFLAGS, 0, 0 }, + { "statusbarrange", USERDEFS_STATUSBARRANGE, 0, 0 }, + { "statusbarcustom", USERDEFS_STATUSBARCUSTOM, 0, 0 }, { NULL, -1, 0, 0 } // END OF LIST }; diff --git a/source/duke3d/src/gamedef.h b/source/duke3d/src/gamedef.h index a5a8a174b..ec594e2f0 100644 --- a/source/duke3d/src/gamedef.h +++ b/source/duke3d/src/gamedef.h @@ -534,6 +534,9 @@ enum UserdefsLabel_t USERDEFS_SCREENAREA_Y2, USERDEFS_SCREENFADE, USERDEFS_MENUBACKGROUND, + USERDEFS_STATUSBARFLAGS, + USERDEFS_STATUSBARRANGE, + USERDEFS_STATUSBARCUSTOM, USERDEFS_END }; diff --git a/source/duke3d/src/gamestructures.cpp b/source/duke3d/src/gamestructures.cpp index ae6077cf8..1518c0914 100644 --- a/source/duke3d/src/gamestructures.cpp +++ b/source/duke3d/src/gamestructures.cpp @@ -178,6 +178,9 @@ int32_t __fastcall VM_GetUserdef(int32_t labelNum) case USERDEFS_SCREENAREA_Y2: labelNum = ud.screenarea_y2; break; case USERDEFS_SCREENFADE: labelNum = ud.screenfade; break; case USERDEFS_MENUBACKGROUND: labelNum = ud.menubackground; break; + case USERDEFS_STATUSBARFLAGS: labelNum = ud.statusbarflags; break; + case USERDEFS_STATUSBARRANGE: labelNum = ud.statusbarrange; break; + case USERDEFS_STATUSBARCUSTOM: labelNum = ud.statusbarcustom; break; default: labelNum = -1; break; } @@ -306,6 +309,9 @@ void __fastcall VM_SetUserdef(int32_t const labelNum, int32_t const iSet) case USERDEFS_SCREENAREA_Y2: ud.screenarea_y2 = iSet; break; case USERDEFS_SCREENFADE: ud.screenfade = iSet; break; case USERDEFS_MENUBACKGROUND: ud.menubackground = iSet; break; + case USERDEFS_STATUSBARFLAGS: ud.statusbarflags = iSet; break; + case USERDEFS_STATUSBARRANGE: ud.statusbarrange = iSet; break; + case USERDEFS_STATUSBARCUSTOM: ud.statusbarcustom = iSet; break; default: break; } } diff --git a/source/duke3d/src/menus.cpp b/source/duke3d/src/menus.cpp index 0722dad95..603c6fd7e 100644 --- a/source/duke3d/src/menus.cpp +++ b/source/duke3d/src/menus.cpp @@ -573,7 +573,7 @@ static MenuRangeInt32_t MEO_SCREENSETUP_CROSSHAIRSIZE = MAKE_MENURANGE( &ud.cros static MenuEntry_t ME_SCREENSETUP_CROSSHAIRSIZE = MAKE_MENUENTRY( s_Scale, &MF_Redfont, &MEF_BigOptions_Apply, &MEO_SCREENSETUP_CROSSHAIRSIZE, RangeInt32 ); static int32_t vpsize; -static MenuRangeInt32_t MEO_SCREENSETUP_SCREENSIZE = MAKE_MENURANGE( &vpsize, &MF_Redfont, 16, 0, 0, 5, EnforceIntervals ); +static MenuRangeInt32_t MEO_SCREENSETUP_SCREENSIZE = MAKE_MENURANGE( &vpsize, &MF_Redfont, 0, 0, 0, 1, EnforceIntervals ); static MenuEntry_t ME_SCREENSETUP_SCREENSIZE = MAKE_MENUENTRY( "Screen size:", &MF_Redfont, &MEF_BigOptionsRt, &MEO_SCREENSETUP_SCREENSIZE, RangeInt32 ); static MenuRangeInt32_t MEO_SCREENSETUP_TEXTSIZE = MAKE_MENURANGE( &ud.textscale, &MF_Redfont, 100, 400, 0, 16, 2 ); static MenuEntry_t ME_SCREENSETUP_TEXTSIZE = MAKE_MENUENTRY( s_Scale, &MF_Redfont, &MEF_BigOptions_Apply, &MEO_SCREENSETUP_TEXTSIZE, RangeInt32 ); @@ -1853,7 +1853,22 @@ static void Menu_Pre(MenuID_t cm) else MenuMenu_ChangeEntryList(M_DISPLAYSETUP, MEL_DISPLAYSETUP_GL); - vpsize = ud.screen_size + 4*(ud.screen_size>=8 && ud.statusbarmode==0) + 4*(ud.screen_size>=4 && ud.althud==0); + MEO_SCREENSETUP_SCREENSIZE.steps = !(ud.statusbarflags & STATUSBAR_NONONE) + + !(ud.statusbarflags & STATUSBAR_NOMODERN) + + !(ud.statusbarflags & STATUSBAR_NOMINI) * (ud.statusbarrange + 1) + + !(ud.statusbarflags & STATUSBAR_NOOVERLAY) + + !(ud.statusbarflags & STATUSBAR_NOFULL) + + !(ud.statusbarflags & STATUSBAR_NOSHRINK) * 14; + MEO_SCREENSETUP_SCREENSIZE.min = MEO_SCREENSETUP_SCREENSIZE.steps - 1; + MenuEntry_DisableOnCondition(&ME_SCREENSETUP_SCREENSIZE, (MEO_SCREENSETUP_SCREENSIZE.steps < 2)); + + vpsize = !(ud.statusbarflags & STATUSBAR_NONONE) + + (ud.screen_size >= 4 && !(ud.statusbarflags & STATUSBAR_NOMODERN)) + + (ud.screen_size >= 4 && ud.althud == 0 && !(ud.statusbarflags & STATUSBAR_NOMINI)) * (ud.statusbarcustom + 1) + + (ud.screen_size >= 8 && !(ud.statusbarflags & STATUSBAR_NOOVERLAY)) + + (ud.screen_size >= 8 && ud.statusbarmode == 0 && !(ud.statusbarflags & STATUSBAR_NOFULL)) + + (ud.screen_size > 8 && !(ud.statusbarflags & STATUSBAR_NOSHRINK)) * ((ud.screen_size - 8) >> 2) + -1; if (getrendermode() != REND_CLASSIC) { @@ -3115,7 +3130,7 @@ static void Menu_Custom2ColScreen(/*MenuEntry_t *entry*/) static int32_t Menu_EntryRangeInt32Modify(MenuEntry_t *entry, int32_t newValue) { if (entry == &ME_SCREENSETUP_SCREENSIZE) - G_SetViewportShrink(newValue - vpsize); + G_SetViewportShrink((newValue - vpsize) * 4); else if (entry == &ME_SCREENSETUP_SBARSIZE) G_SetStatusBarScale(newValue); else if (entry == &ME_SOUND_VOLUME_MASTER) diff --git a/source/duke3d/src/premap.cpp b/source/duke3d/src/premap.cpp index 16c83aa84..dfa0e1e08 100644 --- a/source/duke3d/src/premap.cpp +++ b/source/duke3d/src/premap.cpp @@ -558,6 +558,26 @@ void G_CacheMapData(void) OSD_Printf("Cache time: %dms\n", endtime-starttime); } +extern int32_t fragbarheight(void) +{ + if (ud.screen_size > 0 && !(ud.statusbarflags & STATUSBAR_NOFRAGBAR) +#ifdef SPLITSCREEN_MOD_HACKS + && !g_fakeMultiMode +#endif + && (g_netServer || ud.multimode > 1) && GTFLAGS(GAMETYPE_FRAGBAR)) + { + int32_t i, j = 0; + + for (TRAVERSE_CONNECT(i)) + if (i > j) + j = i; + + return ((j + 3) >> 2) << 3; + } + + return 0; +} + void G_UpdateScreenArea(void) { if (!in3dmode()) @@ -573,27 +593,13 @@ void G_UpdateScreenArea(void) int32_t x1 = scale(ss,xdim,160); int32_t x2 = xdim-x1; - int32_t y1 = ss; - int32_t y2 = 200-ss; + int32_t y1 = scale(ss,(200 * 100) - (tilesiz[BOTTOMSTATUSBAR].y * ud.statusbarscale),200 - tilesiz[BOTTOMSTATUSBAR].y); + int32_t y2 = 200*100-y1; - if (ud.screen_size > 0 && (g_gametypeFlags[ud.coop]&GAMETYPE_FRAGBAR) && (g_netServer || ud.multimode > 1)) - { - int32_t i, j = 0; - - for (TRAVERSE_CONNECT(i)) - if (i > j) j = i; - - if (j > 0) y1 += 8; - if (j > 4) y1 += 8; - if (j > 8) y1 += 8; - if (j > 12) y1 += 8; - } - - y2 *= 100; + y1 += fragbarheight()*100; if (ud.screen_size >= 8 && ud.statusbarmode==0) y2 -= tilesiz[BOTTOMSTATUSBAR].y*ud.statusbarscale; - - y1 = scale(y1,ydim,200); + y1 = scale(y1,ydim,200*100); y2 = scale(y2,ydim,200*100); if (VM_HaveEvent(EVENT_UPDATESCREENAREA)) diff --git a/source/duke3d/src/premap.h b/source/duke3d/src/premap.h index 0d8fdf75c..69853843e 100644 --- a/source/duke3d/src/premap.h +++ b/source/duke3d/src/premap.h @@ -55,6 +55,7 @@ void P_ResetStatus(int playerNum); void P_ResetWeapons(int playerNum); void G_ClearFIFO(void); void G_ResetInterpolations(void); +extern int32_t fragbarheight(void); #ifdef __cplusplus } diff --git a/source/duke3d/src/sbar.cpp b/source/duke3d/src/sbar.cpp index a330104e1..8bf0f4e00 100644 --- a/source/duke3d/src/sbar.cpp +++ b/source/duke3d/src/sbar.cpp @@ -465,6 +465,9 @@ void G_DrawInventory(const DukePlayer_t *p) void G_DrawFrags(void) { + if (ud.statusbarflags & STATUSBAR_NOFRAGBAR) + return; + int32_t i, j = 0; const int32_t orient = 2+8+16+64; @@ -1067,18 +1070,9 @@ void G_DrawBackground(void) return; } - if (ud.screen_size > 0 && (g_gametypeFlags[ud.coop]&GAMETYPE_FRAGBAR) && (g_netServer || ud.multimode > 1)) + y1 = fragbarheight(); + if (y1 != 0) { - int32_t i, j = 0; - - for (TRAVERSE_CONNECT(i)) - if (i > j) j = i; - - if (j > 0) y1 += 8; - if (j > 4) y1 += 8; - if (j > 8) y1 += 8; - if (j > 12) y1 += 8; - y1 = scale(ydim, y1, 200); y1 -= ((tilesiz[dapicnum].y / y1) +1) * tilesiz[dapicnum].y; } diff --git a/source/duke3d/src/screentext.cpp b/source/duke3d/src/screentext.cpp index e825864f7..bbe78577c 100644 --- a/source/duke3d/src/screentext.cpp +++ b/source/duke3d/src/screentext.cpp @@ -1064,7 +1064,7 @@ void G_PrintGameQuotes(int32_t snum) const int32_t reserved_quote = (ps->ftq >= QUOTE_RESERVED && ps->ftq <= QUOTE_RESERVED3); // NOTE: QUOTE_RESERVED4 is not included. - int32_t const ybase = text_fragbarheight() + text_ypos(); + int32_t const ybase = (fragbarheight()<<16) + text_ypos(); int32_t height = 0; int32_t k = ps->fta;