From b7731418f76a1cc0acdb78ea77ffd3e6800b0e62 Mon Sep 17 00:00:00 2001 From: Grinch_ Date: Fri, 24 Dec 2021 16:36:07 +0600 Subject: [PATCH] Code cleanup & fixes --- resource/SA/CheatMenu/json/teleport.json | 141 +++++++++++++++- src/cheatmenu.cpp | 4 +- src/cheatmenu.h | 10 +- src/dllmain.cpp | 18 +-- src/filehandler.cpp | 194 +++++++++++------------ src/fontmgr.cpp | 16 +- src/fontmgr.h | 16 +- src/game.h | 1 + src/hook.cpp | 2 +- src/hotkeys.h | 4 + src/menu.h | 31 ++-- src/neon.h | 7 + src/ped.h | 5 - src/resourcestore.h | 4 + src/visual.cpp | 2 +- 15 files changed, 302 insertions(+), 153 deletions(-) diff --git a/resource/SA/CheatMenu/json/teleport.json b/resource/SA/CheatMenu/json/teleport.json index 4264887..1e8d0b0 100644 --- a/resource/SA/CheatMenu/json/teleport.json +++ b/resource/SA/CheatMenu/json/teleport.json @@ -419,7 +419,146 @@ "Oyster 8": "0, 1249, -2687, -1", "Oyster 9": "0, 725, -1849, -5" }, - "Radar": null, + "Radar": { + "Ammunation sprite, Angel Pine, CS": "0, -2092.699951, -2463.800049, 30.600000", + "Ammunation sprite, Blueberry, CS": "0, 240.000000, -178.199997, 2.000000", + "Ammunation sprite, Bone County, CS": "0, 779.700012, 1874.300049, 4.900000", + "Ammunation sprite, Come-A-Lot, CS": "0, 2156.500000, 943.200012, 10.800000", + "Ammunation sprite, Downtown Los Santos, CS": "0, 1372.900024, -1278.800049, 12.500000", + "Ammunation sprite, El Quebrados, CS": "0, -1509.400024, 2611.800049, 58.500000", + "Ammunation sprite, Fort Carson, CS": "0, -315.670013, 829.869995, 13.430000", + "Ammunation sprite, Ocean Flats, CS": "0, -2626.600098, 209.399994, 4.900000", + "Ammunation sprite, Old Venturas Strip, CS": "0, 2535.899902, 2083.500000, 10.800000", + "Ammunation sprite, Palomino Creek, CS": "0, 2332.899902, 63.599998, 31.000000", + "Ammunation sprite, Willowfield, CS": "0, 2400.500000, -1978.400024, 13.500000", + "Barber sprite, Dillimore, CS": "0, 675.700012, -496.600006, 16.799999", + "Barber sprite, Idlewood, CS": "0, 2070.270264, -1791.091797, 17.148399", + "Barber sprite, Marina, CS": "0, 822.599976, -1590.300049, 13.500000", + "Barber sprite, Playa del Seville, CS": "0, 2726.600098, -2026.400024, 17.500000", + "Barber sprite, Queens, CS": "0, -2570.100098, 245.399994, 10.300000", + "Barber sprite, Redsands East, CS": "0, 2080.300049, 2119.000000, 10.800000", + "Bulldozer sprite, Hunter Quarry, CS": "0, 823.681580, 854.174072, 10.794900", + "Burgershot sprite, Downtown, CS": "0, -1913.300049, 826.200012, 36.900002", + "Burgershot sprite, Garcia, CS": "0, -2335.600098, -165.600006, 39.500000", + "Burgershot sprite, Juniper Hollow, CS": "0, -2356.000000, 1009.000000, 49.000000", + "Burgershot sprite, Marina, CS": "0, 812.900024, -1616.099976, 13.600000", + "Burgershot sprite, Old Venturas Strip, CS": "0, 2469.500000, 2033.800049, 10.800000", + "Burgershot sprite, Redsands East, CS": "0, 1875.300049, 2072.000000, 10.800000", + "Burgershot sprite, Spinybed, CS": "0, 2172.899902, 2795.699951, 10.800000", + "Burgershot sprite, Temple, CS": "0, 1199.099976, -924.000000, 43.299999", + "Burgershot sprite, Whitewood Estates, CS": "0, 1161.500000, 2072.000000, 10.800000", + "Chicken sprite, Angel Pine, CS": "0, -2154.000000, -2461.199951, 30.799999", + "Chicken sprite, Bone County, CS": "0, 172.729996, 1176.760010, 13.700000", + "Chicken sprite, Creek, CS": "0, 2844.500000, 2401.100098, 11.000000", + "Chicken sprite, Downtown, CS": "0, -1816.199951, 620.799988, 37.500000", + "Chicken sprite, East Los Santos, CS": "0, 2421.600098, -1509.599976, 24.100000", + "Chicken sprite, Market, CS": "0, 932.000000, -1353.000000, 14.000000", + "Chicken sprite, Ocean Flats, CS": "0, -2671.600098, 257.399994, 4.600000", + "Chicken sprite, Old Venturas Strip, CS": "0, 2392.399902, 2046.500000, 10.800000", + "Chicken sprite, Pilgrim, CS": "0, 2635.500000, 1674.300049, 11.000000", + "Chicken sprite, The Emerald Isle, CS": "0, 2105.699951, 2228.699951, 11.000000", + "Chicken sprite, Tierra Robada, CS": "0, -1216.000000, 1831.400024, 45.299999", + "Chicken sprite, Willowfield, CS": "0, 2397.800049, -1895.599976, 13.700000", + "Emmetgun sprite, Willowfield, CS": "0, 2447.364258, -1974.496338, 12.546900", + "Flag sprite, Downtown, CS": "0, -1922.922485, 282.715088, 40.039101", + "Flag sprite, LVA Freight Depot, CS": "0, 1636.916016, 912.947815, 9.689000", + "Flag sprite, Las Venturas Airport, CS": "0, 1701.690186, 1649.192993, 9.629600", + "Flag sprite, Little Mexico, CS": "0, 1766.133545, -1704.228149, 12.473100", + "Girlfriend sprite, Downtown, CS": "0, -1799.500000, 1195.500000, 24.109400", + "Girlfriend sprite, El Quebrados, CS": "0, -1398.100952, 2636.873047, 54.703098", + "Girlfriend sprite, Flint Range, CS": "0, -377.397797, -1438.691895, 24.720900", + "Girlfriend sprite, Ganton, CS": "0, 2401.964600, -1723.219727, 12.600500", + "Girlfriend sprite, Paradiso, CS": "0, -2576.807861, 1144.743774, 54.742199", + "Girlfriend sprite, Prickle Pine, CS": "0, 2035.361938, 2732.410645, 9.820300", + "Gym sprite, Ganton, CS": "0, 2228.000244, -1722.811279, 12.554300", + "Gym sprite, Garcia, CS": "0, -2269.399902, -155.600006, 35.299999", + "Gym sprite, Redsands East, CS": "0, 1968.599976, 2292.100098, 16.400000", + "Modgarage sprite, Come-A-Lot, CS": "0, 2382.199951, 1044.000000, 9.800000", + "Modgarage sprite, Doherty, CS": "0, -1941.000000, 251.699997, 33.400002", + "Modgarage sprite, Ocean Flats, CS": "0, -2728.500000, 212.199997, 3.400000", + "Modgarage sprite, Temple, CS": "0, 1043.400024, -1025.300049, 34.400002", + "Modgarage sprite, Willowfield, CS": "0, 2644.252441, -2028.245728, 12.554700", + "No sprite, Easter Basin, CS": "0, -1693.320190, 65.118698, 8.799700", + "No sprite, Hunter Quarry, CS": "0, 455.173187, 803.150085, 5.387200", + "No sprite, Los Santos International, CS": "0, 1750.000000, -2494.000000, 0.000000", + "No sprite, San Fierro, CS": "0, -1673.734741, 56.928699, -10.674000", + "No sprite, Whetstone, CS": "0, -1414.158691, -1414.158691, 20.000000", + "No sprite, Whitewood Estates, CS": "0, 929.496826, 2007.118408, 0.000000", + "Pizza sprite, Blueberry, CS": "0, 203.199997, -200.399994, 6.500000", + "Pizza sprite, Creek, CS": "0, 2750.899902, 2470.899902, 11.000000", + "Pizza sprite, Esplanade North, CS": "0, -1719.099976, 1359.400024, 8.600000", + "Pizza sprite, Financial, CS": "0, -1805.699951, 943.200012, 24.799999", + "Pizza sprite, Idlewood, CS": "0, 2107.624268, -1807.515503, 21.211399", + "Pizza sprite, Palomino Creek, CS": "0, 2330.199951, 75.199997, 31.000000", + "Pizza sprite, Roca Escalante, CS": "0, 2351.800049, 2529.000000, 10.800000", + "Pizza sprite, Starfish Casino, CS": "0, 2635.500000, 1847.400024, 11.000000", + "Pizza sprite, The Emerald Isle, CS": "0, 2083.399902, 2221.000000, 11.000000", + "Race sprite, Blackfield, CS": "0, 1099.551270, 1601.497437, 11.554600", + "Race sprite, East Beach, CS": "0, 2695.624268, -1704.688477, 10.843700", + "Race sprite, Foster Valley, CS": "0, -2120.041748, -444.283813, 34.531200", + "Savegame sprite, Angel Pine, CS": "0, -2037.890015, -2526.959961, 30.129999", + "Savegame sprite, Blueberry, CS": "0, 206.800003, -112.099998, 4.396500", + "Savegame sprite, Calton Heights, CS": "0, -2106.639160, 900.553711, 76.203201", + "Savegame sprite, Chinatown, CS": "0, -2213.864258, 723.558716, 48.914001", + "Savegame sprite, Creek, CS": "0, 2819.125488, 2149.371826, 10.320300", + "Savegame sprite, Dillimore, CS": "0, 793.562317, -514.411621, 16.397301", + "Savegame sprite, Doherty, CS": "0, -2026.481445, 156.802795, 28.539101", + "Savegame sprite, El Quebrados, CS": "0, -1534.170288, 2650.300049, 55.343700", + "Savegame sprite, Fern Ridge, CS": "0, 877.809998, -26.910000, 62.689999", + "Savegame sprite, Fort Carson, CS": "0, -366.184906, 1166.030518, 19.242201", + "Savegame sprite, Hashbury, CS": "0, -2456.925537, -131.329193, 25.537600", + "Savegame sprite, Jefferson, CS": "0, 2103.345947, -1288.338867, 23.816799", + "Savegame sprite, Mulholland, CS": "0, 1331.185547, -630.496216, 108.634903", + "Savegame sprite, Old Venturas Strip, CS": "0, 2370.477295, 2165.474365, 10.326900", + "Savegame sprite, Palomino Creek, CS": "0, 2236.927979, 162.805695, 26.846201", + "Savegame sprite, Paradiso, CS": "0, -2695.745117, 818.471802, 49.484402", + "Savegame sprite, Pirates in Men's Pants, CS": "0, 1969.932495, 1623.242920, 12.361900", + "Savegame sprite, Prickle Pine, CS": "0, 1283.843872, 2528.702881, 10.320300", + "Savegame sprite, Queens, CS": "0, -2419.676758, 334.162109, 34.679600", + "Savegame sprite, Redsands West, CS": "0, 1402.317383, 1901.978271, 10.844900", + "Savegame sprite, Rockshore West, CS": "0, 2441.002197, 695.108887, 10.664600", + "Savegame sprite, San Andreas, CS": "0, 1263.050049, -773.669983, 1091.390015", + "Savegame sprite, Santa Maria Beach, CS": "0, 316.069611, -1772.568848, 4.189300", + "Savegame sprite, The Camel's Toe, CS": "0, 2234.908691, 1285.698120, 10.320300", + "Savegame sprite, The Clown's Pocket, CS": "0, 2220.625732, 1837.347534, 10.320300", + "Savegame sprite, The Four Dragons Casino, CS": "0, 2024.564453, 996.472778, 10.320300", + "Savegame sprite, Tierra Robada, CS": "0, -693.377625, 957.823975, 11.782900", + "Savegame sprite, Verdant Bluffs, CS": "0, 1687.980469, -2100.643066, 13.334300", + "Savegame sprite, Verdant Meadows, CS": "0, 416.954803, 2538.812744, 9.507700", + "Savegame sprite, Verona Beach, CS": "0, 892.666199, -1639.713867, 14.456700", + "Savegame sprite, Whetstone, CS": "0, -1439.014038, -1540.590088, 101.257896", + "Savegame sprite, Whitewood Estates, CS": "0, 922.364685, 2011.898438, 10.766000", + "Savegame sprite, Willowfield, CS": "0, 2483.023682, -2001.074097, 13.054000", + "School sprite, Bayside Marina, CS": "0, -2187.378174, 2416.551758, 4.166000", + "School sprite, Blackfield, CS": "0, 1173.876709, 1351.037109, 9.921900", + "School sprite, San Andreas, CS": "0, -2026.810547, -114.909302, 1034.179199", + "School sprite, Verdant Meadows, CS": "0, 415.549988, 2533.570068, 19.180000", + "Sprayshop sprite, Dillimore, CS": "0, 720.015991, -454.625000, 15.328000", + "Sprayshop sprite, Downtown, CS": "0, -1908.900024, 292.299988, 40.000000", + "Sprayshop sprite, El Quebrados, CS": "0, -1420.546997, 2583.945068, 58.030998", + "Sprayshop sprite, Fort Carson, CS": "0, -103.599998, 1112.400024, 18.700001", + "Sprayshop sprite, Idlewood, CS": "0, 2067.399902, -1831.199951, 13.500000", + "Sprayshop sprite, Juniper Hollow, CS": "0, -2425.459961, 1020.830017, 49.389999", + "Sprayshop sprite, Redsands East, CS": "0, 1966.531982, 2162.649902, 10.995000", + "Sprayshop sprite, Santa Maria Beach, CS": "0, 488.000000, -1734.000000, 34.400002", + "Sprayshop sprite, Temple, CS": "0, 1021.799988, -1018.700012, 30.900000", + "Tattoo sprite, Hashbury, CS": "0, -2490.500000, -40.099998, 39.299999", + "Tattoo sprite, Idlewood, CS": "0, 2071.600098, -1779.900024, 13.500000", + "Tattoo sprite, Redsands East, CS": "0, 2094.600098, 2119.000000, 10.800000", + "Tattoo sprite, Willowfield, CS": "0, 1971.699951, -2036.599976, 13.500000", + "Truck sprite, Flint County, CS": "0, -77.645599, -1136.401001, 0.078100", + "Tshirt sprite, Creek, CS": "0, 2795.199951, 2424.600098, 11.000000", + "Tshirt sprite, Downtown Los Santos, CS": "0, 1458.699951, -1140.000000, 24.200001", + "Tshirt sprite, Downtown, CS": "0, -1692.900024, 952.799988, 26.299999", + "Tshirt sprite, Ganton, CS": "0, 2243.806885, -1668.566650, 20.031300", + "Tshirt sprite, Hashbury, CS": "0, -2489.000000, -26.900000, 32.599998", + "Tshirt sprite, Jefferson, CS": "0, 2112.800049, -1214.699951, 23.900000", + "Tshirt sprite, Juniper Hill, CS": "0, -2371.100098, 910.200012, 47.200001", + "Tshirt sprite, Las Venturas Airport, CS": "0, 1654.000000, 1733.400024, 11.000000", + "Tshirt sprite, Rodeo, CS": "0, 451.899994, -1480.000000, 30.900000", + "Tshirt sprite, Starfish Casino, CS": "0, 2574.300049, 1901.699951, 11.000000", + "Tshirt sprite, The Emerald Isle, CS": "0, 2090.500000, 2221.000000, 11.000000" + }, "Snapshots": { "Snapshot 1": "0, -2511.28, -672.99, 195.75", "Snapshot 10": "0, -2773.04, 783.45, 67.66", diff --git a/src/cheatmenu.cpp b/src/cheatmenu.cpp index f68feb1..61831d0 100644 --- a/src/cheatmenu.cpp +++ b/src/cheatmenu.cpp @@ -156,8 +156,8 @@ void CheatMenu::ApplyStyle() style->Colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.7f, 0.7f, 0.7f, 0.3f); style->Colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.9f, 0.9f, 0.9f, 0.3f); style->Colors[ImGuiCol_CheckMark] = ImVec4(0.80f, 0.80f, 0.83f, 0.31f); - style->Colors[ImGuiCol_SliderGrab] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f); - style->Colors[ImGuiCol_SliderGrabActive] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f); + style->Colors[ImGuiCol_SliderGrab] = ImVec4(0.80f, 0.80f, 0.83f, 0.31f); + style->Colors[ImGuiCol_SliderGrabActive] = ImVec4(0.80f, 0.80f, 0.83f, 0.31f); style->Colors[ImGuiCol_Separator] = ImVec4(0.15f, 0.15f, 0.15f, 0.95f); style->Colors[ImGuiCol_Button] = ImVec4(0.15f, 0.15f, 0.15f, 0.95f); style->Colors[ImGuiCol_ButtonHovered] = ImVec4(0.17f, 0.17f, 0.17f, 1.00f); diff --git a/src/cheatmenu.h b/src/cheatmenu.h index 23325e0..d55c119 100644 --- a/src/cheatmenu.h +++ b/src/cheatmenu.h @@ -27,11 +27,11 @@ private: static inline ImVec2 m_fMenuSize = ImVec2(screen::GetScreenWidth() / 4, screen::GetScreenHeight() / 1.2); static inline bool m_bSizeChangedExternal = false; - static inline CallbackTable header{ - {"Teleport", &Teleport::Draw}, {"Player", &Player::Draw}, {"Ped", &Ped::Draw}, - {"Animation", &Animation::Draw}, - {"Vehicle", &Vehicle::Draw}, {"Weapon", &Weapon::Draw}, {"Game", &Game::Draw}, - {"Visual", &Visual::Draw}, {"Menu", &Menu::Draw} + static inline CallbackTable header + { + {"Teleport", &Teleport::Draw}, {"Player", &Player::Draw}, {"Ped", &Ped::Draw}, + {"Animation", &Animation::Draw}, {"Vehicle", &Vehicle::Draw}, {"Weapon", &Weapon::Draw}, + {"Game", &Game::Draw}, {"Visual", &Visual::Draw}, {"Menu", &Menu::Draw} }; static void ApplyStyle(); diff --git a/src/dllmain.cpp b/src/dllmain.cpp index e51582f..fc6aa8f 100644 --- a/src/dllmain.cpp +++ b/src/dllmain.cpp @@ -6,15 +6,15 @@ void MenuThread(void* param) { - static bool bGameInit = false; + static bool gameInit; // Wait till game init Events::initRwEvent += [] { - bGameInit = true; + gameInit = true; }; - while (!bGameInit) + while (!gameInit) { Sleep(1000); } @@ -91,22 +91,14 @@ BOOL WINAPI DllMain(HINSTANCE hDllHandle, DWORD nReason, LPVOID Reserved) { if (nReason == DLL_PROCESS_ATTACH) { - uint gameVersion = GetGameVersion(); - - if (gameVersion == BY_GAME(GAME_10US_HOODLUM, GAME_10EN, GAME_10EN)) + if (GetGameVersion() == BY_GAME(GAME_10US_HOODLUM, GAME_10EN, GAME_10EN)) { CreateThread(nullptr, NULL, (LPTHREAD_START_ROUTINE)&MenuThread, nullptr, NULL, nullptr); } else { gLog << "Error: Unknown game version. GTA " << BY_GAME("SA v1.0 US Hoodlum", "GTA VC v1.0 EN", "GTA III v1.0 EN") << " is required." << std::endl; -#ifdef GTASA - MessageBox(HWND_DESKTOP, "Unknown game version. GTA SA v1.0 US Hoodlum is required.", "CheatMenu", MB_ICONERROR); -#elif GTAVC - MessageBox(HWND_DESKTOP, "Unknown game version. GTA VC v1.0 EN is required.", "CheatMenu", MB_ICONERROR); -#else // GTA3 - MessageBox(HWND_DESKTOP, "Unknown game version. GTA III v1.0 EN is required.", "CheatMenu", MB_ICONERROR); -#endif + MessageBox(HWND_DESKTOP, "Unknown game version. GTA " BY_GAME("SA v1.0 US Hoodlum", "GTA VC v1.0 EN", "GTA III v1.0 EN") " is required.", "CheatMenu", MB_ICONERROR); } } diff --git a/src/filehandler.cpp b/src/filehandler.cpp index 4380f72..f3a8d23 100644 --- a/src/filehandler.cpp +++ b/src/filehandler.cpp @@ -64,130 +64,124 @@ void FileHandler::GenerateHandlingFile(int pHandling, std::map void FileHandler::FetchColorData(std::vector>& storeVec) { std::string m_FilePath = GAME_PATH((char*)"/data/carcols.dat"); - - if (std::filesystem::exists(m_FilePath)) - { - std::ifstream file(m_FilePath); - std::string line; - bool bIsCar = false; - bool bIsCol = false; - int nLineCount = 0; - - while (getline(file, line)) - { - // skip commented & emety lines - if (line[0] == '#' || line == "") - { - continue; - } - - // section blocks - if (line[0] == 'c' && line[1] == 'a' && line[2] == 'r') - { - bIsCar = true; - continue; - } - - if (line[0] == 'c' && line[1] == 'o' && line[2] == 'l') - { - bIsCol = true; - continue; - } - - if (line[0] == 'e' && line[1] == 'n' && line[2] == 'd') - { - bIsCar = false; - bIsCol = false; - continue; - } - - if (bIsCol) - { - try - { - std::string temp; - std::stringstream ss(line); - - // fix one instance where . is used instead of , - std::replace(temp.begin(), temp.end(), '.', ','); - - // Format: red, green, blue - int r,g,b; - getline(ss, temp, ','); - r = std::stoi(temp); - getline(ss, temp, ','); - g = std::stoi(temp); - getline(ss, temp, ','); - b = std::stoi(temp); - - storeVec.push_back({r / 255.0f, g / 255.0f, b / 255.0f}); - ++nLineCount; - } - catch (...) - { - gLog << "Error parsing carcols.dat, " << line << std::endl; - } - } - } - - file.close(); - } - else + if (!std::filesystem::exists(m_FilePath)) { gLog << "Carcols.dat not found"; + return; } -} -void FileHandler::FetchHandlingID(std::map& storeMap) -{ - std::string m_FilePath = GAME_PATH((char*)"/data/vehicles.ide"); + std::ifstream file(m_FilePath); + std::string line; + bool isCar, isCol; + int count = 0; - if (std::filesystem::exists(m_FilePath)) + while (getline(file, line)) { - std::ifstream file(m_FilePath); - std::string line; - - while (getline(file, line)) + // skip commented & empty lines + if (line[0] == '#' || line == "") { - /* - Format: model, modelname, txdname, type, handlingId, ... - Skip if first thing isn't model id - */ - if (line[0] <= '0' || line[0] >= '9') - { - continue; - } + continue; + } - // running inside try block to handle user errors, mostly commas + // section blocks + if (line[0] == 'c' && line[1] == 'a' && line[2] == 'r') + { + isCar = true; + continue; + } + + if (line[0] == 'c' && line[1] == 'o' && line[2] == 'l') + { + isCol = true; + continue; + } + + if (line[0] == 'e' && line[1] == 'n' && line[2] == 'd') + { + isCar = false; + isCol = false; + continue; + } + + if (isCol) + { try { std::string temp; std::stringstream ss(line); - // get model - getline(ss, temp, ','); - int model = std::stoi(temp); + // fix one instance where . is used instead of , + std::replace(temp.begin(), temp.end(), '.', ','); - // get modelname, txd, type, handlingId - getline(ss, temp, ','); + // Format: red, green, blue + int r,g,b; getline(ss, temp, ','); + r = std::stoi(temp); getline(ss, temp, ','); + g = std::stoi(temp); getline(ss, temp, ','); + b = std::stoi(temp); - temp.erase(std::remove_if(temp.begin(), temp.end(), ::isspace), temp.end()); - - storeMap[model] = temp; + storeVec.push_back({r / 255.0f, g / 255.0f, b / 255.0f}); + ++count; } catch (...) { - gLog << "Error parsing vehicles.ide, " << line << std::endl; + gLog << "Error parsing carcols.dat, " << line << std::endl; } } - - file.close(); } - else - { + + file.close(); +} + +void FileHandler::FetchHandlingID(std::map& storeMap) +{ + std::string m_FilePath = GAME_PATH((char*)"/data/vehicles.ide"); + if (!std::filesystem::exists(m_FilePath)) + { gLog << "Vehicle.ide not found"; + return; } + + std::ifstream file(m_FilePath); + std::string line; + while (getline(file, line)) + { + /* + Format: model, modelname, txdname, type, handlingId, ... + Skip if first thing isn't model id + */ + if (line[0] <= '0' || line[0] >= '9') + { + continue; + } + + // running inside try block to handle user errors, mostly commas + try + { + std::string temp; + std::stringstream ss(line); + + // get model + getline(ss, temp, ','); + int model = std::stoi(temp); + + // get modelname, txd, type, handlingId + getline(ss, temp, ','); + getline(ss, temp, ','); + getline(ss, temp, ','); + getline(ss, temp, ','); + + temp.erase(std::remove_if(temp.begin(), temp.end(), isspace), temp.end()); + + storeMap[model] = temp; + } + catch (...) + { + gLog << "Error parsing vehicles.ide, " << line << std::endl; + } + } + + file.close(); } \ No newline at end of file diff --git a/src/fontmgr.cpp b/src/fontmgr.cpp index b2b6308..a05dcd8 100644 --- a/src/fontmgr.cpp +++ b/src/fontmgr.cpp @@ -20,22 +20,28 @@ ImFont* FontMgr::LoadFont(const char* fontName, float fontMul) size_t fontSize = static_cast(screen::GetScreenHeight() / 54.85f) * fontMul; std::string fullPath = std::string(PLUGIN_PATH((char*)"CheatMenu/fonts/")) + fontName + ".ttf"; - m_vecFonts.push_back({io.Fonts->AddFontFromFileTTF(fullPath.c_str(), fontSize), fontSize, + m_vecFonts.push_back({io.Fonts->AddFontFromFileTTF(fullPath.c_str(), fontSize), fontSize, fontMul, std::string(fontName)}); io.Fonts->Build(); return m_vecFonts.back().m_pFont; } -void FontMgr::ReinitFonts() +void FontMgr::UnloadFonts() { - ImGuiIO& io = ImGui::GetIO(); - io.Fonts->Clear(); + ImGui::GetIO().Fonts->Clear(); +} +void FontMgr::ReloadFonts() +{ + UnloadFonts(); + + ImGuiIO& io = ImGui::GetIO(); for (auto &data : m_vecFonts) { + size_t fontSize = static_cast(screen::GetScreenHeight() / 54.85f) * data.m_fMul; std::string fullPath = PLUGIN_PATH((char*)"CheatMenu/fonts/") + data.m_path + ".ttf"; - data.m_pFont = io.Fonts->AddFontFromFileTTF(fullPath.c_str(), data.fontSize); + data.m_pFont = io.Fonts->AddFontFromFileTTF(fullPath.c_str(), data.m_nSize); } io.FontDefault = GetFont("text"); io.Fonts->Build(); diff --git a/src/fontmgr.h b/src/fontmgr.h index 6e6e319..faf4329 100644 --- a/src/fontmgr.h +++ b/src/fontmgr.h @@ -1,25 +1,31 @@ #pragma once -#include "pch.h" +/* + Font Manager class + Handles loading, fetching, freeing & reloading fonts +*/ class FontMgr { private: struct FontInfo { ImFont *m_pFont; - size_t fontSize; + size_t m_nSize; + float m_fMul; std::string m_path; }; + static inline std::vector m_vecFonts; public: - static inline std::vector m_vecFonts; - FontMgr() = delete; FontMgr(FontMgr&) = delete; static ImFont* GetFont(const char* fontName); static ImFont* LoadFont(const char* fontName, float fontMul = 1.0f); - static void ReinitFonts(); + + // ImGui::GetIO().Default font must be loaded after unloading all fonts + static void UnloadFonts(); + static void ReloadFonts(); }; diff --git a/src/game.h b/src/game.h index 7b5b710..6621d7b 100644 --- a/src/game.h +++ b/src/game.h @@ -1,5 +1,6 @@ #pragma once #include "pch.h" + class Game { public: diff --git a/src/hook.cpp b/src/hook.cpp index da90dc0..e015d63 100644 --- a/src/hook.cpp +++ b/src/hook.cpp @@ -50,7 +50,7 @@ void Hook::RenderFrame(void* ptr) ImVec2 size(screen::GetScreenWidth(), screen::GetScreenHeight()); if (fScreenSize.x != size.x && fScreenSize.y != size.y) { - FontMgr::ReinitFonts(); + FontMgr::ReloadFonts(); if (gRenderer == Render_DirectX9) { diff --git a/src/hotkeys.h b/src/hotkeys.h index 1797765..46e468e 100644 --- a/src/hotkeys.h +++ b/src/hotkeys.h @@ -1,6 +1,10 @@ #pragma once #include +/* + ImGui HotKey Implementation class + Handles hotkeys and hotkey-related functions +*/ class Hotkey { private: diff --git a/src/menu.h b/src/menu.h index 7cc3383..7b19472 100644 --- a/src/menu.h +++ b/src/menu.h @@ -15,23 +15,24 @@ private: struct m_Overlay { - static inline bool bCoord = false; - static inline bool bFPS = false; - static inline int mFPS = 0; - static inline bool bLocName = false; - static inline bool bTransparent = false; - static inline bool bVehHealth = false; - static inline bool bVehSpeed = false; - static inline bool bCpuUsage = false; - static inline float fCpuUsage = 0.0f; - static inline bool bMemUsage = false; - static inline float fMemUsage = 0.0f; - static inline std::vector posNames = { + static inline bool bCoord; + static inline bool bFPS; + static inline int mFPS; + static inline bool bLocName; + static inline bool bTransparent; + static inline bool bVehHealth; + static inline bool bVehSpeed; + static inline bool bCpuUsage; + static inline float fCpuUsage; + static inline bool bMemUsage; + static inline float fMemUsage; + static inline std::vector posNames = + { "Custom", "Top left", "Top right", "Bottom left", "Bottom right" }; static inline DISPLAY_POS mSelectedPos = DISPLAY_POS::BOTTOM_RIGHT; - static inline float fPosX = 0.0f; - static inline float fPosY = 0.0f; + static inline float fPosX; + static inline float fPosY; static inline size_t mInterval = 1000; static inline size_t mLastInterval = 0; static inline int mTotalRam = 0; @@ -40,7 +41,7 @@ private: public: struct m_Commands { - static inline bool m_bShowMenu = false; + static inline bool m_bShowMenu; static inline char m_nInputBuffer[INPUT_BUFFER_SIZE] = ""; }; diff --git a/src/neon.h b/src/neon.h index a6a59b1..94a3fc0 100644 --- a/src/neon.h +++ b/src/neon.h @@ -1,6 +1,13 @@ #pragma once #include "extender/VehicleExtender.h" +/* + Vehicle Neon implementation class for GTA: San Andreas + Handles neon colors and neon color changing + + TODO: Implement for VC & 3 too (maybe) + Dunno how it'd work with the d3d8to9 wrapper +*/ class Neon { private: diff --git a/src/ped.h b/src/ped.h index ac731f7..97ad6f5 100644 --- a/src/ped.h +++ b/src/ped.h @@ -1,9 +1,5 @@ #pragma once #include "pch.h" -#include "player.h" -#ifdef GTASA -#include "weapon.h" -#endif class Ped { @@ -22,7 +18,6 @@ private: #else // GTA3 & GTAVC static inline ResourceStore m_PedData{"ped", eResourceType::TYPE_TEXT}; #endif - static inline bool m_bImagesLoaded; static inline bool m_bExGangWarsInstalled; static inline int m_nPedRemoveRadius = 5; struct m_SpawnPed diff --git a/src/resourcestore.h b/src/resourcestore.h index df4975c..db089c1 100644 --- a/src/resourcestore.h +++ b/src/resourcestore.h @@ -4,6 +4,10 @@ #include "../depend/imgui/imgui.h" #include "d3d9.h" +/* + Global resource handler class + Handles both image and json resources +*/ struct RwD3D9Raster { union diff --git a/src/visual.cpp b/src/visual.cpp index bff8c3c..552098e 100644 --- a/src/visual.cpp +++ b/src/visual.cpp @@ -557,7 +557,7 @@ void Visual::Draw() Ui::ColorPickerAddress("Breathbar color", *(int*)0x5891EB, ImVec4(172, 203, 241, 255)); Ui::EditAddress("Breathbar posX", *(int*)0x58F11F, -999, 94, 999); Ui::EditAddress("Breathbar posY", *(int*)0x58F100, -999, 62, 999); - Ui::ColorPickerAddress("Clock color", *(int*)0x58EBD1, ImVec4(180, 25, 29, 255)); + Ui::ColorPickerAddress("Clock color", *(int*)0x58EBD1, ImVec4(255, 255, 255, 255)); Ui::EditAddress("Clock posX", *(int*)0x58EC16, -999, 32, 999); Ui::EditAddress("Clock posY", *(int*)0x58EC04, -999, 22, 999); Ui::ColorPickerAddress("Healthbar color", *(int*)0x589331, ImVec4(180, 25, 29, 255));