diff --git a/Intersect.Editor/Forms/DockingElements/frmMapLayers.Designer.cs b/Intersect.Editor/Forms/DockingElements/frmMapLayers.Designer.cs index 3cdd9e2c13..3002168127 100644 --- a/Intersect.Editor/Forms/DockingElements/frmMapLayers.Designer.cs +++ b/Intersect.Editor/Forms/DockingElements/frmMapLayers.Designer.cs @@ -38,16 +38,7 @@ private void InitializeComponent() this.lblTileset = new System.Windows.Forms.Label(); this.cmbAutotile = new DarkUI.Controls.DarkComboBox(); this.cmbTilesets = new DarkUI.Controls.DarkComboBox(); - this.rbSlide = new DarkUI.Controls.DarkRadioButton(); - this.rbGrappleStone = new DarkUI.Controls.DarkRadioButton(); - this.rbAnimation = new DarkUI.Controls.DarkRadioButton(); - this.rbResource = new DarkUI.Controls.DarkRadioButton(); - this.rbSound = new DarkUI.Controls.DarkRadioButton(); - this.rbWarp = new DarkUI.Controls.DarkRadioButton(); - this.rbNPCAvoid = new DarkUI.Controls.DarkRadioButton(); - this.rbZDimension = new DarkUI.Controls.DarkRadioButton(); - this.rbItem = new DarkUI.Controls.DarkRadioButton(); - this.rbBlocked = new DarkUI.Controls.DarkRadioButton(); + cmbAttributeType = new DarkUI.Controls.DarkComboBox(); this.grpResource = new DarkUI.Controls.DarkGroupBox(); this.grpZResource = new DarkUI.Controls.DarkGroupBox(); this.rbLevel2 = new DarkUI.Controls.DarkRadioButton(); @@ -137,7 +128,6 @@ private void InitializeComponent() this.lblCritterSprite = new System.Windows.Forms.Label(); this.cmbCritterAnimation = new DarkUI.Controls.DarkComboBox(); this.lblCritterAnimation = new System.Windows.Forms.Label(); - this.rbCritter = new DarkUI.Controls.DarkRadioButton(); this.pnlNpcs = new System.Windows.Forms.Panel(); this.pnlTiles = new System.Windows.Forms.Panel(); this.cmbMapLayer = new DarkUI.Controls.DarkComboBox(); @@ -272,118 +262,26 @@ private void InitializeComponent() this.cmbTilesets.TextPadding = new System.Windows.Forms.Padding(2); this.cmbTilesets.SelectedIndexChanged += new System.EventHandler(this.cmbTilesets_SelectedIndexChanged); this.cmbTilesets.MouseDown += new System.Windows.Forms.MouseEventHandler(this.cmbTilesets_MouseDown); - // - // rbSlide - // - this.rbSlide.AutoSize = true; - this.rbSlide.ForeColor = System.Drawing.Color.Gainsboro; - this.rbSlide.Location = new System.Drawing.Point(115, 30); - this.rbSlide.Name = "rbSlide"; - this.rbSlide.Size = new System.Drawing.Size(48, 17); - this.rbSlide.TabIndex = 35; - this.rbSlide.Text = "Slide"; - this.rbSlide.CheckedChanged += new System.EventHandler(this.rbSlide_CheckedChanged); - // - // rbGrappleStone - // - this.rbGrappleStone.AutoSize = true; - this.rbGrappleStone.ForeColor = System.Drawing.Color.Gainsboro; - this.rbGrappleStone.Location = new System.Drawing.Point(115, 8); - this.rbGrappleStone.Name = "rbGrappleStone"; - this.rbGrappleStone.Size = new System.Drawing.Size(93, 17); - this.rbGrappleStone.TabIndex = 34; - this.rbGrappleStone.Text = "Grapple Stone"; - this.rbGrappleStone.CheckedChanged += new System.EventHandler(this.rbGrappleStone_CheckedChanged); - // - // rbAnimation - // - this.rbAnimation.AutoSize = true; - this.rbAnimation.ForeColor = System.Drawing.Color.Gainsboro; - this.rbAnimation.Location = new System.Drawing.Point(6, 146); - this.rbAnimation.Name = "rbAnimation"; - this.rbAnimation.Size = new System.Drawing.Size(71, 17); - this.rbAnimation.TabIndex = 32; - this.rbAnimation.Text = "Animation"; - this.rbAnimation.CheckedChanged += new System.EventHandler(this.rbAnimation_CheckedChanged); - // - // rbResource - // - this.rbResource.AutoSize = true; - this.rbResource.ForeColor = System.Drawing.Color.Gainsboro; - this.rbResource.Location = new System.Drawing.Point(6, 123); - this.rbResource.Name = "rbResource"; - this.rbResource.Size = new System.Drawing.Size(71, 17); - this.rbResource.TabIndex = 30; - this.rbResource.Text = "Resource"; - this.rbResource.CheckedChanged += new System.EventHandler(this.rbResource_CheckedChanged); - // - // rbSound - // - this.rbSound.AutoSize = true; - this.rbSound.ForeColor = System.Drawing.Color.Gainsboro; - this.rbSound.Location = new System.Drawing.Point(6, 100); - this.rbSound.Name = "rbSound"; - this.rbSound.Size = new System.Drawing.Size(80, 17); - this.rbSound.TabIndex = 28; - this.rbSound.Text = "Map Sound"; - this.rbSound.CheckedChanged += new System.EventHandler(this.rbSound_CheckedChanged); - // - // rbWarp - // - this.rbWarp.AutoSize = true; - this.rbWarp.ForeColor = System.Drawing.Color.Gainsboro; - this.rbWarp.Location = new System.Drawing.Point(6, 53); - this.rbWarp.Name = "rbWarp"; - this.rbWarp.Size = new System.Drawing.Size(51, 17); - this.rbWarp.TabIndex = 25; - this.rbWarp.Text = "Warp"; - this.rbWarp.CheckedChanged += new System.EventHandler(this.rbWarp_CheckedChanged); - // - // rbNPCAvoid - // - this.rbNPCAvoid.AutoSize = true; - this.rbNPCAvoid.ForeColor = System.Drawing.Color.Gainsboro; - this.rbNPCAvoid.Location = new System.Drawing.Point(6, 30); - this.rbNPCAvoid.Name = "rbNPCAvoid"; - this.rbNPCAvoid.Size = new System.Drawing.Size(77, 17); - this.rbNPCAvoid.TabIndex = 24; - this.rbNPCAvoid.Text = "NPC Avoid"; - this.rbNPCAvoid.CheckedChanged += new System.EventHandler(this.rbNPCAvoid_CheckedChanged); - // - // rbZDimension - // - this.rbZDimension.AutoSize = true; - this.rbZDimension.ForeColor = System.Drawing.Color.Gainsboro; - this.rbZDimension.Location = new System.Drawing.Point(115, 53); - this.rbZDimension.Name = "rbZDimension"; - this.rbZDimension.Size = new System.Drawing.Size(84, 17); - this.rbZDimension.TabIndex = 23; - this.rbZDimension.Text = "Z-Dimension"; - this.rbZDimension.CheckedChanged += new System.EventHandler(this.rbZDimension_CheckedChanged); - // - // rbItem - // - this.rbItem.AutoSize = true; - this.rbItem.ForeColor = System.Drawing.Color.Gainsboro; - this.rbItem.Location = new System.Drawing.Point(6, 76); - this.rbItem.Name = "rbItem"; - this.rbItem.Size = new System.Drawing.Size(81, 17); - this.rbItem.TabIndex = 21; - this.rbItem.Text = "Item Spawn"; - this.rbItem.CheckedChanged += new System.EventHandler(this.rbItem_CheckedChanged); - // - // rbBlocked - // - this.rbBlocked.AutoSize = true; - this.rbBlocked.Checked = true; - this.rbBlocked.ForeColor = System.Drawing.Color.Gainsboro; - this.rbBlocked.Location = new System.Drawing.Point(6, 8); - this.rbBlocked.Name = "rbBlocked"; - this.rbBlocked.Size = new System.Drawing.Size(64, 17); - this.rbBlocked.TabIndex = 20; - this.rbBlocked.TabStop = true; - this.rbBlocked.Text = "Blocked"; - this.rbBlocked.CheckedChanged += new System.EventHandler(this.rbBlocked_CheckedChanged); + // cmbAttributeType + // + cmbAttributeType.BackColor = System.Drawing.Color.FromArgb(((int)((byte)69)), ((int)((byte)73)), ((int)((byte)74))); + cmbAttributeType.BorderColor = System.Drawing.Color.FromArgb(((int)((byte)90)), ((int)((byte)90)), ((int)((byte)90))); + cmbAttributeType.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid; + cmbAttributeType.ButtonColor = System.Drawing.Color.FromArgb(((int)((byte)43)), ((int)((byte)43)), ((int)((byte)43))); + cmbAttributeType.DrawDropdownHoverOutline = false; + cmbAttributeType.DrawFocusRectangle = false; + cmbAttributeType.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; + cmbAttributeType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + cmbAttributeType.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + cmbAttributeType.ForeColor = System.Drawing.Color.Gainsboro; + cmbAttributeType.FormattingEnabled = true; + cmbAttributeType.Location = new System.Drawing.Point(8, 8); + cmbAttributeType.Name = "cmbAttributeType"; + cmbAttributeType.Size = new System.Drawing.Size(250, 22); + cmbAttributeType.TabIndex = 100; + cmbAttributeType.Text = null; + cmbAttributeType.TextPadding = new System.Windows.Forms.Padding(2); + cmbAttributeType.SelectedIndexChanged += cmbAttributeType_SelectedIndexChanged; // // grpResource // @@ -393,9 +291,9 @@ private void InitializeComponent() this.grpResource.Controls.Add(this.cmbResourceAttribute); this.grpResource.Controls.Add(this.lblResource); this.grpResource.ForeColor = System.Drawing.Color.Gainsboro; - this.grpResource.Location = new System.Drawing.Point(6, 179); + this.grpResource.Location = new System.Drawing.Point(8, 42); this.grpResource.Name = "grpResource"; - this.grpResource.Size = new System.Drawing.Size(256, 116); + this.grpResource.Size = new System.Drawing.Size(250, grpZResource.Visible ? 120 : 75); this.grpResource.TabIndex = 31; this.grpResource.TabStop = false; this.grpResource.Text = "Resource"; @@ -477,9 +375,9 @@ private void InitializeComponent() this.grpItem.Controls.Add(this.lblMaxItemAmount); this.grpItem.Controls.Add(this.lblMapItem); this.grpItem.ForeColor = System.Drawing.Color.Gainsboro; - this.grpItem.Location = new System.Drawing.Point(6, 179); + this.grpItem.Location = new System.Drawing.Point(8, 42); this.grpItem.Name = "grpItem"; - this.grpItem.Size = new System.Drawing.Size(246, 148); + this.grpItem.Size = new System.Drawing.Size(250, 148); this.grpItem.TabIndex = 22; this.grpItem.TabStop = false; this.grpItem.Text = "Map Item"; @@ -561,9 +459,9 @@ private void InitializeComponent() this.grpWarp.Controls.Add(this.lblX); this.grpWarp.Controls.Add(this.lblMap); this.grpWarp.ForeColor = System.Drawing.Color.Gainsboro; - this.grpWarp.Location = new System.Drawing.Point(6, 179); + this.grpWarp.Location = new System.Drawing.Point(8, 42); this.grpWarp.Name = "grpWarp"; - this.grpWarp.Size = new System.Drawing.Size(255, 367); + this.grpWarp.Size = new System.Drawing.Size(250, 367); this.grpWarp.TabIndex = 26; this.grpWarp.TabStop = false; this.grpWarp.Text = "Warp"; @@ -785,9 +683,9 @@ private void InitializeComponent() this.grpZDimension.Controls.Add(this.grpGateway); this.grpZDimension.Controls.Add(this.grpDimBlock); this.grpZDimension.ForeColor = System.Drawing.Color.Gainsboro; - this.grpZDimension.Location = new System.Drawing.Point(6, 179); + this.grpZDimension.Location = new System.Drawing.Point(8, 42); this.grpZDimension.Name = "grpZDimension"; - this.grpZDimension.Size = new System.Drawing.Size(257, 132); + this.grpZDimension.Size = new System.Drawing.Size(250, 132); this.grpZDimension.TabIndex = 27; this.grpZDimension.TabStop = false; this.grpZDimension.Text = "Z-Dimension"; @@ -892,9 +790,9 @@ private void InitializeComponent() this.grpSound.Controls.Add(this.lblSoundDistance); this.grpSound.Controls.Add(this.lblMapSound); this.grpSound.ForeColor = System.Drawing.Color.Gainsboro; - this.grpSound.Location = new System.Drawing.Point(6, 179); + this.grpSound.Location = new System.Drawing.Point(8, 42); this.grpSound.Name = "grpSound"; - this.grpSound.Size = new System.Drawing.Size(252, 150); + this.grpSound.Size = new System.Drawing.Size(250, 150); this.grpSound.TabIndex = 29; this.grpSound.TabStop = false; this.grpSound.Text = "Map Sound"; @@ -987,9 +885,9 @@ private void InitializeComponent() this.grpSlide.Controls.Add(this.cmbSlideDir); this.grpSlide.Controls.Add(this.lblSlideDir); this.grpSlide.ForeColor = System.Drawing.Color.Gainsboro; - this.grpSlide.Location = new System.Drawing.Point(5, 177); + this.grpSlide.Location = new System.Drawing.Point(8, 42); this.grpSlide.Name = "grpSlide"; - this.grpSlide.Size = new System.Drawing.Size(259, 75); + this.grpSlide.Size = new System.Drawing.Size(250, 75); this.grpSlide.TabIndex = 36; this.grpSlide.TabStop = false; this.grpSlide.Text = "Slide"; @@ -1014,9 +912,9 @@ private void InitializeComponent() "Down", "Left", "Right"}); - this.cmbSlideDir.Location = new System.Drawing.Point(50, 27); + this.cmbSlideDir.Location = new System.Drawing.Point(60, 27); this.cmbSlideDir.Name = "cmbSlideDir"; - this.cmbSlideDir.Size = new System.Drawing.Size(192, 21); + this.cmbSlideDir.Size = new System.Drawing.Size(180, 22); this.cmbSlideDir.TabIndex = 25; this.cmbSlideDir.Text = "Retain Direction"; this.cmbSlideDir.TextPadding = new System.Windows.Forms.Padding(2); @@ -1025,7 +923,7 @@ private void InitializeComponent() // this.lblSlideDir.AutoSize = true; this.lblSlideDir.ForeColor = System.Drawing.Color.Gainsboro; - this.lblSlideDir.Location = new System.Drawing.Point(17, 30); + this.lblSlideDir.Location = new System.Drawing.Point(8, 30); this.lblSlideDir.Name = "lblSlideDir"; this.lblSlideDir.Size = new System.Drawing.Size(23, 13); this.lblSlideDir.TabIndex = 24; @@ -1039,9 +937,9 @@ private void InitializeComponent() this.grpAnimation.Controls.Add(this.cmbAnimationAttribute); this.grpAnimation.Controls.Add(this.lblAnimation); this.grpAnimation.ForeColor = System.Drawing.Color.Gainsboro; - this.grpAnimation.Location = new System.Drawing.Point(6, 179); + this.grpAnimation.Location = new System.Drawing.Point(8, 42); this.grpAnimation.Name = "grpAnimation"; - this.grpAnimation.Size = new System.Drawing.Size(256, 96); + this.grpAnimation.Size = new System.Drawing.Size(250, 96); this.grpAnimation.TabIndex = 33; this.grpAnimation.TabStop = false; this.grpAnimation.Text = "Animaton"; @@ -1341,17 +1239,7 @@ private void InitializeComponent() // this.pnlAttributes.Controls.Add(this.grpWarp); this.pnlAttributes.Controls.Add(this.grpCritter); - this.pnlAttributes.Controls.Add(this.rbCritter); - this.pnlAttributes.Controls.Add(this.rbSlide); - this.pnlAttributes.Controls.Add(this.rbBlocked); - this.pnlAttributes.Controls.Add(this.rbGrappleStone); - this.pnlAttributes.Controls.Add(this.rbAnimation); - this.pnlAttributes.Controls.Add(this.rbResource); - this.pnlAttributes.Controls.Add(this.rbSound); - this.pnlAttributes.Controls.Add(this.rbWarp); - this.pnlAttributes.Controls.Add(this.rbNPCAvoid); - this.pnlAttributes.Controls.Add(this.rbZDimension); - this.pnlAttributes.Controls.Add(this.rbItem); + this.pnlAttributes.Controls.Add(cmbAttributeType); this.pnlAttributes.Controls.Add(this.grpAnimation); this.pnlAttributes.Controls.Add(this.grpSlide); this.pnlAttributes.Controls.Add(this.grpSound); @@ -1385,9 +1273,9 @@ private void InitializeComponent() this.grpCritter.Controls.Add(this.cmbCritterAnimation); this.grpCritter.Controls.Add(this.lblCritterAnimation); this.grpCritter.ForeColor = System.Drawing.Color.Gainsboro; - this.grpCritter.Location = new System.Drawing.Point(6, 179); + this.grpCritter.Location = new System.Drawing.Point(8, 42); this.grpCritter.Name = "grpCritter"; - this.grpCritter.Size = new System.Drawing.Size(256, 260); + this.grpCritter.Size = new System.Drawing.Size(250, 260); this.grpCritter.TabIndex = 38; this.grpCritter.TabStop = false; this.grpCritter.Text = "Critter"; @@ -1610,17 +1498,6 @@ private void InitializeComponent() this.lblCritterAnimation.TabIndex = 10; this.lblCritterAnimation.Text = "Animation"; // - // rbCritter - // - this.rbCritter.AutoSize = true; - this.rbCritter.ForeColor = System.Drawing.Color.Gainsboro; - this.rbCritter.Location = new System.Drawing.Point(115, 73); - this.rbCritter.Name = "rbCritter"; - this.rbCritter.Size = new System.Drawing.Size(52, 17); - this.rbCritter.TabIndex = 37; - this.rbCritter.Text = "Critter"; - this.rbCritter.CheckedChanged += new System.EventHandler(this.rbCritter_CheckedChanged); - // // pnlNpcs // this.pnlNpcs.Controls.Add(this.grpNpcList); @@ -1896,13 +1773,7 @@ private void InitializeComponent() public System.Windows.Forms.PictureBox picTileset; private DarkComboBox cmbAutotile; public DarkComboBox cmbTilesets; - private DarkRadioButton rbResource; - private DarkRadioButton rbSound; - private DarkRadioButton rbWarp; - private DarkRadioButton rbNPCAvoid; - private DarkRadioButton rbZDimension; - private DarkRadioButton rbItem; - private DarkRadioButton rbBlocked; + private DarkComboBox cmbAttributeType; private DarkGroupBox grpResource; private DarkGroupBox grpSound; public DarkComboBox cmbMapAttributeSound; @@ -1951,9 +1822,6 @@ private void InitializeComponent() private DarkGroupBox grpAnimation; private DarkComboBox cmbAnimationAttribute; private System.Windows.Forms.Label lblAnimation; - private DarkRadioButton rbAnimation; - private DarkRadioButton rbSlide; - private DarkRadioButton rbGrappleStone; private DarkGroupBox grpSlide; private DarkComboBox cmbSlideDir; private System.Windows.Forms.Label lblSlideDir; @@ -1984,7 +1852,6 @@ private void InitializeComponent() public DarkComboBox cmbMapLayer; private DarkNumericUpDown nudSoundLoopInterval; private Label lblSoundInterval; - private DarkRadioButton rbCritter; private DarkGroupBox grpCritter; private DarkComboBox cmbCritterSprite; private Label lblCritterSprite; diff --git a/Intersect.Editor/Forms/DockingElements/frmMapLayers.cs b/Intersect.Editor/Forms/DockingElements/frmMapLayers.cs index 43972a0717..362a5453c4 100644 --- a/Intersect.Editor/Forms/DockingElements/frmMapLayers.cs +++ b/Intersect.Editor/Forms/DockingElements/frmMapLayers.cs @@ -117,7 +117,6 @@ public void Init() SetTileset(cmbTilesets.Items[0].ToString()); } - rbZDimension.Visible = Options.Instance.Map.ZDimensionVisible; grpZResource.Visible = Options.Instance.Map.ZDimensionVisible; grpInstanceSettings.Visible = chkChangeInstance.Checked; @@ -131,6 +130,7 @@ public void Init() cmbWarpSound.Items.Clear(); RefreshMapWarpSounds(); + PopulateAttributeTypes(); } //Tiles Tab @@ -467,306 +467,290 @@ private void HideAttributeMenus() grpCritter.Visible = false; } - private void rbItem_CheckedChanged(object sender, EventArgs e) + // Used for returning an integer value depending on which radio button is selected on the forms. This is merely used to make PlaceAtrribute less messy. + private byte GetEditorDimensionGateway() { - HideAttributeMenus(); - grpItem.Visible = true; - cmbItemAttribute.Items.Clear(); - cmbItemAttribute.Items.AddRange(ItemDescriptor.Names); - if (cmbItemAttribute.Items.Count > 0) - { - cmbItemAttribute.SelectedIndex = 0; - } - nudItemRespawnTime.Value = 0; + return rbGateway1.Checked ? (byte)1 : rbGateway2.Checked ? (byte)2 : (byte)0; } - private void rbBlocked_CheckedChanged(object sender, EventArgs e) + private byte GetEditorDimensionBlock() { - HideAttributeMenus(); + return rbBlock1.Checked ? (byte)1 : rbBlock2.Checked ? (byte)2 : (byte)0; } - private void rbNPCAvoid_CheckedChanged(object sender, EventArgs e) + private static readonly Dictionary AttributeTypeStrings = new() { - HideAttributeMenus(); - } + {MapAttributeType.Animation, Strings.Attributes.MapAnimation}, + {MapAttributeType.Blocked,Strings.Attributes.Blocked}, + {MapAttributeType.Critter,Strings.Attributes.Critter}, + {MapAttributeType.GrappleStone,Strings.Attributes.Grapple}, + {MapAttributeType.Item,Strings.Attributes.ItemSpawn}, + {MapAttributeType.NpcAvoid,Strings.Attributes.NpcAvoid}, + {MapAttributeType.Resource,Strings.Attributes.ResourceSpawn}, + {MapAttributeType.Sound,Strings.Attributes.MapSound}, + {MapAttributeType.Slide,Strings.Attributes.Slide}, + {MapAttributeType.Warp,Strings.Attributes.Warp}, + {MapAttributeType.ZDimension,Strings.Attributes.ZDimension}, + }; - private void rbZDimension_CheckedChanged(object sender, EventArgs e) - { - HideAttributeMenus(); - grpZDimension.Visible = true; - } + private static readonly Dictionary AttributeTypeStringToEnum = + AttributeTypeStrings.ToDictionary(kvp => kvp.Value, kvp => kvp.Key); - private void rbWarp_CheckedChanged(object sender, EventArgs e) + private void PopulateAttributeTypes() { - nudWarpX.Maximum = Options.Instance.Map.MapWidth; - nudWarpY.Maximum = Options.Instance.Map.MapHeight; - cmbWarpMap.Items.Clear(); - for (var i = 0; i < MapList.OrderedMaps.Count; i++) - { - cmbWarpMap.Items.Add(MapList.OrderedMaps[i].Name); - } + var attributeTypes = Enum.GetValues(typeof(MapAttributeType)) + .Cast().Where(type => type != MapAttributeType.Walkable); - cmbWarpMap.SelectedIndex = 0; - cmbDirection.SelectedIndex = 0; - if (!rbWarp.Checked) + cmbAttributeType.Items.Clear(); + foreach (var type in attributeTypes) { - return; + if (type == MapAttributeType.ZDimension && !Options.Instance.Map.ZDimensionVisible) + { + continue; + } + cmbAttributeType.Items.Add(AttributeTypeStrings.TryGetValue(type, out var str) ? str : type.ToString()); } - HideAttributeMenus(); - RefreshMapWarpSounds(); - grpWarp.Visible = true; + cmbAttributeType.SelectedIndex = cmbAttributeType.Items.Count > 0 ? 0 : -1; } - private void rbSound_CheckedChanged(object sender, EventArgs e) + private void cmbAttributeType_SelectedIndexChanged(object sender, EventArgs e) { HideAttributeMenus(); - grpSound.Visible = true; - cmbMapAttributeSound.Items.Clear(); - cmbMapAttributeSound.Items.Add(Strings.General.None); - cmbMapAttributeSound.Items.AddRange(GameContentManager.SmartSortedSoundNames); - cmbMapAttributeSound.SelectedIndex = 0; - } - private void rbResource_CheckedChanged(object sender, EventArgs e) - { - cmbResourceAttribute.Items.Clear(); - cmbResourceAttribute.Items.AddRange(ResourceDescriptor.Names); - if (cmbResourceAttribute.Items.Count > 0) + if (cmbAttributeType.SelectedItem is not string selectedTypeString || + !AttributeTypeStringToEnum.TryGetValue(selectedTypeString, out var selectedType)) { - cmbResourceAttribute.SelectedIndex = 0; + return; } - if (!rbResource.Checked) + switch (selectedType) { - return; - } + case MapAttributeType.Item: + grpItem.Visible = true; + cmbItemAttribute.Items.Clear(); + cmbItemAttribute.Items.AddRange(ItemDescriptor.Names); + if (cmbItemAttribute.Items.Count > 0) + { + cmbItemAttribute.SelectedIndex = 0; + } - HideAttributeMenus(); - grpResource.Visible = true; - } + nudItemRespawnTime.Value = 0; + break; + case MapAttributeType.ZDimension: + grpZDimension.Visible = true; + break; + case MapAttributeType.Warp: + grpWarp.Visible = true; + nudWarpX.Maximum = Options.Instance.Map.MapWidth; + nudWarpY.Maximum = Options.Instance.Map.MapHeight; + cmbWarpMap.Items.Clear(); + for (var i = 0; i < MapList.OrderedMaps.Count; i++) + { + cmbWarpMap.Items.Add(MapList.OrderedMaps[i].Name); + } - // Used for returning an integer value depending on which radio button is selected on the forms. This is merely used to make PlaceAtrribute less messy. - private byte GetEditorDimensionGateway() - { - if (rbGateway1.Checked == true) - { - return 1; - } - else if (rbGateway2.Checked == true) - { - return 2; - } + cmbWarpMap.SelectedIndex = 0; + cmbDirection.SelectedIndex = 0; + RefreshMapWarpSounds(); + break; + case MapAttributeType.Sound: + grpSound.Visible = true; + cmbMapAttributeSound.Items.Clear(); + cmbMapAttributeSound.Items.Add(Strings.General.None); + cmbMapAttributeSound.Items.AddRange(GameContentManager.SmartSortedSoundNames); + cmbMapAttributeSound.SelectedIndex = 0; + break; + case MapAttributeType.Resource: + grpResource.Visible = true; + cmbResourceAttribute.Items.Clear(); + cmbResourceAttribute.Items.AddRange(ResourceDescriptor.Names); + if (cmbResourceAttribute.Items.Count > 0) + { + cmbResourceAttribute.SelectedIndex = 0; + } - return 0; - } + break; + case MapAttributeType.Animation: + grpAnimation.Visible = true; + cmbAnimationAttribute.Items.Clear(); + cmbAnimationAttribute.Items.AddRange(AnimationDescriptor.Names); + if (cmbAnimationAttribute.Items.Count > 0) + { + cmbAnimationAttribute.SelectedIndex = 0; + } - private byte GetEditorDimensionBlock() - { - if (rbBlock1.Checked == true) - { - return 1; - } - else if (rbBlock2.Checked == true) - { - return 2; - } + break; + case MapAttributeType.Slide: + grpSlide.Visible = true; + cmbSlideDir.SelectedIndex = 0; + break; + case MapAttributeType.Critter: + grpCritter.Visible = true; + cmbCritterAnimation.Items.Clear(); + cmbCritterAnimation.Items.Add(Strings.General.None); + cmbCritterAnimation.Items.AddRange(AnimationDescriptor.Names); + cmbCritterAnimation.SelectedIndex = 0; + cmbCritterSprite.Items.Clear(); + cmbCritterSprite.Items.Add(Strings.General.None); + cmbCritterSprite.Items.AddRange( + GameContentManager.GetSmartSortedTextureNames(GameContentManager.TextureType.Entity) + ); + cmbCritterSprite.SelectedIndex = 0; + if (nudCritterMoveFrequency.Value == 0) + { + nudCritterMoveFrequency.Value = 1000; + } - return 0; - } + if (nudCritterMoveSpeed.Value == 0) + { + nudCritterMoveSpeed.Value = 400; + } - public int GetAttributeFromEditor() - { - if (rbBlocked.Checked == true) - { - return (int) MapAttributeType.Blocked; - } - else if (rbItem.Checked == true) - { - return (int) MapAttributeType.Item; - } - else if (rbZDimension.Checked == true) - { - return (int) MapAttributeType.ZDimension; - } - else if (rbNPCAvoid.Checked == true) - { - return (int) MapAttributeType.NpcAvoid; - } - else if (rbWarp.Checked == true) - { - return (int) MapAttributeType.Warp; - } - else if (rbSound.Checked == true) - { - return (int) MapAttributeType.Sound; - } - else if (rbResource.Checked == true) - { - return (int) MapAttributeType.Resource; - } - else if (rbAnimation.Checked == true) - { - return (int) MapAttributeType.Animation; - } - else if (rbGrappleStone.Checked == true) - { - return (int) MapAttributeType.GrappleStone; - } - else if (rbSlide.Checked == true) - { - return (int) MapAttributeType.Slide; - } - else if (rbCritter.Checked == true) - { - return (int) MapAttributeType.Critter; + break; + default: + // For Blocked, GrappleStone, NpcAvoid, etc. + break; } - - return (int) MapAttributeType.Walkable; } private MapAttributeType SelectedMapAttributeType { get { - if (rbBlocked.Checked) - { - return MapAttributeType.Blocked; - } - - if (rbItem.Checked) + if (cmbAttributeType.SelectedItem is string selectedString && + AttributeTypeStringToEnum.TryGetValue(selectedString, out var type)) { - return MapAttributeType.Item; + return type; } - if (rbZDimension.Checked) - { - return MapAttributeType.ZDimension; - } - - if (rbNPCAvoid.Checked) - { - return MapAttributeType.NpcAvoid; - } - - if (rbWarp.Checked) - { - return MapAttributeType.Warp; - } - - if (rbSound.Checked) - { - return MapAttributeType.Sound; - } - - if (rbResource.Checked) - { - return MapAttributeType.Resource; - } - - if (rbAnimation.Checked) - { - return MapAttributeType.Animation; - } - - if (rbGrappleStone.Checked) - { - return MapAttributeType.GrappleStone; - } - - if (rbSlide.Checked) - { - return MapAttributeType.Slide; - } - - if (rbCritter.Checked) - { - return MapAttributeType.Critter; - } - - return (MapAttributeType) byte.MaxValue; + return MapAttributeType.Blocked; } } - [Obsolete("The entire switch statement should be implemented as a parameterized CreateAttribute().")] public MapAttribute CreateAttribute() { var attributeType = SelectedMapAttributeType; - var attribute = MapAttribute.CreateAttribute(attributeType); - switch (SelectedMapAttributeType) + return CreateAttribute(attributeType); + } + + public MapAttribute CreateAttribute(MapAttributeType attributeType) + { + switch (attributeType) { case MapAttributeType.Walkable: case MapAttributeType.Blocked: case MapAttributeType.GrappleStone: case MapAttributeType.NpcAvoid: - break; + return MapAttribute.CreateAttribute(attributeType); case MapAttributeType.Item: - var itemAttribute = attribute as MapItemAttribute; - itemAttribute.ItemId = ItemDescriptor.IdFromList(cmbItemAttribute.SelectedIndex); - itemAttribute.Quantity = (int)nudItemQuantity.Value; - itemAttribute.RespawnTime = (long)nudItemRespawnTime.Value; - break; + return CreateItemAttribute(); case MapAttributeType.ZDimension: - var zDimensionAttribute = attribute as MapZDimensionAttribute; - zDimensionAttribute.GatewayTo = GetEditorDimensionGateway(); - zDimensionAttribute.BlockedLevel = GetEditorDimensionBlock(); - break; + return CreateZDimensionAttribute(); case MapAttributeType.Warp: - var warpAttribute = attribute as MapWarpAttribute; - warpAttribute.MapId = MapList.OrderedMaps[cmbWarpMap.SelectedIndex].MapId; - warpAttribute.X = (byte)nudWarpX.Value; - warpAttribute.Y = (byte)nudWarpY.Value; - warpAttribute.Direction = (WarpDirection)cmbDirection.SelectedIndex; - warpAttribute.ChangeInstance = chkChangeInstance.Checked; - warpAttribute.InstanceType = (MapInstanceType)cmbInstanceType.SelectedIndex; - warpAttribute.WarpSound = TextUtils.SanitizeNone(cmbWarpSound.Text); - break; + return CreateWarpAttribute(); case MapAttributeType.Sound: - var soundAttribute = attribute as MapSoundAttribute; - soundAttribute.Distance = (byte)nudSoundDistance.Value; - soundAttribute.File = TextUtils.SanitizeNone(cmbMapAttributeSound.Text); - soundAttribute.LoopInterval = (int)nudSoundLoopInterval.Value; - break; + return CreateSoundAttribute(); case MapAttributeType.Resource: - var resourceAttribute = attribute as MapResourceAttribute; - resourceAttribute.ResourceId = ResourceDescriptor.IdFromList(cmbResourceAttribute.SelectedIndex); - resourceAttribute.SpawnLevel = (byte)(rbLevel1.Checked ? 0 : 1); - break; + return CreateResourceAttribute(); case MapAttributeType.Animation: - var animationAttribute = attribute as MapAnimationAttribute; - animationAttribute.AnimationId = AnimationDescriptor.IdFromList(cmbAnimationAttribute.SelectedIndex); - animationAttribute.IsBlock = chkAnimationBlock.Checked; - break; + return CreateAnimationAttribute(); case MapAttributeType.Slide: - var slideAttribute = attribute as MapSlideAttribute; - slideAttribute.Direction = (Direction)cmbSlideDir.SelectedIndex; - break; + return CreateSlideAttribute(); case MapAttributeType.Critter: - var critterAttribute = attribute as MapCritterAttribute; - critterAttribute.Sprite = cmbCritterSprite.Text; - critterAttribute.AnimationId = AnimationDescriptor.IdFromList(cmbCritterAnimation.SelectedIndex - 1); - critterAttribute.Movement = (byte)cmbCritterMovement.SelectedIndex; - critterAttribute.Layer = (byte)cmbCritterLayer.SelectedIndex; - critterAttribute.Speed = (int)nudCritterMoveSpeed.Value; - critterAttribute.Frequency = (int)nudCritterMoveFrequency.Value; - critterAttribute.IgnoreNpcAvoids = chkCritterIgnoreNpcAvoids.Checked; - critterAttribute.BlockPlayers = chkCritterBlockPlayers.Checked; - critterAttribute.Direction = (byte)cmbCritterDirection.SelectedIndex; - break; + return CreateCritterAttribute(); default: - throw new ArgumentOutOfRangeException(nameof(SelectedMapAttributeType), @"The currently selected attribute type has not been fully implemented."); + throw new ArgumentOutOfRangeException( + nameof(attributeType), + @"The currently selected attribute type has not been fully implemented." + ); } + } - return attribute; + private MapItemAttribute CreateItemAttribute() + { + var itemAttribute = (MapItemAttribute)MapAttribute.CreateAttribute(MapAttributeType.Item); + itemAttribute.ItemId = ItemDescriptor.IdFromList(cmbItemAttribute.SelectedIndex); + itemAttribute.Quantity = (int)nudItemQuantity.Value; + itemAttribute.RespawnTime = (long)nudItemRespawnTime.Value; + return itemAttribute; + } + + private MapZDimensionAttribute CreateZDimensionAttribute() + { + var zDimensionAttribute = (MapZDimensionAttribute)MapAttribute.CreateAttribute(MapAttributeType.ZDimension); + zDimensionAttribute.GatewayTo = GetEditorDimensionGateway(); + zDimensionAttribute.BlockedLevel = GetEditorDimensionBlock(); + return zDimensionAttribute; + } + + private MapWarpAttribute CreateWarpAttribute() + { + var warpAttribute = (MapWarpAttribute)MapAttribute.CreateAttribute(MapAttributeType.Warp); + warpAttribute.MapId = MapList.OrderedMaps[cmbWarpMap.SelectedIndex].MapId; + warpAttribute.X = (byte)nudWarpX.Value; + warpAttribute.Y = (byte)nudWarpY.Value; + warpAttribute.Direction = (WarpDirection)cmbDirection.SelectedIndex; + warpAttribute.ChangeInstance = chkChangeInstance.Checked; + warpAttribute.InstanceType = (MapInstanceType)cmbInstanceType.SelectedIndex; + warpAttribute.WarpSound = TextUtils.SanitizeNone(cmbWarpSound.Text); + return warpAttribute; + } + + private MapSoundAttribute CreateSoundAttribute() + { + var soundAttribute = (MapSoundAttribute)MapAttribute.CreateAttribute(MapAttributeType.Sound); + soundAttribute.Distance = (byte)nudSoundDistance.Value; + soundAttribute.File = TextUtils.SanitizeNone(cmbMapAttributeSound.Text); + soundAttribute.LoopInterval = (int)nudSoundLoopInterval.Value; + return soundAttribute; + } + + private MapResourceAttribute CreateResourceAttribute() + { + var resourceAttribute = (MapResourceAttribute)MapAttribute.CreateAttribute(MapAttributeType.Resource); + resourceAttribute.ResourceId = ResourceDescriptor.IdFromList(cmbResourceAttribute.SelectedIndex); + resourceAttribute.SpawnLevel = (byte)(rbLevel1.Checked ? 0 : 1); + return resourceAttribute; + } + + private MapAnimationAttribute CreateAnimationAttribute() + { + var animationAttribute = (MapAnimationAttribute)MapAttribute.CreateAttribute(MapAttributeType.Animation); + animationAttribute.AnimationId = AnimationDescriptor.IdFromList(cmbAnimationAttribute.SelectedIndex); + animationAttribute.IsBlock = chkAnimationBlock.Checked; + return animationAttribute; + } + + private MapSlideAttribute CreateSlideAttribute() + { + var slideAttribute = (MapSlideAttribute)MapAttribute.CreateAttribute(MapAttributeType.Slide); + slideAttribute.Direction = (Direction)cmbSlideDir.SelectedIndex; + return slideAttribute; + } + + private MapCritterAttribute CreateCritterAttribute() + { + var critterAttribute = (MapCritterAttribute)MapAttribute.CreateAttribute(MapAttributeType.Critter); + critterAttribute.Sprite = cmbCritterSprite.Text; + critterAttribute.AnimationId = AnimationDescriptor.IdFromList(cmbCritterAnimation.SelectedIndex - 1); + critterAttribute.Movement = (byte)cmbCritterMovement.SelectedIndex; + critterAttribute.Layer = (byte)cmbCritterLayer.SelectedIndex; + critterAttribute.Speed = (int)nudCritterMoveSpeed.Value; + critterAttribute.Frequency = (int)nudCritterMoveFrequency.Value; + critterAttribute.IgnoreNpcAvoids = chkCritterIgnoreNpcAvoids.Checked; + critterAttribute.BlockPlayers = chkCritterBlockPlayers.Checked; + critterAttribute.Direction = (byte)cmbCritterDirection.SelectedIndex; + return critterAttribute; } public MapAttribute PlaceAttribute(MapDescriptor mapDescriptor, int x, int y, MapAttribute attribute = null) @@ -996,55 +980,6 @@ private void btnVisualMapSelector_Click(object sender, EventArgs e) } } - private void rbAnimation_CheckedChanged(object sender, EventArgs e) - { - cmbAnimationAttribute.Items.Clear(); - cmbAnimationAttribute.Items.AddRange(AnimationDescriptor.Names); - if (cmbAnimationAttribute.Items.Count > 0) - { - cmbAnimationAttribute.SelectedIndex = 0; - } - - if (!rbAnimation.Checked) - { - return; - } - - HideAttributeMenus(); - grpAnimation.Visible = true; - } - - private void rbCritter_CheckedChanged(object sender, EventArgs e) - { - cmbCritterAnimation.Items.Clear(); - cmbCritterAnimation.Items.Add(Strings.General.None); - cmbCritterAnimation.Items.AddRange(AnimationDescriptor.Names); - cmbCritterAnimation.SelectedIndex = 0; - - cmbCritterSprite.Items.Clear(); - cmbCritterSprite.Items.Add(Strings.General.None); - cmbCritterSprite.Items.AddRange(GameContentManager.GetSmartSortedTextureNames(GameContentManager.TextureType.Entity)); - cmbCritterSprite.SelectedIndex = 0; - - if (nudCritterMoveFrequency.Value == 0) - { - nudCritterMoveFrequency.Value = 1000; - } - - if (nudCritterMoveSpeed.Value == 0) - { - nudCritterMoveSpeed.Value = 400; - } - - if (!rbCritter.Checked) - { - return; - } - - HideAttributeMenus(); - grpCritter.Visible = true; - } - private void frmMapLayers_Load(object sender, EventArgs e) { CreateSwapChain(); @@ -1077,19 +1012,6 @@ private void InitLocalization() cmbAutotile.Items.Add(Strings.Tiles.autotilexp); cmbAutotile.Items.Add(Strings.Tiles.animatedxp); - //Attributes Panel - rbBlocked.Text = Strings.Attributes.Blocked; - rbZDimension.Text = Strings.Attributes.ZDimension; - rbNPCAvoid.Text = Strings.Attributes.NpcAvoid; - rbWarp.Text = Strings.Attributes.Warp; - rbItem.Text = Strings.Attributes.ItemSpawn; - rbSound.Text = Strings.Attributes.MapSound; - rbResource.Text = Strings.Attributes.ResourceSpawn; - rbAnimation.Text = Strings.Attributes.MapAnimation; - rbGrappleStone.Text = Strings.Attributes.Grapple; - rbSlide.Text = Strings.Attributes.Slide; - rbCritter.Text = Strings.Attributes.Critter; - //Map Animation Groupbox grpAnimation.Text = Strings.Attributes.MapAnimation; lblAnimation.Text = Strings.Attributes.MapAnimation; @@ -1237,18 +1159,6 @@ private void CreateSwapChain() } } - private void rbGrappleStone_CheckedChanged(object sender, EventArgs e) - { - HideAttributeMenus(); - } - - private void rbSlide_CheckedChanged(object sender, EventArgs e) - { - HideAttributeMenus(); - grpSlide.Visible = true; - cmbSlideDir.SelectedIndex = 0; - } - private void lstMapNpcs_MouseDown(object sender, MouseEventArgs e) { lstMapNpcs.SelectedIndex = lstMapNpcs.IndexFromPoint(e.Location); @@ -1267,11 +1177,6 @@ private void ChangeTab() pnlEvents.Hide(); pnlNpcs.Hide(); - //Force Game Object Lists to Refresh - rbAnimation_CheckedChanged(null, null); - rbWarp_CheckedChanged(null, null); - rbResource_CheckedChanged(null, null); - if (Globals.EditingLight != null) { Globals.MapLayersWindow.lightEditor.Cancel();