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

Music - Reworked #90

Merged
merged 1 commit into from
Nov 11, 2024
Merged
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
16 changes: 12 additions & 4 deletions addons/music/CfgFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -28,7 +39,6 @@ class CfgFunctions
class init_musicEventHandlers { preInit = 1; };
class init_cbaEvents { preInit = 1; };


class startMonitor {};
class createAction {};
class publicArray {};
Expand All @@ -38,8 +48,6 @@ class CfgFunctions
class verify {};
class queue {};
class play {};


};

class remote
Expand Down
34 changes: 34 additions & 0 deletions addons/music/functions/config/fn_getMusicName.sqf
Original file line number Diff line number Diff line change
@@ -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
35 changes: 35 additions & 0 deletions addons/music/functions/diary/fn_createDiary.sqf
Original file line number Diff line number Diff line change
@@ -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 ["<font face='EtelkaMonospacePro' size=18><execute expression='[] call %1;'>%2</execute></font>", QFUNC(fade_local), LLSTRING(diary_record_MusicControls_fadeButton)]
]
];
27 changes: 27 additions & 0 deletions addons/music/functions/diary/fn_fade_local.sqf
Original file line number Diff line number Diff line change
@@ -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;
69 changes: 69 additions & 0 deletions addons/music/functions/diary/fn_updateHistory.sqf
Original file line number Diff line number Diff line change
@@ -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 ["<font face='EtelkaMonospacePro' color='#0099ff' size='14'>%1</font>", 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 ["<font size=10 face='EtelkaMonospacePro'>%1. %2 - %3</font>", _index, _x#0, _x#2];

_array pushBack _string;
} forEach _history;

player setDiaryRecordText [[QGVAR(diary_subject), _record], [_title, _array joinString "<br />"]];
1 change: 0 additions & 1 deletion addons/music/functions/internal/fn_catalog.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ params [
["_args", [], [] ]
];

ZRN_LOG_MSG_1(INIT,_selectMode);

private _updateArray = false;
private _cat = missionNamespace getVariable [QGVAR(HM_playlists), "404"];
Expand Down
2 changes: 1 addition & 1 deletion addons/music/functions/internal/fn_createAction.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private _insertChildren = {
{
private _playlistAction = [
QGVAR(_x) // * 0: Action name <STRING>
,[_x] call FUNC(getName) // * 1: Name of the action shown in the menu <STRING>
,[_x] call FUNC(getPlaylistName) // * 1: Name of the action shown in the menu <STRING>
,"" // * 2: Icon <STRING> "\A3\ui_f\data\igui\cfg\simpleTasks\types\backpack_ca.paa"
,_code // * 3: Statement <CODE>
,{true} // * 4: Condition <CODE>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}];


Expand All @@ -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];
}];
66 changes: 47 additions & 19 deletions addons/music/stringtable.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<Project name="cvo-auxiliary">
<Package name="Music">
<Key ID="STR_cvo_music_set_cat_title">
<English>CVO - Music</English>
</Key>
<Key ID="STR_cvo_music_set_subcat_serverSetting">
<English>Server Settings</English>
</Key>
<Key ID="STR_cvo_music_set_delayMin">
<English>Minimum Delay</English>
</Key>
<Key ID="STR_cvo_music_set_delayMin_desc">
<English>Minimum Delay in seconds.\nCombined Delay will define pause before the next title in music queue will be played.</English>
</Key>
<Key ID="STR_cvo_music_set_delayRnd">
<English>Randomized Delay</English>
</Key>
<Key ID="STR_cvo_music_set_delayRnd_desc">
<English>Random Delay in seconds.\nCombined Delay will define pause before the next title in music queue will be played.</English>
</Key>
<Container name="CBA Settings">
<Key ID="STR_cvo_music_set_cat_title">
<English>CVO - Music</English>
</Key>
<Key ID="STR_cvo_music_set_subcat_serverSetting">
<English>Server Settings</English>
</Key>
<Key ID="STR_cvo_music_set_delayMin">
<English>Minimum Delay</English>
</Key>
<Key ID="STR_cvo_music_set_delayMin_desc">
<English>Minimum Delay in seconds.\nCombined Delay will define pause before the next title in music queue will be played.</English>
</Key>
<Key ID="STR_cvo_music_set_delayRnd">
<English>Randomized Delay</English>
</Key>
<Key ID="STR_cvo_music_set_delayRnd_desc">
<English>Random Delay in seconds.\nCombined Delay will define pause before the next title in music queue will be played.</English>
</Key>
</Container>
<Container name="Music Diary">
<Key ID="STR_cvo_music_diary_fading">
<English>Music is fading out...</English>
</Key>
<Key ID="STR_cvo_music_diary_fading_already">
<English>Music is already fading...</English>
</Key>
<Key ID="STR_cvo_music_diary_faded">
<English>Music has stopped.</English>
</Key>
<Key ID="STR_cvo_music_diary_subject_title">
<English>CVO Music</English>
</Key>
<Key ID="STR_cvo_music_diary_record_MusicControls_Title">
<English>Music Controls</English>
</Key>
<Key ID="STR_cvo_music_diary_record_MusicControls_fadeButton">
<English>Fade and stop current music</English>
</Key>
<Key ID="STR_cvo_music_diary_record_MusicHistory_Title">
<English>Music History</English>
</Key>
<Key ID="STR_cvo_music_diary_record_MusicHistory_Header">
<English>Previously played Music:</English>
</Key>
</Container>
</Package>
</Project>
</Project>