Ticket #1187: Ticket#1187_V5.patch

File Ticket#1187_V5.patch, 3.8 KB (added by James, 12 years ago)

Works well except function (in order to be called every frame) is called in update cursor function so stops working when cursor is over a resource site.

  • binaries/data/config/default.cfg

     
    190190hotkey.timewarp.fastforward = Space         ; If timewarp mode enabled, speed up the game
    191191hotkey.timewarp.rewind = Backspace          ; If timewarp mode enabled, go back to earlier point in the game
    192192
     193
    193194; > OVERLAY KEYS
    194195hotkey.fps.toggle = "Alt+F"                  ; Toggle frame counter
    195196hotkey.session.devcommands.toggle = "Alt+D"  ; Toggle developer commands panel
    196197hotkey.session.gui.toggle = "Alt+G"          ; Toggle visibility of session GUI
    197198hotkey.menu.toggle = "F10"                   ; Toggle in-game menu
    198199hotkey.timeelapsedcounter.toggle = "F12"     ; Toggle time elapsed counter
     200hotkey.healthbars.toggle = Tab               ; Toggle display of health bars
    199201
     202
    200203; > HOTKEYS ONLY
    201204hotkey.chat = Return                        ; Toggle chat window
    202205
  • binaries/data/mods/public/gui/session/input.js

     
    5252var doublePressTimer = 0;
    5353var prevHotkey = 0;
    5454
     55// Some variables for status bar hotkey
     56var entsOnScreen = {};
     57var showStatusBars = false;
     58
    5559function updateCursor()
    5660{
    5761    if (!mouseIsOverObject)
     
    7175    }
    7276
    7377    Engine.SetCursor("arrow-default");
     78    if(showStatusBars)
     79            allStatusBars(Engine.PickFriendlyEntitiesOnScreen(Engine.GetPlayerID()));
    7480}
    7581
    7682function updateBuildingPlacementPreview()
     
    714720        else if (ev.type == "hotkeyup" && ev.hotkey == "timewarp.rewind")
    715721            Engine.RewindTimeWarp();
    716722    }
     723   
     724    if (ev.type == "hotkeydown" && ev.hotkey == "healthbars.toggle")
     725            showStatusBars = true;
     726    if (ev.type == "hotkeyup" && ev.hotkey == "healthbars.toggle")
     727    {
     728        showStatusBars = false;
     729        error("Remove: " + entsOnScreen);
     730        Engine.GuiInterfaceCall("SetStatusBars", { "entities":entsOnScreen, "enabled":false });
     731        Engine.GuiInterfaceCall("SetStatusBars", { "entities":Engine.PickEntitiesAtPoint(mouseX, mouseY), "enabled":true });
     732    }
    717733
    718734    // State-machine processing:
    719735
     
    13591375{
    13601376    Engine.PostNetworkCommand({"type": "unload-all", "garrisonHolder": garrisonHolder});
    13611377}
     1378// Set all inactive status bars on screen to active, removes those off screen
     1379function allStatusBars(ents)
     1380{
     1381    var temp = entsOnScreen;
     1382    entsOnScreen = ents;
     1383    for (var ent in entsOnScreen)
     1384    {   
     1385        if (temp.indexOf(entsOnScreen[ent]) >=0)
     1386        {
     1387            if(temp.length == 1 && temp[0] == entsOnScreen[ent])
     1388                temp = [];
     1389            temp.splice(temp.indexOf(entsOnScreen[ent]), 1);
     1390        }
     1391    }
     1392    error("Selection: " + g_Selection.toList());
     1393    for (var ent in g_Selection.toList())
     1394    {   
     1395        if (entsOnScreen.indexOf(g_Selection.toList()[ent]) >=0)
     1396            entsOnScreen.splice(entsOnScreen.indexOf(g_Selection.toList()[ent]), 1);
     1397        if (entsOnScreen.indexOf(g_Selection.toList()[ent]) >=0)
     1398        {
     1399            if(temp.length == 1 && temp[i] == g_Selection.toList()[ent])
     1400                temp = {};
     1401            temp.splice(temp.indexOf(g_Selection.toList()[ent]), 1);
     1402        }
     1403    }
     1404    for (var ent in g_Selection.toList())
     1405    {   
     1406        if (entsOnScreen.indexOf(g_Selection.toList()[ent]) >=0)
     1407            entsOnScreen.splice(entsOnScreen.indexOf(g_Selection.toList()[ent]), 1);
     1408        if (entsOnScreen.indexOf(g_Selection.toList()[ent]) >=0)
     1409        {
     1410            if(temp.length == 1 && temp[i] == g_Selection.toList()[ent])
     1411                temp = {};
     1412            temp.splice(temp.indexOf(g_Selection.toList()[ent]), 1);
     1413        }
     1414    }
     1415    error("ents: " + entsOnScreen);
     1416    error("temp: " + temp);
     1417    Engine.GuiInterfaceCall("SetStatusBars", { "entities":entsOnScreen, "enabled":true });
     1418    Engine.GuiInterfaceCall("SetStatusBars", { "entities":temp, "enabled":false });
     1419}
     1420 No newline at end of file