Exemplo n.º 1
0
        private static void OnAcceptButtonClick(WindowBase sender, UIButtonClickEventArgs args)
        {
            try
            {
                CASGenetics ths = CASGenetics.gSingleton;
                if (ths == null)
                {
                    return;
                }

                if (!ths.mHourglassVisible)
                {
                    args.Handled = true;
                    if (ths.mSelectedOffspring != null)
                    {
                        if (CASPuck.Instance != null)
                        {
                            ths.mReturnState = ths.mSelectedOffspring.IsPet ? CASState.PetSummary : CASState.Summary;

                            CASPuck.Instance.AttemptingToAdd = true;
                            CASPuck.ShowInputBlocker();
                            Responder.Instance.CASModel.RequestLoadSim(ths.mSelectedOffspring, false);
                            Responder.Instance.CASModel.RequestAddSimToHousehold(false);
                            Responder.Instance.CASModel.RequestClearStack();
                            CASController.Singleton.SetCurrentState(ths.mReturnState);
                        }
                        else
                        {
                            FacialBlends.CopyGenetics(ths.mSelectedOffspring as SimDescription, sChoice, false, false);

                            new SavedOutfit.Cache(sChoice).PropagateGenetics(sChoice, CASParts.sPrimary);

                            SimOutfit currentOutfit = sChoice.CreatedSim.CurrentOutfit;
                            if (currentOutfit != null)
                            {
                                ThumbnailManager.GenerateHouseholdSimThumbnail(currentOutfit.Key, currentOutfit.Key.InstanceId, 0x0, ThumbnailSizeMask.Large | ThumbnailSizeMask.ExtraLarge | ThumbnailSizeMask.Medium | ThumbnailSizeMask.Small, ThumbnailTechnique.Default, true, false, sChoice.AgeGenderSpecies);
                            }

                            DestroyHousehold();

                            CASGenetics.Unload();
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Common.Exception("OnAcceptButtonClick", e);
            }
        }
Exemplo n.º 2
0
        private static void OnCancelButtonClick(WindowBase sender, UIButtonClickEventArgs args)
        {
            try
            {
                CASGenetics ths = CASGenetics.gSingleton;
                if (ths == null)
                {
                    return;
                }

                if (!ths.mHourglassVisible)
                {
                    args.Handled = true;

                    if (CASPuck.Instance != null)
                    {
                        ths.mReturnState = Responder.Instance.CASModel.CurrentSimDescription.IsPet ? CASState.PetSummary : CASState.Summary;

                        if (ths.mSelectedOffspring == null)
                        {
                            CASController.Singleton.SetCurrentState(ths.mReturnState);
                        }
                        else
                        {
                            int currentPreviewSim = CASPuck.gSingleton.CurrentPreviewSim;
                            if (currentPreviewSim != -1)
                            {
                                ths.mCancelingSim = true;
                                Responder.Instance.CASModel.RequestSetPreviewSim(currentPreviewSim);
                            }
                            else
                            {
                                CASController.Singleton.SetCurrentState(ths.mReturnState);
                            }
                        }
                    }
                    else
                    {
                        DestroyHousehold();

                        CASGenetics.Unload();
                    }
                }
            }
            catch (Exception e)
            {
                Common.Exception("OnCancelButtonClick", e);
            }
        }
Exemplo n.º 3
0
        protected override bool Run(SimDescription me, bool singleSelection)
        {
            List <SimDescription> sims = new List <SimDescription>();

            bool okayed;
            List <IMiniSimDescription> miniSims = FilteredSelection.Selection(me, Common.Localize("FamilyTreeInteraction:Parent"), new ParentTest(me).OnTest, SelectionOption.List, 7, false, out okayed);

            if (miniSims != null)
            {
                foreach (IMiniSimDescription miniSim in miniSims)
                {
                    SimDescription sim = miniSim as SimDescription;
                    if (sim == null)
                    {
                        continue;
                    }

                    sims.Add(sim);
                }
            }

            if (sims.Count == 0)
            {
                sims.AddRange(Relationships.GetParents(me));
            }

            if (sims.Count < 2)
            {
                SimpleMessageDialog.Show(Name, Common.Localize(GetTitlePrefix() + ":Failure"));
                return(false);
            }

            CASGeneticsEx.InitHousehold(sims);

            CASGeneticsEx.sChoice = me;

            if (CASGenetics.gSingleton == null)
            {
                CASGenetics.Load();
            }

            return(true);
        }
Exemplo n.º 4
0
            protected override bool OnPerform()
            {
                CASGenetics genetics = CASGenetics.gSingleton;

                if (genetics != null)
                {
                    Button childByID = genetics.GetChildByID(0x5da4901, true) as Button;
                    childByID.Click -= genetics.OnCancelButtonClick;
                    childByID.Click -= CASGeneticsEx.OnCancelButtonClick;
                    childByID.Click += CASGeneticsEx.OnCancelButtonClick;

                    childByID        = genetics.GetChildByID(0x5da97ff, true) as Button;
                    childByID.Click -= genetics.OnCancelButtonClick;
                    childByID.Click -= CASGeneticsEx.OnCancelButtonClick;
                    childByID.Click += CASGeneticsEx.OnCancelButtonClick;

                    if (genetics.mAcceptButton != null)
                    {
                        genetics.mAcceptButton.Click -= genetics.OnAcceptButtonClick;
                        genetics.mAcceptButton.Click -= CASGeneticsEx.OnAcceptButtonClick;
                        genetics.mAcceptButton.Click += CASGeneticsEx.OnAcceptButtonClick;
                    }

                    if ((genetics.mHourglassVisible) && (genetics.mSelectedOffspring == null) && (genetics.mSelectedParents.Length == 2))
                    {
                        if ((genetics.mSelectedParents[0] == null) && (genetics.mSelectedParents[1] == null))
                        {
                            if (genetics.mFathersButtons != null)
                            {
                                foreach (Button father in genetics.mFathersButtons)
                                {
                                    if (father == null)
                                    {
                                        continue;
                                    }

                                    ISimDescription fatherSim = father.Tag as ISimDescription;
                                    if (fatherSim == null)
                                    {
                                        continue;
                                    }

                                    genetics.mSelectedParents[0] = fatherSim;
                                    genetics.UpdateFatherPreviewTask();
                                    break;
                                }
                            }

                            if ((genetics.mSelectedParents[0] == null) && (genetics.mMothersButtons != null))
                            {
                                foreach (Button mother in genetics.mMothersButtons)
                                {
                                    if (mother == null)
                                    {
                                        continue;
                                    }

                                    ISimDescription motherSim = mother.Tag as ISimDescription;
                                    if (motherSim == null)
                                    {
                                        continue;
                                    }

                                    genetics.mSelectedParents[1] = motherSim;
                                    genetics.UpdateMotherPreviewTask();
                                    break;
                                }
                            }
                        }
                        else if ((genetics.mSelectedParents[0] == null) && (genetics.mSelectedParents[1] != null))
                        {
                            genetics.mSelectedParents[0] = genetics.mSelectedParents[1];
                            genetics.UpdateFatherPreviewTask();
                        }
                        else if ((genetics.mSelectedParents[1] == null) && (genetics.mSelectedParents[0] != null))
                        {
                            genetics.mSelectedParents[1] = genetics.mSelectedParents[0];
                            genetics.UpdateMotherPreviewTask();
                        }
                    }

                    bool enableButtons = (CASPuck.Instance == null);

                    if (genetics.mFathersButtons != null)
                    {
                        foreach (Button button in genetics.mFathersButtons)
                        {
                            if (button == null)
                            {
                                continue;
                            }

                            button.Click -= genetics.OnFatherThumbnailClick;

                            button.MouseUp -= CASGeneticsEx.OnFatherThumbnailMouseUp;
                            button.MouseUp += CASGeneticsEx.OnFatherThumbnailMouseUp;
                        }
                    }

                    if (genetics.mMothersButtons != null)
                    {
                        foreach (Button button in genetics.mMothersButtons)
                        {
                            if (button == null)
                            {
                                continue;
                            }

                            button.Click -= genetics.OnMotherThumbnailClick;

                            button.MouseUp -= CASGeneticsEx.OnMotherThumbnailMouseUp;
                            button.MouseUp += CASGeneticsEx.OnMotherThumbnailMouseUp;
                        }
                    }
                }

                return(true);
            }
Exemplo n.º 5
0
        private static void OnThumbnailMouseUp(WindowBase sender, UIMouseEventArgs args, CASAgeGenderFlags gender)
        {
            try
            {
                CASGenetics ths = CASGenetics.gSingleton;
                if (ths == null)
                {
                    return;
                }

                if (!ths.mHourglassVisible)
                {
                    CASAgeGenderFlags otherGender = CASAgeGenderFlags.Female;

                    Sims3.Gameplay.Function func    = ths.UpdateFatherPreviewTask;
                    Sims3.Gameplay.Function altFunc = ths.UpdateMotherPreviewTask;

                    int index = 0, altIndex = 1;
                    if (gender == CASAgeGenderFlags.Female)
                    {
                        index       = 1;
                        altIndex    = 0;
                        otherGender = CASAgeGenderFlags.Male;

                        func    = ths.UpdateMotherPreviewTask;
                        altFunc = ths.UpdateFatherPreviewTask;
                    }

                    ISimDescription tag = sender.Tag as ISimDescription;

                    if (args.MouseKey == MouseKeys.kMouseLeft)
                    {
                        sAlternate = !sAlternate;
                        if ((!HasGender(otherGender)) && (sAlternate))
                        {
                            ths.mSelectedParents[altIndex] = tag;
                            if (tag != null)
                            {
                                ths.CheckSpecies();

                                Common.FunctionTask.Perform(altFunc);
                            }
                        }
                        else
                        {
                            // Elements are intentionally reversed
                            ths.mSelectedParents[index] = tag;
                            if (tag != null)
                            {
                                ths.CheckSpecies();

                                Common.FunctionTask.Perform(func);
                            }
                        }
                    }
                    else if (args.MouseKey == MouseKeys.kMouseRight)
                    {
                        // Elements are intentionally reversed
                        ths.mSelectedParents[altIndex] = tag;
                        if (tag != null)
                        {
                            ths.CheckSpecies();

                            Common.FunctionTask.Perform(altFunc);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Common.Exception("OnThumbnailMouseUp", e);
            }
        }