mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Handle toolbar values
This commit is contained in:
parent
0de56740c0
commit
ac56702e33
@ -88,6 +88,7 @@ class GVAR(interface) {
|
||||
class controls {
|
||||
class nameTool: RscText {
|
||||
idc = IDC_TOOL_NAME;
|
||||
style = 2;
|
||||
x = 0;
|
||||
y = 0;
|
||||
w = TOOL_W * 2;
|
||||
|
@ -3,12 +3,12 @@
|
||||
ADDON = false;
|
||||
|
||||
PREP(handleCamera);
|
||||
PREP(handleClock);
|
||||
PREP(handleCompass);
|
||||
PREP(handleInterface);
|
||||
PREP(handleKilled);
|
||||
PREP(handleMouse);
|
||||
PREP(handleRespawn);
|
||||
PREP(handleToolbar);
|
||||
PREP(handleUnits);
|
||||
PREP(moduleSpectatorSettings);
|
||||
PREP(setSpectator);
|
||||
@ -17,10 +17,13 @@ PREP(updateInterface);
|
||||
PREP(updateUnits);
|
||||
|
||||
// Permanent variables
|
||||
GVAR(camFocus) = -1;
|
||||
GVAR(camMode) = 0;
|
||||
GVAR(camPan) = 0;
|
||||
GVAR(camPos) = [worldSize,worldSize,0];
|
||||
GVAR(camPos) = [worldSize * 0.5,worldSize * 0.5,0];
|
||||
GVAR(camSpeed) = 1;
|
||||
GVAR(camUnit) = objNull;
|
||||
GVAR(camZoom) = 1.3;
|
||||
|
||||
GVAR(showComp) = true;
|
||||
GVAR(showHelp) = true;
|
||||
|
@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Author: Karel Moricky, SilentSpike
|
||||
* Handles the spectator UI clock
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Parameters <ANY>
|
||||
* 1: PFH handle <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* None <NIL>
|
||||
*
|
||||
* Example:
|
||||
* [ace_spectator_fnc_handleClock, 1, _display] call CBA_fnc_addPerFrameHandler;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_display"];
|
||||
|
||||
// Kill PFH when display is closed
|
||||
if (isNull _display) exitWith { [_this select 1] call CBA_fnc_removePerFrameHandler; };
|
||||
|
||||
// Reduce overhead when toolbar is hidden
|
||||
if !(GVAR(showTool) && GVAR(showInterface)) exitWith {};
|
||||
|
||||
private "_clock";
|
||||
|
||||
_clock = (_display displayCtrl IDC_TOOL) controlsGroupCtrl IDC_TOOL_CLOCK;
|
||||
_clock ctrlSetText ([daytime,"HH:MM"] call BIS_fnc_timeToString);
|
@ -29,12 +29,8 @@ switch (toLower _mode) do {
|
||||
GVAR(camBank) = 0;
|
||||
GVAR(camBoom) = [false,false];
|
||||
GVAR(camDolly) = [false,false,false,false];
|
||||
GVAR(camFocus) = [-1,-1];
|
||||
GVAR(camFOV) = 0.7;
|
||||
GVAR(camPos) set [2,20];
|
||||
GVAR(camSpeed) = 1;
|
||||
GVAR(camTilt) = -10;
|
||||
GVAR(camZoom) = 3;
|
||||
GVAR(gunCam) = false;
|
||||
|
||||
// Initalize display variables
|
||||
@ -47,8 +43,6 @@ switch (toLower _mode) do {
|
||||
GVAR(camera) setDir GVAR(camPan);
|
||||
[] call FUNC(updateCamera);
|
||||
|
||||
GVAR(camera) camSetFOV GVAR(camFOV);
|
||||
|
||||
// Create the dialog
|
||||
createDialog QGVAR(interface);
|
||||
|
||||
@ -78,11 +72,7 @@ switch (toLower _mode) do {
|
||||
GVAR(camBank) = nil;
|
||||
GVAR(camBoom) = nil;
|
||||
GVAR(camDolly) = nil;
|
||||
GVAR(camFocus) = nil;
|
||||
GVAR(camFOV) = nil;
|
||||
GVAR(camSpeed) = nil;
|
||||
GVAR(camTilt) = nil;
|
||||
GVAR(camZoom) = nil;
|
||||
GVAR(gunCam) = nil;
|
||||
|
||||
// Cleanup display variables
|
||||
@ -110,20 +100,14 @@ switch (toLower _mode) do {
|
||||
GVAR(showMap) = false;
|
||||
[] call FUNC(updateInterface);
|
||||
|
||||
// Set text values
|
||||
(_display displayCtrl IDC_TOOL_FOCUS) ctrlSetText str(GVAR(camFocus));
|
||||
(_display displayCtrl IDC_TOOL_FOV) ctrlSetText str(GVAR(camFOV));
|
||||
(_display displayCtrl IDC_TOOL_SPEED) ctrlSetText format ["%1 m/s",GVAR(camSpeed)];
|
||||
(_display displayCtrl IDC_TOOL_VIEW) ctrlSetText (["FREE","FIRST","THIRD"] select GVAR(camMode));
|
||||
|
||||
// Keep unit tree up to date
|
||||
[FUNC(handleUnits), 21, _display] call CBA_fnc_addPerFrameHandler;
|
||||
|
||||
// Handle the compass heading
|
||||
[FUNC(handleCompass), 0, _display] call CBA_fnc_addPerFrameHandler;
|
||||
|
||||
// Handle the clock time
|
||||
[FUNC(handleClock), 1, _display] call CBA_fnc_addPerFrameHandler;
|
||||
// Handle the toolbar values
|
||||
[FUNC(handleToolbar), 0, _display] call CBA_fnc_addPerFrameHandler;
|
||||
|
||||
// Hacky way to enable keybindings
|
||||
//_display displayAddEventHandler ["KeyUp", {[_this,'keyup'] call CBA_events_fnc_keyHandler}];
|
||||
@ -156,11 +140,11 @@ switch (toLower _mode) do {
|
||||
case "onmousezchanged": {
|
||||
_args params ["_ctrl","_zChange"];
|
||||
|
||||
// Scroll to zoom in 3rd person, modifier for FOV
|
||||
// Scroll to change zoom, modifier for focus
|
||||
if (GVAR(ctrlKey)) then {
|
||||
GVAR(camFOV) = ((GVAR(camFOV) - (_zChange * GVAR(camFOV) * 0.2)) max 0.1) min 1;
|
||||
//GVAR(camFocus) set [0,(GVAR(camFocus) select 0) - (_zChange * (GVAR(camFocus) select 0) * 0.2)]
|
||||
} else {
|
||||
GVAR(camZoom) = (GVAR(camZoom) - (_zChange * GVAR(camZoom) * 0.2)) max 0.1;
|
||||
GVAR(camZoom) = ((GVAR(camZoom) + (_zChange * 0.1)) max 0.01) min 2;
|
||||
};
|
||||
};
|
||||
case "onmousemoving": {
|
||||
|
55
addons/spectator/functions/fnc_handleToolbar.sqf
Normal file
55
addons/spectator/functions/fnc_handleToolbar.sqf
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Author: Karel Moricky, SilentSpike
|
||||
* Handles the spectator UI toolbar values and applies them to the camera
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Parameters <ANY>
|
||||
* 1: PFH handle <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* None <NIL>
|
||||
*
|
||||
* Example:
|
||||
* [ace_spectator_fnc_handleToolbar, 0, _display] call CBA_fnc_addPerFrameHandler;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_display"];
|
||||
|
||||
// Kill PFH when display is closed
|
||||
if (isNull _display) exitWith { [_this select 1] call CBA_fnc_removePerFrameHandler; };
|
||||
|
||||
GVAR(camera) camSetFocus [GVAR(camFocus),1.5];
|
||||
GVAR(camera) camSetFov -(linearConversion [0.1,2,GVAR(camZoom),-2,-0.1,true]);
|
||||
GVAR(camera) camCommit 0;
|
||||
|
||||
// Reduce overhead when toolbar is hidden
|
||||
if !(GVAR(showTool) && GVAR(showInterface)) exitWith {};
|
||||
|
||||
private ["_name","_focus","_fov","_speed","_mode","_time","_toolbar"];
|
||||
|
||||
// Find all tool values
|
||||
if (GVAR(camMode) == 0) then {
|
||||
_name = "None";
|
||||
_speed = format ["%1 m/s", GVAR(camSpeed)];
|
||||
} else {
|
||||
_name = name GVAR(camUnit);
|
||||
_speed = format ["%1 km/h", floor(speed GVAR(camUnit))];
|
||||
};
|
||||
|
||||
_focus = format ["%1 m", GVAR(camFocus)];
|
||||
_fov = format ["%1x", floor(GVAR(camZoom) * 100) * 0.01];
|
||||
_mode = ["FREE","FIRST","THIRD"] select GVAR(camMode);
|
||||
_time = [daytime,"HH:MM"] call BIS_fnc_timeToString;
|
||||
|
||||
// Update the UI tools
|
||||
_toolbar = _display displayCtrl IDC_TOOL;
|
||||
(_toolbar controlsGroupCtrl IDC_TOOL_CLOCK) ctrlSetText _time;
|
||||
(_toolbar controlsGroupCtrl IDC_TOOL_FOCUS) ctrlSetText _focus;
|
||||
(_toolbar controlsGroupCtrl IDC_TOOL_FOV) ctrlSetText _fov;
|
||||
(_toolbar controlsGroupCtrl IDC_TOOL_NAME) ctrlSetText _name;
|
||||
(_toolbar controlsGroupCtrl IDC_TOOL_SPEED) ctrlSetText _speed;
|
||||
(_toolbar controlsGroupCtrl IDC_TOOL_VIEW) ctrlSetText _mode;
|
Loading…
Reference in New Issue
Block a user