From a16d5d6f8de8780e919b343311edbbc1a7460524 Mon Sep 17 00:00:00 2001 From: jarves Date: Wed, 4 Oct 2023 23:39:32 -0500 Subject: [PATCH 1/4] ui: rework touch detection - potentially better fix for hover usage Signed-off-by: jarves --- ui/shared/bootstrap_overrides.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ui/shared/bootstrap_overrides.ts b/ui/shared/bootstrap_overrides.ts index 6fb606175c..7769be606b 100644 --- a/ui/shared/bootstrap_overrides.ts +++ b/ui/shared/bootstrap_overrides.ts @@ -8,13 +8,17 @@ Tooltip.Default.trigger = "hover"; let body = document.querySelector('body') as HTMLElement; -function isTouchDevice() { +function hasTouch() { return ('ontouchstart' in window) || (navigator.maxTouchPoints > 0); } +function hasHover() { + return window.matchMedia("(any-hover: hover)").matches; +} + // Disable 'mouseover' to avoid needed to double click on mobile // Leaving 'mouseleave', however still allows dropdown to close when clicking new box -if (!isTouchDevice()) { +if (!hasTouch() || hasHover()) { // Custom dropdown event handlers for mouseover dropdowns body.addEventListener('mouseover', event => { let target = event.target as HTMLElement; From 680d469ec27522219f7acb7dcc38f22876b52873 Mon Sep 17 00:00:00 2001 From: jarves Date: Wed, 4 Oct 2023 23:51:45 -0500 Subject: [PATCH 2/4] feral: add castcondition on tigers fury Signed-off-by: jarves --- sim/druid/tigers_fury.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sim/druid/tigers_fury.go b/sim/druid/tigers_fury.go index fa18b99640..5da3aa320a 100644 --- a/sim/druid/tigers_fury.go +++ b/sim/druid/tigers_fury.go @@ -35,6 +35,9 @@ func (druid *Druid) registerTigersFurySpell() { Duration: time.Second*30 - cdReduction, }, }, + ExtraCastCondition: func(sim *core.Simulation, target *core.Unit) bool { + return !druid.BerserkAura.IsActive() + }, ApplyEffects: func(sim *core.Simulation, _ *core.Unit, _ *core.Spell) { druid.AddEnergy(sim, instantEnergy, energyMetrics) From c9083adefb18d7340833372ff7a4b19123a3c217 Mon Sep 17 00:00:00 2001 From: jarves Date: Wed, 27 Sep 2023 23:18:59 -0500 Subject: [PATCH 3/4] core: pass character init struct by ptr Signed-off-by: jarves --- sim/core/agent.go | 4 ++-- sim/core/dot_test.go | 4 ++-- sim/deathknight/deathknight.go | 4 ++-- sim/deathknight/dps/dps_deathknight.go | 4 ++-- sim/deathknight/tank/tank_deathknight.go | 4 ++-- sim/druid/balance/balance.go | 4 ++-- sim/druid/druid.go | 4 ++-- sim/druid/feral/feral.go | 4 ++-- sim/druid/restoration/restoration.go | 4 ++-- sim/druid/tank/tank.go | 4 ++-- sim/hunter/hunter.go | 6 +++--- sim/mage/mage.go | 6 +++--- sim/paladin/holy/holy.go | 4 ++-- sim/paladin/paladin.go | 4 ++-- sim/paladin/protection/protection.go | 4 ++-- sim/paladin/retribution/retribution.go | 4 ++-- sim/priest/healing/healing_priest.go | 4 ++-- sim/priest/priest.go | 4 ++-- sim/priest/shadow/shadow_priest.go | 4 ++-- sim/priest/smite/smite_priest.go | 4 ++-- sim/rogue/rogue.go | 6 +++--- sim/shaman/elemental/elemental.go | 4 ++-- sim/shaman/enhancement/enhancement.go | 4 ++-- sim/shaman/restoration/restoration.go | 4 ++-- sim/shaman/shaman.go | 4 ++-- sim/warlock/warlock.go | 6 +++--- sim/warrior/dps/dps_warrior.go | 4 ++-- sim/warrior/protection/protection_warrior.go | 4 ++-- sim/warrior/warrior.go | 4 ++-- 29 files changed, 62 insertions(+), 62 deletions(-) diff --git a/sim/core/agent.go b/sim/core/agent.go index d5b632edee..2cc4427a3a 100644 --- a/sim/core/agent.go +++ b/sim/core/agent.go @@ -141,7 +141,7 @@ func ProtoToActionID(protoID *proto.ActionID) ActionID { } } -type AgentFactory func(Character, *proto.Player) Agent +type AgentFactory func(*Character, *proto.Player) Agent type SpecSetter func(*proto.Player, interface{}) var agentFactories = make(map[string]AgentFactory) @@ -175,7 +175,7 @@ func NewAgent(party *Party, partyIndex int, player *proto.Player) Agent { } character := NewCharacter(party, partyIndex, player) - return factory(character, player) + return factory(&character, player) } // Applies the spec options to the given player. This is only necessary because diff --git a/sim/core/dot_test.go b/sim/core/dot_test.go index 9f13e87b0a..b3cfe23e40 100644 --- a/sim/core/dot_test.go +++ b/sim/core/dot_test.go @@ -23,9 +23,9 @@ func init() { ) } -func NewFakeElementalShaman(char Character, options *proto.Player) Agent { +func NewFakeElementalShaman(char *Character, options *proto.Player) Agent { fa := &FakeAgent{ - Character: char, + Character: *char, } fa.Init = func() { diff --git a/sim/deathknight/deathknight.go b/sim/deathknight/deathknight.go index aef2c1ead5..ff1f562d5a 100644 --- a/sim/deathknight/deathknight.go +++ b/sim/deathknight/deathknight.go @@ -407,9 +407,9 @@ func (dk *Deathknight) HasMinorGlyph(glyph proto.DeathknightMinorGlyph) bool { return dk.HasGlyph(int32(glyph)) } -func NewDeathknight(character core.Character, inputs DeathknightInputs, talents string, preNerfedGargoyle bool) *Deathknight { +func NewDeathknight(character *core.Character, inputs DeathknightInputs, talents string, preNerfedGargoyle bool) *Deathknight { dk := &Deathknight{ - Character: character, + Character: *character, Talents: &proto.DeathknightTalents{}, Inputs: inputs, RoRTSBonus: func(u *core.Unit) float64 { return 1.0 }, // default to no bonus for RoR/TS diff --git a/sim/deathknight/dps/dps_deathknight.go b/sim/deathknight/dps/dps_deathknight.go index 10001f1a96..c81db86a26 100644 --- a/sim/deathknight/dps/dps_deathknight.go +++ b/sim/deathknight/dps/dps_deathknight.go @@ -13,7 +13,7 @@ func RegisterDpsDeathknight() { core.RegisterAgentFactory( proto.Player_Deathknight{}, proto.Spec_SpecDeathknight, - func(character core.Character, options *proto.Player) core.Agent { + func(character *core.Character, options *proto.Player) core.Agent { return NewDpsDeathknight(character, options) }, func(player *proto.Player, spec interface{}) { @@ -41,7 +41,7 @@ type DpsDeathknight struct { rotationSetup func() } -func NewDpsDeathknight(character core.Character, player *proto.Player) *DpsDeathknight { +func NewDpsDeathknight(character *core.Character, player *proto.Player) *DpsDeathknight { dk := player.GetDeathknight() dpsDk := &DpsDeathknight{ diff --git a/sim/deathknight/tank/tank_deathknight.go b/sim/deathknight/tank/tank_deathknight.go index d750e31879..8483a3a40d 100644 --- a/sim/deathknight/tank/tank_deathknight.go +++ b/sim/deathknight/tank/tank_deathknight.go @@ -10,7 +10,7 @@ func RegisterTankDeathknight() { core.RegisterAgentFactory( proto.Player_TankDeathknight{}, proto.Spec_SpecTankDeathknight, - func(character core.Character, options *proto.Player) core.Agent { + func(character *core.Character, options *proto.Player) core.Agent { return NewTankDeathknight(character, options) }, func(player *proto.Player, spec interface{}) { @@ -33,7 +33,7 @@ type TankDeathknight struct { Rotation *proto.TankDeathknight_Rotation } -func NewTankDeathknight(character core.Character, options *proto.Player) *TankDeathknight { +func NewTankDeathknight(character *core.Character, options *proto.Player) *TankDeathknight { dkOptions := options.GetTankDeathknight() tankDk := &TankDeathknight{ diff --git a/sim/druid/balance/balance.go b/sim/druid/balance/balance.go index 740c4d7053..1b0f975144 100644 --- a/sim/druid/balance/balance.go +++ b/sim/druid/balance/balance.go @@ -12,7 +12,7 @@ func RegisterBalanceDruid() { core.RegisterAgentFactory( proto.Player_BalanceDruid{}, proto.Spec_SpecBalanceDruid, - func(character core.Character, options *proto.Player) core.Agent { + func(character *core.Character, options *proto.Player) core.Agent { return NewBalanceDruid(character, options) }, func(player *proto.Player, spec interface{}) { @@ -25,7 +25,7 @@ func RegisterBalanceDruid() { ) } -func NewBalanceDruid(character core.Character, options *proto.Player) *BalanceDruid { +func NewBalanceDruid(character *core.Character, options *proto.Player) *BalanceDruid { balanceOptions := options.GetBalanceDruid() selfBuffs := druid.SelfBuffs{} diff --git a/sim/druid/druid.go b/sim/druid/druid.go index eda697cbdf..cceeab3639 100644 --- a/sim/druid/druid.go +++ b/sim/druid/druid.go @@ -270,9 +270,9 @@ func (druid *Druid) Reset(_ *core.Simulation) { druid.SolarICD.Timer.Reset() } -func New(char core.Character, form DruidForm, selfBuffs SelfBuffs, talents string) *Druid { +func New(char *core.Character, form DruidForm, selfBuffs SelfBuffs, talents string) *Druid { druid := &Druid{ - Character: char, + Character: *char, SelfBuffs: selfBuffs, Talents: &proto.DruidTalents{}, StartingForm: form, diff --git a/sim/druid/feral/feral.go b/sim/druid/feral/feral.go index cc2cff27d4..3ad5859ae3 100644 --- a/sim/druid/feral/feral.go +++ b/sim/druid/feral/feral.go @@ -12,7 +12,7 @@ func RegisterFeralDruid() { core.RegisterAgentFactory( proto.Player_FeralDruid{}, proto.Spec_SpecFeralDruid, - func(character core.Character, options *proto.Player) core.Agent { + func(character *core.Character, options *proto.Player) core.Agent { return NewFeralDruid(character, options) }, func(player *proto.Player, spec interface{}) { @@ -25,7 +25,7 @@ func RegisterFeralDruid() { ) } -func NewFeralDruid(character core.Character, options *proto.Player) *FeralDruid { +func NewFeralDruid(character *core.Character, options *proto.Player) *FeralDruid { feralOptions := options.GetFeralDruid() selfBuffs := druid.SelfBuffs{} diff --git a/sim/druid/restoration/restoration.go b/sim/druid/restoration/restoration.go index 98841723eb..428160c8d9 100644 --- a/sim/druid/restoration/restoration.go +++ b/sim/druid/restoration/restoration.go @@ -10,7 +10,7 @@ func RegisterRestorationDruid() { core.RegisterAgentFactory( proto.Player_RestorationDruid{}, proto.Spec_SpecRestorationDruid, - func(character core.Character, options *proto.Player) core.Agent { + func(character *core.Character, options *proto.Player) core.Agent { return NewRestorationDruid(character, options) }, func(player *proto.Player, spec interface{}) { @@ -23,7 +23,7 @@ func RegisterRestorationDruid() { ) } -func NewRestorationDruid(character core.Character, options *proto.Player) *RestorationDruid { +func NewRestorationDruid(character *core.Character, options *proto.Player) *RestorationDruid { restoOptions := options.GetRestorationDruid() selfBuffs := druid.SelfBuffs{} diff --git a/sim/druid/tank/tank.go b/sim/druid/tank/tank.go index 0646a23dbb..4224412452 100644 --- a/sim/druid/tank/tank.go +++ b/sim/druid/tank/tank.go @@ -10,7 +10,7 @@ func RegisterFeralTankDruid() { core.RegisterAgentFactory( proto.Player_FeralTankDruid{}, proto.Spec_SpecFeralTankDruid, - func(character core.Character, options *proto.Player) core.Agent { + func(character *core.Character, options *proto.Player) core.Agent { return NewFeralTankDruid(character, options) }, func(player *proto.Player, spec interface{}) { @@ -23,7 +23,7 @@ func RegisterFeralTankDruid() { ) } -func NewFeralTankDruid(character core.Character, options *proto.Player) *FeralTankDruid { +func NewFeralTankDruid(character *core.Character, options *proto.Player) *FeralTankDruid { tankOptions := options.GetFeralTankDruid() selfBuffs := druid.SelfBuffs{} diff --git a/sim/hunter/hunter.go b/sim/hunter/hunter.go index 9a0795340e..4bc6d67256 100644 --- a/sim/hunter/hunter.go +++ b/sim/hunter/hunter.go @@ -17,7 +17,7 @@ func RegisterHunter() { core.RegisterAgentFactory( proto.Player_Hunter{}, proto.Spec_SpecHunter, - func(character core.Character, options *proto.Player) core.Agent { + func(character *core.Character, options *proto.Player) core.Agent { return NewHunter(character, options) }, func(player *proto.Player, spec interface{}) { @@ -170,11 +170,11 @@ func (hunter *Hunter) Reset(_ *core.Simulation) { hunter.permaHawk = false } -func NewHunter(character core.Character, options *proto.Player) *Hunter { +func NewHunter(character *core.Character, options *proto.Player) *Hunter { hunterOptions := options.GetHunter() hunter := &Hunter{ - Character: character, + Character: *character, Talents: &proto.HunterTalents{}, Options: hunterOptions.Options, Rotation: hunterOptions.Rotation, diff --git a/sim/mage/mage.go b/sim/mage/mage.go index ce760238e1..eb49d92fda 100644 --- a/sim/mage/mage.go +++ b/sim/mage/mage.go @@ -22,7 +22,7 @@ func RegisterMage() { core.RegisterAgentFactory( proto.Player_Mage{}, proto.Spec_SpecMage, - func(character core.Character, options *proto.Player) core.Agent { + func(character *core.Character, options *proto.Player) core.Agent { return NewMage(character, options) }, func(player *proto.Player, spec interface{}) { @@ -157,11 +157,11 @@ func (mage *Mage) Reset(sim *core.Simulation) { mage.delayedPyroAt = 0 } -func NewMage(character core.Character, options *proto.Player) *Mage { +func NewMage(character *core.Character, options *proto.Player) *Mage { mageOptions := options.GetMage() mage := &Mage{ - Character: character, + Character: *character, Talents: &proto.MageTalents{}, Options: mageOptions.Options, Rotation: mageOptions.Rotation, diff --git a/sim/paladin/holy/holy.go b/sim/paladin/holy/holy.go index eae3966848..7230b32915 100644 --- a/sim/paladin/holy/holy.go +++ b/sim/paladin/holy/holy.go @@ -10,7 +10,7 @@ func RegisterHolyPaladin() { core.RegisterAgentFactory( proto.Player_HolyPaladin{}, proto.Spec_SpecHolyPaladin, - func(character core.Character, options *proto.Player) core.Agent { + func(character *core.Character, options *proto.Player) core.Agent { return NewHolyPaladin(character, options) }, func(player *proto.Player, spec interface{}) { @@ -23,7 +23,7 @@ func RegisterHolyPaladin() { ) } -func NewHolyPaladin(character core.Character, options *proto.Player) *HolyPaladin { +func NewHolyPaladin(character *core.Character, options *proto.Player) *HolyPaladin { holyOptions := options.GetHolyPaladin() holy := &HolyPaladin{ diff --git a/sim/paladin/paladin.go b/sim/paladin/paladin.go index bd323d89b4..16c0ee4df9 100644 --- a/sim/paladin/paladin.go +++ b/sim/paladin/paladin.go @@ -169,9 +169,9 @@ func (paladin *Paladin) Reset(_ *core.Simulation) { } // maybe need to add stat dependencies -func NewPaladin(character core.Character, talentsStr string) *Paladin { +func NewPaladin(character *core.Character, talentsStr string) *Paladin { paladin := &Paladin{ - Character: character, + Character: *character, Talents: &proto.PaladinTalents{}, } core.FillTalentsProto(paladin.Talents.ProtoReflect(), talentsStr, TalentTreeSizes) diff --git a/sim/paladin/protection/protection.go b/sim/paladin/protection/protection.go index 7deec28fc6..ddb9f64720 100644 --- a/sim/paladin/protection/protection.go +++ b/sim/paladin/protection/protection.go @@ -12,7 +12,7 @@ func RegisterProtectionPaladin() { core.RegisterAgentFactory( proto.Player_ProtectionPaladin{}, proto.Spec_SpecProtectionPaladin, - func(character core.Character, options *proto.Player) core.Agent { + func(character *core.Character, options *proto.Player) core.Agent { return NewProtectionPaladin(character, options) }, func(player *proto.Player, spec interface{}) { @@ -25,7 +25,7 @@ func RegisterProtectionPaladin() { ) } -func NewProtectionPaladin(character core.Character, options *proto.Player) *ProtectionPaladin { +func NewProtectionPaladin(character *core.Character, options *proto.Player) *ProtectionPaladin { protOptions := options.GetProtectionPaladin() prot := &ProtectionPaladin{ diff --git a/sim/paladin/retribution/retribution.go b/sim/paladin/retribution/retribution.go index bcfec3190a..c619ce0f6a 100644 --- a/sim/paladin/retribution/retribution.go +++ b/sim/paladin/retribution/retribution.go @@ -12,7 +12,7 @@ func RegisterRetributionPaladin() { core.RegisterAgentFactory( proto.Player_RetributionPaladin{}, proto.Spec_SpecRetributionPaladin, - func(character core.Character, options *proto.Player) core.Agent { + func(character *core.Character, options *proto.Player) core.Agent { return NewRetributionPaladin(character, options) }, func(player *proto.Player, spec interface{}) { @@ -25,7 +25,7 @@ func RegisterRetributionPaladin() { ) } -func NewRetributionPaladin(character core.Character, options *proto.Player) *RetributionPaladin { +func NewRetributionPaladin(character *core.Character, options *proto.Player) *RetributionPaladin { retOptions := options.GetRetributionPaladin() pal := paladin.NewPaladin(character, options.TalentsString) diff --git a/sim/priest/healing/healing_priest.go b/sim/priest/healing/healing_priest.go index f1e43ff1b4..743f2e3231 100644 --- a/sim/priest/healing/healing_priest.go +++ b/sim/priest/healing/healing_priest.go @@ -11,7 +11,7 @@ func RegisterHealingPriest() { core.RegisterAgentFactory( proto.Player_HealingPriest{}, proto.Spec_SpecHealingPriest, - func(character core.Character, options *proto.Player) core.Agent { + func(character *core.Character, options *proto.Player) core.Agent { return NewHealingPriest(character, options) }, func(player *proto.Player, spec interface{}) { @@ -36,7 +36,7 @@ type HealingPriest struct { nextCycleIndex int } -func NewHealingPriest(character core.Character, options *proto.Player) *HealingPriest { +func NewHealingPriest(character *core.Character, options *proto.Player) *HealingPriest { healingOptions := options.GetHealingPriest() selfBuffs := priest.SelfBuffs{ diff --git a/sim/priest/priest.go b/sim/priest/priest.go index 204468b277..f17b9dd42c 100644 --- a/sim/priest/priest.go +++ b/sim/priest/priest.go @@ -181,9 +181,9 @@ func (priest *Priest) Reset(_ *core.Simulation) { priest.MindBlastModifier = 1 } -func New(char core.Character, selfBuffs SelfBuffs, talents string) *Priest { +func New(char *core.Character, selfBuffs SelfBuffs, talents string) *Priest { priest := &Priest{ - Character: char, + Character: *char, SelfBuffs: selfBuffs, Talents: &proto.PriestTalents{}, } diff --git a/sim/priest/shadow/shadow_priest.go b/sim/priest/shadow/shadow_priest.go index 1ba2c71634..0562a657f1 100644 --- a/sim/priest/shadow/shadow_priest.go +++ b/sim/priest/shadow/shadow_priest.go @@ -13,7 +13,7 @@ func RegisterShadowPriest() { core.RegisterAgentFactory( proto.Player_ShadowPriest{}, proto.Spec_SpecShadowPriest, - func(character core.Character, options *proto.Player) core.Agent { + func(character *core.Character, options *proto.Player) core.Agent { return NewShadowPriest(character, options) }, func(player *proto.Player, spec interface{}) { @@ -26,7 +26,7 @@ func RegisterShadowPriest() { ) } -func NewShadowPriest(character core.Character, options *proto.Player) *ShadowPriest { +func NewShadowPriest(character *core.Character, options *proto.Player) *ShadowPriest { shadowOptions := options.GetShadowPriest() selfBuffs := priest.SelfBuffs{ diff --git a/sim/priest/smite/smite_priest.go b/sim/priest/smite/smite_priest.go index bb08670cea..ea967c83bb 100644 --- a/sim/priest/smite/smite_priest.go +++ b/sim/priest/smite/smite_priest.go @@ -12,7 +12,7 @@ func RegisterSmitePriest() { core.RegisterAgentFactory( proto.Player_SmitePriest{}, proto.Spec_SpecSmitePriest, - func(character core.Character, options *proto.Player) core.Agent { + func(character *core.Character, options *proto.Player) core.Agent { return NewSmitePriest(character, options) }, func(player *proto.Player, spec interface{}) { @@ -25,7 +25,7 @@ func RegisterSmitePriest() { ) } -func NewSmitePriest(character core.Character, options *proto.Player) *SmitePriest { +func NewSmitePriest(character *core.Character, options *proto.Player) *SmitePriest { smiteOptions := options.GetSmitePriest() selfBuffs := priest.SelfBuffs{ diff --git a/sim/rogue/rogue.go b/sim/rogue/rogue.go index d11730e818..9f4693a888 100644 --- a/sim/rogue/rogue.go +++ b/sim/rogue/rogue.go @@ -13,7 +13,7 @@ func RegisterRogue() { core.RegisterAgentFactory( proto.Player_Rogue{}, proto.Spec_SpecRogue, - func(character core.Character, options *proto.Player) core.Agent { + func(character *core.Character, options *proto.Player) core.Agent { return NewRogue(character, options) }, func(player *proto.Player, spec interface{}) { @@ -240,11 +240,11 @@ func (rogue *Rogue) SpellCritMultiplier() float64 { return rogue.Character.SpellCritMultiplier(primaryModifier, 0) } -func NewRogue(character core.Character, options *proto.Player) *Rogue { +func NewRogue(character *core.Character, options *proto.Player) *Rogue { rogueOptions := options.GetRogue() rogue := &Rogue{ - Character: character, + Character: *character, Talents: &proto.RogueTalents{}, Options: rogueOptions.Options, Rotation: rogueOptions.Rotation, diff --git a/sim/shaman/elemental/elemental.go b/sim/shaman/elemental/elemental.go index 6cabb9ebb9..1c2c9467a8 100644 --- a/sim/shaman/elemental/elemental.go +++ b/sim/shaman/elemental/elemental.go @@ -11,7 +11,7 @@ func RegisterElementalShaman() { core.RegisterAgentFactory( proto.Player_ElementalShaman{}, proto.Spec_SpecElementalShaman, - func(character core.Character, options *proto.Player) core.Agent { + func(character *core.Character, options *proto.Player) core.Agent { return NewElementalShaman(character, options) }, func(player *proto.Player, spec interface{}) { @@ -24,7 +24,7 @@ func RegisterElementalShaman() { ) } -func NewElementalShaman(character core.Character, options *proto.Player) *ElementalShaman { +func NewElementalShaman(character *core.Character, options *proto.Player) *ElementalShaman { eleShamOptions := options.GetElementalShaman() selfBuffs := shaman.SelfBuffs{ diff --git a/sim/shaman/enhancement/enhancement.go b/sim/shaman/enhancement/enhancement.go index 4bff9d7a47..352ed1846e 100644 --- a/sim/shaman/enhancement/enhancement.go +++ b/sim/shaman/enhancement/enhancement.go @@ -13,7 +13,7 @@ func RegisterEnhancementShaman() { core.RegisterAgentFactory( proto.Player_EnhancementShaman{}, proto.Spec_SpecEnhancementShaman, - func(character core.Character, options *proto.Player) core.Agent { + func(character *core.Character, options *proto.Player) core.Agent { return NewEnhancementShaman(character, options) }, func(player *proto.Player, spec interface{}) { @@ -26,7 +26,7 @@ func RegisterEnhancementShaman() { ) } -func NewEnhancementShaman(character core.Character, options *proto.Player) *EnhancementShaman { +func NewEnhancementShaman(character *core.Character, options *proto.Player) *EnhancementShaman { enhOptions := options.GetEnhancementShaman() selfBuffs := shaman.SelfBuffs{ diff --git a/sim/shaman/restoration/restoration.go b/sim/shaman/restoration/restoration.go index 0db14fbf8d..4918aeb645 100644 --- a/sim/shaman/restoration/restoration.go +++ b/sim/shaman/restoration/restoration.go @@ -12,7 +12,7 @@ func RegisterRestorationShaman() { core.RegisterAgentFactory( proto.Player_RestorationShaman{}, proto.Spec_SpecRestorationShaman, - func(character core.Character, options *proto.Player) core.Agent { + func(character *core.Character, options *proto.Player) core.Agent { return NewRestorationShaman(character, options) }, func(player *proto.Player, spec interface{}) { @@ -25,7 +25,7 @@ func RegisterRestorationShaman() { ) } -func NewRestorationShaman(character core.Character, options *proto.Player) *RestorationShaman { +func NewRestorationShaman(character *core.Character, options *proto.Player) *RestorationShaman { restoShamOptions := options.GetRestorationShaman() selfBuffs := shaman.SelfBuffs{ diff --git a/sim/shaman/shaman.go b/sim/shaman/shaman.go index 615b279710..54fc38d315 100644 --- a/sim/shaman/shaman.go +++ b/sim/shaman/shaman.go @@ -20,9 +20,9 @@ const ( SpellFlagFocusable = core.SpellFlagAgentReserved4 ) -func NewShaman(character core.Character, talents string, totems *proto.ShamanTotems, selfBuffs SelfBuffs, thunderstormRange bool) *Shaman { +func NewShaman(character *core.Character, talents string, totems *proto.ShamanTotems, selfBuffs SelfBuffs, thunderstormRange bool) *Shaman { shaman := &Shaman{ - Character: character, + Character: *character, Talents: &proto.ShamanTalents{}, Totems: totems, SelfBuffs: selfBuffs, diff --git a/sim/warlock/warlock.go b/sim/warlock/warlock.go index 969fed5a43..feac522c25 100644 --- a/sim/warlock/warlock.go +++ b/sim/warlock/warlock.go @@ -209,11 +209,11 @@ func (warlock *Warlock) Reset(sim *core.Simulation) { warlock.setupCooldowns(sim) } -func NewWarlock(character core.Character, options *proto.Player) *Warlock { +func NewWarlock(character *core.Character, options *proto.Player) *Warlock { warlockOptions := options.GetWarlock() warlock := &Warlock{ - Character: character, + Character: *character, Talents: &proto.WarlockTalents{}, Options: warlockOptions.Options, Rotation: warlockOptions.Rotation, @@ -250,7 +250,7 @@ func RegisterWarlock() { core.RegisterAgentFactory( proto.Player_Warlock{}, proto.Spec_SpecWarlock, - func(character core.Character, options *proto.Player) core.Agent { + func(character *core.Character, options *proto.Player) core.Agent { return NewWarlock(character, options) }, func(player *proto.Player, spec interface{}) { diff --git a/sim/warrior/dps/dps_warrior.go b/sim/warrior/dps/dps_warrior.go index 9239e67158..92b9136b7b 100644 --- a/sim/warrior/dps/dps_warrior.go +++ b/sim/warrior/dps/dps_warrior.go @@ -13,7 +13,7 @@ func RegisterDpsWarrior() { core.RegisterAgentFactory( proto.Player_Warrior{}, proto.Spec_SpecWarrior, - func(character core.Character, options *proto.Player) core.Agent { + func(character *core.Character, options *proto.Player) core.Agent { return NewDpsWarrior(character, options) }, func(player *proto.Player, spec interface{}) { @@ -44,7 +44,7 @@ type DpsWarrior struct { castSlamAt time.Duration } -func NewDpsWarrior(character core.Character, options *proto.Player) *DpsWarrior { +func NewDpsWarrior(character *core.Character, options *proto.Player) *DpsWarrior { warOptions := options.GetWarrior() war := &DpsWarrior{ diff --git a/sim/warrior/protection/protection_warrior.go b/sim/warrior/protection/protection_warrior.go index de5046e053..2c70c418db 100644 --- a/sim/warrior/protection/protection_warrior.go +++ b/sim/warrior/protection/protection_warrior.go @@ -11,7 +11,7 @@ func RegisterProtectionWarrior() { core.RegisterAgentFactory( proto.Player_ProtectionWarrior{}, proto.Spec_SpecProtectionWarrior, - func(character core.Character, options *proto.Player) core.Agent { + func(character *core.Character, options *proto.Player) core.Agent { return NewProtectionWarrior(character, options) }, func(player *proto.Player, spec interface{}) { @@ -33,7 +33,7 @@ type ProtectionWarrior struct { CustomRotation *common.CustomRotation } -func NewProtectionWarrior(character core.Character, options *proto.Player) *ProtectionWarrior { +func NewProtectionWarrior(character *core.Character, options *proto.Player) *ProtectionWarrior { warOptions := options.GetProtectionWarrior() war := &ProtectionWarrior{ diff --git a/sim/warrior/warrior.go b/sim/warrior/warrior.go index c999f05591..f76bbc025f 100644 --- a/sim/warrior/warrior.go +++ b/sim/warrior/warrior.go @@ -159,9 +159,9 @@ func (warrior *Warrior) Reset(_ *core.Simulation) { warrior.curQueuedAutoSpell = nil } -func NewWarrior(character core.Character, talents string, inputs WarriorInputs) *Warrior { +func NewWarrior(character *core.Character, talents string, inputs WarriorInputs) *Warrior { warrior := &Warrior{ - Character: character, + Character: *character, Talents: &proto.WarriorTalents{}, WarriorInputs: inputs, } From 450f0ac2f171e8f687bc2d895518489c0405f350 Mon Sep 17 00:00:00 2001 From: jarves Date: Thu, 5 Oct 2023 01:58:44 -0500 Subject: [PATCH 4/4] ui: character_stats cleanup - avoid recreating new picker every click Signed-off-by: jarves --- ui/core/components/character_stats.tsx | 42 +++++++++++--------------- ui/core/components/input.tsx | 2 +- ui/core/components/number_picker.ts | 2 +- 3 files changed, 19 insertions(+), 27 deletions(-) diff --git a/ui/core/components/character_stats.tsx b/ui/core/components/character_stats.tsx index 8deb14f7b3..9323f59b41 100644 --- a/ui/core/components/character_stats.tsx +++ b/ui/core/components/character_stats.tsx @@ -103,13 +103,10 @@ export class CharacterStats extends Component { let bonusStatValue = bonusStats.getStat(stat); if (bonusStatValue == 0) { - valueElem.classList.remove('text-success', 'text-danger'); valueElem.classList.add('text-white'); } else if (bonusStatValue > 0) { - valueElem.classList.remove('text-white', 'text-danger'); valueElem.classList.add('text-success'); } else if (bonusStatValue < 0) { - valueElem.classList.remove('text-white', 'text-success'); valueElem.classList.add('text-danger'); } @@ -240,32 +237,27 @@ export class CharacterStats extends Component { ); - let popover = Popover.getOrCreateInstance(link, { + let popover: Popover | null = null; + + let picker = new NumberPicker(null, this.player, { + label: `Bonus ${statName}`, + extraCssClasses: ['mb-0'], + changedEvent: (player: Player) => player.bonusStatsChangeEmitter, + getValue: (player: Player) => player.getBonusStats().getStat(stat), + setValue: (eventID: EventID, player: Player, newValue: number) => { + const bonusStats = player.getBonusStats().withStat(stat, newValue); + player.setBonusStats(eventID, bonusStats); + popover?.hide(); + }, + }); + + popover = new Popover(link, { customClass: 'bonus-stats-popover', placement: 'right', fallbackPlacement: ['left'], sanitize: false, - content: -
- - -
, - }); - - link.addEventListener('shown.bs.popover', (event) => { - let popoverBody = document.querySelector('.popover.bonus-stats-popover .popover-body') as HTMLElement; - popoverBody.innerHTML = ''; - let picker = new NumberPicker(popoverBody, this.player, { - label: `Bonus ${statName}`, - extraCssClasses: ['mb-0'], - changedEvent: (player: Player) => player.bonusStatsChangeEmitter, - getValue: (player: Player) => player.getBonusStats().getStat(stat), - setValue: (eventID: EventID, player: Player, newValue: number) => { - const bonusStats = player.getBonusStats().withStat(stat, newValue); - player.setBonusStats(eventID, bonusStats); - popover.hide(); - }, - }); + html:true, + content: picker.rootElem, }); return link as HTMLElement; diff --git a/ui/core/components/input.tsx b/ui/core/components/input.tsx index 6dba0973f3..4b0e7729ca 100644 --- a/ui/core/components/input.tsx +++ b/ui/core/components/input.tsx @@ -47,7 +47,7 @@ export abstract class Input extends Component { readonly changeEmitter = new TypedEvent(); - constructor(parent: HTMLElement, cssClass: string, modObject: ModObject, config: InputConfig) { + constructor(parent: HTMLElement | null, cssClass: string, modObject: ModObject, config: InputConfig) { super(parent, 'input-root', config.rootElem); this.inputConfig = config; this.modObject = modObject; diff --git a/ui/core/components/number_picker.ts b/ui/core/components/number_picker.ts index 5098bf82b9..e84d3b6972 100644 --- a/ui/core/components/number_picker.ts +++ b/ui/core/components/number_picker.ts @@ -16,7 +16,7 @@ export class NumberPicker extends Input { private float: boolean; private positive: boolean; - constructor(parent: HTMLElement, modObject: ModObject, config: NumberPickerConfig) { + constructor(parent: HTMLElement | null, modObject: ModObject, config: NumberPickerConfig) { super(parent, 'number-picker-root', modObject, config); this.float = config.float || false; this.positive = config.positive || false;