Improve hotkeys
This commit is contained in:
parent
0340d13e0d
commit
e4ee4c507d
@ -50,7 +50,6 @@ bool Game::solid_water = false;
|
||||
bool Game::ss_shortcut = false;
|
||||
bool Game::sync_time = false;
|
||||
|
||||
uint Game::ss_shotcut_timer = 0;
|
||||
uint Game::sync_time_timer = 0;
|
||||
|
||||
uint Game::solid_water_object = 0;
|
||||
@ -107,11 +106,10 @@ Game::Game()
|
||||
|
||||
if (ss_shortcut)
|
||||
{
|
||||
if (Ui::HotKeyPressed(Menu::hotkeys::quick_ss) && timer - ss_shotcut_timer > 1000)
|
||||
if (Ui::HotKeyPressed(Menu::hotkeys::quick_ss))
|
||||
{
|
||||
Command<Commands::TAKE_PHOTO>();
|
||||
CHud::SetHelpMessage("Screenshot taken", false, false, false);
|
||||
ss_shotcut_timer = timer;
|
||||
}
|
||||
}
|
||||
|
||||
@ -262,7 +260,7 @@ void Game::FreeCam()
|
||||
if (freecam::tmouseY < -150)
|
||||
freecam::tmouseY = -150;
|
||||
|
||||
if (KeyPressed(VK_RETURN))
|
||||
if (Ui::HotKeyPressed(Menu::hotkeys::free_cam_tp_player))
|
||||
{
|
||||
CPlayerPed *player = FindPlayerPed(-1);
|
||||
CVector pos = freecam::ped->GetPosition();
|
||||
|
@ -48,8 +48,6 @@ public:
|
||||
static bool solid_water;
|
||||
static bool ss_shortcut;
|
||||
static bool sync_time;
|
||||
|
||||
static uint ss_shotcut_timer;
|
||||
static uint sync_time_timer;
|
||||
static uint solid_water_object;
|
||||
|
||||
|
@ -23,6 +23,7 @@ HotKeyData Menu::hotkeys::freecam{};
|
||||
HotKeyData Menu::hotkeys::command_window{};
|
||||
HotKeyData Menu::hotkeys::flip_veh{};
|
||||
HotKeyData Menu::hotkeys::fix_veh{};
|
||||
HotKeyData Menu::hotkeys::free_cam_tp_player{VK_RETURN,VK_RETURN};
|
||||
HotKeyData Menu::hotkeys::god_mode{};
|
||||
HotKeyData Menu::hotkeys::menu_open{};
|
||||
HotKeyData Menu::hotkeys::quick_ss{};
|
||||
@ -341,7 +342,9 @@ void Menu::Main()
|
||||
if (ImGui::BeginTabItem("Hotkeys"))
|
||||
{
|
||||
ImGui::Spacing();
|
||||
ImGui::TextWrapped("Right clicking will set hotkey to none. Some are set to none by default. Choose keys for them if you want to use them.");
|
||||
ImGui::Text("Usage");
|
||||
Ui::ShowTooltip("Left-click selects hotkey.\nLeft clicking outside deselects."
|
||||
"\nRight click disables hotkey.");
|
||||
ImGui::Spacing();
|
||||
ImGui::BeginChild("Hotkeys");
|
||||
if (Ui::HotKey("Open/ close cheat menu", hotkeys::menu_open))
|
||||
|
@ -24,6 +24,7 @@ public:
|
||||
static HotKeyData command_window;
|
||||
static HotKeyData fix_veh;
|
||||
static HotKeyData flip_veh;
|
||||
static HotKeyData free_cam_tp_player;
|
||||
static HotKeyData god_mode;
|
||||
static HotKeyData menu_open;
|
||||
static HotKeyData quick_ss;
|
||||
|
23
src/Ui.cpp
23
src/Ui.cpp
@ -790,6 +790,7 @@ bool Ui::HotKey(const char* label, HotKeyData& key_data)
|
||||
if (active)
|
||||
{
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetStyle().Colors[ImGuiCol_ButtonActive]);
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImGui::GetStyle().Colors[ImGuiCol_ButtonActive]);
|
||||
|
||||
for (int key = 3; key != 135; ++key)
|
||||
{
|
||||
@ -820,19 +821,18 @@ bool Ui::HotKey(const char* label, HotKeyData& key_data)
|
||||
|
||||
if (key_data.key1 != key_data.key2)
|
||||
text += (" + " + key_names[key_data.key2-1]);
|
||||
|
||||
if (ImGui::Button((text + std::string("##") + std::string(label)).c_str(), ImVec2(ImGui::GetWindowContentRegionWidth() / 3.5, ImGui::GetFrameHeight())))
|
||||
if (!active)
|
||||
current_hotkey = label;
|
||||
|
||||
if (ImGui::Button((text + std::string("##") + std::string(label)).c_str(), ImVec2(ImGui::GetWindowContentRegionWidth() / 3, ImGui::GetFrameHeight())))
|
||||
if (active && (ImGui::IsMouseClicked(ImGuiMouseButton_Left) || ImGui::IsItemClicked(ImGuiMouseButton_Left)))
|
||||
{
|
||||
if (active)
|
||||
{
|
||||
current_hotkey = "";
|
||||
state = true;
|
||||
}
|
||||
else
|
||||
current_hotkey = label;;
|
||||
current_hotkey = "";
|
||||
state = true;
|
||||
}
|
||||
|
||||
if (ImGui::IsItemHovered() && ImGui::IsMouseClicked(1)) // right click
|
||||
if (ImGui::IsItemHovered() && ImGui::IsMouseClicked(ImGuiMouseButton_Right))
|
||||
{
|
||||
key_data.key1 = VK_NONE;
|
||||
key_data.key2 = VK_NONE;
|
||||
@ -843,10 +843,7 @@ bool Ui::HotKey(const char* label, HotKeyData& key_data)
|
||||
ImGui::Text(label);
|
||||
|
||||
if (active)
|
||||
ImGui::PopStyleColor();
|
||||
|
||||
if (!(ImGui::IsWindowFocused() || ImGui::IsItemVisible()))
|
||||
current_hotkey = "";
|
||||
ImGui::PopStyleColor(2);
|
||||
|
||||
return state;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user