SDL3 changesssssssssssssssssssss UwU naxui
This commit is contained in:
parent
cf0659e62a
commit
9b3058cad2
|
|
@ -357,11 +357,12 @@ void Oneshot::update()
|
||||||
screenRect.w = 640;
|
screenRect.w = 640;
|
||||||
screenRect.h = 480;
|
screenRect.h = 480;
|
||||||
|
|
||||||
|
//костыль ебучий
|
||||||
int num_displays;
|
int num_displays;
|
||||||
SDL_DisplayID *displays = SDL_GetDisplays(&num_displays)
|
SDL_DisplayID *displays = SDL_GetDisplays(&num_displays)
|
||||||
|
SDL_free(displays);
|
||||||
//Update obscured map and texture for window portion offscreen
|
//Update obscured map and texture for window portion offscreen
|
||||||
for (int i = 0, max = SDL_GetNumVideoDisplays(); i < max; ++i)
|
for (int i = 0, max = num_displays; i < max; ++i)
|
||||||
{
|
{
|
||||||
SDL_Rect bounds;
|
SDL_Rect bounds;
|
||||||
SDL_GetDisplayBounds(i, &bounds);
|
SDL_GetDisplayBounds(i, &bounds);
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef ONESHOT_H
|
#ifndef ONESHOT_H
|
||||||
#define ONESHOT_H
|
#define ONESHOT_H
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL3/SDL.h>
|
||||||
#include <SDL2/SDL_image.h>
|
#include <SDL3_image/SDL_image.h>
|
||||||
#include <SDL2/SDL_ttf.h>
|
#include <SDL3_ttf/SDL_ttf.h>
|
||||||
|
|
||||||
#include "etc-internal.h"
|
#include "etc-internal.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#include <SDL.h>
|
#include <SDL3/SDL.h>
|
||||||
#include <SDL_shape.h>
|
#include <SDL3/SDL_shape.h>
|
||||||
#include <SDL_image.h>
|
#include <SDL3_image/SDL_image.h>
|
||||||
|
|
||||||
#define FPS 60
|
#define FPS 60
|
||||||
#define DEFAULT_WIDTH 320
|
#define DEFAULT_WIDTH 320
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
static void showInitError(const std::string &msg)
|
static void showInitError(const std::string &msg)
|
||||||
{
|
{
|
||||||
Debug() << msg;
|
Debug() << msg;
|
||||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "OneShot", msg.c_str(), 0);
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "OneShot: sunshine", msg.c_str(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool readMessage(Pipe &ipc, char *buf, size_t size)
|
static bool readMessage(Pipe &ipc, char *buf, size_t size)
|
||||||
|
|
@ -61,9 +61,10 @@ int screenMain(Config &conf)
|
||||||
SDL_WindowShapeMode shapeMode;
|
SDL_WindowShapeMode shapeMode;
|
||||||
shapeMode.mode = ShapeModeColorKey;
|
shapeMode.mode = ShapeModeColorKey;
|
||||||
shapeMode.parameters.colorKey = colorKey;
|
shapeMode.parameters.colorKey = colorKey;
|
||||||
|
//SDL_Surface *surface = SDL_CreateSurface(32, 32, SDL_PIXELFORMAT_INDEX8);
|
||||||
SDL_Surface *shape = SDL_CreateRGBSurface(0, DEFAULT_WIDTH, DEFAULT_HEIGHT, 8, 0, 0, 0, 0);
|
SDL_Surface *shape = SDL_CreateRGBSurface(DEFAULT_WIDTH, DEFAULT_HEIGHT, 0, 0, 0, 0);
|
||||||
SDL_SetPaletteColors(shape->format->palette, &black, 0, 1);
|
// SDL_Palette *palette = SDL_CreateSurfacePalette(surface);
|
||||||
|
SDL_SetPaletteColors(shape, &black, 0, 1);
|
||||||
|
|
||||||
char messageBuf[256];
|
char messageBuf[256];
|
||||||
|
|
||||||
|
|
@ -83,7 +84,7 @@ int screenMain(Config &conf)
|
||||||
if (strcmp(messageBuf, "END") == 0)
|
if (strcmp(messageBuf, "END") == 0)
|
||||||
break;
|
break;
|
||||||
std::string imgname = conf.gameFolder + "/Journal/" + messageBuf + ".png";
|
std::string imgname = conf.gameFolder + "/Journal/" + messageBuf + ".png";
|
||||||
SDL_FreeSurface(shape);
|
SDL_DestroySurface(shape);
|
||||||
if ((shape = IMG_Load(imgname.c_str())) == NULL)
|
if ((shape = IMG_Load(imgname.c_str())) == NULL)
|
||||||
break;
|
break;
|
||||||
SDL_SetWindowSize(win, shape->w, shape->h);
|
SDL_SetWindowSize(win, shape->w, shape->h);
|
||||||
|
|
@ -101,6 +102,6 @@ int screenMain(Config &conf)
|
||||||
ticks = SDL_GetTicks();
|
ticks = SDL_GetTicks();
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_FreeSurface(shape);
|
SDL_DestroySurface(shape);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SDLUTIL_H
|
#ifndef SDLUTIL_H
|
||||||
#define SDLUTIL_H
|
#define SDLUTIL_H
|
||||||
|
|
||||||
#include <SDL_atomic.h>
|
#include <SDL3/SDL_atomic.h>
|
||||||
#include <SDL_thread.h>
|
#include <SDL3/SDL_thread.h>
|
||||||
#include <SDL_rwops.h>
|
#include <SDL3/SDL_IOStream.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
@ -56,32 +56,30 @@ SDL_Thread *createSDLThread(C *obj, const std::string &name = std::string())
|
||||||
* the apk asset folder even when a file with same name exists
|
* the apk asset folder even when a file with same name exists
|
||||||
* on the physical filesystem. This wrapper attempts to open a
|
* on the physical filesystem. This wrapper attempts to open a
|
||||||
* real file first before falling back to the assets folder */
|
* real file first before falling back to the assets folder */
|
||||||
static inline
|
//static inline
|
||||||
SDL_RWops *RWFromFile(const char *filename,
|
//SDL_RWops *RWFromFile(const char *filename,
|
||||||
const char *mode)
|
// const char *mode)
|
||||||
{
|
//{
|
||||||
FILE *f = fopen(filename, mode);
|
// FILE *f = fopen(filename, mode);
|
||||||
|
//
|
||||||
|
// if (!f)
|
||||||
|
// return SDL_RWFromFile(filename, mode);
|
||||||
|
//
|
||||||
|
// return SDL_RWFromFP(f, SDL_TRUE);
|
||||||
|
//}
|
||||||
|
|
||||||
if (!f)
|
inline bool readFileSDL(const char *path, std::string &out){
|
||||||
return SDL_RWFromFile(filename, mode);
|
SDL_IOStream *f = SDL_IOFromFile(path, "rb");
|
||||||
|
|
||||||
return SDL_RWFromFP(f, SDL_TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool readFileSDL(const char *path,
|
|
||||||
std::string &out)
|
|
||||||
{
|
|
||||||
SDL_RWops *f = RWFromFile(path, "rb");
|
|
||||||
|
|
||||||
if (!f)
|
if (!f)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
long size = SDL_RWsize(f);
|
long size = SDL_GetIOSize(f);
|
||||||
size_t back = out.size();
|
size_t back = out.size();
|
||||||
|
|
||||||
out.resize(back+size);
|
out.resize(back+size);
|
||||||
size_t read = SDL_RWread(f, &out[back], 1, size);
|
size_t read = SDL_ReadIO(f, &out[back], size);
|
||||||
SDL_RWclose(f);
|
SDL_CloseIO(f);
|
||||||
|
|
||||||
if (read != (size_t) size)
|
if (read != (size_t) size)
|
||||||
out.resize(back+read);
|
out.resize(back+read);
|
||||||
|
|
@ -118,7 +116,7 @@ private:
|
||||||
start += pbSize;
|
start += pbSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t n = SDL_RWread(ops, start, 1, bufSize - (start - base));
|
size_t n = SDL_ReadIO(ops, start, 1, bufSize - (start - base));
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
return traits_type::eof();
|
return traits_type::eof();
|
||||||
|
|
||||||
|
|
@ -127,7 +125,7 @@ private:
|
||||||
return underflow();
|
return underflow();
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_RWops *ops;
|
SDL_IOStream *ops;
|
||||||
char buf[bufSize+pbSize];
|
char buf[bufSize+pbSize];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -136,7 +134,7 @@ class SDLRWStream
|
||||||
public:
|
public:
|
||||||
SDLRWStream(const char *filename,
|
SDLRWStream(const char *filename,
|
||||||
const char *mode)
|
const char *mode)
|
||||||
: ops(RWFromFile(filename, mode)),
|
: ops(SDL_IOFromFile(filename, mode)),
|
||||||
buf(ops),
|
buf(ops),
|
||||||
s(&buf)
|
s(&buf)
|
||||||
{}
|
{}
|
||||||
|
|
@ -144,7 +142,7 @@ public:
|
||||||
~SDLRWStream()
|
~SDLRWStream()
|
||||||
{
|
{
|
||||||
if (ops)
|
if (ops)
|
||||||
SDL_RWclose(ops);
|
SDL_CloseIO(ops);
|
||||||
}
|
}
|
||||||
|
|
||||||
operator bool() const
|
operator bool() const
|
||||||
|
|
@ -158,7 +156,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SDL_RWops *ops;
|
SDL_CloseIO *ops;
|
||||||
SDLRWBuf<> buf;
|
SDLRWBuf<> buf;
|
||||||
std::istream s;
|
std::istream s;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue