Skip to content

Commit

Permalink
Fix bug Editor (newGUI will save on old file)
Browse files Browse the repository at this point in the history
  • Loading branch information
ducphamhong committed Aug 22, 2024
1 parent 2561380 commit 239a6a3
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,9 @@ namespace Skylicht
canvas->removeAllElement();
m_gizmos->onRemove();

CGUIDesignController::getInstance()->rebuildGUIHierachy();
CGUIDesignController* controller = CGUIDesignController::getInstance();
controller->rebuildGUIHierachy();
controller->newGUI();
resetView(canvas);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,11 @@ namespace Skylicht
}
}

void CGUIDesignController::newGUI()
{
m_guiFilePath = "";
}

bool CGUIDesignController::needSave()
{
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ namespace Skylicht
return m_guiFilePath;
}

void newGUI();

bool needSave();

void save(const char* path);
Expand Down
7 changes: 5 additions & 2 deletions Projects/Main/Platforms/Emscripten/Index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
<title>Skylicht Engine</title>
<meta name="description" content="">
<style type="text/css">
body {
margin: 0 auto;
html,body {
margin: 0 !important;
padding: 0 !important;
background: #000000;
overflow: hidden;
display: block;
}
</style>
</head>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ namespace Skylicht
CUIEventManager::CUIEventManager() :
m_pointerId(-1),
m_capture(NULL),
m_focus(NULL)
m_focus(NULL),
m_pointerX(0),
m_pointerY(0)
{
CEventManager::getInstance()->registerProcessorEvent("CUIEventManager", this);
}
Expand All @@ -52,6 +54,9 @@ namespace Skylicht
f32 mouseX = (f32)event.MouseInput.X;
f32 mouseY = (f32)event.MouseInput.Y;

m_pointerX = event.MouseInput.X;
m_pointerY = event.MouseInput.Y;

if (m_pointerId != -1 && event.MouseInput.ID != m_pointerId)
return true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,16 @@ namespace Skylicht
public:
DECLARE_SINGLETON(CUIEventManager)

protected:
std::vector<CUIContainer*> m_containers;

int m_pointerId;

CUIBase* m_capture;

CUIBase* m_focus;

int m_pointerId;
int m_pointerX;
int m_pointerY;

public:
CUIEventManager();

Expand All @@ -69,6 +71,16 @@ namespace Skylicht
{
return m_focus;
}

inline int getPointerX()
{
return m_pointerX;
}

inline int getPointerY()
{
return m_pointerY;
}
};
}
}

0 comments on commit 239a6a3

Please sign in to comment.