From: <che...@us...> - 2007-06-20 17:16:11
|
Revision: 573 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=573&view=rev Author: chef_koch Date: 2007-06-20 10:16:03 -0700 (Wed, 20 Jun 2007) Log Message: ----------- no code change, just a reorder of the some methods Modified Paths: -------------- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/GUIPrograms.cs Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/GUIPrograms.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/GUIPrograms.cs 2007-06-20 12:27:51 UTC (rev 572) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/GUIPrograms.cs 2007-06-20 17:16:03 UTC (rev 573) @@ -526,28 +526,6 @@ } } - GUIListItem GetSelectedItem() - { - return facadeView.SelectedListItem; - } - - int GetSelectedItemNo() - { - return facadeView.SelectedListItemIndex; - } - - int GetCurrentFatherID() - { - if (lastApp != null) - { - return lastApp.AppID; - } - else - { - return -1; // root - } - } - public int StartWindow { get { return startWindow; } @@ -671,7 +649,28 @@ } } + GUIListItem GetSelectedItem() + { + return facadeView.SelectedListItem; + } + int GetSelectedItemNo() + { + return facadeView.SelectedListItemIndex; + } + + int GetCurrentFatherID() + { + if (lastApp != null) + { + return lastApp.AppID; + } + else + { + return -1; // root + } + } + bool RefreshButtonVisible() { if (lastApp == null) @@ -729,158 +728,83 @@ base.OnPageDestroy(newWindowId); } - public override void Render(float timePassed) + public override void OnAction(Action action) { - base.Render(timePassed); - - if (ThumbnailPath != _lastThumbnailPath) + switch (action.wID) { - screenShotImage.FileName = ThumbnailPath; - facadeView.FilmstripView.InfoImageFileName = ThumbnailPath; - facadeView.FilmstripView.NeedRefresh(); - - _lastThumbnailPath = ThumbnailPath; + case Action.ActionType.ACTION_PARENT_DIR: + case Action.ActionType.ACTION_PREVIOUS_MENU: + // <U> keypress + BackItemClicked(); + UpdateButtons(); + break; + case Action.ActionType.ACTION_CLOSE_DIALOG: + SaveFolderSettings(""); + GUIWindowManager.ShowPreviousWindow(); + break; + case Action.ActionType.ACTION_SHOW_INFO: + OnInfo(); + break; + default: + base.OnAction(action); + break; } - - RenderThumbnail(timePassed); } - /* public override void AllocResources() - { - base.AllocResources(); - if (screenShotImage != null) screenShotImage.AllocResources(); - } - public override void FreeResources() - { - base.FreeResources(); - if (screenShotImage != null) screenShotImage.FreeResources(); - }*/ - - /* public override void Render(float timePassed) - { - base.Render(timePassed); - RenderFilmStrip(); - RenderScreenShot(timePassed); - } - */ - void OnInfo() + public override bool OnMessage(GUIMessage message) { - // <F3> keypress - if (null != lastApp) + switch (message.Message) { - selectedItemIndex = GetSelectedItemNo(); - GUIListItem item = GetSelectedItem(); - - FileItem curFile = null; - - if (!item.Label.Equals(ProgramUtils.cBackLabel) && (!item.IsFolder)) - { - if ((item.MusicTag != null) && (item.MusicTag is FileItem)) + case GUIMessage.MessageType.GUI_MSG_ITEM_FOCUS_CHANGED: { - curFile = (FileItem)item.MusicTag; - } - // show file info but only if the selected item is not the back button - bool ovVisible = mapSettings.OverviewVisible; - ProgramInfoAction modalResult = ProgramInfoAction.LookupFileInfo; - int selectedFileID = -1; - lastApp.OnInfo(item, ref ovVisible, ref modalResult, ref selectedFileID); - if ((null != curFile) && (modalResult == ProgramInfoAction.LookupFileInfo)) - { - FileItem scrapeFile = lastApp.Files.GetFileItemByID(selectedFileID); - if (null != scrapeFile) + int iControl = message.SenderControlId; + if (iControl == facadeView.GetID) { - int scrapeIndex = lastApp.Files.IndexOf(scrapeFile); - if (-1 != scrapeIndex) + if (lastApp != null) { - GUIControl.SelectItemControl(GetID, facadeView.GetID, scrapeIndex + 1); + lastApp.ResetThumbs(); } - ScrapeFileInfo(scrapeFile); } } - mapSettings.OverviewVisible = ovVisible; - UpdateListControl(); - } + break; } + return base.OnMessage(message); } - void ScrapeFileInfo(FileItem curFile) + protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType) { - int minRelevance = 30; - bool bSuccess = false; - ScraperSaveType saveType = ScraperSaveType.DataAndImages; - GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK); - GUIDialogProgress dlgProgress = (GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS); - dlgProgress.ShowWaitCursor = false; - dlgProgress.ShowProgressBar(false); - dlgProgress.SetHeading("Lookup Gameinfo"); - dlgProgress.SetLine(1, curFile.Title); - dlgProgress.SetLine(2, curFile.System_); - dlgProgress.SetLine(3, ""); - dlgProgress.StartModal(GetID); - // dlgProgress.SetPercentage(60); - dlgProgress.Progress(); - bSuccess = curFile.FindFileInfo(ScraperType.ALLGAME); - if ((bSuccess && curFile.FileInfoList.Count > 0) && ((FileItemInfo)(curFile.FileInfoList[0])).RelevanceNorm >= minRelevance) + base.OnClicked(controlId, control, actionType); + if (control == btnViewAs) { - GUIDialogSelect pDlg = (GUIDialogSelect)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_SELECT); - if (null != pDlg) - { - pDlg.Reset(); - pDlg.SetHeading("Select Title"); - foreach (FileItemInfo item in curFile.FileInfoList) - { - if (item.RelevanceNorm >= minRelevance) - { - pDlg.Add(String.Format("{0} ({1})", item.Title, item.Platform)); - } - } - pDlg.DoModal(GetID); + mapSettings.SwitchToNextView(); + ShowThumbPanel(); - // and wait till user selects one - int iSelectedGame = pDlg.SelectedLabel; - if (iSelectedGame < 0) return; - - dlgProgress.StartModal(GetID); - dlgProgress.Progress(); - dlgProgress.ShowProgressBar(false); - curFile.FileInfoFavourite = (FileItemInfo)curFile.FileInfoList[iSelectedGame]; - - curFile.FindFileInfoDetail(lastApp, curFile.FileInfoFavourite, ScraperType.ALLGAME, saveType); - if ((saveType == ScraperSaveType.DataAndImages) || (saveType == ScraperSaveType.Data)) - { - // dlgProgress.SetPercentage(60); - dlgProgress.Progress(); - curFile.SaveFromFileInfoFavourite(); - } - // dlgProgress.SetPercentage(100); - dlgProgress.Progress(); - dlgProgress.Close(); - dlgProgress = null; - } - OnInfo(); } - else + else if (control == btnRefresh) { - string strMsg = ""; - if (!bSuccess) + if (lastApp != null) { - strMsg = "Connection failed"; - Log.Info("myPrograms: RefreshData failed"); + lastApp.Refresh(true); + lastFilepath = lastApp.DefaultFilepath(); + // todo: reset viewHandler + UpdateButtons(); + UpdateListControl(); } - else + } + else if (control == btnViews) + { + OnShowViews(); + } + else if (control == facadeView) + { + // application or file-item was clicked.... + if (actionType == Action.ActionType.ACTION_SELECT_ITEM) { - strMsg = String.Format("No match for '{0}'", curFile.Title); - Log.Info("myPrograms: No data found for '{0}'", curFile.Title); + OnClick(); } - if (null != dlgOk) - { - dlgOk.SetHeading(187); - dlgOk.SetLine(1, strMsg); - dlgOk.SetLine(2, String.Empty); - dlgOk.DoModal(GetID); - } } } + protected override void OnShowContextMenu() { GUIListItem item = facadeView.SelectedListItem; @@ -910,137 +834,44 @@ } } - protected void OnShowViews() + public override void Render(float timePassed) { - GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); - if (dlg == null) return; - dlg.Reset(); - dlg.SetHeading(499); // Actions - dlg.Add(GUILocalizeStrings.Get(100000 + GetID)); // Files - foreach (ViewDefinition view in DatabaseSettings.viewHandler.Views) + base.Render(timePassed); + + if (ThumbnailPath != _lastThumbnailPath) { - dlg.Add(view.LocalizedName); + screenShotImage.FileName = ThumbnailPath; + facadeView.FilmstripView.InfoImageFileName = ThumbnailPath; + facadeView.FilmstripView.NeedRefresh(); + + _lastThumbnailPath = ThumbnailPath; } - dlg.DoModal(GetID); - if (dlg.SelectedLabel == -1) return; - if (dlg.SelectedLabel == 0) - { - int nNewWindow = (int)Window.WINDOW_FILES; - StartWindow = nNewWindow; - ActualView = ""; - DatabaseSettings.viewHandler.CurrentView = null; - if (nNewWindow != GetID) - { - GUIWindowManager.ReplaceWindow(nNewWindow); - } - } - else - { - ViewDefinition selectedView = (ViewDefinition)DatabaseSettings.viewHandler.Views[dlg.SelectedLabel - 1]; - DatabaseSettings.viewHandler.CurrentView = selectedView.Name; - ActualView = selectedView.Name; - int nNewWindow = (int)Window.WINDOW_FILES; - if (GetID != nNewWindow) - { - StartWindow = nNewWindow; - if (nNewWindow != GetID) - { - GUIWindowManager.ReplaceWindow(nNewWindow); - } - } - else - { - if (facadeView.Count <= 0) - { - GUIControl.FocusControl(GetID, btnViewAs.GetID); - } - } - } - if (lastApp != null) - { - lastApp.LoadFiles(); - } - UpdateButtons(); - UpdateListControl(); + + RenderThumbnail(timePassed); } - - protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType) + #region old (maybe obsolete) code: AllocResources() / FreeResources() / Render(float timePassed) + /* + public override void AllocResources() { - base.OnClicked(controlId, control, actionType); - if (control == btnViewAs) - { - mapSettings.SwitchToNextView(); - ShowThumbPanel(); - - } - else if (control == btnRefresh) - { - if (lastApp != null) - { - lastApp.Refresh(true); - lastFilepath = lastApp.DefaultFilepath(); - // todo: reset viewHandler - UpdateButtons(); - UpdateListControl(); - } - } - else if (control == btnViews) - { - OnShowViews(); - } - else if (control == facadeView) - { - // application or file-item was clicked.... - if (actionType == Action.ActionType.ACTION_SELECT_ITEM) - { - OnClick(); - } - } + base.AllocResources(); + if (screenShotImage != null) screenShotImage.AllocResources(); } - public override bool OnMessage(GUIMessage message) + public override void FreeResources() { - switch (message.Message) - { - case GUIMessage.MessageType.GUI_MSG_ITEM_FOCUS_CHANGED: - { - int iControl = message.SenderControlId; - if (iControl == facadeView.GetID) - { - if (lastApp != null) - { - lastApp.ResetThumbs(); - } - } - } - break; - } - return base.OnMessage(message); + base.FreeResources(); + if (screenShotImage != null) screenShotImage.FreeResources(); } - public override void OnAction(Action action) + public override void Render(float timePassed) { - switch (action.wID) - { - case Action.ActionType.ACTION_PARENT_DIR: - case Action.ActionType.ACTION_PREVIOUS_MENU: - // <U> keypress - BackItemClicked(); - UpdateButtons(); - break; - case Action.ActionType.ACTION_CLOSE_DIALOG: - SaveFolderSettings(""); - GUIWindowManager.ShowPreviousWindow(); - break; - case Action.ActionType.ACTION_SHOW_INFO: - OnInfo(); - break; - default: - base.OnAction(action); - break; - } + base.Render(timePassed); + RenderFilmStrip(); + RenderScreenShot(timePassed); } + */ + #endregion #endregion @@ -1081,7 +912,7 @@ void ShowThumbPanel() { int itemIndex = facadeView.SelectedListItemIndex; - + switch ((View)mapSettings.ViewAs) { case View.List: @@ -1160,7 +991,7 @@ if (lastApp != null) facadeView.Sort(new ProgramSort(CurrentSortMethod, CurrentSortAsc)); - + string itemCountText = String.Format("{0} {1}", TotalItems, GUILocalizeStrings.Get(632)); GUIPropertyManager.SetProperty("#itemcount", itemCountText); @@ -1246,66 +1077,6 @@ #region EventHandlers - void FileItemClicked(GUIListItem item) - { - // file item was clicked => launch it! - if (lastApp != null) - { - mapSettings.LastAppID = lastApp.AppID; - lastFilepath = lastApp.DefaultFilepath(); - lastApp.LaunchFile(item); - } - } - - void FolderItemClicked(GUIListItem item) - { - if (item.MusicTag != null) - { - if (item.MusicTag is ApplicationItem) - { - - ApplicationItem candidate = (ApplicationItem)item.MusicTag; - - - SaveItemIndex(GetSelectedItemNo().ToString(), lastApp, lastFilepath); - lastApp = candidate; - mapSettings.LastAppID = lastApp.AppID; - lastFilepath = lastApp.DefaultFilepath(); - DatabaseSettings.viewHandler.CurrentLevel = 0; - - } - else if (item.MusicTag is FileItem) - { - SaveItemIndex(GetSelectedItemNo().ToString(), lastApp, lastFilepath); - // example: subfolder in directory-cache mode - // => set filepath which will be a search criteria for sql / browse - if (lastFilepath == "") - { - // first subfolder - lastFilepath = lastApp.FileDirectory + "\\" + item.Label; - } - else - { - // subsequent subfolder - lastFilepath = lastFilepath + "\\" + item.Label; - } - } - else if (item.MusicTag is ProgramFilterItem) - { - AddNextFilter(item); - } - UpdateListControl(); - } - else - { - // tag is null - // example: subfolder in directory-browse mode - SaveItemIndex(GetSelectedItemNo().ToString(), lastApp, lastFilepath); - lastFilepath = item.Path; - UpdateListControl(); - } - } - void BackItemClicked() { if (lastApp != null) @@ -1374,6 +1145,66 @@ } + void FileItemClicked(GUIListItem item) + { + // file item was clicked => launch it! + if (lastApp != null) + { + mapSettings.LastAppID = lastApp.AppID; + lastFilepath = lastApp.DefaultFilepath(); + lastApp.LaunchFile(item); + } + } + + void FolderItemClicked(GUIListItem item) + { + if (item.MusicTag != null) + { + if (item.MusicTag is ApplicationItem) + { + + ApplicationItem candidate = (ApplicationItem)item.MusicTag; + + + SaveItemIndex(GetSelectedItemNo().ToString(), lastApp, lastFilepath); + lastApp = candidate; + mapSettings.LastAppID = lastApp.AppID; + lastFilepath = lastApp.DefaultFilepath(); + DatabaseSettings.viewHandler.CurrentLevel = 0; + + } + else if (item.MusicTag is FileItem) + { + SaveItemIndex(GetSelectedItemNo().ToString(), lastApp, lastFilepath); + // example: subfolder in directory-cache mode + // => set filepath which will be a search criteria for sql / browse + if (lastFilepath == "") + { + // first subfolder + lastFilepath = lastApp.FileDirectory + "\\" + item.Label; + } + else + { + // subsequent subfolder + lastFilepath = lastFilepath + "\\" + item.Label; + } + } + else if (item.MusicTag is ProgramFilterItem) + { + AddNextFilter(item); + } + UpdateListControl(); + } + else + { + // tag is null + // example: subfolder in directory-browse mode + SaveItemIndex(GetSelectedItemNo().ToString(), lastApp, lastFilepath); + lastFilepath = item.Path; + UpdateListControl(); + } + } + void AddNextFilter(GUIListItem item) { ProgramFilterItem curFilter; @@ -1403,6 +1234,85 @@ } } + void ScrapeFileInfo(FileItem curFile) + { + int minRelevance = 30; + bool bSuccess = false; + ScraperSaveType saveType = ScraperSaveType.DataAndImages; + GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK); + GUIDialogProgress dlgProgress = (GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS); + dlgProgress.ShowWaitCursor = false; + dlgProgress.ShowProgressBar(false); + dlgProgress.SetHeading("Lookup Gameinfo"); + dlgProgress.SetLine(1, curFile.Title); + dlgProgress.SetLine(2, curFile.System_); + dlgProgress.SetLine(3, ""); + dlgProgress.StartModal(GetID); + // dlgProgress.SetPercentage(60); + dlgProgress.Progress(); + bSuccess = curFile.FindFileInfo(ScraperType.ALLGAME); + if ((bSuccess && curFile.FileInfoList.Count > 0) && ((FileItemInfo)(curFile.FileInfoList[0])).RelevanceNorm >= minRelevance) + { + GUIDialogSelect pDlg = (GUIDialogSelect)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_SELECT); + if (null != pDlg) + { + pDlg.Reset(); + pDlg.SetHeading("Select Title"); + foreach (FileItemInfo item in curFile.FileInfoList) + { + if (item.RelevanceNorm >= minRelevance) + { + pDlg.Add(String.Format("{0} ({1})", item.Title, item.Platform)); + } + } + pDlg.DoModal(GetID); + + // and wait till user selects one + int iSelectedGame = pDlg.SelectedLabel; + if (iSelectedGame < 0) return; + + dlgProgress.StartModal(GetID); + dlgProgress.Progress(); + dlgProgress.ShowProgressBar(false); + curFile.FileInfoFavourite = (FileItemInfo)curFile.FileInfoList[iSelectedGame]; + + curFile.FindFileInfoDetail(lastApp, curFile.FileInfoFavourite, ScraperType.ALLGAME, saveType); + if ((saveType == ScraperSaveType.DataAndImages) || (saveType == ScraperSaveType.Data)) + { + // dlgProgress.SetPercentage(60); + dlgProgress.Progress(); + curFile.SaveFromFileInfoFavourite(); + } + // dlgProgress.SetPercentage(100); + dlgProgress.Progress(); + dlgProgress.Close(); + dlgProgress = null; + } + OnInfo(); + } + else + { + string strMsg = ""; + if (!bSuccess) + { + strMsg = "Connection failed"; + Log.Info("myPrograms: RefreshData failed"); + } + else + { + strMsg = String.Format("No match for '{0}'", curFile.Title); + Log.Info("myPrograms: No data found for '{0}'", curFile.Title); + } + if (null != dlgOk) + { + dlgOk.SetHeading(187); + dlgOk.SetLine(1, strMsg); + dlgOk.SetLine(2, String.Empty); + dlgOk.DoModal(GetID); + } + } + } + void OnItemSelected(GUIListItem item, GUIControl parent) { ThumbnailPath = ""; @@ -1448,6 +1358,100 @@ } } + void OnInfo() + { + // <F3> keypress + if (null != lastApp) + { + selectedItemIndex = GetSelectedItemNo(); + GUIListItem item = GetSelectedItem(); + + FileItem curFile = null; + + if (!item.Label.Equals(ProgramUtils.cBackLabel) && (!item.IsFolder)) + { + if ((item.MusicTag != null) && (item.MusicTag is FileItem)) + { + curFile = (FileItem)item.MusicTag; + } + // show file info but only if the selected item is not the back button + bool ovVisible = mapSettings.OverviewVisible; + ProgramInfoAction modalResult = ProgramInfoAction.LookupFileInfo; + int selectedFileID = -1; + lastApp.OnInfo(item, ref ovVisible, ref modalResult, ref selectedFileID); + if ((null != curFile) && (modalResult == ProgramInfoAction.LookupFileInfo)) + { + FileItem scrapeFile = lastApp.Files.GetFileItemByID(selectedFileID); + if (null != scrapeFile) + { + int scrapeIndex = lastApp.Files.IndexOf(scrapeFile); + if (-1 != scrapeIndex) + { + GUIControl.SelectItemControl(GetID, facadeView.GetID, scrapeIndex + 1); + } + ScrapeFileInfo(scrapeFile); + } + } + mapSettings.OverviewVisible = ovVisible; + UpdateListControl(); + } + } + } + + void OnShowViews() + { + GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); + if (dlg == null) return; + dlg.Reset(); + dlg.SetHeading(499); // Actions + dlg.Add(GUILocalizeStrings.Get(100000 + GetID)); // Files + foreach (ViewDefinition view in DatabaseSettings.viewHandler.Views) + { + dlg.Add(view.LocalizedName); + } + dlg.DoModal(GetID); + if (dlg.SelectedLabel == -1) return; + if (dlg.SelectedLabel == 0) + { + int nNewWindow = (int)Window.WINDOW_FILES; + StartWindow = nNewWindow; + ActualView = ""; + DatabaseSettings.viewHandler.CurrentView = null; + if (nNewWindow != GetID) + { + GUIWindowManager.ReplaceWindow(nNewWindow); + } + } + else + { + ViewDefinition selectedView = (ViewDefinition)DatabaseSettings.viewHandler.Views[dlg.SelectedLabel - 1]; + DatabaseSettings.viewHandler.CurrentView = selectedView.Name; + ActualView = selectedView.Name; + int nNewWindow = (int)Window.WINDOW_FILES; + if (GetID != nNewWindow) + { + StartWindow = nNewWindow; + if (nNewWindow != GetID) + { + GUIWindowManager.ReplaceWindow(nNewWindow); + } + } + else + { + if (facadeView.Count <= 0) + { + GUIControl.FocusControl(GetID, btnViewAs.GetID); + } + } + } + if (lastApp != null) + { + lastApp.LoadFiles(); + } + UpdateButtons(); + UpdateListControl(); + } + #endregion } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |