Skip to content

Commit

Permalink
fix sdl message box not appearing
Browse files Browse the repository at this point in the history
  • Loading branch information
goblinhack committed May 26, 2024
1 parent 42700f1 commit 60bafcc
Show file tree
Hide file tree
Showing 11 changed files with 252 additions and 198 deletions.
10 changes: 0 additions & 10 deletions src/gfx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -845,15 +845,6 @@ static void gfx_ui_init_15(void)
}
}

static void gfx_init_rightbar(void)
{
const char *tiles[] = {
"ui_rightbar",
};

tile_load_arr_sprites("data/gfx/ui/ui_rightbar.tga", "rightbar", 104, 256, ARRAY_SIZE(tiles), tiles, GL_NEAREST);
}

static void gfx_init_ui(void) {}

void gfx_init(void)
Expand All @@ -863,7 +854,6 @@ void gfx_init(void)
// begin sort marker1 {
gfx_init_12x12();
gfx_init_24x24();
gfx_init_rightbar();
gfx_init_ui();
gfx_ui_init_0();
gfx_ui_init_1();
Expand Down
9 changes: 8 additions & 1 deletion src/level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@ Levelp level_new(void)
// NOTE: if we use "new" here, the initialization is visibly slower.
// DO NOT USE C++ classes or types
//
Levelp l = (Levelp) myzalloc(SIZEOF(*l), "l");
Levelp l;
LOG("Level memory: %u Mb", SIZEOF(Level) / (1024 * 1024));
LOG("Thing AI: %u Mb", SIZEOF(l->thing_ai) / (1024 * 1024));
LOG("Thing structs: %u Mb", SIZEOF(l->thing_body) / (1024 * 1024));
LOG("Thing IDs: %u Mb", SIZEOF(l->thing_id) / (1024 * 1024));
LOG("Thing size: %u b", SIZEOF(Thing));

l = (Levelp) myzalloc(SIZEOF(*l), "l");
if (! l) {
return nullptr;
}
Expand Down
128 changes: 96 additions & 32 deletions src/level_dungeon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,100 @@
void level_dungeon_create_and_place(Levelp l, int z)
{
level_map_set(l, z,
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
"x1..x...........x..............x"
"x...x=xx=x......x..xxxx==xxxx..x"
"x...x..x..x.....x..xxxx...xxx..x"
"x...x..xx..x....x..xxx.....=...x"
"x...=.xx....x...x...=......=...x"
"x...=..x.....x..x..xxx.....=...x"
"xxx.=.xxx.....x.x..xxxx...xxx..x"
"x...=...xxx.....x..xxxx==xxxx..x"
"x...=.xxx.......x..............x"
"x...=.......xxxxx...x.......x..x"
"x..xxxxx........x..x.x=====x...x"
"x......x........x...x.....x....x"
"xx...xxx........x........x.....x"
"x..............x........x......x"
"xxxx.xxx......x..x.....x.......x"
"x..x.x...........xx............x"
"x..x.x............x.x......x...x"
"x..x.x....xxx.......x..xxxxxxx.x"
"x.........x.x.....xxx....x.....x"
"x..xxx.x..xxx.....xx...........x"
"x...x..x...........x...x....x..x"
"x.........xxx...........x..x...x"
"x...x..xx.xxx......x...x.......x"
"x..xxx....xxx.xxxxxx....x...x..x"
"x...x...x..........x...x...x...x"
"x.......x..........x....x......x"
"x.......x..........x...........x"
"x.......x.........xxxxxxxxxxxxxx"
"x.......x......................x"
"x.......x.....................Ex"
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
"xx...............x............................................................................xx"
"xx...............x............................................................................xx"
"xx.....1.........x............................................................................xx"
"xx...............x............................................................................xx"
"xx.........xxxxxxx............................................................................xx"
"xxxxx......x.....=............................................................................xx"
"xx..x............=............................................................................xx"
"xx..x......x.....=............................................................................xx"
"xx..x......x.....=............................................................................xx"
"xx..xx====xx.xxxxx............................................................................xx"
"xx............................................................................................xx"
"xx.........x..................................................................................xx"
"xx..........x.................................................................................xx"
"xx...........x................................................................................xx"
"xx............x...............................................................................xx"
"xx.............x..............................................................................xx"
"xx..............x.............................................................................xx"
"xx...............x............................................................................xx"
"xx................x...........................................................................xx"
"xx.................x..........................................................................xx"
"xx..................x.........................................................................xx"
"xx...................x........................................................................xx"
"xx....................x.......................................................................xx"
"xx.....................x......................................................................xx"
"xx......................x.....................................................................xx"
"xx.......................x....................................................................xx"
"xx........................x...................................................................xx"
"xx.........................x..................................................................xx"
"xx..........................x.................................................................xx"
"xx...........................x................................................................xx"
"xx............................x...............................................................xx"
"xx.............................x..............................................................xx"
"xx..............................x.............................................................xx"
"xx...............................x............................................................xx"
"xx................................x...........................................................xx"
"xx.................................x..........................................................xx"
"xx..................................x.........................................................xx"
"xx...................................x........................................................xx"
"xx....................................x.......................................................xx"
"xx.....................................x......................................................xx"
"xx......................................x.....................................................xx"
"xx.......................................x....................................................xx"
"xx........................................x...................................................xx"
"xx.........................................x..................................................xx"
"xx..........................................x.................................................xx"
"xx...........................................x................................................xx"
"xx............................................x...............................................xx"
"xx.............................................x..............................................xx"
"xx..............................................x.............................................xx"
"xx...............................................x............................................xx"
"xx................................................x...........................................xx"
"xx.................................................x..........................................xx"
"xx..................................................x.........................................xx"
"xx...................................................x........................................xx"
"xx....................................................x.......................................xx"
"xx.....................................................x......................................xx"
"xx......................................................x.....................................xx"
"xx.......................................................x....................................xx"
"xx........................................................x...................................xx"
"xx.........................................................x..................................xx"
"xx..........................................................x.................................xx"
"xx...........................................................x................................xx"
"xx............................................................x...............................xx"
"xx.............................................................x..............................xx"
"xx..............................................................x.............................xx"
"xx...............................................................x............................xx"
"xx................................................................x...........................xx"
"xx.................................................................x..........................xx"
"xx..................................................................x.........................xx"
"xx...................................................................x........................xx"
"xx....................................................................x.......................xx"
"xx.....................................................................x......................xx"
"xx......................................................................x.....................xx"
"xx.......................................................................x....................xx"
"xx........................................................................x...................xx"
"xx.........................................................................x..................xx"
"xx..........................................................................x.................xx"
"xx...........................................................................x................xx"
"xx............................................................................x...............xx"
"xx.............................................................................x..............xx"
"xx..............................................................................x.............xx"
"xx...............................................................................x............xx"
"xx................................................................................x...........xx"
"xx.................................................................................x..........xx"
"xx..................................................................................x.........xx"
"xx...................................................................................x........xx"
"xx....................................................................................x.......xx"
"xx.....................................................................................x......xx"
"xx......................................................................................x.....xx"
"xx.......................................................................................x....xx"
"xx............................................................................................xx"
"xx...........................................................................................Exx"
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
}
7 changes: 6 additions & 1 deletion src/log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include "my_callstack.hpp"
#include "my_console.hpp"
#include "my_log.hpp"
#include "my_sdl_event.hpp"
#include "my_sdl_proto.hpp"
#include "my_string.hpp"
#include "my_wid_console.hpp"

Expand Down Expand Up @@ -466,7 +468,10 @@ static void sdl_msgerr_(const char *fmt, va_list args)

#if SDL_MAJOR_VERSION >= 2
CON("INF: Show SDL message box");
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "gorget", buf, nullptr);
//
// The window is needed else the box appears behind the main window.
//
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "gorget", buf, sdl.window);
CON("INF: Finished SDL message box");
#endif
}
Expand Down
4 changes: 2 additions & 2 deletions src/my_ascii.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#include "my_tile.hpp"
#include "my_ui.hpp"

#define TERM_GFX_WIDTH_DEF 80
#define TERM_GFX_HEIGHT_DEF 40
#define TERM_GFX_WIDTH_DEF 120
#define TERM_GFX_HEIGHT_DEF 80

#define TERM_WIDTH_MAX (TERM_GFX_WIDTH_DEF * 2)
#define TERM_HEIGHT_MAX (TERM_GFX_HEIGHT_DEF * 2)
Expand Down
6 changes: 3 additions & 3 deletions src/my_game_defs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
#ifndef _MY_GAME_DEFS_HPP_
#define _MY_GAME_DEFS_HPP_

#define MAP_WIDTH 32
#define MAP_HEIGHT 32
#define MAP_DEPTH 32
#define MAP_WIDTH 96
#define MAP_HEIGHT 96
#define MAP_DEPTH 16
#define MAP_SLOTS 16
#define MAP_SCROLL_BORDER 0.4
#define MAP_SCROLL_SPEED 5
Expand Down
2 changes: 1 addition & 1 deletion src/my_thing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
// Essentially equates to the max number of monsters
//
#define THING_AI_MAX 65535 /* sizeof ai_id */
#define THING_MOVE_PATH_MAX (MAP_WIDTH * MAP_HEIGHT)
#define THING_MOVE_PATH_MAX MAP_WIDTH

typedef struct ThingAi_ {
//
Expand Down
10 changes: 3 additions & 7 deletions src/sdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -696,11 +696,7 @@ void config_game_gfx_update(void)
game_pix_height_set(game, game_window_pix_height_get(game));
game_pix_width_set(game, game_window_pix_width_get(game));

if (1) {
game_pix_height_set(game, TILE_WIDTH * 20);
} else {
game_pix_height_set(game, TILE_WIDTH * MAP_HEIGHT);
}
game_pix_height_set(game, TILE_WIDTH * MAP_HEIGHT / 4);
float game_pix_width = (int) (((double) game_pix_height_get(game)) * game_aspect_ratio_get(game));
game_pix_width /= TILE_WIDTH;
game_pix_width = ceil(game_pix_width);
Expand All @@ -719,8 +715,8 @@ void config_game_gfx_update(void)
//
// Use the same resolution as the game
//
game_ui_pix_width_set(game, game_pix_width_get(game));
game_ui_pix_height_set(game, game_pix_height_get(game));
game_ui_pix_width_set(game, game_pix_width_get(game) * 2);
game_ui_pix_height_set(game, game_pix_height_get(game) * 2);

if (! TILE_WIDTH) {
ERR("TILE_WIDTH zero");
Expand Down
8 changes: 4 additions & 4 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void *myzalloc_(int size, const char *what, const char *file, const char *func,
void *ptr = calloc(1, size);

if (! ptr) {
DIE("No memory, %s:%s():%u", file, func, line);
DIE("No memory, %s:%s:%u, size %u", file, func, line, size);
}

IF_DEBUG2 { ptrcheck_alloc(MTYPE_MISC, ptr, what, size, file, func, line); }
Expand All @@ -28,7 +28,7 @@ void *mymalloc_(int size, const char *what, const char *file, const char *func,
void *ptr = malloc(size);

if (! ptr) {
DIE("No memory, %s:%s():%u", file, func, line);
DIE("No memory, %s:%s:%u", file, func, line);
}

IF_DEBUG2 { ptrcheck_alloc(MTYPE_MISC, ptr, what, size, file, func, line); }
Expand All @@ -43,7 +43,7 @@ void *myrealloc_(void *ptr, int size, const char *what, const char *file, const

ptr = realloc(ptr, size);
if (! ptr) {
DIE("No memory, %s:%s():%u", file, func, line);
DIE("No memory, %s:%s:%u", file, func, line);
}

IF_DEBUG2 { ptrcheck_alloc(MTYPE_MISC, ptr, what, size, file, func, line); }
Expand All @@ -69,7 +69,7 @@ char *dupstr_(const char *in, const char *what, const char *file, const char *fu

char *ptr = strdup(in);
if (! ptr) {
DIE("No memory, %s:%s():%u", file, func, line);
DIE("No memory, %s:%s:%u", file, func, line);
}

int size = (__typeof__(size)) strlen(in);
Expand Down
Loading

0 comments on commit 60bafcc

Please sign in to comment.