From 8f823c93268e5db0cf4cf266c884ebc9ea9f3d57 Mon Sep 17 00:00:00 2001 From: dd84ai Date: Sun, 31 Mar 2024 14:19:00 +0200 Subject: [PATCH] feat: gun modifiers tab --- darkstat/common/common_static/common.templ | 2 +- darkstat/front/guns.templ | 68 +++++++++++++++++++--- darkstat/front/shared.templ | 1 + darkstat/front/urls/urls.go | 13 +++-- darkstat/linker/linker.go | 16 +++-- 5 files changed, 81 insertions(+), 19 deletions(-) diff --git a/darkstat/common/common_static/common.templ b/darkstat/common/common_static/common.templ index b2cd85ec..06cb730a 100644 --- a/darkstat/common/common_static/common.templ +++ b/darkstat/common/common_static/common.templ @@ -9,7 +9,7 @@ templ CommonCSS() { } p { - font-size: 1.17em; + font-size: 1.1em; } hr { diff --git a/darkstat/front/guns.templ b/darkstat/front/guns.templ index bc3d39e5..9855e3e4 100644 --- a/darkstat/front/guns.templ +++ b/darkstat/front/guns.templ @@ -9,14 +9,29 @@ import ( "strings" ) -func GunBaseInfoUrl(gun configs_export.Gun) string { - return "guns/guns_base_" + strings.ToLower(gun.Nickname) +func GunDetailedUrl(gun configs_export.Gun, mode GunTabMode) string { + if mode == GunsShowBases { + return "guns/guns_base_" + strings.ToLower(gun.Nickname) + } else { + return "guns/guns_bonuses_" + strings.ToLower(gun.Nickname) + } } +type GunTabMode int64 + +const ( + GunsShowBases GunTabMode = iota + GunsShowDamageBonuses +) + // 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 GunsT(guns []configs_export.Gun) { - @TabMenu(urls.Guns) +templ GunsT(guns []configs_export.Gun, mode GunTabMode) { + if mode == GunsShowBases { + @TabMenu(urls.Guns) + } else { + @TabMenu(urls.GunModifiers) + } @TabContent() {
@@ -53,8 +68,8 @@ templ GunsT(guns []configs_export.Gun) { for _, gun := range guns { - @templ.Raw(JoinClickTriggers("baseinfo_click"+gun.Nickname, "infocard_click"+gun.Nickname)) + @templ.Raw(JoinClickTriggers("guninfo_click"+gun.Nickname, "infocard_click"+gun.Nickname)) }
- @GoodAtBaseSharedT(ShowPricePerVolume(true)) + if mode == GunsShowBases { + @GoodAtBaseSharedT(ShowPricePerVolume(true)) + } else { + @GunShowModifiersShared() + }
@@ -105,3 +124,36 @@ templ GunsT(guns []configs_export.Gun) {
} } + +templ GunShowModifiersShared() { + + + + + + + + + + + + + { children... } + +
TechnologyTarget TypeDamage ModifierHull DmgShield Dmg
+} + +templ GunShowModifiers(gun configs_export.Gun) { + @GunShowModifiersShared() { + for _, bonus := range gun.DamangeBonuses { + + { gun.DamageType } + { bonus.Type } + { fmt.Sprintf("%.2f", bonus.Modifier) } + { strconv.Itoa(int(float64(gun.HullDamage)*bonus.Modifier)) } + { strconv.Itoa(int(float64(gun.ShieldDamage)*bonus.Modifier)) } + + + } + } +} diff --git a/darkstat/front/shared.templ b/darkstat/front/shared.templ index eb1e6dc7..f1e676f0 100644 --- a/darkstat/front/shared.templ +++ b/darkstat/front/shared.templ @@ -122,6 +122,7 @@ templ TabMenu(url utils_types.FilePath) { + }
diff --git a/darkstat/front/urls/urls.go b/darkstat/front/urls/urls.go index 095d42f2..4ac502cd 100644 --- a/darkstat/front/urls/urls.go +++ b/darkstat/front/urls/urls.go @@ -5,10 +5,11 @@ import ( ) const ( - Index utils_types.FilePath = "index.html" - Bases utils_types.FilePath = "bases.html" - Factions utils_types.FilePath = "factions.html" - Rephacks utils_types.FilePath = "rephacks.html" - Commodities utils_types.FilePath = "commodities.html" - Guns utils_types.FilePath = "guns.html" + Index utils_types.FilePath = "index.html" + Bases utils_types.FilePath = "bases.html" + Factions utils_types.FilePath = "factions.html" + Rephacks utils_types.FilePath = "rephacks.html" + Commodities utils_types.FilePath = "commodities.html" + Guns utils_types.FilePath = "guns.html" + GunModifiers utils_types.FilePath = "gun_modifiers.html" ) diff --git a/darkstat/linker/linker.go b/darkstat/linker/linker.go index a099da71..b736db00 100644 --- a/darkstat/linker/linker.go +++ b/darkstat/linker/linker.go @@ -132,7 +132,11 @@ func (l *Linker) Link() *builder.Builder { ), builder.NewComponent( urls.Guns, - front.GunsT(data.Guns), + front.GunsT(data.Guns, front.GunsShowBases), + ), + builder.NewComponent( + urls.GunModifiers, + front.GunsT(data.Guns, front.GunsShowDamageBonuses), ), ) @@ -177,11 +181,15 @@ func (l *Linker) Link() *builder.Builder { ) } - for _, base_info := range data.Guns { + for _, gun := range data.Guns { build.RegComps( builder.NewComponent( - utils_types.FilePath(front.GunBaseInfoUrl(base_info)), - front.GoodAtBaseInfoT(base_info.Bases, front.ShowPricePerVolume(false)), + utils_types.FilePath(front.GunDetailedUrl(gun, front.GunsShowBases)), + front.GoodAtBaseInfoT(gun.Bases, front.ShowPricePerVolume(false)), + ), + builder.NewComponent( + utils_types.FilePath(front.GunDetailedUrl(gun, front.GunsShowDamageBonuses)), + front.GunShowModifiers(gun), ), ) }