• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

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

Commit MetaInfo

Revisióneb8b8622b721eb5f23ee4954146b5305827cdd0a (tree)
Tiempo2012-09-22 16:16:52
Autorh2so5 <h2so5@git....>
Commiterh2so5

Log Message

モデルリストのリロードに対応

Cambiar Resumen

Diferencia incremental

--- a/client/3d/model.cpp
+++ b/client/3d/model.cpp
@@ -60,10 +60,15 @@ int GameLoop::Init(std::shared_ptr<CharacterManager> character_manager)
6060 return 0;
6161 }
6262
63-int GameLoop::Logic(InputManager* input)
63+int GameLoop::ProcessInput(InputManager* input)
6464 {
6565 MoveCamera(input);
6666 myself_->UpdateInput(input);
67+ return 0;
68+}
69+
70+int GameLoop::Update()
71+{
6772 for (auto it = charmgr_->GetAll().begin(); it != charmgr_->GetAll().end(); ++it) {
6873 auto character = *it;
6974 character.second->Update();
Binary files a/client/3d/model.hpp and b/client/3d/model.hpp differ
--- a/client/Card.cpp
+++ b/client/Card.cpp
@@ -76,6 +76,7 @@ Card::Card(
7676
7777 context->Global()->Set(String::New("Network"), script_object->Clone());
7878 context->Global()->Set(String::New("Player"), script_object->Clone());
79+ context->Global()->Set(String::New("Model"), script_object->Clone());
7980 context->Global()->Set(String::New("Account"), script_object->Clone());
8081 context->Global()->Set(String::New("InputBox"), script_object->Clone());
8182 context->Global()->Set(String::New("Card"), script_object->Clone());
@@ -366,10 +367,16 @@ Handle<Value> Card::Function_Screen_player_focus(const Arguments& args)
366367 return Undefined();
367368 }
368369
369-Handle<Value> Card::Function_Rebuild_Modeltree(const Arguments& args)
370+Handle<Value> Card::Function_Model_Rebuild(const Arguments& args)
370371 {
371372 JsonGen jsongen;
372373 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+
373380 return Undefined();
374381 }
375382
@@ -493,6 +500,22 @@ void Card::Property_set_InputBox_message(Local<String> property, Local<Value> va
493500 self->inputbox.message_ = *String::Utf8Value(value->ToString());
494501 }
495502
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+
496519 void Card::SetFunctions()
497520 {
498521
@@ -583,6 +606,16 @@ void Card::SetFunctions()
583606 script_.SetFunction("Model.all", Function_Model_all);
584607
585608 /**
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+ /**
586619 * プレイヤー
587620 *
588621 * @class Player
@@ -791,13 +824,6 @@ void Card::SetFunctions()
791824 */
792825 script_.SetFunction("Screen.player_focus", Function_Screen_player_focus);
793826
794- /**
795- * モデルファイルの構造を再構築します
796- *
797- * @method player_focus
798- * @static
799- */
800- script_.SetFunction("Model.rebuild", Function_Rebuild_Modeltree);
801827 // /**
802828 // * ワールド座標をスクリーン座標に変換します
803829 // *
@@ -1246,7 +1272,17 @@ void Card::OnClose()
12461272 }
12471273 }
12481274 });
1275+}
12491276
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+ }
12501286 }
12511287
12521288 void Card::LoadStorage()
Binary files a/client/Card.hpp and b/client/Card.hpp differ
Binary files a/client/CardManager.cpp and b/client/CardManager.cpp differ
--- a/client/CardManager.hpp
+++ b/client/CardManager.hpp
@@ -36,6 +36,7 @@ class CardManager : public std::enable_shared_from_this<CardManager> {
3636 void OnReceiveJSON(const std::string& info_json, const std::string& msg_json);
3737 void OnLogin(const PlayerPtr& player);
3838 void OnLogout(const PlayerPtr& player);
39+ void OnModelReload();
3940
4041 bool IsGUIActive();
4142 void FocusPlayer();
Binary files a/client/ResourceManager.cpp and b/client/ResourceManager.cpp differ
Binary files a/client/WorldManager.cpp and b/client/WorldManager.cpp differ
--- a/client/bin/cards/modellist/main.js
+++ b/client/bin/cards/modellist/main.js
@@ -13,27 +13,33 @@ var list;
1313 list = new UI.List({
1414 docking: UI.DOCKING_TOP | UI.DOCKING_LEFT | UI.DOCKING_RIGHT | UI.DOCKING_BOTTOM
1515 });
16+Model.onReload = function() {
1617
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+ }
3438 }
3539 }
3640
41+Model.onReload();
42+
3743 Card.board.width = 240;
3844 Card.board.height = 120;
3945 Card.board.docking = UI.DOCKING_BOTTOM | UI.DOCKING_RIGHT
--- a/client/scene/Option.cpp
+++ b/client/scene/Option.cpp
@@ -63,7 +63,8 @@ void Option::End()
6363
6464 BasePtr Option::NextScene()
6565 {
66- if (start_count_ > 30) {
66+ InputManager input;
67+ if (input.GetKeyCount(KEY_INPUT_F1) == 1) {
6768 return background_scene_;
6869 } else {
6970 return BasePtr();
--- a/client/ui/UIList.cpp
+++ b/client/ui/UIList.cpp
@@ -75,6 +75,23 @@ Handle<Value> UIList::Function_removeItem(const Arguments& args)
7575 return args.This();
7676 }
7777
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+
7895 Handle<Value> UIList::Property_scroll_y(Local<String> property, const AccessorInfo &info)
7996 {
8097 assert(info.This()->InternalFieldCount() > 0);
@@ -123,6 +140,15 @@ void UIList::DefineInstanceTemplate(Handle<ObjectTemplate>* object)
123140 SetFunction(object, "removeItem", Function_removeItem);
124141
125142 /**
143+ * アイテムをすべて削除します
144+ *
145+ * @method clearItem
146+ * @return {UIObject} 自分自身
147+ * @chainable
148+ */
149+ SetFunction(object, "clearItems", Function_clearItems);
150+
151+ /**
126152 * スクロール量(px)
127153 *
128154 * @property scroll_y
--- a/client/ui/UIList.hpp
+++ b/client/ui/UIList.hpp
@@ -24,6 +24,7 @@ class UIList : public UIBase {
2424 /* function */
2525 static Handle<Value> Function_addItem(const Arguments& args);
2626 static Handle<Value> Function_removeItem(const Arguments& args);
27+ static Handle<Value> Function_clearItems(const Arguments& args);
2728
2829 /* property */
2930 static Handle<Value> Property_scroll_y(Local<String> property, const AccessorInfo &info);