Esempio n. 1
1
        public override void LoadContent(ContentManager content)
        {
            base.LoadContent(content);

            Background = Content.Load<Texture2D>(@"Texture\Menu\BG");

            gui = new GUI.GUI(@"Fonts\Menu");
            gui.LoadContent(Content);
            gui.CreateButton(new Vector2(ScreenManager.instance.ScreenSize.X / 2 - gui.Font.MeasureString("Start").X / 2,
                               ScreenManager.instance.ScreenSize.Y / 2.5f), "Start");
            gui.CreateButton(new Vector2(ScreenManager.instance.ScreenSize.X / 2 - gui.Font.MeasureString("Exit").X / 2,
                               ScreenManager.instance.ScreenSize.Y / 2.5f + 50), "Exit");

            gui.Buttons[0].OnClick += (object a, EventArgs b) =>
            {
                (a as Button).color = Color.DarkRed;
                Task.WaitAll(Task.Factory.StartNew(() => form.ShowDialog()));
                //form.ShowDialog();
            };

            gui.Buttons[1].OnClick += (object a, EventArgs b) =>
            {
                Screen.ScreenManager.instance.game.Content.Unload();
                Screen.ScreenManager.instance.game.Exit();
            };
        }
Esempio n. 2
0
        public void Initialize()
        {
            TestGui = new GUI.GUI(false);
            TestGui.tvItems.Nodes.Clear();

            if (File.Exists(NewItemFilePath))
            {
                File.Delete(NewItemFilePath);
            }
            if (File.Exists(RenamedItemPath))
            {
                File.Delete(RenamedItemPath);
            }
            if (File.Exists(NewItemInFolderFilePath))
            {
                File.Delete(NewItemInFolderFilePath);
            }
            if (File.Exists(RenamedItemInFolderFilePath))
            {
                File.Delete(RenamedItemInFolderFilePath);
            }
            if (Directory.Exists(NewFolderFilePath))
            {
                Directory.Delete(NewFolderFilePath);
            }
            if (!Directory.Exists("Content/" + RessourcePath))
            {
                Directory.CreateDirectory("Content/" + RessourcePath);
            }

            TestGui.AddEditor(new EditorInfo(new string[] { BaseEditor.GUIRootPathUnitsNormal, BaseEditor.GUIRootPathUnits }, RessourcePath, new string[] { ItemExtention },
                                             typeof(UnitNormalEditor)));

            TestGui.InitGUI();
        }
Esempio n. 3
0
        public Window() {
#endif
            gui = new GUI.GUI(DriverManager.ActiveDriver, this);

            graphics = new GraphicsDeviceManager(this);
            inputHelper = new XNARenderer.InputHelper(this);

#if WINDOWS
            this.IsMouseVisible = true;
            graphics.PreferredBackBufferWidth = width;
            graphics.PreferredBackBufferHeight = height;
            graphics.IsFullScreen = fullScreen;
            graphics.ApplyChanges();
#elif WINDOWS_PHONE
            DriverManager.AssignDriverInstance(new Driver());
            DriverManager.ActiveDriver.Initialize();

            System sys = DriverManager.ActiveDriver.System as System;
            sys.GameWindow = this;
            // Frame rate is 30 fps by default for Windows Phone.
            TargetElapsedTime = TimeSpan.FromTicks(333333);

            Window.OrientationChanged += new EventHandler<EventArgs>(Window_OrientationChanged);
#endif

            Content.RootDirectory = "Content";
        }
        public override void Initialize()
        {
            SceneManagement.Instance = new SceneManagement();
            InputManager.Instance    = new InputManager();
            Camera.Instance          = new Camera(GraphicsDevice.Viewport);


            GUI.GUI gui = new GUI.GUI();
            GUI.GUI.spriteBatch  = SpriteBatch;
            GUI.GUI.ScreenBounds = GraphicsDevice.Viewport.Bounds;

            Debug.Initialize("debugFont");

            base.Initialize();
        }
Esempio n. 5
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            GUI.GUI.Font = Content.Load<SpriteFont>("font");
            FullModel.LoadContent(this);

            // creation of elements
            this.gui = new GUI.GUI(this);
            GUIElement root = GUIElementFactory.CreateStateElement(this, Descent.State.State.ActivateMonsters, Descent.Model.Player.Role.Overlord, null);
            GUIElement createGame = new GUIElement(this, "create", (GraphicsDevice.Viewport.Width - 300) / 2, 400, 300, 100);
            GUIElement joinGame = new GUIElement(this, "join", (GraphicsDevice.Viewport.Width - 300) / 2, 550, 300, 100);
            GUIElement changeName = new GUIElement(this, "changeName", (GraphicsDevice.Viewport.Width - 200) / 2, 250, 200, 100);
            InputElement nameInput = new InputElement(this, "nameInput", changeName.Bound.X + 10, changeName.Bound.Y + (changeName.Bound.Height - 30) / 2, changeName.Bound.Width - 20, 30);
            InputElement connectInput = new InputElement(this, "connectInput", joinGame.Bound.X + 10, joinGame.Bound.Y + (joinGame.Bound.Height - 30) / 2, 150, 30);
            GUIElement buttonCreateGame = new GUIElement(this, "doneCreate", createGame.Bound.X + (createGame.Bound.Width - 100) / 2, createGame.Bound.Y + (createGame.Bound.Height - 30) / 2, 120, 30);
            GUIElement buttonJoinGame = new GUIElement(this, "doneJoin", joinGame.Bound.X + 200, joinGame.Bound.Y + (joinGame.Bound.Height - 30) / 2, 80, 30);

            // assembling tree
            root.AddChild(createGame);
            root.AddChild(joinGame);
            root.AddChild(changeName);
            changeName.AddChild(nameInput);
            createGame.AddChild(buttonCreateGame);
            joinGame.AddChild(connectInput);
            joinGame.AddChild(buttonJoinGame);

            // adding visual to tree
            changeName.SetBackground("boxbg");
            joinGame.SetBackground("boxbg");
            createGame.SetBackground("boxbg");
            nameInput.SetBackground("boxbg");
            connectInput.SetBackground("boxbg");
            buttonCreateGame.SetBackground("boxbg");
            buttonJoinGame.SetBackground("boxbg");
            Image logo = new Image(Content.Load<Texture2D>("logo-descent"));
            root.AddDrawable(root.Name, logo, new Vector2((root.Bound.Width - logo.Texture.Bounds.Width) / 2.0f, 50));

            // adding logic to tree
            root.SetDrawBackground(false);

            root.AddText("changeName", "Name:", new Vector2(5, 0));
            root.AddText("doneCreate", "New Game!", new Vector2(5, 0));
            root.AddText("doneJoin", "Join!", new Vector2(25, 0));
            root.SetClickAction("doneCreate", (n, g) =>
            {
                // Start the game. TODO: Try/catch error handling.
                n.StartGame(1337);

                // Set the nickname. Since this is the server, it will be set on id 1 always.
                if (InputElement.GetInputFrom("nameInput").Length > 0)
                {
                    n.Nickname = InputElement.GetInputFrom("nameInput");
                }

                // Create the state manager.
                n.StateManager = new StateManager(gui);
            });

            root.SetClickAction("doneJoin", (n, g) =>
            {
                g.SetClickAction(g.Name, null);
                n.JoinGame(InputElement.GetInputFrom("connectInput"), 1337);

                Player.Instance.EventManager.AcceptPlayerEvent += new AcceptPlayerHandler((sender, eventArgs) =>
                {
                    if (eventArgs.PlayerId == Player.Instance.Id)
                    {
                        if (InputElement.GetInputFrom("nameInput").Length > 0)
                        {
                            n.Nickname = InputElement.GetInputFrom("nameInput");
                        }

                        n.StateManager = new StateManager(gui);

                        Player.Instance.EventManager.QueueEvent(EventType.PlayerJoined, new PlayerJoinedEventArgs(Player.Instance.Id, Player.Instance.Nickname));
                    }
                });
            });

            Player.Instance.EventManager.PlayerJoinedEvent += new PlayerJoinedHandler((sender, eventArgs) =>
            {
                // If the PlayerJoined event is about our local player(the id will be set just before this, so

            });

            // placing the root in the gui
            gui.ChangeStateGUI(root);
        }