From fc0e8ac739b3d57be410de1de2c30e4b448336d2 Mon Sep 17 00:00:00 2001 From: Grinch_ Date: Wed, 10 Aug 2022 10:40:38 +0600 Subject: [PATCH] add patreon links --- .vscode/tasks.json | 70 ++++++++++++++++++------- FUNDING.yml | 13 +++++ resource/common/locale/English.toml | 4 +- src/cheatmenu.cpp | 7 ++- src/custom/cutscene_sa.cpp | 78 +++++++++++++++++++++++++++ src/custom/cutscene_sa.h | 35 +++++++++++++ src/pages/animation.cpp | 81 ++--------------------------- src/pages/animation.h | 28 ---------- src/pages/menu.cpp | 18 +++++-- src/pch.h | 10 ++-- 10 files changed, 206 insertions(+), 138 deletions(-) create mode 100644 FUNDING.yml create mode 100644 src/custom/cutscene_sa.cpp create mode 100644 src/custom/cutscene_sa.h diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 6496d05..c201451 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -24,11 +24,12 @@ "shell": { "executable": "cmd.exe", "args": [ - "/d", "/c" + "/d", + "/c" ] } } - }, + } }, { "label": "Build ReleaseSA", @@ -51,11 +52,12 @@ "shell": { "executable": "cmd.exe", "args": [ - "/d", "/c" + "/d", + "/c" ] } } - }, + } }, { "label": "Build DebugVC", @@ -78,11 +80,12 @@ "shell": { "executable": "cmd.exe", "args": [ - "/d", "/c" + "/d", + "/c" ] } } - }, + } }, { "label": "Build ReleaseVC", @@ -105,11 +108,12 @@ "shell": { "executable": "cmd.exe", "args": [ - "/d", "/c" + "/d", + "/c" ] } } - }, + } }, { "label": "Build DebugIII", @@ -132,11 +136,12 @@ "shell": { "executable": "cmd.exe", "args": [ - "/d", "/c" + "/d", + "/c" ] } } - }, + } }, { "label": "Build ReleaseIII", @@ -159,11 +164,12 @@ "shell": { "executable": "cmd.exe", "args": [ - "/d", "/c" + "/d", + "/c" ] } } - }, + } }, { "label": "Build DebugAll", @@ -186,11 +192,12 @@ "shell": { "executable": "cmd.exe", "args": [ - "/d", "/c" + "/d", + "/c" ] } } - }, + } }, { "label": "Build ReleaseAll", @@ -213,11 +220,12 @@ "shell": { "executable": "cmd.exe", "args": [ - "/d", "/c" + "/d", + "/c" ] } } - }, + } }, { "label": "Package all", @@ -240,11 +248,12 @@ "shell": { "executable": "cmd.exe", "args": [ - "/d", "/c" + "/d", + "/c" ] } } - }, + } }, { "label": "Format Code", @@ -267,11 +276,32 @@ "shell": { "executable": "cmd.exe", "args": [ - "/d", "/c" + "/d", + "/c" ] } } - }, + } }, + { + "type": "cppbuild", + "label": "C/C++: cl.exe build active file", + "command": "cl.exe", + "args": [ + "/Zi", + "/EHsc", + "/nologo", + "/Fe${fileDirname}\\${fileBasenameNoExtension}.exe", + "${file}" + ], + "options": { + "cwd": "${fileDirname}" + }, + "problemMatcher": [ + "$msCompile" + ], + "group": "build", + "detail": "compiler: cl.exe" + } ] } \ No newline at end of file diff --git a/FUNDING.yml b/FUNDING.yml new file mode 100644 index 0000000..0aa51c4 --- /dev/null +++ b/FUNDING.yml @@ -0,0 +1,13 @@ +# These are supported funding model platforms + +github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: grinch_ +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/resource/common/locale/English.toml b/resource/common/locale/English.toml index c9cbf8c..5abfab3 100644 --- a/resource/common/locale/English.toml +++ b/resource/common/locale/English.toml @@ -168,7 +168,7 @@ FreecamBackwardKey = "Freecam backward" FreecamForwardKey = "Freecam forward" FreecamLeftKey = "Freecam left" FreecamRightKey = "Freecam right" -GitHubRepo = "GitHub repo" +GitHubRepo = "GitHub" GodModeKey = "Toggle god mode" Hotkeys = "Hotkeys" InvalidComamnd = "Invalid Command" @@ -185,6 +185,8 @@ OpenCMDKey = "Open/ close command window" OpenCMDUsing = "Open or close command window using %s" OpenMenuKey = "Open/ close cheat menu" Overlay = "Overlay" +Patreon = "Patreon" +PatreonText = "If you like my work, consider supporting :)" Position = "Position" Remove = "Remove" Favourites = "Add to favourites" diff --git a/src/cheatmenu.cpp b/src/cheatmenu.cpp index 121e975..47f7454 100644 --- a/src/cheatmenu.cpp +++ b/src/cheatmenu.cpp @@ -329,7 +329,6 @@ void CheatMenu::ShowWelcomePage() ImGui::NewLine(); ImGui::TextWrapped(TEXT("Menu.EnsureLatest")); - ImGui::NewLine(); if (ImGui::Button(TEXT("Menu.DiscordServer"), ImVec2(Widget::CalcSize(2)))) { OPEN_LINK(DISCORD_INVITE); @@ -341,6 +340,12 @@ void CheatMenu::ShowWelcomePage() } 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")); } diff --git a/src/custom/cutscene_sa.cpp b/src/custom/cutscene_sa.cpp new file mode 100644 index 0000000..8f7bee0 --- /dev/null +++ b/src/custom/cutscene_sa.cpp @@ -0,0 +1,78 @@ +#include "pch.h" +#include "cutscene_sa.h" + +CutsceneMgr& Cutscene = *CutsceneMgr::Get(); +CutsceneMgr::CutsceneMgr() +{ + static CdeclEvent , PRIORITY_AFTER, ArgPickNone, void()> skipCutsceneEvent; + skipCutsceneEvent += [this]() + { + Stop(); + }; +} + +void CutsceneMgr::Play(std::string& rootKey, std::string& cutsceneId, std::string& interior) +{ + if (CCutsceneMgr::ms_running) + { + Util::SetMessage(TEXT("Animation.CutsceneRunning")); + return; + } + + CPlayerPed* pPlayer = FindPlayerPed(); + if (pPlayer) + { + m_pLastVeh = pPlayer->m_nPedFlags.bInVehicle ? pPlayer->m_pVehicle : nullptr; + m_nVehSeat = -1; + + if (m_pLastVeh && m_pLastVeh->m_pDriver != pPlayer) + { + for (size_t i = 0; i != 8; ++i) + { + if (m_pLastVeh->m_apPassengers[i] == pPlayer) + { + m_nVehSeat = i; + break; + } + } + } + CCutsceneMgr::LoadCutsceneData(cutsceneId.c_str()); + CCutsceneMgr::Update(); + + m_nInterior = pPlayer->m_nAreaCode; + pPlayer->m_nAreaCode = std::stoi(interior); + Command(pPlayer->m_nAreaCode); + CutsceneMgr::m_bRunning = true; + CCutsceneMgr::StartCutscene(); + } +} + +void CutsceneMgr::Stop() +{ + if (CutsceneMgr::m_bRunning) + { + CPlayerPed *pPlayer = FindPlayerPed(); + int hPlayer = CPools::GetPedRef(pPlayer); + + CCutsceneMgr::DeleteCutsceneData(); + CutsceneMgr::m_bRunning = false; + pPlayer->m_nAreaCode = CutsceneMgr::m_nInterior; + CutsceneMgr::m_nInterior = 0; + Command(pPlayer->m_nAreaCode); + + // handle vehicle + if (CutsceneMgr::m_pLastVeh) + { + int hVeh = CPools::GetVehicleRef(CutsceneMgr::m_pLastVeh); + if (CutsceneMgr::m_nVehSeat == -1) + { + Command(hPlayer, hVeh); + } + else + { + Command(hPlayer, hVeh, CutsceneMgr::m_nVehSeat); + } + } + TheCamera.Fade(0, 1); + } +} \ No newline at end of file diff --git a/src/custom/cutscene_sa.h b/src/custom/cutscene_sa.h new file mode 100644 index 0000000..09aeda2 --- /dev/null +++ b/src/custom/cutscene_sa.h @@ -0,0 +1,35 @@ +#pragma once +#include "utils/resourcestore.h" +#include "interface/icheat.hpp" + +extern class CVehicle; + +/* + Cutscene Player Class for SA + Plays mission cutscenes +*/ +class CutsceneMgr : public ICheat +{ +private: + bool m_bRunning; // is cutscene currently running + + // backup data + int m_nInterior; // interior player was in + CVehicle *m_pLastVeh; // vehicle player was in + int m_nVehSeat; // seat id of player vehicle + + friend class ICheat; + CutsceneMgr(); + CutsceneMgr(const CutsceneMgr&); + +public: + ResourceStore m_Data{ "cutscenes", eResourceType::TYPE_TEXT }; // names + + // Plays a cutscene + void Play(std::string& cat, std::string& key, std::string& val); + + // Stops a running cutscene + void Stop(); +}; + +extern CutsceneMgr& Cutscene; \ No newline at end of file diff --git a/src/pages/animation.cpp b/src/pages/animation.cpp index 21f8c92..38aae33 100644 --- a/src/pages/animation.cpp +++ b/src/pages/animation.cpp @@ -19,81 +19,7 @@ #ifdef GTASA #include "utils/overlay.h" - -void Cutscene::Init() -{ - static CdeclEvent , PRIORITY_AFTER, ArgPickNone, void()> skipCutsceneEvent; - skipCutsceneEvent += []() - { - Stop(); - }; -} - -void Cutscene::Play(std::string& rootKey, std::string& cutsceneId, std::string& interior) -{ - if (CCutsceneMgr::ms_running) - { - Util::SetMessage(TEXT("Animation.CutsceneRunning")); - return; - } - - CPlayerPed* pPlayer = FindPlayerPed(); - if (pPlayer) - { - m_pLastVeh = pPlayer->m_nPedFlags.bInVehicle ? pPlayer->m_pVehicle : nullptr; - m_nVehSeat = -1; - - if (m_pLastVeh && m_pLastVeh->m_pDriver != pPlayer) - { - for (size_t i = 0; i != 8; ++i) - { - if (m_pLastVeh->m_apPassengers[i] == pPlayer) - { - m_nVehSeat = i; - break; - } - } - } - CCutsceneMgr::LoadCutsceneData(cutsceneId.c_str()); - CCutsceneMgr::Update(); - - m_nInterior = pPlayer->m_nAreaCode; - pPlayer->m_nAreaCode = std::stoi(interior); - Command(pPlayer->m_nAreaCode); - Cutscene::m_bRunning = true; - CCutsceneMgr::StartCutscene(); - } -} - -void Cutscene::Stop() -{ - if (Cutscene::m_bRunning) - { - CPlayerPed *pPlayer = FindPlayerPed(); - int hPlayer = CPools::GetPedRef(pPlayer); - - CCutsceneMgr::DeleteCutsceneData(); - Cutscene::m_bRunning = false; - pPlayer->m_nAreaCode = Cutscene::m_nInterior; - Cutscene::m_nInterior = 0; - Command(pPlayer->m_nAreaCode); - - // handle vehicle - if (Cutscene::m_pLastVeh) - { - int hVeh = CPools::GetVehicleRef(Cutscene::m_pLastVeh); - if (Cutscene::m_nVehSeat == -1) - { - Command(hPlayer, hVeh); - } - else - { - Command(hPlayer, hVeh, Cutscene::m_nVehSeat); - } - } - TheCamera.Fade(0, 1); - } -} +#include "custom/cutscene_sa.h" void Particle::Play(std::string& cat, std::string& name, std::string& particle) { @@ -273,7 +199,6 @@ void Animation::Play(std::string& cat, std::string& anim, std::string& ifp) void Animation::Init() { #ifdef GTASA - Cutscene::Init(); Events::processScriptsEvent += [] { CPlayerPed* pPlayer = FindPlayerPed(); @@ -434,14 +359,14 @@ void Animation::ShowPage() ImGui::Spacing(); if (ImGui::Button(TEXT("Animation.StopCutscene"), Widget::CalcSize())) { - Cutscene::Stop(); + Cutscene.Stop(); } ImGui::Spacing(); if (ImGui::BeginChild("Cutscene Child")) { ImGui::Spacing(); - Widget::DataList(Cutscene::m_Data, Cutscene::Play); + Widget::DataList(Cutscene.m_Data, [](std::string& a, std::string& b, std::string& c){Cutscene.Play(a, b, c);}); ImGui::EndChild(); } ImGui::EndTabItem(); diff --git a/src/pages/animation.h b/src/pages/animation.h index fe3961a..29c0fd5 100644 --- a/src/pages/animation.h +++ b/src/pages/animation.h @@ -2,35 +2,7 @@ #include "pch.h" #ifdef GTASA -/* - Cutscene Player Class for SA - Plays mission cutscenes -*/ -class Cutscene -{ -private: - static inline bool m_bRunning; // is cutscene currently running - // backup data - static inline int m_nInterior; // interior player was in - static inline CVehicle *m_pLastVeh; // vehicle player was in - static inline int m_nVehSeat; // seat id of player vehicle - -public: - static inline ResourceStore m_Data{ "cutscenes", eResourceType::TYPE_TEXT }; // names - - Cutscene() = delete; - Cutscene(const Cutscene&) = delete; - - // Initializes hooks, vars etc. - static void Init(); - - // Plays a cutscene - static void Play(std::string& cat, std::string& key, std::string& val); - - // Stops a running cutscene - static void Stop(); -}; /* Particle Player Class for SA diff --git a/src/pages/menu.cpp b/src/pages/menu.cpp index af7a19e..d29bea0 100644 --- a/src/pages/menu.cpp +++ b/src/pages/menu.cpp @@ -285,24 +285,29 @@ void Menu::ShowPage() { ImGui::Spacing(); - if (ImGui::Button(TEXT("Menu.CheckUpdate"), ImVec2(Widget::CalcSize(3)))) + if (ImGui::Button(TEXT("Menu.CheckUpdate"), ImVec2(Widget::CalcSize(2)))) { Updater::CheckUpdate(); } ImGui::SameLine(); - if (ImGui::Button(TEXT("Menu.DiscordServer"), ImVec2(Widget::CalcSize(3)))) + 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(3)))) + if (ImGui::Button(TEXT("Menu.GitHubRepo"), ImVec2(Widget::CalcSize(2)))) { OPEN_LINK(GITHUB_LINK); } + + ImGui::SameLine(); + + if (ImGui::Button(TEXT("Menu.Patreon"), ImVec2(Widget::CalcSize(2)))) + { + OPEN_LINK("https://www.patreon.com/grinch_"); + } ImGui::Spacing(); if (ImGui::BeginChild("AboutChild")) @@ -320,6 +325,9 @@ void Menu::ShowPage() ImGui::Dummy(ImVec2(0, 10)); ImGui::TextWrapped(TEXT("Menu.BugDisclaimer")); + ImGui::Spacing(); + Widget::TextCentered(TEXT("Menu.PatreonText")); + ImGui::Dummy(ImVec2(0, 10)); Widget::TextCentered(TEXT("Menu.CopyrightDisclaimer")); diff --git a/src/pch.h b/src/pch.h index a7a711b..9e03d6e 100644 --- a/src/pch.h +++ b/src/pch.h @@ -6,7 +6,6 @@ #include #include #include -#include #include #include #include @@ -78,11 +77,12 @@ enum eRenderer extern eRenderer gRenderer; extern DataStore gConfig; -typedef void(*ArgCallback3)(std::string&, std::string&, std::string&); -typedef void(*ArgCallback)(std::string&); +typedef std::string str; +typedef void(*ArgCallback3)(str&, str&, str&); +typedef void(*ArgCallback)(str&); typedef void(*ArgCallbackNone)(); -typedef std::string(*ArgCallbackRtn)(std::string&); -typedef bool(*ArgCallbackRtnBool)(std::string&); +typedef std::string(*ArgCallbackRtn)(str&); +typedef bool(*ArgCallbackRtnBool)(str&); #ifdef GTASA extern const char* taskNames[1802];