示例#1
0
    public void CreateBaseUI()
    {
        GameObject b = mUI.CreateElement(mUI.Canvas, "uiBase");

        b.transform.SetAsFirstSibling();
        mUI.SetRectFillParent(b);
        mUI.AddImage(b, mUI.PrimaryBackground);

        GameObject vl = mUI.CreateElement(b, "vertLayout");

        mUI.SetRectFillParent(vl);
        mUI.AddVerticalLayout(vl);

        GameObject sp1 = mUI.CreateElement(vl, "spacer");

        mUI.AddLayout(sp1, -1, 10, 1.0f, -1);

        mGlobalTabs = mUI.CreateTabView(vl);

        mPrimaryContent = mUI.CreateElement(vl, "primaryWindow");
        mUI.AddLayout(mPrimaryContent, -1, -1, 1.0f, 1.0f);
        mUI.AddImage(mPrimaryContent, mUI.WindowBackground);
        mUI.AddVerticalLayout(mPrimaryContent);
        mPrimaryContent.GetComponent <VerticalLayoutGroup>().padding = new RectOffset(4, 4, 4, 4);
        mPrimaryContent.GetComponent <VerticalLayoutGroup>().spacing = 4;
    }
示例#2
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);
    }
示例#3
0
    public CContextMenu(CToolkitUI Toolkit, CGameUIStyle Style, GameObject Root)
    {
        _ui    = Toolkit;
        _style = Style;

        _root = _ui.CreateElement(Root, "contextMenuRoot");
        _ui.AddImage(_root, new Color(0, 0, 0, 0.0f));
        _ui.SetRectFillParent(_root);
        _root.AddComponent <CUIContextMenuOverlay>();

        _contextMenu = _ui.CreateElement(_root, "contextMenu");
        _ui.AddImage(_contextMenu, _style.TooltipBackground);
        _ui.SetTransform(_contextMenu, 0, 0, 128, 256);
        _ui.AddVerticalLayout(_contextMenu, new RectOffset(3, 3, 3, 3), 3);
        _contextMenu.GetComponent <RectTransform>().anchorMax = new Vector2(0, 0);
        _contextMenu.GetComponent <RectTransform>().anchorMin = new Vector2(0, 0);

        ContentSizeFitter fitter = _contextMenu.AddComponent <ContentSizeFitter>();

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

        Hide();
    }
示例#4
0
    public void ShowErrorMessage(string Message, string Title)
    {
        if (mErrorMessageBox != null)
        {
            GameObject.Destroy(mErrorMessageBox);
        }

        mErrorMessageBox = _ui.CreateElement(mMenuLayer, "ErrorMessage");
        //errorMsg.SetActive(false);
        _ui.AddImage(mErrorMessageBox, _style.TooltipBackground);
        _ui.SetAnchors(mErrorMessageBox, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f));
        _ui.SetTransform(mErrorMessageBox, 0, 0, 600, 256);
        _ui.AddVerticalLayout(mErrorMessageBox).childForceExpandWidth   = true;
        mErrorMessageBox.AddComponent <ContentSizeFitter>().verticalFit = ContentSizeFitter.FitMode.PreferredSize;

        GameObject titleBar = _ui.CreateElement(mErrorMessageBox, "TitleBar");

        _ui.AddImage(titleBar, _style.ThemeColorC);
        _ui.SetAnchors(titleBar, new Vector2(0.0f, 1.0f), new Vector2(1.0f, 1.0f), new Vector2(0.0f, 1.0f));
        _ui.AddLayout(titleBar, -1, 30, -1, -1);
        //_ui.SetTransform(optsTitle, 0, 0, 0, 26);

        GameObject titleText = _ui.CreateElement(titleBar);

        _ui.SetAnchors(titleText, new Vector2(0.0f, 0.0f), new Vector2(1.0f, 1.0f), new Vector2(0.0f, 1.0f));
        _ui.SetTransform(titleText, 5, 0, -10, 0);
        Text optsTitleTextComp = titleText.AddComponent <Text>();

        optsTitleTextComp.text      = Title;
        optsTitleTextComp.font      = _style.FontA;
        optsTitleTextComp.alignment = TextAnchor.MiddleLeft;


        GameObject messageBody = _ui.CreateElement(mErrorMessageBox, "MsgBorder");

        _ui.AddVerticalLayout(messageBody, new RectOffset(10, 10, 10, 10));

        GameObject message = _ui.CreateElement(messageBody);
        //_ui.SetAnchors(optsTitleText, new Vector2(0.0f, 0.0f), new Vector2(1.0f, 1.0f), new Vector2(0.0f, 1.0f));
        //_ui.SetTransform(optsTitleText, 5, 0, -10, 0);
        Text messageTextComp = message.AddComponent <Text>();

        messageTextComp.text = Message;
        messageTextComp.font = _style.FontA;
        //messageTextComp.alignment = TextAnchor.MiddleLeft;

        // TODO: This message should be removed when session terminated with other game related UI.

        /*
         * GameObject button = _ui.CreateMenuButton(errorMsg, "Exit", () => {
         *      GameObject.Destroy(errorMsg);
         *      CGame.UIManager.PlaySound(CGame.PrimaryResources.AudioClips[15]);
         *      CGame.Game.TerminateGameSession();
         *      CGame.UIManager.AddInterface(new CMainMenuUI());
         * });
         * _ui.SetTransform(button, 50, -100, 256, 50);
         */

        GameObject button = _ui.CreateButton(mErrorMessageBox, "Close", () => {
            GameObject.Destroy(mErrorMessageBox);
            mErrorMessageBox = null;
            CGame.UIManager.PlaySound(CGame.PrimaryResources.AudioClips[15]);
        });

        _ui.AddLayout(button, -1, 20, 1.0f, -1);
    }