Esempio n. 1
0
        public GalaxyScene(IGalaxyViewListener galaxyViewListener, Action mainMenuCallback)
        {
            this.galaxyViewListener = galaxyViewListener;
            this.reportOpener       = new OpenReportVisitor(showDevelopment, showResearch);

            var mainMenuButton = new GuiButton
            {
                BackgroundHover  = new BackgroundTexture(GalaxyTextures.Get.ToggleHover, 7),
                BackgroundNormal = new BackgroundTexture(GalaxyTextures.Get.ToggleNormal, 7),
                ForgroundImage   = GalaxyTextures.Get.MainMenu,
                Padding          = 4,
                ClickCallback    = mainMenuCallback,
                Tooltip          = new SimpleTooltip("GalaxyScene", "MainMenuTooltip")
            };

            mainMenuButton.Position.FixedSize(36, 32).ParentRelative(-1, 1).WithMargins(5, 5);
            this.AddElement(mainMenuButton);

            this.fuelInfo = new GuiText
            {
                TextColor  = Color.Yellow,
                TextHeight = 24,
                Tooltip    = new SimpleTooltip("GalaxyScene", "FuelTooltip")
            };
            this.fuelInfo.Position.WrapContent().Then.RelativeTo(mainMenuButton, 1, 0, -1, 0).WithMargins(20, 5);
            this.AddElement(this.fuelInfo);

            var designButton = new GuiButton
            {
                BackgroundHover  = new BackgroundTexture(GalaxyTextures.Get.ToggleHover, 7),
                BackgroundNormal = new BackgroundTexture(GalaxyTextures.Get.ToggleNormal, 7),
                ForgroundImage   = GalaxyTextures.Get.Design,
                PaddingX         = 12,
                PaddingY         = 4,
                ClickCallback    = () => { using (var form = new FormShipDesignList(this.currentPlayer)) form.ShowDialog(); },
                Tooltip          = new SimpleTooltip("GalaxyScene", "DesignTooltip")
            };

            designButton.Position.FixedSize(48, 32).RelativeTo(fuelInfo, 1, 0, -1, 0).WithMargins(20, 5);
            this.AddElement(designButton);

            var developmentButton = new GuiButton
            {
                BackgroundHover  = new BackgroundTexture(GalaxyTextures.Get.ToggleHover, 7),
                BackgroundNormal = new BackgroundTexture(GalaxyTextures.Get.ToggleNormal, 7),
                ForgroundImage   = GalaxyTextures.Get.Development,
                PaddingX         = 12,
                PaddingY         = 4,
                ClickCallback    = this.showDevelopment,
                Tooltip          = new SimpleTooltip("GalaxyScene", "DevelopmentTooltip")
            };

            developmentButton.Position.FixedSize(48, 32).RelativeTo(designButton, 1, 0, -1, 0).WithMargins(5, 5);
            this.AddElement(developmentButton);

            var researchButton = new GuiButton
            {
                BackgroundHover  = new BackgroundTexture(GalaxyTextures.Get.ToggleHover, 7),
                BackgroundNormal = new BackgroundTexture(GalaxyTextures.Get.ToggleNormal, 7),
                ForgroundImage   = GalaxyTextures.Get.Research,
                PaddingX         = 12,
                PaddingY         = 4,
                ClickCallback    = this.showResearch,
                Tooltip          = new SimpleTooltip("GalaxyScene", "ResearchTooltip")
            };

            researchButton.Position.FixedSize(48, 32).RelativeTo(developmentButton, 1, 0, -1, 0).WithMargins(5, 5);
            this.AddElement(researchButton);

            var diplomacyButton = new GuiButton
            {
                BackgroundHover  = new BackgroundTexture(GalaxyTextures.Get.ToggleHover, 7),
                BackgroundNormal = new BackgroundTexture(GalaxyTextures.Get.ToggleNormal, 7),
                ForgroundImage   = GalaxyTextures.Get.Diplomacy,
                PaddingX         = 12,
                PaddingY         = 4,
                ClickCallback    = () => { using (var form = new FormRelations(this.currentPlayer)) form.ShowDialog(); },
                Tooltip          = new SimpleTooltip("GalaxyScene", "DiplomacyTooltip")
            };

            diplomacyButton.Position.FixedSize(48, 32).RelativeTo(researchButton, 1, 0, -1, 0).WithMargins(5, 5);
            this.AddElement(diplomacyButton);

            var colonizationButton = new GuiButton
            {
                BackgroundHover  = new BackgroundTexture(GalaxyTextures.Get.ToggleHover, 7),
                BackgroundNormal = new BackgroundTexture(GalaxyTextures.Get.ToggleNormal, 7),
                ForgroundImage   = GalaxyTextures.Get.Colonization,
                PaddingX         = 12,
                PaddingY         = 4,
                ClickCallback    = () => { using (var form = new FormColonization(this.currentPlayer)) form.ShowDialog(); },
                Tooltip          = new SimpleTooltip("GalaxyScene", "ColonizationTooltip")
            };

            colonizationButton.Position.FixedSize(48, 32).RelativeTo(diplomacyButton, 1, 0, -1, 0).WithMargins(5, 5);
            this.AddElement(colonizationButton);

            var reportsButton = new GuiButton
            {
                BackgroundHover  = new BackgroundTexture(GalaxyTextures.Get.ToggleHover, 7),
                BackgroundNormal = new BackgroundTexture(GalaxyTextures.Get.ToggleNormal, 7),
                ForgroundImage   = GalaxyTextures.Get.Reports,
                PaddingX         = 12,
                PaddingY         = 4,
                ClickCallback    = () => { using (var form = new FormReports(this.currentPlayer.Reports)) if (form.ShowDialog() == DialogResult.OK)
                                               {
                                                   form.Result.Accept(this.reportOpener);
                                               }
                },
                Tooltip = new SimpleTooltip("GalaxyScene", "ReportsTooltip")
            };

            reportsButton.Position.FixedSize(48, 32).RelativeTo(colonizationButton, 1, 0, -1, 0).WithMargins(5, 5);
            this.AddElement(reportsButton);

            var stareaterButton = new GuiButton
            {
                BackgroundHover  = new BackgroundTexture(GalaxyTextures.Get.ToggleHover, 7),
                BackgroundNormal = new BackgroundTexture(GalaxyTextures.Get.ToggleNormal, 7),
                ForgroundImage   = GalaxyTextures.Get.Stareater,
                PaddingX         = 12,
                PaddingY         = 4,
                ClickCallback    = () => { using (var form = new FormStareater(this.currentPlayer.Stareater)) form.ShowDialog(); },
                Tooltip          = new SimpleTooltip("GalaxyScene", "StareaterTooltip")
            };

            stareaterButton.Position.FixedSize(48, 32).RelativeTo(reportsButton, 1, 0, -1, 0).WithMargins(5, 5);
            this.AddElement(stareaterButton);

            var libraryButton = new GuiButton
            {
                BackgroundHover  = new BackgroundTexture(GalaxyTextures.Get.ToggleHover, 7),
                BackgroundNormal = new BackgroundTexture(GalaxyTextures.Get.ToggleNormal, 7),
                ForgroundImage   = GalaxyTextures.Get.Library,
                PaddingX         = 12,
                PaddingY         = 4,
                ClickCallback    = () => { using (var form = new FormLibrary(this.currentPlayer.Library)) form.ShowDialog(); },
                Tooltip          = new SimpleTooltip("GalaxyScene", "LibraryTooltip")
            };

            libraryButton.Position.FixedSize(48, 32).RelativeTo(stareaterButton, 1, 0, -1, 0).WithMargins(5, 5);
            this.AddElement(libraryButton);

            this.turnCounter = new GuiText {
                TextColor = Color.LightGray, TextHeight = 24
            };
            this.turnCounter.Position.WrapContent().Then.ParentRelative(1, 1).WithMargins(10, 5);
            this.AddElement(this.turnCounter);

            var turnButton = new GuiButton
            {
                BackgroundHover  = new BackgroundTexture(GalaxyTextures.Get.EndTurnHover, 0),
                BackgroundNormal = new BackgroundTexture(GalaxyTextures.Get.EndTurnNormal, 0),
                ClickCallback    = this.galaxyViewListener.TurnEnded,
                Tooltip          = new SimpleTooltip("GalaxyScene", "EndTurn")
            };

            turnButton.Position.FixedSize(80, 80).ParentRelative(1, -1).WithMargins(10, 10);
            this.AddElement(turnButton);

            var radarToggle = new ToggleButton(SettingsWinforms.Get.ShowScanRange)
            {
                BackgroundHover   = new BackgroundTexture(GalaxyTextures.Get.ToggleHover, 7),
                BackgroundNormal  = new BackgroundTexture(GalaxyTextures.Get.ToggleNormal, 7),
                BackgroundToggled = new BackgroundTexture(GalaxyTextures.Get.ToggleToggled, 7),
                ForgroundImage    = new BackgroundTexture(GalaxyTextures.Get.Radar, 0),
                ToggleCallback    = this.toggleRadar,
                Tooltip           = new SimpleTooltip("GalaxyScene", "RadarSwitchToolip")
            };

            radarToggle.Position.FixedSize(24, 24).RelativeTo(turnButton, -1, 1, 1, 1).WithMargins(15, 0);
            this.AddElement(radarToggle);

            this.starInfo = new ConstructionSiteView();
            this.starInfo.Position.ParentRelative(0, -1).WithMargins(0, 0);
            this.AddElement(this.starInfo);
        }