format fixes

This commit is contained in:
2026-08-29 23:33:29 +02:00
parent 954bd762f7
commit 1fa19f0b2e
23 changed files with 335 additions and 147 deletions
-1
View File
@@ -33,7 +33,6 @@ func New(o Opts) *inkwell.Game {
func bootOpening(w *World, start string, finale bool) []inkwell.Action { func bootOpening(w *World, start string, finale bool) []inkwell.Action {
acts := []inkwell.Action{ acts := []inkwell.Action{
EnterScene(w, start), EnterScene(w, start),
inkwell.SetFlag(FlagPoliceTip), inkwell.SetFlag(FlagPoliceTip),
inkwell.Say(Paul, "Back alley. Just like the clerk said."), inkwell.Say(Paul, "Back alley. Just like the clerk said."),
TapeSay(Dex, "A government office tipped you off to remove something from a scene. That doesn't strike you as odd?"), TapeSay(Dex, "A government office tipped you off to remove something from a scene. That doesn't strike you as odd?"),
+4 -2
View File
@@ -10,8 +10,10 @@ func characterPaul() inkwell.Character {
Speed: 96, Speed: 96,
W: 28, W: 28,
H: 68, H: 68,
Start: inkwell.Point{X: 120, Y: 232}, Start: inkwell.Point{
X: 120,
Y: 232,
},
SpeechColor: Ink, SpeechColor: Ink,
} }
} }
+5 -2
View File
@@ -9,8 +9,11 @@ func dialogDexTalk() inkwell.Dialogue {
Name: DlgDex, Name: DlgDex,
Start: "root", Start: "root",
Nodes: []inkwell.DialogueNode{{ Nodes: []inkwell.DialogueNode{{
Name: "root", Name: "root",
Lines: []inkwell.DialogueLine{{Speaker: Dex, Text: "Talk."}}, Lines: []inkwell.DialogueLine{{
Speaker: Dex,
Text: "Talk.",
}},
Choices: []inkwell.DialogueChoice{ Choices: []inkwell.DialogueChoice{
{ {
Text: "What am I doing here, Dex?", Text: "What am I doing here, Dex?",
+5 -2
View File
@@ -9,8 +9,11 @@ func dialogMysteryTapeSilent() inkwell.Dialogue {
Name: DlgMysteryTape, Name: DlgMysteryTape,
Start: "root", Start: "root",
Nodes: []inkwell.DialogueNode{{ Nodes: []inkwell.DialogueNode{{
Name: "root", Name: "root",
Lines: []inkwell.DialogueLine{{Speaker: Dex, Text: "Nothing. Warm, spinning, and silent."}}, Lines: []inkwell.DialogueLine{{
Speaker: Dex,
Text: "Nothing. Warm, spinning, and silent.",
}},
Choices: []inkwell.DialogueChoice{ Choices: []inkwell.DialogueChoice{
{ {
Text: "Are you sure it works?", Text: "Are you sure it works?",
-1
View File
@@ -13,7 +13,6 @@ func itemBlackMarketArmilla() inkwell.Item {
TapeSay(Dex, "Two slots, and both of them lie about the temperature. Don't trade me in for it."), TapeSay(Dex, "Two slots, and both of them lie about the temperature. Don't trade me in for it."),
), ),
OnUseWith: map[string]inkwell.Action{ OnUseWith: map[string]inkwell.Action{
ItemNoodleLetter: inkwell.Seq( ItemNoodleLetter: inkwell.Seq(
inkwell.Say(Paul, "A letter and a bracelet. Brilliant."), inkwell.Say(Paul, "A letter and a bracelet. Brilliant."),
TapeSay(Dex, "Nothing. Which is what I'd charge for it."), TapeSay(Dex, "Nothing. Which is what I'd charge for it."),
+12 -4
View File
@@ -10,11 +10,20 @@ func screenAlley() screen {
title: "ALLEY — BEHIND NOODLE'S HOUSE", title: "ALLEY — BEHIND NOODLE'S HOUSE",
background: BgAlley, background: BgAlley,
exits: []exit{ exits: []exit{
{
{to: ScreenNoodleHouse, label: "back out to the street", side: sideLeft}, to: ScreenNoodleHouse,
label: "back out to the street",
side: sideLeft,
},
}, },
actors: []inkwell.SceneActor{ actors: []inkwell.SceneActor{
{CharacterName: Paul, At: inkwell.Point{X: 120, Y: 232}}, {
CharacterName: Paul,
At: inkwell.Point{
X: 120,
Y: 232,
},
},
}, },
onEnter: setVarIfEmpty(VarArmillaStrip, "SRP: 1 tape"), onEnter: setVarIfEmpty(VarArmillaStrip, "SRP: 1 tape"),
hotspots: []inkwell.Hotspot{hidingPlace(), backDoor(), bin(), fireEscape()}, hotspots: []inkwell.Hotspot{hidingPlace(), backDoor(), bin(), fireEscape()},
@@ -59,7 +68,6 @@ func backDoor() inkwell.Hotspot {
), ),
OnTalk: inkwell.Say(Paul, "To the door? I'm not there yet."), OnTalk: inkwell.Say(Paul, "To the door? I'm not there yet."),
OnUseWith: map[string]inkwell.Action{ OnUseWith: map[string]inkwell.Action{
ItemBlackArmilla: inkwell.Seq( ItemBlackArmilla: inkwell.Seq(
inkwell.Say(Paul, "A black-market bracelet doesn't open a keypad."), inkwell.Say(Paul, "A black-market bracelet doesn't open a keypad."),
TapeSay(Dex, "But you do get an advert out of it."), TapeSay(Dex, "But you do get an advert out of it."),
+4 -1
View File
@@ -6,7 +6,10 @@ func screenBbsTerminal() screen {
title: "TERMINAL — BBS ACCESS POINT", title: "TERMINAL — BBS ACCESS POINT",
background: BgBBSTerminal, background: BgBBSTerminal,
exits: []exit{ exits: []exit{
{label: "step back from the terminal", side: sideNear}, {
label: "step back from the terminal",
side: sideNear,
},
}, },
} }
} }
+5 -1
View File
@@ -38,7 +38,11 @@ type exit struct {
} }
func toSelector() exit { func toSelector() exit {
return exit{to: ScreenSelector, label: "the rest of the city", side: sideNear} return exit{
to: ScreenSelector,
label: "the rest of the city",
side: sideNear,
}
} }
func exitName(to string) string { func exitName(to string) string {
+21 -3
View File
@@ -57,8 +57,20 @@ func registerScreen(w *World) {
var screenFloor = []inkwell.Polygon{ var screenFloor = []inkwell.Polygon{
inkwell.Poly( inkwell.Poly(
inkwell.Point{X: 16, Y: 196}, inkwell.Point{X: 624, Y: 196}, inkwell.Point{
inkwell.Point{X: 624, Y: 258}, inkwell.Point{X: 16, Y: 258}, X: 16,
Y: 196,
}, inkwell.Point{
X: 624,
Y: 196,
},
inkwell.Point{
X: 624,
Y: 258,
}, inkwell.Point{
X: 16,
Y: 258,
},
), ),
} }
@@ -76,7 +88,13 @@ func screenBuild(w *World, s screen) inkwell.Scene {
actors := s.actors actors := s.actors
if actors == nil { if actors == nil {
actors = []inkwell.SceneActor{ actors = []inkwell.SceneActor{
{CharacterName: Paul, At: inkwell.Point{X: 320, Y: 232}}, {
CharacterName: Paul,
At: inkwell.Point{
X: 320,
Y: 232,
},
},
} }
} }
walkboxes := s.walkboxes walkboxes := s.walkboxes
+5 -1
View File
@@ -7,7 +7,11 @@ func screenNoodleHouse() screen {
background: BgNoodleHouse, background: BgNoodleHouse,
onSelector: true, onSelector: true,
exits: []exit{ exits: []exit{
{to: ScreenAlley, label: "the alley behind the house", side: sideRight}, {
to: ScreenAlley,
label: "the alley behind the house",
side: sideRight,
},
}, },
} }
} }
+10 -2
View File
@@ -7,8 +7,16 @@ func screenNormanApartment() screen {
background: BgNormanApartment, background: BgNormanApartment,
onSelector: true, onSelector: true,
exits: []exit{ exits: []exit{
{to: ScreenRooftopHideout, label: "the stairs up to the roof", side: sideBack}, {
{to: ScreenBBSTerminal, label: "Norman's terminal", side: sideRight}, to: ScreenRooftopHideout,
label: "the stairs up to the roof",
side: sideBack,
},
{
to: ScreenBBSTerminal,
label: "Norman's terminal",
side: sideRight,
},
}, },
} }
} }
+5 -1
View File
@@ -6,7 +6,11 @@ func screenPaulShop() screen {
title: "PAUL'S SHOP — JUNK AND GARAGE", title: "PAUL'S SHOP — JUNK AND GARAGE",
background: BgPaulShop, background: BgPaulShop,
exits: []exit{ exits: []exit{
{to: ScreenNoodleHouse, label: "the bus to San Francisco", side: sideNear}, {
to: ScreenNoodleHouse,
label: "the bus to San Francisco",
side: sideNear,
},
}, },
} }
} }
+10 -2
View File
@@ -6,8 +6,16 @@ func screenRooftopHideout() screen {
title: "NORMAN'S ROOFTOP HIDEOUT", title: "NORMAN'S ROOFTOP HIDEOUT",
background: BgRooftopHideout, background: BgRooftopHideout,
exits: []exit{ exits: []exit{
{to: ScreenNormanApartment, label: "back down into the flat", side: sideNear}, {
{to: ScreenBBSTerminal, label: "the old terminal", side: sideRight}, to: ScreenNormanApartment,
label: "back down into the flat",
side: sideNear,
},
{
to: ScreenBBSTerminal,
label: "the old terminal",
side: sideRight,
},
}, },
} }
} }
+10 -2
View File
@@ -6,8 +6,16 @@ func screenSecretClub() screen {
title: "SECRET CLUB — THE UNDERWATER SUN", title: "SECRET CLUB — THE UNDERWATER SUN",
background: BgSecretClub, background: BgSecretClub,
exits: []exit{ exits: []exit{
{to: ScreenBBSTerminal, label: "the terminal in the corner", side: sideBack}, {
{to: ScreenTrinketShop, label: "back out through the shop", side: sideNear}, to: ScreenBBSTerminal,
label: "the terminal in the corner",
side: sideBack,
},
{
to: ScreenTrinketShop,
label: "back out through the shop",
side: sideNear,
},
}, },
} }
} }
+2 -3
View File
@@ -23,9 +23,8 @@ func screenSelector(rest []screen) screen {
title: "SAN FRANCISCO", title: "SAN FRANCISCO",
background: BgSelector, background: BgSelector,
exits: exits, exits: exits,
actors: []inkwell.SceneActor{},
actors: []inkwell.SceneActor{}, walkboxes: []inkwell.Polygon{},
walkboxes: []inkwell.Polygon{},
} }
} }
+5 -1
View File
@@ -6,7 +6,11 @@ func screenSmallRestaurant() screen {
title: "SMALL RESTAURANT — NEXT DOOR", title: "SMALL RESTAURANT — NEXT DOOR",
background: BgSmallRestaurant, background: BgSmallRestaurant,
exits: []exit{ exits: []exit{
{to: ScreenTrinketShop, label: "back to the trinket shop", side: sideLeft}, {
to: ScreenTrinketShop,
label: "back to the trinket shop",
side: sideLeft,
},
}, },
} }
} }
+8 -2
View File
@@ -7,9 +7,15 @@ func screenTrinketShop() screen {
background: BgTrinketShop, background: BgTrinketShop,
onSelector: true, onSelector: true,
exits: []exit{ exits: []exit{
{to: ScreenSmallRestaurant, label: "the eating place next door", side: sideRight},
{ {
to: ScreenSecretClub, label: "the way in at the back", side: sideBack, to: ScreenSmallRestaurant,
label: "the eating place next door",
side: sideRight,
},
{
to: ScreenSecretClub,
label: "the way in at the back",
side: sideBack,
needs: FlagClubEntry, needs: FlagClubEntry,
blocked: "Just a shop, as far as the man behind the counter is concerned.", blocked: "Just a shop, as far as the man behind the counter is concerned.",
}, },
+72 -80
View File
@@ -12,11 +12,21 @@ const (
) )
func RGB(hex uint32) color.Color { func RGB(hex uint32) color.Color {
return color.RGBA{R: uint8(hex >> 16), G: uint8(hex >> 8), B: uint8(hex), A: 0xff} return color.RGBA{
R: uint8(hex >> 16),
G: uint8(hex >> 8),
B: uint8(hex),
A: 0xff,
}
} }
func RGBA(hex uint32, a uint8) color.Color { func RGBA(hex uint32, a uint8) color.Color {
return color.RGBA{R: uint8(hex >> 16), G: uint8(hex >> 8), B: uint8(hex), A: a} return color.RGBA{
R: uint8(hex >> 16),
G: uint8(hex >> 8),
B: uint8(hex),
A: a,
}
} }
var ( var (
@@ -31,47 +41,38 @@ var (
func realWorldTheme() inkwell.Theme { func realWorldTheme() inkwell.Theme {
return inkwell.Theme{ return inkwell.Theme{
Name: RealWorld, Name: RealWorld,
PanelBG: black, PanelBG: black,
StatusText: Ink, StatusText: Ink,
FlashText: Amber, FlashText: Amber,
VerbButtonBG: RGB(0x1E1A14),
VerbButtonBG: RGB(0x1E1A14), VerbButtonSelectedBG: AmberLo,
VerbButtonSelectedBG: AmberLo, VerbButtonText: Ink,
VerbButtonText: Ink,
InventorySlotBG: RGB(0x1E1A14), InventorySlotBG: RGB(0x1E1A14),
InventorySlotSelectedBG: AmberLo, InventorySlotSelectedBG: AmberLo,
SpeechBubbleBG: RGBA(0x14120E, 0xDC),
SpeechBubbleBG: RGBA(0x14120E, 0xDC), SpeechDefaultText: Ink,
SpeechDefaultText: Ink, DialogBG: RGBA(0x0D0B08, 0xF0),
DialogBorder: AmberLo,
DialogBG: RGBA(0x0D0B08, 0xF0), DialogChoiceBG: RGB(0x1E1A14),
DialogBorder: AmberLo, DialogChoiceHover: Amber,
DialogChoiceBG: RGB(0x1E1A14), DialogSpeaker: Amber,
DialogChoiceHover: Amber, DialogText: Ink,
DialogSpeaker: Amber, EndCardBG: RGBA(0x000000, 0xFA),
DialogText: Ink, EndCardText: Ink,
CursorColor: Amber,
EndCardBG: RGBA(0x000000, 0xFA), HotspotOutline: RGB(0x7A6A44),
EndCardText: Ink, SceneBackdrop: sceneBG,
TopBarBG: panel,
CursorColor: Amber, TopBarText: InkDim,
HotspotOutline: RGB(0x7A6A44), TopBarAccent: Amber,
SceneBackdrop: sceneBG, ChatLogBG: panel,
ChatLogPrompt: InkDim,
TopBarBG: panel, ChatLogResponse: Amber,
TopBarText: InkDim, ChatLogSystem: RGB(0x6B6353),
TopBarAccent: Amber, CharacterPanelBG: panel,
CharacterPanelBorder: AmberLo,
ChatLogBG: panel, CharacterPanelTitle: Amber,
ChatLogPrompt: InkDim,
ChatLogResponse: Amber,
ChatLogSystem: RGB(0x6B6353),
CharacterPanelBG: panel,
CharacterPanelBorder: AmberLo,
CharacterPanelTitle: Amber,
} }
} }
@@ -83,47 +84,38 @@ var (
func nokiaPunkTheme() inkwell.Theme { func nokiaPunkTheme() inkwell.Theme {
return inkwell.Theme{ return inkwell.Theme{
Name: NokiaPunk, Name: NokiaPunk,
PanelBG: npBlack, PanelBG: npBlack,
StatusText: Green, StatusText: Green,
FlashText: RGB(0xD8F06A), FlashText: RGB(0xD8F06A),
VerbButtonBG: RGB(0x08140A),
VerbButtonBG: RGB(0x08140A), VerbButtonSelectedBG: GreenLo,
VerbButtonSelectedBG: GreenLo, VerbButtonText: Green,
VerbButtonText: Green,
InventorySlotBG: RGB(0x08140A), InventorySlotBG: RGB(0x08140A),
InventorySlotSelectedBG: GreenLo, InventorySlotSelectedBG: GreenLo,
SpeechBubbleBG: RGBA(0x030603, 0xDC),
SpeechBubbleBG: RGBA(0x030603, 0xDC), SpeechDefaultText: Green,
SpeechDefaultText: Green, DialogBG: RGBA(0x030603, 0xF0),
DialogBorder: Green,
DialogBG: RGBA(0x030603, 0xF0), DialogChoiceBG: RGB(0x08140A),
DialogBorder: Green, DialogChoiceHover: RGB(0xB4FFC8),
DialogChoiceBG: RGB(0x08140A), DialogSpeaker: RGB(0xB4FFC8),
DialogChoiceHover: RGB(0xB4FFC8), DialogText: Green,
DialogSpeaker: RGB(0xB4FFC8), EndCardBG: RGBA(0x000000, 0xFA),
DialogText: Green, EndCardText: Green,
CursorColor: Green,
EndCardBG: RGBA(0x000000, 0xFA), HotspotOutline: GreenLo,
EndCardText: Green, SceneBackdrop: npBlack,
TopBarBG: RGB(0x061006),
CursorColor: Green, TopBarText: GreenLo,
HotspotOutline: GreenLo, TopBarAccent: Green,
SceneBackdrop: npBlack, ChatLogBG: RGB(0x040A04),
ChatLogPrompt: GreenLo,
TopBarBG: RGB(0x061006), ChatLogResponse: Green,
TopBarText: GreenLo, ChatLogSystem: RGB(0x156030),
TopBarAccent: Green, CharacterPanelBG: RGB(0x040A04),
CharacterPanelBorder: Green,
ChatLogBG: RGB(0x040A04), CharacterPanelTitle: RGB(0xB4FFC8),
ChatLogPrompt: GreenLo,
ChatLogResponse: Green,
ChatLogSystem: RGB(0x156030),
CharacterPanelBG: RGB(0x040A04),
CharacterPanelBorder: Green,
CharacterPanelTitle: RGB(0xB4FFC8),
} }
} }
+70 -22
View File
@@ -30,57 +30,101 @@ const (
func registerUI(w *World) { func registerUI(w *World) {
g := w.G g := w.G
g.UIManager.Register(&UseWithGuard{Name: "usewith_guard", W: w}) g.UIManager.Register(&UseWithGuard{
g.UIManager.Register(&ActionPump{Name: "pump", W: w}) Name: "usewith_guard",
g.UIManager.Register(&screenNav{Name: "screen_nav", W: w}) W: w,
g.UIManager.Register(&windowSizer{Name: "window", Scale: 2}) })
g.UIManager.Register(&inkwell.HotspotDebug{Name: "hotspot_debug"}) g.UIManager.Register(&ActionPump{
Name: "pump",
W: w,
})
g.UIManager.Register(&screenNav{
Name: "screen_nav",
W: w,
})
g.UIManager.Register(&windowSizer{
Name: "window",
Scale: 2,
})
g.UIManager.Register(&inkwell.HotspotDebug{
Name: "hotspot_debug",
})
top := &inkwell.TopBar{ top := &inkwell.TopBar{
Name: "topbar", Name: "topbar",
Height: TopBarH, Height: TopBarH,
TimeVar: VarArmillaStrip, TimeVar: VarArmillaStrip,
} }
w.SetTopBar(top) w.SetTopBar(top)
g.UIManager.Register(gated(w, "topbar_gate", top)) g.UIManager.Register(gated(w, "topbar_gate", top))
g.UIManager.Register(&Letterbox{Name: "letterbox", W: w, Bar: 36}) g.UIManager.Register(&Letterbox{
g.UIManager.Register(&hudFrame{Name: "hudframe", W: w}) Name: "letterbox",
W: w,
Bar: 36,
})
g.UIManager.Register(&hudFrame{
Name: "hudframe",
W: w,
})
g.UIManager.Register(gated(w, "status_gate", &inkwell.StatusLine{ g.UIManager.Register(gated(w, "status_gate", &inkwell.StatusLine{
Name: "status", Y: statusY, Align: inkwell.AlignLeft, ScreenWidth: DividerX, Name: "status",
Y: statusY,
Align: inkwell.AlignLeft,
ScreenWidth: DividerX,
})) }))
g.UIManager.Register(gated(w, "inventory_gate", &inkwell.InventoryBar{ g.UIManager.Register(gated(w, "inventory_gate", &inkwell.InventoryBar{
Name: "inventory", Origin: inkwell.Point{X: Pad + 2, Y: invY}, Name: "inventory",
Slots: 8, Cols: 4, SlotSize: invSlot, Gap: invGap, Origin: inkwell.Point{
X: Pad + 2,
Y: invY,
},
Slots: 8,
Cols: 4,
SlotSize: invSlot,
Gap: invGap,
})) }))
g.UIManager.Register(&TapeSlots{ g.UIManager.Register(&TapeSlots{
Name: "tapes", W: w, Name: "tapes",
W: w,
Bounds: inkwell.Rect(192, slotsY, 194, slotsH), Bounds: inkwell.Rect(192, slotsY, 194, slotsH),
}) })
g.UIManager.Register(&TapeChannel{ g.UIManager.Register(&TapeChannel{
Name: "channel", W: w, Name: "channel",
W: w,
Bounds: inkwell.Rect(DividerX+2, HUDTop+2, ScreenW-DividerX-4, ScreenH-HUDTop-4), Bounds: inkwell.Rect(DividerX+2, HUDTop+2, ScreenW-DividerX-4, ScreenH-HUDTop-4),
}) })
g.UIManager.Register(&inkwell.SpeechBubble{ g.UIManager.Register(&inkwell.SpeechBubble{
Name: "speech", MaxWidth: 360, Padding: Pad, OffsetY: 8, FallbackY: TopBarH + Pad, Name: "speech",
MaxWidth: 360,
Padding: Pad,
OffsetY: 8,
FallbackY: TopBarH + Pad,
}) })
g.UIManager.Register(&inkwell.DialogBox{ g.UIManager.Register(&inkwell.DialogBox{
Name: "dialog", Bounds: inkwell.Rect(0, ScreenH-LineH*9, DividerX, LineH*9), Name: "dialog",
LineHeight: LineH, Padding: Pad, Bounds: inkwell.Rect(0, ScreenH-LineH*9, DividerX, LineH*9),
LineHeight: LineH,
Padding: Pad,
}) })
g.UIManager.Register(&inkwell.RadialVerbs{ g.UIManager.Register(&inkwell.RadialVerbs{
Name: "verbs", Trigger: inkwell.MouseButtonRight, Radius: 58, Name: "verbs",
Trigger: inkwell.MouseButtonRight,
Radius: 58,
Labels: map[string]string{ Labels: map[string]string{
"look": "Look", "use": "Use", "talk": "Talk", "take": "Take", "look": "Look", "use": "Use", "talk": "Talk", "take": "Take",
}, },
}) })
g.UIManager.Register(&inkwell.EndCard{Name: "endcard"}) g.UIManager.Register(&inkwell.EndCard{
g.UIManager.Register(&inkwell.Cursor{Name: "cursor"}) Name: "endcard",
})
g.UIManager.Register(&inkwell.Cursor{
Name: "cursor",
})
} }
type windowSizer struct { type windowSizer struct {
@@ -111,7 +155,11 @@ type gate struct {
} }
func gated(w *World, name string, inner inkwell.Widget) inkwell.Widget { func gated(w *World, name string, inner inkwell.Widget) inkwell.Widget {
return &gate{Name: name, W: w, Inner: inner} return &gate{
Name: name,
W: w,
Inner: inner,
}
} }
func (n *gate) GetName() string { return n.Name } func (n *gate) GetName() string { return n.Name }
+43 -5
View File
@@ -9,19 +9,57 @@ import (
func TestScreenNavWrapsBothWays(t *testing.T) { func TestScreenNavWrapsBothWays(t *testing.T) {
g := inkwell.NewGame("t", ScreenW, ScreenH) g := inkwell.NewGame("t", ScreenW, ScreenH)
for _, n := range []string{"a", "b", "c"} { for _, n := range []string{"a", "b", "c"} {
g.SceneManager.Register(inkwell.Scene{Name: n, Background: "bg"}) g.SceneManager.Register(inkwell.Scene{
Name: n,
Background: "bg",
})
} }
w := newWorld(g) w := newWorld(g)
nav := &screenNav{Name: "screen_nav", W: w} nav := &screenNav{
at := func(name string) { EnterScene(w, name).Start().Tick(&inkwell.Ctx{Game: g}) } Name: "screen_nav",
W: w,
}
at := func(name string) {
EnterScene(w, name).Start().Tick(&inkwell.Ctx{
Game: g,
})
}
for _, tc := range []struct { for _, tc := range []struct {
from string from string
step int step int
want string want string
}{ }{
{"a", 1, "b"}, {"b", 1, "c"}, {"c", 1, "a"}, {
{"c", -1, "b"}, {"b", -1, "a"}, {"a", -1, "c"}, from: "a",
step: 1,
want: "b",
},
{
from: "b",
step: 1,
want: "c",
},
{
from: "c",
step: 1,
want: "a",
},
{
from: "c",
step: -1,
want: "b",
},
{
from: "b",
step: -1,
want: "a",
},
{
from: "a",
step: -1,
want: "c",
},
} { } {
at(tc.from) at(tc.from)
if got := nav.neighbour(g, tc.step); got != tc.want { if got := nav.neighbour(g, tc.step); got != tc.want {
+4 -1
View File
@@ -64,7 +64,10 @@ func (t *TapeChannel) Draw(dst *ebiten.Image, ctx *inkwell.UICtx) {
col, txt = th.ChatLogSystem, m.Text col, txt = th.ChatLogSystem, m.Text
} }
for _, wl := range wrap(txt, wrapW) { for _, wl := range wrap(txt, wrapW) {
rendered = append(rendered, line{text: wl, col: col}) rendered = append(rendered, line{
text: wl,
col: col,
})
} }
} }
+31 -7
View File
@@ -28,7 +28,10 @@ func (w *World) PumpTick(dt float64) {
w.running = w.queue[0].Start() w.running = w.queue[0].Start()
w.queue = w.queue[1:] w.queue = w.queue[1:]
} }
ctx := &inkwell.Ctx{Game: w.G, DT: dt} ctx := &inkwell.Ctx{
Game: w.G,
DT: dt,
}
if s, ok := w.G.SceneManager.Get(w.scene); ok { if s, ok := w.G.SceneManager.Get(w.scene); ok {
ctx.Scene = &s ctx.Scene = &s
} }
@@ -59,7 +62,11 @@ func (p *ActionPump) Draw(dst *ebiten.Image, ctx *inkwell.UICtx) {}
type fnAction struct{ fn func(*inkwell.Ctx) } type fnAction struct{ fn func(*inkwell.Ctx) }
func (a *fnAction) Start() inkwell.Runner { return &fnRunner{spec: a} } func (a *fnAction) Start() inkwell.Runner {
return &fnRunner{
spec: a,
}
}
type fnRunner struct{ spec *fnAction } type fnRunner struct{ spec *fnAction }
@@ -68,7 +75,11 @@ func (r *fnRunner) Tick(ctx *inkwell.Ctx) inkwell.Status {
return inkwell.StatusDone return inkwell.StatusDone
} }
func Fn(f func(*inkwell.Ctx)) inkwell.Action { return &fnAction{fn: f} } func Fn(f func(*inkwell.Ctx)) inkwell.Action {
return &fnAction{
fn: f,
}
}
func UseTheme(name string) inkwell.Action { func UseTheme(name string) inkwell.Action {
return Fn(func(ctx *inkwell.Ctx) { ctx.Game.UseTheme(name) }) return Fn(func(ctx *inkwell.Ctx) { ctx.Game.UseTheme(name) })
@@ -97,12 +108,19 @@ func Back(w *World) inkwell.Action {
} }
func TapeSay(speaker, text string) inkwell.Action { func TapeSay(speaker, text string) inkwell.Action {
return &tapeSayAction{speaker: speaker, text: text} return &tapeSayAction{
speaker: speaker,
text: text,
}
} }
type tapeSayAction struct{ speaker, text string } type tapeSayAction struct{ speaker, text string }
func (a *tapeSayAction) Start() inkwell.Runner { return &tapeSayRunner{spec: a} } func (a *tapeSayAction) Start() inkwell.Runner {
return &tapeSayRunner{
spec: a,
}
}
type tapeSayRunner struct { type tapeSayRunner struct {
spec *tapeSayAction spec *tapeSayAction
@@ -143,7 +161,10 @@ func (w *World) TakeTapeOffer() {
} }
func Paused(w *World, inner inkwell.Action) inkwell.Action { func Paused(w *World, inner inkwell.Action) inkwell.Action {
return &pausedAction{w: w, inner: inner} return &pausedAction{
w: w,
inner: inner,
}
} }
type pausedAction struct { type pausedAction struct {
@@ -152,7 +173,10 @@ type pausedAction struct {
} }
func (a *pausedAction) Start() inkwell.Runner { func (a *pausedAction) Start() inkwell.Runner {
return &pausedRunner{spec: a, inner: a.inner.Start()} return &pausedRunner{
spec: a,
inner: a.inner.Start(),
}
} }
type pausedRunner struct { type pausedRunner struct {
+4 -1
View File
@@ -30,7 +30,10 @@ type World struct {
} }
func newWorld(g *inkwell.Game) *World { func newWorld(g *inkwell.Game) *World {
return &World{G: g, mode: ModePlay} return &World{
G: g,
mode: ModePlay,
}
} }
func (w *World) Mode() Mode { return w.mode } func (w *World) Mode() Mode { return w.mode }