Revisión | 9c8ca23cadd2e7deba0be111abc275e0c46247c0 (tree) |
---|---|
Tiempo | 2012-09-16 23:40:15 |
Autor | h2so5 <h2so5@git....> |
Commiter | h2so5 |
Connectシーンを追加
@@ -0,0 +1,71 @@ | ||
1 | +// | |
2 | +// Connect.cpp | |
3 | +// | |
4 | + | |
5 | +#include "MainLoop.hpp" | |
6 | +#include "Connect.hpp" | |
7 | +#include <vector> | |
8 | +#include <algorithm> | |
9 | +#include "../ResourceManager.hpp" | |
10 | +#include "../../common/Logger.hpp" | |
11 | + | |
12 | +namespace scene { | |
13 | +Connect::Connect(const ManagerAccessorPtr& manager_accesor) : | |
14 | + manager_accesor_(manager_accesor), | |
15 | + card_manager_(manager_accesor->card_manager().lock()), | |
16 | + account_manager_(manager_accesor->account_manager().lock()), | |
17 | + config_manager_(manager_accesor->config_manager().lock()), | |
18 | + command_manager_(std::make_shared<CommandManager>(manager_accesor_)) | |
19 | +{ | |
20 | + manager_accesor_->set_command_manager(command_manager_); | |
21 | +} | |
22 | + | |
23 | +Connect::~Connect() | |
24 | +{ | |
25 | +} | |
26 | + | |
27 | +void Connect::Begin() | |
28 | +{ | |
29 | + command_manager_->set_client( | |
30 | + ClientUniqPtr( | |
31 | + new network::Client( | |
32 | + account_manager_->host(), | |
33 | + config_manager_->port(), | |
34 | + (uint16_t)config_manager_->udp_port(), | |
35 | + account_manager_->public_key(), | |
36 | + account_manager_->private_key(), | |
37 | + "server_key.pub", | |
38 | + config_manager_->upnp() | |
39 | + ) | |
40 | + ) | |
41 | + ); | |
42 | +} | |
43 | + | |
44 | +void Connect::Update() | |
45 | +{ | |
46 | + command_manager_->Update(); | |
47 | +} | |
48 | + | |
49 | +void Connect::Draw() | |
50 | +{ | |
51 | + int width, height; | |
52 | + GetScreenState(&width, &height, nullptr); | |
53 | + DrawBox(0, 0, width, height, GetColor(157, 212, 187), TRUE); | |
54 | + | |
55 | +} | |
56 | + | |
57 | +void Connect::End() | |
58 | +{ | |
59 | +} | |
60 | + | |
61 | +BasePtr Connect::NextScene() | |
62 | +{ | |
63 | + InputManager input; | |
64 | + if (command_manager_->status() == CommandManager::STATUS_READY) { | |
65 | + return BasePtr(new scene::MainLoop(manager_accesor_)); | |
66 | + } else { | |
67 | + return BasePtr(); | |
68 | + } | |
69 | +} | |
70 | + | |
71 | +} |
@@ -0,0 +1,37 @@ | ||
1 | +// | |
2 | +// Connect.hpp | |
3 | +// | |
4 | + | |
5 | +#pragma once | |
6 | + | |
7 | +#include <memory> | |
8 | +#include "Base.hpp" | |
9 | +#include "../ManagerAccessor.hpp" | |
10 | + | |
11 | +namespace scene { | |
12 | + | |
13 | +class Connect : public Base { | |
14 | + | |
15 | + public: | |
16 | + Connect(const ManagerAccessorPtr&); | |
17 | + ~Connect(); | |
18 | + void Begin(); | |
19 | + void Update(); | |
20 | + void Draw(); | |
21 | + void End(); | |
22 | + BasePtr NextScene(); | |
23 | + | |
24 | + private: | |
25 | + void AsyncInitialize(); | |
26 | + | |
27 | + private: | |
28 | + ManagerAccessorPtr manager_accesor_; | |
29 | + CardManagerPtr card_manager_; | |
30 | + AccountManagerPtr account_manager_; | |
31 | + ConfigManagerPtr config_manager_; | |
32 | + CommandManagerPtr command_manager_; | |
33 | + | |
34 | + BasePtr next_scene_; | |
35 | +}; | |
36 | + | |
37 | +} |