Bug fixes, better scaling for high res

This commit is contained in:
Grinch_ 2021-02-19 13:41:50 +06:00
parent a9008ac7f9
commit 4b09077728
6 changed files with 43 additions and 29 deletions

View File

@ -8,9 +8,7 @@
"${PLUGIN_SDK_DIR}/plugin_sa",
"${PLUGIN_SDK_DIR}/plugin_sa/game_sa",
"${PLUGIN_SDK_DIR}/shared",
"${PLUGIN_SDK_DIR}/shared/game",
"E:/plugin-sdk-master/plugin_sa/game_sa",
"E:/plugin-sdk-master/shared"
"${PLUGIN_SDK_DIR}/shared/game"
],
"defines": [
"GTASA",
@ -20,12 +18,6 @@
"_CRT_SECURE_NO_WARNINGS",
"_CRT_NON_CONFORMING_SWPRINTFS;",
"GTASA;",
"GTAGAME_NAME=\"San Andreas\"",
"GTAGAME_ABBR=\"SA\"",
"GTAGAME_ABBRLOW=\"sa\"",
"GTAGAME_PROTAGONISTNAME=\"CJ\"",
"GTAGAME_CITYNAME=\"San Andreas\"",
"_LA_SUPPORT",
"_DX9_SDK_INSTALLED",
"PLUGIN_SGV_10US",
"_MBCS",

View File

@ -46,7 +46,7 @@ void CheatMenu::ProcessWindow()
CheatMenu::CheatMenu()
{
ApplyImGuiStyle();
Hook::window_func = std::bind(&ProcessWindow);
Hook::window_callback = std::bind(&ProcessWindow);
Events::initRwEvent += []()
{
@ -113,16 +113,12 @@ void CheatMenu::ApplyImGuiStyle()
style->GrabRounding = 1;
style->WindowRounding = 1;
style->ChildRounding = 1;
style->ScrollbarSize = 12;
style->ScrollbarRounding = 1;
style->GrabRounding = 1;
style->FrameRounding = 0;
style->TabRounding = 1.0;
style->IndentSpacing = 20;
style->AntiAliasedLines = true;
style->AntiAliasedFill = true;
style->ItemSpacing = ImVec2(8, 4);
style->FramePadding = ImVec2(5, 3);
style->Alpha = 1;
style->FrameBorderSize = 0;

View File

@ -10,7 +10,7 @@ f_Reset Hook::oReset9 = NULL;
bool Hook::mouse_visibility = false;
bool Hook::show_mouse = false;
std::function<void()> Hook::window_func = NULL;
std::function<void()> Hook::window_callback = NULL;
LRESULT Hook::WndProc(const HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
@ -51,11 +51,11 @@ void Hook::Present(void *ptr)
{
Hook::ShowMouse(show_mouse);
// Change font size if the game resolution changes
if (Globals::screen_size.x != screen::GetScreenWidth()
&& Globals::screen_size.y != screen::GetScreenHeight())
// handle window scaling here
ImVec2 size(screen::GetScreenWidth(),screen::GetScreenHeight());
if (Globals::screen_size.x != size.x && Globals::screen_size.y != size.y)
{
int font_size = int(screen::GetScreenHeight() / 54.85); // manually tested
int font_size = int(size.y / 54.85f); // manually tested
io.FontDefault = io.Fonts->AddFontFromFileTTF("C:/Windows/Fonts/trebucbd.ttf", font_size);
io.Fonts->Build();
@ -65,7 +65,23 @@ void Hook::Present(void *ptr)
else
ImGui_ImplDX11_InvalidateDeviceObjects();
Globals::screen_size = ImVec2(screen::GetScreenWidth(), screen::GetScreenHeight());
if (Globals::screen_size.x != -1 && Globals::screen_size.y != -1)
{
Globals::menu_size.x += (size.x-Globals::screen_size.x) / 4.0f;
Globals::menu_size.y += (size.y-Globals::screen_size.y) / 1.2f;
}
ImGuiStyle* style = &ImGui::GetStyle();
float scale_x = size.x / 1366.0f;
float scale_y = size.y / 768.0f;
style->FramePadding = ImVec2(5 * scale_x, 3 * scale_y);
style->ItemSpacing = ImVec2(8 * scale_x, 4 * scale_y);
style->ScrollbarSize = 12 * scale_x;
style->IndentSpacing = 20 * scale_x;
style->ItemInnerSpacing = ImVec2(4 * scale_x,4 * scale_y);
Globals::screen_size = size;
}
ImGui_ImplWin32_NewFrame();
@ -76,8 +92,8 @@ void Hook::Present(void *ptr)
ImGui::NewFrame();
if (window_func != NULL)
window_func();
if (window_callback != NULL)
window_callback();
ImGui::EndFrame();
ImGui::Render();

View File

@ -25,7 +25,7 @@ private:
protected:
static bool show_mouse;
static std::function<void()> window_func;
static std::function<void()> window_callback;
Hook();
~Hook();

View File

@ -465,6 +465,10 @@ void Ui::DrawImages(std::vector<std::unique_ptr<TextureStructure>> &img_vec, ImV
std::function<std::string(std::string&)> get_name_func, std::function<bool(std::string&)> verify_func)
{
// scale image size
image_size.x *= screen::GetScreenWidth() / 1366.0f;
image_size.y *= screen::GetScreenHeight() / 768.0f;
int images_in_row = static_cast<int>(ImGui::GetWindowContentRegionWidth() / image_size.x);
image_size.x = ImGui::GetWindowContentRegionWidth() / images_in_row - int(ImGuiStyleVar_ItemSpacing)*0.65f;
@ -536,7 +540,7 @@ void Ui::DrawImages(std::vector<std::unique_ptr<TextureStructure>> &img_vec, ImV
}
if (images_count % images_in_row != 0)
ImGui::SameLine(0.0, 4.0);
ImGui::SameLine(0.0, ImGui::GetStyle().ItemInnerSpacing.x);
images_count++;
}
@ -826,16 +830,22 @@ bool Ui::HotKey(const char* label, HotKeyData& key_data)
if (!active)
current_hotkey = label;
if (active && (ImGui::IsMouseClicked(ImGuiMouseButton_Left) || ImGui::IsItemClicked(ImGuiMouseButton_Right)))
if (active && ImGui::IsMouseClicked(ImGuiMouseButton_Left))
{
current_hotkey = "";
state = true;
}
if (ImGui::IsItemHovered() && ImGui::IsMouseClicked(ImGuiMouseButton_Right))
if (ImGui::IsMouseClicked(ImGuiMouseButton_Right))
{
if (ImGui::IsItemHovered())
{
key_data.key1 = VK_NONE;
key_data.key2 = VK_NONE;
}
else
current_hotkey = "";
state = true;
}

View File

@ -992,7 +992,7 @@ void Vehicle::Main()
ImGui::EndTabItem();
}
if (player && player->m_pVehicle)
if (player->m_pVehicle && player->m_nPedFlags.bInVehicle)
{
CVehicle *veh = FindPlayerPed()->m_pVehicle;
int hveh = CPools::GetVehicleRef(veh);