play pause stop bound to F5 F6 F7
This commit is contained in:
parent
69ac074926
commit
e2bcb0bbbb
|
@ -223,39 +223,20 @@ namespace SHADE
|
|||
{
|
||||
if(editor->SaveScene())
|
||||
{
|
||||
const SHEditorStateChangeEvent STATE_CHANGE_EVENT
|
||||
{
|
||||
.previousState = editor->editorState
|
||||
};
|
||||
editor->editorState = SHEditor::State::PLAY;
|
||||
SHCommandManager::SwapStacks();
|
||||
SHEventManager::BroadcastEvent<SHEditorStateChangeEvent>(STATE_CHANGE_EVENT, SH_EDITOR_ON_PLAY_EVENT);
|
||||
editor->Play();
|
||||
}
|
||||
}
|
||||
ImGui::EndDisabled();
|
||||
ImGui::BeginDisabled(editor->editorState == SHEditor::State::PAUSE);
|
||||
if(ImGui::SmallButton(ICON_MD_PAUSE))
|
||||
{
|
||||
const SHEditorStateChangeEvent STATE_CHANGE_EVENT
|
||||
{
|
||||
.previousState = editor->editorState
|
||||
};
|
||||
editor->editorState = SHEditor::State::PAUSE;
|
||||
|
||||
SHEventManager::BroadcastEvent<SHEditorStateChangeEvent>(STATE_CHANGE_EVENT, SH_EDITOR_ON_PAUSE_EVENT);
|
||||
editor->Pause();
|
||||
}
|
||||
ImGui::EndDisabled();
|
||||
ImGui::BeginDisabled(editor->editorState == SHEditor::State::STOP);
|
||||
if(ImGui::SmallButton(ICON_MD_STOP))
|
||||
{
|
||||
const SHEditorStateChangeEvent STATE_CHANGE_EVENT
|
||||
{
|
||||
.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());
|
||||
editor->Stop();
|
||||
}
|
||||
ImGui::EndDisabled();
|
||||
ImGui::EndMenuBar();
|
||||
|
|
|
@ -168,7 +168,19 @@ namespace SHADE
|
|||
{
|
||||
SHCommandManager::UndoCommand();
|
||||
}
|
||||
|
||||
if(ImGui::IsKeyReleased(ImGuiKey_F5))
|
||||
{
|
||||
Play();
|
||||
}
|
||||
else if (ImGui::IsKeyReleased(ImGuiKey_F6))
|
||||
{
|
||||
Pause();
|
||||
}
|
||||
else if (ImGui::IsKeyReleased(ImGuiKey_F7))
|
||||
{
|
||||
Stop();
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
SDL_Event event;
|
||||
|
|
|
@ -184,6 +184,10 @@ namespace SHADE
|
|||
|
||||
void LoadScene(AssetID const& assetID) noexcept;
|
||||
|
||||
void Play();
|
||||
void Pause();
|
||||
void Stop();
|
||||
|
||||
// List of selected entities
|
||||
std::vector<EntityID> selectedEntities;
|
||||
|
||||
|
|
Loading…
Reference in New Issue