コード例 #1
0
ファイル: MyButtonPanel.cs プロジェクト: caomw/SpaceEngineers
        void Toolbar_ItemChanged(MyToolbar self, MyToolbar.IndexArgs index)
        {
            Debug.Assert(self == Toolbar);

            var tItem = GetToolbarItem(self.GetItemAtIndex(index.ItemIndex));

            UpdateButtonEmissivity(index.ItemIndex);
            (SyncObject as MySyncButtonPanel).SendToolbarItemChanged(tItem, index.ItemIndex);

            if (m_shouldSetOtherToolbars)
            {
                m_shouldSetOtherToolbars = false;
                if (!(SyncObject as MySyncButtonPanel).IsSyncing)
                {
                    foreach (var toolbar in m_openedToolbars)
                    {
                        if (toolbar != self)
                        {
                            toolbar.SetItemAtIndex(index.ItemIndex, self.GetItemAtIndex(index.ItemIndex));
                        }
                    }
                }
                m_shouldSetOtherToolbars = true;
            }

            var slot = Toolbar.GetItemAtIndex(index.ItemIndex);

            if (slot != null)
            {
                string name = slot.DisplayName.ToString();
                SetButtonName(name, index.ItemIndex);
                (SyncObject as MySyncButtonPanel).SendCustonNameChanged(name, index.ItemIndex);
            }
        }
コード例 #2
0
        void Toolbar_ItemChanged(MyToolbar self, MyToolbar.IndexArgs index)
        {
            if (m_syncing)
            {
                return;
            }
            Debug.Assert(self == Toolbar);

            var tItem = ToolbarItem.FromItem(self.GetItemAtIndex(index.ItemIndex));

            UpdateButtonEmissivity(index.ItemIndex);
            MyMultiplayer.RaiseEvent(this, x => x.SendToolbarItemChanged, tItem, index.ItemIndex);

            if (m_shouldSetOtherToolbars)
            {
                m_shouldSetOtherToolbars = false;

                foreach (var toolbar in m_openedToolbars)
                {
                    if (toolbar != self)
                    {
                        toolbar.SetItemAtIndex(index.ItemIndex, self.GetItemAtIndex(index.ItemIndex));
                    }
                }
                m_shouldSetOtherToolbars = true;
            }

            var slot = Toolbar.GetItemAtIndex(index.ItemIndex);

            if (slot != null)
            {
                string name = slot.DisplayName.ToString();
                MyMultiplayer.RaiseEvent(this, x => x.SetButtonName, name, index.ItemIndex);
            }
        }
コード例 #3
0
ファイル: MyButtonPanel.cs プロジェクト: caomw/SpaceEngineers
        public string GetCustomButtonName(int pos)
        {
            string item = null;

            if (false == m_customButtonNames.Dictionary.TryGetValue(pos, out item))
            {
                var actionInSlot = Toolbar.GetItemAtIndex(pos);
                if (actionInSlot != null)
                {
                    return(actionInSlot.DisplayName.ToString());
                }
                return(MyTexts.GetString(MySpaceTexts.NotificationHintNoAction));
            }
            return(item);
        }
コード例 #4
0
ファイル: MyButtonPanel.cs プロジェクト: caomw/SpaceEngineers
        public StringBuilder GetButtonName()
        {
            if (m_selectedButton == -1)
            {
                return(m_emptyName);
            }

            string item = null;

            if (false == m_customButtonNames.Dictionary.TryGetValue(m_selectedButton, out item))
            {
                var actionInSlot = Toolbar.GetItemAtIndex(m_selectedButton);
                if (actionInSlot != null)
                {
                    return(actionInSlot.DisplayName);
                }

                return(m_emptyName);
            }
            return(new StringBuilder(item));
        }
コード例 #5
0
ファイル: MyButtonPanel.cs プロジェクト: caomw/SpaceEngineers
        void UpdateButtonEmissivity(int index)
        {
            if (!InScene)
            {
                return;
            }
            var c = BlockDefinition.ButtonColors[index % BlockDefinition.ButtonColors.Length];

            if (Toolbar.GetItemAtIndex(index) == null)
            {
                c = BlockDefinition.UnassignedButtonColor;
            }
            float emissivity = c.W;

            if (!IsFunctional || CubeGrid.GridSystems.PowerDistributor.PowerState == GameSystems.Electricity.MyPowerStateEnum.NoPower)
            {
                c          = Color.Red.ToVector4();
                emissivity = 0;
            }
            VRageRender.MyRenderProxy.UpdateModelProperties(Render.RenderObjectIDs[0], 0, null, -1, m_emissiveNames[index], null, new Color(c.X, c.Y, c.Z), null, null, emissivity);
        }
コード例 #6
0
        void UpdateButtonEmissivity(int index)
        {
            if (!InScene)
            {
                return;
            }
            var c = BlockDefinition.ButtonColors[index % BlockDefinition.ButtonColors.Length];

            if (Toolbar.GetItemAtIndex(index) == null)
            {
                c = BlockDefinition.UnassignedButtonColor;
            }
            float emissivity = c.W;

            if (!IsWorking)
            {
                c          = Color.Red.ToVector4();
                emissivity = 0;
            }
            UpdateNamedEmissiveParts(Render.RenderObjectIDs[0], m_emissiveNames[index], new Color(c.X, c.Y, c.Z), emissivity);
        }
コード例 #7
0
        void UpdateButtonEmissivity(int index)
        {
            if (!InScene)
            {
                return;
            }
            var c = BlockDefinition.ButtonColors[index % BlockDefinition.ButtonColors.Length];

            if (Toolbar.GetItemAtIndex(index) == null)
            {
                c = BlockDefinition.UnassignedButtonColor;
            }
            float emissivity = c.W;

            if (!IsFunctional || !Enabled || CubeGrid.GridSystems.ResourceDistributor.ResourceState == MyResourceStateEnum.NoPower)
            {
                c          = Color.Red.ToVector4();
                emissivity = 0;
            }
            VRageRender.MyRenderProxy.UpdateColorEmissivity(Render.RenderObjectIDs[0], 0, m_emissiveNames[index], new Color(c.X, c.Y, c.Z), emissivity);
        }