Ejemplo n.º 1
0
        protected override void LoadContent()
        {
            LogSentryBreadcrumb("Loading", "LoadContent was called.", BreadcrumbLevel.Info);
            AssetManager.Initialize(Content, GraphicsDevice, GameSettings.Current);


            //DwarfSprites.LayerLibrary.ConvertTestPSD();


            // Prepare GemGui
            if (GumInputMapper == null)
            {
                GumInputMapper = new Gui.Input.GumInputMapper(Window.Handle);
                GumInput       = new Gui.Input.Input(GumInputMapper);
            }

            GuiSkin = new RenderData(GraphicsDevice, Content);

            // Create console.
            ConsoleGui = new Gui.Root(GuiSkin);
            ConsoleGui.RootItem.AddChild(new Gui.Widgets.AutoGridPanel
            {
                Rows       = 2,
                Columns    = 4,
                AutoLayout = AutoLayout.DockFill
            });

            ConsoleGui.RootItem.Layout();
            if (_logwriter != null)
            {
                _logwriter.SetConsole(GetConsoleTile("LOG"));
            }

            Console.Out.WriteLine("Console created.");

            if (SoundManager.Content == null)
            {
                SoundManager.Content = Content;
                SoundManager.LoadDefaultSounds();
            }

            if (GameStateManager.StateStackIsEmpty)
            {
                LogSentryBreadcrumb("GameState", "There was nothing in the state stack. Starting over.");
                if (GameSettings.Current.DisplayIntro)
                {
                    GameStateManager.PushState(new IntroState(this));
                }
                else
                {
                    GameStateManager.PushState(new MainMenuState(this));
                }
            }

            ControlSettings.Load();
            Drawer2D.Initialize(Content, GraphicsDevice);
            ScreenSaver = new Terrain2D(this);

            base.LoadContent();
        }
Ejemplo n.º 2
0
        public static Gui.TextureAtlas.SpriteAtlasEntry GetDynamicSheet(Gui.Root Root, ResourceType.GuiGraphic Graphic)
        {
            var sheetName = Graphic.GetSheetIdentifier();
            var tex       = ResourceGraphicsHelper.GetResourceTexture(Root.RenderData.Device, Graphic);

            return(Root.SpriteAtlas.AddDynamicSheet(sheetName, new TileSheetDefinition
            {
                TileHeight = Graphic.FrameSize.Y,
                TileWidth = Graphic.FrameSize.X,
                Type = TileSheetType.TileSheet
            }, tex));
        }
Ejemplo n.º 3
0
        public override void OnEnter()
        {
            DwarfGame.GumInputMapper.GetInputQueue();

            if (GuiRoot == null)
            {
                GuiRoot = new Gui.Root(DwarfGame.GuiSkin);
                GuiRoot.MousePointer  = new Gui.MousePointer("mouse", 4, 0);
                GuiRoot.RootItem.Font = "font8";

                _Output = GuiRoot.RootItem.AddChild(new Gui.Widgets.TextBox
                {
                    Border   = "speech-bubble-reverse",
                    TextSize = 1,
                    Font     = "font16"
                }) as Gui.Widgets.TextBox;


                ChoicePanel = GuiRoot.RootItem.AddChild(new Widget
                {
                    Border      = null,
                    TextSize    = 1,
                    Font        = GameSettings.Default.GuiScale == 1 ? "font16" : "font10",
                    Transparent = true
                });

                SpeakerBorder = GuiRoot.RootItem.AddChild(new Widget
                {
                    Border = "border-dark",
                });

                PositionItems();

                if (_employee != null)
                {
                    setupPortrait();
                }
            }

            IsInitialized = true;
            base.OnEnter();
        }
Ejemplo n.º 4
0
 public override void OnEnter()
 {
     GuiRoot = new Gui.Root(DwarfGame.GuiSkin);
     GuiRoot.MousePointer = new Gui.MousePointer("mouse", 4, 0);
     Viewer = GuiRoot.RootItem.AddChild(new EventLogViewer()
     {
         Log            = Log,
         Now            = Now,
         Rect           = GuiRoot.RenderData.VirtualScreen,
         AutoLayout     = AutoLayout.DockFill,
         InteriorMargin = new Margin(32, 32, 16, 16)
     }) as EventLogViewer;
     Viewer.CloseButton.OnClick = (sender, args) =>
     {
         StateManager.PopState();
     };
     // Must be true or Render will not be called.
     IsInitialized = true;
     GuiRoot.RootItem.Layout();
     base.OnEnter();
 }
Ejemplo n.º 5
0
 public static Gui.TextureAtlas.SpriteAtlasEntry GetDynamicSheet(Gui.Root Root, ResourceType.GuiGraphic Graphic)
 {
     if (Graphic == null)
     {
         var tex = AssetManager.GetContentTexture("newgui/error");
         return(Root.SpriteAtlas.AddDynamicSheet("error", new TileSheetDefinition
         {
             TileHeight = 32,
             TileWidth = 32,
             Type = TileSheetType.TileSheet
         }, tex));
     }
     else
     {
         var sheetName = Graphic.GetSheetIdentifier();
         var tex       = ResourceGraphicsHelper.GetResourceTexture(Root.RenderData.Device, Graphic);
         return(Root.SpriteAtlas.AddDynamicSheet(sheetName, new TileSheetDefinition
         {
             TileHeight = Graphic.FrameSize.Y,
             TileWidth = Graphic.FrameSize.X,
             Type = TileSheetType.TileSheet
         }, tex));
     }
 }
Ejemplo n.º 6
0
        protected override void LoadContent()
        {
#if SHARP_RAVEN && !DEBUG
            try
            {
#endif
            AssetManager.Initialize(Content, GraphicsDevice, GameSettings.Default);

            //var palette = TextureTool.ExtractPaletteFromDirectoryRecursive("Entities/Dwarf");
            //var paletteTexture = TextureTool.Texture2DFromMemoryTexture(GraphicsDevice, TextureTool.MemoryTextureFromPalette(palette));
            //paletteTexture.SaveAsPng(System.IO.File.OpenWrite("palette.png"), paletteTexture.Width, paletteTexture.Height);

            // Prepare GemGui
            if (GumInputMapper == null)
            {
                GumInputMapper = new Gui.Input.GumInputMapper(Window.Handle);
                GumInput       = new Gui.Input.Input(GumInputMapper);
            }
            // Register all bindable actions with the input system.
            //GumInput.AddAction("TEST", Gui.Input.KeyBindingType.Pressed);

            GuiSkin = new RenderData(GraphicsDevice, Content);

            // Create console.
            ConsoleGui = new Gui.Root(GuiSkin);
            ConsoleGui.RootItem.AddChild(new Gui.Widgets.AutoGridPanel
            {
                Rows       = 2,
                Columns    = 4,
                AutoLayout = AutoLayout.DockFill
            });

            ConsoleGui.RootItem.Layout();
            if (_logwriter != null)
            {
                _logwriter.SetConsole(GetConsoleTile("LOG"));
            }

            Console.Out.WriteLine("Console created.");

            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
            }

            if (StateManager.StateStack.Count == 0)
            {
                if (GameSettings.Default.DisplayIntro)
                {
                    StateManager.PushState(new IntroState(this, StateManager));
                }
                else
                {
                    StateManager.PushState(new MainMenuState(this, StateManager));
                }
            }
            BiomeLibrary.InitializeStatics();
            EmbarkmentLibrary.InitializeDefaultLibrary();
            VoxelChunk.InitializeStatics();
            ControlSettings.Load();
            Drawer2D.Initialize(Content, GraphicsDevice);
            ResourceLibrary.Initialize();
            base.LoadContent();
#if SHARP_RAVEN && !DEBUG
        }

        catch (Exception exception)
        {
            if (ravenClient != null)
            {
                ravenClient.Capture(new SentryEvent(exception));
            }
            throw;
        }
#endif
        }
Ejemplo n.º 7
0
 public static Gui.TextureAtlas.SpriteAtlasEntry GetDynamicSheet(Gui.Root Root, Resource Resource)
 {
     return(GetDynamicSheet(Root, Resource.Gui_Graphic));
 }