mirror of
https://gitlab.com/2009scape/rt4-client.git
synced 2025-12-19 21:10:19 -07:00
Add API methods for controlling audio
Hook up Update() callback Add Audio QOL plugin with mute/unmute hotkey and better settings persistence
This commit is contained in:
parent
7a7be2a54b
commit
ec255eea52
5 changed files with 130 additions and 4 deletions
|
|
@ -44,7 +44,9 @@ public abstract class Plugin {
|
|||
public void OnXPUpdate(int skill, int xp) {}
|
||||
|
||||
/**
|
||||
* Update() is called once per tick, aka once every 600ms.
|
||||
* Update() is called once every 1000 client loops.
|
||||
* This should be used for things that do need to update occasionally during runtime,
|
||||
* but don't need to update super often.
|
||||
*/
|
||||
public void Update() {}
|
||||
|
||||
|
|
|
|||
|
|
@ -257,4 +257,56 @@ public class API {
|
|||
public static void DispatchCommand(String command) {
|
||||
Cheat.sendCheatPacket(JagString.of(command));
|
||||
}
|
||||
|
||||
public static void PlaySound(int volume, int trackId, int delay) {
|
||||
SoundPlayer.play(volume, trackId, delay);
|
||||
}
|
||||
|
||||
public static void PlayMusic(int volume, int trackId) {
|
||||
MidiPlayer.playFadeOut(trackId, client.js5Archive6, volume);
|
||||
}
|
||||
|
||||
public static void PlayJingle(int jingleId) {
|
||||
MusicPlayer.playJingle(-1, jingleId);
|
||||
}
|
||||
|
||||
public static void SetMusicVolume(int volume) {
|
||||
Preferences.musicVolume = volume;
|
||||
}
|
||||
|
||||
public static int GetMusicVolume() {
|
||||
return Preferences.musicVolume;
|
||||
}
|
||||
|
||||
public static void SetSoundVolume(int volume) {
|
||||
Preferences.soundEffectVolume = volume;
|
||||
}
|
||||
|
||||
public static int GetSoundVolume() {
|
||||
return Preferences.soundEffectVolume;
|
||||
}
|
||||
|
||||
public static void SetAmbientVolume(int volume) {
|
||||
Preferences.ambientSoundsVolume = volume;
|
||||
}
|
||||
|
||||
public static int GetAmbientVolume() {
|
||||
return Preferences.ambientSoundsVolume;
|
||||
}
|
||||
|
||||
public static boolean IsMusicPlaying() {
|
||||
return MidiPlayer.isPlaying();
|
||||
}
|
||||
|
||||
public static boolean IsSoundPlaying() {
|
||||
return SoundPlayer.size != 0;
|
||||
}
|
||||
|
||||
public static void SendMessage(String message) {
|
||||
Chat.add(JagString.EMPTY, 0, JagString.of(message));
|
||||
}
|
||||
|
||||
public static void RequestNewSong() {
|
||||
SoundPlayer.sendTrackEndPacket();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,9 +128,13 @@ public class SoundPlayer {
|
|||
}
|
||||
MidiPlayer.jingle = false;
|
||||
} else if (Preferences.musicVolume != 0 && MusicPlayer.groupId != -1 && !MidiPlayer.isPlaying()) {
|
||||
Protocol.outboundBuffer.p1isaac(137);
|
||||
Protocol.outboundBuffer.p4(MusicPlayer.groupId);
|
||||
MusicPlayer.groupId = -1;
|
||||
sendTrackEndPacket();
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendTrackEndPacket() {
|
||||
Protocol.outboundBuffer.p1isaac(137);
|
||||
Protocol.outboundBuffer.p4(MusicPlayer.groupId);
|
||||
MusicPlayer.groupId = -1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1589,6 +1589,7 @@ public final class client extends GameShell {
|
|||
@Pc(24) GregorianCalendar gregorianCalendar = new GregorianCalendar();
|
||||
MiniMenu.gregorianDateSeed = gregorianCalendar.get(Calendar.HOUR_OF_DAY) * 600 + gregorianCalendar.get(Calendar.MINUTE) * 10 + gregorianCalendar.get(Calendar.SECOND) / 6;
|
||||
aRandom1.setSeed(MiniMenu.gregorianDateSeed);
|
||||
PluginRepository.Update();
|
||||
}
|
||||
this.js5NetworkLoop();
|
||||
if (js5MasterIndex != null) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue