• R/O
  • SSH

hyakutyping: コミット

ゲーム用のソースコード


コミットメタ情報

リビジョンdf53ec8254e282299e6e7f8bb30fb2dadff2028a (tree)
日時2011-07-17 18:07:50
作者satofumi
コミッターsatofumi

ログメッセージ

オプション用のコンポーネントを追加

変更サマリ

差分

diff -r 51e96aeb82c7 -r df53ec8254e2 Makefile
--- a/Makefile Sun Jul 17 13:13:11 2011 +0900
+++ b/Makefile Sun Jul 17 18:07:50 2011 +0900
@@ -57,7 +57,7 @@
5757 .dot.png :
5858 -dot -Tpng $< > $@
5959
60-OBJS = luabindTyping.o HistoryGraph.o
60+OBJS = luabindTyping.o HistoryGraph.o Option.o
6161 REQUIRE_LIBS = $(LIB_DIR)/lua/lua.a $(LIB_DIR)/lua/lua_luabind.a $(LIB_DIR)/gui/gui.a $(LIB_DIR)/input/input.a $(LIB_DIR)/geometry/geometry.a $(LIB_DIR)/system/sdl/system_sdl.a $(LIB_DIR)/system/system.a
6262 $(REQUIRE_LIBS) :
6363 cd $(@D)/ && $(MAKE) $(@F)
@@ -77,11 +77,17 @@
7777
7878 HistoryGraph.o: ../../../libs/gui/Component.h ../../../libs/geometry/Rect.h
7979 HistoryGraph.o: ../../../libs/geometry/Point.h
80+Option.o: ../../../libs/gui/Component.h ../../../libs/geometry/Rect.h
81+Option.o: ../../../libs/geometry/Point.h
8082 HistoryGraph.o: HistoryGraph.h ../../../libs/gui/Component.h
8183 HistoryGraph.o: ../../../libs/geometry/Rect.h ../../../libs/geometry/Point.h
8284 HistoryGraph.o: ../../../libs/gui/CanvasSurface.h ../../../libs/gui/Surface.h
8385 HistoryGraph.o: ../../../libs/common/Color.h ../../../libs/gui/TextSurface.h
8486 HistoryGraph.o: ../../../libs/gui/Font.h
87+Option.o: Option.h ../../../libs/gui/Component.h
88+Option.o: ../../../libs/geometry/Rect.h ../../../libs/geometry/Point.h
89+Option.o: ../../../libs/gui/LayerManager.h ../../../libs/gui/LayerInterface.h
90+Option.o: ../../../libs/gui/CallbackEvent.h ../../../libs/gui/Event.h
8591 hyakutyping.o: hyakutyping.h luabindTyping.h
8692 hyakutyping.o: ../../../libs/lua/lua_runStateMachine.h
8793 hyakutyping.o: ../../../libs/lua/luabindInit.h ../../../libs/lua/luabindGui.h
@@ -93,5 +99,6 @@
9399 hyakutyping.o: ../../../libs/geometry/Rect.h ../../../libs/system/fileExist.h
94100 luabindTyping.o: luabindTyping.h hyakutyping.h HistoryGraph.h
95101 luabindTyping.o: ../../../libs/gui/Component.h ../../../libs/geometry/Rect.h
96-luabindTyping.o: ../../../libs/geometry/Point.h ../../../libs/common/Color.h
97-luabindTyping.o: ../../../libs/gui/Font.h ../../../libs/lua/LuaHandler.h
102+luabindTyping.o: ../../../libs/geometry/Point.h Option.h
103+luabindTyping.o: ../../../libs/common/Color.h ../../../libs/gui/Font.h
104+luabindTyping.o: ../../../libs/lua/LuaHandler.h
diff -r 51e96aeb82c7 -r df53ec8254e2 Option.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Option.cpp Sun Jul 17 18:07:50 2011 +0900
@@ -0,0 +1,152 @@
1+/*!
2+ \file
3+ \brief オプション用のコンポーネント
4+
5+ \author Satofumi KAMIMURA
6+
7+ $Id$
8+*/
9+
10+#include "Option.h"
11+#include "LayerManager.h"
12+#include "CallbackEvent.h"
13+#include <vector>
14+
15+using namespace qrk;
16+using namespace std;
17+
18+
19+struct Option::pImpl
20+{
21+ typedef vector<Component*> Components;
22+
23+ Rect<long> rect_;
24+ bool acceptable_;
25+ float alpha_;
26+ int current_row_;
27+
28+ LayerManager layer_manager_;
29+ CallbackEvent up_event_;
30+ CallbackEvent down_event_;
31+
32+ Components components_;
33+
34+
35+ pImpl(const qrk::Rect<long>& rect)
36+ : rect_(rect), acceptable_(false), alpha_(1.0),
37+ current_row_(0)
38+ {
39+ up_event_.key(SDLK_UP, SDL_KEYDOWN, KMOD_NONE);
40+ down_event_.key(SDLK_DOWN, SDL_KEYDOWN, KMOD_NONE);
41+
42+ layer_manager_.insertEvent(&up_event_);
43+ layer_manager_.insertEvent(&down_event_);
44+ }
45+
46+
47+ ~pImpl(void)
48+ {
49+ layer_manager_.removeEvent(&up_event_);
50+ layer_manager_.removeEvent(&down_event_);
51+ }
52+
53+
54+ void draw(const qrk::Rect<long>& area)
55+ {
56+ // マウスカーソルの移動があった場合、キー入力によるイベントの
57+ // 許可・禁止を無効にする
58+ // !!!
59+
60+ // キー入力があった場合、マウスのカーソル位置による行の選択を無効にする
61+
62+ // 左クリックの処理
63+ // !!!
64+
65+ // 上下キーの処理
66+ bool up = up_event_.isActive();
67+ bool down = down_event_.isActive();
68+ if (up) {
69+ fprintf(stderr, "up\n");
70+ }
71+ if (down) {
72+ fprintf(stderr, "down\n");
73+ }
74+ // !!!
75+ // current_row_
76+
77+ // 左右キーの処理
78+ // !!!
79+
80+ // 各コンポーネントの描画
81+ for (Components::iterator it = components_.begin();
82+ it != components_.end(); ++it) {
83+
84+ if (1) {
85+ (*it)->setEventAcceptable(false);
86+ // !!!
87+ }
88+ (*it)->draw(area);
89+ }
90+ }
91+
92+
93+ void addComponent(Component* component, const Point<long>& position)
94+ {
95+ component->setPosition(position);
96+ components_.push_back(component);
97+ }
98+};
99+
100+
101+Option::Option(const qrk::Rect<long>& rect) : pimpl(new pImpl(rect))
102+{
103+}
104+
105+
106+Option::~Option(void)
107+{
108+}
109+
110+
111+qrk::Rect<long> Option::rect(void) const
112+{
113+ return pimpl->rect_;
114+}
115+
116+
117+void Option::setEventAcceptable(bool acceptable)
118+{
119+ pimpl->acceptable_ = acceptable;
120+}
121+
122+
123+void Option::setAlpha(float alpha)
124+{
125+ pimpl->alpha_ = alpha;
126+}
127+
128+
129+float Option::alpha(void)
130+{
131+ return pimpl->alpha_;
132+}
133+
134+
135+void Option::setRotateAngle(const qrk::Angle& angle)
136+{
137+ (void)angle;
138+ // !!!
139+}
140+
141+
142+void Option::draw(const qrk::Rect<long>& area)
143+{
144+ pimpl->draw(area);
145+}
146+
147+
148+void Option::addComponent(Component* component,
149+ const qrk::Point<long>& position)
150+{
151+ pimpl->addComponent(component, position);
152+}
diff -r 51e96aeb82c7 -r df53ec8254e2 Option.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Option.h Sun Jul 17 18:07:50 2011 +0900
@@ -0,0 +1,39 @@
1+#ifndef OPTION_H
2+
3+/*!
4+ \file
5+ \brief オプション用のコンポーネント
6+
7+ \author Satofumi KAMIMURA
8+
9+ $Id$
10+*/
11+
12+#include "Component.h"
13+#include <memory>
14+
15+
16+class Option : public qrk::Component
17+{
18+public:
19+ explicit Option(const qrk::Rect<long>& rect);
20+ ~Option(void);
21+
22+ qrk::Rect<long> rect(void) const;
23+ void setEventAcceptable(bool acceptable);
24+ void setAlpha(float alpha);
25+ float alpha(void);
26+ void setRotateAngle(const qrk::Angle& angle);
27+ void draw(const qrk::Rect<long>& area);
28+
29+ void addComponent(Component* component, const qrk::Point<long>& position);
30+
31+private:
32+ Option(const Option& rhs);
33+ Option& operator = (Option& rhs);
34+
35+ struct pImpl;
36+ std::auto_ptr<pImpl> pimpl;
37+};
38+
39+#endif /* !OPTION_H */
diff -r 51e96aeb82c7 -r df53ec8254e2 luabindTyping.cpp
--- a/luabindTyping.cpp Sun Jul 17 13:13:11 2011 +0900
+++ b/luabindTyping.cpp Sun Jul 17 18:07:50 2011 +0900
@@ -4,12 +4,13 @@
44
55 \author Satofumi KAMIMURA
66
7- $Id$
7+ $Id: luabindTyping.cpp,v ea1a3e6caa29 2011/01/12 18:05:27 Satofumi $
88 */
99
1010 #include "luabindTyping.h"
1111 #include "hyakutyping.h"
1212 #include "HistoryGraph.h"
13+#include "Option.h"
1314 #include "Color.h"
1415 #include "Font.h"
1516 #include "LuaHandler.h"
@@ -34,6 +35,14 @@
3435 .def("setFont", &HistoryGraph::setFont)
3536 .def("setBackgroundColor", &HistoryGraph::setBackgroundColor)
3637 .def("addData", &HistoryGraph::addData)
37- .def("create", &HistoryGraph::create)
38+ .def("create", &HistoryGraph::create),
39+
40+ class_<Option, qrk::Component>("Option")
41+ .def(constructor<const qrk::Rect<long>&>())
42+ .def("setPosition", &Option::setPosition)
43+ .def("position", &Option::position)
44+ .def("rect", &Option::rect)
45+ .def("setAlpha", &Option::setAlpha)
46+ .def("addComponent", &Option::addComponent)
3847 ];
3948 }
diff -r 51e96aeb82c7 -r df53ec8254e2 scripts/option_config.lua
--- a/scripts/option_config.lua Sun Jul 17 13:13:11 2011 +0900
+++ b/scripts/option_config.lua Sun Jul 17 18:07:50 2011 +0900
@@ -14,6 +14,8 @@
1414 local option_font_size = 26
1515
1616
17+local option_ = nil
18+
1719 local title_ = nil
1820 local title_label_ = nil
1921
@@ -48,6 +50,10 @@
4850
4951 option_config["Enter"] =
5052 function(state)
53+ -- オプション操作のコンポーネント
54+ option_ = Option(screen_:rect())
55+ layer_:push_front(option_)
56+
5157 -- タイトルの作成
5258 font_:setPixelSize(40)
5359 title_ = TextSurface(font_, "オプション")
@@ -98,9 +104,7 @@
98104
99105 local buttons_step = Point(190, 0)
100106 option_input_:setButtonStep(buttons_step)
101-
102- option_input_:setPosition(Point(option_x, option_input_y))
103- layer_:push_front(option_input_)
107+ option_:addComponent(option_input_, Point(option_x, option_input_y))
104108
105109
106110 -- フルスクリーン / ウィンドウ
@@ -122,9 +126,7 @@
122126
123127 buttons_step = Point(230, 0)
124128 option_screen_:setButtonStep(buttons_step)
125-
126- option_screen_:setPosition(Point(option_x, option_screen_y))
127- layer_:push_front(option_screen_)
129+ option_:addComponent(option_screen_, Point(option_x, option_screen_y))
128130
129131
130132 -- 曲
@@ -160,9 +162,7 @@
160162
161163 buttons_step = Point(32, 0)
162164 volume_music_:setButtonStep(buttons_step)
163-
164- volume_music_:setPosition(Point(volume_music_x, volume_music_y))
165- layer_:push_front(volume_music_)
165+ option_:addComponent(volume_music_, Point(volume_music_x, volume_music_y))
166166
167167 -- 効果音の音量
168168 local volume_se_rect = Rect(0, 0, screen_:rect().w, option_font_size)
@@ -175,9 +175,7 @@
175175 base_rect, font_, volume_se_surfaces_,
176176 volume_se_buttons_, "center")
177177 volume_se_:setButtonStep(buttons_step)
178-
179- volume_se_:setPosition(Point(volume_se_x, volume_se_y))
180- layer_:push_front(volume_se_)
178+ option_:addComponent(volume_se_, Point(volume_se_x, volume_se_y))
181179 end
182180
183181
@@ -195,6 +193,8 @@
195193
196194 option_config["Exit"] =
197195 function(state)
196+ layer_:remove(option_)
197+
198198 layer_:remove(title_label_)
199199
200200 layer_:remove(subtitle_input_label_)
@@ -203,7 +203,7 @@
203203 layer_:remove(subtitle_volume_music_label_)
204204 layer_:remove(subtitle_volume_se_label_)
205205
206- layer_:remove(option_input_)
206+ --layer_:remove(option_input_)
207207 layer_:remove(option_screen_)
208208 layer_:remove(volume_music_)
209209 layer_:remove(volume_se_)
@@ -239,4 +239,6 @@
239239
240240 title_label_ = nil
241241 title_ = nil
242+
243+ option_ = nil
242244 end
旧リポジトリブラウザで表示