From 37c864a8650b05668852b6e7d17e81c522916616 Mon Sep 17 00:00:00 2001 From: Alex193a Date: Thu, 28 Jan 2016 17:51:50 +0100 Subject: [PATCH] Enabled Vendor Editor --- SOSSE/ItemEditingForm.cs | 46 ++++++++++++++++++-------------- SOSSE/MainForm.cs | 16 ++++++++++- SOSSE/Properties/AssemblyInfo.cs | 2 +- SOSSE/SOSSE.csproj | 4 +-- SOSSE/VendorEditingForm.cs | 4 +-- 5 files changed, 46 insertions(+), 26 deletions(-) diff --git a/SOSSE/ItemEditingForm.cs b/SOSSE/ItemEditingForm.cs index dfd7bf5..0b05e13 100644 --- a/SOSSE/ItemEditingForm.cs +++ b/SOSSE/ItemEditingForm.cs @@ -296,7 +296,7 @@ private void LoadItemData() storageItems = displayItem(storageDataGridView, storageItemOffset, maxContainerItem); materialItems = displayItem(materialDataGridView, materialItemOffset, maxContainerItem); wardrobeItems = displayItem(wardrobeDataGridView, wardrobeItemOffset, maxContainerItem); - + DataLoaded = true; } @@ -313,7 +313,7 @@ private Item[] displayItem(DataGridView dataGridView, int offset, int count) localOffset += 12; } Array.Sort(items, (x, y) => x.CompareTo(y)); - + dataGridView.Rows.Add(count); for (int i = 0; i < count; i++) { @@ -339,20 +339,20 @@ private Item[] displayItem(DataGridView dataGridView, int offset, int count) { dataGridView.Rows[i].Cells[1].Value = StarQualityList[12]; dataGridView.Rows[i].Cells[1].ReadOnly = true; - dataGridView.Rows[i].Cells[1].Style = MainForm.GrayCellStyle; + dataGridView.Rows[i].Cells[1].Style.BackColor = Color.LightGray; dataGridView.Rows[i].Cells[2].ReadOnly = true; - dataGridView.Rows[i].Cells[2].Style = MainForm.GrayCellStyle; + dataGridView.Rows[i].Cells[2].Style.BackColor = Color.LightGray; } dataGridView.Rows[i].Cells[2].Value = items[i].Quality; dataGridView.Rows[i].Cells[3].Value = items[i].Quantity; if (items[i].Index == 0xFFFF || Item.BaseQuality[items[i].Index] == -1) { dataGridView.Rows[i].Cells[1].ReadOnly = true; - dataGridView.Rows[i].Cells[1].Style = MainForm.GrayCellStyle; + dataGridView.Rows[i].Cells[1].Style.BackColor = Color.LightGray; dataGridView.Rows[i].Cells[2].ReadOnly = true; - dataGridView.Rows[i].Cells[2].Style = MainForm.GrayCellStyle; + dataGridView.Rows[i].Cells[2].Style.BackColor = Color.LightGray; dataGridView.Rows[i].Cells[3].ReadOnly = true; - dataGridView.Rows[i].Cells[3].Style = MainForm.GrayCellStyle; + dataGridView.Rows[i].Cells[3].Style.BackColor = Color.LightGray; } } return items; @@ -362,7 +362,7 @@ private Item[] displayItem(DataGridView dataGridView, int offset, int count) private void dataGridView_CellClick(DataGridView dataGridView, DataGridViewCellEventArgs e) { if ((e.ColumnIndex != 0) && (e.ColumnIndex != 1)) return; - ComboBox cb = (ComboBox)dataGridView.EditingControl; + ComboBox cb = (ComboBox) dataGridView.EditingControl; if (cb != null) cb.DroppedDown = true; } @@ -471,39 +471,42 @@ private int dataGridView_CellValueChanged(DataGridView dataGridView, DataGridVie dataGridView.Rows[e.RowIndex].Cells[1].Value = StarQualityList[0]; dataGridView.Rows[e.RowIndex].Cells[1].ReadOnly = true; - dataGridView.Rows[e.RowIndex].Cells[1].Style = MainForm.GrayCellStyle; + dataGridView.Rows[e.RowIndex].Cells[1].Style.BackColor = + Color.LightGray; dataGridView.Rows[e.RowIndex].Cells[2].Value = -1; dataGridView.Rows[e.RowIndex].Cells[2].ReadOnly = true; - dataGridView.Rows[e.RowIndex].Cells[2].Style = MainForm.GrayCellStyle; + dataGridView.Rows[e.RowIndex].Cells[2].Style.BackColor = + Color.LightGray; if (itemIndex == -1) dataGridView.Rows[e.RowIndex].Cells[3].Value = 0; else dataGridView.Rows[e.RowIndex].Cells[3].Value = 1; dataGridView.Rows[e.RowIndex].Cells[3].ReadOnly = true; - dataGridView.Rows[e.RowIndex].Cells[3].Style = MainForm.GrayCellStyle; + dataGridView.Rows[e.RowIndex].Cells[3].Style.BackColor = + Color.LightGray; } else { dataGridView.Rows[e.RowIndex].Cells[1].Value = StarQualityList[(Item.BaseQuality[itemIndex] - 1) / 30 + 1]; dataGridView.Rows[e.RowIndex].Cells[1].ReadOnly = false; - dataGridView.Rows[e.RowIndex].Cells[1].Style = - dataGridView.DefaultCellStyle; + dataGridView.Rows[e.RowIndex].Cells[1].Style.BackColor = + dataGridView.DefaultCellStyle.BackColor; dataGridView.Rows[e.RowIndex].Cells[2].Value = Item.BaseQuality[itemIndex]; dataGridView.Rows[e.RowIndex].Cells[2].ReadOnly = false; - dataGridView.Rows[e.RowIndex].Cells[2].Style = - dataGridView.DefaultCellStyle; + dataGridView.Rows[e.RowIndex].Cells[2].Style.BackColor = + dataGridView.DefaultCellStyle.BackColor; dataGridView.Rows[e.RowIndex].Cells[3].Value = 1; dataGridView.Rows[e.RowIndex].Cells[3].ReadOnly = false; - dataGridView.Rows[e.RowIndex].Cells[3].Style = - dataGridView.DefaultCellStyle; + dataGridView.Rows[e.RowIndex].Cells[3].Style.BackColor = + dataGridView.DefaultCellStyle.BackColor; } return itemIndex; } return -2; } - + private void bagDataGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (!DataLoaded) return; @@ -744,7 +747,10 @@ private void saveItems(DataGridView dataGridView, int offset, int count, Item[] Array.Copy(itemBytes, 0, MainForm.SaveData, offset, 12 * count); } - private void saveAllItems() + /// + /// Save item changes to save data + /// + public void SaveItems() { if (IsModified) { @@ -860,7 +866,7 @@ private void maxQualityButton_Click(object sender, EventArgs e) private void ItemEditingForm_FormClosing(object sender, FormClosingEventArgs e) { - saveAllItems(); + this.Hide(); e.Cancel = true; } } diff --git a/SOSSE/MainForm.cs b/SOSSE/MainForm.cs index 2eab39b..a0586b4 100644 --- a/SOSSE/MainForm.cs +++ b/SOSSE/MainForm.cs @@ -50,7 +50,7 @@ private void enableButtons() animalButton.Enabled = false; patternButton.Enabled = false; recipeButton.Enabled = false; - vendorButton.Enabled = false; + vendorButton.Enabled = true; npcButton.Enabled = false; generalButton.Enabled = true; eventButton.Enabled = false; @@ -112,6 +112,20 @@ private void openButton_Click(object sender, EventArgs e) MessageBox.Show("Invalid save file", "Error"); return; } + + //only for testing + /* + using (FileStream fs = new FileStream("dec3.bin", FileMode.Create, FileAccess.Write)) + { + using (BinaryWriter bw = new BinaryWriter(fs)) + { + + bw.Write(decompressed); + } + } + */ + + } } diff --git a/SOSSE/Properties/AssemblyInfo.cs b/SOSSE/Properties/AssemblyInfo.cs index 95c3a59..b71bcb8 100644 --- a/SOSSE/Properties/AssemblyInfo.cs +++ b/SOSSE/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.7.4")] +[assembly: AssemblyVersion("1.7.6")] [assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SOSSE/SOSSE.csproj b/SOSSE/SOSSE.csproj index 0be5677..145ff81 100644 --- a/SOSSE/SOSSE.csproj +++ b/SOSSE/SOSSE.csproj @@ -23,7 +23,7 @@ false true 0 - 1.0.0.%2a + 1.7.6.%2a false true @@ -234,7 +234,7 @@ False - Microsoft .NET Framework 4 %28x86 and x64%29 + Microsoft .NET Framework 4 %28x86 e x64%29 true diff --git a/SOSSE/VendorEditingForm.cs b/SOSSE/VendorEditingForm.cs index a30ff93..5654c36 100644 --- a/SOSSE/VendorEditingForm.cs +++ b/SOSSE/VendorEditingForm.cs @@ -11,8 +11,8 @@ namespace SOSSE { public partial class VendorEditingForm : Form { - private int vendorOffset = 0x448E8; - private int[] vendorFlagOffset = { 0x1294, 0x1660, 0x16C4 }; + private int vendorOffset = 0x44E28; + private int[] vendorFlagOffset = { 0x12EC, 0x16B8, 0x171C }; private int currentCountry; private ulong currentMoney; private uint currentItemQuantity;