Skip to content

Commit

Permalink
debug: Add error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
dracc committed Jul 18, 2019
1 parent c0aed65 commit c4ad76b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Includes/font.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
#include "font.h"

#ifdef NXDK
#include "outputLine.h"
#endif

Font::Font(const char* path) {
outputLine("Opening font %s\n", path);
font = TTF_OpenFont(path, 24);
outline_font = TTF_OpenFont(path, 24);
if (font == nullptr) {
outputLine("Main font could not be opened; %s\n", TTF_GetError());
}
outline_font = TTF_OpenFont("vegur2.ttf", 24);
if (outline_font == nullptr) {
outputLine("Outline font could not be opened; %s\n", TTF_GetError());
}
active = {0x7F, 0x7F, 0xFF, 0xFF};
passive = {0xFF, 0x7F, 0xFF, 0xFF};
outline_color = {0x40, 0x40, 0x40, 0x7F};
TTF_SetFontOutline(outline_font, outline_size);
}

Font::~Font() {
outputLine("\nFont destructor called.\n\n");
if (font != nullptr) {
TTF_CloseFont(font);
}
Expand All @@ -20,6 +32,7 @@ Font::~Font() {

bool Font::textureHelper(menuItem* mI, SDL_Color const& c, Renderer* r) {
if (mI == nullptr) {
outputLine("menuItem nullptr check failed.\n");
return false;
}
if (mI->getTexture() != nullptr) {
Expand Down
3 changes: 3 additions & 0 deletions Includes/renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ int max(int lhs, int rhs) {
}

#ifdef NXDK
#include "outputLine.h"
extern "C" {
const extern int SCREEN_HEIGHT;
const extern int SCREEN_WIDTH;
Expand Down Expand Up @@ -70,11 +71,13 @@ int Renderer::init(const char* bg) {
}
SDL_Surface *bgsurf = SDL_LoadBMP(const_cast<char*>(bg));
if (bgsurf == nullptr) {
outputLine("Creating background surface failed.\n");
return 3;
}
background = SDL_CreateTextureFromSurface(renderer, bgsurf);
SDL_FreeSurface(bgsurf);
if (background == nullptr) {
outputLine("Creating background texture failed.\n");
return 4;
}
return ret;
Expand Down

0 comments on commit c4ad76b

Please sign in to comment.