• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

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

Commit MetaInfo

修訂0378c11354f9bd515c00ab7a4d1ad3d036c8d176 (tree)
時間2012-10-11 18:21:07
作者angeart <angeart@git....>
Commiterangeart

Log Message

Titleがなぜが二重Deleteに陥る
一時的にブランチに退避

Change Summary

差異

--- a/client/Card.cpp
+++ b/client/Card.cpp
@@ -24,6 +24,12 @@
2424 #include "GenerateJSON.hpp"
2525 #include "Music.hpp"
2626
27+#pragma comment(lib,"libctemplate.lib")
28+
29+#define CTEMPLATE_DLL_DECL
30+#include <config.h>
31+#include <ctemplate/template.h>
32+
2733
2834 char Card::STORAGE_DIR[] = "storage";
2935 char Card::SCRIPT_PATH[] = "system/js";
@@ -75,6 +81,7 @@ Card::Card(
7581 context->Global()->Set(String::New("Model"), script_object->Clone());
7682 context->Global()->Set(String::New("Account"), script_object->Clone());
7783 context->Global()->Set(String::New("Music"), script_object->Clone());
84+ context->Global()->Set(String::New("Plugin"), script_object->Clone());
7885 context->Global()->Set(String::New("InputBox"), script_object->Clone());
7986 context->Global()->Set(String::New("Card"), script_object->Clone());
8087 context->Global()->Set(String::New("Screen"), script_object->Clone());
@@ -101,11 +108,39 @@ Card::Card(
101108 assert(!ui_board_obj_.IsEmpty() && ui_board_obj_->IsObject());
102109 });
103110
104- ui_board_ = *static_cast<UIBasePtr*>(ui_board_obj_->GetPointerFromInternalField(0));
111+ ui_board_ = *static_cast<UISuperPtr*>(ui_board_obj_->GetPointerFromInternalField(0));
105112 }
106113
107114 ui_board_->set_icon_image_handle(
108115 ResourceManager::LoadCachedGraph(unicode::ToTString(source_folder_ + "/" + icon_)));
116+
117+
118+ auto sprit = [](const std::string &str, const std::string &delim)->std::vector<std::string>
119+ {
120+ std::vector<std::string> res;
121+ size_t current = 0, found, delimlen = delim.size();
122+ while((found = str.find(delim, current)) != std::string::npos){
123+ res.push_back(std::string(str, current, found - current));
124+ current = found + delimlen;
125+ }
126+ res.push_back(std::string(str, current, str.size() - current));
127+ return res;
128+ };
129+
130+
131+ auto ui_board_tmp = *static_cast<UIBoardPtr*>(ui_board_obj_->GetPointerFromInternalField(0));
132+ auto pos = name_.find_first_of("@");
133+ if ( pos != std::string::npos )
134+ {
135+ std::string plug_dat = name_.substr(pos,name_.length() - pos);
136+ auto str_array = sprit(plug_dat,",");
137+ BOOST_FOREACH(auto str,str_array)
138+ {
139+ if(str == "plugin")ui_board_tmp->set_boardvisible(false);
140+ if(str == "uiplugin")ui_board_tmp->set_boardvisible(true);
141+ }
142+ }
143+
109144 }
110145
111146 Card::~Card()
@@ -297,6 +332,26 @@ Handle<Value> Card::Function_Music_IsLoadingDone(const Arguments& args)
297332 return Boolean::New(false);
298333 }
299334
335+Handle<Value> Card::Function_Plugin_Run(const Arguments& args)
336+{
337+ auto self = static_cast<Card*>(args.Holder()->GetPointerFromInternalField(0));
338+ if (auto card_manager = self->manager_accessor_->card_manager().lock()) {
339+ if ( args[0]->IsString() ) {
340+ auto name = std::string(*String::Utf8Value(args[0]->ToString()));
341+ BOOST_FOREACH(auto card,card_manager->cards()) {
342+ auto pos = card->name().find_first_of("@");
343+ if( pos != std::string::npos ) {
344+ if ( name == card->name().substr(0,pos) ) {
345+ card->Run();
346+ }
347+ }
348+ }
349+ }
350+ }
351+ return Undefined();
352+}
353+
354+
300355 Handle<Value> Card::Function_Account_id(const Arguments& args)
301356 {
302357 auto self = static_cast<Card*>(args.Holder()->GetPointerFromInternalField(0));
@@ -890,6 +945,15 @@ void Card::SetFunctions()
890945 script_.SetFunction("Music.rebuild", Function_Music_Rebuild);
891946
892947 script_.SetProperty("Music.onReload", Property_Music_onReload, Property_set_Music_onReload);
948+
949+ /**
950+ * 非自動実行プラグインを走らせます
951+ *
952+ * @method run
953+ * @static
954+ */
955+ script_.SetFunction("Plugin.run", Function_Plugin_Run);
956+
893957 /**
894958 * アカウント
895959 *
@@ -1347,8 +1411,9 @@ UISuperPtr Card::GetWindow() const
13471411 return ui_board_;
13481412 } else {
13491413 if (ui_board_obj_->IsObject()) {
1350- auto ptr = *static_cast<UIBasePtr*>(ui_board_obj_->GetPointerFromInternalField(0));
1351- if (ptr->children_size() > 0) {
1414+ auto ptr = *static_cast<UIBoardPtr*>(ui_board_obj_->GetPointerFromInternalField(0));
1415+ assert(ptr);
1416+ if (ptr->children_size() > 0 && ptr->boardvisible()) {
13521417 return ptr;
13531418 }
13541419 }
Binary files a/client/Card.hpp and b/client/Card.hpp differ
--- a/client/CardManager.hpp
+++ b/client/CardManager.hpp
@@ -66,6 +66,7 @@ class CardManager : public std::enable_shared_from_this<CardManager> {
6666 static char CARDS_DIR[];
6767 static char START_METADATA[];
6868 static char END_METADATA[];
69+
6970 };
7071
7172 typedef std::shared_ptr<CardManager> CardManagerPtr;
--- a/client/GenerateJSON.cpp
+++ b/client/GenerateJSON.cpp
@@ -160,6 +160,31 @@ _error:
160160 return RemoveDirectory( lpPathName );
161161 }
162162
163+ int Trim(char *s) {
164+ int i;
165+ int count = 0;
166+
167+ /* 空ポインタか? */
168+ if ( s == NULL ) { /* yes */
169+ return -1;
170+ }
171+
172+ /* 文字列長を取得する */
173+ i = strlen(s);
174+
175+ /* 末尾から順に空白でない位置を探す */
176+ while ( --i >= 0 && s[i] == ' ' ) count++;
177+
178+ /* 終端ナル文字を付加する */
179+ s[i+1] = '\0';
180+
181+ /* 先頭から順に空白でない位置を探す */
182+ i = 0;
183+ while ( s[i] != '\0' && s[i] == ' ' ) i++;
184+ strcpy(s, &s[i]);
185+
186+ return i + count;
187+ }
163188 };
164189
165190 JsonGen::JsonGen()
@@ -209,7 +234,7 @@ JsonGen::JsonGen()
209234 {
210235 ZeroMemory(tcsTmpPath_Pmd,MAX_PATH);
211236 _tcscpy_s(tcsTmpPath_Pmd,tcsTmpDir);
212- _tcscat_s(tcsTmpPath_Pmd,_T("*.pmd"));
237+ _tcscat_s(tcsTmpPath_Pmd,_T("*.pm?"));
213238 hPmdFind = FindFirstFile(tcsTmpPath_Pmd, &win32fd_pmd);
214239 if(hPmdFind == (HANDLE)0xffffffff)
215240 {
@@ -247,6 +272,7 @@ JsonGen::JsonGen()
247272
248273 // モデル名取得
249274 strcpy_s(pmd_model_name_,pmd_info+7);
275+ Trim(pmd_model_name_);
250276 int cnt = 0x1b;
251277 size_t info_size = ADFUNC_DXconvAnsiToWide(0,0,pmd_info+cnt);
252278 TCHAR *pmd_info_t = new TCHAR[info_size + 1];
--- a/client/ui/Input.cpp
+++ b/client/ui/Input.cpp
@@ -45,6 +45,86 @@ Input::Input() :
4545 y_ = 100;
4646 width_ = 160;
4747 height_ = font_height_ + 4;
48+
49+ right_click_list_.addItem(UIBasePtr(new UIBase([&]()->UIBase{
50+ UILabel label;
51+ label.set_input_adaptor(std::shared_ptr<Input>(this));
52+ label.set_text(unicode::ToTString("切り取り"));
53+ label.set_on_click_function_([&]()->void{
54+ HGLOBAL hGlobal;
55+ LPTSTR pMem;
56+ auto input_ = label.input_adpator();
57+ hGlobal = GlobalAlloc(GHND, lstrlen( input_->message().c_str() ) + 128 );
58+ if ( hGlobal == NULL ) {
59+ return;
60+ }
61+ pMem = (LPTSTR)GlobalLock( hGlobal );
62+ if ( pMem == NULL ) {
63+ GlobalFree( hGlobal );
64+ return;
65+ }
66+ lstrcpy( pMem, input_->message().c_str() );
67+ GlobalUnlock( hGlobal );
68+ OpenClipboard( NULL );
69+ EmptyClipboard();
70+ SetClipboardData(CF_TEXT, hGlobal);
71+ CloseClipboard();
72+ });
73+ return static_cast<UIBase>(label);
74+ }())));
75+ right_click_list_.addItem(UIBasePtr(new UIBase([&]()->UIBase{
76+ UILabel label;
77+ label.set_input_adaptor(std::shared_ptr<Input>(this));
78+ label.set_text(unicode::ToTString("コピー"));
79+ label.set_on_click_function_([&]()->void{
80+ HGLOBAL hGlobal;
81+ LPTSTR pMem;
82+ auto input_ = label.input_adpator();
83+ hGlobal = GlobalAlloc(GHND, lstrlen( input_->message().c_str() ) + 128 );
84+ if ( hGlobal == NULL ) {
85+ return;
86+ }
87+ pMem = (LPTSTR)GlobalLock( hGlobal );
88+ if ( pMem == NULL ) {
89+ GlobalFree( hGlobal );
90+ return;
91+ }
92+ lstrcpy( pMem, input_->message().c_str() );
93+ GlobalUnlock( hGlobal );
94+ OpenClipboard( NULL );
95+ EmptyClipboard();
96+ SetClipboardData(CF_TEXT, hGlobal);
97+ CloseClipboard();
98+ });
99+ return static_cast<UIBase>(label);
100+ }())));
101+ right_click_list_.addItem(UIBasePtr(new UIBase([&]()->UIBase{
102+ UILabel label;
103+ label.set_input_adaptor(std::shared_ptr<Input>(this));
104+ label.set_text(unicode::ToTString("貼り付け"));
105+ label.set_on_click_function_([&]()->void{
106+ HGLOBAL hGlobal;
107+ LPTSTR pMem;
108+ auto input_ = label.input_adpator();
109+ hGlobal = GlobalAlloc(GHND, lstrlen( input_->message().c_str() ) + 128 );
110+ if ( hGlobal == NULL ) {
111+ return;
112+ }
113+ pMem = (LPTSTR)GlobalLock( hGlobal );
114+ if ( pMem == NULL ) {
115+ GlobalFree( hGlobal );
116+ return;
117+ }
118+ lstrcpy( pMem, input_->message().c_str() );
119+ GlobalUnlock( hGlobal );
120+ OpenClipboard( NULL );
121+ EmptyClipboard();
122+ SetClipboardData(CF_TEXT, hGlobal);
123+ CloseClipboard();
124+ });
125+ return static_cast<UIBase>(label);
126+ }())));
127+
48128 }
49129
50130 void Input::Draw()
@@ -271,6 +351,8 @@ void Input::ProcessInput(InputManager* input)
271351 return;
272352 }
273353
354+ bool push_mouse_right = (input->GetMouseRight() > 0);
355+
274356 // bool push_mouse_left = (input->GetMouseLeftCount() > 0);
275357
276358 // bool first_key_shift = (input->GetKeyCount(KEY_INPUT_RSHIFT) == 1
@@ -504,7 +586,7 @@ void Input::ProcessInput(InputManager* input)
504586 #endif
505587
506588 // 選択範囲を記録
507- if (select_start < char_count && char_count <= select_end) {
589+ if (select_start > 0 && char_count >= select_end) {
508590 selecting_lines_.resize(static_cast<int>(lines_.size() + message_lines_.size()) + 1,
509591 std::pair<int, int>(99999, 0));
510592 selecting_lines_[static_cast<int>(lines_.size() + message_lines_.size())].first = std::min(
@@ -716,6 +798,11 @@ void Input::ProcessInput(InputManager* input)
716798 if (active()) {
717799 input->CancelKeyCountAll();
718800 }
801+
802+ // 右クリック描画
803+ if (push_mouse_right) {
804+
805+ }
719806 }
720807
721808 bool Input::active()
--- a/client/ui/Input.hpp
+++ b/client/ui/Input.hpp
@@ -8,6 +8,7 @@
88 #include <functional>
99 #include "../ResourceManager.hpp"
1010 #include "../InputManager.hpp"
11+#include "include.hpp"
1112
1213 class Input {
1314 typedef std::function<bool(const std::string&)> CallbackFunc;
@@ -80,6 +81,8 @@ class Input {
8081 bool reverse_color_;
8182 int blink_count_;
8283
84+ UIList right_click_list_;
85+
8386 private:
8487 const static size_t TEXT_BUFFER_SIZE;
8588 const static size_t HISTORY_MAX_SIZE;
--- a/client/ui/InputBox.cpp
+++ b/client/ui/InputBox.cpp
@@ -102,8 +102,13 @@ InputBox::InputBox(const ManagerAccessorPtr& manager_accessor) :
102102
103103 return true;
104104 });
105+
106+
105107 }
106108
109+
110+
111+
107112 InputBox::~InputBox()
108113 {
109114 }
--- a/client/ui/InputBox.hpp
+++ b/client/ui/InputBox.hpp
@@ -35,7 +35,7 @@ class InputBox : public UISuper {
3535 int multiline() const;
3636 void set_multiline(int multiline);
3737
38- private:
38+private:
3939 void CancelSelect();
4040
4141 void DrawBase();
@@ -112,4 +112,5 @@ class InputBox : public UISuper {
112112 const static int IME_MARGIN_Y;
113113 const static int IME_MAX_PAGE_SIZE;
114114 const static int IME_MIN_WIDTH;
115+
115116 };
--- a/client/ui/UIBase.cpp
+++ b/client/ui/UIBase.cpp
@@ -38,6 +38,15 @@ void UIBase::ProcessInput(InputManager* input)
3838
3939 }
4040
41+void UIBase::Update()
42+{
43+};
44+
45+void UIBase::Draw()
46+{
47+ DrawChildren();
48+}
49+
4150 void UIBase::AsyncUpdate()
4251 {
4352 AsyncUpdateChildren();
@@ -469,6 +478,25 @@ void UIBase::set_parent(const Handle<Object>& parent)
469478 parent_ = Persistent<Object>::New(parent);
470479 }
471480
481+UIBasePtr UIBase::parent_c() const
482+{
483+ return parent_c_;
484+}
485+
486+void UIBase::set_parent_c(const UIBasePtr& parent)
487+{
488+ parent_c_ = parent;
489+}
490+
491+std::shared_ptr<Input> UIBase::input_adpator() const
492+{
493+ return input_adaptor_;
494+}
495+void UIBase::set_input_adaptor(const std::shared_ptr<Input> &adaptor)
496+{
497+ input_adaptor_ = adaptor;
498+}
499+
472500 size_t UIBase::children_size() const
473501 {
474502 return children_.size();
--- a/client/ui/UIBase.hpp
+++ b/client/ui/UIBase.hpp
@@ -7,6 +7,7 @@
77 #include "UISuper.hpp"
88 #include <v8.h>
99 #include "../InputManager.hpp"
10+#include <functional>
1011
1112 using namespace v8;
1213
@@ -14,8 +15,10 @@ class ScriptEnvironment;
1415 typedef std::weak_ptr<ScriptEnvironment> ScriptEnvironmentWeakPtr;
1516
1617 class UIBase;
18+class Input;
1719 typedef std::shared_ptr<UIBase> UIBasePtr;
1820 typedef std::weak_ptr<UIBase> UIBaseWeakPtr;
21+typedef std::function<void()> CallbackFunc;
1922
2023 class UIBase : public UISuper {
2124
@@ -24,8 +27,8 @@ class UIBase : public UISuper {
2427 virtual ~UIBase();
2528
2629 virtual void ProcessInput(InputManager* input);
27- virtual void Update() = 0;
28- virtual void Draw() = 0;
30+ virtual void Update();
31+ virtual void Draw();
2932 virtual void AsyncUpdate(); // 毎ループ実行する必要のない処理
3033
3134 /* function */
@@ -57,7 +60,10 @@ class UIBase : public UISuper {
5760
5861 Handle<Object> parent() const;
5962 void set_parent(const Handle<Object>& parent);
60-
63+ UIBasePtr parent_c() const;
64+ void set_parent_c(const UIBasePtr &parent_c);
65+ std::shared_ptr<Input> input_adpator() const;
66+ void set_input_adaptor(const std::shared_ptr<Input> &adaptor);
6167 size_t children_size() const;
6268
6369 template<class T>
@@ -92,13 +98,22 @@ class UIBase : public UISuper {
9298
9399 void Focus();
94100
101+ public:
102+ /* Property */
103+ template<class F>
104+ void set_on_click_function_(F function);
105+
95106 protected:
96107
97108 Persistent<Object> parent_;
98109 std::vector<Persistent<Object>> children_;
99110
100111 Persistent<Function> on_click_;
112+ CallbackFunc on_click_function_;
101113
114+ /*C++からクラスを伝達するためのメンバ*/
115+ UIBasePtr parent_c_;
116+ std::shared_ptr<Input> input_adaptor_;
102117 };
103118
104119 inline void Destruct(Persistent<Value> handle, void* parameter) {
@@ -155,3 +170,9 @@ void UIBase::SetConstant(Handle<ObjectTemplate>* object, const std::string& name
155170 Handle<ObjectTemplate>& instance_template = *object;
156171 instance_template->Set(String::New(name.c_str()), value);
157172 }
173+
174+template<class F>
175+void UIBase::set_on_click_function_(F function)
176+{
177+ on_click_function_ = function;
178+}
--- a/client/ui/UIBoard.cpp
+++ b/client/ui/UIBoard.cpp
@@ -25,7 +25,8 @@ UIBoard::UIBoard() :
2525 max_height_(800),
2626 min_height_(100),
2727 drag_offset_rect_(-1, -1, -1, -1),
28- drag_resize_offset_rect_(-1, -1, -1, -1)
28+ drag_resize_offset_rect_(-1, -1, -1, -1),
29+ boardvisible_(true)
2930 {
3031 base_image_handle_ = ResourceManager::LoadCachedDivGraph<4>(
3132 _T("system/images/gui/gui_board_bg.png"), 2, 2, 24, 24);
@@ -247,40 +248,42 @@ void UIBoard::Draw()
247248 if (!visible_) {
248249 return;
249250 }
251+
252+ if (boardvisible_) {
253+ SetDrawBlendMode(DX_BLENDMODE_ADD, 255);
250254
251- SetDrawBlendMode(DX_BLENDMODE_ADD, 255);
255+ int x = absolute_x();
256+ int y = absolute_y();
257+ int width = absolute_width();
258+ int height = absolute_height();
252259
253- int x = absolute_x();
254- int y = absolute_y();
255- int width = absolute_width();
256- int height = absolute_height();
260+ DrawGraph(x, y, *base_image_handle_[0], TRUE);
261+ DrawGraph(x + width - BASE_BLOCK_SIZE, y, *base_image_handle_[1], TRUE);
262+ DrawGraph(x, y + height - BASE_BLOCK_SIZE, *base_image_handle_[2], TRUE);
263+ DrawGraph(x + width - BASE_BLOCK_SIZE, y + height - BASE_BLOCK_SIZE, *base_image_handle_[3], TRUE);
257264
258- DrawGraph(x, y, *base_image_handle_[0], TRUE);
259- DrawGraph(x + width - BASE_BLOCK_SIZE, y, *base_image_handle_[1], TRUE);
260- DrawGraph(x, y + height - BASE_BLOCK_SIZE, *base_image_handle_[2], TRUE);
261- DrawGraph(x + width - BASE_BLOCK_SIZE, y + height - BASE_BLOCK_SIZE, *base_image_handle_[3], TRUE);
265+ DrawRectExtendGraphF(x + BASE_BLOCK_SIZE, y,
266+ x + width - BASE_BLOCK_SIZE, y + BASE_BLOCK_SIZE,
267+ 0, 0, 1, BASE_BLOCK_SIZE, *base_image_handle_[1], TRUE);
262268
263- DrawRectExtendGraphF(x + BASE_BLOCK_SIZE, y,
264- x + width - BASE_BLOCK_SIZE, y + BASE_BLOCK_SIZE,
265- 0, 0, 1, BASE_BLOCK_SIZE, *base_image_handle_[1], TRUE);
269+ DrawRectExtendGraphF(x + BASE_BLOCK_SIZE, y + height - BASE_BLOCK_SIZE,
270+ x + width - BASE_BLOCK_SIZE, y + height,
271+ 0, 0, 1, BASE_BLOCK_SIZE, *base_image_handle_[3], TRUE);
266272
267- DrawRectExtendGraphF(x + BASE_BLOCK_SIZE, y + height - BASE_BLOCK_SIZE,
268- x + width - BASE_BLOCK_SIZE, y + height,
269- 0, 0, 1, BASE_BLOCK_SIZE, *base_image_handle_[3], TRUE);
273+ DrawRectExtendGraphF(x, y + BASE_BLOCK_SIZE,
274+ x + BASE_BLOCK_SIZE, y + height - BASE_BLOCK_SIZE,
275+ 0, 0, BASE_BLOCK_SIZE, 1, *base_image_handle_[2], TRUE);
270276
271- DrawRectExtendGraphF(x, y + BASE_BLOCK_SIZE,
272- x + BASE_BLOCK_SIZE, y + height - BASE_BLOCK_SIZE,
273- 0, 0, BASE_BLOCK_SIZE, 1, *base_image_handle_[2], TRUE);
277+ DrawRectExtendGraphF(x + width - BASE_BLOCK_SIZE, y + BASE_BLOCK_SIZE,
278+ x + width, y + height - BASE_BLOCK_SIZE,
279+ 0, 0, BASE_BLOCK_SIZE, 1, *base_image_handle_[3], TRUE);
274280
275- DrawRectExtendGraphF(x + width - BASE_BLOCK_SIZE, y + BASE_BLOCK_SIZE,
276- x + width, y + height - BASE_BLOCK_SIZE,
277- 0, 0, BASE_BLOCK_SIZE, 1, *base_image_handle_[3], TRUE);
281+ DrawRectExtendGraphF(x + BASE_BLOCK_SIZE, y + BASE_BLOCK_SIZE,
282+ x + width - BASE_BLOCK_SIZE, y + height - BASE_BLOCK_SIZE,
283+ 0, 0, 1, 1, *base_image_handle_[3], TRUE);
278284
279- DrawRectExtendGraphF(x + BASE_BLOCK_SIZE, y + BASE_BLOCK_SIZE,
280- x + width - BASE_BLOCK_SIZE, y + height - BASE_BLOCK_SIZE,
281- 0, 0, 1, 1, *base_image_handle_[3], TRUE);
282-
283- SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0);
285+ SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0);
286+ }
284287
285288 DrawChildren();
286289 }
@@ -290,6 +293,16 @@ bool UIBoard::resizable() const
290293 return resizable_;
291294 }
292295
296+bool UIBoard::boardvisible() const
297+{
298+ return boardvisible_;
299+}
300+
301+void UIBoard::set_boardvisible(bool visible)
302+{
303+ boardvisible_ = visible;
304+}
305+
293306 void UIBoard::set_resizable(bool resizable)
294307 {
295308 resizable_ = resizable;
--- a/client/ui/UIBoard.hpp
+++ b/client/ui/UIBoard.hpp
@@ -16,7 +16,9 @@ class UIBoard : public UIBase {
1616 void Draw();
1717
1818 bool resizable() const;
19+ bool boardvisible() const;
1920 void set_resizable(bool resizable);
21+ void set_boardvisible(bool visible);
2022
2123 public:
2224 static void DefineInstanceTemplate(Handle<ObjectTemplate>* object);
@@ -38,6 +40,7 @@ class UIBoard : public UIBase {
3840 std::array<ImageHandlePtr,4> base_image_handle_;
3941
4042 bool resizable_;
43+ bool boardvisible_;
4144
4245 int max_width_, min_width_;
4346 int max_height_, min_height_;
@@ -47,3 +50,5 @@ class UIBoard : public UIBase {
4750 private:
4851 const static int BASE_BLOCK_SIZE;
4952 };
53+
54+typedef std::shared_ptr<UIBoard> UIBoardPtr;
\ No newline at end of file
--- a/client/ui/UIButton.hpp
+++ b/client/ui/UIButton.hpp
@@ -11,7 +11,6 @@
1111 #include <functional>
1212
1313 class UIButton : public UIBase {
14- typedef std::function<void()> CallbackFunc;
1514
1615 public:
1716 UIButton();
--- a/client/ui/UICustom.cpp
+++ b/client/ui/UICustom.cpp
@@ -96,7 +96,8 @@ void UICustom::DefineInstanceTemplate(Handle<ObjectTemplate>* object)
9696 SetProperty(object, "_update", Property_update, Property_set_update);
9797 SetProperty(object, "_draw", Property_draw, Property_set_draw);
9898
99- SetFunction(object, "drawLine", Function_drawLine);
99+ SetFunction(object, "DrawLine", Function_DrawLine);
100+ SetFunction(object, "DrawBox", Function_DrawBox);
100101 }
101102
102103 void UICustom::ProcessInput(InputManager* input)
@@ -131,16 +132,527 @@ void UICustom::Draw()
131132 }
132133 }
133134
134-Handle<Value> UICustom::Function_drawLine(const Arguments& args)
135+
136+Handle<Value> UICustom::Function_DrawLine(const Arguments& args)
137+{
138+ assert(args.This()->InternalFieldCount() > 0);
139+ auto self = std::dynamic_pointer_cast<UICustom>(
140+ *static_cast<UIBasePtr*>(args.This()->GetPointerFromInternalField(0))
141+ );
142+ assert(self);
143+ if( args[0]->IsInt32() &&
144+ args[1]->IsInt32() &&
145+ args[2]->IsInt32() &&
146+ args[3]->IsInt32() &&
147+ args[4]->IsInt32() &&
148+ args[5]->IsInt32() &&
149+ args[6]->IsInt32() )
150+ {
151+ auto x0 = args[0]->Int32Value();
152+ auto y0 = args[1]->Int32Value();
153+ auto x1 = args[2]->Int32Value();
154+ auto y1 = args[3]->Int32Value();
155+ auto r = args[4]->Int32Value();
156+ auto g = args[5]->Int32Value();
157+ auto b = args[6]->Int32Value();
158+
159+ if( args[7]->IsInt32() )
160+ {
161+ auto t = args[7]->Int32Value();
162+ DrawLine(x0, y0, x1, y1, GetColor(r, g, b),t);
163+ }else{
164+ DrawLine(x0, y0, x1, y1, GetColor(r, g, b));
165+ }
166+
167+ }
168+
169+ return Undefined();
170+}
171+
172+Handle<Value> UICustom::Function_DrawBox(const Arguments& args)
173+{
174+ assert(args.This()->InternalFieldCount() > 0);
175+ auto self = std::dynamic_pointer_cast<UICustom>(
176+ *static_cast<UIBasePtr*>(args.This()->GetPointerFromInternalField(0))
177+ );
178+ assert(self);
179+ if( args[0]->IsInt32() &&
180+ args[1]->IsInt32() &&
181+ args[2]->IsInt32() &&
182+ args[3]->IsInt32() &&
183+ args[4]->IsInt32() &&
184+ args[5]->IsInt32() &&
185+ args[6]->IsInt32() )
186+ {
187+ auto x0 = args[0]->Int32Value();
188+ auto y0 = args[1]->Int32Value();
189+ auto x1 = args[2]->Int32Value();
190+ auto y1 = args[3]->Int32Value();
191+ auto r = args[4]->Int32Value();
192+ auto g = args[5]->Int32Value();
193+ auto b = args[6]->Int32Value();
194+
195+ if( args[7]->IsBoolean() )
196+ {
197+ auto fillflag = args[7]->BooleanValue();
198+ DrawBox(x0, y0, x1, y1, GetColor(r, g, b),fillflag ? 1 : 0);
199+ }else{
200+ DrawBox(x0, y0, x1, y1, GetColor(r, g, b),1);
201+ }
202+ }
203+
204+ return Undefined();
205+}
206+
207+Handle<Value> UICustom::Function_DrawEdgeBox(const Arguments& args)
208+{
209+ assert(args.This()->InternalFieldCount() > 0);
210+ auto self = std::dynamic_pointer_cast<UICustom>(
211+ *static_cast<UIBasePtr*>(args.This()->GetPointerFromInternalField(0))
212+ );
213+ assert(self);
214+ if( args[0]->IsInt32() &&
215+ args[1]->IsInt32() &&
216+ args[2]->IsInt32() &&
217+ args[3]->IsInt32() &&
218+ args[4]->IsInt32() &&
219+ args[5]->IsInt32() &&
220+ args[6]->IsInt32() )
221+ {
222+ auto x0 = args[0]->Int32Value();
223+ auto y0 = args[1]->Int32Value();
224+ auto x1 = args[2]->Int32Value();
225+ auto y1 = args[3]->Int32Value();
226+ auto r = args[4]->Int32Value();
227+ auto g = args[5]->Int32Value();
228+ auto b = args[6]->Int32Value();
229+
230+ auto DrawOfOnlyEdge = [](int x, int y, int width, int height, int Color, int thickness)
231+ {
232+ DrawBox( x, y, x + width, y + thickness, Color, TRUE);
233+ DrawBox( x, y, x + thickness, y + height, Color, TRUE);
234+ DrawBox( x + width - thickness, y, x + width, y + height, Color, TRUE);
235+ DrawBox( x, y + height - thickness, x + width, y + height, Color, TRUE);
236+ };// thicknessで示した太さで縁のみの四角形を描画
237+
238+ if( args[7]->IsInt32() )
239+ {
240+ auto t = args[7]->Int32Value();
241+ if( args[8]->IsBoolean() )
242+ {
243+ auto fillflag = args[8]->BooleanValue();
244+ DrawOfOnlyEdge(x0 - t, y0 - t, x1 + t, y1 + t, GetColor(r, g, b),t);
245+ DrawBox(x0, y0, x1, y1, GetColor(r, g, b),fillflag ? 1 : 0);
246+ }else{
247+ DrawOfOnlyEdge(x0 - t, y0 - t, x1 + t, y1 + t, GetColor(r, g, b),t);
248+ }
249+ }else{
250+ DrawOfOnlyEdge(x0 - 1, y0 - 1, x1 + 1, y1 + 1, GetColor(r, g, b),1);
251+ }
252+
253+ }
254+
255+ return Undefined();
256+}
257+
258+Handle<Value> UICustom::Function_DrawCircle(const Arguments& args)
259+{
260+ assert(args.This()->InternalFieldCount() > 0);
261+ auto self = std::dynamic_pointer_cast<UICustom>(
262+ *static_cast<UIBasePtr*>(args.This()->GetPointerFromInternalField(0))
263+ );
264+ assert(self);
265+ if( args[0]->IsInt32() &&
266+ args[1]->IsInt32() &&
267+ args[2]->IsInt32() &&
268+ args[3]->IsInt32() &&
269+ args[4]->IsInt32() &&
270+ args[5]->IsInt32() )
271+ {
272+ auto x0 = args[0]->Int32Value();
273+ auto y0 = args[1]->Int32Value();
274+ auto r0 = args[2]->Int32Value();
275+ auto r = args[3]->Int32Value();
276+ auto g = args[4]->Int32Value();
277+ auto b = args[5]->Int32Value();
278+
279+ if( args[6]->IsBoolean() )
280+ {
281+ auto fillflag = args[6]->BooleanValue();
282+ DrawCircle(x0, y0, r0, GetColor(r, g, b),fillflag ? 1 : 0);
283+ }else{
284+ DrawCircle(x0, y0, r0, GetColor(r, g, b),1);
285+ }
286+ }
287+
288+ return Undefined();
289+}
290+
291+Handle<Value> UICustom::Function_DrawOval(const Arguments& args)
292+{
293+ assert(args.This()->InternalFieldCount() > 0);
294+ auto self = std::dynamic_pointer_cast<UICustom>(
295+ *static_cast<UIBasePtr*>(args.This()->GetPointerFromInternalField(0))
296+ );
297+ assert(self);
298+ if( args[0]->IsInt32() &&
299+ args[1]->IsInt32() &&
300+ args[2]->IsInt32() &&
301+ args[3]->IsInt32() &&
302+ args[4]->IsInt32() &&
303+ args[5]->IsInt32() &&
304+ args[6]->IsInt32() )
305+ {
306+ auto x0 = args[0]->Int32Value();
307+ auto y0 = args[1]->Int32Value();
308+ auto rx = args[2]->Int32Value();
309+ auto ry = args[3]->Int32Value();
310+ auto r = args[4]->Int32Value();
311+ auto g = args[5]->Int32Value();
312+ auto b = args[6]->Int32Value();
313+
314+ if( args[7]->IsBoolean() )
315+ {
316+ auto fillflag = args[7]->BooleanValue();
317+ DrawOval(x0, y0, rx, ry, GetColor(r, g, b),fillflag ? 1 : 0);
318+ }else{
319+ DrawOval(x0, y0, rx, ry, GetColor(r, g, b),1);
320+ }
321+
322+ }
323+
324+ return Undefined();
325+}
326+
327+Handle<Value> UICustom::Function_DrawTriangle(const Arguments& args)
328+{
329+ assert(args.This()->InternalFieldCount() > 0);
330+ auto self = std::dynamic_pointer_cast<UICustom>(
331+ *static_cast<UIBasePtr*>(args.This()->GetPointerFromInternalField(0))
332+ );
333+ assert(self);
334+ if( args[0]->IsInt32() &&
335+ args[1]->IsInt32() &&
336+ args[2]->IsInt32() &&
337+ args[3]->IsInt32() &&
338+ args[4]->IsInt32() &&
339+ args[5]->IsInt32() &&
340+ args[6]->IsInt32() &&
341+ args[7]->IsInt32() &&
342+ args[8]->IsInt32() )
343+ {
344+ auto x0 = args[0]->Int32Value();
345+ auto y0 = args[1]->Int32Value();
346+ auto x1 = args[2]->Int32Value();
347+ auto y1 = args[3]->Int32Value();
348+ auto x2 = args[4]->Int32Value();
349+ auto y2 = args[5]->Int32Value();
350+ auto r = args[6]->Int32Value();
351+ auto g = args[7]->Int32Value();
352+ auto b = args[8]->Int32Value();
353+
354+ if( args[9]->IsBoolean() )
355+ {
356+ auto fillflag = args[9]->BooleanValue();
357+ DrawTriangle(x0, y0, x1, y1, x2, y2, GetColor(r, g, b),fillflag ? 1 : 0);
358+ }else{
359+ DrawTriangle(x0, y0, x1, y1, x2, y2, GetColor(r, g, b),1);
360+ }
361+
362+ }
363+
364+ return Undefined();
365+}
366+
367+Handle<Value> UICustom::Function_DrawQuadrangle(const Arguments& args)
368+{
369+ assert(args.This()->InternalFieldCount() > 0);
370+ auto self = std::dynamic_pointer_cast<UICustom>(
371+ *static_cast<UIBasePtr*>(args.This()->GetPointerFromInternalField(0))
372+ );
373+ assert(self);
374+ if( args[0]->IsInt32() &&
375+ args[1]->IsInt32() &&
376+ args[2]->IsInt32() &&
377+ args[3]->IsInt32() &&
378+ args[4]->IsInt32() &&
379+ args[5]->IsInt32() &&
380+ args[6]->IsInt32() &&
381+ args[7]->IsInt32() &&
382+ args[8]->IsInt32() )
383+ {
384+ auto x0 = args[0]->Int32Value();
385+ auto y0 = args[1]->Int32Value();
386+ auto x1 = args[2]->Int32Value();
387+ auto y1 = args[3]->Int32Value();
388+ auto x2 = args[4]->Int32Value();
389+ auto y2 = args[5]->Int32Value();
390+ auto x3 = args[6]->Int32Value();
391+ auto y3 = args[7]->Int32Value();
392+ auto r = args[8]->Int32Value();
393+ auto g = args[9]->Int32Value();
394+ auto b = args[10]->Int32Value();
395+
396+ if( args[11]->IsBoolean() )
397+ {
398+ auto fillflag = args[9]->BooleanValue();
399+ DrawQuadrangle(x0, y0, x1, y1, x2, y2, x3, y3, GetColor(r, g, b),fillflag ? 1 : 0);
400+ }else{
401+ DrawQuadrangle(x0, y0, x1, y1, x2, y2, x3, y3, GetColor(r, g, b),1);
402+ }
403+
404+ }
405+
406+ return Undefined();
407+}
408+
409+Handle<Value> UICustom::Function_DrawPixel(const Arguments& args)
135410 {
136411 assert(args.This()->InternalFieldCount() > 0);
137412 auto self = std::dynamic_pointer_cast<UICustom>(
138413 *static_cast<UIBasePtr*>(args.This()->GetPointerFromInternalField(0))
139414 );
140415 assert(self);
416+ if( args[0]->IsInt32() &&
417+ args[1]->IsInt32() &&
418+ args[2]->IsInt32() &&
419+ args[3]->IsInt32() &&
420+ args[4]->IsInt32() )
421+ {
422+ auto x0 = args[0]->Int32Value();
423+ auto y0 = args[1]->Int32Value();
424+ auto r = args[2]->Int32Value();
425+ auto g = args[3]->Int32Value();
426+ auto b = args[4]->Int32Value();
427+
428+ DrawPixel(x0, y0, GetColor(r, g, b));
141429
142- DrawLine(100, 100, 200, 200, GetColor(255,255,255));
430+ }
143431
144432 return Undefined();
145433 }
146434
435+Handle<Value> UICustom::Function_Paint(const Arguments& args)
436+{
437+ assert(args.This()->InternalFieldCount() > 0);
438+ auto self = std::dynamic_pointer_cast<UICustom>(
439+ *static_cast<UIBasePtr*>(args.This()->GetPointerFromInternalField(0))
440+ );
441+ assert(self);
442+ if( args[0]->IsInt32() &&
443+ args[1]->IsInt32() &&
444+ args[2]->IsInt32() &&
445+ args[3]->IsInt32() &&
446+ args[4]->IsInt32() )
447+ {
448+ auto x0 = args[0]->Int32Value();
449+ auto y0 = args[1]->Int32Value();
450+ auto r0 = args[2]->Int32Value();
451+ auto g0 = args[3]->Int32Value();
452+ auto b0 = args[4]->Int32Value();
453+ if( args[5]->IsInt32() &&
454+ args[6]->IsInt32() &&
455+ args[7]->IsInt32() )
456+ {
457+ auto r1 = args[5]->Int32Value();
458+ auto g1 = args[6]->Int32Value();
459+ auto b1 = args[7]->Int32Value();
460+ Paint(x0, y0, GetColor(r0, g0, b0), GetColor(r1, g1, b1));
461+ }else{
462+ Paint(x0, y0, GetColor(r0, g0, b0));
463+ }
464+
465+ }
466+
467+ return Undefined();
468+}
469+
470+Handle<Value> UICustom::Function_DrawPixelSet(const Arguments& args)
471+{
472+ assert(args.This()->InternalFieldCount() > 0);
473+ auto self = std::dynamic_pointer_cast<UICustom>(
474+ *static_cast<UIBasePtr*>(args.This()->GetPointerFromInternalField(0))
475+ );
476+ assert(self);
477+ if( args[0]->IsArray() )
478+ {
479+ auto array = Local<Array>::Cast(args[0]);
480+ auto length = array->Length();
481+ auto data = static_cast<POINTDATA*>(array->GetPointerFromInternalField(0));
482+
483+ DrawPixelSet(data,length);
484+ }
485+
486+ return Undefined();
487+}
488+
489+Handle<Value> UICustom::Function_DrawLineSet(const Arguments& args)
490+{
491+ assert(args.This()->InternalFieldCount() > 0);
492+ auto self = std::dynamic_pointer_cast<UICustom>(
493+ *static_cast<UIBasePtr*>(args.This()->GetPointerFromInternalField(0))
494+ );
495+ assert(self);
496+ if( args[0]->IsArray() )
497+ {
498+ auto array = Local<Array>::Cast(args[0]);
499+ auto length = array->Length();
500+ auto data = static_cast<LINEDATA*>(array->GetPointerFromInternalField(0));
501+
502+ DrawLineSet(data,length);
503+ }
504+
505+ return Undefined();
506+}
507+
508+Handle<Value> UICustom::Function_DrawPixel3D(const Arguments& args)
509+{
510+ assert(args.This()->InternalFieldCount() > 0);
511+ auto self = std::dynamic_pointer_cast<UICustom>(
512+ *static_cast<UIBasePtr*>(args.This()->GetPointerFromInternalField(0))
513+ );
514+ assert(self);
515+ if( args[0]->IsInt32() &&
516+ args[1]->IsInt32() &&
517+ args[2]->IsInt32() &&
518+ args[3]->IsInt32() &&
519+ args[4]->IsInt32() &&
520+ args[5]->IsInt32() )
521+ {
522+ auto x0 = args[0]->Int32Value();
523+ auto y0 = args[1]->Int32Value();
524+ auto z0 = args[2]->Int32Value();
525+ auto r = args[3]->Int32Value();
526+ auto g = args[4]->Int32Value();
527+ auto b = args[5]->Int32Value();
528+
529+ DrawPixel3D(VGet(x0, y0, z0), GetColor(r, g, b));
530+
531+ }
532+
533+ return Undefined();
534+}
535+
536+Handle<Value> UICustom::Function_DrawLine3D(const Arguments& args)
537+{
538+ assert(args.This()->InternalFieldCount() > 0);
539+ auto self = std::dynamic_pointer_cast<UICustom>(
540+ *static_cast<UIBasePtr*>(args.This()->GetPointerFromInternalField(0))
541+ );
542+ assert(self);
543+ if( args[0]->IsInt32() &&
544+ args[1]->IsInt32() &&
545+ args[2]->IsInt32() &&
546+ args[3]->IsInt32() &&
547+ args[4]->IsInt32() &&
548+ args[5]->IsInt32() &&
549+ args[6]->IsInt32() &&
550+ args[7]->IsInt32() &&
551+ args[8]->IsInt32() )
552+ {
553+ auto x0 = args[0]->Int32Value();
554+ auto y0 = args[1]->Int32Value();
555+ auto z0 = args[2]->Int32Value();
556+ auto x1 = args[3]->Int32Value();
557+ auto y1 = args[4]->Int32Value();
558+ auto z1 = args[5]->Int32Value();
559+ auto r = args[6]->Int32Value();
560+ auto g = args[7]->Int32Value();
561+ auto b = args[8]->Int32Value();
562+
563+ DrawLine3D(VGet(x0, y0, z0), VGet(x1, y1, z1), GetColor(r, g, b));
564+
565+ }
566+
567+ return Undefined();
568+}
569+
570+Handle<Value> UICustom::Function_DrawCube3D(const Arguments& args)
571+{
572+ assert(args.This()->InternalFieldCount() > 0);
573+ auto self = std::dynamic_pointer_cast<UICustom>(
574+ *static_cast<UIBasePtr*>(args.This()->GetPointerFromInternalField(0))
575+ );
576+ assert(self);
577+ if( args[0]->IsInt32() &&
578+ args[1]->IsInt32() &&
579+ args[2]->IsInt32() &&
580+ args[3]->IsInt32() &&
581+ args[4]->IsInt32() &&
582+ args[5]->IsInt32() &&
583+ args[6]->IsInt32() &&
584+ args[7]->IsInt32() &&
585+ args[8]->IsInt32() &&
586+ args[9]->IsInt32() &&
587+ args[10]->IsInt32() &&
588+ args[11]->IsInt32() )
589+ {
590+ auto x0 = args[0]->Int32Value();
591+ auto y0 = args[1]->Int32Value();
592+ auto z0 = args[2]->Int32Value();
593+ auto x1 = args[3]->Int32Value();
594+ auto y1 = args[4]->Int32Value();
595+ auto z1 = args[5]->Int32Value();
596+ auto dr = args[6]->Int32Value();
597+ auto dg = args[7]->Int32Value();
598+ auto db = args[8]->Int32Value();
599+ auto sr = args[9]->Int32Value();
600+ auto sg = args[10]->Int32Value();
601+ auto sb = args[11]->Int32Value();
602+
603+ if( args[12]->IsBoolean() )
604+ {
605+ auto fillflag = args[9]->BooleanValue();
606+ DrawCube3D(VGet(x0, y0, z0), VGet(x1, y1, z1), GetColor(dr, dg, db), GetColor(sr, sg, db), fillflag ? 1 : 0);
607+ }else{
608+ DrawCube3D(VGet(x0, y0, z0), VGet(x1, y1, z1), GetColor(dr, dg, db), GetColor(sr, sg, db), 1);
609+ }
610+
611+ }
612+
613+ return Undefined();
614+}
615+
616+Handle<Value> UICustom::Function_DrawSphere3D(const Arguments& args)
617+{
618+ assert(args.This()->InternalFieldCount() > 0);
619+ auto self = std::dynamic_pointer_cast<UICustom>(
620+ *static_cast<UIBasePtr*>(args.This()->GetPointerFromInternalField(0))
621+ );
622+ assert(self);
623+ if( args[0]->IsInt32() &&
624+ args[1]->IsInt32() &&
625+ args[2]->IsInt32() &&
626+ args[3]->IsInt32() &&
627+ args[4]->IsInt32() &&
628+ args[5]->IsInt32() &&
629+ args[6]->IsInt32() &&
630+ args[7]->IsInt32() &&
631+ args[8]->IsInt32() &&
632+ args[9]->IsInt32() &&
633+ args[10]->IsInt32() )
634+ {
635+ auto x0 = args[0]->Int32Value();
636+ auto y0 = args[1]->Int32Value();
637+ auto z0 = args[2]->Int32Value();
638+ auto r = args[3]->Int32Value();
639+ auto divnum = args[4]->Int32Value();
640+ auto dr = args[5]->Int32Value();
641+ auto dg = args[6]->Int32Value();
642+ auto db = args[7]->Int32Value();
643+ auto sr = args[8]->Int32Value();
644+ auto sg = args[9]->Int32Value();
645+ auto sb = args[10]->Int32Value();
646+
647+ if( args[11]->IsBoolean() )
648+ {
649+ auto fillflag = args[9]->BooleanValue();
650+ DrawSphere3D(VGet(x0, y0, z0), r, divnum, GetColor(dr, dg, db), GetColor(sr, sg, db), fillflag ? 1 : 0);
651+ }else{
652+ DrawSphere3D(VGet(x0, y0, z0), r, divnum, GetColor(dr, dg, db), GetColor(sr, sg, db), 1);
653+ }
654+
655+ }
656+
657+ return Undefined();
658+}
--- a/client/ui/UICustom.hpp
+++ b/client/ui/UICustom.hpp
@@ -28,7 +28,26 @@ class UICustom : public UIBase {
2828 static void Property_set_draw(Local<String> property, Local<Value> value, const AccessorInfo& info);
2929
3030 private:
31- static Handle<Value> Function_drawLine(const Arguments& args);
31+ /* function */
32+ static Handle<Value> Function_DrawLine(const Arguments& args);
33+ static Handle<Value> Function_DrawBox(const Arguments& args);
34+ static Handle<Value> Function_DrawEdgeBox(const Arguments& args);
35+ static Handle<Value> Function_DrawCircle(const Arguments& args);
36+ static Handle<Value> Function_DrawOval(const Arguments& args);
37+ static Handle<Value> Function_DrawTriangle(const Arguments& args);
38+ static Handle<Value> Function_DrawQuadrangle(const Arguments& args);
39+ static Handle<Value> Function_DrawPixel(const Arguments& args);
40+ static Handle<Value> Function_Paint(const Arguments& args);
41+ static Handle<Value> Function_DrawPixelSet(const Arguments& args);
42+ static Handle<Value> Function_DrawLineSet(const Arguments& args);
43+ static Handle<Value> Function_DrawPixel3D(const Arguments& args);
44+ static Handle<Value> Function_DrawLine3D(const Arguments& args);
45+ static Handle<Value> Function_DrawCube3D(const Arguments& args);
46+ static Handle<Value> Function_DrawSphere3D(const Arguments& args);
47+ static Handle<Value> Function_DrawCapsule3D(const Arguments& args);
48+ static Handle<Value> Function_DrawCone3D(const Arguments& args);
49+
50+ static Handle<Value> Function_LoadGraph(const Arguments& args);
3251
3352 };
3453
--- a/client/ui/UILabel.cpp
+++ b/client/ui/UILabel.cpp
@@ -189,6 +189,8 @@ void UILabel::ProcessInput(InputManager* input)
189189 if (input->GetMouseLeftCount() == 1 && hover) {
190190 if (!on_click_.IsEmpty() && on_click_->IsFunction()) {
191191 on_click_.As<Function>()->CallAsFunction(Context::GetCurrent()->Global(), 0, nullptr);
192+ }else if(!on_click_function_._Empty()) {
193+ on_click_function_();
192194 }
193195 }
194196 }
--- a/client/ui/UIList.cpp
+++ b/client/ui/UIList.cpp
@@ -169,6 +169,36 @@ void UIList::ProcessInput(InputManager* input)
169169
170170 }
171171
172+void UIList::addItem(UIBasePtr item)
173+{
174+ item->set_parent_c(UIBasePtr(new UIList(*this)));
175+ items_.push_back(item);
176+}
177+
178+void UIList::removeItem(UIBasePtr item)
179+{
180+ auto it = std::find(items_.begin(), items_.end(), item);
181+ if (it != items_.end()) {
182+ UIBasePtr chid_ptr = *it;
183+ chid_ptr->set_parent_c(nullptr);
184+ items_.erase(it);
185+ }
186+}
187+
188+void UIList::clearItems()
189+{
190+ BOOST_FOREACH(auto it, items_) {
191+ UIBasePtr chid_ptr = it;
192+ chid_ptr->set_parent_c(nullptr);
193+ }
194+ items_.clear();
195+}
196+
197+void UIList::set_scroll_y(int scroll_y)
198+{
199+ scroll_y_ = scroll_y;
200+}
201+
172202 void UIList::UpdateScrollBar(InputManager* input)
173203 {
174204 int screen_width, screen_height;
--- a/client/ui/UIList.hpp
+++ b/client/ui/UIList.hpp
@@ -17,8 +17,9 @@ class UIList : public UIBase {
1717 void Update();
1818 void Draw();
1919
20+ /* Java Script's Function*/
2021 public:
21- static void DefineInstanceTemplate(Handle<ObjectTemplate>* object);
22+ static void DefineInstanceTemplate(Handle<ObjectTemplate>* object);
2223
2324 private:
2425 /* function */
@@ -30,6 +31,15 @@ class UIList : public UIBase {
3031 static Handle<Value> Property_scroll_y(Local<String> property, const AccessorInfo &info);
3132 static void Property_set_scroll_y(Local<String> property, Local<Value> value, const AccessorInfo& info);
3233
34+ public:
35+ /* function */
36+ void addItem(UIBasePtr item);
37+ void removeItem(UIBasePtr item);
38+ void clearItems();
39+
40+ /* property */
41+ void set_scroll_y(int scroll_y);
42+
3343 private:
3444 std::array<ImageHandlePtr,4> scrollbar_base_image_handle_;
3545