Ticket #2179: moveFormation.diff
File moveFormation.diff, 2.9 KB (added by , 11 years ago) |
---|
-
binaries/data/mods/public/gui/session/unit_commands.js
38 38 // Indexes of resources to sell and buy on barter panel 39 39 var g_barterSell = 0; 40 40 41 // Cache a few quantities which depend on selection 42 var g_canMoveIntoFormation = {}; 43 41 44 // Lay out a row of centered buttons (does not work inside a loop like the other function) 42 45 function layoutButtonRowCentered(rowNumber, guiName, startIndex, endIndex, width) 43 46 { … … 572 575 // Get icon image 573 576 if (guiName == FORMATION) 574 577 { 575 var formationOk = Engine.GuiInterfaceCall("CanMoveEntsIntoFormation", { 576 "ents": g_Selection.toList(), 577 "formationName": item 578 }); 579 578 var formationOk = canMoveEntsIntoFormation(item); 580 579 var grayscale = ""; 581 580 button.enabled = formationOk; 582 581 if (!formationOk) … … 1288 1287 removeDupes(buildableEnts); 1289 1288 return buildableEnts; 1290 1289 } 1290 1291 // Check if the selection can move into formation, and cache the result 1292 function canMoveEntsIntoFormation(formationName) 1293 { 1294 if (!(formationName in g_canMoveIntoFormation)) 1295 { 1296 g_canMoveIntoFormation[formationName] = Engine.GuiInterfaceCall("CanMoveEntsIntoFormation", { 1297 "ents": g_Selection.toList(), 1298 "formationName": formationName 1299 }); 1300 } 1301 return g_canMoveIntoFormation[formationName]; 1302 } 1303 1304 // Reset cached quantities which depend on selection 1305 function onSelectionChanged() 1306 { 1307 g_canMoveIntoFormation = {}; 1308 } 1309 Pas de retour chariot à la fin du fichier -
binaries/data/mods/public/gui/session/session.js
312 312 // simulation state and the current selection). 313 313 if (g_Selection.dirty) 314 314 { 315 // reset cached quantities which depend on selection (in unit_commands.js) 316 onSelectionChanged(); 317 315 318 onSimulationUpdate(); 316 319 317 320 // Display rally points for selected buildings -
binaries/data/mods/public/simulation/helpers/Commands.js
1280 1280 formationName = formationName.replace(/\s+/g,""); 1281 1281 1282 1282 var count = 0; 1283 if (requirements.count == 0) 1284 return true; 1283 1285 var reqClasses = requirements.classesRequired || []; 1284 1286 for each (var ent in ents) 1285 1287 { … … 1292 1294 return false; 1293 1295 1294 1296 count++; 1297 if (count == requirements.count) 1298 return true; 1295 1299 } 1296 1300 1297 if (count < requirements.count) 1298 return false; 1299 1300 return true; 1301 return false; 1301 1302 } 1302 1303 1303 1304 /**