diff --git a/LuaUI/Configs/lang/healthbars.de.json b/LuaUI/Configs/lang/healthbars.de.json index 89a1d4fe94..6fc5a77a5b 100644 --- a/LuaUI/Configs/lang/healthbars.de.json +++ b/LuaUI/Configs/lang/healthbars.de.json @@ -1,6 +1,6 @@ { - "shield_bar" : "Schild", - "health_bar" : "Leben", + "shield" : "Schild", + "health" : "Leben", "building" : "Bauen", "morph" : "Morph", "stockpile" : "Vorrat", @@ -8,15 +8,16 @@ "disarm" : "Entwaffnung", "capture" : "Einfang", "capture_reload" : "Einfang nachladen", - "water_tank" : "Wassertank", "teleport" : "Teleportation", + "teleport_pw" : "Evakuierung", "ability" : "Fähigkeit", + "heat" : "hitze", + "speed" : "tempo", + "reammo" : "bewaffnen", "reload" : "nachladen", "slow" : "langsam", "goo" : "goo", - "reclaim" : "reclaim", - "reammo" : "bewaffnen", - "teleport_pw" : "Evakuierung", + "jump" : "Sprung", "resurrect" : "wiederbeleben", - "jump" : "Sprung" + "reclaim" : "reclaim" } diff --git a/LuaUI/Configs/lang/healthbars.en.json b/LuaUI/Configs/lang/healthbars.en.json index ad2987510b..a8e38aafc8 100644 --- a/LuaUI/Configs/lang/healthbars.en.json +++ b/LuaUI/Configs/lang/healthbars.en.json @@ -1,6 +1,6 @@ { - "shield_bar" : "shield", - "health_bar" : "health", + "shield" : "shield", + "health" : "health", "building" : "building", "morph" : "morph", "stockpile" : "stockpile", @@ -8,17 +8,16 @@ "disarm" : "disarm", "capture" : "capture", "capture_reload" : "capture reload", - "water_tank" : "water tank", "teleport" : "teleport", + "teleport_pw" : "evacuation", "ability" : "ability", "heat" : "heat", "speed" : "speed", + "reammo" : "rearming", "reload" : "reload", "slow" : "slow", "goo" : "goo", - "reclaim" : "reclaim", - "reammo" : "rearming", - "teleport_pw" : "evacuation", + "jump" : "jump", "resurrect" : "resurrect", - "jump" : "jump" + "reclaim" : "reclaim" } diff --git a/LuaUI/Configs/lang/healthbars.fr.json b/LuaUI/Configs/lang/healthbars.fr.json index dfa38d0456..e13b2c087e 100644 --- a/LuaUI/Configs/lang/healthbars.fr.json +++ b/LuaUI/Configs/lang/healthbars.fr.json @@ -1,6 +1,6 @@ { - "shield_bar" : "bouclier", - "health_bar" : "vie", + "shield" : "bouclier", + "health" : "vie", "building" : "construction", "morph" : "évolution", "stockpile" : "réserve", @@ -8,17 +8,16 @@ "disarm" : "désarmer", "capture" : "capturer", "capture_reload" : "recharge de la capture", - "water_tank" : "réservoir d'eau", "teleport" : "téléporter", + "teleport_pw" : "évacuer", "ability" : "capacité", "heat" : "chaleur", "speed" : "vitesse", + "reammo" : "réarmer", "reload" : "recharger", "slow" : "ralenti", "goo" : "slime", - "reclaim" : "recycler", - "reammo" : "réarmer", - "teleport_pw" : "évacuer", + "jump" : "sauter", "resurrect" : "ressusciter", - "jump" : "sauter" + "reclaim" : "recycler" } diff --git a/LuaUI/Configs/lang/healthbars.it.json b/LuaUI/Configs/lang/healthbars.it.json index dee08f7f93..d005f508a6 100644 --- a/LuaUI/Configs/lang/healthbars.it.json +++ b/LuaUI/Configs/lang/healthbars.it.json @@ -1,6 +1,6 @@ { - "shield_bar" : "Scudo", - "health_bar" : "Vita", + "shield" : "Scudo", + "health" : "Vita", "building" : "Edificio", "morph" : "trasforma", "stockpile" : "scorta", @@ -8,17 +8,16 @@ "disarm" : "disarma", "capture" : "cattura", "capture_reload" : "ricarica cattura", - "water_tank" : "serbatoio d'acqua", "teleport" : "Teletrasporto", + "teleport_pw" : "evacuazione", "ability" : "abilità", "heat" : "calore", "speed" : "velocità", + "reammo" : "in riarmo", "reload" : "Ricarica", "slow" : "lento", "goo" : "gelatina", - "reclaim" : "reclama", - "reammo" : "in riarmo", - "teleport_pw" : "evacuazione", + "jump" : "Salto", "resurrect" : "Risorgi", - "jump" : "Salto" + "reclaim" : "reclama" } diff --git a/LuaUI/Configs/lang/healthbars.pl.json b/LuaUI/Configs/lang/healthbars.pl.json index a1edcb2606..822b9286ed 100644 --- a/LuaUI/Configs/lang/healthbars.pl.json +++ b/LuaUI/Configs/lang/healthbars.pl.json @@ -1,6 +1,6 @@ { - "shield_bar" : "tarcza", - "health_bar" : "życie", + "shield" : "tarcza", + "health" : "życie", "building" : "budowa", "morph" : "ulepszenie", "stockpile" : "amunicja", @@ -8,17 +8,16 @@ "disarm" : "rozbrojenie", "capture" : "przejmowanie", "capture_reload" : "przeładowanie", - "water_tank" : "cysterna", "teleport" : "teleport", + "teleport_pw" : "ewakuacja", "ability" : "umiejętność", "heat" : "przegrzanie", "speed" : "prędkość", + "reammo" : "ładowanie", "reload" : "przeładowanie", "slow" : "spowolnienie", "goo" : "rozmnażanie", - "reclaim" : "zbieranie", - "reammo" : "ładowanie", - "teleport_pw" : "ewakuacja", + "jump" : "skok", "resurrect" : "wskrzeszanie", - "jump" : "skok" + "reclaim" : "zbieranie" } diff --git a/LuaUI/Configs/lang/healthbars.ru.json b/LuaUI/Configs/lang/healthbars.ru.json index 86f1740a1b..e90140349c 100644 --- a/LuaUI/Configs/lang/healthbars.ru.json +++ b/LuaUI/Configs/lang/healthbars.ru.json @@ -1,6 +1,6 @@ { - "shield_bar" : "щит", - "health_bar" : "здоровье", + "shield" : "щит", + "health" : "здоровье", "building" : "строительство", "morph" : "улучшение", "stockpile" : "боезапас", @@ -8,17 +8,16 @@ "disarm" : "обезоруживание", "capture" : "захват", "capture_reload" : "перезарядка захвата", - "water_tank" : "запас воды", "teleport" : "телепортация", + "teleport_pw" : "эвакуация", "ability" : "способность", "heat" : "перегрев", "speed" : "скорость", + "reammo" : "перевооружение", "reload" : "перезарядка", "slow" : "замедление", "goo" : "размножение", - "reclaim" : "переработка", - "reammo" : "перевооружение", - "teleport_pw" : "эвакуация", + "jump" : "прыжок", "resurrect" : "воскрешение", - "jump" : "прыжок" + "reclaim" : "переработка" } diff --git a/LuaUI/Configs/lang/healthbars.tr.json b/LuaUI/Configs/lang/healthbars.tr.json index 2595cd8cc3..8c5d37d944 100644 --- a/LuaUI/Configs/lang/healthbars.tr.json +++ b/LuaUI/Configs/lang/healthbars.tr.json @@ -1,6 +1,6 @@ { - "shield_bar": "Kalkan", - "health_bar": "Can", + "shield": "Kalkan", + "health": "Can", "building": "Bina", "morph": "Evrim", "stockpile": "Stoklama", @@ -8,15 +8,16 @@ "disarm": "Silahsız bırak", "capture": "Ele gerçir", "capture_reload": "Yeniden yakala", - "water_tank": "Su tankı", "teleport": "Işınlan", + "teleport_pw": "Tahliye", "ability": "Yetenek", + "heat": "", + "speed": "", + "reammo": "Yeniden Silahlanma", "reload": "Yenile", "slow": "Yavaş", "goo": "goo", - "reclaim": "Yeniden al", - "reammo": "Yeniden Silahlanma", - "teleport_pw": "Tahliye", + "jump": "Zıpla", "resurrect": "Yeniden canlan", - "jump": "Zıpla" + "reclaim": "Yeniden al" } diff --git a/LuaUI/Configs/lang/healthbars.uk_UA.json b/LuaUI/Configs/lang/healthbars.uk_UA.json index 120ed21971..dcb0db06e1 100644 --- a/LuaUI/Configs/lang/healthbars.uk_UA.json +++ b/LuaUI/Configs/lang/healthbars.uk_UA.json @@ -1,6 +1,6 @@ { - "shield_bar" : "щит", - "health_bar" : "здоров'я", + "shield" : "щит", + "health" : "здоров'я", "building" : "будівництво", "morph" : "трансформація", "stockpile" : "запас", @@ -8,17 +8,16 @@ "disarm" : "роззброєння", "capture" : "захоплення", "capture_reload" : "перезарядка захоплення", - "water_tank" : "бак для води", "teleport" : "телепорт", + "teleport_pw" : "евакуація", "ability" : "вміння", "heat" : "перегрів", "speed" : "швидкість", + "reammo" : "переозброєння", "reload" : "перезарядка", "slow" : "сповільнення", "goo" : "розмноження", - "reclaim" : "переробка", - "reammo" : "переозброєння", - "teleport_pw" : "евакуація", + "jump" : "стрибок", "resurrect" : "воскресіння", - "jump" : "стрибок" + "reclaim" : "переробка" } diff --git a/LuaUI/Configs/lang/healthbars.zh_CN.json b/LuaUI/Configs/lang/healthbars.zh_CN.json index 8cfb822c1c..fdbc23e773 100644 --- a/LuaUI/Configs/lang/healthbars.zh_CN.json +++ b/LuaUI/Configs/lang/healthbars.zh_CN.json @@ -1,6 +1,6 @@ { - "shield_bar" : "护盾", - "health_bar" : "生命", + "shield" : "护盾", + "health" : "生命", "building" : "建筑", "morph" : "变形", "stockpile" : "库存", @@ -8,17 +8,16 @@ "disarm" : "缴械", "capture" : "捕获", "capture_reload" : "捕获冷却", - "water_tank" : "水箱", "teleport" : "瞬移", + "teleport_pw" : "疏散", "ability" : "技能", "heat" : "热量", "speed" : "速度", + "reammo" : "重整", "reload" : "重装填", "slow" : "缓速", "goo" : "粘液", - "reclaim" : "回收", - "reammo" : "重整", - "teleport_pw" : "疏散", + "jump" : "跳跃", "resurrect" : "复活", - "jump" : "跳跃" + "reclaim" : "回收" } diff --git a/LuaUI/Configs/lang/healthbars.zh_TW.json b/LuaUI/Configs/lang/healthbars.zh_TW.json index e03adb4726..6825a9b98e 100644 --- a/LuaUI/Configs/lang/healthbars.zh_TW.json +++ b/LuaUI/Configs/lang/healthbars.zh_TW.json @@ -1,6 +1,6 @@ { - "shield_bar" : "護盾", - "health_bar" : "生命值", + "shield" : "護盾", + "health" : "生命值", "building" : "建築物", "morph" : "變形", "stockpile" : "庫存", @@ -8,17 +8,16 @@ "disarm" : "解除武裝", "capture" : "捕獲", "capture_reload" : "捕獲重新裝填", - "water_tank" : "水箱", "teleport" : "傳送", + "teleport_pw" : "疏散", "ability" : "技能", "heat" : "熱量", "speed" : "速度", + "reammo" : "重新裝填", "reload" : "重新裝填", "slow" : "緩速", "goo" : "黏性物", - "reclaim" : "回收", - "reammo" : "重新裝填", - "teleport_pw" : "疏散", + "jump" : "跳躍", "resurrect" : "復活", - "jump" : "跳躍" + "reclaim" : "回收" } diff --git a/LuaUI/Widgets/unit_healthbars.lua b/LuaUI/Widgets/unit_healthbars.lua index 7d818c6f5d..11aa637569 100644 --- a/LuaUI/Widgets/unit_healthbars.lua +++ b/LuaUI/Widgets/unit_healthbars.lua @@ -66,33 +66,39 @@ for i = 1, #FeatureDefs do drawnFeature[i] = (FeatureDefs[i].drawTypeString == "model") end +local addPercent +local addTitle + -------------------------------------------------------------------------------- -- LOCALISATION -------------------------------------------------------------------------------- +-- messages are populated by localization. local messages = { - shield_bar = "shield", - health_bar = "health", - building = "building", - morph = "morph", - stockpile = "stockpile", - paralyze = "paralyze", - disarm = "disarm", - capture = "capture", - capture_reload = "capture reload", - water_tank = "water tank", - teleport = "teleport", - teleport_pw = "teleport", - ability = "ability", - heat = "heat", - speed = "speed", - reload = "reload", - reammo = "reammo", - slow = "slow", - goo = "goo", - jump = "jump", - reclaim = "reclaim", - resurrect = "resurrect", + -- Units + shield = "", + health = "", + building = "", + morph = "", + stockpile = "", + paralyze = "", + disarm = "", + capture = "", + capture_reload = "", + teleport = "", + teleport_pw = "", + ability = "", + heat = "", + speed = "", + reload = "", + reammo = "", + slow = "", + goo = "", + jump = "", + + -- Features + reclaim = "", + resurrect = "", } local function languageChanged () @@ -124,6 +130,11 @@ options_order = { 'showhealthbars', 'drawFeatureHealth', 'drawBarPercentages', ' 'barScale', 'debugMode', 'minReloadTime', 'unitMaxHeight', 'unitPercentHeight', 'unitTitleHeight', 'featureMaxHeight', 'featurePercentHeight', 'featureTitleHeight', + 'invert_shield', 'invert_health', 'invert_building', 'invert_morph', + 'invert_stockpile', 'invert_paralyze', 'invert_disarm', 'invert_capture', + 'invert_capture_reload', 'invert_teleport', 'invert_teleport_pw', 'invert_ability', + 'invert_heat', 'invert_speed', 'invert_reload', 'invert_reammo', + 'invert_slow', 'invert_goo', 'invert_jump', 'invert_reclaim', 'invert_resurrect', } options = { showhealthbars = { @@ -231,6 +242,195 @@ options = { value = 500, OnChange = OptionsChanged, }, + invert_shield = { + name = 'invert shield bar', + type = 'bool', + value = false, + noHotkey = true, + desc = 'invert shield bar', + OnChange = OptionsChanged, + path = 'Settings/Interface/Healthbars/Invert' + }, + invert_health = { + name = 'invert health bar', + type = 'bool', + value = false, + noHotkey = true, + desc = 'invert health bar', + OnChange = OptionsChanged, + path = 'Settings/Interface/Healthbars/Invert' + }, + invert_building = { + name = 'invert building bar', + type = 'bool', + value = false, + noHotkey = true, + desc = 'invert building bar', + OnChange = OptionsChanged, + path = 'Settings/Interface/Healthbars/Invert' + }, + invert_morph = { + name = 'invert morph bar', + type = 'bool', + value = false, + noHotkey = true, + desc = 'invert morph bar', + OnChange = OptionsChanged, + path = 'Settings/Interface/Healthbars/Invert' + }, + invert_stockpile = { + name = 'invert stockpile bar', + type = 'bool', + value = false, + noHotkey = true, + desc = 'invert stockpile bar', + OnChange = OptionsChanged, + path = 'Settings/Interface/Healthbars/Invert' + }, + invert_paralyze = { + name = 'invert paralyze bar', + type = 'bool', + value = false, + noHotkey = true, + desc = 'invert paralyze bar', + OnChange = OptionsChanged, + path = 'Settings/Interface/Healthbars/Invert' + }, + invert_disarm = { + name = 'invert disarm bar', + type = 'bool', + value = false, + noHotkey = true, + desc = 'invert disarm bar', + OnChange = OptionsChanged, + path = 'Settings/Interface/Healthbars/Invert' + }, + invert_capture = { + name = 'invert capture bar', + type = 'bool', + value = false, + noHotkey = true, + desc = 'invert capture bar', + OnChange = OptionsChanged, + path = 'Settings/Interface/Healthbars/Invert' + }, + invert_capture_reload = { + name = 'invert capture_reload bar', + type = 'bool', + value = false, + noHotkey = true, + desc = 'invert capture_reload bar', + OnChange = OptionsChanged, + path = 'Settings/Interface/Healthbars/Invert' + }, + invert_teleport = { + name = 'invert teleport bar', + type = 'bool', + value = false, + noHotkey = true, + desc = 'invert teleport bar', + OnChange = OptionsChanged, + path = 'Settings/Interface/Healthbars/Invert' + }, + invert_teleport_pw = { + name = 'invert teleport_pw bar', + type = 'bool', + value = false, + noHotkey = true, + desc = 'invert teleport_pw bar', + OnChange = OptionsChanged, + path = 'Settings/Interface/Healthbars/Invert' + }, + invert_ability = { + name = 'invert ability bar', + type = 'bool', + value = false, + noHotkey = true, + desc = 'invert ability bar', + OnChange = OptionsChanged, + path = 'Settings/Interface/Healthbars/Invert' + }, + invert_heat = { + name = 'invert heat bar', + type = 'bool', + value = false, + noHotkey = true, + desc = 'invert heat bar', + OnChange = OptionsChanged, + path = 'Settings/Interface/Healthbars/Invert' + }, + invert_speed = { + name = 'invert speed bar', + type = 'bool', + value = false, + noHotkey = true, + desc = 'invert speed bar', + OnChange = OptionsChanged, + path = 'Settings/Interface/Healthbars/Invert' + }, + invert_reload = { + name = 'invert reload bar', + type = 'bool', + value = false, + noHotkey = true, + desc = 'invert reload bar', + OnChange = OptionsChanged, + path = 'Settings/Interface/Healthbars/Invert' + }, + invert_reammo = { + name = 'invert reammo bar', + type = 'bool', + value = false, + noHotkey = true, + desc = 'invert reammo bar', + OnChange = OptionsChanged, + path = 'Settings/Interface/Healthbars/Invert' + }, + invert_slow = { + name = 'invert slow bar', + type = 'bool', + value = false, + noHotkey = true, + desc = 'invert slow bar', + OnChange = OptionsChanged, + path = 'Settings/Interface/Healthbars/Invert' + }, + invert_goo = { + name = 'invert goo bar', + type = 'bool', + value = false, + noHotkey = true, + desc = 'invert goo bar', + OnChange = OptionsChanged, + path = 'Settings/Interface/Healthbars/Invert' + }, + invert_jump = { + name = 'invert jump bar', + type = 'bool', + value = false, + noHotkey = true, + desc = 'invert jump bar', + OnChange = OptionsChanged, + path = 'Settings/Interface/Healthbars/Invert' + }, + invert_reclaim = { + name = 'invert reclaim bar', + type = 'bool', + value = false, + noHotkey = true, + desc = 'invert reclaim bar', + OnChange = OptionsChanged, + path = 'Settings/Interface/Healthbars/Invert' + }, + invert_resurrect = { + name = 'invert resurrect bar', + type = 'bool', + value = false, + noHotkey = true, + desc = 'invert resurrect bar', + OnChange = OptionsChanged, + path = 'Settings/Interface/Healthbars/Invert' + }, } OptionsChanged() @@ -281,31 +481,36 @@ local fbkBottom = { 0.40, 0.40, 0.40, featureBarAlpha } local fbkTop = { 0.06, 0.06, 0.06, featureBarAlpha } local fhpcolormap = { {0.8, 0.0, 0.0, featureBarAlpha}, {0.8, 0.6, 0.0, featureBarAlpha}, {0.0, 0.70, 0.0, featureBarAlpha} } +-- durations flash _p and _b colors. local barColors = { -- Units - emp = { 0.50, 0.50, 1.00, barAlpha }, - emp_p = { 0.40, 0.40, 0.80, barAlpha }, - emp_b = { 0.60, 0.60, 0.90, barAlpha }, + shield = { 0.30, 0.00, 0.90, barAlpha }, + -- healtas colores are in bfcolormap + building = { 0.75, 0.75, 0.75, barAlpha }, + morph = { 0.60, 0.60, 0.60, barAlpha }, + stockpile = { 0.50, 0.50, 0.50, barAlpha }, + paralyze = { 0.50, 0.50, 1.00, barAlpha }, + paralyze_p = { 0.40, 0.40, 0.80, barAlpha }, + paralyze_b = { 0.60, 0.60, 0.90, barAlpha }, disarm = { 0.50, 0.50, 0.50, barAlpha }, disarm_p = { 0.40, 0.40, 0.40, barAlpha }, disarm_b = { 0.60, 0.60, 0.60, barAlpha }, capture = { 1.00, 0.50, 0.00, barAlpha }, capture_reload = { 0.00, 0.60, 0.60, barAlpha }, - build = { 0.75, 0.75, 0.75, barAlpha }, - stock = { 0.50, 0.50, 0.50, barAlpha }, - reload = { 0.00, 0.60, 0.60, barAlpha }, - reload2 = { 0.80, 0.60, 0.00, barAlpha }, + teleport = { 0.00, 0.60, 0.60, barAlpha }, + teleport_pw = { 0.00, 0.60, 0.60, barAlpha }, + ability = { 0.80, 0.60, 0.00, barAlpha }, + heat = { 0.80, 0.60, 0.00, barAlpha }, + speed = { 0.80, 0.60, 0.00, barAlpha }, reammo = { 0.00, 0.60, 0.60, barAlpha }, - jump = { 0.00, 0.80, 0.00, barAlpha }, - jump_p = { 0.80, 0.50, 0.00, barAlpha }, - sheath = { 0.00, 0.20, 1.00, barAlpha }, - fuel = { 0.70, 0.30, 0.00, barAlpha }, + reload = { 0.00, 0.60, 0.60, barAlpha }, slow = { 0.50, 0.10, 0.70, barAlpha }, + slow_p = { 0.50, 0.10, 0.70, barAlpha }, + slow_b = { 0.50, 0.10, 0.70, barAlpha }, goo = { 0.40, 0.40, 0.40, barAlpha }, - shield = { 0.30, 0.0, 0.90, barAlpha }, - tank = { 0.10, 0.20, 0.90, barAlpha }, - tele = { 0.00, 0.60, 0.60, barAlpha }, - tele_pw = { 0.00, 0.60, 0.60, barAlpha }, + jump = { 0.00, 0.80, 0.00, barAlpha }, + jump_p = { 0.80, 0.50, 0.00, barAlpha }, + jump_b = { 0.00, 0.80, 0.00, barAlpha }, -- Features resurrect = { 1.00, 0.50, 0.00, featureBarAlpha }, @@ -445,14 +650,29 @@ local function GetBarDrawer() end end - function externalFunc.AddBar(title, progress, color_index, text, color) + function externalFunc.AddPercentBar(status, percent, color) barsN = barsN + 1 - local barInfo = bars[barsN] + local barInfo = bars[barsN] + local progress = percent + if options["invert_" .. status].value then + progress = 1-progress + end if barInfo then - barInfo.title = title + barInfo.title = addTitle and messages[status] barInfo.progress = progress - barInfo.color = color or barColors[color_index] - barInfo.text = text + barInfo.color = color or barColors[status] + barInfo.text = addPercent and floor(progress*100) .. '%' + end + end + + function externalFunc.AddDurationBar(status, duration) + barsN = barsN + 1 + local barInfo = bars[barsN] + if barInfo then + barInfo.title = addTitle and messages[status] + barInfo.progress = 1 + barInfo.color = barColors[(status .. ((blink and "_b") or "_p"))] + barInfo.text = addPercent and floor(duration) .. 's' end end @@ -523,7 +743,6 @@ do local GetUnitStockpile = Spring.GetUnitStockpile local GetUnitRulesParam = Spring.GetUnitRulesParam - local addPercent local ux, uy, uz local dx, dy, dz, dist local health, maxHealth, paralyzeDamage, capture, build @@ -598,7 +817,6 @@ do reloadTime = ud.reloadTime, primaryWeapon = ud.primaryWeapon, dyanmicComm = ud.customParams.dynamic_comm, - maxWaterTank = ud.customParams.maxwatertank, freeStockpile = (ud.customParams.freestockpile and true) or nil, specialReload = ud.customParams.specialreloadtime, specialRate = ud.customParams.specialreload_userate, @@ -662,14 +880,14 @@ do local shieldOn, shieldPower = GetUnitShieldState(unitID, GetUnitRulesParam(unitID, "comm_shield_num")) if (shieldOn)and(build == 1)and(shieldPower < commShield) then shieldPower = shieldPower / commShield - barDrawer.AddBar(addTitle and messages.shield_bar, shieldPower, "shield", (addPercent and floor(shieldPower*100) .. '%')) + barDrawer.AddPercentBar("shield", shieldPower) end end else local shieldOn, shieldPower = GetUnitShieldState(unitID) if (shieldOn)and(build == 1)and(shieldPower < ci.maxShield) then shieldPower = shieldPower / ci.maxShield - barDrawer.AddBar(addTitle and messages.shield_bar, shieldPower, "shield", (addPercent and floor(shieldPower*100) .. '%')) + barDrawer.AddPercentBar("shield", shieldPower) end end end @@ -681,19 +899,18 @@ do hp100 = 100 end if (drawFullHealthBars)or(hp100 < 100) then - barDrawer.AddBar(addTitle and messages.health_bar, hp, nil, (addPercent and hp100..'%') or '', bfcolormap[hp100]) + barDrawer.AddPercentBar("health", hp, bfcolormap[hp100]) end end - --// BUILD + --// BUILDING if (build < 1) then - barDrawer.AddBar(addTitle and messages.building, build, "build", (addPercent and floor(build*100) .. '%')) + barDrawer.AddPercentBar("building", build) end - --// MORPHING + --// MORPH if (morph) then - local build = morph.progress - barDrawer.AddBar(addTitle and messages.morph, build, "build", (addPercent and floor(build*100) .. '%')) + barDrawer.AddPercentBar("morph", morph.progress) end --// STOCKPILE @@ -704,35 +921,27 @@ do stockpileBuild = GetUnitRulesParam(unitID, "gadgetStockpile") end if numStockpiled and stockpileBuild and (numStockpileQued ~= 0) then - barDrawer.AddBar(addTitle and messages.stockpile, stockpileBuild, "stock", (addPercent and floor(stockpileBuild*100) .. '%')) + barDrawer.AddPercentBar("stockpile", stockpileBuild) end else numStockpiled = false end - --// PARALYZE + --// PARALYZE local paraTime = false local stunned = GetUnitIsStunned(unitID) if (emp > 0) and(emp < 1e8) then - local infotext = "" stunned = stunned and paralyzeDamage >= empHP if (stunned) then paraTime = (paralyzeDamage-empHP)/(maxHealth*empDecline) paraUnits[#paraUnits+1] = unitID - if (addPercent) then - infotext = floor(paraTime) .. 's' - end - emp = 1 + barDrawer.AddDurationBar("paralyze", paraTime) else if (emp > 1) then emp = 1 end - if (addPercent) then - infotext = floor(emp*100)..'%' - end + barDrawer.AddPercentBar("paralyze", emp) end - local empcolor_index = (stunned and ((blink and "emp_b") or "emp_p")) or ("emp") - barDrawer.AddBar(addTitle and messages.paralyze, emp, empcolor_index, infotext) end --// DISARM @@ -741,12 +950,12 @@ do local disarmProp = (disarmFrame - gameFrame)/1200 if disarmProp < 1 then if (not paraTime) and disarmProp > emp + 0.014 then -- 16 gameframes of emp time - barDrawer.AddBar(addTitle and messages.disarm, disarmProp, "disarm", (addPercent and floor(disarmProp*100) .. '%')) + barDrawer.AddPercentBar("disarm", disarmProp) end else local disarmTime = (disarmFrame - gameFrame - 1200)/gameSpeed if (not paraTime) or disarmTime > paraTime + 0.5 then - barDrawer.AddBar(addTitle and messages.disarm, 1, ((blink and "disarm_b") or "disarm_p") or ("disarm"), floor(disarmTime) .. 's') + barDrawer.AddDurationBar("disarm", disarmTime) if not stunned then disarmUnits[#disarmUnits+1] = unitID end @@ -756,7 +965,7 @@ do --// CAPTURE (set by capture gadget) if ((capture or -1) > 0) then - barDrawer.AddBar(addTitle and messages.capture, capture, "capture", (addPercent and floor(capture*100) .. '%')) + barDrawer.AddPercentBar("capture", capture) end --// CAPTURE RECHARGE @@ -764,18 +973,7 @@ do local captureReloadState = GetUnitRulesParam(unitID, "captureRechargeFrame") if (captureReloadState and captureReloadState > 0) then local capture = 1-(captureReloadState-gameFrame)/ci.captureReload - barDrawer.AddBar(addTitle and messages.capture_reload, capture, "reload", (addPercent and floor(capture*100) .. '%')) - end - end - - --// WATER TANK - if ci.maxWaterTank then - local waterTank = GetUnitRulesParam(unitID, "watertank") - if waterTank then - local prog = waterTank/ci.maxWaterTank - if prog < 1 then - barDrawer.AddBar(addTitle and messages.water_tank, prog, "tank", (addPercent and floor(prog*100) .. '%')) - end + barDrawer.AddPercentBar("capture_reload", capture) end end @@ -792,7 +990,7 @@ do prog = 1 - TeleportEnd end if prog < 1 then - barDrawer.AddBar(addTitle and messages.teleport, prog, "tele", (addPercent and floor(prog*100) .. '%')) + barDrawer.AddPercentBar("teleport", prog) end end @@ -802,25 +1000,25 @@ do if TeleportEnd then local prog = 1 - (TeleportEnd - gameFrame)/TELEPORT_CHARGE_NEEDED if prog < 1 then - barDrawer.AddBar(addTitle and messages.teleport, prog, "tele_pw", (addPercent and floor(prog*100) .. '%')) + barDrawer.AddPercentBar("teleport_pw", prog) end end end - --// SPECIAL WEAPON + --// SPECIAL WEAPON / ABILITY if ci.specialReload then if ci.specialRate then local specialReloadProp = GetUnitRulesParam(unitID, "specialReloadRemaining") or 0 if (specialReloadProp > 0) and (specialReloadProp < 1) then - local special = 1 - specialReloadProp - barDrawer.AddBar(addTitle and messages.ability, special, "reload2", (addPercent and floor(special*100) .. '%')) + local special = 1-specialReloadProp + barDrawer.AddPercentBar("ability", special) end else local specialReloadState = GetUnitRulesParam(unitID, "specialReloadFrame") if (specialReloadState and specialReloadState > gameFrame) then local special = 1-(specialReloadState-gameFrame)/ci.specialReload -- don't divide by gamespeed, since specialReload is also in gameframes - barDrawer.AddBar(addTitle and messages.ability, special, "reload2", (addPercent and floor(special*100) .. '%')) + barDrawer.AddPercentBar("ability", special) end end end @@ -829,7 +1027,7 @@ do if ci.heat and build == 1 then local heatState = GetUnitRulesParam(unitID, "heat_bar") if (heatState and heatState > 0) then - barDrawer.AddBar(addTitle and messages.heat, heatState, "reload2", (addPercent and floor(heatState*100) .. '%')) + barDrawer.AddPercentBar("heat", heatState) end end @@ -837,7 +1035,7 @@ do if ci.speed and build == 1 then local speedState = GetUnitRulesParam(unitID, "speed_bar") if (speedState and speedState < 1) then - barDrawer.AddBar(addTitle and messages.speed, speedState, "reload2", (addPercent and floor(speedState*100) .. '%')) + barDrawer.AddPercentBar("speed", speedState) end end @@ -845,7 +1043,7 @@ do if ci.canReammo then local reammoProgress = GetUnitRulesParam(unitID, "reammoProgress") if reammoProgress then - barDrawer.AddBar(addTitle and messages.reammo, reammoProgress, "reammo", (addPercent and floor(reammoProgress*100) .. '%')) + barDrawer.AddPercentBar("reammo", reammoProgress) end end @@ -862,7 +1060,7 @@ do if (reloadFrame > gameFrame + 6) or (GetUnitRulesParam(unitID, "reloadPaused") ~= 1) then -- UPDATE_PERIOD in unit_attributes.lua. reload = 1 - ((reloadFrame-gameFrame)/gameSpeed) / ci.reloadTime; if (reload >= 0) then - barDrawer.AddBar(addTitle and messages.reload, reload, "reload", (addPercent and floor(reload*100) .. '%')) + barDrawer.AddPercentBar("reload", reload) end end end @@ -873,10 +1071,9 @@ do local reloadFrame = GetUnitRulesParam(unitID, "scriptReloadFrame") if reloadFrame and reloadFrame > gameFrame then local scriptLoaded = GetUnitRulesParam(unitID, "scriptLoaded") or ci.scriptBurst - local barText = string.format("%i/%i", scriptLoaded, ci.scriptBurst) -- .. ' | ' .. floor(reload*100) .. '%' reload = Spring.GetUnitRulesParam(unitID, "scriptReloadPercentage") or (1 - ((reloadFrame - gameFrame)/gameSpeed) / ci.scriptReload) if (reload >= 0) then - barDrawer.AddBar(addTitle and messages.reload, reload, "reload", (addPercent and barText)) + barDrawer.AddPercentBar("reload", reload) end end end @@ -884,16 +1081,16 @@ do --// SHEATH --local sheathState = GetUnitRulesParam(unitID, "sheathState") --if sheathState and (sheathState < 1) then - -- barDrawer.AddBar("sheath", sheathState, "sheath", (addPercent and floor(sheathState*100) .. '%')) + -- barDrawer.AddPercentBar("sheath", sheathState) --end --// SLOW local slowState = GetUnitRulesParam(unitID, "slowState") if (slowState and (slowState > 0)) then if slowState > 0.5 then - barDrawer.AddBar(addTitle and messages.slow, 1, "slow", (addPercent and floor((slowState - 0.5)*25) .. 's')) + barDrawer.AddDurationBar("slow", (slowState - 0.5)*25) else - barDrawer.AddBar(addTitle and messages.slow, slowState*2, "slow", (addPercent and floor(slowState*100) .. '%')) + barDrawer.AddPercentBar("slow", slowState) end end @@ -901,7 +1098,7 @@ do if ci.canGoo then local gooState = GetUnitRulesParam(unitID, "gooState") if (gooState and (gooState > 0)) then - barDrawer.AddBar(addTitle and messages.goo, gooState, "goo", (addPercent and floor(gooState*100) .. '%')) + barDrawer.AddPercentBar("goo", gooState) end end @@ -909,7 +1106,7 @@ do if ci.canJump then local jumpReload = GetUnitRulesParam(unitID, "jumpReload") if (jumpReload and (jumpReload > 0) and (jumpReload < 1)) then - barDrawer.AddBar(addTitle and messages.jump, jumpReload, ((blink_j and "jump_p") or "jump"), (addPercent and floor(jumpReload*100) .. '%')) + barDrawer.AddPercentBar("jump", jumpReload) end end @@ -960,7 +1157,7 @@ do local customInfo = {} local ci - function DrawFeatureInfos(featureID, featureDefID, addPercent, addTitle, fx, fy, fz) + function DrawFeatureInfos(featureID, featureDefID, fx, fy, fz) if (not customInfo[featureDefID]) then local featureDef = FeatureDefs[featureDefID or -1] or {height = 0, name = ''} customInfo[featureDefID] = { @@ -990,18 +1187,18 @@ do --// BARS //----------------------------------------------------------------------------- --// HEALTH if (hp < featureHpThreshold)and(drawFeatureHealth) then - local hpcolor = {GetColor(fhpcolormap, hp)} - barDrawer.AddBar(addTitle and messages.health_bar, hp, nil, (addPercent and floor(hp*100) .. '%'), hpcolor) + hp100 = hp*100; hp100 = hp100 - hp100%1; --//same as floor(hp*100), but 10% faster + barDrawer.AddPercentBar("health", hp, bfcolormap[hp100]) end --// RESURRECT if (resurrect > 0) then - barDrawer.AddBar(addTitle and messages.resurrect, resurrect, "resurrect", (addPercent and floor(resurrect*100) .. '%')) + barDrawer.AddPercentBar("resurrect", resurrect) end --// RECLAIMING if (reclaimLeft > 0 and reclaimLeft < 1) then - barDrawer.AddBar(addTitle and messages.reclaim, reclaimLeft, "reclaim", (addPercent and floor(reclaimLeft*100) .. '%')) + barDrawer.AddPercentBar("reclaim", reclaimLeft) end if barDrawer.HasBars() then @@ -1263,7 +1460,9 @@ do dx, dy, dz = wx-cx, wy-cy, wz-cz dist = dx*dx + dy*dy + dz*dz if (dist < featureDistSq) then - DrawFeatureInfos(featureInfo[4], featureInfo[5], (dist < featurePercentSq), (dist < featureTitleSq), wx, wy, wz) + addTitle = dist < featureTitleSq + addPercent = dist < featurePercentSq + DrawFeatureInfos(featureInfo[4], featureInfo[5], wx, wy, wz) end end end @@ -1312,6 +1511,7 @@ do sec = sec+dt blink = (sec%1) < 0.5 blink_j = options.flashJump.value and (activeCmdID == CMD_JUMP) and ((sec%0.5) < 0.25) + barColors.jump = (blink_j and barColors.jump_p) or barColors.jump_b gameFrame = GetGameFrame() visibleUnits = GetVisibleUnits(-1, nil, false) --this don't need any delayed update or caching or optimization since its already done in "LUAUI/cache.lua"