Replace archi SPD instances with built in console
This commit is contained in:
@@ -348,13 +348,12 @@ void Context::SetSpoilerLoaded(const bool spoilerLoaded) {
|
|||||||
|
|
||||||
void Context::AddRecievedArchipelagoItem(const std::string& ap_item_id) {
|
void Context::AddRecievedArchipelagoItem(const std::string& ap_item_id) {
|
||||||
mAPrecieveQueue.emplace(ap_item_id);
|
mAPrecieveQueue.emplace(ap_item_id);
|
||||||
SPDLOG_TRACE("Item Pushed {}", ap_item_id);
|
std::string logMessage = "[LOG] Item Pushed: " + ap_item_id;
|
||||||
AddToArchipelagoConsole("Item Pushed");
|
ArchipelagoConsole_SendMessage(logMessage.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
GetItemEntry Context::GetArchipelagoGIEntry() {
|
GetItemEntry Context::GetArchipelagoGIEntry() {
|
||||||
SPDLOG_TRACE("Trying to get Item Entry");
|
ArchipelagoConsole_SendMessage("[LOG] Trying to get Item Entry");
|
||||||
AddToArchipelagoConsole("Trying to get Item Entry");
|
|
||||||
if(mAPrecieveQueue.empty()) {
|
if(mAPrecieveQueue.empty()) {
|
||||||
// something must have gone wrong here, just give a rupee
|
// something must have gone wrong here, just give a rupee
|
||||||
return ItemTableManager::Instance->RetrieveItemEntry(MOD_NONE, GI_HEART);
|
return ItemTableManager::Instance->RetrieveItemEntry(MOD_NONE, GI_HEART);
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
#include "soh/SaveManager.h"
|
#include "soh/SaveManager.h"
|
||||||
#include "soh/Enhancements/randomizer/ShuffleFairies.h"
|
#include "soh/Enhancements/randomizer/ShuffleFairies.h"
|
||||||
#include "soh/Network/Archipelago/Archipelago.h"
|
#include "soh/Network/Archipelago/Archipelago.h"
|
||||||
|
#include "soh/Network/Archipelago/ArchipelagoConsoleWindow.h"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "macros.h"
|
#include "macros.h"
|
||||||
@@ -223,7 +224,8 @@ static RandomizerCheck randomizerQueuedCheck = RC_UNKNOWN_CHECK;
|
|||||||
static GetItemEntry randomizerQueuedItemEntry = GET_ITEM_NONE;
|
static GetItemEntry randomizerQueuedItemEntry = GET_ITEM_NONE;
|
||||||
|
|
||||||
void ArchipelagoOnRecieveItem(const std::string& ap_item_name) {
|
void ArchipelagoOnRecieveItem(const std::string& ap_item_name) {
|
||||||
SPDLOG_TRACE("Recieve item handler called! {}", ap_item_name);
|
std::string logMessage = "[LOG] Receive item handler called: " + ap_item_name;
|
||||||
|
ArchipelagoConsole_SendMessage(logMessage.c_str());
|
||||||
randomizerQueuedChecks.push(RC_ARCHIPELAGO_RECIEVED_ITEM);
|
randomizerQueuedChecks.push(RC_ARCHIPELAGO_RECIEVED_ITEM);
|
||||||
Rando::Context::GetInstance()->AddRecievedArchipelagoItem(ap_item_name);
|
Rando::Context::GetInstance()->AddRecievedArchipelagoItem(ap_item_name);
|
||||||
}
|
}
|
||||||
@@ -314,7 +316,6 @@ void RandomizerOnPlayerUpdateForRCQueueHandler() {
|
|||||||
GetItemID vanillaItem = (GetItemID)Rando::StaticData::RetrieveItem(vanillaRandomizerGet).GetItemID();
|
GetItemID vanillaItem = (GetItemID)Rando::StaticData::RetrieveItem(vanillaRandomizerGet).GetItemID();
|
||||||
getItemEntry = Rando::Context::GetInstance()->GetFinalGIEntry(rc, true, (GetItemID)vanillaRandomizerGet);
|
getItemEntry = Rando::Context::GetInstance()->GetFinalGIEntry(rc, true, (GetItemID)vanillaRandomizerGet);
|
||||||
}
|
}
|
||||||
SPDLOG_TRACE("RC found!");
|
|
||||||
|
|
||||||
if (loc->HasObtained()) {
|
if (loc->HasObtained()) {
|
||||||
SPDLOG_INFO("RC {} already obtained, skipping", static_cast<uint32_t>(rc));
|
SPDLOG_INFO("RC {} already obtained, skipping", static_cast<uint32_t>(rc));
|
||||||
@@ -373,8 +374,6 @@ void RandomizerOnItemReceiveHandler(GetItemEntry receivedItemEntry) {
|
|||||||
if (randomizerQueuedCheck == RC_UNKNOWN_CHECK)
|
if (randomizerQueuedCheck == RC_UNKNOWN_CHECK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SPDLOG_TRACE("Dropped into recieve handler!");
|
|
||||||
|
|
||||||
auto loc = Rando::Context::GetInstance()->GetItemLocation(randomizerQueuedCheck);
|
auto loc = Rando::Context::GetInstance()->GetItemLocation(randomizerQueuedCheck);
|
||||||
if (randomizerQueuedItemEntry.modIndex == receivedItemEntry.modIndex &&
|
if (randomizerQueuedItemEntry.modIndex == receivedItemEntry.modIndex &&
|
||||||
randomizerQueuedItemEntry.itemId == receivedItemEntry.itemId) {
|
randomizerQueuedItemEntry.itemId == receivedItemEntry.itemId) {
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
typedef enum {
|
typedef enum {
|
||||||
MOD_NONE,
|
MOD_NONE,
|
||||||
MOD_RANDOMIZER,
|
MOD_RANDOMIZER,
|
||||||
MOD_ARCHIPELAGO // no actually used yet i think
|
|
||||||
} ModIndex;
|
} ModIndex;
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TABLE_VANILLA = MOD_NONE,
|
TABLE_VANILLA = MOD_NONE,
|
||||||
|
|||||||
@@ -4,12 +4,12 @@
|
|||||||
|
|
||||||
#include "soh/OTRGlobals.h"
|
#include "soh/OTRGlobals.h"
|
||||||
|
|
||||||
#include <spdlog/spdlog.h>
|
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "consolevariablebridge.h"
|
#include "consolevariablebridge.h"
|
||||||
|
|
||||||
|
#include "soh/Network/Archipelago/ArchipelagoConsoleWindow.h"
|
||||||
|
|
||||||
namespace Rando {
|
namespace Rando {
|
||||||
std::shared_ptr<Settings> Settings::mInstance;
|
std::shared_ptr<Settings> Settings::mInstance;
|
||||||
|
|
||||||
@@ -2968,7 +2968,8 @@ void Settings::ParseArchipelago(const std::map<std::string, int>& slot_data) {
|
|||||||
const std::string& setting_name = std::string(StaticData::APsettingToHoSsetting[APname]);
|
const std::string& setting_name = std::string(StaticData::APsettingToHoSsetting[APname]);
|
||||||
const RandomizerSettingKey index = StaticData::optionNameToEnum[setting_name];
|
const RandomizerSettingKey index = StaticData::optionNameToEnum[setting_name];
|
||||||
mContext->GetOption(index).Set(value);
|
mContext->GetOption(index).Set(value);
|
||||||
SPDLOG_INFO("Parsed Setting {}: ({}, {})", APname, (int)index, value);
|
std::string logMessage = "[LOG] Parsed Setting " + APname + ": (" + std::to_string((int)index) + ", " + std::to_string(value) + ")";
|
||||||
|
ArchipelagoConsole_SendMessage(logMessage.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// maybe we have to set a couple of settings manually, if ap doesn't set them
|
// maybe we have to set a couple of settings manually, if ap doesn't set them
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <spdlog/spdlog.h>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "soh/Network/Archipelago/ArchipelagoConsoleWindow.h"
|
||||||
#include "soh/Enhancements/randomizer/randomizerTypes.h"
|
#include "soh/Enhancements/randomizer/randomizerTypes.h"
|
||||||
#include "soh/Enhancements/randomizer/static_data.h"
|
#include "soh/Enhancements/randomizer/static_data.h"
|
||||||
#include "soh/Enhancements/game-interactor/GameInteractor.h"
|
#include "soh/Enhancements/game-interactor/GameInteractor.h"
|
||||||
@@ -67,7 +67,8 @@ bool ArchipelagoClient::start_client() {
|
|||||||
const std::string itemName = apItem.itemName;
|
const std::string itemName = apItem.itemName;
|
||||||
const std::string playerName = apItem.playerName;
|
const std::string playerName = apItem.playerName;
|
||||||
const std::string locationName = apItem.locationName;
|
const std::string locationName = apItem.locationName;
|
||||||
SPDLOG_TRACE("Location scouted: {} for {} in location {}", itemName, playerName, locationName);
|
std::string logMessage = "[LOG] Location scouted: " + itemName + " for " + playerName + " in location " + locationName;
|
||||||
|
ArchipelagoConsole_SendMessage(logMessage.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
}); // todo maybe move these functions to a lambda, since they don't have to be static anymore
|
}); // todo maybe move these functions to a lambda, since they don't have to be static anymore
|
||||||
@@ -108,7 +109,8 @@ void ArchipelagoClient::check_location(RandomizerCheck SoH_check_id) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int64_t ap_item_id = apclient->get_location_id(std::string(ap_name));
|
int64_t ap_item_id = apclient->get_location_id(std::string(ap_name));
|
||||||
SPDLOG_TRACE("Checked: {}({}), sending to AP server", ap_name, ap_item_id);
|
std::string logMessage = "[LOG] Checked: " + ap_name + "(" + std::to_string(ap_item_id) + "), sending to AP server";
|
||||||
|
ArchipelagoConsole_SendMessage(logMessage.c_str());
|
||||||
|
|
||||||
// currently not sending, because i only get so many real chances
|
// currently not sending, because i only get so many real chances
|
||||||
if(!isConnected()) {
|
if(!isConnected()) {
|
||||||
@@ -127,7 +129,7 @@ void ArchipelagoClient::removeItemRecievedCallback(std::function<void(const std:
|
|||||||
|
|
||||||
void ArchipelagoClient::on_connected() {
|
void ArchipelagoClient::on_connected() {
|
||||||
// todo implement me
|
// todo implement me
|
||||||
SPDLOG_TRACE("AP Connected!!");
|
ArchipelagoConsole_SendMessage("[LOG] AP Connected!");
|
||||||
}
|
}
|
||||||
//void ArchipelagoClient::on_couldntConnect(AP_ConnectionStatus connection_status) {
|
//void ArchipelagoClient::on_couldntConnect(AP_ConnectionStatus connection_status) {
|
||||||
// // todo implement me
|
// // todo implement me
|
||||||
@@ -138,7 +140,8 @@ void ArchipelagoClient::on_item_recieved(int64_t recieved_item_id, bool notify_p
|
|||||||
const std::string item_name = apclient->get_item_name(recieved_item_id, AP_Client_consts::AP_GAME_NAME);
|
const std::string item_name = apclient->get_item_name(recieved_item_id, AP_Client_consts::AP_GAME_NAME);
|
||||||
ArchipelagoClient& ap_client = ArchipelagoClient::getInstance();
|
ArchipelagoClient& ap_client = ArchipelagoClient::getInstance();
|
||||||
if(ap_client.ItemRecievedCallback) {
|
if(ap_client.ItemRecievedCallback) {
|
||||||
SPDLOG_TRACE("item recieved: {}, notify: {}", item_name, notify_player);
|
std::string logMessage = "[LOG] Item recieved: " + item_name + ". Notify: " + std::to_string(notify_player);
|
||||||
|
ArchipelagoConsole_SendMessage(logMessage.c_str());
|
||||||
ap_client.ItemRecievedCallback.operator()(item_name); // somehow passing it through the itemname breaks it????
|
ap_client.ItemRecievedCallback.operator()(item_name); // somehow passing it through the itemname breaks it????
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ ImVector<char*> Items;
|
|||||||
bool autoScroll = true;
|
bool autoScroll = true;
|
||||||
bool scrollToBottom = false;
|
bool scrollToBottom = false;
|
||||||
|
|
||||||
void AddToArchipelagoConsole(const char* fmt, ...) IM_FMTARGS(2) {
|
void ArchipelagoConsole_SendMessage(const char* fmt, ...) IM_FMTARGS(2) {
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
@@ -22,7 +22,7 @@ void ArchipelagoConsoleWindow::DrawElement() {
|
|||||||
const float footer_height_to_reserve = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing();
|
const float footer_height_to_reserve = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing();
|
||||||
|
|
||||||
if (ImGui::Button("Add line to log")) {
|
if (ImGui::Button("Add line to log")) {
|
||||||
AddToArchipelagoConsole("Hello world");
|
ArchipelagoConsole_SendMessage("Hello World");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui::BeginChild("ScrollingRegion", ImVec2(0, 400), false,
|
if (ImGui::BeginChild("ScrollingRegion", ImVec2(0, 400), false,
|
||||||
|
|||||||
@@ -15,6 +15,6 @@ class ArchipelagoConsoleWindow final : public Ship::GuiWindow {
|
|||||||
void UpdateElement() override {};
|
void UpdateElement() override {};
|
||||||
};
|
};
|
||||||
|
|
||||||
void AddToArchipelagoConsole(const char* fmt, ...);
|
void ArchipelagoConsole_SendMessage(const char* fmt, ...);
|
||||||
|
|
||||||
#endif // ARCHIPELAGO_CONSOLE_WINDOW_H
|
#endif // ARCHIPELAGO_CONSOLE_WINDOW_H
|
||||||
@@ -15,7 +15,7 @@ void ArchipelagoSettingsWindow::DrawElement() {
|
|||||||
|
|
||||||
if (ImGui::Button("Connect")) {
|
if (ImGui::Button("Connect")) {
|
||||||
bool success = AP_client.start_client();
|
bool success = AP_client.start_client();
|
||||||
AddToArchipelagoConsole("Trying to connect...");
|
ArchipelagoConsole_SendMessage("[LOG] Trying to connect...");
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
|||||||
Reference in New Issue
Block a user