From c6b5c705c721adac9756b4f209b88029196a25a2 Mon Sep 17 00:00:00 2001 From: jonpas Date: Mon, 8 Jun 2015 23:25:15 +0200 Subject: [PATCH] Added Sitting Settings and Module --- addons/sitting/ACE_Settings.hpp | 7 +++ addons/sitting/CfgVehicles.hpp | 55 ++++++++++++++------- addons/sitting/XEH_preInit.sqf | 1 + addons/sitting/config.cpp | 3 +- addons/sitting/functions/fnc_canSit.sqf | 4 +- addons/sitting/functions/fnc_moduleInit.sqf | 23 +++++++++ addons/sitting/stringtable.xml | 9 ++++ 7 files changed, 82 insertions(+), 20 deletions(-) create mode 100644 addons/sitting/ACE_Settings.hpp create mode 100644 addons/sitting/functions/fnc_moduleInit.sqf diff --git a/addons/sitting/ACE_Settings.hpp b/addons/sitting/ACE_Settings.hpp new file mode 100644 index 0000000000..d4ebb61e83 --- /dev/null +++ b/addons/sitting/ACE_Settings.hpp @@ -0,0 +1,7 @@ +class ACE_Settings { + class GVAR(enable) { + value = 1; + typeName = "BOOL"; + displayName = CSTRING(Enable); + }; +}; diff --git a/addons/sitting/CfgVehicles.hpp b/addons/sitting/CfgVehicles.hpp index c81fbbdef1..319fc6b918 100644 --- a/addons/sitting/CfgVehicles.hpp +++ b/addons/sitting/CfgVehicles.hpp @@ -1,22 +1,25 @@ -#define MACRO_SEAT_ACTION \ - class ACE_Actions { \ - class ACE_MainActions { \ - displayName = ECSTRING(interaction,MainAction); \ - selection = ""; \ - distance = 1.25; \ - condition = "true"; \ - class GVAR(Sit) { \ - displayName = CSTRING(Sit); \ - condition = QUOTE(_this call FUNC(canSit)); \ - statement = QUOTE(_this call FUNC(sit)); \ - showDisabled = 0; \ - priority = 0; \ - icon = PATHTOF(UI\sit_ca.paa); \ - }; \ - }; \ +class CfgVehicles { + class ACE_Module; + class ACE_ModuleSitting: ACE_Module { + author = ECSTRING(common,ACETeam); + category = "ACE"; + displayName = CSTRING(ModuleDisplayName); + function = QFUNC(moduleInit); + scope = 2; + isGlobal = 1; + //icon = QUOTE(PATHTOF(UI\Icon_Module_Sitting_ca.paa)); + class Arguments { + class enable { + displayName = CSTRING(Enable); + typeName = "BOOL"; + defaultValue = 1; + }; + }; + class ModuleDescription { + description = CSTRING(ModuleDescription); + }; }; -class CfgVehicles { class Man; class CAManBase: Man { class ACE_SelfActions { @@ -31,6 +34,24 @@ class CfgVehicles { }; }; + #define MACRO_SEAT_ACTION \ + class ACE_Actions { \ + class ACE_MainActions { \ + displayName = ECSTRING(interaction,MainAction); \ + selection = ""; \ + distance = 1.25; \ + condition = "true"; \ + class GVAR(Sit) { \ + displayName = CSTRING(Sit); \ + condition = QUOTE(_this call FUNC(canSit)); \ + statement = QUOTE(_this call FUNC(sit)); \ + showDisabled = 0; \ + priority = 0; \ + icon = PATHTOF(UI\sit_ca.paa); \ + }; \ + }; \ + }; + class ThingX; // Folding Chair class Land_CampingChair_V1_F: ThingX { diff --git a/addons/sitting/XEH_preInit.sqf b/addons/sitting/XEH_preInit.sqf index 1c8e8ce8ad..ced588299a 100644 --- a/addons/sitting/XEH_preInit.sqf +++ b/addons/sitting/XEH_preInit.sqf @@ -5,6 +5,7 @@ ADDON = false; PREP(canSit); PREP(canStand); PREP(getRandomAnimation); +PREP(moduleInit); PREP(sit); PREP(stand); diff --git a/addons/sitting/config.cpp b/addons/sitting/config.cpp index 9412666aaf..f12fa530fa 100644 --- a/addons/sitting/config.cpp +++ b/addons/sitting/config.cpp @@ -5,7 +5,7 @@ class CfgPatches { units[] = {}; weapons[] = {}; requiredVersion = REQUIRED_VERSION; - requiredAddons[] = {"ace_common"}; + requiredAddons[] = {"ace_interaction"}; author[] = {"Jonpas"}; authorUrl = "https://github.com/jonpas"; VERSION_CONFIG; @@ -13,4 +13,5 @@ class CfgPatches { }; #include "CfgEventHandlers.hpp" +#include "ACE_Settings.hpp" #include "CfgVehicles.hpp" diff --git a/addons/sitting/functions/fnc_canSit.sqf b/addons/sitting/functions/fnc_canSit.sqf index 3e270c9f1a..c9762e265c 100644 --- a/addons/sitting/functions/fnc_canSit.sqf +++ b/addons/sitting/functions/fnc_canSit.sqf @@ -18,5 +18,5 @@ PARAMS_2(_seat,_player); -// If seat object and not occupied -(getNumber (configFile >> "CfgVehicles" >> typeOf _seat >> QGVAR(canSit)) == 1 && {isNil{_seat getVariable QGVAR(seatOccupied)}}) +// Sitting enabled, is seat object and not occupied +(GVAR(enable) && {getNumber (configFile >> "CfgVehicles" >> typeOf _seat >> QGVAR(canSit)) == 1} && {isNil{_seat getVariable QGVAR(seatOccupied)}}) diff --git a/addons/sitting/functions/fnc_moduleInit.sqf b/addons/sitting/functions/fnc_moduleInit.sqf new file mode 100644 index 0000000000..4dbe2c5f0a --- /dev/null +++ b/addons/sitting/functions/fnc_moduleInit.sqf @@ -0,0 +1,23 @@ +/* + * Author: Jonpas + * Initializes the Sitting module. + * + * Arguments: + * Whatever the module provides. + * + * Return Value: + * None + */ +#include "script_component.hpp" + +if !(isServer) exitWith {}; + +PARAMS_3(_logic,_units,_activated); + +if !(_activated) exitWith {}; + +GVAR(Module) = true; + +[_logic, QGVAR(enable), "enable"] call EFUNC(common,readSettingFromModule); + +diag_log text "[ACE]: Sitting Module Initialized."; diff --git a/addons/sitting/stringtable.xml b/addons/sitting/stringtable.xml index cfe3a64f41..16eb84c59f 100644 --- a/addons/sitting/stringtable.xml +++ b/addons/sitting/stringtable.xml @@ -9,5 +9,14 @@ Stand Up WstaƄ + + Enable Sitting + + + Sitting + + + This module allows you to disable the ability to sit on chairs and toilets. + \ No newline at end of file