Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert all suitable settings to CBA Settings #36

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion addons/api/CfgFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class CfgFunctions {
};

class Radios {
DEFINE_FUNCTION(getAllRadios);
DEFINE_FUNCTION(getCurrentRadio);
DEFINE_FUNCTION(setCurrentRadio);
DEFINE_FUNCTION(getCurrentRadioList);
Expand Down Expand Up @@ -96,7 +97,6 @@ class CfgFunctions {
class AcreModules {
class GVAR(mission_setup) {
class basicMissionSetup { file = PATHTOF(modules\basicMissionSetup.sqf); };
class disableSignalLoss { file = PATHTOF(modules\disableSignalLoss.sqf); };
class difficultySettings { file = PATHTOF(modules\difficultySettings.sqf); };
class nameChannels { file = PATHTOF(modules\nameChannels.sqf); };
};
Expand Down
44 changes: 22 additions & 22 deletions addons/api/CfgModules.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ class CfgVehicles
{
class Logic;
class Module_F: Logic { class ArgumentsBaseUnits { class Units; }; class ModuleDescription { class AnyBrain; }; };

class GVAR(basicMissionSetup) : Module_F {
scope = 2;
scope = 1;
Copy link
Member

@Sniperhid Sniperhid Sep 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would disagree with hiding the modules for now. As they are pretty intuitive for most mission makers

displayName = "Basic Mission Setup";
author = "ACRE Team";
category = QGVAR(mission_setup);
Expand All @@ -28,14 +28,14 @@ class CfgVehicles
class Arguments {
class RadioSetup {
displayName = "Channels Per Side";
description = "Set to true to have each side have different ACRE radio frequencies";
typeName = "BOOL";
description = "Set to true to have each side have different ACRE radio frequencies";
typeName = "BOOL";
class values { };
};
class BabelSetup {
displayName = "Babel Language Per Side";
description = "Select whether each side has its own language, and whether they also share a common tongue.";
typeName = "NUMBER";
description = "Select whether each side has its own language, and whether they also share a common tongue.";
typeName = "NUMBER";
class values {
class AllDifferent {name = "Per-Side"; value = 1; };
class SharingDifferent {name = "Per-Side /w Common"; value = 2; default = 2; };
Expand Down Expand Up @@ -69,9 +69,9 @@ class CfgVehicles
sync[] = {};
};
};

class GVAR(DifficultySettings) : Module_F {
scope = 2;
scope = 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing again with hiding the module

displayName = "Difficulty Settings";
category = QGVAR(mission_setup);

Expand All @@ -87,29 +87,29 @@ class CfgVehicles
class Arguments {
class SignalLoss {
displayName = "Signal Loss";
description = "Set to false to disable signal and terrain loss values";
typeName = "BOOL";
description = "Set to false to disable signal and terrain loss values";
typeName = "BOOL";
defaultValue = true;
class values { };
};
class FullDuplex {
displayName = "Full-Duplex Transmissions";
description = "Set to true to enable full-duplex, or multiple people transmitting";
typeName = "BOOL";
description = "Set to true to enable full-duplex, or multiple people transmitting";
typeName = "BOOL";
defaultValue = false;
class values { };
};
class Interference {
displayName = "Signal Interference";
description = "Set to false to disable the interference from multiple transmitters";
typeName = "BOOL";
description = "Set to false to disable the interference from multiple transmitters";
typeName = "BOOL";
defaultValue = true;
class values { };
};
class IgnoreAntennaDirection {
displayName = "Ignore Antenna Direction";
description = "Set to true to disable loss due to antenna directional radiation patterns.";
typeName = "BOOL";
description = "Set to true to disable loss due to antenna directional radiation patterns.";
typeName = "BOOL";
defaultValue = false;
class values { };
};
Expand All @@ -120,7 +120,7 @@ class CfgVehicles
sync[] = {};
};
};

class GVAR(nameChannels) : Module_F {
scope = 2;
displayName = "Name Channels";
Expand All @@ -137,11 +137,11 @@ class CfgVehicles

// Module arguments
class Arguments {

class SideSelect {
displayName = "Side";
description = "Select the side to name channels for";
typeName = "NUMBER";
description = "Select the side to name channels for";
typeName = "NUMBER";
class values
{
class All {name = "All"; value = 1; default = 1;};
Expand All @@ -151,7 +151,7 @@ class CfgVehicles
class Civ {name = "Civilian"; value = 5;};
};
};

class Channel_1 {
displayName = "Channel 1";
description = "Name of Channel 1";
Expand Down Expand Up @@ -209,4 +209,4 @@ class CfgVehicles
sync[] = {};
};
};
};
};
8 changes: 5 additions & 3 deletions addons/api/XEH_pre_init.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ ADDON = false;
DGVAR(selectableCurveScale) = 1.0;
DVAR(ACRE_IS_SPECTATOR) = false;

// Private helper functions
PREP(setupDefaultRadios);
PREP(setupFrequenciesAndBabel);

// Field name mapping for unifying radio field names
PREP(mapChannelFieldName);


// DEPRICATED /////
PREP(setDefaultChannels); // DEPRICATING
PREP(getDefaultChannels); // DEPRICATING

// module loading variables
GVAR(basicMissionSetup) = false;
#include "initSettings.sqf"

ADDON = true;
39 changes: 39 additions & 0 deletions addons/api/fnc_getAllRadios.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Author: ACRE2Team
* Returns all radios defined in CfgAcreRadios.
*
* Arguments:
* None
*
* Return Value:
* 1: Radio Class Names <ARRAY>
* 2: Radio Display Names <ARRAY>
*
* Example:
* [] call acre_api_fnc_getAllRadios;
*
* Public: Yes
*/
#include "script_component.hpp"

// Return cached if already ran
if (!isNil QGVAR(allRadios)) exitWith {
GVAR(allRadios)
};

// Compile and cache for later calls
private _classes = [];
private _names = [];
{
private _isAcre = getNumber (_x >> "isAcre"); // All radio classes have that
private _name = getText (_x >> "name"); // Only non-base classes have that

// Has name and isAcre, assume valid radio class
if (_isAcre == 1 && {_name != ""}) then {
_classes pushBack (configName _x);
_names pushBack _name;
};
} forEach ("true" configClasses (configFile >> "CfgAcreComponents"));

GVAR(allRadios) = [_classes, _names];
GVAR(allRadios)
82 changes: 82 additions & 0 deletions addons/api/fnc_setupDefaultRadios.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* Author: ACRE2Team
* Sets up side frequencies and babel settings from settings menu. Can be ran only once per mission.
*
* Arguments:
* 1: Radio Order <NUMBER>
* 0: Radio Class Name <STRING>
*
* Return Value:
* None
*
* Example:
* [0, "ACRE_PRC343"] call acre_api_fnc_setupDefaultRadios;
*
* Public: No
*/
#include "script_component.hpp"

// Exit on dedicated server or headless client
if (!hasInterface) exitWith {};

// Run once after all 4 defaults have been initialized
if (!isNil QGVAR(hasSetupDefaultRadios) && {GVAR(hasSetupDefaultRadios)}) exitWith {};

params ["_order", "_radioClass"];

// Wait for all 4 defaults to be initialized
if (isNil QGVAR(defaultRadios)) then {
GVAR(defaultRadios) = [];
};
GVAR(defaultRadios) set [_order, _radioClass];
if (count (GVAR(defaultRadios) select {_x isEqualType ""}) < 4) exitWith {};

// Apply default radios
private _addRadios = {
// Don't regive radios if already given
if (acre_player getVariable [QGVAR(hasGivenDefaultRadios), false]) exitWith {};
acre_player setVariable [QGVAR(hasGivenDefaultRadios), true, true];

private _cleanRadioList = [];
if !("ACRE_PRC343" in _this) then {
[acre_player, "ItemRadio"] call EFUNC(lib,removeGear);
[acre_player, "ACRE_PRC343"] call EFUNC(lib,removeGear);
_cleanRadioList = _this;
} else {
private _countDefaultRadios = 0;
{
if (_x == "ACRE_PRC343") then {
_countDefaultRadios = _countDefaultRadios + 1;
if (_countDefaultRadios > 1) then {
_cleanRadioList pushBack _x;
};
} else {
_cleanRadioList pushBack _x;
};
} forEach _this;
};

TRACE_1("Adding Radios",_cleanRadioList);

if (!((["ACRE_PRC77", "ACRE_PRC117F"] arrayIntersect _cleanRadioList) isEqualTo []) && {backpack acre_player == ""}) then {
acre_player addBackpack "B_AssaultPack_khk";
};

{
if (_x != "") then {
acre_player addItem _x;
};
} forEach _cleanRadioList;
};

if (isNull acre_player) then {
GVAR(defaultRadios) spawn {
waitUntil {!isNull acre_player};
_this call _addRadios;
};
} else {
GVAR(defaultRadios) call _addRadios;
};


GVAR(hasSetupDefaultRadios) = true;
49 changes: 49 additions & 0 deletions addons/api/fnc_setupFrequenciesAndBabel.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Author: ACRE2Team
* Sets up side frequencies and babel settings from settings menu. Can be ran only once per mission.
*
* Arguments:
* 0: Unique Side Frequencies <BOOL>
* 1: Babel <NUMBER>
*
* Return Value:
* None
*
* Example:
* [false, 0] call acre_api_fnc_setupFrequenciesAndBabel;
*
* Public: No
*/
#include "script_component.hpp"

// Run once
if (!isNil QGVAR(hasSetupFrequenciesAndBabel) && {GVAR(hasSetupFrequenciesAndBabel)}) exitWith {};

params ["_uniqueFrequencies", "_babel"];

// Unique frequencies are handled in FUNC(setupMission), no need to handle it here

// No babel
if (_babel == 0) exitWith {
[false, _uniqueFrequencies] call FUNC(setupMission);
};

// One language per side babel
if (_babel == 1) exitWith {
[true, _uniqueFrequencies] call FUNC(setupMission);
};

// One language per side + common babel (Zeus gets ALL Languages, including "Common")
// Handle the babel setup via an array, so the bool is set to false
if (_babel == 2) exitWith {
[false, _uniqueFrequencies] call FUNC(setupMission);
[
[east, "Opfor", "Common"],
[west, "Blufor", "Common"],
[independent, "Indepedent", "Common"],
[civilian, "Civilian", "Common"],
[sideLogic, "Opfor", "Blufor", "Indepedent", "Civilian", "Common"]
] call FUNC(babelSetupMission);
};

GVAR(hasSetupFrequenciesAndBabel) = true;
Loading