Skip to content

Commit fe70e2d

Browse files
committed
Initial Commit
1 parent 0c4fe75 commit fe70e2d

16 files changed

Lines changed: 720 additions & 77 deletions

nms-mod-manager/App.xaml

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,83 @@
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:local="clr-namespace:nms_mod_manager"
5-
StartupUri="MainWindow.xaml">
5+
StartupUri="MainWindow.xaml"
6+
ShutdownMode="OnExplicitShutdown">
67
<Application.Resources>
7-
8+
<Style x:Key="betterButton" TargetType="{x:Type Button}">
9+
<Setter Property="Width" Value="100"/>
10+
<Setter Property="Height" Value="50"/>
11+
<Setter Property="Margin" Value="2"/>
12+
<Setter Property="FontFamily" Value="Arial"/>
13+
<Setter Property="FontSize" Value="12px"/>
14+
<Setter Property="Cursor" Value="Hand"/>
15+
<Setter Property="Foreground">
16+
<Setter.Value>
17+
<SolidColorBrush Opacity="1" Color="#dddddd"/>
18+
</Setter.Value>
19+
</Setter>
20+
<Setter Property="Background" >
21+
<Setter.Value>
22+
<SolidColorBrush Opacity="1" Color="#333333" />
23+
</Setter.Value>
24+
</Setter>
25+
<Setter Property="Template">
26+
<Setter.Value>
27+
<ControlTemplate TargetType="{x:Type Button}">
28+
29+
<Border x:Name="border"
30+
SnapsToDevicePixels="True"
31+
BorderThickness="1"
32+
Padding="4,2"
33+
BorderBrush="#333333"
34+
CornerRadius="3"
35+
Background="{TemplateBinding Background}">
36+
<Grid>
37+
<ContentPresenter
38+
Margin="2"
39+
HorizontalAlignment="Center"
40+
VerticalAlignment="Center"
41+
RecognizesAccessKey="True" />
42+
43+
</Grid>
44+
</Border>
45+
46+
</ControlTemplate>
47+
</Setter.Value>
48+
</Setter>
49+
50+
<Style.Triggers>
51+
<Trigger Property="IsMouseOver" Value="true">
52+
<Trigger.EnterActions>
53+
<BeginStoryboard>
54+
<Storyboard>
55+
<ColorAnimation To="#B7494E"
56+
Storyboard.TargetProperty="(Control.Background).(SolidColorBrush.Color)"
57+
FillBehavior="HoldEnd" Duration="0:0:0.25" AutoReverse="False" RepeatBehavior="1x"/>
58+
<ColorAnimation To="#333333"
59+
Storyboard.TargetProperty="(Control.Foreground).(SolidColorBrush.Color)"
60+
FillBehavior="HoldEnd" Duration="0:0:0.25" AutoReverse="False" RepeatBehavior="1x"/>
61+
</Storyboard>
62+
</BeginStoryboard>
63+
</Trigger.EnterActions>
64+
65+
<Trigger.ExitActions>
66+
<BeginStoryboard>
67+
<Storyboard>
68+
<ColorAnimation
69+
Storyboard.TargetProperty="(Control.Background).(SolidColorBrush.Color)"
70+
FillBehavior="HoldEnd" Duration="0:0:0.25" AutoReverse="False" RepeatBehavior="1x"/>
71+
<ColorAnimation
72+
Storyboard.TargetProperty="(Control.Foreground).(SolidColorBrush.Color)"
73+
FillBehavior="HoldEnd" Duration="0:0:0.25" AutoReverse="False" RepeatBehavior="1x"/>
74+
</Storyboard>
75+
</BeginStoryboard>
76+
</Trigger.ExitActions>
77+
78+
</Trigger>
79+
80+
81+
</Style.Triggers>
82+
</Style>
883
</Application.Resources>
984
</Application>

nms-mod-manager/App.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ namespace nms_mod_manager
1313
/// </summary>
1414
public partial class App : Application
1515
{
16+
1617
}
1718
}

nms-mod-manager/AskDialog.xaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<Window x:Class="nms_mod_manager.AskDialog"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6+
xmlns:local="clr-namespace:nms_mod_manager"
7+
mc:Ignorable="d"
8+
Title="AskDialog" Height="85.714" Width="285.25" ResizeMode="NoResize" ShowInTaskbar="False" Topmost="True" WindowStartupLocation="CenterOwner" AllowsTransparency="True" WindowStyle="None">
9+
<Grid Background="#FF3F3F3F">
10+
<Grid.RowDefinitions>
11+
<RowDefinition/>
12+
</Grid.RowDefinitions>
13+
<Grid.ColumnDefinitions>
14+
<ColumnDefinition Width="16*"/>
15+
<ColumnDefinition Width="189*"/>
16+
<ColumnDefinition Width="69*"/>
17+
<ColumnDefinition Width="10"/>
18+
</Grid.ColumnDefinitions>
19+
<Rectangle Grid.ColumnSpan="4" Fill="{x:Null}" HorizontalAlignment="Left" Height="86" Stroke="#B7494E" VerticalAlignment="Top" Width="285"/>
20+
<Button Name="yesButton" Style="{StaticResource betterButton}" Content="Yes" Height="30" Margin="19,10,0,0" VerticalAlignment="Top" Width="Auto" BorderBrush="#FF333333" Background="#FF333333" Foreground="#FFDDDDDD" Grid.Column="2" Click="yesClick"/>
21+
<Label x:Name="askDialog" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" HorizontalAlignment="Right" Height="76" Margin="0,12" Width="189" Background="{x:Null}" Foreground="#FFDDDDDD" Grid.Column="1" VerticalAlignment="Center" FontSize="14"/>
22+
<Button Name="noButton" Style="{StaticResource betterButton}" Content="No" Height="Auto" Margin="19,45,0,10" Width="Auto" BorderBrush="#FF333333" Background="#FF333333" Foreground="#FFDDDDDD" Grid.Column="2" Click="noClick"/>
23+
</Grid>
24+
</Window>

nms-mod-manager/AskDialog.xaml.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using System;
2+
using System.IO;
3+
using System.Windows;
4+
5+
namespace nms_mod_manager
6+
{
7+
/// <summary>
8+
/// Logica di interazione per AskBox.xaml
9+
/// </summary>
10+
public partial class AskDialog : Window
11+
{
12+
FileHandler fs = new FileHandler();
13+
Dialog dialog = new Dialog();
14+
15+
string disablemods = AppDomain.CurrentDomain.BaseDirectory + "GAMEDATA\\PCBANKS\\disablemods.txt";
16+
17+
public AskDialog()
18+
{
19+
InitializeComponent();
20+
}
21+
22+
private void noClick(object sender, RoutedEventArgs e)
23+
{
24+
this.Close();
25+
}
26+
27+
public void Dialog(string content)
28+
{
29+
AskDialog askDialog = new AskDialog();
30+
askDialog.askDialog.Content = content;
31+
askDialog.ShowDialog();
32+
}
33+
34+
private void yesClick(object sender, RoutedEventArgs e)
35+
{
36+
File.Delete(disablemods);
37+
this.Close();
38+
}
39+
}
40+
}

nms-mod-manager/Dialog.xaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<Window x:Class="nms_mod_manager.Dialog"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6+
xmlns:local="clr-namespace:nms_mod_manager"
7+
mc:Ignorable="d"
8+
Title="Dialog" Height="60" Width="80" ResizeMode="NoResize" ShowInTaskbar="False" Topmost="True" WindowStartupLocation="CenterOwner" AllowsTransparency="True" WindowStyle="None" SizeToContent="Width">
9+
<Grid Background="#FF3F3F3F">
10+
<Grid.RowDefinitions>
11+
<RowDefinition/>
12+
</Grid.RowDefinitions>
13+
<Grid.ColumnDefinitions>
14+
<ColumnDefinition Width="10"/>
15+
<ColumnDefinition/>
16+
<ColumnDefinition Width="10"/>
17+
<ColumnDefinition Width="50"/>
18+
<ColumnDefinition Width="10"/>
19+
</Grid.ColumnDefinitions>
20+
<Rectangle Grid.ColumnSpan="5" Fill="{x:Null}" Stroke="#B7494E"/>
21+
<Button Style="{StaticResource betterButton}" Content="OK" Height="Auto" Margin="0,15" Width="Auto" BorderBrush="#FF333333" Background="#FF333333" Foreground="#FFDDDDDD" Click="Button_Click" Grid.Column="3"/>
22+
<Label x:Name="labelDialog" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Height="40" Margin="0,10,0,0" Background="{x:Null}" Foreground="#FFDDDDDD" VerticalAlignment="Top" Grid.Column="1"/>
23+
</Grid>
24+
</Window>

nms-mod-manager/Dialog.xaml.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System.Windows;
2+
3+
namespace nms_mod_manager
4+
{
5+
/// <summary>
6+
/// Logica di interazione per Enabled.xaml
7+
/// </summary>
8+
public partial class Dialog : Window
9+
{
10+
public Dialog()
11+
{
12+
InitializeComponent();
13+
}
14+
15+
private void Button_Click(object sender, RoutedEventArgs e)
16+
{
17+
Close();
18+
}
19+
}
20+
}

nms-mod-manager/FileHandler.cs

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using System.Windows;
8+
using System.Windows.Media;
9+
10+
namespace nms_mod_manager
11+
{
12+
class FileHandler
13+
{
14+
string path = AppDomain.CurrentDomain.BaseDirectory;
15+
string disablemods = AppDomain.CurrentDomain.BaseDirectory + "GAMEDATA\\PCBANKS\\disablemods.txt";
16+
17+
/// <summary>
18+
/// Sanity checks exeecuted when starting up or refreshing the application.
19+
/// </summary>
20+
public int FolderCheck()
21+
{
22+
if (Directory.Exists(path + "GAMEDATA\\PCBANKS") == false || Directory.Exists(path + "Binaries") == false)
23+
{
24+
//Game folders not detected
25+
return 0;
26+
}
27+
else
28+
{
29+
//Check if the mods folders exist, if not create them
30+
Directory.CreateDirectory($"{path}GAMEDATA\\PCBANKS\\MODS");
31+
Directory.CreateDirectory($"{path}mods");
32+
33+
//Check if the lock exists
34+
if (File.Exists(path + "GAMEDATA\\PCBANKS\\disablemods.txt"))
35+
{
36+
//Tell the Window to display a dialog
37+
return 2;
38+
}
39+
else
40+
{
41+
// If 'mods' is empty and mods are present in 'GAMEDATA\PCBANKS\MODS\
42+
if (IsDirectoryEmpty($"{path}mods\\") && IsDirectoryEmpty($"{path}GAMEDATA\\PCBANKS\\MODS\\") == false)
43+
{
44+
//Copy the mods files from the game folder to the 'mods' folder
45+
CopyAllFiles();
46+
return 3;
47+
}
48+
else
49+
{
50+
//Tell the Window it's all good
51+
return 1;
52+
}
53+
}
54+
}
55+
}
56+
57+
/// <summary>
58+
/// Copies all the mods from the game folder to the 'mods' folder
59+
/// </summary>
60+
public void CopyAllFiles()
61+
{
62+
DirectoryInfo enableDir = new DirectoryInfo($"{path}GAMEDATA\\PCBANKS\\MODS");
63+
FileInfo[] enableFiles = enableDir.GetFiles("*.pak");
64+
foreach (FileInfo file in enableFiles)
65+
{
66+
if (File.Exists($"{path}mods\\{file.Name}") == false)
67+
{
68+
Console.WriteLine($"{file.FullName} has been copied.");
69+
File.Copy(file.FullName, $"{path}mods\\{file.Name}");
70+
}
71+
}
72+
}
73+
74+
/// <summary>
75+
/// Copies the specified mod inside the game directory.
76+
/// </summary>
77+
/// <param name="name">
78+
/// A string containing the mod's filename.
79+
/// </param>
80+
public void Copy(string name)
81+
{
82+
string modPath = path + "mods\\" + name;
83+
string storePath = path + "GAMEDATA\\PCBANKS\\MODS\\" + name;
84+
if (File.Exists(storePath) == false)
85+
{
86+
File.Copy(modPath, storePath);
87+
}
88+
}
89+
90+
/// <summary>
91+
/// Deletes the specified mod from the game directory.
92+
/// </summary>
93+
/// <param name="name">
94+
/// A string containing the mod's filename.
95+
/// </param>
96+
public void Delete(string name)
97+
{
98+
string storePath = path + "GAMEDATA\\PCBANKS\\MODS\\" + name;
99+
if (File.Exists(storePath = path + "GAMEDATA\\PCBANKS\\MODS\\" + name))
100+
{
101+
File.Delete(storePath);
102+
}
103+
}
104+
105+
/// <summary>
106+
/// Checks if a given directory is empty.
107+
/// </summary>
108+
/// <param name="path">Absolute path to the given directory.</param>
109+
/// <returns></returns>
110+
public bool IsDirectoryEmpty(string path)
111+
{
112+
return !Directory.EnumerateFileSystemEntries(path).Any();
113+
}
114+
}
115+
}

nms-mod-manager/HexConverter.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using System.Windows.Media;
8+
9+
namespace nms_mod_manager
10+
{
11+
class HexConverter
12+
{
13+
public SolidColorBrush Color(string color)
14+
{
15+
SolidColorBrush brush = new SolidColorBrush((Color)ColorConverter.ConvertFromString(color));
16+
return brush;
17+
}
18+
}
19+
}

nms-mod-manager/MainWindow.xaml

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,38 @@
55
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
66
xmlns:local="clr-namespace:nms_mod_manager"
77
mc:Ignorable="d"
8-
Title="MainWindow" Height="450" Width="800">
9-
<Grid>
10-
8+
Title="NMS Mod Manager" Height="546" Width="800" ResizeMode="CanMinimize" Background="#3f3f3f">
9+
<Grid Height="517" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="792">
10+
<Grid.RowDefinitions>
11+
<RowDefinition Height="20"/>
12+
<RowDefinition Height="24"/>
13+
<RowDefinition Height="Auto" MinHeight="24"/>
14+
<RowDefinition Height="Auto" MinHeight="448"/>
15+
</Grid.RowDefinitions>
16+
<Grid.ColumnDefinitions>
17+
<ColumnDefinition Width="20"/>
18+
<ColumnDefinition Width="154*"/>
19+
<ColumnDefinition Width="11*"/>
20+
<ColumnDefinition Width="154*"/>
21+
<ColumnDefinition Width="9*"/>
22+
<ColumnDefinition Width="155*"/>
23+
<ColumnDefinition Width="10*"/>
24+
<ColumnDefinition Width="154*"/>
25+
<ColumnDefinition Width="10*"/>
26+
<ColumnDefinition Width="102*"/>
27+
<ColumnDefinition Width="10*"/>
28+
</Grid.ColumnDefinitions>
29+
<ListView Foreground="#FFA500" x:Name="modList" Grid.Column="1" HorizontalAlignment="Left" Height="185" Grid.Row="3" VerticalAlignment="Top" Width="761" BorderThickness="5" BorderBrush="#FF333333" Background="{x:Null}" Grid.ColumnSpan="9" DragEnter="ModEnter" Drop="ModDrop"/>
30+
<Button Style="{StaticResource betterButton}" Content="Start No Man's Sky" Click="StartNMS" BorderBrush="#FF333333" Background="#FF333333" Foreground="#FFDDDDDD" Grid.Column="1" Grid.Row="1" Margin="0" Height="24" Width="155" VerticalAlignment="Top" HorizontalAlignment="Left"/>
31+
<Button Style="{StaticResource betterButton}" Content="Disable Mods" HorizontalAlignment="Left" Height="24" Grid.Row="1" Width="155" BorderBrush="#FF333333" Background="#FF333333" Foreground="#FFDDDDDD" Margin="0" Click="Disable" Grid.Column="7" VerticalAlignment="Top"/>
32+
<Button Style="{StaticResource betterButton}" Content="Enable Mods" Grid.Column="5" HorizontalAlignment="Left" Height="24" Grid.Row="1" VerticalAlignment="Top" Width="156" BorderBrush="#FF333333" Background="#FF333333" Foreground="#FFDDDDDD" Margin="0" Click="Enable"/>
33+
<Button Style="{StaticResource betterButton}" Content="Refresh" HorizontalAlignment="Left" Height="24" Grid.Row="1" VerticalAlignment="Top" Width="155" BorderBrush="#FF333333" Background="#FF333333" Foreground="#FFDDDDDD" Margin="0" Click="Refresh" Grid.Column="3"/>
34+
<Button Style="{StaticResource betterButton}" Content="Enable" HorizontalAlignment="Left" Height="24" Grid.Row="3" VerticalAlignment="Top" Width="156" BorderBrush="#FF333333" Background="#FF333333" Foreground="#FFDDDDDD" Margin="0,190,0,0" Click="EnableSelected" Grid.Column="5"/>
35+
<Button Style="{StaticResource betterButton}" Content="Disable" Height="24" Grid.Row="3" VerticalAlignment="Top" Width="Auto" BorderBrush="#FF333333" Background="#FF333333" Foreground="#FFDDDDDD" Margin="0,190,0,0" Click="DisableSelected" Grid.Column="7"/>
36+
<Label Content="Status:" Grid.Column="9" Height="24" Grid.Row="1" VerticalAlignment="Top" Foreground="#FFDDDDDD" RenderTransformOrigin="0.5,0.5" VerticalContentAlignment="Center" HorizontalAlignment="Left" Width="47"/>
37+
<Label x:Name="modStatus" Content="" Grid.Column="9" HorizontalAlignment="Left" Height="24" Grid.Row="1" VerticalAlignment="Top" Width="63" Margin="39,0,0,0"/>
38+
<Label Content="Enabled mods" Grid.Column="1" HorizontalAlignment="Left" Height="24" Margin="1,189,0,0" Grid.Row="3" VerticalAlignment="Top" Width="155" Foreground="#FFDDDDDD" Grid.ColumnSpan="2"/>
39+
<Label Content="Available Mods" Grid.Column="1" Grid.Row="2" Foreground="#FFDDDDDD" Height="24" VerticalAlignment="Top"/>
40+
<ListView x:Name="enableList" Grid.Column="1" HorizontalAlignment="Left" Grid.Row="3" Width="763" BorderThickness="5" BorderBrush="#FF333333" Foreground="#FFB7494E" Background="#FF3F3F3F" Margin="0,218,0,10" Grid.ColumnSpan="9"/>
1141
</Grid>
1242
</Window>

0 commit comments

Comments
 (0)