mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2025-02-18 09:31:09 +00:00
Merge branch 'master' of https://github.com/coelckers/gzdoom
This commit is contained in:
commit
bc4e2dd5c9
20 changed files with 515 additions and 572 deletions
73
.travis.yml
Normal file
73
.travis.yml
Normal file
|
@ -0,0 +1,73 @@
|
|||
language: c++
|
||||
dist: trusty
|
||||
sudo: required
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- os: osx
|
||||
osx_image: xcode8.2
|
||||
env:
|
||||
- CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=Debug -DCMAKE_OSX_DEPLOYMENT_TARGET=10.7"
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode8.2
|
||||
env:
|
||||
- CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_DEPLOYMENT_TARGET=10.7 -DFORCE_INTERNAL_ZLIB=YES -DFORCE_INTERNAL_JPEG=YES -DFORCE_INTERNAL_BZIP2=YES -DFORCE_INTERNAL_GME=YES"
|
||||
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env:
|
||||
- GCC_VERSION=5
|
||||
- CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=Release"
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- kubuntu-backports
|
||||
packages:
|
||||
- g++-5
|
||||
- libsdl2-dev
|
||||
- libgme-dev
|
||||
- libopenal-dev
|
||||
- libmpg123-dev
|
||||
- libsndfile-dev
|
||||
- libfluidsynth-dev
|
||||
- libgtk-3-dev
|
||||
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env:
|
||||
- CLANG_VERSION=3.9
|
||||
- CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=RelWithDebInfo -DDYN_OPENAL=NO -DDYN_FLUIDSYNTH=NO"
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-3.9
|
||||
- kubuntu-backports
|
||||
packages:
|
||||
- clang-3.9
|
||||
- libstdc++-5-dev
|
||||
- libsdl2-dev
|
||||
- libgme-dev
|
||||
- libopenal-dev
|
||||
- libmpg123-dev
|
||||
- libsndfile-dev
|
||||
- libfluidsynth-dev
|
||||
- libgtk-3-dev
|
||||
|
||||
before_install:
|
||||
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew update; brew install mpg123 libsndfile fluidsynth; fi
|
||||
- if [ -n "$GCC_VERSION" ]; then export CC="gcc-${GCC_VERSION}" CXX="g++-${GCC_VERSION}"; fi
|
||||
- if [ -n "$CLANG_VERSION" ]; then export CC="clang-${CLANG_VERSION}" CXX="clang++-${CLANG_VERSION}"; fi
|
||||
- $CC --version
|
||||
- $CXX --version
|
||||
|
||||
script:
|
||||
- mkdir build
|
||||
- cd build
|
||||
- cmake ${CMAKE_OPTIONS} ..
|
||||
- make -j2
|
||||
|
||||
notifications:
|
||||
email: false
|
|
@ -259,6 +259,35 @@ static int pagetic;
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
// [ZZ] this handles the mouse changes in the playsim.
|
||||
// I have no idea why it had to be done before events are dispatched... also no idea why is this not in G_Responder or something.
|
||||
static bool D_ProcessMouseForPlaysim(event_t *ev)
|
||||
{
|
||||
//if (ev->type == EV_Mouse && !paused && menuactive == MENU_Off && ConsoleState != c_down && ConsoleState != c_falling && !E_CheckUiProcessors())
|
||||
if (ev->type == EV_Mouse && !paused) // [ZZ] the other checks are replaced with responders eating the event.
|
||||
{
|
||||
if (Button_Mlook.bDown || freelook)
|
||||
{
|
||||
int look = int(ev->y * m_pitch * mouse_sensitivity * 16.0);
|
||||
if (invertmouse)
|
||||
look = -look;
|
||||
G_AddViewPitch(look);
|
||||
events[eventhead].y = 0;
|
||||
}
|
||||
if (!Button_Strafe.bDown && !lookstrafe)
|
||||
{
|
||||
G_AddViewAngle(int(ev->x * m_yaw * mouse_sensitivity * 8.0));
|
||||
events[eventhead].x = 0;
|
||||
}
|
||||
if ((events[eventhead].x | events[eventhead].y) == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void D_ProcessEvents (void)
|
||||
{
|
||||
event_t *ev;
|
||||
|
@ -291,7 +320,9 @@ void D_ProcessEvents (void)
|
|||
// check events
|
||||
if (E_Responder(ev)) // [ZZ] ZScript ate the event
|
||||
continue;
|
||||
G_Responder (ev);
|
||||
// before passing this further, do some magic
|
||||
if (D_ProcessMouseForPlaysim(ev))
|
||||
G_Responder (ev);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -311,26 +342,6 @@ void D_PostEvent (const event_t *ev)
|
|||
return;
|
||||
}
|
||||
events[eventhead] = *ev;
|
||||
if (ev->type == EV_Mouse && !paused && menuactive == MENU_Off && ConsoleState != c_down && ConsoleState != c_falling && !E_CheckUiProcessors())
|
||||
{
|
||||
if (Button_Mlook.bDown || freelook)
|
||||
{
|
||||
int look = int(ev->y * m_pitch * mouse_sensitivity * 16.0);
|
||||
if (invertmouse)
|
||||
look = -look;
|
||||
G_AddViewPitch (look);
|
||||
events[eventhead].y = 0;
|
||||
}
|
||||
if (!Button_Strafe.bDown && !lookstrafe)
|
||||
{
|
||||
G_AddViewAngle (int(ev->x * m_yaw * mouse_sensitivity * 8.0));
|
||||
events[eventhead].x = 0;
|
||||
}
|
||||
if ((events[eventhead].x | events[eventhead].y) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
eventhead = (eventhead+1)&(MAXEVENTS-1);
|
||||
}
|
||||
|
||||
|
|
|
@ -2677,7 +2677,8 @@ void Net_DoCommand (int type, BYTE **stream, int player)
|
|||
int arg[3] = { 0, 0, 0 };
|
||||
for (int i = 0; i < 3; i++)
|
||||
arg[i] = ReadLong(stream);
|
||||
E_Console(player, s, arg[0], arg[1], arg[2]);
|
||||
bool manual = !!ReadByte(stream);
|
||||
E_Console(player, s, arg[0], arg[1], arg[2], manual);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -2728,7 +2729,7 @@ void Net_SkipCommand (int type, BYTE **stream)
|
|||
break;
|
||||
|
||||
case DEM_NETEVENT:
|
||||
skip = strlen((char *)(*stream)) + 14;
|
||||
skip = strlen((char *)(*stream)) + 15;
|
||||
break;
|
||||
|
||||
case DEM_SUMMON2:
|
||||
|
|
402
src/events.cpp
402
src/events.cpp
|
@ -117,7 +117,7 @@ bool E_UnregisterHandler(DStaticEventHandler* handler)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool E_SendNetworkEvent(FString name, int arg1, int arg2, int arg3)
|
||||
bool E_SendNetworkEvent(FString name, int arg1, int arg2, int arg3, bool manual)
|
||||
{
|
||||
if (gamestate != GS_LEVEL)
|
||||
return false;
|
||||
|
@ -128,6 +128,7 @@ bool E_SendNetworkEvent(FString name, int arg1, int arg2, int arg3)
|
|||
Net_WriteLong(arg1);
|
||||
Net_WriteLong(arg2);
|
||||
Net_WriteLong(arg3);
|
||||
Net_WriteByte(manual);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -433,10 +434,10 @@ bool E_Responder(event_t* ev)
|
|||
return false;
|
||||
}
|
||||
|
||||
void E_Console(int player, FString name, int arg1, int arg2, int arg3)
|
||||
void E_Console(int player, FString name, int arg1, int arg2, int arg3, bool manual)
|
||||
{
|
||||
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
|
||||
handler->ConsoleProcess(player, name, arg1, arg2, arg3);
|
||||
handler->ConsoleProcess(player, name, arg1, arg2, arg3, manual);
|
||||
}
|
||||
|
||||
bool E_CheckUiProcessors()
|
||||
|
@ -472,57 +473,51 @@ IMPLEMENT_POINTER(prev)
|
|||
IMPLEMENT_POINTERS_END
|
||||
|
||||
IMPLEMENT_CLASS(DEventHandler, false, false);
|
||||
IMPLEMENT_CLASS(DBaseEvent, false, false)
|
||||
IMPLEMENT_CLASS(DRenderEvent, false, false)
|
||||
IMPLEMENT_CLASS(DWorldEvent, false, false)
|
||||
IMPLEMENT_CLASS(DPlayerEvent, false, false)
|
||||
IMPLEMENT_CLASS(DUiEvent, false, false)
|
||||
IMPLEMENT_CLASS(DInputEvent, false, false)
|
||||
IMPLEMENT_CLASS(DConsoleEvent, false, false)
|
||||
|
||||
DEFINE_FIELD_X(StaticEventHandler, DStaticEventHandler, Order);
|
||||
DEFINE_FIELD_X(StaticEventHandler, DStaticEventHandler, IsUiProcessor);
|
||||
DEFINE_FIELD_X(StaticEventHandler, DStaticEventHandler, RequireMouse);
|
||||
|
||||
DEFINE_FIELD_X(RenderEvent, DRenderEvent, ViewPos);
|
||||
DEFINE_FIELD_X(RenderEvent, DRenderEvent, ViewAngle);
|
||||
DEFINE_FIELD_X(RenderEvent, DRenderEvent, ViewPitch);
|
||||
DEFINE_FIELD_X(RenderEvent, DRenderEvent, ViewRoll);
|
||||
DEFINE_FIELD_X(RenderEvent, DRenderEvent, FracTic);
|
||||
DEFINE_FIELD_X(RenderEvent, DRenderEvent, Camera);
|
||||
DEFINE_FIELD_X(RenderEvent, FRenderEvent, ViewPos);
|
||||
DEFINE_FIELD_X(RenderEvent, FRenderEvent, ViewAngle);
|
||||
DEFINE_FIELD_X(RenderEvent, FRenderEvent, ViewPitch);
|
||||
DEFINE_FIELD_X(RenderEvent, FRenderEvent, ViewRoll);
|
||||
DEFINE_FIELD_X(RenderEvent, FRenderEvent, FracTic);
|
||||
DEFINE_FIELD_X(RenderEvent, FRenderEvent, Camera);
|
||||
|
||||
DEFINE_FIELD_X(WorldEvent, DWorldEvent, IsSaveGame);
|
||||
DEFINE_FIELD_X(WorldEvent, DWorldEvent, IsReopen);
|
||||
DEFINE_FIELD_X(WorldEvent, DWorldEvent, Thing);
|
||||
DEFINE_FIELD_X(WorldEvent, DWorldEvent, Inflictor);
|
||||
DEFINE_FIELD_X(WorldEvent, DWorldEvent, Damage);
|
||||
DEFINE_FIELD_X(WorldEvent, DWorldEvent, DamageSource);
|
||||
DEFINE_FIELD_X(WorldEvent, DWorldEvent, DamageType);
|
||||
DEFINE_FIELD_X(WorldEvent, DWorldEvent, DamageFlags);
|
||||
DEFINE_FIELD_X(WorldEvent, DWorldEvent, DamageAngle);
|
||||
DEFINE_FIELD_X(WorldEvent, FWorldEvent, IsSaveGame);
|
||||
DEFINE_FIELD_X(WorldEvent, FWorldEvent, IsReopen);
|
||||
DEFINE_FIELD_X(WorldEvent, FWorldEvent, Thing);
|
||||
DEFINE_FIELD_X(WorldEvent, FWorldEvent, Inflictor);
|
||||
DEFINE_FIELD_X(WorldEvent, FWorldEvent, Damage);
|
||||
DEFINE_FIELD_X(WorldEvent, FWorldEvent, DamageSource);
|
||||
DEFINE_FIELD_X(WorldEvent, FWorldEvent, DamageType);
|
||||
DEFINE_FIELD_X(WorldEvent, FWorldEvent, DamageFlags);
|
||||
DEFINE_FIELD_X(WorldEvent, FWorldEvent, DamageAngle);
|
||||
|
||||
DEFINE_FIELD_X(PlayerEvent, DPlayerEvent, PlayerNumber);
|
||||
DEFINE_FIELD_X(PlayerEvent, DPlayerEvent, IsReturn);
|
||||
DEFINE_FIELD_X(PlayerEvent, FPlayerEvent, PlayerNumber);
|
||||
DEFINE_FIELD_X(PlayerEvent, FPlayerEvent, IsReturn);
|
||||
|
||||
DEFINE_FIELD_X(UiEvent, DUiEvent, Type);
|
||||
DEFINE_FIELD_X(UiEvent, DUiEvent, KeyString);
|
||||
DEFINE_FIELD_X(UiEvent, DUiEvent, KeyChar);
|
||||
DEFINE_FIELD_X(UiEvent, DUiEvent, MouseX);
|
||||
DEFINE_FIELD_X(UiEvent, DUiEvent, MouseY);
|
||||
DEFINE_FIELD_X(UiEvent, DUiEvent, IsShift);
|
||||
DEFINE_FIELD_X(UiEvent, DUiEvent, IsAlt);
|
||||
DEFINE_FIELD_X(UiEvent, DUiEvent, IsCtrl);
|
||||
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, DInputEvent, Type);
|
||||
DEFINE_FIELD_X(InputEvent, DInputEvent, KeyScan);
|
||||
DEFINE_FIELD_X(InputEvent, DInputEvent, KeyString);
|
||||
DEFINE_FIELD_X(InputEvent, DInputEvent, KeyChar);
|
||||
DEFINE_FIELD_X(InputEvent, DInputEvent, MouseX);
|
||||
DEFINE_FIELD_X(InputEvent, DInputEvent, MouseY);
|
||||
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);
|
||||
|
||||
DEFINE_FIELD_X(ConsoleEvent, DConsoleEvent, Player)
|
||||
DEFINE_FIELD_X(ConsoleEvent, DConsoleEvent, Name)
|
||||
DEFINE_FIELD_X(ConsoleEvent, DConsoleEvent, Args)
|
||||
DEFINE_FIELD_X(ConsoleEvent, FConsoleEvent, Player)
|
||||
DEFINE_FIELD_X(ConsoleEvent, FConsoleEvent, Name)
|
||||
DEFINE_FIELD_X(ConsoleEvent, FConsoleEvent, Args)
|
||||
DEFINE_FIELD_X(ConsoleEvent, FConsoleEvent, IsManual)
|
||||
|
||||
DEFINE_ACTION_FUNCTION(DStaticEventHandler, SetOrder)
|
||||
{
|
||||
|
@ -545,7 +540,7 @@ DEFINE_ACTION_FUNCTION(DEventHandler, SendNetworkEvent)
|
|||
PARAM_INT(arg3);
|
||||
//
|
||||
|
||||
ACTION_RETURN_BOOL(E_SendNetworkEvent(name, arg1, arg2, arg3));
|
||||
ACTION_RETURN_BOOL(E_SendNetworkEvent(name, arg1, arg2, arg3, false));
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(DEventHandler, Create)
|
||||
|
@ -717,19 +712,12 @@ void DStaticEventHandler::OnUnregister()
|
|||
}
|
||||
}
|
||||
|
||||
static DWorldEvent* E_SetupWorldEvent()
|
||||
static FWorldEvent E_SetupWorldEvent()
|
||||
{
|
||||
static DWorldEvent* e = nullptr;
|
||||
if (!e) e = (DWorldEvent*)RUNTIME_CLASS(DWorldEvent)->CreateNew();
|
||||
e->IsSaveGame = savegamerestore;
|
||||
e->IsReopen = level.FromSnapshot && !savegamerestore; // each one by itself isnt helpful, but with hub load we have savegamerestore==0 and level.FromSnapshot==1.
|
||||
e->Thing = nullptr;
|
||||
e->Inflictor = nullptr;
|
||||
e->Damage = 0;
|
||||
e->DamageAngle = 0.0;
|
||||
e->DamageFlags = 0;
|
||||
e->DamageSource = 0;
|
||||
e->DamageType = NAME_None;
|
||||
FWorldEvent e;
|
||||
e.IsSaveGame = savegamerestore;
|
||||
e.IsReopen = level.FromSnapshot && !savegamerestore; // each one by itself isnt helpful, but with hub load we have savegamerestore==0 and level.FromSnapshot==1.
|
||||
e.DamageAngle = 0.0;
|
||||
return e;
|
||||
}
|
||||
|
||||
|
@ -740,8 +728,8 @@ void DStaticEventHandler::WorldLoaded()
|
|||
// don't create excessive DObjects if not going to be processed anyway
|
||||
if (func == DStaticEventHandler_WorldLoaded_VMPtr)
|
||||
return;
|
||||
DWorldEvent* e = E_SetupWorldEvent();
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, e };
|
||||
FWorldEvent e = E_SetupWorldEvent();
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, &e };
|
||||
GlobalVMStack.Call(func, params, 2, nullptr, 0, nullptr);
|
||||
}
|
||||
}
|
||||
|
@ -753,8 +741,8 @@ void DStaticEventHandler::WorldUnloaded()
|
|||
// don't create excessive DObjects if not going to be processed anyway
|
||||
if (func == DStaticEventHandler_WorldUnloaded_VMPtr)
|
||||
return;
|
||||
DWorldEvent* e = E_SetupWorldEvent();
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, e };
|
||||
FWorldEvent e = E_SetupWorldEvent();
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, &e };
|
||||
GlobalVMStack.Call(func, params, 2, nullptr, 0, nullptr);
|
||||
}
|
||||
}
|
||||
|
@ -766,9 +754,9 @@ void DStaticEventHandler::WorldThingSpawned(AActor* actor)
|
|||
// don't create excessive DObjects if not going to be processed anyway
|
||||
if (func == DStaticEventHandler_WorldThingSpawned_VMPtr)
|
||||
return;
|
||||
DWorldEvent* e = E_SetupWorldEvent();
|
||||
e->Thing = actor;
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, e };
|
||||
FWorldEvent e = E_SetupWorldEvent();
|
||||
e.Thing = actor;
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, &e };
|
||||
GlobalVMStack.Call(func, params, 2, nullptr, 0, nullptr);
|
||||
}
|
||||
}
|
||||
|
@ -780,10 +768,10 @@ void DStaticEventHandler::WorldThingDied(AActor* actor, AActor* inflictor)
|
|||
// don't create excessive DObjects if not going to be processed anyway
|
||||
if (func == DStaticEventHandler_WorldThingDied_VMPtr)
|
||||
return;
|
||||
DWorldEvent* e = E_SetupWorldEvent();
|
||||
e->Thing = actor;
|
||||
e->Inflictor = inflictor;
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, e };
|
||||
FWorldEvent e = E_SetupWorldEvent();
|
||||
e.Thing = actor;
|
||||
e.Inflictor = inflictor;
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, &e };
|
||||
GlobalVMStack.Call(func, params, 2, nullptr, 0, nullptr);
|
||||
}
|
||||
}
|
||||
|
@ -795,9 +783,9 @@ void DStaticEventHandler::WorldThingRevived(AActor* actor)
|
|||
// don't create excessive DObjects if not going to be processed anyway
|
||||
if (func == DStaticEventHandler_WorldThingRevived_VMPtr)
|
||||
return;
|
||||
DWorldEvent* e = E_SetupWorldEvent();
|
||||
e->Thing = actor;
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, e };
|
||||
FWorldEvent e = E_SetupWorldEvent();
|
||||
e.Thing = actor;
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, &e };
|
||||
GlobalVMStack.Call(func, params, 2, nullptr, 0, nullptr);
|
||||
}
|
||||
}
|
||||
|
@ -809,14 +797,14 @@ void DStaticEventHandler::WorldThingDamaged(AActor* actor, AActor* inflictor, AA
|
|||
// don't create excessive DObjects if not going to be processed anyway
|
||||
if (func == DStaticEventHandler_WorldThingDamaged_VMPtr)
|
||||
return;
|
||||
DWorldEvent* e = E_SetupWorldEvent();
|
||||
e->Thing = actor;
|
||||
e->Damage = damage;
|
||||
e->DamageSource = source;
|
||||
e->DamageType = mod;
|
||||
e->DamageFlags = flags;
|
||||
e->DamageAngle = angle;
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, e };
|
||||
FWorldEvent e = E_SetupWorldEvent();
|
||||
e.Thing = actor;
|
||||
e.Damage = damage;
|
||||
e.DamageSource = source;
|
||||
e.DamageType = mod;
|
||||
e.DamageFlags = flags;
|
||||
e.DamageAngle = angle;
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, &e };
|
||||
GlobalVMStack.Call(func, params, 2, nullptr, 0, nullptr);
|
||||
}
|
||||
}
|
||||
|
@ -828,9 +816,9 @@ void DStaticEventHandler::WorldThingDestroyed(AActor* actor)
|
|||
// don't create excessive DObjects if not going to be processed anyway
|
||||
if (func == DStaticEventHandler_WorldThingDestroyed_VMPtr)
|
||||
return;
|
||||
DWorldEvent* e = E_SetupWorldEvent();
|
||||
e->Thing = actor;
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, e };
|
||||
FWorldEvent e = E_SetupWorldEvent();
|
||||
e.Thing = actor;
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, &e };
|
||||
GlobalVMStack.Call(func, params, 2, nullptr, 0, nullptr);
|
||||
}
|
||||
}
|
||||
|
@ -842,8 +830,8 @@ void DStaticEventHandler::WorldLightning()
|
|||
// don't create excessive DObjects if not going to be processed anyway
|
||||
if (func == DStaticEventHandler_WorldLightning_VMPtr)
|
||||
return;
|
||||
DWorldEvent* e = E_SetupWorldEvent();
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, e };
|
||||
FWorldEvent e = E_SetupWorldEvent();
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, &e };
|
||||
GlobalVMStack.Call(func, params, 2, nullptr, 0, nullptr);
|
||||
}
|
||||
}
|
||||
|
@ -855,22 +843,21 @@ void DStaticEventHandler::WorldTick()
|
|||
// don't create excessive DObjects if not going to be processed anyway
|
||||
if (func == DStaticEventHandler_WorldTick_VMPtr)
|
||||
return;
|
||||
DWorldEvent* e = E_SetupWorldEvent();
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, e };
|
||||
FWorldEvent e = E_SetupWorldEvent();
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, &e };
|
||||
GlobalVMStack.Call(func, params, 2, nullptr, 0, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
static DRenderEvent* E_SetupRenderEvent()
|
||||
static FRenderEvent E_SetupRenderEvent()
|
||||
{
|
||||
static DRenderEvent* e = nullptr;
|
||||
if (!e) e = (DRenderEvent*)RUNTIME_CLASS(DRenderEvent)->CreateNew();
|
||||
e->ViewPos = ::ViewPos;
|
||||
e->ViewAngle = ::ViewAngle;
|
||||
e->ViewPitch = ::ViewPitch;
|
||||
e->ViewRoll = ::ViewRoll;
|
||||
e->FracTic = ::r_TicFracF;
|
||||
e->Camera = ::camera;
|
||||
FRenderEvent e;
|
||||
e.ViewPos = ::ViewPos;
|
||||
e.ViewAngle = ::ViewAngle;
|
||||
e.ViewPitch = ::ViewPitch;
|
||||
e.ViewRoll = ::ViewRoll;
|
||||
e.FracTic = ::r_TicFracF;
|
||||
e.Camera = ::camera;
|
||||
return e;
|
||||
}
|
||||
|
||||
|
@ -881,8 +868,8 @@ void DStaticEventHandler::RenderFrame()
|
|||
// don't create excessive DObjects if not going to be processed anyway
|
||||
if (func == DStaticEventHandler_RenderFrame_VMPtr)
|
||||
return;
|
||||
DRenderEvent* e = E_SetupRenderEvent();
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, e };
|
||||
FRenderEvent e = E_SetupRenderEvent();
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, &e };
|
||||
GlobalVMStack.Call(func, params, 2, nullptr, 0, nullptr);
|
||||
}
|
||||
}
|
||||
|
@ -894,21 +881,12 @@ void DStaticEventHandler::RenderOverlay()
|
|||
// don't create excessive DObjects if not going to be processed anyway
|
||||
if (func == DStaticEventHandler_RenderOverlay_VMPtr)
|
||||
return;
|
||||
DRenderEvent* e = E_SetupRenderEvent();
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, e };
|
||||
FRenderEvent e = E_SetupRenderEvent();
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, &e };
|
||||
GlobalVMStack.Call(func, params, 2, nullptr, 0, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
static DPlayerEvent* E_SetupPlayerEvent()
|
||||
{
|
||||
static DPlayerEvent* e = nullptr;
|
||||
if (!e) e = (DPlayerEvent*)RUNTIME_CLASS(DPlayerEvent)->CreateNew();
|
||||
e->PlayerNumber = -1;
|
||||
e->IsReturn = false;
|
||||
return e;
|
||||
}
|
||||
|
||||
void DStaticEventHandler::PlayerEntered(int num, bool fromhub)
|
||||
{
|
||||
IFVIRTUAL(DStaticEventHandler, PlayerEntered)
|
||||
|
@ -916,10 +894,8 @@ void DStaticEventHandler::PlayerEntered(int num, bool fromhub)
|
|||
// don't create excessive DObjects if not going to be processed anyway
|
||||
if (func == DStaticEventHandler_PlayerEntered_VMPtr)
|
||||
return;
|
||||
DPlayerEvent* e = E_SetupPlayerEvent();
|
||||
e->IsReturn = fromhub;
|
||||
e->PlayerNumber = num;
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, e };
|
||||
FPlayerEvent e = { num, fromhub };
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, &e };
|
||||
GlobalVMStack.Call(func, params, 2, nullptr, 0, nullptr);
|
||||
}
|
||||
}
|
||||
|
@ -931,9 +907,8 @@ void DStaticEventHandler::PlayerRespawned(int num)
|
|||
// don't create excessive DObjects if not going to be processed anyway
|
||||
if (func == DStaticEventHandler_PlayerRespawned_VMPtr)
|
||||
return;
|
||||
DPlayerEvent* e = E_SetupPlayerEvent();
|
||||
e->PlayerNumber = num;
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, e };
|
||||
FPlayerEvent e = { num, false };
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, &e };
|
||||
GlobalVMStack.Call(func, params, 2, nullptr, 0, nullptr);
|
||||
}
|
||||
}
|
||||
|
@ -945,9 +920,8 @@ void DStaticEventHandler::PlayerDied(int num)
|
|||
// don't create excessive DObjects if not going to be processed anyway
|
||||
if (func == DStaticEventHandler_PlayerDied_VMPtr)
|
||||
return;
|
||||
DPlayerEvent* e = E_SetupPlayerEvent();
|
||||
e->PlayerNumber = num;
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, e };
|
||||
FPlayerEvent e = { num, false };
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, &e };
|
||||
GlobalVMStack.Call(func, params, 2, nullptr, 0, nullptr);
|
||||
}
|
||||
}
|
||||
|
@ -959,25 +933,50 @@ void DStaticEventHandler::PlayerDisconnected(int num)
|
|||
// don't create excessive DObjects if not going to be processed anyway
|
||||
if (func == DStaticEventHandler_PlayerDisconnected_VMPtr)
|
||||
return;
|
||||
DPlayerEvent* e = E_SetupPlayerEvent();
|
||||
e->PlayerNumber = num;
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, e };
|
||||
FPlayerEvent e = { num, false };
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, &e };
|
||||
GlobalVMStack.Call(func, params, 2, nullptr, 0, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
static DUiEvent* E_SetupUiEvent()
|
||||
FUiEvent::FUiEvent(event_t *ev)
|
||||
{
|
||||
static DUiEvent* e = nullptr;
|
||||
if (!e) e = (DUiEvent*)RUNTIME_CLASS(DUiEvent)->CreateNew();
|
||||
e->Type = EV_GUI_None;
|
||||
e->IsShift = false;
|
||||
e->IsAlt = false;
|
||||
e->IsCtrl = false;
|
||||
e->MouseX = e->MouseY = 0;
|
||||
e->KeyChar = 0;
|
||||
e->KeyString = "";
|
||||
return e;
|
||||
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 = FString(char(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;
|
||||
}
|
||||
}
|
||||
|
||||
bool DStaticEventHandler::UiProcess(event_t* ev)
|
||||
|
@ -987,43 +986,11 @@ bool DStaticEventHandler::UiProcess(event_t* ev)
|
|||
// don't create excessive DObjects if not going to be processed anyway
|
||||
if (func == DStaticEventHandler_UiProcess_VMPtr)
|
||||
return false;
|
||||
DUiEvent* e = E_SetupUiEvent();
|
||||
|
||||
//
|
||||
e->Type = (EGUIEvent)ev->subtype;
|
||||
// we don't want the modders to remember what weird fields mean what for what events.
|
||||
switch (e->Type)
|
||||
{
|
||||
case EV_GUI_None:
|
||||
break;
|
||||
case EV_GUI_KeyDown:
|
||||
case EV_GUI_KeyRepeat:
|
||||
case EV_GUI_KeyUp:
|
||||
e->KeyChar = ev->data1;
|
||||
e->KeyString.Format("%c", e->KeyChar);
|
||||
e->IsShift = !!(ev->data3 & GKM_SHIFT);
|
||||
e->IsAlt = !!(ev->data3 & GKM_ALT);
|
||||
e->IsCtrl = !!(ev->data3 & GKM_CTRL);
|
||||
break;
|
||||
case EV_GUI_Char:
|
||||
e->KeyChar = ev->data1;
|
||||
e->KeyString.Format("%c", e->KeyChar);
|
||||
e->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);
|
||||
e->MouseX = ev->data1;
|
||||
e->MouseY = ev->data2;
|
||||
e->IsShift = !!(ev->data3 & GKM_SHIFT);
|
||||
e->IsAlt = !!(ev->data3 & GKM_ALT);
|
||||
e->IsCtrl = !!(ev->data3 & GKM_CTRL);
|
||||
break;
|
||||
}
|
||||
FUiEvent e = ev;
|
||||
|
||||
int processed;
|
||||
VMReturn results[1] = { &processed };
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, e };
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, &e };
|
||||
GlobalVMStack.Call(func, params, 2, results, 1, nullptr);
|
||||
return !!processed;
|
||||
}
|
||||
|
@ -1031,16 +998,31 @@ bool DStaticEventHandler::UiProcess(event_t* ev)
|
|||
return false;
|
||||
}
|
||||
|
||||
static DInputEvent* E_SetupInputEvent()
|
||||
FInputEvent::FInputEvent(event_t *ev)
|
||||
{
|
||||
static DInputEvent* e = nullptr;
|
||||
if (!e) e = (DInputEvent*)RUNTIME_CLASS(DInputEvent)->CreateNew();
|
||||
e->Type = EV_None;
|
||||
e->KeyScan = 0;
|
||||
e->KeyChar = 0;
|
||||
e->KeyString = "";
|
||||
e->MouseX = e->MouseY = 0;
|
||||
return e;
|
||||
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?
|
||||
}
|
||||
}
|
||||
|
||||
bool DStaticEventHandler::InputProcess(event_t* ev)
|
||||
|
@ -1050,32 +1032,13 @@ bool DStaticEventHandler::InputProcess(event_t* ev)
|
|||
// don't create excessive DObjects if not going to be processed anyway
|
||||
if (func == DStaticEventHandler_InputProcess_VMPtr)
|
||||
return false;
|
||||
DInputEvent* e = E_SetupInputEvent();
|
||||
|
||||
FInputEvent e = ev;
|
||||
//
|
||||
e->Type = (EGenericEvent)ev->type;
|
||||
// we don't want the modders to remember what weird fields mean what for what events.
|
||||
switch (e->Type)
|
||||
{
|
||||
case EV_None:
|
||||
break;
|
||||
case EV_KeyDown:
|
||||
case EV_KeyUp:
|
||||
e->KeyScan = ev->data1;
|
||||
e->KeyChar = ev->data2;
|
||||
e->KeyString.Format("%c", e->KeyChar);
|
||||
break;
|
||||
case EV_Mouse:
|
||||
e->MouseX = ev->x;
|
||||
e->MouseY = ev->y;
|
||||
break;
|
||||
default:
|
||||
break; // EV_DeviceChange = wat?
|
||||
}
|
||||
|
||||
int processed;
|
||||
VMReturn results[1] = { &processed };
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, e };
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, &e };
|
||||
GlobalVMStack.Call(func, params, 2, results, 1, nullptr);
|
||||
return !!processed;
|
||||
}
|
||||
|
@ -1083,18 +1046,7 @@ bool DStaticEventHandler::InputProcess(event_t* ev)
|
|||
return false;
|
||||
}
|
||||
|
||||
static DConsoleEvent* E_SetupConsoleEvent()
|
||||
{
|
||||
static DConsoleEvent* e = nullptr;
|
||||
if (!e) e = (DConsoleEvent*)RUNTIME_CLASS(DConsoleEvent)->CreateNew();
|
||||
e->Player = -1;
|
||||
e->Name = "";
|
||||
for (size_t i = 0; i < countof(e->Args); i++)
|
||||
e->Args[i] = 0;
|
||||
return e;
|
||||
}
|
||||
|
||||
void DStaticEventHandler::ConsoleProcess(int player, FString name, int arg1, int arg2, int arg3)
|
||||
void DStaticEventHandler::ConsoleProcess(int player, FString name, int arg1, int arg2, int arg3, bool manual)
|
||||
{
|
||||
if (player < 0)
|
||||
{
|
||||
|
@ -1103,16 +1055,17 @@ void DStaticEventHandler::ConsoleProcess(int player, FString name, int arg1, int
|
|||
// don't create excessive DObjects if not going to be processed anyway
|
||||
if (func == DStaticEventHandler_ConsoleProcess_VMPtr)
|
||||
return;
|
||||
DConsoleEvent* e = E_SetupConsoleEvent();
|
||||
FConsoleEvent e;
|
||||
|
||||
//
|
||||
e->Player = player;
|
||||
e->Name = name;
|
||||
e->Args[0] = arg1;
|
||||
e->Args[1] = arg2;
|
||||
e->Args[2] = arg3;
|
||||
e.Player = player;
|
||||
e.Name = name;
|
||||
e.Args[0] = arg1;
|
||||
e.Args[1] = arg2;
|
||||
e.Args[2] = arg3;
|
||||
e.IsManual = manual;
|
||||
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, e };
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, &e };
|
||||
GlobalVMStack.Call(func, params, 2, nullptr, 0, nullptr);
|
||||
}
|
||||
}
|
||||
|
@ -1123,16 +1076,17 @@ void DStaticEventHandler::ConsoleProcess(int player, FString name, int arg1, int
|
|||
// don't create excessive DObjects if not going to be processed anyway
|
||||
if (func == DStaticEventHandler_NetworkProcess_VMPtr)
|
||||
return;
|
||||
DConsoleEvent* e = E_SetupConsoleEvent();
|
||||
FConsoleEvent e;
|
||||
|
||||
//
|
||||
e->Player = player;
|
||||
e->Name = name;
|
||||
e->Args[0] = arg1;
|
||||
e->Args[1] = arg2;
|
||||
e->Args[2] = arg3;
|
||||
e.Player = player;
|
||||
e.Name = name;
|
||||
e.Args[0] = arg1;
|
||||
e.Args[1] = arg2;
|
||||
e.Args[2] = arg3;
|
||||
e.IsManual = manual;
|
||||
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, e };
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, &e };
|
||||
GlobalVMStack.Call(func, params, 2, nullptr, 0, nullptr);
|
||||
}
|
||||
}
|
||||
|
@ -1162,7 +1116,7 @@ CCMD(event)
|
|||
for (int i = 0; i < argn; i++)
|
||||
arg[i] = atoi(argv[2 + i]);
|
||||
// call locally
|
||||
E_Console(-1, argv[1], arg[0], arg[1], arg[2]);
|
||||
E_Console(-1, argv[1], arg[0], arg[1], arg[2], true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1187,6 +1141,6 @@ CCMD(netevent)
|
|||
for (int i = 0; i < argn; i++)
|
||||
arg[i] = atoi(argv[2 + i]);
|
||||
// call networked
|
||||
E_SendNetworkEvent(argv[1], arg[0], arg[1], arg[2]);
|
||||
E_SendNetworkEvent(argv[1], arg[0], arg[1], arg[2], true);
|
||||
}
|
||||
}
|
||||
|
|
109
src/events.h
109
src/events.h
|
@ -58,10 +58,10 @@ void E_PlayerDisconnected(int num);
|
|||
// this executes on events.
|
||||
bool E_Responder(event_t* ev); // splits events into InputProcess and UiProcess
|
||||
// this executes on console/net events.
|
||||
void E_Console(int player, FString name, int arg1, int arg2, int arg3);
|
||||
void E_Console(int player, FString name, int arg1, int arg2, int arg3, bool manual);
|
||||
|
||||
// send networked event. unified function.
|
||||
bool E_SendNetworkEvent(FString name, int arg1, int arg2, int arg3);
|
||||
bool E_SendNetworkEvent(FString name, int arg1, int arg2, int arg3, bool manual);
|
||||
|
||||
// check if there is anything that should receive GUI events
|
||||
bool E_CheckUiProcessors();
|
||||
|
@ -152,7 +152,7 @@ public:
|
|||
bool UiProcess(event_t* ev);
|
||||
|
||||
//
|
||||
void ConsoleProcess(int player, FString name, int arg1, int arg2, int arg3);
|
||||
void ConsoleProcess(int player, FString name, int arg1, int arg2, int arg3, bool manual);
|
||||
};
|
||||
class DEventHandler : public DStaticEventHandler
|
||||
{
|
||||
|
@ -163,76 +163,34 @@ public:
|
|||
extern DStaticEventHandler* E_FirstEventHandler;
|
||||
extern DStaticEventHandler* E_LastEventHandler;
|
||||
|
||||
// we cannot call this DEvent because in ZScript, 'event' is a keyword
|
||||
class DBaseEvent : public DObject
|
||||
struct FRenderEvent
|
||||
{
|
||||
DECLARE_CLASS(DBaseEvent, DObject)
|
||||
public:
|
||||
|
||||
DBaseEvent()
|
||||
{
|
||||
// each type of event is created only once to avoid new/delete hell
|
||||
// since from what I remember object creation and deletion results in a lot of GC processing
|
||||
// (and we aren't supposed to pass event objects around anyway)
|
||||
this->ObjectFlags |= OF_Fixed;
|
||||
// we don't want to store events into the savegames because they are global.
|
||||
this->ObjectFlags |= OF_Transient;
|
||||
}
|
||||
};
|
||||
|
||||
class DRenderEvent : public DBaseEvent
|
||||
{
|
||||
DECLARE_CLASS(DRenderEvent, DBaseEvent)
|
||||
public:
|
||||
// these are for all render events
|
||||
DVector3 ViewPos;
|
||||
DAngle ViewAngle;
|
||||
DAngle ViewPitch;
|
||||
DAngle ViewRoll;
|
||||
double FracTic; // 0..1 value that describes where we are inside the current gametic, render-wise.
|
||||
AActor* Camera;
|
||||
|
||||
DRenderEvent()
|
||||
{
|
||||
FracTic = 0;
|
||||
Camera = nullptr;
|
||||
}
|
||||
double FracTic = 0; // 0..1 value that describes where we are inside the current gametic, render-wise.
|
||||
AActor* Camera = nullptr;
|
||||
};
|
||||
|
||||
class DWorldEvent : public DBaseEvent
|
||||
struct FWorldEvent
|
||||
{
|
||||
DECLARE_CLASS(DWorldEvent, DBaseEvent)
|
||||
public:
|
||||
// for loaded/unloaded
|
||||
bool IsSaveGame;
|
||||
bool IsReopen;
|
||||
bool IsSaveGame = false;
|
||||
bool IsReopen = false;
|
||||
// for thingspawned, thingdied, thingdestroyed
|
||||
AActor* Thing;
|
||||
// for thingdied
|
||||
AActor* Inflictor; // can be null
|
||||
// for damagemobj
|
||||
int Damage;
|
||||
AActor* DamageSource; // can be null
|
||||
AActor* Thing = nullptr; // for thingdied
|
||||
AActor* Inflictor = nullptr; // can be null - for damagemobj
|
||||
AActor* DamageSource = nullptr; // can be null
|
||||
int Damage = 0;
|
||||
FName DamageType;
|
||||
int DamageFlags;
|
||||
int DamageFlags = 0;
|
||||
DAngle DamageAngle;
|
||||
|
||||
DWorldEvent()
|
||||
{
|
||||
IsSaveGame = false;
|
||||
IsReopen = false;
|
||||
Thing = nullptr;
|
||||
Inflictor = nullptr;
|
||||
Damage = 0;
|
||||
DamageSource = nullptr;
|
||||
DamageFlags = 0;
|
||||
}
|
||||
};
|
||||
|
||||
class DPlayerEvent : public DBaseEvent
|
||||
struct FPlayerEvent
|
||||
{
|
||||
DECLARE_CLASS(DPlayerEvent, DBaseEvent)
|
||||
public:
|
||||
// we currently have only one member: player index
|
||||
// in ZScript, we have global players[] array from which we can
|
||||
// get both the player itself and player's body,
|
||||
|
@ -240,18 +198,10 @@ public:
|
|||
int PlayerNumber;
|
||||
// we set this to true if level was reopened (RETURN scripts)
|
||||
bool IsReturn;
|
||||
|
||||
DPlayerEvent()
|
||||
{
|
||||
PlayerNumber = -1;
|
||||
IsReturn = false;
|
||||
}
|
||||
};
|
||||
|
||||
class DUiEvent : public DBaseEvent
|
||||
struct FUiEvent
|
||||
{
|
||||
DECLARE_CLASS(DUiEvent, DBaseEvent)
|
||||
public:
|
||||
// this essentially translates event_t UI events to ZScript.
|
||||
EGUIEvent Type;
|
||||
// for keys/chars/whatever
|
||||
|
@ -265,18 +215,13 @@ public:
|
|||
bool IsCtrl;
|
||||
bool IsAlt;
|
||||
|
||||
DUiEvent()
|
||||
{
|
||||
Type = EV_GUI_None;
|
||||
}
|
||||
FUiEvent(event_t *ev);
|
||||
};
|
||||
|
||||
class DInputEvent : public DBaseEvent
|
||||
struct FInputEvent
|
||||
{
|
||||
DECLARE_CLASS(DInputEvent, DBaseEvent)
|
||||
public:
|
||||
// this translates regular event_t events to ZScript (not UI, UI events are sent via DUiEvent and only if requested!)
|
||||
EGenericEvent Type;
|
||||
EGenericEvent Type = EV_None;
|
||||
// for keys
|
||||
int KeyScan;
|
||||
FString KeyString;
|
||||
|
@ -285,26 +230,18 @@ public:
|
|||
int MouseX;
|
||||
int MouseY;
|
||||
|
||||
DInputEvent()
|
||||
{
|
||||
Type = EV_None;
|
||||
}
|
||||
FInputEvent(event_t *ev);
|
||||
};
|
||||
|
||||
class DConsoleEvent : public DBaseEvent
|
||||
struct FConsoleEvent
|
||||
{
|
||||
DECLARE_CLASS(DConsoleEvent, DBaseEvent)
|
||||
public:
|
||||
// player that activated this event. note that it's always -1 for non-playsim events (i.e. these not called with netevent)
|
||||
int Player;
|
||||
//
|
||||
FString Name;
|
||||
int Args[3];
|
||||
|
||||
DConsoleEvent()
|
||||
{
|
||||
Player = -1;
|
||||
}
|
||||
//
|
||||
bool IsManual;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -56,6 +56,7 @@
|
|||
#include "menu/menu.h"
|
||||
#include "textures/textures.h"
|
||||
#include "virtual.h"
|
||||
#include "events.h"
|
||||
|
||||
//
|
||||
// Todo: Move these elsewhere
|
||||
|
@ -173,15 +174,31 @@ DMenu::DMenu(DMenu *parent)
|
|||
|
||||
bool DMenu::CallResponder(event_t *ev)
|
||||
{
|
||||
IFVIRTUAL(DMenu, Responder)
|
||||
if (ev->type == EV_GUI_Event)
|
||||
{
|
||||
VMValue params[] = { (DObject*)this, ev};
|
||||
int retval;
|
||||
VMReturn ret(&retval);
|
||||
GlobalVMStack.Call(func, params, 2, &ret, 1, nullptr);
|
||||
return !!retval;
|
||||
IFVIRTUAL(DMenu, OnUIEvent)
|
||||
{
|
||||
FUiEvent e = ev;
|
||||
VMValue params[] = { (DObject*)this, &e };
|
||||
int retval;
|
||||
VMReturn ret(&retval);
|
||||
GlobalVMStack.Call(func, params, 2, &ret, 1, nullptr);
|
||||
return !!retval;
|
||||
}
|
||||
}
|
||||
else return false;
|
||||
else
|
||||
{
|
||||
IFVIRTUAL(DMenu, OnInputEvent)
|
||||
{
|
||||
FInputEvent e = ev;
|
||||
VMValue params[] = { (DObject*)this, &e };
|
||||
int retval;
|
||||
VMReturn ret(&retval);
|
||||
GlobalVMStack.Call(func, params, 2, &ret, 1, nullptr);
|
||||
return !!retval;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
|
|
@ -6063,10 +6063,9 @@ FxExpression *FxIdentifier::ResolveMember(FCompileContext &ctx, PStruct *classct
|
|||
object = nullptr;
|
||||
return nullptr;
|
||||
}
|
||||
if ((vsym->Flags & VARF_Deprecated) && sym->mVersion >= ctx.Version)
|
||||
if ((vsym->Flags & VARF_Deprecated) && sym->mVersion <= ctx.Version)
|
||||
{
|
||||
ScriptPosition.Message(MSG_WARNING, "Accessing deprecated member variable %s - deprecated since %d.%d.%d", sym->SymbolName.GetChars(), vsym->mVersion.major, vsym->mVersion.minor, vsym->mVersion.revision);
|
||||
ScriptPosition.Message(MSG_WARNING, "Accessing deprecated member variable %s", vsym->SymbolName.GetChars());
|
||||
}
|
||||
|
||||
// We have 4 cases to consider here:
|
||||
|
@ -8513,10 +8512,9 @@ bool FxVMFunctionCall::CheckAccessibility(const VersionInfo &ver)
|
|||
ScriptPosition.Message(MSG_ERROR, "%s not accessible to %s", Function->SymbolName.GetChars(), VersionString.GetChars());
|
||||
return false;
|
||||
}
|
||||
if ((Function->Variants[0].Flags & VARF_Deprecated) && Function->mVersion >= ver)
|
||||
if ((Function->Variants[0].Flags & VARF_Deprecated) && Function->mVersion <= ver)
|
||||
{
|
||||
ScriptPosition.Message(MSG_WARNING, "Accessing deprecated function %s - deprecated since %d.%d.%d", Function->SymbolName.GetChars(), Function->mVersion.major, Function->mVersion.minor, Function->mVersion.revision);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -8565,7 +8563,7 @@ FxExpression *FxVMFunctionCall::Resolve(FCompileContext& ctx)
|
|||
if (!CheckAccessibility(ctx.Version))
|
||||
{
|
||||
delete this;
|
||||
return false;
|
||||
return nullptr;
|
||||
}
|
||||
// This should never happen.
|
||||
if (Self == nullptr && (Function->Variants[0].Flags & VARF_Method))
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
#ifdef HAVE_MPG123
|
||||
|
||||
#ifdef _MSC_VER
|
||||
typedef int ssize_t;
|
||||
#include <stddef.h>
|
||||
typedef ptrdiff_t ssize_t;
|
||||
#endif
|
||||
#include "mpg123.h"
|
||||
|
||||
|
|
|
@ -1,55 +1,3 @@
|
|||
struct InputEventData native version("2.4")
|
||||
{
|
||||
native uint8 type;
|
||||
native uint8 subtype;
|
||||
native int16 data1; // keys / mouse/joystick buttons
|
||||
native int16 data2;
|
||||
native int16 data3;
|
||||
native int x; // mouse/joystick x move
|
||||
native int y; // mouse/joystick y move
|
||||
|
||||
enum EGenericEvent
|
||||
{
|
||||
NoEvent,
|
||||
KeyDown, // data1: scan code, data2: Qwerty ASCII code
|
||||
KeyUp, // same
|
||||
Mouse, // x, y: mouse movement deltas
|
||||
GUI_Event, // subtype specifies actual event
|
||||
DeviceChange,// a device has been connected or removed
|
||||
}
|
||||
|
||||
enum EGUIEvent
|
||||
{
|
||||
GUI_None,
|
||||
GUI_KeyDown, // data1: unshifted ASCII, data2: shifted ASCII, data3: modifiers
|
||||
GUI_KeyRepeat, // same
|
||||
GUI_KeyUp, // same
|
||||
GUI_Char, // data1: translated character (for user text input), data2: alt down?
|
||||
GUI_FirstMouseEvent,
|
||||
GUI_MouseMove,
|
||||
GUI_LButtonDown,
|
||||
GUI_LButtonUp,
|
||||
GUI_LButtonDblClick,
|
||||
GUI_MButtonDown,
|
||||
GUI_MButtonUp,
|
||||
GUI_MButtonDblClick,
|
||||
GUI_RButtonDown,
|
||||
GUI_RButtonUp,
|
||||
GUI_RButtonDblClick,
|
||||
GUI_WheelUp, // data3: shift/ctrl/alt
|
||||
GUI_WheelDown, // "
|
||||
GUI_WheelRight, // "
|
||||
GUI_WheelLeft, // "
|
||||
GUI_BackButtonDown,
|
||||
GUI_BackButtonUp,
|
||||
GUI_FwdButtonDown,
|
||||
GUI_FwdButtonUp,
|
||||
GUI_LastMouseEvent,
|
||||
};
|
||||
|
||||
const KEY_ESCAPE = 0x01;
|
||||
}
|
||||
|
||||
struct TexMan
|
||||
{
|
||||
enum EUseTypes
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
class BaseEvent native version("2.4") { } // just a base class. it doesn't inherit from Object on the scripting side so you can't call Destroy() on it and break everything.
|
||||
|
||||
class RenderEvent : BaseEvent native ui version("2.4")
|
||||
struct RenderEvent native ui version("2.4")
|
||||
{
|
||||
native readonly Vector3 ViewPos;
|
||||
native readonly double ViewAngle;
|
||||
|
@ -10,7 +9,7 @@ class RenderEvent : BaseEvent native ui version("2.4")
|
|||
native readonly Actor Camera;
|
||||
}
|
||||
|
||||
class WorldEvent : BaseEvent native play version("2.4")
|
||||
struct WorldEvent native play version("2.4")
|
||||
{
|
||||
// for loaded/unloaded
|
||||
native readonly bool IsSaveGame;
|
||||
|
@ -28,7 +27,7 @@ class WorldEvent : BaseEvent native play version("2.4")
|
|||
native readonly double DamageAngle;
|
||||
}
|
||||
|
||||
class PlayerEvent : BaseEvent native play version("2.4")
|
||||
struct PlayerEvent native play version("2.4")
|
||||
{
|
||||
// this is the player number that caused the event.
|
||||
// note: you can get player struct from this by using players[e.PlayerNumber]
|
||||
|
@ -37,7 +36,7 @@ class PlayerEvent : BaseEvent native play version("2.4")
|
|||
native readonly bool IsReturn;
|
||||
}
|
||||
|
||||
class UiEvent : BaseEvent native ui version("2.4")
|
||||
struct UiEvent native ui version("2.4")
|
||||
{
|
||||
// d_gui.h
|
||||
enum EGUIEvent
|
||||
|
@ -121,7 +120,7 @@ class UiEvent : BaseEvent native ui version("2.4")
|
|||
native readonly bool IsAlt;
|
||||
}
|
||||
|
||||
class InputEvent : BaseEvent native play version("2.4")
|
||||
struct InputEvent native play version("2.4")
|
||||
{
|
||||
enum EGenericEvent
|
||||
{
|
||||
|
@ -270,13 +269,16 @@ class InputEvent : BaseEvent native play version("2.4")
|
|||
native readonly int MouseY;
|
||||
}
|
||||
|
||||
class ConsoleEvent : BaseEvent native version("2.4")
|
||||
struct ConsoleEvent native version("2.4")
|
||||
{
|
||||
// for net events, this will be the activator.
|
||||
// for UI events, this is always -1, and you need to check if level is loaded and use players[consoleplayer].
|
||||
native readonly int Player;
|
||||
// this is the name and args as specified in SendNetworkEvent or event/netevent CCMDs
|
||||
native readonly String Name;
|
||||
native readonly int Args[3];
|
||||
// this will be true if the event is fired from the console by event/netevent CCMD
|
||||
native readonly bool IsManual;
|
||||
}
|
||||
|
||||
class StaticEventHandler : Object native play version("2.4")
|
||||
|
@ -318,7 +320,7 @@ class StaticEventHandler : Object native play version("2.4")
|
|||
|
||||
//
|
||||
virtual native ui bool UiProcess(UiEvent e);
|
||||
virtual native bool InputProcess(InputEvent e);
|
||||
virtual native ui bool InputProcess(InputEvent e);
|
||||
|
||||
//
|
||||
virtual native ui void ConsoleProcess(ConsoleEvent e);
|
||||
|
|
|
@ -335,18 +335,18 @@ class ConversationMenu : Menu
|
|||
//
|
||||
//=============================================================================
|
||||
|
||||
override bool Responder(InputEventData ev)
|
||||
override bool OnUIEvent(UIEvent ev)
|
||||
{
|
||||
if (demoplayback)
|
||||
{ // No interaction during demo playback
|
||||
return false;
|
||||
}
|
||||
if (ev.type == InputEventData.GUI_Event && ev.subtype == InputEventData.GUI_Char && ev.data1 >= 48 && ev.data1 <= 57)
|
||||
if (ev.type == UIEvent.Type_Char && ev.KeyChar >= 48 && ev.KeyChar <= 57)
|
||||
{ // Activate an item of type numberedmore (dialogue only)
|
||||
mSelection = ev.data1 == 48 ? 9 : ev.data1 - 49;
|
||||
mSelection = ev.KeyChar == 48 ? 9 : ev.KeyChar - 49;
|
||||
return MenuEvent(MKEY_Enter, false);
|
||||
}
|
||||
return Super.Responder(ev);
|
||||
return Super.OnUIEvent(ev);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
|
|
|
@ -99,37 +99,34 @@ class ListMenu : Menu
|
|||
//
|
||||
//=============================================================================
|
||||
|
||||
override bool Responder (InputEventData ev)
|
||||
override bool OnUIEvent(UIEvent ev)
|
||||
{
|
||||
if (ev.type == InputEventData.GUI_Event)
|
||||
if (ev.Type == UIEvent.Type_KeyDown)
|
||||
{
|
||||
if (ev.subtype == InputEventData.GUI_KeyDown)
|
||||
{
|
||||
// tolower
|
||||
int ch = ev.data1;
|
||||
ch = ch >= 65 && ch <91? ch + 32 : ch;
|
||||
// tolower
|
||||
int ch = ev.KeyChar;
|
||||
ch = ch >= 65 && ch <91? ch + 32 : ch;
|
||||
|
||||
for(int i = mDesc.mSelectedItem + 1; i < mDesc.mItems.Size(); i++)
|
||||
for(int i = mDesc.mSelectedItem + 1; i < mDesc.mItems.Size(); i++)
|
||||
{
|
||||
if (mDesc.mItems[i].CheckHotkey(ch))
|
||||
{
|
||||
if (mDesc.mItems[i].CheckHotkey(ch))
|
||||
{
|
||||
mDesc.mSelectedItem = i;
|
||||
MenuSound("menu/cursor");
|
||||
return true;
|
||||
}
|
||||
mDesc.mSelectedItem = i;
|
||||
MenuSound("menu/cursor");
|
||||
return true;
|
||||
}
|
||||
for(int i = 0; i < mDesc.mSelectedItem; i++)
|
||||
}
|
||||
for(int i = 0; i < mDesc.mSelectedItem; i++)
|
||||
{
|
||||
if (mDesc.mItems[i].CheckHotkey(ch))
|
||||
{
|
||||
if (mDesc.mItems[i].CheckHotkey(ch))
|
||||
{
|
||||
mDesc.mSelectedItem = i;
|
||||
MenuSound("menu/cursor");
|
||||
return true;
|
||||
}
|
||||
mDesc.mSelectedItem = i;
|
||||
MenuSound("menu/cursor");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Super.Responder(ev);
|
||||
return Super.OnUIEvent(ev);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
|
|
@ -383,42 +383,39 @@ class LoadSaveMenu : ListMenu
|
|||
//
|
||||
//=============================================================================
|
||||
|
||||
override bool Responder (InputEventData ev)
|
||||
override bool OnUIEvent(UIEvent ev)
|
||||
{
|
||||
if (ev.type == InputEventData.GUI_Event)
|
||||
if (ev.Type == UIEvent.Type_KeyDown)
|
||||
{
|
||||
if (ev.subtype == InputEventData.GUI_KeyDown)
|
||||
if (Selected < manager.SavegameCount())
|
||||
{
|
||||
if (Selected < manager.SavegameCount())
|
||||
switch (ev.KeyChar)
|
||||
{
|
||||
switch (ev.data1)
|
||||
{
|
||||
case UIEvent.Key_F1:
|
||||
manager.SetFileInfo(Selected);
|
||||
return true;
|
||||
case UIEvent.Key_F1:
|
||||
manager.SetFileInfo(Selected);
|
||||
return true;
|
||||
|
||||
case UIEvent.Key_DEL:
|
||||
{
|
||||
String EndString;
|
||||
EndString = String.Format("%s%s%s%s?\n\n%s", Stringtable.Localize("$MNU_DELETESG"), TEXTCOLOR_WHITE, manager.GetSavegame(Selected).SaveTitle, TEXTCOLOR_NORMAL, Stringtable.Localize("$PRESSYN"));
|
||||
StartMessage (EndString, 0);
|
||||
}
|
||||
return true;
|
||||
case UIEvent.Key_DEL:
|
||||
{
|
||||
String EndString;
|
||||
EndString = String.Format("%s%s%s%s?\n\n%s", Stringtable.Localize("$MNU_DELETESG"), TEXTCOLOR_WHITE, manager.GetSavegame(Selected).SaveTitle, TEXTCOLOR_NORMAL, Stringtable.Localize("$PRESSYN"));
|
||||
StartMessage (EndString, 0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (ev.subtype == InputEventData.GUI_WheelUp)
|
||||
{
|
||||
if (TopItem > 0) TopItem--;
|
||||
return true;
|
||||
}
|
||||
else if (ev.subtype == InputEventData.GUI_WheelDown)
|
||||
{
|
||||
if (TopItem < manager.SavegameCount() - listboxRows) TopItem++;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return Super.Responder(ev);
|
||||
else if (ev.Type == UIEvent.Type_WheelUp)
|
||||
{
|
||||
if (TopItem > 0) TopItem--;
|
||||
return true;
|
||||
}
|
||||
else if (ev.Type == UIEvent.Type_WheelDown)
|
||||
{
|
||||
if (TopItem < manager.SavegameCount() - listboxRows) TopItem++;
|
||||
return true;
|
||||
}
|
||||
return Super.OnUIEvent(ev);
|
||||
}
|
||||
|
||||
|
||||
|
@ -503,13 +500,13 @@ class SaveMenu : LoadSaveMenu
|
|||
//
|
||||
//=============================================================================
|
||||
|
||||
override bool Responder (InputEventData ev)
|
||||
override bool OnUIEvent(UIEvent ev)
|
||||
{
|
||||
if (ev.subtype == InputEventData.GUI_KeyDown)
|
||||
if (ev.Type == UIEvent.Type_KeyDown)
|
||||
{
|
||||
if (Selected != -1)
|
||||
{
|
||||
switch (ev.data1)
|
||||
switch (ev.KeyChar)
|
||||
{
|
||||
case UIEvent.Key_DEL:
|
||||
// cannot delete 'new save game' item
|
||||
|
@ -523,9 +520,14 @@ class SaveMenu : LoadSaveMenu
|
|||
}
|
||||
}
|
||||
}
|
||||
return Super.Responder(ev);
|
||||
return Super.OnUIEvent(ev);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
override void Ticker()
|
||||
{
|
||||
|
|
|
@ -169,47 +169,50 @@ class Menu : Object native ui version("2.4")
|
|||
//
|
||||
//=============================================================================
|
||||
|
||||
virtual bool Responder(InputEventData ev)
|
||||
virtual bool OnUIEvent(UIEvent ev)
|
||||
{
|
||||
bool res = false;
|
||||
if (ev.type == InputEventData.GUI_Event)
|
||||
int y = ev.MouseY;
|
||||
if (ev.type == UIEvent.Type_LButtonDown)
|
||||
{
|
||||
if (ev.subtype == InputEventData.GUI_LButtonDown)
|
||||
res = MouseEventBack(MOUSE_Click, ev.MouseX, y);
|
||||
// make the menu's mouse handler believe that the current coordinate is outside the valid range
|
||||
if (res) y = -1;
|
||||
res |= MouseEvent(MOUSE_Click, ev.MouseX, y);
|
||||
if (res)
|
||||
{
|
||||
res = MouseEventBack(MOUSE_Click, ev.data1, ev.data2);
|
||||
// make the menu's mouse handler believe that the current coordinate is outside the valid range
|
||||
if (res) ev.data2 = -1;
|
||||
res |= MouseEvent(MOUSE_Click, ev.data1, ev.data2);
|
||||
if (res)
|
||||
{
|
||||
SetCapture(true);
|
||||
}
|
||||
|
||||
SetCapture(true);
|
||||
}
|
||||
else if (ev.subtype == InputEventData.GUI_MouseMove)
|
||||
|
||||
}
|
||||
else if (ev.type == UIEvent.Type_MouseMove)
|
||||
{
|
||||
BackbuttonTime = 4*Thinker.TICRATE;
|
||||
if (mMouseCapture || m_use_mouse == 1)
|
||||
{
|
||||
BackbuttonTime = 4*Thinker.TICRATE;
|
||||
if (mMouseCapture || m_use_mouse == 1)
|
||||
{
|
||||
res = MouseEventBack(MOUSE_Move, ev.data1, ev.data2);
|
||||
if (res) ev.data2 = -1;
|
||||
res |= MouseEvent(MOUSE_Move, ev.data1, ev.data2);
|
||||
}
|
||||
res = MouseEventBack(MOUSE_Move, ev.MouseX, y);
|
||||
if (res) y = -1;
|
||||
res |= MouseEvent(MOUSE_Move, ev.MouseX, y);
|
||||
}
|
||||
else if (ev.subtype == InputEventData.GUI_LButtonUp)
|
||||
}
|
||||
else if (ev.type == UIEvent.Type_LButtonUp)
|
||||
{
|
||||
if (mMouseCapture)
|
||||
{
|
||||
if (mMouseCapture)
|
||||
{
|
||||
SetCapture(false);
|
||||
res = MouseEventBack(MOUSE_Release, ev.data1, ev.data2);
|
||||
if (res) ev.data2 = -1;
|
||||
res |= MouseEvent(MOUSE_Release, ev.data1, ev.data2);
|
||||
}
|
||||
SetCapture(false);
|
||||
res = MouseEventBack(MOUSE_Release, ev.MouseX, y);
|
||||
if (res) y = -1;
|
||||
res |= MouseEvent(MOUSE_Release, ev.MouseX, y);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool OnInputEvent(InputEvent ev)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
|
|
|
@ -171,14 +171,14 @@ class MessageBoxMenu : Menu
|
|||
//
|
||||
//=============================================================================
|
||||
|
||||
override bool Responder(InputEventData ev)
|
||||
override bool OnUIEvent(UIEvent ev)
|
||||
{
|
||||
if (ev.type == InputEventData.GUI_Event && ev.subtype == InputEventData.GUI_KeyDown)
|
||||
if (ev.type == UIEvent.Type_KeyDown)
|
||||
{
|
||||
if (mMessageMode == 0)
|
||||
{
|
||||
// tolower
|
||||
int ch = ev.data1;
|
||||
int ch = ev.KeyChar;
|
||||
ch = ch >= 65 && ch <91? ch + 32 : ch;
|
||||
|
||||
if (ch == 110 /*'n'*/ || ch == 32)
|
||||
|
@ -199,12 +199,17 @@ class MessageBoxMenu : Menu
|
|||
}
|
||||
return false;
|
||||
}
|
||||
else if (ev.type == InputEventData.KeyDown)
|
||||
return Super.OnUIEvent(ev);
|
||||
}
|
||||
|
||||
override bool OnInputEvent(InputEvent ev)
|
||||
{
|
||||
if (ev.type == InputEvent.Type_KeyDown)
|
||||
{
|
||||
Close();
|
||||
return true;
|
||||
}
|
||||
return Super.Responder(ev);
|
||||
return Super.OnInputEvent(ev);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
|
|
@ -155,35 +155,32 @@ class OptionMenu : Menu
|
|||
//
|
||||
//=============================================================================
|
||||
|
||||
override bool Responder (InputEventData ev)
|
||||
override bool OnUIEvent(UIEvent ev)
|
||||
{
|
||||
if (ev.type == InputEventData.GUI_Event)
|
||||
if (ev.type == UIEvent.Type_WheelUp)
|
||||
{
|
||||
if (ev.subtype == InputEventData.GUI_WheelUp)
|
||||
{
|
||||
int scrollamt = MIN(2, mDesc.mScrollPos);
|
||||
mDesc.mScrollPos -= scrollamt;
|
||||
return true;
|
||||
}
|
||||
else if (ev.subtype == InputEventData.GUI_WheelDown)
|
||||
{
|
||||
if (CanScrollDown)
|
||||
{
|
||||
if (VisBottom >= 0 && VisBottom < (mDesc.mItems.Size()-2))
|
||||
{
|
||||
mDesc.mScrollPos += 2;
|
||||
VisBottom += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
mDesc.mScrollPos++;
|
||||
VisBottom++;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
int scrollamt = MIN(2, mDesc.mScrollPos);
|
||||
mDesc.mScrollPos -= scrollamt;
|
||||
return true;
|
||||
}
|
||||
return Super.Responder(ev);
|
||||
else if (ev.type == UIEvent.Type_WheelDown)
|
||||
{
|
||||
if (CanScrollDown)
|
||||
{
|
||||
if (VisBottom >= 0 && VisBottom < (mDesc.mItems.Size()-2))
|
||||
{
|
||||
mDesc.mScrollPos += 2;
|
||||
VisBottom += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
mDesc.mScrollPos++;
|
||||
VisBottom++;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return Super.OnUIEvent(ev);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
|
|
@ -396,16 +396,16 @@ class EnterKey : Menu
|
|||
}
|
||||
}
|
||||
|
||||
override bool Responder(InputEventData ev)
|
||||
override bool OnInputEvent(InputEvent ev)
|
||||
{
|
||||
// This checks raw keys, not GUI keys.
|
||||
if (ev.type == InputEventData.KeyDown)
|
||||
// This menu checks raw keys, not GUI keys because it needs the raw codes for binding.
|
||||
if (ev.type == InputEvent.Type_KeyDown)
|
||||
{
|
||||
mOwner.SendKey(ev.data1);
|
||||
mOwner.SendKey(ev.KeyScan);
|
||||
menuactive = Menu.On;
|
||||
SetMenuMessage(0);
|
||||
Close();
|
||||
mParentMenu.MenuEvent((ev.data1 == InputEventData.KEY_ESCAPE)? Menu.MKEY_Abort : Menu.MKEY_Input, 0);
|
||||
mParentMenu.MenuEvent((ev.KeyScan == InputEvent.KEY_ESCAPE)? Menu.MKEY_Abort : Menu.MKEY_Input, 0);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -372,9 +372,9 @@ class PlayerMenu : ListMenu
|
|||
//
|
||||
//=============================================================================
|
||||
|
||||
override bool Responder (InputEventData ev)
|
||||
override bool OnUIEvent(UIEvent ev)
|
||||
{
|
||||
if (ev.type == InputEventData.GUI_Event && ev.subtype == InputEventData.GUI_Char && ev.data1 == 32)
|
||||
if (ev.Type == UIEvent.Type_Char && ev.KeyChar == 32)
|
||||
{
|
||||
// turn the player sprite around
|
||||
mRotation = 8 - mRotation;
|
||||
|
@ -385,7 +385,7 @@ class PlayerMenu : ListMenu
|
|||
}
|
||||
return true;
|
||||
}
|
||||
return Super.Responder(ev);
|
||||
return Super.OnUIEvent(ev);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
|
|
@ -108,59 +108,56 @@ class TextEnterMenu : Menu
|
|||
//
|
||||
//=============================================================================
|
||||
|
||||
override bool Responder(InputEventData ev)
|
||||
override bool OnUIEvent(UIEvent ev)
|
||||
{
|
||||
if (ev.type == InputEventData.GUI_Event)
|
||||
// Save game and player name string input
|
||||
if (ev.Type == UIEvent.Type_Char)
|
||||
{
|
||||
// Save game and player name string input
|
||||
if (ev.subtype == InputEventData.GUI_Char)
|
||||
mInputGridOkay = false;
|
||||
if (mEnterString.Length() < mEnterSize &&
|
||||
(mSizeMode == 2/*entering player name*/ || SmallFont.StringWidth(mEnterString) < (mEnterSize-1)*8))
|
||||
{
|
||||
mInputGridOkay = false;
|
||||
if (mEnterString.Length() < mEnterSize &&
|
||||
(mSizeMode == 2/*entering player name*/ || SmallFont.StringWidth(mEnterString) < (mEnterSize-1)*8))
|
||||
{
|
||||
mEnterString.AppendFormat("%c", ev.data1);
|
||||
}
|
||||
mEnterString.AppendFormat("%c", ev.KeyChar);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
int ch = ev.KeyChar;
|
||||
if ((ev.Type == UIEvent.Type_KeyDown || ev.Type == UIEvent.Type_KeyRepeat) && ch == 8)
|
||||
{
|
||||
if (mEnterString.Length() > 0)
|
||||
{
|
||||
mEnterString.Truncate(mEnterString.Length() - 1);
|
||||
}
|
||||
}
|
||||
else if (ev.Type == UIEvent.Type_KeyDown)
|
||||
{
|
||||
if (ch == UIEvent.Key_ESCAPE)
|
||||
{
|
||||
Menu parent = mParentMenu;
|
||||
Close();
|
||||
parent.MenuEvent(MKEY_Abort, false);
|
||||
return true;
|
||||
}
|
||||
int ch = ev.data1;
|
||||
if ((ev.subtype == InputEventData.GUI_KeyDown || ev.subtype == InputEventData.GUI_KeyRepeat) && ch == 8)
|
||||
else if (ch == 13)
|
||||
{
|
||||
if (mEnterString.Length() > 0)
|
||||
{
|
||||
mEnterString.Truncate(mEnterString.Length() - 1);
|
||||
}
|
||||
}
|
||||
else if (ev.subtype == InputEventData.GUI_KeyDown)
|
||||
{
|
||||
if (ch == UIEvent.Key_ESCAPE)
|
||||
{
|
||||
// [TP] If we allow color codes, colorize the string now.
|
||||
if (AllowColors)
|
||||
mEnterString = mEnterString.Filter();
|
||||
|
||||
Menu parent = mParentMenu;
|
||||
parent.MenuEvent(MKEY_Input, false);
|
||||
Close();
|
||||
parent.MenuEvent(MKEY_Abort, false);
|
||||
return true;
|
||||
}
|
||||
else if (ch == 13)
|
||||
{
|
||||
if (mEnterString.Length() > 0)
|
||||
{
|
||||
// [TP] If we allow color codes, colorize the string now.
|
||||
if (AllowColors)
|
||||
mEnterString = mEnterString.Filter();
|
||||
|
||||
Menu parent = mParentMenu;
|
||||
parent.MenuEvent(MKEY_Input, false);
|
||||
Close();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ev.subtype == InputEventData.GUI_KeyDown || ev.subtype == InputEventData.GUI_KeyRepeat)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return Super.Responder(ev);
|
||||
if (ev.Type == UIEvent.Type_KeyDown || ev.Type == UIEvent.Type_KeyRepeat)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return Super.OnUIEvent(ev);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
|
|
@ -57,9 +57,9 @@ class VideoModeMenu : OptionMenu
|
|||
return Super.MenuEvent(mkey, fromcontroller);
|
||||
}
|
||||
|
||||
override bool Responder(InputEventData ev)
|
||||
override bool OnUIEvent(UIEvent ev)
|
||||
{
|
||||
if (ev.type == InputEventData.GUI_Event && ev.subtype == InputEventData.GUI_KeyDown && (ev.data1 == 0x54 || ev.data1 == 0x74))
|
||||
if (ev.Type == UIEvent.Type_KeyDown && (ev.KeyChar == 0x54 || ev.KeyChar == 0x74))
|
||||
{
|
||||
if (SetSelectedSize())
|
||||
{
|
||||
|
@ -67,7 +67,7 @@ class VideoModeMenu : OptionMenu
|
|||
return true;
|
||||
}
|
||||
}
|
||||
return Super.Responder(ev);
|
||||
return Super.OnUIEvent(ev);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue