1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Added smoothness-setting to bubbles effect

This commit is contained in:
Darth Affe 2016-06-14 21:27:11 +02:00
parent 83c64d6cc3
commit 2420aa6bc4
6 changed files with 44 additions and 7 deletions

View File

@ -277,6 +277,9 @@
<setting name="BubbleCount" serializeAs="String">
<value>14</value>
</setting>
<setting name="Smoothness" serializeAs="String">
<value>25</value>
</setting>
</Artemis.Modules.Effects.Bubbles.Bubbles>
<Artemis.Settings.General>
<setting name="LastEffect" serializeAs="String">

View File

@ -106,5 +106,17 @@ namespace Artemis.Modules.Effects.Bubbles {
this["BubbleCount"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("25")]
public int Smoothness {
get {
return ((int)(this["Smoothness"]));
}
set {
this["Smoothness"] = value;
}
}
}
}

View File

@ -23,5 +23,8 @@
<Setting Name="BubbleCount" Type="System.Int32" Scope="User">
<Value Profile="(Default)">14</Value>
</Setting>
<Setting Name="Smoothness" Type="System.Int32" Scope="User">
<Value Profile="(Default)">25</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@ -28,7 +28,6 @@ namespace Artemis.Modules.Effects.Bubbles
: base(mainManager, null)
{
Name = "Bubbles";
KeyboardScale = 25;
Settings = settings;
Initialized = false;
}
@ -39,18 +38,23 @@ namespace Artemis.Modules.Effects.Bubbles
public override void Enable()
{
KeyboardScale = Settings.Smoothness;
Rect rect = MainManager.DeviceManager.ActiveKeyboard.KeyboardRectangle(KeyboardScale);
double scaleFactor = Settings.Smoothness / 25.0;
for (int i = 0; i < Settings.BubbleCount; i++)
{
Color color = Settings.IsRandomColors ? ColorHelpers.GetRandomRainbowColor() : ColorHelpers.ToDrawingColor(Settings.BubbleColor);
// -Settings.MoveSpeed because we want to spawn at least one move away from borders
double initialPositionX = ((rect.Width - (Settings.BubbleSize * 2) - Settings.MoveSpeed) * _random.NextDouble()) + Settings.BubbleSize;
double initialPositionY = ((rect.Height - (Settings.BubbleSize * 2) - Settings.MoveSpeed) * _random.NextDouble()) + Settings.BubbleSize;
double initialDirectionX = (Settings.MoveSpeed * _random.NextDouble()) * (_random.Next(1) == 0 ? -1 : 1);
double initialDirectionY = (Settings.MoveSpeed - Math.Abs(initialDirectionX)) * (_random.Next(1) == 0 ? -1 : 1);
double initialPositionX = ((rect.Width - (Settings.BubbleSize * scaleFactor * 2) - Settings.MoveSpeed * scaleFactor) * _random.NextDouble()) + Settings.BubbleSize * scaleFactor;
double initialPositionY = ((rect.Height - (Settings.BubbleSize * scaleFactor * 2) - Settings.MoveSpeed * scaleFactor) * _random.NextDouble()) + Settings.BubbleSize * scaleFactor;
double initialDirectionX = (Settings.MoveSpeed * scaleFactor * _random.NextDouble()) * (_random.Next(1) == 0 ? -1 : 1);
double initialDirectionY = (Settings.MoveSpeed * scaleFactor - Math.Abs(initialDirectionX)) * (_random.Next(1) == 0 ? -1 : 1);
_bubbles.Add(new Bubble(color, Settings.BubbleSize, new System.Windows.Point(initialPositionX, initialPositionY), new Vector(initialDirectionX, initialDirectionY)));
_bubbles.Add(new Bubble(color, (int)Math.Round(Settings.BubbleSize * scaleFactor),
new System.Windows.Point(initialPositionX, initialPositionY), new Vector(initialDirectionX, initialDirectionY)));
}
Initialized = true;

View File

@ -17,6 +17,7 @@ namespace Artemis.Modules.Effects.Bubbles
public int BubbleSize { get; set; }
public int MoveSpeed { get; set; }
public int BubbleCount { get; set; }
public int Smoothness { get; set; }
public sealed override void Load()
{
@ -27,6 +28,7 @@ namespace Artemis.Modules.Effects.Bubbles
BubbleSize = Bubbles.Default.BubbleSize;
MoveSpeed = Bubbles.Default.MoveSpeed;
BubbleCount = Bubbles.Default.BubbleCount;
Smoothness = Bubbles.Default.Smoothness;
}
public sealed override void Save()
@ -38,6 +40,7 @@ namespace Artemis.Modules.Effects.Bubbles
Bubbles.Default.BubbleSize = BubbleSize;
Bubbles.Default.MoveSpeed = MoveSpeed;
Bubbles.Default.BubbleCount = BubbleCount;
Bubbles.Default.Smoothness = Smoothness;
Bubbles.Default.Save();
}
@ -51,6 +54,7 @@ namespace Artemis.Modules.Effects.Bubbles
BubbleSize = 25;
MoveSpeed = 4;
BubbleCount = 14;
Smoothness = 25;
}
}
}

View File

@ -24,6 +24,7 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
@ -119,9 +120,19 @@
HorizontalAlignment="Right" Width="110" TickPlacement="None" TickFrequency="1"
Value="{Binding Path=EffectSettings.MoveSpeed, Mode=TwoWay}" Minimum="1" Maximum="15"
SmallChange="10" IsSnapToTickEnabled="True" />
<!-- Smoothness -->
<TextBlock Grid.Row="9" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center"
Height="16" Margin="0,9,0,10">
Smoothness
</TextBlock>
<Slider x:Name="Smoothness" Grid.Row="9" Grid.Column="1" VerticalAlignment="Center"
HorizontalAlignment="Right" Width="110" TickPlacement="None" TickFrequency="1"
Value="{Binding Path=EffectSettings.Smoothness, Mode=TwoWay}" Minimum="1" Maximum="100"
SmallChange="10" IsSnapToTickEnabled="True" />
<!-- Buttons -->
<StackPanel Grid.Column="0" Grid.Row="9" Orientation="Horizontal" VerticalAlignment="Bottom">
<StackPanel Grid.Column="0" Grid.Row="10" Orientation="Horizontal" VerticalAlignment="Bottom">
<Button x:Name="ResetSettings" Content="Reset effect" VerticalAlignment="Top" Width="100"
Style="{DynamicResource SquareButtonStyle}" />
<Button x:Name="SaveSettings" Content="Save changes" VerticalAlignment="Top" Width="100"