Skip to content

Commit

Permalink
Initial 0.1.0.0 Release
Browse files Browse the repository at this point in the history
Added config file.
Can change keybinds.
Can specify mounts
  • Loading branch information
trigger-segfault committed Aug 11, 2017
1 parent dcdee1d commit 0c39cc9
Show file tree
Hide file tree
Showing 12 changed files with 648 additions and 137 deletions.
1 change: 1 addition & 0 deletions TerrariaMidiPlayer/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:TerrariaMidiPlayer"
DispatcherUnhandledException="OnDispatcherUnhandledException"
StartupUri="MainWindow.xaml">
<Application.Resources>

Expand Down
6 changes: 6 additions & 0 deletions TerrariaMidiPlayer/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Threading;

namespace TerrariaMidiPlayer {
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application {
private void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) {
if (ErrorMessageBox.Show(e.Exception))
Environment.Exit(0);
e.Handled = true;
}
}
}
23 changes: 23 additions & 0 deletions TerrariaMidiPlayer/ChangeKeybindsDialog.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Window x:Class="TerrariaMidiPlayer.ChangeKeybindsDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:TerrariaMidiPlayer"
mc:Ignorable="d"
Title="Change Keybinds" Height="246" Width="300" Background="#FFF9F9F9" Icon="Resources/Icons/Keybinds.png" SnapsToDevicePixels="True" UseLayoutRounding="True" ResizeMode="NoResize" WindowStartupLocation="CenterOwner">
<Grid>
<local:KeybindReader x:Name="keybindReaderPlay" Margin="74,22,0,0" />
<Button Content="Cancel" HorizontalAlignment="Right" Margin="0,0,10,10" VerticalAlignment="Bottom" Width="75" IsCancel="True"/>
<Button Content="OK" HorizontalAlignment="Right" Margin="0,0,95,10" VerticalAlignment="Bottom" Width="75" IsDefault="True" Click="OnOKClicked"/>
<Label Content="Play" HorizontalAlignment="Left" Margin="37,20,0,0" VerticalAlignment="Top"/>
<Label Content="Pause" HorizontalAlignment="Left" Margin="28,51,0,0" VerticalAlignment="Top"/>
<Label Content="Stop" HorizontalAlignment="Left" Margin="34,82,0,0" VerticalAlignment="Top"/>
<Label Content="Close" HorizontalAlignment="Left" Margin="28,123,0,0" VerticalAlignment="Top"/>
<local:KeybindReader x:Name="keybindReaderPause" Margin="74,53,0,0" />
<local:KeybindReader x:Name="keybindReaderStop" Margin="74,84,0,0" />
<Separator Height="7" Margin="20,113,20,0" VerticalAlignment="Top"/>
<local:KeybindReader x:Name="keybindReaderClose" Margin="74,125,0,0" />

</Grid>
</Window>
47 changes: 47 additions & 0 deletions TerrariaMidiPlayer/ChangeKeybindsDialog.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace TerrariaMidiPlayer {
/// <summary>
/// Interaction logic for EditKeybindsDialog.xaml
/// </summary>
public partial class ChangeKeybindsDialog : Window {

public ChangeKeybindsDialog(Keybind play, Keybind pause, Keybind stop, Keybind close) {
InitializeComponent();
keybindReaderPlay.Keybind = play;
keybindReaderPause.Keybind = pause;
keybindReaderStop.Keybind = stop;
keybindReaderClose.Keybind = close;
}

private void OnOKClicked(object sender, RoutedEventArgs e) {
DialogResult = true;
}

public static bool ShowDialog(Window owner, ref Keybind play, ref Keybind pause, ref Keybind stop, ref Keybind close) {
ChangeKeybindsDialog window = new ChangeKeybindsDialog(play, pause, stop, close);
window.Owner = owner;
var result = window.ShowDialog();
if (result != null && result.Value) {
play = window.keybindReaderPlay.Keybind;
pause = window.keybindReaderPause.Keybind;
stop = window.keybindReaderStop.Keybind;
close = window.keybindReaderClose.Keybind;
return true;
}
return false;
}
}
}
2 changes: 1 addition & 1 deletion TerrariaMidiPlayer/EditNameDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:TerrariaMidiPlayer"
mc:Ignorable="d"
Title="Edit Name" Height="132.57" Width="300" Background="#FFEEEEEE" Icon="Resources/Icons/EditName.png" PreviewKeyDown="OnPreviewKeyDown">
Title="Edit Name" Height="132.57" Width="300" Background="#FFF9F9F9" Icon="Resources/Icons/EditName.png" PreviewKeyDown="OnPreviewKeyDown" WindowStartupLocation="CenterOwner">
<Grid>
<TextBox x:Name="textBox" Height="23" Margin="20,25,20,0" TextWrapping="Wrap" VerticalAlignment="Top"/>
<Button Content="Cancel" HorizontalAlignment="Right" Margin="0,0,10,10" VerticalAlignment="Bottom" Width="75" IsCancel="True"/>
Expand Down
2 changes: 1 addition & 1 deletion TerrariaMidiPlayer/ErrorMessageBox.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<TextBlock TextWrapping="WrapWithOverflow" Text="Unhandled Exception in Terraria Midi Player!" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="#FF952727" FontWeight="Bold"/>
</Label>
<Label HorizontalAlignment="Right" Margin="0,10,18,0" VerticalAlignment="Top" FontWeight="Bold">
<Hyperlink NavigateUri="https://github.com/trigger-death/TriggersNotepad" RequestNavigate="OnRequestNavigate">
<Hyperlink NavigateUri="https://github.com/trigger-death/TerrariaMidiPlayer" RequestNavigate="OnRequestNavigate">
<Run Text="Github Page"/>
</Hyperlink>
</Label>
Expand Down
2 changes: 1 addition & 1 deletion TerrariaMidiPlayer/KeybindReader.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
d:DesignHeight="300" HorizontalAlignment="Left" VerticalAlignment="Top" Height="22" Width="180" Focusable="True" Loaded="OnLoaded">
<Grid>
<Border Background="#FFEEEEEE" BorderBrush="#FF828790" BorderThickness="1" />
<ToggleButton x:Name="buttonKeybind" Content="unused" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Style="{StaticResource {x:Static ToolBar.ToggleButtonStyleKey}}" ToolTip="Edit Keybind" Focusable="False" IsTabStop="False" Padding="0" Click="OnButtonClicked"/>
<ToggleButton x:Name="buttonKeybind" Content="&lt;No Keybind&gt;" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Style="{StaticResource {x:Static ToolBar.ToggleButtonStyleKey}}" ToolTip="Edit Keybind" Focusable="False" IsTabStop="False" Padding="0" Click="OnButtonClicked"/>
</Grid>
<!--BorderBrush="#FF989EA5" BorderThickness="1" Background="#FFE8EAEC"-->
</UserControl>
51 changes: 50 additions & 1 deletion TerrariaMidiPlayer/KeybindReader.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ namespace TerrariaMidiPlayer {


public struct Keybind {

public static Keybind None {
get { return new Keybind(Key.None); }
}

public Key Key;
public ModifierKeys Modifiers;

Expand All @@ -42,6 +47,50 @@ public struct Keybind {
mods |= Keys.Alt;
return (e.KeyCode == (Keys)KeyInterop.VirtualKeyFromKey(Key) && e.Modifiers == mods);
}

public static bool operator ==(Keybind a, Keybind b) {
return (a.Key == b.Key && (a.Modifiers == b.Modifiers || (a.Key == Key.None && b.Key == Key.None)));
}
public static bool operator !=(Keybind a, Keybind b) {
return (a.Key != b.Key || (a.Modifiers != b.Modifiers && (a.Key != Key.None || b.Key != Key.None)));
}

public override string ToString() {
string str = "";
if (Modifiers.HasFlag(ModifierKeys.Control))
str += "Ctrl+";
if (Modifiers.HasFlag(ModifierKeys.Shift))
str += "Shift+";
if (Modifiers.HasFlag(ModifierKeys.Alt))
str += "Alt+";
str += Key.ToString();
return str;
}

public static bool TryParse(string s, out Keybind keybind) {
Key key = Key.None;
ModifierKeys modifiers = ModifierKeys.None;
for (int i = 0; i < 3; i++) {
if (!modifiers.HasFlag(ModifierKeys.Control) && s.StartsWith("Ctrl+", StringComparison.InvariantCultureIgnoreCase)) {
modifiers |= ModifierKeys.Control;
s = s.Substring(5);
}
if (!modifiers.HasFlag(ModifierKeys.Shift) && s.StartsWith("Shift+", StringComparison.InvariantCultureIgnoreCase)) {
modifiers |= ModifierKeys.Shift;
s = s.Substring(6);
}
if (!modifiers.HasFlag(ModifierKeys.Alt) && s.StartsWith("Alt+", StringComparison.InvariantCultureIgnoreCase)) {
modifiers |= ModifierKeys.Alt;
s = s.Substring(4);
}
}
if (Enum.TryParse<Key>(s, out key)) {
keybind = new Keybind(key, modifiers);
return true;
}
keybind = Keybind.None;
return false;
}
}

/// <summary>
Expand Down Expand Up @@ -163,7 +212,7 @@ public enum MapType : uint {
char mappedChar = Char.ToUpper(GetCharFromKey(key));
if (key >= Key.NumPad0 && key <= Key.NumPad9)
mappedChar = '\0';
if (mappedChar >= 32) {
if (mappedChar > 32) { // Yes, exclude space
displayString += mappedChar;
}
else if (key == Key.System) {
Expand Down
33 changes: 18 additions & 15 deletions TerrariaMidiPlayer/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:TerrariaMidiPlayer"
mc:Ignorable="d"
Title="Terraria Midi Player" Height="366" Width="525" Closing="OnWindowClosing" Icon="App.ico" ResizeMode="CanMinimize" SnapsToDevicePixels="True" UseLayoutRounding="True" Loaded="OnLoaded" Background="#FFCFCCC8">
Title="Terraria Midi Player" Height="366" Width="525" Closing="OnClosing" Icon="App.ico" ResizeMode="CanMinimize" SnapsToDevicePixels="True" UseLayoutRounding="True" Loaded="OnLoaded" Background="#FFCFCCC8">
<Window.Resources>
<Style TargetType="ListBox">
<Style.Resources>
Expand Down Expand Up @@ -36,47 +36,47 @@
</LinearGradientBrush>
</Menu.Background>
<MenuItem Header="File">
<MenuItem Header="Exit">
<MenuItem Header="Exit" Click="OnExit">
<MenuItem.Icon>
<Image Source="/TerrariaMidiPlayer;component/Resources/Icons/Exit.png" />
</MenuItem.Icon>
</MenuItem>
</MenuItem>
<MenuItem Header="Options">
<MenuItem Header="Overlay" IsChecked="True" IsCheckable="True">
<MenuItem Header="Overlay" IsChecked="True" IsCheckable="True" Visibility="Collapsed">
<MenuItem.Icon>
<Image Source="Resources/Icons/Overlay.png" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Keybinds...">
<MenuItem Header="Keybinds..." Click="OnChangeKeybinds">
<MenuItem.Icon>
<Image Source="Resources/Icons/Keybinds.png" />
</MenuItem.Icon>
</MenuItem>
</MenuItem>

<MenuItem Header="Help">
<MenuItem Header="About">
<MenuItem Header="About" Visibility="Collapsed">
<MenuItem.Icon>
<Image Source="/TerrariaMidiPlayer;component/Resources/Icons/About.png" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Credits">
<MenuItem Header="Credits" Visibility="Collapsed">
<MenuItem.Icon>
<Image Source="/TerrariaMidiPlayer;component/Resources/Icons/Credits.png" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Open Readme">
<MenuItem Header="Open Readme" Visibility="Collapsed">
<MenuItem.Icon>
<Image Source="/TerrariaMidiPlayer;component/Resources/Icons/Readme.png" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Open Changelog">
<MenuItem Header="Open Changelog" Visibility="Collapsed">
<MenuItem.Icon>
<Image Source="/TerrariaMidiPlayer;component/Resources/Icons/Changelog.png" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="View on GitHub">
<MenuItem Header="View on GitHub" Click="OnOpenOnGitHub">
<MenuItem.Icon>
<Image Source="/TerrariaMidiPlayer;component/Resources/Icons/Github.png" />
</MenuItem.Icon>
Expand Down Expand Up @@ -158,21 +158,23 @@

<local:ProjectileControl x:Name="projectileControl" Margin="0,0,10,10" ProjectilesChanged="OnProjectileChanged" VerticalAlignment="Bottom" HorizontalAlignment="Right"/>

<Label Content="Use Time" HorizontalAlignment="Right" Margin="0,15,81,0" VerticalAlignment="Top"/>
<Label Content="Use Time" HorizontalAlignment="Right" Margin="0,15,81,0" VerticalAlignment="Top" ToolTip="Instrument use time in frames"/>
<local:NumericUpDown x:Name="numericUseTime" Margin="0,17,10,0" HorizontalAlignment="Right" VerticalAlignment="Top" Width="66" Increment="1" Maximum="100" Minimum="3" Value="3" ErrorValue="12" ValueChanged="OnUseTimeChanged"/>
<local:NumericUpDown x:Name="numericChecks" Margin="0,71,10,0" HorizontalAlignment="Right" VerticalAlignment="Top" Width="66" Increment="1" Maximum="1000" Value="0" ValueChanged="OnChecksChanged"/>
<CheckBox x:Name="checkBoxChecks" Content="Checks" HorizontalAlignment="Right" Margin="0,75,81,0" VerticalAlignment="Top" Click="OnChecksEnabledClicked" IsChecked="True" Padding="4,-1,5,0"/>
<CheckBox x:Name="checkBoxChecks" Content="Checks" HorizontalAlignment="Right" Margin="0,75,81,0" VerticalAlignment="Top" Click="OnChecksEnabledClicked" IsChecked="True" Padding="4,-1,5,0" ToolTip="Checks to make sure Terraria is the active window when playing a song. The higher the number, the more notes will pass before it checks again."/>
<local:NumericUpDown x:Name="numericClickTime" Margin="0,44,10,0" HorizontalAlignment="Right" VerticalAlignment="Top" Width="66" Increment="1" Maximum="100" Value="40" ValueChanged="OnClickTimeChanged" Minimum="18"/>
<Label Content="Click Time" HorizontalAlignment="Right" Margin="0,42,76,0" VerticalAlignment="Top"/>
<Label Content="Click Time" HorizontalAlignment="Right" Margin="0,42,81,0" VerticalAlignment="Top" ToolTip="The duration the mouse is held down for in milliseconds"/>
<ComboBox x:Name="comboBoxMount" HorizontalAlignment="Right" Margin="0,107,10,0" VerticalAlignment="Top" Width="100" SelectionChanged="OnMountChanged"/>
<Label Content="Mount" HorizontalAlignment="Right" Margin="0,105,115,0" VerticalAlignment="Top" ToolTip="Needed to calculate the center of the player."/>
</Grid>
</TabItem>
<TabItem Header="Midi Setup">
<Grid Background="#FFF9F9F9">
<Label Content="Tracks" HorizontalAlignment="Left" Margin="10,5,0,0" VerticalAlignment="Top"/>
<ListBox x:Name="listTracks" Margin="10,32,197,125" SelectionChanged="OnTrackChanged"/>
<Separator Height="7" Margin="10,157,10,0" VerticalAlignment="Top"/>
<Label x:Name="labelTotalNotes" Content="Total Notes: 0" HorizontalAlignment="Left" Margin="10,170,0,0" VerticalAlignment="Top"/>
<Label x:Name="labelDuration" Content="Duration: 0:00" HorizontalAlignment="Left" Margin="10,196,0,0" VerticalAlignment="Top"/>
<Label x:Name="labelTotalNotes" Content="Total Notes:" HorizontalAlignment="Left" Margin="10,198,0,0" VerticalAlignment="Top"/>
<Label x:Name="labelDuration" Content="Duration: 0:00" HorizontalAlignment="Left" Margin="10,196,0,0" VerticalAlignment="Top" Visibility="Hidden"/>
<local:NumericUpDown x:Name="numericNoteOffset" Margin="0,170,10,0" HorizontalAlignment="Right" VerticalAlignment="Top" Width="66" Increment="1" Maximum="11" Value="0" ValueChanged="OnNoteOffsetChanged" Minimum="-11"/>
<Label Content="Note Offset" HorizontalAlignment="Right" Margin="0,168,81,0" VerticalAlignment="Top"/>
<Label x:Name="labelNotes" Content="Notes: 0" HorizontalAlignment="Left" Margin="115,84,0,0" VerticalAlignment="Top"/>
Expand All @@ -183,8 +185,9 @@
<CheckBox x:Name="checkBoxTrackEnabled" Content="Enabled" HorizontalAlignment="Right" Margin="0,107,14,0" VerticalAlignment="Top" Click="OnTrackEnabledClicked" IsChecked="True" Padding="4,-1,5,0" RenderTransformOrigin="0.516,5.667"/>
<local:NumericUpDown x:Name="numericSpeed" Margin="0,200,10,0" HorizontalAlignment="Right" VerticalAlignment="Top" Width="66" Increment="1" Maximum="10000" Value="100" ValueChanged="OnSpeedChanged" Minimum="1"/>
<Label Content="Speed (%)" HorizontalAlignment="Right" Margin="0,198,81,0" VerticalAlignment="Top"/>
<local:KeybindReader x:Name="keybindReaderTrack" Margin="0,231,10,0" HorizontalAlignment="Right" KeybindChanged="OnMidiKeybindChanged"/>
<local:KeybindReader x:Name="keybindReaderMidi" Margin="0,231,10,0" HorizontalAlignment="Right" KeybindChanged="OnMidiKeybindChanged"/>
<Label Content="Keybind" HorizontalAlignment="Right" Margin="0,229,195,0" VerticalAlignment="Top"/>
<Label Content="Midi" HorizontalAlignment="Left" Margin="10,168,0,0" VerticalAlignment="Top"/>
</Grid>
</TabItem>
</TabControl>
Expand Down
Loading

0 comments on commit 0c39cc9

Please sign in to comment.