First working version

This commit is contained in:
SAM 2015-05-08 14:14:15 +02:00
parent 2c8dddfc47
commit 6b604c101c
8 changed files with 123 additions and 13 deletions

View File

@ -1,9 +1,24 @@
class ACE_Settings {
class GVAR(viewdistance) {
class GVAR(changeAllowed) {
typeName = "BOOL";
value = 1;
displayName = "Allow View Distance Changing";
description = "Enables changing in game view distance";
};
class GVAR(top_limit) {
typeName = "SCALAR";
values[] = {0,1,2,3,4,5,6,7,8,9,10,11}; // correspond to the index values
displayName = "View Distance Limit";
description = "Sets the top limit for all clients";
};
class GVAR(newViewDistance) {
typeName = "SCALAR";
isClientSettable = 1;
values[] = {1500,2000,2500,3000,3500,4000,5000,6000,7000,8000,9000,10000};
displayName = "View Distance"; // has to be changed to string table type
description = "Change View Distance";
//value = 1;
values[] = {"1500","2000","2500","3000","3500","4000","5000","6000","7000","8000","9000","10000"};
displayName = "Change View Distance";
description = "Changes in game view distance";
};
};
// To do: include string table style displayName & description.

View File

@ -4,3 +4,9 @@ class Extended_PreInit_EventHandlers {
init = QUOTE(call COMPILE_FILE(XEH_preInit));
};
};
class Extended_PostInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_postInit));
};
};

View File

@ -0,0 +1,4 @@
#include "script_component.hpp"
if (!hasInterface || !GVAR(enabled)) exitWith {};
[] call FUNC(initViewDistance);

View File

@ -2,6 +2,8 @@
ADDON = false;
PREP(empty);
PREP(returnViewDistanceValue);
PREP(changeViewDistance);
PREP(initViewDistance);
ADDON = true;

View File

@ -4,21 +4,38 @@
*
*
* Arguments:
* 0: View Distance Setting (SCALAR)
* None
*
* Return Value:
* None
*
* Example:
* [1500] call ace_common_fnc_imanexample
* [] call ace_viewdistance_fnc_changeViewDistance;
*
* Public: No
*/
#include "script_component.hpp"
private ["_new_view_distance"];
private ["_new_view_distance_index","_new_view_distance"];
_new_view_distance = _this select 0;
_new_view_distance_index = GVAR(newViewDistance);
player setViewDistance (_new_view_distance);
_new_view_distance = [_new_view_distance_index] call FUNC(returnViewDistanceValue);
/*
hint format ["DEBUG: Player: %1 new view distance index: %2 new view distance value: %3",(name player),_new_view_distance_index,_new_view_distance];
diag_log format ["DEBUG: Player: %1 new view distance index: %2 new view distance value: %3",(name player),_new_view_distance_index,_new_view_distance];
*/
// To do: add a check against a sever or module top limit here.
if !GVAR(changeAllowed) then
{
hint "You cannot change the view distance!"
}
else
{
setViewDistance _new_view_distance;
};

View File

@ -0,0 +1,24 @@
/*
* Author: Winter
* Sets the player's current view distance according to allowed values.
*
*
* Arguments:
* 0: View Distance Setting (SCALAR)
*
* Return Value:
* None
*
* Example:
* [1500] call ace_common_fnc_imanexample
*
* Public: No
*/
#include "script_component.hpp"
["SettingChanged",{
if (_this select 0 == QGVAR(newViewDistance)) then {
[] call FUNC(changeViewDistance);
};
},true] call ace_common_fnc_addEventHandler;

View File

@ -0,0 +1,42 @@
/*
* Author: Winter
* Returns the view distance value according to the given index
*
*
* Arguments:
* 0: View Distance Index (SCALAR)
*
* Return Value:
* View Distance (SCALAR)
*
* Example:
* [2] call ace_viewdistance_fnc_returnViewDistanceValue;
*
* Public: Yes
*/
#include "script_component.hpp"
private ["_index","_return"];
_index = _this select 0;
_return = 0;
switch (_index) do
{
case 0: {_return = 1500};
case 1: {_return = 2000};
case 2: {_return = 2500};
case 3: {_return = 3000};
case 4: {_return = 3500};
case 5: {_return = 4000};
case 6: {_return = 5000};
case 7: {_return = 6000};
case 8: {_return = 7000};
case 9: {_return = 8000};
case 10: {_return = 9000};
case 11: {_return = 10000};
default {hint "something broke!";};
};
_return;