Ticket #1190: #1190-2012-03-16.patch

File #1190-2012-03-16.patch, 15.6 KB (added by leper, 14 months ago)

Fix indentation of switch statement.

  • binaries/data/mods/public/gui/session/session.xml

     
    593593                    <!-- Stats --> 
    594594                    <object size="8 36 50%-48 100%" name="statsArea" type="image"> 
    595595                        <!-- Attack icon --> 
    596                         <object hidden="true" size="0 0 48 48" type="image" name="attackIcon" sprite="snIconSheetStance" cell_id="1" tooltip_style="sessionToolTip"/> 
    597  
     596                        <object hidden="true" size="0 0 48 48" type="image" name="attackIcon" sprite="stretched:session/icons/single/stance-aggressive.png" tooltip_style="sessionToolTip"/> 
     597  
    598598                        <!-- Armour icon "0 48 48 96"--> 
    599                         <object size="0 0 48 48" type="image" name="armourIcon" sprite="snIconSheetStance" cell_id="3" tooltip_style="sessionToolTip"/> 
     599                        <object size="0 0 48 48" type="image" name="armourIcon" sprite="stretched:session/icons/single/stance-defensive.png" tooltip_style="sessionToolTip"/> 
    600600 
    601601                        <!-- Resource carrying icon/counter --> 
    602602                        <object size="0 40 48 88" type="image" name="resourceCarryingIcon" style="resourceIcon"/> 
  • binaries/data/mods/public/gui/session/sprites.xml

     
    1818    </sprite> 
    1919 
    2020    <!-- ================================  ================================ --> 
    21     <!-- Unit Command Icons --> 
    22     <!-- ================================  ================================ --> 
    23     <sprite name="formation"> 
    24         <image 
    25             texture="session/icons/sheets/formation_select.png" 
    26             cell_size="64 64" 
    27             size="0 0 100% 100%" 
    28         /> 
    29     </sprite> 
    30  
    31     <sprite name="formation_disabled"> 
    32         <image 
    33             texture="session/icons/sheets/formation_nonselect.png" 
    34             cell_size="64 64" 
    35             size="0 0 100% 100%" 
    36         /> 
    37     </sprite> 
    38  
    39     <sprite name="commands"> 
    40         <image 
    41             texture="session/icons/sheets/commands.png" 
    42             cell_size="32 32" 
    43             size="0 0 100% 100%" 
    44         /> 
    45     </sprite> 
    46  
    47     <!-- ================================  ================================ --> 
    4821    <!-- Menu --> 
    4922    <!-- ================================  ================================ --> 
    5023    <sprite name="menuButton"> 
  • binaries/data/mods/public/gui/session/unit_commands.js

     
    304304        // Get icon image 
    305305        if (guiName == "Formation") 
    306306        { 
    307             icon.cell_id = getFormationCellId(item); 
    308307            var formationOk = Engine.GuiInterfaceCall("CanMoveEntsIntoFormation", { 
    309308                "ents": g_Selection.toList(), 
    310309                "formationName": item 
    311310            }); 
    312311 
    313             icon.enabled = formationOk; 
    314312            button.enabled = formationOk; 
    315             if (!icon.enabled) 
    316             { 
    317                 icon.sprite = "formation_disabled"; 
    318                 button.tooltip += " (disabled)"; 
    319             } 
    320             else 
    321             { 
    322                 icon.sprite = "formation"; 
    323             } 
    324         } 
     313            if (!formationOk) 
     314            { 
     315                icon.sprite = "stretched:session/icons/formations/formation-"+item.replace(/\s+/,'').toLowerCase()+".png"; 
     316                 
     317                // Display a meaningful tooltip why the formation is disabled 
     318                var requirements = Engine.GuiInterfaceCall("GetFormationRequirements", { 
     319                    "formationName": item 
     320                }); 
     321 
     322                button.tooltip += " (disabled)"; 
     323                if (requirements.count > 1) 
     324                    button.tooltip += "\n" + requirements.count + " units required"; 
     325                if (requirements.classesRequired) 
     326                { 
     327                    button.tooltip += "\nOnly units of type"; 
     328                    for each (var classRequired in requirements.classesRequired) 
     329                    { 
     330                        button.tooltip += " " + classRequired; 
     331                    } 
     332                    button.tooltip += " allowed."; 
     333                } 
     334            } 
     335            else 
     336            { 
     337                var formationSelected = Engine.GuiInterfaceCall("IsFormationSelected", { 
     338                    "ents": g_Selection.toList(), 
     339                    "formationName": item 
     340                }); 
     341                 
     342                if (formationSelected) 
     343                    icon.sprite = "stretched:session/icons/formations/formation-"+item.replace(/\s+/,'').toLowerCase()+"-selected.png"; 
     344                else 
     345                    icon.sprite = "stretched:session/icons/formations/formation-"+item.replace(/\s+/,'').toLowerCase()+"-available.png"; 
     346            } 
     347        } 
    325348        else if (guiName == "Stance") 
    326349        { 
    327350            var stanceSelected = Engine.GuiInterfaceCall("IsStanceSelected", { 
     
    329352                "stance": item 
    330353            }); 
    331354 
    332             icon.cell_id = i; 
    333355            if (stanceSelected) 
    334                 icon.sprite = "snIconSheetStanceButton"; 
     356                icon.sprite = "stretched:session/icons/single/stance-"+item+"-select.png"; 
    335357            else 
    336                 icon.sprite = "snIconSheetStanceButtonDisabled"; 
     358                icon.sprite = "stretched:session/icons/single/stance-"+item+".png"; 
    337359        } 
    338360        else if (guiName == "Command") 
    339361        { 
    340             //icon.cell_id = i; 
    341             //icon.cell_id = getCommandCellId(item); 
    342362            icon.sprite = "stretched:session/icons/single/" + item.icon; 
    343363 
    344364        } 
     
    520540 
    521541        // TODO: probably should load the stance list from a data file, 
    522542        // and/or vary depending on what units are selected 
    523         var stances = ["violent", "aggressive", "passive", "defensive", "stand"]; 
     543        var stances = ["violent", "aggressive", "passive", "defensive", "standground"]; 
    524544        if (isUnit(entState) && !isAnimal(entState) && !entState.garrisonHolder && stances.length) 
    525545        { 
    526546            setupUnitPanel("Stance", usedPanels, entState, stances, 
  • binaries/data/mods/public/gui/session/utility_functions.js

     
    176176    return dmgArray.join("[font=\"serif-12\"], [/font]"); 
    177177} 
    178178 
    179 function getFormationCellId(formationName) 
    180 { 
    181     switch (formationName) 
    182     { 
    183     case "Loose": 
    184         return 0; 
    185     case "Box": 
    186         return 1; 
    187     case "Column Closed": 
    188         return 2; 
    189     case "Line Closed": 
    190         return 3; 
    191     case "Column Open": 
    192         return 4; 
    193     case "Line Open": 
    194         return 5; 
    195     case "Flank": 
    196         return 6; 
    197     case "Skirmish": 
    198         return 7; 
    199     case "Wedge": 
    200         return 8; 
    201     case "Testudo": 
    202         return 9; 
    203     case "Phalanx": 
    204         return 10; 
    205     case "Syntagma": 
    206         return 11; 
    207     case "Formation12": 
    208         return 12; 
    209     default: 
    210         return -1; 
    211     } 
    212 } 
    213  
    214179function getEntityFormationsList(entState) 
    215180{ 
    216181    var civ = g_Players[entState.player].civ; 
     
    222187{ 
    223188    // TODO: this should come from the civ JSON files instead 
    224189 
    225     var civFormations = ["Loose", "Box", "Column Closed", "Line Closed", "Column Open", "Line Open", "Flank", "Skirmish", "Wedge", "Formation12"]; 
     190    var civFormations = ["Scatter", "Box", "Column Closed", "Line Closed", "Column Open", "Line Open", "Flank", "Skirmish", "Wedge", "Battle Line"]; 
    226191    if (civ == "hele") 
    227192    { 
    228193        civFormations.push("Phalanx"); 
  • binaries/data/mods/public/simulation/components/Formation.js

     
    271271            cols = 6; 
    272272        shape = "opensquare"; 
    273273    } 
    274     else if (this.formationName == "Loose") 
     274    else if (this.formationName == "Scatter") 
    275275    { 
    276276        var width = Math.sqrt(count) * separation * 5; 
    277277 
     
    418418        var cols = Math.ceil(Math.sqrt(count)); 
    419419        shape = "square"; 
    420420    } 
    421     else if (this.formationName == "Formation12") 
     421    else if (this.formationName == "Battle Line") 
    422422    { 
    423423        if (count <= 5) 
    424424            cols = count; 
  • binaries/data/mods/public/simulation/components/GuiInterface.js

     
    362362        return ""; 
    363363}; 
    364364 
     365GuiInterface.prototype.GetFormationRequirements = function(player, data) 
     366{ 
     367    return GetFormationRequirements(data.formationName); 
     368}; 
     369 
    365370GuiInterface.prototype.CanMoveEntsIntoFormation = function(player, data) 
    366371{ 
    367372    return CanMoveEntsIntoFormation(data.ents, data.formationName); 
    368373}; 
    369374 
     375GuiInterface.prototype.IsFormationSelected = function(player, data) 
     376{ 
     377    for each (var ent in data.ents) 
     378    { 
     379        var cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI); 
     380        if (cmpUnitAI) 
     381        { 
     382            // GetLastFormationName is named in a strange way as it (also) is 
     383            // the value of the current formation (see Formation.js LoadFormation) 
     384            if (cmpUnitAI.GetLastFormationName() == data.formationName) 
     385                return true; 
     386        } 
     387    } 
     388    return false; 
     389}; 
     390 
    370391GuiInterface.prototype.IsStanceSelected = function(player, data) 
    371392{ 
    372393    for each (var ent in data.ents) 
     
    783804    "GetTemplateData": 1, 
    784805    "GetNextNotification": 1, 
    785806 
     807    "GetFormationRequirements": 1, 
    786808    "CanMoveEntsIntoFormation": 1, 
     809    "IsFormationSelected": 1, 
    787810    "IsStanceSelected": 1, 
    788811 
    789812    "SetSelectionHighlight": 1, 
  • binaries/data/mods/public/simulation/components/Identity.js

     
    5757        "</element>" + 
    5858    "</optional>" + 
    5959    "<optional>" + 
    60         "<element name='Formations' a:help='Optional list of space-separated formations this unit is allowed to use. Choices include: Loose, Box, ColumnClosed, LineClosed, ColumnOpen, LineOpen, Flank, Skirmish, Wedge, Testudo, Phalanx, Syntagma, Formation12'>" + 
     60        "<element name='Formations' a:help='Optional list of space-separated formations this unit is allowed to use. Choices include: Scatter, Box, ColumnClosed, LineClosed, ColumnOpen, LineOpen, Flank, Skirmish, Wedge, Testudo, Phalanx, Syntagma, BattleLine'>" + 
    6161            "<attribute name='datatype'>" + 
    6262                "<value>tokens</value>" + 
    6363            "</attribute>" + 
  • binaries/data/mods/public/simulation/components/UnitAI.js

     
    99            "<value>aggressive</value>" + 
    1010            "<value>defensive</value>" + 
    1111            "<value>passive</value>" + 
    12             "<value>stand</value>" + 
     12            "<value>standground</value>" + 
    1313        "</choice>" + 
    1414    "</element>" + 
    1515    "<element name='FormationController'>" + 
     
    9898        respondStandGround: false, 
    9999        respondHoldGround: false, 
    100100    }, 
    101     "stand": { 
     101    "standground": { 
    102102        targetVisibleEnemies: true, 
    103103        targetAttackers: true, 
    104104        respondFlee: false, 
     
    25432543    this.SetStance(stance); 
    25442544    // Stop moving if switching to stand ground 
    25452545    // TODO: Also stop existing orders in a sensible way 
    2546     if (stance == "stand") 
     2546    if (stance == "standground") 
    25472547        this.StopMoving(); 
    25482548 
    25492549    // Reset the range query, since the range depends on stance 
  • binaries/data/mods/public/simulation/helpers/Commands.js

     
    584584        } 
    585585        else 
    586586        { 
    587             cmpFormation.LoadFormation("Loose"); 
     587            cmpFormation.LoadFormation("Scatter"); 
    588588        } 
    589589    } 
    590590 
    591591    return nonformedUnitAIs.concat(Engine.QueryInterface(formationEnt, IID_UnitAI)); 
    592592} 
    593593 
     594function GetFormationRequirements(formationName) 
     595{ 
     596    var countRequired = 1; 
     597    var classesRequired; 
     598    switch(formationName) 
     599    { 
     600    case "Scatter": 
     601    case "Column Closed": 
     602    case "Line Closed": 
     603    case "Column Open": 
     604    case "Line Open": 
     605    case "Battle Line": 
     606        break; 
     607    case "Box": 
     608        countRequired = 4; 
     609        break; 
     610    case "Flank": 
     611        countRequired = 8; 
     612        break; 
     613    case "Skirmish": 
     614        classesRequired = ["Ranged"]; 
     615        break; 
     616    case "Wedge": 
     617        countRequired = 3; 
     618        classesRequired = ["Cavalry"]; 
     619        break; 
     620    case "Phalanx": 
     621        countRequired = 10; 
     622        classesRequired = ["Melee", "Infantry"]; 
     623        break; 
     624    case "Syntagma": 
     625        countRequired = 9; 
     626        classesRequired = ["Melee", "Infantry"]; // TODO: pike only 
     627        break; 
     628    case "Testudo": 
     629        countRequired = 9; 
     630        classesRequired = ["Melee", "Infantry"]; 
     631        break; 
     632    default: 
     633        // We encountered a unknown formation -> warn the user 
     634        warn("Commands.js: GetFormationRequirements: unknown formation: " + formationName); 
     635        return false; 
     636    } 
     637    return { "count": countRequired, "classesRequired": classesRequired }; 
     638} 
     639 
     640 
    594641function CanMoveEntsIntoFormation(ents, formationName) 
    595642{ 
    596643    var count = ents.length; 
    597     var classesRequired; 
    598644 
    599645    // TODO: should check the player's civ is allowed to use this formation 
    600646 
    601     if (formationName == "Loose") 
    602     { 
    603         return true; 
    604     } 
    605     else if (formationName == "Box") 
    606     { 
    607         if (count < 4) 
    608             return false; 
    609     } 
    610     else if (formationName == "Column Closed") 
    611     { 
    612     } 
    613     else if (formationName == "Line Closed") 
    614     { 
    615     } 
    616     else if (formationName == "Column Open") 
    617     { 
    618     } 
    619     else if (formationName == "Line Open") 
    620     { 
    621     } 
    622     else if (formationName == "Flank") 
    623     { 
    624         if (count < 8) 
    625             return false; 
    626     } 
    627     else if (formationName == "Skirmish") 
    628     { 
    629         classesRequired = ["Ranged"]; 
    630     } 
    631     else if (formationName == "Wedge") 
    632     { 
    633         if (count < 3) 
    634             return false; 
    635         classesRequired = ["Cavalry"]; 
    636     } 
    637     else if (formationName == "Formation12") 
    638     { 
    639     } 
    640     else if (formationName == "Phalanx") 
    641     { 
    642         if (count < 10) 
    643             return false; 
    644         classesRequired = ["Melee", "Infantry"]; 
    645     } 
    646     else if (formationName == "Syntagma") 
    647     { 
    648         if (count < 9) 
    649             return false; 
    650         classesRequired = ["Melee", "Infantry"]; // TODO: pike only 
    651     } 
    652     else if (formationName == "Testudo") 
    653     { 
    654         if (count < 9) 
    655             return false; 
    656         classesRequired = ["Melee", "Infantry"]; 
    657     } 
    658     else 
    659     { 
     647    var requirements = GetFormationRequirements(formationName); 
     648    if (!requirements) 
     649        return false; 
     650     
     651    if (count < requirements.count) 
    660652        return false; 
    661     } 
    662653 
    663     var looseOnlyUnits = true; 
     654    var scatterOnlyUnits = true; 
    664655    for each (var ent in ents) 
    665656    { 
    666657        var cmpIdentity = Engine.QueryInterface(ent, IID_Identity); 
    667658        if (cmpIdentity) 
    668659        { 
    669660            var classes = cmpIdentity.GetClassesList(); 
    670             if (looseOnlyUnits && (classes.indexOf("Worker") == -1 || classes.indexOf("Support") == -1)) 
    671                 looseOnlyUnits = false; 
    672             for each (var classRequired in classesRequired) 
     661            if (scatterOnlyUnits && (classes.indexOf("Worker") == -1 || classes.indexOf("Support") == -1)) 
     662                scatterOnlyUnits = false; 
     663            for each (var classRequired in requirements.classesRequired) 
    673664            { 
    674665                if (classes.indexOf(classRequired) == -1) 
    675666                { 
     
    679670        } 
    680671    } 
    681672 
    682     if (looseOnlyUnits) 
     673    if (scatterOnlyUnits) 
    683674        return false; 
    684675 
    685676    return true; 
     
    703694    return entities.filter(function(ent) { return CanControlUnit(ent, player, controlAll);} ); 
    704695} 
    705696 
     697Engine.RegisterGlobal("GetFormationRequirements", GetFormationRequirements); 
    706698Engine.RegisterGlobal("CanMoveEntsIntoFormation", CanMoveEntsIntoFormation); 
    707699Engine.RegisterGlobal("ProcessCommand", ProcessCommand); 
  • binaries/data/mods/public/simulation/templates/template_unit.xml

     
    3737    <GenericName>Unit</GenericName> 
    3838    <Classes datatype="tokens">Unit ConquestCritical</Classes> 
    3939    <Formations datatype="tokens"> 
    40       Loose 
     40      Scatter 
    4141      Box 
    4242      ColumnClosed 
    4343      LineClosed 
     
    4949      Testudo 
    5050      Phalanx 
    5151      Syntagma 
    52       Formation12 
     52      BattleLine 
    5353    </Formations> 
    5454  </Identity> 
    5555  <Looter/>