1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-06-19 13:45:23 +00:00

Merge pull request #995 from gucio321/tcp-ip-tips

tip-labels in tcpip menu
This commit is contained in:
Tim Sarbin 2020-12-21 08:21:48 -05:00 committed by GitHub
commit 8a55e1bd4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -62,6 +62,7 @@ const (
tcpJoinBtnX, tcpJoinBtnY = 264, 240 tcpJoinBtnX, tcpJoinBtnY = 264, 240
errorLabelX, errorLabelY = 400, 250 errorLabelX, errorLabelY = 400, 250
machineIPX, machineIPY = 400, 90 machineIPX, machineIPY = 400, 90
tipX, tipY = 400, 300
) )
const ( const (
@ -159,6 +160,8 @@ type MainMenu struct {
tcpJoinGameLabel *d2ui.Label tcpJoinGameLabel *d2ui.Label
machineIP *d2ui.Label machineIP *d2ui.Label
errorLabel *d2ui.Label errorLabel *d2ui.Label
joinTipLabel *d2ui.Label
hostTipLabel *d2ui.Label
tcpJoinGameEntry *d2ui.TextBox tcpJoinGameEntry *d2ui.TextBox
screenMode mainMenuScreenMode screenMode mainMenuScreenMode
leftButtonHeld bool leftButtonHeld bool
@ -182,10 +185,12 @@ func (v *MainMenu) OnLoad(loading d2screen.LoadingState) {
v.audioProvider.PlayBGM(d2resource.BGMTitle) v.audioProvider.PlayBGM(d2resource.BGMTitle)
loading.Progress(twentyPercent) loading.Progress(twentyPercent)
v.createLabels(loading) v.createMainMenuLabels(loading)
v.createMultiplayerLabels()
v.loadBackgroundSprites() v.loadBackgroundSprites()
v.createLogos(loading) v.createLogos(loading)
v.createButtons(loading) v.createMainMenuButtons(loading)
v.createMultiplayerMenuButtons()
v.tcpJoinGameEntry = v.uiManager.NewTextbox() v.tcpJoinGameEntry = v.uiManager.NewTextbox()
v.tcpJoinGameEntry.SetPosition(joinGameDialogX, joinGameDialogY) v.tcpJoinGameEntry.SetPosition(joinGameDialogX, joinGameDialogY)
@ -235,7 +240,7 @@ func (v *MainMenu) loadBackgroundSprites() {
v.serverIPBackground.SetPosition(serverIPbackgroundX, serverIPbackgroundY) v.serverIPBackground.SetPosition(serverIPbackgroundX, serverIPbackgroundY)
} }
func (v *MainMenu) createLabels(loading d2screen.LoadingState) { func (v *MainMenu) createMainMenuLabels(loading d2screen.LoadingState) {
v.versionLabel = v.uiManager.NewLabel(d2resource.FontFormal12, d2resource.PaletteStatic) v.versionLabel = v.uiManager.NewLabel(d2resource.FontFormal12, d2resource.PaletteStatic)
v.versionLabel.Alignment = d2ui.HorizontalAlignRight v.versionLabel.Alignment = d2ui.HorizontalAlignRight
v.versionLabel.SetText("OpenDiablo2 - " + v.buildInfo.Branch) v.versionLabel.SetText("OpenDiablo2 - " + v.buildInfo.Branch)
@ -268,6 +273,14 @@ func (v *MainMenu) createLabels(loading d2screen.LoadingState) {
v.openDiabloLabel.SetPosition(od2LabelX, od2LabelY) v.openDiabloLabel.SetPosition(od2LabelX, od2LabelY)
loading.Progress(fiftyPercent) loading.Progress(fiftyPercent)
if v.errorLabel != nil {
v.errorLabel.SetPosition(errorLabelX, errorLabelY)
v.errorLabel.Alignment = d2ui.HorizontalAlignCenter
v.errorLabel.Color[0] = d2util.Color(red)
}
}
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
@ -285,11 +298,21 @@ func (v *MainMenu) createLabels(loading d2screen.LoadingState) {
v.machineIP.Color[0] = d2util.Color(lightYellow) v.machineIP.Color[0] = d2util.Color(lightYellow)
v.machineIP.SetPosition(machineIPX, machineIPY) v.machineIP.SetPosition(machineIPX, machineIPY)
if v.errorLabel != nil { v.hostTipLabel = v.uiManager.NewLabel(d2resource.FontFormal12, d2resource.PaletteUnits)
v.errorLabel.SetPosition(errorLabelX, errorLabelY) v.hostTipLabel.Alignment = d2ui.HorizontalAlignCenter
v.errorLabel.Alignment = d2ui.HorizontalAlignCenter v.hostTipLabel.SetText(d2ui.ColorTokenize(strings.Join(d2util.SplitIntoLinesWithMaxWidth(
v.errorLabel.Color[0] = d2util.Color(red) v.asset.TranslateLabel(d2enum.TipHostLabel), 36),
} "\n"), d2ui.ColorTokenGold))
v.hostTipLabel.SetPosition(tipX, tipY)
v.hostTipLabel.SetVisible(false)
v.joinTipLabel = v.uiManager.NewLabel(d2resource.FontFormal12, d2resource.PaletteUnits)
v.joinTipLabel.Alignment = d2ui.HorizontalAlignCenter
v.joinTipLabel.SetText(d2ui.ColorTokenize(strings.Join(d2util.SplitIntoLinesWithMaxWidth(
v.asset.TranslateLabel(d2enum.TipJoinLabel), 36),
"\n"), d2ui.ColorTokenGold))
v.joinTipLabel.SetPosition(tipX, tipY)
v.joinTipLabel.SetVisible(false)
} }
func (v *MainMenu) createLogos(loading d2screen.LoadingState) { func (v *MainMenu) createLogos(loading d2screen.LoadingState) {
@ -329,7 +352,7 @@ func (v *MainMenu) createLogos(loading d2screen.LoadingState) {
v.diabloLogoRightBack.SetPosition(diabloLogoX, diabloLogoY) v.diabloLogoRightBack.SetPosition(diabloLogoX, diabloLogoY)
} }
func (v *MainMenu) createButtons(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.TranslateLabel(d2enum.ExitGameLabel))
v.exitDiabloButton.SetPosition(exitDiabloBtnX, exitDiabloBtnY) v.exitDiabloButton.SetPosition(exitDiabloBtnX, exitDiabloBtnY)
v.exitDiabloButton.OnActivated(func() { v.onExitButtonClicked() }) v.exitDiabloButton.OnActivated(func() { v.onExitButtonClicked() })
@ -367,8 +390,6 @@ func (v *MainMenu) createButtons(loading d2screen.LoadingState) {
v.btnServerIPOk = v.uiManager.NewButton(d2ui.ButtonTypeOkCancel, v.asset.TranslateString(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() })
v.createMultiplayerMenuButtons()
loading.Progress(eightyPercent) loading.Progress(eightyPercent)
} }
@ -390,10 +411,14 @@ func (v *MainMenu) createMultiplayerMenuButtons() {
v.btnTCPIPHostGame = v.uiManager.NewButton(d2ui.ButtonTypeWide, v.asset.TranslateLabel(d2enum.TCPIPHostGameLabel)) v.btnTCPIPHostGame = v.uiManager.NewButton(d2ui.ButtonTypeWide, v.asset.TranslateLabel(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.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.TranslateLabel(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.OnHoverEnd(func() { v.joinTipLabel.SetVisible(false) })
} }
func (v *MainMenu) onMapTestClicked() { func (v *MainMenu) onMapTestClicked() {