Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/Linux_x86_64_SDL3_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ jobs:
uses: actions/cache@v4
with:
path: build
key: ${{ github.workflow }}-v2-${{ github.sha }}
restore-keys: ${{ github.workflow }}-v2-
key: ${{ github.workflow }}-v3-${{ github.sha }}
restore-keys: ${{ github.workflow }}-v3-

# We specify `-DDEVILUTIONX_SYSTEM_BENCHMARK=OFF` to work around the following error:
# lto1: fatal error: bytecode stream in file ‘/usr/lib/x86_64-linux-gnu/libbenchmark_main.a’ generated with LTO version 11.2 instead of the expected 11.3
Expand Down
7 changes: 5 additions & 2 deletions 3rdParty/libsmackerdec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ include(functions/FetchContent_ExcludeFromAll_backport)

include(FetchContent)
FetchContent_Declare_ExcludeFromAll(libsmackerdec
URL https://github.com/diasurgical/libsmackerdec/archive/91e732bb6953489077430572f43fc802bf2c75b2.tar.gz
URL_HASH MD5=c3b1ecbe702266e149b158178a03e2b3
URL https://github.com/diasurgical/libsmackerdec/archive/0aaaf8c94a097b009d844db0d44dd7cd0ff81922.tar.gz
URL_HASH SHA256=c3a7fbc91531eee8989b1d281415adc0209d84ffc0437c6b0b4f677ae7fd3b41
)
FetchContent_MakeAvailable_ExcludeFromAll(libsmackerdec)

Expand All @@ -17,6 +17,9 @@ target_include_directories(libsmackerdec PUBLIC ${libsmackerdec_SOURCE_DIR}/incl

if(USE_SDL1)
target_link_libraries(libsmackerdec PUBLIC ${SDL_LIBRARY})
elseif(USE_SDL3)
target_link_libraries(libsmackerdec PUBLIC SDL3::SDL3)
target_compile_definitions(libsmackerdec PUBLIC USE_SDL3)
elseif(TARGET SDL2::SDL2 AND NOT (DEVILUTIONX_STATIC_SDL2 AND TARGET SDL2::SDL2-static))
target_link_libraries(libsmackerdec PUBLIC SDL2::SDL2)
elseif(TARGET SDL2::SDL2-static)
Expand Down
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,12 @@ endif()

# Graphics options
if(NOT USE_SDL1)
set(DEVILUTIONX_DISPLAY_TEXTURE_FORMAT "SDL_PIXELFORMAT_RGB888" CACHE STRING "Texture format for DevilutionX textures when using the GPU renderer")
if(USE_SDL3)
set(_texture_format_default "SDL_PIXELFORMAT_XRGB8888")
else()
set(_texture_format_default "SDL_PIXELFORMAT_RGB888")
endif()
set(DEVILUTIONX_DISPLAY_TEXTURE_FORMAT "${_texture_format_default}" CACHE STRING "Texture format for DevilutionX textures when using the GPU renderer")
mark_as_advanced(DEVILUTIONX_DISPLAY_TEXTURE_FORMAT)
endif()

Expand Down
13 changes: 13 additions & 0 deletions Source/DiabloUI/button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

#include <optional>

#ifdef USE_SDL3
#include <SDL3/SDL_events.h>
#include <SDL3/SDL_mouse.h>
#else
#include <SDL.h>

Check warning on line 9 in Source/DiabloUI/button.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/DiabloUI/button.cpp:9:1 [misc-include-cleaner]

included header SDL.h is not used directly
#endif

#include "DiabloUI/diabloui.h"
#include "DiabloUI/ui_flags.hpp"
Expand Down Expand Up @@ -55,18 +60,26 @@
{ .flags = UiFlags::AlignCenter | UiFlags::FontSizeDialog | UiFlags::ColorDialogWhite });
}

bool HandleMouseEventButton(const SDL_Event &event, UiButton *button)

Check warning on line 63 in Source/DiabloUI/button.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/DiabloUI/button.cpp:63:35 [misc-include-cleaner]

no header providing "SDL_Event" is directly included
{
if (event.button.button != SDL_BUTTON_LEFT)

Check warning on line 65 in Source/DiabloUI/button.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/DiabloUI/button.cpp:65:29 [misc-include-cleaner]

no header providing "SDL_BUTTON_LEFT" is directly included
return false;
switch (event.type) {
#ifdef USE_SDL3
case SDL_EVENT_MOUSE_BUTTON_UP:
#else
case SDL_MOUSEBUTTONUP:

Check warning on line 71 in Source/DiabloUI/button.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/DiabloUI/button.cpp:71:7 [misc-include-cleaner]

no header providing "SDL_MOUSEBUTTONUP" is directly included
#endif
if (button->IsPressed()) {
button->Activate();
return true;
}
return false;
#ifdef USE_SDL3
case SDL_EVENT_MOUSE_BUTTON_DOWN:
#else
case SDL_MOUSEBUTTONDOWN:

Check warning on line 81 in Source/DiabloUI/button.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/DiabloUI/button.cpp:81:7 [misc-include-cleaner]

no header providing "SDL_MOUSEBUTTONDOWN" is directly included
#endif
button->Press();
return true;
default:
Expand Down
18 changes: 17 additions & 1 deletion Source/DiabloUI/credits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@
#include <string_view>
#include <vector>

#ifdef USE_SDL3
#include <SDL3/SDL_events.h>
#include <SDL3/SDL_rect.h>
#include <SDL3/SDL_surface.h>
#include <SDL3/SDL_timer.h>
#else
#include <SDL.h>

Check warning on line 15 in Source/DiabloUI/credits.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/DiabloUI/credits.cpp:15:1 [misc-include-cleaner]

included header SDL.h is not used directly
#endif

#include "DiabloUI/credits_lines.h"
#include "DiabloUI/diabloui.h"
Expand All @@ -30,7 +37,7 @@

namespace {

const SDL_Rect VIEWPORT = { 0, 114, 640, 251 };

Check warning on line 40 in Source/DiabloUI/credits.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/DiabloUI/credits.cpp:40:7 [misc-include-cleaner]

no header providing "SDL_Rect" is directly included
const int LINE_H = 22;

// The maximum number of visible lines is the number of whole lines
Expand Down Expand Up @@ -65,7 +72,7 @@
}
}

ticks_begin_ = SDL_GetTicks();

Check warning on line 75 in Source/DiabloUI/credits.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/DiabloUI/credits.cpp:75:18 [misc-include-cleaner]

no header providing "SDL_GetTicks" is directly included
prev_offset_y_ = 0;
finished_ = false;
}
Expand All @@ -76,9 +83,9 @@
ArtBackground = std::nullopt;
}

void Render();

Check warning on line 86 in Source/DiabloUI/credits.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/DiabloUI/credits.cpp:86:7 [readability-identifier-naming]

invalid case style for method 'Render'

[[nodiscard]] bool Finished() const

Check warning on line 88 in Source/DiabloUI/credits.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/DiabloUI/credits.cpp:88:21 [readability-identifier-naming]

invalid case style for method 'Finished'
{
return finished_;
}
Expand All @@ -102,7 +109,11 @@
return;
prev_offset_y_ = offsetY;

#ifdef USE_SDL3
SDL_FillSurfaceRect(DiabloUiSurface(), nullptr, 0);
#else
SDL_FillRect(DiabloUiSurface(), nullptr, 0x000000);
#endif
const Point uiPosition = GetUIRectangle().position;
if (ArtBackgroundWidescreen)
RenderClxSprite(Surface(DiabloUiSurface()), (*ArtBackgroundWidescreen)[0], uiPosition - Displacement { 320, 0 });
Expand Down Expand Up @@ -152,10 +163,15 @@
do {
creditsRenderer.Render();
UiFadeIn();
while (PollEvent(&event) != 0) {
while (PollEvent(&event)) {
switch (event.type) {
#ifdef USE_SDL3
case SDL_EVENT_KEY_DOWN:
case SDL_EVENT_MOUSE_BUTTON_UP:
#else
case SDL_KEYDOWN:
case SDL_MOUSEBUTTONUP:
#endif
endMenu = true;
break;
default:
Expand Down
Loading
Loading