Added text recieved from AP to the log
This commit is contained in:
@@ -349,11 +349,11 @@ void Context::SetSpoilerLoaded(const bool spoilerLoaded) {
|
|||||||
void Context::AddRecievedArchipelagoItem(const RandomizerGet item) {
|
void Context::AddRecievedArchipelagoItem(const RandomizerGet item) {
|
||||||
mAPrecieveQueue.emplace(item);
|
mAPrecieveQueue.emplace(item);
|
||||||
std::string logMessage = "[LOG] Item Pushed: " + item;
|
std::string logMessage = "[LOG] Item Pushed: " + item;
|
||||||
ArchipelagoConsole_SendMessage(logMessage.c_str());
|
ArchipelagoConsole_SendMessage(logMessage.c_str(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
GetItemEntry Context::GetArchipelagoGIEntry() {
|
GetItemEntry Context::GetArchipelagoGIEntry() {
|
||||||
ArchipelagoConsole_SendMessage("[LOG] Trying to get Item Entry");
|
ArchipelagoConsole_SendMessage("[LOG] Trying to get Item Entry", true);
|
||||||
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);
|
||||||
|
|||||||
@@ -25,18 +25,14 @@ extern PlayState* gPlayState;
|
|||||||
}
|
}
|
||||||
|
|
||||||
ArchipelagoClient::ArchipelagoClient() {
|
ArchipelagoClient::ArchipelagoClient() {
|
||||||
std::string uuid = ap_get_uuid("uuid");
|
uuid = ap_get_uuid("uuid");
|
||||||
|
|
||||||
gameWon = false;
|
gameWon = false;
|
||||||
|
itemQueued = false;
|
||||||
namespace apc = AP_Client_consts;
|
|
||||||
CVarSetInteger(CVAR_REMOTE_ARCHIPELAGO("Connected"), 0);
|
|
||||||
bool itemQueued = false;
|
|
||||||
|
|
||||||
// call poll every frame
|
// call poll every frame
|
||||||
COND_HOOK(GameInteractor::OnGameFrameUpdate, true, [](){ArchipelagoClient::GetInstance().Poll();});
|
COND_HOOK(GameInteractor::OnGameFrameUpdate, true, [](){ArchipelagoClient::GetInstance().Poll();});
|
||||||
COND_HOOK(GameInteractor::OnLoadGame, true, [](int32_t file_id){ArchipelagoClient::GetInstance().GameLoaded();});
|
COND_HOOK(GameInteractor::OnLoadGame, true, [](int32_t file_id){ArchipelagoClient::GetInstance().GameLoaded();});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ArchipelagoClient& ArchipelagoClient::GetInstance() {
|
ArchipelagoClient& ArchipelagoClient::GetInstance() {
|
||||||
@@ -62,7 +58,7 @@ bool ArchipelagoClient::StartClient() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
apClient->set_slot_connected_handler([&](const nlohmann::json data) {
|
apClient->set_slot_connected_handler([&](const nlohmann::json data) {
|
||||||
ArchipelagoConsole_SendMessage("[LOG] Connected.", false);
|
ArchipelagoConsole_SendMessage("[LOG] Connected.", true);
|
||||||
ArchipelagoClient::StartLocationScouts();
|
ArchipelagoClient::StartLocationScouts();
|
||||||
|
|
||||||
slotData = data;
|
slotData = data;
|
||||||
@@ -105,10 +101,10 @@ bool ArchipelagoClient::StartClient() {
|
|||||||
const std::string playerName = apItem.playerName;
|
const std::string playerName = apItem.playerName;
|
||||||
const std::string locationName = apItem.locationName;
|
const std::string locationName = apItem.locationName;
|
||||||
std::string logMessage = "[LOG] Location scouted: " + itemName + " for " + playerName + " in location " + locationName;
|
std::string logMessage = "[LOG] Location scouted: " + itemName + " for " + playerName + " in location " + locationName;
|
||||||
ArchipelagoConsole_SendMessage(logMessage.c_str());
|
ArchipelagoConsole_SendMessage(logMessage.c_str(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
ArchipelagoConsole_SendMessage("[LOG] Scouting finished.");
|
ArchipelagoConsole_SendMessage("[LOG] Scouting finished.", true);
|
||||||
}); // 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
|
||||||
|
|
||||||
apClient->set_location_checked_handler([&](const std::list<int64_t> locations) {
|
apClient->set_location_checked_handler([&](const std::list<int64_t> locations) {
|
||||||
@@ -117,6 +113,11 @@ bool ArchipelagoClient::StartClient() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
apClient->set_print_json_handler([&](const std::list<APClient::TextNode>& nodes) {
|
||||||
|
std::string text = apClient->render_json(nodes, APClient::RenderFormat::TEXT);
|
||||||
|
ArchipelagoConsole_SendMessage(text.c_str(), false);
|
||||||
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,7 +132,7 @@ void ArchipelagoClient::GameLoaded() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArchipelagoConsole_SendMessage("[LOG] Synching Items and Locations.");
|
ArchipelagoConsole_SendMessage("[LOG] Synching Items and Locations.", true);
|
||||||
|
|
||||||
SynchItems();
|
SynchItems();
|
||||||
SynchSentLocations();
|
SynchSentLocations();
|
||||||
@@ -153,7 +154,7 @@ void ArchipelagoClient::StartLocationScouts() {
|
|||||||
|
|
||||||
void ArchipelagoClient::SynchItems() {
|
void ArchipelagoClient::SynchItems() {
|
||||||
// Send a Synch request to get any items we may have missed
|
// Send a Synch request to get any items we may have missed
|
||||||
ArchipelagoConsole_SendMessage("[LOG] Sending synch request");
|
ArchipelagoConsole_SendMessage("[LOG] Sending synch request", true);
|
||||||
apClient->Sync();
|
apClient->Sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,7 +169,7 @@ void ArchipelagoClient::SynchSentLocations() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::string locationLog = "[LOG] Synching " + std::to_string(checkedLocations.size())+ " checks already found in game";
|
std::string locationLog = "[LOG] Synching " + std::to_string(checkedLocations.size())+ " checks already found in game";
|
||||||
ArchipelagoConsole_SendMessage(locationLog.c_str());
|
ArchipelagoConsole_SendMessage(locationLog.c_str(), true);
|
||||||
|
|
||||||
apClient->LocationChecks(checkedLocations);
|
apClient->LocationChecks(checkedLocations);
|
||||||
}
|
}
|
||||||
@@ -198,7 +199,7 @@ void ArchipelagoClient::CheckLocation(RandomizerCheck sohCheckId) {
|
|||||||
int64_t apItemId = apClient->get_location_id(std::string(apName));
|
int64_t apItemId = apClient->get_location_id(std::string(apName));
|
||||||
|
|
||||||
std::string logMessage = "[LOG] Checked: " + apName + "(" + std::to_string(apItemId) + "), sending to AP server";
|
std::string logMessage = "[LOG] Checked: " + apName + "(" + std::to_string(apItemId) + "), sending to AP server";
|
||||||
ArchipelagoConsole_SendMessage(logMessage.c_str());
|
ArchipelagoConsole_SendMessage(logMessage.c_str(), true);
|
||||||
|
|
||||||
if(!IsConnected()) {
|
if(!IsConnected()) {
|
||||||
return;
|
return;
|
||||||
@@ -214,7 +215,7 @@ void ArchipelagoClient::OnItemReceived(const ApItem apItem) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string logMessage = "[Log] Recieved " + apItem.itemName;
|
std::string logMessage = "[Log] Recieved " + apItem.itemName;
|
||||||
ArchipelagoConsole_SendMessage(logMessage.c_str());
|
ArchipelagoConsole_SendMessage(logMessage.c_str(), true);
|
||||||
|
|
||||||
// add item to the queue
|
// add item to the queue
|
||||||
recieveQueue.push(apItem);
|
recieveQueue.push(apItem);
|
||||||
@@ -224,12 +225,12 @@ void ArchipelagoClient::QueueItem(const ApItem item) {
|
|||||||
if(item.index < gSaveContext.ship.quest.data.archipelago.lastReceivedItemIndex) {
|
if(item.index < gSaveContext.ship.quest.data.archipelago.lastReceivedItemIndex) {
|
||||||
// Skip queueing any items we already have
|
// Skip queueing any items we already have
|
||||||
std::string logMessage = "[Log] Skipping giving " + item.itemName + ". We recieved this previously.";
|
std::string logMessage = "[Log] Skipping giving " + item.itemName + ". We recieved this previously.";
|
||||||
ArchipelagoConsole_SendMessage(logMessage.c_str());
|
ArchipelagoConsole_SendMessage(logMessage.c_str(), true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string logMessage = "[Log] Giving " + item.itemName;
|
std::string logMessage = "[Log] Giving " + item.itemName;
|
||||||
ArchipelagoConsole_SendMessage(logMessage.c_str());
|
ArchipelagoConsole_SendMessage(logMessage.c_str(), true);
|
||||||
const RandomizerGet RG = Rando::StaticData::itemNameToEnum[item.itemName];
|
const RandomizerGet RG = Rando::StaticData::itemNameToEnum[item.itemName];
|
||||||
if(RG == RG_NONE) {
|
if(RG == RG_NONE) {
|
||||||
return;
|
return;
|
||||||
@@ -390,6 +391,8 @@ void InitArchipelagoData(bool isDebug) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RegisterArchipelago() {
|
void RegisterArchipelago() {
|
||||||
|
CVarSetInteger(CVAR_REMOTE_ARCHIPELAGO("Connected"), 0);
|
||||||
|
|
||||||
COND_HOOK(GameInteractor::OnRandomizerItemGivenHooks, IS_ARCHIPELAGO,
|
COND_HOOK(GameInteractor::OnRandomizerItemGivenHooks, IS_ARCHIPELAGO,
|
||||||
[](uint32_t rc, GetItemEntry gi, uint8_t isGiSkipped) {
|
[](uint32_t rc, GetItemEntry gi, uint8_t isGiSkipped) {
|
||||||
if (rc == RC_ARCHIPELAGO_RECIEVED_ITEM) {
|
if (rc == RC_ARCHIPELAGO_RECIEVED_ITEM) {
|
||||||
|
|||||||
@@ -10,7 +10,9 @@ bool autoScroll = true;
|
|||||||
using namespace UIWidgets;
|
using namespace UIWidgets;
|
||||||
|
|
||||||
void ArchipelagoConsole_SendMessage(const char* fmt, bool debugMessage, ...) {
|
void ArchipelagoConsole_SendMessage(const char* fmt, bool debugMessage, ...) {
|
||||||
if (!debugMessage || CVarGetInteger(CVAR_REMOTE_ARCHIPELAGO("DebugEnabled"), 0)) {
|
if (debugMessage && CVarGetInteger(CVAR_REMOTE_ARCHIPELAGO("DebugEnabled"), 0) == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
@@ -19,7 +21,6 @@ void ArchipelagoConsole_SendMessage(const char* fmt, bool debugMessage, ...) {
|
|||||||
va_end(args);
|
va_end(args);
|
||||||
Items.push_back(strdup(buf));
|
Items.push_back(strdup(buf));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void ArchipelagoConsoleWindow::DrawElement() {
|
void ArchipelagoConsoleWindow::DrawElement() {
|
||||||
ImGui::SeparatorText("Archipelago Log");
|
ImGui::SeparatorText("Archipelago Log");
|
||||||
|
|||||||
@@ -15,6 +15,6 @@ class ArchipelagoConsoleWindow final : public Ship::GuiWindow {
|
|||||||
void UpdateElement() override {};
|
void UpdateElement() override {};
|
||||||
};
|
};
|
||||||
|
|
||||||
void ArchipelagoConsole_SendMessage(const char* fmt, bool debugMessage = true, ...);
|
void ArchipelagoConsole_SendMessage(const char* fmt, bool debugMessage = false, ...);
|
||||||
|
|
||||||
#endif // ARCHIPELAGO_CONSOLE_WINDOW_H
|
#endif // ARCHIPELAGO_CONSOLE_WINDOW_H
|
||||||
@@ -39,7 +39,7 @@ void ArchipelagoSettingsWindow::DrawElement() {
|
|||||||
|
|
||||||
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 = AP_client.StartClient();
|
||||||
ArchipelagoConsole_SendMessage("[LOG] Trying to connect...", false);
|
ArchipelagoConsole_SendMessage("[LOG] Trying to connect...", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
|||||||
Reference in New Issue
Block a user