private void ForceSelectPlm(int index) { if (ActiveRoomState?.MyPlmSet != null && index >= 0 && index < ActiveRoomState.MyPlmSet.PlmCount) { PlmIndex = index; ActivePlm = ActiveRoomState.MyPlmSet.Plms [PlmIndex]; if (ActivePlm.MyPlmType?.Index == 0) { ActivePlm.MyPlmType.PlmID = ActivePlm.PlmID; } ForceSelectPlmType(ActivePlm.MyPlmType?.Index ?? IndexNone); if (ActivePlm.MyScrollPlmData != null) { int i = ScrollDatas.FindIndex(x => x == ActivePlm.MyScrollPlmData); ForceSelectScrollData(i); } else { ForceSelectScrollData(-1); } } else { PlmIndex = IndexNone; ActivePlm = null; ForceSelectPlmType(IndexNone); } }
// Constructor, copy from existing PLM. public Plm(Plm source) : base() { PlmID = source.PlmID; PosX = source.PosX; PosY = source.PosY; MainVariable = source.MainVariable; MyPlmType = source.MyPlmType; MyScrollPlmData = null; }
//---------------------------------------------------------------------------------------- private bool ForceAddPlm(int col, int row) { if (ActivePlmSet == null || ActivePlmType == null) { return(false); } Plm newPlm = new Plm(); newPlm.SetDefault(); newPlm.PlmID = ActivePlmType.PlmID; newPlm.MyPlmType = ActivePlmType; newPlm.PosX = (byte)col; newPlm.PosY = (byte)row; ActivePlmSet.Plms.Add(newPlm); ChangesMade = true; return(true); }
// Move selected PLM down in list. public void MovePlmDown() { if (ActivePlmSet == null || ActivePlm == null) { return; } if (PlmIndex + 1 < ActivePlmSet.PlmCount) { Plm temp = ActivePlmSet.Plms [PlmIndex]; ActivePlmSet.Plms [PlmIndex] = ActivePlmSet.Plms [PlmIndex + 1]; ActivePlmSet.Plms [PlmIndex + 1] = temp; PlmIndex++; HandlingSelection = true; PlmListChanged?.Invoke(this, new ListLoadEventArgs(PlmIndex)); HandlingSelection = false; ChangesMade = true; } }
public ActiveItems(Project p) { ActiveArea = p.AreaIndex; ActiveRoom = p.ActiveRoom; ActiveRoomState = p.ActiveRoomState; ActiveTileSet = p.ActiveTileSet; ActiveDoor = p.ActiveDoor; ActiveLevelData = p.ActiveLevelData; ActivePlm = p.ActivePlm; ActivePlmType = p.ActivePlmType; ActiveEnemy = p.ActiveEnemy; ActiveEnemyGfx = p.ActiveEnemyGfx; ActiveEnemyType = p.ActiveEnemyType; ActiveScrollData = p.ActiveScrollData; ActiveScrollColor = p.ActiveScrollColor; ActiveFx = p.ActiveFx; ActiveFxData = p.ActiveFxData; ActiveBackground = p.ActiveBackground; }
// Select PLM at given tile position (col, row), updates row, col, width & height to // exact position and size of PLM. public bool SelectPlmAt(int col, int row) { if (ActivePlmSet == null) { return(false); } for (int index = 0; index < ActivePlmSet.PlmCount; index++) { Plm p = ActivePlmSet.Plms [index]; int width = p.MyPlmType?.Graphics.Width / 16 ?? 0; int height = p.MyPlmType?.Graphics.Height / 16 ?? 0; if (col >= p.PosX && col < p.PosX + width && row >= p.PosY && row < p.PosY + height) { HandlingSelection = true; var a = new ActiveItems(this); ForceSelectPlm(index); RaiseChangeEvents(a); HandlingSelection = false; return(true); } } return(false); }