Skip to content

Commit

Permalink
Revert sprite position in 4:3 mode
Browse files Browse the repository at this point in the history
  • Loading branch information
drojf committed Aug 13, 2021
1 parent ed6f93a commit 1e7043b
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions Assets.Scripts.Core.Buriko/BurikoScriptFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2532,6 +2532,9 @@ public BurikoVariable OperationMODDrawCharacter()
bool flag = ReadVariable().BoolValue();
string textureName2 = textureName + "0";
string text = textureName + str;

x = MODRyukishiRevertSpritePosition(textureName, x);

MODSystem.instance.modSceneController.MODLipSyncInvalidateAndGenerateId(character);
if (!MODSystem.instance.modSceneController.MODLipSyncIsEnabled())
{
Expand Down Expand Up @@ -2580,6 +2583,9 @@ public BurikoVariable OperationMODDrawCharacterWithFiltering()
bool flag = ReadVariable().BoolValue();
string textureName2 = textureName + "0";
string text = textureName + str;

x = MODRyukishiRevertSpritePosition(textureName, x);

MODSystem.instance.modSceneController.MODLipSyncInvalidateAndGenerateId(character);
if (!MODSystem.instance.modSceneController.MODLipSyncIsEnabled())
{
Expand Down Expand Up @@ -2821,5 +2827,35 @@ public BurikoVariable OperationMODGenericCall()
}
return BurikoVariable.Null;
}

/// <summary>
/// This function reverts the x positions of sprites when using 4:3 backgrounds to match the original game
/// In some places, our mod has 'spread out' the sprite positions to better match 16:9 widescreen by setting
/// their X position to 240/-240 instead of 160/-160 (mostly when there are 3 characters on the screen at once).
/// However, when playing in 4:3 mode, this causes the sprites to be more cut-off than they were in the original game.
/// This function attempts to revert this specific case by changing an X of 240/-240 into 160/-160.
/// </summary>
private int MODRyukishiRevertSpritePosition(string path, int x)
{
path = path.ToLower();

if(BurikoMemory.Instance.GetGlobalFlag("GBackgroundSet").IntValue() == 1 && // Using OG Backgrounds AND
BurikoMemory.Instance.GetGlobalFlag("GStretchBackgrounds").IntValue() == 0) // Not stretching backgrounds
{
if (path.StartsWith("sprite/") || path.StartsWith("portrait/")) // is from the sprite or portrait folder
{
if (x == 240)
{
return 160;
}
else if (x == -240)
{
return -160;
}
}
}

return x;
}
}
}

0 comments on commit 1e7043b

Please sign in to comment.