LAN: remember player name and max players setting

This commit is contained in:
Arisotura 2024-08-15 13:34:27 +02:00
parent 5b986d3111
commit 0e6235a7c4
2 changed files with 19 additions and 4 deletions

View File

@ -71,7 +71,8 @@ DefaultList<int> DefaultInts =
#ifdef GDBSTUB_ENABLED
{"Instance*.Gdb.ARM7.Port", 3334},
{"Instance*.Gdb.ARM9.Port", 3333},
#endif
#endif,
{"LAN.HostNumPlayers", 16},
};
RangeList IntRanges =
@ -90,6 +91,7 @@ RangeList IntRanges =
{"Instance*.Window*.ScreenAspectTop", {0, AspectRatiosNum-1}},
{"Instance*.Window*.ScreenAspectBot", {0, AspectRatiosNum-1}},
{"MP.AudioMode", {0, 2}},
{"LAN.HostNumPlayers", {2, 16}},
};
DefaultList<bool> DefaultBools =

View File

@ -51,10 +51,11 @@ LANStartHostDialog::LANStartHostDialog(QWidget* parent) : QDialog(parent), ui(ne
setMPInterface(MPInterface_LAN);
// TODO: remember the last setting? so this doesn't suck massively
// we could also remember the player name (and auto-init it from the firmware name or whatever)
auto cfg = Config::GetGlobalTable();
ui->txtPlayerName->setText(cfg.GetQString("LAN.PlayerName"));
ui->sbNumPlayers->setRange(2, 16);
ui->sbNumPlayers->setValue(16);
ui->sbNumPlayers->setValue(cfg.GetInt("LAN.HostNumPlayers"));
}
LANStartHostDialog::~LANStartHostDialog()
@ -82,6 +83,11 @@ void LANStartHostDialog::done(int r)
}
lanDlg = LANDialog::openDlg(parentWidget());
auto cfg = Config::GetGlobalTable();
cfg.SetString("LAN.PlayerName", player);
cfg.SetInt("LAN.HostNumPlayers", numplayers);
Config::Save();
}
else
{
@ -99,6 +105,9 @@ LANStartClientDialog::LANStartClientDialog(QWidget* parent) : QDialog(parent), u
setMPInterface(MPInterface_LAN);
auto cfg = Config::GetGlobalTable();
ui->txtPlayerName->setText(cfg.GetQString("LAN.PlayerName"));
QStandardItemModel* model = new QStandardItemModel();
ui->tvAvailableGames->setModel(model);
const QStringList listheader = {"Name", "Players", "Status", "Host IP"};
@ -209,6 +218,10 @@ void LANStartClientDialog::done(int r)
setEnabled(true);
lanDlg = LANDialog::openDlg(parentWidget());
auto cfg = Config::GetGlobalTable();
cfg.SetString("LAN.PlayerName", player);
Config::Save();
}
else
{