修訂 | 1e85aac7ee6028dd809d80527c0172308414f33f (tree) |
---|---|
時間 | 2012-09-11 00:05:07 |
作者 | h2so5 <h2so5@git....> |
Commiter | h2so5 |
InputBoxの改行まわりの不具合を修正
単一行Inputに対応
@@ -20,6 +20,7 @@ const int Input::IME_MAX_PAGE_SIZE = 6; | ||
20 | 20 | const int Input::IME_MIN_WIDTH = 120; |
21 | 21 | |
22 | 22 | Input::Input() : |
23 | + multiline_(true), | |
23 | 24 | reverse_color_(false) |
24 | 25 | { |
25 | 26 | input_bg_image_handle_ = ResourceManager::LoadCachedDivGraph<4>( |
@@ -38,6 +39,7 @@ Input::Input() : | ||
38 | 39 | candidate_x_ = -1; |
39 | 40 | candidate_y_ = -1; |
40 | 41 | blink_count_ = 0; |
42 | + prev_cursor_pos_ = -1; | |
41 | 43 | |
42 | 44 | x_ = 100; |
43 | 45 | y_ = 100; |
@@ -91,22 +93,22 @@ void Input::Draw() | ||
91 | 93 | // int internal_height = height_ - INPUT_MARGIN * 2; |
92 | 94 | |
93 | 95 | // 選択範囲の背景を描画 |
94 | - int current_line = 0; | |
95 | - for (auto it = selecting_lines_.begin(); it != selecting_lines_.end(); ++it) { | |
96 | - auto line = *it; | |
97 | - if (line.first < line.second) { | |
98 | - SetDrawBlendMode(DX_BLENDMODE_ALPHA, 100); | |
99 | - DrawBox(internal_x + line.first, | |
100 | - internal_y + current_line * font_height_, | |
101 | - internal_x + line.second, | |
102 | - internal_y + (current_line + 1) * font_height_, | |
103 | - GetColor(255, 0, 255), TRUE); | |
104 | - SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0); | |
105 | - } | |
106 | - current_line++; | |
107 | - } | |
108 | - | |
109 | - current_line = 0; | |
96 | + //int current_line = 0; | |
97 | + //for (auto it = selecting_lines_.begin(); it != selecting_lines_.end(); ++it) { | |
98 | + // auto line = *it; | |
99 | + // if (line.first < line.second) { | |
100 | + // SetDrawBlendMode(DX_BLENDMODE_ALPHA, 100); | |
101 | + // DrawBox(internal_x + line.first, | |
102 | + // internal_y + current_line * font_height_, | |
103 | + // internal_x + line.second, | |
104 | + // internal_y + (current_line + 1) * font_height_, | |
105 | + // GetColor(255, 0, 255), TRUE); | |
106 | + // SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0); | |
107 | + // } | |
108 | + // current_line++; | |
109 | + //} | |
110 | + | |
111 | + int current_line = 0; | |
110 | 112 | for (auto it = clause_lines_.begin(); it != clause_lines_.end(); ++it) { |
111 | 113 | auto line = *it; |
112 | 114 | if (line.first < line.second) { |
@@ -260,8 +262,7 @@ void Input::Draw() | ||
260 | 262 | |
261 | 263 | void Input::Update() |
262 | 264 | { |
263 | - blink_count_ += 1; | |
264 | - blink_count_ %= 60; | |
265 | + blink_count_ = (blink_count_ + 1) % 60; | |
265 | 266 | } |
266 | 267 | |
267 | 268 | void Input::ProcessInput(InputManager* input) |
@@ -281,7 +282,8 @@ void Input::ProcessInput(InputManager* input) | ||
281 | 282 | bool push_key_v = (input->GetKeyCount(KEY_INPUT_V) > 0); |
282 | 283 | bool push_key_ctrl = (input->GetKeyCount(KEY_INPUT_LCONTROL) > 0 |
283 | 284 | || input->GetKeyCount(KEY_INPUT_RCONTROL) > 0); |
284 | - | |
285 | + | |
286 | + bool push_key_return = (input->GetKeyCount(KEY_INPUT_RETURN) > 0); | |
285 | 287 | bool first_key_return = (input->GetKeyCount(KEY_INPUT_RETURN) == 1); |
286 | 288 | |
287 | 289 | bool push_repeat_key_return = (input->GetKeyCount(KEY_INPUT_RETURN) |
@@ -296,7 +298,7 @@ void Input::ProcessInput(InputManager* input) | ||
296 | 298 | if (!active() && push_key_v && push_key_ctrl) { |
297 | 299 | set_active(true); |
298 | 300 | } else { |
299 | - if (push_key_shift && first_key_return) { | |
301 | + if (push_key_shift && push_key_return) { | |
300 | 302 | SetActiveKeyInput(input_handle_); |
301 | 303 | } else if (first_key_return) { |
302 | 304 | if (CheckKeyInput(input_handle_) == 1) { |
@@ -364,6 +366,7 @@ void Input::ProcessInput(InputManager* input) | ||
364 | 366 | TCHAR c = *it; |
365 | 367 | int width = GetDrawStringWidthToHandle(&c, 1, font_handle_); |
366 | 368 | line_buffer += c; |
369 | + char_count++; | |
367 | 370 | #else |
368 | 371 | unsigned char c = *it; |
369 | 372 | TCHAR string[2] = { 0, 0 }; |
@@ -406,6 +409,11 @@ void Input::ProcessInput(InputManager* input) | ||
406 | 409 | if (active()) { |
407 | 410 | // カーソル位置(byte)を取得 |
408 | 411 | cursor_byte_pos = GetKeyInputCursorPosition(input_handle_); |
412 | + if (prev_cursor_pos_ != cursor_byte_pos) { | |
413 | + ResetCursorCount(); | |
414 | + } | |
415 | + | |
416 | + prev_cursor_pos_ = cursor_byte_pos; | |
409 | 417 | |
410 | 418 | // カーソルのドット単位の位置を取得する |
411 | 419 | cursor_dot_pos = GetDrawStringWidthToHandle(String, cursor_byte_pos, |
@@ -471,6 +479,7 @@ void Input::ProcessInput(InputManager* input) | ||
471 | 479 | TCHAR c = *it; |
472 | 480 | int width = GetDrawStringWidthToHandle(&c, 1, font_handle_); |
473 | 481 | line_buffer += c; |
482 | + char_count++; | |
474 | 483 | #else |
475 | 484 | unsigned char c = *it; |
476 | 485 | TCHAR string[2] = { 0, 0 }; |
@@ -552,6 +561,7 @@ void Input::ProcessInput(InputManager* input) | ||
552 | 561 | TCHAR c = *it; |
553 | 562 | int width = GetDrawStringWidthToHandle(&c, 1, font_handle_); |
554 | 563 | line_buffer += tstring(&c, 1); |
564 | + char_count++; | |
555 | 565 | #else |
556 | 566 | unsigned char c = *it; |
557 | 567 | TCHAR string[2] = { 0, 0 }; |
@@ -696,10 +706,10 @@ void Input::ProcessInput(InputManager* input) | ||
696 | 706 | line_buffer.clear(); |
697 | 707 | line_width = 0; |
698 | 708 | |
699 | - if (push_key_shift && (push_repeat_key_up || push_repeat_key_down)) { | |
700 | - SetKeyInputSelectArea(GetKeyInputCursorPosition(input_handle_), | |
701 | - prev_cursor_pos_, input_handle_); | |
702 | - } | |
709 | + //if (push_key_shift && (push_repeat_key_up || push_repeat_key_down)) { | |
710 | + // SetKeyInputSelectArea(GetKeyInputCursorPosition(input_handle_), | |
711 | + // prev_cursor_pos_, input_handle_); | |
712 | + //} | |
703 | 713 | |
704 | 714 | } |
705 | 715 |
@@ -732,7 +742,7 @@ void Input::ResetCursorCount() | ||
732 | 742 | void Input::CancelSelect() |
733 | 743 | { |
734 | 744 | int pos = GetKeyInputCursorPosition(input_handle_); |
735 | - prev_cursor_pos_ = pos; | |
745 | + // prev_cursor_pos_ = pos; | |
736 | 746 | SetKeyInputSelectArea(-1, -1, input_handle_); |
737 | 747 | } |
738 | 748 |
@@ -811,4 +821,14 @@ bool Input::reverse_color() const | ||
811 | 821 | void Input::set_reverse_color(bool flag) |
812 | 822 | { |
813 | 823 | reverse_color_ = flag; |
824 | +} | |
825 | + | |
826 | +bool Input::multiline() const | |
827 | +{ | |
828 | + return multiline_; | |
829 | +} | |
830 | + | |
831 | +void Input::set_multiline(bool flag) | |
832 | +{ | |
833 | + multiline_ = flag; | |
814 | 834 | } |
\ No newline at end of file |
@@ -40,6 +40,9 @@ class Input { | ||
40 | 40 | bool reverse_color() const; |
41 | 41 | void set_reverse_color(bool flag); |
42 | 42 | |
43 | + bool multiline() const; | |
44 | + void set_multiline(bool flag); | |
45 | + | |
43 | 46 | void set_on_enter(const CallbackFunc& func); |
44 | 47 | |
45 | 48 | public: |
@@ -65,7 +68,7 @@ class Input { | ||
65 | 68 | int selecting_candidate_, selecting_clause_; |
66 | 69 | int cursor_moveto_x_, cursor_moveto_y_; |
67 | 70 | int prev_cursor_pos_, cursor_drag_count_; |
68 | - int multiline_; | |
71 | + bool multiline_; | |
69 | 72 | |
70 | 73 | std::vector<std::pair<int, int>> selecting_lines_; |
71 | 74 | std::vector<std::pair<int, int>> clause_lines_; |
@@ -343,7 +343,7 @@ void InputBox::ProcessInput(InputManager* input) | ||
343 | 343 | bool empty = input_.text().empty(); |
344 | 344 | input_.ProcessInput(input); |
345 | 345 | |
346 | - if (IsActive() && ((first_key_return && empty) || push_key_esc)) { | |
346 | + if (IsActive() && ((first_key_return && !push_key_shift && empty) || push_key_esc)) { | |
347 | 347 | Inactivate(); |
348 | 348 | } else if (!IsActive() && first_key_return) { |
349 | 349 | Activate(); |
@@ -9,7 +9,7 @@ | ||
9 | 9 | |
10 | 10 | #define MMO_VERSION_MAJOR 0 |
11 | 11 | #define MMO_VERSION_MINOR 2 |
12 | -#define MMO_VERSION_REVISION 5 | |
12 | +#define MMO_VERSION_REVISION 6 | |
13 | 13 | |
14 | 14 | #ifdef MMO_VERSION_BUILD |
15 | 15 | #define MMO_VERSION_BUILD_TEXT " Build " MMO_VERSION_TOSTRING(MMO_VERSION_BUILD) |