-
-
Notifications
You must be signed in to change notification settings - Fork 419
[Lookup Anything] Background theme options #1151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
[Lookup Anything] Background theme options #1151
Conversation
Thanks for the pull request! Splitting the logic between For example, something like... /// <summary>Get the default themes.</summary>
private static Dictionary<string, ThemeData> GetDefaultThemes()
{
return new()
{
// formerly LetterBackground
["TornLetter"] = new ThemeData
{
Background = new()
{
Texture = "LooseSprites/letterBG",
SourceRect = new Rectangle(0, 0, 320, 180)
}
},
// formerly PlainBackground
["PlainWheat"] = new ThemeData
{
Background = new()
{
Color = "Wheat"
},
Border = new()
{
Color = "BurlyWood",
Width = 4
}
},
// formerly MenuBoxBackground
["MenuBox_Inset"] = new ThemeData
{
Background = new()
{
Texture = "Maps/MenuTiles",
SourceRect = new Rectangle(0, 316, 60, 60),
ScaleMode = BackgroundScaleMode.TextureBox
}
}
};
} Then the unified implementation would do something like... public void DrawBackground(SpriteBatch b, int x, int y, int width, int height)
{
if (this.Theme.Background is { } background)
{
if (background.Color != null)
Utility.DrawSquare(b, new(x, y, width, height), 0, backgroundColor: background.Color);
if (background.Texture != null)
{
Rectangle sourceRect = background.SourceRect;
switch (background.ScaleMode)
{
case BackgroundScaleMode.TextureBox:
// copy logic from MenuBoxBackground
break;
default:
// copy logic from LetterBackground
break;
}
}
}
if (this.Theme.Border is { } border)
Utility.DrawSquare(b, new(x, y, width, height), border.Width, border.Color);
} Once we have that, it'll be much easier to allow custom mod themes (which I could add after merging the PR). |
a14ba1e
to
52c555c
Compare
52c555c
to
f2ffe11
Compare
Adds some background theme options, and refactor code for potential mod added themes down the road (i.e. not in this PR)