Permalink
Browse files

Added better approach to home navigation with custom parameters for e…

…xpansion later (based on IR-Server-Suite).
  • Loading branch information...
RickDB committed Dec 28, 2016
1 parent 4aa803c commit ef8503894a8d69aeb249103a0a2bbd477f0617b6
Showing with 125 additions and 117 deletions.
  1. +3 −1 MyAnimePlugin3/ConfigFiles/AnimePluginSettings.cs
  2. +122 −116 MyAnimePlugin3/Windows/MainWindow.cs
@@ -34,7 +34,8 @@ public class AnimePluginSettings
public string ModeToggleKey = "]";
public string StartTextToggleKey = "[";
private string _subPaths;
public bool HomeButtonNavigation = true;
public bool BasicHome = true;
public bool HomeButtonNavigation = true;
public Dictionary<int, string> ImportFolderMappings
{
@@ -442,6 +443,7 @@ public void Load()
StartTextToggleKey = xmlreader.GetValueAsString("Anime3", "StartTextToggleKey", "[");
AskBeforeStartStreamingPlayback = GetBooleanSetting(ref xmlreader, "AskBeforeStartStreamingPlayback", true);
HomeButtonNavigation = GetBooleanSetting(ref xmlreader, "HomeButtonNavigation", true);
BasicHome = xmlreader.GetValueAsBool("general", "startbasichome", false);
_subPaths = xmlreader.GetValueAsString("subtitles", "paths", @".\");
xmlreader.Dispose();
@@ -2436,122 +2436,140 @@ public override void DeInit()
public override void OnAction(MediaPortal.GUI.Library.Action action)
{
//BaseConfig.MyAnimeLog.Write("Received action: {0}/{1}", action.wID, (char)(action.m_key.KeyChar));
//BaseConfig.MyAnimeLog.Write("Received action: {0} | keychar: {1}", action.wID, (char)(action.m_key.KeyChar));
if (GUIWindowManager.ActiveWindowEx != this.GetID)
{
return;
}
switch (action.wID)
{
case MediaPortal.GUI.Library.Action.ActionType.ACTION_SWITCH_HOME:
if (!BaseConfig.Settings.HomeButtonNavigation)
{
base.OnAction(action);
// Set home window message for use later
var msgHome = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GOTO_WINDOW, 0, 0, 0,
(int) GUIWindow.Window.WINDOW_SECOND_HOME, 00432100, null);
if (BaseConfig.Settings.BasicHome)
msgHome = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GOTO_WINDOW, 0, 0, 0,
(int) GUIWindow.Window.WINDOW_HOME, 00432100, null);
}
break;
case MediaPortal.GUI.Library.Action.ActionType.ACTION_MOVE_DOWN:
case MediaPortal.GUI.Library.Action.ActionType.ACTION_MOVE_UP:
switch (action.wID)
{
case Action.ActionType.ACTION_SWITCH_HOME:
if (!BaseConfig.Settings.HomeButtonNavigation)
{
string keyChar = KeycodeToString(action.m_key.KeyChar);
BaseConfig.MyAnimeLog.Write("Keychar for home: " + keyChar);
if (keyChar.ToLower() != "h")
{
GUIWindowManager.SendThreadMessage(msgHome);
}
}
break;
case MediaPortal.GUI.Library.Action.ActionType.ACTION_MOVE_DOWN:
case MediaPortal.GUI.Library.Action.ActionType.ACTION_MOVE_UP:
//Reset autoclose timer on search
if (searchTimer != null && searchTimer.Enabled)
{
searchTimer.Stop();
searchTimer.Start();
}
//Reset autoclose timer on search
if (searchTimer != null && searchTimer.Enabled)
{
searchTimer.Stop();
searchTimer.Start();
}
base.OnAction(action);
break;
case MediaPortal.GUI.Library.Action.ActionType.ACTION_MOVE_LEFT:
case MediaPortal.GUI.Library.Action.ActionType.ACTION_MOVE_RIGHT:
base.OnAction(action);
break;
case MediaPortal.GUI.Library.Action.ActionType.ACTION_MOVE_LEFT:
case MediaPortal.GUI.Library.Action.ActionType.ACTION_MOVE_RIGHT:
base.OnAction(action);
break;
case MediaPortal.GUI.Library.Action.ActionType.ACTION_REMOTE_RED_BUTTON:
OnSearchAction(SearchAction.ToggleMode);
return;
base.OnAction(action);
break;
case MediaPortal.GUI.Library.Action.ActionType.ACTION_REMOTE_RED_BUTTON:
OnSearchAction(SearchAction.ToggleMode);
return;
case MediaPortal.GUI.Library.Action.ActionType.ACTION_REMOTE_BLUE_BUTTON:
OnSearchAction(SearchAction.ToggleStartWord);
return;
case MediaPortal.GUI.Library.Action.ActionType.ACTION_REMOTE_BLUE_BUTTON:
OnSearchAction(SearchAction.ToggleStartWord);
return;
case MediaPortal.GUI.Library.Action.ActionType.ACTION_KEY_PRESSED:
KeyCommandHandler(action.m_key.KeyChar);
return;
case MediaPortal.GUI.Library.Action.ActionType.ACTION_KEY_PRESSED:
KeyCommandHandler(action.m_key.KeyChar);
return;
case MediaPortal.GUI.Library.Action.ActionType.ACTION_PARENT_DIR:
return;
case MediaPortal.GUI.Library.Action.ActionType.ACTION_PARENT_DIR:
return;
case MediaPortal.GUI.Library.Action.ActionType.ACTION_HOME:
UpdateSearchPanel(false);
ImageAllocator.FlushAll();
GUIWindowManager.ShowPreviousWindow();
break;
case MediaPortal.GUI.Library.Action.ActionType.ACTION_HOME:
if (BaseConfig.Settings.HomeButtonNavigation)
{
UpdateSearchPanel(false);
ImageAllocator.FlushAll();
GUIWindowManager.ShowPreviousWindow();
}
else
{
GUIWindowManager.SendThreadMessage(msgHome);
break;
}
break;
case MediaPortal.GUI.Library.Action.ActionType.ACTION_PLAY:
BaseConfig.MyAnimeLog.Write("Received PLAY action");
case MediaPortal.GUI.Library.Action.ActionType.ACTION_PLAY:
BaseConfig.MyAnimeLog.Write("Received PLAY action");
try
{
IVM ivm = GetCurrent().Selected;
if (ivm is AnimeGroupVM)
{
AnimeGroupVM grp = (AnimeGroupVM)ivm;
JMMServerBinary.Contract_AnimeEpisode contract =
JMMServerVM.Instance.clientBinaryHTTP.GetNextUnwatchedEpisodeForGroup(grp.AnimeGroupID,
JMMServerVM.Instance.CurrentUser.JMMUserID);
if (contract == null) return;
AnimeEpisodeVM ep = new AnimeEpisodeVM(contract);
vidHandler.ResumeOrPlay(ep);
}
try
{
IVM ivm = GetCurrent().Selected;
if (ivm is AnimeGroupVM)
{
AnimeGroupVM grp = (AnimeGroupVM) ivm;
JMMServerBinary.Contract_AnimeEpisode contract =
JMMServerVM.Instance.clientBinaryHTTP.GetNextUnwatchedEpisodeForGroup(grp.AnimeGroupID,
JMMServerVM.Instance.CurrentUser.JMMUserID);
if (contract == null) return;
AnimeEpisodeVM ep = new AnimeEpisodeVM(contract);
vidHandler.ResumeOrPlay(ep);
}
if (ivm is AnimeSeriesVM)
{
AnimeSeriesVM ser = (AnimeSeriesVM)ivm;
//ser = null;
if ((!ser.AnimeSeriesID.HasValue)) return;
JMMServerBinary.Contract_AnimeEpisode contract =
JMMServerVM.Instance.clientBinaryHTTP.GetNextUnwatchedEpisode(ser.AnimeSeriesID.Value,
JMMServerVM.Instance.CurrentUser.JMMUserID);
if (contract == null) return;
AnimeEpisodeVM ep = new AnimeEpisodeVM(contract);
vidHandler.ResumeOrPlay(ep);
}
}
catch (Exception ex)
{
BaseConfig.MyAnimeLog.Write(ex.ToString());
}
break;
if (ivm is AnimeSeriesVM)
{
AnimeSeriesVM ser = (AnimeSeriesVM) ivm;
//ser = null;
if ((!ser.AnimeSeriesID.HasValue)) return;
JMMServerBinary.Contract_AnimeEpisode contract =
JMMServerVM.Instance.clientBinaryHTTP.GetNextUnwatchedEpisode(ser.AnimeSeriesID.Value,
JMMServerVM.Instance.CurrentUser.JMMUserID);
if (contract == null) return;
AnimeEpisodeVM ep = new AnimeEpisodeVM(contract);
vidHandler.ResumeOrPlay(ep);
}
}
catch (Exception ex)
{
BaseConfig.MyAnimeLog.Write(ex.ToString());
}
break;
case MediaPortal.GUI.Library.Action.ActionType.ACTION_PREVIOUS_MENU:
if (searchTimer != null && searchTimer.Enabled)
{
OnSearchAction(SearchAction.EndSearch);
return;
}
case MediaPortal.GUI.Library.Action.ActionType.ACTION_PREVIOUS_MENU:
if (searchTimer != null && searchTimer.Enabled)
{
OnSearchAction(SearchAction.EndSearch);
return;
}
// back one level
// back one level
//string msg = string.Format("LIST LEVEL:: {0} - GF: {1} ", listLevel, selectedGroupFilter?.GroupFilterName ?? "None");
//string msg = string.Format("LIST LEVEL:: {0} - GF: {1} ", listLevel, selectedGroupFilter?.GroupFilterName ?? "None");
// BaseConfig.MyAnimeLog.Write(msg);
// BaseConfig.MyAnimeLog.Write(msg);
if (Breadcrumbs.Count == 1)
{
BaseConfig.MyAnimeLog.Write("Going HOME");
goto case MediaPortal.GUI.Library.Action.ActionType.ACTION_HOME;
}
Breadcrumbs.Remove(Breadcrumbs[Breadcrumbs.Count - 1]);
LoadFacade();
break;
if (Breadcrumbs.Count == 1)
{
BaseConfig.MyAnimeLog.Write("Going HOME");
goto case MediaPortal.GUI.Library.Action.ActionType.ACTION_HOME;
}
Breadcrumbs.Remove(Breadcrumbs[Breadcrumbs.Count - 1]);
LoadFacade();
break;
default:
base.OnAction(action);
break;
}
default:
base.OnAction(action);
break;
}
}
void GUIWindowManager_OnThreadMessageHandler(object sender, GUIMessage message)
@@ -2561,29 +2579,17 @@ void GUIWindowManager_OnThreadMessageHandler(object sender, GUIMessage message)
return;
}
//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());
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");
}
}
}
// Check for custom param 2 and let message thru if found
if (message.Param2 == 00432100)
return;
// Prevent certain messages from beeing sent to MP core
if (message.Message == GUIMessage.MessageType.GUI_MSG_GOTO_WINDOW &&

0 comments on commit ef85038

Please sign in to comment.