mirror of
https://github.com/antopilo/Nuake.git
synced 2025-12-30 21:49:06 +03:00
Editor animations/optimization
This commit is contained in:
3
Editor/AnimatedValue.cpp
Normal file
3
Editor/AnimatedValue.cpp
Normal file
@@ -0,0 +1,3 @@
|
||||
#include "AnimatedValue.h"
|
||||
|
||||
std::vector<IAnimatedValue*> IAnimatedValue::Instances;
|
||||
62
Editor/AnimatedValue.h
Normal file
62
Editor/AnimatedValue.h
Normal file
@@ -0,0 +1,62 @@
|
||||
#pragma once
|
||||
#include <Nuake/Core/Maths.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
class IAnimatedValue
|
||||
{
|
||||
public:
|
||||
static std::vector<IAnimatedValue*> Instances;
|
||||
|
||||
static void UpdateAll (float ts)
|
||||
{
|
||||
for (auto& instance : Instances)
|
||||
{
|
||||
instance->Update(ts);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void Update(float ts) = 0;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class AnimatedValue : public IAnimatedValue
|
||||
{
|
||||
public:
|
||||
T Value;
|
||||
T TargetValue;
|
||||
float Speed = 20.0f;
|
||||
AnimatedValue(T value = T(), T targetValue = T())
|
||||
: Value(value), TargetValue(targetValue)
|
||||
{
|
||||
IAnimatedValue::Instances.push_back(this);
|
||||
}
|
||||
|
||||
~AnimatedValue()
|
||||
{
|
||||
auto it = std::remove(Instances.begin(), Instances.end(), this);
|
||||
IAnimatedValue::Instances.erase(it, Instances.end());
|
||||
}
|
||||
|
||||
virtual void Update(float ts) override
|
||||
{
|
||||
Value = glm::mix(Value, TargetValue, glm::clamp(Speed * ts, 0.0f, 1.0f));
|
||||
}
|
||||
|
||||
void SetValue(T value)
|
||||
{
|
||||
Value = value;
|
||||
TargetValue = value;
|
||||
}
|
||||
|
||||
operator T() const
|
||||
{
|
||||
return Value;
|
||||
}
|
||||
|
||||
AnimatedValue<T>& operator =(T value)
|
||||
{
|
||||
TargetValue = value;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
@@ -65,6 +65,7 @@
|
||||
|
||||
#include "../Events/EditorRequests.h"
|
||||
#include "../../../../Nuake/Thirdparty/glfw/include/GLFW/glfw3.h"
|
||||
#include "../../../AnimatedValue.h"
|
||||
|
||||
namespace Nuake {
|
||||
|
||||
@@ -2955,6 +2956,7 @@ namespace Nuake {
|
||||
|
||||
void EditorInterface::Update(float ts)
|
||||
{
|
||||
Logger::Log("Opacity: " + std::to_string(ts), "UPDATE");
|
||||
if (!Engine::GetCurrentScene() || Engine::IsPlayMode())
|
||||
{
|
||||
return;
|
||||
|
||||
@@ -339,7 +339,6 @@ namespace Nuake
|
||||
ImGui::EndDragDropSource();
|
||||
}
|
||||
|
||||
|
||||
Ref<VulkanImage> textureImage = TextureManager::Get()->GetTexture2("Resources/Images/file_icon.png");
|
||||
|
||||
const auto textureMgr = TextureManager::Get();
|
||||
@@ -355,7 +354,11 @@ namespace Nuake
|
||||
else if (fileType == FileType::Image)
|
||||
{
|
||||
const std::string path = file->GetAbsolutePath();
|
||||
textureImage = textureMgr->GetTexture2(path);
|
||||
if (!textureMgr->IsTextureLoaded2(path) && textureLoadedThisFrame < maxTextureLoadedPerFrame)
|
||||
{
|
||||
textureImage = textureMgr->GetTexture2(path);
|
||||
textureLoadedThisFrame++;
|
||||
}
|
||||
}
|
||||
else if (fileType == FileType::Project)
|
||||
{
|
||||
@@ -1037,6 +1040,8 @@ namespace Nuake
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
DrawContextMenu();
|
||||
@@ -1049,7 +1054,7 @@ namespace Nuake
|
||||
}
|
||||
|
||||
ThumbnailManager::Get().OnEndFrame();
|
||||
|
||||
textureLoadedThisFrame = 0;
|
||||
ImGui::EndChild();
|
||||
}
|
||||
ImGui::End();
|
||||
|
||||
@@ -8,6 +8,8 @@ namespace Nuake {
|
||||
{
|
||||
private:
|
||||
EditorInterface* Editor;
|
||||
const int maxTextureLoadedPerFrame = 4;
|
||||
int textureLoadedThisFrame = 0;
|
||||
|
||||
public:
|
||||
static Ref<Directory> m_CurrentDirectory;
|
||||
|
||||
@@ -15,7 +15,12 @@ using namespace Nuake;
|
||||
|
||||
FileBrowserWidget::FileBrowserWidget(EditorContext& inCtx) : IEditorWidget(inCtx)
|
||||
{
|
||||
currentDirectory = FileSystem::RootDirectory;
|
||||
SetCurrentDirectory(FileSystem::RootDirectory);
|
||||
}
|
||||
|
||||
void FileBrowserWidget::SetCurrentDirectory(Ref<Nuake::Directory> dir)
|
||||
{
|
||||
queueDirectory = dir;
|
||||
}
|
||||
|
||||
void FileBrowserWidget::Update(float ts)
|
||||
@@ -27,6 +32,12 @@ void FileBrowserWidget::Draw()
|
||||
{
|
||||
if (BeginWidgetWindow("File Browser"))
|
||||
{
|
||||
if (queueDirectory != currentDirectory)
|
||||
{
|
||||
opacity.SetValue(0.0f);
|
||||
opacity = 1.0f;
|
||||
currentDirectory = queueDirectory;
|
||||
}
|
||||
Ref<Nuake::Directory> rootDirectory = FileSystem::GetFileTree();
|
||||
|
||||
auto availableSpace = ImGui::GetContentRegionAvail();
|
||||
@@ -35,7 +46,8 @@ void FileBrowserWidget::Draw()
|
||||
ImVec4* colors = ImGui::GetStyle().Colors;
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, colors[ImGuiCol_TitleBgCollapsed]);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 8);
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2(0, 0));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, { 0, 0 });
|
||||
if (ImGui::BeginChild("Tree", ImVec2(splitterSizeLeft, availableSpace.y), true))
|
||||
{
|
||||
ImGuiTreeNodeFlags base_flags = ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_SpanAvailWidth |
|
||||
@@ -54,7 +66,7 @@ void FileBrowserWidget::Draw()
|
||||
bool open = ImGui::TreeNodeEx("PROJECT", base_flags);
|
||||
if (ImGui::IsItemClicked())
|
||||
{
|
||||
this->currentDirectory = FileSystem::RootDirectory;
|
||||
SetCurrentDirectory(FileSystem::RootDirectory);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,6 +79,8 @@ void FileBrowserWidget::Draw()
|
||||
ImGui::TreePop();
|
||||
}
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::PopStyleColor();
|
||||
ImGui::EndChild();
|
||||
|
||||
@@ -113,7 +127,7 @@ void FileBrowserWidget::Draw()
|
||||
{
|
||||
if (currentDirectory != FileSystem::RootDirectory)
|
||||
{
|
||||
currentDirectory = currentDirectory->Parent;
|
||||
SetCurrentDirectory(currentDirectory->Parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -127,7 +141,7 @@ void FileBrowserWidget::Draw()
|
||||
{
|
||||
if (editorContext.GetSelection().Type == EditorSelectionType::Directory)
|
||||
{
|
||||
currentDirectory = editorContext.GetSelection().Directory;
|
||||
SetCurrentDirectory(editorContext.GetSelection().Directory);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,7 +174,7 @@ void FileBrowserWidget::Draw()
|
||||
|
||||
if (ImGui::Button(pathLabel.c_str()))
|
||||
{
|
||||
currentDirectory = paths[i];
|
||||
SetCurrentDirectory(paths[i]);
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
@@ -217,6 +231,7 @@ void FileBrowserWidget::Draw()
|
||||
int i = 1; // current amount of item per row.
|
||||
if (ImGui::BeginTable("ssss", amount))
|
||||
{
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, opacity);
|
||||
// Button to go up a level.
|
||||
//if (m_CurrentDirectory && m_CurrentDirectory != FileSystem::RootDirectory && m_CurrentDirectory->Parent)
|
||||
//{
|
||||
@@ -274,10 +289,12 @@ void FileBrowserWidget::Draw()
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::PopStyleVar();
|
||||
//DrawContextMenu();
|
||||
|
||||
//m_HasClickedOnFile = false;
|
||||
|
||||
ImageLoaded = 0;
|
||||
ImGui::EndTable();
|
||||
}
|
||||
}
|
||||
@@ -308,7 +325,7 @@ void FileBrowserWidget::DrawFiletree(Ref<Nuake::Directory> dir)
|
||||
|
||||
if (ImGui::IsItemClicked())
|
||||
{
|
||||
currentDirectory = dir;
|
||||
SetCurrentDirectory(dir);
|
||||
}
|
||||
|
||||
if (open)
|
||||
@@ -351,7 +368,7 @@ void FileBrowserWidget::DrawDirectory(Ref<Nuake::Directory> directory, uint32_t
|
||||
{
|
||||
if (ImGui::IsMouseDoubleClicked(0))
|
||||
{
|
||||
currentDirectory = directory;
|
||||
SetCurrentDirectory(directory);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -386,7 +403,7 @@ void FileBrowserWidget::DrawDirectory(Ref<Nuake::Directory> directory, uint32_t
|
||||
{
|
||||
if (ImGui::MenuItem("Open"))
|
||||
{
|
||||
currentDirectory = directory;
|
||||
SetCurrentDirectory(directory);
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
@@ -594,7 +611,25 @@ void FileBrowserWidget::DrawFile(Ref<Nuake::File> file, uint32_t drawId)
|
||||
else if (fileType == FileType::Image)
|
||||
{
|
||||
const std::string path = file->GetAbsolutePath();
|
||||
textureImage = textureMgr->GetTexture2(path);
|
||||
|
||||
int32_t imageNumberToLoadMax = maxImageLoaded;
|
||||
if (ImGui::IsItemVisible())
|
||||
{
|
||||
imageNumberToLoadMax = 1;
|
||||
}
|
||||
|
||||
if (ImageLoaded < maxImageLoaded || textureMgr->IsTextureLoaded2(path))
|
||||
{
|
||||
if(!textureMgr->IsTextureLoaded2(path))
|
||||
ImageLoaded++;
|
||||
|
||||
textureImage = textureMgr->GetTexture2(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
textureImage = textureMgr->GetTexture2("Resources/Images/env_file_icon.png");
|
||||
}
|
||||
}
|
||||
else if (fileType == FileType::Project)
|
||||
{
|
||||
@@ -653,7 +688,7 @@ void FileBrowserWidget::DrawFile(Ref<Nuake::File> file, uint32_t drawId)
|
||||
|
||||
ImVec2 startOffset = ImVec2(imguiStyle.CellPadding.x / 2.0f, 0);
|
||||
ImVec2 offsetEnd = ImVec2(startOffset.x, imguiStyle.CellPadding.y / 2.0f);
|
||||
ImU32 rectColor = IM_COL32(255, 255, 255, 16);
|
||||
ImU32 rectColor = IM_COL32(255, 255, 255, 16 * opacity);
|
||||
ImGui::GetWindowDrawList()->AddRectFilled(prevScreenPos + ImVec2(0, 80) - startOffset, prevScreenPos + totalSize + offsetEnd, rectColor, 1.0f);
|
||||
|
||||
ImU32 rectColor2 = UI::PrimaryCol;
|
||||
@@ -882,36 +917,38 @@ Color FileBrowserWidget::GetColorByFileType(Nuake::FileType fileType)
|
||||
case Nuake::FileType::Mesh:
|
||||
break;
|
||||
case Nuake::FileType::Script:
|
||||
return { 1.0, 0.0, 0.0, 1.0 };
|
||||
return { 1.0, 0.0, 0.0, 1.0 * opacity };
|
||||
break;
|
||||
case Nuake::FileType::NetScript:
|
||||
return { 1.0, 0.0, 0.0, 1.0 };
|
||||
return { 1.0, 0.0, 0.0, 1.0 * opacity };
|
||||
break;
|
||||
case Nuake::FileType::Project:
|
||||
return Engine::GetProject()->Settings.PrimaryColor;
|
||||
auto color = Engine::GetProject()->Settings.PrimaryColor ;
|
||||
color.a *= opacity;
|
||||
return color;
|
||||
break;
|
||||
case Nuake::FileType::Prefab:
|
||||
break;
|
||||
case Nuake::FileType::Scene:
|
||||
return { 0, 1.0f, 1.0, 1.0 };
|
||||
return { 0, 1.0f, 1.0, 1.0 * opacity };
|
||||
break;
|
||||
case Nuake::FileType::Wad:
|
||||
break;
|
||||
case Nuake::FileType::Map:
|
||||
return { 0.0, 1.0, 0.0, 1.0 };
|
||||
return { 0.0, 1.0, 0.0, 1.0 * opacity };
|
||||
break;
|
||||
case Nuake::FileType::Assembly:
|
||||
break;
|
||||
case Nuake::FileType::Solution:
|
||||
break;
|
||||
case Nuake::FileType::Audio:
|
||||
return { 0.0, 0.0, 1.0, 1.0 };
|
||||
return { 0.0, 0.0, 1.0, 1.0 * opacity };
|
||||
break;
|
||||
case Nuake::FileType::UI:
|
||||
return { 1.0, 1.0, 0.0, 1.0 };
|
||||
return { 1.0, 1.0, 0.0, 1.0 * opacity };
|
||||
break;
|
||||
case Nuake::FileType::CSS:
|
||||
return { 1.0, 0.0, 1.0, 1.0 };
|
||||
return { 1.0, 0.0, 1.0, 1.0 * opacity };
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
|
||||
#include "IEditorWidget.h"
|
||||
|
||||
#include "../../../../../AnimatedValue.h"
|
||||
|
||||
namespace Nuake
|
||||
{
|
||||
class Directory;
|
||||
@@ -15,10 +17,13 @@ namespace Nuake
|
||||
class FileBrowserWidget : public IEditorWidget
|
||||
{
|
||||
private:
|
||||
AnimatedValue<float> opacity;
|
||||
float splitterSizeLeft = 300.0f;
|
||||
float splitterSizeRight = 300.0f;
|
||||
|
||||
int maxImageLoaded = 2;
|
||||
int ImageLoaded = 0;
|
||||
Ref<Nuake::Directory> currentDirectory;
|
||||
Ref<Nuake::Directory> queueDirectory;
|
||||
|
||||
std::string searchQuery;
|
||||
|
||||
@@ -27,6 +32,7 @@ public:
|
||||
~FileBrowserWidget() = default;
|
||||
|
||||
public:
|
||||
void SetCurrentDirectory(Ref<Nuake::Directory> dir);
|
||||
void Update(float ts) override;
|
||||
void Draw() override;
|
||||
|
||||
|
||||
@@ -418,11 +418,36 @@ void SceneHierarchyWidget::DrawEntity(Nuake::Entity entity, bool drawChildrens)
|
||||
editorContext.SetSelection(EditorSelection(entity));
|
||||
}
|
||||
|
||||
if (!isDragging && (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(0)) || Input::IsKeyPressed(Key::F2))
|
||||
if (!isDragging && (ImGui::IsItemHovered() && ImGui::IsMouseTripleClicked(0)) || Input::IsKeyPressed(Key::F2))
|
||||
{
|
||||
isRenaming = true;
|
||||
}
|
||||
|
||||
if (!isDragging && (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(0)) || Input::IsKeyPressed(Key::F2))
|
||||
{
|
||||
Ref<EditorCamera> editorCam = editorContext.GetScene()->m_EditorCamera;
|
||||
|
||||
// Get target object's world position
|
||||
glm::vec3 targetPos = glm::vec3(entity.GetComponent<TransformComponent>().GetGlobalTransform()[3]);
|
||||
|
||||
// Choose a direction and distance to place the camera away from the object
|
||||
glm::vec3 offset = glm::vec3(2.0f, 2.0f, 2.0f); // above and behind
|
||||
|
||||
// Place camera at offset from the target
|
||||
glm::vec3 camPos = targetPos + offset;
|
||||
|
||||
editorCam->Translation = camPos;
|
||||
|
||||
Vector3 direction = glm::normalize(targetPos - Vector3(camPos));
|
||||
float yaw = glm::degrees(atan2(direction.z, direction.x));
|
||||
float pitch = glm::degrees(asin(direction.y));
|
||||
|
||||
editorCam->TargetYaw = yaw;
|
||||
editorCam->TargetPitch = pitch;
|
||||
// Set the camera's transform as the inverse of the view matrix
|
||||
//editorCam->SetTransform(glm::inverse(view));
|
||||
}
|
||||
|
||||
if (!isRenaming && selection.Type == EditorSelectionType::Entity && Input::IsKeyPressed(Key::DELETE_KEY))
|
||||
{
|
||||
this->deletionQueue = selection.Entity;
|
||||
|
||||
@@ -18,6 +18,7 @@ public:
|
||||
private:
|
||||
std::string searchQuery;
|
||||
bool isRenaming;
|
||||
|
||||
Nuake::Entity deletionQueue;
|
||||
|
||||
void DrawSearchBar();
|
||||
|
||||
@@ -136,6 +136,7 @@ void SelectionPropertyWidget::DrawNone()
|
||||
ImGui::Text(text.c_str());
|
||||
}
|
||||
|
||||
Nuake::Entity lastEntity;
|
||||
void SelectionPropertyWidget::DrawEntity(Nuake::Entity entity)
|
||||
{
|
||||
if (!entity.IsValid())
|
||||
@@ -143,6 +144,14 @@ void SelectionPropertyWidget::DrawEntity(Nuake::Entity entity)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (lastEntity != entity)
|
||||
{
|
||||
opacity.SetValue(0.0f);
|
||||
opacity = 1.0f;
|
||||
lastEntity = entity;
|
||||
}
|
||||
|
||||
DrawAddComponentMenu(entity);
|
||||
|
||||
transformPanel.Draw(entity);
|
||||
@@ -1487,6 +1496,8 @@ void SelectionPropertyWidget::DrawFile(Ref<Nuake::File> file)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SelectionPropertyWidget::DrawResource(Nuake::Resource resource)
|
||||
{
|
||||
|
||||
@@ -1758,13 +1769,13 @@ void SelectionPropertyWidget::DrawNetScriptPanel(Ref<Nuake::File> file)
|
||||
void SelectionPropertyWidget::DrawComponent(Nuake::Entity& entity, entt::meta_any& component)
|
||||
{
|
||||
// Call into custom component drawer if one is available for this component
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, opacity);
|
||||
const auto componentIdHash = component.type().info().hash();
|
||||
if (ComponentTypeDrawers.contains(componentIdHash))
|
||||
{
|
||||
const auto drawerFn = ComponentTypeDrawers[componentIdHash];
|
||||
drawerFn(entity, component);
|
||||
|
||||
ImGui::PopStyleVar();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1818,7 +1829,7 @@ void SelectionPropertyWidget::DrawComponent(Nuake::Entity& entity, entt::meta_an
|
||||
ImGui::PopStyleVar();
|
||||
delete boldFont;
|
||||
}
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::PopStyleVar(2);
|
||||
}
|
||||
|
||||
void SelectionPropertyWidget::DrawComponentContent(entt::meta_any& component)
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#include "IEditorWidget.h"
|
||||
#include "../../EditorSelectionPanel.h"
|
||||
|
||||
#include "../../../../../AnimatedValue.h"
|
||||
|
||||
class EditorContext;
|
||||
|
||||
using DrawComponentTypeFn = std::function<void(Nuake::Entity& entity, entt::meta_any& componentInstance)>;
|
||||
@@ -15,6 +17,8 @@ private:
|
||||
SkinnedMeshPanel skinnedMeshPanel;
|
||||
Ref<Nuake::File> currentFile;
|
||||
Ref<Nuake::Resource> selectedResource;
|
||||
AnimatedValue<float> opacity;
|
||||
|
||||
public:
|
||||
SelectionPropertyWidget(EditorContext& inCtx);
|
||||
~SelectionPropertyWidget() = default;
|
||||
|
||||
@@ -26,13 +26,16 @@ IEditorWidget(context),
|
||||
gizmoDrawingMode(GizmoDrawingModes::EditorOnly)
|
||||
{
|
||||
OnSceneChanged(context.GetScene());
|
||||
|
||||
overlayOpacity.Speed = 10.0f;
|
||||
overlayOpacity = 1.0f;
|
||||
outlineSize = Engine::GetProject()->Settings.OutlineRadius;
|
||||
}
|
||||
|
||||
ViewportWidget::~ViewportWidget()
|
||||
{
|
||||
VkRenderer::Get().RemoveViewport(sceneViewport->GetID());
|
||||
}
|
||||
|
||||
void ViewportWidget::Update(float ts)
|
||||
{
|
||||
editorContext.GetScene()->Update(ts);
|
||||
@@ -58,12 +61,30 @@ void ViewportWidget::Update(float ts)
|
||||
|
||||
void ViewportWidget::Draw()
|
||||
{
|
||||
auto oldTarget = overlayOpacity.TargetValue;
|
||||
overlayOpacity.TargetValue = Engine::GetGameState() == GameState::Playing ? 0.0f : 1.0f;
|
||||
|
||||
if (overlayOpacity.TargetValue == oldTarget)
|
||||
{
|
||||
IAnimatedValue::UpdateAll(glm::clamp((float)Engine::GetTimestep(), 0.0f, Engine::GetFixedTimeStep()));
|
||||
}
|
||||
else
|
||||
{
|
||||
overlayOpacity.Value = (Engine::GetGameState() != GameState::Playing);
|
||||
overlayOpacity.TargetValue = 1.0f - overlayOpacity.Value;
|
||||
}
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
|
||||
if (BeginWidgetWindow(ICON_FA_GAMEPAD + std::string("Viewport")))
|
||||
{
|
||||
ImGui::PopStyleVar();
|
||||
|
||||
DrawOverlay();
|
||||
{
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, overlayOpacity.Value);
|
||||
Logger::Log("Opacity: " + std::to_string(overlayOpacity.Value), "Animated");
|
||||
DrawOverlay();
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
|
||||
ImGuizmo::BeginFrame();
|
||||
ImGuizmo::SetOrthographic(false);
|
||||
@@ -109,6 +130,8 @@ void ViewportWidget::Draw()
|
||||
ImGuizmo::AllowAxisFlip(true);
|
||||
ImGuizmo::SetRect(viewportMin.x, viewportMin.y, regionAvail.x, regionAvail.y);
|
||||
|
||||
Engine::GetProject()->Settings.OutlineRadius = outlineSize;
|
||||
|
||||
// TODO(grid)
|
||||
auto selection = editorContext.GetSelection();
|
||||
if (selection.Type == EditorSelectionType::Entity && !Engine::IsPlayMode())
|
||||
@@ -210,11 +233,14 @@ void ViewportWidget::Draw()
|
||||
Nuake::Entity entity = Nuake::Entity((entt::entity)picked, editorContext.GetScene().get());
|
||||
if (entity.IsValid())
|
||||
{
|
||||
outlineSize.SetValue(0.0f);
|
||||
outlineSize = 7.0f;
|
||||
editorContext.SetSelection(entity);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
outlineSize.SetValue(0.0f);
|
||||
editorContext.SetSelection(EditorSelection());
|
||||
}
|
||||
});
|
||||
@@ -508,11 +534,6 @@ void ViewportWidget::OnDebugDraw(DebugCmd& debugCmd)
|
||||
|
||||
void ViewportWidget::DrawOverlay()
|
||||
{
|
||||
if (Engine::GetGameState() == GameState::Playing)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
const float DISTANCE = 10.0f;
|
||||
int corner = 0;
|
||||
@@ -528,7 +549,7 @@ void ViewportWidget::DrawOverlay()
|
||||
ImGui::SetNextWindowPos(window_pos, ImGuiCond_Always, window_pos_pivot);
|
||||
ImGui::SetNextWindowViewport(viewport->ID);
|
||||
|
||||
ImGui::SetNextWindowBgAlpha(0.35f); // Transparent background
|
||||
ImGui::SetNextWindowBgAlpha(0.35f * overlayOpacity); // Transparent background
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 32.0f);
|
||||
|
||||
bool showOverlay = true;
|
||||
@@ -542,7 +563,7 @@ void ViewportWidget::DrawOverlay()
|
||||
if (selectedMode)
|
||||
{
|
||||
Color color = Engine::GetProject()->Settings.PrimaryColor;
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, { color.r, color.g, color.b, 1.0f });
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, { color.r, color.g, color.b, 1.0 });
|
||||
}
|
||||
|
||||
if (ImGui::Button(ICON_FA_ARROWS_ALT, ImVec2(30, 28)) || (ImGui::Shortcut(ImGuiKey_W, 0, ImGuiInputFlags_RouteGlobalLow) && !ImGui::IsAnyItemActive() && !IsControllingCamera))
|
||||
@@ -584,7 +605,7 @@ void ViewportWidget::DrawOverlay()
|
||||
if (selectedMode)
|
||||
{
|
||||
Color color = Engine::GetProject()->Settings.PrimaryColor;
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, { color.r, color.g, color.b, 1.0f });
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, { color.r, color.g, color.b, 1 });
|
||||
}
|
||||
|
||||
if (ImGui::Button(ICON_FA_EXPAND_ALT, ImVec2(30, 28)) || (ImGui::Shortcut(ImGuiKey_R, 0, ImGuiInputFlags_RouteGlobalLow) && !ImGui::IsAnyItemActive() && !IsControllingCamera))
|
||||
@@ -605,7 +626,7 @@ void ViewportWidget::DrawOverlay()
|
||||
if (selectedMode)
|
||||
{
|
||||
Color color = Engine::GetProject()->Settings.PrimaryColor;
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, { color.r, color.g, color.b, 1.0f });
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, { color.r, color.g, color.b, 1 });
|
||||
}
|
||||
|
||||
if (ImGui::Button(ICON_FA_GLOBE, ImVec2(30, 28)))
|
||||
@@ -626,7 +647,7 @@ void ViewportWidget::DrawOverlay()
|
||||
if (selectedMode)
|
||||
{
|
||||
Color color = Engine::GetProject()->Settings.PrimaryColor;
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, { color.r, color.g, color.b, 1.0f });
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, { color.r, color.g, color.b, 1 });
|
||||
}
|
||||
|
||||
if (ImGui::Button(ICON_FA_CUBE, ImVec2(30, 28)))
|
||||
@@ -646,6 +667,7 @@ void ViewportWidget::DrawOverlay()
|
||||
ImGui::SameLine();
|
||||
ImGui::PushItemWidth(75);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, { 6, 6 });
|
||||
|
||||
ImGui::DragFloat("##snapping", &CurrentSnapping.x, 0.01f, 0.0f, 100.0f);
|
||||
CurrentSnapping = { CurrentSnapping.x, CurrentSnapping.x, CurrentSnapping.x };
|
||||
ImGui::PopStyleVar();
|
||||
@@ -696,7 +718,7 @@ void ViewportWidget::DrawOverlay()
|
||||
ImVec2 end = start + ImGui::GetWindowSize() - ImVec2(0, 16.0);
|
||||
ImVec2 startOffset = ImVec2(start.x, end.y - (normalizedSpeed * (ImGui::GetWindowHeight() - 20.0)));
|
||||
|
||||
ImGui::GetWindowDrawList()->AddRectFilled(startOffset + ImVec2(0, 10.0), end + ImVec2(0.0, 20.0), IM_COL32(255, 255, 255, 180), 8.0f, ImDrawFlags_RoundCornersAll);
|
||||
ImGui::GetWindowDrawList()->AddRectFilled(startOffset + ImVec2(0, 10.0), end + ImVec2(0.0, 20.0), IM_COL32(255, 255, 255, 180 * overlayOpacity), 8.0f, ImDrawFlags_RoundCornersAll);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 100);
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "IEditorWidget.h"
|
||||
|
||||
#include <imgui/ImGuizmo.h>
|
||||
#include "../../../../../AnimatedValue.h"
|
||||
|
||||
class EditorContext;
|
||||
|
||||
@@ -26,6 +27,9 @@ private:
|
||||
private:
|
||||
Ref<Nuake::Viewport> sceneViewport;
|
||||
|
||||
AnimatedValue<float> outlineSize;
|
||||
AnimatedValue<float> overlayOpacity;
|
||||
|
||||
// Gizmo
|
||||
GizmoDrawingModes gizmoDrawingMode;
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ namespace Nuake
|
||||
static std::map<std::string, Ref<Texture>> m_Registry;
|
||||
static std::map<std::string, Ref<VulkanImage>> m_Registry2;
|
||||
bool IsTextureLoaded(const std::string path);
|
||||
bool IsTextureLoaded2(const std::string path);
|
||||
|
||||
void LoadStaticTextures();
|
||||
|
||||
@@ -23,6 +22,7 @@ namespace Nuake
|
||||
static TextureManager* Get();
|
||||
|
||||
TextureManager();
|
||||
bool IsTextureLoaded2(const std::string path);
|
||||
|
||||
Ref<Texture> GetTexture(const std::string path);
|
||||
Ref<VulkanImage> GetTexture2(const std::string path);
|
||||
|
||||
@@ -33,6 +33,10 @@ namespace Nuake
|
||||
void SetPitch(float pitch);
|
||||
|
||||
bool IsFlying() const { return m_IsFlying; }
|
||||
|
||||
|
||||
float TargetYaw = 0.f;
|
||||
float TargetPitch = 0.0f;
|
||||
private:
|
||||
bool controlled = false;
|
||||
bool firstMouse = false;
|
||||
@@ -42,8 +46,6 @@ namespace Nuake
|
||||
|
||||
float Yaw = 0.0f;
|
||||
float Pitch = 0.0f;
|
||||
float TargetYaw = 0.f;
|
||||
float TargetPitch = 0.0f;
|
||||
void UpdateDirection();
|
||||
};
|
||||
}
|
||||
|
||||
@@ -9310,6 +9310,13 @@ bool ImGui::IsMouseDoubleClicked(ImGuiMouseButton button, ImGuiID owner_id)
|
||||
return g.IO.MouseClickedCount[button] == 2 && TestKeyOwner(MouseButtonToKey(button), owner_id);
|
||||
}
|
||||
|
||||
bool ImGui::IsMouseTripleClicked(ImGuiMouseButton button)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown));
|
||||
return g.IO.MouseClickedCount[button] == 3 && TestKeyOwner(MouseButtonToKey(button), ImGuiKeyOwner_Any);
|
||||
}
|
||||
|
||||
int ImGui::GetMouseClickedCount(ImGuiMouseButton button)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
|
||||
@@ -3485,6 +3485,7 @@ namespace ImGui
|
||||
IMGUI_API bool IsMouseClicked(ImGuiMouseButton button, ImGuiID owner_id, ImGuiInputFlags flags = 0);
|
||||
IMGUI_API bool IsMouseReleased(ImGuiMouseButton button, ImGuiID owner_id);
|
||||
IMGUI_API bool IsMouseDoubleClicked(ImGuiMouseButton button, ImGuiID owner_id);
|
||||
IMGUI_API bool IsMouseTripleClicked(ImGuiMouseButton button);
|
||||
|
||||
// [EXPERIMENTAL] Shortcut Routing
|
||||
// - ImGuiKeyChord = a ImGuiKey optionally OR-red with ImGuiMod_Alt/ImGuiMod_Ctrl/ImGuiMod_Shift/ImGuiMod_Super.
|
||||
|
||||
Reference in New Issue
Block a user