mirror of
https://github.com/n00mkrad/flowframes.git
synced 2025-12-23 03:39:26 +01:00
string -> Fraction parsing now has error handling avoiding some problems
This commit is contained in:
@@ -49,11 +49,29 @@ namespace Flowframes.Data
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Fraction(string text)
|
public Fraction(string text)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
string[] numbers = text.Split('/');
|
string[] numbers = text.Split('/');
|
||||||
Numerator = numbers[0].GetInt();
|
Numerator = numbers[0].GetInt();
|
||||||
Denominator = numbers[1].GetInt();
|
Denominator = numbers[1].GetInt();
|
||||||
}
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Numerator = text.GetFloat().RoundToInt();
|
||||||
|
Denominator = 1;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
Numerator = 0;
|
||||||
|
Denominator = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger.Log($"Fraction from String: Fraction(\"{text}\") => {Numerator}/{Denominator}", true);
|
||||||
|
}
|
||||||
|
|
||||||
private static int getGCD(int a, int b)
|
private static int getGCD(int a, int b)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -95,6 +95,8 @@ namespace Flowframes.Main
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static bool InputIsValid(string inDir, string outDir, Fraction fpsOut, float factor, I.OutMode outMode)
|
public static bool InputIsValid(string inDir, string outDir, Fraction fpsOut, float factor, I.OutMode outMode)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
bool passes = true;
|
bool passes = true;
|
||||||
|
|
||||||
@@ -128,6 +130,12 @@ namespace Flowframes.Main
|
|||||||
|
|
||||||
return passes;
|
return passes;
|
||||||
}
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
Logger.Log($"Failed to run InputIsValid: {e.Message}\n{e.StackTrace}", true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static bool CheckAiAvailable(AI ai)
|
public static bool CheckAiAvailable(AI ai)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user