diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..1ff0c42
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,63 @@
+###############################################################################
+# Set default behavior to automatically normalize line endings.
+###############################################################################
+* text=auto
+
+###############################################################################
+# Set default behavior for command prompt diff.
+#
+# This is need for earlier builds of msysgit that does not have it on by
+# default for csharp files.
+# Note: This is only used by command line
+###############################################################################
+#*.cs diff=csharp
+
+###############################################################################
+# Set the merge driver for project and solution files
+#
+# Merging from the command prompt will add diff markers to the files if there
+# are conflicts (Merging from VS is not affected by the settings below, in VS
+# the diff markers are never inserted). Diff markers may cause the following
+# file extensions to fail to load in VS. An alternative would be to treat
+# these files as binary and thus will always conflict and require user
+# intervention with every merge. To do so, just uncomment the entries below
+###############################################################################
+#*.sln merge=binary
+#*.csproj merge=binary
+#*.vbproj merge=binary
+#*.vcxproj merge=binary
+#*.vcproj merge=binary
+#*.dbproj merge=binary
+#*.fsproj merge=binary
+#*.lsproj merge=binary
+#*.wixproj merge=binary
+#*.modelproj merge=binary
+#*.sqlproj merge=binary
+#*.wwaproj merge=binary
+
+###############################################################################
+# behavior for image files
+#
+# image files are treated as binary by default.
+###############################################################################
+#*.jpg binary
+#*.png binary
+#*.gif binary
+
+###############################################################################
+# diff behavior for common document formats
+#
+# Convert binary document formats to text before diffing them. This feature
+# is only available from the command line. Turn it on by uncommenting the
+# entries below.
+###############################################################################
+#*.doc diff=astextplain
+#*.DOC diff=astextplain
+#*.docx diff=astextplain
+#*.DOCX diff=astextplain
+#*.dot diff=astextplain
+#*.DOT diff=astextplain
+#*.pdf diff=astextplain
+#*.PDF diff=astextplain
+#*.rtf diff=astextplain
+#*.RTF diff=astextplain
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3c4efe2
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,261 @@
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+
+# User-specific files
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+
+# Visual Studio 2015 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUNIT
+*.VisualState.xml
+TestResult.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# DNX
+project.lock.json
+project.fragment.lock.json
+artifacts/
+
+*_i.c
+*_p.c
+*_i.h
+*.ilk
+*.meta
+*.obj
+*.pch
+*.pdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*.log
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# JustCode is a .NET coding add-in
+.JustCode
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# TODO: Comment the next line if you want to checkin your web deploy settings
+# but database connection strings (with potential passwords) will be unencrypted
+#*.pubxml
+*.publishproj
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# The packages folder can be ignored because of Package Restore
+**/packages/*
+# except build/, which is used as an MSBuild target.
+!**/packages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/packages/repositories.config
+# NuGet v3's project.json files produces more ignoreable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+node_modules/
+orleans.codegen.cs
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+
+# SQL Server files
+*.mdf
+*.ldf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# JetBrains Rider
+.idea/
+*.sln.iml
+
+# CodeRush
+.cr/
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
\ No newline at end of file
diff --git a/DayZLootEdit.sln b/DayZLootEdit.sln
new file mode 100644
index 0000000..fe90876
--- /dev/null
+++ b/DayZLootEdit.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.31105.61
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DayZLootEdit", "DayZLootEdit\DayZLootEdit.csproj", "{9747E2CC-3468-4864-A359-A2F0F1874450}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {9747E2CC-3468-4864-A359-A2F0F1874450}.Debug|Any CPU.ActiveCfg = Release|Any CPU
+ {9747E2CC-3468-4864-A359-A2F0F1874450}.Debug|Any CPU.Build.0 = Release|Any CPU
+ {9747E2CC-3468-4864-A359-A2F0F1874450}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {9747E2CC-3468-4864-A359-A2F0F1874450}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {54C5E96A-06ED-4354-870B-F873442C8DAE}
+ EndGlobalSection
+EndGlobal
diff --git a/DayZLootEdit/App.config b/DayZLootEdit/App.config
new file mode 100644
index 0000000..bae5d6d
--- /dev/null
+++ b/DayZLootEdit/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/DayZLootEdit/App.xaml b/DayZLootEdit/App.xaml
new file mode 100644
index 0000000..5c0bc8b
--- /dev/null
+++ b/DayZLootEdit/App.xaml
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/DayZLootEdit/App.xaml.cs b/DayZLootEdit/App.xaml.cs
new file mode 100644
index 0000000..25de200
--- /dev/null
+++ b/DayZLootEdit/App.xaml.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace DayZLootEdit
+{
+ ///
+ /// Interaktionslogik für "App.xaml"
+ ///
+ public partial class App : Application
+ {
+ }
+}
diff --git a/DayZLootEdit/DayZLootEdit.csproj b/DayZLootEdit/DayZLootEdit.csproj
new file mode 100644
index 0000000..9b0a79a
--- /dev/null
+++ b/DayZLootEdit/DayZLootEdit.csproj
@@ -0,0 +1,160 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {9747E2CC-3468-4864-A359-A2F0F1874450}
+ WinExe
+ DayZLootEdit
+ DayZLootEdit
+ v4.6.1
+ 512
+ {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ 4
+ true
+
+ false
+ publish\
+ true
+ Disk
+ false
+ Foreground
+ 7
+ Days
+ false
+ false
+ true
+ 1
+ 0.2.1.%2a
+ false
+ true
+ true
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+ false
+
+
+ 229AEDC982ACA4F6C5DEAF6B83D2A10EEBE66534
+
+
+ DayZLootEdit_TemporaryKey.pfx
+
+
+ true
+
+
+ true
+
+
+ dayz_types.ico
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 4.0
+
+
+
+
+
+
+
+ MSBuild:Compile
+ Designer
+
+
+
+ InfoWindow.xaml
+
+
+ MSBuild:Compile
+ Designer
+
+
+ App.xaml
+ Code
+
+
+
+ MainWindow.xaml
+ Code
+
+
+ Designer
+ MSBuild:Compile
+
+
+
+
+ Code
+
+
+ True
+ True
+ Resources.resx
+
+
+ True
+ Settings.settings
+ True
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+
+
+
+
+
+ False
+ Microsoft .NET Framework 4.6.1 %28x86 und x64%29
+ true
+
+
+ False
+ .NET Framework 3.5 SP1
+ false
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/DayZLootEdit/InfoWindow.xaml b/DayZLootEdit/InfoWindow.xaml
new file mode 100644
index 0000000..97bba59
--- /dev/null
+++ b/DayZLootEdit/InfoWindow.xaml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/DayZLootEdit/InfoWindow.xaml.cs b/DayZLootEdit/InfoWindow.xaml.cs
new file mode 100644
index 0000000..818ce53
--- /dev/null
+++ b/DayZLootEdit/InfoWindow.xaml.cs
@@ -0,0 +1,51 @@
+using System.Diagnostics;
+using System.Reflection;
+using System.Text;
+using System.Windows;
+
+namespace DayZLootEdit
+{
+ ///
+ /// Interaktionslogik für Window1.xaml
+ ///
+ public partial class InfoWindow : Window
+ {
+ public InfoWindow()
+ {
+
+ InitializeComponent();
+
+ string version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
+ string versionText = "Version %1";
+ StringBuilder builder = new StringBuilder(versionText);
+ builder.Replace("%1", version);
+ versionText = builder.ToString();
+ lblVersion.Content = versionText.ToString();
+
+ string copyright = string.Empty;
+ Assembly assembly = typeof(InfoWindow).Assembly;
+ if (assembly != null)
+ {
+ object[] attributes = assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), true);
+ if ((attributes != null) && (attributes.Length > 0))
+ {
+ copyright = ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
+ }
+ if (string.IsNullOrEmpty(copyright))
+ {
+ copyright = "(C) ME";
+ }
+ lblCopyright.Content = copyright.ToString();
+ }
+
+ string credits = "This application is a further development\nof 'DayZ LootEdit' by MrX13415.\n\nIf you have any suggestions for\nimprovement, please contact me\non GitHub.";
+ rtbCredits.AppendText(credits);
+
+ }
+
+ private void CloseBtn_Click(object sender, RoutedEventArgs e)
+ {
+ this.Close();
+ }
+ }
+}
diff --git a/DayZLootEdit/LootTable.cs b/DayZLootEdit/LootTable.cs
new file mode 100644
index 0000000..ea94791
--- /dev/null
+++ b/DayZLootEdit/LootTable.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.ObjectModel;
+using System.IO;
+using System.Xml.Linq;
+
+namespace DayZLootEdit
+{
+ class LootTable
+ {
+ public string FilePath { get; private set; }
+ public XElement XML { get; private set; }
+
+ public ObservableCollection Loot { get; set; } = new ObservableCollection();
+
+ public LootTable(string lFile)
+ {
+ FilePath = lFile;
+ }
+
+ public void LoadFile(string lFile = "")
+ {
+ if (lFile != "") { FilePath = lFile; }
+ XML = XElement.Load(FilePath);
+ process();
+ }
+
+ public void SaveFile(string lFile = "")
+ {
+ if (lFile != "") { FilePath = lFile; }
+ FileInfo file = new FileInfo(FilePath);
+ if (file.Exists)
+ {
+ DateTime now = DateTime.Now;
+ FileInfo backup = new FileInfo(file.FullName + ".backup-" + now.ToString("yyyyMMdd-HHmmss") + ".xml");
+ if (!backup.Exists)
+ {
+ file.CopyTo(backup.FullName);
+ }
+ }
+ XML.Save(FilePath);
+ }
+
+ private void process()
+ {
+ Loot.Clear();
+ foreach(XElement node in XML.Elements())
+ {
+ Loot.Add(new LootType(node));
+ }
+ }
+
+ }
+}
diff --git a/DayZLootEdit/LootType.cs b/DayZLootEdit/LootType.cs
new file mode 100644
index 0000000..cd6f22c
--- /dev/null
+++ b/DayZLootEdit/LootType.cs
@@ -0,0 +1,192 @@
+using System;
+using System.Linq;
+using System.Xml.Linq;
+
+namespace DayZLootEdit
+{
+ public class LootType
+ {
+ private XElement xtype;
+
+ public LootType(XElement xnode)
+ {
+ this.xtype = xnode;
+ }
+
+ public string Name
+ {
+ get { return xtype.Attribute("name")?.Value; }
+ set { xtype.Attribute("name").Value = value; }
+ }
+
+ public int Nominal
+ {
+ get { return GetValueInt(xtype, "nominal"); }
+ set { xtype.Element("nominal")?.SetValue(value.ToString()); }
+ }
+ public int Min
+ {
+ get { return GetValueInt(xtype, "min"); }
+ set { xtype.Element("min")?.SetValue(value.ToString()); }
+ }
+ public int Lifetime
+ {
+ get { return Lifetime = GetValueInt(xtype, "lifetime"); }
+ set { xtype.Element("lifetime")?.SetValue(value.ToString()); }
+ }
+ public int Restock
+ {
+ get { return GetValueInt(xtype, "restock"); }
+ set { xtype.Element("restock")?.SetValue(value.ToString()); }
+ }
+ public int QMin
+ {
+ get { return GetValueInt(xtype, "quantmin"); }
+ set { xtype.Element("quantmin")?.SetValue(value.ToString()); }
+ }
+ public int QMax
+ {
+ get { return GetValueInt(xtype, "quantmax"); }
+ set { xtype.Element("quantmax")?.SetValue(value.ToString()); }
+ }
+ public int Cost
+ {
+ get { return GetValueInt(xtype, "cost"); }
+ set { xtype.Element("cost")?.SetValue(value.ToString()); }
+ }
+
+ public bool InCargo
+ {
+ get { return GetFlag(xtype, "count_in_cargo"); }
+ set { xtype.Element("flags")?.Attribute("count_in_cargo")?.SetValue(value.ToString()); }
+ }
+ public bool InHoarder
+ {
+ get { return GetFlag(xtype, "count_in_hoarder"); }
+ set { xtype.Element("flags")?.Attribute("count_in_hoarder")?.SetValue(value.ToString()); }
+ }
+ public bool InMap
+ {
+ get { return GetFlag(xtype, "count_in_map"); }
+ set { xtype.Element("flags")?.Attribute("count_in_map")?.SetValue(value.ToString()); }
+ }
+ public bool InPlayer
+ {
+ get { return GetFlag(xtype, "count_in_player"); }
+ set { xtype.Element("flags")?.Attribute("count_in_player")?.SetValue(value.ToString()); }
+ }
+ public bool Crafted
+ {
+ get { return GetFlag(xtype, "crafted"); }
+ set { xtype.Element("flags")?.Attribute("crafted")?.SetValue(value.ToString()); }
+ }
+ public bool Deloot
+ {
+ get { return GetFlag(xtype, "deloot"); }
+ set { xtype.Element("flags")?.Attribute("deloot")?.SetValue(value.ToString()); }
+ }
+
+ public string Category
+ {
+ get { return xtype.Element("category")?.Attribute("name").Value; }
+ set { xtype.Element("category")?.Attribute("name")?.SetValue(value); }
+ }
+
+ public string Tag
+ {
+ get
+ {
+ return string.Join(", ",
+ xtype.Elements().Where(
+ node => node.Name.LocalName.Equals("tag")
+ ).Select(
+ node => node.Attribute("name")?.Value
+ ));
+ }
+ set
+ {
+ xtype.Elements().Where(node => node.Name.LocalName.Equals("tag")).Remove();
+
+ foreach (string s in value.Split(',').Select(s => s.Trim()))
+ {
+ xtype.Add(new XElement("tag", new XAttribute("name", s)));
+ }
+ }
+ }
+
+ public string Usage
+ {
+ get
+ {
+ return string.Join(", ",
+ xtype.Elements().Where(
+ node => node.Name.LocalName.Equals("usage")
+ ).Select(
+ node => node.Attribute("name")?.Value
+ ));
+ }
+ set
+ {
+ xtype.Elements().Where(node => node.Name.LocalName.Equals("usage")).Remove();
+
+ foreach (string s in value.Split(',').Select(s => s.Trim()))
+ {
+ xtype.Add(new XElement("usage", new XAttribute("name", s)));
+ }
+ }
+ }
+
+ public string Value
+ {
+ get
+ {
+ return string.Join(", ",
+ xtype.Elements().Where(
+ node => node.Name.LocalName.Equals("value")
+ ).Select(
+ node => node.Attribute("name")?.Value
+ ));
+ }
+ set
+ {
+ xtype.Elements().Where(node => node.Name.LocalName.Equals("value")).Remove();
+
+ foreach (string s in value.Split(',').Select(s => s.Trim()))
+ {
+ xtype.Add(new XElement("value", new XAttribute("name", s)));
+ }
+ }
+ }
+
+ private int GetValueInt(XElement node, string name)
+ {
+ int val = 0;
+ int.TryParse(node.Element(name)?.Value, out val);
+ return val;
+ }
+
+ private bool GetFlag(XElement node, string attrib)
+ {
+ return (bool)node.Element("flags")?.Attribute(attrib)?.Value.Equals("1");
+ }
+
+ public void SetNominal(int percentage)
+ {
+ int value = (int)Math.Round(Nominal / 100.0 * percentage);
+ if (value > 0)
+ {
+ Nominal = value;
+ }
+ }
+
+ public void SetMin(int percentage)
+ {
+ int value = (int)Math.Round(Min / 100.0 * percentage);
+ if (value > 0)
+ {
+ Min = value;
+ }
+ }
+
+ }
+}
diff --git a/DayZLootEdit/MainWindow.xaml b/DayZLootEdit/MainWindow.xaml
new file mode 100644
index 0000000..05357df
--- /dev/null
+++ b/DayZLootEdit/MainWindow.xaml
@@ -0,0 +1,597 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/DayZLootEdit/MainWindow.xaml.cs b/DayZLootEdit/MainWindow.xaml.cs
new file mode 100644
index 0000000..e4e0036
--- /dev/null
+++ b/DayZLootEdit/MainWindow.xaml.cs
@@ -0,0 +1,1001 @@
+using Microsoft.Win32;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Web;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Input;
+
+namespace DayZLootEdit
+{
+ ///
+ /// Interaktionslogik für MainWindow.xaml
+ ///
+ public partial class MainWindow : Window
+ {
+
+ // VARIABLES
+
+ private const string WINDOW_TITLE_DEFAULT = "DayZ Loot Editor";
+ private const string WINDOW_TITLE_FILE = "DayZ Loot Editor - [%1]";
+
+ private string LootFile = "";
+ private LootTable LootTable;
+
+ private List categoryList = new List();
+ private List tagList = new List();
+
+ // MAIN WINDOW
+
+ public MainWindow()
+ {
+
+ InitializeComponent();
+ InitializeControls();
+
+ }
+
+ private void InitializeControls()
+ {
+
+ this.Title = WINDOW_TITLE_DEFAULT;
+ MnuFileSave.IsEnabled = false;
+ MnuFileSaveAs.IsEnabled = false;
+ MnuFileClose.IsEnabled = false;
+ MnuFileReload.IsEnabled = false;
+ MnuEditSelectAll.IsEnabled = false;
+ MnuEditSelectNone.IsEnabled = false;
+ MnuEditName.IsEnabled = false;
+ MnuEditAmount.IsEnabled = false;
+ MnuEditLifetime.IsEnabled = false;
+ MnuEditRestock.IsEnabled = false;
+ MnuEditQuantity.IsEnabled = false;
+ MnuEditCost.IsEnabled = false;
+ MnuEditClear.IsEnabled = false;
+
+ ResetPercentControls();
+ ResetFilterControls();
+
+ txtFilterName.Text = "";
+ cmbFilterCategory.SelectedIndex = 0;
+ cmbFilterTag.SelectedIndex = 0;
+ txtFilterUsage.Text = "";
+ txtFilterValue.Text = "";
+
+ grpPercent.IsEnabled = false;
+ grpFilter.IsEnabled = false;
+
+ lblStatusCount.Content = "No Data";
+ prgLoading.Visibility = Visibility.Hidden;
+
+ }
+
+ private async void OpenLootFile(string lFile)
+ {
+
+ try
+ {
+
+ string windowTitle = "";
+ StringBuilder builder = new StringBuilder(WINDOW_TITLE_FILE);
+ builder.Replace("%1", lFile);
+ windowTitle = builder.ToString();
+ this.Title = windowTitle;
+ this.IsEnabled = false;
+ Mouse.OverrideCursor = Cursors.Wait;
+
+ LootList.ItemsSource = null;
+ ResetPercentControls();
+ ResetFilterControls();
+
+ lblStatusCount.Content = "loading...";
+
+ LootTable = new LootTable(lFile);
+ LootTable.LoadFile();
+
+ prgLoading.Value = 0;
+ prgLoading.Maximum = LootTable.Loot.Count;
+ prgLoading.Visibility = Visibility.Visible;
+ await Task.Delay(TimeSpan.FromMilliseconds(500));
+
+ RefreshFilterListing();
+
+ prgLoading.Value = LootTable.Loot.Count;
+ await Task.Delay(TimeSpan.FromSeconds(1));
+ prgLoading.Visibility = Visibility.Hidden;
+
+ this.IsEnabled = true;
+
+ LootList.ItemsSource = LootTable.Loot;
+ LootList.IsEnabled = true;
+
+ MnuFileSave.IsEnabled = true;
+ MnuFileSaveAs.IsEnabled = true;
+ MnuFileClose.IsEnabled = true;
+ MnuFileReload.IsEnabled = true;
+ MnuEditSelectAll.IsEnabled = true;
+ MnuEditSelectNone.IsEnabled = false;
+ MnuEditAmount.IsEnabled = false;
+ MnuEditLifetime.IsEnabled = false;
+ MnuEditRestock.IsEnabled = false;
+ MnuEditQuantity.IsEnabled = false;
+ MnuEditCost.IsEnabled = false;
+ MnuEditClear.IsEnabled = false;
+
+ grpFilter.IsEnabled = true;
+
+ Mouse.OverrideCursor = Cursors.Arrow;
+ UpdateStatus();
+
+ }
+ catch (Exception err)
+ {
+
+ Mouse.OverrideCursor = Cursors.Arrow;
+
+ string mb_caption = "Error";
+ string mb_message = "An error occurred!\n\n%1";
+ StringBuilder builder = new StringBuilder(mb_message);
+ builder.Replace("%1", err.ToString());
+ mb_message = builder.ToString();
+
+ MessageBox.Show(
+ mb_message,
+ mb_caption,
+ MessageBoxButton.OK,
+ MessageBoxImage.Error
+ );
+
+ this.IsEnabled = true;
+ InitializeControls();
+
+ }
+
+ }
+
+ private async void SaveLootFile(string lFile = "")
+ {
+
+ try
+ {
+
+ if (lFile == "")
+ {
+ lFile = LootTable.FilePath;
+ }
+
+ string windowTitle = "";
+ StringBuilder builder = new StringBuilder(WINDOW_TITLE_FILE);
+ builder.Replace("%1", lFile);
+ windowTitle = builder.ToString();
+ this.Title = windowTitle;
+ this.IsEnabled = false;
+ Mouse.OverrideCursor = Cursors.Wait;
+
+ lblStatusCount.Content = "saving...";
+
+ prgLoading.Value = 0;
+ prgLoading.Maximum = LootTable.Loot.Count;
+ prgLoading.Visibility = Visibility.Visible;
+ await Task.Delay(TimeSpan.FromMilliseconds(500));
+
+ LootTable.SaveFile(lFile);
+
+ prgLoading.Value = LootTable.Loot.Count;
+ await Task.Delay(TimeSpan.FromSeconds(1));
+ prgLoading.Visibility = Visibility.Hidden;
+
+ /*
+ string mb_caption = "Success";
+ string mb_message = "File '%1' saved.";
+ StringBuilder mb_builder = new StringBuilder(mb_message);
+ mb_builder.Replace("%1", LootTable.FilePath);
+ mb_message = mb_builder.ToString();
+
+ MessageBox.Show(
+ mb_message,
+ mb_caption,
+ MessageBoxButton.OK,
+ MessageBoxImage.Information
+ );
+ */
+
+ this.IsEnabled = true;
+
+ Mouse.OverrideCursor = Cursors.Arrow;
+ UpdateStatus();
+
+ }
+ catch (Exception err)
+ {
+
+ Mouse.OverrideCursor = Cursors.Arrow;
+
+ string mb_caption = "Error";
+ string mb_message = "An error occurred!\n\n%1";
+ StringBuilder builder = new StringBuilder(mb_message);
+ builder.Replace("%1", err.ToString());
+ mb_message = builder.ToString();
+
+ MessageBox.Show(
+ mb_message,
+ mb_caption,
+ MessageBoxButton.OK,
+ MessageBoxImage.Error
+ );
+
+ this.IsEnabled = true;
+ InitializeControls();
+
+ }
+
+ }
+
+ // MAIN MENU
+
+ private void MnuFileOpen_Click(object sender, RoutedEventArgs e)
+ {
+
+ OpenFileDialog dlg = new OpenFileDialog();
+ dlg.Filter = "XML Files (*.xml)|*.xml|All Files (*.*)|*.*";
+ dlg.Title = "Open DayZ Types-File";
+
+ if (dlg.ShowDialog().Value)
+ {
+ LootFile = dlg.FileName;
+ OpenLootFile(LootFile);
+ }
+
+ }
+
+ private void MnuFileSave_Click(object sender, RoutedEventArgs e)
+ {
+
+ SaveLootFile();
+
+ }
+
+ private void MnuFileSaveAs_Click(object sender, RoutedEventArgs e)
+ {
+
+ SaveFileDialog dlg = new SaveFileDialog();
+ dlg.Filter = "XML Files (*.xml)|*.xml|All Files (*.*)|*.*";
+ dlg.Title = "Save DayZ Types-File";
+
+ if (dlg.ShowDialog().Value)
+ {
+ LootFile = dlg.FileName;
+ SaveLootFile(LootFile);
+ }
+
+ }
+
+ private void MnuFileReload_Click(object sender, RoutedEventArgs e)
+ {
+
+ OpenLootFile(LootFile);
+
+ }
+
+ private void MnuFileClose_Click(object sender, RoutedEventArgs e)
+ {
+
+ LootList.ItemsSource = null;
+ InitializeControls();
+
+ }
+
+ private void MnuFileExit_Click(object sender, RoutedEventArgs e)
+ {
+
+ this.Close();
+
+ }
+
+ private void MnuHelpInfo_Click(object sender, RoutedEventArgs e)
+ {
+
+ InfoWindow iw = new InfoWindow();
+ iw.ShowDialog();
+
+ }
+
+ private void MnuEditSelectAll_Click(object sender, RoutedEventArgs e)
+ {
+ LootList.SelectAll();
+ LootList.Focus();
+ }
+
+ private void MnuEditSelectNone_Click(object sender, RoutedEventArgs e)
+ {
+ LootList.SelectedIndex = -1;
+ LootList.Focus();
+ }
+
+ private void MnuEditNameSearchDuckDuck_Click(object sender, RoutedEventArgs e)
+ {
+ string uriBase = "https://duckduckgo.com/?q=";
+ string selectedClass = "";
+ foreach (LootType loot in LootList.SelectedItems)
+ {
+ selectedClass = loot.Name;
+ break;
+ }
+ string searchText = "DayZ " + selectedClass;
+ string uriQuery = uriBase + HttpUtility.UrlEncode(searchText);
+ Process.Start(uriQuery);
+ }
+
+ private void MnuEditNameSearchGoogle_Click(object sender, RoutedEventArgs e)
+ {
+ string uriBase = "https://www.google.com/search?q=";
+ string selectedClass = "";
+ foreach (LootType loot in LootList.SelectedItems)
+ {
+ selectedClass = loot.Name;
+ break;
+ }
+ string searchText = "DayZ " + selectedClass;
+ string uriQuery = uriBase + HttpUtility.UrlEncode(searchText);
+ Process.Start(uriQuery);
+ }
+
+ private void MnuEditAmountNominalToMin_Click(object sender, RoutedEventArgs e)
+ {
+ foreach (LootType loot in LootList.SelectedItems)
+ {
+ int value = loot.Nominal;
+ loot.Min = value;
+ }
+ LootList.Items.Refresh();
+ LootList.Focus();
+ }
+
+ private void MnuEditAmountMinToNominal_Click(object sender, RoutedEventArgs e)
+ {
+ foreach (LootType loot in LootList.SelectedItems)
+ {
+ int value = loot.Min;
+ loot.Nominal = value;
+ }
+ LootList.Items.Refresh();
+ LootList.Focus();
+ }
+
+ private void MnuEditAmountZero_Click(object sender, RoutedEventArgs e)
+ {
+ foreach (LootType loot in LootList.SelectedItems)
+ {
+ loot.Nominal = 0;
+ loot.Min = 0;
+ }
+ LootList.Items.Refresh();
+ LootList.Focus();
+ }
+
+ private void MnuEditLifetimeValue_Click(object sender, RoutedEventArgs e)
+ {
+ MenuItem item = e.OriginalSource as MenuItem;
+ foreach (LootType loot in LootList.SelectedItems)
+ {
+ loot.Lifetime = int.Parse(item.Tag.ToString());
+ }
+ LootList.Items.Refresh();
+ LootList.Focus();
+ }
+
+ private void MnuEditRestockValue_Click(object sender, RoutedEventArgs e)
+ {
+ MenuItem item = e.OriginalSource as MenuItem;
+ foreach (LootType loot in LootList.SelectedItems)
+ {
+ loot.Restock = int.Parse(item.Tag.ToString());
+ }
+ LootList.Items.Refresh();
+ LootList.Focus();
+ }
+
+ private void MnuEditQuantityNormal_Click(object sender, RoutedEventArgs e)
+ {
+ foreach (LootType loot in LootList.SelectedItems)
+ {
+ loot.QMax = -1;
+ loot.QMin = -1;
+ }
+ LootList.Items.Refresh();
+ LootList.Focus();
+ }
+
+ private void MnuEditQuantityQMaxValue_Click(object sender, RoutedEventArgs e)
+ {
+ MenuItem item = e.OriginalSource as MenuItem;
+ foreach (LootType loot in LootList.SelectedItems)
+ {
+ loot.QMax = int.Parse(item.Header.ToString());
+ }
+ LootList.Items.Refresh();
+ LootList.Focus();
+ }
+
+ private void MnuEditQuantityQMinValue_Click(object sender, RoutedEventArgs e)
+ {
+ MenuItem item = e.OriginalSource as MenuItem;
+ foreach (LootType loot in LootList.SelectedItems)
+ {
+ loot.QMin = int.Parse(item.Header.ToString());
+ }
+ LootList.Items.Refresh();
+ LootList.Focus();
+ }
+
+ private void MnuEditQuantityPresets_100_1_Click(object sender, RoutedEventArgs e)
+ {
+ foreach (LootType loot in LootList.SelectedItems)
+ {
+ loot.QMax = 100;
+ loot.QMin = 1;
+ }
+ LootList.Items.Refresh();
+ LootList.Focus();
+ }
+
+ private void MnuEditQuantityPresets_100_10_Click(object sender, RoutedEventArgs e)
+ {
+ foreach (LootType loot in LootList.SelectedItems)
+ {
+ loot.QMax = 100;
+ loot.QMin = 10;
+ }
+ LootList.Items.Refresh();
+ LootList.Focus();
+ }
+
+ private void MnuEditQuantityPresets_100_20_Click(object sender, RoutedEventArgs e)
+ {
+ foreach (LootType loot in LootList.SelectedItems)
+ {
+ loot.QMax = 100;
+ loot.QMin = 20;
+ }
+ LootList.Items.Refresh();
+ LootList.Focus();
+ }
+
+ private void MnuEditQuantityPresets_100_30_Click(object sender, RoutedEventArgs e)
+ {
+ foreach (LootType loot in LootList.SelectedItems)
+ {
+ loot.QMax = 100;
+ loot.QMin = 30;
+ }
+ LootList.Items.Refresh();
+ LootList.Focus();
+ }
+
+ private void MnuEditQuantityPresets_90_10_Click(object sender, RoutedEventArgs e)
+ {
+ foreach (LootType loot in LootList.SelectedItems)
+ {
+ loot.QMax = 90;
+ loot.QMin = 10;
+ }
+ LootList.Items.Refresh();
+ LootList.Focus();
+ }
+
+ private void MnuEditQuantityPresets_80_20_Click(object sender, RoutedEventArgs e)
+ {
+ foreach (LootType loot in LootList.SelectedItems)
+ {
+ loot.QMax = 80;
+ loot.QMin = 20;
+ }
+ LootList.Items.Refresh();
+ LootList.Focus();
+ }
+
+ private void MnuEditQuantityPresets_70_30_Click(object sender, RoutedEventArgs e)
+ {
+ foreach (LootType loot in LootList.SelectedItems)
+ {
+ loot.QMax = 70;
+ loot.QMin = 30;
+ }
+ LootList.Items.Refresh();
+ LootList.Focus();
+ }
+
+ private void MnuEditQuantityPresets_60_10_Click(object sender, RoutedEventArgs e)
+ {
+ foreach (LootType loot in LootList.SelectedItems)
+ {
+ loot.QMax = 60;
+ loot.QMin = 10;
+ }
+ LootList.Items.Refresh();
+ LootList.Focus();
+ }
+
+ private void MnuEditQuantityPresets_50_10_Click(object sender, RoutedEventArgs e)
+ {
+ foreach (LootType loot in LootList.SelectedItems)
+ {
+ loot.QMax = 50;
+ loot.QMin = 10;
+ }
+ LootList.Items.Refresh();
+ LootList.Focus();
+ }
+
+ private void MnuEditQuantityPresets_40_10_Click(object sender, RoutedEventArgs e)
+ {
+ foreach (LootType loot in LootList.SelectedItems)
+ {
+ loot.QMax = 40;
+ loot.QMin = 10;
+ }
+ LootList.Items.Refresh();
+ LootList.Focus();
+ }
+
+ private void MnuEditQuantityPresets_30_10_Click(object sender, RoutedEventArgs e)
+ {
+ foreach (LootType loot in LootList.SelectedItems)
+ {
+ loot.QMax = 30;
+ loot.QMin = 10;
+ }
+ LootList.Items.Refresh();
+ LootList.Focus();
+ }
+
+ private void MnuEditQuantityPresets_0_0_Click(object sender, RoutedEventArgs e)
+ {
+ foreach (LootType loot in LootList.SelectedItems)
+ {
+ loot.QMax = 0;
+ loot.QMin = 0;
+ }
+ LootList.Items.Refresh();
+ LootList.Focus();
+ }
+
+ private void MnuEditCostValue_Click(object sender, RoutedEventArgs e)
+ {
+ MenuItem item = e.OriginalSource as MenuItem;
+ foreach (LootType loot in LootList.SelectedItems)
+ {
+ loot.Cost = int.Parse(item.Header.ToString());
+ }
+ LootList.Items.Refresh();
+ LootList.Focus();
+ }
+
+ private void MnuEditClearTag_Click(object sender, RoutedEventArgs e)
+ {
+ foreach (LootType loot in LootList.SelectedItems)
+ {
+ loot.Tag = "";
+ }
+ LootList.Items.Refresh();
+ LootList.Focus();
+ }
+
+ private void MnuEditClearUsage_Click(object sender, RoutedEventArgs e)
+ {
+ foreach (LootType loot in LootList.SelectedItems)
+ {
+ loot.Usage = "";
+ }
+ LootList.Items.Refresh();
+ LootList.Focus();
+ }
+
+ private void MnuEditClearValue_Click(object sender, RoutedEventArgs e)
+ {
+ foreach (LootType loot in LootList.SelectedItems)
+ {
+ loot.Value = "";
+ }
+ LootList.Items.Refresh();
+ LootList.Focus();
+ }
+
+ // PERCENT
+
+ private void UpdatePercentControls()
+ {
+
+ int newval = 0;
+ bool ok = int.TryParse(txtPercent.Text.Replace("%", ""), out newval);
+
+ if (ok)
+ {
+ sldPercent.Value = newval;
+ txtPercent.Text = String.Format("{0}%", newval);
+ btnPercent?.Focus();
+ }
+
+ }
+
+ private void ResetPercentControls()
+ {
+
+ txtPercent.Text = "100%";
+ sldPercent.Value = 100;
+ btnPercent.IsEnabled = true;
+
+ }
+
+ private void txtPercent_GotFocus(object sender, RoutedEventArgs e)
+ {
+
+ txtPercent.SelectAll();
+
+ }
+
+ private void txtPercent_LostFocus(object sender, RoutedEventArgs e)
+ {
+
+ UpdatePercentControls();
+
+ }
+
+ private void txtPercent_KeyUp(object sender, KeyEventArgs e)
+ {
+
+ if (e.Key == Key.Enter)
+ {
+ UpdatePercentControls();
+ }
+
+ }
+
+ private void sldPercent_ValueChanged(object sender, RoutedPropertyChangedEventArgs e)
+ {
+
+ txtPercent.Text = Math.Round(sldPercent.Value).ToString();
+ UpdatePercentControls();
+
+ }
+
+ private void btnPercent_Click(object sender, RoutedEventArgs e)
+ {
+
+ int percentage = 0;
+ bool ok = int.TryParse(txtPercent.Text.Replace("%", ""), out percentage);
+ if (!ok) return;
+
+ foreach (LootType loot in LootList.SelectedItems)
+ {
+ loot.SetNominal(percentage);
+ loot.SetMin(percentage);
+ }
+
+ UpdatePercentControls();
+ LootList.Items.Refresh();
+ LootList.Focus();
+
+ }
+
+ // FILTER
+
+ private void RefreshFilterListing()
+ {
+
+ categoryList.Clear();
+ categoryList.Add("");
+
+ for (int i = 1; i < LootTable.Loot.Count; i++)
+ {
+ prgLoading.Value = i;
+ if (LootTable.Loot[i].Category != null)
+ {
+ bool exists = string.Concat(categoryList).Contains(LootTable.Loot[i].Category);
+ if (!exists)
+ {
+ categoryList.Add(LootTable.Loot[i].Category);
+ }
+ }
+ }
+
+ cmbFilterCategory.ItemsSource = categoryList;
+ cmbFilterCategory.SelectedIndex = 0;
+
+ tagList.Clear();
+ tagList.Add("");
+
+ for (int i = 1; i < LootTable.Loot.Count; i++)
+ {
+ prgLoading.Value = i;
+ if (LootTable.Loot[i].Tag != null)
+ {
+ bool exists = string.Concat(tagList).Contains(LootTable.Loot[i].Tag);
+ if (!exists)
+ {
+ tagList.Add(LootTable.Loot[i].Tag);
+ }
+ }
+ }
+
+ cmbFilterTag.ItemsSource = tagList;
+ cmbFilterTag.SelectedIndex = 0;
+
+ }
+
+ private void ResetFilterControls()
+ {
+
+ chkFilterName.IsChecked = false;
+ //txtFilterName.Text = "";
+
+ chkFilterInCargo.IsChecked = false;
+ chkFilterInHoarder.IsChecked = false;
+ chkFilterInMap.IsChecked = false;
+ chkFilterInPlayer.IsChecked = false;
+ chkFilterCrafted.IsChecked = false;
+ chkFilterDeloot.IsChecked = false;
+
+ chkFilterCategory.IsChecked = false;
+ //cmbFilterCategory.SelectedIndex = 0;
+
+ chkFilterTag.IsChecked = false;
+ //cmbFilterTag.SelectedIndex = 0;
+
+ chkFilterUsage.IsChecked = false;
+ //txtFilterUsage.Text = "";
+
+ chkFilterValue.IsChecked = false;
+ //txtFilterValue.Text = "";
+
+ //btnFilterReset.IsEnabled = true;
+ btnFilterExec.IsEnabled = false;
+
+ }
+
+ private void ResetFilter()
+ {
+ LootList.ItemsSource = LootTable.Loot;
+ ResetFilterControls();
+ UpdateStatus();
+
+ }
+
+ private void UpdateFilter()
+ {
+ ListCollectionView collectionView = new ListCollectionView(LootTable.Loot);
+ List