void LogAllStations() { Logger.Init(logPath); Logger.Log("Game version: " + Game.Version.ToString(), logPath); if ((int)Game.Version < (int)GameVersion.VER_1_0_1493_0_STEAM) { Logger.Log("WARNING: Can't use the native radio wheel organizer on this game version. " + "Please update to 1.0.1493.0 or higher."); } Logger.Log("Checking all native and add-on radios...", logPath); maxStationCount = RadioNativeFunctions._MAX_RADIO_STATION_INDEX(); validStationNames = new List <string>(); for (int i = 0; i < maxStationCount; i++) { string stationName = RadioNativeFunctions.GET_RADIO_STATION_NAME(i); validStationNames.Add(stationName); string s = "Name: " + stationName + " || Proper name: " + RadioNativeFunctions.GetRadioStationProperName(i); Logger.Log(s, logPath); } Logger.Log("Please use the 'Name' name for your wheel organization lists (NativeWheels.cfg)! 'Proper name' is only for display purposes.", logPath); }
void UnhideAllStations() { for (int i = 0; i < maxStationCount; i++) { RadioNativeFunctions._LOCK_RADIO_STATION(RadioNativeFunctions.GET_RADIO_STATION_NAME(i), false); } }
void HandleQueuedStationActions() { if (CanDoQueuedAction()) { if (ActionQueued == ActionOptions.StopCurrent) { if (RadioStation.CurrentPlaying != null) { // Turn off custom radio RadioStation.CurrentPlaying.Stop(); // Enable last played vanilla radio RadioNativeFunctions.SET_RADIO_TO_STATION_INDEX(lastVanillaStationPlayed); // Make vanilla radio audible RadioNativeFunctions.VanillaRadioFadedOut(false); RadioStation.CurrentPlaying = null; lastRadioWasCustom = false; } } else if (ActionQueued == ActionOptions.PlayQueued) { if (RadioStation.NextQueuedStation != null && RadioStation.NextQueuedStation != RadioStation.CurrentPlaying) { // Enable custom radio if (RadioStation.CurrentPlaying != null) { RadioStation.CurrentPlaying.Stop(); } RadioStation.CurrentPlaying = RadioStation.NextQueuedStation; RadioStation.CurrentPlaying.Play(); RadioStation.NextQueuedStation = null; // Set vanilla radio to Off but save what station was playing beforehand lastVanillaStationPlayed = RadioNativeFunctions.GET_PLAYER_RADIO_STATION_INDEX(); RadioNativeFunctions.SetVanillaRadioOff(); // Make vanilla radio audible RadioNativeFunctions.VanillaRadioFadedOut(false); lastRadioWasCustom = true; } } // Set to DoNothing since queued action is completed ActionQueued = ActionOptions.DoNothing; } }
public void UpdateDashboardInfo() { if (CurrentSound == null || CurrentSound.Sound == null) { return; } if (Game.Player.Character.IsInVehicle()) { string[] info = CurrentSound.DisplayName.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None); RadioNativeFunctions.UpdateRadioScaleform(Name, info[0], info[1]); } }
public void HandleRadioWheelExtraControls() { if (WheelVars.CurrentRadioWheel.Visible) { if (RadioStation.CurrentPlaying != null) { ControlSkipTrack = GTAFunction.UsingGamepad() ? Config.GP_Skip_Track : Config.KB_Skip_Track; ControlVolumeUp = GTAFunction.UsingGamepad() ? Config.GP_Volume_Up : Config.KB_Volume_Up; ControlVolumeDown = GTAFunction.UsingGamepad() ? Config.GP_Volume_Down : Config.KB_Volume_Down; ControlNextWheel = GTAFunction.UsingGamepad() ? GTA.Control.VehicleAccelerate : GTA.Control.WeaponWheelPrev; ControlPrevWheel = GTAFunction.UsingGamepad() ? GTA.Control.VehicleBrake : GTA.Control.WeaponWheelNext; if (Config.DisplayHelpText) { GTAFunction.DisplayHelpTextThisFrame( GTAFunction.InputString(ControlSkipTrack) + " : Skip Track\n" + GTAFunction.InputString(ControlVolumeUp) + " " + GTAFunction.InputString(ControlVolumeDown) + " : Volume: " + Math.Round(SoundFile.SoundEngine.SoundVolume * 100, 0) + "%\n" + GTAFunction.InputString(ControlNextWheel) + " " + GTAFunction.InputString(ControlPrevWheel) + " : Next / Prev Wheel\n", false, false); } if (Game.IsControlJustPressed(2, ControlSkipTrack)) { RadioStation.CurrentPlaying.PlayNextSong(); } else if (Game.IsControlJustPressed(2, ControlVolumeUp)) { SoundFile.StepVolume(0.05f, 2); } else if (Game.IsControlJustPressed(2, ControlVolumeDown)) { SoundFile.StepVolume(-0.05f, 2); } } } if (RadioStation.CurrentPlaying != null) { Game.DisableControlThisFrame(2, GTA.Control.VehicleNextRadio); Game.DisableControlThisFrame(2, GTA.Control.VehicleNextRadioTrack); Game.DisableControlThisFrame(2, GTA.Control.VehiclePrevRadio); Game.DisableControlThisFrame(2, GTA.Control.VehiclePrevRadioTrack); RadioNativeFunctions.SetVanillaRadioOff(); } }
void OnTick(object sender, EventArgs e) { if (GTAFunction.HasCheatStringJustBeenEntered("radio_reload")) { UnhideAllStations(); NativeWheel.WheelList = null; currentWheel = null; GetOrganizationLists(); loaded = true; Wait(150); } if (RadioNativeFunctions.IsRadioHudComponentVisible()) { if (!loaded && Game.Player.CanControlCharacter) { LogAllStations(); GetOrganizationLists(); loaded = true; } ShowHelpTexts(); ControlWheelChange(); if (Event_JUST_OPENED_OnNextOpen) { OnJustOpened(); } DisableNativeScrollRadioControls(); Event_JUST_OPENED_OnNextOpen = false; } else { if (!loaded) { return; } if (!Event_JUST_OPENED_OnNextOpen) { OnJustClosed(); Event_JUST_OPENED_OnNextOpen = true; } } }
bool VanillaOrCustomRadioWheelIsVisible() { //return /*_IS_PLAYER_VEHICLE_RADIO_ENABLED() &&*/ Game.IsControlPressed(2, GTA.Control.VehicleRadioWheel) && Game.Player.CanControlCharacter; if (Game.IsControlPressed(2, GTA.Control.VehicleRadioWheel) && Game.Player.CanControlCharacter) { if (Game.Player.Character.IsInVehicle() && RadioNativeFunctions._IS_PLAYER_VEHICLE_RADIO_ENABLED()) { return(true); } else if (Game.Player.Character.IsOnFoot) { if (RadioNativeFunctions.IsRadioHudComponentVisible() || WheelVars.CurrentRadioWheel.Visible || IsCurrentCustomStationPlaying()) { return(true); } } } return(false); }
void UpdateWheelThisFrame() { if (!WheelListIsPopulated()) { return; } // Unhide all listed radios foreach (var station in currentWheel.stationList) { RadioNativeFunctions._LOCK_RADIO_STATION(station, false); } // Hide any valid station name that isn't in the current wheel station list foreach (var station in validStationNames) { if (!currentWheel.stationList.Any(s => s.Equals(station))) { RadioNativeFunctions._LOCK_RADIO_STATION(station, true); } } }
public void HandleEnterExitVehicles() { if (!lastPlayedOnFoot && !RadioNativeFunctions._IS_PLAYER_VEHICLE_RADIO_ENABLED()) { if (RadioStation.CurrentPlaying != null) { RadioStation.CurrentPlaying.Stop(); RadioStation.CurrentPlaying = null; if (WheelVars.CurrentRadioWheel != null) { WheelVars.CurrentRadioWheel.Visible = false; } // Make vanilla radio audible RadioNativeFunctions.VanillaRadioFadedOut(false); canResumeCustomStation = true; } } /*if (Game.Player.Character.CurrentVehicle != null * && Game.Player.Character.CurrentVehicle.EngineRunning * && lastRadioWasCustom * && canResumeCustomStation * && !IsCurrentCustomStationPlaying()) * { * ActionQueued = ActionOptions.PlayQueued; * * // Set the queued radio station based on the current category selected, using stationPairList. * RadioStation.NextQueuedStation = StationWheelPair.List.Find(x => x.Category == WheelVars.CurrentRadioWheel.SelectedCategory).Station; * * SetActionDelay(Config.WheelActionDelay); * * canResumeCustomStation = false; * }*/ }
bool IsMobileRadioEnabled() { return(RadioNativeFunctions.IS_MOBILE_PHONE_RADIO_ACTIVE() || IsCurrentCustomStationPlaying()); }
void SetupEvents() { GeneralEvents.OnPlayerEnteredVehicle += (veh) => { bool vehWasEngineRunning = veh.EngineRunning; // Make vanilla radio silent RadioNativeFunctions.VanillaRadioFadedOut(true); DateTime enteredTime = DateTime.Now; while (!veh.EngineRunning || DateTime.Now > enteredTime.AddSeconds(10)) { //UI.ShowSubtitle((enteredTime.AddSeconds(10) - DateTime.Now).TotalMilliseconds.ToString()); vehWasEngineRunning = false; Yield(); } // In case the timeout above caused the loop to break, // We will not continue because the vehicle is dead. if (!veh.EngineRunning) { return; } if (UsedVehiclesManager.IsUsedVehicle(veh)) { canResumeCustomStation = false; if (UsedVehiclesManager.GetVehicleStationInfo(veh) == null) { // Make vanilla radio audible RadioNativeFunctions.VanillaRadioFadedOut(false); canResumeCustomStation = false; lastRadioWasCustom = false; return; } ActionQueued = ActionOptions.PlayQueued; UsedVehiclesManager.SetLastStationNow(veh); SetActionDelay(Config.WheelActionDelay + 300); lastRadioWasCustom = true; //UI.ShowSubtitle("Started playback"); } else { // If the engine was running, don't mess with it. // Since I can't figure out how to see if a vehicle // was emitting a station, I'll just not mess with it. if (vehWasEngineRunning) { //UI.ShowSubtitle("RADIO IS ENABLED: " + RadioNativeFunctions.GET_PLAYER_RADIO_STATION_INDEX().ToString()); // Make vanilla radio audible RadioNativeFunctions.VanillaRadioFadedOut(false); canResumeCustomStation = false; lastRadioWasCustom = false; return; } int chooseRandom = RadioStation.random.Next(10); //UI.ShowSubtitle("RANDOM: " + chooseRandom.ToString()); // 70% chance to play a custom station. if (chooseRandom >= 3) { ActionQueued = ActionOptions.PlayQueued; // Set the queued radio station randomly, chosen from stationPairList. chooseRandom = RadioStation.random.Next(StationWheelPair.List.Count); UsedVehiclesManager.UpdateVehicleWithStationInfo(veh, StationWheelPair.List[chooseRandom]); UsedVehiclesManager.SetLastStationNow(veh); SetActionDelay(Config.WheelActionDelay + 300); canResumeCustomStation = false; lastRadioWasCustom = true; } else { UsedVehiclesManager.UpdateVehicleWithStationInfo(veh, null); // Make vanilla radio audible RadioNativeFunctions.VanillaRadioFadedOut(false); canResumeCustomStation = false; lastRadioWasCustom = false; } } }; GeneralEvents.OnPlayerExitedVehicle += (veh) => { if (veh == null) { return; } /*if (!IsMobileRadioEnabled()) * { * lastRadioWasCustom = IsCurrentCustomStationPlaying() ? true : false; * }*/ // Make vanilla radio audible RadioNativeFunctions.VanillaRadioFadedOut(false); UsedVehiclesManager.UpdateVehicleWithStationInfo(veh, lastRadioWasCustom ? StationWheelPair.List.Find(x => x.Category == WheelVars.CurrentRadioWheel.SelectedCategory) : null); }; /*GeneralEvents.OnPlayerVehicleEngineTurnedOn += (veh) => * { * if (IsCurrentCustomStationPlaying()) return; * * if (lastRadioWasCustom && canResumeCustomStation) * { * ActionQueued = ActionOptions.PlayQueued; * * // Set the queued radio station based on the current category selected, using stationPairList. * RadioStation.NextQueuedStation = StationWheelPair.List.Find(x => x.Category == WheelVars.CurrentRadioWheel.SelectedCategory).Station; * * SetActionDelay(Config.WheelActionDelay); * * canResumeCustomStation = false; * } * };*/ }