public void ApplySmoothTransition() { RadioChannelData?channel = AudioManagerHelper.GetActiveChannelData(); if (channel != null) { ushort index = channel.Value.m_infoIndex; if (m_currentChannel == index) { return; } m_currentChannel = index; if (index == 0) { if (m_musicFileBackup != null) { AudioManager mgr = Singleton <AudioManager> .instance; ReflectionHelper.SetPrivateField(mgr, "m_musicFiles", m_musicFileBackup); } } else { AudioManager mgr = Singleton <AudioManager> .instance; ReflectionHelper.SetPrivateField(mgr, "m_musicFiles", null); } } }
void musicEntryEnableDisable(UIComponent component, int value) { RadioContentInfo info = m_CurrentContent[value]; AudioManagerHelper.SetContentEnabled(info, !AudioManagerHelper.ContentIsEnabled(info)); RebuildList(); }
private String GetEntryTextFor(RadioContentInfo content) { String name = AudioManagerHelper.GetContentName(content); switch (content.m_contentType) { case RadioContentInfo.ContentType.Blurb: name = "<sprite Blurb> " + name; break; case RadioContentInfo.ContentType.Broadcast: name = "<sprite Broadcast> " + name; break; case RadioContentInfo.ContentType.Commercial: name = "<sprite Commercial> " + name; break; case RadioContentInfo.ContentType.Music: name = "<sprite Music> " + name; break; case RadioContentInfo.ContentType.Talk: name = "<sprite Talk> " + name; break; } if (ModOptions.Instance.ImprovedDisableContentUI) { if (!AudioManagerHelper.ContentIsEnabled(content)) { name = "<sprite ContentUnchecked>" + name; } else { name = "<sprite ContentChecked>" + name; } } else { if (!AudioManagerHelper.ContentIsEnabled(content)) { name = "<sprite ContentDisabled>" + name; } } return(name); }
private void TopOpenStationDirectoryOnEventClick(UIComponent uiComponent, UIMouseEventParameter uiMouseEventParameter) { var data = AudioManagerHelper.GetActiveChannelData(); if (data != null) { var info = AudioManagerHelper.GetUserChannelInfo(data.Value.Info); var dir = DataLocation.gameContentPath; if (info != null) { dir = info.m_DefinitionDirectory; } DesktopHelper.OpenFileExternally(dir); } }
void musicEntrySelected(UIComponent component, int value) { if (ModOptions.Instance.ImprovedDisableContentUI) { Vector3 mouse = Input.mousePosition / component.GetUIView().inputScale; Vector3 diff = mouse - component.absolutePosition; if (diff.x <= 20) { musicEntryEnableDisable(component, value); return; } } RadioContentInfo info = m_CurrentContent[value]; AudioManagerHelper.SwitchToContent(info); }
/// <summary> /// Applies the content sensitivity /// </summary> public void ApplyDisallowedContentRestrictions() { if (!ModOptions.Instance.EnableContextSensitivity && !ModOptions.Instance.EnableDisabledContent) { return; } RebuildDisallowedContent(); // Find the current content and check if it is in the list of allowed content // Otherwise trigger radio content rebuild and stop playback RadioChannelData?currentchannel = AudioManagerHelper.GetActiveChannelData(); if (currentchannel != null) { RadioContentData?currentcontent = AudioManagerHelper.GetActiveContentInfo(); if (currentcontent != null && currentcontent.Value.Info != null) { HashSet <RadioContentInfo> disallowed; if (DisallowedContent.TryGetValue(currentchannel.Value.Info, out disallowed)) { if (ModOptions.Instance.EnableDebugInfo) { foreach (var v in disallowed) { CSLMusicMod.Log("Disallowed:" + v.name + "," + v.m_displayName); } } if (disallowed != null && disallowed.Contains(currentcontent.Value.Info)) { AudioManagerHelper.TriggerRebuildInternalSongList(); CSLMusicMod.Log("Wrong context for " + currentcontent.Value.Info.m_fileName); AudioManagerHelper.NextTrack(); } } } } }
/// <summary> /// Rebuilds the list of allowed content /// </summary> public void RebuildDisallowedContent() { if (m_WatcherUpdateTicker++ % 10 == 0) { AudioManager mgr = Singleton <AudioManager> .instance; for (int i = 0; i < mgr.m_radioChannels.m_size; ++i) { RebuildDisallowedContentForChannel(mgr.m_radioChannels[i]); } } else { RadioChannelData?currentchannel = AudioManagerHelper.GetActiveChannelData(); if (currentchannel != null) { RebuildDisallowedContentForChannel(currentchannel.Value); } } }
void buttonNextTrackClicked(UIComponent component, UIMouseEventParameter eventParam) { AudioManagerHelper.NextTrack(); }
private void RebuildList() { AudioManager mgr = Singleton <AudioManager> .instance; ushort activechannel = ReflectionHelper.GetPrivateField <ushort>(mgr, "m_activeRadioChannel"); //Debug.Log("Selected active channel " + activechannel + " of " + mgr.m_radioChannelCount); //Dictionary<RadioContentInfo, String> entrytexts = new Dictionary<RadioContentInfo, string>(); if (activechannel >= 0) { RadioChannelData channeldata = mgr.m_radioChannels[activechannel]; RadioChannelInfo info = channeldata.Info; m_CurrentContent.Clear(); if (info != null) { // Only show supported content entries HashSet <RadioContentInfo.ContentType> supported_content = new HashSet <RadioContentInfo.ContentType>(); foreach (var state in info.m_stateChain) { supported_content.Add(state.m_contentType); } for (uint i = 0; i < PrefabCollection <RadioContentInfo> .PrefabCount(); ++i) { var c = PrefabCollection <RadioContentInfo> .GetPrefab(i); if (c == null) { continue; } if (c.m_radioChannels == null) { continue; } if (supported_content.Contains(c.m_contentType) && c.m_radioChannels.Contains(info)) { //entrytexts[c] = GetEntryTextFor(c); //if(!IsFiltered(entrytexts[c])) if (!IsFiltered(AudioManagerHelper.GetContentName(c))) { m_CurrentContent.Add(c); } } } } m_RadioChannelInfo.isVisible = m_CurrentContent.Count == 0; //Debug.Log(m_CurrentContent.Count + " entries "); } m_CurrentContent.Sort((RadioContentInfo x, RadioContentInfo y) => { if (m_SortAscending) { //return string.Compare(entrytexts[x], entrytexts[y], StringComparison.CurrentCulture); return(string.Compare(AudioManagerHelper.GetContentName(x), AudioManagerHelper.GetContentName(y), StringComparison.CurrentCulture)); } else { //return string.Compare(entrytexts[y], entrytexts[x], StringComparison.CurrentCulture); return(string.Compare(AudioManagerHelper.GetContentName(y), AudioManagerHelper.GetContentName(x), StringComparison.CurrentCulture)); } }); RefreshListWidget(); }
public void Update() { // Check if some other UI has the focus if (UIView.HasInputFocus()) { m_NextTrackKey_IsDown = false; m_OpenPanelKey_IsDown = false; m_NextStationKey_IsDown = false; return; } m_ModifierCtrl = (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)); m_ModifierShift = (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)); m_ModiferAlt = (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)); //Next track if (ShortcutDown(ModOptions.Instance.ShortcutNextTrack)) { m_NextTrackKey_IsDown = true; } else if (m_NextTrackKey_IsDown && ShortcutUp(ModOptions.Instance.ShortcutNextTrack)) { m_NextTrackKey_IsDown = false; CSLMusicMod.Log("Pressed shortcut for next track"); AudioManagerHelper.NextTrack(); } //Next station if (ShortcutDown(ModOptions.Instance.ShortcutNextStation)) { m_NextStationKey_IsDown = true; } else if (m_NextStationKey_IsDown && ShortcutUp(ModOptions.Instance.ShortcutNextStation)) { CSLMusicMod.Log("Pressed shortcut for next station"); m_NextStationKey_IsDown = false; AudioManagerHelper.NextStation(); } //Panel if (ShortcutDown(ModOptions.Instance.ShortcutOpenRadioPanel)) { m_OpenPanelKey_IsDown = true; } else if (m_OpenPanelKey_IsDown && ShortcutUp(ModOptions.Instance.ShortcutOpenRadioPanel)) { m_OpenPanelKey_IsDown = false; CSLMusicMod.Log("Pressed shortcut for hide/show panel"); var radiopanel = CurrentRadioPanel; if (radiopanel != null) { var visible = ReflectionHelper.GetPrivateField <bool>(radiopanel, "m_isVisible"); if (visible) { radiopanel.HideRadio(); } else { radiopanel.ShowRadio(); } } } }
/// <summary> /// Rebuilds the allowed content for a channel. /// </summary> /// <param name="channel">Channel.</param> private void RebuildDisallowedContentForChannel(RadioChannelData channel) { if (channel.Info == null) { return; } HashSet <RadioContentInfo> disallowed; if (!DisallowedContent.TryGetValue(channel.Info, out disallowed)) { disallowed = new HashSet <RadioContentInfo>(); DisallowedContent[channel.Info] = disallowed; } else { disallowed.Clear(); } UserRadioChannel userchannel = AudioManagerHelper.GetUserChannelInfo(channel.Info); if (userchannel != null) { // If the channel is a custom channel, we can check for context and for content disabling // The method returns NULL if all songs apply! var allowedsongs = userchannel.GetApplyingSongs(); if (allowedsongs == null) { if (ModOptions.Instance.EnableDisabledContent && ModOptions.Instance.DisabledContent.Count != 0) { foreach (UserRadioContent usercontent in userchannel.m_Content) { if (usercontent.m_VanillaContentInfo != null) { bool isenabled = (!ModOptions.Instance.EnableDisabledContent || AudioManagerHelper.ContentIsEnabled(usercontent.m_VanillaContentInfo)); if (!isenabled) { disallowed.Add(usercontent.m_VanillaContentInfo); } } } } } else { foreach (UserRadioContent usercontent in userchannel.m_Content) { if (usercontent.m_VanillaContentInfo != null) { bool isincontext = (!ModOptions.Instance.EnableContextSensitivity || allowedsongs.Contains(usercontent)); bool isenabled = (!ModOptions.Instance.EnableDisabledContent || AudioManagerHelper.ContentIsEnabled(usercontent.m_VanillaContentInfo)); if (!isincontext || !isenabled) { disallowed.Add(usercontent.m_VanillaContentInfo); } } } } } else { // If the channel is a vanilla channel, we can still disable content AudioManager mgr = Singleton <AudioManager> .instance; if (mgr.m_radioContents.m_size > 0) { for (int i = 0; i < mgr.m_radioContents.m_size; ++i) { var content = mgr.m_radioContents[i]; if (content.Info != null && content.Info.m_radioChannels != null && content.Info.m_radioChannels.Contains(channel.Info)) { if (!AudioManagerHelper.ContentIsEnabled(content.Info)) { disallowed.Add(content.Info); } } } } } }