Ticket #1190: #1190-2012-03-16.patch
| File #1190-2012-03-16.patch, 15.6 KB (added by leper, 14 months ago) |
|---|
-
binaries/data/mods/public/gui/session/session.xml
593 593 <!-- Stats --> 594 594 <object size="8 36 50%-48 100%" name="statsArea" type="image"> 595 595 <!-- Attack icon --> 596 <object hidden="true" size="0 0 48 48" type="image" name="attackIcon" sprite="s nIconSheetStance" 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 598 598 <!-- Armour icon "0 48 48 96"--> 599 <object size="0 0 48 48" type="image" name="armourIcon" sprite="s nIconSheetStance" 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"/> 600 600 601 601 <!-- Resource carrying icon/counter --> 602 602 <object size="0 40 48 88" type="image" name="resourceCarryingIcon" style="resourceIcon"/> -
binaries/data/mods/public/gui/session/sprites.xml
18 18 </sprite> 19 19 20 20 <!-- ================================ ================================ --> 21 <!-- Unit Command Icons -->22 <!-- ================================ ================================ -->23 <sprite name="formation">24 <image25 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 <image33 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 <image41 texture="session/icons/sheets/commands.png"42 cell_size="32 32"43 size="0 0 100% 100%"44 />45 </sprite>46 47 <!-- ================================ ================================ -->48 21 <!-- Menu --> 49 22 <!-- ================================ ================================ --> 50 23 <sprite name="menuButton"> -
binaries/data/mods/public/gui/session/unit_commands.js
304 304 // Get icon image 305 305 if (guiName == "Formation") 306 306 { 307 icon.cell_id = getFormationCellId(item);308 307 var formationOk = Engine.GuiInterfaceCall("CanMoveEntsIntoFormation", { 309 308 "ents": g_Selection.toList(), 310 309 "formationName": item 311 310 }); 312 311 313 icon.enabled = formationOk;314 312 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 } 325 348 else if (guiName == "Stance") 326 349 { 327 350 var stanceSelected = Engine.GuiInterfaceCall("IsStanceSelected", { … … 329 352 "stance": item 330 353 }); 331 354 332 icon.cell_id = i;333 355 if (stanceSelected) 334 icon.sprite = "s nIconSheetStanceButton";356 icon.sprite = "stretched:session/icons/single/stance-"+item+"-select.png"; 335 357 else 336 icon.sprite = "s nIconSheetStanceButtonDisabled";358 icon.sprite = "stretched:session/icons/single/stance-"+item+".png"; 337 359 } 338 360 else if (guiName == "Command") 339 361 { 340 //icon.cell_id = i;341 //icon.cell_id = getCommandCellId(item);342 362 icon.sprite = "stretched:session/icons/single/" + item.icon; 343 363 344 364 } … … 520 540 521 541 // TODO: probably should load the stance list from a data file, 522 542 // 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"]; 524 544 if (isUnit(entState) && !isAnimal(entState) && !entState.garrisonHolder && stances.length) 525 545 { 526 546 setupUnitPanel("Stance", usedPanels, entState, stances, -
binaries/data/mods/public/gui/session/utility_functions.js
176 176 return dmgArray.join("[font=\"serif-12\"], [/font]"); 177 177 } 178 178 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 214 179 function getEntityFormationsList(entState) 215 180 { 216 181 var civ = g_Players[entState.player].civ; … … 222 187 { 223 188 // TODO: this should come from the civ JSON files instead 224 189 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"]; 226 191 if (civ == "hele") 227 192 { 228 193 civFormations.push("Phalanx"); -
binaries/data/mods/public/simulation/components/Formation.js
271 271 cols = 6; 272 272 shape = "opensquare"; 273 273 } 274 else if (this.formationName == " Loose")274 else if (this.formationName == "Scatter") 275 275 { 276 276 var width = Math.sqrt(count) * separation * 5; 277 277 … … 418 418 var cols = Math.ceil(Math.sqrt(count)); 419 419 shape = "square"; 420 420 } 421 else if (this.formationName == " Formation12")421 else if (this.formationName == "Battle Line") 422 422 { 423 423 if (count <= 5) 424 424 cols = count; -
binaries/data/mods/public/simulation/components/GuiInterface.js
362 362 return ""; 363 363 }; 364 364 365 GuiInterface.prototype.GetFormationRequirements = function(player, data) 366 { 367 return GetFormationRequirements(data.formationName); 368 }; 369 365 370 GuiInterface.prototype.CanMoveEntsIntoFormation = function(player, data) 366 371 { 367 372 return CanMoveEntsIntoFormation(data.ents, data.formationName); 368 373 }; 369 374 375 GuiInterface.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 370 391 GuiInterface.prototype.IsStanceSelected = function(player, data) 371 392 { 372 393 for each (var ent in data.ents) … … 783 804 "GetTemplateData": 1, 784 805 "GetNextNotification": 1, 785 806 807 "GetFormationRequirements": 1, 786 808 "CanMoveEntsIntoFormation": 1, 809 "IsFormationSelected": 1, 787 810 "IsStanceSelected": 1, 788 811 789 812 "SetSelectionHighlight": 1, -
binaries/data/mods/public/simulation/components/Identity.js
57 57 "</element>" + 58 58 "</optional>" + 59 59 "<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'>" + 61 61 "<attribute name='datatype'>" + 62 62 "<value>tokens</value>" + 63 63 "</attribute>" + -
binaries/data/mods/public/simulation/components/UnitAI.js
9 9 "<value>aggressive</value>" + 10 10 "<value>defensive</value>" + 11 11 "<value>passive</value>" + 12 "<value>stand </value>" +12 "<value>standground</value>" + 13 13 "</choice>" + 14 14 "</element>" + 15 15 "<element name='FormationController'>" + … … 98 98 respondStandGround: false, 99 99 respondHoldGround: false, 100 100 }, 101 "stand ": {101 "standground": { 102 102 targetVisibleEnemies: true, 103 103 targetAttackers: true, 104 104 respondFlee: false, … … 2543 2543 this.SetStance(stance); 2544 2544 // Stop moving if switching to stand ground 2545 2545 // TODO: Also stop existing orders in a sensible way 2546 if (stance == "stand ")2546 if (stance == "standground") 2547 2547 this.StopMoving(); 2548 2548 2549 2549 // Reset the range query, since the range depends on stance -
binaries/data/mods/public/simulation/helpers/Commands.js
584 584 } 585 585 else 586 586 { 587 cmpFormation.LoadFormation(" Loose");587 cmpFormation.LoadFormation("Scatter"); 588 588 } 589 589 } 590 590 591 591 return nonformedUnitAIs.concat(Engine.QueryInterface(formationEnt, IID_UnitAI)); 592 592 } 593 593 594 function 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 594 641 function CanMoveEntsIntoFormation(ents, formationName) 595 642 { 596 643 var count = ents.length; 597 var classesRequired;598 644 599 645 // TODO: should check the player's civ is allowed to use this formation 600 646 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) 660 652 return false; 661 }662 653 663 var looseOnlyUnits = true;654 var scatterOnlyUnits = true; 664 655 for each (var ent in ents) 665 656 { 666 657 var cmpIdentity = Engine.QueryInterface(ent, IID_Identity); 667 658 if (cmpIdentity) 668 659 { 669 660 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) 673 664 { 674 665 if (classes.indexOf(classRequired) == -1) 675 666 { … … 679 670 } 680 671 } 681 672 682 if ( looseOnlyUnits)673 if (scatterOnlyUnits) 683 674 return false; 684 675 685 676 return true; … … 703 694 return entities.filter(function(ent) { return CanControlUnit(ent, player, controlAll);} ); 704 695 } 705 696 697 Engine.RegisterGlobal("GetFormationRequirements", GetFormationRequirements); 706 698 Engine.RegisterGlobal("CanMoveEntsIntoFormation", CanMoveEntsIntoFormation); 707 699 Engine.RegisterGlobal("ProcessCommand", ProcessCommand); -
binaries/data/mods/public/simulation/templates/template_unit.xml
37 37 <GenericName>Unit</GenericName> 38 38 <Classes datatype="tokens">Unit ConquestCritical</Classes> 39 39 <Formations datatype="tokens"> 40 Loose40 Scatter 41 41 Box 42 42 ColumnClosed 43 43 LineClosed … … 49 49 Testudo 50 50 Phalanx 51 51 Syntagma 52 Formation1252 BattleLine 53 53 </Formations> 54 54 </Identity> 55 55 <Looter/>
