Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
trade.c
Go to the documentation of this file.
1/* The buying and selling dialogs: how many of the item, at what total, and
2 the purchase or the sale */
3
4#include "menus/item_shop.h"
5
6/* Creates the buying dialog's windows: the quantity, the total with its yes and
7 no, and the cursor */
9 win->quantityLabel = createTextWindow(buy->layer, 1, 0xB9, 0x3A);
10 win->times = createTextWindow(buy->layer, 1, 0x103, 0x54);
11 win->quantity = createTextWindow(buy->layer, 1, 0x11E, 0x54);
12 win->total = createTextWindow(buy->layer, 1, 0x9A, 0x2C);
13 win->yes = createTextWindow(buy->layer, 1, 0xC5, 0x49);
14 win->no = createTextWindow(buy->layer, 1, 0xC5, 0x59);
15 win->cursor = createCursor(buy->layer, buy->depth - 1, 0xB8, 0x49);
16 win->cursor->setVisible(win->cursor, 0);
17}
18
19/* Shows the quantity to buy; or hides it */
21 if (show) {
24 win->quantity->setNumber(win->quantity, 0, buy->quantity);
25 win->quantity->setRightAlign(win->quantity, 1);
26 } else {
28 win->times->setVisible(win->times, 0);
29 win->quantity->setVisible(win->quantity, 0);
30 }
31}
32
33/* Shows the total price with yes and no to confirm the purchase; or hides them */
35 if (show) {
37 win->total->setNumber(win->total, 1, ITEM_FUNCS.get(buy->item)->price * buy->quantity);
40 } else {
41 win->total->setVisible(win->total, 0);
42 win->yes->setVisible(win->yes, 0);
43 win->no->setVisible(win->no, 0);
44 }
45}
46
47/* Draws the buying screen's frames, the quantity's blinking arrows and the
48 marker over a partner */
50 SpriteDrawer sprite;
51
52 initSpriteDrawer(&sprite);
53 sprite.setLayerId(buy->layer, buy->depth);
54 sprite.setTexture(0x280, 0x100);
55 if (buy->panels[0].level != 0) {
56 sprite.setScale(buy->panels[0].level, ONE, ONE);
57 if (buy->panels[0].level != ONE) {
58 sprite.setPivot(0x140, 0x42);
59 }
60 sprite.draw(FILE_CACHE.getEntry(FILE_SHOP_SPRITES << 16), 0xA, 0x9A, 0x34);
61 if (buy->panels[0].level != ONE) {
62 sprite.setPivot(0x140, 0x59);
63 } else {
64 if (GFX.funcs.getTime() - buy->blinkTime >= 9) {
65 buy->blinkTime = GFX.funcs.getTime();
66 buy->blink = 1 - buy->blink;
67 }
68 if (buy->blink) {
69 if (buy->quantity < buy->max) {
70 sprite.draw(FILE_CACHE.getEntry(FILE_SHOP_SPRITES << 16), 0x12, 0x122, 0x51);
71 }
72 if (buy->quantity >= 2) {
73 sprite.draw(FILE_CACHE.getEntry(FILE_SHOP_SPRITES << 16), 0x13, 0x122, 0x5B);
74 }
75 }
76 }
77 sprite.draw(FILE_CACHE.getEntry(FILE_SHOP_SPRITES << 16), 0xB, 0xF6, 0x4F);
78 }
79 if (buy->panels[1].level != 0) {
80 STRETCH_SPRITE(sprite, buy->panels[1].level, 0x140, 0x32);
81 sprite.draw(FILE_CACHE.getEntry(FILE_SHOP_SPRITES << 16), 0x15, 0x7B, 0x26);
82 if (buy->panels[1].level != ONE) {
83 sprite.setPivot(0x140, 0x57);
84 }
85 sprite.draw(FILE_CACHE.getEntry(FILE_SHOP_SPRITES << 16), 0xC, 0xAF, 0x43);
86 }
87 if (buy->panels[2].level != 0) {
88 sprite.setLayerId(buy->layer, buy->depth - 2);
89 STRETCH_SPRITE(sprite, buy->panels[2].level, 0x140, 0x32);
90 sprite.draw(FILE_CACHE.getEntry(FILE_SHOP_SPRITES << 16), 0x15, 0x7B, 0x26);
91 }
92 if (buy->panels[3].level != 0) {
93 sprite.setLayerId(buy->layer, buy->depth - 2);
94 STRETCH_SPRITE(sprite, buy->panels[3].level, 0x140, 0x32);
95 sprite.draw(FILE_CACHE.getEntry(FILE_SHOP_SPRITES << 16), 0x15, 0x7B, 0x26);
96 }
97 if (buy->markerShown) {
98 if (GFX.funcs.getTime() - buy->markerTime >= 9) {
99 buy->markerTime = GFX.funcs.getTime();
100 if (++buy->markerFrame >= 8) {
101 buy->markerFrame = 0;
102 }
103 }
104 sprite.setLayerId(buy->layer, buy->depth - 2);
105 sprite.setScale(ONE, ONE, ONE);
106 sprite.setClutRow(buy->markerFrame);
107 sprite.draw(FILE_CACHE.getEntry(FILE_SHOP_SPRITES << 16), 0xF, buy->partner * 0x63 + 0x10, 0x9C);
108 }
109}
110
111/* The quantity to buy: up/down change it by one, left/right by ten, up to
112 what the money and the bag's 99 allow; cross goes on to the total,
113 triangle back to the list and circle turns the details' page */
114static inline void STITSHOP_chooseBuyQuantity(ShopBuy *buy, ShopBuyWindows *win) {
115 s32 old;
116 u16 price;
117
118 old = buy->quantity;
120 buy->quantity++;
121 if (buy->quantity > buy->max) {
122 buy->quantity = buy->max;
123 }
124 } else if (PAD_PRESSED(PAD_DOWN) || PAD_REPEATED(PAD_DOWN)) {
125 if (--buy->quantity <= 0) {
126 buy->quantity = 1;
127 }
128 } else if (PAD_PRESSED(PAD_LEFT) || PAD_REPEATED(PAD_LEFT)) {
129 buy->quantity -= 10;
130 if (buy->quantity < 10) {
131 buy->quantity = 1;
132 }
134 buy->quantity += 10;
135 if (buy->quantity > buy->max) {
136 buy->quantity = buy->max;
137 }
138 }
139 if (old != buy->quantity) {
140 price = ITEM_FUNCS.get(buy->item)->price;
141 if (GAME.money < price * buy->quantity) {
142 buy->quantity = GAME.money / price;
143 }
144 STITSHOP_showQuantity(buy, win, 1);
145 win->info->showItem(win->info, buy->item, buy->quantity);
147 } else if (PAD_PRESSED(PAD_CROSS)) {
149 buy->nextSubstate(buy);
150 } else if (PAD_PRESSED(PAD_TRIANGLE)) {
152 buy->nextSubstate(buy);
153 buy->step = 1;
154 buy->quantity = 1;
155 win->info->showItem(win->info, buy->item, 1);
156 } else if (PAD_PRESSED(PAD_CIRCLE)) {
157 if (win->info->substate == 3) {
158 win->info->turnPage(win->info);
159 buy->substate = 12;
160 }
161 }
162}
163
164/* The item list: cross picks the item under the cursor, unless the bag holds
165 99 of it or the money is short (a message then), triangle closes the dialog
166 and circle turns the details' page */
167static inline void STITSHOP_pickBuyItem(ShopBuy *buy, ShopBuyWindows *win) {
168 if (PAD_PRESSED(PAD_CROSS)) {
170 buy->item = win->list->getSelected(win->list);
171 if (GAME.items[buy->item] == 99) {
173 win->total->setVisible(win->total, 0);
174 buy->substate = 45;
175 } else if (GAME.money < ITEM_FUNCS.get(buy->item)->price) {
177 win->total->setVisible(win->total, 0);
178 buy->substate = 45;
179 } else {
180 win->list->showCursor(win->list, 0);
181 buy->substate = 5;
182 }
183 } else if (PAD_PRESSED(PAD_TRIANGLE)) {
185 win->list->close(win->list);
186 win->info->close(win->info);
187 buy->substate = 50;
188 } else if (PAD_PRESSED(PAD_CIRCLE)) {
189 if (win->info->substate == 3) {
190 win->info->turnPage(win->info);
191 win->list->freezeCursor(win->list, 1);
192 buy->substate = 4;
193 }
194 }
195}
196
197/* Yes or no to the total: yes buys the items (at most 99 in the bag) and pays
198 for them, and for equipment asks next whether to equip it; triangle cancels
199 and circle turns the details' page */
200static inline void STITSHOP_confirmBuy(ShopBuy *buy, ShopBuyWindows *win) {
201 s32 old;
202
203 old = buy->choice;
204 if (PAD_PRESSED(PAD_UP)) {
205 buy->choice = 0;
206 } else if (PAD_PRESSED(PAD_DOWN)) {
207 buy->choice = 1;
208 }
209 if (old != buy->choice) {
211 win->cursor->setPos(win->cursor, 0xB8, buy->choice * 0x10 + 0x49);
212 } else if (win->info->shown && PAD_PRESSED(PAD_CROSS)) {
214 buy->setSubstate(buy, 20);
215 if (buy->choice == 0) {
218 buy->step = 1;
219 }
220 if (GAME.items[buy->item] + buy->quantity >= 100) {
221 GAME.items[buy->item] = 99;
222 } else {
223 GAME.items[buy->item] += buy->quantity;
224 }
225 win->info->showItem(win->info, buy->item, buy->quantity);
226 GAME.money -= ITEM_FUNCS.get(buy->item)->price * buy->quantity;
227 buy->shop->showMoney(buy->shop);
228 }
229 } else if (PAD_PRESSED(PAD_TRIANGLE)) {
231 buy->setSubstate(buy, 20);
232 } else if (PAD_PRESSED(PAD_CIRCLE)) {
233 if (win->info->substate == 3) {
234 win->info->turnPage(win->info);
235 buy->substate = 18;
236 }
237 }
238}
239
240/* Once the total's panel has closed: asks whether to equip what was bought
241 when a partner of the party can, else goes back to the list */
242static inline void STITSHOP_endBuyTotal(ShopBuy *buy, ShopBuyWindows *win) {
243 s32 i;
244 s32 n;
245
246 if (STITSHOP_funcs.updateFade(&buy->panels[1]) != 0) {
247 if (buy->step != 0) {
248 for (i = 0, n = 0; i < 3; i++) {
250 n++;
251 }
252 }
253 if (n != 0) {
254 buy->setSubstate(buy, 25);
255 } else {
256 buy->substate = 10;
257 buy->step = 1;
258 }
259 } else {
260 buy->substate = 10;
261 buy->step = 1;
262 }
263 }
264}
265
266/* Yes or no to equipping what was bought: cross answers, triangle declines */
267static inline void STITSHOP_confirmEquip(ShopBuy *buy, ShopBuyWindows *win) {
268 s32 old;
269
270 old = buy->choice;
271 if (PAD_PRESSED(PAD_UP)) {
272 buy->choice = 0;
273 } else if (PAD_PRESSED(PAD_DOWN)) {
274 buy->choice = 1;
275 }
276 if (old != buy->choice) {
278 win->cursor->setPos(win->cursor, 0xB8, buy->choice * 0x10 + 0x49);
279 }
280 if (PAD_PRESSED(PAD_CROSS)) {
282 buy->nextSubstate(buy);
283 if (buy->choice == 0) {
284 buy->step = 1;
285 }
286 } else if (PAD_PRESSED(PAD_TRIANGLE)) {
288 buy->nextSubstate(buy);
289 }
290}
291
292/* The marker over the partner to equip: left/right move it to the next partner
293 who can equip the item, cross equips it on them and triangle gives up */
294static inline void STITSHOP_chooseEquipPartner(ShopBuy *buy, ShopBuyWindows *win) {
295 s32 old;
296 s32 partner;
297
298 old = buy->partner;
300 do {
301 if (--buy->partner < 0) {
302 buy->partner = 0;
303 break;
304 }
307 do {
308 if (++buy->partner > win->info->partyCount - 1) {
309 buy->partner = win->info->partyCount - 1;
310 break;
311 }
313 }
314 if (old != buy->partner) {
317 } else {
318 buy->partner = old;
319 }
320 } else if (PAD_PRESSED(PAD_CROSS)) {
322 partner = GAME.funcs.getPartyMember(buy->partner);
323 STITSHOP_funcs.equip(partner, STITSHOP_funcs.compareEquip(partner, buy->item), buy->item, 1);
324 win->info->refreshPartner(win->info, buy->partner);
325 buy->substate = 36;
326 } else if (PAD_PRESSED(PAD_TRIANGLE)) {
328 buy->substate++;
329 }
330}
331
332/* Closes the list and works out the most of the item that can be bought: what
333 the money pays for (an item priced 0 counts as 1), up to 99 in the bag */
334static inline void STITSHOP_startBuyQuantity(ShopBuy *buy, ShopBuyWindows *win) {
335 u16 price;
336
337 win->list->close(win->list);
338 price = ITEM_FUNCS.get(buy->item)->price;
339 if (price == 0) {
340 price = 1;
341 }
342 buy->max = GAME.money / price;
343 if (buy->max + GAME.items[buy->item] >= 100) {
344 buy->max = 99 - GAME.items[buy->item];
345 }
346 buy->substate++;
347}
348
349/* Once the total's panel has opened: shows the total with yes and no, the
350 cursor on yes */
351static inline void STITSHOP_openBuyTotal(ShopBuy *buy, ShopBuyWindows *win) {
352 if (STITSHOP_funcs.updateFade(&buy->panels[1]) != 0) {
353 STITSHOP_showBuyTotal(buy, win, 1);
354 buy->choice = 0;
355 win->cursor->setPos(win->cursor, 0xB8, 0x49);
356 win->cursor->setVisible(win->cursor, 1);
357 buy->substate++;
358 }
359}
360
361/* Once the question's panels have opened: asks whether to equip what was
362 bought, the cursor on yes */
363static inline void STITSHOP_openEquipQuestion(ShopBuy *buy, ShopBuyWindows *win) {
365 if (STITSHOP_funcs.updateFade(&buy->panels[2]) != 0) {
369 buy->choice = 0;
370 win->cursor->setPos(win->cursor, 0xB8, 0x49);
371 win->cursor->setVisible(win->cursor, 1);
372 buy->substate++;
373 }
374}
375
376/* Hides the question about equipping and closes its panel, and the message's
377 too when the answer was no */
378static inline void STITSHOP_closeEquipQuestion(ShopBuy *buy, ShopBuyWindows *win) {
379 win->total->setVisible(win->total, 0);
380 win->yes->setVisible(win->yes, 0);
381 win->no->setVisible(win->no, 0);
382 win->cursor->setVisible(win->cursor, 0);
383 STITSHOP_funcs.startFade(&buy->panels[1], 0);
384 if (buy->step == 0) {
385 STITSHOP_funcs.startFade(&buy->panels[2], 0);
386 }
387 buy->substate++;
388}
389
390/* Once the question's panel has closed: on yes goes on to pick the partner, on
391 no back to the list */
392static inline void STITSHOP_endEquipQuestion(ShopBuy *buy, ShopBuyWindows *win) {
393 if (buy->step == 0) {
395 }
396 if (STITSHOP_funcs.updateFade(&buy->panels[1]) != 0) {
397 if (buy->step != 0) {
398 buy->setSubstate(buy, 30);
399 } else {
400 buy->substate = 10;
401 buy->step = 1;
402 win->info->nextSubstate(win->info);
403 }
404 }
405}
406
407/* Once the message's panel has opened: shows the marker over the first partner
408 who can equip the item (or the last one picked) and asks who equips it */
409static inline void STITSHOP_showEquipMarker(ShopBuy *buy, ShopBuyWindows *win) {
410 if (STITSHOP_funcs.updateFade(&buy->panels[2]) != 0) {
411 if (buy->step == 0) {
412 for (buy->partner = 0; buy->partner < 3; buy->partner++) {
414 break;
415 }
416 }
417 }
418 buy->markerShown = 1;
420 buy->substate++;
421 }
422}
423
424/* Once the message that the item was equipped has closed: back to the list
425 when none is left in the bag, else to picking a partner again */
426static inline void STITSHOP_endEquipped(ShopBuy *buy, ShopBuyWindows *win) {
427 if (STITSHOP_funcs.updateFade(&buy->panels[3]) != 0) {
428 if (GAME.items[buy->item] <= 0) {
429 buy->substate = 35;
430 } else {
431 buy->substate = 30;
432 buy->step = 1;
433 }
434 }
435}
436
437/* The buying dialog: pick the item in the list, how many, confirm, then
438 (equipment) whether to equip it and on which partner */
440 switch (buy->substate) {
441 case 0:
442 default:
443 if (win->list == NULL) {
444 /* ShopBuy starts as a ShopDialog */
445 win->list = STITSHOP_createItemList((ShopDialog *)buy, buy->shop->shop, 0);
446 }
447 buy->substate++;
448 break;
449 case 1:
450 if (win->list->state == TASK_DONE) {
451 if (win->info == NULL) {
452 win->info = STITSHOP_createInfo(0, win->list->getSelected(win->list));
453 }
454 buy->substate++;
455 }
456 break;
457 case 2:
458 if (win->info->substate == 3) {
459 win->list->showCursor(win->list, 1);
460 buy->substate++;
461 }
462 break;
463 case 3:
464 STITSHOP_pickBuyItem(buy, win);
465 break;
466 case 4:
467 if (win->info->substate == 3) {
468 win->list->freezeCursor(win->list, 0);
469 buy->substate = 3;
470 }
471 break;
472 case 5:
474 break;
475 case 6:
476 if (win->list->state == TASK_DONE) {
477 STITSHOP_funcs.startFade(&buy->panels[0], 1);
478 buy->substate++;
479 }
480 break;
481 case 7:
482 if (STITSHOP_funcs.updateFade(&buy->panels[0]) != 0) {
483 STITSHOP_showQuantity(buy, win, 1);
484 buy->substate++;
485 }
486 break;
487 case 8:
489 break;
490 case 9:
491 STITSHOP_showQuantity(buy, win, 0);
492 STITSHOP_funcs.startFade(&buy->panels[0], 0);
493 buy->substate++;
494 break;
495 case 10:
496 if (STITSHOP_funcs.updateFade(&buy->panels[0]) != 0) {
497 if (buy->step != 0) {
498 win->list->start(win->list);
499 buy->nextSubstate(buy);
500 } else {
501 buy->substate = 15;
502 }
503 }
504 break;
505 case 11:
506 if (win->list->state == TASK_DONE) {
507 win->list->showCursor(win->list, 1);
508 buy->substate = 2;
509 }
510 break;
511 case 12:
512 if (win->info->substate == 3) {
513 buy->substate = 8;
514 }
515 break;
516 case 15:
517 STITSHOP_funcs.startFade(&buy->panels[1], 1);
518 buy->substate++;
519 break;
520 case 16:
521 STITSHOP_openBuyTotal(buy, win);
522 break;
523 case 17:
524 STITSHOP_confirmBuy(buy, win);
525 break;
526 case 18:
527 if (win->info->substate == 3) {
528 buy->substate = 17;
529 }
530 break;
531 case 20:
532 buy->quantity = 1;
533 win->info->showItem(win->info, buy->item, 1);
534 STITSHOP_showBuyTotal(buy, win, 0);
535 win->cursor->setVisible(win->cursor, 0);
536 STITSHOP_funcs.startFade(&buy->panels[1], 0);
537 buy->substate++;
538 break;
539 case 21:
540 STITSHOP_endBuyTotal(buy, win);
541 break;
542 case 25:
543 if (win->info->shown) {
544 win->info->nextSubstate(win->info);
545 STITSHOP_funcs.startFade(&buy->panels[1], 1);
546 STITSHOP_funcs.startFade(&buy->panels[2], 1);
547 buy->substate++;
548 }
549 break;
550 case 26:
552 break;
553 case 27:
554 STITSHOP_confirmEquip(buy, win);
555 break;
556 case 28:
558 break;
559 case 29:
561 break;
562 case 30:
563 STITSHOP_funcs.startFade(&buy->panels[2], 1);
564 buy->substate++;
565 break;
566 case 31:
567 STITSHOP_showEquipMarker(buy, win);
568 break;
569 case 32:
571 break;
572 case 33:
573 STITSHOP_funcs.startFade(&buy->panels[2], 0);
574 win->total->setVisible(win->total, 0);
575 buy->substate++;
576 break;
577 case 34:
578 if (STITSHOP_funcs.updateFade(&buy->panels[2]) != 0) {
579 buy->substate++;
580 }
581 break;
582 case 35:
583 buy->substate = 10;
584 buy->step = 1;
585 win->info->nextSubstate(win->info);
586 buy->markerShown = 0;
587 break;
588 case 36:
589 buy->markerShown = 0;
590 STITSHOP_funcs.startFade(&buy->panels[2], 0);
591 win->total->setVisible(win->total, 0);
592 buy->substate++;
593 break;
594 case 37:
595 if (STITSHOP_funcs.updateFade(&buy->panels[2]) != 0) {
596 STITSHOP_funcs.startFade(&buy->panels[3], 1);
597 buy->substate++;
598 }
599 break;
600 case 38:
601 if (STITSHOP_funcs.updateFade(&buy->panels[3]) != 0) {
603 buy->substate++;
604 }
605 break;
606 case 39:
607 if (PAD_PRESSED(PAD_CROSS)) {
609 STITSHOP_funcs.startFade(&buy->panels[3], 0);
610 win->total->setVisible(win->total, 0);
611 buy->substate++;
612 }
613 break;
614 case 40:
615 STITSHOP_endEquipped(buy, win);
616 break;
617 case 45:
618 STITSHOP_funcs.startFade(&buy->panels[2], 1);
619 win->list->freezeCursor(win->list, 1);
620 buy->substate++;
621 break;
622 case 46:
623 if (STITSHOP_funcs.updateFade(&buy->panels[2]) != 0) {
624 win->total->setVisible(win->total, 1);
625 buy->substate++;
626 }
627 break;
628 case 47:
631 win->total->setVisible(win->total, 0);
632 STITSHOP_funcs.startFade(&buy->panels[2], 0);
633 buy->substate++;
634 }
635 break;
636 case 48:
637 if (STITSHOP_funcs.updateFade(&buy->panels[2]) != 0) {
638 win->list->freezeCursor(win->list, 0);
639 buy->substate = 3;
640 }
641 break;
642 case 50:
643 if (win->info == NULL) {
644 buy->state = TASK_KILL;
645 }
646 break;
647 }
648}
649
650/* The buying dialog's task: creates its windows, starting at a quantity of 1,
651 then runs and draws it */
653 switch (buy->state) {
654 case TASK_INIT:
655 default:
656 buy->nextState(buy);
658 buy->panels[0].duration = 10;
659 buy->panels[1].duration = 10;
660 buy->panels[2].duration = 10;
661 buy->panels[3].duration = 10;
662 buy->quantity = 1;
663 break;
664 case TASK_RUN:
665 STITSHOP_runBuy(buy, win);
666 STITSHOP_drawBuy(buy, win);
667 break;
668 case TASK_DONE:
669 case TASK_KILL:
670 break;
671 }
672}
673
674/* Shows the item selected in the list, and the quantity, in the details panel
675 (buy->showItem) */
676void STITSHOP_showBuyItem(ShopBuy *buy, s32 item, s32 quantity) {
677 ShopBuyWindows *win = buy->children;
678
679 win->info->showItem(win->info, item, quantity);
680}
681
682/* Creates the buying dialog (task), when buy is chosen in the shop */
685
687 buy->layer = SCREEN_LAYER;
688 buy->depth = 4;
689 buy->shop = shop;
690 return buy;
691}
692
693/* Creates the selling dialog's windows: the cursor, the four kinds of sale, the
694 quantity, the total with its yes and no, and the message */
696 s32 i;
697
698 win->cursor = createCursor(sell->layer, sell->depth - 1, 0, 0xB0);
699 win->cursor->setVisible(win->cursor, 0);
700 for (i = 0; i < 4; i++) {
701 win->types[i] = createTextWindow(sell->layer, 1, 0xBE, i * 0xE + 0x2F);
702 }
703 win->quantityLabel = createTextWindow(sell->layer, 1, 0xB9, 0x3A);
704 win->times = createTextWindow(sell->layer, 1, 0x103, 0x54);
705 win->quantity = createTextWindow(sell->layer, 1, 0x11E, 0x54);
706 win->total = createTextWindow(sell->layer, 1, 0x9A, 0x2C);
707 win->yes = createTextWindow(sell->layer, 1, 0xC5, 0x49);
708 win->no = createTextWindow(sell->layer, 1, 0xC5, 0x59);
709 win->message = createTextWindow(sell->layer, 1, 0x9A, 0x8A);
710}
711
712/* Draws the selling screen's frames, and the quantity's blinking arrows */
714 SpriteDrawer sprite;
715
716 initSpriteDrawer(&sprite);
717 sprite.setTexture(0x280, 0x100);
718 if (sell->panels[3].level != 0) {
719 sprite.setLayerId(sell->layer, 1);
720 if (sell->panels[3].level != ONE) {
721 sprite.setScale(sell->panels[3].level, ONE, ONE);
722 sprite.setPivot(0x140, 0x41);
723 }
724 sprite.draw(FILE_CACHE.getEntry(FILE_SHOP_SPRITES << 16), 0xD, 0xA0, 0x24);
725 }
726 sprite.setLayerId(sell->layer, sell->depth);
727 if (sell->panels[0].level != 0) {
728 if (sell->panels[0].level != ONE) {
729 sprite.setScale(sell->panels[0].level, ONE, ONE);
730 sprite.setPivot(0x140, 0x4F);
731 }
732 sprite.draw(FILE_CACHE.getEntry(FILE_SHOP_SPRITES << 16), 4, 0xA9, 0x26);
733 }
734 if (sell->panels[1].level != 0) {
735 if (sell->panels[1].level != ONE) {
736 sprite.setScale(sell->panels[1].level, ONE, ONE);
737 sprite.setPivot(0x140, 0x42);
738 }
739 sprite.draw(FILE_CACHE.getEntry(FILE_SHOP_SPRITES << 16), 0xA, 0x9A, 0x34);
740 if (sell->panels[1].level != ONE) {
741 sprite.setPivot(0x140, 0x59);
742 } else {
743 if (GFX.funcs.getTime() - sell->blinkTime >= 9) {
744 sell->blinkTime = GFX.funcs.getTime();
745 sell->blink = 1 - sell->blink;
746 }
747 if (sell->blink) {
748 if (sell->quantity < sell->max) {
749 sprite.draw(FILE_CACHE.getEntry(FILE_SHOP_SPRITES << 16), 0x12, 0x122, 0x51);
750 }
751 if (sell->quantity >= 2) {
752 sprite.draw(FILE_CACHE.getEntry(FILE_SHOP_SPRITES << 16), 0x13, 0x122, 0x5B);
753 }
754 }
755 }
756 sprite.draw(FILE_CACHE.getEntry(FILE_SHOP_SPRITES << 16), 0xB, 0xF6, 0x4F);
757 }
758 if (sell->panels[2].level != 0) {
759 if (sell->panels[2].level != ONE) {
760 sprite.setScale(sell->panels[2].level, ONE, ONE);
761 sprite.setPivot(0x140, 0x32);
762 }
763 sprite.draw(FILE_CACHE.getEntry(FILE_SHOP_SPRITES << 16), 0x15, 0x7B, 0x26);
764 if (sell->panels[2].level != ONE) {
765 sprite.setPivot(0x140, 0x57);
766 }
767 sprite.draw(FILE_CACHE.getEntry(FILE_SHOP_SPRITES << 16), 0xC, 0xAF, 0x43);
768 }
769 if (sell->panels[4].level != 0) {
770 if (sell->panels[4].level != ONE) {
771 sprite.setScale(sell->panels[4].level, ONE, ONE);
772 sprite.setPivot(0x140, 0x8F);
773 }
774 sprite.draw(FILE_CACHE.getEntry(FILE_SHOP_SPRITES << 16), 0x15, 0x7B, 0x84);
775 }
776}
777
778/* Once the panel has opened: shows the four kinds of items to sell (items,
779 weapons, armor, accessories) and the cursor on the last one chosen */
780static inline void STITSHOP_openSellTypes(ShopSell *sell, ShopSellWindows *win) {
781 s32 i;
782
783 if (STITSHOP_funcs.updateFade(&sell->panels[0]) != 0) {
784 for (i = 0; i < 4; i++) {
785 win->types[i]->setString(win->types[i], FILE_CACHE.load(TEXT_FILE(TEXT_ITEM_SHOP)), i + 0x1D);
786 }
787 win->cursor->setPos(win->cursor, 0xB0, sell->type * 0xE + 0x2F);
788 win->cursor->setVisible(win->cursor, 1);
789 sell->substate++;
790 }
791}
792
793/* Up/down choose the kind of items to sell; cross lists the bag's items of
794 that kind, triangle closes the dialog */
795static inline void STITSHOP_chooseSellType(ShopSell *sell, ShopSellWindows *win) {
796 s32 old;
797
798 old = sell->type;
800 if (--sell->type < 0) {
801 sell->type = 0;
802 }
803 } else if (PAD_PRESSED(PAD_DOWN) || PAD_REPEATED(PAD_DOWN)) {
804 if (++sell->type >= 4) {
805 sell->type = 3;
806 }
807 }
808 if (old != sell->type) {
810 win->cursor->setPos(win->cursor, 0xB0, sell->type * 0xE + 0x2F);
811 }
812 if (PAD_PRESSED(PAD_CROSS)) {
814 win->cursor->setVisible(win->cursor, 0);
815 if (win->list != NULL) {
816 win->list->state = TASK_KILL;
817 }
818 sell->substate++;
819 } else if (PAD_PRESSED(PAD_TRIANGLE)) {
821 sell->setSubstate(sell, 50);
822 }
823}
824
825/* Once the quantity's panel has opened: shows how many to sell, up to all of
826 the item the bag holds */
827static inline void STITSHOP_openSellQuantity(ShopSell *sell, ShopSellWindows *win) {
828 if (STITSHOP_funcs.updateFade(&sell->panels[1]) != 0) {
831 win->quantity->setNumber(win->quantity, 0, sell->quantity);
832 win->quantity->setRightAlign(win->quantity, 1);
833 sell->item = win->list->getSelected(win->list);
834 sell->max = GAME.items[sell->item];
835 sell->substate++;
836 }
837}
838
839/* The quantity to sell: up/down change it by one, left/right by ten, up to
840 what the bag holds; cross goes on to the total, triangle back to the list */
841static inline void STITSHOP_chooseSellQuantity(ShopSell *sell, ShopSellWindows *win) {
842 s32 old;
843
844 old = sell->quantity;
846 sell->quantity++;
847 if (sell->quantity > sell->max) {
848 sell->quantity = sell->max;
849 }
850 } else if (PAD_PRESSED(PAD_DOWN) || PAD_REPEATED(PAD_DOWN)) {
851 if (--sell->quantity <= 0) {
852 sell->quantity = 1;
853 }
854 } else if (PAD_PRESSED(PAD_LEFT) || PAD_REPEATED(PAD_LEFT)) {
855 sell->quantity -= 10;
856 if (sell->quantity < 10) {
857 sell->quantity = 1;
858 }
860 sell->quantity += 10;
861 if (sell->quantity > sell->max) {
862 sell->quantity = sell->max;
863 }
864 }
865 if (old != sell->quantity) {
866 ITEM_FUNCS.get(sell->item); /* its result is unused */
867 win->quantity->setNumber(win->quantity, 0, sell->quantity);
868 win->quantity->setRightAlign(win->quantity, 1);
869 win->info->showItem(win->info, sell->item, sell->quantity);
871 }
872 if (PAD_PRESSED(PAD_CROSS)) {
874 sell->step = 0;
875 sell->substate++;
876 } else if (PAD_PRESSED(PAD_TRIANGLE)) {
878 sell->quantity = 1;
879 win->info->showItem(win->info, sell->item, 1);
880 sell->step = 1;
881 sell->substate++;
882 }
883}
884
885/* Hides the quantity and closes its panel, then goes on to the total, or back
886 to the list after triangle */
887static inline void STITSHOP_closeSellQuantity(ShopSell *sell, ShopSellWindows *win) {
888 STITSHOP_funcs.startFade(&sell->panels[1], 0);
890 win->times->setVisible(win->times, 0);
891 win->quantity->setVisible(win->quantity, 0);
892 if (sell->step != 0) {
893 win->list->start(win->list);
894 sell->substate++;
895 } else {
896 sell->setSubstate(sell, 30);
897 }
898}
899
900/* Once the total's panel has opened: shows what the items sell for with sell
901 and no, the cursor on sell */
902static inline void STITSHOP_openSellTotal(ShopSell *sell, ShopSellWindows *win) {
903 if (STITSHOP_funcs.updateFade(&sell->panels[2]) != 0) {
905 win->total->setNumber(win->total, 1, ITEM_FUNCS.get(sell->item)->sellPrice * sell->quantity);
908 sell->choice = 0;
909 win->cursor->setPos(win->cursor, 0xB8, 0x49);
910 win->cursor->setVisible(win->cursor, 1);
911 sell->substate++;
912 }
913}
914
915/* Sell or no to the total: sell takes the items from the bag and adds their
916 price to the money (up to 9999999); the list is refilled either way */
917static inline void STITSHOP_confirmSell(ShopSell *sell, ShopSellWindows *win) {
918 s32 old;
919
920 old = sell->choice;
921 if (PAD_PRESSED(PAD_UP)) {
922 sell->choice = 0;
923 } else if (PAD_PRESSED(PAD_DOWN)) {
924 sell->choice = 1;
925 }
926 if (old != sell->choice) {
928 win->cursor->setPos(win->cursor, 0xB8, sell->choice * 0x10 + 0x49);
929 } else if (PAD_PRESSED(PAD_CROSS)) {
931 if (sell->choice == 0) {
932 GAME.money += ITEM_FUNCS.get(sell->item)->sellPrice * sell->quantity;
933 if (GAME.money > 9999999) {
934 GAME.money = 9999999;
935 }
936 GAME.items[sell->item] -= sell->quantity;
937 if (GAME.items[sell->item] < 0) {
938 GAME.items[sell->item] = 0;
939 }
940 sell->shop->showMoney(sell->shop);
941 }
942 win->list->listBag(win->list);
943 sell->substate++;
944 } else if (PAD_PRESSED(PAD_TRIANGLE)) {
946 sell->substate++;
947 }
948}
949
950/* Hides the total and closes its panel; back to the kinds of items when none
951 of the kind is left, else back to the list */
952static inline void STITSHOP_closeSellTotal(ShopSell *sell, ShopSellWindows *win) {
953 STITSHOP_funcs.startFade(&sell->panels[2], 0);
954 win->total->setVisible(win->total, 0);
955 win->yes->setVisible(win->yes, 0);
956 win->no->setVisible(win->no, 0);
957 win->cursor->setVisible(win->cursor, 0);
958 if (win->list->count <= 0 && GAME.items[sell->item] == 0) {
959 sell->quantity = 1;
960 win->list->state = TASK_KILL;
961 win->info->close(win->info);
962 sell->substate = 39;
963 } else {
964 win->list->start(win->list);
965 sell->substate++;
966 }
967}
968
969/* Brings the list back while the total's panel closes: its cursor and page
970 move up when the last row sold out, and the details show the item now under
971 it; then back to the list */
972static inline void STITSHOP_reopenSellList(ShopSell *sell, ShopSellWindows *win) {
973 if (win->list == NULL) {
974 /* ShopSell starts as a ShopDialog */
975 win->list = STITSHOP_createItemList((ShopDialog *)sell, STITSHOP_sellLists[sell->type], 1);
976 } else if (win->list->substate == 100) {
977 win->list->substate = 1;
978 if (win->list->selection > win->list->count - 1) {
979 win->list->selection--;
980 }
981 if (win->list->page > win->list->pages - 1) {
982 win->list->page--;
983 }
984 sell->item = win->list->getSelected(win->list);
985 sell->quantity = 1;
986 win->info->showItem(win->info, sell->item, 1);
987 }
988 if (STITSHOP_funcs.updateFade(&sell->panels[2]) != 0) {
989 sell->substate = 26;
990 }
991}
992
993/* Hides the kinds of items and the cursor and closes their panel */
994static inline void STITSHOP_closeSellTypes(ShopSell *sell, ShopSellWindows *win) {
995 s32 i;
996
997 win->cursor->setVisible(win->cursor, 0);
998 for (i = 0; i < 4; i++) {
999 win->types[i]->setVisible(win->types[i], 0);
1000 }
1001 STITSHOP_funcs.startFade(&sell->panels[0], 0);
1002 sell->substate++;
1003}
1004
1005/* The selling dialog: pick the kind of item, then the item in the list, how
1006 many, and confirm */
1008 switch (sell->substate) {
1009 case 0:
1010 default:
1011 STITSHOP_funcs.startFade(&sell->panels[0], 1);
1012 sell->substate++;
1013 break;
1014 case 1:
1015 STITSHOP_openSellTypes(sell, win);
1016 break;
1017 case 2:
1018 STITSHOP_chooseSellType(sell, win);
1019 break;
1020 case 3:
1021 if (win->list == NULL) {
1022 /* ShopSell starts as a ShopDialog */
1023 win->list = STITSHOP_createItemList((ShopDialog *)sell, STITSHOP_sellLists[sell->type], 1);
1024 sell->substate++;
1025 } else {
1026 win->list->state = TASK_KILL;
1027 }
1028 break;
1029 case 4:
1030 if (win->list->substate == 100) {
1031 if (win->list->count > 0) {
1032 sell->setSubstate(sell, 50);
1033 sell->step = 1;
1034 } else {
1035 sell->substate = 200;
1036 }
1037 }
1038 break;
1039 case 100:
1040 win->list->substate = 1;
1041 sell->substate = 101;
1042 break;
1043 case 101:
1044 if (win->list->state == TASK_DONE) {
1045 if (win->info == NULL) {
1046 win->info = STITSHOP_createInfo(1, win->list->getSelected(win->list));
1047 }
1048 sell->substate = 5;
1049 }
1050 break;
1051 case 5:
1052 if (win->info->substate == 3) {
1053 win->list->showCursor(win->list, 1);
1054 sell->substate++;
1055 }
1056 break;
1057 case 6:
1058 if (PAD_PRESSED(PAD_CROSS)) {
1060 sell->substate = 20;
1061 } else if (PAD_PRESSED(PAD_TRIANGLE)) {
1063 win->list->close(win->list);
1064 win->info->close(win->info);
1065 sell->substate = 40;
1066 }
1067 break;
1068 case 20:
1069 win->list->close(win->list);
1070 sell->substate++;
1071 break;
1072 case 21:
1073 if (win->list->state == TASK_DONE) {
1074 STITSHOP_funcs.startFade(&sell->panels[1], 1);
1075 sell->substate++;
1076 }
1077 break;
1078 case 22:
1079 STITSHOP_openSellQuantity(sell, win);
1080 break;
1081 case 23:
1082 STITSHOP_chooseSellQuantity(sell, win);
1083 break;
1084 case 24:
1085 STITSHOP_closeSellQuantity(sell, win);
1086 break;
1087 case 25:
1088 if (win->list->substate == 100) {
1089 win->list->substate = 1;
1090 }
1091 if (STITSHOP_funcs.updateFade(&sell->panels[1]) != 0) {
1092 sell->substate++;
1093 }
1094 break;
1095 case 26:
1096 if (win->list->state == TASK_DONE) {
1097 win->list->showCursor(win->list, 1);
1098 sell->substate = 6;
1099 }
1100 break;
1101 case 30:
1102 if (STITSHOP_funcs.updateFade(&sell->panels[1]) != 0) {
1103 STITSHOP_funcs.startFade(&sell->panels[2], 1);
1104 sell->substate++;
1105 }
1106 break;
1107 case 31:
1108 STITSHOP_openSellTotal(sell, win);
1109 break;
1110 case 32:
1111 STITSHOP_confirmSell(sell, win);
1112 break;
1113 case 33:
1114 STITSHOP_closeSellTotal(sell, win);
1115 break;
1116 case 34:
1117 STITSHOP_reopenSellList(sell, win);
1118 break;
1119 case 39:
1120 if (STITSHOP_funcs.updateFade(&sell->panels[2]) != 0) {
1121 sell->substate = 40;
1122 }
1123 break;
1124 case 40:
1125 if (win->info == NULL) {
1126 sell->substate++;
1127 }
1128 break;
1129 case 41:
1130 sell->substate = 0;
1131 break;
1132 case 200:
1133 STITSHOP_funcs.startFade(&sell->panels[4], 1);
1134 sell->substate++;
1135 break;
1136 case 201:
1137 if (STITSHOP_funcs.updateFade(&sell->panels[4]) != 0) {
1139 win->message->setSubString(win->message, FILE_CACHE.load(TEXT_FILE(TEXT_ITEM_SHOP)), sell->type + 0x1D, 1);
1140 sell->substate++;
1141 }
1142 break;
1143 case 202:
1146 win->message->setVisible(win->message, 0);
1147 STITSHOP_funcs.startFade(&sell->panels[4], 0);
1148 sell->substate++;
1149 }
1150 break;
1151 case 203:
1152 if (STITSHOP_funcs.updateFade(&sell->panels[4]) != 0) {
1153 win->cursor->setVisible(win->cursor, 1);
1154 sell->substate = 2;
1155 }
1156 break;
1157 case 50:
1158 STITSHOP_closeSellTypes(sell, win);
1159 break;
1160 case 51:
1161 if (STITSHOP_funcs.updateFade(&sell->panels[0]) != 0) {
1162 if (sell->step != 0) {
1163 sell->setSubstate(sell, 100);
1164 } else {
1165 sell->state = TASK_KILL;
1166 }
1167 }
1168 break;
1169 }
1170}
1171
1172/* The selling dialog's task: creates its windows, starting at a quantity of 1,
1173 then runs and draws it */
1175 switch (sell->state) {
1176 case TASK_INIT:
1177 default:
1178 sell->nextState(sell);
1179 STITSHOP_createSellWindows(sell, win);
1180 sell->panels[0].duration = 10;
1181 sell->panels[1].duration = 10;
1182 sell->panels[2].duration = 10;
1183 sell->panels[3].duration = 10;
1184 sell->panels[4].duration = 10;
1185 sell->quantity = 1;
1186 break;
1187 case TASK_RUN:
1188 STITSHOP_runSell(sell, win);
1189 STITSHOP_drawSell(sell, win);
1190 break;
1191 case TASK_DONE:
1192 case TASK_KILL:
1193 break;
1194 }
1195}
1196
1197/* Shows the item selected in the list, and the quantity, in the details panel
1198 (sell->showItem) */
1199void STITSHOP_showSellItem(ShopSell *sell, s32 item, s32 quantity) {
1200 ShopSellWindows *win = sell->children;
1201
1202 win->info->showItem(win->info, item, quantity);
1203}
1204
1205/* Creates the selling dialog (task), when sell is chosen in the shop */
1208
1210 sell->layer = SCREEN_LAYER;
1211 sell->depth = 4;
1212 sell->shop = shop;
1213 return sell;
1214}
#define NULL
Definition common.h:17
signed int s32
Definition common.h:11
unsigned short u16
Definition common.h:10
GfxState GFX
GFX: the graphics state and its methods.
Definition display.c:209
GameState GAME
The save data, the game mode and the methods.
Definition state.c:64
#define TASK_RUN
Definition task.h:35
#define TASK_KILL
Definition task.h:37
#define TASK_INIT
Tasks: every game object is a task, a heap block that starts with this header and is updated once per...
Definition task.h:34
#define TASK_DONE
Definition task.h:36
Cursor * createCursor(s16 layerId, s32 depth, s16 x, s16 y)
A menu cursor on a layer at (x, y)
Definition cursor.c:92
#define TEXT_ITEM_SHOP
ITSHOP: STITSHOP's.
Definition file.h:216
#define TEXT_FILE(file)
Definition file.h:190
FileCache FILE_CACHE
The file cache.
Definition file_cache.c:7
#define ITEM_KIND_ACCESSORY
Definition game_state.h:222
#define ITEM_KIND_WEAPON
Definition game_state.h:220
#define ITEM_KIND_ARMOR
Definition game_state.h:221
#define STRETCH_SPRITE(sprite, level, x, y)
Definition gfx.h:273
#define SCREEN_LAYER
The layer over the whole screen that most modes create first and draw their menus on (FIELDSTG and ST...
Definition gfx.h:45
ShopInfo * STITSHOP_createInfo(s32 selling, s32 item)
Creates the details panel (task) of the item selected, when buying or selling.
Definition info.c:865
ShopItemList * STITSHOP_createItemList(ShopDialog *dialog, s32 type, s32 selling)
Creates the item list (task) of a dialog: the items of the shop type when buying, the bag's of the it...
Definition item_list.c:346
STITSHOP.PRO: the item shop.
#define FILE_SHOP_SPRITES
The shop's sprite sheet; the next file is its texture archive.
Definition item_shop.h:19
ItemFuncs ITEM_FUNCS
Definition items.c:890
#define PAD_CROSS
Definition pad.h:31
#define PAD_CIRCLE
Definition pad.h:30
#define PAD_DOWN
Definition pad.h:24
#define PAD_RIGHT
Definition pad.h:23
#define PAD_TRIANGLE
Definition pad.h:32
#define PAD_PRESSED(button)
One button of pad 1: newly pressed, auto-repeated while held, or held.
Definition pad.h:140
#define PAD_UP
Definition pad.h:22
#define PAD_LEFT
Definition pad.h:25
#define PAD_REPEATED(button)
Definition pad.h:141
SoundState SOUND
rsin and rcos (libgte) read rsin_tbl[a - 0x800] and the like: their addresses before the table fall i...
Definition sound.c:180
#define SOUND_MENU_CONFIRM
SYSTEM07.
Definition sound.h:44
#define SOUND_SELECT
Sounds the overlays share, with SOUNDTST's names.
Definition sound.h:38
#define SOUND_MENU_CANCEL
SYSTEM01.
Definition sound.h:39
#define SOUND_MENU_MOVE
SYSTEM06.
Definition sound.h:43
#define SOUND_CURSOR
SYSTEM02: a cursor moves.
Definition sound.h:40
void initSpriteDrawer(SpriteDrawer *obj)
Clears a sprite drawer to neutral (no scale, gray tint, follows the scroll), gives it its methods and...
s32 STITSHOP_sellLists[]
The item list each kind of sale shows.
Definition stitshop.c:6
ItemShopFuncs STITSHOP_funcs
The shop's helpers.
Definition stitshop.c:228
void(* setPos)()
(cursor, x, y)
Definition text.h:34
void(* setVisible)()
(cursor, visible)
Definition text.h:33
void *(* load)(u32 file)
Definition file.h:92
void *(* getEntry)(u32 fileAndIndex)
Definition file.h:96
s32(* getPartyMember)(u32 index)
Definition game_state.h:24
s8 items[0x193]
counts, up to 99
Definition game_state.h:512
GameFuncs funcs
Definition game_state.h:582
s32(* getTime)(void)
Definition gfx.h:31
GfxFuncs funcs
Definition gfx.h:77
s32(* isKind)(s32 item, s32 kind)
ItemInfo.kind == kind.
Definition game_state.h:672
struct ItemInfo *(* get)(s32 item)
getItem
Definition game_state.h:670
u16 sellPrice
0: cannot be sold
Definition game_state.h:228
void(* equip)(s32 partner, s32 slot, s32 item, s32 fromBag)
Definition item_shop.h:235
s32(* updateFade)(PanelAnim *fade)
Definition item_shop.h:229
void(* startFade)(PanelAnim *fade, s32 fadeIn)
Definition item_shop.h:228
s32(* compareEquip)(s32 partner, s32 item)
Definition item_shop.h:234
s32(* canEquip)(s32 partner, s32 item)
Definition item_shop.h:233
The main task of the shop (STITSHOP_createShop)
Definition item_shop.h:23
void(* showMoney)(struct ItemShop *shop)
Definition item_shop.h:32
s32 level
Definition menu.h:21
s32 duration
Definition menu.h:19
Cursor * cursor
Definition item_shop.h:183
TextWindow * times
Definition item_shop.h:178
TextWindow * total
Definition item_shop.h:180
ShopItemList * list
Definition item_shop.h:175
TextWindow * yes
Definition item_shop.h:181
TextWindow * quantity
Definition item_shop.h:179
TextWindow * no
Definition item_shop.h:182
TextWindow * quantityLabel
Definition item_shop.h:177
ShopInfo * info
Definition item_shop.h:176
The dialog to buy an item (STITSHOP_createBuy)
Definition item_shop.h:155
s32 blink
Definition item_shop.h:164
s32 layer
Definition item_shop.h:159
s32 max
Definition item_shop.h:163
void(* nextState)(struct ShopBuy *task)
Definition item_shop.h:156
s32 substate
Definition item_shop.h:156
void(* setSubstate)(struct ShopBuy *task, s32 substate)
Definition item_shop.h:156
PanelAnim panels[4]
Definition item_shop.h:171
s32 markerShown
Definition item_shop.h:168
s32 blinkTime
Definition item_shop.h:165
void(* showItem)(struct ShopBuy *buy, s32 item, s32 quantity)
Definition item_shop.h:157
s32 partner
the one the marker is over
Definition item_shop.h:167
void * children
Definition item_shop.h:156
s32 markerFrame
the marker's clut row, 0-7
Definition item_shop.h:169
s32 state
Definition item_shop.h:156
void(* nextSubstate)(struct ShopBuy *task)
Definition item_shop.h:156
s32 step
Definition item_shop.h:156
s32 markerTime
Definition item_shop.h:170
s32 item
Definition item_shop.h:161
struct ItemShop * shop
Definition item_shop.h:158
s32 quantity
Definition item_shop.h:162
s32 depth
Definition item_shop.h:160
s32 choice
Definition item_shop.h:166
What ShopBuy and ShopSell start with, and are passed to the item list as: the list shows its selectio...
Definition item_shop.h:110
void(* nextSubstate)(struct ShopInfo *task)
Definition item_shop.h:68
void(* turnPage)(struct ShopInfo *info)
Definition item_shop.h:83
void(* showItem)(struct ShopInfo *info, s32 item, s32 quantity)
Definition item_shop.h:80
void(* close)(struct ShopInfo *info)
Definition item_shop.h:81
s32 partyCount
Definition item_shop.h:73
s32 substate
Definition item_shop.h:68
s32 shown
Definition item_shop.h:78
void(* refreshPartner)(struct ShopInfo *info, s32 member)
Definition item_shop.h:84
void(* freezeCursor)(struct ShopItemList *list, s32 frozen)
Definition item_shop.h:139
void(* close)(struct ShopItemList *list)
Definition item_shop.h:136
void(* showCursor)(struct ShopItemList *list, s32 visible)
Definition item_shop.h:138
void(* start)(struct ShopItemList *list)
Definition item_shop.h:135
void(* listBag)(struct ShopItemList *list)
Definition item_shop.h:141
s32(* getSelected)(struct ShopItemList *list)
Definition item_shop.h:137
TextWindow * message
Definition item_shop.h:214
Cursor * cursor
Definition item_shop.h:206
TextWindow * types[4]
Definition item_shop.h:207
ShopItemList * list
Definition item_shop.h:204
TextWindow * quantityLabel
Definition item_shop.h:208
ShopInfo * info
Definition item_shop.h:205
TextWindow * yes
Definition item_shop.h:212
TextWindow * quantity
Definition item_shop.h:210
TextWindow * times
Definition item_shop.h:209
TextWindow * no
Definition item_shop.h:213
TextWindow * total
Definition item_shop.h:211
The dialog to sell an item (STITSHOP_createSell)
Definition item_shop.h:187
void(* nextState)(struct ShopSell *task)
Definition item_shop.h:188
struct ItemShop * shop
Definition item_shop.h:190
s32 depth
Definition item_shop.h:192
s32 layer
Definition item_shop.h:191
s32 choice
Definition item_shop.h:199
s32 state
Definition item_shop.h:188
s32 quantity
Definition item_shop.h:195
void * children
Definition item_shop.h:188
s32 blinkTime
Definition item_shop.h:198
void(* showItem)(struct ShopSell *sell, s32 item, s32 quantity)
Definition item_shop.h:189
void(* setSubstate)(struct ShopSell *task, s32 substate)
Definition item_shop.h:188
PanelAnim panels[5]
Definition item_shop.h:200
s32 substate
Definition item_shop.h:188
s32 blink
the quantity's arrows are shown
Definition item_shop.h:197
short(* playSound)(s32 id)
returns the voice of a key-on
Definition sound.h:187
Draws sprites from a sprite sheet (such as file 0x277, the menu graphics): a sheet has a table of fra...
Definition gfx.h:223
void(* setPivot)()
(x, y)
Definition gfx.h:250
void(* setScale)()
(x, y, z), ONE = 1.0
Definition gfx.h:248
void(* setLayerId)()
(id, depth)
Definition gfx.h:244
void(* setClutRow)()
(row)
Definition gfx.h:247
void(* draw)()
(sheet, frame, x, y)
Definition gfx.h:246
void(* setTexture)()
(x, y)
Definition gfx.h:242
void(* setRightAlign)()
no prototype: callers would truncate u8 args
Definition text.h:178
void(* setSubString)()
Definition text.h:168
void(* setNumber)()
Definition text.h:166
void(* setString)()
Definition text.h:165
void(* setVisible)(struct TextWindow *obj, u8 arg)
Definition text.h:177
void * createTask(void(*update)(), s32 size, s32 childrenSize)
createTaskWithId for a task nothing needs to find
Definition task.c:105
TextWindow * createTextWindow(s16 layerId, s16 style, s16 x, s16 y)
A text window on a layer, in a font style, at (x, y)
static void STITSHOP_openSellQuantity(ShopSell *sell, ShopSellWindows *win)
Once the quantity's panel has opened: shows how many to sell, up to all of the item the bag holds.
Definition trade.c:827
void STITSHOP_createBuyWindows(ShopBuy *buy, ShopBuyWindows *win)
Creates the buying dialog's windows: the quantity, the total with its yes and no, and the cursor.
Definition trade.c:8
static void STITSHOP_chooseBuyQuantity(ShopBuy *buy, ShopBuyWindows *win)
The quantity to buy: up/down change it by one, left/right by ten, up to what the money and the bag's ...
Definition trade.c:114
void STITSHOP_updateBuy(ShopBuy *buy, ShopBuyWindows *win)
The buying dialog's task: creates its windows, starting at a quantity of 1, then runs and draws it.
Definition trade.c:652
ShopSell * STITSHOP_createSell(ItemShop *shop)
Creates the selling dialog (task), when sell is chosen in the shop.
Definition trade.c:1206
void STITSHOP_runSell(ShopSell *sell, ShopSellWindows *win)
The selling dialog: pick the kind of item, then the item in the list, how many, and confirm.
Definition trade.c:1007
static void STITSHOP_confirmBuy(ShopBuy *buy, ShopBuyWindows *win)
Yes or no to the total: yes buys the items (at most 99 in the bag) and pays for them,...
Definition trade.c:200
void STITSHOP_createSellWindows(ShopSell *sell, ShopSellWindows *win)
Creates the selling dialog's windows: the cursor, the four kinds of sale, the quantity,...
Definition trade.c:695
void STITSHOP_showQuantity(ShopBuy *buy, ShopBuyWindows *win, s32 show)
Shows the quantity to buy; or hides it.
Definition trade.c:20
static void STITSHOP_chooseEquipPartner(ShopBuy *buy, ShopBuyWindows *win)
The marker over the partner to equip: left/right move it to the next partner who can equip the item,...
Definition trade.c:294
static void STITSHOP_endEquipped(ShopBuy *buy, ShopBuyWindows *win)
Once the message that the item was equipped has closed: back to the list when none is left in the bag...
Definition trade.c:426
static void STITSHOP_confirmSell(ShopSell *sell, ShopSellWindows *win)
Sell or no to the total: sell takes the items from the bag and adds their price to the money (up to 9...
Definition trade.c:917
void STITSHOP_drawBuy(ShopBuy *buy, ShopBuyWindows *win)
Draws the buying screen's frames, the quantity's blinking arrows and the marker over a partner.
Definition trade.c:49
static void STITSHOP_openSellTypes(ShopSell *sell, ShopSellWindows *win)
Once the panel has opened: shows the four kinds of items to sell (items, weapons, armor,...
Definition trade.c:780
void STITSHOP_drawSell(ShopSell *sell, ShopSellWindows *win)
Draws the selling screen's frames, and the quantity's blinking arrows.
Definition trade.c:713
void STITSHOP_updateSell(ShopSell *sell, ShopSellWindows *win)
The selling dialog's task: creates its windows, starting at a quantity of 1, then runs and draws it.
Definition trade.c:1174
static void STITSHOP_pickBuyItem(ShopBuy *buy, ShopBuyWindows *win)
The item list: cross picks the item under the cursor, unless the bag holds 99 of it or the money is s...
Definition trade.c:167
static void STITSHOP_confirmEquip(ShopBuy *buy, ShopBuyWindows *win)
Yes or no to equipping what was bought: cross answers, triangle declines.
Definition trade.c:267
static void STITSHOP_reopenSellList(ShopSell *sell, ShopSellWindows *win)
Brings the list back while the total's panel closes: its cursor and page move up when the last row so...
Definition trade.c:972
void STITSHOP_runBuy(ShopBuy *buy, ShopBuyWindows *win)
The buying dialog: pick the item in the list, how many, confirm, then (equipment) whether to equip it...
Definition trade.c:439
static void STITSHOP_startBuyQuantity(ShopBuy *buy, ShopBuyWindows *win)
Closes the list and works out the most of the item that can be bought: what the money pays for (an it...
Definition trade.c:334
static void STITSHOP_openBuyTotal(ShopBuy *buy, ShopBuyWindows *win)
Once the total's panel has opened: shows the total with yes and no, the cursor on yes.
Definition trade.c:351
static void STITSHOP_chooseSellQuantity(ShopSell *sell, ShopSellWindows *win)
The quantity to sell: up/down change it by one, left/right by ten, up to what the bag holds; cross go...
Definition trade.c:841
static void STITSHOP_closeSellQuantity(ShopSell *sell, ShopSellWindows *win)
Hides the quantity and closes its panel, then goes on to the total, or back to the list after triangl...
Definition trade.c:887
static void STITSHOP_endEquipQuestion(ShopBuy *buy, ShopBuyWindows *win)
Once the question's panel has closed: on yes goes on to pick the partner, on no back to the list.
Definition trade.c:392
void STITSHOP_showBuyItem(ShopBuy *buy, s32 item, s32 quantity)
Shows the item selected in the list, and the quantity, in the details panel (buy->showItem)
Definition trade.c:676
static void STITSHOP_openSellTotal(ShopSell *sell, ShopSellWindows *win)
Once the total's panel has opened: shows what the items sell for with sell and no,...
Definition trade.c:902
static void STITSHOP_closeSellTotal(ShopSell *sell, ShopSellWindows *win)
Hides the total and closes its panel; back to the kinds of items when none of the kind is left,...
Definition trade.c:952
static void STITSHOP_showEquipMarker(ShopBuy *buy, ShopBuyWindows *win)
Once the message's panel has opened: shows the marker over the first partner who can equip the item (...
Definition trade.c:409
static void STITSHOP_closeEquipQuestion(ShopBuy *buy, ShopBuyWindows *win)
Hides the question about equipping and closes its panel, and the message's too when the answer was no...
Definition trade.c:378
ShopBuy * STITSHOP_createBuy(ItemShop *shop)
Creates the buying dialog (task), when buy is chosen in the shop.
Definition trade.c:683
void STITSHOP_showBuyTotal(ShopBuy *buy, ShopBuyWindows *win, s32 show)
Shows the total price with yes and no to confirm the purchase; or hides them.
Definition trade.c:34
static void STITSHOP_chooseSellType(ShopSell *sell, ShopSellWindows *win)
Up/down choose the kind of items to sell; cross lists the bag's items of that kind,...
Definition trade.c:795
static void STITSHOP_openEquipQuestion(ShopBuy *buy, ShopBuyWindows *win)
Once the question's panels have opened: asks whether to equip what was bought, the cursor on yes.
Definition trade.c:363
void STITSHOP_showSellItem(ShopSell *sell, s32 item, s32 quantity)
Shows the item selected in the list, and the quantity, in the details panel (sell->showItem)
Definition trade.c:1199
static void STITSHOP_endBuyTotal(ShopBuy *buy, ShopBuyWindows *win)
Once the total's panel has closed: asks whether to equip what was bought when a partner of the party ...
Definition trade.c:242
static void STITSHOP_closeSellTypes(ShopSell *sell, ShopSellWindows *win)
Hides the kinds of items and the cursor and closes their panel.
Definition trade.c:994