Skip to Content
The Alchemy Project

src/shop/shop_item_picker.c

The forge's counter; the item picker scripts use to choose one of a party member's items, to show Naribwe's fortune teller or to drop; and the grid of item icons the shop's windows draw. More…

Included by shop.c.

Macros

NameDescription
#defineITEM_PICKER_PRICE_WINDOW_X BY_LANGUAGE(16, 14, 13, 14, 14, 14)The price window's place and width, in tiles, fitted to its edition's text.
#defineITEM_PICKER_PRICE_WINDOW_WIDTH BY_LANGUAGE(14, 16, 17, 16, 16, 16)
#defineITEM_PICKER_DETAILS_WINDOW_WIDTH BY_LANGUAGE(13, 16, 18, 18, 16, 18)The item details window's width, in tiles, fitted to its edition's text.
#defineSHOP_PRICE_NOTE_X JAPANESE_OR(8, 0)The note sits under the item's name; the price line reads "Price", the price, then "Coins".
#defineITEM_PICKER_PRICE_NUMBER_X BY_LANGUAGE(32, 40, 40, 40, 32, 40)
#defineSHOP_PRICE_COINS_X BY_LANGUAGE(72, 80, 80, 88, 72, 80)

Functions

NameDescription
Sint32mnForgeRun (Sint32 actorId)Runs the forge: the smith's line, then a party member's materials to forge, until the player leaves.
Sint32mnForgeChooseMember (void)Runs the forge's party member choice, the sell counter's.
Sint32mnForgeSelectItem (Sint32 unitId)Lets the player choose the party member's item to forge, on the sell counter's grid.
Sint32mnForgeOfferItem (Sint32 unitId, Sint32 slot)The forge's offer for one inventory item: refuses an item it has no recipe for, otherwise asks (a rusted weapon takes its own lines), and on yes takes the item, redraws the grid and stores the rolled result.
Sint32mnItemPickerRunToShow (Sint32 *selectedUnit, Sint32 *selectedSlot)Runs the item picker for an item to show, refusing one that cannot be unequipped: Naribwe's fortune teller reads the party's fortune from it.
Sint32mnItemPickerRunToDrop (Sint32 *selectedUnit, Sint32 *selectedSlot)Runs the item picker for an item to drop, showing each item's sale price.
Sint32mnItemPickerRun (Sint32 *selectedUnit, Sint32 *selectedSlot, Sint32 itemMode)Lets the player choose a party member, then one of its items, four party members a page, returning the unit and slot through the pointers (both -1 when cancelled).
Sint32mnItemPickerSelectItem (Sint32 unitId)Lets the player choose one of the party member's items, refusing with a message one that cannot be dropped or removed (gmInventoryCheckDiscard or gmInventoryCheckUnequip, by the picker's mode).
voidmnItemPickerDrawItem (WINDOW *window, Sint32 unitId, Sint32 slot)Draws the slot's item name and, below it, why it cannot be dropped or removed, or, for an item to drop, what the whole stack would sell for.
voidmnItemIconGridDraw (void)Queues each loaded icon's sprite while the grid is visible.
voidmnItemIconGridInit (void)Empties the grid, hides it and starts its drawing event.
voidmnItemIconGridRelease (void)Stops the drawing event and frees the icons' VRAM cache entries.
voidmnItemIconGridSetPos (Sint32 index, Sint32 x, Sint32 y)Places icon index at (x, y) screen pixels.
voidmnItemIconGridSetVisible (Sint32 visible)Shows the grid (1) or hides it (0).
voidmnItemIconGridLoadItems (Uint16 *items, Sint32 count, Sint32 mode)Releases the item icons' VRAM entries, then loads the icons of up to count items with the ICON_ layers in mode (an empty item keeps its old entry) and gives each its sprite attributes and tile.
voidmnItemIconGridShowInventory (WINDOW *window, Sint32 x, Sint32 y, Sint32 unitId)Shows a party member's INVENTORY_SLOTS inventory icons at (x, y) pixels inside window, SHOP_INVENTORY_COLUMNS to a row, 16 pixels apart.

Description

The forge's counter; the item picker scripts use to choose one of a party member's items, to show Naribwe's fortune teller or to drop; and the grid of item icons the shop's windows draw. Part of shop.c.

Macros in detail

ITEM_PICKER_PRICE_WINDOW_X

#define ITEM_PICKER_PRICE_WINDOW_X BY_LANGUAGE(16, 14, 13, 14, 14, 14)

The price window's place and width, in tiles, fitted to its edition's text.

Referenced by mnItemPickerSelectItem().

Definition at line 222 of file shop_item_picker.c.

ITEM_PICKER_PRICE_WINDOW_WIDTH

#define ITEM_PICKER_PRICE_WINDOW_WIDTH BY_LANGUAGE(14, 16, 17, 16, 16, 16)

Referenced by mnItemPickerSelectItem().

Definition at line 223 of file shop_item_picker.c.

ITEM_PICKER_DETAILS_WINDOW_WIDTH

#define ITEM_PICKER_DETAILS_WINDOW_WIDTH BY_LANGUAGE(13, 16, 18, 18, 16, 18)

The item details window's width, in tiles, fitted to its edition's text.

Referenced by mnItemPickerSelectItem().

Definition at line 226 of file shop_item_picker.c.

SHOP_PRICE_NOTE_X

#define SHOP_PRICE_NOTE_X JAPANESE_OR(8, 0)

The note sits under the item's name; the price line reads "Price", the price, then "Coins". Japanese indents the note by 8 pixels; Japanese and French draw the price and the coins label 8 pixels further left, Spanish the coins label 8 pixels further right.

Referenced by mnItemPickerDrawItem().

Definition at line 390 of file shop_item_picker.c.

ITEM_PICKER_PRICE_NUMBER_X

#define ITEM_PICKER_PRICE_NUMBER_X BY_LANGUAGE(32, 40, 40, 40, 32, 40)

Referenced by mnItemPickerDrawItem().

Definition at line 391 of file shop_item_picker.c.

SHOP_PRICE_COINS_X

#define SHOP_PRICE_COINS_X BY_LANGUAGE(72, 80, 80, 88, 72, 80)

Referenced by mnItemPickerDrawItem().

Definition at line 392 of file shop_item_picker.c.

Functions in detail

mnForgeRun

Sint32 mnForgeRun(Sint32 actorId)

Runs the forge: the smith's line, then a party member's materials to forge, until the player leaves. actorId is the actor whose portrait the messages show. Called through the stub table; returns 0.

References fdActorGetByIdStub(), mnCursorSetPosImmediate(), mnForgeChooseMember(), mnPortraitOpenWindowStub(), mnShopInitState(), mnShopReleaseState(), mnShopShowKeeperMessage(), mnWindowCloseStub(), mnWindowSpriteCreateStub(), result and Sint32.

Referenced by dbShopTestTalkToSunshine() and scYallamRoomsTalkToSunshine().

Definition at line 8 of file shop_item_picker.c.

mnForgeChooseMember

Sint32 mnForgeChooseMember(void)

Runs the forge's party member choice, the sell counter's.

References mnShopChooseMember() and Sint32.

Referenced by mnForgeRun().

Definition at line 46 of file shop_item_picker.c.

mnForgeSelectItem

Sint32 mnForgeSelectItem(Sint32 unitId)

Lets the player choose the party member's item to forge, on the sell counter's grid.

References mnShopSelectSell() and Sint32.

Referenced by mnShopChooseMember().

Definition at line 53 of file shop_item_picker.c.

mnForgeOfferItem

Sint32 mnForgeOfferItem(Sint32 unitId, Sint32 slot)

The forge's offer for one inventory item: refuses an item it has no recipe for, otherwise asks (a rusted weapon takes its own lines), and on yes takes the item, redraws the grid and stores the rolled result. Returns 0 when the item was taken, else -1.

References gmInventoryRemoveStub(), gmUnitGet(), mnForgeGetItemCondition(), mnForgeRollResult(), mnForgeSetItem(), mnMessageArgumentPushStub(), mnShopAskYesNo(), mnShopDrawMemberItems(), mnShopShowKeeperMessageHidingCursor(), result and Sint32.

Referenced by mnShopSelectSell().

Definition at line 62 of file shop_item_picker.c.

mnItemPickerRunToShow

Sint32 mnItemPickerRunToShow(Sint32 *selectedUnit, Sint32 *selectedSlot)

Runs the item picker for an item to show, refusing one that cannot be unequipped: Naribwe's fortune teller reads the party's fortune from it.

References mnItemPickerRun() and Sint32.

Referenced by dbShopTestOpenItemPicker() and scNaribweRoomsReadFortune().

Definition at line 113 of file shop_item_picker.c.

mnItemPickerRunToDrop

Sint32 mnItemPickerRunToDrop(Sint32 *selectedUnit, Sint32 *selectedSlot)

Runs the item picker for an item to drop, showing each item's sale price.

References mnItemPickerRun() and Sint32.

Referenced by dbPsynergyTestOpenItemPicker() and scDailaRoomsGiveItem().

Definition at line 119 of file shop_item_picker.c.

mnItemPickerRun

Sint32 mnItemPickerRun(Sint32 *selectedUnit, Sint32 *selectedSlot, Sint32 itemMode)

Lets the player choose a party member, then one of its items, four party members a page, returning the unit and slot through the pointers (both -1 when cancelled). itemMode is what the item is for (ITEM_PICKER_MODE). Holds the shop's state while it runs.

References gmInventoryCountStub(), mnCreatePartyFiguresStub(), mnCursorPlace(), mnCursorSetPosImmediate(), mnGridMoveCursor(), mnItemPickerSelectItem(), mnReleasePartyFiguresStub(), mnShopDrawMemberItems(), mnShopDrawParty(), mnShopInitState(), mnShopReleaseState(), mnShowPartyFiguresStub(), mnWindowCloseStub(), mnWindowCreateStub(), mnWindowSpriteCreateStub(), mnWindowSpritePrepareForRedrawStub(), PerWork, result, Sint32, sySoundPlayStub() and sySynch().

Referenced by mnItemPickerRunToDrop() and mnItemPickerRunToShow().

Definition at line 128 of file shop_item_picker.c.

mnItemPickerSelectItem

Sint32 mnItemPickerSelectItem(Sint32 unitId)

Lets the player choose one of the party member's items, refusing with a message one that cannot be dropped or removed (gmInventoryCheckDiscard or gmInventoryCheckUnequip, by the picker's mode). Returns the slot, or -1 when cancelled.

References gmInventoryCheckDiscardStub(), gmInventoryCheckUnequipStub(), gmInventoryCountStub(), gmUnitGet(), mnCursorPlace(), mnItemMenuDrawItemDetailsStub(), mnItemPickerDrawItem(), mnMessageAllTypedStub(), mnMessageCloseFinishedWindowsStub(), mnMessageOpenWindowStub(), mnShopDrawMemberItems(), mnShopDrawMessage(), mnWindowCloseStub(), mnWindowCreateStub(), mnWindowSpritePrepareForRedrawStub(), PerWork, result, Sint32, sySoundPlayStub() and sySynch().

Referenced by mnItemPickerRun().

Definition at line 232 of file shop_item_picker.c.

mnItemPickerDrawItem

void mnItemPickerDrawItem(WINDOW *window, Sint32 unitId, Sint32 slot)

Draws the slot's item name and, below it, why it cannot be dropped or removed, or, for an item to drop, what the whole stack would sell for. Called by mnItemPickerSelectItem each time the cursor moves.

References gmInventoryCheckDiscardStub(), gmInventoryCheckUnequipStub(), gmUnitGet(), mnShopSalePrice(), mnTextDrawMessageAsTilesStub(), mnTextDrawNumberInWindowStub(), mnWindowSpriteRedrawSavedRectStub() and Sint32.

Referenced by mnItemPickerSelectItem().

Definition at line 397 of file shop_item_picker.c.

mnItemIconGridDraw

void mnItemIconGridDraw(void)

Queues each loaded icon's sprite while the grid is visible. Runs every tick as an event.

References Sint32 and syOAMAddSpriteAtDepth().

Referenced by mnItemIconGridInit() and mnItemIconGridRelease().

Definition at line 445 of file shop_item_picker.c.

mnItemIconGridInit

void mnItemIconGridInit(void)

Empties the grid, hides it and starts its drawing event.

References mnItemIconGridDraw(), Sint32 and sySetEvent().

Referenced by mnShopInitState().

Definition at line 465 of file shop_item_picker.c.

mnItemIconGridRelease

void mnItemIconGridRelease(void)

Stops the drawing event and frees the icons' VRAM cache entries.

References mnItemIconGridDraw(), Sint32, syCloseEvent() and syVRAMCacheFreeEntry().

Referenced by mnShopReleaseState().

Definition at line 480 of file shop_item_picker.c.

mnItemIconGridSetPos

void mnItemIconGridSetPos(Sint32 index, Sint32 x, Sint32 y)

Places icon index at (x, y) screen pixels.

References Sint32.

Referenced by mnItemIconGridShowInventory().

Definition at line 494 of file shop_item_picker.c.

mnItemIconGridSetVisible

void mnItemIconGridSetVisible(Sint32 visible)

Shows the grid (1) or hides it (0).

References Sint32.

Referenced by mnItemIconGridShowInventory(), mnShopChooseMember() and mnShopSelectBuy().

Definition at line 503 of file shop_item_picker.c.

mnItemIconGridLoadItems

void mnItemIconGridLoadItems(Uint16 *items, Sint32 count, Sint32 mode)

Releases the item icons' VRAM entries, then loads the icons of up to count items with the ICON_ layers in mode (an empty item keeps its old entry) and gives each its sprite attributes and tile.

References mnItemIconLoadLayersIntoSlotStub(), Sint32, syVRAMCacheFindFreeEntry(), syVRAMCacheFreeEntry() and VramCacheEntries.

Referenced by mnItemIconGridShowInventory().

Definition at line 513 of file shop_item_picker.c.

mnItemIconGridShowInventory

void mnItemIconGridShowInventory(WINDOW *window, Sint32 x, Sint32 y, Sint32 unitId)

Shows a party member's INVENTORY_SLOTS inventory icons at (x, y) pixels inside window, SHOP_INVENTORY_COLUMNS to a row, 16 pixels apart.

References gmUnitGet(), mnItemIconGridLoadItems(), mnItemIconGridSetPos(), mnItemIconGridSetVisible() and Sint32.

Referenced by mnShopDrawCarriedItem() and mnShopDrawMemberItems().

Definition at line 551 of file shop_item_picker.c.