Exemplo n.º 1
0
            protected int NextSort(SimInfo left, SimInfo right)
            {
                if (mOrder >= 2) return 0;

                Sorter sorter = new Sorter(mOrder + 1);

                SorterFunc sort = sorter.GetSort();
                if (sort == null) return 0;

                return sort(left, right);
            }
Exemplo n.º 2
0
        public void PopulateSkewer(Window skewer, ref Skewer.SkewerItem[] skewerItems, float baseSize, float deltaSize)
        {
            Common.StringBuilder msg = new Common.StringBuilder("PopulateSkewer");

            try
            {
                if (mCyclePortraits != null)
                {
                    mCyclePortraits.Visible = ((PortraitPanel.Settings.mShowCycleButton) || (!PortraitPanel.Settings.mShowSimMenu) || (mSimInfo.Count > 24));
                }

                if (Skewer.Instance.mPetsSkewer != null)
                {
                    Skewer.Instance.mPetsSkewer.Visible = false;
                }

                HideSkewer(ref Skewer.Instance.mHouseholdItems);
                HideSkewer(ref Skewer.Instance.mPetItems);
                HideSkewer(ref skewerItems);

                float num = baseSize + (deltaSize * 8f);

                msg += Common.NewLine + num;

                skewer.Visible = false;
                if ((mSimInfo != null) && (mSimInfo.Count > 0))
                {
                    Sorter sorter = new Sorter(0);

                    Sorter.SorterFunc sort = sorter.GetSort();
                    if (sort != null)
                    {
                        mSimInfo.Sort(new Comparison<SimInfo>(sort));
                    }

                    int maximumPortraits = 24;
                    int maximumColumn3 = 8;
                    if (!PortraitPanel.Settings.mUsePortraitSeventeen)
                    {
                        maximumPortraits--;
                        maximumColumn3--;
                    }

                    int count = mSimInfo.Count;
                    if (count > 0x0)
                    {
                        msg += Common.NewLine + count;

                        bool exceeded = false;

                        List<SimInfo> column1 = new List<SimInfo>();
                        List<SimInfo> column2 = new List<SimInfo>();
                        List<SimInfo> column3 = new List<SimInfo>();

                        if ((mSimInfo.Count > maximumPortraits) && (PortraitPanel.Settings.mRevertToSingleListOnTooMany))
                        {
                            exceeded = true;
                        }
                        else
                        {
                            foreach (SimInfo info in mSimInfo)
                            {
                                SimDescription sim = PortraitPanel.Settings.GetSim(info);
                                if (sim == null) continue;

                                List<List<SimInfo>> choices = new List<List<SimInfo>>();
                                List<int> maximums = new List<int>();

                                if (IsVisible(sim, PortraitPanel.Settings.mColumnFilter1, false, 1))
                                {
                                    msg += Common.NewLine + "IsVisible 1";

                                    choices.Add(column1);
                                    maximums.Add(8);
                                }
                                
                                if (IsVisible(sim, PortraitPanel.Settings.mColumnFilter2, false, 2))
                                {
                                    msg += Common.NewLine + "IsVisible 2";

                                    choices.Add(column2);
                                    maximums.Add(8);
                                }
                                
                                if (IsVisible(sim, PortraitPanel.Settings.mColumnFilter3, false, 3))
                                {
                                    msg += Common.NewLine + "IsVisible 3";

                                    choices.Add(column3);
                                    maximums.Add(maximumColumn3);
                                }
                                
                                if ((choices.Count == 0) && (PortraitPanel.Settings.mRevertToSingleListOnFilterFail))
                                {
                                    msg += Common.NewLine + "Exceeded 1";

                                    exceeded = true;
                                }

                                bool placed = false;
                                for (int i = 0; i < choices.Count; i++)
                                {
                                    if (choices[i].Count < maximums[i])
                                    {
                                        choices[i].Add(info);
                                        placed = true;
                                        break;
                                    }
                                }

                                if (!placed)
                                {
                                    if (PortraitPanel.Settings.mRevertToSingleListOnFilterFail)
                                    {
                                        msg += Common.NewLine + "Exceeded 2";

                                        exceeded = true;
                                    }
                                    else if (choices.Count > 0)
                                    {
                                        choices[0].Add(info);
                                    }
                                }
                            }
                        }

                        if ((column1.Count + column2.Count + column3.Count) == 0)
                        {
                            msg += Common.NewLine + "Exceeded 3";

                            exceeded = true;
                        }

                        float num4 = baseSize;
                        if (exceeded)
                        {
                            Populate(ref skewerItems, 0, mSimInfo, 0, deltaSize, ref num4);
                        }
                        else
                        {
                            Populate(ref skewerItems, 0, column1, 1, deltaSize, ref num4);
                            Populate(ref skewerItems, 8, column2, 2, deltaSize, ref num4);
                            Populate(ref skewerItems, 16, column3, 3, deltaSize, ref num4);
                        }

                        Rect area = skewer.Area;
                        area.Set(area.TopLeft.x, num - num4, area.BottomRight.x, area.BottomRight.y);
                        skewer.Area = area;
                        skewer.Visible = true;
                    }
                }
            }
            catch (Exception exception)
            {
                Common.Exception(msg, exception);
            }
            finally
            {
                //Common.DebugWriteLog(msg);
            }
        }