-
Notifications
You must be signed in to change notification settings - Fork 0
/
SGBFontBridgeService.cs
70 lines (57 loc) · 1.9 KB
/
SGBFontBridgeService.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using UnityEngine;
using Naninovel;
namespace BobboNet.SGB.IMod.Naninovel
{
/// <summary>
/// This service connects custom fonts with SGB IMod.
/// </summary>
[InitializeAtRuntime]
public class SGBFontBridgeService : IEngineService
{
private Font defaultFont;
//
// Constructors
//
public SGBFontBridgeService() { defaultFont = SGBFontManager.CurrentFont; }
//
// Interface Methods
//
public UniTask InitializeServiceAsync()
{
// Initialize the service here.
return UniTask.CompletedTask;
}
public void ResetService()
{
// Reset service state here.
}
public void DestroyService()
{
// Stop the service and release any used resources here.
}
//
// Public Methods
//
public Font GetDefaultFont() => defaultFont;
public Font GetFont() => SGBFontManager.CurrentFont;
public void SetFont(Font newFont) => SGBFontManager.CurrentFont = newFont;
/// <summary>
/// Try to get a font target for a given SGB project.
/// </summary>
/// <param name="projectName">The name / subpath of the SGB project to find a font for.</param>
/// <param name="foundTarget">The found font target, if there was any/</param>
/// <returns>True if a target was found, false otherwise.</returns>
public bool TryGetFontTarget(string projectName, out SGBFontTarget foundTarget)
{
var config = Engine.GetConfiguration<SGBIModConfiguration>();
foreach (var target in config.fontTargets)
{
if (target.projectName != projectName) continue;
foundTarget = target;
return true;
}
foundTarget = null;
return false;
}
}
}