Skip to content

Commit

Permalink
Fixed setting saving for HomeButtonNavigation.
Browse files Browse the repository at this point in the history
Fixed filtering on initial start as timer would not be started and disallow filter input.
HomeButtonNavigation changed to allow navigation to home via either dedicated home button or "H" key.
  • Loading branch information
RickDB authored and RickDB committed Dec 28, 2016
1 parent 613f679 commit 4aa803c
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 36 deletions.
8 changes: 4 additions & 4 deletions MyAnimePlugin3/ConfigFiles/AnimePluginSettings.cs
Expand Up @@ -440,8 +440,8 @@ public void Load()

ModeToggleKey = xmlreader.GetValueAsString("Anime3", "ModeToggleKey", "]");
StartTextToggleKey = xmlreader.GetValueAsString("Anime3", "StartTextToggleKey", "[");
AskBeforeStartStreamingPlayback = xmlreader.GetValueAsBool("Anime3", "AskBeforeStartStreamingPlayback", true);
HomeButtonNavigation = xmlreader.GetValueAsBool("Anime3", "HomeButtonNavigation", true);
AskBeforeStartStreamingPlayback = GetBooleanSetting(ref xmlreader, "AskBeforeStartStreamingPlayback", true);
HomeButtonNavigation = GetBooleanSetting(ref xmlreader, "HomeButtonNavigation", true);

_subPaths = xmlreader.GetValueAsString("subtitles", "paths", @".\");
xmlreader.Dispose();
Expand Down Expand Up @@ -539,8 +539,8 @@ public void Save()
xmlwriter.SetValue("Anime3", "FfdshowNotificationsLockTime", ((int)FfdshowNotificationsLockTime).ToString());
xmlwriter.SetValue("Anime3", "ModeToggleKey", ModeToggleKey);
xmlwriter.SetValue("Anime3", "StartTextToggleKey", StartTextToggleKey);
xmlwriter.SetValue("Anime3", "AskBeforeStartStreamingPlayback", AskBeforeStartStreamingPlayback);
xmlwriter.SetValue("Anime3", "HomeButtonNavigation", HomeButtonNavigation);
xmlwriter.SetValue("Anime3", "AskBeforeStartStreamingPlayback", AskBeforeStartStreamingPlayback ? "1" : "0");
xmlwriter.SetValue("Anime3", "HomeButtonNavigation", HomeButtonNavigation ? "1" : "0");

string pth = Path.GetTempPath();
if (!_subPaths.Contains(pth))
Expand Down
95 changes: 63 additions & 32 deletions MyAnimePlugin3/Windows/MainWindow.cs
Expand Up @@ -2444,6 +2444,14 @@ public override void OnAction(MediaPortal.GUI.Library.Action action)

switch (action.wID)
{

case MediaPortal.GUI.Library.Action.ActionType.ACTION_SWITCH_HOME:
if (!BaseConfig.Settings.HomeButtonNavigation)
{
base.OnAction(action);

}
break;
case MediaPortal.GUI.Library.Action.ActionType.ACTION_MOVE_DOWN:
case MediaPortal.GUI.Library.Action.ActionType.ACTION_MOVE_UP:

Expand Down Expand Up @@ -2477,13 +2485,10 @@ public override void OnAction(MediaPortal.GUI.Library.Action action)
return;

case MediaPortal.GUI.Library.Action.ActionType.ACTION_HOME:
if (BaseConfig.Settings.HomeButtonNavigation)
{
UpdateSearchPanel(false);
ImageAllocator.FlushAll();
GUIWindowManager.ShowPreviousWindow();
}
break;
UpdateSearchPanel(false);
ImageAllocator.FlushAll();
GUIWindowManager.ShowPreviousWindow();
break;

case MediaPortal.GUI.Library.Action.ActionType.ACTION_PLAY:
BaseConfig.MyAnimeLog.Write("Received PLAY action");
Expand Down Expand Up @@ -2549,30 +2554,54 @@ public override void OnAction(MediaPortal.GUI.Library.Action action)
}
}

void GUIWindowManager_OnThreadMessageHandler(object sender, GUIMessage message)
{
if (GUIWindowManager.ActiveWindowEx != this.GetID)
void GUIWindowManager_OnThreadMessageHandler(object sender, GUIMessage message)
{
return;
}
if (GUIWindowManager.ActiveWindowEx != this.GetID)
{
return;
}

if (message.Message == GUIMessage.MessageType.GUI_MSG_GOTO_WINDOW &&
message.TargetWindowId == 0 && message.TargetControlId == 0 && message.SenderControlId == 0 &&
message.SendToTargetWindow == false && message.Object == null && message.Object2 == null &&
message.Param2 == 0 && message.Param3 == 0 && message.Param4 == 0 &&
(message.Param1 == (int)GUIWindow.Window.WINDOW_HOME ||
message.Param1 == (int)GUIWindow.Window.WINDOW_SECOND_HOME)
)
{
// Prevent certain messages from beeing sent to MP core
message.SendToTargetWindow = true;
message.TargetWindowId = GetID;
message.Param1 = GetID;
message.Message = GUIMessage.MessageType.GUI_MSG_HIDE_MESSAGE;
//BaseConfig.MyAnimeLog.Write("Message = " + message.Message.ToString());
//BaseConfig.MyAnimeLog.Write("Message param1 = " + message.Param1.ToString());
//BaseConfig.MyAnimeLog.Write("Message param2 = " + message.Param2.ToString());
//BaseConfig.MyAnimeLog.Write("Message param3 = " + message.Param3.ToString());
//BaseConfig.MyAnimeLog.Write("Message param4 = " + message.Param4.ToString());
//BaseConfig.MyAnimeLog.Write("SendToTargetWindow = " + message.SendToTargetWindow.ToString());

if (!BaseConfig.Settings.HomeButtonNavigation)
{
if (message.Param1 == 35 || message.Param1 == 115)
{
// Check if searching and otherwise handle as normal
if (searchTimer != null && !searchTimer.Enabled)
{
//BaseConfig.MyAnimeLog.Write("Search was NOT open so letting command thru");
return;
}
else
{
//BaseConfig.MyAnimeLog.Write("Search was open so cancelling command");
}
}
}

// Prevent certain messages from beeing sent to MP core
if (message.Message == GUIMessage.MessageType.GUI_MSG_GOTO_WINDOW &&
message.TargetWindowId == 0 && message.TargetControlId == 0 && message.SenderControlId == 0 &&
message.SendToTargetWindow == false && message.Object == null && message.Object2 == null &&
message.Param2 == 0 && message.Param3 == 0 && message.Param4 == 0 &&
(message.Param1 == (int) GUIWindow.Window.WINDOW_HOME ||
message.Param1 == (int) GUIWindow.Window.WINDOW_SECOND_HOME)
)
{
message.SendToTargetWindow = true;
message.TargetWindowId = GetID;
message.Param1 = GetID;
message.Message = GUIMessage.MessageType.GUI_MSG_HIDE_MESSAGE;
}
}
}

#region Find
#region Find

#region Keyboard event handling

Expand Down Expand Up @@ -2611,27 +2640,29 @@ public string KeycodeToString(int keyCode)

private void KeyCommandHandler(int keycodeInput)
{
// For some reason keycode [ and ] aren't lining up to their WinForm keycode counterpart so we have this workaround first
char keycode = (char) keycodeInput;
string keycodeString = KeycodeToString(keycodeInput).ToLower();
//BaseConfig.MyAnimeLog.Write("KeyCommandHandler | keycode string: " + keycodeString);
//BaseConfig.MyAnimeLog.Write("KeyCommandHandler | Mode toggle key: " + BaseConfig.Settings.ModeToggleKey);

// Skip key command processing if video window is fullscreen
if (g_Player.FullScreen)
return;

// Delay stopwatch for certain events
if (keyCommandDelayTimer.ElapsedMilliseconds < 5000)
if (keyCommandDelayTimer.IsRunning && keyCommandDelayTimer.ElapsedMilliseconds < 5000)
{
return;
}

keyCommandDelayTimer.Stop();

//when the list is selected, search the input
if ((m_Facade.CurrentLayout == GUIFacadeControl.Layout.List && m_Facade.ListLayout.IsFocused)
|| (m_Facade.CurrentLayout == GUIFacadeControl.Layout.LargeIcons && m_Facade.ThumbnailLayout.IsFocused)
|| (m_Facade.CurrentLayout == GUIFacadeControl.Layout.Filmstrip && m_Facade.FilmstripLayout.IsFocused)
|| (m_Facade.CurrentLayout == GUIFacadeControl.Layout.CoverFlow && m_Facade.CoverFlowLayout.IsFocused))
{
// For some reason keycode [ and ] aren't lining up to their WinForm keycode counterpart so we have this workaround first
char keycode = (char) keycodeInput;
string keycodeString = KeycodeToString(keycodeInput).ToLower();

if (keycodeString == BaseConfig.Settings.ModeToggleKey)
{
Expand Down

0 comments on commit 4aa803c

Please sign in to comment.