Skip to content

Commit

Permalink
floating numbers and alt highlight work with zoom
Browse files Browse the repository at this point in the history
  • Loading branch information
qndel committed Sep 16, 2018
1 parent 2137ebd commit dbd7222
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 56 deletions.
Binary file modified Infernity.zip
Binary file not shown.
88 changes: 45 additions & 43 deletions Source/automap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ void __cdecl InitAutomap()
signed int v15; // edx
int size; // [esp+Ch] [ebp-4h]

int old_320 = ScreenWidth / 2;
int old_32 = ScreenWidth / 20;
int old_50 = 50*640/ScreenWidth;
int old_5 = 5*640/ScreenWidth;
int old_320 = 320;// ScreenWidth / 2;
int old_32 = 32;// ScreenWidth / 20;
int old_50 = 50;// 50 * 640 / ScreenWidth;
int old_5 = 5;// 5 * 640 / ScreenWidth;

v0 = old_50;
v1 = 0;
Expand Down Expand Up @@ -322,6 +322,35 @@ int GetItemRarity(int index) {
return GetItemRarity(index, NULL, false);
}

POINT adjustCoordsToZoom(int x, int y) {
int targetHeight = GLOBAL_HEIGHT - GLOBAL_HEIGHT * globalScrollZoom / 200;
int targetWidth = GLOBAL_WIDTH - GLOBAL_WIDTH * globalScrollZoom / 200;
int widthDiff = GLOBAL_WIDTH - targetWidth;
int heightDiff = GLOBAL_HEIGHT - targetHeight;
int distToCenterX = abs(ScreenWidth / 2 - x);
int distToCenterY = abs(ScreenHeight / 2 - y);
if (x <= ScreenWidth / 2) {
x = ScreenWidth / 2 - distToCenterX - distToCenterX * (globalScrollZoom) / 100;
}
else {
x = ScreenWidth / 2 + distToCenterX + distToCenterX * (globalScrollZoom) / 100;
}

if (y <= ScreenHeight / 2) {
y = ScreenHeight / 2 - distToCenterY - distToCenterY * (globalScrollZoom) / 100;
}
else {
y = ScreenHeight / 2 + distToCenterY + distToCenterY * (globalScrollZoom) / 100;
}

POINT p;
p.x = x;
p.y = y;
return p;


}

void AddItemToDrawQueue(int x, int y, int id) {

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

int targetHeight = GLOBAL_HEIGHT - GLOBAL_HEIGHT * globalScrollZoom / 200;
int targetWidth = GLOBAL_WIDTH - GLOBAL_WIDTH * globalScrollZoom / 200;
int widthDiff = GLOBAL_WIDTH - targetWidth;
int heightDiff = GLOBAL_HEIGHT - targetHeight;

//x += widthDiff/4;
//y += widthDiff/4;
std::stringstream ss;



int distToCenterX = abs(ScreenWidth/2-x);
int distToCenterY = abs(ScreenHeight / 2 - y);
if (x <= ScreenWidth / 2) {
x = ScreenWidth / 2 - distToCenterX - distToCenterX * (globalScrollZoom) / 100;
}
else {
x = ScreenWidth / 2 + distToCenterX + distToCenterX * (globalScrollZoom) / 100;
}

if (y <= ScreenHeight / 2) {
y = ScreenHeight / 2 - distToCenterY - distToCenterY * (globalScrollZoom) / 100;
}
else {
y = ScreenHeight / 2 + distToCenterY + distToCenterY * (globalScrollZoom) / 100;
}

x -= centerXOffset / 2 + 20;
y -= 193;




//ss << x << " " << y << " ";

//NetSendCmdString(1 << myplr, ss.str().c_str());
//x += x globalScrollZoom / 100;
//y += y * globalScrollZoom / 100;
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));
POINT p = adjustCoordsToZoom(x, y);
x = p.x; y = p.y;
x -= centerXOffset / 2 + 20;
y -= 193;
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));
}

void HighlightItemsNameOnMap()
Expand Down Expand Up @@ -1219,6 +1214,13 @@ void __cdecl DrawAutomapGame()
v0+=15;
}
PrintGameStr(8, v0, "INFERNITY", COL_RED);
v0 += 15;

int targetHeight = GLOBAL_HEIGHT - GLOBAL_HEIGHT * globalScrollZoom / 200;
int targetWidth = GLOBAL_WIDTH - GLOBAL_WIDTH * globalScrollZoom / 200;
std::stringstream res;
res << targetWidth << "x" << targetHeight;
PrintGameStr(8, v0, (char*)res.str().c_str(), COL_RED);
}
// 5CCB10: using guessed type char setlvlnum;
// 5CF31D: using guessed type char setlevel;
Expand Down
8 changes: 8 additions & 0 deletions Source/diablo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -768,12 +768,20 @@ LRESULT __stdcall GM_Game(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
if ((short)HIWORD(wParam) < 0)
{
if (globalScrollZoom > 0) {
int globalScrollZoom2 = globalScrollZoom - 5;
int targetHeight = GLOBAL_HEIGHT - GLOBAL_HEIGHT * globalScrollZoom2 / 200;
int targetWidth = GLOBAL_WIDTH - GLOBAL_WIDTH * globalScrollZoom2 / 200;
if (targetHeight < 480 || targetWidth < 640) { return 0; }
globalScrollZoom -= 5;
}
}
else
{
if (globalScrollZoom < 100) {
int globalScrollZoom2 = globalScrollZoom + 5;
int targetHeight = GLOBAL_HEIGHT - GLOBAL_HEIGHT * globalScrollZoom2 / 200;
int targetWidth = GLOBAL_WIDTH - GLOBAL_WIDTH * globalScrollZoom2 / 200;
if (targetHeight < 480 || targetWidth < 640) { return 0; }
globalScrollZoom += 5;
}
}
Expand Down
2 changes: 2 additions & 0 deletions Source/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ void setGameState(int state);
void fatalLua(const char* message);
void LuaInit();
void DrawGame(int StartX, int StartY, bool isTown);
POINT adjustCoordsToZoom(int x, int y);
void AddToFloatingQueue(FloatingText ft);

extern std::map<std::string, bool> BoolConfig;
extern std::map<std::string, int> IntConfig;
Expand Down
27 changes: 19 additions & 8 deletions Source/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ void DrawFloatingTextAbovePlayer() {

int walkStandX = ScrollInfo._sxoff;// +plr[myplr]._pyoff;
int walkStandY = ScrollInfo._syoff;// +plr[myplr]._pxoff;

if (plr[myplr]._pmode == PM_WALK2 && ScrollInfo._sdir == 4) {
walkStandX += 32;
walkStandY += 16;
Expand Down Expand Up @@ -245,18 +245,29 @@ void DrawFloatingTextAbovePlayer() {
int col = FloatingTextQueue[i].posY - plr[myplr].WorldY;
int PlayerShiftY = 0;
int PlayerShiftX = 0;
x = 32 * (row - col) + (200 * (walkStandX) / 100 >> 1) - GetTextWidth((char*)text.c_str()) / 2;
y = 16 * (row + col) + (200 * (walkStandY) / 100 >> 1) - 16;
//x = 32 * (row - col) + (200 * (walkStandX) / 100 >> 1);
//y = 16 * (row + col) + (200 * (walkStandY) / 100 >> 1) - 16;
//walkStandX * (200-globalScrollZoom) / 200
walkStandX += (walkStandX* globalScrollZoom ) / 100;
walkStandY += (walkStandY* globalScrollZoom) / 100;
x = 64 * (row - col) * (globalScrollZoom + 100) / 200 + walkStandX;
y = 32 * (row + col) * (globalScrollZoom + 100) / 200 + walkStandY - 16;


int drawXOffset = 0;
if (invflag || sbookflag)
drawXOffset -= 160;
if (chrflag || questlog)
drawXOffset += 160;
//if (invflag || sbookflag)
// drawXOffset -= 160;
//if (chrflag || questlog)
// drawXOffset += 160;
x = x + ScreenWidth / 2;// 320 + drawXOffset;
y = y + GetHeightDiff()/2;
}

//POINT p = adjustCoordsToZoom(x, y);
//x = p.x;
//y = p.y;
y += 100;
x -= GetTextWidth((char*)text.c_str()) / 2;
double PI = 3.14159265;
double DistanceToTravel = ScreenHeight * PercentOfTheScreenToTravel / 100;
//y = ax + b
Expand All @@ -273,7 +284,7 @@ void DrawFloatingTextAbovePlayer() {
int drawx = x - int(progress * diff_x);
int drawy = y - int(progress * diff_y);

if (drawx > 0 && drawy < ScreenWidth && drawy > minHeight && drawy < ScreenHeight) {
if (drawx > 0 && drawx < ScreenWidth && drawy > minHeight && drawy < ScreenHeight) {
char bfr[256];

//int callerID;
Expand Down
4 changes: 2 additions & 2 deletions ddraw_settings.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[video]
windowedResolution=1280x960
windowedResolution=1600x1200
fullscreenResolution=1280x960
refresh=60
fullscreen=0
vsync=1
vsync=0
3 changes: 2 additions & 1 deletion lootFilter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ function testLootFilter1(args)
end

function lootFilter(playerName,playerClass,itemName,itemType,itemSlot,itemRarity,itemColor)
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})
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})
if isGood == true then
if v1 ~= nil and v2 ~= nil and v3 ~= nil and v4 ~= nil and v5 ~= nil then
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
Expand Down Expand Up @@ -314,6 +314,7 @@ end



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

function yourLootFilter(args)
return args.itemName,1,args.itemColor,0,0,0
Expand Down
4 changes: 2 additions & 2 deletions structs.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <string>
#define GLOBAL_WIDTH 1280
#define GLOBAL_HEIGHT 960
#define GLOBAL_WIDTH 640
#define GLOBAL_HEIGHT 480
#define MAX_STASH_TABS 100
#define MEGAPACKETSIZE 92000
class drawingQueue
Expand Down

0 comments on commit dbd7222

Please sign in to comment.