set text font
This commit is contained in:
parent
feaa1b6054
commit
be7492a4b6
|
@ -26,6 +26,7 @@ before_install:
|
||||||
- mkdir build
|
- mkdir build
|
||||||
- cp libgtest_main.so build/libgtest_main.a
|
- cp libgtest_main.so build/libgtest_main.a
|
||||||
- cp libgtest.so build/libgtest.a
|
- cp libgtest.so build/libgtest.a
|
||||||
|
# still needed to actually execute the binary
|
||||||
- sudo cp -a include/gtest /usr/include
|
- sudo cp -a include/gtest /usr/include
|
||||||
- sudo cp -a libgtest_main.so libgtest.so /usr/lib/
|
- sudo cp -a libgtest_main.so libgtest.so /usr/lib/
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
## A high-level object-oriented Gameboy Advance sprite engine library
|
## 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:
|
That's a mouthful - let's break that down:
|
||||||
|
|
||||||
|
@ -160,7 +160,10 @@ Useful text manipulation:
|
||||||
|
|
||||||
* `setText(txt, row, col)`
|
* `setText(txt, row, col)`
|
||||||
* `<< text` or `<< int` etc: append to text stream for debugging purposes.
|
* `<< 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
|
#### Error logging
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,10 @@ public:
|
||||||
void clear();
|
void clear();
|
||||||
void setText(std::string text, int row, int col);
|
void setText(std::string text, int row, int col);
|
||||||
void setText(const char* 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();
|
static TextStream& instance();
|
||||||
|
|
||||||
void persist() override;
|
void persist() override;
|
||||||
|
|
|
@ -21,7 +21,7 @@ TextStream::TextStream() : Background(0, text_data, sizeof(text_data), nullptr,
|
||||||
this->palette = std::unique_ptr<BackgroundPaletteManager>(new BackgroundPaletteManager());
|
this->palette = std::unique_ptr<BackgroundPaletteManager>(new BackgroundPaletteManager());
|
||||||
|
|
||||||
persist();
|
persist();
|
||||||
clearMap();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void log_text(const char* text) {
|
void log_text(const char* text) {
|
||||||
|
@ -94,12 +94,21 @@ TextStream& TextStream::operator<<(const char * s) {
|
||||||
return *this;
|
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);
|
palette.get()->change(PALETTE_TEXT_BANK, PALETTE_COLOR_INDEX, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextStream::persist() {
|
void TextStream::persist() {
|
||||||
Background::persist();
|
Background::persist();
|
||||||
// WARNING: stream hijacks last bg palette bank, last index, no matter what.
|
// WARNING: stream hijacks last bg palette bank, last index, no matter what.
|
||||||
setTextColor(PaletteManager::color(31, 31, 31));
|
setFontColor(PaletteManager::color(31, 31, 31));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue