Fixed UCP toggles, added copy-paste control for plugins

This commit is contained in:
PeekabooSteam
2023-11-22 17:15:23 +00:00
parent 65edce855b
commit 1022fc2f0c
7 changed files with 156 additions and 48 deletions

View File

@@ -1,4 +1,6 @@
export interface ContextInterface {
allowUnitCopying?: boolean;
allowUnitPasting?: boolean;
useSpawnMenu?: boolean;
useUnitControlPanel?: boolean;
useUnitInfoPanel?: boolean;
@@ -6,16 +8,28 @@ export interface ContextInterface {
export class Context {
#allowUnitCopying:boolean;
#allowUnitPasting:boolean;
#useSpawnMenu:boolean;
#useUnitControlPanel:boolean;
#useUnitInfoPanel:boolean;
constructor( config:ContextInterface ) {
this.#allowUnitCopying = ( config.allowUnitCopying !== false );
this.#allowUnitPasting = ( config.allowUnitPasting !== false );
this.#useSpawnMenu = ( config.useSpawnMenu !== false );
this.#useUnitControlPanel = ( config.useUnitControlPanel !== false );
this.#useUnitInfoPanel = ( config.useUnitInfoPanel !== false );
}
getAllowUnitCopying() {
return this.#allowUnitCopying;
}
getAllowUnitPasting() {
return this.#allowUnitPasting;
}
getUseSpawnMenu() {
return this.#useSpawnMenu;
}

View File

@@ -1001,6 +1001,9 @@ export class UnitsManager {
*
*/
copy(units: Unit[] | null = null) {
if ( !getApp().getContextManager().getCurrentContext().getAllowUnitCopying() )
return;
if (units === null)
units = this.getSelectedUnits({ excludeHumans: true });
@@ -1018,6 +1021,9 @@ export class UnitsManager {
* @returns True if units were pasted successfully
*/
paste() {
if ( !getApp().getContextManager().getCurrentContext().getAllowUnitPasting() )
return;
let spawnPoints = 0;
/* If spawns are restricted, check that the user has the necessary spawn points */