Added textbox to console window for chatting and server commands

This commit is contained in:
Jerom Venneker
2025-05-29 19:38:38 +02:00
parent 7d49cb1281
commit 497700fe6a
3 changed files with 29 additions and 1 deletions

View File

@@ -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;

View File

@@ -58,7 +58,7 @@ class ArchipelagoClient{
void QueueExternalCheck(int64_t apLocation);
void SendGameWon();
void SendMessage(const char* message);
void Poll();
std::unique_ptr<APClient> apClient;

View File

@@ -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