diff --git a/addons/music/CfgFunctions.hpp b/addons/music/CfgFunctions.hpp index c73bce6..5db76fe 100644 --- a/addons/music/CfgFunctions.hpp +++ b/addons/music/CfgFunctions.hpp @@ -15,10 +15,21 @@ class CfgFunctions class initial_playlists { preInit = 1; }; class fromConfig {}; - class getName {}; + class getPlaylistName {}; + class getMusicName {}; class addonLoaded {}; }; + class diary + { + file = PATH_TO_FUNC_SUB(diary); + + class createDiary { postInit = 1; }; + class updateHistory {}; + + class fade_local {}; + }; + class internal { file = PATH_TO_FUNC_SUB(internal); @@ -28,7 +39,6 @@ class CfgFunctions class init_musicEventHandlers { preInit = 1; }; class init_cbaEvents { preInit = 1; }; - class startMonitor {}; class createAction {}; class publicArray {}; @@ -38,8 +48,6 @@ class CfgFunctions class verify {}; class queue {}; class play {}; - - }; class remote diff --git a/addons/music/functions/config/fn_getMusicName.sqf b/addons/music/functions/config/fn_getMusicName.sqf new file mode 100644 index 0000000..765ab99 --- /dev/null +++ b/addons/music/functions/config/fn_getMusicName.sqf @@ -0,0 +1,34 @@ +#include "../../script_component.hpp" + +/* +* Author: Zorn +* function to retrieve the Name of a playlist, ether configFile or missionConfigFile. If +* +* Arguments: +* +* Return Value: +* None +* +* Example: +* ['something', player] call prefix_component_fnc_functionname +* +* Public: No +*/ + +params [ + ["_className", "", [""] ] +]; + +private _hasMissionConfig = isClass ( missionConfigFile >> "CfgMusic" >> _className); +private _hasConfig = isClass ( configFile >> "CfgMusic" >> _className); + +private _cfgPath = switch (true) do { + case (_hasMissionConfig): { missionConfigFile >> "CfgMusic" >> _className }; + case (_hasConfig): { configFile >> "CfgMusic" >> _className }; +}; + +private _title = getText ( _cfgPath >> "name"); + +if (_title == "") then {_title = _className}; + +_title \ No newline at end of file diff --git a/addons/music/functions/config/fn_getName.sqf b/addons/music/functions/config/fn_getPlaylistName.sqf similarity index 100% rename from addons/music/functions/config/fn_getName.sqf rename to addons/music/functions/config/fn_getPlaylistName.sqf diff --git a/addons/music/functions/diary/fn_createDiary.sqf b/addons/music/functions/diary/fn_createDiary.sqf new file mode 100644 index 0000000..71ebfcb --- /dev/null +++ b/addons/music/functions/diary/fn_createDiary.sqf @@ -0,0 +1,35 @@ +#include "../../script_component.hpp" + +/* +* Author: Zorn +* This function creates the Diary Entry. +* +* Arguments: +* +* Return Value: +* None +* +* Example: +* ['something', player] call prefix_component_fnc_functionname +* +* Public: No +*/ + +if !(hasInterface) exitWith {}; + + +// Create Music Subject +GVAR(subject) = player createDiarySubject [QGVAR(diary_subject), LLSTRING(diary_subject_title)]; + +// Create Initial Music History Entry +["INIT"] call CVO_MUSIC_fnc_updateHistory; + + +// Create Controls Entry +player createDiaryRecord [ + QGVAR(diary_subject), + [ + LLSTRING(diary_record_MusicControls_Title), + format ["%2", QFUNC(fade_local), LLSTRING(diary_record_MusicControls_fadeButton)] + ] +]; \ No newline at end of file diff --git a/addons/music/functions/diary/fn_fade_local.sqf b/addons/music/functions/diary/fn_fade_local.sqf new file mode 100644 index 0000000..685570f --- /dev/null +++ b/addons/music/functions/diary/fn_fade_local.sqf @@ -0,0 +1,27 @@ +#include "../../script_component.hpp" + +/* +* Author: Zorn +* Function to execute the Request for a local Fading down of the Music to 0. +* +* Arguments: +* +* Return Value: +* None +* +* Example: +* ['something', player] call prefix_component_fnc_functionname +* +* Public: No +*/ + +private _time = 10; + +if (GETMGVAR(isFading,false)) exitWith { + systemChat LLSTRING(diary_fading_already); +}; + +[_time] call FUNC(fade_client); + +systemChat LLSTRING(diary_fading); +[ { systemChat LLSTRING(diary_faded) } , [], _time] call CBA_fnc_waitAndExecute; \ No newline at end of file diff --git a/addons/music/functions/diary/fn_updateHistory.sqf b/addons/music/functions/diary/fn_updateHistory.sqf new file mode 100644 index 0000000..c7e63c4 --- /dev/null +++ b/addons/music/functions/diary/fn_updateHistory.sqf @@ -0,0 +1,69 @@ +#include "../../script_component.hpp" + +/* +* Author: Zorn +* Function to create and update the Music History Diary Entry +* +* Arguments: +* +* Return Value: +* None +* +* Example: +* ['something', player] call prefix_component_fnc_functionname +* +* Public: No +*/ + +params [ + ["_class", "", [""] ] +]; + +if (_class == "") exitWith {}; + +private _record = GETMGVAR(record_musicHistory,"404"); +private _title = LLSTRING(diary_record_MusicHistory_Title); + +ZRN_LOG_1(_title); + +if (_record isEqualTo "404") then { + ZRN_LOG_1(_record); + // Create The Diary Entry + _record = player createDiaryRecord [ + QGVAR(diary_subject), [ _title, "yaaay" ] + ]; + SETMGVAR(record_musicHistory,_record); + + GVAR(history_array) = []; +}; + +private _history = GETMGVAR(history_array,[]); + +private _time = systemTime apply {if (_x < 10) then {"0" + str _x} else {str _x}}; // ["2021","05","03","14","09","37","593"] +private _timeStr = format ["%1:%2", _time#3, _time#4]; + +if (_class != "INIT") then { + _history pushBack [_timeStr, _class, [_class] call FUNC(getMusicName)]; +}; + + + +private _array = [ format ["%1", LLSTRING(diary_record_MusicHistory_Header)] ]; + +private _longestIndex = count str count _history; + +{ + // Index + private _index = _forEachIndex + 1; + private _maxChars = _longestIndex; + private _str = str _index; + private _numStr = count _str; + if (_numStr < _maxChars) then { for "_i" from 1 to (_maxChars - _numStr) do { _str = _str insert [0, " "]; }; }; + _index = _str; + + private _string = format ["%1. %2 - %3", _index, _x#0, _x#2]; + + _array pushBack _string; +} forEach _history; + +player setDiaryRecordText [[QGVAR(diary_subject), _record], [_title, _array joinString "
"]]; \ No newline at end of file diff --git a/addons/music/functions/internal/fn_catalog.sqf b/addons/music/functions/internal/fn_catalog.sqf index fa5b0ea..83698a0 100644 --- a/addons/music/functions/internal/fn_catalog.sqf +++ b/addons/music/functions/internal/fn_catalog.sqf @@ -23,7 +23,6 @@ params [ ["_args", [], [] ] ]; -ZRN_LOG_MSG_1(INIT,_selectMode); private _updateArray = false; private _cat = missionNamespace getVariable [QGVAR(HM_playlists), "404"]; diff --git a/addons/music/functions/internal/fn_createAction.sqf b/addons/music/functions/internal/fn_createAction.sqf index ffc35f8..ca64711 100644 --- a/addons/music/functions/internal/fn_createAction.sqf +++ b/addons/music/functions/internal/fn_createAction.sqf @@ -57,7 +57,7 @@ private _insertChildren = { { private _playlistAction = [ QGVAR(_x) // * 0: Action name - ,[_x] call FUNC(getName) // * 1: Name of the action shown in the menu + ,[_x] call FUNC(getPlaylistName) // * 1: Name of the action shown in the menu ,"" // * 2: Icon "\A3\ui_f\data\igui\cfg\simpleTasks\types\backpack_ca.paa" ,_code // * 3: Statement ,{true} // * 4: Condition diff --git a/addons/music/functions/internal/fn_init_musicEventHandlers.sqf b/addons/music/functions/internal/fn_init_musicEventHandlers.sqf index 5d22966..0dd3521 100644 --- a/addons/music/functions/internal/fn_init_musicEventHandlers.sqf +++ b/addons/music/functions/internal/fn_init_musicEventHandlers.sqf @@ -24,7 +24,7 @@ addMusicEventHandler ["MusicStart", { private _completedAt = CBA_MissionTime + _totalLength - linearConversion [0,1,_currentPosition,0,_totalLength,true]; [QGVAR(EH_update_server), [getPlayerID player, _completedAt]] call CBA_fnc_serverEvent; - systemChat format ["MusicStart: %1", _musicClassname]; + [_musicClassname] call FUNC(updateHistory); }]; @@ -34,6 +34,4 @@ addMusicEventHandler ["MusicStop", { private _completedAt = -1; [QGVAR(EH_update_server), [getPlayerID player, _completedAt]] call CBA_fnc_serverEvent; - - systemChat format ["Music Stop: %1", _musicClassname]; }]; \ No newline at end of file diff --git a/addons/music/stringtable.xml b/addons/music/stringtable.xml index 420e43f..5f5978b 100644 --- a/addons/music/stringtable.xml +++ b/addons/music/stringtable.xml @@ -1,23 +1,51 @@ - - CVO - Music - - - Server Settings - - - Minimum Delay - - - Minimum Delay in seconds.\nCombined Delay will define pause before the next title in music queue will be played. - - - Randomized Delay - - - Random Delay in seconds.\nCombined Delay will define pause before the next title in music queue will be played. - + + + CVO - Music + + + Server Settings + + + Minimum Delay + + + Minimum Delay in seconds.\nCombined Delay will define pause before the next title in music queue will be played. + + + Randomized Delay + + + Random Delay in seconds.\nCombined Delay will define pause before the next title in music queue will be played. + + + + + Music is fading out... + + + Music is already fading... + + + Music has stopped. + + + CVO Music + + + Music Controls + + + Fade and stop current music + + + Music History + + + Previously played Music: + + - \ No newline at end of file +