mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 11:35:08 -04:00
fix changing colours in launcher not saving
This commit is contained in:
parent
4be56bf54c
commit
5caa2c99b2
@ -507,7 +507,7 @@ ReturnCode Png_Decode(Bitmap* bmp, struct Stream* stream) {
|
|||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*------------------------------------------------------PNG encoder--------------------------------------------------------*
|
*------------------------------------------------------PNG encoder--------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static ReturnCode Bitmap_Crc32StreamWrite(struct Stream* stream, uint8_t* data, uint32_t count, uint32_t* modified) {
|
static ReturnCode Bitmap_Crc32StreamWrite(struct Stream* stream, const uint8_t* data, uint32_t count, uint32_t* modified) {
|
||||||
struct Stream* source;
|
struct Stream* source;
|
||||||
uint32_t i, crc32 = stream->Meta.CRC32.CRC32;
|
uint32_t i, crc32 = stream->Meta.CRC32.CRC32;
|
||||||
|
|
||||||
|
@ -895,7 +895,7 @@ static ReturnCode Deflate_FlushBlock(struct DeflateState* state, int len) {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ReturnCode Deflate_StreamWrite(struct Stream* stream, uint8_t* data, uint32_t count, uint32_t* modified) {
|
static ReturnCode Deflate_StreamWrite(struct Stream* stream, const uint8_t* data, uint32_t count, uint32_t* modified) {
|
||||||
struct DeflateState* state;
|
struct DeflateState* state;
|
||||||
ReturnCode res;
|
ReturnCode res;
|
||||||
|
|
||||||
@ -978,7 +978,7 @@ static ReturnCode GZip_StreamClose(struct Stream* stream) {
|
|||||||
return Stream_Write(state->Base.Dest, data, sizeof(data));
|
return Stream_Write(state->Base.Dest, data, sizeof(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
static ReturnCode GZip_StreamWrite(struct Stream* stream, uint8_t* data, uint32_t count, uint32_t* modified) {
|
static ReturnCode GZip_StreamWrite(struct Stream* stream, const uint8_t* data, uint32_t count, uint32_t* modified) {
|
||||||
struct GZipState* state = stream->Meta.Inflate;
|
struct GZipState* state = stream->Meta.Inflate;
|
||||||
uint32_t i, crc32 = state->Crc32;
|
uint32_t i, crc32 = state->Crc32;
|
||||||
state->Size += count;
|
state->Size += count;
|
||||||
@ -992,7 +992,7 @@ static ReturnCode GZip_StreamWrite(struct Stream* stream, uint8_t* data, uint32_
|
|||||||
return Deflate_StreamWrite(stream, data, count, modified);
|
return Deflate_StreamWrite(stream, data, count, modified);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ReturnCode GZip_StreamWriteFirst(struct Stream* stream, uint8_t* data, uint32_t count, uint32_t* modified) {
|
static ReturnCode GZip_StreamWriteFirst(struct Stream* stream, const uint8_t* data, uint32_t count, uint32_t* modified) {
|
||||||
static uint8_t header[10] = { 0x1F, 0x8B, 0x08 }; /* GZip header */
|
static uint8_t header[10] = { 0x1F, 0x8B, 0x08 }; /* GZip header */
|
||||||
struct GZipState* state = stream->Meta.Inflate;
|
struct GZipState* state = stream->Meta.Inflate;
|
||||||
ReturnCode res;
|
ReturnCode res;
|
||||||
@ -1024,7 +1024,7 @@ static ReturnCode ZLib_StreamClose(struct Stream* stream) {
|
|||||||
return Stream_Write(state->Base.Dest, data, sizeof(data));
|
return Stream_Write(state->Base.Dest, data, sizeof(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
static ReturnCode ZLib_StreamWrite(struct Stream* stream, uint8_t* data, uint32_t count, uint32_t* modified) {
|
static ReturnCode ZLib_StreamWrite(struct Stream* stream, const uint8_t* data, uint32_t count, uint32_t* modified) {
|
||||||
struct ZLibState* state = stream->Meta.Inflate;
|
struct ZLibState* state = stream->Meta.Inflate;
|
||||||
uint32_t i, adler32 = state->Adler32;
|
uint32_t i, adler32 = state->Adler32;
|
||||||
uint32_t s1 = adler32 & 0xFFFF, s2 = (adler32 >> 16) & 0xFFFF;
|
uint32_t s1 = adler32 & 0xFFFF, s2 = (adler32 >> 16) & 0xFFFF;
|
||||||
@ -1040,7 +1040,7 @@ static ReturnCode ZLib_StreamWrite(struct Stream* stream, uint8_t* data, uint32_
|
|||||||
return Deflate_StreamWrite(stream, data, count, modified);
|
return Deflate_StreamWrite(stream, data, count, modified);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ReturnCode ZLib_StreamWriteFirst(struct Stream* stream, uint8_t* data, uint32_t count, uint32_t* modified) {
|
static ReturnCode ZLib_StreamWriteFirst(struct Stream* stream, const uint8_t* data, uint32_t count, uint32_t* modified) {
|
||||||
static uint8_t header[2] = { 0x78, 0x9C }; /* ZLib header */
|
static uint8_t header[2] = { 0x78, 0x9C }; /* ZLib header */
|
||||||
struct ZLibState* state = stream->Meta.Inflate;
|
struct ZLibState* state = stream->Meta.Inflate;
|
||||||
ReturnCode res;
|
ReturnCode res;
|
||||||
|
@ -387,8 +387,6 @@ static void ColoursScreen_TextChanged(struct LInput* w) {
|
|||||||
if (!Convert_ParseUInt8(&s->IptColours[index + 2].Text, &b)) return;
|
if (!Convert_ParseUInt8(&s->IptColours[index + 2].Text, &b)) return;
|
||||||
|
|
||||||
Launcher_SaveSkin();
|
Launcher_SaveSkin();
|
||||||
Launcher_SaveOptions = true;
|
|
||||||
|
|
||||||
col->R = r; col->G = g; col->B = b;
|
col->R = r; col->G = g; col->B = b;
|
||||||
Launcher_Redraw();
|
Launcher_Redraw();
|
||||||
}
|
}
|
||||||
@ -436,6 +434,7 @@ static void ColoursScreen_KeyDown(struct LScreen* s, Key key) {
|
|||||||
|
|
||||||
static void ColoursScreen_ResetAll(void* widget, int x, int y) {
|
static void ColoursScreen_ResetAll(void* widget, int x, int y) {
|
||||||
Launcher_ResetSkin();
|
Launcher_ResetSkin();
|
||||||
|
Launcher_SaveSkin();
|
||||||
ColoursScreen_UpdateAll(&ColoursScreen_Instance);
|
ColoursScreen_UpdateAll(&ColoursScreen_Instance);
|
||||||
Launcher_Redraw();
|
Launcher_Redraw();
|
||||||
}
|
}
|
||||||
@ -1021,6 +1020,7 @@ static void UpdatesScreen_Format(struct LLabel* lbl, const char* prefix, TimeMS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
LLabel_SetText(lbl, &str);
|
LLabel_SetText(lbl, &str);
|
||||||
|
LWidget_Redraw(lbl);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void UpdatesScreen_FormatBoth(struct UpdatesScreen* s) {
|
static void UpdatesScreen_FormatBoth(struct UpdatesScreen* s) {
|
||||||
|
@ -227,9 +227,7 @@ void Launcher_Run(void) {
|
|||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
Window_ProcessEvents();
|
Window_ProcessEvents();
|
||||||
if (!Window_Exists) break;
|
if (!Window_Exists || Launcher_ShouldExit) break;
|
||||||
if (Launcher_ShouldExit) break;
|
|
||||||
LWebTask_Tick(&CheckUpdateTask.Base);
|
|
||||||
|
|
||||||
Launcher_Screen->Tick(Launcher_Screen);
|
Launcher_Screen->Tick(Launcher_Screen);
|
||||||
if (Launcher_Dirty) Launcher_Display();
|
if (Launcher_Dirty) Launcher_Display();
|
||||||
@ -306,6 +304,7 @@ void Launcher_SaveSkin(void) {
|
|||||||
Launcher_SetCol("launcher-btn-fore-active-col", Launcher_ButtonForeActiveCol);
|
Launcher_SetCol("launcher-btn-fore-active-col", Launcher_ButtonForeActiveCol);
|
||||||
Launcher_SetCol("launcher-btn-fore-inactive-col", Launcher_ButtonForeCol);
|
Launcher_SetCol("launcher-btn-fore-inactive-col", Launcher_ButtonForeCol);
|
||||||
Launcher_SetCol("launcher-btn-highlight-inactive-col", Launcher_ButtonHighlightCol);
|
Launcher_SetCol("launcher-btn-highlight-inactive-col", Launcher_ButtonHighlightCol);
|
||||||
|
Launcher_SaveOptions = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -144,8 +144,8 @@ void GraphicsMode_MakeDefault(struct GraphicsMode* m) {
|
|||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*---------------------------------------------------------Memory----------------------------------------------------------*
|
*---------------------------------------------------------Memory----------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
void Mem_Set(void* dst, uint8_t value, uint32_t numBytes) { memset(dst, value, numBytes); }
|
void Mem_Set(void* dst, uint8_t value, uint32_t numBytes) { memset(dst, value, numBytes); }
|
||||||
void Mem_Copy(void* dst, void* src, uint32_t numBytes) { memcpy(dst, src, numBytes); }
|
void Mem_Copy(void* dst, const void* src, uint32_t numBytes) { memcpy(dst, src, numBytes); }
|
||||||
|
|
||||||
CC_NOINLINE static void Platform_AllocFailed(const char* place) {
|
CC_NOINLINE static void Platform_AllocFailed(const char* place) {
|
||||||
String log; char logBuffer[STRING_SIZE+20 + 1];
|
String log; char logBuffer[STRING_SIZE+20 + 1];
|
||||||
@ -475,7 +475,7 @@ ReturnCode File_Read(FileHandle file, uint8_t* buffer, uint32_t count, uint32_t*
|
|||||||
return Win_Return(success);
|
return Win_Return(success);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnCode File_Write(FileHandle file, uint8_t* buffer, uint32_t count, uint32_t* bytesWrote) {
|
ReturnCode File_Write(FileHandle file, const uint8_t* buffer, uint32_t count, uint32_t* bytesWrote) {
|
||||||
BOOL success = WriteFile(file, buffer, count, bytesWrote, NULL);
|
BOOL success = WriteFile(file, buffer, count, bytesWrote, NULL);
|
||||||
return Win_Return(success);
|
return Win_Return(success);
|
||||||
}
|
}
|
||||||
@ -601,7 +601,7 @@ ReturnCode File_Read(FileHandle file, uint8_t* buffer, uint32_t count, uint32_t*
|
|||||||
return Nix_Return(*bytesRead != -1);
|
return Nix_Return(*bytesRead != -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnCode File_Write(FileHandle file, uint8_t* buffer, uint32_t count, uint32_t* bytesWrote) {
|
ReturnCode File_Write(FileHandle file, const uint8_t* buffer, uint32_t count, uint32_t* bytesWrote) {
|
||||||
*bytesWrote = write(file, buffer, count);
|
*bytesWrote = write(file, buffer, count);
|
||||||
return Nix_Return(*bytesWrote != -1);
|
return Nix_Return(*bytesWrote != -1);
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ CC_EXPORT void Mem_Free(void* mem);
|
|||||||
/* Sets the contents of a block of memory to the given value. */
|
/* Sets the contents of a block of memory to the given value. */
|
||||||
void Mem_Set(void* dst, uint8_t value, uint32_t numBytes);
|
void Mem_Set(void* dst, uint8_t value, uint32_t numBytes);
|
||||||
/* Copies a block of memory to another block. NOTE: These blocks MUST NOT overlap. */
|
/* Copies a block of memory to another block. NOTE: These blocks MUST NOT overlap. */
|
||||||
void Mem_Copy(void* dst, void* src, uint32_t numBytes);
|
void Mem_Copy(void* dst, const void* src, uint32_t numBytes);
|
||||||
|
|
||||||
/* Logs a debug message to console. */
|
/* Logs a debug message to console. */
|
||||||
void Platform_Log(const String* message);
|
void Platform_Log(const String* message);
|
||||||
@ -131,7 +131,7 @@ ReturnCode File_Append(FileHandle* file, const String* path);
|
|||||||
/* Attempts to read data from the file. */
|
/* Attempts to read data from the file. */
|
||||||
ReturnCode File_Read(FileHandle file, uint8_t* buffer, uint32_t count, uint32_t* bytesRead);
|
ReturnCode File_Read(FileHandle file, uint8_t* buffer, uint32_t count, uint32_t* bytesRead);
|
||||||
/* Attempts to write data to the file. */
|
/* Attempts to write data to the file. */
|
||||||
ReturnCode File_Write(FileHandle file, uint8_t* buffer, uint32_t count, uint32_t* bytesWrote);
|
ReturnCode File_Write(FileHandle file, const uint8_t* buffer, uint32_t count, uint32_t* bytesWrote);
|
||||||
/* Attempts to close the given file. */
|
/* Attempts to close the given file. */
|
||||||
ReturnCode File_Close(FileHandle file);
|
ReturnCode File_Close(FileHandle file);
|
||||||
/* Attempts to seek to a position in the given file. */
|
/* Attempts to seek to a position in the given file. */
|
||||||
|
16
src/Stream.c
16
src/Stream.c
@ -21,7 +21,7 @@ ReturnCode Stream_Read(struct Stream* s, uint8_t* buffer, uint32_t count) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnCode Stream_Write(struct Stream* s, uint8_t* buffer, uint32_t count) {
|
ReturnCode Stream_Write(struct Stream* s, const uint8_t* buffer, uint32_t count) {
|
||||||
uint32_t write;
|
uint32_t write;
|
||||||
ReturnCode res;
|
ReturnCode res;
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ ReturnCode Stream_Write(struct Stream* s, uint8_t* buffer, uint32_t count) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ReturnCode Stream_DefaultIO(struct Stream* s, uint8_t* data, uint32_t count, uint32_t* modified) {
|
static ReturnCode Stream_DefaultIO(struct Stream* s, const uint8_t* data, uint32_t count, uint32_t* modified) {
|
||||||
*modified = 0; return ReturnCode_NotSupported;
|
*modified = 0; return ReturnCode_NotSupported;
|
||||||
}
|
}
|
||||||
ReturnCode Stream_DefaultReadU8(struct Stream* s, uint8_t* data) {
|
ReturnCode Stream_DefaultReadU8(struct Stream* s, uint8_t* data) {
|
||||||
@ -86,7 +86,7 @@ void Stream_Init(struct Stream* s) {
|
|||||||
static ReturnCode Stream_FileRead(struct Stream* s, uint8_t* data, uint32_t count, uint32_t* modified) {
|
static ReturnCode Stream_FileRead(struct Stream* s, uint8_t* data, uint32_t count, uint32_t* modified) {
|
||||||
return File_Read(s->Meta.File, data, count, modified);
|
return File_Read(s->Meta.File, data, count, modified);
|
||||||
}
|
}
|
||||||
static ReturnCode Stream_FileWrite(struct Stream* s, uint8_t* data, uint32_t count, uint32_t* modified) {
|
static ReturnCode Stream_FileWrite(struct Stream* s, const uint8_t* data, uint32_t count, uint32_t* modified) {
|
||||||
return File_Write(s->Meta.File, data, count, modified);
|
return File_Write(s->Meta.File, data, count, modified);
|
||||||
}
|
}
|
||||||
static ReturnCode Stream_FileClose(struct Stream* s) {
|
static ReturnCode Stream_FileClose(struct Stream* s) {
|
||||||
@ -213,7 +213,7 @@ static ReturnCode Stream_MemoryReadU8(struct Stream* s, uint8_t* data) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ReturnCode Stream_MemoryWrite(struct Stream* s, uint8_t* data, uint32_t count, uint32_t* modified) {
|
static ReturnCode Stream_MemoryWrite(struct Stream* s, const uint8_t* data, uint32_t count, uint32_t* modified) {
|
||||||
count = min(count, s->Meta.Mem.Left);
|
count = min(count, s->Meta.Mem.Left);
|
||||||
Mem_Copy(s->Meta.Mem.Cur, data, count);
|
Mem_Copy(s->Meta.Mem.Cur, data, count);
|
||||||
|
|
||||||
@ -352,21 +352,21 @@ void Stream_ReadonlyBuffered(struct Stream* s, struct Stream* source, void* data
|
|||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*-------------------------------------------------Read/Write primitives---------------------------------------------------*
|
*-------------------------------------------------Read/Write primitives---------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
uint16_t Stream_GetU16_LE(uint8_t* data) {
|
uint16_t Stream_GetU16_LE(const uint8_t* data) {
|
||||||
return (uint16_t)(data[0] | (data[1] << 8));
|
return (uint16_t)(data[0] | (data[1] << 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t Stream_GetU16_BE(uint8_t* data) {
|
uint16_t Stream_GetU16_BE(const uint8_t* data) {
|
||||||
return (uint16_t)((data[0] << 8) | data[1]);
|
return (uint16_t)((data[0] << 8) | data[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Stream_GetU32_LE(uint8_t* data) {
|
uint32_t Stream_GetU32_LE(const uint8_t* data) {
|
||||||
return (uint32_t)(
|
return (uint32_t)(
|
||||||
(uint32_t)data[0] | ((uint32_t)data[1] << 8) |
|
(uint32_t)data[0] | ((uint32_t)data[1] << 8) |
|
||||||
((uint32_t)data[2] << 16) | ((uint32_t)data[3] << 24));
|
((uint32_t)data[2] << 16) | ((uint32_t)data[3] << 24));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Stream_GetU32_BE(uint8_t* data) {
|
uint32_t Stream_GetU32_BE(const uint8_t* data) {
|
||||||
return (uint32_t)(
|
return (uint32_t)(
|
||||||
((uint32_t)data[0] << 24) | ((uint32_t)data[1] << 16) |
|
((uint32_t)data[0] << 24) | ((uint32_t)data[1] << 16) |
|
||||||
((uint32_t)data[2] << 8) | (uint32_t)data[3]);
|
((uint32_t)data[2] << 8) | (uint32_t)data[3]);
|
||||||
|
12
src/Stream.h
12
src/Stream.h
@ -15,7 +15,7 @@ struct Stream {
|
|||||||
/* Attempts to efficiently read a single byte from this stream. (fallbacks to Read) */
|
/* Attempts to efficiently read a single byte from this stream. (fallbacks to Read) */
|
||||||
ReturnCode (*ReadU8)(struct Stream* s, uint8_t* data);
|
ReturnCode (*ReadU8)(struct Stream* s, uint8_t* data);
|
||||||
/* Attempts to write some bytes to this stream. */
|
/* Attempts to write some bytes to this stream. */
|
||||||
ReturnCode (*Write)(struct Stream* s, uint8_t* data, uint32_t count, uint32_t* modified);
|
ReturnCode (*Write)(struct Stream* s, const uint8_t* data, uint32_t count, uint32_t* modified);
|
||||||
/* Attempts to quickly advance the position in this stream. (falls back to reading then discarding) */
|
/* Attempts to quickly advance the position in this stream. (falls back to reading then discarding) */
|
||||||
ReturnCode (*Skip)(struct Stream* s, uint32_t count);
|
ReturnCode (*Skip)(struct Stream* s, uint32_t count);
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ struct Stream {
|
|||||||
/* Attempts to fully read up to count bytes from the stream. */
|
/* Attempts to fully read up to count bytes from the stream. */
|
||||||
ReturnCode Stream_Read(struct Stream* s, uint8_t* buffer, uint32_t count);
|
ReturnCode Stream_Read(struct Stream* s, uint8_t* buffer, uint32_t count);
|
||||||
/* Attempts to fully write up to count bytes from the stream. */
|
/* Attempts to fully write up to count bytes from the stream. */
|
||||||
ReturnCode Stream_Write(struct Stream* s, uint8_t* buffer, uint32_t count);
|
ReturnCode Stream_Write(struct Stream* s, const uint8_t* buffer, uint32_t count);
|
||||||
/* Initalises default function pointers for a stream. (all read, write, seeks return an error) */
|
/* Initalises default function pointers for a stream. (all read, write, seeks return an error) */
|
||||||
void Stream_Init(struct Stream* s);
|
void Stream_Init(struct Stream* s);
|
||||||
/* Slow way of reading a U8 integer through stream->Read(stream, 1, tmp). */
|
/* Slow way of reading a U8 integer through stream->Read(stream, 1, tmp). */
|
||||||
@ -66,13 +66,13 @@ CC_EXPORT void Stream_WriteonlyMemory(struct Stream* s, void* data, uint32_t len
|
|||||||
CC_EXPORT void Stream_ReadonlyBuffered(struct Stream* s, struct Stream* source, void* data, uint32_t size);
|
CC_EXPORT void Stream_ReadonlyBuffered(struct Stream* s, struct Stream* source, void* data, uint32_t size);
|
||||||
|
|
||||||
/* Reads a little-endian 16 bit unsigned integer from memory. */
|
/* Reads a little-endian 16 bit unsigned integer from memory. */
|
||||||
uint16_t Stream_GetU16_LE(uint8_t* data);
|
uint16_t Stream_GetU16_LE(const uint8_t* data);
|
||||||
/* Reads a big-endian 16 bit unsigned integer from memory. */
|
/* Reads a big-endian 16 bit unsigned integer from memory. */
|
||||||
uint16_t Stream_GetU16_BE(uint8_t* data);
|
uint16_t Stream_GetU16_BE(const uint8_t* data);
|
||||||
/* Reads a little-endian 32 bit unsigned integer from memory. */
|
/* Reads a little-endian 32 bit unsigned integer from memory. */
|
||||||
uint32_t Stream_GetU32_LE(uint8_t* data);
|
uint32_t Stream_GetU32_LE(const uint8_t* data);
|
||||||
/* Reads a big-endian 32 bit unsigned integer from memory. */
|
/* Reads a big-endian 32 bit unsigned integer from memory. */
|
||||||
uint32_t Stream_GetU32_BE(uint8_t* data);
|
uint32_t Stream_GetU32_BE(const uint8_t* data);
|
||||||
|
|
||||||
/* Writes a big-endian 16 bit unsigned integer to memory. */
|
/* Writes a big-endian 16 bit unsigned integer to memory. */
|
||||||
void Stream_SetU16_BE(uint8_t* data, uint16_t value);
|
void Stream_SetU16_BE(uint8_t* data, uint16_t value);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user