Skip to content

Commit 605ff23

Browse files
authored
Merge pull request #200 from cortex-command-community/misc-gui-fixes
Misc gui fixes
2 parents 3469103 + b89c056 commit 605ff23

File tree

6 files changed

+26
-36
lines changed

6 files changed

+26
-36
lines changed

Source/Main.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -411,12 +411,9 @@ int main(int argc, char** argv) {
411411

412412
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS | SDL_INIT_GAMEPAD );
413413

414-
#if SDL_MINOR_VERSION > 22
415414
SDL_SetHint(SDL_HINT_MOUSE_AUTO_CAPTURE, "0");
416-
#endif
417-
418-
SDL_HideCursor();
419415
SDL_SetHint("SDL_ALLOW_TOPMOST", "0");
416+
SDL_HideCursor();
420417

421418
if (std::filesystem::exists("Base.rte/gamecontrollerdb.txt")) {
422419
SDL_AddGamepadMappingsFromFile("Base.rte/gamecontrollerdb.txt");

Source/Managers/GLResourceMan.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,5 +154,7 @@ GLuint GLResourceMan::UpdateDynamicBitmap(BITMAP* bitmap, bool updated, const st
154154

155155
void GLResourceMan::DestroyBitmapInfo(BITMAP* bitmap) {
156156
GLBitmapInfo* info = GetBitmapInfo(bitmap);
157-
rlUnloadTexture(info->m_Texture);
158-
}
157+
if (info) {
158+
rlUnloadTexture(info->m_Texture);
159+
}
160+
}

Source/Managers/WindowMan.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ void WindowMan::Initialize() {
133133
ImGui::CreateContext();
134134
ImGuiIO& io = ImGui::GetIO();
135135
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad;
136-
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad;
136+
io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange;
137137

138138
ImGui::StyleColorsDark();
139139
ImGui_ImplSDL3_InitForOpenGL(m_PrimaryWindow.get(), m_GLContext.get());

Source/Menus/LoadingScreen.cpp

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,19 +76,11 @@ void LoadingScreen::CreateLoadingSplash(int xOffset) {
7676
m_LoadingBackground->Create(ContentFile("Base.rte/GUIs/Title/LoadingSplash.png").GetAsBitmap(COLORCONV_NONE, false), false, Vector(), true, false, Vector(1.0F, 0));
7777
m_LoadingBackground->SetOffset(Vector(static_cast<float>(((m_LoadingBackground->GetBitmap()->w - g_WindowMan.GetResX()) / 2) + xOffset), 0));
7878

79-
Box loadingSplashTargetBox(Vector(0, static_cast<float>((g_WindowMan.GetResY() - m_LoadingBackground->GetBitmap()->h) / 2)), static_cast<float>(g_WindowMan.GetResX()), static_cast<float>(m_LoadingBackground->GetBitmap()->h));
80-
RenderTarget defaultTarget{
81-
FloatRect(0, 0, g_WindowMan.GetResX(), g_WindowMan.GetResY()),
82-
FloatRect(0, 0, g_WindowMan.GetResX(), g_WindowMan.GetResY()),
83-
0,
84-
Texture2D(),
85-
true
86-
};
87-
defaultTarget.Begin();
88-
g_WindowMan.ClearBackbuffer();
79+
Box loadingSplashTargetBox(Vector(0, static_cast<float>((g_WindowMan.GetResY() - g_LoadingScreen.m_LoadingBackground->GetBitmap()->h) / 2)), static_cast<float>(g_WindowMan.GetResX()), static_cast<float>(g_LoadingScreen.m_LoadingBackground->GetBitmap()->h));
80+
g_WindowMan.ClearBackbuffer(false);
81+
g_WindowMan.GetScreenBuffer()->Begin();
8982
m_LoadingBackground->Draw(loadingSplashTargetBox, loadingSplashTargetBox);
90-
rlDrawRenderBatchActive();
91-
g_WindowMan.Present();
83+
g_WindowMan.UploadFrame();
9284
}
9385

9486
void LoadingScreen::CreateProgressReportListbox(GUIControlManager* parentControlManager) {
@@ -152,6 +144,7 @@ void LoadingScreen::LoadingSplashProgressReport(const std::string& reportString,
152144
blit(g_LoadingScreen.m_ProgressListboxBitmap, g_FrameMan.GetBackBuffer32(), 0, 0, g_LoadingScreen.m_ProgressListboxPosX, g_LoadingScreen.m_ProgressListboxPosY, g_LoadingScreen.m_ProgressListboxBitmap->w, g_LoadingScreen.m_ProgressListboxBitmap->h);
153145

154146
Box loadingSplashTargetBox(Vector(0, static_cast<float>((g_WindowMan.GetResY() - g_LoadingScreen.m_LoadingBackground->GetBitmap()->h) / 2)), static_cast<float>(g_WindowMan.GetResX()), static_cast<float>(g_LoadingScreen.m_LoadingBackground->GetBitmap()->h));
147+
155148
g_WindowMan.ClearBackbuffer(false);
156149
g_WindowMan.GetScreenBuffer()->Begin();
157150
g_LoadingScreen.m_LoadingBackground->Draw(loadingSplashTargetBox, loadingSplashTargetBox);

Source/Renderer/raylib/rlutils.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
//----------------------------------------------------------------------------------
6060
// Global Variables Definition
6161
//----------------------------------------------------------------------------------
62-
static int logTypeLevel = LOG_INFO; // Minimum log type level
62+
static int logTypeLevel = LOG_ERROR; // Minimum log type level
6363

6464
static TraceLogCallback traceLog = NULL; // TraceLog callback function pointer
6565
static LoadFileDataCallback loadFileData = NULL; // LoadFileData callback function pointer
@@ -509,4 +509,4 @@ static int android_close(void *cookie)
509509
}
510510
#endif // PLATFORM_ANDROID
511511

512-
#endif
512+
#endif

Source/System/ContentFile.cpp

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -258,19 +258,18 @@ void ContentFile::GetAsAnimation(std::vector<BITMAP*>& vectorToFill, int frameCo
258258
}
259259
}
260260
SDL_Palette* ContentFile::DefaultPaletteToSDL() {
261-
SDL_Palette* palette = SDL_CreatePalette(256);
262-
std::array<SDL_Color, 256> paletteColor;
263-
PALETTE currentPalette;
264-
get_palette(currentPalette);
265-
paletteColor[0] = {.r = 0, .g = 0, .b = 0, .a = 0};
266-
for (size_t i = 1; i < paletteColor.size(); ++i) {
267-
paletteColor[i].r = currentPalette[i].r;
268-
paletteColor[i].g = currentPalette[i].g;
269-
paletteColor[i].b = currentPalette[i].b;
270-
paletteColor[i].a = 255;
271-
}
272-
SDL_SetPaletteColors(palette, paletteColor.data(), 0, 256);
273-
return palette;
261+
SDL_Palette* palette = SDL_CreatePalette(256);
262+
std::array<SDL_Color, 256> paletteColor;
263+
const PALETTE& defaultPalette = g_FrameMan.GetDefaultPalette();
264+
paletteColor[0] = {.r = 0, .g = 0, .b = 0, .a = 0};
265+
for (size_t i = 1; i < paletteColor.size(); ++i) {
266+
paletteColor[i].r = defaultPalette[i].r;
267+
paletteColor[i].g = defaultPalette[i].g;
268+
paletteColor[i].b = defaultPalette[i].b;
269+
paletteColor[i].a = 255;
270+
}
271+
SDL_SetPaletteColors(palette, paletteColor.data(), 0, 256);
272+
return palette;
274273
}
275274

276275
SDL_Surface* ContentFile::LoadImageAsSurface(int conversionMode, const std::string& dataPathToLoad) {
@@ -286,7 +285,6 @@ SDL_Surface* ContentFile::LoadImageAsSurface(int conversionMode, const std::stri
286285
image = newImage;
287286
bitDepth = 8;
288287
} else if (bitDepth != 8 || convert8To32) {
289-
290288
SDL_Palette* palette = DefaultPaletteToSDL();
291289
if (SDL_GetPixelFormatDetails(image->format)->bits_per_pixel == 8) {
292290
SDL_SetSurfacePalette(image, palette);
@@ -312,7 +310,7 @@ BITMAP* ContentFile::LoadAndReleaseBitmap(int conversionMode, const std::string&
312310
int bitDepth = SDL_GetPixelFormatDetails(image->format)->bits_per_pixel;
313311

314312
BITMAP* returnBitmap = create_bitmap_ex(bitDepth, image->w, image->h);
315-
313+
316314
// allegro doesn't (always) align lines to 4byte, so copy line by line. SDL_Surface.pitch is the size in bytes per line + alignment padding.
317315
for (int y = 0; y < image->h; ++y) {
318316
memcpy(returnBitmap->line[y], static_cast<unsigned char*>(image->pixels) + image->pitch * y, image->w * SDL_GetPixelFormatDetails(image->format)->bytes_per_pixel);

0 commit comments

Comments
 (0)