1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-12-27 04:26:29 -05:00
OpenDiablo2/d2game/d2player/mini_panel.go

405 lines
8.6 KiB
Go
Raw Normal View History

package d2player
import (
"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 (
miniPanelX = 325
miniPanelY = 526
panelOffsetLeft = 130
panelOffsetRight = 130
)
const (
containerOffsetX = -75
containerOffsetY = -49
buttonOffsetX = -72
buttonOffsetY = -52
)
type miniPanelContent struct {
buttonType d2ui.ButtonType
onActivate func()
tooltip string
}
type miniPanelActions struct {
characterToggle func()
inventoryToggle func()
skilltreeToggle func()
partyToggle func()
automapToggle func()
messageToggle func()
questToggle func()
menuToggle func()
}
func newMiniPanel(asset *d2asset.AssetManager,
uiManager *d2ui.UIManager,
l d2util.LogLevel,
isSinglePlayer bool) *miniPanel {
mp := &miniPanel{
ui: uiManager,
asset: asset,
isOpen: false,
isSinglePlayer: isSinglePlayer,
}
mp.Logger = d2util.NewLogger()
mp.Logger.SetLevel(l)
mp.Logger.SetPrefix(logPrefix)
return mp
}
type miniPanel struct {
Ui hud polishing (#938) * d2ui/tooltip: Make it invisible by default * d2ui/button: Add GetToggled() method * d2player/HUD: Add tooltip for minipanel button * d2ui/button: Add disabled frame to minipanel buttons * d2ui/widget_group: Add SetEnable method for clickable widgets * d2player/mini_panel: move menu button here from HUD * d2ui/button: toggled buttons take preference over disabled buttons * d2player/help_overlay: Make panel only use widgets * d2player/hud: Group most widgets into widget group * d2ui/custom_widget: Allow tooltip to be attached * d2player/hud: Attach staminaBar tooltip to staminaBar * d2player/hud: Attach experienceBar tooltip to experienceBar widget * d2ui/ui_manager: Always draw tooltips last * d2player/help_overlay: It should be drawn over the HUD * d2player/globeWidget: Move tooltip here from HUD * d2core/tooltip: Automatically add tooltips to the uiManager * d2core/ui_manager: Remove special handling of widgetGroups for rendering * d2player/help_overlay: Add button to widget group * d2player/hud: Attack runwalk tooltip to button * d2player/mini_panel: Add panelButton to its own widget group * d2core/widget_group: When a clickable is added, it's also added to uiManager * d2player/globeWidget: make tooltip un/lock on click * d2player/hud: Add runbutton to widget group * d2player/mini_panel: Add group for tooltips this allows us to move the tooltip with the panelbuttons. They can't be in the general panelGroup as they would all become visible when the panel is opened. * d2core/button: Remove debug log when a button with tooltip is hovered
2020-11-21 05:35:32 -05:00
ui *d2ui.UIManager
asset *d2asset.AssetManager
container *d2ui.Sprite
sprite *d2ui.Sprite
menuButton *d2ui.Button
miniPanelTooltip *d2ui.Tooltip
isOpen bool
tempIsOpen bool
disabled bool
isSinglePlayer bool
movedLeft bool
movedRight bool
panelGroup *d2ui.WidgetGroup
groupAlwaysVis *d2ui.WidgetGroup
tooltipGroup *d2ui.WidgetGroup
*d2util.Logger
}
func (m *miniPanel) load(actions *miniPanelActions) {
var err error
m.sprite, err = m.ui.NewSprite(d2resource.MinipanelButton, d2resource.PaletteSky)
if err != nil {
m.Error(err.Error())
return
}
m.createWidgets(actions)
}
func (m *miniPanel) createWidgets(actions *miniPanelActions) {
var err error
m.panelGroup = m.ui.NewWidgetGroup(d2ui.RenderPriorityMinipanel)
m.panelGroup.SetPosition(miniPanelX, miniPanelY)
Ui hud polishing (#938) * d2ui/tooltip: Make it invisible by default * d2ui/button: Add GetToggled() method * d2player/HUD: Add tooltip for minipanel button * d2ui/button: Add disabled frame to minipanel buttons * d2ui/widget_group: Add SetEnable method for clickable widgets * d2player/mini_panel: move menu button here from HUD * d2ui/button: toggled buttons take preference over disabled buttons * d2player/help_overlay: Make panel only use widgets * d2player/hud: Group most widgets into widget group * d2ui/custom_widget: Allow tooltip to be attached * d2player/hud: Attach staminaBar tooltip to staminaBar * d2player/hud: Attach experienceBar tooltip to experienceBar widget * d2ui/ui_manager: Always draw tooltips last * d2player/help_overlay: It should be drawn over the HUD * d2player/globeWidget: Move tooltip here from HUD * d2core/tooltip: Automatically add tooltips to the uiManager * d2core/ui_manager: Remove special handling of widgetGroups for rendering * d2player/help_overlay: Add button to widget group * d2player/hud: Attack runwalk tooltip to button * d2player/mini_panel: Add panelButton to its own widget group * d2core/widget_group: When a clickable is added, it's also added to uiManager * d2player/globeWidget: make tooltip un/lock on click * d2player/hud: Add runbutton to widget group * d2player/mini_panel: Add group for tooltips this allows us to move the tooltip with the panelbuttons. They can't be in the general panelGroup as they would all become visible when the panel is opened. * d2core/button: Remove debug log when a button with tooltip is hovered
2020-11-21 05:35:32 -05:00
m.groupAlwaysVis = m.ui.NewWidgetGroup(d2ui.RenderPriorityMinipanel)
m.tooltipGroup = m.ui.NewWidgetGroup(d2ui.RenderPriorityForeground)
Ui hud polishing (#938) * d2ui/tooltip: Make it invisible by default * d2ui/button: Add GetToggled() method * d2player/HUD: Add tooltip for minipanel button * d2ui/button: Add disabled frame to minipanel buttons * d2ui/widget_group: Add SetEnable method for clickable widgets * d2player/mini_panel: move menu button here from HUD * d2ui/button: toggled buttons take preference over disabled buttons * d2player/help_overlay: Make panel only use widgets * d2player/hud: Group most widgets into widget group * d2ui/custom_widget: Allow tooltip to be attached * d2player/hud: Attach staminaBar tooltip to staminaBar * d2player/hud: Attach experienceBar tooltip to experienceBar widget * d2ui/ui_manager: Always draw tooltips last * d2player/help_overlay: It should be drawn over the HUD * d2player/globeWidget: Move tooltip here from HUD * d2core/tooltip: Automatically add tooltips to the uiManager * d2core/ui_manager: Remove special handling of widgetGroups for rendering * d2player/help_overlay: Add button to widget group * d2player/hud: Attack runwalk tooltip to button * d2player/mini_panel: Add panelButton to its own widget group * d2core/widget_group: When a clickable is added, it's also added to uiManager * d2player/globeWidget: make tooltip un/lock on click * d2player/hud: Add runbutton to widget group * d2player/mini_panel: Add group for tooltips this allows us to move the tooltip with the panelbuttons. They can't be in the general panelGroup as they would all become visible when the panel is opened. * d2core/button: Remove debug log when a button with tooltip is hovered
2020-11-21 05:35:32 -05:00
// container sprite
miniPanelContainerPath := d2resource.Minipanel
if m.isSinglePlayer {
miniPanelContainerPath = d2resource.MinipanelSmall
}
2020-09-12 16:25:09 -04:00
m.container, err = m.ui.NewSprite(miniPanelContainerPath, d2resource.PaletteSky)
if err != nil {
m.Error(err.Error())
return
}
if err = m.container.SetCurrentFrame(0); err != nil {
m.Error(err.Error())
return
}
// nolint:golint,gomnd // divide by 2 does not need a magic number
x, y := screenWidth/2+containerOffsetX, screenHeight+containerOffsetY
m.container.SetPosition(x, y)
m.panelGroup.AddWidget(m.container)
Ui hud polishing (#938) * d2ui/tooltip: Make it invisible by default * d2ui/button: Add GetToggled() method * d2player/HUD: Add tooltip for minipanel button * d2ui/button: Add disabled frame to minipanel buttons * d2ui/widget_group: Add SetEnable method for clickable widgets * d2player/mini_panel: move menu button here from HUD * d2ui/button: toggled buttons take preference over disabled buttons * d2player/help_overlay: Make panel only use widgets * d2player/hud: Group most widgets into widget group * d2ui/custom_widget: Allow tooltip to be attached * d2player/hud: Attach staminaBar tooltip to staminaBar * d2player/hud: Attach experienceBar tooltip to experienceBar widget * d2ui/ui_manager: Always draw tooltips last * d2player/help_overlay: It should be drawn over the HUD * d2player/globeWidget: Move tooltip here from HUD * d2core/tooltip: Automatically add tooltips to the uiManager * d2core/ui_manager: Remove special handling of widgetGroups for rendering * d2player/help_overlay: Add button to widget group * d2player/hud: Attack runwalk tooltip to button * d2player/mini_panel: Add panelButton to its own widget group * d2core/widget_group: When a clickable is added, it's also added to uiManager * d2player/globeWidget: make tooltip un/lock on click * d2player/hud: Add runbutton to widget group * d2player/mini_panel: Add group for tooltips this allows us to move the tooltip with the panelbuttons. They can't be in the general panelGroup as they would all become visible when the panel is opened. * d2core/button: Remove debug log when a button with tooltip is hovered
2020-11-21 05:35:32 -05:00
m.createButtons(actions)
m.panelGroup.SetVisible(false)
}
func (m *miniPanel) createButtons(actions *miniPanelActions) {
var x, y int
buttonWidth, buttonHeight, err := m.sprite.GetFrameSize(0)
if err != nil {
m.Error(err.Error())
return
}
buttonWidth++
// nolint:golint,gomnd // divide by 2 does not need a magic number
x, y = screenWidth/2+buttonOffsetX, screenHeight+buttonOffsetY-buttonHeight
buttonsFirst := []miniPanelContent{
{d2ui.ButtonTypeMinipanelCharacter,
actions.characterToggle,
m.asset.TranslateString("minipanelchar"),
},
{d2ui.ButtonTypeMinipanelInventory,
actions.inventoryToggle,
m.asset.TranslateString("minipanelinv"),
},
{d2ui.ButtonTypeMinipanelSkill,
actions.skilltreeToggle,
m.asset.TranslateString("minipaneltree"),
},
}
for i := range buttonsFirst {
btn := m.createButton(buttonsFirst[i], x+(i*buttonWidth), y, buttonHeight)
m.panelGroup.AddWidget(btn)
}
idxOffset := len(buttonsFirst)
if !m.isSinglePlayer {
partyContent := miniPanelContent{d2ui.ButtonTypeMinipanelParty,
actions.partyToggle,
m.asset.TranslateString("minipanelparty"),
}
btn := m.createButton(partyContent, x+(3*buttonWidth), y, buttonHeight)
m.panelGroup.AddWidget(btn)
idxOffset++
remove d2asset singleton (#726) * export d2asset singleton * add *d2asset.AssetManager to d2app - d2app now has a reference to an asset manager which it will use for loading - added asset loader methods to the asset manager - functions in d2asset are now wrappers for asset manager methods * add asset manager reference to audio provider - d2app asset manager reference is now passed to audio provider - asset manager is created in main.go for now to pass into audio provider - CreateSoundEffect is now a method, no longer exported, uses the asset manager reference * d2app passes asset manager refence to map engine test * in d2asset, all calls to LoadFile replaced with call to Singleton.Loadfile * blizzard intro and credits screen - d2app passes reference to the asset manager to these screens * asset manager for d2map - adding MapStampFactory, takes an asset manager reference - embedded MapStampFactory into the MapEngine - LoadStamp is now a method of the MapStampFactory * d2asset: removed LoadFileStream, LoadFile, and FileExists * d2gui changes - singleton now has an asset manager reference - calls to d2asset loader functions removed - createButton is now a method of LayoutManager - moved LayoutEntry to its own file * map entity factory - Map engine has an embedded map entity factory - Map stamp factory gets a reference to the map engine's entity factory - Stamps are given a reference to the map engine entity factory when created - Character select gets a map entity factory - Embedded the stamp factory into the MapEngine * asset manager for d2ui - d2ui is passed an asset manager reference when created - all calls to d2asset loader functions in d2ui now refer to the asset manager - d2gamescreen gets a ui manager when created - help overlay is now passed a ui manager when created * d2gamescreen + d2player: asset manager references added an asset manager reference to - inventory panel + inventory grid - mini panel - game controls - help overlay - character select - main menu - select hero class - hero stats panel * Removed d2asset.LoadAnimation all references to this function have been replaced with calls to the asset manager method * adding asset to help overlay, bugfix for 4d59c91 * Removed d2asset.LoadFont and d2asset.LoadAnimationWithEffect all references to these have been replaced with calls to the asset manager methods * MapRenderer now gets an asset manager reference * removed d2asset.LoadPalette all references have been replaced with calls to an asset manager instance * merged d2object with d2mapentity d2object was only being used to create objects in the map, so the provider function is now a method of the map entity factory. calls to d2asset have been removed. * removed d2asset.LoadComposite all calls are now made to the asset manager method * removed d2asset singleton all singleton references have been removed, a single instance of the asset manager is passed around the entire app * rename Initialize to NewAssetManager
2020-09-12 16:51:30 -04:00
}
buttonsLast := []miniPanelContent{
{d2ui.ButtonTypeMinipanelAutomap,
actions.automapToggle,
m.asset.TranslateString("minipanelautomap"),
},
{d2ui.ButtonTypeMinipanelMessage,
actions.messageToggle,
m.asset.TranslateString("minipanelmessage"),
},
{d2ui.ButtonTypeMinipanelQuest,
actions.questToggle,
m.asset.TranslateString("minipanelquest"),
},
{d2ui.ButtonTypeMinipanelMen,
actions.menuToggle,
m.asset.TranslateString("minipanelmenubtn"),
},
}
for i := range buttonsLast {
idx := i + idxOffset
btn := m.createButton(buttonsLast[i], x+(idx*buttonWidth), y, buttonHeight)
m.panelGroup.AddWidget(btn)
}
Ui hud polishing (#938) * d2ui/tooltip: Make it invisible by default * d2ui/button: Add GetToggled() method * d2player/HUD: Add tooltip for minipanel button * d2ui/button: Add disabled frame to minipanel buttons * d2ui/widget_group: Add SetEnable method for clickable widgets * d2player/mini_panel: move menu button here from HUD * d2ui/button: toggled buttons take preference over disabled buttons * d2player/help_overlay: Make panel only use widgets * d2player/hud: Group most widgets into widget group * d2ui/custom_widget: Allow tooltip to be attached * d2player/hud: Attach staminaBar tooltip to staminaBar * d2player/hud: Attach experienceBar tooltip to experienceBar widget * d2ui/ui_manager: Always draw tooltips last * d2player/help_overlay: It should be drawn over the HUD * d2player/globeWidget: Move tooltip here from HUD * d2core/tooltip: Automatically add tooltips to the uiManager * d2core/ui_manager: Remove special handling of widgetGroups for rendering * d2player/help_overlay: Add button to widget group * d2player/hud: Attack runwalk tooltip to button * d2player/mini_panel: Add panelButton to its own widget group * d2core/widget_group: When a clickable is added, it's also added to uiManager * d2player/globeWidget: make tooltip un/lock on click * d2player/hud: Add runbutton to widget group * d2player/mini_panel: Add group for tooltips this allows us to move the tooltip with the panelbuttons. They can't be in the general panelGroup as they would all become visible when the panel is opened. * d2core/button: Remove debug log when a button with tooltip is hovered
2020-11-21 05:35:32 -05:00
//nolint:gomnd // divide by 2 is not a magic number
x = screenWidth/2 + miniPanelButtonOffsetX
y = screenHeight + miniPanelButtonOffsetY
// minipanel open/close tooltip
m.miniPanelTooltip = m.ui.NewTooltip(d2resource.Font16, d2resource.PaletteUnits, d2ui.TooltipXCenter, d2ui.TooltipYTop)
m.miniPanelTooltip.SetPosition(x+miniPanelTooltipOffsetX, y+miniPanelTooltipOffsetY)
// minipanel button
m.menuButton = m.ui.NewButton(d2ui.ButtonTypeMinipanelOpenClose, "")
m.menuButton.SetPosition(x, y)
m.menuButton.OnActivated(m.onMenuButtonClicked)
m.menuButton.SetTooltip(m.miniPanelTooltip)
m.updateMinipanelTooltipText()
m.groupAlwaysVis.AddWidget(m.menuButton)
}
func (m *miniPanel) createButton(content miniPanelContent, x, y, buttonHeight int) *d2ui.Button {
// Tooltip
tt := m.ui.NewTooltip(d2resource.Font16, d2resource.PaletteSky, d2ui.TooltipXCenter, d2ui.TooltipYTop)
tt.SetPosition(x, y-buttonHeight)
tt.SetText(content.tooltip)
tt.SetVisible(false)
m.tooltipGroup.AddWidget(tt)
// Button
btn := m.ui.NewButton(content.buttonType, "")
btn.SetPosition(x, y)
btn.OnActivated(content.onActivate)
btn.SetTooltip(tt)
Ui hud polishing (#938) * d2ui/tooltip: Make it invisible by default * d2ui/button: Add GetToggled() method * d2player/HUD: Add tooltip for minipanel button * d2ui/button: Add disabled frame to minipanel buttons * d2ui/widget_group: Add SetEnable method for clickable widgets * d2player/mini_panel: move menu button here from HUD * d2ui/button: toggled buttons take preference over disabled buttons * d2player/help_overlay: Make panel only use widgets * d2player/hud: Group most widgets into widget group * d2ui/custom_widget: Allow tooltip to be attached * d2player/hud: Attach staminaBar tooltip to staminaBar * d2player/hud: Attach experienceBar tooltip to experienceBar widget * d2ui/ui_manager: Always draw tooltips last * d2player/help_overlay: It should be drawn over the HUD * d2player/globeWidget: Move tooltip here from HUD * d2core/tooltip: Automatically add tooltips to the uiManager * d2core/ui_manager: Remove special handling of widgetGroups for rendering * d2player/help_overlay: Add button to widget group * d2player/hud: Attack runwalk tooltip to button * d2player/mini_panel: Add panelButton to its own widget group * d2core/widget_group: When a clickable is added, it's also added to uiManager * d2player/globeWidget: make tooltip un/lock on click * d2player/hud: Add runbutton to widget group * d2player/mini_panel: Add group for tooltips this allows us to move the tooltip with the panelbuttons. They can't be in the general panelGroup as they would all become visible when the panel is opened. * d2core/button: Remove debug log when a button with tooltip is hovered
2020-11-21 05:35:32 -05:00
btn.SetRenderPriority(d2ui.RenderPriorityForeground)
return btn
}
Ui hud polishing (#938) * d2ui/tooltip: Make it invisible by default * d2ui/button: Add GetToggled() method * d2player/HUD: Add tooltip for minipanel button * d2ui/button: Add disabled frame to minipanel buttons * d2ui/widget_group: Add SetEnable method for clickable widgets * d2player/mini_panel: move menu button here from HUD * d2ui/button: toggled buttons take preference over disabled buttons * d2player/help_overlay: Make panel only use widgets * d2player/hud: Group most widgets into widget group * d2ui/custom_widget: Allow tooltip to be attached * d2player/hud: Attach staminaBar tooltip to staminaBar * d2player/hud: Attach experienceBar tooltip to experienceBar widget * d2ui/ui_manager: Always draw tooltips last * d2player/help_overlay: It should be drawn over the HUD * d2player/globeWidget: Move tooltip here from HUD * d2core/tooltip: Automatically add tooltips to the uiManager * d2core/ui_manager: Remove special handling of widgetGroups for rendering * d2player/help_overlay: Add button to widget group * d2player/hud: Attack runwalk tooltip to button * d2player/mini_panel: Add panelButton to its own widget group * d2core/widget_group: When a clickable is added, it's also added to uiManager * d2player/globeWidget: make tooltip un/lock on click * d2player/hud: Add runbutton to widget group * d2player/mini_panel: Add group for tooltips this allows us to move the tooltip with the panelbuttons. They can't be in the general panelGroup as they would all become visible when the panel is opened. * d2core/button: Remove debug log when a button with tooltip is hovered
2020-11-21 05:35:32 -05:00
func (m *miniPanel) onMenuButtonClicked() {
m.menuButton.Toggle()
m.Toggle()
m.updateMinipanelTooltipText()
}
func (m *miniPanel) updateMinipanelTooltipText() {
var stringTableKey string
if m.menuButton.GetToggled() {
stringTableKey = "panelcmini"
} else {
stringTableKey = "panelmini"
}
m.miniPanelTooltip.SetText(m.asset.TranslateString(stringTableKey))
}
func (m *miniPanel) IsOpen() bool {
return m.isOpen
}
func (m *miniPanel) Toggle() {
if m.isOpen {
m.Close()
} else {
m.Open()
}
}
func (m *miniPanel) Open() {
if !(m.movedRight && m.movedLeft) {
m.panelGroup.SetVisible(true)
}
Ui hud polishing (#938) * d2ui/tooltip: Make it invisible by default * d2ui/button: Add GetToggled() method * d2player/HUD: Add tooltip for minipanel button * d2ui/button: Add disabled frame to minipanel buttons * d2ui/widget_group: Add SetEnable method for clickable widgets * d2player/mini_panel: move menu button here from HUD * d2ui/button: toggled buttons take preference over disabled buttons * d2player/help_overlay: Make panel only use widgets * d2player/hud: Group most widgets into widget group * d2ui/custom_widget: Allow tooltip to be attached * d2player/hud: Attach staminaBar tooltip to staminaBar * d2player/hud: Attach experienceBar tooltip to experienceBar widget * d2ui/ui_manager: Always draw tooltips last * d2player/help_overlay: It should be drawn over the HUD * d2player/globeWidget: Move tooltip here from HUD * d2core/tooltip: Automatically add tooltips to the uiManager * d2core/ui_manager: Remove special handling of widgetGroups for rendering * d2player/help_overlay: Add button to widget group * d2player/hud: Attack runwalk tooltip to button * d2player/mini_panel: Add panelButton to its own widget group * d2core/widget_group: When a clickable is added, it's also added to uiManager * d2player/globeWidget: make tooltip un/lock on click * d2player/hud: Add runbutton to widget group * d2player/mini_panel: Add group for tooltips this allows us to move the tooltip with the panelbuttons. They can't be in the general panelGroup as they would all become visible when the panel is opened. * d2core/button: Remove debug log when a button with tooltip is hovered
2020-11-21 05:35:32 -05:00
if !m.menuButton.GetToggled() {
m.menuButton.Toggle()
}
m.isOpen = true
}
func (m *miniPanel) Close() {
m.panelGroup.SetVisible(false)
Ui hud polishing (#938) * d2ui/tooltip: Make it invisible by default * d2ui/button: Add GetToggled() method * d2player/HUD: Add tooltip for minipanel button * d2ui/button: Add disabled frame to minipanel buttons * d2ui/widget_group: Add SetEnable method for clickable widgets * d2player/mini_panel: move menu button here from HUD * d2ui/button: toggled buttons take preference over disabled buttons * d2player/help_overlay: Make panel only use widgets * d2player/hud: Group most widgets into widget group * d2ui/custom_widget: Allow tooltip to be attached * d2player/hud: Attach staminaBar tooltip to staminaBar * d2player/hud: Attach experienceBar tooltip to experienceBar widget * d2ui/ui_manager: Always draw tooltips last * d2player/help_overlay: It should be drawn over the HUD * d2player/globeWidget: Move tooltip here from HUD * d2core/tooltip: Automatically add tooltips to the uiManager * d2core/ui_manager: Remove special handling of widgetGroups for rendering * d2player/help_overlay: Add button to widget group * d2player/hud: Attack runwalk tooltip to button * d2player/mini_panel: Add panelButton to its own widget group * d2core/widget_group: When a clickable is added, it's also added to uiManager * d2player/globeWidget: make tooltip un/lock on click * d2player/hud: Add runbutton to widget group * d2player/mini_panel: Add group for tooltips this allows us to move the tooltip with the panelbuttons. They can't be in the general panelGroup as they would all become visible when the panel is opened. * d2core/button: Remove debug log when a button with tooltip is hovered
2020-11-21 05:35:32 -05:00
if m.menuButton.GetToggled() {
m.menuButton.Toggle()
}
m.isOpen = false
}
func (m *miniPanel) IsInRect(px, py int) bool {
return m.panelGroup.Contains(px, py)
}
func (m *miniPanel) moveRight() {
m.panelGroup.OffsetPosition(panelOffsetRight, 0)
m.tooltipGroup.OffsetPosition(panelOffsetRight, 0)
}
func (m *miniPanel) undoMoveRight() {
m.panelGroup.OffsetPosition(-panelOffsetRight, 0)
2020-11-26 08:16:55 -05:00
m.tooltipGroup.OffsetPosition(-panelOffsetRight, 0)
}
func (m *miniPanel) moveLeft() {
m.panelGroup.OffsetPosition(-panelOffsetLeft, 0)
m.tooltipGroup.OffsetPosition(-panelOffsetLeft, 0)
}
func (m *miniPanel) undoMoveLeft() {
m.panelGroup.OffsetPosition(panelOffsetLeft, 0)
m.tooltipGroup.OffsetPosition(panelOffsetLeft, 0)
}
func (m *miniPanel) SetMovedLeft(moveLeft bool) {
if m.movedLeft == moveLeft {
return
}
if m.movedRight {
if moveLeft {
m.undoMoveRight()
m.panelGroup.SetVisible(false)
} else {
m.moveRight()
Ui hud polishing (#938) * d2ui/tooltip: Make it invisible by default * d2ui/button: Add GetToggled() method * d2player/HUD: Add tooltip for minipanel button * d2ui/button: Add disabled frame to minipanel buttons * d2ui/widget_group: Add SetEnable method for clickable widgets * d2player/mini_panel: move menu button here from HUD * d2ui/button: toggled buttons take preference over disabled buttons * d2player/help_overlay: Make panel only use widgets * d2player/hud: Group most widgets into widget group * d2ui/custom_widget: Allow tooltip to be attached * d2player/hud: Attach staminaBar tooltip to staminaBar * d2player/hud: Attach experienceBar tooltip to experienceBar widget * d2ui/ui_manager: Always draw tooltips last * d2player/help_overlay: It should be drawn over the HUD * d2player/globeWidget: Move tooltip here from HUD * d2core/tooltip: Automatically add tooltips to the uiManager * d2core/ui_manager: Remove special handling of widgetGroups for rendering * d2player/help_overlay: Add button to widget group * d2player/hud: Attack runwalk tooltip to button * d2player/mini_panel: Add panelButton to its own widget group * d2core/widget_group: When a clickable is added, it's also added to uiManager * d2player/globeWidget: make tooltip un/lock on click * d2player/hud: Add runbutton to widget group * d2player/mini_panel: Add group for tooltips this allows us to move the tooltip with the panelbuttons. They can't be in the general panelGroup as they would all become visible when the panel is opened. * d2core/button: Remove debug log when a button with tooltip is hovered
2020-11-21 05:35:32 -05:00
m.panelGroup.SetVisible(m.isOpen)
}
} else {
if moveLeft {
m.moveLeft()
} else {
m.undoMoveLeft()
}
}
m.movedLeft = moveLeft
}
func (m *miniPanel) SetMovedRight(moveRight bool) {
if m.movedRight == moveRight {
return
}
if m.movedLeft {
if moveRight {
m.undoMoveLeft()
m.panelGroup.SetVisible(false)
} else {
m.moveLeft()
Ui hud polishing (#938) * d2ui/tooltip: Make it invisible by default * d2ui/button: Add GetToggled() method * d2player/HUD: Add tooltip for minipanel button * d2ui/button: Add disabled frame to minipanel buttons * d2ui/widget_group: Add SetEnable method for clickable widgets * d2player/mini_panel: move menu button here from HUD * d2ui/button: toggled buttons take preference over disabled buttons * d2player/help_overlay: Make panel only use widgets * d2player/hud: Group most widgets into widget group * d2ui/custom_widget: Allow tooltip to be attached * d2player/hud: Attach staminaBar tooltip to staminaBar * d2player/hud: Attach experienceBar tooltip to experienceBar widget * d2ui/ui_manager: Always draw tooltips last * d2player/help_overlay: It should be drawn over the HUD * d2player/globeWidget: Move tooltip here from HUD * d2core/tooltip: Automatically add tooltips to the uiManager * d2core/ui_manager: Remove special handling of widgetGroups for rendering * d2player/help_overlay: Add button to widget group * d2player/hud: Attack runwalk tooltip to button * d2player/mini_panel: Add panelButton to its own widget group * d2core/widget_group: When a clickable is added, it's also added to uiManager * d2player/globeWidget: make tooltip un/lock on click * d2player/hud: Add runbutton to widget group * d2player/mini_panel: Add group for tooltips this allows us to move the tooltip with the panelbuttons. They can't be in the general panelGroup as they would all become visible when the panel is opened. * d2core/button: Remove debug log when a button with tooltip is hovered
2020-11-21 05:35:32 -05:00
m.panelGroup.SetVisible(m.isOpen)
}
} else {
if moveRight {
m.moveRight()
} else {
m.undoMoveRight()
}
}
m.movedRight = moveRight
}
Ui hud polishing (#938) * d2ui/tooltip: Make it invisible by default * d2ui/button: Add GetToggled() method * d2player/HUD: Add tooltip for minipanel button * d2ui/button: Add disabled frame to minipanel buttons * d2ui/widget_group: Add SetEnable method for clickable widgets * d2player/mini_panel: move menu button here from HUD * d2ui/button: toggled buttons take preference over disabled buttons * d2player/help_overlay: Make panel only use widgets * d2player/hud: Group most widgets into widget group * d2ui/custom_widget: Allow tooltip to be attached * d2player/hud: Attach staminaBar tooltip to staminaBar * d2player/hud: Attach experienceBar tooltip to experienceBar widget * d2ui/ui_manager: Always draw tooltips last * d2player/help_overlay: It should be drawn over the HUD * d2player/globeWidget: Move tooltip here from HUD * d2core/tooltip: Automatically add tooltips to the uiManager * d2core/ui_manager: Remove special handling of widgetGroups for rendering * d2player/help_overlay: Add button to widget group * d2player/hud: Attack runwalk tooltip to button * d2player/mini_panel: Add panelButton to its own widget group * d2core/widget_group: When a clickable is added, it's also added to uiManager * d2player/globeWidget: make tooltip un/lock on click * d2player/hud: Add runbutton to widget group * d2player/mini_panel: Add group for tooltips this allows us to move the tooltip with the panelbuttons. They can't be in the general panelGroup as they would all become visible when the panel is opened. * d2core/button: Remove debug log when a button with tooltip is hovered
2020-11-21 05:35:32 -05:00
func (m *miniPanel) openDisabled() {
if m.disabled {
return
}
m.tempIsOpen = m.isOpen
if !m.isOpen {
m.Open()
}
m.menuButton.SetEnabled(false)
m.panelGroup.SetEnabled(false)
m.disabled = true
}
func (m *miniPanel) closeDisabled() {
if m.disabled {
return
}
m.tempIsOpen = m.isOpen
if m.isOpen {
m.Close()
}
m.menuButton.SetEnabled(false)
m.panelGroup.SetEnabled(false)
m.disabled = true
}
func (m *miniPanel) restoreDisabled() {
if !m.disabled {
return
}
m.disabled = false
m.menuButton.SetEnabled(true)
m.panelGroup.SetEnabled(true)
if m.tempIsOpen {
m.Open()
} else {
m.Close()
}
}