リビジョン | cd8108bff473d0de78b172c574f69631e92396dc (tree) |
---|---|
日時 | 2012-09-27 21:31:07 |
作者 | h2so5 <h2so5@git....> |
コミッター | h2so5 |
ウィジェット位置の記憶機能を追加
モデルリストのmain.jsの文字コードを修正
@@ -8,6 +8,10 @@ | ||
8 | 8 | #include "CardManager.hpp" |
9 | 9 | #include "AccountManager.hpp" |
10 | 10 | #include "ManagerAccessor.hpp" |
11 | +#include <boost/property_tree/xml_parser.hpp> | |
12 | +#include <boost/filesystem.hpp> | |
13 | + | |
14 | +const char* WindowManager::LAYOUT_XML_PATH = "./user/layout.xml"; | |
11 | 15 | |
12 | 16 | WindowManager::WindowManager(const ManagerAccessorPtr& manager_accessor) : |
13 | 17 | manager_accessor_(manager_accessor) |
@@ -18,6 +22,10 @@ manager_accessor_(manager_accessor) | ||
18 | 22 | ResourceManager::LoadCachedGraph(_T("system/images/gui/gui_icon_base.png")); |
19 | 23 | } |
20 | 24 | |
25 | +WindowManager::~WindowManager() | |
26 | +{ | |
27 | +} | |
28 | + | |
21 | 29 | void WindowManager::Init() |
22 | 30 | { |
23 | 31 |
@@ -94,15 +102,23 @@ void WindowManager::DrawButtons() | ||
94 | 102 | void WindowManager::DrawIcons(const Rect& rect) |
95 | 103 | { |
96 | 104 | int x = 32; |
97 | - BOOST_FOREACH(const auto& window, closed_windows_) { | |
98 | - if (auto ptr = window.lock()) { | |
105 | + auto card_manager = manager_accessor_->card_manager().lock(); | |
106 | + BOOST_FOREACH(const auto& card, card_manager->cards()) { | |
107 | + | |
108 | + if (auto ptr = card->GetWindow()) { | |
99 | 109 | ImageHandlePtr image_handle; |
100 | 110 | if (auto custom_icon = ptr->icon_image_handle()) { |
101 | 111 | image_handle = custom_icon; |
102 | 112 | } else { |
103 | 113 | image_handle = icon_base_image_handle_; |
104 | 114 | } |
115 | + | |
116 | + if (ptr->visible()) { | |
117 | + SetDrawBlendMode(DX_BLENDMODE_SUB, 40); | |
118 | + } | |
105 | 119 | DrawGraph(rect.x + x, rect.y + 100 + 4, *image_handle, TRUE); |
120 | + SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0); | |
121 | + | |
106 | 122 | x += 64; |
107 | 123 | } |
108 | 124 | } |
@@ -111,8 +127,9 @@ void WindowManager::DrawIcons(const Rect& rect) | ||
111 | 127 | void WindowManager::ProcessInputIcons(const Rect& rect, InputManager* input) |
112 | 128 | { |
113 | 129 | int x = 32; |
114 | - BOOST_FOREACH(const auto& window, closed_windows_) { | |
115 | - if (auto ptr = window.lock()) { | |
130 | + auto card_manager = manager_accessor_->card_manager().lock(); | |
131 | + BOOST_FOREACH(const auto& card, card_manager->cards()) { | |
132 | + if (auto ptr = card->GetWindow()) { | |
116 | 133 | |
117 | 134 | int icon_x = rect.x + x; |
118 | 135 | int icon_y = rect.y + 100 + 4; |
@@ -121,7 +138,7 @@ void WindowManager::ProcessInputIcons(const Rect& rect, InputManager* input) | ||
121 | 138 | && icon_y <= input->GetMouseY() && input->GetMouseY() <= icon_y + 48); |
122 | 139 | |
123 | 140 | if (hover && input->GetMouseLeftCount() == 1) { |
124 | - ptr->set_visible(true); | |
141 | + ptr->set_visible(!(ptr->visible())); | |
125 | 142 | input->CancelMouseLeft(); |
126 | 143 | } |
127 | 144 | x += 64; |
@@ -134,3 +151,54 @@ void WindowManager::AddWindow(const UISuperPtr& window) | ||
134 | 151 | { |
135 | 152 | windows_.push_back(window); |
136 | 153 | } |
154 | + | |
155 | +void WindowManager::RestorePosition() | |
156 | +{ | |
157 | + if (boost::filesystem::exists(LAYOUT_XML_PATH)) { | |
158 | + ptree tree; | |
159 | + read_xml(LAYOUT_XML_PATH, tree); | |
160 | + | |
161 | + auto card_manager = manager_accessor_->card_manager().lock(); | |
162 | + BOOST_FOREACH(const auto& card, card_manager->cards()) { | |
163 | + if (auto ptr = card->GetWindow()) { | |
164 | + auto child = tree.get_child_optional(card->name()); | |
165 | + if (child) { | |
166 | + ptr->set_top (child->get<int>("top", 0)); | |
167 | + ptr->set_left (child->get<int>("left", 0)); | |
168 | + ptr->set_right (child->get<int>("right", 0)); | |
169 | + ptr->set_bottom (child->get<int>("bottom", 0)); | |
170 | + ptr->set_offset_x (child->get<int>("offset_x", 0)); | |
171 | + ptr->set_offset_y (child->get<int>("offset_y", 0)); | |
172 | + ptr->set_offset_width (child->get<int>("offset_width", 0)); | |
173 | + ptr->set_offset_height (child->get<int>("offset_height", 0)); | |
174 | + ptr->set_visible (child->get<bool>("visible", true)); | |
175 | + } | |
176 | + } | |
177 | + } | |
178 | + } | |
179 | +} | |
180 | + | |
181 | +void WindowManager::SavePosition() | |
182 | +{ | |
183 | + ptree tree; | |
184 | + auto card_manager = manager_accessor_->card_manager().lock(); | |
185 | + BOOST_FOREACH(const auto& card, card_manager->cards()) { | |
186 | + if (auto ptr = card->GetWindow()) { | |
187 | + ptree child_tree; | |
188 | + | |
189 | + child_tree.put("top", ptr->top()); | |
190 | + child_tree.put("right", ptr->right()); | |
191 | + child_tree.put("left", ptr->left()); | |
192 | + child_tree.put("bottom", ptr->bottom()); | |
193 | + child_tree.put("offset_x", ptr->offset_x()); | |
194 | + child_tree.put("offset_y", ptr->offset_y()); | |
195 | + child_tree.put("offset_width", ptr->offset_width()); | |
196 | + child_tree.put("offset_height", ptr->offset_height()); | |
197 | + child_tree.put("visible", ptr->visible()); | |
198 | + | |
199 | + tree.put_child(card->name(), child_tree); | |
200 | + } | |
201 | + } | |
202 | + | |
203 | + write_xml(LAYOUT_XML_PATH, tree); | |
204 | +} | |
\ No newline at end of file |
@@ -14,6 +14,8 @@ class InputManager; | ||
14 | 14 | class WindowManager { |
15 | 15 | public: |
16 | 16 | WindowManager(const ManagerAccessorPtr& manager_accessor = ManagerAccessorPtr()); |
17 | + ~WindowManager(); | |
18 | + | |
17 | 19 | void Init(); |
18 | 20 | void ProcessInput(InputManager* input); |
19 | 21 | void Update(); |
@@ -25,6 +27,9 @@ class WindowManager { | ||
25 | 27 | |
26 | 28 | void AddWindow(const UISuperPtr& window); |
27 | 29 | |
30 | + void RestorePosition(); | |
31 | + void SavePosition(); | |
32 | + | |
28 | 33 | private: |
29 | 34 | ManagerAccessorPtr manager_accessor_; |
30 | 35 |
@@ -32,6 +37,8 @@ class WindowManager { | ||
32 | 37 | ImageHandlePtr icon_base_image_handle_; |
33 | 38 | std::vector<UISuperWeakPtr> windows_; |
34 | 39 | std::vector<UISuperWeakPtr> closed_windows_; |
40 | + | |
41 | + static const char* LAYOUT_XML_PATH; | |
35 | 42 | }; |
36 | 43 | |
37 | 44 | typedef std::shared_ptr<WindowManager> WindowManagerPtr; |
@@ -2,7 +2,7 @@ | ||
2 | 2 | /***MetaData*** |
3 | 3 | |
4 | 4 | { |
5 | - "name": "モデルリスト", | |
5 | + "name": "繝「繝?Ν繝ェ繧ケ繝?, | |
6 | 6 | "icon": "icon.png", |
7 | 7 | "api_version": 1 |
8 | 8 | } |
@@ -43,6 +43,8 @@ MainLoop::MainLoop(const ManagerAccessorPtr& manager_accessor) : | ||
43 | 43 | ResourceManager::LoadCachedGraph(_T("system/images/gui/gui_icon_map.png"))); |
44 | 44 | card_manager_->AddNativeCard("rader", minimap_); |
45 | 45 | |
46 | + window_manager_->RestorePosition(); | |
47 | + | |
46 | 48 | player_manager_->Init(); |
47 | 49 | world_manager_->Init(); |
48 | 50 |
@@ -51,6 +53,7 @@ MainLoop::MainLoop(const ManagerAccessorPtr& manager_accessor) : | ||
51 | 53 | |
52 | 54 | MainLoop::~MainLoop() |
53 | 55 | { |
56 | + window_manager_->SavePosition(); | |
54 | 57 | account_manager_->Save("./user/account.xml"); |
55 | 58 | } |
56 | 59 |