From c1bbcace85fa37fbcc7c5e47e00cd7388519674a Mon Sep 17 00:00:00 2001 From: Raimon Zamora Date: Tue, 17 Oct 2023 18:48:35 +0200 Subject: [PATCH] - [NEW] Modul de fonts --- source/aux_font.cpp | 59 +++++++++++++++++++++++++++++++++++++++++++++ source/aux_font.h | 28 +++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 source/aux_font.cpp create mode 100644 source/aux_font.h diff --git a/source/aux_font.cpp b/source/aux_font.cpp new file mode 100644 index 0000000..fd36bec --- /dev/null +++ b/source/aux_font.cpp @@ -0,0 +1,59 @@ +#include "aux_font.h" +#include "jgame.h" + +namespace font +{ + static draw::surface *font1 = nullptr; + static draw::surface *font2 = nullptr; + static int mode = font::type::normal; + + void init() + { + font::font1 = draw::loadSurface("fuente1.gif"); + font::font2 = draw::loadSurface("fuente2.gif"); + } + + void selectFont(const int which) + { + font::mode = which; + } + + void setColor(const int color) + { + switch (color) { + case font::color::white: draw::setPaletteEntry(63, 255, 255, 255); break; + case font::color::red: draw::setPaletteEntry(63, 255, 0, 0); break; + case font::color::green: draw::setPaletteEntry(63, 0, 255, 0); break; + case font::color::blue: draw::setPaletteEntry(63, 0, 0, 255); break; + } + + } + + void print(const int x, const int y, const std::string text) + { + draw::setSource(font::mode == font::type::colored ? font::font2 : font::font1); + draw::setTrans(0); + + if (font::mode == font::type::fade) for (int i=64;i<=67;++i) draw::swapcol(i, i+4); + + const int len = text.length(); + for (int i=0;i + +namespace font +{ + namespace type + { + const int normal = 0; + const int colored = 1; + const int fade = 2; + } + + namespace color + { + const int white = 0; + const int red = 1; + const int green = 2; + const int blue = 3; + } + + void init(); + void selectFont(const int which); + void setColor(const int color); + + void print(const int x, const int y, const std::string text); + void print(const int x, const int y, const int num); +}