From b2c91edc9646daa331de71d589e4fec6bdef4945 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 11 Jul 2018 17:09:17 +0300 Subject: GUI change: - methods OnInitDialog, OnApply & OnClose of CDlgBase now return true if successful. return of false prevents a dialog from being loaded or left respectively; - massive code cleaning considering the 'virtual' attribute of overridden methods; - also fixes #1476 (Don't close "Create new account" window if user not set account name) --- plugins/MirLua/src/Modules/m_options.cpp | 6 ++++-- plugins/MirLua/src/options.cpp | 9 +++++---- plugins/MirLua/src/options.h | 6 +++--- 3 files changed, 12 insertions(+), 9 deletions(-) (limited to 'plugins/MirLua') diff --git a/plugins/MirLua/src/Modules/m_options.cpp b/plugins/MirLua/src/Modules/m_options.cpp index f956885bb7..29383e89ad 100644 --- a/plugins/MirLua/src/Modules/m_options.cpp +++ b/plugins/MirLua/src/Modules/m_options.cpp @@ -14,7 +14,7 @@ public: { } - void OnInitDialog() override + bool OnInitDialog() override { if (m_onInitDialogRef) { @@ -22,9 +22,10 @@ public: lua_pushlightuserdata(L, m_hwnd); luaM_pcall(L, 1, 0); } + return true; } - void OnApply() override + bool OnApply() override { if (m_onApplyRef) { @@ -32,6 +33,7 @@ public: lua_pushlightuserdata(L, m_hwnd); luaM_pcall(L, 1, 0); } + return true; } void OnDestroy() override diff --git a/plugins/MirLua/src/options.cpp b/plugins/MirLua/src/options.cpp index f0a7827a93..f6b0f4cd51 100644 --- a/plugins/MirLua/src/options.cpp +++ b/plugins/MirLua/src/options.cpp @@ -17,8 +17,7 @@ CMLuaOptions::CMLuaOptions() static int ScriptStatusToIcon(ScriptStatus status) { - switch (status) - { + switch (status) { case ScriptStatus::None: return -1; case ScriptStatus::Loaded: @@ -41,7 +40,7 @@ void CMLuaOptions::LoadScripts() } } -void CMLuaOptions::OnInitDialog() +bool CMLuaOptions::OnInitDialog() { CDlgBase::OnInitDialog(); @@ -71,9 +70,10 @@ void CMLuaOptions::OnInitDialog() LoadScripts(); isScriptListInit = true; + return true; } -void CMLuaOptions::OnApply() +bool CMLuaOptions::OnApply() { int count = m_scripts.GetItemCount(); for (int iItem = 0; iItem < count; iItem++) { @@ -83,6 +83,7 @@ void CMLuaOptions::OnApply() else script->Enable(); } + return true; } INT_PTR CMLuaOptions::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) diff --git a/plugins/MirLua/src/options.h b/plugins/MirLua/src/options.h index fa5c6dc823..9b540bc392 100644 --- a/plugins/MirLua/src/options.h +++ b/plugins/MirLua/src/options.h @@ -14,13 +14,13 @@ private: void LoadScripts(); protected: - void OnInitDialog(); - void OnApply(); + bool OnInitDialog() override; + bool OnApply() override; void OnScriptListClick(CCtrlListView::TEventInfo *evt); void OnReload(CCtrlBase*); - INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam); + INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override; public: CMLuaOptions(); -- cgit v1.2.3