修訂 | 0378c11354f9bd515c00ab7a4d1ad3d036c8d176 (tree) |
---|---|
時間 | 2012-10-11 18:21:07 |
作者 | angeart <angeart@git....> |
Commiter | angeart |
Titleがなぜが二重Deleteに陥る
一時的にブランチに退避
@@ -24,6 +24,12 @@ | ||
24 | 24 | #include "GenerateJSON.hpp" |
25 | 25 | #include "Music.hpp" |
26 | 26 | |
27 | +#pragma comment(lib,"libctemplate.lib") | |
28 | + | |
29 | +#define CTEMPLATE_DLL_DECL | |
30 | +#include <config.h> | |
31 | +#include <ctemplate/template.h> | |
32 | + | |
27 | 33 | |
28 | 34 | char Card::STORAGE_DIR[] = "storage"; |
29 | 35 | char Card::SCRIPT_PATH[] = "system/js"; |
@@ -75,6 +81,7 @@ Card::Card( | ||
75 | 81 | context->Global()->Set(String::New("Model"), script_object->Clone()); |
76 | 82 | context->Global()->Set(String::New("Account"), script_object->Clone()); |
77 | 83 | context->Global()->Set(String::New("Music"), script_object->Clone()); |
84 | + context->Global()->Set(String::New("Plugin"), script_object->Clone()); | |
78 | 85 | context->Global()->Set(String::New("InputBox"), script_object->Clone()); |
79 | 86 | context->Global()->Set(String::New("Card"), script_object->Clone()); |
80 | 87 | context->Global()->Set(String::New("Screen"), script_object->Clone()); |
@@ -101,11 +108,39 @@ Card::Card( | ||
101 | 108 | assert(!ui_board_obj_.IsEmpty() && ui_board_obj_->IsObject()); |
102 | 109 | }); |
103 | 110 | |
104 | - ui_board_ = *static_cast<UIBasePtr*>(ui_board_obj_->GetPointerFromInternalField(0)); | |
111 | + ui_board_ = *static_cast<UISuperPtr*>(ui_board_obj_->GetPointerFromInternalField(0)); | |
105 | 112 | } |
106 | 113 | |
107 | 114 | ui_board_->set_icon_image_handle( |
108 | 115 | 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 | + | |
109 | 144 | } |
110 | 145 | |
111 | 146 | Card::~Card() |
@@ -297,6 +332,26 @@ Handle<Value> Card::Function_Music_IsLoadingDone(const Arguments& args) | ||
297 | 332 | return Boolean::New(false); |
298 | 333 | } |
299 | 334 | |
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 | + | |
300 | 355 | Handle<Value> Card::Function_Account_id(const Arguments& args) |
301 | 356 | { |
302 | 357 | auto self = static_cast<Card*>(args.Holder()->GetPointerFromInternalField(0)); |
@@ -890,6 +945,15 @@ void Card::SetFunctions() | ||
890 | 945 | script_.SetFunction("Music.rebuild", Function_Music_Rebuild); |
891 | 946 | |
892 | 947 | 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 | + | |
893 | 957 | /** |
894 | 958 | * アカウント |
895 | 959 | * |
@@ -1347,8 +1411,9 @@ UISuperPtr Card::GetWindow() const | ||
1347 | 1411 | return ui_board_; |
1348 | 1412 | } else { |
1349 | 1413 | 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()) { | |
1352 | 1417 | return ptr; |
1353 | 1418 | } |
1354 | 1419 | } |
@@ -66,6 +66,7 @@ class CardManager : public std::enable_shared_from_this<CardManager> { | ||
66 | 66 | static char CARDS_DIR[]; |
67 | 67 | static char START_METADATA[]; |
68 | 68 | static char END_METADATA[]; |
69 | + | |
69 | 70 | }; |
70 | 71 | |
71 | 72 | typedef std::shared_ptr<CardManager> CardManagerPtr; |
@@ -160,6 +160,31 @@ _error: | ||
160 | 160 | return RemoveDirectory( lpPathName ); |
161 | 161 | } |
162 | 162 | |
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 | + } | |
163 | 188 | }; |
164 | 189 | |
165 | 190 | JsonGen::JsonGen() |
@@ -209,7 +234,7 @@ JsonGen::JsonGen() | ||
209 | 234 | { |
210 | 235 | ZeroMemory(tcsTmpPath_Pmd,MAX_PATH); |
211 | 236 | _tcscpy_s(tcsTmpPath_Pmd,tcsTmpDir); |
212 | - _tcscat_s(tcsTmpPath_Pmd,_T("*.pmd")); | |
237 | + _tcscat_s(tcsTmpPath_Pmd,_T("*.pm?")); | |
213 | 238 | hPmdFind = FindFirstFile(tcsTmpPath_Pmd, &win32fd_pmd); |
214 | 239 | if(hPmdFind == (HANDLE)0xffffffff) |
215 | 240 | { |
@@ -247,6 +272,7 @@ JsonGen::JsonGen() | ||
247 | 272 | |
248 | 273 | // モデル名取得 |
249 | 274 | strcpy_s(pmd_model_name_,pmd_info+7); |
275 | + Trim(pmd_model_name_); | |
250 | 276 | int cnt = 0x1b; |
251 | 277 | size_t info_size = ADFUNC_DXconvAnsiToWide(0,0,pmd_info+cnt); |
252 | 278 | TCHAR *pmd_info_t = new TCHAR[info_size + 1]; |
@@ -45,6 +45,86 @@ Input::Input() : | ||
45 | 45 | y_ = 100; |
46 | 46 | width_ = 160; |
47 | 47 | 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 | + | |
48 | 128 | } |
49 | 129 | |
50 | 130 | void Input::Draw() |
@@ -271,6 +351,8 @@ void Input::ProcessInput(InputManager* input) | ||
271 | 351 | return; |
272 | 352 | } |
273 | 353 | |
354 | + bool push_mouse_right = (input->GetMouseRight() > 0); | |
355 | + | |
274 | 356 | // bool push_mouse_left = (input->GetMouseLeftCount() > 0); |
275 | 357 | |
276 | 358 | // bool first_key_shift = (input->GetKeyCount(KEY_INPUT_RSHIFT) == 1 |
@@ -504,7 +586,7 @@ void Input::ProcessInput(InputManager* input) | ||
504 | 586 | #endif |
505 | 587 | |
506 | 588 | // 選択範囲を記録 |
507 | - if (select_start < char_count && char_count <= select_end) { | |
589 | + if (select_start > 0 && char_count >= select_end) { | |
508 | 590 | selecting_lines_.resize(static_cast<int>(lines_.size() + message_lines_.size()) + 1, |
509 | 591 | std::pair<int, int>(99999, 0)); |
510 | 592 | selecting_lines_[static_cast<int>(lines_.size() + message_lines_.size())].first = std::min( |
@@ -716,6 +798,11 @@ void Input::ProcessInput(InputManager* input) | ||
716 | 798 | if (active()) { |
717 | 799 | input->CancelKeyCountAll(); |
718 | 800 | } |
801 | + | |
802 | + // 右クリック描画 | |
803 | + if (push_mouse_right) { | |
804 | + | |
805 | + } | |
719 | 806 | } |
720 | 807 | |
721 | 808 | bool Input::active() |
@@ -8,6 +8,7 @@ | ||
8 | 8 | #include <functional> |
9 | 9 | #include "../ResourceManager.hpp" |
10 | 10 | #include "../InputManager.hpp" |
11 | +#include "include.hpp" | |
11 | 12 | |
12 | 13 | class Input { |
13 | 14 | typedef std::function<bool(const std::string&)> CallbackFunc; |
@@ -80,6 +81,8 @@ class Input { | ||
80 | 81 | bool reverse_color_; |
81 | 82 | int blink_count_; |
82 | 83 | |
84 | + UIList right_click_list_; | |
85 | + | |
83 | 86 | private: |
84 | 87 | const static size_t TEXT_BUFFER_SIZE; |
85 | 88 | const static size_t HISTORY_MAX_SIZE; |
@@ -102,8 +102,13 @@ InputBox::InputBox(const ManagerAccessorPtr& manager_accessor) : | ||
102 | 102 | |
103 | 103 | return true; |
104 | 104 | }); |
105 | + | |
106 | + | |
105 | 107 | } |
106 | 108 | |
109 | + | |
110 | + | |
111 | + | |
107 | 112 | InputBox::~InputBox() |
108 | 113 | { |
109 | 114 | } |
@@ -35,7 +35,7 @@ class InputBox : public UISuper { | ||
35 | 35 | int multiline() const; |
36 | 36 | void set_multiline(int multiline); |
37 | 37 | |
38 | - private: | |
38 | +private: | |
39 | 39 | void CancelSelect(); |
40 | 40 | |
41 | 41 | void DrawBase(); |
@@ -112,4 +112,5 @@ class InputBox : public UISuper { | ||
112 | 112 | const static int IME_MARGIN_Y; |
113 | 113 | const static int IME_MAX_PAGE_SIZE; |
114 | 114 | const static int IME_MIN_WIDTH; |
115 | + | |
115 | 116 | }; |
@@ -38,6 +38,15 @@ void UIBase::ProcessInput(InputManager* input) | ||
38 | 38 | |
39 | 39 | } |
40 | 40 | |
41 | +void UIBase::Update() | |
42 | +{ | |
43 | +}; | |
44 | + | |
45 | +void UIBase::Draw() | |
46 | +{ | |
47 | + DrawChildren(); | |
48 | +} | |
49 | + | |
41 | 50 | void UIBase::AsyncUpdate() |
42 | 51 | { |
43 | 52 | AsyncUpdateChildren(); |
@@ -469,6 +478,25 @@ void UIBase::set_parent(const Handle<Object>& parent) | ||
469 | 478 | parent_ = Persistent<Object>::New(parent); |
470 | 479 | } |
471 | 480 | |
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 | + | |
472 | 500 | size_t UIBase::children_size() const |
473 | 501 | { |
474 | 502 | return children_.size(); |
@@ -7,6 +7,7 @@ | ||
7 | 7 | #include "UISuper.hpp" |
8 | 8 | #include <v8.h> |
9 | 9 | #include "../InputManager.hpp" |
10 | +#include <functional> | |
10 | 11 | |
11 | 12 | using namespace v8; |
12 | 13 |
@@ -14,8 +15,10 @@ class ScriptEnvironment; | ||
14 | 15 | typedef std::weak_ptr<ScriptEnvironment> ScriptEnvironmentWeakPtr; |
15 | 16 | |
16 | 17 | class UIBase; |
18 | +class Input; | |
17 | 19 | typedef std::shared_ptr<UIBase> UIBasePtr; |
18 | 20 | typedef std::weak_ptr<UIBase> UIBaseWeakPtr; |
21 | +typedef std::function<void()> CallbackFunc; | |
19 | 22 | |
20 | 23 | class UIBase : public UISuper { |
21 | 24 |
@@ -24,8 +27,8 @@ class UIBase : public UISuper { | ||
24 | 27 | virtual ~UIBase(); |
25 | 28 | |
26 | 29 | virtual void ProcessInput(InputManager* input); |
27 | - virtual void Update() = 0; | |
28 | - virtual void Draw() = 0; | |
30 | + virtual void Update(); | |
31 | + virtual void Draw(); | |
29 | 32 | virtual void AsyncUpdate(); // 毎ループ実行する必要のない処理 |
30 | 33 | |
31 | 34 | /* function */ |
@@ -57,7 +60,10 @@ class UIBase : public UISuper { | ||
57 | 60 | |
58 | 61 | Handle<Object> parent() const; |
59 | 62 | 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); | |
61 | 67 | size_t children_size() const; |
62 | 68 | |
63 | 69 | template<class T> |
@@ -92,13 +98,22 @@ class UIBase : public UISuper { | ||
92 | 98 | |
93 | 99 | void Focus(); |
94 | 100 | |
101 | + public: | |
102 | + /* Property */ | |
103 | + template<class F> | |
104 | + void set_on_click_function_(F function); | |
105 | + | |
95 | 106 | protected: |
96 | 107 | |
97 | 108 | Persistent<Object> parent_; |
98 | 109 | std::vector<Persistent<Object>> children_; |
99 | 110 | |
100 | 111 | Persistent<Function> on_click_; |
112 | + CallbackFunc on_click_function_; | |
101 | 113 | |
114 | + /*C++からクラスを伝達するためのメンバ*/ | |
115 | + UIBasePtr parent_c_; | |
116 | + std::shared_ptr<Input> input_adaptor_; | |
102 | 117 | }; |
103 | 118 | |
104 | 119 | inline void Destruct(Persistent<Value> handle, void* parameter) { |
@@ -155,3 +170,9 @@ void UIBase::SetConstant(Handle<ObjectTemplate>* object, const std::string& name | ||
155 | 170 | Handle<ObjectTemplate>& instance_template = *object; |
156 | 171 | instance_template->Set(String::New(name.c_str()), value); |
157 | 172 | } |
173 | + | |
174 | +template<class F> | |
175 | +void UIBase::set_on_click_function_(F function) | |
176 | +{ | |
177 | + on_click_function_ = function; | |
178 | +} |
@@ -25,7 +25,8 @@ UIBoard::UIBoard() : | ||
25 | 25 | max_height_(800), |
26 | 26 | min_height_(100), |
27 | 27 | 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) | |
29 | 30 | { |
30 | 31 | base_image_handle_ = ResourceManager::LoadCachedDivGraph<4>( |
31 | 32 | _T("system/images/gui/gui_board_bg.png"), 2, 2, 24, 24); |
@@ -247,40 +248,42 @@ void UIBoard::Draw() | ||
247 | 248 | if (!visible_) { |
248 | 249 | return; |
249 | 250 | } |
251 | + | |
252 | + if (boardvisible_) { | |
253 | + SetDrawBlendMode(DX_BLENDMODE_ADD, 255); | |
250 | 254 | |
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(); | |
252 | 259 | |
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); | |
257 | 264 | |
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); | |
262 | 268 | |
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); | |
266 | 272 | |
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); | |
270 | 276 | |
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); | |
274 | 280 | |
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); | |
278 | 284 | |
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 | + } | |
284 | 287 | |
285 | 288 | DrawChildren(); |
286 | 289 | } |
@@ -290,6 +293,16 @@ bool UIBoard::resizable() const | ||
290 | 293 | return resizable_; |
291 | 294 | } |
292 | 295 | |
296 | +bool UIBoard::boardvisible() const | |
297 | +{ | |
298 | + return boardvisible_; | |
299 | +} | |
300 | + | |
301 | +void UIBoard::set_boardvisible(bool visible) | |
302 | +{ | |
303 | + boardvisible_ = visible; | |
304 | +} | |
305 | + | |
293 | 306 | void UIBoard::set_resizable(bool resizable) |
294 | 307 | { |
295 | 308 | resizable_ = resizable; |
@@ -16,7 +16,9 @@ class UIBoard : public UIBase { | ||
16 | 16 | void Draw(); |
17 | 17 | |
18 | 18 | bool resizable() const; |
19 | + bool boardvisible() const; | |
19 | 20 | void set_resizable(bool resizable); |
21 | + void set_boardvisible(bool visible); | |
20 | 22 | |
21 | 23 | public: |
22 | 24 | static void DefineInstanceTemplate(Handle<ObjectTemplate>* object); |
@@ -38,6 +40,7 @@ class UIBoard : public UIBase { | ||
38 | 40 | std::array<ImageHandlePtr,4> base_image_handle_; |
39 | 41 | |
40 | 42 | bool resizable_; |
43 | + bool boardvisible_; | |
41 | 44 | |
42 | 45 | int max_width_, min_width_; |
43 | 46 | int max_height_, min_height_; |
@@ -47,3 +50,5 @@ class UIBoard : public UIBase { | ||
47 | 50 | private: |
48 | 51 | const static int BASE_BLOCK_SIZE; |
49 | 52 | }; |
53 | + | |
54 | +typedef std::shared_ptr<UIBoard> UIBoardPtr; | |
\ No newline at end of file |
@@ -11,7 +11,6 @@ | ||
11 | 11 | #include <functional> |
12 | 12 | |
13 | 13 | class UIButton : public UIBase { |
14 | - typedef std::function<void()> CallbackFunc; | |
15 | 14 | |
16 | 15 | public: |
17 | 16 | UIButton(); |
@@ -96,7 +96,8 @@ void UICustom::DefineInstanceTemplate(Handle<ObjectTemplate>* object) | ||
96 | 96 | SetProperty(object, "_update", Property_update, Property_set_update); |
97 | 97 | SetProperty(object, "_draw", Property_draw, Property_set_draw); |
98 | 98 | |
99 | - SetFunction(object, "drawLine", Function_drawLine); | |
99 | + SetFunction(object, "DrawLine", Function_DrawLine); | |
100 | + SetFunction(object, "DrawBox", Function_DrawBox); | |
100 | 101 | } |
101 | 102 | |
102 | 103 | void UICustom::ProcessInput(InputManager* input) |
@@ -131,16 +132,527 @@ void UICustom::Draw() | ||
131 | 132 | } |
132 | 133 | } |
133 | 134 | |
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) | |
135 | 410 | { |
136 | 411 | assert(args.This()->InternalFieldCount() > 0); |
137 | 412 | auto self = std::dynamic_pointer_cast<UICustom>( |
138 | 413 | *static_cast<UIBasePtr*>(args.This()->GetPointerFromInternalField(0)) |
139 | 414 | ); |
140 | 415 | 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)); | |
141 | 429 | |
142 | - DrawLine(100, 100, 200, 200, GetColor(255,255,255)); | |
430 | + } | |
143 | 431 | |
144 | 432 | return Undefined(); |
145 | 433 | } |
146 | 434 | |
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 | +} |
@@ -28,7 +28,26 @@ class UICustom : public UIBase { | ||
28 | 28 | static void Property_set_draw(Local<String> property, Local<Value> value, const AccessorInfo& info); |
29 | 29 | |
30 | 30 | 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); | |
32 | 51 | |
33 | 52 | }; |
34 | 53 |
@@ -189,6 +189,8 @@ void UILabel::ProcessInput(InputManager* input) | ||
189 | 189 | if (input->GetMouseLeftCount() == 1 && hover) { |
190 | 190 | if (!on_click_.IsEmpty() && on_click_->IsFunction()) { |
191 | 191 | on_click_.As<Function>()->CallAsFunction(Context::GetCurrent()->Global(), 0, nullptr); |
192 | + }else if(!on_click_function_._Empty()) { | |
193 | + on_click_function_(); | |
192 | 194 | } |
193 | 195 | } |
194 | 196 | } |
@@ -169,6 +169,36 @@ void UIList::ProcessInput(InputManager* input) | ||
169 | 169 | |
170 | 170 | } |
171 | 171 | |
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 | + | |
172 | 202 | void UIList::UpdateScrollBar(InputManager* input) |
173 | 203 | { |
174 | 204 | int screen_width, screen_height; |
@@ -17,8 +17,9 @@ class UIList : public UIBase { | ||
17 | 17 | void Update(); |
18 | 18 | void Draw(); |
19 | 19 | |
20 | + /* Java Script's Function*/ | |
20 | 21 | public: |
21 | - static void DefineInstanceTemplate(Handle<ObjectTemplate>* object); | |
22 | + static void DefineInstanceTemplate(Handle<ObjectTemplate>* object); | |
22 | 23 | |
23 | 24 | private: |
24 | 25 | /* function */ |
@@ -30,6 +31,15 @@ class UIList : public UIBase { | ||
30 | 31 | static Handle<Value> Property_scroll_y(Local<String> property, const AccessorInfo &info); |
31 | 32 | static void Property_set_scroll_y(Local<String> property, Local<Value> value, const AccessorInfo& info); |
32 | 33 | |
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 | + | |
33 | 43 | private: |
34 | 44 | std::array<ImageHandlePtr,4> scrollbar_base_image_handle_; |
35 | 45 |