Improvements in connection UI + random cleanup
This commit is contained in:
@@ -421,9 +421,9 @@ void Context::ParseArchipelago() {
|
||||
mSeedGenerated = false;
|
||||
mSpoilerLoaded = false;
|
||||
|
||||
ArchipelagoClient& ap_client = ArchipelagoClient::GetInstance();
|
||||
ParseArchipelagoItemsLocations(ap_client.GetScoutedItems());
|
||||
ParseArchipelagoOptions(ap_client.GetSlotData());
|
||||
ArchipelagoClient& apClient = ArchipelagoClient::GetInstance();
|
||||
ParseArchipelagoItemsLocations(apClient.GetScoutedItems());
|
||||
ParseArchipelagoOptions(apClient.GetSlotData());
|
||||
mEntranceShuffler->UnshuffleAllEntrances();
|
||||
mDungeons->ResetAllDungeons();
|
||||
mTrials->RemoveAllTrials();
|
||||
|
||||
@@ -52,8 +52,8 @@ bool ArchipelagoClient::StartClient() {
|
||||
|
||||
apClient->set_socket_error_handler([&](const std::string& msg) {
|
||||
retries++;
|
||||
if(retries > AP_Client_consts::MAX_RETRIES) {
|
||||
ArchipelagoConsole_SendMessage("[ERROR] Could not connect to server");
|
||||
if(retries >= AP_Client_consts::MAX_RETRIES) {
|
||||
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
|
||||
disconnecting = true;
|
||||
return;
|
||||
@@ -418,31 +418,11 @@ const std::vector<ArchipelagoClient::ApItem>& ArchipelagoClient::GetScoutedItems
|
||||
return scoutedItems;
|
||||
}
|
||||
|
||||
const char* ArchipelagoClient::GetConnectionStatus() {
|
||||
uint8_t ArchipelagoClient::GetConnectionStatus() {
|
||||
if (!apClient) {
|
||||
return "Disconnected!";
|
||||
}
|
||||
|
||||
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 "";
|
||||
return (uint8_t)APClient::State::DISCONNECTED;
|
||||
} else {
|
||||
return (uint8_t)apClient->get_state();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ static constexpr int MAX_PLAYER_NAME_LENGHT = 17;
|
||||
static constexpr int MAX_PASSWORD_LENGTH = 32;
|
||||
|
||||
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
|
||||
|
||||
class ArchipelagoClient {
|
||||
@@ -47,7 +47,7 @@ class ArchipelagoClient {
|
||||
// getters
|
||||
const std::string GetSlotName() const;
|
||||
|
||||
const char* GetConnectionStatus();
|
||||
uint8_t GetConnectionStatus();
|
||||
const nlohmann::json GetSlotData();
|
||||
const std::vector<ApItem>& GetScoutedItems();
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "soh/SaveManager.h"
|
||||
|
||||
void ArchipelagoSettingsWindow::DrawElement() {
|
||||
ArchipelagoClient& AP_client = ArchipelagoClient::GetInstance();
|
||||
ArchipelagoClient& apClient = ArchipelagoClient::GetInstance();
|
||||
|
||||
ImGui::SeparatorText("Connection info");
|
||||
|
||||
@@ -38,12 +38,36 @@ void ArchipelagoSettingsWindow::DrawElement() {
|
||||
ImGui::PopStyleColor();
|
||||
UIWidgets::PopStyleCombobox();
|
||||
|
||||
if (UIWidgets::Button("Connect", UIWidgets::ButtonOptions().Color(THEME_COLOR).Size(ImVec2(0.0, 0.0)))) {
|
||||
bool success = AP_client.StartClient();
|
||||
if (!apClient.IsConnected()) {
|
||||
if (UIWidgets::Button("Connect", UIWidgets::ButtonOptions().Color(THEME_COLOR).Size(ImVec2(0.0, 0.0)))) {
|
||||
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::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;
|
||||
if (!sArchipelagoTexturesLoaded) {
|
||||
|
||||
@@ -2233,14 +2233,6 @@ extern "C" void Randomizer_ShowRandomizerMenu() {
|
||||
SohGui::ShowRandomizerSettingsMenu();
|
||||
}
|
||||
|
||||
extern "C" void Archipelago_Connect() {
|
||||
ArchipelagoClient::GetInstance().StartClient();
|
||||
}
|
||||
|
||||
extern "C" void Archipelago_Disconnect() {
|
||||
ArchipelagoClient::GetInstance().StopClient();
|
||||
}
|
||||
|
||||
extern "C" void Archipelago_ShowArchipelagoMenu() {
|
||||
SohGui::ShowArchipelagoSettingsMenu();
|
||||
}
|
||||
|
||||
@@ -155,8 +155,6 @@ uint8_t Randomizer_IsSpoilerLoaded();
|
||||
void Randomizer_SetSpoilerLoaded(bool spoilerLoaded);
|
||||
uint8_t Randomizer_GenerateRandomizer();
|
||||
void Randomizer_ShowRandomizerMenu();
|
||||
void Archipelago_Connect();
|
||||
void Archipelago_Disconnect();
|
||||
void Archipelago_ShowArchipelagoMenu();
|
||||
int CustomMessage_RetrieveIfExists(PlayState* play);
|
||||
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 (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.
|
||||
if (CVarGetInteger(CVAR_REMOTE_ARCHIPELAGO("ConnectionStatus"), 0) != 4) {
|
||||
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_ERROR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
|
||||
|
||||
Reference in New Issue
Block a user