diff --git a/.travis.yml b/.travis.yml index e02bb48..d006f23 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,7 @@ before_install: - mkdir build - cp libgtest_main.so build/libgtest_main.a - cp libgtest.so build/libgtest.a + # still needed to actually execute the binary - sudo cp -a include/gtest /usr/include - sudo cp -a libgtest_main.so libgtest.so /usr/lib/ diff --git a/README.md b/README.md index d4754b0..727cfd6 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ## A high-level object-oriented Gameboy Advance sprite engine library -![travis build status](https://travis-ci.org/wgroeneveld/gba-sprite-engine.svg?branch=master) +[![Build Status](https://travis-ci.org/wgroeneveld/gba-sprite-engine.svg?branch=master)](https://travis-ci.org/wgroeneveld/gba-sprite-engine) That's a mouthful - let's break that down: @@ -160,7 +160,10 @@ Useful text manipulation: * `setText(txt, row, col)` * `<< text` or `<< int` etc: append to text stream for debugging purposes. -* `setTextColor(COLOR)`: changes default color palette (white). +* `setFontColor(COLOR)`: changes default color palette (white). +* `setFontStyle(const void* data, int size)` if you prefer your own font face. + +Changing the font style assumes a tile width of 32 and the same symbol indexes! It also resets the font color and map so call this before doing anything else. #### Error logging diff --git a/engine/include/libgba-sprite-engine/background/text_stream.h b/engine/include/libgba-sprite-engine/background/text_stream.h index 3a145eb..ff529e8 100644 --- a/engine/include/libgba-sprite-engine/background/text_stream.h +++ b/engine/include/libgba-sprite-engine/background/text_stream.h @@ -35,7 +35,10 @@ public: void clear(); void setText(std::string text, int row, int col); void setText(const char* text, int row, int col); - void setTextColor(COLOR color); + + void setFontColor(COLOR color); + void setFontStyle(const void *data, int size); + static TextStream& instance(); void persist() override; diff --git a/engine/src/background/text_stream.cpp b/engine/src/background/text_stream.cpp index ac34036..f96fb85 100644 --- a/engine/src/background/text_stream.cpp +++ b/engine/src/background/text_stream.cpp @@ -21,7 +21,7 @@ TextStream::TextStream() : Background(0, text_data, sizeof(text_data), nullptr, this->palette = std::unique_ptr(new BackgroundPaletteManager()); persist(); - clearMap(); + clear(); } void log_text(const char* text) { @@ -94,12 +94,21 @@ TextStream& TextStream::operator<<(const char * s) { return *this; } -void TextStream::setTextColor(COLOR color) { +// WARNING: resets map and font color. Assumes a fixed tile width of TILE_WIDTH +void TextStream::setFontStyle(const void *data, int size) { + this->data = data; + this->size = size; + + persist(); + clear(); +} + +void TextStream::setFontColor(COLOR color) { palette.get()->change(PALETTE_TEXT_BANK, PALETTE_COLOR_INDEX, color); } void TextStream::persist() { Background::persist(); // WARNING: stream hijacks last bg palette bank, last index, no matter what. - setTextColor(PaletteManager::color(31, 31, 31)); + setFontColor(PaletteManager::color(31, 31, 31)); }