diff --git a/soh/soh/Network/Archipelago/Archipelago.cpp b/soh/soh/Network/Archipelago/Archipelago.cpp index 6e64489cc..1990f7c1c 100644 --- a/soh/soh/Network/Archipelago/Archipelago.cpp +++ b/soh/soh/Network/Archipelago/Archipelago.cpp @@ -342,6 +342,14 @@ void ArchipelagoClient::SendGameWon() { } } +void ArchipelagoClient::SendMessage(const char* message) { + if(apClient == nullptr) { + return; + } + + apClient->Say(std::string(message)); +} + void ArchipelagoClient::Poll() { if(apClient == nullptr) { return; diff --git a/soh/soh/Network/Archipelago/Archipelago.h b/soh/soh/Network/Archipelago/Archipelago.h index bd8a14d6e..a2056c71a 100644 --- a/soh/soh/Network/Archipelago/Archipelago.h +++ b/soh/soh/Network/Archipelago/Archipelago.h @@ -58,7 +58,7 @@ class ArchipelagoClient{ void QueueExternalCheck(int64_t apLocation); void SendGameWon(); - + void SendMessage(const char* message); void Poll(); std::unique_ptr apClient; diff --git a/soh/soh/Network/Archipelago/ArchipelagoConsoleWindow.cpp b/soh/soh/Network/Archipelago/ArchipelagoConsoleWindow.cpp index eea74ac02..66a91d692 100644 --- a/soh/soh/Network/Archipelago/ArchipelagoConsoleWindow.cpp +++ b/soh/soh/Network/Archipelago/ArchipelagoConsoleWindow.cpp @@ -66,6 +66,26 @@ void ArchipelagoConsoleWindow::DrawElement() { ImGui::EndChild(); ImGui::PopStyleColor(); ImGui::PopStyleVar(3); + + static char textEntryBuf[1024]; + static bool keepFocus = false; + + if(keepFocus) { + ImGui::SetKeyboardFocusHere(); + keepFocus = false; + } + if(ImGui::InputText("##AP_MessageField", textEntryBuf, 1023, ImGuiInputTextFlags_EnterReturnsTrue)) { + ArchipelagoClient::GetInstance().SendMessage(textEntryBuf); + textEntryBuf[0] = '\0'; + keepFocus = true; + } + //keepFocus = ImGui::IsItemActive(); + ImGui::SameLine(); + if(ImGui::Button("Send")) { + ArchipelagoClient::GetInstance().SendMessage(textEntryBuf); + textEntryBuf[0] = '\0'; + keepFocus = true; + } }; ImVec4 getColorVal(const std::string& color) { // TODO change color strings to an enum