コード例 #1
0
ファイル: Window.cs プロジェクト: jrs1498/IsometricProject
        private GI_Window _window; // Window containing this cell

        #endregion Fields

        #region Constructors

        public GI_WindowCell(GameInterface gameInterface, Texture2D texture, int width, int height, int x, int y, GI_Window window)
            : base(gameInterface, texture, width, height, x, y, true)
        {
            _window = window;
            _viewPosition = Vector2.Zero;
            _split = false;

            // ---------- Hook up events ----------
            PositionChanged += delegate()
            {
                if (_split)
                {
                    _childCell1.Position = Position;
                    Vector2 relativePosition = _childCell2.Position - _previousPosition;
                    _childCell2.Position = Position + relativePosition;
                }
            };
        }
コード例 #2
0
        private void LoadInterface(Texture2D texture)
        {
            GI_DropdownMenu mainmenu = new GI_DropdownMenu(this, texture);
            _objs.Add(mainmenu);

            // ---------- File submenu ----------
            GI_DropdownSubmenu file = new GI_DropdownSubmenu(this, texture);
            _objs.Add(file);

            file.AddButton(() => { Console.WriteLine("New level placeholder button"); }, "New");
            file.AddButton(() => { _screen.GameLevel.SaveLevel("poopies"); }, "Save");
            file.AddButton(() => { Console.WriteLine("save as button"); }, "Save As");
            file.AddButton(() => { Console.WriteLine("Open file placeholder button"); }, "Open");

            mainmenu.AddSubMenu(file, "File");

            // ---------- Tools submenu ----------
            GI_DropdownSubmenu tools = new GI_DropdownSubmenu(this, texture);
            _objs.Add(tools);

            tools.AddButton(() => { _screen.GameLevel.MainLayer.TileSystem.CurrentTool = TileSystem.Tool.elevate; }, "Elevate");
            tools.AddButton(() => { _screen.GameLevel.MainLayer.TileSystem.CurrentTool = TileSystem.Tool.smooth; }, "Smooth");
            tools.AddButton(() => { _screen.GameLevel.MainLayer.TileSystem.CurrentTool = TileSystem.Tool.zeroelevation; }, "Zero Elevation");

            mainmenu.AddSubMenu(tools, "Tools");

            // ========== WINDOWS SUBMENU START ==========
            GI_DropdownSubmenu windows = new GI_DropdownSubmenu(this, texture);
            _objs.Add(windows);

            // ----- Content Browser -----
            GI_Window contentBrowser = new GI_Window(this, texture, _initialWindowWidth, _initialWindowHeight, 200, 200, "Content Browser");
            windows.AddButtonForObj(contentBrowser, "Content Browser");
            _objs.Add(contentBrowser);

            contentBrowser.MainCell.Split(true, 0.6f);
            contentBrowser.MainCell.Child2.Split(false, 0.7f);

            GI_WindowCell contentCell   = contentBrowser.MainCell.Child1;
            GI_WindowCell infoCell      = contentBrowser.MainCell.Child2.Child1;
            GI_WindowCell fileCell      = contentBrowser.MainCell.Child2.Child2;

            // Info cell
            Vector2 selectorSize = new Vector2(100, 140);
            Vector2 selectorPosition;
            selectorPosition.X = (infoCell.Left + (infoCell.Width / 2)) - (selectorSize.X / 2);
            selectorPosition.Y = infoCell.Top + 10;
            GI_WindowCellObj selectionIndicator = new GI_WindowCellObj(this, texture, (int)selectorSize.X, (int)selectorSize.Y, (int)selectorPosition.X, (int)selectorPosition.Y, infoCell);

            Vector2 textFieldSize = new Vector2(120, 16);
            GI_TextField textfieldRefernceID = new GI_TextField(this, texture, (int)textFieldSize.X, (int)textFieldSize.Y, infoCell.Left + (infoCell.Width / 2), infoCell.Bottom - 100, infoCell, "Reference ID:");
            GI_TextField textfieldTextureName = new GI_TextField(this, texture, (int)textFieldSize.X, (int)textFieldSize.Y, infoCell.Left + (infoCell.Width / 2), textfieldRefernceID.Bottom + 10, infoCell, "Texture Name:");

            // Content cell
            Dictionary<short, CL_ObjType> content = _screen.ContentLib.GetLoadedFile("tiletypes");
            int i = 0;
            foreach (KeyValuePair<short, CL_ObjType> element in content)
            {
                CL_ObjType tile = new CL_ObjType(element.Value.ReferenceID, element.Value.Texture);
                GI_ContentButton button = new GI_ContentButton(this, 50, 70, contentCell.Left + (i * 60), contentCell.Top, tile);
                contentCell.AddObject(button);
                button.Clicked += delegate()
                {
                    _screen.GameLevel.MainLayer.TileSystem.CurrentTileReference = tile.ReferenceID;
                    selectionIndicator.Texture = tile.Texture;
                    textfieldRefernceID.Text = "" + tile.ReferenceID;
                    textfieldTextureName.Text = tile.Texture.ToString();
                };
                i++;
            }

            // ----- Another Window -----

            mainmenu.AddSubMenu(windows, "Windows");
            // ========== WINDOWS SUBMENU END ==========
        }
コード例 #3
0
 public GI_WindowComponent(GameInterface gameInterface, Texture2D texture, int width, int height, int x, int y, GI_Window window)
     : base(gameInterface, texture, width, height, x, y)
 {
     _window = window;
 }