Add cutscene player

This commit is contained in:
Grinch_ 2021-04-26 00:59:14 +06:00
parent 82ac63afca
commit f478812ba8
8 changed files with 291 additions and 3 deletions

View File

@ -6,6 +6,49 @@
Animation::Animation()
{
json.LoadData(search_categories, selected_item);
Cutscene::json.LoadData(Cutscene::categories, Cutscene::selected);
Events::processScriptsEvent += []
{
if (Cutscene::running)
{
if (Command<Commands::HAS_CUTSCENE_FINISHED>())
{
Command<Commands::CLEAR_CUTSCENE>();
Cutscene::running = false;
Cutscene::scene_name = "";
CPlayerPed* player = FindPlayerPed();
player->m_nAreaCode = Cutscene::interior;
Command<Commands::SET_AREA_VISIBLE>(player->m_nAreaCode);
Cutscene::interior = 0;
TheCamera.Fade(0, 1);
}
}
else
{
if (Cutscene::scene_name != "" && Command<Commands::HAS_CUTSCENE_LOADED>())
{
Command<Commands::START_CUTSCENE>();
Cutscene::running = true;
}
}
};
}
void Animation::PlayCutscene(std::string& rootkey, std::string& cutscene_str, std::string& interior)
{
if (Util::IsOnCutscene())
{
CHud::SetHelpMessage("Another cutscene is running", false, false, false);
return;
}
Cutscene::scene_name = cutscene_str;
Command<Commands::LOAD_CUTSCENE>(cutscene_str.c_str());
CPlayerPed *player =FindPlayerPed();
Cutscene::interior = player->m_nAreaCode;
player->m_nAreaCode = std::stoi(interior);
Command<Commands::SET_AREA_VISIBLE>(player->m_nAreaCode);
}
void Animation::Draw()
@ -88,6 +131,33 @@ void Animation::Draw()
}
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("Cutscene"))
{
ImGui::Spacing();
if (ImGui::Button("Stop cutscene", Ui::GetSize()))
{
if (Cutscene::running)
{
Command<Commands::CLEAR_CUTSCENE>();
Cutscene::running = false;
Cutscene::scene_name = "";
CPlayerPed* player = FindPlayerPed();
player->m_nAreaCode = Cutscene::interior;
Command<Commands::SET_AREA_VISIBLE>(player->m_nAreaCode);
Cutscene::interior = 0;
TheCamera.Fade(0, 1);
}
}
ImGui::Spacing();
if (ImGui::BeginChild("Cutscene Child"))
{
ImGui::Spacing();
Ui::DrawJSON(Cutscene::json, Cutscene::categories, Cutscene::selected, Cutscene::filter, &PlayCutscene, nullptr);
ImGui::EndChild();
}
ImGui::EndTabItem();
}
ImGui::EndTabBar();
}
}

View File

@ -10,6 +10,18 @@ private:
inline static std::vector<std::string> search_categories;
inline static std::string selected_item = "All";
struct Cutscene
{
inline static CJson json = CJson("cutscene");
inline static ImGuiTextFilter filter = "";
inline static std::vector<std::string> categories;
inline static std::string selected = "All";
inline static std::string scene_name = "";
inline static int interior = 0;
inline static bool running = false;
};
inline static char anim_buffer[INPUT_BUFFER_SIZE] = "";
inline static char ifp_buffer[INPUT_BUFFER_SIZE] = "";
@ -26,6 +38,7 @@ protected:
public:
static void Draw();
static void PlayAnimation(std::string& rootkey, std::string& anim, std::string& ifp);
static void PlayCutscene(std::string& rootkey, std::string& cutscene_str, std::string& interior);
static void RemoveAnimation(std::string& rootkey, std::string& anim, std::string& ifp);
};

View File

@ -0,0 +1,149 @@
{
"All":
{
"bcesa4w" : "0",
"bcesa5w" : "0",
"bcesar2" : "2",
"bcesar4" : "0",
"bcesar5" : "0",
"bcras1" : "0",
"bcras2" : "0",
"bhill1" : "0",
"bhill2" : "5",
"bhill3a" : "5",
"bhill3b" : "0",
"bhill3c" : "0",
"bhill5a" : "5",
"bhill5b" : "3",
"cas6b_1" : "1",
"cas6b_2" : "1",
"cas_11a" : "2",
"cas_1a" : "11",
"cas_2" : "0",
"cas_3" : "11",
"cas_4a" : "0",
"cas_4b" : "0",
"cas_4c" : "2",
"cas_5a" : "2",
"cas_6a" : "2",
"cas_7b" : "11",
"cas_9a1" : "2",
"cas_9a2" : "0",
"cat_2" : "0",
"cat_3" : "0",
"cat_4" : "0",
"cesar1a" : "0",
"crash1a" : "17",
"crash3a" : "0",
"crashv1" : "0",
"d10_alt" : "0",
"d8_alt" : "0",
"date1a" : "10",
"date3a" : "4",
"date3b" : "4",
"date5a" : "6",
"date5b" : "6",
"date2a" : "9",
"date2b" : "9",
"date4a" : "5",
"date4b" : "5",
"date1b" : "5",
"date6a" : "5",
"date6b" : "17",
"desert1" : "0",
"desert2" : "0",
"desert3" : "0",
"desert4" : "0",
"desert6" : "0",
"desert8" : "0",
"desert9" : "0",
"des_10a" : "0",
"des_10b" : "0",
"doc_2" : "0",
"epilog" : "3",
"farl_2a" : "3",
"farl_3a" : "3",
"farl_3b" : "0",
"farl_4a" : "1",
"farl_5a" : "1",
"final1a" : "1",
"final2a" : "1",
"final2b" : "0",
"garag1b" : "1",
"garag1c" : "1",
"garag3a" : "1",
"grove1a" : "3",
"grove1b" : "3",
"grove1c" : "2",
"grove2" : "1",
"heist1a" : "10",
"heist2a" : "10",
"heist4a" : "10",
"heist5a" : "10",
"heist6a" : "10",
"heist8a" : "0",
"intro1a" : "3",
"intro1b" : "0",
"intro2a" : "2",
"prolog1" : "14",
"prolog3" : "0",
"riot4e1" : "0",
"riot4e2" : "0",
"riot_1a" : "5",
"riot_1b" : "5",
"riot_2" : "1",
"riot_4a" : "1",
"riot_4b" : "0",
"riot_4c" : "2",
"riot_4d" : "2",
"ryder1a" : "0",
"ryder2a" : "0",
"ryder3a" : "2",
"scrash1" : "1",
"scrash2" : "1",
"smoke1a" : "0",
"smoke1b" : "0",
"smoke2a" : "0",
"smoke2b" : "0",
"smoke3a" : "0",
"smoke4a" : "0",
"steal_1" : "1",
"steal_2" : "1",
"steal_4" : "1",
"steal_5" : "1",
"strap1a" : "0",
"strap2a" : "10",
"strap3a" : "10",
"strap4a" : "0",
"strp4b1" : "3",
"strp4b2" : "0",
"sweet1a" : "0",
"sweet1b" : "1",
"sweet1c" : "3",
"sweet2a" : "0",
"sweet2b" : "0",
"sweet3a" : "1",
"sweet3b" : "0",
"sweet4a" : "0",
"sweet5a" : "1",
"sweet6a" : "1",
"sweet6b" : "0",
"sweet7a" : "0",
"synd_2a" : "1",
"synd_2b" : "3",
"synd_3a" : "0",
"synd_4a" : "1",
"synd_4b" : "0",
"synd_7" : "1",
"truth_1" : "12",
"truth_2" : "0",
"w2_alt" : "1",
"woozi1a" : "1",
"woozi1b" : "1",
"woozie2" : "1",
"woozie4" : "1",
"zero_1" : "6",
"zero_2" : "6",
"zero_4" : "6"
}
}

View File

@ -420,7 +420,55 @@
"Oyster 8": "0, 1249, -2687, -1",
"Oyster 9": "0, 725, -1849, -5"
},
"Radar": null,
"Radar": {
"Cj sprite, Ganton, LS": "0, 2495.214355, -1687.029785, 12.514400",
"No sprite, Blueberry Acres, LS": "0, 0.000000, 0.000000, 0.000000",
"Propertyg sprite, Jefferson, LS": "0, 2103.345947, -1288.338867, 23.816799",
"Propertyg sprite, Mulholland, LS": "0, 1331.185547, -630.496216, 108.634903",
"Propertyg sprite, Santa Maria Beach, LS": "0, 316.069611, -1772.568848, 4.189300",
"Propertyg sprite, Verdant Bluffs, LS": "0, 1687.980469, -2100.643066, 13.334300",
"Propertyg sprite, Verona Beach, LS": "0, 892.666199, -1639.713867, 14.456700",
"Propertyg sprite, Willowfield, LS": "0, 2483.023682, -2001.074097, 13.054000",
"Propertyr sprite, Angel Pine, LS": "0, -2079.096924, -2309.898682, 30.117201",
"Propertyr sprite, Blueberry, LS": "0, 206.800003, -112.099998, 4.396500",
"Propertyr sprite, Calton Heights, LS": "0, -2106.639160, 900.553711, 76.203201",
"Propertyr sprite, Chinatown, LS": "0, -2213.864258, 723.558716, 48.914001",
"Propertyr sprite, Creek, LS": "0, 2819.125488, 2149.371826, 10.320300",
"Propertyr sprite, Dillimore, LS": "0, 793.562317, -514.411621, 16.397301",
"Propertyr sprite, Doherty, LS": "0, -2027.829956, -44.045399, 38.769199",
"Propertyr sprite, Downtown, LS": "0, -1969.270020, 282.470001, 34.599998",
"Propertyr sprite, El Quebrados, LS": "0, -1534.170288, 2650.300049, 55.343700",
"Propertyr sprite, Fort Carson, LS": "0, -366.184906, 1166.030518, 19.242201",
"Propertyr sprite, Garcia, LS": "0, -2243.620117, 133.199997, 34.799999",
"Propertyr sprite, Hashbury, LS": "0, -2456.925537, -131.329193, 25.537600",
"Propertyr sprite, Old Venturas Strip, LS": "0, 2370.477295, 2165.474365, 10.326900",
"Propertyr sprite, Palomino Creek, LS": "0, 2236.927979, 162.805695, 26.846201",
"Propertyr sprite, Paradiso, LS": "0, -2695.745117, 818.471802, 49.484402",
"Propertyr sprite, Pirates in Men's Pants, LS": "0, 1969.932495, 1623.242920, 12.361900",
"Propertyr sprite, Prickle Pine, LS": "0, 1283.843872, 2528.702881, 10.320300",
"Propertyr sprite, Queens, LS": "0, -2419.676758, 334.162109, 34.679600",
"Propertyr sprite, Redsands West, LS": "0, 1402.317383, 1901.978271, 10.844900",
"Propertyr sprite, Rockshore West, LS": "0, 2441.002197, 695.108887, 10.664600",
"Propertyr sprite, The Camel's Toe, LS": "0, 2234.908691, 1285.698120, 10.320300",
"Propertyr sprite, The Clown's Pocket, LS": "0, 2220.625732, 1837.347534, 10.320300",
"Propertyr sprite, Tierra Robada, LS": "0, -1045.775146, 1552.976318, 32.798000",
"Propertyr sprite, Verdant Meadows, LS": "0, 426.497192, 2530.688965, 16.100000",
"Propertyr sprite, Whetstone, LS": "0, -1439.014038, -1540.590088, 101.257896",
"Propertyr sprite, Whitewood Estates, LS": "0, 922.364685, 2011.898438, 10.766000",
"Race sprite, Blackfield, LS": "0, 1099.551270, 1601.497437, 11.554600",
"Race sprite, East Beach, LS": "0, 2695.624268, -1704.688477, 10.843700",
"Race sprite, Foster Valley, LS": "0, -2120.041748, -444.283813, 34.531200",
"Sprayshop sprite, Dillimore, LS": "0, 720.015991, -454.625000, 15.328000",
"Sprayshop sprite, Downtown, LS": "0, -1908.900024, 292.299988, 40.000000",
"Sprayshop sprite, El Quebrados, LS": "0, -1420.546997, 2583.945068, 58.030998",
"Sprayshop sprite, Fort Carson, LS": "0, -103.599998, 1112.400024, 18.700001",
"Sprayshop sprite, Idlewood, LS": "0, 2067.399902, -1831.199951, 13.500000",
"Sprayshop sprite, Juniper Hollow, LS": "0, -2425.459961, 1020.830017, 49.389999",
"Sprayshop sprite, Redsands East, LS": "0, 1966.531982, 2162.649902, 10.995000",
"Sprayshop sprite, Santa Maria Beach, LS": "0, 488.000000, -1734.000000, 34.400002",
"Sprayshop sprite, Temple, LS": "0, 1021.799988, -1018.700012, 30.900000",
"Waypoint sprite, Los Flores, LS": "0, 2623.328613, -1228.941040, 0.000000"
},
"Snapshots": {
"Snapshot 1": "0, -2511.28, -672.99, 195.75",
"Snapshot 10": "0, -2773.04, 783.45, 67.66",

File diff suppressed because one or more lines are too long

View File

@ -289,8 +289,8 @@ void Game::ClearFreecamStuff()
void Game::Draw()
{
ImGui::Spacing();
static CPlayerPed* player = FindPlayerPed();
static int hplayer = CPools::GetPedRef(player);
CPlayerPed* player = FindPlayerPed();
int hplayer = CPools::GetPedRef(player);
if (ImGui::BeginTabBar("Game", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll))
{

View File

@ -1,6 +1,7 @@
#include "pch.h"
#include "Util.h"
#include "../Depend/imgui/stb_image.h"
#include <CCutsceneMgr.h>
void Util::ClearCharTasksVehCheck(CPed* ped)
{
@ -124,6 +125,11 @@ bool Util::IsOnMission()
return FindPlayerPed()->CanPlayerStartMission() && !*(patch::Get<char*>(0x5D5380, false) + CTheScripts::OnAMissionFlag);
}
bool Util::IsOnCutscene()
{
return CCutsceneMgr::ms_running;
}
std::string Util::GetLocationName(CVector* pos)
{
int hplayer = CPools::GetPedRef(FindPlayerPed());

View File

@ -12,6 +12,7 @@ public:
static int GetLargestGangInZone();
static void LoadTexturesInDirRecursive(const char * path, const char * file_ext, std::vector<std::string>& category_vec, std::vector<std::unique_ptr<TextureStructure>> &store_vec);
static void ReleaseTextures(std::vector<std::unique_ptr<TextureStructure>> &store_vec);
static bool IsOnCutscene();
static bool IsOnMission();
static std::string GetLocationName(CVector *pos);
static void RainbowValues(int &r, int&g, int &b, float speed);