Exemplo n.º 1
0
        internal static void Start(string[] args)
        {
            //var win = new ShareDeck();
            //win.ShowDialog();
            //return;
            var launcher = CommandLineHandler.Instance.HandleArguments(Environment.GetCommandLineArgs());

            DeveloperMode = CommandLineHandler.Instance.DevMode;

            Versioned.Setup(Program.DeveloperMode);
            /* This section is automatically generated from the file Scripting/ApiVersions.xml. So, if you enjoy not getting pissed off, don't modify it.*/
            //START_REPLACE_API_VERSION
            Versioned.RegisterVersion(Version.Parse("3.1.0.0"), DateTime.Parse("2014-1-12"), ReleaseMode.Live);
            Versioned.RegisterVersion(Version.Parse("3.1.0.1"), DateTime.Parse("2014-1-22"), ReleaseMode.Test);
            Versioned.RegisterFile("PythonApi", "pack://application:,,,/Scripting/Versions/3.1.0.0.py", Version.Parse("3.1.0.0"));
            Versioned.RegisterFile("PythonApi", "pack://application:,,,/Scripting/Versions/3.1.0.1.py", Version.Parse("3.1.0.1"));
            //END_REPLACE_API_VERSION
            Versioned.Register <ScriptApi>();

            launcher.Launch();

            if (launcher.Shutdown)
            {
                if (Application.Current.MainWindow != null)
                {
                    Application.Current.MainWindow.Close();
                }
                return;
            }
        }
Exemplo n.º 2
0
 public void Get_Throws_IfNoTypeForVersionRegistered()
 {
     SetDebug(false);
     Versioned.Setup(false);
     Versioned.RegisterVersion(new Version(3, 1, 0, 0), DateTime.MinValue, ReleaseMode.Live);
     Versioned.RegisterVersion(new Version(3, 1, 0, 1), DateTime.MinValue, ReleaseMode.Live);
     Versioned.Register <TestTypeBase>();
     Assert.Throws <InvalidOperationException>(() =>
     {
         var g = Versioned.Get <TestTypeBase>(new Version(3, 1, 0, 2));
     });
 }
Exemplo n.º 3
0
        public void ValidVersion_ReturnsFalseIfVersionNotRegistered()
        {
            SetDebug(false);
            Versioned.Setup(false);
            Versioned.RegisterVersion(new Version(3, 1, 0, 0), DateTime.MinValue, ReleaseMode.Live);

            Versioned.Register <TestTypeBase>();

            var val = Versioned.ValidVersion(new Version(3, 1, 0, 1));

            Assert.False(val);
        }
Exemplo n.º 4
0
        public void ValidVersion_WorksProperlyForDeveloperMode()
        {
            SetDebug(true);
            Versioned.Setup(false);
            Versioned.RegisterVersion(new Version(3, 1, 0, 0), DateTime.MinValue, ReleaseMode.Live);
            Versioned.RegisterVersion(new Version(3, 1, 0, 1), DateTime.MinValue, ReleaseMode.Test);

            Versioned.Register <TestTypeBase>();

            var val = Versioned.ValidVersion(new Version(3, 1, 0, 1));

            Assert.True(val);
        }
Exemplo n.º 5
0
        public void Get_ReturnsProperVersionInLive()
        {
            SetDebug(false);
            Versioned.Setup(false);
            Versioned.RegisterVersion(new Version(3, 1, 0, 0), DateTime.MinValue, ReleaseMode.Live);
            Versioned.RegisterVersion(new Version(3, 1, 0, 1), DateTime.MinValue, ReleaseMode.Test);

            Versioned.Register <TestTypeBase>();

            var val = Versioned.Get <TestTypeBase>(new Version(3, 1, 0, 0));

            Assert.AreEqual(typeof(TestType_3_1_0_0), val.GetType());
        }
Exemplo n.º 6
0
 private void LoadSync()
 {
     Versioned.Setup(Program.DeveloperMode);
     /* This section is automatically generated from the file Scripting/ApiVersions.xml. So, if you enjoy not getting pissed off, don't modify it.*/
     //START_REPLACE_API_VERSION
     Versioned.RegisterVersion(Version.Parse("3.1.0.0"), DateTime.Parse("2014-1-12", System.Globalization.CultureInfo.InvariantCulture), ReleaseMode.Live);
     Versioned.RegisterVersion(Version.Parse("3.1.0.1"), DateTime.Parse("2014-1-22", System.Globalization.CultureInfo.InvariantCulture), ReleaseMode.Live);
     Versioned.RegisterVersion(Version.Parse("3.1.0.2"), DateTime.Parse("2015-8-26", System.Globalization.CultureInfo.InvariantCulture), ReleaseMode.Live);
     Versioned.RegisterFile("PythonApi", "pack://application:,,,/Scripting/Versions/3.1.0.0.py", Version.Parse("3.1.0.0"));
     Versioned.RegisterFile("PythonApi", "pack://application:,,,/Scripting/Versions/3.1.0.1.py", Version.Parse("3.1.0.1"));
     Versioned.RegisterFile("PythonApi", "pack://application:,,,/Scripting/Versions/3.1.0.2.py", Version.Parse("3.1.0.2"));
     //END_REPLACE_API_VERSION
     Versioned.Register <ScriptApi>();
 }
Exemplo n.º 7
0
        public void Get_Throws_IfRequestedVersionIsTestAndWeAreInLive()
        {
            Versioned.Setup(false);
            SetDebug(false);
            var curx  = X.Instance;
            var testx = A.Fake <IX>();

            A.CallTo(() => testx.Debug).Returns(false);
            X.SingletonContext = testx;

            Versioned.RegisterVersion(new Version(3, 1, 0, 0), DateTime.MinValue, ReleaseMode.Live);
            Versioned.RegisterVersion(new Version(3, 1, 0, 1), DateTime.MinValue, ReleaseMode.Test);
            Versioned.Register <TestTypeBase>();
            Assert.Throws <InvalidOperationException>(() =>
            {
                var g = Versioned.Get <TestTypeBase>(new Version(3, 1, 0, 1));
            });

            X.SingletonContext = curx;
        }
Exemplo n.º 8
0
        internal static void Start(string[] args, bool isTestRelease)
        {
            Log.Info("Start");
            IsReleaseTest           = isTestRelease;
            GameMessage.MuteChecker = () =>
            {
                if (Program.Client == null)
                {
                    return(false);
                }
                return(Program.Client.Muted != 0);
            };

            Log.Info("Setting SSL Validation Helper");
            SSLHelper = new SSLValidationHelper();

            Log.Info("Setting api path");
            Octgn.Site.Api.ApiClient.DefaultUrl = new Uri(AppConfig.WebsitePath);
            try
            {
                Log.Debug("Setting rendering mode.");
                RenderOptions.ProcessRenderMode = Prefs.UseHardwareRendering ? RenderMode.Default : RenderMode.SoftwareOnly;
            }
            catch (Exception)
            {
                // if the system gets mad, best to leave it alone.
            }

            Log.Info("Setting temp main window");
            Application.Current.MainWindow = new Window();
            try
            {
                Log.Info("Checking if admin");
                var isAdmin = UacHelper.IsProcessElevated && UacHelper.IsUacEnabled;
                if (isAdmin)
                {
                    MessageBox.Show(
                        "You are currently running OCTGN as Administrator. It is recommended that you run as a standard user, or you will most likely run into problems. Please exit OCTGN and run as a standard user.",
                        "WARNING",
                        MessageBoxButton.OK,
                        MessageBoxImage.Exclamation);
                }
            }
            catch (Exception e)
            {
                Log.Warn("Couldn't check if admin", e);
            }

            Log.Info("Creating Lobby Client");
            var handshaker        = new DefaultHandshaker();
            var connectionCreator = new TcpConnectionCreator(handshaker);
            var lobbyClientConfig = new LibraryCommunicationClientConfig(connectionCreator);

            LobbyClient = new Octgn.Library.Communication.Client(lobbyClientConfig, typeof(Program).Assembly.GetName().Version);

            //Log.Info("Adding trace listeners");
            //Debug.Listeners.Add(DebugListener);
            //DebugTrace.Listeners.Add(DebugListener);
            //Trace.Listeners.Add(DebugListener);
            //ChatLog = new CacheTraceListener();
            //Trace.Listeners.Add(ChatLog);
            Log.Info("Creating Game Message Dispatcher");
            GameMess = new GameMessageDispatcher();
            GameMess.ProcessMessage(
                x =>
            {
                for (var i = 0; i < x.Arguments.Length; i++)
                {
                    var arg       = x.Arguments[i];
                    var cardModel = arg as DataNew.Entities.Card;
                    var cardId    = arg as CardIdentity;
                    var card      = arg as Card;
                    if (card != null && (card.FaceUp || card.MayBeConsideredFaceUp))
                    {
                        cardId = card.Type;
                    }

                    if (cardId != null || cardModel != null)
                    {
                        ChatCard chatCard = null;
                        if (cardId != null)
                        {
                            chatCard = new ChatCard(cardId);
                        }
                        else
                        {
                            chatCard = new ChatCard(cardModel);
                        }
                        if (card != null)
                        {
                            chatCard.SetGameCard(card);
                        }
                        x.Arguments[i] = chatCard;
                    }
                    else
                    {
                        x.Arguments[i] = arg == null ? "[?]" : arg.ToString();
                    }
                }
                return(x);
            });

            Log.Info("Registering versioned stuff");

            //BasePath = Path.GetDirectoryName(typeof (Program).Assembly.Location) + '\\';
            Log.Info("Setting Games Path");
            GameSettings = new GameSettings();
            if (shutDown)
            {
                Log.Info("Shutdown Time");
                if (Application.Current.MainWindow != null)
                {
                    Application.Current.MainWindow.Close();
                }
                return;
            }

            Log.Info("Decide to ask about wine");
            if (Prefs.AskedIfUsingWine == false)
            {
                Log.Info("Asking about wine");
                var res = MessageBox.Show("Are you running OCTGN on Linux or a Mac using Wine?", "Using Wine",
                                          MessageBoxButton.YesNo, MessageBoxImage.Question);
                if (res == MessageBoxResult.Yes)
                {
                    Prefs.AskedIfUsingWine      = true;
                    Prefs.UsingWine             = true;
                    Prefs.UseHardwareRendering  = false;
                    Prefs.UseGameFonts          = false;
                    Prefs.UseWindowTransparency = false;
                }
                else if (res == MessageBoxResult.No)
                {
                    Prefs.AskedIfUsingWine      = true;
                    Prefs.UsingWine             = false;
                    Prefs.UseHardwareRendering  = true;
                    Prefs.UseGameFonts          = true;
                    Prefs.UseWindowTransparency = true;
                }
            }
            // Check for desktop experience
            if (Prefs.UsingWine == false)
            {
                try
                {
                    Log.Debug("Checking for Desktop Experience");
                    var objMC = new ManagementClass("Win32_ServerFeature");
                    // Expected Exception: System.Management.ManagementException
                    // Additional information: Not found
                    var  objMOC = objMC.GetInstances();
                    bool gotIt  = false;
                    foreach (var objMO in objMOC)
                    {
                        if ((UInt32)objMO["ID"] == 35)
                        {
                            Log.Debug("Found Desktop Experience");
                            gotIt = true;
                            break;
                        }
                    }
                    if (!gotIt)
                    {
                        var res =
                            MessageBox.Show(
                                "You are running OCTGN without the windows Desktop Experience installed. This WILL cause visual, gameplay, and sound issues. Though it isn't required, it is HIGHLY recommended. \n\nWould you like to be shown a site to tell you how to turn it on?",
                                "Windows Desktop Experience Missing", MessageBoxButton.YesNo,
                                MessageBoxImage.Exclamation);
                        if (res == MessageBoxResult.Yes)
                        {
                            LaunchUrl(
                                "http://blogs.msdn.com/b/findnavish/archive/2012/06/01/enabling-win-7-desktop-experience-on-windows-server-2008.aspx");
                        }
                        else
                        {
                            MessageBox.Show("Ok, but you've been warned...", "Warning", MessageBoxButton.OK,
                                            MessageBoxImage.Warning);
                        }
                    }
                }
                catch (Exception e)
                {
                    Log.Warn(
                        "Check desktop experience error. An error like 'Not Found' is normal and shouldn't be worried about",
                        e);
                }
            }
            // Send off user/computer stats
            try
            {
                var osver    = System.Environment.OSVersion.VersionString;
                var osBit    = Win32.Is64BitOperatingSystem;
                var procBit  = Win32.Is64BitProcess;
                var issubbed = SubscriptionModule.Get().IsSubscribed;
                var iswine   = Prefs.UsingWine;
                // Use the API to submit info
            }
            catch (Exception e)
            {
                Log.Warn("Sending stats error", e);
            }
            //var win = new ShareDeck();
            //win.ShowDialog();
            //return;
            Log.Info("Getting Launcher");
            Launchers.ILauncher launcher = CommandLineHandler.Instance.HandleArguments(Environment.GetCommandLineArgs());
            DeveloperMode = CommandLineHandler.Instance.DevMode;

            Versioned.Setup(Program.DeveloperMode);
            /* This section is automatically generated from the file Scripting/ApiVersions.xml. So, if you enjoy not getting pissed off, don't modify it.*/
            //START_REPLACE_API_VERSION
            Versioned.RegisterVersion(Version.Parse("3.1.0.0"), DateTime.Parse("2014-1-12"), ReleaseMode.Live);
            Versioned.RegisterVersion(Version.Parse("3.1.0.1"), DateTime.Parse("2014-1-22"), ReleaseMode.Live);
            Versioned.RegisterVersion(Version.Parse("3.1.0.2"), DateTime.Parse("2015-8-26"), ReleaseMode.Live);
            Versioned.RegisterFile("PythonApi", "pack://application:,,,/Scripting/Versions/3.1.0.0.py", Version.Parse("3.1.0.0"));
            Versioned.RegisterFile("PythonApi", "pack://application:,,,/Scripting/Versions/3.1.0.1.py", Version.Parse("3.1.0.1"));
            Versioned.RegisterFile("PythonApi", "pack://application:,,,/Scripting/Versions/3.1.0.2.py", Version.Parse("3.1.0.2"));
            //END_REPLACE_API_VERSION
            Versioned.Register <ScriptApi>();

            launcher.Launch().Wait();

            if (launcher.Shutdown)
            {
                if (Application.Current.MainWindow != null)
                {
                    Application.Current.MainWindow.Close();
                }
                return;
            }
        }
Exemplo n.º 9
0
        internal static void Start(string[] args)
        {
            Log.Info("Start");
            if (shutDown)
            {
                Log.Info("Shutdown Time");
                if (Application.Current.MainWindow != null)
                {
                    Application.Current.MainWindow.Close();
                }
                return;
            }

            Log.Info("Decide to ask about wine");
            if (Prefs.AskedIfUsingWine == false)
            {
                Log.Info("Asking about wine");
                var res = MessageBox.Show("Are you running OCTGN on Linux or a Mac using Wine?", "Using Wine",
                                          MessageBoxButton.YesNo, MessageBoxImage.Question);
                if (res == MessageBoxResult.Yes)
                {
                    Prefs.AskedIfUsingWine      = true;
                    Prefs.UsingWine             = true;
                    Prefs.UseHardwareRendering  = false;
                    Prefs.UseGameFonts          = false;
                    Prefs.UseWindowTransparency = false;
                }
                else if (res == MessageBoxResult.No)
                {
                    Prefs.AskedIfUsingWine      = true;
                    Prefs.UsingWine             = false;
                    Prefs.UseHardwareRendering  = true;
                    Prefs.UseGameFonts          = true;
                    Prefs.UseWindowTransparency = true;
                }
            }
            // Check for desktop experience
            if (Prefs.UsingWine == false)
            {
                try
                {
                    Log.Debug("Checking for Desktop Experience");
                    var  objMC  = new ManagementClass("Win32_ServerFeature");
                    var  objMOC = objMC.GetInstances();
                    bool gotIt  = false;
                    foreach (var objMO in objMOC)
                    {
                        if ((UInt32)objMO["ID"] == 35)
                        {
                            Log.Debug("Found Desktop Experience");
                            gotIt = true;
                            break;
                        }
                    }
                    if (!gotIt)
                    {
                        var res =
                            MessageBox.Show(
                                "You are running OCTGN without the windows Desktop Experience installed. This WILL cause visual, gameplay, and sound issues. Though it isn't required, it is HIGHLY recommended. \n\nWould you like to be shown a site to tell you how to turn it on?",
                                "Windows Desktop Experience Missing", MessageBoxButton.YesNo,
                                MessageBoxImage.Exclamation);
                        if (res == MessageBoxResult.Yes)
                        {
                            LaunchUrl(
                                "http://blogs.msdn.com/b/findnavish/archive/2012/06/01/enabling-win-7-desktop-experience-on-windows-server-2008.aspx");
                        }
                        else
                        {
                            MessageBox.Show("Ok, but you've been warned...", "Warning", MessageBoxButton.OK,
                                            MessageBoxImage.Warning);
                        }
                    }
                }
                catch (Exception e)
                {
                    Log.Warn(
                        "Check desktop experience error. An error like 'Not Found' is normal and shouldn't be worried about",
                        e);
                }
            }

            //var win = new ShareDeck();
            //win.ShowDialog();
            //return;
            Log.Info("Getting Launcher");
            Launchers.ILauncher launcher = CommandLineHandler.Instance.HandleArguments(Environment.GetCommandLineArgs());
            DeveloperMode = CommandLineHandler.Instance.DevMode;

            Versioned.Setup(Program.DeveloperMode);
            /* This section is automatically generated from the file Scripting/ApiVersions.xml. So, if you enjoy not getting pissed off, don't modify it.*/
            //START_REPLACE_API_VERSION
            Versioned.RegisterVersion(Version.Parse("3.1.0.0"), DateTime.Parse("2014-1-12"), ReleaseMode.Live);
            Versioned.RegisterVersion(Version.Parse("3.1.0.1"), DateTime.Parse("2014-1-22"), ReleaseMode.Live);
            Versioned.RegisterVersion(Version.Parse("3.1.0.2"), DateTime.Parse("2014-1-22"), ReleaseMode.Test);
            Versioned.RegisterFile("PythonApi", "pack://application:,,,/Scripting/Versions/3.1.0.0.py", Version.Parse("3.1.0.0"));
            Versioned.RegisterFile("PythonApi", "pack://application:,,,/Scripting/Versions/3.1.0.1.py", Version.Parse("3.1.0.1"));
            Versioned.RegisterFile("PythonApi", "pack://application:,,,/Scripting/Versions/3.1.0.2.py", Version.Parse("3.1.0.2"));
            //END_REPLACE_API_VERSION
            Versioned.Register <ScriptApi>();

            launcher.Launch();

            if (launcher.Shutdown)
            {
                if (Application.Current.MainWindow != null)
                {
                    Application.Current.MainWindow.Close();
                }
                return;
            }
        }