Skip to content

Commit

Permalink
Merge pull request #129 from JacobDomagala/122-add-option-to-modify-a…
Browse files Browse the repository at this point in the history
…nimationpoints

[#122, #130]: Add option to edit `AnimationPoint's` duration and improve UI in `Editor`
  • Loading branch information
JacobDomagala authored Jun 27, 2023
2 parents a9eee77 + 4723531 commit 13d52ff
Show file tree
Hide file tree
Showing 9 changed files with 1,786 additions and 229 deletions.
Binary file added assets/fonts/fa-regular-400.ttf
Binary file not shown.
Binary file added assets/fonts/fa-solid-900.ttf
Binary file not shown.
2 changes: 1 addition & 1 deletion assets/levels/MediumLevel.dgl

Large diffs are not rendered by default.

25 changes: 21 additions & 4 deletions editor/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Editor::Editor(const glm::ivec2& screenSize) : gui_(*this)
renderer::ApplicationType::EDITOR);
gui_.Init();

m_deltaTime = Timer::milliseconds(static_cast< long >(TARGET_TIME * 1000.0f));
m_deltaTime = Timer::milliseconds(static_cast< long >(TARGET_TIME));
}

void
Expand All @@ -46,8 +46,8 @@ Editor::ShowCursor(bool choice)
void
Editor::HandleCamera()
{
m_timer.ToggleTimer();
m_deltaTime = m_timer.GetMsDeltaTime();
//m_timer.ToggleTimer();
//m_deltaTime = m_timer.GetMsDeltaTime();

auto cameraMoveBy = glm::vec2();

Expand Down Expand Up @@ -332,6 +332,19 @@ Editor::HandleObjectSelected(Object::ID objectID, bool fromGUI)
}
}

Object::ID
Editor::GetSelectedEditorObject() const
{
Object::ID selected = Object::INVALID_ID;

if (m_currentEditorObjectSelected)
{
selected = m_currentEditorObjectSelected->GetLinkedObjectID();
}

return selected;
}

void
Editor::SelectGameObject()
{
Expand Down Expand Up @@ -473,7 +486,11 @@ Editor::ActionOnObject(Editor::ACTION action)
if (m_editorObjectSelected && m_currentEditorObjectSelected)
{
gui_.ObjectDeleted(m_currentEditorObjectSelected->GetLinkedObjectID());
m_editorObjects.erase(stl::find(m_editorObjects, m_currentEditorObjectSelected));
if (Object::GetTypeFromID(m_currentEditorObjectSelected->GetLinkedObjectID())
== ObjectType::ANIMATION_POINT)
{
animationPoints_.erase(stl::find(animationPoints_, m_currentEditorObjectSelected));
}
m_currentEditorObjectSelected->DeleteLinkedObject();
UnselectEditorObject();
}
Expand Down
20 changes: 12 additions & 8 deletions editor/editor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ class Animatable;
class Editor : public Application
{
public:
enum class ACTION
{
UNSELECT,
REMOVE
};
explicit Editor(const glm::ivec2& screenSize);

// APPLICATION OVERRIDES
Expand Down Expand Up @@ -130,26 +135,25 @@ class Editor : public Application
void
HandleObjectSelected(Object::ID objectID, bool fromGUI);

[[nodiscard]] Object::ID
GetSelectedEditorObject() const;

void
HandleEditorObjectSelected(const std::shared_ptr< EditorObject >& newSelectedEditorObject,
bool fromGUI = false);

void
ActionOnObject(ACTION action);

private:
enum class ACTION
{
UNSELECT,
REMOVE
};


// [[nodiscard]] std::shared_ptr< EditorObject >
// GetEditorObjectByID(Object::ID ID);

void
SetupRendererData();

void
ActionOnObject(ACTION action);

void
DrawEditorObjects();

Expand Down
1 change: 0 additions & 1 deletion editor/editor_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ class EditorObject
Object::ID m_objectID = Object::INVALID_ID;
bool m_hasLinkedObject = false;


bool m_selected = false;
bool m_isBackground = false;

Expand Down
Loading

0 comments on commit 13d52ff

Please sign in to comment.