- Llevem tot el referent a pintar fonts de jdraw
- [NEW] draw::setPaletteEntry()
This commit is contained in:
@@ -27,7 +27,7 @@ namespace draw
|
|||||||
uint8_t sel_color = 0; // Color seleccionat per defecte
|
uint8_t sel_color = 0; // Color seleccionat per defecte
|
||||||
uint8_t transparent = 0; // El color transparent
|
uint8_t transparent = 0; // El color transparent
|
||||||
|
|
||||||
surface *textsurf = nullptr; // Surface on guardar el gif amb la font
|
//surface *textsurf = nullptr; // Surface on guardar el gif amb la font
|
||||||
|
|
||||||
SDL_Rect viewport;
|
SDL_Rect viewport;
|
||||||
|
|
||||||
@@ -55,13 +55,13 @@ namespace draw
|
|||||||
sel_color = transparent = 0;
|
sel_color = transparent = 0;
|
||||||
for (int i=0;i<256;++i) color_indices[i] = i;
|
for (int i=0;i<256;++i) color_indices[i] = i;
|
||||||
|
|
||||||
textsurf = loadSurface("font.gif");
|
//textsurf = loadSurface("font.gif");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finalització del sistema
|
// Finalització del sistema
|
||||||
void quit()
|
void quit()
|
||||||
{
|
{
|
||||||
if (textsurf) freeSurface(textsurf);
|
//if (textsurf) freeSurface(textsurf);
|
||||||
|
|
||||||
// Si la superficie "screen" existia, alliberem la seua memòria
|
// Si la superficie "screen" existia, alliberem la seua memòria
|
||||||
if (screen != nullptr)
|
if (screen != nullptr)
|
||||||
@@ -223,6 +223,12 @@ namespace draw
|
|||||||
free(buffer);
|
free(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Estableix una entrada de la paleta del sistema
|
||||||
|
void setPaletteEntry(const uint8_t index, const uint8_t r, const uint8_t g, const uint8_t b)
|
||||||
|
{
|
||||||
|
palette[index] = (r << 16) + (g << 8) + b;
|
||||||
|
}
|
||||||
|
|
||||||
// Esborra la superficie "destination" amb el color especificat
|
// Esborra la superficie "destination" amb el color especificat
|
||||||
void cls(const uint8_t color)
|
void cls(const uint8_t color)
|
||||||
{
|
{
|
||||||
@@ -407,33 +413,6 @@ namespace draw
|
|||||||
for (int i=0; i<256; ++i) if (decPalEntry(i, 16)) fading_out = true;
|
for (int i=0; i<256; ++i) if (decPalEntry(i, 16)) fading_out = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void print(const char* text, const int x, const int y, const Uint8 color, const Uint8 borde)
|
|
||||||
{
|
|
||||||
surface* tmp = source;
|
|
||||||
source = textsurf;
|
|
||||||
swapcol(1, color);
|
|
||||||
const int len = strlen(text);
|
|
||||||
for (int i=0;i<len;++i)
|
|
||||||
{
|
|
||||||
char chr = text[i];
|
|
||||||
if (borde!=0)
|
|
||||||
{
|
|
||||||
swapcol(1, borde);
|
|
||||||
draw(-1+x+i*4, y-1, 4, 6, (chr&15)*4, (chr>>4)*6);
|
|
||||||
draw(x+i*4, y-1, 4, 6, (chr&15)*4, (chr>>4)*6);
|
|
||||||
draw(1+x+i*4, y-1, 4, 6, (chr&15)*4, (chr>>4)*6);
|
|
||||||
draw(-1+x+i*4, y, 4, 6, (chr&15)*4, (chr>>4)*6);
|
|
||||||
draw(1+x+i*4, y, 4, 6, (chr&15)*4, (chr>>4)*6);
|
|
||||||
draw(-1+x+i*4, y+1, 4, 6, (chr&15)*4, (chr>>4)*6);
|
|
||||||
draw(x+i*4, y+1, 4, 6, (chr&15)*4, (chr>>4)*6);
|
|
||||||
draw(1+x+i*4, y+1, 4, 6, (chr&15)*4, (chr>>4)*6);
|
|
||||||
swapcol(1, color);
|
|
||||||
}
|
|
||||||
draw(x+i*4, y, 4, 6, (chr&15)*4, (chr>>4)*6);
|
|
||||||
}
|
|
||||||
source = tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Refresca la pantalla
|
// Refresca la pantalla
|
||||||
void render()
|
void render()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -67,6 +67,13 @@ namespace draw
|
|||||||
/// @param filename nom de l'arxiu GIF d'on carregar la paleta
|
/// @param filename nom de l'arxiu GIF d'on carregar la paleta
|
||||||
void loadPalette(const std::string &filename);
|
void loadPalette(const std::string &filename);
|
||||||
|
|
||||||
|
/// @brief Estableix una entrada de la paleta del sistema
|
||||||
|
/// @param index l'index de l'entrada de la paleta
|
||||||
|
/// @param r la component roja de l'entrada de la paleta
|
||||||
|
/// @param g la component verda de l'entrada de la paleta
|
||||||
|
/// @param b la component blava de l'entrada de la paleta
|
||||||
|
void setPaletteEntry(const uint8_t index, const uint8_t r, const uint8_t g, const uint8_t b);
|
||||||
|
|
||||||
/// @brief Esborra la superficie "destination" amb el color especificat
|
/// @brief Esborra la superficie "destination" amb el color especificat
|
||||||
/// @param color color a usar per a borrar la superficie de destinació
|
/// @param color color a usar per a borrar la superficie de destinació
|
||||||
void cls(const uint8_t color);
|
void cls(const uint8_t color);
|
||||||
@@ -96,7 +103,7 @@ namespace draw
|
|||||||
void fadein();
|
void fadein();
|
||||||
void fadeout();
|
void fadeout();
|
||||||
|
|
||||||
void print(const char* text, const int x, const int y, const uint8_t color, const uint8_t borde);
|
//void print(const char* text, const int x, const int y, const uint8_t color, const uint8_t borde);
|
||||||
|
|
||||||
/// @brief Refresca la pantalla
|
/// @brief Refresca la pantalla
|
||||||
void render();
|
void render();
|
||||||
|
|||||||
Reference in New Issue
Block a user