From 70e59cc24eca0ddc6358c1adb179956456b825a0 Mon Sep 17 00:00:00 2001 From: WeylonSantana Date: Sat, 22 Mar 2025 16:23:47 -0300 Subject: [PATCH 01/55] starting replacing old resource state by the new one --- .../Resources/ResourceDescriptor.cs | 20 +++++++++++-------- .../Resources/ResourceGraphicType.cs | 8 ++++++++ .../Resources/ResourceStateDescriptor.cs | 12 ++++++++--- 3 files changed, 29 insertions(+), 11 deletions(-) create mode 100644 Framework/Intersect.Framework.Core/GameObjects/Resources/ResourceGraphicType.cs diff --git a/Framework/Intersect.Framework.Core/GameObjects/Resources/ResourceDescriptor.cs b/Framework/Intersect.Framework.Core/GameObjects/Resources/ResourceDescriptor.cs index 09bacf6a8a..c864234a8a 100644 --- a/Framework/Intersect.Framework.Core/GameObjects/Resources/ResourceDescriptor.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/Resources/ResourceDescriptor.cs @@ -3,7 +3,6 @@ using Intersect.Framework.Core.GameObjects.Conditions; using Intersect.Framework.Core.GameObjects.Events; using Intersect.Framework.Core.GameObjects.Items; -using Intersect.GameObjects; using Intersect.Models; using Newtonsoft.Json; @@ -23,22 +22,27 @@ public partial class ResourceDescriptor : DatabaseObject, IF public ResourceDescriptor(Guid id) : base(id) { Name = "New Resource"; - Initial = new ResourceStateDescriptor(); - Exhausted = new ResourceStateDescriptor(); + HealthGraphics = []; } //EF wants NO PARAMETERS!!!!! public ResourceDescriptor() { Name = "New Resource"; - Initial = new ResourceStateDescriptor(); - Exhausted = new ResourceStateDescriptor(); + HealthGraphics = []; } - // Graphics - public ResourceStateDescriptor Initial { get; set; } + public bool UseExplicitMaxHealthForResourceStates { get; set; } - public ResourceStateDescriptor Exhausted { get; set; } + [NotMapped, JsonIgnore] + public Dictionary HealthGraphics { get; set; } + + [Column("HealthGraphics")] + public string JsonHealthGraphics + { + get => JsonConvert.SerializeObject(HealthGraphics); + set => HealthGraphics = JsonConvert.DeserializeObject>(value); + } [Column("Animation")] public Guid AnimationId { get; set; } diff --git a/Framework/Intersect.Framework.Core/GameObjects/Resources/ResourceGraphicType.cs b/Framework/Intersect.Framework.Core/GameObjects/Resources/ResourceGraphicType.cs new file mode 100644 index 0000000000..9dad9264fc --- /dev/null +++ b/Framework/Intersect.Framework.Core/GameObjects/Resources/ResourceGraphicType.cs @@ -0,0 +1,8 @@ +namespace Intersect.Framework.Core.GameObjects.Resources; + +public enum ResourceGraphicType +{ + Graphic, + Tileset, + Animation, +} diff --git a/Framework/Intersect.Framework.Core/GameObjects/Resources/ResourceStateDescriptor.cs b/Framework/Intersect.Framework.Core/GameObjects/Resources/ResourceStateDescriptor.cs index 53264d952b..8a5be02a11 100644 --- a/Framework/Intersect.Framework.Core/GameObjects/Resources/ResourceStateDescriptor.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/Resources/ResourceStateDescriptor.cs @@ -1,15 +1,21 @@ -using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; namespace Intersect.Framework.Core.GameObjects.Resources; [Owned] public partial class ResourceStateDescriptor { - public string Graphic { get; set; } = null; + public string Graphic { get; set; } = default; + + public ResourceGraphicType GraphicType { get; set; } = ResourceGraphicType.Graphic; public bool RenderBelowEntities { get; set; } - public bool GraphicFromTileset { get; set; } + public Guid AnimationId { get; set; } = Guid.Empty; + + public int MinHp { get; set; } + + public int MaxHp { get; set; } public int X { get; set; } From 483c1bd76128c610c85aa9756d73a0eb3f246f2f Mon Sep 17 00:00:00 2001 From: WeylonSantana Date: Thu, 20 Mar 2025 15:26:56 -0300 Subject: [PATCH 02/55] update sprite on server --- Intersect.Server.Core/Entities/Entity.cs | 2 +- Intersect.Server.Core/Entities/Resource.cs | 31 +++++++++++++++++++--- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/Intersect.Server.Core/Entities/Entity.cs b/Intersect.Server.Core/Entities/Entity.cs index ed1f6f6a3a..4338c619d8 100644 --- a/Intersect.Server.Core/Entities/Entity.cs +++ b/Intersect.Server.Core/Entities/Entity.cs @@ -1557,7 +1557,7 @@ public void AddVital(Vital vital, long amount) SetVital(vital, GetVital(vital) + safeAmount); } - public void SubVital(Vital vital, long amount) + public virtual void SubVital(Vital vital, long amount) { if (!Enum.IsDefined(vital)) { diff --git a/Intersect.Server.Core/Entities/Resource.cs b/Intersect.Server.Core/Entities/Resource.cs index 22839d0567..344d437613 100644 --- a/Intersect.Server.Core/Entities/Resource.cs +++ b/Intersect.Server.Core/Entities/Resource.cs @@ -2,7 +2,6 @@ using Intersect.Framework.Core.GameObjects.Items; using Intersect.Framework.Core.GameObjects.Resources; using Intersect.Framework.Reflection; -using Intersect.GameObjects; using Intersect.Network.Packets.Server; using Intersect.Server.Database; using Intersect.Server.Database.PlayerData.Players; @@ -24,13 +23,14 @@ public Resource(ResourceDescriptor descriptor) Descriptor = descriptor; Name = descriptor.Name; - Sprite = descriptor.Initial.Graphic; + SetMaxVital( Vital.Health, Randomization.Next(Math.Min(1, descriptor.MinHp), Math.Max(descriptor.MaxHp, Math.Min(1, descriptor.MinHp)) + 1) ); RestoreVital(Vital.Health); + HandleSprite(); Passable = descriptor.WalkableBefore; HideName = true; } @@ -46,6 +46,29 @@ public void Destroy(bool dropItems = false, Entity killer = null) PacketSender.SendEntityLeave(this); } + private void HandleSprite() + { + var graphicStates = Descriptor.HealthGraphics.Values.ToList(); + var currentHealthPercentage = Math.Floor((float)GetVital(Vital.Health) / GetMaxVital(Vital.Health)); + var currentGraphicState = graphicStates.FirstOrDefault( + state => currentHealthPercentage >= state.MinHp && currentHealthPercentage <= state.MaxHp + ); + + if (currentGraphicState is null || currentGraphicState.GraphicType == ResourceGraphicType.Animation) + { + Sprite = default; + return; + } + + Sprite = currentGraphicState.Graphic; + } + + public override void SubVital(Vital vital, long amount) + { + base.SubVital(vital, amount); + HandleSprite(); + } + public override void Die(bool dropItems = true, Entity killer = null) { lock (EntityLock) @@ -53,7 +76,7 @@ public override void Die(bool dropItems = true, Entity killer = null) base.Die(false, killer); } - Sprite = Descriptor.Exhausted.Graphic; + HandleSprite(); Passable = Descriptor.WalkableAfter; IsDead = true; @@ -68,7 +91,7 @@ public override void Die(bool dropItems = true, Entity killer = null) public void Spawn() { - Sprite = Descriptor.Initial.Graphic; + HandleSprite(); var minimumHealth = Descriptor.MinHp; var maximumHealth = Descriptor.MaxHp; From ceba4ea338cf416f78329f5b6abb58884ef09616 Mon Sep 17 00:00:00 2001 From: WeylonSantana Date: Thu, 20 Mar 2025 15:27:31 -0300 Subject: [PATCH 03/55] finished on editor, adding controls and render on map --- Intersect.Editor/Core/Graphics.cs | 123 +- Intersect.Editor/Core/Main.cs | 8 +- .../Forms/Editors/frmResource.Designer.cs | 605 ++++++---- Intersect.Editor/Forms/Editors/frmResource.cs | 1003 ++++++++++------- .../Forms/Editors/frmResource.resx | 4 +- Intersect.Editor/Localization/Strings.cs | 43 +- 6 files changed, 1061 insertions(+), 725 deletions(-) diff --git a/Intersect.Editor/Core/Graphics.cs b/Intersect.Editor/Core/Graphics.cs index 5c4129a160..a2c1ac9224 100644 --- a/Intersect.Editor/Core/Graphics.cs +++ b/Intersect.Editor/Core/Graphics.cs @@ -1388,65 +1388,96 @@ bool alternate continue; } - if (TextUtils.IsNone(resource.Initial.Graphic)) + if (resource.HealthGraphics.Count == 0) { continue; } - if (resource.Initial.GraphicFromTileset) + var fullVitalResourceGraphic = resource.HealthGraphics.FirstOrDefault( + g => g.Value.MaxHp == 100 + ); + + if (fullVitalResourceGraphic.Value is not { MaxHp: 100 } resourceGraphic) { - var res = GameContentManager.GetTexture( - GameContentManager.TextureType.Tileset, resource.Initial.Graphic - ); + continue; + } - if (res == null) - { - continue; - } + // we have the graphic, now lets build based on type + switch(resourceGraphic.GraphicType) + { + case ResourceGraphicType.Graphic: + { + var texture = GameContentManager.GetTexture( + GameContentManager.TextureType.Resource, resourceGraphic.Graphic + ); - float xpos = x * Options.Instance.Map.TileWidth + xoffset; - float ypos = y * Options.Instance.Map.TileHeight + yoffset; - if ((resource.Initial.Height + 1) * Options.Instance.Map.TileHeight > Options.Instance.Map.TileHeight) - { - ypos -= (resource.Initial.Height + 1) * Options.Instance.Map.TileHeight - Options.Instance.Map.TileHeight; - } + if (texture == null) + { + continue; + } - if ((resource.Initial.Width + 1) * Options.Instance.Map.TileWidth > Options.Instance.Map.TileWidth) - { - xpos -= ((resource.Initial.Width + 1) * Options.Instance.Map.TileWidth - Options.Instance.Map.TileWidth) / 2; - } + float xpos = x * Options.Instance.Map.TileWidth + xoffset; + float ypos = y * Options.Instance.Map.TileHeight + yoffset; - DrawTexture( - res, xpos, ypos, resource.Initial.X * Options.Instance.Map.TileWidth, - resource.Initial.Y * Options.Instance.Map.TileHeight, - (resource.Initial.Width + 1) * Options.Instance.Map.TileWidth, - (resource.Initial.Height + 1) * Options.Instance.Map.TileHeight, renderTarget - ); - } - else - { - var res = GameContentManager.GetTexture( - GameContentManager.TextureType.Resource, resource.Initial.Graphic - ); + if (texture.Height > Options.Instance.Map.TileHeight) + { + ypos -= texture.Height - Options.Instance.Map.TileHeight; + } - if (res == null) - { - continue; - } + if (texture.Width > Options.Instance.Map.TileWidth) + { + xpos -= (texture.Width - Options.Instance.Map.TileWidth) / 2; + } - float xpos = x * Options.Instance.Map.TileWidth + xoffset; - float ypos = y * Options.Instance.Map.TileHeight + yoffset; - if (res.Height > Options.Instance.Map.TileHeight) - { - ypos -= res.Height - Options.Instance.Map.TileHeight; - } + DrawTexture( + texture, xpos, ypos, 0, 0, texture.Width, texture.Height, renderTarget + ); + } + break; - if (res.Width > Options.Instance.Map.TileWidth) - { - xpos -= (res.Width - Options.Instance.Map.TileWidth) / 2; - } + case ResourceGraphicType.Tileset: + { + var texture = GameContentManager.GetTexture( + GameContentManager.TextureType.Tileset, resourceGraphic.Graphic + ); + + if (texture == null) + { + continue; + } + + float xpos = x * Options.Instance.Map.TileWidth + xoffset; + float ypos = y * Options.Instance.Map.TileHeight + yoffset; + + if ((resourceGraphic.Height + 1) * Options.Instance.Map.TileHeight > Options.Instance.Map.TileHeight) + { + ypos -= (resourceGraphic.Height + 1) * Options.Instance.Map.TileHeight - Options.Instance.Map.TileHeight; + } + + if ((resourceGraphic.Width + 1) * Options.Instance.Map.TileWidth > Options.Instance.Map.TileWidth) + { + xpos -= ((resourceGraphic.Width + 1) * Options.Instance.Map.TileWidth - Options.Instance.Map.TileWidth) / 2; + } - DrawTexture(res, xpos, ypos, 0, 0, res.Width, res.Height, renderTarget); + DrawTexture( + texture, xpos, ypos, resourceGraphic.X * Options.Instance.Map.TileWidth, + resourceGraphic.Y * Options.Instance.Map.TileHeight, + (resourceGraphic.Width + 1) * Options.Instance.Map.TileWidth, + (resourceGraphic.Height + 1) * Options.Instance.Map.TileHeight, renderTarget + ); + } + break; + + case ResourceGraphicType.Animation: + //TODO: FIX THIS + break; + + default: + throw new ArgumentOutOfRangeException( + nameof(resourceGraphic.GraphicType), + resourceGraphic.GraphicType, + "Unknown ResourceGraphicType" + ); } } else if (tmpMap.Attributes[x, y].Type == MapAttributeType.Animation) diff --git a/Intersect.Editor/Core/Main.cs b/Intersect.Editor/Core/Main.cs index 5c65cd0271..acf0800823 100644 --- a/Intersect.Editor/Core/Main.cs +++ b/Intersect.Editor/Core/Main.cs @@ -1,4 +1,4 @@ -using Intersect.Editor.Content; +using Intersect.Editor.Content; using Intersect.Editor.Forms; using Intersect.Editor.General; using Intersect.Editor.Localization; @@ -52,12 +52,6 @@ public static void StartLoop() public static void DrawFrame() { - //Check Editors - if (Globals.ResourceEditor != null && Globals.ResourceEditor.IsDisposed == false) - { - Globals.ResourceEditor.Render(); - } - if (Globals.MapGrid == null) { return; diff --git a/Intersect.Editor/Forms/Editors/frmResource.Designer.cs b/Intersect.Editor/Forms/Editors/frmResource.Designer.cs index abcaa73d8f..9e7a45f95f 100644 --- a/Intersect.Editor/Forms/Editors/frmResource.Designer.cs +++ b/Intersect.Editor/Forms/Editors/frmResource.Designer.cs @@ -37,14 +37,15 @@ private void InitializeComponent() txtSearch = new DarkTextBox(); lstGameObjects = new Controls.GameObjectList(); grpGeneral = new DarkGroupBox(); + chkUseExplicitMaxHealthForResourceStates = new DarkCheckBox(); btnAddFolder = new DarkButton(); lblFolder = new Label(); cmbFolder = new DarkComboBox(); nudMaxHp = new DarkNumericUpDown(); nudMinHp = new DarkNumericUpDown(); nudSpawnDuration = new DarkNumericUpDown(); - cmbAnimation = new DarkComboBox(); - lblAnimation = new Label(); + cmbDeathAnimation = new DarkComboBox(); + lblDeathAnimation = new Label(); lblMaxHp = new Label(); lblSpawnDuration = new Label(); chkWalkableAfter = new DarkCheckBox(); @@ -56,18 +57,25 @@ private void InitializeComponent() txtName = new DarkTextBox(); btnRequirements = new DarkButton(); grpGraphics = new DarkGroupBox(); - chkExhaustedBelowEntities = new DarkCheckBox(); - chkInitialBelowEntities = new DarkCheckBox(); - chkExhaustedFromTileset = new DarkCheckBox(); - chkInitialFromTileset = new DarkCheckBox(); - exhaustedGraphicContainer = new Panel(); - picEndResource = new PictureBox(); - initalGraphicContainer = new Panel(); - picInitialResource = new PictureBox(); - cmbEndSprite = new DarkComboBox(); - lblPic2 = new Label(); - cmbInitialSprite = new DarkComboBox(); - lblPic = new Label(); + btnRemoveHealthState = new DarkButton(); + btnAddHealthState = new DarkButton(); + lblHealthStateName = new Label(); + lstHealthState = new ListBox(); + txtHealthStateName = new DarkTextBox(); + grpGraphicData = new DarkGroupBox(); + nudHealthRangeMax = new DarkNumericUpDown(); + nudHealthRangeMin = new DarkNumericUpDown(); + lblHealthRange = new Label(); + cmbGraphicFile = new DarkComboBox(); + lblGraphicFile = new Label(); + cmbAnimation = new DarkComboBox(); + lblAnimation = new Label(); + chkRenderBelowEntity = new DarkCheckBox(); + cmbGraphicType = new DarkComboBox(); + lblGraphicType = new Label(); + lblHealthStates = new Label(); + graphicContainer = new Panel(); + picResource = new PictureBox(); tmrRender = new System.Windows.Forms.Timer(components); pnlContainer = new Panel(); grpRequirements = new DarkGroupBox(); @@ -111,10 +119,11 @@ private void InitializeComponent() ((System.ComponentModel.ISupportInitialize)nudMinHp).BeginInit(); ((System.ComponentModel.ISupportInitialize)nudSpawnDuration).BeginInit(); grpGraphics.SuspendLayout(); - exhaustedGraphicContainer.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)picEndResource).BeginInit(); - initalGraphicContainer.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)picInitialResource).BeginInit(); + grpGraphicData.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)nudHealthRangeMax).BeginInit(); + ((System.ComponentModel.ISupportInitialize)nudHealthRangeMin).BeginInit(); + graphicContainer.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)picResource).BeginInit(); pnlContainer.SuspendLayout(); grpRequirements.SuspendLayout(); grpCommonEvent.SuspendLayout(); @@ -191,14 +200,15 @@ private void InitializeComponent() // grpGeneral.BackColor = System.Drawing.Color.FromArgb(45, 45, 48); grpGeneral.BorderColor = System.Drawing.Color.FromArgb(90, 90, 90); + grpGeneral.Controls.Add(chkUseExplicitMaxHealthForResourceStates); grpGeneral.Controls.Add(btnAddFolder); grpGeneral.Controls.Add(lblFolder); grpGeneral.Controls.Add(cmbFolder); grpGeneral.Controls.Add(nudMaxHp); grpGeneral.Controls.Add(nudMinHp); grpGeneral.Controls.Add(nudSpawnDuration); - grpGeneral.Controls.Add(cmbAnimation); - grpGeneral.Controls.Add(lblAnimation); + grpGeneral.Controls.Add(cmbDeathAnimation); + grpGeneral.Controls.Add(lblDeathAnimation); grpGeneral.Controls.Add(lblMaxHp); grpGeneral.Controls.Add(lblSpawnDuration); grpGeneral.Controls.Add(chkWalkableAfter); @@ -213,11 +223,21 @@ private void InitializeComponent() grpGeneral.Margin = new Padding(4, 3, 4, 3); grpGeneral.Name = "grpGeneral"; grpGeneral.Padding = new Padding(4, 3, 4, 3); - grpGeneral.Size = new Size(260, 324); + grpGeneral.Size = new Size(260, 353); grpGeneral.TabIndex = 15; grpGeneral.TabStop = false; grpGeneral.Text = "General"; // + // chkUseExplicitMaxHealthForResourceStates + // + chkUseExplicitMaxHealthForResourceStates.Location = new System.Drawing.Point(7, 319); + chkUseExplicitMaxHealthForResourceStates.Margin = new Padding(4, 3, 4, 3); + chkUseExplicitMaxHealthForResourceStates.Name = "chkUseExplicitMaxHealthForResourceStates"; + chkUseExplicitMaxHealthForResourceStates.Size = new Size(246, 20); + chkUseExplicitMaxHealthForResourceStates.TabIndex = 53; + chkUseExplicitMaxHealthForResourceStates.Text = "Use explicit Max Health for States?"; + chkUseExplicitMaxHealthForResourceStates.CheckedChanged += chkUseExplicitMaxHealthForResourceStates_CheckedChanged; + // // btnAddFolder // btnAddFolder.Location = new System.Drawing.Point(224, 52); @@ -300,37 +320,37 @@ private void InitializeComponent() nudSpawnDuration.Value = new decimal(new int[] { 0, 0, 0, 0 }); nudSpawnDuration.ValueChanged += nudSpawnDuration_ValueChanged; // - // cmbAnimation - // - cmbAnimation.BackColor = System.Drawing.Color.FromArgb(69, 73, 74); - cmbAnimation.BorderColor = System.Drawing.Color.FromArgb(90, 90, 90); - cmbAnimation.BorderStyle = ButtonBorderStyle.Solid; - cmbAnimation.ButtonColor = System.Drawing.Color.FromArgb(43, 43, 43); - cmbAnimation.DrawDropdownHoverOutline = false; - cmbAnimation.DrawFocusRectangle = false; - cmbAnimation.DrawMode = DrawMode.OwnerDrawFixed; - cmbAnimation.DropDownStyle = ComboBoxStyle.DropDownList; - cmbAnimation.FlatStyle = FlatStyle.Flat; - cmbAnimation.ForeColor = System.Drawing.Color.Gainsboro; - cmbAnimation.FormattingEnabled = true; - cmbAnimation.Location = new System.Drawing.Point(88, 207); - cmbAnimation.Margin = new Padding(4, 3, 4, 3); - cmbAnimation.Name = "cmbAnimation"; - cmbAnimation.Size = new Size(157, 24); - cmbAnimation.TabIndex = 39; - cmbAnimation.Text = null; - cmbAnimation.TextPadding = new Padding(2); - cmbAnimation.SelectedIndexChanged += cmbAnimation_SelectedIndexChanged; - // - // lblAnimation - // - lblAnimation.AutoSize = true; - lblAnimation.Location = new System.Drawing.Point(7, 210); - lblAnimation.Margin = new Padding(4, 0, 4, 0); - lblAnimation.Name = "lblAnimation"; - lblAnimation.Size = new Size(66, 15); - lblAnimation.TabIndex = 36; - lblAnimation.Text = "Animation:"; + // cmbDeathAnimation + // + cmbDeathAnimation.BackColor = System.Drawing.Color.FromArgb(69, 73, 74); + cmbDeathAnimation.BorderColor = System.Drawing.Color.FromArgb(90, 90, 90); + cmbDeathAnimation.BorderStyle = ButtonBorderStyle.Solid; + cmbDeathAnimation.ButtonColor = System.Drawing.Color.FromArgb(43, 43, 43); + cmbDeathAnimation.DrawDropdownHoverOutline = false; + cmbDeathAnimation.DrawFocusRectangle = false; + cmbDeathAnimation.DrawMode = DrawMode.OwnerDrawFixed; + cmbDeathAnimation.DropDownStyle = ComboBoxStyle.DropDownList; + cmbDeathAnimation.FlatStyle = FlatStyle.Flat; + cmbDeathAnimation.ForeColor = System.Drawing.Color.Gainsboro; + cmbDeathAnimation.FormattingEnabled = true; + cmbDeathAnimation.Location = new System.Drawing.Point(7, 237); + cmbDeathAnimation.Margin = new Padding(4, 3, 4, 3); + cmbDeathAnimation.Name = "cmbDeathAnimation"; + cmbDeathAnimation.Size = new Size(239, 24); + cmbDeathAnimation.TabIndex = 39; + cmbDeathAnimation.Text = null; + cmbDeathAnimation.TextPadding = new Padding(2); + cmbDeathAnimation.SelectedIndexChanged += cmbDeathAnimation_SelectedIndexChanged; + // + // lblDeathAnimation + // + lblDeathAnimation.AutoSize = true; + lblDeathAnimation.Location = new System.Drawing.Point(7, 210); + lblDeathAnimation.Margin = new Padding(4, 0, 4, 0); + lblDeathAnimation.Name = "lblDeathAnimation"; + lblDeathAnimation.Size = new Size(100, 15); + lblDeathAnimation.TabIndex = 36; + lblDeathAnimation.Text = "Death Animation:"; // // lblMaxHp // @@ -354,7 +374,7 @@ private void InitializeComponent() // // chkWalkableAfter // - chkWalkableAfter.Location = new System.Drawing.Point(7, 264); + chkWalkableAfter.Location = new System.Drawing.Point(7, 293); chkWalkableAfter.Margin = new Padding(4, 3, 4, 3); chkWalkableAfter.Name = "chkWalkableAfter"; chkWalkableAfter.Size = new Size(246, 20); @@ -364,7 +384,7 @@ private void InitializeComponent() // // chkWalkableBefore // - chkWalkableBefore.Location = new System.Drawing.Point(7, 238); + chkWalkableBefore.Location = new System.Drawing.Point(7, 267); chkWalkableBefore.Margin = new Padding(4, 3, 4, 3); chkWalkableBefore.Name = "chkWalkableBefore"; chkWalkableBefore.Size = new Size(246, 20); @@ -451,18 +471,16 @@ private void InitializeComponent() // grpGraphics.BackColor = System.Drawing.Color.FromArgb(45, 45, 48); grpGraphics.BorderColor = System.Drawing.Color.FromArgb(90, 90, 90); - grpGraphics.Controls.Add(chkExhaustedBelowEntities); - grpGraphics.Controls.Add(chkInitialBelowEntities); - grpGraphics.Controls.Add(chkExhaustedFromTileset); - grpGraphics.Controls.Add(chkInitialFromTileset); - grpGraphics.Controls.Add(exhaustedGraphicContainer); - grpGraphics.Controls.Add(initalGraphicContainer); - grpGraphics.Controls.Add(cmbEndSprite); - grpGraphics.Controls.Add(lblPic2); - grpGraphics.Controls.Add(cmbInitialSprite); - grpGraphics.Controls.Add(lblPic); + grpGraphics.Controls.Add(btnRemoveHealthState); + grpGraphics.Controls.Add(btnAddHealthState); + grpGraphics.Controls.Add(lblHealthStateName); + grpGraphics.Controls.Add(lstHealthState); + grpGraphics.Controls.Add(txtHealthStateName); + grpGraphics.Controls.Add(grpGraphicData); + grpGraphics.Controls.Add(lblHealthStates); + grpGraphics.Controls.Add(graphicContainer); grpGraphics.ForeColor = System.Drawing.Color.Gainsboro; - grpGraphics.Location = new System.Drawing.Point(0, 325); + grpGraphics.Location = new System.Drawing.Point(0, 359); grpGraphics.Margin = new Padding(4, 3, 4, 3); grpGraphics.Name = "grpGraphics"; grpGraphics.Padding = new Padding(4, 3, 4, 3); @@ -471,161 +489,264 @@ private void InitializeComponent() grpGraphics.TabStop = false; grpGraphics.Text = "Graphics"; // - // chkExhaustedBelowEntities - // - chkExhaustedBelowEntities.Location = new System.Drawing.Point(696, 15); - chkExhaustedBelowEntities.Margin = new Padding(4, 3, 4, 3); - chkExhaustedBelowEntities.Name = "chkExhaustedBelowEntities"; - chkExhaustedBelowEntities.Size = new Size(114, 24); - chkExhaustedBelowEntities.TabIndex = 35; - chkExhaustedBelowEntities.Text = "Below Entities"; - chkExhaustedBelowEntities.CheckedChanged += chkExhaustedBelowEntities_CheckedChanged; - // - // chkInitialBelowEntities - // - chkInitialBelowEntities.Location = new System.Drawing.Point(286, 15); - chkInitialBelowEntities.Margin = new Padding(4, 3, 4, 3); - chkInitialBelowEntities.Name = "chkInitialBelowEntities"; - chkInitialBelowEntities.Size = new Size(114, 24); - chkInitialBelowEntities.TabIndex = 34; - chkInitialBelowEntities.Text = "Below Entities"; - chkInitialBelowEntities.CheckedChanged += chkInitialBelowEntities_CheckedChanged; - // - // chkExhaustedFromTileset - // - chkExhaustedFromTileset.Location = new System.Drawing.Point(696, 37); - chkExhaustedFromTileset.Margin = new Padding(4, 3, 4, 3); - chkExhaustedFromTileset.Name = "chkExhaustedFromTileset"; - chkExhaustedFromTileset.Size = new Size(114, 24); - chkExhaustedFromTileset.TabIndex = 33; - chkExhaustedFromTileset.Text = "From Tileset"; - chkExhaustedFromTileset.CheckedChanged += chkExhaustedFromTileset_CheckedChanged; - // - // chkInitialFromTileset - // - chkInitialFromTileset.Location = new System.Drawing.Point(286, 37); - chkInitialFromTileset.Margin = new Padding(4, 3, 4, 3); - chkInitialFromTileset.Name = "chkInitialFromTileset"; - chkInitialFromTileset.Size = new Size(114, 24); - chkInitialFromTileset.TabIndex = 32; - chkInitialFromTileset.Text = "From Tileset"; - chkInitialFromTileset.CheckedChanged += chkInitialFromTileset_CheckedChanged; - // - // exhaustedGraphicContainer - // - exhaustedGraphicContainer.AutoScroll = true; - exhaustedGraphicContainer.Controls.Add(picEndResource); - exhaustedGraphicContainer.Location = new System.Drawing.Point(426, 72); - exhaustedGraphicContainer.Margin = new Padding(4, 3, 4, 3); - exhaustedGraphicContainer.Name = "exhaustedGraphicContainer"; - exhaustedGraphicContainer.Size = new Size(385, 445); - exhaustedGraphicContainer.TabIndex = 25; - // - // picEndResource - // - picEndResource.Location = new System.Drawing.Point(0, 0); - picEndResource.Margin = new Padding(4, 3, 4, 3); - picEndResource.Name = "picEndResource"; - picEndResource.Size = new Size(212, 335); - picEndResource.TabIndex = 2; - picEndResource.TabStop = false; - picEndResource.MouseDown += picExhustedResource_MouseDown; - picEndResource.MouseMove += picExhaustedResource_MouseMove; - picEndResource.MouseUp += picExhaustedResource_MouseUp; - // - // initalGraphicContainer - // - initalGraphicContainer.AutoScroll = true; - initalGraphicContainer.Controls.Add(picInitialResource); - initalGraphicContainer.Location = new System.Drawing.Point(15, 72); - initalGraphicContainer.Margin = new Padding(4, 3, 4, 3); - initalGraphicContainer.Name = "initalGraphicContainer"; - initalGraphicContainer.Size = new Size(385, 445); - initalGraphicContainer.TabIndex = 24; - // - // picInitialResource - // - picInitialResource.Location = new System.Drawing.Point(0, 0); - picInitialResource.Margin = new Padding(4, 3, 4, 3); - picInitialResource.Name = "picInitialResource"; - picInitialResource.Size = new Size(210, 335); - picInitialResource.TabIndex = 2; - picInitialResource.TabStop = false; - picInitialResource.MouseDown += picInitialResource_MouseDown; - picInitialResource.MouseMove += picInitialResource_MouseMove; - picInitialResource.MouseUp += picInitialResource_MouseUp; - // - // cmbEndSprite - // - cmbEndSprite.BackColor = System.Drawing.Color.FromArgb(69, 73, 74); - cmbEndSprite.BorderColor = System.Drawing.Color.FromArgb(90, 90, 90); - cmbEndSprite.BorderStyle = ButtonBorderStyle.Solid; - cmbEndSprite.ButtonColor = System.Drawing.Color.FromArgb(43, 43, 43); - cmbEndSprite.DrawDropdownHoverOutline = false; - cmbEndSprite.DrawFocusRectangle = false; - cmbEndSprite.DrawMode = DrawMode.OwnerDrawFixed; - cmbEndSprite.DropDownStyle = ComboBoxStyle.DropDownList; - cmbEndSprite.FlatStyle = FlatStyle.Flat; - cmbEndSprite.ForeColor = System.Drawing.Color.Gainsboro; - cmbEndSprite.FormattingEnabled = true; - cmbEndSprite.Items.AddRange(new object[] { "None" }); - cmbEndSprite.Location = new System.Drawing.Point(426, 37); - cmbEndSprite.Margin = new Padding(4, 3, 4, 3); - cmbEndSprite.Name = "cmbEndSprite"; - cmbEndSprite.Size = new Size(228, 24); - cmbEndSprite.TabIndex = 16; - cmbEndSprite.Text = "None"; - cmbEndSprite.TextPadding = new Padding(2); - cmbEndSprite.SelectedIndexChanged += cmbEndSprite_SelectedIndexChanged; - // - // lblPic2 - // - lblPic2.AutoSize = true; - lblPic2.Location = new System.Drawing.Point(422, 18); - lblPic2.Margin = new Padding(4, 0, 4, 0); - lblPic2.Name = "lblPic2"; - lblPic2.Size = new Size(104, 15); - lblPic2.TabIndex = 15; - lblPic2.Text = "Removed Graphic:"; - // - // cmbInitialSprite - // - cmbInitialSprite.BackColor = System.Drawing.Color.FromArgb(69, 73, 74); - cmbInitialSprite.BorderColor = System.Drawing.Color.FromArgb(90, 90, 90); - cmbInitialSprite.BorderStyle = ButtonBorderStyle.Solid; - cmbInitialSprite.ButtonColor = System.Drawing.Color.FromArgb(43, 43, 43); - cmbInitialSprite.DrawDropdownHoverOutline = false; - cmbInitialSprite.DrawFocusRectangle = false; - cmbInitialSprite.DrawMode = DrawMode.OwnerDrawFixed; - cmbInitialSprite.DropDownStyle = ComboBoxStyle.DropDownList; - cmbInitialSprite.FlatStyle = FlatStyle.Flat; - cmbInitialSprite.ForeColor = System.Drawing.Color.Gainsboro; - cmbInitialSprite.FormattingEnabled = true; - cmbInitialSprite.Items.AddRange(new object[] { "None" }); - cmbInitialSprite.Location = new System.Drawing.Point(15, 37); - cmbInitialSprite.Margin = new Padding(4, 3, 4, 3); - cmbInitialSprite.Name = "cmbInitialSprite"; - cmbInitialSprite.Size = new Size(227, 24); - cmbInitialSprite.TabIndex = 14; - cmbInitialSprite.Text = "None"; - cmbInitialSprite.TextPadding = new Padding(2); - cmbInitialSprite.SelectedIndexChanged += cmbInitialSprite_SelectedIndexChanged; - // - // lblPic - // - lblPic.AutoSize = true; - lblPic.Location = new System.Drawing.Point(12, 18); - lblPic.Margin = new Padding(4, 0, 4, 0); - lblPic.Name = "lblPic"; - lblPic.Size = new Size(83, 15); - lblPic.TabIndex = 13; - lblPic.Text = "Initial Graphic:"; + // btnRemoveHealthState + // + btnRemoveHealthState.Location = new System.Drawing.Point(172, 187); + btnRemoveHealthState.Margin = new Padding(4, 3, 4, 3); + btnRemoveHealthState.Name = "btnRemoveHealthState"; + btnRemoveHealthState.Padding = new Padding(6); + btnRemoveHealthState.Size = new Size(88, 27); + btnRemoveHealthState.TabIndex = 67; + btnRemoveHealthState.Text = "Remove"; + btnRemoveHealthState.Click += btnRemoveHealthState_Click; + // + // btnAddHealthState + // + btnAddHealthState.Location = new System.Drawing.Point(7, 187); + btnAddHealthState.Margin = new Padding(4, 3, 4, 3); + btnAddHealthState.Name = "btnAddHealthState"; + btnAddHealthState.Padding = new Padding(6); + btnAddHealthState.Size = new Size(88, 27); + btnAddHealthState.TabIndex = 67; + btnAddHealthState.Text = "Add"; + btnAddHealthState.Click += btnAddHealthState_Click; + // + // lblHealthStateName + // + lblHealthStateName.AutoSize = true; + lblHealthStateName.Location = new System.Drawing.Point(4, 139); + lblHealthStateName.Margin = new Padding(4, 0, 4, 0); + lblHealthStateName.Name = "lblHealthStateName"; + lblHealthStateName.Size = new Size(153, 15); + lblHealthStateName.TabIndex = 56; + lblHealthStateName.Text = "Health Graphic State Name:"; + // + // lstHealthState + // + lstHealthState.BackColor = System.Drawing.Color.FromArgb(60, 63, 65); + lstHealthState.BorderStyle = BorderStyle.FixedSingle; + lstHealthState.ForeColor = System.Drawing.Color.Gainsboro; + lstHealthState.FormattingEnabled = true; + lstHealthState.ItemHeight = 15; + lstHealthState.Location = new System.Drawing.Point(7, 39); + lstHealthState.Margin = new Padding(4, 3, 4, 3); + lstHealthState.Name = "lstHealthState"; + lstHealthState.Size = new Size(253, 92); + lstHealthState.TabIndex = 60; + lstHealthState.SelectedIndexChanged += lstHealthState_SelectedIndexChanged; + // + // txtHealthStateName + // + txtHealthStateName.BackColor = System.Drawing.Color.FromArgb(69, 73, 74); + txtHealthStateName.BorderStyle = BorderStyle.FixedSingle; + txtHealthStateName.ForeColor = System.Drawing.Color.FromArgb(220, 220, 220); + txtHealthStateName.Location = new System.Drawing.Point(7, 158); + txtHealthStateName.Margin = new Padding(4, 3, 4, 3); + txtHealthStateName.Name = "txtHealthStateName"; + txtHealthStateName.Size = new Size(253, 23); + txtHealthStateName.TabIndex = 55; + // + // grpGraphicData + // + grpGraphicData.BackColor = System.Drawing.Color.FromArgb(45, 45, 48); + grpGraphicData.BorderColor = System.Drawing.Color.FromArgb(90, 90, 90); + grpGraphicData.Controls.Add(nudHealthRangeMax); + grpGraphicData.Controls.Add(nudHealthRangeMin); + grpGraphicData.Controls.Add(lblHealthRange); + grpGraphicData.Controls.Add(cmbGraphicFile); + grpGraphicData.Controls.Add(lblGraphicFile); + grpGraphicData.Controls.Add(cmbAnimation); + grpGraphicData.Controls.Add(lblAnimation); + grpGraphicData.Controls.Add(chkRenderBelowEntity); + grpGraphicData.Controls.Add(cmbGraphicType); + grpGraphicData.Controls.Add(lblGraphicType); + grpGraphicData.ForeColor = System.Drawing.Color.Gainsboro; + grpGraphicData.Location = new System.Drawing.Point(7, 221); + grpGraphicData.Margin = new Padding(2); + grpGraphicData.Name = "grpGraphicData"; + grpGraphicData.Padding = new Padding(2); + grpGraphicData.Size = new Size(253, 292); + grpGraphicData.TabIndex = 34; + grpGraphicData.TabStop = false; + grpGraphicData.Text = "Graphic Data"; + // + // nudHealthRangeMax + // + nudHealthRangeMax.BackColor = System.Drawing.Color.FromArgb(69, 73, 74); + nudHealthRangeMax.ForeColor = System.Drawing.Color.Gainsboro; + nudHealthRangeMax.Location = new System.Drawing.Point(137, 229); + nudHealthRangeMax.Margin = new Padding(4, 3, 4, 3); + nudHealthRangeMax.Name = "nudHealthRangeMax"; + nudHealthRangeMax.Size = new Size(102, 23); + nudHealthRangeMax.TabIndex = 68; + nudHealthRangeMax.Value = new decimal(new int[] { 0, 0, 0, 0 }); + nudHealthRangeMax.ValueChanged += nudHealthRangeMax_ValueChanged; + // + // nudHealthRangeMin + // + nudHealthRangeMin.BackColor = System.Drawing.Color.FromArgb(69, 73, 74); + nudHealthRangeMin.ForeColor = System.Drawing.Color.Gainsboro; + nudHealthRangeMin.Location = new System.Drawing.Point(12, 229); + nudHealthRangeMin.Margin = new Padding(4, 3, 4, 3); + nudHealthRangeMin.Name = "nudHealthRangeMin"; + nudHealthRangeMin.Size = new Size(102, 23); + nudHealthRangeMin.TabIndex = 67; + nudHealthRangeMin.Value = new decimal(new int[] { 0, 0, 0, 0 }); + nudHealthRangeMin.ValueChanged += nudHealthRangeMin_ValueChanged; + // + // lblHealthRange + // + lblHealthRange.AutoSize = true; + lblHealthRange.Location = new System.Drawing.Point(12, 208); + lblHealthRange.Margin = new Padding(4, 0, 4, 0); + lblHealthRange.Name = "lblHealthRange"; + lblHealthRange.Size = new Size(160, 15); + lblHealthRange.TabIndex = 58; + lblHealthRange.Text = "Health Range Min - Max (%):"; + // + // cmbGraphicFile + // + cmbGraphicFile.BackColor = System.Drawing.Color.FromArgb(69, 73, 74); + cmbGraphicFile.BorderColor = System.Drawing.Color.FromArgb(90, 90, 90); + cmbGraphicFile.BorderStyle = ButtonBorderStyle.Solid; + cmbGraphicFile.ButtonColor = System.Drawing.Color.FromArgb(43, 43, 43); + cmbGraphicFile.DrawDropdownHoverOutline = false; + cmbGraphicFile.DrawFocusRectangle = false; + cmbGraphicFile.DrawMode = DrawMode.OwnerDrawFixed; + cmbGraphicFile.DropDownStyle = ComboBoxStyle.DropDownList; + cmbGraphicFile.FlatStyle = FlatStyle.Flat; + cmbGraphicFile.ForeColor = System.Drawing.Color.Gainsboro; + cmbGraphicFile.FormattingEnabled = true; + cmbGraphicFile.Location = new System.Drawing.Point(12, 119); + cmbGraphicFile.Margin = new Padding(4, 3, 4, 3); + cmbGraphicFile.Name = "cmbGraphicFile"; + cmbGraphicFile.Size = new Size(227, 24); + cmbGraphicFile.TabIndex = 57; + cmbGraphicFile.Text = null; + cmbGraphicFile.TextPadding = new Padding(2); + cmbGraphicFile.SelectedIndexChanged += cmbGraphicFile_SelectedIndexChanged; + // + // lblGraphicFile + // + lblGraphicFile.AutoSize = true; + lblGraphicFile.Location = new System.Drawing.Point(9, 99); + lblGraphicFile.Margin = new Padding(4, 0, 4, 0); + lblGraphicFile.Name = "lblGraphicFile"; + lblGraphicFile.Size = new Size(72, 15); + lblGraphicFile.TabIndex = 56; + lblGraphicFile.Text = "Graphic File:"; + // + // cmbAnimation + // + cmbAnimation.BackColor = System.Drawing.Color.FromArgb(69, 73, 74); + cmbAnimation.BorderColor = System.Drawing.Color.FromArgb(90, 90, 90); + cmbAnimation.BorderStyle = ButtonBorderStyle.Solid; + cmbAnimation.ButtonColor = System.Drawing.Color.FromArgb(43, 43, 43); + cmbAnimation.DrawDropdownHoverOutline = false; + cmbAnimation.DrawFocusRectangle = false; + cmbAnimation.DrawMode = DrawMode.OwnerDrawFixed; + cmbAnimation.DropDownStyle = ComboBoxStyle.DropDownList; + cmbAnimation.FlatStyle = FlatStyle.Flat; + cmbAnimation.ForeColor = System.Drawing.Color.Gainsboro; + cmbAnimation.FormattingEnabled = true; + cmbAnimation.Location = new System.Drawing.Point(12, 175); + cmbAnimation.Margin = new Padding(4, 3, 4, 3); + cmbAnimation.Name = "cmbAnimation"; + cmbAnimation.Size = new Size(227, 24); + cmbAnimation.TabIndex = 55; + cmbAnimation.Text = null; + cmbAnimation.TextPadding = new Padding(2); + cmbAnimation.SelectedIndexChanged += UpdateCurrentState; + // + // lblAnimation + // + lblAnimation.AutoSize = true; + lblAnimation.Location = new System.Drawing.Point(9, 155); + lblAnimation.Margin = new Padding(4, 0, 4, 0); + lblAnimation.Name = "lblAnimation"; + lblAnimation.Size = new Size(66, 15); + lblAnimation.TabIndex = 54; + lblAnimation.Text = "Animation:"; + // + // chkRenderBelowEntity + // + chkRenderBelowEntity.Location = new System.Drawing.Point(12, 71); + chkRenderBelowEntity.Margin = new Padding(4, 3, 4, 3); + chkRenderBelowEntity.Name = "chkRenderBelowEntity"; + chkRenderBelowEntity.Size = new Size(227, 20); + chkRenderBelowEntity.TabIndex = 53; + chkRenderBelowEntity.Text = "Render Below Entity"; + chkRenderBelowEntity.CheckedChanged += chkRenderBelowEntity_CheckedChanged; + // + // cmbGraphicType + // + cmbGraphicType.BackColor = System.Drawing.Color.FromArgb(69, 73, 74); + cmbGraphicType.BorderColor = System.Drawing.Color.FromArgb(90, 90, 90); + cmbGraphicType.BorderStyle = ButtonBorderStyle.Solid; + cmbGraphicType.ButtonColor = System.Drawing.Color.FromArgb(43, 43, 43); + cmbGraphicType.DrawDropdownHoverOutline = false; + cmbGraphicType.DrawFocusRectangle = false; + cmbGraphicType.DrawMode = DrawMode.OwnerDrawFixed; + cmbGraphicType.DropDownStyle = ComboBoxStyle.DropDownList; + cmbGraphicType.FlatStyle = FlatStyle.Flat; + cmbGraphicType.ForeColor = System.Drawing.Color.Gainsboro; + cmbGraphicType.FormattingEnabled = true; + cmbGraphicType.Location = new System.Drawing.Point(12, 41); + cmbGraphicType.Margin = new Padding(4, 3, 4, 3); + cmbGraphicType.Name = "cmbGraphicType"; + cmbGraphicType.Size = new Size(227, 24); + cmbGraphicType.TabIndex = 21; + cmbGraphicType.Text = null; + cmbGraphicType.TextPadding = new Padding(2); + cmbGraphicType.SelectedIndexChanged += cmbGraphicType_SelectedIndexChanged; + // + // lblGraphicType + // + lblGraphicType.AutoSize = true; + lblGraphicType.Location = new System.Drawing.Point(9, 21); + lblGraphicType.Margin = new Padding(4, 0, 4, 0); + lblGraphicType.Name = "lblGraphicType"; + lblGraphicType.Size = new Size(78, 15); + lblGraphicType.TabIndex = 20; + lblGraphicType.Text = "Graphic Type:"; + // + // lblHealthStates + // + lblHealthStates.AutoSize = true; + lblHealthStates.Location = new System.Drawing.Point(10, 21); + lblHealthStates.Margin = new Padding(4, 0, 4, 0); + lblHealthStates.Name = "lblHealthStates"; + lblHealthStates.Size = new Size(79, 15); + lblHealthStates.TabIndex = 55; + lblHealthStates.Text = "Health States:"; + // + // graphicContainer + // + graphicContainer.AutoScroll = true; + graphicContainer.Controls.Add(picResource); + graphicContainer.Location = new System.Drawing.Point(270, 22); + graphicContainer.Margin = new Padding(4, 3, 4, 3); + graphicContainer.Name = "graphicContainer"; + graphicContainer.Size = new Size(540, 491); + graphicContainer.TabIndex = 24; + // + // picResource + // + picResource.Location = new System.Drawing.Point(0, 0); + picResource.Margin = new Padding(4, 3, 4, 3); + picResource.Name = "picResource"; + picResource.Size = new Size(540, 491); + picResource.TabIndex = 2; + picResource.TabStop = false; + picResource.MouseDown += picResource_MouseDown; + picResource.MouseMove += picResource_MouseMove; + picResource.MouseUp += picResource_MouseUp; // // tmrRender // tmrRender.Enabled = true; tmrRender.Interval = 10; - tmrRender.Tick += tmrRender_Tick; + tmrRender.Tick += Render; // // pnlContainer // @@ -655,7 +776,7 @@ private void InitializeComponent() grpRequirements.Margin = new Padding(2); grpRequirements.Name = "grpRequirements"; grpRequirements.Padding = new Padding(2); - grpRequirements.Size = new Size(285, 106); + grpRequirements.Size = new Size(285, 135); grpRequirements.TabIndex = 33; grpRequirements.TabStop = false; grpRequirements.Text = "Requirements"; @@ -798,7 +919,7 @@ private void InitializeComponent() grpDrops.Margin = new Padding(4, 3, 4, 3); grpDrops.Name = "grpDrops"; grpDrops.Padding = new Padding(4, 3, 4, 3); - grpDrops.Size = new Size(264, 324); + grpDrops.Size = new Size(264, 353); grpDrops.TabIndex = 31; grpDrops.TabStop = false; grpDrops.Text = "Drops"; @@ -829,7 +950,7 @@ private void InitializeComponent() // // btnDropRemove // - btnDropRemove.Location = new System.Drawing.Point(168, 287); + btnDropRemove.Location = new System.Drawing.Point(168, 312); btnDropRemove.Margin = new Padding(4, 3, 4, 3); btnDropRemove.Name = "btnDropRemove"; btnDropRemove.Padding = new Padding(6); @@ -840,7 +961,7 @@ private void InitializeComponent() // // btnDropAdd // - btnDropAdd.Location = new System.Drawing.Point(10, 287); + btnDropAdd.Location = new System.Drawing.Point(10, 312); btnDropAdd.Margin = new Padding(4, 3, 4, 3); btnDropAdd.Name = "btnDropAdd"; btnDropAdd.Padding = new Padding(6); @@ -1110,10 +1231,12 @@ private void InitializeComponent() ((System.ComponentModel.ISupportInitialize)nudSpawnDuration).EndInit(); grpGraphics.ResumeLayout(false); grpGraphics.PerformLayout(); - exhaustedGraphicContainer.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)picEndResource).EndInit(); - initalGraphicContainer.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)picInitialResource).EndInit(); + grpGraphicData.ResumeLayout(false); + grpGraphicData.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)nudHealthRangeMax).EndInit(); + ((System.ComponentModel.ISupportInitialize)nudHealthRangeMin).EndInit(); + graphicContainer.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)picResource).EndInit(); pnlContainer.ResumeLayout(false); grpRequirements.ResumeLayout(false); grpRequirements.PerformLayout(); @@ -1144,15 +1267,10 @@ private void InitializeComponent() private DarkCheckBox chkWalkableBefore; private DarkComboBox cmbToolType; private System.Windows.Forms.Label lblToolType; - private DarkComboBox cmbEndSprite; - private System.Windows.Forms.Label lblPic2; - private DarkComboBox cmbInitialSprite; - private System.Windows.Forms.Label lblPic; private System.Windows.Forms.Label lblSpawnDuration; - public System.Windows.Forms.PictureBox picEndResource; - public System.Windows.Forms.PictureBox picInitialResource; + public System.Windows.Forms.PictureBox picResource; private System.Windows.Forms.Label lblMaxHp; - private System.Windows.Forms.Label lblAnimation; + private System.Windows.Forms.Label lblDeathAnimation; private System.Windows.Forms.Timer tmrRender; private System.Windows.Forms.Panel pnlContainer; private DarkButton btnSave; @@ -1166,10 +1284,9 @@ private void InitializeComponent() public System.Windows.Forms.ToolStripButton toolStripItemPaste; private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; public System.Windows.Forms.ToolStripButton toolStripItemUndo; - private System.Windows.Forms.Panel exhaustedGraphicContainer; - private System.Windows.Forms.Panel initalGraphicContainer; + private System.Windows.Forms.Panel graphicContainer; private DarkButton btnRequirements; - private DarkComboBox cmbAnimation; + private DarkComboBox cmbDeathAnimation; private DarkNumericUpDown nudSpawnDuration; private DarkNumericUpDown nudMaxHp; private DarkNumericUpDown nudMinHp; @@ -1183,8 +1300,6 @@ private void InitializeComponent() private System.Windows.Forms.Label lblDropMaxAmount; private System.Windows.Forms.Label lblDropChance; private System.Windows.Forms.Label lblDropItem; - private DarkCheckBox chkExhaustedFromTileset; - private DarkCheckBox chkInitialFromTileset; private DarkGroupBox grpRegen; private DarkNumericUpDown nudHpRegen; private System.Windows.Forms.Label lblHpRegen; @@ -1192,8 +1307,6 @@ private void InitializeComponent() private DarkGroupBox grpCommonEvent; private DarkComboBox cmbEvent; private System.Windows.Forms.Label lblEvent; - private DarkCheckBox chkExhaustedBelowEntities; - private DarkCheckBox chkInitialBelowEntities; private DarkButton btnClearSearch; private DarkTextBox txtSearch; private DarkButton btnAddFolder; @@ -1207,5 +1320,23 @@ private void InitializeComponent() private DarkTextBox txtCannotHarvest; private DarkNumericUpDown nudDropMinAmount; private Label lblDropMinAmount; + private Label lblHealthStates; + private DarkGroupBox grpGraphicData; + private DarkComboBox cmbGraphicType; + private Label lblGraphicType; + private DarkCheckBox chkRenderBelowEntity; + private DarkComboBox cmbAnimation; + private Label lblAnimation; + private DarkComboBox cmbGraphicFile; + private Label lblGraphicFile; + private ListBox lstHealthState; + private DarkButton btnRemoveHealthState; + private DarkButton btnAddHealthState; + private Label lblHealthStateName; + private DarkTextBox txtHealthStateName; + private Label lblHealthRange; + private DarkNumericUpDown nudHealthRangeMax; + private DarkNumericUpDown nudHealthRangeMin; + private DarkCheckBox chkUseExplicitMaxHealthForResourceStates; } } \ No newline at end of file diff --git a/Intersect.Editor/Forms/Editors/frmResource.cs b/Intersect.Editor/Forms/Editors/frmResource.cs index 58c4ff5dd6..92437103e6 100644 --- a/Intersect.Editor/Forms/Editors/frmResource.cs +++ b/Intersect.Editor/Forms/Editors/frmResource.cs @@ -1,4 +1,5 @@ using System.ComponentModel; +using System.Diagnostics.CodeAnalysis; using DarkUI.Forms; using Intersect.Editor.Content; using Intersect.Editor.Core; @@ -7,10 +8,8 @@ using Intersect.Editor.Networking; using Intersect.Enums; using Intersect.Framework.Core.GameObjects.Animations; -using Intersect.Framework.Core.GameObjects.Events; using Intersect.Framework.Core.GameObjects.Items; using Intersect.Framework.Core.GameObjects.Resources; -using Intersect.GameObjects; using Intersect.Utilities; using EventDescriptor = Intersect.Framework.Core.GameObjects.Events.EventDescriptor; using Graphics = System.Drawing.Graphics; @@ -19,29 +18,14 @@ namespace Intersect.Editor.Forms.Editors; public partial class FrmResource : EditorForm { - - private List mChanged = []; - - private string mCopiedItem; - - private ResourceDescriptor mEditorItem; - - private Bitmap mEndBitmap; - - private Bitmap mEndGraphic; - - private Bitmap mInitialBitmap; - - private Bitmap mInitialGraphic; - - private List mKnownFolders = []; - - private bool mMouseDown; - - private BindingList _dropList = []; - - //General Editting Variables - bool mTMouseDown; + private readonly List _changed = []; + private string? _copiedItem; + private ResourceDescriptor? _editorItem; + private Bitmap? _graphicBitmap; + private Bitmap? _resourceGraphic; + private bool _mouseDown; + private readonly List _knownFolders = []; + private readonly BindingList _dropList = []; public FrmResource() { @@ -61,22 +45,99 @@ public FrmResource() lstDrops.DataSource = _dropList; lstDrops.DisplayMember = nameof(NotifiableDrop.DisplayName); - lstGameObjects.Init(UpdateToolStripItems, AssignEditorItem, toolStripItemNew_Click, toolStripItemCopy_Click, toolStripItemUndo_Click, toolStripItemPaste_Click, toolStripItemDelete_Click); + lstGameObjects.Init( + UpdateToolStripItems, + AssignEditorItem, + toolStripItemNew_Click, + toolStripItemCopy_Click, + toolStripItemUndo_Click, + toolStripItemPaste_Click, + toolStripItemDelete_Click + ); } + + #region Basic Editor Functions + private void AssignEditorItem(Guid id) { - mEditorItem = ResourceDescriptor.Get(id); + if (!ResourceDescriptor.TryGet(id, out _editorItem)) + { + _editorItem = null; + } + UpdateEditor(); } + private void toolStripItemNew_Click(object sender, EventArgs e) + { + PacketSender.SendCreateObject(GameObjectType.Resource); + } + + private void toolStripItemDelete_Click(object sender, EventArgs e) + { + if (_editorItem != null && lstGameObjects.Focused) + { + if (DarkMessageBox.ShowWarning( + Strings.ResourceEditor.deleteprompt, Strings.ResourceEditor.deletetitle, DarkDialogButton.YesNo, + Icon + ) == + DialogResult.Yes) + { + PacketSender.SendDeleteObject(_editorItem); + } + } + } + + private void toolStripItemCopy_Click(object sender, EventArgs e) + { + if (_editorItem != null && lstGameObjects.Focused) + { + _copiedItem = _editorItem.JsonData; + toolStripItemPaste.Enabled = true; + } + } + + private void toolStripItemPaste_Click(object sender, EventArgs e) + { + if (_editorItem != null && _copiedItem != null && lstGameObjects.Focused) + { + _editorItem.Load(_copiedItem, true); + UpdateEditor(); + } + } + + private void toolStripItemUndo_Click(object sender, EventArgs e) + { + if (_editorItem != null && _changed.Contains(_editorItem) && _editorItem != null) + { + if (DarkMessageBox.ShowWarning( + Strings.ResourceEditor.undoprompt, Strings.ResourceEditor.undotitle, DarkDialogButton.YesNo, + Icon + ) == + DialogResult.Yes) + { + _editorItem.RestoreBackup(); + UpdateEditor(); + } + } + } + + private void UpdateToolStripItems() + { + toolStripItemCopy.Enabled = _editorItem != null && lstGameObjects.Focused; + toolStripItemPaste.Enabled = _editorItem != null && _copiedItem != null && lstGameObjects.Focused; + toolStripItemDelete.Enabled = _editorItem != null && lstGameObjects.Focused; + toolStripItemUndo.Enabled = _editorItem != null && lstGameObjects.Focused; + } + protected override void GameObjectUpdatedDelegate(GameObjectType type) { if (type == GameObjectType.Resource) { InitEditor(); - if (mEditorItem != null && !ResourceDescriptor.Lookup.Values.Contains(mEditorItem)) + if (_editorItem != null && !ResourceDescriptor.Lookup.Values.Contains(_editorItem)) { - mEditorItem = null; + _editorItem = null; UpdateEditor(); } } @@ -84,7 +145,7 @@ protected override void GameObjectUpdatedDelegate(GameObjectType type) private void btnCancel_Click(object sender, EventArgs e) { - foreach (var item in mChanged) + foreach (var item in _changed) { item.RestoreBackup(); item.DeleteBackup(); @@ -98,7 +159,7 @@ private void btnCancel_Click(object sender, EventArgs e) private void btnSave_Click(object sender, EventArgs e) { //Send Changed items - foreach (var item in mChanged) + foreach (var item in _changed) { PacketSender.SendSaveObject(item); item.DeleteBackup(); @@ -109,14 +170,17 @@ private void btnSave_Click(object sender, EventArgs e) Dispose(); } + #endregion + + #region Form Events + private void frmResource_Load(object sender, EventArgs e) { - mInitialBitmap = new Bitmap(picInitialResource.Width, picInitialResource.Height); - mEndBitmap = new Bitmap(picInitialResource.Width, picInitialResource.Height); + _graphicBitmap = new Bitmap(picResource.Width, picResource.Height); - cmbAnimation.Items.Clear(); - cmbAnimation.Items.Add(Strings.General.None); - cmbAnimation.Items.AddRange(AnimationDescriptor.Names); + cmbDeathAnimation.Items.Clear(); + cmbDeathAnimation.Items.Add(Strings.General.None); + cmbDeathAnimation.Items.AddRange(AnimationDescriptor.Names); cmbDropItem.Items.Clear(); cmbDropItem.Items.Add(Strings.General.None); cmbDropItem.Items.AddRange(ItemDescriptor.Names); @@ -124,65 +188,22 @@ private void frmResource_Load(object sender, EventArgs e) UpdateEditor(); } - private void PopulateInitialGraphicList() + private void frmResource_FormClosed(object sender, FormClosedEventArgs e) { - cmbInitialSprite.Items.Clear(); - cmbInitialSprite.Items.Add(Strings.General.None); - var resources = GameContentManager.GetSmartSortedTextureNames(GameContentManager.TextureType.Resource); - if (mEditorItem.Initial.GraphicFromTileset) - { - resources = GameContentManager.GetSmartSortedTextureNames(GameContentManager.TextureType.Tileset); - } - - for (var i = 0; i < resources.Length; i++) - { - cmbInitialSprite.Items.Add(resources[i]); - } - - if (mEditorItem != null) - { - if (mEditorItem.Initial.Graphic != null && cmbInitialSprite.Items.Contains(mEditorItem.Initial.Graphic)) - { - cmbInitialSprite.SelectedIndex = cmbInitialSprite.FindString( - TextUtils.NullToNone(TextUtils.NullToNone(mEditorItem.Initial.Graphic)) - ); - - return; - } - } - - cmbInitialSprite.SelectedIndex = 0; + Globals.CurrentEditor = -1; } - private void PopulateExhaustedGraphicList() + private void form_KeyDown(object sender, KeyEventArgs e) { - cmbEndSprite.Items.Clear(); - cmbEndSprite.Items.Add(Strings.General.None); - var resources = GameContentManager.GetSmartSortedTextureNames(GameContentManager.TextureType.Resource); - if (mEditorItem.Exhausted.GraphicFromTileset) + if (e.Control && e.KeyCode == Keys.N) { - resources = GameContentManager.GetSmartSortedTextureNames(GameContentManager.TextureType.Tileset); + toolStripItemNew_Click(null, null); } + } - for (var i = 0; i < resources.Length; i++) - { - cmbEndSprite.Items.Add(resources[i]); - } - - if (mEditorItem != null) - { - if (mEditorItem.Exhausted.Graphic != null && cmbEndSprite.Items.Contains(mEditorItem.Exhausted.Graphic)) - { - cmbEndSprite.SelectedIndex = cmbEndSprite.FindString( - TextUtils.NullToNone(TextUtils.NullToNone(mEditorItem.Exhausted.Graphic)) - ); - - return; - } - } + #endregion - cmbEndSprite.SelectedIndex = 0; - } + #region Intersect Setup private void InitLocalization() { @@ -201,9 +222,10 @@ private void InitLocalization() lblHP.Text = Strings.ResourceEditor.minhp; lblMaxHp.Text = Strings.ResourceEditor.maxhp; lblSpawnDuration.Text = Strings.ResourceEditor.spawnduration; - lblAnimation.Text = Strings.ResourceEditor.animation; + lblDeathAnimation.Text = Strings.ResourceEditor.DeathAnimation; chkWalkableBefore.Text = Strings.ResourceEditor.walkablebefore; chkWalkableAfter.Text = Strings.ResourceEditor.walkableafter; + chkUseExplicitMaxHealthForResourceStates.Text = Strings.ResourceEditor.UseExplicitMaxHealthForResourceStates; grpDrops.Text = Strings.ResourceEditor.drops; lblDropItem.Text = Strings.ResourceEditor.dropitem; @@ -217,14 +239,18 @@ private void InitLocalization() lblHpRegen.Text = Strings.ResourceEditor.hpregen; lblRegenHint.Text = Strings.ResourceEditor.regenhint; - grpGraphics.Text = Strings.ResourceEditor.graphics; - lblPic.Text = Strings.ResourceEditor.initialgraphic; - lblPic2.Text = Strings.ResourceEditor.exhaustedgraphic; - - chkExhaustedBelowEntities.Text = Strings.ResourceEditor.belowentities; - chkInitialBelowEntities.Text = Strings.ResourceEditor.belowentities; - chkInitialFromTileset.Text = Strings.ResourceEditor.fromtileset; - chkExhaustedFromTileset.Text = Strings.ResourceEditor.fromtileset; + grpGraphics.Text = Strings.ResourceEditor.Graphics; + lblHealthStates.Text = Strings.ResourceEditor.HealthStatesLabel; + lblHealthStateName.Text = Strings.ResourceEditor.HealthStateName; + btnAddHealthState.Text = Strings.ResourceEditor.AddHealthState; + btnRemoveHealthState.Text = Strings.ResourceEditor.RemoveHealthState; + grpGraphicData.Text = Strings.ResourceEditor.GraphicData; + lblGraphicType.Text = Strings.ResourceEditor.GraphicType; + cmbGraphicType.Items.Clear(); + cmbGraphicType.Items.AddRange([.. Strings.ResourceEditor.GraphicTypes.Values]); + chkRenderBelowEntity.Text = Strings.ResourceEditor.BelowEntities; + lblGraphicFile.Text = Strings.ResourceEditor.GraphicFile; + lblAnimation.Text = Strings.ResourceEditor.Animation; grpCommonEvent.Text = Strings.ResourceEditor.commonevent; lblEvent.Text = Strings.ResourceEditor.harvestevent; @@ -244,36 +270,53 @@ private void InitLocalization() private void UpdateEditor() { - if (mEditorItem != null) + if (_editorItem != null) { pnlContainer.Show(); - txtName.Text = mEditorItem.Name; - cmbFolder.Text = mEditorItem.Folder; - cmbToolType.SelectedIndex = mEditorItem.Tool + 1; - nudSpawnDuration.Value = mEditorItem.SpawnDuration; - cmbAnimation.SelectedIndex = AnimationDescriptor.ListIndex(mEditorItem.AnimationId) + 1; - nudMinHp.Value = mEditorItem.MinHp; - nudMaxHp.Value = mEditorItem.MaxHp; - chkWalkableBefore.Checked = mEditorItem.WalkableBefore; - chkWalkableAfter.Checked = mEditorItem.WalkableAfter; - chkInitialFromTileset.Checked = mEditorItem.Initial.GraphicFromTileset; - chkExhaustedFromTileset.Checked = mEditorItem.Exhausted.GraphicFromTileset; - cmbEvent.SelectedIndex = EventDescriptor.ListIndex(mEditorItem.EventId) + 1; - chkInitialBelowEntities.Checked = mEditorItem.Initial.RenderBelowEntities; - chkExhaustedBelowEntities.Checked = mEditorItem.Exhausted.RenderBelowEntities; - txtCannotHarvest.Text = mEditorItem.CannotHarvestMessage; - - //Regen - nudHpRegen.Value = mEditorItem.VitalRegen; - PopulateInitialGraphicList(); - PopulateExhaustedGraphicList(); + txtName.Text = _editorItem.Name; + cmbFolder.Text = _editorItem.Folder; + cmbToolType.SelectedIndex = _editorItem.Tool + 1; + nudSpawnDuration.Value = _editorItem.SpawnDuration; + cmbDeathAnimation.SelectedIndex = AnimationDescriptor.ListIndex(_editorItem.AnimationId) + 1; + nudMinHp.Value = _editorItem.MinHp; + nudMaxHp.Value = _editorItem.MaxHp; + chkWalkableBefore.Checked = _editorItem.WalkableBefore; + chkWalkableAfter.Checked = _editorItem.WalkableAfter; + chkUseExplicitMaxHealthForResourceStates.Checked = _editorItem.UseExplicitMaxHealthForResourceStates; + cmbEvent.SelectedIndex = EventDescriptor.ListIndex(_editorItem.EventId) + 1; + txtCannotHarvest.Text = _editorItem.CannotHarvestMessage; + nudHpRegen.Value = _editorItem.VitalRegen; + + picResource.Hide(); + lstHealthState.Items.Clear(); + foreach (var state in _editorItem.HealthGraphics.Keys) + { + lstHealthState.Items.Add(state); + } + + if (lstHealthState.Items.Count > 0) + { + lstHealthState.SelectedIndex = 0; + } + else + { + txtHealthStateName.Text = string.Empty; + cmbGraphicType.SelectedIndex = (int)ResourceGraphicType.Graphic; + chkRenderBelowEntity.Checked = false; + cmbGraphicFile.Items.Clear(); + cmbAnimation.Items.Clear(); + nudHealthRangeMin.Value = 0; + nudHealthRangeMax.Value = 0; + picResource.Hide(); + } + UpdateDropValues(); - Render(); - if (mChanged.IndexOf(mEditorItem) == -1) + + if (_changed.IndexOf(_editorItem) == -1) { - mChanged.Add(mEditorItem); - mEditorItem.MakeBackup(); + _changed.Add(_editorItem); + _editorItem.MakeBackup(); } } else @@ -287,10 +330,43 @@ private void UpdateEditor() UpdateToolStripItems(); } + #endregion + + #region Helpers + + private bool TryGetCurrentHealthState([NotNullWhen(true)] out ResourceStateDescriptor? state) + { + state = null; + + if (_editorItem is null) + { + return false; + } + + if (lstHealthState.SelectedIndex < 0) + { + return false; + } + + var selectedIndex = lstHealthState.SelectedIndex; + var stateKey = _editorItem.HealthGraphics.Keys.ToList()[selectedIndex]; + if (!_editorItem.HealthGraphics.TryGetValue(stateKey, out state)) + { + return false; + } + + return true; + } + private void UpdateDropValues() { + if (_editorItem is null) + { + return; + } + _dropList.Clear(); - foreach (var drop in mEditorItem.Drops) + foreach (var drop in _editorItem.Drops) { _dropList.Add(new NotifiableDrop { @@ -302,151 +378,127 @@ private void UpdateDropValues() } } - private void nudSpawnDuration_ValueChanged(object sender, EventArgs e) + private void UpdateHealthStateControls() { - mEditorItem.SpawnDuration = (int) nudSpawnDuration.Value; - } - - private void cmbToolType_SelectedIndexChanged(object sender, EventArgs e) - { - mEditorItem.Tool = cmbToolType.SelectedIndex - 1; - } - - private void chkWalkableBefore_CheckedChanged(object sender, EventArgs e) - { - mEditorItem.WalkableBefore = chkWalkableBefore.Checked; - } + if (!TryGetCurrentHealthState(out var currentState)) + { + return; + } - private void chkWalkableAfter_CheckedChanged(object sender, EventArgs e) - { - mEditorItem.WalkableAfter = chkWalkableAfter.Checked; + cmbGraphicType.SelectedIndex = (int)currentState.GraphicType; + chkRenderBelowEntity.Checked = currentState.RenderBelowEntities; + nudHealthRangeMin.Value = currentState.MinHp; + nudHealthRangeMax.Value = currentState.MaxHp; + UpdateGraphicFileControl(currentState); } - private void cmbInitialSprite_SelectedIndexChanged(object sender, EventArgs e) + private void UpdateCurrentState(object sender, EventArgs e) { - mInitialGraphic?.Dispose(); - mInitialGraphic = null; - if (cmbInitialSprite.SelectedIndex > 0) + if (_editorItem is null) { - mEditorItem.Initial.Graphic = cmbInitialSprite.Text; - var graphic = Path.Combine( - "resources", mEditorItem.Initial.GraphicFromTileset ? "tilesets" : "resources", - cmbInitialSprite.Text - ); - - if (File.Exists(graphic)) - { - mInitialGraphic = (Bitmap) Image.FromFile(graphic); - picInitialResource.Width = mInitialGraphic.Width; - picInitialResource.Height = mInitialGraphic.Height; - mInitialBitmap = new Bitmap(picInitialResource.Width, picInitialResource.Height); - } + return; } - else + + if (!TryGetCurrentHealthState(out var currentState)) { - mEditorItem.Initial.Graphic = null; + return; } - picInitialResource.Visible = mInitialGraphic != null; - Render(); + currentState.GraphicType = (ResourceGraphicType)cmbGraphicType.SelectedIndex; + currentState.AnimationId = AnimationDescriptor.IdFromList(cmbAnimation.SelectedIndex - 1); } - private void cmbEndSprite_SelectedIndexChanged(object sender, EventArgs e) + private void UpdateGraphicFileControl(ResourceStateDescriptor currentState) { - mEndGraphic?.Dispose(); - mEndGraphic = null; - if (cmbEndSprite.SelectedIndex > 0) + cmbGraphicFile.Items.Clear(); + cmbGraphicFile.Items.Add(Strings.General.None); + + if (currentState.GraphicType == ResourceGraphicType.Animation) { - mEditorItem.Exhausted.Graphic = cmbEndSprite.Text; - var graphic = Path.Combine( - "resources", mEditorItem.Exhausted.GraphicFromTileset ? "tilesets" : "resources", cmbEndSprite.Text - ); + cmbGraphicFile.Enabled = false; + picResource.Visible = false; + cmbAnimation.Enabled = true; + return; + } - if (File.Exists(graphic)) - { - mEndGraphic = (Bitmap) Image.FromFile(graphic); - picEndResource.Width = mEndGraphic.Width; - picEndResource.Height = mEndGraphic.Height; - mEndBitmap = new Bitmap(picEndResource.Width, picEndResource.Height); - } + cmbGraphicFile.Enabled = true; + picResource.Visible = true; + cmbAnimation.Enabled = false; + + var resources = GameContentManager.GetSmartSortedTextureNames( + currentState.GraphicType == ResourceGraphicType.Tileset + ? GameContentManager.TextureType.Tileset + : GameContentManager.TextureType.Resource + ); + + cmbGraphicFile.Items.AddRange(resources); + + if (_editorItem is null) + { + return; } - else + + if (currentState.Graphic != null && cmbGraphicFile.Items.Contains(currentState.Graphic)) { - mEditorItem.Exhausted.Graphic = null; + cmbGraphicFile.SelectedIndex = cmbGraphicFile.FindString(TextUtils.NullToNone(currentState.Graphic)); + return; } - picEndResource.Visible = mEndGraphic != null; - Render(); + cmbGraphicFile.SelectedIndex = 0; } - public void Render() + private void Render(object sender, EventArgs e) { - if (mEditorItem == null) + if (_editorItem is null) { return; } - // Initial Sprite - var gfx = Graphics.FromImage(mInitialBitmap); - gfx.FillRectangle(Brushes.Black, new Rectangle(0, 0, picInitialResource.Width, picInitialResource.Height)); - if (cmbInitialSprite.SelectedIndex > 0 && mInitialGraphic != null) + if (_graphicBitmap is null) { - gfx.DrawImage( - mInitialGraphic, new Rectangle(0, 0, mInitialGraphic.Width, mInitialGraphic.Height), - new Rectangle(0, 0, mInitialGraphic.Width, mInitialGraphic.Height), GraphicsUnit.Pixel - ); + return; } - if (mEditorItem.Initial.GraphicFromTileset) + if (_resourceGraphic is null) { - var selX = mEditorItem.Initial.X; - var selY = mEditorItem.Initial.Y; - var selW = mEditorItem.Initial.Width; - var selH = mEditorItem.Initial.Height; - if (selW < 0) - { - selX -= Math.Abs(selW); - selW = Math.Abs(selW); - } + return; + } - if (selH < 0) - { - selY -= Math.Abs(selH); - selH = Math.Abs(selH); - } + if (!TryGetCurrentHealthState(out var currentState)) + { + return; + } - gfx.DrawRectangle( - new Pen(System.Drawing.Color.White, 2f), - new Rectangle( - selX * Options.Instance.Map.TileWidth, selY * Options.Instance.Map.TileHeight, - Options.Instance.Map.TileWidth + selW * Options.Instance.Map.TileWidth, Options.Instance.Map.TileHeight + selH * Options.Instance.Map.TileHeight - ) - ); + if (currentState.Graphic is null) + { + return; } - gfx.Dispose(); - gfx = picInitialResource.CreateGraphics(); - gfx.DrawImageUnscaled(mInitialBitmap, new System.Drawing.Point(0, 0)); + if (currentState.GraphicType == ResourceGraphicType.Animation) + { + return; + } - gfx.Dispose(); + var gfx = Graphics.FromImage(_graphicBitmap); + gfx.FillRectangle(Brushes.Black, new Rectangle(0, 0, picResource.Width, picResource.Height)); - // End Sprite - gfx = Graphics.FromImage(mEndBitmap); - gfx.FillRectangle(Brushes.Black, new Rectangle(0, 0, picEndResource.Width, picEndResource.Height)); - if (cmbEndSprite.SelectedIndex > 0 && mEndGraphic != null) + if (cmbGraphicFile.SelectedIndex > 0 && cmbGraphicFile.SelectedIndex > 0) { gfx.DrawImage( - mEndGraphic, new Rectangle(0, 0, mEndGraphic.Width, mEndGraphic.Height), - new Rectangle(0, 0, mEndGraphic.Width, mEndGraphic.Height), GraphicsUnit.Pixel + _resourceGraphic, + new Rectangle(0, 0, _resourceGraphic.Width, _resourceGraphic.Height), + new Rectangle(0, 0, _resourceGraphic.Width, _resourceGraphic.Height), + GraphicsUnit.Pixel ); } - if (mEditorItem.Exhausted.GraphicFromTileset) + if (currentState.GraphicType == ResourceGraphicType.Tileset) { - var selX = mEditorItem.Exhausted.X; - var selY = mEditorItem.Exhausted.Y; - var selW = mEditorItem.Exhausted.Width; - var selH = mEditorItem.Exhausted.Height; + var selX = currentState.X; + var selY = currentState.Y; + var selW = currentState.Width; + var selH = currentState.Height; + if (selW < 0) { selX -= Math.Abs(selW); @@ -459,192 +511,207 @@ public void Render() selH = Math.Abs(selH); } + var tileWidth = Options.Instance.Map.TileWidth; + var tileHeight = Options.Instance.Map.TileHeight; + gfx.DrawRectangle( new Pen(System.Drawing.Color.White, 2f), new Rectangle( - selX * Options.Instance.Map.TileWidth, selY * Options.Instance.Map.TileHeight, - Options.Instance.Map.TileWidth + selW * Options.Instance.Map.TileWidth, Options.Instance.Map.TileHeight + selH * Options.Instance.Map.TileHeight + selX * tileWidth, + selY * tileHeight, + tileWidth + selW * tileWidth, + tileHeight + selH * tileHeight ) ); } gfx.Dispose(); - gfx = picEndResource.CreateGraphics(); - gfx.DrawImageUnscaled(mEndBitmap, new System.Drawing.Point(0, 0)); + gfx = picResource.CreateGraphics(); + gfx.DrawImageUnscaled(_graphicBitmap, new System.Drawing.Point(0, 0)); gfx.Dispose(); } + #endregion + + #region Form Events + private void txtName_TextChanged(object sender, EventArgs e) { - mEditorItem.Name = txtName.Text; - lstGameObjects.UpdateText(txtName.Text); - } + if (_editorItem is null) + { + return; + } - private void frmResource_FormClosed(object sender, FormClosedEventArgs e) - { - btnCancel_Click(null, null); + _editorItem.Name = txtName.Text; + lstGameObjects.UpdateText(txtName.Text); } - private void tmrRender_Tick(object sender, EventArgs e) + private void cmbToolType_SelectedIndexChanged(object sender, EventArgs e) { - Render(); - } + if (_editorItem is null) + { + return; + } - private void toolStripItemNew_Click(object sender, EventArgs e) - { - PacketSender.SendCreateObject(GameObjectType.Resource); + _editorItem.Tool = cmbToolType.SelectedIndex - 1; } - private void toolStripItemDelete_Click(object sender, EventArgs e) + private void nudMinHp_ValueChanged(object sender, EventArgs e) { - if (mEditorItem != null && lstGameObjects.Focused) + if (_editorItem is null) { - if (DarkMessageBox.ShowWarning( - Strings.ResourceEditor.deleteprompt, Strings.ResourceEditor.deletetitle, DarkDialogButton.YesNo, - Icon - ) == - DialogResult.Yes) - { - PacketSender.SendDeleteObject(mEditorItem); - } + return; } + + _editorItem.MinHp = (int)nudMinHp.Value; } - private void toolStripItemCopy_Click(object sender, EventArgs e) + private void nudMaxHp_ValueChanged(object sender, EventArgs e) { - if (mEditorItem != null && lstGameObjects.Focused) + if (_editorItem is null) { - mCopiedItem = mEditorItem.JsonData; - toolStripItemPaste.Enabled = true; + return; } + + _editorItem.MaxHp = (int)nudMaxHp.Value; } - private void toolStripItemPaste_Click(object sender, EventArgs e) + private void nudSpawnDuration_ValueChanged(object sender, EventArgs e) { - if (mEditorItem != null && mCopiedItem != null && lstGameObjects.Focused) + if (_editorItem is null) { - mEditorItem.Load(mCopiedItem, true); - UpdateEditor(); + return; } + + _editorItem.SpawnDuration = (int)nudSpawnDuration.Value; } - private void toolStripItemUndo_Click(object sender, EventArgs e) + private void cmbDeathAnimation_SelectedIndexChanged(object sender, EventArgs e) { - if (mChanged.Contains(mEditorItem) && mEditorItem != null) + if (_editorItem is null) { - if (DarkMessageBox.ShowWarning( - Strings.ResourceEditor.undoprompt, Strings.ResourceEditor.undotitle, DarkDialogButton.YesNo, - Icon - ) == - DialogResult.Yes) - { - mEditorItem.RestoreBackup(); - UpdateEditor(); - } + return; } - } - private void UpdateToolStripItems() - { - toolStripItemCopy.Enabled = mEditorItem != null && lstGameObjects.Focused; - toolStripItemPaste.Enabled = mEditorItem != null && mCopiedItem != null && lstGameObjects.Focused; - toolStripItemDelete.Enabled = mEditorItem != null && lstGameObjects.Focused; - toolStripItemUndo.Enabled = mEditorItem != null && lstGameObjects.Focused; + _editorItem.Animation = AnimationDescriptor.Get(AnimationDescriptor.IdFromList(cmbDeathAnimation.SelectedIndex - 1)); } - private void form_KeyDown(object sender, KeyEventArgs e) + private void chkWalkableBefore_CheckedChanged(object sender, EventArgs e) { - if (e.Control) + if (_editorItem is null) { - if (e.KeyCode == Keys.N) - { - toolStripItemNew_Click(null, null); - } + return; } - } - private void btnRequirements_Click(object sender, EventArgs e) - { - var frm = new FrmDynamicRequirements(mEditorItem.HarvestingRequirements, RequirementType.Resource); - frm.ShowDialog(); + _editorItem.WalkableBefore = chkWalkableBefore.Checked; } - private void cmbAnimation_SelectedIndexChanged(object sender, EventArgs e) + private void chkWalkableAfter_CheckedChanged(object sender, EventArgs e) { - mEditorItem.Animation = AnimationDescriptor.Get(AnimationDescriptor.IdFromList(cmbAnimation.SelectedIndex - 1)); - } + if (_editorItem is null) + { + return; + } - private void nudMinHp_ValueChanged(object sender, EventArgs e) - { - mEditorItem.MinHp = (int) nudMinHp.Value; + _editorItem.WalkableAfter = chkWalkableAfter.Checked; } - private void nudMaxHp_ValueChanged(object sender, EventArgs e) + private void chkUseExplicitMaxHealthForResourceStates_CheckedChanged(object sender, EventArgs e) { - mEditorItem.MaxHp = (int) nudMaxHp.Value; + if (_editorItem is null) + { + return; + } + + _editorItem.UseExplicitMaxHealthForResourceStates = chkUseExplicitMaxHealthForResourceStates.Checked; } private void lstDrops_SelectedIndexChanged(object sender, EventArgs e) { if (lstDrops.SelectedIndex > -1) { - cmbDropItem.SelectedIndex = ItemDescriptor.ListIndex(mEditorItem.Drops[lstDrops.SelectedIndex].ItemId) + 1; - nudDropMaxAmount.Value = mEditorItem.Drops[lstDrops.SelectedIndex].MaxQuantity; - nudDropMinAmount.Value = mEditorItem.Drops[lstDrops.SelectedIndex].MinQuantity; - nudDropChance.Value = (decimal)mEditorItem.Drops[lstDrops.SelectedIndex].Chance; + cmbDropItem.SelectedIndex = ItemDescriptor.ListIndex(_editorItem.Drops[lstDrops.SelectedIndex].ItemId) + 1; + nudDropMaxAmount.Value = _editorItem.Drops[lstDrops.SelectedIndex].MaxQuantity; + nudDropMinAmount.Value = _editorItem.Drops[lstDrops.SelectedIndex].MinQuantity; + nudDropChance.Value = (decimal)_editorItem.Drops[lstDrops.SelectedIndex].Chance; } } private void cmbDropItem_SelectedIndexChanged(object sender, EventArgs e) { + if (_editorItem is null) + { + return; + } + int index = lstDrops.SelectedIndex; if (index < 0 || index > lstDrops.Items.Count) { return; } - mEditorItem.Drops[index].ItemId = ItemDescriptor.IdFromList(cmbDropItem.SelectedIndex - 1); - _dropList[index].ItemId = mEditorItem.Drops[index].ItemId; + _editorItem.Drops[index].ItemId = ItemDescriptor.IdFromList(cmbDropItem.SelectedIndex - 1); + _dropList[index].ItemId = _editorItem.Drops[index].ItemId; } private void nudDropMaxAmount_ValueChanged(object sender, EventArgs e) { + if (_editorItem is null) + { + return; + } + int index = lstDrops.SelectedIndex; if (index < 0 || index > lstDrops.Items.Count) { return; } - mEditorItem.Drops[index].MaxQuantity = (int)nudDropMaxAmount.Value; - _dropList[index].MaxQuantity = mEditorItem.Drops[index].MaxQuantity; + _editorItem.Drops[index].MaxQuantity = (int)nudDropMaxAmount.Value; + _dropList[index].MaxQuantity = _editorItem.Drops[index].MaxQuantity; } private void nudDropMinAmount_ValueChanged(object sender, EventArgs e) { + if (_editorItem is null) + { + return; + } + int index = lstDrops.SelectedIndex; if (index < 0 || index > lstDrops.Items.Count) { return; } - mEditorItem.Drops[index].MinQuantity = (int)nudDropMinAmount.Value; - _dropList[index].MinQuantity = mEditorItem.Drops[index].MinQuantity; + _editorItem.Drops[index].MinQuantity = (int)nudDropMinAmount.Value; + _dropList[index].MinQuantity = _editorItem.Drops[index].MinQuantity; } private void nudDropChance_ValueChanged(object sender, EventArgs e) { + if (_editorItem is null) + { + return; + } + int index = lstDrops.SelectedIndex; if (index < 0 || index > lstDrops.Items.Count) { return; } - mEditorItem.Drops[index].Chance = (double)nudDropChance.Value; - _dropList[index].Chance = mEditorItem.Drops[index].Chance; + _editorItem.Drops[index].Chance = (double)nudDropChance.Value; + _dropList[index].Chance = _editorItem.Drops[index].Chance; } private void btnDropAdd_Click(object sender, EventArgs e) { + if (_editorItem is null) + { + return; + } + var drop = new Drop() { ItemId = ItemDescriptor.IdFromList(cmbDropItem.SelectedIndex - 1), @@ -653,7 +720,7 @@ private void btnDropAdd_Click(object sender, EventArgs e) Chance = (double)nudDropChance.Value }; - mEditorItem.Drops.Add(drop); + _editorItem.Drops.Add(drop); _dropList.Add(new NotifiableDrop { @@ -668,163 +735,267 @@ private void btnDropAdd_Click(object sender, EventArgs e) private void btnDropRemove_Click(object sender, EventArgs e) { + if (_editorItem is null) + { + return; + } + if (lstDrops.SelectedIndex < 0) { return; } var index = lstDrops.SelectedIndex; - mEditorItem.Drops.RemoveAt(index); + _editorItem.Drops.RemoveAt(index); _dropList.RemoveAt(index); } - private void chkInitialFromTileset_CheckedChanged(object sender, EventArgs e) + private void nudHpRegen_ValueChanged(object sender, EventArgs e) { - mEditorItem.Initial.GraphicFromTileset = chkInitialFromTileset.Checked; - PopulateInitialGraphicList(); + if (_editorItem is null) + { + return; + } + + _editorItem.VitalRegen = (int)nudHpRegen.Value; } - private void chkExhaustedFromTileset_CheckedChanged(object sender, EventArgs e) + private void cmbEvent_SelectedIndexChanged(object sender, EventArgs e) { - mEditorItem.Exhausted.GraphicFromTileset = chkExhaustedFromTileset.Checked; - PopulateExhaustedGraphicList(); + if (_editorItem is null) + { + return; + } + + _editorItem.Event = EventDescriptor.Get(EventDescriptor.IdFromList(cmbEvent.SelectedIndex - 1)); } - private void picInitialResource_MouseDown(object sender, MouseEventArgs e) + private void btnRequirements_Click(object sender, EventArgs e) { - if (e.X > picInitialResource.Width || e.Y > picInitialResource.Height) + if (_editorItem is null) { return; } - if (!chkInitialFromTileset.Checked) + var frm = new FrmDynamicRequirements(_editorItem.HarvestingRequirements, RequirementType.Resource); + frm.ShowDialog(); + } + + private void txtCannotHarvest_TextChanged(object sender, EventArgs e) + { + if (_editorItem is null) { return; } - mMouseDown = true; - mEditorItem.Initial.X = (int) Math.Floor((double) e.X / Options.Instance.Map.TileWidth); - mEditorItem.Initial.Y = (int) Math.Floor((double) e.Y / Options.Instance.Map.TileHeight); - mEditorItem.Initial.Width = 0; - mEditorItem.Initial.Height = 0; - if (mEditorItem.Initial.X < 0) + _editorItem.CannotHarvestMessage = txtCannotHarvest.Text; + } + + private void lstHealthState_SelectedIndexChanged(object sender, EventArgs e) + { + if (_editorItem is null) { - mEditorItem.Initial.X = 0; + return; } - if (mEditorItem.Initial.Y < 0) + if (lstHealthState.SelectedIndex < 0) { - mEditorItem.Initial.Y = 0; + return; } - Render(); + UpdateHealthStateControls(); } - private void picInitialResource_MouseUp(object sender, MouseEventArgs e) + private void btnAddHealthState_Click(object sender, EventArgs e) { - if (e.X > picInitialResource.Width || e.Y > picInitialResource.Height) + //alert if name is less than 3 characters + if (txtHealthStateName.Text.Length <= 0) { + DarkMessageBox.ShowError( + Strings.ResourceEditor.HealthStateNameError, + Strings.ResourceEditor.HealthStateErrorTitle + ); return; } - if (!chkInitialFromTileset.Checked) + if (_editorItem is null) { return; } - var selX = mEditorItem.Initial.X; - var selY = mEditorItem.Initial.Y; - var selW = mEditorItem.Initial.Width; - var selH = mEditorItem.Initial.Height; - if (selW < 0) + if (_editorItem.HealthGraphics.ContainsKey(txtHealthStateName.Text)) { - selX -= Math.Abs(selW); - selW = Math.Abs(selW); + DarkMessageBox.ShowError( + Strings.ResourceEditor.HealthStateNameExists, + Strings.ResourceEditor.HealthStateErrorTitle + ); + return; } - if (selH < 0) + var state = new ResourceStateDescriptor(); + _editorItem.HealthGraphics.Add(txtHealthStateName.Text, state); + lstHealthState.Items.Add(txtHealthStateName.Text); + lstHealthState.SelectedIndex = lstHealthState.Items.Count - 1; + txtHealthStateName.Text = string.Empty; + } + + private void btnRemoveHealthState_Click(object sender, EventArgs e) + { + if (_editorItem is null) { - selY -= Math.Abs(selH); - selH = Math.Abs(selH); + return; } - mEditorItem.Initial.X = selX; - mEditorItem.Initial.Y = selY; - mEditorItem.Initial.Width = selW; - mEditorItem.Initial.Height = selH; - mMouseDown = false; - Render(); + var selectedIndex = lstHealthState.SelectedIndex; + if (selectedIndex < 0) + { + return; + } + + var stateKey = _editorItem.HealthGraphics.Keys.ToList()[selectedIndex]; + if (!_editorItem.HealthGraphics.TryGetValue(stateKey, out _)) + { + return; + } + + _editorItem.HealthGraphics.Remove(stateKey); + lstHealthState.Items.RemoveAt(selectedIndex); + if (lstHealthState.Items.Count > 0) + { + lstHealthState.SelectedIndex = 0; + } } - private void picInitialResource_MouseMove(object sender, MouseEventArgs e) + private void cmbGraphicType_SelectedIndexChanged(object sender, EventArgs e) { - if (e.X > picInitialResource.Width || e.Y > picInitialResource.Height) + if (!TryGetCurrentHealthState(out var currentState)) { return; } - if (!chkInitialFromTileset.Checked) + UpdateCurrentState(sender, e); + UpdateGraphicFileControl(currentState); + } + + private void chkRenderBelowEntity_CheckedChanged(object sender, EventArgs e) + { + if (!TryGetCurrentHealthState(out var currentState)) + { + return; + } + + currentState.RenderBelowEntities = chkRenderBelowEntity.Checked; + } + + private void cmbGraphicFile_SelectedIndexChanged(object sender, EventArgs e) + { + _resourceGraphic?.Dispose(); + _resourceGraphic = null; + + if (!TryGetCurrentHealthState(out var currentState)) + { + return; + } + + if (cmbGraphicFile.SelectedIndex > 0) + { + currentState.Graphic = cmbGraphicFile.Text; + var graphic = Path.Combine( + "resources", currentState.GraphicType == ResourceGraphicType.Tileset ? "tilesets" : "resources", cmbGraphicFile.Text + ); + + if (File.Exists(graphic)) + { + _resourceGraphic = (Bitmap)Image.FromFile(graphic); + picResource.Width = _resourceGraphic.Width; + picResource.Height = _resourceGraphic.Height; + _graphicBitmap = new Bitmap(picResource.Width, picResource.Height); + } + } + else + { + currentState.Graphic = null; + } + + picResource.Visible = _resourceGraphic != null; + } + + private void nudHealthRangeMin_ValueChanged(object sender, EventArgs e) + { + if (!TryGetCurrentHealthState(out var currentState)) { return; } - if (mMouseDown) + currentState.MinHp = (int)nudHealthRangeMin.Value; + } + + private void nudHealthRangeMax_ValueChanged(object sender, EventArgs e) + { + if (!TryGetCurrentHealthState(out var currentState)) { - var tmpX = (int) Math.Floor((double) e.X / Options.Instance.Map.TileWidth); - var tmpY = (int) Math.Floor((double) e.Y / Options.Instance.Map.TileHeight); - mEditorItem.Initial.Width = tmpX - mEditorItem.Initial.X; - mEditorItem.Initial.Height = tmpY - mEditorItem.Initial.Y; + return; } - Render(); + currentState.MaxHp = (int)nudHealthRangeMax.Value; } - private void picExhustedResource_MouseDown(object sender, MouseEventArgs e) + private void picResource_MouseDown(object sender, MouseEventArgs e) { - if (e.X > picEndResource.Width || e.Y > picEndResource.Height) + if (_editorItem is null) { return; } - if (!chkExhaustedFromTileset.Checked) + if (e.X > picResource.Width || e.Y > picResource.Height) { return; } - mMouseDown = true; - mEditorItem.Exhausted.X = (int) Math.Floor((double) e.X / Options.Instance.Map.TileWidth); - mEditorItem.Exhausted.Y = (int) Math.Floor((double) e.Y / Options.Instance.Map.TileHeight); - mEditorItem.Exhausted.Width = 0; - mEditorItem.Exhausted.Height = 0; - if (mEditorItem.Exhausted.X < 0) + if ((ResourceGraphicType)cmbGraphicType.SelectedIndex != ResourceGraphicType.Tileset) { - mEditorItem.Exhausted.X = 0; + return; } - if (mEditorItem.Exhausted.Y < 0) + if (!TryGetCurrentHealthState(out var currentState)) { - mEditorItem.Exhausted.Y = 0; + return; } - Render(); + _mouseDown = true; + currentState.X = Math.Max(0, (int)Math.Floor((double)e.X / Options.Instance.Map.TileWidth)); + currentState.Y = Math.Max(0, (int)Math.Floor((double)e.Y / Options.Instance.Map.TileHeight)); + currentState.Width = 0; + currentState.Height = 0; } - private void picExhaustedResource_MouseUp(object sender, MouseEventArgs e) + private void picResource_MouseUp(object sender, MouseEventArgs e) { - if (e.X > picEndResource.Width || e.Y > picEndResource.Height) + if (_editorItem is null) { return; } - if (!chkExhaustedFromTileset.Checked) + if (e.X > picResource.Width || e.Y > picResource.Height) { return; } - var selX = mEditorItem.Exhausted.X; - var selY = mEditorItem.Exhausted.Y; - var selW = mEditorItem.Exhausted.Width; - var selH = mEditorItem.Exhausted.Height; + if ((ResourceGraphicType)cmbGraphicType.SelectedIndex != ResourceGraphicType.Tileset) + { + return; + } + + if (!TryGetCurrentHealthState(out var currentState)) + { + return; + } + + var selX = currentState.X; + var selY = currentState.Y; + var selW = currentState.Width; + var selH = currentState.Height; + if (selW < 0) { selX -= Math.Abs(selW); @@ -837,61 +1008,45 @@ private void picExhaustedResource_MouseUp(object sender, MouseEventArgs e) selH = Math.Abs(selH); } - mEditorItem.Exhausted.X = selX; - mEditorItem.Exhausted.Y = selY; - mEditorItem.Exhausted.Width = selW; - mEditorItem.Exhausted.Height = selH; - mMouseDown = false; - Render(); + currentState.X = selX; + currentState.Y = selY; + currentState.Width = selW; + currentState.Height = selH; + _mouseDown = false; } - private void picExhaustedResource_MouseMove(object sender, MouseEventArgs e) + private void picResource_MouseMove(object sender, MouseEventArgs e) { - if (e.X > picEndResource.Width || e.Y > picEndResource.Height) + if (_editorItem is null) { return; } - if (!chkExhaustedFromTileset.Checked) + if (e.X > picResource.Width || e.Y > picResource.Height) { return; } - if (mMouseDown) + if ((ResourceGraphicType)cmbGraphicType.SelectedIndex != ResourceGraphicType.Tileset) { - var tmpX = (int) Math.Floor((double) e.X / Options.Instance.Map.TileWidth); - var tmpY = (int) Math.Floor((double) e.Y / Options.Instance.Map.TileHeight); - mEditorItem.Exhausted.Width = tmpX - mEditorItem.Exhausted.X; - mEditorItem.Exhausted.Height = tmpY - mEditorItem.Exhausted.Y; + return; } - Render(); - } - - private void nudHpRegen_ValueChanged(object sender, EventArgs e) - { - mEditorItem.VitalRegen = (int) nudHpRegen.Value; - } - - private void cmbEvent_SelectedIndexChanged(object sender, EventArgs e) - { - mEditorItem.Event = EventDescriptor.Get(EventDescriptor.IdFromList(cmbEvent.SelectedIndex - 1)); - } - - private void chkInitialBelowEntities_CheckedChanged(object sender, EventArgs e) - { - mEditorItem.Initial.RenderBelowEntities = chkInitialBelowEntities.Checked; - } + if (!TryGetCurrentHealthState(out var currentState)) + { + return; + } - private void chkExhaustedBelowEntities_CheckedChanged(object sender, EventArgs e) - { - mEditorItem.Exhausted.RenderBelowEntities = chkExhaustedBelowEntities.Checked; + if (_mouseDown) + { + var tmpX = Math.Max(0, (int)Math.Floor((double)e.X / Options.Instance.Map.TileWidth)); + var tmpY = Math.Max(0, (int)Math.Floor((double)e.Y / Options.Instance.Map.TileHeight)); + currentState.Width = tmpX - currentState.X; + currentState.Height = tmpY - currentState.Y; + } } - private void txtCannotHarvest_TextChanged(object sender, EventArgs e) - { - mEditorItem.CannotHarvestMessage = txtCannotHarvest.Text; - } + #endregion #region "Item List - Folders, Searching, Sorting, Etc" @@ -901,22 +1056,22 @@ public void InitEditor() var mFolders = new List(); foreach (var itm in ResourceDescriptor.Lookup) { - if (!string.IsNullOrEmpty(((ResourceDescriptor) itm.Value).Folder) && - !mFolders.Contains(((ResourceDescriptor) itm.Value).Folder)) + if (!string.IsNullOrEmpty(((ResourceDescriptor)itm.Value).Folder) && + !mFolders.Contains(((ResourceDescriptor)itm.Value).Folder)) { - mFolders.Add(((ResourceDescriptor) itm.Value).Folder); - if (!mKnownFolders.Contains(((ResourceDescriptor) itm.Value).Folder)) + mFolders.Add(((ResourceDescriptor)itm.Value).Folder); + if (!_knownFolders.Contains(((ResourceDescriptor)itm.Value).Folder)) { - mKnownFolders.Add(((ResourceDescriptor) itm.Value).Folder); + _knownFolders.Add(((ResourceDescriptor)itm.Value).Folder); } } } mFolders.Sort(); - mKnownFolders.Sort(); + _knownFolders.Sort(); cmbFolder.Items.Clear(); cmbFolder.Items.Add(""); - cmbFolder.Items.AddRange(mKnownFolders.ToArray()); + cmbFolder.Items.AddRange(_knownFolders.ToArray()); var items = ResourceDescriptor.Lookup.OrderBy(p => p.Value?.Name).Select(pair => new KeyValuePair>(pair.Key, new KeyValuePair(((ResourceDescriptor)pair.Value)?.Name ?? Models.DatabaseObject.Deleted, ((ResourceDescriptor)pair.Value)?.Folder ?? ""))).ToArray(); @@ -935,7 +1090,7 @@ private void btnAddFolder_Click(object sender, EventArgs e) { if (!cmbFolder.Items.Contains(folderName)) { - mEditorItem.Folder = folderName; + _editorItem.Folder = folderName; lstGameObjects.ExpandFolder(folderName); InitEditor(); cmbFolder.Text = folderName; @@ -945,7 +1100,7 @@ private void btnAddFolder_Click(object sender, EventArgs e) private void cmbFolder_SelectedIndexChanged(object sender, EventArgs e) { - mEditorItem.Folder = cmbFolder.Text; + _editorItem.Folder = cmbFolder.Text; InitEditor(); } diff --git a/Intersect.Editor/Forms/Editors/frmResource.resx b/Intersect.Editor/Forms/Editors/frmResource.resx index c277bbb80b..59159b1071 100644 --- a/Intersect.Editor/Forms/Editors/frmResource.resx +++ b/Intersect.Editor/Forms/Editors/frmResource.resx @@ -1,7 +1,7 @@