Skip to content

Commit

Permalink
Add closeMudlet() to the Lua api. (Mudlet#917)
Browse files Browse the repository at this point in the history
Saves and closes all profiles from within Mudlet and closes the application.
  • Loading branch information
itsTheFae authored and ahmedcharles committed Apr 17, 2017
1 parent de64759 commit 07e9c43
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/TLuaInterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2468,6 +2468,12 @@ int TLuaInterpreter::killTrigger( lua_State *L )
return 1;
}

int TLuaInterpreter::closeMudlet(lua_State* L)
{
mudlet::self()->forceClose();
return 0;
}

// openUserWindow( session, string window_name )
int TLuaInterpreter::openUserWindow( lua_State *L )
{
Expand Down Expand Up @@ -13081,6 +13087,7 @@ void TLuaInterpreter::initLuaGlobals()
lua_register( pGlobalLua, "tempTimer", TLuaInterpreter::tempTimer );
lua_register( pGlobalLua, "tempTrigger", TLuaInterpreter::tempTrigger );
lua_register( pGlobalLua, "tempRegexTrigger", TLuaInterpreter::tempRegexTrigger );
lua_register( pGlobalLua, "closeMudlet", TLuaInterpreter::closeMudlet);
lua_register( pGlobalLua, "openUserWindow", TLuaInterpreter::openUserWindow );
lua_register( pGlobalLua, "echoUserWindow", TLuaInterpreter::echoUserWindow );
lua_register( pGlobalLua, "enableTimer", TLuaInterpreter::enableTimer );
Expand Down
1 change: 1 addition & 0 deletions src/TLuaInterpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ class TLuaInterpreter : public QThread
static int setFgColor( lua_State * L );
static int setBgColor( lua_State * L );
static int tempTimer( lua_State * L );
static int closeMudlet( lua_State* L );
static int openUserWindow( lua_State * L );
static int echoUserWindow( lua_State * L );
static int clearUserWindow( lua_State * L );
Expand Down
8 changes: 8 additions & 0 deletions src/mudlet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1726,6 +1726,14 @@ void mudlet::closeEvent(QCloseEvent *event)
qApp->quit();
}

void mudlet::forceClose()
{
for (auto console : mConsoleMap) {
console->mUserAgreedToCloseConsole = true;
}

close();
}

void mudlet::readSettings()
{
Expand Down
1 change: 1 addition & 0 deletions src/mudlet.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class mudlet : public QMainWindow, public Ui::MainWindow
Host * getActiveHost();
void registerTimer( TTimer *, QTimer * );
void unregisterTimer( QTimer * );
void forceClose();
bool openWindow( Host *, const QString & );
bool createMiniConsole( Host *, const QString &, int, int, int, int );
bool createLabel( Host *, const QString &, int, int, int, int, bool );
Expand Down

0 comments on commit 07e9c43

Please sign in to comment.