private void AddToExistingLayerChange(LayerChange layerChange, LayerChange oldValues) { foreach (var change in layerChange.PixelChanges.ChangedPixels) { if (LastChanges[layerChange.LayerIndex].PixelChanges.ChangedPixels.ContainsKey(change.Key)) { continue; } else { LastChanges[layerChange.LayerIndex].PixelChanges.ChangedPixels.Add(change.Key, change.Value); } } foreach (var change in oldValues.PixelChanges.ChangedPixels) { if (LastOldValues[layerChange.LayerIndex].PixelChanges.ChangedPixels.ContainsKey(change.Key)) { continue; } else { LastOldValues[layerChange.LayerIndex].PixelChanges.ChangedPixels.Add(change.Key, change.Value); } } }
void changeLayer() //GameScene 넘어가기 전 무기 Layer 변경: Touchable -> weapon { layerChange = GM.gameObject.GetComponent <LayerChange>(); s_itemSpawn = GameObject.Find("itemSpawn").GetComponent <ItemSpawn>(); int itemSpawnLens = s_itemSpawn.itemSpawn.Length; GameObject[] Items = GameObject.FindObjectsOfType(typeof(GameObject)) as GameObject[]; int len = Items.Length; touchableItems = new GameObject[itemSpawnLens]; int idx = 0; for (int i = 0; i < len; i++) { if (Items[i].layer == (int)eLAYER.TOUCHABLE) { touchableItems[idx] = Items[i]; if (touchableItems[idx].tag == "weapon") { layerChange.InputWeaponArr(touchableItems[idx]); } idx++; } } }
private void UseTool(List <Coordinates> mouseMoveCords, BitmapOperationTool tool, Color color) { if (Keyboard.IsKeyDown(Key.LeftShift) && !MouseCordsNotInLine(mouseMoveCords)) { mouseMoveCords = GetSquareCoordiantes(mouseMoveCords); } if (!tool.RequiresPreviewLayer) { LayerChange[] modifiedLayers = tool.Use(Manager.ActiveLayer, mouseMoveCords.ToArray(), color); LayerChange[] oldPixelsValues = new LayerChange[modifiedLayers.Length]; for (int i = 0; i < modifiedLayers.Length; i++) { Layer layer = Manager.ActiveDocument.Layers.First(x => x.LayerGuid == modifiedLayers[i].LayerGuid); oldPixelsValues[i] = ApplyToLayer(layer, modifiedLayers[i]); BitmapChanged?.Invoke(this, new BitmapChangedEventArgs( modifiedLayers[i].PixelChanges, oldPixelsValues[i].PixelChanges, modifiedLayers[i].LayerGuid)); } } else { UseToolOnPreviewLayer(mouseMoveCords, tool.ClearPreviewLayerOnEachIteration); } }
public override LayerChange[] Use(Layer layer, Coordinates[] mouseMove, Color color) { LayerChange[] result = new LayerChange[affectedLayers.Length]; var end = mouseMove[0]; var lastSelection = currentSelection.ToArray(); for (int i = 0; i < affectedLayers.Length; i++) { if (currentSelection.Length > 0) { endPixelColors = BitmapUtils.GetPixelsForSelection(affectedLayers, currentSelection); var changes = MoveSelection(affectedLayers[i], mouseMove); ClearSelectedPixels(affectedLayers[i], lastSelection); changes = RemoveTransparentPixels(changes); result[i] = new LayerChange(changes, affectedLayers[i]); } else { var vector = Transform.GetTranslation(lastMouseMove, end); affectedLayers[i].Offset = new Thickness(affectedLayers[i].OffsetX + vector.X, affectedLayers[i].OffsetY + vector.Y, 0, 0); result[i] = new LayerChange(BitmapPixelChanges.Empty, affectedLayers[i]); } } lastMouseMove = end; return(result); }
/// <summary> /// Returns all changes and deletes them from controller. /// </summary> /// <returns>Tuple array with new changes and old values.</returns> public Tuple <LayerChange, LayerChange>[] PopChanges() { // Maybe replace Tuple with custom data type if (LastChanges == null) { return(null); } Tuple <LayerChange, LayerChange>[] result = new Tuple <LayerChange, LayerChange> [LastChanges.Count]; int i = 0; foreach (KeyValuePair <Guid, LayerChange> change in LastChanges) { Dictionary <Position.Coordinates, System.Windows.Media.Color> pixelChanges = change.Value.PixelChanges.ChangedPixels.ToDictionary(entry => entry.Key, entry => entry.Value); Dictionary <Position.Coordinates, System.Windows.Media.Color> oldValues = LastOldValues[change.Key].PixelChanges.ChangedPixels .ToDictionary(entry => entry.Key, entry => entry.Value); LayerChange tmp = new LayerChange(new BitmapPixelChanges(pixelChanges), change.Key); LayerChange oldValuesTmp = new LayerChange(new BitmapPixelChanges(oldValues), change.Key); result[i] = new Tuple <LayerChange, LayerChange>(tmp, oldValuesTmp); i++; } LastChanges = null; LastOldValues = null; return(result); }
private void AddToExistingLayerChange(LayerChange layerChange, LayerChange oldValues) { foreach (KeyValuePair <Position.Coordinates, System.Windows.Media.Color> change in layerChange.PixelChanges.ChangedPixels) { if (LastChanges[layerChange.LayerGuid].PixelChanges.ChangedPixels.ContainsKey(change.Key)) { continue; } else { LastChanges[layerChange.LayerGuid].PixelChanges.ChangedPixels.Add(change.Key, change.Value); } } foreach (KeyValuePair <Position.Coordinates, System.Windows.Media.Color> change in oldValues.PixelChanges.ChangedPixels) { if (LastOldValues[layerChange.LayerGuid].PixelChanges.ChangedPixels.ContainsKey(change.Key)) { continue; } else { LastOldValues[layerChange.LayerGuid].PixelChanges.ChangedPixels.Add(change.Key, change.Value); } } }
void Update() { if (!IsLayerChange) //무기아이템 GameScene으로 넘어갈 때 weapon layer로 변경 { IsLayerChange = true; layerChange = GM.gameObject.GetComponent <LayerChange>(); ItemSpawn1 s_itemSpawn = GameObject.Find("itemSpawn").GetComponent <ItemSpawn1>(); int itemSpawnLens = s_itemSpawn.itemSpawn.Length; GameObject[] Items = GameObject.FindObjectsOfType(typeof(GameObject)) as GameObject[]; int len = Items.Length; touchableItems = new GameObject[itemSpawnLens]; int idx = 0; for (int i = 0; i < len; i++) { if (Items[i].layer == (int)eLAYER.TOUCHABLE) { touchableItems[idx] = Items[i]; if (touchableItems[idx].tag == "weapon") { layerChange.InputWeaponArr(touchableItems[idx]); } idx++; } } } if (Input.GetMouseButtonDown(0) && highlightBox.activeSelf == true) { TouchItem(); } }
void changeLayerToWeapon() { LayerChange LC = GetComponent <LayerChange>(); for (int i = 0; i < 4; i++) { LC.OutputWeapon(i).layer = (int)eLAYER.WEAPON; } }
//================================================================================ // ILayerChangeEventListener methods //================================================================================ public void OnChangeEvent(LayerChangeEvent @event) { //You can choose to handle changes to conversations or messages however you'd like: IList <LayerChange> changes = @event.Changes; for (int i = 0; i < changes.Count; i++) { LayerChange change = changes[i]; if (change.ObjectType == LayerObjectType.Conversation) { Conversation conversation = change.GetObject <Conversation>(); Log.Verbose(TAG, "Conversation " + conversation.Id + " attribute " + change.AttributeName + " was changed from " + change.OldValue + " to " + change.NewValue); if (LayerChange.Type.Insert == change.ChangeType) { } else if (LayerChange.Type.Update == change.ChangeType) { } else if (LayerChange.Type.Delete == change.ChangeType) { } } else if (change.ObjectType == LayerObjectType.Message) { IMessage message = change.GetObject <IMessage>(); Log.Verbose(TAG, "Message " + message.Id + " attribute " + change .AttributeName + " was changed from " + change.OldValue + " to " + change.NewValue); if (LayerChange.Type.Insert == change.ChangeType) { } else if (LayerChange.Type.Update == change.ChangeType) { } else if (LayerChange.Type.Delete == change.ChangeType) { } } } //If we don't have an active conversation, grab the oldest one if (activeConversation == null) { activeConversation = _GetConversation(); } //If anything in the conversation changes, re-draw it in the GUI _DrawConversation(); //Check the meta-data for color changes _GetTopBarMetaData(); }
private LayerChange ApplyToLayer(Layer layer, LayerChange change) { layer.DynamicResize(change.PixelChanges); var oldPixelsValues = new LayerChange( GetOldPixelsValues(change.PixelChanges.ChangedPixels.Keys.ToArray()), change.LayerIndex); layer.SetPixels(change.PixelChanges, false); return(oldPixelsValues); }
public void DeletePixels(Layer[] layers, Coordinates[] pixels) { var changes = BitmapPixelChanges.FromSingleColoredArray(pixels, Color.FromArgb(0, 0, 0, 0)); var oldValues = BitmapUtils.GetPixelsForSelection(layers, pixels); LayerChange[] old = new LayerChange[layers.Length]; LayerChange[] newChange = new LayerChange[layers.Length]; for (int i = 0; i < layers.Length; i++) { old[i] = new LayerChange( BitmapPixelChanges.FromArrays(pixels, oldValues[layers[i]]), i); newChange[i] = new LayerChange(changes, i); layers[i].SetPixels(changes); } UndoManager.AddUndoChange(new Change("UndoChanges", old, newChange, "Deleted pixels")); }
private void UseTool(List <Coordinates> mouseMoveCords, BitmapOperationTool tool, Color color) { if (sizeSetting == null) { sizeSetting = tool.Toolbar.GetSetting <SizeSetting>("ToolSize"); } int thickness = sizeSetting != null ? sizeSetting.Value : 1; bool shiftDown = Keyboard.IsKeyDown(Key.LeftShift); if (shiftDown && tool.UsesShift) { bool mouseInLine = MouseCordsNotInLine(mouseMoveCords, thickness); if (!mouseInLine) { mouseMoveCords = GetSquareCoordiantes(mouseMoveCords); } else { mouseMoveCords = GetLineCoordinates(mouseMoveCords, thickness); } } if (!tool.RequiresPreviewLayer) { LayerChange[] modifiedLayers = tool.Use(Manager.ActiveLayer, mouseMoveCords, color); LayerChange[] oldPixelsValues = new LayerChange[modifiedLayers.Length]; for (int i = 0; i < modifiedLayers.Length; i++) { Layer layer = Manager.ActiveDocument.Layers.First(x => x.LayerGuid == modifiedLayers[i].LayerGuid); oldPixelsValues[i] = ApplyToLayer(layer, modifiedLayers[i]); BitmapChanged?.Invoke(this, new BitmapChangedEventArgs( modifiedLayers[i].PixelChanges, oldPixelsValues[i].PixelChanges, modifiedLayers[i].LayerGuid)); } } else { UseToolOnPreviewLayer(mouseMoveCords, tool.ClearPreviewLayerOnEachIteration); } }
public override LayerChange[] Use(Layer layer, List <Coordinates> coordinates, Color color) { int toolSize = Toolbar.GetSetting <SizeSetting>("ToolSize").Value; float correctionFactor = Toolbar.GetSetting <FloatSetting>("CorrectionFactor").Value; Mode = Toolbar.GetEnumSetting <BrightnessMode>("BrightnessMode").Value; LayerChange[] layersChanges = new LayerChange[1]; if (Keyboard.IsKeyDown(Key.LeftCtrl)) { layersChanges[0] = new LayerChange(ChangeBrightness(layer, coordinates[0], toolSize, -correctionFactor), layer); } else { layersChanges[0] = new LayerChange(ChangeBrightness(layer, coordinates[0], toolSize, correctionFactor), layer); } return(layersChanges); }
public override LayerChange[] Use(Layer layer, Coordinates[] coordinates, Color color) { int toolSize = Toolbar.GetSetting <SizeSetting>("ToolSize").Value; float correctionFactor = Toolbar.GetSetting <FloatSetting>("CorrectionFactor").Value; Enum.TryParse((Toolbar.GetSetting <DropdownSetting>("BrightnessMode")?.Value as ComboBoxItem)?.Content as string, out BrightnessMode mode); Mode = mode; LayerChange[] layersChanges = new LayerChange[1]; if (Keyboard.IsKeyDown(Key.LeftCtrl)) { layersChanges[0] = new LayerChange(ChangeBrightness(layer, coordinates[0], toolSize, -correctionFactor), layer); } else { layersChanges[0] = new LayerChange(ChangeBrightness(layer, coordinates[0], toolSize, correctionFactor), layer); } return(layersChanges); }
/// <summary> /// Adds layer changes to controller. /// </summary> /// <param name="changes">New changes.</param> /// <param name="oldValues">Old values of changes.</param> public void AddChanges(LayerChange changes, LayerChange oldValues) { if (changes.PixelChanges.ChangedPixels.Count > 0) { if (LastChanges == null) { LastChanges = new Dictionary <Guid, LayerChange> { { changes.LayerGuid, changes } }; LastOldValues = new Dictionary <Guid, LayerChange> { { oldValues.LayerGuid, oldValues } }; } else if (LastChanges.ContainsKey(changes.LayerGuid)) { AddToExistingLayerChange(changes, oldValues); } else { AddNewLayerChange(changes, oldValues); } } }
private LayerChange[] ApplyToLayers(Layer[] layers, LayerChange[] changes) { LayerChange[] oldPixelValues = new LayerChange[changes.Length]; for (int i = 0; i < layers.Length; i++) { Layer layer = layers[i]; LayerChange change = changes.First(x => x.LayerGuid == layer.LayerGuid); layer.DynamicResize(change.PixelChanges); oldPixelValues[i] = new LayerChange( GetOldPixelsValues(change.PixelChanges.ChangedPixels.Keys.ToArray()), change.LayerGuid); } for (int i = 0; i < layers.Length; i++) { Layer layer = layers[i]; LayerChange change = changes.First(x => x.LayerGuid == layer.LayerGuid); layer.SetPixels(change.PixelChanges, false); } return(oldPixelValues); }
public void DeletePixels(Layer[] layers, Coordinates[] pixels) { if (Manager.ActiveDocument == null) { return; } BitmapPixelChanges changes = BitmapPixelChanges.FromSingleColoredArray(pixels, Color.FromArgb(0, 0, 0, 0)); Dictionary <Guid, Color[]> oldValues = BitmapUtils.GetPixelsForSelection(layers, pixels); LayerChange[] old = new LayerChange[layers.Length]; LayerChange[] newChange = new LayerChange[layers.Length]; for (int i = 0; i < layers.Length; i++) { Guid guid = layers[i].LayerGuid; old[i] = new LayerChange( BitmapPixelChanges.FromArrays(pixels, oldValues[layers[i].LayerGuid]), guid); newChange[i] = new LayerChange(changes, guid); layers[i].SetPixels(changes); } Manager.ActiveDocument.UndoManager.AddUndoChange(new Change("UndoChanges", old, newChange, "Deleted pixels")); }
private LayerChange ApplyToLayer(Layer layer, LayerChange change) { return(ApplyToLayers(new Layer[] { layer }, new LayerChange[] { change })[0]); }
private void AddNewLayerChange(LayerChange changes, LayerChange oldValues) { LastChanges[changes.LayerGuid] = changes; LastOldValues[changes.LayerGuid] = oldValues; }
public ChangeMapAppearance(bool isColorModified, bool isFontModified, bool isSizeModified, bool doesAreaChanged) { // background color of the map mOldBackGroundColor = Map.Instance.BackgroundColor; mNewBackGroundColor = BlueBrick.Properties.Settings.Default.DefaultBackgroundColor; // and the other modification to the layer bool doesGridChanged = isColorModified || isFontModified || isSizeModified; foreach (Layer layer in Map.Instance.LayerList) { if (doesGridChanged) { LayerGrid gridLayer = layer as LayerGrid; if (gridLayer != null) { // create a copy of the edited layer to hold the old data LayerGrid oldLayerData = new LayerGrid(); oldLayerData.CopyOptionsFrom(gridLayer); // create a new layer to store the new data LayerGrid newLayerData = new LayerGrid(); newLayerData.CopyOptionsFrom(gridLayer); // and change only the grid colors if (isColorModified) { newLayerData.GridColor = BlueBrick.Properties.Settings.Default.DefaultGridColor; newLayerData.SubGridColor = BlueBrick.Properties.Settings.Default.DefaultSubGridColor; } if (isFontModified) { newLayerData.CellIndexColor = BlueBrick.Properties.Settings.Default.DefaultTextColor; newLayerData.CellIndexFont = BlueBrick.Properties.Settings.Default.DefaultTextFont; } if (isSizeModified) { newLayerData.GridSizeInStud = BlueBrick.Properties.Settings.Default.DefaultGridSize; newLayerData.SubDivisionNumber = BlueBrick.Properties.Settings.Default.DefaultSubDivisionNumber; newLayerData.DisplayGrid = BlueBrick.Properties.Settings.Default.DefaultGridEnabled; newLayerData.DisplaySubGrid = BlueBrick.Properties.Settings.Default.DefaultSubGridEnabled; } // create a new entry for the list and store it in the list LayerChange layerChange = new LayerChange(); layerChange.mReference = gridLayer; layerChange.mOldData = oldLayerData; layerChange.mNewData = newLayerData; mLayerChanges.Add(layerChange); } } if (doesAreaChanged) { LayerArea areaLayer = layer as LayerArea; if (areaLayer != null) { // create a copy of the edited layer to hold the old data LayerArea oldLayerData = new LayerArea(); oldLayerData.CopyOptionsFrom(areaLayer); // create a new layer to store the new data LayerArea newLayerData = new LayerArea(); newLayerData.CopyOptionsFrom(areaLayer); // and change the area parameters newLayerData.Transparency = BlueBrick.Properties.Settings.Default.DefaultAreaTransparency; newLayerData.AreaCellSizeInStud = BlueBrick.Properties.Settings.Default.DefaultAreaSize; // create a new entry for the list and store it in the list LayerChange layerChange = new LayerChange(); layerChange.mReference = areaLayer; layerChange.mOldData = oldLayerData; layerChange.mNewData = newLayerData; layerChange.mOldColorMap = areaLayer.ColorMap; mLayerChanges.Add(layerChange); } } } }
protected LayerChange[] Only(BitmapPixelChanges changes, Guid layerGuid) { onlyLayerArr[0] = new LayerChange(changes, layerGuid); return(onlyLayerArr); }
public ChangeMapAppearance(bool isColorModified, bool isFontModified, bool isSizeModified, bool doesAreaChanged) { // background color of the map mOldBackGroundColor = Map.Instance.BackgroundColor; mNewBackGroundColor = BlueBrick.Properties.Settings.Default.DefaultBackgroundColor; // and the other modification to the layer bool doesGridChanged = isColorModified || isFontModified || isSizeModified; foreach (Layer layer in Map.Instance.LayerList) { if (doesGridChanged) { LayerGrid gridLayer = layer as LayerGrid; if (gridLayer != null) { // create a copy of the edited layer to hold the old data LayerGrid oldLayerData = new LayerGrid(); oldLayerData.CopyOptionsFrom(gridLayer); // create a new layer to store the new data LayerGrid newLayerData = new LayerGrid(); newLayerData.CopyOptionsFrom(gridLayer); // and change only the grid colors if (isColorModified) { newLayerData.GridColor = BlueBrick.Properties.Settings.Default.DefaultGridColor; newLayerData.SubGridColor = BlueBrick.Properties.Settings.Default.DefaultSubGridColor; } if (isFontModified) { newLayerData.CellIndexColor = BlueBrick.Properties.Settings.Default.DefaultTextColor; newLayerData.CellIndexFont = BlueBrick.Properties.Settings.Default.DefaultTextFont; } if (isSizeModified) { newLayerData.GridSizeInStud = BlueBrick.Properties.Settings.Default.DefaultGridSize; newLayerData.SubDivisionNumber = BlueBrick.Properties.Settings.Default.DefaultSubDivisionNumber; newLayerData.DisplayGrid = BlueBrick.Properties.Settings.Default.DefaultGridEnabled; newLayerData.DisplaySubGrid = BlueBrick.Properties.Settings.Default.DefaultSubGridEnabled; } // create a new entry for the list and store it in the list LayerChange layerChange = new LayerChange(); layerChange.mReference = gridLayer; layerChange.mOldData = oldLayerData; layerChange.mNewData = newLayerData; mLayerChanges.Add(layerChange); } } if (doesAreaChanged) { LayerArea areaLayer = layer as LayerArea; if (areaLayer != null) { // create a copy of the edited layer to hold the old data LayerArea oldLayerData = new LayerArea(); oldLayerData.CopyOptionsFrom(areaLayer); // create a new layer to store the new data LayerArea newLayerData = new LayerArea(); newLayerData.CopyOptionsFrom(areaLayer); // and change the area parameters newLayerData.Transparency = BlueBrick.Properties.Settings.Default.DefaultAreaTransparency; newLayerData.AreaCellSizeInStud = BlueBrick.Properties.Settings.Default.DefaultAreaSize; // create a new entry for the list and store it in the list LayerChange layerChange = new LayerChange(); layerChange.mReference = areaLayer; layerChange.mOldData = oldLayerData; layerChange.mNewData = newLayerData; layerChange.mOldColorMap = areaLayer.ColorMap; mLayerChanges.Add(layerChange); } } } }