Skip to content

Commit

Permalink
Added pointers of most commonly used subsystems to Context
Browse files Browse the repository at this point in the history
  • Loading branch information
rokups committed Jun 27, 2017
1 parent 04ad84e commit 4b61629
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
42 changes: 42 additions & 0 deletions Source/Atomic/Core/Context.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,27 @@ class GlobalEventListener
virtual void EndSendEvent(Context* context, Object* sender, StringHash eventType, VariantMap& eventData) = 0;
};

class Metrics;
class Engine;
class Time;
class WorkQueue;
class Profiler;
class FileSystem;
class Log;
class ResourceCache;
class Localization;
class Network;
class Web;
class Database;
class Input;
class Audio;
class UI;
class SystemUI;
class Graphics;
class Renderer;
class Console;
class DebugHud;

// ATOMIC END

/// Tracking structure for event receivers.
Expand Down Expand Up @@ -228,6 +249,27 @@ class ATOMIC_API Context : public RefCounted
void AddGlobalEventListener(GlobalEventListener* listener) { globalEventListeners_.Push(listener); }
void RemoveGlobalEventListener(GlobalEventListener* listener) { globalEventListeners_.Erase(globalEventListeners_.Find(listener)); }

WeakPtr<Engine> engine_;
WeakPtr<Time> time_;
WeakPtr<WorkQueue> workQueue_;
WeakPtr<Profiler> profiler_;
WeakPtr<FileSystem> fileSystem_;
WeakPtr<Log> log_;
WeakPtr<ResourceCache> cache_;
WeakPtr<Localization> l18n_;
WeakPtr<Network> network_;
WeakPtr<Web> web_;
WeakPtr<Database> db_;
WeakPtr<Input> input_;
WeakPtr<Audio> audio_;
WeakPtr<UI> ui_;
WeakPtr<SystemUI> systemUi_;
WeakPtr<Graphics> graphics_;
WeakPtr<Renderer> renderer_;
WeakPtr<Console> console_;
WeakPtr<DebugHud> debugHud_;
WeakPtr<Metrics> metrics_;

// ATOMIC END

private:
Expand Down
25 changes: 25 additions & 0 deletions Source/Atomic/Engine/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
// ATOMIC BEGIN
#include "../Resource/XMLFile.h"
#include "../UI/SystemUI/SystemUI.h"
#include "../UI/SystemUI/Console.h"
#include "../UI/SystemUI/DebugHud.h"
// ATOMIC END

#ifdef ATOMIC_NAVIGATION
Expand Down Expand Up @@ -348,6 +350,29 @@ bool Engine::Initialize(const VariantMap& parameters)

// ATOMIC BEGIN
context_->RegisterSubsystem(new SystemUI(context_));

context_->engine_ = GetSubsystem<Engine>();
context_->time_ = GetSubsystem<Time>();
context_->workQueue_ = GetSubsystem<WorkQueue>();
context_->profiler_ = GetSubsystem<Profiler>();
context_->fileSystem_ = GetSubsystem<FileSystem>();
context_->log_ = GetSubsystem<Log>();
context_->cache_ = GetSubsystem<ResourceCache>();
context_->l18n_ = GetSubsystem<Localization>();
context_->network_ = GetSubsystem<Network>();
context_->web_ = GetSubsystem<Web>();
#ifdef ATOMIC_DATABASE
context_->db_ = GetSubsystem<Database>();
#endif
context_->input_ = GetSubsystem<Input>();
context_->audio_ = GetSubsystem<Audio>();
context_->ui_ = GetSubsystem<UI>();
context_->systemUi_ = GetSubsystem<SystemUI>();
context_->graphics_ = GetSubsystem<Graphics>();
context_->renderer_ = GetSubsystem<Renderer>();
context_->console_ = GetSubsystem<Console>();
context_->debugHud_ = GetSubsystem<DebugHud>();
context_->metrics_ = GetSubsystem<Metrics>();
// ATOMIC END

frameTimer_.Reset();
Expand Down

0 comments on commit 4b61629

Please sign in to comment.