示例#1
0
        public MessageScreen(ScreenComponent manager, string title, string content, string buttonText = "OK", Action <Control, MouseEventArgs> buttonClick = null) : base(manager)
        {
            assets = manager.Game.Assets;

            IsOverlay  = true;
            Background = new BorderBrush(Color.Black * 0.5f);
            Title      = title;

            panel = new Panel(manager)
            {
                Padding             = Border.All(20),
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center
            };
            Controls.Add(panel);

            StackPanel spanel = new StackPanel(manager);

            panel.Controls.Add(spanel);

            Label headLine = new Label(manager)
            {
                Text = title,
                Font = Skin.Current.HeadlineFont,
                HorizontalAlignment = HorizontalAlignment.Stretch
            };

            spanel.Controls.Add(headLine);

            Label contentLabel = new Label(manager)
            {
                Text = content,
                Font = Skin.Current.TextFont,
                HorizontalAlignment = HorizontalAlignment.Stretch
            };

            spanel.Controls.Add(contentLabel);

            Button closeButton = Button.TextButton(manager, buttonText);

            closeButton.HorizontalAlignment = HorizontalAlignment.Stretch;
            closeButton.LeftMouseClick     += (s, e) =>
            {
                if (buttonClick != null)
                {
                    buttonClick(s, e);
                }
                else
                {
                    manager.NavigateBack();
                }
            };
            spanel.Controls.Add(closeButton);

            panel.Background = NineTileBrush.FromSingleTexture(assets.LoadTexture(typeof(ScreenComponent), "panel"), 30, 30);
        }
示例#2
0
        public PauseScreen(ScreenComponent manager) : base(manager)
        {
            assets = manager.Game.Assets;

            // IsOverlay = true;
            // Background = new BorderBrush(new Color(Color.Black, 0.5f));

            Background = new TextureBrush(assets.LoadTexture(typeof(ScreenComponent), "background"), TextureBrushMode.Stretch);

            StackPanel stack = new StackPanel(manager);

            Controls.Add(stack);

            Button resumeButton = Button.TextButton(manager, Languages.OctoClient.Resume);

            resumeButton.HorizontalAlignment = HorizontalAlignment.Stretch;
            resumeButton.Margin          = new Border(0, 0, 0, 10);
            resumeButton.LeftMouseClick += (s, e) =>
            {
                manager.NavigateBack();
            };
            stack.Controls.Add(resumeButton);

            Button optionButton = Button.TextButton(manager, Languages.OctoClient.Options);

            optionButton.HorizontalAlignment = HorizontalAlignment.Stretch;
            optionButton.Margin          = new Border(0, 0, 0, 10);
            optionButton.MinWidth        = 300;
            optionButton.LeftMouseClick += (s, e) =>
            {
                manager.NavigateToScreen(new OptionsScreen(manager));
            };
            stack.Controls.Add(optionButton);

            Button creditsButton = Button.TextButton(manager, Languages.OctoClient.CreditsCrew);

            creditsButton.HorizontalAlignment = HorizontalAlignment.Stretch;
            creditsButton.Margin          = new Border(0, 0, 0, 10);
            creditsButton.LeftMouseClick += (s, e) =>
            {
                manager.NavigateToScreen(new CreditsScreen(manager));
            };
            stack.Controls.Add(creditsButton);

            Button mainMenuButton = Button.TextButton(manager, Languages.OctoClient.ToMainMenu);

            mainMenuButton.HorizontalAlignment = HorizontalAlignment.Stretch;
            mainMenuButton.Margin          = new Border(0, 0, 0, 10);
            mainMenuButton.LeftMouseClick += (s, e) =>
            {
                manager.Player.RemovePlayer();
                manager.Game.Simulation.ExitGame();
                manager.NavigateHome();
            };
            stack.Controls.Add(mainMenuButton);
        }
        public InventoryScreen(ScreenComponent manager) : base(manager)
        {
            player    = manager.Player;
            IsOverlay = true;

            Texture2D panelBackground = manager.Game.Content.LoadTexture2DFromFile("./Assets/OctoAwesome.Client/panel.png", manager.GraphicsDevice);

            Background = NineTileBrush.FromSingleTexture(panelBackground, 30, 30);

            HorizontalAlignment = HorizontalAlignment.Center;
            VerticalAlignment   = VerticalAlignment.Center;
            Width  = 600;
            Height = 400;

            Label headLine = new Label(manager);

            headLine.Text = Languages.OctoClient.Inventory;
            headLine.Font = Skin.Current.HeadlineFont;
            headLine.HorizontalAlignment = HorizontalAlignment.Left;
            headLine.VerticalAlignment   = VerticalAlignment.Top;
            Controls.Add(headLine);

            Button closeButton = Button.TextButton(manager, Languages.OctoClient.Close);

            closeButton.LeftMouseClick += (s, e) => { manager.NavigateBack(); };
            Controls.Add(closeButton);

            //counter = new LabelControl(ScreenManager)
            //{
            //    Font = ScreenManager.NormalText,
            //    Color = Color.Black,
            //    Position = new Index2(((ScreenManager.ScreenSize.X - 600) / 2) + 100,
            //        ((ScreenManager.ScreenSize.Y - 400) / 2) + 140),
            //};
            //Controls.Add(counter);

            Title = Languages.OctoClient.Inventory;
        }
示例#4
0
        public LoadingScreen(ScreenComponent manager) : base(manager)
        {
            Padding     = new Border(0, 0, 0, 0);
            tokenSource = new CancellationTokenSource();

            Title = "Loading";

            SetDefaultBackground();

            //Main Panel
            var mainStack = new Grid(manager);

            mainStack.Columns.Add(new ColumnDefinition()
            {
                ResizeMode = ResizeMode.Parts, Width = 4
            });
            mainStack.Rows.Add(new RowDefinition()
            {
                ResizeMode = ResizeMode.Parts, Height = 1
            });
            mainStack.Margin = Border.All(50);
            mainStack.HorizontalAlignment = HorizontalAlignment.Stretch;
            mainStack.VerticalAlignment   = VerticalAlignment.Stretch;

            Controls.Add(mainStack);

            var backgroundStack = new Panel(manager)
            {
                Background          = new BorderBrush(Color.White * 0.5f),
                VerticalAlignment   = VerticalAlignment.Stretch,
                HorizontalAlignment = HorizontalAlignment.Stretch,
                Margin = Border.All(10)
            };

            mainStack.AddControl(backgroundStack, 0, 0, 1, 1);

            var mainGrid = new Grid(manager)
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Stretch
            };

            mainGrid.Columns.Add(new ColumnDefinition()
            {
                ResizeMode = ResizeMode.Parts, Width = 1
            });
            mainGrid.Columns.Add(new ColumnDefinition()
            {
                ResizeMode = ResizeMode.Parts, Width = 3
            });
            mainGrid.Columns.Add(new ColumnDefinition()
            {
                ResizeMode = ResizeMode.Parts, Width = 1
            });
            mainGrid.Rows.Add(new RowDefinition()
            {
                ResizeMode = ResizeMode.Parts, Height = 4
            });
            mainGrid.Rows.Add(new RowDefinition()
            {
                ResizeMode = ResizeMode.Parts, Height = 1
            });
            mainGrid.Rows.Add(new RowDefinition()
            {
                ResizeMode = ResizeMode.Parts, Height = 1
            });
            mainGrid.Rows.Add(new RowDefinition()
            {
                ResizeMode = ResizeMode.Parts, Height = 4
            });

            backgroundStack.Controls.Add(mainGrid);

            var text = new Label(manager)
            {
                Text = "Konfuzius sagt: Das hier lädt...",
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center,
                Padding             = Border.All(10),
            };

            quoteUpdate = Task.Run(async() => await UpdateLabel(text, loadingQuoteProvider, TimeSpan.FromSeconds(1.5), tokenSource.Token));
            mainGrid.AddControl(text, 1, 1);


            //Buttons
            var buttonStack = new StackPanel(manager)
            {
                VerticalAlignment   = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center,
                Orientation         = Orientation.Horizontal
            };

            mainGrid.AddControl(buttonStack, 1, 2);

            Button cancelButton = GetButton(Languages.OctoClient.Cancel);

            buttonStack.Controls.Add(cancelButton);

            Debug.WriteLine("Create GameScreen");
            gameScreen = new GameScreen(manager);
            gameScreen.Update(new GameTime());
            gameScreen.OnCenterChanged += SwitchToGame;

            cancelButton.LeftMouseClick += (s, e) =>
            {
                tokenSource.Cancel();
                tokenSource.Dispose();
                manager.Player.SetEntity(null);
                manager.Game.Simulation.ExitGame();
                gameScreen.Unload();
                manager.NavigateBack();
            };
        }
示例#5
0
        public TargetScreen(ScreenComponent manager, Action <int, int> tp, int x, int y) : base(manager)
        {
            assets = manager.Game.Assets;

            IsOverlay  = true;
            Background = new BorderBrush(Color.Black * 0.5f);
            Title      = "Select target";

            Texture2D panelBackground = assets.LoadTexture(typeof(ScreenComponent), "panel");
            Panel     panel           = new Panel(manager)
            {
                Background          = NineTileBrush.FromSingleTexture(panelBackground, 30, 30),
                Padding             = Border.All(20),
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center
            };

            Controls.Add(panel);

            StackPanel spanel = new StackPanel(manager);

            panel.Controls.Add(spanel);

            Label headLine = new Label(manager)
            {
                Text = Title,
                Font = Skin.Current.HeadlineFont,
                HorizontalAlignment = HorizontalAlignment.Stretch
            };

            spanel.Controls.Add(headLine);

            StackPanel vstack = new StackPanel(manager);

            vstack.Orientation = Orientation.Vertical;
            spanel.Controls.Add(vstack);

            StackPanel xStack = new StackPanel(manager);

            xStack.Orientation = Orientation.Horizontal;
            vstack.Controls.Add(xStack);

            Label xLabel = new Label(manager);

            xLabel.Text = "X:";
            xStack.Controls.Add(xLabel);

            Textbox xText = new Textbox(manager)
            {
                Background = new BorderBrush(Color.Gray),
                Width      = 150,
                Margin     = new Border(2, 10, 2, 10),
                Text       = x.ToString()
            };

            xStack.Controls.Add(xText);

            StackPanel yStack = new StackPanel(manager);

            yStack.Orientation = Orientation.Horizontal;
            vstack.Controls.Add(yStack);

            Label yLabel = new Label(manager);

            yLabel.Text = "Y:";
            yStack.Controls.Add(yLabel);

            Textbox yText = new Textbox(manager)
            {
                Background = new BorderBrush(Color.Gray),
                Width      = 150,
                Margin     = new Border(2, 10, 2, 10),
                Text       = y.ToString()
            };

            yStack.Controls.Add(yText);

            Button closeButton = Button.TextButton(manager, "Teleport");

            closeButton.HorizontalAlignment = HorizontalAlignment.Stretch;
            closeButton.LeftMouseClick     += (s, e) =>
            {
                if (tp != null)
                {
                    tp(int.Parse(xText.Text), int.Parse(yText.Text));
                }
                else
                {
                    manager.NavigateBack();
                }
            };
            spanel.Controls.Add(closeButton);
        }
示例#6
0
        public CreditsScreen(ScreenComponent manager) : base(manager)
        {
            Padding = new Border(0, 0, 0, 0);

            Title = Languages.OctoClient.CreditsCrew;

            Image background = new Image(manager);

            background.Texture             = Manager.Content.LoadTexture2DFromFile("./Assets/OctoAwesome.Client/background_notext.png", Manager.GraphicsDevice);
            background.VerticalAlignment   = VerticalAlignment.Stretch;
            background.HorizontalAlignment = HorizontalAlignment.Stretch;
            Controls.Add(background);

            Button backButton = Button.TextButton(manager, Languages.OctoClient.Back);

            backButton.VerticalAlignment   = VerticalAlignment.Top;
            backButton.HorizontalAlignment = HorizontalAlignment.Left;
            backButton.LeftMouseClick     += (s, e) =>
            {
                manager.NavigateBack();
            };
            backButton.Margin = new Border(10, 10, 10, 10);
            Controls.Add(backButton);

            List <CrewMember> crew = CrewMember.getCrew(manager);

            ScrollContainer crewScroll = new ScrollContainer(manager)
            {
                VerticalAlignment = VerticalAlignment.Stretch,
                Margin            = new Border(10, 10, 10, 10),
                CanFocus          = false
            };

            StackPanel crewList = new StackPanel(manager)
            {
                MinWidth          = 700,
                VerticalAlignment = VerticalAlignment.Stretch,
                Orientation       = Orientation.Vertical,
            };

            crewScroll.Content = crewList;

            foreach (CrewMember member in crew)
            {
                Panel memberPanel = new Panel(manager)
                {
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    MinHeight           = 30,
                    Background          = new BorderBrush(Color.White),
                    Margin            = new Border(5, 5, 5, 5),
                    HoveredBackground = new BorderBrush(Color.LightGray)
                };

                memberPanel.LeftMouseClick += (s, e) =>
                {
                    manager.NavigateToScreen(new CrewMemberScreen(manager, member));
                };

                Label name = new Label(manager)
                {
                    Text = member.Username,
                    VerticalAlignment   = VerticalAlignment.Stretch,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    Padding             = new Border(5, 5, 5, 5)
                };

                memberPanel.Controls.Add(name);
                crewList.Controls.Add(memberPanel);
            }


            Controls.Add(crewScroll);
        }
示例#7
0
        public OptionsScreen(ScreenComponent manager) : base(manager)
        {
            game    = (OctoGame)manager.Game;
            Padding = new Border(0, 0, 0, 0);

            Title = Languages.OctoClient.Options;

            ////////////////////////////////////////////Background////////////////////////////////////////////
            Image background = new Image(manager);

            background.Texture             = Manager.Content.LoadTexture2DFromFile("./Assets/OctoAwesome.Client/background_notext.png", Manager.GraphicsDevice);
            background.VerticalAlignment   = VerticalAlignment.Stretch;
            background.HorizontalAlignment = HorizontalAlignment.Stretch;
            Controls.Add(background);

            ////////////////////////////////////////////Back Button////////////////////////////////////////////
            Button backButton = Button.TextButton(manager, Languages.OctoClient.Back);

            backButton.VerticalAlignment   = VerticalAlignment.Top;
            backButton.HorizontalAlignment = HorizontalAlignment.Left;
            backButton.LeftMouseClick     += (s, e) =>
            {
                manager.NavigateBack();
            };
            backButton.Margin = new Border(10, 10, 10, 10);
            Controls.Add(backButton);

            ////////////////////////////////////////////Settings Stack////////////////////////////////////////////
            StackPanel settingsStack = new StackPanel(manager);

            settingsStack.Orientation = Orientation.Vertical;
            Texture2D panelBackground = manager.Content.LoadTexture2DFromFile("./Assets/OctoAwesome.Client/panel.png", manager.GraphicsDevice);

            settingsStack.Background = NineTileBrush.FromSingleTexture(panelBackground, 30, 30);
            settingsStack.Padding    = new Border(20, 20, 20, 20);
            Controls.Add(settingsStack);


            //////////////////////Viewrange//////////////////////
            string viewrange = ConfigurationManager.AppSettings["Viewrange"];

            rangeTitle      = new Label(manager);
            rangeTitle.Text = Languages.OctoClient.Viewrange + ": " + viewrange;
            settingsStack.Controls.Add(rangeTitle);

            Slider viewrangeSlider = new Slider(manager);

            viewrangeSlider.HorizontalAlignment = HorizontalAlignment.Stretch;
            viewrangeSlider.Height        = 20;
            viewrangeSlider.Range         = 9;
            viewrangeSlider.Value         = int.Parse(viewrange) - 1;
            viewrangeSlider.ValueChanged += (value) => SetViewrange(value + 1);
            settingsStack.Controls.Add(viewrangeSlider);


            //////////////////////Persistence//////////////////////
            StackPanel persistenceStack = new StackPanel(manager);

            persistenceStack.Orientation = Orientation.Horizontal;
            persistenceStack.Margin      = new Border(0, 10, 0, 0);
            settingsStack.Controls.Add(persistenceStack);

            persistenceTitle      = new Label(manager);
            persistenceTitle.Text = Languages.OctoClient.DisablePersistence + ":";
            persistenceStack.Controls.Add(persistenceTitle);

            Checkbox disablePersistence = new Checkbox(manager);

            disablePersistence.Checked         = bool.Parse(ConfigurationManager.AppSettings["DisablePersistence"]);
            disablePersistence.CheckedChanged += (state) => SetPersistence(state);
            persistenceStack.Controls.Add(disablePersistence);

            //////////////////////Map Path//////////////////////
            StackPanel mapPathStack = new StackPanel(manager);

            mapPathStack.Orientation         = Orientation.Horizontal;
            mapPathStack.Margin              = new Border(0, 10, 0, 0);
            mapPathStack.HorizontalAlignment = HorizontalAlignment.Stretch;
            settingsStack.Controls.Add(mapPathStack);

            mapPath = new Textbox(manager);
            // mapPath.HorizontalAlignment = HorizontalAlignment.Stretch;
            mapPath.Text       = ConfigurationManager.AppSettings["ChunkRoot"];
            mapPath.Enabled    = false;
            mapPath.Background = new BorderBrush(Color.LightGray, LineType.Solid, Color.Gray);
            mapPathStack.Controls.Add(mapPath);

            Button changePath = Button.TextButton(manager, Languages.OctoClient.ChangePath);

            changePath.Height          = 31;
            changePath.LeftMouseClick += (s, e) => ChangePath();
            mapPathStack.Controls.Add(changePath);


            //////////////////////Delete Map//////////////////////
            deleteButton = Button.TextButton(manager, Languages.OctoClient.DeleteMap);
            deleteButton.HorizontalAlignment = HorizontalAlignment.Stretch;
            deleteButton.Margin          = new Border(0, 10, 0, 0);
            deleteButton.LeftMouseClick += (s, e) => deleteMap();
            settingsStack.Controls.Add(deleteButton);


            ////////////////////////////////////////////Restart Button////////////////////////////////////////////
            exitButton = Button.TextButton(manager, Languages.OctoClient.RestartGameToApplyChanges);
            exitButton.VerticalAlignment   = VerticalAlignment.Top;
            exitButton.HorizontalAlignment = HorizontalAlignment.Right;
            exitButton.Enabled             = false;
            exitButton.Visible             = false;
            exitButton.LeftMouseClick     += (s, e) =>
            {
                Process.Start(System.Reflection.Assembly.GetEntryAssembly().Location);
                game.Exit();
            };
            exitButton.Margin = new Border(10, 10, 10, 10);
            Controls.Add(exitButton);
        }
示例#8
0
        public CrewMemberScreen(ScreenComponent manager, CrewMember member) : base(manager)
        {
            VerticalAlignment   = VerticalAlignment.Center;
            HorizontalAlignment = HorizontalAlignment.Center;

            SpriteFont boldFont = manager.Content.Load <SpriteFont>("BoldFont");

            Padding = new Border(0, 0, 0, 0);

            //The Background Image
            Image background = new Image(manager)
            {
                Texture             = manager.Content.LoadTexture2DFromFile("./Assets/OctoAwesome.Client/background_notext.png", manager.GraphicsDevice),
                VerticalAlignment   = VerticalAlignment.Stretch,
                HorizontalAlignment = HorizontalAlignment.Stretch
            };

            Controls.Add(background);

            //The Panel
            Texture2D panelBackground = manager.Content.LoadTexture2DFromFile("./Assets/OctoAwesome.Client/panel.png", manager.GraphicsDevice);
            Panel     panel           = new Panel(manager)
            {
                MaxWidth   = 750,
                Background = NineTileBrush.FromSingleTexture(panelBackground, 30, 30),
                Padding    = new Border(15, 15, 15, 15),
            };

            Controls.Add(panel);

            //The Vertical Stack - Split the Panel in half Vertical
            StackPanel verticalStack = new StackPanel(manager)
            {
                VerticalAlignment   = VerticalAlignment.Stretch,
                HorizontalAlignment = HorizontalAlignment.Stretch,
                Orientation         = Orientation.Vertical,
            };
            // panel.Controls.Add(verticalStack);



            //The Main Stack - Split the Panel in half Horizontal
            StackPanel horizontalStack = new StackPanel(manager)
            {
                HorizontalAlignment = HorizontalAlignment.Center,
                Orientation         = Orientation.Horizontal
            };

            panel.Controls.Add(horizontalStack);


            //The Profile Image
            Image profileImage = new Image(manager)
            {
                Height              = 200,
                Width               = 200,
                VerticalAlignment   = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center,
                Padding             = new Border(0, 0, 10, 0)
            };

            if (member.PictureFilename == null)
            {
                profileImage.Texture = manager.Content.LoadTexture2DFromFile("./Assets/OctoAwesome.Client/Crew/base.png", manager.GraphicsDevice);
            }
            else
            {
                profileImage.Texture = manager.Content.LoadTexture2DFromFile(member.PictureFilename, manager.GraphicsDevice);
            }
            horizontalStack.Controls.Add(profileImage);



            //The Text Stack
            StackPanel textStack = new StackPanel(manager);

            textStack.VerticalAlignment   = VerticalAlignment.Stretch;
            textStack.HorizontalAlignment = HorizontalAlignment.Left;
            textStack.Width = 430;
            horizontalStack.Controls.Add(textStack);

            //The Username
            Label username = new Label(manager)
            {
                Text = member.Username,
                Font = manager.Content.Load <SpriteFont>("HeadlineFont"),
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Top
            };

            textStack.Controls.Add(username);

            //The Alias
            Label alias = new Label(manager)
            {
                Text = member.Alias,
                HorizontalAlignment = HorizontalAlignment.Left
            };

            textStack.Controls.Add(alias);

            //Achievements
            string achievementString = "";

            foreach (CrewMember.Achievements achievement in member.AchievementList)
            {
                achievementString += " " + achievement.ToString();
                if (member.AchievementList.IndexOf(achievement) != member.AchievementList.Count - 1)
                {
                    achievementString += ", ";
                }
            }
            StackPanel achievementStack = new StackPanel(manager);

            achievementStack.VerticalAlignment   = VerticalAlignment.Top;
            achievementStack.HorizontalAlignment = HorizontalAlignment.Left;
            achievementStack.Orientation         = Orientation.Horizontal;
            textStack.Controls.Add(achievementStack);

            Label achievementsTitle = new Label(manager)
            {
                Text = Languages.OctoClient.Achievements + ": ", Font = boldFont, HorizontalAlignment = HorizontalAlignment.Left
            };

            Label achievements = new Label(manager)
            {
                Text = achievementString, HorizontalAlignment = HorizontalAlignment.Left
            };

            achievementStack.Controls.Add(achievementsTitle);
            achievementStack.Controls.Add(achievements);



            Panel DescriptionPanel = new Panel(manager)
            {
                VerticalAlignment   = VerticalAlignment.Stretch,
                HorizontalAlignment = HorizontalAlignment.Stretch,
            };

            textStack.Controls.Add(DescriptionPanel);

            Label Description = new Label(manager)
            {
                Text                    = member.Description,
                WordWrap                = true,
                VerticalAlignment       = VerticalAlignment.Stretch,
                HorizontalAlignment     = HorizontalAlignment.Left,
                HorizontalTextAlignment = HorizontalAlignment.Left,
                VerticalTextAlignment   = VerticalAlignment.Top,
            };

            Description.InvalidateDimensions();
            DescriptionPanel.Controls.Add(Description);

            panel.Width = 700;

            //The Back Button
            Button backButton = Button.TextButton(manager, Languages.OctoClient.Back);

            backButton.VerticalAlignment   = VerticalAlignment.Top;
            backButton.HorizontalAlignment = HorizontalAlignment.Left;
            backButton.LeftMouseClick     += (s, e) =>
            {
                manager.NavigateBack();
            };
            backButton.Margin = new Border(10, 10, 10, 10);
            Controls.Add(backButton);

            Title = member.Alias;
        }