Пример #1
0
        public GI_Label(GameInterface gameInterface, Texture2D texture, GI_WindowCell cell, string text, GI_WindowCellObj obj)
            : base(gameInterface, texture, obj.Width, obj.Height, obj.Left, obj.Top, cell)
        {
            _obj            = obj;
            _textPosition   = Vector2.Zero;
            Text            = text;

            // ---------- Hook up events ----------
            _obj.PositionChanged += delegate()
            {
                AdjustTextPosition();
            };
        }
Пример #2
0
        public GI_WindowCellObj(GameInterface gameInterface, Texture2D texture, int width, int height, int x, int y, GI_WindowCell cell)
            : base(gameInterface, texture, width, height, x, y)
        {
            cell.AddObject(this);
            cell.Window.Closed += Close;

            Closed += delegate()
            {
                // TODO: Add closing event code here
            };
        }
Пример #3
0
        /// <summary>
        /// Split this cell into two child cells
        /// </summary>
        /// <param name="vertical">True for vertical, false for horizontal</param>
        /// <param name="splitRatio">The cross section where the split occurs</param>
        public void Split(bool vertical, float splitRatio = 0.5f)
        {
            // This cell should not contain anything, but we must guarantee that it doesn't
            _objs.Clear();

            // New cell sizes
            Vector2 size1 = new Vector2(Width, Height);
            Vector2 size2 = new Vector2(Width, Height);

            // New cell positions
            Vector2 position1 = new Vector2(Left, Top);
            Vector2 position2 = new Vector2(Left, Top);

            if (vertical)
            {
                // Split this cell vertically
                size1.X         = Width * splitRatio;
                size2.X         = Width - size1.X - TraceThickness;
                position2.X     = Left + size1.X + TraceThickness;

                _vertSplit      = true;
            }
            else
            {
                // Splits this cell horizontally
                size1.Y         = Height * splitRatio;
                size2.Y         = Height - size1.Y - TraceThickness;
                position2.Y     = Top + size1.Y + TraceThickness;

                _vertSplit      = false;
            }

            // Create the new cells
            _childCell1 = new GI_WindowCell(_gameInterface, _texture, (int)size1.X, (int)size1.Y, (int)position1.X, (int)position1.Y, _window);
            _childCell2 = new GI_WindowCell(_gameInterface, _texture, (int)size2.X, (int)size2.Y, (int)position2.X, (int)position2.Y, _window);

            // Update split boolean to indicate there are children
            _split = true;
        }
Пример #4
0
        /// <summary>
        /// Common constructor code
        /// All constructors should call this method
        /// </summary>
        private void Construct(string title)
        {
            _title = title;

            // ---------- Create main cell ----------
            _mainCell = new GI_WindowCell(_gameInterface, _texture,
                Width - (TraceThickness * 2), Height - (TraceThickness + TitlebarThickness),
                Left + TraceThickness, Top + TitlebarThickness, this);
            _objs.Add(_mainCell);

            // ---------- Add main window buttons ----------
            int buttonSize = TitlebarThickness - (TraceThickness * 2);

            GI_Button closeButton = new GI_Button(_gameInterface, _texture, buttonSize, buttonSize,
                Right - (buttonSize + TraceThickness), Top + TraceThickness, "X");
            closeButton.Clicked += delegate() { this.Close(); };
            _objs.Add(closeButton);
        }
Пример #5
0
        /// <summary>
        /// Create a new text field with a label
        /// </summary>
        public GI_TextField(GameInterface gameInterface, Texture2D texture, int width, int height, int x, int y, GI_WindowCell cell, string labelText)
            : base(gameInterface, texture, width, height, x, y, cell)
        {
            Construct();

            GI_Label label = new GI_Label(gameInterface, texture, cell, labelText, this);
        }
Пример #6
0
 /// <summary>
 /// Create a new text field
 /// </summary>
 public GI_TextField(GameInterface gameInterface, Texture2D texture, int width, int height, int x, int y, GI_WindowCell cell)
     : base(gameInterface, texture, width, height, x, y, cell)
 {
     Construct();
 }