Ticket #1187: Ticket#1187_V6.patch

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

I really can't foresee any problems but feel free to point out flaws when you find them

  • 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 updateCursorAndTooltip()
    5660{
    5761    var cursorSet = false;
     
    8387        Engine.SetCursor("arrow-default");
    8488    if (!tooltipSet)
    8589        informationTooltip.hidden = true;
     90    if(showStatusBars)
     91            allStatusBars(Engine.PickFriendlyEntitiesOnScreen(Engine.GetPlayerID()));
    8692}
    8793
    8894function updateBuildingPlacementPreview()
     
    760766            Engine.RewindTimeWarp();
    761767    }
    762768
     769
     770    if (ev.type == "hotkeydown" && ev.hotkey == "healthbars.toggle")
     771            showStatusBars = true;
     772    if (ev.type == "hotkeyup" && ev.hotkey == "healthbars.toggle")
     773    {
     774        showStatusBars = false;
     775        error("Remove: " + entsOnScreen);
     776        Engine.GuiInterfaceCall("SetStatusBars", { "entities":entsOnScreen, "enabled":false });
     777        Engine.GuiInterfaceCall("SetStatusBars", { "entities":Engine.PickEntitiesAtPoint(mouseX, mouseY), "enabled":true });
     778    }
     779   
    763780    // State-machine processing:
    764781
    765782    switch (inputState)
     
    14121429{
    14131430    Engine.PostNetworkCommand({"type": "unload-all", "garrisonHolder": garrisonHolder});
    14141431}
     1432
     1433
     1434// Set all inactive status bars on screen to active, removes those off screen
     1435function allStatusBars(ents)
     1436{
     1437    var temp = entsOnScreen;
     1438    entsOnScreen = ents;
     1439    for (var ent in entsOnScreen)
     1440    {   
     1441        if (temp.indexOf(entsOnScreen[ent]) >=0)
     1442        {
     1443            if(temp.length == 1 && temp[0] == entsOnScreen[ent])
     1444                temp = [];
     1445            temp.splice(temp.indexOf(entsOnScreen[ent]), 1);
     1446        }
     1447    }
     1448    error("Selection: " + g_Selection.toList());
     1449    for (var ent in g_Selection.toList())
     1450    {   
     1451        if (entsOnScreen.indexOf(g_Selection.toList()[ent]) >=0)
     1452            entsOnScreen.splice(entsOnScreen.indexOf(g_Selection.toList()[ent]), 1);
     1453        if (entsOnScreen.indexOf(g_Selection.toList()[ent]) >=0)
     1454        {
     1455            if(temp.length == 1 && temp[i] == g_Selection.toList()[ent])
     1456                temp = {};
     1457            temp.splice(temp.indexOf(g_Selection.toList()[ent]), 1);
     1458        }
     1459    }
     1460    for (var ent in g_Selection.toList())
     1461    {   
     1462        if (entsOnScreen.indexOf(g_Selection.toList()[ent]) >=0)
     1463            entsOnScreen.splice(entsOnScreen.indexOf(g_Selection.toList()[ent]), 1);
     1464        if (entsOnScreen.indexOf(g_Selection.toList()[ent]) >=0)
     1465        {
     1466            if(temp.length == 1 && temp[i] == g_Selection.toList()[ent])
     1467                temp = {};
     1468            temp.splice(temp.indexOf(g_Selection.toList()[ent]), 1);
     1469        }
     1470    }
     1471    error("ents: " + entsOnScreen);
     1472    error("temp: " + temp);
     1473    Engine.GuiInterfaceCall("SetStatusBars", { "entities":entsOnScreen, "enabled":true });
     1474    Engine.GuiInterfaceCall("SetStatusBars", { "entities":temp, "enabled":false });
     1475}
     1476 No newline at end of file