mirror of
https://github.com/HarbourMasters/Shipwright
synced 2026-06-25 18:24:27 -04:00
0d2346d322
* Avoid `randomizer_check_tracker.h` in widely used `randomizer.h` due to transitive `libultraship.h`/`UIWidgets.hpp` inclusion * Avoid `libultraship.h` inclusion in heavily used `GameInteractor.h` header * Remove unused libultraship includes * Break huge unneeded transitive include chain (via UIWidgets.hpp) This avoids that changing just UIWidgets.hpp, for example, would retrigger a rebuild of like half the project. There were a huge transitive include chains, mostly via MenuTypes.h and UIWidgets.hpp. Because of that, I'm splitting UIWidgets into a second header file UIWidgetOptions.hpp, which can be consumed by MenuTypes.h. MenuTypes.h is split into BackendTypes.h to avoid pulling in Fast3D/Windowing/GUI stuff into unrelated code. Example chain, one of many: libultraship.h <- UIWidgets.hpp <- MenuTypes.hpp <- randomizer/option.h <- randomizer/item_location.h <- trial.h <- static_data.h <- SeedContext <- (basically all randomizer related sources, lots of other sources in Enhancement, more...) * Avoid libultraship.h in Notification.h and ObjectExtension.h; these headers are also heavily used * Add missing include * Remove unused libultraship includes * Include only ship/window/GuiWindow.h in GUI-related headers instead of libultraship.h * Cleanup ConfigUpdater.h and playthrough.cpp * Remove libultraship.h from Anchor.h and fix transitive dependencies in OTRGlobals.cpp * Remove unused libultraship.h includes in Anchor code
133 lines
5.0 KiB
C++
133 lines
5.0 KiB
C++
#include "Anchor.h"
|
|
#include <ship/window/gui/IconsFontAwesome4.h>
|
|
#include "soh/OTRGlobals.h"
|
|
#include "soh/util.h"
|
|
#include "soh/Enhancements/randomizer/SeedContext.h"
|
|
|
|
extern "C" {
|
|
#include "variables.h"
|
|
#include "functions.h"
|
|
extern PlayState* gPlayState;
|
|
}
|
|
|
|
void AnchorRoomWindow::Draw() {
|
|
if (!IsVisible() || !Anchor::Instance->isConnected) {
|
|
return;
|
|
}
|
|
|
|
ImGui::PushStyleColor(ImGuiCol_WindowBg,
|
|
ImVec4(0, 0, 0, CVarGetFloat(CVAR_SETTING("Notifications.BgOpacity"), 0.5f)));
|
|
ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0, 0, 0, 0));
|
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 4.0f);
|
|
|
|
auto vp = ImGui::GetMainViewport();
|
|
ImGui::SetNextWindowViewport(vp->ID);
|
|
|
|
ImGui::Begin("Anchor Room", nullptr,
|
|
ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoFocusOnAppearing |
|
|
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoTitleBar |
|
|
ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoScrollbar);
|
|
|
|
DrawElement();
|
|
|
|
ImGui::End();
|
|
|
|
ImGui::PopStyleVar();
|
|
ImGui::PopStyleColor(2);
|
|
}
|
|
|
|
void AnchorRoomWindow::DrawElement() {
|
|
bool isGlobalRoom = (std::string("soh-global") == CVarGetString(CVAR_REMOTE_ANCHOR("RoomId"), ""));
|
|
|
|
if (isGlobalRoom) {
|
|
u32 activeClients = 0;
|
|
for (auto& [clientId, client] : Anchor::Instance->clients) {
|
|
if (client.online) {
|
|
activeClients++;
|
|
}
|
|
}
|
|
ImGui::Text("Players Online: %d", activeClients);
|
|
return;
|
|
}
|
|
|
|
// First build a list of teams
|
|
std::set<std::string> teams;
|
|
for (auto& [clientId, client] : Anchor::Instance->clients) {
|
|
teams.insert(client.teamId);
|
|
}
|
|
|
|
for (auto& team : teams) {
|
|
if (teams.size() > 1) {
|
|
ImGui::SeparatorText(team.c_str());
|
|
}
|
|
bool isOwnTeam = team == CVarGetString(CVAR_REMOTE_ANCHOR("TeamId"), "default");
|
|
for (auto& [clientId, client] : Anchor::Instance->clients) {
|
|
if (client.teamId != team) {
|
|
continue;
|
|
}
|
|
|
|
ImGui::PushID(clientId);
|
|
|
|
if (client.clientId == Anchor::Instance->roomState.ownerClientId) {
|
|
ImGui::TextColored(ImVec4(1, 1, 0, 1), "%s", ICON_FA_GAVEL);
|
|
ImGui::SameLine();
|
|
}
|
|
|
|
if (client.self) {
|
|
ImGui::TextColored(ImVec4(0.8f, 1.0f, 0.8f, 1.0f), "%s", CVarGetString(CVAR_REMOTE_ANCHOR("Name"), ""));
|
|
} else if (!client.online) {
|
|
ImGui::TextColored(ImVec4(1, 1, 1, 0.3f), "%s - offline", client.name.c_str());
|
|
ImGui::PopID();
|
|
continue;
|
|
} else {
|
|
ImGui::Text("%s", client.name.c_str());
|
|
}
|
|
|
|
if (Anchor::Instance->roomState.showLocationsMode == 2 ||
|
|
(Anchor::Instance->roomState.showLocationsMode == 1 && isOwnTeam)) {
|
|
if ((client.self ? Anchor::Instance->IsSaveLoaded() : client.isSaveLoaded)) {
|
|
ImGui::SameLine();
|
|
ImGui::TextColored(
|
|
ImVec4(1, 1, 1, 0.5f), "- %s",
|
|
SohUtils::GetSceneName(client.self ? gPlayState->sceneNum : client.sceneNum).c_str());
|
|
}
|
|
}
|
|
|
|
if (Anchor::Instance->CanTeleportTo(client.clientId)) {
|
|
ImGui::SameLine();
|
|
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0));
|
|
if (ImGui::Button(ICON_FA_LOCATION_ARROW, ImVec2(20.0f, 20.0f))) {
|
|
Anchor::Instance->SendPacket_RequestTeleport(client.clientId);
|
|
}
|
|
ImGui::PopStyleVar();
|
|
}
|
|
|
|
if (client.clientVersion != Anchor::clientVersion) {
|
|
ImGui::SameLine();
|
|
ImGui::TextColored(ImVec4(1, 0, 0, 1), ICON_FA_EXCLAMATION_TRIANGLE);
|
|
if (ImGui::IsItemHovered()) {
|
|
ImGui::BeginTooltip();
|
|
ImGui::Text("Incompatible version! Will not work together!");
|
|
ImGui::Text("Yours: %s", Anchor::clientVersion.c_str());
|
|
ImGui::Text("Theirs: %s", client.clientVersion.c_str());
|
|
ImGui::EndTooltip();
|
|
}
|
|
}
|
|
uint32_t seed = IS_RANDO ? Rando::Context::GetInstance()->GetSeed() : 0;
|
|
if (client.isSaveLoaded && Anchor::Instance->IsSaveLoaded() && client.seed != seed && client.online &&
|
|
!client.self) {
|
|
ImGui::SameLine();
|
|
ImGui::TextColored(ImVec4(1, 0, 0, 1), ICON_FA_EXCLAMATION_TRIANGLE);
|
|
if (ImGui::IsItemHovered()) {
|
|
ImGui::BeginTooltip();
|
|
ImGui::Text("Seed mismatch! Continuing will break things!");
|
|
ImGui::Text("Yours: %u", seed);
|
|
ImGui::Text("Theirs: %u", client.seed);
|
|
ImGui::EndTooltip();
|
|
}
|
|
}
|
|
ImGui::PopID();
|
|
}
|
|
}
|
|
}
|