Skip to content

Commit

Permalink
Merge pull request #262 from lastbattle/staging
Browse files Browse the repository at this point in the history
Quest editor, image upscaling for obj+bg, .NET 8.0
  • Loading branch information
lastbattle authored Nov 4, 2024
2 parents e7d75d2 + acf3130 commit da59908
Show file tree
Hide file tree
Showing 288 changed files with 29,637 additions and 18,756 deletions.
8 changes: 5 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[submodule "spine-runtimes"]
path = spine-runtimes
url = https://github.com/EsotericSoftware/spine-runtimes
[submodule "MapleLib"]
path = MapleLib
url = https://github.com/lastbattle/MapleLib
branch = main
[submodule "dockpanelsuite"]
path = dockpanelsuite
url = https://github.com/lastbattle/dockpanelsuiteCore
branch = main
28 changes: 28 additions & 0 deletions HaCreator/Converter/BoolToTemplateConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;

namespace HaCreator.Converter
{
public class BoolToTemplateConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is bool boolValue && parameter is DataTemplate[] templates && templates.Length == 2)
{
return boolValue ? templates[0] : templates[1];
}
return null;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
36 changes: 36 additions & 0 deletions HaCreator/Converter/CharacterJobTypeToCharacterJobStrConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using MapleLib.WzLib.WzStructure.Data.CharacterStructure;
using MapleLib.WzLib.WzStructure.Data.QuestStructure;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Media;

namespace HaCreator.Converter
{
public class CharacterJobTypeToCharacterJobStrConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is CharacterClassType job)
{
return job.ToString();
}
return CharacterClassType.NULL.ToString();
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is string jobName)
{
CharacterClassType job = (CharacterClassType)Enum.Parse(typeof(CharacterClassType), jobName);

return job;
}
return CharacterClassType.NULL;
}
}
}
28 changes: 28 additions & 0 deletions HaCreator/Converter/CharacterSubJobTypeConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using MapleLib.WzLib.WzStructure.Data.CharacterStructure;
using System;
using System.Globalization;
using System.Windows.Data;

namespace HaCreator.Converter
{
public class CharacterSubJobTypeConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is long subJob)
{
return CharacterSubJobFlagTypeExt.ToEnum((int) subJob);
}
return CharacterSubJobFlagType.Adventurer.ToString();
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is CharacterSubJobFlagType jobType)
{
return (long)jobType;
}
return (long) CharacterSubJobFlagType.Adventurer;
}
}
}
30 changes: 30 additions & 0 deletions HaCreator/Converter/EnumNameIntValueConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace HaCreator.Converter
{
public class EnumNameIntValueConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is Enum enumValue)
{
string name = enumValue.ToString().Replace("_", " ");
int intValue = System.Convert.ToInt32(enumValue);

return $"{name} ({intValue})";
}
return string.Empty;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
40 changes: 40 additions & 0 deletions HaCreator/Converter/EnumToIntHexValueConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace HaCreator.Converter
{
public class EnumToIntHexValueConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
return 0;

Type enumType = value.GetType();
if (!enumType.IsEnum)
throw new ArgumentException("Value must be an enum", nameof(value));

Type underlyingType = Enum.GetUnderlyingType(enumType);
if (underlyingType == typeof(int))
{
int intValue = System.Convert.ToInt32(value);

return string.Format("0x{0:X}", intValue); // Uppercase hex
}

// If the enum is not based on int, return the original value
return value;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
// Implement if needed, or throw NotImplementedException
throw new NotImplementedException();
}
}
}
39 changes: 39 additions & 0 deletions HaCreator/Converter/EnumToIntValueConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using MapleLib.WzLib.WzStructure.Data.QuestStructure;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace HaCreator.Converter
{
public class EnumToIntValueConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
return 0;

Type enumType = value.GetType();
if (!enumType.IsEnum)
throw new ArgumentException("Value must be an enum", nameof(value));

Type underlyingType = Enum.GetUnderlyingType(enumType);
if (underlyingType == typeof(int))
{
return System.Convert.ToInt32(value);
}

// If the enum is not based on int, return the original value
return value;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
// Implement if needed, or throw NotImplementedException
throw new NotImplementedException();
}
}
}
27 changes: 27 additions & 0 deletions HaCreator/Converter/EnumToVisibilityConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows;

namespace HaCreator.Converter
{
public class EnumToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null || parameter == null)
return Visibility.Collapsed;

return value.Equals(parameter) ? Visibility.Visible : Visibility.Collapsed;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
47 changes: 47 additions & 0 deletions HaCreator/Converter/ItemIdToItemNameConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace HaCreator.Converter
{

public class ItemIdToItemNameConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
return string.Empty;

int itemId = 0;
if (value is int)
{
itemId = (int)value;
} else
{
itemId = (int) ((long)value);
}

const string NO_NAME = "NO NAME";

if (!Program.InfoManager.ItemNameCache.ContainsKey(itemId))
{
return NO_NAME;
}
Tuple<string, string, string> nameCache = Program.InfoManager.ItemNameCache[itemId]; // // itemid, <item category, item name, item desc>
if (nameCache != null)
{
return nameCache.Item2;
}
return NO_NAME;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
45 changes: 45 additions & 0 deletions HaCreator/Converter/JobBitfieldToJobNamesConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using MapleLib.WzLib.WzStructure.Data.CharacterStructure;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace HaCreator.Converter
{
public class JobBitfieldToJobNamesConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
long bitfield = (long)value;

IEnumerable<string> classNames = Enum.GetValues(typeof(CharacterJobPreBBType))
.Cast<CharacterJobPreBBType>()
.Where(c => c != CharacterJobPreBBType.None)
.Where(c => ((CharacterJobPreBBType)bitfield).HasFlag(c))
.Select(c =>
{
string jobName = c.ToString();

// Add spaces between words
string ret = string.Concat(jobName.Select(x => char.IsUpper(x) ? " " + x : x.ToString())).Trim();
return ret;
});

if (classNames.Count() == 0)
{
return string.Empty;
}
return string.Join(", ", classNames);
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}

}
}

38 changes: 38 additions & 0 deletions HaCreator/Converter/JobClassBitfieldToClassNamesConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using MapleLib.WzLib.WzStructure.Data.CharacterStructure;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace HaCreator.Converter
{
public class JobClassBitfieldToClassNamesConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
int bitfield = (int)value;

IEnumerable<string> classNames = Enum.GetValues(typeof(CharacterClassType))
.Cast<CharacterClassType>()
.Where(c => c != CharacterClassType.NULL && c != CharacterClassType.UltimateAdventurer)
.Where(c => (bitfield & (1 << (int)c)) != 0)
.Select(c => c.ToString());

if (classNames.Count() == 0)
{
return "ALL CLASSES";
}
return string.Join(", ", classNames);
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}

}
}

Loading

0 comments on commit da59908

Please sign in to comment.