2018-08-04 17:10:04 +02:00
/*
2018-11-15 21:13:52 +01:00
MetaCmd - actual steam command scripts for internal meta and control activities
2018-08-04 17:10:04 +02:00
Copyright ( C ) Lumiera . org
2018 , Hermann Vosseler < Ichthyostega @ web . de >
This program is free software ; you can redistribute it and / or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation ; either version 2 of
the License , or ( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 675 Mass Ave , Cambridge , MA 0213 9 , USA .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/** @file meta-cmd.cpp
2018-11-15 21:13:52 +01:00
* * Actual definition of Steam - Layer command scripts for meta / ctrl actions .
2018-08-04 17:10:04 +02:00
* * Any actions issued by the UI - Layer to control internal application state
* * @ todo WIP 8 / 2018 early draft
* *
* * @ see cmd . hpp
* * @ see command . hpp
* * @ see command - def . hpp
* * @ see cmd - context . hpp
* * @ see SessionCommandFunction_test
* *
*/
# include "proc/cmd.hpp"
# include "proc/control/command-def.hpp"
//#include "proc/mobject/session.hpp"
2018-10-08 05:00:06 +02:00
# include "include/ui-protocol.hpp" //////////////////////////////////////////////////////////////TICKET #1140 : verify if this include is required
2018-08-04 19:07:21 +02:00
# include "include/gui-notification-facade.h"
2018-10-06 17:42:22 +02:00
# include "gui/interact/wizard.hpp" //////////////////////////////////////////////////////////////TICKET #1140 : include needed temporarily
2018-09-29 19:04:27 +02:00
# include "lib/diff/gen-node.hpp"
2018-08-04 17:10:04 +02:00
# include "lib/idi/entry-id.hpp"
2018-10-06 17:42:22 +02:00
# include "lib/format-string.hpp" //////////////////////////////////////////////////////////////TICKET #1140 : include needed temporarily
2018-09-29 19:04:27 +02:00
//#include "lib/symbol.hpp"
2018-10-03 04:43:16 +02:00
# include "lib/util.hpp"
2018-08-04 17:10:04 +02:00
2018-09-29 13:37:48 +02:00
# include <string>
2018-08-04 17:10:04 +02:00
using lib : : hash : : LuidH ;
2018-09-29 13:37:48 +02:00
using gui : : ID ;
using gui : : NOTE_INFO ;
using gui : : NOTE_WARN ;
using gui : : NOTE_ERROR ;
using gui : : NotifyLevel ;
2018-10-08 05:00:06 +02:00
using gui : : MARK_expand ;
2018-09-29 13:37:48 +02:00
using gui : : GuiNotification ;
2018-09-29 19:04:27 +02:00
using lib : : diff : : GenNode ;
2018-08-04 17:10:04 +02:00
//using util::cStr;
2018-10-06 17:42:22 +02:00
using util : : _Fmt ; //////////////////////////////////////////////////////////////TICKET #1140 : include needed temporarily
2018-10-03 04:43:16 +02:00
using util : : isYes ;
2018-09-29 13:37:48 +02:00
using std : : string ;
2018-08-04 17:10:04 +02:00
namespace proc {
namespace cmd {
namespace error = lumiera : : error ;
//using mobject::Session;
namespace { // implementation helper...
} //(End) implementation helper
/** instruct the session to start keeping the UI up-to-date through diff messages.
* @ remarks we assume the UI is _empty_ when issuing this command . Thus the session
* will commence by sending a _population diff_ , to reflect all the UI relevant
* structures currently present within the session data . Moreover , from that point
* on , any changes within the session structure and contents will be reflected by
* pushing appropriate diff messages upwards through the GuiNotification façade .
* @ note to UNDO this action means to waive the live - update state . In addition ,
* the session will push up a status change to mark the session - root as defunct .
2018-08-04 18:45:58 +02:00
* @ todo used for preliminary integration testing ///////////////////////////////////////////TICKET #211 prefix test_ bypasses logging and immediately executes for now (2018)
2018-08-04 17:10:04 +02:00
*/
2018-08-04 18:45:58 +02:00
COMMAND_DEFINITION ( test_meta_activateContentDiff )
2018-08-04 17:10:04 +02:00
{
def . operation ( [ ] ( )
{
TODO ( " send a population diff starting from scratch " ) ;
TODO ( " activate life-update service within the session " ) ;
2018-11-15 21:13:52 +01:00
// Temporary hack to get any meaningful UI <-> Steam communication
2018-09-29 13:37:48 +02:00
GuiNotification : : facade ( ) . displayInfo ( NOTE_INFO , " Request: population-Diff from Session. " ) ;
2018-08-04 17:10:04 +02:00
} )
. captureUndo ( [ ] ( ) - > bool
{
2018-08-04 18:45:58 +02:00
return false ; ///////////////////////////////////////////////////////////TICKET #1153 : use status from service for live diff updates
2018-08-04 17:10:04 +02:00
} )
. undoOperation ( [ ] ( bool wasActive )
{
if ( not wasActive )
{
UNIMPLEMENTED ( " send a status update diff into the root node, to mark it as defunct " ) ;
2018-08-04 18:45:58 +02:00
TODO ( " clear the life-update service within the session " ) ;
}
} ) ;
} ;
/** instruct the session to start keeping the UI up-to-date through diff messages.
* @ remarks we assume the UI is _empty_ when issuing this command . Thus the session
* will commence by sending a _population diff_ , to reflect all the UI relevant
* structures currently present within the session data . Moreover , from that point
* on , any changes within the session structure and contents will be reflected by
* pushing appropriate diff messages upwards through the GuiNotification façade .
* @ note to UNDO this action means to waive the live - update state . In addition ,
* the session will push up a status change to mark the session - root as defunct .
*/
COMMAND_DEFINITION ( meta_deactivateContentDiff )
{
def . operation ( [ ] ( )
{
TODO ( " send a status update diff into the root node, to mark it as defunct " ) ;
TODO ( " clear the life-update service within the session " ) ;
} )
. captureUndo ( [ ] ( ) - > bool
{
return true ; ///////////////////////////////////////////////////////////TICKET #1153 : use status from service for live diff updates
} )
. undoOperation ( [ ] ( bool wasActive )
{
if ( wasActive )
{
UNIMPLEMENTED ( " send a diff update to completely clear the root node, then send a population diff with current session content " ) ;
TODO ( " activate life-update service within the session " ) ;
2018-08-04 17:10:04 +02:00
}
} ) ;
} ;
2018-09-29 13:37:48 +02:00
/* ===== Demo and Development ===== */
/** DemoGuiRoundtrip: push a notification info message back up into the UI.
2018-11-15 21:13:52 +01:00
* @ todo this is a demo mock setup to further development of the Steam - Stage integration //////////////TICKET #1140 : prototypical Steam-Stage communication
2018-09-29 13:37:48 +02:00
*/
COMMAND_DEFINITION ( test_meta_displayInfo )
{
2018-09-29 15:23:47 +02:00
def . operation ( [ ] ( int level , string message )
2018-09-29 13:37:48 +02:00
{
2018-09-29 15:23:47 +02:00
GuiNotification : : facade ( ) . displayInfo ( static_cast < NotifyLevel > ( level ) , message ) ;
2018-09-29 13:37:48 +02:00
} )
2018-09-29 15:23:47 +02:00
. captureUndo ( [ ] ( int level , string message ) - > string
2018-09-29 13:37:48 +02:00
{
2018-09-29 15:23:47 +02:00
return _Fmt { " displayInfo(%d, '%s') " } % level % message ;
2018-09-29 13:37:48 +02:00
} )
2018-09-29 15:23:47 +02:00
. undoOperation ( [ ] ( int , string , string uiAction )
2018-09-29 13:37:48 +02:00
{
2018-09-29 15:23:47 +02:00
GuiNotification : : facade ( ) . displayInfo ( NOTE_WARN , " can not UNDO UI-Action: " + uiAction ) ;
2018-09-29 13:37:48 +02:00
} ) ;
} ;
/** DemoGuiRoundtrip: send a `markError` message back up into the UI.
2018-11-15 21:13:52 +01:00
* @ todo this is a demo mock setup to further development of the Steam - Stage integration //////////////TICKET #1140 : prototypical Steam-Stage communication
2018-09-29 13:37:48 +02:00
*/
COMMAND_DEFINITION ( test_meta_markError )
{
def . operation ( [ ] ( string message )
{
ID errorLogID = gui : : interact : : Wizard : : getErrorLogID ( ) ;
GuiNotification : : facade ( ) . markError ( errorLogID , message ) ;
} )
2018-09-29 15:23:47 +02:00
. captureUndo ( [ ] ( string message ) - > string
2018-09-29 13:37:48 +02:00
{
2018-09-29 15:23:47 +02:00
return _Fmt { " GUI::errorLog <- markError('%s') " } % message ;
2018-09-29 13:37:48 +02:00
} )
2018-09-29 15:23:47 +02:00
. undoOperation ( [ ] ( string , string uiAction )
2018-09-29 13:37:48 +02:00
{
2018-09-29 15:23:47 +02:00
GuiNotification : : facade ( ) . displayInfo ( NOTE_WARN , " can not UNDO UI-Action: " + uiAction ) ;
2018-09-29 13:37:48 +02:00
} ) ;
} ;
/** DemoGuiRoundtrip: send a `markNote` message back up into the UI.
2018-11-15 21:13:52 +01:00
* @ todo this is a demo mock setup to further development of the Steam - Stage integration //////////////TICKET #1140 : prototypical Steam-Stage communication
2018-09-29 13:37:48 +02:00
*/
COMMAND_DEFINITION ( test_meta_markNote )
{
def . operation ( [ ] ( string message )
{
ID errorLogID = gui : : interact : : Wizard : : getErrorLogID ( ) ;
GuiNotification : : facade ( ) . markNote ( errorLogID , message ) ;
} )
2018-09-29 15:23:47 +02:00
. captureUndo ( [ ] ( string message ) - > string
2018-09-29 13:37:48 +02:00
{
2018-09-29 15:23:47 +02:00
return _Fmt { " GUI::errorLog <- markNote('%s') " } % message ;
2018-09-29 13:37:48 +02:00
} )
2018-09-29 15:23:47 +02:00
. undoOperation ( [ ] ( string , string uiAction )
2018-09-29 13:37:48 +02:00
{
2018-09-29 15:23:47 +02:00
GuiNotification : : facade ( ) . displayInfo ( NOTE_WARN , " can not UNDO UI-Action: " + uiAction ) ;
2018-09-29 13:37:48 +02:00
} ) ;
} ;
/** DemoGuiRoundtrip: send a generic `mark` message with given _action ID_ back up into the UI.
2018-11-15 21:13:52 +01:00
* @ todo this is a demo mock setup to further development of the Steam - Stage integration //////////////TICKET #1140 : prototypical Steam-Stage communication
2018-09-29 13:37:48 +02:00
*/
COMMAND_DEFINITION ( test_meta_markAction )
{
def . operation ( [ ] ( string actionID , string message )
{
ID errorLogID = gui : : interact : : Wizard : : getErrorLogID ( ) ;
2018-09-30 03:38:46 +02:00
GuiNotification : : facade ( ) . mark ( errorLogID
2018-10-08 05:00:06 +02:00
, actionID = = MARK_expand ? GenNode { actionID , isYes ( message ) }
: GenNode { actionID , message } ) ;
2018-09-29 13:37:48 +02:00
} )
2018-09-29 15:23:47 +02:00
. captureUndo ( [ ] ( string actionID , string message ) - > string
2018-09-29 13:37:48 +02:00
{
2018-09-29 15:23:47 +02:00
return _Fmt { " GUI::errorLog <- mark(%s, '%s') " } % actionID % message ;
2018-09-29 13:37:48 +02:00
} )
2018-09-29 15:23:47 +02:00
. undoOperation ( [ ] ( string , string , string uiAction )
2018-09-29 13:37:48 +02:00
{
2018-09-29 15:23:47 +02:00
GuiNotification : : facade ( ) . displayInfo ( NOTE_WARN , " can not UNDO UI-Action: " + uiAction ) ;
2018-09-29 13:37:48 +02:00
} ) ;
} ;
2018-08-04 17:10:04 +02:00
/** more to come here...*/
} } // namespace proc::cmd