diff --git a/d2common/d2util/stringutils.go b/d2common/d2util/stringutils.go index c9c859cb..c9d9aa65 100644 --- a/d2common/d2util/stringutils.go +++ b/d2common/d2util/stringutils.go @@ -135,6 +135,11 @@ func SplitIntoLinesWithMaxWidth(fullSentence string, maxChars int) []string { return lines } +// SplitIntoLineWithMaxWidthOneLine do the same as SplitIntoLinesWithMaxWidth but return string with newline char +func SplitIntoLinesWithMaxWidthOneLine(s string, l int) string { + return strings.Join(SplitIntoLinesWithMaxWidth(s, l), "\n") +} + func splitCjkIntoChunks(str string, chars int) []string { chunks := make([]string, chars/len(str)) i, count := 0, 0 diff --git a/d2game/d2gamescreen/character_select.go b/d2game/d2gamescreen/character_select.go index 2e78579b..c0c622a1 100644 --- a/d2game/d2gamescreen/character_select.go +++ b/d2game/d2gamescreen/character_select.go @@ -292,17 +292,15 @@ func rgbaColor(rgba uint32) color.RGBA { } func (v *CharacterSelect) createButtons(loading d2screen.LoadingState) { - v.newCharButton = v.uiManager.NewButton(d2ui.ButtonTypeTall, "CREATE NEW\nCHARACTER") - + v.newCharButton = v.uiManager.NewButton(d2ui.ButtonTypeTall, d2util.SplitIntoLinesWithMaxWidthOneLine(v.asset.TranslateString("#831"), 13)) v.newCharButton.SetPosition(newCharBtnX, newCharBtnY) v.newCharButton.OnActivated(func() { v.onNewCharButtonClicked() }) - v.convertCharButton = v.uiManager.NewButton(d2ui.ButtonTypeTall, "CONVERT TO\nEXPANSION") - + v.convertCharButton = v.uiManager.NewButton(d2ui.ButtonTypeTall, d2util.SplitIntoLinesWithMaxWidthOneLine(v.asset.TranslateString("#825"), 13)) v.convertCharButton.SetPosition(convertCharBtnX, convertCharBtnY) v.convertCharButton.SetEnabled(false) - v.deleteCharButton = v.uiManager.NewButton(d2ui.ButtonTypeTall, "DELETE\nCHARACTER") + v.deleteCharButton = v.uiManager.NewButton(d2ui.ButtonTypeTall, d2util.SplitIntoLinesWithMaxWidthOneLine(v.asset.TranslateString("#832"), 13)) v.deleteCharButton.OnActivated(func() { v.onDeleteCharButtonClicked() }) v.deleteCharButton.SetPosition(deleteCharBtnX, deleteCharBtnY) diff --git a/d2game/d2player/hero_stats_panel.go b/d2game/d2player/hero_stats_panel.go index b3d1a329..d1814a65 100644 --- a/d2game/d2player/hero_stats_panel.go +++ b/d2game/d2player/hero_stats_panel.go @@ -2,6 +2,7 @@ package d2player import ( "strconv" + "strings" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2interface" @@ -42,14 +43,14 @@ const ( labelLifeX, labelLifeY = 280, 322 labelManaX, labelManaY = 280, 360 - labelResFireLine1X, labelResFireLine1Y = 310, 395 - labelResFireLine2X, labelResFireLine2Y = 310, 402 - labelResColdLine1X, labelResColdLine1Y = 310, 445 + labelResFireLine1X, labelResFireLine1Y = 310, 396 + labelResFireLine2X, labelResFireLine2Y = 310, 403 + labelResColdLine1X, labelResColdLine1Y = 310, 444 labelResColdLine2X, labelResColdLine2Y = 310, 452 labelResLightLine1X, labelResLightLine1Y = 310, 420 - labelResLightLine2X, labelResLightLine2Y = 310, 427 + labelResLightLine2X, labelResLightLine2Y = 310, 428 labelResPoisLine1X, labelResPoisLine1Y = 310, 468 - labelResPoisLine2X, labelResPoisLine2Y = 310, 477 + labelResPoisLine2X, labelResPoisLine2Y = 310, 476 ) const ( @@ -241,6 +242,10 @@ func (s *HeroStatsPanel) renderStaticPanelFrames(target d2interface.Surface) { func (s *HeroStatsPanel) renderStaticLabels(target d2interface.Surface) { var label *d2ui.Label + fr := strings.Split(s.asset.TranslateString("strchrfir"), "\n") + lr := strings.Split(s.asset.TranslateString("strchrlit"), "\n") + cr := strings.Split(s.asset.TranslateString("strchrcol"), "\n") + pr := strings.Split(s.asset.TranslateString("strchrpos"), "\n") // all static labels are not stored since we use them only once to generate the image cache var staticLabelConfigs = []struct { x, y int @@ -264,17 +269,17 @@ func (s *HeroStatsPanel) renderStaticLabels(target d2interface.Surface) { {labelManaX, labelManaY, s.asset.TranslateString("strchrman"), d2resource.Font6, true}, // can't use "Fire\nResistance" because line spacing is too big and breaks the layout - {labelResFireLine1X, labelResFireLine1Y, "Fire", d2resource.Font6, true}, - {labelResFireLine2X, labelResFireLine2Y, "Resistance", d2resource.Font6, true}, + {labelResFireLine1X, labelResFireLine1Y, fr[0], d2resource.Font6, true}, + {labelResFireLine2X, labelResFireLine2Y, fr[len(fr)-1], d2resource.Font6, true}, - {labelResColdLine1X, labelResColdLine1Y, "Cold", d2resource.Font6, true}, - {labelResColdLine2X, labelResColdLine2Y, "Resistance", d2resource.Font6, true}, + {labelResColdLine1X, labelResColdLine1Y, cr[0], d2resource.Font6, true}, + {labelResColdLine2X, labelResColdLine2Y, cr[len(cr)-1], d2resource.Font6, true}, - {labelResLightLine1X, labelResLightLine1Y, "Lightning", d2resource.Font6, true}, - {labelResLightLine2X, labelResLightLine2Y, "Resistance", d2resource.Font6, true}, + {labelResLightLine1X, labelResLightLine1Y, lr[0], d2resource.Font6, true}, + {labelResLightLine2X, labelResLightLine2Y, lr[len(lr)-1], d2resource.Font6, true}, - {labelResPoisLine1X, labelResPoisLine1Y, "Poison", d2resource.Font6, true}, - {labelResPoisLine2X, labelResPoisLine2Y, "Resistance", d2resource.Font6, true}, + {labelResPoisLine1X, labelResPoisLine1Y, pr[0], d2resource.Font6, true}, + {labelResPoisLine2X, labelResPoisLine2Y, pr[len(pr)-1], d2resource.Font6, true}, } for _, cfg := range staticLabelConfigs {