mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-09-28 14:16:01 -04:00
Merge branch 'multi-language-labels' into hotfix
This commit is contained in:
commit
0d6e8ac0be
@ -135,6 +135,11 @@ func SplitIntoLinesWithMaxWidth(fullSentence string, maxChars int) []string {
|
|||||||
return lines
|
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 {
|
func splitCjkIntoChunks(str string, chars int) []string {
|
||||||
chunks := make([]string, chars/len(str))
|
chunks := make([]string, chars/len(str))
|
||||||
i, count := 0, 0
|
i, count := 0, 0
|
||||||
|
@ -292,17 +292,15 @@ func rgbaColor(rgba uint32) color.RGBA {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (v *CharacterSelect) createButtons(loading d2screen.LoadingState) {
|
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.SetPosition(newCharBtnX, newCharBtnY)
|
||||||
v.newCharButton.OnActivated(func() { v.onNewCharButtonClicked() })
|
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.SetPosition(convertCharBtnX, convertCharBtnY)
|
||||||
v.convertCharButton.SetEnabled(false)
|
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.OnActivated(func() { v.onDeleteCharButtonClicked() })
|
||||||
v.deleteCharButton.SetPosition(deleteCharBtnX, deleteCharBtnY)
|
v.deleteCharButton.SetPosition(deleteCharBtnX, deleteCharBtnY)
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package d2player
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2interface"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2interface"
|
||||||
@ -42,14 +43,14 @@ const (
|
|||||||
labelLifeX, labelLifeY = 280, 322
|
labelLifeX, labelLifeY = 280, 322
|
||||||
labelManaX, labelManaY = 280, 360
|
labelManaX, labelManaY = 280, 360
|
||||||
|
|
||||||
labelResFireLine1X, labelResFireLine1Y = 310, 395
|
labelResFireLine1X, labelResFireLine1Y = 310, 396
|
||||||
labelResFireLine2X, labelResFireLine2Y = 310, 402
|
labelResFireLine2X, labelResFireLine2Y = 310, 403
|
||||||
labelResColdLine1X, labelResColdLine1Y = 310, 445
|
labelResColdLine1X, labelResColdLine1Y = 310, 444
|
||||||
labelResColdLine2X, labelResColdLine2Y = 310, 452
|
labelResColdLine2X, labelResColdLine2Y = 310, 452
|
||||||
labelResLightLine1X, labelResLightLine1Y = 310, 420
|
labelResLightLine1X, labelResLightLine1Y = 310, 420
|
||||||
labelResLightLine2X, labelResLightLine2Y = 310, 427
|
labelResLightLine2X, labelResLightLine2Y = 310, 428
|
||||||
labelResPoisLine1X, labelResPoisLine1Y = 310, 468
|
labelResPoisLine1X, labelResPoisLine1Y = 310, 468
|
||||||
labelResPoisLine2X, labelResPoisLine2Y = 310, 477
|
labelResPoisLine2X, labelResPoisLine2Y = 310, 476
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -241,6 +242,10 @@ func (s *HeroStatsPanel) renderStaticPanelFrames(target d2interface.Surface) {
|
|||||||
func (s *HeroStatsPanel) renderStaticLabels(target d2interface.Surface) {
|
func (s *HeroStatsPanel) renderStaticLabels(target d2interface.Surface) {
|
||||||
var label *d2ui.Label
|
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
|
// all static labels are not stored since we use them only once to generate the image cache
|
||||||
var staticLabelConfigs = []struct {
|
var staticLabelConfigs = []struct {
|
||||||
x, y int
|
x, y int
|
||||||
@ -264,17 +269,17 @@ func (s *HeroStatsPanel) renderStaticLabels(target d2interface.Surface) {
|
|||||||
{labelManaX, labelManaY, s.asset.TranslateString("strchrman"), d2resource.Font6, true},
|
{labelManaX, labelManaY, s.asset.TranslateString("strchrman"), d2resource.Font6, true},
|
||||||
|
|
||||||
// can't use "Fire\nResistance" because line spacing is too big and breaks the layout
|
// can't use "Fire\nResistance" because line spacing is too big and breaks the layout
|
||||||
{labelResFireLine1X, labelResFireLine1Y, "Fire", d2resource.Font6, true},
|
{labelResFireLine1X, labelResFireLine1Y, fr[0], d2resource.Font6, true},
|
||||||
{labelResFireLine2X, labelResFireLine2Y, "Resistance", d2resource.Font6, true},
|
{labelResFireLine2X, labelResFireLine2Y, fr[len(fr)-1], d2resource.Font6, true},
|
||||||
|
|
||||||
{labelResColdLine1X, labelResColdLine1Y, "Cold", d2resource.Font6, true},
|
{labelResColdLine1X, labelResColdLine1Y, cr[0], d2resource.Font6, true},
|
||||||
{labelResColdLine2X, labelResColdLine2Y, "Resistance", d2resource.Font6, true},
|
{labelResColdLine2X, labelResColdLine2Y, cr[len(cr)-1], d2resource.Font6, true},
|
||||||
|
|
||||||
{labelResLightLine1X, labelResLightLine1Y, "Lightning", d2resource.Font6, true},
|
{labelResLightLine1X, labelResLightLine1Y, lr[0], d2resource.Font6, true},
|
||||||
{labelResLightLine2X, labelResLightLine2Y, "Resistance", d2resource.Font6, true},
|
{labelResLightLine2X, labelResLightLine2Y, lr[len(lr)-1], d2resource.Font6, true},
|
||||||
|
|
||||||
{labelResPoisLine1X, labelResPoisLine1Y, "Poison", d2resource.Font6, true},
|
{labelResPoisLine1X, labelResPoisLine1Y, pr[0], d2resource.Font6, true},
|
||||||
{labelResPoisLine2X, labelResPoisLine2Y, "Resistance", d2resource.Font6, true},
|
{labelResPoisLine2X, labelResPoisLine2Y, pr[len(pr)-1], d2resource.Font6, true},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, cfg := range staticLabelConfigs {
|
for _, cfg := range staticLabelConfigs {
|
||||||
|
Loading…
Reference in New Issue
Block a user