1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-06-15 20:15:24 +00:00

asset manager: merged TranslateLabel to TranslateString

This commit is contained in:
M. Sz 2021-01-28 11:20:59 +01:00
parent 60c1b4ea26
commit 20f2649b65
8 changed files with 54 additions and 54 deletions

View File

@ -1,6 +1,6 @@
package d2enum package d2enum
// there are labels for "numeric labels (see AssetManager.TranslateLabel) // there are labels for "numeric labels (see AssetManager.TranslateString)
const ( const (
RepairAll = iota RepairAll = iota
_ _

View File

@ -64,17 +64,18 @@ const (
type AssetManager struct { type AssetManager struct {
*d2util.Logger *d2util.Logger
*d2loader.Loader *d2loader.Loader
tables []d2tbl.TextDictionary tables []d2tbl.TextDictionary
dt1s d2interface.Cache dt1s d2interface.Cache
ds1s d2interface.Cache ds1s d2interface.Cache
cofs d2interface.Cache cofs d2interface.Cache
dccs d2interface.Cache dccs d2interface.Cache
animations d2interface.Cache animations d2interface.Cache
fonts d2interface.Cache fonts d2interface.Cache
palettes d2interface.Cache palettes d2interface.Cache
transforms d2interface.Cache transforms d2interface.Cache
Records *d2records.RecordManager Records *d2records.RecordManager
language string language string
languageModifier int
} }
// SetLogLevel sets the log level for the asset manager, record manager, and file loader // SetLogLevel sets the log level for the asset manager, record manager, and file loader
@ -141,6 +142,7 @@ func (am *AssetManager) LoadLanguage(languagePath string) string {
am.Infof("Language: %s", language) am.Infof("Language: %s", language)
am.language = language am.language = language
am.languageModifier = d2resource.GetLabelModifier(language)
return language return language
} }
@ -287,7 +289,8 @@ func (am *AssetManager) LoadStringTable(tablePath string) (d2tbl.TextDictionary,
} }
// TranslateString returns the translation of the given string. The string is retrieved from // TranslateString returns the translation of the given string. The string is retrieved from
// the loaded string tables. // the loaded string tables. If input value is int (e.g. from d2enum/numeric_labels.go)
// output string is translation for # + input
func (am *AssetManager) TranslateString(input interface{}) string { func (am *AssetManager) TranslateString(input interface{}) string {
var key string var key string
@ -296,6 +299,8 @@ func (am *AssetManager) TranslateString(input interface{}) string {
key = s key = s
case fmt.Stringer: case fmt.Stringer:
key = s.String() key = s.String()
case int:
key = fmt.Sprintf("#%d", d2enum.BaseLabelNumbers(s+am.languageModifier))
} }
for idx := range am.tables { for idx := range am.tables {
@ -309,11 +314,6 @@ func (am *AssetManager) TranslateString(input interface{}) string {
return key return key
} }
// TranslateLabel translates the label taking into account its shift in the table
func (am *AssetManager) TranslateLabel(label int) string {
return am.TranslateString(fmt.Sprintf("#%d", d2enum.BaseLabelNumbers(label+d2resource.GetLabelModifier(am.language))))
}
// LoadPaletteTransform loads a palette transform file // LoadPaletteTransform loads a palette transform file
func (am *AssetManager) LoadPaletteTransform(path string) (*d2pl2.PL2, error) { func (am *AssetManager) LoadPaletteTransform(path string) (*d2pl2.PL2, error) {
if pl2, found := am.transforms.Retrieve(path); found { if pl2, found := am.transforms.Retrieve(path); found {

View File

@ -923,7 +923,7 @@ func (v *Button) createTooltip() {
t.SetText(v.manager.asset.TranslateString("strClose")) t.SetText(v.manager.asset.TranslateString("strClose"))
case buttonTooltipOk: case buttonTooltipOk:
t = v.manager.NewTooltip(d2resource.Font16, d2resource.PaletteSky, TooltipXCenter, TooltipYBottom) t = v.manager.NewTooltip(d2resource.Font16, d2resource.PaletteSky, TooltipXCenter, TooltipYBottom)
t.SetText(v.manager.asset.TranslateLabel(d2enum.OKLabel)) t.SetText(v.manager.asset.TranslateString(d2enum.OKLabel))
case buttonTooltipBuy: case buttonTooltipBuy:
t = v.manager.NewTooltip(d2resource.Font16, d2resource.PaletteSky, TooltipXCenter, TooltipYBottom) t = v.manager.NewTooltip(d2resource.Font16, d2resource.PaletteSky, TooltipXCenter, TooltipYBottom)
t.SetText(v.manager.asset.TranslateString("NPCPurchaseItems")) t.SetText(v.manager.asset.TranslateString("NPCPurchaseItems"))
@ -935,7 +935,7 @@ func (v *Button) createTooltip() {
t.SetText(v.manager.asset.TranslateString("NPCRepairItems")) t.SetText(v.manager.asset.TranslateString("NPCRepairItems"))
case buttonTooltipRepairAll: case buttonTooltipRepairAll:
t = v.manager.NewTooltip(d2resource.Font16, d2resource.PaletteSky, TooltipXCenter, TooltipYBottom) t = v.manager.NewTooltip(d2resource.Font16, d2resource.PaletteSky, TooltipXCenter, TooltipYBottom)
t.SetText(v.manager.asset.TranslateLabel(d2enum.RepairAll)) t.SetText(v.manager.asset.TranslateString(d2enum.RepairAll))
case buttonTooltipLeftArrow: case buttonTooltipLeftArrow:
t = v.manager.NewTooltip(d2resource.Font16, d2resource.PaletteSky, TooltipXCenter, TooltipYBottom) t = v.manager.NewTooltip(d2resource.Font16, d2resource.PaletteSky, TooltipXCenter, TooltipYBottom)
t.SetText(v.manager.asset.TranslateString("KeyLeft")) t.SetText(v.manager.asset.TranslateString("KeyLeft"))

View File

@ -229,7 +229,7 @@ func (v *CharacterSelect) loadHeroTitle() {
func (v *CharacterSelect) loadDeleteCharConfirm() { func (v *CharacterSelect) loadDeleteCharConfirm() {
v.deleteCharConfirmLabel = v.uiManager.NewLabel(d2resource.Font16, d2resource.PaletteUnits) v.deleteCharConfirmLabel = v.uiManager.NewLabel(d2resource.Font16, d2resource.PaletteUnits)
lines := strings.Join(d2util.SplitIntoLinesWithMaxWidth(v.asset.TranslateLabel(d2enum.DelCharConfLabel), 29), "\n") lines := strings.Join(d2util.SplitIntoLinesWithMaxWidth(v.asset.TranslateString(d2enum.DelCharConfLabel), 29), "\n")
v.deleteCharConfirmLabel.SetText(lines) v.deleteCharConfirmLabel.SetText(lines)
v.deleteCharConfirmLabel.Alignment = d2ui.HorizontalAlignCenter v.deleteCharConfirmLabel.Alignment = d2ui.HorizontalAlignCenter
deleteConfirmX, deleteConfirmY := 400, 185 deleteConfirmX, deleteConfirmY := 400, 185
@ -282,23 +282,23 @@ func (v *CharacterSelect) createButtons(loading d2screen.LoadingState) {
v.deleteCharButton.OnActivated(func() { v.onDeleteCharButtonClicked() }) v.deleteCharButton.OnActivated(func() { v.onDeleteCharButtonClicked() })
v.deleteCharButton.SetPosition(deleteCharBtnX, deleteCharBtnY) v.deleteCharButton.SetPosition(deleteCharBtnX, deleteCharBtnY)
v.exitButton = v.uiManager.NewButton(d2ui.ButtonTypeMedium, v.asset.TranslateLabel(d2enum.ExitLabel)) v.exitButton = v.uiManager.NewButton(d2ui.ButtonTypeMedium, v.asset.TranslateString(d2enum.ExitLabel))
v.exitButton.SetPosition(exitBtnX, exitBtnY) v.exitButton.SetPosition(exitBtnX, exitBtnY)
v.exitButton.OnActivated(func() { v.onExitButtonClicked() }) v.exitButton.OnActivated(func() { v.onExitButtonClicked() })
loading.Progress(twentyPercent) loading.Progress(twentyPercent)
v.deleteCharCancelButton = v.uiManager.NewButton(d2ui.ButtonTypeOkCancel, v.asset.TranslateLabel(d2enum.NoLabel)) v.deleteCharCancelButton = v.uiManager.NewButton(d2ui.ButtonTypeOkCancel, v.asset.TranslateString(d2enum.NoLabel))
v.deleteCharCancelButton.SetPosition(deleteCancelX, deleteCancelY) v.deleteCharCancelButton.SetPosition(deleteCancelX, deleteCancelY)
v.deleteCharCancelButton.SetVisible(false) v.deleteCharCancelButton.SetVisible(false)
v.deleteCharCancelButton.OnActivated(func() { v.onDeleteCharacterCancelClicked() }) v.deleteCharCancelButton.OnActivated(func() { v.onDeleteCharacterCancelClicked() })
v.deleteCharOkButton = v.uiManager.NewButton(d2ui.ButtonTypeOkCancel, v.asset.TranslateLabel(d2enum.YesLabel)) v.deleteCharOkButton = v.uiManager.NewButton(d2ui.ButtonTypeOkCancel, v.asset.TranslateString(d2enum.YesLabel))
v.deleteCharOkButton.SetPosition(deleteOkX, deleteOkY) v.deleteCharOkButton.SetPosition(deleteOkX, deleteOkY)
v.deleteCharOkButton.SetVisible(false) v.deleteCharOkButton.SetVisible(false)
v.deleteCharOkButton.OnActivated(func() { v.onDeleteCharacterConfirmClicked() }) v.deleteCharOkButton.OnActivated(func() { v.onDeleteCharacterConfirmClicked() })
v.okButton = v.uiManager.NewButton(d2ui.ButtonTypeMedium, v.asset.TranslateLabel(d2enum.OKLabel)) v.okButton = v.uiManager.NewButton(d2ui.ButtonTypeMedium, v.asset.TranslateString(d2enum.OKLabel))
v.okButton.SetPosition(okBtnX, okBtnY) v.okButton.SetPosition(okBtnX, okBtnY)
v.okButton.OnActivated(func() { v.onOkButtonClicked() }) v.okButton.OnActivated(func() { v.onOkButtonClicked() })
} }

View File

@ -97,14 +97,14 @@ func (v *Cinematics) OnLoad(_ d2screen.LoadingState) {
v.cinematicsLabel = v.uiManager.NewLabel(d2resource.Font30, d2resource.PaletteStatic) v.cinematicsLabel = v.uiManager.NewLabel(d2resource.Font30, d2resource.PaletteStatic)
v.cinematicsLabel.Alignment = d2ui.HorizontalAlignCenter v.cinematicsLabel.Alignment = d2ui.HorizontalAlignCenter
v.cinematicsLabel.SetText(v.asset.TranslateLabel(d2enum.SelectCinematicLabel)) v.cinematicsLabel.SetText(v.asset.TranslateString(d2enum.SelectCinematicLabel))
v.cinematicsLabel.Color[0] = d2util.Color(lightBrown) v.cinematicsLabel.Color[0] = d2util.Color(lightBrown)
v.cinematicsLabel.SetPosition(cinematicsLabelX, cinematicsLabelY) v.cinematicsLabel.SetPosition(cinematicsLabelX, cinematicsLabelY)
} }
func (v *Cinematics) createButtons() { func (v *Cinematics) createButtons() {
v.cinematicsExitBtn = v.uiManager.NewButton(d2ui.ButtonTypeMedium, v.cinematicsExitBtn = v.uiManager.NewButton(d2ui.ButtonTypeMedium,
v.asset.TranslateString(v.asset.TranslateLabel(d2enum.CancelLabel))) v.asset.TranslateString(v.asset.TranslateString(d2enum.CancelLabel)))
v.cinematicsExitBtn.SetPosition(cinematicsExitBtnX, cinematicsExitBtnY) v.cinematicsExitBtn.SetPosition(cinematicsExitBtnX, cinematicsExitBtnY)
v.cinematicsExitBtn.OnActivated(func() { v.onCinematicsExitBtnClicked() }) v.cinematicsExitBtn.OnActivated(func() { v.onCinematicsExitBtnClicked() })

View File

@ -106,7 +106,7 @@ func (v *Credits) OnLoad(loading d2screen.LoadingState) {
v.creditsBackground.SetPosition(creditsX, creditsY) v.creditsBackground.SetPosition(creditsX, creditsY)
loading.Progress(twentyPercent) loading.Progress(twentyPercent)
v.exitButton = v.uiManager.NewButton(d2ui.ButtonTypeMedium, v.asset.TranslateLabel(d2enum.ExitLabel)) v.exitButton = v.uiManager.NewButton(d2ui.ButtonTypeMedium, v.asset.TranslateString(d2enum.ExitLabel))
v.exitButton.SetPosition(charSelExitBtnX, charSelExitBtnY) v.exitButton.SetPosition(charSelExitBtnX, charSelExitBtnY)
v.exitButton.OnActivated(func() { v.onExitButtonClicked() }) v.exitButton.OnActivated(func() { v.onExitButtonClicked() })
loading.Progress(fourtyPercent) loading.Progress(fourtyPercent)

View File

@ -255,14 +255,14 @@ func (v *MainMenu) createMainMenuLabels(loading d2screen.LoadingState) {
v.copyrightLabel = v.uiManager.NewLabel(d2resource.FontFormal12, d2resource.PaletteStatic) v.copyrightLabel = v.uiManager.NewLabel(d2resource.FontFormal12, d2resource.PaletteStatic)
v.copyrightLabel.Alignment = d2ui.HorizontalAlignCenter v.copyrightLabel.Alignment = d2ui.HorizontalAlignCenter
v.copyrightLabel.SetText(v.asset.TranslateLabel(d2enum.CopyrightLabel)) v.copyrightLabel.SetText(v.asset.TranslateString(d2enum.CopyrightLabel))
v.copyrightLabel.Color[0] = d2util.Color(lightBrown) v.copyrightLabel.Color[0] = d2util.Color(lightBrown)
v.copyrightLabel.SetPosition(copyrightX, copyrightY) v.copyrightLabel.SetPosition(copyrightX, copyrightY)
loading.Progress(thirtyPercent) loading.Progress(thirtyPercent)
v.copyrightLabel2 = v.uiManager.NewLabel(d2resource.FontFormal12, d2resource.PaletteStatic) v.copyrightLabel2 = v.uiManager.NewLabel(d2resource.FontFormal12, d2resource.PaletteStatic)
v.copyrightLabel2.Alignment = d2ui.HorizontalAlignCenter v.copyrightLabel2.Alignment = d2ui.HorizontalAlignCenter
v.copyrightLabel2.SetText(v.asset.TranslateLabel(d2enum.AllRightsReservedLabel)) v.copyrightLabel2.SetText(v.asset.TranslateString(d2enum.AllRightsReservedLabel))
v.copyrightLabel2.Color[0] = d2util.Color(lightBrown) v.copyrightLabel2.Color[0] = d2util.Color(lightBrown)
v.copyrightLabel2.SetPosition(copyright2X, copyright2Y) v.copyrightLabel2.SetPosition(copyright2X, copyright2Y)
@ -284,24 +284,24 @@ func (v *MainMenu) createMultiplayerLabels() {
v.tcpIPOptionsLabel = v.uiManager.NewLabel(d2resource.Font42, d2resource.PaletteUnits) v.tcpIPOptionsLabel = v.uiManager.NewLabel(d2resource.Font42, d2resource.PaletteUnits)
v.tcpIPOptionsLabel.SetPosition(tcpOptionsX, tcpOptionsY) v.tcpIPOptionsLabel.SetPosition(tcpOptionsX, tcpOptionsY)
v.tcpIPOptionsLabel.Alignment = d2ui.HorizontalAlignCenter v.tcpIPOptionsLabel.Alignment = d2ui.HorizontalAlignCenter
v.tcpIPOptionsLabel.SetText(v.asset.TranslateLabel(d2enum.TCPIPOptionsLabel)) v.tcpIPOptionsLabel.SetText(v.asset.TranslateString(d2enum.TCPIPOptionsLabel))
v.tcpJoinGameLabel = v.uiManager.NewLabel(d2resource.Font16, d2resource.PaletteUnits) v.tcpJoinGameLabel = v.uiManager.NewLabel(d2resource.Font16, d2resource.PaletteUnits)
v.tcpJoinGameLabel.Alignment = d2ui.HorizontalAlignCenter v.tcpJoinGameLabel.Alignment = d2ui.HorizontalAlignCenter
v.tcpJoinGameLabel.SetText(strings.Join(d2util.SplitIntoLinesWithMaxWidth(v.asset.TranslateLabel(d2enum.TCPIPEnterHostIPLabel), 27), "\n")) v.tcpJoinGameLabel.SetText(strings.Join(d2util.SplitIntoLinesWithMaxWidth(v.asset.TranslateString(d2enum.TCPIPEnterHostIPLabel), 27), "\n"))
v.tcpJoinGameLabel.Color[0] = d2util.Color(gold) v.tcpJoinGameLabel.Color[0] = d2util.Color(gold)
v.tcpJoinGameLabel.SetPosition(joinGameX, joinGameY) v.tcpJoinGameLabel.SetPosition(joinGameX, joinGameY)
v.machineIP = v.uiManager.NewLabel(d2resource.Font24, d2resource.PaletteUnits) v.machineIP = v.uiManager.NewLabel(d2resource.Font24, d2resource.PaletteUnits)
v.machineIP.Alignment = d2ui.HorizontalAlignCenter v.machineIP.Alignment = d2ui.HorizontalAlignCenter
v.machineIP.SetText(v.asset.TranslateLabel(d2enum.TCPIPYourIPLabel) + "\n" + v.getLocalIP()) v.machineIP.SetText(v.asset.TranslateString(d2enum.TCPIPYourIPLabel) + "\n" + v.getLocalIP())
v.machineIP.Color[0] = d2util.Color(lightYellow) v.machineIP.Color[0] = d2util.Color(lightYellow)
v.machineIP.SetPosition(machineIPX, machineIPY) v.machineIP.SetPosition(machineIPX, machineIPY)
v.hostTipLabel = v.uiManager.NewLabel(d2resource.FontFormal12, d2resource.PaletteUnits) v.hostTipLabel = v.uiManager.NewLabel(d2resource.FontFormal12, d2resource.PaletteUnits)
v.hostTipLabel.Alignment = d2ui.HorizontalAlignCenter v.hostTipLabel.Alignment = d2ui.HorizontalAlignCenter
v.hostTipLabel.SetText(d2ui.ColorTokenize(strings.Join(d2util.SplitIntoLinesWithMaxWidth( v.hostTipLabel.SetText(d2ui.ColorTokenize(strings.Join(d2util.SplitIntoLinesWithMaxWidth(
v.asset.TranslateLabel(d2enum.TipHostLabel), 36), v.asset.TranslateString(d2enum.TipHostLabel), 36),
"\n"), d2ui.ColorTokenGold)) "\n"), d2ui.ColorTokenGold))
v.hostTipLabel.SetPosition(tipX, tipY) v.hostTipLabel.SetPosition(tipX, tipY)
v.hostTipLabel.SetVisible(false) v.hostTipLabel.SetVisible(false)
@ -309,7 +309,7 @@ func (v *MainMenu) createMultiplayerLabels() {
v.joinTipLabel = v.uiManager.NewLabel(d2resource.FontFormal12, d2resource.PaletteUnits) v.joinTipLabel = v.uiManager.NewLabel(d2resource.FontFormal12, d2resource.PaletteUnits)
v.joinTipLabel.Alignment = d2ui.HorizontalAlignCenter v.joinTipLabel.Alignment = d2ui.HorizontalAlignCenter
v.joinTipLabel.SetText(d2ui.ColorTokenize(strings.Join(d2util.SplitIntoLinesWithMaxWidth( v.joinTipLabel.SetText(d2ui.ColorTokenize(strings.Join(d2util.SplitIntoLinesWithMaxWidth(
v.asset.TranslateLabel(d2enum.TipJoinLabel), 36), v.asset.TranslateString(d2enum.TipJoinLabel), 36),
"\n"), d2ui.ColorTokenGold)) "\n"), d2ui.ColorTokenGold))
v.joinTipLabel.SetPosition(tipX, tipY) v.joinTipLabel.SetPosition(tipX, tipY)
v.joinTipLabel.SetVisible(false) v.joinTipLabel.SetVisible(false)
@ -353,20 +353,20 @@ func (v *MainMenu) createLogos(loading d2screen.LoadingState) {
} }
func (v *MainMenu) createMainMenuButtons(loading d2screen.LoadingState) { func (v *MainMenu) createMainMenuButtons(loading d2screen.LoadingState) {
v.exitDiabloButton = v.uiManager.NewButton(d2ui.ButtonTypeWide, v.asset.TranslateLabel(d2enum.ExitGameLabel)) v.exitDiabloButton = v.uiManager.NewButton(d2ui.ButtonTypeWide, v.asset.TranslateString(d2enum.ExitGameLabel))
v.exitDiabloButton.SetPosition(exitDiabloBtnX, exitDiabloBtnY) v.exitDiabloButton.SetPosition(exitDiabloBtnX, exitDiabloBtnY)
v.exitDiabloButton.OnActivated(func() { v.onExitButtonClicked() }) v.exitDiabloButton.OnActivated(func() { v.onExitButtonClicked() })
v.creditsButton = v.uiManager.NewButton(d2ui.ButtonTypeShort, v.asset.TranslateLabel(d2enum.CreditsLabel)) v.creditsButton = v.uiManager.NewButton(d2ui.ButtonTypeShort, v.asset.TranslateString(d2enum.CreditsLabel))
v.creditsButton.SetPosition(creditBtnX, creditBtnY) v.creditsButton.SetPosition(creditBtnX, creditBtnY)
v.creditsButton.OnActivated(func() { v.onCreditsButtonClicked() }) v.creditsButton.OnActivated(func() { v.onCreditsButtonClicked() })
v.cinematicsButton = v.uiManager.NewButton(d2ui.ButtonTypeShort, v.asset.TranslateLabel(d2enum.CinematicsLabel)) v.cinematicsButton = v.uiManager.NewButton(d2ui.ButtonTypeShort, v.asset.TranslateString(d2enum.CinematicsLabel))
v.cinematicsButton.SetPosition(cineBtnX, cineBtnY) v.cinematicsButton.SetPosition(cineBtnX, cineBtnY)
v.cinematicsButton.OnActivated(func() { v.onCinematicsButtonClicked() }) v.cinematicsButton.OnActivated(func() { v.onCinematicsButtonClicked() })
loading.Progress(seventyPercent) loading.Progress(seventyPercent)
v.singlePlayerButton = v.uiManager.NewButton(d2ui.ButtonTypeWide, v.asset.TranslateLabel(d2enum.SinglePlayerLabel)) v.singlePlayerButton = v.uiManager.NewButton(d2ui.ButtonTypeWide, v.asset.TranslateString(d2enum.SinglePlayerLabel))
v.singlePlayerButton.SetPosition(singlePlayerBtnX, singlePlayerBtnY) v.singlePlayerButton.SetPosition(singlePlayerBtnX, singlePlayerBtnY)
v.singlePlayerButton.OnActivated(func() { v.onSinglePlayerClicked() }) v.singlePlayerButton.OnActivated(func() { v.onSinglePlayerClicked() })
@ -379,15 +379,15 @@ func (v *MainMenu) createMainMenuButtons(loading d2screen.LoadingState) {
v.mapTestButton.OnActivated(func() { v.onMapTestClicked() }) v.mapTestButton.OnActivated(func() { v.onMapTestClicked() })
v.btnTCPIPCancel = v.uiManager.NewButton(d2ui.ButtonTypeMedium, v.btnTCPIPCancel = v.uiManager.NewButton(d2ui.ButtonTypeMedium,
v.asset.TranslateLabel(d2enum.CancelLabel)) v.asset.TranslateString(d2enum.CancelLabel))
v.btnTCPIPCancel.SetPosition(tcpBtnX, tcpBtnY) v.btnTCPIPCancel.SetPosition(tcpBtnX, tcpBtnY)
v.btnTCPIPCancel.OnActivated(func() { v.onTCPIPCancelClicked() }) v.btnTCPIPCancel.OnActivated(func() { v.onTCPIPCancelClicked() })
v.btnServerIPCancel = v.uiManager.NewButton(d2ui.ButtonTypeOkCancel, v.asset.TranslateLabel(d2enum.CancelLabel)) v.btnServerIPCancel = v.uiManager.NewButton(d2ui.ButtonTypeOkCancel, v.asset.TranslateString(d2enum.CancelLabel))
v.btnServerIPCancel.SetPosition(srvCancelBtnX, srvCancelBtnY) v.btnServerIPCancel.SetPosition(srvCancelBtnX, srvCancelBtnY)
v.btnServerIPCancel.OnActivated(func() { v.onBtnTCPIPCancelClicked() }) v.btnServerIPCancel.OnActivated(func() { v.onBtnTCPIPCancelClicked() })
v.btnServerIPOk = v.uiManager.NewButton(d2ui.ButtonTypeOkCancel, v.asset.TranslateLabel(d2enum.OKLabel)) v.btnServerIPOk = v.uiManager.NewButton(d2ui.ButtonTypeOkCancel, v.asset.TranslateString(d2enum.OKLabel))
v.btnServerIPOk.SetPosition(srvOkBtnX, srvOkBtnY) v.btnServerIPOk.SetPosition(srvOkBtnX, srvOkBtnY)
v.btnServerIPOk.OnActivated(func() { v.onBtnTCPIPOkClicked() }) v.btnServerIPOk.OnActivated(func() { v.onBtnTCPIPOkClicked() })
loading.Progress(eightyPercent) loading.Progress(eightyPercent)
@ -395,26 +395,26 @@ func (v *MainMenu) createMainMenuButtons(loading d2screen.LoadingState) {
func (v *MainMenu) createMultiplayerMenuButtons() { func (v *MainMenu) createMultiplayerMenuButtons() {
v.multiplayerButton = v.uiManager.NewButton(d2ui.ButtonTypeWide, v.multiplayerButton = v.uiManager.NewButton(d2ui.ButtonTypeWide,
v.asset.TranslateLabel(d2enum.OtherMultiplayerLabel)) v.asset.TranslateString(d2enum.OtherMultiplayerLabel))
v.multiplayerButton.SetPosition(multiplayerBtnX, multiplayerBtnY) v.multiplayerButton.SetPosition(multiplayerBtnX, multiplayerBtnY)
v.multiplayerButton.OnActivated(func() { v.onMultiplayerClicked() }) v.multiplayerButton.OnActivated(func() { v.onMultiplayerClicked() })
v.networkTCPIPButton = v.uiManager.NewButton(d2ui.ButtonTypeWide, v.asset.TranslateLabel(d2enum.TCPIPGameLabel)) v.networkTCPIPButton = v.uiManager.NewButton(d2ui.ButtonTypeWide, v.asset.TranslateString(d2enum.TCPIPGameLabel))
v.networkTCPIPButton.SetPosition(tcpNetBtnX, tcpNetBtnY) v.networkTCPIPButton.SetPosition(tcpNetBtnX, tcpNetBtnY)
v.networkTCPIPButton.OnActivated(func() { v.onNetworkTCPIPClicked() }) v.networkTCPIPButton.OnActivated(func() { v.onNetworkTCPIPClicked() })
v.networkCancelButton = v.uiManager.NewButton(d2ui.ButtonTypeWide, v.networkCancelButton = v.uiManager.NewButton(d2ui.ButtonTypeWide,
v.asset.TranslateLabel(d2enum.CancelLabel)) v.asset.TranslateString(d2enum.CancelLabel))
v.networkCancelButton.SetPosition(networkCancelBtnX, networkCancelBtnY) v.networkCancelButton.SetPosition(networkCancelBtnX, networkCancelBtnY)
v.networkCancelButton.OnActivated(func() { v.onNetworkCancelClicked() }) v.networkCancelButton.OnActivated(func() { v.onNetworkCancelClicked() })
v.btnTCPIPHostGame = v.uiManager.NewButton(d2ui.ButtonTypeWide, v.asset.TranslateLabel(d2enum.TCPIPHostGameLabel)) v.btnTCPIPHostGame = v.uiManager.NewButton(d2ui.ButtonTypeWide, v.asset.TranslateString(d2enum.TCPIPHostGameLabel))
v.btnTCPIPHostGame.SetPosition(tcpHostBtnX, tcpHostBtnY) v.btnTCPIPHostGame.SetPosition(tcpHostBtnX, tcpHostBtnY)
v.btnTCPIPHostGame.OnActivated(func() { v.onTCPIPHostGameClicked() }) v.btnTCPIPHostGame.OnActivated(func() { v.onTCPIPHostGameClicked() })
v.btnTCPIPHostGame.OnHoverStart(func() { v.hostTipLabel.SetVisible(true) }) v.btnTCPIPHostGame.OnHoverStart(func() { v.hostTipLabel.SetVisible(true) })
v.btnTCPIPHostGame.OnHoverEnd(func() { v.hostTipLabel.SetVisible(false) }) v.btnTCPIPHostGame.OnHoverEnd(func() { v.hostTipLabel.SetVisible(false) })
v.btnTCPIPJoinGame = v.uiManager.NewButton(d2ui.ButtonTypeWide, v.asset.TranslateLabel(d2enum.TCPIPJoinGameLabel)) v.btnTCPIPJoinGame = v.uiManager.NewButton(d2ui.ButtonTypeWide, v.asset.TranslateString(d2enum.TCPIPJoinGameLabel))
v.btnTCPIPJoinGame.SetPosition(tcpJoinBtnX, tcpJoinBtnY) v.btnTCPIPJoinGame.SetPosition(tcpJoinBtnX, tcpJoinBtnY)
v.btnTCPIPJoinGame.OnActivated(func() { v.onTCPIPJoinGameClicked() }) v.btnTCPIPJoinGame.OnActivated(func() { v.onTCPIPJoinGameClicked() })
v.btnTCPIPJoinGame.OnHoverStart(func() { v.joinTipLabel.SetVisible(true) }) v.btnTCPIPJoinGame.OnHoverStart(func() { v.joinTipLabel.SetVisible(true) })
@ -672,5 +672,5 @@ func (v *MainMenu) getLocalIP() string {
v.Warning("no IPv4 Address could be found") v.Warning("no IPv4 Address could be found")
return v.asset.TranslateLabel(d2enum.IPNotFoundLabel) return v.asset.TranslateString(d2enum.IPNotFoundLabel)
} }

View File

@ -416,7 +416,7 @@ func (v *SelectHeroClass) createLabels() {
halfFontWidth := fontWidth / half halfFontWidth := fontWidth / half
v.headingLabel.SetPosition(headingX-halfFontWidth, headingY) v.headingLabel.SetPosition(headingX-halfFontWidth, headingY)
v.headingLabel.SetText(v.asset.TranslateLabel(d2enum.SelectHeroClassLabel)) v.headingLabel.SetText(v.asset.TranslateString(d2enum.SelectHeroClassLabel))
v.headingLabel.Alignment = d2ui.HorizontalAlignCenter v.headingLabel.Alignment = d2ui.HorizontalAlignCenter
v.heroClassLabel = v.uiManager.NewLabel(d2resource.Font30, d2resource.PaletteUnits) v.heroClassLabel = v.uiManager.NewLabel(d2resource.Font30, d2resource.PaletteUnits)
@ -437,7 +437,7 @@ func (v *SelectHeroClass) createLabels() {
v.heroNameLabel = v.uiManager.NewLabel(d2resource.Font16, d2resource.PaletteUnits) v.heroNameLabel = v.uiManager.NewLabel(d2resource.Font16, d2resource.PaletteUnits)
v.heroNameLabel.Alignment = d2ui.HorizontalAlignLeft v.heroNameLabel.Alignment = d2ui.HorizontalAlignLeft
v.heroNameLabel.SetText(d2ui.ColorTokenize(v.asset.TranslateLabel(d2enum.CharNameLabel), d2ui.ColorTokenGold)) v.heroNameLabel.SetText(d2ui.ColorTokenize(v.asset.TranslateString(d2enum.CharNameLabel), d2ui.ColorTokenGold))
v.heroNameLabel.SetPosition(heroNameLabelX, heroNameLabelY) v.heroNameLabel.SetPosition(heroNameLabelX, heroNameLabelY)
v.expansionCharLabel = v.uiManager.NewLabel(d2resource.Font16, d2resource.PaletteUnits) v.expansionCharLabel = v.uiManager.NewLabel(d2resource.Font16, d2resource.PaletteUnits)
@ -447,16 +447,16 @@ func (v *SelectHeroClass) createLabels() {
v.hardcoreCharLabel = v.uiManager.NewLabel(d2resource.Font16, d2resource.PaletteUnits) v.hardcoreCharLabel = v.uiManager.NewLabel(d2resource.Font16, d2resource.PaletteUnits)
v.hardcoreCharLabel.Alignment = d2ui.HorizontalAlignLeft v.hardcoreCharLabel.Alignment = d2ui.HorizontalAlignLeft
v.hardcoreCharLabel.SetText(d2ui.ColorTokenize(v.asset.TranslateLabel(d2enum.HardCoreLabel), d2ui.ColorTokenGold)) v.hardcoreCharLabel.SetText(d2ui.ColorTokenize(v.asset.TranslateString(d2enum.HardCoreLabel), d2ui.ColorTokenGold))
v.hardcoreCharLabel.SetPosition(hardcoreLabelX, hardcoreLabelY) v.hardcoreCharLabel.SetPosition(hardcoreLabelX, hardcoreLabelY)
} }
func (v *SelectHeroClass) createButtons() { func (v *SelectHeroClass) createButtons() {
v.exitButton = v.uiManager.NewButton(d2ui.ButtonTypeMedium, v.asset.TranslateLabel(d2enum.ExitLabel)) v.exitButton = v.uiManager.NewButton(d2ui.ButtonTypeMedium, v.asset.TranslateString(d2enum.ExitLabel))
v.exitButton.SetPosition(selHeroExitBtnX, selHeroExitBtnY) v.exitButton.SetPosition(selHeroExitBtnX, selHeroExitBtnY)
v.exitButton.OnActivated(func() { v.onExitButtonClicked() }) v.exitButton.OnActivated(func() { v.onExitButtonClicked() })
v.okButton = v.uiManager.NewButton(d2ui.ButtonTypeMedium, v.asset.TranslateLabel(d2enum.OKLabel)) v.okButton = v.uiManager.NewButton(d2ui.ButtonTypeMedium, v.asset.TranslateString(d2enum.OKLabel))
v.okButton.SetPosition(selHeroOkBtnX, selHeroOkBtnY) v.okButton.SetPosition(selHeroOkBtnX, selHeroOkBtnY)
v.okButton.OnActivated(func() { v.onOkButtonClicked() }) v.okButton.OnActivated(func() { v.onOkButtonClicked() })
v.okButton.SetVisible(false) v.okButton.SetVisible(false)
@ -719,7 +719,7 @@ func (v *SelectHeroClass) setDescLabels(descKey int, key string) {
if key != "" { if key != "" {
heroDesc = v.asset.TranslateString(key) heroDesc = v.asset.TranslateString(key)
} else { } else {
heroDesc = v.asset.TranslateLabel(descKey) heroDesc = v.asset.TranslateString(descKey)
} }
parts := d2util.SplitIntoLinesWithMaxWidth(heroDesc, heroDescCharWidth) parts := d2util.SplitIntoLinesWithMaxWidth(heroDesc, heroDescCharWidth)