protected override void Update(float deltaTime) { if (type == Type.InGame) { Vector2 initialPos = new Vector2(0.0f, GameMain.GraphicsHeight); Vector2 defaultPos = new Vector2(0.0f, HUDLayoutSettings.InventoryAreaLower.Y - InnerFrame.Rect.Height - 20 * GUI.Scale); Vector2 endPos = new Vector2(GameMain.GraphicsWidth, defaultPos.Y); /*for (int i = MessageBoxes.IndexOf(this); i >= 0; i--) * { * if (MessageBoxes[i] is GUIMessageBox otherMsgBox && otherMsgBox != this && otherMsgBox.type == type && !otherMsgBox.closing) * { * defaultPos = new Vector2( * Math.Max(otherMsgBox.InnerFrame.RectTransform.AbsoluteOffset.X + 10 * GUI.Scale, defaultPos.X), * Math.Max(otherMsgBox.InnerFrame.RectTransform.AbsoluteOffset.Y + 10 * GUI.Scale, defaultPos.Y)); * } * }*/ if (!closing) { InnerFrame.RectTransform.AbsoluteOffset = Vector2.SmoothStep(initialPos, defaultPos, openState).ToPoint(); openState = Math.Min(openState + deltaTime * 2.0f, 1.0f); if (GUI.MouseOn != InnerFrame && !InnerFrame.IsParentOf(GUI.MouseOn)) { inGameCloseTimer += deltaTime; } if (inGameCloseTimer >= inGameCloseTime) { Close(); } } else { openState += deltaTime * 2.0f; InnerFrame.RectTransform.AbsoluteOffset = Vector2.SmoothStep(defaultPos, endPos, openState - 1.0f).ToPoint(); if (openState >= 2.0f) { if (Parent != null) { Parent.RemoveChild(this); } if (MessageBoxes.Contains(this)) { MessageBoxes.Remove(this); } } } } }
protected override void Update(float deltaTime) { if (Draggable) { GUIComponent parent = GUI.MouseOn?.Parent?.Parent; if ((GUI.MouseOn == InnerFrame || InnerFrame.IsParentOf(GUI.MouseOn)) && !(GUI.MouseOn is GUIButton || GUI.MouseOn is GUIColorPicker || GUI.MouseOn is GUITextBox || parent is GUITextBox)) { GUI.MouseCursor = CursorState.Move; if (PlayerInput.PrimaryMouseButtonDown()) { DraggingPosition = RectTransform.ScreenSpaceOffset.ToVector2() - PlayerInput.MousePosition; } } if (PlayerInput.PrimaryMouseButtonHeld() && DraggingPosition != Vector2.Zero) { GUI.MouseCursor = CursorState.Dragging; RectTransform.ScreenSpaceOffset = (PlayerInput.MousePosition + DraggingPosition).ToPoint(); } else { DraggingPosition = Vector2.Zero; } } if (type == Type.InGame) { Vector2 initialPos = new Vector2(0.0f, GameMain.GraphicsHeight); Vector2 defaultPos = new Vector2(0.0f, HUDLayoutSettings.InventoryAreaLower.Y - InnerFrame.Rect.Height - 20 * GUI.Scale); Vector2 endPos = new Vector2(GameMain.GraphicsWidth, defaultPos.Y); if (!closing) { Point step = Vector2.SmoothStep(initialPos, defaultPos, openState).ToPoint(); InnerFrame.RectTransform.AbsoluteOffset = step; if (BackgroundIcon != null) { BackgroundIcon.RectTransform.AbsoluteOffset = new Point(InnerFrame.Rect.Location.X - (int)(BackgroundIcon.Rect.Size.X / 1.25f), (int)defaultPos.Y - BackgroundIcon.Rect.Size.Y / 2); if (!MathUtils.NearlyEqual(openState, 1.0f)) { BackgroundIcon.Color = ToolBox.GradientLerp(openState, Color.Transparent, Color.White); } } if (!(Screen.Selected is RoundSummaryScreen) && !MessageBoxes.Any(mb => mb.UserData is RoundSummary)) { openState = Math.Min(openState + deltaTime * 2.0f, 1.0f); } if (GUI.MouseOn != InnerFrame && !InnerFrame.IsParentOf(GUI.MouseOn) && AutoClose) { inGameCloseTimer += deltaTime; } if (inGameCloseTimer >= inGameCloseTime) { Close(); } } else { openState += deltaTime * 2.0f; Point step = Vector2.SmoothStep(defaultPos, endPos, openState - 1.0f).ToPoint(); InnerFrame.RectTransform.AbsoluteOffset = step; if (BackgroundIcon != null) { BackgroundIcon.Color *= 0.9f; } if (openState >= 2.0f) { if (Parent != null) { Parent.RemoveChild(this); } if (MessageBoxes.Contains(this)) { MessageBoxes.Remove(this); } } } if (newBackgroundIcon != null) { if (!iconSwitching) { if (BackgroundIcon != null) { BackgroundIcon.Color *= 0.9f; if (BackgroundIcon.Color.A == 0) { BackgroundIcon = null; iconSwitching = true; RemoveChild(BackgroundIcon); } } else { iconSwitching = true; } iconState = 0; } else { newBackgroundIcon.SetAsFirstChild(); newBackgroundIcon.RectTransform.AbsoluteOffset = new Point(InnerFrame.Rect.Location.X - (int)(newBackgroundIcon.Rect.Size.X / 1.25f), (int)defaultPos.Y - newBackgroundIcon.Rect.Size.Y / 2); newBackgroundIcon.Color = ToolBox.GradientLerp(iconState, Color.Transparent, Color.White); if (newBackgroundIcon.Color.A == 255) { BackgroundIcon = newBackgroundIcon; BackgroundIcon.SetAsFirstChild(); newBackgroundIcon = null; iconSwitching = false; } iconState = Math.Min(iconState + deltaTime * 2.0f, 1.0f); } } } }
protected override void Update(float deltaTime) { if (type != Type.InGame) { return; } Vector2 initialPos = new Vector2(0.0f, GameMain.GraphicsHeight); Vector2 defaultPos = new Vector2(0.0f, HUDLayoutSettings.InventoryAreaLower.Y - InnerFrame.Rect.Height - 20 * GUI.Scale); Vector2 endPos = new Vector2(GameMain.GraphicsWidth, defaultPos.Y); if (!closing) { Point step = Vector2.SmoothStep(initialPos, defaultPos, openState).ToPoint(); InnerFrame.RectTransform.AbsoluteOffset = step; if (BackgroundIcon != null) { BackgroundIcon.RectTransform.AbsoluteOffset = new Point(InnerFrame.Rect.Location.X - (int)(BackgroundIcon.Rect.Size.X / 1.25f), (int)defaultPos.Y - BackgroundIcon.Rect.Size.Y / 2); if (!MathUtils.NearlyEqual(openState, 1.0f)) { BackgroundIcon.Color = ToolBox.GradientLerp(openState, Color.Transparent, Color.White); } } if (!(Screen.Selected is RoundSummaryScreen) && !MessageBoxes.Any(mb => mb.UserData is RoundSummary)) { openState = Math.Min(openState + deltaTime * 2.0f, 1.0f); } if (GUI.MouseOn != InnerFrame && !InnerFrame.IsParentOf(GUI.MouseOn) && AutoClose) { inGameCloseTimer += deltaTime; } if (inGameCloseTimer >= inGameCloseTime) { Close(); } } else { openState += deltaTime * 2.0f; Point step = Vector2.SmoothStep(defaultPos, endPos, openState - 1.0f).ToPoint(); InnerFrame.RectTransform.AbsoluteOffset = step; if (BackgroundIcon != null) { BackgroundIcon.Color *= 0.9f; } if (openState >= 2.0f) { if (Parent != null) { Parent.RemoveChild(this); } if (MessageBoxes.Contains(this)) { MessageBoxes.Remove(this); } } } if (newBackgroundIcon != null) { if (!iconSwitching) { if (BackgroundIcon != null) { BackgroundIcon.Color *= 0.9f; if (BackgroundIcon.Color.A == 0) { BackgroundIcon = null; iconSwitching = true; RemoveChild(BackgroundIcon); } } else { iconSwitching = true; } iconState = 0; } else { newBackgroundIcon.SetAsFirstChild(); newBackgroundIcon.RectTransform.AbsoluteOffset = new Point(InnerFrame.Rect.Location.X - (int)(newBackgroundIcon.Rect.Size.X / 1.25f), (int)defaultPos.Y - newBackgroundIcon.Rect.Size.Y / 2); newBackgroundIcon.Color = ToolBox.GradientLerp(iconState, Color.Transparent, Color.White); if (newBackgroundIcon.Color.A == 255) { BackgroundIcon = newBackgroundIcon; BackgroundIcon.SetAsFirstChild(); newBackgroundIcon = null; iconSwitching = false; } iconState = Math.Min(iconState + deltaTime * 2.0f, 1.0f); } } }
protected override void Update(float deltaTime) { if (type == Type.InGame) { Vector2 initialPos = new Vector2(0.0f, GameMain.GraphicsHeight); Vector2 defaultPos = new Vector2(0.0f, HUDLayoutSettings.InventoryAreaLower.Y - InnerFrame.Rect.Height - 20 * GUI.Scale); Vector2 endPos = new Vector2(GameMain.GraphicsWidth, defaultPos.Y); /*for (int i = MessageBoxes.IndexOf(this); i >= 0; i--) * { * if (MessageBoxes[i] is GUIMessageBox otherMsgBox && otherMsgBox != this && otherMsgBox.type == type && !otherMsgBox.closing) * { * defaultPos = new Vector2( * Math.Max(otherMsgBox.InnerFrame.RectTransform.AbsoluteOffset.X + 10 * GUI.Scale, defaultPos.X), * Math.Max(otherMsgBox.InnerFrame.RectTransform.AbsoluteOffset.Y + 10 * GUI.Scale, defaultPos.Y)); * } * }*/ if (!closing) { Point step = Vector2.SmoothStep(initialPos, defaultPos, openState).ToPoint(); InnerFrame.RectTransform.AbsoluteOffset = step; if (BackgroundIcon != null) { BackgroundIcon.RectTransform.AbsoluteOffset = new Point(InnerFrame.Rect.Location.X - (int)(BackgroundIcon.Rect.Size.X / 1.25f), (int)defaultPos.Y - BackgroundIcon.Rect.Size.Y / 2); if (!MathUtils.NearlyEqual(openState, 1.0f)) { BackgroundIcon.Color = ToolBox.GradientLerp(openState, Color.Transparent, Color.White); } } openState = Math.Min(openState + deltaTime * 2.0f, 1.0f); if (GUI.MouseOn != InnerFrame && !InnerFrame.IsParentOf(GUI.MouseOn) && AutoClose) { inGameCloseTimer += deltaTime; } if (inGameCloseTimer >= inGameCloseTime) { Close(); } } else { openState += deltaTime * 2.0f; Point step = Vector2.SmoothStep(defaultPos, endPos, openState - 1.0f).ToPoint(); InnerFrame.RectTransform.AbsoluteOffset = step; if (BackgroundIcon != null) { BackgroundIcon.Color *= 0.9f; } if (openState >= 2.0f) { if (Parent != null) { Parent.RemoveChild(this); } if (MessageBoxes.Contains(this)) { MessageBoxes.Remove(this); } } } if (newBackgroundIcon != null) { if (!iconSwitching) { if (BackgroundIcon != null) { BackgroundIcon.Color *= 0.9f; if (BackgroundIcon.Color.A == 0) { BackgroundIcon = null; iconSwitching = true; RemoveChild(BackgroundIcon); } } else { iconSwitching = true; } iconState = 0; } else { newBackgroundIcon.SetAsFirstChild(); newBackgroundIcon.RectTransform.AbsoluteOffset = new Point(InnerFrame.Rect.Location.X - (int)(newBackgroundIcon.Rect.Size.X / 1.25f), (int)defaultPos.Y - newBackgroundIcon.Rect.Size.Y / 2); newBackgroundIcon.Color = ToolBox.GradientLerp(iconState, Color.Transparent, Color.White); if (newBackgroundIcon.Color.A == 255) { BackgroundIcon = newBackgroundIcon; BackgroundIcon.SetAsFirstChild(); newBackgroundIcon = null; iconSwitching = false; } iconState = Math.Min(iconState + deltaTime * 2.0f, 1.0f); } } } }