From 9bd63e0932004d3281a34d7df16221bcab6a4b1b Mon Sep 17 00:00:00 2001 From: cbeimers113 Date: Fri, 31 Jan 2025 22:21:24 -0500 Subject: [PATCH] Replace info panel with topbar --- TODO.md | 14 +- internal/context/notifications.go | 8 +- internal/entity/plant.go | 8 +- internal/entity/tile.go | 16 +- internal/graphics/texture.go | 45 +++-- .../graphics/textures/{ => gui}/cursor.png | Bin .../graphics/textures/{ => gui}/menuLogo.png | Bin internal/graphics/textures/gui/run.png | Bin 0 -> 715 bytes internal/graphics/textures/gui/walk.png | Bin 0 -> 660 bytes .../graphics/textures/{ => world}/dirt.png | Bin .../graphics/textures/{ => world}/grass.png | Bin .../graphics/textures/{ => world}/sand.png | Bin .../graphics/textures/{ => world}/seed.png | Bin .../graphics/textures/{ => world}/stalk.png | Bin .../graphics/textures/{ => world}/stone.png | Bin .../graphics/textures/{ => world}/water.png | Bin internal/gui/color/color.go | 2 +- internal/gui/gui.go | 12 +- internal/gui/main_menu.go | 7 + internal/gui/simulation_view.go | 163 ++++++++++++------ internal/gui/tile_context_menu.go | 2 +- internal/io/input_manager/input_manager.go | 4 + internal/state/state.go | 31 +++- main.go | 3 - 24 files changed, 205 insertions(+), 110 deletions(-) rename internal/graphics/textures/{ => gui}/cursor.png (100%) rename internal/graphics/textures/{ => gui}/menuLogo.png (100%) create mode 100644 internal/graphics/textures/gui/run.png create mode 100644 internal/graphics/textures/gui/walk.png rename internal/graphics/textures/{ => world}/dirt.png (100%) rename internal/graphics/textures/{ => world}/grass.png (100%) rename internal/graphics/textures/{ => world}/sand.png (100%) rename internal/graphics/textures/{ => world}/seed.png (100%) rename internal/graphics/textures/{ => world}/stalk.png (100%) rename internal/graphics/textures/{ => world}/stone.png (100%) rename internal/graphics/textures/{ => world}/water.png (100%) diff --git a/TODO.md b/TODO.md index 6f49bc1..2bb0c6b 100644 --- a/TODO.md +++ b/TODO.md @@ -1,16 +1,22 @@ ### v0.2.1: -- [x] Space & control to go vertically up and down -- [x] Limit how far from map we can go -- [ ] Tab to play/pause -- [ ] Toolbar instead of info panel +- [ ] Reset position on new sim +- [ ] Fix autosave bug/persistent plants issue - [ ] Fullscreen option in config +- [ ] GUI scale option in config - [ ] Fix mouse jittering bug when going in and out of menus - [ ] Pipeline improvements / build & release binaries / auto-tagging - [ ] Auto updates - [ ] Skybox - [ ] Shadows - [ ] Revisit tile highlighting +- [ ] Fix bug with conservation of mass (water) +- [x] Toggle info panel for chemical quantities in top right +- [x] Notifications appear in bottom left +- [x] Topbar instead of info panel +- [x] Space & control to go vertically up and down +- [x] Limit how far from map we can go +- [x] Tab to play/pause ### v0.3.0 - Plants Upgrade: diff --git a/internal/context/notifications.go b/internal/context/notifications.go index c08260c..39c5adf 100644 --- a/internal/context/notifications.go +++ b/internal/context/notifications.go @@ -66,16 +66,16 @@ func (n *NotificationManager) Render() { } n.noteObjects = make([]*gui.Label, 0) - width, _ := n.app.GetSize() + _, height := n.app.GetSize() // Add labels to screen for notifications for i, note := range n.notifications { - alpha := color.Opaque.A * min(note.timer, LIMIT/2) / (LIMIT / 2) + alpha := color.Translucent.A * min(note.timer, LIMIT/2) / (LIMIT / 2) fgCol := &math32.Color4{R: 0.0, G: 0.0, B: 0.0, A: alpha} bgCol := &math32.Color4{R: 1.0, G: 1.0, B: 1.0, A: alpha} obj := gui.NewLabel(note.message) - y := float32(i)*obj.Height() + 10*float32(i+1) - obj.SetPosition(float32(width)-obj.Width()-15, y) + y := float32(height) - float32(i+1) * (obj.Height() + 10) + obj.SetPosition(5, y) obj.SetPaddings(0, 5, 0, 5) obj.SetColor4(fgCol) obj.SetBgColor4(bgCol) diff --git a/internal/entity/plant.go b/internal/entity/plant.go index be877bb..17cc411 100644 --- a/internal/entity/plant.go +++ b/internal/entity/plant.go @@ -146,13 +146,9 @@ func (p *Plant) Update() { p.SetPosition(p.X, 0.5+p.Scale().Y/2, p.Z) } -// Infostring returns a string representation of the tile +// Infostring returns a string representation of the plant func (p Plant) InfoString() string { - infoString := "Plant:\n" - infoString += fmt.Sprintf("age=%d\n", p.Age) - infoString += fmt.Sprintf("colour=#%06x", p.Colour) - - return infoString + return fmt.Sprintf("plant,  : %dt,  : #%06x", p.Age, p.Colour) } // Material returns the plant's material diff --git a/internal/entity/tile.go b/internal/entity/tile.go index c1b8ef8..fda548d 100644 --- a/internal/entity/tile.go +++ b/internal/entity/tile.go @@ -292,14 +292,14 @@ func (t *Tile) AddPlant(entities map[int]Entity, scene *core.Node) bool { // Infostring returns a string representation of the tile func (t Tile) InfoString() string { - infoString := "Tile:\n" - infoString += fmt.Sprintf("type=%s\n", t.Type.Name) - infoString += fmt.Sprintf("temperature=%s\n", t.Temperature) - infoString += fmt.Sprintf("water level=%s\n", t.WaterLevel) - infoString += fmt.Sprintf("elevation=%s\n", t.getElevation()) - infoString += fmt.Sprintf("planted=%t", len(t.Plants) > 0) - - return infoString + return fmt.Sprintf( + "%s, : %s,  : %s,  : %s,  : %d", + t.Type.Name, + t.Temperature, + t.WaterLevel, + t.getElevation(), + len(t.Plants), + ) } // Material returns the tile's material diff --git a/internal/graphics/texture.go b/internal/graphics/texture.go index d959b57..ea8e8b0 100644 --- a/internal/graphics/texture.go +++ b/internal/graphics/texture.go @@ -12,35 +12,45 @@ import ( ) const ( + // Gui TexMenuLogo = "menuLogo" TexCursor = "cursor" - TexDirt = "dirt" - TexGrass = "grass" - TexSand = "sand" - TexSeed = "seed" - TexStalk = "stalk" - TexStone = "stone" - TexWater = "water" + TexWalk = "walk" + TexRun = "run" + + // World + TexDirt = "dirt" + TexGrass = "grass" + TexSand = "sand" + TexSeed = "seed" + TexStalk = "stalk" + TexStone = "stone" + TexWater = "water" ) var ( - //go:embed textures/menuLogo.png + //go:embed textures/gui/menuLogo.png bytesMenuLogo []byte - //go:embed textures/cursor.png + //go:embed textures/gui/cursor.png bytesCursor []byte - //go:embed textures/dirt.png + //go:embed textures/gui/walk.png + bytesWalk []byte + //go:embed textures/gui/run.png + bytesRun []byte + + //go:embed textures/world/dirt.png bytesDirt []byte - //go:embed textures/grass.png + //go:embed textures/world/grass.png bytesGrass []byte - //go:embed textures/sand.png + //go:embed textures/world/sand.png bytesSand []byte - //go:embed textures/seed.png + //go:embed textures/world/seed.png bytesSeed []byte - //go:embed textures/stalk.png + //go:embed textures/world/stalk.png bytesStalk []byte - //go:embed textures/stone.png + //go:embed textures/world/stone.png bytesStone []byte - //go:embed textures/water.png + //go:embed textures/world/water.png bytesWater []byte ) @@ -55,6 +65,9 @@ func init() { }{ {id: TexMenuLogo, data: bytesMenuLogo}, {id: TexCursor, data: bytesCursor}, + {id: TexWalk, data: bytesWalk}, + {id: TexRun, data: bytesRun}, + {id: TexDirt, data: bytesDirt}, {id: TexGrass, data: bytesGrass}, {id: TexSand, data: bytesSand}, diff --git a/internal/graphics/textures/cursor.png b/internal/graphics/textures/gui/cursor.png similarity index 100% rename from internal/graphics/textures/cursor.png rename to internal/graphics/textures/gui/cursor.png diff --git a/internal/graphics/textures/menuLogo.png b/internal/graphics/textures/gui/menuLogo.png similarity index 100% rename from internal/graphics/textures/menuLogo.png rename to internal/graphics/textures/gui/menuLogo.png diff --git a/internal/graphics/textures/gui/run.png b/internal/graphics/textures/gui/run.png new file mode 100644 index 0000000000000000000000000000000000000000..daa3f404e50572c45245cda6598468cc96715cdd GIT binary patch literal 715 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}c0*}aI1_r*vAk26?e?&q9iy!t)x7$D3u`~F*C13&(AeP!Bo#s z&*=9a=50VV+fpMu(>y)37&w3&Rt70XRt82O%L|C5p=^+AG#Ht|;!HrcAtMum0FaIX z;>>myuy_`b4FU;34AKvy(JW35DWjSSI&2zO%yr)@%rAH=jVRRmHM=J zMdXQdZr2ud^y=t5_1`dY>C~ess`Up{bUM>EO$n@1(eyI&S=PBr(6^%}e)jpRmy6pE z=G`m(Rd>F49uV$(ZWAx2%sWl|lE}8)9Sw##8rSMiTg^EZ8gnr9jpm!E9z7U-S- zZP9WzH7PZ??}6aEhiPVYz70z)dGeMYmW?^%lJkmH)BD|$Ihr<}p1ON{w)3ksW=kAh z`sVGk3I48YSS59zy_fuURaz`b{acdqw54nG&ONN1Wfo)ow{vqv`|}-BBj+4pIQQgs z-xa@SJ2h>O1wBh)t2NvHggY)(?f>knH~Q9I^jCXae`-UDnEywmUk)j8|I`xBzWyWe dEbH*22kKh_g5s}F5AFiRh^MQc%Q~loCIIhW`C$M6 literal 0 HcmV?d00001 diff --git a/internal/graphics/textures/gui/walk.png b/internal/graphics/textures/gui/walk.png new file mode 100644 index 0000000000000000000000000000000000000000..f8f6273c4f1108c526ecdc7525701d97852fbabf GIT binary patch literal 660 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}c0*}aI1_r*vAk26?e?&q9iy!t)x7$D3u`~F*C13&(AeP!Bo#s z&*=9a=50VV+fpMu(>y)37&w3&Rt70XRt82O%L|C5p=^+AG#Ht|;!HrcAtMum0FaIX z;>>myuy_`b4FU;34AKvy(JWBLEIjjwCAx5GP;=3h z$Hi*