From 2869aea4f5b25d86f8c9852d7831041925a152b2 Mon Sep 17 00:00:00 2001 From: "M. Sz" Date: Mon, 21 Dec 2020 12:48:59 +0100 Subject: [PATCH] tip-labels in tcpip menu --- d2game/d2gamescreen/main_menu.go | 47 ++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/d2game/d2gamescreen/main_menu.go b/d2game/d2gamescreen/main_menu.go index 8330973e..c11f8e09 100644 --- a/d2game/d2gamescreen/main_menu.go +++ b/d2game/d2gamescreen/main_menu.go @@ -62,6 +62,7 @@ const ( tcpJoinBtnX, tcpJoinBtnY = 264, 240 errorLabelX, errorLabelY = 400, 250 machineIPX, machineIPY = 400, 90 + tipX, tipY = 400, 300 ) const ( @@ -159,6 +160,8 @@ type MainMenu struct { tcpJoinGameLabel *d2ui.Label machineIP *d2ui.Label errorLabel *d2ui.Label + joinTipLabel *d2ui.Label + hostTipLabel *d2ui.Label tcpJoinGameEntry *d2ui.TextBox screenMode mainMenuScreenMode leftButtonHeld bool @@ -182,10 +185,12 @@ func (v *MainMenu) OnLoad(loading d2screen.LoadingState) { v.audioProvider.PlayBGM(d2resource.BGMTitle) loading.Progress(twentyPercent) - v.createLabels(loading) + v.createMainMenuLabels(loading) + v.createMultiplayerLabels() v.loadBackgroundSprites() v.createLogos(loading) - v.createButtons(loading) + v.createMainMenuButtons(loading) + v.createMultiplayerMenuButtons() v.tcpJoinGameEntry = v.uiManager.NewTextbox() v.tcpJoinGameEntry.SetPosition(joinGameDialogX, joinGameDialogY) @@ -235,7 +240,7 @@ func (v *MainMenu) loadBackgroundSprites() { 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.Alignment = d2ui.HorizontalAlignRight v.versionLabel.SetText("OpenDiablo2 - " + v.buildInfo.Branch) @@ -268,6 +273,14 @@ func (v *MainMenu) createLabels(loading d2screen.LoadingState) { v.openDiabloLabel.SetPosition(od2LabelX, od2LabelY) 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.SetPosition(tcpOptionsX, tcpOptionsY) 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.SetPosition(machineIPX, machineIPY) - if v.errorLabel != nil { - v.errorLabel.SetPosition(errorLabelX, errorLabelY) - v.errorLabel.Alignment = d2ui.HorizontalAlignCenter - v.errorLabel.Color[0] = d2util.Color(red) - } + v.hostTipLabel = v.uiManager.NewLabel(d2resource.FontFormal12, d2resource.PaletteUnits) + v.hostTipLabel.Alignment = d2ui.HorizontalAlignCenter + v.hostTipLabel.SetText(d2ui.ColorTokenize(strings.Join(d2util.SplitIntoLinesWithMaxWidth( + 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) { @@ -329,7 +352,7 @@ func (v *MainMenu) createLogos(loading d2screen.LoadingState) { 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.SetPosition(exitDiabloBtnX, exitDiabloBtnY) 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.SetPosition(srvOkBtnX, srvOkBtnY) v.btnServerIPOk.OnActivated(func() { v.onBtnTCPIPOkClicked() }) - - v.createMultiplayerMenuButtons() 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.SetPosition(tcpHostBtnX, tcpHostBtnY) 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.SetPosition(tcpJoinBtnX, tcpJoinBtnY) 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() {