sprites fix

This commit is contained in:
p.kosyh 2011-06-18 07:20:10 +00:00
parent d3fd6c1b1a
commit 3f998785f2
3 changed files with 25 additions and 21 deletions

1
debian/changelog vendored
View file

@ -3,6 +3,7 @@ instead (1.4.3) unstable; urgency=low
* bug fix in nopara logic; * bug fix in nopara logic;
* ukranian translation and tutorial; * ukranian translation and tutorial;
* multilang tutorial3; * multilang tutorial3;
* sprites small fix (predefined handles);
-- Peter Kosyh <p.kosyh@gmail.com> Thu, 15 Jun 2011 16:56:00 +0400 -- Peter Kosyh <p.kosyh@gmail.com> Thu, 15 Jun 2011 16:56:00 +0400

View file

@ -836,6 +836,8 @@ static int luaB_text_sprite(lua_State *L) {
char txtkey[32]; char txtkey[32];
const char *color = luaL_optstring(L, 3, NULL); const char *color = luaL_optstring(L, 3, NULL);
int style = luaL_optnumber(L, 4, 0); int style = luaL_optnumber(L, 4, 0);
const char *desc = luaL_optstring(L, 5, NULL);
color_t col = { .r = game_theme.fgcol.r, .g = game_theme.fgcol.g, .b = game_theme.fgcol.b }; color_t col = { .r = game_theme.fgcol.r, .g = game_theme.fgcol.g, .b = game_theme.fgcol.b };
if (!font) if (!font)
@ -858,14 +860,15 @@ static int luaB_text_sprite(lua_State *L) {
if (!img) if (!img)
return 0; return 0;
key = sname;
strncpy(txtkey, text, sizeof(txtkey));
txtkey[sizeof(txtkey) - 1] = 0;
sprite_name(text, sname, sizeof(sname)); if (!desc || sprite_lookup(desc)) {
key = sname;
strncpy(txtkey, text, sizeof(txtkey));
txtkey[sizeof(txtkey) - 1] = 0;
sprite_name(txtkey, sname, sizeof(sname));
} else
key = desc;
sp = sprite_new(key, img); sp = sprite_new(key, img);
if (!sp) if (!sp)

View file

@ -33,8 +33,8 @@ sprite = {
font_scaled_size = function(size) font_scaled_size = function(size)
return stead.font_scaled_size(size); return stead.font_scaled_size(size);
end; end;
font = function(font, size) font = function(font, size, ...)
return stead.font_load(font, size); return stead.font_load(font, size, ...);
end; end;
free_font = function(font) free_font = function(font)
return stead.font_free(key); return stead.font_free(key);
@ -43,20 +43,20 @@ sprite = {
local w,h = stead.sprite_text_size(font) local w,h = stead.sprite_text_size(font)
return h return h
end; end;
alpha = function(name, alpha) alpha = function(name, alpha, ...)
return stead.sprite_alpha(name, alpha); return stead.sprite_alpha(name, alpha, ...);
end; end;
dup = function(name) dup = function(name, ...)
return stead.sprite_dup(name); return stead.sprite_dup(name, ...);
end; end;
scale = function(name, xs, ys) scale = function(name, xs, ys, ...)
return stead.sprite_scale(name, xs, ys); return stead.sprite_scale(name, xs, ys, ...);
end; end;
rotate = function(name, angle) rotate = function(name, angle, ...)
return stead.sprite_rotate(name, angle); return stead.sprite_rotate(name, angle, ...);
end; end;
text = function(font, text, col, style) text = function(font, text, col, style, ...)
return stead.sprite_text(font, text, col, style); return stead.sprite_text(font, text, col, style, ...);
end; end;
size = function(spr) size = function(spr)
return stead.sprite_size(spr); return stead.sprite_size(spr);
@ -85,8 +85,8 @@ sprite = {
pixel = function(d, x, y, col, alpha) pixel = function(d, x, y, col, alpha)
return stead.sprite_pixel(d, x, y, col, alpha) return stead.sprite_pixel(d, x, y, col, alpha)
end; end;
load = function(fname) load = function(fname, ...)
return stead.sprite_load(fname); return stead.sprite_load(fname, ...);
end; end;
free = function(key) free = function(key)
return stead.sprite_free(key); return stead.sprite_free(key);