1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-22 17:49:43 +01:00

Use levelDirError for graphics errors too

This will actually do several things:

(1) Make the tile size checks apply to the appropriate graphics files
    once again.
(2) Make the game print a fallback error message if the error message
    hasn't been set on the levelDirError error screen.
(3) Use levelDirError for graphics errors too.
(4) Make the error message for tile size checks failing specify both
    width and height, not just a square dimension.
(5) Make the error messages mentioned above translatable.

It turns out that (1) didn't happen after #923 was merged, since #923
removed needing to process a tilesheet into a vector of surfaces for all
graphics files except sprites.png and flipsprites.png. Thus, the game
ended up only checking the correct tile sizes for those files only.

In the process of fixing this, I also got rid of the PROCESS_TILESHEET
macros and turned them into two different functions: One to make the
array, and one to check the tile size of the tilesheet.

I also did (2) just in case FILESYSTEM_levelDirHasError() returns false
even though we know we have an error.

And (3) is needed so things are unified and we have one user-facing
error message system when users load levels. To facilitate this, I
removed the title string, since it's really not needed.

Unfortunately, (1) doesn't apply to font.png again, but that's because
of the new font stuff and I'm not sure what Dav999 has in store for
error checking. But that's also why I did (4), because it looks like
tile sizes in font.png files can be different (i.e. non-square).
This commit is contained in:
Misa 2023-05-17 17:00:33 -07:00
parent 68199396bd
commit 474cdc092e
17 changed files with 118 additions and 80 deletions

View file

@ -758,9 +758,11 @@ Has trobat el laboratori secret!" explanation="" max="34*4"/>
<string english="Last 1 minute on the Super Gravitron" translation="Aguanta 1 minut al supergravitró" explanation="achievement/trophy description" max="38*2"/>
<string english="MASTER OF THE UNIVERSE" translation="MÀSTER DE LUNIVERS" explanation="achievement/trophy title - no death mode complete" max="38*2"/>
<string english="Complete the game in no death mode" translation="Passat el joc en el mode|sense cap mort" explanation="achievement/trophy description" max="38*2"/>
<string english="Something went wrong, but we forgot to print an error message." translation="" explanation="the message that is printed in case the game detects an error but there&apos;s no error message set" max="38*6"/>
<string english="Could not mount {path}: real directory doesn&apos;t exist" translation="No sha pogut muntar {path}: el directori real no existeix" explanation="mount: link/attach a directory (folder) in the filesystem into the game&apos;s filesystem so we can access it" max="38*6"/>
<string english="Level {path} not found" translation="" explanation="" max="38*6"/>
<string english="Error parsing {path}: {error}" translation="" explanation="we tried to parse the level file, but failed" max="38*6"/>
<string english="{filename} dimensions not exact multiples of {width} by {height}!" translation="" explanation="filename is something like tiles.png, tiles2.png, etc. and width/height are something like 8, 32, etc.; this is used if the dimensions of a graphics file aren&apos;t an exact multiple of the given size (e.g. 8x8, 32x32, etc.)" max="38*6"/>
<string english="ERROR: Could not write to language folder! Make sure there is no &quot;lang&quot; folder next to the regular saves." translation="ERROR: No sha pogut escriure|a la carpeta de llengua! Assegurat|que no hi hagi cap carpeta «lang»|al costat de les partides desades normals." explanation="" max="38*5"/>
<string english="" translation="" explanation=""/>
<string english="" translation="" explanation=""/>

View file

@ -758,9 +758,11 @@ Du hast das Geheimlabor gefunden!" explanation="" max="34*4"/>
<string english="Last 1 minute on the Super Gravitron" translation="Überstehe 1 Minute im Super Gravitron" explanation="achievement/trophy description" max="38*2"/>
<string english="MASTER OF THE UNIVERSE" translation="HERRSCHER DES UNIVERSUMS" explanation="achievement/trophy title - no death mode complete" max="38*2"/>
<string english="Complete the game in no death mode" translation="Beende das Spiel im Keine-Tode-Modus" explanation="achievement/trophy description" max="38*2"/>
<string english="Something went wrong, but we forgot to print an error message." translation="" explanation="the message that is printed in case the game detects an error but there&apos;s no error message set" max="38*6"/>
<string english="Could not mount {path}: real directory doesn&apos;t exist" translation="Konnte {Pfad} nicht mounten: echtes Verzeichnis existiert nicht" explanation="mount: link/attach a directory (folder) in the filesystem into the game&apos;s filesystem so we can access it" max="38*6"/>
<string english="Level {path} not found" translation="" explanation="" max="38*6"/>
<string english="Error parsing {path}: {error}" translation="" explanation="we tried to parse the level file, but failed" max="38*6"/>
<string english="{filename} dimensions not exact multiples of {width} by {height}!" translation="" explanation="filename is something like tiles.png, tiles2.png, etc. and width/height are something like 8, 32, etc.; this is used if the dimensions of a graphics file aren&apos;t an exact multiple of the given size (e.g. 8x8, 32x32, etc.)" max="38*6"/>
<string english="ERROR: Could not write to language folder! Make sure there is no &quot;lang&quot; folder next to the regular saves." translation="FEHLER: Konnte nicht in den Sprachordner schreiben! Stelle sicher, dass es keinen &quot;lang&quot;-Ordner neben den regulären Spielständen gibt." explanation="" max="38*5"/>
<string english="" translation="" explanation=""/>
<string english="" translation="" explanation=""/>

View file

@ -752,9 +752,11 @@ You have found the secret lab!" translation="" explanation="" max="34*4"/>
<string english="Last 1 minute on the Super Gravitron" translation="" explanation="achievement/trophy description" max="38*2"/>
<string english="MASTER OF THE UNIVERSE" translation="" explanation="achievement/trophy title - no death mode complete" max="38*2"/>
<string english="Complete the game in no death mode" translation="" explanation="achievement/trophy description" max="38*2"/>
<string english="Something went wrong, but we forgot to print an error message." translation="" explanation="the message that is printed in case the game detects an error but there&apos;s no error message set" max="38*6"/>
<string english="Could not mount {path}: real directory doesn&apos;t exist" translation="" explanation="mount: link/attach a directory (folder) in the filesystem into the game&apos;s filesystem so we can access it" max="38*6"/>
<string english="Level {path} not found" translation="" explanation="" max="38*6"/>
<string english="Error parsing {path}: {error}" translation="" explanation="we tried to parse the level file, but failed" max="38*6"/>
<string english="{filename} dimensions not exact multiples of {width} by {height}!" translation="" explanation="filename is something like tiles.png, tiles2.png, etc. and width/height are something like 8, 32, etc.; this is used if the dimensions of a graphics file aren&apos;t an exact multiple of the given size (e.g. 8x8, 32x32, etc.)" max="38*6"/>
<string english="ERROR: Could not write to language folder! Make sure there is no &quot;lang&quot; folder next to the regular saves." translation="" explanation="" max="38*5"/>
<string english="" translation="" explanation=""/>
<string english="" translation="" explanation=""/>

View file

@ -758,9 +758,11 @@ Vi trovis la sekretan labon!" explanation="" max="34*4"/>
<string english="Last 1 minute on the Super Gravitron" translation="Travivi 1 minuton en la Supergravitrono" explanation="achievement/trophy description" max="38*2"/>
<string english="MASTER OF THE UNIVERSE" translation="MAJSTRO DE L&apos; UNIVERSO" explanation="achievement/trophy title - no death mode complete" max="38*2"/>
<string english="Complete the game in no death mode" translation="Kompletigi la ludon en mortula reĝimo" explanation="achievement/trophy description" max="38*2"/>
<string english="Something went wrong, but we forgot to print an error message." translation="" explanation="the message that is printed in case the game detects an error but there&apos;s no error message set" max="38*6"/>
<string english="Could not mount {path}: real directory doesn&apos;t exist" translation="Ne eblis munti {path}: vera dosierujo ne ekzistas" explanation="mount: link/attach a directory (folder) in the filesystem into the game&apos;s filesystem so we can access it" max="38*6"/>
<string english="Level {path} not found" translation="" explanation="" max="38*6"/>
<string english="Error parsing {path}: {error}" translation="" explanation="we tried to parse the level file, but failed" max="38*6"/>
<string english="{filename} dimensions not exact multiples of {width} by {height}!" translation="" explanation="filename is something like tiles.png, tiles2.png, etc. and width/height are something like 8, 32, etc.; this is used if the dimensions of a graphics file aren&apos;t an exact multiple of the given size (e.g. 8x8, 32x32, etc.)" max="38*6"/>
<string english="ERROR: Could not write to language folder! Make sure there is no &quot;lang&quot; folder next to the regular saves." translation="ERARO: Ne eblis skribi en lingvo-dosierujo! Certigu, ke ne estas dosierujo &quot;lang&quot; apud la normalaj konservaĵoj." explanation="" max="38*5"/>
<string english="" translation="" explanation=""/>
<string english="" translation="" explanation=""/>

View file

@ -758,9 +758,11 @@ You have found the secret lab!" translation="¡Enhorabuena!
<string english="Last 1 minute on the Super Gravitron" translation="Aguanta 1 minuto en el Supergravitrón" explanation="achievement/trophy description" max="38*2"/>
<string english="MASTER OF THE UNIVERSE" translation="LÍDER DEL UNIVERSO" explanation="achievement/trophy title - no death mode complete" max="38*2"/>
<string english="Complete the game in no death mode" translation="Completa el juego en el modo sin muerte" explanation="achievement/trophy description" max="38*2"/>
<string english="Something went wrong, but we forgot to print an error message." translation="" explanation="the message that is printed in case the game detects an error but there&apos;s no error message set" max="38*6"/>
<string english="Could not mount {path}: real directory doesn&apos;t exist" translation="No se ha podido seguir {path}: El directorio real no existe" explanation="mount: link/attach a directory (folder) in the filesystem into the game&apos;s filesystem so we can access it" max="38*6"/>
<string english="Level {path} not found" translation="" explanation="" max="38*6"/>
<string english="Error parsing {path}: {error}" translation="" explanation="we tried to parse the level file, but failed" max="38*6"/>
<string english="{filename} dimensions not exact multiples of {width} by {height}!" translation="" explanation="filename is something like tiles.png, tiles2.png, etc. and width/height are something like 8, 32, etc.; this is used if the dimensions of a graphics file aren&apos;t an exact multiple of the given size (e.g. 8x8, 32x32, etc.)" max="38*6"/>
<string english="ERROR: Could not write to language folder! Make sure there is no &quot;lang&quot; folder next to the regular saves." translation="ERROR: No se ha podido escribir en la carpeta de idioma. Comprueba que no haya una carpeta &quot;lang&quot; junto a los guardados normales." explanation="" max="38*5"/>
<string english="" translation="" explanation=""/>
<string english="" translation="" explanation=""/>

View file

@ -752,9 +752,11 @@ You have found the secret lab!" translation="Félicitations ! Vous avez trouvé
<string english="Last 1 minute on the Super Gravitron" translation="Tenir 1 minute dans le Super Gravitron" explanation="achievement/trophy description" max="38*2"/>
<string english="MASTER OF THE UNIVERSE" translation="MAÎTRE DE L&apos;UNIVERS" explanation="achievement/trophy title - no death mode complete" max="38*2"/>
<string english="Complete the game in no death mode" translation="Terminer le jeu en mode sans mort" explanation="achievement/trophy description" max="38*2"/>
<string english="Something went wrong, but we forgot to print an error message." translation="" explanation="the message that is printed in case the game detects an error but there&apos;s no error message set" max="38*6"/>
<string english="Could not mount {path}: real directory doesn&apos;t exist" translation="Impossible de monter {path} : le véritable dossier n&apos;existe pas" explanation="mount: link/attach a directory (folder) in the filesystem into the game&apos;s filesystem so we can access it" max="38*6"/>
<string english="Level {path} not found" translation="" explanation="" max="38*6"/>
<string english="Error parsing {path}: {error}" translation="" explanation="we tried to parse the level file, but failed" max="38*6"/>
<string english="{filename} dimensions not exact multiples of {width} by {height}!" translation="" explanation="filename is something like tiles.png, tiles2.png, etc. and width/height are something like 8, 32, etc.; this is used if the dimensions of a graphics file aren&apos;t an exact multiple of the given size (e.g. 8x8, 32x32, etc.)" max="38*6"/>
<string english="ERROR: Could not write to language folder! Make sure there is no &quot;lang&quot; folder next to the regular saves." translation="ERREUR : impossible d&apos;écrire dans le dossier de langue ! Assurez-vous qu&apos;il n&apos;y ait pas de dossier « lang » à côté des sauvegardes standard." explanation="" max="38*5"/>
<string english="" translation="" explanation=""/>
<string english="" translation="" explanation=""/>

View file

@ -758,9 +758,11 @@ Hai trovato il laboratorio segreto!" explanation="" max="34*4"/>
<string english="Last 1 minute on the Super Gravitron" translation="Resisti 1 minuto sul Super Gravitrone" explanation="achievement/trophy description" max="38*2"/>
<string english="MASTER OF THE UNIVERSE" translation="DOMINATORE DELL&apos;UNIVERSO" explanation="achievement/trophy title - no death mode complete" max="38*2"/>
<string english="Complete the game in no death mode" translation="Completa il gioco in modalità Una vita" explanation="achievement/trophy description" max="38*2"/>
<string english="Something went wrong, but we forgot to print an error message." translation="" explanation="the message that is printed in case the game detects an error but there&apos;s no error message set" max="38*6"/>
<string english="Could not mount {path}: real directory doesn&apos;t exist" translation="Impossibile installare {path}: la directory reale non esiste" explanation="mount: link/attach a directory (folder) in the filesystem into the game&apos;s filesystem so we can access it" max="38*6"/>
<string english="Level {path} not found" translation="" explanation="" max="38*6"/>
<string english="Error parsing {path}: {error}" translation="" explanation="we tried to parse the level file, but failed" max="38*6"/>
<string english="{filename} dimensions not exact multiples of {width} by {height}!" translation="" explanation="filename is something like tiles.png, tiles2.png, etc. and width/height are something like 8, 32, etc.; this is used if the dimensions of a graphics file aren&apos;t an exact multiple of the given size (e.g. 8x8, 32x32, etc.)" max="38*6"/>
<string english="ERROR: Could not write to language folder! Make sure there is no &quot;lang&quot; folder next to the regular saves." translation="ERRORE: impossibile scrivere sulla cartella lingua! Assicurati che non ci sia una cartella &quot;lang&quot; insieme ai normali salvataggi." explanation="" max="38*5"/>
<string english="" translation="" explanation=""/>
<string english="" translation="" explanation=""/>

View file

@ -759,9 +759,11 @@ Je hebt het geheime lab gevonden!" explanation="" max="34*4"/>
<string english="Last 1 minute on the Super Gravitron" translation="Hou het 1 minuut vol in de Supergravitron" explanation="achievement/trophy description" max="38*2"/>
<string english="MASTER OF THE UNIVERSE" translation="MEESTER VAN HET UNIVERSUM" explanation="achievement/trophy title - no death mode complete" max="38*2"/>
<string english="Complete the game in no death mode" translation="Voltooi het spel in de éénlevenmodus" explanation="achievement/trophy description" max="38*2"/>
<string english="Something went wrong, but we forgot to print an error message." translation="" explanation="the message that is printed in case the game detects an error but there&apos;s no error message set" max="38*6"/>
<string english="Could not mount {path}: real directory doesn&apos;t exist" translation="Kon {path} niet aankoppelen: echte map bestaat niet" explanation="mount: link/attach a directory (folder) in the filesystem into the game&apos;s filesystem so we can access it" max="38*6"/>
<string english="Level {path} not found" translation="" explanation="" max="38*6"/>
<string english="Error parsing {path}: {error}" translation="" explanation="we tried to parse the level file, but failed" max="38*6"/>
<string english="{filename} dimensions not exact multiples of {width} by {height}!" translation="" explanation="filename is something like tiles.png, tiles2.png, etc. and width/height are something like 8, 32, etc.; this is used if the dimensions of a graphics file aren&apos;t an exact multiple of the given size (e.g. 8x8, 32x32, etc.)" max="38*6"/>
<string english="ERROR: Could not write to language folder! Make sure there is no &quot;lang&quot; folder next to the regular saves." translation="ERROR: Kan niet schrijven naar talenmap! Zorg dat er geen &quot;lang&quot;-map naast de normale opgeslagen bestanden staat." explanation="" max="38*5"/>
<string english="" translation="" explanation=""/>
<string english="" translation="" explanation=""/>

View file

@ -758,9 +758,11 @@ Você encontrou o laboratório secreto!" explanation="" max="34*4"/>
<string english="Last 1 minute on the Super Gravitron" translation="Último 1 minuto no Super Gravitron" explanation="achievement/trophy description" max="38*2"/>
<string english="MASTER OF THE UNIVERSE" translation="MESTRE DO UNIVERSO" explanation="achievement/trophy title - no death mode complete" max="38*2"/>
<string english="Complete the game in no death mode" translation="Complete o jogo no modo sem mortes" explanation="achievement/trophy description" max="38*2"/>
<string english="Something went wrong, but we forgot to print an error message." translation="" explanation="the message that is printed in case the game detects an error but there&apos;s no error message set" max="38*6"/>
<string english="Could not mount {path}: real directory doesn&apos;t exist" translation="Não foi possível montar {path}: o diretório real não existe" explanation="mount: link/attach a directory (folder) in the filesystem into the game&apos;s filesystem so we can access it" max="38*6"/>
<string english="Level {path} not found" translation="" explanation="" max="38*6"/>
<string english="Error parsing {path}: {error}" translation="" explanation="we tried to parse the level file, but failed" max="38*6"/>
<string english="{filename} dimensions not exact multiples of {width} by {height}!" translation="" explanation="filename is something like tiles.png, tiles2.png, etc. and width/height are something like 8, 32, etc.; this is used if the dimensions of a graphics file aren&apos;t an exact multiple of the given size (e.g. 8x8, 32x32, etc.)" max="38*6"/>
<string english="ERROR: Could not write to language folder! Make sure there is no &quot;lang&quot; folder next to the regular saves." translation="ERRO: não foi possível gravar na pasta do idioma! Não pode ter &quot;lang&quot; ao lado dos salvamentos comuns." explanation="" max="38*5"/>
<string english="" translation="" explanation=""/>
<string english="" translation="" explanation=""/>

View file

@ -758,9 +758,11 @@ Encontraste o laboratório secreto!" explanation="" max="34*4"/>
<string english="Last 1 minute on the Super Gravitron" translation="Resiste durante 1 minuto em Supergravitrão." explanation="achievement/trophy description" max="38*2"/>
<string english="MASTER OF THE UNIVERSE" translation="MESTRE DO UNIVERSO" explanation="achievement/trophy title - no death mode complete" max="38*2"/>
<string english="Complete the game in no death mode" translation="Conclui o jogo em Imortal." explanation="achievement/trophy description" max="38*2"/>
<string english="Something went wrong, but we forgot to print an error message." translation="" explanation="the message that is printed in case the game detects an error but there&apos;s no error message set" max="38*6"/>
<string english="Could not mount {path}: real directory doesn&apos;t exist" translation="Não foi possível montar {path}: o diretório não existe" explanation="mount: link/attach a directory (folder) in the filesystem into the game&apos;s filesystem so we can access it" max="38*6"/>
<string english="Level {path} not found" translation="" explanation="" max="38*6"/>
<string english="Error parsing {path}: {error}" translation="" explanation="we tried to parse the level file, but failed" max="38*6"/>
<string english="{filename} dimensions not exact multiples of {width} by {height}!" translation="" explanation="filename is something like tiles.png, tiles2.png, etc. and width/height are something like 8, 32, etc.; this is used if the dimensions of a graphics file aren&apos;t an exact multiple of the given size (e.g. 8x8, 32x32, etc.)" max="38*6"/>
<string english="ERROR: Could not write to language folder! Make sure there is no &quot;lang&quot; folder next to the regular saves." translation="ERRO: Não foi possível escrever na pasta de idioma! Certifica-te de que não há uma pasta &apos;&apos;lang&apos;&apos; junto dos dados guardados." explanation="" max="38*5"/>
<string english="" translation="" explanation=""/>
<string english="" translation="" explanation=""/>

View file

@ -758,9 +758,11 @@ You have found the secret lab!" translation="Поздравляем!
<string english="Last 1 minute on the Super Gravitron" translation="Проживите 1 минуту в Супер Гравитроне" explanation="achievement/trophy description" max="38*2"/>
<string english="MASTER OF THE UNIVERSE" translation="ВЛАСТЕЛИН ВСЕЛЕННОЙ" explanation="achievement/trophy title - no death mode complete" max="38*2"/>
<string english="Complete the game in no death mode" translation="Пройдите игру в режиме &quot;не умирая&quot;" explanation="achievement/trophy description" max="38*2"/>
<string english="Something went wrong, but we forgot to print an error message." translation="" explanation="the message that is printed in case the game detects an error but there&apos;s no error message set" max="38*6"/>
<string english="Could not mount {path}: real directory doesn&apos;t exist" translation="Не удалось монтировать {path}: настоящего каталога по данному пути не существует" explanation="mount: link/attach a directory (folder) in the filesystem into the game&apos;s filesystem so we can access it" max="38*6"/>
<string english="Level {path} not found" translation="" explanation="" max="38*6"/>
<string english="Error parsing {path}: {error}" translation="" explanation="we tried to parse the level file, but failed" max="38*6"/>
<string english="{filename} dimensions not exact multiples of {width} by {height}!" translation="" explanation="filename is something like tiles.png, tiles2.png, etc. and width/height are something like 8, 32, etc.; this is used if the dimensions of a graphics file aren&apos;t an exact multiple of the given size (e.g. 8x8, 32x32, etc.)" max="38*6"/>
<string english="ERROR: Could not write to language folder! Make sure there is no &quot;lang&quot; folder next to the regular saves." translation="ОШИБКА: Не удалось записать данные в папку локализации! Убедитесь, что рядом с обычными сохранениями нет папки &quot;lang&quot;." explanation="" max="38*5"/>
<string english="" translation="" explanation=""/>
<string english="" translation="" explanation=""/>

View file

@ -758,9 +758,11 @@ Gizli laboratuvarı buldun!" explanation="" max="34*4"/>
<string english="Last 1 minute on the Super Gravitron" translation="Süper Gravitron&apos;da 1 dakika dayan" explanation="achievement/trophy description" max="38*2"/>
<string english="MASTER OF THE UNIVERSE" translation="EVRENİN USTASI" explanation="achievement/trophy title - no death mode complete" max="38*2"/>
<string english="Complete the game in no death mode" translation="Oyunu ölümsüz modunda tamamla" explanation="achievement/trophy description" max="38*2"/>
<string english="Something went wrong, but we forgot to print an error message." translation="" explanation="the message that is printed in case the game detects an error but there&apos;s no error message set" max="38*6"/>
<string english="Could not mount {path}: real directory doesn&apos;t exist" translation="{path} bağlanamadı: gerçek klasör yok" explanation="mount: link/attach a directory (folder) in the filesystem into the game&apos;s filesystem so we can access it" max="38*6"/>
<string english="Level {path} not found" translation="" explanation="" max="38*6"/>
<string english="Error parsing {path}: {error}" translation="" explanation="we tried to parse the level file, but failed" max="38*6"/>
<string english="{filename} dimensions not exact multiples of {width} by {height}!" translation="" explanation="filename is something like tiles.png, tiles2.png, etc. and width/height are something like 8, 32, etc.; this is used if the dimensions of a graphics file aren&apos;t an exact multiple of the given size (e.g. 8x8, 32x32, etc.)" max="38*6"/>
<string english="ERROR: Could not write to language folder! Make sure there is no &quot;lang&quot; folder next to the regular saves." translation="HATA: Dil klasörüne yazılamadı! Normal kayıt dosyalarının yanında &quot;lang&quot; adlı bir klasör olmadığından emin ol." explanation="" max="38*5"/>
<string english="" translation="" explanation=""/>
<string english="" translation="" explanation=""/>

View file

@ -20,7 +20,7 @@ extern "C"
}
// Sigh... This is the second forward-declaration, we need to put this in a header file
SDL_Texture* LoadImage(const char *filename, const TextureLoadType loadtype);
SDL_Texture* LoadImage(const char *filename, TextureLoadType loadtype);
namespace font
{

View file

@ -151,9 +151,6 @@ void Graphics::init(void)
levelcomplete_mounted = false;
flipgamecomplete_mounted = false;
fliplevelcomplete_mounted = false;
SDL_zeroa(error);
SDL_zeroa(error_title);
}
void Graphics::destroy(void)
@ -238,65 +235,6 @@ void Graphics::updatetitlecolours(void)
col_trinket = getcol(18);
}
#define PROCESS_TILESHEET_CHECK_ERROR(tilesheet, tile_square) \
if (grphx.im_##tilesheet == NULL) \
{ \
/* We have already asserted; just no-op. */ \
} \
else if (grphx.im_##tilesheet->w % tile_square != 0 \
|| grphx.im_##tilesheet->h % tile_square != 0) \
{ \
static const char error_fmt[] = "%s.png dimensions not exact multiples of %i!"; \
static const char error_title_fmt[] = "Error with %s.png"; \
\
SDL_snprintf(error, sizeof(error), error_fmt, #tilesheet, tile_square); \
SDL_snprintf(error_title, sizeof(error_title), error_title_fmt, #tilesheet); \
\
vlog_error("%s", error); \
\
return false; \
}
#define PROCESS_TILESHEET_RENAME(tilesheet, vector, tile_square, extra_code) \
PROCESS_TILESHEET_CHECK_ERROR(tilesheet, tile_square) \
\
else \
{ \
int j; \
for (j = 0; j < grphx.im_##tilesheet->h / tile_square; ++j) \
{ \
int i; \
for (i = 0; i < grphx.im_##tilesheet->w / tile_square; ++i) \
{ \
SDL_Surface* temp = GetSubSurface( \
grphx.im_##tilesheet, \
i * tile_square, j * tile_square, \
tile_square, tile_square \
); \
vector.push_back(temp); \
\
extra_code \
} \
} \
\
VVV_freefunc(SDL_FreeSurface, grphx.im_##tilesheet); \
}
#define PROCESS_TILESHEET(tilesheet, tile_square, extra_code) \
PROCESS_TILESHEET_RENAME(tilesheet, tilesheet, tile_square, extra_code)
bool Graphics::MakeSpriteArray(void)
{
PROCESS_TILESHEET(sprites_surf, 32, {})
PROCESS_TILESHEET(flipsprites_surf, 32, {})
return true;
}
#undef PROCESS_TILESHEET
#undef PROCESS_TILESHEET_RENAME
#undef PROCESS_TILESHEET_CHECK_ERROR
void Graphics::map_tab(int opt, const char* text, bool selected /*= false*/)
{
@ -3433,14 +3371,76 @@ bool Graphics::onscreen(int t)
return (t >= -40 && t <= 280);
}
bool Graphics::checktexturesize(
const char* filename, SDL_Texture* texture,
const int tilewidth, const int tileheight
) {
int texturewidth;
int textureheight;
if (query_texture(texture, NULL, NULL, &texturewidth, &textureheight) != 0)
{
/* Just give it the benefit of the doubt. */
vlog_warn(
"Assuming the dimensions of %s are exact multiples of %i by %i!",
filename, tilewidth, tileheight
);
return true;
}
const bool valid = texturewidth % tilewidth == 0 && textureheight % tileheight == 0;
if (!valid)
{
FILESYSTEM_setLevelDirError(
loc::gettext("{filename} dimensions not exact multiples of {width} by {height}!"),
"filename:str, width:int, height:int",
filename, tilewidth, tileheight
);
return false;
}
return true;
}
static void make_array(
SDL_Surface** tilesheet,
std::vector<SDL_Surface*>& vector,
const int tile_square
) {
int j;
for (j = 0; j < (*tilesheet)->h / tile_square; j++)
{
int i;
for (i = 0; i < (*tilesheet)->w / tile_square; i++)
{
SDL_Surface* temp = GetSubSurface(
*tilesheet,
i * tile_square, j * tile_square,
tile_square, tile_square
);
vector.push_back(temp);
}
}
VVV_freefunc(SDL_FreeSurface, *tilesheet);
}
bool Graphics::reloadresources(void)
{
grphx.destroy();
grphx.init();
MAYBE_FAIL(checktexturesize("tiles.png", grphx.im_tiles, 8, 8));
MAYBE_FAIL(checktexturesize("tiles2.png", grphx.im_tiles2, 8, 8));
MAYBE_FAIL(checktexturesize("tiles3.png", grphx.im_tiles3, 8, 8));
MAYBE_FAIL(checktexturesize("entcolours.png", grphx.im_entcolours, 8, 8));
MAYBE_FAIL(checktexturesize("sprites.png", grphx.im_sprites, 32, 32));
MAYBE_FAIL(checktexturesize("flipsprites.png", grphx.im_flipsprites, 32, 32));
MAYBE_FAIL(checktexturesize("teleporter.png", grphx.im_teleporter, 96, 96));
destroy();
MAYBE_FAIL(MakeSpriteArray());
make_array(&grphx.im_sprites_surf, sprites_surf, 32);
make_array(&grphx.im_flipsprites_surf, flipsprites_surf, 32);
images[IMAGE_LEVELCOMPLETE] = grphx.im_image0;
images[IMAGE_MINIMAP] = grphx.im_image1;

View file

@ -56,8 +56,6 @@ public:
void drawgravityline(int t);
bool MakeSpriteArray(void);
void drawcoloredtile(int x, int y, int t, int r, int g, int b);
void drawmenu(int cr, int cg, int cb, enum Menu::MenuName menu);
@ -275,6 +273,10 @@ public:
bool onscreen(int t);
bool reloadresources(void);
bool checktexturesize(
const char* filename, SDL_Texture* texture,
int tilewidth, int tileheight
);
#ifndef NO_CUSTOM_LEVELS
bool tiles1_mounted;
bool tiles2_mounted;
@ -402,9 +404,6 @@ public:
SDL_Color crewcolourreal(int t);
void render_roomname(uint32_t font_flag, const char* roomname, int r, int g, int b);
char error[128];
char error_title[128]; /* for SDL_ShowSimpleMessageBox */
};
#ifndef GRAPHICS_DEFINITION

View file

@ -1626,23 +1626,34 @@ static void menurender(void)
break;
case Menu::errorloadinglevel:
{
const char* str;
const char* message;
if (FILESYSTEM_levelDirHasError())
{
str = FILESYSTEM_getLevelDirError();
message = FILESYSTEM_getLevelDirError();
}
else
{
str = graphics.error;
message = loc::gettext("Something went wrong, but we forgot to print an error message.");
}
font::print(PR_2X | PR_CEN, -1, 45, loc::gettext("ERROR"), tr, tg, tb);
font::print_wrap(PR_CEN, -1, 65, str, tr, tg, tb);
font::print_wrap(PR_CEN, -1, 65, message, tr, tg, tb);
break;
}
case Menu::warninglevellist:
{
const char* message;
if (FILESYSTEM_levelDirHasError())
{
message = FILESYSTEM_getLevelDirError();
}
else
{
message = loc::gettext("Something went wrong, but we forgot to print an error message.");
}
font::print(PR_2X | PR_CEN, -1, 45, loc::gettext("WARNING"), tr, tg, tb);
font::print_wrap(PR_CEN, -1, 65, FILESYSTEM_getLevelDirError(), tr, tg, tb);
font::print_wrap(PR_CEN, -1, 65, message, tr, tg, tb);
break;
}
default:
break;
}

View file

@ -658,12 +658,16 @@ int main(int argc, char *argv[])
{
/* Something wrong with the default assets? We can't use them to
* display the error message, and we have to bail. */
SDL_ShowSimpleMessageBox(
SDL_MESSAGEBOX_ERROR,
graphics.error_title,
graphics.error,
NULL
);
const char* message;
if (FILESYSTEM_levelDirHasError())
{
message = FILESYSTEM_getLevelDirError();
}
else
{
message = loc::gettext("Something went wrong, but we forgot to print an error message.");
}
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error", message, NULL);
VVV_exit(1);
}