Added REMOTE_CVAR.

Swapped Remote CVars.
This commit is contained in:
Malkierian 2024-04-02 20:03:57 -07:00 committed by Malkierian
parent 808aca867e
commit cd3a4cfa09
4 changed files with 23 additions and 21 deletions

View File

@ -16,7 +16,7 @@ void GameInteractor::EnableRemoteInteractor() {
return;
}
if (SDLNet_ResolveHost(&remoteIP, CVarGetString("gRemote.IP", "127.0.0.1"), CVarGetInteger("gRemote.Port", 43384)) == -1) {
if (SDLNet_ResolveHost(&remoteIP, CVarGetString(REMOTE_CVAR("IP"), "127.0.0.1"), CVarGetInteger(REMOTE_CVAR("Port"), 43384)) == -1) {
SPDLOG_ERROR("[GameInteractor] SDLNet_ResolveHost: {}", SDLNet_GetError());
}

View File

@ -1148,8 +1148,8 @@ extern "C" void InitOTR() {
srand(now);
#ifdef ENABLE_REMOTE_CONTROL
SDLNet_Init();
if (CVarGetInteger("gRemote.Enabled", 0)) {
switch (CVarGetInteger("gRemote.Scheme", GI_SCHEME_SAIL)) {
if (CVarGetInteger(REMOTE_CVAR("Enabled"), 0)) {
switch (CVarGetInteger(REMOTE_CVAR("Scheme"), GI_SCHEME_SAIL)) {
case GI_SCHEME_SAIL:
GameInteractorSail::Instance->Enable();
break;
@ -1174,8 +1174,8 @@ extern "C" void DeinitOTR() {
SaveManager_ThreadPoolWait();
OTRAudio_Exit();
#ifdef ENABLE_REMOTE_CONTROL
if (CVarGetInteger("gRemote.Enabled", 0)) {
switch (CVarGetInteger("gRemote.Scheme", GI_SCHEME_SAIL)) {
if (CVarGetInteger(REMOTE_CVAR("Enabled"), 0)) {
switch (CVarGetInteger(REMOTE_CVAR("Scheme"), GI_SCHEME_SAIL)) {
case GI_SCHEME_SAIL:
GameInteractorSail::Instance->Disable();
break;

View File

@ -65,7 +65,7 @@ private:
uint32_t IsGameMasterQuest();
#endif
#define RANDOMIZER_CVAR(var) "gRandoEnhancements." var
#define RANDO_ENHANCEMENT_CVAR(var) "gRandoEnhancements." var
#define RANDOMIZER_SEED_CVAR(var) "gRandoSettings." var
#define COSMETIC_CVAR(var) "gCosmetics." var
#define AUDIO_CVAR(var) "gAudioEditor." var
@ -79,7 +79,9 @@ uint32_t IsGameMasterQuest();
#define ITEM_TRACKER_CVAR(var) TRACKER_CVAR("ItemTracker." var)
#define CHECK_TRACKER_CVAR(var) TRACKER_CVAR("CheckTracker." var)
#define ENTRANCE_TRACKER_CVAR(var) TRACKER_CVAR("EntranceTracker." var)
#define DEV_TOOLS_CVAR(var) "gDeveloperTools."
#define DEV_TOOLS_CVAR(var) "gDeveloperTools." var
#define GENERAL_CVAR(var) "gGeneral." var
#define REMOTE_CVAR(var) "gRemote." var
#ifndef __cplusplus
void InitOTR(void);

View File

@ -1752,27 +1752,27 @@ bool isStringEmpty(std::string str) {
#ifdef ENABLE_REMOTE_CONTROL
void DrawRemoteControlMenu() {
if (ImGui::BeginMenu("Network")) {
static std::string ip = CVarGetString("gRemote.IP", "127.0.0.1");
static uint16_t port = CVarGetInteger("gRemote.Port", 43384);
bool isFormValid = !isStringEmpty(CVarGetString("gRemote.IP", "127.0.0.1")) && port > 1024 && port < 65535;
static std::string ip = CVarGetString(REMOTE_CVAR("IP"), "127.0.0.1");
static uint16_t port = CVarGetInteger(REMOTE_CVAR("Port"), 43384);
bool isFormValid = !isStringEmpty(CVarGetString(REMOTE_CVAR("IP"), "127.0.0.1")) && port > 1024 && port < 65535;
const char* remoteOptions[2] = { "Sail", "Crowd Control"};
ImGui::BeginDisabled(GameInteractor::Instance->isRemoteInteractorEnabled);
ImGui::Text("Remote Interaction Scheme");
if (UIWidgets::EnhancementCombobox("gRemote.Scheme", remoteOptions, GI_SCHEME_SAIL)) {
switch (CVarGetInteger("gRemote.Scheme", GI_SCHEME_SAIL)) {
if (UIWidgets::EnhancementCombobox(REMOTE_CVAR("Scheme"), remoteOptions, GI_SCHEME_SAIL)) {
switch (CVarGetInteger(REMOTE_CVAR("Scheme"), GI_SCHEME_SAIL)) {
case GI_SCHEME_SAIL:
case GI_SCHEME_CROWD_CONTROL:
CVarSetString("gRemote.IP", "127.0.0.1");
CVarSetInteger("gRemote.Port", 43384);
CVarSetString(REMOTE_CVAR("IP"), "127.0.0.1");
CVarSetInteger(REMOTE_CVAR("Port"), 43384);
ip = "127.0.0.1";
port = 43384;
break;
}
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
}
switch (CVarGetInteger("gRemote.Scheme", GI_SCHEME_SAIL)) {
switch (CVarGetInteger(REMOTE_CVAR("Scheme"), GI_SCHEME_SAIL)) {
case GI_SCHEME_SAIL:
UIWidgets::InsertHelpHoverText(
"Sail is a networking protocol designed to facilitate remote "
@ -1805,14 +1805,14 @@ void DrawRemoteControlMenu() {
ImGui::Text("Remote IP & Port");
if (ImGui::InputText("##gRemote.IP", (char*)ip.c_str(), ip.capacity() + 1)) {
CVarSetString("gRemote.IP", ip.c_str());
CVarSetString(REMOTE_CVAR("IP"), ip.c_str());
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
}
ImGui::SameLine();
ImGui::PushItemWidth(ImGui::GetFontSize() * 5);
if (ImGui::InputScalar("##gRemote.Port", ImGuiDataType_U16, &port)) {
CVarSetInteger("gRemote.Port", port);
CVarSetInteger(REMOTE_CVAR("Port"), port);
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
}
@ -1825,9 +1825,9 @@ void DrawRemoteControlMenu() {
const char* buttonLabel = GameInteractor::Instance->isRemoteInteractorEnabled ? "Disable" : "Enable";
if (ImGui::Button(buttonLabel, ImVec2(-1.0f, 0.0f))) {
if (GameInteractor::Instance->isRemoteInteractorEnabled) {
CVarSetInteger("gRemote.Enabled", 0);
CVarSetInteger(REMOTE_CVAR("Enabled"), 0);
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
switch (CVarGetInteger("gRemote.Scheme", GI_SCHEME_SAIL)) {
switch (CVarGetInteger(REMOTE_CVAR("Scheme"), GI_SCHEME_SAIL)) {
case GI_SCHEME_SAIL:
GameInteractorSail::Instance->Disable();
break;
@ -1836,9 +1836,9 @@ void DrawRemoteControlMenu() {
break;
}
} else {
CVarSetInteger("gRemote.Enabled", 1);
CVarSetInteger(REMOTE_CVAR("Enabled"), 1);
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
switch (CVarGetInteger("gRemote.Scheme", GI_SCHEME_SAIL)) {
switch (CVarGetInteger(REMOTE_CVAR("Scheme"), GI_SCHEME_SAIL)) {
case GI_SCHEME_SAIL:
GameInteractorSail::Instance->Enable();
break;