2020-04-28 23:40:54 +00:00
|
|
|
|
using GameBaseClassLibrary;
|
|
|
|
|
using System;
|
2020-04-19 22:53:34 +00:00
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Net;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Media.Imaging;
|
2020-04-20 09:31:26 +00:00
|
|
|
|
using UWUVCI_AIO_WPF.UI.Frames.InjectFrames.Configurations;
|
2020-10-02 00:38:48 +00:00
|
|
|
|
using Path = System.IO.Path;
|
2022-02-10 22:51:09 +00:00
|
|
|
|
using Rectangle = System.Drawing.Rectangle;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using PixelFormat = System.Windows.Media.PixelFormat;
|
|
|
|
|
using Pfim;
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using Image = System.Windows.Controls.Image;
|
2020-04-19 22:53:34 +00:00
|
|
|
|
|
|
|
|
|
namespace UWUVCI_AIO_WPF.UI.Windows
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Interaktionslogik für IMG_Message.xaml
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class IMG_Message : Window
|
|
|
|
|
{
|
|
|
|
|
string ic = "";
|
|
|
|
|
string tvs = "";
|
2020-04-28 23:40:54 +00:00
|
|
|
|
string repoid = "";
|
|
|
|
|
string icback = "";
|
|
|
|
|
string tvback = "";
|
2022-02-10 22:51:09 +00:00
|
|
|
|
private static List<GCHandle> handles = new List<GCHandle>();
|
2020-04-28 23:40:54 +00:00
|
|
|
|
public IMG_Message(string icon, string tv, string repoid)
|
2020-04-19 22:53:34 +00:00
|
|
|
|
{
|
2020-04-30 15:01:41 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
2020-05-04 16:20:21 +00:00
|
|
|
|
if(this.Owner != null)
|
|
|
|
|
{
|
2020-09-30 15:32:34 +00:00
|
|
|
|
if (this.Owner?.GetType() != typeof(MainWindow))
|
2020-05-04 16:20:21 +00:00
|
|
|
|
{
|
|
|
|
|
this.WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2020-05-06 21:53:52 +00:00
|
|
|
|
|
2020-05-04 16:20:21 +00:00
|
|
|
|
|
2020-04-30 15:01:41 +00:00
|
|
|
|
}
|
2020-06-11 08:12:03 +00:00
|
|
|
|
catch (Exception )
|
2020-04-30 15:01:41 +00:00
|
|
|
|
{
|
|
|
|
|
this.WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
InitializeComponent();
|
2020-04-28 23:40:54 +00:00
|
|
|
|
|
2020-04-19 22:53:34 +00:00
|
|
|
|
ic = icon;
|
|
|
|
|
tvs = tv;
|
2020-04-28 23:40:54 +00:00
|
|
|
|
if (ic.Contains("tga")){
|
|
|
|
|
icb.Visibility = Visibility.Hidden;
|
|
|
|
|
icl.Visibility = Visibility.Hidden;
|
|
|
|
|
//tgic.Visibility = Visibility.Visible;
|
|
|
|
|
}
|
|
|
|
|
if (tvs.Contains("tga"))
|
|
|
|
|
{
|
|
|
|
|
tvb.Visibility = Visibility.Hidden;
|
|
|
|
|
tvl.Visibility = Visibility.Hidden;
|
|
|
|
|
tgtv.Visibility = Visibility.Visible;
|
|
|
|
|
}
|
2022-02-10 22:51:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.icon.Source = GetRepoImages(icon);
|
|
|
|
|
this.tv.Source = GetRepoImages(tv);
|
|
|
|
|
this.repoid = repoid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private BitmapImage GetRepoImages(string imageURL)
|
|
|
|
|
{
|
2020-04-28 23:40:54 +00:00
|
|
|
|
BitmapImage bitmap = new BitmapImage();
|
2022-02-10 22:51:09 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var webRequest = (HttpWebRequest)WebRequest.Create(new Uri(imageURL, UriKind.Absolute));
|
|
|
|
|
webRequest.AllowWriteStreamBuffering = true;
|
|
|
|
|
webRequest.Timeout = 30000;
|
|
|
|
|
|
|
|
|
|
var webReponse = webRequest.GetResponse();
|
|
|
|
|
var stream = webReponse.GetResponseStream();
|
|
|
|
|
|
|
|
|
|
if (!imageURL.EndsWith(".tga"))
|
|
|
|
|
{
|
|
|
|
|
var image = System.Drawing.Image.FromStream(stream);
|
|
|
|
|
|
|
|
|
|
using (var graphics = Graphics.FromImage(image))
|
|
|
|
|
{
|
|
|
|
|
graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
|
|
|
|
|
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
|
|
|
|
|
graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
|
|
|
|
|
graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
|
|
|
|
|
graphics.DrawImage(image, new Rectangle(0, 0, image.Width, image.Height), new Rectangle(0, 0, image.Width, image.Height), GraphicsUnit.Pixel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
using (var memory = new MemoryStream())
|
|
|
|
|
{
|
|
|
|
|
image.Save(memory, System.Drawing.Imaging.ImageFormat.Png);
|
|
|
|
|
memory.Position = 0;
|
|
|
|
|
|
|
|
|
|
bitmap.BeginInit();
|
|
|
|
|
bitmap.StreamSource = memory;
|
|
|
|
|
bitmap.CacheOption = BitmapCacheOption.OnLoad;
|
|
|
|
|
bitmap.EndInit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2022-03-09 07:50:52 +00:00
|
|
|
|
//This code doesn't work
|
|
|
|
|
/*
|
2022-02-10 22:51:09 +00:00
|
|
|
|
var image = Pfim.Pfim.FromStream(stream);
|
|
|
|
|
foreach (var im in WpfImage(image))
|
|
|
|
|
{
|
|
|
|
|
var encoder = new PngBitmapEncoder();
|
|
|
|
|
using (var memory = new MemoryStream())
|
|
|
|
|
{
|
|
|
|
|
BitmapSource bitmapSource = (BitmapSource)im.Source;
|
|
|
|
|
encoder.Frames.Add(BitmapFrame.Create(bitmapSource));
|
|
|
|
|
encoder.Save(memory);
|
|
|
|
|
memory.Position = 0;
|
|
|
|
|
|
|
|
|
|
bitmap.BeginInit();
|
|
|
|
|
bitmap.StreamSource = memory;
|
|
|
|
|
bitmap.CacheOption = BitmapCacheOption.OnLoad;
|
|
|
|
|
bitmap.EndInit();
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-03-09 07:50:52 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
//using old method for .tga
|
|
|
|
|
bitmap.BeginInit();
|
|
|
|
|
bitmap.UriSource = new Uri(imageURL, UriKind.Absolute);
|
|
|
|
|
bitmap.EndInit();
|
2022-02-10 22:51:09 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
//something broke, so yolo we go with the old method!
|
2020-04-19 22:53:34 +00:00
|
|
|
|
bitmap.BeginInit();
|
2022-02-10 22:51:09 +00:00
|
|
|
|
bitmap.UriSource = new Uri(imageURL, UriKind.Absolute);
|
2020-04-19 22:53:34 +00:00
|
|
|
|
bitmap.EndInit();
|
2022-02-10 22:51:09 +00:00
|
|
|
|
}
|
|
|
|
|
return bitmap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static PixelFormat PixelFormat(IImage image)
|
|
|
|
|
{
|
|
|
|
|
switch (image.Format)
|
|
|
|
|
{
|
|
|
|
|
case ImageFormat.Rgb24:
|
|
|
|
|
return PixelFormats.Bgr24;
|
|
|
|
|
case ImageFormat.Rgba32:
|
|
|
|
|
return PixelFormats.Bgra32;
|
|
|
|
|
case ImageFormat.Rgb8:
|
|
|
|
|
return PixelFormats.Gray8;
|
|
|
|
|
case ImageFormat.R5g5b5a1:
|
|
|
|
|
case ImageFormat.R5g5b5:
|
|
|
|
|
return PixelFormats.Bgr555;
|
|
|
|
|
case ImageFormat.R5g6b5:
|
|
|
|
|
return PixelFormats.Bgr565;
|
|
|
|
|
default:
|
|
|
|
|
throw new Exception($"Unable to convert {image.Format} to WPF PixelFormat");
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-04-19 22:53:34 +00:00
|
|
|
|
|
2022-02-10 22:51:09 +00:00
|
|
|
|
private static IEnumerable<Image> WpfImage(IImage image)
|
|
|
|
|
{
|
|
|
|
|
var pinnedArray = GCHandle.Alloc(image.Data, GCHandleType.Pinned);
|
|
|
|
|
var addr = pinnedArray.AddrOfPinnedObject();
|
|
|
|
|
var bsource = BitmapSource.Create(image.Width, image.Height, 96.0, 96.0,
|
|
|
|
|
PixelFormat(image), null, addr, image.DataLen, image.Stride);
|
2020-04-19 22:53:34 +00:00
|
|
|
|
|
2022-02-10 22:51:09 +00:00
|
|
|
|
handles.Add(pinnedArray);
|
|
|
|
|
yield return new Image
|
|
|
|
|
{
|
|
|
|
|
Source = bsource,
|
|
|
|
|
Width = image.Width,
|
|
|
|
|
Height = image.Height,
|
|
|
|
|
MaxHeight = image.Height,
|
|
|
|
|
MaxWidth = image.Width,
|
|
|
|
|
Margin = new Thickness(4),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
foreach (var mip in image.MipMaps)
|
|
|
|
|
{
|
|
|
|
|
var mipAddr = addr + mip.DataOffset;
|
|
|
|
|
var mipSource = BitmapSource.Create(mip.Width, mip.Height, 96.0, 96.0,
|
|
|
|
|
PixelFormat(image), null, mipAddr, mip.DataLen, mip.Stride);
|
|
|
|
|
yield return new Image
|
|
|
|
|
{
|
|
|
|
|
Source = mipSource,
|
|
|
|
|
Width = mip.Width,
|
|
|
|
|
Height = mip.Height,
|
|
|
|
|
MaxHeight = mip.Height,
|
|
|
|
|
MaxWidth = mip.Width,
|
|
|
|
|
Margin = new Thickness(4)
|
|
|
|
|
};
|
|
|
|
|
}
|
2020-04-19 22:53:34 +00:00
|
|
|
|
}
|
2022-02-10 22:51:09 +00:00
|
|
|
|
|
2020-04-19 22:53:34 +00:00
|
|
|
|
private void Button_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Canc_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.Close();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Yes_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
MainViewModel mvm = FindResource("mvm") as MainViewModel;
|
|
|
|
|
var client = new WebClient();
|
2020-10-02 00:38:48 +00:00
|
|
|
|
if (Directory.Exists(Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo")))
|
2020-04-19 22:53:34 +00:00
|
|
|
|
{
|
2020-10-02 00:38:48 +00:00
|
|
|
|
Directory.Delete(Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo"), true);
|
2020-04-19 22:53:34 +00:00
|
|
|
|
}
|
2020-10-02 00:38:48 +00:00
|
|
|
|
Directory.CreateDirectory(Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo"));
|
|
|
|
|
client.DownloadFile(ic, Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo", $"iconTex.{ic.Split('.')[3]}"));
|
|
|
|
|
mvm.GameConfiguration.TGAIco.ImgPath = Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo", $"iconTex.{ic.Split('.')[3]}");
|
2020-04-28 23:40:54 +00:00
|
|
|
|
mvm.GameConfiguration.TGAIco.extension = $".{ic.Split('.')[3]}";
|
2020-04-20 09:31:26 +00:00
|
|
|
|
if (mvm.test == GameBaseClassLibrary.GameConsoles.GCN)
|
|
|
|
|
{
|
2020-04-21 02:05:19 +00:00
|
|
|
|
(mvm.Thing as GCConfig).icoIMG.Visibility = Visibility.Visible;
|
2020-04-20 09:31:26 +00:00
|
|
|
|
}
|
|
|
|
|
else if(mvm.GameConfiguration.Console == GameBaseClassLibrary.GameConsoles.WII)
|
|
|
|
|
{
|
2020-04-21 02:05:19 +00:00
|
|
|
|
(mvm.Thing as WiiConfig).icoIMG.Visibility = Visibility.Visible;
|
2020-04-20 09:31:26 +00:00
|
|
|
|
}
|
2020-04-21 19:52:52 +00:00
|
|
|
|
else if (mvm.GameConfiguration.Console == GameBaseClassLibrary.GameConsoles.N64)
|
|
|
|
|
{
|
|
|
|
|
(mvm.Thing as N64Config).icoIMG.Visibility = Visibility.Visible;
|
|
|
|
|
}
|
2020-04-21 20:54:32 +00:00
|
|
|
|
else if (mvm.GameConfiguration.Console == GameBaseClassLibrary.GameConsoles.GBA)
|
|
|
|
|
{
|
|
|
|
|
(mvm.Thing as GBA).icoIMG.Visibility = Visibility.Visible;
|
|
|
|
|
}
|
2020-06-13 07:27:42 +00:00
|
|
|
|
else if (mvm.GameConfiguration.Console == GameBaseClassLibrary.GameConsoles.TG16)
|
|
|
|
|
{
|
|
|
|
|
(mvm.Thing as TurboGrafX).icoIMG.Visibility = Visibility.Visible;
|
|
|
|
|
}
|
|
|
|
|
else if (mvm.GameConfiguration.Console == GameBaseClassLibrary.GameConsoles.NDS || mvm.GameConfiguration.Console == GameBaseClassLibrary.GameConsoles.SNES || mvm.GameConfiguration.Console == GameBaseClassLibrary.GameConsoles.NES || mvm.GameConfiguration.Console == GameBaseClassLibrary.GameConsoles.MSX)
|
2020-04-21 19:52:52 +00:00
|
|
|
|
{
|
|
|
|
|
(mvm.Thing as OtherConfigs).icoIMG.Visibility = Visibility.Visible;
|
|
|
|
|
}
|
2020-10-02 00:38:48 +00:00
|
|
|
|
client.DownloadFile(tvs, Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo", $"bootTvTex.{tvs.Split('.')[3]}"));
|
|
|
|
|
mvm.GameConfiguration.TGATv.ImgPath = Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo", $"bootTvTex.{tvs.Split('.')[3]}");
|
2020-04-28 23:40:54 +00:00
|
|
|
|
mvm.GameConfiguration.TGATv.extension = $".{tvs.Split('.')[3]}";
|
2020-04-20 09:31:26 +00:00
|
|
|
|
if (mvm.test == GameBaseClassLibrary.GameConsoles.GCN)
|
|
|
|
|
{
|
2020-04-21 02:05:19 +00:00
|
|
|
|
(mvm.Thing as GCConfig).tvIMG.Visibility = Visibility.Visible;
|
2020-10-02 00:38:48 +00:00
|
|
|
|
(mvm.Thing as GCConfig).imgpath(Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo", $"iconTex.{ic.Split('.')[3]}"), Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo", $"bootTvTex.{tvs.Split('.')[3]}"));
|
2020-06-13 07:27:42 +00:00
|
|
|
|
|
2020-04-20 09:31:26 +00:00
|
|
|
|
}
|
|
|
|
|
else if (mvm.GameConfiguration.Console == GameBaseClassLibrary.GameConsoles.WII)
|
|
|
|
|
{
|
2020-04-21 02:05:19 +00:00
|
|
|
|
(mvm.Thing as WiiConfig).tvIMG.Visibility = Visibility.Visible;
|
2020-10-02 00:38:48 +00:00
|
|
|
|
(mvm.Thing as WiiConfig).imgpath(Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo", $"iconTex.{ic.Split('.')[3]}"), Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo", $"bootTvTex.{tvs.Split('.')[3]}"));
|
2020-06-13 07:27:42 +00:00
|
|
|
|
|
2020-04-20 09:31:26 +00:00
|
|
|
|
}
|
2020-04-21 19:52:52 +00:00
|
|
|
|
else if (mvm.GameConfiguration.Console == GameBaseClassLibrary.GameConsoles.N64)
|
|
|
|
|
{
|
|
|
|
|
(mvm.Thing as N64Config).tvIMG.Visibility = Visibility.Visible;
|
2020-10-02 00:38:48 +00:00
|
|
|
|
(mvm.Thing as N64Config).imgpath(Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo", $"iconTex.{ic.Split('.')[3]}"), Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo", $"bootTvTex.{tvs.Split('.')[3]}"));
|
2020-04-28 23:40:54 +00:00
|
|
|
|
|
2020-04-21 19:52:52 +00:00
|
|
|
|
}
|
2020-04-21 20:54:32 +00:00
|
|
|
|
else if (mvm.GameConfiguration.Console == GameBaseClassLibrary.GameConsoles.GBA)
|
|
|
|
|
{
|
|
|
|
|
(mvm.Thing as GBA).tvIMG.Visibility = Visibility.Visible;
|
2020-10-02 00:38:48 +00:00
|
|
|
|
(mvm.Thing as GBA).imgpath(Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo", $"iconTex.{ic.Split('.')[3]}"), Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo", $"bootTvTex.{tvs.Split('.')[3]}"));
|
2020-04-21 20:54:32 +00:00
|
|
|
|
}
|
2020-06-13 07:27:42 +00:00
|
|
|
|
else if (mvm.GameConfiguration.Console == GameBaseClassLibrary.GameConsoles.TG16)
|
|
|
|
|
{
|
|
|
|
|
(mvm.Thing as TurboGrafX).tvIMG.Visibility = Visibility.Visible;
|
2020-10-02 00:38:48 +00:00
|
|
|
|
(mvm.Thing as TurboGrafX).imgpath(Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo", $"iconTex.{ic.Split('.')[3]}"), Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo", $"bootTvTex.{tvs.Split('.')[3]}"));
|
2020-06-13 07:27:42 +00:00
|
|
|
|
}
|
|
|
|
|
else if (mvm.GameConfiguration.Console == GameBaseClassLibrary.GameConsoles.NDS || mvm.GameConfiguration.Console == GameBaseClassLibrary.GameConsoles.SNES || mvm.GameConfiguration.Console == GameBaseClassLibrary.GameConsoles.NES || mvm.GameConfiguration.Console == GameBaseClassLibrary.GameConsoles.MSX)
|
2020-04-21 19:52:52 +00:00
|
|
|
|
{
|
2020-04-21 20:54:32 +00:00
|
|
|
|
(mvm.Thing as OtherConfigs).tvIMG.Visibility = Visibility.Visible;
|
2020-10-02 00:38:48 +00:00
|
|
|
|
(mvm.Thing as OtherConfigs).imgpath(Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo", $"iconTex.{ic.Split('.')[3]}"), Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo", $"bootTvTex.{tvs.Split('.')[3]}"));
|
2020-04-21 19:52:52 +00:00
|
|
|
|
|
|
|
|
|
}
|
2020-05-06 21:53:52 +00:00
|
|
|
|
/* if(mvm.test == GameConsoles.GCN)
|
2020-04-28 23:40:54 +00:00
|
|
|
|
{
|
|
|
|
|
checkForAdditionalFiles(GameConsoles.GCN);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
checkForAdditionalFiles(mvm.GameConfiguration.Console);
|
2020-05-06 21:53:52 +00:00
|
|
|
|
}*/
|
2020-04-28 23:40:54 +00:00
|
|
|
|
|
2020-04-19 22:53:34 +00:00
|
|
|
|
this.Close();
|
|
|
|
|
}
|
2020-04-28 23:40:54 +00:00
|
|
|
|
private void checkForAdditionalFiles(GameConsoles console)
|
|
|
|
|
{
|
2020-10-02 00:38:48 +00:00
|
|
|
|
if (!Directory.Exists(Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo")))
|
2020-04-28 23:40:54 +00:00
|
|
|
|
{
|
2020-10-02 00:38:48 +00:00
|
|
|
|
Directory.CreateDirectory(Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo"));
|
2020-04-28 23:40:54 +00:00
|
|
|
|
}
|
|
|
|
|
bool ini = false;
|
|
|
|
|
bool btsnd = false;
|
|
|
|
|
string inip = "";
|
|
|
|
|
string btsndp = "";
|
|
|
|
|
string exten = "";
|
|
|
|
|
string linkbase = "https://raw.githubusercontent.com/Flumpster/UWUVCI-Images/master/";
|
|
|
|
|
if (console == GameConsoles.N64)
|
|
|
|
|
{
|
|
|
|
|
if (RemoteFileExists(linkbase+repoid+"/game.ini"))
|
|
|
|
|
{
|
|
|
|
|
ini = true;
|
|
|
|
|
inip = linkbase + repoid + "/game.ini";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
string[] ext = { "wav", "mp3", "btsnd" };
|
|
|
|
|
foreach(var e in ext)
|
|
|
|
|
{
|
|
|
|
|
if (RemoteFileExists(linkbase + repoid + "/BootSound." + e))
|
|
|
|
|
{
|
|
|
|
|
btsnd = true;
|
|
|
|
|
btsndp = linkbase + repoid + "/BootSound." + e;
|
|
|
|
|
exten = e;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(ini || btsnd)
|
|
|
|
|
{
|
|
|
|
|
string extra = "There are more additional files found. Do you want to download those?";
|
|
|
|
|
if (ini && !btsnd) { extra = "There is an additional INI file available for Dowload. Do you want to dowload it?"; }
|
|
|
|
|
if (!ini && btsnd) { extra = "There is an additional BootSound file available for Dowload. Do you want to dowload it?"; }
|
|
|
|
|
if (ini && btsnd) { extra = "There is an adittional INI and BootSound file available for Dowload. Do you want to download those?"; }
|
|
|
|
|
MainViewModel mvm = FindResource("mvm") as MainViewModel;
|
|
|
|
|
Custom_Message cm = new Custom_Message("Found additional Files",extra);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
cm.Owner = mvm.mw;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
cm.ShowDialog();
|
|
|
|
|
if (mvm.addi)
|
|
|
|
|
{
|
|
|
|
|
var client = new WebClient();
|
|
|
|
|
if (ini)
|
|
|
|
|
{
|
2020-10-02 00:38:48 +00:00
|
|
|
|
client.DownloadFile(inip, Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo", "game.ini"));
|
|
|
|
|
(mvm.Thing as N64Config).ini.Text = Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo", "game.ini");
|
|
|
|
|
mvm.GameConfiguration.N64Stuff.INIPath = Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo", "game.ini");
|
2020-04-28 23:40:54 +00:00
|
|
|
|
}
|
|
|
|
|
if (btsnd)
|
|
|
|
|
{
|
2020-10-02 00:38:48 +00:00
|
|
|
|
client.DownloadFile(btsndp, Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo", $"bootSound.{exten}"));
|
|
|
|
|
mvm.BootSound = Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo", $"bootSound.{exten}");
|
2020-04-28 23:40:54 +00:00
|
|
|
|
switch (console)
|
|
|
|
|
{
|
|
|
|
|
case GameConsoles.NDS:
|
2020-10-02 00:38:48 +00:00
|
|
|
|
(mvm.Thing as OtherConfigs).sound.Text = Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo", $"bootSound.{exten}");
|
2020-04-28 23:40:54 +00:00
|
|
|
|
break;
|
|
|
|
|
case GameConsoles.GBA:
|
2020-10-02 00:38:48 +00:00
|
|
|
|
(mvm.Thing as GBA).sound.Text = Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo", $"bootSound.{exten}");
|
2020-04-28 23:40:54 +00:00
|
|
|
|
break;
|
|
|
|
|
case GameConsoles.N64:
|
2020-10-02 00:38:48 +00:00
|
|
|
|
(mvm.Thing as N64Config).sound.Text = Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo", $"bootSound.{exten}");
|
2020-04-28 23:40:54 +00:00
|
|
|
|
break;
|
|
|
|
|
case GameConsoles.WII:
|
|
|
|
|
if(mvm.test == GameConsoles.GCN)
|
|
|
|
|
{
|
2020-10-02 00:38:48 +00:00
|
|
|
|
(mvm.Thing as GCConfig).sound.Text = Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo", $"bootSound.{exten}");
|
2020-04-28 23:40:54 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-10-02 00:38:48 +00:00
|
|
|
|
(mvm.Thing as WiiConfig).sound.Text = Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo", $"bootSound.{exten}");
|
2020-04-28 23:40:54 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
mvm.addi = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public void checkForAdditionalFiles(GameConsoles console, string repoid)
|
|
|
|
|
{
|
2020-10-02 00:38:48 +00:00
|
|
|
|
if (!Directory.Exists(Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo")))
|
2020-04-28 23:40:54 +00:00
|
|
|
|
{
|
2020-10-02 00:38:48 +00:00
|
|
|
|
Directory.CreateDirectory(Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo"));
|
2020-04-28 23:40:54 +00:00
|
|
|
|
}
|
|
|
|
|
bool ini = false;
|
|
|
|
|
bool btsnd = false;
|
|
|
|
|
string inip = "";
|
|
|
|
|
string btsndp = "";
|
|
|
|
|
string exten = "";
|
|
|
|
|
string linkbase = "https://raw.githubusercontent.com/Flumpster/UWUVCI-Images/master/";
|
|
|
|
|
if (console == GameConsoles.N64)
|
|
|
|
|
{
|
|
|
|
|
if (RemoteFileExists(linkbase + repoid + "/game.ini"))
|
|
|
|
|
{
|
|
|
|
|
ini = true;
|
|
|
|
|
inip = linkbase + repoid + "/game.ini";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
string[] ext = { "wav", "mp3", "btsnd" };
|
|
|
|
|
foreach (var e in ext)
|
|
|
|
|
{
|
|
|
|
|
if (RemoteFileExists(linkbase + repoid + "/BootSound." + e))
|
|
|
|
|
{
|
|
|
|
|
btsnd = true;
|
|
|
|
|
btsndp = linkbase + repoid + "/BootSound." + e;
|
|
|
|
|
exten = e;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (ini || btsnd)
|
|
|
|
|
{
|
|
|
|
|
string extra = "There are more additional files found. Do you want to download those?";
|
|
|
|
|
if (ini && !btsnd) { extra = "There is an additional INI file available for Dowload. Do you want to dowload it?"; }
|
|
|
|
|
if (!ini && btsnd) { extra = "There is an additional BootSound file available for Dowload. Do you want to dowload it?"; }
|
|
|
|
|
if (ini && btsnd) { extra = "There is an adittional INI and BootSound file available for Dowload. Do you want to download those?"; }
|
|
|
|
|
MainViewModel mvm = FindResource("mvm") as MainViewModel;
|
|
|
|
|
Custom_Message cm = new Custom_Message("Found additional Files", extra);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
cm.Owner = mvm.mw;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
cm.ShowDialog();
|
|
|
|
|
if (mvm.addi)
|
|
|
|
|
{
|
|
|
|
|
var client = new WebClient();
|
|
|
|
|
if (ini)
|
|
|
|
|
{
|
2020-10-02 00:38:48 +00:00
|
|
|
|
client.DownloadFile(inip, Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo", "game.ini"));
|
|
|
|
|
(mvm.Thing as N64Config).ini.Text = Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo", "game.ini");
|
|
|
|
|
mvm.GameConfiguration.N64Stuff.INIPath = Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo", "game.ini");
|
2020-04-28 23:40:54 +00:00
|
|
|
|
}
|
|
|
|
|
if (btsnd)
|
|
|
|
|
{
|
2020-10-02 00:38:48 +00:00
|
|
|
|
client.DownloadFile(btsndp, Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo", $"bootSound.{exten}"));
|
|
|
|
|
mvm.BootSound = Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo", $"bootSound.{exten}");
|
2020-04-28 23:40:54 +00:00
|
|
|
|
switch (console)
|
|
|
|
|
{
|
|
|
|
|
case GameConsoles.NDS:
|
2020-10-02 00:38:48 +00:00
|
|
|
|
(mvm.Thing as OtherConfigs).sound.Text = Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo", $"bootSound.{exten}");
|
2020-04-28 23:40:54 +00:00
|
|
|
|
break;
|
|
|
|
|
case GameConsoles.GBA:
|
2020-10-02 00:38:48 +00:00
|
|
|
|
(mvm.Thing as GBA).sound.Text = Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo", $"bootSound.{exten}");
|
2020-04-28 23:40:54 +00:00
|
|
|
|
break;
|
|
|
|
|
case GameConsoles.N64:
|
2020-10-02 00:38:48 +00:00
|
|
|
|
(mvm.Thing as N64Config).sound.Text = Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo", $"bootSound.{exten}");
|
2020-04-28 23:40:54 +00:00
|
|
|
|
break;
|
|
|
|
|
case GameConsoles.WII:
|
|
|
|
|
if (mvm.test == GameConsoles.GCN)
|
|
|
|
|
{
|
2020-10-02 00:38:48 +00:00
|
|
|
|
(mvm.Thing as GCConfig).sound.Text = Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo", $"bootSound.{exten}");
|
2020-04-28 23:40:54 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-10-02 00:38:48 +00:00
|
|
|
|
(mvm.Thing as WiiConfig).sound.Text = Path.Combine(Directory.GetCurrentDirectory(), "bin", "repo", $"bootSound.{exten}");
|
2020-04-28 23:40:54 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
2020-04-19 22:53:34 +00:00
|
|
|
|
|
2020-04-28 23:40:54 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
mvm.addi = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private bool RemoteFileExists(string url)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
|
|
|
|
|
request.Method = "HEAD";
|
|
|
|
|
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
|
|
|
|
|
response.Close();
|
|
|
|
|
return (response.StatusCode == HttpStatusCode.OK);
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-05-06 21:53:52 +00:00
|
|
|
|
private void wind_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
(FindResource("mvm") as MainViewModel).mw.Topmost = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void wind_Closed(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
(FindResource("mvm") as MainViewModel).mw.Topmost = false;
|
|
|
|
|
}
|
2020-04-19 22:53:34 +00:00
|
|
|
|
}
|
|
|
|
|
}
|