void Window1_Loaded(object sender, RoutedEventArgs e)
        {
            Logging.Setup();
            Logging.AddToAuthorun();
            ShowInTaskbar = false;
            RegisterHotkey();
            
            _Model = new Model();
            this.DataContext = _Model;
            foreach (string s in Environment.GetCommandLineArgs())
            {
                if (File.Exists(s) && System.IO.Path.GetExtension(s) != ".exe")
                {
                    _Model.Open(s);
                }
            }
            if (!_Model._Loaded) _Model.Load();
            KeyDown += new KeyEventHandler(Window1_KeyDown);
            Closed += new EventHandler(Window1_Closed);
            
            Closing += new System.ComponentModel.CancelEventHandler(Window1_Closing);
            App.Current.Deactivated += new EventHandler(Current_Deactivated);
            _RitchTextBox.Focus();
            _RitchTextBox.TextChanged += new TextChangedEventHandler(RitchTextBox_TextChanged);

            new DispatcherTimer().StartRepeatMethod(60 * 10, Update);
            this.Show(); 
           
            
        }
Example #2
0
        public static Vehicle CreateVehicle(Model model, Vector3 position)
        {
            model.Load();
            var car = Internal.Function.Call<Vehicle>(0x00a5, model, position);
            model.Release();

            return car;
        }
Example #3
0
 public static Model RequestModel(string hash)
 {
     var model = new Model(hash);
     while (!model.IsLoaded)
     {
         model.Load();
         model.LoadCollision();
         GameFiber.Yield();
     }
     return model;
 }
Example #4
0
        public static Pickup CreatePickup(Vector3 position, Model model, PickupType type)
        {
            model.Load();

            var retval = Internal.Function.Call<Pickup>(0x0213, model, (int)type, position);
            PickupHandler.Register(retval);

            model.Release();

            retval._origPos = position;
            return retval;
        }
Example #5
0
        public static Ped CreatePed(Model model, Vector3 position, int pedtype)
        {
            if (model.ID >= 290 && model.ID <= 299)
            {
                return Internal.Function.Call<Ped>(0x009a, pedtype, model, position);
            }

            model.Load();
            var ped = Internal.Function.Call<Ped>(0x009a, pedtype, model, position);
            model.Release();

            return ped;
        }
Example #6
0
 public void Load()
 {
     Model model = new Model(Model);
     model.Load();
 }
Example #7
0
        static void Main(string[] args)
        {
            try
            {
                var currentAssembly = Assembly.GetExecutingAssembly();
                Console.WriteLine("{0}, Version {1}", currentAssembly.GetCustomAttribute<AssemblyTitleAttribute>().Title, currentAssembly.GetName().Version.ToString());
                Console.WriteLine(currentAssembly.GetCustomAttribute<AssemblyCopyrightAttribute>().Copyright);
                Console.WriteLine();

                //If arguments parsing become more complex Consider using NDesk.Option

                if (args.Length == 0)
                    ShowUsageAndExit();

                for (int index = 0; index < args.Length;)
                {
                    var command = args[index++].ToLower();
                    switch (command)
                    {
                        case "-v":
                        case "--verbose":
                            if (index < args.Length && args[index][0] != '-') // no "-v blabla"
                                ShowUsageAndExit("--verbose shouldn't have any parameters");

                            Verbose = true;
                            break;
                        case "-h":
                        case "--help":
                            ShowUsageAndExit();
                            break;
                        case "-p":
                        case "--platform":
                            if (index >= args.Length || args[index][0] == '-') //no -p -i
                                ShowUsageAndExit("You must define a platform after --platform");

                            var builderName = args[index++];
                            if (Builder != null ||  //no -p java -i file.spml -p xamarin
                                (index < args.Length && args[index][0] != '-')) //no -p java xamarin
                                ShowUsageAndExit("Only one builder");

                            if (!Builders.TryGetValue(builderName, out Builder)) //no -p unknown
                                ShowUsageAndExit("Unknown platform");
                            break;
                        case "-i":
                        case "--input":
                            if (index >= args.Length || args[index][0] == '-')
                                ShowUsageAndExit("Input must be specified.");

                            do
                                Sources.Add(args[index++]);
                            while (index < args.Length && args[index][0] != '-');

                            break;
                        case "-o":
                        case "--output":
                            if (index >= args.Length || args[index][0] == '-')
                                ShowUsageAndExit("Output must be specified.");

                            var destination = args[index++];
                            if (Destination != null ||
                                (index < args.Length && args[index][0] != '-'))
                                ShowUsageAndExit("Only one output");

                            Destination = destination;
                            break;
                        case "-f":
                        case "--format":
                            if (index >= args.Length || args[index][0] == '-')
                                ShowUsageAndExit("Format must be specified.");

                            var format = args[index++];
                            if (Format != null ||
                                (index < args.Length && args[index][0] != '-'))
                                ShowUsageAndExit("Only one format");

                            Format = format;
                            break;
                        case "-n":
                        case "--namespace":
                            if (index >= args.Length || args[index][0] == '-')
                                ShowUsageAndExit("Namespace must be specified.");

                            var ns = args[index++];
                            if (Namespace != null ||  //already set by previex --platform
                                (index < args.Length && args[index][0] != '-')) //if the next argument is not a command
                                ShowUsageAndExit("Only one namespace");

                            Namespace = ns;
                            break;
                    }

                }

                if (Builder == null)
                    ShowUsageAndExit("Platform must be specified.");

                if (Sources.Count <= 0)
                    ShowUsageAndExit("Source must be specified.");

                // Get Model
                Model = new Model();

                foreach (var source in Sources)
                {
                    var modelFile = source.TrimEnd('/');

                    if (modelFile.EndsWith("/spml/all", StringComparison.CurrentCultureIgnoreCase))
                    {
                        using (var client = new HttpClient())
                        {
                            var result = client.GetAsync(modelFile).Result;
                            if (result.IsSuccessStatusCode)
                            {
                                var protocols = result.Content.ReadAsStringAsync().Result.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                                if (protocols.Length > 0)
                                {
                                    var baseUrl = modelFile.Substring(0, modelFile.Length - 4);
                                    foreach (var protocol in protocols)
                                    {
                                        Console.WriteLine("Building Protocol: " + protocol + "...");
                                        Model.Load(string.Format("{0}?file={1}", baseUrl, protocol));
                                    }
                                }
                                else
                                    ShowUsageAndExit("No Protocols");
                            }
                            else
                                ShowUsageAndExit("Host unreachable");
                        }
                    }
                    else
                        Model.Load(modelFile);
                }

                Builder.Build(Model,Destination,Format);
            }
            catch (Exception ex)
            {
            #if DEBUG
                if (System.Diagnostics.Debugger.IsAttached)
                    System.Diagnostics.Debugger.Break();
            #endif

                if (ex is ProtocolMalformedException)
                    Program.ShowUsageAndExit(ex.Message);
                if (ex is FileNotFoundException)
                    Program.ShowUsageAndExit(ex.Message);

                Program.ShowUsageAndExit(string.Format("An unexpected error has occured : {0}", ex.StackTrace));
            }
        }
 public void Init( Microsoft.Xna.Framework.Game game )
 {
     _model = new Model( (Game1) game );
     _model.Load( GameStatePlayMenu.MapToPlay );
     _model.Start();
 }