-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from Ceikry/master
Audio/Command API Expansion
- Loading branch information
Showing
7 changed files
with
163 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package AudioQOL | ||
|
||
import plugin.Plugin | ||
import plugin.annotations.PluginMeta | ||
import plugin.api.API | ||
import plugin.api.FontColor | ||
import plugin.api.FontType | ||
import plugin.api.TextModifier | ||
import rt4.Keyboard | ||
import java.awt.event.KeyAdapter | ||
import java.awt.event.KeyEvent | ||
|
||
@PluginMeta( | ||
author = "Ceikry", | ||
description = "Provides some QOL for audio, including better settings persistence", | ||
version = 1.0 | ||
) | ||
class plugin : Plugin() { | ||
var isMute = false | ||
var lastVolumes: Triple<Int,Int,Int>? = null | ||
|
||
override fun Update() { | ||
if (isMute) return | ||
API.StoreData("sound-vol", API.GetSoundVolume()) | ||
API.StoreData("music-vol", API.GetMusicVolume()) | ||
API.StoreData("amb-vol", API.GetAmbientVolume()) | ||
} | ||
|
||
override fun Init() { | ||
val soundVol = API.GetData("sound-vol") as? Int ?: 255 | ||
val musicVol = API.GetData("music-vol") as? Int ?: 127 | ||
val ambVol = API.GetData("amb-vol") as? Int ?: 127 | ||
API.SetMusicVolume(soundVol) | ||
API.SetAmbientVolume(musicVol) | ||
API.SetSoundVolume(ambVol) | ||
|
||
API.AddKeyboardListener(object : KeyAdapter() { | ||
override fun keyPressed(e: KeyEvent) { | ||
if (API.IsKeyPressed(Keyboard.KEY_CTRL) && e.keyCode == KeyEvent.VK_M) { | ||
toggleMute() | ||
} | ||
} | ||
}) | ||
} | ||
|
||
private fun toggleMute() { | ||
isMute = !isMute | ||
if (isMute) { | ||
lastVolumes = Triple(API.GetMusicVolume(), API.GetSoundVolume(), API.GetAmbientVolume()) | ||
API.SetMusicVolume(0) | ||
API.SetSoundVolume(0) | ||
API.SetAmbientVolume(0) | ||
API.SendMessage("Audio Muted.") | ||
if (API.IsMusicPlaying()) { | ||
API.PlayMusic(0, -1) | ||
} | ||
} else { | ||
API.SetMusicVolume(lastVolumes?.first ?: 255) | ||
API.SetSoundVolume(lastVolumes?.second ?: 127) | ||
API.SetAmbientVolume(lastVolumes?.third ?: 127) | ||
API.SendMessage("Audio Unmuted.") | ||
if ((lastVolumes?.first ?: 255) > 0) { | ||
API.RequestNewSong() | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package TabReply | ||
|
||
import plugin.Plugin | ||
import plugin.annotations.PluginMeta | ||
import plugin.api.API | ||
import java.awt.event.KeyAdapter | ||
import java.awt.event.KeyEvent | ||
|
||
@PluginMeta ( | ||
author = "Ceikry", | ||
description = "Allows you to press tab to reply to DMs.", | ||
version = 1.0 | ||
) | ||
class plugin : Plugin() { | ||
override fun Init() { | ||
API.AddKeyboardListener(object : KeyAdapter() { | ||
override fun keyPressed(e: KeyEvent) { | ||
if (e.keyCode == KeyEvent.VK_TAB) | ||
API.DispatchCommand("::reply") | ||
} | ||
}) | ||
} | ||
} |