cleanup all
This commit is contained in:
parent
168e3b7751
commit
5d6c0b0973
|
@ -404,7 +404,7 @@ int game_load(int nr)
|
||||||
int game_saves_enabled(void)
|
int game_saves_enabled(void)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
instead_function("isEnableSave", NULL);
|
instead_function("instead.isEnableSave", NULL);
|
||||||
rc = instead_bretval(0);
|
rc = instead_bretval(0);
|
||||||
instead_clear();
|
instead_clear();
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -413,7 +413,7 @@ int game_saves_enabled(void)
|
||||||
int game_autosave_enabled(void)
|
int game_autosave_enabled(void)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
instead_function("isEnableAutosave", NULL);
|
instead_function("instead.isEnableAutosave", NULL);
|
||||||
rc = instead_bretval(0);
|
rc = instead_bretval(0);
|
||||||
instead_clear();
|
instead_clear();
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -435,11 +435,11 @@ int game_save(int nr)
|
||||||
{ .val = NULL, }
|
{ .val = NULL, }
|
||||||
};
|
};
|
||||||
if (nr == -1)
|
if (nr == -1)
|
||||||
instead_function("autosave", args_1); /* enable saving for -1 */
|
instead_function("instead.autosave", args_1); /* enable saving for -1 */
|
||||||
else if (!game_autosave_enabled())
|
else if (!game_autosave_enabled())
|
||||||
return 0; /* nothing todo */
|
return 0; /* nothing todo */
|
||||||
else
|
else
|
||||||
instead_function("autosave", args_0); /* enable saving for 0 */
|
instead_function("instead.autosave", args_0); /* enable saving for 0 */
|
||||||
instead_clear();
|
instead_clear();
|
||||||
}
|
}
|
||||||
snprintf(cmd, sizeof(cmd) - 1, "save %s", s);
|
snprintf(cmd, sizeof(cmd) - 1, "save %s", s);
|
||||||
|
@ -1164,7 +1164,7 @@ static int check_fading(void)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
int st;
|
int st;
|
||||||
instead_function("get_fading", NULL);
|
instead_function("instead.get_fading", NULL);
|
||||||
rc = instead_bretval(0);
|
rc = instead_bretval(0);
|
||||||
st = instead_iretval(1);
|
st = instead_iretval(1);
|
||||||
|
|
||||||
|
@ -1200,7 +1200,7 @@ static void game_autosave(void)
|
||||||
int b,r;
|
int b,r;
|
||||||
if (!curgame_dir)
|
if (!curgame_dir)
|
||||||
return;
|
return;
|
||||||
instead_function("get_autosave", NULL);
|
instead_function("instead.get_autosave", NULL);
|
||||||
b = instead_bretval(0);
|
b = instead_bretval(0);
|
||||||
r = instead_iretval(1);
|
r = instead_iretval(1);
|
||||||
instead_clear();
|
instead_clear();
|
||||||
|
@ -1216,7 +1216,7 @@ static void dec_music(void *data)
|
||||||
int rc;
|
int rc;
|
||||||
if (!curgame_dir)
|
if (!curgame_dir)
|
||||||
return;
|
return;
|
||||||
instead_function("dec_music_loop", NULL);
|
instead_function("instead.dec_music_loop", NULL);
|
||||||
rc = instead_iretval(0);
|
rc = instead_iretval(0);
|
||||||
instead_clear();
|
instead_clear();
|
||||||
if (rc == -1)
|
if (rc == -1)
|
||||||
|
@ -1237,7 +1237,7 @@ void game_music_player(void)
|
||||||
return;
|
return;
|
||||||
if (!opt_music)
|
if (!opt_music)
|
||||||
return;
|
return;
|
||||||
instead_function("get_music", NULL);
|
instead_function("instead.get_music", NULL);
|
||||||
mus = instead_retval(0);
|
mus = instead_retval(0);
|
||||||
loop = instead_iretval(1);
|
loop = instead_iretval(1);
|
||||||
unix_path(mus);
|
unix_path(mus);
|
||||||
|
@ -1330,7 +1330,7 @@ void game_sound_player(void)
|
||||||
|
|
||||||
if (!snd_volume_mus(-1))
|
if (!snd_volume_mus(-1))
|
||||||
return;
|
return;
|
||||||
instead_function("get_sound", NULL);
|
instead_function("instead.get_sound", NULL);
|
||||||
|
|
||||||
loop = instead_iretval(2);
|
loop = instead_iretval(2);
|
||||||
chan = instead_iretval(1);
|
chan = instead_iretval(1);
|
||||||
|
@ -1340,11 +1340,11 @@ void game_sound_player(void)
|
||||||
if (chan != -1) {
|
if (chan != -1) {
|
||||||
/* halt channel */
|
/* halt channel */
|
||||||
snd_halt_chan(chan, 500);
|
snd_halt_chan(chan, 500);
|
||||||
instead_function("set_sound", args); instead_clear();
|
instead_function("instead.set_sound", args); instead_clear();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
instead_function("set_sound", args); instead_clear();
|
instead_function("instead.set_sound", args); instead_clear();
|
||||||
|
|
||||||
unix_path(snd);
|
unix_path(snd);
|
||||||
w = sound_find(snd);
|
w = sound_find(snd);
|
||||||
|
@ -1356,26 +1356,18 @@ void game_sound_player(void)
|
||||||
snd_play(w, chan, loop - 1);
|
snd_play(w, chan, loop - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *norm_inv(char *invstr)
|
static char *get_inv(void)
|
||||||
{
|
{
|
||||||
char *ni;
|
char *ni;
|
||||||
struct instead_args args[] = {
|
struct instead_args args[] = {
|
||||||
{ .val = NULL, .type = INSTEAD_STR },
|
|
||||||
{ .val = NULL, .type = INSTEAD_BOOL },
|
{ .val = NULL, .type = INSTEAD_BOOL },
|
||||||
{ .val = NULL, },
|
{ .val = NULL, },
|
||||||
};
|
};
|
||||||
if (!invstr || !(*invstr))
|
args[0].val = (INV_MODE(game_theme.inv_mode) == INV_MODE_HORIZ)?"true":"false";
|
||||||
return invstr;
|
instead_function("instead.get_inv", args);
|
||||||
args[0].val = invstr;
|
|
||||||
args[1].val = (INV_MODE(game_theme.inv_mode) == INV_MODE_HORIZ)?"true":"false";
|
|
||||||
instead_function("normalize_inv", args);
|
|
||||||
ni = instead_retval(0);
|
ni = instead_retval(0);
|
||||||
instead_clear();
|
instead_clear();
|
||||||
if (ni) {
|
return ni;
|
||||||
free(invstr);
|
|
||||||
invstr = ni;
|
|
||||||
}
|
|
||||||
return invstr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int find_diff_pos(const char *p1, const char *p2)
|
static int find_diff_pos(const char *p1, const char *p2)
|
||||||
|
@ -1438,13 +1430,13 @@ int game_cmd(char *cmd)
|
||||||
if (!cmdstr)
|
if (!cmdstr)
|
||||||
goto inv; /* hackish? ok, yes it is... */
|
goto inv; /* hackish? ok, yes it is... */
|
||||||
|
|
||||||
instead_function("get_title", NULL);
|
instead_function("instead.get_title", NULL);
|
||||||
title = instead_retval(0);
|
title = instead_retval(0);
|
||||||
instead_clear();
|
instead_clear();
|
||||||
|
|
||||||
new_place = check_new_place(title);
|
new_place = check_new_place(title);
|
||||||
|
|
||||||
instead_function("get_picture", NULL);
|
instead_function("instead.get_picture", NULL);
|
||||||
pict = instead_retval(0);
|
pict = instead_retval(0);
|
||||||
instead_clear();
|
instead_clear();
|
||||||
|
|
||||||
|
@ -1522,7 +1514,9 @@ int game_cmd(char *cmd)
|
||||||
el_clear(el_ways);
|
el_clear(el_ways);
|
||||||
el_clear(el_scene);
|
el_clear(el_scene);
|
||||||
|
|
||||||
waystr = instead_cmd("way"); instead_clear();
|
instead_function("instead.get_ways", NULL);
|
||||||
|
waystr = instead_retval(0);
|
||||||
|
instead_clear();
|
||||||
|
|
||||||
if (waystr) {
|
if (waystr) {
|
||||||
waystr[strcspn(waystr,"\n")] = 0;
|
waystr[strcspn(waystr,"\n")] = 0;
|
||||||
|
@ -1595,9 +1589,7 @@ inv:
|
||||||
if (inv_enabled()) {
|
if (inv_enabled()) {
|
||||||
int off;
|
int off;
|
||||||
|
|
||||||
invstr = instead_cmd("inv"); instead_clear();
|
invstr = get_inv();
|
||||||
|
|
||||||
invstr = norm_inv(invstr);
|
|
||||||
|
|
||||||
off = txt_box_off(el_box(el_inv));
|
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);
|
||||||
|
|
|
@ -148,22 +148,7 @@ int instead_iretval(int n)
|
||||||
return 0;
|
return 0;
|
||||||
return lua_tonumber(L, n - N);
|
return lua_tonumber(L, n - N);
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
char *instead_cmd(char *s)
|
|
||||||
{
|
|
||||||
char buf[4096];
|
|
||||||
char *p;
|
|
||||||
p = encode_esc_string(s);
|
|
||||||
if (!p)
|
|
||||||
return NULL;
|
|
||||||
s = togame(p); free(p);
|
|
||||||
if (!s)
|
|
||||||
return NULL;
|
|
||||||
snprintf(buf, sizeof(buf), "return iface:cmd('%s')", s); free(s);
|
|
||||||
p = getstring(buf);
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
char *instead_cmd(char *s)
|
char *instead_cmd(char *s)
|
||||||
{
|
{
|
||||||
struct instead_args args[] = {
|
struct instead_args args[] = {
|
||||||
|
@ -180,7 +165,7 @@ char *instead_cmd(char *s)
|
||||||
free(s);
|
free(s);
|
||||||
return instead_retval(0);
|
return instead_retval(0);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
int instead_function(char *s, struct instead_args *args)
|
int instead_function(char *s, struct instead_args *args)
|
||||||
{
|
{
|
||||||
int base = 0;
|
int base = 0;
|
||||||
|
|
|
@ -106,25 +106,38 @@ iface.inv = function(self, str)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
iface.ways = function(self, str)
|
iface.ways = function(self, str)
|
||||||
if str then
|
|
||||||
str = stead.string.gsub(str, '\\'..stead.delim, '<&delim;>');
|
|
||||||
str = stead.string.gsub(str, stead.delim, game.gui.ways_delim);
|
|
||||||
str = stead.string.gsub(str, '<&delim;>', stead.delim);
|
|
||||||
return '<c>'..str..'</c>';
|
|
||||||
end
|
|
||||||
return str
|
return str
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function normalize_inv(str, horiz)
|
function get_inv(horiz)
|
||||||
str = stead.string.gsub(str, '\\'..stead.delim, '<&delim;>'):gsub(stead.delim..'$', '')
|
str = iface:cmd("inv");
|
||||||
if not horiz then
|
if str then
|
||||||
str = stead.string.gsub(str, stead.delim, game.gui.inv_delim);
|
str = stead.string.gsub(str, '\n$','');
|
||||||
else
|
str = stead.string.gsub(str, '\\'..stead.delim, '<&delim;>')
|
||||||
str = stead.string.gsub(str, stead.delim, game.gui.hinv_delim);
|
str = stead.string.gsub(str, stead.delim..'$', '')
|
||||||
|
if not horiz then
|
||||||
|
str = stead.string.gsub(str, stead.delim, game.gui.inv_delim);
|
||||||
|
else
|
||||||
|
str = stead.string.gsub(str, stead.delim, game.gui.hinv_delim);
|
||||||
|
end
|
||||||
|
str = stead.string.gsub(str, '<&delim;>', stead.delim);
|
||||||
end
|
end
|
||||||
str = stead.string.gsub(str, '<&delim;>', stead.delim);
|
|
||||||
return str
|
return str
|
||||||
end
|
end
|
||||||
|
instead.get_inv = get_inv;
|
||||||
|
|
||||||
|
function get_ways()
|
||||||
|
str = iface:cmd("way");
|
||||||
|
if str then
|
||||||
|
str = stead.string.gsub(str, '\n$','');
|
||||||
|
str = stead.string.gsub(str, '\\'..stead.delim, '<&delim;>');
|
||||||
|
str = stead.string.gsub(str, stead.delim, game.gui.ways_delim);
|
||||||
|
str = stead.string.gsub(str, '<&delim;>', stead.delim);
|
||||||
|
return iface:center(str);
|
||||||
|
end
|
||||||
|
return str
|
||||||
|
end
|
||||||
|
instead.get_ways = get_ways;
|
||||||
|
|
||||||
function get_title()
|
function get_title()
|
||||||
local s
|
local s
|
||||||
|
@ -140,6 +153,20 @@ function get_title()
|
||||||
return s
|
return s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
instead.get_title = get_title;
|
||||||
|
instead.get_picture = get_picture;
|
||||||
|
instead.get_music = get_music;
|
||||||
|
instead.get_sound = get_sound;
|
||||||
|
instead.set_sound = set_sound;
|
||||||
|
instead.get_autosave = get_autosave;
|
||||||
|
instead.get_music_loop = get_music_loop;
|
||||||
|
instead.dec_music_loop = dec_music_loop;
|
||||||
|
|
||||||
|
instead.isEnableSave = isEnableSave;
|
||||||
|
instead.isEnableAutosave = isEnableAutosave;
|
||||||
|
instead.autosave = autosave;
|
||||||
|
|
||||||
|
|
||||||
-- here is gui staff only
|
-- here is gui staff only
|
||||||
function stat(v)
|
function stat(v)
|
||||||
v.status_type = true
|
v.status_type = true
|
||||||
|
@ -258,7 +285,7 @@ function isFading() --to check fading from sdl gui
|
||||||
return g and r ~= false, v
|
return g and r ~= false, v
|
||||||
end
|
end
|
||||||
|
|
||||||
function get_fading()
|
instead.get_fading = function()
|
||||||
local r, v
|
local r, v
|
||||||
r, v = isFading()
|
r, v = isFading()
|
||||||
if v == nil then v = game.gui.fading end
|
if v == nil then v = game.gui.fading end
|
||||||
|
|
Reference in a new issue