Skip to content

Commit

Permalink
LAN: remember player name and max players setting
Browse files Browse the repository at this point in the history
  • Loading branch information
Arisotura committed Aug 15, 2024
1 parent 5b986d3 commit 0e6235a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/frontend/qt_sdl/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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 =
Expand Down
19 changes: 16 additions & 3 deletions src/frontend/qt_sdl/LANDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
{
Expand All @@ -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"};
Expand Down Expand Up @@ -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
{
Expand Down

0 comments on commit 0e6235a

Please sign in to comment.