public override void Update(GameTime gameTime) { float DrawY = PanelY + 32; int CurrentAllMutatorsIndex = (int)(MouseHelper.MouseStateCurrent.Y - DrawY) / 20 + AvailableMutatorsValue; if (CurrentAllMutatorsIndex >= 0 && CurrentAllMutatorsIndex < ListAvailableMutators.Count && MouseHelper.InputLeftButtonPressed() && MouseHelper.MouseStateCurrent.X >= LeftPanelX && MouseHelper.MouseStateCurrent.X < LeftPanelX + PanelWidth - 20) { SelectedAvailableMutatorsIndex = CurrentAllMutatorsIndex; ActiveMutator = ListAvailableMutators[CurrentAllMutatorsIndex]; } int CurrentActiveMutatorsIndex = (int)(MouseHelper.MouseStateCurrent.Y - DrawY) / 20 + ActiveMutatorsValue; if (CurrentActiveMutatorsIndex >= 0 && CurrentActiveMutatorsIndex < ListActiveMutators.Count && MouseHelper.InputLeftButtonPressed() && MouseHelper.MouseStateCurrent.X >= RightPanelX && MouseHelper.MouseStateCurrent.X < RightPanelX + PanelWidth - 20) { SelectedActiveMutatorsIndex = CurrentActiveMutatorsIndex; ActiveMutator = ListActiveMutators[CurrentActiveMutatorsIndex]; } foreach (IUIElement ActiveButton in ArrayMenuButton) { ActiveButton.Update(gameTime); } }
public override void Draw(CustomSpriteBatch g) { DrawBox(g, new Vector2(LeftPanelX, PanelY), PanelWidth, PanelHeight, Color.White); DrawBox(g, new Vector2(LeftPanelX, PanelY), PanelWidth, 30, Color.White); DrawBox(g, new Vector2(LeftPanelX + PanelWidth - 132, PanelY + 3), 127, 24, Color.White); g.DrawStringRightAligned(fntText, "Available Mutators", new Vector2(LeftPanelX + PanelWidth - 15, PanelY + 6), Color.White); float DrawY = PanelY + 32; for (int M = AvailableMutatorsValue; M < ListAvailableMutators.Count; M++) { Mutator ActiveMutator = ListAvailableMutators[M]; g.DrawString(fntText, ActiveMutator.Name, new Vector2(LeftPanelX + 5, DrawY), Color.White); if (MouseHelper.MouseStateCurrent.X >= LeftPanelX && MouseHelper.MouseStateCurrent.X < LeftPanelX + PanelWidth - 20 && MouseHelper.MouseStateCurrent.Y >= DrawY && MouseHelper.MouseStateCurrent.Y < DrawY + 20) { g.Draw(sprPixel, new Rectangle(LeftPanelX + 5, (int)DrawY, PanelWidth - 30, 20), Color.FromNonPremultiplied(255, 255, 255, 127)); } if (M == SelectedAvailableMutatorsIndex) { g.Draw(sprPixel, new Rectangle(LeftPanelX + 5, (int)DrawY, PanelWidth - 30, 20), Color.FromNonPremultiplied(255, 255, 255, 127)); } DrawY += 20; if (DrawY >= PanelY + PanelHeight) { break; } } DrawBox(g, new Vector2(RightPanelX, PanelY), PanelWidth, PanelHeight, Color.White); DrawBox(g, new Vector2(RightPanelX, PanelY), PanelWidth, 30, Color.White); DrawBox(g, new Vector2(RightPanelX + PanelWidth - 115, PanelY + 3), 110, 24, Color.White); g.DrawStringRightAligned(fntText, "Active Mutators", new Vector2(RightPanelX + PanelWidth - 15, PanelY + 6), Color.White); DrawY = PanelY + 32; for (int M = AvailableMutatorsValue; M < ListActiveMutators.Count; M++) { Mutator ActiveMutator = ListActiveMutators[M]; g.DrawString(fntText, ActiveMutator.Name, new Vector2(RightPanelX + 5, DrawY), Color.White); if (MouseHelper.MouseStateCurrent.X >= RightPanelX && MouseHelper.MouseStateCurrent.X < RightPanelX + PanelWidth - 20 && MouseHelper.MouseStateCurrent.Y >= DrawY && MouseHelper.MouseStateCurrent.Y < DrawY + 20) { g.Draw(sprPixel, new Rectangle(RightPanelX + 5, (int)DrawY, PanelWidth - 30, 20), Color.FromNonPremultiplied(255, 255, 255, 127)); } if (M == SelectedActiveMutatorsIndex) { g.Draw(sprPixel, new Rectangle(RightPanelX + 5, (int)DrawY, PanelWidth - 30, 20), Color.FromNonPremultiplied(255, 255, 255, 127)); } DrawY += 20; if (DrawY >= PanelY + PanelHeight) { break; } } int DescriptionBoxY = PanelY + PanelHeight + 20; int DescriptionWidth = (int)(Constants.Width * 0.94); int DescriptionHeight = (int)(Constants.Height * 0.2); DrawBox(g, new Vector2(LeftPanelX, DescriptionBoxY), DescriptionWidth, DescriptionHeight, Color.White); DrawBox(g, new Vector2(LeftPanelX, DescriptionBoxY), DescriptionWidth, 30, Color.White); DrawBox(g, new Vector2(LeftPanelX + DescriptionWidth - 115, DescriptionBoxY + 3), 110, 24, Color.White); g.DrawStringRightAligned(fntText, "Mutator Details", new Vector2(LeftPanelX + DescriptionWidth - 15, DescriptionBoxY + 6), Color.White); if (ActiveMutator != null) { TextHelper.DrawTextMultiline(g, fntText, TextHelper.FitToWidth(fntText, ActiveMutator.Description, DescriptionWidth - 15), TextHelper.TextAligns.Left, LeftPanelX + DescriptionWidth / 2, DescriptionBoxY + 30, DescriptionWidth - 15); } foreach (IUIElement ActiveButton in ArrayMenuButton) { ActiveButton.Draw(g); } }