コード例 #1
0
        public static void Postfix(StorageSettings __instance, Action __state)
        {
            //BUG FIX TIME
            //public void ExposeData() in StorageSettings would re-assign the filter, meaning the action passed to its ctor was lost
            //so workaround, save it before ExposeData and re-assign it
            RankComp.settingsChangedCallbackInfo.SetValue(__instance.filter, __state);

            //Save/load the ranked filters in a list
            var comp = RankComp.Get();

            if (Scribe.mode == LoadSaveMode.Saving)
            {
                List <ThingFilter> ranks = comp?.GetRanks(__instance, false);
                if (ranks == null)
                {
                    return;
                }

                Scribe_Collections.Look(ref ranks, "ranks", LookMode.Deep);
            }
            else if (Scribe.mode == LoadSaveMode.LoadingVars)
            {
                List <ThingFilter> loadRanks = null;
                Scribe_Collections.Look(ref loadRanks, "ranks", LookMode.Deep);
                comp?.SetRanks(__instance, loadRanks);
            }
        }
コード例 #2
0
        public void DoWindowContents(Rect wrect)
        {
            var options = new Listing_Standard();

            options.Begin(wrect);

            bool old = returnLower;

            options.CheckboxLabeled("TD.SettingReturn".Translate(), ref returnLower);
            if (old != returnLower)
            {
                if (RankComp.Get() is RankComp comp)
                {
                    comp.dirty = true;
                }
            }
            options.Label("TD.SettingDescCPU".Translate());
            options.Label("TD.SettingDescLowerStorage".Translate());
            options.Label("TD.SettingDescDefault".Translate());
            options.Gap();
            options.Label("TD.SettingDesc".Translate());
            options.Gap();

            options.End();
        }
コード例 #3
0
        public static void DrawRanking(ITab_Storage tab)
        {
            IHaulDestination haulDestination = SelStoreInfo.GetValue(tab, null) as IHaulDestination;

            if (haulDestination == null)
            {
                return;
            }
            StorageSettings settings = haulDestination.GetStoreSettings();

            if (settings == null)
            {
                return;
            }

            var comp  = RankComp.Get();
            int count = comp.CountExtraFilters(settings);

            if (curRank > count)
            {
                curRank = count;
            }

            float buttonMargin = TopAreaHeight.rankHeight + 4;

            //ITab_Storage.WinSize = 300
            Rect rect = new Rect(0f, (float)GetTopAreaHeight.Invoke(tab, new object[] { }) - TopAreaHeight.rankHeight - 2, 280, TopAreaHeight.rankHeight);

            //Left Arrow
            Rect leftButtonRect = rect.LeftPartPixels(TopAreaHeight.rankHeight);

            if (curRank > 0)
            {
                if (Widgets.ButtonImage(leftButtonRect, Tex.ArrowLeft))
                {
                    SoundDefOf.Tick_Tiny.PlayOneShotOnCamera();
                    curRank--;
                }
            }

            //Right Arrow
            Rect rightButtonRect = rect.RightPartPixels(TopAreaHeight.rankHeight);

            if (curRank == count)
            {
                if (Widgets.ButtonImage(rightButtonRect, Tex.Plus))
                {
                    SoundDefOf.Click.PlayOneShotOnCamera();
                    comp.AddFilter(settings);
                    curRank++;
                }
            }
            else
            {
                if (Widgets.ButtonImage(rightButtonRect, Tex.ArrowRight))
                {
                    SoundDefOf.Tick_Tiny.PlayOneShotOnCamera();
                    curRank++;
                }
            }

            //Delete rank button
            rightButtonRect.x -= buttonMargin;
            if (curRank > 0)
            {
                if (Widgets.ButtonImage(rightButtonRect, Tex.DeleteX))
                {
                    SoundDefOf.Crunch.PlayOneShotOnCamera();
                    comp.RemoveFilter(settings, curRank--);
                }
            }

            //Label
            rect.x     += buttonMargin;
            rect.width -= buttonMargin * 3;
            Text.Font   = GameFont.Small;
            if (count == 0)
            {
                Widgets.Label(rect, "TD.AddFilter".Translate());
            }
            else
            {
                Widgets.Label(rect, "TD.RankNum".Translate(curRank + 1));
            }
        }
コード例 #4
0
 //private void TryNotifyChanged()
 public static void Prefix(StorageSettings __instance)
 {
     RankComp.Get()?.CascadeDown(__instance);
 }