OSDN Git Service

Sceneに標準でProcessInputメソッドを追加
authorh2so5 <h2so5@git.sourceforge.jp>
Sat, 22 Sep 2012 01:15:05 +0000 (10:15 +0900)
committerh2so5 <h2so5@git.sourceforge.jp>
Sat, 22 Sep 2012 01:15:05 +0000 (10:15 +0900)
Optionシーンを追加

16 files changed:
client/ConfigManager.hpp
client/Core.cpp
client/scene/Base.hpp
client/scene/Connect.cpp
client/scene/Connect.hpp
client/scene/Init.cpp
client/scene/Init.hpp
client/scene/MainLoop.cpp
client/scene/MainLoop.hpp
client/scene/Option.cpp [new file with mode: 0644]
client/scene/Option.hpp [new file with mode: 0644]
client/scene/ServerChange.cpp
client/scene/ServerChange.hpp
client/scene/Title.cpp
client/scene/Title.hpp
server/Server.cpp

index caa2662..083d817 100644 (file)
@@ -44,6 +44,7 @@ class ConfigManager
         bool antialias() const;
         std::string host() const;
         int port() const;
+
         int max_script_execution_time() const;
         int max_local_storage_size() const;
         bool upnp() const;
index 0d207de..73196e4 100644 (file)
@@ -59,6 +59,9 @@ void Core::MainLoop()
             current_scene_) {
 
         InputManager::Update();
+               InputManager input;
+               
+        current_scene_->ProcessInput(&input);
         current_scene_->Update();
         current_scene_->Draw();
 
index f9ce0ac..c735562 100644 (file)
@@ -7,16 +7,18 @@
 #include "DxLib.h"
 #include <memory>
 #include "../../common/unicode.hpp"
+#include "../InputManager.hpp"
 
 namespace scene {
 class Base;
 typedef std::shared_ptr<Base> BasePtr;
 
-class Base {
+class Base : public std::enable_shared_from_this<Base> {
     public:
         virtual ~Base();
            virtual void Begin() = 0;
            virtual void Update() = 0;
+               virtual void ProcessInput(InputManager*) = 0;
            virtual void Draw() = 0;
            virtual void End() = 0;
            virtual BasePtr NextScene() {return BasePtr();};
index d383bbd..9f1f05e 100644 (file)
@@ -94,13 +94,16 @@ void Connect::Update()
                break;
        }
 
-    InputManager input;
-    button_.ProcessInput(&input);
     button_.Update();
     button_label_.Update();
     message_.Update();
 }
 
+void Connect::ProcessInput(InputManager* input)
+{
+    button_.ProcessInput(input);
+}
+
 void Connect::Draw()
 {
     int width, height;
index 7d6dd47..4b34fcf 100644 (file)
@@ -19,6 +19,7 @@ class Connect : public Base {
         ~Connect();
         void Begin();
         void Update();
+               void ProcessInput(InputManager*);
         void Draw();
         void End();
         BasePtr NextScene();
index f42f58a..345a45d 100644 (file)
Binary files a/client/scene/Init.cpp and b/client/scene/Init.cpp differ
index 56288e6..edadcf0 100644 (file)
@@ -23,6 +23,7 @@ class Init : public Base {
         void Begin();
         void Update();
         void Draw();
+               void ProcessInput(InputManager*);
         void End();
         BasePtr NextScene();
 
@@ -30,7 +31,7 @@ class Init : public Base {
         void AsyncInitialize();
 
     private:
-        ManagerAccessorPtr manager_accesor_;
+        ManagerAccessorPtr manager_accessor_;
         ConfigManagerPtr config_manager_;
         CardManagerPtr card_manager_;
         AccountManagerPtr account_manager_;
index 511820b..db2972a 100644 (file)
@@ -3,6 +3,7 @@
 //
 
 #include "MainLoop.hpp"
+#include "Option.hpp"
 #include <vector>
 #include <algorithm>
 #include "../ResourceManager.hpp"
@@ -48,45 +49,21 @@ void MainLoop::Begin()
 void MainLoop::Update()
 {
     command_manager_->Update();
-
-    InputManager input;
-
-    inputbox_.ProcessInput(&input);
     inputbox_.Update();
-
-    player_manager_->ProcessInput(&input);
     player_manager_->Update();
-    
-    card_manager_->ProcessInput(&input);
     card_manager_->Update();
-
-       minimap_.ProcessInput(&input);
        minimap_.Update();
-
-    world_manager_->ProcessInput(&input);
     world_manager_->Update();
-
 }
 
-void MainLoop::Draw()
+void MainLoop::ProcessInput(InputManager* input)
 {
-    world_manager_->Draw();
-    player_manager_->Draw();
-    card_manager_->Draw();
-    inputbox_.Draw();
-       minimap_.Draw();
-
-    InputManager input;
+    inputbox_.ProcessInput(input);
+    player_manager_->ProcessInput(input);
+    card_manager_->ProcessInput(input);
+       minimap_.ProcessInput(input);
+    world_manager_->ProcessInput(input);
 
-       ProcessInput(&input);
-}
-
-void MainLoop::End()
-{
-}
-
-void MainLoop::ProcessInput(InputManager *input)
-{
        if(input->GetKeyCount(InputManager::KEYBIND_SCREEN_SHOT) > 0 && !inputbox_.IsActive())
        {
                TCHAR tmp_str[MAX_PATH];
@@ -109,8 +86,22 @@ void MainLoop::ProcessInput(InputManager *input)
        }
 }
 
+void MainLoop::Draw()
+{
+    world_manager_->Draw();
+    player_manager_->Draw();
+    card_manager_->Draw();
+    inputbox_.Draw();
+       minimap_.Draw();
+}
+
+void MainLoop::End()
+{
+}
+
 BasePtr MainLoop::NextScene()
 {
+       InputManager input;
        if(world_manager_->stage()->host_change_flag())
        {
                //account_manager_->set_host(world_manager_->stage()->host_change_flag().second);
index a7613af..a784367 100644 (file)
@@ -27,12 +27,12 @@ class MainLoop : public Base {
         void Begin();
         void Update();
         void Draw();
+               void ProcessInput(InputManager*);
         void End();
                BasePtr NextScene();
 
     private:
         std::function<void(const tstring&)> push_message_;
-               void ProcessInput(InputManager *input);
 
     private:
         // アクセサ
diff --git a/client/scene/Option.cpp b/client/scene/Option.cpp
new file mode 100644 (file)
index 0000000..57d8252
--- /dev/null
@@ -0,0 +1,73 @@
+//
+// Option.cpp
+//
+
+#include "Option.hpp"
+
+namespace scene {
+
+Option::Option(const ManagerAccessorPtr& manager_accessor,
+                       const BasePtr& background_scene) :
+      manager_accesor_(manager_accessor),
+      config_manager_(manager_accessor->config_manager().lock()),
+      card_manager_(manager_accessor->card_manager().lock()),
+      account_manager_(manager_accessor->account_manager().lock()),
+         background_scene_(background_scene),
+      start_count_(0)
+{
+    manager_accesor_->set_config_manager(config_manager_);
+    manager_accesor_->set_card_manager(card_manager_);
+    manager_accesor_->set_account_manager(account_manager_);
+
+}
+
+Option::~Option()
+{
+}
+
+void Option::Begin()
+{
+}
+
+void Option::Update()
+{
+    start_count_++;
+       if (background_scene_) {
+               background_scene_->Update();
+       }
+}
+
+void Option::ProcessInput(InputManager* input)
+{
+
+}
+
+void Option::Draw()
+{
+       if (background_scene_) {
+               background_scene_->Draw();
+       }
+
+    int width, height;
+    GetScreenState(&width, &height, nullptr);
+       SetDrawBlendMode(DX_BLENDMODE_ALPHA, 200);
+       DrawBox(0, 0, width, height, GetColor(157, 212, 187), TRUE);
+       SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0);
+}
+
+void Option::End()
+{
+
+}
+
+BasePtr Option::NextScene()
+{
+    if (start_count_ > 30) {
+        return background_scene_;
+    } else {
+        return BasePtr();
+    }
+}
+
+}
\ No newline at end of file
diff --git a/client/scene/Option.hpp b/client/scene/Option.hpp
new file mode 100644 (file)
index 0000000..1670f95
--- /dev/null
@@ -0,0 +1,38 @@
+//
+// Option.hpp
+//
+
+#pragma once
+
+#include "Base.hpp"
+#include "../ManagerHeader.hpp"
+#include "../ManagerAccessor.hpp"
+
+namespace scene {
+class Option : public Base {
+
+    public:
+        Option(const ManagerAccessorPtr& manager_accessor,
+                       const BasePtr& background_scene);
+        ~Option();
+        void Begin();
+        void Update();
+               void ProcessInput(InputManager*);
+        void Draw();
+        void End();
+        BasePtr NextScene();
+
+    private:
+        void AsyncInitialize();
+
+    private:
+        ManagerAccessorPtr manager_accesor_;
+        ConfigManagerPtr config_manager_;
+        CardManagerPtr card_manager_;
+        AccountManagerPtr account_manager_;
+
+               BasePtr background_scene_;
+
+        int start_count_;
+};
+}
\ No newline at end of file
index 5d889b2..d1bcb29 100644 (file)
@@ -32,6 +32,11 @@ void ServerChange::Update()
 {
 }
 
+void ServerChange::ProcessInput(InputManager* input)
+{
+
+}
+
 void ServerChange::Draw()
 {
 }
index 312b218..dee50ad 100644 (file)
@@ -17,6 +17,7 @@ class ServerChange : public Base{
                ~ServerChange();
         void Begin();
         void Update();
+               void ProcessInput(InputManager*);
         void Draw();
         void End();
         BasePtr NextScene();
index 2ca1c2f..b21bce0 100644 (file)
Binary files a/client/scene/Title.cpp and b/client/scene/Title.cpp differ
index e1e6696..dda821f 100644 (file)
@@ -20,6 +20,7 @@ class Title : public Base {
         ~Title();
         void Begin();
         void Update();
+               void ProcessInput(InputManager*);
         void Draw();
         void End();
         BasePtr NextScene();
index f11b57c..c2e29c2 100644 (file)
@@ -316,6 +316,14 @@ namespace network {
                        body = buffer.substr(sizeof(header));\r
                }\r
 \r
+        // 復号\r
+        if (session.lock() && header == header::ENCRYPT_HEADER) {\r
+            body.erase(0, sizeof(header));\r
+                       body = session.lock()->encrypter().Decrypt(body);\r
+            Utils::Deserialize(body, &header);\r
+                       body = buffer.substr(sizeof(header));\r
+        }\r
+\r
                if (header == network::header::ServerRequstedStatus) {\r
                        SendUDP(GetStatusJSON(), endpoint);\r
                } else {\r