From 4636a526994d1e63d7a6c990b2a266f1c1d85026 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 23 Apr 2021 12:24:42 +0200 Subject: [PATCH] - MP summary screen ported. --- source/core/gamecontrol.cpp | 22 ++++ wadsrc/static/zscript/games/duke/dukegame.zs | 6 ++ .../static/zscript/games/duke/ui/screens.zs | 102 ++++++++++++++++++ wadsrc/static/zscript/razebase.zs | 55 ++++++++++ wadsrc/static/zscript/screenjob.zs | 28 +++++ 5 files changed, 213 insertions(+) diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index 665c8b8e1..7b3ef32fe 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -1459,6 +1459,13 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Raze, MusicEnabled, MusicEnabled) ACTION_RETURN_INT(MusicEnabled()); } +DEFINE_ACTION_FUNCTION(_Raze, PlayerName) +{ + PARAM_PROLOGUE; + PARAM_INT(index); + ACTION_RETURN_STRING(unsigned(index) >= MAXPLAYERS ? "" : PlayerName(index)); +} + extern bool demoplayback; DEFINE_GLOBAL(multiplayer) DEFINE_GLOBAL(netgame) @@ -1466,3 +1473,18 @@ DEFINE_GLOBAL(gameaction) DEFINE_GLOBAL(gamestate) DEFINE_GLOBAL(demoplayback) DEFINE_GLOBAL(consoleplayer) +DEFINE_GLOBAL(currentLevel) + +DEFINE_FIELD_X(MapRecord, MapRecord, parTime) +DEFINE_FIELD_X(MapRecord, MapRecord, designerTime) +DEFINE_FIELD_X(MapRecord, MapRecord, fileName) +DEFINE_FIELD_X(MapRecord, MapRecord, labelName) +DEFINE_FIELD_X(MapRecord, MapRecord, name) +DEFINE_FIELD_X(MapRecord, MapRecord, music) +DEFINE_FIELD_X(MapRecord, MapRecord, cdSongId) +DEFINE_FIELD_X(MapRecord, MapRecord, flags) +DEFINE_FIELD_X(MapRecord, MapRecord, levelNumber) +DEFINE_FIELD_X(MapRecord, MapRecord, nextLevel) +DEFINE_FIELD_X(MapRecord, MapRecord, nextSecret) +//native readonly String messages[MAX_MESSAGES]; +DEFINE_FIELD_X(MapRecord, MapRecord, author) diff --git a/wadsrc/static/zscript/games/duke/dukegame.zs b/wadsrc/static/zscript/games/duke/dukegame.zs index d92e9e27d..9bc375d13 100644 --- a/wadsrc/static/zscript/games/duke/dukegame.zs +++ b/wadsrc/static/zscript/games/duke/dukegame.zs @@ -25,6 +25,12 @@ struct Duke native native static int PlaySound(int num, int channel = CHAN_AUTO, int flags = 0, float vol =0.8f); native static bool CheckSoundPlaying(int num); + static void PlayBonusMusic() + { + if (Raze.MusicEnabled()) + PlaySound(DukeSnd.BONUSMUSIC, CHAN_AUTO, CHANF_UI); + } + //========================================================================== // // wrappers around DrawText to allow easier reuse of the old code. diff --git a/wadsrc/static/zscript/games/duke/ui/screens.zs b/wadsrc/static/zscript/games/duke/ui/screens.zs index 264c78ec1..0e14bdf43 100644 --- a/wadsrc/static/zscript/games/duke/ui/screens.zs +++ b/wadsrc/static/zscript/games/duke/ui/screens.zs @@ -411,3 +411,105 @@ class Episode5End : ImageScreen } } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +class DukeMultiplayerBonusScreen : SkippableScreenJob +{ + int playerswhenstarted; + + void Init(int pos) + { + Super.Init(fadein|fadeout); + playerswhenstarted = pos; + } + + override void Start() + { + Duke.PlayBonusMusic(); + } + + override void Draw(double smoothratio) + { + String tempbuf; + int currentclock = int((ticks + smoothratio) * 120 / GameTicRate); + Screen.ClearScreen(); + Screen.DrawTexture(TexMan.CheckForTexture("MENUSCREEN"), false, 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_Color, 0xff808080, DTA_LegacyRenderStyle, STYLE_Normal); + Screen.DrawTexture(TexMan.CheckForTexture("INGAMEDUKETHREEDEE"), true, 160, 34, DTA_FullscreenScale, FSMode_Fit320x200, DTA_CenterOffsetRel, true); + if (Raze.isPlutoPak()) Screen.DrawTexture(TexMan.CheckForTexture("MENUPLUTOPAKSPRITE"), true, 260, 36, DTA_FullscreenScale, FSMode_Fit320x200, DTA_CenterOffsetRel, true); + + Duke.GameText(160, 58 + 2, "$Multiplayer Totals", 0, 0); + Duke.GameText(160, 58 + 10, currentLevel.DisplayName(), 0, 0); + Duke.GameText(160, 165, "$Presskey", 8 - int(sin(currentclock / 10.) * 8), 0); + + int t = 0; + + Duke.MiniText(38, 80, "$Name", 0, -1, 8); + Duke.MiniText(269+20, 80, "$Kills", 0, 1, 8); + + for (int i = 0; i < playerswhenstarted; i++) + { + tempbuf.Format("%-4d", i + 1); + Duke.MiniText(92 + (i * 23), 80, tempbuf, 0, -1, 3); + } + + for (int i = 0; i < playerswhenstarted; i++) + { + int xfragtotal = 0; + tempbuf.Format("%d", i + 1); + + Duke.MiniText(30, 90 + t, tempbuf, 0); + Duke.MiniText(38, 90 + t, Raze.PlayerName(i), 0, -1, Raze.playerPalette(i)); + + for (int y = 0; y < playerswhenstarted; y++) + { + int frag = Raze.playerFrags(i, y); + if (i == y) + { + int fraggedself = Raze.playerFraggedSelf(y); + tempbuf.Format("%-4d", fraggedself); + Duke.MiniText(92 + (y * 23), 90 + t, tempbuf, 0, -1, 2); + xfragtotal -= fraggedself; + } + else + { + tempbuf.Format("%-4d", frag); + Duke.MiniText(92 + (y * 23), 90 + t, tempbuf, 0); + xfragtotal += frag; + } + /* + if (myconnectindex == connecthead) + { + tempbuf.Format("stats %ld killed %ld %ld\n", i + 1, y + 1, frag); + sendscore(tempbuf); + } + */ + } + + tempbuf.Format("%-4d", xfragtotal); + Duke.MiniText(101 + (8 * 23), 90 + t, tempbuf, 0, -1, 2); + + t += 7; + } + + for (int y = 0; y < playerswhenstarted; y++) + { + int yfragtotal = 0; + for (int i = 0; i < playerswhenstarted; i++) + { + if (i == y) + yfragtotal += Raze.playerFraggedself(i); + int frag = Raze.playerFrags(i, y); + yfragtotal += frag; + } + tempbuf.Format("%-4d", yfragtotal); + Duke.MiniText(92 + (y * 23), 96 + (8 * 7), tempbuf, 0, -1, 2); + } + + Duke.MiniText(45, 96 + (8 * 7), "$Deaths", 0, -1, 8); + } +} + diff --git a/wadsrc/static/zscript/razebase.zs b/wadsrc/static/zscript/razebase.zs index 41cb20aee..9e5609ab1 100644 --- a/wadsrc/static/zscript/razebase.zs +++ b/wadsrc/static/zscript/razebase.zs @@ -37,8 +37,46 @@ struct UserConfigStruct native extend struct _ { native @UserConfigStruct userConfig; + native MapRecord currentLevel; } +struct MapRecord native +{ + enum MIFlags + { + FORCEEOG = 1, + USERMAP = 2, + } + + native readonly int parTime; + native readonly int designerTime; + native readonly String fileName; + native readonly String labelName; + native readonly String name; + native readonly String music; + native readonly int cdSongId; + native readonly int flags; + native readonly int levelNumber; + + // The rest is only used by Blood + native readonly int nextLevel; + native readonly int nextSecret; + //native readonly String messages[MAX_MESSAGES]; + native readonly String author; + + String GetLabelName() + { + if (flags & USERMAP) return "$TXT_USERMAP"; + return labelName; + } + String DisplayName() + { + if (name == "") return labelName; + return name; + } +} + + struct Raze { static int calcSinTableValue(int ang) @@ -50,6 +88,7 @@ struct Raze native static void StopAllSounds(); native static bool SoundEnabled(); native static bool MusicEnabled(); + native static String PlayerName(int i); // game check shortcuts static bool isNam() @@ -97,6 +136,22 @@ struct Raze return gameinfo.gametype & GAMEFLAG_BLOOD; } + // Dont know yet how to best export this, so for now these are just placeholders as MP is not operational anyway. + static int playerPalette(int i) + { + return 0; + } + + static int playerFrags(int i, int j) + { + return 0; + } + + static int playerFraggedSelf(int i) + { + return 0; + } + } /* diff --git a/wadsrc/static/zscript/screenjob.zs b/wadsrc/static/zscript/screenjob.zs index 477dd8889..c1323e572 100644 --- a/wadsrc/static/zscript/screenjob.zs +++ b/wadsrc/static/zscript/screenjob.zs @@ -85,3 +85,31 @@ class ImageScreen : SkippableScreenJob native //override void OnTick(); //override void Draw(double smooth); } + +//--------------------------------------------------------------------------- +// +// this is to have a unified interface to the summary screens +// that can be set up automatically by the games to avoid direct access to game data. +// +//--------------------------------------------------------------------------- + +class SummaryScreenBase : ScreenJob +{ + MapRecord level; + int kills, maxkills; + int secrets, maxsecrets, supersecrets; + int time; + bool cheatflag; + + void SetParameters(MapRecord map, int kills_, int maxkills_, int secrets_, int maxsecrets_, int supersecrets_, int time_, bool cheated) + { + level = map; + kills = kills_; + maxkills = maxkills_; + secrets = secrets_; + maxsecrets = maxsecrets_; + supersecrets = supersecrets_; + time = time_; + cheatflag = cheated; + } +}