- [NEW] fonts amb colorets

- [WIP] stringProperty
This commit is contained in:
2025-11-18 20:23:09 +01:00
parent f72311bb17
commit 57f9ed32e3
4 changed files with 18 additions and 3 deletions

View File

@@ -49,8 +49,9 @@ namespace font
draw::draw({sx, sy, spaces[c], h}, {x, y, spaces[c], h}); draw::draw({sx, sy, spaces[c], h}, {x, y, spaces[c], h});
} }
void print(const char* text, int x, int y) void print(const char* text, int x, int y, uint32_t color)
{ {
SDL_SetTextureColorMod(surf, (color>>16)&0xff, (color>>8)&0xff, color&0xff);
draw::setSource(surf); draw::setSource(surf);
while(*text) { while(*text) {
printChar(*text, x, y); printChar(*text, x, y);

View File

@@ -1,8 +1,9 @@
#pragma once #pragma once
#include <stdint.h>
namespace font namespace font
{ {
void load(const char* filename); void load(const char* filename);
void print(const char* text, int x, int y); void print(const char* text, int x, int y, uint32_t color = 0xffffffff);
const int len(const char *text); const int len(const char *text);
} }

View File

@@ -124,6 +124,8 @@ bool loop()
tilemap::draw(); tilemap::draw();
propertygrid::start(); propertygrid::start();
propertygrid::stringProperty("Peiv", "Teib");
propertygrid::stringProperty("Peiv", "Teib");
propertygrid::end(); propertygrid::end();
/*x1 += 6; x2 = x1 + font::len("FILE")+6; /*x1 += 6; x2 = x1 + font::len("FILE")+6;

View File

@@ -31,7 +31,18 @@ namespace propertygrid
std::string stringProperty(std::string label, std::string value) std::string stringProperty(std::string label, std::string value)
{ {
const SDL_Point win_size = draw::getWindowSize();
const int x = win_size.x-propertygrid::width;
const int y = 48+line*24;
draw::setClip(x,y,propertygrid::width, 24);
draw::setColor(0xffffffff);
draw::fillrect(x,y,propertygrid::width, 24);
draw::setColor(0xffa0a0a0);
draw::line(x,71+line*24,win_size.x, y+23);
draw::line(x+propertygrid::width/2,y,x+propertygrid::width/2, y+23);
font::print(label.c_str(), x+8, y+9, 0xff000000);
line++;
return "";
} }
void end() void end()