[Build] Fix the NO_LINK build

The NO_LINK build had bitrot and was no longer building. This fixes the
issue by properly disabling Link-related code, including unreachable
functions when the project is built with ENABLE_LINK=FALSE
This commit is contained in:
Fabrice de Gans 2023-09-04 13:35:47 -07:00
parent 7a7778c644
commit 0f4ec57557
3 changed files with 36 additions and 8 deletions

View File

@ -2521,6 +2521,8 @@ EVT_HANDLER(VSync, "Wait for vertical sync")
GetMenuOptionConfig("VSync", config::OptionID::kPrefVsync);
}
#ifndef NO_LINK
void MainFrame::EnableNetworkMenu()
{
cmd_enable &= ~CMDEN_LINK_ANY;
@ -2545,12 +2547,12 @@ void SetLinkTypeMenu(const char* type, int value)
mf->SetMenuOption(type, 1);
gopts.gba_link_type = value;
update_opts();
#ifndef NO_LINK
CloseLink();
#endif
mf->EnableNetworkMenu();
}
#endif // NO_LINK
EVT_HANDLER_MASK(LanLink, "Start Network link", CMDEN_LINK_ANY)
{
#ifndef NO_LINK
@ -2577,42 +2579,58 @@ EVT_HANDLER_MASK(LanLink, "Start Network link", CMDEN_LINK_ANY)
EVT_HANDLER(LinkType0Nothing, "Link nothing")
{
#ifndef NO_LINK
SetLinkTypeMenu("LinkType0Nothing", 0);
#endif
}
EVT_HANDLER(LinkType1Cable, "Link cable")
{
#ifndef NO_LINK
SetLinkTypeMenu("LinkType1Cable", 1);
#endif
}
EVT_HANDLER(LinkType2Wireless, "Link wireless")
{
#ifndef NO_LINK
SetLinkTypeMenu("LinkType2Wireless", 2);
#endif
}
EVT_HANDLER(LinkType3GameCube, "Link GameCube")
{
#ifndef NO_LINK
SetLinkTypeMenu("LinkType3GameCube", 3);
#endif
}
EVT_HANDLER(LinkType4Gameboy, "Link Gameboy")
{
#ifndef NO_LINK
SetLinkTypeMenu("LinkType4Gameboy", 4);
#endif
}
EVT_HANDLER(LinkAuto, "Enable link at boot")
{
#ifndef NO_LINK
GetMenuOptionConfig("LinkAuto", config::OptionID::kGBALinkAuto);
#endif
}
EVT_HANDLER(SpeedOn, "Enable faster network protocol by default")
{
#ifndef NO_LINK
GetMenuOptionConfig("SpeedOn", config::OptionID::kGBALinkFast);
#endif
}
EVT_HANDLER(LinkProto, "Local host IPC")
{
#ifndef NO_LINK
GetMenuOptionConfig("LinkProto", config::OptionID::kGBALinkProto);
#endif
}
EVT_HANDLER(LinkConfigure, "Link options...")

View File

@ -827,13 +827,13 @@ MainFrame::MainFrame()
menus_opened(0),
dialog_opened(0),
focused(false),
#ifndef NO_LINK
gba_link_observer_(config::OptionID::kGBALinkHost,
std::bind(&MainFrame::EnableNetworkMenu, this)),
#endif
keep_on_top_styler_(this),
status_bar_observer_(config::OptionID::kGenStatusBar,
std::bind(&MainFrame::OnStatusBarChanged,
this,
std::placeholders::_1)),
gba_link_observer_(config::OptionID::kGBALinkHost,
std::bind(&MainFrame::EnableNetworkMenu, this)) {
std::bind(&MainFrame::OnStatusBarChanged, this, std::placeholders::_1)) {
jpoll = new JoystickPoller();
this->Connect(wxID_ANY, wxEVT_SHOW, wxShowEventHandler(JoystickPoller::ShowDialog), jpoll, jpoll);
}
@ -1263,6 +1263,8 @@ void MainFrame::StopModal()
panel->Resume();
}
#ifndef NO_LINK
LinkMode MainFrame::GetConfiguredLinkMode()
{
switch (gopts.gba_link_type) {
@ -1306,6 +1308,8 @@ LinkMode MainFrame::GetConfiguredLinkMode()
return LINK_DISCONNECTED;
}
#endif // NO_LINK
void MainFrame::IdentifyRom()
{
if (!panel->rom_name.empty())

View File

@ -246,7 +246,9 @@ public:
// adjust menus based on current cmd_enable
void enable_menus();
#ifndef NO_LINK
void EnableNetworkMenu();
#endif
// adjust menus based on available save game states
void update_state_ts(bool force = false);
@ -268,8 +270,10 @@ public:
return focused;
}
#ifndef NO_LINK
// Returns the link mode to set according to the options
LinkMode GetConfiguredLinkMode();
#endif
void IdentifyRom();
@ -352,9 +356,11 @@ private:
JoystickPoller* jpoll = nullptr;
// quicker & more accurate than FindFocus() != NULL
bool focused;
#ifndef NO_LINK
const config::OptionsObserver gba_link_observer_;
#endif
const widgets::KeepOnTopStyler keep_on_top_styler_;
const config::OptionsObserver status_bar_observer_;
const config::OptionsObserver gba_link_observer_;
// helper function for adding menu to accel editor
void add_menu_accels(wxTreeCtrl* tc, wxTreeItemId& parent, wxMenu* menu);