[III] Finish vehicle tab
This commit is contained in:
parent
525f426725
commit
e74089ec74
@ -61,8 +61,7 @@ void FileHandler::GenerateHandlingFile(int pHandling, std::map<int, std::string>
|
|||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileHandler::FetchColorData(std::vector<std::vector<float>>& storeVec,
|
void FileHandler::FetchColorData(std::vector<std::vector<float>>& storeVec)
|
||||||
std::map<std::string, std::vector<int>>& storeMap)
|
|
||||||
{
|
{
|
||||||
std::string m_FilePath = GAME_PATH((char*)"/data/carcols.dat");
|
std::string m_FilePath = GAME_PATH((char*)"/data/carcols.dat");
|
||||||
|
|
||||||
@ -129,37 +128,6 @@ void FileHandler::FetchColorData(std::vector<std::vector<float>>& storeVec,
|
|||||||
gLog << "Error parsing carcols.dat, " << line << std::endl;
|
gLog << "Error parsing carcols.dat, " << line << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bIsCar)
|
|
||||||
{
|
|
||||||
std::string temp;
|
|
||||||
std::stringstream ss(line);
|
|
||||||
|
|
||||||
// Format: modelname, colorindex1, colorindex2,...
|
|
||||||
getline(ss, temp, ',');
|
|
||||||
std::string name = temp;
|
|
||||||
while (getline(ss, temp, ','))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
std::for_each(name.begin(), name.end(), [](char& c)
|
|
||||||
{
|
|
||||||
c = ::toupper(c);
|
|
||||||
});
|
|
||||||
|
|
||||||
int val = std::stoi(temp);
|
|
||||||
if (!(std::find(storeMap[name].begin(), storeMap[name].end(), val) !=
|
|
||||||
storeMap[name].end()))
|
|
||||||
{
|
|
||||||
storeMap[name].push_back(val);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
gLog << "Error parsing carcols.dat, " << line << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
|
@ -10,11 +10,10 @@ public:
|
|||||||
FileHandler(FileHandler&) = delete;
|
FileHandler(FileHandler&) = delete;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Parses data/carcols.dat file and stores color data per vehicle
|
Parses data/carcols.dat file and stores color data
|
||||||
TODO: Implement something that also parses modloader data
|
TODO: Implement something that also parses modloader data
|
||||||
*/
|
*/
|
||||||
static void FetchColorData(std::vector<std::vector<float>>& storeVec,
|
static void FetchColorData(std::vector<std::vector<float>>& storeVec);
|
||||||
std::map<std::string, std::vector<int>>& storeMap);
|
|
||||||
/*
|
/*
|
||||||
Parses data/vehicles.ide file and stores handingId in a map
|
Parses data/vehicles.ide file and stores handingId in a map
|
||||||
TODO: Implement something that also parses modloader data
|
TODO: Implement something that also parses modloader data
|
||||||
|
@ -36,7 +36,7 @@ Vehicle::Vehicle()
|
|||||||
#ifdef GTASA
|
#ifdef GTASA
|
||||||
FileHandler::FetchHandlingID(m_VehicleIDE);
|
FileHandler::FetchHandlingID(m_VehicleIDE);
|
||||||
#endif
|
#endif
|
||||||
FileHandler::FetchColorData(m_CarcolsColorData, m_CarcolsCarData);
|
FileHandler::FetchColorData(m_CarcolsColorData);
|
||||||
|
|
||||||
Events::processScriptsEvent += [this]
|
Events::processScriptsEvent += [this]
|
||||||
{
|
{
|
||||||
@ -335,8 +335,6 @@ void Vehicle::SpawnVehicle(std::string& rootkey, std::string& vehName, std::stri
|
|||||||
|
|
||||||
int interior = BY_GAME(player->m_nAreaCode, player->m_nInterior, 0);
|
int interior = BY_GAME(player->m_nAreaCode, player->m_nInterior, 0);
|
||||||
|
|
||||||
if (Command<Commands::IS_MODEL_AVAILABLE>(imodel))
|
|
||||||
{
|
|
||||||
CVector pos = player->GetPosition();
|
CVector pos = player->GetPosition();
|
||||||
int speed = 0;
|
int speed = 0;
|
||||||
|
|
||||||
@ -486,18 +484,15 @@ void Vehicle::SpawnVehicle(std::string& rootkey, std::string& vehName, std::stri
|
|||||||
#else // GTA3 & GTAVC
|
#else // GTA3 & GTAVC
|
||||||
Command<Commands::RESTORE_CAMERA_JUMPCUT>();
|
Command<Commands::RESTORE_CAMERA_JUMPCUT>();
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Vehicle::GetNameFromModel(int model)
|
std::string Vehicle::GetNameFromModel(int model)
|
||||||
{
|
{
|
||||||
CBaseModelInfo* info;
|
#ifdef GTA3
|
||||||
#ifdef GTASA
|
return std::to_string(model);
|
||||||
info = CModelInfo::GetModelInfo(model);
|
|
||||||
#else
|
#else
|
||||||
info = CModelInfo::ms_modelInfoPtrs[model];
|
return (const char*)CModelInfo::GetModelInfo(model) + 0x32;
|
||||||
#endif
|
#endif
|
||||||
return (const char*)info + 0x32;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Vehicle::GetModelFromName(const char* name)
|
int Vehicle::GetModelFromName(const char* name)
|
||||||
@ -522,7 +517,7 @@ void Vehicle::Draw()
|
|||||||
int hplayer = CPools::GetPedRef(pPlayer);
|
int hplayer = CPools::GetPedRef(pPlayer);
|
||||||
CVehicle *pVeh = pPlayer->m_pVehicle;
|
CVehicle *pVeh = pPlayer->m_pVehicle;
|
||||||
|
|
||||||
if (ImGui::Button("Blow up cars", ImVec2(Ui::GetSize(BY_GAME(3,2)))))
|
if (ImGui::Button("Blow up cars", ImVec2(Ui::GetSize(BY_GAME(3,2,2)))))
|
||||||
{
|
{
|
||||||
for (CVehicle *pVeh : CPools::ms_pVehiclePool)
|
for (CVehicle *pVeh : CPools::ms_pVehiclePool)
|
||||||
{
|
{
|
||||||
@ -532,7 +527,7 @@ void Vehicle::Draw()
|
|||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
|
||||||
if (ImGui::Button("Fix vehicle", ImVec2(Ui::GetSize(BY_GAME(3,2)))))
|
if (ImGui::Button("Fix vehicle", ImVec2(Ui::GetSize(BY_GAME(3,2,2)))))
|
||||||
{
|
{
|
||||||
if (pPlayer && pVeh)
|
if (pPlayer && pVeh)
|
||||||
{
|
{
|
||||||
@ -802,7 +797,10 @@ void Vehicle::Draw()
|
|||||||
{
|
{
|
||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
ImGui::BeginChild("MenusChild");
|
ImGui::BeginChild("MenusChild");
|
||||||
|
|
||||||
|
#ifdef GTASA
|
||||||
Ui::EditAddress<float>("Density multiplier", 0x8A5B20, 0, 1, 10);
|
Ui::EditAddress<float>("Density multiplier", 0x8A5B20, 0, 1, 10);
|
||||||
|
#endif
|
||||||
if (ImGui::CollapsingHeader("Enter nearest vehicle as"))
|
if (ImGui::CollapsingHeader("Enter nearest vehicle as"))
|
||||||
{
|
{
|
||||||
int hplayer = CPools::GetPedRef(pPlayer);
|
int hplayer = CPools::GetPedRef(pPlayer);
|
||||||
@ -829,6 +827,7 @@ void Vehicle::Draw()
|
|||||||
Command<Commands::WARP_CHAR_INTO_CAR>(hplayer, pClosestVeh);
|
Command<Commands::WARP_CHAR_INTO_CAR>(hplayer, pClosestVeh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef GTA3
|
||||||
for (int i = 0; i < seats; ++i)
|
for (int i = 0; i < seats; ++i)
|
||||||
{
|
{
|
||||||
if (i % 2 != 1)
|
if (i % 2 != 1)
|
||||||
@ -846,6 +845,7 @@ void Vehicle::Draw()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -865,7 +865,7 @@ void Vehicle::Draw()
|
|||||||
for (CVehicle* pVeh : CPools::ms_pVehiclePool)
|
for (CVehicle* pVeh : CPools::ms_pVehiclePool)
|
||||||
{
|
{
|
||||||
if (DistanceBetweenPoints(pVeh->GetPosition(), player->GetPosition()) < m_nVehRemoveRadius
|
if (DistanceBetweenPoints(pVeh->GetPosition(), player->GetPosition()) < m_nVehRemoveRadius
|
||||||
&& !(BY_GAME(player->m_nPedFlags.bInVehicle, true, true) && player->m_pVehicle == pVeh))
|
&& player->m_pVehicle != pVeh)
|
||||||
{
|
{
|
||||||
Command<Commands::DELETE_CAR>(CPools::GetVehicleRef(pVeh));
|
Command<Commands::DELETE_CAR>(CPools::GetVehicleRef(pVeh));
|
||||||
}
|
}
|
||||||
@ -875,6 +875,7 @@ void Vehicle::Draw()
|
|||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef GTA3
|
||||||
if (ImGui::CollapsingHeader("Traffic options"))
|
if (ImGui::CollapsingHeader("Traffic options"))
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -894,6 +895,7 @@ void Vehicle::Draw()
|
|||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if (pPlayer && pPlayer->m_pVehicle)
|
if (pPlayer && pPlayer->m_pVehicle)
|
||||||
{
|
{
|
||||||
CVehicle* pVeh = pPlayer->m_pVehicle;
|
CVehicle* pVeh = pPlayer->m_pVehicle;
|
||||||
@ -1019,7 +1021,7 @@ void Vehicle::Draw()
|
|||||||
{
|
{
|
||||||
return GetNameFromModel(std::stoi(str));
|
return GetNameFromModel(std::stoi(str));
|
||||||
});
|
});
|
||||||
#elif GTAVC
|
#else // GTA3 & GTAVC
|
||||||
Ui::DrawJSON(m_Spawner::m_VehData, SpawnVehicle, nullptr);
|
Ui::DrawJSON(m_Spawner::m_VehData, SpawnVehicle, nullptr);
|
||||||
#endif
|
#endif
|
||||||
ImGui::EndTabItem();
|
ImGui::EndTabItem();
|
||||||
@ -1061,14 +1063,12 @@ void Vehicle::Draw()
|
|||||||
ImGui::RadioButton("Primary", &m_Color::m_nRadioButton, 1);
|
ImGui::RadioButton("Primary", &m_Color::m_nRadioButton, 1);
|
||||||
ImGui::RadioButton("Secondary", &m_Color::m_nRadioButton, 2);
|
ImGui::RadioButton("Secondary", &m_Color::m_nRadioButton, 2);
|
||||||
ImGui::NextColumn();
|
ImGui::NextColumn();
|
||||||
ImGui::Checkbox("Show all", &m_Color::bShowAll);
|
ImGui::NewLine();
|
||||||
ImGui::RadioButton("Tertiary", &m_Color::m_nRadioButton, 3);
|
ImGui::RadioButton("Tertiary", &m_Color::m_nRadioButton, 3);
|
||||||
ImGui::RadioButton("Quaternary", &m_Color::m_nRadioButton, 4);
|
ImGui::RadioButton("Quaternary", &m_Color::m_nRadioButton, 4);
|
||||||
#elif GTAVC
|
#else // GTA3 & GTAVC
|
||||||
ImGui::Checkbox("Show all", &m_Color::bShowAll);
|
|
||||||
ImGui::RadioButton("Primary", &m_Color::m_nRadioButton, 1);
|
ImGui::RadioButton("Primary", &m_Color::m_nRadioButton, 1);
|
||||||
ImGui::NextColumn();
|
ImGui::NextColumn();
|
||||||
ImGui::NewLine();
|
|
||||||
ImGui::RadioButton("Secondary", &m_Color::m_nRadioButton, 2);
|
ImGui::RadioButton("Secondary", &m_Color::m_nRadioButton, 2);
|
||||||
#endif
|
#endif
|
||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
@ -1085,13 +1085,11 @@ void Vehicle::Draw()
|
|||||||
|
|
||||||
ImGui::BeginChild("Colorss");
|
ImGui::BeginChild("Colorss");
|
||||||
|
|
||||||
if (m_Color::bShowAll)
|
|
||||||
{
|
|
||||||
for (int colorId = 0; colorId < count; ++colorId)
|
for (int colorId = 0; colorId < count; ++colorId)
|
||||||
{
|
{
|
||||||
if (Ui::ColorButton(colorId, m_CarcolsColorData[colorId], ImVec2(btnSize, btnSize)))
|
if (Ui::ColorButton(colorId, m_CarcolsColorData[colorId], ImVec2(btnSize, btnSize)))
|
||||||
{
|
{
|
||||||
*(uint8_replacement*)(int(veh) + BY_GAME(0x433, 0x19F) + m_Color::m_nRadioButton) = colorId;
|
*(uint8_replacement*)(int(veh) + BY_GAME(0x433, 0x19F, 0x19B) + m_Color::m_nRadioButton) = colorId;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((colorId + 1) % btnsInRow != 0)
|
if ((colorId + 1) % btnsInRow != 0)
|
||||||
@ -1099,34 +1097,6 @@ void Vehicle::Draw()
|
|||||||
ImGui::SameLine(0.0, 4.0);
|
ImGui::SameLine(0.0, 4.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::string vehName = GetNameFromModel(pPlayer->m_pVehicle->m_nModelIndex);
|
|
||||||
for (auto entry : m_CarcolsCarData)
|
|
||||||
{
|
|
||||||
if (entry.first == vehName)
|
|
||||||
{
|
|
||||||
int count = 1;
|
|
||||||
for (int colorId : entry.second)
|
|
||||||
{
|
|
||||||
if (Ui::ColorButton(colorId, m_CarcolsColorData[colorId],
|
|
||||||
ImVec2(btnSize, btnSize)))
|
|
||||||
{
|
|
||||||
*(uint8_replacement*)(int(veh) + BY_GAME(0x433, 0x19F) + m_Color::m_nRadioButton) = colorId;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count % btnsInRow != 0)
|
|
||||||
{
|
|
||||||
ImGui::SameLine(0.0, 4.0);
|
|
||||||
}
|
|
||||||
++count;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
ImGui::EndTabItem();
|
ImGui::EndTabItem();
|
||||||
|
@ -24,12 +24,10 @@ private:
|
|||||||
static inline bool m_bLockSpeed;
|
static inline bool m_bLockSpeed;
|
||||||
static inline float m_fLockSpeed;
|
static inline float m_fLockSpeed;
|
||||||
static inline std::vector<std::vector<float>> m_CarcolsColorData;
|
static inline std::vector<std::vector<float>> m_CarcolsColorData;
|
||||||
static inline std::map<std::string, std::vector<int>> m_CarcolsCarData;
|
|
||||||
struct m_Color
|
struct m_Color
|
||||||
{
|
{
|
||||||
static inline bool m_bMatFilter = true;
|
static inline bool m_bMatFilter = true;
|
||||||
static inline int m_nRadioButton = 1;
|
static inline int m_nRadioButton = 1;
|
||||||
static inline bool bShowAll;
|
|
||||||
static inline float m_fColorPicker[3]{ 0, 0, 0 };
|
static inline float m_fColorPicker[3]{ 0, 0, 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user