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

+5
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

+1-1
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

+1-1
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

+2-2
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

+3-3
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

+1-1
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

+1-1
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

+5-3
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

+1
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

+3-1
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))

Sources/Sandbox.Graphics/Gui/MyGuiControlRadioButton.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ public override MyGuiControlBase HandleInput()
305305

306306
public override void Draw(float transitionAlpha, float backgroundTransitionAlpha)
307307
{
308-
base.Draw(transitionAlpha, backgroundTransitionAlpha);
308+
base.Draw(transitionAlpha, transitionAlpha);
309309

310310
Vector2 topLeft = Vector2.Zero;
311311
if (Icon.HasValue || (Text != null && Text.Length > 0))

Sources/Sandbox.Graphics/Gui/MyGuiControlSlider.cs

+1
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ public override void Draw(float transitionAlpha, float backgroundTransitionAlpha
260260
GetPositionAbsoluteTopLeft(),
261261
Size - new Vector2(m_labelSpaceWidth, 0f),
262262
ApplyColorMaskModifiers(ColorMask, Enabled, transitionAlpha),
263+
ApplyColorMaskModifiers(ColorMask, Enabled, backgroundTransitionAlpha),
263264
textureScale: DebugScale);
264265
DrawThumb(transitionAlpha);
265266
m_label.Draw(transitionAlpha, backgroundTransitionAlpha);

Sources/Sandbox.Graphics/Gui/MyGuiControlTabControl.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public override void Draw(float transitionAlpha, float backgroundTransitionAlpha
195195
var font = (isEnabled && isHighlight) ? MyFontEnum.White : MyFontEnum.Blue;
196196

197197
// Draw background texture
198-
texture.Draw(currentPos, TabButtonSize, ApplyColorMaskModifiers(ColorMask, isEnabled, transitionAlpha), m_tabButtonScale);
198+
texture.Draw(currentPos, TabButtonSize, ApplyColorMaskModifiers(ColorMask, isEnabled, transitionAlpha), ApplyColorMaskModifiers(ColorMask, isEnabled, backgroundTransitionAlpha), m_tabButtonScale);
199199
StringBuilder text = currentTab.Text;
200200
if (text != null)
201201
{

Sources/Sandbox.Graphics/Gui/MyGuiControlTable.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ public override void Draw(float transitionAlpha, float backgroundTransitionAlpha
449449
var position = GetPositionAbsoluteTopLeft();
450450
float height = RowHeight * (VisibleRowsCount + 1); // One row is taken up by the header of the table.
451451
m_styleDef.Texture.Draw(position, Size,
452-
ApplyColorMaskModifiers(ColorMask, Enabled, backgroundTransitionAlpha));
452+
ApplyColorMaskModifiers(ColorMask, Enabled, transitionAlpha), ApplyColorMaskModifiers(ColorMask, Enabled, backgroundTransitionAlpha));
453453

454454
if (HeaderVisible)
455455
DrawHeader(transitionAlpha);

Sources/Sandbox.Graphics/Gui/MyGuiControlTextbox.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ public override void Draw(float transitionAlpha, float backgroundTransitionAlpha
265265
if (!Visible)
266266
return;
267267

268-
m_compositeBackground.Draw(GetPositionAbsoluteTopLeft(), Size, ApplyColorMaskModifiers(ColorMask, Enabled, backgroundTransitionAlpha));
268+
m_compositeBackground.Draw(GetPositionAbsoluteTopLeft(), Size, ApplyColorMaskModifiers(ColorMask, Enabled, transitionAlpha), ApplyColorMaskModifiers(ColorMask, Enabled, backgroundTransitionAlpha));
269269

270270
base.Draw(transitionAlpha, backgroundTransitionAlpha);
271271

Sources/Sandbox.Graphics/Gui/MyScrollbar.cs

+4-3
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,14 @@ public override void Draw(Color colorMask)
173173
}
174174

175175
var leftTopPosition = OwnerControl.GetPositionAbsoluteCenter() + Position;
176-
m_backgroundTexture.Draw(leftTopPosition, Size, colorMask);
176+
m_backgroundTexture.Draw(leftTopPosition, Size, colorMask, colorMask);
177177

178178
if (CanScroll())
179179
{
180180
var carretPosition = GetCarretPosition();
181181
Texture.Draw(leftTopPosition + carretPosition,
182182
CaretSize,
183-
colorMask);
183+
colorMask, colorMask);
184184
}
185185
}
186186

@@ -280,13 +280,14 @@ public override void Draw(Color colorMask)
280280
}
281281

282282
var leftTopPosition = OwnerControl.GetPositionAbsoluteCenter() + Position;
283-
m_backgroundTexture.Draw(leftTopPosition, Size, colorMask);
283+
m_backgroundTexture.Draw(leftTopPosition, Size, colorMask, colorMask);
284284

285285
if (CanScroll())
286286
{
287287
var carretPosition = GetCarretPosition();
288288
Texture.Draw(leftTopPosition + carretPosition,
289289
CaretSize,
290+
colorMask,
290291
colorMask,
291292
ScrollBarScale);
292293
}

0 commit comments

Comments
 (0)