From aef882c1378f2f0d07cf62eff8fa6c22fbe6c75f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 6 Dec 2018 00:28:05 +0100 Subject: [PATCH] - more direct native stuff, this is a week old but was almost forgotten. --- src/g_level.cpp | 18 ++++---- .../postprocessing/hw_postprocessshader.cpp | 29 ++++++++----- src/menu/menu.cpp | 43 ++++++++++++++----- src/p_sectors.cpp | 2 +- 4 files changed, 62 insertions(+), 30 deletions(-) diff --git a/src/g_level.cpp b/src/g_level.cpp index dca97f2190d..fe5477bf6c5 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -2031,9 +2031,9 @@ void FLevelLocals::SetMusicVolume(float f) //========================================================================== -bool IsPointInMap(DVector3 p) +int IsPointInMap(double x, double y, double z) { - subsector_t *subsector = R_PointInSubsector(FLOAT2FIXED(p.X), FLOAT2FIXED(p.Y)); + subsector_t *subsector = R_PointInSubsector(FLOAT2FIXED(x), FLOAT2FIXED(y)); if (!subsector) return false; for (uint32_t i = 0; i < subsector->numlines; i++) @@ -2044,26 +2044,26 @@ bool IsPointInMap(DVector3 p) divline_t dline; P_MakeDivline(seg->linedef, &dline); - bool pol = P_PointOnDivlineSide(p.XY(), &dline) < 1; + bool pol = P_PointOnDivlineSide(x, y, &dline) < 1; if (!pol) return false; } - double ceilingZ = subsector->sector->ceilingplane.ZatPoint(p.X, p.Y); - if (p.Z > ceilingZ) return false; + double ceilingZ = subsector->sector->ceilingplane.ZatPoint(x, y); + if (z > ceilingZ) return false; - double floorZ = subsector->sector->floorplane.ZatPoint(p.X, p.Y); - if (p.Z < floorZ) return false; + double floorZ = subsector->sector->floorplane.ZatPoint(x, y); + if (z < floorZ) return false; return true; } -DEFINE_ACTION_FUNCTION(FLevelLocals, IsPointInMap) +DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, IsPointInMap, IsPointInMap) { PARAM_PROLOGUE; PARAM_FLOAT(x); PARAM_FLOAT(y); PARAM_FLOAT(z); - ACTION_RETURN_BOOL(IsPointInMap(DVector3(x,y,z))); + ACTION_RETURN_BOOL(IsPointInMap(x, y, z)); } template diff --git a/src/hwrenderer/postprocessing/hw_postprocessshader.cpp b/src/hwrenderer/postprocessing/hw_postprocessshader.cpp index 95205dac66a..dc6a465b624 100644 --- a/src/hwrenderer/postprocessing/hw_postprocessshader.cpp +++ b/src/hwrenderer/postprocessing/hw_postprocessshader.cpp @@ -35,13 +35,8 @@ static bool IsConsolePlayer(player_t *player) return int(activator->player - players) == consoleplayer; } -DEFINE_ACTION_FUNCTION(_Shader, SetEnabled) +static void ShaderSetEnabled(player_t *player, const FString &shaderName, bool value) { - PARAM_PROLOGUE; - PARAM_POINTER(player, player_t); - PARAM_STRING(shaderName); - PARAM_BOOL(value); - if (IsConsolePlayer(player)) { for (unsigned int i = 0; i < PostProcessShaders.Size(); i++) @@ -51,17 +46,21 @@ DEFINE_ACTION_FUNCTION(_Shader, SetEnabled) shader.Enabled = value; } } - return 0; } -DEFINE_ACTION_FUNCTION(_Shader, SetUniform1f) +DEFINE_ACTION_FUNCTION_NATIVE(_Shader, SetEnabled, ShaderSetEnabled) { PARAM_PROLOGUE; PARAM_POINTER(player, player_t); PARAM_STRING(shaderName); - PARAM_STRING(uniformName); - PARAM_FLOAT(value); + PARAM_BOOL(value); + ShaderSetEnabled(player, shaderName, value); + return 0; +} + +static void ShaderSetUniform1f(player_t *player, const FString &shaderName, const FString &uniformName, double value) +{ if (IsConsolePlayer(player)) { for (unsigned int i = 0; i < PostProcessShaders.Size(); i++) @@ -77,6 +76,16 @@ DEFINE_ACTION_FUNCTION(_Shader, SetUniform1f) } } } +} + +DEFINE_ACTION_FUNCTION_NATIVE(_Shader, SetUniform1f, ShaderSetUniform1f) +{ + PARAM_PROLOGUE; + PARAM_POINTER(player, player_t); + PARAM_STRING(shaderName); + PARAM_STRING(uniformName); + PARAM_FLOAT(value); + ShaderSetUniform1f(player, shaderName, uniformName, value); return 0; } diff --git a/src/menu/menu.cpp b/src/menu/menu.cpp index a09186dcc3a..a61733a2d8a 100644 --- a/src/menu/menu.cpp +++ b/src/menu/menu.cpp @@ -83,13 +83,22 @@ CVAR(Color, dimcolor, 0xffd700, CVAR_ARCHIVE) -DEFINE_ACTION_FUNCTION(DMenu, GetCurrentMenu) +static DMenu *GetCurrentMenu() +{ + return CurrentMenu; +} + +DEFINE_ACTION_FUNCTION_NATIVE(DMenu, GetCurrentMenu, GetCurrentMenu) { ACTION_RETURN_OBJECT(CurrentMenu); } +static int GetMenuTime() +{ + return MenuTime; +} -DEFINE_ACTION_FUNCTION(DMenu, MenuTime) +DEFINE_ACTION_FUNCTION_NATIVE(DMenu, MenuTime, GetMenuTime) { ACTION_RETURN_INT(MenuTime); } @@ -123,13 +132,17 @@ IMPLEMENT_CLASS(DMenuDescriptor, false, false) IMPLEMENT_CLASS(DListMenuDescriptor, false, false) IMPLEMENT_CLASS(DOptionMenuDescriptor, false, false) -DEFINE_ACTION_FUNCTION(DMenuDescriptor, GetDescriptor) +DMenuDescriptor *GetMenuDescriptor(int name) +{ + DMenuDescriptor **desc = MenuDescriptors.CheckKey(ENamedName(name)); + return desc ? *desc : nullptr; +} + +DEFINE_ACTION_FUNCTION_NATIVE(DMenuDescriptor, GetDescriptor, GetMenuDescriptor) { PARAM_PROLOGUE; PARAM_NAME(name); - DMenuDescriptor **desc = MenuDescriptors.CheckKey(name); - auto retn = desc ? *desc : nullptr; - ACTION_RETURN_OBJECT(retn); + ACTION_RETURN_OBJECT(GetMenuDescriptor(name)); } size_t DListMenuDescriptor::PropagateMark() @@ -240,12 +253,16 @@ bool DMenu::CallMenuEvent(int mkey, bool fromcontroller) // //============================================================================= -DEFINE_ACTION_FUNCTION(DMenu, SetMouseCapture) +static void SetMouseCapture(bool on) { - PARAM_PROLOGUE; - PARAM_BOOL(on); if (on) I_SetMouseCapture(); else I_ReleaseMouseCapture(); +} +DEFINE_ACTION_FUNCTION_NATIVE(DMenu, SetMouseCapture, SetMouseCapture) +{ + PARAM_PROLOGUE; + PARAM_BOOL(on); + SetMouseCapture(on); return 0; } @@ -271,7 +288,13 @@ void DMenu::Close () } } -DEFINE_ACTION_FUNCTION(DMenu, Close) + +static void Close(DMenu *menu) +{ + menu->Close(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(DMenu, Close, Close) { PARAM_SELF_PROLOGUE(DMenu); self->Close(); diff --git a/src/p_sectors.cpp b/src/p_sectors.cpp index 968508dcc73..0f8285e93a1 100644 --- a/src/p_sectors.cpp +++ b/src/p_sectors.cpp @@ -1092,7 +1092,7 @@ double GetFriction(const sector_t *self, int plane, double *pMoveFac) } } - //=========================================================================== + //=========================================================================== // // //