Refactor code

This commit is contained in:
Grinch_ 2022-08-18 07:12:21 +06:00
parent 9c5d399e18
commit 5e4b7a9420
46 changed files with 503 additions and 385 deletions

View File

@ -76,6 +76,7 @@
"xutility": "cpp", "xutility": "cpp",
"*.rh": "cpp", "*.rh": "cpp",
"csignal": "cpp", "csignal": "cpp",
"coroutine": "cpp" "coroutine": "cpp",
"any": "cpp"
} }
} }

View File

@ -3036,7 +3036,7 @@ ImGuiWindow::ImGuiWindow(ImGuiContext* context, const char* name) : DrawListInst
NameBufLen = (int)strlen(name) + 1; NameBufLen = (int)strlen(name) + 1;
ID = ImHashStr(name); ID = ImHashStr(name);
IDStack.push_back(ID); IDStack.push_back(ID);
MoveId = GetID("#MOVE"); MoveId = GetPageID("#MOVE");
ScrollTarget = ImVec2(FLT_MAX, FLT_MAX); ScrollTarget = ImVec2(FLT_MAX, FLT_MAX);
ScrollTargetCenterRatio = ImVec2(0.5f, 0.5f); ScrollTargetCenterRatio = ImVec2(0.5f, 0.5f);
AutoFitFramesX = AutoFitFramesY = -1; AutoFitFramesX = AutoFitFramesY = -1;
@ -3059,7 +3059,7 @@ ImGuiWindow::~ImGuiWindow()
ColumnsStorage.clear_destruct(); ColumnsStorage.clear_destruct();
} }
ImGuiID ImGuiWindow::GetID(const char* str, const char* str_end) ImGuiID ImGuiWindow::GetPageID(const char* str, const char* str_end)
{ {
ImGuiID seed = IDStack.back(); ImGuiID seed = IDStack.back();
ImGuiID id = ImHashStr(str, str_end ? (str_end - str) : 0, seed); ImGuiID id = ImHashStr(str, str_end ? (str_end - str) : 0, seed);
@ -3070,7 +3070,7 @@ ImGuiID ImGuiWindow::GetID(const char* str, const char* str_end)
return id; return id;
} }
ImGuiID ImGuiWindow::GetID(const void* ptr) ImGuiID ImGuiWindow::GetPageID(const void* ptr)
{ {
ImGuiID seed = IDStack.back(); ImGuiID seed = IDStack.back();
ImGuiID id = ImHashData(&ptr, sizeof(void*), seed); ImGuiID id = ImHashData(&ptr, sizeof(void*), seed);
@ -3081,7 +3081,7 @@ ImGuiID ImGuiWindow::GetID(const void* ptr)
return id; return id;
} }
ImGuiID ImGuiWindow::GetID(int n) ImGuiID ImGuiWindow::GetPageID(int n)
{ {
ImGuiID seed = IDStack.back(); ImGuiID seed = IDStack.back();
ImGuiID id = ImHashData(&n, sizeof(n), seed); ImGuiID id = ImHashData(&n, sizeof(n), seed);
@ -5187,7 +5187,7 @@ bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, b
bool ImGui::BeginChild(const char* str_id, const ImVec2& size_arg, bool border, ImGuiWindowFlags extra_flags) bool ImGui::BeginChild(const char* str_id, const ImVec2& size_arg, bool border, ImGuiWindowFlags extra_flags)
{ {
ImGuiWindow* window = GetCurrentWindow(); ImGuiWindow* window = GetCurrentWindow();
return BeginChildEx(str_id, window->GetID(str_id), size_arg, border, extra_flags); return BeginChildEx(str_id, window->GetPageID(str_id), size_arg, border, extra_flags);
} }
bool ImGui::BeginChild(ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags extra_flags) bool ImGui::BeginChild(ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags extra_flags)
@ -5586,7 +5586,7 @@ static bool ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& s
ImRect resize_rect(corner - def.InnerDir * grip_hover_outer_size, corner + def.InnerDir * grip_hover_inner_size); ImRect resize_rect(corner - def.InnerDir * grip_hover_outer_size, corner + def.InnerDir * grip_hover_inner_size);
if (resize_rect.Min.x > resize_rect.Max.x) ImSwap(resize_rect.Min.x, resize_rect.Max.x); if (resize_rect.Min.x > resize_rect.Max.x) ImSwap(resize_rect.Min.x, resize_rect.Max.x);
if (resize_rect.Min.y > resize_rect.Max.y) ImSwap(resize_rect.Min.y, resize_rect.Max.y); if (resize_rect.Min.y > resize_rect.Max.y) ImSwap(resize_rect.Min.y, resize_rect.Max.y);
ImGuiID resize_grip_id = window->GetID(resize_grip_n); // == GetWindowResizeCornerID() ImGuiID resize_grip_id = window->GetPageID(resize_grip_n); // == GetWindowResizeCornerID()
ButtonBehavior(resize_rect, resize_grip_id, &hovered, &held, ImGuiButtonFlags_FlattenChildren | ImGuiButtonFlags_NoNavFocus); ButtonBehavior(resize_rect, resize_grip_id, &hovered, &held, ImGuiButtonFlags_FlattenChildren | ImGuiButtonFlags_NoNavFocus);
//GetForegroundDrawList(window)->AddRect(resize_rect.Min, resize_rect.Max, IM_COL32(255, 255, 0, 255)); //GetForegroundDrawList(window)->AddRect(resize_rect.Min, resize_rect.Max, IM_COL32(255, 255, 0, 255));
if (hovered || held) if (hovered || held)
@ -5621,7 +5621,7 @@ static bool ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& s
bool hovered, held; bool hovered, held;
ImRect border_rect = GetResizeBorderRect(window, border_n, grip_hover_inner_size, WINDOWS_HOVER_PADDING); ImRect border_rect = GetResizeBorderRect(window, border_n, grip_hover_inner_size, WINDOWS_HOVER_PADDING);
ImGuiID border_id = window->GetID(border_n + 4); // == GetWindowResizeBorderID() ImGuiID border_id = window->GetPageID(border_n + 4); // == GetWindowResizeBorderID()
ButtonBehavior(border_rect, border_id, &hovered, &held, ImGuiButtonFlags_FlattenChildren | ImGuiButtonFlags_NoNavFocus); ButtonBehavior(border_rect, border_id, &hovered, &held, ImGuiButtonFlags_FlattenChildren | ImGuiButtonFlags_NoNavFocus);
//GetForegroundDrawLists(window)->AddRect(border_rect.Min, border_rect.Max, IM_COL32(255, 255, 0, 255)); //GetForegroundDrawLists(window)->AddRect(border_rect.Min, border_rect.Max, IM_COL32(255, 255, 0, 255));
if ((hovered && g.HoveredIdTimer > WINDOWS_RESIZE_FROM_EDGES_FEEDBACK_TIMER) || held) if ((hovered && g.HoveredIdTimer > WINDOWS_RESIZE_FROM_EDGES_FEEDBACK_TIMER) || held)
@ -5841,12 +5841,12 @@ void ImGui::RenderWindowTitleBarContents(ImGuiWindow* window, const ImRect& titl
// Collapse button (submitting first so it gets priority when choosing a navigation init fallback) // Collapse button (submitting first so it gets priority when choosing a navigation init fallback)
if (has_collapse_button) if (has_collapse_button)
if (CollapseButton(window->GetID("#COLLAPSE"), collapse_button_pos)) if (CollapseButton(window->GetPageID("#COLLAPSE"), collapse_button_pos))
window->WantCollapseToggle = true; // Defer actual collapsing to next frame as we are too far in the Begin() function window->WantCollapseToggle = true; // Defer actual collapsing to next frame as we are too far in the Begin() function
// Close button // Close button
if (has_close_button) if (has_close_button)
if (CloseButton(window->GetID("#CLOSE"), close_button_pos)) if (CloseButton(window->GetPageID("#CLOSE"), close_button_pos))
*p_open = false; *p_open = false;
window->DC.NavLayerCurrent = ImGuiNavLayer_Main; window->DC.NavLayerCurrent = ImGuiNavLayer_Main;
@ -6536,7 +6536,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
} }
// Pull/inherit current state // Pull/inherit current state
window->DC.NavFocusScopeIdCurrent = (flags & ImGuiWindowFlags_ChildWindow) ? parent_window->DC.NavFocusScopeIdCurrent : window->GetID("#FOCUSSCOPE"); // Inherit from parent only // -V595 window->DC.NavFocusScopeIdCurrent = (flags & ImGuiWindowFlags_ChildWindow) ? parent_window->DC.NavFocusScopeIdCurrent : window->GetPageID("#FOCUSSCOPE"); // Inherit from parent only // -V595
PushClipRect(window->InnerClipRect.Min, window->InnerClipRect.Max, true); PushClipRect(window->InnerClipRect.Min, window->InnerClipRect.Max, true);
@ -7425,22 +7425,22 @@ void ImGui::PopID()
window->IDStack.pop_back(); window->IDStack.pop_back();
} }
ImGuiID ImGui::GetID(const char* str_id) ImGuiID ImGui::GetPageID(const char* str_id)
{ {
ImGuiWindow* window = GImGui->CurrentWindow; ImGuiWindow* window = GImGui->CurrentWindow;
return window->GetID(str_id); return window->GetPageID(str_id);
} }
ImGuiID ImGui::GetID(const char* str_id_begin, const char* str_id_end) ImGuiID ImGui::GetPageID(const char* str_id_begin, const char* str_id_end)
{ {
ImGuiWindow* window = GImGui->CurrentWindow; ImGuiWindow* window = GImGui->CurrentWindow;
return window->GetID(str_id_begin, str_id_end); return window->GetPageID(str_id_begin, str_id_end);
} }
ImGuiID ImGui::GetID(const void* ptr_id) ImGuiID ImGui::GetPageID(const void* ptr_id)
{ {
ImGuiWindow* window = GImGui->CurrentWindow; ImGuiWindow* window = GImGui->CurrentWindow;
return window->GetID(ptr_id); return window->GetPageID(ptr_id);
} }
bool ImGui::IsRectVisible(const ImVec2& size) bool ImGui::IsRectVisible(const ImVec2& size)
@ -8520,7 +8520,7 @@ bool ImGui::IsPopupOpen(ImGuiID id, ImGuiPopupFlags popup_flags)
bool ImGui::IsPopupOpen(const char* str_id, ImGuiPopupFlags popup_flags) bool ImGui::IsPopupOpen(const char* str_id, ImGuiPopupFlags popup_flags)
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
ImGuiID id = (popup_flags & ImGuiPopupFlags_AnyPopupId) ? 0 : g.CurrentWindow->GetID(str_id); ImGuiID id = (popup_flags & ImGuiPopupFlags_AnyPopupId) ? 0 : g.CurrentWindow->GetPageID(str_id);
if ((popup_flags & ImGuiPopupFlags_AnyPopupLevel) && id != 0) if ((popup_flags & ImGuiPopupFlags_AnyPopupLevel) && id != 0)
IM_ASSERT(0 && "Cannot use IsPopupOpen() with a string id and ImGuiPopupFlags_AnyPopupLevel."); // But non-string version is legal and used internally IM_ASSERT(0 && "Cannot use IsPopupOpen() with a string id and ImGuiPopupFlags_AnyPopupLevel."); // But non-string version is legal and used internally
return IsPopupOpen(id, popup_flags); return IsPopupOpen(id, popup_flags);
@ -8549,7 +8549,7 @@ ImGuiWindow* ImGui::GetTopMostAndVisiblePopupModal()
void ImGui::OpenPopup(const char* str_id, ImGuiPopupFlags popup_flags) void ImGui::OpenPopup(const char* str_id, ImGuiPopupFlags popup_flags)
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
OpenPopupEx(g.CurrentWindow->GetID(str_id), popup_flags); OpenPopupEx(g.CurrentWindow->GetPageID(str_id), popup_flags);
} }
void ImGui::OpenPopup(ImGuiID id, ImGuiPopupFlags popup_flags) void ImGui::OpenPopup(ImGuiID id, ImGuiPopupFlags popup_flags)
@ -8760,7 +8760,7 @@ bool ImGui::BeginPopup(const char* str_id, ImGuiWindowFlags flags)
return false; return false;
} }
flags |= ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings; flags |= ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings;
return BeginPopupEx(g.CurrentWindow->GetID(str_id), flags); return BeginPopupEx(g.CurrentWindow->GetPageID(str_id), flags);
} }
// If 'p_open' is specified for a modal popup window, the popup will have a regular close button which will close the popup. // If 'p_open' is specified for a modal popup window, the popup will have a regular close button which will close the popup.
@ -8769,7 +8769,7 @@ bool ImGui::BeginPopupModal(const char* name, bool* p_open, ImGuiWindowFlags fla
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow; ImGuiWindow* window = g.CurrentWindow;
const ImGuiID id = window->GetID(name); const ImGuiID id = window->GetPageID(name);
if (!IsPopupOpen(id, ImGuiPopupFlags_None)) if (!IsPopupOpen(id, ImGuiPopupFlags_None))
{ {
g.NextWindowData.ClearFlags(); // We behave like Begin() and need to consume those values g.NextWindowData.ClearFlags(); // We behave like Begin() and need to consume those values
@ -8825,7 +8825,7 @@ void ImGui::OpenPopupOnItemClick(const char* str_id, ImGuiPopupFlags popup_flags
int mouse_button = (popup_flags & ImGuiPopupFlags_MouseButtonMask_); int mouse_button = (popup_flags & ImGuiPopupFlags_MouseButtonMask_);
if (IsMouseReleased(mouse_button) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup)) if (IsMouseReleased(mouse_button) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup))
{ {
ImGuiID id = str_id ? window->GetID(str_id) : g.LastItemData.ID; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict! ImGuiID id = str_id ? window->GetPageID(str_id) : g.LastItemData.ID; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict!
IM_ASSERT(id != 0); // You cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item) IM_ASSERT(id != 0); // You cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item)
OpenPopupEx(id, popup_flags); OpenPopupEx(id, popup_flags);
} }
@ -8853,7 +8853,7 @@ bool ImGui::BeginPopupContextItem(const char* str_id, ImGuiPopupFlags popup_flag
ImGuiWindow* window = g.CurrentWindow; ImGuiWindow* window = g.CurrentWindow;
if (window->SkipItems) if (window->SkipItems)
return false; return false;
ImGuiID id = str_id ? window->GetID(str_id) : g.LastItemData.ID; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict! ImGuiID id = str_id ? window->GetPageID(str_id) : g.LastItemData.ID; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict!
IM_ASSERT(id != 0); // You cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item) IM_ASSERT(id != 0); // You cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item)
int mouse_button = (popup_flags & ImGuiPopupFlags_MouseButtonMask_); int mouse_button = (popup_flags & ImGuiPopupFlags_MouseButtonMask_);
if (IsMouseReleased(mouse_button) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup)) if (IsMouseReleased(mouse_button) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup))
@ -8867,7 +8867,7 @@ bool ImGui::BeginPopupContextWindow(const char* str_id, ImGuiPopupFlags popup_fl
ImGuiWindow* window = g.CurrentWindow; ImGuiWindow* window = g.CurrentWindow;
if (!str_id) if (!str_id)
str_id = "window_context"; str_id = "window_context";
ImGuiID id = window->GetID(str_id); ImGuiID id = window->GetPageID(str_id);
int mouse_button = (popup_flags & ImGuiPopupFlags_MouseButtonMask_); int mouse_button = (popup_flags & ImGuiPopupFlags_MouseButtonMask_);
if (IsMouseReleased(mouse_button) && IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup)) if (IsMouseReleased(mouse_button) && IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup))
if (!(popup_flags & ImGuiPopupFlags_NoOpenOverItems) || !IsAnyItemHovered()) if (!(popup_flags & ImGuiPopupFlags_NoOpenOverItems) || !IsAnyItemHovered())
@ -8881,7 +8881,7 @@ bool ImGui::BeginPopupContextVoid(const char* str_id, ImGuiPopupFlags popup_flag
ImGuiWindow* window = g.CurrentWindow; ImGuiWindow* window = g.CurrentWindow;
if (!str_id) if (!str_id)
str_id = "void_context"; str_id = "void_context";
ImGuiID id = window->GetID(str_id); ImGuiID id = window->GetPageID(str_id);
int mouse_button = (popup_flags & ImGuiPopupFlags_MouseButtonMask_); int mouse_button = (popup_flags & ImGuiPopupFlags_MouseButtonMask_);
if (IsMouseReleased(mouse_button) && !IsWindowHovered(ImGuiHoveredFlags_AnyWindow)) if (IsMouseReleased(mouse_button) && !IsWindowHovered(ImGuiHoveredFlags_AnyWindow))
if (GetTopMostPopupModal() == NULL) if (GetTopMostPopupModal() == NULL)

View File

@ -477,9 +477,9 @@ namespace ImGui
IMGUI_API void PushID(const void* ptr_id); // push pointer into the ID stack (will hash pointer). IMGUI_API void PushID(const void* ptr_id); // push pointer into the ID stack (will hash pointer).
IMGUI_API void PushID(int int_id); // push integer into the ID stack (will hash integer). IMGUI_API void PushID(int int_id); // push integer into the ID stack (will hash integer).
IMGUI_API void PopID(); // pop from the ID stack. IMGUI_API void PopID(); // pop from the ID stack.
IMGUI_API ImGuiID GetID(const char* str_id); // calculate unique ID (hash of whole ID stack + given parameter). e.g. if you want to query into ImGuiStorage yourself IMGUI_API ImGuiID GetPageID(const char* str_id); // calculate unique ID (hash of whole ID stack + given parameter). e.g. if you want to query into ImGuiStorage yourself
IMGUI_API ImGuiID GetID(const char* str_id_begin, const char* str_id_end); IMGUI_API ImGuiID GetPageID(const char* str_id_begin, const char* str_id_end);
IMGUI_API ImGuiID GetID(const void* ptr_id); IMGUI_API ImGuiID GetPageID(const void* ptr_id);
// Widgets: Text // Widgets: Text
IMGUI_API void TextUnformatted(const char* text, const char* text_end = NULL); // raw text without formatting. Roughly equivalent to Text("%s", text) but: A) doesn't require null terminated string if 'text_end' is specified, B) it's faster, no memory copy is done, no buffer size limits, recommended for long chunks of text. IMGUI_API void TextUnformatted(const char* text, const char* text_end = NULL); // raw text without formatting. Roughly equivalent to Text("%s", text) but: A) doesn't require null terminated string if 'text_end' is specified, B) it's faster, no memory copy is done, no buffer size limits, recommended for long chunks of text.

View File

@ -2942,7 +2942,7 @@ static void ShowDemoWindowLayout()
ImGui::TextUnformatted(names[i]); ImGui::TextUnformatted(names[i]);
const ImGuiWindowFlags child_flags = enable_extra_decorations ? ImGuiWindowFlags_MenuBar : 0; const ImGuiWindowFlags child_flags = enable_extra_decorations ? ImGuiWindowFlags_MenuBar : 0;
const ImGuiID child_id = ImGui::GetID((void*)(intptr_t)i); const ImGuiID child_id = ImGui::GetPageID((void*)(intptr_t)i);
const bool child_is_visible = ImGui::BeginChild(child_id, ImVec2(child_w, 200.0f), true, child_flags); const bool child_is_visible = ImGui::BeginChild(child_id, ImVec2(child_w, 200.0f), true, child_flags);
if (ImGui::BeginMenuBar()) if (ImGui::BeginMenuBar())
{ {
@ -2989,7 +2989,7 @@ static void ShowDemoWindowLayout()
{ {
float child_height = ImGui::GetTextLineHeight() + style.ScrollbarSize + style.WindowPadding.y * 2.0f; float child_height = ImGui::GetTextLineHeight() + style.ScrollbarSize + style.WindowPadding.y * 2.0f;
ImGuiWindowFlags child_flags = ImGuiWindowFlags_HorizontalScrollbar | (enable_extra_decorations ? ImGuiWindowFlags_AlwaysVerticalScrollbar : 0); ImGuiWindowFlags child_flags = ImGuiWindowFlags_HorizontalScrollbar | (enable_extra_decorations ? ImGuiWindowFlags_AlwaysVerticalScrollbar : 0);
ImGuiID child_id = ImGui::GetID((void*)(intptr_t)i); ImGuiID child_id = ImGui::GetPageID((void*)(intptr_t)i);
bool child_is_visible = ImGui::BeginChild(child_id, ImVec2(-100, child_height), true, child_flags); bool child_is_visible = ImGui::BeginChild(child_id, ImVec2(-100, child_height), true, child_flags);
if (scroll_to_off) if (scroll_to_off)
ImGui::SetScrollX(scroll_to_off_px); ImGui::SetScrollX(scroll_to_off_px);
@ -5854,7 +5854,7 @@ void ImGui::ShowAboutWindow(bool* p_open)
bool copy_to_clipboard = ImGui::Button("Copy to clipboard"); bool copy_to_clipboard = ImGui::Button("Copy to clipboard");
ImVec2 child_size = ImVec2(0, ImGui::GetTextLineHeightWithSpacing() * 18); ImVec2 child_size = ImVec2(0, ImGui::GetTextLineHeightWithSpacing() * 18);
ImGui::BeginChildFrame(ImGui::GetID("cfg_infos"), child_size, ImGuiWindowFlags_NoMove); ImGui::BeginChildFrame(ImGui::GetPageID("cfg_infos"), child_size, ImGuiWindowFlags_NoMove);
if (copy_to_clipboard) if (copy_to_clipboard)
{ {
ImGui::LogToClipboard(); ImGui::LogToClipboard();
@ -7805,7 +7805,7 @@ void ShowExampleAppDocuments(bool* p_open)
{ {
ImGui::Text("Save change to the following items?"); ImGui::Text("Save change to the following items?");
float item_height = ImGui::GetTextLineHeightWithSpacing(); float item_height = ImGui::GetTextLineHeightWithSpacing();
if (ImGui::BeginChildFrame(ImGui::GetID("frame"), ImVec2(-FLT_MIN, 6.25f * item_height))) if (ImGui::BeginChildFrame(ImGui::GetPageID("frame"), ImVec2(-FLT_MIN, 6.25f * item_height)))
{ {
for (int n = 0; n < close_queue.Size; n++) for (int n = 0; n < close_queue.Size; n++)
if (close_queue[n]->Dirty) if (close_queue[n]->Dirty)

View File

@ -2050,9 +2050,9 @@ public:
ImGuiWindow(ImGuiContext* context, const char* name); ImGuiWindow(ImGuiContext* context, const char* name);
~ImGuiWindow(); ~ImGuiWindow();
ImGuiID GetID(const char* str, const char* str_end = NULL); ImGuiID GetPageID(const char* str, const char* str_end = NULL);
ImGuiID GetID(const void* ptr); ImGuiID GetPageID(const void* ptr);
ImGuiID GetID(int n); ImGuiID GetPageID(int n);
ImGuiID GetIDNoKeepAlive(const char* str, const char* str_end = NULL); ImGuiID GetIDNoKeepAlive(const char* str, const char* str_end = NULL);
ImGuiID GetIDNoKeepAlive(const void* ptr); ImGuiID GetIDNoKeepAlive(const void* ptr);
ImGuiID GetIDNoKeepAlive(int n); ImGuiID GetIDNoKeepAlive(int n);

View File

@ -303,7 +303,7 @@ ImGuiTable* ImGui::TableFindByID(ImGuiID id)
// Read about "TABLE SIZING" at the top of this file. // Read about "TABLE SIZING" at the top of this file.
bool ImGui::BeginTable(const char* str_id, int columns_count, ImGuiTableFlags flags, const ImVec2& outer_size, float inner_width) bool ImGui::BeginTable(const char* str_id, int columns_count, ImGuiTableFlags flags, const ImVec2& outer_size, float inner_width)
{ {
ImGuiID id = GetID(str_id); ImGuiID id = GetPageID(str_id);
return BeginTableEx(str_id, id, columns_count, flags, outer_size, inner_width); return BeginTableEx(str_id, id, columns_count, flags, outer_size, inner_width);
} }
@ -2898,7 +2898,7 @@ void ImGui::TableHeader(const char* label)
// Keep header highlighted when context menu is open. // Keep header highlighted when context menu is open.
const bool selected = (table->IsContextPopupOpen && table->ContextPopupColumn == column_n && table->InstanceInteracted == table->InstanceCurrent); const bool selected = (table->IsContextPopupOpen && table->ContextPopupColumn == column_n && table->InstanceInteracted == table->InstanceCurrent);
ImGuiID id = window->GetID(label); ImGuiID id = window->GetPageID(label);
ImRect bb(cell_r.Min.x, cell_r.Min.y, cell_r.Max.x, ImMax(cell_r.Max.y, cell_r.Min.y + label_height + g.Style.CellPadding.y * 2.0f)); ImRect bb(cell_r.Min.x, cell_r.Min.y, cell_r.Max.x, ImMax(cell_r.Max.y, cell_r.Min.y + label_height + g.Style.CellPadding.y * 2.0f));
ItemSize(ImVec2(0.0f, label_height)); // Don't declare unclipped width, it'll be fed ContentMaxPosHeadersIdeal ItemSize(ImVec2(0.0f, label_height)); // Don't declare unclipped width, it'll be fed ContentMaxPosHeadersIdeal
if (!ItemAdd(bb, id)) if (!ItemAdd(bb, id))
@ -3812,7 +3812,7 @@ ImGuiID ImGui::GetColumnsID(const char* str_id, int columns_count)
// Differentiate column ID with an arbitrary prefix for cases where users name their columns set the same as another widget. // Differentiate column ID with an arbitrary prefix for cases where users name their columns set the same as another widget.
// In addition, when an identifier isn't explicitly provided we include the number of columns in the hash to make it uniquer. // In addition, when an identifier isn't explicitly provided we include the number of columns in the hash to make it uniquer.
PushID(0x11223347 + (str_id ? 0 : columns_count)); PushID(0x11223347 + (str_id ? 0 : columns_count));
ImGuiID id = window->GetID(str_id ? str_id : "columns"); ImGuiID id = window->GetPageID(str_id ? str_id : "columns");
PopID(); PopID();
return id; return id;

View File

@ -675,7 +675,7 @@ bool ImGui::ButtonEx(const char* label, const ImVec2& size_arg, ImGuiButtonFlags
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style; const ImGuiStyle& style = g.Style;
const ImGuiID id = window->GetID(label); const ImGuiID id = window->GetPageID(label);
const ImVec2 label_size = CalcTextSize(label, NULL, true); const ImVec2 label_size = CalcTextSize(label, NULL, true);
ImVec2 pos = window->DC.CursorPos; ImVec2 pos = window->DC.CursorPos;
@ -738,7 +738,7 @@ bool ImGui::InvisibleButton(const char* str_id, const ImVec2& size_arg, ImGuiBut
// Cannot use zero-size for InvisibleButton(). Unlike Button() there is not way to fallback using the label size. // Cannot use zero-size for InvisibleButton(). Unlike Button() there is not way to fallback using the label size.
IM_ASSERT(size_arg.x != 0.0f && size_arg.y != 0.0f); IM_ASSERT(size_arg.x != 0.0f && size_arg.y != 0.0f);
const ImGuiID id = window->GetID(str_id); const ImGuiID id = window->GetPageID(str_id);
ImVec2 size = CalcItemSize(size_arg, 0.0f, 0.0f); ImVec2 size = CalcItemSize(size_arg, 0.0f, 0.0f);
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size); const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size);
ItemSize(size); ItemSize(size);
@ -758,7 +758,7 @@ bool ImGui::ArrowButtonEx(const char* str_id, ImGuiDir dir, ImVec2 size, ImGuiBu
return false; return false;
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
const ImGuiID id = window->GetID(str_id); const ImGuiID id = window->GetPageID(str_id);
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size); const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size);
const float default_size = GetFrameHeight(); const float default_size = GetFrameHeight();
ItemSize(size, (size.y >= default_size) ? g.Style.FramePadding.y : -1.0f); ItemSize(size, (size.y >= default_size) ? g.Style.FramePadding.y : -1.0f);
@ -1062,7 +1062,7 @@ bool ImGui::ImageButton(ImTextureID user_texture_id, const ImVec2& size, const I
// Default to using texture ID as ID. User can still push string/integer prefixes. // Default to using texture ID as ID. User can still push string/integer prefixes.
PushID((void*)(intptr_t)user_texture_id); PushID((void*)(intptr_t)user_texture_id);
const ImGuiID id = window->GetID("#image"); const ImGuiID id = window->GetPageID("#image");
PopID(); PopID();
const ImVec2 padding = (frame_padding >= 0) ? ImVec2((float)frame_padding, (float)frame_padding) : g.Style.FramePadding; const ImVec2 padding = (frame_padding >= 0) ? ImVec2((float)frame_padding, (float)frame_padding) : g.Style.FramePadding;
@ -1077,7 +1077,7 @@ bool ImGui::Checkbox(const char* label, bool* v)
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style; const ImGuiStyle& style = g.Style;
const ImGuiID id = window->GetID(label); const ImGuiID id = window->GetPageID(label);
const ImVec2 label_size = CalcTextSize(label, NULL, true); const ImVec2 label_size = CalcTextSize(label, NULL, true);
const float square_sz = GetFrameHeight(); const float square_sz = GetFrameHeight();
@ -1183,7 +1183,7 @@ bool ImGui::RadioButton(const char* label, bool active)
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style; const ImGuiStyle& style = g.Style;
const ImGuiID id = window->GetID(label); const ImGuiID id = window->GetPageID(label);
const ImVec2 label_size = CalcTextSize(label, NULL, true); const ImVec2 label_size = CalcTextSize(label, NULL, true);
const float square_sz = GetFrameHeight(); const float square_sz = GetFrameHeight();
@ -1579,7 +1579,7 @@ bool ImGui::BeginCombo(const char* label, const char* preview_value, ImGuiComboF
return false; return false;
const ImGuiStyle& style = g.Style; const ImGuiStyle& style = g.Style;
const ImGuiID id = window->GetID(label); const ImGuiID id = window->GetPageID(label);
IM_ASSERT((flags & (ImGuiComboFlags_NoArrowButton | ImGuiComboFlags_NoPreview)) != (ImGuiComboFlags_NoArrowButton | ImGuiComboFlags_NoPreview)); // Can't use both flags together IM_ASSERT((flags & (ImGuiComboFlags_NoArrowButton | ImGuiComboFlags_NoPreview)) != (ImGuiComboFlags_NoArrowButton | ImGuiComboFlags_NoPreview)); // Can't use both flags together
const float arrow_size = (flags & ImGuiComboFlags_NoArrowButton) ? 0.0f : GetFrameHeight(); const float arrow_size = (flags & ImGuiComboFlags_NoArrowButton) ? 0.0f : GetFrameHeight();
@ -2395,7 +2395,7 @@ bool ImGui::DragScalar(const char* label, ImGuiDataType data_type, void* p_data,
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style; const ImGuiStyle& style = g.Style;
const ImGuiID id = window->GetID(label); const ImGuiID id = window->GetPageID(label);
const float w = CalcItemWidth(); const float w = CalcItemWidth();
const ImVec2 label_size = CalcTextSize(label, NULL, true); const ImVec2 label_size = CalcTextSize(label, NULL, true);
@ -3013,7 +3013,7 @@ bool ImGui::SliderScalar(const char* label, ImGuiDataType data_type, void* p_dat
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style; const ImGuiStyle& style = g.Style;
const ImGuiID id = window->GetID(label); const ImGuiID id = window->GetPageID(label);
const float w = CalcItemWidth(); const float w = CalcItemWidth();
const ImVec2 label_size = CalcTextSize(label, NULL, true); const ImVec2 label_size = CalcTextSize(label, NULL, true);
@ -3179,7 +3179,7 @@ bool ImGui::VSliderScalar(const char* label, const ImVec2& size, ImGuiDataType d
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style; const ImGuiStyle& style = g.Style;
const ImGuiID id = window->GetID(label); const ImGuiID id = window->GetPageID(label);
const ImVec2 label_size = CalcTextSize(label, NULL, true); const ImVec2 label_size = CalcTextSize(label, NULL, true);
const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + size); const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + size);
@ -3979,7 +3979,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
if (is_multiline) // Open group before calling GetID() because groups tracks id created within their scope (including the scrollbar) if (is_multiline) // Open group before calling GetID() because groups tracks id created within their scope (including the scrollbar)
BeginGroup(); BeginGroup();
const ImGuiID id = window->GetID(label); const ImGuiID id = window->GetPageID(label);
const ImVec2 label_size = CalcTextSize(label, NULL, true); const ImVec2 label_size = CalcTextSize(label, NULL, true);
const ImVec2 frame_size = CalcItemSize(size_arg, CalcItemWidth(), (is_multiline ? g.FontSize * 8.0f : label_size.y) + style.FramePadding.y * 2.0f); // Arbitrary default of 8 lines high for multi-line const ImVec2 frame_size = CalcItemSize(size_arg, CalcItemWidth(), (is_multiline ? g.FontSize * 8.0f : label_size.y) + style.FramePadding.y * 2.0f); // Arbitrary default of 8 lines high for multi-line
const ImVec2 total_size = ImVec2(frame_size.x + (label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f), frame_size.y); const ImVec2 total_size = ImVec2(frame_size.x + (label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f), frame_size.y);
@ -5506,7 +5506,7 @@ bool ImGui::ColorButton(const char* desc_id, const ImVec4& col, ImGuiColorEditFl
return false; return false;
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
const ImGuiID id = window->GetID(desc_id); const ImGuiID id = window->GetPageID(desc_id);
float default_size = GetFrameHeight(); float default_size = GetFrameHeight();
if (size.x == 0.0f) if (size.x == 0.0f)
size.x = default_size; size.x = default_size;
@ -5763,7 +5763,7 @@ bool ImGui::TreeNode(const char* label)
ImGuiWindow* window = GetCurrentWindow(); ImGuiWindow* window = GetCurrentWindow();
if (window->SkipItems) if (window->SkipItems)
return false; return false;
return TreeNodeBehavior(window->GetID(label), 0, label, NULL); return TreeNodeBehavior(window->GetPageID(label), 0, label, NULL);
} }
bool ImGui::TreeNodeV(const char* str_id, const char* fmt, va_list args) bool ImGui::TreeNodeV(const char* str_id, const char* fmt, va_list args)
@ -5782,7 +5782,7 @@ bool ImGui::TreeNodeEx(const char* label, ImGuiTreeNodeFlags flags)
if (window->SkipItems) if (window->SkipItems)
return false; return false;
return TreeNodeBehavior(window->GetID(label), flags, label, NULL); return TreeNodeBehavior(window->GetPageID(label), flags, label, NULL);
} }
bool ImGui::TreeNodeEx(const char* str_id, ImGuiTreeNodeFlags flags, const char* fmt, ...) bool ImGui::TreeNodeEx(const char* str_id, ImGuiTreeNodeFlags flags, const char* fmt, ...)
@ -5811,7 +5811,7 @@ bool ImGui::TreeNodeExV(const char* str_id, ImGuiTreeNodeFlags flags, const char
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
const char* label_end = g.TempBuffer + ImFormatStringV(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), fmt, args); const char* label_end = g.TempBuffer + ImFormatStringV(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), fmt, args);
return TreeNodeBehavior(window->GetID(str_id), flags, g.TempBuffer, label_end); return TreeNodeBehavior(window->GetPageID(str_id), flags, g.TempBuffer, label_end);
} }
bool ImGui::TreeNodeExV(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args) bool ImGui::TreeNodeExV(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args)
@ -5822,7 +5822,7 @@ bool ImGui::TreeNodeExV(const void* ptr_id, ImGuiTreeNodeFlags flags, const char
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
const char* label_end = g.TempBuffer + ImFormatStringV(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), fmt, args); const char* label_end = g.TempBuffer + ImFormatStringV(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), fmt, args);
return TreeNodeBehavior(window->GetID(ptr_id), flags, g.TempBuffer, label_end); return TreeNodeBehavior(window->GetPageID(ptr_id), flags, g.TempBuffer, label_end);
} }
bool ImGui::TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags) bool ImGui::TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags)
@ -6131,7 +6131,7 @@ bool ImGui::CollapsingHeader(const char* label, ImGuiTreeNodeFlags flags)
if (window->SkipItems) if (window->SkipItems)
return false; return false;
return TreeNodeBehavior(window->GetID(label), flags | ImGuiTreeNodeFlags_CollapsingHeader, label); return TreeNodeBehavior(window->GetPageID(label), flags | ImGuiTreeNodeFlags_CollapsingHeader, label);
} }
// p_visible == NULL : regular collapsing header // p_visible == NULL : regular collapsing header
@ -6147,7 +6147,7 @@ bool ImGui::CollapsingHeader(const char* label, bool* p_visible, ImGuiTreeNodeFl
if (p_visible && !*p_visible) if (p_visible && !*p_visible)
return false; return false;
ImGuiID id = window->GetID(label); ImGuiID id = window->GetPageID(label);
flags |= ImGuiTreeNodeFlags_CollapsingHeader; flags |= ImGuiTreeNodeFlags_CollapsingHeader;
if (p_visible) if (p_visible)
flags |= ImGuiTreeNodeFlags_AllowItemOverlap | ImGuiTreeNodeFlags_ClipLabelForTrailingButton; flags |= ImGuiTreeNodeFlags_AllowItemOverlap | ImGuiTreeNodeFlags_ClipLabelForTrailingButton;
@ -6191,7 +6191,7 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
const ImGuiStyle& style = g.Style; const ImGuiStyle& style = g.Style;
// Submit label or explicit size to ItemSize(), whereas ItemAdd() will submit a larger/spanning rectangle. // Submit label or explicit size to ItemSize(), whereas ItemAdd() will submit a larger/spanning rectangle.
ImGuiID id = window->GetID(label); ImGuiID id = window->GetPageID(label);
ImVec2 label_size = CalcTextSize(label, NULL, true); ImVec2 label_size = CalcTextSize(label, NULL, true);
ImVec2 size(size_arg.x != 0.0f ? size_arg.x : label_size.x, size_arg.y != 0.0f ? size_arg.y : label_size.y); ImVec2 size(size_arg.x != 0.0f ? size_arg.x : label_size.x, size_arg.y != 0.0f ? size_arg.y : label_size.y);
ImVec2 pos = window->DC.CursorPos; ImVec2 pos = window->DC.CursorPos;
@ -6354,7 +6354,7 @@ bool ImGui::BeginListBox(const char* label, const ImVec2& size_arg)
return false; return false;
const ImGuiStyle& style = g.Style; const ImGuiStyle& style = g.Style;
const ImGuiID id = GetID(label); const ImGuiID id = GetPageID(label);
const ImVec2 label_size = CalcTextSize(label, NULL, true); const ImVec2 label_size = CalcTextSize(label, NULL, true);
// Size default to hold ~7.25 items. // Size default to hold ~7.25 items.
@ -6483,7 +6483,7 @@ int ImGui::PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_get
return -1; return -1;
const ImGuiStyle& style = g.Style; const ImGuiStyle& style = g.Style;
const ImGuiID id = window->GetID(label); const ImGuiID id = window->GetPageID(label);
const ImVec2 label_size = CalcTextSize(label, NULL, true); const ImVec2 label_size = CalcTextSize(label, NULL, true);
if (frame_size.x == 0.0f) if (frame_size.x == 0.0f)
@ -6893,7 +6893,7 @@ bool ImGui::BeginMenuEx(const char* label, const char* icon, bool enabled)
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style; const ImGuiStyle& style = g.Style;
const ImGuiID id = window->GetID(label); const ImGuiID id = window->GetPageID(label);
bool menu_is_open = IsPopupOpen(id, ImGuiPopupFlags_None); bool menu_is_open = IsPopupOpen(id, ImGuiPopupFlags_None);
// Sub-menus are ChildWindow so that mouse can be hovering across them (otherwise top-most popup menu would steal focus and not allow hovering on parent menu) // Sub-menus are ChildWindow so that mouse can be hovering across them (otherwise top-most popup menu would steal focus and not allow hovering on parent menu)
@ -7261,7 +7261,7 @@ bool ImGui::BeginTabBar(const char* str_id, ImGuiTabBarFlags flags)
if (window->SkipItems) if (window->SkipItems)
return false; return false;
ImGuiID id = window->GetID(str_id); ImGuiID id = window->GetPageID(str_id);
ImGuiTabBar* tab_bar = g.TabBars.GetOrAddByKey(id); ImGuiTabBar* tab_bar = g.TabBars.GetOrAddByKey(id);
ImRect tab_bar_bb = ImRect(window->DC.CursorPos.x, window->DC.CursorPos.y, window->WorkRect.Max.x, window->DC.CursorPos.y + g.FontSize + g.Style.FramePadding.y * 2); ImRect tab_bar_bb = ImRect(window->DC.CursorPos.x, window->DC.CursorPos.y, window->WorkRect.Max.x, window->DC.CursorPos.y + g.FontSize + g.Style.FramePadding.y * 2);
tab_bar->ID = id; tab_bar->ID = id;
@ -7608,7 +7608,7 @@ static ImU32 ImGui::TabBarCalcTabID(ImGuiTabBar* tab_bar, const char* label)
else else
{ {
ImGuiWindow* window = GImGui->CurrentWindow; ImGuiWindow* window = GImGui->CurrentWindow;
return window->GetID(label); return window->GetPageID(label);
} }
} }

View File

@ -143,9 +143,8 @@ TranslatorName = "Grinch_"
About = "About" About = "About"
Author = "Author" Author = "Author"
AutoCheckUpdate = "Check for updates" AutoCheckUpdate = "Check for updates"
BugDisclaimer = "If you find bugs or have suggestions, let me know on discord." BugDisclaimer = "Be sure to inform me about bugs or suggestions & join the discord server for beta updates"
Build = "Build" Build = "Build"
CheatMenuNoDir = "Failed to find CheatMenu directory!"
CheckUpdate = "Check update" CheckUpdate = "Check update"
Commands = "Commands" Commands = "Commands"
Config = "Config" Config = "Config"

View File

@ -139,7 +139,6 @@ Author = "作者"
AutoCheckUpdate = "检查更新" AutoCheckUpdate = "检查更新"
BugDisclaimer = "如果您发现错误或有建议,请通知我告诉我有哪些问题。" BugDisclaimer = "如果您发现错误或有建议,请通知我告诉我有哪些问题。"
Build = "生成" Build = "生成"
CheatMenuNoDir = "未能找到 CheatMenu 目录!"
CheckUpdate = "检查更新" CheckUpdate = "检查更新"
Commands = "命令" Commands = "命令"
Config = "配置" Config = "配置"

View File

@ -15,13 +15,14 @@
#include "pages/vehicle.h" #include "pages/vehicle.h"
#include "pages/visual.h" #include "pages/visual.h"
#include "pages/weapon.h" #include "pages/weapon.h"
#include "interface/ipage.h"
static bool DrawTitleBar() static bool DrawTitleBar()
{ {
bool hovered, held; bool hovered, held;
ImGuiWindow *window = ImGui::GetCurrentWindow(); ImGuiWindow *window = ImGui::GetCurrentWindow();
ImGuiStyle& Style = ImGui::GetStyle(); ImGuiStyle& Style = ImGui::GetStyle();
ImGuiID id = window->GetID("#CLOSE"); ImGuiID id = window->GetPageID("#CLOSE");
ImGui::PushFont(FontMgr::Get("title")); ImGui::PushFont(FontMgr::Get("title"));
Widget::TextCentered(MENU_TITLE); Widget::TextCentered(MENU_TITLE);
@ -87,7 +88,7 @@ void CheatMenu::DrawWindow()
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImGui::PushStyleVar(ImGuiStyleVar_FramePadding,
ImVec2(ImGui::GetWindowWidth() / 85, ImGui::GetWindowHeight() / 200)); ImVec2(ImGui::GetWindowWidth() / 85, ImGui::GetWindowHeight() / 200));
ProcessPages(); PageHandler::DrawPages();
if (m_bSizeChangedExternal) if (m_bSizeChangedExternal)
m_bSizeChangedExternal = false; m_bSizeChangedExternal = false;
@ -119,21 +120,18 @@ void CheatMenu::Init()
} }
// Load menu settings // Load menu settings
m_nMenuPage = (eMenuPages)gConfig.Get("Window.CurrentPage", (size_t)eMenuPages::WELCOME); // m_nMenuPage = (eMenuPages)gConfig.Get("Window.CurrentPage", (size_t)eMenuPages::WELCOME);
m_fMenuSize.x = gConfig.Get("Window.SizeX", screen::GetScreenWidth() / 4.0f); m_fMenuSize.x = gConfig.Get("Window.SizeX", screen::GetScreenWidth() / 4.0f);
m_fMenuSize.y = gConfig.Get("Window.SizeY", screen::GetScreenHeight() / 1.2f); m_fMenuSize.y = gConfig.Get("Window.SizeY", screen::GetScreenHeight() / 1.2f);
srand(CTimer::m_snTimeInMilliseconds); srand(CTimer::m_snTimeInMilliseconds);
ApplyStyle(); ApplyStyle();
Locale::Init(FILE_NAME "/locale/", "English", "English"); Locale::Init(FILE_NAME "/locale/", "English", "English");
GenHeaderList(); // GenHeaderList();
// Init menu parts // Init menu parts
Game::Init();
Menu::Init();
Player::Init(); Player::Init();
Ped::Init(); Ped::Init();
Teleport::Init();
Vehicle::Init(); Vehicle::Init();
Visual::Init(); Visual::Init();
WeaponPage::Init(); WeaponPage::Init();
@ -164,7 +162,7 @@ void CheatMenu::Init()
D3dHook::SetMouseState(m_bShowMenu); D3dHook::SetMouseState(m_bShowMenu);
} }
if (Teleport::IsQuickTeleportActive() && quickTeleport.PressedRealtime()) if (teleportPage.IsQuickTeleportActive() && quickTeleport.PressedRealtime())
{ {
D3dHook::SetMouseState(true); D3dHook::SetMouseState(true);
} }

View File

@ -3,7 +3,7 @@
/* /*
* Main CheatMenu Class * Main CheatMenu Class
* Handles rendering, resizing, page handling etc. * Handles rendering, resizing, page drawing etc.
*/ */
class CheatMenu class CheatMenu
{ {

View File

@ -35,7 +35,7 @@ void FreecamMgr::Enable()
Command<Commands::CAMERA_PERSIST_FOV>(true); Command<Commands::CAMERA_PERSIST_FOV>(true);
} }
void FreecamMgr::Process() void FreecamMgr::DrawPages()
{ {
int delta = (CTimer::m_snTimeInMilliseconds - CTimer::m_snPreviousTimeInMilliseconds); int delta = (CTimer::m_snTimeInMilliseconds - CTimer::m_snPreviousTimeInMilliseconds);
int ratio = 1 / (1 + (delta * m_nMul)); int ratio = 1 / (1 + (delta * m_nMul));
@ -183,7 +183,7 @@ FreecamMgr::FreecamMgr()
{ {
if (m_bEnabled) if (m_bEnabled)
{ {
Process(); DrawPages();
} }
}; };
} }

View File

@ -19,7 +19,7 @@ private:
FreecamMgr(const FreecamMgr&); FreecamMgr(const FreecamMgr&);
// Process freecam mode each frame // Process freecam mode each frame
void Process(); void DrawPages();
public: public:
int m_nMul = 1; // speed multiplier int m_nMul = 1; // speed multiplier

View File

@ -231,11 +231,11 @@ NeonMgr::NeonMgr()
NeonMgr::~NeonMgr() NeonMgr::~NeonMgr()
{ {
if (m_pNeonTexture) // if (m_pNeonTexture)
{ // {
RwTextureDestroy(m_pNeonTexture); // RwTextureDestroy(m_pNeonTexture);
m_pNeonTexture = nullptr; // m_pNeonTexture = nullptr;
} // }
} }
bool NeonMgr::IsInstalled(CVehicle* pVeh) bool NeonMgr::IsInstalled(CVehicle* pVeh)

View File

@ -3,7 +3,7 @@
RandomCheatsMgr& RandomCheats = RandomCheatsMgr::Get(); RandomCheatsMgr& RandomCheats = RandomCheatsMgr::Get();
void RandomCheatsMgr::Process() void RandomCheatsMgr::DrawPages()
{ {
uint timer = CTimer::m_snTimeInMilliseconds; uint timer = CTimer::m_snTimeInMilliseconds;
static uint m_nTimer = 0; static uint m_nTimer = 0;
@ -72,7 +72,7 @@ RandomCheatsMgr::RandomCheatsMgr()
{ {
if (m_bEnabled) if (m_bEnabled)
{ {
Process(); DrawPages();
} }
}; };
} }

View File

@ -17,7 +17,7 @@ private:
RandomCheatsMgr(const RandomCheatsMgr&); RandomCheatsMgr(const RandomCheatsMgr&);
// Process the RandomCheat each frame & draw progress bar // Process the RandomCheat each frame & draw progress bar
void Process(); void DrawPages();
public: public:
bool m_bProgressBar = true; bool m_bProgressBar = true;

View File

@ -9,7 +9,7 @@ TopDownCamera::TopDownCamera()
{ {
if (m_bEnabled) if (m_bEnabled)
{ {
Process(); DrawPages();
} }
}; };
} }
@ -18,7 +18,7 @@ TopDownCamera::TopDownCamera()
Taken from gta chaos mod by Lordmau5 Taken from gta chaos mod by Lordmau5
https://github.com/gta-chaos-mod/Trilogy-ASI-Script https://github.com/gta-chaos-mod/Trilogy-ASI-Script
*/ */
void TopDownCamera::Process() void TopDownCamera::DrawPages()
{ {
CPlayerPed *player = FindPlayerPed(); CPlayerPed *player = FindPlayerPed();
CVector pos = player->GetPosition (); CVector pos = player->GetPosition ();

View File

@ -17,7 +17,7 @@ public:
int m_nZoom = 40; int m_nZoom = 40;
// Process cheat each frame // Process cheat each frame
void Process(); void DrawPages();
}; };
extern TopDownCamera& TopDownCam; extern TopDownCamera& TopDownCam;

View File

@ -4,6 +4,7 @@
#define SPAWN_PED_LIMIT 20 #define SPAWN_PED_LIMIT 20
#define DISCORD_INVITE "https://discord.gg/ZzW7kmf" #define DISCORD_INVITE "https://discord.gg/ZzW7kmf"
#define GITHUB_LINK "https://github.com/user-grinch/Cheat-Menu" #define GITHUB_LINK "https://github.com/user-grinch/Cheat-Menu"
#define PATREON_LINK "https://www.patreon.com/grinch_"
#define IMGUI_DEFINE_MATH_OPERATORS #define IMGUI_DEFINE_MATH_OPERATORS
#define MENU_NAME "Cheat Menu" #define MENU_NAME "Cheat Menu"

View File

@ -100,7 +100,7 @@ void MenuThread(void* param)
CheatMenu::Init(); CheatMenu::Init();
// Checking for updates once a day // Checking for updates once a day
if (Menu::m_bAutoCheckUpdate && gConfig.Get("Menu.LastUpdateChecked", 0) != st.wDay) if (menuPage.m_bAutoCheckUpdate && gConfig.Get("Menu.LastUpdateChecked", 0) != st.wDay)
{ {
Updater::CheckUpdate(); Updater::CheckUpdate();
gConfig.Set("Menu.LastUpdateChecked", st.wDay); gConfig.Set("Menu.LastUpdateChecked", st.wDay);
@ -113,9 +113,9 @@ void MenuThread(void* param)
while (true) while (true)
{ {
FontMgr::Process(); FontMgr::DrawPages();
RPC::Process(); RPC::DrawPages();
Updater::Process(); Updater::DrawPages();
Sleep(1000); Sleep(1000);
} }
} }

View File

@ -2,90 +2,21 @@
#include "ipage.h" #include "ipage.h"
#include "utils/updater.h" #include "utils/updater.h"
#include "utils/widget.h" #include "utils/widget.h"
#include "imgui/imgui_internal.h"
#include "pages/welcome.h"
static void DrawAnniversaryPage() void PageHandler::AddPage(PagePtr page)
{ {
Widget::TextCentered("Happy Anniversary!"); m_PageList.push_back(page);
ImGui::NewLine();
ImGui::TextWrapped("On this day, in 2019, the first public version of menu was released in MixMods Forum."
" It's been a blast working on it and I've learned a lot in the process.\n\nThanks to you and everyone who used or"
" contributed to the modification in any form or shape.");
ImGui::NewLine();
ImGui::TextWrapped("Feel free to star the GitHub repo or join the discord server and provide feedback, ideas, or suggestions.");
ImGui::NewLine();
if (ImGui::Button(TEXT("Menu.DiscordServer"), ImVec2(Widget::CalcSize(3))))
{
OPEN_LINK(DISCORD_INVITE);
}
ImGui::SameLine();
if (ImGui::Button(TEXT("Menu.GitHubRepo"), ImVec2(Widget::CalcSize(3))))
{
OPEN_LINK(GITHUB_LINK);
}
}
static void DrawWelcomePage()
{
ImGui::NewLine();
Widget::TextCentered(TEXT("Menu.WelcomeMSG"));
Widget::TextCentered(std::format("{}: Grinch_",TEXT("Menu.Author")));
ImGui::NewLine();
ImGui::TextWrapped(TEXT("Menu.EnsureLatest"));
if (ImGui::Button(TEXT("Menu.DiscordServer"), ImVec2(Widget::CalcSize(2))))
{
OPEN_LINK(DISCORD_INVITE);
}
ImGui::SameLine();
if (ImGui::Button(TEXT("Menu.GitHubRepo"), ImVec2(Widget::CalcSize(2))))
{
OPEN_LINK(GITHUB_LINK);
}
ImGui::NewLine();
ImGui::TextWrapped(TEXT("Menu.BugDisclaimer"));
ImGui::Dummy(ImVec2(0, 20));
Widget::TextCentered(TEXT("Menu.PatreonText"));
if (ImGui::Button(TEXT("Menu.Patreon"), ImVec2(Widget::CalcSize(1))))
{
OPEN_LINK("https://www.patreon.com/grinch_");
}
ImGui::Dummy(ImVec2(0, 30));
Widget::TextCentered(TEXT("Menu.CopyrightDisclaimer"));
} }
static void DrawUpdatePage() void PageHandler::SetCurrentPage(PagePtr page)
{ {
std::string ver = Updater::GetUpdateVersion(); m_pCurrentPage = page;
ImGui::Dummy(ImVec2(0, 20));
Widget::TextCentered(TEXT("Menu.NewVersion"));
Widget::TextCentered(std::format("{}: {}", TEXT("Menu.CurrentVersion"), MENU_VERSION));
Widget::TextCentered(TEXT("Menu.LatestVersion") + ver);
ImGui::Dummy(ImVec2(0, 10));
ImGui::TextWrapped(TEXT("Menu.UpdaterInfo1"));
ImGui::Dummy(ImVec2(0, 10));
ImGui::TextWrapped(TEXT("Menu.UpdaterInfo2"));
ImGui::Dummy(ImVec2(0, 5));
if (ImGui::Button(TEXT("Menu.DiscordServer"), ImVec2(Widget::CalcSize(2))))
{
OPEN_LINK(DISCORD_INVITE);
}
ImGui::SameLine();
if (ImGui::Button(TEXT("Menu.DownloadPage"), Widget::CalcSize(2)))
{
ShellExecute(NULL, "open", std::string("https://github.com/user-grinch/Cheat-Menu/releases/tag/" +
ver).c_str(), NULL, NULL, SW_SHOWNORMAL);
}
} }
template <typename T> using IPageStatic = IPage<WelcomePage>; // dummy class
void IPage<T>::Process() void PageHandler::DrawPages()
{ {
ImVec2 size = Widget::CalcSize(3, false); ImVec2 size = Widget::CalcSize(3, false);
ImGuiStyle &style = ImGui::GetStyle(); ImGuiStyle &style = ImGui::GetStyle();
@ -93,12 +24,20 @@ void IPage<T>::Process()
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0)); ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0));
if (Updater::IsUpdateAvailable()) if (Updater::IsUpdateAvailable())
{ {
m_nCurrentPage = eMenuPage::Update; for (PagePtr ptr : m_PageList)
{
IPageStatic* page = reinterpret_cast<IPageStatic*>(ptr);
if (page->GetPageID() == ePageID::Update)
{
m_pCurrentPage = page;
break;
}
}
} }
// Check once if it's anniversary day // Check once if it's anniversary day
static bool aniCheckDone; static bool checked;
if (!aniCheckDone) if (!checked)
{ {
SYSTEMTIME st; SYSTEMTIME st;
GetSystemTime(&st); GetSystemTime(&st);
@ -114,48 +53,40 @@ void IPage<T>::Process()
if (!flag) if (!flag)
{ {
gConfig.Set("Window.AnniversaryShown", true); gConfig.Set("Window.AnniversaryShown", true);
m_nMenuPage = eMenuPages::ANNIVERSARY;
for (void* ptr : m_PageList)
{
IPageStatic* page = reinterpret_cast<IPageStatic*>(ptr);
if (page->GetPageID() == ePageID::Anniversary)
{
m_pCurrentPage = page;
break;
}
}
} }
} }
aniCheckDone = true; checked = true;
} }
// Draw header buttons
ImDrawList *pDrawList = ImGui::GetWindowDrawList(); ImDrawList *pDrawList = ImGui::GetWindowDrawList();
for (size_t i = 0; i < m_headerList.size(); ++i) size_t count = 0;
{ for (PagePtr ptr : m_PageList)
/* {
* For welcome & update pages IPageStatic* pg = reinterpret_cast<IPageStatic*>(ptr);
* They don't need to add item in the header list if (!pg->HasHeaderButton())
*/
if (m_headerList[i].skipHeader)
{ {
if (m_nMenuPage == m_headerList[i].page)
{
pCallback = m_headerList[i].pFunc;
}
continue; continue;
} }
const char* text = m_headerList[i].name.c_str(); std::string text = TEXT_S(pg->GetPageKey());
ImVec4 color = (pg == m_pCurrentPage) ? style.Colors[ImGuiCol_ButtonActive] : style.Colors[ImGuiCol_Button];
ImVec4 color; if (ImGui::InvisibleButton(text.c_str(), size))
if (m_headerList[i].page == m_nMenuPage)
{ {
color = style.Colors[ImGuiCol_ButtonActive]; m_pCurrentPage = pg;
pCallback = m_headerList[i].pFunc; size_t id = static_cast<size_t>(pg->GetPageID());
} gConfig.Set("Window.CurrentPage", id);
else
{
color = style.Colors[ImGuiCol_Button];
}
if (ImGui::InvisibleButton(text, size))
{
m_nMenuPage = m_headerList[i].page;
size_t curPage = static_cast<size_t>(m_headerList[i].page);
gConfig.Set("Window.CurrentPage", curPage);
pCallback = m_headerList[i].pFunc;
Updater::ResetUpdaterState(); Updater::ResetUpdaterState();
} }
@ -169,28 +100,30 @@ void IPage<T>::Process()
* TODO: hardcoded atm * TODO: hardcoded atm
*/ */
ImDrawFlags flags = ImDrawFlags_RoundCornersNone; ImDrawFlags flags = ImDrawFlags_RoundCornersNone;
if (i == 0) flags = ImDrawFlags_RoundCornersTopLeft; if (count == 0) flags = ImDrawFlags_RoundCornersTopLeft;
if (i == 2) flags = ImDrawFlags_RoundCornersTopRight; if (count == 2) flags = ImDrawFlags_RoundCornersTopRight;
if (i == 6) flags = ImDrawFlags_RoundCornersBottomLeft; if (count == 6) flags = ImDrawFlags_RoundCornersBottomLeft;
if (i == 8) flags = ImDrawFlags_RoundCornersBottomRight; if (count == 8) flags = ImDrawFlags_RoundCornersBottomRight;
ImVec2 min = ImGui::GetItemRectMin(); ImVec2 min = ImGui::GetItemRectMin();
ImVec2 max = ImGui::GetItemRectMax(); ImVec2 max = ImGui::GetItemRectMax();
ImVec2 size = ImGui::CalcTextSize(text); ImVec2 size = ImGui::CalcTextSize(text.c_str());
pDrawList->AddRectFilled(min, max, ImGui::GetColorU32(color), style.FrameRounding, flags); pDrawList->AddRectFilled(min, max, ImGui::GetColorU32(color), style.FrameRounding, flags);
ImGui::RenderTextClipped(min + style.FramePadding, max - style.FramePadding, text, NULL, &size, style.ButtonTextAlign); ImGui::RenderTextClipped(min + style.FramePadding, max - style.FramePadding, text.c_str(), NULL, &size, style.ButtonTextAlign);
if (i % 3 != 2) if (count % 3 != 2)
{ {
ImGui::SameLine(); ImGui::SameLine();
} }
++count;
} }
ImGui::PopStyleVar(); ImGui::PopStyleVar();
ImGui::Spacing();
ImGui::Dummy(ImVec2(0, 10)); ImGui::Dummy(ImVec2(0, 10));
if (m_pCurrentPage != nullptr && ImGui::BeginChild("HEADERCONTENT")) if (m_pCurrentPage != nullptr && ImGui::BeginChild("HEADERCONTENT"))
{ {
m_pCurrentPage->Draw(); reinterpret_cast<IPageStatic*>(m_pCurrentPage)->Draw();
ImGui::EndChild(); ImGui::EndChild();
} }
} }

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <vector> #include <vector>
enum class eMenuPage enum class ePageID
{ {
Anniversary, Anniversary,
Game, Game,
@ -18,6 +18,30 @@ enum class eMenuPage
Welcome Welcome
}; };
/*
Handles all pages
Draws the page code too
*/
using PagePtr = void*;
class PageHandler
{
private:
static inline std::vector<PagePtr> m_PageList; // Contains list of the created pages
static inline PagePtr m_pCurrentPage = nullptr; // Currently visible menu page
public:
PageHandler() = delete;
PageHandler(const PageHandler&) = delete;
// Process the menu pages & draw them
static void DrawPages();
// Add a new page
static void AddPage(PagePtr page);
static void SetCurrentPage(PagePtr page);
};
/* /*
Interface class for pages Interface class for pages
Every page must inherit this Every page must inherit this
@ -26,47 +50,41 @@ template<typename T>
class IPage class IPage
{ {
private: private:
eMenuPage m_ePage; // Menu page ID ePageID m_eID; // Menu page ID
bool m_bHasHeader; // Does the page has a header button bool m_bHasHeader; // Does the page has a header button
std::string m_NameKey; // A key to the page name string std::string m_NameKey; // A key to the page name string
public: public:
static inline std::vector<IPage*> m_nPageList; // Contains list of the created pages IPage(ePageID page, const std::string& key, bool header)
static inline IPage* m_pCurrentPage = nullptr; // Currently visible menu page : m_eID(page), m_NameKey(key), m_bHasHeader(header)
IPage(m_ePage page, std::string&& key, bool header = true)
: m_ePage(page), m_NameKey(key), m_bHasHeader(header)
{ {
m_nPageList.push_back(this); PageHandler::AddPage(reinterpret_cast<PagePtr>(this));
} }
// Page drawing code goes here // Page drawing code goes here
virtual void Draw() = 0; virtual void Draw() = 0;
static T *Get() final static T &Get()
{ {
static T _instance; static T _instance;
return &_instance; return _instance;
} }
// Returns the ID of the page // Returns the ID of the page
eMenuPage GetPageID() final virtual ePageID GetPageID() final
{ {
return m_ePage; return m_eID;
} }
// Returns true if the page has a visible header button // Returns true if the page has a visible header button
bool HasHeaderButton() final virtual bool HasHeaderButton() final
{ {
return m_bHasHeader; return m_bHasHeader;
} }
// Returns the page name key // Returns the page name key
std::string GetKey() final virtual std::string GetPageKey() final
{ {
return m_NameKey; return m_NameKey;
} }
// Process the menu pages & draw them
static void Process() final;
}; };

34
src/pages/anniversary.cpp Normal file
View File

@ -0,0 +1,34 @@
#include "pch.h"
#include "anniversary.h"
#include "utils/widget.h"
AnniversaryPage& anniversaryPage = AnniversaryPage::Get();
void AnniversaryPage::Draw()
{
Widget::TextCentered("Happy Anniversary!");
ImGui::NewLine();
ImGui::TextWrapped("On this day, in 2019, the first public version of menu was released."
" It's been a blast working on it and I've learned a lot in the process.\n\nThanks to you and everyone who used or"
" contributed to the modification in any shape or form.");
ImGui::NewLine();
ImGui::TextWrapped("Feel free to star the GitHub repo or join the discord server and provide feedback, ideas, or suggestions.");
ImGui::NewLine();
if (ImGui::Button(TEXT("Menu.DiscordServer"), ImVec2(Widget::CalcSize(3))))
{
OPEN_LINK(DISCORD_INVITE);
}
ImGui::SameLine();
if (ImGui::Button(TEXT("Menu.GitHubRepo"), ImVec2(Widget::CalcSize(3))))
{
OPEN_LINK(GITHUB_LINK);
}
ImGui::SameLine();
if (ImGui::Button(TEXT("Menu.Patreon"), ImVec2(Widget::CalcSize(3))))
{
OPEN_LINK(PATREON_LINK);
}
}

16
src/pages/anniversary.h Normal file
View File

@ -0,0 +1,16 @@
#pragma once
#include "interface/ipage.h"
// The anniversary celebration page
class AnniversaryPage : public IPage<AnniversaryPage>
{
private:
friend IPage;
AnniversaryPage() : IPage<AnniversaryPage>(ePageID::Anniversary, "Anniversary", false){}
AnniversaryPage(const AnniversaryPage&);
public:
void Draw();
};
extern AnniversaryPage& anniversaryPage;

View File

@ -38,7 +38,10 @@ static void RealTimeClock()
CClock::ms_nGameClockSeconds = now->tm_sec; CClock::ms_nGameClockSeconds = now->tm_sec;
} }
void Game::Init() GamePage& gamePage = GamePage::Get();
GamePage::GamePage()
: IPage<GamePage>(ePageID::Game, "Window.GamePage", true)
{ {
#ifdef GTASA #ifdef GTASA
@ -52,13 +55,13 @@ void Game::Init()
}; };
#endif #endif
Events::processScriptsEvent += [] Events::processScriptsEvent += [this]
{ {
uint timer = CTimer::m_snTimeInMilliseconds; uint timer = CTimer::m_snTimeInMilliseconds;
CPlayerPed* pPlayer = FindPlayerPed(); CPlayerPed* pPlayer = FindPlayerPed();
int hplayer = CPools::GetPedRef(pPlayer); int hplayer = CPools::GetPedRef(pPlayer);
if (HardMode::m_bEnabled) if (m_HardMode.m_bEnabled)
{ {
if (pPlayer->m_fHealth > 50.0f) if (pPlayer->m_fHealth > 50.0f)
{ {
@ -122,9 +125,9 @@ void Game::Init()
if (Freecam.Toggle()) if (Freecam.Toggle())
{ {
// restore lock camera zoom here // restore lock camera zoom here
if (Game::m_bLockCameraZoom) if (m_bLockCameraZoom)
{ {
TheCamera.LerpFOV(TheCamera.FindCamFOV(), Game::m_nCameraZoom, 250, true); TheCamera.LerpFOV(TheCamera.FindCamFOV(), m_nCameraZoom, 250, true);
} }
else else
{ {
@ -170,7 +173,7 @@ void SetPlayerMission(std::string& rootkey, std::string& name, std::string& id)
} }
} }
void Game::ShowPage() void GamePage::Draw()
{ {
ImGui::Spacing(); ImGui::Spacing();
CPlayerPed* pPlayer = FindPlayerPed(); CPlayerPed* pPlayer = FindPlayerPed();
@ -269,32 +272,32 @@ void Game::ShowPage()
{ {
Command<Commands::FREEZE_ONSCREEN_TIMER>(m_bMissionTimer); Command<Commands::FREEZE_ONSCREEN_TIMER>(m_bMissionTimer);
} }
if (Widget::Checkbox(TEXT("Game.HardMode"), &HardMode::m_bEnabled, TEXT("Game.HardModeText"))) if (Widget::Checkbox(TEXT("Game.HardMode"), &m_HardMode.m_bEnabled, TEXT("Game.HardModeText")))
{ {
CPlayerPed* player = FindPlayerPed(); CPlayerPed* player = FindPlayerPed();
if (HardMode::m_bEnabled) if (m_HardMode.m_bEnabled)
{ {
HardMode::m_fBacArmour = player->m_fArmour; m_HardMode.m_fBacArmour = player->m_fArmour;
HardMode::m_fBacHealth = player->m_fHealth; m_HardMode.m_fBacHealth = player->m_fHealth;
#ifdef GTASA #ifdef GTASA
HardMode::m_fBacMaxHealth = CStats::GetStatValue(STAT_MAX_HEALTH); m_HardMode.m_fBacMaxHealth = CStats::GetStatValue(STAT_MAX_HEALTH);
HardMode::m_fBacStamina = CStats::GetStatValue(STAT_STAMINA); m_HardMode.m_fBacStamina = CStats::GetStatValue(STAT_STAMINA);
#else #else
HardMode::m_fBacMaxHealth = 100.0f; m_HardMode.m_fBacMaxHealth = 100.0f;
#endif #endif
player->m_fHealth = 50.0f; player->m_fHealth = 50.0f;
} }
else else
{ {
player->m_fArmour = HardMode::m_fBacArmour; player->m_fArmour = m_HardMode.m_fBacArmour;
#ifdef GTASA #ifdef GTASA
CStats::SetStatValue(STAT_STAMINA, HardMode::m_fBacStamina); CStats::SetStatValue(STAT_STAMINA, m_HardMode.m_fBacStamina);
CStats::SetStatValue(STAT_MAX_HEALTH, HardMode::m_fBacMaxHealth); CStats::SetStatValue(STAT_MAX_HEALTH, m_HardMode.m_fBacMaxHealth);
#endif #endif
player->m_fHealth = HardMode::m_fBacHealth; player->m_fHealth = m_HardMode.m_fBacHealth;
} }
} }
#ifdef GTASA #ifdef GTASA
@ -611,9 +614,9 @@ void Game::ShowPage()
if (Freecam.Toggle()) if (Freecam.Toggle())
{ {
// restore lock camera zoom here // restore lock camera zoom here
if (Game::m_bLockCameraZoom) if (m_bLockCameraZoom)
{ {
TheCamera.LerpFOV(TheCamera.FindCamFOV(), Game::m_nCameraZoom, 250, true); TheCamera.LerpFOV(TheCamera.FindCamFOV(), m_nCameraZoom, 250, true);
} }
else else
{ {

View File

@ -1,44 +1,47 @@
#pragma once #pragma once
#include "pch.h" #include "pch.h"
#include "interface/ipage.h"
class Game class GamePage : public IPage<GamePage>
{ {
private: private:
static inline ResourceStore m_MissionData{ "missions", eResourceType::TYPE_TEXT }; ResourceStore m_MissionData{ "missions", eResourceType::TYPE_TEXT };
static inline bool m_bDisableCheats; bool m_bDisableCheats;
static inline bool m_bDisableReplay; bool m_bDisableReplay;
static inline bool m_bMissionTimer; bool m_bMissionTimer;
static inline bool m_bMobileRadio; bool m_bMobileRadio;
struct HardMode struct
{ {
static inline bool m_bEnabled; bool m_bEnabled;
static inline float m_fBacHealth = 0.0f; float m_fBacHealth;
static inline float m_fBacMaxHealth = 0.0f; float m_fBacMaxHealth;
static inline float m_fBacArmour = 0.0f; float m_fBacArmour;
static inline float m_fBacStamina = 0.0f; float m_fBacStamina;
}; } m_HardMode;
#ifdef GTASA #ifdef GTASA
static inline bool m_bForbiddenArea = true; // wanted level when going outside playable aea bool m_bForbiddenArea = true; // Wanted level when going outside playable aea
static inline bool m_bSolidWater; // walk on water hack bool m_bSolidWater; // Walk on water hack
static inline bool m_bNoWaterPhysics; bool m_bNoWaterPhysics;
static inline bool m_bScreenShot; bool m_bScreenShot;
static inline ResourceStore m_StatData{ "stats", eResourceType::TYPE_TEXT }; ResourceStore m_StatData{ "stats", eResourceType::TYPE_TEXT };
#endif #endif
friend IPage;
GamePage();
GamePage(const GamePage&);
public: public:
static inline bool m_bFreezeTime; bool m_bFreezeTime;
static inline bool m_bSyncTime; bool m_bSyncTime; // Sync time with system
#ifdef GTASA #ifdef GTASA
static inline int m_nCameraZoom = 70.0f; int m_nCameraZoom = 70.0f;
static inline bool m_bLockCameraZoom; bool m_bLockCameraZoom;
#endif #endif
Game() = delete; void Draw();
Game(const Game&) = delete;
static void Init();
static void ShowPage();
}; };
extern GamePage& gamePage;

View File

@ -7,7 +7,9 @@
#include "utils/rpc.h" #include "utils/rpc.h"
#include "utils/overlay.h" #include "utils/overlay.h"
void Menu::Init() MenuPage& menuPage = MenuPage::Get();
MenuPage::MenuPage()
: IPage<MenuPage>(ePageID::Menu, "Window.MenuPage", true)
{ {
m_bDiscordRPC = gConfig.Get("Menu.DiscordRPC", false); m_bDiscordRPC = gConfig.Get("Menu.DiscordRPC", false);
m_bAutoCheckUpdate = gConfig.Get("Menu.AutoCheckUpdate", true); m_bAutoCheckUpdate = gConfig.Get("Menu.AutoCheckUpdate", true);
@ -19,7 +21,7 @@ void Menu::Init()
} }
} }
void Menu::ShowPage() void MenuPage::Draw()
{ {
if (ImGui::BeginTabBar("Menu", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) if (ImGui::BeginTabBar("Menu", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll))
{ {
@ -49,7 +51,7 @@ void Menu::ShowPage()
{ {
Locale::SetDefaultLocale(); Locale::SetDefaultLocale();
selected = Locale::GetCurrentLocaleIndex(); selected = Locale::GetCurrentLocaleIndex();
CheatMenu::GenHeaderList(); // CheatMenu::GenHeaderList();
} }
} }
@ -72,7 +74,7 @@ void Menu::ShowPage()
{ {
if (Locale::SetLocale(selected) == Locale::eReturnCodes::SUCCESS) if (Locale::SetLocale(selected) == Locale::eReturnCodes::SUCCESS)
{ {
CheatMenu::GenHeaderList(); // CheatMenu::GenHeaderList();
} }
else else
{ {
@ -306,7 +308,7 @@ void Menu::ShowPage()
if (ImGui::Button(TEXT("Menu.Patreon"), ImVec2(Widget::CalcSize(2)))) if (ImGui::Button(TEXT("Menu.Patreon"), ImVec2(Widget::CalcSize(2))))
{ {
OPEN_LINK("https://www.patreon.com/grinch_"); OPEN_LINK(PATREON_LINK);
} }
ImGui::Spacing(); ImGui::Spacing();

View File

@ -1,23 +1,18 @@
#pragma once #pragma once
#include "pch.h" #include "interface/ipage.h"
/* class MenuPage : public IPage<MenuPage>
Menu Class
Handles code for the Menu page
*/
class Menu
{ {
public: public:
static inline bool m_bAutoCheckUpdate; // Should updates be checked automatically bool m_bAutoCheckUpdate; // Should updates be checked automatically
static inline bool m_bDiscordRPC; // Is the discord rich presence enabled bool m_bDiscordRPC; // Is the discord rich presence enabled
static inline bool m_bTextOnlyMode; // Hide all menu images mode bool m_bTextOnlyMode; // Hide all menu images mode
Menu() = delete;
Menu(const Menu&) = delete;
// Inits the class friend IPage;
static void Init(); MenuPage();
MenuPage(const MenuPage&);
// Displays the menu page void Draw();
static void ShowPage();
}; };
extern MenuPage& menuPage;

View File

@ -10,6 +10,8 @@
#include "custom/particle_sa.h" #include "custom/particle_sa.h"
#endif #endif
ScenePage& scenePage = ScenePage::Get();
void ScenePage::Draw() void ScenePage::Draw()
{ {
if (ImGui::BeginTabBar("Animation", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) if (ImGui::BeginTabBar("Animation", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll))

View File

@ -1,14 +1,19 @@
#pragma once #pragma once
#include "pch.h" #include "interface/ipage.h"
/* /*
Scene Player class ScenePage Class
Contains animations, cutscenes, particles, tasks etc
*/ */
class ScenePage class ScenePage : public IPage<ScenePage>
{ {
public: private:
ScenePage() = delete; friend IPage;
ScenePage(const ScenePage&) = delete; ScenePage() : IPage<ScenePage>(ePageID::Scene, "Window.ScenePage", true){}
ScenePage(const ScenePage&);
static void Draw(); public:
}; void Draw();
};
extern ScenePage& scenePage;

View File

@ -9,7 +9,7 @@
tRadarTrace* ms_RadarTrace = reinterpret_cast<tRadarTrace*>(patch::GetPointer(0x5838B0 + 2)); tRadarTrace* ms_RadarTrace = reinterpret_cast<tRadarTrace*>(patch::GetPointer(0x5838B0 + 2));
static int maxSprites = *(uint*)0x5D5870; static int maxSprites = *(uint*)0x5D5870;
void Teleport::FetchRadarSpriteData() void TeleportPage::FetchRadarSpriteData()
{ {
uint timer = CTimer::m_snTimeInMilliseconds; uint timer = CTimer::m_snTimeInMilliseconds;
@ -35,21 +35,22 @@ void Teleport::FetchRadarSpriteData()
} }
#endif #endif
bool Teleport::IsQuickTeleportActive() bool TeleportPage::IsQuickTeleportActive()
{ {
return m_bQuickTeleport; return m_bQuickTeleport;
} }
TeleportPage& teleportPage = TeleportPage::Get();
TeleportPage::TeleportPage()
void Teleport::Init() : IPage<TeleportPage>(ePageID::Teleport, "Window.TeleportPage", true)
{ {
m_bTeleportMarker = gConfig.Get("Features.TeleportMarker", false); m_bTeleportMarker = gConfig.Get("Features.TeleportMarker", false);
m_bQuickTeleport = gConfig.Get("Features.QuickTeleport", false); m_bQuickTeleport = gConfig.Get("Features.QuickTeleport", false);
m_fMapSize.x = gConfig.Get("Game.MapSizeX", 6000.0f); m_fMapSize.x = gConfig.Get("Game.MapSizeX", 6000.0f);
m_fMapSize.y = gConfig.Get("Game.MapSizeY", 6000.0f); m_fMapSize.y = gConfig.Get("Game.MapSizeY", 6000.0f);
Events::drawingEvent += [] Events::drawingEvent += [this]
{ {
if (m_bTeleportMarker && teleportMarker.Pressed()) if (m_bTeleportMarker && teleportMarker.Pressed())
{ {
@ -119,7 +120,7 @@ void Teleport::Init()
#ifdef GTASA #ifdef GTASA
template<eTeleportType Type> template<eTeleportType Type>
void Teleport::WarpPlayer(CVector pos, int interiorID) void TeleportPage::WarpPlayer(CVector pos, int interiorID)
{ {
CPlayerPed* pPlayer = FindPlayerPed(); CPlayerPed* pPlayer = FindPlayerPed();
CVehicle* pVeh = pPlayer->m_pVehicle; CVehicle* pVeh = pPlayer->m_pVehicle;
@ -192,7 +193,7 @@ void Teleport::WarpPlayer(CVector pos, int interiorID)
} }
#else #else
template<eTeleportType Type> template<eTeleportType Type>
void Teleport::WarpPlayer(CVector pos, int interiorID) void TeleportPage::WarpPlayer(CVector pos, int interiorID)
{ {
CPlayerPed* pPlayer = FindPlayerPed(); CPlayerPed* pPlayer = FindPlayerPed();
CVehicle* pVeh = pPlayer->m_pVehicle; CVehicle* pVeh = pPlayer->m_pVehicle;
@ -224,9 +225,41 @@ void Teleport::WarpPlayer(CVector pos, int interiorID)
} }
#endif #endif
void Teleport::ShowPage() void TeleportPage::LocationAddNew()
{
ImGui::InputTextWithHint(TEXT("Teleport.Location"), TEXT("Teleport.LocationHint"), m_LocBuf, INPUT_BUFFER_SIZE);
ImGui::InputTextWithHint(TEXT("Teleport.Coordinates"), "x, y, z", m_InBuf, INPUT_BUFFER_SIZE);
ImGui::Spacing();
if (ImGui::Button(TEXT("Window.AddEntry"), Widget::CalcSize()))
{
std::string key = std::string("Custom.") + m_LocBuf;
m_locData.m_pData->Set(key.c_str(), ("0, " + std::string(m_InBuf)));
#ifdef GTASA
// Clear the Radar coordinates
m_locData.m_pData->RemoveTable("Radar");
#endif
m_locData.m_pData->Save();
Util::SetMessage(TEXT("Window.AddEntryMSG"));
}
}
void TeleportPage::LocationClick(str& unk1, str& unk2, str& loc)
{
int dim = 0;
CVector pos;
if (sscanf(loc.c_str(), "%d,%f,%f,%f", &dim, &pos.x, &pos.y, &pos.z) == 4)
{
WarpPlayer<eTeleportType::Coordinate>(pos, dim);
}
else
{
Util::SetMessage(TEXT("Teleport.InvalidLocation"));
}
}
void TeleportPage::Draw()
{ {
static char locBuf[INPUT_BUFFER_SIZE], inBuf[INPUT_BUFFER_SIZE];
if (ImGui::BeginTabBar("Teleport", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) if (ImGui::BeginTabBar("Teleport", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll))
{ {
ImGui::Spacing(); ImGui::Spacing();
@ -264,19 +297,19 @@ void Teleport::ShowPage()
{ {
CVector pos = FindPlayerPed()->GetPosition(); CVector pos = FindPlayerPed()->GetPosition();
strcpy(inBuf, strcpy(m_InBuf,
(std::to_string(static_cast<int>(pos.x)) + ", " + std::to_string(static_cast<int>(pos.y)) + (std::to_string(static_cast<int>(pos.x)) + ", " + std::to_string(static_cast<int>(pos.y)) +
", " + std::to_string(static_cast<int>(pos.z))).c_str()); ", " + std::to_string(static_cast<int>(pos.z))).c_str());
} }
ImGui::InputTextWithHint(TEXT("Teleport.Coordinates"), "x, y, z", inBuf, INPUT_BUFFER_SIZE); ImGui::InputTextWithHint(TEXT("Teleport.Coordinates"), "x, y, z", m_InBuf, INPUT_BUFFER_SIZE);
ImGui::Spacing(); ImGui::Spacing();
if (ImGui::Button(TEXT("Teleport.TeleportToCoord"), Widget::CalcSize(2))) if (ImGui::Button(TEXT("Teleport.TeleportToCoord"), Widget::CalcSize(2)))
{ {
CVector pos{0, 0, 10}; CVector pos{0, 0, 10};
if (sscanf(inBuf,"%f,%f,%f", &pos.x, &pos.y, &pos.z) == 3) if (sscanf(m_InBuf,"%f,%f,%f", &pos.x, &pos.y, &pos.z) == 3)
{ {
pos.z += 1.0f; pos.z += 1.0f;
WarpPlayer(pos); WarpPlayer(pos);
@ -336,36 +369,8 @@ void Teleport::ShowPage()
FetchRadarSpriteData(); FetchRadarSpriteData();
#endif #endif
ImGui::Spacing(); ImGui::Spacing();
Widget::DataList(m_locData, Widget::DataList(m_locData, fArg3Wrapper(teleportPage.LocationClick),
[](std::string& unk1, std::string& unk2, std::string& loc){ fArgNoneWrapper(teleportPage.LocationAddNew));
int dim = 0;
CVector pos;
if (sscanf(loc.c_str(), "%d,%f,%f,%f", &dim, &pos.x, &pos.y, &pos.z) == 4)
{
WarpPlayer<eTeleportType::Coordinate>(pos, dim);
}
else
{
Util::SetMessage(TEXT("Teleport.InvalidLocation"));
}
},
[](){
ImGui::InputTextWithHint(TEXT("Teleport.Location"), TEXT("Teleport.LocationHint"), locBuf, INPUT_BUFFER_SIZE);
ImGui::InputTextWithHint(TEXT("Teleport.Coordinates"), "x, y, z", inBuf, INPUT_BUFFER_SIZE);
ImGui::Spacing();
if (ImGui::Button(TEXT("Window.AddEntry"), Widget::CalcSize()))
{
std::string key = std::string("Custom.") + locBuf;
m_locData.m_pData->Set(key.c_str(), ("0, " + std::string(inBuf)));
#ifdef GTASA
// Clear the Radar coordinates
m_locData.m_pData->RemoveTable("Radar");
#endif
m_locData.m_pData->Save();
Util::SetMessage(TEXT("Window.AddEntryMSG"));
}
});
ImGui::EndTabItem(); ImGui::EndTabItem();
} }
ImGui::EndTabBar(); ImGui::EndTabBar();

View File

@ -1,5 +1,6 @@
#pragma once #pragma once
#include "pch.h" #include "pch.h"
#include "interface/ipage.h"
enum class eTeleportType enum class eTeleportType
{ {
@ -8,43 +9,44 @@ enum class eTeleportType
Coordinate, Coordinate,
}; };
/* class TeleportPage : public IPage<TeleportPage>
Teleport Class
Contains code for the Teleport menu page
*/
class Teleport
{ {
private: private:
static inline bool m_bInsertCoord; char m_LocBuf[INPUT_BUFFER_SIZE], m_InBuf[INPUT_BUFFER_SIZE];
static inline bool m_bTeleportMarker; bool m_bInsertCoord;
static inline bool m_bQuickTeleport; bool m_bTeleportMarker;
static inline ImVec2 m_fMapSize; bool m_bQuickTeleport;
ImVec2 m_fMapSize;
#ifdef GTASA #ifdef GTASA
static inline DataStore m_SpriteData {"sprites"};
DataStore m_SpriteData {"sprites"};
/* /*
Generates radar sprite coordinates on the fly. Generates radar sprite coordinates on the fly.
Shouldn't get saved in 'teleport.json', needs to be cleared at game shutdown. Shouldn't get saved in 'teleport.json', needs to be cleared at game shutdown.
*/ */
static void FetchRadarSpriteData(); void FetchRadarSpriteData();
#endif #endif
public: public:
static inline ResourceStore m_locData{"locations", eResourceType::TYPE_TEXT}; ResourceStore m_locData{"locations", eResourceType::TYPE_TEXT};
Teleport() = delete; friend IPage;
Teleport(const Teleport&) = delete; TeleportPage();
TeleportPage(const TeleportPage&);
// Initialized the class, hooks etc. void Draw();
static void Init();
// Returns true if quick teleport feature is active
bool IsQuickTeleportActive();
// Callbacks
void LocationAddNew();
void LocationClick(str&, str&, str&);
// Warp player to position, marker, map etc // Warp player to position, marker, map etc
template<eTeleportType Type = eTeleportType::Coordinate> template<eTeleportType Type = eTeleportType::Coordinate>
static void WarpPlayer(CVector pos = CVector(0, 0, 0), int interiorID = 0); void WarpPlayer(CVector pos = CVector(0, 0, 0), int interiorID = 0);
// Returns true if quick teleport feature is active
static bool IsQuickTeleportActive();
// Draws the teleport menu page
static void ShowPage();
}; };
extern TeleportPage& teleportPage;

32
src/pages/update.cpp Normal file
View File

@ -0,0 +1,32 @@
#include "pch.h"
#include "update.h"
#include "utils/widget.h"
#include "utils/updater.h"
UpdatePage& updatePage = UpdatePage::Get();
void UpdatePage::Draw()
{
std::string ver = Updater::GetUpdateVersion();
ImGui::Dummy(ImVec2(0, 20));
Widget::TextCentered(TEXT("Menu.NewVersion"));
Widget::TextCentered(std::format("{}: {}", TEXT("Menu.CurrentVersion"), MENU_VERSION));
Widget::TextCentered(TEXT("Menu.LatestVersion") + ver);
ImGui::Dummy(ImVec2(0, 10));
ImGui::TextWrapped(TEXT("Menu.UpdaterInfo1"));
ImGui::Dummy(ImVec2(0, 10));
ImGui::TextWrapped(TEXT("Menu.UpdaterInfo2"));
ImGui::Dummy(ImVec2(0, 5));
if (ImGui::Button(TEXT("Menu.DiscordServer"), ImVec2(Widget::CalcSize(2))))
{
OPEN_LINK(DISCORD_INVITE);
}
ImGui::SameLine();
if (ImGui::Button(TEXT("Menu.DownloadPage"), Widget::CalcSize(2)))
{
OPEN_LINK(std::string("https://github.com/user-grinch/Cheat-Menu/releases/tag/" + ver).c_str());
}
}

16
src/pages/update.h Normal file
View File

@ -0,0 +1,16 @@
#pragma once
#include "interface/ipage.h"
// This page shows up when an update is found
class UpdatePage : public IPage<UpdatePage>
{
private:
friend IPage;
UpdatePage() : IPage<UpdatePage>(ePageID::Update, "Update", false){}
UpdatePage(const UpdatePage&);
public:
void Draw();
};
extern UpdatePage& updatePage;

View File

@ -1238,7 +1238,7 @@ void Vehicle::ShowPage()
if (ImGui::BeginTabItem(TEXT("Teleport.Location"))) if (ImGui::BeginTabItem(TEXT("Teleport.Location")))
{ {
ImGui::Spacing(); ImGui::Spacing();
Widget::DataList(Teleport::m_locData, Widget::DataList(teleportPage.m_locData,
[](std::string& rootkey, std::string& bLocName, std::string& loc) [](std::string& rootkey, std::string& bLocName, std::string& loc)
{ {
CVehicle* pVeh = BY_GAME(FindPlayerVehicle(-1, false), FindPlayerVehicle(), FindPlayerVehicle()); CVehicle* pVeh = BY_GAME(FindPlayerVehicle(-1, false), FindPlayerVehicle(), FindPlayerVehicle());

View File

@ -979,34 +979,34 @@ void Visual::ShowPage()
int hour = CClock::ms_nGameClockHours; int hour = CClock::ms_nGameClockHours;
int minute = CClock::ms_nGameClockMinutes; int minute = CClock::ms_nGameClockMinutes;
if (Game::m_bSyncTime) if (gamePage.m_bSyncTime)
{ {
ImGui::BeginDisabled(Game::m_bSyncTime); ImGui::BeginDisabled(gamePage.m_bSyncTime);
} }
if (ImGui::InputInt(TEXT("Visual.Hour"), &hour) & !Game::m_bSyncTime) if (ImGui::InputInt(TEXT("Visual.Hour"), &hour) & !gamePage.m_bSyncTime)
{ {
if (hour < 0) hour = 23; if (hour < 0) hour = 23;
if (hour > 23) hour = 0; if (hour > 23) hour = 0;
CClock::ms_nGameClockHours = hour; CClock::ms_nGameClockHours = hour;
} }
if (ImGui::InputInt(TEXT("Visual.Minute"), &minute) & !Game::m_bSyncTime) if (ImGui::InputInt(TEXT("Visual.Minute"), &minute) & !gamePage.m_bSyncTime)
{ {
if (minute < 0) minute = 59; if (minute < 0) minute = 59;
if (minute > 59) minute = 0; if (minute > 59) minute = 0;
CClock::ms_nGameClockMinutes = minute; CClock::ms_nGameClockMinutes = minute;
} }
if (Game::m_bSyncTime) if (gamePage.m_bSyncTime)
{ {
ImGui::EndDisabled(); ImGui::EndDisabled();
Widget::Tooltip(TEXT("Visual.SyncTimeEnabled")); Widget::Tooltip(TEXT("Visual.SyncTimeEnabled"));
} }
if (ImGui::Checkbox(TEXT("Visual.FreezeGameTime"), &Game::m_bFreezeTime)) if (ImGui::Checkbox(TEXT("Visual.FreezeGameTime"), &gamePage.m_bFreezeTime))
{ {
if (Game::m_bFreezeTime) if (gamePage.m_bFreezeTime)
{ {
patch::SetRaw(BY_GAME(0x52CF10, 0x487010, 0x473460), (char *)"\xEB\xEF", 2); patch::SetRaw(BY_GAME(0x52CF10, 0x487010, 0x473460), (char *)"\xEB\xEF", 2);
} }

35
src/pages/welcome.cpp Normal file
View File

@ -0,0 +1,35 @@
#include "pch.h"
#include "welcome.h"
#include "utils/widget.h"
WelcomePage& welcomePage = WelcomePage::Get();
void WelcomePage::Draw()
{
ImGui::NewLine();
Widget::TextCentered(TEXT("Menu.WelcomeMSG"));
Widget::TextCentered(std::format("{}: Grinch_",TEXT("Menu.Author")));
ImGui::NewLine();
ImGui::TextWrapped(TEXT("Menu.EnsureLatest"));
if (ImGui::Button(TEXT("Menu.DiscordServer"), ImVec2(Widget::CalcSize(3))))
{
OPEN_LINK(DISCORD_INVITE);
}
ImGui::SameLine();
if (ImGui::Button(TEXT("Menu.GitHubRepo"), ImVec2(Widget::CalcSize(3))))
{
OPEN_LINK(GITHUB_LINK);
}
ImGui::SameLine();
if (ImGui::Button(TEXT("Menu.Patreon"), ImVec2(Widget::CalcSize(3))))
{
OPEN_LINK(PATREON_LINK);
}
ImGui::NewLine();
ImGui::TextWrapped(TEXT("Menu.BugDisclaimer"));
ImGui::Dummy(ImVec2(0, 20));
Widget::TextCentered(TEXT("Menu.PatreonText"));
Widget::TextCentered(TEXT("Menu.CopyrightDisclaimer"));
}

19
src/pages/welcome.h Normal file
View File

@ -0,0 +1,19 @@
#pragma once
#include "interface/ipage.h"
// The default page for new install
class WelcomePage : public IPage<WelcomePage>
{
private:
friend IPage;
WelcomePage() : IPage<WelcomePage>(ePageID::Welcome, "Welcome", false)
{
PageHandler::SetCurrentPage(this);
}
WelcomePage(const WelcomePage&);
public:
void Draw();
};
extern WelcomePage& welcomePage;

View File

@ -71,7 +71,7 @@ void FontMgr::ReloadAll()
m_bFontReloadRequired = false; m_bFontReloadRequired = false;
} }
void FontMgr::Process() void FontMgr::DrawPages()
{ {
if (curState == eStates::Idle) if (curState == eStates::Idle)
{ {

View File

@ -45,7 +45,7 @@ public:
static ImFont* Load(const char* fontID, const char* path = 0, float fontMul = 1.0f); static ImFont* Load(const char* fontID, const char* path = 0, float fontMul = 1.0f);
// Handles font downloading // Handles font downloading
static void Process(); static void DrawPages();
// Reloads all the fonts // Reloads all the fonts
static void ReloadAll(); static void ReloadAll();

View File

@ -310,7 +310,7 @@ void Overlay::ProcessCommands(std::string&& str)
ss >> temp; ss >> temp;
pos.z = std::stof(temp); pos.z = std::stof(temp);
Teleport::WarpPlayer(pos); teleportPage.WarpPlayer(pos);
} }
catch (...) catch (...)
{ {

View File

@ -66,9 +66,9 @@ void RPC::Init()
} }
} }
void RPC::Process() void RPC::DrawPages()
{ {
if (!(Menu::m_bDiscordRPC && bInit)) if (!(menuPage.m_bDiscordRPC && bInit))
{ {
return; return;
} }

View File

@ -36,6 +36,6 @@ public:
RPC(RPC&) = delete; RPC(RPC&) = delete;
static void Init(); static void Init();
static void Process(); static void DrawPages();
static void Shutdown(); static void Shutdown();
}; };

View File

@ -24,7 +24,7 @@ void Updater::CheckUpdate()
} }
} }
void Updater::Process() void Updater::DrawPages()
{ {
if (Updater::curState != States::CHECKING) if (Updater::curState != States::CHECKING)
{ {

View File

@ -32,7 +32,7 @@ public:
static bool IsUpdateAvailable(); static bool IsUpdateAvailable();
// Needs to run in it's own thread to prevent the game from freezing // Needs to run in it's own thread to prevent the game from freezing
static void Process(); static void DrawPages();
// Resets updater state to IDLE // Resets updater state to IDLE
static void ResetUpdaterState(); static void ResetUpdaterState();

View File

@ -323,7 +323,7 @@ void Widget::ImageList(ResourceStore &store, fArg1_t clickFunc, fRtnArg1_t getNa
m_ImageSize.x = ImGui::GetWindowContentRegionWidth() - style.ItemSpacing.x * (imagesInRow-1); m_ImageSize.x = ImGui::GetWindowContentRegionWidth() - style.ItemSpacing.x * (imagesInRow-1);
m_ImageSize.x /= imagesInRow; m_ImageSize.x /= imagesInRow;
bool showImages = !Menu::m_bTextOnlyMode; bool showImages = !menuPage.m_bTextOnlyMode;
if (gRenderer == Render_DirectX11) if (gRenderer == Render_DirectX11)
{ {
showImages = false; showImages = false;