public virtual void Check(ViewController view, Align.Align align)
        {
            // int mouseX = view.GetMouse().X;
            // int mouseY = view.GetMouse().Y;
            // int ulCornerX = (int)position.X;
            // int ulCornerY = (int)position.Y;
            // int brCornerX = ulCornerX + align.width;
            // int brCornerY = ulCornerY + align.height;
            Rectangle Rect = new Rectangle((int)position.X, (int)position.Y, align.width, align.height);

            for (int i = 0; i < Animations.Count; i++)
            {
                //Rect = Animations[i].Apply(Rect, view.animationDelta);
            }

            //if (mouseX > ulCornerX && mouseY > ulCornerY && mouseX < brCornerX && mouseY < brCornerY)
            if (Rect.Contains(view.GetMouse().Position))
            {
                if (view.GetMouse().LeftButton == ButtonState.Released)
                {
                    wasClicked = false;
                }
                if (view.GetMouse().LeftButton == ButtonState.Pressed && !wasClicked)
                {
                    handler(view.GetMouse(), this);
                    wasClicked = true;
                }
            }
        }
 public Screen(int screenId, string backgroundTexture, Align.Align align, bool DoesOcclusion = true)
 {
     this.screenId          = screenId;
     this.backgroundTexture = backgroundTexture;
     this.align             = align;
     this.align.Screen      = this;
     this.DoesOcclusion     = DoesOcclusion;
 }
Esempio n. 3
0
 public SystemScreen(int screenId, string backgroundTexture, int systemId, Align.Align align) : base(screenId, backgroundTexture, align)
 {
     this.screenId          = screenId;
     this.backgroundTexture = backgroundTexture;
     this.systemId          = systemId;
     exitButton             = new InvisibleButton(new CornerAlign(Corner.BOTTOMRIGHT, 64, 25), ExitScreen);
     AddButton(exitButton);
 }
Esempio n. 4
0
 public TextBox(string textboxTextureId, string initialText, Align.Align align, MouseHandler onClick = null,
                TextboxHandler outOfFocus = null, TextboxHandler updateKey = null, int charLimit = 26) : base(
         textboxTextureId, initialText, onClick)
 {
     this.align      = align;
     Value           = initialText;
     this.charLimit  = charLimit;
     this.outOfFocus = outOfFocus;
     this.updateKey  = updateKey;
 }
Esempio n. 5
0
 public Slider(string sliderTextureId, int initialValue, Align.Align align, int minValue, int maxValue,
               float increment           = 1.0f, MouseHandler onClick = null, SliderHandler outOfFocus = null,
               SliderHandler updateValue = null) : base(sliderTextureId, "", align, onClick)
 {
     this.align       = align;
     Value            = initialValue;
     this.outOfFocus  = outOfFocus;
     this.updateValue = updateValue;
     this.minValue    = minValue;
     this.maxValue    = maxValue;
     this.increment   = increment;
 }
 public override void Check(ViewController view, Align.Align align)
 {
     if (align.GetRect(view).Contains(view.GetMouse().Position))
     {
         if (view.GetMouse().LeftButton == ButtonState.Released)
         {
             wasClicked = false;
         }
         if (view.GetMouse().LeftButton == ButtonState.Pressed && !wasClicked)
         {
             handler(view.GetMouse(), this);
             wasClicked = true;
         }
     }
 }
Esempio n. 7
0
        public override void Check(ViewController view, Align.Align align)
        {
            int mouseX    = view.GetMouse().X;
            int mouseY    = view.GetMouse().Y;
            int ulCornerX = (int)position.X;
            int ulCornerY = (int)position.Y;
            int brCornerX = ulCornerX + align.width;
            int brCornerY = ulCornerY + align.height;

            if (view.GetMouse().LeftButton == ButtonState.Released)
            {
                wasClicked = false;
            }
            if (view.GetMouse().LeftButton == ButtonState.Pressed && !wasClicked)
            {
                if (mouseX > ulCornerX && mouseY > ulCornerY && mouseX < brCornerX && mouseY < brCornerY)
                {
                    if (handler != null)
                    {
                        handler(view.GetMouse(), this);
                    }
                    inFocus    = true;
                    wasClicked = true;
                }
                else
                {
                    inFocus = false;
                    if (outOfFocus != null)
                    {
                        outOfFocus(this, Value);
                    }
                }

                Debug.WriteLine("clicked " + mouseX + " br" + brCornerX);
            }
        }
 public InvisibleButton(Align.Align align, MouseHandler mouseHandler) : base("", "", align, mouseHandler)
 {
 }
 public SystemScreenAlign(Align parentAlign, int systemId, int width = 320, int height = 294, int leftMargin = 0, int topMargin = 0, int rightMargin = 0, int bottomMargin = 0) : base(width, height, leftMargin, topMargin, rightMargin, bottomMargin)
 {
     this.systemId    = systemId;
     this.parentAlign = parentAlign;
 }
Esempio n. 10
0
 public Button(string buttonTextureId, string text, Align.Align align, MouseHandler mouseHandler) : this(buttonTextureId, text, mouseHandler)
 {
     // TODO Fix this
     this.align = align;
 }
Esempio n. 11
0
        public override void Check(ViewController view, Align.Align align)
        {
            int mouseX    = view.GetMouse().X;
            int mouseY    = view.GetMouse().Y;
            int ulCornerX = (int)position.X;
            int ulCornerY = (int)position.Y;
            int brCornerX = ulCornerX + align.width;
            int brCornerY = ulCornerY + align.height;

            if (view.GetMouse().LeftButton == ButtonState.Released)
            {
                wasClicked = false;
            }
            if (view.GetMouse().LeftButton == ButtonState.Pressed && !wasClicked)
            {
                if (mouseX > ulCornerX && mouseY > ulCornerY && mouseX < brCornerX && mouseY < brCornerY)
                {
                    if (handler != null)
                    {
                        handler(view.GetMouse(), this);
                    }
                    inFocus    = true;
                    wasClicked = true;
                }
                else
                {
                    inFocus = false;
                    if (outOfFocus != null)
                    {
                        outOfFocus(this, Value);
                    }
                }
                Debug.WriteLine("clicked " + mouseX + " br" + brCornerX);
            }
            var keys = Keyboard.GetState().GetPressedKeys();

            if (keys.Contains(Keys.LeftShift) || keys.Contains(Keys.Right))
            {
                shift = true;
            }
            else
            {
                shift = false;
            }
            if (inFocus && Array.FindAll(keys, p => (p != Keys.LeftShift) && (p != Keys.RightShift)).Length > 0)
            {
                currentKey = Array.Find(keys, p => (p != Keys.LeftShift) && (p != Keys.RightShift));
            }
            if (inFocus && currentKey != Keys.None && Keyboard.GetState().IsKeyUp(currentKey))
            {
                var letter = currentKey.ToString();
                if (letter.Length > 1)
                {
                    letter = "";
                }
                if (currentKey == Keys.Back)
                {
                    if (Value.Length > 0)
                    {
                        Value = Value.Remove(Value.Length - 1, 1);
                    }
                }
                else if (currentKey == Keys.Space)
                {
                    if (Value.Length < charLimit)
                    {
                        Value += " ";
                    }
                }
                else if (currentKey == Keys.Enter)
                {
                    inFocus = false;
                }
                else
                {
                    if (Value.Length < charLimit)
                    {
                        Value += shift ? letter : letter.ToLower();
                    }
                }
                currentKey = Keys.None;
            }
        }
 public ForceOrganizerScreen(int screenId, string backgroundTexture, Align.Align align, bool DoesOcclusion = true) : base(screenId, backgroundTexture, align, DoesOcclusion)
 {
 }
Esempio n. 13
0
 public PlanetScreen(int screenId, string backgroundTexture, Align.Align align, int systemId, int planetId) : base(screenId, backgroundTexture, align)
 {
     this.systemId = systemId;
     this.planetId = planetId;
     AddButton(new Button("", "Attack", new RectAlign(this, new Vector2(200, 270), 20, 20), Attack));
 }
Esempio n. 14
0
 public CornerAlign(Corner corner, int width, int height, Align parentAlign, int leftMargin = 0, int topMargin = 0, int rightMargin = 0, int bottomMargin = 0) : base(width, height, leftMargin, topMargin, rightMargin, bottomMargin)
 {
     Corner           = corner;
     this.parentAlign = parentAlign;
 }
Esempio n. 15
0
 public GroundCombatScreen(int screenId, string backgroundTexture, Align.Align align, Planet planet, bool DoesOcclusion = true) : base(screenId, backgroundTexture, align, DoesOcclusion)
 {
     this.planet = planet;
 }
 public EdgeAlign(Edge edge, int width, int height, Align superAlign, int leftMargin = 0, int topMargin = 0, int rightMargin = 0, int bottomMargin = 0) : base(width, height, leftMargin, topMargin, rightMargin, bottomMargin)
 {
     this.edge       = edge;
     this.superAlign = superAlign;
 }
Esempio n. 17
0
        public Ledger(int screenId, string backgroundTexture, Align.Align align, bool DoesOcclusion = true) : base(screenId, backgroundTexture, align, DoesOcclusion)
        {
            Button closeLedger = new Button("creation_arrow_right", "", new EdgeAlign(Edge.TOPLEFTOFRIGHT, 20, 20, align, leftMargin: 6, topMargin: -22), ToggleLedger);

            AddButton(closeLedger);
        }
 public CharacterCreatorScreen(int screenId, string backgroundTexture, Align.Align align, bool DoesOcclusion = true) : base(screenId, backgroundTexture, align, DoesOcclusion)
 {
 }