diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 6b2e3fb71..f9577df89 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -810,6 +810,7 @@ set (PCH_SOURCES common/audio/sound/oalsound.cpp common/audio/sound/s_environment.cpp common/audio/sound/s_sound.cpp + #common/audio/sound/s_reverbedit.cpp common/audio/music/music_midi_base.cpp common/audio/music/music.cpp common/audio/music/i_music.cpp @@ -828,7 +829,6 @@ set (PCH_SOURCES common/fonts/v_text.cpp common/textures/hw_ihwtexture.cpp common/textures/hw_material.cpp - common/textures/bitmap.cpp common/textures/m_png.cpp common/textures/texture.cpp @@ -905,6 +905,7 @@ set (PCH_SOURCES common/filesystem/file_directory.cpp common/filesystem/resourcefile.cpp common/engine/cycler.cpp + common/engine/d_event.cpp common/engine/stats.cpp common/engine/sc_man.cpp common/engine/palettecontainer.cpp @@ -918,6 +919,7 @@ set (PCH_SOURCES common/objects/dobject.cpp common/objects/dobjgc.cpp common/objects/dobjtype.cpp + common/rendering/v_framebuffer.cpp common/rendering/v_video.cpp common/rendering/r_thread.cpp @@ -960,7 +962,7 @@ set (PCH_SOURCES common/scripting/vm/vmexec.cpp common/scripting/vm/vmframe.cpp common/scripting/interface/stringformat.cpp - #common/scripting/interface/exports.cpp + common/scripting/interface/vmnatives.cpp common/scripting/frontend/ast.cpp common/scripting/frontend/zcc_compile.cpp common/scripting/frontend/zcc_parser.cpp diff --git a/source/blood/src/blood.cpp b/source/blood/src/blood.cpp index 7727df008..f78d80bef 100644 --- a/source/blood/src/blood.cpp +++ b/source/blood/src/blood.cpp @@ -70,7 +70,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "gamecontrol.h" #include "m_argv.h" #include "statistics.h" -#include "menu/menu.h" +#include "menu.h" #include "raze_sound.h" #include "nnexts.h" #include"secrets.h" diff --git a/source/blood/src/d_menu.cpp b/source/blood/src/d_menu.cpp index e849a5749..d8ac4ce17 100644 --- a/source/blood/src/d_menu.cpp +++ b/source/blood/src/d_menu.cpp @@ -39,7 +39,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "network.h" #include "mmulti.h" #include "c_bind.h" -#include "menu/menu.h" +#include "menu.h" #include "sfx.h" bool ShowOptionMenu(); diff --git a/source/blood/src/demo.cpp b/source/blood/src/demo.cpp index 4c77c0419..0796a1d20 100644 --- a/source/blood/src/demo.cpp +++ b/source/blood/src/demo.cpp @@ -44,7 +44,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "screen.h" #include "view.h" #include "gamecontrol.h" -#include "menu/menu.h" +#include "menu.h" #include "gameconfigfile.h" #include "findfile.h" diff --git a/source/blood/src/levels.cpp b/source/blood/src/levels.cpp index 7cfee76ee..08c519eea 100644 --- a/source/blood/src/levels.cpp +++ b/source/blood/src/levels.cpp @@ -43,7 +43,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "sfx.h" #include "view.h" #include "eventq.h" -#include "menu/menu.h" +#include "menu.h" BEGIN_BLD_NS diff --git a/source/blood/src/network.cpp b/source/blood/src/network.cpp index e485601bd..4d83d3a23 100644 --- a/source/blood/src/network.cpp +++ b/source/blood/src/network.cpp @@ -38,7 +38,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "seq.h" #include "sound.h" #include "view.h" -#include "menu/menu.h" +#include "menu.h" extern bool gHaveNetworking; diff --git a/source/blood/src/view.cpp b/source/blood/src/view.cpp index 5b190eaba..eaae01e6e 100644 --- a/source/blood/src/view.cpp +++ b/source/blood/src/view.cpp @@ -60,7 +60,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "weapon.h" #include "nnexts.h" #include "zstring.h" -#include "menu/menu.h" +#include "menu.h" #include "gstrings.h" #include "v_2ddrawer.h" #include "v_video.h" diff --git a/source/common/audio/music/music_midi_base.cpp b/source/common/audio/music/music_midi_base.cpp index 65c59c54b..6ce987801 100644 --- a/source/common/audio/music/music_midi_base.cpp +++ b/source/common/audio/music/music_midi_base.cpp @@ -35,7 +35,7 @@ #include "c_dispatch.h" #include "v_text.h" -#include "menu/menu.h" +#include "menu.h" #include #include "s_music.h" #include "c_cvars.h" diff --git a/source/common/audio/sound/oalsound.cpp b/source/common/audio/sound/oalsound.cpp index be3cc5d65..ee3e127c3 100644 --- a/source/common/audio/sound/oalsound.cpp +++ b/source/common/audio/sound/oalsound.cpp @@ -2071,7 +2071,7 @@ FSoundChan *OpenALSoundRenderer::FindLowestChannel() #endif // NO_OPENAL -#include "menu/menu.h" +#include "menu.h" void I_BuildALDeviceList(FOptionValues* opt) { diff --git a/source/common/audio/sound/s_reverbedit.cpp b/source/common/audio/sound/s_reverbedit.cpp new file mode 100644 index 000000000..25993a400 --- /dev/null +++ b/source/common/audio/sound/s_reverbedit.cpp @@ -0,0 +1,553 @@ +/* +** +** reverb editor +** +**--------------------------------------------------------------------------- +** Copyright 2005-2016 Randy Heit +** Copyright 2005-2017 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. +**--------------------------------------------------------------------------- +** +*/ + +#include "s_soundinternal.h" +#include "sc_man.h" +#include "cmdlib.h" +#include "templates.h" +#include "filesystem.h" +#include "i_system.h" +#include "printf.h" +#include "i_specialpaths.h" +#include "c_cvars.h" +#include "c_dispatch.h" +#include "vm.h" +#include "dobject.h" +#include "menu.h" + +void S_ReadReverbDef (FScanner &sc); + +extern ReverbContainer *ForcedEnvironment; +ReverbContainer *CurrentEnv; +REVERB_PROPERTIES SavedProperties; + +extern FReverbField ReverbFields[]; +extern const char* ReverbFieldNames[]; +extern int NumReverbs; + + +// These are for internal use only and not supposed to be user-settable +CVAR(String, reverbedit_name, "", CVAR_NOSET); +CVAR(Int, reverbedit_id1, 0, CVAR_NOSET); +CVAR(Int, reverbedit_id2, 0, CVAR_NOSET); +CVAR(String, reverbsavename, "", 0); + + +CUSTOM_CVAR(Bool, eaxedit_test, false, CVAR_NOINITCALL) +{ + if (self) + { + ForcedEnvironment = CurrentEnv; + } + else + { + ForcedEnvironment = nullptr; + } +} + +struct EnvFlag +{ + const char *Name; + int CheckboxControl; + unsigned int Flag; +}; + +inline int HIBYTE(int i) +{ + return (i >> 8) & 255; +} + +inline int LOBYTE(int i) +{ + return i & 255; +} + +uint16_t FirstFreeID(uint16_t base, bool builtin) +{ + int tryCount = 0; + int priID = HIBYTE(base); + + // If the original sound is built-in, start searching for a new + // primary ID at 30. + if (builtin) + { + for (priID = 30; priID < 256; ++priID) + { + if (S_FindEnvironment(priID << 8) == nullptr) + { + break; + } + } + if (priID == 256) + { // Oh well. + priID = 30; + } + } + + for (;;) + { + uint16_t lastID = Environments->ID; + const ReverbContainer *env = Environments->Next; + + // Find the lowest-numbered free ID with the same primary ID as base + // If none are available, add 100 to base's primary ID and try again. + // If that fails, then the primary ID gets incremented + // by 1 until a match is found. If all the IDs searchable by this + // algorithm are in use, then you're in trouble. + + while (env != nullptr) + { + if (HIBYTE(env->ID) > priID) + { + break; + } + if (HIBYTE(env->ID) == priID) + { + if (HIBYTE(lastID) == priID) + { + if (LOBYTE(env->ID) - LOBYTE(lastID) > 1) + { + return lastID + 1; + } + } + lastID = env->ID; + } + env = env->Next; + } + if (LOBYTE(lastID) == 255) + { + if (tryCount == 0) + { + base += 100 * 256; + tryCount = 1; + } + else + { + base += 256; + } + } + else if (builtin && lastID == 0) + { + return priID << 8; + } + else + { + return lastID + 1; + } + } +} + +FString SuggestNewName(const ReverbContainer *env) +{ + const ReverbContainer *probe = nullptr; + char text[32]; + size_t len; + int number, numdigits; + + strncpy(text, env->Name, 31); + text[31] = 0; + + len = strlen(text); + while (text[len - 1] >= '0' && text[len - 1] <= '9') + { + len--; + } + number = atoi(text + len); + if (number < 1) + { + number = 1; + } + + if (text[len - 1] != ' ' && len < 31) + { + text[len++] = ' '; + } + + for (; number < 100000; ++number) + { + if (number < 10) numdigits = 1; + else if (number < 100) numdigits = 2; + else if (number < 1000) numdigits = 3; + else if (number < 10000)numdigits = 4; + else numdigits = 5; + if (len + numdigits > 31) + { + len = 31 - numdigits; + } + mysnprintf(text + len, countof(text) - len, "%d", number); + + probe = Environments; + while (probe != nullptr) + { + if (stricmp(probe->Name, text) == 0) + break; + probe = probe->Next; + } + if (probe == nullptr) + { + break; + } + } + return text; +} + +void ExportEnvironments(const char *filename, uint32_t count, const ReverbContainer **envs) +{ + FString dest = M_GetDocumentsPath() + filename; + + FileWriter *f = FileWriter::Open(dest); + + if (f != nullptr) + { + for (uint32_t i = 0; i < count; ++i) + { + const ReverbContainer *env = envs[i]; + const ReverbContainer *base; + + if ((unsigned int)env->Properties.Environment < 26) + { + base = DefaultEnvironments[env->Properties.Environment]; + } + else + { + base = nullptr; + } + f->Printf("\"%s\" %u %u\n{\n", env->Name, HIBYTE(env->ID), LOBYTE(env->ID)); + for (int j = 0; j < NumReverbs; ++j) + { + const FReverbField *ctl = &ReverbFields[j]; + const char *ctlName = ReverbFieldNames[j]; + if (ctlName) + { + if (j == 0 || + (ctl->Float && base->Properties.*ctl->Float != env->Properties.*ctl->Float) || + (ctl->Int && base->Properties.*ctl->Int != env->Properties.*ctl->Int)) + { + f->Printf("\t%s ", ctlName); + if (ctl->Float) + { + float v = env->Properties.*ctl->Float * 1000; + int vi = int(v >= 0.0 ? v + 0.5 : v - 0.5); + f->Printf("%d.%03d\n", vi / 1000, abs(vi % 1000)); + } + else + { + f->Printf("%d\n", env->Properties.*ctl->Int); + } + } + else + { + if ((1 << ctl->Flag) & (env->Properties.Flags ^ base->Properties.Flags)) + { + f->Printf("\t%s %s\n", ctlName, ctl->Flag & env->Properties.Flags ? "true" : "false"); + } + } + } + } + f->Printf("}\n\n"); + } + delete f; + } + else + { + M_StartMessage("Save failed", 1); + } +} + +DEFINE_ACTION_FUNCTION(DReverbEdit, GetValue) +{ + PARAM_PROLOGUE; + PARAM_INT(index); + float v = 0; + + if (index >= 0 && index < NumReverbs) + { + auto rev = &ReverbFields[index]; + if (rev->Int != nullptr) + { + v = float(CurrentEnv->Properties.*(rev->Int)); + } + else if (rev->Float != nullptr) + { + v = CurrentEnv->Properties.*(rev->Float); + } + else + { + v = !!(CurrentEnv->Properties.Flags & (1 << int(rev->Flag))); + } + } + ACTION_RETURN_FLOAT(v); + return 1; +} + +DEFINE_ACTION_FUNCTION(DReverbEdit, SetValue) +{ + PARAM_PROLOGUE; + PARAM_INT(index); + PARAM_FLOAT(v); + + if (index >= 0 && index < NumReverbs) + { + auto rev = &ReverbFields[index]; + if (rev->Int != nullptr) + { + v = CurrentEnv->Properties.*(rev->Int) = clamp(int(v), rev->Min, rev->Max); + } + else if (rev->Float != nullptr) + { + v = CurrentEnv->Properties.*(rev->Float) = clamp(float(v), rev->Min / 1000.f, rev->Max / 1000.f); + } + else + { + if (v == 0) CurrentEnv->Properties.Flags &= ~(1 << int(rev->Flag)); + else CurrentEnv->Properties.Flags |= (1 << int(rev->Flag)); + } + } + + ACTION_RETURN_FLOAT(v); + return 1; +} + +DEFINE_ACTION_FUNCTION(DReverbEdit, GrayCheck) +{ + PARAM_PROLOGUE; + ACTION_RETURN_BOOL(CurrentEnv->Builtin); + return 1; +} + +DEFINE_ACTION_FUNCTION(DReverbEdit, GetSelectedEnvironment) +{ + PARAM_PROLOGUE; + if (numret > 1) + { + numret = 2; + ret[1].SetInt(CurrentEnv ? CurrentEnv->ID : -1); + } + if (numret > 0) + { + ret[0].SetString(CurrentEnv ? CurrentEnv->Name : ""); + } + return numret; +} + +DEFINE_ACTION_FUNCTION(DReverbEdit, FillSelectMenu) +{ + PARAM_PROLOGUE; + PARAM_STRING(ccmd); + PARAM_OBJECT(desc, DOptionMenuDescriptor); + desc->mItems.Clear(); + for (auto env = Environments; env != nullptr; env = env->Next) + { + FStringf text("(%d, %d) %s", HIBYTE(env->ID), LOBYTE(env->ID), env->Name); + FStringf cmd("%s \"%s\"", ccmd.GetChars(), env->Name); + PClass *cls = PClass::FindClass("OptionMenuItemCommand"); + if (cls != nullptr && cls->IsDescendantOf("OptionMenuItem")) + { + auto func = dyn_cast(cls->FindSymbol("Init", true)); + if (func != nullptr) + { + DMenuItemBase *item = (DMenuItemBase*)cls->CreateNew(); + VMValue params[] = { item, &text, FName(cmd).GetIndex(), false, true }; + VMCall(func->Variants[0].Implementation, params, 5, nullptr, 0); + desc->mItems.Push((DMenuItemBase*)item); + } + } + } + return 0; +} + +static TArray> SaveState; + +DEFINE_ACTION_FUNCTION(DReverbEdit, FillSaveMenu) +{ + PARAM_PROLOGUE; + PARAM_OBJECT(desc, DOptionMenuDescriptor); + desc->mItems.Resize(4); + SaveState.Clear(); + for (auto env = Environments; env != nullptr; env = env->Next) + { + if (!env->Builtin) + { + int index = (int)SaveState.Push(std::make_pair(env, false)); + + FStringf text("(%d, %d) %s", HIBYTE(env->ID), LOBYTE(env->ID), env->Name); + PClass *cls = PClass::FindClass("OptionMenuItemReverbSaveSelect"); + if (cls != nullptr && cls->IsDescendantOf("OptionMenuItem")) + { + auto func = dyn_cast(cls->FindSymbol("Init", true)); + if (func != nullptr) + { + DMenuItemBase *item = (DMenuItemBase*)cls->CreateNew(); + VMValue params[] = { item, &text, index, FName("OnOff").GetIndex() }; + VMCall(func->Variants[0].Implementation, params, 4, nullptr, 0); + desc->mItems.Push((DMenuItemBase*)item); + } + } + } + } + return 0; +} + +DEFINE_ACTION_FUNCTION(DReverbEdit, GetSaveSelection) +{ + PARAM_PROLOGUE; + PARAM_INT(index); + bool res = false; + if ((unsigned)index <= SaveState.Size()) + { + res = SaveState[index].second; + } + ACTION_RETURN_BOOL(res); +} + +DEFINE_ACTION_FUNCTION(DReverbEdit, ToggleSaveSelection) +{ + PARAM_PROLOGUE; + PARAM_INT(index); + if ((unsigned)index <= SaveState.Size()) + { + SaveState[index].second = !SaveState[index].second; + } + return 0; +} + + +CCMD(savereverbs) +{ + if (SaveState.Size() == 0) return; + + TArray toSave; + + for (auto &p : SaveState) + { + if (p.second) toSave.Push(p.first); + } + ExportEnvironments(reverbsavename, toSave.Size(), &toSave[0]); + SaveState.Clear(); +} + +static void SelectEnvironment(const char *envname) +{ + for (auto env = Environments; env != nullptr; env = env->Next) + { + if (!strcmp(env->Name, envname)) + { + CurrentEnv = env; + SavedProperties = env->Properties; + if (eaxedit_test) ForcedEnvironment = env; + + // Set up defaults for a new environment based on this one. + int newid = FirstFreeID(env->ID, env->Builtin); + UCVarValue cv; + cv.Int = HIBYTE(newid); + reverbedit_id1.ForceSet(cv, CVAR_Int); + cv.Int = LOBYTE(newid); + reverbedit_id2.ForceSet(cv, CVAR_Int); + FString selectname = SuggestNewName(env); + cv.String = selectname.GetChars(); + reverbedit_name.ForceSet(cv, CVAR_String); + return; + } + } +} + +void InitReverbMenu() +{ + // Make sure that the editor's variables are properly initialized. + SelectEnvironment("Off"); +} + +CCMD(selectenvironment) +{ + if (argv.argc() > 1) + { + auto str = argv[1]; + SelectEnvironment(str); + } + else + InitReverbMenu(); +} + +CCMD(revertenvironment) +{ + if (CurrentEnv != nullptr) + { + CurrentEnv->Properties = SavedProperties; + } +} + +CCMD(createenvironment) +{ + if (S_FindEnvironment(reverbedit_name)) + { + M_StartMessage(FStringf("An environment with the name '%s' already exists", *reverbedit_name), 1); + return; + } + int id = (reverbedit_id1 << 8) + reverbedit_id2; + if (S_FindEnvironment(id)) + { + M_StartMessage(FStringf("An environment with the ID (%d, %d) already exists", *reverbedit_id1, *reverbedit_id2), 1); + return; + } + + auto newenv = new ReverbContainer; + newenv->Builtin = false; + newenv->ID = id; + newenv->Name = copystring(reverbedit_name); + newenv->Next = nullptr; + newenv->Properties = CurrentEnv->Properties; + S_AddEnvironment(newenv); + SelectEnvironment(newenv->Name); +} + +CCMD(reverbedit) +{ + C_DoCommand("openmenu reverbedit"); +} + +// This is here because it depends on Doom's resource management and is not universal. +void S_ParseReverbDef () +{ + int lump, lastlump = 0; + + while ((lump = fileSystem.FindLump ("REVERBS", &lastlump)) != -1) + { + FScanner sc; + sc.OpenLumpNum(lump); + S_ReadReverbDef (sc);; + } + InitReverbMenu(); +} + diff --git a/source/common/console/c_bind.cpp b/source/common/console/c_bind.cpp index 5e82f5bd0..c5a540645 100644 --- a/source/common/console/c_bind.cpp +++ b/source/common/console/c_bind.cpp @@ -47,7 +47,7 @@ #include "sc_man.h" #include "c_cvars.h" -#include "d_event.h" +#include "d_eventbase.h" extern int chatmodeon; diff --git a/source/common/engine/d_event.cpp b/source/common/engine/d_event.cpp new file mode 100644 index 000000000..c58a98df1 --- /dev/null +++ b/source/common/engine/d_event.cpp @@ -0,0 +1,198 @@ +/* +** c_dispatch.cpp +** Functions for executing console commands and aliases +** +**--------------------------------------------------------------------------- +** Copyright 1998-2016 Randy Heit +** Copyright 2003-2019 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. +**--------------------------------------------------------------------------- +** +*/ + +#include "c_bind.h" +#include "d_eventbase.h" +#include "c_console.h" +#include "d_gui.h" +#include "menu.h" +#include "utf8.h" +#include "m_joy.h" +#include "vm.h" + +bool G_Responder(event_t* ev); + +int eventhead; +int eventtail; +event_t events[MAXEVENTS]; + +//========================================================================== +// +// D_ProcessEvents +// +// Send all the events of the given timestamp down the responder chain. +// Events are asynchronous inputs generally generated by the game user. +// Events can be discarded if no responder claims them +// +//========================================================================== + +void D_ProcessEvents (void) +{ + event_t *ev; + while (eventtail != eventhead) + { + ev = &events[eventtail]; + eventtail = (eventtail + 1) & (MAXEVENTS - 1); + if (ev->type == EV_None) + continue; + if (ev->type == EV_DeviceChange) + UpdateJoystickMenu(I_UpdateDeviceList()); + if (C_Responder (ev)) + continue; // console ate the event + if (M_Responder (ev)) + continue; // menu ate the event + G_Responder (ev); + } +} + +//========================================================================== +// +// D_RemoveNextCharEvent +// +// Removes the next EV_GUI_Char event in the input queue. Used by the menu, +// since it (generally) consumes EV_GUI_KeyDown events and not EV_GUI_Char +// events, and it needs to ensure that there is no left over input when it's +// done. If there are multiple EV_GUI_KeyDowns before the EV_GUI_Char, then +// there are dead chars involved, so those should be removed, too. We do +// this by changing the message type to EV_None rather than by actually +// removing the event from the queue. +// +//========================================================================== + +void D_RemoveNextCharEvent() +{ + assert(events[eventtail].type == EV_GUI_Event && events[eventtail].subtype == EV_GUI_KeyDown); + for (int evnum = eventtail; evnum != eventhead; evnum = (evnum+1) & (MAXEVENTS-1)) + { + event_t *ev = &events[evnum]; + if (ev->type != EV_GUI_Event) + break; + if (ev->subtype == EV_GUI_KeyDown || ev->subtype == EV_GUI_Char) + { + ev->type = EV_None; + if (ev->subtype == EV_GUI_Char) + break; + } + else + { + break; + } + } +} + + +FInputEvent::FInputEvent(const event_t *ev) +{ + Type = (EGenericEvent)ev->type; + // we don't want the modders to remember what weird fields mean what for what events. + KeyScan = 0; + KeyChar = 0; + MouseX = 0; + MouseY = 0; + switch (Type) + { + case EV_None: + break; + case EV_KeyDown: + case EV_KeyUp: + KeyScan = ev->data1; + KeyChar = ev->data2; + KeyString = FString(char(ev->data1)); + break; + case EV_Mouse: + MouseX = ev->x; + MouseY = ev->y; + break; + default: + break; // EV_DeviceChange = wat? + } +} + +FUiEvent::FUiEvent(const event_t *ev) +{ + Type = (EGUIEvent)ev->subtype; + KeyChar = 0; + IsShift = false; + IsAlt = false; + IsCtrl = false; + MouseX = 0; + MouseY = 0; + // we don't want the modders to remember what weird fields mean what for what events. + switch (ev->subtype) + { + case EV_GUI_None: + break; + case EV_GUI_KeyDown: + case EV_GUI_KeyRepeat: + case EV_GUI_KeyUp: + KeyChar = ev->data1; + KeyString = FString(char(ev->data1)); + IsShift = !!(ev->data3 & GKM_SHIFT); + IsAlt = !!(ev->data3 & GKM_ALT); + IsCtrl = !!(ev->data3 & GKM_CTRL); + break; + case EV_GUI_Char: + KeyChar = ev->data1; + KeyString = MakeUTF8(ev->data1); + IsAlt = !!ev->data2; // only true for Win32, not sure about SDL + break; + default: // mouse event + // note: SDL input doesn't seem to provide these at all + //Printf("Mouse data: %d, %d, %d, %d\n", ev->x, ev->y, ev->data1, ev->data2); + MouseX = ev->data1; + MouseY = ev->data2; + IsShift = !!(ev->data3 & GKM_SHIFT); + IsAlt = !!(ev->data3 & GKM_ALT); + IsCtrl = !!(ev->data3 & GKM_CTRL); + break; + } +} + +DEFINE_FIELD_X(UiEvent, FUiEvent, Type); +DEFINE_FIELD_X(UiEvent, FUiEvent, KeyString); +DEFINE_FIELD_X(UiEvent, FUiEvent, KeyChar); +DEFINE_FIELD_X(UiEvent, FUiEvent, MouseX); +DEFINE_FIELD_X(UiEvent, FUiEvent, MouseY); +DEFINE_FIELD_X(UiEvent, FUiEvent, IsShift); +DEFINE_FIELD_X(UiEvent, FUiEvent, IsAlt); +DEFINE_FIELD_X(UiEvent, FUiEvent, IsCtrl); + +DEFINE_FIELD_X(InputEvent, FInputEvent, Type); +DEFINE_FIELD_X(InputEvent, FInputEvent, KeyScan); +DEFINE_FIELD_X(InputEvent, FInputEvent, KeyString); +DEFINE_FIELD_X(InputEvent, FInputEvent, KeyChar); +DEFINE_FIELD_X(InputEvent, FInputEvent, MouseX); +DEFINE_FIELD_X(InputEvent, FInputEvent, MouseY); + diff --git a/source/common/engine/d_eventbase.h b/source/common/engine/d_eventbase.h new file mode 100644 index 000000000..6ae14b4a3 --- /dev/null +++ b/source/common/engine/d_eventbase.h @@ -0,0 +1,77 @@ +#pragma once +#include +#include "d_gui.h" +#include "zstring.h" + +// Input event types. +enum EGenericEvent +{ + EV_None, + EV_KeyDown, // data1: scan code, data2: Qwerty ASCII code + EV_KeyUp, // same + EV_Mouse, // x, y: mouse movement deltas + EV_GUI_Event, // subtype specifies actual event + EV_DeviceChange,// a device has been connected or removed +}; + +// Event structure. +struct event_t +{ + uint8_t type; + uint8_t subtype; + int16_t data1; // keys / mouse/joystick buttons + int16_t data2; + int16_t data3; + int x; // mouse/joystick x move + int y; // mouse/joystick y move +}; + + + +// Called by IO functions when input is detected. +void D_PostEvent (const event_t* ev); +void D_RemoveNextCharEvent(); +void D_ProcessEvents(void); + +enum +{ + MAXEVENTS = 128 +}; + +extern event_t events[MAXEVENTS]; +extern int eventhead; +extern int eventtail; + +struct FUiEvent +{ + // this essentially translates event_t UI events to ZScript. + EGUIEvent Type; + // for keys/chars/whatever + FString KeyString; + int KeyChar; + // for mouse + int MouseX; + int MouseY; + // global (?) + bool IsShift; + bool IsCtrl; + bool IsAlt; + + FUiEvent(const event_t *ev); +}; + +struct FInputEvent +{ + // this translates regular event_t events to ZScript (not UI, UI events are sent via DUiEvent and only if requested!) + EGenericEvent Type = EV_None; + // for keys + int KeyScan; + FString KeyString; + int KeyChar; + // for mouse + int MouseX; + int MouseY; + + FInputEvent(const event_t *ev); +}; + diff --git a/source/common/engine/d_gui.h b/source/common/engine/d_gui.h new file mode 100644 index 000000000..774f928ac --- /dev/null +++ b/source/common/engine/d_gui.h @@ -0,0 +1,115 @@ +/* +** d_gui.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. +**--------------------------------------------------------------------------- +** +** So when do I get a real UT-like windowing system? +*/ + +#ifndef __D_GUI_H__ +#define __D_GUI_H__ + +// For a GUIEvent, x and y specify absolute location of mouse pointer +enum EGUIEvent +{ + EV_GUI_None, + EV_GUI_KeyDown, // data1: unshifted ASCII, data2: shifted ASCII, data3: modifiers + EV_GUI_KeyRepeat, // same + EV_GUI_KeyUp, // same + EV_GUI_Char, // data1: translated character (for user text input), data2: alt down? + EV_GUI_FirstMouseEvent, + EV_GUI_MouseMove, + EV_GUI_LButtonDown, + EV_GUI_LButtonUp, + EV_GUI_LButtonDblClick, + EV_GUI_MButtonDown, + EV_GUI_MButtonUp, + EV_GUI_MButtonDblClick, + EV_GUI_RButtonDown, + EV_GUI_RButtonUp, + EV_GUI_RButtonDblClick, + EV_GUI_WheelUp, // data3: shift/ctrl/alt + EV_GUI_WheelDown, // " + EV_GUI_WheelRight, // " + EV_GUI_WheelLeft, // " + EV_GUI_BackButtonDown, + EV_GUI_BackButtonUp, + EV_GUI_FwdButtonDown, + EV_GUI_FwdButtonUp, + EV_GUI_LastMouseEvent, +}; + +enum GUIKeyModifiers +{ + GKM_SHIFT = 1, + GKM_CTRL = 2, + GKM_ALT = 4, + GKM_META = 8, + GKM_LBUTTON = 16 +}; + +// Special codes for some GUI keys, including a few real ASCII codes. +enum ESpecialGUIKeys +{ + GK_PGDN = 1, + GK_PGUP = 2, + GK_HOME = 3, + GK_END = 4, + GK_LEFT = 5, + GK_RIGHT = 6, + GK_ALERT = 7, // ASCII bell + GK_BACKSPACE= 8, // ASCII + GK_TAB = 9, // ASCII + GK_LINEFEED = 10, // ASCII + GK_DOWN = 10, + GK_VTAB = 11, // ASCII + GK_UP = 11, + GK_FORMFEED = 12, // ASCII + GK_RETURN = 13, // ASCII + GK_F1 = 14, + GK_F2 = 15, + GK_F3 = 16, + GK_F4 = 17, + GK_F5 = 18, + GK_F6 = 19, + GK_F7 = 20, + GK_F8 = 21, + GK_F9 = 22, + GK_F10 = 23, + GK_F11 = 24, + GK_F12 = 25, + GK_DEL = 26, + GK_ESCAPE = 27, // ASCII + GK_FREE1 = 28, + GK_FREE2 = 29, + GK_BACK = 30, // browser back key + GK_CESCAPE = 31 // color escape +}; + +#endif //__D_GUI_H__ diff --git a/source/common/engine/i_interface.h b/source/common/engine/i_interface.h index 5bd03dd0b..f5fed4531 100644 --- a/source/common/engine/i_interface.h +++ b/source/common/engine/i_interface.h @@ -17,6 +17,7 @@ struct SystemCallbacks void (*OnScreenSizeChanged)(); IntRect(*GetSceneRect)(); FString(*GetLocationDescription)(); + void (*MenuDim)(); }; extern SystemCallbacks *sysCallbacks; diff --git a/source/common/engine/m_joy.cpp b/source/common/engine/m_joy.cpp index c20b406c7..578287ad5 100644 --- a/source/common/engine/m_joy.cpp +++ b/source/common/engine/m_joy.cpp @@ -36,7 +36,7 @@ #include "vectors.h" #include "m_joy.h" #include "gameconfigfile.h" -#include "d_event.h" +#include "d_eventbase.h" #include "cmdlib.h" #include "printf.h" diff --git a/source/common/engine/st_start.h b/source/common/engine/st_start.h index 5b8edad4b..1456e051c 100644 --- a/source/common/engine/st_start.h +++ b/source/common/engine/st_start.h @@ -57,6 +57,9 @@ public: virtual void NetMessage(const char *format, ...) {} // cover for printf virtual void NetDone() {} virtual bool NetLoop(bool (*timer_callback)(void *), void *userdata) { return false; } + virtual void AppendStatusLine(const char* status) {} + virtual void LoadingStatus(const char* message, int colors) {} + protected: int MaxPos, CurPos, NotchPos; }; diff --git a/source/common/objects/dobjgc.cpp b/source/common/objects/dobjgc.cpp index 40b29a680..9afa0b0af 100644 --- a/source/common/objects/dobjgc.cpp +++ b/source/common/objects/dobjgc.cpp @@ -59,8 +59,9 @@ #include "dobject.h" #include "templates.h" #include "c_dispatch.h" -#include "menu/menu.h" +#include "menu.h" #include "stats.h" +#include "printf.h" // MACROS ------------------------------------------------------------------ diff --git a/source/common/objects/dobjtype.cpp b/source/common/objects/dobjtype.cpp index 83653c20e..cf6d32d04 100644 --- a/source/common/objects/dobjtype.cpp +++ b/source/common/objects/dobjtype.cpp @@ -922,3 +922,31 @@ unsigned GetVirtualIndex(PClass *cls, const char *funcname) return VIndex; } + +void PClass::InitializeDefaults() +{ + if (VMType != nullptr) // purely internal classes have no symbol table + { + if (bRuntimeClass) + { + // Copy parent values from the parent defaults. + assert(ParentClass != nullptr); + if (Defaults != nullptr) ParentClass->InitializeSpecials(Defaults, ParentClass->Defaults, &PClass::SpecialInits); + for (const PField* field : Fields) + { + if (!(field->Flags & VARF_Native) && !(field->Flags & VARF_Meta)) + { + field->Type->SetDefaultValue(Defaults, unsigned(field->Offset), &SpecialInits); + } + } + } + if (Meta != nullptr) ParentClass->InitializeSpecials(Meta, ParentClass->Meta, &PClass::MetaInits); + for (const PField* field : Fields) + { + if (!(field->Flags & VARF_Native) && (field->Flags & VARF_Meta)) + { + field->Type->SetDefaultValue(Meta, unsigned(field->Offset), &MetaInits); + } + } + } +} \ No newline at end of file diff --git a/source/common/objects/dobjtype.h b/source/common/objects/dobjtype.h index 16adbf72f..07a48454e 100644 --- a/source/common/objects/dobjtype.h +++ b/source/common/objects/dobjtype.h @@ -46,6 +46,7 @@ public: int FindVirtualIndex(FName name, PFunction::Variant *variant, PFunction *parentfunc); PSymbol *FindSymbol(FName symname, bool searchparents) const; PField *AddField(FName name, PType *type, uint32_t flags); + void InitializeDefaults(); static void StaticInit(); static void StaticShutdown(); diff --git a/source/common/platform/posix/cocoa/i_input.mm b/source/common/platform/posix/cocoa/i_input.mm index dad875fba..3b562bcb8 100644 --- a/source/common/platform/posix/cocoa/i_input.mm +++ b/source/common/platform/posix/cocoa/i_input.mm @@ -38,7 +38,7 @@ #include "c_console.h" #include "c_cvars.h" #include "c_dispatch.h" -#include "d_event.h" +#include "d_eventbase.h" #include "c_buttons.h" #include "d_gui.h" #include "dikeys.h" diff --git a/source/common/platform/posix/cocoa/i_joystick.cpp b/source/common/platform/posix/cocoa/i_joystick.cpp index d7d7587ac..6f0e22c8b 100644 --- a/source/common/platform/posix/cocoa/i_joystick.cpp +++ b/source/common/platform/posix/cocoa/i_joystick.cpp @@ -35,7 +35,7 @@ #include #include -#include "d_event.h" +#include "d_eventbase.h" #include "i_system.h" #include "m_argv.h" #include "m_joy.h" diff --git a/source/common/platform/posix/sdl/i_input.cpp b/source/common/platform/posix/sdl/i_input.cpp index 164b0b228..6b34e6d64 100644 --- a/source/common/platform/posix/sdl/i_input.cpp +++ b/source/common/platform/posix/sdl/i_input.cpp @@ -34,7 +34,7 @@ #include "m_argv.h" #include "v_video.h" -#include "d_event.h" +#include "d_eventbase.h" #include "d_gui.h" #include "c_buttons.h" #include "c_console.h" diff --git a/source/common/platform/win32/i_dijoy.cpp b/source/common/platform/win32/i_dijoy.cpp index 0d471ab18..eb016fdd4 100644 --- a/source/common/platform/win32/i_dijoy.cpp +++ b/source/common/platform/win32/i_dijoy.cpp @@ -44,7 +44,7 @@ #include #include "i_input.h" -#include "d_event.h" +#include "d_eventbase.h" #include "templates.h" #include "gameconfigfile.h" #include "cmdlib.h" diff --git a/source/common/platform/win32/i_input.cpp b/source/common/platform/win32/i_input.cpp index 2a67766bd..8e9af9fa6 100644 --- a/source/common/platform/win32/i_input.cpp +++ b/source/common/platform/win32/i_input.cpp @@ -77,7 +77,7 @@ #include "s_soundinternal.h" #include "gameconfigfile.h" #include "hardware.h" -#include "d_event.h" +#include "d_eventbase.h" #include "v_text.h" #include "version.h" #include "engineerrors.h" diff --git a/source/common/platform/win32/i_keyboard.cpp b/source/common/platform/win32/i_keyboard.cpp index 9567809f5..7fdb83e3e 100644 --- a/source/common/platform/win32/i_keyboard.cpp +++ b/source/common/platform/win32/i_keyboard.cpp @@ -39,7 +39,7 @@ #include #include "i_input.h" -#include "d_event.h" +#include "d_eventbase.h" // MACROS ------------------------------------------------------------------ diff --git a/source/common/platform/win32/i_mouse.cpp b/source/common/platform/win32/i_mouse.cpp index a3aaec674..ddcdc7816 100644 --- a/source/common/platform/win32/i_mouse.cpp +++ b/source/common/platform/win32/i_mouse.cpp @@ -39,10 +39,12 @@ #include #include "i_input.h" -#include "d_event.h" +#include "d_eventbase.h" #include "d_gui.h" #include "hardware.h" -#include "menu/menu.h" +#include "menu.h" +#include "menustate.h" +#include "keydef.h" #include "i_interface.h" // MACROS ------------------------------------------------------------------ diff --git a/source/common/platform/win32/i_rawps2.cpp b/source/common/platform/win32/i_rawps2.cpp index a6b31970f..2a7547f3e 100644 --- a/source/common/platform/win32/i_rawps2.cpp +++ b/source/common/platform/win32/i_rawps2.cpp @@ -37,7 +37,7 @@ #include #include "i_input.h" -#include "d_event.h" +#include "d_eventbase.h" #include "templates.h" #include "gameconfigfile.h" #include "m_argv.h" diff --git a/source/common/platform/win32/i_xinput.cpp b/source/common/platform/win32/i_xinput.cpp index e473d8bd2..7085de82f 100644 --- a/source/common/platform/win32/i_xinput.cpp +++ b/source/common/platform/win32/i_xinput.cpp @@ -39,7 +39,7 @@ #include #include "i_input.h" -#include "d_event.h" +#include "d_eventbase.h" #include "templates.h" #include "gameconfigfile.h" #include "m_argv.h" diff --git a/source/common/rendering/hwrenderer/data/hw_cvars.cpp b/source/common/rendering/hwrenderer/data/hw_cvars.cpp index c8a7abc28..6faf39e0d 100644 --- a/source/common/rendering/hwrenderer/data/hw_cvars.cpp +++ b/source/common/rendering/hwrenderer/data/hw_cvars.cpp @@ -40,7 +40,8 @@ #include "c_dispatch.h" #include "v_video.h" #include "hw_cvars.h" -#include "menu/menu.h" +#include "menu.h" +#include "printf.h" CUSTOM_CVAR(Int, gl_fogmode, 1, CVAR_ARCHIVE | CVAR_NOINITCALL) diff --git a/source/common/rendering/v_video.cpp b/source/common/rendering/v_video.cpp index 2f11b86e3..435768c98 100644 --- a/source/common/rendering/v_video.cpp +++ b/source/common/rendering/v_video.cpp @@ -53,7 +53,7 @@ #include "cmdlib.h" #include "hardware.h" #include "m_png.h" -#include "menu/menu.h" +#include "menu.h" #include "vm.h" #include "r_videoscale.h" #include "i_time.h" diff --git a/source/common/scripting/core/imports.cpp b/source/common/scripting/core/imports.cpp index 0c277c964..b1b478b74 100644 --- a/source/common/scripting/core/imports.cpp +++ b/source/common/scripting/core/imports.cpp @@ -36,7 +36,7 @@ #include "gstrings.h" #include "v_font.h" -#include "menu/menu.h" +#include "menu.h" #include "types.h" #include "dictionary.h" #include "vm.h" diff --git a/source/common/scripting/frontend/zcc_compile.cpp b/source/common/scripting/frontend/zcc_compile.cpp index 59870ee9b..5c73fc1cc 100644 --- a/source/common/scripting/frontend/zcc_compile.cpp +++ b/source/common/scripting/frontend/zcc_compile.cpp @@ -650,6 +650,7 @@ int ZCCCompiler::Compile() CreateStructTypes(); CompileAllConstants(); CompileAllFields(); + InitDefaults(); InitFunctions(); return FScriptPosition::ErrorCounter; } @@ -1942,6 +1943,18 @@ void ZCCCompiler::SetImplicitArgs(TArray* args, TArray* argfla } +void ZCCCompiler::InitDefaults() +{ + for (auto c : Classes) + { + if (c->ClassType()->ParentClass) + { + auto ti = c->ClassType(); + ti->InitializeDefaults(); + } + } +} + //========================================================================== // // diff --git a/source/common/scripting/frontend/zcc_compile.h b/source/common/scripting/frontend/zcc_compile.h index 5c90f77dd..ca19d8aff 100644 --- a/source/common/scripting/frontend/zcc_compile.h +++ b/source/common/scripting/frontend/zcc_compile.h @@ -139,6 +139,7 @@ protected: void CompileFunction(ZCC_StructWork *c, ZCC_FuncDeclarator *f, bool forclass); void InitFunctions(); + virtual void InitDefaults(); TArray Constants; TArray Structs; diff --git a/source/common/scripting/interface/vmnatives.cpp b/source/common/scripting/interface/vmnatives.cpp new file mode 100644 index 000000000..b62e22993 --- /dev/null +++ b/source/common/scripting/interface/vmnatives.cpp @@ -0,0 +1,643 @@ +/* +** vmnatives.cpp +** +** VM exports for engine backend classes +** +**--------------------------------------------------------------------------- +** Copyright 2005-2020 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. +**--------------------------------------------------------------------------- +** +** +*/ + + +#include "texturemanager.h" +#include "filesystem.h" +#include "c_console.h" +#include "c_cvars.h" +#include "c_bind.h" +#include "c_dispatch.h" +#include "templates.h" +#include "menu.h" +#include "vm.h" +#include "gstrings.h" +#include "printf.h" +#include "s_music.h" + + +//========================================================================== +// +// texture manager exports +// +//========================================================================== + +DEFINE_ACTION_FUNCTION(_TexMan, GetName) +{ + PARAM_PROLOGUE; + PARAM_INT(texid); + auto tex = TexMan.GameByIndex(texid); + FString retval; + + if (tex != nullptr) + { + if (tex->GetName().IsNotEmpty()) retval = tex->GetName(); + else + { + // Textures for full path names do not have their own name, they merely link to the source lump. + auto lump = tex->GetSourceLump(); + if (fileSystem.GetLinkedTexture(lump) == tex) + retval = fileSystem.GetFileFullName(lump); + } + } + ACTION_RETURN_STRING(retval); +} + +static int CheckForTexture(const FString& name, int type, int flags) +{ + return TexMan.CheckForTexture(name, static_cast(type), flags).GetIndex(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, CheckForTexture, CheckForTexture) +{ + PARAM_PROLOGUE; + PARAM_STRING(name); + PARAM_INT(type); + PARAM_INT(flags); + ACTION_RETURN_INT(CheckForTexture(name, type, flags)); +} + +//========================================================================== +// +// +// +//========================================================================== + +static int GetTextureSize(int texid, int* py) +{ + auto tex = TexMan.GameByIndex(texid); + int x, y; + if (tex != nullptr) + { + x = int(0.5 + tex->GetDisplayWidth()); + y = int(0.5 + tex->GetDisplayHeight()); + } + else x = y = -1; + if (py) *py = y; + return x; +} + +DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, GetSize, GetTextureSize) +{ + PARAM_PROLOGUE; + PARAM_INT(texid); + int x, y; + x = GetTextureSize(texid, &y); + if (numret > 0) ret[0].SetInt(x); + if (numret > 1) ret[1].SetInt(y); + return MIN(numret, 2); +} + +//========================================================================== +// +// +// +//========================================================================== +static void GetScaledSize(int texid, DVector2* pvec) +{ + auto tex = TexMan.GameByIndex(texid); + double x, y; + if (tex != nullptr) + { + x = tex->GetDisplayWidth(); + y = tex->GetDisplayHeight(); + } + else x = y = -1; + if (pvec) + { + pvec->X = x; + pvec->Y = y; + } +} + +DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, GetScaledSize, GetScaledSize) +{ + PARAM_PROLOGUE; + PARAM_INT(texid); + DVector2 vec; + GetScaledSize(texid, &vec); + ACTION_RETURN_VEC2(vec); +} + +//========================================================================== +// +// +// +//========================================================================== +static void GetScaledOffset(int texid, DVector2* pvec) +{ + auto tex = TexMan.GameByIndex(texid); + double x, y; + if (tex != nullptr) + { + x = tex->GetDisplayLeftOffset(); + y = tex->GetDisplayTopOffset(); + } + else x = y = -1; + if (pvec) + { + pvec->X = x; + pvec->Y = y; + } +} + +DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, GetScaledOffset, GetScaledOffset) +{ + PARAM_PROLOGUE; + PARAM_INT(texid); + DVector2 vec; + GetScaledOffset(texid, &vec); + ACTION_RETURN_VEC2(vec); +} + +//========================================================================== +// +// +// +//========================================================================== + +static int CheckRealHeight(int texid) +{ + auto tex = TexMan.GameByIndex(texid); + if (tex != nullptr) return tex->CheckRealHeight(); + else return -1; +} + +DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, CheckRealHeight, CheckRealHeight) +{ + PARAM_PROLOGUE; + PARAM_INT(texid); + ACTION_RETURN_INT(CheckRealHeight(texid)); +} + +bool OkForLocalization(FTextureID texnum, const char* substitute); + +static int OkForLocalization_(int index, const FString& substitute) +{ + return OkForLocalization(FSetTextureID(index), substitute); +} + +DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, OkForLocalization, OkForLocalization_) +{ + PARAM_PROLOGUE; + PARAM_INT(name); + PARAM_STRING(subst) + ACTION_RETURN_INT(OkForLocalization_(name, subst)); +} + + +//===================================================================================== +// +// FFont exports +// +//===================================================================================== + +static FFont *GetFont(int name) +{ + return V_GetFont(FName(ENamedName(name)).GetChars()); +} + +DEFINE_ACTION_FUNCTION_NATIVE(FFont, GetFont, GetFont) +{ + PARAM_PROLOGUE; + PARAM_INT(name); + ACTION_RETURN_POINTER(GetFont(name)); +} + +static FFont *FindFont(int name) +{ + return FFont::FindFont(FName(ENamedName(name))); +} + +DEFINE_ACTION_FUNCTION_NATIVE(FFont, FindFont, FindFont) +{ + PARAM_PROLOGUE; + PARAM_NAME(name); + ACTION_RETURN_POINTER(FFont::FindFont(name)); +} + +static int GetCharWidth(FFont *font, int code) +{ + return font->GetCharWidth(code); +} + +DEFINE_ACTION_FUNCTION_NATIVE(FFont, GetCharWidth, GetCharWidth) +{ + PARAM_SELF_STRUCT_PROLOGUE(FFont); + PARAM_INT(code); + ACTION_RETURN_INT(self->GetCharWidth(code)); +} + +static int GetHeight(FFont *font) +{ + return font->GetHeight(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(FFont, GetHeight, GetHeight) +{ + PARAM_SELF_STRUCT_PROLOGUE(FFont); + ACTION_RETURN_INT(self->GetHeight()); +} + +static int GetDisplacement(FFont* font) +{ + return font->GetDisplacement(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(FFont, GetDisplacement, GetDisplacement) +{ + PARAM_SELF_STRUCT_PROLOGUE(FFont); + ACTION_RETURN_INT(self->GetDisplacement()); +} + +double GetBottomAlignOffset(FFont *font, int c); +DEFINE_ACTION_FUNCTION_NATIVE(FFont, GetBottomAlignOffset, GetBottomAlignOffset) +{ + PARAM_SELF_STRUCT_PROLOGUE(FFont); + PARAM_INT(code); + ACTION_RETURN_FLOAT(GetBottomAlignOffset(self, code)); +} + +static int StringWidth(FFont *font, const FString &str) +{ + const char *txt = str[0] == '$' ? GStrings(&str[1]) : str.GetChars(); + return font->StringWidth(txt); +} + +DEFINE_ACTION_FUNCTION_NATIVE(FFont, StringWidth, StringWidth) +{ + PARAM_SELF_STRUCT_PROLOGUE(FFont); + PARAM_STRING(str); + ACTION_RETURN_INT(StringWidth(self, str)); +} + +static int GetMaxAscender(FFont* font, const FString& str) +{ + const char* txt = str[0] == '$' ? GStrings(&str[1]) : str.GetChars(); + return font->GetMaxAscender(txt); +} + +DEFINE_ACTION_FUNCTION_NATIVE(FFont, GetMaxAscender, GetMaxAscender) +{ + PARAM_SELF_STRUCT_PROLOGUE(FFont); + PARAM_STRING(str); + ACTION_RETURN_INT(GetMaxAscender(self, str)); +} + +static int CanPrint(FFont *font, const FString &str) +{ + const char *txt = str[0] == '$' ? GStrings(&str[1]) : str.GetChars(); + return font->CanPrint(txt); +} + +DEFINE_ACTION_FUNCTION_NATIVE(FFont, CanPrint, CanPrint) +{ + PARAM_SELF_STRUCT_PROLOGUE(FFont); + PARAM_STRING(str); + ACTION_RETURN_INT(CanPrint(self, str)); +} + +static int FindFontColor(int name) +{ + return V_FindFontColor(ENamedName(name)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(FFont, FindFontColor, FindFontColor) +{ + PARAM_PROLOGUE; + PARAM_NAME(code); + ACTION_RETURN_INT((int)V_FindFontColor(code)); +} + +static void GetCursor(FFont *font, FString *result) +{ + *result = font->GetCursor(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(FFont, GetCursor, GetCursor) +{ + PARAM_SELF_STRUCT_PROLOGUE(FFont); + ACTION_RETURN_STRING(FString(self->GetCursor())); +} + +//========================================================================== +// +// file system +// +//========================================================================== + +DEFINE_ACTION_FUNCTION(_Wads, GetNumLumps) +{ + PARAM_PROLOGUE; + ACTION_RETURN_INT(fileSystem.GetNumEntries()); +} + +DEFINE_ACTION_FUNCTION(_Wads, CheckNumForName) +{ + PARAM_PROLOGUE; + PARAM_STRING(name); + PARAM_INT(ns); + PARAM_INT(wadnum); + PARAM_BOOL(exact); + ACTION_RETURN_INT(fileSystem.CheckNumForName(name, ns, wadnum, exact)); +} + +DEFINE_ACTION_FUNCTION(_Wads, CheckNumForFullName) +{ + PARAM_PROLOGUE; + PARAM_STRING(name); + ACTION_RETURN_INT(fileSystem.CheckNumForFullName(name)); +} + +DEFINE_ACTION_FUNCTION(_Wads, FindLump) +{ + PARAM_PROLOGUE; + PARAM_STRING(name); + PARAM_INT(startlump); + PARAM_INT(ns); + const bool isLumpValid = startlump >= 0 && startlump < fileSystem.GetNumEntries(); + ACTION_RETURN_INT(isLumpValid ? fileSystem.FindLump(name, &startlump, 0 != ns) : -1); +} + +DEFINE_ACTION_FUNCTION(_Wads, GetLumpName) +{ + PARAM_PROLOGUE; + PARAM_INT(lump); + FString lumpname; + fileSystem.GetFileShortName(lumpname, lump); + ACTION_RETURN_STRING(lumpname); +} + +DEFINE_ACTION_FUNCTION(_Wads, GetLumpFullName) +{ + PARAM_PROLOGUE; + PARAM_INT(lump); + ACTION_RETURN_STRING(fileSystem.GetFileFullName(lump)); +} + +DEFINE_ACTION_FUNCTION(_Wads, GetLumpNamespace) +{ + PARAM_PROLOGUE; + PARAM_INT(lump); + ACTION_RETURN_INT(fileSystem.GetFileNamespace(lump)); +} + +DEFINE_ACTION_FUNCTION(_Wads, ReadLump) +{ + PARAM_PROLOGUE; + PARAM_INT(lump); + const bool isLumpValid = lump >= 0 && lump < fileSystem.GetNumEntries(); + ACTION_RETURN_STRING(isLumpValid ? fileSystem.ReadFile(lump).GetString() : FString()); +} + +//========================================================================== +// +// CVARs +// +//========================================================================== + +DEFINE_ACTION_FUNCTION(_CVar, GetInt) +{ + PARAM_SELF_STRUCT_PROLOGUE(FBaseCVar); + auto v = self->GetGenericRep(CVAR_Int); + ACTION_RETURN_INT(v.Int); +} + +DEFINE_ACTION_FUNCTION(_CVar, GetFloat) +{ + PARAM_SELF_STRUCT_PROLOGUE(FBaseCVar); + auto v = self->GetGenericRep(CVAR_Float); + ACTION_RETURN_FLOAT(v.Float); +} + +DEFINE_ACTION_FUNCTION(_CVar, GetString) +{ + PARAM_SELF_STRUCT_PROLOGUE(FBaseCVar); + auto v = self->GetGenericRep(CVAR_String); + ACTION_RETURN_STRING(v.String); +} + +DEFINE_ACTION_FUNCTION(_CVar, SetInt) +{ + // Only menus are allowed to change CVARs. + PARAM_SELF_STRUCT_PROLOGUE(FBaseCVar); + if (!(self->GetFlags() & CVAR_MOD)) + { + // Only menus are allowed to change non-mod CVARs. + if (DMenu::InMenu == 0) + { + ThrowAbortException(X_OTHER, "Attempt to change CVAR '%s' outside of menu code", self->GetName()); + } + } + PARAM_INT(val); + UCVarValue v; + v.Int = val; + self->SetGenericRep(v, CVAR_Int); + return 0; +} + +DEFINE_ACTION_FUNCTION(_CVar, SetFloat) +{ + PARAM_SELF_STRUCT_PROLOGUE(FBaseCVar); + if (!(self->GetFlags() & CVAR_MOD)) + { + // Only menus are allowed to change non-mod CVARs. + if (DMenu::InMenu == 0) + { + ThrowAbortException(X_OTHER, "Attempt to change CVAR '%s' outside of menu code", self->GetName()); + } + } + PARAM_FLOAT(val); + UCVarValue v; + v.Float = (float)val; + self->SetGenericRep(v, CVAR_Float); + return 0; +} + +DEFINE_ACTION_FUNCTION(_CVar, SetString) +{ + // Only menus are allowed to change CVARs. + PARAM_SELF_STRUCT_PROLOGUE(FBaseCVar); + if (!(self->GetFlags() & CVAR_MOD)) + { + // Only menus are allowed to change non-mod CVARs. + if (DMenu::InMenu == 0) + { + ThrowAbortException(X_OTHER, "Attempt to change CVAR '%s' outside of menu code", self->GetName()); + } + } + PARAM_STRING(val); + UCVarValue v; + v.String = val.GetChars(); + self->SetGenericRep(v, CVAR_String); + return 0; +} + +DEFINE_ACTION_FUNCTION(_CVar, GetRealType) +{ + PARAM_SELF_STRUCT_PROLOGUE(FBaseCVar); + ACTION_RETURN_INT(self->GetRealType()); +} + +DEFINE_ACTION_FUNCTION(_CVar, ResetToDefault) +{ + PARAM_SELF_STRUCT_PROLOGUE(FBaseCVar); + if (!(self->GetFlags() & CVAR_MOD)) + { + // Only menus are allowed to change non-mod CVARs. + if (DMenu::InMenu == 0) + { + ThrowAbortException(X_OTHER, "Attempt to change CVAR '%s' outside of menu code", self->GetName()); + } + } + + self->ResetToDefault(); + return 0; +} + +DEFINE_ACTION_FUNCTION(_CVar, FindCVar) +{ + PARAM_PROLOGUE; + PARAM_NAME(name); + ACTION_RETURN_POINTER(FindCVar(name.GetChars(), nullptr)); +} + +//============================================================================= +// +// +// +//============================================================================= + +DEFINE_ACTION_FUNCTION(FKeyBindings, SetBind) +{ + PARAM_SELF_STRUCT_PROLOGUE(FKeyBindings); + PARAM_INT(k); + PARAM_STRING(cmd); + + // Only menus are allowed to change bindings. + if (DMenu::InMenu == 0) + { + I_FatalError("Attempt to change key bindings outside of menu code to '%s'", cmd.GetChars()); + } + + + self->SetBind(k, cmd); + return 0; +} + +DEFINE_ACTION_FUNCTION(FKeyBindings, NameKeys) +{ + PARAM_PROLOGUE; + PARAM_INT(k1); + PARAM_INT(k2); + char buffer[120]; + C_NameKeys(buffer, k1, k2); + ACTION_RETURN_STRING(buffer); +} + +DEFINE_ACTION_FUNCTION(FKeyBindings, GetKeysForCommand) +{ + PARAM_SELF_STRUCT_PROLOGUE(FKeyBindings); + PARAM_STRING(cmd); + int k1, k2; + self->GetKeysForCommand(cmd.GetChars(), &k1, &k2); + if (numret > 0) ret[0].SetInt(k1); + if (numret > 1) ret[1].SetInt(k2); + return MIN(numret, 2); +} + +DEFINE_ACTION_FUNCTION(FKeyBindings, UnbindACommand) +{ + PARAM_SELF_STRUCT_PROLOGUE(FKeyBindings); + PARAM_STRING(cmd); + + // Only menus are allowed to change bindings. + if (DMenu::InMenu == 0) + { + I_FatalError("Attempt to unbind key bindings for '%s' outside of menu code", cmd.GetChars()); + } + + self->UnbindACommand(cmd); + return 0; +} + +// This is only accessible to the special menu item to run CCMDs. +DEFINE_ACTION_FUNCTION(DOptionMenuItemCommand, DoCommand) +{ + if (CurrentMenu == nullptr) return 0; + PARAM_PROLOGUE; + PARAM_STRING(cmd); + PARAM_BOOL(unsafe); + UnsafeExecutionScope scope(unsafe); + C_DoCommand(cmd); + return 0; +} + +DEFINE_ACTION_FUNCTION(_Console, MidPrint) +{ + PARAM_PROLOGUE; + PARAM_POINTER(fnt, FFont); + PARAM_STRING(text); + PARAM_BOOL(bold); + + const char* txt = text[0] == '$' ? GStrings(&text[1]) : text.GetChars(); + C_MidPrint(fnt, txt, bold); + return 0; +} + +DEFINE_ACTION_FUNCTION(_Console, HideConsole) +{ + C_HideConsole(); + return 0; +} + +DEFINE_ACTION_FUNCTION(_Console, Printf) +{ + PARAM_PROLOGUE; + PARAM_VA_POINTER(va_reginfo) // Get the hidden type information array + + FString s = FStringFormat(VM_ARGS_NAMES); + Printf("%s\n", s.GetChars()); + return 0; +} + +DEFINE_GLOBAL_NAMED(mus_playing, musplaying); +DEFINE_FIELD_X(MusPlayingInfo, MusPlayingInfo, name); +DEFINE_FIELD_X(MusPlayingInfo, MusPlayingInfo, baseorder); +DEFINE_FIELD_X(MusPlayingInfo, MusPlayingInfo, loop); + +DEFINE_GLOBAL_NAMED(PClass::AllClasses, AllClasses) +DEFINE_GLOBAL(Bindings) diff --git a/source/common/scripting/vm/vmexec.h b/source/common/scripting/vm/vmexec.h index d88945a44..154cac29e 100644 --- a/source/common/scripting/vm/vmexec.h +++ b/source/common/scripting/vm/vmexec.h @@ -360,6 +360,10 @@ static int ExecScriptFunc(VMFrameStack *stack, VMReturn *ret, int numret) OP(SS): ASSERTA(a); ASSERTS(B); ASSERTKD(C); GETADDR(PA,KC,X_WRITE_NIL); +#ifdef _DEBUG + // Should never happen, if it does it indicates a compiler side problem. + if (((FString*)ptr)->GetChars() == nullptr) ThrowAbortException(X_OTHER, "Uninitialized string"); +#endif *(FString *)ptr = reg.s[B]; NEXTOP; OP(SS_R): diff --git a/source/common/textures/gametexture.h b/source/common/textures/gametexture.h index c624fa9f5..5f32e1fdb 100644 --- a/source/common/textures/gametexture.h +++ b/source/common/textures/gametexture.h @@ -103,7 +103,7 @@ class FGameTexture int flags = 0; uint8_t warped = 0; int8_t expandSprite = -1; - uint16_t GlowHeight; + uint16_t GlowHeight = 128; PalEntry GlowColor = 0; int16_t SkyOffset = 0; diff --git a/source/common/textures/texturemanager.h b/source/common/textures/texturemanager.h index 90ad35209..d9da9d20d 100644 --- a/source/common/textures/texturemanager.h +++ b/source/common/textures/texturemanager.h @@ -3,6 +3,7 @@ #include #include "tarray.h" #include "textureid.h" +#include "textures.h" #include "basics.h" #include "texmanip.h" #include "name.h" diff --git a/source/common/utility/m_alloc.cpp b/source/common/utility/m_alloc.cpp index 8ab7b6fcc..5c2ea25b9 100644 --- a/source/common/utility/m_alloc.cpp +++ b/source/common/utility/m_alloc.cpp @@ -54,7 +54,7 @@ #endif #ifndef _DEBUG -#if !defined(__solaris__) && !defined(__OpenBSD__) +#if !defined(__solaris__) && !defined(__OpenBSD__) && !defined(__DragonFly__) void *M_Malloc(size_t size) { void *block = malloc(size); @@ -124,7 +124,7 @@ void *M_Realloc(void *memblock, size_t size) #include #endif -#if !defined(__solaris__) && !defined(__OpenBSD__) +#if !defined(__solaris__) && !defined(__OpenBSD__) && !defined(__DragonFly__) void *M_Malloc_Dbg(size_t size, const char *file, int lineno) { void *block = _malloc_dbg(size, _NORMAL_BLOCK, file, lineno); @@ -192,7 +192,7 @@ void *M_Realloc_Dbg(void *memblock, size_t size, const char *file, int lineno) #endif #endif -#if !defined(__solaris__) && !defined(__OpenBSD__) +#if !defined(__solaris__) && !defined(__OpenBSD__) && !defined(__DragonFly__) void M_Free (void *block) { if (block != NULL) diff --git a/source/core/console/c_console.cpp b/source/core/console/c_console.cpp index e2fecc597..5840bbace 100644 --- a/source/core/console/c_console.cpp +++ b/source/core/console/c_console.cpp @@ -1759,7 +1759,6 @@ CCMD(toggleconsole) C_ToggleConsole(); } -#if 0 // The Build engine cannot do this at the moment. Q: Implement and redirect some messages here? /* Printing in the middle of the screen */ CVAR(Float, con_midtime, 3.f, CVAR_ARCHIVE) @@ -1768,6 +1767,7 @@ const char *console_bar = "----------------------------------------"; void C_MidPrint (FFont *font, const char *msg, bool bold) { +#if 0 // The Build engine cannot do this at the moment. Q: Implement and redirect some messages here? if (StatusBar == nullptr || screen == nullptr) return; @@ -1793,8 +1793,8 @@ void C_MidPrint (FFont *font, const char *msg, bool bold) { StatusBar->DetachMessage (MAKE_ID('C','N','T','R')); } -} #endif +} /****** Tab completion code ******/ diff --git a/source/core/console/d_event.cpp b/source/core/console/d_event.cpp index cc926e9b3..71787e781 100644 --- a/source/core/console/d_event.cpp +++ b/source/core/console/d_event.cpp @@ -40,10 +40,6 @@ #include "inputstate.h" #include "menu.h" -int eventhead; -int eventtail; -event_t events[NUM_EVENTS]; - //========================================================================== // // G_Responder @@ -87,35 +83,6 @@ bool G_Responder (event_t *ev) } -//========================================================================== -// -// D_ProcessEvents -// -// Send all the events of the given timestamp down the responder chain. -// Events are asynchronous inputs generally generated by the game user. -// Events can be discarded if no responder claims them -// -//========================================================================== - -void D_ProcessEvents (void) -{ - event_t *ev; - while (eventtail != eventhead) - { - ev = &events[eventtail]; - eventtail = (eventtail + 1) & (NUM_EVENTS - 1); - if (ev->type == EV_None) - continue; - /*if (ev->type == EV_DeviceChange) - UpdateJoystickMenu(I_UpdateDeviceList());*/ - if (C_Responder (ev)) - continue; // console ate the event - if (M_Responder (ev)) - continue; // menu ate the event - G_Responder (ev); - } -} - //========================================================================== // // D_PostEvent @@ -143,41 +110,6 @@ void D_PostEvent (const event_t *ev) // Also add it to the event queue. events[eventhead] = *ev; - eventhead = (eventhead+1)&(NUM_EVENTS-1); + eventhead = (eventhead+1)&(MAXEVENTS-1); } -//========================================================================== -// -// D_RemoveNextCharEvent -// -// Removes the next EV_GUI_Char event in the input queue. Used by the menu, -// since it (generally) consumes EV_GUI_KeyDown events and not EV_GUI_Char -// events, and it needs to ensure that there is no left over input when it's -// done. If there are multiple EV_GUI_KeyDowns before the EV_GUI_Char, then -// there are dead chars involved, so those should be removed, too. We do -// this by changing the message type to EV_None rather than by actually -// removing the event from the queue. -// -//========================================================================== - -void D_RemoveNextCharEvent() -{ - assert(events[eventtail].type == EV_GUI_Event && events[eventtail].subtype == EV_GUI_KeyDown); - for (int evnum = eventtail; evnum != eventhead; evnum = (evnum+1) & (NUM_EVENTS-1)) - { - event_t *ev = &events[evnum]; - if (ev->type != EV_GUI_Event) - break; - if (ev->subtype == EV_GUI_KeyDown || ev->subtype == EV_GUI_Char) - { - ev->type = EV_None; - if (ev->subtype == EV_GUI_Char) - break; - } - else - { - break; - } - } -} - diff --git a/source/core/console/d_event.h b/source/core/console/d_event.h index 5723ca3aa..509f86f15 100644 --- a/source/core/console/d_event.h +++ b/source/core/console/d_event.h @@ -1,40 +1,8 @@ #pragma once #include - -// Input event types. -enum EGenericEvent -{ - EV_None, - EV_KeyDown, // data1: scan code, data2: Qwerty ASCII code - EV_KeyUp, // same - EV_Mouse, // x, y: mouse movement deltas - EV_GUI_Event, // subtype specifies actual event - EV_DeviceChange,// a device has been connected or removed -}; - -// Event structure. -struct event_t -{ - uint8_t type; - uint8_t subtype; - int16_t data1; // keys / mouse/joystick buttons - int16_t data2; - int16_t data3; - int x; // mouse/joystick x move - int y; // mouse/joystick y move -}; - +#include "d_eventbase.h" // Called by IO functions when input is detected. void D_PostEvent (const event_t* ev); -void D_RemoveNextCharEvent(); -void D_ProcessEvents(void); - -enum -{ - NUM_EVENTS = 128 -}; - -extern event_t events[NUM_EVENTS]; diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index c3274ef6e..10d815401 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -1111,3 +1111,7 @@ void updatePauseStatus() } } +bool OkForLocalization(FTextureID texnum, const char* substitute) +{ + return false; +} diff --git a/source/core/menu/joystickmenu.cpp b/source/core/menu/joystickmenu.cpp index ccb3ef6d5..0c3163f53 100644 --- a/source/core/menu/joystickmenu.cpp +++ b/source/core/menu/joystickmenu.cpp @@ -418,9 +418,9 @@ void UpdateJoystickMenu(IJoystickConfig *selected) if (i == (int)Joysticks.Size()) { SELECTED_JOYSTICK = NULL; - if (DMenu::CurrentMenu != NULL && dynamic_cast(DMenu::CurrentMenu)) + if (CurrentMenu != NULL && dynamic_cast(CurrentMenu)) { - DMenu::CurrentMenu->Close(); + CurrentMenu->Close(); } } } diff --git a/source/core/menu/listmenu.cpp b/source/core/menu/listmenu.cpp index 7f0d97926..8beb4a63c 100644 --- a/source/core/menu/listmenu.cpp +++ b/source/core/menu/listmenu.cpp @@ -536,7 +536,7 @@ bool FListMenuItemSelectable::MouseEvent(int type, int x, int y) { if (type == DMenu::MOUSE_Release) { - if (NULL != DMenu::CurrentMenu && DMenu::CurrentMenu->MenuEvent(MKEY_Enter, true)) + if (NULL != CurrentMenu && CurrentMenu->MenuEvent(MKEY_Enter, true)) { return true; } diff --git a/source/core/menu/loadsavemenu.cpp b/source/core/menu/loadsavemenu.cpp index 3e8dfdabc..2469b16f6 100644 --- a/source/core/menu/loadsavemenu.cpp +++ b/source/core/menu/loadsavemenu.cpp @@ -33,7 +33,7 @@ ** */ -#include "menu/menu.h" +#include "menu.h" #include "version.h" #include "m_png.h" #include "filesystem.h" diff --git a/source/core/menu/menu.cpp b/source/core/menu/menu.cpp index 84e86e491..901120099 100644 --- a/source/core/menu/menu.cpp +++ b/source/core/menu/menu.cpp @@ -85,8 +85,9 @@ CVAR(Int, m_show_backbutton, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) TArray menuClasses(TArray::ENoInit(0)); -DMenu *DMenu::CurrentMenu; +DMenu *CurrentMenu; int DMenu::MenuTime; +bool DMenu::InMenu; FNewGameStartup NewGameStartupInfo; EMenuState menuactive; @@ -207,7 +208,7 @@ bool DMenu::MenuEvent (int mkey, bool fromcontroller) { if (scriptID != 0) { - M_MenuSound(DMenu::CurrentMenu->mParentMenu? BackSound : CloseSound); + M_MenuSound(CurrentMenu->mParentMenu? BackSound : CloseSound); Close(); return true; } @@ -224,24 +225,24 @@ bool DMenu::MenuEvent (int mkey, bool fromcontroller) void DMenu::Close () { - assert(DMenu::CurrentMenu == this); + assert(CurrentMenu == this); - DMenu::CurrentMenu = mParentMenu; + CurrentMenu = mParentMenu; if (mParentMenu && transition.StartTransition(this, mParentMenu, MA_Return)) { - g_currentMenu = DMenu::CurrentMenu->scriptID; + g_currentMenu = CurrentMenu->scriptID; } else { Destroy(); toDelete.Push(this); - if (DMenu::CurrentMenu == NULL) + if (CurrentMenu == NULL) { M_ClearMenus(); } else { - g_currentMenu = DMenu::CurrentMenu->scriptID; + g_currentMenu = CurrentMenu->scriptID; } } } @@ -322,7 +323,7 @@ void DMenu::Ticker () void DMenu::Drawer () { - if (this == DMenu::CurrentMenu && BackbuttonAlpha > 0 && m_show_backbutton >= 0 && m_use_mouse) + if (this == CurrentMenu && BackbuttonAlpha > 0 && m_show_backbutton >= 0 && m_use_mouse) { auto texid = TexMan.CheckForTexture("engine/graphics/m_back.png", ETextureType::Any); if (texid.isValid()) @@ -365,7 +366,7 @@ void M_StartControlPanel (bool makeSound) { static bool created = false; // intro might call this repeatedly - if (DMenu::CurrentMenu != NULL) + if (CurrentMenu != NULL) return; if (!created) // Cannot do this earlier. @@ -396,7 +397,7 @@ void M_StartControlPanel (bool makeSound) void Menu_Open(int playerid) { - M_StartControlPanel(DMenu::CurrentMenu == nullptr); + M_StartControlPanel(CurrentMenu == nullptr); } //============================================================================= @@ -409,12 +410,12 @@ void M_ActivateMenu(DMenu *menu) { g_currentMenu = menu->scriptID; if (menuactive == MENU_Off) menuactive = MENU_On; - if (DMenu::CurrentMenu != NULL) + if (CurrentMenu != NULL) { - DMenu::CurrentMenu->ReleaseCapture(); - transition.StartTransition(DMenu::CurrentMenu, menu, MA_Advance); + CurrentMenu->ReleaseCapture(); + transition.StartTransition(CurrentMenu, menu, MA_Advance); } - DMenu::CurrentMenu = menu; + CurrentMenu = menu; DMenu::MenuTime = -1; M_Ticker(); // This needs to be called once here to make sure that the menu actually has ticked before it gets drawn for the first time. } @@ -482,8 +483,8 @@ bool M_SetMenu(FName menu, int param, FName caller) case NAME_EngineCredits: case NAME_EngineCredits2: { - auto m = DMenu::CurrentMenu; - DMenu::CurrentMenu = m->mParentMenu; + auto m = CurrentMenu; + CurrentMenu = m->mParentMenu; m->mParentMenu = nullptr; toDelete.Push(m); break; @@ -579,7 +580,7 @@ bool M_SetMenu(FName menu, int param, FName caller) { newmenu = new DListMenu; } - newmenu->Init(DMenu::CurrentMenu, ld); + newmenu->Init(CurrentMenu, ld); M_ActivateMenu(newmenu); } } @@ -603,7 +604,7 @@ bool M_SetMenu(FName menu, int param, FName caller) { newmenu = new DOptionMenu; } - newmenu->Init(DMenu::CurrentMenu, ld); + newmenu->Init(CurrentMenu, ld); M_ActivateMenu(newmenu); } else if ((*desc)->mType == MDESC_ImageScroller) @@ -627,7 +628,7 @@ bool M_SetMenu(FName menu, int param, FName caller) { newmenu = new DImageScrollerMenu; } - newmenu->Init(DMenu::CurrentMenu, ld); + newmenu->Init(CurrentMenu, ld); M_ActivateMenu(newmenu); } return true; @@ -641,7 +642,7 @@ bool M_SetMenu(FName menu, int param, FName caller) if (menuclass->IsDescendantOf(RUNTIME_CLASS(DMenu))) { DMenu *newmenu = (DMenu*)menuclass->CreateNew(); - newmenu->mParentMenu = DMenu::CurrentMenu; + newmenu->mParentMenu = CurrentMenu; M_ActivateMenu(newmenu); return true; } @@ -673,7 +674,7 @@ bool M_DoResponder (event_t *ev) } */ - if (DMenu::CurrentMenu != NULL && menuactive != MENU_Off) + if (CurrentMenu != NULL && menuactive != MENU_Off) { // There are a few input sources we are interested in: // @@ -708,9 +709,9 @@ bool M_DoResponder (event_t *ev) } // pass everything else on to the current menu - return DMenu::CurrentMenu->Responder(ev); + return CurrentMenu->Responder(ev); } - else if (DMenu::CurrentMenu->TranslateKeyboardEvents()) + else if (CurrentMenu->TranslateKeyboardEvents()) { ch = ev->data1; keyup = ev->subtype == EV_GUI_KeyUp; @@ -729,7 +730,7 @@ bool M_DoResponder (event_t *ev) default: if (!keyup) { - return DMenu::CurrentMenu->Responder(ev); + return CurrentMenu->Responder(ev); } break; } @@ -812,11 +813,11 @@ bool M_DoResponder (event_t *ev) { MenuButtonTickers[mkey] = KEY_REPEAT_DELAY; } - DMenu::CurrentMenu->MenuEvent(mkey, fromcontroller); + CurrentMenu->MenuEvent(mkey, fromcontroller); return true; } } - return DMenu::CurrentMenu->Responder(ev) || !keyup; + return CurrentMenu->Responder(ev) || !keyup; } else if (MenuEnabled) { @@ -871,12 +872,12 @@ void M_Ticker (void) { DMenu::MenuTime++; if (DMenu::MenuTime & 3) return; - if (DMenu::CurrentMenu != NULL && menuactive != MENU_Off) + if (CurrentMenu != NULL && menuactive != MENU_Off) { if (DMenu::MenuTime != 0) D_ProcessEvents(); // The main loop is blocked when the menu is open and cannot dispatch the events. if (transition.previous) transition.previous->Ticker(); - if (DMenu::CurrentMenu == nullptr) return; // In case one of the sub-screens has closed the menu. - DMenu::CurrentMenu->Ticker(); + if (CurrentMenu == nullptr) return; // In case one of the sub-screens has closed the menu. + CurrentMenu->Ticker(); for (int i = 0; i < NUM_MKEYS; ++i) { @@ -885,7 +886,7 @@ void M_Ticker (void) if (MenuButtonTickers[i] > 0 && --MenuButtonTickers[i] <= 0) { MenuButtonTickers[i] = KEY_REPEAT_RATE; - DMenu::CurrentMenu->MenuEvent(i, MenuButtonOrigin[i]); + CurrentMenu->MenuEvent(i, MenuButtonOrigin[i]); } } } @@ -912,9 +913,9 @@ void M_Drawer (void) { PalEntry fade = 0x70000000; - if (DMenu::CurrentMenu != NULL && menuactive != MENU_Off) + if (CurrentMenu != NULL && menuactive != MENU_Off) { - if (DMenu::CurrentMenu->DimAllowed() && fade && !DrawBackground) twod->AddColorOnlyQuad(0, 0, screen->GetWidth(), screen->GetHeight(), fade); + if (CurrentMenu->DimAllowed() && fade && !DrawBackground) twod->AddColorOnlyQuad(0, 0, screen->GetWidth(), screen->GetHeight(), fade); bool going = false; if (transition.previous) @@ -929,10 +930,10 @@ void M_Drawer (void) } if (!going) { - assert(DMenu::CurrentMenu); - DMenu::CurrentMenu->origin = { 0,0 }; + assert(CurrentMenu); + CurrentMenu->origin = { 0,0 }; // else if (DrawBackground) Menu_DrawBackground(origin); - DMenu::CurrentMenu->Drawer(); + CurrentMenu->Drawer(); } } } @@ -954,7 +955,7 @@ void M_ClearMenus (bool final) M_DemoNoPlay = false; transition.previous = transition.current = nullptr; transition.dir = 0; - auto menu = DMenu::CurrentMenu; + auto menu = CurrentMenu; while (menu != nullptr) { auto nextm = menu->mParentMenu; @@ -962,7 +963,7 @@ void M_ClearMenus (bool final) delete menu; menu = nextm; } - DMenu::CurrentMenu = nullptr; + CurrentMenu = nullptr; menuactive = MENU_Off; M_UnpauseSound(); if (!final) @@ -978,7 +979,7 @@ void Menu_Close(int playerid) bool M_Active() { - return DMenu::CurrentMenu != nullptr || ConsoleState == c_down || ConsoleState == c_falling; + return CurrentMenu != nullptr || ConsoleState == c_down || ConsoleState == c_falling; } //============================================================================= @@ -1000,11 +1001,11 @@ void M_MenuSound(EMenuSounds snd) void M_PreviousMenu() { - if (DMenu::CurrentMenu != nullptr) + if (CurrentMenu != nullptr) { - DMenu* parent = DMenu::CurrentMenu->mParentMenu; - DMenu::CurrentMenu->Destroy(); - DMenu::CurrentMenu = parent; + DMenu* parent = CurrentMenu->mParentMenu; + CurrentMenu->Destroy(); + CurrentMenu = parent; } } @@ -1122,3 +1123,4 @@ CCMD(openloadmenu) M_StartControlPanel(true); M_SetMenu(NAME_Loadgamemenu); } + diff --git a/source/core/menu/menu.h b/source/core/menu/menu.h index 549db2e7c..9458ecc6f 100644 --- a/source/core/menu/menu.h +++ b/source/core/menu/menu.h @@ -11,6 +11,7 @@ #include "zstring.h" #include "baselayer.h" #include "v_draw.h" +#include "menustate.h" EXTERN_CVAR(Float, snd_menuvolume) EXTERN_CVAR(Int, m_use_mouse); @@ -85,14 +86,6 @@ typedef struct MenuGameplayStemEntry extern MenuGameplayStemEntry g_MenuGameplayEntries[MAXMENUGAMEPLAYENTRIES]; -enum EMenuState : int -{ - MENU_Off, // Menu is closed - MENU_On, // Menu is opened - MENU_WaitKey, // Menu is opened and waiting for a key in the controls menu - MENU_OnNoPause, // Menu is opened but does not pause the game -}; - enum EMenuSounds : int { ActivateSound, @@ -326,8 +319,8 @@ public: BACKBUTTON_TIME = 4*MENU_TICRATE }; - static DMenu *CurrentMenu; static int MenuTime; + static bool InMenu; DMenu *mParentMenu; DVector2 origin = { 0,0 }; @@ -842,5 +835,6 @@ public: }; extern FSavegameManager savegameManager; +extern DMenu* CurrentMenu; #endif diff --git a/source/core/menu/menudef.cpp b/source/core/menu/menudef.cpp index 64feeae19..c30ac3af2 100644 --- a/source/core/menu/menudef.cpp +++ b/source/core/menu/menudef.cpp @@ -100,7 +100,7 @@ void M_DeinitMenus() MenuDescriptors.Clear(); OptionValues.Clear(); - DMenu::CurrentMenu = NULL; + CurrentMenu = NULL; DefaultListMenuSettings.mItems.Clear(); } diff --git a/source/core/menu/menuinput.cpp b/source/core/menu/menuinput.cpp index f3da36bcf..44a5e9a61 100644 --- a/source/core/menu/menuinput.cpp +++ b/source/core/menu/menuinput.cpp @@ -33,7 +33,7 @@ ** */ -#include "menu/menu.h" +#include "menu.h" #include "c_cvars.h" #include "d_event.h" #include "d_gui.h" diff --git a/source/core/menu/messagebox.cpp b/source/core/menu/messagebox.cpp index 4fdf781b6..232114894 100644 --- a/source/core/menu/messagebox.cpp +++ b/source/core/menu/messagebox.cpp @@ -132,7 +132,7 @@ void DMessageBoxMenu::Destroy() void DMessageBoxMenu::CloseSound() { - M_MenuSound(DMenu::CurrentMenu ? BackSound : ::CloseSound); + M_MenuSound(CurrentMenu ? BackSound : ::CloseSound); } //============================================================================= @@ -362,13 +362,13 @@ bool DMessageBoxMenu::MouseEvent(int type, int x, int y) void M_StartMessage(const char *message, int messagemode, int scriptId, FName action) { - if (DMenu::CurrentMenu == NULL) + if (CurrentMenu == NULL) { // only play a sound if no menu was active before M_StartControlPanel(menuactive == MENU_Off); } - DMenu *newmenu = new DMessageBoxMenu(DMenu::CurrentMenu, message, messagemode, false, action); - newmenu->mParentMenu = DMenu::CurrentMenu; + DMenu *newmenu = new DMessageBoxMenu(CurrentMenu, message, messagemode, false, action); + newmenu->mParentMenu = CurrentMenu; newmenu->scriptID = scriptId; M_ActivateMenu(newmenu); } @@ -382,7 +382,7 @@ void M_StartMessage(const char *message, int messagemode, int scriptId, FName ac DMenu* CreateMessageBoxMenu(DMenu* parent, const char* message, int messagemode, int scriptId, bool playsound, FName action, hFunc handler) { - auto newmenu = new DMessageBoxMenu(DMenu::CurrentMenu, message, messagemode, false, action, handler); + auto newmenu = new DMessageBoxMenu(CurrentMenu, message, messagemode, false, action, handler); newmenu->scriptID = scriptId; return newmenu; @@ -403,7 +403,7 @@ CCMD (menu_endgame) M_StartControlPanel (true); FString tempstring; tempstring << GStrings("ENDGAME") << "\n\n" << GStrings("PRESSYN"); - DMenu* newmenu = CreateMessageBoxMenu(DMenu::CurrentMenu, tempstring, 0, 501, false, NAME_None, [](bool res) + DMenu* newmenu = CreateMessageBoxMenu(CurrentMenu, tempstring, 0, 501, false, NAME_None, [](bool res) { if (res) { @@ -429,7 +429,7 @@ CCMD (menu_quit) FString EndString; EndString << GStrings("CONFIRM_QUITMSG") << "\n\n" << GStrings("PRESSYN"); - DMenu *newmenu = CreateMessageBoxMenu(DMenu::CurrentMenu, EndString, 0, 500, false, NAME_None, [](bool res) + DMenu *newmenu = CreateMessageBoxMenu(CurrentMenu, EndString, 0, 500, false, NAME_None, [](bool res) { if (res) throw CExitEvent(0); }); diff --git a/source/core/menu/optionmenu.cpp b/source/core/menu/optionmenu.cpp index 1558a9099..f12fb9221 100644 --- a/source/core/menu/optionmenu.cpp +++ b/source/core/menu/optionmenu.cpp @@ -42,7 +42,7 @@ #include "c_cvars.h" #include "c_bind.h" #include "gameconfigfile.h" -#include "menu/menu.h" +#include "menu.h" #include "v_draw.h" #include "v_2ddrawer.h" #include "v_video.h" @@ -428,7 +428,7 @@ void DOptionMenu::Drawer () int cur_indent = mDesc->mItems[i]->Draw(mDesc, y, indent, isSelected); if (cur_indent >= 0 && isSelected && mDesc->mItems[i]->Selectable()) { - if ((((DMenu::MenuTime>>2)%8) < 6) || DMenu::CurrentMenu != this) + if ((((DMenu::MenuTime>>2)%8) < 6) || CurrentMenu != this) { DrawOptionText(cur_indent + 3 * CleanXfac_1, y, OptionSettings.mFontColorSelection, "◄"); //M_DrawConText(OptionSettings.mFontColorSelection, cur_indent + 3 * CleanXfac_1, y+fontheight-9*CleanYfac_1, "\xd"); @@ -478,7 +478,7 @@ bool FOptionMenuItem::MouseEvent(int type, int x, int y) { if (Selectable() && type == DMenu::MOUSE_Release) { - return DMenu::CurrentMenu->MenuEvent(MKEY_Enter, true); + return CurrentMenu->MenuEvent(MKEY_Enter, true); } return false; } diff --git a/source/core/menu/optionmenuitems.h b/source/core/menu/optionmenuitems.h index 2870f5341..2fa8b31a8 100644 --- a/source/core/menu/optionmenuitems.h +++ b/source/core/menu/optionmenuitems.h @@ -68,7 +68,7 @@ public: bool Activate(FName caller) override { M_MenuSound(CursorSound); - M_SetMenu(mAction, mParam, static_cast(DMenu::CurrentMenu)->GetDescriptor()->mMenuName); + M_SetMenu(mAction, mParam, static_cast(CurrentMenu)->GetDescriptor()->mMenuName); return true; } }; @@ -481,7 +481,7 @@ public: { M_MenuSound(AdvanceSound); mWaiting = true; - DMenu *input = new DEnterKey(DMenu::CurrentMenu, &mInput); + DMenu *input = new DEnterKey(CurrentMenu, &mInput); M_ActivateMenu(input); return true; } @@ -685,7 +685,7 @@ public: bool MouseEvent(int type, int x, int y) override { - DOptionMenu *lm = static_cast(DMenu::CurrentMenu); + DOptionMenu *lm = static_cast(CurrentMenu); if (type != DMenu::MOUSE_Click) { if (!lm->CheckFocus(this)) return false; @@ -905,7 +905,7 @@ public: { M_MenuSound(AdvanceSound); mEntering = true; - mInput = new DTextEnterMenu(DMenu::CurrentMenu, NewSmallFont, GetCVarString(), 256, fromcontroller ); + mInput = new DTextEnterMenu(CurrentMenu, NewSmallFont, GetCVarString(), 256, fromcontroller ); M_ActivateMenu( mInput ); return true; } diff --git a/source/core/menu/resolutionmenu.cpp b/source/core/menu/resolutionmenu.cpp index 99c511905..692e5c264 100644 --- a/source/core/menu/resolutionmenu.cpp +++ b/source/core/menu/resolutionmenu.cpp @@ -35,7 +35,7 @@ #include "c_dispatch.h" #include "c_cvars.h" #include "v_video.h" -#include "menu/menu.h" +#include "menu.h" CVAR(Int, menu_resolution_custom_width, 640, 0) CVAR(Int, menu_resolution_custom_height, 480, 0) diff --git a/source/core/menu/savegamemanager.cpp b/source/core/menu/savegamemanager.cpp index 87a071004..b0a0d2c49 100644 --- a/source/core/menu/savegamemanager.cpp +++ b/source/core/menu/savegamemanager.cpp @@ -33,7 +33,7 @@ ** */ -#include "menu/menu.h" +#include "menu.h" #include "version.h" #include "m_png.h" #include "filesystem.h" @@ -660,7 +660,7 @@ CCMD(quicksave) tempstring.Substitute("%s", slot->SaveTitle.GetChars()); M_StartControlPanel(true); - DMenu* newmenu = CreateMessageBoxMenu(DMenu::CurrentMenu, tempstring, 0, INT_MAX, false, NAME_None, [](bool res) + DMenu* newmenu = CreateMessageBoxMenu(CurrentMenu, tempstring, 0, INT_MAX, false, NAME_None, [](bool res) { if (res) { @@ -708,7 +708,7 @@ CCMD(quickload) M_StartControlPanel(true); - DMenu* newmenu = CreateMessageBoxMenu(DMenu::CurrentMenu, tempstring, 0, INT_MAX, false, NAME_None, [](bool res) + DMenu* newmenu = CreateMessageBoxMenu(CurrentMenu, tempstring, 0, INT_MAX, false, NAME_None, [](bool res) { if (res) { diff --git a/source/duke3d/src/d_menu.cpp b/source/duke3d/src/d_menu.cpp index 50791263d..0dd8cfd93 100644 --- a/source/duke3d/src/d_menu.cpp +++ b/source/duke3d/src/d_menu.cpp @@ -34,7 +34,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "gamecvars.h" #include "gamecontrol.h" #include "c_bind.h" -#include "menu/menu.h" +#include "menu.h" #include "gstrings.h" #include "version.h" #include "namesdyn.h" diff --git a/source/duke3d/src/demo.cpp b/source/duke3d/src/demo.cpp index 17aa54e3d..44110a9ce 100644 --- a/source/duke3d/src/demo.cpp +++ b/source/duke3d/src/demo.cpp @@ -29,7 +29,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "savegame.h" #include "screens.h" #include "printf.h" -#include "menu/menu.h" +#include "menu.h" BEGIN_DUKE_NS diff --git a/source/duke3d/src/duke3d.h b/source/duke3d/src/duke3d.h index ee0915fad..6a2e70ace 100644 --- a/source/duke3d/src/duke3d.h +++ b/source/duke3d/src/duke3d.h @@ -32,7 +32,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "polymost.h" #include "gamecvars.h" #include "gamecontrol.h" -#include "menu/menu.h" +#include "menu.h" #include "memarena.h" diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index ef7e13b93..9307e74ce 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -48,7 +48,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "c_dispatch.h" #include "filesystem.h" #include "statistics.h" -#include "menu/menu.h" +#include "menu.h" #include "mapinfo.h" #include "v_video.h" #include "glbackend/glbackend.h" diff --git a/source/duke3d/src/game.h b/source/duke3d/src/game.h index 5affc1c2c..c55d3d9bd 100644 --- a/source/duke3d/src/game.h +++ b/source/duke3d/src/game.h @@ -33,7 +33,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "gamevars.h" #include "mmulti.h" #include "network.h" -#include "menu/menu.h" +#include "menu.h" #include "palette.h" #include "cmdlib.h" diff --git a/source/duke3d/src/gamedef.cpp b/source/duke3d/src/gamedef.cpp index deb008754..d885f5a6c 100644 --- a/source/duke3d/src/gamedef.cpp +++ b/source/duke3d/src/gamedef.cpp @@ -36,7 +36,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "savegame.h" #include "printf.h" #include "m_argv.h" -#include "menu/menu.h" +#include "menu.h" #include "stringtable.h" #include "mapinfo.h" #include "gamestructures.h" diff --git a/source/duke3d/src/gameexec.cpp b/source/duke3d/src/gameexec.cpp index 64e515140..b36c90776 100644 --- a/source/duke3d/src/gameexec.cpp +++ b/source/duke3d/src/gameexec.cpp @@ -38,7 +38,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "files.h" #include "base64.h" #include "version.h" -#include "menu/menu.h" +#include "menu.h" #include "c_dispatch.h" #include "quotemgr.h" #include "mapinfo.h" diff --git a/source/duke3d/src/gamevars.cpp b/source/duke3d/src/gamevars.cpp index a4939d7c1..667ce6977 100644 --- a/source/duke3d/src/gamevars.cpp +++ b/source/duke3d/src/gamevars.cpp @@ -26,7 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "menus.h" #include "savegame.h" #include "gamecvars.h" -#include "menu/menu.h" +#include "menu.h" #include "gamestructures.h" BEGIN_DUKE_NS diff --git a/source/duke3d/src/global.h b/source/duke3d/src/global.h index 8d56d0a4f..2e4c5424b 100644 --- a/source/duke3d/src/global.h +++ b/source/duke3d/src/global.h @@ -30,7 +30,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "quotes.h" #include "sector.h" #include "sounds.h" -#include "menu/menu.h" +#include "menu.h" BEGIN_DUKE_NS diff --git a/source/duke3d/src/premap.cpp b/source/duke3d/src/premap.cpp index 78ea98bbe..996830bb0 100644 --- a/source/duke3d/src/premap.cpp +++ b/source/duke3d/src/premap.cpp @@ -30,7 +30,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "savegame.h" #include "sbar.h" #include "statistics.h" -#include "menu/menu.h" +#include "menu.h" #include "mapinfo.h" #include "cmdlib.h" #include "v_2ddrawer.h" diff --git a/source/duke3d/src/savegame.cpp b/source/duke3d/src/savegame.cpp index 2f0c87e14..faf2c7b94 100644 --- a/source/duke3d/src/savegame.cpp +++ b/source/duke3d/src/savegame.cpp @@ -31,7 +31,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "gamecontrol.h" #include "version.h" #include "savegamehelp.h" -#include "menu/menu.h" +#include "menu.h" #include "mapinfo.h" #include "raze_music.h" diff --git a/source/duke3d/src/screens.cpp b/source/duke3d/src/screens.cpp index abf839488..aafe1a255 100644 --- a/source/duke3d/src/screens.cpp +++ b/source/duke3d/src/screens.cpp @@ -31,7 +31,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "sbar.h" #include "screens.h" #include "gamecvars.h" -#include "menu/menu.h" +#include "menu.h" #include "mapinfo.h" #include "v_2ddrawer.h" diff --git a/source/exhumed/src/d_menu.cpp b/source/exhumed/src/d_menu.cpp index 107852c59..a83d04199 100644 --- a/source/exhumed/src/d_menu.cpp +++ b/source/exhumed/src/d_menu.cpp @@ -31,7 +31,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "raze_sound.h" -#include "menu/menu.h" +#include "menu/menu.h" // to override the local menu.h #include "../../glbackend/glbackend.h" diff --git a/source/exhumed/src/menu.cpp b/source/exhumed/src/menu.cpp index 5bf472f2b..e4b46914a 100644 --- a/source/exhumed/src/menu.cpp +++ b/source/exhumed/src/menu.cpp @@ -38,7 +38,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "light.h" #include "cd.h" #include "raze_sound.h" -#include "menu/menu.h" +#include "menu.h" #include "v_2ddrawer.h" #include diff --git a/source/rr/src/d_menu.cpp b/source/rr/src/d_menu.cpp index 21dddbe6f..425cd1b95 100644 --- a/source/rr/src/d_menu.cpp +++ b/source/rr/src/d_menu.cpp @@ -34,7 +34,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "gamecvars.h" #include "gamecontrol.h" #include "c_bind.h" -#include "menu/menu.h" +#include "menu.h" #include "gstrings.h" #include "version.h" #include "namesdyn.h" diff --git a/source/rr/src/duke3d.h b/source/rr/src/duke3d.h index 981844b16..acbe04398 100644 --- a/source/rr/src/duke3d.h +++ b/source/rr/src/duke3d.h @@ -33,7 +33,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "polymost.h" #include "gamecvars.h" -#include "menu/menu.h" +#include "menu.h" BEGIN_RR_NS diff --git a/source/rr/src/gamedef.cpp b/source/rr/src/gamedef.cpp index d94f3e007..d80782a15 100644 --- a/source/rr/src/gamedef.cpp +++ b/source/rr/src/gamedef.cpp @@ -35,7 +35,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "osd.h" #include "m_crc32.h" #include "printf.h" -#include "menu/menu.h" +#include "menu.h" #include "stringtable.h" #include "mapinfo.h" diff --git a/source/rr/src/premap.cpp b/source/rr/src/premap.cpp index b53c4e453..53e9d2b49 100644 --- a/source/rr/src/premap.cpp +++ b/source/rr/src/premap.cpp @@ -28,7 +28,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "savegame.h" #include "cmdline.h" #include "statistics.h" -#include "menu/menu.h" +#include "menu.h" #include "mapinfo.h" #include "cmdlib.h" #include "v_2ddrawer.h" diff --git a/source/rr/src/screens.cpp b/source/rr/src/screens.cpp index 5cc926276..341f873d7 100644 --- a/source/rr/src/screens.cpp +++ b/source/rr/src/screens.cpp @@ -31,7 +31,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "demo.h" #include "mdsprite.h" #include "gamecvars.h" -#include "menu/menu.h" +#include "menu.h" #include "mapinfo.h" #include "v_2ddrawer.h" diff --git a/source/sw/src/d_menu.cpp b/source/sw/src/d_menu.cpp index e82e4a92d..07a6127e3 100644 --- a/source/sw/src/d_menu.cpp +++ b/source/sw/src/d_menu.cpp @@ -49,7 +49,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "colormap.h" #include "config.h" -#include "menu/menu.h" +#include "menu.h" #include "raze_sound.h" #include "sounds.h" diff --git a/source/sw/src/draw.cpp b/source/sw/src/draw.cpp index 14d742340..bf3e844bb 100644 --- a/source/sw/src/draw.cpp +++ b/source/sw/src/draw.cpp @@ -56,7 +56,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "interpso.h" #include "sector.h" #include "config.h" -#include "menu/menu.h" +#include "menu.h" #include "swcvar.h" #include "v_2ddrawer.h" #include "v_video.h" diff --git a/source/sw/src/game.cpp b/source/sw/src/game.cpp index 73087bc05..5c0c75ad8 100644 --- a/source/sw/src/game.cpp +++ b/source/sw/src/game.cpp @@ -93,7 +93,7 @@ Things required to make savegames work: #include "printf.h" #include "m_argv.h" #include "debugbreak.h" -#include "menu/menu.h" +#include "menu.h" #include "raze_music.h" #include "statistics.h" #include "gstrings.h" diff --git a/source/sw/src/panel.cpp b/source/sw/src/panel.cpp index 63c032842..887bf4a6d 100644 --- a/source/sw/src/panel.cpp +++ b/source/sw/src/panel.cpp @@ -44,7 +44,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "v_2ddrawer.h" #include "weapon.h" -#include "menu/menu.h" +#include "menu.h" #include "swcvar.h" #include "raze_sound.h" diff --git a/source/sw/src/player.cpp b/source/sw/src/player.cpp index b440067ff..ff1e8f13d 100644 --- a/source/sw/src/player.cpp +++ b/source/sw/src/player.cpp @@ -63,7 +63,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "track.h" #include "interp.h" #include "interpso.h" -#include "menu/menu.h" +#include "menu.h" #include "gstrings.h" #include "raze_music.h" diff --git a/source/sw/src/scrip2.cpp b/source/sw/src/scrip2.cpp index eab38165d..120633978 100644 --- a/source/sw/src/scrip2.cpp +++ b/source/sw/src/scrip2.cpp @@ -39,7 +39,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "jsector.h" #include "parent.h" #include "scriptfile.h" -#include "menu/menu.h" +#include "menu.h" #include "quotemgr.h" #include "mapinfo.h" diff --git a/source/sw/src/sounds.cpp b/source/sw/src/sounds.cpp index 0fbf17dce..49cf36654 100644 --- a/source/sw/src/sounds.cpp +++ b/source/sw/src/sounds.cpp @@ -48,7 +48,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "rts.h" #include "menus.h" #include "config.h" -#include "menu/menu.h" +#include "menu.h" #include "raze_music.h" #include "raze_sound.h" #include "filesystem.h"