mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 10:37:37 +02:00
fix doubled input responses in some menus
decimal marker weights
This commit is contained in:
@ -11,7 +11,7 @@ using TMPro;
|
||||
|
||||
public class SectionDialog : Dialog
|
||||
{
|
||||
const float MIN_WEIGHT = 0, MAX_WEIGHT = 10;
|
||||
const float MIN_WEIGHT = 0, MAX_WEIGHT = 10, WEIGHT_INTERVAL = 0.1f;
|
||||
SectionTimelineObj sectionObj;
|
||||
[SerializeField] TMP_InputField sectionName;
|
||||
[SerializeField] Toggle challengeEnable;
|
||||
@ -40,7 +40,7 @@ public class SectionDialog : Dialog
|
||||
|
||||
markerWeight.maxValue = MAX_WEIGHT;
|
||||
markerWeight.minValue = MIN_WEIGHT;
|
||||
markerWeight.wholeNumbers = true;
|
||||
markerWeight.wholeNumbers = false;
|
||||
|
||||
if (!initHooks)
|
||||
{
|
||||
@ -68,7 +68,7 @@ public class SectionDialog : Dialog
|
||||
|
||||
markerWeight.maxValue = MAX_WEIGHT;
|
||||
markerWeight.minValue = MIN_WEIGHT;
|
||||
markerWeight.wholeNumbers = true;
|
||||
markerWeight.wholeNumbers = false;
|
||||
|
||||
UpdateCatButtonState();
|
||||
}
|
||||
@ -103,16 +103,23 @@ public class SectionDialog : Dialog
|
||||
public void SetSectionWeight()
|
||||
{
|
||||
if (sectionObj == null) return;
|
||||
sectionObj.chartEntity["weight"] = markerWeight.value;
|
||||
markerWeightManual.text = ((float) sectionObj.chartEntity["weight"]).ToString("G");
|
||||
sectionObj.chartEntity["weight"] = RoundNearest(markerWeight.value, WEIGHT_INTERVAL);
|
||||
markerWeight.value = sectionObj.chartEntity["weight"];
|
||||
markerWeightManual.text = ((float) sectionObj.chartEntity["weight"]).ToString("0.0");
|
||||
}
|
||||
|
||||
public void SetSectionWeightManual()
|
||||
{
|
||||
if (sectionObj == null) return;
|
||||
sectionObj.chartEntity["weight"] = Mathf.Round((float)Math.Clamp(Convert.ToSingle(markerWeightManual.text), MIN_WEIGHT, MAX_WEIGHT));
|
||||
sectionObj.chartEntity["weight"] = RoundNearest((float)Math.Clamp(Convert.ToSingle(markerWeightManual.text), MIN_WEIGHT, MAX_WEIGHT), WEIGHT_INTERVAL);
|
||||
markerWeight.value = sectionObj.chartEntity["weight"];
|
||||
markerWeightManual.text = ((float) sectionObj.chartEntity["weight"]).ToString("G");
|
||||
markerWeightManual.text = ((float) sectionObj.chartEntity["weight"]).ToString("0.0");
|
||||
}
|
||||
|
||||
float RoundNearest(float a, float interval)
|
||||
{
|
||||
int root = Mathf.RoundToInt(a / interval);
|
||||
return root * interval;
|
||||
}
|
||||
|
||||
void UpdateCatButtonState()
|
||||
|
Reference in New Issue
Block a user