Skip to content

Commit

Permalink
For v0.1.1
Browse files Browse the repository at this point in the history
- Add flag: rejecting auto-detection of broadcaster
- Fix bug: when fix overlay without focus of main window
- Fix bug: wrong monitor value adjustment
  • Loading branch information
SemiRain committed Feb 21, 2019
1 parent 8a57964 commit 53c15c6
Show file tree
Hide file tree
Showing 5 changed files with 200 additions and 100 deletions.
18 changes: 16 additions & 2 deletions bayoen-star-exe/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,22 @@

<mtc:Flyout x:Name="StreamingFlyout" Header="Streaming Now?" Position="Left" Width="{Binding Width, ElementName=BayoenWindow}">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
<Button x:Name="StreamingYesButton" Content="Yes" Height="35" Width="100" Margin="6" Style="{DynamicResource AccentedSquareButtonStyle}" VerticalAlignment="Center"/>
<Button x:Name="StreamingNoButton" Content="No" Height="35" Width="100" Margin="6" Style="{DynamicResource SquareButtonStyle}" VerticalAlignment="Center"/>
<StackPanel.Resources>
<Style BasedOn="{StaticResource {x:Type TextBlock}}" TargetType="TextBlock">
<Setter Property="FontSize" Value="14"/>
<Setter Property="FontWeight" Value="Bold"/>
</Style>
</StackPanel.Resources>

<Button x:Name="StreamingYesButton" Height="35" Width="100" Margin="6" Style="{DynamicResource AccentedSquareButtonStyle}" VerticalAlignment="Center">
<TextBlock Text="Yes"/>
</Button>
<Button x:Name="StreamingNoButton" Height="35" Width="100" Margin="6" Style="{DynamicResource SquareButtonStyle}" VerticalAlignment="Center">
<TextBlock Text="No"/>
</Button>
<Button x:Name="StreamingNeverButton" Height="35" Width="100" Margin="6" Style="{DynamicResource SquareButtonStyle}" VerticalAlignment="Center">
<TextBlock Text="Never"/>
</Button>
</StackPanel>
</mtc:Flyout>
</mtc:FlyoutsControl>
Expand Down
222 changes: 153 additions & 69 deletions bayoen-star-exe/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public MainWindow()
public wf::NotifyIcon Notify;
public MetroWindow Setting;
public ComboBox ClosingEventComboBox;
public CheckBox IgnoreBroadcasterCheckBox;
public ComboBox ChromaKeyComboBox;
public MetroWindow Overlay;

Expand Down Expand Up @@ -340,6 +341,13 @@ void InitializeFlyout()
this.StreamingFlyout.IsOpen = false;
};

this.StreamingNeverButton.Click += (sender, e) =>
{
this.StreamingFlyout.IsOpen = false;
this.preferences.IsNoAutoDetect = true;
this.IgnoreBroadcasterCheckBox.IsChecked = true;
};

// for Goal
this.GoalTypeTextBlock.ToolTip = "Games until TOTAL N-scores for two player; 합계 N점이 될 때까지 게임합니다" +
Environment.NewLine + "Games until FIRST N-score for any player; 누군가 먼저 N점이 될 때까지 게임합니다";
Expand Down Expand Up @@ -418,69 +426,13 @@ void InitializeFlyout()

void InitializeTopMenu()
{
#region [Reset Menu]
MenuItem ResetMenuItem = BuildMenu("Reset", "appbar_new");
ResetMenuItem.Click += ResetMenuItem_ClickAsync;
this.TopCompositeCollection.Add(ResetMenuItem);
#endregion

MenuItem GoalMenuItem = BuildMenu("Goal", "appbar_controller_xbox");
this.TopCompositeCollection.Add(GoalMenuItem);

List<MenuItem> GoalItems = new List<MenuItem>();
MenuItem SetGoalItem = new MenuItem()
{
Header = "Set...",
ToolTip = "Set goal with its score and type; 목표를 입력하고 설정합니다",
};
SetGoalItem.Click += (sender, e) =>
{
this.GoalFlyout.IsOpen = true;
};
GoalItems.Add(SetGoalItem);

MenuItem RemoveGoalItem = new MenuItem()
{
Header = "Remove",
ToolTip = "Remove goal; 목표를 취소합니다",
};
RemoveGoalItem.Click += (sender, e) =>
{
this.preferences.GoalType = GoalTypes.None;
this.preferences.GoalCounter = GoalCounters.Star;
this.preferences.GoalScore = 0;

this.GoalScore = this.preferences.GoalScore.Value;
this.GoalCounter = this.preferences.GoalCounter.Value;
this.GoalType = this.preferences.GoalType.Value;
};
GoalItems.Add(RemoveGoalItem);
GoalMenuItem.ItemsSource = GoalItems;

if (this.preferences.GoalType == null)
{
this.preferences.GoalType = GoalTypes.None;
}

if (this.preferences.GoalCounter == null)
{
this.preferences.GoalCounter = GoalCounters.Star;
}
if (this.preferences.GoalScore == null)
{
this.preferences.GoalScore = 0;
}

this.GoalTypeComboBox.SelectedIndex = (int)this.preferences.GoalType.Value;
this.GoalCounterComboBox.SelectedIndex = (int)this.preferences.GoalCounter.Value;
this.GoalScoreNumericUpDown.Value = this.preferences.GoalScore.Value;

MenuItem OverlayMenuItem = BuildMenu("Overlay", "appbar_app_plus");
OverlayMenuItem.Click += OverlayMenuItem_Click;
this.TopCompositeCollection.Add(OverlayMenuItem);

MenuItem SettingMenuItem = BuildMenu("Settings", "appbar_settings");
SettingMenuItem.Click += SettingMenuItem_Click;
this.TopCompositeCollection.Add(SettingMenuItem);

#region [Mode Menu]
MenuItem ModeMenuItem = BuildMenu("Mode", "appbar_list");
this.TopCompositeCollection.Add(ModeMenuItem);

Expand Down Expand Up @@ -582,7 +534,72 @@ void InitializeTopMenu()
int modeIndex = (int)this.preferences.DisplayMode.Value;
(ModeItems[modeIndex] as MenuItem).IsChecked = true;
}
#endregion

#region [Goal Menu]
MenuItem GoalMenuItem = BuildMenu("Goal", "appbar_controller_xbox");
this.TopCompositeCollection.Add(GoalMenuItem);

List<MenuItem> GoalItems = new List<MenuItem>();
MenuItem SetGoalItem = new MenuItem()
{
Header = "Set...",
ToolTip = "Set goal with its score and type; 목표를 입력하고 설정합니다",
};
SetGoalItem.Click += (sender, e) =>
{
this.GoalFlyout.IsOpen = true;
};
GoalItems.Add(SetGoalItem);

MenuItem RemoveGoalItem = new MenuItem()
{
Header = "Remove",
ToolTip = "Remove goal; 목표를 취소합니다",
};
RemoveGoalItem.Click += (sender, e) =>
{
this.preferences.GoalType = GoalTypes.None;
this.preferences.GoalCounter = GoalCounters.Star;
this.preferences.GoalScore = 0;

this.GoalScore = this.preferences.GoalScore.Value;
this.GoalCounter = this.preferences.GoalCounter.Value;
this.GoalType = this.preferences.GoalType.Value;
};
GoalItems.Add(RemoveGoalItem);
GoalMenuItem.ItemsSource = GoalItems;

if (this.preferences.GoalType == null)
{
this.preferences.GoalType = GoalTypes.None;
}

if (this.preferences.GoalCounter == null)
{
this.preferences.GoalCounter = GoalCounters.Star;
}
if (this.preferences.GoalScore == null)
{
this.preferences.GoalScore = 0;
}

this.GoalTypeComboBox.SelectedIndex = (int)this.preferences.GoalType.Value;
this.GoalCounterComboBox.SelectedIndex = (int)this.preferences.GoalCounter.Value;
this.GoalScoreNumericUpDown.Value = this.preferences.GoalScore.Value;
#endregion

#region [Overlay Menu]
MenuItem OverlayMenuItem = BuildMenu("Overlay", "appbar_app_plus");
OverlayMenuItem.Click += OverlayMenuItem_Click;
this.TopCompositeCollection.Add(OverlayMenuItem);
#endregion

#region [Setting Menu]
MenuItem SettingMenuItem = BuildMenu("Settings", "appbar_settings");
SettingMenuItem.Click += SettingMenuItem_Click;
this.TopCompositeCollection.Add(SettingMenuItem);
#endregion

MenuItem BuildMenu(string header, string appbar)
{
Expand Down Expand Up @@ -739,7 +756,7 @@ void InitializeSettingWindow()

if (this.preferences.ClosingEvent == null)
{
ClosingEventComboBox.SelectedIndex = -1;
ClosingEventComboBox.SelectedIndex = 0;
}
else
{
Expand All @@ -766,6 +783,22 @@ void InitializeSettingWindow()
};
StreamingGroupBox.Content = StreamingGroupPanel;

this.IgnoreBroadcasterCheckBox = new CheckBox()
{
Content = "Disable auto-detcting broadcasters",
Margin = new Thickness(5),
ToolTip = "방송 송출프로그램을 자동감지하지 않습니다",
};
this.IgnoreBroadcasterCheckBox.Click += (sender, e) =>
{
this.preferences.IsNoAutoDetect = !this.preferences.IsNoAutoDetect;
};
if (this.preferences.IsNoAutoDetect == null)
{
this.preferences.IsNoAutoDetect = false;
}
this.IgnoreBroadcasterCheckBox.IsChecked = this.preferences.IsNoAutoDetect.Value;
StreamingGroupPanel.Children.Add(this.IgnoreBroadcasterCheckBox);

CheckBox HideOfflineCheckBox = new CheckBox()
{
Expand Down Expand Up @@ -1285,13 +1318,23 @@ void InitializeDisplay()
this.Overlay.ContextMenu = new ContextMenu();
MenuItem OverlayFixMenu = new MenuItem()
{
Header = "Fixed",
Header = "Fix",
IsCheckable = true,
};
OverlayFixMenu.Click += (sender, e) =>
{
this.preferences.IsOverlayFixed = !this.preferences.IsOverlayFixed;
OverlayFixMenu.IsChecked = this.preferences.IsOverlayFixed.Value;
int style = GetWindowLong(this.PPTProcesses.Single().MainWindowHandle, (int)GWL.GWL_STYLE);
if ((style & (uint)WS.WS_MINIMIZE) == (uint)WS.WS_MINIMIZE)
{
System.Media.SystemSounds.Hand.Play();
OverlayFixMenu.IsChecked = false;
return;
}
else
{
this.preferences.IsOverlayFixed = !this.preferences.IsOverlayFixed;
OverlayFixMenu.IsChecked = this.preferences.IsOverlayFixed.Value;
}
};
this.Overlay.ContextMenu.Items.Add(OverlayFixMenu);

Expand Down Expand Up @@ -1546,7 +1589,9 @@ private void CountingStars()

private void CheckStreaming()
{
if (this.StreamAskFlag) return;
if (this.StreamAskFlag) return;

if (this.preferences.IsNoAutoDetect.Value) return;

this.StreamingRing++;

Expand Down Expand Up @@ -1654,15 +1699,34 @@ string SetText(int number)

private void FromMonitors()
{
this.countingStar[0] = int.Parse(this.Monitors[2].Text);
this.countingStar[1] = int.Parse(this.Monitors[3].Text);
this.countingCrown[0] = int.Parse(this.Monitors[4].Text);
this.countingCrown[1] = int.Parse(this.Monitors[5].Text);
int tempStar0 = this.countingStar[0];
int tempStar1 = this.countingStar[1];
int tempCrown0 = this.countingCrown[0];
int tempCrown1 = this.countingCrown[1];

try
{
this.countingStar[0] = int.Parse(this.Monitors[2].Text);
this.countingStar[1] = int.Parse(this.Monitors[3].Text);
this.countingCrown[0] = int.Parse(this.Monitors[4].Text);
this.countingCrown[1] = int.Parse(this.Monitors[5].Text);
}
catch
{
this.countingStar[0] = tempStar0;
this.countingStar[1] = tempStar1;
this.countingCrown[0] = tempCrown0;
this.countingCrown[1] = tempCrown1;
System.Media.SystemSounds.Hand.Play();
}
}

private void CheckOverlay()
{
GetWindowRect(this.PPTProcesses.Single().MainWindowHandle, ref this.currentRect);
if (this.PPTProcesses.Length == 1)
{
GetWindowRect(this.PPTProcesses.Single().MainWindowHandle, ref this.currentRect);
}

this.FixOverlay();

Expand Down Expand Up @@ -1958,6 +2022,26 @@ public RECT(RECT rect)
[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern bool GetWindowRect(IntPtr hwnd, ref RECT rectangle);

[System.Runtime.InteropServices.DllImport("user32.dll", SetLastError = true)]
public static extern int GetWindowLong(IntPtr hWnd, int nIndex);

public enum GWL : int
{
GWL_WNDPROC = (-4),
GWL_HINSTANCE = (-6),
GWL_HWNDPARENT = (-8),
GWL_STYLE = (-16),
GWL_EXSTYLE = (-20),
GWL_USERDATA = (-21),
GWL_ID = (-12)
}

public enum WS : uint
{
WS_MINIMIZE = 0x20000000,

}

private void Status(string s)
{
this.StatusTextBlock.Text = s + versionText;
Expand Down
2 changes: 2 additions & 0 deletions bayoen-star-exe/Preferences.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class Preferences
public bool? IsFitToScore;
public bool? IsOverlayFixed;
public bool? IsNoAutoUpdate;
public bool? IsNoAutoDetect;
public DisplayModes? DisplayMode;

public GoalTypes? GoalType;
Expand Down Expand Up @@ -51,6 +52,7 @@ public void Clear()
this.IsFitToScore = null;
this.IsOverlayFixed = null;
this.IsNoAutoUpdate = null;
this.IsNoAutoDetect = null;

this.Overlay = null;
this.DisplayMode = null;
Expand Down
4 changes: 2 additions & 2 deletions bayoen-star-exe/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.1.0.5")]
[assembly: AssemblyFileVersion("0.1.0.5")]
[assembly: AssemblyVersion("0.1.1.0")]
[assembly: AssemblyFileVersion("0.1.1.0")]
Loading

0 comments on commit 53c15c6

Please sign in to comment.