Skip to content

Commit

Permalink
sync
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuuki committed Mar 31, 2024
2 parents 5bf9645 + 328a8af commit 4534da4
Show file tree
Hide file tree
Showing 8 changed files with 124 additions and 38 deletions.
11 changes: 7 additions & 4 deletions Game/Genshin/Settings.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.Win32;
using Newtonsoft.Json;
using System.Text;
using YuukiPS_Launcher.Utils;

namespace YuukiPS_Launcher.Game.Genshin
{
Expand Down Expand Up @@ -72,7 +73,7 @@ public string GetDataGeneralString()

if (keys is null || result is null || result.Length is 0)
{
Console.WriteLine($"Fallback value will be used.");
Logger.Info("Settings", $"Fallback value will be used.");
return "en";
}

Expand All @@ -85,7 +86,7 @@ public int GetVoiceLanguageID()
byte[]? value = GetDataGeneral();
if (value is null || value.Length is 0)
{
Console.WriteLine($"Fallback value will be used (2 / ja-jp).");
Logger.Info("Settings", $"Fallback value will be used (2 / ja-jp).");
return 2;
}
ReadOnlySpan<char> regValue = Encoding.UTF8.GetString(value).AsSpan().Trim('\0');
Expand All @@ -97,7 +98,7 @@ public int GetRegServerNameID()
byte[]? value = GetDataGeneral();
if (value is null || value.Length is 0)
{
Console.WriteLine($"Fallback value will be used (0 / USA).");
Logger.Info("Settings", $"Fallback value will be used (0 / USA).");
return 0;
}
string regValue = new string(Encoding.UTF8.GetString(value).AsSpan().Trim('\0'));
Expand All @@ -112,7 +113,9 @@ public enum ServerRegionID
os_cht = 3,
// YuukiPS
sg1 = 4,
eu1 = 5
eu1 = 5,
// make the warn thing to shut the hell up
dev_docker = 6
}

public class GeneralDataProp
Expand Down
1 change: 1 addition & 0 deletions Json/Profile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class Game
{
public string path = ""; // if blank set auto
public GameType type = GameType.GenshinImpact;
public bool wipeLogin = false;

public Extra extra { get; set; } = new();

Expand Down
18 changes: 16 additions & 2 deletions Main.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

113 changes: 89 additions & 24 deletions Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,72 @@ namespace YuukiPS_Launcher
{
public partial class Main : Form
{
private string randomString()
private void WipeLogin()
{
Random random = new Random();
int rInt = random.Next(0, 4 + 1);
string result = "";
string keyName = "Software\\miHoYo"; // default value to not delete PC system. learned this the hard way!!
string subKeyName = "Genshin Impact";

switch (rInt)
if (GetTypeGame.Text == "GenshinImpact")
{
case 0:
result = "Hey, I'm YuukiPS Launcher, and I'm a logaholic.";
break;
case 1:
result = "u-uhm how do i give myself all items? 🤓";
break;
case 2:
result = "9999: Git analysis?\nGit: Skill issue, sir.";
break;
case 3:
result = ":smiley:";
break;
case 4:
result = "i'm lazy";
break;
keyName = "Software\\miHoYo";
subKeyName = "Genshin Impact";
}
else if (GetTypeGame.Text == "StarRail")
{
keyName = "Software\\Cognosphere";
subKeyName = "Star Rail";
}

using (RegistryKey key = Registry.CurrentUser.OpenSubKey(keyName, true))
{
if (key == null)
{
Logger.Warning("Login", subKeyName + " doesn't exist.");
return;
}
else
{
try
{
key.DeleteSubKeyTree(subKeyName);
}
catch (Exception ex)
{
Logger.Warning("Login", subKeyName + " doesn't exist.");
}
Logger.Info("Login", "Wiped login cache!");
}
}
}

private string randomString()
{
Random rnd = new();

var results = new Dictionary<int, string>
{
{0, "Hey, I'm YuukiPS Launcher, and I'm a logaholic."},
{1, "u-uhm how do i give myself all items? 🤓"},
{2, "9999: Git analysis?\nGit: Skill issue, sir."},
{3, ":smiley:"},
{4, "i'm lazy"},
{5, "makeitmeme.com/join/ATCBQ\n9999: Oh no iplogger ☎️☎️☎️☎️"},
{6, "Error 404: Motivation not found"},
{7, "A programmer's favorite hangout spot? The Foo Bar."},
{8, "I told my computer I needed a break, and it said 'No, you need to update'."},
{9, "What's iwak???"},
{10, "I hate [object Object]"},
{11, "My cat's name :(){:|:&}:; you should type it in your Linux terminal"},
{12, "I can write the code doesn't mean that I can fix your Microwave"},
{13, "0.1 + 0.2; // -> 0.30000000000000004"},
{14, "I've got a really good UDP joke to tell you, but you might not get it..."},
{15, "Proxy Stop...\nJust kidding"},
{16, "rm -rf --no-preserve-root /\nRunning..."}
};

int rInt = rnd.Next(0, results.Count);
string result = results[rInt];

return result;
}

Expand Down Expand Up @@ -235,6 +276,7 @@ public void SaveProfile(string name_save = "Default")
// Game
tmp_profile.game.path = Set_LA_GameFolder.Text;
tmp_profile.game.type = (GameType)GetTypeGame.SelectedItem;
tmp_profile.game.wipeLogin = Enable_WipeLoginCache.Checked;

// Server
tmp_profile.server.url = GetServerHost.Text;
Expand Down Expand Up @@ -401,9 +443,12 @@ public void DoStart()
if (!proxy.Start())
{
MessageBox.Show("Maybe port is already use or Windows Firewall does not allow using port " + set_proxy_port + " or Windows Update sometimes takes that range, or try again it might magically work again.", "Proxy port cannot be used");
try {
try
{
Process.Start(new ProcessStartInfo("cmd", $"/c net stop winnat") { CreateNoWindow = true, UseShellExecute = false });
} catch {
}
catch
{
// skip
}
proxy.Stop();
Expand Down Expand Up @@ -1642,6 +1687,11 @@ private void CheckGameRun_Tick(object sender, EventArgs e)
}
DoneCheck = true;

if (Enable_WipeLoginCache.Checked)
{
WipeLogin();
}

if (Enable_RPC.Checked)
{
discord.UpdateStatus("Not playing", "Stop", "sleep");
Expand Down Expand Up @@ -1764,11 +1814,11 @@ void CheckProxy(bool force_off = false)
if (proxy != null)
{
object? id = registry.GetValue("ProxyServer");
stIsRunProxy.Text = "Status: ON (Internal): "+id;
stIsRunProxy.Text = "Status: ON (Internal): " + id;
}
else
{
stIsRunProxy.Text = "Status: ON (External)";
stIsRunProxy.Text = "Status: ON (External)";
// If external is on and proxy app is enabled, make sure external proxy is off
if (CheckProxyEnable.Checked)
{
Expand Down Expand Up @@ -2051,5 +2101,20 @@ async private void btnstartUpdate_Click(object sender, EventArgs e)
}
}
}

private void wipeLoginCacheInfo_Click(object sender, EventArgs e)
{
MessageBox.Show("This deletes the login cache every time the game closes (logs you out).\nThis is useful if you use the guest account on HSR servers, since you don't have to remember to log out.", "Information.", MessageBoxButtons.OK, MessageBoxIcon.Question);
}

private void Enable_WipeLoginCache_CheckedChanged(object sender, EventArgs e)
{

}

private void checkBox1_CheckedChanged(object sender, EventArgs e)
{

}
}
}
6 changes: 4 additions & 2 deletions Utils/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public void initLogging(string startMsg, string lPath)
strMsg = startMsg;

File.WriteAllText(logPath, strMsg);

Info("Logger", "Initializated logger");
}

public static void Info(string type, string msg)
Expand Down Expand Up @@ -66,7 +68,7 @@ public static void Error(string type, string msg)
Console.ForegroundColor = ConsoleColor.Gray;
Console.Write(msg + "\n");

File.WriteAllText(logPath, $"[${DateTime.Now.ToString("hh:mm:ss")}] [${type}:ERROR] " + msg + "\n");
File.AppendAllText(logPath, $"[${DateTime.Now.ToString("hh:mm:ss")}] [${type}:ERROR] " + msg + "\n");
}
public static void Warning(string type, string msg)
{
Expand All @@ -88,7 +90,7 @@ public static void Warning(string type, string msg)
Console.Write("] ");
Console.ForegroundColor = ConsoleColor.Gray;
Console.Write(msg + "\n");
File.WriteAllText(logPath, $"[${DateTime.Now.ToString("hh:mm:ss")}] [${type}:WARNING] " + msg + "\n");
File.AppendAllText(logPath, $"[${DateTime.Now.ToString("hh:mm:ss")}] [${type}:WARNING] " + msg + "\n");
}
}
}
2 changes: 1 addition & 1 deletion Yuuki/API.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class API
}
else
{
Console.WriteLine("Error GET API: " + response.StatusCode);
Logger.Error("API", "Error GET API: " + response.StatusCode);
}
return null;
}
Expand Down
7 changes: 4 additions & 3 deletions Yuuki/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Diagnostics;
using System.Net;
using YuukiPS_Launcher.Json;
using YuukiPS_Launcher.Utils;

namespace YuukiPS_Launcher.Yuuki
{
Expand All @@ -25,10 +26,10 @@ public static string DLJava()
{
if (!Directory.Exists(JAVA_FOLDER))
{
Console.WriteLine("No Java Folder Found so Create a new folder");
Logger.Info("Server", "No Java Folder Found so Create a new folder");
Directory.CreateDirectory(JAVA_FOLDER);
}
Console.WriteLine("Check Version JAVA");
Logger.Info("Settings", "Check Version JAVA");
var Javabin = Path.Combine(JAVA_FOLDER, "bin");
if (CheckJava(Javabin))
{
Expand Down Expand Up @@ -87,7 +88,7 @@ public static string DLJava()
{
Microsoft.VisualBasic.FileIO.FileSystem.MoveDirectory(java_folder_version, JAVA_FOLDER, true);
//Tool.ExecuteCMD($"Move {java_folder_version}\\*.* {JAVA_FOLDER}");
Console.WriteLine("done...");
Logger.Info("Server", "done...");
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions YuukiPS Launcher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

<ApplicationManifest>Properties\app.manifest</ApplicationManifest>

<AssemblyVersion>2024.3.31.2113</AssemblyVersion>
<FileVersion>2024.3.31.2113</FileVersion>
<AssemblyVersion>2024.3.31.2132</AssemblyVersion>
<FileVersion>2024.3.31.2132</FileVersion>

<EnableWindowsTargeting>true</EnableWindowsTargeting>
<AssemblyName>YuukiPS</AssemblyName>
Expand Down

0 comments on commit 4534da4

Please sign in to comment.