Esempio n. 1
0
        private ImageViewWithFrame AddToSearchResults(
            Texture texture,
            int imageSize,
            float leftRightMargin,
            float topBottomMargin)
        {
            var image = new ImageViewWithFrame();
            image.BigSize = imageSize;
            image.ImageTexture = texture;
            image.FrameTexture = FrameTexture;
            image.LeftMargin = leftRightMargin / 2.0f;
            image.RightMargin = leftRightMargin / 2.0f;
            image.TopMargin = topBottomMargin / 2.0f;
            image.BottomMargin = topBottomMargin / 2.0f;

            image.MeasureSize();

            return image;
        }
Esempio n. 2
0
    private void OnGUI()
    {
        Vector3 p = Camera.main.WorldToScreenPoint(SpawnObject.transform.position);
        Vector3 e = Camera.main.WorldToScreenPoint(SpawnEndObject.transform.position);
        p.y = Screen.height - p.y;
        e.y = Screen.height - e.y;

        if (state == ShowDeckState)
        {
            int fullItemWidth = BigSize + Spacing;

            float scaledBigFrameOffsetX = Scale(14) * BigScale;
            float scaledBigFrameOffsetY = Scale(13) * BigScale;
            float scaledBigFrameWidth = BigSize + (Scale(30) * BigScale);
            float scaledBigFrameHeight = BigSize + (Scale(27) * BigScale);

            float scaledSmallFrameOffsetX = Scale(5) * SmallScale;
            float scaledSmallFrameOffsetY = Scale(5) * SmallScale;
            float scaledSmallFrameWidth = SmallSize + (Scale(10) * SmallScale);
            float scaledSmallFrameHeight = SmallSize + (Scale(9) * SmallScale);

            float width = (fullItemWidth * size) + p.x + (Screen.width - e.x - Spacing);
            scrollViewVector = GUI.BeginScrollView(new Rect(0, p.y - 20, Screen.width, scaledBigFrameHeight + Scale(25)), scrollViewVector, new Rect(0, 0, width, scaledBigFrameHeight));

            p.y = 10;

            float firstImageOffsetY = p.y + (Scale(7) * BigScale);
            float secondImageOffsetY = p.y + SmallSize + (Scale(13 + 7) * BigScale);

            p.x -= scaledBigFrameOffsetX - scaledSmallFrameOffsetX;

            int imageIndex = 0;
            for (int i = 0; i < size; ++i)
            {
                ScaleMode scaleMode = ScaleMode.ScaleAndCrop;

                Rect imageRect = CalculatePosition(p, p.y, scaledBigFrameWidth + 200);

                GUI.BeginGroup(imageRect);

                GUI.DrawTexture(new Rect(scaledBigFrameOffsetX, scaledBigFrameOffsetY, BigSize, BigSize), textures[imageIndex], scaleMode);
                GUI.DrawTexture(new Rect(0, 0, scaledBigFrameWidth, scaledBigFrameHeight), FrameObject, ScaleMode.StretchToFill);

                ++imageIndex;
                float x = scaledBigFrameOffsetX - Scale(9);
                GUI.DrawTexture(new Rect(x, firstImageOffsetY, SmallSize, SmallSize), textures[imageIndex], scaleMode);
                GUI.DrawTexture(new Rect(x - scaledSmallFrameOffsetX, firstImageOffsetY - scaledSmallFrameOffsetY, scaledSmallFrameWidth, scaledSmallFrameHeight), FrameObject, ScaleMode.StretchToFill);

                ++imageIndex;
                GUI.DrawTexture(new Rect(x, secondImageOffsetY, SmallSize, SmallSize), textures[imageIndex], scaleMode);
                GUI.DrawTexture(new Rect(x - scaledSmallFrameOffsetX, secondImageOffsetY - scaledSmallFrameOffsetY, scaledSmallFrameWidth, scaledSmallFrameHeight), FrameObject, ScaleMode.StretchToFill);
                ++imageIndex;

                GroupControl groupControl = new GroupControl();
                ImageViewWithFrame frame = new ImageViewWithFrame();
                frame.BigSize = BigSize;
                frame.FrameTexture = FrameObject;
                frame.ImageTexture = textures[imageIndex];
                frame.RightMargin = 30;

                frame.MeasureSize();
                //frame.Render();
                groupControl.Items.Add(frame);

                frame = new ImageViewWithFrame();
                frame.BigSize = SmallSize;
                frame.FrameTexture = FrameObject;
                frame.ImageTexture = textures[imageIndex];
                frame.LeftMargin = x - scaledSmallFrameOffsetX;
                frame.TopMargin = firstImageOffsetY - scaledSmallFrameOffsetY;

                frame.MeasureSize();
                //frame.Render();
                groupControl.Items.Add(frame);

                frame = new ImageViewWithFrame();
                frame.BigSize = SmallSize;
                frame.FrameTexture = FrameObject;
                frame.ImageTexture = textures[imageIndex];
                frame.LeftMargin = x - scaledSmallFrameOffsetX;
                frame.TopMargin = secondImageOffsetY - scaledSmallFrameOffsetY;

                frame.MeasureSize();
                //frame.Render();
                groupControl.Items.Add(frame);

                groupControl.Render();

                GUI.EndGroup();

                p.x += fullItemWidth;
            }

            GUI.EndScrollView(true);
        }

        if (Input.GetMouseButtonDown(0) && !isMousePressed && mouseTimeout <= 0)
        {
            mouseTimeout = 30;

            isMousePressed = true;

            MouseDown();
        }
        else
        {
            isMousePressed = false;

            if (mouseTimeout > 0)
            {
                --mouseTimeout;
            }
        }
    }
Esempio n. 3
0
        private void AddToSet(ImageViewWithFrame imageView)
        {
            Vector3 p = new Vector3(Scale(10), Scale(10));

            var startPosition = Camera.main.WorldToScreenPoint(SpawnMyDeckStartLocation.transform.position);
            startPosition.y = Screen.height - startPosition.y;

            var endPosition = Camera.main.WorldToScreenPoint(SpawnMyDeckEndLocation.transform.position);
            endPosition.y = Screen.height - endPosition.y;

            float controlWidth = endPosition.x - startPosition.x;
            float fullSize = controlWidth / 3.6f;

            GroupControl item = new GroupControl();

            var framedImage = new ImageViewWithFrame();
            framedImage.BigSize = (int)(fullSize * 0.9f);
            framedImage.ImageTexture = imageView.ImageTexture;
            framedImage.FrameTexture = imageView.FrameTexture;
            framedImage.LeftMargin = 0;
            framedImage.RightMargin = (int)(fullSize * 0.05f);
            framedImage.TopMargin = 0;
            framedImage.MeasureSize();

            item.Items.Add(framedImage);

            Rect rect = new Rect();
            rect.x = (int)(p.x + (int)(fullSize * 0.05f) + (fullSize * (x % breakIn)));
            rect.y = (int)(p.y + (((p.y * 2) + framedImage.BigSize) * (int)(x / breakIn)));
            rect.width = framedImage.Rect.width;
            rect.height = framedImage.Rect.height;
            item.Rect = rect;

            var cancelImage = new ImageView();
            cancelImage.Width = cancelImage.Height = (int)(fullSize * 0.22);
            cancelImage.ImageScaleMode = ScaleMode.ScaleToFit;
            cancelImage.Offset.x = (int)(fullSize * 0.74);
            cancelImage.Offset.y = (int)(fullSize * 0.11);
            cancelImage.ImageTexture = MiniCancelTexture;
            cancelImage.MeasureSize();

            // Revert auto scalling stuff in measure size.
            rect = cancelImage.ImageRect;
            rect.x = cancelImage.Offset.x;
            rect.y = cancelImage.Offset.y;
            rect.width = rect.height = cancelImage.Width;
            cancelImage.ImageRect = rect;

            item.Tag = imageView.Tag;
            item.Items.Add(cancelImage);
            selectedCardsImages.Add(item);

            item.MeasureSize();

            selectedCardsScrollContentHeight = item.Rect.y + item.Rect.height;
            ++x;
        }
Esempio n. 4
0
        private void AddToSet2(ImageViewWithFrame imageView)
        {
            Vector3 p = new Vector3(Scale(10), Scale(10));

            var startPosition = Camera.main.WorldToScreenPoint(SpawnMyDeckStartLocation.transform.position);
            startPosition.y = Screen.height - startPosition.y;

            var endPosition = Camera.main.WorldToScreenPoint(SpawnMyDeckEndLocation.transform.position);
            endPosition.y = Screen.height - endPosition.y;

            float controlWidth = endPosition.x - startPosition.x;
            float fullSize = controlWidth / 3.6f;

            var framedImage = new ImageViewWithFrame();
            framedImage.BigSize = (int)(fullSize * 0.9f);
            framedImage.ImageTexture = imageView.ImageTexture;
            framedImage.FrameTexture = imageView.FrameTexture;
            framedImage.LeftMargin = p.x + (int)(fullSize * 0.05f) + (fullSize * (x % breakIn));
            framedImage.RightMargin = (int)(fullSize * 0.05f);
            framedImage.TopMargin = p.y + (((p.y * 2) + framedImage.BigSize) * (int)(x / breakIn));
            framedImage.MeasureSize();

            var cancelImage = new ImageView();
            cancelImage.Width = cancelImage.Height = (int)(framedImage.BigSize * 0.12);
            cancelImage.ImageScaleMode = ScaleMode.ScaleToFit;
            cancelImage.LeftMargin = (int)framedImage.LeftMargin + (int)(framedImage.BigSize * 0.85);
            cancelImage.TopMargin = (int)framedImage.TopMargin + Scale(5);
            cancelImage.ImageTexture = MiniCancelTexture;
            cancelImage.MeasureSize();

            selectedCardsImages.Add(framedImage);

            selectedCardsScrollContentHeight = framedImage.TopMargin + framedImage.Rect.height;
            ++x;
        }
Esempio n. 5
0
    private IEnumerator ImageViewWithFrame(
        CardData card,
        ImageViewWithFrame frame,
        int imageSize,
        string resourcePath,
        float leftMargin = 0,
        float topMargin = 0,
        float rightMargin = 0,
        float bottomMargin = 0)
    {
        Texture texture;

        if (!string.IsNullOrEmpty(resourcePath))
        {
            texture = Resources.Load<Texture>(resourcePath);
        }
        else
        {
            string path = WebCache.GetCachedPath(card);
            WWW www = new WWW(path);
            yield return www;

            texture = www.texture;
        }

        frame.BigSize = imageSize;
        frame.FrameTexture = FrameObject;
        frame.ImageTexture = texture;
        frame.LeftMargin = leftMargin;
        frame.TopMargin = topMargin;
        frame.RightMargin = rightMargin;
        frame.BottomMargin = bottomMargin;

        frame.MeasureSize();
    }