Skip to content

Commit

Permalink
Updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Danilo1301 committed Aug 21, 2024
1 parent 716b630 commit c89248f
Show file tree
Hide file tree
Showing 16 changed files with 81 additions and 15 deletions.
3 changes: 1 addition & 2 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"/include"
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
Expand Down
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.7.3";
const char* Mod::m_Version = "3.8.0";

bool canTurnSirenOn = true;
bool canTurnPanelOn = true;
Expand Down
32 changes: 26 additions & 6 deletions GiroflexVSL/Pattern.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@

#include "pch.h"

#include "Log.h"

#include <vector>

struct PatternStep {
std::vector<int> data;
int duration = 0;

bool useCustomColor = false;
CRGBA customColor = CRGBA(255, 0, 0);

bool useCustomLedColor = false;
CRGBA customLedColor = CRGBA(255, 0, 0);
};

class Pattern {
Expand Down Expand Up @@ -62,6 +70,12 @@ class Pattern {
stepValue["data"].append(d);
}

stepValue["useCustomColor"] = step->useCustomColor;
stepValue["customColor"] = ColorToJSON(step->customColor);

stepValue["useCustomLedColor"] = step->useCustomLedColor;
stepValue["customLedColor"] = ColorToJSON(step->customLedColor);

value["steps"].append( stepValue );
}

Expand All @@ -72,19 +86,25 @@ class Pattern {
{
for (int step_i = 0; step_i < (int)value["steps"].size(); step_i++)
{
Json::Value step = value["steps"][step_i];
Json::Value stepValue = value["steps"][step_i];

int duration = step["duration"].asInt();
int duration = stepValue["duration"].asInt();

if (duration <= 0) continue;

std::vector<int> data;
for (int val_i = 0; val_i < (int)step["data"].size(); val_i++)
for (int val_i = 0; val_i < (int)stepValue["data"].size(); val_i++)
{
data.push_back(step["data"][val_i].asInt());
data.push_back(stepValue["data"][val_i].asInt());
}

AddStep(data, duration);
auto step = AddStep(data, duration);

step->useCustomColor = ValidateValue(stepValue["useCustomColor"], step->useCustomColor).asBool();
step->customColor = ValidateColor(stepValue["customColor"], step->customColor);

step->useCustomLedColor = ValidateValue(stepValue["useCustomLedColor"], step->useCustomLedColor).asBool();
step->customLedColor = ValidateColor(stepValue["customLedColor"], step->customColor);
}
}
};
};
19 changes: 19 additions & 0 deletions GiroflexVSL/SirenSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ bool SirenSystem::FixLoudSounds = true;
float SirenSystem::m_VolumeSirens = 1.0f;
float SirenSystem::m_VolumeRadio = 3.0f;

CAudioStream* SirenSystem::m_AudioSirenToggle = NULL;

extern IBASS* BASS;
extern CCamera* camera;

Expand Down Expand Up @@ -226,6 +228,14 @@ SirenGroup* SirenSystem::GetCurrentVehicleSoundGroup()
return GetSirenGroupForModelId(GetCurrentVehicleModelId());
}

void SirenSystem::PlaySirenToggleSound()
{
if(m_AudioSirenToggle->GetState() != AudioStreamState::STREAM_STOPPED)
m_AudioSirenToggle->Stop();

m_AudioSirenToggle->Play();
}

//--------------------------------------

SirenSystem::SirenSystem(int hVehicle)
Expand All @@ -237,6 +247,15 @@ void SirenSystem::LoadAudios()
{
Log::Level(LOG_LEVEL::LOG_BOTH) << "SirenSystem: LoadAudios" << std::endl;

// load siren toggle sounds

if(!m_AudioSirenToggle)
{
m_AudioSirenToggle = SoundSystem::LoadStreamFromAudiosFolder("/siren_toggle.wav", false);
}

//

auto vehicle = Vehicles::GetVehicleByHandle(hVehicle);
auto modelId = vehicle->modelId;

Expand Down
4 changes: 4 additions & 0 deletions GiroflexVSL/SirenSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class SirenSystem {
static float m_VolumeSirens;
static float m_VolumeRadio;

static CAudioStream* m_AudioSirenToggle;

static void Load();
static void LoadConfig();
static void LoadVehicles();
Expand All @@ -49,6 +51,8 @@ class SirenSystem {
static int GetCurrentVehicleModelId();
static SirenGroup* GetCurrentVehicleSoundGroup();

static void PlaySirenToggleSound();

//

int hVehicle = 0;
Expand Down
16 changes: 16 additions & 0 deletions GiroflexVSL/Vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ void Vehicle::Update(int dt)
//player vehicle
if(ModConfig::TurnOnLightsWithSiren)
{
SirenSystem::PlaySirenToggleSound();

SetGiroflexEnabled(gameSirenState);
}
} else {
Expand Down Expand Up @@ -293,6 +295,13 @@ void Vehicle::UpdateLightGroups(int dt)
color = point->customColor;
}

//pattern color
auto step = lightGroupData->GetCurrenetStep();
if(step->useCustomColor)
{
color = step->customColor;
}

//
int index = i;

Expand Down Expand Up @@ -569,6 +578,13 @@ void Vehicle::RenderBefore()
} else {
color = lightGroup->ledColor2Enabled;
}

//pattern color
auto step = lightGroupData->GetCurrenetStep();
if(step->useCustomLedColor)
{
color = step->customLedColor;
}

//
int index = i;
Expand Down
6 changes: 5 additions & 1 deletion GiroflexVSL/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// ---------------------------------------

//MYMODCFG(net.danilo1301.giroflexVSL, GiroflexVSL, Mod::m_Version, Danilo1301) //whoops
MYMODCFG(net.danilo1301.giroflexVSL, GiroflexVSL, 3.7.3, Danilo1301)
MYMODCFG(net.danilo1301.giroflexVSL, GiroflexVSL, 3.8.0, Danilo1301)

// ---------------------------------------

Expand Down Expand Up @@ -548,8 +548,12 @@ extern "C" void OnModLoad()

ModConfig::ProcessVersionChanges_PreConfigLoad();

Log::Level(LOG_LEVEL::LOG_BOTH) << "Mod Load" << std::endl;

ModConfig::Load();

Log::Level(LOG_LEVEL::LOG_BOTH) << "Mod End Load" << std::endl;

if (Patterns::m_Patterns.size() == 0)
{
Patterns::CreateDefaultPatterns();
Expand Down
2 changes: 1 addition & 1 deletion GiroflexVSL/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ static CRGBA ColorFromJSON(Json::Value json) {
color.r = json["r"].asInt();
color.g = json["g"].asInt();
color.b = json["b"].asInt();
color.a = json["a"].asInt();
color.a = json["a"].empty() ? 255 : json["a"].asInt();
return color;
}

Expand Down
3 changes: 3 additions & 0 deletions GiroflexVSL/windows/WindowSoundPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,9 @@ void WindowSoundPanel::Update(int dt)
buttonToggleLights->activeColor = buttonActiveColor;
buttonToggleLights->onIsActiveChange = [vehicle](bool isActive) {
vehicle->SetGiroflexEnabled(!vehicle->prevLightsState);

SirenSystem::PlaySirenToggleSound();

//Menu::ShowPopup(1, vehicle->prevLightsState ? 1 : 0, 0, 1000.0f);
};
}
Expand Down
2 changes: 1 addition & 1 deletion cleo/giroflex v3/GiroflexVSL.fxt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ DGFX2 ~1~, ~1~
DGFX3 ~1~, ~1~, ~1~
DGFX4 <
DGFX5 >
DGFX6 Giroflex VSL v3.7.3 (by ~y~Danilo1301~w~)
DGFX6 Giroflex VSL v3.8.0 (by ~y~Danilo1301~w~)
DGFX7 Fechar
DGFX8 Voltar
DGFX9 Editar posicao
Expand Down
2 changes: 1 addition & 1 deletion cleo/giroflex v3/GiroflexVSL_en.fxt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ DGFX2 ~1~, ~1~
DGFX3 ~1~, ~1~, ~1~
DGFX4 <
DGFX5 >
DGFX6 Giroflex VSL v3.7.3 (by ~y~Danilo1301~w~)
DGFX6 Giroflex VSL v3.8.0 (by ~y~Danilo1301~w~)
DGFX7 Close
DGFX8 Back
DGFX9 Edit position
Expand Down
Binary file added files/configs/giroflexVSL/audios/siren_switch.wav
Binary file not shown.
Binary file added files/configs/giroflexVSL/audios/siren_toggle.wav
Binary file not shown.
Binary file added files/versions/3.8.0/GiroflexVSL-3.8.0__en.zip
Binary file not shown.
Binary file added files/versions/3.8.0/GiroflexVSL-3.8.0__pt-br.zip
Binary file not shown.
5 changes: 3 additions & 2 deletions info.txt
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,10 @@ OBS: I also found a bug that detects a lightpanel button press before the panel
[3.7.3]
[X] CHANGE: change the way it loads the libs (and add a log message if they are not loaded)

[3.7.4]
[3.8.0]
[X] FIX: flare is always enabled
[ ] FIX: issue with two leds using same object
[X] ADD: support to multi color on patterns
[X] ADD: sounds to the buttons (turn lights only, not turn sounds yet)

-----------------------
NOTES:
Expand Down

0 comments on commit c89248f

Please sign in to comment.