Skip to content

Commit

Permalink
Added script function StopEvaluatingTriggers
Browse files Browse the repository at this point in the history
  • Loading branch information
nickgammon committed Feb 23, 2013
1 parent bd11114 commit 0ff3058
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 10 deletions.
10 changes: 9 additions & 1 deletion ProcessPreviousLine.cpp
Expand Up @@ -584,6 +584,8 @@ assemble the full text of the original line.
// timer t ("Process all triggers");

m_CurrentPlugin = NULL;
m_iStopTriggerEvaluation = eKeepEvaluatingTriggers;

// do main triggers
ProcessOneTriggerSequence (strCurrentLine,
StyledLine,
Expand All @@ -599,10 +601,12 @@ assemble the full text of the original line.

// do plugins
for (PluginListIterator pit = m_PluginList.begin ();
pit != m_PluginList.end ();
pit != m_PluginList.end () &&
m_iStopTriggerEvaluation != eStopEvaluatingTriggersInAllPlugins;
++pit)
{
m_CurrentPlugin = *pit;
m_iStopTriggerEvaluation = eKeepEvaluatingTriggers;
if (m_CurrentPlugin->m_bEnabled)
ProcessOneTriggerSequence (strCurrentLine,
StyledLine,
Expand Down Expand Up @@ -1402,6 +1406,10 @@ POSITION pos;
if (!trigger_item->bKeepEvaluating) // exit loop if no more evaluation wanted
break;

// exit loop if this trigger cancelled evaluation
if (m_iStopTriggerEvaluation != eKeepEvaluatingTriggers)
break;

} // end of successful evaluation
else
break;
Expand Down
2 changes: 2 additions & 0 deletions doc.cpp
Expand Up @@ -613,6 +613,7 @@ BEGIN_DISPATCH_MAP(CMUSHclientDoc, CDocument)
DISP_FUNCTION(CMUSHclientDoc, "Bookmark", Bookmark, VT_EMPTY, VTS_I4 VTS_BOOL)
DISP_FUNCTION(CMUSHclientDoc, "SetTitle", SetTitle, VT_EMPTY, VTS_BSTR)
DISP_FUNCTION(CMUSHclientDoc, "SetMainTitle", SetMainTitle, VT_EMPTY, VTS_BSTR)
DISP_FUNCTION(CMUSHclientDoc, "StopEvaluatingTriggers", StopEvaluatingTriggers, VT_EMPTY, VTS_BOOL)
DISP_PROPERTY_PARAM(CMUSHclientDoc, "NormalColour", GetNormalColour, SetNormalColour, VT_I4, VTS_I2)
DISP_PROPERTY_PARAM(CMUSHclientDoc, "BoldColour", GetBoldColour, SetBoldColour, VT_I4, VTS_I2)
DISP_PROPERTY_PARAM(CMUSHclientDoc, "CustomColourText", GetCustomColourText, SetCustomColourText, VT_I4, VTS_I2)
Expand Down Expand Up @@ -7841,3 +7842,4 @@ void CMUSHclientDoc::FixInputWrap()
} // end of for each view
} // end of CMUSHclientDoc::FixInputWrap()


16 changes: 16 additions & 0 deletions doc.h
Expand Up @@ -179,6 +179,15 @@ enum {
eHotspotCallback = 11, // miniwindow hotspot callback
};


// value for m_iStopTriggerEvaluation - should we stop trigger evaluation?

enum {
eKeepEvaluatingTriggers,
eStopEvaluatingTriggers,
eStopEvaluatingTriggersInAllPlugins
};

// MCCP (Mud Client Compression Protocol) stuff

// NB 85 is MCCP v1, 86 is MCCP v2
Expand Down Expand Up @@ -1340,6 +1349,12 @@ class CMUSHclientDoc : public CDocument
CString m_strWindowTitle; // for SetTitle
CString m_strMainWindowTitle; // for SetMainTitle


// see enum above: eKeepEvaluatingTriggers, eStopEvaluatingTriggers,
// eStopEvaluatingTriggersInAllPlugins

unsigned short m_iStopTriggerEvaluation;

#ifdef PANE
// for pane windows

Expand Down Expand Up @@ -2766,6 +2781,7 @@ class CMUSHclientDoc : public CDocument
afx_msg void Bookmark(long LineNumber, BOOL Set);
afx_msg void SetTitle(LPCTSTR Title);
afx_msg void SetMainTitle(LPCTSTR Title);
afx_msg void StopEvaluatingTriggers(BOOL AllPlugins);
afx_msg long GetNormalColour(short WhichColour);
afx_msg void SetNormalColour(short WhichColour, long nNewValue);
afx_msg long GetBoldColour(short WhichColour);
Expand Down
1 change: 1 addition & 0 deletions mushclient.cnt
Expand Up @@ -510,6 +510,7 @@
3 SpellCheckDlg=FNC_SpellCheckDlg
3 StripANSI=FNC_StripANSI
3 StopSound=FNC_StopSound
3 StopEvaluatingTriggers=FNT_StopEvaluatingTriggers
3 Tell=FNC_Tell
3 TextRectangle=FNC_TextRectangle
3 Trace=FNC_Trace
Expand Down
17 changes: 9 additions & 8 deletions mushclient.odl
Expand Up @@ -70,14 +70,14 @@ library MUSHclient
[id(44)] long SetCommand(BSTR Message);
[id(45)] BSTR GetNotes();
[id(46)] void SetNotes(BSTR Message);
[id(411), propget] long NormalColour(short WhichColour);
[id(411), propput] void NormalColour(short WhichColour, long nNewValue);
[id(412), propget] long BoldColour(short WhichColour);
[id(412), propput] void BoldColour(short WhichColour, long nNewValue);
[id(413), propget] long CustomColourText(short WhichColour);
[id(413), propput] void CustomColourText(short WhichColour, long nNewValue);
[id(414), propget] long CustomColourBackground(short WhichColour);
[id(414), propput] void CustomColourBackground(short WhichColour, long nNewValue);
[id(412), propget] long NormalColour(short WhichColour);
[id(412), propput] void NormalColour(short WhichColour, long nNewValue);
[id(413), propget] long BoldColour(short WhichColour);
[id(413), propput] void BoldColour(short WhichColour, long nNewValue);
[id(414), propget] long CustomColourText(short WhichColour);
[id(414), propput] void CustomColourText(short WhichColour, long nNewValue);
[id(415), propget] long CustomColourBackground(short WhichColour);
[id(415), propput] void CustomColourBackground(short WhichColour, long nNewValue);
[id(47)] void Redraw();
[id(48)] long ResetTimer(BSTR TimerName);
[id(49)] void SetOutputFont(BSTR FontName, short PointSize);
Expand Down Expand Up @@ -442,6 +442,7 @@ library MUSHclient
[id(408)] void Bookmark(long LineNumber, BOOL Set);
[id(409)] void SetTitle(BSTR Title);
[id(410)] void SetMainTitle(BSTR Title);
[id(411)] void StopEvaluatingTriggers(BOOL AllPlugins);
//}}AFX_ODL_METHOD

};
Expand Down
2 changes: 1 addition & 1 deletion resource.h
Expand Up @@ -1562,7 +1562,7 @@
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_3D_CONTROLS 1
#define _APS_NEXT_RESOURCE_VALUE 368
#define _APS_NEXT_RESOURCE_VALUE 369
#define _APS_NEXT_COMMAND_VALUE 33054
#define _APS_NEXT_CONTROL_VALUE 2897
#define _APS_NEXT_SYMED_VALUE 312
Expand Down
1 change: 1 addition & 0 deletions scripting/functionlist.cpp
Expand Up @@ -367,6 +367,7 @@ tInternalFunctionsTable InternalFunctionsTable [] = {
{ "SpellCheckCommand" , "( StartCol , EndCol )" } ,
{ "SpellCheckDlg" , "( Text )" } ,
{ "StopSound" , "( Buffer )" } ,
{ "StopEvaluatingTriggers" , "( AllPlugins )" } ,
{ "StripANSI" , "( Message )" } ,
{ "Tell" , "( Message )" } ,
{ "TextRectangle" , "( Left , Top , Right , Bottom , BorderOffset , BorderColour , BorderWidth , OutsideFillColour , OutsideFillStyle )" } ,
Expand Down
11 changes: 11 additions & 0 deletions scripting/lua_methods.cpp
Expand Up @@ -5619,6 +5619,16 @@ static int L_StopSound (lua_State *L)
return 1; // number of result fields
} // end of L_StopSound

//----------------------------------------
// world.StopEvaluatingTriggers
//----------------------------------------
static int L_StopEvaluatingTriggers (lua_State *L)
{
CMUSHclientDoc *pDoc = doc (L);
pDoc->StopEvaluatingTriggers (optboolean (L, 1, 0));
return 0; // number of result fields
} // end of L_StopEvaluatingTriggers

//----------------------------------------
// world.Tell
//----------------------------------------
Expand Down Expand Up @@ -7011,6 +7021,7 @@ static const struct luaL_Reg worldlib [] =
{"SpellCheckDlg", L_SpellCheckDlg},
{"StripANSI", L_StripANSI},
{"StopSound", L_StopSound},
{"StopEvaluatingTriggers", L_StopEvaluatingTriggers},
{"Tell", L_Tell},
{"TextRectangle", L_TextRectangle},
{"GetTrace", L_GetTrace},
Expand Down
7 changes: 7 additions & 0 deletions scripting/methods/methods_triggers.cpp
Expand Up @@ -26,6 +26,7 @@
// GetTriggerWildcard
// IsTrigger
// SetTriggerOption
// StopEvaluatingTriggers


#define TO(arg) offsetof (CTrigger, arg), sizeof (((CTrigger *)NULL)->arg)
Expand Down Expand Up @@ -892,3 +893,9 @@ CTrigger * trigger_item;
}
return vaResult;
} // end of CMUSHclientDoc::GetTriggerWildcard

void CMUSHclientDoc::StopEvaluatingTriggers(BOOL AllPlugins)
{
m_iStopTriggerEvaluation = AllPlugins ? eStopEvaluatingTriggersInAllPlugins : eStopEvaluatingTriggers;
} // end of CMUSHclientDoc::StopEvaluatingTriggers

0 comments on commit 0ff3058

Please sign in to comment.