Revisión | eb8b8622b721eb5f23ee4954146b5305827cdd0a (tree) |
---|---|
Tiempo | 2012-09-22 16:16:52 |
Autor | h2so5 <h2so5@git....> |
Commiter | h2so5 |
モデルリストのリロードに対応
@@ -60,10 +60,15 @@ int GameLoop::Init(std::shared_ptr<CharacterManager> character_manager) | ||
60 | 60 | return 0; |
61 | 61 | } |
62 | 62 | |
63 | -int GameLoop::Logic(InputManager* input) | |
63 | +int GameLoop::ProcessInput(InputManager* input) | |
64 | 64 | { |
65 | 65 | MoveCamera(input); |
66 | 66 | myself_->UpdateInput(input); |
67 | + return 0; | |
68 | +} | |
69 | + | |
70 | +int GameLoop::Update() | |
71 | +{ | |
67 | 72 | for (auto it = charmgr_->GetAll().begin(); it != charmgr_->GetAll().end(); ++it) { |
68 | 73 | auto character = *it; |
69 | 74 | character.second->Update(); |
@@ -76,6 +76,7 @@ Card::Card( | ||
76 | 76 | |
77 | 77 | context->Global()->Set(String::New("Network"), script_object->Clone()); |
78 | 78 | context->Global()->Set(String::New("Player"), script_object->Clone()); |
79 | + context->Global()->Set(String::New("Model"), script_object->Clone()); | |
79 | 80 | context->Global()->Set(String::New("Account"), script_object->Clone()); |
80 | 81 | context->Global()->Set(String::New("InputBox"), script_object->Clone()); |
81 | 82 | context->Global()->Set(String::New("Card"), script_object->Clone()); |
@@ -366,10 +367,16 @@ Handle<Value> Card::Function_Screen_player_focus(const Arguments& args) | ||
366 | 367 | return Undefined(); |
367 | 368 | } |
368 | 369 | |
369 | -Handle<Value> Card::Function_Rebuild_Modeltree(const Arguments& args) | |
370 | +Handle<Value> Card::Function_Model_Rebuild(const Arguments& args) | |
370 | 371 | { |
371 | 372 | JsonGen jsongen; |
372 | 373 | ResourceManager::BuildModelFileTree(); |
374 | + | |
375 | + auto self = static_cast<Card*>(args.Holder()->GetPointerFromInternalField(0)); | |
376 | + if (auto card_manager = self->manager_accessor_->card_manager().lock()) { | |
377 | + card_manager->OnModelReload(); | |
378 | + } | |
379 | + | |
373 | 380 | return Undefined(); |
374 | 381 | } |
375 | 382 |
@@ -493,6 +500,22 @@ void Card::Property_set_InputBox_message(Local<String> property, Local<Value> va | ||
493 | 500 | self->inputbox.message_ = *String::Utf8Value(value->ToString()); |
494 | 501 | } |
495 | 502 | |
503 | +Handle<Value> Card::Property_Model_onReload(Local<String> property, const AccessorInfo &info) | |
504 | +{ | |
505 | + assert(info.Holder()->InternalFieldCount() > 0); | |
506 | + auto self = static_cast<Card*>(info.Holder()->GetPointerFromInternalField(0)); | |
507 | + return self->model.on_reload_; | |
508 | +} | |
509 | + | |
510 | +void Card::Property_set_Model_onReload(Local<String> property, Local<Value> value, const AccessorInfo& info) | |
511 | +{ | |
512 | + if (value->IsFunction()) { | |
513 | + assert(info.Holder()->InternalFieldCount() > 0); | |
514 | + auto self = static_cast<Card*>(info.Holder()->GetPointerFromInternalField(0)); | |
515 | + self->model.on_reload_ = Persistent<Function>::New(value.As<Function>()); | |
516 | + } | |
517 | +} | |
518 | + | |
496 | 519 | void Card::SetFunctions() |
497 | 520 | { |
498 | 521 |
@@ -583,6 +606,16 @@ void Card::SetFunctions() | ||
583 | 606 | script_.SetFunction("Model.all", Function_Model_all); |
584 | 607 | |
585 | 608 | /** |
609 | + * モデルファイルの構造を再構築します | |
610 | + * | |
611 | + * @method rebuild | |
612 | + * @static | |
613 | + */ | |
614 | + script_.SetFunction("Model.rebuild", Function_Model_Rebuild); | |
615 | + | |
616 | + script_.SetProperty("Model.onReload", Property_Model_onReload, Property_set_Model_onReload); | |
617 | + | |
618 | + /** | |
586 | 619 | * プレイヤー |
587 | 620 | * |
588 | 621 | * @class Player |
@@ -791,13 +824,6 @@ void Card::SetFunctions() | ||
791 | 824 | */ |
792 | 825 | script_.SetFunction("Screen.player_focus", Function_Screen_player_focus); |
793 | 826 | |
794 | - /** | |
795 | - * モデルファイルの構造を再構築します | |
796 | - * | |
797 | - * @method player_focus | |
798 | - * @static | |
799 | - */ | |
800 | - script_.SetFunction("Model.rebuild", Function_Rebuild_Modeltree); | |
801 | 827 | // /** |
802 | 828 | // * ワールド座標をスクリーン座標に変換します |
803 | 829 | // * |
@@ -1246,7 +1272,17 @@ void Card::OnClose() | ||
1246 | 1272 | } |
1247 | 1273 | } |
1248 | 1274 | }); |
1275 | +} | |
1249 | 1276 | |
1277 | +void Card::OnModelReload() | |
1278 | +{ | |
1279 | + if (!model.on_reload_.IsEmpty() && model.on_reload_->IsFunction()) { | |
1280 | + script_.TimedWith( | |
1281 | + [&](const Handle<Context>& context) | |
1282 | + { | |
1283 | + model.on_reload_->Call(context->Global(), 0, nullptr); | |
1284 | + }); | |
1285 | + } | |
1250 | 1286 | } |
1251 | 1287 | |
1252 | 1288 | void Card::LoadStorage() |
@@ -36,6 +36,7 @@ class CardManager : public std::enable_shared_from_this<CardManager> { | ||
36 | 36 | void OnReceiveJSON(const std::string& info_json, const std::string& msg_json); |
37 | 37 | void OnLogin(const PlayerPtr& player); |
38 | 38 | void OnLogout(const PlayerPtr& player); |
39 | + void OnModelReload(); | |
39 | 40 | |
40 | 41 | bool IsGUIActive(); |
41 | 42 | void FocusPlayer(); |
@@ -13,27 +13,33 @@ var list; | ||
13 | 13 | list = new UI.List({ |
14 | 14 | docking: UI.DOCKING_TOP | UI.DOCKING_LEFT | UI.DOCKING_RIGHT | UI.DOCKING_BOTTOM |
15 | 15 | }); |
16 | +Model.onReload = function() { | |
16 | 17 | |
17 | -var even_line = false; | |
18 | -var model_names = Model.all(); | |
19 | -for (var i = 0; i < model_names.length; i++) { | |
20 | - if ((/char:/).test(model_names[i])) { | |
21 | - (function(model_name){ | |
22 | - list.addItem( | |
23 | - new UI.Label({ | |
24 | - docking: UI.DOCKING_TOP | UI.DOCKING_LEFT | UI.DOCKING_RIGHT, | |
25 | - text: model_name, | |
26 | - bgcolor: ((even_line = !even_line) ? "#EEAFEECC" : "#FFFFFFCC"), | |
27 | - onclick: function() { | |
28 | - Player.stopMotion(); | |
29 | - Account.updateModelName(model_name) | |
30 | - } | |
31 | - }) | |
32 | - ); | |
33 | - })(model_names[i]) | |
18 | + list.clearItems(); | |
19 | + | |
20 | + var even_line = false; | |
21 | + var model_names = Model.all(); | |
22 | + for (var i = 0; i < model_names.length; i++) { | |
23 | + if ((/char:/).test(model_names[i])) { | |
24 | + (function(model_name){ | |
25 | + list.addItem( | |
26 | + new UI.Label({ | |
27 | + docking: UI.DOCKING_TOP | UI.DOCKING_LEFT | UI.DOCKING_RIGHT, | |
28 | + text: model_name, | |
29 | + bgcolor: ((even_line = !even_line) ? "#EEAFEECC" : "#FFFFFFCC"), | |
30 | + onclick: function() { | |
31 | + Player.stopMotion(); | |
32 | + Account.updateModelName(model_name) | |
33 | + } | |
34 | + }) | |
35 | + ); | |
36 | + })(model_names[i]) | |
37 | + } | |
34 | 38 | } |
35 | 39 | } |
36 | 40 | |
41 | +Model.onReload(); | |
42 | + | |
37 | 43 | Card.board.width = 240; |
38 | 44 | Card.board.height = 120; |
39 | 45 | Card.board.docking = UI.DOCKING_BOTTOM | UI.DOCKING_RIGHT |
@@ -63,7 +63,8 @@ void Option::End() | ||
63 | 63 | |
64 | 64 | BasePtr Option::NextScene() |
65 | 65 | { |
66 | - if (start_count_ > 30) { | |
66 | + InputManager input; | |
67 | + if (input.GetKeyCount(KEY_INPUT_F1) == 1) { | |
67 | 68 | return background_scene_; |
68 | 69 | } else { |
69 | 70 | return BasePtr(); |
@@ -75,6 +75,23 @@ Handle<Value> UIList::Function_removeItem(const Arguments& args) | ||
75 | 75 | return args.This(); |
76 | 76 | } |
77 | 77 | |
78 | +Handle<Value> UIList::Function_clearItems(const Arguments& args) | |
79 | +{ | |
80 | + assert(args.This()->InternalFieldCount() > 0); | |
81 | + auto self = std::dynamic_pointer_cast<UIList>( | |
82 | + *static_cast<UIBasePtr*>(args.This()->GetPointerFromInternalField(0)) | |
83 | + ); | |
84 | + assert(self); | |
85 | + | |
86 | + BOOST_FOREACH(auto it, self->items_) { | |
87 | + UIBasePtr chid_ptr = *static_cast<UIBasePtr*>(it->GetPointerFromInternalField(0)); | |
88 | + chid_ptr->set_parent(Handle<Object>()); | |
89 | + } | |
90 | + self->items_.clear(); | |
91 | + | |
92 | + return args.This(); | |
93 | +} | |
94 | + | |
78 | 95 | Handle<Value> UIList::Property_scroll_y(Local<String> property, const AccessorInfo &info) |
79 | 96 | { |
80 | 97 | assert(info.This()->InternalFieldCount() > 0); |
@@ -123,6 +140,15 @@ void UIList::DefineInstanceTemplate(Handle<ObjectTemplate>* object) | ||
123 | 140 | SetFunction(object, "removeItem", Function_removeItem); |
124 | 141 | |
125 | 142 | /** |
143 | + * アイテムをすべて削除します | |
144 | + * | |
145 | + * @method clearItem | |
146 | + * @return {UIObject} 自分自身 | |
147 | + * @chainable | |
148 | + */ | |
149 | + SetFunction(object, "clearItems", Function_clearItems); | |
150 | + | |
151 | + /** | |
126 | 152 | * スクロール量(px) |
127 | 153 | * |
128 | 154 | * @property scroll_y |
@@ -24,6 +24,7 @@ class UIList : public UIBase { | ||
24 | 24 | /* function */ |
25 | 25 | static Handle<Value> Function_addItem(const Arguments& args); |
26 | 26 | static Handle<Value> Function_removeItem(const Arguments& args); |
27 | + static Handle<Value> Function_clearItems(const Arguments& args); | |
27 | 28 | |
28 | 29 | /* property */ |
29 | 30 | static Handle<Value> Property_scroll_y(Local<String> property, const AccessorInfo &info); |