summaryrefslogtreecommitdiff
path: root/plugins/MirLua
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2016-06-16 08:03:15 +0000
committerAlexander Lantsev <aunsane@gmail.com>2016-06-16 08:03:15 +0000
commit379d05e49fd38452c8071ff4069bd8d54b6e7b01 (patch)
tree19fb2622327a5255222df076447ff1486ab3f650 /plugins/MirLua
parentc990f4c72d79cc5b70d7c27d2acfce906e5f6100 (diff)
MirLua: fixed m_options module
git-svn-id: http://svn.miranda-ng.org/main/trunk@16990 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua')
-rw-r--r--plugins/MirLua/res/resource.rc11
-rw-r--r--plugins/MirLua/src/m_options.cpp34
2 files changed, 31 insertions, 14 deletions
diff --git a/plugins/MirLua/res/resource.rc b/plugins/MirLua/res/resource.rc
index 85d91554d8..66744b2c00 100644
--- a/plugins/MirLua/res/resource.rc
+++ b/plugins/MirLua/res/resource.rc
@@ -86,6 +86,13 @@ BEGIN
CONTROL "Popup on obsolete methods",IDC_POPUPONOBSOLETE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,21,294,10
END
+IDD_SCRIPTOPTIONSPAGE DIALOGEX 0, 0, 310, 250
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
+EXSTYLE WS_EX_CONTROLPARENT
+FONT 8, "MS Shell Dlg", 0, 0, 0x1
+BEGIN
+END
+
/////////////////////////////////////////////////////////////////////////////
//
@@ -101,6 +108,10 @@ BEGIN
VERTGUIDE, 302
HORZGUIDE, 242
END
+
+ IDD_SCRIPTOPTIONSPAGE, DIALOG
+ BEGIN
+ END
END
#endif // APSTUDIO_INVOKED
diff --git a/plugins/MirLua/src/m_options.cpp b/plugins/MirLua/src/m_options.cpp
index f41d4b6006..fb74776ca8 100644
--- a/plugins/MirLua/src/m_options.cpp
+++ b/plugins/MirLua/src/m_options.cpp
@@ -3,13 +3,13 @@
class CMLuaScriptOptionPage : public CDlgBase
{
private:
- CMLuaScript *script;
+ lua_State *L;
int onInitDialogRef;
int onApplyRef;
public:
- CMLuaScriptOptionPage(CMLuaScript *script, int onInitDialogRef, int onApplyRef)
- : CDlgBase(g_hInstance, IDD_SCRIPTOPTIONSPAGE), script(script),
+ CMLuaScriptOptionPage(lua_State *L, int onInitDialogRef, int onApplyRef)
+ : CDlgBase(g_hInstance, IDD_SCRIPTOPTIONSPAGE), L(L),
onInitDialogRef(onInitDialogRef), onApplyRef(onApplyRef)
{
}
@@ -19,10 +19,10 @@ protected:
{
if (onInitDialogRef)
{
- lua_rawgeti(script->L, LUA_REGISTRYINDEX, onInitDialogRef);
+ lua_rawgeti(L, LUA_REGISTRYINDEX, onInitDialogRef);
- lua_pushlightuserdata(script->L, (void*)this->GetHwnd());
- luaM_pcall(script->L, 1, 0);
+ lua_pushlightuserdata(L, (void*)this->GetHwnd());
+ luaM_pcall(L, 1, 0);
}
}
@@ -30,20 +30,24 @@ protected:
{
if (onApplyRef)
{
- lua_rawgeti(script->L, LUA_REGISTRYINDEX, onApplyRef);
+ lua_rawgeti(L, LUA_REGISTRYINDEX, onApplyRef);
- lua_pushlightuserdata(script->L, (void*)this->GetHwnd());
- luaM_pcall(script->L, 1, 0);
+ lua_pushlightuserdata(L, (void*)this->GetHwnd());
+ luaM_pcall(L, 1, 0);
}
}
+
+ void OnDestroy()
+ {
+ lua_pushnil(L);
+ lua_rawsetp(L, LUA_REGISTRYINDEX, this);
+ }
};
void MakeOptionDialogPage(lua_State *L, OPTIONSDIALOGPAGE &odp)
{
- CMLuaScript *script = CMLuaScript::GetScriptFromEnviroment(L);
-
odp.hInstance = g_hInstance;
- odp.hLangpack = script->GetId();
+ odp.hLangpack = CMLuaScript::GetScriptIdFromEnviroment(L);
lua_getfield(L, -1, "Flags");
odp.flags = luaL_optinteger(L, -1, ODPF_BOLDGROUPS | ODPF_TCHAR | ODPF_DONTTRANSLATE);
@@ -77,8 +81,10 @@ void MakeOptionDialogPage(lua_State *L, OPTIONSDIALOGPAGE &odp)
onApplyRef = luaL_ref(L, LUA_REGISTRYINDEX);
else
lua_pop(L, 1);
-
- odp.pDialog = new CMLuaScriptOptionPage(script, onInitDialogRef, onApplyRef);
+
+ lua_State *T = lua_newthread(L);
+ lua_rawsetp(L, LUA_REGISTRYINDEX, T);
+ odp.pDialog = new CMLuaScriptOptionPage(T, onInitDialogRef, onApplyRef);
}
int opt_AddPage(lua_State *L)