protected void SetProperty(object value) { foreach (var o in EditorParams.Objects) { EditorParams.PropertySetter(o, EditorParams.PropertyName, value); } }
public DrivingPicker(Rectangle location, DockType dockType, CompressedBuilding compressedBuilding, EditorParams editorParams) : base(location, dockType, true) { this.compressedBuilding = compressedBuilding; this.editorParams = editorParams; drawSpriteBack = true; spriteBack = GraphicsManager.GetPreBuilt(Engine.ContentStorage.PrebuiltSprite.EditorPanelBackGrey); AddBorder(3, Resizing.NONE, 1); AddHeading(40, "Driving Picker", GraphicsManager.GetSpriteFont(Font.OpenSans18), Color.White, false, false, false, false, true, GraphicsManager.GetSpriteColour(6)); }
public static void SaveLevel(EditorParams pu, EditorLogic lu, int slotNumber, string path) { string filepath = Application.streamingAssetsPath + path + "level_" + slotNumber.ToString() + ".json"; LevelData ld = new LevelData(pu, lu); string jsonData = JsonUtility.ToJson(ld); File.WriteAllText(filepath, jsonData); }
public EditorView(Rectangle location, DockType dockType, CompressedBuilding compressedBuilding, EditorParams editorParams) : base(location, dockType, true) { this.editorParams = editorParams; camera = new Camera(containerCamera.worldCameraViewport, 4, Vector2.Zero, new Vector2(1000, 1000), false); camera.CenterOn(new Vector2(500, 500)); camera.setZoomIndex(5); camera.lockZoom = false; camera.lockKeyMove = false; canChangeFocusOrder = false; borderMap = new BorderMap(compressedBuilding, editorParams); this.compressedBuilding = compressedBuilding; inGrid = false; }
IEnumerator <object> ManageLabelTask() { while (true) { var popupMenu = PropertyLabel.Input.WasMouseReleased(1); if (popupMenu || PropertyLabel.Input.WasMouseReleased(0)) { PropertyLabel.SetFocus(); } PropertyLabel.Color = PropertyLabel.IsFocused() ? Theme.Colors.KeyboardFocusBorder : Theme.Colors.BlackText; if (popupMenu) { // Wait until the label actually change its color. yield return(null); yield return(null); ShowPropertyContextMenu(); } if (PropertyLabel.IsFocused()) { if (Command.Copy.WasIssued()) { Command.Copy.Consume(); Copy(); } if (Command.Paste.WasIssued()) { Command.Paste.Consume(); Paste(); } if (resetToDefault.WasIssued()) { resetToDefault.Consume(); var defaultValue = EditorParams.DefaultValueGetter(); if (defaultValue != null) { SetProperty(defaultValue); } } } yield return(null); } }
public BuildingScreen(CompressedBuilding compressedBuilding, BuildingsBinary buildingsBinary, EditorParams editorParams) { GameController.inGameState = InGameState.RUNNING; this.editorParams = editorParams; this.compressedBuilding = compressedBuilding; GameController.editorInMenu = false; this.buildingsBinary = buildingsBinary; AddContainer(new BackgroundMenu(new Rectangle(0, 0, 0, 0), DockType.SCREENRESOLUTION, TextureSheet.Editor)); editorView = new EditorView(new Rectangle(100, 100, 2000, 1500), DockType.SCREENRESOLUTION, compressedBuilding, editorParams); AddContainer(editorView); buildingPicker = new BuildingPicker(new Rectangle(200, 150, 400, 500), DockType.TOPRIGHTFIXEDY, compressedBuilding, editorParams); shadowPicker = new ShadowPicker(new Rectangle(200, 150, 400, 500), DockType.TOPRIGHTFIXEDY, compressedBuilding, editorParams); objectPicker = new ObjectPicker(new Rectangle(200, 150, 400, 500), DockType.TOPRIGHTFIXEDY, compressedBuilding, editorParams); drivingPicker = new DrivingPicker(new Rectangle(200, 150, 400, 500), DockType.TOPRIGHTFIXEDY, compressedBuilding, editorParams); AddContainer(buildingPicker); general = new General(new Rectangle(200, 150, 600, 1250), DockType.TOPLEFTFIXEDY, compressedBuilding, editorParams); AddContainer(general); }
public BuildingPicker(Rectangle location, DockType dockType, CompressedBuilding compressedBuilding, EditorParams editorParams) : base(location, dockType, true) { this.compressedBuilding = compressedBuilding; this.editorParams = editorParams; drawSpriteBack = true; spriteBack = GraphicsManager.GetPreBuilt(Engine.ContentStorage.PrebuiltSprite.EditorPanelBackGrey); AddBorder(3, Resizing.NONE, 1); AddHeading(40, "Building Picker", GraphicsManager.GetSpriteFont(Font.OpenSans18), Color.White, false, false, false, false, true, GraphicsManager.GetSpriteColour(6)); AddUiControl(new Label("Index", Font.OpenSans24Bold, Color.White, new Vector2(195, 310), true, "")); AddUiControl(new PictureBox("Picture", new Rectangle(100, 80, 192, 192), null)); AddUiControl(new Box("Box", new Rectangle(90, 70, 212, 212), 3, 0, 20, true, false)); AddUiControl(new ButtonBlueMedium("Back", new Point(30, 360), "(Q) >", Color.White)); AddUiControl(new ButtonBlueMedium("Next", new Point(210, 360), "(E) >", Color.White)); SetSamplePiece(); }
public LevelData(EditorParams pu, EditorLogic lu) { gridSizeX = (int)pu.gridSize.x; gridSizeY = (int)pu.gridSize.y; gemColors = new int[gridSizeX * gridSizeY]; gemBonuses = new int[gridSizeX * gridSizeY]; for (int x = 0; x < gridSizeX; x++) { for (int y = 0; y < gridSizeY; y++) { if (!lu.grid[x, y].IsEmpty()) { gemColors[x * gridSizeY + y] = lu.grid[x, y].Gem.Color; gemBonuses[x * gridSizeY + y] = lu.grid[x, y].Gem.Bonus; } else { gemColors[x * gridSizeY + y] = -1; } } } colorVector = pu.colorVector; availableBonuses = pu.permittedBonuses; sequenceSize = pu.sequenceSize; maximumEnergy = pu.maximumEnergy; spawnNewGems = pu.spawnNewGems; spawnEnergy = pu.spawnEnergy; randomizeColors = pu.randomizeColors; bonusPercentage = pu.bonusesPercentage; energyPercentage = pu.energyPercentage; winCondition = pu.winCondition; timeAvailable = pu.timeAvailable; scoreToWin = pu.scoreToWin; movesAvailable = pu.movesAvailable; }
public ShadowPicker(Rectangle location, DockType dockType, CompressedBuilding compressedBuilding, EditorParams editorParams) : base(location, dockType, true) { this.editorParams = editorParams; this.compressedBuilding = compressedBuilding; drawSpriteBack = true; spriteBack = GraphicsManager.GetPreBuilt(Engine.ContentStorage.PrebuiltSprite.EditorPanelBackGrey); AddBorder(3, Resizing.NONE, 1); AddHeading(40, "Shadow Picker", GraphicsManager.GetSpriteFont(Font.OpenSans18), Color.White, false, false, false, false, true, GraphicsManager.GetSpriteColour(6)); editStyleCombo = new ComboEditorCycleNoLabel("Side", "", new Point(5, 10), true, false, true); editStyleCombo.AddCycleObject(new CycleObject("Left Shadows", ShadowSide.LEFT)); editStyleCombo.AddCycleObject(new CycleObject("Right Shadows", ShadowSide.RIGHT)); AddUiControl(editStyleCombo); AddUiControl(new Label("Index", Font.OpenSans24Bold, Color.White, new Vector2(195, 320), true, "")); AddUiControl(new ButtonBlueMedium("Back", new Point(30, 360), "(Q) >", Color.White)); AddUiControl(new ButtonBlueMedium("Next", new Point(210, 360), "(E) >", Color.White)); SetSampleShadow(); }
public override void Update(Input input) { base.Update(input); if (GetButtonPress("New")) { EditorParams editorParams = new EditorParams(); CompressedBuilding building = new CompressedBuilding(GetHousePieceRow(), GetDirectionFacing(), editorParams); building.InitNew(buildingsBinary.GetNextId()); ScreenController.ChangeScreen(new BuildingScreen(building, buildingsBinary, editorParams)); } if (GetButtonPress("Load")) { CompressedBuilding building = (CompressedBuilding)listBoxBuildings.GetSelectedObjectValue(); if (building != null) { EditorParams editorParams = new EditorParams(); building.InitOld(editorParams); ScreenController.ChangeScreen(new BuildingScreen(building, buildingsBinary, editorParams)); } } }
public ParsingResult ParseParams() { if (_fileSystem.File.Exists(FancyZonesEditorParamsFile)) { string data = string.Empty; try { data = ReadFile(FancyZonesEditorParamsFile); EditorParams editorParams = JsonSerializer.Deserialize <EditorParams>(data, _options); // Process ID App.PowerToysPID = editorParams.ProcessId; // Span zones across monitors App.Overlay.SpanZonesAcrossMonitors = editorParams.SpanZonesAcrossMonitors; if (!App.Overlay.SpanZonesAcrossMonitors) { // Monitors count if (editorParams.Monitors.Count != App.Overlay.DesktopsCount) { MessageBox.Show(Properties.Resources.Error_Invalid_Arguments, Properties.Resources.Error_Message_Box_Title); ((App)Application.Current).Shutdown(); } string targetMonitorName = string.Empty; double primaryMonitorDPI = 96f; double minimalUsedMonitorDPI = double.MaxValue; foreach (NativeMonitorData nativeData in editorParams.Monitors) { if (nativeData.LeftCoordinate == 0 && nativeData.TopCoordinate == 0) { primaryMonitorDPI = nativeData.Dpi; } if (minimalUsedMonitorDPI > nativeData.Dpi) { minimalUsedMonitorDPI = nativeData.Dpi; } if (nativeData.IsSelected) { targetMonitorName = nativeData.MonitorId; } } var monitors = App.Overlay.Monitors; double identifyScaleFactor = minimalUsedMonitorDPI / primaryMonitorDPI; double scaleFactor = 96f / primaryMonitorDPI; // Update monitors data foreach (Monitor monitor in monitors) { bool matchFound = false; monitor.Scale(scaleFactor); double scaledBoundX = (int)(monitor.Device.UnscaledBounds.X * identifyScaleFactor); double scaledBoundY = (int)(monitor.Device.UnscaledBounds.Y * identifyScaleFactor); foreach (NativeMonitorData nativeData in editorParams.Monitors) { // Can't do an exact match since the rounding algorithm used by the framework is different from ours if (scaledBoundX >= (nativeData.LeftCoordinate - 1) && scaledBoundX <= (nativeData.LeftCoordinate + 1) && scaledBoundY >= (nativeData.TopCoordinate - 1) && scaledBoundY <= (nativeData.TopCoordinate + 1)) { monitor.Device.Id = nativeData.MonitorId; monitor.Device.Dpi = nativeData.Dpi; matchFound = true; break; } } if (matchFound == false) { MessageBox.Show(string.Format(Properties.Resources.Error_Monitor_Match_Not_Found, monitor.Device.UnscaledBounds.ToString())); } } // Set active desktop for (int i = 0; i < monitors.Count; i++) { var monitor = monitors[i]; if (monitor.Device.Id == targetMonitorName) { App.Overlay.CurrentDesktop = i; break; } } } else { // Update monitors data foreach (Monitor monitor in App.Overlay.Monitors) { bool matchFound = false; foreach (NativeMonitorData nativeData in editorParams.Monitors) { // Can't do an exact match since the rounding algorithm used by the framework is different from ours if (monitor.Device.UnscaledBounds.X >= (nativeData.LeftCoordinate - 1) && monitor.Device.UnscaledBounds.X <= (nativeData.LeftCoordinate + 1) && monitor.Device.UnscaledBounds.Y >= (nativeData.TopCoordinate - 1) && monitor.Device.UnscaledBounds.Y <= (nativeData.TopCoordinate + 1)) { monitor.Device.Id = nativeData.MonitorId; monitor.Device.Dpi = nativeData.Dpi; matchFound = true; break; } } if (matchFound == false) { MessageBox.Show(string.Format(Properties.Resources.Error_Monitor_Match_Not_Found, monitor.Device.UnscaledBounds.ToString())); } } } } catch (Exception ex) { return(new ParsingResult(false, ex.Message, data)); } return(new ParsingResult(true)); } else { return(new ParsingResult(false)); } }
public ColorGradientPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams) { if (editorParams.Objects.Count() > 1) { ExpandButton.Visible = false; EditorContainer.AddNode(new ThemedSimpleText { Text = "Unable to edit multiple gradients", VAlignment = VAlignment.Center, LayoutCell = new LayoutCell(Alignment.Center, stretchX: 0), }); return; } gradientControlWidget = new TransactionalGradientControlWidget(EditorParams.History) { MinMaxHeight = 35f, Height = 35f, LayoutCell = new LayoutCell(Alignment.LeftCenter), Padding = new Thickness { Right = 5f, Bottom = 5f } }; var gradientProperty = CoalescedPropertyValue(new ColorGradient(Color4.White, Color4.Black)).DistinctUntilChanged(); gradientControlWidget.Gradient = gradientProperty.GetValue(); ContainerWidget.AddChangeWatcher(gradientProperty, g => gradientControlWidget.Gradient = g); gradientControlWidget.SelectionChanged += SelectPoint; EditorContainer.AddNode(gradientControlWidget); EditorContainer.AddNode(CreatePipetteButton()); ExpandableContent.Padding = new Thickness { Left = 25f, Right = 25f, Top = 5f }; ExpandableContent.AddNode(new Widget { Layout = new HBoxLayout { Spacing = 10f }, Nodes = { new ThemedSimpleText { Text = nameof(GradientControlPoint.Position), MinWidth = 150 }, (positionEditor = EditorParams.NumericEditBoxFactory()) }, Padding = new Thickness(0, 3f) }); ExpandableContent.AddNode(new Widget { Layout = new HBoxLayout { Spacing = 10f }, Nodes = { new ThemedSimpleText { Text = nameof(GradientControlPoint.Color), MinWidth = 150 }, (colorEditor = EditorParams.EditBoxFactory()) }, Padding = new Thickness(0, 3f) }); positionEditor.Step = 0.005f; colorEditor.Submitted += SetColor; positionEditor.Submitted += SetPosition; colorPanel = new ColorPickerPanel(); ExpandableContent.AddNode(colorPanel.Widget); var padding = colorPanel.Widget.Padding; padding.Right = 12; colorPanel.Widget.Padding = padding; colorPanel.DragStarted += () => EditorParams.History?.BeginTransaction(); gradientControlWidget.DragStarted += () => EditorParams.History?.BeginTransaction(); gradientControlWidget.DragEnded += () => { EditorParams.History?.CommitTransaction(); EditorParams.History?.EndTransaction(); }; colorPanel.DragEnded += () => { EditorParams.History?.CommitTransaction(); EditorParams.History?.EndTransaction(); }; colorPanel.Changed += () => { EditorParams.History?.RollbackTransaction(); Core.Operations.SetProperty.Perform(selectedControlPoint, nameof(GradientControlPoint.Color), colorPanel.Color); }; SelectPoint(selectedControlPoint); }
public ParsingResult ParseParams() { Logger.LogTrace(); if (_fileSystem.File.Exists(FancyZonesEditorParamsFile)) { string data = string.Empty; try { data = ReadFile(FancyZonesEditorParamsFile); EditorParams editorParams = JsonSerializer.Deserialize <EditorParams>(data, _options); // Process ID App.PowerToysPID = editorParams.ProcessId; // Span zones across monitors App.Overlay.SpanZonesAcrossMonitors = editorParams.SpanZonesAcrossMonitors; if (!App.Overlay.SpanZonesAcrossMonitors) { string targetMonitorName = string.Empty; foreach (NativeMonitorData nativeData in editorParams.Monitors) { Rect workArea = new Rect(nativeData.LeftCoordinate, nativeData.TopCoordinate, nativeData.Width, nativeData.Height); if (nativeData.IsSelected) { targetMonitorName = nativeData.MonitorId; } var monitor = new Monitor(workArea, workArea); monitor.Device.Id = nativeData.MonitorId; monitor.Device.Dpi = nativeData.Dpi; App.Overlay.AddMonitor(monitor); } // Set active desktop var monitors = App.Overlay.Monitors; for (int i = 0; i < monitors.Count; i++) { var monitor = monitors[i]; if (monitor.Device.Id == targetMonitorName) { App.Overlay.CurrentDesktop = i; break; } } } else { if (editorParams.Monitors.Count != 1) { return(new ParsingResult(false)); } var nativeData = editorParams.Monitors[0]; Rect workArea = new Rect(nativeData.LeftCoordinate, nativeData.TopCoordinate, nativeData.Width, nativeData.Height); var monitor = new Monitor(workArea, workArea); monitor.Device.Id = nativeData.MonitorId; App.Overlay.AddMonitor(monitor); } } catch (Exception ex) { Logger.LogError("Editor params parsing error", ex); return(new ParsingResult(false, ex.Message, data)); } return(new ParsingResult(true)); } else { return(new ParsingResult(false)); } }