Added Custom Bases.

Noticed injects with Super Mario Bros as base do not work, so i'm going to remove it.

ToDo:
Config feature
Updater
This commit is contained in:
NicoAICP 2020-04-06 19:50:12 +02:00
parent c4f5bb7adc
commit 76464b6bd4
7 changed files with 178 additions and 10 deletions

View file

@ -13,7 +13,19 @@ namespace UWUVCI_AIO_WPF
{
public GameConsoles Console { get; set; }
public GameBases BaseRom { get; set; }
public string CBasePath { get; set; }
private string cBasePath;
public string CBasePath
{
get { return cBasePath; }
set { cBasePath = value;
OnPropertyChanged();
}
}
public string GameName { get; set; }

View file

@ -186,7 +186,29 @@ namespace UWUVCI_AIO_WPF
decrypt.WaitForExit();
}
}
public static string ExtractBase(string path, GameConsoles console)
{
if(!Directory.Exists(Path.Combine(Properties.Settings.Default.BasePath, "CustomBases")))
{
Directory.CreateDirectory(Path.Combine(Properties.Settings.Default.BasePath, "CustomBases"));
}
string outputPath = Path.Combine(Properties.Settings.Default.BasePath, "CustomBases", $"[{console.ToString()}] Custom");
int i = 0;
while (Directory.Exists(outputPath))
{
outputPath = Path.Combine(Properties.Settings.Default.BasePath, $"[{console.ToString()}] Custom_{i}");
i++;
}
using (Process decrypt = new Process())
{
decrypt.StartInfo.FileName = Path.Combine(toolsPath, "Cdecrypt.exe");
decrypt.StartInfo.Arguments = $"{Properties.Settings.Default.Ckey} \"{path}\" \"{outputPath}";
decrypt.Start();
decrypt.WaitForExit();
}
return outputPath;
}
// This function changes TitleID, ProductCode and GameName in app.xml (ID) and meta.xml (ID, ProductCode, Name)
private static void EditXML(string gameName)
{

View file

@ -11,6 +11,7 @@ using System.Windows.Forms;
using UWUVCI_AIO_WPF.Classes;
using UWUVCI_AIO_WPF.Properties;
using UWUVCI_AIO_WPF.UI;
using UWUVCI_AIO_WPF.UI.Frames.InjectFrames.Bases;
using UWUVCI_AIO_WPF.UI.Windows;
namespace UWUVCI_AIO_WPF
@ -200,6 +201,7 @@ namespace UWUVCI_AIO_WPF
}
private MainWindow mw;
private CustomBaseFrame cb = null;
public MainViewModel()
{
@ -215,6 +217,18 @@ namespace UWUVCI_AIO_WPF
GetAllBases();
}
public void resetCBASE()
{
if(cb != null) cb.Reset();
}
public void removeCBASE()
{
cb = null;
}
public void SetCBASE(CustomBaseFrame cbs)
{
cb = cbs;
}
public void setMW(MainWindow mwi)
{
mw = mwi;
@ -235,6 +249,7 @@ namespace UWUVCI_AIO_WPF
RomSet = false;
RomPath = null;
Injected = false;
GameConfiguration.CBasePath = null;
}
public void Inject()
{
@ -711,10 +726,6 @@ namespace UWUVCI_AIO_WPF
{
MessageBox.Show("Images need to either be in a Bit Depth of 32bit or 24bit. \nIf using Tools like paint.net do not choose the Auto function.", "Image Warning", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
public void CBaseWarning()
{
MessageBox.Show("If using Custom Bases there will be a chance that the programm crashes if adding a wrong base (example: a normal wiiu game instead of a nds vc game).\nIf you add a wrong base, we will not assist you fixing it, other than telling you to use another base.", "Custom base Warning", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
public bool CBaseConvertInfo()
{
bool ret = false;
@ -842,6 +853,7 @@ namespace UWUVCI_AIO_WPF
}
return info;
}
public void SetInjectPath()
{

View file

@ -54,11 +54,13 @@ namespace UWUVCI_AIO_WPF.UI.Frames
private void Button_Click_2(object sender, RoutedEventArgs e)
{
mvm.Pack(true);
mvm.resetCBASE();
}
private void Button_Click_3(object sender, RoutedEventArgs e)
{
mvm.Pack(false);
mvm.resetCBASE();
}
}
}

View file

@ -54,6 +54,7 @@ namespace UWUVCI_AIO_WPF.UI.Frames.InjectFrames.Bases
try
{
mvm = FindResource("mvm") as MainViewModel;
mvm.removeCBASE();
if (cbCombo.SelectedIndex != -1 && cbCombo.SelectedIndex != mvm.OldIndex)
{
if (cbCombo.SelectedIndex == 0)

View file

@ -9,8 +9,8 @@
d:DesignHeight="198" d:DesignWidth="383"
Title="CustomBaseFrame">
<Grid>
<TextBox materialDesign:HintAssist.Hint="BASE PATH" Style="{StaticResource MaterialDesignFloatingHintTextBox}" Margin="0,5,108,145" Background="{x:Null}" Foreground="Black" SelectionBrush="#FF00C3D7" CaretBrush="#FF21C3F3" FontSize="18" Text="{Binding GameConfiguration.CBasePath}" IsReadOnly="True" />
<Grid DataContext="{StaticResource mvm}">
<TextBox materialDesign:HintAssist.Hint="BASE PATH" Style="{StaticResource MaterialDesignFloatingHintTextBox}" Margin="0,5,108,145" Background="{x:Null}" Foreground="Black" SelectionBrush="#FF00C3D7" CaretBrush="#FF21C3F3" FontSize="18" Text="{Binding GameConfiguration.CBasePath}" IsReadOnly="True" Focusable="False" />
<Button Content="Set Path" HorizontalAlignment="Left" Margin="280,21,0,0" VerticalAlignment="Top" Width="103" Height="26" Click="Button_Click"/>
<TextBlock x:Name="tbCode" HorizontalAlignment="Center" Margin="10,84,10,0" TextWrapping="Wrap" Text="Code folder not found" VerticalAlignment="Top" TextAlignment="Center" Width="363" FontSize="20" Foreground="DarkRed"/>
<TextBlock x:Name="tbContent" HorizontalAlignment="Center" Margin="10,119,10,0" TextWrapping="Wrap" Text="Content folder not found" VerticalAlignment="Top" TextAlignment="Center" Width="363" FontSize="20" Foreground="DarkRed"/>

View file

@ -15,6 +15,9 @@ using System.Windows.Shapes;
using UWUVCI_AIO_WPF.Classes;
using GameBaseClassLibrary;
using System.Windows.Forms;
using System.IO;
using MessageBox = System.Windows.Forms.MessageBox;
namespace UWUVCI_AIO_WPF.UI.Frames.InjectFrames.Bases
{
@ -30,10 +33,17 @@ namespace UWUVCI_AIO_WPF.UI.Frames.InjectFrames.Bases
public CustomBaseFrame(GameBases Base, GameConsoles console, bool existing)
{
InitializeComponent();
tbCode.Text = "Code Folder not found";
tbCode.Foreground = new SolidColorBrush(Color.FromRgb(205, 50, 50));
tbContent.Text = "Content Folder not found";
tbContent.Foreground = new SolidColorBrush(Color.FromRgb(205, 50, 50));
tbMeta.Text = "Meta Folder not found";
tbMeta.Foreground = new SolidColorBrush(Color.FromRgb(205, 50, 50));
mvm = (MainViewModel)FindResource("mvm");
bases = Base;
this.existing = existing;
this.console = console;
mvm.SetCBASE(this);
}
private void CreateConfig(GameBases Base, GameConsoles console, bool existing)
{
@ -50,10 +60,119 @@ namespace UWUVCI_AIO_WPF.UI.Frames.InjectFrames.Bases
private void Button_Click(object sender, RoutedEventArgs e)
{
tbCode.Text = "Code Folder not found";
tbCode.Foreground = new SolidColorBrush(Color.FromRgb(205, 50, 50));
tbContent.Text = "Content Folder not found";
tbContent.Foreground = new SolidColorBrush(Color.FromRgb(205, 50, 50));
tbMeta.Text = "Meta Folder not found";
tbMeta.Foreground = new SolidColorBrush(Color.FromRgb(205, 50, 50));
mvm.BaseDownloaded = false;
//warning if using custom bases programm may crash
//get folder
//check if WUP or Loadiine
//if yes, enable config and create new game config
DialogResult res = System.Windows.Forms.MessageBox.Show("If using Custom Bases there will be a chance that the programm crashes if adding a wrong base (example: a normal wiiu game instead of a nds vc game).\nIf you add a wrong base, we will not assist you fixing it, other than telling you to use another base.\nIf you agree to this please select Yes", "Custom base Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
if(res == DialogResult.Yes)
{ //get folder
using (var dialog = new System.Windows.Forms.FolderBrowserDialog())
{
System.Windows.Forms.DialogResult result = dialog.ShowDialog();
if (result == DialogResult.OK)
{
try
{
if (mvm.DirectoryIsEmpty(dialog.SelectedPath))
{
System.Windows.Forms.MessageBox.Show("The folder is Empty. Please choose another folder");
}
else
{
if(Directory.GetDirectories(dialog.SelectedPath).Length > 3)
{
MessageBox.Show("This folder has too many subfolders. Please choose another folder");
}
else
{
if(Directory.GetDirectories(dialog.SelectedPath).Length > 0)
{
//Code Content Meta
if (Directory.Exists(System.IO.Path.Combine(dialog.SelectedPath, "content")) && Directory.Exists(System.IO.Path.Combine(dialog.SelectedPath, "code")) && Directory.Exists(System.IO.Path.Combine(dialog.SelectedPath, "meta")))
{
//create new Game Config
mvm.GameConfiguration = new GameConfig();
mvm.GameConfiguration.Console = console;
mvm.GameConfiguration.CBasePath = dialog.SelectedPath;
GameBases gb = new GameBases();
gb.Name = "Custom";
gb.Region = Regions.EU;
gb.Path = mvm.GameConfiguration.CBasePath;
mvm.GameConfiguration.BaseRom = gb;
tbCode.Text = "Code Folder exists";
tbCode.Foreground = new SolidColorBrush(Color.FromRgb(50, 205, 50));
tbContent.Text = "Content Folder exists";
tbContent.Foreground = new SolidColorBrush(Color.FromRgb(50, 205, 50));
tbMeta.Text = "Meta Folder exists";
tbMeta.Foreground = new SolidColorBrush(Color.FromRgb(50, 205, 50));
mvm.BaseDownloaded = true;
}
else
{
MessageBox.Show("This Folder is not in the \"loadiine\" format");
}
}
else
{
//WUP
if (Directory.GetFiles(dialog.SelectedPath, "*.app").Length > 0 && Directory.GetFiles(dialog.SelectedPath, "*.h3").Length > 0 && File.Exists(System.IO.Path.Combine(dialog.SelectedPath, "title.tmd")) && File.Exists(System.IO.Path.Combine(dialog.SelectedPath, "title.tik")))
{
if (mvm.CBaseConvertInfo())
{
//Convert to LOADIINE => save under bases/custom or custom_x path => create new config
string path = Injection.ExtractBase(dialog.SelectedPath, console);
mvm.GameConfiguration = new GameConfig();
mvm.GameConfiguration.Console = console;
mvm.GameConfiguration.CBasePath = path;
GameBases gb = new GameBases();
gb.Name = "Custom";
gb.Region = Regions.EU;
gb.Path = mvm.GameConfiguration.CBasePath;
mvm.GameConfiguration.BaseRom = gb;
tbCode.Text = "Code Folder exists";
tbCode.Foreground = new SolidColorBrush(Color.FromRgb(50, 205, 50));
tbContent.Text = "Content Folder exists";
tbContent.Foreground = new SolidColorBrush(Color.FromRgb(50, 205, 50));
tbMeta.Text = "Meta Folder exists";
tbMeta.Foreground = new SolidColorBrush(Color.FromRgb(50, 205, 50));
mvm.BaseDownloaded = true;
}
}
else
{
MessageBox.Show("This Folder does not contain needed NUS files");
}
}
}
}
}
catch (Exception )
{
}
}
}
}
}
public void Reset()
{
tbCode.Text = "Code Folder not found";
tbCode.Foreground = new SolidColorBrush(Color.FromRgb(205, 50, 50));
tbContent.Text = "Content Folder not found";
tbContent.Foreground = new SolidColorBrush(Color.FromRgb(205, 50, 50));
tbMeta.Text = "Meta Folder not found";
tbMeta.Foreground = new SolidColorBrush(Color.FromRgb(205, 50, 50));
mvm = (MainViewModel)FindResource("mvm");
}
}
}