diff --git a/darkstat/front/shared.templ b/darkstat/front/shared.templ index 918c95be..9e490c9f 100644 --- a/darkstat/front/shared.templ +++ b/darkstat/front/shared.templ @@ -137,6 +137,7 @@ templ TabMenu(url utils_types.FilePath) { + }
diff --git a/darkstat/front/thrusters.templ b/darkstat/front/thrusters.templ new file mode 100644 index 00000000..6a2d7408 --- /dev/null +++ b/darkstat/front/thrusters.templ @@ -0,0 +1,87 @@ +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 ThrusterDetailedUrl(thruster configs_export.Thruster) string { + return "thrusters/thruster_base_" + strings.ToLower(thruster.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 ThrusterT(thrusters []configs_export.Thruster) { + @TabMenu(urls.Thrusters) + @TabContent() { +
+
+
+ + + + + + + + + + + + + + + + + + + + + for _, thruster := range thrusters { + + + + + + + + + + + + + + + + @templ.Raw(JoinClickTriggers("bottominfo_click"+thruster.Nickname, "infocard_click"+thruster.Nickname)) + + } + +
ThrusterPriceBuyableMax ForcePower UsageEfficiencyValueRatingHit PtsLootableNicknameName IDInfo ID
{ thruster.Name }{ strconv.Itoa(thruster.Price) } { strconv.FormatBool(len(thruster.Bases) > 0) }{ strconv.Itoa(thruster.MaxForce) } { strconv.Itoa(thruster.PowerUsage) }{ fmt.Sprintf("%.2f",thruster.Efficiency) }{ fmt.Sprintf("%.2f", thruster.Value) }{ fmt.Sprintf("%.2f", thruster.Rating) }{ strconv.Itoa(thruster.HitPts) }{ strconv.FormatBool(thruster.Lootable) }{ thruster.Nickname } { strconv.Itoa(thruster.NameID) } { strconv.Itoa(thruster.InfoID) }
+
+
+ @GoodAtBaseSharedT(ShowPricePerVolume(false)) +
+
+
+ @InfocardShared() +
+
+ } +} diff --git a/darkstat/front/urls/urls.go b/darkstat/front/urls/urls.go index 8c3b5ec9..2e3858f6 100644 --- a/darkstat/front/urls/urls.go +++ b/darkstat/front/urls/urls.go @@ -15,4 +15,5 @@ const ( Missiles utils_types.FilePath = "missiles.html" Mines utils_types.FilePath = "mines.html" Shields utils_types.FilePath = "shields.html" + Thrusters utils_types.FilePath = "thrusters.html" ) diff --git a/darkstat/linker/linker.go b/darkstat/linker/linker.go index affc4c0b..f544e50c 100644 --- a/darkstat/linker/linker.go +++ b/darkstat/linker/linker.go @@ -133,6 +133,22 @@ func (l *Linker) Link() *builder.Builder { }) } + sort.Slice(data.Thrusters, func(i, j int) bool { + if data.Thrusters[i].Name != "" && data.Thrusters[j].Name == "" { + return true + } + return data.Thrusters[i].Name < data.Thrusters[j].Name + }) + + for _, base_info := range data.Thrusters { + 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( @@ -175,6 +191,10 @@ func (l *Linker) Link() *builder.Builder { urls.Shields, front.ShieldT(data.Shields), ), + builder.NewComponent( + urls.Thrusters, + front.ThrusterT(data.Thrusters), + ), ) for _, base := range data.Bases { @@ -258,5 +278,14 @@ func (l *Linker) Link() *builder.Builder { ) } + for _, thruster := range data.Thrusters { + build.RegComps( + builder.NewComponent( + utils_types.FilePath(front.ThrusterDetailedUrl(thruster)), + front.GoodAtBaseInfoT(thruster.Bases, front.ShowPricePerVolume(false)), + ), + ) + } + return build } diff --git a/go.mod b/go.mod index 547ba19f..74bb1875 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.24.0 + github.com/darklab8/fl-configs v0.25.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 b41c2b97..1b9a30fc 100644 --- a/go.sum +++ b/go.sum @@ -26,6 +26,8 @@ github.com/darklab8/fl-configs v0.23.1 h1:NnPyyodeJEyAzbCLlcvlwl/vxFOMldZRReacx7 github.com/darklab8/fl-configs v0.23.1/go.mod h1:8zaCaFL21TvawP65KB9NOJ+nEpaMDQYsnoOi77RiSVY= github.com/darklab8/fl-configs v0.24.0 h1:0FyycPLtFAehWIzw/REvt5GXC1Is4keqBOSiuT0+4TU= github.com/darklab8/fl-configs v0.24.0/go.mod h1:8zaCaFL21TvawP65KB9NOJ+nEpaMDQYsnoOi77RiSVY= +github.com/darklab8/fl-configs v0.25.0 h1:A3ydu6zAiA8Szsv7bCaatsHDz1qdRGXhkQBUkBhzIJo= +github.com/darklab8/fl-configs v0.25.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=