From 97ff78b9542025ffcea42bd911e758860210ed31 Mon Sep 17 00:00:00 2001
From: "p.kosyh"
Date: Tue, 26 Jul 2011 08:06:15 +0000
Subject: [PATCH] win.align added
---
debian/changelog | 2 ++
src/sdl-instead/game.c | 2 +-
src/sdl-instead/instead.c | 5 +++--
src/sdl-instead/themes.c | 19 ++++++++++++++++++-
src/sdl-instead/themes.h | 5 +++--
themes/default/theme.ini | 3 ++-
6 files changed, 29 insertions(+), 7 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 17bf602..dd67b60 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,6 +3,8 @@ instead (1.4.5) unstable; urgency=low
* bug fix in rnd() w/o parameter;
* callpush/callpop/cctx/strip moved to stead;
* bug fix in for_each;
+ * win.align added to theme;
+ * theme_name added;
-- Peter Kosyh Thu, 14 Jul 2011 16:18:00 +0400
diff --git a/src/sdl-instead/game.c b/src/sdl-instead/game.c
index c83cb34..06e8efa 100644
--- a/src/sdl-instead/game.c
+++ b/src/sdl-instead/game.c
@@ -551,7 +551,7 @@ int game_apply_theme(void)
if (!DIRECT_MODE)
game_clear(0, 0, game_theme.w, game_theme.h);
gfx_flip();
- lay = txt_layout(game_theme.font, ALIGN_JUSTIFY, game_theme.win_w, game_theme.win_h);
+ lay = txt_layout(game_theme.font, game_theme.win_align, game_theme.win_w, game_theme.win_h);
if (!lay)
return -1;
box = txt_box(game_theme.win_w, game_theme.win_h);
diff --git a/src/sdl-instead/instead.c b/src/sdl-instead/instead.c
index 7ecc48c..e900eb3 100644
--- a/src/sdl-instead/instead.c
+++ b/src/sdl-instead/instead.c
@@ -580,8 +580,9 @@ static int luaB_theme_var(lua_State *L) {
static int luaB_theme_name(lua_State *L) {
if (game_own_theme && opt_owntheme)
- return 0;
- lua_pushstring(L, curtheme_dir);
+ lua_pushstring(L, ".");
+ else
+ lua_pushstring(L, curtheme_dir);
return 1;
}
diff --git a/src/sdl-instead/themes.c b/src/sdl-instead/themes.c
index 9b908e5..50c1201 100644
--- a/src/sdl-instead/themes.c
+++ b/src/sdl-instead/themes.c
@@ -1,4 +1,3 @@
-
#include "externals.h"
#include "internals.h"
@@ -6,6 +5,22 @@ int theme_relative = 0;
char *curtheme_dir = NULL;
+static int parse_win_align(const char *v, void *data)
+{
+ int *i = (int *)data;
+ if (!strcmp(v, "left"))
+ *i = ALIGN_LEFT;
+ else if (!strcmp(v, "justify"))
+ *i = ALIGN_JUSTIFY;
+ else if (!strcmp(v, "center"))
+ *i = ALIGN_CENTER;
+ else if (!strcmp(v, "right"))
+ *i = ALIGN_RIGHT;
+ else
+ return -1;
+ return 0;
+}
+
static int parse_gfx_mode(const char *v, void *data)
{
int *i = (int *)data;
@@ -149,6 +164,7 @@ struct parser cmd_parser[] = {
{ "scr.gfx.h", parse_int, &game_theme.max_scene_h },
{ "scr.gfx.mode", parse_gfx_mode, &game_theme.gfx_mode },
+ { "win.align", parse_win_align, &game_theme.win_align },
{ "win.x", parse_int, &game_theme.win_x },
{ "win.y", parse_int, &game_theme.win_y },
{ "win.w", parse_int, &game_theme.win_w },
@@ -296,6 +312,7 @@ struct game_theme game_theme = {
.menu_font = NULL,
.menu_button_name = NULL,
.menu_button = NULL,
+ .win_align = ALIGN_JUSTIFY,
.gfx_mode = GFX_MODE_EMBEDDED,
.inv_mode = INV_MODE_VERT | INV_ALIGN_SET(ALIGN_LEFT),
.click_name = NULL,
diff --git a/src/sdl-instead/themes.h b/src/sdl-instead/themes.h
index fb4088d..6c57fb0 100644
--- a/src/sdl-instead/themes.h
+++ b/src/sdl-instead/themes.h
@@ -26,8 +26,9 @@ struct game_theme {
img_t use;
img_t cursor;
int pad;
-
- int win_x;
+
+ int win_align;
+ int win_x;
int win_y;
int win_w;
int win_h;
diff --git a/themes/default/theme.ini b/themes/default/theme.ini
index 1d2d24e..e7e5f1e 100644
--- a/themes/default/theme.ini
+++ b/themes/default/theme.ini
@@ -19,6 +19,7 @@ scr.gfx.cursor.use = cursor-use.png
scr.gfx.pad = 16
scr.gfx.mode = embedded
+win.align = justify
win.x = 48
win.y = 8
win.w = 500
@@ -50,7 +51,7 @@ inv.gfx.down = adown.png
inv.col.fg = #CCCCCC
inv.col.link = #CCCCCC
inv.col.alink = goldenrod
-inv.mode = vertical
+inv.mode = vertical-left
inv.up.x = -1
inv.up.y = -1
inv.down.x = -1