Skip to content

Commit

Permalink
Updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Danilo1301 committed Jul 14, 2024
1 parent 36e0738 commit 279bce9
Show file tree
Hide file tree
Showing 87 changed files with 8,756 additions and 236 deletions.
2 changes: 1 addition & 1 deletion GiroflexVSL/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ include $(CLEAR_VARS)
LOCAL_CPP_EXTENSION := .cpp .cc
LOCAL_CPP_FEATURES += exceptions
LOCAL_MODULE := GiroflexVSL
LOCAL_SRC_FILES := main.cpp mod/logger.cpp mod/config.cpp json_reader.cpp json_value.cpp json_writer.cpp Log.cpp Mod.cpp menu/Draw.cpp menu/Menu.cpp menu/Item.cpp menu/Window.cpp menu/CleoMenu.cpp Input.cpp windows/WindowTest.cpp Vehicles.cpp Vehicle.cpp Globals.cpp LightGroup.cpp ModelInfo.cpp ModelInfos.cpp windows/WindowMain.cpp windows/WindowLightGroups.cpp windows/WindowSettings.cpp windows/WindowEditing.cpp Patterns.cpp LightGroupDatas.cpp windows/WindowWhiteCorona.cpp windows/WindowShadow.cpp windows/WindowPointLight.cpp windows/WindowFlare.cpp ModConfig.cpp iniconfig/INIFile.cpp iniconfig/INISection.cpp SoundSystem.cpp windows/WindowSelectPanel.cpp windows/WindowSoundPanel.cpp windows/SoundPanelButton.cpp windows/WindowSoundPanelSettings.cpp windows/WindowPanel.cpp ConvertOldVersion.cpp windows/WindowRotate.cpp audiosystem.cpp SirenSystem.cpp Widgets.cpp GiroflexVSL.cpp VehicleDummy.cpp windows/WindowLed.cpp
LOCAL_SRC_FILES := main.cpp mod/logger.cpp mod/config.cpp json_reader.cpp json_value.cpp json_writer.cpp Log.cpp Mod.cpp menu/Draw.cpp menu/Menu.cpp menu/Item.cpp menu/Window.cpp menu/CleoMenu.cpp Input.cpp windows/WindowTest.cpp Vehicles.cpp Vehicle.cpp Globals.cpp LightGroup.cpp ModelInfo.cpp ModelInfos.cpp windows/WindowMain.cpp windows/WindowLightGroups.cpp windows/WindowSettings.cpp windows/WindowEditing.cpp Patterns.cpp LightGroupDatas.cpp windows/WindowWhiteCorona.cpp windows/WindowShadow.cpp windows/WindowPointLight.cpp windows/WindowFlare.cpp ModConfig.cpp iniconfig/INIFile.cpp iniconfig/INISection.cpp SoundSystem.cpp windows/WindowSelectPanel.cpp windows/WindowSoundPanel.cpp windows/SoundPanelButton.cpp windows/WindowSoundPanelSettings.cpp windows/WindowPanel.cpp ConvertOldVersion.cpp windows/WindowRotate.cpp audiosystem.cpp SirenSystem.cpp Widgets.cpp GiroflexVSL.cpp VehicleDummy.cpp windows/WindowLed.cpp sdk/Image.cpp
LOCAL_CFLAGS += -O2 -mfloat-abi=softfp -DNDEBUG -std=c++17
LOCAL_C_INCLUDES += ./include
LOCAL_LDLIBS += -llog
Expand Down
33 changes: 33 additions & 0 deletions GiroflexVSL/LightGroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "pch.h"

#include "Point.h"
#include "LightGroupRotateObject.h"

class LightGroup {
public:
Expand Down Expand Up @@ -64,8 +65,13 @@ class LightGroup {
float rotateAngle = 0.0f;

bool useLightbarLEDs = false;
int lightbarLEDStartIndex = 1;
bool useNormalLEDs = false;
int normalLEDStartIndex = 1;
CRGBA ledColorEnabled = CRGBA(255, 255, 255);
CRGBA ledColorDisabled = CRGBA(0, 0, 0);

LightGroupRotateObject rotateObject;

LightGroup() {}

Expand Down Expand Up @@ -180,6 +186,19 @@ class LightGroup {
value["useNormalLEDs"] = useNormalLEDs;
value["normalLEDStartIndex"] = normalLEDStartIndex;

value["ledColorEnabled"] = ColorToJSON(ledColorEnabled);
value["ledColorDisabled"] = ColorToJSON(ledColorDisabled);

//rotate object
Json::Value rotateObjectValue = Json::objectValue;
rotateObjectValue["speed"] = rotateObject.speed;
rotateObjectValue["objects"] = Json::arrayValue;
for(auto object : rotateObject.objects)
{
rotateObjectValue["objects"].append(object);
}
value["rotateObject"] = rotateObjectValue;

return value;
}

Expand Down Expand Up @@ -248,5 +267,19 @@ class LightGroup {
useLightbarLEDs = ValidateValue(value["useLightbarLEDs"], useLightbarLEDs).asBool();
useNormalLEDs = ValidateValue(value["useNormalLEDs"], useNormalLEDs).asBool();
normalLEDStartIndex = ValidateValue(value["normalLEDStartIndex"], normalLEDStartIndex).asInt();

ledColorEnabled = ValidateColor(value["ledColorEnabled"], ledColorEnabled);
ledColorDisabled = ValidateColor(value["ledColorDisabled"], ledColorDisabled);

//rotate object
Json::Value rotateObjectValue = value["rotateObject"];
rotateObject.speed = ValidateValue(rotateObjectValue["speed"], rotateObject.speed).asInt();

rotateObject.objects.clear();
for (int i = 0; i < (int)rotateObjectValue["objects"].size(); i++)
{
auto object = rotateObjectValue["objects"][i].asString();
rotateObject.objects.push_back(object);
}
}
};
17 changes: 17 additions & 0 deletions GiroflexVSL/LightGroupRotateObject.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once

#include "pch.h"

enum class eRotateObjectAxis {
X,
Y,
Z
};

struct LightGroupRotateObject {
bool rotate = true;
bool rotateAlways = true;
float speed = 5.0f;
eRotateObjectAxis axis = eRotateObjectAxis::Z;
std::vector<std::string> objects;
};
2 changes: 1 addition & 1 deletion GiroflexVSL/Mod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ extern RpClump* (*RpClumpForAllAtomics)(RpClump* clump, RpAtomicCallBack callbac
extern RpGeometry* (*RpGeometryForAllMaterials)(RpGeometry* geometry, RpMaterialCallBack fpCallBack, void* pData);
extern char* (*GetFrameNodeName)(RwFrame* frame);

const char* Mod::m_Version = "3.5.0";
const char* Mod::m_Version = "3.6.0";

bool canTurnSirenOn = true;
bool canTurnPanelOn = true;
Expand Down
10 changes: 8 additions & 2 deletions GiroflexVSL/ModConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "SirenSystem.h"

#include "windows/WindowSoundPanel.h"
#include "windows/WindowPanel.h"

#include "iniconfig/INIFile.h"

Expand Down Expand Up @@ -197,15 +198,19 @@ void ModConfig::SaveSettings()
generalSection->AddIntFromBool("ignore_message_old_version", ModConfig::IgnoreOldModVersionMessage);
generalSection->AddIntFromBool("turn_on_lights_with_siren", ModConfig::TurnOnLightsWithSiren);
generalSection->AddIntFromBool("enable_deep_log", Log::deepLogEnabled);
generalSection->AddFloat("volume_sirens", SirenSystem::m_VolumeSirens);
generalSection->AddFloat("volume_radio", SirenSystem::m_VolumeRadio);

generalSection->AddLine("");
generalSection->AddLine("; Fixes the loud siren sound when camera gets closer to vehicle (or when your camera is inside the vehicle)");
generalSection->AddLine("; 0 = disabled | 1 = enabled");
generalSection->AddIntFromBool("fix_loud_siren_sounds", SirenSystem::FixLoudSounds);
generalSection->AddLine("");

generalSection->AddFloat("volume_sirens", SirenSystem::m_VolumeSirens);
generalSection->AddFloat("volume_radio", SirenSystem::m_VolumeRadio);

generalSection->AddInt("amount_of_panel_slots", WindowPanel::NumOfSlots);


auto soundPanelSection = file.AddSection("SoundPanel");
soundPanelSection->AddIntFromBool("allow_multiple_sound", WindowSoundPanel::m_allowMultipleSounds);
soundPanelSection->AddIntFromBool("show_on_enter_vehicle", WindowSoundPanel::m_showOnEnterVehicle);
Expand Down Expand Up @@ -338,6 +343,7 @@ void ModConfig::LoadSettings()
generalSection->GetBoolFromInt("fix_loud_siren_sounds", &SirenSystem::FixLoudSounds);
generalSection->GetFloat("volume_sirens", &SirenSystem::m_VolumeSirens);
generalSection->GetFloat("volume_radio", &SirenSystem::m_VolumeRadio);
generalSection->GetInt("amount_of_panel_slots", &WindowPanel::NumOfSlots);
}

auto soundPanelSections = file.GetSections("SoundPanel");
Expand Down
59 changes: 29 additions & 30 deletions GiroflexVSL/Vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "windows/WindowEditing.h"

extern void* (*GetVehicleFromRef)(int);
extern RwMatrix* (*RwMatrixRotate)(RwMatrix* matrix, const RwV3d* axis, RwReal angle, RwOpCombineType combineOp);

static std::list<std::pair<unsigned int *, unsigned int>> resetEntries;

Expand Down Expand Up @@ -389,6 +390,27 @@ void Vehicle::RenderBefore()

//Log::Level(LOG_LEVEL::LOG_BOTH) << "name: " << name << std::endl;

//rotate objects
for (auto lightGroup : modelInfo->lightGroups)
{
if(!StringVectorContainsString(lightGroup->rotateObject.objects, to_lower(name)))
{
continue;
}

auto axisVal = lightGroup->rotateObject.axis;

RwV3d axis = {
(float)(axisVal == eRotateObjectAxis::X ? 1 : 0),
(float)(axisVal == eRotateObjectAxis::Y ? 1 : 0),
(float)(axisVal == eRotateObjectAxis::Z ? 1 : 0)
};
RwReal angle = lightGroup->rotateObject.speed;

RwMatrixRotate(&frameAtomic->modelling, &axis, angle, rwCOMBINEPRECONCAT);
}

//leds
for (auto lightGroup : modelInfo->lightGroups)
{
if(!lightGroup->useLightbarLEDs && !lightGroup->useNormalLEDs) continue;
Expand All @@ -406,18 +428,20 @@ void Vehicle::RenderBefore()

if(lightGroup->useLightbarLEDs)
{
if (to_lower(name).compare(to_lower("lightbar-led-" + std::to_string(i + 1))) != 0) continue;
int ledIndex = i + lightGroup->lightbarLEDStartIndex;

if (to_lower(name).compare(to_lower("lightbar-led-" + std::to_string(ledIndex))) != 0) continue;
}

if(lightGroup->useNormalLEDs)
{
int normalLedIndex = i + lightGroup->normalLEDStartIndex;
int ledIndex = i + lightGroup->normalLEDStartIndex;

if (to_lower(name).compare(to_lower("led-" + std::to_string(normalLedIndex))) != 0) continue;
if (to_lower(name).compare(to_lower("led-" + std::to_string(ledIndex))) != 0) continue;
}

//color
CRGBA color = CRGBA(255, 255, 255);
CRGBA color = lightGroup->ledColorEnabled;

//
int index = i;
Expand All @@ -437,7 +461,7 @@ void Vehicle::RenderBefore()

if (!enabled)
{
color = CRGBA(0, 0, 0, 255);
color = lightGroup->ledColorDisabled;
}

auto materials = VehicleDummy::RpGeometryGetAllMaterials(atomic->geometry);
Expand All @@ -456,31 +480,6 @@ void Vehicle::RenderBefore()
}
}

/*
if(name.find("lightbar-led-") == std::string::npos) continue;
auto materials = VehicleDummy::RpGeometryGetAllMaterials(atomic->geometry);
for (auto material : materials)
{
//if (!material) continue;
resetEntries.push_back(std::make_pair(reinterpret_cast<unsigned int *>(&material->color), *reinterpret_cast<unsigned int *>(&material->color)));
if(ledsTime < 1000)
{
material->color = { 255, 255, 255, 255 };
} else {
material->color = { 0, 0, 0, 255 };
}
resetEntries.push_back(std::make_pair(reinterpret_cast<unsigned int *>(&material->surfaceProps), *reinterpret_cast<unsigned int *>(&material->surfaceProps)));
material->surfaceProps.ambient = 10;
material->surfaceProps.diffuse = 10;
material->surfaceProps.specular = 10;
}
*/

void Vehicle::RenderAfter()
{
for (auto &p : resetEntries)
Expand Down
Loading

0 comments on commit 279bce9

Please sign in to comment.