From 6db355a9473b9b774be66c39cfefd74d841791fd Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 14 Mar 2017 10:41:13 +0100 Subject: [PATCH] - added a callback to menu items for when a new menu gets created. - added a StartSlideshow ACS and ZScript command and extended the functionality to specify the slideshow's name when starting it. This is for triggering any kind of intermission definition in the middle of a level - keep in mind that this may not be set up to loop! --- src/g_game.cpp | 17 ++++++++++++++++- src/g_game.h | 1 + src/p_acs.cpp | 6 ++++++ wadsrc/static/zscript/base.txt | 2 +- wadsrc/static/zscript/menu/listmenu.txt | 5 +++++ wadsrc/static/zscript/menu/menuitembase.txt | 1 + wadsrc/static/zscript/menu/optionmenu.txt | 6 ++++++ wadsrc/static/zscript/strife/strifeitems.txt | 2 +- 8 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/g_game.cpp b/src/g_game.cpp index 4bb55ad49..06fd1db95 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -147,6 +147,7 @@ CVAR(Int, nametagcolor, CR_GOLD, CVAR_ARCHIVE) gameaction_t gameaction; gamestate_t gamestate = GS_STARTUP; +FName SelectedSlideshow; // what to start when ga_slideshow int paused; bool pauseext; @@ -1119,7 +1120,7 @@ void G_Ticker () G_DoCompleted (); break; case ga_slideshow: - if (gamestate == GS_LEVEL) F_StartIntermission(level.info->slideshow, FSTATE_InLevel); + if (gamestate == GS_LEVEL) F_StartIntermission(SelectedSlideshow, FSTATE_InLevel); break; case ga_worlddone: G_DoWorldDone (); @@ -2983,6 +2984,20 @@ bool G_CheckDemoStatus (void) return false; } +void G_StartSlideshow(FName whichone) +{ + gameaction = ga_slideshow; + SelectedSlideshow = whichone == NAME_None ? level.info->slideshow : whichone; +} + +DEFINE_ACTION_FUNCTION(FLevelLocals, StartSlideshow) +{ + PARAM_PROLOGUE; + PARAM_NAME_DEF(whichone); + G_StartSlideshow(whichone); + return 0; +} + DEFINE_GLOBAL(players) DEFINE_GLOBAL(playeringame) DEFINE_GLOBAL(PlayerClasses) diff --git a/src/g_game.h b/src/g_game.h index f3f774039..0bfc498dd 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -64,6 +64,7 @@ void G_Ticker (void); bool G_Responder (event_t* ev); void G_ScreenShot (char *filename); +void G_StartSlideshow(FName whichone); FString G_BuildSaveName (const char *prefix, int slot); diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 99e092b28..c2f40e825 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -62,6 +62,7 @@ #include "r_sky.h" #include "gstrings.h" #include "gi.h" +#include "g_game.h" #include "sc_man.h" #include "c_bind.h" #include "info.h" @@ -4961,6 +4962,7 @@ enum EACSFunctions ACSF_Round, ACSF_Ceil, ACSF_ScriptCall, + ACSF_StartSlideshow, // OpenGL stuff @@ -6808,6 +6810,10 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) case ACSF_ScriptCall: return ScriptCall(argCount, args); + case ACSF_StartSlideshow: + G_StartSlideshow(FName(FBehavior::StaticLookupString(args[0]))); + break; + default: break; } diff --git a/wadsrc/static/zscript/base.txt b/wadsrc/static/zscript/base.txt index e509702e6..fb50ddb63 100644 --- a/wadsrc/static/zscript/base.txt +++ b/wadsrc/static/zscript/base.txt @@ -491,7 +491,7 @@ struct LevelLocals native native int GetUDMFInt(int type, int index, Name key); native double GetUDMFFloat(int type, int index, Name key); native bool ExecuteSpecial(int special, Actor activator, line linedef, bool lineside, int arg1 = 0, int arg2 = 0, int arg3 = 0, int arg4 = 0, int arg5 = 0); - + native static void StartSlideshow(Name whichone = 'none'); } struct StringTable native diff --git a/wadsrc/static/zscript/menu/listmenu.txt b/wadsrc/static/zscript/menu/listmenu.txt index e0bb72af9..b1fbcd105 100644 --- a/wadsrc/static/zscript/menu/listmenu.txt +++ b/wadsrc/static/zscript/menu/listmenu.txt @@ -74,6 +74,11 @@ class ListMenu : Menu } } } + // notify all items that the menu was just created. + for(int i=0;i