示例#1
0
        protected override void LoadContent()
        {
            // Prepare GemGui
            GumInputMapper = new Gum.Input.GumInputMapper(Window.Handle);
            GumInput       = new Gum.Input.Input(GumInputMapper);

            // Register all bindable actions with the input system.
            GumInput.AddAction("TEST", Gum.Input.KeyBindingType.Pressed);

            GumSkin = new RenderData(GraphicsDevice, Content,
                                     "newgui/xna_draw", "Content/newgui/sheets.txt");

            if (SoundManager.Content == null)
            {
                SoundManager.Content = Content;
                SoundManager.LoadDefaultSounds();
#if XNA_BUILD
                SoundManager.SetActiveSongs(ContentPaths.Music.dwarfcorp, ContentPaths.Music.dwarfcorp_2,
                                            ContentPaths.Music.dwarfcorp_3, ContentPaths.Music.dwarfcorp_4, ContentPaths.Music.dwarfcorp_5);
#endif
            }

            // The thing keeping this from working is that some states are tied tightly to the play state.
            // Ideally the solution is to stop caching these at all, so there's no point in trying to make
            // an implementation work just to throw it out.

            /*
             * foreach (var type in System.Reflection.Assembly.GetExecutingAssembly().GetTypes())
             * {
             *  if (type.IsSubclassOf(typeof(GameState)))
             *  {
             *      var instance = Activator.CreateInstance(type, this, StateManager);
             *      StateManager.States.Add(type.Name, instance as GameState);
             *  }
             * }
             */

            /*
             * PlayState playState = new PlayState(this, StateManager);
             * StateManager.States["IntroState"] = new IntroState(this, StateManager);
             * StateManager.States["PlayState"] = playState;
             * StateManager.States["MainMenuState"] = new MainMenuState(this, StateManager);
             * StateManager.States["NewGameChooseWorldState"] = new NewGameChooseWorldState(this, StateManager);
             * StateManager.States["NewGameCreateDebugWorldState"] = new NewGameCreateDebugWorldState(this, StateManager);
             * StateManager.States["WorldSetupState"] = new WorldSetupState(this, StateManager);
             * StateManager.States["WorldGeneratorState"] = new WorldGeneratorState(this, StateManager);
             * StateManager.States["OptionsState"] = new OptionsState(this, StateManager);
             * StateManager.States["NewOptionsState"] = new NewOptionsState(this, StateManager);
             * StateManager.States["EconomyState"] = new EconomyState(this, StateManager);
             * StateManager.States["CompanyMakerState"] = new CompanyMakerState(this, StateManager);
             * StateManager.States["WorldLoaderState"] = new WorldLoaderState(this, StateManager);
             * StateManager.States["GameLoaderState"] = new GameLoaderState(this, StateManager);
             * StateManager.States["LoseState"] = new LoseState(this, StateManager, playState);
             * StateManager.States["LoadState"] = new LoadState(this, StateManager);
             */

            if (GameSettings.Default.DisplayIntro)
            {
                StateManager.PushState(new IntroState(this, StateManager));
            }
            else
            {
                StateManager.PushState(new MainMenuState(this, StateManager));
            }

            BiomeLibrary.InitializeStatics();
            Embarkment.Initialize();
            VoxelChunk.InitializeStatics();
            ControlSettings.Load();
            Drawer2D.Initialize(Content, GraphicsDevice);
            ResourceLibrary.Initialize();

            base.LoadContent();
        }
示例#2
0
        protected override void LoadContent()
        {
            var renderData = new Gum.RenderData(
                GraphicsDevice,
                this.Content,
#if GEMXNA
                "Content/xna_draw",
#elif GEMMONO
                "Content/mono_draw",
#endif
                "Content/dwarf_corp_skin/sheets.txt");

            GuiRoot = new Root(new Point(640, 480), renderData);

            GuiRoot.MousePointer    = new MousePointer("mouse", 1.0f, 0);
            GuiRoot.TooltipTextSize = 2;

            var frame = GuiRoot.RootItem.AddChild(new Widget
            {
                Text                = "- DEMO MENU -",
                Border              = "border-one",
                TextSize            = 1,
                TextColor           = new Vector4(1, 0, 0, 1),
                TextHorizontalAlign = HorizontalAlign.Center,
                MinimumSize         = new Point(256, 256),
                AutoLayout          = AutoLayout.FloatCenter,
                InteriorMargin      = new Margin
                {
                    Top = GuiRoot.GetTileSheet("font2").TileHeight * 2
                },
                Padding = new Margin(2, 2, 2, 2),
                Font    = "font2"
            });

            frame.AddChild(new Widget
            {
                Text    = "View Atlas",
                Border  = "border-thin",
                OnClick = (sender, args) =>
                {
                    var dialog = GuiRoot.ConstructWidget(new ShowTextureDialog());
                    GuiRoot.ShowDialog(dialog);
                    GuiRoot.RootItem.Layout();
                },
                TextHorizontalAlign = HorizontalAlign.Center,
                TextVerticalAlign   = VerticalAlign.Center,
                AutoLayout          = AutoLayout.DockTop,
                Font = "font2"
            });

            frame.AddChild(new Widget
            {
                Text    = "View Demo Pane",
                Border  = "border-thin",
                OnClick = (sender, args) =>
                {
                    var dialog = GuiRoot.ConstructWidget(new DemoDialog());
                    GuiRoot.ShowDialog(dialog);
                },
                TextHorizontalAlign = HorizontalAlign.Center,
                TextVerticalAlign   = VerticalAlign.Center,
                AutoLayout          = AutoLayout.DockTop,
                Font = "font2"
            });

            frame.AddChild(new Widget
            {
                Text    = "View Tab Pane",
                Border  = "border-thin",
                OnClick = (sender, args) =>
                {
                    var dialog = GuiRoot.ConstructWidget(new TabDialog());
                    GuiRoot.ShowDialog(dialog);
                },
                TextHorizontalAlign = HorizontalAlign.Center,
                TextVerticalAlign   = VerticalAlign.Center,
                AutoLayout          = AutoLayout.DockTop,
                Font = "font2"
            });

            frame.AddChild(new Widget
            {
                Text    = "View Tilable Border Pane",
                Border  = "border-thin",
                OnClick = (sender, args) =>
                {
                    var dialog = GuiRoot.ConstructWidget(new BorderTilingDialog());
                    GuiRoot.ShowDialog(dialog);
                },
                TextHorizontalAlign = HorizontalAlign.Center,
                TextVerticalAlign   = VerticalAlign.Center,
                AutoLayout          = AutoLayout.DockTop,
                Font = "font2"
            });

            frame.AddChild(new Widget
            {
                Text    = "Toggle Alignment",
                Border  = "border-thin",
                OnClick = (sender, args) =>
                {
                    if (frame.AutoLayout == AutoLayout.FloatTopRight)
                    {
                        frame.AutoLayout = AutoLayout.FloatBottomRight;
                    }
                    else if (frame.AutoLayout == AutoLayout.FloatBottomRight)
                    {
                        frame.AutoLayout = AutoLayout.FloatBottomLeft;
                    }
                    else if (frame.AutoLayout == AutoLayout.FloatBottomLeft)
                    {
                        frame.AutoLayout = AutoLayout.FloatTopLeft;
                    }
                    else if (frame.AutoLayout == AutoLayout.FloatTopLeft)
                    {
                        frame.AutoLayout = AutoLayout.FloatTopRight;
                    }
                    else
                    {
                        frame.AutoLayout = AutoLayout.FloatTopLeft;
                    }
                    GuiRoot.RootItem.Layout();
                },
                TextHorizontalAlign = HorizontalAlign.Center,
                TextVerticalAlign   = VerticalAlign.Center,
                AutoLayout          = AutoLayout.DockTop,
                Font = "font2"
            });

            GuiRoot.RootItem.Layout();
        }