mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-14 03:40:50 +00:00
- more Duke screen porting.
This commit is contained in:
parent
9c95f003f1
commit
7fbe153ae7
14 changed files with 241 additions and 22 deletions
|
@ -1436,13 +1436,29 @@ DEFINE_ACTION_FUNCTION(_Screen, GetViewWindow)
|
|||
return MIN(numret, 4);
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(_Build, ShadeToLight, shadeToLight)
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(_Raze, ShadeToLight, shadeToLight)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
PARAM_INT(shade);
|
||||
ACTION_RETURN_INT(shadeToLight(shade));
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(_Raze, StopAllSounds, FX_StopAllSounds)
|
||||
{
|
||||
FX_StopAllSounds();
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(_Raze, SoundEnabled, SoundEnabled)
|
||||
{
|
||||
ACTION_RETURN_INT(SoundEnabled());
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(_Raze, MusicEnabled, MusicEnabled)
|
||||
{
|
||||
ACTION_RETURN_INT(MusicEnabled());
|
||||
}
|
||||
|
||||
extern bool demoplayback;
|
||||
DEFINE_GLOBAL(multiplayer)
|
||||
DEFINE_GLOBAL(netgame)
|
||||
|
|
|
@ -70,12 +70,12 @@ extern UserConfig userConfig;
|
|||
|
||||
extern int nomusic;
|
||||
extern bool nosound;
|
||||
inline bool MusicEnabled()
|
||||
inline int MusicEnabled() // int return is for scripting
|
||||
{
|
||||
return mus_enabled && !nomusic;
|
||||
}
|
||||
|
||||
inline bool SoundEnabled()
|
||||
inline int SoundEnabled()
|
||||
{
|
||||
return snd_enabled && !nosound;
|
||||
}
|
||||
|
|
|
@ -139,10 +139,11 @@ void InitFonts_d()
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
static void BigText(double x, double y, const char* text, double alpha = 1.)
|
||||
static void BigText(double x, double y, const char* text, int align = -1, double alpha = 1.)
|
||||
{
|
||||
auto width = BigFont->StringWidth(text);
|
||||
DrawText(twod, BigFont, CR_UNTRANSLATED, x - width / 2, y - 12, text, DTA_FullscreenScale, FSMode_Fit320x200, DTA_Alpha, alpha, TAG_DONE);
|
||||
if (align != -1)
|
||||
x -= BigFont->StringWidth(text) * (align == 0 ? 0.5 : 1);
|
||||
DrawText(twod, BigFont, CR_UNTRANSLATED, x, y - 12, text, DTA_FullscreenScale, FSMode_Fit320x200, DTA_Alpha, alpha, TAG_DONE);
|
||||
}
|
||||
|
||||
static void GameText(double x, double y, const char* t, int shade, int align = -1, int trans = 0)
|
||||
|
|
|
@ -135,7 +135,6 @@ static void BigText(double x, double y, const char* text, int align, double alph
|
|||
//x *= 2.2; y *= 2.64;
|
||||
if (align != -1)
|
||||
x -= BigFont->StringWidth(text) * (align == 0 ? 0.2 : 0.4);
|
||||
auto width = BigFont->StringWidth(text);
|
||||
DrawText(twod, BigFont, CR_UNTRANSLATED, x, y - 12, text, DTA_FullscreenScale, FSMode_Fit320x200, DTA_ScaleX, 0.4, DTA_ScaleY, 0.4, DTA_Alpha, alpha, TAG_DONE);
|
||||
}
|
||||
|
||||
|
@ -576,7 +575,7 @@ public:
|
|||
|
||||
void OnTick() override
|
||||
{
|
||||
if (!S_CheckSoundPlaying(-1, 35) && ticks > 15 * GameTicRate) state = finished; // make sure it stays, even if sound is off.
|
||||
if (!S_CheckSoundPlaying(35) && ticks > 15 * GameTicRate) state = finished; // make sure it stays, even if sound is off.
|
||||
}
|
||||
void Draw(double) override
|
||||
{
|
||||
|
|
|
@ -897,4 +897,11 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Duke, PLaySound, PlaySound)
|
|||
ACTION_RETURN_INT(PlaySound(snd, chan, flags, vol));
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(_Duke, CheckSoundPlaying, S_CheckSoundPlaying)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
PARAM_INT(snd);
|
||||
ACTION_RETURN_INT(S_CheckSoundPlaying(snd));
|
||||
}
|
||||
|
||||
END_DUKE_NS
|
||||
|
|
|
@ -48,7 +48,6 @@ void S_MenuSound(void);
|
|||
void S_StopSound(int sndNum, DDukeActor* spr = nullptr, int flags = -1);
|
||||
|
||||
int S_CheckSoundPlaying(int soundNum);
|
||||
inline int S_CheckSoundPlaying(int sprnum, int soundNum) { return S_CheckSoundPlaying(soundNum); }
|
||||
int S_CheckActorSoundPlaying(DDukeActor* spriteNum, int soundNum, int channel = 0);
|
||||
int S_CheckAnyActorSoundPlaying(DDukeActor* spriteNum);
|
||||
|
||||
|
|
|
@ -218,7 +218,9 @@ struct TexMan
|
|||
AllowSkins = 8,
|
||||
ShortNameOnly = 16,
|
||||
DontCreate = 32,
|
||||
Localize = 64
|
||||
Localize = 64,
|
||||
ForceLookup = 128,
|
||||
NoAlias = 256
|
||||
};
|
||||
|
||||
enum ETexReplaceFlags
|
||||
|
|
|
@ -85,7 +85,7 @@ class ListMenuItemBloodTextItem : ListMenuItemTextItem
|
|||
if (selected) shade = 32 - ((MSTime() * 120 / 1000) & 63);
|
||||
|
||||
Screen.DrawText(gamefont, Font.CR_UNDEFINED, xpos+1, mYpos+1, mText, DTA_Color, 0xff000000, DTA_FullscreenScale, FSMode_Fit320x200);
|
||||
Screen.DrawText(gamefont, Font.CR_UNDEFINED, xpos, mYpos, mText, DTA_TranslationIndex, trans, DTA_Color, Build.shadeToLight(shade), DTA_FullscreenScale, FSMode_Fit320x200);
|
||||
Screen.DrawText(gamefont, Font.CR_UNDEFINED, xpos, mYpos, mText, DTA_TranslationIndex, trans, DTA_Color, Raze.shadeToLight(shade), DTA_FullscreenScale, FSMode_Fit320x200);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,6 +23,56 @@ struct Duke native
|
|||
|
||||
native static void PlaySpecialMusic(int which);
|
||||
native static int PlaySound(int num, int channel = CHAN_AUTO, int flags = 0, float vol =0.8f);
|
||||
native static bool CheckSoundPlaying(int num);
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// wrappers around DrawText to allow easier reuse of the old code.
|
||||
// The vertical displacements are to have the same positioning as with the original code.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
static void BigText(double x, double y, String text, int align = -1, double alpha = 1.)
|
||||
{
|
||||
|
||||
if (!Raze.isRR())
|
||||
{
|
||||
if (align != -1) x -= BigFont.StringWidth(text) * (align == 0 ? 0.5 : 1);
|
||||
Screen.DrawText(BigFont, Font.CR_UNTRANSLATED, x, y - 12, text, DTA_FullscreenScale, FSMode_Fit320x200, DTA_Alpha, alpha);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (align != -1) x -= BigFont.StringWidth(text) * (align == 0 ? 0.2 : 0.4);
|
||||
Screen.DrawText(BigFont, Font.CR_UNTRANSLATED, x, y - 12, text, DTA_FullscreenScale, FSMode_Fit320x200, DTA_ScaleX, 0.4, DTA_ScaleY, 0.4, DTA_Alpha, alpha);
|
||||
}
|
||||
}
|
||||
|
||||
static void GameText(double x, double y, String t, int shade, int align = -1, int trans = 0)
|
||||
{
|
||||
int fsmode = FSMode_Fit320x200;
|
||||
if (Raze.isRR())
|
||||
{
|
||||
x *= 2;
|
||||
y *= 2;
|
||||
fsmode = FSMode_Fit640x400;
|
||||
}
|
||||
if (align != -1) x -= SmallFont.StringWidth(t) * (align == 0 ? 0.5 : 1);
|
||||
Screen.DrawText(SmallFont, Font.CR_UNDEFINED, x, y + 2, t, DTA_FullscreenScale, fsmode, DTA_TranslationIndex, Translation.MakeID(Translation_Remap, trans), DTA_Color, Raze.shadeToLight(shade));
|
||||
}
|
||||
|
||||
static void MiniText(double x, double y, String t, int shade, int align = -1, int trans = 0)
|
||||
{
|
||||
int fsmode = FSMode_Fit320x200;
|
||||
if (Raze.isRR())
|
||||
{
|
||||
x *= 2;
|
||||
y *= 2;
|
||||
fsmode = FSMode_Fit640x400;
|
||||
}
|
||||
if (align != -1) x -= SmallFont2.StringWidth(t) * (align == 0 ? 0.5 : 1);
|
||||
Screen.DrawText(SmallFont2, Font.CR_UNDEFINED, x, y, t, DTA_FullscreenScale, fsmode, DTA_TranslationIndex, Translation.MakeID(Translation_Remap, trans), DTA_Color, Raze.shadeToLight(shade));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ class DukeMenuDelegate : RazeMenuDelegate
|
|||
String picname;
|
||||
if (!right) picname= String.Format("SPINNINGNUKEICON%d", ((mclock >> 3) % frames));
|
||||
else picname = String.Format("SPINNINGNUKEICON%d", frames - 1 - ((frames - 1 + (mclock >> 3)) % frames));
|
||||
int light = 231 + (Build.calcSinTableValue(mclock<<5) / 768.);
|
||||
int light = 231 + (Raze.calcSinTableValue(mclock<<5) / 768.);
|
||||
let pe = color(255, light, light, light);
|
||||
Screen.DrawTexture(TexMan.CheckForTexture(picname), false, x, y, DTA_FullscreenScale, FSMode_Fit320x200, DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_Color, pe, DTA_CenterOffsetRel, true);
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ class ListMenuItemDukeLogo : ListMenuItem
|
|||
if (gameinfo.gametype & GAMEFLAG_PLUTOPAK)
|
||||
{
|
||||
int mclock = MSTime() * 120 / 1000;
|
||||
int light = 223 + (Build.calcSinTableValue(mclock<<4) / 512.);
|
||||
int light = 223 + (Raze.calcSinTableValue(mclock<<4) / 512.);
|
||||
let pe = Color(255, light, light, light);
|
||||
Screen.DrawTexture(TexMan.CheckForTexture("MENUPLUTOPAKSPRITE"), false, x + 100, 36, DTA_FullscreenScale, FSMode_Fit320x200Top, DTA_Color, pe, DTA_CenterOffsetRel, true);
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ class ListMenuItemDukeTextItem : ListMenuItemTextItem
|
|||
if (selected)
|
||||
{
|
||||
int mclock = MSTime() * 120 / 1000;
|
||||
int light = 231 + (Build.calcSinTableValue(mclock<<5) / 512.);
|
||||
int light = 231 + (Raze.calcSinTableValue(mclock<<5) / 512.);
|
||||
pe = Color(255, light, light, light);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -51,7 +51,7 @@ class TitleScreen : SkippableScreenJob
|
|||
|
||||
override void Start()
|
||||
{
|
||||
if (Build.isNam() || userConfig.nologo) Duke.PlaySpecialMusic(Duke.MUS_INTRO);
|
||||
if (Raze.isNam() || userConfig.nologo) Duke.PlaySpecialMusic(Duke.MUS_INTRO);
|
||||
}
|
||||
|
||||
override void OnTick()
|
||||
|
@ -70,12 +70,12 @@ class TitleScreen : SkippableScreenJob
|
|||
if (soundanm == 2 && clock >= 280 && clock < 395)
|
||||
{
|
||||
soundanm = 3;
|
||||
if (Build.isPlutoPak()) Duke.PlaySound(DukeSnd.FLY_BY, CHAN_AUTO, CHANF_UI);
|
||||
if (Raze.isPlutoPak()) Duke.PlaySound(DukeSnd.FLY_BY, CHAN_AUTO, CHANF_UI);
|
||||
}
|
||||
else if (soundanm == 3 && clock >= 395)
|
||||
{
|
||||
soundanm = 4;
|
||||
if (Build.isPlutoPak()) Duke.PlaySound(DukeSnd.PIPEBOMB_EXPLODE, CHAN_AUTO, CHANF_UI);
|
||||
if (Raze.isPlutoPak()) Duke.PlaySound(DukeSnd.PIPEBOMB_EXPLODE, CHAN_AUTO, CHANF_UI);
|
||||
}
|
||||
|
||||
if (clock > (860 + 120))
|
||||
|
@ -116,7 +116,7 @@ class TitleScreen : SkippableScreenJob
|
|||
DTA_CenterOffsetRel, true, DTA_TranslationIndex, trans, DTA_ScaleX, scale, DTA_ScaleY, scale);
|
||||
}
|
||||
|
||||
if (Build.isPlutoPak())
|
||||
if (Raze.isPlutoPak())
|
||||
{
|
||||
scale = (410 - clamp(clock, 280, 395)) / 16.;
|
||||
if (scale > 0. && clock > 280)
|
||||
|
@ -269,3 +269,145 @@ class E2EndScreen : ImageScreen
|
|||
Duke.PlaySound(DukeSnd.PIPEBOMB_EXPLODE, CHAN_AUTO, CHANF_UI);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
class Episode3End : ImageScreen
|
||||
{
|
||||
int soundstate;
|
||||
int finishtime;
|
||||
|
||||
void Init()
|
||||
{
|
||||
Super.Init("", fadein|fadeout, 0x7fffffff);
|
||||
texid = TexMan.CheckForTexture("radlogo.anm", TexMan.Type_Any, TexMan.TryAny | TexMan.ForceLookup); // must override with 'forcelookup'.
|
||||
soundstate = 0;
|
||||
finishtime = 0;
|
||||
}
|
||||
|
||||
override void OnSkip()
|
||||
{
|
||||
Raze.StopAllSounds();
|
||||
}
|
||||
|
||||
override void OnTick()
|
||||
{
|
||||
switch (soundstate)
|
||||
{
|
||||
case 0:
|
||||
Duke.PlaySound(DukeSnd.ENDSEQVOL3SND5, CHAN_AUTO, CHANF_UI);
|
||||
soundstate++;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if (!Duke.CheckSoundPlaying(DukeSnd.ENDSEQVOL3SND5))
|
||||
{
|
||||
Duke.PlaySound(DukeSnd.ENDSEQVOL3SND6, CHAN_AUTO, CHANF_UI);
|
||||
soundstate++;
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if (!Duke.CheckSoundPlaying(DukeSnd.ENDSEQVOL3SND6))
|
||||
{
|
||||
Duke.PlaySound(DukeSnd.ENDSEQVOL3SND7, CHAN_AUTO, CHANF_UI);
|
||||
soundstate++;
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
if (!Duke.CheckSoundPlaying(DukeSnd.ENDSEQVOL3SND7))
|
||||
{
|
||||
Duke.PlaySound(DukeSnd.ENDSEQVOL3SND8, CHAN_AUTO, CHANF_UI);
|
||||
soundstate++;
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
if (!Duke.CheckSoundPlaying(DukeSnd.ENDSEQVOL3SND8))
|
||||
{
|
||||
Duke.PlaySound(DukeSnd.ENDSEQVOL3SND9, CHAN_AUTO, CHANF_UI);
|
||||
soundstate++;
|
||||
}
|
||||
break;
|
||||
|
||||
case 5:
|
||||
if (!Duke.CheckSoundPlaying(DukeSnd.ENDSEQVOL3SND9))
|
||||
{
|
||||
soundstate++;
|
||||
finishtime = ticks + GameTicRate * (Raze.SoundEnabled() ? 1 : 5); // if sound is off this wouldn't wait without a longer delay here.
|
||||
}
|
||||
break;
|
||||
|
||||
case 6:
|
||||
if (Raze.isPlutoPak())
|
||||
{
|
||||
if (ticks > finishtime) jobstate = finished;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (jobstate != running) Raze.StopAllSounds();
|
||||
}
|
||||
|
||||
override void OnDestroy()
|
||||
{
|
||||
if (!Raze.isPlutoPak()) Duke.PlaySound(DukeSnd.ENDSEQVOL3SND4, CHAN_AUTO, CHANF_UI);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
class Episode4Text : SkippableScreenJob
|
||||
{
|
||||
void Init()
|
||||
{
|
||||
Super.Init(fadein|fadeout);
|
||||
}
|
||||
|
||||
|
||||
override void Draw(double sm)
|
||||
{
|
||||
Screen.ClearScreen();
|
||||
Duke.BigText(160, 60, "$Thanks to all our");
|
||||
Duke.BigText(160, 60 + 16, "$fans for giving");
|
||||
Duke.BigText(160, 60 + 16 + 16, "$us big heads.");
|
||||
Duke.BigText(160, 70 + 16 + 16 + 16, "$Look for a Duke Nukem 3D");
|
||||
Duke.BigText(160, 70 + 16 + 16 + 16 + 16, "$sequel soon.");
|
||||
}
|
||||
|
||||
override void Start()
|
||||
{
|
||||
Duke.PlaySound(DukeSnd.ENDSEQVOL3SND4, CHAN_AUTO, CHANF_UI);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
class Episode5End : ImageScreen
|
||||
{
|
||||
void Init()
|
||||
{
|
||||
Super.Init("FIREFLYGROWEFFECT", fadein|fadeout|stopsound);
|
||||
}
|
||||
|
||||
override void OnTick()
|
||||
{
|
||||
if (ticks == 1) Duke.PlaySound(DukeSnd.E5L7_DUKE_QUIT_YOU, CHAN_AUTO, CHANF_UI);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -98,10 +98,10 @@ class ListMenuItemExhumedTextItem : ListMenuItemTextItem
|
|||
double y = mYpos + v.y / 2;
|
||||
|
||||
int shade;
|
||||
if (selected) shade = Build.CalcSinTableValue(MSTime() * 16 * 120 / 1000) >> 9;
|
||||
if (selected) shade = Raze.CalcSinTableValue(MSTime() * 16 * 120 / 1000) >> 9;
|
||||
else if (Selectable()) shade = 0;
|
||||
else shade = 25;
|
||||
let color = Build.shadeToLight(shade);
|
||||
let color = Raze.shadeToLight(shade);
|
||||
|
||||
double scalex = 1.; // Squash the text if it is too wide. Due to design limitations we cannot expand the box here. :(
|
||||
if (texsize.X - 18 < width)
|
||||
|
|
|
@ -39,7 +39,7 @@ extend struct _
|
|||
native @UserConfigStruct userConfig;
|
||||
}
|
||||
|
||||
struct Build
|
||||
struct Raze
|
||||
{
|
||||
static int calcSinTableValue(int ang)
|
||||
{
|
||||
|
@ -47,6 +47,9 @@ struct Build
|
|||
}
|
||||
|
||||
native static Color shadeToLight(int shade);
|
||||
native static void StopAllSounds();
|
||||
native static bool SoundEnabled();
|
||||
native static bool MusicEnabled();
|
||||
|
||||
// game check shortcuts
|
||||
static bool isNam()
|
||||
|
|
|
@ -32,6 +32,7 @@ class ScreenJob native
|
|||
native virtual bool OnEvent(InputEvent evt);
|
||||
native virtual void OnTick();
|
||||
native virtual void Draw(double smoothratio);
|
||||
virtual void OnSkip() {}
|
||||
|
||||
//native int DrawFrame(double smoothratio);
|
||||
//native int GetFadeState();
|
||||
|
@ -48,7 +49,6 @@ class SkippableScreenJob : ScreenJob native
|
|||
{
|
||||
native void Init(int flags = 0, float fadet = 250.f);
|
||||
//native override bool OnEvent(InputEvent evt);
|
||||
virtual void Skipped() {}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in a new issue