Skip to content

Commit 5a8ba55

Browse files
committed
Allow scripts to change font size of config menu
If a new font or language causes the text of one of the config buttons to go outside of its border, you can now call ModSetConfigFontSize in init.txt to shrink the font. Onikakushi default is 18
1 parent 10492b0 commit 5a8ba55

File tree

6 files changed

+35
-1
lines changed

6 files changed

+35
-1
lines changed

Assets.Scripts.Core.Buriko/BurikoOperations.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ public enum BurikoOperations
134134
ModDrawCharacter,
135135
ModDrawCharacterWithFiltering,
136136
ModPlayVoiceLS,
137-
ModPlayMovie
137+
ModPlayMovie,
138+
ModSetConfigFontSize
138139
}
139140
}

Assets.Scripts.Core.Buriko/BurikoScriptFile.cs

+10
Original file line numberDiff line numberDiff line change
@@ -2149,6 +2149,8 @@ public BurikoVariable ExecuteOperation(BurikoOperations op)
21492149
return OperationMODPlayVoiceLS();
21502150
case BurikoOperations.ModPlayMovie:
21512151
return OperationMODPlayMovie();
2152+
case BurikoOperations.ModSetConfigFontSize:
2153+
return OperationMODSetConfigFontSize();
21522154
default:
21532155
ScriptError("Unhandled Operation : " + op);
21542156
return BurikoVariable.Null;
@@ -2493,5 +2495,13 @@ public BurikoVariable OperationMODPlayMovie()
24932495
gameSystem.ExecuteActions();
24942496
return BurikoVariable.Null;
24952497
}
2498+
2499+
private BurikoVariable OperationMODSetConfigFontSize()
2500+
{
2501+
SetOperationType("MODSetConfigFontSize");
2502+
int size = ReadVariable().IntValue();
2503+
GameSystem.Instance.ConfigMenuFontSize = size;
2504+
return BurikoVariable.Null;
2505+
}
24962506
}
24972507
}

Assets.Scripts.Core/GameSystem.cs

+2
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ public class GameSystem : MonoBehaviour
164164

165165
public float AspectRatio;
166166

167+
public float ConfigMenuFontSize = 0;
168+
167169
public static GameSystem Instance => _instance ?? (_instance = GameObject.Find("_GameSystem").GetComponent<GameSystem>());
168170

169171
public GameState GameState

Assets.Scripts.UI.Config/ConfigManager.cs

+7
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ private IEnumerator DoOpen(int offscreen)
5656
GameSystem.Instance.MainUIController.FadeOut(0.3f, isBlocking: false);
5757
GameSystem.Instance.SceneController.HideFace(0.3f);
5858
GameSystem.Instance.ExecuteActions();
59+
if (GameSystem.Instance.ConfigMenuFontSize > 0)
60+
{
61+
foreach (TextRefresher text in Panel.GetComponentsInChildren<TextRefresher>())
62+
{
63+
text.SetFontSize(GameSystem.Instance.ConfigMenuFontSize);
64+
}
65+
}
5966
}
6067

6168
public void Open(int screen, bool msgWindow)

BGICompiler.Compiler/OperationHandler.cs

+1
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ public void FillParamValues()
163163
paramLookup.Add("ModDrawCharacterWithFiltering", new OpType(BurikoOperations.ModDrawCharacterWithFiltering, "iisssiiibiiiiiiib"));
164164
paramLookup.Add("ModPlayVoiceLS", new OpType(BurikoOperations.ModPlayVoiceLS, "iisib"));
165165
paramLookup.Add("ModPlayMovie", new OpType(BurikoOperations.ModPlayMovie, "s"));
166+
paramLookup.Add("ModSetConfigFontSize", new OpType(BurikoOperations.ModSetConfigFontSize, "i"));
166167
}
167168

168169
public void ParamCheck(string op, BGIParameters param)

TextRefresher.cs

+13
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ private void UpdateText()
2323
if (textMesh != null)
2424
{
2525
textMesh.text = ((!language) ? Japanese : English);
26+
// Game places the main menu at y +2, which puts them a bit too high in their boxes.
27+
if (System.Math.Abs(textMesh.transform.localPosition.y - 2f) < 0.1)
28+
{
29+
Vector3 localPosition = textMesh.transform.localPosition;
30+
localPosition.y = 1f;
31+
textMesh.transform.localPosition = localPosition;
32+
}
2633
}
2734
else
2835
{
@@ -59,4 +66,10 @@ private void Update()
5966
UpdateText();
6067
}
6168
}
69+
70+
public void SetFontSize(float size)
71+
{
72+
if (textMesh == null) { return; }
73+
textMesh.fontSize = size;
74+
}
6275
}

0 commit comments

Comments
 (0)