Improvements in connection UI + random cleanup
This commit is contained in:
@@ -421,9 +421,9 @@ void Context::ParseArchipelago() {
|
|||||||
mSeedGenerated = false;
|
mSeedGenerated = false;
|
||||||
mSpoilerLoaded = false;
|
mSpoilerLoaded = false;
|
||||||
|
|
||||||
ArchipelagoClient& ap_client = ArchipelagoClient::GetInstance();
|
ArchipelagoClient& apClient = ArchipelagoClient::GetInstance();
|
||||||
ParseArchipelagoItemsLocations(ap_client.GetScoutedItems());
|
ParseArchipelagoItemsLocations(apClient.GetScoutedItems());
|
||||||
ParseArchipelagoOptions(ap_client.GetSlotData());
|
ParseArchipelagoOptions(apClient.GetSlotData());
|
||||||
mEntranceShuffler->UnshuffleAllEntrances();
|
mEntranceShuffler->UnshuffleAllEntrances();
|
||||||
mDungeons->ResetAllDungeons();
|
mDungeons->ResetAllDungeons();
|
||||||
mTrials->RemoveAllTrials();
|
mTrials->RemoveAllTrials();
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ bool ArchipelagoClient::StartClient() {
|
|||||||
|
|
||||||
apClient->set_socket_error_handler([&](const std::string& msg) {
|
apClient->set_socket_error_handler([&](const std::string& msg) {
|
||||||
retries++;
|
retries++;
|
||||||
if(retries > AP_Client_consts::MAX_RETRIES) {
|
if(retries >= AP_Client_consts::MAX_RETRIES) {
|
||||||
ArchipelagoConsole_SendMessage("[ERROR] Could not connect to server");
|
ArchipelagoConsole_SendMessage("[ERROR] Could not connect to server after several tries.\nAre the entered server address and slot name correct?");
|
||||||
CVarSetInteger(CVAR_REMOTE_ARCHIPELAGO("ConnectionStatus"), 2); // Connection error
|
CVarSetInteger(CVAR_REMOTE_ARCHIPELAGO("ConnectionStatus"), 2); // Connection error
|
||||||
disconnecting = true;
|
disconnecting = true;
|
||||||
return;
|
return;
|
||||||
@@ -418,31 +418,11 @@ const std::vector<ArchipelagoClient::ApItem>& ArchipelagoClient::GetScoutedItems
|
|||||||
return scoutedItems;
|
return scoutedItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* ArchipelagoClient::GetConnectionStatus() {
|
uint8_t ArchipelagoClient::GetConnectionStatus() {
|
||||||
if (!apClient) {
|
if (!apClient) {
|
||||||
return "Disconnected!";
|
return (uint8_t)APClient::State::DISCONNECTED;
|
||||||
}
|
} else {
|
||||||
|
return (uint8_t)apClient->get_state();
|
||||||
APClient::State clientStatus = apClient->get_state();
|
|
||||||
|
|
||||||
switch (clientStatus) {
|
|
||||||
case APClient::State::DISCONNECTED: {
|
|
||||||
return "Disconnected!";
|
|
||||||
}
|
|
||||||
case APClient::State::SOCKET_CONNECTING: {
|
|
||||||
return "Socket Connecting!";
|
|
||||||
}
|
|
||||||
case APClient::State::SOCKET_CONNECTED: {
|
|
||||||
return "Socket Connected!";
|
|
||||||
}
|
|
||||||
case APClient::State::ROOM_INFO: {
|
|
||||||
return "Room info Received!";
|
|
||||||
}
|
|
||||||
case APClient::State::SLOT_CONNECTED: {
|
|
||||||
return "Slot Connected!";
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ static constexpr int MAX_PLAYER_NAME_LENGHT = 17;
|
|||||||
static constexpr int MAX_PASSWORD_LENGTH = 32;
|
static constexpr int MAX_PASSWORD_LENGTH = 32;
|
||||||
|
|
||||||
static constexpr char const* AP_GAME_NAME = "Ship of Harkinian";
|
static constexpr char const* AP_GAME_NAME = "Ship of Harkinian";
|
||||||
static constexpr int MAX_RETRIES = 6;
|
static constexpr int MAX_RETRIES = 3;
|
||||||
} // namespace AP_Client_consts
|
} // namespace AP_Client_consts
|
||||||
|
|
||||||
class ArchipelagoClient {
|
class ArchipelagoClient {
|
||||||
@@ -47,7 +47,7 @@ class ArchipelagoClient {
|
|||||||
// getters
|
// getters
|
||||||
const std::string GetSlotName() const;
|
const std::string GetSlotName() const;
|
||||||
|
|
||||||
const char* GetConnectionStatus();
|
uint8_t GetConnectionStatus();
|
||||||
const nlohmann::json GetSlotData();
|
const nlohmann::json GetSlotData();
|
||||||
const std::vector<ApItem>& GetScoutedItems();
|
const std::vector<ApItem>& GetScoutedItems();
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
#include "soh/SaveManager.h"
|
#include "soh/SaveManager.h"
|
||||||
|
|
||||||
void ArchipelagoSettingsWindow::DrawElement() {
|
void ArchipelagoSettingsWindow::DrawElement() {
|
||||||
ArchipelagoClient& AP_client = ArchipelagoClient::GetInstance();
|
ArchipelagoClient& apClient = ArchipelagoClient::GetInstance();
|
||||||
|
|
||||||
ImGui::SeparatorText("Connection info");
|
ImGui::SeparatorText("Connection info");
|
||||||
|
|
||||||
@@ -38,12 +38,36 @@ void ArchipelagoSettingsWindow::DrawElement() {
|
|||||||
ImGui::PopStyleColor();
|
ImGui::PopStyleColor();
|
||||||
UIWidgets::PopStyleCombobox();
|
UIWidgets::PopStyleCombobox();
|
||||||
|
|
||||||
|
if (!apClient.IsConnected()) {
|
||||||
if (UIWidgets::Button("Connect", UIWidgets::ButtonOptions().Color(THEME_COLOR).Size(ImVec2(0.0, 0.0)))) {
|
if (UIWidgets::Button("Connect", UIWidgets::ButtonOptions().Color(THEME_COLOR).Size(ImVec2(0.0, 0.0)))) {
|
||||||
bool success = AP_client.StartClient();
|
bool success = apClient.StartClient();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (UIWidgets::Button("Disconnect", UIWidgets::ButtonOptions().Color(THEME_COLOR).Size(ImVec2(0.0, 0.0)))) {
|
||||||
|
bool success = apClient.StopClient();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::Text(ArchipelagoClient::GetInstance().GetConnectionStatus());
|
|
||||||
|
uint8_t clientStatus = apClient.GetConnectionStatus();
|
||||||
|
switch (clientStatus) {
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
case 3:
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.7f, 0.7f, 0.7f, 1.0f));
|
||||||
|
ImGui::Text("Connecting...");
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.5f, 1.0f, 0.5f, 1.0f));
|
||||||
|
ImGui::Text("Connected");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.0f, 0.5f, 0.5f, 1.0f));
|
||||||
|
ImGui::Text("Not Connected");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ImGui::PopStyleColor();
|
||||||
|
|
||||||
static bool sArchipelagoTexturesLoaded = false;
|
static bool sArchipelagoTexturesLoaded = false;
|
||||||
if (!sArchipelagoTexturesLoaded) {
|
if (!sArchipelagoTexturesLoaded) {
|
||||||
|
|||||||
@@ -2233,14 +2233,6 @@ extern "C" void Randomizer_ShowRandomizerMenu() {
|
|||||||
SohGui::ShowRandomizerSettingsMenu();
|
SohGui::ShowRandomizerSettingsMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void Archipelago_Connect() {
|
|
||||||
ArchipelagoClient::GetInstance().StartClient();
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" void Archipelago_Disconnect() {
|
|
||||||
ArchipelagoClient::GetInstance().StopClient();
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" void Archipelago_ShowArchipelagoMenu() {
|
extern "C" void Archipelago_ShowArchipelagoMenu() {
|
||||||
SohGui::ShowArchipelagoSettingsMenu();
|
SohGui::ShowArchipelagoSettingsMenu();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -155,8 +155,6 @@ uint8_t Randomizer_IsSpoilerLoaded();
|
|||||||
void Randomizer_SetSpoilerLoaded(bool spoilerLoaded);
|
void Randomizer_SetSpoilerLoaded(bool spoilerLoaded);
|
||||||
uint8_t Randomizer_GenerateRandomizer();
|
uint8_t Randomizer_GenerateRandomizer();
|
||||||
void Randomizer_ShowRandomizerMenu();
|
void Randomizer_ShowRandomizerMenu();
|
||||||
void Archipelago_Connect();
|
|
||||||
void Archipelago_Disconnect();
|
|
||||||
void Archipelago_ShowArchipelagoMenu();
|
void Archipelago_ShowArchipelagoMenu();
|
||||||
int CustomMessage_RetrieveIfExists(PlayState* play);
|
int CustomMessage_RetrieveIfExists(PlayState* play);
|
||||||
void Overlay_DisplayText(float duration, const char* text);
|
void Overlay_DisplayText(float duration, const char* text);
|
||||||
|
|||||||
@@ -1806,7 +1806,6 @@ void FileChoose_UpdateArchipelagoMenu(GameState* thisx) {
|
|||||||
|
|
||||||
if (CHECK_BTN_ALL(input->press.button, BTN_A)) {
|
if (CHECK_BTN_ALL(input->press.button, BTN_A)) {
|
||||||
if (this->archipelagoIndex == ASM_START_ARCHIPELAGO) {
|
if (this->archipelagoIndex == ASM_START_ARCHIPELAGO) {
|
||||||
uint16_t testnumber = CVarGetInteger(CVAR_REMOTE_ARCHIPELAGO("ConnectionStatus"), 0);
|
|
||||||
// Only continue when connected to a slot and locations are scouted.
|
// Only continue when connected to a slot and locations are scouted.
|
||||||
if (CVarGetInteger(CVAR_REMOTE_ARCHIPELAGO("ConnectionStatus"), 0) != 4) {
|
if (CVarGetInteger(CVAR_REMOTE_ARCHIPELAGO("ConnectionStatus"), 0) != 4) {
|
||||||
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_ERROR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
|
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_ERROR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
|
||||||
|
|||||||
Reference in New Issue
Block a user