|
|
|
|
@ -14,7 +14,6 @@ namespace dvl {
|
|
|
|
|
|
|
|
|
|
bool sgbControllerActive = false; |
|
|
|
|
coords speedspellscoords[50]; |
|
|
|
|
const int repeatRate = 100; |
|
|
|
|
int speedspellcount = 0; |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -33,7 +32,6 @@ bool InGameMenu()
|
|
|
|
|
|
|
|
|
|
namespace { |
|
|
|
|
|
|
|
|
|
DWORD invmove = 0; |
|
|
|
|
int slot = SLOTXY_INV_FIRST; |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -446,22 +444,16 @@ void Interact()
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void AttrIncBtnSnap(MoveDirectionY dir) |
|
|
|
|
void AttrIncBtnSnap(AxisDirection dir) |
|
|
|
|
{ |
|
|
|
|
if (dir == MoveDirectionY_NONE) { |
|
|
|
|
invmove = 0; |
|
|
|
|
static AxisDirectionRepeater repeater; |
|
|
|
|
dir = repeater.Get(dir); |
|
|
|
|
if (dir.y == AxisDirectionY_NONE) |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (chrbtnactive && plr[myplr]._pStatPts <= 0) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
DWORD ticks = SDL_GetTicks(); |
|
|
|
|
if (ticks - invmove < repeatRate) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
invmove = ticks; |
|
|
|
|
|
|
|
|
|
// first, find our cursor location
|
|
|
|
|
int slot = 0; |
|
|
|
|
for (int i = 0; i < 4; i++) { |
|
|
|
|
@ -474,10 +466,10 @@ void AttrIncBtnSnap(MoveDirectionY dir)
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (dir == MoveDirectionY_UP) { |
|
|
|
|
if (dir.y == AxisDirectionY_UP) { |
|
|
|
|
if (slot > 0) |
|
|
|
|
--slot; |
|
|
|
|
} else if (dir == MoveDirectionY_DOWN) { |
|
|
|
|
} else if (dir.y == AxisDirectionY_DOWN) { |
|
|
|
|
if (slot < 3) |
|
|
|
|
++slot; |
|
|
|
|
} |
|
|
|
|
@ -493,18 +485,13 @@ void AttrIncBtnSnap(MoveDirectionY dir)
|
|
|
|
|
* If mouse coords are at SLOTXY_CHEST_LAST, consider this center of equipment |
|
|
|
|
* small inventory squares are 29x29 (roughly) |
|
|
|
|
*/ |
|
|
|
|
void InvMove(MoveDirection dir) |
|
|
|
|
void InvMove(AxisDirection dir) |
|
|
|
|
{ |
|
|
|
|
if (dir.x == MoveDirectionX_NONE && dir.y == MoveDirectionY_NONE) { |
|
|
|
|
invmove = 0; |
|
|
|
|
static AxisDirectionRepeater repeater(/*min_interval_ms=*/100); |
|
|
|
|
dir = repeater.Get(dir); |
|
|
|
|
if (dir.x == AxisDirectionX_NONE && dir.y == AxisDirectionY_NONE) |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
DWORD ticks = SDL_GetTicks(); |
|
|
|
|
if (ticks - invmove < repeatRate) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
invmove = ticks; |
|
|
|
|
int x = MouseX; |
|
|
|
|
int y = MouseY; |
|
|
|
|
|
|
|
|
|
@ -529,7 +516,7 @@ void InvMove(MoveDirection dir)
|
|
|
|
|
slot = SLOTXY_BELT_LAST; |
|
|
|
|
|
|
|
|
|
// when item is on cursor, this is the real cursor XY
|
|
|
|
|
if (dir.x == MoveDirectionX_LEFT) { |
|
|
|
|
if (dir.x == AxisDirectionX_LEFT) { |
|
|
|
|
if (slot >= SLOTXY_HAND_RIGHT_FIRST && slot <= SLOTXY_HAND_RIGHT_LAST) { |
|
|
|
|
x = InvRect[SLOTXY_CHEST_FIRST].X + RIGHT_PANEL + (INV_SLOT_SIZE_PX / 2); |
|
|
|
|
y = InvRect[SLOTXY_CHEST_FIRST].Y - (INV_SLOT_SIZE_PX / 2); |
|
|
|
|
@ -561,7 +548,7 @@ void InvMove(MoveDirection dir)
|
|
|
|
|
x = InvRect[slot].X + PANEL_LEFT + (INV_SLOT_SIZE_PX / 2); |
|
|
|
|
y = InvRect[slot].Y + PANEL_TOP - (INV_SLOT_SIZE_PX / 2); |
|
|
|
|
} |
|
|
|
|
} else if (dir.x == MoveDirectionX_RIGHT) { |
|
|
|
|
} else if (dir.x == AxisDirectionX_RIGHT) { |
|
|
|
|
if (slot == SLOTXY_RING_LEFT) { |
|
|
|
|
x = InvRect[SLOTXY_RING_RIGHT].X + RIGHT_PANEL + (INV_SLOT_SIZE_PX / 2); |
|
|
|
|
y = InvRect[SLOTXY_RING_RIGHT].Y - (INV_SLOT_SIZE_PX / 2); |
|
|
|
|
@ -592,7 +579,7 @@ void InvMove(MoveDirection dir)
|
|
|
|
|
y = InvRect[slot].Y + PANEL_TOP - (INV_SLOT_SIZE_PX / 2); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (dir.y == MoveDirectionY_UP) { |
|
|
|
|
if (dir.y == AxisDirectionY_UP) { |
|
|
|
|
if (slot > 24 && slot <= 27) { // first 3 general slots
|
|
|
|
|
x = InvRect[SLOTXY_RING_LEFT].X + RIGHT_PANEL + (INV_SLOT_SIZE_PX / 2); |
|
|
|
|
y = InvRect[SLOTXY_RING_LEFT].Y - (INV_SLOT_SIZE_PX / 2); |
|
|
|
|
@ -626,7 +613,7 @@ void InvMove(MoveDirection dir)
|
|
|
|
|
x = InvRect[slot].X + RIGHT_PANEL + (INV_SLOT_SIZE_PX / 2); |
|
|
|
|
y = InvRect[slot].Y - (INV_SLOT_SIZE_PX / 2); |
|
|
|
|
} |
|
|
|
|
} else if (dir.y == MoveDirectionY_DOWN) { |
|
|
|
|
} else if (dir.y == AxisDirectionY_DOWN) { |
|
|
|
|
if (slot >= SLOTXY_HEAD_FIRST && slot <= SLOTXY_HEAD_LAST) { |
|
|
|
|
x = InvRect[SLOTXY_CHEST_FIRST].X + RIGHT_PANEL + (INV_SLOT_SIZE_PX / 2); |
|
|
|
|
y = InvRect[SLOTXY_CHEST_FIRST].Y - (INV_SLOT_SIZE_PX / 2); |
|
|
|
|
@ -688,18 +675,12 @@ bool HSExists(int x, int y)
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void HotSpellMove(MoveDirection dir) |
|
|
|
|
void HotSpellMove(AxisDirection dir) |
|
|
|
|
{ |
|
|
|
|
if (dir.x == MoveDirectionX_NONE && dir.y == MoveDirectionY_NONE) { |
|
|
|
|
invmove = 0; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
DWORD ticks = SDL_GetTicks(); |
|
|
|
|
if (ticks - invmove < repeatRate) { |
|
|
|
|
static AxisDirectionRepeater repeater; |
|
|
|
|
dir = repeater.Get(dir); |
|
|
|
|
if (dir.x == AxisDirectionX_NONE && dir.y == AxisDirectionY_NONE) |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
invmove = ticks; |
|
|
|
|
|
|
|
|
|
int spbslot = plr[myplr]._pRSpell; |
|
|
|
|
for (int r = 0; r < speedspellcount; r++) { |
|
|
|
|
@ -715,23 +696,23 @@ void HotSpellMove(MoveDirection dir)
|
|
|
|
|
int x = speedspellscoords[spbslot].x; |
|
|
|
|
int y = speedspellscoords[spbslot].y; |
|
|
|
|
|
|
|
|
|
if (dir.x == MoveDirectionX_LEFT) { |
|
|
|
|
if (dir.x == AxisDirectionX_LEFT) { |
|
|
|
|
if (spbslot < speedspellcount - 1) { |
|
|
|
|
x = speedspellscoords[spbslot + 1].x; |
|
|
|
|
y = speedspellscoords[spbslot + 1].y; |
|
|
|
|
} |
|
|
|
|
} else if (dir.x == MoveDirectionX_RIGHT) { |
|
|
|
|
} else if (dir.x == AxisDirectionX_RIGHT) { |
|
|
|
|
if (spbslot > 0) { |
|
|
|
|
x = speedspellscoords[spbslot - 1].x; |
|
|
|
|
y = speedspellscoords[spbslot - 1].y; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (dir.y == MoveDirectionY_UP) { |
|
|
|
|
if (dir.y == AxisDirectionY_UP) { |
|
|
|
|
if (HSExists(x, y - SPLICONLENGTH)) { |
|
|
|
|
y -= SPLICONLENGTH; |
|
|
|
|
} |
|
|
|
|
} else if (dir.y == MoveDirectionY_DOWN) { |
|
|
|
|
} else if (dir.y == AxisDirectionY_DOWN) { |
|
|
|
|
if (HSExists(x, y + SPLICONLENGTH)) { |
|
|
|
|
y += SPLICONLENGTH; |
|
|
|
|
} |
|
|
|
|
@ -742,23 +723,15 @@ void HotSpellMove(MoveDirection dir)
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SpellBookMove(MoveDirection dir) |
|
|
|
|
void SpellBookMove(AxisDirection dir) |
|
|
|
|
{ |
|
|
|
|
if (dir.x == MoveDirectionX_NONE && dir.y == MoveDirectionY_NONE) { |
|
|
|
|
invmove = 0; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
static AxisDirectionRepeater repeater; |
|
|
|
|
dir = repeater.Get(dir); |
|
|
|
|
|
|
|
|
|
DWORD ticks = SDL_GetTicks(); |
|
|
|
|
if (ticks - invmove < repeatRate) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
invmove = ticks; |
|
|
|
|
|
|
|
|
|
if (dir.x == MoveDirectionX_LEFT) { |
|
|
|
|
if (dir.x == AxisDirectionX_LEFT) { |
|
|
|
|
if (sbooktab > 0) |
|
|
|
|
sbooktab--; |
|
|
|
|
} else if (dir.x == MoveDirectionX_RIGHT) { |
|
|
|
|
} else if (dir.x == AxisDirectionX_RIGHT) { |
|
|
|
|
if ((gbIsHellfire && sbooktab < 4) || (!gbIsHellfire && sbooktab < 3)) |
|
|
|
|
sbooktab++; |
|
|
|
|
} |
|
|
|
|
@ -827,12 +800,12 @@ bool IsPathBlocked(int x, int y, int dir)
|
|
|
|
|
return !PosOkPlayer(myplr, d1x, d1y) && !PosOkPlayer(myplr, d2x, d2y); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void WalkInDir(MoveDirection dir) |
|
|
|
|
void WalkInDir(AxisDirection dir) |
|
|
|
|
{ |
|
|
|
|
const int x = plr[myplr]._pfutx; |
|
|
|
|
const int y = plr[myplr]._pfuty; |
|
|
|
|
|
|
|
|
|
if (dir.x == MoveDirectionX_NONE && dir.y == MoveDirectionY_NONE) { |
|
|
|
|
if (dir.x == AxisDirectionX_NONE && dir.y == AxisDirectionY_NONE) { |
|
|
|
|
if (sgbControllerActive && plr[myplr].walkpath[0] != WALK_NONE && plr[myplr].destAction == ACTION_NONE) |
|
|
|
|
NetSendCmdLoc(true, CMD_WALKXY, x, y); // Stop walking
|
|
|
|
|
return; |
|
|
|
|
@ -849,27 +822,56 @@ void WalkInDir(MoveDirection dir)
|
|
|
|
|
NetSendCmdLoc(true, CMD_WALKXY, dx, dy); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void QuestLogMove(AxisDirection move_dir) |
|
|
|
|
{ |
|
|
|
|
static AxisDirectionRepeater repeater; |
|
|
|
|
move_dir = repeater.Get(move_dir); |
|
|
|
|
if (move_dir.y == AxisDirectionY_UP) |
|
|
|
|
QuestlogUp(); |
|
|
|
|
else if (move_dir.y == AxisDirectionY_DOWN) |
|
|
|
|
QuestlogDown(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
typedef void (*HandleLeftStickOrDPadFn)(dvl::AxisDirection); |
|
|
|
|
|
|
|
|
|
HandleLeftStickOrDPadFn GetLeftStickOrDPadGameUIHandler() |
|
|
|
|
{ |
|
|
|
|
if (invflag) { |
|
|
|
|
return &InvMove; |
|
|
|
|
} else if (chrflag && plr[myplr]._pStatPts > 0) { |
|
|
|
|
return &AttrIncBtnSnap; |
|
|
|
|
} else if (spselflag) { |
|
|
|
|
return &HotSpellMove; |
|
|
|
|
} else if (sbookflag) { |
|
|
|
|
return &SpellBookMove; |
|
|
|
|
} else if (questlog) { |
|
|
|
|
return &QuestLogMove; |
|
|
|
|
} |
|
|
|
|
return NULL; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void ProcessLeftStickOrDPadGameUI() { |
|
|
|
|
HandleLeftStickOrDPadFn handler = GetLeftStickOrDPadGameUIHandler(); |
|
|
|
|
if (handler != NULL) |
|
|
|
|
handler(GetLeftStickOrDpadDirection(true)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Movement() |
|
|
|
|
{ |
|
|
|
|
if (InGameMenu() || questlog |
|
|
|
|
if (InGameMenu() |
|
|
|
|
|| IsControllerButtonPressed(ControllerButton_BUTTON_START) |
|
|
|
|
|| IsControllerButtonPressed(ControllerButton_BUTTON_BACK)) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
MoveDirection move_dir = GetMoveDirection(); |
|
|
|
|
if (move_dir.x != MoveDirectionX_NONE || move_dir.y != MoveDirectionY_NONE) { |
|
|
|
|
AxisDirection move_dir = GetMoveDirection(); |
|
|
|
|
if (move_dir.x != AxisDirectionX_NONE || move_dir.y != AxisDirectionY_NONE) { |
|
|
|
|
sgbControllerActive = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (invflag) { |
|
|
|
|
InvMove(move_dir); |
|
|
|
|
} else if (chrflag && plr[myplr]._pStatPts > 0) { |
|
|
|
|
AttrIncBtnSnap(move_dir.y); |
|
|
|
|
} else if (spselflag) { |
|
|
|
|
HotSpellMove(move_dir); |
|
|
|
|
} else if (sbookflag) { |
|
|
|
|
SpellBookMove(move_dir); |
|
|
|
|
} else { |
|
|
|
|
// TODO: This should be called independently of game logic / tick rate.
|
|
|
|
|
ProcessLeftStickOrDPadGameUI(); |
|
|
|
|
|
|
|
|
|
if (GetLeftStickOrDPadGameUIHandler() == NULL) { |
|
|
|
|
WalkInDir(move_dir); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|