feat(parity): implement EterBase CTimer, image/slot cooldown geometry rendering (pass32)
This commit is contained in:
+1
-1
@@ -30,7 +30,7 @@ if(AVA2_EMBED_PYTHON)
|
||||
add_library(ava2_lzo STATIC third_party/ava2-lzo/lzo1x_d2.c)
|
||||
target_include_directories(ava2_lzo PUBLIC third_party/ava2-lzo)
|
||||
set_target_properties(ava2_lzo PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
add_library(ava2_python src/python_background.cpp src/python_pet_skill.cpp src/item_sound.cpp src/python_offline_shop.cpp src/python_switchbot.cpp src/python_dungeon_info.cpp src/python_drop_item.cpp src/python_battlepass.cpp src/python_guild.cpp src/python_shop_search.cpp src/python_cube_renewal.cpp src/python_messenger.cpp src/python_quest.cpp src/nonplayer_data.cpp src/python_wiki.cpp src/python_runtime.cpp src/python_net.cpp src/python_dbg.cpp src/python_system.cpp src/python_minimap.cpp src/python_chr.cpp src/python_app.cpp src/player_settings.cpp src/python_wndmgr.cpp src/python_gameplay_modules.cpp src/python_ime.cpp src/python_grp.cpp src/python_native_modules.cpp src/python_event_manager.cpp src/python_chat.cpp src/eter_lib/parser.cpp src/eter_base/Random.cpp src/game_type.cpp src/eter_ui/PythonWindow.cpp src/eter_ui/PythonWindowManager.cpp src/eter_net/PythonNetworkStream.cpp src/eter_net/PythonNetworkStreamCommand.cpp src/eter_net/PythonNetworkStreamPhaseGameRecv.cpp src/eter_net/PythonExchange.cpp src/eter_net/PythonSafeBox.cpp)
|
||||
add_library(ava2_python src/python_background.cpp src/python_pet_skill.cpp src/item_sound.cpp src/python_offline_shop.cpp src/python_switchbot.cpp src/python_dungeon_info.cpp src/python_drop_item.cpp src/python_battlepass.cpp src/python_guild.cpp src/python_shop_search.cpp src/python_cube_renewal.cpp src/python_messenger.cpp src/python_quest.cpp src/nonplayer_data.cpp src/python_wiki.cpp src/python_runtime.cpp src/python_net.cpp src/python_dbg.cpp src/python_system.cpp src/python_minimap.cpp src/python_chr.cpp src/python_app.cpp src/player_settings.cpp src/python_wndmgr.cpp src/python_gameplay_modules.cpp src/python_ime.cpp src/python_grp.cpp src/python_native_modules.cpp src/python_event_manager.cpp src/python_chat.cpp src/eter_lib/parser.cpp src/eter_base/Random.cpp src/eter_base/Timer.cpp src/game_type.cpp src/eter_ui/PythonWindow.cpp src/eter_ui/PythonWindowManager.cpp src/eter_net/PythonNetworkStream.cpp src/eter_net/PythonNetworkStreamCommand.cpp src/eter_net/PythonNetworkStreamPhaseGameRecv.cpp src/eter_net/PythonExchange.cpp src/eter_net/PythonSafeBox.cpp)
|
||||
target_include_directories(ava2_python PUBLIC src ${CMAKE_CURRENT_SOURCE_DIR} third_party/extern_include)
|
||||
target_link_libraries(ava2_python PUBLIC SDL3::SDL3 mtpython ava2_render PRIVATE mt_codepage ava2_transport ava2_lzo ava2_poly)
|
||||
endif()
|
||||
|
||||
@@ -724,3 +724,23 @@ Validation: macOS build and Android arm64 libmain.so pass. Five targeted CTests
|
||||
- `python3 tools/audit_ava2_python_interfaces.py`: **46 Windows modules compared; 0 missing methods; 0 overlapping placeholder methods**.
|
||||
- CTest suite: **41/41 tests passed (100%)**.
|
||||
- Android arm64 `libmain.so` and macOS arm64 `ava2_client` build cleanly.
|
||||
|
||||
## 2026-10-08 pass32 — EterBase Timer & Singleton, image/slot cooldown geometry rendering (dracaryS_DUNGEON_LIB)
|
||||
- **EterBase CTimer and ELTimer Parity**:
|
||||
- Added `src/eter_base/Singleton.h` and `src/eter_base/Timer.h` / `src/eter_base/Timer.cpp` replicating upstream Windows `EterBase/Timer.h` and `Timer.cpp`.
|
||||
- Implemented `CTimer : public CSingleton<CTimer>` with safe singleton fallback, `Advance()`, `Adjust()`, `SetBaseTime()`, `GetCurrentSecond()`, `GetCurrentMillisecond()`, `GetElapsedSecond()`, `GetElapsedMilliecond()`, and `UseCustomTime()`.
|
||||
- Implemented `ELTimer_Init()`, `ELTimer_GetMSec()`, `ELTimer_SetServerMSec()`, `ELTimer_GetServerMSec()`, `ELTimer_SetFrameMSec()`, `ELTimer_GetFrameMSec()`, and `ELTimer_GetServerFrameMSec()`.
|
||||
- Updated `src/python_app.cpp` `SetServerMSec` and `ResetPythonAppState` to synchronize with `ELTimer`.
|
||||
- **Image Cooldown Geometry Rendering (`dracaryS_DUNGEON_LIB`)**:
|
||||
- Declared and implemented `RenderCoolTime(float fCoolTime)` and `OnRenderCoolTime(float fCoolTime)` on `CGraphicImageInstance` in `src/eter_image/GrpImageInstance.h` and `.cpp`.
|
||||
- Declared and implemented `RenderCoolTime(float fCoolTime)` and `OnRenderCoolTime(float fCoolTime)` on `CGraphicExpandedImageInstance` in `src/eter_image/GrpExpandedImageInstance.h` and `GrpImageInstance.cpp`.
|
||||
- Formed 8-triangle radial fan sweep geometry rendered via hardware-accelerated `SDL_RenderGeometry` matching upstream Direct3D behavior.
|
||||
- **Python Window Cooldown Parity**:
|
||||
- Updated `CImageBox::OnRender()` and `CExpandedImageBox::OnRender()` in `src/eter_ui/PythonWindow.cpp` to call `RenderCoolTime((CTimer::Instance().GetCurrentSecond() - m_fCoolTimeStart) / m_fCoolTime)` when `m_fCoolTime != 0.0f` matching upstream lines 1687 and 1895.
|
||||
- Updated `CSlotWindow::OnRender()` in `src/eter_ui/PythonWindow.cpp` to render radial clock-sweep cooldown geometry via `SDL_RenderGeometry` matching upstream `CPythonGraphic::RenderCoolTimeBox`.
|
||||
- **Results**:
|
||||
- Checked packet constants: **240**, 0 mismatches, 0 unmatched.
|
||||
- `python3 tools/audit_windows_parity.py`: **0 placeholder bindings**.
|
||||
- `python3 tools/audit_ava2_python_interfaces.py`: **46 Windows modules compared; 0 missing methods; 0 overlapping placeholder methods**.
|
||||
- CTest suite: **41/41 tests passed (100%)**.
|
||||
- Android arm64 `libmain.so` and macOS arm64 `ava2_client` build cleanly.
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
#pragma once
|
||||
#include "shared/common/Singleton.h"
|
||||
@@ -0,0 +1,138 @@
|
||||
#include "Timer.h"
|
||||
#include <chrono>
|
||||
|
||||
static DWORD gs_dwBaseTime = 0;
|
||||
static DWORD gs_dwServerTime = 0;
|
||||
static DWORD gs_dwClientTime = 0;
|
||||
static DWORD gs_dwFrameTime = 0;
|
||||
|
||||
static DWORD LocalClockMSec()
|
||||
{
|
||||
auto now = std::chrono::steady_clock::now();
|
||||
return static_cast<DWORD>(std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch()).count());
|
||||
}
|
||||
|
||||
BOOL ELTimer_Init()
|
||||
{
|
||||
gs_dwBaseTime = LocalClockMSec();
|
||||
gs_dwServerTime = 0;
|
||||
gs_dwClientTime = 0;
|
||||
gs_dwFrameTime = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
DWORD ELTimer_GetMSec()
|
||||
{
|
||||
if (gs_dwBaseTime == 0)
|
||||
ELTimer_Init();
|
||||
return LocalClockMSec() - gs_dwBaseTime;
|
||||
}
|
||||
|
||||
VOID ELTimer_SetServerMSec(DWORD dwServerTime)
|
||||
{
|
||||
if (0 != dwServerTime)
|
||||
{
|
||||
gs_dwServerTime = dwServerTime;
|
||||
gs_dwClientTime = CTimer::Instance().GetCurrentMillisecond();
|
||||
}
|
||||
}
|
||||
|
||||
DWORD ELTimer_GetServerMSec()
|
||||
{
|
||||
return CTimer::Instance().GetCurrentMillisecond() - gs_dwClientTime + gs_dwServerTime;
|
||||
}
|
||||
|
||||
DWORD ELTimer_GetFrameMSec()
|
||||
{
|
||||
return gs_dwFrameTime;
|
||||
}
|
||||
|
||||
DWORD ELTimer_GetServerFrameMSec()
|
||||
{
|
||||
return ELTimer_GetFrameMSec() - gs_dwClientTime + gs_dwServerTime;
|
||||
}
|
||||
|
||||
VOID ELTimer_SetFrameMSec()
|
||||
{
|
||||
gs_dwFrameTime = ELTimer_GetMSec();
|
||||
}
|
||||
|
||||
CTimer::CTimer()
|
||||
{
|
||||
m_dwBaseTime = 0;
|
||||
m_dwCurrentTime = 0;
|
||||
m_bUseRealTime = true;
|
||||
m_index = 0;
|
||||
m_dwElapsedTime = 0;
|
||||
m_fCurrentTime = 0.0f;
|
||||
}
|
||||
|
||||
CTimer::~CTimer()
|
||||
{
|
||||
}
|
||||
|
||||
void CTimer::SetBaseTime()
|
||||
{
|
||||
m_dwCurrentTime = 0;
|
||||
}
|
||||
|
||||
void CTimer::Advance()
|
||||
{
|
||||
if (!m_bUseRealTime)
|
||||
{
|
||||
++m_index;
|
||||
if (m_index == 1)
|
||||
m_index = -1;
|
||||
|
||||
m_dwCurrentTime += 16 + (m_index & 1);
|
||||
m_fCurrentTime = m_dwCurrentTime / 1000.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
DWORD currentTime = ELTimer_GetMSec();
|
||||
if (m_dwCurrentTime == 0)
|
||||
m_dwCurrentTime = currentTime;
|
||||
|
||||
m_dwElapsedTime = currentTime - m_dwCurrentTime;
|
||||
m_dwCurrentTime = currentTime;
|
||||
}
|
||||
}
|
||||
|
||||
void CTimer::Adjust(int iTimeGap)
|
||||
{
|
||||
m_dwCurrentTime += iTimeGap;
|
||||
}
|
||||
|
||||
float CTimer::GetCurrentSecond()
|
||||
{
|
||||
if (m_bUseRealTime)
|
||||
return ELTimer_GetMSec() / 1000.0f;
|
||||
|
||||
return m_fCurrentTime;
|
||||
}
|
||||
|
||||
DWORD CTimer::GetCurrentMillisecond()
|
||||
{
|
||||
if (m_bUseRealTime)
|
||||
return ELTimer_GetMSec();
|
||||
|
||||
return m_dwCurrentTime;
|
||||
}
|
||||
|
||||
float CTimer::GetElapsedSecond()
|
||||
{
|
||||
return GetElapsedMilliecond() / 1000.0f;
|
||||
}
|
||||
|
||||
DWORD CTimer::GetElapsedMilliecond()
|
||||
{
|
||||
if (!m_bUseRealTime)
|
||||
return 16 + (m_index & 1);
|
||||
|
||||
return m_dwElapsedTime;
|
||||
}
|
||||
|
||||
void CTimer::UseCustomTime()
|
||||
{
|
||||
m_bUseRealTime = false;
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
#pragma once
|
||||
|
||||
#include "shared/common/Singleton.h"
|
||||
#include <cstdint>
|
||||
|
||||
#ifndef DWORD
|
||||
typedef uint32_t DWORD;
|
||||
#endif
|
||||
#ifndef BOOL
|
||||
typedef int BOOL;
|
||||
#endif
|
||||
#ifndef VOID
|
||||
#define VOID void
|
||||
#endif
|
||||
|
||||
class CTimer : public CSingleton<CTimer>
|
||||
{
|
||||
public:
|
||||
CTimer();
|
||||
virtual ~CTimer();
|
||||
|
||||
static CTimer& Instance()
|
||||
{
|
||||
CTimer* p = CSingleton<CTimer>::InstancePtr();
|
||||
if (!p)
|
||||
{
|
||||
static CTimer s_defaultTimer;
|
||||
return s_defaultTimer;
|
||||
}
|
||||
return *p;
|
||||
}
|
||||
|
||||
static CTimer* InstancePtr()
|
||||
{
|
||||
CTimer* p = CSingleton<CTimer>::InstancePtr();
|
||||
if (!p)
|
||||
{
|
||||
static CTimer s_defaultTimer;
|
||||
return &s_defaultTimer;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
static CTimer& instance()
|
||||
{
|
||||
return Instance();
|
||||
}
|
||||
|
||||
void Advance();
|
||||
void Adjust(int iTimeGap);
|
||||
void SetBaseTime();
|
||||
|
||||
float GetCurrentSecond();
|
||||
DWORD GetCurrentMillisecond();
|
||||
|
||||
float GetElapsedSecond();
|
||||
DWORD GetElapsedMilliecond();
|
||||
|
||||
void UseCustomTime();
|
||||
|
||||
protected:
|
||||
bool m_bUseRealTime;
|
||||
DWORD m_dwBaseTime;
|
||||
DWORD m_dwCurrentTime;
|
||||
float m_fCurrentTime;
|
||||
DWORD m_dwElapsedTime;
|
||||
int m_index;
|
||||
};
|
||||
|
||||
BOOL ELTimer_Init();
|
||||
|
||||
DWORD ELTimer_GetMSec();
|
||||
|
||||
VOID ELTimer_SetServerMSec(DWORD dwServerTime);
|
||||
DWORD ELTimer_GetServerMSec();
|
||||
|
||||
VOID ELTimer_SetFrameMSec();
|
||||
DWORD ELTimer_GetFrameMSec();
|
||||
DWORD ELTimer_GetServerFrameMSec();
|
||||
@@ -70,6 +70,7 @@ public:
|
||||
UpdateRenderingRect();
|
||||
}
|
||||
void SetRenderingMode(int iMode) { m_iRenderingMode = iMode; }
|
||||
void RenderCoolTime(float fCoolTime);
|
||||
|
||||
protected:
|
||||
void Initialize()
|
||||
@@ -97,6 +98,7 @@ protected:
|
||||
}
|
||||
|
||||
void OnRender() override;
|
||||
void OnRenderCoolTime(float fCoolTime) override;
|
||||
|
||||
protected:
|
||||
struct RECT_FLOAT
|
||||
|
||||
@@ -196,3 +196,277 @@ void CGraphicExpandedImageInstance::OnRender()
|
||||
SDL_RenderTextureRotated(renderer, tex, &srcRect, &dstRect, m_fRotation, ¢er, flip);
|
||||
}
|
||||
}
|
||||
|
||||
void CGraphicImageInstance::RenderCoolTime(float fCoolTime)
|
||||
{
|
||||
if (IsEmpty())
|
||||
return;
|
||||
|
||||
OnRenderCoolTime(fCoolTime);
|
||||
}
|
||||
|
||||
void CGraphicImageInstance::OnRenderCoolTime(float fCoolTime)
|
||||
{
|
||||
CGraphicDevice* pDevice = CGraphicDevice::InstancePtr();
|
||||
if (!pDevice) return;
|
||||
SDL_Renderer* renderer = pDevice->GetRenderer();
|
||||
if (!renderer) return;
|
||||
|
||||
CGraphicImage* pImage = m_roImage.GetPointer();
|
||||
if (!pImage) return;
|
||||
CGraphicTexture* pTexture = pImage->GetTexturePointer();
|
||||
if (!pTexture) return;
|
||||
SDL_Texture* tex = pTexture->GetSDLTexture(renderer);
|
||||
if (!tex) return;
|
||||
|
||||
float fimgWidth = pImage->GetWidth() * m_v2Scale.x;
|
||||
float fimgHeight = pImage->GetHeight() * m_v2Scale.y;
|
||||
float fimgWidthHalf = fimgWidth * 0.5f;
|
||||
float fimgHeightHalf = fimgHeight * 0.5f;
|
||||
|
||||
const RECT& c_rRect = pImage->GetRectReference();
|
||||
float texReverseWidth = 1.0f / float(pTexture->GetWidth());
|
||||
float texReverseHeight = 1.0f / float(pTexture->GetHeight());
|
||||
float su = c_rRect.left * texReverseWidth;
|
||||
float sv = c_rRect.top * texReverseHeight;
|
||||
float eu = c_rRect.right * texReverseWidth;
|
||||
float ev = c_rRect.bottom * texReverseHeight;
|
||||
float euh = (su + eu) * 0.5f;
|
||||
float evh = (sv + ev) * 0.5f;
|
||||
float fxCenter = m_v2Position.x + fimgWidthHalf - 0.5f;
|
||||
float fyCenter = m_v2Position.y + fimgHeightHalf - 0.5f;
|
||||
|
||||
if (fCoolTime >= 1.0f)
|
||||
return;
|
||||
if (fCoolTime < 0.0f)
|
||||
fCoolTime = 0.0f;
|
||||
|
||||
const int c_iTriangleCountPerBox = 8;
|
||||
static D3DXVECTOR2 s_v2BoxPos[c_iTriangleCountPerBox] =
|
||||
{
|
||||
D3DXVECTOR2(-1.0f, -1.0f),
|
||||
D3DXVECTOR2(-1.0f, 0.0f),
|
||||
D3DXVECTOR2(-1.0f, +1.0f),
|
||||
D3DXVECTOR2(0.0f, +1.0f),
|
||||
D3DXVECTOR2(+1.0f, +1.0f),
|
||||
D3DXVECTOR2(+1.0f, 0.0f),
|
||||
D3DXVECTOR2(+1.0f, -1.0f),
|
||||
D3DXVECTOR2(0.0f, -1.0f),
|
||||
};
|
||||
|
||||
D3DXVECTOR2 v2TexPos[c_iTriangleCountPerBox] =
|
||||
{
|
||||
D3DXVECTOR2(su, sv),
|
||||
D3DXVECTOR2(su, evh),
|
||||
D3DXVECTOR2(su, ev),
|
||||
D3DXVECTOR2(euh, ev),
|
||||
D3DXVECTOR2(eu, ev),
|
||||
D3DXVECTOR2(eu, evh),
|
||||
D3DXVECTOR2(eu, sv),
|
||||
D3DXVECTOR2(euh, sv),
|
||||
};
|
||||
|
||||
int iTriCount = int(8.0f - 8.0f * fCoolTime);
|
||||
float fLastPercentage = (8.0f - 8.0f * fCoolTime) - iTriCount;
|
||||
|
||||
struct TVert {
|
||||
float x, y;
|
||||
float u, v;
|
||||
};
|
||||
std::vector<TVert> vertices;
|
||||
vertices.push_back({ fxCenter, fyCenter, euh, evh });
|
||||
vertices.push_back({ fxCenter, fyCenter - fimgHeightHalf - 0.5f, euh, sv });
|
||||
|
||||
if (iTriCount > 0)
|
||||
{
|
||||
for (int j = 0; j < iTriCount; ++j)
|
||||
{
|
||||
vertices.push_back({
|
||||
fxCenter + (s_v2BoxPos[j].x * fimgWidthHalf) - 0.5f,
|
||||
fyCenter + (s_v2BoxPos[j].y * fimgHeightHalf) - 0.5f,
|
||||
v2TexPos[j & (c_iTriangleCountPerBox - 1)].x,
|
||||
v2TexPos[j & (c_iTriangleCountPerBox - 1)].y
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (fLastPercentage > 0.0f)
|
||||
{
|
||||
D3DXVECTOR2* pv2Pos = &s_v2BoxPos[(iTriCount + 7) % 8];
|
||||
D3DXVECTOR2* pv2LastPos = &s_v2BoxPos[(iTriCount + 8) % 8];
|
||||
float fxShit = (pv2LastPos->x - pv2Pos->x) * fLastPercentage + pv2Pos->x;
|
||||
float fyShit = (pv2LastPos->y - pv2Pos->y) * fLastPercentage + pv2Pos->y;
|
||||
vertices.push_back({
|
||||
fimgWidthHalf * fxShit + fxCenter - 0.5f,
|
||||
fimgHeightHalf * fyShit + fyCenter - 0.5f,
|
||||
euh + fxShit * (eu - euh),
|
||||
evh + fyShit * (ev - evh)
|
||||
});
|
||||
++iTriCount;
|
||||
}
|
||||
|
||||
if (vertices.size() < 3 || iTriCount <= 0)
|
||||
return;
|
||||
|
||||
std::vector<SDL_Vertex> sdlVertices(vertices.size());
|
||||
for (size_t i = 0; i < vertices.size(); ++i) {
|
||||
sdlVertices[i].position.x = vertices[i].x;
|
||||
sdlVertices[i].position.y = vertices[i].y;
|
||||
sdlVertices[i].color = SDL_FColor{ m_DiffuseColor.r, m_DiffuseColor.g, m_DiffuseColor.b, m_DiffuseColor.a };
|
||||
sdlVertices[i].tex_coord = SDL_FPoint{ vertices[i].u, vertices[i].v };
|
||||
}
|
||||
|
||||
std::vector<int> indices;
|
||||
indices.reserve(iTriCount * 3);
|
||||
for (int k = 0; k < iTriCount; ++k) {
|
||||
indices.push_back(0);
|
||||
indices.push_back(k + 1);
|
||||
indices.push_back(k + 2);
|
||||
}
|
||||
|
||||
SDL_SetTextureBlendMode(tex, SDL_BLENDMODE_BLEND);
|
||||
SDL_RenderGeometry(renderer, tex, sdlVertices.data(), static_cast<int>(sdlVertices.size()), indices.data(), static_cast<int>(indices.size()));
|
||||
}
|
||||
|
||||
void CGraphicExpandedImageInstance::RenderCoolTime(float fCoolTime)
|
||||
{
|
||||
if (IsEmpty())
|
||||
return;
|
||||
|
||||
OnRenderCoolTime(fCoolTime);
|
||||
}
|
||||
|
||||
void CGraphicExpandedImageInstance::OnRenderCoolTime(float fCoolTime)
|
||||
{
|
||||
CGraphicDevice* pDevice = CGraphicDevice::InstancePtr();
|
||||
if (!pDevice) return;
|
||||
SDL_Renderer* renderer = pDevice->GetRenderer();
|
||||
if (!renderer) return;
|
||||
|
||||
CGraphicImage* pImage = m_roImage.GetPointer();
|
||||
if (!pImage) return;
|
||||
CGraphicTexture* pTexture = pImage->GetTexturePointer();
|
||||
if (!pTexture) return;
|
||||
SDL_Texture* tex = pTexture->GetSDLTexture(renderer);
|
||||
if (!tex) return;
|
||||
|
||||
if (fCoolTime >= 1.0f)
|
||||
return;
|
||||
if (fCoolTime < 0.0f)
|
||||
fCoolTime = 0.0f;
|
||||
|
||||
const RECT& c_rRect = pImage->GetRectReference();
|
||||
float texReverseWidth = 1.0f / float(pTexture->GetWidth());
|
||||
float texReverseHeight = 1.0f / float(pTexture->GetHeight());
|
||||
|
||||
float su = (c_rRect.left - m_RenderingRect.left) * texReverseWidth;
|
||||
float sv = (c_rRect.top - m_RenderingRect.top) * texReverseHeight;
|
||||
float eu = (c_rRect.right + m_RenderingRect.right) * texReverseWidth;
|
||||
float ev = (c_rRect.bottom + m_RenderingRect.bottom) * texReverseHeight;
|
||||
|
||||
float fimgWidth = c_rRect.right - c_rRect.left;
|
||||
float fimgHeight = c_rRect.bottom - c_rRect.top;
|
||||
float fimgWidthHalf = fimgWidth * 0.5f;
|
||||
float fimgHeightHalf = fimgHeight * 0.5f;
|
||||
|
||||
float fxCenter = m_v2Position.x - 0.5f + fimgWidthHalf;
|
||||
float fyCenter = m_v2Position.y - 0.5f + fimgHeightHalf;
|
||||
|
||||
const int c_iTriangleCountPerBox = 8;
|
||||
static D3DXVECTOR2 v2BoxPos[c_iTriangleCountPerBox] =
|
||||
{
|
||||
D3DXVECTOR2(-1.0f, -1.0f),
|
||||
D3DXVECTOR2(-1.0f, 0.0f),
|
||||
D3DXVECTOR2(-1.0f, +1.0f),
|
||||
D3DXVECTOR2(0.0f, +1.0f),
|
||||
D3DXVECTOR2(+1.0f, +1.0f),
|
||||
D3DXVECTOR2(+1.0f, 0.0f),
|
||||
D3DXVECTOR2(+1.0f, -1.0f),
|
||||
D3DXVECTOR2(0.0f, -1.0f),
|
||||
};
|
||||
|
||||
D3DXVECTOR2 v2TexPos[c_iTriangleCountPerBox] =
|
||||
{
|
||||
D3DXVECTOR2(su, sv),
|
||||
D3DXVECTOR2(su, 0.5f * (ev + sv)),
|
||||
D3DXVECTOR2(su, ev),
|
||||
D3DXVECTOR2(0.5f * (su + eu), ev),
|
||||
D3DXVECTOR2(eu, ev),
|
||||
D3DXVECTOR2(eu, 0.5f * (ev + sv)),
|
||||
D3DXVECTOR2(eu, sv),
|
||||
D3DXVECTOR2(0.5f * (su + eu), sv),
|
||||
};
|
||||
|
||||
int iTriCount = int(8.0f - 8.0f * fCoolTime);
|
||||
float fLastPercentage = (8.0f - 8.0f * fCoolTime) - iTriCount;
|
||||
|
||||
struct TVert {
|
||||
float x, y;
|
||||
float u, v;
|
||||
};
|
||||
std::vector<TVert> vertices;
|
||||
vertices.push_back({ fxCenter, fyCenter, 0.5f * (su + eu), 0.5f * (ev + sv) });
|
||||
vertices.push_back({ fxCenter, fyCenter - fimgHeightHalf, 0.5f * (su + eu), sv });
|
||||
|
||||
if (iTriCount > 0)
|
||||
{
|
||||
for (int j = 0; j < iTriCount; ++j)
|
||||
{
|
||||
vertices.push_back({
|
||||
fxCenter + (v2BoxPos[j].x * fimgWidthHalf),
|
||||
fyCenter + (v2BoxPos[j].y * fimgHeightHalf),
|
||||
v2TexPos[j & (c_iTriangleCountPerBox - 1)].x,
|
||||
v2TexPos[j & (c_iTriangleCountPerBox - 1)].y
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (fLastPercentage > 0.0f)
|
||||
{
|
||||
D3DXVECTOR2* pv2Pos = &v2BoxPos[(iTriCount + 7) % 8];
|
||||
D3DXVECTOR2* pv2LastPos = &v2BoxPos[(iTriCount + 8) % 8];
|
||||
float fxShit = (pv2LastPos->x - pv2Pos->x) * fLastPercentage + pv2Pos->x;
|
||||
float fyShit = (pv2LastPos->y - pv2Pos->y) * fLastPercentage + pv2Pos->y;
|
||||
vertices.push_back({
|
||||
fimgWidthHalf * fxShit + fxCenter + 0.5f,
|
||||
fimgHeightHalf * fyShit + fyCenter + 0.5f,
|
||||
su + 0.5f * (eu - su) + fxShit * 0.5f * (eu - su),
|
||||
sv + 0.5f * (ev - sv) + fyShit * 0.5f * (ev - sv)
|
||||
});
|
||||
++iTriCount;
|
||||
}
|
||||
|
||||
if (vertices.size() < 3 || iTriCount <= 0)
|
||||
return;
|
||||
|
||||
std::vector<SDL_Vertex> sdlVertices(vertices.size());
|
||||
for (size_t i = 0; i < vertices.size(); ++i) {
|
||||
sdlVertices[i].position.x = vertices[i].x;
|
||||
sdlVertices[i].position.y = vertices[i].y;
|
||||
sdlVertices[i].color = SDL_FColor{ m_DiffuseColor.r, m_DiffuseColor.g, m_DiffuseColor.b, m_DiffuseColor.a };
|
||||
sdlVertices[i].tex_coord = SDL_FPoint{ vertices[i].u, vertices[i].v };
|
||||
}
|
||||
|
||||
std::vector<int> indices;
|
||||
indices.reserve(iTriCount * 3);
|
||||
for (int k = 0; k < iTriCount; ++k) {
|
||||
indices.push_back(0);
|
||||
indices.push_back(k + 1);
|
||||
indices.push_back(k + 2);
|
||||
}
|
||||
|
||||
switch (m_iRenderingMode) {
|
||||
case RENDERING_MODE_SCREEN:
|
||||
case RENDERING_MODE_COLOR_DODGE:
|
||||
SDL_SetTextureBlendMode(tex, SDL_BLENDMODE_ADD);
|
||||
break;
|
||||
case RENDERING_MODE_MODULATE:
|
||||
SDL_SetTextureBlendMode(tex, SDL_BLENDMODE_MOD);
|
||||
break;
|
||||
default:
|
||||
SDL_SetTextureBlendMode(tex, SDL_BLENDMODE_BLEND);
|
||||
break;
|
||||
}
|
||||
|
||||
SDL_RenderGeometry(renderer, tex, sdlVertices.data(), static_cast<int>(sdlVertices.size()), indices.data(), static_cast<int>(indices.size()));
|
||||
}
|
||||
|
||||
@@ -91,6 +91,8 @@ public:
|
||||
return m_roImage->GetHeight();
|
||||
}
|
||||
|
||||
void RenderCoolTime(float fCoolTime);
|
||||
|
||||
void LeftRightReverse()
|
||||
{
|
||||
m_bLeftRightReverse = true;
|
||||
@@ -128,6 +130,7 @@ protected:
|
||||
}
|
||||
|
||||
virtual void OnRender();
|
||||
virtual void OnRenderCoolTime(float fCoolTime);
|
||||
virtual void OnSetImagePointer() {}
|
||||
|
||||
virtual BOOL OnIsType(DWORD dwType)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "PythonWindow.h"
|
||||
#include "PythonWindowManager.h"
|
||||
#include "src/eter_image/GrpDevice.h"
|
||||
#include "eter_base/Timer.h"
|
||||
#include "eter_render/CRenderTarget.h"
|
||||
#include "shared/common/CRC32.h"
|
||||
#include <SDL3/SDL.h>
|
||||
@@ -847,7 +848,12 @@ namespace UI
|
||||
if (!m_pImageInstance)
|
||||
return;
|
||||
if (IsShow())
|
||||
m_pImageInstance->Render();
|
||||
{
|
||||
if (m_fCoolTime == 0.0f)
|
||||
m_pImageInstance->Render();
|
||||
else
|
||||
m_pImageInstance->RenderCoolTime((CTimer::Instance().GetCurrentSecond() - m_fCoolTimeStart) / m_fCoolTime);
|
||||
}
|
||||
}
|
||||
|
||||
void CImageBox::OnChangePosition()
|
||||
@@ -988,8 +994,15 @@ namespace UI
|
||||
|
||||
void CExpandedImageBox::OnRender()
|
||||
{
|
||||
if (m_pImageInstance && IsShow())
|
||||
m_pImageInstance->Render();
|
||||
if (!m_pImageInstance)
|
||||
return;
|
||||
if (IsShow())
|
||||
{
|
||||
if (m_fCoolTime == 0.0f)
|
||||
m_pImageInstance->Render();
|
||||
else
|
||||
((CGraphicExpandedImageInstance*)m_pImageInstance)->RenderCoolTime((CTimer::Instance().GetCurrentSecond() - m_fCoolTimeStart) / m_fCoolTime);
|
||||
}
|
||||
}
|
||||
|
||||
// CAniImageBox
|
||||
@@ -1573,7 +1586,7 @@ namespace UI
|
||||
// Render cooltime overlay & countdown text
|
||||
CGraphicDevice* pDevice = CGraphicDevice::InstancePtr();
|
||||
SDL_Renderer* ren = pDevice ? pDevice->GetRenderer() : nullptr;
|
||||
float curTime = SDL_GetTicks() / 1000.0f;
|
||||
float curTime = CTimer::Instance().GetCurrentSecond();
|
||||
|
||||
for (auto& pair : m_slotMap) {
|
||||
SSlot& slot = pair.second;
|
||||
@@ -1581,16 +1594,65 @@ namespace UI
|
||||
float elapsed = curTime - slot.fStartCoolTime;
|
||||
if (elapsed < slot.fCoolTime) {
|
||||
if (ren) {
|
||||
float percent = std::max(0.0f, std::min(1.0f, (slot.fCoolTime - elapsed) / slot.fCoolTime));
|
||||
SDL_SetRenderDrawBlendMode(ren, SDL_BLENDMODE_BLEND);
|
||||
SDL_SetRenderDrawColor(ren, 15, 15, 15, 175);
|
||||
SDL_FRect shadeRect{
|
||||
static_cast<float>(m_rect.left + slot.ixPosition),
|
||||
static_cast<float>(m_rect.top + slot.iyPosition + slot.iyCellSize * (1.0f - percent)),
|
||||
static_cast<float>(slot.ixCellSize),
|
||||
static_cast<float>(slot.iyCellSize * percent)
|
||||
};
|
||||
SDL_RenderFillRect(ren, &shadeRect);
|
||||
float percent = (curTime - slot.fStartCoolTime) / slot.fCoolTime;
|
||||
float fRadius = slot.ixCellSize * 0.5f;
|
||||
float fxCenter = m_rect.left + slot.ixPosition + fRadius;
|
||||
float fyCenter = m_rect.top + slot.iyPosition + fRadius;
|
||||
|
||||
if (percent < 1.0f) {
|
||||
if (percent < 0.0f) percent = 0.0f;
|
||||
const int c_iTriangleCountPerBox = 8;
|
||||
static const SDL_FPoint s_v2BoxPos[c_iTriangleCountPerBox] = {
|
||||
{ -1.0f, -1.0f },
|
||||
{ -1.0f, 0.0f },
|
||||
{ -1.0f, +1.0f },
|
||||
{ 0.0f, +1.0f },
|
||||
{ +1.0f, +1.0f },
|
||||
{ +1.0f, 0.0f },
|
||||
{ +1.0f, -1.0f },
|
||||
{ 0.0f, -1.0f },
|
||||
};
|
||||
int iTriCount = static_cast<int>(8.0f - 8.0f * percent);
|
||||
float fLastPercentage = (8.0f - 8.0f * percent) - iTriCount;
|
||||
|
||||
std::vector<SDL_Vertex> vertices;
|
||||
SDL_FColor color{ 0.0f, 0.0f, 0.0f, 0.55f };
|
||||
vertices.push_back({ { fxCenter, fyCenter }, color, { 0.0f, 0.0f } });
|
||||
vertices.push_back({ { fxCenter, fyCenter - fRadius }, color, { 0.0f, 0.0f } });
|
||||
|
||||
for (int j = 0; j < iTriCount; ++j) {
|
||||
vertices.push_back({
|
||||
{ fxCenter + s_v2BoxPos[j].x * fRadius, fyCenter + s_v2BoxPos[j].y * fRadius },
|
||||
color,
|
||||
{ 0.0f, 0.0f }
|
||||
});
|
||||
}
|
||||
|
||||
if (fLastPercentage > 0.0f) {
|
||||
const SDL_FPoint* pv2LastPos = &s_v2BoxPos[(iTriCount - 1 + 8) % 8];
|
||||
const SDL_FPoint* pv2Pos = &s_v2BoxPos[(iTriCount + 8) % 8];
|
||||
float lx = (pv2Pos->x - pv2LastPos->x) * fLastPercentage + pv2LastPos->x;
|
||||
float ly = (pv2Pos->y - pv2LastPos->y) * fLastPercentage + pv2LastPos->y;
|
||||
vertices.push_back({
|
||||
{ fxCenter + lx * fRadius, fyCenter + ly * fRadius },
|
||||
color,
|
||||
{ 0.0f, 0.0f }
|
||||
});
|
||||
++iTriCount;
|
||||
}
|
||||
|
||||
if (vertices.size() >= 3 && iTriCount > 0) {
|
||||
std::vector<int> indices;
|
||||
indices.reserve(iTriCount * 3);
|
||||
for (int k = 0; k < iTriCount; ++k) {
|
||||
indices.push_back(0);
|
||||
indices.push_back(k + 1);
|
||||
indices.push_back(k + 2);
|
||||
}
|
||||
SDL_SetRenderDrawBlendMode(ren, SDL_BLENDMODE_BLEND);
|
||||
SDL_RenderGeometry(ren, nullptr, vertices.data(), static_cast<int>(vertices.size()), indices.data(), static_cast<int>(indices.size()));
|
||||
}
|
||||
}
|
||||
|
||||
int remainSec = static_cast<int>(std::ceil(slot.fCoolTime - elapsed));
|
||||
if (remainSec > 0 && slot.ixCellSize >= 24) {
|
||||
@@ -1603,6 +1665,9 @@ namespace UI
|
||||
SDL_RenderDebugText(ren, tx, ty, buf);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
slot.fCoolTime = 0.0f;
|
||||
slot.fStartCoolTime = 0.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -16,6 +16,7 @@
|
||||
#include "python_wiki.h"
|
||||
#include "shared/common/PythonUtils.h"
|
||||
#include "eter_base/Random.h"
|
||||
#include "eter_base/Timer.h"
|
||||
#include "python_background.h"
|
||||
#include "eter_ui/PythonWindowManager.h"
|
||||
#include "eter_effect/EffectManager.h"
|
||||
@@ -444,9 +445,9 @@ std::int32_t GetServerTimeStamp() { return server_clock.timestamp(unix_seconds()
|
||||
void SetServerTime(std::int32_t time) { server_clock.set(time,local_milliseconds(),unix_seconds()); }
|
||||
std::uint32_t GetLocalMSec() { return local_milliseconds(); }
|
||||
std::int32_t GetApplicationSeconds() { return static_cast<std::int32_t>(std::chrono::duration_cast<std::chrono::seconds>(std::chrono::steady_clock::now()-app_start).count()); }
|
||||
void SetServerMSec(std::uint32_t time) { if(time==0) return;elt_server_time=time;elt_client_time=local_milliseconds(); }
|
||||
void SetServerMSec(std::uint32_t time) { if(time==0) return;elt_server_time=time;elt_client_time=local_milliseconds(); ELTimer_SetServerMSec(time); }
|
||||
std::uint32_t GetServerMSec() { return local_milliseconds()-elt_client_time+elt_server_time; }
|
||||
void ResetPythonAppState() { elt_server_time=elt_client_time=0;server_clock=ServerClock(local_milliseconds());app_start=std::chrono::steady_clock::now();s_test_server_flag=false;twoHandedAttackSpeedDecrease=0; }
|
||||
void ResetPythonAppState() { elt_server_time=elt_client_time=0;ELTimer_Init();server_clock=ServerClock(local_milliseconds());app_start=std::chrono::steady_clock::now();s_test_server_flag=false;twoHandedAttackSpeedDecrease=0; }
|
||||
std::uint8_t GetEnterGameLanguage() {
|
||||
const char* locales[]={"ymir","en","de","tr","pt","es","fr","ro","pl","it","cz","hu"};
|
||||
for(std::uint8_t i=1;i<12;++i) if(s_locale_name==locales[i]) return i;
|
||||
|
||||
Reference in New Issue
Block a user