Example #1
0
    public CTooltip(CToolkitUI Toolkit, CGameUIStyle Style, GameObject Root)
    {
        _ui    = Toolkit;
        _style = Style;

        _tooltipOverGame = false;
        _tooltip         = _ui.CreateElement(Root, "tooltip");
        _ui.AddImage(_tooltip, _style.TooltipBackground);
        _ui.SetTransform(_tooltip, 0, 0, 256, 256);
        _ui.AddVerticalLayout(_tooltip, new RectOffset(3, 3, 3, 3), 3);
        _tooltip.GetComponent <RectTransform>().anchorMax = new Vector2(0, 0);
        _tooltip.GetComponent <RectTransform>().anchorMin = new Vector2(0, 0);
        ContentSizeFitter fitter = _tooltip.AddComponent <ContentSizeFitter>();

        fitter.horizontalFit = ContentSizeFitter.FitMode.PreferredSize;
        fitter.verticalFit   = ContentSizeFitter.FitMode.PreferredSize;

        float width = 150.0f;

        GameObject title = _ui.CreateTextElement(_tooltip, "Title", "title", CToolkitUI.ETextStyle.TS_HEADING);

        _ui.AddLayout(title, width, -1, -1, -1);

        GameObject details = _ui.CreateTextElement(_tooltip, "Sub-title", "subtitle", CToolkitUI.ETextStyle.TS_DEFAULT);

        _ui.AddLayout(details, width, -1, -1, -1);

        GameObject desc = _ui.CreateTextElement(_tooltip, "Description text that can be longer.", "description", CToolkitUI.ETextStyle.TS_HEADING);

        _ui.AddLayout(desc, width, -1, -1, -1);

        Hide(false);
    }
Example #2
0
    /// <summary>
    /// Add an item to the context menu.
    /// </summary>
    public void AddItem(string Text, Action OnClicked = null)
    {
        GameObject item = _ui.CreateElement(_contextMenu, "item");

        _ui.AddLayout(item, 128.0f, 20.0f, -1, -1);
        _ui.AddImage(item, Color.white);
        _ui.AddHorizontalLayout(item);
        item.GetComponent <HorizontalLayoutGroup>().childAlignment = TextAnchor.MiddleCenter;

        GameObject title = _ui.CreateTextElement(item, Text, "item", CToolkitUI.ETextStyle.TS_HEADING);
        //_ui.AddLayout(title, 128.0f, -1, -1, -1);

        ColorBlock cb = new ColorBlock();

        cb.normalColor      = _style.ThemeColorB;
        cb.highlightedColor = _style.ThemeColorA;
        cb.colorMultiplier  = 1.0f;

        Button     button    = item.AddComponent <Button>();
        Navigation buttonNav = new Navigation();

        buttonNav.mode       = Navigation.Mode.None;
        button.targetGraphic = item.GetComponent <Image>();
        button.navigation    = buttonNav;
        button.colors        = cb;

        if (OnClicked != null)
        {
            button.onClick.AddListener(() =>
            {
                OnClicked();
                Hide();
            });
        }
    }
Example #3
0
    public CUIManager(CToolkitUI Toolkit, CGameUIStyle Style)
    {
        _ui    = Toolkit;
        _style = Style;
        _uiRes = CGame.UIResources;

        mPoseRT = new RenderTexture(512, 512, 24, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear);
        mPoseRT.antiAliasing = 8;

        gameUI = _ui.CreateElement(_ui.Canvas, "gameUI");
        _ui.SetRectFillParent(gameUI);
        gameUI.transform.SetAsFirstSibling();

        underlayLayer = _ui.CreateElement(gameUI, "underlayLayer");
        _ui.SetRectFillParent(underlayLayer);

        CanvasGroup cgroup = underlayLayer.AddComponent <CanvasGroup>();

        cgroup.blocksRaycasts = false;

        primaryLayer             = _ui.CreateElement(gameUI, "primaryLayer");
        mPrimaryLayerGroup       = primaryLayer.AddComponent <CanvasGroup>();
        mPrimaryLayerGroup.alpha = 1.0f;
        _ui.SetRectFillParent(primaryLayer);

        overlayLayer = _ui.CreateElement(gameUI, "overlayLayer");
        _ui.SetRectFillParent(overlayLayer);

        cgroup = overlayLayer.AddComponent <CanvasGroup>();
        cgroup.blocksRaycasts = false;

        cutsceneLayer = _ui.CreateElement(gameUI, "cutsceneLayer");
        _ui.SetRectFillParent(cutsceneLayer);
        GameObject letterBox = _ui.CreateElement(cutsceneLayer);

        _ui.SetAnchors(letterBox, new Vector2(0, 1), new Vector2(1, 1), new Vector2(0, 1));
        _ui.AddImage(letterBox, _style.ThemeColorC);
        _ui.SetTransform(letterBox, 0, 0, 0, 54);

        letterBox = _ui.CreateElement(cutsceneLayer);
        _ui.SetAnchors(letterBox, new Vector2(0, 0), new Vector2(1, 0), new Vector2(0, 0));
        _ui.AddImage(letterBox, _style.ThemeColorC);
        _ui.SetTransform(letterBox, 0, 0, 0, 54);

        mCutsceneLayerGroup                = cutsceneLayer.AddComponent <CanvasGroup>();
        mCutsceneLayerGroup.alpha          = 0.0f;
        mCutsceneLayerGroup.blocksRaycasts = false;

        /*
         * fadeOverLayer = _ui.CreateElement(gameUI, "fadeOverLayer");
         * _ui.SetRectFillParent(fadeOverLayer);
         * _ui.AddImage(fadeOverLayer, Color.black);
         */

        contextMenuLayer = _ui.CreateElement(gameUI, "contextMenuLayer");
        _ui.SetRectFillParent(contextMenuLayer);

        mMenuLayer = _ui.CreateElement(gameUI, "menuLayer");
        _ui.SetRectFillParent(mMenuLayer);

        GameObject productText = _ui.CreateTextElement(overlayLayer, CGame.PRODUCT_NAME + " (" + CGame.VERSION_MAJOR + "." + CGame.VERSION_MINOR + ") " + CGame.VERSION_NAME, "productText", CToolkitUI.ETextStyle.TS_HEADING);

        _ui.SetAnchors(productText, new Vector2(0, 1), new Vector2(1, 1), new Vector2(0, 1));
        _ui.SetTransform(productText, 5, 0, -10, 20);
        productText.GetComponent <Text>().alignment = TextAnchor.MiddleRight;

        mContextMenu = new CContextMenu(Toolkit, Style, contextMenuLayer);
        mTooltip     = new CTooltip(Toolkit, Style, overlayLayer);

        SetupForGameSession();
    }