From: <che...@us...> - 2007-08-05 10:09:26
|
Revision: 792 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=792&view=rev Author: chef_koch Date: 2007-08-05 03:09:23 -0700 (Sun, 05 Aug 2007) Log Message: ----------- added new class SettingsBase - SettingsRoot & AppSettingsBase depend on it -> easier to use the designer and add new options Modified Paths: -------------- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsBase.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/SetupForm.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/GUIProgramsAlt.csproj trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/ProgramUtils.cs Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsBase.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsBase.cs 2007-08-05 08:48:44 UTC (rev 791) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsBase.cs 2007-08-05 10:09:23 UTC (rev 792) @@ -40,19 +40,44 @@ namespace GUIPrograms.Design { - public partial class AppSettingsBase : UserControl + public partial class AppSettingsBase : SettingsBase { string preLaunch = string.Empty; string postLaunch = string.Empty; + protected bool useThumbsDir = true; - protected ConditionChecker conditionChecker = new ConditionChecker(); - public AppSettingsBase() { InitializeComponent(); InitDefault(); } + public override void LoadSettings(ApplicationItem curApp) + { + base.LoadSettings(curApp); + + AppItemToForm(curApp); + + if (DatabaseHandler.KeyExists(ProgramUtils.cUSE_MP_THUMBS_DIR)) + useThumbsDir = bool.Parse(DatabaseHandler.ReadSetting(ProgramUtils.cUSE_MP_THUMBS_DIR)); + else + useThumbsDir = true; + } + + public override void SaveSettings(ApplicationItem curApp) + { + base.SaveSettings(curApp); + + FormToAppItem(curApp); + } + + + + + + + + public virtual bool AppItemToForm(ApplicationItem curApp) { if (curApp != null) @@ -72,16 +97,6 @@ } } - public virtual bool EntriesOK(ApplicationItem curApp) - { - return true; - } - - public virtual void LoadFromAppItem(ApplicationItem tempApp) - { - // virtual! - } - protected void SetWindowStyle(ProcessWindowStyle val) { switch (val) Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/SetupForm.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/SetupForm.cs 2007-08-05 08:48:44 UTC (rev 791) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/SetupForm.cs 2007-08-05 10:09:23 UTC (rev 792) @@ -63,10 +63,10 @@ private AppSettingsGamebase appSettingsGameBase = new AppSettingsGamebase(); private AppSettingsGrouper appSettingsGrouper = new AppSettingsGrouper(); private ProgramViews appSettingsProgramView = new ProgramViews(); - private AppSettingsRoot appSettingsRoot = new AppSettingsRoot(); + private SettingsRoot appSettingsRoot = new SettingsRoot(); private AppSettingsFilesView appSettingsFileEditView = new AppSettingsFilesView(); private AppSettingsFilesImportProgress filesProgress = new AppSettingsFilesImportProgress(); - private AppSettingsBase pageCurrentSettings = null; + private SettingsBase pageCurrentSettings = null; private bool profilesIsLoaded = false; private const string ROOTNODENAME = "Applications"; private const int POSITIONHOLDER = 10; @@ -363,34 +363,24 @@ - private AppSettingsBase GetCurrentSettingsPage() + private SettingsBase GetCurrentSettingsPage() { - AppSettingsBase appSettings = null; ApplicationItem currentApplication = GetTreeNodeApplicationItem(treeView.SelectedNode); + if (currentApplication == null) return appSettingsRoot; - if (currentApplication != null) + switch (currentApplication.SourceType) { - switch (currentApplication.SourceType) - { - case ItemType.DIRCACHE: - appSettings = appSettingsDirCache; - break; - case ItemType.MAMEDIRECT: - appSettings = appSettingsMame; - break; - case ItemType.GROUPER: - appSettings = appSettingsGrouper; - break; - case ItemType.GAMEBASE: - appSettings = this.appSettingsGameBase; - break; - } + case ItemType.DIRCACHE: + return appSettingsDirCache; + case ItemType.MAMEDIRECT: + return appSettingsMame; + case ItemType.GROUPER: + return appSettingsGrouper; + case ItemType.GAMEBASE: + return appSettingsGameBase; + default: + return appSettingsRoot; } - else - { - appSettings = appSettingsRoot; - } - return appSettings; } bool TabIsDisplayed(TabPage view) @@ -458,38 +448,38 @@ } - private void SyncPanel(AppSettingsBase pageSettings) + private void SyncPanel() { this.tabControl.TabPages["detailsTabPage"].Controls.Clear(); - if (pageSettings != null) - { - this.tabControl.TabPages["detailsTabPage"].Controls.Add(pageSettings); + pageCurrentSettings = GetCurrentSettingsPage(); + if (pageCurrentSettings == null) return; - ApplicationItem currentApplication = GetTreeNodeApplicationItem(treeView.SelectedNode); - pageSettings.AppItemToForm(currentApplication); + this.tabControl.TabPages["detailsTabPage"].Controls.Add(pageCurrentSettings); - if (currentApplication != null) + ApplicationItem currentApplication = GetTreeNodeApplicationItem(treeView.SelectedNode); + pageCurrentSettings.LoadSettings(currentApplication); + + if (currentApplication != null) + { + RemoveViewsPage(); + RemoveDBOptionsPage(); + if (currentApplication.FileEditorAllowed()) { - RemoveViewsPage(); - RemoveDBOptionsPage(); - if (currentApplication.FileEditorAllowed()) - { - AddFilesPage(currentApplication); - } - else - { - RemoveFilesPage(); - } + AddFilesPage(currentApplication); } else { - // special treatment for root node RemoveFilesPage(); - AddViewsPage(); - AddDBOptionsPage(); } } + else + { + // special treatment for root node + RemoveFilesPage(); + AddViewsPage(); + AddDBOptionsPage(); + } } private bool SaveAppItem() @@ -499,40 +489,37 @@ // currentApplication can be NULL for the root Element..... so don't catch this! pageCurrentSettings = GetCurrentSettingsPage(); - - if (pageCurrentSettings != null) + if (pageCurrentSettings == null) { - if (pageCurrentSettings.EntriesOK(currentApplication)) + Log.Debug("SetupForm: SaveAppItem() pageCurrentSettings == null"); + return false; + } + + if (pageCurrentSettings.EntriesOK(currentApplication)) + { + if (appSettingsFileEditView.EntriesOK()) { - if (appSettingsFileEditView.EntriesOK()) + pageCurrentSettings.SaveSettings(currentApplication); + appSettingsFileEditView.FillApplicationItem(currentApplication); + if (currentApplication != null) { - - pageCurrentSettings.FormToAppItem(currentApplication); - appSettingsFileEditView.FillApplicationItem(currentApplication); - - - if (currentApplication != null) - { - currentApplication.InsertOrUpdateSettings(); - treeView.SelectedNode.Text = currentApplication.Title;// +" " + currentApplication.Position; - success = true; - } + currentApplication.InsertOrUpdateSettings(); + treeView.SelectedNode.Text = currentApplication.Title;// +" " + currentApplication.Position; + success = true; } } - else - { + } + else + { // some of the entries are invalid success = false; - } } return success; } private void SyncDetails() { - pageCurrentSettings = GetCurrentSettingsPage(); - - SyncPanel(pageCurrentSettings); + SyncPanel(); SyncButtons(); } @@ -952,7 +939,7 @@ { if (pageCurrentSettings.EntriesOK(currentApplication)) { - pageCurrentSettings.FormToAppItem(currentApplication); + pageCurrentSettings.SaveSettings(currentApplication); if (currentApplication != null) { currentApplication.InsertOrUpdateSettings(); Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/GUIProgramsAlt.csproj =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/GUIProgramsAlt.csproj 2007-08-05 08:48:44 UTC (rev 791) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/GUIProgramsAlt.csproj 2007-08-05 10:09:23 UTC (rev 792) @@ -98,11 +98,11 @@ <Compile Include="Design\AppSettingsMame.Designer.cs"> <DependentUpon>AppSettingsMame.cs</DependentUpon> </Compile> - <Compile Include="Design\AppSettingsRoot.cs"> + <Compile Include="Design\SettingsRoot.cs"> <SubType>UserControl</SubType> </Compile> - <Compile Include="Design\AppSettingsRoot.Designer.cs"> - <DependentUpon>AppSettingsRoot.cs</DependentUpon> + <Compile Include="Design\SettingsRoot.Designer.cs"> + <DependentUpon>SettingsRoot.cs</DependentUpon> </Compile> <Compile Include="Design\FileInfoScraperForm.cs"> <SubType>Form</SubType> @@ -122,6 +122,12 @@ <Compile Include="Design\AppSettingsPrePost.Designer.cs"> <DependentUpon>AppSettingsPrePost.cs</DependentUpon> </Compile> + <Compile Include="Design\SettingsBase.cs"> + <SubType>UserControl</SubType> + </Compile> + <Compile Include="Design\SettingsBase.Designer.cs"> + <DependentUpon>SettingsBase.cs</DependentUpon> + </Compile> <Compile Include="Design\SetupForm.cs"> <SubType>Form</SubType> </Compile> @@ -195,8 +201,8 @@ <DependentUpon>AppSettingsMame.cs</DependentUpon> <SubType>Designer</SubType> </EmbeddedResource> - <EmbeddedResource Include="Design\AppSettingsRoot.resx"> - <DependentUpon>AppSettingsRoot.cs</DependentUpon> + <EmbeddedResource Include="Design\SettingsRoot.resx"> + <DependentUpon>SettingsRoot.cs</DependentUpon> <SubType>Designer</SubType> </EmbeddedResource> <EmbeddedResource Include="Design\FileInfoScraperForm.resx"> @@ -211,6 +217,10 @@ <SubType>Designer</SubType> <DependentUpon>AppSettingsPrePost.cs</DependentUpon> </EmbeddedResource> + <EmbeddedResource Include="Design\SettingsBase.resx"> + <DependentUpon>SettingsBase.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> <EmbeddedResource Include="Design\SetupForm.resx"> <DependentUpon>SetupForm.cs</DependentUpon> <SubType>Designer</SubType> Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/ProgramUtils.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/ProgramUtils.cs 2007-08-05 08:48:44 UTC (rev 791) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/ProgramUtils.cs 2007-08-05 10:09:23 UTC (rev 792) @@ -97,14 +97,17 @@ public const int GetID = (int)GUIWindow.Window.WINDOW_FILES; public const int ProgramInfoID = 1206; // some magic number, sync with DialogAppInfo.xml public const string cBackLabel = ".."; + public const string cDefaultPluginTitle = "My Programs Alt."; public const string cMAMEDIRECT = "MAME_DIRECT"; public const string cDIRCACHE = "DIR_CACHE"; public const string cGROUPER = "GROUPER"; public const string cGAMEBASE = "GAMEBASE"; - public const string cSLIDESPEED = "SLIDESPEED"; + // Settings public const string cPLUGINTITLE = "PLUGINTITLE"; + public const string cSLIDESPEED = "SLIDESPEED"; + public const string cUSE_MP_THUMBS_DIR = "USE_MP_THUMBS_DIR"; #endregion Variables This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |