Skip to content

Commit

Permalink
#5200: MainFrame initialises itself now after the radiant module has …
Browse files Browse the repository at this point in the history
…been started up
  • Loading branch information
codereader committed Aug 27, 2020
1 parent 21820e1 commit 9f252a5
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 30 deletions.
8 changes: 8 additions & 0 deletions include/imainframe.h
Expand Up @@ -117,6 +117,14 @@ class IMainFrame :
* automatically removed by this class.
*/
virtual sigc::signal<void>& signal_MainFrameConstructed() = 0;

/**
* Signal fired after the MainFrame window is shown the first time
* during application start up.
* This is a one-time signal, after emission the subscribers will be
* automatically removed by this class.
*/
virtual sigc::signal<void>& signal_MainFrameReady() = 0;
};

// This is the accessor for the mainframe module
Expand Down
22 changes: 3 additions & 19 deletions radiant/RadiantModule.cpp
@@ -1,18 +1,9 @@
#include "RadiantModule.h"

#include <iostream>
#include <ctime>

#include "iregistry.h"
#include "icommandsystem.h"
#include "itextstream.h"
#include "iuimanager.h"
#include "ieventmanager.h"
#include "i18n.h"
#include "imainframe.h"

#include "scene/Node.h"

#include "module/StaticModule.h"

namespace radiant
Expand Down Expand Up @@ -75,18 +66,11 @@ void RadiantModule::shutdownModule()

void RadiantModule::postModuleInitialisation()
{
// Initialise the mainframe
GlobalMainFrame().construct();

// Broadcast the startup event
rMessage() << "All modules initialised, radiant started" << std::endl;

// Broadcast the startup event
broadcastStartupEvent();

// Load the shortcuts from the registry
GlobalEventManager().loadAccelerators();

// Show the top level window as late as possible
GlobalMainFrame().getWxTopLevelWindow()->Show();

time_t localtime;
time(&localtime);
rMessage() << "Startup complete at " << ctime(&localtime) << std::endl;
Expand Down
11 changes: 6 additions & 5 deletions radiant/map/StartupMapLoader.cpp
Expand Up @@ -6,8 +6,9 @@
#include "irender.h"
#include "iregistry.h"
#include "icommandsystem.h"
#include "itextstream.h"
#include "igame.h"
#include "iradiant.h"
#include "imainframe.h"
#include "imru.h"
#include "module/StaticModule.h"

Expand All @@ -18,7 +19,7 @@
namespace map
{

void StartupMapLoader::onRadiantStartup()
void StartupMapLoader::onMainFrameReady()
{
std::string mapToLoad = "";

Expand Down Expand Up @@ -99,7 +100,7 @@ const StringSet& StartupMapLoader::getDependencies() const

if (_dependencies.empty())
{
_dependencies.insert(MODULE_RADIANT_APP);
_dependencies.insert(MODULE_MAINFRAME);
}

return _dependencies;
Expand All @@ -109,8 +110,8 @@ void StartupMapLoader::initialiseModule(const IApplicationContext& ctx)
{
rMessage() << getName() << "::initialiseModule called." << std::endl;

GlobalRadiant().signal_radiantStarted().connect(
sigc::mem_fun(*this, &StartupMapLoader::onRadiantStartup)
GlobalMainFrame().signal_MainFrameReady().connect(
sigc::mem_fun(*this, &StartupMapLoader::onMainFrameReady)
);
}

Expand Down
4 changes: 2 additions & 2 deletions radiant/map/StartupMapLoader.h
Expand Up @@ -16,8 +16,8 @@ class StartupMapLoader :
void initialiseModule(const IApplicationContext& ctx) override;

private:
// This gets called as soon as the mainframe starts up
void onRadiantStartup();
// This gets called as soon as the mainframe is shown
void onMainFrameReady();

void loadMapSafe(const std::string& map);
};
Expand Down
25 changes: 25 additions & 0 deletions radiant/ui/mainframe/MainFrame.cpp
Expand Up @@ -10,6 +10,7 @@
#include "ientityinspector.h"
#include "iorthoview.h"
#include "iregistry.h"
#include "iradiant.h"

#include "log/Console.h"
#include "xyview/GlobalXYWnd.h"
Expand Down Expand Up @@ -73,6 +74,7 @@ const StringSet& MainFrame::getDependencies() const
_dependencies.insert(MODULE_ORTHOVIEWMANAGER);
_dependencies.insert(MODULE_CAMERA);
_dependencies.insert(MODULE_MAP);
_dependencies.insert(MODULE_RADIANT_APP);
}

return _dependencies;
Expand Down Expand Up @@ -146,6 +148,9 @@ void MainFrame::initialiseModule(const IApplicationContext& ctx)
_mapModifiedChangedConn = GlobalMapModule().signal_modifiedChanged().connect(
sigc::mem_fun(this, &MainFrame::updateTitle)
);

GlobalRadiant().signal_radiantStarted().connect(
sigc::mem_fun(this, &MainFrame::onRadiantStarted));
}

void MainFrame::shutdownModule()
Expand All @@ -168,6 +173,21 @@ void MainFrame::exitCmd(const cmd::ArgumentList& args)
}
}

void MainFrame::onRadiantStarted()
{
// Initialise the mainframe
construct();

// Load the shortcuts from the registry
GlobalEventManager().loadAccelerators();

// Show the top level window as late as possible
getWxTopLevelWindow()->Show();

signal_MainFrameReady().emit();
signal_MainFrameReady().clear();
}

void MainFrame::keyChanged()
{
#ifdef WIN32
Expand Down Expand Up @@ -540,6 +560,11 @@ sigc::signal<void>& MainFrame::signal_MainFrameConstructed()
return _sigMainFrameConstructed;
}

sigc::signal<void>& MainFrame::signal_MainFrameReady()
{
return _sigMainFrameReady;
}

// Define the static MainFrame module
module::StaticModule<MainFrame> mainFrameModule;

Expand Down
5 changes: 5 additions & 0 deletions radiant/ui/mainframe/MainFrame.h
Expand Up @@ -29,6 +29,7 @@ class MainFrame :
sigc::connection _mapModifiedChangedConn;

sigc::signal<void> _sigMainFrameConstructed;
sigc::signal<void> _sigMainFrameReady;

private:
void keyChanged();
Expand Down Expand Up @@ -62,6 +63,7 @@ class MainFrame :
const std::string& message, bool forceDisplay = false) override;

sigc::signal<void>& signal_MainFrameConstructed() override;
sigc::signal<void>& signal_MainFrameReady() override;

// Command to toggle the current layout's camera fullscreen mode
void toggleFullscreenCameraView(const cmd::ArgumentList& args);
Expand All @@ -86,6 +88,9 @@ class MainFrame :
// Creates the topmost application window
void createTopLevelWindow();

// Constructs the MainFrame and shows the Window
void onRadiantStarted();

#ifdef WIN32
// Enables or disabled desktop composition, Windows-specific
void setDesktopCompositionEnabled(bool enabled);
Expand Down
7 changes: 4 additions & 3 deletions radiantcore/map/Map.cpp
Expand Up @@ -66,6 +66,7 @@ namespace

Map::Map() :
_lastCopyMapName(""),
_modified(false),
_saveInProgress(false),
_shutdownListener(0)
{}
Expand Down Expand Up @@ -217,14 +218,14 @@ void Map::freeMap()

bool Map::isModified() const
{
return m_modified;
return _modified;
}

void Map::setModified(bool modifiedFlag)
{
if (m_modified != modifiedFlag)
if (_modified != modifiedFlag)
{
m_modified = modifiedFlag;
_modified = modifiedFlag;

// when the map is modified, let the listeners now
signal_modifiedChanged().emit();
Expand Down
2 changes: 1 addition & 1 deletion radiantcore/map/Map.h
Expand Up @@ -42,7 +42,7 @@ class Map :
// Pointer to the resource for this map
IMapResourcePtr _resource;

bool m_modified;
bool _modified;

scene::INodePtr _worldSpawnNode; // "classname" "worldspawn" !

Expand Down

0 comments on commit 9f252a5

Please sign in to comment.