1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-11-16 09:25:57 -05:00

Move Gold Panel (#962)

* move gold panel
This commit is contained in:
gucio321 2020-12-12 10:39:26 +01:00 committed by GitHub
parent 3f8dcf2232
commit 2e31f3d1ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 560 additions and 249 deletions

View File

@ -0,0 +1,129 @@
package d2enum
// there are labels for "numeric labels (see AssetManager.TranslateLabel)
const (
CancelLabel = iota
CopyrightLabel
AllRightsReservedLabel
SinglePlayerLabel
_
OtherMultiplayerLabel
ExitGameLabel
CreditsLabel
CinematicsLabel
ViewAllCinematicsLabel
EpilogueLabel
SelectCinematicLabel
_
TCPIPGameLabel
TCPIPOptionsLabel
TCPIPHostGameLabel
TCPIPJoinGameLabel
TCPIPEnterHostIPLabel
TCPIPYourIPLabel
TipHostLabel
TipJoinLabel
IPNotFoundLabel
CharNameLabel
HardCoreLabel
SelectHeroClassLabel
AmazonDescr
NecromancerDescr
BarbarianDescr
SorceressDescr
PaladinDescr
_
HellLabel
NightmareLabel
NormalLabel
SelectDifficultyLabel
_
DelCharConfLabel
OpenLabel
_
YesLabel
NoLabel
_
ExitLabel
OKLabel
)
// BaseLabelNumbers returns base label value (#n in english string table table)
func BaseLabelNumbers(idx int) int {
baseLabelNumbers := []int{
// main menu labels
1612, // CANCEL
1613, // (c) 2000 Blizzard Entertainment
1614, // All Rights Reserved.
1620, // SINGLE PLAYER
1621, // BATTLE.NET
1623, // OTHER MULTIPLAYER
1625, // EXIT DIABLO II
1627, // CREDITS
1639, // CINEMATICS
// cinematics menu labels
1640, // View All Earned Cinematics
1659, // Epilogue
1660, // SELECT CINEMATICS
// multiplayer labels
1663, // OPEN BATTLE.NET
1666, // TCP/IP GAME
1667, // TCP/IP Options
1675, // HOST GAME
1676, // JOIN GAME
1678, // Enter Host IP Address to Join Game
1680, // Your IP Address is:
1689, // Tip: host game
1690, // Tip: join game
1691, // Cannot detect a valid TCP/IP address.
1694, // Character Name
1696, // Hardcore
1697, // Select Hero Class
1698, // amazon description
1704, // nec description
1709, // barb description
1710, // sorc description
1711, // pal description
/*in addition, as many elements as the value
of the highest modifier must be listed*/
1712,
/* here, should be labels used to battle.net multiplayer, but they are not used yet,
therefore I don't list them here.*/
// difficulty levels:
1800, // Hell
1864, // Nightmare
1865, // Normal
1867, // Select Difficulty
1869, // not used, for locales with +1 mod
1878, // delete char confirm
1881, // Open
1889, // char name is currently taken (not used)
1896, // YES
1925, // NO
1926, // not used, for locales with +1 mod
970, // EXIT
971, // OK
1612,
}
return baseLabelNumbers[idx]
}

View File

@ -109,10 +109,11 @@ const (
GameGlobeOverlap = "/data/global/ui/PANEL/overlap.DC6"
HealthManaIndicator = "/data/global/ui/PANEL/hlthmana.DC6"
AddSkillButton = "/data/global/ui/PANEL/level.DC6"
GoldMoveDialog = "/data/global/ui/menu/dialogbackground.DC6"
MoveGoldDialog = "/data/global/ui/menu/dialogbackground.DC6"
WPTabs = "/data/global/ui/menu/expwaygatetabs.dc6"
WPBg = "/data/global/ui/menu/waygatebackground.dc6"
WPIcons = "/data/global/ui/menu/waygateicons.dc6"
UpDownArrows = "/data/global/ui/BIGMENU/numberarrows.dc6"
// --- Escape Menu ---
// main

View File

@ -304,76 +304,9 @@ func (am *AssetManager) TranslateString(input interface{}) string {
return key
}
func (am *AssetManager) baseLabelNumbers(idx int) int {
baseLabelNumbers := []int{
// main menu labels
1612, // CANCEL
1613, // (c) 2000 Blizzard Entertainment
1614, // All Rights Reserved.
1620, // SINGLE PLAYER
1621, // BATTLE.NET
1623, // OTHER MULTIPLAYER
1625, // EXIT DIABLO II
1627, // CREDITS
1639, // CINEMATICS
// cinematics menu labels
1640, // View All Earned Cinematics
1659, // Epilogue
1660, // SELECT CINEMATICS
// multiplayer labels
1663, // OPEN BATTLE.NET
1666, // TCP/IP GAME
1667, // TCP/IP Options
1675, // HOST GAME
1676, // JOIN GAME
1678, // Enter Host IP Address to Join Game
1680, // Your IP Address is:
1689, // Tip: host game
1690, // Tip: join game
1691, // Cannot detect a valid TCP/IP address.
1694, // Character Name
1696, // Hardcore
1697, // Select Hero Class
1698, // amazon description
1704, // nec description
1709, // barb description
1710, // sorc description
1711, // pal description
/*in addition, as many elements as the value
of the highest modifier must be listed*/
1712,
/* here, should be labels used to battle.net multiplayer, but they are not used yet,
therefore I don't list them here.*/
// difficulty levels:
1800, // Hell
1864, // Nightmare
1865, // Normal
1867, // Select Difficulty
1869, // not used, for locales with +1 mod
1878, // delete char confirm
1881, // Open
1889, // char name is currently taken (not used)
1896, // YES
1925, // NO
1926, // not used, for locales with +1 mod
970, // EXIT
971,
}
return baseLabelNumbers[idx]
}
// 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", am.baseLabelNumbers(label+d2resource.GetLabelModifier(am.language))))
return am.TranslateString(fmt.Sprintf("#%d", d2enum.BaseLabelNumbers(label+d2resource.GetLabelModifier(am.language))))
}
// LoadPaletteTransform loads a palette transform file

View File

@ -47,12 +47,14 @@ const (
ButtonTypeSell ButtonType = 27
ButtonTypeRepair ButtonType = 28
ButtonTypeRepairAll ButtonType = 29
ButtonTypeLeftArrow ButtonType = 30
ButtonTypeRightArrow ButtonType = 31
ButtonTypeQuery ButtonType = 32
ButtonTypeSquelchChat ButtonType = 33
ButtonTypeTabBlank ButtonType = 34
ButtonTypeBlankQuestBtn ButtonType = 35
ButtonTypeUpArrow ButtonType = 30
ButtonTypeDownArrow ButtonType = 31
ButtonTypeLeftArrow ButtonType = 32
ButtonTypeRightArrow ButtonType = 33
ButtonTypeQuery ButtonType = 34
ButtonTypeSquelchChat ButtonType = 35
ButtonTypeTabBlank ButtonType = 36
ButtonTypeBlankQuestBtn ButtonType = 37
ButtonNoFixedWidth int = -1
ButtonNoFixedHeight int = -1
@ -151,6 +153,12 @@ const (
buttonOkCancelSegmentsY = 1
buttonOkCancelDisabledFrame = -1
buttonUpDownArrowSegmentsX = 1
buttonUpDownArrowSegmentsY = 1
buttonUpDownArrowDisabledFrame = -1
buttonUpArrowBaseFrame = 0
buttonDownArrowBaseFrame = 2
buttonBuySellSegmentsX = 1
buttonBuySellSegmentsY = 1
buttonBuySellDisabledFrame = 1
@ -427,6 +435,36 @@ func getButtonLayouts() map[ButtonType]ButtonLayout {
TooltipXOffset: buttonBuySellTooltipXOffset,
TooltipYOffset: buttonBuySellTooltipYOffset,
},
ButtonTypeUpArrow: {
XSegments: buttonUpDownArrowSegmentsX,
YSegments: buttonUpDownArrowSegmentsY,
DisabledFrame: buttonUpDownArrowDisabledFrame,
DisabledColor: whiteAlpha100,
BaseFrame: buttonUpArrowBaseFrame,
ResourceName: d2resource.UpDownArrows,
PaletteName: d2resource.PaletteSky,
Toggleable: false,
FontPath: d2resource.Font16,
AllowFrameChange: true,
HasImage: true,
FixedWidth: ButtonNoFixedWidth,
FixedHeight: ButtonNoFixedHeight,
},
ButtonTypeDownArrow: {
XSegments: buttonUpDownArrowSegmentsX,
YSegments: buttonUpDownArrowSegmentsY,
DisabledFrame: buttonUpDownArrowDisabledFrame,
DisabledColor: whiteAlpha100,
BaseFrame: buttonDownArrowBaseFrame,
ResourceName: d2resource.UpDownArrows,
PaletteName: d2resource.PaletteSky,
Toggleable: false,
FontPath: d2resource.Font16,
AllowFrameChange: true,
HasImage: true,
FixedWidth: ButtonNoFixedWidth,
FixedHeight: ButtonNoFixedHeight,
},
ButtonTypeLeftArrow: {
XSegments: buttonBuySellSegmentsX,
YSegments: buttonBuySellSegmentsY,
@ -815,7 +853,7 @@ func (v *Button) createTooltip() {
t.SetText(v.manager.asset.TranslateString("strClose"))
case buttonTooltipOk:
t = v.manager.NewTooltip(d2resource.Font16, d2resource.PaletteSky, TooltipXCenter, TooltipYBottom)
t.SetText(v.manager.asset.TranslateString("#971"))
t.SetText(v.manager.asset.TranslateLabel(d2enum.OKLabel))
case buttonTooltipBuy:
t = v.manager.NewTooltip(d2resource.Font16, d2resource.PaletteSky, TooltipXCenter, TooltipYBottom)
t.SetText(v.manager.asset.TranslateString("NPCPurchaseItems"))

View File

@ -1,12 +1,14 @@
package d2ui
import (
"strconv"
"strings"
"time"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2interface"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2resource"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2util"
)
// static check that TextBox implements widget
@ -22,6 +24,10 @@ type TextBox struct {
bgSprite *Sprite
enabled bool
isFocused bool
isNumberOnly bool
maxValue int
*d2util.Logger
}
// NewTextbox creates a new instance of a text box
@ -41,6 +47,9 @@ func (ui *UIManager) NewTextbox() *TextBox {
textLabel: ui.NewLabel(d2resource.FontFormal11, d2resource.PaletteUnits),
lineBar: ui.NewLabel(d2resource.FontFormal11, d2resource.PaletteUnits),
enabled: true,
Logger: ui.Logger,
isNumberOnly: false, // (disabled)
maxValue: -1, // (disabled)
}
tb.lineBar.SetText("_")
@ -75,16 +84,32 @@ func (v *TextBox) OnKeyChars(event d2interface.KeyCharsEvent) bool {
}
newText := string(event.Chars())
if !(len(newText) > 0) {
return false
}
if len(newText) > 0 {
if !v.isNumberOnly {
v.text += newText
v.SetText(v.text)
return true
}
number, err := strconv.Atoi(v.text + newText)
if err != nil {
v.Debugf("Unable to convert string %s to intager: %s", v.text+newText, err)
return false
}
if number <= v.maxValue {
v.text += newText
} else {
v.text = strconv.Itoa(v.maxValue)
}
v.SetText(v.text)
return true
}
// OnKeyRepeat handles key repeat events
@ -212,3 +237,9 @@ func (v *TextBox) OnActivated(_ func()) {
func (v *TextBox) Activate() {
v.isFocused = true
}
// SetNumberOnly sets text box to support only numeric values
func (v *TextBox) SetNumberOnly(max int) {
v.isNumberOnly = true
v.maxValue = max
}

View File

@ -9,10 +9,10 @@ type RenderPriority int
const (
RenderPriorityBackground RenderPriority = iota
RenderPrioritySkilltree
RenderPriorityInventory
RenderPrioritySkilltreeIcon
RenderPriorityHeroStatsPanel
RenderPriorityQuestLog
RenderPriorityInventory
RenderPriorityHUDPanel
RenderPriorityMinipanel
RenderPriorityHelpPanel

View File

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

View File

@ -2,6 +2,7 @@ package d2gamescreen
import (
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2data/d2video"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2interface"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2resource"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2util"
@ -96,14 +97,14 @@ func (v *Cinematics) OnLoad(_ d2screen.LoadingState) {
v.cinematicsLabel = v.uiManager.NewLabel(d2resource.Font30, d2resource.PaletteStatic)
v.cinematicsLabel.Alignment = d2ui.HorizontalAlignCenter
v.cinematicsLabel.SetText(v.asset.TranslateLabel(selectCinematicLabel))
v.cinematicsLabel.SetText(v.asset.TranslateLabel(d2enum.SelectCinematicLabel))
v.cinematicsLabel.Color[0] = rgbaColor(lightBrown)
v.cinematicsLabel.SetPosition(cinematicsLabelX, cinematicsLabelY)
}
func (v *Cinematics) createButtons() {
v.cinematicsExitBtn = v.uiManager.NewButton(d2ui.ButtonTypeMedium,
v.asset.TranslateString(v.asset.TranslateLabel(cancelLabel)))
v.asset.TranslateString(v.asset.TranslateLabel(d2enum.CancelLabel)))
v.cinematicsExitBtn.SetPosition(cinematicsExitBtnX, cinematicsExitBtnY)
v.cinematicsExitBtn.OnActivated(func() { v.onCinematicsExitBtnClicked() })

View File

@ -6,6 +6,7 @@ import (
"path"
"strings"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2interface"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2resource"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2util"
@ -105,7 +106,7 @@ func (v *Credits) OnLoad(loading d2screen.LoadingState) {
v.creditsBackground.SetPosition(creditsX, creditsY)
loading.Progress(twentyPercent)
v.exitButton = v.uiManager.NewButton(d2ui.ButtonTypeMedium, v.asset.TranslateLabel(exitLabel))
v.exitButton = v.uiManager.NewButton(d2ui.ButtonTypeMedium, v.asset.TranslateLabel(d2enum.ExitLabel))
v.exitButton.SetPosition(charSelExitBtnX, charSelExitBtnY)
v.exitButton.OnActivated(func() { v.onExitButtonClicked() })
loading.Progress(fourtyPercent)

View File

@ -84,76 +84,6 @@ type BuildInfo struct {
Branch, Commit string
}
const (
// main menu labels
cancelLabel = iota
copyrightLabel
allRightsReservedLabel
singlePlayerLabel
_
otherMultiplayerLabel
exitGameLabel
creditsLabel
cinematicsLabel
// cinematics menu labels
//nolint:deadcode,varcheck,unused // will be used
viewAllCinematicsLabel
//nolint:deadcode,varcheck,unused // will be used
epilogueLabel
selectCinematicLabel
// multiplayer menu labels
_
tcpIPGameLabel
tcpIPOptionsLabel
tcpIPHostGameLabel
tcpIPJoinGameLabel
tcpIPEnterHostIPLabel
tcpIPYourIPLabel
//nolint:deadcode,varcheck,unused // will be used
tipHostLabel
//nolint:deadcode,varcheck,unused // will be used
tipJoinLabel
ipNotFoundLabel
// select hero class menu labels
charNameLabel
hardCoreLabel
selectHeroClassLabel
amazonDescr
necromancerDescr
barbarianDescr
sorceressDescr
paladinDescr
_
//nolint:deadcode,varcheck,unused // will be used
hellLabel
//nolint:deadcode,varcheck,unused // will be used
nightmareLabel
//nolint:deadcode,varcheck,unused // will be used
normalLabel
//nolint:deadcode,varcheck,unused // will be used
selectDifficultyLabel
_
delCharConfLabel
//nolint:deadcode,varcheck,unused // will be used
openLabel
_
yesLabel
noLabel
_
exitLabel
)
// CreateMainMenu creates an instance of MainMenu
func CreateMainMenu(
navigator d2interface.Navigator,
@ -320,14 +250,14 @@ func (v *MainMenu) createLabels(loading d2screen.LoadingState) {
v.copyrightLabel = v.uiManager.NewLabel(d2resource.FontFormal12, d2resource.PaletteStatic)
v.copyrightLabel.Alignment = d2ui.HorizontalAlignCenter
v.copyrightLabel.SetText(v.asset.TranslateLabel(copyrightLabel))
v.copyrightLabel.SetText(v.asset.TranslateLabel(d2enum.CopyrightLabel))
v.copyrightLabel.Color[0] = rgbaColor(lightBrown)
v.copyrightLabel.SetPosition(copyrightX, copyrightY)
loading.Progress(thirtyPercent)
v.copyrightLabel2 = v.uiManager.NewLabel(d2resource.FontFormal12, d2resource.PaletteStatic)
v.copyrightLabel2.Alignment = d2ui.HorizontalAlignCenter
v.copyrightLabel2.SetText(v.asset.TranslateLabel(allRightsReservedLabel))
v.copyrightLabel2.SetText(v.asset.TranslateLabel(d2enum.AllRightsReservedLabel))
v.copyrightLabel2.Color[0] = rgbaColor(lightBrown)
v.copyrightLabel2.SetPosition(copyright2X, copyright2Y)
@ -341,17 +271,17 @@ func (v *MainMenu) createLabels(loading d2screen.LoadingState) {
v.tcpIPOptionsLabel = v.uiManager.NewLabel(d2resource.Font42, d2resource.PaletteUnits)
v.tcpIPOptionsLabel.SetPosition(tcpOptionsX, tcpOptionsY)
v.tcpIPOptionsLabel.Alignment = d2ui.HorizontalAlignCenter
v.tcpIPOptionsLabel.SetText(v.asset.TranslateLabel(tcpIPOptionsLabel))
v.tcpIPOptionsLabel.SetText(v.asset.TranslateLabel(d2enum.TCPIPOptionsLabel))
v.tcpJoinGameLabel = v.uiManager.NewLabel(d2resource.Font16, d2resource.PaletteUnits)
v.tcpJoinGameLabel.Alignment = d2ui.HorizontalAlignCenter
v.tcpJoinGameLabel.SetText(strings.Join(d2util.SplitIntoLinesWithMaxWidth(v.asset.TranslateLabel(tcpIPEnterHostIPLabel), 27), "\n"))
v.tcpJoinGameLabel.SetText(strings.Join(d2util.SplitIntoLinesWithMaxWidth(v.asset.TranslateLabel(d2enum.TCPIPEnterHostIPLabel), 27), "\n"))
v.tcpJoinGameLabel.Color[0] = rgbaColor(gold)
v.tcpJoinGameLabel.SetPosition(joinGameX, joinGameY)
v.machineIP = v.uiManager.NewLabel(d2resource.Font24, d2resource.PaletteUnits)
v.machineIP.Alignment = d2ui.HorizontalAlignCenter
v.machineIP.SetText(v.asset.TranslateLabel(tcpIPYourIPLabel) + "\n" + v.getLocalIP())
v.machineIP.SetText(v.asset.TranslateLabel(d2enum.TCPIPYourIPLabel) + "\n" + v.getLocalIP())
v.machineIP.Color[0] = rgbaColor(lightYellow)
v.machineIP.SetPosition(machineIPX, machineIPY)
@ -400,20 +330,20 @@ func (v *MainMenu) createLogos(loading d2screen.LoadingState) {
}
func (v *MainMenu) createButtons(loading d2screen.LoadingState) {
v.exitDiabloButton = v.uiManager.NewButton(d2ui.ButtonTypeWide, v.asset.TranslateLabel(exitGameLabel))
v.exitDiabloButton = v.uiManager.NewButton(d2ui.ButtonTypeWide, v.asset.TranslateLabel(d2enum.ExitGameLabel))
v.exitDiabloButton.SetPosition(exitDiabloBtnX, exitDiabloBtnY)
v.exitDiabloButton.OnActivated(func() { v.onExitButtonClicked() })
v.creditsButton = v.uiManager.NewButton(d2ui.ButtonTypeShort, v.asset.TranslateLabel(creditsLabel))
v.creditsButton = v.uiManager.NewButton(d2ui.ButtonTypeShort, v.asset.TranslateLabel(d2enum.CreditsLabel))
v.creditsButton.SetPosition(creditBtnX, creditBtnY)
v.creditsButton.OnActivated(func() { v.onCreditsButtonClicked() })
v.cinematicsButton = v.uiManager.NewButton(d2ui.ButtonTypeShort, v.asset.TranslateLabel(cinematicsLabel))
v.cinematicsButton = v.uiManager.NewButton(d2ui.ButtonTypeShort, v.asset.TranslateLabel(d2enum.CinematicsLabel))
v.cinematicsButton.SetPosition(cineBtnX, cineBtnY)
v.cinematicsButton.OnActivated(func() { v.onCinematicsButtonClicked() })
loading.Progress(seventyPercent)
v.singlePlayerButton = v.uiManager.NewButton(d2ui.ButtonTypeWide, v.asset.TranslateLabel(singlePlayerLabel))
v.singlePlayerButton = v.uiManager.NewButton(d2ui.ButtonTypeWide, v.asset.TranslateLabel(d2enum.SinglePlayerLabel))
v.singlePlayerButton.SetPosition(singlePlayerBtnX, singlePlayerBtnY)
v.singlePlayerButton.OnActivated(func() { v.onSinglePlayerClicked() })
@ -426,15 +356,15 @@ func (v *MainMenu) createButtons(loading d2screen.LoadingState) {
v.mapTestButton.OnActivated(func() { v.onMapTestClicked() })
v.btnTCPIPCancel = v.uiManager.NewButton(d2ui.ButtonTypeMedium,
v.asset.TranslateLabel(cancelLabel))
v.asset.TranslateLabel(d2enum.CancelLabel))
v.btnTCPIPCancel.SetPosition(tcpBtnX, tcpBtnY)
v.btnTCPIPCancel.OnActivated(func() { v.onTCPIPCancelClicked() })
v.btnServerIPCancel = v.uiManager.NewButton(d2ui.ButtonTypeOkCancel, v.asset.TranslateLabel(cancelLabel))
v.btnServerIPCancel = v.uiManager.NewButton(d2ui.ButtonTypeOkCancel, v.asset.TranslateLabel(d2enum.CancelLabel))
v.btnServerIPCancel.SetPosition(srvCancelBtnX, srvCancelBtnY)
v.btnServerIPCancel.OnActivated(func() { v.onBtnTCPIPCancelClicked() })
v.btnServerIPOk = v.uiManager.NewButton(d2ui.ButtonTypeOkCancel, "OK")
v.btnServerIPOk = v.uiManager.NewButton(d2ui.ButtonTypeOkCancel, v.asset.TranslateString(d2enum.OKLabel))
v.btnServerIPOk.SetPosition(srvOkBtnX, srvOkBtnY)
v.btnServerIPOk.OnActivated(func() { v.onBtnTCPIPOkClicked() })
@ -444,24 +374,24 @@ func (v *MainMenu) createButtons(loading d2screen.LoadingState) {
func (v *MainMenu) createMultiplayerMenuButtons() {
v.multiplayerButton = v.uiManager.NewButton(d2ui.ButtonTypeWide,
v.asset.TranslateLabel(otherMultiplayerLabel))
v.asset.TranslateLabel(d2enum.OtherMultiplayerLabel))
v.multiplayerButton.SetPosition(multiplayerBtnX, multiplayerBtnY)
v.multiplayerButton.OnActivated(func() { v.onMultiplayerClicked() })
v.networkTCPIPButton = v.uiManager.NewButton(d2ui.ButtonTypeWide, v.asset.TranslateLabel(tcpIPGameLabel))
v.networkTCPIPButton = v.uiManager.NewButton(d2ui.ButtonTypeWide, v.asset.TranslateLabel(d2enum.TCPIPGameLabel))
v.networkTCPIPButton.SetPosition(tcpNetBtnX, tcpNetBtnY)
v.networkTCPIPButton.OnActivated(func() { v.onNetworkTCPIPClicked() })
v.networkCancelButton = v.uiManager.NewButton(d2ui.ButtonTypeWide,
v.asset.TranslateLabel(cancelLabel))
v.asset.TranslateLabel(d2enum.CancelLabel))
v.networkCancelButton.SetPosition(networkCancelBtnX, networkCancelBtnY)
v.networkCancelButton.OnActivated(func() { v.onNetworkCancelClicked() })
v.btnTCPIPHostGame = v.uiManager.NewButton(d2ui.ButtonTypeWide, v.asset.TranslateLabel(tcpIPHostGameLabel))
v.btnTCPIPHostGame = v.uiManager.NewButton(d2ui.ButtonTypeWide, v.asset.TranslateLabel(d2enum.TCPIPHostGameLabel))
v.btnTCPIPHostGame.SetPosition(tcpHostBtnX, tcpHostBtnY)
v.btnTCPIPHostGame.OnActivated(func() { v.onTCPIPHostGameClicked() })
v.btnTCPIPJoinGame = v.uiManager.NewButton(d2ui.ButtonTypeWide, v.asset.TranslateLabel(tcpIPJoinGameLabel))
v.btnTCPIPJoinGame = v.uiManager.NewButton(d2ui.ButtonTypeWide, v.asset.TranslateLabel(d2enum.TCPIPJoinGameLabel))
v.btnTCPIPJoinGame.SetPosition(tcpJoinBtnX, tcpJoinBtnY)
v.btnTCPIPJoinGame.OnActivated(func() { v.onTCPIPJoinGameClicked() })
}
@ -717,5 +647,5 @@ func (v *MainMenu) getLocalIP() string {
v.Warning("no IPv4 Address could be found")
return v.asset.TranslateLabel(ipNotFoundLabel)
return v.asset.TranslateLabel(d2enum.IPNotFoundLabel)
}

View File

@ -416,7 +416,7 @@ func (v *SelectHeroClass) createLabels() {
halfFontWidth := fontWidth / half
v.headingLabel.SetPosition(headingX-halfFontWidth, headingY)
v.headingLabel.SetText(v.asset.TranslateLabel(selectHeroClassLabel))
v.headingLabel.SetText(v.asset.TranslateLabel(d2enum.SelectHeroClassLabel))
v.headingLabel.Alignment = d2ui.HorizontalAlignCenter
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.Alignment = d2ui.HorizontalAlignLeft
v.heroNameLabel.SetText(d2ui.ColorTokenize(v.asset.TranslateLabel(charNameLabel), d2ui.ColorTokenGold))
v.heroNameLabel.SetText(d2ui.ColorTokenize(v.asset.TranslateLabel(d2enum.CharNameLabel), d2ui.ColorTokenGold))
v.heroNameLabel.SetPosition(heroNameLabelX, heroNameLabelY)
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.Alignment = d2ui.HorizontalAlignLeft
v.hardcoreCharLabel.SetText(d2ui.ColorTokenize(v.asset.TranslateLabel(hardCoreLabel), d2ui.ColorTokenGold))
v.hardcoreCharLabel.SetText(d2ui.ColorTokenize(v.asset.TranslateLabel(d2enum.HardCoreLabel), d2ui.ColorTokenGold))
v.hardcoreCharLabel.SetPosition(hardcoreLabelX, hardcoreLabelY)
}
func (v *SelectHeroClass) createButtons() {
v.exitButton = v.uiManager.NewButton(d2ui.ButtonTypeMedium, v.asset.TranslateLabel(exitLabel))
v.exitButton = v.uiManager.NewButton(d2ui.ButtonTypeMedium, v.asset.TranslateLabel(d2enum.ExitLabel))
v.exitButton.SetPosition(selHeroExitBtnX, selHeroExitBtnY)
v.exitButton.OnActivated(func() { v.onExitButtonClicked() })
v.okButton = v.uiManager.NewButton(d2ui.ButtonTypeMedium, "OK")
v.okButton = v.uiManager.NewButton(d2ui.ButtonTypeMedium, v.asset.TranslateLabel(d2enum.OKLabel))
v.okButton.SetPosition(selHeroOkBtnX, selHeroOkBtnY)
v.okButton.OnActivated(func() { v.onOkButtonClicked() })
v.okButton.SetVisible(false)
@ -685,22 +685,22 @@ func (v *SelectHeroClass) updateHeroText() {
return
case d2enum.HeroBarbarian:
v.heroClassLabel.SetText(v.asset.TranslateString("partycharbar"))
v.setDescLabels(barbarianDescr, "")
v.setDescLabels(d2enum.BarbarianDescr, "")
case d2enum.HeroNecromancer:
v.heroClassLabel.SetText(v.asset.TranslateString("partycharnec"))
v.setDescLabels(necromancerDescr, "")
v.setDescLabels(d2enum.NecromancerDescr, "")
case d2enum.HeroPaladin:
v.heroClassLabel.SetText(v.asset.TranslateString("partycharpal"))
v.setDescLabels(paladinDescr, "")
v.setDescLabels(d2enum.PaladinDescr, "")
case d2enum.HeroAssassin:
v.heroClassLabel.SetText(v.asset.TranslateString("partycharass"))
v.setDescLabels(0, "#305")
case d2enum.HeroSorceress:
v.heroClassLabel.SetText(v.asset.TranslateString("partycharsor"))
v.setDescLabels(sorceressDescr, "")
v.setDescLabels(d2enum.SorceressDescr, "")
case d2enum.HeroAmazon:
v.heroClassLabel.SetText(v.asset.TranslateString("partycharama"))
v.setDescLabels(amazonDescr, "")
v.setDescLabels(d2enum.AmazonDescr, "")
case d2enum.HeroDruid:
v.heroClassLabel.SetText(v.asset.TranslateString("partychardru"))
// here is a problem with polish language: in polish string table, there are two items with key "#304"

View File

@ -444,6 +444,12 @@ func (g *GameControls) onEscKey() {
}
if g.inventory.IsOpen() {
if g.inventory.moveGoldPanel.IsOpen() {
g.inventory.moveGoldPanel.Close()
return
}
g.inventory.Close()
escHandled = true
@ -704,6 +710,7 @@ func (g *GameControls) Load() {
func (g *GameControls) Advance(elapsed float64) error {
g.mapRenderer.Advance(elapsed)
g.hud.Advance(elapsed)
g.inventory.Advance(elapsed)
if err := g.escapeMenu.Advance(elapsed); err != nil {
return err
@ -728,7 +735,7 @@ func (g *GameControls) updateLayout() {
func (g *GameControls) isLeftPanelOpen() bool {
// https://github.com/OpenDiablo2/OpenDiablo2/issues/801
return g.heroStatsPanel.IsOpen() || g.questLog.IsOpen()
return g.heroStatsPanel.IsOpen() || g.questLog.IsOpen() || g.inventory.moveGoldPanel.IsOpen()
}
func (g *GameControls) isRightPanelOpen() bool {

View File

@ -35,6 +35,8 @@ func NewInventory(asset *d2asset.AssetManager,
record *d2records.InventoryRecord) *Inventory {
itemTooltip := ui.NewTooltip(d2resource.FontFormal11, d2resource.PaletteStatic, d2ui.TooltipXCenter, d2ui.TooltipYBottom)
mgp := NewMoveGoldPanel(asset, ui, gold, l)
// https://github.com/OpenDiablo2/OpenDiablo2/issues/797
itemFactory, _ := diablo2item.NewItemFactory(asset)
@ -48,8 +50,11 @@ func NewInventory(asset *d2asset.AssetManager,
// originY: record.Panel.Top,
originY: 0, // expansion data has these all offset by +60 ...
gold: gold,
moveGoldPanel: mgp,
}
inventory.moveGoldPanel.SetOnCloseCb(func() { inventory.onCloseGoldPanel() })
inventory.Logger = d2util.NewLogger()
inventory.Logger.SetLevel(l)
inventory.Logger.SetPrefix(logPrefix)
@ -62,15 +67,11 @@ type Inventory struct {
asset *d2asset.AssetManager
item *diablo2item.ItemFactory
uiManager *d2ui.UIManager
frame *d2ui.UIFrame
panel *d2ui.Sprite
goldLabel *d2ui.Label
grid *ItemGrid
itemTooltip *d2ui.Tooltip
closeButton *d2ui.Button
goldButton *d2ui.Button
goldLabel *d2ui.Label
panelGroup *d2ui.WidgetGroup
panelMoveGold *d2ui.WidgetGroup
hoverX int
hoverY int
originX int
@ -81,6 +82,7 @@ type Inventory struct {
isOpen bool
onCloseCb func()
gold int
moveGoldPanel *MoveGoldPanel
*d2util.Logger
}
@ -99,35 +101,45 @@ func (g *Inventory) Load() {
var err error
g.panelGroup = g.uiManager.NewWidgetGroup(d2ui.RenderPriorityInventory)
g.panelMoveGold = g.uiManager.NewWidgetGroup(d2ui.RenderPriorityHeroStatsPanel)
g.frame = d2ui.NewUIFrame(g.asset, g.uiManager, d2ui.FrameRight)
g.panelGroup.AddWidget(g.frame)
g.closeButton = g.uiManager.NewButton(d2ui.ButtonTypeSquareClose, "")
g.closeButton.SetVisible(false)
g.closeButton.SetPosition(invCloseButtonX, invCloseButtonY)
g.closeButton.OnActivated(func() { g.Close() })
g.panelGroup.AddWidget(g.closeButton)
g.goldButton = g.uiManager.NewButton(d2ui.ButtonTypeGoldCoin, "")
g.goldButton.SetVisible(false)
g.goldButton.SetPosition(invGoldButtonX, invGoldButtonY)
g.goldButton.OnActivated(func() { g.onGoldClicked() })
g.panelGroup.AddWidget(g.goldButton)
g.goldLabel = g.uiManager.NewLabel(d2resource.Font16, d2resource.PaletteStatic)
g.goldLabel.Alignment = d2ui.HorizontalAlignLeft
g.goldLabel.SetText(fmt.Sprintln(g.gold))
g.goldLabel.SetPosition(invGoldLabelX, invGoldLabelY)
g.panelGroup.AddWidget(g.goldLabel)
frame := d2ui.NewUIFrame(g.asset, g.uiManager, d2ui.FrameRight)
g.panelGroup.AddWidget(frame)
g.panel, err = g.uiManager.NewSprite(d2resource.InventoryCharacterPanel, d2resource.PaletteSky)
if err != nil {
g.Error(err.Error())
}
g.panelGroup.SetVisible(false)
closeButton := g.uiManager.NewButton(d2ui.ButtonTypeSquareClose, "")
closeButton.SetVisible(false)
closeButton.SetPosition(invCloseButtonX, invCloseButtonY)
closeButton.OnActivated(func() { g.Close() })
g.panelGroup.AddWidget(closeButton)
goldButton := g.uiManager.NewButton(d2ui.ButtonTypeGoldCoin, "")
goldButton.SetVisible(false)
goldButton.SetPosition(invGoldButtonX, invGoldButtonY)
goldButton.OnActivated(func() { g.onGoldClicked() })
// nolint:gocritic // this variable will be used in future
// deposite := g.asset.TranslateString("strGoldDeposit")
drop := g.asset.TranslateString("strGoldDrop")
// nolint:gocritic // this variable will be used in future
// withdraw := g.asset.TranslateString("strGoldWithdraw")
tooltip := g.uiManager.NewTooltip(d2resource.Font16, d2resource.PaletteSky, d2ui.TooltipXCenter, d2ui.TooltipYBottom)
// here should be switch-case statement for each of move-gold button descr
tooltip.SetText(drop)
tooltip.SetPosition(invGoldButtonX, invGoldButtonY)
goldButton.SetTooltip(tooltip)
g.panelGroup.AddWidget(goldButton)
g.goldLabel = g.uiManager.NewLabel(d2resource.Font16, d2resource.PaletteStatic)
g.goldLabel.Alignment = d2ui.HorizontalAlignLeft
g.goldLabel.SetText(fmt.Sprintln(g.moveGoldPanel.gold))
g.goldLabel.SetPosition(invGoldLabelX, invGoldLabelY)
g.panelGroup.AddWidget(g.goldLabel)
// https://github.com/OpenDiablo2/OpenDiablo2/issues/795
testInventoryCodes := [][]string{
@ -176,6 +188,10 @@ func (g *Inventory) Load() {
if err != nil {
g.Errorf("could not add items to the inventory, err: %v", err.Error())
}
g.moveGoldPanel.Load()
g.panelGroup.SetVisible(false)
}
// Open opens the inventory
@ -187,6 +203,7 @@ func (g *Inventory) Open() {
// Close closes the inventory
func (g *Inventory) Close() {
g.isOpen = false
g.moveGoldPanel.Close()
g.panelGroup.SetVisible(false)
g.onCloseCb()
}
@ -197,7 +214,16 @@ func (g *Inventory) SetOnCloseCb(cb func()) {
}
func (g *Inventory) onGoldClicked() {
g.Info("Gold action clicked")
g.Info("Move gold action clicked")
g.toggleMoveGoldPanel()
}
func (g *Inventory) toggleMoveGoldPanel() {
g.moveGoldPanel.Toggle()
}
func (g *Inventory) onCloseGoldPanel() {
}
// IsOpen returns true if the inventory is open
@ -205,26 +231,28 @@ func (g *Inventory) IsOpen() bool {
return g.isOpen
}
// Advance advances the state of the Inventory
func (g *Inventory) Advance(_ float64) {
if !g.IsOpen() {
return
}
g.goldLabel.SetText(fmt.Sprintln(g.moveGoldPanel.gold))
}
// Render draws the inventory onto the given surface
func (g *Inventory) Render(target d2interface.Surface) {
if !g.isOpen {
return
}
g.goldLabel.Render(target)
err := g.renderFrame(target)
if err != nil {
g.Error(err.Error())
}
g.renderFrame(target)
g.grid.Render(target)
g.renderItemHover(target)
}
func (g *Inventory) renderFrame(target d2interface.Surface) error {
g.frame.Render(target)
func (g *Inventory) renderFrame(target d2interface.Surface) {
frames := []int{
frameInventoryTopLeft,
frameInventoryTopRight,
@ -237,7 +265,8 @@ func (g *Inventory) renderFrame(target d2interface.Surface) error {
for _, frame := range frames {
if err := g.panel.SetCurrentFrame(frame); err != nil {
return err
g.Error(err.Error())
return
}
w, h := g.panel.GetCurrentFrameSize()
@ -254,8 +283,6 @@ func (g *Inventory) renderFrame(target d2interface.Surface) error {
x = g.originX + 1
}
}
return nil
}
func (g *Inventory) renderItemHover(target d2interface.Surface) {
@ -285,10 +312,12 @@ func (g *Inventory) renderItemHover(target d2interface.Surface) {
}
func (g *Inventory) renderItemDescription(target d2interface.Surface, i InventoryItem) {
if !g.moveGoldPanel.IsOpen() {
lines := i.GetItemDescription()
g.itemTooltip.SetTextLines(lines)
_, y := g.grid.SlotToScreen(i.InventoryGridSlot())
g.itemTooltip.SetPosition(g.hoverX, y)
g.itemTooltip.Render(target)
}
}

View File

@ -0,0 +1,209 @@
package d2player
import (
"fmt"
"strconv"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2resource"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2util"
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2asset"
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2ui"
)
const (
moveGoldX, moveGoldY = 300, 350
moveGoldCloseButtonX, moveGoldCloseButtonY = moveGoldX + 140, moveGoldY - 42
moveGoldOkButtonX, moveGoldOkButtonY = moveGoldX + 35, moveGoldY - 42
moveGoldValueX, moveGoldValueY = moveGoldX + 29, moveGoldY - 90
moveGoldActionLabelX, moveGoldActionLabelY = moveGoldX + 105, moveGoldY - 150
moveGoldActionLabelOffsetY = 25
moveGoldUpArrowX, moveGoldUpArrowY = moveGoldX + 14, moveGoldY - 91
moveGoldDownArrowX, moveGoldDownArrowY = moveGoldX + 14, moveGoldY - 76
)
const goldValueFilter = "0123456789"
// NewMoveGoldPanel creates a new move gold panel
func NewMoveGoldPanel(asset *d2asset.AssetManager,
ui *d2ui.UIManager,
gold int,
l d2util.LogLevel,
) *MoveGoldPanel {
originX := 0
originY := 0
mgp := &MoveGoldPanel{
asset: asset,
uiManager: ui,
originX: originX,
originY: originY,
gold: gold,
}
mgp.Logger = d2util.NewLogger()
mgp.Logger.SetLevel(l)
mgp.Logger.SetPrefix(logPrefix)
return mgp
}
// MoveGoldPanel represents the move gold panel
type MoveGoldPanel struct {
asset *d2asset.AssetManager
uiManager *d2ui.UIManager
panel *d2ui.Sprite
onCloseCb func()
panelGroup *d2ui.WidgetGroup
gold int
actionLabel1 *d2ui.Label
actionLabel2 *d2ui.Label
value *d2ui.TextBox
originX int
originY int
isOpen bool
*d2util.Logger
}
// Load the data for the move gold panel
func (s *MoveGoldPanel) Load() {
var err error
s.panelGroup = s.uiManager.NewWidgetGroup(d2ui.RenderPriorityInventory)
s.panel, err = s.uiManager.NewSprite(d2resource.MoveGoldDialog, d2resource.PaletteSky)
if err != nil {
s.Error(err.Error())
}
s.panel.SetPosition(moveGoldX, moveGoldY)
s.panelGroup.AddWidget(s.panel)
closeButton := s.uiManager.NewButton(d2ui.ButtonTypeSquareClose, "")
closeButton.SetVisible(false)
closeButton.SetPosition(moveGoldCloseButtonX, moveGoldCloseButtonY)
closeButton.OnActivated(func() { s.Close() })
s.panelGroup.AddWidget(closeButton)
okButton := s.uiManager.NewButton(d2ui.ButtonTypeSquareOk, "")
okButton.SetVisible(false)
okButton.SetPosition(moveGoldOkButtonX, moveGoldOkButtonY)
okButton.OnActivated(func() { s.action() })
s.panelGroup.AddWidget(okButton)
s.value = s.uiManager.NewTextbox()
s.value.SetFilter(goldValueFilter)
s.value.SetText(fmt.Sprintln(s.gold))
s.value.Activate()
s.value.SetNumberOnly(s.gold)
s.value.SetPosition(moveGoldValueX, moveGoldValueY)
s.panelGroup.AddWidget(s.value)
s.actionLabel1 = s.uiManager.NewLabel(d2resource.Font16, d2resource.PaletteStatic)
s.actionLabel1.Alignment = d2ui.HorizontalAlignCenter
s.actionLabel1.SetPosition(moveGoldActionLabelX, moveGoldActionLabelY)
s.panelGroup.AddWidget(s.actionLabel1)
s.actionLabel2 = s.uiManager.NewLabel(d2resource.Font16, d2resource.PaletteStatic)
s.actionLabel2.Alignment = d2ui.HorizontalAlignCenter
s.actionLabel2.SetPosition(moveGoldActionLabelX, moveGoldActionLabelY+moveGoldActionLabelOffsetY)
s.panelGroup.AddWidget(s.actionLabel2)
increase := s.uiManager.NewButton(d2ui.ButtonTypeUpArrow, d2resource.PaletteSky)
increase.SetPosition(moveGoldUpArrowX, moveGoldUpArrowY)
increase.SetVisible(false)
increase.OnActivated(func() { s.increase() })
s.panelGroup.AddWidget(increase)
decrease := s.uiManager.NewButton(d2ui.ButtonTypeDownArrow, d2resource.PaletteSky)
decrease.SetPosition(moveGoldDownArrowX, moveGoldDownArrowY)
decrease.SetVisible(false)
decrease.OnActivated(func() { s.decrease() })
s.panelGroup.AddWidget(decrease)
s.setActionText()
s.panelGroup.SetVisible(false)
}
func (s *MoveGoldPanel) action() {
value, err := strconv.Atoi(s.value.GetText())
if err != nil {
s.Errorf("Invalid value in textbox (%s): %s", s.value.GetText(), err)
return
}
// here should be placed move action (drop, deposite e.t.c.)
s.gold -= value
s.value.SetText(fmt.Sprintln(s.gold))
s.value.SetNumberOnly(s.gold)
s.Close()
}
func (s *MoveGoldPanel) increase() {
currentValue, err := strconv.Atoi(s.value.GetText())
if err != nil {
s.Errorf("Incorrect value in textbox (cannot be converted into intager) %s", err)
return
}
if currentValue < s.gold {
s.value.SetText(fmt.Sprintln(currentValue + 1))
}
}
func (s *MoveGoldPanel) decrease() {
currentValue, err := strconv.Atoi(s.value.GetText())
if err != nil {
s.Errorf("Incorrect value in textbox (cannot be converted into intager) %s", err)
return
}
if currentValue > 0 {
s.value.SetText(fmt.Sprintln(currentValue - 1))
}
}
func (s *MoveGoldPanel) setActionText() {
dropGoldStr := d2util.SplitIntoLinesWithMaxWidth(s.asset.TranslateString("strDropGoldHowMuch"), 20)
// nolint:gocritic // it will be used
// depositeGoldStr := d2util.SplitIntoLinesWithMaxWidth(s.asset.TranslateString("strBankGoldDeposit"), 20)
// witherawGoldStr := d2util.SplitIntoLinesWithMaxWidgh(s.asset.TranslateString("strBankGoldWithdraw"), 20)
s.actionLabel1.SetText(d2ui.ColorTokenize(dropGoldStr[0], d2ui.ColorTokenGold))
s.actionLabel2.SetText(d2ui.ColorTokenize(dropGoldStr[1], d2ui.ColorTokenGold))
}
// IsOpen returns true if the move gold panel is opened
func (s *MoveGoldPanel) IsOpen() bool {
return s.isOpen
}
// Toggle toggles the visibility of the move gold panel
func (s *MoveGoldPanel) Toggle() {
if s.isOpen {
s.Close()
} else {
s.Open()
}
}
// Open opens the move gold panel
func (s *MoveGoldPanel) Open() {
s.isOpen = true
s.panelGroup.SetVisible(true)
}
// Close closed the move gold panel
func (s *MoveGoldPanel) Close() {
s.isOpen = false
s.panelGroup.SetVisible(false)
s.onCloseCb()
}
// SetOnCloseCb the callback run on closing the HeroStatsPanel
func (s *MoveGoldPanel) SetOnCloseCb(cb func()) {
s.onCloseCb = cb
}

View File

@ -13,7 +13,9 @@ import (
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2ui"
)
const white = 0xffffffff
const (
white = 0xffffffff
)
const ( // for the dc6 frames
questLogTopLeft = iota
@ -531,7 +533,7 @@ func (s *QuestLog) renderStaticPanelFrames(target d2interface.Surface) {
}
}
// copy from character select
// copy from character select (github.com/OpenDiablo2/OpenDiablo2/d2game/d2gamescreen/character_select.go)
func rgbaColor(rgba uint32) color.RGBA {
result := color.RGBA{}
a, b, g, r := 0, 1, 2, 3