コード例 #1
0
        protected void WarningScreenTick(WarningScreen screen)
        {
            string         identifier = (string)screen.Metadata;
            DownloadedItem item;

            if (!game.AsyncDownloader.TryGetItem(identifier, out item) || item.Data == null)
            {
                return;
            }

            long contentLength = (long)item.Data;

            if (contentLength <= 0)
            {
                return;
            }
            string url = identifier.Substring(3);

            float  contentLengthMB = (contentLength / 1024f / 1024f);
            string address         = url;

            if (url.StartsWith("https://"))
            {
                address = url.Substring(8);
            }
            if (url.StartsWith("http://"))
            {
                address = url.Substring(7);
            }

            screen.SetTextData("Do you want to download the server's texture pack?",
                               "Texture pack url:", address,
                               "Download size: " + contentLengthMB.ToString("F3") + " MB");
            screen.RedrawText();
        }
コード例 #2
0
        protected internal void RetrieveTexturePack(string url)
        {
            if (!game.AcceptedUrls.HasEntry(url) && !game.DeniedUrls.HasEntry(url))
            {
                game.AsyncDownloader.RetrieveContentLength(url, true, "CL_" + url);
                string address = url;
                if (url.StartsWith("https://"))
                {
                    address = url.Substring(8);
                }
                if (url.StartsWith("http://"))
                {
                    address = url.Substring(7);
                }

                WarningScreen warning = new WarningScreen(game, true, true);
                warning.Metadata = "CL_" + url;
                warning.SetHandlers(DownloadTexturePack, SkipTexturePack, WarningScreenTick);

                warning.SetTextData(
                    "Do you want to download the server's texture pack?",
                    "Texture pack url:", address,
                    "Download size: Determining...");
                game.Gui.ShowWarning(warning);
            }
            else
            {
                DownloadTexturePack(url);
            }
        }
コード例 #3
0
 void OpenUrl(WarningScreen screen)
 {
     try {
         Process.Start((string)screen.Metadata);
     } catch (Exception ex) {
         ErrorHandler.LogError("ChatScreen.OpenUrl", ex);
     }
 }
コード例 #4
0
 void AppendUrl(WarningScreen screen)
 {
     if (!game.ClickableChat)
     {
         return;
     }
     textInput.AppendText((string)screen.Metadata);
 }
コード例 #5
0
        void Deny(WarningScreen warning, bool always)
        {
            string plugin = (string)warning.Metadata;

            if (always && !denied.HasEntry(plugin))
            {
                denied.AddEntry(plugin);
            }
        }
コード例 #6
0
        void SkipTexturePack(WarningScreen screen, bool always)
        {
            string url = ((string)screen.Metadata).Substring(3);

            if (always && !game.DeniedUrls.HasEntry(url))
            {
                game.DeniedUrls.AddEntry(url);
            }
        }
コード例 #7
0
        void DownloadTexturePack(WarningScreen screen, bool always)
        {
            string url = ((string)screen.Metadata).Substring(3);

            DownloadTexturePack(url);
            if (always && !game.AcceptedUrls.HasEntry(url))
            {
                game.AcceptedUrls.AddEntry(url);
            }
        }
コード例 #8
0
        internal void MakeWarning(Game game, string plugin)
        {
            WarningScreen warning = new WarningScreen(game, true, false);

            warning.Metadata = plugin;
            warning.SetHandlers(Accept, Deny, null);

            warning.SetTextData(
                "&eAre you sure you want to load plugin " + plugin + " ?",
                "Be careful - plugins from strangers may have viruses",
                " or other malicious behaviour.");
            game.Gui.ShowWarning(warning);
        }
コード例 #9
0
        void Accept(WarningScreen warning, bool always)
        {
            string plugin = (string)warning.Metadata;

            if (always && !accepted.HasEntry(plugin))
            {
                accepted.AddEntry(plugin);
            }

            string dir = Path.Combine(Program.AppDirectory, "plugins");

            Load(Path.Combine(dir, plugin + ".dll"), true);
        }
コード例 #10
0
        public void ShowWarning(WarningScreen screen)
        {
            bool cursorVis = game.CursorVisible;

            if (overlays.Count == 0)
            {
                game.CursorVisible = true;
            }
            overlays.Add(screen);
            if (overlays.Count == 1)
            {
                game.CursorVisible = cursorVis;
            }
            // Save cursor visibility state
            screen.Init();
        }
コード例 #11
0
ファイル: Game.cs プロジェクト: MINERGUY67880/ClassicalSharp
        public void ShowWarning(WarningScreen screen)
        {
            if (!(activeScreen is WarningScreen))
            {
                screen.lastScreen = activeScreen;
                activeScreen      = screen;

                screen.lastCursorVisible = CursorVisible;
                if (!CursorVisible)
                {
                    CursorVisible = true;
                }
            }
            else
            {
                screen.lastCursorVisible = WarningScreens[0].lastCursorVisible;
            }
            WarningScreens.Add(screen);
            screen.Init();
        }
コード例 #12
0
ファイル: Game.cs プロジェクト: MINERGUY67880/ClassicalSharp
        public void SetNewScreen(Screen screen, bool disposeOld)
        {
            // don't switch to the new screen immediately if the user
            // is currently looking at a warning dialog.
            if (activeScreen is WarningScreen)
            {
                WarningScreen warning = (WarningScreen)activeScreen;
                if (warning.lastScreen != null)
                {
                    warning.lastScreen.Dispose();
                }

                warning.lastScreen = screen;
                if (warning.lastScreen != null)
                {
                    screen.Init();
                }
                return;
            }
            InputHandler.ScreenChanged(activeScreen, screen);
            if (activeScreen != null && disposeOld)
            {
                activeScreen.Dispose();
            }

            if (screen == null)
            {
                hudScreen.GainFocus();
            }
            else if (activeScreen == null)
            {
                hudScreen.LoseFocus();
            }

            if (screen != null)
            {
                screen.Init();
            }
            activeScreen = screen;
        }
コード例 #13
0
        void WarningScreenTick(WarningScreen screen)
        {
            string         identifier = (string)screen.Metadata;
            DownloadedItem item;

            if (!game.AsyncDownloader.TryGetItem(identifier, out item) || item.Data == null)
            {
                return;
            }

            long contentLength = (long)item.Data;

            if (contentLength <= 0)
            {
                return;
            }
            string url = identifier.Substring(3);

            float contentLengthMB = (contentLength / 1024f / 1024f);

            screen.SetText("Do you want to download the server's terrain image?",
                           "The terrain image is located at:", url,
                           "Terrain image size: " + contentLengthMB.ToString("F3") + " MB");
        }
コード例 #14
0
ファイル: Game.cs プロジェクト: andrewphorn/ClassicalSharp
        public void ShowWarning( WarningScreen screen )
        {
            if( !(activeScreen is WarningScreen) ) {
                screen.lastScreen = activeScreen;
                activeScreen = screen;

                screen.lastCursorVisible = CursorVisible;
                if( !CursorVisible) CursorVisible = true;
            } else {
                screen.lastCursorVisible = WarningScreens[0].lastCursorVisible;
            }
            WarningScreens.Add( screen );
            screen.Init();
        }
コード例 #15
0
 void OpenUrl( WarningScreen screen )
 {
     try {
         Process.Start( (string)screen.Metadata );
     } catch( Exception ex ) {
         ErrorHandler.LogError( "ChatScreen.OpenUrl", ex );
     }
 }
コード例 #16
0
		void DownloadTexturePack( WarningScreen screen ) { 
			DownloadTexturePack( ((string)screen.Metadata).Substring( 3 ) );
		}
コード例 #17
0
		void WarningScreenTick( WarningScreen screen ) {
			string identifier = (string)screen.Metadata;
			DownloadedItem item;
			if( !game.AsyncDownloader.TryGetItem( identifier, out item ) || item.Data == null ) return;
			
			long contentLength = (long)item.Data;
			if( contentLength <= 0 ) return;
			string url = identifier.Substring( 3 );
			
			float contentLengthMB = (contentLength / 1024f / 1024f );
			screen.SetText( "Do you want to download the server's terrain image?",
			               "The terrain image is located at:", url,
			               "Terrain image size: " + contentLengthMB.ToString( "F3" ) + " MB" );
		}
コード例 #18
0
 void DownloadTexturePack(WarningScreen screen)
 {
     DownloadTexturePack(((string)screen.Metadata).Substring(3));
 }
コード例 #19
0
 void AppendUrl( WarningScreen screen )
 {
     textInput.AppendText( (string)screen.Metadata );
 }