2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 11:44:55 +00:00

Merge remote-tracking branch 'origin/main' into utf8

# Conflicts:
#	DataSpec/DNAMP1/FRME.cpp
#	DataSpec/DNAMP1/MLVL.cpp
#	Runtime/CMain.cpp
#	hecl/lib/Blender/Connection.cpp
This commit is contained in:
2021-10-25 19:03:01 -04:00
28 changed files with 481 additions and 238 deletions

View File

@@ -275,9 +275,14 @@ def recursive_cook(buffer, obj, version, path_hasher, parent_name):
def cook(writepipebuf, version, path_hasher):
global hjustifications, vjustifications, model_draw_flags_e
hjustifications = dict((i[0], i[3]) for i in bpy.types.Object.retro_textpane_hjustification[1]['items'])
vjustifications = dict((i[0], i[3]) for i in bpy.types.Object.retro_textpane_vjustification[1]['items'])
model_draw_flags_e = dict((i[0], i[3]) for i in bpy.types.Object.retro_widget_model_draw_flags[1]['items'])
if bpy.app.version >= (2, 93, 0):
hjustifications = dict((i[0], i[3]) for i in bpy.types.Object.retro_textpane_hjustification.keywords['items'])
vjustifications = dict((i[0], i[3]) for i in bpy.types.Object.retro_textpane_vjustification.keywords['items'])
model_draw_flags_e = dict((i[0], i[3]) for i in bpy.types.Object.retro_widget_model_draw_flags.keywords['items'])
else:
hjustifications = dict((i[0], i[3]) for i in bpy.types.Object.retro_textpane_hjustification[1]['items'])
vjustifications = dict((i[0], i[3]) for i in bpy.types.Object.retro_textpane_vjustification[1]['items'])
model_draw_flags_e = dict((i[0], i[3]) for i in bpy.types.Object.retro_widget_model_draw_flags[1]['items'])
buffer = bytearray()
buffer += struct.pack('>IIII', 0, 0, 0, 0)
@@ -320,7 +325,7 @@ def register():
('RETRO_ADDITIVE', 'Additive', '', 3),
('RETRO_ALPHA_ADDITIVE_OVERDRAW', 'Alpha Additive Overdraw', '', 4)]
bpy.types.Object.retro_widget_parent = bpy.props.StringProperty(name='Retro: FRME Widget Parent', description='Refers to internal frame widgets')
bpy.types.Object.retro_widget_use_anim_controller = bpy.props.BoolProperty(name='Retro: Use Animiation Conroller')
bpy.types.Object.retro_widget_use_anim_controller = bpy.props.BoolProperty(name='Retro: Use Animation Controller')
bpy.types.Object.retro_widget_default_visible = bpy.props.BoolProperty(name='Retro: Default Visible', description='Sets widget is visible by default')
bpy.types.Object.retro_widget_default_active = bpy.props.BoolProperty(name='Retro: Default Active', description='Sets widget is cases by default')
bpy.types.Object.retro_widget_cull_faces = bpy.props.BoolProperty(name='Retro: Cull Faces', description='Enables face culling')

View File

@@ -249,10 +249,16 @@ def cook(writebuf, mesh_obj):
if mesh_obj.type != 'MESH':
raise RuntimeError("%s is not a mesh" % mesh_obj.name)
obj_vismodes = dict((i[0], i[3]) for i in bpy.types.Object.retro_mapobj_vis_mode[1]['items'])
if bpy.app.version >= (2, 93, 0):
obj_vismodes = dict((i[0], i[3]) for i in bpy.types.Object.retro_mapobj_vis_mode.keywords['items'])
else:
obj_vismodes = dict((i[0], i[3]) for i in bpy.types.Object.retro_mapobj_vis_mode[1]['items'])
# Write out visibility type
vis_types = dict((i[0], i[3]) for i in bpy.types.Scene.retro_map_vis_mode[1]['items'])
if hasattr(bpy.types.Scene.retro_map_vis_mode, '__getitem__'):
vis_types = dict((i[0], i[3]) for i in bpy.types.Scene.retro_map_vis_mode[1]['items'])
else:
vis_types = dict((i[0], i[3]) for i in bpy.types.Scene.retro_map_vis_mode.keywords['items'])
writebuf(struct.pack('I', vis_types[bpy.context.scene.retro_map_vis_mode]))
# Copy mesh (and apply mesh modifiers with triangulation)

View File

@@ -6,7 +6,7 @@ namespace hecl::blender {
constexpr uint32_t MinBlenderMajorSearch = 2;
constexpr uint32_t MaxBlenderMajorSearch = 2;
constexpr uint32_t MinBlenderMinorSearch = 83;
constexpr uint32_t MaxBlenderMinorSearch = 92;
constexpr uint32_t MaxBlenderMinorSearch = 93;
std::optional<std::string> FindBlender(int& major, int& minor);

View File

@@ -11,7 +11,6 @@
namespace hecl {
namespace DNACVAR {
enum class EType : atUint8 { Boolean, Signed, Unsigned, Real, Literal, Vec2f, Vec2d, Vec3f, Vec3d, Vec4f, Vec4d };
enum class EFlags {
None = 0,
System = (1 << 0),
@@ -48,6 +47,7 @@ struct CVarContainer : public athena::io::DNA<athena::Endian::Big> {
} // namespace DNACVAR
class CVarManager;
class ICVarValueReference;
class CVar : protected DNACVAR::CVar {
friend class CVarManager;
Delete _d;
@@ -148,6 +148,13 @@ public:
void lock();
void addListener(ListenerFunc func) { m_listeners.push_back(std::move(func)); }
void addVariableReference(ICVarValueReference* v) { m_valueReferences.push_back(v); }
void removeVariableReference(ICVarValueReference* v) {
auto it = std::find(m_valueReferences.begin(), m_valueReferences.end(), v);
if (it != m_valueReferences.end()) {
m_valueReferences.erase(it);
}
}
bool isValidInput(std::string_view input) const;
@@ -164,6 +171,7 @@ private:
bool m_unlocked = false;
bool m_wasDeserialized = false;
std::vector<ListenerFunc> m_listeners;
std::vector<ICVarValueReference*> m_valueReferences;
bool safeToModify(EType type) const;
void init(EFlags flags, bool removeColor = true);
};
@@ -212,9 +220,9 @@ inline bool CVar::toValue(double& value) const {
}
template <>
inline bool CVar::toValue(float& value) const {
bool isValid = false;
value = static_cast<float>(toReal(&isValid));
return isValid;
bool isValid = false;
value = static_cast<float>(toReal(&isValid));
return isValid;
}
template <>
inline bool CVar::toValue(bool& value) const {
@@ -303,5 +311,43 @@ public:
m_cvar->lock();
}
};
class ICVarValueReference {
protected:
CVar* m_cvar = nullptr;
public:
ICVarValueReference() = default;
explicit ICVarValueReference(CVar* cv) : m_cvar(cv) {
if (m_cvar != nullptr) {
m_cvar->addVariableReference(this);
}
}
virtual ~ICVarValueReference() {
if (m_cvar != nullptr) {
m_cvar->removeVariableReference(this);
}
m_cvar = nullptr;
}
virtual void updateValue() = 0;
};
template <typename T>
class CVarValueReference : public ICVarValueReference {
T* m_valueRef = nullptr;
public:
CVarValueReference() = default;
explicit CVarValueReference(T* t, CVar* cv) : ICVarValueReference(cv) {
m_valueRef = t;
if (m_valueRef && m_cvar) {
m_cvar->toValue(*m_valueRef);
}
}
void updateValue() override {
if (m_valueRef != nullptr && m_cvar->isModified()) {
m_cvar->toValue(*m_valueRef);
}
}
};
} // namespace hecl

View File

@@ -36,14 +36,17 @@ extern "C" int rep_closefrom(int lower);
#include <functional>
#include <list>
#include <map>
#include <optional>
#include <regex>
#include <string>
#include "logvisor/logvisor.hpp"
#include "FourCC.hpp"
#include "athena/Global.hpp"
#include "logvisor/logvisor.hpp"
#include "xxhash/xxhash.h"
#include "FourCC.hpp"
#if defined(__has_feature)
#if __has_feature(thread_sanitizer)
#define HECL_NO_SANITIZE_THREAD __attribute__((no_sanitize("thread")))

View File

@@ -449,6 +449,9 @@ void CVar::lock() {
void CVar::dispatch() {
for (const ListenerFunc& listen : m_listeners)
listen(this);
for (auto* ref : m_valueReferences) {
ref->updateValue();
}
}
bool isReal(std::string_view v) {