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

WIP Quick match #336

Draft
wants to merge 19 commits into
base: develop
Choose a base branch
from
Draft
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
4 changes: 4 additions & 0 deletions ClientCore/ClientConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ public string GetThemePath(string themeName)

public string MPMapsIniPath => SafePath.CombineFilePath(clientDefinitionsIni.GetStringValue(SETTINGS, "MPMapsPath", SafePath.CombineFilePath("INI", "MPMaps.ini")));

public string ApiIniPath => clientDefinitionsIni.GetStringValue(SETTINGS, "QuickMatchPath", "INI/API.ini");

public string QuickMatchIniPath => clientDefinitionsIni.GetStringValue(SETTINGS, "QuickMatchPath", "INI/QuickMatch.ini");

public string KeyboardINI => clientDefinitionsIni.GetStringValue(SETTINGS, "KeyboardINI", "Keyboard.ini");

public int MinimumIngameWidth => clientDefinitionsIni.GetIntValue(SETTINGS, "MinimumIngameWidth", 640);
Expand Down
9 changes: 9 additions & 0 deletions ClientCore/Enums/ProgressBarModeEnum.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.ComponentModel;

namespace ClientCore.Enums;

public enum ProgressBarModeEnum
{
Determinate = 0,
Indeterminate = 1
}
11 changes: 11 additions & 0 deletions ClientCore/Exceptions/ClientException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System;

namespace ClientCore.Exceptions
{
public class ClientException : Exception
{
public ClientException(string message, Exception innerException = null) : base(message, innerException)
{
}
}
}
14 changes: 14 additions & 0 deletions ClientCore/Exceptions/ClientRequestException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Net;

namespace ClientCore.Exceptions
{
public class ClientRequestException : ClientException
{
public HttpStatusCode? StatusCode { get; }

public ClientRequestException(string message, HttpStatusCode? statusCode = null) : base(message)
{
StatusCode = statusCode;
}
}
}
4 changes: 2 additions & 2 deletions ClientGUI/GameProcessLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static void StartGameProcess(WindowManager windowManager)
SafePath.DeleteFileIfExists(ProgramConstants.GamePath, "TI.LOG");
SafePath.DeleteFileIfExists(ProgramConstants.GamePath, "TS.LOG");

GameProcessStarting?.Invoke();
// GameProcessStarting?.Invoke();

if (UserINISettings.Instance.WindowedMode && UseQres && RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
Expand Down Expand Up @@ -139,7 +139,7 @@ public static void StartGameProcess(WindowManager windowManager)
}
}

GameProcessStarted?.Invoke();
// GameProcessStarted?.Invoke();

Logger.Log("Waiting for qres.dat or " + gameExecutableName + " to exit.");
}
Expand Down
8 changes: 5 additions & 3 deletions ClientGUI/Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
using Rampastring.XNAUI.XNAControls;
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace ClientGUI
{
Expand Down Expand Up @@ -69,6 +70,9 @@ private XNAControl GetControl(string controlName)
if (controlName == primaryControl.Name)
return primaryControl;

if (controlName == primaryControl.Parent.Name)
return primaryControl.Parent;

var control = Find(primaryControl.Children, controlName);
if (control == null)
throw new KeyNotFoundException($"Control '{controlName}' not found while parsing input '{Input}'");
Expand Down Expand Up @@ -104,7 +108,7 @@ public void SetPrimaryControl(XNAControl primaryControl)
public int GetExprValue(string input, XNAControl parsingControl)
{
this.parsingControl = parsingControl;
Input = input;
Input = Regex.Replace(input, @"\s", "");
tokenPlace = 0;
return GetExprValue();
}
Expand All @@ -115,8 +119,6 @@ private int GetExprValue()

while (true)
{
SkipWhitespace();

if (IsEndOfInput())
return value;

Expand Down
14 changes: 13 additions & 1 deletion ClientGUI/XNAClientDropDown.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public class XNAClientDropDown : XNADropDown
{
public ToolTip ToolTip { get; set; }

public bool DisabledMouseScroll { get; set; }

public XNAClientDropDown(WindowManager windowManager) : base(windowManager)
{
}
Expand Down Expand Up @@ -46,6 +48,16 @@ public override void OnMouseLeftDown()
UpdateToolTipBlock();
}

public override void OnMouseScrolled()
{
if (DisabledMouseScroll)
return;

base.OnMouseScrolled();
}

public void Close() => CloseDropDown();

protected override void CloseDropDown()
{
base.CloseDropDown();
Expand All @@ -60,4 +72,4 @@ protected void UpdateToolTipBlock()
ToolTip.Blocked = true;
}
}
}
}
85 changes: 85 additions & 0 deletions ClientGUI/XNAClientProgressBar.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
using System;
using ClientCore.Enums;
using Microsoft.Xna.Framework;
using Rampastring.Tools;
using Rampastring.XNAUI;
using Rampastring.XNAUI.XNAControls;

namespace ClientGUI;

public class XNAClientProgressBar : XNAProgressBar
{
public int Speed { get; set; } = 4;

public double WidthRatio { get; set; } = 0.25;

public ProgressBarModeEnum ProgressBarMode { get; set; }

private int _left { get; set; }

public XNAClientProgressBar(WindowManager windowManager) : base(windowManager)
{
}

public override void Update(GameTime gameTime)
{
_left = (_left + Speed) % Width;

base.Update(gameTime);
}

public override void Draw(GameTime gameTime)
{
switch (ProgressBarMode)
{
case ProgressBarModeEnum.Indeterminate:
DrawIndeterminateMode(gameTime);
return;
case ProgressBarModeEnum.Determinate:
default:
base.Draw(gameTime);
return;
}
}

public void DrawIndeterminateMode(GameTime gameTime)
{
Rectangle wrect = RenderRectangle();
int filledWidth = (int)(wrect.Width * WidthRatio);

for (int i = 0; i < BorderWidth; i++)
{
var rect = new Rectangle(wrect.X + i, wrect.Y + i, wrect.Width - i, wrect.Height - i);

Renderer.DrawRectangle(rect, BorderColor);
}

Renderer.FillRectangle(new Rectangle(wrect.X + BorderWidth, wrect.Y + BorderWidth, wrect.Width - BorderWidth * 2, wrect.Height - BorderWidth * 2), UnfilledColor);

if (_left + filledWidth > wrect.Width - BorderWidth * 2)
{
Renderer.FillRectangle(new Rectangle(wrect.X + BorderWidth, wrect.Y + BorderWidth, (_left + filledWidth) - (wrect.Width - (BorderWidth * 2)), wrect.Height - BorderWidth * 2), FilledColor);
}

Renderer.FillRectangle(new Rectangle(wrect.X + BorderWidth + _left, wrect.Y + BorderWidth, Math.Min(filledWidth, wrect.Width - (BorderWidth * 2) - _left), wrect.Height - BorderWidth * 2), FilledColor);
}

public override void ParseAttributeFromINI(IniFile iniFile, string key, string value)
{
switch (key)
{
case "WidthRatio":
WidthRatio = double.Parse(value);
return;
case "ProgressBarMode":
ProgressBarMode = (ProgressBarModeEnum)Enum.Parse(typeof(ProgressBarModeEnum), value);
return;
case "Speed":
Speed = int.Parse(value);
return;
default:
base.ParseAttributeFromINI(iniFile, key, value);
return;
}
}
}
7 changes: 6 additions & 1 deletion ClientGUI/XNAMessageBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,10 @@ private static void MsgBox_OKClicked(XNAMessageBox messageBox)
/// <param name="caption">The caption of the message box.</param>
/// <param name="description">The description in the message box.</param>
/// <returns>The XNAMessageBox instance that is created.</returns>
public static XNAMessageBox ShowYesNoDialog(WindowManager windowManager, string caption, string description)
public static XNAMessageBox ShowYesNoDialog(WindowManager windowManager, string caption, string description)
=> ShowYesNoDialog(windowManager, caption, description, null);

public static XNAMessageBox ShowYesNoDialog(WindowManager windowManager, string caption, string description, Action<XNAMessageBox> yesAction)
{
var panel = new DarkeningPanel(windowManager);
windowManager.AddAndInitializeControl(panel);
Expand All @@ -274,6 +277,8 @@ public static XNAMessageBox ShowYesNoDialog(WindowManager windowManager, string

panel.AddChild(msgBox);
msgBox.YesClickedAction = MsgBox_YesClicked;
if (yesAction != null)
msgBox.YesClickedAction += yesAction;
msgBox.NoClickedAction = MsgBox_NoClicked;

return msgBox;
Expand Down
12 changes: 12 additions & 0 deletions ClientGUI/XNAScrollablePanel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Rampastring.XNAUI;
using Rampastring.XNAUI.XNAControls;

namespace ClientGUI;

public class XNAScrollablePanel : XNAPanel
{
public XNAScrollablePanel(WindowManager windowManager) : base(windowManager)
{
DrawMode = ControlDrawMode.UNIQUE_RENDER_TARGET;
}
}
Loading