Skip to content

Commit

Permalink
Add runtime font outline adjustment
Browse files Browse the repository at this point in the history
  • Loading branch information
drojf committed Feb 11, 2024
1 parent d0e5480 commit e7a0c4b
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 2 deletions.
3 changes: 1 addition & 2 deletions Assets.Scripts.Core.Buriko/BurikoScriptFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2666,8 +2666,7 @@ private BurikoVariable OperationMODSetMainFontOutlineWidth()
{
SetOperationType("MODSetMainFontOutlineWidth");
int width = ReadVariable().IntValue();
GameSystem.Instance.OutlineWidth = width / 100f;
GameSystem.Instance.MainUIController.TextWindow.outlineWidth = GameSystem.Instance.OutlineWidth;
GameSystem.Instance.MainUIController.SetFontOutlineWidth(width/100f);
return BurikoVariable.Null;
}

Expand Down
10 changes: 10 additions & 0 deletions Assets.Scripts.UI/MainUIController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -822,5 +822,15 @@ private static void GUIUnclickableTextArea(Rect rect, string text)
GUI.Label(rect, text, GUI.skin.textArea);
}

/// <summary>
/// Sets the font outline width, and updates the current textwindow outline width
/// Hopefully if you toggle language (which toggles the font on chapters 1-9), the outline width is retained.
/// </summary>
/// <param name="outlineWidth">The outline width as a float typically between (0, 1)</param>
public void SetFontOutlineWidth(float outlineWidth)
{
gameSystem.OutlineWidth = outlineWidth;
TextWindow.outlineWidth = GameSystem.Instance.OutlineWidth;
}
}
}
8 changes: 8 additions & 0 deletions MOD.Scripts.UI/MODMenuCommon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ public static string TextField(string text, int maxLength, params GUILayoutOptio
return GUILayout.TextField(text, maxLength, MODStyleManager.OnGUIInstance.Group.textField, options);
}

public static string TextField(string text, int maxLength, out bool hasChanged, params GUILayoutOption[] options)
{
string newValue = GUILayout.TextField(text, maxLength, MODStyleManager.OnGUIInstance.Group.textField, options);

hasChanged = text != newValue;
return newValue;
}

public static int GetGlobal(string flagName) => BurikoMemory.Instance.GetGlobalFlag(flagName).IntValue();
public static void SetGlobal(string flagName, int flagValue) => BurikoMemory.Instance.SetGlobalFlag(flagName, flagValue);
}
Expand Down
29 changes: 29 additions & 0 deletions MOD.Scripts.UI/MODMenuNormal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class MODMenuNormal : MODMenuModuleInterface

private static int gameClearClickCount = 3;

string TextField_FontOutlineWidth;

public MODMenuNormal(MODMenu modMenu, MODMenuAudioOptions audioOptionsMenu)
{
this.modMenu = modMenu;
Expand Down Expand Up @@ -165,6 +167,7 @@ public void OnBeforeMenuVisible() {
GameSystem.Instance.SceneController.MODGetExpressionThresholds(out float threshold1, out float threshold2);
TextField_ComputedLipSyncThreshold1 = threshold1.ToString();
TextField_ComputedLipSyncThreshold2 = threshold2.ToString();
TextField_FontOutlineWidth = GameSystem.Instance.OutlineWidth.ToString();

gameClearClickCount = 3;
}
Expand Down Expand Up @@ -372,6 +375,8 @@ private void TroubleShootingTabOnGUI()
GUILayout.EndHorizontal();

OnGUIComputedLipsync();

OnGUIFontDebug();
}
else
{
Expand Down Expand Up @@ -463,6 +468,30 @@ private void OnGUIComputedLipsync()
}
}

private void OnGUIFontDebug()
{
Label("Font Debugging");

GUILayout.BeginHorizontal();
{
Label(new GUIContent("Outline", "Font Outline Width"));
TextField_FontOutlineWidth = TextField(TextField_FontOutlineWidth, 5, out bool hasChanged);
if (hasChanged)
{
try
{
GameSystem.Instance.MainUIController.SetFontOutlineWidth(float.Parse(TextField_FontOutlineWidth));
}
catch (Exception e)
{
MODToaster.Show("Failed to set font settings:" + e.ToString());
}
MODToaster.Show("Font Updated");
}
}
GUILayout.EndHorizontal();
}

public bool UserCanClose() => true;
public string Heading() => Loc.MODMenuNormal_127; //Mod Options Menu

Expand Down

0 comments on commit e7a0c4b

Please sign in to comment.