From d7b3eb875e56363ac2d8dc94d195074f2f6d443a Mon Sep 17 00:00:00 2001 From: Ichimaki Date: Sat, 2 Apr 2022 22:56:07 +0800 Subject: [PATCH] v6.1 Release Changes: https://github.com/IchimakiKasura/Launcher-DL-3/releases/tag/v6.1 --- Config.kasu | 2 +- Global.cs | 9 +--- Launcher DL v6.csproj | 4 +- Lib/Console Dev Output/DebugOutput.cs | 75 ++++++--------------------- Lib/Core/StartUp.cs | 7 +++ Lib/KasuExtension.cs | 54 ++++++++++--------- Lib/MainWindow/Windows.cs | 4 +- Lib/Regex.cs | 2 +- Lib/RichTextBoxHandler.cs | 1 - MainWindow.xaml.cs | 11 ---- 10 files changed, 60 insertions(+), 109 deletions(-) diff --git a/Config.kasu b/Config.kasu index 1340e4d..164b6c3 100644 --- a/Config.kasu +++ b/Config.kasu @@ -72,4 +72,4 @@ EnablePlaylist: "false" ! "Japanese" - idfk if its accurate ! "Bruh" !============================================================ -Language: "Japanese" \ No newline at end of file +Language: "default" \ No newline at end of file diff --git a/Global.cs b/Global.cs index 80207a6..50fe8b4 100644 --- a/Global.cs +++ b/Global.cs @@ -1,21 +1,16 @@ global using System; global using System.IO; -global using System.Linq; global using System.Text; global using System.Windows; -global using System.Threading; global using System.Diagnostics; -global using System.Windows.Data; global using System.Windows.Input; global using System.Windows.Media; -global using System.Windows.Shapes; global using System.ComponentModel; global using System.Windows.Interop; global using System.Threading.Tasks; global using System.Windows.Controls; global using System.Windows.Threading; global using System.Windows.Documents; -global using System.Windows.Navigation; global using System.Collections.Generic; global using System.Windows.Media.Imaging; global using System.Runtime.InteropServices; @@ -31,11 +26,11 @@ public partial class MainWindow readonly string Version = "Build Version:\nDevelopment Build"; - readonly string HiddenButtonText = "LauncherDL buildver6.0\n\n" + + readonly string HiddenButtonText = "LauncherDL Development Build\n\n" + "OMG this is so E P I C!!\n\n" + "New GUI/Layout, Animations!?!\n\n" + "The OLD Button Hover Animation from ver3 is even back!??\n\n\n" + - "Hotfix Update v6.0.5:\n" + + "Update v6.1:\n" + "Added Few Languages\n" + "Added Customizable Background color\n" + "Fixed font family\n\n" + diff --git a/Launcher DL v6.csproj b/Launcher DL v6.csproj index 89e2940..3a703d3 100644 --- a/Launcher DL v6.csproj +++ b/Launcher DL v6.csproj @@ -1,9 +1,9 @@  - Exe + WinExe net6.0-windows - 6.0.5 + 6.1 Launcher_DL_v6 enable true diff --git a/Lib/Console Dev Output/DebugOutput.cs b/Lib/Console Dev Output/DebugOutput.cs index 08e15c9..a44fd9a 100644 --- a/Lib/Console Dev Output/DebugOutput.cs +++ b/Lib/Console Dev Output/DebugOutput.cs @@ -3,6 +3,8 @@ namespace Launcher_DL_v6; public class DebugOutput { static bool Started = false; + + // Added this because I think it can cause performance issues public static bool IsDebug = false; public static void StartUp() @@ -71,6 +73,7 @@ public static void Button_Clicked(string WhatButton) break; }; } + public static void Button_Output(string WhatButton, dynamic Download = default) { if(!IsDebug) return; @@ -106,66 +109,18 @@ public static void ERROR_Debug(string Text) public static void Selected_Language(string text) { - if(IsDebug)Console.WriteLine($"\x1b[32m[LANGUAGE]\x1b[0m Current Language: {text}"); - } - - public static void Selected_Language_Error(string text) - { - if(IsDebug)Console.WriteLine($"\x1b[31m[LANGUAGE]\x1b[0m Error Can't Recognize \"{text}\", Please Check again."); + if(text == "japanese" || + text == "tagalog" || + text == "english" || + text == "default" || + text == "bruh") + { + if(IsDebug)Console.WriteLine($"\x1b[32m[LANGUAGE]\x1b[0m Current Language: {text}"); + } + else + { + if(IsDebug)Console.WriteLine($"\x1b[31m[LANGUAGE]\x1b[0m Error Can't Recognize \"{text}\", Please Check again."); + } } - // public static async void Test_Debug() - // { - // if(IsDebug)Console.WriteLine($"\x1b[33m[TEST DEBUG]\x1b[0m Started!\n"); - - // MW.Input_Link.Text = "https://www.youtube.com/watch?v=3vSxHROQ4Hs"; - - // // File Format test - // if(IsDebug)Console.WriteLine($"\x1b[33m[TEST DEBUG]\x1b[0m File format test"); - - // // Video only [no sound] - // if(IsDebug)Console.WriteLine($"\x1b[33m[TEST DEBUG]\x1b[0m Video [No sound]"); - // MW.Input_Type.SelectedIndex = 0; - // MW.Input_Format.Text = "313"; - // MW.Input_Name.Text = "Video [No sound]"; - // await Task.Run(delegate {Thread.Sleep(2000);}); - - // // Video only [Type] - // if(IsDebug)Console.WriteLine($"\x1b[33m[TEST DEBUG]\x1b[0m Video [Type]"); - // MW.Input_Type.SelectedIndex = 1; - // MW.Input_Name.Text = "Video [Type]"; - // await Task.Run(delegate {Thread.Sleep(2000);}); - - - // // audio only - // if(IsDebug)Console.WriteLine($"\x1b[33m[TEST DEBUG]\x1b[0m Audio"); - // MW.Input_Type.SelectedIndex = 2; - // MW.Input_MpThreeFormat.IsChecked = false; - // MW.Input_Name.Text = "Audio"; - // await Task.Run(delegate {Thread.Sleep(2000);}); - - - // // audio only [mp3 format] - // if(IsDebug)Console.WriteLine($"\x1b[33m[TEST DEBUG]\x1b[0m Audio [mp3]"); - // MW.Input_Type.SelectedIndex = 2; - // MW.Input_MpThreeFormat.IsChecked = true; - // MW.Input_Name.Text = "Audio [mp3]"; - // await Task.Run(delegate {Thread.Sleep(2000);}); - - - // // video with audio - // if(IsDebug)Console.WriteLine($"\x1b[33m[TEST DEBUG]\x1b[0m Custom"); - // MW.Input_Type.SelectedIndex = 0; - // MW.Input_Format.Text = "137+140"; - // MW.Input_Name.Text = "Custom"; - // await Task.Run(delegate {Thread.Sleep(2000);}); - - - // if(IsDebug)Console.WriteLine($"\x1b[33m[TEST DEBUG]\x1b[0m Ended!\n"); - // MW.Input_Link.Text = string.Empty; - // MW.Input_Name.Text = string.Empty; - // MW.Input_Format.Text = "Best"; - - // } - } \ No newline at end of file diff --git a/Lib/Core/StartUp.cs b/Lib/Core/StartUp.cs index 75e2593..e475228 100644 --- a/Lib/Core/StartUp.cs +++ b/Lib/Core/StartUp.cs @@ -29,6 +29,11 @@ private async void Initialize() Button_Update.Click += Update; Closing += Window_Close; KeyDown += Window_PreviewKeyDown; + + Input_MpThreeFormat.Click += delegate + { + Config.AlwayDownloadInMP3 = Input_MpThreeFormat.IsChecked.Value; + }; #region Open Folder thing Open_Folder.Click += delegate { OpenFolder(Config.DefaultOutput); }; @@ -66,4 +71,6 @@ private async void Initialize() } + public Color ClrConv(string color) { return (Color)ColorConverter.ConvertFromString(color); } + } \ No newline at end of file diff --git a/Lib/KasuExtension.cs b/Lib/KasuExtension.cs index a0507eb..1e364d4 100644 --- a/Lib/KasuExtension.cs +++ b/Lib/KasuExtension.cs @@ -2,24 +2,34 @@ public class LauncherDefaultConfig { - public string BackgroundName { get; set; } = "background.png"; - public string BackgroundColor { get; set; } = "#A31F0000"; - public string GlowColor { get; set; } = "#FFFF8282"; - public string DefaultOutput { get; set; } = "output"; - public string SystemLanguage { get; set; } = "default"; - public int DefaultFileTypeOnStartUp { get; set; } = 0; - public bool AlwayDownloadInMP3 { get; set; } = true; - public bool ShowSystemOutput { get; set; } = true; - public bool EnablePlaylist { get; set; } = false; + public string BackgroundName { get; set; } = "background.png"; + public string BackgroundColor { get; set; } = "#A31F0000"; + public string GlowColor { get; set; } = "#FFFF8282"; + public string DefaultOutput { get; set; } = "output"; + public string SystemLanguage { get; set; } = "default"; + public int DefaultFileTypeOnStartUp { get; set; } = 0; + public bool AlwayDownloadInMP3 { get; set; } = true; + public bool ShowSystemOutput { get; set; } = true; + public bool EnablePlaylist { get; set; } = false; } public partial class MainWindow { + // should've used JSON but damn,I don't want to add System.Text.Json or Newtonsoft.Json private async Task LoadConfig() { - - // should've used JSON but damn,I don't want to add System.Text.Json or Newtonsoft.Json - string Data = await File.ReadAllTextAsync("Config.kasu"); + string Data = string.Empty; + + try + { + Data = await File.ReadAllTextAsync("Config.kasu"); + } + catch + { + MessageBox.Show("Config.kasu is Missing!\nPlease create a Config.kasu to avoid this message","Error",MessageBoxButton.OK,MessageBoxImage.Error); + } + + int TotalDetected = 0; try { @@ -27,35 +37,29 @@ private async Task LoadConfig() { DebugOutput.LoadConfig_Debug(match); if (match.Groups["BackgroundName"].Success) Config.BackgroundName = match.Groups["BackgroundName"].Value.Trim(); - if (match.Groups["GlowColor"].Success) Config.GlowColor = match.Groups["GlowColor"].Value.Trim(); if (match.Groups["BackgroundColor"].Success) Config.BackgroundColor = match.Groups["BackgroundColor"].Value.Trim(); + if (match.Groups["GlowColor"].Success) Config.GlowColor = match.Groups["GlowColor"].Value.Trim(); if (match.Groups["DefaultOutput"].Success) Config.DefaultOutput = match.Groups["DefaultOutput"].Value.Trim(); if (match.Groups["DefaultFileTypeOnStartUp"].Success) Config.DefaultFileTypeOnStartUp = int.Parse(match.Groups["DefaultFileTypeOnStartUp"].Value.Trim()); if (match.Groups["AlwayDownloadInMP3"].Success) Config.AlwayDownloadInMP3 = bool.Parse(match.Groups["AlwayDownloadInMP3"].Value.Trim()); if (match.Groups["ShowSystemOutput"].Success) Config.ShowSystemOutput = bool.Parse(match.Groups["ShowSystemOutput"].Value.Trim()); if (match.Groups["EnablePlaylist"].Success) Config.EnablePlaylist = bool.Parse(match.Groups["EnablePlaylist"].Value.Trim()); if (match.Groups["Language"].Success) Config.SystemLanguage = match.Groups["Language"].Value.Trim(); + + if(match.Success) ++TotalDetected; } if (!File.Exists($"Images/{Config.BackgroundName}")) throw new Exception(); if (Config.DefaultFileTypeOnStartUp >= 3) throw new Exception(); + if (TotalDetected != 9) throw new Exception(); - switch (Config.SystemLanguage.ToLower()) - { - default: DebugOutput.Selected_Language_Error(Config.SystemLanguage); throw new Exception(); - case "japanese": DebugOutput.Selected_Language(Config.SystemLanguage); break; - case "tagalog": DebugOutput.Selected_Language(Config.SystemLanguage);break; - case "english": DebugOutput.Selected_Language(Config.SystemLanguage);break; - case "bruh": DebugOutput.Selected_Language(Config.SystemLanguage);break; - case "customized": DebugOutput.Selected_Language(Config.SystemLanguage);break; - } - + DebugOutput.Selected_Language(Config.SystemLanguage.ToLower()); // Check if BackgroundColor input is valid. - Color BackgroundColor = (Color)ColorConverter.ConvertFromString(Config.BackgroundColor); + Color BackgroundColor = ClrConv(Config.BackgroundColor); Window_BackgroundName.ImageSource = new BitmapImage(new Uri($"Images/{Config.BackgroundName}", UriKind.Relative)); - Window_DropShadow.Color = (Color)ColorConverter.ConvertFromString(Config.GlowColor); + Window_DropShadow.Color = ClrConv(Config.GlowColor); DebugOutput.LoadConfig_Done(false); if (Config.ShowSystemOutput) Output_text.AddFormattedText($"<#a85192%14>[SYSTEM] SUCCESS \"Config.kasu\" loaded!"); diff --git a/Lib/MainWindow/Windows.cs b/Lib/MainWindow/Windows.cs index b9dcb12..5f08ec8 100644 --- a/Lib/MainWindow/Windows.cs +++ b/Lib/MainWindow/Windows.cs @@ -21,7 +21,7 @@ void Focus() Activated += delegate { Opac = new(1, TimeSpan.FromMilliseconds(200)); - Anim = new((Color)ColorConverter.ConvertFromString(Config.BackgroundColor), TimeSpan.FromMilliseconds(200)); + Anim = new(ClrConv(Config.BackgroundColor), TimeSpan.FromMilliseconds(200)); Focus(); DebugOutput.WindowFocusDebug(true); }; @@ -113,6 +113,8 @@ private void Window_Components(bool Disable) Input_Type.IsEnabled = Input_MpThreeFormat.IsEnabled = true; + if(Input_Name.Text == "Unavailable") Input_Name.Text = string.Empty; + if(Input_Type.SelectedIndex == 0) Input_Format.IsEnabled = true; } } diff --git a/Lib/Regex.cs b/Lib/Regex.cs index 44e850a..234a4be 100644 --- a/Lib/Regex.cs +++ b/Lib/Regex.cs @@ -17,6 +17,6 @@ public static class LauncherDL_Regex readonly public static Regex SelectedRes = new(@"\[.*\].*(?(?:\D+.*p|audio only)).*-(?.*?);", RegexOptions.Compiled); // kasu Extension - readonly public static Regex KasuExtension = new("BackgroundName:.*\"(?.*)\"|GlowColor:.*\"(?.*)\"|DefaultFileTypeOnStartUp:.*\"(?.*)\"|AlwayDownloadInMP3:.*\"(?.*)\"|ShowSystemOutput:.*\"(?.*)\"|EnablePlaylist:*.\"(?.*)\"|Language:.*\"(?.*)\"|DefaultOutput:.*\"(?.*)\"|BackgroundColor:.*\"(?.*)\"", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Multiline); + readonly public static Regex KasuExtension = new("BackgroundName:.*\"(?.*)\"|GlowColor:.*\"(?.*)\"|DefaultFileTypeOnStartUp:.*\"(?.*)\"|AlwayDownloadInMP3:.*\"(?.*)\"|ShowSystemOutput:.*\"(?.*)\"|EnablePlaylist:.*\"(?.*)\"|Language:.*\"(?.*)\"|DefaultOutput:.*\"(?.*)\"|BackgroundColor:.*\"(?.*)\"", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Multiline); } \ No newline at end of file diff --git a/Lib/RichTextBoxHandler.cs b/Lib/RichTextBoxHandler.cs index acf90cd..b8a1639 100644 --- a/Lib/RichTextBoxHandler.cs +++ b/Lib/RichTextBoxHandler.cs @@ -33,7 +33,6 @@ public static void AddText(this RichTextBox box, string text, string color = def /// /// /// - public static void AddFormattedText(this RichTextBox rt, string Input, bool DontAddNewline = false) { // resets the Format diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index 488f2a6..db34df6 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -16,12 +16,6 @@ public MainWindow() // For Debug Purposes if(Console.OpenStandardInput(1) != Stream.Null) { - // this.KeyDown += delegate (object s, KeyEventArgs e){ - // if(e.Key == Key.P) - // { - // DebugOutput.Test_Debug(); - // } - // }; DebugOutput.IsDebug = true; DebugOutput.StartUp(); } @@ -39,11 +33,6 @@ public MainWindow() MessageBox.Show(HiddenButtonText, "huzuaah!", MessageBoxButton.OK, MessageBoxImage.Asterisk); }; - Input_MpThreeFormat.Click += delegate - { - Config.AlwayDownloadInMP3 = Input_MpThreeFormat.IsChecked.Value; - }; - InitializeTopButtons(); Initialize(); }