Skip to content

Commit

Permalink
Feat: Add StatsBars on bottom and refactor whole statsbars management (
Browse files Browse the repository at this point in the history
…#797)

* feat: added stats bars on bottom and refactored whole statsbar management \
modularize statsbars

* fix: change bar style settings name

* feat: added stats bars on bottom and refactored whole statsbar management \
modularize statsbars

* fix: change bar style settings name

* fix: fix mess with rebase

* fix: fix mess with rebase

* fix: added unintended removal of panel icons
  • Loading branch information
matheussf committed Jun 28, 2024
1 parent d6692e2 commit 5fdb983
Show file tree
Hide file tree
Showing 9 changed files with 945 additions and 257 deletions.
552 changes: 548 additions & 4 deletions data/styles/30-statsbar.otui

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion modules/client_options/data_options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -358,4 +358,4 @@ return {
modules.game_healthcircle.setCircleOpacity(bar:recursiveGetChildById('valueBar'):getValue() / 100)
end
}
}
}
2 changes: 1 addition & 1 deletion modules/client_options/general.otui
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,4 @@ Panel
margin-left: 10
anchors.verticalCenter: prev.verticalCenter
anchors.left: prev.right
mouse-scroll: false
mouse-scroll: false
1 change: 1 addition & 0 deletions modules/game_console/console.lua
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ function init()

-- toggle WASD
consoleToggleChat = consolePanel:getChildById('toggleChat')

load()

if g_game.isOnline() then
Expand Down
38 changes: 28 additions & 10 deletions modules/game_healthcircle/game_healthcircle.lua
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,8 @@ manaCheckBox = nil
experienceCheckBox = nil
skillCheckBox = nil
chooseSkillComboBox = nil
chooseTopBarDimension = nil
chooseStatsBarDimension = nil
chooseStatsBarPlacement = nil
distFromCenScrollbar = nil
opacityScrollbar = nil

Expand All @@ -520,7 +521,8 @@ function addToOptionsModule()
experienceCheckBox = optionPanel:recursiveGetChildById('experienceCheckBox')
skillCheckBox = optionPanel:recursiveGetChildById('skillCheckBox')
chooseSkillComboBox = optionPanel:recursiveGetChildById('chooseSkillComboBox')
chooseTopBarDimension = optionPanel:recursiveGetChildById('chooseTopBarDimension')
chooseStatsBarDimension = optionPanel:recursiveGetChildById('chooseStatsBarDimension')
chooseStatsBarPlacement = optionPanel:recursiveGetChildById('chooseStatsBarPlacement')
distFromCenScrollbar = optionPanel:recursiveGetChildById('distFromCenScrollbar')
opacityScrollbar = optionPanel:recursiveGetChildById('opacityScrollbar')

Expand All @@ -534,11 +536,19 @@ function addToOptionsModule()
chooseSkillComboBox:addOption('Shielding', 'shielding')
chooseSkillComboBox:addOption('Fishing', 'fishing')

chooseTopBarDimension:addOption(tr('Compact'), 'compact')
chooseTopBarDimension:addOption(tr('Default'), 'default')
chooseTopBarDimension:addOption(tr('Hide'), 'hide')
chooseTopBarDimension:addOption(tr('Large'), 'large')
chooseTopBarDimension:addOption(tr('Parallel'), 'parallel')
chooseStatsBarPlacement:addOption(tr('Top'), 'top')
chooseStatsBarPlacement:addOption(tr('Bottom'), 'bottom')

chooseStatsBarDimension:addOption(tr('Hide'), 'hide')
chooseStatsBarDimension:addOption(tr('Compact'), 'compact')
chooseStatsBarDimension:addOption(tr('Default'), 'default')
chooseStatsBarDimension:addOption(tr('Large'), 'large')
chooseStatsBarDimension:addOption(tr('Parallel'), 'parallel')

statsBarMenuLoaded = true

chooseStatsBarDimension:setCurrentOptionByData(g_settings.getString('statsbar_dimension'), true)
chooseStatsBarPlacement:setCurrentOptionByData(g_settings.getString('statsbar_placement'), true)

-- Set values
healthCheckBox:setChecked(isHealthCircle)
Expand All @@ -555,6 +565,12 @@ function addToOptionsModule()
opacityScrollbar:setValue(opacityCircle * 100)
end

function updateStatsBar()
if statsBarMenuLoaded then
modules.game_interface.updateStatsBar(chooseStatsBarDimension:getCurrentOption().data, chooseStatsBarPlacement:getCurrentOption().data)
end
end

function setPlayerValues()
local skillType = skillTypes[g_game.getCharacterName()]
if not skillType then
Expand All @@ -563,8 +579,9 @@ function setPlayerValues()
chooseSkillComboBox:setCurrentOptionByData(skillType, true)
end

function setTopBarOption(data, placement)
chooseTopBarDimension:setCurrentOptionByData(data, true)
function setStatsBarOption(dimension, placement)
chooseStatsBarDimension:setCurrentOptionByData(dimension, true)
chooseStatsBarPlacement:setCurrentOptionByData(placement, true)
end

function destroyOptionsModule()
Expand All @@ -575,7 +592,8 @@ function destroyOptionsModule()
chooseSkillComboBox = nil
distFromCenScrollbar = nil
opacityScrollbar = nil
chooseTopBarDimension = nil
chooseStatsBarDimension = nil
chooseStatsBarPlacement = nil

modules.client_options.removeTab('HP/MP Circle')
optionPanel = nil
Expand Down
15 changes: 12 additions & 3 deletions modules/game_healthcircle/option_healthcircle.otui
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,26 @@ Panel
height: 32

Label
!text: tr('Top Bar Style:')
!text: tr('Bar Style:')
anchors.left: parent.left
margin-left: 18
color: #c0c0c0ff
anchors.verticalCenter: parent.verticalCenter

QtComboBox
id: chooseTopBarDimension
id: chooseStatsBarPlacement
width: 120
margin-left: 10
anchors.verticalCenter: prev.verticalCenter
anchors.left: prev.right
mouse-scroll: false
@onTextChange: modules.game_interface.setStatsBarOption(self:getCurrentOption().data, 'top')
@onTextChange: modules.game_healthcircle.updateStatsBar()

QtComboBox
id: chooseStatsBarDimension
width: 120
margin-left: 10
anchors.verticalCenter: prev.verticalCenter
anchors.left: prev.right
mouse-scroll: false
@onTextChange: modules.game_healthcircle.updateStatsBar()
11 changes: 9 additions & 2 deletions modules/game_interface/gameinterface.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ gameSelectedPanel = nil
panelsList = {}
panelsRadioGroup = nil
gameTopPanel = nil
gameBottomStatsBarPanel = nil
gameBottomPanel = nil
showTopMenuButton = nil
logoutButton = nil
Expand Down Expand Up @@ -78,6 +79,7 @@ function init()
gameLeftPanel = gameRootPanel:getChildById('gameLeftPanel')
gameBottomPanel = gameRootPanel:getChildById('gameBottomPanel')
gameTopPanel = gameRootPanel:getChildById('gameTopPanel')
gameBottomStatsBarPanel = gameRootPanel:getChildById('gameBottomStatsBarPanel')

leftIncreaseSidePanels = gameRootPanel:getChildById('leftIncreaseSidePanels')
leftDecreaseSidePanels = gameRootPanel:getChildById('leftDecreaseSidePanels')
Expand Down Expand Up @@ -1171,6 +1173,10 @@ function getGameTopStatsBar()
return gameTopPanel
end

function getGameBottomStatsBar()
return gameBottomStatsBarPanel
end

function getGameMapPanel()
return gameMapPanel
end
Expand Down Expand Up @@ -1280,8 +1286,9 @@ function limitZoom()
end


function setStatsBarOption(dimension, placement)
StatsBar.setStatsBarOption(dimension, placement)
function updateStatsBar(dimension, placement)
StatsBar.updateCurrentStats(dimension, placement)
StatsBar.updateStatsBarOption()
end

function onIncreaseLeftPanels()
Expand Down
13 changes: 12 additions & 1 deletion modules/game_interface/gameinterface.otui
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ UIWidget
anchors.right: gameRightExtraPanel.left
anchors.top: gameTopPanel.bottom
anchors.bottom: gameBottomPanel.top

focusable: false

Button
Expand All @@ -59,7 +60,7 @@ UIWidget
id: gameBottomPanel
anchors.left: gameLeftExtraPanel.right
anchors.right: gameRightExtraPanel.left
anchors.top: bottomSplitter.top
anchors.top: gameBottomStatsBarPanel.bottom
anchors.bottom: parent.bottom

GameSidePanel
Expand Down Expand Up @@ -162,6 +163,16 @@ UIWidget
anchors.right: gameRightExtraPanel.left
anchors.top: parent.top
focusable: false

TopStatsBar
id: gameBottomStatsBarPanel
anchors.left: gameLeftExtraPanel.right
anchors.right: gameRightExtraPanel.left
anchors.top: bottomSplitter.bottom
margin-left: 1
margin-right: 1
focusable: false

Button
id: leftIncreaseSidePanels
anchors.left: gameLeftExtraPanel.right
Expand Down
Loading

0 comments on commit 5fdb983

Please sign in to comment.