public MainWindow(GameData.GameData gameData)
        {
            doCloseButton = false;             // explicitly disable close button, we'll draw it ourselves
            doCloseX      = true;
            optionalTitle = "Prepare Landing"; // Do not translate
            MinimizedWindow.WindowLabel = optionalTitle;
            MinimizedWindow.AddMinimizedWindowContent += AddMinimizedWindowContent;

            /*
             * GUI utilities (tabs)
             */
            _tabGuiUtilities.Clear();
            _tabGuiUtilities.Add(new TabTerrain(gameData, 0.30f));
            _tabGuiUtilities.Add(new TabTemperature(gameData, 0.30f));
            _tabGuiUtilities.Add(new TabFilteredTiles(0.48f));
            _tabGuiUtilities.Add(new TabInfo(gameData, 0.48f));
            _tabGuiUtilities.Add(new TabOptions(gameData, 0.35f));
            _tabGuiUtilities.Add(new TabLoadSave(gameData, 0.48f));
#if TAB_OVERLAYS
            _tabGuiUtilities.Add(new TabOverlays(gameData, 0.50f));
#endif
            _tabGuiUtilities.Add(new TabGodMode(gameData, 0.30f));

            TabController.Clear();
            TabController.AddTabRange(_tabGuiUtilities);

            /*
             * Bottom buttons
             */

            #region BOTTOM_BUTTONS

            var buttonFilterTiles = new ButtonDescriptor("PLMWBB_FilterTiles".Translate(),
                                                         delegate
            {
                SoundDefOf.TickLow.PlayOneShotOnCamera();

                // reset starting display index
                _tileDisplayIndexStart = 0;

                // reset selected index
                _selectedTileIndex = -1;

                // do the tile filtering
                PrepareLanding.Instance.TileFilter.Filter();
            });

            var buttonResetFilters = new ButtonDescriptor("PLMWBB_ResetFilters".Translate(),
                                                          delegate
            {
                SoundDefOf.TickLow.PlayOneShotOnCamera();
                gameData.UserData.ResetAllFields();
            });

            var buttonMinimize = new ButtonDescriptor("PLMWBB_Minimize".Translate(),
                                                      delegate
            {
                SoundDefOf.TickHigh.PlayOneShotOnCamera();
                Minimize();
            });

            var buttonSelectRandomSite = new ButtonDescriptor("PLMWBB_SelectRandom".Translate(),
                                                              delegate
            {
                SoundDefOf.Click.PlayOneShotOnCamera();
                var tileId = PrepareLanding.Instance.TileFilter.RandomFilteredTile();
                if (tileId == Tile.Invalid)
                {
                    return;
                }

                Find.WorldInterface.SelectedTile = tileId;
                Find.WorldCameraDriver.JumpTo(Find.WorldGrid.GetTileCenter(Find.WorldInterface.SelectedTile));
            });

            _buttonCloseDescriptor = new ButtonDescriptor("CloseButton".Translate(),
                                                          delegate
            {
                SoundDefOf.TickHigh.PlayOneShotOnCamera();

                // reset starting display index
                _tileDisplayIndexStart = 0;

                // reset selected index
                _selectedTileIndex = -1;

                ForceClose();
            }, displayState: DisplayState.Entry | DisplayState.MapInitializing);


            _bottomButtonsDescriptorList =
                new List <ButtonDescriptor> {
                buttonFilterTiles, buttonResetFilters, buttonSelectRandomSite, buttonMinimize, _buttonCloseDescriptor
            };

            #endregion BOTTOM_BUTTONS

            /*
             * Minimized window buttons
             */

            #region MINIMIZED_WINDOW_BUTTONS

            //TODO: this is exactly the same code than in TabFilterTiles.cs: find a way to refactor the code.

            var buttonListStart = new ButtonDescriptor("<<", delegate
            {
                // reset starting display index
                _tileDisplayIndexStart = 0;
            }, "PLMWFTIL_GoToStartOfTileList".Translate());

            var buttonPreviousPage = new ButtonDescriptor("<", delegate
            {
                if (_tileDisplayIndexStart >= MaxDisplayedTileWhenMinimized)
                {
                    _tileDisplayIndexStart -= MaxDisplayedTileWhenMinimized;
                }
                else
                {
                    Messages.Message("PLMWFTIL_ReachedListStart".Translate(), MessageTypeDefOf.RejectInput);
                }
            }, "PLMWFTIL_GoToPreviousListPage".Translate());

            var buttonNextPage = new ButtonDescriptor(">", delegate
            {
                var matchingTilesCount  = PrepareLanding.Instance.TileFilter.AllMatchingTiles.Count;
                _tileDisplayIndexStart += MaxDisplayedTileWhenMinimized;
                if (_tileDisplayIndexStart > matchingTilesCount)
                {
                    Messages.Message($"{"PLMWFTIL_NoMoreTilesAvailable".Translate()} {matchingTilesCount}).",
                                     MessageTypeDefOf.RejectInput);
                    _tileDisplayIndexStart -= MaxDisplayedTileWhenMinimized;
                }
            }, "PLMWFTIL_GoToNextListPage".Translate());

            var buttonListEnd = new ButtonDescriptor(">>", delegate
            {
                var matchingTilesCount    = PrepareLanding.Instance.TileFilter.AllMatchingTiles.Count;
                var tileDisplayIndexStart = matchingTilesCount - matchingTilesCount % MaxDisplayedTileWhenMinimized;
                if (tileDisplayIndexStart == _tileDisplayIndexStart)
                {
                    Messages.Message($"{"PLMWFTIL_NoMoreTilesAvailable".Translate()} {matchingTilesCount}).",
                                     MessageTypeDefOf.RejectInput);
                }

                _tileDisplayIndexStart = tileDisplayIndexStart;
            }, "PLMWFTIL_GoToEndOfList".Translate());

            _minimizedWindowButtonsDescriptorList =
                new List <ButtonDescriptor> {
                buttonListStart, buttonPreviousPage, buttonNextPage, buttonListEnd
            };

            #endregion MINIMIZED_WINDOW_BUTTONS
        }
Exemple #2
0
        public MainWindow(UserData userData)
        {
            _userData = userData;

            doCloseButton = false; // explicitly disable close button, we'll draw it ourselves
            doCloseX      = true;
            optionalTitle = "Prepare Landing";
            MinimizedWindow.WindowLabel = optionalTitle;
            MinimizedWindow.AddMinimizedWindowContent += AddMinimizedWindowContent;

            /*
             * GUI utilities (tabs)
             */
            _tabGuiUtilities.Clear();
            _tabGuiUtilities.Add(new TabTerrain(userData, 0.30f));
            _tabGuiUtilities.Add(new TabTemperature(userData, 0.30f));
            _tabGuiUtilities.Add(new TabFilteredTiles(0.48f));
            _tabGuiUtilities.Add(new TabInfo(userData, 0.48f));
            _tabGuiUtilities.Add(new TabOptions(userData, 0.30f));
            _tabGuiUtilities.Add(new TabLoadSave(userData, 0.48f));

            TabController.Clear();
            TabController.AddTabRange(_tabGuiUtilities);

            /*
             * Bottom buttons
             */

            #region BOTTOM_BUTTONS

            var buttonFilterTiles = new ButtonDescriptor("Filter Tiles",
                                                         delegate
            {
                SoundDefOf.TickLow.PlayOneShotOnCamera();

                // reset starting display index
                _tileDisplayIndexStart = 0;

                // reset selected index
                _selectedTileIndex = -1;

                // do the tile filtering
                PrepareLanding.Instance.TileFilter.Filter();
            });

            var buttonResetFilters = new ButtonDescriptor("Reset Filters",
                                                          delegate
            {
                SoundDefOf.TickLow.PlayOneShotOnCamera();
                userData.ResetAllFields();
            });

            var buttonMinimize = new ButtonDescriptor("Minimize",
                                                      delegate
            {
                SoundDefOf.TickHigh.PlayOneShotOnCamera();
                Minimize();
            });

            _buttonCloseDescriptor = new ButtonDescriptor("CloseButton".Translate(),
                                                          delegate
            {
                SoundDefOf.TickHigh.PlayOneShotOnCamera();

                // reset starting display index
                _tileDisplayIndexStart = 0;

                // reset selected index
                _selectedTileIndex = -1;

                ForceClose();
            }, displayState: DisplayState.Entry | DisplayState.MapInitializing);


            _bottomButtonsDescriptorList =
                new List <ButtonDescriptor> {
                buttonFilterTiles, buttonResetFilters, buttonMinimize, _buttonCloseDescriptor
            };

            #endregion BOTTOM_BUTTONS

            /*
             * Minimized window buttons
             */

            #region MINIMIZED_WINDOW_BUTTONS

            var buttonListStart = new ButtonDescriptor("<<", delegate
            {
                // reset starting display index
                _tileDisplayIndexStart = 0;
            }, "Go to start of tile list.");

            var buttonPreviousPage = new ButtonDescriptor("<", delegate
            {
                if (_tileDisplayIndexStart >= MaxDisplayedTileWhenMinimized)
                {
                    _tileDisplayIndexStart -= MaxDisplayedTileWhenMinimized;
                }
                else
                {
                    Messages.Message("Reached start of tile list.", MessageSound.RejectInput);
                }
            }, "Go to previous list page.");

            var buttonNextPage = new ButtonDescriptor(">", delegate
            {
                var matchingTilesCount  = PrepareLanding.Instance.TileFilter.AllMatchingTiles.Count;
                _tileDisplayIndexStart += MaxDisplayedTileWhenMinimized;
                if (_tileDisplayIndexStart > matchingTilesCount)
                {
                    Messages.Message($"No more tiles available to display (max: {matchingTilesCount}).",
                                     MessageSound.RejectInput);
                    _tileDisplayIndexStart -= MaxDisplayedTileWhenMinimized;
                }
            }, "Go to next list page.");

            var buttonListEnd = new ButtonDescriptor(">>", delegate
            {
                var matchingTilesCount    = PrepareLanding.Instance.TileFilter.AllMatchingTiles.Count;
                var tileDisplayIndexStart = matchingTilesCount - matchingTilesCount % MaxDisplayedTileWhenMinimized;
                if (tileDisplayIndexStart == _tileDisplayIndexStart)
                {
                    Messages.Message($"No more tiles available to display (max: {matchingTilesCount}).",
                                     MessageSound.RejectInput);
                }

                _tileDisplayIndexStart = tileDisplayIndexStart;
            }, "Go to end of list.");

            _minimizedWindowButtonsDescriptorList =
                new List <ButtonDescriptor> {
                buttonListStart, buttonPreviousPage, buttonNextPage, buttonListEnd
            };

            #endregion MINIMIZED_WINDOW_BUTTONS
        }