Skip to content

Commit

Permalink
minor scripting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Bashar-Ahmed committed Mar 7, 2022
1 parent f89a5c6 commit 84defab
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 37 deletions.
12 changes: 1 addition & 11 deletions rootex/assets/scenes/pause.scene.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,7 @@
],
"entity": {
"components": {
"MusicComponent": {
"attenuationModel": 53251,
"audio": "rootex/assets/ball.wav",
"isAttenuated": false,
"isLooping": true,
"maxDistance": 100.0,
"playOnStart": true,
"referenceDistance": 1.0,
"rollOffFactor": 1.0,
"volume": 1.0
},

"TextUIComponent": {
"color": {
"a": 1.0,
Expand Down
4 changes: 2 additions & 2 deletions rootex/framework/components/physics/rigid_body_component.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ class RigidBodyComponent : public CollisionComponent, public btMotionState
void getWorldTransform(btTransform& worldTrans) const override;
void setWorldTransform(const btTransform& worldTrans) override;

void updateTransform();

void handleHit(Hit* hit) override;

public:
virtual ~RigidBodyComponent() = default;

void updateTransform();

void applyForce(const Vector3& force);
void applyTorque(const Vector3& torque);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,26 +232,19 @@ void RenderableComponent::draw()

ImGui::BeginGroup();
ImGui::Text("%s", newMaterial->getPath().filename().generic_string().c_str());
if (ImGui::Button((ICON_ROOTEX_PENCIL_SQUARE_O "##" + newMaterial->getPath().generic_string()).c_str()))
if (ImGui::Button((ICON_ROOTEX_PENCIL_SQUARE_O "##1" + newMaterial->getPath().generic_string()).c_str()))
{
EventManager::GetSingleton()->call(EditorEvents::EditorOpenFile, VariantVector { newMaterial->getPath().generic_string(), (int)newMaterial->getType() });
}
ImGui::SameLine();
if (ImGui::Button((ICON_ROOTEX_FOLDER_OPEN "##" + newMaterial->getPath().generic_string()).c_str()))
if (ImGui::Button((ICON_ROOTEX_FOLDER_OPEN "##2" + newMaterial->getPath().generic_string()).c_str()))
{
if (Optional<String> result = OS::SelectFile("Material(*.rmat)\0*.rmat\0", "game/assets/materials/"))
{
setMaterialOverride(oldMaterial, ResourceLoader::CreateMaterialResourceFile(*result));
}
}
ImGui::SameLine();
if (ImGui::Button((ICON_ROOTEX_FOLDER_OPEN "##" + oldMaterial->getPath().generic_string()).c_str()))
{
if (Optional<String> result = OS::SelectFile("Material(*.rmat)\0*.rmat\0", "game/assets/materials/"))
{
setMaterialOverride(oldMaterial, ResourceLoader::CreateMaterialResourceFile(*result));
}
}
ImGui::EndGroup();
ImGui::NextColumn();
ImGui::Separator();
Expand Down
34 changes: 20 additions & 14 deletions rootex/framework/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,29 @@ void System::setActive(bool enabled)

void System::pause()
{
for (auto& systemType : GetSystems())
{
for (auto& system : systemType)
{
system->m_IsSystemPaused = true;
}
}
EventManager::GetSingleton()->defer([]()
{
for (auto& systemType : GetSystems())
{
for (auto& system : systemType)
{
system->m_IsSystemPaused = true;
}
}
});
}
void System::unPause()
{
for (auto& systemType : GetSystems())
{
for (auto& system : systemType)
{
system->m_IsSystemPaused = false;
}
}
EventManager::GetSingleton()->defer([]()
{
for (auto& systemType : GetSystems())
{
for (auto& system : systemType)
{
system->m_IsSystemPaused = false;
}
}
});
}

void System::draw()
Expand Down
7 changes: 6 additions & 1 deletion rootex/script/interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ void LuaInterpreter::registerTypes()
resourceLoader["CreateAnimatedModel"] = &ResourceLoader::CreateAnimatedModelResourceFile;
resourceLoader["CreateCollisionModel"] = &ResourceLoader::CreateAnimatedModelResourceFile;
resourceLoader["CreateParticleEffectResourceFile"] = &ResourceLoader::CreateParticleEffectResourceFile;
resourceLoader["CreateMaterialResourceFile"] = &ResourceLoader::CreateMaterialResourceFile;
}
{
sol::usertype<ResourceFile> resourceFile = rootex.new_usertype<ResourceFile>("ResourceFile");
Expand Down Expand Up @@ -491,7 +492,7 @@ void LuaInterpreter::registerTypes()

transformComponent["getPosition"] = &TransformComponent::getPosition;
transformComponent["setPosition"] = &TransformComponent::setPosition;

transformComponent["getScale"] = &TransformComponent::getScale;
transformComponent["setScale"] = &TransformComponent::setScale;

Expand Down Expand Up @@ -521,6 +522,8 @@ void LuaInterpreter::registerTypes()
"ModelComponent",
sol::base_classes, sol::bases<Component, RenderableComponent>());
modelComponent["getModelResourceFile"] = &ModelComponent::getModelResourceFile;
modelComponent["setMaterialOverride"] = &RenderableComponent::setMaterialOverride;
modelComponent["getMaterialOverride"] = &RenderableComponent::getMaterialOverride;
}
{
sol::usertype<AnimatedModelComponent> animatedModelComponent = rootex.new_usertype<AnimatedModelComponent>(
Expand Down Expand Up @@ -620,6 +623,8 @@ void LuaInterpreter::registerTypes()
rigidBodyComponent["applyTorque"] = &RigidBodyComponent::applyTorque;
rigidBodyComponent["setAxisLock"] = &RigidBodyComponent::setAxisLock;
rigidBodyComponent["translate"] = &RigidBodyComponent::translate;

rigidBodyComponent["update"] = &RigidBodyComponent::updateTransform;
}
{
sol::usertype<BoxColliderComponent> bcc = rootex.new_usertype<BoxColliderComponent>(
Expand Down

0 comments on commit 84defab

Please sign in to comment.