Skip to content

Commit

Permalink
Frame API was added.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ev3nt committed Jan 15, 2022
1 parent 5c10abb commit 14f2fe1
Show file tree
Hide file tree
Showing 50 changed files with 6,710 additions and 2,298 deletions.
1,059 changes: 1,059 additions & 0 deletions 3rd/Detours/Include/detours.h

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions 3rd/Detours/Include/detver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//////////////////////////////////////////////////////////////////////////////
//
// Common version parameters.
//
// Microsoft Research Detours Package, Version 4.0.1
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//

#define _USING_V110_SDK71_ 1
#include "winver.h"
#if 0
#include <windows.h>
#include <detours.h>
#else
#ifndef DETOURS_STRINGIFY
#define DETOURS_STRINGIFY(x) DETOURS_STRINGIFY_(x)
#define DETOURS_STRINGIFY_(x) #x
#endif

#define VER_FILEFLAGSMASK 0x3fL
#define VER_FILEFLAGS 0x0L
#define VER_FILEOS 0x00040004L
#define VER_FILETYPE 0x00000002L
#define VER_FILESUBTYPE 0x00000000L
#endif
#define VER_DETOURS_BITS DETOUR_STRINGIFY(DETOURS_BITS)
Binary file added 3rd/Detours/Lib/detours.lib
Binary file not shown.
Binary file modified Maps/lua.w3m
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# War3 Lua - 1.1.4 (Beta)
# War3 Lua - 1.1.4 (<span style="color:green">Ashenvale</span>)

[![build](https://github.com/Ev3nt/war3_lua/actions/workflows/build.yml/badge.svg)](https://github.com/Ev3nt/war3_lua/actions/workflows/build.yml)

Expand Down
69 changes: 40 additions & 29 deletions Scripts/blizzard.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10218,35 +10218,46 @@ end
--
-- ***************************************************************************

function GetEffectPos(effect)
return GetObjectPos(effect)
end

function GetEffectX(effect)
return GetObjectX(effect)
end

function GetEffectY(effect)
return GetObjectY(effect)
end

function GetEffectZ(effect)
return GetObjectZ(effect)
end

function SetEffectPos(effect, x, y, z)
SetObjectPos(effect, x, y, z)
end

function SetEffectX(effect, x)
SetObjectX(effect, x)
end

function SetEffectY(effect, y)
SetObjectY(effect, y)
end
function SetEffectZ(effect, z)
SetObjectZ(effect, z)
-- function GetEffectPos(effect)
-- return GetObjectPos(effect)
-- end

-- function GetEffectX(effect)
-- return GetObjectX(effect)
-- end

-- function GetEffectY(effect)
-- return GetObjectY(effect)
-- end

-- function GetEffectZ(effect)
-- return GetObjectZ(effect)
-- end

-- function SetEffectPos(effect, x, y, z)
-- SetObjectPos(effect, x, y, z)
-- end

-- function SetEffectX(effect, x)
-- SetObjectX(effect, x)
-- end

-- function SetEffectY(effect, y)
-- SetObjectY(effect, y)
-- end
-- function SetEffectZ(effect, z)
-- SetObjectZ(effect, z)
-- end

function _print(...)
local string = ""

for i,v in ipairs({...}) do
string = string..tostring(v)
end

print(string)
DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 60, string)
end

-- ===========================================================================
Expand Down
File renamed without changes.
158 changes: 158 additions & 0 deletions Src Backup/FrameAPI.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
#include "FrameAPI.h"
#include "Variables.h"
#include "fcalls.h"

std::unordered_map<EFrameEvent, std::unordered_map<UINT, UINT>> frameEventHashTable;

UINT GetOriginFrame(EOriginFrame originframe, UINT index) {
CGameUI* gameui = GetGameUI();

switch (originframe) {
case ORIGIN_FRAME_GAME_UI:
return (UINT)gameui;
case ORIGIN_FRAME_WORLD_FRAME:
return (UINT)gameui->WorldFrameWar3;
case ORIGIN_FRAME_HERO_BAR:
return (UINT)gameui->HeroBar;
case ORIGIN_FRAME_HERO_BUTTON:
return (UINT)GetPanelButton((UINT)gameui->HeroBar, index, 0);
case ORIGIN_FRAME_HERO_HP_BAR:
return *(UINT*)((UINT)GetPanelButton((UINT)gameui->HeroBar, index, 0) + 0x1cc);
case ORIGIN_FRAME_HERO_MANA_BAR:
return *(UINT*)((UINT)GetPanelButton((UINT)gameui->HeroBar, index, 0) + 0x1d0);
case ORIGIN_FRAME_HERO_BUTTON_INDICATOR:
// Undefined
break;
case ORIGIN_FRAME_ITEM_BUTTON:
return *(UINT*)(*(UINT*)(*(UINT*)(gameui->InfoBar + 0x148) + 0x130) + 8 * index + 4);
case ORIGIN_FRAME_COMMAND_BUTTON:
return (UINT)GetPanelButton((UINT)gameui->CommandBar, index / 4, index % 4);
case ORIGIN_FRAME_SYSTEM_BUTTON:
// Undefined
break;
case ORIGIN_FRAME_PORTRAIT:
return (UINT)gameui->Portrait;
case ORIGIN_FRAME_MINIMAP:
return (UINT)gameui->Minimap;
case ORIGIN_FRAME_MINIMAP_BUTTON:
return (UINT)gameui->MinimapButtons[index];
case ORIGIN_FRAME_TOOLTIP:
return GetTooltipFrame();
case ORIGIN_FRAME_UBERTOOLTIP:
// Undefined
break;
case ORIGIN_FRAME_CHAT_MSG:
return (UINT)gameui->ChatMessage;
case ORIGIN_FRAME_UNIT_MSG:
return (UINT)gameui->UnitMessage;
case ORIGIN_FRAME_TOP_MSG:
return (UINT)gameui->TopMessage;
default:
break;
}

return NULL;
}

UINT GetPanelButton(UINT frame, BYTE row, BYTE column) {
return *(UINT*)(*(DWORD*)(16 * row + *((DWORD*)frame + 85) + 8) + 4 * column) - sizeof(CFrame);
}

UINT GetTooltipFrame(UINT unknown0) {
return fastcall<UINT>(MakePtr(gameBase, _getTooltipFrame), unknown0);
}

BOOL LoadTOCFile(LPCSTR filename) {
DWORD stringHastTable = MakePtr(gameBase, _stringHastTable);
DWORD FDFHashTable = MakePtr(gameBase, _FDFHashTable);

if (*(int*)(stringHastTable + 0x14) < 0xFFFF) {
thiscall<void>(MakePtr(gameBase, _stringHashNodeGrowListArray), stringHastTable, 0xFFFF);
}

if (*(int*)(FDFHashTable + 0x14) < 0xFFFF) {
thiscall<void>(MakePtr(gameBase, _baseFrameHashNodeGrowListArray), FDFHashTable, 0xFFFF);
}

return fastcall<BOOL>(MakePtr(gameBase, _readFDFFile), filename, stringHastTable, FDFHashTable, MakePtr(gameBase, _CFrameDefStatus));
}

UINT GetFrameByName(LPCSTR framename, UINT id) {
return fastcall<UINT>(MakePtr(gameBase, _getCFrameByName), framename, id);
}

UINT CreateFrame(LPCSTR baseframe, UINT parentframe, EFramePoint point, EFramePoint relativepoint, UINT id) {
return fastcall<UINT>(MakePtr(gameBase, _createCFrame), baseframe, parentframe, point, relativepoint, id);
}

void SetFrameText(UINT frame, LPCSTR text) {
thiscall<void>(MakePtr(gameBase, _setCFrameText), *(UINT*)(FRAMELAYOUT(frame) + 0x130), text);
}

void SetFrameTextColor(UINT frame, BYTE red, BYTE green, BYTE blue, BYTE alpha) {
DWORD color = ((alpha << 24) + (red << 16) + (green << 8) + blue);
thiscall<void>(MakePtr(gameBase, _setCFrameTextColor), FRAMELAYOUT(frame), &color);
}

float GetFrameTextHeight(UINT frame) {
return thiscall<float>(MakePtr(gameBase, _getCFrameTextHeight), FRAMELAYOUT(frame));
}

void SetFrameWidth(UINT frame, float width) {
thiscall<void>(MakePtr(gameBase, _setCLayoutFrameWidth), FRAMELAYOUT(frame), width);
}

void SetFrameHeight(UINT frame, float height) {
thiscall<void>(MakePtr(gameBase, _setCLayoutFrameHeight), FRAMELAYOUT(frame), height);
}

void SetFrameSize(UINT frame, float width, float height) {
SetFrameWidth(frame, width);
SetFrameHeight(frame, height);
}

void SetFrameScale(UINT frame, float scale) {
thiscall<void>(MakePtr(gameBase, _setCLayoutFrameScale), FRAMELAYOUT(frame), scale);
}

void SetFrameAbsolutePoint(UINT frame, EFramePoint point, float offsetX, float offsetY) {
thiscall<void>(MakePtr(gameBase, _setCLayoutFrameAbsolutePoint), FRAMELAYOUT(frame), point, offsetX, offsetY, 1);
}

void SetFramePoint(UINT frame, EFramePoint point, UINT parentframe, EFramePoint relativepoint, float offsetX, float offsetY) {
thiscall<void>(MakePtr(gameBase, _setCLayoutFramePoint), FRAMELAYOUT(frame), point, FRAMELAYOUT(parentframe), relativepoint, offsetX, offsetY, 1);
}

float GetFrameWidth(UINT frame) {
return *(float*)(FRAMELAYOUT(frame) + 0x58);
}

float GetFrameHeight(UINT frame) {
return *(float*)(FRAMELAYOUT(frame) + 0x5c);
}

UINT GetFramePoint(UINT frame, EFramePoint point) {
return *(UINT*)(FRAMELAYOUT(frame) + 4 * (UINT)point + 8);
}

UINT GetFramePointParent(UINT frame, EFramePoint point) {
return *(UINT*)(GetFramePoint(frame, point) + 4);
}

UINT GetFramePointRelativePoint(UINT frame, EFramePoint point) {
return *(UINT*)(GetFramePoint(frame, point) + 8);
}

float GetFramePointX(UINT frame, EFramePoint point) {
return *(float*)(GetFramePoint(frame, point) + 12);
}

float GetFramePointY(UINT frame, EFramePoint point) {
return *(float*)(GetFramePoint(frame, point) + 16);
}

//---------------------------------------------------------------------------------------

void TriggerRegisterFrameEvent(UINT trigger, UINT frame, EFrameEvent event) {
frameEventHashTable[event][frame] = trigger;
}
105 changes: 105 additions & 0 deletions Src Backup/FrameAPI.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#pragma once

#include "Warcraft.h"
#include "Mem.h"

enum EFramePoint : UINT
{
TopLeft = 0,
Top = 1,
TopRight = 2,
Left = 3,
Center = 4,
Right = 5,
BottomLeft = 6,
Bottom = 7,
BottomRight = 8
};

enum EOriginFrame : UINT {
ORIGIN_FRAME_GAME_UI,
ORIGIN_FRAME_WORLD_FRAME,
ORIGIN_FRAME_HERO_BAR,
ORIGIN_FRAME_HERO_BUTTON,
ORIGIN_FRAME_HERO_HP_BAR,
ORIGIN_FRAME_HERO_MANA_BAR,
ORIGIN_FRAME_HERO_BUTTON_INDICATOR,
ORIGIN_FRAME_ITEM_BUTTON,
ORIGIN_FRAME_COMMAND_BUTTON,
ORIGIN_FRAME_SYSTEM_BUTTON,
ORIGIN_FRAME_PORTRAIT,
ORIGIN_FRAME_MINIMAP,
ORIGIN_FRAME_MINIMAP_BUTTON,
ORIGIN_FRAME_TOOLTIP,
ORIGIN_FRAME_UBERTOOLTIP,
ORIGIN_FRAME_CHAT_MSG,
ORIGIN_FRAME_UNIT_MSG,
ORIGIN_FRAME_TOP_MSG
};

enum EFrameEvent : UINT {
FRAMEEVENT_CONTROL_CLICK = 1,
FRAMEEVENT_MOUSE_ENTER,
FRAMEEVENT_MOUSE_LEAVE,
FRAMEEVENT_MOUSE_UP,
FRAMEEVENT_MOUSE_DOWN,
FRAMEEVENT_MOUSE_WHEEL,
FRAMEEVENT_CHECKBOX_CHECKED,
FRAMEEVENT_CHECKBOX_UNCHECKED,
FRAMEEVENT_EDITBOX_TEXT_CHANGED,
FRAMEEVENT_POPUPMENU_ITEM_CHANGED,
FRAMEEVENT_MOUSE_DOUBLECLICK,
FRAMEEVENT_SPRITE_ANIM_UPDATE,
FRAMEEVENT_SLIDER_VALUE_CHANGED,
FRAMEEVENT_DIALOG_CANCEL,
FRAMEEVENT_DIALOG_ACCEPT,
FRAMEEVENT_EDITBOX_ENTER
};

//DWORD eventType[16] = {MakePtr(gameBase, _frameevent_control_click), MakePtr(gameBase, _frameevent_control_mouseenter) };

UINT GetOriginFrame(EOriginFrame originframe, UINT index);

UINT GetPanelButton(UINT frame, BYTE row, BYTE column);

UINT GetTooltipFrame(UINT unknown0 = NULL);

BOOL LoadTOCFile(LPCSTR filename);

UINT GetFrameByName(LPCSTR framename, UINT id);

UINT CreateFrame(LPCSTR baseframe, UINT parentframe, EFramePoint point, EFramePoint relativepoint, UINT id);

void SetFrameText(UINT frame, LPCSTR text);

void SetFrameTextColor(UINT frame, BYTE red, BYTE green, BYTE blue, BYTE alpha);

float GetFrameTextHeight(UINT frame);

void SetFrameWidth(UINT frame, float width);

void SetFrameHeight(UINT frame, float height);

void SetFrameSize(UINT frame, float width, float height);

void SetFrameScale(UINT frame, float scale);

void SetFrameAbsolutePoint(UINT frame, EFramePoint point, float offsetX, float offsetY);

void SetFramePoint(UINT frame, EFramePoint point, UINT parentframe, EFramePoint relativepoint, float offsetX, float offsetY);

float GetFrameWidth(UINT frame);

float GetFrameHeight(UINT frame);

UINT GetFramePointParent(UINT frame, EFramePoint point);

UINT GetFramePointRelativePoint(UINT frame, EFramePoint point);

float GetFramePointX(UINT frame, EFramePoint point);

float GetFramePointY(UINT frame, EFramePoint point);

//---------------------------------------------------------------------------------------

void TriggerRegisterFrameEvent(UINT trigger, UINT frame, EFrameEvent event);
Loading

0 comments on commit 14f2fe1

Please sign in to comment.