Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump SDL version to 2.0.12 #388

Merged
merged 1 commit into from
Mar 24, 2020
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
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ jobs:
include:
- os: linux
compiler: gcc
env: SDL_LIB=SDL2-2.0.10 SDL_MIXER_LIB=SDL2_mixer-2.0.4 RUN_CODECOV=1
env: SDL_LIB=SDL2-2.0.12 SDL_MIXER_LIB=SDL2_mixer-2.0.4 RUN_CODECOV=1
- os: linux
compiler: gcc
env: SDL_LIB=SDL2-2.0.0 SDL_MIXER_LIB=SDL2_mixer-2.0.0
- os: linux
compiler: clang
env: SDL_LIB=SDL2-2.0.10 SDL_MIXER_LIB=SDL2_mixer-2.0.4
env: SDL_LIB=SDL2-2.0.12 SDL_MIXER_LIB=SDL2_mixer-2.0.4
- os: linux
dist: xenial # Oldest still-supported LTS right now against which the AppImage is built. Update this to the next LTS when support drops.
name: Linux AppImage
Expand All @@ -20,7 +20,7 @@ jobs:
- docker
- os: osx
compiler: clang
env: SDL_LIB=SDL2-2.0.10 SDL_MIXER_LIB=SDL2_mixer-2.0.4 BUILD_TARGET=mac DEPLOY=mac
env: SDL_LIB=SDL2-2.0.12 SDL_MIXER_LIB=SDL2_mixer-2.0.4 BUILD_TARGET=mac DEPLOY=mac
- os: linux
name: PS Vita
env: BUILD_TARGET=vita DEPLOY=vita
Expand Down
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,15 @@ if(APPLE)

set(DIRS "")

# if SDL2 library is a framework, we need to indicate to CMake
# the path to its dependencies. SDL2_LIBRARY contains two parts.
# Example: /Library/Frameworks/SDL2.framework;-framework Cocoa
# So strip out everything after the ';'
string(REGEX REPLACE ";.*$" "" SDL2_LIB_DIR "${SDL2_LIBRARY}")
if(EXISTS "${SDL2_LIB_DIR}/Versions/A/Frameworks")
set(DIRS "${DIRS};${SDL2_LIB_DIR}/Versions/A/Frameworks")
endif()

# if SDL2_mixer library is a framework, we need to indicate to CMake
# the path to its dependencies (Ogg.framework etc):
if(EXISTS "${SDL2_MIXER_LIBRARY}/Versions/A/Frameworks")
Expand Down
6 changes: 6 additions & 0 deletions src/graphics/color.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,11 @@ typedef uint32_t color_t;
#define COLOR_ENEMY_CENTRAL 0x7b0000
#define COLOR_ENEMY_NORTHERN 0x1800ff
#define COLOR_ENEMY_DESERT 0x08007b
#define COLOR_MOUSE_TRANSPARENT 0x00000000
#define COLOR_MOUSE_BLACK 0x000000ff
#define COLOR_MOUSE_DARK_GRAY 0x3f3f3fff
#define COLOR_MOUSE_MEDIUM_GRAY 0x737373ff
#define COLOR_MOUSE_LIGHT_GRAY 0xb3b3b3ff
#define COLOR_MOUSE_WHITE 0xffffffff

#endif // GRAPHICS_COLOR_H
29 changes: 15 additions & 14 deletions src/platform/cursor.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "game/system.h"
#include "graphics/color.h"
#include "input/cursor.h"

#include "SDL.h"
Expand All @@ -7,24 +8,24 @@ static SDL_Cursor* cursors[CURSOR_MAX];
static SDL_Surface* cursor_surfaces[CURSOR_MAX];
static int current_cursor_id = CURSOR_ARROW;

static const SDL_Color mouse_colors[] = {
{ 0x00, 0x00, 0x00, 0x00 }, /* Transparent */
{ 0x00, 0x00, 0x00, 0xFF }, /* Black */
{ 0x3F, 0x3F, 0x3F, 0xFF }, /* Dark gray */
{ 0x73, 0x73, 0x73, 0xFF }, /* Medium gray */
{ 0xB3, 0xB3, 0xB3, 0xFF }, /* Light gray */
{ 0xFF, 0xFF, 0xFF, 0xFF } /* White */
static const color_t mouse_colors[] = {
COLOR_MOUSE_TRANSPARENT,
COLOR_MOUSE_TRANSPARENT,
COLOR_MOUSE_TRANSPARENT,
COLOR_MOUSE_BLACK,
COLOR_MOUSE_DARK_GRAY,
COLOR_MOUSE_MEDIUM_GRAY,
COLOR_MOUSE_LIGHT_GRAY,
COLOR_MOUSE_WHITE
};

static SDL_Surface* generate_cursor_surface(const char* data, int width, int height)
{
SDL_Surface* cursor_surface = SDL_CreateRGBSurfaceFrom((void*)data, width, height, 8, sizeof(Uint8) * width, 0, 0, 0, 0);

SDL_LockSurface(cursor_surface);
SDL_SetPaletteColors(cursor_surface->format->palette, mouse_colors, ' ', 1);
SDL_SetPaletteColors(cursor_surface->format->palette, &mouse_colors[1], '#', 5);
SDL_UnlockSurface(cursor_surface);

SDL_Surface *cursor_surface = SDL_CreateRGBSurface(0, width, height, 32, 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff);
color_t *pixels = cursor_surface->pixels;
for (int i = 0; i < width * height; ++i) {
pixels[i] = mouse_colors[data[i] - 32];
}
return cursor_surface;
}

Expand Down