From 01a8e57a3ca99702af7491af97562f9ef39dc7c3 Mon Sep 17 00:00:00 2001 From: BeniS Date: Tue, 21 Aug 2012 18:13:16 +1200 Subject: [PATCH] Battle modules filtering buttons no longer scroll, fixed skill modules regeneration alert. --- modules/game_battle/battle.otui | 100 +++++++++++++++++--------------- modules/game_skills/skills.lua | 44 ++++++++++++-- 2 files changed, 90 insertions(+), 54 deletions(-) diff --git a/modules/game_battle/battle.otui b/modules/game_battle/battle.otui index 2b19b89b..bade8b81 100644 --- a/modules/game_battle/battle.otui +++ b/modules/game_battle/battle.otui @@ -44,60 +44,64 @@ MiniWindow @onClose: modules.game_battle.onMiniWindowClose() &save: true + BattlePlayers + id: hidePlayers + !tooltip: tr('Hide players') + anchors.top: parent.top + anchors.right: next.left + margin-right: 5 + margin-top: 26 + @onCheckChange: modules.game_battle.checkCreatures() + + BattleNPCs + id: hideNPCs + !tooltip: tr('Hide Npcs') + anchors.top: parent.top + anchors.right: next.left + margin-right: 5 + margin-top: 26 + @onCheckChange: modules.game_battle.checkCreatures() + + BattleMonsters + id: hideMonsters + !tooltip: tr('Hide monsters') + anchors.top: parent.top + anchors.horizontalCenter: parent.horizontalCenter + margin-top: 26 + @onCheckChange: modules.game_battle.checkCreatures() + + BattleSkulls + id: hideSkulls + !tooltip: tr('Hide non-skull players') + anchors.top: prev.top + anchors.left: prev.right + margin-left: 5 + @onCheckChange: modules.game_battle.checkCreatures() + + BattleParty + id: hideParty + !tooltip: tr('Hide party members') + anchors.top: prev.top + anchors.left: prev.right + margin-left: 5 + phantom: true + @onCheckChange: modules.game_battle.checkCreatures() + + HorizontalSeparator + anchors.top: prev.bottom + anchors.left: parent.left + anchors.right: parent.right + margin-top: 5 + MiniWindowContents - BattlePlayers - id: hidePlayers - !tooltip: tr('Hide players') - anchors.top: parent.top - anchors.right: next.left - margin-right: 5 - margin-top: 3 - @onCheckChange: modules.game_battle.checkCreatures() - - BattleNPCs - id: hideNPCs - !tooltip: tr('Hide Npcs') - anchors.top: parent.top - anchors.right: next.left - margin-right: 5 - margin-top: 3 - @onCheckChange: modules.game_battle.checkCreatures() - - BattleMonsters - id: hideMonsters - !tooltip: tr('Hide monsters') - anchors.top: parent.top - anchors.horizontalCenter: parent.horizontalCenter - margin-top: 3 - @onCheckChange: modules.game_battle.checkCreatures() - - BattleSkulls - id: hideSkulls - !tooltip: tr('Hide non-skull players') - anchors.top: prev.top - anchors.left: prev.right - margin-left: 5 - @onCheckChange: modules.game_battle.checkCreatures() - - BattleParty - id: hideParty - !tooltip: tr('Hide party members') - anchors.top: prev.top - anchors.left: prev.right - margin-left: 5 - @onCheckChange: modules.game_battle.checkCreatures() - - HorizontalSeparator - anchors.top: prev.bottom - anchors.left: parent.left - anchors.right: parent.right - margin-top: 5 + anchors.top: parent.top + margin-top: 50 Panel id: battlePanel anchors.left: parent.left anchors.right: parent.right - anchors.top: prev.bottom + anchors.top: parent.top margin-top: 5 padding-right: 5 layout: diff --git a/modules/game_skills/skills.lua b/modules/game_skills/skills.lua index e7781793..3369abd3 100644 --- a/modules/game_skills/skills.lua +++ b/modules/game_skills/skills.lua @@ -115,12 +115,44 @@ function setSkillPercent(id, percent, tooltip) end end -function checkAlert(id, value, maxValue, threshold) - if value > maxValue or maxValue < 1 then - return +function checkAlert(id, value, maxValue, threshold, greaterThan) + if greaterThan == nil then greaterThan = false end + local alert = false + + -- maxValue can be set to false to check value and threshold + -- used for regeneration checking + if type(maxValue) == 'boolean' then + if maxValue then + return + end + + if greaterThan then + if value > threshold then + alert = true + end + else + if value < threshold then + alert = true + end + end + elseif type(maxValue) == 'number' then + if maxValue < 0 then + return + end + + local percent = math.floor((value / maxValue) * 100) + if greaterThan then + if percent > threshold then + alert = true + end + else + if percent < threshold then + alert = true + end + end end - local percent = math.floor((value / maxValue) * 100) - if percent < threshold then + + if alert then setSkillColor(id, '#b22222') -- red else resetSkillColor(id) @@ -267,7 +299,7 @@ function onRegenerationChange(localPlayer, regenerationTime) end setSkillValue('regenerationTime', hours .. ":" .. minutes) - checkAlert('regenerationTime', regenerationTime, 30, 20) -- what is max regeneration? + checkAlert('regenerationTime', regenerationTime, false, 300) end function onSpeedChange(localPlayer, speed)