Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added additional UI functionality #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Project/Icons/Thumbs.db
Binary file not shown.
Binary file added Project/Thumbs.db
Binary file not shown.
9 changes: 9 additions & 0 deletions Source/CharacterEditor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<Compile Include="Utility.cs" />
<EmbeddedResource Include="Forms\Editor.resx">
<DependentUpon>Editor.cs</DependentUpon>
Expand All @@ -141,6 +146,10 @@
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<Content Include="icon.ico" />
Expand Down
10 changes: 6 additions & 4 deletions Source/Forms/Editor.Data.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
using System;
using System.Linq;
using System.Windows.Forms;
using CharacterEditor.Character;

Expand Down Expand Up @@ -75,12 +76,14 @@ private void SyncCharacterDataToGui()
};

// Ok .NET 2.0, have it your way
listView.SelectedIndexChanged += ListViewInventorySelectedIndexChanged;
//DM_EDIT: No. you dont make lemonade, YOU MAKE .NET 2.0 TAKE THE LEMONS BACK!
listView.SelectedIndexChanged += new EventHandler(ListViewInventorySelectedIndexChanged);
listView.MouseUp += new MouseEventHandler(ItemClicked);

foreach (Slot slot in inventory.Items)
{
ListViewItem listViewItem;

if (slot.Count > 0 && slot.Item.Type != 0x00)
{
listViewItem = new ListViewItem
Expand All @@ -99,7 +102,6 @@ private void SyncCharacterDataToGui()
Tag = slot.Item
};
}

listView.Items.Add(listViewItem);
}

Expand Down
3,161 changes: 1,666 additions & 1,495 deletions Source/Forms/Editor.Designer.cs

Large diffs are not rendered by default.

105 changes: 102 additions & 3 deletions Source/Forms/Editor.Inventory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace CharacterEditor.Forms
{
public partial class Editor
{

private Item SelectedItem
{
get
Expand All @@ -28,12 +29,16 @@ private Slot SelectedSlot
}
}

// ListView Select
/// <summary>
/// Called when the selected index of the invintory is changed.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ListViewInventorySelectedIndexChanged(object sender, EventArgs e)
{
if (SelectedItem == null)
return;

// Ignore dirtiness
lock (dirtyWatcher)
dirtyWatcher.IgnoreDirtiness = true;
Expand All @@ -51,11 +56,13 @@ private void ListViewInventorySelectedIndexChanged(object sender, EventArgs e)
// comboBoxItemPrefixId.SelectedIndex = (SelectedItem.Modifier - 1) % 10 + 1;
//else
// comboBoxItemPrefixId.SelectedIndex = 0;

nudItemLevel.Value = SelectedItem.Level;
comboBoxItemRarity.SelectedIndex = SelectedItem.Rarity;
checkBoxItemAdapted.Checked = SelectedItem.Flags.HasFlag(Item.ItemFlags.Adapted);
nudItemCount.Value = SelectedSlot.Count;


}
else
{
Expand Down Expand Up @@ -190,6 +197,98 @@ private void NudItemCountValueChanged(object sender, EventArgs e)
SelectedSlot.Count = (int)nudItemCount.Value;
}

/// <summary>
/// Called when an item is clicked
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ItemClicked(object sender, MouseEventArgs e)
{
var loc = ((ListView)sender).HitTest(e.Location);
if (e.Button == MouseButtons.Right)
{
if (loc.Item != null) contextMenuStrip1.Show(((ListView)sender), e.Location);
}
}

private void toolStripCut_Click(object sender, EventArgs e)
{
toolStripCopy_Click(sender, e);
toolStripDelete_Click(sender, e);
}
private void toolStripCopy_Click(object sender, EventArgs e)
{
myclipboard[0] = SelectedItem.Type;
myclipboard[1] = SelectedItem.Subtype;
myclipboard[2] = SelectedItem.Material;
myclipboard[3] = (byte)SelectedItem.Level;
myclipboard[4] = SelectedItem.Rarity;
if (SelectedItem.Flags.HasFlag(Item.ItemFlags.Adapted))
{
myclipboard[5] = 0x01;
}
else
{
myclipboard[5] = 0x02;
}
myclipboard[6] = (byte)SelectedSlot.Count;
toolStripPaste.Enabled = true;
}
private void toolStripPaste_Click(object sender, EventArgs e)
{
lock (dirtyWatcher)//tell the watchdog to turn around
dirtyWatcher.IgnoreDirtiness = true;

//load from clipboard
SelectedItem.Type = myclipboard[0];
SelectedItem.Subtype = myclipboard[1];
SelectedItem.Material = myclipboard[2];
SelectedItem.Level = myclipboard[3];
SelectedItem.Rarity = myclipboard[4];
if (SelectedItem.Flags.HasFlag(Item.ItemFlags.Adapted))
{
myclipboard[5] = 0x01;
}
else
{
myclipboard[5] = 0x02;
}
SelectedSlot.Count = myclipboard[6];
ListViewInventorySelectedIndexChanged(sender, e);

lock (dirtyWatcher)
dirtyWatcher.IgnoreDirtiness = false;
}
private void toolStripDelete_Click(object sender, EventArgs e)
{
//TODO: fix me, i give errors. =/
//lock (dirtyWatcher)//tell the watchdog to turn around
// dirtyWatcher.IgnoreDirtiness = true;

////Set everyhting to be empty,
//comboBoxItemType.SelectedIndex = -1;
//comboBoxItemSubtype.SelectedIndex = -1;
//comboBoxItemMaterial.SelectedIndex = -1;
//comboBoxItemPrefixId.SelectedIndex = -1;
//nudItemLevel.Value = 0;
//comboBoxItemRarity.SelectedIndex = -1;
//checkBoxItemAdapted.Checked = false;
//nudItemCount.Value = 0;

////hopefully call the events that write these values.
//ComboBoxItemTypeSelectedIndexChanged(sender, e);
//ComboBoxItemSubtypeSelectedIndexChanged(sender, e);
//ComboBoxItemMaterialSelectedIndexChanged(sender, e);
//ComboBoxItemModifierSelectedIndexChanged(sender, e);
//NudItemLevelValueChanged(sender, e);
//ComboBoxItemRaritySelectedIndexChanged(sender, e);
//CheckBoxItemAdaptedCheckedChanged(sender, e);
//NudItemCountValueChanged(sender, e);

//lock (dirtyWatcher)
// dirtyWatcher.IgnoreDirtiness = false;

}
private void UpdateItemAvatar()
{
if (SelectedSlot.Count == 0)
Expand Down
7 changes: 6 additions & 1 deletion Source/Forms/Editor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public partial class Editor : Form
private DirtyWatcher dirtyWatcher;
private Thread dirtyThread;
private readonly FormItemStats itemStats;

private byte[] myclipboard;
public Editor()
{
database = new Database();
Expand All @@ -27,6 +27,11 @@ public Editor()
comboBoxPetKind.Items.Add("None");
string[] pets = Constants.ItemSubtypes[(int)Constants.ItemType.Pets];
comboBoxPetKind.Items.AddRange(pets.Where(x => !String.IsNullOrEmpty(x)).ToArray());
myclipboard = new byte[7];
toolStripCut.Click += new EventHandler(toolStripCut_Click);
toolStripCopy.Click += new EventHandler(toolStripCopy_Click);
toolStripPaste.Click += new EventHandler(toolStripPaste_Click);
toolStripDelete.Click += new EventHandler(toolStripDelete_Click);
}

private void FormEditorShown(object sender, EventArgs e)
Expand Down
Loading