Ticket #1187: health_bar_hotkey_v01.patch
File health_bar_hotkey_v01.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 // Set all inactive status bars on screen to active, removes those off screen 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 entsOffScreen = splice(entsShowingHealth, entsToDisplayHealthFor); 1442 entsOffScreen = splice(entsOffScreen, g_Selection.toList()); 1443 entsOffScreen = splice(entsOffScreen, Engine.PickEntitiesAtPoint(mouseX, mouseY)); 1444 Engine.GuiInterfaceCall("SetStatusBars", { "entities": entsOffScreen, "enabled": false }); 1445 entsShowingHealth = null; 1446 } 1447 1448 if (displayingHealthBars) 1449 { 1450 Engine.GuiInterfaceCall("SetStatusBars", { "entities": entsToDisplayHealthFor, "enabled": true }); 1451 entsShowingHealth = entsToDisplayHealthFor; 1452 } 1453 } -
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 object to splice from, and an object to slice out 232 function splice(splice_from, what_to_splice) 233 { 234 if (!what_to_splice || what_to_splice.length == 0) 235 { 236 return splice_from; 237 } 238 239 for (var index in what_to_splice) 240 { 241 var splice_from_index = splice_from.indexOf(what_to_splice[index]); 242 if (splice_from_index >= 0) 243 splice_from.splice(splice_from_index, 1); 244 } 245 246 return splice_from; 247 }