Exemple #1
0
        void CloneItem()
        {
            if (this.lv.SelectedItems.Count > 0)
            {
                this.Cursor = Cursors.WaitCursor;
                try
                {
                    // this command operates on a single item only;
                    // to avoid ambiguity, use the focused item
                    NgbhItem item = this.GetFocusedItem();
                    if (item != null)
                    {
                        int      itemIndex = this.lv.FocusedItem.Index + 1;
                        NgbhItem item1     = item.Clone();

                        items.Insert(itemIndex, item1);
                        this.AddItemAt(item1, itemIndex);

                        this.lv.FocusedItem.Focused = false;
                    }
                }
                catch (Exception exception1)
                {
                    this.Cursor = Cursors.Default;
                    Helper.ExceptionMessage(Localization.Manager.GetString("errconvert"), exception1);
                }
                this.Cursor = Cursors.Default;
            }
        }
Exemple #2
0
        /// <summary>
        /// Unserializes a BinaryStream into the Attributes of this Instance
        /// </summary>
        /// <param name="reader">The Stream that contains the FileData</param>
        internal virtual void Unserialize(System.IO.BinaryReader reader)
        {
            if ((uint)parent.Version >= (uint)NgbhVersion.Nightlife)
            {
                version = reader.ReadUInt32();
            }

            uint ct = reader.ReadUInt32();

            itemsa.Clear();
            for (int j = 0; j < ct; j++)
            {
                NgbhItem item = itemsa.AddNew();
                item.Unserialize(reader);
            }



            ct = reader.ReadUInt32();
            itemsb.Clear();
            for (int j = 0; j < ct; j++)
            {
                NgbhItem item = itemsb.AddNew();
                item.Unserialize(reader);
            }

            if (parent != null)
            {
                parent.Changed = false;
            }
        }
Exemple #3
0
        public void SelectMemoriesByGuid(Collections.NgbhItems items)
        {
            if (items.Length > 0)
            {
                this.lv.Enabled = false;

                ArrayList guidList = new ArrayList();
                foreach (NgbhItem item in items)
                {
                    if (!guidList.Contains(item.Guid))
                    {
                        guidList.Add(item.Guid);
                    }
                }

                foreach (ListViewItem li in this.lv.Items)
                {
                    NgbhItem item = li.Tag as NgbhItem;
                    if (guidList.Contains(item.Guid))
                    {
                        li.Selected = true;
                    }
                }

                this.lv.Enabled = true;
            }
        }
Exemple #4
0
        void AddItemToList(NgbhItem item)
        {
            if (item == null)
            {
                return;
            }

            NgbhItemsListViewItem lvi = new NgbhItemsListViewItem(this, item);
        }
Exemple #5
0
        public void DeleteMemoryEchoes(Collections.NgbhItems items, uint ownerID)
        {
            int deletedCount       = 0;
            ExceptionBuilder trace = new ExceptionBuilder();

            trace.Append("Memories found:" + Helper.lbr);

            Collections.NgbhSlots slots = this.GetSlots(Data.NeighborhoodSlots.Sims);
            foreach (NgbhSlot slot in slots)
            {
                // skip my own memories?
                if (ownerID == slot.SlotID)
                {
                    continue;
                }

                SDesc simDesc = FileTable.ProviderRegistry.SimDescriptionProvider.SimInstance[(ushort)slot.SlotID] as SDesc;
                Collections.NgbhItems simMemories = slot.ItemsB;

                Collections.NgbhItems memoryToRemove = new SimPe.Plugin.Collections.NgbhItems(null);
                for (int j = 0; j < simMemories.Length; j++)
                {
                    for (int i = 0; i < items.Length; i++)
                    {
                        NgbhItem item      = items[i];
                        NgbhItem simMemory = simMemories[j];

                        if (
                            simMemory.IsMemory && item.IsMemory &&
                            simMemory.Guid == item.Guid &&
                            ArrayEquals(simMemory.Data, item.Data) &&
                            !simMemory.Flags.IsVisible
                            )
                        {
                            memoryToRemove.Add(simMemory);                             // simMemory.RemoveFromParentB();
                        }
                    }
                }

                if (memoryToRemove.Count > 0)
                {
                    deletedCount += memoryToRemove.Count;
                    trace.AppendFormat("{0} {1}: {2} \r\n", simDesc.SimName, simDesc.SimFamilyName, memoryToRemove.Count);
                    foreach (NgbhItem item in memoryToRemove)
                    {
                        trace.AppendFormat("\t- {0}\r\n", item.ToString());
                    }
                    trace.Append("\t\r\n\r\n");
                    slot.ItemsB.Remove(memoryToRemove);
                }
            }

            if (deletedCount > 0)
            {
                Message.Show(String.Format("Deleted {0} memories from the sim pool", deletedCount) + Helper.lbr + Helper.lbr + trace.ToString());
            }
        }
Exemple #6
0
        public NgbhItem FindItem(uint guid)
        {
            NgbhItem res = itemsa.FindItemByGuid(guid);

            if (res == null)
            {
                res = itemsb.FindItemByGuid(guid);
            }
            return(res);
        }
Exemple #7
0
        void InsertItemToList(int index, NgbhItem item)
        {
            if (item == null)
            {
                return;
            }

            NgbhItemsListViewItem lvi = new NgbhItemsListViewItem(this, item, false);

            lv.Items.Insert(index, lvi);
        }
Exemple #8
0
 private void AddItemAt(NgbhItem item, int index)
 {
     this.InsertItemToList(index, item);
     this.lv.SelectedItems.Clear();
     this.lv.Items[index].Selected = true;
     this.lv.Items[index].EnsureVisible();
     if (this.SelectedIndexChanged != null)
     {
         SelectedIndexChanged(this, new EventArgs());
     }
 }
Exemple #9
0
        public NgbhItem Clone(Ngbh parent, NgbhSlotList parentslot)
        {
            NgbhItem ret = new NgbhItem(parentslot);

            ret.guid   = this.guid;
            ret.data   = this.data.Clone() as ushort[];
            ret.flags  = this.flags;
            ret.flags2 = this.flags2;
            ret.parent = parent;
            ret.invnr  = this.invnr;
            return(ret);
        }
Exemple #10
0
 void SelectSubject(NgbhItem item)
 {
     this.cbSubject.SelectedSimId = item.SubjectGuid;
     if (item.MemoryType == SimMemoryType.Object)
     {
         this.cbSubjectObj.SelectedGuid = item.ReferencedObjectGuid;
     }
     else
     {
         this.cbSubjectObj.SelectedGuid = item.SubjectGuid;
     }
 }
Exemple #11
0
        internal void UpdateSelected(NgbhItem item)
        {
            if (item == null)
            {
                return;
            }
            if (SelectedItem == null)
            {
                return;
            }

            SelectedItem.Update();
            this.Refresh(false);
        }
Exemple #12
0
        protected ushort GetSecondaryAspirationValue(SDesc sim)
        {
            if (!SimPe.Helper.WindowsRegistry.AllowChangeOfSecondaryAspiration)
            {
                return(0);
            }
            NgbhItem ni = GetSecondaryAspirationToken(sim, false);

            if (ni == null)
            {
                return(0);
            }
            return(ni.Value);
        }
Exemple #13
0
        public NgbhItemsListViewItem(NgbhItemsListView parent, NgbhItem item, bool autoadd) : base()
        {
            this.item   = item;
            this.parent = parent;
            //mci = NgbhUI.ObjectCache.FindItem(item.Guid);



            Update();
            if (autoadd)
            {
                parent.Items.Add(this);
            }
        }
Exemple #14
0
        private void lladd_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            if (items == null || cbadd.SelectedIndex < 0)
            {
                return;
            }

            Data.Alias    a   = cbadd.SelectedItem as Data.Alias;
            SimMemoryType smt = (SimMemoryType)a.Id;

            int      index = this.NextItemIndex(true);
            NgbhItem item  = items.InsertNew(index, smt);

            item.SetInitialGuid(smt);
            InsertItemToList(index, item);

            lv.Items[index].Selected = true;
            lv.Items[index].EnsureVisible();
        }
Exemple #15
0
        void PasteItems(bool asgossip)
        {
            int itemIndex = this.NextItemIndex(false);

            this.Cursor = Cursors.WaitCursor;
            System.Collections.Queue newq = new Queue();
            try
            {
                while (clipboard.Count > 0)
                {
                    NgbhItem item = clipboard.Dequeue() as NgbhItem;
                    newq.Enqueue(item);

                    if (item != null)
                    {
                        item = item.Clone(this.Slot);

                        if (item.IsMemory && item.OwnerInstance > 0 && !asgossip)
                        {
                            item.OwnerInstance = (ushort)items.Parent.SlotID;
                        }

                        if (asgossip)
                        {
                            item.Flags.IsVisible = false;
                        }

                        AddItemAfterSelected(item);
                    }
                }
            }
            catch (Exception exception1)
            {
                this.Cursor = Cursors.Default;
                Helper.ExceptionMessage(Localization.Manager.GetString("errconvert"), exception1);
            }

            clipboard.Clear();
            clipboard   = newq;
            this.Cursor = Cursors.Default;
        }
Exemple #16
0
        void SetContent()
        {
            if (inter)
            {
                return;
            }
            inter = true;
            if (des != null && slot != null)
            {
                item            = slot.FindItem(des.Guid);
                pb.NumberOffset = des.Minimum;
                pb.Maximum      = des.Maximum;

                if (item != null)
                {
                    pb.Value = item.GetValue(des.DataNumber);
                    if (des.HasComplededFlag)
                    {
                        cb.Checked = item.GetValue(des.CompletedDataNumber) != 0;
                    }
                }
                else
                {
                    lb.Text = des.ToString();
                }



                this.Enabled = true;
            }
            else
            {
                this.Enabled = false;
            }


            SetVisible();
            inter = false;
        }
Exemple #17
0
        private void ll_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            if (item != null)
            {
                return;
            }
            if (slot == null)
            {
                return;
            }
            if (des == null)
            {
                return;
            }

            if (des.Intern)
            {
                item = slot.ItemsA.AddNew(SimMemoryType.Skill);
            }
            else
            {
                item = slot.ItemsB.AddNew(SimMemoryType.Skill);
            }

            item.Guid = des.Guid;
            item.PutValue(des.DataNumber, 0);
            if (des.HasComplededFlag)
            {
                item.PutValue(des.CompletedDataNumber, 0);
            }

            SetContent();

            if (AddedNewItem != null)
            {
                AddedNewItem(this, new EventArgs());
            }
        }
Exemple #18
0
        protected NgbhItem GetSecondaryAspirationToken(SDesc sim, bool create)
        {
            if (ngbh == null)
            {
                return(null);
            }
            NgbhSlot slot = ngbh.Sims.GetInstanceSlot(sim.Instance, true);

            if (slot != null)
            {
                NgbhItem item = slot.FindItem(SEC_ASP_TOKEN_GUID);
                if (create && item == null)
                {
                    item = slot.ItemsB.AddNew(SimMemoryType.Token);

                    item.Guid  = SEC_ASP_TOKEN_GUID;
                    item.Value = 0;
                }
                return(item);
            }

            return(null);
        }
Exemple #19
0
        void AddItemAfterSelected(NgbhItem item)
        {
            //if (this.lv.SelectedItems.Count > 0)
            {
                this.Cursor = Cursors.WaitCursor;
                try
                {
                    int selectedIndex = this.NextItemIndex(true);

                    NgbhItems.Insert(selectedIndex, item);
                    this.AddItemAt(item, selectedIndex);
                    this.lv.Items[selectedIndex].Selected = true;
                    this.lv.Items[selectedIndex].EnsureVisible();
                }
                catch (Exception exception1)
                {
                    this.Cursor = Cursors.Default;
                    Helper.ExceptionMessage(Localization.Manager.GetString("errconvert"), exception1);
                }

                this.Cursor = Cursors.Default;
            }
        }
Exemple #20
0
 public void Dispose()
 {
     item   = null;
     parent = null;
 }
Exemple #21
0
 public NgbhItemsListViewItem(NgbhItemsListView parent, NgbhItem item) : this(parent, item, true)
 {
 }
Exemple #22
0
        public void StoreAspirations(SimPe.Data.MetaData.AspirationTypes[] asps, SDesc sim)
        {
            if (sim == null)
            {
                return;
            }
            if (asps == null)
            {
                return;
            }
            if (asps.Length < 2)
            {
                return;
            }
            SimPe.Data.MetaData.AspirationTypes[] old = LoadAspirations(sim);
            bool chg  = false;
            bool chg2 = asps[1] != old[1];

            for (int i = 0; i < 2; i++)
            {
                if (asps[i] != old[i])
                {
                    chg = true;
                }
            }

            if (!chg)
            {
                return;
            }
            //LoadMemoryResource(sim);
            ushort a = 0;
            ushort v = 0;

            for (int i = 0; i < 2; i++)
            {
                if (i == 0)
                {
                    v = (ushort)asps[i];
                }
                else if (i == 1 && ((ushort)asps[i]) == v)
                {
                    v = 0;
                }
                else if (i == 1)
                {
                    v = (ushort)asps[i];
                }
                a |= (ushort)asps[i];
            }

            sim.CharacterDescription.Aspiration = (SimPe.Data.MetaData.AspirationTypes)a;

            if (SimPe.Helper.WindowsRegistry.AllowChangeOfSecondaryAspiration && chg2)
            {
                NgbhItem itm = GetSecondaryAspirationToken(sim, true);
                itm.Value = v;

                ngbh.SynchronizeUserData();
            }
        }
Exemple #23
0
 void SelectOwner(SimPe.PackedFiles.Wrapper.SimComboBox cb, NgbhItem item)
 {
     cb.SelectedSimInstance = item.OwnerInstance;
 }
Exemple #24
0
 void SelectNgbhItem(SimPe.PackedFiles.Wrapper.ObjectComboBox cb, NgbhItem item)
 {
     cb.SelectedGuid = item.Guid;
 }
Exemple #25
0
        public void FixNeighborhoodMemories()
        {
            int deletedCount = 0;
            int fixedCount   = 0;

            ExceptionBuilder trace = new ExceptionBuilder();

            trace.Append("Invalid memories found:" + Helper.lbr);

            Collections.NgbhSlots slots = this.GetSlots(Data.NeighborhoodSlots.Sims);

            foreach (NgbhSlot slot in slots)
            {
                SDesc simDesc = FileTable.ProviderRegistry.SimDescriptionProvider.SimInstance[slot.SlotID] as SDesc;
                Collections.NgbhItems simMemories = slot.ItemsB;

                ArrayList memoryToRemove = new ArrayList();
                ArrayList memoryToFix    = new ArrayList();


                NgbhItem lastSpamMemory = null;

                for (int j = 0; j < simMemories.Length; j++)
                {
                    NgbhItem simMemory = simMemories[j];

                    // skip tokens...
                    if (simMemory.IsMemory)
                    {
                        // ...and the lame "Met Unknown" memories
                        if (simMemory.SimInstance != 0)
                        {
                            // fix invalid sim instances
                            ushort inst = FileTable.ProviderRegistry.SimDescriptionProvider.GetInstance(simMemory.SimID);
                            if (simMemory.SimInstance != inst)
                            {
                                simMemory.SimInstance = inst;
                                memoryToFix.Add(simMemory);
                            }


                            if (simDesc == null)
                            {
                                memoryToRemove.Add(simMemory);
                            }
                        }

                        // it could be spam...
                        // collapse duplicate items
                        if (simMemory.IsSpam)
                        {
                            if (
                                lastSpamMemory != null &&
                                lastSpamMemory.Guid == simMemory.Guid &&
                                lastSpamMemory.SimInstance == simMemory.SimInstance
                                )
                            {
                                memoryToRemove.Add(simMemory);
                            }

                            lastSpamMemory = simMemory;
                        }
                        else
                        {
                            lastSpamMemory = null;
                        }
                    }
                }                 // for simMemories


                if (memoryToRemove.Count > 0 || memoryToFix.Count > 0)
                {
                    deletedCount += memoryToRemove.Count;
                    fixedCount   += memoryToFix.Count;

                    trace.AppendFormat("{0} {1}: {2} \r\n", simDesc.SimName, simDesc.SimFamilyName, memoryToRemove.Count + memoryToFix.Count);

                    foreach (NgbhItem item in memoryToFix)
                    {
                        trace.AppendFormat("[FIX]- {0}\r\n", item.ToString());
                    }

                    NgbhItem[] itemsToRemove = (NgbhItem[])memoryToRemove.ToArray(typeof(NgbhItem));
                    foreach (NgbhItem item in itemsToRemove)
                    {
                        trace.AppendFormat("[DEL]- {0}\r\n", item.ToString());
                    }

                    trace.Append("\t\r\n\r\n");
                    slot.ItemsB.Remove(itemsToRemove);
                }
            }

            if (deletedCount > 0 || fixedCount > 0)
            {
                Helper.ExceptionMessage(String.Format("Fixed/Deleted {0} invalid memories.", deletedCount + fixedCount), trace);
            }
        }