Skip to content

Commit

Permalink
- added the script side core module for the cutscene system.
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed May 22, 2021
1 parent cef7db2 commit 13d2588
Show file tree
Hide file tree
Showing 6 changed files with 601 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Expand Up @@ -1467,6 +1467,7 @@ source_group("Common\\Console" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/
source_group("Common\\Utility" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/utility/.+")
source_group("Common\\Engine" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/engine/.+")
source_group("Common\\2D" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/2d/.+")
source_group("Common\\Cutscenes" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/cutscenes/.+")
source_group("Common\\Objects" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/objects/.+")
source_group("Common\\Menu" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/menu/.+")
source_group("Common\\Fonts" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/fonts/.+")
Expand Down
40 changes: 40 additions & 0 deletions src/common/scripting/interface/vmnatives.cpp
Expand Up @@ -50,6 +50,8 @@
#include "i_interface.h"
#include "base_sbar.h"
#include "image.h"
#include "s_soundinternal.h"
#include "i_time.h"

//==========================================================================
//
Expand Down Expand Up @@ -989,6 +991,44 @@ DEFINE_ACTION_FUNCTION(_Console, Printf)
return 0;
}

static void StopAllSounds()
{
soundEngine->StopAllChannels();
}

DEFINE_ACTION_FUNCTION_NATIVE(_System, StopAllSounds, StopAllSounds)
{
StopAllSounds();
return 0;
}

static void Mus_Stop()
{
S_StopMusic(true);
}

DEFINE_ACTION_FUNCTION_NATIVE(_System, StopMusic, Mus_Stop)
{
Mus_Stop();
return 0;
}

DEFINE_ACTION_FUNCTION_NATIVE(_System, SoundEnabled, SoundEnabled)
{
ACTION_RETURN_INT(SoundEnabled());
}

DEFINE_ACTION_FUNCTION_NATIVE(_System, MusicEnabled, MusicEnabled)
{
ACTION_RETURN_INT(MusicEnabled());
}

DEFINE_ACTION_FUNCTION_NATIVE(_System, GetTimeFrac, I_GetTimeFrac)
{
ACTION_RETURN_FLOAT(I_GetTimeFrac());
}


DEFINE_GLOBAL_NAMED(mus_playing, musplaying);
DEFINE_FIELD_X(MusPlayingInfo, MusPlayingInfo, name);
DEFINE_FIELD_X(MusPlayingInfo, MusPlayingInfo, baseorder);
Expand Down
1 change: 1 addition & 0 deletions src/g_game.cpp
Expand Up @@ -3131,3 +3131,4 @@ DEFINE_GLOBAL(demoplayback)
DEFINE_GLOBAL(automapactive);
DEFINE_GLOBAL(Net_Arbitrator);
DEFINE_GLOBAL(netgame);
DEFINE_GLOBAL(paused);
1 change: 1 addition & 0 deletions wadsrc/static/zscript.txt
Expand Up @@ -5,6 +5,7 @@ version "4.5"
#include "zscript/engine/dynarrays.zs"
#include "zscript/engine/dictionary.zs"
#include "zscript/engine/inputevents.zs"
#include "zscript/engine/screenjob.zs"

#include "zscript/engine/ui/menu/colorpickermenu.zs"
#include "zscript/engine/ui/menu/joystickmenu.zs"
Expand Down
21 changes: 21 additions & 0 deletions wadsrc/static/zscript/engine/base.zs
Expand Up @@ -180,6 +180,27 @@ struct _ native // These are the global variables, the struct is only here to av
native MenuDelegateBase menuDelegate;
native readonly int consoleplayer;
native readonly double NotifyFontScale;
native readonly int paused;
}

struct System native
{
native static void StopMusic();
native static void StopAllSounds();
native static bool SoundEnabled();
native static bool MusicEnabled();
native static double GetTimeFrac();

static bool specialKeyEvent(InputEvent ev)
{
if (ev.type == InputEvent.Type_KeyDown || ev.type == InputEvent.Type_KeyUp)
{
int key = ev.KeyScan;
if (key == InputEvent.KEY_VOLUMEDOWN || key == InputEvent.KEY_VOLUMEUP || (key > InputEvent.KEY_LASTJOYBUTTON && key < InputEvent.KEY_PAD_LTHUMB_RIGHT)) return true;
}
return false;
}

}

struct MusPlayingInfo native
Expand Down

0 comments on commit 13d2588

Please sign in to comment.