mirror of
https://github.com/EricPlayZ/EGameTools.git
synced 2025-07-18 17:37:53 +08:00
fixed some GUI stuff
This commit is contained in:
@ -4474,9 +4474,7 @@ namespace Config {
|
|||||||
reinterpret_cast<KeyBindOption*>(entry.optionPtr)->ChangeKeyBind(it->code);
|
reinterpret_cast<KeyBindOption*>(entry.optionPtr)->ChangeKeyBind(it->code);
|
||||||
} else if (entry.key == "SavedTeleportLocations") {
|
} else if (entry.key == "SavedTeleportLocations") {
|
||||||
Menu::Teleport::savedTeleportLocations = Menu::Teleport::ParseTeleportLocations(strValue);
|
Menu::Teleport::savedTeleportLocations = Menu::Teleport::ParseTeleportLocations(strValue);
|
||||||
Menu::Teleport::savedTeleportLocationNames.clear();
|
Menu::Teleport::UpdateTeleportLocationVisualNames();
|
||||||
for (const auto& tpLoc : Menu::Teleport::savedTeleportLocations)
|
|
||||||
Menu::Teleport::savedTeleportLocationNames.push_back(tpLoc.name.data());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4551,9 +4549,7 @@ namespace Config {
|
|||||||
break;
|
break;
|
||||||
} else if (entry.key == "SavedTeleportLocations") {
|
} else if (entry.key == "SavedTeleportLocations") {
|
||||||
Menu::Teleport::savedTeleportLocations = Menu::Teleport::ParseTeleportLocations(strValue);
|
Menu::Teleport::savedTeleportLocations = Menu::Teleport::ParseTeleportLocations(strValue);
|
||||||
Menu::Teleport::savedTeleportLocationNames.clear();
|
Menu::Teleport::UpdateTeleportLocationVisualNames();
|
||||||
for (const auto& tpLoc : Menu::Teleport::savedTeleportLocations)
|
|
||||||
Menu::Teleport::savedTeleportLocationNames.push_back(tpLoc.name.data());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,8 @@
|
|||||||
namespace Menu {
|
namespace Menu {
|
||||||
namespace Teleport {
|
namespace Teleport {
|
||||||
std::vector<TeleportLocation> savedTeleportLocations;
|
std::vector<TeleportLocation> savedTeleportLocations;
|
||||||
std::vector<const char*> savedTeleportLocationNames;
|
static std::vector<std::string> savedTeleportLocationNames;
|
||||||
|
static std::vector<const char*> savedTeleportLocationNamesPtrs;
|
||||||
static int selectedTPLocation = -1;
|
static int selectedTPLocation = -1;
|
||||||
static char newLocationName[25]{};
|
static char newLocationName[25]{};
|
||||||
|
|
||||||
@ -18,6 +19,17 @@ namespace Menu {
|
|||||||
KeyBindOption teleportToSelectedLocation{ VK_F9 };
|
KeyBindOption teleportToSelectedLocation{ VK_F9 };
|
||||||
KeyBindOption teleportToCoords{ VK_NONE };
|
KeyBindOption teleportToCoords{ VK_NONE };
|
||||||
|
|
||||||
|
void UpdateTeleportLocationVisualNames() {
|
||||||
|
savedTeleportLocationNames.clear();
|
||||||
|
savedTeleportLocationNamesPtrs.clear();
|
||||||
|
for (const auto& loc : savedTeleportLocations) {
|
||||||
|
std::string completeName = loc.name + " (X: " + std::format("{:.1f}", loc.pos.X) + ", Y: " + std::format("{:.1f}", loc.pos.X) + ", Z: " + std::format("{:.1f}", loc.pos.Z) + ")";
|
||||||
|
savedTeleportLocationNames.emplace_back(completeName);
|
||||||
|
}
|
||||||
|
for (const auto& name : savedTeleportLocationNames) {
|
||||||
|
savedTeleportLocationNamesPtrs.emplace_back(name.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
std::vector<TeleportLocation> ParseTeleportLocations(const std::string& input) {
|
std::vector<TeleportLocation> ParseTeleportLocations(const std::string& input) {
|
||||||
if (input.empty())
|
if (input.empty())
|
||||||
return {};
|
return {};
|
||||||
@ -187,18 +199,22 @@ namespace Menu {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SaveTeleportLocation(const char* locationName) {
|
static bool SaveTeleportLocation(const char* locationName) {
|
||||||
if (isTeleportationDisabled()) {
|
if (isTeleportationDisabled()) {
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
ImGui::EndPopup();
|
||||||
ImGui::OpenPopup("Couldn't add location");
|
ImGui::OpenPopup("Couldn't add location");
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto savedLocIt = std::find_if(savedTeleportLocations.begin(), savedTeleportLocations.end(), [&locationName](const auto& loc) {
|
auto savedLocIt = std::find_if(savedTeleportLocations.begin(), savedTeleportLocations.end(), [&locationName](const auto& loc) {
|
||||||
return loc.name == locationName;
|
return loc.name == locationName;
|
||||||
});
|
});
|
||||||
if (savedLocIt != savedTeleportLocations.end()) {
|
if (savedLocIt != savedTeleportLocations.end()) {
|
||||||
ImGui::OpenPopup("The location you have entered already exists, if you want to change it then please remove it and add it again.");
|
ImGui::CloseCurrentPopup();
|
||||||
return;
|
ImGui::EndPopup();
|
||||||
|
ImGui::OpenPopup("Location already exists");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 playerPos{};
|
Vector3 playerPos{};
|
||||||
@ -206,58 +222,80 @@ namespace Menu {
|
|||||||
if (Camera::freeCam.GetValue()) {
|
if (Camera::freeCam.GetValue()) {
|
||||||
GamePH::FreeCamera* freeCam = GamePH::FreeCamera::Get();
|
GamePH::FreeCamera* freeCam = GamePH::FreeCamera::Get();
|
||||||
if (!freeCam) {
|
if (!freeCam) {
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
ImGui::EndPopup();
|
||||||
ImGui::OpenPopup("Couldn't add location");
|
ImGui::OpenPopup("Couldn't add location");
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 camPos{};
|
Vector3 camPos{};
|
||||||
freeCam->GetPosition(&camPos);
|
freeCam->GetPosition(&camPos);
|
||||||
if (camPos.isDefault()) {
|
if (camPos.isDefault()) {
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
ImGui::EndPopup();
|
||||||
ImGui::OpenPopup("Couldn't add location");
|
ImGui::OpenPopup("Couldn't add location");
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
playerPos = camPos;
|
playerPos = camPos;
|
||||||
} else {
|
} else {
|
||||||
Engine::CBulletPhysicsCharacter* playerCharacter = Engine::CBulletPhysicsCharacter::Get();
|
Engine::CBulletPhysicsCharacter* playerCharacter = Engine::CBulletPhysicsCharacter::Get();
|
||||||
if (!playerCharacter) {
|
if (!playerCharacter) {
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
ImGui::EndPopup();
|
||||||
ImGui::OpenPopup("Couldn't add location");
|
ImGui::OpenPopup("Couldn't add location");
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
playerPos = playerCharacter->playerPos;
|
playerPos = playerCharacter->playerPos;
|
||||||
}
|
}
|
||||||
playerPos = playerPos.round(1);
|
playerPos = playerPos.round(1);
|
||||||
|
|
||||||
if (savedLocIt != savedTeleportLocations.end() && savedLocIt->pos.round() == playerPos.round()) {
|
savedLocIt = std::find_if(savedTeleportLocations.begin(), savedTeleportLocations.end(), [&playerPos](const auto& loc) {
|
||||||
|
return loc.pos == playerPos;
|
||||||
|
});
|
||||||
|
if (savedLocIt != savedTeleportLocations.end() && savedLocIt->pos == playerPos) {
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
ImGui::EndPopup();
|
||||||
ImGui::OpenPopup("Location already exists");
|
ImGui::OpenPopup("Location already exists");
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
savedTeleportLocations.emplace_back(std::string(locationName), playerPos);
|
savedTeleportLocations.emplace_back(std::string(locationName), playerPos);
|
||||||
savedTeleportLocationNames.clear();
|
UpdateTeleportLocationVisualNames();
|
||||||
for (const auto& loc : savedTeleportLocations)
|
|
||||||
savedTeleportLocationNames.emplace_back(loc.name.data());
|
ImGui::CloseCurrentPopup();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
static void HandleDialogs() {
|
static void HandleDialogs() {
|
||||||
if (ImGui::BeginPopupModal("Give the location a name", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
|
if (ImGui::BeginPopupModal("Give the location a name", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||||
if (ImGui::InputTextWithHint("##TPLocationNameInputText", "Location name", newLocationName, IM_ARRAYSIZE(newLocationName), ImGuiInputTextFlags_EnterReturnsTrue) || ImGui::Button("OK", ImVec2(120.0f, 0.0f))) {
|
bool tpSaveResult = true;
|
||||||
SaveTeleportLocation(newLocationName);
|
ImGui::PushItemWidth(500.0f * Menu::scale);
|
||||||
|
if (ImGui::InputTextWithHint("##TPLocationNameInputText", "Location name", newLocationName, IM_ARRAYSIZE(newLocationName), ImGuiInputTextFlags_EnterReturnsTrue) || ImGui::Button("OK", ImVec2(500.0f, 0.0f) * Menu::scale)) {
|
||||||
|
ImGui::PopItemWidth();
|
||||||
|
tpSaveResult = SaveTeleportLocation(newLocationName);
|
||||||
newLocationName[0] = 0;
|
newLocationName[0] = 0;
|
||||||
|
}
|
||||||
|
if (tpSaveResult)
|
||||||
|
ImGui::EndPopup();
|
||||||
|
}
|
||||||
|
if (ImGui::BeginPopupModal("Location already exists", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||||
|
ImGui::PushItemWidth(500.0f * Menu::scale);
|
||||||
|
ImGui::TextCentered("The location you have entered already exists. Either the name of the location, or the position of the location is already inside the list. If you want to change it then please remove it and add it again.", false);
|
||||||
|
if (ImGui::Button("OK", ImVec2(500.0f, 0.0f) * Menu::scale)) {
|
||||||
|
ImGui::PopItemWidth();
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
}
|
}
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
if (ImGui::BeginPopupModal("Location already exists", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
|
ImGui::SetNextWindowSizeConstraints(ImVec2(500.0f, 0.0f) * Menu::scale, ImVec2(500.0f, 800.0f) * Menu::scale);
|
||||||
ImGui::Text("The location you have entered already exists. Either the name of the location, or the position of the location is already inside the list. If you want to change it then please remove it and add it again.");
|
|
||||||
if (ImGui::Button("OK", ImVec2(120.0f, 0.0f)))
|
|
||||||
ImGui::CloseCurrentPopup();
|
|
||||||
ImGui::EndPopup();
|
|
||||||
}
|
|
||||||
if (ImGui::BeginPopupModal("Couldn't add location", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
|
if (ImGui::BeginPopupModal("Couldn't add location", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||||
ImGui::Text("Something went wrong trying to add a location. Either the player class or camera class are not found, or you're in a place in the game where the character or camera isn't properly loaded. If this happens, even though you know it should work fine, please contact @EricPlayZ on NexusMods, GitHub or Discord.");
|
ImGui::PushItemWidth(500.0f * Menu::scale);
|
||||||
if (ImGui::Button("OK", ImVec2(120.0f, 0.0f)))
|
ImGui::TextCentered("Something went wrong trying to add a location. Either the player class or camera class are not found, or you're in a place in the game where the character or camera isn't properly loaded. If this happens, even though you know it should work fine, please contact @EricPlayZ on NexusMods, GitHub or Discord.");
|
||||||
|
if (ImGui::Button("OK", ImVec2(500.0f, 0.0f) * Menu::scale)) {
|
||||||
|
ImGui::PopItemWidth();
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
|
}
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -271,7 +309,7 @@ namespace Menu {
|
|||||||
ImGui::SeparatorText("Saved Locations##Teleport");
|
ImGui::SeparatorText("Saved Locations##Teleport");
|
||||||
ImGui::BeginDisabled(isTeleportationDisabled()); {
|
ImGui::BeginDisabled(isTeleportationDisabled()); {
|
||||||
ImGui::PushItemWidth(-FLT_MIN);
|
ImGui::PushItemWidth(-FLT_MIN);
|
||||||
ImGui::ListBox("##SavedTPLocationsListBox", &selectedTPLocation, savedTeleportLocationNames.data(), static_cast<int>(savedTeleportLocationNames.size()), 5);
|
ImGui::ListBox("##SavedTPLocationsListBox", &selectedTPLocation, savedTeleportLocationNamesPtrs.data(), static_cast<int>(savedTeleportLocationNamesPtrs.size()), 5);
|
||||||
ImGui::PopItemWidth();
|
ImGui::PopItemWidth();
|
||||||
|
|
||||||
ImGui::EndDisabled();
|
ImGui::EndDisabled();
|
||||||
@ -283,9 +321,7 @@ namespace Menu {
|
|||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (ImGui::Button("Remove Selected Location")) {
|
if (ImGui::Button("Remove Selected Location")) {
|
||||||
savedTeleportLocations.erase(savedTeleportLocations.begin() + selectedTPLocation);
|
savedTeleportLocations.erase(savedTeleportLocations.begin() + selectedTPLocation);
|
||||||
savedTeleportLocationNames.clear();
|
UpdateTeleportLocationVisualNames();
|
||||||
for (const auto& loc : savedTeleportLocations)
|
|
||||||
savedTeleportLocationNames.emplace_back(loc.name.data());
|
|
||||||
selectedTPLocation = -1;
|
selectedTPLocation = -1;
|
||||||
}
|
}
|
||||||
ImGui::EndDisabled();
|
ImGui::EndDisabled();
|
||||||
@ -324,7 +360,7 @@ namespace Menu {
|
|||||||
ImGui::Text(playerPos.data());
|
ImGui::Text(playerPos.data());
|
||||||
ImGui::Text(cameraPos.data());
|
ImGui::Text(cameraPos.data());
|
||||||
|
|
||||||
ImGui::PushItemWidth(200.0f);
|
ImGui::PushItemWidth(200.0f * Menu::scale);
|
||||||
ImGui::InputFloat("X", &teleportCoords.X, 1.0f, 10.0f, "%.2f");
|
ImGui::InputFloat("X", &teleportCoords.X, 1.0f, 10.0f, "%.2f");
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::InputFloat("Y", &teleportCoords.Y, 1.0f, 10.0f, "%.2f");
|
ImGui::InputFloat("Y", &teleportCoords.Y, 1.0f, 10.0f, "%.2f");
|
||||||
|
@ -9,11 +9,11 @@ namespace Menu {
|
|||||||
};
|
};
|
||||||
|
|
||||||
extern std::vector<TeleportLocation> savedTeleportLocations;
|
extern std::vector<TeleportLocation> savedTeleportLocations;
|
||||||
extern std::vector<const char*> savedTeleportLocationNames;
|
|
||||||
|
|
||||||
extern KeyBindOption teleportToSelectedLocation;
|
extern KeyBindOption teleportToSelectedLocation;
|
||||||
extern KeyBindOption teleportToCoords;
|
extern KeyBindOption teleportToCoords;
|
||||||
|
|
||||||
|
extern void UpdateTeleportLocationVisualNames();
|
||||||
extern std::vector<TeleportLocation> ParseTeleportLocations(const std::string& input);
|
extern std::vector<TeleportLocation> ParseTeleportLocations(const std::string& input);
|
||||||
extern std::string ConvertTeleportLocationsToStr(const std::vector<TeleportLocation>& teleportLocations);
|
extern std::string ConvertTeleportLocationsToStr(const std::vector<TeleportLocation>& teleportLocations);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user