Refactor program structure by adding Archives and Functions classes; introduce Varibles struct for shared state management
This commit is contained in:
@@ -1,63 +1,78 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using System.Net;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace OnlineFixImporter
|
||||||
string gamepath = "";
|
|
||||||
string gamename = "";
|
|
||||||
string gameexe = "";
|
|
||||||
|
|
||||||
Console.WriteLine(args[0]);
|
|
||||||
string userProfilePath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
|
|
||||||
string tarGamePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/games";
|
|
||||||
// Directory.SetCurrentDirectory(Directory.GetParent(fixfile).FullName);
|
|
||||||
|
|
||||||
if (!Directory.Exists(userProfilePath + "/.config/OFME-Linux"))
|
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(userProfilePath + "/.config/OFME-Linux");
|
class Program
|
||||||
}
|
|
||||||
if (!Directory.Exists(userProfilePath + "/.config/OFME-Linux/icons"))
|
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(userProfilePath + "/.config/OFME-Linux/icons");
|
|
||||||
}
|
|
||||||
if (!Directory.Exists(userProfilePath + "/.config/OFME-Linux/banners"))
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(userProfilePath + "/.config/OFME-Linux/banners");
|
|
||||||
}
|
|
||||||
if (!Directory.Exists(tarGamePath))
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(tarGamePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args[0].EndsWith(".exe"))
|
|
||||||
|
|
||||||
|
|
||||||
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
AddToFix(args[0]);
|
Console.WriteLine(Varibles.fileFromArgs);
|
||||||
if (Directory.GetFiles(gamepath, "OnlineFix.ini", SearchOption.AllDirectories).Length == 0)
|
|
||||||
|
Varibles.writeOutAllVar();
|
||||||
|
|
||||||
|
Functions.checkFiles();
|
||||||
|
if (Varibles.fileFromArgs.EndsWith(".exe"))
|
||||||
{
|
{
|
||||||
Notify("This is not a valid OnlineFix game","error");
|
if (Directory.GetFiles(Varibles.gamepath, "OnlineFix.ini", SearchOption.AllDirectories).Length == 0)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"This is not a valid OnlineFix game");
|
||||||
|
Functions.Notify("This is not a valid OnlineFix game", "error");
|
||||||
Environment.Exit(1);
|
Environment.Exit(1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Varibles.gameexe = Varibles.fileFromArgs;
|
||||||
|
Functions.AddToFix(Varibles.gameexe);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (args[0].EndsWith(".rar"))
|
else if (Varibles.fileFromArgs.EndsWith(".rar"))
|
||||||
{
|
{
|
||||||
unrarfix(args[0]);
|
|
||||||
if (!Directory.Exists(Directory.GetCurrentDirectory() + "/Fix Repair"))
|
if (!Directory.Exists(Directory.GetCurrentDirectory() + "/Fix Repair"))
|
||||||
{
|
{
|
||||||
Notify("This is not a valid OnlineFix rar file or Fix Repair folder is missing","error");
|
Console.WriteLine($"This is not a valid OnlineFix rar file or Fix Repair folder is missing");
|
||||||
|
Functions.Notify("This is not a valid OnlineFix rar file or Fix Repair folder is missing", "error");
|
||||||
Environment.Exit(1);
|
Environment.Exit(1);
|
||||||
}
|
}
|
||||||
|
Archives.unrarfix(Varibles.fileFromArgs);
|
||||||
|
Functions.AddToFix(Varibles.gameexe);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Console.WriteLine($"Invalid argument. Please provide a .exe or .rar file.");
|
||||||
Environment.Exit(1);
|
Environment.Exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Directory.SetCurrentDirectory(Directory.GetParent(fixfile).FullName);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// if (args[0] == "create")
|
// if (args[0] == "create")
|
||||||
// {
|
// {
|
||||||
@@ -76,225 +91,14 @@ else
|
|||||||
// AddToFix(args[1]);
|
// AddToFix(args[1]);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
void unrarfix(string fixfile)
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Console.WriteLine($"Current directory: {Directory.GetCurrentDirectory()}");
|
|
||||||
|
|
||||||
string mainfile = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.rar")[0];
|
|
||||||
// string fixfile = Directory.GetFiles(Directory.GetCurrentDirectory() + "/Fix Repair", "*.rar")[0];
|
|
||||||
Console.WriteLine($"Main file: {mainfile}");
|
|
||||||
|
|
||||||
unrar(mainfile, Directory.GetCurrentDirectory() + "/game");
|
|
||||||
|
|
||||||
unrar(fixfile, Directory.GetCurrentDirectory() + "/fix");
|
|
||||||
|
|
||||||
string gamefolder = Directory.GetDirectories(Directory.GetCurrentDirectory() + "/game")[0];
|
|
||||||
|
|
||||||
Console.WriteLine($"Game folder: {gamefolder}");
|
|
||||||
string fixfolder = Directory.GetCurrentDirectory() + "/fix";
|
|
||||||
|
|
||||||
Console.WriteLine($"Fix folder: {fixfolder}");
|
|
||||||
MoveDirectoryOverwrite(fixfolder, gamefolder);
|
|
||||||
|
|
||||||
|
|
||||||
static void MoveDirectoryOverwrite(string sourceDir, string destDir)
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(destDir);
|
|
||||||
|
|
||||||
|
|
||||||
foreach (var file in Directory.GetFiles(sourceDir, "*", SearchOption.AllDirectories))
|
|
||||||
{
|
|
||||||
var target = Path.Combine(destDir, Path.GetRelativePath(sourceDir, file));
|
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(target)!);
|
|
||||||
|
|
||||||
if (File.Exists(target))
|
|
||||||
File.Delete(target);
|
|
||||||
|
|
||||||
File.Move(file, target);
|
|
||||||
}
|
|
||||||
|
|
||||||
Directory.Delete(sourceDir, true);
|
|
||||||
}
|
|
||||||
string dirtomove = Directory.GetDirectories(Directory.GetCurrentDirectory() + "/game")[0];
|
|
||||||
gamename = Path.GetFileName(dirtomove);
|
|
||||||
Console.WriteLine($"Game name: {gamename}");
|
|
||||||
|
|
||||||
|
|
||||||
gamepath = Path.Combine(tarGamePath, gamename);
|
|
||||||
|
|
||||||
foreach (var file in Directory.GetFiles(dirtomove))
|
|
||||||
{
|
|
||||||
Console.WriteLine($"File: {file}");
|
|
||||||
}
|
|
||||||
|
|
||||||
Directory.Move(dirtomove, gamepath);
|
|
||||||
|
|
||||||
// delete old folders and rars
|
|
||||||
Directory.Delete(Directory.GetCurrentDirectory() + "/game", true);
|
|
||||||
Directory.Delete(Directory.GetCurrentDirectory() + "/Fix Repair", true);
|
|
||||||
File.Delete(mainfile);
|
|
||||||
foreach (var file in Directory.GetFiles(gamepath, "*.exe"))
|
|
||||||
{
|
|
||||||
if (!file.Contains("Unity"))
|
|
||||||
{
|
|
||||||
gameexe = file;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
AddToFix(gameexe);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void AddToFix(string gameexe)
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
gamepath = Path.GetFullPath(gameexe).Replace(Path.GetFileName(gameexe), "");
|
|
||||||
gamename = Path.GetFileName(gameexe);
|
|
||||||
string gameid = "";
|
|
||||||
|
|
||||||
|
|
||||||
string fixinit = Directory.GetFiles(gamepath, "OnlineFix.ini", SearchOption.AllDirectories)[0];
|
|
||||||
foreach (var line in File.ReadLines(fixinit))
|
|
||||||
{
|
|
||||||
if (line.Contains("RealAppId"))
|
|
||||||
{
|
|
||||||
gameid = line.Split('=')[1].Trim();
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ExtractIcon(gameexe, $"{userProfilePath}/.config/OFME-Linux/icons/{gameid}ico");
|
|
||||||
|
|
||||||
// Image image = Image.FromFile($"{userProfilePath}/.config/OFME-Linux/icons/{gameid}ico");
|
|
||||||
// using var image = SixLabors.ImageSharp.Image.Load($"{userProfilePath}/.config/OFME-Linux/icons/{gameid}ico");
|
|
||||||
|
|
||||||
var icoPath = $"{userProfilePath}/.config/OFME-Linux/icons/{gameid}ico";
|
|
||||||
var pngPath = $"{userProfilePath}/.config/OFME-Linux/icons/{gameid}";
|
|
||||||
|
|
||||||
var result = System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo
|
|
||||||
{
|
|
||||||
FileName = "icotool",
|
|
||||||
Arguments = $"-x -o {pngPath} {icoPath}", // extracts largest image as png
|
|
||||||
RedirectStandardOutput = true,
|
|
||||||
UseShellExecute = false
|
|
||||||
});
|
|
||||||
result!.WaitForExit();
|
|
||||||
|
|
||||||
string get;
|
|
||||||
using (WebClient client = new WebClient())
|
|
||||||
{
|
|
||||||
get = client.DownloadString($"https://store.steampowered.com/api/appdetails?appids={gameid}");
|
|
||||||
}
|
|
||||||
//File.WriteAllText($"{userProfilePath}/{gameid}.json", get);
|
|
||||||
|
|
||||||
|
|
||||||
dynamic json = JObject.Parse(get);
|
|
||||||
string headerImage = json[gameid.ToString()]["data"]["header_image"];
|
|
||||||
Console.WriteLine(headerImage);
|
|
||||||
|
|
||||||
using (WebClient client = new WebClient())
|
|
||||||
{
|
|
||||||
client.DownloadFile(headerImage, $"{userProfilePath}/.config/OFME-Linux/banners/{gameid}header.png");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// image.SaveAsPng($"{userProfilePath}/.config/OFME-Linux/icons/{gameid}");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
File.Delete($"{userProfilePath}/.config/OFME-Linux/icons/{gameid}ico");
|
|
||||||
|
|
||||||
|
|
||||||
Console.WriteLine($"Fix ini file: {fixinit}");
|
|
||||||
// string gameid = File.ReadAllText(gamepath + "/steam_appid.txt");
|
|
||||||
|
|
||||||
Directory.CreateDirectory($"{userProfilePath}/.local/share/OnlineFix Linux Launcher/prefixes/{gamename.Split('.')[0]}");
|
|
||||||
string prefix = @$"[{gamename.Split('.')[0]}]
|
|
||||||
fakeSteamID=480
|
|
||||||
steamID={gameid}
|
|
||||||
icon={userProfilePath}/.config/OFME-Linux/icons/{gameid}
|
|
||||||
overrides=steam_api64=n;stubdrm64=n;winmm=n,b;onlinefix64=n;steamoverlay64=n
|
|
||||||
executable={gameexe}
|
|
||||||
mainPath={gamepath}
|
|
||||||
prefixPath={userProfilePath}/.local/share/OnlineFix Linux Launcher/prefixes/{gamename.Split('.')[0]}
|
|
||||||
proton=GE-Proton10-34
|
|
||||||
steamRuntime=1
|
|
||||||
steamOverlay=1
|
|
||||||
wined3d=
|
|
||||||
nativeWayland=
|
|
||||||
fixPath=
|
|
||||||
banner={userProfilePath}/.config/OFME-Linux/banners/{gameid}header.png"+"\n\n";
|
|
||||||
|
|
||||||
File.AppendAllText(userProfilePath + "/.config/OFME-Linux/Games.ini", prefix);
|
|
||||||
Notify($"Game {gamename} has been added to OnlineFix Linux Launcher","info");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void unrar(string archivePath, string outputDir)
|
|
||||||
{
|
|
||||||
var sevenZipPath = "7z";
|
|
||||||
// var archivePath = @"C:\temp\archive.rar";
|
|
||||||
// var outputDir = @"\out";
|
|
||||||
var password = "online-fix.me";
|
|
||||||
|
|
||||||
var psi = new ProcessStartInfo
|
|
||||||
{
|
|
||||||
FileName = sevenZipPath,
|
|
||||||
Arguments = $"x \"{archivePath}\" -o\"{outputDir}\" -p\"{password}\" -y",
|
|
||||||
UseShellExecute = false,
|
|
||||||
RedirectStandardOutput = true,
|
|
||||||
RedirectStandardError = true,
|
|
||||||
CreateNoWindow = true
|
|
||||||
};
|
|
||||||
|
|
||||||
using var process = Process.Start(psi);
|
|
||||||
string stdout = process!.StandardOutput.ReadToEnd();
|
|
||||||
string stderr = process.StandardError.ReadToEnd();
|
|
||||||
process.WaitForExit();
|
|
||||||
|
|
||||||
Console.WriteLine(stdout);
|
|
||||||
Console.WriteLine(stderr);
|
|
||||||
Console.WriteLine($"Exit code: {process.ExitCode}");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Notify(string message, string type)
|
|
||||||
{
|
|
||||||
// string type = typeI switch
|
|
||||||
// {
|
|
||||||
// 0 => "info",
|
|
||||||
// 1 => "error",
|
|
||||||
// };
|
|
||||||
Process.Start(new ProcessStartInfo
|
|
||||||
{
|
|
||||||
FileName = "zenity",
|
|
||||||
Arguments = $"--{type} --title=\"Onlinefix importer\" --text=\"{message}\" --no-wrap",
|
|
||||||
UseShellExecute = false
|
|
||||||
})?.WaitForExit();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ExtractIcon(string exePath, string outputPngPath)
|
|
||||||
{
|
|
||||||
var process = Process.Start(new ProcessStartInfo
|
|
||||||
{
|
|
||||||
FileName = "icoextract",
|
|
||||||
Arguments = $"\"{exePath}\" \"{outputPngPath}\"",
|
|
||||||
RedirectStandardOutput = true,
|
|
||||||
UseShellExecute = false
|
|
||||||
});
|
|
||||||
process?.WaitForExit();
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -0,0 +1,88 @@
|
|||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
|
||||||
|
namespace OnlineFixImporter
|
||||||
|
{
|
||||||
|
public class Archives
|
||||||
|
{
|
||||||
|
public static void unrarfix(string fixfile)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Console.WriteLine($"Current directory: {Directory.GetCurrentDirectory()}");
|
||||||
|
|
||||||
|
string mainfile = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.rar")[0];
|
||||||
|
// string fixfile = Directory.GetFiles(Directory.GetCurrentDirectory() + "/Fix Repair", "*.rar")[0];
|
||||||
|
Console.WriteLine($"Main file: {mainfile}");
|
||||||
|
|
||||||
|
unrar(mainfile, Directory.GetCurrentDirectory() + "/game");
|
||||||
|
|
||||||
|
unrar(fixfile, Directory.GetCurrentDirectory() + "/fix");
|
||||||
|
|
||||||
|
string gamefolder = Directory.GetDirectories(Directory.GetCurrentDirectory() + "/game")[0];
|
||||||
|
|
||||||
|
Console.WriteLine($"Game folder: {gamefolder}");
|
||||||
|
string fixfolder = Directory.GetCurrentDirectory() + "/fix";
|
||||||
|
|
||||||
|
Console.WriteLine($"Fix folder: {fixfolder}");
|
||||||
|
Functions.MoveDirectoryOverwrite(fixfolder, gamefolder);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
string dirtomove = Directory.GetDirectories(Directory.GetCurrentDirectory() + "/game")[0];
|
||||||
|
Varibles.gamename = Path.GetFileName(dirtomove);
|
||||||
|
Console.WriteLine($"Game name: {Varibles.gamename}");
|
||||||
|
|
||||||
|
|
||||||
|
Varibles.gamepath = Path.Combine(Varibles.tarGamePath, Varibles.gamename);
|
||||||
|
|
||||||
|
foreach (var file in Directory.GetFiles(dirtomove))
|
||||||
|
{
|
||||||
|
Console.WriteLine($"File: {file}");
|
||||||
|
}
|
||||||
|
|
||||||
|
Directory.Move(dirtomove, Varibles.gamepath);
|
||||||
|
|
||||||
|
// delete old folders and rars
|
||||||
|
Directory.Delete(Directory.GetCurrentDirectory() + "/game", true);
|
||||||
|
Directory.Delete(Directory.GetCurrentDirectory() + "/Fix Repair", true);
|
||||||
|
File.Delete(mainfile);
|
||||||
|
foreach (var file in Directory.GetFiles(Varibles.gamepath, "*.exe"))
|
||||||
|
{
|
||||||
|
if (!file.Contains("Unity"))
|
||||||
|
{
|
||||||
|
Varibles.gameexe = file;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static void unrar(string archivePath, string outputDir)
|
||||||
|
{
|
||||||
|
var sevenZipPath = "7z";
|
||||||
|
// var archivePath = @"C:\temp\archive.rar";
|
||||||
|
// var outputDir = @"\out";
|
||||||
|
var password = "online-fix.me";
|
||||||
|
|
||||||
|
var psi = new ProcessStartInfo
|
||||||
|
{
|
||||||
|
FileName = sevenZipPath,
|
||||||
|
Arguments = $"x \"{archivePath}\" -o\"{outputDir}\" -p\"{password}\" -y",
|
||||||
|
UseShellExecute = false,
|
||||||
|
RedirectStandardOutput = true,
|
||||||
|
RedirectStandardError = true,
|
||||||
|
CreateNoWindow = true
|
||||||
|
};
|
||||||
|
|
||||||
|
using var process = Process.Start(psi);
|
||||||
|
string stdout = process!.StandardOutput.ReadToEnd();
|
||||||
|
string stderr = process.StandardError.ReadToEnd();
|
||||||
|
process.WaitForExit();
|
||||||
|
|
||||||
|
Console.WriteLine(stdout);
|
||||||
|
Console.WriteLine(stderr);
|
||||||
|
Console.WriteLine($"Exit code: {process.ExitCode}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,155 @@
|
|||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
using System.Net;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace OnlineFixImporter
|
||||||
|
{
|
||||||
|
public class Functions
|
||||||
|
{
|
||||||
|
static public void checkFiles()
|
||||||
|
{
|
||||||
|
|
||||||
|
Directory.CreateDirectory(Varibles.userProfilePath + "/.config/OFME-Linux/icons");
|
||||||
|
Directory.CreateDirectory(Varibles.userProfilePath + "/.config/OFME-Linux/banners");
|
||||||
|
Directory.CreateDirectory(Varibles.userProfilePath + "/.local/share/OnlineFix Linux Launcher/prefixes");
|
||||||
|
Directory.CreateDirectory(Varibles.tarGamePath);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
static public void MoveDirectoryOverwrite(string sourceDir, string destDir)
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(destDir);
|
||||||
|
|
||||||
|
|
||||||
|
foreach (var file in Directory.GetFiles(sourceDir, "*", SearchOption.AllDirectories))
|
||||||
|
{
|
||||||
|
var target = Path.Combine(destDir, Path.GetRelativePath(sourceDir, file));
|
||||||
|
Directory.CreateDirectory(Path.GetDirectoryName(target)!);
|
||||||
|
|
||||||
|
if (File.Exists(target))
|
||||||
|
File.Delete(target);
|
||||||
|
|
||||||
|
File.Move(file, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
Directory.Delete(sourceDir, true);
|
||||||
|
}
|
||||||
|
static void ExtractIcon(string exePath, string outputPngPath)
|
||||||
|
{
|
||||||
|
var process = Process.Start(new ProcessStartInfo
|
||||||
|
{
|
||||||
|
FileName = "icoextract",
|
||||||
|
Arguments = $"\"{exePath}\" \"{outputPngPath}\"",
|
||||||
|
RedirectStandardOutput = true,
|
||||||
|
UseShellExecute = false
|
||||||
|
});
|
||||||
|
process?.WaitForExit();
|
||||||
|
}
|
||||||
|
static public void AddToFix(string gameexe)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
Varibles.gamepath = Path.GetFullPath(gameexe).Replace(Path.GetFileName(gameexe), "");
|
||||||
|
Varibles.gamename = Path.GetFileName(gameexe);
|
||||||
|
string gameid = "";
|
||||||
|
|
||||||
|
|
||||||
|
string fixinit = Directory.GetFiles(Varibles.gamepath, "OnlineFix.ini", SearchOption.AllDirectories)[0];
|
||||||
|
foreach (var line in File.ReadLines(fixinit))
|
||||||
|
{
|
||||||
|
if (line.Contains("RealAppId"))
|
||||||
|
{
|
||||||
|
gameid = line.Split('=')[1].Trim();
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ExtractIcon(gameexe, $"{Varibles.userProfilePath}/.config/OFME-Linux/icons/{gameid}ico");
|
||||||
|
|
||||||
|
// Image image = Image.FromFile($"{userProfilePath}/.config/OFME-Linux/icons/{gameid}ico");
|
||||||
|
// using var image = SixLabors.ImageSharp.Image.Load($"{userProfilePath}/.config/OFME-Linux/icons/{gameid}ico");
|
||||||
|
|
||||||
|
var icoPath = $"{Varibles.userProfilePath}/.config/OFME-Linux/icons/{gameid}ico";
|
||||||
|
var pngPath = $"{Varibles.userProfilePath}/.config/OFME-Linux/icons/{gameid}";
|
||||||
|
|
||||||
|
var result = System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo
|
||||||
|
{
|
||||||
|
FileName = "icotool",
|
||||||
|
Arguments = $"-x -o {pngPath} {icoPath}", // extracts largest image as png
|
||||||
|
RedirectStandardOutput = true,
|
||||||
|
UseShellExecute = false
|
||||||
|
});
|
||||||
|
result!.WaitForExit();
|
||||||
|
|
||||||
|
string get;
|
||||||
|
using (WebClient client = new WebClient())
|
||||||
|
{
|
||||||
|
get = client.DownloadString($"https://store.steampowered.com/api/appdetails?appids={gameid}");
|
||||||
|
}
|
||||||
|
//File.WriteAllText($"{userProfilePath}/{gameid}.json", get);
|
||||||
|
|
||||||
|
|
||||||
|
dynamic json = JObject.Parse(get);
|
||||||
|
string headerImage = json[gameid.ToString()]["data"]["header_image"];
|
||||||
|
Console.WriteLine(headerImage);
|
||||||
|
|
||||||
|
|
||||||
|
using (WebClient client = new WebClient())
|
||||||
|
{
|
||||||
|
client.DownloadFile(headerImage, $"{Varibles.userProfilePath}/.config/OFME-Linux/banners/{gameid}header.png");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// image.SaveAsPng($"{userProfilePath}/.config/OFME-Linux/icons/{gameid}");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
File.Delete($"{Varibles.userProfilePath}/.config/OFME-Linux/icons/{gameid}ico");
|
||||||
|
|
||||||
|
|
||||||
|
Console.WriteLine($"Fix ini file: {fixinit}");
|
||||||
|
// string gameid = File.ReadAllText(Varibles.gamepath + "/steam_appid.txt");
|
||||||
|
|
||||||
|
Directory.CreateDirectory($"{Varibles.userProfilePath}/.local/share/OnlineFix Linux Launcher/prefixes/{Varibles.gamename.Split('.')[0]}");
|
||||||
|
string prefix = @$"[{Varibles.gamename.Split('.')[0]}]
|
||||||
|
fakeSteamID=480
|
||||||
|
steamID={gameid}
|
||||||
|
icon={Varibles.userProfilePath}/.config/OFME-Linux/icons/{gameid}
|
||||||
|
overrides=steam_api64=n;stubdrm64=n;winmm=n,b;onlinefix64=n;steamoverlay64=n
|
||||||
|
executable={gameexe}
|
||||||
|
mainPath={Varibles.gamepath}
|
||||||
|
prefixPath={Varibles.userProfilePath}/.local/share/OnlineFix Linux Launcher/prefixes/{Varibles.gamename.Split('.')[0]}
|
||||||
|
proton=GE-Proton10-34
|
||||||
|
steamRuntime=1
|
||||||
|
steamOverlay=1
|
||||||
|
wined3d=
|
||||||
|
nativeWayland=
|
||||||
|
fixPath=
|
||||||
|
banner={Varibles.userProfilePath}/.config/OFME-Linux/banners/{gameid}header.png" + "\n\n";
|
||||||
|
|
||||||
|
File.AppendAllText(Varibles.userProfilePath + "/.config/OFME-Linux/Games.ini", prefix);
|
||||||
|
Notify($"Game {Varibles.gamename} has been added to OnlineFix Linux Launcher", "info");
|
||||||
|
}
|
||||||
|
static public void Notify(string message, string type)
|
||||||
|
{
|
||||||
|
// string type = typeI switch
|
||||||
|
// {
|
||||||
|
// 0 => "info",
|
||||||
|
// 1 => "error",
|
||||||
|
// };
|
||||||
|
Process.Start(new ProcessStartInfo
|
||||||
|
{
|
||||||
|
FileName = "zenity",
|
||||||
|
Arguments = $"--{type} --title=\"Onlinefix importer\" --text=\"{message}\" --no-wrap",
|
||||||
|
UseShellExecute = false
|
||||||
|
})?.WaitForExit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
namespace OnlineFixImporter
|
||||||
|
{
|
||||||
|
|
||||||
|
public struct Varibles
|
||||||
|
{
|
||||||
|
static public string gamepath { get; set; } = "";
|
||||||
|
static public string gamename { get; set; } = "";
|
||||||
|
static public string gameexe { get; set; } = "";
|
||||||
|
static public string[] args { get; } = Environment.GetCommandLineArgs();
|
||||||
|
static public string fileFromArgs { get; set; } = args[1];
|
||||||
|
static public string userProfilePath { get; } = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
|
||||||
|
static public string tarGamePath { get; } = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/games";
|
||||||
|
|
||||||
|
static public void writeOutAllVar()
|
||||||
|
{
|
||||||
|
Console.WriteLine($"gamepath: {gamepath}");
|
||||||
|
Console.WriteLine($"gamename: {gamename}");
|
||||||
|
Console.WriteLine($"gameexe: {gameexe}");
|
||||||
|
Console.WriteLine($"userProfilePath: {userProfilePath}");
|
||||||
|
Console.WriteLine($"tarGamePath: {tarGamePath}");
|
||||||
|
Console.WriteLine($"args: {string.Join(", ", args)}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user