Ejemplo n.º 1
0
 public GameForm(CommandLineOptions commandLineOptions)
 {
     InitializeComponent();
     InitializeGame(Handle, commandLineOptions);
     InitializeGameForm();
     InitializeGameView();
     InitializeRunner();
 }
Ejemplo n.º 2
0
 public void TestEmptyOptions()
 {
     var opts = new CommandLineOptions(new string[] { }, new NameValueCollection(), "");
     Assert.IsNull(opts.ArenaFilename);
     Assert.IsFalse(opts.DedicatedServer);
     Assert.IsFalse(opts.DeleteTemplates);
     Assert.IsFalse(opts.SaveTemplates);
 }
Ejemplo n.º 3
0
 public void TestCommandLineSet()
 {
     var opts = new CommandLineOptions(new string[] { "--dedicated_server", "delete_templates", "--arena", "foo.xml" }, new NameValueCollection(), "");
     Assert.AreEqual("foo.xml", opts.ArenaFilename);
     Assert.IsTrue(opts.DedicatedServer);
     Assert.IsFalse(opts.DeleteTemplates);
     Assert.IsFalse(opts.SaveTemplates);
 }
Ejemplo n.º 4
0
 public AssaultWingCore(GraphicsDeviceService graphicsDeviceService, CommandLineOptions args)
     : base(graphicsDeviceService)
 {
     Log.Write("Assault Wing version " + MiscHelper.Version);
     CommandLineOptions = args;
     Log.Write("Loading settings from " + MiscHelper.DataDirectory);
     Settings = AWSettings.FromFile(this, MiscHelper.DataDirectory);
     NetworkMode = NetworkMode.Standalone;
     InitializeComponents();
     _standingsTimer = new AWTimer(() => GameTime.TotalRealTime, TimeSpan.FromSeconds(1));
 }
Ejemplo n.º 5
0
 public void TestCommandLineAndArgumentTextSet()
 {
     var argumentText =
     @"arena  =  foo.xml
     dedicated_server=
     save_templates  ";
     var opts = new CommandLineOptions(new string[] { "--arena", "bar.xml", "--dedicated_server", "--delete_templates" }, new NameValueCollection(), argumentText);
     Assert.AreEqual("bar.xml", opts.ArenaFilename);
     Assert.IsTrue(opts.DedicatedServer);
     Assert.IsTrue(opts.DeleteTemplates);
     Assert.IsTrue(opts.SaveTemplates);
 }
Ejemplo n.º 6
0
 public void TestArgumentTextSet()
 {
     var argumentText =
     @"dedicated_server
     save_templates=false
     arena = foo.xml";
     var opts = new CommandLineOptions(new string[] { }, new NameValueCollection(), argumentText);
     Assert.AreEqual("foo.xml", opts.ArenaFilename);
     Assert.IsTrue(opts.DedicatedServer);
     Assert.IsFalse(opts.DeleteTemplates);
     Assert.IsTrue(opts.SaveTemplates);
 }
Ejemplo n.º 7
0
 public static void Main(string[] args)
 {
     Thread.CurrentThread.Name = "MainThread";
     if (MiscHelper.IsNetworkDeployed) Log.Write("Activation URI = '{0}'", ApplicationDeployment.CurrentDeployment.ActivationUri);
     g_commandLineOptions = new CommandLineOptions(Environment.GetCommandLineArgs(), MiscHelper.QueryParams, AssaultWingCore.GetArgumentText());
     PostInstall.EnsureDone();
     AccessibilityShortcuts.ToggleAccessibilityShortcutKeys(returnToStarting: false);
     try
     {
         using (Instance = new AssaultWingProgram())
         {
             Instance.Run();
         }
     }
     finally
     {
         AccessibilityShortcuts.ToggleAccessibilityShortcutKeys(returnToStarting: true);
     }
 }
Ejemplo n.º 8
0
        public AssaultWing(GraphicsDeviceService graphicsDeviceService, CommandLineOptions args)
            : base(graphicsDeviceService, args)
        {
            CustomControls = new List<Tuple<Control, Action>>();
            MessageHandlers = new Net.MessageHandling.MessageHandlers(this);
            if (CommandLineOptions.DedicatedServer)
                Logic = new DedicatedServerLogic(this);
            else if (CommandLineOptions.QuickStart != null)
                Logic = new QuickStartLogic(this, CommandLineOptions.QuickStart);
            else
                Logic = new UserControlledLogic(this);
            ArenaLoadTask = new BackgroundTask();
            NetworkingErrors = new Queue<string>();
            _gameSettingsSendTimer = new AWTimer(() => GameTime.TotalRealTime, TimeSpan.FromSeconds(2)) { SkipPastIntervals = true };
            _arenaStateSendTimer = new AWTimer(() => GameTime.TotalRealTime, TimeSpan.FromSeconds(2)) { SkipPastIntervals = true };
            _frameNumberSynchronizationTimer = new AWTimer(() => GameTime.TotalRealTime, TimeSpan.FromSeconds(1)) { SkipPastIntervals = true };

            NetworkEngine = new NetworkEngine(this, 30);
            WebData = new WebData(this, 21);
            Components.Add(NetworkEngine);
            Components.Add(WebData);
            ChatStartControl = Settings.Controls.Chat.GetControl();
            _frameStepControl = new KeyboardKey(Keys.F8);
            _frameRunControl = new KeyboardKey(Keys.F7);
            _frameStep = false;
            _debugPrintLagTimer = new AWTimer(() => GameTime.TotalRealTime, TimeSpan.FromSeconds(1)) { SkipPastIntervals = true };
            DataEngine.SpectatorAdded += SpectatorAddedHandler;
            DataEngine.SpectatorRemoved += SpectatorRemovedHandler;
            NetworkEngine.Enabled = true;
            AW2.Graphics.PlayerViewport.CustomOverlayCreators.Add(viewport => new SystemStatusOverlay(viewport));

            // Replace the dummy StatsBase by a proper StatsSender.
            Components.Remove(comp => comp is StatsBase);
            Stats = new StatsSender(this, 7);
            Components.Add(Stats);
            Stats.Enabled = true;
        }
Ejemplo n.º 9
0
 private void InitializeGame(IntPtr windowHandle, CommandLineOptions commandLineOptions)
 {
     if (!commandLineOptions.DedicatedServer) _graphicsDeviceService = new GraphicsDeviceService(windowHandle);
     _game = new AssaultWing(_graphicsDeviceService, commandLineOptions);
     AssaultWingCore.Instance = _game; // HACK: support older code that uses the static instance
     _game.Window = new Window(new Window.WindowImpl
     {
         GetTitle = () => Text,
         SetTitle = text => BeginInvoke((Action)(() => Text = text)),
         GetClientBounds = () => _isFullScreen ? ClientRectangle.ToXnaRectangle() : _gameView.ClientRectangle.ToXnaRectangle(),
         GetFullScreen = () => _isFullScreen,
         SetWindowed = () => BeginInvoke((Action)SetWindowed),
         SetFullScreen = (width, height) => BeginInvoke((Action<int, int>)SetFullScreen, width, height),
         IsVerticalSynced = () => _graphicsDeviceService.IsVerticalSynced,
         EnableVerticalSync = () => BeginInvoke((Action)_graphicsDeviceService.EnableVerticalSync),
         DisableVerticalSync = () => BeginInvoke((Action)_graphicsDeviceService.DisableVerticalSync),
         EnsureCursorHidden = () => BeginInvoke((Action)EnsureCursorHidden),
         EnsureCursorShown = () => BeginInvoke((Action)EnsureCursorShown),
     });
     _gameView.Draw += _game.Draw;
     _gameView.ExternalWndProc += WndProcImpl;
     _gameView.Resize += (sender, eventArgs) => _game.DataEngine.RearrangeViewports();
 }
Ejemplo n.º 10
0
 public QuickStartLogic(AssaultWing game, CommandLineOptions.QuickStartOptions options)
     : base(game)
 {
     _options = options;
 }