SDXFrameWork  0.13
SDXFrameWork
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
Director.h
1 //Copyright © 2014 SDXFramework
2 //[License]GNU Affero General Public License, version 3
3 //[Contact]http://sourceforge.jp/projects/dxframework/
4 #pragma once
5 #include <Framework/IScene.h>
6 
7 namespace SDX
8 {
11  class Director
12  {
13  private:
14  MONO_STATE(Director)
15 
16  static std::vector<std::shared_ptr<IScene>>& Single()
17  {
18  static std::vector<std::shared_ptr<IScene>> instance;
19  return instance;
20  }
21 
23  static void Remove()
24  {
25  auto it = Single().begin();
26 
27  while (it != Single().end())
28  {
29  if ((*it)->isEnd)
30  {
31  it = Single().erase(it);
32  if (Single().size() == 0){ break; }
33  continue;
34  }
35  it++;
36  }
37  }
38 
39  public:
41  static void Run()
42  {
44 
45  while (System::Update(IsDraw()))
46  {
47  if (Single().size() == 0){ break; }
48  Single().back()->Update();
49  if (IsDraw()){ Single().back()->Draw(); }
50 
52 
53  Remove();
54  }
55  }
56 
60  static void AddScene(std::shared_ptr<IScene> 追加するシーン)
61  {
62  bool isExist = false;
63 
64  //既に存在する場合、削除してから追加
65  auto it = Single().begin();
66  while (it != Single().end())
67  {
68  if ((*it) == 追加するシーン)
69  {
70  isExist = true;
71  Single().erase(it);
72  break;
73  }
74  ++it;
75  }
76 
77  Single().push_back(追加するシーン);
78  }
79 
82  static std::shared_ptr<IScene> GetScene(int インデックス)
83  {
84  return Single()[Single().size() - インデックス - 1];
85  }
86 
89  static bool ActiveScene(int インデックス)
90  {
91  int no = Single().size() - インデックス - 1;
92  if (no < 0) { return false; }
93 
94  AddScene(Single()[no]);
95 
96  return true;
97  }
98 
100  static bool& IsDraw()
101  {
102  static bool isDraw = true;
103  return isDraw;
104  }
105 
106  };
107 }
static bool Update(bool 描画更新フラグ=true)
各種更新処理をまとめて行う.
Definition: System.h:111
static void Run()
実行開始.
Definition: Director.h:41
static std::shared_ptr< IScene > GetScene(int インデックス)
上からインデックス番目のシーンを取得.
Definition: Director.h:82
static void CheckFPS()
FPS計測を更新.
Definition: Time.h:75
シーンを管理するクラス.
Definition: Director.h:11
static void ResetFPS()
FPSの計測開始.
Definition: Time.h:69
static bool & IsDraw()
描画更新フラグを設定.
Definition: Director.h:100
static bool ActiveScene(int インデックス)
上からインデックス番目のシーンをアクティブにする.
Definition: Director.h:89
static void AddScene(std::shared_ptr< IScene > 追加するシーン)
Sceneを追加しスタックに積む.
Definition: Director.h:60