2020-03-01 13:12:17 +00:00
using System ;
using System.Collections.Generic ;
using System.Threading.Tasks ;
using System.Windows ;
using System.Windows.Controls ;
using System.Windows.Input ;
using System.Windows.Media ;
2020-03-08 22:25:34 +00:00
using UWUVCI_AIO_WPF.UI.Frames ;
2020-03-13 22:35:20 +00:00
using GameBaseClassLibrary ;
2020-04-02 19:45:24 +00:00
using UWUVCI_AIO_WPF.UI.Frames.Path ;
2020-05-27 20:10:48 +00:00
using System.IO ;
using NAudio.Wave ;
2020-10-17 14:36:11 +00:00
using System.Diagnostics ;
2020-03-01 13:12:17 +00:00
namespace UWUVCI_AIO_WPF
{
/// <summary>
/// Interaktionslogik für MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
2020-05-27 20:10:48 +00:00
private readonly List < Key > _konamiCode = new List < Key >
{
Key . Up , Key . Up ,
Key . Down , Key . Down ,
Key . Left , Key . Right ,
Key . Left , Key . Right ,
Key . B , Key . A ,
Key . Enter
} ;
2020-07-29 15:20:29 +00:00
private bool movingrn = false ;
private bool startedmoving = false ;
2020-05-27 20:10:48 +00:00
public static byte [ ] StreamToBytes ( System . IO . Stream stream )
{
long originalPosition = 0 ;
if ( stream . CanSeek )
{
originalPosition = stream . Position ;
stream . Position = 0 ;
}
try
{
byte [ ] readBuffer = new byte [ 4096 ] ;
int totalBytesRead = 0 ;
int bytesRead ;
while ( ( bytesRead = stream . Read ( readBuffer , totalBytesRead , readBuffer . Length - totalBytesRead ) ) > 0 )
{
totalBytesRead + = bytesRead ;
if ( totalBytesRead = = readBuffer . Length )
{
int nextByte = stream . ReadByte ( ) ;
if ( nextByte ! = - 1 )
{
byte [ ] temp = new byte [ readBuffer . Length * 2 ] ;
Buffer . BlockCopy ( readBuffer , 0 , temp , 0 , readBuffer . Length ) ;
Buffer . SetByte ( temp , totalBytesRead , ( byte ) nextByte ) ;
readBuffer = temp ;
totalBytesRead + + ;
}
}
}
byte [ ] buffer = readBuffer ;
if ( readBuffer . Length ! = totalBytesRead )
{
buffer = new byte [ totalBytesRead ] ;
Buffer . BlockCopy ( readBuffer , 0 , buffer , 0 , totalBytesRead ) ;
}
return buffer ;
}
finally
{
if ( stream . CanSeek )
{
stream . Position = originalPosition ;
}
}
}
2020-08-11 19:35:17 +00:00
internal void is32 ( )
{
2020-10-02 06:43:07 +00:00
Wii . DataContext = this ;
Wii . IsEnabled = false ;
GC . DataContext = this ;
GC . IsEnabled = false ;
2020-08-11 19:35:17 +00:00
}
2020-06-08 07:34:21 +00:00
static MemoryStream sound = new MemoryStream ( Properties . Resources . mario ) ;
2020-05-27 20:10:48 +00:00
private int _match ;
static MemoryStream ms = new MemoryStream ( StreamToBytes ( sound ) ) ;
static WaveStream ws = new Mp3FileReader ( ms ) ;
static WaveOutEvent output = new WaveOutEvent ( ) ;
private void Window_KeyUp ( object sender , KeyEventArgs e )
{
if ( e . Key = = _konamiCode [ _match ] )
{
if ( + + _match > = _konamiCode . Count )
{
_match = 0 ;
output . PlaybackStopped + = new EventHandler < StoppedEventArgs > ( Media_Ended ) ;
output . Init ( ws ) ;
output . Play ( ) ;
}
}
else if ( _match > 0 & & e . Key ! = _konamiCode [ _match ] )
{
_match = 0 ;
}
}
public static void Media_Ended ( object sender , EventArgs e )
{
if ( output . PlaybackState = = PlaybackState . Stopped )
{
if ( ms ! = null )
{
ms . Close ( ) ;
ms . Flush ( ) ;
}
if ( ws ! = null )
{
ws . Close ( ) ;
}
if ( output ! = null )
{
output . Dispose ( ) ;
}
}
}
2020-05-22 13:26:36 +00:00
public bool move = true ;
2020-03-01 13:12:17 +00:00
public MainWindow ( )
{
InitializeComponent ( ) ;
2020-03-08 22:25:34 +00:00
load_frame . Content = new StartFrame ( ) ;
2020-04-04 22:16:55 +00:00
( FindResource ( "mvm" ) as MainViewModel ) . setMW ( this ) ;
2020-03-01 13:12:17 +00:00
}
2020-07-29 15:20:29 +00:00
private void ButtonCloseMenu_Click ( object sender , RoutedEventArgs e )
2020-03-01 13:12:17 +00:00
{
ButtonOpenMenu . Visibility = Visibility . Visible ;
ButtonCloseMenu . Visibility = Visibility . Collapsed ;
}
private void ButtonOpenMenu_Click ( object sender , RoutedEventArgs e )
{
ButtonOpenMenu . Visibility = Visibility . Collapsed ;
ButtonCloseMenu . Visibility = Visibility . Visible ;
}
2020-07-29 15:20:29 +00:00
private void ButtonCloseMenu_Click ( object sender , MouseEventArgs e )
{
if ( ! movingrn )
{
// Storyboard sb = this.FindResource("MenuClose") as Storyboard;
// if (sb != null) { BeginStoryboard(sb); }
}
}
private void ButtonOpenMenu_Click ( object sender , MouseEventArgs e )
{
if ( ! movingrn )
{
// Storyboard sb = this.FindResource("MenuOpen") as Storyboard;
// if (sb != null) { BeginStoryboard(sb); }
}
}
2020-03-01 13:12:17 +00:00
private void MoveWindow ( object sender , MouseButtonEventArgs e )
{
2020-07-29 15:20:29 +00:00
startedmoving = true ;
2020-03-01 13:12:17 +00:00
try
{
2020-05-22 13:26:36 +00:00
if ( e . ChangedButton = = MouseButton . Left & & move )
2020-07-29 15:20:29 +00:00
{
movingrn = true ;
2020-10-02 06:43:07 +00:00
DragMove ( ) ;
2020-07-29 15:20:29 +00:00
}
2020-03-01 13:12:17 +00:00
}
catch ( Exception )
{
2020-10-02 06:43:07 +00:00
//left empty on purpose
2020-03-01 13:12:17 +00:00
}
2020-07-29 15:20:29 +00:00
startedmoving = false ;
2020-03-01 13:12:17 +00:00
}
2020-03-08 22:25:34 +00:00
private void DestroyFrame ( )
{
//(load_frame.Content as IDisposable).Dispose();
load_frame . Content = null ;
load_frame . NavigationService . RemoveBackEntry ( ) ;
}
2020-06-11 08:12:03 +00:00
public void ListView_Click ( object sender , MouseButtonEventArgs e )
2020-03-01 13:12:17 +00:00
{
2020-07-29 15:20:29 +00:00
if ( ! startedmoving & & ! movingrn )
2020-04-21 02:05:19 +00:00
{
2020-07-29 15:20:29 +00:00
try
{
MainViewModel mvm = FindResource ( "mvm" ) as MainViewModel ;
2020-05-22 09:36:31 +00:00
2020-07-29 15:20:29 +00:00
/ * if ( ( sender as ListView ) . SelectedIndex = = 9 )
2020-04-21 02:05:19 +00:00
{
2020-07-29 15:20:29 +00:00
mvm . saveconf = mvm . GameConfiguration . Clone ( ) ;
} * /
if ( mvm . curr ! = null )
2020-04-21 02:05:19 +00:00
{
2020-07-29 15:20:29 +00:00
mvm . curr . Background = null ;
2020-04-21 02:05:19 +00:00
}
2020-07-29 15:20:29 +00:00
mvm . curr = ( sender as ListView ) . SelectedItem as ListViewItem ;
if ( mvm . curr ! = null )
2020-04-21 02:05:19 +00:00
{
2020-07-29 15:20:29 +00:00
mvm . curr . Background = new SolidColorBrush ( Color . FromArgb ( 25 , 255 , 255 , 255 ) ) ;
2020-04-21 02:05:19 +00:00
}
2020-07-29 15:20:29 +00:00
mvm . GameConfiguration = new GameConfig ( ) ;
mvm . LGameBasesString . Clear ( ) ;
mvm . CanInject = false ;
mvm . BaseDownloaded = false ;
mvm . RomSet = false ;
mvm . RomPath = null ;
mvm . Injected = false ;
mvm . CBasePath = null ;
mvm . bcf = null ;
mvm . BootSound = null ;
mvm . setThing ( null ) ;
mvm . gc2rom = null ;
mvm . Index = - 1 ;
mvm . donttrim = false ;
mvm . NKITFLAG = false ;
mvm . prodcode = "" ;
mvm . foldername = "" ;
mvm . jppatch = false ;
mvm . test = GameConsoles . WII ;
mvm . regionfrii = false ;
mvm . cd = false ;
mvm . regionfriijp = false ;
mvm . regionfriius = false ;
mvm . pixelperfect = false ;
mvm . injected2 = false ;
mvm . RemoveCreatedIMG ( ) ;
mvm . isDoneMW ( ) ;
2020-10-02 06:43:07 +00:00
DestroyFrame ( ) ;
mvm . saveconf = null ;
mvm . GC = false ;
2020-07-29 15:20:29 +00:00
switch ( ( sender as ListView ) . SelectedIndex )
2020-04-21 02:05:19 +00:00
{
2020-07-29 15:20:29 +00:00
case 0 :
tbTitleBar . Text = "UWUVCI AIO - NDS VC INJECT" ;
/ * if ( mvm . saveconf ! = null & & mvm . saveconf . Console = = GameConsoles . NDS )
{
load_frame . Content = new INJECTFRAME ( GameConsoles . NDS , mvm . saveconf ) ;
}
else
{ * /
load_frame . Content = new INJECTFRAME ( GameConsoles . NDS ) ;
//}
break ;
case 1 :
tbTitleBar . Text = "UWUVCI AIO - GBA VC INJECT" ;
/ * if ( mvm . saveconf ! = null & & mvm . saveconf . Console = = GameConsoles . GBA )
{
load_frame . Content = new INJECTFRAME ( GameConsoles . GBA , mvm . saveconf ) ;
}
else
{ * /
load_frame . Content = new INJECTFRAME ( GameConsoles . GBA ) ;
//}
break ;
case 2 :
tbTitleBar . Text = "UWUVCI AIO - N64 VC INJECT" ;
/ * if ( mvm . saveconf ! = null & & mvm . saveconf . Console = = GameConsoles . N64 )
{
load_frame . Content = new INJECTFRAME ( GameConsoles . N64 , mvm . saveconf ) ;
}
else
{ * /
mvm . GameConfiguration . N64Stuff = new Classes . N64Conf ( ) ;
load_frame . Content = new INJECTFRAME ( GameConsoles . N64 ) ;
//}
break ;
case 4 :
tbTitleBar . Text = "UWUVCI AIO - NES VC INJECT" ;
/ * if ( mvm . saveconf ! = null & & mvm . saveconf . Console = = GameConsoles . NES )
{
load_frame . Content = new INJECTFRAME ( GameConsoles . NES , mvm . saveconf ) ;
}
else
{ * /
load_frame . Content = new INJECTFRAME ( GameConsoles . NES ) ;
//}
break ;
case 3 :
tbTitleBar . Text = "UWUVCI AIO - SNES VC INJECT" ;
/ * if ( mvm . saveconf ! = null & & mvm . saveconf . Console = = GameConsoles . SNES )
{
load_frame . Content = new INJECTFRAME ( GameConsoles . SNES , mvm . saveconf ) ;
}
else
{ * /
load_frame . Content = new INJECTFRAME ( GameConsoles . SNES ) ;
//}
break ;
case 5 :
tbTitleBar . Text = "UWUVCI AIO - TurboGrafX-16 VC INJECT" ;
/ * if ( mvm . saveconf ! = null & & mvm . saveconf . Console = = GameConsoles . TG16 )
{
load_frame . Content = new INJECTFRAME ( GameConsoles . TG16 , mvm . saveconf ) ;
}
else
{ * /
load_frame . Content = new INJECTFRAME ( GameConsoles . TG16 ) ;
// }
break ;
case 6 :
tbTitleBar . Text = "UWUVCI AIO - MSX VC INJECT" ;
/ * if ( mvm . saveconf ! = null & & mvm . saveconf . Console = = GameConsoles . MSX )
{
load_frame . Content = new INJECTFRAME ( GameConsoles . MSX , mvm . saveconf ) ;
}
else
{ * /
load_frame . Content = new INJECTFRAME ( GameConsoles . MSX ) ;
//}
break ;
case 7 :
tbTitleBar . Text = "UWUVCI AIO - Wii VC INJECT" ;
/ * if ( mvm . saveconf ! = null & & mvm . saveconf . Console = = GameConsoles . WII )
{
load_frame . Content = new INJECTFRAME ( GameConsoles . WII , mvm . saveconf ) ;
}
else
{ * /
load_frame . Content = new INJECTFRAME ( GameConsoles . WII ) ;
//}
break ;
case 8 :
2020-10-02 06:43:07 +00:00
mvm . GC = true ;
2020-07-29 15:20:29 +00:00
tbTitleBar . Text = "UWUVCI AIO - GC VC INJECT" ;
/ * if ( mvm . saveconf ! = null & & ( mvm . saveconf . Console = = GameConsoles . WII | | mvm . saveconf . Console = = GameConsoles . GCN ) & & mvm . GC = = true )
{
load_frame . Content = new INJECTFRAME ( GameConsoles . GCN , mvm . saveconf ) ;
}
else
{ * /
load_frame . Content = new INJECTFRAME ( GameConsoles . GCN ) ;
//}
break ;
/ * case 9 :
DestroyFrame ( ) ;
tbTitleBar . Text = "UWUVCI AIO - Retroarch VC Inject" ;
load_frame . Content = new SettingsFrame ( this ) ;
break ; * /
case 9 :
2020-08-10 22:39:30 +00:00
tbTitleBar . Text = "UWUVCI AIO - ???????? ?? ??????" ;
2020-08-10 13:38:42 +00:00
load_frame . Content = new Teaser ( ) ;
2020-07-29 15:20:29 +00:00
break ;
2020-04-21 02:05:19 +00:00
}
2020-07-29 15:20:29 +00:00
}
2020-10-02 06:43:07 +00:00
catch
2020-07-29 15:20:29 +00:00
{
2020-10-02 06:43:07 +00:00
// left empty on purpose
2020-07-29 15:20:29 +00:00
}
2020-03-08 22:25:34 +00:00
}
2020-03-01 13:12:17 +00:00
}
2020-04-02 19:45:24 +00:00
public void paths ( bool remove )
{
load_frame . Content = null ;
if ( remove )
{
load_frame . Content = new SettingsFrame ( this ) ;
}
else
{
load_frame . Content = new Paths ( this ) ;
}
}
2020-03-01 13:12:17 +00:00
private void Window_Close ( object sender , RoutedEventArgs e )
{
2020-10-02 06:43:07 +00:00
Close ( ) ;
2020-03-01 13:12:17 +00:00
}
private void Window_Minimize ( object sender , RoutedEventArgs e )
{
2020-10-02 06:43:07 +00:00
WindowState = WindowState . Minimized ;
2020-03-01 13:12:17 +00:00
}
2020-04-16 18:52:26 +00:00
private void Button_MouseEnter ( object sender , MouseEventArgs e )
{
2020-04-18 03:31:36 +00:00
min . Background = new SolidColorBrush ( Color . FromArgb ( 100 , 255 , 255 , 255 ) ) ;
2020-04-16 18:52:26 +00:00
}
private void close_MouseEnter ( object sender , MouseEventArgs e )
{
2020-04-18 03:31:36 +00:00
close . Background = new SolidColorBrush ( Color . FromArgb ( 150 , 255 , 100 , 100 ) ) ;
2020-04-16 18:52:26 +00:00
}
private void close_MouseLeave ( object sender , MouseEventArgs e )
{
close . Background = new SolidColorBrush ( Color . FromArgb ( 0 , 250 , 250 , 250 ) ) ;
}
private void min_MouseLeave ( object sender , MouseEventArgs e )
{
min . Background = new SolidColorBrush ( Color . FromArgb ( 0 , 250 , 250 , 250 ) ) ;
}
2020-08-10 13:38:42 +00:00
private void sett_MouseEnter ( object sender , MouseEventArgs e )
{
settings . Background = new SolidColorBrush ( Color . FromArgb ( 100 , 255 , 255 , 255 ) ) ;
}
private void sett_MouseLeave ( object sender , MouseEventArgs e )
{
settings . Background = new SolidColorBrush ( Color . FromArgb ( 0 , 250 , 250 , 250 ) ) ;
}
2020-06-27 17:15:57 +00:00
public void setDebug ( bool bypass )
2020-04-16 18:52:26 +00:00
{
MainViewModel mvm = FindResource ( "mvm" ) as MainViewModel ;
mvm . debug = true ;
2020-06-24 15:54:51 +00:00
spc . Visibility = Visibility . Visible ;
2020-06-27 17:15:57 +00:00
if ( bypass )
2020-06-24 15:54:51 +00:00
{
spc . Text = "Debug & Space Bypass Mode" ;
2020-06-27 17:15:57 +00:00
spc . ToolTip = "Disables all Space checks. May cause issues.\n\"Unhides\" used Tools (Displays whats going on in the Background while a ProgressBar appears" ;
2020-06-24 15:54:51 +00:00
}
else
{
spc . Text = "Debug Mode" ;
2020-06-27 17:15:57 +00:00
spc . ToolTip = "\"Unhides\" used Tools (Displays whats going on in the Background while a ProgressBar appears" ;
2020-06-24 15:54:51 +00:00
}
}
public void allowBypass ( )
{
( FindResource ( "mvm" ) as MainViewModel ) . saveworkaround = true ;
spc . Visibility = Visibility . Visible ;
2020-06-27 17:15:57 +00:00
spc . Text = "Space Bypass Mode" ;
2020-10-02 06:43:07 +00:00
spc . ToolTip = "Disables all Space checks. May cause issues." ;
}
2020-07-29 15:20:29 +00:00
private void Window_MouseUp ( object sender , MouseButtonEventArgs e )
{
new Task ( ( ) = >
{
System . Threading . Thread . Sleep ( 30 ) ;
if ( ! startedmoving )
{
movingrn = false ;
}
} ) . Start ( ) ;
}
2020-08-10 13:38:42 +00:00
private void settings_Click ( object sender , RoutedEventArgs e )
{
MainViewModel mvm = FindResource ( "mvm" ) as MainViewModel ;
mvm . GameConfiguration = new GameConfig ( ) ;
mvm . LGameBasesString . Clear ( ) ;
mvm . CanInject = false ;
mvm . BaseDownloaded = false ;
mvm . RomSet = false ;
mvm . RomPath = null ;
mvm . Injected = false ;
mvm . CBasePath = null ;
mvm . bcf = null ;
mvm . BootSound = null ;
mvm . setThing ( null ) ;
mvm . gc2rom = null ;
mvm . Index = - 1 ;
mvm . donttrim = false ;
mvm . NKITFLAG = false ;
mvm . prodcode = "" ;
mvm . foldername = "" ;
mvm . jppatch = false ;
mvm . GC = false ;
mvm . test = GameConsoles . WII ;
mvm . regionfrii = false ;
mvm . cd = false ;
mvm . regionfriijp = false ;
mvm . regionfriius = false ;
mvm . pixelperfect = false ;
mvm . injected2 = false ;
mvm . RemoveCreatedIMG ( ) ;
mvm . isDoneMW ( ) ;
DestroyFrame ( ) ;
tbTitleBar . Text = "UWUVCI AIO - Settings" ;
load_frame . Content = new SettingsFrame ( this ) ;
}
2020-10-05 20:11:10 +00:00
private void vwiiMode_Click ( object sender , RoutedEventArgs e )
{
2020-10-28 00:16:20 +00:00
try
{
Process . Start ( "UWUVCI VWII.exe" ) ;
Environment . Exit ( 0 ) ;
}
catch
{
//left empty on purpose
}
2020-10-05 20:11:10 +00:00
}
2020-03-01 13:12:17 +00:00
}
}