Font menu should auto start at currently selected font

This commit is contained in:
UnknownShadow200 2018-07-23 22:28:08 +10:00
parent 28d1d81821
commit 5e8c1900fc
4 changed files with 26 additions and 19 deletions

View file

@ -9,17 +9,24 @@ namespace ClassicalSharp.Gui.Screens {
public FontListScreen(Game game) : base(game) {
titleText = "Select a font";
FontFamily[] families = FontFamily.Families;
entries = new string[families.Length + 3];
entries = new string[families.Length];
for (int i = 0; i < families.Length; i++) {
entries[i + 3] = families[i].Name;
entries[i] = families[i].Name;
families[i].Dispose();
}
Array.Sort(entries);
}
public override void Init() {
base.Init();
string font = game.FontName;
entries[0] = FontFamily.GenericMonospace.Name;
entries[1] = FontFamily.GenericSansSerif.Name;
entries[2] = FontFamily.GenericSerif.Name;
for (int i = 0; i < entries.Length; i++) {
if (!Utils.CaselessEq(font, entries[i])) continue;
SetCurrentIndex(i);
return;
}
}
protected override void TextButtonClick(Game game, Widget widget) {

View file

@ -17,8 +17,8 @@ namespace OpenTK.Platform.Windows {
const int SM_CXSCREEN = 0, SM_CYSCREEN = 1, BITSPIXEL = 12;
DisplayDevice device = new DisplayDevice();
device.Bounds.Width = API.GetSystemMetrics(0);
device.Bounds.Height = API.GetSystemMetrics(1);
device.Bounds.Width = API.GetSystemMetrics(SM_CXSCREEN);
device.Bounds.Height = API.GetSystemMetrics(SM_CYSCREEN);
device.BitsPerPixel = API.GetDeviceCaps(dc, BITSPIXEL);
DisplayDevice.Default = device;

View file

@ -294,8 +294,8 @@
<ClCompile Include="BlockPhysics.c" />
<ClCompile Include="PickedPosRenderer.c" />
<ClCompile Include="Picking.c" />
<ClCompile Include="X11ErrorHandler.c" />
<ClCompile Include="X11Platform.c" />
<ClCompile Include="NixErrorHandler.c" />
<ClCompile Include="NixPlatform.c" />
<ClCompile Include="Program.c" />
<ClCompile Include="Random.c" />
<ClCompile Include="Screens.c" />
@ -314,7 +314,7 @@
<ClCompile Include="WinPlatform.c" />
<ClCompile Include="WinWindow.c" />
<ClCompile Include="World.c" />
<ClCompile Include="X11Window.c" />
<ClCompile Include="NixWindow.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View file

@ -527,20 +527,20 @@
<ClCompile Include="DisplayDevice.c">
<Filter>Source Files\Platform</Filter>
</ClCompile>
<ClCompile Include="X11Window.c">
<Filter>Source Files\Platform</Filter>
</ClCompile>
<ClCompile Include="Socket.c">
<Filter>Source Files\Platform</Filter>
</ClCompile>
<ClCompile Include="X11Platform.c">
<Filter>Source Files\Platform</Filter>
</ClCompile>
<ClCompile Include="X11ErrorHandler.c">
<Filter>Source Files\Platform</Filter>
</ClCompile>
<ClCompile Include="EnvRenderer.c">
<Filter>Source Files\Rendering</Filter>
</ClCompile>
<ClCompile Include="NixErrorHandler.c">
<Filter>Source Files\Platform</Filter>
</ClCompile>
<ClCompile Include="NixWindow.c">
<Filter>Source Files\Platform</Filter>
</ClCompile>
<ClCompile Include="NixPlatform.c">
<Filter>Source Files\Platform</Filter>
</ClCompile>
</ItemGroup>
</Project>