Exemple #1
0
        protected ModPrefab_Craftable(
            string nameID,
            string iconFilePath,
            TechType iconTechType,
            string friendlyName,
            string description,
            TechType template,
            TabNode newTabNode,
            CraftTree.Type[] fabricatorTypes,
            string[][] fabricatorTabs,
            TechType requiredAnalysis,
            TechGroup groupForPDA,
            TechCategory categoryForPDA,
            EquipmentType equipmentType,
            QuickSlotType quickSlotType,
            CraftData.BackgroundType backgroundType,
            Vector2int itemSize,
            string gamerResourceFileName,
            ModPrefab_Fragment fragment
            )
            : base(nameID, $"{nameID}:Prefab")
        {
            NameID               = nameID;
            IconFilePath         = iconFilePath;
            IconTechType         = iconTechType;
            FriendlyName         = friendlyName;
            Description          = description;
            PrefabTemplate       = template;
            NewTabNode           = newTabNode;
            FabricatorTypes      = fabricatorTypes;
            FabricatorTabs       = fabricatorTabs;
            RequiredForUnlock    = requiredAnalysis;
            GroupForPDA          = groupForPDA;
            CategoryForPDA       = categoryForPDA;
            TypeForEquipment     = equipmentType;
            TypeForQuickslot     = quickSlotType;
            BackgroundType       = backgroundType;
            ItemSize             = itemSize;
            GameResourceFileName = gamerResourceFileName;
            _Fragment            = fragment;

            //IngameMenuHandler.Main.RegisterOnQuitEvent(OnQuitEvent);
        }
        private void TiTle(Rect rect)
        {
            rect.DrawOutLine(2, Color.red);
            GUI.Box(rect, "", "GameToolbar");
            float offset  = rect.x;
            int   xx_size = 17;

            _nodes.ForEach((index, node) =>
            {
                bool _draw = node.needCloseBtn ? offset + node.tabWidth + xx_size <= rect.xMax : offset + node.tabWidth <= rect.xMax;

                if (!_draw)
                {
                    return;
                }

                var _rect = new Rect(offset, rect.y, node.tabWidth, rect.height);
                node.isOn = GUI.Toggle(_rect, node.isOn, node.content, "toolbarbutton");
                bool ison = node.isOn;
                if (ison)
                {
                    _current = node;
                    _nodes.ForEach((_node) =>
                    {
                        if (_node != node)
                        {
                            _node.isOn = false;
                        }
                    });
                }
                offset += node.tabWidth;
                if (node.needCloseBtn)
                {
                    _rect = new Rect(offset, rect.y, xx_size, rect.height);
                    if (GUI.Button(_rect, "", "WinBtnClose"))
                    {
                        RemoveTab(node.content);
                    }
                    offset += xx_size;
                }
            });
        }
Exemple #3
0
        public override CswNbtNode CopyNode(bool IsNodeTemp = false, Action <CswNbtNode> OnCopy = null)
        {
            // Copy NodeType
            string NewNodeTypeName = "Copy Of " + NodeTypeName.Text;
            Int32  CopyInt         = 1;

            while (null != _CswNbtResources.MetaData.getNodeType(NewNodeTypeName))
            {
                CopyInt++;
                NewNodeTypeName = "Copy " + CopyInt.ToString() + " Of " + NodeTypeName.Text;
            }

            CswNbtObjClassDesignNodeType NodeTypeCopy = base.CopyNodeImpl(IsNodeTemp, delegate(CswNbtNode NewNode)
            {
                ((CswNbtObjClassDesignNodeType)NewNode).InternalCreate    = true;
                ((CswNbtObjClassDesignNodeType)NewNode).NodeTypeName.Text = NewNodeTypeName;
                if (null != OnCopy)
                {
                    OnCopy(NewNode);
                }
            });

            // Copy Tabs
            Dictionary <Int32, CswNbtObjClassDesignNodeTypeTab> TabMap = new Dictionary <Int32, CswNbtObjClassDesignNodeTypeTab>();

            foreach (CswNbtObjClassDesignNodeTypeTab TabNode in getTabNodes())
            {
                CswNbtObjClassDesignNodeTypeTab TabCopy = TabNode.CopyNode(IsNodeTemp, delegate(CswNbtNode CopiedNode)
                {
                    ((CswNbtObjClassDesignNodeTypeTab)CopiedNode).NodeTypeValue.RelatedNodeId = NodeTypeCopy.NodeId;
                    ((CswNbtObjClassDesignNodeTypeTab)CopiedNode).TabName.Text = TabNode.TabName.Text;
                });

                TabMap.Add(TabNode.RelationalId.PrimaryKey, TabCopy);
            }

            // case 31518 - props won't be able to see the tab if we don't do this
            _CswNbtResources.MetaData.refreshAll();

            // Copy Props
            Collection <CswNbtObjClassDesignNodeTypeProp>        PropNodes = getPropNodes();
            Dictionary <Int32, CswNbtObjClassDesignNodeTypeProp> PropMap   = new Dictionary <Int32, CswNbtObjClassDesignNodeTypeProp>();

            foreach (CswNbtObjClassDesignNodeTypeProp PropNode in PropNodes)
            {
                CswNbtObjClassDesignNodeTypeProp PropCopy = PropNode.CopyNode(IsNodeTemp, delegate(CswNbtNode CopiedNode)
                {
                    ((CswNbtObjClassDesignNodeTypeProp)CopiedNode).NodeTypeValue.RelatedNodeId = NodeTypeCopy.NodeId;
                    ((CswNbtObjClassDesignNodeTypeProp)CopiedNode).PropName.Text = PropNode.PropName.Text;
                });
                PropMap.Add(PropNode.RelationalId.PrimaryKey, PropCopy);

                // Fix layout
                if (PropCopy.PropName.Text.Equals(CswNbtObjClass.PropertyName.Save))
                {
                    foreach (CswNbtObjClassDesignNodeTypeTab NewTab in TabMap.Values)
                    {
                        //Case 29181 - Save prop on all tabs except identity
                        if (NewTab.RelationalId.PrimaryKey != NodeTypeCopy.RelationalNodeType.getIdentityTab().TabId)
                        {
                            _CswNbtResources.MetaData.NodeTypeLayout.updatePropLayout(CswEnumNbtLayoutType.Edit, NodeTypeCopy.RelationalId.PrimaryKey, PropCopy.RelationalNodeTypeProp, false, NewTab.RelationalId.PrimaryKey, Int32.MaxValue, 1);
                        }
                    }
                }
                else
                {
                    foreach (CswEnumNbtLayoutType LayoutType in CswEnumNbtLayoutType._All)
                    {
                        Dictionary <Int32, CswNbtMetaDataNodeTypeLayoutMgr.NodeTypeLayout> OriginalLayouts = _CswNbtResources.MetaData.NodeTypeLayout.getLayout(LayoutType, PropNode.RelationalNodeTypeProp, null);
                        foreach (CswNbtMetaDataNodeTypeLayoutMgr.NodeTypeLayout OriginalLayout in OriginalLayouts.Values)
                        {
                            if (OriginalLayout != null)
                            {
                                Int32 NewTabId = Int32.MinValue;
                                if (LayoutType == CswEnumNbtLayoutType.Edit)
                                {
                                    NewTabId = TabMap[OriginalLayout.TabId].RelationalId.PrimaryKey;
                                }
                                _CswNbtResources.MetaData.NodeTypeLayout.updatePropLayout(LayoutType, NodeTypeCopy.RelationalId.PrimaryKey, PropCopy.RelationalNodeTypeProp, true, NewTabId, OriginalLayout.DisplayRow, OriginalLayout.DisplayColumn);
                            }
                        }
                    } // foreach( CswEnumNbtLayoutType LayoutType in CswEnumNbtLayoutType._All )
                }
            }         // foreach( CswNbtObjClassDesignNodeTypeProp PropNode in getPropNodes() )


            // Fix Conditional Props (case 22328)
            foreach (CswNbtObjClassDesignNodeTypeProp PropNode in PropNodes)
            {
                if (CswTools.IsPrimaryKey(PropNode.DisplayConditionProperty.RelatedNodeId))
                {
                    CswNbtObjClassDesignNodeTypeProp PropCopy             = PropMap[PropNode.RelationalId.PrimaryKey];
                    CswNbtObjClassDesignNodeTypeProp DisplayConditionProp = PropNodes.FirstOrDefault(p => p.NodeId == PropNode.DisplayConditionProperty.RelatedNodeId);
                    if (null != DisplayConditionProp)
                    {
                        CswNbtObjClassDesignNodeTypeProp DisplayConditionPropCopy = PropMap[DisplayConditionProp.RelationalId.PrimaryKey];
                        PropCopy.DisplayConditionProperty.RelatedNodeId = DisplayConditionPropCopy.NodeId;
                    }
                }
            }

            // Fix the name template, now that properties are in place
            NodeTypeCopy.postChanges(true);

            //if( OnCopyNodeType != null )
            //    OnCopyNodeType( OldNodeType, NewNodeType );

            return(NodeTypeCopy.Node);
        } // CopyNode()