Skip to content

Commit

Permalink
Merge pull request #394 from ethanmoffat/release_fixes
Browse files Browse the repository at this point in the history
Fixes for v1 release
  • Loading branch information
ethanmoffat authored Nov 4, 2024
2 parents 1ceb620 + b886fe2 commit e5a99d2
Show file tree
Hide file tree
Showing 57 changed files with 375 additions and 166 deletions.
15 changes: 9 additions & 6 deletions EOLib/Domain/Character/AttackValidationActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
using EOLib.Domain.Extensions;
using EOLib.Domain.Map;
using EOLib.IO.Repositories;
using Optional;
using Optional.Collections;

namespace EOLib.Domain.Character
{
Expand Down Expand Up @@ -39,12 +41,13 @@ public AttackValidationError ValidateCharacterStateBeforeAttacking()

var rp = _characterProvider.MainCharacter.RenderProperties;

var isRangedWeapon = _eifFileProvider.EIFFile
.Where(x => x.Type == IO.ItemType.Weapon && x.SubType == IO.ItemSubType.Ranged)
.Any(x => x.DollGraphic == rp.WeaponGraphic);
var isArrows = _eifFileProvider.EIFFile
.Where(x => x.Type == IO.ItemType.Shield && x.SubType == IO.ItemSubType.Arrows)
.Any(x => x.DollGraphic == rp.ShieldGraphic);
var matchingWeapon = _eifFileProvider.EIFFile
.SingleOrNone(x => x.DollGraphic == rp.WeaponGraphic && x.Type == IO.ItemType.Weapon);
var matchingArrows = _eifFileProvider.EIFFile
.SingleOrNone(x => x.DollGraphic == rp.ShieldGraphic && x.Type == IO.ItemType.Shield);

var isRangedWeapon = matchingWeapon.Map(x => x.SubType == IO.ItemSubType.Ranged).ValueOr(false);
var isArrows = matchingArrows.Map(x => x.SubType == IO.ItemSubType.Arrows).ValueOr(false);

if (isRangedWeapon && (rp.ShieldGraphic == 0 || !isArrows))
return AttackValidationError.MissingArrows;
Expand Down
10 changes: 5 additions & 5 deletions EndlessClient/.config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,31 @@
"isRoot": true,
"tools": {
"dotnet-mgcb": {
"version": "3.8.1.303",
"version": "3.8.2.1105",
"commands": [
"mgcb"
]
},
"dotnet-mgcb-editor": {
"version": "3.8.1.303",
"version": "3.8.2.1105",
"commands": [
"mgcb-editor"
]
},
"dotnet-mgcb-editor-linux": {
"version": "3.8.1.303",
"version": "3.8.2.1105",
"commands": [
"mgcb-editor-linux"
]
},
"dotnet-mgcb-editor-windows": {
"version": "3.8.1.303",
"version": "3.8.2.1105",
"commands": [
"mgcb-editor-windows"
]
},
"dotnet-mgcb-editor-mac": {
"version": "3.8.1.303",
"version": "3.8.2.1105",
"commands": [
"mgcb-editor-mac"
]
Expand Down
2 changes: 1 addition & 1 deletion EndlessClient/ControlSets/BackButtonControlSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private XNAButton GetBackButton()
DrawOrder = 100,
ClickArea = new Rectangle(4, 16, 16, 16)
};
button.OnClick += DoBackButtonClick;
button.OnMouseDown += DoBackButtonClick;

_clientWindowSizeRepository.GameWindowSizeChanged += (o, e) =>
{
Expand Down
14 changes: 10 additions & 4 deletions EndlessClient/ControlSets/CreateAccountControlSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using EndlessClient.GameExecution;
using EndlessClient.Input;
using EndlessClient.Rendering;
using EndlessClient.UIControls;
using EOLib;
using EOLib.Domain.Account;
using EOLib.Graphics;
Expand Down Expand Up @@ -148,7 +149,7 @@ private IXNATextBox AccountInputTextBoxCreationHelper(GameControlIdentifier whic
//set the second 3 Y coord to start at 260 and move up by 51 each time
var txtYCoord = (i < 3 ? 69 : 260) + i % 3 * 51;
var drawArea = new Rectangle(358, txtYCoord, 240, _textBoxBackground.Height);
return new XNATextBox(drawArea,
return new ClearableTextBox(drawArea,
Constants.FontSize08,
_textBoxBackground,
_textBoxLeft,
Expand All @@ -169,7 +170,7 @@ private IXNAButton GetCreateAccountCancelButton()
new Vector2(481, 417),
new Rectangle(0, 40, 120, 40),
new Rectangle(120, 40, 120, 40));
button.OnClick += (o, e) => _mainButtonController.GoToInitialState();
button.OnMouseDown += (o, e) => _mainButtonController.GoToInitialState();
return button;
}

Expand All @@ -192,7 +193,7 @@ private IXNAPanel GetCreateAccountLabels()
protected override IXNAButton GetCreateButton()
{
var button = base.GetCreateButton();
button.OnClick += DoCreateAccount;
button.OnMouseDown += DoCreateAccount;
return button;
}

Expand All @@ -207,7 +208,12 @@ private void DoCreateAccount(object sender, EventArgs e)
_tbRealName.Text,
_tbLocation.Text,
_tbEmail.Text));
_createAccountTask.ContinueWith(_ => _createAccountTask = null);
_createAccountTask
.ContinueWith(t =>
{
_createAccountTask = null;
t.ThrowIfFaulted();
});
}
}
}
Expand Down
15 changes: 10 additions & 5 deletions EndlessClient/ControlSets/InitialControlSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,28 +83,28 @@ public override IGameComponent FindComponentByControlIdentifier(GameControlIdent
private IXNAButton GetMainCreateAccountButton()
{
var button = MainButtonCreationHelper(GameControlIdentifier.InitialCreateAccount);
button.OnClick += (o, e) => AsyncMainButtonClick(_mainButtonController.ClickCreateAccount);
button.OnMouseDown += (o, e) => AsyncMainButtonClick(_mainButtonController.ClickCreateAccount);
return button;
}

private IXNAButton GetMainLoginButton()
{
var button = MainButtonCreationHelper(GameControlIdentifier.InitialLogin);
button.OnClick += (o, e) => AsyncMainButtonClick(_mainButtonController.ClickLogin);
button.OnMouseDown += (o, e) => AsyncMainButtonClick(_mainButtonController.ClickLogin);
return button;
}

private IXNAButton GetViewCreditsButton()
{
var button = MainButtonCreationHelper(GameControlIdentifier.InitialViewCredits);
button.OnClick += (o, e) => _mainButtonController.ClickViewCredits();
button.OnMouseDown += (o, e) => _mainButtonController.ClickViewCredits();
return button;
}

private IXNAButton GetExitButton()
{
var button = MainButtonCreationHelper(GameControlIdentifier.InitialExitGame);
button.OnClick += (o, e) => _mainButtonController.ClickExit();
button.OnMouseDown += (o, e) => _mainButtonController.ClickExit();
return button;
}

Expand All @@ -113,7 +113,12 @@ private void AsyncMainButtonClick(Func<Task> clickHandler)
if (_mainButtonClickTask == null)
{
_mainButtonClickTask = clickHandler();
_mainButtonClickTask.ContinueWith(_ => _mainButtonClickTask = null);
_mainButtonClickTask
.ContinueWith(t =>
{
_mainButtonClickTask = null;
t.ThrowIfFaulted();
});
}
}

Expand Down
11 changes: 8 additions & 3 deletions EndlessClient/ControlSets/LoggedInControlSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ private IXNAButton GetPasswordButton()
new Vector2(454, 417),
new Rectangle(0, 120, 120, 40),
new Rectangle(120, 120, 120, 40));
button.OnClick += (o, e) => AsyncButtonAction(_accountController.ChangePassword);
button.OnMouseDown += (o, e) => AsyncButtonAction(_accountController.ChangePassword);
return button;
}

protected override IXNAButton GetCreateButton()
{
var button = base.GetCreateButton();
button.OnClick += (o, e) => AsyncButtonAction(_characterManagementController.CreateCharacter);
button.OnMouseDown += (o, e) => AsyncButtonAction(_characterManagementController.CreateCharacter);
return button;
}

Expand All @@ -99,7 +99,12 @@ private void AsyncButtonAction(Func<Task> clickHandler)
if (_loggedInActionTask == null)
{
_loggedInActionTask = clickHandler();
_loggedInActionTask.ContinueWith(_ => _loggedInActionTask = null);
_loggedInActionTask
.ContinueWith(t =>
{
_loggedInActionTask = null;
t.ThrowIfFaulted();
});
}
}
}
Expand Down
16 changes: 11 additions & 5 deletions EndlessClient/ControlSets/LoginPromptControlSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using EndlessClient.Controllers;
using EndlessClient.GameExecution;
using EndlessClient.Input;
using EndlessClient.UIControls;
using EOLib;
using EOLib.Config;
using EOLib.Domain.Login;
Expand Down Expand Up @@ -90,7 +91,7 @@ private IXNAPictureBox GetLoginPanelBackground()

private IXNATextBox GetLoginUserNameTextBox()
{
var textBox = new XNATextBox(
var textBox = new ClearableTextBox(
new Rectangle(402, 322, 140, _textBoxBackground.Height),
Constants.FontSize08,
_textBoxBackground,
Expand All @@ -112,7 +113,7 @@ private IXNATextBox GetLoginUserNameTextBox()

private IXNATextBox GetLoginPasswordTextBox()
{
var textBox = new XNATextBox(
var textBox = new ClearableTextBox(
new Rectangle(402, 358, 140, _textBoxBackground.Height),
Constants.FontSize08,
_textBoxBackground,
Expand All @@ -139,7 +140,7 @@ private XNAButton GetLoginAccountButton()
{
DrawOrder = _personPicture.DrawOrder + 2
};
button.OnClick += DoLogin;
button.OnMouseDown += DoLogin;
return button;
}

Expand All @@ -149,7 +150,12 @@ private void DoLogin(object sender, EventArgs e)
{
var loginParameters = new LoginParameters(_tbUsername.Text, _tbPassword.Text);
_loginTask = _loginController.LoginToAccount(loginParameters);
_loginTask.ContinueWith(_ => _loginTask = null);
_loginTask
.ContinueWith(t =>
{
_loginTask = null;
t.ThrowIfFaulted();
});
}
}

Expand All @@ -159,7 +165,7 @@ private XNAButton GetLoginCancelButton()
{
DrawOrder = _personPicture.DrawOrder + 2
};
button.OnClick += (o, e) => _mainButtonController.GoToInitialState();
button.OnMouseDown += (o, e) => _mainButtonController.GoToInitialState();
return button;
}
}
Expand Down
22 changes: 22 additions & 0 deletions EndlessClient/Controllers/TaskExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Threading.Tasks;
using EndlessClient.Rendering;

namespace EndlessClient.Controllers
{
public static class TaskExtensions
{
public static Task ThrowIfFaulted(this Task t)
{
if (t.IsFaulted)
{
// Invoke any exception on the main game thread
// Exceptions thrown by tasks are quietly swallowed
// Invoking this on the main thread ensures the Update() loop catches it and
// handles it in the global exception handler (see EndlessGame::Update)
Task.Run(DispatcherGameComponent.Invoke(() => throw t.Exception).RunSynchronously);
}

return t;
}
}
}
2 changes: 1 addition & 1 deletion EndlessClient/Dialogs/Actions/InGameDialogActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ private void UseDefaultDialogSounds(ScrollingListDialog dialog)
UseDefaultDialogSounds((BaseEODialog)dialog);

foreach (var button in dialog.ChildControls.OfType<IXNAButton>())
button.OnClick += Handler;
button.OnMouseDown += Handler;

void Handler(object sender, EventArgs e) => _sfxPlayer.PlaySfx(SoundEffectID.DialogButtonClick);
}
Expand Down
2 changes: 1 addition & 1 deletion EndlessClient/Dialogs/BarberDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private void InitializeCharacterControl()
private void InitializeDialogItems(IEODialogButtonService dialogButtonService)
{
var cancel = CreateButton(dialogButtonService, new Vector2(215, 151), SmallButton.Cancel);
cancel.OnClick += (_, _) => Close(XNADialogResult.Cancel);
cancel.OnMouseDown += (_, _) => Close(XNADialogResult.Cancel);

_changeHairItem = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 0)
{
Expand Down
4 changes: 2 additions & 2 deletions EndlessClient/Dialogs/BardDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public BardDialog(INativeGraphicsManager nativeGraphicsManager,
dialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Cancel));
cancel.Initialize();
cancel.SetParentControl(this);
cancel.OnClick += (_, _) => Close(XNADialogResult.Cancel);
cancel.OnMouseDown += (_, _) => Close(XNADialogResult.Cancel);

CenterInGameView();

Expand All @@ -63,7 +63,7 @@ protected override void OnDrawControl(GameTime gameTime)
});
}

protected override bool HandleClick(IXNAControl control, MouseEventArgs eventArgs)
protected override bool HandleMouseDown(IXNAControl control, MouseEventArgs eventArgs)
{
if (eventArgs.Button == MouseButton.Left && _currentTick > 8)
{
Expand Down
8 changes: 4 additions & 4 deletions EndlessClient/Dialogs/BoardDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public BoardDialog(INativeGraphicsManager nativeGraphicsManager,
_state = BoardDialogState.ViewList;
_cachedPostInfo = new HashSet<BoardPostInfo>();

_subject = new XNATextBox(new Rectangle(150, 44, 315, 19), Constants.FontSize08, caretTexture: contentProvider.Textures[ContentProvider.Cursor])
_subject = new ClearableTextBox(new Rectangle(150, 44, 315, 19), Constants.FontSize08, caretTexture: contentProvider.Textures[ContentProvider.Cursor])
{
TextAlignment = LabelAlignment.MiddleLeft,
TextColor = ColorConstants.LightGrayText,
Expand All @@ -77,7 +77,7 @@ public BoardDialog(INativeGraphicsManager nativeGraphicsManager,
_subject.SetScrollWheelHandler(_scrollBar);
_subject.SetParentControl(this);

_message = new XNATextBox(new Rectangle(18, 80, 430, 168), Constants.FontSize08, caretTexture: contentProvider.Textures[ContentProvider.Cursor])
_message = new ClearableTextBox(new Rectangle(18, 80, 430, 168), Constants.FontSize08, caretTexture: contentProvider.Textures[ContentProvider.Cursor])
{
TextAlignment = LabelAlignment.TopLeft,
TextColor = ColorConstants.LightGrayText,
Expand All @@ -91,8 +91,8 @@ public BoardDialog(INativeGraphicsManager nativeGraphicsManager,
_message.SetScrollWheelHandler(_scrollBar);
_message.SetParentControl(this);

_add.OnClick += AddButton_Click;
_delete.OnClick += DeleteButton_Click;
_add.OnMouseDown += AddButton_Click;
_delete.OnMouseDown += DeleteButton_Click;
}

public override void Initialize()
Expand Down
6 changes: 3 additions & 3 deletions EndlessClient/Dialogs/ChangePasswordDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public ChangePasswordDialog(INativeGraphicsManager nativeGraphicsManager,
_inputBoxes = new IXNATextBox[4];
for (int i = 0; i < _inputBoxes.Length; ++i)
{
var tb = new XNATextBox(new Rectangle(198, 60 + i * 30, 137, 19), Constants.FontSize08, caretTexture: cursorTexture)
var tb = new ClearableTextBox(new Rectangle(198, 60 + i * 30, 137, 19), Constants.FontSize08, caretTexture: cursorTexture)
{
LeftPadding = 5,
DefaultText = " ",
Expand All @@ -70,14 +70,14 @@ public ChangePasswordDialog(INativeGraphicsManager nativeGraphicsManager,
new Vector2(157, 195),
dialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Ok),
dialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Ok));
_ok.OnClick += OnButtonPressed;
_ok.OnMouseDown += OnButtonPressed;

_cancel = new XNAButton(
dialogButtonService.SmallButtonSheet,
new Vector2(250, 195),
dialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Cancel),
dialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Cancel));
_cancel.OnClick += (s, e) => Close(XNADialogResult.Cancel);
_cancel.OnMouseDown += (s, e) => Close(XNADialogResult.Cancel);

CenterInGameView();
}
Expand Down
Loading

0 comments on commit e5a99d2

Please sign in to comment.