Skip to content

Commit

Permalink
v1.0.2: Release cleanup
Browse files Browse the repository at this point in the history
- Fix #5
- Fix #4 (Missing vault cards currently)
- Fix #2
- Add in the "short stick", it appears that my JSON data is somehow a bit wrong.... :/
- Add in badges just because (:
- Do some commenting for the helpers for future readers
- Make the `Check for Updates` button properly work... Oops (:
- Version bump of course
  • Loading branch information
FromDarkHell committed Sep 25, 2021
1 parent 942d8ee commit 3c3cf9c
Show file tree
Hide file tree
Showing 11 changed files with 143 additions and 1,681 deletions.
2 changes: 1 addition & 1 deletion BL3SaveEditor/AutoUpdater.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>

<item>
<version>1.0.1.0</version>
<version>1.0.2.0</version>
<url>https://github.com/FromDarkHell/BL3SaveEditor/releases/latest/download/BL3SaveEditor-Portable.zip</url>
<changelog>https://github.com/FromDarkHell/BL3SaveEditor/releases/latest</changelog>
<mandatory>false</mandatory>
Expand Down
59 changes: 49 additions & 10 deletions BL3SaveEditor/Helpers/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
return value;
}
}

/// <summary>
/// A WPF value converter which converts a UInt32 amount of seconds to a TimeSpan (and back and forth)
/// </summary>
Expand All @@ -40,6 +41,9 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
}
}

/// <summary>
/// A WPF multi-value converter which will only return true if all of the variables passed can be converted ot a bool; and resolve as True.
/// </summary>
public class AndConverter : IMultiValueConverter {
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) {
if (values.Any(v => ReferenceEquals(v, DependencyProperty.UnsetValue)))
Expand All @@ -58,6 +62,9 @@ public object[] ConvertBack(object value, Type[] targetTypes, object parameter,
}
}

/// <summary>
/// A WPF value converter which implements a simple limiting function on the passed parameter (as an integer)
/// </summary>
public class IntegerLimiterConverter : IValueConverter {
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
int limit = System.Convert.ToInt32(parameter);
Expand All @@ -74,6 +81,9 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
}

#region Specialized Converters
/// <summary>
/// A simple WPF converter that converts the EXP points of a player to the specified level
/// </summary>
public class EXPointToLevelConverter : IValueConverter {
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
return PlayerXP.GetLevelForPoints(System.Convert.ToInt32(value));
Expand All @@ -83,6 +93,12 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
return PlayerXP.GetPointsForXPLevel(System.Convert.ToInt32(value));
}
}

/// <summary>
/// A simple WPF converter that converts the XP level of a player to the specified XP points
/// <para></para>
/// See also: <seealso cref="EXPointToLevelConverter"/>
/// </summary>
public class LevelToEXPointConverter : IValueConverter {
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
return PlayerXP.GetPointsForXPLevel(System.Convert.ToInt32(value));
Expand All @@ -92,6 +108,9 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
return PlayerXP.GetLevelForPoints(System.Convert.ToInt32(value));
}
}
/// <summary>
/// A WPF value converter that converts the player class (<see cref="PlayerClassSaveGameData"/>) to a string based off of the path
/// </summary>
public class StringToCharacterClassConverter : IValueConverter {
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
if (value != null) {
Expand All @@ -112,9 +131,11 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
}
return null;
}


}

/// <summary>
/// A simple WPF value converter which converts the <see cref="CustomPlayerColorSaveGameData"/> struct to a native C# <see cref="Color"/> struct.
/// </summary>
public class CustomPlayerColorToColorConverter : IValueConverter {
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {

Expand Down Expand Up @@ -153,6 +174,10 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
return null;
}
}

/// <summary>
/// A simple WPF value converter which converts the passed in customization path to a "human safe" name
/// </summary>
public class CustomizationToStringConverter : IValueConverter {
private Character chx = null;
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
Expand Down Expand Up @@ -227,6 +252,10 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
return null;
}
}

/// <summary>
/// A WPF value converter which converts the given <c>parameter</c> ("money"/"eridium") to the integer value based off of the stored character in <c>value</c>
/// </summary>
public class CurrencyToIntegerConverter : IValueConverter {
private Character chx = null;
private uint currencyHash = 0;
Expand All @@ -236,18 +265,12 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
string param = (string)parameter;
chx = (Character)value;
switch (param) {
case "golden":
currencyHash = DataPathTranslations.GoldenKeyHash;
break;
case "money":
currencyHash = DataPathTranslations.MoneyHash;
break;
case "eridium":
currencyHash = DataPathTranslations.EridiumHash;
break;
case "diamond":
currencyHash = DataPathTranslations.DiamondKeyHash;
break;
default:
break;
}
Expand Down Expand Up @@ -277,6 +300,7 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
return chx;
}
}

public class TravelStationConverter : IMultiValueConverter {
private Character chx = null;
private bool bShowDbgMaps = false;
Expand Down Expand Up @@ -323,6 +347,10 @@ public object[] ConvertBack(object value, Type[] targetType, object parameter, C
return null;
}
}

/// <summary>
/// Converts the most active playthrough of the <see cref="Character"/> stored in <c>value</c> to a string (NVHM/TVHM)
/// </summary>
public class PlaythroughToStringConverter : IValueConverter {
private static readonly string[] indexToString = new string[] {
"NVHM",
Expand All @@ -346,6 +374,10 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
return chx;
}
}

/// <summary>
/// Converts guardian rank data to a valid data grid type (<see cref="ObservableCollection{T}"/>
/// </summary>
public class GuardianRankToDataGridConverter : IValueConverter {
private Profile prf = null;

Expand Down Expand Up @@ -377,12 +409,15 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
return prf;
}
}

public class KeyToIntegerConverter : IValueConverter {
private Profile prf = null;

public static Dictionary<string, uint> stringToHash = new Dictionary<string, uint>() {
{ "GoldenKeys", DataPathTranslations.GoldenKeyHash },
{ "DiamondKeys", DataPathTranslations.DiamondKeyHash }
{ "DiamondKeys", DataPathTranslations.DiamondKeyHash },
{ "VaultCard1Keys", DataPathTranslations.VaultCard1Hash },
{ "VaultCard2Keys", DataPathTranslations.VaultCard2Hash }
};

public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
Expand Down Expand Up @@ -446,8 +481,11 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
return prf;
}
}

/// <summary>
/// A WPF converter that returns the first object that is not set to null in the multiple values passed in to the multi-value converter
/// </summary>
public class MultiElementObjectBinder : IMultiValueConverter {

public object Convert(object[] value, Type targetType, object parameter, CultureInfo culture) {
foreach (object obj in value) {
if (obj != null && obj != DependencyProperty.UnsetValue) {
Expand All @@ -462,6 +500,7 @@ public object[] ConvertBack(object value, Type[] targetType, object parameter, C
return null;
}
}

public class IntegerToMayhemLevelConverter : IValueConverter {
private Borderlands3Serial serial = null;
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
Expand Down
33 changes: 20 additions & 13 deletions BL3SaveEditor/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
</adonisControls:AdonisWindow.TitleBarContent>
<Grid>
<ToolBar x:Uid="ToolWindowToolbar" AllowDrop="False" Focusable="False" HorizontalAlignment="Left"
VerticalAlignment="Top" Width="792"
Background="{DynamicResource {x:Static adonisUi:Brushes.Layer0BackgroundBrush}}" Height="30">
VerticalAlignment="Top" Background="{DynamicResource {x:Static adonisUi:Brushes.Layer0BackgroundBrush}}"
Height="30">
<!-- I'm hiding this button for now because I find it to be a pain to work on -->
<Button Visibility="Collapsed" Name="NewSaveBtn" Click="NewSaveBtn_Click">
<StackPanel Orientation="Horizontal">
Expand Down Expand Up @@ -155,7 +155,8 @@
<ComboBox IsEnabled="{Binding Path=bSaveLoaded}"
ItemsSource="{Binding Path=ValidPlayerClasses}"
SelectedValue="{Binding Path=saveGame.Character.PlayerClassData, Mode=TwoWay, Converter={StaticResource CharacterClassConverter1}}"
HorizontalAlignment="Stretch" Margin="155,11,20,0" VerticalAlignment="Top" />
SelectionChanged="CharacterClass_SelectionChanged" HorizontalAlignment="Stretch"
Margin="155,11,20,0" VerticalAlignment="Top" />

<Label FontWeight="Normal" Content="XP Level: " Margin="10,40,0,0"
VerticalContentAlignment="Center" HorizontalContentAlignment="Left"
Expand Down Expand Up @@ -849,38 +850,44 @@
<xctk:LongUpDown Value="{Binding profile.Profile.GuardianRank.NewGuardianExperience, Mode=TwoWay}"
HorizontalAlignment="Right" Margin="0,175,10,0" VerticalAlignment="Top"
ToolTip="Amount of XP associated with your guardian rank level" Width="254" />
<Label FontWeight="Normal" Content="Bank SDUs: " HorizontalAlignment="Right" Margin="0,260,309,0"
<Label FontWeight="Normal" Content="Bank SDUs: " HorizontalAlignment="Right" Margin="0,287,309,0"
VerticalAlignment="Top" Width="100" Height="20" />
<xctk:IntegerUpDown
Value="{Binding profile.Profile, Mode=TwoWay, Converter={StaticResource SDUConverter1}, ConverterParameter=Bank}"
Minimum="0" Maximum="{Binding MaximumBankSDUs}" HorizontalAlignment="Right"
Margin="0,260,10,0" VerticalAlignment="Top" ToolTip="Amount of Bank SDUs on your character"
Margin="0,287,10,0" VerticalAlignment="Top" ToolTip="Amount of Bank SDUs on your character"
Width="254" />

<Label FontWeight="Normal" Content="Lost Loot SDUs: " HorizontalAlignment="Right"
Margin="0,285,309,0" VerticalAlignment="Top" Width="100" Height="20" />
Margin="0,312,309,0" VerticalAlignment="Top" Width="100" Height="20" />
<xctk:IntegerUpDown
Value="{Binding profile.Profile, Mode=TwoWay, Converter={StaticResource SDUConverter1}, ConverterParameter=LostLoot}"
Minimum="0" Maximum="{Binding MaximumLostLootSDUs}" HorizontalAlignment="Right"
Margin="0,285,10,0" VerticalAlignment="Top"
Margin="0,312,10,0" VerticalAlignment="Top"
ToolTip="Amount of Lost Loot SDUs on your profile" Width="254" />
<Label FontWeight="Normal" Content="Citizen Science Bucks: " HorizontalAlignment="Right"
Margin="0,210,284,0" VerticalAlignment="Top" Width="125" Height="20" />
<xctk:IntegerUpDown Value="{Binding profile.Profile.CitizenScienceCSBucksAmount, Mode=TwoWay}"
HorizontalAlignment="Right" Margin="0,210,10,0" VerticalAlignment="Top"
ToolTip="Amount of XP associated with your guardian rank level" Width="254" />
ToolTip="Amount of citizen science dollars you've got" Width="254" />
<Label FontWeight="Normal" Content="Golden Keys: " HorizontalAlignment="Right" Margin="0,235,284,0"
VerticalAlignment="Top" Width="125" Height="20" />
<xctk:IntegerUpDown
Value="{Binding profile.Profile, Mode=TwoWay, Converter={StaticResource KeyToIntegerConverter1}, ConverterParameter=GoldenKeys}"
HorizontalAlignment="Right" Margin="0,235,10,0" VerticalAlignment="Top"
ToolTip="Amount of XP associated with your guardian rank level" Width="254" />
<Button Content="Clear Lost Loot" HorizontalAlignment="Right" Margin="0,320,304,0" Width="105"
ToolTip="Amount of golden keys on your profile" Width="254" />
<Button Content="Clear Lost Loot" HorizontalAlignment="Right" Margin="0,347,304,0" Width="105"
Height="24" VerticalAlignment="Top" Name="ClearLLBtn" Click="ClearLLBtn_Click" />
<Button Content="Clear Bank" HorizontalAlignment="Right" Margin="0,320,159,0" Width="105"
<Button Content="Clear Bank" HorizontalAlignment="Right" Margin="0,347,159,0" Width="105"
Height="24" VerticalAlignment="Top" Name="ClearBankBtn" Click="ClearBankBtn_Click" />
<Button Content="Inject Guardian Rank" HorizontalAlignment="Right" Margin="0,320,10,0" Width="125"
<Button Content="Inject Guardian Rank" HorizontalAlignment="Right" Margin="0,347,10,0" Width="125"
Height="24" VerticalAlignment="Top" Click="InjectGRBtn_Click" />
<Label FontWeight="Normal" Content="Diamond Keys: " HorizontalAlignment="Right" Margin="0,260,284,0"
VerticalAlignment="Top" Width="125" Height="20" />
<xctk:IntegerUpDown
Value="{Binding profile.Profile, ConverterParameter=DiamondKeys, Converter={StaticResource KeyToIntegerConverter1}, Mode=TwoWay}"
HorizontalAlignment="Right" Margin="0,260,10,0" VerticalAlignment="Top"
ToolTip="Amount of diamond keys for your profile" Width="254" />
</Grid>
</TabItem>
<TabItem HorizontalAlignment="Left">
Expand Down Expand Up @@ -956,7 +963,7 @@
<Run Foreground="MediumPurple" Text="In memory of Baysix. Fly high." />
</TextBlock>
<Button Content="Check For Updates" VerticalAlignment="Top" HorizontalAlignment="Right"
Margin="0,22,6,0" Width="120" />
Margin="0,22,6,0" Width="120" Click="UpdateButton_Click" />
<CheckBox Name="DarkModeBox" Content="Enable Dark Mode" HorizontalAlignment="Right"
Margin="0,51,6,0" VerticalAlignment="Top" IsChecked="True" Height="20"
Checked="DarkModeBox_Checked" Unchecked="DarkModeBox_Checked" Width="120" />
Expand Down
Loading

0 comments on commit 3c3cf9c

Please sign in to comment.