Exemple #1
0
        public void RecalculateAttributes(IItemStack stack)
        {
            ModularItemHelper.RecalculateAttributes(stack, api.World);

            ItemStack headstack = GetToolheadStack(stack);

            int tooltier = 0;

            if (headstack != null)
            {
                headstack.ResolveBlockOrItem(api.World);
                ToolPart part = (ToolPart)headstack.Item;

                if (part != null)
                {
                    tooltier = part.TinkerProps.ToolTier;
                }
            }

            if (tooltier != 0)
            {
                stack.Attributes.SetInt("tooltier", tooltier);
            }
            else
            {
                stack.Attributes.RemoveAttribute("tooltier");
            }
        }
 //adding custom toolpart to webpart for custom properties
 public override Microsoft.SharePoint.WebPartPages.ToolPart[] GetToolParts()
 {
     ToolPart[] allToolParts = new ToolPart[2];
     //our custom toolpart
     allToolParts[0] = new MyToolPart();
     allToolParts[1] = new WebPartToolPart();
     return(allToolParts);
 }
Exemple #3
0
        public override ToolPart[] GetToolParts()
        {
            var toolparts = new ToolPart[2];

            toolparts[0] = new WebPartToolPart();
            toolparts[1] = new UserProfileToolPart();

            return(toolparts);
        }
        public override ToolPart[] GetToolParts()
        {
            ToolPart[] toolparts = new ToolPart[3];
            toolparts[0] = new ListSummaryToolpart();
            toolparts[1] = new WebPartToolPart();
            toolparts[2] = new CustomPropertyToolPart();


            return(toolparts);
        }
Exemple #5
0
 public override ToolPart[] GetToolParts()
 {
     var toolparts = new ToolPart[3];
     var wptp = new WebPartToolPart();
     var cptp = new CustomPropertyToolPart();
     var ctp = new DropDownList1();
     toolparts[0] = wptp;
     toolparts[1] = cptp;
     toolparts[2] = ctp;
     return toolparts;
 }
Exemple #6
0
 public override ToolPart[] GetToolParts()
 {
     ToolPart[] toolparts = new ToolPart[3];
     WebPartToolPart wptp = new WebPartToolPart();
     CustomPropertyToolPart cptp = new CustomPropertyToolPart();
     ToolpartDropDownList ctp = new ToolpartDropDownList();
     toolparts[0] = wptp;
     toolparts[1] = cptp;
     toolparts[2] = ctp;
     return toolparts;
 }
Exemple #7
0
 public override ToolPart[] GetToolParts()
 {
     var toolparts = new ToolPart[3];
     var wptp = new WebPartToolPart();
     var cptp = new CustomPropertyToolPart();
     var ctp = new AdvDdl(QCID.ToString());
     toolparts[0] = wptp;
     toolparts[1] = cptp;
     toolparts[2] = ctp;
     return toolparts;
 }
Exemple #8
0
 public override ToolPart[] GetToolParts()
 {
     ToolPart[] toolparts = new ToolPart[3];
     WebPartToolPart wptp = new WebPartToolPart();
     CustomPropertyToolPart cptp = new CustomPropertyToolPart();
     SelectNewsType ctp = new SelectNewsType();
     toolparts[0] = wptp;
     toolparts[1] = cptp;
     toolparts[2] = ctp;
     return toolparts;
 }
Exemple #9
0
        public override ToolPart[] GetToolParts()
        {
            ToolPart[] toolparts = new ToolPart[3];
            toolparts[0] = new WebPartToolPart();
            toolparts[1] = new CustomPropertyToolPart();

            //Create a custom toolpart
            toolparts[2] = new SummaryRollupToolpart();

            return(toolparts);
        }
Exemple #10
0
        public override ToolPart[] GetToolParts()
        {
            var toolparts = new ToolPart[3];
            var wptp      = new WebPartToolPart();
            var cptp      = new CustomPropertyToolPart();
            var ctp       = new AdvDdl(QCID.ToString());

            toolparts[0] = wptp;
            toolparts[1] = cptp;
            toolparts[2] = ctp;
            return(toolparts);
        }
Exemple #11
0
        public override ToolPart[] GetToolParts()
        {
            ToolPart[]             toolparts = new ToolPart[3];
            WebPartToolPart        wptp      = new WebPartToolPart();
            CustomPropertyToolPart cptp      = new CustomPropertyToolPart();
            ToolpartDropDownList   ctp       = new ToolpartDropDownList();

            toolparts[0] = wptp;
            toolparts[1] = cptp;
            toolparts[2] = ctp;
            return(toolparts);
        }
        public override ToolPart[] GetToolParts()
        {
            ToolPart[]             allToolsParts     = new ToolPart[3];
            WebPartToolPart        standardToolParts = new WebPartToolPart();
            CustomPropertyToolPart customToolParts   = new CustomPropertyToolPart();

            allToolsParts[0] = standardToolParts;
            allToolsParts[1] = customToolParts;
            allToolsParts[2] = new SimpleListItemToolPart();

            return(allToolsParts);
        }
Exemple #13
0
        public override ToolPart[] GetToolParts()
        {
            ToolPart[]             toolparts = new ToolPart[3];
            WebPartToolPart        wptp      = new WebPartToolPart();
            CustomPropertyToolPart cptp      = new CustomPropertyToolPart();
            SelectNewsType         ctp       = new SelectNewsType();

            toolparts[0] = wptp;
            toolparts[1] = cptp;
            toolparts[2] = ctp;
            return(toolparts);
        }
        public override ToolPart[] GetToolParts()
        {
            ToolPart[] allToolsParts = new ToolPart[3];
            WebPartToolPart standardToolParts = new WebPartToolPart();
            CustomPropertyToolPart customToolParts = new CustomPropertyToolPart();

            allToolsParts[0] = standardToolParts;
            allToolsParts[1] = customToolParts;
            allToolsParts[2] = new SimpleListToolPart();

            return allToolsParts;
        }
Exemple #15
0
        public override ToolPart[] GetToolParts()
        {
            var toolparts = new ToolPart[3];
            var wptp      = new WebPartToolPart();
            var cptp      = new CustomPropertyToolPart();
            var ctp       = new DropDownList1();

            toolparts[0] = wptp;
            toolparts[1] = cptp;
            toolparts[2] = ctp;
            return(toolparts);
        }
 public override ToolPart[] GetToolParts()
 {
     ToolPart[] toolParts = base.GetToolParts();
     if (toolParts.Length == 3)
     {
         ToolPart part = toolParts[0];
         toolParts[0] = toolParts[2];
         toolParts[2] = toolParts[1];
         toolParts[1] = part;
     }
     return(toolParts);
 }
Exemple #17
0
        public override ToolPart[] GetToolParts()
        {
            ToolPart[] toolparts = new ToolPart[4];

            toolparts[0]             = new WebPartToolPart();
            toolparts[1]             = new ListReportViewToolPart();
            toolparts[1].ChromeState = PartChromeState.Minimized;
            toolparts[2]             = new ReportingServicesToolPart();
            toolparts[2].ChromeState = PartChromeState.Minimized;
            toolparts[3]             = new CustomPropertyToolPart();

            return(toolparts);
        }
Exemple #18
0
        public override ToolPart[] GetToolParts()
        {
            ToolPart[] toolparts = new ToolPart[3];
            WebPartToolPart wp1 = new WebPartToolPart();
            CustomPropertyToolPart wp2 = new CustomPropertyToolPart();
            ToolPartCustom wp3 = new ToolPartCustom();

            wp1.Expand(WebPartToolPart.Categories.Appearance);
            toolparts[0] = wp1;
            toolparts[1] = wp2;
            toolparts[2] = wp3;

            return toolparts;
        }
        /// <summary>
        ///	This method gets the custom tool parts for this Web Part by overriding the
        ///	GetToolParts method of the WebPart base class. You must implement
        ///	custom tool parts in a separate class that derives from 
        ///	Microsoft.SharePoint.WebPartPages.ToolPart. 
        ///	</summary>
        ///<returns>An array of references to ToolPart objects.</returns>
        public override ToolPart[] GetToolParts()
        {
            ToolPart[] objToolParts = new ToolPart[3];
            WebPartToolPart objWPTP = new WebPartToolPart();
            CustomPropertyToolPart objCustomToolPart = new CustomPropertyToolPart();
            objToolParts[0] = objCustomToolPart;
            objToolParts[1] = objWPTP;
            objToolParts[2] = new CopyrightToolpart();

            objWPTP.Expand(Microsoft.SharePoint.WebPartPages.WebPartToolPart.Categories.Appearance);
            objCustomToolPart.Expand("User Control");

            return objToolParts;
        }
Exemple #20
0
        public override float GetMiningSpeed(IItemStack itemstack, Block block, IPlayer forPlayer)
        {
            ItemStack partstack = ModularItemHelper.GetToolheadStack(itemstack);
            ToolPart  part      = null;

            if (partstack != null)
            {
                partstack.ResolveBlockOrItem(api.World);
                part = (ToolPart)partstack.Item;
            }

            if (part != null)
            {
                return(part.GetMiningSpeed(itemstack, block, forPlayer));
            }

            return(base.GetMiningSpeed(itemstack, block, forPlayer));
        }
        /// <summary>
        /// Add a ListConnectionToolPart to enable users to easily select data sources.
        /// </summary>
        /// <returns></returns>
        public override ToolPart[] GetToolParts()
        {
            try
            {
                ToolPart[]             toolparts = new ToolPart[3];
                ListConnectionToolPart listConnectionToolPart = new ListConnectionToolPart();

                CustomPropertyToolPart custom = new CustomPropertyToolPart();
                WebPartToolPart        wptp   = new WebPartToolPart();

                toolparts[0] = listConnectionToolPart;
                toolparts[1] = wptp;
                toolparts[2] = custom;
                return(toolparts);
            }
            catch (Exception ex)
            { AddError(ex); }
            return(null);
        }
Exemple #22
0
        public override ToolPart[] GetToolParts()
        {
            ToolPart[] allToolsParts = new ToolPart[3];
            try
            {
                WebPartToolPart        standardToolParts = new WebPartToolPart();
                CustomPropertyToolPart customToolParts   = new CustomPropertyToolPart();

                allToolsParts[0] = standardToolParts;
                allToolsParts[1] = customToolParts;
                allToolsParts[2] = new SimpleListToolPart();
            }
            catch (Exception ex)
            {
                LogEngine.Log(ex, "Accessible Lists");
            }

            return(allToolsParts);
        }
        public override ToolPart[] GetToolParts()
        {
            ToolPart[] allToolsParts = new ToolPart[3];
            try
            {
                WebPartToolPart standardToolParts = new WebPartToolPart();
                CustomPropertyToolPart customToolParts = new CustomPropertyToolPart();

                allToolsParts[0] = standardToolParts;
                allToolsParts[1] = customToolParts;
                allToolsParts[2] = new SimpleListToolPart();
            }
            catch (Exception ex)
            {
                LogEngine.Log(ex, "Accessible Lists");
            }

            return allToolsParts;
        }
        public override ToolPart[] GetToolParts()
        {
            try
            {
                ToolPart[]      toolparts       = new ToolPart[3];
                KWizComToolPart kwizcomToolPart = new KWizComToolPart();

                CustomPropertyToolPart custom = new CustomPropertyToolPart();
                WebPartToolPart        wptp   = new WebPartToolPart();

                toolparts[0] = kwizcomToolPart;
                toolparts[1] = custom;
                toolparts[2] = wptp;
                return(toolparts);
            }
            catch (Exception ex)
            { AddError(ex); }
            return(null);
        }
Exemple #25
0
        private void DropOptionalParts()
        {
            Vec3d spawnPos = Pos.ToVec3d();

            spawnPos.Y += 1.1;

            SlotDefinition[] slots = (Inventory[0].Itemstack.Item as IModularItem).GetSlotDefinitions();

            for (int i = 1; i < Inventory.Count; ++i)
            {
                ItemStack      stack = Inventory[i].Itemstack;
                SlotDefinition slot  = slots[i - 1];

                ToolPart part = stack?.Item as ToolPart;

                if (part == null || !slot.ValidPartTypes.Contains(part.TinkerProps.PartType) || slot.Optional)
                {
                    Api.World.SpawnItemEntity(stack, spawnPos);
                    Inventory[i].Itemstack = null;
                }
            }
        }
Exemple #26
0
        public override void StartServerSide(ICoreServerAPI api)
        {
            base.StartServerSide(api);

            api.RegisterCommand("tboxcreate", "Generates an empty modular tool", "", (player, groupId, args) =>
            {
                if (this.modularTool == null)
                {
                    this.modularTool = ModCore.api.World.GetItem(new AssetLocation("tbox:modulartool"));
                }

                ItemStack modularStack = new ItemStack(modularTool);

                player.InventoryManager.TryGiveItemstack(modularStack, true);
            }, Privilege.chat);

            api.RegisterCommand("tboxadd", "Adds a tool part to the held modular item", "", (player, groupId, args) =>
            {
                ItemSlot slot    = player.InventoryManager.ActiveHotbarSlot;
                ModularItem tool = slot.Itemstack?.Item as ModularItem;
                if (tool != null)
                {
                    string toolslot = args.PopWord();
                    ToolPart part   = GetItem(new AssetLocation(args.PopWord())) as ToolPart;

                    if (part != null)
                    {
                        if (tool.AddPart(slot.Itemstack, toolslot, new ItemStack(part, 1)))
                        {
                            slot.MarkDirty();
                        }
                        else
                        {
                            player.SendMessage(groupId, "Can't add part to modular item", EnumChatType.CommandError);
                        }
                    }
                    else
                    {
                        player.SendMessage(groupId, "Part does not exist or doesn't have the ToolPart class applied", EnumChatType.CommandError);
                    }
                }
                else
                {
                    player.SendMessage(groupId, "You are not holding a modular item", EnumChatType.CommandError);
                }
            }, Privilege.chat);

            api.RegisterCommand("tboxremove", "Removes a tool part from the held modular item", "", (player, groupId, args) =>
            {
                ItemSlot slot    = player.InventoryManager.ActiveHotbarSlot;
                ModularItem tool = slot.Itemstack?.Item as ModularItem;
                if (tool != null)
                {
                    string toolslot = args.PopWord();

                    ItemStack part = tool.RemovePart(slot.Itemstack, toolslot);
                    part.ResolveBlockOrItem(ModCore.api.World);

                    if (part != null)
                    {
                        player.InventoryManager.TryGiveItemstack(part, true);
                    }
                    slot.MarkDirty();
                }
                else
                {
                    player.SendMessage(groupId, "You are not holding a modular item", EnumChatType.CommandError);
                }
            }, Privilege.chat);
        }
Exemple #27
0
        private void OnSlotModified(int slot)
        {
            if (Api.Side == EnumAppSide.Server)
            {
                bool dirty = false;
                if (slot == 0)
                {
                    if (Inventory[0].Itemstack == null)
                    {
                        DropInvalidParts();
                        inventory.Resize(4);
                        dirty = true;
                    }
                    else if (Inventory[0].Itemstack != null)
                    {
                        // Drop any items that are not ToolPart into the world
                        DropInvalidParts();

                        IModularItem item = Inventory[0].Itemstack?.Item as IModularItem;

                        if (item != null)
                        {
                            // Fill part slots
                            SlotDefinition[] slotdefs = item.TinkerProps.AvailableSlots;

                            if (slotdefs != null)
                            {
                                inventory.Resize(slotdefs.Length + 1);
                                var slots = item.GetSlots(Inventory[0].Itemstack);
                                for (int i = 0; i < slotdefs.Length; ++i)
                                {
                                    var toolpart = slots[slotdefs[i].SlotName];

                                    Inventory[i + 1].Itemstack = toolpart;
                                }
                            }
                            else
                            {
                                DropParts();
                                inventory.Resize(1);
                            }
                        }
                        else
                        {
                            // Not a valid IModularItem, so no slots
                            DropParts();
                            inventory.Resize(1);
                        }

                        dirty = true;
                    }
                }
                else
                {
                    if (Inventory[0].Itemstack != null)
                    {
                        int              partindex = slot - 1;
                        IModularItem     item      = Inventory[0].Itemstack.Item as IModularItem;
                        SlotDefinition[] slotdefs  = item.TinkerProps.AvailableSlots;

                        // Only apply the part if it inside the number of available slots
                        if (partindex < slotdefs?.Length)
                        {
                            SlotDefinition slotdef = slotdefs[partindex];
                            item.RemovePart(Inventory[0].Itemstack, slotdef.SlotName);

                            ToolPart part = Inventory[slot].Itemstack?.Item as ToolPart;

                            if (part != null)
                            {
                                item.AddPart(Inventory[0].Itemstack, slotdef.SlotName, Inventory[slot].Itemstack);
                            }
                        }

                        if (!item.HasNeededParts(Inventory[0].Itemstack))
                        {
                            DropOptionalParts();
                            Inventory[0].Itemstack = null;
                        }
                    }
                    else
                    {
                        ToolPart toolhead = Inventory[1].Itemstack?.Item as ToolPart;
                        ToolPart handle   = Inventory[3].Itemstack?.Item as ToolPart;

                        if (toolhead != null && handle != null && toolhead.TinkerProps.ResultItem != null)
                        {
                            IModularTool result = Api.World.GetItem(new AssetLocation(toolhead.TinkerProps.ResultItem)) as IModularTool;

                            if (result != null)
                            {
                                Inventory[0].Itemstack = new ItemStack(result as Item, 1);

                                if (!(result.AddPart(Inventory[0].Itemstack, "toolhead", Inventory[1].Itemstack) && result.AddPart(Inventory[0].Itemstack, "handle", Inventory[3].Itemstack)))
                                {
                                    Inventory[0].Itemstack = null;
                                }
                            }
                        }
                    }


                    dirty = true;
                }

                if (lastStack?.Item == null || lastStack.Item is IModularItem)
                {
                    lastStack = Inventory[0].Itemstack;
                }

                // Resend the inventory if needed
                if (dirty)
                {
                    byte[] data;

                    using (MemoryStream ms = new MemoryStream())
                    {
                        BinaryWriter  writer = new BinaryWriter(ms);
                        TreeAttribute tree   = new TreeAttribute();
                        inventory.ToTreeAttributes(tree);
                        tree.ToBytes(writer);
                        data = ms.ToArray();
                    }

                    foreach (string guid in Inventory.openedByPlayerGUIds)
                    {
                        IServerPlayer player = Api.World.PlayerByUid(guid) as IServerPlayer;

                        // Make sure that only online players recieve the update
                        if (player.ConnectionState != EnumClientState.Offline)
                        {
                            UpdateInventory(player, data);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Method retrievs the toolpart for the calendar
        /// </summary>
        /// <returns></returns>
        public override ToolPart[] GetToolParts()
        {
            ToolPart[] toolparts = new ToolPart[3];
            WebPartToolPart wptp = new WebPartToolPart();
            CustomPropertyToolPart custom = new CustomPropertyToolPart();
            toolparts[0] = custom;
            toolparts[1] = wptp;

            toolparts[2] = new NCMiniCalendarToolpart();

            return toolparts;
        }