135
135
#define S_CREDIT 0x00200000 // killough 10/98: credit
136
136
#define S_THERMO 0x00400000 // Slider for choosing a value
137
137
#define S_CHOICE 0x00800000 // this item has several values
138
- // #define S_ 0x01000000
138
+ #define S_DISABLED 0x01000000
139
139
#define S_NAME 0x02000000
140
140
#define S_RESET_Y 0x04000000
141
- // #define S_ 0x08000000
141
+ #define S_FUNC 0x08000000
142
142
// #define S_ 0x10000000
143
143
// #define S_ 0x20000000
144
144
#define S_STR 0x40000000 // need to refactor things...
150
150
* S_HASDEFPTR = the set of items whose var field points to default array
151
151
*/
152
152
153
- #define S_SHOWDESC (S_LABEL|S_TITLE|S_YESNO|S_CRITEM|S_COLOR|S_PREV|S_NEXT|S_INPUT|S_WEAP|S_NUM|S_FILE|S_CREDIT|S_CHOICE|S_THERMO|S_NAME)
153
+ #define S_SHOWDESC (S_LABEL|S_TITLE|S_YESNO|S_CRITEM|S_COLOR|S_PREV|S_NEXT|S_INPUT|S_WEAP|S_NUM|S_FILE|S_CREDIT|S_CHOICE|S_FUNC| S_THERMO|S_NAME)
154
154
155
- #define S_SHOWSET (S_YESNO|S_CRITEM|S_COLOR|S_INPUT|S_WEAP|S_NUM|S_FILE|S_CHOICE|S_THERMO|S_NAME)
155
+ #define S_SHOWSET (S_YESNO|S_CRITEM|S_COLOR|S_INPUT|S_WEAP|S_NUM|S_FILE|S_CHOICE|S_FUNC| S_THERMO|S_NAME)
156
156
157
157
#define S_STRING (S_FILE|S_NAME)
158
158
@@ -757,6 +757,7 @@ void M_ChooseSkill(int choice)
757
757
message = s_NIGHTMARE ; // Ty 03/27/98 - externalized
758
758
759
759
M_StartMessage (message , M_VerifySkill , true);
760
+ M_SetupNextMenu (& ReadDef1 ); // Clear in-menu variables when "no" or "ESC"
760
761
761
762
return ;
762
763
}
@@ -1656,6 +1657,22 @@ static void M_SetSetupMenuItemOn (const int x)
1656
1657
}
1657
1658
}
1658
1659
1660
+ static dboolean M_ItemSelected (const setup_menu_t * s )
1661
+ {
1662
+ int flags = s -> m_flags ;
1663
+
1664
+ if (s == current_setup_menu + set_menu_itemon && whichSkull && !(flags & S_NOSELECT ))
1665
+ return true;
1666
+
1667
+ return false;
1668
+ }
1669
+
1670
+ static void M_BlinkingArrowRight (const setup_menu_t * s )
1671
+ {
1672
+ if (M_ItemSelected (s ) && !setup_select )
1673
+ strcat (menu_buffer , " <" );
1674
+ }
1675
+
1659
1676
static void M_UpdateSetupMenu (setup_menu_t * new_setup_menu )
1660
1677
{
1661
1678
current_setup_menu = new_setup_menu ;
@@ -1797,6 +1814,48 @@ static int entry_index;
1797
1814
static char entry_string_index [ENTRY_STRING_BFR_SIZE ]; // points to new strings while editing
1798
1815
static int choice_value ;
1799
1816
1817
+ /////////////////////////////
1818
+ //
1819
+ // M_ItemDisabled
1820
+ //
1821
+ // Disable certain menu options based on various conditions:
1822
+ // StrictMode, Complevel, and more!
1823
+ //
1824
+ //
1825
+
1826
+ static dboolean M_ItemDisabled (const setup_menu_t * s )
1827
+ {
1828
+ // Strict Mode
1829
+ if (dsda_StrictMode () && dsda_IsStrictConfig (s -> config_id ))
1830
+ return true;
1831
+
1832
+ return false;
1833
+ }
1834
+
1835
+ /////////////////////////////
1836
+ //
1837
+ // Menu Text Colors
1838
+ //
1839
+ //
1840
+
1841
+ static int GetItemColor (int flags )
1842
+ {
1843
+ return (flags & S_TITLE && flags & S_DISABLED ) ? cr_title + CR_DARKEN :
1844
+ flags & S_DISABLED ? cr_label + CR_DARKEN :
1845
+ flags & (S_SELECT |S_TC_SEL ) ? cr_label_edit :
1846
+ flags & S_HILITE ? cr_label_highlight :
1847
+ flags & (S_TITLE |S_NEXT |S_PREV ) ? cr_title :
1848
+ cr_label ; // killough 10/98
1849
+ }
1850
+
1851
+ static int GetOptionColor (int flags )
1852
+ {
1853
+ return flags & S_DISABLED ? cr_value + CR_DARKEN :
1854
+ flags & S_SELECT ? cr_value_edit :
1855
+ flags & S_HILITE ? cr_value_highlight :
1856
+ cr_value ;
1857
+ }
1858
+
1800
1859
/////////////////////////////
1801
1860
//
1802
1861
// phares 4/18/98:
@@ -1810,31 +1869,42 @@ static int choice_value;
1810
1869
static void M_DrawItem (const setup_menu_t * s , int y )
1811
1870
{
1812
1871
int x = s -> m_x ;
1872
+ char text [66 ];
1813
1873
int flags = s -> m_flags ;
1814
1874
char * p , * t ;
1815
1875
int w = 0 ;
1816
- int color =
1817
- dsda_StrictMode () && dsda_IsStrictConfig (s -> config_id ) ? cr_label + CR_DARKEN :
1818
- flags & (S_SELECT |S_TC_SEL ) ? cr_label_edit :
1819
- flags & S_HILITE ? cr_label_highlight :
1820
- flags & (S_TITLE |S_NEXT |S_PREV ) ? cr_title :
1821
- cr_label ; // killough 10/98
1876
+ int color ;
1877
+
1878
+ if (M_ItemDisabled (s ))
1879
+ flags |= S_DISABLED ;
1880
+
1881
+ color = GetItemColor (flags );
1882
+
1883
+ // Add ". . ." to function
1884
+ sprintf (text , "%s%s" , s -> m_text , (flags & S_FUNC ) ? ". . ." : "" );
1822
1885
1823
1886
/* killough 10/98:
1824
1887
* Enhance to support multiline text separated by newlines.
1825
1888
* This supports multiline items on horizontally-crowded menus.
1826
1889
*/
1827
1890
1828
- for (p = t = Z_Strdup (s -> m_text ); (p = strtok (p ,"\n" )); y += 8 , p = NULL )
1891
+ for (p = t = Z_Strdup (text ); (p = strtok (p ,"\n" )); y += 8 , p = NULL )
1829
1892
{ /* killough 10/98: support left-justification: */
1830
- if (flags & S_CENTER )
1831
- w = M_GetPixelWidth (p ) / 2 ;
1832
- else if (!(flags & S_LEFTJUST ))
1833
- w = M_GetPixelWidth (p ) + 4 ;
1834
- M_DrawString (x - w , y ,color , p );
1835
- // print a blinking "arrow" next to the currently highlighted menu item
1836
- if (s == current_setup_menu + set_menu_itemon && whichSkull && !(flags & S_NOSELECT ))
1837
- M_DrawString (x - w - 8 , y , color , ">" );
1893
+ w = M_GetPixelWidth (p );
1894
+
1895
+ if (!(flags & S_LEFTJUST ))
1896
+ x -= (w + 4 );
1897
+
1898
+ M_DrawString (x , y , color , p );
1899
+
1900
+ // print a blinking left "arrow" before highlighted menu item
1901
+ if (M_ItemSelected (s ))
1902
+ M_DrawString (x - 8 , y , color , ">" );
1903
+
1904
+ // print a blinking right "arrow" after highlighted function
1905
+ if (flags & S_FUNC )
1906
+ if (M_ItemSelected (s ) && !setup_select )
1907
+ M_DrawString (x + w , y , color , " <" );
1838
1908
}
1839
1909
Z_Free (t );
1840
1910
}
@@ -1865,19 +1935,17 @@ static void M_DrawSetting(const setup_menu_t* s, int y)
1865
1935
// Determine color of the text. This may or may not be used later,
1866
1936
// depending on whether the item is a text string or not.
1867
1937
1868
- color =
1869
- dsda_StrictMode () && dsda_IsStrictConfig (s -> config_id ) ? cr_value + CR_DARKEN :
1870
- flags & S_SELECT ? cr_value_edit :
1871
- flags & S_HILITE ? cr_value_highlight :
1872
- cr_value ;
1938
+ if (M_ItemDisabled (s ))
1939
+ flags |= S_DISABLED ;
1940
+
1941
+ color = GetOptionColor (flags );
1873
1942
1874
1943
// Is the item a YES/NO item?
1875
1944
1876
1945
if (flags & S_YESNO ) {
1877
1946
strcpy (menu_buffer , dsda_IntConfig (s -> config_id ) ? "YES" : "NO" );
1878
1947
1879
- if (s == current_setup_menu + set_menu_itemon && whichSkull && !setup_select )
1880
- strcat (menu_buffer , " <" );
1948
+ M_BlinkingArrowRight (s );
1881
1949
M_DrawMenuString (x ,y ,color );
1882
1950
return ;
1883
1951
}
@@ -1900,12 +1968,11 @@ static void M_DrawSetting(const setup_menu_t* s, int y)
1900
1968
if (flags & S_CRITEM )
1901
1969
{
1902
1970
color = value ;
1903
- if (dsda_StrictMode () && dsda_IsStrictConfig ( s -> config_id ))
1971
+ if (M_ItemDisabled ( s ))
1904
1972
color += CR_DARKEN ;
1905
1973
}
1906
1974
}
1907
- if (s == current_setup_menu + set_menu_itemon && whichSkull && !setup_select )
1908
- strcat (menu_buffer , " <" );
1975
+ M_BlinkingArrowRight (s );
1909
1976
M_DrawMenuString (x , y , color );
1910
1977
return ;
1911
1978
}
@@ -1962,9 +2029,7 @@ static void M_DrawSetting(const setup_menu_t* s, int y)
1962
2029
if (!any_input )
1963
2030
M_GetKeyString (0 , 0 );
1964
2031
1965
- if (s == current_setup_menu + set_menu_itemon && whichSkull && !setup_select )
1966
- strcat (menu_buffer , " <" );
1967
-
2032
+ M_BlinkingArrowRight (s );
1968
2033
M_DrawMenuString (x , y , color );
1969
2034
1970
2035
return ;
@@ -1991,8 +2056,7 @@ static void M_DrawSetting(const setup_menu_t* s, int y)
1991
2056
1992
2057
if (!ch ) // don't show this item in automap mode
1993
2058
V_DrawNamePatch (x + 1 ,y ,0 ,"M_PALNO" , CR_DEFAULT , VPT_STRETCH );
1994
- if (s == current_setup_menu + set_menu_itemon && whichSkull && !setup_select )
1995
- M_DrawString (x + 8 , y , color , " <" );
2059
+ M_BlinkingArrowRight (s );
1996
2060
return ;
1997
2061
}
1998
2062
@@ -2049,8 +2113,7 @@ static void M_DrawSetting(const setup_menu_t* s, int y)
2049
2113
// Draw the setting for the item
2050
2114
2051
2115
strcpy (menu_buffer , text );
2052
- if (s == current_setup_menu + set_menu_itemon && whichSkull && !setup_select )
2053
- strcat (menu_buffer , " <" );
2116
+ M_BlinkingArrowRight (s );
2054
2117
M_DrawMenuString (x , y , color );
2055
2118
return ;
2056
2119
}
@@ -2081,8 +2144,7 @@ static void M_DrawSetting(const setup_menu_t* s, int y)
2081
2144
}
2082
2145
}
2083
2146
2084
- if (s == current_setup_menu + set_menu_itemon && whichSkull && !setup_select )
2085
- strcat (menu_buffer , " <" );
2147
+ M_BlinkingArrowRight (s );
2086
2148
M_DrawMenuString (x ,y ,color );
2087
2149
return ;
2088
2150
}
@@ -2092,8 +2154,7 @@ static void M_DrawSetting(const setup_menu_t* s, int y)
2092
2154
2093
2155
sprintf (menu_buffer , "%d" , dsda_IntConfig (s -> config_id ));
2094
2156
2095
- if (s == current_setup_menu + set_menu_itemon && whichSkull && !setup_select )
2096
- strcat (menu_buffer , " <" );
2157
+ M_BlinkingArrowRight (s );
2097
2158
M_DrawMenuString (x + 80 , y + 3 , color );
2098
2159
return ;
2099
2160
}
@@ -2340,6 +2401,8 @@ static void M_DrawInstructions(void)
2340
2401
else {
2341
2402
if (flags & S_INPUT )
2342
2403
M_DrawInstructionString (cr_info_highlight , "Press Enter to Change, Del to Clear" );
2404
+ else if (flags & S_FUNC )
2405
+ M_DrawInstructionString (cr_info_highlight , "Press Enter to Select" );
2343
2406
else
2344
2407
M_DrawInstructionString (cr_info_highlight , "Press Enter to Change" );
2345
2408
}
@@ -2351,6 +2414,7 @@ static void M_DrawInstructions(void)
2351
2414
#define FINAL_ENTRY { 0, S_SKIP | S_END, m_null }
2352
2415
#define EMPTY_LINE { 0, S_SKIP, m_null }
2353
2416
#define NEW_COLUMN { 0, S_SKIP | S_RESET_Y, m_null }
2417
+ #define FUNCTION (action_name , flags , offset_x , action_func ) { action_name, !flags ? (S_FUNC) : (S_FUNC | flags), m_null, offset_x, .action = action_func }
2354
2418
2355
2419
static void M_EnterSetup (menu_t * menu , dboolean * setup_flag , setup_menu_t * setup_menu )
2356
2420
{
@@ -3756,7 +3820,7 @@ static void M_BuildLevelTable(void)
3756
3820
if (map -> best_skill ) {
3757
3821
dsda_StringPrintF (& m_text , "%d" , map -> best_skill );
3758
3822
entry -> m_text = m_text .string ;
3759
- if (map -> best_skill == num_skills )
3823
+ if (map -> best_skill == num_og_skills )
3760
3824
entry -> m_flags |= S_TC_SEL ;
3761
3825
}
3762
3826
else {
@@ -4875,11 +4939,23 @@ static dboolean M_LevelTableResponder(int ch, int action, event_t* ev)
4875
4939
4876
4940
static dboolean M_SetupCommonSelectResponder (int ch , int action , event_t * ev )
4877
4941
{
4942
+ setup_menu_t * ptr1 = current_setup_menu + set_menu_itemon ;
4943
+
4944
+ // Execute functions
4945
+ if (ptr1 -> m_flags & S_FUNC )
4946
+ {
4947
+ if (action == MENU_ENTER ) {
4948
+ if (ptr1 -> action )
4949
+ ptr1 -> action ();
4950
+
4951
+ M_SelectDone (ptr1 );
4952
+ return true;
4953
+ }
4954
+ }
4955
+
4878
4956
// changing an entry
4879
4957
if (setup_select )
4880
4958
{
4881
- setup_menu_t * ptr1 = current_setup_menu + set_menu_itemon ;
4882
-
4883
4959
if (action == MENU_ESCAPE ) // Exit key = no change
4884
4960
{
4885
4961
M_SelectDone (ptr1 ); // phares 4/17/98
@@ -5100,7 +5176,7 @@ static dboolean M_SetupNavigationResponder(int ch, int action, event_t* ev)
5100
5176
{
5101
5177
int flags = ptr1 -> m_flags ;
5102
5178
5103
- if (dsda_StrictMode () && dsda_IsStrictConfig ( ptr1 -> config_id ))
5179
+ if (M_ItemDisabled ( ptr1 ))
5104
5180
return true;
5105
5181
5106
5182
// You've selected an item to change. Highlight it, post a new
@@ -6168,30 +6244,22 @@ void M_Drawer (void)
6168
6244
if (
6169
6245
currentMenu -> menuitems [i ].status != -1 && (
6170
6246
!currentMenu -> menuitems [i ].name [0 ] || !W_LumpNameExists (currentMenu -> menuitems [i ].name )
6171
- )
6247
+ ) && !( currentMenu -> menuitems [ i ]. flags & MENUF_OPTLUMP )
6172
6248
)
6173
6249
++ lumps_missing ;
6174
6250
6175
- if (!lumps_missing )
6176
- for (i = 0 ; i < max ; i ++ )
6177
- {
6178
- if (currentMenu -> menuitems [i ].name [0 ])
6179
- V_DrawNamePatch (x , y , 0 , currentMenu -> menuitems [i ].name ,
6180
- currentMenu -> menuitems [i ].color , VPT_STRETCH );
6181
-
6182
- y += LINEHEIGHT ;
6183
- }
6184
- else
6185
- for (i = 0 ; i < max ; i ++ )
6186
- {
6187
- const char * alttext = currentMenu -> menuitems [i ].alttext ;
6188
-
6189
- if (alttext )
6190
- M_WriteText (x , y + 8 - (M_StringHeight (alttext ) / 2 ),
6191
- alttext , currentMenu -> menuitems [i ].color );
6192
-
6193
- y += LINEHEIGHT ;
6194
- }
6251
+ for (i = 0 ; i < max ; i ++ )
6252
+ {
6253
+ const char * alttext = currentMenu -> menuitems [i ].alttext ;
6254
+ if (!lumps_missing && currentMenu -> menuitems [i ].name [0 ] &&
6255
+ !(currentMenu -> menuitems [i ].flags & MENUF_OPTLUMP ))
6256
+ V_DrawNamePatch (x , y , 0 , currentMenu -> menuitems [i ].name ,
6257
+ currentMenu -> menuitems [i ].color , VPT_STRETCH );
6258
+ else if (alttext )
6259
+ M_WriteText (x , y + 8 - (M_StringHeight (alttext ) / 2 ),
6260
+ alttext , currentMenu -> menuitems [i ].color );
6261
+ y += LINEHEIGHT ;
6262
+ }
6195
6263
6196
6264
// DRAW SKULL
6197
6265
if (max > 0 )
0 commit comments