Beispiel #1
0
 public CardRun(ChatCard card)
     : base(new Run(card.ToString()))
 {
     this.FontWeight = FontWeights.Bold;
     this.Foreground = Brushes.DarkSlateGray;
     this.Cursor     = Cursors.Hand;
     _card           = card;
     _card.UpdateCardText((model, gamecard) =>
     {
         (this.Inlines.FirstInline as Run).Text = model.PropertyName();
     });
 }
Beispiel #2
0
 public CardModelEventArgs(ChatCard model, RoutedEvent routedEvent, object source)
     : base(routedEvent, source)
 {
     CardModel = model;
 }
 public CardModelEventArgs(ChatCard model, RoutedEvent routedEvent, object source)
     : base(routedEvent, source)
 {
     CardModel = model;
 }
 public CardRun(ChatCard card)
     : base(new Run(card.ToString()))
 {
     this.FontWeight = FontWeights.Bold;
     this.Foreground = Brushes.DarkSlateGray;
     this.Cursor = Cursors.Hand;
     _card = card;
     _card.UpdateCardText((model, gamecard) =>
         {
             (this.Inlines.FirstInline as Run).Text = model.PropertyName();
         });
 }
Beispiel #5
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.Site = 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);
            }

            // Check if running on network drive
            try
            {
                Log.Info("Check if running on network drive");
                var myDocs = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                //var myDocs = "\\\\";
                if (myDocs.StartsWith("\\\\") && !CheckNetworkFixInstalled())
                {
                    var res = MessageBox.Show(String.Format(
                        @"Your system is currently running on a network share. '{0}'

This will cause OCTGN not to function properly. At this time, the only work around is to install OCTGN on a machine that doesn't map your folders onto a network drive.

You can still use OCTGN, but it most likely won't work.

Would you like to visit our help page for solutions to this problem?", myDocs),
                        "ERROR", MessageBoxButton.YesNoCancel, MessageBoxImage.Error);

                    if (res == MessageBoxResult.Yes)
                    {
                        LaunchUrl("http://help.octgn.net/solution/articles/4000006491-octgn-on-network-share-mac");
                        shutDown = true;
                    }
                    else if (res == MessageBoxResult.No)
                    {

                    }
                    else
                    {
                        shutDown = true;
                    }
                }

            }
            catch (Exception e)
            {
                Log.Warn("Check if running on network drive failed", e);
                throw;
            }

            Log.Info("Creating Lobby Client");
            LobbyClient = new Skylabs.Lobby.Client(LobbyConfig.Get());
            //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");
                    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();

            if (launcher.Shutdown)
            {
                if (Application.Current.MainWindow != null)
                    Application.Current.MainWindow.Close();
                return;
            }
        }
Beispiel #6
0
        static Program()
        {
            Log.Info("Constructng Program");
            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.Site = 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);
            }

            // Check if running on network drive
            try
            {
                Log.Info("Check if running on network drive");
                var myDocs = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                //var myDocs = "\\\\";
                if (myDocs.StartsWith("\\\\"))
                {
                    var res = MessageBox.Show(String.Format(
                        @"Your system is currently running on a network share. '{0}'

This will cause OCTGN not to function properly. At this time, the only work around is to install OCTGN on a machine that doesn't map your folders onto a network drive.

You can still use OCTGN, but it most likely won't work.

Would you like to visit our help page for solutions to this problem?", myDocs),
                        "ERROR", MessageBoxButton.YesNoCancel, MessageBoxImage.Error);

                    if (res == MessageBoxResult.Yes)
                    {
                        LaunchUrl("http://help.octgn.net/solution/articles/4000006491-octgn-on-network-share-mac");
                        shutDown = true;
                    }
                    else if (res == MessageBoxResult.No)
                    {

                    }
                    else
                    {
                        shutDown = true;
                    }
                }

            }
            catch (Exception e)
            {
                Log.Warn("Check if running on network drive failed", e);
                throw;
            }

            Log.Info("Creating Lobby Client");
            LobbyClient = new Skylabs.Lobby.Client(LobbyConfig.Get());
            //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();
            Log.Info("Finished Constructing Program");
        }
Beispiel #7
0
        static Program()
        {
            GameMessage.MuteChecker = () =>
            {
                if (Program.Client == null) return false;
                return Program.Client.Muted != 0;
            };
            Log.Info("Starting OCTGN");
            Octgn.Site.Api.ApiClient.Site = 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.
            }

            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");
            LobbyClient = new Skylabs.Lobby.Client(LobbyConfig.Get());
            //Log.Info("Adding trace listeners");
            //Debug.Listeners.Add(DebugListener);
            //DebugTrace.Listeners.Add(DebugListener);
            //Trace.Listeners.Add(DebugListener);
            //ChatLog = new CacheTraceListener();
            //Trace.Listeners.Add(ChatLog);
            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();
        }