Skip to content

Commit

Permalink
Project updated to Beta 1.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashley Davies authored and Ashley Davies committed May 26, 2020
1 parent 3a96562 commit d555866
Show file tree
Hide file tree
Showing 45 changed files with 7,236 additions and 1,492 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Beta 1.4.2
- Added support for installing game saves
- Added support for installing files to both console USB ports
- Added automatic uninstall when installing mods to same game
- Added save/edit game regions option to settings
- Added more information window to help menu
- Added mod requests form window
- Fixed uninstalling mods when installing to same game
- Fixed updating scrollbars when using mouse wheel
- Settings file is now saved to Documents folder
- Cleaned and documented most of the code
- Other additional minor improvements

## Beta 1.4.1
A small update to support installing mods to account resources, allowing the user to choose their specified userId when prompted.

Expand Down
78 changes: 78 additions & 0 deletions src/ModioX/AppUpdate/AppUpdate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
using DarkUI.Forms;
using ModioX.Extensions;
using ModioX.Forms;
using ModioX.Windows;
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Windows.Forms;

namespace ModioX.AppUpdate
{
internal static class AppUpdate
{
/// <summary>
///
/// </summary>
public static Version CurrentVersion { get; } = Assembly.GetExecutingAssembly().GetName().Version;

/// <summary>
/// Checks the current application version against the version hosted via dropbox text file.
/// </summary>
public static void CheckApplicationVersion()
{
try
{
MainForm.mainForm.SetStatus($"Checking for a new update...");
Program.Log.Info("Checking for a new update...");

using (StreamReader streamReader = new StreamReader(HttpExtensions.GetStream(Utilities.ProjectVersionUrl)))
{
Version newVersion = new Version(streamReader.ReadToEnd());

if (CurrentVersion.CompareTo(newVersion) < 0)
{
RunInstaller(newVersion);
}
else
{
MainForm.mainForm.SetStatus($"ModioX is running latest available update (Beta v{newVersion.ToString().Remove(0, 2)})");
Program.Log.InfoFormat($"ModioX is running latest available update (Beta v{newVersion.ToString().Remove(0, 2)})");
}
}
}
catch (Exception ex)
{
MainForm.mainForm.SetStatus($"Failed to update. Message : {ex.Message}");
Program.Log.Info("Failed to update. Message : {ex.Message}", ex);
Application.Exit();
}
}

/// <summary>
/// Downloads the new version installer from GitHub releases to the users downloads folder, closes the application and runs the installer
/// </summary>
/// <param name="newVersion">Newest update version</param>
private static void RunInstaller(Version newVersion)
{
try
{
MainForm.mainForm.SetStatus("New update available - Starting to download the installed...");
Program.Log.Info("New update available - Starting to download the installer...");
DarkMessageBox.Show(MainForm.mainForm, $@"This version of ModioX is now outdated. An update (v{newVersion}) has been released on GitHub. Click OK to download and run the installer.", @"Update Available", MessageBoxIcon.Information);
Program.WebClient.DownloadFile($"{Utilities.ProjectRepoUrl}releases/download/{newVersion}/ModioX.Installer.Windows.exe", $@"{KnownFolders.GetPath(KnownFolder.Downloads)}\ModioX.Installer.Windows.exe");
Process.Start($@"{KnownFolders.GetPath(KnownFolder.Downloads)}\ModioX.Installer.Windows.exe");
Application.Exit();
}
catch (Exception ex)
{
MainForm.mainForm.SetStatus($"There was a problem starting the update installer : {ex.Message})");
Program.Log.Error($"There was a problem starting the update installer : {ex.Message}", ex);
DarkMessageBox.Show(MainForm.mainForm, @"There was an issue. You will need to manually install the latest available update from the GitHub releases page.", "Error", MessageBoxIcon.Error);
Process.Start($"{Utilities.ProjectRepoUrl}releases/latest");
Application.Exit();
}
}
}
}
14 changes: 7 additions & 7 deletions src/ModioX/Extensions/FtpConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ public string ReadFile(string directory)
try
{
byte[] newFileData = request.DownloadData(url);
fileString = System.Text.Encoding.UTF8.GetString(newFileData);
fileString = Encoding.UTF8.GetString(newFileData);
}
catch
{
Expand Down Expand Up @@ -630,7 +630,7 @@ public class FtpDirectoryInfo : FileSystemInfo
public FtpDirectoryInfo(FtpConnection ftp, string path)
{
this._ftp = ftp;
base.FullPath = path;
FullPath = path;
}

public override void Delete()
Expand All @@ -647,12 +647,12 @@ public override void Delete()

public FtpDirectoryInfo[] GetDirectories()
{
return this.FtpConnection.GetDirectories(base.FullPath);
return this.FtpConnection.GetDirectories(FullPath);
}

public FtpDirectoryInfo[] GetDirectories(string path)
{
path = Path.Combine(base.FullPath, path);
path = Path.Combine(FullPath, path);
return this.FtpConnection.GetDirectories(path);
}

Expand Down Expand Up @@ -765,7 +765,7 @@ public DateTime? LastWriteTimeUtc

public override string Name
{
get { return Path.GetFileName(base.FullPath); }
get { return Path.GetFileName(FullPath); }
}
}

Expand All @@ -786,8 +786,8 @@ public FtpFileInfo(FtpConnection ftp, string filePath)
throw new ArgumentNullException("fileName");
}

base.OriginalPath = filePath;
base.FullPath = filePath;
OriginalPath = filePath;
FullPath = filePath;
this._filePath = filePath;
this._ftp = ftp;
this._name = Path.GetFileName(filePath);
Expand Down
73 changes: 68 additions & 5 deletions src/ModioX/Extensions/FtpExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using System.Collections.Generic;
using DarkUI.Forms;
using ModioX.Forms;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;

namespace ModioX.Extensions
{
Expand Down Expand Up @@ -116,17 +119,32 @@ internal static bool FileExists(string hostAddress, string consoleFile)
/// Downloads the specified console file to the computer
/// </summary>
/// <param name="hostAddress">PS3 IP address</param>
/// <param name="folderPath">Path of the uploading file directory</param>
internal static List<string> GetFolderNames(string hostAddress, string folderPath)
/// <param name="consolePath">Path of the uploading file directory</param>
internal static bool DirectoryExists(string hostAddress, string consolePath)
{
using (FtpConnection ftpConnection = new FtpConnection(hostAddress))
{
ftpConnection.Open();

return ftpConnection.DirectoryExists(consolePath);
}
}

/// <summary>
/// Downloads the specified console file to the computer
/// </summary>
/// <param name="hostAddress">PS3 IP address</param>
/// <param name="consolePath">Path of the uploading file directory</param>
internal static List<string> GetFolderNames(string hostAddress, string consolePath)
{
using (FtpConnection ftpConnection = new FtpConnection(hostAddress))
{
List<string> folderNames = new List<string>();

ftpConnection.Open();

string dirPath = folderPath.Contains("/")
? folderPath.Substring(0, folderPath.LastIndexOf('/')) + '/'
string dirPath = consolePath.Contains("/")
? consolePath.Substring(0, consolePath.LastIndexOf('/')) + '/'
: "/dev_hdd0/";

ftpConnection.SetCurrentDirectory(dirPath);
Expand All @@ -141,5 +159,50 @@ internal static List<string> GetFolderNames(string hostAddress, string folderPat
return folderNames;
}
}

/// <summary>
/// Prompts the user with their account id's and returns the specified userId
/// </summary>
/// <param name="hostAddress">Console IP Address</param>
/// <returns></returns>
public static string GetUserId(string hostAddress)
{
List<string> userIds = GetFolderNames(hostAddress, "/dev_hdd0/home/");

if (userIds.Count < 1)
{
_ = DarkMessageBox.Show(MainForm.mainForm, "Could not find any userId's on your console. Make sure you have created at least one user profile.", "No Users Found", MessageBoxIcon.Error);
return null;
}
else
{
return Utilities.GetItemFromList("Profile IDs", userIds);
}
}

/// <summary>
/// Prompts the user with their account id's and returns the specified userId
/// </summary>
/// <param name="hostAddress">Console IP Address</param>
/// <returns></returns>
internal static string GetPathForUSB(string hostAddress)
{
string[] usbPaths = new string[]
{
"/dev_usb000/",
"/dev_usb001/"
};

foreach (string usbPath in usbPaths)
{
if (DirectoryExists(hostAddress, usbPath))
{
return usbPath;
}
}

_ = DarkMessageBox.Show(MainForm.mainForm, "No USB devices are connected to your console. Make sure there is at least one device connected for installing mods.", "No USB Device", MessageBoxIcon.Error);
return null;
}
}
}
9 changes: 7 additions & 2 deletions src/ModioX/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
namespace ModioX.Extensions
using System.IO;

namespace ModioX.Extensions
{
internal static class StringExtensions
{

public static string ReplaceInvalidChars(string filename)
{
return string.Join("_", filename.Split(Path.GetInvalidFileNameChars()));
}
}
}
88 changes: 65 additions & 23 deletions src/ModioX/Extensions/Utilities.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using ModioX.Models.Database;
using ModioX.Forms;
using ModioX.Models.Database;
using ModioX.Windows;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
Expand Down Expand Up @@ -96,8 +99,23 @@ internal static CategoriesData GetCategoriesData()
}

/// <summary>
/// Depth-first recursive delete, with handling for descendant
/// directories open in Windows Explorer.
///
/// </summary>
/// <param name="title"></param>
/// <param name="items"></param>
/// <returns></returns>
public static string GetItemFromList(string title, List<string> items)
{
using (ListItemPicker listViewDialog = new ListItemPicker() { Text = title, Items = items })
{
listViewDialog.ShowDialog();
return listViewDialog.SelectedItem;
}
}

/// <summary>
/// Depth-first recursive delete, with handling for descendant
/// directories open in Windows Explorer.
/// </summary>
internal static void DeleteDirectory(string path)
{
Expand Down Expand Up @@ -126,33 +144,57 @@ internal static void DeleteDirectory(string path)
/// <param name="modItem">Mod info to fill with</param>
internal static void OpenReportTemplate(ModsData.ModItem modItem)
{
Process.Start($"{ProjectRepoUrl}issues/new?" +
$"title=[Report] {modItem.Name} ({modItem.Type}) ({modItem.GameId.ToUpper()})" +
$"&labels=report-mod&" +
$"body=Id: {modItem.Id}%0A" +
$"Author: {modItem.Author}%0A" +
$"Version: {modItem.Version}%0A" +
$"Configuration: {modItem.Configuration}%0A" +
$"Files: {string.Join(" | ", modItem.InstallPaths)}%0A" +
"----------------------- %0A" +
"*Please include some additional information about the issue you are experiencing, such as how to reproduce the problem, what happened before this occurred, etc...");
_ = Process.Start($"{ProjectRepoUrl}issues/new?"
+ $"title={modItem.Name} ({modItem.Type}) ({modItem.GameId.ToUpper()})"
+ $"&labels=mod report&"
+ $"body=- Mod Name: {modItem.Name}%0A"
+ $"- Mod Id: {modItem.Id}%0A"
+ $"- Mod Type: {modItem.Type}%0A"
+ $"- Category: {MainForm.Categories.GetCategoryById(modItem.GameId).Title}%0A"
+ $"- Author: {modItem.Author}%0A"
+ $"- Version: {modItem.Version}%0A"
+ "----------------------- %0A"
+ "*Please include additional information about the issue, details such as how to reproduce the problem, what happened before this occurred, etc...");
}

/// <summary>
/// Open a new issue template for requesting mods
/// </summary>
internal static void OpenRequestTemplate()
{
Process.Start($"{ProjectRepoUrl}issues/new?" +
$"title=[Request] Mod Name (SPRX/EBOOT/etc.)" +
$"&labels=request-mod&" +
$"body=Enter some information about the mods you'd like to be added, as well as any links you can find that showcase the mods.%0A" +
$"Author: Creator / Developer%0A" +
$"Version: Version%0A" +
$"Configuration: Singleplayer / Multiplayer / Zombies%0A" +
$"Files: Download Link%0A" +
"----------------------- %0A" +
"*Please include any other additional information you can find on the mods.");
_ = Process.Start($"{ProjectRepoUrl}issues/new?"
+ $"title=Mod Name (SPRX/EBOOT/etc.)"
+ $"&labels=mod request&"
+ $"body=Please provide as much information you can find about the mods, also any links you can find showcasing the mods will help to find more details.%0A"
+ $"- Author: Creator/Developer%0A"
+ $"- Version: Version%0A"
+ $"- Game Type: Singleplayer/Multiplayer/Zombies%0A"
+ $"- Files: Download Link%0A"
+ "----------------------- %0A"
+ "*Here you can include any other additional information we may need.");
}

/// <summary>
/// Open a new issue template for requesting mods
/// </summary>
internal static void OpenRequestTemplate(string name, string type, string categoryTitle, string author, string version, string description, string links)
{
string requestTemplate = $"{ProjectRepoUrl}issues/new?"
+ $"title=[Request Mod] {name} ({type})&"
+ $"labels=mod request&"
+ $"assignee=ohhsodead&"
+ $"body=Please provide as much information you can find about the mods, also any links you can find showcasing the mods will help to find more details.%0A"
+ $"- Name: {name}%0A"
+ $"- Type: {type}%0A"
+ $"- Category: {categoryTitle}%0A"
+ $"- Author: {author}%0A"
+ $"- Version: {version}%0A"
+ $"- Description: {description}%0A"
+ $"- Links: {links}%0A"
+ "----------------------- %0A"
+ "*You could include any other additional information we may need here.";

_ = Process.Start(requestTemplate);
}

public static void AddFilesToZip(string zipPath, string[] files)
Expand Down
Loading

0 comments on commit d555866

Please sign in to comment.