metaforce/Runtime/CInGameTweakManagerBase.hpp

91 lines
2.4 KiB
C++
Raw Normal View History

2016-04-12 23:07:23 -07:00
#ifndef __URDE_CINGAMETWEAKMANAGERBASE_HPP__
#define __URDE_CINGAMETWEAKMANAGERBASE_HPP__
2015-08-26 17:23:46 -07:00
#include <string>
2016-07-23 21:46:32 -07:00
#include <vector>
2015-08-26 17:23:46 -07:00
2016-07-29 10:00:23 -07:00
#include "RetroTypes.hpp"
2016-03-04 15:04:53 -08:00
namespace urde
2015-08-26 17:23:46 -07:00
{
2016-07-29 10:00:23 -07:00
class CTweakValue
2016-07-23 21:46:32 -07:00
{
2016-07-29 10:00:23 -07:00
public:
struct Audio
{
float x0_fadeIn, x4_fadeOut, x8_volume;
std::string xc_fileName;
2017-08-12 22:26:14 -07:00
CAssetId x1c_res;
2017-11-12 22:19:18 -08:00
Audio(float fadeIn, float fadeOut, float vol, std::string_view fileName, u32 handle)
: x0_fadeIn(fadeIn), x4_fadeOut(fadeOut), x8_volume(vol), xc_fileName(fileName), x1c_res(handle) {}
float GetFadeIn() const { return x0_fadeIn; }
float GetFadeOut() const { return x4_fadeOut; }
float GetVolume() const { return x8_volume; }
2017-11-12 22:19:18 -08:00
std::string_view GetFileName() const { return xc_fileName; }
2017-08-12 22:26:14 -07:00
CAssetId GetResId() const { return x1c_res; }
static Audio None() { return Audio{0.f, 0.f, 0.f, "", 0}; }
2016-07-29 10:00:23 -07:00
};
2016-07-23 21:46:32 -07:00
enum class EType
{
2016-07-29 10:00:23 -07:00
};
EType x0_type;
2016-07-23 21:46:32 -07:00
std::string x4_key;
std::string x14_str;
Audio x24_audio;
union
{
u32 x44_int;
float x44_flt;
};
2016-07-29 10:00:23 -07:00
public:
CTweakValue()=default;
//CTweakValue(CTextInputStream&);
//void PutTo(CTextOutStream&);
2017-11-12 22:19:18 -08:00
std::string_view GetName() const { return x4_key; }
std::string_view GetValueAsString() const;
void SetValueFromString(std::string_view);
const Audio& GetAudio() const { return x24_audio; }
2016-07-29 10:00:23 -07:00
EType GetType() const { return x0_type; }
2016-07-23 21:46:32 -07:00
};
2015-08-26 17:23:46 -07:00
class CInGameTweakManagerBase
{
2016-07-23 21:46:32 -07:00
protected:
std::vector<CTweakValue> x0_values;
2015-08-26 17:23:46 -07:00
public:
2017-11-12 22:19:18 -08:00
bool HasTweakValue(std::string_view name) const
2016-07-23 21:46:32 -07:00
{
for (const CTweakValue& val : x0_values)
2016-07-29 10:00:23 -07:00
if (val.GetName() == name)
2016-07-23 21:46:32 -07:00
return true;
return false;
}
2017-11-12 22:19:18 -08:00
const CTweakValue* GetTweakValue(std::string_view name) const
2016-07-23 21:46:32 -07:00
{
for (const CTweakValue& val : x0_values)
2016-07-29 10:00:23 -07:00
if (val.GetName() == name)
2016-07-23 21:46:32 -07:00
return &val;
return nullptr;
}
2017-11-12 22:19:18 -08:00
bool ReadFromMemoryCard(std::string_view name)
2015-08-26 17:23:46 -07:00
{
return true;
}
2017-05-21 09:01:04 -07:00
2017-08-12 22:26:14 -07:00
static std::string GetIdentifierForMidiEvent(CAssetId world, CAssetId area,
2017-11-12 22:19:18 -08:00
std::string_view midiObj)
2017-05-21 09:01:04 -07:00
{
return hecl::Format("World %8.8x Area %8.8x MidiObject: %s",
2017-11-12 22:19:18 -08:00
u32(world.Value()), u32(area.Value()), midiObj.data());
2017-05-21 09:01:04 -07:00
}
2015-08-26 17:23:46 -07:00
};
}
2016-04-12 23:07:23 -07:00
#endif // __URDE_CINGAMETWEAKMANAGERBASE_HPP__