Skip to content

Commit

Permalink
Merge pull request #2091 from antonpup/dev
Browse files Browse the repository at this point in the history
v0.8.0 stable
  • Loading branch information
diogotr7 authored Jun 13, 2020
2 parents 0beaed9 + d0f9e03 commit 7a387ab
Show file tree
Hide file tree
Showing 6 changed files with 160 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ public Event_Desktop() : base()
public override void UpdateLights(EffectFrame frame)
{
var layers = new Queue<EffectLayer>(Application.Profile.Layers.Where(l => l.Enabled).Reverse().Select(l => l.Render(_game_state)));
var overlayLayers = new Queue<EffectLayer>(Application.Profile.OverlayLayers.Where(l => l.Enabled).Reverse().Select(l => l.Render(_game_state)));


//Scripts before interactive and shortcut assistant layers
//ProfilesManager.DesktopProfile.UpdateEffectScripts(layers);

Expand All @@ -43,7 +42,6 @@ public override void UpdateLights(EffectFrame frame)
}

frame.AddLayers(layers.ToArray());
frame.AddOverlayLayers(overlayLayers.ToArray());
}

public override void SetGameState(IGameState new_game_state)
Expand Down
154 changes: 144 additions & 10 deletions Project-Aurora/Project-Aurora/Profiles/Discord/GSI/AuroraGSI.plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class AuroraGSI {

getName() { return "AuroraGSI"; }
getDescription() { return "Sends information to Aurora about users connecting to/disconnecting from, mute/deafen status"; }
getVersion() { return "1.1"; }
getVersion() { return "2.1.1"; }
getAuthor() { return "Popato & DrMeteor"; }
getChanges() {
return {
Expand All @@ -52,6 +52,20 @@ class AuroraGSI {
"1.1" :
`
Made the state only be sent if it changed.
`,
"2.0" :
`
Version bump to stop the update prompt derping.
`,
"2.1.0":
`
Allow to track mute/deafen statuses outside voice channels.
Fix unread status for Enhanced Discord users.
Actually fix self-updating loop
`,
"2.1.1":
`
Fix "being_called" boolean so it's now usable (triggers when user calls and getting called in DMs)
`
};
}
Expand Down Expand Up @@ -124,10 +138,133 @@ class AuroraGSI {

let getVoiceStates = NeatoLib.Modules.get(["getVoiceState"]).getVoiceStates,
getUser = NeatoLib.Modules.get(["getUser"]).getUser,
getChannel = NeatoLib.Modules.get(["getChannel"]).getChannel;
getChannel = NeatoLib.Modules.get(["getChannel"]).getChannel,
getCalls = NeatoLib.Modules.get(["getCalls"]).getCalls,
getLanguage = document.documentElement.lang;

// this.jsonTimer = setInterval( this.sendJsonToAurora, 50, this.json );

switch (getLanguage) {
case "en-US":
var mute = '[aria-label="Mute"]';
var deafen = '[aria-label="Deafen"]';
break;
case "en-GB":
var mute = '[aria-label="Mute"]';
var deafen = '[aria-label="Deafen"]';
break;
case "pl":
var mute = '[aria-label="Wycisz"]';
var deafen = '[aria-label="Wyłącz dźwięk"]';
break;
case "da":
var mute = '[aria-label="Gør stum"]';
var deafen = '[aria-label="Gør døv"]';
break;
case "de":
var mute = '[aria-label="Stummschalten"]';
var deafen = '[aria-label="Ein- und Ausgabe deaktivieren"]';
break;
case "es-ES":
var mute = '[aria-label="Silenciar"]';
var deafen = '[aria-label="Ensordecer"]';
break;
case "fr":
var mute = '[aria-label="Rendre muet"]';
var deafen = '[aria-label="Mettre en sourdine"]';
break;
case "hr":
var mute = '[aria-label="Isključi mikrofon"]';
var deafen = '[aria-label="Isključi zvuk"]';
break;
case "it":
var mute = '[aria-label="Silenzia"]';
var deafen = '[aria-label="Silenzia l\'audio"]';
break;
case "lt":
var mute = '[aria-label="Nutildyti"]';
var deafen = '[aria-label="Išjungti garsą"]';
break;
case "hu":
var mute = '[aria-label="Némítás"]';
var deafen = '[aria-label="Süketítés"]';
break;
case "hl":
var mute = '[aria-label="Dempen"]';
var deafen = '[aria-label="Hoorbaar maken"]';
break;
case "no":
var mute = '[aria-label="Demp"]';
var deafen = '[aria-label="Slå av lyd"]';
break;
case "pt-BR":
var mute = '[aria-label="Desativar microfone"]';
var deafen = '[aria-label="Desativar áudio"]';
break;
case "ro":
var mute = '[aria-label="Dezactivează microfonul"]';
var deafen = '[aria-label="Dezactivează sunetul"]';
break;
case "fi":
var mute = '[aria-label="Mykistä"]';
var deafen = '[aria-label="Hiljennä"]';
break;
case "sv-SE":
var mute = '[aria-label="Mikrofon av"]';
var deafen = '[aria-label="Ljud av"]';
break;
case "vi":
var mute = '[aria-label="Tắt âm"]';
var deafen = '[aria-label="Tắt tiếng"]';
break;
case "tr":
var mute = '[aria-label="Sustur"]';
var deafen = '[aria-label="Sağırlaştır"]';
break;
case "cs":
var mute = '[aria-label="Ztlumit mikrofon"]';
var deafen = '[aria-label="Ztlumit zvuk"]';
break;
case "el":
var mute = '[aria-label="Σίγαση"]';
var deafen = '[aria-label="Κώφωση"]';
break;
case "bg":
var mute = '[aria-label="Изкл. на микрофона"]';
var deafen = '[aria-label="Заглушаване"]';
break;
case "ru":
var mute = '[aria-label="Откл. микрофон"]';
var deafen = '[aria-label="Откл. звук"]';
break;
case "uk":
var mute = '[aria-label="Вимкнути мікрофон"]';
var deafen = '[aria-label="Вимкнути звук"]';
break;
case "th":
var mute = '[aria-label="ปิดเสียง"]';
var deafen = '[aria-label="ปิดการได้ยิน"]';
break;
case "zh-CN":
var mute = '[aria-label="麦克风静音"]';
var deafen = '[aria-label="耳机静音"]';
break;
case "ja":
var mute = '[aria-label="ミュート"]';
var deafen = '[aria-label="スピーカーミュート"]';
break;
case "zh-TW":
var mute = '[aria-label="靜音"]';
var deafen = '[aria-label="拒聽"]';
break;
case "ko":
var mute = '[aria-label="마이크 음소거 "]';
var deafen = '[aria-label="헤드셋 음소거 "]';
break;
default:
console.log("Something is fucked up... can't find language");
}

this.updatetimer = setInterval(() => {
var self = this;

Expand Down Expand Up @@ -206,21 +343,18 @@ class AuroraGSI {
self.json.voice.name = "";
}

if(voiceStates){
let userVoiceState = voiceStates[localUser.id];
if(userVoiceState){
self.json.user.self_mute = userVoiceState.selfMute;
self.json.user.self_deafen = userVoiceState.selfDeaf;
}
}
self.json.user.self_mute = document.querySelector(mute).getAttribute("aria-checked");
self.json.user.self_deafen = document.querySelector(deafen).getAttribute("aria-checked");

self.json.user.unread_messages = false;
self.json.user.mentions = false;

if (document.querySelector('[class^="numberBadge-"]'))
self.json.user.mentions = true;
if (document.getElementsByClassName("bd-unread").length > 0)
if (Object.values(NeatoLib.Modules.get("getUnreadGuilds").getUnreadGuilds()).length > 0)
self.json.user.unread_messages = true;
if (getCalls().filter(function(x){return x.ringing.length > 0;}).length > 0)
self.json.user.being_called = true;

if(JSON.stringify(this.json) !== this.lastJson){
console.log("false");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class UserNode : AutoJsonNode<UserNode> {
[AutoJsonPropertyName("self_deafen")] public bool SelfDeafen;
public bool Mentions;
[AutoJsonPropertyName("unread_messages")] public bool UnreadMessages;
[AutoJsonPropertyName("being_called")] public bool BeingCalled;

internal UserNode(string json) : base(json) {
Status = GetStatus(GetString("status"));
Expand Down
3 changes: 2 additions & 1 deletion Project-Aurora/Project-Aurora/Settings/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,8 @@ public class Configuration : INotifyPropertyChanged
public float idle_frequency;

//Hardware Monitor
public int HardwareMonitorUpdateRate { get; set; } = 300;
public int HardwareMonitorUpdateRate { get; set; } = 500;
public bool HardwareMonitorUseAverageValues { get; set; } = true;

public VariableRegistry VarRegistry;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@

<TextBlock HorizontalAlignment="Left" Margin="12,278,0,0" TextWrapping="Wrap" Text="Hardware sensors update rate:" VerticalAlignment="Top" ToolTip="Used for CPU and GPU usage, etc"/>
<xctk:IntegerUpDown HorizontalAlignment="Left" Height="24" Margin="178,278,0,0" VerticalAlignment="Top" Width="50" Value="{Binding HardwareMonitorUpdateRate}" Maximum="2000" Minimum="100" MouseWheelActiveOnFocus="True" />
<CheckBox Content="Use average hardware sensor values instead of real-time ones " ToolTip="This option should make sudden transitions in CPU / GPU usage smoother" HorizontalAlignment="Left" Margin="10,302,0,0" VerticalAlignment="Top" IsChecked="{Binding HardwareMonitorUseAverageValues}" />

</Grid>
</TabItem>
Expand Down
13 changes: 11 additions & 2 deletions Project-Aurora/Project-Aurora/Utils/HardwareMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static bool TryDump()
lines.Add("-----");
lines.Add(hw.Name);
lines.Add("Sensors:");
foreach (var sensor in hw.Sensors.OrderBy(s => s.SensorType))
foreach (var sensor in hw.Sensors.OrderBy(s => s.Identifier))
{
lines.Add($"Name: {sensor.Name}, Id: {sensor.Identifier}, Type: {sensor.SensorType}");
}
Expand Down Expand Up @@ -99,14 +99,17 @@ private static ISensor FindSensor(this IHardware hardware, SensorType type)

public abstract class HardwareUpdater
{
private const int MAX_QUEUE = 8;
protected IHardware hw;
protected bool inUse;

private readonly Timer _useTimer;
private readonly Timer _updateTimer;
private readonly Queue<float> _values;

protected HardwareUpdater()
{
_values = new Queue<float>(MAX_QUEUE);
_useTimer = new Timer(5000);
_useTimer.Elapsed += (a, b) =>
{
Expand All @@ -132,7 +135,13 @@ protected float GetValue(ISensor sensor)
_useTimer.Stop();
_useTimer.Start();

return sensor?.Value ?? 0;
if (_values.Count == MAX_QUEUE)
_values.Dequeue();
_values.Enqueue(sensor?.Value ?? 0);

return Global.Configuration.HardwareMonitorUseAverageValues ?
_values.Average() :
sensor?.Value ?? 0;
}
}

Expand Down

0 comments on commit 7a387ab

Please sign in to comment.