Ejemplo n.º 1
0
        private MyGuiControlTable.Cell CreateTerminalCell(CubeGridInfo gridInfo, bool isActive)
        {
            MyGuiControlTable.Cell cell = new MyGuiControlTable.Cell();

            Vector2 size = new Vector2(0.1f, m_shipsData.RowHeight * 0.9f);

            MyStringId     tooltip = MySpaceTexts.BroadcastScreen_TerminalButton_ToolTip;
            MyRefuseReason reason  = CanTakeTerminal(gridInfo);

            switch (reason)
            {
            case MyRefuseReason.NoStableConnection:
            case MyRefuseReason.PlayerBroadcastOff:
            case MyRefuseReason.NoOwner:
                isActive = false;
                break;
            }

            cell.Control = new MyGuiControlButton(text: MyTexts.Get(MySpaceTexts.Terminal),
                                                  visualStyle: VRage.Game.MyGuiControlButtonStyleEnum.Rectangular,
                                                  size: size,
                                                  textScale: 0.9f,
                                                  onButtonClick: OnButtonClicked_OpenTerminal
                                                  );
            cell.Control.SetToolTip(tooltip);
            cell.Control.Enabled = isActive;
            m_shipsData.Controls.Add(cell.Control);
            return(cell);
        }
Ejemplo n.º 2
0
        private MyGuiControlTable.Cell CreateStatusIcons(CubeGridInfo gridInfo, bool isActive)
        {
            MyGuiControlTable.Cell cell = new MyGuiControlTable.Cell();
            float iconSize = m_shipsData.RowHeight * 0.7f;

            bool antIsActive, keyIsActive, remIsActive;

            antIsActive = keyIsActive = remIsActive = isActive;
            MyStringId antTooltip, remTooltip;

            antTooltip = remTooltip = MyStringId.NullOrEmpty;
            StringBuilder keyTooltip = new StringBuilder();

            MyGuiControlParent gr = new MyGuiControlParent();

            MyRefuseReason reasonT  = CanTakeTerminal(gridInfo);
            MyRefuseReason reasonRC = CanTakeRemoteControl(gridInfo);

            //Antenna icon
            switch (reasonT)
            {
            case MyRefuseReason.PlayerBroadcastOff:
                antIsActive = false;
                antTooltip  = MySpaceTexts.BroadcastScreen_TerminalButton_PlayerBroadcastOffToolTip;
                break;

            case MyRefuseReason.NoStableConnection:
                antIsActive = false;
                antTooltip  = MySpaceTexts.BroadcastScreen_TerminalButton_NoStableConnectionToolTip;
                break;

            case MyRefuseReason.NoOwner:
            case MyRefuseReason.NoProblem:
                antTooltip = MySpaceTexts.BroadcastScreen_TerminalButton_StableConnectionToolTip;
                break;
            }
            MyGuiControlImage antenna = new MyGuiControlImage(
                position: new Vector2(-2 * iconSize, 0),
                size: new Vector2(iconSize, iconSize),
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                backgroundTexture: (antIsActive ? MyGuiConstants.BS_ANTENNA_ON : MyGuiConstants.BS_ANTENNA_OFF)
                );

            antenna.SetToolTip(antTooltip);
            gr.Controls.Add(antenna);

            //Remote Control icon
            switch (reasonRC)
            {
            case MyRefuseReason.NoRemoteControl:
                remTooltip  = MySpaceTexts.BroadcastScreen_TakeControlButton_NoRemoteToolTip;
                remIsActive = false;
                break;

            case MyRefuseReason.NoMainRemoteControl:
                remTooltip  = MySpaceTexts.BroadcastScreen_TakeControlButton_NoMainRemoteControl;
                remIsActive = false;
                break;

            case MyRefuseReason.NoOwner:
            case MyRefuseReason.NoProblem:
                remTooltip = MySpaceTexts.BroadcastScreen_TakeControlButton_RemoteToolTip;
                break;
            }
            MyGuiControlImage remote = new MyGuiControlImage(
                position: new Vector2(-1 * iconSize, 0),
                size: new Vector2(iconSize, iconSize),
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                backgroundTexture: (remIsActive ? MyGuiConstants.BS_REMOTE_ON : MyGuiConstants.BS_REMOTE_OFF)
                );

            remote.SetToolTip(remTooltip);
            gr.Controls.Add(remote);

            //Key icon
            if ((reasonT == MyRefuseReason.NoStableConnection || reasonT == MyRefuseReason.PlayerBroadcastOff) && reasonRC == MyRefuseReason.NoRemoteControl)
            {
                keyTooltip.Append(MyTexts.Get(MySpaceTexts.BroadcastScreen_UnavailableControlButton));
                keyIsActive = false;
            }
            if (keyIsActive && (reasonT == MyRefuseReason.NoOwner || reasonRC == MyRefuseReason.NoOwner || reasonT == MyRefuseReason.NoStableConnection || reasonT == MyRefuseReason.PlayerBroadcastOff))
            {
                keyIsActive = false;
                keyTooltip.Append(MyTexts.Get(MySpaceTexts.BroadcastScreen_NoOwnership));
            }
            if (reasonT == MyRefuseReason.NoOwner)
            {
                keyTooltip.AppendLine();
                keyTooltip.Append(MyTexts.Get(MySpaceTexts.DisplayName_Block_Antenna));
            }
            if (reasonRC == MyRefuseReason.NoOwner)
            {
                keyTooltip.AppendLine();
                keyTooltip.Append(MyTexts.Get(MySpaceTexts.DisplayName_Block_RemoteControl));
            }
            if (keyIsActive)
            {
                keyTooltip.Append(MyTexts.Get(MySpaceTexts.BroadcastScreen_Ownership));
            }
            MyGuiControlImage key = new MyGuiControlImage(
                size: new Vector2(iconSize, iconSize),
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                backgroundTexture: (keyIsActive ? MyGuiConstants.BS_KEY_ON : MyGuiConstants.BS_KEY_OFF)
                );

            key.SetToolTip(keyTooltip.ToString());
            gr.Controls.Add(key);


            cell.Control = gr;
            m_shipsData.Controls.Add(gr);
            return(cell);
        }