You've already forked OpenRCT2-Unity
mirror of
https://github.com/izzy2lost/OpenRCT2-Unity.git
synced 2026-03-10 12:38:22 -07:00
Replace our own integer types with standard ones
This commit is contained in:
@@ -27,7 +27,7 @@ CursorRepository::~CursorRepository()
|
||||
|
||||
void CursorRepository::LoadCursors()
|
||||
{
|
||||
SetCursorScale(static_cast<uint8>(round(gConfigGeneral.window_scale)));
|
||||
SetCursorScale(static_cast<uint8_t>(round(gConfigGeneral.window_scale)));
|
||||
SetCurrentCursor(CURSOR_ARROW);
|
||||
}
|
||||
|
||||
@@ -46,19 +46,19 @@ void CursorRepository::SetCurrentCursor(CURSOR_ID cursorId)
|
||||
}
|
||||
}
|
||||
|
||||
static bool getBit(const uint8 * data, size_t x, size_t y, size_t width)
|
||||
static bool getBit(const uint8_t * data, size_t x, size_t y, size_t width)
|
||||
{
|
||||
size_t position = y * width + x;
|
||||
return (data[position / 8] & (1 << (7 - (x % 8)))) != 0;
|
||||
}
|
||||
|
||||
static void setBit(uint8 * data, size_t x, size_t y, size_t width)
|
||||
static void setBit(uint8_t * data, size_t x, size_t y, size_t width)
|
||||
{
|
||||
size_t position = y * width + x;
|
||||
data[position / 8] |= (1 << (7 - (position % 8)));
|
||||
}
|
||||
|
||||
static void drawRect(uint8 * data, size_t x, size_t y, size_t width, size_t scale)
|
||||
static void drawRect(uint8_t * data, size_t x, size_t y, size_t width, size_t scale)
|
||||
{
|
||||
for (size_t outY = (y * scale); outY < ((1 + y) * scale); outY++)
|
||||
{
|
||||
@@ -69,10 +69,10 @@ static void drawRect(uint8 * data, size_t x, size_t y, size_t width, size_t scal
|
||||
}
|
||||
}
|
||||
|
||||
static uint8 * scaleDataArray(const uint8 data[], size_t width, size_t height, size_t scale)
|
||||
static uint8_t * scaleDataArray(const uint8_t data[], size_t width, size_t height, size_t scale)
|
||||
{
|
||||
size_t length = width * height;
|
||||
auto * ret = static_cast<uint8 *>(calloc(sizeof(uint8), length * scale * scale));
|
||||
auto * ret = static_cast<uint8_t *>(calloc(sizeof(uint8_t), length * scale * scale));
|
||||
|
||||
for (size_t y = 0; y < height * 8; y++)
|
||||
{
|
||||
@@ -88,7 +88,7 @@ static uint8 * scaleDataArray(const uint8 data[], size_t width, size_t height, s
|
||||
return ret;
|
||||
}
|
||||
|
||||
SDL_Cursor * CursorRepository::Create(const CursorData * cursorInfo, uint8 scale)
|
||||
SDL_Cursor * CursorRepository::Create(const CursorData * cursorInfo, uint8_t scale)
|
||||
{
|
||||
SDL_Cursor * cursor;
|
||||
|
||||
@@ -112,7 +112,7 @@ SDL_Cursor * CursorRepository::Create(const CursorData * cursorInfo, uint8 scale
|
||||
return cursor;
|
||||
}
|
||||
|
||||
void CursorRepository::SetCursorScale(uint8 cursorScale)
|
||||
void CursorRepository::SetCursorScale(uint8_t cursorScale)
|
||||
{
|
||||
if (cursorScale > 0.0)
|
||||
{
|
||||
@@ -121,7 +121,7 @@ void CursorRepository::SetCursorScale(uint8 cursorScale)
|
||||
}
|
||||
}
|
||||
|
||||
void CursorRepository::GenerateScaledCursorSetHolder(uint8 scale)
|
||||
void CursorRepository::GenerateScaledCursorSetHolder(uint8_t scale)
|
||||
{
|
||||
if (_scaledCursors.find(scale) == _scaledCursors.end())
|
||||
{
|
||||
|
||||
@@ -50,24 +50,24 @@ namespace OpenRCT2::Ui
|
||||
}
|
||||
};
|
||||
|
||||
constexpr static sint32 BASE_CURSOR_WIDTH = 32;
|
||||
constexpr static sint32 BASE_CURSOR_HEIGHT = 32;
|
||||
constexpr static int32_t BASE_CURSOR_WIDTH = 32;
|
||||
constexpr static int32_t BASE_CURSOR_HEIGHT = 32;
|
||||
|
||||
CURSOR_ID _currentCursor = CURSOR_UNDEFINED;
|
||||
uint8 _currentCursorScale = 1;
|
||||
uint8_t _currentCursorScale = 1;
|
||||
|
||||
std::map<uint8, CursorSetHolder> _scaledCursors;
|
||||
std::map<uint8_t, CursorSetHolder> _scaledCursors;
|
||||
|
||||
public:
|
||||
~CursorRepository();
|
||||
void LoadCursors();
|
||||
CURSOR_ID GetCurrentCursor();
|
||||
void SetCurrentCursor(CURSOR_ID cursorId);
|
||||
void SetCursorScale(uint8 cursorScale);
|
||||
void SetCursorScale(uint8_t cursorScale);
|
||||
|
||||
private:
|
||||
SDL_Cursor * Create(const CursorData * cursorInfo, uint8 scale);
|
||||
void GenerateScaledCursorSetHolder(uint8 scale);
|
||||
SDL_Cursor * Create(const CursorData * cursorInfo, uint8_t scale);
|
||||
void GenerateScaledCursorSetHolder(uint8_t scale);
|
||||
static const CursorData * GetCursorData(CURSOR_ID cursorId);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ void TextComposition::HandleMessage(const SDL_Event * e)
|
||||
break;
|
||||
}
|
||||
|
||||
uint16 modifier = e->key.keysym.mod;
|
||||
uint16_t modifier = e->key.keysym.mod;
|
||||
SDL_Keycode key = e->key.keysym.sym;
|
||||
if (key == SDLK_KP_ENTER)
|
||||
{
|
||||
@@ -241,7 +241,7 @@ void TextComposition::CursorRight()
|
||||
void TextComposition::Insert(const utf8 * text)
|
||||
{
|
||||
const utf8 * ch = text;
|
||||
uint32 codepoint;
|
||||
uint32_t codepoint;
|
||||
while ((codepoint = utf8_get_next(ch, &ch)) != 0)
|
||||
{
|
||||
InsertCodepoint(codepoint);
|
||||
|
||||
@@ -26,8 +26,8 @@ namespace OpenRCT2::Ui
|
||||
TextInputSession _session = {};
|
||||
|
||||
bool _imeActive = false;
|
||||
sint32 _imeStart = 0;
|
||||
sint32 _imeLength = 0;
|
||||
int32_t _imeStart = 0;
|
||||
int32_t _imeLength = 0;
|
||||
utf8 _imeBuffer[32] = {};
|
||||
|
||||
public:
|
||||
|
||||
@@ -255,7 +255,7 @@ namespace OpenRCT2::Ui
|
||||
return DIALOG_TYPE::NONE;
|
||||
}
|
||||
|
||||
static sint32 Execute(const std::string &command, std::string * output = nullptr)
|
||||
static int32_t Execute(const std::string &command, std::string * output = nullptr)
|
||||
{
|
||||
#ifndef __EMSCRIPTEN__
|
||||
log_verbose("executing \"%s\"...\n", command.c_str());
|
||||
|
||||
@@ -130,10 +130,10 @@ namespace OpenRCT2::Ui
|
||||
std::string resultExtension = Path::GetExtension(resultFilename);
|
||||
if (resultExtension.empty())
|
||||
{
|
||||
sint32 filterIndex = openFileName.nFilterIndex - 1;
|
||||
int32_t filterIndex = openFileName.nFilterIndex - 1;
|
||||
|
||||
assert(filterIndex >= 0);
|
||||
assert(filterIndex < (sint32)desc.Filters.size());
|
||||
assert(filterIndex < (int32_t)desc.Filters.size());
|
||||
|
||||
std::string pattern = desc.Filters[filterIndex].Pattern;
|
||||
std::string patternExtension = Path::GetExtension(pattern);
|
||||
|
||||
@@ -59,7 +59,7 @@ using namespace OpenRCT2::Ui;
|
||||
class UiContext final : public IUiContext
|
||||
{
|
||||
private:
|
||||
constexpr static uint32 TOUCH_DOUBLE_TIMEOUT = 300;
|
||||
constexpr static uint32_t TOUCH_DOUBLE_TIMEOUT = 300;
|
||||
|
||||
IPlatformUiContext * const _platformUiContext;
|
||||
IWindowManager * const _windowManager;
|
||||
@@ -67,9 +67,9 @@ private:
|
||||
CursorRepository _cursorRepository;
|
||||
|
||||
SDL_Window * _window = nullptr;
|
||||
sint32 _width = 0;
|
||||
sint32 _height = 0;
|
||||
sint32 _scaleQuality = 0;
|
||||
int32_t _width = 0;
|
||||
int32_t _height = 0;
|
||||
int32_t _scaleQuality = 0;
|
||||
|
||||
bool _resolutionsAllowAnyAspectRatio = false;
|
||||
std::vector<Resolution> _fsResolutions;
|
||||
@@ -80,10 +80,10 @@ private:
|
||||
KeyboardShortcuts _keyboardShortcuts;
|
||||
TextComposition _textComposition;
|
||||
CursorState _cursorState = {};
|
||||
uint32 _lastKeyPressed = 0;
|
||||
const uint8 * _keysState = nullptr;
|
||||
uint8 _keysPressed[256] = {};
|
||||
uint32 _lastGestureTimestamp = 0;
|
||||
uint32_t _lastKeyPressed = 0;
|
||||
const uint8_t * _keysState = nullptr;
|
||||
uint8_t _keysPressed[256] = {};
|
||||
uint32_t _lastGestureTimestamp = 0;
|
||||
float _gestureRadius = 0;
|
||||
|
||||
InGameConsole _inGameConsole;
|
||||
@@ -132,25 +132,25 @@ public:
|
||||
return _window;
|
||||
}
|
||||
|
||||
sint32 GetWidth() override
|
||||
int32_t GetWidth() override
|
||||
{
|
||||
return _width;
|
||||
}
|
||||
|
||||
sint32 GetHeight() override
|
||||
int32_t GetHeight() override
|
||||
{
|
||||
return _height;
|
||||
}
|
||||
|
||||
sint32 GetScaleQuality() override
|
||||
int32_t GetScaleQuality() override
|
||||
{
|
||||
return _scaleQuality;
|
||||
}
|
||||
|
||||
void SetFullscreenMode(FULLSCREEN_MODE mode) override
|
||||
{
|
||||
static constexpr const sint32 SDLFSFlags[] = { 0, SDL_WINDOW_FULLSCREEN, SDL_WINDOW_FULLSCREEN_DESKTOP };
|
||||
uint32 windowFlags = SDLFSFlags[(sint32)mode];
|
||||
static constexpr const int32_t SDLFSFlags[] = { 0, SDL_WINDOW_FULLSCREEN, SDL_WINDOW_FULLSCREEN_DESKTOP };
|
||||
uint32_t windowFlags = SDLFSFlags[(int32_t)mode];
|
||||
|
||||
// HACK Changing window size when in fullscreen usually has no effect
|
||||
if (mode == FULLSCREEN_MODE::FULLSCREEN)
|
||||
@@ -187,13 +187,13 @@ public:
|
||||
|
||||
bool HasFocus() override
|
||||
{
|
||||
uint32 windowFlags = GetWindowFlags();
|
||||
uint32_t windowFlags = GetWindowFlags();
|
||||
return (windowFlags & SDL_WINDOW_INPUT_FOCUS) != 0;
|
||||
}
|
||||
|
||||
bool IsMinimised() override
|
||||
{
|
||||
uint32 windowFlags = GetWindowFlags();
|
||||
uint32_t windowFlags = GetWindowFlags();
|
||||
return (windowFlags & SDL_WINDOW_MINIMIZED) ||
|
||||
(windowFlags & SDL_WINDOW_HIDDEN);
|
||||
}
|
||||
@@ -209,12 +209,12 @@ public:
|
||||
return &_cursorState;
|
||||
}
|
||||
|
||||
const uint8 * GetKeysState() override
|
||||
const uint8_t * GetKeysState() override
|
||||
{
|
||||
return _keysState;
|
||||
}
|
||||
|
||||
const uint8 * GetKeysPressed() override
|
||||
const uint8_t * GetKeysPressed() override
|
||||
{
|
||||
return _keysPressed;
|
||||
}
|
||||
@@ -229,7 +229,7 @@ public:
|
||||
_cursorRepository.SetCurrentCursor(cursor);
|
||||
}
|
||||
|
||||
void SetCursorScale(uint8 scale) override
|
||||
void SetCursorScale(uint8_t scale) override
|
||||
{
|
||||
_cursorRepository.SetCursorScale(scale);
|
||||
}
|
||||
@@ -239,12 +239,12 @@ public:
|
||||
SDL_ShowCursor(value ? SDL_ENABLE : SDL_DISABLE);
|
||||
}
|
||||
|
||||
void GetCursorPosition(sint32 * x, sint32 * y) override
|
||||
void GetCursorPosition(int32_t * x, int32_t * y) override
|
||||
{
|
||||
SDL_GetMouseState(x, y);
|
||||
}
|
||||
|
||||
void SetCursorPosition(sint32 x, sint32 y) override
|
||||
void SetCursorPosition(int32_t x, int32_t y) override
|
||||
{
|
||||
SDL_WarpMouseInWindow(nullptr, x, y);
|
||||
}
|
||||
@@ -254,7 +254,7 @@ public:
|
||||
SDL_SetWindowGrab(_window, value ? SDL_TRUE : SDL_FALSE);
|
||||
}
|
||||
|
||||
void SetKeysPressed(uint32 keysym, uint8 scancode) override
|
||||
void SetKeysPressed(uint32_t keysym, uint8_t scancode) override
|
||||
{
|
||||
_lastKeyPressed = keysym;
|
||||
_keysPressed[scancode] = 1;
|
||||
@@ -268,10 +268,10 @@ public:
|
||||
|
||||
void DrawRainAnimation(IRainDrawer* rainDrawer, rct_drawpixelinfo* dpi, DrawRainFunc drawFunc) override
|
||||
{
|
||||
sint32 left = dpi->x;
|
||||
sint32 right = left + dpi->width;
|
||||
sint32 top = dpi->y;
|
||||
sint32 bottom = top + dpi->height;
|
||||
int32_t left = dpi->x;
|
||||
int32_t right = left + dpi->width;
|
||||
int32_t top = dpi->y;
|
||||
int32_t bottom = top + dpi->height;
|
||||
|
||||
for (auto& w : g_window_list)
|
||||
{
|
||||
@@ -341,7 +341,7 @@ public:
|
||||
case SDL_WINDOWEVENT_RESTORED:
|
||||
{
|
||||
// Update default display index
|
||||
sint32 displayIndex = SDL_GetWindowDisplayIndex(_window);
|
||||
int32_t displayIndex = SDL_GetWindowDisplayIndex(_window);
|
||||
if (displayIndex != gConfigGeneral.default_display)
|
||||
{
|
||||
gConfigGeneral.default_display = displayIndex;
|
||||
@@ -364,8 +364,8 @@ public:
|
||||
}
|
||||
break;
|
||||
case SDL_MOUSEMOTION:
|
||||
_cursorState.x = (sint32)(e.motion.x / gConfigGeneral.window_scale);
|
||||
_cursorState.y = (sint32)(e.motion.y / gConfigGeneral.window_scale);
|
||||
_cursorState.x = (int32_t)(e.motion.x / gConfigGeneral.window_scale);
|
||||
_cursorState.y = (int32_t)(e.motion.y / gConfigGeneral.window_scale);
|
||||
break;
|
||||
case SDL_MOUSEWHEEL:
|
||||
if (_inGameConsole.IsOpen())
|
||||
@@ -377,8 +377,8 @@ public:
|
||||
break;
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
{
|
||||
sint32 x = (sint32)(e.button.x / gConfigGeneral.window_scale);
|
||||
sint32 y = (sint32)(e.button.y / gConfigGeneral.window_scale);
|
||||
int32_t x = (int32_t)(e.button.x / gConfigGeneral.window_scale);
|
||||
int32_t y = (int32_t)(e.button.y / gConfigGeneral.window_scale);
|
||||
switch (e.button.button) {
|
||||
case SDL_BUTTON_LEFT:
|
||||
store_mouse_input(MOUSE_STATE_LEFT_PRESS, x, y);
|
||||
@@ -398,8 +398,8 @@ public:
|
||||
}
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
{
|
||||
sint32 x = (sint32)(e.button.x / gConfigGeneral.window_scale);
|
||||
sint32 y = (sint32)(e.button.y / gConfigGeneral.window_scale);
|
||||
int32_t x = (int32_t)(e.button.x / gConfigGeneral.window_scale);
|
||||
int32_t y = (int32_t)(e.button.y / gConfigGeneral.window_scale);
|
||||
switch (e.button.button) {
|
||||
case SDL_BUTTON_LEFT:
|
||||
store_mouse_input(MOUSE_STATE_LEFT_RELEASE, x, y);
|
||||
@@ -420,13 +420,13 @@ public:
|
||||
// Apple sends touchscreen events for trackpads, so ignore these events on macOS
|
||||
#ifndef __MACOSX__
|
||||
case SDL_FINGERMOTION:
|
||||
_cursorState.x = (sint32)(e.tfinger.x * _width);
|
||||
_cursorState.y = (sint32)(e.tfinger.y * _height);
|
||||
_cursorState.x = (int32_t)(e.tfinger.x * _width);
|
||||
_cursorState.y = (int32_t)(e.tfinger.y * _height);
|
||||
break;
|
||||
case SDL_FINGERDOWN:
|
||||
{
|
||||
sint32 x = (sint32)(e.tfinger.x * _width);
|
||||
sint32 y = (sint32)(e.tfinger.y * _height);
|
||||
int32_t x = (int32_t)(e.tfinger.x * _width);
|
||||
int32_t y = (int32_t)(e.tfinger.y * _height);
|
||||
|
||||
_cursorState.touchIsDouble = (!_cursorState.touchIsDouble &&
|
||||
e.tfinger.timestamp - _cursorState.touchDownTimestamp < TOUCH_DOUBLE_TIMEOUT);
|
||||
@@ -449,8 +449,8 @@ public:
|
||||
}
|
||||
case SDL_FINGERUP:
|
||||
{
|
||||
sint32 x = (sint32)(e.tfinger.x * _width);
|
||||
sint32 y = (sint32)(e.tfinger.y * _height);
|
||||
int32_t x = (int32_t)(e.tfinger.x * _width);
|
||||
int32_t y = (int32_t)(e.tfinger.y * _height);
|
||||
|
||||
if (_cursorState.touchIsDouble)
|
||||
{
|
||||
@@ -481,8 +481,8 @@ public:
|
||||
_gestureRadius += e.mgesture.dDist;
|
||||
|
||||
// Zoom gesture
|
||||
constexpr sint32 tolerance = 128;
|
||||
sint32 gesturePixels = (sint32)(_gestureRadius * _width);
|
||||
constexpr int32_t tolerance = 128;
|
||||
int32_t gesturePixels = (int32_t)(_gestureRadius * _width);
|
||||
if (abs(gesturePixels) > tolerance)
|
||||
{
|
||||
_gestureRadius = 0;
|
||||
@@ -504,7 +504,7 @@ public:
|
||||
_cursorState.any = _cursorState.left | _cursorState.middle | _cursorState.right;
|
||||
|
||||
// Updates the state of the keys
|
||||
sint32 numKeys = 256;
|
||||
int32_t numKeys = 256;
|
||||
_keysState = SDL_GetKeyboardState(&numKeys);
|
||||
}
|
||||
|
||||
@@ -521,7 +521,7 @@ public:
|
||||
_scaleQuality = SCALE_QUALITY_NN;
|
||||
}
|
||||
|
||||
sint32 scaleQuality = _scaleQuality;
|
||||
int32_t scaleQuality = _scaleQuality;
|
||||
if (_scaleQuality == SCALE_QUALITY_SMOOTH_NN)
|
||||
{
|
||||
scaleQuality = SCALE_QUALITY_LINEAR;
|
||||
@@ -529,7 +529,7 @@ public:
|
||||
snprintf(scaleQualityBuffer, sizeof(scaleQualityBuffer), "%u", scaleQuality);
|
||||
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, scaleQualityBuffer);
|
||||
|
||||
sint32 width, height;
|
||||
int32_t width, height;
|
||||
SDL_GetWindowSize(_window, &width, &height);
|
||||
OnResize(width, height);
|
||||
}
|
||||
@@ -539,9 +539,9 @@ public:
|
||||
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, gConfigGeneral.minimize_fullscreen_focus_loss ? "1" : "0");
|
||||
|
||||
// Set window position to default display
|
||||
sint32 defaultDisplay = Math::Clamp(0, gConfigGeneral.default_display, 0xFFFF);
|
||||
sint32 x = SDL_WINDOWPOS_UNDEFINED_DISPLAY(defaultDisplay);
|
||||
sint32 y = SDL_WINDOWPOS_UNDEFINED_DISPLAY(defaultDisplay);
|
||||
int32_t defaultDisplay = Math::Clamp(0, gConfigGeneral.default_display, 0xFFFF);
|
||||
int32_t x = SDL_WINDOWPOS_UNDEFINED_DISPLAY(defaultDisplay);
|
||||
int32_t y = SDL_WINDOWPOS_UNDEFINED_DISPLAY(defaultDisplay);
|
||||
|
||||
CreateWindow(x, y);
|
||||
|
||||
@@ -562,7 +562,7 @@ public:
|
||||
void RecreateWindow() override
|
||||
{
|
||||
// Use the position of the current window for the new window
|
||||
sint32 x, y;
|
||||
int32_t x, y;
|
||||
SDL_SetWindowFullscreen(_window, 0);
|
||||
SDL_GetWindowPosition(_window, &x, &y);
|
||||
|
||||
@@ -608,16 +608,16 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
void CreateWindow(sint32 x, sint32 y)
|
||||
void CreateWindow(int32_t x, int32_t y)
|
||||
{
|
||||
// Get saved window size
|
||||
sint32 width = gConfigGeneral.window_width;
|
||||
sint32 height = gConfigGeneral.window_height;
|
||||
int32_t width = gConfigGeneral.window_width;
|
||||
int32_t height = gConfigGeneral.window_height;
|
||||
if (width <= 0) width = 640;
|
||||
if (height <= 0) height = 480;
|
||||
|
||||
// Create window in window first rather than fullscreen so we have the display the window is on first
|
||||
uint32 flags = SDL_WINDOW_RESIZABLE;
|
||||
uint32_t flags = SDL_WINDOW_RESIZABLE;
|
||||
if (gConfigGeneral.drawing_engine == DRAWING_ENGINE_OPENGL)
|
||||
{
|
||||
flags |= SDL_WINDOW_OPENGL;
|
||||
@@ -643,15 +643,15 @@ private:
|
||||
TriggerResize();
|
||||
}
|
||||
|
||||
void OnResize(sint32 width, sint32 height)
|
||||
void OnResize(int32_t width, int32_t height)
|
||||
{
|
||||
// Scale the native window size to the game's canvas size
|
||||
_width = (sint32)(width / gConfigGeneral.window_scale);
|
||||
_height = (sint32)(height / gConfigGeneral.window_scale);
|
||||
_width = (int32_t)(width / gConfigGeneral.window_scale);
|
||||
_height = (int32_t)(height / gConfigGeneral.window_scale);
|
||||
|
||||
drawing_engine_resize();
|
||||
|
||||
uint32 flags = SDL_GetWindowFlags(_window);
|
||||
uint32_t flags = SDL_GetWindowFlags(_window);
|
||||
if ((flags & SDL_WINDOW_MINIMIZED) == 0)
|
||||
{
|
||||
window_resize_gui(_width, _height);
|
||||
@@ -661,7 +661,7 @@ private:
|
||||
gfx_invalidate_screen();
|
||||
|
||||
// Check if the window has been resized in windowed mode and update the config file accordingly
|
||||
sint32 nonWindowFlags =
|
||||
int32_t nonWindowFlags =
|
||||
#ifndef __MACOSX__
|
||||
SDL_WINDOW_MAXIMIZED |
|
||||
#endif
|
||||
@@ -683,8 +683,8 @@ private:
|
||||
void UpdateFullscreenResolutions()
|
||||
{
|
||||
// Query number of display modes
|
||||
sint32 displayIndex = SDL_GetWindowDisplayIndex(_window);
|
||||
sint32 numDisplayModes = SDL_GetNumDisplayModes(displayIndex);
|
||||
int32_t displayIndex = SDL_GetWindowDisplayIndex(_window);
|
||||
int32_t numDisplayModes = SDL_GetNumDisplayModes(displayIndex);
|
||||
|
||||
// Get desktop aspect ratio
|
||||
SDL_DisplayMode mode;
|
||||
@@ -693,7 +693,7 @@ private:
|
||||
// Get resolutions
|
||||
auto resolutions = std::vector<Resolution>();
|
||||
float desktopAspectRatio = (float)mode.w / mode.h;
|
||||
for (sint32 i = 0; i < numDisplayModes; i++)
|
||||
for (int32_t i = 0; i < numDisplayModes; i++)
|
||||
{
|
||||
SDL_GetDisplayMode(displayIndex, i, &mode);
|
||||
if (mode.w > 0 && mode.h > 0)
|
||||
@@ -710,8 +710,8 @@ private:
|
||||
std::sort(resolutions.begin(), resolutions.end(),
|
||||
[](const Resolution &a, const Resolution &b) -> bool
|
||||
{
|
||||
sint32 areaA = a.Width * a.Height;
|
||||
sint32 areaB = b.Width * b.Height;
|
||||
int32_t areaA = a.Width * a.Height;
|
||||
int32_t areaB = b.Width * b.Height;
|
||||
return areaA < areaB;
|
||||
});
|
||||
|
||||
@@ -733,11 +733,11 @@ private:
|
||||
_fsResolutions = resolutions;
|
||||
}
|
||||
|
||||
Resolution GetClosestResolution(sint32 inWidth, sint32 inHeight)
|
||||
Resolution GetClosestResolution(int32_t inWidth, int32_t inHeight)
|
||||
{
|
||||
Resolution result = { 640, 480 };
|
||||
sint32 closestAreaDiff = -1;
|
||||
sint32 destinationArea = inWidth * inHeight;
|
||||
int32_t closestAreaDiff = -1;
|
||||
int32_t destinationArea = inWidth * inHeight;
|
||||
for (const Resolution &resolution : _fsResolutions)
|
||||
{
|
||||
// Check if exact match
|
||||
@@ -748,7 +748,7 @@ private:
|
||||
}
|
||||
|
||||
// Check if area is closer to best match
|
||||
sint32 areaDiff = std::abs((resolution.Width * resolution.Height) - destinationArea);
|
||||
int32_t areaDiff = std::abs((resolution.Width * resolution.Height) - destinationArea);
|
||||
if (closestAreaDiff == -1 || areaDiff < closestAreaDiff)
|
||||
{
|
||||
closestAreaDiff = areaDiff;
|
||||
@@ -758,7 +758,7 @@ private:
|
||||
return result;
|
||||
}
|
||||
|
||||
uint32 GetWindowFlags()
|
||||
uint32_t GetWindowFlags()
|
||||
{
|
||||
return SDL_GetWindowFlags(_window);
|
||||
}
|
||||
@@ -766,10 +766,10 @@ private:
|
||||
static void DrawRainWindow(
|
||||
IRainDrawer * rainDrawer,
|
||||
rct_window * original_w,
|
||||
sint16 left,
|
||||
sint16 right,
|
||||
sint16 top,
|
||||
sint16 bottom,
|
||||
int16_t left,
|
||||
int16_t right,
|
||||
int16_t top,
|
||||
int16_t bottom,
|
||||
DrawRainFunc drawFunc)
|
||||
{
|
||||
rct_window * w{};
|
||||
@@ -781,10 +781,10 @@ private:
|
||||
auto vp = original_w->viewport;
|
||||
if (vp != nullptr)
|
||||
{
|
||||
left = std::max<sint16>(left, vp->x);
|
||||
right = std::min<sint16>(right, vp->x + vp->width);
|
||||
top = std::max<sint16>(top, vp->y);
|
||||
bottom = std::min<sint16>(bottom, vp->y + vp->height);
|
||||
left = std::max<int16_t>(left, vp->x);
|
||||
right = std::min<int16_t>(right, vp->x + vp->width);
|
||||
top = std::max<int16_t>(top, vp->y);
|
||||
bottom = std::min<int16_t>(bottom, vp->y + vp->height);
|
||||
if (left < right && top < bottom)
|
||||
{
|
||||
auto width = right - left;
|
||||
@@ -818,7 +818,7 @@ private:
|
||||
return;
|
||||
}
|
||||
|
||||
sint16 w_right = RCT_WINDOW_RIGHT(w);
|
||||
int16_t w_right = RCT_WINDOW_RIGHT(w);
|
||||
if (right > w_right) {
|
||||
DrawRainWindow(rainDrawer, original_w, left, w_right, top, bottom, drawFunc);
|
||||
|
||||
@@ -835,7 +835,7 @@ private:
|
||||
return;
|
||||
}
|
||||
|
||||
sint16 w_bottom = RCT_WINDOW_BOTTOM(w);
|
||||
int16_t w_bottom = RCT_WINDOW_BOTTOM(w);
|
||||
if (bottom > w_bottom)
|
||||
{
|
||||
DrawRainWindow(rainDrawer, original_w, left, right, top, w_bottom, drawFunc);
|
||||
|
||||
@@ -124,7 +124,7 @@ namespace OpenRCT2::Ui
|
||||
}
|
||||
|
||||
private:
|
||||
static sint32 Execute(const std::string &command, std::string * output = nullptr)
|
||||
static int32_t Execute(const std::string &command, std::string * output = nullptr)
|
||||
{
|
||||
log_verbose("executing \"%s\"...\n", command.c_str());
|
||||
FILE * fpipe = popen(command.c_str(), "r");
|
||||
|
||||
@@ -132,7 +132,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
rct_window * OpenView(uint8 view) override
|
||||
rct_window * OpenView(uint8_t view) override
|
||||
{
|
||||
switch (view)
|
||||
{
|
||||
@@ -168,7 +168,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
rct_window * OpenDetails(uint8 type, sint32 id) override
|
||||
rct_window * OpenDetails(uint8_t type, int32_t id) override
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
@@ -212,7 +212,7 @@ public:
|
||||
return window_guest_list_open_with_filter(intent->GetSIntExtra(INTENT_EXTRA_GUEST_LIST_FILTER), intent->GetSIntExtra(INTENT_EXTRA_RIDE_ID));
|
||||
case WC_LOADSAVE:
|
||||
{
|
||||
uint32 type = intent->GetUIntExtra(INTENT_EXTRA_LOADSAVE_TYPE);
|
||||
uint32_t type = intent->GetUIntExtra(INTENT_EXTRA_LOADSAVE_TYPE);
|
||||
std::string defaultName = intent->GetStringExtra(INTENT_EXTRA_PATH);
|
||||
loadsave_callback callback = (loadsave_callback) intent->GetPointerExtra(INTENT_EXTRA_CALLBACK);
|
||||
rct_window *w = window_loadsave_open(type, defaultName.c_str());
|
||||
@@ -363,7 +363,7 @@ public:
|
||||
case INTENT_ACTION_INVALIDATE_VEHICLE_WINDOW:
|
||||
{
|
||||
rct_vehicle * vehicle = static_cast<rct_vehicle *>(intent.GetPointerExtra(INTENT_EXTRA_VEHICLE));
|
||||
sint32 viewVehicleIndex;
|
||||
int32_t viewVehicleIndex;
|
||||
Ride * ride;
|
||||
rct_window * w;
|
||||
|
||||
@@ -418,7 +418,7 @@ public:
|
||||
|
||||
case INTENT_ACTION_UPDATE_BANNER:
|
||||
{
|
||||
uint8 bannerIndex = static_cast<uint8>(intent.GetUIntExtra(INTENT_EXTRA_BANNER_INDEX));
|
||||
uint8_t bannerIndex = static_cast<uint8_t>(intent.GetUIntExtra(INTENT_EXTRA_BANNER_INDEX));
|
||||
|
||||
rct_window * w = window_find_by_number(WC_BANNER, bannerIndex);
|
||||
if (w != nullptr)
|
||||
@@ -462,14 +462,14 @@ public:
|
||||
input_handle_keyboard(isTitle);
|
||||
}
|
||||
|
||||
std::string GetKeyboardShortcutString(sint32 shortcut) override
|
||||
std::string GetKeyboardShortcutString(int32_t shortcut) override
|
||||
{
|
||||
utf8 buffer[256];
|
||||
keyboard_shortcuts_format_string(buffer, sizeof(buffer), shortcut);
|
||||
return std::string(buffer);
|
||||
}
|
||||
|
||||
void SetMainView(sint32 x, sint32 y, sint32 zoom, sint32 rotation) override
|
||||
void SetMainView(int32_t x, int32_t y, int32_t zoom, int32_t rotation) override
|
||||
{
|
||||
auto mainWindow = window_get_main();
|
||||
if (mainWindow != nullptr)
|
||||
|
||||
@@ -25,17 +25,17 @@ namespace OpenRCT2::Audio
|
||||
ISDLAudioSource * _source = nullptr;
|
||||
SpeexResamplerState * _resampler = nullptr;
|
||||
|
||||
sint32 _group = MIXER_GROUP_SOUND;
|
||||
int32_t _group = MIXER_GROUP_SOUND;
|
||||
double _rate = 0;
|
||||
uint64 _offset = 0;
|
||||
sint32 _loop = 0;
|
||||
uint64_t _offset = 0;
|
||||
int32_t _loop = 0;
|
||||
|
||||
sint32 _volume = 1;
|
||||
int32_t _volume = 1;
|
||||
float _volume_l = 0.f;
|
||||
float _volume_r = 0.f;
|
||||
float _oldvolume_l = 0.f;
|
||||
float _oldvolume_r = 0.f;
|
||||
sint32 _oldvolume = 0;
|
||||
int32_t _oldvolume = 0;
|
||||
float _pan = 0;
|
||||
|
||||
bool _stopping = false;
|
||||
@@ -79,12 +79,12 @@ namespace OpenRCT2::Audio
|
||||
_resampler = value;
|
||||
}
|
||||
|
||||
sint32 GetGroup() const override
|
||||
int32_t GetGroup() const override
|
||||
{
|
||||
return _group;
|
||||
}
|
||||
|
||||
void SetGroup(sint32 group) override
|
||||
void SetGroup(int32_t group) override
|
||||
{
|
||||
_group = group;
|
||||
}
|
||||
@@ -99,34 +99,34 @@ namespace OpenRCT2::Audio
|
||||
_rate = std::max(0.001, rate);
|
||||
}
|
||||
|
||||
uint64 GetOffset() const override
|
||||
uint64_t GetOffset() const override
|
||||
{
|
||||
return _offset;
|
||||
}
|
||||
|
||||
bool SetOffset(uint64 offset) override
|
||||
bool SetOffset(uint64_t offset) override
|
||||
{
|
||||
if (_source != nullptr && offset < _source->GetLength())
|
||||
{
|
||||
AudioFormat format = _source->GetFormat();
|
||||
sint32 samplesize = format.channels * format.BytesPerSample();
|
||||
int32_t samplesize = format.channels * format.BytesPerSample();
|
||||
_offset = (offset / samplesize) * samplesize;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual sint32 GetLoop() const override
|
||||
virtual int32_t GetLoop() const override
|
||||
{
|
||||
return _loop;
|
||||
}
|
||||
|
||||
virtual void SetLoop(sint32 value) override
|
||||
virtual void SetLoop(int32_t value) override
|
||||
{
|
||||
_loop = value;
|
||||
}
|
||||
|
||||
sint32 GetVolume() const override
|
||||
int32_t GetVolume() const override
|
||||
{
|
||||
return _volume;
|
||||
}
|
||||
@@ -151,12 +151,12 @@ namespace OpenRCT2::Audio
|
||||
return _oldvolume_r;
|
||||
}
|
||||
|
||||
sint32 GetOldVolume() const override
|
||||
int32_t GetOldVolume() const override
|
||||
{
|
||||
return _oldvolume;
|
||||
}
|
||||
|
||||
void SetVolume(sint32 volume) override
|
||||
void SetVolume(int32_t volume) override
|
||||
{
|
||||
_volume = Math::Clamp(0, volume, MIXER_VOLUME_MAX);
|
||||
}
|
||||
@@ -223,7 +223,7 @@ namespace OpenRCT2::Audio
|
||||
return !_done;
|
||||
}
|
||||
|
||||
void Play(IAudioSource * source, sint32 loop) override
|
||||
void Play(IAudioSource * source, int32_t loop) override
|
||||
{
|
||||
_source = static_cast<ISDLAudioSource *>(source);
|
||||
_loop = loop;
|
||||
|
||||
@@ -45,8 +45,8 @@ namespace OpenRCT2::Audio
|
||||
std::vector<std::string> GetOutputDevices() override
|
||||
{
|
||||
std::vector<std::string> devices;
|
||||
sint32 numDevices = SDL_GetNumAudioDevices(SDL_FALSE);
|
||||
for (sint32 i = 0; i < numDevices; i++)
|
||||
int32_t numDevices = SDL_GetNumAudioDevices(SDL_FALSE);
|
||||
for (int32_t i = 0; i < numDevices; i++)
|
||||
{
|
||||
std::string deviceName = String::ToStd(SDL_GetAudioDeviceName(i, SDL_FALSE));
|
||||
devices.push_back(deviceName);
|
||||
@@ -71,9 +71,9 @@ namespace OpenRCT2::Audio
|
||||
|
||||
void StartTitleMusic() override { }
|
||||
|
||||
IAudioChannel * PlaySound(sint32 soundId, sint32 volume, sint32 pan) override { return nullptr; }
|
||||
IAudioChannel * PlaySoundAtLocation(sint32 soundId, sint16 x, sint16 y, sint16 z) override { return nullptr; }
|
||||
IAudioChannel * PlaySoundPanned(sint32 soundId, sint32 pan, sint16 x, sint16 y, sint16 z) override { return nullptr; }
|
||||
IAudioChannel * PlaySound(int32_t soundId, int32_t volume, int32_t pan) override { return nullptr; }
|
||||
IAudioChannel * PlaySoundAtLocation(int32_t soundId, int16_t x, int16_t y, int16_t z) override { return nullptr; }
|
||||
IAudioChannel * PlaySoundPanned(int32_t soundId, int32_t pan, int16_t x, int16_t y, int16_t z) override { return nullptr; }
|
||||
|
||||
void ToggleAllSounds() override { }
|
||||
void PauseSounds() override { }
|
||||
|
||||
@@ -26,24 +26,24 @@ namespace OpenRCT2::Audio
|
||||
#pragma pack(push, 1)
|
||||
struct WaveFormat
|
||||
{
|
||||
uint16 encoding;
|
||||
uint16 channels;
|
||||
uint32 frequency;
|
||||
uint32 byterate;
|
||||
uint16 blockalign;
|
||||
uint16 bitspersample;
|
||||
uint16_t encoding;
|
||||
uint16_t channels;
|
||||
uint32_t frequency;
|
||||
uint32_t byterate;
|
||||
uint16_t blockalign;
|
||||
uint16_t bitspersample;
|
||||
};
|
||||
assert_struct_size(WaveFormat, 16);
|
||||
|
||||
struct WaveFormatEx
|
||||
{
|
||||
uint16 encoding;
|
||||
uint16 channels;
|
||||
uint32 frequency;
|
||||
uint32 byterate;
|
||||
uint16 blockalign;
|
||||
uint16 bitspersample;
|
||||
uint16 extrasize;
|
||||
uint16_t encoding;
|
||||
uint16_t channels;
|
||||
uint32_t frequency;
|
||||
uint32_t byterate;
|
||||
uint16_t blockalign;
|
||||
uint16_t bitspersample;
|
||||
uint16_t extrasize;
|
||||
};
|
||||
assert_struct_size(WaveFormatEx, 18);
|
||||
#pragma pack(pop)
|
||||
|
||||
@@ -20,16 +20,16 @@ namespace OpenRCT2::Audio
|
||||
*/
|
||||
struct AudioFormat
|
||||
{
|
||||
sint32 freq;
|
||||
int32_t freq;
|
||||
SDL_AudioFormat format;
|
||||
sint32 channels;
|
||||
int32_t channels;
|
||||
|
||||
sint32 BytesPerSample() const
|
||||
int32_t BytesPerSample() const
|
||||
{
|
||||
return (SDL_AUDIO_BITSIZE(format)) / 8;
|
||||
}
|
||||
|
||||
sint32 GetByteRate() const
|
||||
int32_t GetByteRate() const
|
||||
{
|
||||
return BytesPerSample() * channels;
|
||||
}
|
||||
|
||||
@@ -42,15 +42,15 @@ namespace OpenRCT2::Audio
|
||||
float _volume = 1.0f;
|
||||
float _adjustSoundVolume = 0.0f;
|
||||
float _adjustMusicVolume = 0.0f;
|
||||
uint8 _settingSoundVolume = 0xFF;
|
||||
uint8 _settingMusicVolume = 0xFF;
|
||||
uint8_t _settingSoundVolume = 0xFF;
|
||||
uint8_t _settingMusicVolume = 0xFF;
|
||||
|
||||
IAudioSource * _css1Sources[SOUND_MAXID] = { nullptr };
|
||||
IAudioSource * _musicSources[PATH_ID_END] = { nullptr };
|
||||
|
||||
std::vector<uint8> _channelBuffer;
|
||||
std::vector<uint8> _convertBuffer;
|
||||
std::vector<uint8> _effectBuffer;
|
||||
std::vector<uint8_t> _channelBuffer;
|
||||
std::vector<uint8_t> _convertBuffer;
|
||||
std::vector<uint8_t> _effectBuffer;
|
||||
|
||||
public:
|
||||
AudioMixerImpl()
|
||||
@@ -73,7 +73,7 @@ namespace OpenRCT2::Audio
|
||||
want.format = AUDIO_S16SYS;
|
||||
want.channels = 2;
|
||||
want.samples = 2048;
|
||||
want.callback = [](void * arg, uint8 * dst, sint32 length) -> void
|
||||
want.callback = [](void * arg, uint8_t * dst, int32_t length) -> void
|
||||
{
|
||||
auto mixer = static_cast<AudioMixerImpl *>(arg);
|
||||
mixer->GetNextAudioChunk(dst, (size_t)length);
|
||||
@@ -139,7 +139,7 @@ namespace OpenRCT2::Audio
|
||||
SDL_UnlockAudioDevice(_deviceId);
|
||||
}
|
||||
|
||||
IAudioChannel * Play(IAudioSource * source, sint32 loop, bool deleteondone, bool deletesourceondone) override
|
||||
IAudioChannel * Play(IAudioSource * source, int32_t loop, bool deleteondone, bool deletesourceondone) override
|
||||
{
|
||||
Lock();
|
||||
ISDLAudioChannel * channel = AudioChannel::Create();
|
||||
@@ -169,7 +169,7 @@ namespace OpenRCT2::Audio
|
||||
IAudioSource * source = _musicSources[pathId];
|
||||
if (source == nullptr)
|
||||
{
|
||||
const utf8 * path = context_get_path_legacy((sint32)pathId);
|
||||
const utf8 * path = context_get_path_legacy((int32_t)pathId);
|
||||
source = AudioSource::CreateMemoryFromWAV(path, &_format);
|
||||
if (source == nullptr)
|
||||
{
|
||||
@@ -187,12 +187,12 @@ namespace OpenRCT2::Audio
|
||||
_volume = volume;
|
||||
}
|
||||
|
||||
IAudioSource * GetSoundSource(sint32 id) override
|
||||
IAudioSource * GetSoundSource(int32_t id) override
|
||||
{
|
||||
return _css1Sources[id];
|
||||
}
|
||||
|
||||
IAudioSource * GetMusicSource(sint32 id) override
|
||||
IAudioSource * GetMusicSource(int32_t id) override
|
||||
{
|
||||
return _musicSources[id];
|
||||
}
|
||||
@@ -212,7 +212,7 @@ namespace OpenRCT2::Audio
|
||||
}
|
||||
}
|
||||
|
||||
void GetNextAudioChunk(uint8 * dst, size_t length)
|
||||
void GetNextAudioChunk(uint8_t * dst, size_t length)
|
||||
{
|
||||
UpdateAdjustedSound();
|
||||
|
||||
@@ -224,7 +224,7 @@ namespace OpenRCT2::Audio
|
||||
while (it != _channels.end())
|
||||
{
|
||||
auto channel = *it;
|
||||
sint32 group = channel->GetGroup();
|
||||
int32_t group = channel->GetGroup();
|
||||
if (group != MIXER_GROUP_SOUND || gConfigSound.sound_enabled)
|
||||
{
|
||||
MixChannel(channel, dst, length);
|
||||
@@ -256,10 +256,10 @@ namespace OpenRCT2::Audio
|
||||
}
|
||||
}
|
||||
|
||||
void MixChannel(ISDLAudioChannel * channel, uint8 * data, size_t length)
|
||||
void MixChannel(ISDLAudioChannel * channel, uint8_t * data, size_t length)
|
||||
{
|
||||
sint32 byteRate = _format.GetByteRate();
|
||||
sint32 numSamples = (sint32)(length / byteRate);
|
||||
int32_t byteRate = _format.GetByteRate();
|
||||
int32_t numSamples = (int32_t)(length / byteRate);
|
||||
double rate = 1;
|
||||
if (_format.format == AUDIO_S16SYS)
|
||||
{
|
||||
@@ -281,7 +281,7 @@ namespace OpenRCT2::Audio
|
||||
}
|
||||
|
||||
// Read raw PCM from channel
|
||||
sint32 readSamples = (sint32)(numSamples * rate);
|
||||
int32_t readSamples = (int32_t)(numSamples * rate);
|
||||
size_t readLength = (size_t)(readSamples / cvt.len_ratio) * byteRate;
|
||||
_channelBuffer.resize(readLength);
|
||||
size_t bytesRead = channel->Read(_channelBuffer.data(), readLength);
|
||||
@@ -310,25 +310,25 @@ namespace OpenRCT2::Audio
|
||||
// Apply effects
|
||||
if (rate != 1)
|
||||
{
|
||||
sint32 inRate = (sint32)(bufferLen / byteRate);
|
||||
sint32 outRate = numSamples;
|
||||
int32_t inRate = (int32_t)(bufferLen / byteRate);
|
||||
int32_t outRate = numSamples;
|
||||
if (bytesRead != readLength)
|
||||
{
|
||||
inRate = _format.freq;
|
||||
outRate = _format.freq * (1 / rate);
|
||||
}
|
||||
_effectBuffer.resize(length);
|
||||
bufferLen = ApplyResample(channel, buffer, (sint32)(bufferLen / byteRate), numSamples, inRate, outRate);
|
||||
bufferLen = ApplyResample(channel, buffer, (int32_t)(bufferLen / byteRate), numSamples, inRate, outRate);
|
||||
buffer = _effectBuffer.data();
|
||||
}
|
||||
|
||||
// Apply panning and volume
|
||||
ApplyPan(channel, buffer, bufferLen, byteRate);
|
||||
sint32 mixVolume = ApplyVolume(channel, buffer, bufferLen);
|
||||
int32_t mixVolume = ApplyVolume(channel, buffer, bufferLen);
|
||||
|
||||
// Finally mix on to destination buffer
|
||||
size_t dstLength = std::min(length, bufferLen);
|
||||
SDL_MixAudioFormat(data, (const uint8 *)buffer, _format.format, (uint32)dstLength, mixVolume);
|
||||
SDL_MixAudioFormat(data, (const uint8_t *)buffer, _format.format, (uint32_t)dstLength, mixVolume);
|
||||
|
||||
channel->UpdateOldVolume();
|
||||
}
|
||||
@@ -337,9 +337,9 @@ namespace OpenRCT2::Audio
|
||||
* Resample the given buffer into _effectBuffer.
|
||||
* Assumes that srcBuffer is the same format as _format.
|
||||
*/
|
||||
size_t ApplyResample(ISDLAudioChannel * channel, const void * srcBuffer, sint32 srcSamples, sint32 dstSamples, sint32 inRate, sint32 outRate)
|
||||
size_t ApplyResample(ISDLAudioChannel * channel, const void * srcBuffer, int32_t srcSamples, int32_t dstSamples, int32_t inRate, int32_t outRate)
|
||||
{
|
||||
sint32 byteRate = _format.GetByteRate();
|
||||
int32_t byteRate = _format.GetByteRate();
|
||||
|
||||
// Create resampler
|
||||
SpeexResamplerState * resampler = channel->GetResampler();
|
||||
@@ -350,8 +350,8 @@ namespace OpenRCT2::Audio
|
||||
}
|
||||
speex_resampler_set_rate(resampler, inRate, outRate);
|
||||
|
||||
uint32 inLen = srcSamples;
|
||||
uint32 outLen = dstSamples;
|
||||
uint32_t inLen = srcSamples;
|
||||
uint32_t outLen = dstSamples;
|
||||
speex_resampler_process_interleaved_int(
|
||||
resampler,
|
||||
(const spx_int16_t *)srcBuffer,
|
||||
@@ -368,16 +368,16 @@ namespace OpenRCT2::Audio
|
||||
{
|
||||
switch (_format.format) {
|
||||
case AUDIO_S16SYS:
|
||||
EffectPanS16(channel, (sint16 *)buffer, (sint32)(len / sampleSize));
|
||||
EffectPanS16(channel, (int16_t *)buffer, (int32_t)(len / sampleSize));
|
||||
break;
|
||||
case AUDIO_U8:
|
||||
EffectPanU8(channel, (uint8 *)buffer, (sint32)(len / sampleSize));
|
||||
EffectPanU8(channel, (uint8_t *)buffer, (int32_t)(len / sampleSize));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sint32 ApplyVolume(const IAudioChannel * channel, void * buffer, size_t len)
|
||||
int32_t ApplyVolume(const IAudioChannel * channel, void * buffer, size_t len)
|
||||
{
|
||||
float volumeAdjust = _volume;
|
||||
volumeAdjust *= (gConfigSound.master_volume / 100.0f);
|
||||
@@ -396,34 +396,34 @@ namespace OpenRCT2::Audio
|
||||
break;
|
||||
}
|
||||
|
||||
sint32 startVolume = (sint32)(channel->GetOldVolume() * volumeAdjust);
|
||||
sint32 endVolume = (sint32)(channel->GetVolume() * volumeAdjust);
|
||||
int32_t startVolume = (int32_t)(channel->GetOldVolume() * volumeAdjust);
|
||||
int32_t endVolume = (int32_t)(channel->GetVolume() * volumeAdjust);
|
||||
if (channel->IsStopping())
|
||||
{
|
||||
endVolume = 0;
|
||||
}
|
||||
|
||||
sint32 mixVolume = (sint32)(channel->GetVolume() * volumeAdjust);
|
||||
int32_t mixVolume = (int32_t)(channel->GetVolume() * volumeAdjust);
|
||||
if (startVolume != endVolume)
|
||||
{
|
||||
// Set to max since we are adjusting the volume ourselves
|
||||
mixVolume = MIXER_VOLUME_MAX;
|
||||
|
||||
// Fade between volume levels to smooth out sound and minimize clicks from sudden volume changes
|
||||
sint32 fadeLength = (sint32)len / _format.BytesPerSample();
|
||||
int32_t fadeLength = (int32_t)len / _format.BytesPerSample();
|
||||
switch (_format.format) {
|
||||
case AUDIO_S16SYS:
|
||||
EffectFadeS16((sint16 *)buffer, fadeLength, startVolume, endVolume);
|
||||
EffectFadeS16((int16_t *)buffer, fadeLength, startVolume, endVolume);
|
||||
break;
|
||||
case AUDIO_U8:
|
||||
EffectFadeU8((uint8 *)buffer, fadeLength, startVolume, endVolume);
|
||||
EffectFadeU8((uint8_t *)buffer, fadeLength, startVolume, endVolume);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return mixVolume;
|
||||
}
|
||||
|
||||
static void EffectPanS16(const IAudioChannel * channel, sint16 * data, sint32 length)
|
||||
static void EffectPanS16(const IAudioChannel * channel, int16_t * data, int32_t length)
|
||||
{
|
||||
const float dt = 1.0f / (length * 2);
|
||||
float volumeL = channel->GetOldVolumeL();
|
||||
@@ -431,53 +431,53 @@ namespace OpenRCT2::Audio
|
||||
const float d_left = dt * (channel->GetVolumeL() - channel->GetOldVolumeL());
|
||||
const float d_right = dt * (channel->GetVolumeR() - channel->GetOldVolumeR());
|
||||
|
||||
for (sint32 i = 0; i < length * 2; i += 2)
|
||||
for (int32_t i = 0; i < length * 2; i += 2)
|
||||
{
|
||||
data[i] = (sint16)(data[i] * volumeL);
|
||||
data[i + 1] = (sint16)(data[i + 1] * volumeR);
|
||||
data[i] = (int16_t)(data[i] * volumeL);
|
||||
data[i + 1] = (int16_t)(data[i + 1] * volumeR);
|
||||
volumeL += d_left;
|
||||
volumeR += d_right;
|
||||
}
|
||||
}
|
||||
|
||||
static void EffectPanU8(const IAudioChannel * channel, uint8 * data, sint32 length)
|
||||
static void EffectPanU8(const IAudioChannel * channel, uint8_t * data, int32_t length)
|
||||
{
|
||||
float volumeL = channel->GetVolumeL();
|
||||
float volumeR = channel->GetVolumeR();
|
||||
float oldVolumeL = channel->GetOldVolumeL();
|
||||
float oldVolumeR = channel->GetOldVolumeR();
|
||||
|
||||
for (sint32 i = 0; i < length * 2; i += 2)
|
||||
for (int32_t i = 0; i < length * 2; i += 2)
|
||||
{
|
||||
float t = (float)i / (length * 2);
|
||||
data[i] = (uint8)(data[i] * ((1.0 - t) * oldVolumeL + t * volumeL));
|
||||
data[i + 1] = (uint8)(data[i + 1] * ((1.0 - t) * oldVolumeR + t * volumeR));
|
||||
data[i] = (uint8_t)(data[i] * ((1.0 - t) * oldVolumeL + t * volumeL));
|
||||
data[i + 1] = (uint8_t)(data[i + 1] * ((1.0 - t) * oldVolumeR + t * volumeR));
|
||||
}
|
||||
}
|
||||
|
||||
static void EffectFadeS16(sint16 * data, sint32 length, sint32 startvolume, sint32 endvolume)
|
||||
static void EffectFadeS16(int16_t * data, int32_t length, int32_t startvolume, int32_t endvolume)
|
||||
{
|
||||
static_assert(SDL_MIX_MAXVOLUME == MIXER_VOLUME_MAX, "Max volume differs between OpenRCT2 and SDL2");
|
||||
|
||||
float startvolume_f = (float)startvolume / SDL_MIX_MAXVOLUME;
|
||||
float endvolume_f = (float)endvolume / SDL_MIX_MAXVOLUME;
|
||||
for (sint32 i = 0; i < length; i++)
|
||||
for (int32_t i = 0; i < length; i++)
|
||||
{
|
||||
float t = (float)i / length;
|
||||
data[i] = (sint16)(data[i] * ((1 - t) * startvolume_f + t * endvolume_f));
|
||||
data[i] = (int16_t)(data[i] * ((1 - t) * startvolume_f + t * endvolume_f));
|
||||
}
|
||||
}
|
||||
|
||||
static void EffectFadeU8(uint8* data, sint32 length, sint32 startvolume, sint32 endvolume)
|
||||
static void EffectFadeU8(uint8_t* data, int32_t length, int32_t startvolume, int32_t endvolume)
|
||||
{
|
||||
static_assert(SDL_MIX_MAXVOLUME == MIXER_VOLUME_MAX, "Max volume differs between OpenRCT2 and SDL2");
|
||||
|
||||
float startvolume_f = (float)startvolume / SDL_MIX_MAXVOLUME;
|
||||
float endvolume_f = (float)endvolume / SDL_MIX_MAXVOLUME;
|
||||
for (sint32 i = 0; i < length; i++)
|
||||
for (int32_t i = 0; i < length; i++)
|
||||
{
|
||||
float t = (float)i / length;
|
||||
data[i] = (uint8)(data[i] * ((1 - t) * startvolume_f + t * endvolume_f));
|
||||
data[i] = (uint8_t)(data[i] * ((1 - t) * startvolume_f + t * endvolume_f));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -489,10 +489,10 @@ namespace OpenRCT2::Audio
|
||||
{
|
||||
size_t reqConvertBufferCapacity = len * cvt->len_mult;
|
||||
_convertBuffer.resize(reqConvertBufferCapacity);
|
||||
std::copy_n((const uint8 *)src, len, _convertBuffer.data());
|
||||
std::copy_n((const uint8_t *)src, len, _convertBuffer.data());
|
||||
|
||||
cvt->len = (sint32)len;
|
||||
cvt->buf = (uint8 *)_convertBuffer.data();
|
||||
cvt->len = (int32_t)len;
|
||||
cvt->buf = (uint8_t *)_convertBuffer.data();
|
||||
if (SDL_ConvertAudio(cvt) >= 0)
|
||||
{
|
||||
result = true;
|
||||
|
||||
@@ -25,8 +25,8 @@ namespace OpenRCT2::Audio
|
||||
private:
|
||||
AudioFormat _format = {};
|
||||
SDL_RWops * _rw = nullptr;
|
||||
uint64 _dataBegin = 0;
|
||||
uint64 _dataLength = 0;
|
||||
uint64_t _dataBegin = 0;
|
||||
uint64_t _dataLength = 0;
|
||||
|
||||
public:
|
||||
~FileAudioSource()
|
||||
@@ -34,7 +34,7 @@ namespace OpenRCT2::Audio
|
||||
Unload();
|
||||
}
|
||||
|
||||
uint64 GetLength() const override
|
||||
uint64_t GetLength() const override
|
||||
{
|
||||
return _dataLength;
|
||||
}
|
||||
@@ -44,17 +44,17 @@ namespace OpenRCT2::Audio
|
||||
return _format;
|
||||
}
|
||||
|
||||
size_t Read(void * dst, uint64 offset, size_t len) override
|
||||
size_t Read(void * dst, uint64_t offset, size_t len) override
|
||||
{
|
||||
size_t bytesRead = 0;
|
||||
sint64 currentPosition = SDL_RWtell(_rw);
|
||||
int64_t currentPosition = SDL_RWtell(_rw);
|
||||
if (currentPosition != -1)
|
||||
{
|
||||
size_t bytesToRead = (size_t)std::min<uint64>(len, _dataLength - offset);
|
||||
sint64 dataOffset = _dataBegin + offset;
|
||||
size_t bytesToRead = (size_t)std::min<uint64_t>(len, _dataLength - offset);
|
||||
int64_t dataOffset = _dataBegin + offset;
|
||||
if (currentPosition != dataOffset)
|
||||
{
|
||||
sint64 newPosition = SDL_RWseek(_rw, dataOffset, SEEK_SET);
|
||||
int64_t newPosition = SDL_RWseek(_rw, dataOffset, SEEK_SET);
|
||||
if (newPosition == -1)
|
||||
{
|
||||
return 0;
|
||||
@@ -67,11 +67,11 @@ namespace OpenRCT2::Audio
|
||||
|
||||
bool LoadWAV(SDL_RWops * rw)
|
||||
{
|
||||
const uint32 DATA = 0x61746164;
|
||||
const uint32 FMT = 0x20746D66;
|
||||
const uint32 RIFF = 0x46464952;
|
||||
const uint32 WAVE = 0x45564157;
|
||||
const uint16 pcmformat = 0x0001;
|
||||
const uint32_t DATA = 0x61746164;
|
||||
const uint32_t FMT = 0x20746D66;
|
||||
const uint32_t RIFF = 0x46464952;
|
||||
const uint32_t WAVE = 0x45564157;
|
||||
const uint16_t pcmformat = 0x0001;
|
||||
|
||||
Unload();
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace OpenRCT2::Audio
|
||||
}
|
||||
_rw = rw;
|
||||
|
||||
uint32 chunkId = SDL_ReadLE32(rw);
|
||||
uint32_t chunkId = SDL_ReadLE32(rw);
|
||||
if (chunkId != RIFF)
|
||||
{
|
||||
log_verbose("Not a WAV file");
|
||||
@@ -90,21 +90,21 @@ namespace OpenRCT2::Audio
|
||||
|
||||
// Read and discard chunk size
|
||||
SDL_ReadLE32(rw);
|
||||
uint32 chunkFormat = SDL_ReadLE32(rw);
|
||||
uint32_t chunkFormat = SDL_ReadLE32(rw);
|
||||
if (chunkFormat != WAVE)
|
||||
{
|
||||
log_verbose("Not in WAVE format");
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 fmtChunkSize = FindChunk(rw, FMT);
|
||||
uint32_t fmtChunkSize = FindChunk(rw, FMT);
|
||||
if (!fmtChunkSize)
|
||||
{
|
||||
log_verbose("Could not find FMT chunk");
|
||||
return false;
|
||||
}
|
||||
|
||||
uint64 chunkStart = SDL_RWtell(rw);
|
||||
uint64_t chunkStart = SDL_RWtell(rw);
|
||||
|
||||
WaveFormat waveFormat;
|
||||
SDL_RWread(rw, &waveFormat, sizeof(waveFormat), 1);
|
||||
@@ -128,7 +128,7 @@ namespace OpenRCT2::Audio
|
||||
}
|
||||
_format.channels = waveFormat.channels;
|
||||
|
||||
uint32 dataChunkSize = FindChunk(rw, DATA);
|
||||
uint32_t dataChunkSize = FindChunk(rw, DATA);
|
||||
if (dataChunkSize == 0)
|
||||
{
|
||||
log_verbose("Could not find DATA chunk");
|
||||
@@ -141,18 +141,18 @@ namespace OpenRCT2::Audio
|
||||
}
|
||||
|
||||
private:
|
||||
uint32 FindChunk(SDL_RWops * rw, uint32 wantedId)
|
||||
uint32_t FindChunk(SDL_RWops * rw, uint32_t wantedId)
|
||||
{
|
||||
uint32 subchunkId = SDL_ReadLE32(rw);
|
||||
uint32 subchunkSize = SDL_ReadLE32(rw);
|
||||
uint32_t subchunkId = SDL_ReadLE32(rw);
|
||||
uint32_t subchunkSize = SDL_ReadLE32(rw);
|
||||
if (subchunkId == wantedId)
|
||||
{
|
||||
return subchunkSize;
|
||||
}
|
||||
const uint32 FACT = 0x74636166;
|
||||
const uint32 LIST = 0x5453494c;
|
||||
const uint32 BEXT = 0x74786562;
|
||||
const uint32 JUNK = 0x4B4E554A;
|
||||
const uint32_t FACT = 0x74636166;
|
||||
const uint32_t LIST = 0x5453494c;
|
||||
const uint32_t BEXT = 0x74786562;
|
||||
const uint32_t JUNK = 0x4B4E554A;
|
||||
while (subchunkId == FACT || subchunkId == LIST || subchunkId == BEXT || subchunkId == JUNK)
|
||||
{
|
||||
SDL_RWseek(rw, subchunkSize, RW_SEEK_CUR);
|
||||
|
||||
@@ -27,11 +27,11 @@ namespace OpenRCT2::Audio
|
||||
{
|
||||
private:
|
||||
AudioFormat _format = {};
|
||||
std::vector<uint8> _data;
|
||||
uint8 * _dataSDL = nullptr;
|
||||
std::vector<uint8_t> _data;
|
||||
uint8_t * _dataSDL = nullptr;
|
||||
size_t _length = 0;
|
||||
|
||||
const uint8 * GetData()
|
||||
const uint8_t * GetData()
|
||||
{
|
||||
return _dataSDL != nullptr ? _dataSDL : _data.data();
|
||||
}
|
||||
@@ -42,7 +42,7 @@ namespace OpenRCT2::Audio
|
||||
Unload();
|
||||
}
|
||||
|
||||
uint64 GetLength() const override
|
||||
uint64_t GetLength() const override
|
||||
{
|
||||
return _length;
|
||||
}
|
||||
@@ -52,17 +52,17 @@ namespace OpenRCT2::Audio
|
||||
return _format;
|
||||
}
|
||||
|
||||
size_t Read(void * dst, uint64 offset, size_t len) override
|
||||
size_t Read(void * dst, uint64_t offset, size_t len) override
|
||||
{
|
||||
size_t bytesToRead = 0;
|
||||
if (offset < _length)
|
||||
{
|
||||
bytesToRead = (size_t)std::min<uint64>(len, _length - offset);
|
||||
bytesToRead = (size_t)std::min<uint64_t>(len, _length - offset);
|
||||
|
||||
auto src = GetData();
|
||||
if (src != nullptr)
|
||||
{
|
||||
std::copy_n(src + offset, bytesToRead, (uint8 *)dst);
|
||||
std::copy_n(src + offset, bytesToRead, (uint8_t *)dst);
|
||||
}
|
||||
}
|
||||
return bytesToRead;
|
||||
@@ -79,7 +79,7 @@ namespace OpenRCT2::Audio
|
||||
if (rw != nullptr)
|
||||
{
|
||||
SDL_AudioSpec audiospec = {};
|
||||
uint32 audioLen;
|
||||
uint32_t audioLen;
|
||||
SDL_AudioSpec * spec = SDL_LoadWAV_RW(rw, false, &audiospec, &_dataSDL, &audioLen);
|
||||
if (spec != nullptr)
|
||||
{
|
||||
@@ -112,17 +112,17 @@ namespace OpenRCT2::Audio
|
||||
SDL_RWops * rw = SDL_RWFromFile(path, "rb");
|
||||
if (rw != nullptr)
|
||||
{
|
||||
uint32 numSounds;
|
||||
uint32_t numSounds;
|
||||
SDL_RWread(rw, &numSounds, sizeof(numSounds), 1);
|
||||
if (index < numSounds)
|
||||
{
|
||||
SDL_RWseek(rw, index * 4, RW_SEEK_CUR);
|
||||
|
||||
uint32 pcmOffset;
|
||||
uint32_t pcmOffset;
|
||||
SDL_RWread(rw, &pcmOffset, sizeof(pcmOffset), 1);
|
||||
SDL_RWseek(rw, pcmOffset, RW_SEEK_SET);
|
||||
|
||||
uint32 pcmSize;
|
||||
uint32_t pcmSize;
|
||||
SDL_RWread(rw, &pcmSize, sizeof(pcmSize), 1);
|
||||
_length = pcmSize;
|
||||
|
||||
@@ -160,9 +160,9 @@ namespace OpenRCT2::Audio
|
||||
if (SDL_BuildAudioCVT(&cvt, _format.format, _format.channels, _format.freq, format->format, format->channels, format->freq) >= 0)
|
||||
{
|
||||
auto src = GetData();
|
||||
auto cvtBuffer = std::vector<uint8>(_length * cvt.len_mult);
|
||||
auto cvtBuffer = std::vector<uint8_t>(_length * cvt.len_mult);
|
||||
std::copy_n(src, _length, cvtBuffer.data());
|
||||
cvt.len = (sint32)_length;
|
||||
cvt.len = (int32_t)_length;
|
||||
cvt.buf = cvtBuffer.data();
|
||||
if (SDL_ConvertAudio(&cvt) >= 0)
|
||||
{
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
#include <openrct2/core/Imaging.h>
|
||||
#include "BitmapReader.h"
|
||||
|
||||
static std::vector<uint8> ReadToVector(std::istream &stream)
|
||||
static std::vector<uint8_t> ReadToVector(std::istream &stream)
|
||||
{
|
||||
std::vector<uint8> result;
|
||||
std::vector<uint8_t> result;
|
||||
if (!stream.eof() && !stream.fail())
|
||||
{
|
||||
stream.seekg(0, std::ios_base::end);
|
||||
@@ -58,11 +58,11 @@ static Image ReadBitmap(std::istream &istream, IMAGE_FORMAT format)
|
||||
std::fill(image.Pixels.begin(), image.Pixels.end(), 0xFF);
|
||||
|
||||
// Copy pixels over
|
||||
auto src = (const uint8 *)bitmap->pixels;
|
||||
auto src = (const uint8_t *)bitmap->pixels;
|
||||
auto dst = image.Pixels.data();
|
||||
if (numChannels == 4)
|
||||
{
|
||||
for (sint32 y = 0; y < bitmap->h; y++)
|
||||
for (int32_t y = 0; y < bitmap->h; y++)
|
||||
{
|
||||
std::memcpy(dst, src, bitmap->w);
|
||||
src += bitmap->pitch;
|
||||
@@ -71,9 +71,9 @@ static Image ReadBitmap(std::istream &istream, IMAGE_FORMAT format)
|
||||
}
|
||||
else
|
||||
{
|
||||
for (sint32 y = 0; y < bitmap->h; y++)
|
||||
for (int32_t y = 0; y < bitmap->h; y++)
|
||||
{
|
||||
for (sint32 x = 0; x < bitmap->w; x++)
|
||||
for (int32_t x = 0; x < bitmap->w; x++)
|
||||
{
|
||||
std::memcpy(dst, src, 3);
|
||||
src += 3;
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace OpenRCT2
|
||||
public:
|
||||
std::unique_ptr<IDrawingEngine> Create(DRAWING_ENGINE_TYPE type, const std::shared_ptr<IUiContext>& uiContext) override
|
||||
{
|
||||
switch ((sint32)type) {
|
||||
switch ((int32_t)type) {
|
||||
case DRAWING_ENGINE_SOFTWARE:
|
||||
return CreateSoftwareDrawingEngine(uiContext);
|
||||
case DRAWING_ENGINE_SOFTWARE_WITH_HARDWARE_DISPLAY:
|
||||
|
||||
@@ -28,7 +28,7 @@ using namespace OpenRCT2::Ui;
|
||||
class HardwareDisplayDrawingEngine final : public X8DrawingEngine
|
||||
{
|
||||
private:
|
||||
constexpr static uint32 DIRTY_VISUAL_TIME = 32;
|
||||
constexpr static uint32_t DIRTY_VISUAL_TIME = 32;
|
||||
|
||||
std::shared_ptr<IUiContext> const _uiContext;
|
||||
SDL_Window * _window = nullptr;
|
||||
@@ -36,19 +36,19 @@ private:
|
||||
SDL_Texture * _screenTexture = nullptr;
|
||||
SDL_Texture * _scaledScreenTexture = nullptr;
|
||||
SDL_PixelFormat * _screenTextureFormat = nullptr;
|
||||
uint32 _paletteHWMapped[256] = { 0 };
|
||||
uint32_t _paletteHWMapped[256] = { 0 };
|
||||
#ifdef __ENABLE_LIGHTFX__
|
||||
uint32 _lightPaletteHWMapped[256] = { 0 };
|
||||
uint32_t _lightPaletteHWMapped[256] = { 0 };
|
||||
#endif
|
||||
|
||||
// Steam overlay checking
|
||||
uint32 _pixelBeforeOverlay = 0;
|
||||
uint32 _pixelAfterOverlay = 0;
|
||||
uint32_t _pixelBeforeOverlay = 0;
|
||||
uint32_t _pixelAfterOverlay = 0;
|
||||
bool _overlayActive = false;
|
||||
bool _pausedBeforeOverlay = false;
|
||||
bool _useVsync = true;
|
||||
|
||||
std::vector<uint32> _dirtyVisualsTime;
|
||||
std::vector<uint32_t> _dirtyVisualsTime;
|
||||
|
||||
bool smoothNN = false;
|
||||
|
||||
@@ -90,7 +90,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void Resize(uint32 width, uint32 height) override
|
||||
void Resize(uint32_t width, uint32_t height) override
|
||||
{
|
||||
if (_screenTexture != nullptr)
|
||||
{
|
||||
@@ -99,16 +99,16 @@ public:
|
||||
SDL_FreeFormat(_screenTextureFormat);
|
||||
|
||||
SDL_RendererInfo rendererInfo = {};
|
||||
sint32 result = SDL_GetRendererInfo(_sdlRenderer, &rendererInfo);
|
||||
int32_t result = SDL_GetRendererInfo(_sdlRenderer, &rendererInfo);
|
||||
if (result < 0)
|
||||
{
|
||||
log_warning("HWDisplayDrawingEngine::Resize error: %s", SDL_GetError());
|
||||
return;
|
||||
}
|
||||
uint32 pixelFormat = SDL_PIXELFORMAT_UNKNOWN;
|
||||
for (uint32 i = 0; i < rendererInfo.num_texture_formats; i++)
|
||||
uint32_t pixelFormat = SDL_PIXELFORMAT_UNKNOWN;
|
||||
for (uint32_t i = 0; i < rendererInfo.num_texture_formats; i++)
|
||||
{
|
||||
uint32 format = rendererInfo.texture_formats[i];
|
||||
uint32_t format = rendererInfo.texture_formats[i];
|
||||
if (!SDL_ISPIXELFORMAT_FOURCC(format) &&
|
||||
!SDL_ISPIXELFORMAT_INDEXED(format) &&
|
||||
(pixelFormat == SDL_PIXELFORMAT_UNKNOWN || SDL_BYTESPERPIXEL(format) < SDL_BYTESPERPIXEL(pixelFormat)))
|
||||
@@ -117,7 +117,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
sint32 scaleQuality = GetContext()->GetUiContext()->GetScaleQuality();
|
||||
int32_t scaleQuality = GetContext()->GetUiContext()->GetScaleQuality();
|
||||
if (scaleQuality == SCALE_QUALITY_SMOOTH_NN)
|
||||
{
|
||||
scaleQuality = SCALE_QUALITY_LINEAR;
|
||||
@@ -141,7 +141,7 @@ public:
|
||||
_screenTexture = SDL_CreateTexture(_sdlRenderer, pixelFormat, SDL_TEXTUREACCESS_STREAMING, width, height);
|
||||
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, scaleQualityBuffer);
|
||||
|
||||
uint32 scale = std::ceil(gConfigGeneral.window_scale);
|
||||
uint32_t scale = std::ceil(gConfigGeneral.window_scale);
|
||||
_scaledScreenTexture = SDL_CreateTexture(_sdlRenderer, pixelFormat, SDL_TEXTUREACCESS_TARGET,
|
||||
width * scale, height * scale);
|
||||
}
|
||||
@@ -150,7 +150,7 @@ public:
|
||||
_screenTexture = SDL_CreateTexture(_sdlRenderer, pixelFormat, SDL_TEXTUREACCESS_STREAMING,width, height);
|
||||
}
|
||||
|
||||
uint32 format;
|
||||
uint32_t format;
|
||||
SDL_QueryTexture(_screenTexture, &format, nullptr, nullptr, nullptr);
|
||||
_screenTextureFormat = SDL_AllocFormat(format);
|
||||
|
||||
@@ -161,7 +161,7 @@ public:
|
||||
{
|
||||
if (_screenTextureFormat != nullptr)
|
||||
{
|
||||
for (sint32 i = 0; i < 256; i++)
|
||||
for (int32_t i = 0; i < 256; i++)
|
||||
{
|
||||
_paletteHWMapped[i] = SDL_MapRGB(_screenTextureFormat, palette[i].red, palette[i].green, palette[i].blue);
|
||||
}
|
||||
@@ -170,7 +170,7 @@ public:
|
||||
if (gConfigGeneral.enable_light_fx)
|
||||
{
|
||||
auto lightPalette = lightfx_get_palette();
|
||||
for (sint32 i = 0; i < 256; i++)
|
||||
for (int32_t i = 0; i < 256; i++)
|
||||
{
|
||||
auto src = &lightPalette->entries[i];
|
||||
_lightPaletteHWMapped[i] = SDL_MapRGBA(_screenTextureFormat, src->red, src->green, src->blue, src->alpha);
|
||||
@@ -190,15 +190,15 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
void OnDrawDirtyBlock(uint32 left, uint32 top, uint32 columns, uint32 rows) override
|
||||
void OnDrawDirtyBlock(uint32_t left, uint32_t top, uint32_t columns, uint32_t rows) override
|
||||
{
|
||||
if (gShowDirtyVisuals)
|
||||
{
|
||||
uint32 right = left + columns;
|
||||
uint32 bottom = top + rows;
|
||||
for (uint32 x = left; x < right; x++)
|
||||
uint32_t right = left + columns;
|
||||
uint32_t bottom = top + rows;
|
||||
for (uint32_t x = left; x < right; x++)
|
||||
{
|
||||
for (uint32 y = top; y < bottom; y++)
|
||||
for (uint32_t y = top; y < bottom; y++)
|
||||
{
|
||||
SetDirtyVisualTime(x, y, DIRTY_VISUAL_TIME);
|
||||
}
|
||||
@@ -213,7 +213,7 @@ private:
|
||||
if (gConfigGeneral.enable_light_fx)
|
||||
{
|
||||
void * pixels;
|
||||
sint32 pitch;
|
||||
int32_t pitch;
|
||||
if (SDL_LockTexture(_screenTexture, nullptr, &pixels, &pitch) == 0)
|
||||
{
|
||||
lightfx_render_to_texture(pixels, pitch, _bits, _width, _height, _paletteHWMapped, _lightPaletteHWMapped);
|
||||
@@ -223,7 +223,7 @@ private:
|
||||
else
|
||||
#endif
|
||||
{
|
||||
CopyBitsToTexture(_screenTexture, _bits, (sint32)_width, (sint32)_height, _paletteHWMapped);
|
||||
CopyBitsToTexture(_screenTexture, _bits, (int32_t)_width, (int32_t)_height, _paletteHWMapped);
|
||||
}
|
||||
if (smoothNN)
|
||||
{
|
||||
@@ -257,17 +257,17 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
void CopyBitsToTexture(SDL_Texture * texture, uint8 * src, sint32 width, sint32 height, const uint32 * palette)
|
||||
void CopyBitsToTexture(SDL_Texture * texture, uint8_t * src, int32_t width, int32_t height, const uint32_t * palette)
|
||||
{
|
||||
void * pixels;
|
||||
sint32 pitch;
|
||||
int32_t pitch;
|
||||
if (SDL_LockTexture(texture, nullptr, &pixels, &pitch) == 0)
|
||||
{
|
||||
sint32 padding = pitch - (width * 4);
|
||||
int32_t padding = pitch - (width * 4);
|
||||
if (pitch == width * 4)
|
||||
{
|
||||
uint32 * dst = (uint32 *)pixels;
|
||||
for (sint32 i = width * height; i > 0; i--)
|
||||
uint32_t * dst = (uint32_t *)pixels;
|
||||
for (int32_t i = width * height; i > 0; i--)
|
||||
{
|
||||
*dst++ = palette[*src++];
|
||||
}
|
||||
@@ -276,26 +276,26 @@ private:
|
||||
{
|
||||
if (pitch == (width * 2) + padding)
|
||||
{
|
||||
uint16 * dst = (uint16 *)pixels;
|
||||
for (sint32 y = height; y > 0; y--)
|
||||
uint16_t * dst = (uint16_t *)pixels;
|
||||
for (int32_t y = height; y > 0; y--)
|
||||
{
|
||||
for (sint32 x = width; x > 0; x--)
|
||||
for (int32_t x = width; x > 0; x--)
|
||||
{
|
||||
const uint8 lower = *(uint8 *)(&palette[*src++]);
|
||||
const uint8 upper = *(uint8 *)(&palette[*src++]);
|
||||
const uint8_t lower = *(uint8_t *)(&palette[*src++]);
|
||||
const uint8_t upper = *(uint8_t *)(&palette[*src++]);
|
||||
*dst++ = (lower << 8) | upper;
|
||||
}
|
||||
dst = (uint16*)(((uint8 *)dst) + padding);
|
||||
dst = (uint16_t*)(((uint8_t *)dst) + padding);
|
||||
}
|
||||
}
|
||||
else if (pitch == width + padding)
|
||||
{
|
||||
uint8 * dst = (uint8 *)pixels;
|
||||
for (sint32 y = height; y > 0; y--)
|
||||
uint8_t * dst = (uint8_t *)pixels;
|
||||
for (int32_t y = height; y > 0; y--)
|
||||
{
|
||||
for (sint32 x = width; x > 0; x--)
|
||||
for (int32_t x = width; x > 0; x--)
|
||||
{
|
||||
*dst++ = *(uint8 *)(&palette[*src++]);
|
||||
*dst++ = *(uint8_t *)(&palette[*src++]);
|
||||
}
|
||||
dst += padding;
|
||||
}
|
||||
@@ -305,10 +305,10 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
uint32 GetDirtyVisualTime(uint32 x, uint32 y)
|
||||
uint32_t GetDirtyVisualTime(uint32_t x, uint32_t y)
|
||||
{
|
||||
uint32 result = 0;
|
||||
uint32 i = y * _dirtyGrid.BlockColumns + x;
|
||||
uint32_t result = 0;
|
||||
uint32_t i = y * _dirtyGrid.BlockColumns + x;
|
||||
if (_dirtyVisualsTime.size() > i)
|
||||
{
|
||||
result = _dirtyVisualsTime[i];
|
||||
@@ -316,9 +316,9 @@ private:
|
||||
return result;
|
||||
}
|
||||
|
||||
void SetDirtyVisualTime(uint32 x, uint32 y, uint32 value)
|
||||
void SetDirtyVisualTime(uint32_t x, uint32_t y, uint32_t value)
|
||||
{
|
||||
uint32 i = y * _dirtyGrid.BlockColumns + x;
|
||||
uint32_t i = y * _dirtyGrid.BlockColumns + x;
|
||||
if (_dirtyVisualsTime.size() > i)
|
||||
{
|
||||
_dirtyVisualsTime[i] = value;
|
||||
@@ -328,9 +328,9 @@ private:
|
||||
void UpdateDirtyVisuals()
|
||||
{
|
||||
_dirtyVisualsTime.resize(_dirtyGrid.BlockRows * _dirtyGrid.BlockColumns);
|
||||
for (uint32 y = 0; y < _dirtyGrid.BlockRows; y++)
|
||||
for (uint32_t y = 0; y < _dirtyGrid.BlockRows; y++)
|
||||
{
|
||||
for (uint32 x = 0; x < _dirtyGrid.BlockColumns; x++)
|
||||
for (uint32_t x = 0; x < _dirtyGrid.BlockColumns; x++)
|
||||
{
|
||||
auto timeLeft = GetDirtyVisualTime(x, y);
|
||||
if (timeLeft > 0)
|
||||
@@ -347,20 +347,20 @@ private:
|
||||
float scaleY = gConfigGeneral.window_scale;
|
||||
|
||||
SDL_SetRenderDrawBlendMode(_sdlRenderer, SDL_BLENDMODE_BLEND);
|
||||
for (uint32 y = 0; y < _dirtyGrid.BlockRows; y++)
|
||||
for (uint32_t y = 0; y < _dirtyGrid.BlockRows; y++)
|
||||
{
|
||||
for (uint32 x = 0; x < _dirtyGrid.BlockColumns; x++)
|
||||
for (uint32_t x = 0; x < _dirtyGrid.BlockColumns; x++)
|
||||
{
|
||||
auto timeLeft = GetDirtyVisualTime(x, y);
|
||||
if (timeLeft > 0)
|
||||
{
|
||||
uint8 alpha = (uint8)(timeLeft * 5 / 2);
|
||||
uint8_t alpha = (uint8_t)(timeLeft * 5 / 2);
|
||||
|
||||
SDL_Rect ddRect;
|
||||
ddRect.x = (sint32)(x * _dirtyGrid.BlockWidth * scaleX);
|
||||
ddRect.y = (sint32)(y * _dirtyGrid.BlockHeight * scaleY);
|
||||
ddRect.w = (sint32)(_dirtyGrid.BlockWidth * scaleX);
|
||||
ddRect.h = (sint32)(_dirtyGrid.BlockHeight * scaleY);
|
||||
ddRect.x = (int32_t)(x * _dirtyGrid.BlockWidth * scaleX);
|
||||
ddRect.y = (int32_t)(y * _dirtyGrid.BlockHeight * scaleY);
|
||||
ddRect.w = (int32_t)(_dirtyGrid.BlockWidth * scaleX);
|
||||
ddRect.h = (int32_t)(_dirtyGrid.BlockHeight * scaleY);
|
||||
|
||||
SDL_SetRenderDrawColor(_sdlRenderer, 255, 255, 255, alpha);
|
||||
SDL_RenderFillRect(_sdlRenderer, &ddRect);
|
||||
@@ -369,10 +369,10 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
void ReadCentrePixel(uint32 * pixel)
|
||||
void ReadCentrePixel(uint32_t * pixel)
|
||||
{
|
||||
SDL_Rect centrePixelRegion = { (sint32)(_width / 2), (sint32)(_height / 2), 1, 1 };
|
||||
SDL_RenderReadPixels(_sdlRenderer, ¢rePixelRegion, SDL_PIXELFORMAT_RGBA8888, pixel, sizeof(uint32));
|
||||
SDL_Rect centrePixelRegion = { (int32_t)(_width / 2), (int32_t)(_height / 2), 1, 1 };
|
||||
SDL_RenderReadPixels(_sdlRenderer, ¢rePixelRegion, SDL_PIXELFORMAT_RGBA8888, pixel, sizeof(uint32_t));
|
||||
}
|
||||
|
||||
// Should be called before SDL_RenderPresent to capture frame buffer before Steam overlay is drawn.
|
||||
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
void Resize(uint32 width, uint32 height) override
|
||||
void Resize(uint32_t width, uint32_t height) override
|
||||
{
|
||||
SDL_FreeSurface(_surface);
|
||||
SDL_FreeSurface(_RGBASurface);
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
if (windowSurface != nullptr && _palette != nullptr)
|
||||
{
|
||||
SDL_Colour colours[256];
|
||||
for (sint32 i = 0; i < 256; i++) {
|
||||
for (int32_t i = 0; i < 256; i++) {
|
||||
colours[i].r = palette[i].red;
|
||||
colours[i].g = palette[i].green;
|
||||
colours[i].b = palette[i].blue;
|
||||
@@ -113,7 +113,7 @@ private:
|
||||
}
|
||||
|
||||
// Copy pixels from the virtual screen buffer to the surface
|
||||
std::copy_n(_bits, _surface->pitch * _surface->h, (uint8 *)_surface->pixels);
|
||||
std::copy_n(_bits, _surface->pitch * _surface->h, (uint8_t *)_surface->pixels);
|
||||
|
||||
// Unlock the surface
|
||||
if (SDL_MUSTLOCK(_surface))
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user