mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2025-02-04 23:56:40 -05:00
code cleanup
This commit is contained in:
parent
570d71845e
commit
640a9e043d
@ -135,11 +135,6 @@ func SplitIntoLinesWithMaxWidth(fullSentence string, maxChars int) []string {
|
||||
return lines
|
||||
}
|
||||
|
||||
// SplitIntoLinesWithMaxWidthOneLine does 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
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"math"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2hero"
|
||||
|
||||
@ -229,7 +230,7 @@ func (v *CharacterSelect) loadHeroTitle() {
|
||||
|
||||
func (v *CharacterSelect) loadDeleteCharConfirm() {
|
||||
v.deleteCharConfirmLabel = v.uiManager.NewLabel(d2resource.Font16, d2resource.PaletteUnits)
|
||||
lines := d2util.SplitIntoLinesWithMaxWidthOneLine(v.asset.TranslateLabel(delCharConfLabel), 30)
|
||||
lines := strings.Join(d2util.SplitIntoLinesWithMaxWidth(v.asset.TranslateLabel(delCharConfLabel), 30), "\n")
|
||||
v.deleteCharConfirmLabel.SetText(lines)
|
||||
v.deleteCharConfirmLabel.Alignment = d2ui.HorizontalAlignCenter
|
||||
deleteConfirmX, deleteConfirmY := 400, 185
|
||||
@ -292,17 +293,18 @@ func rgbaColor(rgba uint32) color.RGBA {
|
||||
}
|
||||
|
||||
func (v *CharacterSelect) createButtons(loading d2screen.LoadingState) {
|
||||
v.newCharButton = v.uiManager.NewButton(d2ui.ButtonTypeTall, d2util.SplitIntoLinesWithMaxWidthOneLine(v.asset.TranslateString("#831"), 13))
|
||||
v.newCharButton = v.uiManager.NewButton(d2ui.ButtonTypeTall, strings.Join(
|
||||
d2util.SplitIntoLinesWithMaxWidth(v.asset.TranslateString("#831"), 13), "\n"))
|
||||
v.newCharButton.SetPosition(newCharBtnX, newCharBtnY)
|
||||
v.newCharButton.OnActivated(func() { v.onNewCharButtonClicked() })
|
||||
|
||||
v.convertCharButton = v.uiManager.NewButton(d2ui.ButtonTypeTall,
|
||||
d2util.SplitIntoLinesWithMaxWidthOneLine(v.asset.TranslateString("#825"), 13))
|
||||
strings.Join(d2util.SplitIntoLinesWithMaxWidth(v.asset.TranslateString("#825"), 13), "\n"))
|
||||
v.convertCharButton.SetPosition(convertCharBtnX, convertCharBtnY)
|
||||
v.convertCharButton.SetEnabled(false)
|
||||
|
||||
v.deleteCharButton = v.uiManager.NewButton(d2ui.ButtonTypeTall,
|
||||
d2util.SplitIntoLinesWithMaxWidthOneLine(v.asset.TranslateString("#832"), 13))
|
||||
strings.Join(d2util.SplitIntoLinesWithMaxWidth(v.asset.TranslateString("#832"), 13), "\n"))
|
||||
v.deleteCharButton.OnActivated(func() { v.onDeleteCharButtonClicked() })
|
||||
v.deleteCharButton.SetPosition(deleteCharBtnX, deleteCharBtnY)
|
||||
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2hero"
|
||||
|
||||
@ -344,7 +345,7 @@ func (v *MainMenu) createLabels(loading d2screen.LoadingState) {
|
||||
|
||||
v.tcpJoinGameLabel = v.uiManager.NewLabel(d2resource.Font16, d2resource.PaletteUnits)
|
||||
v.tcpJoinGameLabel.Alignment = d2ui.HorizontalAlignCenter
|
||||
v.tcpJoinGameLabel.SetText(d2util.SplitIntoLinesWithMaxWidthOneLine(v.asset.TranslateLabel(tcpIPEnterHostIPLabel), 27))
|
||||
v.tcpJoinGameLabel.SetText(strings.Join(d2util.SplitIntoLinesWithMaxWidth(v.asset.TranslateLabel(tcpIPEnterHostIPLabel), 27), "\n"))
|
||||
v.tcpJoinGameLabel.Color[0] = rgbaColor(gold)
|
||||
v.tcpJoinGameLabel.SetPosition(joinGameX, joinGameY)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user