Exemplo n.º 1
0
        public string EchoInputValues(IFieldContext context, bool boolVal, int intVal, float floatVal, string strVal,
                                      ThingKind kindVal)
        {
            var result = string.Join("|", new object[] { boolVal, intVal, floatVal, strVal, kindVal });

            return(result);
        }
Exemplo n.º 2
0
        public override void Randomize()
        {
            base.Randomize();
            thingKind = Extensions.GetEnumValues <ThingKind>().RandomElement();
            thing     = GetThings().RandomElement();
            stuff     = GetStuffsForThing().RandomElement();
            amount    = new IntRange(Rand.RangeInclusive(1, 100), Rand.RangeInclusive(1, 100));
            equip     = Rand.Bool;

            if (amount.max > thing.stackLimit)
            {
                amount.max = thing.stackLimit;
            }

            if (amount.min > amount.max)
            {
                amount.min = amount.max;
            }
        }
Exemplo n.º 3
0
        public static string Translate(this ThingKind thing)
        {
            switch (thing)
            {
            case ThingKind.Weapon:
                return(R.String.MSP_ThingKind_Weapon.CapitalizeFirst());

            case ThingKind.Aparrel:
                return(R.String.MSP_ThingKind_Aparrel.CapitalizeFirst());

            case ThingKind.Building:
                return(R.String.MSP_ThingKind_Building.CapitalizeFirst());

            case ThingKind.Items:
                return(R.String.MSP_ThingKind_Items.CapitalizeFirst());

            default:
                return(R.String.MSP_Undefined.CapitalizeFirst());
            }
        }
Exemplo n.º 4
0
 public Thing(String id, ThingKind kind, object thing)
 {
     ID    = id;
     Kind  = kind;
     Value = thing;
 }
Exemplo n.º 5
0
        public override void DoEditInterface(Listing_ScenEdit listing)
        {
            Rect rect = listing.GetScenPartRect(this, RowHeight * 8 + 31f);

            Rect[] a    = rect.SplitRows(5, 4);
            Rect[] rows = a[0].SplitRows(RowHeight, RowHeight, RowHeight, 31f, RowHeight);

            Rect[] r_kind   = rows[0].SplitCols(1, 2);
            Rect[] r_thing  = rows[1].SplitCols(1, 2);
            Rect[] r_stuff  = rows[2].SplitCols(1, 2);
            Rect[] r_amount = rows[3].SplitCols(1, 2);
            Rect   r_equip  = rows[4];

            // Text.Anchor = TextAnchor.MiddleRight;
            Widgets.Label(r_kind[0], R.String.MSP_ThingKind.CapitalizeFirst());
            // Text.Anchor = TextAnchor.UpperLeft;
            if (Widgets.ButtonText(r_kind[1], thingKind.Translate()))
            {
                FloatMenuUtility.MakeMenu(Extensions.GetEnumValues <ThingKind>(), Extensions.Translate, (k) => () =>
                {
                    thingKind = k;
                    thing     = GetThings().RandomElement();
                    if (thing.MadeFromStuff)
                    {
                        stuff = GetStuffsForThing().RandomElement();
                    }
                });
            }

            // Text.Anchor = TextAnchor.MiddleRight;
            Widgets.Label(r_thing[0], R.String.MSP_Thing.CapitalizeFirst());
            // Text.Anchor = TextAnchor.UpperLeft;
            if (Widgets.ButtonText(r_thing[1], thing.LabelCap))
            {
                FloatMenuUtility.MakeMenu(GetThings(), (t) => t.LabelCap, (t) => () =>
                {
                    thing = t;
                    if (t.MadeFromStuff)
                    {
                        stuff = GenStuff.DefaultStuffFor(thing);
                    }
                    else
                    {
                        stuff = null;
                    }
                });
            }

            // Text.Anchor = TextAnchor.MiddleRight;
            Widgets.Label(r_stuff[0], R.String.MSP_Stuff.CapitalizeFirst());
            // Text.Anchor = TextAnchor.UpperLeft;
            if (thing.MadeFromStuff && Widgets.ButtonText(r_stuff[1], stuff.LabelCap))
            {
                FloatMenuUtility.MakeMenu(GetStuffsForThing(), (s) => s.LabelCap, (s) => () =>
                {
                    stuff = s;
                });
            }

            if (amount.max > thing.stackLimit)
            {
                amount.max = thing.stackLimit;
            }

            if (amount.min > amount.max)
            {
                amount.min = amount.max;
            }

            if (amount.min != 1 && amount.max != 1)
            {
                equip = false;
            }

            // Text.Anchor = TextAnchor.MiddleRight;
            Widgets.Label(r_amount[0], R.String.MSP_Amount.CapitalizeFirst());
            // Text.Anchor = TextAnchor.UpperLeft;

            if (thing.stackLimit == 1)
            {
                // Text.Anchor = TextAnchor.MiddleCenter;
                Widgets.Label(r_amount[1], thing.stackLimit.ToStringCached());
                // Text.Anchor = TextAnchor.UpperLeft;
            }
            else
            {
                Widgets.IntRange(r_amount[1], listing.CurHeight.GetHashCode(), ref amount, 1, thing.stackLimit);
            }

            if (thingKind == ThingKind.Aparrel || thingKind == ThingKind.Weapon)
            {
                bool oldValue = equip;
                Widgets.CheckboxLabeled(r_equip, R.String.MSP_Equip.CapitalizeFirst(), ref equip);
                if (!oldValue && equip)
                {
                    amount.min = amount.max = 1;
                }
            }

            DoContextEditInterface(a[1]);
        }