From caa4b2fc11d8bad650267187a3ea84c74be72b30 Mon Sep 17 00:00:00 2001 From: "M. Sz" Date: Mon, 14 Dec 2020 19:01:27 +0100 Subject: [PATCH 1/3] escape menu hotkeys --- d2game/d2player/escape_menu.go | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/d2game/d2player/escape_menu.go b/d2game/d2player/escape_menu.go index 2609da1f..0625add1 100644 --- a/d2game/d2player/escape_menu.go +++ b/d2game/d2player/escape_menu.go @@ -398,25 +398,15 @@ func (m *EscapeMenu) OnLoad() { // OnEscKey is called when the escape key is pressed func (m *EscapeMenu) OnEscKey() { - // note: original D2 returns straight to the game from however deep in the menu we are - switch m.currentLayout { - case optionsLayoutID: - m.setLayout(mainLayoutID) - return - case soundOptionsLayoutID, - videoOptionsLayoutID, - automapOptionsLayoutID, - configureControlsLayoutID: + if m.currentLayout == configureControlsLayoutID { m.setLayout(optionsLayoutID) if err := m.keyBindingMenu.Close(); err != nil { m.Errorf("unable to close the configure controls menu: %v", err.Error()) } - - return + } else { + m.close() } - - m.close() } // SetOnCloseCb sets the callback that is run when close() is called From 69fc4d30e43a0f5c7e749616cf5f83ec54420c0a Mon Sep 17 00:00:00 2001 From: "M. Sz" Date: Tue, 15 Dec 2020 09:16:40 +0100 Subject: [PATCH 2/3] hero save file --- d2app/app.go | 21 +++++++++++---------- d2core/d2hero/hero_stats_state.go | 31 ++++++++++++++----------------- 2 files changed, 25 insertions(+), 27 deletions(-) diff --git a/d2app/app.go b/d2app/app.go index f4ae128c..272af28c 100644 --- a/d2app/app.go +++ b/d2app/app.go @@ -233,11 +233,12 @@ func (a *App) parseArguments() { loggingShort = 'l' loggingDesc = "Enables verbose logging. Log levels will include those below it. " + "0 disables log messages, " + - "1 shows errors, " + - "2 shows warnings, " + - "3 shows info, " + - "4 shows debug" + - "5 uses value from config file (default)" + "1 shows fatal errors, " + + "2 shows errors, " + + "3 shows warnings, " + + "4 shows info, " + + "5 shows debug" + + "6 uses value from config file (default)" ) a.Options.profiler = kingpin.Flag(profilerArg, profilerDesc).String() @@ -315,7 +316,7 @@ func (a *App) Run() error { a.gitCommit = "build" } - fmt.Printf(fmtVersion, a.gitBranch, a.gitCommit) + a.Errorf(fmtVersion, a.gitBranch, a.gitCommit) os.Exit(0) } @@ -739,7 +740,7 @@ func (a *App) doCaptureFrame(target d2interface.Surface) error { return err } - a.Info(fmt.Sprintf("saved frame to %s", a.capturePath)) + a.Infof("saved frame to %s", a.capturePath) return nil } @@ -799,7 +800,7 @@ func (a *App) convertFramesToGif() error { return err } - a.Info(fmt.Sprintf("saved animation to %s", a.capturePath)) + a.Infof("saved animation to %s", a.capturePath) return nil } @@ -937,7 +938,7 @@ func (a *App) ToCreateGame(filePath string, connType d2clientconnectiontype.Clie if err = gameClient.Open(host, filePath); err != nil { errorMessage := fmt.Sprintf("can not connect to the host: %s", host) - fmt.Println(errorMessage) + a.Error(errorMessage) a.ToMainMenu(errorMessage) } else { game, err := d2gamescreen.CreateGame( @@ -956,7 +957,7 @@ func (a *App) ToCharacterSelect(connType d2clientconnectiontype.ClientConnection characterSelect, err := d2gamescreen.CreateCharacterSelect(a, a.asset, a.renderer, a.inputManager, a.audio, a.ui, connType, a.config.LogLevel, connHost) if err != nil { - fmt.Printf("unable to create character select screen: %s", err) + a.Errorf("unable to create character select screen: %s", err) } a.screen.SetNextScreen(characterSelect) diff --git a/d2core/d2hero/hero_stats_state.go b/d2core/d2hero/hero_stats_state.go index 04ad52a4..46c32be6 100644 --- a/d2core/d2hero/hero_stats_state.go +++ b/d2core/d2hero/hero_stats_state.go @@ -10,28 +10,23 @@ type HeroStatsState struct { Level int `json:"level"` Experience int `json:"experience"` - Vitality int `json:"vitality"` - Energy int `json:"energy"` Strength int `json:"strength"` + Energy int `json:"energy"` Dexterity int `json:"dexterity"` + Vitality int `json:"vitality"` + // there are stats and skills points remaining to add. + StatPoints int `json:"statPoints"` + SkillPoints int `json:"skillPoints"` - AttackRating int `json:"attackRating"` - DefenseRating int `json:"defenseRating"` - - MaxStamina int `json:"maxStamina"` - Health int `json:"health"` - MaxHealth int `json:"maxHealth"` - Mana int `json:"mana"` - MaxMana int `json:"maxMana"` - - FireResistance int `json:"fireResistance"` - ColdResistance int `json:"coldResistance"` - LightningResistance int `json:"lightningResistance"` - PoisonResistance int `json:"poisonResistance"` + Health int `json:"health"` + MaxHealth int `json:"maxHealth"` + Mana int `json:"mana"` + MaxMana int `json:"maxMana"` + Stamina float64 `json:"-"` // only MaxStamina is saved, Stamina gets reset on entering world + MaxStamina int `json:"maxStamina"` // values which are not saved/loaded(computed) - Stamina float64 `json:"-"` // only MaxStamina is saved, Stamina gets reset on entering world - NextLevelExp int `json:"-"` + NextLevelExp int `json:"-"` } // CreateHeroStatsState generates a running state from a hero stats. @@ -44,6 +39,8 @@ func (f *HeroStateFactory) CreateHeroStatsState(heroClass d2enum.Hero, classStat Dexterity: classStats.InitDex, Vitality: classStats.InitVit, Energy: classStats.InitEne, + StatPoints: 0, + SkillPoints: 0, MaxHealth: classStats.InitVit * classStats.LifePerVit, MaxMana: classStats.InitEne * classStats.ManaPerEne, From dfb3e2705ab81831dc5372a876ce7619d57202b9 Mon Sep 17 00:00:00 2001 From: "M. Sz" Date: Wed, 16 Dec 2020 17:01:26 +0100 Subject: [PATCH 3/3] updated d2hero.HeroStatsState --- d2core/d2hero/hero_stats_state.go | 33 +++++++++++++++++-------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/d2core/d2hero/hero_stats_state.go b/d2core/d2hero/hero_stats_state.go index 46c32be6..04ad52a4 100644 --- a/d2core/d2hero/hero_stats_state.go +++ b/d2core/d2hero/hero_stats_state.go @@ -10,23 +10,28 @@ type HeroStatsState struct { Level int `json:"level"` Experience int `json:"experience"` - Strength int `json:"strength"` - Energy int `json:"energy"` - Dexterity int `json:"dexterity"` Vitality int `json:"vitality"` - // there are stats and skills points remaining to add. - StatPoints int `json:"statPoints"` - SkillPoints int `json:"skillPoints"` + Energy int `json:"energy"` + Strength int `json:"strength"` + Dexterity int `json:"dexterity"` - Health int `json:"health"` - MaxHealth int `json:"maxHealth"` - Mana int `json:"mana"` - MaxMana int `json:"maxMana"` - Stamina float64 `json:"-"` // only MaxStamina is saved, Stamina gets reset on entering world - MaxStamina int `json:"maxStamina"` + AttackRating int `json:"attackRating"` + DefenseRating int `json:"defenseRating"` + + MaxStamina int `json:"maxStamina"` + Health int `json:"health"` + MaxHealth int `json:"maxHealth"` + Mana int `json:"mana"` + MaxMana int `json:"maxMana"` + + FireResistance int `json:"fireResistance"` + ColdResistance int `json:"coldResistance"` + LightningResistance int `json:"lightningResistance"` + PoisonResistance int `json:"poisonResistance"` // values which are not saved/loaded(computed) - NextLevelExp int `json:"-"` + Stamina float64 `json:"-"` // only MaxStamina is saved, Stamina gets reset on entering world + NextLevelExp int `json:"-"` } // CreateHeroStatsState generates a running state from a hero stats. @@ -39,8 +44,6 @@ func (f *HeroStateFactory) CreateHeroStatsState(heroClass d2enum.Hero, classStat Dexterity: classStats.InitDex, Vitality: classStats.InitVit, Energy: classStats.InitEne, - StatPoints: 0, - SkillPoints: 0, MaxHealth: classStats.InitVit * classStats.LifePerVit, MaxMana: classStats.InitEne * classStats.ManaPerEne,