Skip to content

Commit

Permalink
Improved item consume behavior, scrolled text end clicks and item too…
Browse files Browse the repository at this point in the history
…ltip interactions
  • Loading branch information
Pyrdacor committed Mar 10, 2021
1 parent 8ca807a commit b4dcbcc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
16 changes: 10 additions & 6 deletions Ambermoon.Core/UI/Layout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,8 @@ bool ShowTextItem(uint index, uint subIndex)

void UseItem(ItemGrid itemGrid, int slot, ItemSlot itemSlot)
{
itemGrid.HideTooltip();

if (itemSlot.Flags.HasFlag(ItemSlotFlags.Broken))
{
SetInventoryMessage(game.DataNameProvider.CannotUseBrokenItems, true);
Expand Down Expand Up @@ -1592,11 +1594,6 @@ void UseItem(ItemGrid itemGrid, int slot, ItemSlot itemSlot)
return;
}

void PlayConsume(Action finishAction)
{
ItemAnimation.Play(game, RenderView, ItemAnimation.Type.Consume, itemGrid.GetSlotPosition(slot), finishAction);
}

if (item.Flags.HasFlag(ItemFlags.Readable) && item.TextIndex != 0)
{
if (!ShowTextItem(item.TextIndex, item.TextSubIndex))
Expand All @@ -1611,8 +1608,10 @@ void PlayConsume(Action finishAction)
}
else
{
PlayConsume(() =>
game.StartSequence();
DestroyItem(itemSlot, TimeSpan.FromMilliseconds(50), true, () =>
{
game.EndSequence();
game.CurrentSavegame.ActivateSpecialItem(item.SpecialItemPurpose);
SetInventoryMessage(game.DataNameProvider.SpecialItemActivated, true);
});
Expand Down Expand Up @@ -2076,6 +2075,8 @@ internal void SetInventoryMessage(string message, bool waitForClick = false)
{
if (waitForClick)
{
foreach (var itemGrid in itemGrids)
itemGrid.HideTooltip();
inventoryMessage?.Destroy();
game.CursorType = CursorType.Click;
inventoryMessage = AddScrollableText(new Rect(21, 51, 162, 14), game.ProcessText(message));
Expand Down Expand Up @@ -2351,6 +2352,9 @@ void ApplyItemRemoveEffects()
{
game.EquipmentRemoved(itemSlot.ItemIndex, itemSlot.Amount, itemSlot.Flags.HasFlag(ItemSlotFlags.Cursed));
}

if (game.CurrentWindow.Window == Window.Inventory)
game.UpdateCharacterInfo();
}

if (consumed)
Expand Down
6 changes: 5 additions & 1 deletion Ambermoon.Core/UI/Popup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,11 @@ public UIText AddText(Rect bounds, IText text, TextColor textColor, TextAlign te
{
bool closeAfterScroll = CloseOnClick;
CloseOnClick = false;
uiText.Scrolled += scrolledToEnd => CloseOnClick = closeAfterScroll && scrolledToEnd;
uiText.Scrolled += scrolledToEnd =>
{
if (closeAfterScroll && scrolledToEnd)
game.ClosePopup();
};
}
return uiText;
}
Expand Down

0 comments on commit b4dcbcc

Please sign in to comment.