コード例 #1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override async void LoadContent()
        {
            base.LoadContent();

            IO      = new IOComponent(this);
            Plugins = new PluginComponent(this);
            Network = new NetworkManager(this);

            await IO.Init();

            await IO.LoadConfig();

            await Network.Init();

            Content       = new ContentManager();
            TextureLoader = new TextureLoader(Graphics.GraphicsDevice);
            Content.LoadTextures(Path.Combine(IO.Directories["Content"], "Textures"), this);

            if (IO.Config.Client.Resolution.X == 0 && IO.Config.Client.Resolution.Y == 0)
            {
                Graphics.PreferredBackBufferWidth  = (int)(GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width * .9);
                Graphics.PreferredBackBufferHeight =
                    (int)(GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height * .8);
                Graphics.ApplyChanges();
                base.Window.Position =
                    new Point(
                        (GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width - Graphics.PreferredBackBufferWidth) /
                        2,
                        (GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height - Graphics.PreferredBackBufferHeight) /
                        2);
            }
            else
            {
                Graphics.PreferredBackBufferWidth  = IO.Config.Client.Resolution.X;
                Graphics.PreferredBackBufferHeight = IO.Config.Client.Resolution.Y;
                Graphics.ApplyChanges();
            }

            // Initialize MonoForce after loading skins.
            UI.Initialize();
            SpriteBatch = UI.Renderer.SpriteBatch; // Set the spritebatch to the Neoforce managed one


            // Create the main window for all content to be added to.
            Window = new MainWindow(UI, this);
            Window.Init();
            UI.Add(Window);
            Window.SendToBack();

            // Unlike the server, the clientside plugins must be loaded last.
            await Plugins.Init();

            // Now that all the textures have been loaded, set the block textures
            foreach (var block in BlockType.Blocks.Where(x => x.IsRenderable))
            {
                var str = "blocks." + (block.Category != null ? block.Category + "." : string.Empty) + block.Name;
                block.Texture = Content[str];
            }
        }
コード例 #2
0
ファイル: MapGameState.cs プロジェクト: VilRan/Legatus
        public MapGameState(FortressGame game)
            : base(game)
        {
            Game = game;
            MapView    view     = new MapView(game.Session.Map);
            UIViewport viewport = new UIViewport(0, 0, game.Width, game.Height, view, game);

            UI.Add(viewport);
        }
コード例 #3
0
        private void Init()
        {
            CurrentCircuit = BaseCircuit;
            toolBox        = new ToolBoxMenu();
            UI.Add(new SelectionPanel(toolBox, false));
            propMenu = new PropMenu();
            SelectionPanel s = new SelectionPanel(propMenu, true);

            s.pos.x = width;
            UI.Add(s);
            escapeKey = Keyboard.key("esc");
        }
コード例 #4
0
ファイル: Office.cs プロジェクト: kielthecoder/Home-Office
        private void InitializeUI()
        {
            _panels = new UI(this);

            if (_gw.Registered)
            {
                Log("Office::InitializeUI", "Creating TST-902 on {0}", _gw.Name);
                _tp = new Tst902(_cfg.GetInteger("panel", "rf_id", 0x03), _gw);
                _panels.Add_902(_tp);
            }

            Log("Office::InitializeUI", "Creating XPanel");
            _xpanel = new XpanelForSmartGraphics(_cfg.GetInteger("xpanel", "ip_id", 0x04), _sys);
            _panels.Add(_xpanel);

            Log("Office::InitializeUI", "Registering devices");
            _panels.Register();
        }
コード例 #5
0
        public App()
        {
            _gui = new UI();

            AppLayout.Load();

            var tabs = new Tabs("section_nav", Game.Canvas.Width, Game.Canvas.Height, AppLayout.Data.SectionSelectorTabWidth, AppLayout.Data.SectionSelectorTabHeight);

            var sprite_tab = tabs.AddTab("SPRITE");
            var map_tab    = tabs.AddTab("MAP");

            var sprite_editor = new SpriteEditor("sprite_editor", sprite_tab.Width, sprite_tab.Height);

            sprite_tab.Add(sprite_editor);

            sprite_editor.Align(Alignment.Center);

            _gui.Add(tabs);
        }
コード例 #6
0
        public ShipDesignerGameState(SpaceGame game)
            : base(game)
        {
            game.Resized += OnResized;

            Map = new ShipDesignerMap(game.Data);
            ShipDesignerMapView mapView     = new ShipDesignerMapView(Map);
            UIViewport          mapViewport = new UIViewport(96, 0, UI.Width - 96, UI.Height, mapView, game);

            mapViewport.IsAlwaysAtBottom = true;
            ShipDesignerModuleView moduleView     = new ShipDesignerModuleView(Map);
            UIViewport             moduleViewport = new UIViewport(0, 0, 96, UI.Height, moduleView, game);

            moduleViewport.IsAlwaysAtBottom = true;

            SpriteData     testSprite = game.Data.Sprites["TestIcon"];
            UIButtonSimple testButton = new UIButtonSimple(
                mapViewport.Bounds.Right - testSprite.Width * 4, mapViewport.Bounds.Bottom - testSprite.Height, testSprite.Width, testSprite.Height,
                Map.TestShip, testSprite.Base);
            //testButton.Tooltip = "Test the ship";

            SpriteData     newSprite = game.Data.Sprites["NewIcon"];
            UIButtonSimple newButton = new UIButtonSimple(
                mapViewport.Bounds.Right - newSprite.Width * 3, mapViewport.Bounds.Bottom - newSprite.Height, newSprite.Width, newSprite.Height,
                Map.NewShip, newSprite.Base);
            //newButton.Tooltip = "Create a new ship";

            SpriteData     saveSprite = game.Data.Sprites["SaveIcon"];
            UIButtonSimple saveButton = new UIButtonSimple(
                mapViewport.Bounds.Right - saveSprite.Width * 2, mapViewport.Bounds.Bottom - saveSprite.Height, saveSprite.Width, saveSprite.Height,
                Map.SaveShip, saveSprite.Base);
            //saveButton.Tooltip = "Save the current ship";

            SpriteData     loadSprite = game.Data.Sprites["LoadIcon"];
            UIButtonSimple loadButton = new UIButtonSimple(
                mapViewport.Bounds.Right - loadSprite.Width, mapViewport.Bounds.Bottom - loadSprite.Height, loadSprite.Width, loadSprite.Height,
                Map.LoadShip, loadSprite.Base);

            //loadButton.Tooltip = "Load a ship";

            UI.Add(testButton, newButton, saveButton, loadButton, moduleViewport, mapViewport);
        }
コード例 #7
0
        internal GSMenu(Vector2 center, int width, int height) : base(center, width, height)
        {
            Console.WriteLine("UIScale: " + Settings.UIScale);
            Console.WriteLine("Entering Menu!");

            UI.Add(new UITextObject(new Rectangle(-128, 10, 256, 128), Anchor.Top, GameState.canvas, "SETTINGS", Color.Black, font, textAlignment.Center, 3.0f, false));

            UI.Add(new UITextObject(new Rectangle(-384, -192, 256, 64), Anchor.Center, GameState.canvas, "RESOLUTION", Color.Black, font, textAlignment.Left, 1f, false));
            UI.Add(new UITextObject(new Rectangle(-384, -64, 256, 64), Anchor.Center, GameState.canvas, "WINDOW MODE", Color.Black, font, textAlignment.Left, 1f, false));
            UI.Add(new UITextObject(new Rectangle(-384, 64, 256, 64), Anchor.Center, GameState.canvas, "UI SIZE", Color.Black, font, textAlignment.Left, 1f, false));

            UI.Add(new UITextObject(new Rectangle(0, -192, 256, 64), Anchor.Center, GameState.canvas, "MASTER VOLUME", Color.Black, font, textAlignment.Left, 1f, false));
            UI.Add(new UITextObject(new Rectangle(0, -64, 256, 64), Anchor.Center, GameState.canvas, "MUSIC VOLUME", Color.Black, font, textAlignment.Left, 1f, false));
            UI.Add(new UITextObject(new Rectangle(0, 64, 256, 64), Anchor.Center, GameState.canvas, "EFFECT VOLUME", Color.Black, font, textAlignment.Left, 1f, false));

            UI.Add(resolutionButton = new CycleButton <Point>(new Rectangle(-184, -192, 128, 32), Anchor.Center, GameState.canvas, resolutionOptions, resolutionLabels));
            UI.Add(windowModeButton = new CycleButton <bool>(new Rectangle(-184, -64, 128, 32), Anchor.Center, GameState.canvas, new bool[] { false, true }, new string[] { "windowed", "fullscreen" }));
            UI.Add(UIScaleButton    = new CycleButton <float>(new Rectangle(-184, 64, 128, 32), Anchor.Center, GameState.canvas, uiScaleOptions, uiScaleLabels));

            UI.Add(masterVolumeButton = new CycleButton <float>(new Rectangle(224, -192, 128, 32), Anchor.Center, GameState.canvas, volumeOptions, volumeLabels));
            UI.Add(musicVolumeButton  = new CycleButton <float>(new Rectangle(224, -64, 128, 32), Anchor.Center, GameState.canvas, volumeOptions, volumeLabels));
            UI.Add(effectVolumeButton = new CycleButton <float>(new Rectangle(224, 64, 128, 32), Anchor.Center, GameState.canvas, volumeOptions, volumeLabels));

            UI.Add(exitGameButton = new UIButton(new Rectangle(16, -96, 64, 32), "views/menu/wood_button_2", "", Anchor.Bottom, GameState.canvas));
            new UITextObject(exitGameButton, "EXIT", Color.Black, font, textAlignment.Center, 1.0f, false);

            UI.Add(continueButton = new UIButton(new Rectangle(-80, -96, 64, 32), "views/menu/wood_button_2", "", Anchor.Bottom, GameState.canvas));
            new UITextObject(continueButton, "APPLY", Color.Black, font, textAlignment.Center, 1.0f, false);

            resolutionButton.SetCurrentValue(Settings.Resolution);
            windowModeButton.SetCurrentValue(Settings.FullScreen);
            UIScaleButton.SetCurrentValue(Settings.UIScale);
            masterVolumeButton.SetCurrentValue(Settings.MasterVolume);
            musicVolumeButton.SetCurrentValue(Settings.MusicVolume);
            effectVolumeButton.SetCurrentValue(Settings.EffectVolume);

            continueButton.OnMouseUp += StartHandler;
            exitGameButton.OnMouseUp += ExitHandler;
        }
コード例 #8
0
        public override void Load()
        {
            ui = new UI()
            {
                DrawStats = false
            };

            var tabs = new Tabs("tabs", Game.Canvas.Width, Game.Canvas.Height, 200, 20);

            var panel1 = tabs.AddTab("Window");
            var panel2 = tabs.AddTab("List View");
            var panel3 = tabs.AddTab("Layout");

            var button_panel_1 = new Button("button_panel_1", "Open Window", 160);

            var list_view = new ListView("list_view", 250, 200);

            list_view.AddItem("Item1", null);
            list_view.AddItem("Item2", null);
            list_view.AddItem("Item3", null);
            list_view.AddItem("Item4", null);
            list_view.AddItem("Item1", null);
            list_view.AddItem("Item2", null);
            list_view.AddItem("Item3", null);
            list_view.AddItem("Item4", null);
            list_view.AddItem("Item1", null);
            list_view.AddItem("Item2", null);
            list_view.AddItem("Item3", null);
            list_view.AddItem("Item4", null);
            list_view.AddItem("Item1", null);
            list_view.AddItem("Item2", null);
            list_view.AddItem("Item3", null);

            list_view.OnSelect += item => { Console.WriteLine($"Selected: {item.Label}"); };

            var layout_container = new Container("layout_container", 300, 300);

            layout_container.Add(new Button("layout_container_b1", "B1", 50));
            layout_container.Add(new Button("layout_container_b2", "B3", 50));
            layout_container.Add(new Button("layout_container_b2", "B3", 50));

            layout_container.Layout(Orientation.Vertical, ContainerAlignment.Stretch, ContainerAlignment.End, 10, 10);

            layout_container.DebugColor = 10;

            panel1.Add(button_panel_1);

            panel2.Add(list_view);

            panel3.Add(layout_container);

            layout_container.Align(Alignment.Center);

            button_panel_1.Align(Alignment.Center);

            list_view.Align(Alignment.Center);

            ui.Add(tabs);

            var window = new Window("window", 300, 300);

            ui.SetVisible(window, false);

            ui.Add(window);

            button_panel_1.OnClick += () => { window.ShowAndFocus(); };
        }
コード例 #9
0
ファイル: MainMenu.cs プロジェクト: EliasSelenius/LogicSim
 public MainMenu()
 {
     UI.Add(new UIButton("New", new NewWorkTable(), new Vector2(width / 2 - 150, height / 2), new Vector2(300, 50)));
     UI.Add(new UIButton("Load", null, new Vector2(width / 2 - 150, height / 2 + 55), new Vector2(300, 50)));
     UI.Add(new UIButton("Exit", new ExitApp(), new Vector2(width / 2 - 150, height / 2 + 110), new Vector2(300, 50)));
 }