Ticket #1187: health_bar_hotkey_v02.patch
File health_bar_hotkey_v02.patch, 3.4 KB (added by , 12 years ago) |
---|
-
binaries/data/config/default.cfg
197 197 hotkey.session.gui.toggle = "Alt+G" ; Toggle visibility of session GUI 198 198 hotkey.menu.toggle = "F10" ; Toggle in-game menu 199 199 hotkey.timeelapsedcounter.toggle = "F12" ; Toggle time elapsed counter 200 hotkey.healthbars.toggle = Tab ; Toggle display of health bars 200 201 201 202 ; > HOTKEYS ONLY 202 203 hotkey.chat = Return ; Toggle chat window -
binaries/data/mods/public/gui/session/input.js
52 52 var doublePressTimer = 0; 53 53 var prevHotkey = 0; 54 54 55 // Toggling of health bars 56 var displayingHealthBars = false; 57 var entsShowingHealth = null; 58 55 59 function updateCursorAndTooltip() 56 60 { 57 61 var cursorSet = false; … … 83 87 Engine.SetCursor("arrow-default"); 84 88 if (!tooltipSet) 85 89 informationTooltip.hidden = true; 90 if (displayingHealthBars) 91 recalculateHealthBarDisplay(); 86 92 } 87 93 88 94 function updateBuildingPlacementPreview() … … 760 766 Engine.RewindTimeWarp(); 761 767 } 762 768 769 if (ev.hotkey == "healthbars.toggle") 770 { 771 displayingHealthBars = (ev.type == "hotkeydown"); 772 recalculateHealthBarDisplay(); 773 } 774 763 775 // State-machine processing: 764 776 765 777 switch (inputState) … … 1415 1427 { 1416 1428 Engine.PostNetworkCommand({"type": "unload-all", "garrisonHolder": garrisonHolder}); 1417 1429 } 1430 1431 // Recalculate the display of on-screen health bars 1432 function recalculateHealthBarDisplay() 1433 { 1434 if (displayingHealthBars) 1435 var entsToDisplayHealthFor = Engine.PickFriendlyEntitiesOnScreen(Engine.GetPlayerID()); 1436 1437 if (entsShowingHealth) 1438 { 1439 var entsOffScreen = entsShowingHealth; 1440 if (displayingHealthBars) 1441 array_splice(entsOffScreen, entsToDisplayHealthFor); 1442 // Always keep selected and hovered unit health bars showing 1443 array_splice(entsOffScreen, g_Selection.toList()); 1444 array_splice(entsOffScreen, Engine.PickEntitiesAtPoint(mouseX, mouseY)); 1445 Engine.GuiInterfaceCall("SetStatusBars", { "entities": entsOffScreen, "enabled": false }); 1446 entsShowingHealth = null; 1447 } 1448 1449 if (displayingHealthBars) 1450 { 1451 Engine.GuiInterfaceCall("SetStatusBars", { "entities": entsToDisplayHealthFor, "enabled": true }); 1452 entsShowingHealth = entsToDisplayHealthFor; 1453 } 1454 } -
binaries/data/mods/public/gui/common/functions_utility.js
226 226 return hours + ':' + (minutes < 10 ? '0' + minutes : minutes) + ':' + (seconds < 10 ? '0' + seconds : seconds); 227 227 } 228 228 229 // ==================================================================== 230 231 // Takes an array to splice from, and an array to splice out 232 function array_splice(splice_from, what_to_splice) 233 { 234 if (!what_to_splice || what_to_splice.length == 0) 235 return splice_from; 236 237 for (var index in what_to_splice) 238 { 239 var splice_from_index = splice_from.indexOf(what_to_splice[index]); 240 if (splice_from_index >= 0) 241 splice_from.splice(splice_from_index, 1); 242 } 243 244 return splice_from; 245 }