Skip to content

Commit

Permalink
Implement Line Awesome as an icon font
Browse files Browse the repository at this point in the history
  • Loading branch information
ExplosBlue committed Nov 7, 2023
1 parent fea625c commit fb41e82
Show file tree
Hide file tree
Showing 8 changed files with 1,469 additions and 7 deletions.
3 changes: 2 additions & 1 deletion Fushigi.Byml/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

## Credit
This byml library (code and structure) is taken from the [BymlView](https://github.com/shadowninja108/BymlView/tree/master/BymlView/Backend/Blitz/Lp/Byml) repository,
with a few minor adjustments (mostly to make it more independent) and fixes.
with a few minor adjustments (mostly to make it more independent) and fixes.
Line Awesome icon font provided by [icons8](https://icons8.com/line-awesome)
9 changes: 9 additions & 0 deletions Fushigi/Fushigi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@
<None Update="res\imgui.ini">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="res\la-brands-400.ttf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="res\la-regular-400.ttf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="res\la-solid-900.ttf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Binary file added Fushigi/res/la-brands-400.ttf
Binary file not shown.
Binary file added Fushigi/res/la-regular-400.ttf
Binary file not shown.
Binary file added Fushigi/res/la-solid-900.ttf
Binary file not shown.
31 changes: 29 additions & 2 deletions Fushigi/ui/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@
using ImGuiNET;
using System.Runtime.CompilerServices;
using System.Numerics;
using System.Collections.Generic;
using System.Runtime.InteropServices;

namespace Fushigi.ui
{
public class MainWindow
{

private ImFontPtr mDefaultFont;
private ImFontPtr mIconFont;

public MainWindow()
{
Expand All @@ -30,13 +33,37 @@ public MainWindow()
nativeConfig->OversampleV = 8;
nativeConfig->RasterizerMultiply = 1f;
nativeConfig->GlyphOffset = new Vector2(0);

{
mDefaultFont = io.Fonts.AddFontFromFileTTF(
Path.Combine("res", "Font.ttf"),
16, nativeConfig);
16, nativeConfig, io.Fonts.GetGlyphRangesJapanese());

//other fonts go here and follow the same schema

nativeConfig->MergeMode = 1;

GCHandle rangeHandle = GCHandle.Alloc(new ushort[] { IconUtil.MIN_GLYPH_RANGE, IconUtil.MAX_GLYPH_RANGE, 0 }, GCHandleType.Pinned);
try
{
io.Fonts.AddFontFromFileTTF(
Path.Combine("res", "la-regular-400.ttf"),
16, nativeConfig, rangeHandle.AddrOfPinnedObject());

io.Fonts.AddFontFromFileTTF(
Path.Combine("res", "la-solid-900.ttf"),
16, nativeConfig, rangeHandle.AddrOfPinnedObject());

io.Fonts.AddFontFromFileTTF(
Path.Combine("res", "la-brands-400.ttf"),
16, nativeConfig, rangeHandle.AddrOfPinnedObject());

io.Fonts.Build();
}
finally
{
if (rangeHandle.IsAllocated)
rangeHandle.Free();
}
}
}
});
Expand Down
23 changes: 19 additions & 4 deletions Fushigi/ui/widgets/CourseScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Fushigi.course;
using Fushigi.param;
using Fushigi.rstb;
using Fushigi.util;
using ImGuiNET;
using Newtonsoft.Json.Linq;
using Silk.NET.Input;
Expand All @@ -17,6 +18,7 @@
using System.Text;
using System.Text.RegularExpressions;
using System.Xml.Linq;
using static System.Net.Mime.MediaTypeNames;

namespace Fushigi.ui.widgets
{
Expand Down Expand Up @@ -63,7 +65,7 @@ public void DrawUI(GL gl)
{
ActorsPanel();

ActorParameterPanel();
SelectionParameterPanel();

RailsPanel();

Expand Down Expand Up @@ -285,9 +287,9 @@ private void RailsPanel()
ImGui.End();
}

private void ActorParameterPanel()
private void SelectionParameterPanel()
{
bool status = ImGui.Begin("Actor Parameters", ImGuiWindowFlags.AlwaysVerticalScrollbar);
bool status = ImGui.Begin("Selection Parameters", ImGuiWindowFlags.AlwaysVerticalScrollbar);

if (mSelectedActor != null)
{
Expand Down Expand Up @@ -413,7 +415,20 @@ private void ActorParameterPanel()
else
{
ImGui.AlignTextToFramePadding();
ImGui.Text("No actor or rail is selected");

string text = "No item selected";

var windowWidth = ImGui.GetWindowSize().X;
var textWidth = ImGui.CalcTextSize(text).X;

var windowHight = ImGui.GetWindowSize().Y;
var textHeight = ImGui.CalcTextSize(text).Y;

ImGui.SetCursorPosX((windowWidth - textWidth) * 0.5f);
ImGui.SetCursorPosY((windowHight - textHeight) * 0.5f);
ImGui.BeginDisabled();
ImGui.Text(text);
ImGui.EndDisabled();
}

if (status)
Expand Down
Loading

0 comments on commit fb41e82

Please sign in to comment.