mirror of
https://github.com/MonsterDruide1/OdysseyDecomp
synced 2026-04-23 09:04:21 +00:00
Library/Yaml: Simplify ParameterBase (#1012)
This commit is contained in:
parent
1020da244f
commit
00fb866836
|
|
@ -151,7 +151,7 @@ void PlaneParam::initialize(const sead::Vector3f& direction, ParameterObj* param
|
|||
StringTmp<256> distance = {"%sDistance", planeName};
|
||||
|
||||
initializeDir(direction, parameterObj, normal.cstr(), "平面法線");
|
||||
mDistanceFromOrigin = new ParameterF32(distance.cstr(), "原点からの距離",
|
||||
mDistanceFromOrigin = new ParameterF32(0.0f, distance.cstr(), "原点からの距離",
|
||||
"Min=-100000, Max=100000", parameterObj, true);
|
||||
}
|
||||
} // namespace al
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ ScreenPointKeeper::ScreenPointKeeper() {
|
|||
mOptions = new ParameterObj();
|
||||
|
||||
mAddTargetNum =
|
||||
new ParameterS32("AddTargetNum", "AddTargetNum", "Min=0, Max=10", mOptions, true);
|
||||
new ParameterS32(0, "AddTargetNum", "AddTargetNum", "Min=0, Max=10", mOptions, true);
|
||||
|
||||
mParameterIo->addObj(mOptions, "Options");
|
||||
mParameterIo->addArray(mTargets, "Targets");
|
||||
|
|
|
|||
|
|
@ -40,19 +40,11 @@ SEAD_ENUM(YamlParamType,
|
|||
#define PARAM_TYPE_DEF(Name, Type) \
|
||||
class Parameter##Name : public Parameter<Type> { \
|
||||
public: \
|
||||
Parameter##Name(const sead::SafeString& name, const sead::SafeString& label, \
|
||||
const sead::SafeString& meta, ParameterObj* obj, bool e) \
|
||||
: Parameter(name, label, meta, obj, e) {} \
|
||||
\
|
||||
Parameter##Name(Type const& value, const sead::SafeString& name, \
|
||||
const sead::SafeString& label, const sead::SafeString& meta, \
|
||||
ParameterObj* obj, bool e) \
|
||||
: Parameter(value, name, label, meta, obj, e) {} \
|
||||
\
|
||||
Parameter##Name(const sead::SafeString& name, const sead::SafeString& label, \
|
||||
const sead::SafeString& meta, ParameterList* list, bool e) \
|
||||
: Parameter(name, label, meta, list, e) {} \
|
||||
\
|
||||
Parameter##Name(Type const& value, const sead::SafeString& name, \
|
||||
const sead::SafeString& label, const sead::SafeString& meta, \
|
||||
ParameterList* list, bool e) \
|
||||
|
|
@ -71,9 +63,9 @@ class ParameterBase {
|
|||
public:
|
||||
static u32 calcHash(const sead::SafeString& key);
|
||||
|
||||
// TODO: rename parameter bool e in all functions
|
||||
ParameterBase(bool e) { initialize("default", "parameter", "", e); }
|
||||
ParameterBase() { initialize("default", "parameter", "", true); }
|
||||
|
||||
// TODO: rename parameter bool e in all functions
|
||||
ParameterBase(const sead::SafeString& name, const sead::SafeString& label,
|
||||
const sead::SafeString& meta, ParameterObj* obj, bool e);
|
||||
|
||||
|
|
@ -139,39 +131,42 @@ template <typename T>
|
|||
class Parameter : public ParameterBase {
|
||||
public:
|
||||
// TODO: rename parameter bool e in constructor
|
||||
Parameter(const sead::SafeString& name, const sead::SafeString& label,
|
||||
const sead::SafeString& meta, ParameterObj* obj, bool e)
|
||||
: ParameterBase(e) {
|
||||
Parameter(const T& value, const sead::SafeString& name, const sead::SafeString& label,
|
||||
const sead::SafeString& meta, ParameterObj* obj, bool e) {
|
||||
initializeListNode(name, label, meta, obj, e);
|
||||
mValue = T();
|
||||
setValue(value);
|
||||
}
|
||||
|
||||
Parameter(const T& value, const sead::SafeString& name, const sead::SafeString& label,
|
||||
const sead::SafeString& meta, ParameterObj* obj, bool e)
|
||||
: ParameterBase(e) {
|
||||
initializeListNode(name, label, meta, obj, e);
|
||||
mValue = value;
|
||||
}
|
||||
|
||||
Parameter(const sead::SafeString& name, const sead::SafeString& label,
|
||||
const sead::SafeString& meta, ParameterList* list, bool e)
|
||||
: ParameterBase(e) {
|
||||
const sead::SafeString& meta, ParameterList* list, bool e) {
|
||||
initializeListNode(name, label, meta, list, e);
|
||||
mValue = T();
|
||||
}
|
||||
|
||||
Parameter(const T& value, const sead::SafeString& name, const sead::SafeString& label,
|
||||
const sead::SafeString& meta, ParameterList* list, bool e)
|
||||
: ParameterBase(e) {
|
||||
initializeListNode(name, label, meta, list, e);
|
||||
mValue = value;
|
||||
setValue(value);
|
||||
}
|
||||
|
||||
const void* ptr() const override { return &mValue; };
|
||||
|
||||
void* ptr() override { return &mValue; };
|
||||
|
||||
s32 size() const override { return sizeof(T); }
|
||||
s32 size() const override {
|
||||
// BUG: sead::FixedSafeString<128> is excluded from this list
|
||||
if constexpr (std::is_same<T, sead::FixedSafeString<32>>())
|
||||
return 32;
|
||||
else if constexpr (std::is_same<T, sead::FixedSafeString<64>>())
|
||||
return 64;
|
||||
else if constexpr (std::is_same<T, sead::FixedSafeString<256>>())
|
||||
return 256;
|
||||
// NOTE: from 512 onwards, no examples exist in the binary
|
||||
else if constexpr (std::is_same<T, sead::FixedSafeString<512>>())
|
||||
return 512;
|
||||
else if constexpr (std::is_same<T, sead::FixedSafeString<1024>>())
|
||||
return 1024;
|
||||
else if constexpr (std::is_same<T, sead::FixedSafeString<2048>>())
|
||||
return 2048;
|
||||
else if constexpr (std::is_same<T, sead::FixedSafeString<4096>>())
|
||||
return 4096;
|
||||
else
|
||||
return sizeof(T);
|
||||
}
|
||||
|
||||
const char* getParamTypeStr() const override {
|
||||
return YamlParamType::text(YamlParamType::Invalid);
|
||||
|
|
|
|||
Loading…
Reference in a new issue