Editor Tweaks #192
|
@ -223,39 +223,20 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
if(editor->SaveScene())
|
if(editor->SaveScene())
|
||||||
{
|
{
|
||||||
const SHEditorStateChangeEvent STATE_CHANGE_EVENT
|
editor->Play();
|
||||||
{
|
|
||||||
.previousState = editor->editorState
|
|
||||||
};
|
|
||||||
editor->editorState = SHEditor::State::PLAY;
|
|
||||||
SHCommandManager::SwapStacks();
|
|
||||||
SHEventManager::BroadcastEvent<SHEditorStateChangeEvent>(STATE_CHANGE_EVENT, SH_EDITOR_ON_PLAY_EVENT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::EndDisabled();
|
ImGui::EndDisabled();
|
||||||
ImGui::BeginDisabled(editor->editorState == SHEditor::State::PAUSE);
|
ImGui::BeginDisabled(editor->editorState == SHEditor::State::PAUSE);
|
||||||
if(ImGui::SmallButton(ICON_MD_PAUSE))
|
if(ImGui::SmallButton(ICON_MD_PAUSE))
|
||||||
{
|
{
|
||||||
const SHEditorStateChangeEvent STATE_CHANGE_EVENT
|
editor->Pause();
|
||||||
{
|
|
||||||
.previousState = editor->editorState
|
|
||||||
};
|
|
||||||
editor->editorState = SHEditor::State::PAUSE;
|
|
||||||
|
|
||||||
SHEventManager::BroadcastEvent<SHEditorStateChangeEvent>(STATE_CHANGE_EVENT, SH_EDITOR_ON_PAUSE_EVENT);
|
|
||||||
}
|
}
|
||||||
ImGui::EndDisabled();
|
ImGui::EndDisabled();
|
||||||
ImGui::BeginDisabled(editor->editorState == SHEditor::State::STOP);
|
ImGui::BeginDisabled(editor->editorState == SHEditor::State::STOP);
|
||||||
if(ImGui::SmallButton(ICON_MD_STOP))
|
if(ImGui::SmallButton(ICON_MD_STOP))
|
||||||
{
|
{
|
||||||
const SHEditorStateChangeEvent STATE_CHANGE_EVENT
|
editor->Stop();
|
||||||
{
|
|
||||||
.previousState = editor->editorState
|
|
||||||
};
|
|
||||||
editor->editorState = SHEditor::State::STOP;
|
|
||||||
SHCommandManager::SwapStacks();
|
|
||||||
SHEventManager::BroadcastEvent<SHEditorStateChangeEvent>(STATE_CHANGE_EVENT, SH_EDITOR_ON_STOP_EVENT);
|
|
||||||
editor->LoadScene(SHSceneManager::GetCurrentSceneAssetID());
|
|
||||||
}
|
}
|
||||||
ImGui::EndDisabled();
|
ImGui::EndDisabled();
|
||||||
ImGui::EndMenuBar();
|
ImGui::EndMenuBar();
|
||||||
|
|
|
@ -168,6 +168,18 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
SHCommandManager::UndoCommand();
|
SHCommandManager::UndoCommand();
|
||||||
}
|
}
|
||||||
|
if(ImGui::IsKeyReleased(ImGuiKey_F5))
|
||||||
|
{
|
||||||
|
Play();
|
||||||
|
}
|
||||||
|
else if (ImGui::IsKeyReleased(ImGuiKey_F6))
|
||||||
|
{
|
||||||
|
Pause();
|
||||||
|
}
|
||||||
|
else if (ImGui::IsKeyReleased(ImGuiKey_F7))
|
||||||
|
{
|
||||||
|
Stop();
|
||||||
|
}
|
||||||
|
|
||||||
Render();
|
Render();
|
||||||
}
|
}
|
||||||
|
@ -597,6 +609,48 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SHEditor::Play()
|
||||||
|
{
|
||||||
|
if(editorState == State::PLAY)
|
||||||
|
return;
|
||||||
|
if (SaveScene())
|
||||||
|
{
|
||||||
|
const SHEditorStateChangeEvent STATE_CHANGE_EVENT
|
||||||
|
{
|
||||||
|
.previousState = editorState
|
||||||
|
};
|
||||||
|
editorState = State::PLAY;
|
||||||
|
SHCommandManager::SwapStacks();
|
||||||
|
SHEventManager::BroadcastEvent<SHEditorStateChangeEvent>(STATE_CHANGE_EVENT, SH_EDITOR_ON_PLAY_EVENT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHEditor::Pause()
|
||||||
|
{
|
||||||
|
if (editorState == State::PAUSE)
|
||||||
|
return;
|
||||||
|
const SHEditorStateChangeEvent STATE_CHANGE_EVENT
|
||||||
|
{
|
||||||
|
.previousState = editorState
|
||||||
|
};
|
||||||
|
editorState = State::PAUSE;
|
||||||
|
SHEventManager::BroadcastEvent<SHEditorStateChangeEvent>(STATE_CHANGE_EVENT, SH_EDITOR_ON_PAUSE_EVENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHEditor::Stop()
|
||||||
|
{
|
||||||
|
if (editorState == State::STOP)
|
||||||
|
return;
|
||||||
|
const SHEditorStateChangeEvent STATE_CHANGE_EVENT
|
||||||
|
{
|
||||||
|
.previousState = editorState
|
||||||
|
};
|
||||||
|
editorState = SHEditor::State::STOP;
|
||||||
|
SHCommandManager::SwapStacks();
|
||||||
|
SHEventManager::BroadcastEvent<SHEditorStateChangeEvent>(STATE_CHANGE_EVENT, SH_EDITOR_ON_STOP_EVENT);
|
||||||
|
LoadScene(SHSceneManager::GetCurrentSceneAssetID());
|
||||||
|
}
|
||||||
|
|
||||||
void SHEditor::NewFrame()
|
void SHEditor::NewFrame()
|
||||||
{
|
{
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
|
|
|
@ -184,6 +184,10 @@ namespace SHADE
|
||||||
|
|
||||||
void LoadScene(AssetID const& assetID) noexcept;
|
void LoadScene(AssetID const& assetID) noexcept;
|
||||||
|
|
||||||
|
void Play();
|
||||||
|
void Pause();
|
||||||
|
void Stop();
|
||||||
|
|
||||||
// List of selected entities
|
// List of selected entities
|
||||||
std::vector<EntityID> selectedEntities;
|
std::vector<EntityID> selectedEntities;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue