mirror of
https://forgejo.xatacraft.ru/Sunshine/mkxp-sunshine.git
synced 2026-08-19 21:39:57 +00:00
SDL3 changesssssssssssssssssssss UwU naxui
This commit is contained in:
parent
cf0659e62a
commit
9b3058cad2
4 changed files with 40 additions and 40 deletions
|
|
@ -357,11 +357,12 @@ void Oneshot::update()
|
|||
screenRect.w = 640;
|
||||
screenRect.h = 480;
|
||||
|
||||
//костыль ебучий
|
||||
int num_displays;
|
||||
SDL_DisplayID *displays = SDL_GetDisplays(&num_displays)
|
||||
|
||||
SDL_free(displays);
|
||||
//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_GetDisplayBounds(i, &bounds);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef ONESHOT_H
|
||||
#define ONESHOT_H
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL2/SDL_image.h>
|
||||
#include <SDL2/SDL_ttf.h>
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3_image/SDL_image.h>
|
||||
#include <SDL3_ttf/SDL_ttf.h>
|
||||
|
||||
#include "etc-internal.h"
|
||||
#include <string>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include <SDL.h>
|
||||
#include <SDL_shape.h>
|
||||
#include <SDL_image.h>
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_shape.h>
|
||||
#include <SDL3_image/SDL_image.h>
|
||||
|
||||
#define FPS 60
|
||||
#define DEFAULT_WIDTH 320
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
static void showInitError(const std::string &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)
|
||||
|
|
@ -61,9 +61,10 @@ int screenMain(Config &conf)
|
|||
SDL_WindowShapeMode shapeMode;
|
||||
shapeMode.mode = ShapeModeColorKey;
|
||||
shapeMode.parameters.colorKey = colorKey;
|
||||
|
||||
SDL_Surface *shape = SDL_CreateRGBSurface(0, DEFAULT_WIDTH, DEFAULT_HEIGHT, 8, 0, 0, 0, 0);
|
||||
SDL_SetPaletteColors(shape->format->palette, &black, 0, 1);
|
||||
//SDL_Surface *surface = SDL_CreateSurface(32, 32, SDL_PIXELFORMAT_INDEX8);
|
||||
SDL_Surface *shape = SDL_CreateRGBSurface(DEFAULT_WIDTH, DEFAULT_HEIGHT, 0, 0, 0, 0);
|
||||
// SDL_Palette *palette = SDL_CreateSurfacePalette(surface);
|
||||
SDL_SetPaletteColors(shape, &black, 0, 1);
|
||||
|
||||
char messageBuf[256];
|
||||
|
||||
|
|
@ -83,7 +84,7 @@ int screenMain(Config &conf)
|
|||
if (strcmp(messageBuf, "END") == 0)
|
||||
break;
|
||||
std::string imgname = conf.gameFolder + "/Journal/" + messageBuf + ".png";
|
||||
SDL_FreeSurface(shape);
|
||||
SDL_DestroySurface(shape);
|
||||
if ((shape = IMG_Load(imgname.c_str())) == NULL)
|
||||
break;
|
||||
SDL_SetWindowSize(win, shape->w, shape->h);
|
||||
|
|
@ -101,6 +102,6 @@ int screenMain(Config &conf)
|
|||
ticks = SDL_GetTicks();
|
||||
}
|
||||
|
||||
SDL_FreeSurface(shape);
|
||||
SDL_DestroySurface(shape);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef SDLUTIL_H
|
||||
#define SDLUTIL_H
|
||||
|
||||
#include <SDL_atomic.h>
|
||||
#include <SDL_thread.h>
|
||||
#include <SDL_rwops.h>
|
||||
#include <SDL3/SDL_atomic.h>
|
||||
#include <SDL3/SDL_thread.h>
|
||||
#include <SDL3/SDL_IOStream.h>
|
||||
|
||||
#include <string>
|
||||
#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
|
||||
* on the physical filesystem. This wrapper attempts to open a
|
||||
* real file first before falling back to the assets folder */
|
||||
static inline
|
||||
SDL_RWops *RWFromFile(const char *filename,
|
||||
const char *mode)
|
||||
{
|
||||
FILE *f = fopen(filename, mode);
|
||||
//static inline
|
||||
//SDL_RWops *RWFromFile(const char *filename,
|
||||
// const char *mode)
|
||||
//{
|
||||
// FILE *f = fopen(filename, mode);
|
||||
//
|
||||
// if (!f)
|
||||
// return SDL_RWFromFile(filename, mode);
|
||||
//
|
||||
// return SDL_RWFromFP(f, SDL_TRUE);
|
||||
//}
|
||||
|
||||
if (!f)
|
||||
return SDL_RWFromFile(filename, mode);
|
||||
|
||||
return SDL_RWFromFP(f, SDL_TRUE);
|
||||
}
|
||||
|
||||
inline bool readFileSDL(const char *path,
|
||||
std::string &out)
|
||||
{
|
||||
SDL_RWops *f = RWFromFile(path, "rb");
|
||||
inline bool readFileSDL(const char *path, std::string &out){
|
||||
SDL_IOStream *f = SDL_IOFromFile(path, "rb");
|
||||
|
||||
if (!f)
|
||||
return false;
|
||||
|
||||
long size = SDL_RWsize(f);
|
||||
long size = SDL_GetIOSize(f);
|
||||
size_t back = out.size();
|
||||
|
||||
out.resize(back+size);
|
||||
size_t read = SDL_RWread(f, &out[back], 1, size);
|
||||
SDL_RWclose(f);
|
||||
size_t read = SDL_ReadIO(f, &out[back], size);
|
||||
SDL_CloseIO(f);
|
||||
|
||||
if (read != (size_t) size)
|
||||
out.resize(back+read);
|
||||
|
|
@ -118,7 +116,7 @@ private:
|
|||
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)
|
||||
return traits_type::eof();
|
||||
|
||||
|
|
@ -127,7 +125,7 @@ private:
|
|||
return underflow();
|
||||
}
|
||||
|
||||
SDL_RWops *ops;
|
||||
SDL_IOStream *ops;
|
||||
char buf[bufSize+pbSize];
|
||||
};
|
||||
|
||||
|
|
@ -136,7 +134,7 @@ class SDLRWStream
|
|||
public:
|
||||
SDLRWStream(const char *filename,
|
||||
const char *mode)
|
||||
: ops(RWFromFile(filename, mode)),
|
||||
: ops(SDL_IOFromFile(filename, mode)),
|
||||
buf(ops),
|
||||
s(&buf)
|
||||
{}
|
||||
|
|
@ -144,7 +142,7 @@ public:
|
|||
~SDLRWStream()
|
||||
{
|
||||
if (ops)
|
||||
SDL_RWclose(ops);
|
||||
SDL_CloseIO(ops);
|
||||
}
|
||||
|
||||
operator bool() const
|
||||
|
|
@ -158,7 +156,7 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
SDL_RWops *ops;
|
||||
SDL_CloseIO *ops;
|
||||
SDLRWBuf<> buf;
|
||||
std::istream s;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue