Skip to content

Commit

Permalink
runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
Akarinnnnn committed Mar 1, 2021
1 parent c37ba90 commit 57ddf5e
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 5 deletions.
39 changes: 39 additions & 0 deletions UniGal.Compiler.Frontend/Response/rtenv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,45 @@ internal class rtenv
}
return ret;
}

internal static EnvironmentInfo.Display on_display(XmlReader r, List<CompilerError> errors)
{
uint w = 1920;
uint h = 1080;
bool fullscr = true;

while (r.Read())
{
if(r.NodeType == XmlNodeType.Element)
{
switch (r.Name)
{
case "resolution":
string res = r.Value;
var xPos = res.IndexOf('x');
try
{
w = uint.Parse(res.AsSpan()[0..xPos]);
h = uint.Parse(res.AsSpan()[xPos..]);
}
catch (FormatException) { continue; }
catch (OverflowException) { continue; }
break;
case "fullscreen":
string strRepersent = r.Value;
if (bool.TryParse(strRepersent, out fullscr))
continue;
else
fullscr = true;
break;
default:
break;
}
}
}

return new(w, h, fullscr);
}
}
}
}
10 changes: 5 additions & 5 deletions UniGal.Compiler.Frontend/Response/toplevel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,8 @@ internal static Metadata on_metadata(XmlReader r, List<CompilerError> errors)

internal static EnvironmentInfo on_rtenv(XmlReader r, List<CompilerError> errors)
{
uint w = 0;
uint h = 0;
bool fullscr=true;
List<EnvironmentInfo.RedistPackage> redists = new(4);

EnvironmentInfo.Display dispProp = new();
while (r.Read() && r.NodeType != XmlNodeType.EndElement)
{

Expand All @@ -45,6 +42,9 @@ internal static EnvironmentInfo on_rtenv(XmlReader r, List<CompilerError> errors
case "redists":
redists = rtenv.on_redist(r, errors);
break;
case "display":
dispProp = rtenv.on_display(r, errors);
break;
default:
break;
}
Expand All @@ -54,7 +54,7 @@ internal static EnvironmentInfo on_rtenv(XmlReader r, List<CompilerError> errors
}
}

EnvironmentInfo ret = new(w, h, fullscr, redists);
EnvironmentInfo ret = new(dispProp, redists);
return ret;
}

Expand Down

0 comments on commit 57ddf5e

Please sign in to comment.