Add [automaticmode] Load File button to console lobby

options.ini [automaticmode] section:
  automaticmode=1
  automaticfile=c:\path\to\config.ini

Right-click was considered then dropped in favor of a dedicated button
at 467,510 (below Pick Cond., left of Reprint).

C++ (MW4Shell.cpp):
- SAutoFileSlot struct + g_aAutoSlots[16], g_bAutomaticMode, g_szAutomaticFile globals
- [automaticmode] ini read at StartUp
- CTCL_LoadAutoFile: checks file exists, reads [mission] page into existing
  g_nRookieXxx globals + [slot0]..[slot15] pages into g_aAutoSlots[]; returns 1 if loaded
- CTCL_GetAutoSlotName(out_str, k): pilot name for slot k
- CTCL_GetAutoSlotMech(out_str, k): mech display name for slot k
- CTCL_GetAutoSlotInt(k, field): Type/Team/Skin/Decal for slot k (fields 0-3)
- Register/unregister all 4 callbacks in StartUp/ShutDown

Script (ConLobby.script):
- o_load_file button at 467, 510
- Handler: CTCL_LoadAutoFile -> if loaded, sends MAIL_SET_ROOKIE_MISSION to
  ConLobbyMission (game options), clears all slots, then applies per-slot data
  in a loop (pilot names, mech by display-name lookup in allowed_mechs[], team,
  skin, decal). USE_ALLOWED_MECHS/non-ALLOWED_MECHS both handled via #if.

File not consumed (stays on disk); external app overwrites for next load.
Rebuild required: MW4.exe (Release + Profile).
This commit is contained in:
2026-07-24 08:44:57 -05:00
parent fccdc2dee4
commit c33465611f
2 changed files with 233 additions and 0 deletions
@@ -1229,6 +1229,16 @@ main
o_all_random_mech.state = 0 // initially enabled
initialize(o_all_random_mech)
// [automaticmode] Load File button -- below Pick Cond., left of Reprint
object o_load_file = s_multistatepane
o_load_file.total_states = 3
o_load_file.textsize = 1
o_load_file.text = "Load File"
o_load_file.file = WPATH "button_reg_138x23m_3state.tga"
o_load_file.location = 467, 510, o_frame.location.z + 1
o_load_file.state = 0 // initially enabled
initialize(o_load_file)
// MSL Added default settings button
object o_default = s_multistatepane
o_default.total_states = 3
@@ -1664,6 +1674,94 @@ main
mail(MAIL_RESET_AFTER_LAUNCH, this) // reset
return
}
// [automaticmode] Load File button handler
if (sender == o_load_file)
{
play press, 1
if callback($$CTCL_LoadAutoFile$$)
{
// Apply mission + game options via existing Rookie Mission flow
mail(MAIL_SET_ROOKIE_MISSION, @ConLobbyMission@)
// Clear all slots
o_cam_list.nselected = 0
for (k = 0; k < nRosterCount; k++)
{
if (1 <= o_BotList[k].nselected)
{
if (o_BotList[k].nselected == 1) && (k < MAXTESLA_P)
{
o_Editbox[k].boxValue = ""
initialize(o_Editbox[k])
deactivate(o_Editbox[k])
}
o_BotList[k].nselected = 0
m_naLastSelected[k] = 0
if (ROSTER_top_of_list <= k) && (k < ROSTER_top_of_list + ROSTER_DISPLAY_COUNT)
mail(MAIL_PLAYER_TYPE_CHANGED, k, this)
}
}
// Apply per-slot data from file
string szAutoName
string szAutoMech
int nAutoType
int j
for (k = 0; k < nRosterCount; k++)
{
nAutoType = callback($$CTCL_GetAutoSlotInt$$, k, 0)
if nAutoType > 0
{
o_BotList[k].nselected = nAutoType
m_naLastSelected[k] = nAutoType
if (o_BotList[k].nselected > 0)
activate(o_BotList[k])
if (nAutoType == 1) && (k < MAXTESLA_P)
{
callback($$CTCL_GetAutoSlotName$$, szAutoName, k)
o_Editbox[k].boxValue = szAutoName
initialize(o_Editbox[k])
activate(o_Editbox[k])
}
callback($$CTCL_GetAutoSlotMech$$, szAutoMech, k)
if (!equal$(szAutoMech, ""))
{
#if USE_ALLOWED_MECHS
for (j = 0; j < MAX_ALLOWED_MECHS; j++)
{
if equal$(mech[allowed_mechs[j]], szAutoMech)
{
o_mech_variant[k].nselected = j
break
}
}
#else
for (j = 0; j < $$m_mechCount$$; j++)
{
if equal$(mech[j], szAutoMech)
{
o_mech_variant[k].nselected = j
break
}
}
#endif
}
if cur_team_val > 0
o_team[k].nselected = callback($$CTCL_GetAutoSlotInt$$, k, 1)
else
o_skins[k].nselected = callback($$CTCL_GetAutoSlotInt$$, k, 2)
o_decal[k].nselected = callback($$CTCL_GetAutoSlotInt$$, k, 3)
initialize(o_mech_variant[k])
if (ROSTER_top_of_list <= k) && (k < ROSTER_top_of_list + ROSTER_DISPLAY_COUNT)
{
activate(o_mech_variant[k])
mail(MAIL_PLAYER_TYPE_CHANGED, k, this)
}
else
deactivate(o_mech_variant[k])
}
}
}
return
}
if (sender == o_reprint)
{
play press,1