2020-01-27 22:14:35 +08:00
using CodeWalker.Properties ;
using System ;
2017-09-21 18:33:05 +08:00
using System.Collections.Generic ;
2020-01-27 22:14:35 +08:00
using System.IO ;
2017-09-21 18:33:05 +08:00
using System.Linq ;
2020-01-27 22:14:35 +08:00
using System.Reflection ;
2017-09-21 18:33:05 +08:00
using System.Threading.Tasks ;
using System.Windows.Forms ;
2020-01-27 22:14:35 +08:00
using System.Windows.Shell ;
2017-09-21 18:33:05 +08:00
namespace CodeWalker
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main ( string [ ] args )
{
bool menumode = false ;
bool explorermode = false ;
2018-03-03 21:03:08 +08:00
bool projectmode = false ;
2019-01-11 11:24:50 +08:00
bool vehiclesmode = false ;
2019-11-06 01:53:20 +08:00
bool pedsmode = false ;
2017-09-21 18:33:05 +08:00
if ( ( args ! = null ) & & ( args . Length > 0 ) )
{
foreach ( string arg in args )
{
2017-12-20 07:52:50 +08:00
string argl = arg . ToLowerInvariant ( ) ;
if ( argl = = "menu" )
2017-09-21 18:33:05 +08:00
{
menumode = true ;
}
2017-12-20 07:52:50 +08:00
if ( argl = = "explorer" )
2017-09-21 18:33:05 +08:00
{
explorermode = true ;
}
2018-03-03 21:03:08 +08:00
if ( argl = = "project" )
{
projectmode = true ;
}
2019-01-11 11:24:50 +08:00
if ( argl = = "vehicles" )
{
vehiclesmode = true ;
}
2019-11-06 01:53:20 +08:00
if ( argl = = "peds" )
{
pedsmode = true ;
}
2017-09-21 18:33:05 +08:00
}
}
2020-01-27 22:14:35 +08:00
EnsureJumpList ( ) ;
2017-09-21 18:33:05 +08:00
Application . EnableVisualStyles ( ) ;
Application . SetCompatibleTextRenderingDefault ( false ) ;
2018-02-21 16:34:49 +08:00
// Always check the GTA folder first thing
if ( ! GTAFolder . UpdateGTAFolder ( Properties . Settings . Default . RememberGTAFolder ) )
{
2018-02-21 17:12:17 +08:00
MessageBox . Show ( "Could not load CodeWalker because no valid GTA 5 folder was selected. CodeWalker will now exit." , "GTA 5 Folder Not Found" , MessageBoxButtons . OK , MessageBoxIcon . Stop ) ;
2018-02-21 16:34:49 +08:00
return ;
}
2017-09-21 18:33:05 +08:00
#if ! DEBUG
try
{
#endif
2018-03-03 21:03:08 +08:00
if ( menumode )
2017-09-21 18:33:05 +08:00
{
2017-12-24 19:49:04 +08:00
Application . Run ( new MenuForm ( ) ) ;
2017-09-21 18:33:05 +08:00
}
else if ( explorermode )
{
Application . Run ( new ExploreForm ( ) ) ;
}
2018-03-03 21:03:08 +08:00
else if ( projectmode )
{
2018-03-03 21:09:31 +08:00
Application . Run ( new Project . ProjectForm ( ) ) ;
2018-03-03 21:03:08 +08:00
}
2019-01-11 11:24:50 +08:00
else if ( vehiclesmode )
{
Application . Run ( new Vehicles . VehicleForm ( ) ) ;
}
2019-11-06 01:53:20 +08:00
else if ( pedsmode )
{
Application . Run ( new Peds . PedsForm ( ) ) ;
}
2017-09-21 18:33:05 +08:00
else
{
Application . Run ( new WorldForm ( ) ) ;
}
#if ! DEBUG
}
catch ( Exception ex )
{
MessageBox . Show ( "An unexpected error was encountered!\n" + ex . ToString ( ) ) ;
//this can happen if folder wasn't chosen, or in some other catastrophic error. meh.
}
#endif
}
2020-01-27 22:14:35 +08:00
static void EnsureJumpList ( )
{
if ( Settings . Default . JumpListInitialised ) return ;
try
{
var cwpath = Assembly . GetEntryAssembly ( ) . Location ;
var cwdir = Path . GetDirectoryName ( cwpath ) ;
var jtWorld = new JumpTask ( ) ;
jtWorld . ApplicationPath = cwpath ;
jtWorld . IconResourcePath = cwpath ;
jtWorld . WorkingDirectory = cwdir ;
jtWorld . Arguments = "" ;
jtWorld . Title = "World View" ;
jtWorld . Description = "Display the GTAV World" ;
jtWorld . CustomCategory = "Launch Options" ;
var jtExplorer = new JumpTask ( ) ;
jtExplorer . ApplicationPath = cwpath ;
jtExplorer . IconResourcePath = Path . Combine ( cwdir , "CodeWalker RPF Explorer.exe" ) ;
jtExplorer . WorkingDirectory = cwdir ;
jtExplorer . Arguments = "explorer" ;
jtExplorer . Title = "RPF Explorer" ;
jtExplorer . Description = "Open RPF Explorer" ;
jtExplorer . CustomCategory = "Launch Options" ;
var jtVehicles = new JumpTask ( ) ;
jtVehicles . ApplicationPath = cwpath ;
jtVehicles . IconResourcePath = Path . Combine ( cwdir , "CodeWalker Vehicle Viewer.exe" ) ;
jtVehicles . WorkingDirectory = cwdir ;
jtVehicles . Arguments = "vehicles" ;
jtVehicles . Title = "Vehicle Viewer" ;
jtVehicles . Description = "Open Vehicle Viewer" ;
jtVehicles . CustomCategory = "Launch Options" ;
var jtPeds = new JumpTask ( ) ;
jtPeds . ApplicationPath = cwpath ;
jtPeds . IconResourcePath = Path . Combine ( cwdir , "CodeWalker Ped Viewer.exe" ) ;
jtPeds . WorkingDirectory = cwdir ;
jtPeds . Arguments = "peds" ;
jtPeds . Title = "Ped Viewer" ;
jtPeds . Description = "Open Ped Viewer" ;
jtPeds . CustomCategory = "Launch Options" ;
var jumpList = new JumpList ( ) ;
jumpList . JumpItems . Add ( jtWorld ) ;
jumpList . JumpItems . Add ( jtExplorer ) ;
jumpList . JumpItems . Add ( jtVehicles ) ;
jumpList . JumpItems . Add ( jtPeds ) ;
jumpList . Apply ( ) ;
Settings . Default . JumpListInitialised = true ;
Settings . Default . Save ( ) ;
}
catch
{ }
}
2017-09-21 18:33:05 +08:00
}
}