More events added
This commit is contained in:
@@ -646,6 +646,9 @@ void EditorApp::startNewGame(const Ogre::String &scenePath)
|
||||
setGamePlayState(GamePlayState::Playing);
|
||||
Ogre::LogManager::getSingleton().logMessage(
|
||||
"Game started: loaded scene " + scenePath);
|
||||
// Send "scene_ready" event after scene is loaded and
|
||||
// entities/components are populated and ready to run.
|
||||
EventBus::getInstance().send("scene_ready");
|
||||
} else {
|
||||
Ogre::LogManager::getSingleton().logMessage(
|
||||
"Failed to load scene: " + serializer.getLastError());
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "StartupMenuSystem.hpp"
|
||||
#include "../EditorApp.hpp"
|
||||
#include "../components/StartupMenu.hpp"
|
||||
#include "EventBus.hpp"
|
||||
#include <imgui.h>
|
||||
#include <OgreFontManager.h>
|
||||
#include <OgreImGuiOverlay.h>
|
||||
@@ -118,7 +119,6 @@ void StartupMenuSystem::update(float deltaTime)
|
||||
|
||||
void StartupMenuSystem::renderMenu(StartupMenuComponent &sm)
|
||||
{
|
||||
|
||||
ImVec2 size = ImGui::GetMainViewport()->Size;
|
||||
ImGui::SetNextWindowPos(ImVec2(0, 0), ImGuiCond_Always);
|
||||
ImGui::SetNextWindowSize(ImVec2(size.x, size.y), ImGuiCond_Always);
|
||||
@@ -126,12 +126,12 @@ void StartupMenuSystem::renderMenu(StartupMenuComponent &sm)
|
||||
ImVec4 solidColor = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
ImGui::PushStyleColor(ImGuiCol_WindowBg, solidColor);
|
||||
|
||||
ImGui::Begin("StartupMenu", nullptr,
|
||||
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoDecoration |
|
||||
ImGuiWindowFlags_NoResize |
|
||||
ImGuiWindowFlags_NoMove |
|
||||
ImGuiWindowFlags_NoCollapse |
|
||||
ImGuiWindowFlags_NoFocusOnAppearing);
|
||||
ImGui::Begin(
|
||||
"StartupMenu", nullptr,
|
||||
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoDecoration |
|
||||
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove |
|
||||
ImGuiWindowFlags_NoCollapse |
|
||||
ImGuiWindowFlags_NoFocusOnAppearing);
|
||||
|
||||
if (m_menuFont)
|
||||
ImGui::PushFont(m_menuFont);
|
||||
@@ -143,25 +143,30 @@ void StartupMenuSystem::renderMenu(StartupMenuComponent &sm)
|
||||
|
||||
std::vector<ButtonData> buttons;
|
||||
buttons.push_back({ "NEW GAME", [&]() {
|
||||
// Send "new_game" event before starting the game
|
||||
EventBus::getInstance().send("new_game");
|
||||
m_editorApp->startNewGame(sm.newGameScene);
|
||||
} });
|
||||
|
||||
if (sm.showLoadGame)
|
||||
buttons.push_back({ "LOAD GAME", [&]() {
|
||||
Ogre::LogManager::getSingleton().logMessage(
|
||||
"Load game not implemented");
|
||||
} });
|
||||
buttons.push_back(
|
||||
{ "LOAD GAME", [&]() {
|
||||
Ogre::LogManager::getSingleton().logMessage(
|
||||
"Load game not implemented");
|
||||
} });
|
||||
|
||||
if (sm.showOptions)
|
||||
buttons.push_back({ "OPTIONS", [&]() {
|
||||
Ogre::LogManager::getSingleton().logMessage(
|
||||
"Options not implemented");
|
||||
} });
|
||||
buttons.push_back(
|
||||
{ "OPTIONS", [&]() {
|
||||
Ogre::LogManager::getSingleton().logMessage(
|
||||
"Options not implemented");
|
||||
} });
|
||||
|
||||
if (sm.showQuit)
|
||||
buttons.push_back({ "QUIT", [&]() {
|
||||
Ogre::Root::getSingleton().queueEndRendering();
|
||||
} });
|
||||
buttons.push_back(
|
||||
{ "QUIT", [&]() {
|
||||
Ogre::Root::getSingleton().queueEndRendering();
|
||||
} });
|
||||
|
||||
// Calculate button dimensions
|
||||
float buttonWidth = 0.0f;
|
||||
@@ -172,12 +177,11 @@ void StartupMenuSystem::renderMenu(StartupMenuComponent &sm)
|
||||
float bwidth = textSize.x +
|
||||
(ImGui::GetStyle().FramePadding.x * 2.0f) +
|
||||
extraPixels;
|
||||
float bheight = textSize.y +
|
||||
(ImGui::GetStyle().FramePadding.y * 2.0f);
|
||||
float bheight =
|
||||
textSize.y + (ImGui::GetStyle().FramePadding.y * 2.0f);
|
||||
if (buttonWidth < bwidth)
|
||||
buttonWidth = bwidth;
|
||||
buttonsHeight += bheight +
|
||||
ImGui::GetStyle().ItemSpacing.y;
|
||||
buttonsHeight += bheight + ImGui::GetStyle().ItemSpacing.y;
|
||||
}
|
||||
if (!buttons.empty())
|
||||
buttonsHeight -= ImGui::GetStyle().ItemSpacing.y;
|
||||
@@ -205,13 +209,13 @@ void StartupMenuSystem::renderMissingMenuError()
|
||||
ImVec4 solidColor = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
ImGui::PushStyleColor(ImGuiCol_WindowBg, solidColor);
|
||||
|
||||
ImGui::Begin("StartupMenuError", nullptr,
|
||||
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoDecoration |
|
||||
ImGuiWindowFlags_NoResize |
|
||||
ImGuiWindowFlags_NoMove |
|
||||
ImGuiWindowFlags_NoCollapse |
|
||||
ImGuiWindowFlags_NoFocusOnAppearing |
|
||||
ImGuiWindowFlags_NoInputs);
|
||||
ImGui::Begin(
|
||||
"StartupMenuError", nullptr,
|
||||
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoDecoration |
|
||||
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove |
|
||||
ImGuiWindowFlags_NoCollapse |
|
||||
ImGuiWindowFlags_NoFocusOnAppearing |
|
||||
ImGuiWindowFlags_NoInputs);
|
||||
|
||||
const char *msg = "Error: No StartupMenuComponent entity found.\n"
|
||||
"Make sure startup_menu.json is loaded and contains\n"
|
||||
|
||||
Reference in New Issue
Block a user