mirror of
https://github.com/holub/mame
synced 2025-06-03 11:26:56 +03:00
plugins/cheat: clear popmessage (nw)
This commit is contained in:
parent
73bf0b9521
commit
b793232c97
@ -327,6 +327,7 @@ function cheat.startplugin()
|
||||
end
|
||||
|
||||
local function menu_callback(index, event)
|
||||
manager:machine():popmessage()
|
||||
if index > #cheats and event == "select" then
|
||||
index = index - #cheats
|
||||
if index == 2 then
|
||||
|
@ -243,8 +243,8 @@ function cheatfind.startplugin()
|
||||
matchsel = 1
|
||||
menu_blocks = {}
|
||||
|
||||
table = cheat.getspaces()
|
||||
for tag, list in pairs(table) do
|
||||
local space_table = cheat.getspaces()
|
||||
for tag, list in pairs(space_table) do
|
||||
if list.program then
|
||||
local ram = {}
|
||||
for num, entry in pairs(list.program.map) do
|
||||
@ -257,8 +257,8 @@ function cheatfind.startplugin()
|
||||
end
|
||||
end
|
||||
end
|
||||
table = cheat.getram()
|
||||
for tag, ram in pairs(table) do
|
||||
space_table = cheat.getram()
|
||||
for tag, ram in pairs(space_table) do
|
||||
devtable[#devtable + 1] = { tag = tag, space = ram.dev, ram = {{ offset = 0, size = ram.size }} }
|
||||
end
|
||||
end
|
||||
@ -484,10 +484,12 @@ function cheatfind.startplugin()
|
||||
_G.ce.inject(cheat)
|
||||
end
|
||||
else
|
||||
local filename = string.format("%s_%08x_cheat.json", emu.romname(), match.addr)
|
||||
local json = require("json")
|
||||
local file = io.open(string.format("%s_%08x_cheat.json", emu.romname(), match.addr), "w")
|
||||
local file = io.open(filename, "w")
|
||||
file:write(json.stringify(cheat))
|
||||
file:close()
|
||||
manager:machine():popmessage("Cheat written to " .. filename)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1720,33 +1720,35 @@ lua_engine::~lua_engine()
|
||||
close();
|
||||
}
|
||||
|
||||
int lua_engine::compile_with_env(const char *env, const char *script)
|
||||
int lua_engine::compile_with_env(const char *envname, const char *script, const char *env)
|
||||
{
|
||||
std::string field = std::string("env_").append(env);
|
||||
std::string field = std::string("env_").append(envname);
|
||||
int error;
|
||||
lua_settop(m_lua_state, 0);
|
||||
lua_getfield(m_lua_state, LUA_REGISTRYINDEX, field.c_str());
|
||||
|
||||
if(!lua_istable(m_lua_state, -1))
|
||||
{
|
||||
emu_file file(m_machine->manager().options().plugins_path(), OPEN_FLAG_READ);
|
||||
// optionally load a script to prepare the environment
|
||||
if(file.open(env, ".lua") != osd_file::error::NONE)
|
||||
{
|
||||
int error = luaL_loadfile(m_lua_state, file.fullpath());
|
||||
if(error || (error = lua_pcall(m_lua_state, 0, 0, 0) != LUA_OK))
|
||||
{
|
||||
if(error == LUA_ERRRUN)
|
||||
printf("%s\n", lua_tostring(m_lua_state, -1));
|
||||
lua_pop(m_lua_state, 1);
|
||||
}
|
||||
}
|
||||
if(!lua_istable(m_lua_state, -1))
|
||||
lua_newtable(m_lua_state);
|
||||
lua_newtable(m_lua_state);
|
||||
lua_setfield(m_lua_state, LUA_REGISTRYINDEX, field.c_str());
|
||||
lua_getfield(m_lua_state, LUA_REGISTRYINDEX, field.c_str());
|
||||
}
|
||||
|
||||
if(int error = luaL_loadstring(m_lua_state, script) != LUA_OK)
|
||||
// optionally load a string to prepare the environment
|
||||
if(env)
|
||||
{
|
||||
error = luaL_loadstring(m_lua_state, env);
|
||||
lua_pushvalue(m_lua_state, -2);
|
||||
if((error != LUA_OK) || ((error = lua_pcall(m_lua_state, 1, 0, 0)) != LUA_OK))
|
||||
{
|
||||
if((error == LUA_ERRSYNTAX) || (error == LUA_ERRRUN))
|
||||
printf("%s\n", lua_tostring(m_lua_state, -1));
|
||||
lua_pop(m_lua_state, 1);
|
||||
}
|
||||
lua_getfield(m_lua_state, LUA_REGISTRYINDEX, field.c_str());
|
||||
}
|
||||
|
||||
if((error = luaL_loadstring(m_lua_state, script)) != LUA_OK)
|
||||
{
|
||||
if(error == LUA_ERRSYNTAX)
|
||||
printf("%s\n", lua_tostring(m_lua_state, -1));
|
||||
@ -1801,6 +1803,8 @@ void lua_engine::run(const char *env, int ref)
|
||||
run_internal(env, ref);
|
||||
lua_pop(m_lua_state, 1);
|
||||
}
|
||||
// create specialization so luabridge doesn't have to be included everywhere
|
||||
template int lua_engine::run<int>(const char *env, int ref);
|
||||
|
||||
void lua_engine::run_internal(const char *env, int ref)
|
||||
{
|
||||
@ -1812,7 +1816,8 @@ void lua_engine::run_internal(const char *env, int ref)
|
||||
if(lua_isfunction(m_lua_state, -1))
|
||||
{
|
||||
lua_pushvalue(m_lua_state, -3);
|
||||
if(int error = lua_pcall(m_lua_state, 1, 1, 0) != LUA_OK)
|
||||
int error;
|
||||
if((error = lua_pcall(m_lua_state, 1, 1, 0)) != LUA_OK)
|
||||
{
|
||||
if(error == LUA_ERRRUN)
|
||||
printf("%s\n", lua_tostring(m_lua_state, -1));
|
||||
@ -1824,6 +1829,7 @@ void lua_engine::run_internal(const char *env, int ref)
|
||||
lua_replace(m_lua_state, 1);
|
||||
lua_pop(m_lua_state, 1);
|
||||
}
|
||||
|
||||
void lua_engine::menu_populate(std::string &menu, std::vector<menu_item> &menu_list)
|
||||
{
|
||||
std::string field = "menu_pop_" + menu;
|
||||
@ -1835,7 +1841,8 @@ void lua_engine::menu_populate(std::string &menu, std::vector<menu_item> &menu_l
|
||||
lua_pop(m_lua_state, 1);
|
||||
return;
|
||||
}
|
||||
if(int error = lua_pcall(m_lua_state, 0, 1, 0) != LUA_OK)
|
||||
int error;
|
||||
if((error = lua_pcall(m_lua_state, 0, 1, 0)) != LUA_OK)
|
||||
{
|
||||
if(error == LUA_ERRRUN)
|
||||
printf("%s\n", lua_tostring(m_lua_state, -1));
|
||||
@ -1881,7 +1888,8 @@ bool lua_engine::menu_callback(std::string &menu, int index, std::string event)
|
||||
{
|
||||
lua_pushinteger(m_lua_state, index);
|
||||
lua_pushstring(m_lua_state, event.c_str());
|
||||
if(int error = lua_pcall(m_lua_state, 2, 1, 0))
|
||||
int error;
|
||||
if((error = lua_pcall(m_lua_state, 2, 1, 0)) != LUA_OK)
|
||||
{
|
||||
if(error == 2)
|
||||
printf("%s\n", lua_tostring(m_lua_state, -1));
|
||||
@ -1922,7 +1930,8 @@ void lua_engine::execute_function(const char *id)
|
||||
{
|
||||
if (lua_isfunction(m_lua_state, -1))
|
||||
{
|
||||
if(int error = lua_pcall(m_lua_state, 0, 0, 0))
|
||||
int error;
|
||||
if((error = lua_pcall(m_lua_state, 0, 0, 0)) != LUA_OK)
|
||||
{
|
||||
if(error == 2)
|
||||
printf("%s\n", lua_tostring(m_lua_state, -1));
|
||||
@ -2062,8 +2071,10 @@ void lua_engine::attach_notifiers()
|
||||
int lua_engine::lua_machine::l_popmessage(lua_State *L)
|
||||
{
|
||||
running_machine *m = luabridge::Stack<running_machine *>::get(L, 1);
|
||||
luaL_argcheck(L, lua_isstring(L, 2), 2, "message (string) expected");
|
||||
m->popmessage("%s", luaL_checkstring(L, 2));
|
||||
if(!lua_isstring(L, 2))
|
||||
m->popmessage();
|
||||
else
|
||||
m->popmessage("%s", luaL_checkstring(L, 2));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -2245,6 +2256,9 @@ void lua_engine::initialize()
|
||||
.addFunction ("tag", &ioport_port::tag)
|
||||
.addFunction ("active", &ioport_port::active)
|
||||
.addFunction ("live", &ioport_port::live)
|
||||
.addFunction ("read", &ioport_port::read)
|
||||
.addFunction ("write", &ioport_port::write)
|
||||
.addFunction ("field", &ioport_port::field)
|
||||
.addProperty <luabridge::LuaRef, void> ("fields", &lua_engine::l_ioports_port_get_fields)
|
||||
.endClass()
|
||||
.beginClass <ioport_field> ("ioport_field")
|
||||
@ -2466,7 +2480,7 @@ void lua_engine::initialize()
|
||||
.addCFunction ("read", &lua_emu_file::l_emu_file_read)
|
||||
.endClass()
|
||||
// make sure there's a reference to the emu_file search path in your script as long as you need it
|
||||
// otherwise it might be garbage collected as emu_file don't copy the string
|
||||
// otherwise it might be garbage collected as emu_file doesn't copy the string
|
||||
.deriveClass <emu_file, lua_emu_file> ("file")
|
||||
.addConstructor <void (*)(const char *, UINT32)> ()
|
||||
.addFunction ("open", static_cast<osd_file::error (emu_file::*)(const char *)>(&emu_file::open))
|
||||
|
@ -63,11 +63,11 @@ public:
|
||||
void attach_notifiers();
|
||||
void on_frame_done();
|
||||
|
||||
int compile_with_env(const char *env, const char *script);
|
||||
template <typename Tout, typename Tin> Tout run(const char *env, int ref, Tin in);
|
||||
template <typename Tout> Tout run(const char *env, int ref);
|
||||
template <typename Tin> void run(const char *env, int ref, Tin in);
|
||||
void run(const char *env, int ref);
|
||||
int compile_with_env(const char *envname, const char *script, const char *env = nullptr);
|
||||
template <typename Tout, typename Tin> Tout run(const char *envname, int ref, Tin in);
|
||||
template <typename Tout> Tout run(const char *envname, int ref);
|
||||
template <typename Tin> void run(const char *envname, int ref, Tin in);
|
||||
void run(const char *envname, int ref);
|
||||
private:
|
||||
struct hook {
|
||||
lua_State *L;
|
||||
|
Loading…
Reference in New Issue
Block a user