Skip to content

Commit

Permalink
Merge branch 'diasurgical:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
ikonomov authored Aug 27, 2023
2 parents 57921d7 + 45dbe6a commit 75a386b
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 38 deletions.
6 changes: 6 additions & 0 deletions Source/diablo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,12 @@ void RightMouseDown(bool isShiftHeld)
return;
}

if (qtextflag) {
qtextflag = false;
stream_stop();
return;
}

if (DoomFlag) {
doom_close();
return;
Expand Down
8 changes: 5 additions & 3 deletions Source/engine/render/scrollrt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,21 +263,23 @@ void DrawCursor(const Surface &out)

// Copy the buffer before the item cursor and its 1px outline are drawn to a temporary buffer.
const int outlineWidth = !MyPlayer->HoldItem.isEmpty() ? 1 : 0;
Displacement offset = !MyPlayer->HoldItem.isEmpty() ? Displacement { cursSize / 2 } : Displacement { 0 };
Point cursPosition = MousePosition - offset;

Rectangle &rect = cursor.rect;
rect.position.x = MousePosition.x - outlineWidth;
rect.position.x = cursPosition.x - outlineWidth;
rect.size.width = cursSize.width + 2 * outlineWidth;
Clip(rect.position.x, rect.size.width, out.w());

rect.position.y = MousePosition.y - outlineWidth;
rect.position.y = cursPosition.y - outlineWidth;
rect.size.height = cursSize.height + 2 * outlineWidth;
Clip(rect.position.y, rect.size.height, out.h());

if (rect.size.width == 0 || rect.size.height == 0)
return;

BlitCursor(cursor.behindBuffer, rect.size.width, &out[rect.position], out.pitch(), rect.size.width, rect.size.height);
DrawSoftwareCursor(out, MousePosition + Displacement { 0, cursSize.height - 1 }, pcurs);
DrawSoftwareCursor(out, cursPosition + Displacement { 0, cursSize.height - 1 }, pcurs);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Source/error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void InitNextLines()
/** Maps from error_id to error message. */
const char *const MsgStrings[] = {
"",
N_("No automap available in town"),
N_("Game saved"),
N_("No multiplayer functions in demo"),
N_("Direct Sound Creation Failed"),
N_("Not available in shareware version"),
Expand Down
2 changes: 1 addition & 1 deletion Source/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace devilution {

enum diablo_message : uint8_t {
EMSG_NONE,
EMSG_NO_AUTOMAP_IN_TOWN,
EMSG_GAME_SAVED,
EMSG_NO_MULTIPLAYER_IN_DEMO,
EMSG_DIRECT_SOUND_FAILED,
EMSG_NOT_IN_SHAREWARE,
Expand Down
1 change: 1 addition & 0 deletions Source/gamemenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ void gamemenu_save_game(bool /*bActivate*/)
DrawAndBlit();
SaveGame();
ClrDiabloMsg();
InitDiabloMsg(EMSG_GAME_SAVED);
RedrawEverything();
NewCursor(CURSOR_HAND);
if (CornerStone.activated) {
Expand Down
13 changes: 0 additions & 13 deletions Source/inv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,6 @@ int FindSlotUnderCursor(Point cursorPosition, Size itemSize)
int i = cursorPosition.x;
int j = cursorPosition.y;

if (!IsHardwareCursor()) {
// offset the cursor position to match the hot pixel we'd use for a hardware cursor
i += itemSize.width * INV_SLOT_HALF_SIZE_PX;
j += itemSize.height * INV_SLOT_HALF_SIZE_PX;
}

for (int r = 0; r < NUM_XY_SLOTS; r++) {
int xo = GetRightPanel().position.x;
int yo = GetRightPanel().position.y;
Expand Down Expand Up @@ -555,8 +549,6 @@ void CheckInvPaste(Player &player, Point cursorPosition)
}
CalcPlrInv(player, true);
if (&player == MyPlayer) {
if (player.HoldItem.isEmpty() && !IsHardwareCursor())
SetCursorPos(MousePosition + Displacement { itemSize * INV_SLOT_HALF_SIZE_PX });
NewCursor(player.HoldItem);
}
}
Expand Down Expand Up @@ -820,11 +812,6 @@ void CheckInvCut(Player &player, Point cursorPosition, bool automaticMove, bool
holdItem.clear();
} else {
NewCursor(holdItem);
if (!IsHardwareCursor() && !dropItem) {
// For a hardware cursor, we set the "hot point" to the center of the item instead.
Size cursSize = GetInvItemSize(holdItem._iCurs + CURSOR_FIRSTITEM);
SetCursorPos(cursorPosition - Displacement(cursSize / 2));
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Source/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2826,7 +2826,7 @@ void StripTopGold(Player &player)
void ApplyPlrDamage(DamageType damageType, Player &player, int dam, int minHP /*= 0*/, int frac /*= 0*/, DeathReason deathReason /*= DeathReason::MonsterOrTrap*/)
{
int totalDamage = (dam << 6) + frac;
if (&player == MyPlayer) {
if (&player == MyPlayer && player._pHitPoints > 0) {
AddFloatingNumber(damageType, player, totalDamage);
}
if (totalDamage > 0 && player.pManaShield) {
Expand Down
23 changes: 4 additions & 19 deletions Source/qol/stash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,10 @@ void CheckStashPaste(Point cursorPosition)
Player &player = *MyPlayer;

const Size itemSize = GetInventorySize(player.HoldItem);
const Displacement hotPixelOffset = Displacement(itemSize * INV_SLOT_HALF_SIZE_PX);
if (IsHardwareCursor()) {
// It's more natural to select the top left cell of the region the sprite is overlapping when putting an item
// into an inventory grid, so compensate for the adjusted hot pixel of hardware cursors.
cursorPosition -= hotPixelOffset;
}

// It's more natural to select the top left cell of the region the sprite is overlapping when putting an item
// into an inventory grid, so compensate for the adjusted hot pixel of item cursors.
cursorPosition -= Displacement(itemSize * INV_SLOT_HALF_SIZE_PX);

if (player.HoldItem._itype == ItemType::Gold) {
if (Stash.gold > std::numeric_limits<int>::max() - player.HoldItem._ivalue)
Expand All @@ -103,10 +101,6 @@ void CheckStashPaste(Point cursorPosition)
player.HoldItem.clear();
PlaySFX(IS_GOLD);
Stash.dirty = true;
if (!IsHardwareCursor()) {
// To make software cursors behave like hardware cursors we need to adjust the hand cursor position manually
SetCursorPos(cursorPosition + hotPixelOffset);
}
NewCursor(CURSOR_HAND);
return;
}
Expand Down Expand Up @@ -157,10 +151,6 @@ void CheckStashPaste(Point cursorPosition)

Stash.dirty = true;

if (player.HoldItem.isEmpty() && !IsHardwareCursor()) {
// To make software cursors behave like hardware cursors we need to adjust the hand cursor position manually
SetCursorPos(cursorPosition + hotPixelOffset);
}
NewCursor(player.HoldItem);
}

Expand Down Expand Up @@ -235,11 +225,6 @@ void CheckStashCut(Point cursorPosition, bool automaticMove)
holdItem.clear();
} else {
NewCursor(holdItem);
if (!IsHardwareCursor()) {
// For a hardware cursor, we set the "hot point" to the center of the item instead.
Size cursSize = GetInvItemSize(holdItem._iCurs + CURSOR_FIRSTITEM);
SetCursorPos(cursorPosition - Displacement(cursSize / 2));
}
}
}
}
Expand Down
Binary file modified test/fixtures/timedemo/WarriorLevel1to2/demo_0.dmo
Binary file not shown.

0 comments on commit 75a386b

Please sign in to comment.