Skip to content

Commit dbd7222

Browse files
committed
floating numbers and alt highlight work with zoom
1 parent 2137ebd commit dbd7222

File tree

8 files changed

+80
-56
lines changed

8 files changed

+80
-56
lines changed

Infernity.zip

-4.18 KB
Binary file not shown.

Source/automap.cpp

Lines changed: 45 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ void __cdecl InitAutomap()
5757
signed int v15; // edx
5858
int size; // [esp+Ch] [ebp-4h]
5959

60-
int old_320 = ScreenWidth / 2;
61-
int old_32 = ScreenWidth / 20;
62-
int old_50 = 50*640/ScreenWidth;
63-
int old_5 = 5*640/ScreenWidth;
60+
int old_320 = 320;// ScreenWidth / 2;
61+
int old_32 = 32;// ScreenWidth / 20;
62+
int old_50 = 50;// 50 * 640 / ScreenWidth;
63+
int old_5 = 5;// 5 * 640 / ScreenWidth;
6464

6565
v0 = old_50;
6666
v1 = 0;
@@ -322,6 +322,35 @@ int GetItemRarity(int index) {
322322
return GetItemRarity(index, NULL, false);
323323
}
324324

325+
POINT adjustCoordsToZoom(int x, int y) {
326+
int targetHeight = GLOBAL_HEIGHT - GLOBAL_HEIGHT * globalScrollZoom / 200;
327+
int targetWidth = GLOBAL_WIDTH - GLOBAL_WIDTH * globalScrollZoom / 200;
328+
int widthDiff = GLOBAL_WIDTH - targetWidth;
329+
int heightDiff = GLOBAL_HEIGHT - targetHeight;
330+
int distToCenterX = abs(ScreenWidth / 2 - x);
331+
int distToCenterY = abs(ScreenHeight / 2 - y);
332+
if (x <= ScreenWidth / 2) {
333+
x = ScreenWidth / 2 - distToCenterX - distToCenterX * (globalScrollZoom) / 100;
334+
}
335+
else {
336+
x = ScreenWidth / 2 + distToCenterX + distToCenterX * (globalScrollZoom) / 100;
337+
}
338+
339+
if (y <= ScreenHeight / 2) {
340+
y = ScreenHeight / 2 - distToCenterY - distToCenterY * (globalScrollZoom) / 100;
341+
}
342+
else {
343+
y = ScreenHeight / 2 + distToCenterY + distToCenterY * (globalScrollZoom) / 100;
344+
}
345+
346+
POINT p;
347+
p.x = x;
348+
p.y = y;
349+
return p;
350+
351+
352+
}
353+
325354
void AddItemToDrawQueue(int x, int y, int id) {
326355

327356
if (lootFilterBroken == false) {
@@ -352,45 +381,11 @@ void AddItemToDrawQueue(int x, int y, int id) {
352381
if (lfd.show == false) { return; }
353382
int centerXOffset = GetTextWidth((char*)lfd.name.c_str()) ;
354383

355-
int targetHeight = GLOBAL_HEIGHT - GLOBAL_HEIGHT * globalScrollZoom / 200;
356-
int targetWidth = GLOBAL_WIDTH - GLOBAL_WIDTH * globalScrollZoom / 200;
357-
int widthDiff = GLOBAL_WIDTH - targetWidth;
358-
int heightDiff = GLOBAL_HEIGHT - targetHeight;
359-
360-
//x += widthDiff/4;
361-
//y += widthDiff/4;
362-
std::stringstream ss;
363-
364-
365-
366-
int distToCenterX = abs(ScreenWidth/2-x);
367-
int distToCenterY = abs(ScreenHeight / 2 - y);
368-
if (x <= ScreenWidth / 2) {
369-
x = ScreenWidth / 2 - distToCenterX - distToCenterX * (globalScrollZoom) / 100;
370-
}
371-
else {
372-
x = ScreenWidth / 2 + distToCenterX + distToCenterX * (globalScrollZoom) / 100;
373-
}
374-
375-
if (y <= ScreenHeight / 2) {
376-
y = ScreenHeight / 2 - distToCenterY - distToCenterY * (globalScrollZoom) / 100;
377-
}
378-
else {
379-
y = ScreenHeight / 2 + distToCenterY + distToCenterY * (globalScrollZoom) / 100;
380-
}
381-
382-
x -= centerXOffset / 2 + 20;
383-
y -= 193;
384-
385-
386-
387-
388-
//ss << x << " " << y << " ";
389-
390-
//NetSendCmdString(1 << myplr, ss.str().c_str());
391-
//x += x globalScrollZoom / 100;
392-
//y += y * globalScrollZoom / 100;
393-
drawQ.push_back(drawingQueue(x, y, GetTextWidth((char*)lfd.name.c_str()), 13, it->_ix, it->_iy, id, lfd.color2, lfd.name, 1, lfd.r, lfd.g,lfd.b));
384+
POINT p = adjustCoordsToZoom(x, y);
385+
x = p.x; y = p.y;
386+
x -= centerXOffset / 2 + 20;
387+
y -= 193;
388+
drawQ.push_back(drawingQueue(x, y, GetTextWidth((char*)lfd.name.c_str()), 13, it->_ix, it->_iy, id, lfd.color2, lfd.name, 1, lfd.r, lfd.g,lfd.b));
394389
}
395390

396391
void HighlightItemsNameOnMap()
@@ -1219,6 +1214,13 @@ void __cdecl DrawAutomapGame()
12191214
v0+=15;
12201215
}
12211216
PrintGameStr(8, v0, "INFERNITY", COL_RED);
1217+
v0 += 15;
1218+
1219+
int targetHeight = GLOBAL_HEIGHT - GLOBAL_HEIGHT * globalScrollZoom / 200;
1220+
int targetWidth = GLOBAL_WIDTH - GLOBAL_WIDTH * globalScrollZoom / 200;
1221+
std::stringstream res;
1222+
res << targetWidth << "x" << targetHeight;
1223+
PrintGameStr(8, v0, (char*)res.str().c_str(), COL_RED);
12221224
}
12231225
// 5CCB10: using guessed type char setlvlnum;
12241226
// 5CF31D: using guessed type char setlevel;

Source/diablo.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,12 +768,20 @@ LRESULT __stdcall GM_Game(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
768768
if ((short)HIWORD(wParam) < 0)
769769
{
770770
if (globalScrollZoom > 0) {
771+
int globalScrollZoom2 = globalScrollZoom - 5;
772+
int targetHeight = GLOBAL_HEIGHT - GLOBAL_HEIGHT * globalScrollZoom2 / 200;
773+
int targetWidth = GLOBAL_WIDTH - GLOBAL_WIDTH * globalScrollZoom2 / 200;
774+
if (targetHeight < 480 || targetWidth < 640) { return 0; }
771775
globalScrollZoom -= 5;
772776
}
773777
}
774778
else
775779
{
776780
if (globalScrollZoom < 100) {
781+
int globalScrollZoom2 = globalScrollZoom + 5;
782+
int targetHeight = GLOBAL_HEIGHT - GLOBAL_HEIGHT * globalScrollZoom2 / 200;
783+
int targetWidth = GLOBAL_WIDTH - GLOBAL_WIDTH * globalScrollZoom2 / 200;
784+
if (targetHeight < 480 || targetWidth < 640) { return 0; }
777785
globalScrollZoom += 5;
778786
}
779787
}

Source/engine.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ void setGameState(int state);
112112
void fatalLua(const char* message);
113113
void LuaInit();
114114
void DrawGame(int StartX, int StartY, bool isTown);
115+
POINT adjustCoordsToZoom(int x, int y);
116+
void AddToFloatingQueue(FloatingText ft);
115117

116118
extern std::map<std::string, bool> BoolConfig;
117119
extern std::map<std::string, int> IntConfig;

Source/player.cpp

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ void DrawFloatingTextAbovePlayer() {
216216

217217
int walkStandX = ScrollInfo._sxoff;// +plr[myplr]._pyoff;
218218
int walkStandY = ScrollInfo._syoff;// +plr[myplr]._pxoff;
219-
219+
220220
if (plr[myplr]._pmode == PM_WALK2 && ScrollInfo._sdir == 4) {
221221
walkStandX += 32;
222222
walkStandY += 16;
@@ -245,18 +245,29 @@ void DrawFloatingTextAbovePlayer() {
245245
int col = FloatingTextQueue[i].posY - plr[myplr].WorldY;
246246
int PlayerShiftY = 0;
247247
int PlayerShiftX = 0;
248-
x = 32 * (row - col) + (200 * (walkStandX) / 100 >> 1) - GetTextWidth((char*)text.c_str()) / 2;
249-
y = 16 * (row + col) + (200 * (walkStandY) / 100 >> 1) - 16;
248+
//x = 32 * (row - col) + (200 * (walkStandX) / 100 >> 1);
249+
//y = 16 * (row + col) + (200 * (walkStandY) / 100 >> 1) - 16;
250+
//walkStandX * (200-globalScrollZoom) / 200
251+
walkStandX += (walkStandX* globalScrollZoom ) / 100;
252+
walkStandY += (walkStandY* globalScrollZoom) / 100;
253+
x = 64 * (row - col) * (globalScrollZoom + 100) / 200 + walkStandX;
254+
y = 32 * (row + col) * (globalScrollZoom + 100) / 200 + walkStandY - 16;
250255

251256

252257
int drawXOffset = 0;
253-
if (invflag || sbookflag)
254-
drawXOffset -= 160;
255-
if (chrflag || questlog)
256-
drawXOffset += 160;
258+
//if (invflag || sbookflag)
259+
// drawXOffset -= 160;
260+
//if (chrflag || questlog)
261+
// drawXOffset += 160;
257262
x = x + ScreenWidth / 2;// 320 + drawXOffset;
258263
y = y + GetHeightDiff()/2;
259264
}
265+
266+
//POINT p = adjustCoordsToZoom(x, y);
267+
//x = p.x;
268+
//y = p.y;
269+
y += 100;
270+
x -= GetTextWidth((char*)text.c_str()) / 2;
260271
double PI = 3.14159265;
261272
double DistanceToTravel = ScreenHeight * PercentOfTheScreenToTravel / 100;
262273
//y = ax + b
@@ -273,7 +284,7 @@ void DrawFloatingTextAbovePlayer() {
273284
int drawx = x - int(progress * diff_x);
274285
int drawy = y - int(progress * diff_y);
275286

276-
if (drawx > 0 && drawy < ScreenWidth && drawy > minHeight && drawy < ScreenHeight) {
287+
if (drawx > 0 && drawx < ScreenWidth && drawy > minHeight && drawy < ScreenHeight) {
277288
char bfr[256];
278289

279290
//int callerID;

ddraw_settings.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[video]
2-
windowedResolution=1280x960
2+
windowedResolution=1600x1200
33
fullscreenResolution=1280x960
44
refresh=60
55
fullscreen=0
6-
vsync=1
6+
vsync=0

lootFilter.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ function testLootFilter1(args)
261261
end
262262

263263
function lootFilter(playerName,playerClass,itemName,itemType,itemSlot,itemRarity,itemColor)
264-
local isGood,v1,v2,v3,v4,v5,v6 = pcall(lootFilterLowercase,{playerName=playerName:lower(),playerClass=playerClass,itemName=itemName:lower(),itemType=itemType,itemSlot=itemSlot,itemRarity=itemRarity,itemColor=itemColor})
264+
local isGood,v1,v2,v3,v4,v5,v6 = pcall(lootFilterLowercase,{playerName=playerName:lower(),playerClass=playerClass,itemName=itemName:lower(),itemType=itemType,itemSlot=itemSlot,itemRarity=itemRarity,itemColor=itemColor})
265265
if isGood == true then
266266
if v1 ~= nil and v2 ~= nil and v3 ~= nil and v4 ~= nil and v5 ~= nil then
267267
if type(v1) == "string" and type(v2) == "number" and type(v3) == "number" and type(v4) == "number" and type(v5) == "number" and type(v6) == "number" then
@@ -314,6 +314,7 @@ end
314314

315315

316316

317+
-- you can look what I've done in testLootFilter1 function and do stuff in yourLootFilter.
317318

318319
function yourLootFilter(args)
319320
return args.itemName,1,args.itemColor,0,0,0

structs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include <string>
2-
#define GLOBAL_WIDTH 1280
3-
#define GLOBAL_HEIGHT 960
2+
#define GLOBAL_WIDTH 640
3+
#define GLOBAL_HEIGHT 480
44
#define MAX_STASH_TABS 100
55
#define MEGAPACKETSIZE 92000
66
class drawingQueue

0 commit comments

Comments
 (0)