Skip to content
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

feat: window background transparency #2373

Merged
merged 1 commit into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion Intersect.Client.Framework/Gwen/Control/WindowControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,15 @@ public override bool IsOnTop
get { return Parent.Children.Where(x => x is WindowControl).Last() == this; }
}

/// <summary>
/// If the shadow under the window should be drawn.
/// </summary>
public bool DrawShadow { get; set; } = true;

public override JObject GetJson(bool isRoot = default)
{
var obj = base.GetJson(isRoot);
obj.Add(nameof(DrawShadow), DrawShadow);
obj.Add("ActiveImage", GetImageFilename(ControlState.Active));
obj.Add("InactiveImage", GetImageFilename(ControlState.Inactive));
obj.Add("ActiveColor", Color.ToString(mActiveColor));
Expand All @@ -182,6 +188,13 @@ public override JObject GetJson(bool isRoot = default)
public override void LoadJson(JToken obj, bool isRoot = default)
{
base.LoadJson(obj);

var tokenDrawShadow = obj[nameof(DrawShadow)];
if (tokenDrawShadow != null)
{
DrawShadow = (bool)tokenDrawShadow;
}

if (obj["ActiveImage"] != null)
{
SetImage(
Expand Down Expand Up @@ -333,7 +346,11 @@ protected override void Render(Skin.Base skin)
protected override void RenderUnder(Skin.Base skin)
{
base.RenderUnder(skin);
skin.DrawShadow(this);

if (DrawShadow)
{
skin.DrawShadow(this);
}
}

public override void Touch()
Expand Down
14 changes: 10 additions & 4 deletions Intersect.Client.Framework/Gwen/Skin/Intersect2021.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ public override void DrawWindow(Control.Base control, int topHeight, bool inFocu
return;
}


GameTexture? renderTexture = null;
if (windowControl.TryGetTexture(WindowControl.ControlState.Active, out var activeTexture))
{
Expand Down Expand Up @@ -193,19 +192,26 @@ public override void DrawWindow(Control.Base control, int topHeight, bool inFocu

Rectangle frameBounds = windowControl.RenderBounds;

if (titleBar != default)
var shouldDrawTitlebarBackground = titleBar != default && windowControl.TitleBar.ShouldDrawBackground;
if (shouldDrawTitlebarBackground)
{
frameBounds = new Rectangle(
0,
windowControl.TitleBar.Bottom,
control.RenderBounds.Width,
control.RenderBounds.Height
);
}

titleBar.Draw(Renderer, windowControl.TitleBar.Bounds, windowControl.RenderColor);
if (frame != default && windowControl.ShouldDrawBackground)
{
frame.Draw(Renderer, frameBounds, windowControl.RenderColor);
}

frame.Draw(Renderer, frameBounds, windowControl.RenderColor);
if (shouldDrawTitlebarBackground)
{
titleBar.Draw(Renderer, windowControl.TitleBar.Bounds, windowControl.RenderColor);
}
}

#endregion
Expand Down
Loading