Skip to content

Commit c0806b3

Browse files
authored
Combined changes
* all modifications made from https://github.com/jensbrak/Loki/commits/master/?since=2023-01-05&until=2025-09-16 to add compatibility with newer Valheim patches (Call For Arms (0.221.4)) * include ability to move inventory items via drag&drop (Feature: Moving inventory items Wufflez#37)
2 parents b718053 + 108869c commit c0806b3

29 files changed

+2239
-2907
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,4 +337,5 @@ ASALocalRun/
337337
.localhistory/
338338

339339
# BeatPulse healthcheck temp database
340-
healthchecksdb
340+
healthchecksdb
341+
Loki/SharedItemData.old1.csv

Loki/Beard.cs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,13 @@ namespace Loki
55
{
66
public readonly struct Beard
77
{
8-
private static readonly Beard[] SensibleBeards =
9-
{
10-
new Beard(Loki.Properties.Resources.B_No_beard, "BeardNone"),
11-
new Beard(Loki.Properties.Resources.B_Braided_2, "Beard5"),
12-
new Beard(Loki.Properties.Resources.B_Braided_2, "Beard6"),
13-
new Beard(Loki.Properties.Resources.B_Braided_3, "Beard9"),
14-
new Beard(Loki.Properties.Resources.B_Braided_4, "Beard10"),
15-
new Beard(Loki.Properties.Resources.B_Long_1, "Beard1"),
16-
new Beard(Loki.Properties.Resources.B_Long_2, "Beard2"),
17-
new Beard(Loki.Properties.Resources.B_Short_1, "Beard3"),
18-
new Beard(Loki.Properties.Resources.B_Short_2, "Beard4"),
19-
new Beard(Loki.Properties.Resources.B_Short_3, "Beard7"),
20-
new Beard(Loki.Properties.Resources.B_Thick_1, "Beard8"),
21-
};
8+
private static readonly IEnumerable<Beard> SensibleBeards =
9+
ItemDb.AllItems
10+
.Where(i =>
11+
i.ItemType == ItemType.Customization
12+
&& i.ItemName.ToLower().Contains("beard"))
13+
.Select(i =>
14+
new Beard(i.DisplayName, i.ItemName));
2215

2316
private static readonly IEnumerable<Beard> SillyBeards =
2417
ItemDb.AllItems.Where(i => i.ItemType == ItemType.Trophy)

Loki/Biome.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ public enum Biome
1212
DeepNorth = 64,
1313
Ocean = 256,
1414
Mistlands = 512,
15-
BiomesMax = 513,
15+
All = 895,
1616
}
1717
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Globalization;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using System.Windows;
8+
using System.Windows.Data;
9+
10+
namespace Loki
11+
{
12+
public class BoolToLocalizedTextConverter : IValueConverter
13+
{
14+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
15+
{
16+
if (value == null)
17+
{
18+
return null;
19+
}
20+
21+
if (value is bool boolValue)
22+
{
23+
var localizedText = boolValue
24+
? Loki.Properties.Resources.BoolTrueText
25+
: Loki.Properties.Resources.BoolFalseText;
26+
return localizedText ?? value.ToString();
27+
}
28+
29+
return null;
30+
}
31+
32+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
33+
{
34+
throw new NotImplementedException();
35+
}
36+
}
37+
}

Loki/CharacterFile.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,20 @@ public string FilePath
5050

5151
public static CharacterFile[] LoadCharacterFiles()
5252
{
53-
string localLowPath = Shell32.GetKnownFolderPath(Shell32.LocalLowId);
54-
string charactersPath = Path.Join(localLowPath, @"IronGate\Valheim\characters");
55-
return Directory.EnumerateFiles(charactersPath, "*.fch").Select(FromPath).ToArray();
53+
54+
// Explicit load of a character file
55+
if (!string.IsNullOrEmpty(MainWindow.explicitlyLoadThisFile))
56+
{
57+
// File to open given by command line arg (ie "open with -> Loki")
58+
return new CharacterFile[] { FromPath(MainWindow.explicitlyLoadThisFile) };
59+
}
60+
else
61+
{
62+
// Standard behaviour: open all character files in Valheim local save directory
63+
string localLowPath = Shell32.GetKnownFolderPath(Shell32.LocalLowId);
64+
string charactersPath = Path.Join(localLowPath, @"IronGate\Valheim\characters_local");
65+
return Directory.EnumerateFiles(charactersPath, "*.fch").Select(FromPath).ToArray();
66+
}
5667
}
5768

5869
public static CharacterFile FromPath(string characterFilePath)

Loki/Commands.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,14 @@ public static class Commands
1212

1313
public static RoutedUICommand RestoreCharacter =
1414
new RoutedUICommand("Restore", nameof(RestoreCharacter), typeof(Commands));
15+
16+
public static RoutedUICommand ModifyAllSkills =
17+
new RoutedUICommand("ModifySkills", nameof(ModifyAllSkills), typeof(Commands));
18+
19+
public static RoutedUICommand RepairInventoryItems =
20+
new RoutedUICommand("RepairItems", nameof(RepairInventoryItems), typeof(Commands));
21+
22+
public static RoutedUICommand FillInventoryStacks =
23+
new RoutedUICommand("FillStacks", nameof(RepairInventoryItems), typeof(Commands));
1524
}
1625
}

Loki/EnumConverter.cs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Globalization;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using System.Windows.Data;
8+
using System.Windows;
9+
10+
namespace Loki
11+
{
12+
public class EnumConverter : IValueConverter
13+
{
14+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
15+
{
16+
if (value == null)
17+
{
18+
return null;
19+
}
20+
21+
if (targetType.IsEnum)
22+
{
23+
// int -> Enum
24+
return Enum.ToObject(targetType, value);
25+
}
26+
27+
if (value.GetType().IsEnum)
28+
{
29+
// Enum -> int
30+
return System.Convert.ChangeType(value, Enum.GetUnderlyingType(value.GetType()));
31+
}
32+
33+
return null;
34+
}
35+
36+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
37+
{
38+
// Same conversion for both directions
39+
return Convert(value, targetType, parameter, culture);
40+
}
41+
}
42+
}

Loki/Hair.cs

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,13 @@ namespace Loki
55
{
66
public readonly struct Hair
77
{
8-
private static readonly Hair[] SensibleHairs =
9-
{
10-
new Hair(Loki.Properties.Resources.No_hair, "HairNone"),
11-
new Hair(Loki.Properties.Resources.Braided_1, "Hair3"),
12-
new Hair(Loki.Properties.Resources.Braided_2, "Hair11"),
13-
new Hair(Loki.Properties.Resources.Braided_3, "Hair12"),
14-
new Hair(Loki.Properties.Resources.Braided_4, "Hair6"),
15-
new Hair(Loki.Properties.Resources.Long_1, "Hair1"),
16-
new Hair(Loki.Properties.Resources.Ponytail_1, "Hair2"),
17-
new Hair(Loki.Properties.Resources.Ponytail_2, "Hair4"),
18-
new Hair(Loki.Properties.Resources.Ponytail_3, "Hair7"),
19-
new Hair(Loki.Properties.Resources.Ponytail_4, "Hair5"),
20-
new Hair(Loki.Properties.Resources.Short_1, "Hair8"),
21-
new Hair(Loki.Properties.Resources.Short_2, "Hair13"),
22-
new Hair(Loki.Properties.Resources.Side_Swept_1, "Hair9"),
23-
new Hair(Loki.Properties.Resources.Side_Swept_2, "Hair10"),
24-
new Hair(Loki.Properties.Resources.Side_Swept_3, "Hair14"),
25-
new Hair(Loki.Properties.Resources.Blob_hair, "TrophyBlob"),
26-
};
8+
private static readonly IEnumerable<Hair> SensibleHairs =
9+
ItemDb.AllItems
10+
.Where(i =>
11+
i.ItemType == ItemType.Customization
12+
&& i.ItemName.ToLower().Contains("hair"))
13+
.Select(i =>
14+
new Hair(i.DisplayName, i.ItemName));
2715

2816
private static readonly IEnumerable<Hair> SillyHairs =
2917
ItemDb.AllItems.Where(i => i.ItemType == ItemType.Trophy)

Loki/InventoryListItem.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,17 @@ private static InventoryListItem CreateListItem(SharedItemData itemData)
4343
ItemType.Legs => Loki.Properties.Resources.Legs,
4444
ItemType.Hands => Loki.Properties.Resources.Hands,
4545
ItemType.Trophy => Loki.Properties.Resources.Trophy,
46-
ItemType.TwoHandedWeapon => Loki.Properties.Resources.Trophy,
46+
ItemType.TwoHandedWeapon => Loki.Properties.Resources.Two_Handed_Weapon,
4747
ItemType.Torch => Loki.Properties.Resources.Torch,
4848
ItemType.Misc => Loki.Properties.Resources.Miscellaneous,
4949
ItemType.Shoulder => Loki.Properties.Resources.Shoulder,
5050
ItemType.Utility => Loki.Properties.Resources.Utility,
5151
ItemType.Tool => Loki.Properties.Resources.Tool,
5252
ItemType.AttachAtgeir => Loki.Properties.Resources.Attach_Atgeir,
53+
ItemType.Fish => Loki.Properties.Resources.Fish,
54+
ItemType.TwoHandedWeaponLeft => Loki.Properties.Resources.Two_Handed_Weapon_Left,
55+
ItemType.AmmoNonEquipable => Loki.Properties.Resources.Ammo_Non_Equipable,
56+
ItemType.Trinket => Loki.Properties.Resources.Trinket,
5357
_ => Loki.Properties.Resources.Unknown,
5458
};
5559
return new InventoryListItem(displayName, category, itemData);

Loki/InventorySlotEditor.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@
167167
</UserControl.Resources>
168168

169169

170-
<Border CornerRadius="4" x:Name="LayoutRoot" AllowDrop="True" Drop="BorderDrop">
170+
<Border CornerRadius="4" x:Name="LayoutRoot" AllowDrop="True" Drop="BorderDrop" MouseMove="BorderMouseMove">
171171
<Border.Style>
172172
<Style TargetType="Border">
173173
<Setter Property="Background" Value="DarkGray"/>

0 commit comments

Comments
 (0)