metaforce/Runtime/CInGameTweakManagerBase.hpp

91 lines
2.4 KiB
C++
Raw Normal View History

2016-04-13 06:07:23 +00:00
#ifndef __URDE_CINGAMETWEAKMANAGERBASE_HPP__
#define __URDE_CINGAMETWEAKMANAGERBASE_HPP__
2015-08-27 00:23:46 +00:00
#include <string>
2016-07-24 04:46:32 +00:00
#include <vector>
2015-08-27 00:23:46 +00:00
2016-07-29 17:00:23 +00:00
#include "RetroTypes.hpp"
2016-03-04 23:04:53 +00:00
namespace urde
2015-08-27 00:23:46 +00:00
{
2016-07-29 17:00:23 +00:00
class CTweakValue
2016-07-24 04:46:32 +00:00
{
2016-07-29 17:00:23 +00:00
public:
struct Audio
{
float x0_fadeIn, x4_fadeOut, x8_volume;
std::string xc_fileName;
ResId x1c_res;
Audio(float fadeIn, float fadeOut, float vol, const std::string& 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; }
const std::string& GetFileName() const { return xc_fileName; }
ResId GetResId() const { return x1c_res; }
static Audio None() { return Audio{0.f, 0.f, 0.f, "", 0}; }
2016-07-29 17:00:23 +00:00
};
2016-07-24 04:46:32 +00:00
enum class EType
{
2016-07-29 17:00:23 +00:00
};
EType x0_type;
2016-07-24 04:46:32 +00:00
std::string x4_key;
std::string x14_str;
Audio x24_audio;
union
{
u32 x44_int;
float x44_flt;
};
2016-07-29 17:00:23 +00:00
public:
CTweakValue()=default;
//CTweakValue(CTextInputStream&);
//void PutTo(CTextOutStream&);
const std::string& GetName() const { return x4_key; }
const std::string& GetValueAsString() const;
void SetValueFromString(const std::string&);
const Audio& GetAudio() const { return x24_audio; }
2016-07-29 17:00:23 +00:00
EType GetType() const { return x0_type; }
2016-07-24 04:46:32 +00:00
};
2015-08-27 00:23:46 +00:00
class CInGameTweakManagerBase
{
2016-07-24 04:46:32 +00:00
protected:
std::vector<CTweakValue> x0_values;
2015-08-27 00:23:46 +00:00
public:
2016-07-24 04:46:32 +00:00
bool HasTweakValue(const std::string& name) const
{
for (const CTweakValue& val : x0_values)
2016-07-29 17:00:23 +00:00
if (val.GetName() == name)
2016-07-24 04:46:32 +00:00
return true;
return false;
}
const CTweakValue* GetTweakValue(const std::string& name) const
{
for (const CTweakValue& val : x0_values)
2016-07-29 17:00:23 +00:00
if (val.GetName() == name)
2016-07-24 04:46:32 +00:00
return &val;
return nullptr;
}
2015-08-27 00:23:46 +00:00
bool ReadFromMemoryCard(const std::string& name)
{
return true;
}
2017-05-21 16:01:04 +00:00
static std::string GetIdentifierForMidiEvent(ResId world, ResId area,
const std::string& midiObj)
{
return hecl::Format("World %8.8x Area %8.8x MidiObject: %s",
u32(world), u32(area), midiObj.c_str());
}
2015-08-27 00:23:46 +00:00
};
}
2016-04-13 06:07:23 +00:00
#endif // __URDE_CINGAMETWEAKMANAGERBASE_HPP__