diff --git a/MaterialForm.Designer.cs b/MaterialForm.Designer.cs new file mode 100644 index 0000000..11fd9c9 --- /dev/null +++ b/MaterialForm.Designer.cs @@ -0,0 +1,429 @@ +namespace cdda_item_creator +{ + partial class MaterialForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.identTextBox = new System.Windows.Forms.TextBox(); + this.nameTextBox = new System.Windows.Forms.TextBox(); + this.bashResistUpDown = new System.Windows.Forms.NumericUpDown(); + this.cutResistUpDown = new System.Windows.Forms.NumericUpDown(); + this.acidResistUpDown = new System.Windows.Forms.NumericUpDown(); + this.chipResistUpDown = new System.Windows.Forms.NumericUpDown(); + this.elecResistUpDown = new System.Windows.Forms.NumericUpDown(); + this.fireResistUpDown = new System.Windows.Forms.NumericUpDown(); + this.specificHeatLiquidUpDown = new System.Windows.Forms.NumericUpDown(); + this.specificHeatSolidUpDown = new System.Windows.Forms.NumericUpDown(); + this.latentHeatUpDown = new System.Windows.Forms.NumericUpDown(); + this.freezePointUpDown = new System.Windows.Forms.NumericUpDown(); + this.salvagedIntoTextBox = new System.Windows.Forms.TextBox(); + this.repairedIntoTextBox = new System.Windows.Forms.TextBox(); + this.edibleCheckBox = new System.Windows.Forms.CheckBox(); + this.rottingCheckBox = new System.Windows.Forms.CheckBox(); + this.softCheckBox = new System.Windows.Forms.CheckBox(); + this.reinforcesCheckBox = new System.Windows.Forms.CheckBox(); + this.bashDmgVerbTextBox = new System.Windows.Forms.TextBox(); + this.cutDmgVerbTextBox = new System.Windows.Forms.TextBox(); + this.materialLoaderComboBox = new System.Windows.Forms.ComboBox(); + this.densityUpDown = new System.Windows.Forms.NumericUpDown(); + ((System.ComponentModel.ISupportInitialize)(this.bashResistUpDown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.cutResistUpDown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.acidResistUpDown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.chipResistUpDown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.elecResistUpDown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.fireResistUpDown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.specificHeatLiquidUpDown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.specificHeatSolidUpDown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.latentHeatUpDown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.freezePointUpDown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.densityUpDown)).BeginInit(); + this.SuspendLayout(); + // + // identTextBox + // + this.identTextBox.Location = new System.Drawing.Point(60, 58); + this.identTextBox.Name = "identTextBox"; + this.identTextBox.Size = new System.Drawing.Size(100, 20); + this.identTextBox.TabIndex = 0; + // + // nameTextBox + // + this.nameTextBox.Location = new System.Drawing.Point(60, 105); + this.nameTextBox.Name = "nameTextBox"; + this.nameTextBox.Size = new System.Drawing.Size(100, 20); + this.nameTextBox.TabIndex = 1; + // + // bashResistUpDown + // + this.bashResistUpDown.Location = new System.Drawing.Point(60, 146); + this.bashResistUpDown.Maximum = new decimal(new int[] { + 99999, + 0, + 0, + 0}); + this.bashResistUpDown.Minimum = new decimal(new int[] { + 99999, + 0, + 0, + -2147483648}); + this.bashResistUpDown.Name = "bashResistUpDown"; + this.bashResistUpDown.Size = new System.Drawing.Size(56, 20); + this.bashResistUpDown.TabIndex = 2; + // + // cutResistUpDown + // + this.cutResistUpDown.Location = new System.Drawing.Point(60, 172); + this.cutResistUpDown.Maximum = new decimal(new int[] { + 99999, + 0, + 0, + 0}); + this.cutResistUpDown.Minimum = new decimal(new int[] { + 99999, + 0, + 0, + -2147483648}); + this.cutResistUpDown.Name = "cutResistUpDown"; + this.cutResistUpDown.Size = new System.Drawing.Size(56, 20); + this.cutResistUpDown.TabIndex = 3; + // + // acidResistUpDown + // + this.acidResistUpDown.Location = new System.Drawing.Point(60, 198); + this.acidResistUpDown.Maximum = new decimal(new int[] { + 99999, + 0, + 0, + 0}); + this.acidResistUpDown.Minimum = new decimal(new int[] { + 99999, + 0, + 0, + -2147483648}); + this.acidResistUpDown.Name = "acidResistUpDown"; + this.acidResistUpDown.Size = new System.Drawing.Size(56, 20); + this.acidResistUpDown.TabIndex = 4; + // + // chipResistUpDown + // + this.chipResistUpDown.Location = new System.Drawing.Point(60, 276); + this.chipResistUpDown.Maximum = new decimal(new int[] { + 99999, + 0, + 0, + 0}); + this.chipResistUpDown.Minimum = new decimal(new int[] { + 99999, + 0, + 0, + -2147483648}); + this.chipResistUpDown.Name = "chipResistUpDown"; + this.chipResistUpDown.Size = new System.Drawing.Size(56, 20); + this.chipResistUpDown.TabIndex = 5; + // + // elecResistUpDown + // + this.elecResistUpDown.Location = new System.Drawing.Point(60, 224); + this.elecResistUpDown.Maximum = new decimal(new int[] { + 99999, + 0, + 0, + 0}); + this.elecResistUpDown.Minimum = new decimal(new int[] { + 99999, + 0, + 0, + -2147483648}); + this.elecResistUpDown.Name = "elecResistUpDown"; + this.elecResistUpDown.Size = new System.Drawing.Size(56, 20); + this.elecResistUpDown.TabIndex = 6; + // + // fireResistUpDown + // + this.fireResistUpDown.Location = new System.Drawing.Point(60, 250); + this.fireResistUpDown.Maximum = new decimal(new int[] { + 99999, + 0, + 0, + 0}); + this.fireResistUpDown.Minimum = new decimal(new int[] { + 99999, + 0, + 0, + -2147483648}); + this.fireResistUpDown.Name = "fireResistUpDown"; + this.fireResistUpDown.Size = new System.Drawing.Size(56, 20); + this.fireResistUpDown.TabIndex = 7; + // + // specificHeatLiquidUpDown + // + this.specificHeatLiquidUpDown.DecimalPlaces = 3; + this.specificHeatLiquidUpDown.Increment = new decimal(new int[] { + 5, + 0, + 0, + 131072}); + this.specificHeatLiquidUpDown.Location = new System.Drawing.Point(184, 146); + this.specificHeatLiquidUpDown.Maximum = new decimal(new int[] { + 99999, + 0, + 0, + 0}); + this.specificHeatLiquidUpDown.Minimum = new decimal(new int[] { + 99999, + 0, + 0, + -2147483648}); + this.specificHeatLiquidUpDown.Name = "specificHeatLiquidUpDown"; + this.specificHeatLiquidUpDown.Size = new System.Drawing.Size(56, 20); + this.specificHeatLiquidUpDown.TabIndex = 8; + // + // specificHeatSolidUpDown + // + this.specificHeatSolidUpDown.DecimalPlaces = 3; + this.specificHeatSolidUpDown.Increment = new decimal(new int[] { + 5, + 0, + 0, + 131072}); + this.specificHeatSolidUpDown.Location = new System.Drawing.Point(184, 172); + this.specificHeatSolidUpDown.Maximum = new decimal(new int[] { + 99999, + 0, + 0, + 0}); + this.specificHeatSolidUpDown.Minimum = new decimal(new int[] { + 99999, + 0, + 0, + -2147483648}); + this.specificHeatSolidUpDown.Name = "specificHeatSolidUpDown"; + this.specificHeatSolidUpDown.Size = new System.Drawing.Size(56, 20); + this.specificHeatSolidUpDown.TabIndex = 9; + // + // latentHeatUpDown + // + this.latentHeatUpDown.DecimalPlaces = 1; + this.latentHeatUpDown.Increment = new decimal(new int[] { + 5, + 0, + 0, + 131072}); + this.latentHeatUpDown.Location = new System.Drawing.Point(184, 198); + this.latentHeatUpDown.Maximum = new decimal(new int[] { + 99999, + 0, + 0, + 0}); + this.latentHeatUpDown.Minimum = new decimal(new int[] { + 99999, + 0, + 0, + -2147483648}); + this.latentHeatUpDown.Name = "latentHeatUpDown"; + this.latentHeatUpDown.Size = new System.Drawing.Size(56, 20); + this.latentHeatUpDown.TabIndex = 10; + // + // freezePointUpDown + // + this.freezePointUpDown.Location = new System.Drawing.Point(184, 224); + this.freezePointUpDown.Maximum = new decimal(new int[] { + 99999, + 0, + 0, + 0}); + this.freezePointUpDown.Minimum = new decimal(new int[] { + 99999, + 0, + 0, + -2147483648}); + this.freezePointUpDown.Name = "freezePointUpDown"; + this.freezePointUpDown.Size = new System.Drawing.Size(56, 20); + this.freezePointUpDown.TabIndex = 11; + // + // salvagedIntoTextBox + // + this.salvagedIntoTextBox.Location = new System.Drawing.Point(184, 263); + this.salvagedIntoTextBox.Name = "salvagedIntoTextBox"; + this.salvagedIntoTextBox.Size = new System.Drawing.Size(100, 20); + this.salvagedIntoTextBox.TabIndex = 12; + // + // repairedIntoTextBox + // + this.repairedIntoTextBox.Location = new System.Drawing.Point(184, 299); + this.repairedIntoTextBox.Name = "repairedIntoTextBox"; + this.repairedIntoTextBox.Size = new System.Drawing.Size(100, 20); + this.repairedIntoTextBox.TabIndex = 13; + // + // edibleCheckBox + // + this.edibleCheckBox.AutoSize = true; + this.edibleCheckBox.Location = new System.Drawing.Point(184, 326); + this.edibleCheckBox.Name = "edibleCheckBox"; + this.edibleCheckBox.Size = new System.Drawing.Size(55, 17); + this.edibleCheckBox.TabIndex = 14; + this.edibleCheckBox.Text = "Edible"; + this.edibleCheckBox.UseVisualStyleBackColor = true; + // + // rottingCheckBox + // + this.rottingCheckBox.AutoSize = true; + this.rottingCheckBox.Location = new System.Drawing.Point(184, 349); + this.rottingCheckBox.Name = "rottingCheckBox"; + this.rottingCheckBox.Size = new System.Drawing.Size(60, 17); + this.rottingCheckBox.TabIndex = 15; + this.rottingCheckBox.Text = "Rotting"; + this.rottingCheckBox.UseVisualStyleBackColor = true; + // + // softCheckBox + // + this.softCheckBox.AutoSize = true; + this.softCheckBox.Location = new System.Drawing.Point(184, 372); + this.softCheckBox.Name = "softCheckBox"; + this.softCheckBox.Size = new System.Drawing.Size(45, 17); + this.softCheckBox.TabIndex = 16; + this.softCheckBox.Text = "Soft"; + this.softCheckBox.UseVisualStyleBackColor = true; + // + // reinforcesCheckBox + // + this.reinforcesCheckBox.AutoSize = true; + this.reinforcesCheckBox.Location = new System.Drawing.Point(184, 395); + this.reinforcesCheckBox.Name = "reinforcesCheckBox"; + this.reinforcesCheckBox.Size = new System.Drawing.Size(77, 17); + this.reinforcesCheckBox.TabIndex = 17; + this.reinforcesCheckBox.Text = "Reinforces"; + this.reinforcesCheckBox.UseVisualStyleBackColor = true; + // + // bashDmgVerbTextBox + // + this.bashDmgVerbTextBox.Location = new System.Drawing.Point(342, 58); + this.bashDmgVerbTextBox.Name = "bashDmgVerbTextBox"; + this.bashDmgVerbTextBox.Size = new System.Drawing.Size(100, 20); + this.bashDmgVerbTextBox.TabIndex = 18; + // + // cutDmgVerbTextBox + // + this.cutDmgVerbTextBox.Location = new System.Drawing.Point(342, 84); + this.cutDmgVerbTextBox.Name = "cutDmgVerbTextBox"; + this.cutDmgVerbTextBox.Size = new System.Drawing.Size(100, 20); + this.cutDmgVerbTextBox.TabIndex = 19; + // + // materialLoaderComboBox + // + this.materialLoaderComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.materialLoaderComboBox.FormattingEnabled = true; + this.materialLoaderComboBox.Location = new System.Drawing.Point(60, 13); + this.materialLoaderComboBox.Name = "materialLoaderComboBox"; + this.materialLoaderComboBox.Size = new System.Drawing.Size(121, 21); + this.materialLoaderComboBox.TabIndex = 20; + this.materialLoaderComboBox.SelectedIndexChanged += new System.EventHandler(this.materialLoaderComboBox_SelectedIndexChanged); + // + // densityUpDown + // + this.densityUpDown.Location = new System.Drawing.Point(60, 302); + this.densityUpDown.Maximum = new decimal(new int[] { + 99999, + 0, + 0, + 0}); + this.densityUpDown.Name = "densityUpDown"; + this.densityUpDown.Size = new System.Drawing.Size(56, 20); + this.densityUpDown.TabIndex = 21; + // + // MaterialForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.densityUpDown); + this.Controls.Add(this.materialLoaderComboBox); + this.Controls.Add(this.cutDmgVerbTextBox); + this.Controls.Add(this.bashDmgVerbTextBox); + this.Controls.Add(this.reinforcesCheckBox); + this.Controls.Add(this.softCheckBox); + this.Controls.Add(this.rottingCheckBox); + this.Controls.Add(this.edibleCheckBox); + this.Controls.Add(this.repairedIntoTextBox); + this.Controls.Add(this.salvagedIntoTextBox); + this.Controls.Add(this.freezePointUpDown); + this.Controls.Add(this.latentHeatUpDown); + this.Controls.Add(this.specificHeatSolidUpDown); + this.Controls.Add(this.specificHeatLiquidUpDown); + this.Controls.Add(this.fireResistUpDown); + this.Controls.Add(this.elecResistUpDown); + this.Controls.Add(this.chipResistUpDown); + this.Controls.Add(this.acidResistUpDown); + this.Controls.Add(this.cutResistUpDown); + this.Controls.Add(this.bashResistUpDown); + this.Controls.Add(this.nameTextBox); + this.Controls.Add(this.identTextBox); + this.Name = "MaterialForm"; + this.Text = "MaterialForm"; + ((System.ComponentModel.ISupportInitialize)(this.bashResistUpDown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.cutResistUpDown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.acidResistUpDown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.chipResistUpDown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.elecResistUpDown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.fireResistUpDown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.specificHeatLiquidUpDown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.specificHeatSolidUpDown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.latentHeatUpDown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.freezePointUpDown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.densityUpDown)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox identTextBox; + private System.Windows.Forms.TextBox nameTextBox; + private System.Windows.Forms.NumericUpDown bashResistUpDown; + private System.Windows.Forms.NumericUpDown cutResistUpDown; + private System.Windows.Forms.NumericUpDown acidResistUpDown; + private System.Windows.Forms.NumericUpDown chipResistUpDown; + private System.Windows.Forms.NumericUpDown elecResistUpDown; + private System.Windows.Forms.NumericUpDown fireResistUpDown; + private System.Windows.Forms.NumericUpDown specificHeatLiquidUpDown; + private System.Windows.Forms.NumericUpDown specificHeatSolidUpDown; + private System.Windows.Forms.NumericUpDown latentHeatUpDown; + private System.Windows.Forms.NumericUpDown freezePointUpDown; + private System.Windows.Forms.TextBox salvagedIntoTextBox; + private System.Windows.Forms.TextBox repairedIntoTextBox; + private System.Windows.Forms.CheckBox edibleCheckBox; + private System.Windows.Forms.CheckBox rottingCheckBox; + private System.Windows.Forms.CheckBox softCheckBox; + private System.Windows.Forms.CheckBox reinforcesCheckBox; + private System.Windows.Forms.TextBox bashDmgVerbTextBox; + private System.Windows.Forms.TextBox cutDmgVerbTextBox; + private System.Windows.Forms.ComboBox materialLoaderComboBox; + private System.Windows.Forms.NumericUpDown densityUpDown; + } +} \ No newline at end of file diff --git a/MaterialForm.cs b/MaterialForm.cs new file mode 100644 index 0000000..355e255 --- /dev/null +++ b/MaterialForm.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace cdda_item_creator +{ + public partial class MaterialForm : Form + { + MaterialType main_material = new MaterialType() { }; + private BindingSource MaterialBindingSource; + private void LoadMaterialDataBinding() + { + MaterialBindingSource = new BindingSource(components); + ((ISupportInitialize)(MaterialBindingSource)).BeginInit(); + + identTextBox.DataBindings.Add(new Binding("Text", MaterialBindingSource, "Ident", true)); + nameTextBox.DataBindings.Add(new Binding("Text", MaterialBindingSource, "Name", true)); + + bashResistUpDown.DataBindings.Add(new Binding("Value", MaterialBindingSource, "BashResist", true)); + cutResistUpDown.DataBindings.Add(new Binding("Value", MaterialBindingSource, "CutResist", true)); + acidResistUpDown.DataBindings.Add(new Binding("Value", MaterialBindingSource, "AcidResist", true)); + elecResistUpDown.DataBindings.Add(new Binding("Value", MaterialBindingSource, "ElecResist", true)); + fireResistUpDown.DataBindings.Add(new Binding("Value", MaterialBindingSource, "fireResist", true)); + chipResistUpDown.DataBindings.Add(new Binding("Value", MaterialBindingSource, "ChipResist", true)); + + densityUpDown.DataBindings.Add(new Binding("Value", MaterialBindingSource, "Density", true)); + + specificHeatLiquidUpDown.DataBindings.Add(new Binding("Value", MaterialBindingSource, "SpecificHeatLiquid", true)); + specificHeatSolidUpDown.DataBindings.Add(new Binding("Value", MaterialBindingSource, "SpecificHeatSolid", true)); + latentHeatUpDown.DataBindings.Add(new Binding("Value", MaterialBindingSource, "LatentHeat", true)); + freezePointUpDown.DataBindings.Add(new Binding("Value", MaterialBindingSource, "FreezePoint", true)); + + salvagedIntoTextBox.DataBindings.Add(new Binding("Text", MaterialBindingSource, "SalvagedInto", true)); + repairedIntoTextBox.DataBindings.Add(new Binding("Text", MaterialBindingSource, "RepairedInto", true)); + + edibleCheckBox.DataBindings.Add(new Binding("Checked", MaterialBindingSource, "Edible", true)); + rottingCheckBox.DataBindings.Add(new Binding("Checked", MaterialBindingSource, "Rotting", true)); + softCheckBox.DataBindings.Add(new Binding("Checked", MaterialBindingSource, "Soft", true)); + reinforcesCheckBox.DataBindings.Add(new Binding("Checked", MaterialBindingSource, "Reinforces", true)); + + bashDmgVerbTextBox.DataBindings.Add(new Binding("Text", MaterialBindingSource, "BashDmgVerb", true)); + cutDmgVerbTextBox.DataBindings.Add(new Binding("Text", MaterialBindingSource, "CutDmgVerb", true)); + + ((ISupportInitialize)(MaterialBindingSource)).EndInit(); + + MaterialBindingSource.Add(main_material); + } + private void LoadMaterialList() + { + materialLoaderComboBox.Items.AddRange(Program.LoadedObjectDictionary.GetList("material").ToArray()); + } + public MaterialForm() + { + InitializeComponent(); + LoadMaterialList(); + LoadMaterialDataBinding(); + } + private void UpdateMainMaterialBindings() + { + MaterialBindingSource.Clear(); + MaterialBindingSource.Add(main_material); + MaterialBindingSource.ResetBindings(false); + } + private void materialLoaderComboBox_SelectedIndexChanged(object sender, EventArgs e) + { + if (materialLoaderComboBox.SelectedIndex == -1) + { + return; + } + // TODO: selector for items, and show what mod they're from + List mats = Program.LoadedObjectDictionary.GetMaterials(materialLoaderComboBox.Text); + main_material = mats[0].DeepCopy(); + UpdateMainMaterialBindings(); + } + } +} diff --git a/MaterialForm.resx b/MaterialForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/MaterialForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/MaterialType.cs b/MaterialType.cs index 58b6f7c..494f64e 100644 --- a/MaterialType.cs +++ b/MaterialType.cs @@ -8,7 +8,7 @@ namespace cdda_item_creator { - class BurnDataChunk + public class BurnDataChunk { public bool Immune { get; set; } // volume string, like "10 ml" @@ -17,7 +17,7 @@ class BurnDataChunk public float Smoke { get; set; } public float Burn { get; set; } } - class MaterialType + public class MaterialType { // mandatory public string Ident { get; set; } = ""; diff --git a/Program.cs b/Program.cs index ccc61aa..ffb89a4 100644 --- a/Program.cs +++ b/Program.cs @@ -24,6 +24,7 @@ public static class LoadedObjectDictionary static Dictionary> mtypes_by_id = new Dictionary> { }; static Dictionary> spells_by_id = new Dictionary> { }; static Dictionary> mattacks_by_id = new Dictionary> { }; + static Dictionary> materials_by_id = new Dictionary> { }; static public void Add(string type, string id) { @@ -38,6 +39,20 @@ static public void Add(string type, string id) ids_by_type.Add(type, temp_list); } } + static public void Add(string id, MaterialType material) + { + List temp_material; + if (materials_by_id.TryGetValue(id, out temp_material)) + { + temp_material.Add(material); + materials_by_id[id] = temp_material; + } + else + { + temp_material = new List { material }; + materials_by_id.Add(id, temp_material); + } + } static public void Add(string id, MonsterAttack mattack) { List temp_attack; @@ -100,6 +115,12 @@ static public List GetMAttacks(string id) mattacks_by_id.TryGetValue(id, out ret); return ret; } + static public List GetMaterials(string id) + { + List ret; + materials_by_id.TryGetValue(id, out ret); + return ret; + } } /// /// The main entry point for the application. diff --git a/cdda-item-creator.csproj b/cdda-item-creator.csproj index aa8636f..09be82e 100644 --- a/cdda-item-creator.csproj +++ b/cdda-item-creator.csproj @@ -50,6 +50,12 @@ + + Form + + + MaterialForm.cs + @@ -86,6 +92,9 @@ ViewerForm.cs + + MaterialForm.cs + MonsterAttackForm.cs diff --git a/custom_json.cs b/custom_json.cs index d43c2f5..96c296b 100644 --- a/custom_json.cs +++ b/custom_json.cs @@ -346,10 +346,14 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { JArray outer = JToken.Load(reader).ToObject(); - Dictionary ret = new Dictionary { }; - foreach (JArray array in outer) + Dictionary ret = null; + if (outer != null) { - ret.Add((string)array[0], array[1].ToObject()); + ret = new Dictionary { }; + foreach (JArray array in outer) + { + ret.Add((string)array[0], array[1].ToObject()); + } } return ret; } diff --git a/selector.Designer.cs b/selector.Designer.cs index cbded4a..d563d5e 100644 --- a/selector.Designer.cs +++ b/selector.Designer.cs @@ -35,6 +35,7 @@ private void InitializeComponent() this.loadGameDialog = new System.Windows.Forms.Button(); this.currentPathLabelLabel = new System.Windows.Forms.Label(); this.currentPathLabel = new System.Windows.Forms.Label(); + this.createMaterialButton = new System.Windows.Forms.Button(); this.SuspendLayout(); // // spellButton @@ -99,11 +100,22 @@ private void InitializeComponent() this.currentPathLabel.Size = new System.Drawing.Size(0, 13); this.currentPathLabel.TabIndex = 5; // + // createMaterialButton + // + this.createMaterialButton.Location = new System.Drawing.Point(93, 146); + this.createMaterialButton.Name = "createMaterialButton"; + this.createMaterialButton.Size = new System.Drawing.Size(75, 61); + this.createMaterialButton.TabIndex = 6; + this.createMaterialButton.Text = "Create Material"; + this.createMaterialButton.UseVisualStyleBackColor = true; + this.createMaterialButton.Click += new System.EventHandler(this.createMaterialButton_Click); + // // SelectorForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(256, 146); + this.ClientSize = new System.Drawing.Size(256, 214); + this.Controls.Add(this.createMaterialButton); this.Controls.Add(this.currentPathLabel); this.Controls.Add(this.currentPathLabelLabel); this.Controls.Add(this.loadGameDialog); @@ -126,5 +138,6 @@ private void InitializeComponent() private System.Windows.Forms.Button loadGameDialog; private System.Windows.Forms.Label currentPathLabelLabel; private System.Windows.Forms.Label currentPathLabel; + private System.Windows.Forms.Button createMaterialButton; } } \ No newline at end of file diff --git a/selector.cs b/selector.cs index 673ac8d..81cd77f 100644 --- a/selector.cs +++ b/selector.cs @@ -94,6 +94,9 @@ private void TryLoadObjectLists() default: break; } break; + case "material": + Program.LoadedObjectDictionary.Add(generic_object.Ident, (MaterialType)obj.ToObject(typeof(MaterialType), j_ser)); + break; default: break; } } @@ -116,25 +119,25 @@ public SelectorForm() private void spellButton_Click(object sender, EventArgs e) { spell_form form = new spell_form(); - this.Hide(); + Hide(); form.ShowDialog(); - this.Show(); + Show(); } private void createMonster_button_Click(object sender, EventArgs e) { MonsterForm form = new MonsterForm(); - this.Hide(); + Hide(); form.ShowDialog(); - this.Show(); + Show(); } private void viewLoadedItemsButton_Click(object sender, EventArgs e) { ViewerForm form = new ViewerForm(); - this.Hide(); + Hide(); form.ShowDialog(); - this.Show(); + Show(); } private void loadGameDialog_Click(object sender, EventArgs e) @@ -152,6 +155,14 @@ private void loadGameDialog_Click(object sender, EventArgs e) File.WriteAllText(Application.StartupPath + "\\cdda_data_path", cdda_path); } } + + private void createMaterialButton_Click(object sender, EventArgs e) + { + MaterialForm form = new MaterialForm(); + Hide(); + form.ShowDialog(); + Show(); + } } public class GenericTypedObject {