Ui bug fixes

This commit is contained in:
Grinch_ 2022-04-20 11:57:49 +06:00
parent ab571e22a9
commit a0994f625d
5 changed files with 21 additions and 39 deletions

View File

@ -234,7 +234,7 @@
"CustomSkinsDirTip": "Place your dff & txd files inside 'modloader/CustomSkins'", "CustomSkinsDirTip": "Place your dff & txd files inside 'modloader/CustomSkins'",
"CustomSkinsTab": "Custom skins", "CustomSkinsTab": "Custom skins",
"CustomSkinsTip": "Note: Your txd & dff names can't exceed 8 characters. Don't change names while the game is running.", "CustomSkinsTip": "Note: Your txd & dff names can't exceed 8 characters. Don't change names while the game is running.",
"CustomSkinTutorial": "Custom skin allows to change player skins without replacing any existing game ped skins.\n\nSteps to enable 'Custom Skins',\n\n\n1. Download & install modloader\n\n2. Create a folder inside 'modloader' folder with the name 'CustomSkins'\n\n3. Download ped skins online ( .dff & .txd files) and put them inside.\n\n4. Restart your game.\n\n\n\nLimitations:\n\n1. Your .dff & .txd file names must not exceed 8 characters.\n\n2. Do not rename them while the game is running\n\n\nDoing so will crash your game.", "CustomSkinTutorial": "Custom skin allows to change player skins without replacing any existing game ped skins.\n\nSteps to enable 'Custom Skins',\n\n1. Download & install modloader\n2. Create a folder inside 'modloader' folder with the name 'CustomSkins'\n3. Download ped skins online ( .dff & .txd files) and put them inside.\n4. Restart your game.\n\nLimitations:\n\n1. Your .dff & .txd file names must not exceed 8 characters.\n2. Do not rename them while the game is running\n\nDoing so will crash your game.",
"CycleJump": "Higher cycle jumps", "CycleJump": "Higher cycle jumps",
"DownloadModloader": "Download modloader", "DownloadModloader": "Download modloader",
"DrunkEffect": "Drunk effect", "DrunkEffect": "Drunk effect",

View File

@ -602,7 +602,7 @@ void Menu::ShowPage()
if (ImGui::CollapsingHeader(TEXT("Menu.QuickWepSpawnerCMD"))) if (ImGui::CollapsingHeader(TEXT("Menu.QuickWepSpawnerCMD")))
{ {
ImGui::Spacing(); ImGui::Spacing();
ImGui::TextWrapped(TEXT("Menu.QuickWepSpawnerCMDTxt")); ImGui::TextWrapped(TEXT("Menu.QuickWepSpawnerCMDText"));
ImGui::Spacing(); ImGui::Spacing();
ImGui::Separator(); ImGui::Separator();
} }

View File

@ -49,7 +49,7 @@ bool Ui::DrawTitleBar()
return pressed; return pressed;
} }
bool Ui::RoundedImageButton(ImTextureID user_texture_id, ImVec2& size, const char* hover_text, int frame_padding, const ImVec4& bg_col, const ImVec4& tint_col) bool Ui::RoundedImageButton(ImTextureID user_texture_id, ImVec2& size, const char* hover_text)
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow; ImGuiWindow* window = g.CurrentWindow;
@ -61,62 +61,42 @@ bool Ui::RoundedImageButton(ImTextureID user_texture_id, ImVec2& size, const cha
const ImGuiID id = window->GetID("#image"); const ImGuiID id = window->GetID("#image");
ImGui::PopID(); ImGui::PopID();
ImVec2 padding = (frame_padding >= 0) ? ImVec2((float)frame_padding, (float)frame_padding) : g.Style.FramePadding; ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size);
if (window->SkipItems)
return false;
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size + padding * 2);
ImGui::ItemSize(bb); ImGui::ItemSize(bb);
if (!ImGui::ItemAdd(bb, id)) if (!ImGui::ItemAdd(bb, id))
return false; return false;
bool hovered, held; window->DrawList->AddImageRounded(user_texture_id, bb.Min, bb.Max, ImVec2(0, 0), ImVec2(1, 1), ImGui::GetColorU32(ImVec4(1, 1, 1, 1)), 5.0f);
bool pressed = ImGui::ButtonBehavior(bb, id, &hovered, &held);
// Render
const ImU32 col = ImGui::GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button);
ImGui::RenderNavHighlight(bb, id);
ImGui::RenderFrame(bb.Min, bb.Max, col, true, ImClamp((float)ImMin(padding.x, padding.y), 0.0f, g.Style.FrameRounding));
if (bg_col.w > 0.0f)
window->DrawList->AddRectFilled(bb.Min + padding, bb.Max - padding, ImGui::GetColorU32(bg_col));
window->DrawList->AddImageRounded(user_texture_id, bb.Min + padding, bb.Max - padding, ImVec2(0, 0), ImVec2(1, 1), ImGui::GetColorU32(tint_col), 5.0f);
if (ImGui::IsItemHovered()) if (ImGui::IsItemHovered())
{ {
ImDrawList* drawlist = ImGui::GetWindowDrawList(); window->DrawList->AddRectFilled(bb.Min, bb.Max, ImGui::GetColorU32(ImGuiCol_ModalWindowDimBg), 5.6f);
// Drawing selected overlay
ImVec2 btnMin = ImGui::GetItemRectMin();
ImVec2 btnMax = ImGui::GetItemRectMax();
drawlist->AddRectFilled(btnMin, btnMax, ImGui::GetColorU32(ImGuiCol_ModalWindowDimBg), 8.0f);
// Calculating and drawing text over the image // Calculating and drawing text over the image
ImVec2 textSize = ImGui::CalcTextSize(hover_text); ImVec2 textSize = ImGui::CalcTextSize(hover_text);
if (textSize.x < size.x) if (textSize.x < size.x)
{ {
float offsetX = (ImGui::GetItemRectSize().x - textSize.x) / 2; float offsetX = (ImGui::GetItemRectSize().x - textSize.x) / 2;
drawlist->AddText(ImVec2(btnMin.x + offsetX, btnMin.y + 10), ImGui::GetColorU32(ImGuiCol_Text), hover_text); window->DrawList->AddText(ImVec2(bb.Min.x + offsetX, bb.Min.y + 10), ImGui::GetColorU32(ImGuiCol_Text), hover_text);
} }
else else
{ {
std::string buff = ""; std::string buf = "";
std::stringstream ss(hover_text); std::stringstream ss(hover_text);
short count = 1; short count = 1;
while (ss >> buff) while (ss >> buf)
{ {
textSize = ImGui::CalcTextSize(buff.c_str()); textSize = ImGui::CalcTextSize(buf.c_str());
float offsetX = (ImGui::GetItemRectSize().x - textSize.x) / 2; float offsetX = (ImGui::GetItemRectSize().x - textSize.x) / 2;
drawlist->AddText(ImVec2(btnMin.x + offsetX, btnMin.y + 10 * count), window->DrawList->AddText(ImVec2(bb.Min.x + offsetX, bb.Min.y + 10 * count),
ImGui::GetColorU32(ImGuiCol_Text), buff.c_str()); ImGui::GetColorU32(ImGuiCol_Text), buf.c_str());
++count; ++count;
} }
} }
} }
return pressed; return ImGui::IsItemClicked(0);
} }
bool Ui::ListBox(const char* label, std::vector<std::string>& all_items, int& selected) bool Ui::ListBox(const char* label, std::vector<std::string>& all_items, int& selected)
@ -553,6 +533,7 @@ void Ui::DrawImages(ResourceStore &store, std::function<void(std::string&)> onLe
std::function<std::string(std::string&)> getName, std::function<bool(std::string&)> verifyFunc, std::function<std::string(std::string&)> getName, std::function<bool(std::string&)> verifyFunc,
const char** customNames, size_t length) const char** customNames, size_t length)
{ {
ImGuiStyle& style = ImGui::GetStyle();
/* /*
Trying to scale images based on resolutions Trying to scale images based on resolutions
Native 1366x768 Native 1366x768
@ -563,7 +544,8 @@ void Ui::DrawImages(ResourceStore &store, std::function<void(std::string&)> onLe
int imageCount = 1; int imageCount = 1;
int imagesInRow = static_cast<int>(ImGui::GetWindowContentRegionWidth() / m_ImageSize.x); int imagesInRow = static_cast<int>(ImGui::GetWindowContentRegionWidth() / m_ImageSize.x);
m_ImageSize.x = ImGui::GetWindowContentRegionWidth() / imagesInRow - static_cast<int>(ImGuiStyleVar_ItemSpacing) * 0.65f; m_ImageSize.x = ImGui::GetWindowContentRegionWidth() - style.ItemSpacing.x * (imagesInRow-1);
m_ImageSize.x /= imagesInRow;
ImGui::Spacing(); ImGui::Spacing();
@ -573,7 +555,7 @@ void Ui::DrawImages(ResourceStore &store, std::function<void(std::string&)> onLe
imgPopup.function = nullptr; imgPopup.function = nullptr;
} }
ImGui::PushItemWidth((ImGui::GetWindowContentRegionWidth() - ImGui::GetStyle().ItemSpacing.x)/2); ImGui::PushItemWidth((ImGui::GetWindowContentRegionWidth() - style.ItemSpacing.x)/2);
if (customNames) if (customNames)
{ {
ListBoxCustomNames("##Categories", store.m_Categories, store.m_Selected, customNames, length); ListBoxCustomNames("##Categories", store.m_Categories, store.m_Selected, customNames, length);
@ -620,7 +602,7 @@ void Ui::DrawImages(ResourceStore &store, std::function<void(std::string&)> onLe
} }
else else
{ {
if (Ui::RoundedImageButton(store.m_ImagesList[i]->m_pTexture, m_ImageSize, modelName.c_str(), 0, ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1))) if (Ui::RoundedImageButton(store.m_ImagesList[i]->m_pTexture, m_ImageSize, modelName.c_str()))
{ {
onLeftClick(text); onLeftClick(text);
} }
@ -637,7 +619,7 @@ void Ui::DrawImages(ResourceStore &store, std::function<void(std::string&)> onLe
{ {
if (imageCount % imagesInRow != 0) if (imageCount % imagesInRow != 0)
{ {
ImGui::SameLine(0.0, ImGui::GetStyle().ItemInnerSpacing.x); ImGui::SameLine(0.0, style.ItemInnerSpacing.x);
} }
} }
imageCount++; imageCount++;

View File

@ -81,7 +81,7 @@ public:
static void RadioButtonAddress(const char* label, std::vector<NamedMemory>& named_mem); static void RadioButtonAddress(const char* label, std::vector<NamedMemory>& named_mem);
static void RadioButtonAddressEx(const char* label, int addr, std::vector<NamedValue>& named_val); static void RadioButtonAddressEx(const char* label, int addr, std::vector<NamedValue>& named_val);
static bool RoundedImageButton(ImTextureID user_texture_id, ImVec2& size, const char* hover_text, int frame_padding, const ImVec4& bg_col, const ImVec4& tint_col); static bool RoundedImageButton(ImTextureID user_texture_id, ImVec2& size, const char* hover_text);
static void ColorPickerAddress(const char* label, int base_addr, ImVec4&& default_color); static void ColorPickerAddress(const char* label, int base_addr, ImVec4&& default_color);
static void ShowTooltip(const char* text); static void ShowTooltip(const char* text);
}; };

View File

@ -2,5 +2,5 @@
#define MENU_NAME "Cheat Menu" #define MENU_NAME "Cheat Menu"
#define MENU_VERSION_NUMBER "3.3" #define MENU_VERSION_NUMBER "3.3"
#define MENU_VERSION MENU_VERSION_NUMBER"-beta" #define MENU_VERSION MENU_VERSION_NUMBER"-beta"
#define BUILD_NUMBER "20220328" #define BUILD_NUMBER "20220417"
#define MENU_TITLE MENU_NAME " v" MENU_VERSION #define MENU_TITLE MENU_NAME " v" MENU_VERSION