Skip to content

Commit 672b104

Browse files
committed
Merge pull request #6 from mexmer/gui-transparency-fixes
Gui transparency fixes
2 parents a3d1a97 + b495c9d commit 672b104

16 files changed

+32
-20
lines changed

Sources/Sandbox.Game/Game/Screens/Helpers/MyGuiControlComponentList.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ internal ItemIconControl(MyPhysicalItemDefinition def)
121121
originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP));
122122
}
123123
}
124+
125+
public override void Draw(float transitionAlpha, float backgroundTransitionAlpha)
126+
{
127+
base.Draw(transitionAlpha, transitionAlpha);
128+
}
124129
}
125130

126131
internal class ComponentControl : MyGuiControlBase

Sources/Sandbox.Game/Game/Screens/MyGuiScreenDialogAmount.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class MyGuiScreenDialogAmount : MyGuiScreenBase
4141
/// <param name="minMaxDecimalDigits">Number of digits used from min and max value. Decimal places beyond this value are cut off (no rounding occurs).</param>
4242
/// <param name="parseAsInteger">True will ensure parsing as integer number (you cannot input decimal values). False will parse as decimal number.</param>
4343
public MyGuiScreenDialogAmount(float min, float max, int minMaxDecimalDigits = 3, bool parseAsInteger = false, float? defaultAmount = null, MyStringId? caption = null) :
44-
base(new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, null)
44+
base(new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, null, backgroundTransition: MySandboxGame.Config.UIBkTransparency, guiTransition: MySandboxGame.Config.UITransparency)
4545
{
4646
CanHideOthers = false;
4747
EnabledBackgroundFade = true;

Sources/Sandbox.Game/Game/SessionComponents/MySessionComponentVoxelHand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ public void DrawMaterial()
416416
var pos = new Vector2(0.5525f,0.84f);
417417
var size = new Vector2(0.05f, 0.05f);
418418

419-
m_texture.Draw(pos, size, Color.White);
419+
m_texture.Draw(pos, size, Color.White, Color.White);
420420
MyGuiManager.DrawBorders(pos, size, Color.White, 1);
421421

422422
pos.X += 0.06f;

Sources/Sandbox.Graphics/Gui/MyGuiCompositeTexture.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public void Draw(Vector2 positionTopLeft, float innerHeight, Color colorMask)
170170
}
171171
}
172172

173-
public void Draw(Vector2 positionLeftTop, Vector2 size, Color colorMask, float textureScale = 1f)
173+
public void Draw(Vector2 positionLeftTop, Vector2 size, Color colorMask, Color colorMaskCenter, float textureScale = 1f)
174174
{
175175
Rectangle target;
176176
size = Vector2.Clamp(size, MinSizeGui * textureScale, MaxSizeGui * textureScale);
@@ -268,7 +268,7 @@ public void Draw(Vector2 positionLeftTop, Vector2 size, Color colorMask, float t
268268
var screenSizeC = screenSize - new Vector2I(leftWidth + rightWidth, topHeight + bottomHeight);
269269
var pos = screenPosLT + new Vector2I(leftWidth, topHeight);
270270
SetTargetRectangle(out target, ref pos, ref screenSizeC, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
271-
MyGuiManager.DrawSprite(m_center.Texture, target, colorMask);
271+
MyGuiManager.DrawSprite(m_center.Texture, target, colorMaskCenter);
272272
}
273273
}
274274

Sources/Sandbox.Graphics/Gui/MyGuiControlBase.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -598,17 +598,17 @@ public static void ReadIfHasValue(ref Color target, Vector4? source)
598598

599599
public virtual void Draw(float transitionAlpha, float backgroundTransitionAlpha)
600600
{
601-
DrawBackground(backgroundTransitionAlpha);
601+
DrawBackground(transitionAlpha, backgroundTransitionAlpha);
602602
DrawElements(transitionAlpha, backgroundTransitionAlpha);
603603
DrawBorder(transitionAlpha);
604604
}
605605

606-
protected void DrawBackground(float transitionAlpha)
606+
protected void DrawBackground(float transitionAlpha, float backgroundTransitionAlpha)
607607
{
608608
// Draw background texture if there is one and background is not completely transparent.
609609
if (BackgroundTexture != null && ColorMask.W > 0.0f)
610610
{
611-
BackgroundTexture.Draw(GetPositionAbsoluteTopLeft(), Size, ApplyColorMaskModifiers(ColorMask, Enabled, transitionAlpha));
611+
BackgroundTexture.Draw(GetPositionAbsoluteTopLeft(), Size, ApplyColorMaskModifiers(ColorMask, Enabled, transitionAlpha), ApplyColorMaskModifiers(ColorMask, Enabled, backgroundTransitionAlpha));
612612
}
613613
}
614614

Sources/Sandbox.Graphics/Gui/MyGuiControlCombobox.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ private void DrawOpenedAreaItems(int startIndex, int endIndex, float transitionA
966966
Vector2 dropdownSize = Vector2.Clamp(new Vector2(Size.X, itemsHeight + minSize.Y), minSize, maxSize);
967967
var topLeft = GetPositionAbsoluteTopLeft();
968968
m_styleDef.DropDownTexture.Draw(topLeft + m_openedArea.Position, dropdownSize,
969-
ApplyColorMaskModifiers(ColorMask, Enabled, transitionAlpha));
969+
ApplyColorMaskModifiers(ColorMask, Enabled, transitionAlpha), ApplyColorMaskModifiers(ColorMask, Enabled, transitionAlpha));
970970

971971
// Scissor to cut off items that overflow dropdown area.
972972
var scissor = m_openedItemArea;

Sources/Sandbox.Graphics/Gui/MyGuiControlCompositePanel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public override MyObjectBuilder_GuiControlBase GetObjectBuilder()
4646

4747
public override void Draw(float transitionAlpha, float backgroundTransitionAlpha)
4848
{
49-
BackgroundTexture.Draw(GetPositionAbsoluteTopLeft(), Size, ApplyColorMaskModifiers(ColorMask, Enabled, backgroundTransitionAlpha));
49+
BackgroundTexture.Draw(GetPositionAbsoluteTopLeft(), Size, ApplyColorMaskModifiers(ColorMask, Enabled, transitionAlpha), ApplyColorMaskModifiers(ColorMask, Enabled, backgroundTransitionAlpha));
5050
DrawBorder(transitionAlpha);
5151
}
5252

Sources/Sandbox.Graphics/Gui/MyGuiControlGrid.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ public override void Draw(float transitionAlpha, float backgroundTransitionAlpha
546546
{
547547
base.Draw(transitionAlpha, backgroundTransitionAlpha);
548548
RefreshItemsRectangle();
549-
DrawItemBackgrounds(backgroundTransitionAlpha);
549+
DrawItemBackgrounds(transitionAlpha, backgroundTransitionAlpha);
550550
DrawItems(transitionAlpha);
551551
DrawItemTexts(transitionAlpha);
552552
//DebugDraw();
@@ -700,7 +700,7 @@ private void DebugDraw()
700700
}
701701
}
702702

703-
private void DrawItemBackgrounds(float transitionAlpha)
703+
private void DrawItemBackgrounds(float transitionAlpha, float backgroundTransitionAlpha)
704704
{
705705
var normalTexture = m_styleDef.ItemTexture.Normal;
706706
var highlightTexture = m_styleDef.ItemTexture.Highlight;
@@ -729,8 +729,10 @@ private void DrawItemBackgrounds(float transitionAlpha)
729729
texture: highlight ? highlightTexture : normalTexture,
730730
normalizedCoord: drawPositionTopLeft,
731731
normalizedSize: ItemSize,
732-
color: ApplyColorMaskModifiers(ColorMask, enabled, transitionAlpha * blinkingTransparency),
732+
color: ApplyColorMaskModifiers(ColorMask, enabled, backgroundTransitionAlpha * blinkingTransparency),
733733
drawAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
734+
if (highlight && backgroundTransitionAlpha < 0.2)
735+
MyGuiManager.DrawBorders(drawPositionTopLeft, ItemSize, ApplyColorMaskModifiers(MyGuiConstants.THEMED_GUI_LINE_COLOR.ToVector4(), Enabled, transitionAlpha),1);
734736
++idx;
735737
}
736738
}

Sources/Sandbox.Graphics/Gui/MyGuiControlList.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ public override void Draw(float transitionAlpha, float backgroundTransitionAlpha
134134
{
135135
var topLeft = GetPositionAbsoluteTopLeft();
136136
m_styleDef.Texture.Draw(topLeft, Size,
137+
ApplyColorMaskModifiers(ColorMask, Enabled, transitionAlpha),
137138
ApplyColorMaskModifiers(ColorMask, Enabled, backgroundTransitionAlpha));
138139

139140
var scissor = m_itemsRectangle;

Sources/Sandbox.Graphics/Gui/MyGuiControlListbox.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ public override void Draw(float transitionAlpha, float backgroundTransitionAlpha
409409
base.Draw(transitionAlpha, backgroundTransitionAlpha);
410410
var positionTopLeft = GetPositionAbsoluteTopLeft();
411411

412-
m_styleDef.Texture.Draw(positionTopLeft, Size, ApplyColorMaskModifiers(ColorMask, Enabled, backgroundTransitionAlpha));
412+
m_styleDef.Texture.Draw(positionTopLeft, Size, ApplyColorMaskModifiers(ColorMask, Enabled, transitionAlpha), ApplyColorMaskModifiers(ColorMask, Enabled, backgroundTransitionAlpha));
413413

414414
var position = positionTopLeft + new Vector2(m_itemsRectangle.X, m_itemsRectangle.Y);
415415
int index = m_visibleRowIndexOffset;
@@ -449,6 +449,8 @@ public override void Draw(float transitionAlpha, float backgroundTransitionAlpha
449449
if (isHighlit)
450450
{
451451
MyGuiManager.DrawSpriteBatch(m_styleDef.ItemTextureHighlight, position, ItemSize, color, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
452+
if (backgroundTransitionAlpha < 0.2)
453+
MyGuiManager.DrawBorders(position, ItemSize, ApplyColorMaskModifiers(MyGuiConstants.THEMED_GUI_LINE_COLOR.ToVector4(), Enabled, transitionAlpha), 1);
452454
}
453455

454456
if (!String.IsNullOrEmpty(item.Icon))

0 commit comments

Comments
 (0)