From d3848215d7c60ec53ed9472e846f47849c9c45c3 Mon Sep 17 00:00:00 2001 From: dd84ai Date: Mon, 1 Apr 2024 00:34:30 +0200 Subject: [PATCH] feat: mines tab shown --- darkstat/front/mines.templ | 103 ++++++++++++++++++++++++++++++++++++ darkstat/front/shared.templ | 1 + darkstat/front/urls/urls.go | 1 + darkstat/linker/linker.go | 22 ++++++++ go.mod | 2 +- go.sum | 2 + 6 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 darkstat/front/mines.templ diff --git a/darkstat/front/mines.templ b/darkstat/front/mines.templ new file mode 100644 index 00000000..073b4881 --- /dev/null +++ b/darkstat/front/mines.templ @@ -0,0 +1,103 @@ +package front + +import ( + "strconv" + "github.com/darklab8/fl-darkstat/darkstat/front/urls" + "github.com/darklab8/fl-darkstat/darkstat/common/types" + "github.com/darklab8/fl-configs/configs/configs_export" + "fmt" + "strings" +) + +func MineDetailedUrl(mine configs_export.Mine) string { + return "mines/mines_base_" + strings.ToLower(mine.Nickname) +} + +// https://www.cssscript.com/minimalist-table-sortable/#:~:text=Description%3A-,sorttable.,clicking%20on%20the%20table%20headers +// https://www.cssscript.com/fast-html-table-sorting/ +templ MinesT(mines []configs_export.Mine) { + @TabMenu(urls.Mines) + @TabContent() { +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + for _, mine := range mines { + + + + + + + + + + + + + + + + + + + + + + + + @templ.Raw(JoinClickTriggers("bottominfo_click"+mine.Nickname, "infocard_click"+mine.Nickname)) + + } + +
MinePriceAmmo PriceHull DmgShield DmgValueRefireDetonation Dist.RadiusSeek Dist.Top SpeedAccelerationLinear DragLifetimeOwner SafeToughnessHit PtsLootableNicknameName IDInfo ID
{ mine.Name }{ strconv.Itoa(mine.Price) } { strconv.Itoa(mine.AmmoPrice) } { strconv.Itoa(mine.HullDamage) }{ strconv.Itoa(mine.ShieldDamage) }{ fmt.Sprintf("%.2f",mine.Value) }{ fmt.Sprintf("%.2f", mine.Refire) }{ fmt.Sprintf("%.2f", mine.DetonationDistance) }{ fmt.Sprintf("%.2f",mine.Radius) }{ strconv.Itoa(mine.SeekDistance) }{ strconv.Itoa(mine.TopSpeed) }{ strconv.Itoa(mine.Acceleration) }{ fmt.Sprintf("%.6f",mine.LinearDrag) }{ fmt.Sprintf("%.2f",mine.LifeTime) }{ strconv.Itoa(mine.OwnerSafe) }{ fmt.Sprintf("%.2f",mine.Toughness) }{ strconv.Itoa(mine.HitPts) }{ strconv.FormatBool(mine.Lootable) }{ mine.Nickname } { strconv.Itoa(mine.IdsName) } { strconv.Itoa(mine.IdsInfo) }
+
+
+ @GoodAtBaseSharedT(ShowPricePerVolume(false)) +
+
+
+ @InfocardShared() +
+
+ } +} diff --git a/darkstat/front/shared.templ b/darkstat/front/shared.templ index f0257fed..0888f193 100644 --- a/darkstat/front/shared.templ +++ b/darkstat/front/shared.templ @@ -124,6 +124,7 @@ templ TabMenu(url utils_types.FilePath) { + }
diff --git a/darkstat/front/urls/urls.go b/darkstat/front/urls/urls.go index 94855213..986fd748 100644 --- a/darkstat/front/urls/urls.go +++ b/darkstat/front/urls/urls.go @@ -13,4 +13,5 @@ const ( Guns utils_types.FilePath = "guns.html" GunModifiers utils_types.FilePath = "gun_modifiers.html" Missiles utils_types.FilePath = "missiles.html" + Mines utils_types.FilePath = "mines.html" ) diff --git a/darkstat/linker/linker.go b/darkstat/linker/linker.go index 866bcb73..2d9b0979 100644 --- a/darkstat/linker/linker.go +++ b/darkstat/linker/linker.go @@ -108,6 +108,15 @@ func (l *Linker) Link() *builder.Builder { }) } + for _, base_info := range data.Mines { + sort.Slice(base_info.Bases, func(i, j int) bool { + if base_info.Bases[i].BaseName != "" && base_info.Bases[j].BaseName == "" { + return true + } + return base_info.Bases[i].BaseName < base_info.Bases[j].BaseName + }) + } + build := builder.NewBuilder() build.RegComps( builder.NewComponent( @@ -142,6 +151,10 @@ func (l *Linker) Link() *builder.Builder { urls.Missiles, front.GunsT(data.Missiles, front.GunsMissiles), ), + builder.NewComponent( + urls.Mines, + front.MinesT(data.Mines), + ), ) for _, base := range data.Bases { @@ -207,5 +220,14 @@ func (l *Linker) Link() *builder.Builder { ) } + for _, mine := range data.Mines { + build.RegComps( + builder.NewComponent( + utils_types.FilePath(front.MineDetailedUrl(mine)), + front.GoodAtBaseInfoT(mine.Bases, front.ShowPricePerVolume(false)), + ), + ) + } + return build } diff --git a/go.mod b/go.mod index a6b409de..f65ef684 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.21.1 require ( github.com/a-h/templ v0.2.543 - github.com/darklab8/fl-configs v0.22.0 + github.com/darklab8/fl-configs v0.23.0 github.com/darklab8/go-typelog v0.6.0 github.com/darklab8/go-utils v0.12.0 github.com/yosssi/gohtml v0.0.0-20201013000340-ee4748c638f4 diff --git a/go.sum b/go.sum index 498e40e0..7a3901f8 100644 --- a/go.sum +++ b/go.sum @@ -20,6 +20,8 @@ github.com/darklab8/fl-configs v0.21.1 h1:dBIVOJocWL9JefjU616cY4KdpxyCgEBuvpETf7 github.com/darklab8/fl-configs v0.21.1/go.mod h1:8zaCaFL21TvawP65KB9NOJ+nEpaMDQYsnoOi77RiSVY= github.com/darklab8/fl-configs v0.22.0 h1:f3klPld5n0qLS7wn3x3uqEvrgf348pgHnuOnpqgRlVQ= github.com/darklab8/fl-configs v0.22.0/go.mod h1:8zaCaFL21TvawP65KB9NOJ+nEpaMDQYsnoOi77RiSVY= +github.com/darklab8/fl-configs v0.23.0 h1:QqVOMnWLewFBzZNdvgdrD0C8RuY06dBwaREpux/29x4= +github.com/darklab8/fl-configs v0.23.0/go.mod h1:8zaCaFL21TvawP65KB9NOJ+nEpaMDQYsnoOi77RiSVY= github.com/darklab8/go-typelog v0.6.0 h1:Ci8imc7ScXiy5e1qMgf46NyJjrqNLPoIE1gbVe7bxl4= github.com/darklab8/go-typelog v0.6.0/go.mod h1:AwwOf3dkp/tpevHFNbkB+PbwlDrUUgO1CVFkEnj+q5w= github.com/darklab8/go-utils v0.12.0 h1:LxsG3yVNf9W4xyV+tHPOaZB2ewItgM/1BzOXyKFvofs=