mirror of
https://github.com/amevarashi/RJW-Sexperience.git
synced 2024-08-14 23:54:08 +00:00
Rename source folder
This commit is contained in:
parent
0a412a0060
commit
a4c046a841
55 changed files with 0 additions and 0 deletions
36
Source/RJWSexperience/Settings/SettingsWidgets.cs
Normal file
36
Source/RJWSexperience/Settings/SettingsWidgets.cs
Normal file
|
@ -0,0 +1,36 @@
|
|||
using UnityEngine;
|
||||
using Verse;
|
||||
|
||||
namespace RJWSexperience.Settings
|
||||
{
|
||||
public static class SettingsWidgets
|
||||
{
|
||||
public const float lineHeight = 24f;
|
||||
|
||||
public static void LabelwithTextfield(Rect rect, string label, string tooltip, ref float value, float min, float max)
|
||||
{
|
||||
Rect textfieldRect = new Rect(rect.xMax - 100f, rect.y, 100f, rect.height);
|
||||
string valuestr = value.ToString();
|
||||
Widgets.Label(rect, label);
|
||||
Widgets.TextFieldNumeric(textfieldRect, ref value, ref valuestr, min, max);
|
||||
Widgets.DrawHighlightIfMouseover(rect);
|
||||
TooltipHandler.TipRegion(rect, tooltip);
|
||||
}
|
||||
|
||||
public static void SliderOption(Rect doublerect, string label, string tooltip, ref float value, float min, float max, float roundTo)
|
||||
{
|
||||
// Slider was fighting with textfield for "correct" decimals. Causes a repeating slider move sound
|
||||
float fieldValue = value;
|
||||
float sliderValue = value;
|
||||
float minChange = roundTo / 10f;
|
||||
|
||||
LabelwithTextfield(doublerect.TopHalf(), label, tooltip, ref fieldValue, min, max);
|
||||
sliderValue = Widgets.HorizontalSlider(doublerect.BottomHalf(), sliderValue, min, max, roundTo: roundTo);
|
||||
|
||||
if (Mathf.Abs(fieldValue - value) > minChange)
|
||||
value = fieldValue;
|
||||
else
|
||||
value = sliderValue;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue