mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-25 05:21:16 +00:00
- updated common code from screenjob branch.
That is, all parts not related to cutscenes.
This commit is contained in:
parent
f89e6950c3
commit
c1a8776a15
16 changed files with 163 additions and 21 deletions
|
@ -102,6 +102,11 @@ void S_SetMusicCallbacks(MusicCallbacks* cb)
|
|||
if (mus_cb.OpenMusic == nullptr) mus_cb.OpenMusic = DefaultOpenMusic; // without this we are dead in the water.
|
||||
}
|
||||
|
||||
int MusicEnabled() // int return is for scripting
|
||||
{
|
||||
return mus_enabled && !nomusic;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
|
@ -632,7 +637,7 @@ static void CheckReplayGain(const char *musicname, EMidiDevice playertype, const
|
|||
|
||||
bool S_ChangeMusic(const char* musicname, int order, bool looping, bool force)
|
||||
{
|
||||
if (nomusic) return false; // skip the entire procedure if music is globally disabled.
|
||||
if (!MusicEnabled()) return false; // skip the entire procedure if music is globally disabled.
|
||||
|
||||
if (!force && PlayList.GetNumSongs())
|
||||
{ // Don't change if a playlist is active
|
||||
|
@ -854,7 +859,7 @@ void S_StopMusic (bool force)
|
|||
|
||||
CCMD (changemus)
|
||||
{
|
||||
if (!nomusic)
|
||||
if (MusicEnabled())
|
||||
{
|
||||
if (argv.argc() > 1)
|
||||
{
|
||||
|
|
|
@ -11,6 +11,7 @@ class FileReader;
|
|||
class SoundStream;
|
||||
|
||||
|
||||
int MusicEnabled();
|
||||
typedef bool(*StreamCallback)(SoundStream* stream, void* buff, int len, void* userdata);
|
||||
SoundStream *S_CreateCustomStream(size_t size, int samplerate, int numchannels, StreamCallback cb, void *userdata);
|
||||
void S_StopCustomStream(SoundStream* stream);
|
||||
|
|
|
@ -43,7 +43,14 @@
|
|||
#include "s_music.h"
|
||||
#include "m_random.h"
|
||||
#include "printf.h"
|
||||
#include "c_cvars.h"
|
||||
|
||||
CVARD(Bool, snd_enabled, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enables/disables sound effects")
|
||||
|
||||
int SoundEnabled()
|
||||
{
|
||||
return snd_enabled && !nosound && !nosfx;
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -382,7 +389,7 @@ FSoundChan *SoundEngine::StartSound(int type, const void *source,
|
|||
FVector3 pos, vel;
|
||||
FRolloffInfo *rolloff;
|
||||
|
||||
if (sound_id <= 0 || volume <= 0 || nosfx || nosound || blockNewSounds)
|
||||
if (sound_id <= 0 || volume <= 0 || nosfx || !SoundEnabled() || blockNewSounds)
|
||||
return NULL;
|
||||
|
||||
// prevent crashes.
|
||||
|
|
|
@ -429,3 +429,5 @@ inline int S_FindSound(const char* name)
|
|||
{
|
||||
return soundEngine->FindSound(name);
|
||||
}
|
||||
|
||||
int SoundEnabled();
|
||||
|
|
|
@ -98,8 +98,7 @@ unsigned FCommandBuffer::CalcCellSize(unsigned length)
|
|||
unsigned cellcount = 0;
|
||||
for (unsigned i = 0; i < length; i++)
|
||||
{
|
||||
int w;
|
||||
NewConsoleFont->GetChar(Text[i], CR_UNTRANSLATED, &w);
|
||||
int w = NewConsoleFont->GetCharWidth(Text[i]);
|
||||
cellcount += w / 9;
|
||||
}
|
||||
return cellcount;
|
||||
|
@ -112,8 +111,7 @@ unsigned FCommandBuffer::CharsForCells(unsigned cellin, bool *overflow)
|
|||
int cells = cellin;
|
||||
while (cells > 0)
|
||||
{
|
||||
int w;
|
||||
NewConsoleFont->GetChar(Text[chars++], CR_UNTRANSLATED, &w);
|
||||
int w = NewConsoleFont->GetCharWidth(Text[chars++]);
|
||||
cells -= w / 9;
|
||||
}
|
||||
*overflow = (cells < 0);
|
||||
|
|
|
@ -592,8 +592,7 @@ void C_DrawConsole ()
|
|||
|
||||
oldbottom = ConBottom;
|
||||
|
||||
if (ConsoleState == c_up && gamestate != GS_INTRO && gamestate != GS_INTERMISSION &&
|
||||
gamestate != GS_FULLCONSOLE && gamestate != GS_MENUSCREEN)
|
||||
if (ConsoleState == c_up && gamestate == GS_LEVEL)
|
||||
{
|
||||
if (NotifyStrings) NotifyStrings->Draw();
|
||||
return;
|
||||
|
@ -731,7 +730,7 @@ void C_ToggleConsole ()
|
|||
}
|
||||
if (gamestate == GS_MENUSCREEN)
|
||||
{
|
||||
gameaction = ga_fullconsole;
|
||||
if (sysCallbacks.ToggleFullConsole) sysCallbacks.ToggleFullConsole();
|
||||
togglestate = c_down;
|
||||
}
|
||||
else if (!chatmodeon && (ConsoleState == c_up || ConsoleState == c_rising) && menuactive == MENU_Off)
|
||||
|
|
|
@ -32,6 +32,8 @@ struct SystemCallbacks
|
|||
void (*ConsoleToggled)(int state);
|
||||
bool (*PreBindTexture)(FRenderState* state, FGameTexture*& tex, EUpscaleFlags& flags, int& scaleflags, int& clampmode, int& translation, int& overrideshader);
|
||||
void (*FontCharCreated)(FGameTexture* base, FGameTexture* untranslated);
|
||||
void (*ToggleFullConsole)();
|
||||
void (*StartCutscene)(bool blockui);
|
||||
};
|
||||
|
||||
extern SystemCallbacks sysCallbacks;
|
||||
|
|
|
@ -635,7 +635,7 @@ int FileSystem::GetNumForFullName (const char *name)
|
|||
//
|
||||
// FindFile
|
||||
//
|
||||
// Looks up a file by name, either eith or without path and extension
|
||||
// Looks up a file by name, either with or without path and extension
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
|
|
|
@ -291,16 +291,19 @@ FMaterial* DFrameBuffer::CreateMaterial(FGameTexture* tex, int scaleflags)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_Screen, GetWidth)
|
||||
static int ScreenGetWidth() { return twod->GetWidth(); }
|
||||
static int ScreenGetHeight() { return twod->GetHeight(); }
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(_Screen, GetWidth, ScreenGetWidth)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
ACTION_RETURN_INT(screen->GetWidth());
|
||||
ACTION_RETURN_INT(twod->GetWidth());
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_Screen, GetHeight)
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(_Screen, GetHeight, ScreenGetHeight)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
ACTION_RETURN_INT(screen->GetHeight());
|
||||
ACTION_RETURN_INT(twod->GetHeight());
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_Screen, PaletteColor)
|
||||
|
|
|
@ -564,6 +564,20 @@ DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, Substitute, StringSubst)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void StringStripRight(FString* self, const FString& junk)
|
||||
{
|
||||
if (junk.IsNotEmpty()) self->StripRight(junk);
|
||||
else self->StripRight();
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, StripRight, StringStripRight)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(FString);
|
||||
PARAM_STRING(junk);
|
||||
StringStripRight(self, junk);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void StringSplit(FString* self, TArray<FString>* tokens, const FString& delimiter, int keepEmpty)
|
||||
{
|
||||
self->Split(*tokens, delimiter, static_cast<FString::EmptyTokenType>(keepEmpty));
|
||||
|
|
|
@ -50,6 +50,8 @@
|
|||
#include "i_interface.h"
|
||||
#include "base_sbar.h"
|
||||
#include "image.h"
|
||||
#include "s_soundinternal.h"
|
||||
#include "i_time.h"
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
|
@ -696,6 +698,18 @@ DEFINE_ACTION_FUNCTION_NATIVE(FFont, GetGlyphHeight, GetGlyphHeight)
|
|||
PARAM_INT(code);
|
||||
ACTION_RETURN_INT(GetGlyphHeight(self, code));
|
||||
}
|
||||
|
||||
static int GetDefaultKerning(FFont* font)
|
||||
{
|
||||
return font->GetDefaultKerning();
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(FFont, GetDefaultKerning, GetDefaultKerning)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(FFont);
|
||||
ACTION_RETURN_INT(self->GetDefaultKerning());
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// file system
|
||||
|
@ -995,6 +1009,58 @@ DEFINE_ACTION_FUNCTION(_Console, Printf)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void StopAllSounds()
|
||||
{
|
||||
soundEngine->StopAllChannels();
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(_System, StopAllSounds, StopAllSounds)
|
||||
{
|
||||
StopAllSounds();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int PlayMusic(const FString& musname, int order, int looped)
|
||||
{
|
||||
return S_ChangeMusic(musname, order, !!looped, true);
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(_System, PlayMusic, PlayMusic)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
PARAM_STRING(name);
|
||||
PARAM_INT(order);
|
||||
PARAM_BOOL(looped);
|
||||
ACTION_RETURN_BOOL(PlayMusic(name, order, looped));
|
||||
}
|
||||
|
||||
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);
|
||||
|
|
|
@ -195,9 +195,16 @@ void I_FreezeTime(bool frozen)
|
|||
else
|
||||
{
|
||||
assert(FreezeTime != 0);
|
||||
FirstFrameStartTime += GetClockTimeNS() - FreezeTime;
|
||||
if (FirstFrameStartTime != 0) FirstFrameStartTime += GetClockTimeNS() - FreezeTime;
|
||||
FreezeTime = 0;
|
||||
I_SetFrameTime();
|
||||
}
|
||||
}
|
||||
|
||||
void I_ResetFrameTime()
|
||||
{
|
||||
// Reset the starting point of the current frame to now. For use after lengthy operations that should not result in tic accumulation.
|
||||
auto ft = CurrentFrameStartTime;
|
||||
I_SetFrameTime();
|
||||
FirstFrameStartTime += (CurrentFrameStartTime - ft);
|
||||
}
|
||||
|
|
|
@ -38,3 +38,6 @@ uint64_t I_msTimeFS();
|
|||
|
||||
// Nanosecond-accurate time
|
||||
uint64_t I_nsTime();
|
||||
|
||||
// Reset the timer after a lengthy operation
|
||||
void I_ResetFrameTime();
|
||||
|
|
|
@ -3043,6 +3043,11 @@ static void GC_MarkGameRoots()
|
|||
GC::Mark(NextToThink);
|
||||
}
|
||||
|
||||
static void System_ToggleFullConsole()
|
||||
{
|
||||
gameaction = ga_fullconsole;
|
||||
}
|
||||
|
||||
bool CheckSkipGameOptionBlock(const char* str);
|
||||
|
||||
//==========================================================================
|
||||
|
@ -3091,6 +3096,10 @@ static int D_DoomMain_Internal (void)
|
|||
nullptr,
|
||||
CheckSkipGameOptionBlock,
|
||||
System_ConsoleToggled,
|
||||
nullptr,
|
||||
nullptr,
|
||||
System_ToggleFullConsole,
|
||||
nullptr,
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -180,7 +180,7 @@ void DBot::Dofire (ticcmd_t *cmd)
|
|||
if (player->ReadyWeapon == NULL)
|
||||
return;
|
||||
|
||||
if (player->damagecount > skill.isp)
|
||||
if (player->damagecount > (unsigned)skill.isp)
|
||||
{
|
||||
first_shot = true;
|
||||
return;
|
||||
|
|
|
@ -76,11 +76,14 @@ enum EGameState
|
|||
GS_INTERMISSION,
|
||||
GS_FINALE,
|
||||
GS_DEMOSCREEN,
|
||||
GS_FULLCONSOLE, // [RH] Fullscreen console
|
||||
GS_HIDECONSOLE, // [RH] The menu just did something that should hide fs console
|
||||
GS_STARTUP, // [RH] Console is fullscreen, and game is just starting
|
||||
GS_TITLELEVEL, // [RH] A combination of GS_LEVEL and GS_DEMOSCREEN
|
||||
GS_INTRO,
|
||||
GS_CUTSCENE,
|
||||
|
||||
GS_MENUSCREEN = GS_DEMOSCREEN,
|
||||
GS_FULLCONSOLE,
|
||||
GS_HIDECONSOLE,
|
||||
GS_STARTUP,
|
||||
GS_TITLELEVEL,
|
||||
}
|
||||
|
||||
const TEXTCOLOR_BRICK = "\034A";
|
||||
|
@ -182,6 +185,26 @@ struct _ native // These are the global variables, the struct is only here to av
|
|||
native readonly double NotifyFontScale;
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
native String name;
|
||||
|
@ -389,6 +412,7 @@ struct Screen native
|
|||
native static Color PaletteColor(int index);
|
||||
native static int GetWidth();
|
||||
native static int GetHeight();
|
||||
native static Vector2 GetTextScreenSize();
|
||||
native static void Clear(int left, int top, int right, int bottom, Color color, int palcolor = -1);
|
||||
native static void Dim(Color col, double amount, int x, int y, int w, int h);
|
||||
|
||||
|
@ -495,6 +519,7 @@ struct Font native
|
|||
native static Font GetFont(Name fontname);
|
||||
native BrokenLines BreakLines(String text, int maxlen);
|
||||
native int GetGlyphHeight(int code);
|
||||
native int GetDefaultKerning();
|
||||
}
|
||||
|
||||
struct Console native
|
||||
|
@ -665,6 +690,7 @@ struct StringStruct native
|
|||
native int CodePointCount() const;
|
||||
native int, int GetNextCodePoint(int position) const;
|
||||
native void Substitute(String str, String replace);
|
||||
native void StripRight(String junk = "");
|
||||
}
|
||||
|
||||
struct Translation version("2.4")
|
||||
|
|
Loading…
Reference in a new issue