Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show completed achievement in status bar #242

Merged
merged 1 commit into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion game/res/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const helpText = "Tiny World Help" +

const helpPanelWidth = 680
const helpPanelHeight = 460
const statusTimeout = 180
const statusTimeout = 4 * 60

const saveTooltipText = "Save game to disk or local browser storage."
const randomTilesTooltipText = "Random tiles available/total.\nBuild religious buildings to get more."
Expand Down Expand Up @@ -516,6 +516,7 @@ func (ui *UI) createStatusBar() *widget.Container {
Idle: ui.sprites.TextColor,
}),
widget.ButtonOpts.TextPadding(widget.NewInsetsSimple(4)),
widget.ButtonOpts.TextPosition(widget.TextPositionCenter, widget.TextPositionCenter),
widget.ButtonOpts.Image(ui.simpleButtonImage()),
widget.ButtonOpts.WidgetOpts(
widget.WidgetOpts.LayoutData(widget.AnchorLayoutData{
Expand Down
3 changes: 3 additions & 0 deletions game/sys/achievements.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type Achievements struct {
time generic.Resource[res.GameTick]
update generic.Resource[res.UpdateInterval]
editor generic.Resource[res.EditorMode]
ui generic.Resource[res.UI]
achievements generic.Resource[achievements.Achievements]
}

Expand All @@ -25,6 +26,7 @@ func (s *Achievements) Initialize(world *ecs.World) {
s.time = generic.NewResource[res.GameTick](world)
s.update = generic.NewResource[res.UpdateInterval](world)
s.editor = generic.NewResource[res.EditorMode](world)
s.ui = generic.NewResource[res.UI](world)
s.achievements = generic.NewResource[achievements.Achievements](world)
}

Expand All @@ -51,6 +53,7 @@ func (s *Achievements) Update(world *ecs.World) {
achievements.Completed = append(achievements.Completed, ach.ID)
save.SaveAchievements(s.PlayerFile, achievements.Completed)
println(fmt.Sprintf("Achievement completed: %s", ach.Name))
s.ui.Get().SetStatusLabel(fmt.Sprintf(" \nAchievement completed!\n\"%s\"\n ", ach.Name))
}
}
}
Expand Down
Loading