• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

コミットメタ情報

リビジョンcd8108bff473d0de78b172c574f69631e92396dc (tree)
日時2012-09-27 21:31:07
作者h2so5 <h2so5@git....>
コミッターh2so5

ログメッセージ

ウィジェット位置の記憶機能を追加
モデルリストのmain.jsの文字コードを修正

変更サマリ

差分

--- a/client/WindowManager.cpp
+++ b/client/WindowManager.cpp
@@ -8,6 +8,10 @@
88 #include "CardManager.hpp"
99 #include "AccountManager.hpp"
1010 #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";
1115
1216 WindowManager::WindowManager(const ManagerAccessorPtr& manager_accessor) :
1317 manager_accessor_(manager_accessor)
@@ -18,6 +22,10 @@ manager_accessor_(manager_accessor)
1822 ResourceManager::LoadCachedGraph(_T("system/images/gui/gui_icon_base.png"));
1923 }
2024
25+WindowManager::~WindowManager()
26+{
27+}
28+
2129 void WindowManager::Init()
2230 {
2331
@@ -94,15 +102,23 @@ void WindowManager::DrawButtons()
94102 void WindowManager::DrawIcons(const Rect& rect)
95103 {
96104 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()) {
99109 ImageHandlePtr image_handle;
100110 if (auto custom_icon = ptr->icon_image_handle()) {
101111 image_handle = custom_icon;
102112 } else {
103113 image_handle = icon_base_image_handle_;
104114 }
115+
116+ if (ptr->visible()) {
117+ SetDrawBlendMode(DX_BLENDMODE_SUB, 40);
118+ }
105119 DrawGraph(rect.x + x, rect.y + 100 + 4, *image_handle, TRUE);
120+ SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0);
121+
106122 x += 64;
107123 }
108124 }
@@ -111,8 +127,9 @@ void WindowManager::DrawIcons(const Rect& rect)
111127 void WindowManager::ProcessInputIcons(const Rect& rect, InputManager* input)
112128 {
113129 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()) {
116133
117134 int icon_x = rect.x + x;
118135 int icon_y = rect.y + 100 + 4;
@@ -121,7 +138,7 @@ void WindowManager::ProcessInputIcons(const Rect& rect, InputManager* input)
121138 && icon_y <= input->GetMouseY() && input->GetMouseY() <= icon_y + 48);
122139
123140 if (hover && input->GetMouseLeftCount() == 1) {
124- ptr->set_visible(true);
141+ ptr->set_visible(!(ptr->visible()));
125142 input->CancelMouseLeft();
126143 }
127144 x += 64;
@@ -134,3 +151,54 @@ void WindowManager::AddWindow(const UISuperPtr& window)
134151 {
135152 windows_.push_back(window);
136153 }
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
--- a/client/WindowManager.hpp
+++ b/client/WindowManager.hpp
@@ -14,6 +14,8 @@ class InputManager;
1414 class WindowManager {
1515 public:
1616 WindowManager(const ManagerAccessorPtr& manager_accessor = ManagerAccessorPtr());
17+ ~WindowManager();
18+
1719 void Init();
1820 void ProcessInput(InputManager* input);
1921 void Update();
@@ -25,6 +27,9 @@ class WindowManager {
2527
2628 void AddWindow(const UISuperPtr& window);
2729
30+ void RestorePosition();
31+ void SavePosition();
32+
2833 private:
2934 ManagerAccessorPtr manager_accessor_;
3035
@@ -32,6 +37,8 @@ class WindowManager {
3237 ImageHandlePtr icon_base_image_handle_;
3338 std::vector<UISuperWeakPtr> windows_;
3439 std::vector<UISuperWeakPtr> closed_windows_;
40+
41+ static const char* LAYOUT_XML_PATH;
3542 };
3643
3744 typedef std::shared_ptr<WindowManager> WindowManagerPtr;
--- a/client/bin/system/widgets/modellist/main.js
+++ b/client/bin/system/widgets/modellist/main.js
@@ -2,7 +2,7 @@
22 /***MetaData***
33
44 {
5- "name": "モデルリスト",
5+ "name": "繝「繝?Ν繝ェ繧ケ繝?,
66 "icon": "icon.png",
77 "api_version": 1
88 }
--- a/client/scene/MainLoop.cpp
+++ b/client/scene/MainLoop.cpp
@@ -43,6 +43,8 @@ MainLoop::MainLoop(const ManagerAccessorPtr& manager_accessor) :
4343 ResourceManager::LoadCachedGraph(_T("system/images/gui/gui_icon_map.png")));
4444 card_manager_->AddNativeCard("rader", minimap_);
4545
46+ window_manager_->RestorePosition();
47+
4648 player_manager_->Init();
4749 world_manager_->Init();
4850
@@ -51,6 +53,7 @@ MainLoop::MainLoop(const ManagerAccessorPtr& manager_accessor) :
5153
5254 MainLoop::~MainLoop()
5355 {
56+ window_manager_->SavePosition();
5457 account_manager_->Save("./user/account.xml");
5558 }
5659