#include "GenerateJSON.hpp"\r
#include "Music.hpp"\r
\r
+#pragma comment(lib,"libctemplate.lib")\r
+\r
+#define CTEMPLATE_DLL_DECL\r
+#include <config.h>\r
+#include <ctemplate/template.h>\r
+\r
\r
char Card::STORAGE_DIR[] = "storage";\r
char Card::SCRIPT_PATH[] = "system/js";\r
context->Global()->Set(String::New("Model"), script_object->Clone());\r
context->Global()->Set(String::New("Account"), script_object->Clone());\r
context->Global()->Set(String::New("Music"), script_object->Clone());\r
+ context->Global()->Set(String::New("Plugin"), script_object->Clone());\r
context->Global()->Set(String::New("InputBox"), script_object->Clone());\r
context->Global()->Set(String::New("Card"), script_object->Clone());\r
context->Global()->Set(String::New("Screen"), script_object->Clone());\r
assert(!ui_board_obj_.IsEmpty() && ui_board_obj_->IsObject());\r
});\r
\r
- ui_board_ = *static_cast<UIBasePtr*>(ui_board_obj_->GetPointerFromInternalField(0));\r
+ ui_board_ = *static_cast<UISuperPtr*>(ui_board_obj_->GetPointerFromInternalField(0));\r
}\r
\r
ui_board_->set_icon_image_handle(\r
ResourceManager::LoadCachedGraph(unicode::ToTString(source_folder_ + "/" + icon_)));\r
+\r
+\r
+ auto sprit = [](const std::string &str, const std::string &delim)->std::vector<std::string>\r
+ {\r
+ std::vector<std::string> res;\r
+ size_t current = 0, found, delimlen = delim.size();\r
+ while((found = str.find(delim, current)) != std::string::npos){\r
+ res.push_back(std::string(str, current, found - current));\r
+ current = found + delimlen;\r
+ }\r
+ res.push_back(std::string(str, current, str.size() - current));\r
+ return res;\r
+ };\r
+\r
+\r
+ auto ui_board_tmp = *static_cast<UIBoardPtr*>(ui_board_obj_->GetPointerFromInternalField(0));\r
+ auto pos = name_.find_first_of("@");\r
+ if ( pos != std::string::npos )\r
+ {\r
+ std::string plug_dat = name_.substr(pos,name_.length() - pos);\r
+ auto str_array = sprit(plug_dat,",");\r
+ BOOST_FOREACH(auto str,str_array)\r
+ {\r
+ if(str == "plugin")ui_board_tmp->set_boardvisible(false);\r
+ if(str == "uiplugin")ui_board_tmp->set_boardvisible(true);\r
+ }\r
+ }\r
+\r
}\r
\r
Card::~Card()\r
return Boolean::New(false);\r
}\r
\r
+Handle<Value> Card::Function_Plugin_Run(const Arguments& args)\r
+{\r
+ auto self = static_cast<Card*>(args.Holder()->GetPointerFromInternalField(0));\r
+ if (auto card_manager = self->manager_accessor_->card_manager().lock()) {\r
+ if ( args[0]->IsString() ) {\r
+ auto name = std::string(*String::Utf8Value(args[0]->ToString()));\r
+ BOOST_FOREACH(auto card,card_manager->cards()) {\r
+ auto pos = card->name().find_first_of("@");\r
+ if( pos != std::string::npos ) {\r
+ if ( name == card->name().substr(0,pos) ) {\r
+ card->Run();\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+ return Undefined();\r
+}\r
+\r
+\r
Handle<Value> Card::Function_Account_id(const Arguments& args)\r
{\r
auto self = static_cast<Card*>(args.Holder()->GetPointerFromInternalField(0));\r
script_.SetFunction("Music.rebuild", Function_Music_Rebuild);\r
\r
script_.SetProperty("Music.onReload", Property_Music_onReload, Property_set_Music_onReload);\r
+\r
+ /**\r
+ * 非自動実行プラグインを走らせます\r
+ *\r
+ * @method run\r
+ * @static\r
+ */\r
+ script_.SetFunction("Plugin.run", Function_Plugin_Run);\r
+\r
/**\r
* アカウント\r
*\r
return ui_board_;\r
} else {\r
if (ui_board_obj_->IsObject()) {\r
- auto ptr = *static_cast<UIBasePtr*>(ui_board_obj_->GetPointerFromInternalField(0));\r
- if (ptr->children_size() > 0) {\r
+ auto ptr = *static_cast<UIBoardPtr*>(ui_board_obj_->GetPointerFromInternalField(0));\r
+ assert(ptr);\r
+ if (ptr->children_size() > 0 && ptr->boardvisible()) {\r
return ptr;\r
}\r
}\r
return RemoveDirectory( lpPathName );\r
}\r
\r
+ int Trim(char *s) {\r
+ int i;\r
+ int count = 0;\r
+\r
+ /* \8bó\83|\83C\83\93\83^\82©? */\r
+ if ( s == NULL ) { /* yes */\r
+ return -1;\r
+ }\r
+\r
+ /* \95¶\8e\9a\97ñ\92·\82ð\8eæ\93¾\82·\82é */\r
+ i = strlen(s);\r
+\r
+ /* \96\96\94ö\82©\82ç\8f\87\82É\8bó\94\92\82Å\82È\82¢\88Ê\92u\82ð\92T\82· */\r
+ while ( --i >= 0 && s[i] == ' ' ) count++;\r
+\r
+ /* \8fI\92[\83i\83\8b\95¶\8e\9a\82ð\95t\89Á\82·\82é */\r
+ s[i+1] = '\0';\r
+\r
+ /* \90æ\93ª\82©\82ç\8f\87\82É\8bó\94\92\82Å\82È\82¢\88Ê\92u\82ð\92T\82· */\r
+ i = 0;\r
+ while ( s[i] != '\0' && s[i] == ' ' ) i++;\r
+ strcpy(s, &s[i]);\r
+\r
+ return i + count;\r
+ }\r
};\r
\r
JsonGen::JsonGen()\r
{\r
ZeroMemory(tcsTmpPath_Pmd,MAX_PATH);\r
_tcscpy_s(tcsTmpPath_Pmd,tcsTmpDir);\r
- _tcscat_s(tcsTmpPath_Pmd,_T("*.pmd"));\r
+ _tcscat_s(tcsTmpPath_Pmd,_T("*.pm?"));\r
hPmdFind = FindFirstFile(tcsTmpPath_Pmd, &win32fd_pmd);\r
if(hPmdFind == (HANDLE)0xffffffff)\r
{\r
\r
// \83\82\83f\83\8b\96¼\8eæ\93¾\r
strcpy_s(pmd_model_name_,pmd_info+7);\r
+ Trim(pmd_model_name_);\r
int cnt = 0x1b;\r
size_t info_size = ADFUNC_DXconvAnsiToWide(0,0,pmd_info+cnt);\r
TCHAR *pmd_info_t = new TCHAR[info_size + 1];\r
const size_t Input::TEXT_BUFFER_SIZE = 1024;
const size_t Input::HISTORY_MAX_SIZE = 50;
-const int Input::KEY_REPEAT_FRAME = 6;
+const int Input::KEY_REPEAT_FRAME = 8;
const int Input::INPUT_MARGIN_X = 8;
const int Input::INPUT_MARGIN_Y = 6;
const int Input::IME_MAX_PAGE_SIZE = 6;
const int Input::IME_MIN_WIDTH = 120;
-Input::Input() :
+Input::Input(ConfigManagerPtr config_manager) :
multiline_(true),
- reverse_color_(false)
+ reverse_color_(false),
+ drag_flag_(false),
+ rightmenu_show_(false),
+ config_manager_(config_manager)
{
input_bg_image_handle_ = ResourceManager::LoadCachedDivGraph<4>(
_T("system/images/gui/gui_inputbox_input_bg.png"), 2, 2, 12, 12);
y_ = 100;
width_ = 160;
height_ = font_height_ + 4;
+
+}
+
+void Input::Init()
+{
+ right_click_list_.addItem(UIBasePtr(new UILabel([&]()->UILabel{
+ UILabel label;
+ label.set_input_adaptor(this);
+ label.set_text(unicode::ToTString(unicode::sjis2utf8("切り取り")));
+ label.set_width(120);
+ label.set_top(12);
+ label.set_left(0);
+ label.set_textcolor(UISuper::Color(0,0,0,255));
+ label.set_bgcolor(UISuper::Color(255,255,255,180));
+ label.set_on_click_function_([](UIBase* ptr)->void{
+ auto input_ = ptr->input_adpator();
+ auto sel_txt = input_->selecting_text();
+ SetClipboardText(sel_txt.c_str());
+ auto text = input_->text();
+ auto pos = text.find(sel_txt);
+ tstring res;
+ if( pos != std::string::npos )
+ {
+ res = text.substr(0,pos);
+ res += text.substr(pos + sel_txt.size(),text.size() - pos + sel_txt.size());
+ }
+ input_->set_text(res);
+ });
+ label.set_on_hover_function_([](UIBase* ptr)->void{
+ auto label_ptr = (UILabel *)ptr;
+ label_ptr->set_bgcolor(UISuper::Color(0,0,0,180));
+ label_ptr->set_textcolor(UISuper::Color(255,255,255));
+ });
+ label.set_on_out_function_([](UIBase* ptr)->void{
+ auto label_ptr = (UILabel *)ptr;
+ label_ptr->set_bgcolor(UISuper::Color(255,255,255,180));
+ label_ptr->set_textcolor(UISuper::Color(0,0,0));
+ });
+ return label;
+ }())));
+ right_click_list_.addItem(UIBasePtr(new UILabel([&]()->UILabel{
+ UILabel label;
+ label.set_input_adaptor(this);
+ label.set_text(unicode::ToTString(unicode::sjis2utf8("コピー")));
+ label.set_width(120);
+ label.set_top(12);
+ label.set_left(0);
+ label.set_textcolor(UISuper::Color(0,0,0,255));
+ label.set_bgcolor(UISuper::Color(255,255,255,180));
+ label.set_on_click_function_([&](UIBase* ptr)->void{
+ auto input_ = ptr->input_adpator();
+ SetClipboardText(input_->selecting_text().c_str());
+ });
+ label.set_on_hover_function_([](UIBase* ptr)->void{
+ auto label_ptr = (UILabel *)ptr;
+ label_ptr->set_bgcolor(UISuper::Color(0,0,0,180));
+ label_ptr->set_textcolor(UISuper::Color(255,255,255));
+ });
+ label.set_on_out_function_([](UIBase* ptr)->void{
+ auto label_ptr = (UILabel *)ptr;
+ label_ptr->set_bgcolor(UISuper::Color(255,255,255,180));
+ label_ptr->set_textcolor(UISuper::Color(0,0,0));
+ });
+ return label;
+ }())));
+ right_click_list_.addItem(UIBasePtr(new UILabel([&]()->UILabel{
+ UILabel label;
+ label.set_input_adaptor(this);
+ label.set_text(unicode::ToTString(unicode::sjis2utf8("貼り付け")));
+ label.set_width(120);
+ label.set_top(12);
+ label.set_left(0);
+ label.set_textcolor(UISuper::Color(0,0,0,255));
+ label.set_bgcolor(UISuper::Color(255,255,255,180));
+ label.set_on_click_function_([&](UIBase* ptr)->void{
+ auto input_ = ptr->input_adpator();
+ auto size = GetClipboardText(NULL);
+ if(size > 0){
+ TCHAR *buf = new TCHAR[size];
+ GetClipboardText(buf);
+ input_->paste_text(buf);
+ delete []buf;
+ }
+ });
+ label.set_on_hover_function_([](UIBase* ptr)->void{
+ auto label_ptr = (UILabel *)ptr;
+ label_ptr->set_bgcolor(UISuper::Color(0,0,0,180));
+ label_ptr->set_textcolor(UISuper::Color(255,255,255));
+ });
+ label.set_on_out_function_([](UIBase* ptr)->void{
+ auto label_ptr = (UILabel *)ptr;
+ label_ptr->set_bgcolor(UISuper::Color(255,255,255,180));
+ label_ptr->set_textcolor(UISuper::Color(0,0,0));
+ });
+ return label;
+ }())));
+ right_click_list_.set_height((font_height_ + 2)* 3);
+ right_click_list_.set_width(120);
}
void Input::Draw()
}
}
- for (auto it = lines_.begin(); it != lines_.end(); ++it) {
- auto line = *it;
- DrawStringToHandle(internal_x, internal_y + current_line * font_height_,
- line.c_str(), text_color, font_handle_);
- current_line++;
- }
+ int select_start = 0,select_end = 0;
+ GetKeyInputSelectArea(&select_start,&select_end,input_handle_);
+ if( select_start > select_end )std::swap(select_start,select_end);
+
+ if( select_start > -1 && select_end != select_start ) {
+ if ( multiline_ ) {
+ BOOST_FOREACH(auto it,lines_){
+ int width = 0;
+ TCHAR c[2] = {0};
+ if( select_start >= it.size() && select_start != -1 ) {
+ DrawStringToHandle(internal_x, internal_y + current_line * font_height_,
+ it.c_str(), text_color, font_handle_);
+ if(select_start == it.size()){
+ select_start -= it.size();
+ }else{
+ select_start -= it.size() + 1;
+ }
+ select_end -= it.size() + 1;
+ ++current_line;
+ }else if(select_start != -1){
+ for(int i = 0;i < select_start;++i){
+ c[0] = it[i];
+ DrawStringToHandle(internal_x + width, internal_y + current_line * font_height_,
+ c, text_color, font_handle_);
+ width += GetDrawStringWidthToHandle(c,1,font_handle_);
+ }
+ for(int i = select_start;i < ((select_end > it.size()) ? it.size() : select_end); ++i){
+ c[0] = it[i];
+ SetDrawBlendMode(DX_BLENDMODE_ALPHA, 180);
+ DrawBox(internal_x + width,internal_y + current_line * font_height_,
+ internal_x + width + GetDrawStringWidthToHandle(c,1,font_handle_),internal_y + ( current_line + 1 ) * font_height_,text_color,1);
+ DrawStringToHandle(internal_x + width, internal_y + current_line * font_height_,
+ c, !reverse_color_ ? GetColor(255, 255, 255) : GetColor(0, 0, 0), font_handle_);
+ width += GetDrawStringWidthToHandle(c,1,font_handle_);
+ SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0);
+ }
+ for(int i = ((select_end > it.size()) ? it.size() : select_end);i < it.size(); ++i){
+ c[0] = it[i];
+ DrawStringToHandle(internal_x + width, internal_y + current_line * font_height_,
+ c, text_color, font_handle_);
+ width += GetDrawStringWidthToHandle(c,1,font_handle_);
+ }
+ if(select_end > it.size()){
+ select_end -= it.size() + 1;
+ select_start = 0;
+ }else{
+ select_start = -1;
+ }
+ ++current_line;
+ }else if(select_start == -1){
+ DrawStringToHandle(internal_x + width, internal_y + current_line * font_height_,
+ it.c_str(), text_color, font_handle_);
+ ++current_line;
+ }
+ }
+ }else{
+ BOOST_FOREACH(auto it,lines_){
+ int width = 0;
+ TCHAR c[2] = {0};
+ for(int i = 0;i < select_start;++i){
+ c[0] = it[i];
+ DrawStringToHandle(internal_x + width, internal_y + current_line * font_height_,
+ c, text_color, font_handle_);
+ width += GetDrawStringWidthToHandle(c,1,font_handle_);
+ }
+ for(int i = select_start;i < select_end; ++i){
+ c[0] = it[i];
+ SetDrawBlendMode(DX_BLENDMODE_ALPHA, 180);
+ DrawBox(internal_x + width,internal_y + current_line * font_height_,
+ internal_x + width + GetDrawStringWidthToHandle(c,1,font_handle_),internal_y + ( current_line + 1 ) * font_height_,text_color,1);
+ DrawStringToHandle(internal_x + width, internal_y + current_line * font_height_,
+ c, !reverse_color_ ? GetColor(255, 255, 255) : GetColor(0, 0, 0), font_handle_);
+ width += GetDrawStringWidthToHandle(c,1,font_handle_);
+ SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0);
+ }
+ for(int i = select_end;i < it.size(); ++i){
+ c[0] = it[i];
+ DrawStringToHandle(internal_x + width, internal_y + current_line * font_height_,
+ c, text_color, font_handle_);
+ width += GetDrawStringWidthToHandle(c,1,font_handle_);
+ }
+ }
+ }
+ }else{
+ for (auto it = lines_.begin(); it != lines_.end(); ++it) {
+ auto line = *it;
+ DrawStringToHandle(internal_x, internal_y + current_line * font_height_,
+ line.c_str(), text_color, font_handle_);
+ current_line++;
+ }
+ }
+
// カーソルを描画
if (clause_lines_.size() <= 0 && active() && blink_count_ < 30) {
}
}
}
+ {
+ if ( rightmenu_show_ ) {
+ right_click_list_.Draw();
+ }
+ }
}
void Input::Update()
{
blink_count_ = (blink_count_ + 1) % 60;
+ {
+ if ( rightmenu_show_ ) {
+ right_click_list_.Update();
+ }
+ }
}
void Input::ProcessInput(InputManager* input)
return;
}
- // bool push_mouse_left = (input->GetMouseLeftCount() > 0);
+ if ( rightmenu_show_ ) {
+ right_click_list_.ProcessInput(input);
+ }
+
+ bool push_mouse_left = (input->GetMouseLeftCount() > 0);
+ bool prev_mouse_left = input->GetPrevMouseLeft();
+
+ bool push_mouse_right = (input->GetMouseRightCount() > 0);
+ bool prev_mouse_right = input->GetPrevMouseRight();
// bool first_key_shift = (input->GetKeyCount(KEY_INPUT_RSHIFT) == 1
// || input->GetKeyCount(KEY_INPUT_LSHIFT) == 1);
+ KEY_REPEAT_FRAME) % (KEY_REPEAT_FRAME + 1) == 0;
bool push_repeat_key_down = (input->GetKeyCount(KEY_INPUT_DOWN)
+ KEY_REPEAT_FRAME) % (KEY_REPEAT_FRAME + 1) == 0;
+
// bool push_long_backspace = (input->GetKeyCount(KEY_INPUT_BACK) > 60 * 1.5);
auto input_text = text();
}
if (active()) {
- // カーソル位置(byte)を取得
+ if ( !rightmenu_show_ &&
+ !( rightmenu_show_ && right_click_list_.absolute_x()<= input->GetMouseX() && input->GetMouseX() <= right_click_list_.absolute_x()+ right_click_list_.absolute_width()
+ && right_click_list_.absolute_y() <= input->GetMouseY() && input->GetMouseY() <= right_click_list_.absolute_y() + right_click_list_.absolute_height())) {
+ // マウス左ボタンが押された時
+ if (push_mouse_left && !prev_mouse_left) {
+ auto mpos = input->GetMousePos();
+ auto offset_x = mpos.first - (x_ + INPUT_MARGIN_X);
+ auto offset_y = mpos.second - (y_ + INPUT_MARGIN_Y);
+ // カレット変更
+ if( multiline_ ) {
+ auto line_num = offset_y / font_height_;
+ //if( ( offset_y % font_height_ ) != 0 )++line_num;
+ int tmp = 0,cnt = 0;
+ if( line_num < (int)lines_.size() && line_num >= 0 ){
+ for(int i = 0;i < line_num; ++i){
+ cnt += lines_[i].size();
+ }
+ for(int i = 0;i < lines_[line_num].size(); ++i){
+ auto tmp_x = GetDrawStringWidthToHandle(&lines_[line_num][i],1,font_handle_);
+ if( tmp + tmp_x < offset_x ){
+ tmp += tmp_x;
+ ++cnt;
+ }
+ }
+ SetKeyInputCursorPosition(line_num + cnt,input_handle_);
+ }
+ }else{
+ int tmp = 0,cnt = 0;
+ for(int i = 0;i < lines_[0].size(); ++i){
+ auto tmp_x = GetDrawStringWidthToHandle(&lines_[0][i],1,font_handle_);
+ if( tmp + tmp_x < offset_x ){
+ tmp += tmp_x;
+ ++cnt;
+ }
+ }
+ if( selecting_coursorpoint_.first = selecting_coursorpoint_.second ) {
+ SetKeyInputSelectArea( -1, -1, input_handle_ );
+ }else{
+ SetKeyInputSelectArea(selecting_coursorpoint_.first,selecting_coursorpoint_.second,input_handle_);
+ }
+ SetKeyInputCursorPosition(cnt,input_handle_);
+ }
+ }
+ // マウス左ボタンがドラッグされた時
+ if (push_mouse_left && prev_mouse_left ) {
+ int prev_cursor_pos = 0;
+ if( !drag_flag_ ){
+ prev_cursor_pos = GetKeyInputCursorPosition(input_handle_);
+ }else{
+ prev_cursor_pos = selecting_coursorpoint_.first;
+ }
+ auto mpos = input->GetMousePos();
+ auto offset_x = mpos.first - (x_ + INPUT_MARGIN_X);
+ auto offset_y = mpos.second - (y_ + INPUT_MARGIN_Y);
+ // カレット変更
+ if( multiline_ ) {
+ auto line_num = offset_y / font_height_;
+ int tmp = 0,cnt = 0;
+ if( line_num < (int)lines_.size() && line_num >= 0){
+ for(int i = 0;i < line_num; ++i,++cnt){
+ cnt += lines_[i].size();
+ }
+ for(int i = 0;i < lines_[line_num].size(); ++i){
+ auto tmp_x = GetDrawStringWidthToHandle(&lines_[line_num][i],1,font_handle_);
+ if( tmp + tmp_x < offset_x ){
+ tmp += tmp_x;
+ ++cnt;
+ }
+ }
+ }
+ selecting_coursorpoint_ = std::make_pair<int,int>(prev_cursor_pos,cnt);
+ }else{
+ int tmp = 0,cnt = 0;
+ for(int i = 0;i < lines_[0].size(); ++i){
+ auto tmp_x = GetDrawStringWidthToHandle(&lines_[0][i],1,font_handle_);
+ if( tmp + tmp_x < offset_x ){
+ tmp += tmp_x;
+ ++cnt;
+ }
+ }
+ selecting_coursorpoint_ = std::make_pair<int,int>(prev_cursor_pos,cnt);
+ }
+ SetKeyInputSelectArea(selecting_coursorpoint_.first,selecting_coursorpoint_.second,input_handle_);
+ SetKeyInputCursorPosition(selecting_coursorpoint_.second,input_handle_);
+ drag_flag_ = true;
+ }
+ // マウス左ボタンが離され、且つ前回ドラッグされていた時
+ if (!push_mouse_left && prev_mouse_left && drag_flag_ ) {
+ drag_flag_ = false;
+ if( selecting_coursorpoint_.first == selecting_coursorpoint_.second ) {
+ SetKeyInputSelectArea( -1, -1, input_handle_ );
+ }else{
+ SetKeyInputSelectArea(selecting_coursorpoint_.first,selecting_coursorpoint_.second,input_handle_);
+ }
+ SetKeyInputCursorPosition(selecting_coursorpoint_.second,input_handle_);
+ }
+ }else{
+ if( push_mouse_left ){
+ rightmenu_show_ = false;
+ auto mpos = input->GetMousePos();
+ auto offset_x = mpos.first - (x_ + INPUT_MARGIN_X);
+ auto offset_y = mpos.second - (y_ + INPUT_MARGIN_Y);
+ // カレット変更
+ if( multiline_ ) {
+ auto line_num = offset_y / font_height_;
+ //if( ( offset_y % font_height_ ) != 0 )++line_num;
+ int tmp = 0,cnt = 0;
+ if( line_num < (int)lines_.size() && line_num >= 0 ){
+ for(int i = 0;i < line_num; ++i){
+ cnt += lines_[i].size();
+ }
+ for(int i = 0;i < lines_[line_num].size(); ++i){
+ auto tmp_x = GetDrawStringWidthToHandle(&lines_[line_num][i],1,font_handle_);
+ if( tmp + tmp_x < offset_x ){
+ tmp += tmp_x;
+ ++cnt;
+ }
+ }
+ SetKeyInputCursorPosition(line_num + cnt,input_handle_);
+ }
+ }else{
+ int tmp = 0,cnt = 0;
+ for(int i = 0;i < lines_[0].size(); ++i){
+ auto tmp_x = GetDrawStringWidthToHandle(&lines_[0][i],1,font_handle_);
+ if( tmp + tmp_x < offset_x ){
+ tmp += tmp_x;
+ ++cnt;
+ }
+ }
+ if( selecting_coursorpoint_.first = selecting_coursorpoint_.second ) {
+ SetKeyInputSelectArea( -1, -1, input_handle_ );
+ }else{
+ SetKeyInputSelectArea(selecting_coursorpoint_.first,selecting_coursorpoint_.second,input_handle_);
+ }
+ SetKeyInputCursorPosition(cnt,input_handle_);
+ }
+ }
+ }
+ // マウス右ボタンが押されたとき
+ if ( push_mouse_right && !prev_mouse_right ) {
+ if( x() <= input->GetMouseX() && input->GetMouseX() <= x() + width() &&
+ y() <= input->GetMouseY() && input->GetMouseY() <= y() + height()){
+ mouse_pos_ = input->GetMousePos();
+ if( mouse_pos_.second + right_click_list_.absolute_height() > config_manager_->screen_height()){
+ right_click_list_.set_top(mouse_pos_.second - right_click_list_.absolute_height());
+ if ( mouse_pos_.first + right_click_list_.absolute_width() > config_manager_->screen_width()){
+ right_click_list_.set_left(mouse_pos_.first - right_click_list_.absolute_width());
+ BOOST_FOREACH(auto it,right_click_list_.getItems()){
+ it->set_left(mouse_pos_.first - right_click_list_.absolute_width());
+ it->set_top(mouse_pos_.second - right_click_list_.absolute_height() + 12);
+ }
+ }else{
+ right_click_list_.set_left(mouse_pos_.first);
+ BOOST_FOREACH(auto it,right_click_list_.getItems()){
+ it->set_left(mouse_pos_.first);
+ it->set_top(mouse_pos_.second - right_click_list_.absolute_height() + 12);
+ }
+ }
+ }else{
+ right_click_list_.set_top(mouse_pos_.second);
+ if ( mouse_pos_.first + right_click_list_.absolute_width() > config_manager_->screen_width()){
+ right_click_list_.set_left(mouse_pos_.first - right_click_list_.absolute_width());
+ BOOST_FOREACH(auto it,right_click_list_.getItems()){
+ it->set_left(mouse_pos_.first - right_click_list_.absolute_width());
+ it->set_top(mouse_pos_.second + 12);
+ }
+ }else{
+ right_click_list_.set_left(mouse_pos_.first);
+ BOOST_FOREACH(auto it,right_click_list_.getItems()){
+ it->set_left(mouse_pos_.first);
+ it->set_top(mouse_pos_.second + 12);
+ }
+ }
+ }
+ rightmenu_show_ = true;
+ }
+ }
+
+ // カーソル位置(文字単位)を取得
cursor_byte_pos = GetKeyInputCursorPosition(input_handle_);
if (prev_cursor_pos_ != cursor_byte_pos) {
ResetCursorCount();
prev_cursor_pos_ = cursor_byte_pos;
+
// カーソルのドット単位の位置を取得する
cursor_dot_pos = GetDrawStringWidthToHandle(String, cursor_byte_pos,
font_handle_);
TCHAR c = *it;
int width = GetDrawStringWidthToHandle(&c, 1, font_handle_);
line_buffer += tstring(&c, 1);
+ char_count++;
#else
unsigned char c = *it;
TCHAR string[2] = { 0, 0 };
&& cursor_moveto_x_ <= line_width + width
&& static_cast<int>(lines_.size() + message_lines_.size()) * font_height_ <= cursor_moveto_y_
&& cursor_moveto_y_ <= (static_cast<int>(lines_.size() + message_lines_.size()) + 1) * font_height_) {
- SetKeyInputCursorPosition(prev_char_count, input_handle_);
+ SetKeyInputCursorPosition(char_count - 1, input_handle_);
cursor_moveto_x_ = -1;
cursor_moveto_y_ = -1;
}
on_enter_ = func;
}
+tstring Input::selecting_text() const
+{
+ int select_start = 0,select_end = 0;
+ GetKeyInputSelectArea(&select_start,&select_end,input_handle_);
+ if( select_start > select_end )std::swap(select_start,select_end);
+ tstring selecting_text;
+
+ if( select_start > -1 && select_end != select_start ) {
+ if ( multiline_ ) {
+ BOOST_FOREACH(auto it,lines_){
+ TCHAR c[2] = {0};
+ if( select_start > it.size() && select_start != -1 ) {
+ select_start -= it.size();
+ select_end -= it.size();
+ }else{
+ for(int i = select_start;i < select_end; ++i){
+ c[0] = it[i];
+ selecting_text += c;
+ }
+ select_start = -1;
+ }
+ }
+ }else{
+ BOOST_FOREACH(auto it,lines_){
+ TCHAR c[2] = {0};
+ for(int i = select_start;i < select_end; ++i){
+ c[0] = it[i];
+ selecting_text += c;
+ }
+ }
+ }
+ }
+ return selecting_text;
+}
+
+void Input::paste_text(tstring text)
+{
+ auto pos = GetKeyInputCursorPosition(input_handle_);
+ TCHAR String[TEXT_BUFFER_SIZE];
+ GetKeyInputString(String, input_handle_);
+ tstring dat(String, _tcslen(String));
+ dat.insert(pos,text);
+ SetKeyInputString(dat.c_str(), input_handle_);
+}
+
bool Input::reverse_color() const
{
return reverse_color_;
#include <functional>
#include "../ResourceManager.hpp"
#include "../InputManager.hpp"
+#include "../ConfigManager.hpp"
+#include "include.hpp"
+#include <boost/enable_shared_from_this.hpp>
-class Input {
+class Input{
typedef std::function<bool(const std::string&)> CallbackFunc;
public:
- Input();
+ Input(ConfigManagerPtr config_manager);
void Draw();
void Update();
void ProcessInput(InputManager* input);
+ void Init();
bool active();
void set_active(bool flag);
void set_on_enter(const CallbackFunc& func);
+ tstring selecting_text() const;
+ void paste_text(tstring text);
+
public:
void CancelSelect();
std::vector<std::pair<int, int>> selecting_lines_;
std::vector<std::pair<int, int>> clause_lines_;
std::vector<std::pair<int, int>> selecting_clause_lines_;
+ std::pair<int, int> selecting_coursorpoint_;
+ bool drag_flag_;
CallbackFunc on_enter_;
tstring message_;
bool reverse_color_;
int blink_count_;
+ bool rightmenu_show_;
+ std::pair<int, int> mouse_pos_;
+
+ UIList right_click_list_;
+
+ ConfigManagerPtr config_manager_;
private:
const static size_t TEXT_BUFFER_SIZE;
selecting_tab_index_(0),
manager_accessor_(manager_accessor),
card_(std::make_shared<Card>(manager_accessor_, "", "immo", "",
- std::vector<std::string>()))
+ std::vector<std::string>())),
+ input_(manager_accessor->config_manager().lock())
{
absolute_rect_ = Rect(100, 100, 800, 100);
return true;
});
+ input_.Init();
}
InputBox::~InputBox()
#include <DxLib.h>
#include <algorithm>
-UIBase::UIBase()
+UIBase::UIBase() :
+hover_flag_(false)
{
}
}
+void UIBase::Update()
+{
+};
+
+void UIBase::Draw()
+{
+ if(!children_.empty()){
+ DrawChildren();
+ }
+}
+
void UIBase::AsyncUpdate()
{
AsyncUpdateChildren();
parent_ = Persistent<Object>::New(parent);
}
+UIBasePtr UIBase::parent_c() const
+{
+ return parent_c_;
+}
+
+void UIBase::set_parent_c(const UIBasePtr& parent)
+{
+ parent_c_ = parent;
+}
+
+Input* UIBase::input_adpator() const
+{
+ return input_adaptor_;
+}
+
+void UIBase::set_input_adaptor(Input* adaptor)
+{
+ input_adaptor_ = adaptor;
+}
+
size_t UIBase::children_size() const
{
return children_.size();
#include "UISuper.hpp"
#include <v8.h>
#include "../InputManager.hpp"
+#include <functional>
using namespace v8;
typedef std::weak_ptr<ScriptEnvironment> ScriptEnvironmentWeakPtr;
class UIBase;
+class Input;
typedef std::shared_ptr<UIBase> UIBasePtr;
typedef std::weak_ptr<UIBase> UIBaseWeakPtr;
+typedef std::function<void(UIBase*)> CallbackFuncWithThisPointer;
class UIBase : public UISuper {
virtual ~UIBase();
virtual void ProcessInput(InputManager* input);
- virtual void Update() = 0;
- virtual void Draw() = 0;
+ virtual void Update();
+ virtual void Draw();
virtual void AsyncUpdate(); // 毎ループ実行する必要のない処理
/* function */
Handle<Object> parent() const;
void set_parent(const Handle<Object>& parent);
+ UIBasePtr parent_c() const;
+ void set_parent_c(const UIBasePtr &parent_c);
+ Input* input_adpator() const;
+ void set_input_adaptor(Input * adaptor);
size_t children_size() const;
void Focus();
+ public:
+ /* Property */
+ template<class F>
+ void set_on_click_function_(F function);
+ template<class F>
+ void set_on_hover_function_(F function);
+ template<class F>
+ void set_on_out_function_(F function);
+
protected:
Persistent<Object> parent_;
std::vector<Persistent<Object>> children_;
Persistent<Function> on_click_;
+ CallbackFuncWithThisPointer on_click_function_;
+ CallbackFuncWithThisPointer on_hover_function_;
+ CallbackFuncWithThisPointer on_out_function_;
+
+ bool hover_flag_;
+
+ /*C++からクラスを伝達するためのメンバ*/
+ UIBasePtr parent_c_;
+ Input* input_adaptor_;
};
Handle<ObjectTemplate>& instance_template = *object;
instance_template->Set(String::New(name.c_str()), value);
}
+
+template<class F>
+void UIBase::set_on_click_function_(F function)
+{
+ on_click_function_ = function;
+}
+
+template<class F>
+void UIBase::set_on_hover_function_(F function)
+{
+ on_hover_function_ = function;
+}
+
+template<class F>
+void UIBase::set_on_out_function_(F function)
+{
+ on_out_function_ = function;
+}
\ No newline at end of file
max_height_(800),
min_height_(100),
drag_offset_rect_(-1, -1, -1, -1),
- drag_resize_offset_rect_(-1, -1, -1, -1)
+ drag_resize_offset_rect_(-1, -1, -1, -1),
+ boardvisible_(true)
{
base_image_handle_ = ResourceManager::LoadCachedDivGraph<4>(
_T("system/images/gui/gui_board_bg.png"), 2, 2, 24, 24);
if (!visible_) {
return;
}
+
+ if (boardvisible_) {
+ SetDrawBlendMode(DX_BLENDMODE_ADD, 255);
- SetDrawBlendMode(DX_BLENDMODE_ADD, 255);
+ int x = absolute_x();
+ int y = absolute_y();
+ int width = absolute_width();
+ int height = absolute_height();
- int x = absolute_x();
- int y = absolute_y();
- int width = absolute_width();
- int height = absolute_height();
+ DrawGraph(x, y, *base_image_handle_[0], TRUE);
+ DrawGraph(x + width - BASE_BLOCK_SIZE, y, *base_image_handle_[1], TRUE);
+ DrawGraph(x, y + height - BASE_BLOCK_SIZE, *base_image_handle_[2], TRUE);
+ DrawGraph(x + width - BASE_BLOCK_SIZE, y + height - BASE_BLOCK_SIZE, *base_image_handle_[3], TRUE);
- DrawGraph(x, y, *base_image_handle_[0], TRUE);
- DrawGraph(x + width - BASE_BLOCK_SIZE, y, *base_image_handle_[1], TRUE);
- DrawGraph(x, y + height - BASE_BLOCK_SIZE, *base_image_handle_[2], TRUE);
- DrawGraph(x + width - BASE_BLOCK_SIZE, y + height - BASE_BLOCK_SIZE, *base_image_handle_[3], TRUE);
+ DrawRectExtendGraphF(x + BASE_BLOCK_SIZE, y,
+ x + width - BASE_BLOCK_SIZE, y + BASE_BLOCK_SIZE,
+ 0, 0, 1, BASE_BLOCK_SIZE, *base_image_handle_[1], TRUE);
- DrawRectExtendGraphF(x + BASE_BLOCK_SIZE, y,
- x + width - BASE_BLOCK_SIZE, y + BASE_BLOCK_SIZE,
- 0, 0, 1, BASE_BLOCK_SIZE, *base_image_handle_[1], TRUE);
+ DrawRectExtendGraphF(x + BASE_BLOCK_SIZE, y + height - BASE_BLOCK_SIZE,
+ x + width - BASE_BLOCK_SIZE, y + height,
+ 0, 0, 1, BASE_BLOCK_SIZE, *base_image_handle_[3], TRUE);
- DrawRectExtendGraphF(x + BASE_BLOCK_SIZE, y + height - BASE_BLOCK_SIZE,
- x + width - BASE_BLOCK_SIZE, y + height,
- 0, 0, 1, BASE_BLOCK_SIZE, *base_image_handle_[3], TRUE);
+ DrawRectExtendGraphF(x, y + BASE_BLOCK_SIZE,
+ x + BASE_BLOCK_SIZE, y + height - BASE_BLOCK_SIZE,
+ 0, 0, BASE_BLOCK_SIZE, 1, *base_image_handle_[2], TRUE);
- DrawRectExtendGraphF(x, y + BASE_BLOCK_SIZE,
- x + BASE_BLOCK_SIZE, y + height - BASE_BLOCK_SIZE,
- 0, 0, BASE_BLOCK_SIZE, 1, *base_image_handle_[2], TRUE);
+ DrawRectExtendGraphF(x + width - BASE_BLOCK_SIZE, y + BASE_BLOCK_SIZE,
+ x + width, y + height - BASE_BLOCK_SIZE,
+ 0, 0, BASE_BLOCK_SIZE, 1, *base_image_handle_[3], TRUE);
- DrawRectExtendGraphF(x + width - BASE_BLOCK_SIZE, y + BASE_BLOCK_SIZE,
- x + width, y + height - BASE_BLOCK_SIZE,
- 0, 0, BASE_BLOCK_SIZE, 1, *base_image_handle_[3], TRUE);
+ DrawRectExtendGraphF(x + BASE_BLOCK_SIZE, y + BASE_BLOCK_SIZE,
+ x + width - BASE_BLOCK_SIZE, y + height - BASE_BLOCK_SIZE,
+ 0, 0, 1, 1, *base_image_handle_[3], TRUE);
- DrawRectExtendGraphF(x + BASE_BLOCK_SIZE, y + BASE_BLOCK_SIZE,
- x + width - BASE_BLOCK_SIZE, y + height - BASE_BLOCK_SIZE,
- 0, 0, 1, 1, *base_image_handle_[3], TRUE);
-
- SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0);
+ SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0);
+ }
DrawChildren();
}
return resizable_;
}
+bool UIBoard::boardvisible() const
+{
+ return boardvisible_;
+}
+
+void UIBoard::set_boardvisible(bool visible)
+{
+ boardvisible_ = visible;
+}
+
void UIBoard::set_resizable(bool resizable)
{
resizable_ = resizable;
void Draw();
bool resizable() const;
+ bool boardvisible() const;
void set_resizable(bool resizable);
+ void set_boardvisible(bool visible);
public:
static void DefineInstanceTemplate(Handle<ObjectTemplate>* object);
std::array<ImageHandlePtr,4> base_image_handle_;
bool resizable_;
+ bool boardvisible_;
int max_width_, min_width_;
int max_height_, min_height_;
private:
const static int BASE_BLOCK_SIZE;
};
+
+typedef std::shared_ptr<UIBoard> UIBoardPtr;
\ No newline at end of file
SetProperty(object, "_update", Property_update, Property_set_update);
SetProperty(object, "_draw", Property_draw, Property_set_draw);
- SetFunction(object, "drawLine", Function_drawLine);
+ SetFunction(object, "DrawLine", Function_DrawLine);
+ SetFunction(object, "DrawBox", Function_DrawBox);
}
void UICustom::ProcessInput(InputManager* input)
}
}
-Handle<Value> UICustom::Function_drawLine(const Arguments& args)
+
+Handle<Value> UICustom::Function_DrawLine(const Arguments& args)
+{
+ assert(args.This()->InternalFieldCount() > 0);
+ auto self = std::dynamic_pointer_cast<UICustom>(
+ *static_cast<UIBasePtr*>(args.This()->GetPointerFromInternalField(0))
+ );
+ assert(self);
+ if( args[0]->IsInt32() &&
+ args[1]->IsInt32() &&
+ args[2]->IsInt32() &&
+ args[3]->IsInt32() &&
+ args[4]->IsInt32() &&
+ args[5]->IsInt32() &&
+ args[6]->IsInt32() )
+ {
+ auto x0 = args[0]->Int32Value();
+ auto y0 = args[1]->Int32Value();
+ auto x1 = args[2]->Int32Value();
+ auto y1 = args[3]->Int32Value();
+ auto r = args[4]->Int32Value();
+ auto g = args[5]->Int32Value();
+ auto b = args[6]->Int32Value();
+
+ if( args[7]->IsInt32() )
+ {
+ auto t = args[7]->Int32Value();
+ DrawLine(x0, y0, x1, y1, GetColor(r, g, b),t);
+ }else{
+ DrawLine(x0, y0, x1, y1, GetColor(r, g, b));
+ }
+
+ }
+
+ return Undefined();
+}
+
+Handle<Value> UICustom::Function_DrawBox(const Arguments& args)
+{
+ assert(args.This()->InternalFieldCount() > 0);
+ auto self = std::dynamic_pointer_cast<UICustom>(
+ *static_cast<UIBasePtr*>(args.This()->GetPointerFromInternalField(0))
+ );
+ assert(self);
+ if( args[0]->IsInt32() &&
+ args[1]->IsInt32() &&
+ args[2]->IsInt32() &&
+ args[3]->IsInt32() &&
+ args[4]->IsInt32() &&
+ args[5]->IsInt32() &&
+ args[6]->IsInt32() )
+ {
+ auto x0 = args[0]->Int32Value();
+ auto y0 = args[1]->Int32Value();
+ auto x1 = args[2]->Int32Value();
+ auto y1 = args[3]->Int32Value();
+ auto r = args[4]->Int32Value();
+ auto g = args[5]->Int32Value();
+ auto b = args[6]->Int32Value();
+
+ if( args[7]->IsBoolean() )
+ {
+ auto fillflag = args[7]->BooleanValue();
+ DrawBox(x0, y0, x1, y1, GetColor(r, g, b),fillflag ? 1 : 0);
+ }else{
+ DrawBox(x0, y0, x1, y1, GetColor(r, g, b),1);
+ }
+ }
+
+ return Undefined();
+}
+
+Handle<Value> UICustom::Function_DrawEdgeBox(const Arguments& args)
+{
+ assert(args.This()->InternalFieldCount() > 0);
+ auto self = std::dynamic_pointer_cast<UICustom>(
+ *static_cast<UIBasePtr*>(args.This()->GetPointerFromInternalField(0))
+ );
+ assert(self);
+ if( args[0]->IsInt32() &&
+ args[1]->IsInt32() &&
+ args[2]->IsInt32() &&
+ args[3]->IsInt32() &&
+ args[4]->IsInt32() &&
+ args[5]->IsInt32() &&
+ args[6]->IsInt32() )
+ {
+ auto x0 = args[0]->Int32Value();
+ auto y0 = args[1]->Int32Value();
+ auto x1 = args[2]->Int32Value();
+ auto y1 = args[3]->Int32Value();
+ auto r = args[4]->Int32Value();
+ auto g = args[5]->Int32Value();
+ auto b = args[6]->Int32Value();
+
+ auto DrawOfOnlyEdge = [](int x, int y, int width, int height, int Color, int thickness)
+ {
+ DrawBox( x, y, x + width, y + thickness, Color, TRUE);
+ DrawBox( x, y, x + thickness, y + height, Color, TRUE);
+ DrawBox( x + width - thickness, y, x + width, y + height, Color, TRUE);
+ DrawBox( x, y + height - thickness, x + width, y + height, Color, TRUE);
+ };// thickness\82Å\8e¦\82µ\82½\91¾\82³\82Å\89\8f\82Ì\82Ý\82Ì\8el\8ap\8c`\82ð\95`\89æ
+
+ if( args[7]->IsInt32() )
+ {
+ auto t = args[7]->Int32Value();
+ if( args[8]->IsBoolean() )
+ {
+ auto fillflag = args[8]->BooleanValue();
+ DrawOfOnlyEdge(x0 - t, y0 - t, x1 + t, y1 + t, GetColor(r, g, b),t);
+ DrawBox(x0, y0, x1, y1, GetColor(r, g, b),fillflag ? 1 : 0);
+ }else{
+ DrawOfOnlyEdge(x0 - t, y0 - t, x1 + t, y1 + t, GetColor(r, g, b),t);
+ }
+ }else{
+ DrawOfOnlyEdge(x0 - 1, y0 - 1, x1 + 1, y1 + 1, GetColor(r, g, b),1);
+ }
+
+ }
+
+ return Undefined();
+}
+
+Handle<Value> UICustom::Function_DrawCircle(const Arguments& args)
+{
+ assert(args.This()->InternalFieldCount() > 0);
+ auto self = std::dynamic_pointer_cast<UICustom>(
+ *static_cast<UIBasePtr*>(args.This()->GetPointerFromInternalField(0))
+ );
+ assert(self);
+ if( args[0]->IsInt32() &&
+ args[1]->IsInt32() &&
+ args[2]->IsInt32() &&
+ args[3]->IsInt32() &&
+ args[4]->IsInt32() &&
+ args[5]->IsInt32() )
+ {
+ auto x0 = args[0]->Int32Value();
+ auto y0 = args[1]->Int32Value();
+ auto r0 = args[2]->Int32Value();
+ auto r = args[3]->Int32Value();
+ auto g = args[4]->Int32Value();
+ auto b = args[5]->Int32Value();
+
+ if( args[6]->IsBoolean() )
+ {
+ auto fillflag = args[6]->BooleanValue();
+ DrawCircle(x0, y0, r0, GetColor(r, g, b),fillflag ? 1 : 0);
+ }else{
+ DrawCircle(x0, y0, r0, GetColor(r, g, b),1);
+ }
+ }
+
+ return Undefined();
+}
+
+Handle<Value> UICustom::Function_DrawOval(const Arguments& args)
+{
+ assert(args.This()->InternalFieldCount() > 0);
+ auto self = std::dynamic_pointer_cast<UICustom>(
+ *static_cast<UIBasePtr*>(args.This()->GetPointerFromInternalField(0))
+ );
+ assert(self);
+ if( args[0]->IsInt32() &&
+ args[1]->IsInt32() &&
+ args[2]->IsInt32() &&
+ args[3]->IsInt32() &&
+ args[4]->IsInt32() &&
+ args[5]->IsInt32() &&
+ args[6]->IsInt32() )
+ {
+ auto x0 = args[0]->Int32Value();
+ auto y0 = args[1]->Int32Value();
+ auto rx = args[2]->Int32Value();
+ auto ry = args[3]->Int32Value();
+ auto r = args[4]->Int32Value();
+ auto g = args[5]->Int32Value();
+ auto b = args[6]->Int32Value();
+
+ if( args[7]->IsBoolean() )
+ {
+ auto fillflag = args[7]->BooleanValue();
+ DrawOval(x0, y0, rx, ry, GetColor(r, g, b),fillflag ? 1 : 0);
+ }else{
+ DrawOval(x0, y0, rx, ry, GetColor(r, g, b),1);
+ }
+
+ }
+
+ return Undefined();
+}
+
+Handle<Value> UICustom::Function_DrawTriangle(const Arguments& args)
+{
+ assert(args.This()->InternalFieldCount() > 0);
+ auto self = std::dynamic_pointer_cast<UICustom>(
+ *static_cast<UIBasePtr*>(args.This()->GetPointerFromInternalField(0))
+ );
+ assert(self);
+ if( args[0]->IsInt32() &&
+ args[1]->IsInt32() &&
+ args[2]->IsInt32() &&
+ args[3]->IsInt32() &&
+ args[4]->IsInt32() &&
+ args[5]->IsInt32() &&
+ args[6]->IsInt32() &&
+ args[7]->IsInt32() &&
+ args[8]->IsInt32() )
+ {
+ auto x0 = args[0]->Int32Value();
+ auto y0 = args[1]->Int32Value();
+ auto x1 = args[2]->Int32Value();
+ auto y1 = args[3]->Int32Value();
+ auto x2 = args[4]->Int32Value();
+ auto y2 = args[5]->Int32Value();
+ auto r = args[6]->Int32Value();
+ auto g = args[7]->Int32Value();
+ auto b = args[8]->Int32Value();
+
+ if( args[9]->IsBoolean() )
+ {
+ auto fillflag = args[9]->BooleanValue();
+ DrawTriangle(x0, y0, x1, y1, x2, y2, GetColor(r, g, b),fillflag ? 1 : 0);
+ }else{
+ DrawTriangle(x0, y0, x1, y1, x2, y2, GetColor(r, g, b),1);
+ }
+
+ }
+
+ return Undefined();
+}
+
+Handle<Value> UICustom::Function_DrawQuadrangle(const Arguments& args)
+{
+ assert(args.This()->InternalFieldCount() > 0);
+ auto self = std::dynamic_pointer_cast<UICustom>(
+ *static_cast<UIBasePtr*>(args.This()->GetPointerFromInternalField(0))
+ );
+ assert(self);
+ if( args[0]->IsInt32() &&
+ args[1]->IsInt32() &&
+ args[2]->IsInt32() &&
+ args[3]->IsInt32() &&
+ args[4]->IsInt32() &&
+ args[5]->IsInt32() &&
+ args[6]->IsInt32() &&
+ args[7]->IsInt32() &&
+ args[8]->IsInt32() )
+ {
+ auto x0 = args[0]->Int32Value();
+ auto y0 = args[1]->Int32Value();
+ auto x1 = args[2]->Int32Value();
+ auto y1 = args[3]->Int32Value();
+ auto x2 = args[4]->Int32Value();
+ auto y2 = args[5]->Int32Value();
+ auto x3 = args[6]->Int32Value();
+ auto y3 = args[7]->Int32Value();
+ auto r = args[8]->Int32Value();
+ auto g = args[9]->Int32Value();
+ auto b = args[10]->Int32Value();
+
+ if( args[11]->IsBoolean() )
+ {
+ auto fillflag = args[9]->BooleanValue();
+ DrawQuadrangle(x0, y0, x1, y1, x2, y2, x3, y3, GetColor(r, g, b),fillflag ? 1 : 0);
+ }else{
+ DrawQuadrangle(x0, y0, x1, y1, x2, y2, x3, y3, GetColor(r, g, b),1);
+ }
+
+ }
+
+ return Undefined();
+}
+
+Handle<Value> UICustom::Function_DrawPixel(const Arguments& args)
{
assert(args.This()->InternalFieldCount() > 0);
auto self = std::dynamic_pointer_cast<UICustom>(
*static_cast<UIBasePtr*>(args.This()->GetPointerFromInternalField(0))
);
assert(self);
+ if( args[0]->IsInt32() &&
+ args[1]->IsInt32() &&
+ args[2]->IsInt32() &&
+ args[3]->IsInt32() &&
+ args[4]->IsInt32() )
+ {
+ auto x0 = args[0]->Int32Value();
+ auto y0 = args[1]->Int32Value();
+ auto r = args[2]->Int32Value();
+ auto g = args[3]->Int32Value();
+ auto b = args[4]->Int32Value();
+
+ DrawPixel(x0, y0, GetColor(r, g, b));
- DrawLine(100, 100, 200, 200, GetColor(255,255,255));
+ }
return Undefined();
}
+Handle<Value> UICustom::Function_Paint(const Arguments& args)
+{
+ assert(args.This()->InternalFieldCount() > 0);
+ auto self = std::dynamic_pointer_cast<UICustom>(
+ *static_cast<UIBasePtr*>(args.This()->GetPointerFromInternalField(0))
+ );
+ assert(self);
+ if( args[0]->IsInt32() &&
+ args[1]->IsInt32() &&
+ args[2]->IsInt32() &&
+ args[3]->IsInt32() &&
+ args[4]->IsInt32() )
+ {
+ auto x0 = args[0]->Int32Value();
+ auto y0 = args[1]->Int32Value();
+ auto r0 = args[2]->Int32Value();
+ auto g0 = args[3]->Int32Value();
+ auto b0 = args[4]->Int32Value();
+ if( args[5]->IsInt32() &&
+ args[6]->IsInt32() &&
+ args[7]->IsInt32() )
+ {
+ auto r1 = args[5]->Int32Value();
+ auto g1 = args[6]->Int32Value();
+ auto b1 = args[7]->Int32Value();
+ Paint(x0, y0, GetColor(r0, g0, b0), GetColor(r1, g1, b1));
+ }else{
+ Paint(x0, y0, GetColor(r0, g0, b0));
+ }
+
+ }
+
+ return Undefined();
+}
+
+Handle<Value> UICustom::Function_DrawPixelSet(const Arguments& args)
+{
+ assert(args.This()->InternalFieldCount() > 0);
+ auto self = std::dynamic_pointer_cast<UICustom>(
+ *static_cast<UIBasePtr*>(args.This()->GetPointerFromInternalField(0))
+ );
+ assert(self);
+ if( args[0]->IsArray() )
+ {
+ auto array = Local<Array>::Cast(args[0]);
+ auto length = array->Length();
+ auto data = static_cast<POINTDATA*>(array->GetPointerFromInternalField(0));
+
+ DrawPixelSet(data,length);
+ }
+
+ return Undefined();
+}
+
+Handle<Value> UICustom::Function_DrawLineSet(const Arguments& args)
+{
+ assert(args.This()->InternalFieldCount() > 0);
+ auto self = std::dynamic_pointer_cast<UICustom>(
+ *static_cast<UIBasePtr*>(args.This()->GetPointerFromInternalField(0))
+ );
+ assert(self);
+ if( args[0]->IsArray() )
+ {
+ auto array = Local<Array>::Cast(args[0]);
+ auto length = array->Length();
+ auto data = static_cast<LINEDATA*>(array->GetPointerFromInternalField(0));
+
+ DrawLineSet(data,length);
+ }
+
+ return Undefined();
+}
+
+Handle<Value> UICustom::Function_DrawPixel3D(const Arguments& args)
+{
+ assert(args.This()->InternalFieldCount() > 0);
+ auto self = std::dynamic_pointer_cast<UICustom>(
+ *static_cast<UIBasePtr*>(args.This()->GetPointerFromInternalField(0))
+ );
+ assert(self);
+ if( args[0]->IsInt32() &&
+ args[1]->IsInt32() &&
+ args[2]->IsInt32() &&
+ args[3]->IsInt32() &&
+ args[4]->IsInt32() &&
+ args[5]->IsInt32() )
+ {
+ auto x0 = args[0]->Int32Value();
+ auto y0 = args[1]->Int32Value();
+ auto z0 = args[2]->Int32Value();
+ auto r = args[3]->Int32Value();
+ auto g = args[4]->Int32Value();
+ auto b = args[5]->Int32Value();
+
+ DrawPixel3D(VGet(x0, y0, z0), GetColor(r, g, b));
+
+ }
+
+ return Undefined();
+}
+
+Handle<Value> UICustom::Function_DrawLine3D(const Arguments& args)
+{
+ assert(args.This()->InternalFieldCount() > 0);
+ auto self = std::dynamic_pointer_cast<UICustom>(
+ *static_cast<UIBasePtr*>(args.This()->GetPointerFromInternalField(0))
+ );
+ assert(self);
+ if( args[0]->IsInt32() &&
+ args[1]->IsInt32() &&
+ args[2]->IsInt32() &&
+ args[3]->IsInt32() &&
+ args[4]->IsInt32() &&
+ args[5]->IsInt32() &&
+ args[6]->IsInt32() &&
+ args[7]->IsInt32() &&
+ args[8]->IsInt32() )
+ {
+ auto x0 = args[0]->Int32Value();
+ auto y0 = args[1]->Int32Value();
+ auto z0 = args[2]->Int32Value();
+ auto x1 = args[3]->Int32Value();
+ auto y1 = args[4]->Int32Value();
+ auto z1 = args[5]->Int32Value();
+ auto r = args[6]->Int32Value();
+ auto g = args[7]->Int32Value();
+ auto b = args[8]->Int32Value();
+
+ DrawLine3D(VGet(x0, y0, z0), VGet(x1, y1, z1), GetColor(r, g, b));
+
+ }
+
+ return Undefined();
+}
+
+Handle<Value> UICustom::Function_DrawCube3D(const Arguments& args)
+{
+ assert(args.This()->InternalFieldCount() > 0);
+ auto self = std::dynamic_pointer_cast<UICustom>(
+ *static_cast<UIBasePtr*>(args.This()->GetPointerFromInternalField(0))
+ );
+ assert(self);
+ if( args[0]->IsInt32() &&
+ args[1]->IsInt32() &&
+ args[2]->IsInt32() &&
+ args[3]->IsInt32() &&
+ args[4]->IsInt32() &&
+ args[5]->IsInt32() &&
+ args[6]->IsInt32() &&
+ args[7]->IsInt32() &&
+ args[8]->IsInt32() &&
+ args[9]->IsInt32() &&
+ args[10]->IsInt32() &&
+ args[11]->IsInt32() )
+ {
+ auto x0 = args[0]->Int32Value();
+ auto y0 = args[1]->Int32Value();
+ auto z0 = args[2]->Int32Value();
+ auto x1 = args[3]->Int32Value();
+ auto y1 = args[4]->Int32Value();
+ auto z1 = args[5]->Int32Value();
+ auto dr = args[6]->Int32Value();
+ auto dg = args[7]->Int32Value();
+ auto db = args[8]->Int32Value();
+ auto sr = args[9]->Int32Value();
+ auto sg = args[10]->Int32Value();
+ auto sb = args[11]->Int32Value();
+
+ if( args[12]->IsBoolean() )
+ {
+ auto fillflag = args[9]->BooleanValue();
+ DrawCube3D(VGet(x0, y0, z0), VGet(x1, y1, z1), GetColor(dr, dg, db), GetColor(sr, sg, db), fillflag ? 1 : 0);
+ }else{
+ DrawCube3D(VGet(x0, y0, z0), VGet(x1, y1, z1), GetColor(dr, dg, db), GetColor(sr, sg, db), 1);
+ }
+
+ }
+
+ return Undefined();
+}
+
+Handle<Value> UICustom::Function_DrawSphere3D(const Arguments& args)
+{
+ assert(args.This()->InternalFieldCount() > 0);
+ auto self = std::dynamic_pointer_cast<UICustom>(
+ *static_cast<UIBasePtr*>(args.This()->GetPointerFromInternalField(0))
+ );
+ assert(self);
+ if( args[0]->IsInt32() &&
+ args[1]->IsInt32() &&
+ args[2]->IsInt32() &&
+ args[3]->IsInt32() &&
+ args[4]->IsInt32() &&
+ args[5]->IsInt32() &&
+ args[6]->IsInt32() &&
+ args[7]->IsInt32() &&
+ args[8]->IsInt32() &&
+ args[9]->IsInt32() &&
+ args[10]->IsInt32() )
+ {
+ auto x0 = args[0]->Int32Value();
+ auto y0 = args[1]->Int32Value();
+ auto z0 = args[2]->Int32Value();
+ auto r = args[3]->Int32Value();
+ auto divnum = args[4]->Int32Value();
+ auto dr = args[5]->Int32Value();
+ auto dg = args[6]->Int32Value();
+ auto db = args[7]->Int32Value();
+ auto sr = args[8]->Int32Value();
+ auto sg = args[9]->Int32Value();
+ auto sb = args[10]->Int32Value();
+
+ if( args[11]->IsBoolean() )
+ {
+ auto fillflag = args[9]->BooleanValue();
+ DrawSphere3D(VGet(x0, y0, z0), r, divnum, GetColor(dr, dg, db), GetColor(sr, sg, db), fillflag ? 1 : 0);
+ }else{
+ DrawSphere3D(VGet(x0, y0, z0), r, divnum, GetColor(dr, dg, db), GetColor(sr, sg, db), 1);
+ }
+
+ }
+
+ return Undefined();
+}
static void Property_set_draw(Local<String> property, Local<Value> value, const AccessorInfo& info);
private:
- static Handle<Value> Function_drawLine(const Arguments& args);
+ /* function */
+ static Handle<Value> Function_DrawLine(const Arguments& args);
+ static Handle<Value> Function_DrawBox(const Arguments& args);
+ static Handle<Value> Function_DrawEdgeBox(const Arguments& args);
+ static Handle<Value> Function_DrawCircle(const Arguments& args);
+ static Handle<Value> Function_DrawOval(const Arguments& args);
+ static Handle<Value> Function_DrawTriangle(const Arguments& args);
+ static Handle<Value> Function_DrawQuadrangle(const Arguments& args);
+ static Handle<Value> Function_DrawPixel(const Arguments& args);
+ static Handle<Value> Function_Paint(const Arguments& args);
+ static Handle<Value> Function_DrawPixelSet(const Arguments& args);
+ static Handle<Value> Function_DrawLineSet(const Arguments& args);
+ static Handle<Value> Function_DrawPixel3D(const Arguments& args);
+ static Handle<Value> Function_DrawLine3D(const Arguments& args);
+ static Handle<Value> Function_DrawCube3D(const Arguments& args);
+ static Handle<Value> Function_DrawSphere3D(const Arguments& args);
+ static Handle<Value> Function_DrawCapsule3D(const Arguments& args);
+ static Handle<Value> Function_DrawCone3D(const Arguments& args);
+
+ static Handle<Value> Function_LoadGraph(const Arguments& args);
};
if (input->GetMouseLeftCount() == 1 && hover) {
if (!on_click_.IsEmpty() && on_click_->IsFunction()) {
on_click_.As<Function>()->CallAsFunction(Context::GetCurrent()->Global(), 0, nullptr);
+ }else if(!on_click_function_._Empty()) {
+ on_click_function_(this);
+ input->CancelMouseLeft();
+ }
+ }else if(hover && !hover_flag_){
+ if(!on_hover_function_._Empty()) {
+ on_hover_function_(this);
+ hover_flag_ = true;
+ }
+ }else if(!hover && hover_flag_){
+ if(!on_out_function_._Empty()) {
+ on_out_function_(this);
+ hover_flag_ = false;
}
}
}
}
+void UIList::addItem(UIBasePtr item)
+{
+ item->set_parent_c(UIBasePtr(new UIList(*this)));
+ items_.push_back(item);
+}
+
+void UIList::removeItem(UIBasePtr item)
+{
+ auto it = std::find(items_.begin(), items_.end(), item);
+ if (it != items_.end()) {
+ UIBasePtr chid_ptr = *it;
+ chid_ptr->set_parent_c(nullptr);
+ items_.erase(it);
+ }
+}
+
+void UIList::clearItems()
+{
+ BOOST_FOREACH(auto it, items_) {
+ UIBasePtr chid_ptr = it;
+ chid_ptr->set_parent_c(nullptr);
+ }
+ items_.clear();
+}
+
+std::vector<UIBasePtr> UIList::getItems() const
+{
+ return items_;
+}
+
+void UIList::set_scroll_y(int scroll_y)
+{
+ scroll_y_ = scroll_y;
+}
+
void UIList::UpdateScrollBar(InputManager* input)
{
int screen_width, screen_height;
void Draw();
public:
- static void DefineInstanceTemplate(Handle<ObjectTemplate>* object);
+ static void DefineInstanceTemplate(Handle<ObjectTemplate>* object);
private:
/* function */
static Handle<Value> Property_scroll_y(Local<String> property, const AccessorInfo &info);
static void Property_set_scroll_y(Local<String> property, Local<Value> value, const AccessorInfo& info);
+ public:
+ /* function */
+ void addItem(UIBasePtr item);
+ void removeItem(UIBasePtr item);
+ void clearItems();
+ std::vector<UIBasePtr> getItems() const;
+
+ /* property */
+ void set_scroll_y(int scroll_y);
+
private:
std::array<ImageHandlePtr,4> scrollbar_base_image_handle_;