From 97bcc8167934097b20b5a83bc311950f40e15496 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Thu, 4 Sep 2025 13:24:00 +0200 Subject: add an about activity --- go/activities/about.go | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++ go/client/gameMenu.go | 4 ++++ 2 files changed, 64 insertions(+) create mode 100644 go/activities/about.go diff --git a/go/activities/about.go b/go/activities/about.go new file mode 100644 index 00000000..8669f5bb --- /dev/null +++ b/go/activities/about.go @@ -0,0 +1,60 @@ +package activities + +import ( + "image/color" + + "muhq.space/muhqs-game/go/ui" +) + +// About is an Activity that presents the about information in a scrollable buffer. +// It features an arrow back button calling activities.PopActivity(). +type About struct { + ui.Collection +} + +var about = [...]string{ + " ", + "Muhq's Game", + "Copyright Florian Fischer", + "Game material GNU Free Documentation License", + "Implementation GNU GPL 3+", + " ", + "Font: Antykwa Torunska", + "Designer: Zygfryd Gardzielewski", + "Author: Janusz Marian Nowacki", + "This work is released under the GUST Font Nosource License", + " ", + "Used go packages", + "github.com/RyanCarrier/dijkstra - MIT License", + "github.com/hajimehoshi/ebiten - Apache 2.0 license", + "golang.org/x/image - BSD-3-Clause", + "golang.org/x/net - BSD-3-Clause", + "gopkg.in/yaml.v3", +} + +const ABOUT_MARGIN = 25 + +func NewAbout(width, height int) *About { + a := &About{ui.Collection{Width: width, Height: height}} + + buffer := ui.NewBuffer(ABOUT_MARGIN, ABOUT_MARGIN, width-2*ABOUT_MARGIN, height-2*ABOUT_MARGIN) + a.AddWidget(buffer) + buffer.Bg(color.Black) + buffer.AddLines(about[:]) + + back := ui.NewRoundSimpleButton(5, 5, 40, "←", func(*ui.SimpleButton) { PopActivity() }) + a.AddWidget(back) + + return a +} + +func (a *About) Layout(int, int) (int, int) { + return a.Width, a.Height +} + +func (a *About) Update() error { + if err := ui.Update(); err != nil { + return err + } + return a.Collection.Update() +} diff --git a/go/client/gameMenu.go b/go/client/gameMenu.go index 20389a9a..af53e21e 100644 --- a/go/client/gameMenu.go +++ b/go/client/gameMenu.go @@ -12,6 +12,7 @@ func newGameMenu(g *Game) *activities.ButtonList { "concede", "wincondition", "settings", + "about", } handlers := []func(*ui.SimpleButton){ func(*ui.SimpleButton) { @@ -25,6 +26,9 @@ func newGameMenu(g *Game) *activities.ButtonList { func(*ui.SimpleButton) { activities.PushActivity(newSettingsMenu(g)) }, + func(*ui.SimpleButton) { + activities.PushActivity(activities.NewAbout(g.Width, g.Height)) + }, } bl = activities.NewButtonList(g.Width, g.Height, labels, handlers) return bl -- cgit v1.2.3