inv_mode disabled
This commit is contained in:
parent
3a1292e75e
commit
f21fc4a8a0
|
@ -324,6 +324,11 @@ int game_save(int nr)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int inv_enabled(void)
|
||||||
|
{
|
||||||
|
return (game_theme.inv_mode != INV_MODE_DISABLED);
|
||||||
|
}
|
||||||
|
|
||||||
int game_apply_theme(void)
|
int game_apply_theme(void)
|
||||||
{
|
{
|
||||||
layout_t lay;
|
layout_t lay;
|
||||||
|
@ -356,19 +361,23 @@ int game_apply_theme(void)
|
||||||
txt_box_set(box, lay);
|
txt_box_set(box, lay);
|
||||||
el_set(el_scene, elt_box, game_theme.win_x, 0, box);
|
el_set(el_scene, elt_box, game_theme.win_x, 0, box);
|
||||||
|
|
||||||
lay = txt_layout(game_theme.inv_font, (game_theme.inv_mode == INV_MODE_HORIZ)?
|
|
||||||
ALIGN_CENTER:ALIGN_LEFT, game_theme.inv_w, game_theme.inv_h);
|
|
||||||
if (!lay)
|
|
||||||
return -1;
|
|
||||||
txt_layout_color(lay, game_theme.icol);
|
|
||||||
txt_layout_link_color(lay, game_theme.ilcol);
|
|
||||||
txt_layout_active_color(lay, game_theme.iacol);
|
|
||||||
box = txt_box(game_theme.inv_w, game_theme.inv_h);
|
|
||||||
if (!box)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
txt_box_set(box, lay);
|
if (inv_enabled()) {
|
||||||
el_set(el_inv, elt_box, game_theme.inv_x, game_theme.inv_y, box);
|
lay = txt_layout(game_theme.inv_font, (game_theme.inv_mode == INV_MODE_HORIZ)?
|
||||||
|
ALIGN_CENTER:ALIGN_LEFT, game_theme.inv_w, game_theme.inv_h);
|
||||||
|
if (!lay)
|
||||||
|
return -1;
|
||||||
|
txt_layout_color(lay, game_theme.icol);
|
||||||
|
txt_layout_link_color(lay, game_theme.ilcol);
|
||||||
|
txt_layout_active_color(lay, game_theme.iacol);
|
||||||
|
|
||||||
|
box = txt_box(game_theme.inv_w, game_theme.inv_h);
|
||||||
|
if (!box)
|
||||||
|
return -1;
|
||||||
|
txt_box_set(box, lay);
|
||||||
|
el_set(el_inv, elt_box, game_theme.inv_x, game_theme.inv_y, box);
|
||||||
|
} else
|
||||||
|
el_set(el_inv, elt_box, game_theme.inv_x, game_theme.inv_y, NULL);
|
||||||
|
|
||||||
lay = txt_layout(game_theme.font, ALIGN_CENTER, game_theme.win_w, 0);
|
lay = txt_layout(game_theme.font, ALIGN_CENTER, game_theme.win_w, 0);
|
||||||
if (!lay)
|
if (!lay)
|
||||||
|
@ -1385,25 +1394,27 @@ int game_cmd(char *cmd)
|
||||||
el_draw(el_scene);
|
el_draw(el_scene);
|
||||||
|
|
||||||
inv:
|
inv:
|
||||||
invstr = instead_cmd("inv"); instead_clear();
|
if (inv_enabled()) {
|
||||||
|
int off;
|
||||||
|
|
||||||
if (invstr && game_theme.inv_mode == INV_MODE_HORIZ) {
|
invstr = instead_cmd("inv"); instead_clear();
|
||||||
invstr = horiz_inv(invstr);
|
|
||||||
}
|
|
||||||
|
|
||||||
do {
|
if (invstr && game_theme.inv_mode == INV_MODE_HORIZ)
|
||||||
int off = txt_box_off(el_box(el_inv));
|
invstr = horiz_inv(invstr);
|
||||||
|
|
||||||
|
off = txt_box_off(el_box(el_inv));
|
||||||
txt_layout_set(txt_box_layout(el_box(el_inv)), invstr);
|
txt_layout_set(txt_box_layout(el_box(el_inv)), invstr);
|
||||||
txt_box_set(el_box(el_inv), txt_box_layout(el_box(el_inv)));
|
txt_box_set(el_box(el_inv), txt_box_layout(el_box(el_inv)));
|
||||||
txt_box_scroll(el_box(el_inv), off);
|
txt_box_scroll(el_box(el_inv), off);
|
||||||
} while(0);
|
|
||||||
|
|
||||||
if (invstr)
|
if (invstr)
|
||||||
free(invstr);
|
free(invstr);
|
||||||
|
|
||||||
el_clear(el_inv);
|
el_clear(el_inv);
|
||||||
el_draw(el_inv);
|
el_draw(el_inv);
|
||||||
|
}
|
||||||
// scene_scrollbar();
|
// scene_scrollbar();
|
||||||
|
|
||||||
if (new_pict || new_place) {
|
if (new_pict || new_place) {
|
||||||
img_t offscreen;
|
img_t offscreen;
|
||||||
game_cursor(CURSOR_CLEAR);
|
game_cursor(CURSOR_CLEAR);
|
||||||
|
@ -1869,6 +1880,8 @@ static int sel_el = 0;
|
||||||
|
|
||||||
static void frame_next(void)
|
static void frame_next(void)
|
||||||
{
|
{
|
||||||
|
if (sel_el == el_scene && !inv_enabled())
|
||||||
|
sel_el = el_inv;
|
||||||
switch(sel_el) {
|
switch(sel_el) {
|
||||||
default:
|
default:
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -1914,6 +1927,8 @@ static void frame_prev(void)
|
||||||
sel_el = el_scene;
|
sel_el = el_scene;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (sel_el == el_inv && !inv_enabled())
|
||||||
|
sel_el = el_scene;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int select_ref(int prev, int last);
|
static int select_ref(int prev, int last);
|
||||||
|
|
|
@ -1455,6 +1455,8 @@ struct layout *layout_new(fnt_t fn, int w, int h)
|
||||||
void txt_layout_size(layout_t lay, int *w, int *h)
|
void txt_layout_size(layout_t lay, int *w, int *h)
|
||||||
{
|
{
|
||||||
struct layout *layout = (struct layout *)lay;
|
struct layout *layout = (struct layout *)lay;
|
||||||
|
if (!lay)
|
||||||
|
return;
|
||||||
if (w)
|
if (w)
|
||||||
*w = layout->w;
|
*w = layout->w;
|
||||||
if (h)
|
if (h)
|
||||||
|
@ -1515,9 +1517,11 @@ void txt_layout_free(layout_t lay)
|
||||||
{
|
{
|
||||||
struct layout *layout = (struct layout *)lay;
|
struct layout *layout = (struct layout *)lay;
|
||||||
_txt_layout_free(lay);
|
_txt_layout_free(lay);
|
||||||
cache_free(layout->img_cache);
|
if (lay) {
|
||||||
layout->img_cache = NULL;
|
cache_free(layout->img_cache);
|
||||||
free(lay);
|
layout->img_cache = NULL;
|
||||||
|
free(lay);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define TOKEN_NONE 0
|
#define TOKEN_NONE 0
|
||||||
|
@ -1788,21 +1792,29 @@ void layout_debug(struct layout *layout)
|
||||||
void txt_layout_color(layout_t lay, color_t fg)
|
void txt_layout_color(layout_t lay, color_t fg)
|
||||||
{
|
{
|
||||||
struct layout *layout = (struct layout*)lay;
|
struct layout *layout = (struct layout*)lay;
|
||||||
|
if (!lay)
|
||||||
|
return;
|
||||||
layout->col = fg;
|
layout->col = fg;
|
||||||
}
|
}
|
||||||
void txt_layout_link_color(layout_t lay, color_t link)
|
void txt_layout_link_color(layout_t lay, color_t link)
|
||||||
{
|
{
|
||||||
struct layout *layout = (struct layout*)lay;
|
struct layout *layout = (struct layout*)lay;
|
||||||
|
if (!lay)
|
||||||
|
return;
|
||||||
layout->lcol = link;
|
layout->lcol = link;
|
||||||
}
|
}
|
||||||
void txt_layout_active_color(layout_t lay, color_t link)
|
void txt_layout_active_color(layout_t lay, color_t link)
|
||||||
{
|
{
|
||||||
struct layout *layout = (struct layout*)lay;
|
struct layout *layout = (struct layout*)lay;
|
||||||
|
if (!lay)
|
||||||
|
return;
|
||||||
layout->acol = link;
|
layout->acol = link;
|
||||||
}
|
}
|
||||||
void txt_layout_link_style(layout_t lay, int style)
|
void txt_layout_link_style(layout_t lay, int style)
|
||||||
{
|
{
|
||||||
struct layout *layout = (struct layout*)lay;
|
struct layout *layout = (struct layout*)lay;
|
||||||
|
if (!lay)
|
||||||
|
return;
|
||||||
layout->lstyle = style;
|
layout->lstyle = style;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1886,6 +1898,8 @@ void txt_layout_draw_ex(layout_t lay, struct line *line, int x, int y, int off,
|
||||||
struct word *word;
|
struct word *word;
|
||||||
// line = layout->lines;
|
// line = layout->lines;
|
||||||
// gfx_clip(x, y, layout->w, layout->h);
|
// gfx_clip(x, y, layout->w, layout->h);
|
||||||
|
if (!lay)
|
||||||
|
return;
|
||||||
if (!line)
|
if (!line)
|
||||||
line = layout->lines;
|
line = layout->lines;
|
||||||
for (; line; line= line->next) {
|
for (; line; line= line->next) {
|
||||||
|
@ -1947,7 +1961,7 @@ void txt_box_norm(textbox_t tbox)
|
||||||
struct line *line;
|
struct line *line;
|
||||||
int off = box->off;
|
int off = box->off;
|
||||||
|
|
||||||
if (!box->lay)
|
if (!tbox || !box->lay)
|
||||||
return;
|
return;
|
||||||
box->line = box->lay->lines;
|
box->line = box->lay->lines;
|
||||||
for (line = box->line; line; line = line->next) {
|
for (line = box->line; line; line = line->next) {
|
||||||
|
@ -1961,12 +1975,16 @@ void txt_box_norm(textbox_t tbox)
|
||||||
layout_t txt_box_layout(textbox_t tbox)
|
layout_t txt_box_layout(textbox_t tbox)
|
||||||
{
|
{
|
||||||
struct textbox *box = (struct textbox *)tbox;
|
struct textbox *box = (struct textbox *)tbox;
|
||||||
|
if (!box)
|
||||||
|
return NULL;
|
||||||
return box->lay;
|
return box->lay;
|
||||||
}
|
}
|
||||||
|
|
||||||
void txt_box_set(textbox_t tbox, layout_t lay)
|
void txt_box_set(textbox_t tbox, layout_t lay)
|
||||||
{
|
{
|
||||||
struct textbox *box = (struct textbox *)tbox;
|
struct textbox *box = (struct textbox *)tbox;
|
||||||
|
if (!box)
|
||||||
|
return;
|
||||||
box->lay = (struct layout*)lay;
|
box->lay = (struct layout*)lay;
|
||||||
box->off = 0;
|
box->off = 0;
|
||||||
if (lay)
|
if (lay)
|
||||||
|
@ -1977,6 +1995,8 @@ void txt_box_set(textbox_t tbox, layout_t lay)
|
||||||
void txt_box_resize(textbox_t tbox, int w, int h)
|
void txt_box_resize(textbox_t tbox, int w, int h)
|
||||||
{
|
{
|
||||||
struct textbox *box = (struct textbox *)tbox;
|
struct textbox *box = (struct textbox *)tbox;
|
||||||
|
if (!tbox)
|
||||||
|
return;
|
||||||
box->w = w;
|
box->w = w;
|
||||||
box->h = h;
|
box->h = h;
|
||||||
txt_box_norm(tbox);
|
txt_box_norm(tbox);
|
||||||
|
@ -1997,7 +2017,10 @@ void txt_box_scroll_next(textbox_t tbox, int disp)
|
||||||
{
|
{
|
||||||
int off, h;
|
int off, h;
|
||||||
struct textbox *box = (struct textbox *)tbox;
|
struct textbox *box = (struct textbox *)tbox;
|
||||||
struct line *line = box->line;
|
struct line *line;
|
||||||
|
if (!tbox)
|
||||||
|
return;
|
||||||
|
line = box->line;
|
||||||
if (!line)
|
if (!line)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -2024,7 +2047,10 @@ void txt_box_scroll_prev(textbox_t tbox, int disp)
|
||||||
{
|
{
|
||||||
int off;
|
int off;
|
||||||
struct textbox *box = (struct textbox *)tbox;
|
struct textbox *box = (struct textbox *)tbox;
|
||||||
struct line *line = box->line;
|
struct line *line;
|
||||||
|
if (!tbox)
|
||||||
|
return;
|
||||||
|
line = box->line;
|
||||||
if (!line)
|
if (!line)
|
||||||
return;
|
return;
|
||||||
off = box->off - line->y; /* offset from cur line */
|
off = box->off - line->y; /* offset from cur line */
|
||||||
|
@ -2044,6 +2070,8 @@ void txt_box_scroll_prev(textbox_t tbox, int disp)
|
||||||
|
|
||||||
void txt_box_scroll(textbox_t tbox, int disp)
|
void txt_box_scroll(textbox_t tbox, int disp)
|
||||||
{
|
{
|
||||||
|
if (!tbox)
|
||||||
|
return;
|
||||||
if (disp >0)
|
if (disp >0)
|
||||||
return txt_box_scroll_next(tbox, disp);
|
return txt_box_scroll_next(tbox, disp);
|
||||||
else if (disp <0)
|
else if (disp <0)
|
||||||
|
@ -2053,7 +2081,10 @@ void txt_box_scroll(textbox_t tbox, int disp)
|
||||||
void txt_box_next_line(textbox_t tbox)
|
void txt_box_next_line(textbox_t tbox)
|
||||||
{
|
{
|
||||||
struct textbox *box = (struct textbox *)tbox;
|
struct textbox *box = (struct textbox *)tbox;
|
||||||
struct line *line = box->line;
|
struct line *line;
|
||||||
|
if (!box || !box->lay)
|
||||||
|
return;
|
||||||
|
line = box->line;
|
||||||
if (!line)
|
if (!line)
|
||||||
return;
|
return;
|
||||||
// txt_box_norm(tbox);
|
// txt_box_norm(tbox);
|
||||||
|
@ -2069,7 +2100,10 @@ void txt_box_next_line(textbox_t tbox)
|
||||||
void txt_box_prev_line(textbox_t tbox)
|
void txt_box_prev_line(textbox_t tbox)
|
||||||
{
|
{
|
||||||
struct textbox *box = (struct textbox *)tbox;
|
struct textbox *box = (struct textbox *)tbox;
|
||||||
struct line *line = box->line;
|
struct line *line;
|
||||||
|
if (!box || !box->lay)
|
||||||
|
return;
|
||||||
|
line = box->line;
|
||||||
if (!line)
|
if (!line)
|
||||||
return;
|
return;
|
||||||
line = line->prev;
|
line = line->prev;
|
||||||
|
@ -2083,13 +2117,18 @@ void txt_box_prev_line(textbox_t tbox)
|
||||||
int txt_box_off(textbox_t tbox)
|
int txt_box_off(textbox_t tbox)
|
||||||
{
|
{
|
||||||
struct textbox *box = (struct textbox *)tbox;
|
struct textbox *box = (struct textbox *)tbox;
|
||||||
|
if (!box)
|
||||||
|
return -1;
|
||||||
return box->off;
|
return box->off;
|
||||||
}
|
}
|
||||||
|
|
||||||
void txt_box_next(textbox_t tbox)
|
void txt_box_next(textbox_t tbox)
|
||||||
{
|
{
|
||||||
struct textbox *box = (struct textbox *)tbox;
|
struct textbox *box = (struct textbox *)tbox;
|
||||||
struct line *line = box->line;
|
struct line *line;
|
||||||
|
if (!tbox)
|
||||||
|
return;
|
||||||
|
line = box->line;
|
||||||
if (!line)
|
if (!line)
|
||||||
return;
|
return;
|
||||||
for (; line; line = line->next) {
|
for (; line; line = line->next) {
|
||||||
|
@ -2105,8 +2144,14 @@ void txt_box_next(textbox_t tbox)
|
||||||
void txt_box_prev(textbox_t tbox)
|
void txt_box_prev(textbox_t tbox)
|
||||||
{
|
{
|
||||||
struct textbox *box = (struct textbox *)tbox;
|
struct textbox *box = (struct textbox *)tbox;
|
||||||
struct layout *lay = box->lay;
|
struct layout *lay;
|
||||||
struct line *line = box->line;
|
struct line *line;
|
||||||
|
if (!tbox)
|
||||||
|
return;
|
||||||
|
lay = box->lay;
|
||||||
|
if (!lay)
|
||||||
|
return;
|
||||||
|
line = box->line;
|
||||||
if (!line)
|
if (!line)
|
||||||
return;
|
return;
|
||||||
for (; line; line = line->prev) {
|
for (; line; line = line->prev) {
|
||||||
|
@ -2128,7 +2173,8 @@ xref_t txt_box_xrefs(textbox_t tbox)
|
||||||
struct xref *xref = NULL;
|
struct xref *xref = NULL;
|
||||||
struct word *word = NULL;
|
struct word *word = NULL;
|
||||||
struct line *line;
|
struct line *line;
|
||||||
|
if (!tbox)
|
||||||
|
return NULL;
|
||||||
for (line = box->line; line; line = line->next) {
|
for (line = box->line; line; line = line->next) {
|
||||||
if (line->y < box->off)
|
if (line->y < box->off)
|
||||||
continue; /* too high */
|
continue; /* too high */
|
||||||
|
@ -2150,6 +2196,8 @@ xref_t txt_box_xref(textbox_t tbox, int x, int y)
|
||||||
struct xref *xref = NULL;
|
struct xref *xref = NULL;
|
||||||
struct word *word = NULL;
|
struct word *word = NULL;
|
||||||
struct line *line;
|
struct line *line;
|
||||||
|
if (!tbox)
|
||||||
|
return NULL;
|
||||||
y += box->off;
|
y += box->off;
|
||||||
if (x < 0)
|
if (x < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -2182,6 +2230,8 @@ xref_t txt_box_xref(textbox_t tbox, int x, int y)
|
||||||
|
|
||||||
void txt_box_free(textbox_t tbox)
|
void txt_box_free(textbox_t tbox)
|
||||||
{
|
{
|
||||||
|
if (!tbox)
|
||||||
|
return;
|
||||||
free(tbox);
|
free(tbox);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2190,6 +2240,8 @@ img_t txt_box_render(textbox_t tbox)
|
||||||
SDL_Surface *old_screen;
|
SDL_Surface *old_screen;
|
||||||
img_t dst;
|
img_t dst;
|
||||||
struct textbox *box = (struct textbox *)tbox;
|
struct textbox *box = (struct textbox *)tbox;
|
||||||
|
if (!tbox)
|
||||||
|
return NULL;
|
||||||
dst = gfx_new(box->w, box->h);
|
dst = gfx_new(box->w, box->h);
|
||||||
if (!dst)
|
if (!dst)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -2207,6 +2259,8 @@ img_t txt_box_render(textbox_t tbox)
|
||||||
void txt_box_draw(textbox_t tbox, int x, int y)
|
void txt_box_draw(textbox_t tbox, int x, int y)
|
||||||
{
|
{
|
||||||
struct textbox *box = (struct textbox *)tbox;
|
struct textbox *box = (struct textbox *)tbox;
|
||||||
|
if (!tbox)
|
||||||
|
return;
|
||||||
gfx_clip(x, y, box->w, box->h);
|
gfx_clip(x, y, box->w, box->h);
|
||||||
// printf("line: %d\n", box->line->y);
|
// printf("line: %d\n", box->line->y);
|
||||||
txt_layout_draw_ex(box->lay, box->line, x, y - box->off, box->off, box->h, NULL);
|
txt_layout_draw_ex(box->lay, box->line, x, y - box->off, box->off, box->h, NULL);
|
||||||
|
@ -2216,6 +2270,8 @@ void txt_box_draw(textbox_t tbox, int x, int y)
|
||||||
void txt_box_update_links(textbox_t tbox, int x, int y, clear_fn clear)
|
void txt_box_update_links(textbox_t tbox, int x, int y, clear_fn clear)
|
||||||
{
|
{
|
||||||
struct textbox *box = (struct textbox *)tbox;
|
struct textbox *box = (struct textbox *)tbox;
|
||||||
|
if (!tbox)
|
||||||
|
return;
|
||||||
gfx_clip(x, y, box->w, box->h);
|
gfx_clip(x, y, box->w, box->h);
|
||||||
// printf("line: %d\n", box->line->y);
|
// printf("line: %d\n", box->line->y);
|
||||||
txt_layout_draw_ex(box->lay, box->line, x, y - box->off, box->off, box->h, clear);
|
txt_layout_draw_ex(box->lay, box->line, x, y - box->off, box->off, box->h, clear);
|
||||||
|
@ -2624,7 +2680,7 @@ xref_t txt_layout_xref(layout_t lay, int x, int y)
|
||||||
struct word *word;
|
struct word *word;
|
||||||
struct line *line;
|
struct line *line;
|
||||||
int i;
|
int i;
|
||||||
if (x < 0 || y < 0)
|
if (!lay || x < 0 || y < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
for (xref = layout->xrefs; xref; xref = xref->next) {
|
for (xref = layout->xrefs; xref; xref = xref->next) {
|
||||||
for (i = 0; i < xref->num; i ++) {
|
for (i = 0; i < xref->num; i ++) {
|
||||||
|
|
|
@ -24,6 +24,8 @@ static int parse_inv_mode(const char *v, void *data)
|
||||||
*i = INV_MODE_VERT;
|
*i = INV_MODE_VERT;
|
||||||
else if (!strcmp(v, "horizontal") || !strcmp(v, "1"))
|
else if (!strcmp(v, "horizontal") || !strcmp(v, "1"))
|
||||||
*i = INV_MODE_HORIZ;
|
*i = INV_MODE_HORIZ;
|
||||||
|
else if (!strcmp(v, "disabled") || !strcmp(v, "-1"))
|
||||||
|
*i = INV_MODE_DISABLED;
|
||||||
else
|
else
|
||||||
return -1;
|
return -1;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -116,6 +116,7 @@ extern int theme_img_scale(img_t *p);
|
||||||
#define GFX_MODE_FIXED 1
|
#define GFX_MODE_FIXED 1
|
||||||
#define GFX_MODE_EMBEDDED 2
|
#define GFX_MODE_EMBEDDED 2
|
||||||
|
|
||||||
|
#define INV_MODE_DISABLED -1
|
||||||
#define INV_MODE_VERT 0
|
#define INV_MODE_VERT 0
|
||||||
#define INV_MODE_HORIZ 1
|
#define INV_MODE_HORIZ 1
|
||||||
|
|
||||||
|
|
Reference in a new issue