From 9ded48fd7833d815d034b290aed3e893696f2a52 Mon Sep 17 00:00:00 2001 From: Walter White Date: Tue, 11 Jul 2023 00:19:24 +0900 Subject: [PATCH 01/14] add additional resolution glide opom window --- glide3x/src/wrapper.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/glide3x/src/wrapper.cpp b/glide3x/src/wrapper.cpp index b2cacb0..754482c 100644 --- a/glide3x/src/wrapper.cpp +++ b/glide3x/src/wrapper.cpp @@ -286,6 +286,8 @@ GrContext_t Wrapper::grSstWinOpen(FxU32 hwnd, GrScreenResolution_t screen_resolu App.game.size = { 640, 480 }; else if (screen_resolution == GR_RESOLUTION_800x600) App.game.size = { 800, 600 }; + else if (screen_resolution == GR_RESOLUTION_1024x768) + App.game.size = { 1024, 768 }; else { if (App.game.custom_size.x != 0) { App.game.size = App.game.custom_size; From c59dc08370657ceadc49e5112a7c68ebc23bb290 Mon Sep 17 00:00:00 2001 From: Walter White Date: Tue, 11 Jul 2023 00:20:03 +0900 Subject: [PATCH 02/14] fix picked up item masking --- d2gl/src/graphic/context.cpp | 2 +- d2gl/src/graphic/shaders/mod.glsl | 4 ++-- d2gl/src/graphic/shaders/mod.glsl.h | 20 ++++++++++---------- d2gl/src/modules/hd_text.cpp | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/d2gl/src/graphic/context.cpp b/d2gl/src/graphic/context.cpp index 8fc3de6..af73675 100644 --- a/d2gl/src/graphic/context.cpp +++ b/d2gl/src/graphic/context.cpp @@ -641,7 +641,7 @@ void Context::onResize(glm::uvec2 w_size, glm::uvec2 g_size, uint32_t bpp) m_upscale_ubo->updateDataVec2f("out_size", { (float)App.game.tex_size.x * App.viewport.scale.x, (float)App.game.tex_size.y * App.viewport.scale.y }); m_postfx_ubo->updateDataVec2f("rel_size", { 1.0f / App.viewport.size.x, 1.0f / App.viewport.size.y }); m_mod_pipeline->setUniformVec2f("u_Scale", App.viewport.scale); - m_mod_pipeline->setUniformVec2f("u_ViewportSize", { (float)App.viewport.size.x, (float)App.viewport.size.y }); + m_mod_pipeline->setUniformVec4f("u_Viewport", { (float)App.viewport.offset.x, (float)App.viewport.offset.y, (float)App.viewport.size.x, (float)App.viewport.size.y }); modules::MiniMap::Instance().resize(); toggleVsync(); diff --git a/d2gl/src/graphic/shaders/mod.glsl b/d2gl/src/graphic/shaders/mod.glsl index 82f76ba..f148351 100644 --- a/d2gl/src/graphic/shaders/mod.glsl +++ b/d2gl/src/graphic/shaders/mod.glsl @@ -69,7 +69,7 @@ in vec2 v_Extra; uniform vec2 u_Scale; uniform vec4 u_TextMask; uniform bool u_IsMasking = false; -uniform vec2 u_ViewportSize; +uniform vec4 u_Viewport; float msdf(vec3 rgb, float smoothess, float weight) { @@ -163,7 +163,7 @@ void main() FragColor.a *= v_Flags.z / 100.0; } - if (texture(u_MaskTexture, gl_FragCoord.xy / u_ViewportSize).r > 0.1) + if (texture(u_MaskTexture, (gl_FragCoord.xy - u_Viewport.xy) / u_Viewport.zw).r > 0.1) FragColor.a = 0.0; } diff --git a/d2gl/src/graphic/shaders/mod.glsl.h b/d2gl/src/graphic/shaders/mod.glsl.h index 8f44249..63e28f0 100644 --- a/d2gl/src/graphic/shaders/mod.glsl.h +++ b/d2gl/src/graphic/shaders/mod.glsl.h @@ -40,16 +40,16 @@ "uniform vec2 u_Scale;" "uniform vec4 u_TextMask;" "uniform bool u_IsMasking=false;" -"uniform vec2 u_ViewportSize;" -"float v(vec3 v,float u,float i)" +"uniform vec4 u_Viewport;" +"float v(vec3 v,float u,float y)" "{" - "float r=max(min(v.x,v.y),min(max(v.x,v.y),v.z)),n=max(u,1.)*(r-1.+.5*i);" + "float r=max(min(v.x,v.y),min(max(v.x,v.y),v.z)),n=max(u,1.)*(r-1.+.5*y);" "return clamp(n+.5,0.,1.);" "}" "vec3 v(vec3 v,float u)" "{" - "float r=dot(v,vec3(.299,.587,.114));" - "return mix(v,vec3(r),u);" + "float y=dot(v,vec3(.299,.587,.114));" + "return mix(v,vec3(y),u);" "}" "void main()" "{" @@ -78,13 +78,13 @@ "else " "if(v_Flags.w==1u)" "{" - "float r=v(d.xyz,v_Extra.x,v_Extra.y+.02),y=v(d.xyz,v_Extra.x,1.01);" - "FragColor=vec4(mix(v_Color2.xyz,v_Color1.xyz,y),v_Color1.w*r);" + "float y=v(d.xyz,v_Extra.x,v_Extra.y+.02),r=v(d.xyz,v_Extra.x,1.01);" + "FragColor=vec4(mix(v_Color2.xyz,v_Color1.xyz,r),v_Color1.w*y);" "}" "else " "{" - "float r=smoothstep(1.5,1.,u_Scale.x),n=v(d.xyz,v_Extra.x/(1.+r),v_Extra.y);" - "FragColor=vec4(v_Color1.xyz,v_Color1.w*n*(1.+.2*r));" + "float y=smoothstep(1.5,1.,u_Scale.x),r=v(d.xyz,v_Extra.x/(1.+y),v_Extra.y);" + "FragColor=vec4(v_Color1.xyz,v_Color1.w*r*(1.+.2*y));" "}" "if(u_IsMasking&&v_Flags.z==0u)" "if(u_TextMask.xv_Position.x&&u_TextMask.y>v_Position.y&&u_TextMask.w0u)" "FragColor.w*=v_Flags.z/1e2;" "}" - "if(texture(u_MaskTexture,gl_FragCoord.xy/u_ViewportSize).x>.1)" + "if(texture(u_MaskTexture,(gl_FragCoord.xy-u_Viewport.xy)/u_Viewport.zw).x>.1)" "FragColor.w=0.;" "}" "\n#endif" \ No newline at end of file diff --git a/d2gl/src/modules/hd_text.cpp b/d2gl/src/modules/hd_text.cpp index c4188c0..e675ed8 100644 --- a/d2gl/src/modules/hd_text.cpp +++ b/d2gl/src/modules/hd_text.cpp @@ -780,7 +780,7 @@ void HDText::startEntryText() void HDText::drawEntryText() { - if (!m_entry_text_draw) + if (App.game.screen != GameScreen::InGame || !m_entry_text_draw) return; if (m_entry_timer < std::clock()) From 1cd7161b6218addecc17878705f42c5d87739467 Mon Sep 17 00:00:00 2001 From: Walter White Date: Thu, 13 Jul 2023 11:59:41 +0900 Subject: [PATCH 03/14] patch improvement --- d2gl/src/patch.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/d2gl/src/patch.cpp b/d2gl/src/patch.cpp index cefa2ca..647195f 100644 --- a/d2gl/src/patch.cpp +++ b/d2gl/src/patch.cpp @@ -112,8 +112,9 @@ bool SubPatch::prepare() } else if (m_type == PatchType::Swap) { uint8_t* bytes = (uint8_t*)&m_pointer; + const size_t start = 4 - m_length; for (uint32_t i = 0; i < m_length; i++) - m_new_code[i] = bytes[3 - i]; + m_new_code[i] = bytes[3 - start - i]; } m_ready = true; From 398b43fa9f6802c6a165f0738b97b396e7f2272d Mon Sep 17 00:00:00 2001 From: Walter White Date: Thu, 13 Jul 2023 12:00:52 +0900 Subject: [PATCH 04/14] avg frame calc fix --- d2gl/src/graphic/context.cpp | 7 +++++-- d2gl/src/graphic/context.h | 3 ++- d2gl/src/modules/motion_prediction.cpp | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/d2gl/src/graphic/context.cpp b/d2gl/src/graphic/context.cpp index af73675..c848ce8 100644 --- a/d2gl/src/graphic/context.cpp +++ b/d2gl/src/graphic/context.cpp @@ -294,7 +294,7 @@ Context::Context() LARGE_INTEGER qpf; QueryPerformanceFrequency(&qpf); m_frame.frequency = double(qpf.QuadPart) / 1000.0; - m_frame.frame_times.assign(FRAMETIME_SAMPLE_COUNT, m_frame.frame_time); + m_frame.frame_times.assign(MAX_FRAMETIME_SAMPLE_COUNT, m_frame.frame_time); m_limiter.timer = CreateWaitableTimer(NULL, TRUE, NULL); setFpsLimit(!App.vsync && App.foreground_fps.active, App.foreground_fps.range.value); @@ -791,7 +791,9 @@ void Context::presentFrame() m_frame.frame_times.pop_front(); m_frame.frame_times.push_back(m_frame.frame_time); - m_frame.average_frame_time = std::reduce(m_frame.frame_times.begin(), m_frame.frame_times.end()) / FRAMETIME_SAMPLE_COUNT; + std::deque::iterator iter = m_frame.frame_times.begin() + (MAX_FRAMETIME_SAMPLE_COUNT - m_frame.frame_sample_count); + m_frame.average_frame_time = std::reduce(iter, m_frame.frame_times.end()) / m_frame.frame_sample_count; + m_frame.frame_sample_count += m_frame.frame_sample_count == MAX_FRAMETIME_SAMPLE_COUNT ? 0 : 1; m_frame.frame_count++; } @@ -902,6 +904,7 @@ void Context::setFpsLimit(bool active, int max_fps) m_limiter.active = active; m_limiter.frame_len_ms = 1000.0f / max_fps; m_limiter.frame_len_ns = (uint64_t)(m_limiter.frame_len_ms * 10000); + m_frame.frame_sample_count = 1; resetFileTime(); } diff --git a/d2gl/src/graphic/context.h b/d2gl/src/graphic/context.h index e5329fa..b63972a 100644 --- a/d2gl/src/graphic/context.h +++ b/d2gl/src/graphic/context.h @@ -35,7 +35,7 @@ namespace d2gl { #define MAX_VERTICES 4 * 50000 #define MAX_VERTICES_MOD 4 * 20000 #define PIXEL_BUFFER_SIZE 12 * 1024 * 1024 -#define FRAMETIME_SAMPLE_COUNT 120 +#define MAX_FRAMETIME_SAMPLE_COUNT 120 #define TEXTURE_SLOT_DEFAULT 0 #define TEXTURE_SLOT_GAME 1 @@ -91,6 +91,7 @@ struct FrameMetrics { uint32_t vertex_count = 0; uint32_t drawcall_count = 0; uint32_t frame_count = 0; + uint32_t frame_sample_count = 0; }; struct LimiterMetrics { diff --git a/d2gl/src/modules/motion_prediction.cpp b/d2gl/src/modules/motion_prediction.cpp index 09ba3cc..d156498 100644 --- a/d2gl/src/modules/motion_prediction.cpp +++ b/d2gl/src/modules/motion_prediction.cpp @@ -91,7 +91,7 @@ void MotionPrediction::update() m_frame_time = d2::isEscMenuOpen() ? 0.0f : (float)(App.context->getFrameTime() / 1000.0); - const auto frame_time_ms = (int64_t)((App.vsync || App.foreground_fps.active ? App.context->getAvgFrameTime() : App.context->getFrameTime()) * (65536.0 / 1000.0)); + const auto frame_time_ms = (int64_t)(App.context->getAvgFrameTime() * (65536.0 / 1000.0)); int32_t delta = (int32_t)glm::max((int64_t)INT_MIN, glm::min((int64_t)INT_MAX, frame_time_ms)); m_player_motion.unit = d2::getPlayerUnit(); From 7f3f967b028c4486f9f27042be3f62e4b85b8c0b Mon Sep 17 00:00:00 2001 From: Walter White Date: Thu, 13 Jul 2023 12:03:28 +0900 Subject: [PATCH 05/14] unit hover nameplate fix --- d2gl/src/d2/common.cpp | 26 ++++---- d2gl/src/d2/common.h | 1 + d2gl/src/d2/funcs.cpp | 9 ++- d2gl/src/d2/funcs.h | 3 +- d2gl/src/d2/stubs.cpp | 29 +++++++++ d2gl/src/d2/stubs.h | 4 ++ d2gl/src/modules/hd_text.cpp | 119 ++++++++++++++++++++--------------- d2gl/src/modules/hd_text.h | 18 +++--- 8 files changed, 135 insertions(+), 74 deletions(-) diff --git a/d2gl/src/d2/common.cpp b/d2gl/src/d2/common.cpp index 0f3f873..9550ca0 100644 --- a/d2gl/src/d2/common.cpp +++ b/d2gl/src/d2/common.cpp @@ -35,6 +35,7 @@ int* video_mode = (int*)getProc((DLL_D2GFX), (0x1D208), (0x1D264), (0x1A220), (0 bool* perspective = (bool*)getProc((DLL_D2GFX), (0xE188), (0xE198), (0x10C94), (0x10C30), (0x10C8C), (0x10BE0), (0x10BE4), (0x32DA48)); bool* esc_menu_open = (bool*)getProc((DLL_D2CLIENT), (0x1248D8), (0x11A6CC), (0xFB094), (0x1040E4), (0x102B7C), (0xFADA4), (0x11C8B4), (0x3A27E4)); bool* is_alt_clicked = (bool*)getProc((DLL_D2CLIENT), (0x1248E8), (0x11A6DC), (0xFB0A4), (0x1040F4), (0x102B8C), (0xFADB4), (0x11C8C4), (0x3A27F4)); +int is_unit_hovered = 0; uint32_t* is_in_game = (uint32_t*)getProc((DLL_D2CLIENT), (0x1109FC), (0x1077C4), (0xE48EC), (0xF18C0), (0x11BCC4), (0xF8C9C), (0xF79E0), (0x3A27C0)); UnitAny* player_unit = (UnitAny*)getProc((DLL_D2CLIENT), (0x1263F8), (0x11C200), (0x11C4F0), (0x11C1E0), (0x11C3D0), (0x11BBFC), (0x11D050), (0x3A6A70)); @@ -113,9 +114,6 @@ getUnitRoom_t getUnitRoom = (getUnitRoom_t)getProc((DLL_D2COMMON), (), (), (), ( getLevelNoByRoom_t getLevelNoByRoom = (getLevelNoByRoom_t)getProc((DLL_D2COMMON), (), (), (), (), (), (), (-10691), ()); uintptr_t getLevelName_Fn = getProc((DLL_D2CLIENT), (0x88420), (0x839F0), (0x9DC10), (0x61AA0), (0x8B1A0), (0xBE240), (0x18250), (0x53E70)); -// Offset D2WinUnitHover = getOffset((DLL_D2WIN), (), (-10124, 0xF7E9C1FA, 0x1F3), (-10175, 0x03C2572B, 0x1A3), (-10037, 0x03C2572B, 0x1A3), (-10201, 0x03C2572B, 0x1A3), (-10110, 0x03C2572B, 0x1A3), (-10124, 0x03C2572B, 0x1A3), (0x10318B, 0x03C22BF0)); -// DWORD D2WinUnitHoverRet = helpers::GetProcOffset(D2WinUnitHover) + (isVer(V_110) ? 5 : 6); - // d2client + 0x291F8 : 1 2 3 4 (potion keys) // d2client + 0x27708 : life XX/XX // d2client + 0x277C7 : Mana XX/XX @@ -136,17 +134,15 @@ void initHooks() *is_in_game = 0; Patch no_intro = Patch(); - no_intro.add(PatchType::Swap, getOffset((DLL_D2LAUNCH), (0x24F0C), (0x27A58), (0x1E210), (0x1E11C), (0x1E240), (0x1E0FC), (0x1E2F4), (0x2D4C84)), 4, 0x00000000); - no_intro.add(PatchType::Swap, getOffset((DLL_D2LAUNCH), (0x24F34), (0x27A80), (0x1E238), (0x1E144), (0x1E268), (0x1E124), (0x1E31C), (0x2D4CAC)), 4, 0x00000000); - no_intro.add(PatchType::Swap, getOffset((DLL_D2LAUNCH), (0x24F5C), (0x27AA8), (0x1E260), (0x1E16C), (0x1E290), (0x1E14C), (0x1E344), (0x2D4CD4)), 4, 0x00000000); - no_intro.add(PatchType::Swap, getOffset((DLL_D2LAUNCH), (0x24F84), (0x27AD0), (0x1E288), (0x1E194), (0x1E2B8), (0x1E174), (0x1E36C), (0x2D4CFC)), 4, 0x00000000); + no_intro.add(PatchType::Swap, getOffset((DLL_D2LAUNCH), (0x24F0C), (0x27A58), (0x1E210), (0x1E11C), (0x1E240), (0x1E0FC), (0x1E2F4), (0x2D4C84)), 1, 0x00); + no_intro.add(PatchType::Swap, getOffset((DLL_D2LAUNCH), (0x24F34), (0x27A80), (0x1E238), (0x1E144), (0x1E268), (0x1E124), (0x1E31C), (0x2D4CAC)), 1, 0x00); + no_intro.add(PatchType::Swap, getOffset((DLL_D2LAUNCH), (0x24F5C), (0x27AA8), (0x1E260), (0x1E16C), (0x1E290), (0x1E14C), (0x1E344), (0x2D4CD4)), 1, 0x00); + no_intro.add(PatchType::Swap, getOffset((DLL_D2LAUNCH), (0x24F84), (0x27AD0), (0x1E288), (0x1E194), (0x1E2B8), (0x1E174), (0x1E36C), (0x2D4CFC)), 1, 0x00); no_intro.toggle(App.skip_intro); - if (isVer(V_113d)) { - Patch multiple_instance = Patch(); - multiple_instance.add(PatchType::Swap, getOffset((DLL_D2GFX), (), (), (), (), (), (), (0xB6B0), ()), 2, 0xEB450000); - multiple_instance.toggle(true); - } + Patch multiple_instance = Patch(); + multiple_instance.add(PatchType::Swap, getOffset((DLL_D2GFX), (0x447C), (0x446A), (0x84CF), (0x84AF), (0x894F), (0x85BF), (0xB6B0), (0xF562B)), 2, isVer(V_109d) ? 0xEB47 : (isVer(V_110) ? 0xEB49 : 0xEB45)); + multiple_instance.toggle(true); Patch game_loop = Patch(); game_loop.add(PatchType::Call, getOffset((DLL_D2CLIENT), (0x9B3D, 0xE87A5F0B), (0xA2A2, 0xE8B51B0C), (0x89A2F, 0xE84A37F8), (0x3356F, 0xE85E9CFD), (0x7D1BF, 0xE84801F9), (0x44E2F, 0xE81A85FC), (0x45E7F, 0xE8E473FC), (0x4F256, 0xE8E5550C)), 5, (uintptr_t)gameDrawBeginStub); @@ -185,6 +181,12 @@ void initHooks() App.mini_map.active = false; } + Patch common_patches = Patch(); + common_patches.add(PatchType::Auto, getOffset((DLL_D2WIN, 0x85F60F9E, 0xC7), (-10124, 0, 0x150), (-10124, 0, 0x127), (-10175), (-10037), (-10201), (-10110), (-10124), (0x1030B4, 0x85DB0F9E, -1)), 5, (uintptr_t)unitHoverBeginPatch); + common_patches.add(PatchType::Auto, getOffset((DLL_D2WIN, 0x8D140152, 0x162), (-10124, 0x03C55650, 0x1CC), (-10124, 0x03C55650, 0x1A3), (-10175), (-10037), (-10201), (-10110), (-10124), (0x10314B, 0, -1)), 5, (uintptr_t)unitHoverMidPatch); + common_patches.add(PatchType::Auto, getOffset((DLL_D2WIN, 0xC1E81F03, 0x1A0), (-10124, 0, 0x228), (-10124, 0, 0x1FF), (-10175), (-10037), (-10201), (-10110), (-10124), (0x103188, 0, -1)), 5, (uintptr_t)unitHoverEndPatch); + common_patches.toggle(true); + patch_motion_prediction = std::make_unique(); patch_motion_prediction->add(PatchType::Auto, getOffset((DLL_D2CLIENT, 0x83EC1053), (0x7FCF0, 0x83EC5053), (0x7B4F0, 0x83EC4C53), (0x941F0), (0x15C80), (0x71990), (0x7CA40), (0x76170), (0xA0A01, 0x8BEC83EC)), 5, (uintptr_t)(isVer(V_109d) ? rectangledTextBeginStub109d : (isVer(V_110) ? rectangledTextBeginStub110f : rectangledTextBeginStub))); patch_motion_prediction->add(PatchType::Auto, getOffset((DLL_D2CLIENT, 0x5D5B83C4), (0x7FE50), (0x7B650), (0x9431A), (0x15DAA), (0x71ABA), (0x7CB6A), (0x7629A), (0xA0B1B, 0x5E5B8BE5)), 5, (uintptr_t)rectangledTextEndStub); diff --git a/d2gl/src/d2/common.h b/d2gl/src/d2/common.h index f7c1dc0..9502daf 100644 --- a/d2gl/src/d2/common.h +++ b/d2gl/src/d2/common.h @@ -77,6 +77,7 @@ extern int* video_mode; extern bool* perspective; extern bool* esc_menu_open; extern bool* is_alt_clicked; +extern int is_unit_hovered; extern uint32_t* is_in_game; extern UnitAny* player_unit; diff --git a/d2gl/src/d2/funcs.cpp b/d2gl/src/d2/funcs.cpp index 695940c..5d9fb78 100644 --- a/d2gl/src/d2/funcs.cpp +++ b/d2gl/src/d2/funcs.cpp @@ -113,9 +113,9 @@ bool isUnitDead(UnitAny* unit) return unit && (d2::getUnitFlag(unit) & 0x10000); } -wchar_t* getPlayerName(UnitAny* unit) +char* getPlayerName(UnitAny* unit) { - return (wchar_t*)(isVer(V_109d) ? unit->v109.pPlayerData->szName : unit->v110.pPlayerData->szName); + return (char*)(isVer(V_109d) ? unit->v109.pPlayerData->szName : unit->v110.pPlayerData->szName); } MonsterType getMonsterType(UnitAny* unit) @@ -413,6 +413,11 @@ void drawRectFrame() modules::HDText::Instance().drawRectFrame(); } +void drawUnitHealthBar() +{ + modules::HDText::Instance().drawUnitHealthBar(); +} + void loadUIImage() { modules::HDText::Instance().loadUIImage(); diff --git a/d2gl/src/d2/funcs.h b/d2gl/src/d2/funcs.h index d015ff7..3bc6c73 100644 --- a/d2gl/src/d2/funcs.h +++ b/d2gl/src/d2/funcs.h @@ -39,7 +39,7 @@ uint32_t getUnitStat(UnitAny* unit, uint32_t stat); UnitAny* getSelectedItem(); bool isUnitDead(UnitAny* unit); -wchar_t* getPlayerName(UnitAny* unit); +char* getPlayerName(UnitAny* unit); MonsterType getMonsterType(UnitAny* unit); wchar_t* getMonsterName(UnitAny* unit); @@ -86,6 +86,7 @@ void rectangledTextEnd(); void unitHoverText(); void altItemsText(); void drawRectFrame(); +void drawUnitHealthBar(); void loadUIImage(); void drawSubTextA(); diff --git a/d2gl/src/d2/stubs.cpp b/d2gl/src/d2/stubs.cpp index dd15ab3..4167f99 100644 --- a/d2gl/src/d2/stubs.cpp +++ b/d2gl/src/d2/stubs.cpp @@ -442,6 +442,35 @@ __declspec(naked) void altItemsTextStub109d() } } +__declspec(naked) void unitHoverBeginPatch() +{ + __asm + { + mov is_unit_hovered, 0x1 + ret + } +} + +__declspec(naked) void unitHoverMidPatch() +{ + __asm + { + mov is_unit_hovered, 0x2 + ret + } +} + +__declspec(naked) void unitHoverEndPatch() +{ + __asm + { + pushad + call drawUnitHealthBar + popad + ret + } +} + __declspec(naked) void loadUIImageStub() { __asm diff --git a/d2gl/src/d2/stubs.h b/d2gl/src/d2/stubs.h index dec6f77..bf09959 100644 --- a/d2gl/src/d2/stubs.h +++ b/d2gl/src/d2/stubs.h @@ -49,6 +49,10 @@ void altItemsTextStub(); void altItemsTextStub110f(); void altItemsTextStub109d(); +void unitHoverBeginPatch(); +void unitHoverMidPatch(); +void unitHoverEndPatch(); + void loadUIImageStub(); void loadUIImageStubECX(); void drawSubTextAStub(); diff --git a/d2gl/src/modules/hd_text.cpp b/d2gl/src/modules/hd_text.cpp index e675ed8..5940b0d 100644 --- a/d2gl/src/modules/hd_text.cpp +++ b/d2gl/src/modules/hd_text.cpp @@ -130,8 +130,8 @@ HDText::HDText() void HDText::reset() { m_masking = false; - m_is_player_dead = d2::isUnitDead(d2::getPlayerUnit()); m_map_text_line = 1; + m_is_player_dead = d2::isUnitDead(d2::getPlayerUnit()); } void HDText::update() @@ -151,7 +151,6 @@ void HDText::update() mask = false; } } - m_cur_level_no = App.game.screen == GameScreen::InGame ? *d2::level_no : 0; } @@ -265,7 +264,7 @@ bool HDText::drawText(const wchar_t* str, int x, int y, uint32_t color, uint32_t bool HDText::drawFramedText(const wchar_t* str, int x, int y, uint32_t color, uint32_t centered) { - if (!isActive() || !str) + if (!str || !isActive()) return false; if (*d2::is_alt_clicked) @@ -273,15 +272,14 @@ bool HDText::drawFramedText(const wchar_t* str, int x, int y, uint32_t color, ui const auto unit = d2::getSelectedUnit(); if (unit) { - if (unit->dwType == d2::UnitType::Monster && isVerMin(V_111) && y == 32 && !centered) { - drawMonsterHealthBar(unit); - return true; - } - - if (unit->dwType == d2::UnitType::Player || d2::isMercUnit(unit)) { - m_hovered_player_id = d2::getUnitID(unit) | ((uint8_t)unit->dwType << 24); - if (isVer(V_114d)) - wcscpy_s(m_hovered_player_str, str); + const bool is_monster = (unit->dwType == d2::UnitType::Monster && y == 32); + if (unit->dwType == d2::UnitType::Player || d2::isMercUnit(unit) || is_monster) { + m_hovered_unit.id = d2::getUnitID(unit) | ((uint8_t)unit->dwType << 24); + m_hovered_unit.color = color; + if (!is_monster) { + wcscpy_s(m_hovered_unit.name, str); + m_hovered_unit.pos = { x, y }; + } return false; } } @@ -370,7 +368,6 @@ bool HDText::drawFramedText(const wchar_t* str, int x, int y, uint32_t color, ui font->drawText(str, pos + padding, text_color, true); App.context->toggleDelayPush(false); - m_draw_sub_text = false; return true; } @@ -445,35 +442,25 @@ bool HDText::drawSolidRect(int left, int top, int right, int bottom, uint32_t co if (App.game.screen != GameScreen::InGame || !isActive()) return false; - if (isVerMax(V_110)) { - static bool monster_hp = false; + const int width = right - left; + const int height = bottom - top; + + if (d2::is_unit_hovered) { const auto unit = d2::getSelectedUnit(); - if (unit && unit->dwType == d2::UnitType::Monster && top == 18 && bottom == 34) { - if (!monster_hp) { - drawMonsterHealthBar(unit); - monster_hp = true; - } - return true; + if (unit && (unit->dwType == d2::UnitType::Player || d2::isMercUnit(unit))) { + if (d2::is_unit_hovered == 1) { + m_hovered_unit.hp[0] = width; + m_hovered_unit.pos = { left, top }; + } else + m_hovered_unit.hp[1] = width; } - monster_hp = false; + return true; } - const int width = right - left; - const int height = bottom - top; - // if (draw_mode == 1 && top < 200) { // trace("[] | %d | %d | %dx%d | %dx%d", color, draw_mode, left, top, width, height); // } - if (height == g_text_size[m_lang_id].hp_bar && m_hovered_player_id && m_text_size == 1 && (color == 0 || color == 261)) { - if (m_hovered_player_hp1 == 0) { - m_hovered_player_hp1 = width; - m_hovered_player_pos = { left, top }; - } else - m_hovered_player_hp2 = width; - return true; - } - if (color != 0) // skip drawing except black color return false; @@ -574,11 +561,19 @@ void HDText::drawSubText(uint8_t fn) static int *length, *x, *y; if (fn == 1) { - str = *(const wchar_t**)(ptr + (isVerMax(V_110) ? 0x20 : 0x68)); - color = (uint32_t*)(ptr + (isVerMax(V_110) ? 0x78 : 0x74)); - length = (int*)(ptr + (isVerMax(V_110) ? 0x1C : 0x10)); - x = (int*)(ptr + (isVerMax(V_110) ? 0x18 : 0x18)); - y = (int*)(ptr + (isVerMax(V_110) ? 0x70 : 0x6C)); + if (isVerMax(V_110)) { + str = *(const wchar_t**)(ptr + 0x20); + color = (uint32_t*)(ptr + 0x78); + length = (int*)(ptr + 0x1C); + x = (int*)(ptr + 0x18); + y = (int*)(ptr + 0x70); + } else { + str = *(const wchar_t**)(ptr + 0x68); + color = (uint32_t*)(ptr + 0x74); + length = (int*)(ptr + 0x10); + x = (int*)(ptr + 0x18); + y = (int*)(ptr + 0x6C); + } } else if (fn == 2) { str = (const wchar_t*)(ptr + 0x390); color = (uint32_t*)(ptr + 0x74); @@ -593,8 +588,8 @@ void HDText::drawSubText(uint8_t fn) y = (int*)(ptr + 0x8); } - if (m_hovered_player_id) { - drawPlayerHealthBar(isVer(V_114d) ? m_hovered_player_str : str, *color); + if (m_hovered_unit.id) { + m_hovered_unit.id = 0; *length = 0; return; } @@ -797,6 +792,20 @@ void HDText::drawEntryText() setTextSize(old_size); } +void HDText::drawUnitHealthBar() +{ + if (!isActive()) + return; + + d2::is_unit_hovered = 0; + if (const auto unit = d2::getSelectedUnit()) { + if (unit->dwType == d2::UnitType::Player || d2::isMercUnit(unit)) + drawPlayerHealthBar(unit); + else + drawMonsterHealthBar(unit); + } +} + void HDText::drawMonsterHealthBar(d2::UnitAny* unit) { const auto name = d2::getMonsterName(unit); @@ -821,7 +830,7 @@ void HDText::drawMonsterHealthBar(d2::UnitAny* unit) const auto text_size = font->getTextSize(name); float hp_percent = (float)hp / (float)max_hp; - glm::vec2 bar_size = { 120.0f, 18.0f }; + glm::vec2 bar_size = { 140.0f, 18.0f }; if (text_size.x + 40.0f > bar_size.x) bar_size.x = text_size.x + 40.0f; @@ -845,33 +854,39 @@ void HDText::drawMonsterHealthBar(d2::UnitAny* unit) text_color = L'\x34'; else if (type == d2::MonsterType::Champion) text_color = L'\x33'; + else + text_color = getColor(m_hovered_unit.color); if (hp == 0) text_color = L'\x31'; glm::vec2 text_pos = { center - text_size.x / 2, 19.3f + 14.5f }; font->drawText(name, text_pos, g_text_colors.at(text_color)); + m_hovered_unit.color = 0; } -void HDText::drawPlayerHealthBar(const wchar_t* name, uint32_t color) +void HDText::drawPlayerHealthBar(d2::UnitAny* unit) { - const uint32_t hp = m_hovered_player_hp1; - const uint32_t max_hp = m_hovered_player_hp1 + m_hovered_player_hp2; + const uint32_t hp = m_hovered_unit.hp[0]; + const uint32_t max_hp = m_hovered_unit.hp[0] + m_hovered_unit.hp[1]; const auto font = getFont(1); font->setShadow(2); font->setMasking(false); font->setAlign(TextAlign::Center); + if (isVerMax(V_110) && unit->dwType == d2::UnitType::Player) + mbstowcs_s(nullptr, m_hovered_unit.name, d2::getPlayerName(unit), 16); + const wchar_t* name = unit->dwType == d2::UnitType::Player ? m_hovered_unit.name : d2::getMonsterName(unit); const auto text_size = font->getTextSize(name); - float hp_percent = (float)hp / (float)max_hp; + const float hp_percent = (float)hp / (float)max_hp; glm::vec2 bar_size = { 60.0f, 16.0f }; if (text_size.x + 20.0f > bar_size.x) bar_size.x = text_size.x + 20.0f; - auto offset = modules::MotionPrediction::Instance().getUnitOffset(m_hovered_player_id); - const float center = (float)(m_hovered_player_pos.x + max_hp / 2) + (float)offset.x; - glm::vec2 bar_pos = { center - bar_size.x / 2, (float)m_hovered_player_pos.y + (float)offset.y }; + auto offset = modules::MotionPrediction::Instance().getUnitOffset(m_hovered_unit.id); + const float center = (float)(m_hovered_unit.pos.x + max_hp / 2) + (float)offset.x; + glm::vec2 bar_pos = { center - bar_size.x / 2, (float)m_hovered_unit.pos.y + (float)offset.y }; m_object_bg->setFlags(2); m_object_bg->setPosition(bar_pos); @@ -887,10 +902,10 @@ void HDText::drawPlayerHealthBar(const wchar_t* name, uint32_t color) } glm::vec2 text_pos = { center - text_size.x / 2, bar_pos.y + 14.5f }; - font->drawText(name, text_pos, g_text_colors.at(getColor(color))); + font->drawText(name, text_pos, g_text_colors.at(getColor(m_hovered_unit.color))); - m_hovered_player_id = 0; - m_hovered_player_hp1 = m_hovered_player_hp2 = 0; + m_hovered_unit.hp[0] = m_hovered_unit.hp[1] = 0; + m_hovered_unit.color = 0; } inline wchar_t HDText::getColor(uint32_t color) diff --git a/d2gl/src/modules/hd_text.h b/d2gl/src/modules/hd_text.h index e62fefc..396d595 100644 --- a/d2gl/src/modules/hd_text.h +++ b/d2gl/src/modules/hd_text.h @@ -30,6 +30,14 @@ enum class FramedTextType { Monster, }; +struct HoveredUnit { + uint32_t id = 0; + uint32_t hp[2] = { 0 }; + glm::ivec2 pos = { 0, 0 }; + wchar_t name[50] = { 0 }; + uint32_t color = 0; +}; + class HDText { std::map> m_fonts; std::unique_ptr m_object_bg; @@ -41,7 +49,6 @@ class HDText { bool m_map_names = false; bool m_bordered_rect = false; - bool m_draw_sub_text = true; bool m_is_player_dead = false; glm::mat4 m_mvp = glm::mat4(0.0f); @@ -53,11 +60,7 @@ class HDText { clock_t m_entry_timer = 0; int m_cur_level_no = 0; - uint32_t m_hovered_player_id = 0; - uint32_t m_hovered_player_hp1 = 0; - uint32_t m_hovered_player_hp2 = 0; - glm::ivec2 m_hovered_player_pos = { 0, 0 }; - wchar_t m_hovered_player_str[30] = { 0 }; + HoveredUnit m_hovered_unit; const uint32_t m_bg_color = 0x000000CC; const uint32_t m_border_color = 0x222222DD; @@ -100,6 +103,7 @@ class HDText { void drawRectFrame(); void loadUIImage(); + void drawUnitHealthBar(); void startEntryText(); void drawEntryText(); @@ -107,7 +111,7 @@ class HDText { private: void drawMonsterHealthBar(d2::UnitAny* unit); - void drawPlayerHealthBar(const wchar_t* name, uint32_t color); + void drawPlayerHealthBar(d2::UnitAny* unit); inline wchar_t getColor(uint32_t color); From 3bfc86770ba7c09d439d08628da181a42fd2d9e1 Mon Sep 17 00:00:00 2001 From: Walter White Date: Thu, 13 Jul 2023 12:25:49 +0900 Subject: [PATCH 06/14] shader error fix --- d2gl/src/graphic/shaders/mod.glsl | 2 +- d2gl/src/graphic/shaders/mod.glsl.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/d2gl/src/graphic/shaders/mod.glsl b/d2gl/src/graphic/shaders/mod.glsl index f148351..c5df365 100644 --- a/d2gl/src/graphic/shaders/mod.glsl +++ b/d2gl/src/graphic/shaders/mod.glsl @@ -160,7 +160,7 @@ void main() break; } if (v_Flags.z > 0u) - FragColor.a *= v_Flags.z / 100.0; + FragColor.a *= (float(v_Flags.z) * 0.01); } if (texture(u_MaskTexture, (gl_FragCoord.xy - u_Viewport.xy) / u_Viewport.zw).r > 0.1) diff --git a/d2gl/src/graphic/shaders/mod.glsl.h b/d2gl/src/graphic/shaders/mod.glsl.h index 63e28f0..c291751 100644 --- a/d2gl/src/graphic/shaders/mod.glsl.h +++ b/d2gl/src/graphic/shaders/mod.glsl.h @@ -140,7 +140,7 @@ "break;" "}" "if(v_Flags.z>0u)" - "FragColor.w*=v_Flags.z/1e2;" + "FragColor.w*=float(v_Flags.z)*.01;" "}" "if(texture(u_MaskTexture,(gl_FragCoord.xy-u_Viewport.xy)/u_Viewport.zw).x>.1)" "FragColor.w=0.;" From fdfbca21c3b68695dcc245395624ffefd146c5b0 Mon Sep 17 00:00:00 2001 From: Walter White Date: Thu, 13 Jul 2023 12:41:23 +0900 Subject: [PATCH 07/14] refactor --- d2gl/src/win32.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/d2gl/src/win32.cpp b/d2gl/src/win32.cpp index c78c9a4..c7f8886 100644 --- a/d2gl/src/win32.cpp +++ b/d2gl/src/win32.cpp @@ -234,10 +234,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) return 0; } if (option::Menu::instance().isVisible()) { - if (wParam == VK_ESCAPE) { - return 0; - } - if (wParam >= 0x30 && wParam <= 0x39) + if (wParam == VK_ESCAPE || (wParam >= 0x30 && wParam <= 0x39)) return 0; } } From 69383b339c657d7596dc236463c09f4bd8f0a555 Mon Sep 17 00:00:00 2001 From: Walter White Date: Thu, 13 Jul 2023 12:44:32 +0900 Subject: [PATCH 08/14] POR and SIN lang add --- d2gl/src/modules/hd_text.cpp | 2 + d2gl/src/modules/hd_text/variables.h | 99 ++++++++++++++++++++-------- 2 files changed, 73 insertions(+), 28 deletions(-) diff --git a/d2gl/src/modules/hd_text.cpp b/d2gl/src/modules/hd_text.cpp index 5940b0d..2457a04 100644 --- a/d2gl/src/modules/hd_text.cpp +++ b/d2gl/src/modules/hd_text.cpp @@ -33,6 +33,8 @@ HDText::HDText() std::string lang_file = helpers::getLangString(true); auto buffer = helpers::loadFile("assets\\atlases\\" + lang_file + ".txt"); + if (!buffer.size && m_lang_id == LANG_SIN) + buffer = helpers::loadFile("assets\\atlases\\chi.txt"); if (!buffer.size) buffer = helpers::loadFile("assets\\atlases\\default.txt"); diff --git a/d2gl/src/modules/hd_text/variables.h b/d2gl/src/modules/hd_text/variables.h index e54d770..f1eafae 100644 --- a/d2gl/src/modules/hd_text/variables.h +++ b/d2gl/src/modules/hd_text/variables.h @@ -43,7 +43,6 @@ struct D2TextInfo { struct D2TextMetrics { glm::vec<2, uint8_t> large_text; glm::vec<2, uint8_t> entry_text; - uint8_t hp_bar; }; // clang-format off @@ -104,18 +103,18 @@ inline const std::vector g_popups = { }; inline const std::vector g_text_size = { - { { 36, 26 }, { 26, 41 }, 16 }, // ENG - { { 36, 26 }, { 26, 41 }, 16 }, // ESP - { { 36, 26 }, { 26, 41 }, 16 }, // DEU - { { 36, 26 }, { 26, 41 }, 16 }, // FRA - { { 0, 0 }, { 0, 0 }, 0 }, // POR - { { 36, 26 }, { 26, 41 }, 16 }, // ITA - { { 44, 31 }, { 26, 31 }, 22 }, // JPN - { { 38, 34 }, { 26, 34 }, 22 }, // KOR - { { 0, 0 }, { 0, 0 }, 0 }, // SIN - { { 54, 34 }, { 31, 33 }, 18 }, // CHI - { { 37, 29 }, { 26, 29 }, 19 }, // POL - { { 41, 30 }, { 26, 30 }, 17 }, // RUS + { { 36, 26 }, { 26, 41 } }, // ENG + { { 36, 26 }, { 26, 41 } }, // ESP + { { 36, 26 }, { 26, 41 } }, // DEU + { { 36, 26 }, { 26, 41 } }, // FRA + { { 36, 26 }, { 26, 41 } }, // POR + { { 36, 26 }, { 26, 41 } }, // ITA + { { 44, 31 }, { 26, 31 } }, // JPN + { { 38, 34 }, { 26, 34 } }, // KOR + { { 54, 34 }, { 31, 33 } }, // SIN + { { 54, 34 }, { 31, 33 } }, // CHI + { { 37, 29 }, { 26, 29 } }, // POL + { { 41, 30 }, { 26, 30 } }, // RUS }; inline const std::vector> g_option_overwrites = { @@ -123,11 +122,11 @@ inline const std::vector> g_option_overwrites = { { "automapfade", "automapparty" }, // ESP { "resolution" }, // DEU { "textonly", "automapfade", "blendshadow", "perspective", "smallno", "smallyes" }, // FRA - { }, // POR + { "3dbias", "perspective", "resolution", "smallon", "smalloff" }, // POR { "smallyes", "auto", "automapparty", "smallno" }, // ITA { "perspective", "640x480", "automapfade", "blendshadow", "center", "everything", "full", "gamma", "low", "medium", "mini", "music" }, // JPN { "smallyes", "smallno", "sound", "music", "3dsound", "eax", "audioonly", "textonly", "videooptions", "resolution", "640x480", "medium", "low", "blendshadow", "gamma", "contrast", "automapoptions", "automapmode", "full", "automapfade", "everything", "center", "auto", "automapcenter", "automapparty", "automappartynames", "cfgoptions" }, // KOR - { }, // SIN + { "previous", "resolution", "smallno", "smalloff", "smallyes", "soundoptions", "sprevious", "textonly", "videooptions", "3dbias", "640x480", "800x600", "audioonly", "audiotext", "auto", "automapcenter", "automapfade", "automapmode", "automapparty", "automappartynames", "blendshadow", "center", "contrast", "eax", "everything", "full", "gamma", "high", "lightquality", "low", "medium", "mini", "music", "perspective", "cfgoptions" }, // SIN { "previous", "resolution", "smallno", "smalloff", "smallyes", "soundoptions", "sprevious", "textonly", "videooptions", "3dbias", "640x480", "800x600", "audioonly", "audiotext", "auto", "automapcenter", "automapfade", "automapmode", "automapparty", "automappartynames", "blendshadow", "center", "contrast", "eax", "everything", "full", "gamma", "high", "lightquality", "low", "medium", "mini", "music", "perspective", "cfgoptions" }, // CHI { "perspective", "medium", "center" }, // POL { "3dbias", "perspective", "resolution", "smallon", "blendshadow", "auto", "mini", "full", "automapmode", "contrast" }, // RUS @@ -314,7 +313,51 @@ inline std::map> g_options_text_others = { { 0, { 218, 26 }, L"AFFICHER NOMS" }, // SHOW NAMES { 1, { 226, 36 }, L"CONFIGURER COMMANDES" }, // CONFIGURE CONTROLS } }, - { LANG_POR, {} }, + { LANG_POR, { + { 0, { 160, 36 }, L"OPÇÕES" }, // OPTIONS + { 1, { 178, 36 }, L"SALVAR E SAIR DO JOGO" }, // SAVE AND EXIT GAME + { 1, { 100, 36 }, L"VOLTAR AO JOGO" }, // RETURN TO GAME + { 1, { 57, 36 }, L"MENU ANTERIOR" }, // PREVIOUS MENU + { 0, { 231, 26 }, L"MENU ANTERIOR" }, // PREVIOUS MENU + { 0, { 41, 26 }, L"SOBRE" }, // ON + { 0, { 52, 26 }, L"DESLIGADO" }, // OFF + { 0, { 51, 26 }, L"SIM" }, // YES + { 0, { 40, 26 }, L"NÃO" }, // NO + { 1, { 53, 36 }, L"OPÇÕES DE SOM" }, // SOUND OPTIONS + { 0, { 95, 26 }, L"SOM" }, // SOUND + { 0, { 84, 26 }, L"MÚSICA" }, // MUSIC + { 0, { 144, 26 }, L"SOM 3D" }, // 3D SOUND + { 1, { 106, 26 }, L"EFEITOS AMBIENTAIS" }, // ENVIRONMENTAL EFFECTS + { 0, { 109, 26 }, L"3D BIAS" }, // 3D BIAS + { 0, { 157, 26 }, L"NPC FALA" }, // NPC SPEECH + { 1, { 4, 26 }, L"ÁUDIO E TEXTO" }, // AUDIO AND TEXT + { 0, { 184, 26 }, L"SOMENTE AUDIO" }, // AUDIO ONLY + { 0, { 169, 26 }, L"SOMENTE TEXTO" }, // TEXT ONLY + { 1, { 39, 36 }, L"OPÇÕES DE VÍDEO" }, // VIDEO OPTIONS + { 0, { 175, 26 }, L"RESOLUÇÃO" }, // RESOLUTION + { 0, { 135, 26 }, L"800x600" }, // 800x600 + { 0, { 123, 26 }, L"640x480" }, // 640x480 + { 1, { 9, 26 }, L"QUALIDADE DE ILUMINAÇÃO" }, // LIGHTING QUALITY + { 0, { 57, 26 }, L"ALTO" }, // HIGH + { 0, { 108, 26 }, L"MÉDIO" }, // MEDIUM + { 0, { 66, 26 }, L"BAIXO" }, // LOW + { 1, { 10, 26 }, L"SOMBRAS MISTURADAS" }, // BLENDED SHADOWS + { 0, { 174, 26 }, L"PERSPECTIVA" }, // PERSPECTIVE + { 0, { 105, 26 }, L"GAMA" }, // GAMMA + { 0, { 151, 26 }, L"CONTRASTE" }, // CONTRAST + { 1, { 122, 36 }, L"OPÇÕES DE AUTOMAPA" }, // AUTOMAP OPTIONS + { 0, { 213, 26 }, L"TAMANHO DO AUTOMAPA" }, // AUTOMAP SIZE + { 0, { 180, 26 }, L"TELA CHEIA" }, // FULL SCREEN + { 0, { 131, 26 }, L"MINI MAPA" }, // MINI MAP + { 0, { 70, 26 }, L"DESAPARECER" }, // FADE + { 0, { 173, 26 }, L"TUDO" }, // EVERYTHING + { 0, { 104, 26 }, L"CENTRO" }, // CENTER + { 0, { 86, 26 }, L"AUTO" }, // AUTO + { 1, { 80, 26 }, L"CENTRALIZAR QUANDO LIMPO" }, // CENTER WHEN CLEARED + { 0, { 194, 26 }, L"FESTA DE SHOW" }, // SHOW PARTY + { 0, { 190, 26 }, L"MOSTRAR NOMES" }, // SHOW NAMES + { 1, { 167, 36 }, L"CONFIGURAR CONTROLES" }, // CONFIGURE CONTROLS + } }, { LANG_ITA, { { 0, { 146, 36 }, L"OPZIONI" }, // OPTIONS { 2, { 4, 36 }, L"SALVA ED ESCI DAL GIOCO" }, // SAVE AND EXIT GAME @@ -467,8 +510,8 @@ inline std::map> g_options_text_others = { { 0, { 97, 34 }, L"环场效果" }, // ENVIRONMENTAL EFFECTS { 0, { 81, 34 }, L"3D偏向" }, // 3D BIAS { 0, { 95, 34 }, L"NPC语音" }, // NPC SPEECH - { 0, { 120, 34 }, L"语音和文本" }, // AUDIO AND TEXT 音效和文本 - { 0, { 98, 34 }, L"仅语音" }, // AUDIO ONLY 仅音效 + { 0, { 120, 34 }, L"语音和文本" }, // AUDIO AND TEXT + { 0, { 98, 34 }, L"仅语音" }, // AUDIO ONLY { 0, { 99, 34 }, L"仅文本" }, // TEXT ONLY { 0, { 151, 54 }, L"视频选项" }, // VIDEO OPTIONS { 0, { 72, 34 }, L"分辨率" }, // RESOLUTION @@ -493,7 +536,7 @@ inline std::map> g_options_text_others = { { 0, { 121, 34 }, L"打开时居中" }, // CENTER WHEN CLEARED { 0, { 103, 34 }, L"显示队伍" }, // SHOW PARTY { 0, { 104, 34 }, L"显示名字" }, // SHOW NAMES - { 0, { 152, 54 }, L"操作设置" }, // CONFIGURE CONTROLS 设置控制 + { 0, { 152, 54 }, L"操作设置" }, // CONFIGURE CONTROLS } }, { LANG_CHI, { { 0, { 74, 54 }, L"選項" }, // OPTIONS @@ -686,9 +729,9 @@ inline const std::map> g_death_text_others = { { 1, { 220, 36 }, L"Vous avez perdu de l'or" }, // You lost gold } }, { LANG_POR, { - { 1, { 20, 36 }, L"Você morreu" }, // youdiedhardcore.dc6 - { 1, { 175, 36 }, L"Pressione ESC para continuar." }, // youdiedinst.dc6 - { 1, { 23, 36 }, L"You lost gold" }, // youdiedsoftcore.dc6 + { 1, { 20, 36 }, L"Você morreu" }, // You have died + { 1, { 175, 36 }, L"Pressione ESC para continuar." }, // Press ESC to continue + { 1, { 23, 36 }, L"Você perdeu ouro" }, // You lost gold } }, { LANG_ITA, { { 0, { 181, 36 }, L"Sei morto" }, // You have died @@ -721,12 +764,12 @@ inline const std::map> g_death_text_others = { { 1, { 250, 37 }, L"TWOJA POSTAĆ STRACIŁA ZŁOTO" }, // You lost gold } }, { LANG_RUS, { - { 1, { 20, 36 }, L"Вы умерли." }, - { 0, { 202, 41 }, L"Вы умерли." }, // You have died - { 1, { 245, 36 }, L"Нажмите ESC, чтобы продолжить." }, - { 2, { 73, 41 }, L"Нажмите ESC, чтобы продолжить." }, // Press ESC to continue - { 1, { 106, 36 }, L"You lost gold" }, - { 1, { 124, 41 }, L"You lost gold" }, // You lost gold + { 1, { 20, 36 }, L"Вы умерли" }, + { 0, { 202, 41 }, L"Вы умерли" }, // You have died + { 1, { 245, 36 }, L"Нажмите ESC, чтобы продолжить" }, + { 2, { 73, 41 }, L"Нажмите ESC, чтобы продолжить" }, // Press ESC to continue + { 1, { 106, 36 }, L"Вы потеряли золото" }, + { 1, { 124, 41 }, L"Вы потеряли золото" }, // You lost gold } }, }; From 79b516cf606bf267c99a42dfa3c2e9420caf482a Mon Sep 17 00:00:00 2001 From: Walter White Date: Thu, 13 Jul 2023 13:12:46 +0900 Subject: [PATCH 09/14] missing glyph renders (?) instead nothing --- d2gl/src/modules/hd_text.cpp | 6 ++++-- d2gl/src/modules/hd_text/glyph_set.cpp | 11 +++++++++++ d2gl/src/modules/hd_text/glyph_set.h | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/d2gl/src/modules/hd_text.cpp b/d2gl/src/modules/hd_text.cpp index 2457a04..6f0c42d 100644 --- a/d2gl/src/modules/hd_text.cpp +++ b/d2gl/src/modules/hd_text.cpp @@ -286,7 +286,8 @@ bool HDText::drawFramedText(const wchar_t* str, int x, int y, uint32_t color, ui } } - float font_size, line_count; + float font_size; + int line_count = 0; auto font = getFont(1); const auto text_color = g_text_colors.at(getColor(color)); glm::vec2 pos, padding, box_size, size; @@ -382,7 +383,8 @@ bool HDText::drawRectangledText(const wchar_t* str, int x, int y, uint32_t rect_ // rectColor = 0, rectTransparency = 1, dwColor = 0 alt item // rectColor = 140, rectTransparency = 5, dwColor = 0 alt item hovered - float font_size, line_count; + float font_size; + int line_count = 0; auto font = getFont(m_text_size); const auto text_color = g_text_colors.at(getColor(color)); uint32_t bg_color = m_bg_color; diff --git a/d2gl/src/modules/hd_text/glyph_set.cpp b/d2gl/src/modules/hd_text/glyph_set.cpp index 1ff5779..b4584e0 100644 --- a/d2gl/src/modules/hd_text/glyph_set.cpp +++ b/d2gl/src/modules/hd_text/glyph_set.cpp @@ -58,4 +58,15 @@ GlyphSet::GlyphSet(Texture* texture, const std::string& name) delete[] buffer.data; } +const Glyph* GlyphSet::getGlyph(wchar_t c) +{ + if (m_glyphes.find(c) != m_glyphes.end()) + return &m_glyphes[c]; + + if (c > 0x20) + return &m_glyphes[L'?']; + + return nullptr; +} + } \ No newline at end of file diff --git a/d2gl/src/modules/hd_text/glyph_set.h b/d2gl/src/modules/hd_text/glyph_set.h index 404ecd3..9912e9c 100644 --- a/d2gl/src/modules/hd_text/glyph_set.h +++ b/d2gl/src/modules/hd_text/glyph_set.h @@ -35,7 +35,7 @@ class GlyphSet { GlyphSet(Texture* texture, const std::string& name); ~GlyphSet() = default; - inline const Glyph* getGlyph(wchar_t c) { return m_glyphes.find(c) != m_glyphes.end() ? &m_glyphes[c] : nullptr; } + const Glyph* getGlyph(wchar_t c); }; } \ No newline at end of file From 9e1361f103a05e81f744ff575a4c78e500c384bf Mon Sep 17 00:00:00 2001 From: Walter White Date: Thu, 13 Jul 2023 16:09:08 +0900 Subject: [PATCH 10/14] fix --- d2gl/src/modules/hd_text/glyph_set.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/d2gl/src/modules/hd_text/glyph_set.cpp b/d2gl/src/modules/hd_text/glyph_set.cpp index b4584e0..e9559f4 100644 --- a/d2gl/src/modules/hd_text/glyph_set.cpp +++ b/d2gl/src/modules/hd_text/glyph_set.cpp @@ -62,7 +62,8 @@ const Glyph* GlyphSet::getGlyph(wchar_t c) { if (m_glyphes.find(c) != m_glyphes.end()) return &m_glyphes[c]; - + if (c == L'\xa0') + return &m_glyphes[L' ']; if (c > 0x20) return &m_glyphes[L'?']; From ed41b321a1d2d8ea66edbe35678e757175408a99 Mon Sep 17 00:00:00 2001 From: Walter White Date: Thu, 13 Jul 2023 16:20:05 +0900 Subject: [PATCH 11/14] version change --- d2gl/src/app.h | 2 +- ddraw/ddraw.rc | Bin 4528 -> 4528 bytes glide3x/glide3x.rc | Bin 4526 -> 4526 bytes 3 files changed, 1 insertion(+), 1 deletion(-) diff --git a/d2gl/src/app.h b/d2gl/src/app.h index 43f98ab..8a19fa5 100644 --- a/d2gl/src/app.h +++ b/d2gl/src/app.h @@ -38,7 +38,7 @@ struct D2GLApp { bool ready = false; std::string menu_title = "D2GL"; - std::string version_str = "D2GL v1.2.0 by Bayaraa."; + std::string version_str = "D2GL v1.2.1 by Bayaraa."; std::string ini_file = "d2gl.ini"; std::string mpq_file = "d2gl.mpq"; std::string log_file = "d2gl.log"; diff --git a/ddraw/ddraw.rc b/ddraw/ddraw.rc index fd00986283d321061f722f5af2fdf27b7e3ae35f..c48dd760e5bb246bc33e247d2cf0de7a9789e137 100644 GIT binary patch delta 50 zcmdm>yg_-xBo0Qy$&)z@84Wid<+#ekYRI6+U@*CmM|blX?rn^4uK4D8yh1Dhjcg7~ delta 50 zcmdm>yg_-xBo0P{$&)z@84Wfc<+#ekYQUh!U@*CmM|blX?rn^4uK4D8yh1DhjPnji diff --git a/glide3x/glide3x.rc b/glide3x/glide3x.rc index 1cb5a52a9031d71965947626822e6c191f051ca4..3099ed07b063b937c90944dfbd83a574f3a525fb 100644 GIT binary patch delta 34 ncmZ3dyiR$;Bo0Qy$&)z@84Widyt*s^&x{Ka delta 34 ncmZ3dyiR$;Bo0P{$&)z@84Wfcyt*s^&r1sq From 53a244765f24f2412012c80470e064cb7564cb95 Mon Sep 17 00:00:00 2001 From: Walter White Date: Thu, 13 Jul 2023 16:38:51 +0900 Subject: [PATCH 12/14] remove hd cursor requirements from minimap, hd text. --- d2gl/src/graphic/context.cpp | 4 +++- d2gl/src/modules/hd_text.h | 2 +- d2gl/src/modules/mini_map.h | 2 +- d2gl/src/option/ini.cpp | 6 +++--- d2gl/src/option/menu.cpp | 30 ++++++------------------------ 5 files changed, 14 insertions(+), 30 deletions(-) diff --git a/d2gl/src/graphic/context.cpp b/d2gl/src/graphic/context.cpp index c848ce8..4479b5a 100644 --- a/d2gl/src/graphic/context.cpp +++ b/d2gl/src/graphic/context.cpp @@ -707,6 +707,7 @@ void Context::onStageChange() modules::MiniMap::Instance().draw(); } + modules::HDText::Instance().drawEntryText(); modules::HDText::drawFpsCounter(); break; case DrawStage::CursorItem: @@ -714,8 +715,9 @@ void Context::onStageChange() setVertexFlagW(10); break; case DrawStage::Cursor: + flushVertices(); + setVertexFlagW(10); appendDelayedObjects(); - modules::HDText::Instance().drawEntryText(); #ifdef _HDTEXT modules::HDText::showSampleText(); #endif diff --git a/d2gl/src/modules/hd_text.h b/d2gl/src/modules/hd_text.h index 396d595..4af585e 100644 --- a/d2gl/src/modules/hd_text.h +++ b/d2gl/src/modules/hd_text.h @@ -77,7 +77,7 @@ class HDText { return instance; } - inline bool isActive() { return App.hd_cursor && App.hd_text; } + inline bool isActive() { return App.hd_text; } inline void setMVP(const glm::mat4& mvp) { m_mvp = mvp; } void reset(); diff --git a/d2gl/src/modules/mini_map.h b/d2gl/src/modules/mini_map.h index 804a74b..5e64ea0 100644 --- a/d2gl/src/modules/mini_map.h +++ b/d2gl/src/modules/mini_map.h @@ -36,7 +36,7 @@ class MiniMap { return instance; } - inline bool isActive() { return ISGLIDE3X() && App.hd_cursor && App.mini_map.active; } + inline bool isActive() { return ISGLIDE3X() && App.mini_map.active; } inline uint32_t getTimeWidth() const { return m_time_width; } void resize(); diff --git a/d2gl/src/option/ini.cpp b/d2gl/src/option/ini.cpp index da294f8..f940f30 100644 --- a/d2gl/src/option/ini.cpp +++ b/d2gl/src/option/ini.cpp @@ -220,12 +220,12 @@ void saveIni() "[Feature]\n\n" "; HD cursor in game & menu screen.\n" "hd_cursor=%s\n\n" - "; HD in game text (HD cursor required).\n" + "; HD in game text.\n" "hd_text=%s\n\n" - //"; HD life & mana orbs (HD cursor required).\n" + //"; HD life & mana orbs.\n" //"hd_orbs=%s\n" //"hd_orbs_centered=%s\n\n" - "; Always on Minimap widget (only available in glide mode, HD cursor required).\n" + "; Always on Minimap widget (only available in glide mode).\n" "mini_map=%s\n" "mini_map_text_over=%s\n" "mini_map_width=%d\n" diff --git a/d2gl/src/option/menu.cpp b/d2gl/src/option/menu.cpp index f27307f..f88b5b6 100644 --- a/d2gl/src/option/menu.cpp +++ b/d2gl/src/option/menu.cpp @@ -303,33 +303,15 @@ void Menu::draw() if (tabBegin("Features", 2, &active_tab)) { childBegin("##w5", true); drawCheckbox_m("HD Cursor", App.hd_cursor, "High-definition in game & menu screen cursor.", hd_cursor) - { saveBool("Feature", "hd_cursor", App.hd_cursor); - if (!App.hd_cursor) { - App.hd_text = false; - d2::patch_hd_text->toggle(App.hd_text); - saveBool("Feature", "hd_text", App.hd_text); - - App.hd_orbs.active = false; - saveBool("Feature", "hd_orbs", App.hd_orbs.active); - - if (ISGLIDE3X()) { - App.mini_map.active = false; - d2::patch_minimap->toggle(App.mini_map.active); - saveBool("Feature", "mini_map", App.mini_map.active); - } - } - } drawSeparator(); - ImGui::BeginDisabled(!App.hd_cursor); - drawCheckbox_m("HD Text", App.hd_text, "High-definition ingame texts.", hd_text) - { - d2::patch_hd_text->toggle(App.hd_text); - saveBool("Feature", "hd_text", App.hd_text); - } - ImGui::EndDisabled(); + drawCheckbox_m("HD Text", App.hd_text, "High-definition ingame texts.", hd_text) + { + d2::patch_hd_text->toggle(App.hd_text); + saveBool("Feature", "hd_text", App.hd_text); + } drawSeparator(); - ImGui::BeginDisabled(!ISGLIDE3X() || !App.hd_cursor || !App.mini_map.available); + ImGui::BeginDisabled(!ISGLIDE3X() || !App.mini_map.available); drawCheckbox_m("Mini Map", App.mini_map.active, "Always on minimap widget.", mini_map) { d2::patch_minimap->toggle(App.mini_map.active); From a2c373b59408efd52e43fdd611053b540b5e276a Mon Sep 17 00:00:00 2001 From: Walter White Date: Thu, 13 Jul 2023 19:48:42 +0900 Subject: [PATCH 13/14] shader fix --- d2gl/src/graphic/shaders/mod.glsl | 2 +- d2gl/src/graphic/shaders/mod.glsl.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/d2gl/src/graphic/shaders/mod.glsl b/d2gl/src/graphic/shaders/mod.glsl index c5df365..90d8a15 100644 --- a/d2gl/src/graphic/shaders/mod.glsl +++ b/d2gl/src/graphic/shaders/mod.glsl @@ -119,7 +119,7 @@ void main() FragColor = texture(u_MapTexture, v_TexCoord); FragColor.rgb = greyscale(FragColor.rgb, 0.2); if (v_Flags.z > 0u) - FragColor.a *= v_Flags.z / 100.0; + FragColor.a *= (float(v_Flags.z) * 0.01); break; case 6u: FragColor = v_Color1; diff --git a/d2gl/src/graphic/shaders/mod.glsl.h b/d2gl/src/graphic/shaders/mod.glsl.h index c291751..d0830a1 100644 --- a/d2gl/src/graphic/shaders/mod.glsl.h +++ b/d2gl/src/graphic/shaders/mod.glsl.h @@ -100,7 +100,7 @@ "FragColor=texture(u_MapTexture,v_TexCoord);" "FragColor.xyz=v(FragColor.xyz,.2);" "if(v_Flags.z>0u)" - "FragColor.w*=v_Flags.z/1e2;" + "FragColor.w*=float(v_Flags.z)*.01;" "break;" "case 6u:" "FragColor=v_Color1;" From 742644f2de427b2272e80b67f4995fecb23d54a9 Mon Sep 17 00:00:00 2001 From: Walter White Date: Thu, 13 Jul 2023 19:48:56 +0900 Subject: [PATCH 14/14] unit hover bug fix --- d2gl/src/modules/hd_text.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/d2gl/src/modules/hd_text.cpp b/d2gl/src/modules/hd_text.cpp index 6f0c42d..52a0efc 100644 --- a/d2gl/src/modules/hd_text.cpp +++ b/d2gl/src/modules/hd_text.cpp @@ -798,10 +798,10 @@ void HDText::drawEntryText() void HDText::drawUnitHealthBar() { + d2::is_unit_hovered = 0; if (!isActive()) return; - d2::is_unit_hovered = 0; if (const auto unit = d2::getSelectedUnit()) { if (unit->dwType == d2::UnitType::Player || d2::isMercUnit(unit)) drawPlayerHealthBar(unit);