Skip to content

Commit 432708f

Browse files
committed
Added Roboto font with a range of font sizes
Added menu bar Added settings and about windows
1 parent 296bbfa commit 432708f

File tree

9 files changed

+155
-6
lines changed

9 files changed

+155
-6
lines changed

ERPLoader/Settings.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ public class Settings
2020

2121
public bool LaunchGame { get; set; }
2222

23+
public class ExplorerSettingsTemplate
24+
{
25+
public int FontSize { get; set; }
26+
}
27+
public ExplorerSettingsTemplate ExplorerSettings { get; set; }
28+
2329
public Settings()
2430
{
2531
Instance = this;
@@ -30,6 +36,10 @@ public Settings()
3036
DisabledModsEndsWith = "_DISABLED";
3137
FindReplaceFileName = "FindReplace.json";
3238
LaunchGame = true;
39+
ExplorerSettings = new()
40+
{
41+
FontSize = 4
42+
};
3343
}
3444

3545
public static void InitSettings()
@@ -77,7 +87,7 @@ public bool Verify(bool checkGameExeExists = true)
7787
.Where(p => p.PropertyType == typeof(string))
7888
.Select(p => (string)p.GetValue(this))
7989
.Any(v => string.IsNullOrWhiteSpace(v));
80-
90+
8191
if (ContainEmptyValue)
8292
{
8393
Logger.Error("Found empty value(s) in settings.json file. Please fix them or delete the file");

EasyERPExplorer/EasyERPExplorer.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
2222
<PlatformTarget>x64</PlatformTarget>
23+
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
2324
</PropertyGroup>
2425

2526
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
159 KB
Binary file not shown.

EasyERPExplorer/Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ static void Main()
2121
{
2222
GameFolderExplorer gameFolderExplorer = new();
2323
ModsExplorer modsExplorer = new();
24+
InfoWindow infoWindow = new();
2425

2526
Window.DrawWindows.Add(gameFolderExplorer);
2627
Window.DrawWindows.Add(modsExplorer);
28+
Window.DrawWindows.Add(infoWindow);
2729

2830
Window wnd = new();
2931
wnd.Run();

EasyERPExplorer/Renderer/ImGuiController.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using ImGuiNET;
1+
using ERPLoader;
2+
using ImGuiNET;
23
using OpenTK.Graphics.OpenGL4;
34
using OpenTK.Mathematics;
45
using OpenTK.Windowing.Desktop;
@@ -31,6 +32,8 @@ public class ImGuiController : IDisposable
3132

3233
private System.Numerics.Vector2 _scaleFactor = System.Numerics.Vector2.One;
3334

35+
public static readonly List<ImFontPtr> Fonts = new();
36+
3437
/// <summary>
3538
/// Constructs a new ImGuiController.
3639
/// </summary>
@@ -42,7 +45,12 @@ public ImGuiController(int width, int height)
4245
IntPtr context = ImGui.CreateContext();
4346
ImGui.SetCurrentContext(context);
4447
var io = ImGui.GetIO();
45-
io.Fonts.AddFontDefault();
48+
//io.Fonts.AddFontDefault();
49+
50+
for (short i = 12; i < 25; i++)
51+
Fonts.Add(io.Fonts.AddFontFromFileTTF("Fonts\\Roboto-Medium.ttf", i));
52+
Settings.Instance.ExplorerSettings.FontSize = 4;
53+
io.Fonts.Build();
4654

4755
io.BackendFlags |= ImGuiBackendFlags.RendererHasVtxOffset;
4856

EasyERPExplorer/Renderer/Window.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using OpenTK.Graphics.OpenGL4;
1+
using ImGuiNET;
2+
using OpenTK.Graphics.OpenGL4;
23
using OpenTK.Mathematics;
34
using OpenTK.Windowing.Common;
45
using OpenTK.Windowing.Desktop;
@@ -61,10 +62,12 @@ protected override void OnRenderFrame(FrameEventArgs e)
6162

6263
DrawWindows.Where(w => !w.IsOpen).ToList().ForEach(w => DrawWindows.Remove(w));
6364

65+
ImGui.PushFont(ImGuiController.Fonts[ERPLoader.Settings.Instance.ExplorerSettings.FontSize]);
6466
foreach (var window in DrawWindows.ToArray())
6567
{
6668
window.Draw();
6769
}
70+
ImGui.PopFont();
6871

6972
_controller.Render();
7073

EasyERPExplorer/Windows/GameFolderExplorer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public GameFolderExplorer()
2424

2525
public override void Draw()
2626
{
27-
ImGui.SetNextWindowPos(Padding);
27+
ImGui.SetNextWindowPos(new Vector2(Padding.X, Padding.Y + 20));
2828
ImGui.SetNextWindowSize(new Vector2(Window.Instance.ClientSize.X / 2f - Padding.X * 1.5f, Window.Instance.ClientSize.Y - Padding.Y * 2));
2929

3030
if (ImGui.Begin("Game Directory Explorer", ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoBringToFrontOnFocus))
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
using EasyERPExplorer.Renderer;
2+
using ERPLoader;
3+
using ImGuiNET;
4+
using System.Diagnostics;
5+
6+
namespace EasyERPExplorer.Windows
7+
{
8+
class InfoWindow : ImGuiDrawWindow
9+
{
10+
private bool ShowSettingsWindow = false;
11+
private bool ShowLicenseWindow = false;
12+
private bool ShowAuthorWindow = false;
13+
private bool ShowAppInfoWindow = false;
14+
15+
public override void Draw()
16+
{
17+
if (ImGui.BeginMainMenuBar())
18+
{
19+
if (ImGui.BeginMenu("Settings"))
20+
{
21+
ImGui.MenuItem("View/Edit", null, ref ShowSettingsWindow);
22+
ImGui.EndMenu();
23+
}
24+
25+
if (ImGui.BeginMenu("About"))
26+
{
27+
ImGui.MenuItem("License", null, ref ShowLicenseWindow);
28+
ImGui.MenuItem("Author", null, ref ShowAuthorWindow);
29+
ImGui.MenuItem("EasyERPMod", null, ref ShowAppInfoWindow);
30+
ImGui.EndMenu();
31+
}
32+
33+
ImGui.EndMainMenuBar();
34+
}
35+
36+
if (ShowSettingsWindow && ImGui.Begin("Settings", ImGuiWindowFlags.AlwaysAutoResize))
37+
{
38+
if (ImGui.Button("Save"))
39+
{
40+
Settings.Instance.SaveSettings();
41+
}
42+
ImGui.SameLine();
43+
if (ImGui.Button("Close"))
44+
{
45+
ShowSettingsWindow = false;
46+
}
47+
ImGui.Separator();
48+
49+
if (ImGui.BeginCombo("Font size", $"{Settings.Instance.ExplorerSettings.FontSize + 12}px"))
50+
{
51+
for (short i = 0; i < ImGuiController.Fonts.Count; i++)
52+
{
53+
if (ImGui.Selectable($"{i + 12}px"))
54+
{
55+
Settings.Instance.ExplorerSettings.FontSize = i;
56+
}
57+
}
58+
59+
ImGui.EndCombo();
60+
}
61+
62+
ImGui.End();
63+
}
64+
65+
if (ShowLicenseWindow && ImGui.Begin("License", ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoCollapse))
66+
{
67+
string license = @"Copyright (C) 2021 Duc Nguyen
68+
69+
This program is free software: you can redistribute it and/or modify
70+
it under the terms of the GNU General Public License as published by
71+
the Free Software Foundation, either version 3 of the License, or
72+
(at your option) any later version.
73+
74+
This program is distributed in the hope that it will be useful,
75+
but WITHOUT ANY WARRANTY; without even the implied warranty of
76+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
77+
GNU General Public License for more details.
78+
79+
You should have received a copy of the GNU General Public License
80+
along with this program. If not, see <https://www.gnu.org/licenses/>.";
81+
82+
ImGui.Text(license);
83+
if (ImGui.Button("Close"))
84+
{
85+
ShowLicenseWindow = false;
86+
}
87+
}
88+
89+
if (ShowAuthorWindow && ImGui.Begin("Author", ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoCollapse))
90+
{
91+
ImGui.Text("Hi, I'm Tom. A developer who cannot find a job then get too bored and create apps for fun."); ImGui.NewLine();
92+
ImGui.Text("For now, that's all :)");
93+
94+
ImGui.NewLine();
95+
if (ImGui.Button("Close"))
96+
{
97+
ShowAuthorWindow = false;
98+
}
99+
}
100+
101+
if (ShowAppInfoWindow && ImGui.Begin("EasyERPMod", ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoCollapse))
102+
{
103+
string version = System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString(3);
104+
ImGui.BulletText("EasyERPMod version " + version);
105+
ImGui.NewLine();
106+
ImGui.Text("The app is created to help simplify modding process for F1 games using Ego Engine Modding.");
107+
if (ImGui.Button("GitHub"))
108+
{
109+
Process.Start("https://github.com/ducng99/EasyERPMod");
110+
}
111+
ImGui.SameLine();
112+
if (ImGui.Button("RaceDepartment"))
113+
{
114+
Process.Start("https://www.racedepartment.com/downloads/easyerpmod-make-modding-easier.44824/");
115+
}
116+
117+
ImGui.Separator();
118+
if (ImGui.Button("Close"))
119+
{
120+
ShowAppInfoWindow = false;
121+
}
122+
}
123+
}
124+
}
125+
}

EasyERPExplorer/Windows/ModsExplorer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public ModsExplorer()
2424

2525
public override void Draw()
2626
{
27-
ImGui.SetNextWindowPos(new Vector2(Window.Instance.ClientSize.X / 2f + Padding.X * 0.5f, Padding.Y));
27+
ImGui.SetNextWindowPos(new Vector2(Window.Instance.ClientSize.X / 2f + Padding.X * 0.5f, Padding.Y + 20));
2828
ImGui.SetNextWindowSize(new Vector2(Window.Instance.ClientSize.X / 2f - Padding.X * 1.5f, Window.Instance.ClientSize.Y - Padding.Y * 2));
2929

3030
if (ImGui.Begin("Mods Explorer", ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoBringToFrontOnFocus))

0 commit comments

Comments
 (0)