• R/O
  • SSH

hyakutyping: コミット

ゲーム用のソースコード


コミットメタ情報

リビジョン3204eca42c349f8b92666f1f71b655a032e620ae (tree)
日時2011-07-19 10:05:26
作者satofumi
コミッターsatofumi

ログメッセージ

オプション画面のカーソル表示を追加

変更サマリ

差分

diff -r 0f165cdec295 -r 3204eca42c34 Option.cpp
--- a/Option.cpp Tue Jul 19 06:58:24 2011 +0900
+++ b/Option.cpp Tue Jul 19 10:05:26 2011 +0900
@@ -10,6 +10,7 @@
1010 #include "Option.h"
1111 #include "LayerManager.h"
1212 #include "CallbackEvent.h"
13+#include "Label.h"
1314 #include "Menu.h"
1415 #include <vector>
1516
@@ -19,6 +20,20 @@
1920
2021 struct Option::pImpl
2122 {
23+ class Cursor
24+ {
25+ public:
26+ Label* label;
27+ Point<long> offset;
28+ bool draw_front;
29+
30+ Cursor(Label* label_, Point<long> offset_, bool draw_front_)
31+ : label(label_), offset(offset_), draw_front(draw_front_)
32+ {
33+ }
34+ };
35+
36+ typedef vector<Cursor> Cursors;
2237 typedef vector<Menu*> Components;
2338
2439 Rect<long> rect_;
@@ -33,9 +48,13 @@
3348 CallbackEvent right_event_;
3449
3550 Components components_;
51+ Cursors cursors_;
52+
53+ Point<long> prev_cursor_;
54+ Point<long> cursor_;
3655
3756
38- pImpl(const qrk::Rect<long>& rect)
57+ pImpl(const Rect<long>& rect)
3958 : rect_(rect), acceptable_(false), alpha_(1.0),
4059 current_row_index_(0)
4160 {
@@ -60,19 +79,29 @@
6079 }
6180
6281
63- void draw(const qrk::Rect<long>& area)
82+ void draw(const Rect<long>& area)
6483 {
84+ // マウスの移動を検出したら、キー入力用のカーソル表示を消す
85+ if ((prev_cursor_.x != cursor_.x) || (prev_cursor_.y != cursor_.y)) {
86+ removeCursor();
87+ }
88+ prev_cursor_ = cursor_;
89+ cursor_ = layer_manager_.cursor();
90+
6591 // 上下キーの処理
92+ int next_row_index = current_row_index_;
6693 bool up = up_event_.isActive();
6794 bool down = down_event_.isActive();
6895 if (up && (current_row_index_ > 0)) {
69- --current_row_index_;
96+ next_row_index = current_row_index_ - 1;
7097 }
7198 if (down &&
7299 (current_row_index_ < static_cast<int>(components_.size()) - 1)) {
73- ++current_row_index_;
100+ next_row_index = current_row_index_ + 1;
74101 }
75- fprintf(stderr, "current_row_index_: %d\n", current_row_index_);
102+ if (next_row_index != current_row_index_) {
103+ updateSelectedRow(next_row_index);
104+ }
76105
77106 // 左右キーの処理
78107 bool left = left_event_.isActive();
@@ -93,12 +122,35 @@
93122 }
94123
95124
125+ void updateSelectedRow(int next_row_index)
126+ {
127+ removeCursor();
128+ plaseCursor(next_row_index);
129+
130+ current_row_index_ = next_row_index;
131+ }
132+
133+
134+ void removeCursor(void)
135+ {
136+ Menu* menu = components_[current_row_index_];
137+ menu->unregisterIconLabel();
138+ }
139+
140+
141+ void plaseCursor(int index)
142+ {
143+ Cursor& cursor = cursors_[index];
144+ Menu* menu = components_[index];
145+ menu->setIconOffset(cursor.offset);
146+ menu->registerIconLabel(*cursor.label, cursor.draw_front);
147+ }
148+
96149 void updateSelectedItem(int index, int xx)
97150 {
98151 Menu* menu = components_[index];
99152 int max_item_index = menu->indexSize();
100153 int next_item_index = static_cast<int>(menu->clickedId()) + xx;
101- fprintf(stderr, ", %d, ", next_item_index);
102154 if ((next_item_index <= 0) || (next_item_index > max_item_index)) {
103155 return;
104156 }
@@ -107,11 +159,21 @@
107159 menu->press(next_item_index);
108160 }
109161
110- void addSubMenu(qrk::Menu* sub_menu, const Point<long>& position)
162+
163+ void addSubMenu(Menu* sub_menu, const Point<long>& position,
164+ Label* cursor_label, const Point<long>& cursor_offset,
165+ bool draw_front)
111166 {
112167 sub_menu->setPosition(position);
113168 sub_menu->setEventAcceptable(false);
114169 components_.push_back(sub_menu);
170+
171+ cursors_.push_back(Cursor(cursor_label, cursor_offset, draw_front));
172+
173+ // 最初に登録された項目にアイコンを適用する
174+ if (cursors_.size() == 1) {
175+ updateSelectedRow(0);
176+ }
115177 }
116178 };
117179
@@ -163,7 +225,10 @@
163225 }
164226
165227
166-void Option::addSubMenu(Menu* sub_menu, const qrk::Point<long>& position)
228+void Option::addSubMenu(Menu* sub_menu, const qrk::Point<long>& position,
229+ qrk::Label* cursor_label,
230+ const qrk::Point<long>& cursor_offset, bool draw_front)
167231 {
168- pimpl->addSubMenu(sub_menu, position);
232+ pimpl->addSubMenu(sub_menu, position,
233+ cursor_label, cursor_offset, draw_front);
169234 }
diff -r 0f165cdec295 -r 3204eca42c34 Option.h
--- a/Option.h Tue Jul 19 06:58:24 2011 +0900
+++ b/Option.h Tue Jul 19 10:05:26 2011 +0900
@@ -15,6 +15,7 @@
1515 namespace qrk
1616 {
1717 class Menu;
18+ class Label;
1819 }
1920
2021
@@ -31,7 +32,10 @@
3132 void setRotateAngle(const qrk::Angle& angle);
3233 void draw(const qrk::Rect<long>& area);
3334
34- void addSubMenu(qrk::Menu* sub_menu, const qrk::Point<long>& position);
35+ void addSubMenu(qrk::Menu* sub_menu, const qrk::Point<long>& position,
36+ qrk::Label* cursor_label,
37+ const qrk::Point<long>& cursor_offset,
38+ bool draw_front = true);
3539
3640 private:
3741 Option(const Option& rhs);
diff -r 0f165cdec295 -r 3204eca42c34 luabindTyping.cpp
--- a/luabindTyping.cpp Tue Jul 19 06:58:24 2011 +0900
+++ b/luabindTyping.cpp Tue Jul 19 10:05:26 2011 +0900
@@ -11,6 +11,7 @@
1111 #include "hyakutyping.h"
1212 #include "HistoryGraph.h"
1313 #include "Menu.h"
14+#include "Label.h"
1415 #include "Option.h"
1516 #include "Color.h"
1617 #include "Font.h"
diff -r 0f165cdec295 -r 3204eca42c34 scripts/first_menu.lua
--- a/scripts/first_menu.lua Tue Jul 19 06:58:24 2011 +0900
+++ b/scripts/first_menu.lua Tue Jul 19 10:05:26 2011 +0900
@@ -126,10 +126,10 @@
126126 end
127127
128128 -- メニューで選択された状態へ遷移させる
129- if menu_:isClicked() then
130- --if true then
131- selected_index_ = menu_:clickedId()
132- --selected_index_ = 3
129+ --if menu_:isClicked() then
130+ if true then
131+ --selected_index_ = menu_:clickedId()
132+ selected_index_ = 3
133133
134134 if selected_index_ == 1 then
135135 require("practice_menu")
diff -r 0f165cdec295 -r 3204eca42c34 scripts/option_config.lua
--- a/scripts/option_config.lua Tue Jul 19 06:58:24 2011 +0900
+++ b/scripts/option_config.lua Tue Jul 19 10:05:26 2011 +0900
@@ -33,18 +33,22 @@
3333 local option_input_ = nil
3434 local option_input_buttons_ = nil
3535 local option_input_surfaces_ = nil
36+local option_input_cursor_ = nil
3637
3738 local option_screen_ = nil
3839 local option_screen_buttons_ = nil
3940 local option_screen_surfaces_ = nil
41+local option_screen_cursor_ = nil
4042
4143 local volume_music_ = nil
4244 local volume_music_buttons_ = nil
4345 local volume_music_surfaces_ = nil
46+local volume_music_cursor_ = nil
4447
4548 local volume_se_ = nil
4649 local volume_se_buttons_ = nil
4750 local volume_se_surfaces_ = nil
51+local volume_se_cursor_ = nil
4852
4953
5054 option_config["Enter"] =
@@ -97,13 +101,22 @@
97101 local option_input_y = 135
98102 option_input_buttons_ = {}
99103 option_input_surfaces_ = {}
104+
105+ local cursor_rect = Rect(0, 0, base_rect.w, 4)
106+ local cursor_surface =
107+ ColorSurface(cursor_rect, Color(0.0, 0.3, 0.0, 1.0))
108+ option_input_cursor_ = Label(cursor_surface)
109+ table.insert(option_input_surfaces_, cursor_surface)
110+
100111 createMenu(option_input_, buttons_text, base_rect, font_,
101112 option_input_surfaces_, option_input_buttons_, "center")
102113
103114 local buttons_step = Point(190, 0)
104115 option_input_:setButtonStep(buttons_step)
105116 option_input_:setEnableClickedAndFocus(true)
106- option_:addSubMenu(option_input_, Point(option_x, option_input_y))
117+ option_:addSubMenu(option_input_, Point(option_x, option_input_y),
118+ option_input_cursor_,
119+ Point(0, base_rect.h/2 + 4), false)
107120
108121
109122 -- フルスクリーン / ウィンドウ
@@ -119,13 +132,21 @@
119132 local option_screen_y = 235
120133 option_screen_buttons_ = {}
121134 option_screen_surfaces_ = {}
135+
136+ cursor_rect = Rect(0, 0, base_rect.w, 4)
137+ cursor_surface = ColorSurface(cursor_rect, Color(0.0, 0.3, 0.0, 1.0))
138+ option_screen_cursor_ = Label(cursor_surface)
139+ table.insert(option_screen_surfaces_, cursor_surface)
140+
122141 createMenu(option_screen_, buttons_text, base_rect, font_,
123142 option_screen_surfaces_, option_screen_buttons_, "center")
124143
125144 buttons_step = Point(230, 0)
126145 option_screen_:setButtonStep(buttons_step)
127146 option_screen_:setEnableClickedAndFocus(true)
128- option_:addSubMenu(option_screen_, Point(option_x, option_screen_y))
147+ option_:addSubMenu(option_screen_, Point(option_x, option_screen_y),
148+ option_screen_cursor_,
149+ Point(0, base_rect.h/2 + 4), false)
129150
130151
131152 -- 曲
@@ -155,13 +176,21 @@
155176 local volume_music_y = music_y
156177 volume_music_buttons_ = {}
157178 volume_music_surfaces_ = {}
179+
180+ cursor_rect = Rect(0, 0, base_rect.w, 4)
181+ cursor_surface = ColorSurface(cursor_rect, Color(0.0, 0.3, 0.0, 1.0))
182+ volume_music_cursor_ = Label(cursor_surface)
183+ table.insert(volume_music_surfaces_, cursor_surface)
184+
158185 createMenu(volume_music_, buttons_text, base_rect, font_,
159186 volume_music_surfaces_, volume_music_buttons_, "center")
160187
161188 buttons_step = Point(32, 0)
162189 volume_music_:setButtonStep(buttons_step)
163190 volume_music_:setEnableClickedAndFocus(true)
164- option_:addSubMenu(volume_music_, Point(volume_music_x, volume_music_y))
191+ option_:addSubMenu(volume_music_, Point(volume_music_x, volume_music_y),
192+ volume_music_cursor_,
193+ Point(0, base_rect.h/2 + 4), false)
165194
166195
167196 -- 効果音の音量
@@ -171,11 +200,19 @@
171200 local volume_se_y = se_y
172201 volume_se_buttons_ = {}
173202 volume_se_surfaces_ = {}
203+
204+ cursor_rect = Rect(0, 0, base_rect.w, 4)
205+ cursor_surface = ColorSurface(cursor_rect, Color(0.0, 0.3, 0.0, 1.0))
206+ volume_se_cursor_ = Label(cursor_surface)
207+ table.insert(volume_se_surfaces_, cursor_surface)
208+
174209 createMenu(volume_se_, buttons_text, base_rect, font_,
175210 volume_se_surfaces_, volume_se_buttons_, "center")
211+
176212 volume_se_:setButtonStep(buttons_step)
177213 volume_se_:setEnableClickedAndFocus(true)
178- option_:addSubMenu(volume_se_, Point(volume_se_x, volume_se_y))
214+ option_:addSubMenu(volume_se_, Point(volume_se_x, volume_se_y),
215+ volume_se_cursor_, Point(0, base_rect.h/2 + 4), false)
179216
180217
181218 -- 保存されている設定を読み出して反映させる
@@ -234,18 +271,22 @@
234271 subtitle_volume_se_label_ = nil
235272 subtitle_volume_se_ = nil
236273
274+ option_input_cursor_ = nil
237275 option_input_buttons_ = nil
238276 option_input_surfaces_ = nil
239277 option_input_ = nil
240278
279+ option_screen_cursor_ = nil
241280 option_screen_buttons_ = nil
242281 option_screen_surfaces_ = nil
243282 option_screen_ = nil
244283
284+ volume_music_cursor_ = nil
245285 volume_music_buttons_ = nil
246286 volume_music_surfaces_ = nil
247287 volume_music_ = nil
248288
289+ volume_se_cursor_ = nil
249290 volume_se_buttons_ = nil
250291 volume_se_surfaces_ = nil
251292 volume_se_ = nil
旧リポジトリブラウザで表示