Esempio n. 1
0
        public Slider(
            IRenderer renderer,
            string label,
            IParams <float> parameter,
            int element,
            float min,
            float max,
            float displayMin,
            float displayMax,
            IUniformBuffer uniformbuffer
            )
        {
            this.renderer  = renderer;
            this.parameter = parameter;
            this.element   = element;
            Name           = label;

            Style      = Style.Foreground;
            textBuffer = new TextBuffer(Style.Font);
            ninePatch  = new NinePatch(Style.NinePatchStyle);

            Min        = min;
            Max        = max;
            DisplayMin = displayMin;
            DisplayMax = displayMax;

            if (parameter != null)
            {
                CurrentValue = parameter[element];
            }
            Label = label;

            this.uniformBuffer = uniformbuffer;
        }
Esempio n. 2
0
        public ColorPicker(
            //FramebufferManager framebufferManager,
            MaterialManager materialManager,
            IRenderer renderer
            )
        {
            GeometryMesh discMesh = new GeometryMesh(
                new RenderStack.Geometry.Shapes.Disc(1.0, 0.8, 32, 2),
                NormalStyle.PolygonNormals
                );
            GeometryMesh triangleMesh = new GeometryMesh(
                new RenderStack.Geometry.Shapes.Triangle(0.8f / 0.57735027f),
                NormalStyle.PolygonNormals
                );

            hsv  = materialManager["HSVColorFill"];
            hsv2 = materialManager["HSVColorFill2"];

            disc     = new Model("disc", discMesh, hsv, 0.0f, 0.0f, 0.0f);
            triangle = new Model("triangle", triangleMesh, hsv2, 0.0f, 0.0f, 0.0f);

            group.Add(disc);
            group.Add(triangle);

            //this.framebufferManager = framebufferManager;
            this.materialManager = materialManager;
            this.renderer        = renderer;

            this.ninePatch = new NinePatch(Style.NinePatchStyle);

            FillBasePixels = new Vector2(aSize, aSize);
        }
Esempio n. 3
0
        public override void initialise()
        {
            sampleTexture = Mdx.graphics.newTexture(Mdx.files.@internal("mini2Dx.png"));
            sampleRegion  = Mdx.graphics.newTextureRegion(sampleTexture);
            sampleRegion2 = Mdx.graphics.newTextureRegion(sampleTexture).split(16, 17)[1][1];
            sampleRegion2.flip(false, true);
            sampleSprite         = Mdx.graphics.newSprite(sampleTexture);
            sampleNinePatch      = Mdx.graphics.newNinePatch(Mdx.graphics.newTexture(Mdx.files.@internal("ninepatch.png")), 6, 6, 6, 6);
            sampleAtlas          = Mdx.graphics.newTextureAtlas(Mdx.files.@internal("packfile.atlas"));
            sampleAtlasRegion    = sampleAtlas.findRegion("tileGreen", 47);
            sampleTilingDrawable = Mdx.graphics.newTilingDrawable(Mdx.graphics.newTextureRegion(Mdx.graphics.newTexture(Mdx.files.@internal("background.png"))));
            Mdx.graphicsContext.setColor(Mdx.graphics.newColor(1f, 1f, 1f, 1f));
            Mdx.graphicsContext.setBackgroundColor(new MonoGameColor(Color.Blue));
            sampleSprite.setOriginCenter();
            music = Mdx.audio.newMusic(Mdx.files.@internal("music.ogg"));
            sound = Mdx.audio.newSound(Mdx.files.@internal("sound.wav"));

            Mdx.audio.addMusicCompletionListener(new AudioCompletionListener());
            Mdx.audio.addSoundCompletionListener(new AudioCompletionListener());

            Mdx.input.newXboxGamePad((GamePad)Mdx.input.getGamePads().get(0)).addListener(new UATInputProcessor(this));

            sampleShader = Mdx.graphics.newShader("grayscaleShader");
            Mdx.graphicsContext.setFont(Mdx.fonts.newBitmapFont(Mdx.files.@internal("arial24.fnt")));
            Mdx.graphicsContext.getFont().setColor(Mdx.graphics.newColor(255, 255, 255, 255));
            sampleFontCache = Mdx.graphicsContext.getFont().newCache();
            sampleFontCache.setColor(Mdx.graphics.newColor(255, 255, 255, 255));
            sampleFontCache.addText("Hello!\nBonjour!\nCiao!\nGuten tag!\nNamaste!", 400, 165, 100, Align.LEFT, true);
            sampleFontCache.addText("Hello!\nBonjour!\nCiao!\nGuten tag!\nNamaste!", 500, 165, 100, Align.CENTER, true);
            sampleFontCache.addText("Hello!\nBonjour!\nCiao!\nGuten tag!\nNamaste!", 600, 165, 100, Align.RIGHT, true);
            sampleMap = new TiledMap(Mdx.files.@internal("orthogonal_no_cache.tmx"));
            Mdx.input.setInputProcessor(new UATInputProcessor(this));
        }
Esempio n. 4
0
        public ToolTip(GeeUIMain theGeeUI, View parentView, View linkedTo, string text)
            : base(theGeeUI, parentView)
        {
            this.Patch = GeeUIMain.NinePatchPanelUnselected;

            ToolTipText.Value = text;
            TextView          = new TextView(theGeeUI, this, text, Vector2.Zero);
            this.ChildrenLayouts.Add(new ExpandToFitLayout());
            this.ChildrenLayouts.Add(new VerticalViewLayout(0, false));

            this.realParent = linkedTo;

            if (this.realParent != null)
            {
                this.Add(new NotifyBinding(this.CheckActive, this.realParent.Active, this.realParent.Attached));
            }

            this.Add(new NotifyBinding(this.CheckActive, this.Active));

            this.AnchorPoint.Value = new Vector2(0f, 1f);
            this.Position.Value    = InputManager.GetMousePosV();

            this.Add(new NotifyBinding(CheckActive, this.Active, realParent.Active));
            this.AnimateIn();
        }
Esempio n. 5
0
        public Slider(
            Renderer renderer,
            string label,
            Floats parameter,
            int element,
            float min,
            float max,
            float displayMin,
            float displayMax
            )
        {
            this.renderer  = renderer;
            this.parameter = parameter;
            this.element   = element;
            Name           = label;

            Style      = Style.Foreground;
            textBuffer = new TextBuffer(Style.Font);
            ninePatch  = new NinePatch(Style.NinePatchStyle);

            Min        = min;
            Max        = max;
            DisplayMin = displayMin;
            DisplayMax = displayMax;

            CurrentValue = parameter[element];
            Label        = label;
        }
Esempio n. 6
0
        protected override void CreateChildren()
        {
            base.CreateChildren();

            Bg = Chrome.Get(Chrome.Type.TAG);
            Add(Bg);
        }
Esempio n. 7
0
 public PanelView(GeeUIMain GeeUI, View rootView, Vector2 position)
     : base(GeeUI, rootView)
 {
     SelectedNinepatch   = GeeUIMain.NinePatchPanelSelected;
     UnselectedNinepatch = GeeUIMain.NinePatchPanelUnselected;
     Position.Value      = position;
 }
Esempio n. 8
0
        public override void LoadContent(JContent contentManager)
        {
            font = contentManager.Load <SpriteFont>("MediumFont");

            np       = new NinePatch(contentManager.Load <Sprite>("TestNP"), new Rectangle(5, 5, 6, 6));
            buttonNP = new NinePatch(contentManager.Load <Sprite>("ButtonNP"), new Rectangle(10, 10, 12, 12));
        }
Esempio n. 9
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            Mdx.graphicsContext = new MonoGameGraphics(GraphicsDevice);
            Mdx.graphics        = new MonoGameGraphicsUtils(GraphicsDevice);
            Mdx.audio           = new MonoGameAudio();

            sampleTexture = Mdx.graphics.newTexture(Mdx.files.@internal("mini2Dx.png"));
            sampleRegion  = Mdx.graphics.newTextureRegion(sampleTexture);
            sampleRegion2 = Mdx.graphics.newTextureRegion(sampleTexture).split(16, 17)[1][1];
            sampleRegion2.flip(false, true);
            sampleSprite         = Mdx.graphics.newSprite(sampleTexture);
            sampleNinePatch      = Mdx.graphics.newNinePatch(Mdx.graphics.newTexture(Mdx.files.@internal("ninepatch.png")), 6, 6, 6, 6);
            sampleAtlas          = Mdx.graphics.newTextureAtlas(Mdx.files.@internal("pack.atlas"));
            sampleAtlasRegion    = sampleAtlas.findRegion("tileGreen", 47);
            sampleTilingDrawable = new MonoGameTilingDrawable(Mdx.graphics.newTexture(Mdx.files.@internal("background.png")));
            Mdx.graphicsContext.setColor(new MonoGameColor(255, 255, 255, 255));
            Mdx.graphicsContext.setBackgroundColor(new MonoGameColor(Color.Blue));
            sampleSprite.setOriginCenter();
            music = Mdx.audio.newMusic(Mdx.files.@internal("music.ogg"));
            sound = Mdx.audio.newSound(Mdx.files.@internal("sound.wav"));

            Mdx.audio.addMusicCompletionListener(new AudioCompletionListener());
            Mdx.audio.addSoundCompletionListener(new AudioCompletionListener());

            Mdx.input.newXbox360GamePad((GamePad)Mdx.input.getGamePads().get(0)).addListener(new UATInputProcessor(this));
        }
Esempio n. 10
0
 public WindowView(GeeUIMain GeeUI, View rootView, Vector2 position)
     : base(GeeUI, rootView)
 {
     Position.Value    = position;
     NinePatchNormal   = GeeUIMain.NinePatchWindowUnselected;
     NinePatchSelected = GeeUIMain.NinePatchWindowSelected;
 }
Esempio n. 11
0
        protected override void OnPaint(System.Drawing.Graphics g)
        {
            var strSize    = g.MeasureString(this.Text, this.Font);
            var contentBox = new RectangleF(0, 0, this.Size.Width, this.Size.Height);

            var patch =
                this.pressed ? backgroundPressed9P
                : this.over ? backgroundOver9P
                : backgroundNormal9P;

            if (patch != null)
            {
                patch          = anim != null && anim.IsRunning() ? anim.GetCurrentFrame() : patch;
                lastDrawnPatch = patch;
                contentBox     = patch.GetContentBox(this.Size);
                patch.Paint(g, this.Size);
            }
            else
            {
                drawDefaultButton(g);
            }

            g.SetClip(contentBox, System.Drawing.Drawing2D.CombineMode.Intersect);
            g.DrawString(this.Text, this.Font, new SolidBrush(this.ForeColor), contentBox.Width / 2 - strSize.Width / 2 + contentBox.Left, contentBox.Height / 2 - strSize.Height / 2 + contentBox.Top);
        }
Esempio n. 12
0
        public void GetNinePatches_WithExternalPatchesCoveringVector_ShouldDivide()
        {
            // arrange
            RectangleF[] ar;
            var          left   = 32;
            var          right  = 32;
            var          top    = 6;
            var          bottom = 6;
            var          size   = new Vector2(64, 12);

            var expected = new[]
            {
                new RectangleF(0, 0, 32, 6),
                new RectangleF(32, 0, 0, 6),
                new RectangleF(32, 0, 32, 6),

                new RectangleF(0, 6, 32, 0),
                new RectangleF(32, 6, 0, 0),
                new RectangleF(32, 6, 32, 0),

                new RectangleF(0, 6, 32, 6),
                new RectangleF(32, 6, 0, 6),
                new RectangleF(32, 6, 32, 6),
            };

            // act
            ar = NinePatch.GetNinePatches(size, left, right, top, bottom);

            // assert
            for (var i = 0; i < ar.Length; i++)
            {
                Assert.That(ar[i], Is.EqualTo(expected[i]));
            }
        }
Esempio n. 13
0
        public void GetNinePatches_ShouldDivideSpaceWithPatchesSizes()
        {
            // arrange
            RectangleF[] ar;
            var          left   = 12;
            var          right  = 12;
            var          top    = 12;
            var          bottom = 12;
            var          size   = new Vector2(600, 120);

            var expected = new[]
            {
                new RectangleF(0, 0, 12, 12),
                new RectangleF(12, 0, 576, 12),
                new RectangleF(588, 0, 12, 12),

                new RectangleF(0, 12, 12, 96),
                new RectangleF(12, 12, 576, 96),
                new RectangleF(588, 12, 12, 96),

                new RectangleF(0, 108, 12, 12),
                new RectangleF(12, 108, 576, 12),
                new RectangleF(588, 108, 12, 12),
            };

            // act
            ar = NinePatch.GetNinePatches(size, left, right, top, bottom);

            // assert
            for (var i = 0; i < ar.Length; i++)
            {
                Assert.That(ar[i], Is.EqualTo(expected[i]));
            }
        }
Esempio n. 14
0
        public override void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch)
        {
            NinePatch patch = Selected ? SelectedNinepatch : UnselectedNinepatch;

            patch.Draw(spriteBatch, AbsolutePosition, Width, Height, 0f, EffectiveOpacity);
            base.Draw(spriteBatch);
        }
Esempio n. 15
0
        public Palette(
            Brushes.BrushManager brushManager,
            MaterialManager materialManager,
            IRenderer renderer
            )
        {
            this.brushManager    = brushManager;
            this.materialManager = materialManager;
            this.renderer        = renderer;

            this.ninePatch = new NinePatch(Style.NinePatchStyle);

            material = materialManager["Palette"];

            brushes = brushManager.Lists["platonic"];
            foreach (Brush brush in brushes)
            {
                brushModelGroup.Add(brush.Model);
            }

            rects = new Rectangle[brushes.Count];
            for (int i = 0; i < brushes.Count; ++i)
            {
                rects[i] = new Rectangle();
            }

            FillBasePixels = new Vector2(brushSize, brushes.Count * brushSize);
        }
Esempio n. 16
0
        public Window(int width, int height, NinePatch chrome)
        {
            Blocker             = new TouchArea(0, 0, PixelScene.uiCamera.CameraWidth, PixelScene.uiCamera.CameraHeight);
            Blocker.ClickAction = BlockerClickAction;
            Blocker.Camera      = PixelScene.uiCamera;
            Add(Blocker);

            Chrome = chrome;

            Width  = width;
            Height = height;

            chrome.X = -chrome.MarginLeft();
            chrome.Y = -chrome.MarginTop();
            chrome.Size(width - chrome.X + chrome.MarginRight(), height - chrome.Y + chrome.MarginBottom());
            Add(chrome);

            Camera   = new Camera(0, 0, (int)chrome.Width, (int)chrome.Height, PixelScene.defaultZoom);
            Camera.X = (int)(Game.Width - Camera.CameraWidth * Camera.Zoom) / 2;
            Camera.Y = (int)(Game.Height - Camera.CameraHeight * Camera.Zoom) / 2;
            Camera.Scroll.Set(chrome.X, chrome.Y);
            Camera.Add(Camera);

            Keys.Event.Add(this);
        }
Esempio n. 17
0
        public NinePatchTest()
        {
            var ninePatch = new NinePatch("gfx/ninepatch", 4, 4, 7, 5);

            ninePatch.X = 10;
            ninePatch.Y = 10;
            Add(ninePatch);
        }
Esempio n. 18
0
        public void LoadFromTextureTest()
        {
            NinePatch target  = new NinePatch(); // TODO: Initialize to an appropriate value
            Texture2D texture = null;            // TODO: Initialize to an appropriate value

            target.LoadFromTexture(texture);
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }
Esempio n. 19
0
        public void topHeightTest()
        {
            NinePatch target = new NinePatch(); // TODO: Initialize to an appropriate value
            int       actual;

            actual = target.topHeight;
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Esempio n. 20
0
        public void BitmapFromDecodeRes_ShouldContainNinePatchChunk(int resId, string name)
        {
            Bitmap bm = BitmapFactory.DecodeResource(Application.Context.Resources, resId);

            byte[] chunk = bm.GetNinePatchChunk();
            Assert.IsTrue(NinePatch.IsNinePatchChunk(chunk),
                          $"Bitmap decoded from resource `{name}` did not contain a valid NinePatch chunk.");
        }
Esempio n. 21
0
        public HUD(float height, Skin skin) : base(height, skin)
        {
            var assets = G.Assets;

            _font           = assets.GetAsset <TileFont>("core:ui.font2");
            _inventoryPatch = assets.GetAsset <NinePatch>("core:ui.inventory");
            _crosshair      = assets.GetAsset <Image>("core:ui.crosshair");
        }
Esempio n. 22
0
 public ButtonView(GeeUIMain GeeUI, View rootview, View contentView, Vector2 position)
     : base(GeeUI, rootview)
 {
     NinePatchNormal   = GeeUIMain.NinePatchBtnDefault;
     NinePatchHover    = GeeUIMain.NinePatchBtnHover;
     NinePatchClicked  = GeeUIMain.NinePatchBtnClicked;
     Position.Value    = position;
     ButtonContentview = contentView;
 }
Esempio n. 23
0
        public SubFixPanel(Anchor anchor, float width, float height, bool scrollOverflow = false, int childPadding = DEFAULT_CHILD_PADDING) :
            base(anchor, new Vector2(width, height), new Vector2(width, height), false,
                 scrollOverflow, new Point(15, 20), true)
        {
            ChildPadding = new Vector2(childPadding);
            var testTexture = Storage.Content.Load <Texture2D>("images/Test");

            Texture = new NinePatch(new TextureRegion(testTexture, 0, 8, 24, 24), 3);
        }
Esempio n. 24
0
 public Button(IRenderer renderer, string label, Style style)
 {
     this.Style      = style;
     this.renderer   = renderer;
     this.textBuffer = new TextBuffer(Style.Font);
     this.ninePatch  = new NinePatch(Style.NinePatchStyle);
     Name            = label;
     Label           = label;
 }
Esempio n. 25
0
 public Button(Vector2 Position, string text, SpriteFont font, Action lambdaOnClick = null)
 {
     this.Position = Position;
     base.UIC_Initialize();
     this.lambdaOnClick = lambdaOnClick;
     td          = new TextDrawer(font, text, Position, textColor, TextAlign.Center);
     patchNormal = YogUI.btn_normal;
     patchHover  = YogUI.btn_hover;
     patchClick  = YogUI.btn_hover;
 }
Esempio n. 26
0
        protected override void CreateChildren()
        {
            base.CreateChildren();

            Bg = Chrome.Get(Chrome.Type.BUTTON);
            Add(Bg);

            InternalText = PixelScene.CreateText(9);
            Add(InternalText);
        }
Esempio n. 27
0
        public void BitmapFromDecodeResStream_ShouldContainNinePatchChunk(int resId, string name)
        {
            var value             = new Android.Util.TypedValue();
            InputStreamInvoker si = GetResourceStream(resId, value);
            Bitmap             bm = BitmapFactory.DecodeResourceStream(Application.Context.Resources, value, si, null, null);

            byte[] chunk = bm.GetNinePatchChunk();
            Assert.IsTrue(NinePatch.IsNinePatchChunk(chunk),
                          $"Bitmap decoded from resource stream with id `{name}` did not contain a valid NinePatch chunk.");
        }
Esempio n. 28
0
        public void DrawTest()
        {
            NinePatch   target        = new NinePatch(); // TODO: Initialize to an appropriate value
            SpriteBatch sb            = null;            // TODO: Initialize to an appropriate value
            Vector2     position      = new Vector2();   // TODO: Initialize to an appropriate value
            int         contentWidth  = 0;               // TODO: Initialize to an appropriate value
            int         contentHeight = 0;               // TODO: Initialize to an appropriate value

            target.Draw(sb, position, contentWidth, contentHeight);
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }
Esempio n. 29
0
        public SliderView(GeeUIMain GeeUI, View rootView, Vector2 position, int min, int max)
            : base(GeeUI, rootView)
        {
            SliderRange    = GeeUIMain.NinePatchSliderRange;
            SliderDefault  = GeeUIMain.TextureSliderDefault;
            SliderSelected = GeeUIMain.TextureSliderSelected;

            _min = min;
            _max = max;

            Position.Value = position;
        }
Esempio n. 30
0
        public void getCenterTest()
        {
            NinePatch target        = new NinePatch(); // TODO: Initialize to an appropriate value
            int       contentWidth  = 0;               // TODO: Initialize to an appropriate value
            int       contentHeight = 0;               // TODO: Initialize to an appropriate value
            Vector2   expected      = new Vector2();   // TODO: Initialize to an appropriate value
            Vector2   actual;

            actual = target.getCenter(contentWidth, contentHeight);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Esempio n. 31
0
        protected override void OnPaint(System.Drawing.Graphics g)
        {
            var actualText = this.checked_ ? this.CheckedText : this.Text;
            var strSize = g.MeasureString(actualText, this.Font);
            var contentBox = new RectangleF(0, 0, this.Size.Width, this.Size.Height);

            var patch =
                this.pressed ?
                    this.checked_ ? backgroundCheckedPressed9P : backgroundPressed9P
                : this.over ?
                    this.checked_ ? backgroundCheckedOver9P : backgroundOver9P
                :
                    this.checked_ ? backgroundCheckedNormal9P : backgroundNormal9P;

            if (patch != null)
            {
                patch = anim != null && anim.IsRunning() ? anim.GetCurrentFrame() : patch;
                lastDrawnPatch = patch;
                contentBox = patch.GetContentBox(this.Size);
                patch.Paint(g, this.Size);
            }
            else
                drawDefaultToggleButton(g);

            g.SetClip(contentBox, System.Drawing.Drawing2D.CombineMode.Intersect);
            g.DrawString(actualText, this.Font, new SolidBrush(this.ForeColor), contentBox.Width / 2 - strSize.Width / 2 + contentBox.Left, contentBox.Height / 2 - strSize.Height / 2 + contentBox.Top);
        }
Esempio n. 32
0
    void Awake()
    {
        back = gameObject.FindChildByName ( "back" ).GetComponent<NinePatch> ();

        BoxCollider2D = GetComponent<BoxCollider2D> ();
        if ( BoxCollider2D == null )
            Debug.LogError ( "There is no BoxCollider2D component on Game singleton" );

        combo = ComboList.Instance.GetCombo();

        Create ();

        Game.Instance.RegisterComboPane ( this );
    }