/[MorrowindCustomClothingSlotCreator]/trunk/MorrowindCustomClothingSlotCreator/Form1.cs
ViewVC logotype

Diff of /trunk/MorrowindCustomClothingSlotCreator/Form1.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 32 by william, Sat Jul 30 09:59:11 2011 UTC revision 35 by william, Sat Jul 30 12:34:22 2011 UTC
# Line 49  namespace MorrowindCustomClothingSlotCre Line 49  namespace MorrowindCustomClothingSlotCre
49          {          {
50              this.Close();              this.Close();
51          }          }
52            private void mnuItemSavePlugin_Click(object sender, EventArgs e)
53            {
54                if (!this.TES3PluginLoader.PluginLoaded) return;
55                if (!this.TES3PluginLoader.PluginSavingIsImplemented)
56                {
57                    MessageBox.Show("Plugin Saving has not been implemetned", "Unimplemented Function:", MessageBoxButtons.OK, MessageBoxIcon.Error);
58                    return;
59                }
60                if (!this.TES3PluginLoader.Save())
61                {
62                    MessageBox.Show("Failed to Save Plugin: " + this.TES3PluginLoader.PluginFile + "\n\nReason: \n\n" + this.TES3PluginLoader.PluginLoadFailureReason, "Failed to Save File:", MessageBoxButtons.OK, MessageBoxIcon.Error);
63                }
64                else
65                {
66                    MessageBox.Show("Successfully Saved Plugin: " + this.TES3PluginLoader.PluginFile, "Successfully Saved File:", MessageBoxButtons.OK, MessageBoxIcon.Information);
67                }
68            }
69            private void mnuItemSavePluginAs_Click(object sender, EventArgs e)
70            {
71                if (!this.TES3PluginLoader.PluginLoaded) return;
72    
73                if (!this.TES3PluginLoader.PluginSavingIsImplemented)
74                {
75                    MessageBox.Show("Plugin Saving has not been implemetned", "Unimplemented Function:", MessageBoxButtons.OK, MessageBoxIcon.Error);
76                    return;
77                }
78    
79                DialogResult result = PluginSaver.ShowDialog();
80                string PluginFile = PluginSaver.FileName;
81                if (result != DialogResult.OK) return;
82    
83                if (!this.TES3PluginLoader.SaveAs(PluginFile))
84                {
85                    MessageBox.Show("Failed to Save Plugin As: " + PluginFile + "\n\nReason: \n\n" + this.TES3PluginLoader.PluginLoadFailureReason, "Failed to Save File As:", MessageBoxButtons.OK, MessageBoxIcon.Error);
86                }
87                else
88                {
89                    MessageBox.Show("Successfully Saved Plugin: " + PluginFile, "Successfully Saved File:", MessageBoxButtons.OK, MessageBoxIcon.Information);
90                }
91            }
92          private void mnuItemOpenPlugin_Click(object sender, EventArgs e)          private void mnuItemOpenPlugin_Click(object sender, EventArgs e)
93          {          {
94              this.log.Clear();              this.log.Clear();
# Line 69  namespace MorrowindCustomClothingSlotCre Line 108  namespace MorrowindCustomClothingSlotCre
108          {          {
109              ClothingEntry chosen_entry = null;              ClothingEntry chosen_entry = null;
110              editor_flow.Enabled = false;              editor_flow.Enabled = false;
111                btnCommitEntry.Tag = null;
112              foreach (KeyValuePair<string, ClothingEntry> entry in this.TES3PluginLoader.ClothingSection.ClothingEntries)              foreach (KeyValuePair<string, ClothingEntry> entry in this.TES3PluginLoader.ClothingSection.ClothingEntries)
113              {              {
114                  string key = lstClothingEntries.Items[lstClothingEntries.SelectedIndex].ToString();                  string key = lstClothingEntries.Items[lstClothingEntries.SelectedIndex].ToString();
# Line 82  namespace MorrowindCustomClothingSlotCre Line 122  namespace MorrowindCustomClothingSlotCre
122          {          {
123              if (entry == null) return;              if (entry == null) return;
124              editor_flow.Enabled = true;              editor_flow.Enabled = true;
125    
126                btnCommitEntry.Tag = entry;
127    
128              txtClothingName.Text = entry.CLOT_NAME;              txtClothingName.Text = entry.CLOT_NAME;
129    
130              int actual_type = entry.CLOT_CTDT_TYPE;              int actual_type = entry.CLOT_CTDT_TYPE;
131              //int actual_type = 0x01020309;              //int actual_type = 0x01020309;
132    
133              int type = (actual_type & 0x000000FF) >> 0;              byte type = (byte)( (actual_type & 0x000000FF) >> 0);
134              int unknown2 = (actual_type & 0x0000FF00) >> 8;              byte unknown2 = (byte)((actual_type & 0x0000FF00) >> 8);
135              int unknown1 = (actual_type & 0x00FF0000) >> 16;              byte unknown1 = (byte)((actual_type & 0x00FF0000) >> 16);
136              int index = (int)(actual_type & 0xFF000000) >> 24;              byte index = (byte)((uint)(actual_type & 0xFF000000) >> 24);
137    
138              // Set the clothing type in the drop down              // Set the clothing type in the drop down
139              foreach (string item in comboClothingType.Items)              foreach (string item in comboClothingType.Items)
# Line 123  namespace MorrowindCustomClothingSlotCre Line 166  namespace MorrowindCustomClothingSlotCre
166          }          }
167    
168          private void Form1_Shown(object sender, EventArgs e) { editor_flow.Enabled = false; }          private void Form1_Shown(object sender, EventArgs e) { editor_flow.Enabled = false; }
169    
170            private void btnCommitEntry_Click(object sender, EventArgs e)
171            {
172                ClothingEntry entry = (btnCommitEntry.Tag as ClothingEntry);
173                if (entry == null) return;
174    
175                byte type = 0;
176                byte index = 0;
177    
178                if (comboClothingType.Items[comboClothingType.SelectedIndex].ToString() == "Unknown")
179                {
180                    type = (byte)((entry.CLOT_CTDT_TYPE & 0x000000FF) >> 0);
181                }
182                else
183                {
184                    string type_name = comboClothingType.Items[comboClothingType.SelectedIndex].ToString();
185                    byte type_value = (byte)((entry.CLOT_CTDT_TYPE & 0x000000FF) >> 0);
186                    foreach (int val in Enum.GetValues(typeof(ClothingTypes)))
187                    {
188                        if (Enum.GetName(typeof(ClothingTypes), val) == type_name) { type_value = (byte)val; break; }
189                    }
190                    type = Convert.ToByte(type_value);
191                }
192    
193    
194                if (comboCustomClothingSlotIndex.Items[comboCustomClothingSlotIndex.SelectedIndex].ToString() == "Default") { index = 0; }
195                else { index = Convert.ToByte(comboCustomClothingSlotIndex.Items[comboCustomClothingSlotIndex.SelectedIndex].ToString(),16); }
196                
197    
198    
199                int SlotIndex = (index << 24) | type;
200                if (CommitClothingEntry(entry, SlotIndex))
201                {
202                    MessageBox.Show("Successfully Commited: " + entry.CLOT_NAME, "Clothing Entry Commit:", MessageBoxButtons.OK, MessageBoxIcon.Information);
203                }
204                else
205                {
206                    MessageBox.Show("Failed to Commit: " + entry.CLOT_NAME, "Clothing Entry Commit:", MessageBoxButtons.OK, MessageBoxIcon.Error);
207                }
208            }
209    
210            private bool CommitClothingEntry(ClothingEntry entry, int SlotIndex)
211            {
212                bool ret = false;
213                entry.CLOT_CTDT_TYPE = SlotIndex;
214                ret = entry.Commit(this.TES3PluginLoader);
215                return ret;
216            }  
217      }      }
218  }  }

Legend:
Removed from v.32  
changed lines
  Added in v.35

  ViewVC Help
Powered by ViewVC 1.1.22