Add shop components 436-450; Odometer exact at 15 fps
Fifteen shop components: PriceTag, Wallet, ShopItem, Cart, Receipt, Checkout, CurrencyConvert, SaleBadge, Quantity, PricingTiers, Coupon, DailyReward, BidTicker, TradeWindow and VendingMachine. Receipt prints dot by dot with feed holes and a torn edge; Coupon cuts real notches; SaleBadge is a sixteen-point starburst; VendingMachine sells A1 to D4 by code and drops the snack into its tray. Sums are checked against overflow, TradeWindow withdraws both confirms on any change to an offer, and a disabled Checkout veils its inert content. text.Odometer now counts digits as text, steps at 15 fps as S5 asks, draws exact digits at rest and lands rolls that floats would stall.
This commit is contained in:
28 files changed
+2420
-9
No files matched your search
@@ -0,0 +1,35 @@
|
||||
package shop
|
||||
|
||||
import (
|
||||
"github.com/egoist/mygo/ui"
|
||||
|
||||
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
|
||||
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/text"
|
||||
)
|
||||
|
||||
type WalletOptions struct {
|
||||
// Digits pads each balance; zero fits the number.
|
||||
Digits int
|
||||
}
|
||||
|
||||
// Wallet shows gold and gem balances that roll on change.
|
||||
func Wallet(c *ui.Context, gold, gems int, o WalletOptions) *ui.Element {
|
||||
k := pixel.K(c)
|
||||
g, m := amount("Wallet gold", gold), amount("Wallet gems", gems)
|
||||
_, gw := coin(k, Gold)
|
||||
_, mw := coin(k, Gems)
|
||||
return ui.Column(c).Gap(k.D(2)).Role(ui.RoleGroup).Label(k.Msg("wallet")).Description(g + " " + gw + ", " + m + " " + mw).Children(func() {
|
||||
for _, row := range []struct {
|
||||
cur Currency
|
||||
n int
|
||||
}{{Gold, gold}, {Gems, gems}} {
|
||||
sp, _ := coin(k, row.cur)
|
||||
ui.Row(c).Gap(k.D(4)).AlignItems(ui.Center).Children(func() {
|
||||
ui.Box(c).Size(k.D(12), k.D(12)).Draw(func(p *ui.Painter, r ui.Rect) {
|
||||
k.Canvas(p, r).Sprite(0, 0, sp, 0, pixel.Ink, 1)
|
||||
})
|
||||
text.Odometer(c, row.n, text.OdometerOptions{Digits: o.Digits})
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user