Not finnished yet, commit

This commit is contained in:
Linus Probert 2019-03-04 18:06:46 +01:00
parent bab5fd7980
commit 06ca6c3e1e
1 changed files with 25 additions and 4 deletions

View File

@ -87,8 +87,29 @@ create_number_subsprite(SDL_Color fg,
{ {
Sprite *sprite = sprite_create(); Sprite *sprite = sprite_create();
sprite_load_text_texture(sprite, "GUI/SDS_8x8.ttf", 0, 8, 1); sprite_load_text_texture(sprite, "GUI/SDS_8x8.ttf", 0, 8, 1);
char priceLabel[10]; char priceLabel[9];
m_sprintf(priceLabel, 10, format, value); m_sprintf(priceLabel, 9, format, value);
texture_load_from_text(sprite->textures[0],
priceLabel,
fg,
outline,
builder->renderer);
sprite->dim = sprite->textures[0]->dim;
return sprite;
}
static Sprite *
create_small_number_subsprite(SDL_Color fg,
SDL_Color outline,
const char *format,
double value)
{
Sprite *sprite = sprite_create();
sprite_load_text_texture(sprite, "GUI/SDS_6x6.ttf", 0, 6, 1);
char priceLabel[9];
m_sprintf(priceLabel, 9, format, value);
texture_load_from_text(sprite->textures[0], texture_load_from_text(sprite->textures[0],
priceLabel, priceLabel,
fg, fg,
@ -131,7 +152,7 @@ create_priced_item(double price,
Item *item = create_item(path0, path1, clip, cb); Item *item = create_item(path0, path1, clip, cb);
item->price = price; item->price = price;
Sprite *priceSprite = create_number_subsprite(C_YELLOW, C_BLACK, "$%.0f", item->price); Sprite *priceSprite = create_number_subsprite(C_YELLOW, C_BLACK, "$.0f", item->price);
linkedlist_append(&item->subsprites, priceSprite); linkedlist_append(&item->subsprites, priceSprite);
return item; return item;
@ -243,7 +264,7 @@ item_builder_build_item(ItemKey key, int level)
} }
if (item->value != 1) { if (item->value != 1) {
Sprite *valueSprite = create_number_subsprite(C_BLUE, C_BLACK, "%.1f", item->value); Sprite *valueSprite = create_small_number_subsprite(C_BLUE, C_BLACK, "%g", item->value);
valueSprite->offset.x = item->sprite->dim.width - valueSprite->dim.width; valueSprite->offset.x = item->sprite->dim.width - valueSprite->dim.width;
valueSprite->offset.y = item->sprite->dim.height - valueSprite->dim.height; valueSprite->offset.y = item->sprite->dim.height - valueSprite->dim.height;
linkedlist_append(&item->subsprites, valueSprite); linkedlist_append(&item->subsprites, valueSprite);