Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions ControlPad/DataHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,31 @@ public static void LoadCategoryControls(string path)
{
string[] lines = File.ReadAllLines(path);

for (int i = 0; i < SliderValues.Count; i++)
for (int i = 0; i < SliderValues.Count && i < lines.Length; i++)
{
if (int.TryParse(lines[i].Split(':')[1].Trim(), out int sliderCategoryId))
var parts = lines[i].Split(':');
if (parts.Length >= 2 && int.TryParse(parts[1].Trim(), out int sliderCategoryId))
{
var category = SliderCategories.FirstOrDefault(c => c.Id == sliderCategoryId);
SliderValues[i].slider.Category = category;
}
else
{
SliderValues[i].slider.Category = null;
}
}
for (int i = 0; i < ButtonValues.Count; i++)
for (int i = 0; i < ButtonValues.Count && (i + SliderValues.Count) < lines.Length; i++)
{
if (int.TryParse(lines[i + SliderValues.Count].Split(':')[1].Trim(), out int buttonCategoryId))
var parts = lines[i + SliderValues.Count].Split(':');
if (parts.Length >= 2 && int.TryParse(parts[1].Trim(), out int buttonCategoryId))
{
var category = ButtonValues[i].button.Category = ButtonCategories.FirstOrDefault(c => c.Id == buttonCategoryId);
var category = ButtonCategories.FirstOrDefault(c => c.Id == buttonCategoryId);
ButtonValues[i].button.Category = category;
}
else
{
ButtonValues[i].button.Category = null;
}
}
}
}
Expand Down
Loading