diff --git a/src/dllmain.cpp b/src/dllmain.cpp index cd910b1..2f15784 100644 --- a/src/dllmain.cpp +++ b/src/dllmain.cpp @@ -70,19 +70,29 @@ void MenuThread(void* param) } #endif - Log::Print("Stating " MENU_TITLE "\nAuthor: Grinch_\nDiscord: " DISCORD_INVITE "\nMore Info: " GITHUB_LINK "\n"); + Log::Print("Starting " MENU_TITLE " (" BUILD_NUMBER ")\nAuthor: Grinch_\nDiscord: " + DISCORD_INVITE "\nMore Info: " GITHUB_LINK); + // date time + SYSTEMTIME st; + GetSystemTime(&st); + Log::Print("Date: {}-{}-{} Time: {}:{}\n", st.wYear, st.wMonth, st.wDay, + st.wHour, st.wMinute); CheatMenu::Init(); // Checking for updates once a day - SYSTEMTIME st; - GetSystemTime(&st); if (gConfig.Get("Menu.LastUpdateChecked", 0) != st.wDay) { Updater::CheckUpdate(); Updater::IncrementDailyUsageCounter(); gConfig.Set("Menu.LastUpdateChecked", st.wDay); } + + if (Updater::IsUpdateAvailable()) + { + Updater::GetUpdateVersion(); + Log::Print("New update available: %s", Updater::GetUpdateVersion().c_str()); + } while (true) { diff --git a/src/game.cpp b/src/game.cpp index e4fd32a..afa364a 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -471,7 +471,7 @@ void Game::ShowPage() #ifdef GTASA if (Widget::Checkbox(TEXT("Game.ForbiddenWantedLevel"), &m_bForbiddenArea, TEXT("Game.ForbiddenWantedLevelText"))) { - patch::Set(0x441770, m_bForbiddenArea ? 0x83 : 0xC3, false); + patch::Set(0x441770, m_bForbiddenArea ? 0x83 : 0xC3); } Widget::CheckboxAddr(TEXT("Game.FreePNS"), 0x96C009); #endif diff --git a/src/ped.cpp b/src/ped.cpp index a4024c2..5fb6169 100644 --- a/src/ped.cpp +++ b/src/ped.cpp @@ -305,7 +305,7 @@ void Ped::ShowPage() { ImGui::Spacing(); #ifdef GTASA - Widget::ImageList(m_PedData, SpawnPed, nullptr, + Widget::ImageList(m_PedData, SpawnPed, [](std::string& str) { return m_PedData.m_pData->Get(str.c_str(), "Unknown"); @@ -356,7 +356,6 @@ void Ped::ShowPage() Spawner::m_nWeaponId = std::stoi(str); weaponName = Weapon::m_WeaponData.m_pData->Get(str.c_str(), "Unknown"); }, - nullptr, [](std::string& str) { return Weapon::m_WeaponData.m_pData->Get(str.c_str(), "Unknown"); diff --git a/src/player.cpp b/src/player.cpp index 34a51f3..b86e247 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -778,7 +778,7 @@ void Player::ShowPage() { if (pPlayer->m_nModelIndex == 0) { - Widget::ImageList(m_ClothData, ChangePlayerCloth, nullptr, [](std::string& str) + Widget::ImageList(m_ClothData, ChangePlayerCloth, [](std::string& str) { std::stringstream ss(str); std::string temp; @@ -787,7 +787,7 @@ void Player::ShowPage() getline(ss, temp, '$'); return temp; - });// nullptr, clothNameList, sizeof(clothNameList) / sizeof(const char*)); + }); } else { @@ -841,7 +841,7 @@ void Player::ShowPage() } if (ImGui::BeginTabItem(TEXT("Player.PedSkinsTab"))) { - Widget::ImageList(Ped::m_PedData, ChangePlayerModel, nullptr, + Widget::ImageList(Ped::m_PedData, ChangePlayerModel, [](std::string& str) { return Ped::m_PedData.m_pData->Get(str.c_str(), "Unknown"); diff --git a/src/vehicle.cpp b/src/vehicle.cpp index e102965..91d0be4 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -1061,8 +1061,8 @@ void Vehicle::ShowPage() ImGui::SetNextItemWidth(width); ImGui::InputTextWithHint("##LicenseText", TEXT("Vehicle.PlateText"), Spawner::m_nLicenseText, 9); - Widget::ImageList(Spawner::m_VehData, SpawnVehicle, nullptr, - [](std::string& str) + Widget::ImageList(Spawner::m_VehData, SpawnVehicle, + [](std::string& str) { return GetNameFromModel(std::stoi(str)); }); @@ -1274,7 +1274,6 @@ void Vehicle::ShowPage() Paint::SetNodeTexture(FindPlayerPed()->m_pVehicle, PaintData::m_Selected, str, PaintData::m_bMatFilter); }, - nullptr, [](std::string& str) { return str; @@ -1291,10 +1290,10 @@ void Vehicle::ShowPage() { AddComponent(str); }, - [](std::string& str) - { - RemoveComponent(str); - }, + // [](std::string& str) + // { + // RemoveComponent(str); + // }, [](std::string& str) { return str; diff --git a/src/vehicle.h b/src/vehicle.h index 6521596..0305434 100644 --- a/src/vehicle.h +++ b/src/vehicle.h @@ -39,13 +39,13 @@ private: static inline bool m_bApplyOnTraffic; static inline uint m_bTrafficTimer; }; - static inline ResourceStore m_TuneData { "components", eResourceType::TYPE_IMAGE, ImVec2(100, 80) }; + static inline ResourceStore m_TuneData { "components", eResourceType::TYPE_IMAGE_TEXT, ImVec2(100, 80) }; #endif struct Spawner { #ifdef GTASA - static inline ResourceStore m_VehData { "vehicles", eResourceType::TYPE_IMAGE, ImVec2(100, 75)}; + static inline ResourceStore m_VehData { "vehicles", eResourceType::TYPE_IMAGE_TEXT, ImVec2(100, 75)}; #else static inline ResourceStore m_VehData {"vehicles", eResourceType::TYPE_TEXT}; #endif diff --git a/src/weapon.cpp b/src/weapon.cpp index 56a5695..9c6994b 100644 --- a/src/weapon.cpp +++ b/src/weapon.cpp @@ -347,7 +347,7 @@ void Weapon::ShowPage() m_nAmmoCount = (m_nAmmoCount > 99999) ? 99999 : m_nAmmoCount; } #ifdef GTASA - Widget::ImageList(m_WeaponData, GiveWeaponToPlayer, nullptr, + Widget::ImageList(m_WeaponData, GiveWeaponToPlayer, [](std::string& str) { return m_WeaponData.m_pData->Get(str.c_str(), "Unknown"); @@ -370,16 +370,14 @@ void Weapon::ShowPage() "Ballas\0Grove street families\0Los santos vagos\0San fierro rifa\0Da nang boys\0" "Mafia\0Mountain cloud triad\0Varrio los aztecas\0Gang9\0Gang10\0" }; - std::string str = std::format("{}\0{}\0{}\0", TEXT("Weapon.Weapon1"), TEXT("Weapon.Weapon2"), - TEXT("Weapon.Weapon3")); ImGui::Combo(TEXT("Weapon.SelectGang"), &m_nSelectedGang, gangList); - ImGui::Combo(TEXT("Ped.SelectWeapon"), &m_nSelectedWeapon, str.c_str()); + ImGui::Combo(TEXT("Ped.SelectWeapon"), &m_nSelectedWeapon, "Weapon 1\0Weapon 2\0Weapon 3\0"); ImGui::Spacing(); std::string key = std::to_string(m_nGangWeaponList[m_nSelectedGang][m_nSelectedWeapon]); ImGui::Text(TEXT("Weapon.CurrentWeapon"), m_WeaponData.m_pData->Get(key.c_str(), "Unknown").c_str()); ImGui::Spacing(); - Widget::ImageList(m_WeaponData, SetGangWeapon, nullptr, + Widget::ImageList(m_WeaponData, SetGangWeapon, [](std::string& str) { return m_WeaponData.m_pData->Get(str.c_str(), "Unknown"); diff --git a/src/widget.cpp b/src/widget.cpp index e403f83..9c8f0ba 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -249,8 +249,7 @@ static bool RoundedImageButton(ImTextureID user_texture_id, ImVec2& size, const return ImGui::IsItemClicked(0); } -void Widget::ImageList(ResourceStore &store, ArgCallback leftClickFunc, ArgCallback rightClickFunc, - ArgCallbackRtn getNameFunc, ArgCallbackRtnBool verifyFunc) +void Widget::ImageList(ResourceStore &store, ArgCallback clickFunc, ArgCallbackRtn getNameFunc, ArgCallbackRtnBool verifyFunc) { ImGuiStyle& style = ImGui::GetStyle(); /* @@ -280,14 +279,6 @@ void Widget::ImageList(ResourceStore &store, ArgCallback leftClickFunc, ArgCallb contextMenu.func = nullptr; } - ImGui::PushItemWidth((ImGui::GetWindowContentRegionWidth() - style.ItemSpacing.x)/2); - Widget::ListBox("##Categories", store.m_Categories, store.m_Selected); - ImGui::SameLine(); - Filter("##Filter", store.m_Filter, "Search"); - - ImGui::Spacing(); - - ImGui::BeginChild("DrawImages"); if (showImages) { ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(3, 3)); @@ -297,80 +288,152 @@ void Widget::ImageList(ResourceStore &store, ArgCallback leftClickFunc, ArgCallb } // Draw images here - for (uint i = 0; i < store.m_ImagesList.size(); ++i) + if (ImGui::BeginTabBar("MYTABS")) { - std::string text = store.m_ImagesList[i]->m_FileName; - std::string modelName = getNameFunc(text); - - if (store.m_Filter.PassFilter(modelName.c_str()) - && (store.m_ImagesList[i]->m_CategoryName == store.m_Selected || store.m_Selected == "All") - && (verifyFunc == nullptr || verifyFunc(text)) - ) + if (ImGui::BeginTabItem(TEXT("Window.Search"))) { - /* - Couldn't figure out how to laod images for Dx11 - Using texts for now - */ - if (showImages) - { - if (RoundedImageButton(store.m_ImagesList[i]->m_pTexture, m_ImageSize, modelName.c_str())) - { - leftClickFunc(text); - } - - } - else - { - if (ImGui::MenuItem(modelName.c_str())) - { - leftClickFunc(text); - } - } + ImGui::Spacing(); + ImGui::PushItemWidth((ImGui::GetWindowContentRegionWidth() - style.ItemSpacing.x)/2); + Widget::ListBox("##Categories", store.m_Categories, store.m_Selected); + ImGui::SameLine(); + Filter("##Filter", store.m_Filter, "Search"); + ImGui::PopItemWidth(); + ImGui::Spacing(); + ImGui::BeginChild("DrawImages"); - // Right click popup - if (ImGui::IsItemClicked(1) && rightClickFunc != nullptr) + for (uint i = 0; i < store.m_ImagesList.size(); ++i) { - contextMenu.func = rightClickFunc; - contextMenu.val = modelName; - } + std::string text = store.m_ImagesList[i]->m_FileName; + std::string modelName = getNameFunc(text); - if (showImages) - { - if (imageCount % imagesInRow != 0) + if (store.m_Filter.PassFilter(modelName.c_str()) + && (store.m_ImagesList[i]->m_CategoryName == store.m_Selected || store.m_Selected == "All") + && (verifyFunc == nullptr || verifyFunc(text)) + ) { - ImGui::SameLine(0.0, style.ItemInnerSpacing.x); + /* + Couldn't figure out how to laod images for Dx11 + Using texts for now + */ + if (showImages) + { + if (RoundedImageButton(store.m_ImagesList[i]->m_pTexture, m_ImageSize, modelName.c_str())) + { + clickFunc(text); + } + + } + else + { + if (ImGui::MenuItem(modelName.c_str())) + { + clickFunc(text); + } + } + + // Right click popup + if (ImGui::IsItemClicked(1)) + { + contextMenu.func = (void*)1; + contextMenu.val = text; + contextMenu.key = std::format("{} ({})", modelName, text); + } + + if (showImages) + { + if (imageCount % imagesInRow != 0) + { + ImGui::SameLine(0.0, style.ItemInnerSpacing.x); + } + } + imageCount++; } } - imageCount++; + if (contextMenu.func != nullptr) + { + if (ImGui::BeginPopupContextWindow()) + { + ImGui::Text(contextMenu.key.c_str()); + ImGui::Separator(); + if (ImGui::MenuItem(TEXT("Menu.Favourites"))) + { + store.m_pData->Set(std::format("Favourites.{}", contextMenu.key).c_str(), contextMenu.val); + store.m_pData->Save(); + SetHelpMessage(TEXT("Menu.FavouritesText")); + } + if (ImGui::MenuItem(TEXT("Menu.Close"))) + { + contextMenu.func = nullptr; + } + + ImGui::EndPopup(); + } + } + ImGui::EndChild(); + ImGui::EndTabItem(); } + if (ImGui::BeginTabItem(TEXT("Window.FavouritesTab"))) + { + ImGui::Spacing(); + ImGui::PushItemWidth(ImGui::GetWindowContentRegionWidth()); + Filter("##Filter", store.m_Filter, TEXT("Window.Search")); + ImGui::PopItemWidth(); + ImGui::Spacing(); + ImGui::BeginChild("DrawFavourites"); + size_t count = 0; + for (auto [k, v] : *store.m_pData->GetTable("Favourites")) + { + std::string key = std::string(k.str()); + if (store.m_Filter.PassFilter(key.c_str())) + { + std::string val = v.value_or("Unkonwn"); + if (ImGui::MenuItem(key.c_str()) && clickFunc != nullptr) + { + clickFunc(val); + } + + if (ImGui::IsItemClicked(1)) + { + contextMenu = {std::string("Favourites"), key, val, (void*)1}; + } + } + ++count; + } + if (count == 0) + { + Widget::TextCentered(TEXT("Menu.FavouritesNone")); + } + if (contextMenu.func != nullptr) + { + if (ImGui::BeginPopupContextWindow()) + { + ImGui::Text(contextMenu.key.c_str()); + ImGui::Separator(); + if (ImGui::MenuItem(TEXT("Menu.FavouritesRemove"))) + { + store.m_pData->RemoveKey("Favourites", contextMenu.key.c_str()); + store.m_pData->Save(); + SetHelpMessage(TEXT("Menu.FavouritesRemoveText")); + } + if (ImGui::MenuItem(TEXT("Menu.Close"))) + { + contextMenu.func = nullptr; + } + + ImGui::EndPopup(); + } + } + ImGui::EndChild(); + ImGui::EndTabItem(); + } + ImGui::EndTabBar(); } + if (showImages) { ImGui::PopStyleVar(4); } - - // Draw popup code - if (contextMenu.func != nullptr) - { - if (ImGui::BeginPopupContextWindow()) - { - ImGui::Text(contextMenu.val.c_str()); - ImGui::Separator(); - if (ImGui::MenuItem("Remove")) - { - static_cast(contextMenu.func)(contextMenu.val); - } - - if (ImGui::MenuItem("Close")) - { - contextMenu.func = nullptr; - } - - ImGui::EndPopup(); - } - } - ImGui::EndChild(); } bool Widget::ColorBtn(int colorId, std::vector& color, ImVec2 size) @@ -717,7 +780,7 @@ bool Widget::ListBox(const char* label, VecStr& allItems, std::string& selected) bool Widget::ListBox(const char* label, VecStr& allItems, int& selected) { bool rtn = false; - if (ImGui::BeginCombo(label, std::to_string(selected).c_str())) + if (ImGui::BeginCombo(label, allItems[selected].c_str())) { for (size_t index = 0; index < allItems.size(); ++index) { diff --git a/src/widget.h b/src/widget.h index 734664e..f4085d6 100644 --- a/src/widget.h +++ b/src/widget.h @@ -65,8 +65,8 @@ public: static void Filter(const char* label, ImGuiTextFilter& filter, const char* hint); // Draws ResourceStore images in the interface - static void ImageList(ResourceStore &store, ArgCallback leftClickFunc, ArgCallback rightClickFunc, - ArgCallbackRtn getNameFunc, ArgCallbackRtnBool verifyFunc = nullptr); + static void ImageList(ResourceStore &store, ArgCallback clickFunc, ArgCallbackRtn getNameFunc, + ArgCallbackRtnBool verifyFunc = nullptr); // Draws a dropdown listbox static bool ListBox(const char* label, VecStr& allItems, int& selected);