Skip to content

Commit

Permalink
v6.1 Release
Browse files Browse the repository at this point in the history
  • Loading branch information
IchimakiKasura committed Apr 2, 2022
1 parent fa58ad0 commit d7b3eb8
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 109 deletions.
2 changes: 1 addition & 1 deletion Config.kasu
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ EnablePlaylist: "false"
! "Japanese" - idfk if its accurate
! "Bruh"
!============================================================
Language: "Japanese"
Language: "default"
9 changes: 2 additions & 7 deletions Global.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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" +
Expand Down
4 changes: 2 additions & 2 deletions Launcher DL v6.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Version>6.0.5</Version>
<Version>6.1</Version>
<RootNamespace>Launcher_DL_v6</RootNamespace>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
Expand Down
75 changes: 15 additions & 60 deletions Lib/Console Dev Output/DebugOutput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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";

// }

}
7 changes: 7 additions & 0 deletions Lib/Core/StartUp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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); };
Expand Down Expand Up @@ -66,4 +71,6 @@ private async void Initialize()

}

public Color ClrConv(string color) { return (Color)ColorConverter.ConvertFromString(color); }

}
54 changes: 29 additions & 25 deletions Lib/KasuExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,60 +2,64 @@

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
{
foreach(Match match in LauncherDL_Regex.KasuExtension.Matches(Data))
{
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] <DarkGreen%14>SUCCESS <gray%14>\"Config.kasu\" loaded!");
Expand Down
4 changes: 3 additions & 1 deletion Lib/MainWindow/Windows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Expand Down Expand Up @@ -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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Lib/Regex.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ public static class LauncherDL_Regex
readonly public static Regex SelectedRes = new(@"\[.*\].*(?<name>(?:\D+.*p|audio only)).*-(?<size>.*?);", RegexOptions.Compiled);

// kasu Extension
readonly public static Regex KasuExtension = new("BackgroundName:.*\"(?<BackgroundName>.*)\"|GlowColor:.*\"(?<GlowColor>.*)\"|DefaultFileTypeOnStartUp:.*\"(?<DefaultFileTypeOnStartUp>.*)\"|AlwayDownloadInMP3:.*\"(?<AlwayDownloadInMP3>.*)\"|ShowSystemOutput:.*\"(?<ShowSystemOutput>.*)\"|EnablePlaylist:*.\"(?<EnablePlaylist>.*)\"|Language:.*\"(?<Language>.*)\"|DefaultOutput:.*\"(?<DefaultOutput>.*)\"|BackgroundColor:.*\"(?<BackgroundColor>.*)\"", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Multiline);
readonly public static Regex KasuExtension = new("BackgroundName:.*\"(?<BackgroundName>.*)\"|GlowColor:.*\"(?<GlowColor>.*)\"|DefaultFileTypeOnStartUp:.*\"(?<DefaultFileTypeOnStartUp>.*)\"|AlwayDownloadInMP3:.*\"(?<AlwayDownloadInMP3>.*)\"|ShowSystemOutput:.*\"(?<ShowSystemOutput>.*)\"|EnablePlaylist:.*\"(?<EnablePlaylist>.*)\"|Language:.*\"(?<Language>.*)\"|DefaultOutput:.*\"(?<DefaultOutput>.*)\"|BackgroundColor:.*\"(?<BackgroundColor>.*)\"", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Multiline);

}
1 change: 0 additions & 1 deletion Lib/RichTextBoxHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public static void AddText(this RichTextBox box, string text, string color = def
/// <exception cref="ForegroundPropertyException"/>
/// <exception cref="FontSizePropertyException"/>
/// <exception cref="FontWeightPropertyException"/>

public static void AddFormattedText(this RichTextBox rt, string Input, bool DontAddNewline = false)
{
// resets the Format
Expand Down
11 changes: 0 additions & 11 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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();
}
Expand Down

0 comments on commit d7b3eb8

Please sign in to comment.