Skip to content

Commit

Permalink
Make credential dialog work with SDL3
Browse files Browse the repository at this point in the history
  • Loading branch information
vmpn committed Jan 18, 2025
1 parent 16c34d7 commit 0757ad4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion client/SDL/SDL3/dialogs/sdl_input_widgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ SdlInputWidgetList::SdlInputWidgetList(const std::string& title,
title.c_str(), total_width, static_cast<int>(total_height),
SDL_WINDOW_HIGH_PIXEL_DENSITY | SDL_WINDOW_MOUSE_FOCUS | SDL_WINDOW_INPUT_FOCUS, &_window,
&_renderer);
if (rc != 0)
if (!rc)
widget_log_error(rc, "SDL_CreateWindowAndRenderer");
else
{
Expand Down
11 changes: 9 additions & 2 deletions client/SDL/SDL3/dialogs/sdl_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,20 @@ SdlWidget::~SdlWidget()
SDL_DestroyTexture(_image);
}

bool SdlWidget::error_ex(Sint32 res, const char* what, const char* file, size_t line,
bool SdlWidget::error_ex(bool success, const char* what, const char* file, size_t line,
const char* fkt)
{
if (success)
{
// Flip SDL3 convention to existing code convention to minimize code changes
return false;
}
static wLog* log = nullptr;
if (!log)
log = WLog_Get(TAG);
return sdl_log_error_ex(res, log, what, file, line, fkt);
// Use -1 as it indicates error similar to SDL2 conventions
// sdl_log_error_ex treats any value other than 0 as SDL error
return sdl_log_error_ex(-1, log, what, file, line, fkt);
}

static bool draw_rect(SDL_Renderer* renderer, const SDL_FRect* rect, SDL_Color color)
Expand Down
2 changes: 1 addition & 1 deletion client/SDL/SDL3/dialogs/sdl_widget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class SdlWidget
[[nodiscard]] const SDL_FRect& rect() const;

#define widget_log_error(res, what) SdlWidget::error_ex(res, what, __FILE__, __LINE__, __func__)
static bool error_ex(Sint32 res, const char* what, const char* file, size_t line,
static bool error_ex(bool success, const char* what, const char* file, size_t line,
const char* fkt);

private:
Expand Down

0 comments on commit 0757ad4

Please sign in to comment.