Skip to content

Add the Shop extension (shop dialog, shop item, currency counter) - #2386

Open
4ian wants to merge 1 commit into
mainfrom
claude/dreamy-mendel-iw5mn6-shop
Open

4ian wants to merge 1 commit into
mainfrom
claude/dreamy-mendel-iw5mn6-shop

Conversation

@4ian

@4ian 4ian commented Nov 28, 2026 •

Copy link
Copy Markdown
Collaborator

A shop for any game: upgrades with levels, items bought once or again and again, skins to equip, locked items, several currencies, from 1 or 2 items to hundreds. Events only.

Shops in 15 styles

Three custom objects, nested

  • Shop dialog: title, money counters, category tabs, and a scrolling list or grid of items.
    • The list is clipped with SpriteMasking and has a scrollbar (the Scrollbar extension).
    • It works with the mouse, touch (drag to scroll), keyboard and gamepad.
  • Shop item: one row or card: icon, title, description, level pips (or "3/20", "x3"), and a price button (a PanelSpriteButton).
    • Its states are shown in it: locked (padlock and text), too expensive (grey button), owned, maximum level, "Equip", "Equipped".
    • It can be used alone, as a single item to buy.
  • Currency counter: an icon and an amount that counts up or down. The shop has one per currency, and it can be used alone in any HUD.

The list and grid layouts are not two objects: they are two variants of the same shop dialog. The item placed in the variant is the model of every item (a wide row, or a card with Columns: 4). The model tab and counter work the same way.

Simple API (for humans and AI agents)

1. Fill the shop

  • "Add an item": identifier, title, description, price, icon (20 generic names: Heart, Shield, Magnet, Potion...), category.
    • The same identifier updates the item, so running it again is safe.
  • Optional actions per item:
    • Maximum level (1: bought once; more: an upgrade; 0: bought again and again);
    • Price multiplier per level, Level;
    • Currency ("Coins", "Gems"...);
    • Lock (with a text like "Reach level 5");
    • Can be equipped, Equip;
    • Icon image (any image of the game), Remove.
  • "Add items from a variable": an array of structures (Id, Title, Description, Price, Icon, Category, and optionally MaxLevel, PriceMultiplier, Level, Currency, IsLocked, LockedText, CanBeEquipped, IsEquipped). This is how 100 items are added.

2. Money

  • "Money" (currency, amount), and the expression Money("Coins").

3. React to what happens (one-frame conditions)

  • "An item was bought" (or "Item X was bought"), with Bought item, Price, Currency, Level.
  • "A purchase failed", with Failed item and Failure reason (Locked or NotEnoughMoney).
  • "An item was equipped".
  • "Was closed by the player".

4. Query

  • Item level, price, state (Buy, TooExpensive, Locked, Owned, Max, Equip, Equipped), icon, title.
  • Is owned, at maximum level, locked, equipped; Equipped item of a category; Number of items.

5. Purchases

  • Automatic (the shop takes the money and gives the item), or Confirmed by events: "A purchase is requested", then "Complete a purchase". This is for a confirmation dialog or a real-money purchase.
  • "Buy an item (like the player)" does what the button does.

6. Saving

  • "Save the items in a variable" and "Load the items from a variable" (the levels and the equipped items).

Categories and navigation

  • Tabs are created from the categories (or from the "Categories" property, for their order).
  • Arrows choose an item; Enter, Space or A buys; Q/E, Page Up/Down, LB/RB or left/right in a list change the tab; Escape or B closes.
  • "Show a category", "Focus an item" (scrolls to it).

Layout

  • Columns, spacing.
  • "Shrink to the items": a shop with 2 items is short, and a shop with 100 scrolls.
  • Without tabs, the list takes their place. The shop can be made taller or shorter.

Also a Shop::FormatNumber(number, separator) expression (1,250 / 1.250 / 1 250).

Tests

Gameplay tests in GDevelop.

With the default objects:

  • items, money, tabs;
  • buying with Enter and with a touch; the price doubling per level;
  • locked and too expensive items;
  • equipping skins, and switching back for free;
  • saving; Escape;
  • 100 items from a variable in a 3-column grid, scrolled to the last one.

With the art of the 15 styles (GDevelop-assets#780), and in the "Shop" example (GDevelopApp/GDevelop-examples#1138), which has 5 tests.

npm run build, npm test and npm run check-post-build pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants