mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
ace_settings: first draft
This commit is contained in:
parent
e5f02f8d63
commit
e277b05aff
@ -2,7 +2,6 @@
|
||||
class Extended_PreInit_EventHandlers {
|
||||
class ADDON {
|
||||
init = QUOTE(call COMPILE_FILE(XEH_preInit));
|
||||
serverInit = QUOTE(call COMPILE_FILE(scripts\readParameters));
|
||||
disableModuload = true;
|
||||
};
|
||||
};
|
||||
|
@ -85,6 +85,7 @@ PREP(isInBuilding);
|
||||
PREP(isPlayer);
|
||||
PREP(isTurnedOut);
|
||||
PREP(letterToCode);
|
||||
PREP(loadSettingsOnServer);
|
||||
PREP(map);
|
||||
PREP(moduleCheckPBOs);
|
||||
PREP(moduleLSDVehicles);
|
||||
@ -115,6 +116,8 @@ PREP(setName);
|
||||
PREP(setParameter);
|
||||
PREP(setPitchBankYaw);
|
||||
PREP(setVariableJIP);
|
||||
PREP(setSetting);
|
||||
PREP(setSettingFromConfig);
|
||||
PREP(stringToColoredText);
|
||||
PREP(subString);
|
||||
PREP(toBin);
|
||||
@ -163,6 +166,10 @@ PREP(hashListSet);
|
||||
PREP(hashListPush);
|
||||
|
||||
|
||||
// Load settings
|
||||
if (isServer) {}
|
||||
call FUNC(loadSettingsOnServer);
|
||||
};
|
||||
|
||||
ACE_player = player;
|
||||
|
||||
@ -183,7 +190,6 @@ if (hasInterface) then {
|
||||
}, 0, []] call cba_fnc_addPerFrameHandler;
|
||||
};
|
||||
|
||||
|
||||
PREP(stringCompare);
|
||||
PREP(string_removeWhiteSpace);
|
||||
PREP(isHC);
|
||||
|
@ -57,10 +57,16 @@ class ACE_canInteractConditions {
|
||||
};
|
||||
};
|
||||
|
||||
class ACE_Options {
|
||||
class ACE_Settings {
|
||||
class GVAR(forceAllSettings) {
|
||||
value = 0;
|
||||
typeName = "BOOL";
|
||||
};
|
||||
class GVAR(enableNumberHotkeys) {
|
||||
value = 1;
|
||||
typeName = "BOOL";
|
||||
isClientSetable = 1;
|
||||
displayName = "$STR_ACE_Common_EnableNumberHotkeys";
|
||||
default = 1;
|
||||
};
|
||||
};
|
||||
|
||||
|
74
addons/common/functions/fnc_loadSettingsOnServer.sqf
Normal file
74
addons/common/functions/fnc_loadSettingsOnServer.sqf
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Author: CAA-Picard
|
||||
* Load the parameters on the server.
|
||||
* Config < Server UserConfig < Mission Config
|
||||
*
|
||||
* Arguments:
|
||||
* None
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
GVAR(settingsList) = [];
|
||||
|
||||
// Load settings from main config
|
||||
_countOptions = count (configFile >> "ACE_Settings");
|
||||
for "_index" from 0 to (_countOptions - 1) do {
|
||||
_optionEntry = (configFile >> "ACE_Settings") select _index;
|
||||
|
||||
_name = configName _optionEntry;
|
||||
_valueEntry = _optionEntry >> "value";
|
||||
_typeEntry = _optionEntry >> "typeName";
|
||||
|
||||
[_name, _valueEntry, _typeEntry] call FUNC(setSettingFromConfig);
|
||||
};
|
||||
// Check if all settings should be forced
|
||||
if (GVAR(forceAllSettings)) then {
|
||||
{
|
||||
if !(missionNamespace getVariable format ["%1_forced", _x]) then {
|
||||
missionNamespace setVariable format ["%1_forced", _x, true];
|
||||
publicVariable format ["%1_forced", _name];
|
||||
};
|
||||
} forEach GVAR(settingsList);
|
||||
};
|
||||
|
||||
|
||||
// Load settings from server userconfig
|
||||
DFUNC(common,serverUserConfig) = compile preprocessFileLineNumbers "\userconfig\ACE\ACE_Settings.hpp";
|
||||
if !(isNil QFUNC(common,serverUserConfig)) then {
|
||||
[] call FUNC(serverUserConfig);
|
||||
};
|
||||
// Check if all settings should be forced
|
||||
if (GVAR(forceAllSettings)) then {
|
||||
{
|
||||
if !(missionNamespace getVariable format ["%1_forced", _x]) then {
|
||||
missionNamespace setVariable format ["%1_forced", _x, true];
|
||||
publicVariable format ["%1_forced", _name];
|
||||
};
|
||||
} forEach GVAR(settingsList);
|
||||
};
|
||||
|
||||
|
||||
// Load settings from mission config
|
||||
_countOptions = count (missionConfigFile >> "ACE_Settings");
|
||||
for "_index" from 0 to (_countOptions - 1) do {
|
||||
_optionEntry = (missionConfigFile >> "ACE_Settings") select _index;
|
||||
|
||||
_name = configName _optionEntry;
|
||||
_valueEntry = _optionEntry >> "value";
|
||||
|
||||
[_name, _valueEntry] call FUNC(setSettingFromConfig);
|
||||
};
|
||||
// Check if all settings should be forced
|
||||
if (GVAR(forceAllSettings)) then {
|
||||
{
|
||||
if !(missionNamespace getVariable format ["%1_forced", _x]) then {
|
||||
missionNamespace setVariable format ["%1_forced", _x, true];
|
||||
publicVariable format ["%1_forced", _name];
|
||||
};
|
||||
} forEach GVAR(settingsList);
|
||||
};
|
40
addons/common/functions/fnc_setSetting.sqf
Normal file
40
addons/common/functions/fnc_setSetting.sqf
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Author: CAA-Picard
|
||||
* Set a setting if it was not previosuly forced. Force if neccesary.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Setting name (String)
|
||||
* 1: Value (Any)
|
||||
* 2: Force it? (Bool) (Optional)
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
EXPLODE_2_PVT(_this,_name,_value);
|
||||
|
||||
if !(isServer) exitWith {};
|
||||
|
||||
private ["force"];
|
||||
_force = false;
|
||||
if (count _this > 2) then {
|
||||
_force = _this select 2;
|
||||
};
|
||||
|
||||
// Check if it's already forced and quit
|
||||
if (missionNamespace getVariable [format ["%1_forced", _name], false]) exitWith {};
|
||||
|
||||
// Check if the variable is already defined
|
||||
if (isNil _name) then {
|
||||
// Add the variable to a list on the server
|
||||
GVAR(settingsList) pushBack _name;
|
||||
};
|
||||
|
||||
// Update the variable and publish it
|
||||
missionNamespace setVariable [_name, _value];
|
||||
publicVariable _name;
|
||||
missionNamespace setVariable [format ["%1_forced", _name], _force];
|
||||
publicVariable format ["%1_forced", _name];
|
76
addons/common/functions/fnc_setSettingFromConfig.sqf
Normal file
76
addons/common/functions/fnc_setSettingFromConfig.sqf
Normal file
@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Author: CAA-Picard
|
||||
* Load a setting from config if it was not previosuly forced. Force if neccesary.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Setting name (String)
|
||||
* 1: Config entry (config entry)
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
EXPLODE_2_PVT(_this,_name,_optionEntry);
|
||||
|
||||
_fnc_getValueWithType = {
|
||||
EXPLODE_2_PVT(_this,_optionEntry,_typeName);
|
||||
|
||||
_value = getNumber (_optionEntry >> "value");
|
||||
if (_typeName == "BOOL") exitWith {
|
||||
_value = _value > 0;
|
||||
};
|
||||
if (_typeName == "STRING") exitWith {
|
||||
_value = getText (_optionEntry >> "value");
|
||||
};
|
||||
if (_typeName == "ARRAY") exitWith {
|
||||
_value = getArray (_optionEntry >> "value");
|
||||
};
|
||||
_value
|
||||
};
|
||||
|
||||
// Check if the variable is already defined
|
||||
if (isNil _name) exitWith {
|
||||
// That setting was not loaded yet
|
||||
|
||||
//diag_log text format ["[ACE]: Mission setting '%1' doesn't exist", _name];
|
||||
|
||||
_typeEntry = _this select 2;
|
||||
_typeName = getText _typeEntry;
|
||||
|
||||
_value = [_optionEntry, _typeName] call _fnc_getValueWithType;
|
||||
|
||||
// Init the variable and publish it
|
||||
missionNamespace setVariable [_name, _value];
|
||||
publicVariable _name;
|
||||
// Set the variable to not forced
|
||||
missionNamespace setVariable [format ["%1_forced", _name], false];
|
||||
publicVariable format ["%1_forced", _name];
|
||||
|
||||
// Add the variable to a list on the server
|
||||
GVAR(settingsList) pushBack _name;
|
||||
|
||||
} else {
|
||||
// The setting already exists.
|
||||
|
||||
// Check if it's already forced and quit
|
||||
if (missionNamespace getVariable format ["%1_forced", _name]) exitWith {};
|
||||
|
||||
// The setting is not forced, so update the value
|
||||
|
||||
// Get the type from the existing variable
|
||||
_typeName = typeName missionNamespace getVariable _name;
|
||||
_value = [_optionEntry, _typeName] call _fnc_getValueWithType;
|
||||
|
||||
// Update the variable and publish it
|
||||
missionNamespace setVariable [_name, _value];
|
||||
publicVariable _name;
|
||||
|
||||
// Check if it needs forcing
|
||||
if (getNumber (_optionEntry >> "force") > 0) then {
|
||||
missionNamespace setVariable [format ["%1_forced", _name], true];
|
||||
publicVariable format ["%1_forced", _name];
|
||||
};
|
||||
};
|
@ -1,55 +0,0 @@
|
||||
// by CAA-Picard
|
||||
#include "script_component.hpp"
|
||||
|
||||
// Read ACE_Parameters from config and set them on the mission namespace
|
||||
_config = configFile >> "ACE_Parameters_Numeric";
|
||||
_count = count _config;
|
||||
for "_index" from 0 to (_count - 1) do {
|
||||
_x = _config select _index;
|
||||
|
||||
_name = configName _x;
|
||||
_value = _x call bis_fnc_getcfgdata;
|
||||
[_name, _value] call FUNC(setParameter);
|
||||
};
|
||||
|
||||
_config = configFile >> "ACE_Parameters_Boolean";
|
||||
_count = count _config;
|
||||
for "_index" from 0 to (_count - 1) do {
|
||||
_x = _config select _index;
|
||||
|
||||
_name = configName _x;
|
||||
_value = _x call bis_fnc_getcfgdata;
|
||||
[_name, _value > 0] call FUNC(setParameter);
|
||||
};
|
||||
|
||||
|
||||
// Read ACE_Parameters from mission and set them on the mission namespace, replacing defaults if necesary
|
||||
_config = missionConfigFile >> "ACE_Parameters";
|
||||
_count = count _config;
|
||||
for "_index" from 0 to (_count - 1) do {
|
||||
_x = _config select _index;
|
||||
|
||||
_name = configName _x;
|
||||
_value = _x call bis_fnc_getcfgdata;
|
||||
[_name, _value] call FUNC(setParameter);
|
||||
};
|
||||
|
||||
_config = missionConfigFile >> "ACE_Parameters_Numeric";
|
||||
_count = count _config;
|
||||
for "_index" from 0 to (_count - 1) do {
|
||||
_x = _config select _index;
|
||||
|
||||
_name = configName _x;
|
||||
_value = _x call bis_fnc_getcfgdata;
|
||||
[_name, _value] call FUNC(setParameter);
|
||||
};
|
||||
|
||||
_config = missionConfigFile >> "ACE_Parameters_Boolean";
|
||||
_count = count _config;
|
||||
for "_index" from 0 to (_count - 1) do {
|
||||
_x = _config select _index;
|
||||
|
||||
_name = configName _x;
|
||||
_value = _x call bis_fnc_getcfgdata;
|
||||
[_name, _value > 0] call FUNC(setParameter);
|
||||
};
|
@ -15,29 +15,47 @@ class CfgPatches {
|
||||
#include "CfgEventHandlers.hpp"
|
||||
#include "CfgVehicles.hpp"
|
||||
|
||||
class ACE_Options {
|
||||
class ACE_Settings {
|
||||
class GVAR(showPlayerNames) {
|
||||
value = 1;
|
||||
typeName = "SCALAR";
|
||||
isClientSetable = 1;
|
||||
displayName = "$STR_ACE_NameTags_ShowPlayerNames";
|
||||
values[] = {"Disabled", "Enabled", "Only Cursor", "Only On Keypress", "Only Cursor and KeyPress"};
|
||||
default = 1;
|
||||
};
|
||||
class GVAR(showPlayerRanks) {
|
||||
value = 1;
|
||||
typeName = "BOOL";
|
||||
isClientSetable = 1;
|
||||
displayName = "$STR_ACE_NameTags_ShowPlayerRanks";
|
||||
default = 1;
|
||||
};
|
||||
class GVAR(showVehicleCrewInfo) {
|
||||
value = 1;
|
||||
typeName = "BOOL";
|
||||
isClientSetable = 1;
|
||||
displayName = "$STR_ACE_CrewInfo_ShowVehicleCrewInfo";
|
||||
default = 1;
|
||||
};
|
||||
};
|
||||
|
||||
class ACE_Parameters_Numeric {
|
||||
GVAR(PlayerNamesViewDistance) = 5;
|
||||
GVAR(PlayerNamesMaxAlpha) = 0.8;
|
||||
GVAR(CrewInfoVisibility) = 0;
|
||||
};
|
||||
class ACE_Parameters_Boolean {
|
||||
GVAR(ShowNamesForAI) = 0;
|
||||
class GVAR(PlayerNamesViewDistance) {
|
||||
value = 5;
|
||||
typeName = "SCALAR";
|
||||
isClientSetable = 0;
|
||||
};
|
||||
class GVAR(PlayerNamesMaxAlpha) {
|
||||
value = 0.8;
|
||||
typeName = "SCALAR";
|
||||
isClientSetable = 0;
|
||||
};
|
||||
class GVAR(CrewInfoVisibility) {
|
||||
value = 0;
|
||||
typeName = "BOOL";
|
||||
isClientSetable = 0;
|
||||
};
|
||||
class GVAR(ShowNamesForAI) {
|
||||
value = 0;
|
||||
typeName = "BOOL";
|
||||
isClientSetable = 0;
|
||||
};
|
||||
};
|
||||
|
||||
#include <RscTitles.hpp>
|
||||
|
Loading…
Reference in New Issue
Block a user