mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-02-03 12:31:15 +00:00
Merge branch 'flatpak' of github.com:iAmSomeone2/isle-portable into flatpak
This commit is contained in:
commit
155407129f
@ -60,6 +60,8 @@ message(STATUS "Internal miniwin: ${ISLE_MINIWIN}")
|
||||
message(STATUS "Isle debugging: ${ISLE_DEBUG}")
|
||||
message(STATUS "Compile shaders: ${ISLE_COMPILE_SHADERS}")
|
||||
|
||||
add_library(Isle::iniparser INTERFACE IMPORTED)
|
||||
|
||||
if (DOWNLOAD_DEPENDENCIES)
|
||||
# FetchContent downloads and configures dependencies
|
||||
message(STATUS "Fetching SDL3 and iniparser. This might take a while...")
|
||||
@ -82,6 +84,7 @@ if (DOWNLOAD_DEPENDENCIES)
|
||||
set(BUILD_DOCS off)
|
||||
set(BUILD_SHARED_LIBS off)
|
||||
FetchContent_MakeAvailable(iniparser)
|
||||
target_link_libraries(Isle::iniparser INTERFACE iniparser-static)
|
||||
endblock()
|
||||
else()
|
||||
# find_package looks for already-installed system packages.
|
||||
@ -89,10 +92,8 @@ else()
|
||||
# to add search paths.
|
||||
find_package(SDL3 CONFIG REQUIRED)
|
||||
|
||||
find_package(iniparser CONFIG COMPONENTS static)
|
||||
if (NOT TARGET iniparser-static)
|
||||
find_package(iniparser REQUIRED MODULE COMPONENTS static)
|
||||
endif()
|
||||
find_package(iniparser REQUIRED CONFIG COMPONENTS shared)
|
||||
target_link_libraries(Isle::iniparser INTERFACE iniparser-shared)
|
||||
endif()
|
||||
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
@ -493,7 +494,7 @@ if (ISLE_BUILD_APP)
|
||||
target_link_libraries(isle PRIVATE $<$<BOOL:${ISLE_USE_DX5}>:DirectX5::DirectX5>)
|
||||
|
||||
# Link SDL and iniparser
|
||||
target_link_libraries(isle PRIVATE SDL3::SDL3 iniparser-static)
|
||||
target_link_libraries(isle PRIVATE SDL3::SDL3 Isle::iniparser)
|
||||
|
||||
# Allow unconditional include of miniwin/miniwindevice.h
|
||||
target_link_libraries(isle PRIVATE miniwin-headers)
|
||||
@ -556,7 +557,7 @@ if (ISLE_BUILD_CONFIG)
|
||||
target_link_libraries(config PRIVATE DirectX5::DirectX5)
|
||||
endif()
|
||||
target_compile_definitions(config PRIVATE DIRECT3D_VERSION=0x500)
|
||||
target_link_libraries(config PRIVATE SDL3::SDL3 iniparser-static)
|
||||
target_link_libraries(config PRIVATE SDL3::SDL3 Isle::iniparser)
|
||||
if (NOT ISLE_MINIWIN)
|
||||
target_link_libraries(config PRIVATE ddraw dxguid)
|
||||
endif()
|
||||
|
||||
@ -78,6 +78,9 @@ class LegoVideoManager : public MxVideoManager {
|
||||
|
||||
inline void DrawCursor();
|
||||
|
||||
void DrawDigitToBuffer32(uint8_t* p_dst, int p_pitch, int p_x, int p_y, int p_digit, uint32_t p_color);
|
||||
void DrawTextToSurface32(uint8_t* p_dst, int p_pitch, int p_x, int p_y, const char* p_text, uint32_t p_color);
|
||||
|
||||
Tgl::Renderer* m_renderer; // 0x64
|
||||
Lego3DManager* m_3dManager; // 0x68
|
||||
LegoROI* m_viewROI; // 0x6c
|
||||
|
||||
@ -406,37 +406,14 @@ inline void LegoVideoManager::DrawCursor()
|
||||
// FUNCTION: LEGO1 0x1007bbc0
|
||||
void LegoVideoManager::DrawFPS()
|
||||
{
|
||||
char zeros[8] = "0000.00";
|
||||
|
||||
if (m_unk0x528 == NULL) {
|
||||
m_arialFont = CreateFont(
|
||||
12,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
FW_NORMAL,
|
||||
FALSE,
|
||||
FALSE,
|
||||
FALSE,
|
||||
ANSI_CHARSET,
|
||||
OUT_DEFAULT_PRECIS,
|
||||
CLIP_DEFAULT_PRECIS,
|
||||
DEFAULT_QUALITY,
|
||||
FF_DONTCARE | VARIABLE_PITCH,
|
||||
"Arial"
|
||||
);
|
||||
int width = 64; // Big enough for 9999.99
|
||||
int height = 16;
|
||||
|
||||
HDC dc = GetDC(NULL);
|
||||
SelectObject(dc, m_arialFont);
|
||||
GetTextExtentPoint(dc, zeros, strlen(zeros), &m_fpsSize);
|
||||
ReleaseDC(NULL, dc);
|
||||
|
||||
m_unk0x528 = m_displaySurface->FUN_100bc8b0(m_fpsSize.cx, m_fpsSize.cy);
|
||||
SetRect(&m_fpsRect, 0, 0, m_fpsSize.cx, m_fpsSize.cy);
|
||||
m_unk0x528 = m_displaySurface->FUN_100bc8b0(width, height);
|
||||
SetRect(&m_fpsRect, 0, 0, width, height);
|
||||
|
||||
if (m_unk0x528 == NULL) {
|
||||
DeleteObject(m_arialFont);
|
||||
m_arialFont = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -450,9 +427,7 @@ void LegoVideoManager::DrawFPS()
|
||||
|
||||
if (m_unk0x528->Lock(NULL, &surfaceDesc, DDLOCK_WAIT, NULL) != DD_OK) {
|
||||
m_unk0x528->Release();
|
||||
DeleteObject(m_arialFont);
|
||||
m_unk0x528 = NULL;
|
||||
m_arialFont = NULL;
|
||||
}
|
||||
else {
|
||||
DWORD i;
|
||||
@ -472,8 +447,7 @@ void LegoVideoManager::DrawFPS()
|
||||
if (Timer()->GetTime() > m_unk0x54c + 5000.f) {
|
||||
char buffer[32];
|
||||
MxFloat time = (Timer()->GetTime() - m_unk0x54c) / 1000.0f;
|
||||
MxS32 nb = sprintf(buffer, "%.02f", m_unk0x550 / time);
|
||||
SDL_Log("%.02f", m_unk0x550 / time);
|
||||
sprintf(buffer, "%.02f", m_unk0x550 / time);
|
||||
m_unk0x54c = Timer()->GetTime();
|
||||
|
||||
DDSURFACEDESC surfaceDesc;
|
||||
@ -481,37 +455,13 @@ void LegoVideoManager::DrawFPS()
|
||||
surfaceDesc.dwSize = sizeof(surfaceDesc);
|
||||
|
||||
if (m_unk0x528->Lock(NULL, &surfaceDesc, DDLOCK_WAIT, NULL) == DD_OK) {
|
||||
DWORD i;
|
||||
char* ptr = (char*) surfaceDesc.lpSurface;
|
||||
memset(surfaceDesc.lpSurface, 0, surfaceDesc.lPitch * surfaceDesc.dwHeight);
|
||||
|
||||
for (i = 0; i < surfaceDesc.dwHeight; i++) {
|
||||
memset(ptr, 0, surfaceDesc.lPitch);
|
||||
ptr += surfaceDesc.lPitch;
|
||||
}
|
||||
DrawTextToSurface32((uint8_t*) surfaceDesc.lpSurface, surfaceDesc.lPitch, 0, 0, buffer, 0xFF0000FF);
|
||||
|
||||
m_unk0x528->Unlock(surfaceDesc.lpSurface);
|
||||
m_unk0x550 = 1.f;
|
||||
}
|
||||
|
||||
HDC dc;
|
||||
if (m_unk0x528->GetDC(&dc) != DD_OK) {
|
||||
m_unk0x528->Release();
|
||||
m_unk0x528 = NULL;
|
||||
DeleteObject(m_arialFont);
|
||||
m_arialFont = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
SelectObject(dc, m_arialFont);
|
||||
SetTextColor(dc, RGB(255, 255, 0));
|
||||
SetBkColor(dc, RGB(0, 0, 0));
|
||||
SetBkMode(dc, OPAQUE);
|
||||
GetTextExtentPoint32(dc, buffer, nb, &m_fpsSize);
|
||||
|
||||
RECT rect;
|
||||
SetRect(&rect, 0, 0, m_fpsSize.cx, m_fpsSize.cy);
|
||||
ExtTextOut(dc, 0, 0, ETO_OPAQUE, &rect, buffer, nb, NULL);
|
||||
m_unk0x528->ReleaseDC(dc);
|
||||
m_unk0x550 = 1.f;
|
||||
}
|
||||
else {
|
||||
m_unk0x550 += 1.f;
|
||||
@ -826,3 +776,63 @@ MxResult LegoVideoManager::ConfigureD3DRM()
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
void LegoVideoManager::DrawDigitToBuffer32(uint8_t* p_dst, int p_pitch, int p_x, int p_y, int p_digit, uint32_t p_color)
|
||||
{
|
||||
if (p_digit < 0 || p_digit > 9) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t* pixels = (uint32_t*) p_dst;
|
||||
int rowStride = p_pitch / 4;
|
||||
|
||||
// 4x5 bitmap font
|
||||
const uint8_t digitFont[5][10] = {
|
||||
{0b1111, 0b0001, 0b1111, 0b1111, 0b1001, 0b1111, 0b1111, 0b1111, 0b1111, 0b1111},
|
||||
{0b1001, 0b0001, 0b0001, 0b0001, 0b1001, 0b1000, 0b1000, 0b0001, 0b1001, 0b1001},
|
||||
{0b1001, 0b0001, 0b1111, 0b1111, 0b1111, 0b1111, 0b1111, 0b0010, 0b1111, 0b1111},
|
||||
{0b1001, 0b0001, 0b1000, 0b0001, 0b0001, 0b0001, 0b1001, 0b0010, 0b1001, 0b0001},
|
||||
{0b1111, 0b0001, 0b1111, 0b1111, 0b0001, 0b1111, 0b1111, 0b0100, 0b1111, 0b1111},
|
||||
};
|
||||
|
||||
for (int row = 0; row < 5; ++row) {
|
||||
uint8_t bits = digitFont[row][p_digit];
|
||||
for (int col = 0; col < 5; ++col) {
|
||||
if (bits & (1 << (4 - col))) {
|
||||
for (int dy = 0; dy < 2; ++dy) {
|
||||
for (int dx = 0; dx < 2; ++dx) {
|
||||
pixels[(p_y + row * 2 + dy) * rowStride + (p_x + col * 2 + dx)] = p_color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LegoVideoManager::DrawTextToSurface32(
|
||||
uint8_t* p_dst,
|
||||
int p_pitch,
|
||||
int p_x,
|
||||
int p_y,
|
||||
const char* p_text,
|
||||
uint32_t p_color
|
||||
)
|
||||
{
|
||||
while (*p_text) {
|
||||
if (*p_text >= '0' && *p_text <= '9') {
|
||||
DrawDigitToBuffer32(p_dst, p_pitch, p_x, p_y, *p_text - '0', p_color);
|
||||
p_x += 10;
|
||||
}
|
||||
else if (*p_text == '.') {
|
||||
uint32_t* pixels = (uint32_t*) p_dst;
|
||||
int rowStride = p_pitch / 4;
|
||||
for (int dy = 0; dy < 2; ++dy) {
|
||||
for (int dx = 0; dx < 2; ++dx) {
|
||||
pixels[(p_y + 10 + dy) * rowStride + (p_x + 2 + dx)] = p_color;
|
||||
}
|
||||
}
|
||||
p_x += 4;
|
||||
}
|
||||
++p_text;
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,7 +46,6 @@
|
||||
#define CLIP_DEFAULT_PRECIS 0
|
||||
#define DEFAULT_QUALITY 0
|
||||
#define ETO_OPAQUE 0x0002
|
||||
#define FF_DONTCARE 0x00000000
|
||||
#define RASTERCAPS 0x00000000
|
||||
#define RC_PALETTE 0x0100
|
||||
#define SIZEPALETTE 104
|
||||
|
||||
Loading…
Reference in New Issue
Block a user