Ui bug fixes
This commit is contained in:
parent
ab571e22a9
commit
a0994f625d
@ -234,7 +234,7 @@
|
||||
"CustomSkinsDirTip": "Place your dff & txd files inside 'modloader/CustomSkins'",
|
||||
"CustomSkinsTab": "Custom skins",
|
||||
"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",
|
||||
"DownloadModloader": "Download modloader",
|
||||
"DrunkEffect": "Drunk effect",
|
||||
|
@ -602,7 +602,7 @@ void Menu::ShowPage()
|
||||
if (ImGui::CollapsingHeader(TEXT("Menu.QuickWepSpawnerCMD")))
|
||||
{
|
||||
ImGui::Spacing();
|
||||
ImGui::TextWrapped(TEXT("Menu.QuickWepSpawnerCMDTxt"));
|
||||
ImGui::TextWrapped(TEXT("Menu.QuickWepSpawnerCMDText"));
|
||||
ImGui::Spacing();
|
||||
ImGui::Separator();
|
||||
}
|
||||
|
52
src/ui.cpp
52
src/ui.cpp
@ -49,7 +49,7 @@ bool Ui::DrawTitleBar()
|
||||
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;
|
||||
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");
|
||||
ImGui::PopID();
|
||||
|
||||
ImVec2 padding = (frame_padding >= 0) ? ImVec2((float)frame_padding, (float)frame_padding) : g.Style.FramePadding;
|
||||
|
||||
if (window->SkipItems)
|
||||
return false;
|
||||
|
||||
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size + padding * 2);
|
||||
ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size);
|
||||
ImGui::ItemSize(bb);
|
||||
if (!ImGui::ItemAdd(bb, id))
|
||||
return false;
|
||||
|
||||
bool hovered, held;
|
||||
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);
|
||||
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);
|
||||
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
ImDrawList* drawlist = ImGui::GetWindowDrawList();
|
||||
|
||||
// Drawing selected overlay
|
||||
ImVec2 btnMin = ImGui::GetItemRectMin();
|
||||
ImVec2 btnMax = ImGui::GetItemRectMax();
|
||||
drawlist->AddRectFilled(btnMin, btnMax, ImGui::GetColorU32(ImGuiCol_ModalWindowDimBg), 8.0f);
|
||||
window->DrawList->AddRectFilled(bb.Min, bb.Max, ImGui::GetColorU32(ImGuiCol_ModalWindowDimBg), 5.6f);
|
||||
|
||||
// Calculating and drawing text over the image
|
||||
ImVec2 textSize = ImGui::CalcTextSize(hover_text);
|
||||
if (textSize.x < size.x)
|
||||
{
|
||||
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
|
||||
{
|
||||
std::string buff = "";
|
||||
std::string buf = "";
|
||||
std::stringstream ss(hover_text);
|
||||
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;
|
||||
drawlist->AddText(ImVec2(btnMin.x + offsetX, btnMin.y + 10 * count),
|
||||
ImGui::GetColorU32(ImGuiCol_Text), buff.c_str());
|
||||
window->DrawList->AddText(ImVec2(bb.Min.x + offsetX, bb.Min.y + 10 * count),
|
||||
ImGui::GetColorU32(ImGuiCol_Text), buf.c_str());
|
||||
++count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return pressed;
|
||||
return ImGui::IsItemClicked(0);
|
||||
}
|
||||
|
||||
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,
|
||||
const char** customNames, size_t length)
|
||||
{
|
||||
ImGuiStyle& style = ImGui::GetStyle();
|
||||
/*
|
||||
Trying to scale images based on resolutions
|
||||
Native 1366x768
|
||||
@ -563,7 +544,8 @@ void Ui::DrawImages(ResourceStore &store, std::function<void(std::string&)> onLe
|
||||
|
||||
int imageCount = 1;
|
||||
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();
|
||||
|
||||
@ -573,7 +555,7 @@ void Ui::DrawImages(ResourceStore &store, std::function<void(std::string&)> onLe
|
||||
imgPopup.function = nullptr;
|
||||
}
|
||||
|
||||
ImGui::PushItemWidth((ImGui::GetWindowContentRegionWidth() - ImGui::GetStyle().ItemSpacing.x)/2);
|
||||
ImGui::PushItemWidth((ImGui::GetWindowContentRegionWidth() - style.ItemSpacing.x)/2);
|
||||
if (customNames)
|
||||
{
|
||||
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
|
||||
{
|
||||
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);
|
||||
}
|
||||
@ -637,7 +619,7 @@ void Ui::DrawImages(ResourceStore &store, std::function<void(std::string&)> onLe
|
||||
{
|
||||
if (imageCount % imagesInRow != 0)
|
||||
{
|
||||
ImGui::SameLine(0.0, ImGui::GetStyle().ItemInnerSpacing.x);
|
||||
ImGui::SameLine(0.0, style.ItemInnerSpacing.x);
|
||||
}
|
||||
}
|
||||
imageCount++;
|
||||
|
2
src/ui.h
2
src/ui.h
@ -81,7 +81,7 @@ public:
|
||||
|
||||
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 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 ShowTooltip(const char* text);
|
||||
};
|
||||
|
@ -2,5 +2,5 @@
|
||||
#define MENU_NAME "Cheat Menu"
|
||||
#define MENU_VERSION_NUMBER "3.3"
|
||||
#define MENU_VERSION MENU_VERSION_NUMBER"-beta"
|
||||
#define BUILD_NUMBER "20220328"
|
||||
#define BUILD_NUMBER "20220417"
|
||||
#define MENU_TITLE MENU_NAME " v" MENU_VERSION
|
||||
|
Loading…
Reference in New Issue
Block a user