OSDN Git Service

fix build system ofmoflib1 and saisei1
[moflib/moflib.git] / saisei-1.0 / bin / script / menu.lua
1 require('script/moflib')
2 require('script/common')
3 require('script/bubble')
4
5 --{{{ question_attached
6 function question_attached(item_tween)
7         local items = load_game_data('gamedata.item_profile')
8         local list = {}
9         for i = 1, #items, 1 do
10                 local name = get_icon_image_tag(items[i].icon_type) .. 
11                         '<layout w="360" h="32" xalign="left" yalign="center">' .. items[i].name .. '</layout>'
12                 if tonumber(items[i].attached) == 1 then 
13                         if tonumber(items[i].equipped) == 1 then
14                                 table.insert(list, name .. '<layout w="100" h="32" xalign="right" yalign="center"><col name="blue">(\91\95\94õ\92\86)</col></layout>')
15                         else
16                                 table.insert(list, name)
17                         end
18                 end
19         end
20         return question('\8f\8a\8e\9d\83A\83C\83e\83\80(\8ec\82è0\83X\83\8d\83b\83g)', list, nil, nil, item_tween)
21 end
22 --}}}
23 --{{{ question_stored
24 function question_stored(item_tween)
25         local items = load_game_data('gamedata.item_profile')
26         local list = {}
27         for i = 1, #items, 1 do
28                 local name = get_icon_image_tag(items[i].icon_type) .. 
29                         '<layout w="360" h="32" xalign="left" yalign="center">' .. items[i].name .. '</layout>'
30                 if tonumber(items[i].stored) == 1 then 
31                         table.insert(list, name)
32                 end
33         end
34         return question('\91q\8cÉ\83A\83C\83e\83\80', list, nil, nil, item_tween)
35 end
36 --}}}
37 --{{{ question_relic
38 function question_relic(item_tween)
39         local relics = load_game_data('gamedata.relic_profile')
40         local list = {}
41         for i = 1, #relics, 1 do
42                 if relics[i].num ~= 0 then
43                         local name = get_icon_image_tag(relics[i].icon_type) .. 
44                                 '<layout w="360" h="32" xalign="left" yalign="center">' .. relics[i].name .. '</layout>' ..
45                                 '<layout w="100" h="32" xalign="right" yalign="center">' .. relics[i].num .. '\83\96</layout>'
46                         table.insert(list, name)
47                 end
48         end
49         return question('\83\8c\83\8a\83b\83N', list, nil, nil, item_tween) -- relic\82Í\91S\95\94disable
50 end
51 --}}}
52 --{{{ question_setup_weapon
53 function question_setup_weapon(item_tween)
54         local items = load_game_data('gamedata.item_profile')
55         local list = {}
56         local disables = {}
57         local num_items = 0
58         for i = 1, #items, 1 do
59                 local type = tonumber(items[i].type);
60                 local state = ''
61                 if items[i].equipped == '1' then
62                         state = '<layout w="100" h="32" xalign="right" yalign="center">(\91\95\94õ\92\86)</layout></col>'
63                 elseif items[i].attached == '1' then
64                         state = '<layout w="100" h="32" xalign="right" yalign="center"><col name="blue">(\8f\8a\8e\9d)</col></layout>'
65                 elseif items[i].stored == '1' then
66                         state = '<layout w="100" h="32" xalign="right" yalign="center"><col name="blue">(\91q\8cÉ)</col></layout>'
67                 end
68                 if type == ITEM_TYPE_KNIGH or type == ITEM_TYPE_SWORD or type == ITEM_TYPE_BLADE then 
69                         -- \91\95\94õ\92\86\82¾\82Á\82½\82çdisable
70                         if items[i].equipped == '1' then
71                                 local name = get_icon_image_tag(items[i].icon_type) .. 
72                                         '<col name="gray"><layout w="360" h="32" xalign="left" yalign="center">' .. items[i].name .. '</layout>'
73                                 table.insert(list, name .. state)
74                                 table.insert(disables, num_items)
75                         else
76                                 local name = get_icon_image_tag(items[i].icon_type) .. 
77                                         '<layout w="360" h="32" xalign="left" yalign="center">' .. items[i].name .. '</layout>'
78                                 table.insert(list, name .. state)
79                         end
80                         num_items = num_items + 1
81                 end
82         end
83         return question('\91\95\94õ\82·\82é\95\90\8aí\82ð\91I\91ð', list, nil, disables, item_tween)
84 end
85 --}}}
86 --{{{ question_setup_armer
87 function question_setup_armer(item_tween)
88         local items = load_game_data('gamedata.item_profile')
89         local list = {}
90         local disables = {}
91         local num_items = 0
92         for i = 1, #items, 1 do
93                 local type = tonumber(items[i].type);
94                 local state = ''
95                 if items[i].equipped == '1' then
96                         state = '<layout w="100" h="32" xalign="right" yalign="center">(\91\95\94õ\92\86)</layout></col>'
97                 elseif items[i].attached == '1' then
98                         state = '<layout w="100" h="32" xalign="right" yalign="center"><col name="blue">(\8f\8a\8e\9d)</col></layout>'
99                 elseif items[i].stored == '1' then
100                         state = '<layout w="100" h="32" xalign="right" yalign="center"><col name="blue">(\91q\8cÉ)</col></layout>'
101                 end
102                 if type == ITEM_TYPE_ROBE or type == ITEM_TYPE_ARMER then 
103                         -- \91\95\94õ\92\86\82¾\82Á\82½\82çdisable
104                         if items[i].equipped == '1' then
105                                 local name = get_icon_image_tag(items[i].icon_type) .. 
106                                         '<col name="gray"><layout w="360" h="32" xalign="left" yalign="center">' .. items[i].name .. '</layout>'
107                                 table.insert(list, name .. state)
108                                 table.insert(disables, num_items)
109                         else
110                                 local name = get_icon_image_tag(items[i].icon_type) .. 
111                                         '<layout w="360" h="32" xalign="left" yalign="center">' .. items[i].name .. '</layout>'
112                                 table.insert(list, name .. state)
113                         end
114                         num_items = num_items + 1
115
116                 end
117         end
118         return question('\91\95\94õ\82·\82é\96h\8bï\82ð\91I\91ð', list, nil, disables, item_tween)
119 end
120 --}}}
121 --{{{ question_setup_item
122 function question_setup_item(item_tween)
123         local items = load_game_data('gamedata.item_profile')
124         local list = {}
125         local disables = {}
126         local num_items = 0
127         for i = 1, #items, 1 do
128                 local state = ''
129                 if items[i].equipped == '1' then
130                         state = '<layout w="100" h="32" xalign="right" yalign="center">(\91\95\94õ\92\86)</layout></col>'
131                 elseif items[i].attached == '1' then
132                         state = '<layout w="100" h="32" xalign="right" yalign="center"><col name="blue">(\8f\8a\8e\9d)</col></layout>'
133                 elseif items[i].stored == '1' then
134                         state = '<layout w="100" h="32" xalign="right" yalign="center"><col name="blue">(\91q\8cÉ)</col></layout>'
135                 end
136
137                 -- \91\95\94õ\92\86\82¾\82Á\82½\82çdisable
138                 if items[i].equipped == '1' then
139                         local name = get_icon_image_tag(items[i].icon_type) .. 
140                                 '<col name="gray"><layout w="360" h="32" xalign="left" yalign="center">' .. items[i].name .. '</layout>'
141                         table.insert(list, name .. state)
142                         table.insert(disables, num_items)
143                 else
144                         local name = get_icon_image_tag(items[i].icon_type) .. 
145                                 '<layout w="360" h="32" xalign="left" yalign="center">' .. items[i].name .. '</layout>'
146                         table.insert(list, name .. state)
147                 end
148                 num_items = num_items + 1
149         end
150         return question('\8f\8a\8e\9d\82·\82é\83A\83C\83e\83\80\82ð\91I\91ð(\8ec\82è0\83X\83\8d\83b\83g)', list, nil, disables, item_tween)
151 end
152 --}}}
153 --{{{ question_setup_ideal
154 function question_setup_ideal(item_tween)
155         local items = load_game_data('gamedata.ideal_profile')
156         local list = {}
157         for i = 1, #items, 1 do
158                 local state = ''
159                 if items[i].attend == '1' then
160                         state = '<layout w="100" h="32" xalign="right" yalign="center"><col name="blue">(\8eQ\89Á)</col></layout>'
161                 end
162                 local name = get_icon_image_tag(items[i].icon_type) .. 
163                         '<layout w="360" h="32" xalign="left" yalign="center">' .. items[i].name .. '</layout>'
164                 table.insert(list, name .. state)
165         end
166         return question('\8fo\8c\82\90_\97ì\82ð\91I\91ð(\8ec\82è0\83X\83\8d\83b\83g)', list, nil, nil, item_tween)
167 end
168 --}}}
169 --{{{ item_menu
170 function item_menu()
171         local base_width = 500
172         local base_height = 400
173
174         local items = 
175                 {
176                         '<layout w="170" h="24" xalign="center">\8f\8a\8e\9d\83A\83C\83e\83\80</layout>',
177                         '<layout w="170" h="24" xalign="center">\91q\8cÉ\83A\83C\83e\83\80</layout>',
178                         '<layout w="170" h="24" xalign="center">\83\8c\83\8a\83b\83N</layout>',
179                 }
180         local tab_menu = Question:new('\83A\83C\83e\83\80\8aÇ\97\9d\83\81\83j\83\85\81[', items, 'direction=horizontal')
181         local prop = tab_menu:get_properties()
182         local old_width, old_height = split(prop['preferred_size'], ',')
183         local x, y = layout(0.5, base_width, 0.5, 0.5, base_height, 0.5)
184         local width = base_width
185         local height = 70
186         -- tab_menu\82Ìtween\82ð\90Ý\92è
187         tab_menu:set_tween('open.position2', {[0] = {x, -height}, [20] = {x, y}}, 20)
188         tab_menu:set_tween('open.size2', {[0] = {width - old_width, height - old_height}}, 0)
189         tab_menu:set_tween('close.position2', {[0] = {x, y}, [20] = {x, -height}}, 20)
190         tab_menu:set_tween('close.size2', {[0] = {width - old_width, height - old_height}}, 0)
191         tab_menu:set_tween('close.color', {[5] = {1, 1, 1, 1}, [20] = {0, 1, 1, 1}}, 20)
192
193         local frame = tab_menu:show()
194         wait_frame(frame)
195         while true do
196                 local key = get_key()
197                 if key == KEY_UP then tab_menu:move_cursor_up()
198                 elseif key == KEY_DOWN then tab_menu:move_cursor_down()
199                 elseif key == KEY_LEFT then tab_menu:move_cursor_left()
200                 elseif key == KEY_RIGHT then tab_menu:move_cursor_right()
201                 elseif key == KEY_X then 
202                         sound("sound/cancel.wav")-- \83L\83\83\83\93\83Z\83\8b\89¹
203                         frame = tab_menu:hide()
204                         wait_frame(frame)
205                         tab_menu:dispose()
206                         return 
207                 elseif key == KEY_Z then 
208                         local index = tab_menu:get_current()
209                         sound("sound/decide.wav")-- \8c\88\92è\89¹
210                         -- tab_menu\82Ì\88Ê\92u\8cv\8eZ
211                         local prop = tab_menu:get_properties()
212
213                         -- item_menu\82Ì\82½\82ß\82Ìtween\8dì\90¬
214                         local item_tween = DefaultTween:new(x, y + height + 10, width, base_height - height) -- \88ê\8fu\82Å\8c»\82ê\82é
215                         if index == 0 then
216                                 question_attached(item_tween)
217                         elseif index == 1 then
218                                 question_stored(item_tween)
219                         elseif index == 2 then
220                                 question_relic(item_tween)
221                                 --question('\83\8c\83\8a\83b\83N', {'\8dz\90ÎX15', '\96\82\8f»\90ÎX10', '\90Â\8f»\90ÎX2', '\8cÃ\95\8f\91X4', '\93ä\82Ì\89t\91ÌX3'}, nil, nil, item_tween)
222                         end
223                 end     
224         end
225 end
226 --}}}
227 --{{{ setup_menu
228 function setup_menu()
229         local base_width = 500
230         local base_height = 400
231
232         local items = 
233                 {
234                         '<layout w="120" h="24" xalign="center">\95\90\8aí</layout>',
235                         '<layout w="120" h="24" xalign="center">\96h\8bï</layout>',
236                         '<layout w="120" h="24" xalign="center">\90_\97ì</layout>',
237                         '<layout w="120" h="24" xalign="center">\83A\83C\83e\83\80</layout>',
238                 }
239         local tab_menu = Question:new('\83Z\83b\83g\83A\83b\83v\83\81\83j\83\85\81[', items, 'direction=horizontal')
240         local prop = tab_menu:get_properties()
241         local old_width, old_height = split(prop['preferred_size'], ',')
242         local x, y = layout(0.5, base_width, 0.5, 0.5, base_height, 0.5)
243         local width = base_width
244         local height = 70
245         -- tab_menu\82Ìtween\82ð\90Ý\92è
246         tab_menu:set_tween('open.position2', {[0] = {x, -height}, [20] = {x, y}}, 20)
247         tab_menu:set_tween('open.size2', {[0] = {width - old_width, height - old_height}}, 0)
248         tab_menu:set_tween('close.position2', {[0] = {x, y}, [20] = {x, -height}}, 20)
249         tab_menu:set_tween('close.size2', {[0] = {width - old_width, height - old_height}}, 0)
250         tab_menu:set_tween('close.color', {[5] = {1, 1, 1, 1}, [20] = {0, 1, 1, 1}}, 20)
251
252         local frame = tab_menu:show()
253         wait_frame(frame)
254         while true do
255                 local key = get_key()
256                 if key == KEY_UP then tab_menu:move_cursor_up()
257                 elseif key == KEY_DOWN then tab_menu:move_cursor_down()
258                 elseif key == KEY_LEFT then tab_menu:move_cursor_left()
259                 elseif key == KEY_RIGHT then tab_menu:move_cursor_right()
260                 elseif key == KEY_X then 
261                         sound("sound/cancel.wav")-- \83L\83\83\83\93\83Z\83\8b\89¹
262                         frame = tab_menu:hide()
263                         wait_frame(frame)
264                         tab_menu:dispose()
265                         return 
266                 elseif key == KEY_Z then 
267                         local index = tab_menu:get_current()
268                         sound("sound/decide.wav")-- \8c\88\92è\89¹
269                         -- tab_menu\82Ì\88Ê\92u\8cv\8eZ
270                         local prop = tab_menu:get_properties()
271
272                         -- item_menu\82Ì\82½\82ß\82Ìtween\8dì\90¬
273                         local item_tween = DefaultTween:new(x, y + height + 10, width, base_height - height) -- \88ê\8fu\82Å\8c»\82ê\82é
274                         if index == 0 then
275                                 question_setup_weapon(item_tween)
276                         elseif index == 1 then
277                                 question_setup_armer(item_tween)
278                         elseif index == 2 then
279                                 question_setup_ideal(item_tween) 
280                         elseif index == 3 then
281                                 question_setup_item(item_tween)
282                         end
283                 end     
284         end
285 end
286 --}}}
287
288 function main()
289         --pic = Picture:new('image/yukkuri.png')
290         --pic:set_tween('color', {[0] = {1, 1, 1}, [10] = {1, 0, 0}, [100] = {1, 0, 1, 1}})
291         --pic:set_tween('position2', {[0] = {200, 100}, [100] = {400, 200}})
292         --pic:set_tween('size2', {[0] = {100, 100}, [30] = {200, 200}, [60] = {100, 100}})
293         
294         local answer
295         while true do
296                 local items = {'\83X\83e\81[\83^\83X', '\83A\83C\83e\83\80\8aÇ\97\9d', '\83Z\83b\83g\83A\83b\83v', '\83V\83X\83e\83\80', '<col name="gray">\83_\83\93\83W\83\87\83\93\92E\8fo</col>'}
297                 answer = question('\83\81\83C\83\93\83\81\83j\83\85\81[', items, nil, {4}, RightSlideTween:new(0.2, 0.8, 0.3, 0.7, 20))
298                 if answer == 0 then
299                         break
300                 elseif answer == 1 then
301                         --{{{ \83X\83e\81[\83^\83X
302                         local texts = {
303                                         'HP   200/400         \83Q\83C\83\93    80%<nl/>\8dU\8c\82\97Í    200        \8aÑ\92Ê\97Í      20<nl/>\95¨\97\9d\96h\8cä 100        \96\82\96@\96h\8cä   50',
304                                         '\8f\8a\8e\9d\83A\83C\83e\83\80\90\94   5<nl />\8eg\96ð\90_\97ì\90\94       5          \90í\93¬\8eQ\89Á\90_\97ì\90\94      2',
305                                         '\8f\8a\8e\9d\8bà           3JEM',
306                                 }
307                         message('\83\8a\81[\83X', texts, '', ExtensionTween:new())
308                         --}}}
309                 elseif answer == 2 then
310                         item_menu()
311                 elseif answer == 3 then
312                         setup_menu()
313                 elseif answer == 4 then
314                         --{{{ \83V\83X\83e\83\80
315                         answer = question('\83V\83X\83e\83\80\83\81\83j\83\85\81[', {'\83Z\81[\83u', '\83\8d\81[\83h', '\8aÂ\8b«\90Ý\92è', '\82à\82Ç\82é'})
316                         --}}}
317                 end 
318         end -- \83\81\83C\83\93\83\81\83j\83\85\81[
319
320 end
321