diff --git a/common/main/newmenu.h b/common/main/newmenu.h index 2537b10f6..53401793a 100644 --- a/common/main/newmenu.h +++ b/common/main/newmenu.h @@ -179,6 +179,14 @@ static inline void nm_set_item_text(newmenu_item *ni, const char *text) ni->text = (char *)text; } +static inline void nm_set_item_radio(newmenu_item *ni, const char *text, unsigned checked, unsigned grp) +{ + ni->type = NM_TYPE_RADIO; + ni->text = (char *)text; + ni->value = checked; + ni->group = grp; +} + #define NEWMENU_MOUSE // #define NORMAL_CHECK_BOX "" diff --git a/similar/main/gamecntl.c b/similar/main/gamecntl.c index 73ef2083e..e0b61b2c9 100644 --- a/similar/main/gamecntl.c +++ b/similar/main/gamecntl.c @@ -1766,10 +1766,10 @@ void do_cheat_menu() nm_set_item_text(& mm[5], "Score:"); nm_set_item_input(&mm[6], 10, score_text); #if defined(DXX_BUILD_DESCENT_I) - mm[7].type=NM_TYPE_RADIO; mm[7].value=(Players[Player_num].laser_level==0); mm[7].group=0; mm[7].text="Laser level 1"; - mm[8].type=NM_TYPE_RADIO; mm[8].value=(Players[Player_num].laser_level==1); mm[8].group=0; mm[8].text="Laser level 2"; - mm[9].type=NM_TYPE_RADIO; mm[9].value=(Players[Player_num].laser_level==2); mm[9].group=0; mm[9].text="Laser level 3"; - mm[10].type=NM_TYPE_RADIO; mm[10].value=(Players[Player_num].laser_level==3); mm[10].group=0; mm[10].text="Laser level 4"; + nm_set_item_radio(&mm[7], "Laser level 1", (Players[Player_num].laser_level==0), 0); + nm_set_item_radio(&mm[8], "Laser level 2", (Players[Player_num].laser_level==1), 0); + nm_set_item_radio(&mm[9], "Laser level 3", (Players[Player_num].laser_level==2), 0); + nm_set_item_radio(&mm[10], "Laser level 4", (Players[Player_num].laser_level==3), 0); mm[11].type=NM_TYPE_NUMBER; mm[11].value=Players[Player_num].secondary_ammo[CONCUSSION_INDEX]; mm[11].text="Missiles"; mm[11].min_value=0; mm[11].max_value=200; mmn = newmenu_do("Wimp Menu",NULL,12, mm, NULL, NULL ); diff --git a/similar/main/menu.c b/similar/main/menu.c index 4fb79a5d0..608bdb993 100644 --- a/similar/main/menu.c +++ b/similar/main/menu.c @@ -920,10 +920,8 @@ void change_res() for (i = 0; i <= num_presets-1; i++) { snprintf(restext[mc], sizeof(restext[mc]), "%ix%i", SM_W(modes[i]), SM_H(modes[i])); - m[mc].type = NM_TYPE_RADIO; - m[mc].text = restext[mc]; - m[mc].value = ((citem == -1) && (Game_screen_mode == modes[i]) && GameCfg.AspectY == SM_W(modes[i])/gcd(SM_W(modes[i]),SM_H(modes[i])) && GameCfg.AspectX == SM_H(modes[i])/gcd(SM_W(modes[i]),SM_H(modes[i]))); - m[mc].group = 0; + + nm_set_item_radio(&m[mc], restext[mc], ((citem == -1) && (Game_screen_mode == modes[i]) && GameCfg.AspectY == SM_W(modes[i])/gcd(SM_W(modes[i]),SM_H(modes[i])) && GameCfg.AspectX == SM_H(modes[i])/gcd(SM_W(modes[i]),SM_H(modes[i]))), 0); if (m[mc].value) citem = mc; mc++; @@ -932,7 +930,7 @@ void change_res() nm_set_item_text(& m[mc], ""); mc++; // little space for overview // the fields for custom resolution and aspect opt_cval = mc; - m[mc].type = NM_TYPE_RADIO; m[mc].text = "use custom values"; m[mc].value = (citem == -1); m[mc].group = 0; mc++; + nm_set_item_radio(&m[mc], "use custom values", (citem == -1), 0); mc++; nm_set_item_text(& m[mc], "resolution:"); mc++; snprintf(crestext, sizeof(crestext), "%ix%i", SM_W(Game_screen_mode), SM_H(Game_screen_mode)); nm_set_item_input(&m[mc], 11, crestext); modes[mc] = 0; mc++; @@ -1136,8 +1134,8 @@ void input_config() nm_set_item_text(& m[nitems], ""); nitems++; nm_set_item_text(& m[nitems], "MOUSE CONTROL TYPE:"); nitems++; opt_ic_mouseflightsim = nitems; - m[nitems].type = NM_TYPE_RADIO; m[nitems].text = "normal"; m[nitems].value = !PlayerCfg.MouseFlightSim; m[nitems].group = 0; nitems++; - m[nitems].type = NM_TYPE_RADIO; m[nitems].text = "FlightSim"; m[nitems].value = PlayerCfg.MouseFlightSim; m[nitems].group = 0; nitems++; + nm_set_item_radio(&m[nitems], "normal", !PlayerCfg.MouseFlightSim, 0); nitems++; + nm_set_item_radio(&m[nitems], "FlightSim", PlayerCfg.MouseFlightSim, 0); nitems++; nm_set_item_text(& m[nitems], ""); nitems++; opt_ic_joymousesens = nitems; nm_set_item_menu(&m[nitems], "SENSITIVITY & DEADZONE"); nitems++; @@ -1167,17 +1165,17 @@ void reticle_config() int nitems = 0, i, opt_ret_type, opt_ret_rgba, opt_ret_size; nm_set_item_text(& m[nitems], "Reticle Type:"); nitems++; opt_ret_type = nitems; - m[nitems].type = NM_TYPE_RADIO; m[nitems].text = "Classic"; m[nitems].value = 0; m[nitems].group = 0; nitems++; + nm_set_item_radio(&m[nitems], "Classic", 0, 0); nitems++; #ifdef OGL - m[nitems].type = NM_TYPE_RADIO; m[nitems].text = "Classic Reboot"; m[nitems].value = 0; m[nitems].group = 0; nitems++; + nm_set_item_radio(&m[nitems], "Classic Reboot", 0, 0); nitems++; #endif - m[nitems].type = NM_TYPE_RADIO; m[nitems].text = "None"; m[nitems].value = 0; m[nitems].group = 0; nitems++; - m[nitems].type = NM_TYPE_RADIO; m[nitems].text = "X"; m[nitems].value = 0; m[nitems].group = 0; nitems++; - m[nitems].type = NM_TYPE_RADIO; m[nitems].text = "Dot"; m[nitems].value = 0; m[nitems].group = 0; nitems++; - m[nitems].type = NM_TYPE_RADIO; m[nitems].text = "Circle"; m[nitems].value = 0; m[nitems].group = 0; nitems++; - m[nitems].type = NM_TYPE_RADIO; m[nitems].text = "Cross V1"; m[nitems].value = 0; m[nitems].group = 0; nitems++; - m[nitems].type = NM_TYPE_RADIO; m[nitems].text = "Cross V2"; m[nitems].value = 0; m[nitems].group = 0; nitems++; - m[nitems].type = NM_TYPE_RADIO; m[nitems].text = "Angle"; m[nitems].value = 0; m[nitems].group = 0; nitems++; + nm_set_item_radio(&m[nitems], "None", 0, 0); nitems++; + nm_set_item_radio(&m[nitems], "X", 0, 0); nitems++; + nm_set_item_radio(&m[nitems], "Dot", 0, 0); nitems++; + nm_set_item_radio(&m[nitems], "Circle", 0, 0); nitems++; + nm_set_item_radio(&m[nitems], "Cross V1", 0, 0); nitems++; + nm_set_item_radio(&m[nitems], "Cross V2", 0, 0); nitems++; + nm_set_item_radio(&m[nitems], "Angle", 0, 0); nitems++; nm_set_item_text(& m[nitems], ""); nitems++; nm_set_item_text(& m[nitems], "Reticle Color:"); nitems++; opt_ret_rgba = nitems; @@ -1270,10 +1268,10 @@ void graphics_config() #ifdef OGL nm_set_item_text(& m[nitems], "Texture Filtering:"); nitems++; opt_gr_texfilt = nitems; - m[nitems].type = NM_TYPE_RADIO; m[nitems].text = "None (Classical)"; m[nitems].value = 0; m[nitems].group = 0; nitems++; - m[nitems].type = NM_TYPE_RADIO; m[nitems].text = "Bilinear"; m[nitems].value = 0; m[nitems].group = 0; nitems++; - m[nitems].type = NM_TYPE_RADIO; m[nitems].text = "Trilinear"; m[nitems].value = 0; m[nitems].group = 0; nitems++; - m[nitems].type = NM_TYPE_RADIO; m[nitems].text = "Anisotropic"; m[nitems].value = 0; m[nitems].group = 0; nitems++; + nm_set_item_radio(&m[nitems++], "None (Classical)", 0, 0); + nm_set_item_radio(&m[nitems++], "Bilinear", 0, 0); + nm_set_item_radio(&m[nitems++], "Trilinear", 0, 0); + nm_set_item_radio(&m[nitems++], "Anisotropic", 0, 0); #if defined(DXX_BUILD_DESCENT_II) opt_gr_movietexfilt = nitems; nm_set_item_checkbox(&m[nitems++], "Movie Filter", GameCfg.MovieTexFilt); @@ -1811,19 +1809,19 @@ void do_sound_menu() nm_set_item_text(& m[nitems++], "music type:"); opt_sm_mtype0 = nitems; - m[nitems].type = NM_TYPE_RADIO; m[nitems].text = "no music"; m[nitems].value = (GameCfg.MusicType == MUSIC_TYPE_NONE); m[nitems].group = 0; nitems++; + nm_set_item_radio(&m[nitems], "no music", (GameCfg.MusicType == MUSIC_TYPE_NONE), 0); nitems++; #if defined(USE_SDLMIXER) || defined(_WIN32) opt_sm_mtype1 = nitems; - m[nitems].type = NM_TYPE_RADIO; m[nitems].text = "built-in/addon music"; m[nitems].value = (GameCfg.MusicType == MUSIC_TYPE_BUILTIN); m[nitems].group = 0; nitems++; + nm_set_item_radio(&m[nitems], "built-in/addon music", (GameCfg.MusicType == MUSIC_TYPE_BUILTIN), 0); nitems++; #endif opt_sm_mtype2 = nitems; - m[nitems].type = NM_TYPE_RADIO; m[nitems].text = "cd music"; m[nitems].value = (GameCfg.MusicType == MUSIC_TYPE_REDBOOK); m[nitems].group = 0; nitems++; + nm_set_item_radio(&m[nitems], "cd music", (GameCfg.MusicType == MUSIC_TYPE_REDBOOK), 0); nitems++; #ifdef USE_SDLMIXER opt_sm_mtype3 = nitems; - m[nitems].type = NM_TYPE_RADIO; m[nitems].text = "jukebox"; m[nitems].value = (GameCfg.MusicType == MUSIC_TYPE_CUSTOM); m[nitems].group = 0; nitems++; + nm_set_item_radio(&m[nitems], "jukebox", (GameCfg.MusicType == MUSIC_TYPE_CUSTOM), 0); nitems++; #endif @@ -1857,13 +1855,13 @@ void do_sound_menu() nm_set_item_text(& m[nitems++], "level music play order:"); opt_sm_mtype3_lmplayorder1 = nitems; - m[nitems].type = NM_TYPE_RADIO; m[nitems].text = "continuously"; m[nitems].value = (GameCfg.CMLevelMusicPlayOrder == MUSIC_CM_PLAYORDER_CONT); m[nitems].group = 1; nitems++; + nm_set_item_radio(&m[nitems], "continuously", (GameCfg.CMLevelMusicPlayOrder == MUSIC_CM_PLAYORDER_CONT), 1); nitems++; opt_sm_mtype3_lmplayorder2 = nitems; - m[nitems].type = NM_TYPE_RADIO; m[nitems].text = "one track per level"; m[nitems].value = (GameCfg.CMLevelMusicPlayOrder == MUSIC_CM_PLAYORDER_LEVEL); m[nitems].group = 1; nitems++; + nm_set_item_radio(&m[nitems], "one track per level", (GameCfg.CMLevelMusicPlayOrder == MUSIC_CM_PLAYORDER_LEVEL), 1); nitems++; opt_sm_mtype3_lmplayorder3 = nitems; - m[nitems].type = NM_TYPE_RADIO; m[nitems].text = "random"; m[nitems].value = (GameCfg.CMLevelMusicPlayOrder == MUSIC_CM_PLAYORDER_RAND); m[nitems].group = 1; nitems++; + nm_set_item_radio(&m[nitems], "random", (GameCfg.CMLevelMusicPlayOrder == MUSIC_CM_PLAYORDER_RAND), 1); nitems++; nm_set_item_text(& m[nitems++], ""); diff --git a/similar/main/net_udp.c b/similar/main/net_udp.c index 6bd159229..fab1783ec 100644 --- a/similar/main/net_udp.c +++ b/similar/main/net_udp.c @@ -3305,32 +3305,32 @@ int net_udp_setup_game() nm_set_item_text(& m[optnum], TXT_OPTIONS); optnum++; opt.mode = optnum; - m[optnum].type = NM_TYPE_RADIO; m[optnum].text = TXT_ANARCHY; m[optnum].value=(Netgame.gamemode == NETGAME_ANARCHY); m[optnum].group=0; opt.anarchy=optnum; optnum++; - m[optnum].type = NM_TYPE_RADIO; m[optnum].text = TXT_TEAM_ANARCHY; m[optnum].value=(Netgame.gamemode == NETGAME_TEAM_ANARCHY); m[optnum].group=0; opt.team_anarchy=optnum; optnum++; - m[optnum].type = NM_TYPE_RADIO; m[optnum].text = TXT_ANARCHY_W_ROBOTS; m[optnum].value=(Netgame.gamemode == NETGAME_ROBOT_ANARCHY); m[optnum].group=0; opt.robot_anarchy=optnum; optnum++; - m[optnum].type = NM_TYPE_RADIO; m[optnum].text = TXT_COOPERATIVE; m[optnum].value=(Netgame.gamemode == NETGAME_COOPERATIVE); m[optnum].group=0; opt.coop=optnum; optnum++; + nm_set_item_radio(&m[optnum], TXT_ANARCHY,(Netgame.gamemode == NETGAME_ANARCHY),0); opt.anarchy=optnum; optnum++; + nm_set_item_radio(&m[optnum], TXT_TEAM_ANARCHY,(Netgame.gamemode == NETGAME_TEAM_ANARCHY),0); opt.team_anarchy=optnum; optnum++; + nm_set_item_radio(&m[optnum], TXT_ANARCHY_W_ROBOTS,(Netgame.gamemode == NETGAME_ROBOT_ANARCHY),0); opt.robot_anarchy=optnum; optnum++; + nm_set_item_radio(&m[optnum], TXT_COOPERATIVE,(Netgame.gamemode == NETGAME_COOPERATIVE),0); opt.coop=optnum; optnum++; #if defined(DXX_BUILD_DESCENT_II) - m[optnum].type = NM_TYPE_RADIO; m[optnum].text = "Capture the flag"; m[optnum].value=(Netgame.gamemode == NETGAME_CAPTURE_FLAG); m[optnum].group=0; opt.capture=optnum; optnum++; + nm_set_item_radio(&m[optnum], "Capture the flag",(Netgame.gamemode == NETGAME_CAPTURE_FLAG),0); opt.capture=optnum; optnum++; if (HoardEquipped()) { - m[optnum].type = NM_TYPE_RADIO; m[optnum].text = "Hoard"; m[optnum].value=(Netgame.gamemode == NETGAME_HOARD); m[optnum].group=0; opt.hoard=optnum; optnum++; - m[optnum].type = NM_TYPE_RADIO; m[optnum].text = "Team Hoard"; m[optnum].value=(Netgame.gamemode == NETGAME_TEAM_HOARD); m[optnum].group=0; opt.team_hoard=optnum; optnum++; + nm_set_item_radio(&m[optnum], "Hoard",(Netgame.gamemode == NETGAME_HOARD),0); opt.hoard=optnum; optnum++; + nm_set_item_radio(&m[optnum], "Team Hoard",(Netgame.gamemode == NETGAME_TEAM_HOARD),0); opt.team_hoard=optnum; optnum++; } else { opt.hoard = opt.team_hoard = 0; // NOTE: Make sure if you use these, use them in connection with HoardEquipped() only! } #endif - m[optnum].type = NM_TYPE_RADIO; m[optnum].text = "Bounty"; m[optnum].value = ( Netgame.gamemode & NETGAME_BOUNTY ); m[optnum].group = 0; opt.mode_end=opt.bounty=optnum; optnum++; + nm_set_item_radio(&m[optnum], "Bounty", ( Netgame.gamemode & NETGAME_BOUNTY ), 0); opt.mode_end=opt.bounty=optnum; optnum++; nm_set_item_text(& m[optnum], ""); optnum++; - m[optnum].type = NM_TYPE_RADIO; m[optnum].text = "Open game"; m[optnum].group=1; m[optnum].value=(!Netgame.RefusePlayers && !Netgame.game_flag.closed); optnum++; + nm_set_item_radio(&m[optnum], "Open game",(!Netgame.RefusePlayers && !Netgame.game_flag.closed),1); optnum++; opt.closed = optnum; - m[optnum].type = NM_TYPE_RADIO; m[optnum].text = TXT_CLOSED_GAME; m[optnum].group=1; m[optnum].value=Netgame.game_flag.closed; optnum++; + nm_set_item_radio(&m[optnum], TXT_CLOSED_GAME,Netgame.game_flag.closed,1); optnum++; opt.refuse = optnum; - m[optnum].type = NM_TYPE_RADIO; m[optnum].text = "Restricted Game "; m[optnum].group=1; m[optnum].value=Netgame.RefusePlayers; optnum++; + nm_set_item_radio(&m[optnum], "Restricted Game ",Netgame.RefusePlayers,1); optnum++; opt.maxnet = optnum; sprintf( srmaxnet, "Maximum players: %d", Netgame.max_numplayers);