Ejemplo n.º 1
0
		public override void DoWindowContents(Rect inRect)
		{
			Text.Font = GameFont.Small;
			Rect rect;
			Rect outRect = rect = inRect.ContractedBy(4f);
			rect.xMax -= 33f;
			Rect rect2 = new Rect(0f, 0f, CategoryWidth, Text.CalcHeight("test", 1000f));
			Rect rect3 = new Rect(rect2.xMax, 0f, TitleWidth, rect2.height);
			Rect rect4 = new Rect(rect3.xMax, 0f, NumberWidth, rect2.height);
			Rect rect5 = new Rect(rect4.xMax, 0f, rect.width - rect4.xMax, rect2.height);
			Widgets.BeginScrollView(outRect, ref scrollPosition, new Rect(0f, 0f, rect.width, rect2.height * (float)tweakValueFields.Count));
			foreach (TweakInfo tweakValueField in tweakValueFields)
			{
				Widgets.Label(rect2, tweakValueField.tweakValue.category);
				Widgets.Label(rect3, $"{tweakValueField.field.DeclaringType.Name}.{tweakValueField.field.Name}");
				float num;
				bool flag;
				if (tweakValueField.field.FieldType == typeof(float) || tweakValueField.field.FieldType == typeof(int) || tweakValueField.field.FieldType == typeof(ushort))
				{
					float asFloat = GetAsFloat(tweakValueField.field);
					num = Widgets.HorizontalSlider(rect5, GetAsFloat(tweakValueField.field), tweakValueField.tweakValue.min, tweakValueField.tweakValue.max);
					SetFromFloat(tweakValueField.field, num);
					flag = (asFloat != num);
				}
				else if (tweakValueField.field.FieldType == typeof(bool))
				{
					bool num2 = (bool)tweakValueField.field.GetValue(null);
					bool checkOn = num2;
					Widgets.Checkbox(rect5.xMin, rect5.yMin, ref checkOn);
					tweakValueField.field.SetValue(null, checkOn);
					num = (checkOn ? 1 : 0);
					flag = (num2 != checkOn);
				}
				else
				{
					Log.ErrorOnce($"Attempted to tweakvalue unknown field type {tweakValueField.field.FieldType}", 83944645);
					flag = false;
					num = tweakValueField.initial;
				}
				if (num != tweakValueField.initial)
				{
					GUI.color = Color.red;
					Widgets.Label(rect4, $"{tweakValueField.initial} -> {num}");
					GUI.color = Color.white;
					if (Widgets.ButtonInvisible(rect4))
					{
						flag = true;
						if (tweakValueField.field.FieldType == typeof(float) || tweakValueField.field.FieldType == typeof(int) || tweakValueField.field.FieldType == typeof(ushort))
						{
							SetFromFloat(tweakValueField.field, tweakValueField.initial);
						}
						else if (tweakValueField.field.FieldType == typeof(bool))
						{
							tweakValueField.field.SetValue(null, tweakValueField.initial != 0f);
						}
						else
						{
							Log.ErrorOnce($"Attempted to tweakvalue unknown field type {tweakValueField.field.FieldType}", 83944646);
						}
					}
				}
				else
				{
					Widgets.Label(rect4, $"{tweakValueField.initial}");
				}
				if (flag)
				{
					MethodInfo method = tweakValueField.field.DeclaringType.GetMethod(tweakValueField.field.Name + "_Changed", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
					if (method != null)
					{
						method.Invoke(null, null);
					}
				}
				rect2.y += rect2.height;
				rect3.y += rect2.height;
				rect4.y += rect2.height;
				rect5.y += rect2.height;
			}
			Widgets.EndScrollView();
		}