mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-10-31 15:45:06 -04:00
Moved (and renamed) UpdateColor() and UpdateParticleColors() into a C++ file
This commit is contained in:
parent
2a16268d42
commit
770653b2f4
@ -4,6 +4,8 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
std::vector<std::string> sceneNames = {
|
std::vector<std::string> sceneNames = {
|
||||||
"Inside the Deku Tree",
|
"Inside the Deku Tree",
|
||||||
"Dodongo's Cavern",
|
"Dodongo's Cavern",
|
||||||
@ -349,3 +351,35 @@ size_t SohUtils::CopyStringToCharBuffer(char* buffer, const std::string& source,
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" void UpdateColor(const char* trailName, Color_RGBA8* color, int* changed, int* reset) {
|
||||||
|
Color_RGBA8 defaultColor = { 255, 255, 255, 255 };
|
||||||
|
char cvarName[50];
|
||||||
|
if (CVarGetInteger(cvarName,0)) {
|
||||||
|
snprintf(cvarName, sizeof(cvarName), "%s.Value", trailName);
|
||||||
|
*color = CVarGetColor(cvarName, defaultColor);
|
||||||
|
*changed = 1;
|
||||||
|
} else if (*changed) {
|
||||||
|
*color = defaultColor;
|
||||||
|
*reset = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" void UpdateParticleColors(Color_RGBA8* color, Color_RGBA8 p1StartColor, Color_RGBA8 p2StartColor,
|
||||||
|
Color_RGBA8 p1EndColor, Color_RGBA8 p2EndColor) {
|
||||||
|
p1StartColor.r = color->r;
|
||||||
|
p2StartColor.r = color->r * 0.8f;
|
||||||
|
p1EndColor.r = color->r * 0.6f;
|
||||||
|
p2EndColor.r = color->r * 0.4f;
|
||||||
|
|
||||||
|
p1StartColor.g = color->g;
|
||||||
|
p2StartColor.g = color->g * 0.8f;
|
||||||
|
p1EndColor.g = color->g * 0.6f;
|
||||||
|
p2EndColor.g = color->g * 0.4f;
|
||||||
|
|
||||||
|
p1StartColor.b = color->b;
|
||||||
|
p2StartColor.b = color->b * 0.8f;
|
||||||
|
p1EndColor.b = color->b * 0.6f;
|
||||||
|
p2EndColor.b = color->b * 0.4f;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -1,21 +1,40 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#ifdef __cplusplus
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#endif
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <global.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
|
||||||
namespace SohUtils {
|
namespace SohUtils {
|
||||||
const std::string& GetSceneName(int32_t scene);
|
const std::string& GetSceneName(int32_t scene);
|
||||||
|
|
||||||
const std::string& GetItemName(int32_t item);
|
const std::string& GetItemName(int32_t item);
|
||||||
|
|
||||||
const std::string& GetQuestItemName(int32_t item);
|
const std::string& GetQuestItemName(int32_t item);
|
||||||
|
|
||||||
// Copies a string and ensures the destination is null terminated if the source string is larger than size
|
// Copies a string and ensures the destination is null terminated if the source string is larger than size
|
||||||
// Only up to size-1 characters are copied from the source string
|
// Only up to size-1 characters are copied from the source string
|
||||||
void CopyStringToCharArray(char* destination, std::string source, size_t size);
|
void CopyStringToCharArray(char* destination, std::string source, size_t size);
|
||||||
|
|
||||||
std::string Sanitize(std::string stringValue);
|
std::string Sanitize(std::string stringValue);
|
||||||
|
|
||||||
|
// Copies a string into a char buffer up to maxBufferSize characters. This does NOT insert a null terminator
|
||||||
|
// on the end, as this is used for in-game messages which are not null-terminated.
|
||||||
|
size_t CopyStringToCharBuffer(char* buffer, const std::string& source, size_t maxBufferSize);
|
||||||
|
|
||||||
// Copies a string into a char buffer up to maxBufferSize characters. This does NOT insert a null terminator
|
|
||||||
// on the end, as this is used for in-game messages which are not null-terminated.
|
|
||||||
size_t CopyStringToCharBuffer(char* buffer, const std::string& source, size_t maxBufferSize);
|
|
||||||
} // namespace SohUtils
|
} // namespace SohUtils
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void UpdateColor(const char* trailName, Color_RGBA8* color, int* changed, int* reset);
|
||||||
|
|
||||||
|
void UpdateParticleColors(Color_RGBA8* color, Color_RGBA8 p1StartColor, Color_RGBA8 p2StartColor,
|
||||||
|
Color_RGBA8 p1EndColor, Color_RGBA8 p2EndColor);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
@ -2,8 +2,8 @@
|
|||||||
#include "objects/gameplay_keep/gameplay_keep.h"
|
#include "objects/gameplay_keep/gameplay_keep.h"
|
||||||
|
|
||||||
#include "soh/frame_interpolation.h"
|
#include "soh/frame_interpolation.h"
|
||||||
|
#include "soh/util.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
void EffectBlure_AddVertex(EffectBlure* this, Vec3f* p1, Vec3f* p2) {
|
void EffectBlure_AddVertex(EffectBlure* this, Vec3f* p1, Vec3f* p2) {
|
||||||
EffectBlureElement* elem;
|
EffectBlureElement* elem;
|
||||||
@ -200,36 +200,6 @@ void EffectBlure_Init2(void* thisx, void* initParamsx) {
|
|||||||
void EffectBlure_Destroy(void* thisx) {
|
void EffectBlure_Destroy(void* thisx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateTrailColor(const char* trailName, Color_RGBA8* color, int* changed, int* reset) {
|
|
||||||
Color_RGBA8 defaultColor = { 255, 255, 255, 255 };
|
|
||||||
char cvarName[50];
|
|
||||||
if (CVarGetInteger(snprintf(cvarName, sizeof(cvarName), "%s.Changed", trailName), 0)) {
|
|
||||||
*color = CVarGetColor(snprintf(cvarName, sizeof(cvarName), "%s.Value", trailName), defaultColor);
|
|
||||||
*changed = 1;
|
|
||||||
} else if (*changed) {
|
|
||||||
*color = defaultColor;
|
|
||||||
*reset = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void updateParticleColors(Color_RGBA8* color, Color_RGBA8 p1StartColor, Color_RGBA8 p2StartColor,
|
|
||||||
Color_RGBA8 p1EndColor, Color_RGBA8 p2EndColor) {
|
|
||||||
p1StartColor.r = color->r;
|
|
||||||
p2StartColor.r = color->r * 0.8f;
|
|
||||||
p1EndColor.r = color->r * 0.6f;
|
|
||||||
p2EndColor.r = color->r * 0.4f;
|
|
||||||
|
|
||||||
p1StartColor.g = color->g;
|
|
||||||
p2StartColor.g = color->g * 0.8f;
|
|
||||||
p1EndColor.g = color->g * 0.6f;
|
|
||||||
p2EndColor.g = color->g * 0.4f;
|
|
||||||
|
|
||||||
p1StartColor.b = color->b;
|
|
||||||
p2StartColor.b = color->b * 0.8f;
|
|
||||||
p1EndColor.b = color->b * 0.6f;
|
|
||||||
p2EndColor.b = color->b * 0.4f;
|
|
||||||
}
|
|
||||||
|
|
||||||
s32 EffectBlure_Update(void* thisx) {
|
s32 EffectBlure_Update(void* thisx) {
|
||||||
EffectBlure* this = (EffectBlure*)thisx;
|
EffectBlure* this = (EffectBlure*)thisx;
|
||||||
s32 i;
|
s32 i;
|
||||||
@ -239,26 +209,26 @@ s32 EffectBlure_Update(void* thisx) {
|
|||||||
|
|
||||||
switch (this->trailType) { // a better way?
|
switch (this->trailType) { // a better way?
|
||||||
case TRAIL_TYPE_BOOMERANG:
|
case TRAIL_TYPE_BOOMERANG:
|
||||||
updateTrailColor("gCosmetics.Trails_Boomerang", &color, &changed, &reset);
|
UpdateColor("gCosmetics.Trails_Boomerang", &color, &changed, &reset);
|
||||||
break;
|
break;
|
||||||
case TRAIL_TYPE_BOMBCHU:
|
case TRAIL_TYPE_BOMBCHU:
|
||||||
updateTrailColor("gCosmetics.Trails_Bombchu", &color, &changed, &reset);
|
UpdateColor("gCosmetics.Trails_Bombchu", &color, &changed, &reset);
|
||||||
updateParticleColors(&color, this->p1StartColor, this->p2StartColor, this->p1EndColor, this->p2EndColor);
|
UpdateParticleColors(&color, this->p1StartColor, this->p2StartColor, this->p1EndColor, this->p2EndColor);
|
||||||
break;
|
break;
|
||||||
case TRAIL_TYPE_KOKIRI_SWORD:
|
case TRAIL_TYPE_KOKIRI_SWORD:
|
||||||
updateTrailColor("gCosmetics.Trails_KokiriSword", &color, &changed, &reset);
|
UpdateColor("gCosmetics.Trails_KokiriSword", &color, &changed, &reset);
|
||||||
break;
|
break;
|
||||||
case TRAIL_TYPE_MASTER_SWORD:
|
case TRAIL_TYPE_MASTER_SWORD:
|
||||||
updateTrailColor("gCosmetics.Trails_MasterSword", &color, &changed, &reset);
|
UpdateColor("gCosmetics.Trails_MasterSword", &color, &changed, &reset);
|
||||||
break;
|
break;
|
||||||
case TRAIL_TYPE_BIGGORON_SWORD:
|
case TRAIL_TYPE_BIGGORON_SWORD:
|
||||||
updateTrailColor("gCosmetics.Trails_BiggoronSword", &color, &changed, &reset);
|
UpdateColor("gCosmetics.Trails_BiggoronSword", &color, &changed, &reset);
|
||||||
break;
|
break;
|
||||||
case TRAIL_TYPE_STICK:
|
case TRAIL_TYPE_STICK:
|
||||||
updateTrailColor("gCosmetics.Trails_Stick", &color, &changed, &reset);
|
UpdateColor("gCosmetics.Trails_Stick", &color, &changed, &reset);
|
||||||
break;
|
break;
|
||||||
case TRAIL_TYPE_HAMMER:
|
case TRAIL_TYPE_HAMMER:
|
||||||
updateTrailColor("gCosmetics.Trails_Hammer", &color, &changed, &reset);
|
UpdateColor("gCosmetics.Trails_Hammer", &color, &changed, &reset);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user