From b0301d6fc9d1a50f543cf539f93e46f0000dfdff Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 4 Oct 2020 20:03:14 +0200 Subject: [PATCH] - progress. --- source/CMakeLists.txt | 1 + source/core/gi.cpp | 52 +++++++++ source/core/gi.h | 55 ++++++++++ wadsrc/static/zscript.txt | 1 - wadsrc/static/zscript/base.zs | 10 +- wadsrc/static/zscript/ui/menu/menu.zs | 5 +- wadsrc/static/zscript/ui/menu/readthis.zs | 125 ---------------------- 7 files changed, 120 insertions(+), 129 deletions(-) create mode 100644 source/core/gi.cpp create mode 100644 source/core/gi.h delete mode 100644 wadsrc/static/zscript/ui/menu/readthis.zs diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 62574a5c5..ebd0d7e0a 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -802,6 +802,7 @@ set (PCH_SOURCES core/palette.cpp core/zcompile.cpp core/statusbar.cpp + core/gi.cpp core/console/c_console.cpp core/console/d_event.cpp diff --git a/source/core/gi.cpp b/source/core/gi.cpp new file mode 100644 index 000000000..abcf03e1e --- /dev/null +++ b/source/core/gi.cpp @@ -0,0 +1,52 @@ +/* +** gi.cpp +** Holds same game-dependant info +** +**--------------------------------------------------------------------------- +** Copyright 1998-2006 Randy Heit +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include +#include "gi.h" +#include "sc_man.h" +#include "filesystem.h" +#include "v_video.h" +#include "vm.h" +#include "c_cvars.h" + +gameinfo_t gameinfo; + +EXTERN_CVAR(Float, turbo) + + +DEFINE_GLOBAL(gameinfo) +DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, gametype) +DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, mBackButton) +DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, mSliderColor) + diff --git a/source/core/gi.h b/source/core/gi.h new file mode 100644 index 000000000..4a8c2622f --- /dev/null +++ b/source/core/gi.h @@ -0,0 +1,55 @@ +/* +** gi.h +** +**--------------------------------------------------------------------------- +** Copyright 1998-2006 Randy Heit +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#ifndef __GI_H__ +#define __GI_H__ + +#include "basics.h" +#include "zstring.h" +#include "name.h" + + + +struct gameinfo_t +{ + int gametype; + FName mSliderColor; + FString mBackButton; +}; + + +extern gameinfo_t gameinfo; + +bool CheckGame(const char *string, bool chexisdoom); + +#endif //__GI_H__ diff --git a/wadsrc/static/zscript.txt b/wadsrc/static/zscript.txt index 44f5c6761..56a4dfc23 100644 --- a/wadsrc/static/zscript.txt +++ b/wadsrc/static/zscript.txt @@ -16,6 +16,5 @@ version "4.3" #include "zscript/ui/menu/messagebox.zs" #include "zscript/ui/menu/optionmenu.zs" #include "zscript/ui/menu/optionmenuitems.zs" -#include "zscript/ui/menu/readthis.zs" #include "zscript/ui/menu/reverbedit.zs" #include "zscript/ui/menu/textentermenu.zs" diff --git a/wadsrc/static/zscript/base.zs b/wadsrc/static/zscript/base.zs index abbb3182e..03f633624 100644 --- a/wadsrc/static/zscript/base.zs +++ b/wadsrc/static/zscript/base.zs @@ -1,7 +1,8 @@ - + struct _ native // These are the global variables, the struct is only here to avoid extending the parser for this. { native readonly Array AllClasses; + native readonly @GameInfoStruct gameinfo; //native readonly int GameTicRate; native readonly Font smallfont; @@ -344,6 +345,13 @@ struct GIFont version("2.4") Name color; }; +struct GameInfoStruct native +{ + native int gametype; + native String mBackButton; + native Name mSliderColor; +} + class Object native { const TICRATE = 35; diff --git a/wadsrc/static/zscript/ui/menu/menu.zs b/wadsrc/static/zscript/ui/menu/menu.zs index 65a563211..1a9c681bb 100644 --- a/wadsrc/static/zscript/ui/menu/menu.zs +++ b/wadsrc/static/zscript/ui/menu/menu.zs @@ -283,9 +283,10 @@ class Menu : Object native ui version("2.4") // //============================================================================= - static void MenuSound(Sound snd) + static void MenuSound(Name snd) { - S_StartSound (snd, CHAN_VOICE, CHANF_MAYBE_LOCAL|CHAN_UI, snd_menuvolume, ATTN_NONE); + // todo: Cannot use game specific IDs here - sound also may be set up too late by the games + //S_StartSound (snd, CHAN_VOICE, CHANF_MAYBE_LOCAL|CHAN_UI, snd_menuvolume, ATTN_NONE); } deprecated("4.0") static void DrawConText (int color, int x, int y, String str) diff --git a/wadsrc/static/zscript/ui/menu/readthis.zs b/wadsrc/static/zscript/ui/menu/readthis.zs deleted file mode 100644 index 58904b0f4..000000000 --- a/wadsrc/static/zscript/ui/menu/readthis.zs +++ /dev/null @@ -1,125 +0,0 @@ -/* -** readthis.cpp -** Help screens -** -**--------------------------------------------------------------------------- -** Copyright 2001-2010 Randy Heit -** Copyright 2010 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -*/ - -class ReadThisMenu : GenericMenu -{ - int mScreen; - int mInfoTic; - - //============================================================================= - // - // - // - //============================================================================= - - override void Init(Menu parent) - { - Super.Init(parent); - mScreen = 1; - mInfoTic = gametic; - } - - override void Drawer() - { - double alpha; - TextureID tex, prevpic; - - // Did the mapper choose a custom help page via MAPINFO? - if (Level.F1Pic.Length() != 0) - { - tex = TexMan.CheckForTexture(Level.F1Pic, TexMan.Type_MiscPatch); - mScreen = 1; - } - - if (!tex.IsValid()) - { - tex = TexMan.CheckForTexture(gameinfo.infoPages[mScreen-1], TexMan.Type_MiscPatch); - } - - if (mScreen > 1) - { - prevpic = TexMan.CheckForTexture(gameinfo.infoPages[mScreen-2], TexMan.Type_MiscPatch); - } - - screen.Dim(0, 1.0, 0,0, screen.GetWidth(), screen.GetHeight()); - alpha = MIN((gametic - mInfoTic) * (3. / Thinker.TICRATE), 1.); - if (alpha < 1. && prevpic.IsValid()) - { - screen.DrawTexture (prevpic, false, 0, 0, DTA_Fullscreen, true); - } - else alpha = 1; - screen.DrawTexture (tex, false, 0, 0, DTA_Fullscreen, true, DTA_Alpha, alpha); - - } - - - //============================================================================= - // - // - // - //============================================================================= - - override bool MenuEvent(int mkey, bool fromcontroller) - { - if (mkey == MKEY_Enter) - { - MenuSound("menu/choose"); - mScreen++; - mInfoTic = gametic; - if (Level.F1Pic.Length() != 0 || mScreen > gameinfo.infoPages.Size()) - { - Close(); - } - return true; - } - else return Super.MenuEvent(mkey, fromcontroller); - } - - //============================================================================= - // - // - // - //============================================================================= - - override bool MouseEvent(int type, int x, int y) - { - if (type == MOUSE_Click) - { - return MenuEvent(MKEY_Enter, true); - } - return false; - } - -} \ No newline at end of file