Browse Source

WinRT: Bug fix for UTIL_BasePath(), description improvement; Win32: OPL choice fix

louyihua 8 years ago
parent
commit
ab97bf0e65

+ 2 - 1
win32/win32.cpp

@@ -142,7 +142,7 @@ void ResetControls(HWND hwndDlg)
 
 	ComboBox_SetCurSel(hwndDlg, IDC_CD, gConfig.eCDType - MUSIC_MP3);
 	ComboBox_SetCurSel(hwndDlg, IDC_BGM, gConfig.eMusicType);
-	ComboBox_SetCurSel(hwndDlg, IDC_OPL, gConfig.eOPLType - OPL_DOSBOX);
+	ComboBox_SetCurSel(hwndDlg, IDC_OPL, gConfig.eOPLType);
 
 	SetDlgItemText(hwndDlg, IDC_WIDTH, _ultot(gConfig.dwScreenWidth, buffer, 10));
 	SetDlgItemText(hwndDlg, IDC_HEIGHT, _ultot(gConfig.dwScreenHeight, buffer, 10));
@@ -174,6 +174,7 @@ INT_PTR InitProc(HWND hwndDlg, HWND hwndCtrl, LPARAM lParam)
 
 	ComboBox_AddString(hwndDlg, IDC_OPL, TEXT("DOSBOX"));
 	ComboBox_AddString(hwndDlg, IDC_OPL, TEXT("MAME"));
+	ComboBox_AddString(hwndDlg, IDC_OPL, TEXT("DOSBOXNEW"));
 
 	ResetControls(hwndDlg);
 

+ 6 - 4
winrt/SDLPal.Common/MainPage.xaml

@@ -9,13 +9,15 @@
 
     <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
         <ScrollViewer HorizontalScrollMode="Disabled">
-            <StackPanel VerticalAlignment="Top" Margin="10,0,10,0">
-                <TextBox x:Name="tbGamePath" x:Uid="GamePath" TextWrapping="Wrap" VerticalAlignment="Top" Header="游戏资源文件夹" IsReadOnly="True" PlaceholderText="游戏资源文件夹"/>
+            <StackPanel VerticalAlignment="Top" Margin="15,0,15,0">
+                <TextBlock Text="SDLPAL" FontSize="48" />
+                <TextBlock x:Uid="Title" Text="设置模式" FontSize="28" VerticalAlignment="Center" />
+                <TextBox x:Name="tbGamePath" x:Uid="GamePath" TextWrapping="Wrap" VerticalAlignment="Top" Header="游戏资源文件夹" IsReadOnly="True" PlaceholderText="未选择游戏资源文件夹"/>
                 <Button x:Name="btnBrowseGame" x:Uid="ButtonBrowse" Content="浏览文件夹" HorizontalAlignment="Left" VerticalAlignment="Top" Click="btnBrowse_Click" />
                 <ToggleSwitch x:Name="tsIsDOS" x:Uid="DOS" Header="游戏资源版本" OffContent="WIN95" OnContent="DOS" Toggled="tsIsDOS_Toggled" />
-                <ToggleSwitch x:Name="tsUseEmbedFont" x:Uid="EmbeddedFont" Header="游戏内嵌字体" OffContent="否" OnContent="是" />
+                <ToggleSwitch x:Name="tsUseEmbedFont" x:Uid="EmbeddedFont" Header="使用游戏资源内置字体" OffContent="否" OnContent="是" />
                 <ToggleSwitch x:Name="tsLanguage" x:Uid="Language" Header="游戏资源语言" OffContent="繁体中文" OnContent="简体中文" />
-                <TextBox x:Name="tbMsgFile" x:Uid="MessageFile" Header="自定义语言文件" TextWrapping="Wrap" VerticalAlignment="Top" PlaceholderText="自定义语言文件" IsReadOnly="True"/>
+                <TextBox x:Name="tbMsgFile" x:Uid="MessageFile" Header="自定义语言文件" TextWrapping="Wrap" VerticalAlignment="Top" PlaceholderText="自定义语言文件" IsReadOnly="True"/>
                 <StackPanel Orientation="Horizontal">
                     <Button x:Name="btnBrowseMsgFile" x:Uid="ButtonBrowseFile" Content="选择语言文件" Click="btnBrowseFile_Click" />
                     <Button x:Name="btnClearMsgFile" x:Uid="ButtonClearFile" Content="禁用语言文件" Margin="20,0,0,0" Click="btnClearFile_Click" />

+ 9 - 12
winrt/SDLPal.Common/MainPage.xaml.cpp

@@ -154,15 +154,19 @@ void SDLPal::MainPage::btnFinish_Click(Platform::Object^ sender, Windows::UI::Xa
 	auto loader = ref new Windows::ApplicationModel::Resources::ResourceLoader();
 	if (tbGamePath->Text->Length() > 0)
 	{
-		SaveControlContents();
 		auto mru_list = Windows::Storage::AccessCache::StorageApplicationPermissions::MostRecentlyUsedList;
 		if (tbGamePath->Tag) mru_list->Add(safe_cast<Windows::Storage::StorageFolder^>(tbGamePath->Tag), tbGamePath->Text);
 		if (tbMsgFile->Tag) mru_list->Add(safe_cast<Windows::Storage::StorageFile^>(tbMsgFile->Tag), tbMsgFile->Text);
-		auto handler = ref new Windows::UI::Popups::UICommandInvokedHandler(this, &MainPage::CloseUICommandHandler);
+
+		SaveControlContents();
+		gConfig.fLaunchSetting = FALSE;
+		PAL_SaveConfig();
+
 		auto dlg = ref new Windows::UI::Popups::MessageDialog(loader->GetString("MBExitContent"));
-		dlg->Commands->Append(ref new Windows::UI::Popups::UICommand(loader->GetString("MBYes"), handler, safe_cast<Platform::Object^>(0)));
-		dlg->Commands->Append(ref new Windows::UI::Popups::UICommand(loader->GetString("MBNo"), handler, safe_cast<Platform::Object^>(1)));
-		dlg->ShowAsync();
+		dlg->Title = loader->GetString("MBExitTitle");
+		concurrency::create_task(dlg->ShowAsync()).then([] (Windows::UI::Popups::IUICommand^ command) {
+			Application::Current->Exit();
+		});
 	}
 	else
 	{
@@ -170,13 +174,6 @@ void SDLPal::MainPage::btnFinish_Click(Platform::Object^ sender, Windows::UI::Xa
 	}
 }
 
-void SDLPal::MainPage::CloseUICommandHandler(Windows::UI::Popups::IUICommand^ command)
-{
-	gConfig.fLaunchSetting = ((int)command->Id == 0);
-	PAL_SaveConfig();
-	Application::Current->Exit();
-}
-
 void SDLPal::MainPage::btnClearFile_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
 {
 	tbMsgFile->Text = "";

+ 0 - 2
winrt/SDLPal.Common/MainPage.xaml.h

@@ -25,8 +25,6 @@ namespace SDLPal
 		void SaveControlContents();
 
 	private:
-		void CloseUICommandHandler(Windows::UI::Popups::IUICommand^ command);
-
 		void btnBrowse_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
 		void tsIsDOS_Toggled(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
 		void cbBGM_SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e);

+ 6 - 1
winrt/SDLPal.Common/SDLPal.cpp

@@ -23,7 +23,12 @@ int CALLBACK WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
 		// Check the 'running' file to determine whether the program is abnormally terminated last time.
 		// If so, force to launch the setting page.
 		auto file = AWait(Windows::Storage::ApplicationData::Current->LocalFolder->GetFileAsync("running"), g_eventHandle);
-		gConfig.fLaunchSetting = TRUE; last_crashed = true;
+		// When there is a debugger, ignore the last crash state, as it can be recovered by the debugger.
+		if (!IsDebuggerPresent())
+		{
+			gConfig.fLaunchSetting = TRUE;
+			last_crashed = true;
+		}
 		AWait(file->DeleteAsync(), g_eventHandle);
 	}
 	catch(Platform::Exception^)

+ 10 - 10
winrt/SDLPal.Common/Strings/en/Resources.resw

@@ -172,7 +172,7 @@
     <value>DOS</value>
   </data>
   <data name="EmbeddedFont.Header" xml:space="preserve">
-    <value>Use the font within game resource</value>
+    <value>Use the font embedded in game resource</value>
   </data>
   <data name="EmbeddedFont.OffContent" xml:space="preserve">
     <value>No</value>
@@ -184,7 +184,7 @@
     <value>Folder of game resource</value>
   </data>
   <data name="GamePath.PlaceholderText" xml:space="preserve">
-    <value>Folder of game resource</value>
+    <value>No folder selected</value>
   </data>
   <data name="Language.Header" xml:space="preserve">
     <value>Game resource language</value>
@@ -202,20 +202,17 @@
     <value>The game resource folder must be specified!</value>
   </data>
   <data name="MBExitContent" xml:space="preserve">
-    <value>Settings saved for next launch.
-Choose the behavior of next launch:</value>
-  </data>
-  <data name="MBNo" xml:space="preserve">
-    <value>Start game</value>
+    <value>Settings have been saved and the game will be started on next launch.
+You can use the "return setting" menu option inside the game to return to this page.</value>
   </data>
-  <data name="MBYes" xml:space="preserve">
-    <value>Enter setting</value>
+  <data name="MBExitTitle" xml:space="preserve">
+    <value>Setting finished</value>
   </data>
   <data name="MessageFile.Header" xml:space="preserve">
     <value>Customized message file</value>
   </data>
   <data name="MessageFile.PlaceholderText" xml:space="preserve">
-    <value>Customized message file</value>
+    <value>No customized message file</value>
   </data>
   <data name="OPL.Header" xml:space="preserve">
     <value>Type of OPL simulator</value>
@@ -259,6 +256,9 @@ Choose the behavior of next launch:</value>
   <data name="SurroundOPL.OnContent" xml:space="preserve">
     <value>Yes</value>
   </data>
+  <data name="Title.Text" xml:space="preserve">
+    <value>Setting mode</value>
+  </data>
   <data name="TouchOverlay.Header" xml:space="preserve">
     <value>Use touch overlay</value>
   </data>

+ 9 - 9
winrt/SDLPal.Common/Strings/zh-hans/Resources.resw

@@ -184,7 +184,7 @@
     <value>游戏资源文件夹</value>
   </data>
   <data name="GamePath.PlaceholderText" xml:space="preserve">
-    <value>游戏资源文件夹</value>
+    <value>未选择文件夹</value>
   </data>
   <data name="Language.Header" xml:space="preserve">
     <value>游戏资源语言</value>
@@ -202,20 +202,17 @@
     <value>必须指定游戏资源文件夹!</value>
   </data>
   <data name="MBExitContent" xml:space="preserve">
-    <value>设置已保存,下次启动程序时生效。
-请选择下次启动程序时的行为:</value>
-  </data>
-  <data name="MBNo" xml:space="preserve">
-    <value>启动游戏</value>
+    <value>您的设置已保存,下次启动时将直接开始游戏。
+在游戏中,您可以通过游戏系统菜单的“返回设置”选项返回本设置页面。</value>
   </data>
-  <data name="MBYes" xml:space="preserve">
-    <value>进入设置</value>
+  <data name="MBExitTitle" xml:space="preserve">
+    <value>设置已完成</value>
   </data>
   <data name="MessageFile.Header" xml:space="preserve">
     <value>自定义语言文件</value>
   </data>
   <data name="MessageFile.PlaceholderText" xml:space="preserve">
-    <value>自定义语言文件</value>
+    <value>自定义语言文件</value>
   </data>
   <data name="OPL.Header" xml:space="preserve">
     <value>OPL 模拟器</value>
@@ -259,6 +256,9 @@
   <data name="SurroundOPL.OnContent" xml:space="preserve">
     <value>是</value>
   </data>
+  <data name="Title.Text" xml:space="preserve">
+    <value>设置模式</value>
+  </data>
   <data name="TouchOverlay.Header" xml:space="preserve">
     <value>启用触屏辅助</value>
   </data>

+ 15 - 15
winrt/SDLPal.Common/Strings/zh-hant/Resources.resw

@@ -142,13 +142,13 @@
     <value>背景音樂格式</value>
   </data>
   <data name="ButtonBrowse.Content" xml:space="preserve">
-    <value>瀏覽資料夾</value>
+    <value>瀏覽檔案夾</value>
   </data>
   <data name="ButtonBrowseFile.Content" xml:space="preserve">
-    <value>選擇語言檔</value>
+    <value>選擇語言檔</value>
   </data>
   <data name="ButtonClearFile.Content" xml:space="preserve">
-    <value>禁用語言檔</value>
+    <value>禁用語言檔</value>
   </data>
   <data name="ButtonDefault.Content" xml:space="preserve">
     <value>默認設定</value>
@@ -181,10 +181,10 @@
     <value>是</value>
   </data>
   <data name="GamePath.Header" xml:space="preserve">
-    <value>遊戲資源檔夾</value>
+    <value>遊戲資源檔夾</value>
   </data>
   <data name="GamePath.PlaceholderText" xml:space="preserve">
-    <value>遊戲資源檔夾</value>
+    <value>未選擇檔案夾</value>
   </data>
   <data name="Language.Header" xml:space="preserve">
     <value>遊戲資源語言</value>
@@ -199,23 +199,20 @@
     <value>上次程式異常退出,已顯示設定頁供您檢查設定是否正確。</value>
   </data>
   <data name="MBEmptyContent" xml:space="preserve">
-    <value>必須指定遊戲資源檔夾!</value>
+    <value>必須指定遊戲資源檔夾!</value>
   </data>
   <data name="MBExitContent" xml:space="preserve">
-    <value>設定已保存,下次啟動程式時生效
-請選擇下次啟動程式時的行為:</value>
+    <value>您的設定已保存,下次啟動時將直接開始遊戲
+在遊戲中,您可以通過遊戲系統功能表的“返回設定”選項返回本設定頁面。</value>
   </data>
-  <data name="MBNo" xml:space="preserve">
-    <value>啟動遊戲</value>
-  </data>
-  <data name="MBYes" xml:space="preserve">
-    <value>進入設定</value>
+  <data name="MBExitTitle" xml:space="preserve">
+    <value>設定已完成</value>
   </data>
   <data name="MessageFile.Header" xml:space="preserve">
-    <value>自訂語言檔</value>
+    <value>自訂語言檔案</value>
   </data>
   <data name="MessageFile.PlaceholderText" xml:space="preserve">
-    <value>自訂語言檔</value>
+    <value>自訂語言檔</value>
   </data>
   <data name="OPL.Header" xml:space="preserve">
     <value>OPL 模擬器</value>
@@ -259,6 +256,9 @@
   <data name="SurroundOPL.OnContent" xml:space="preserve">
     <value>是</value>
   </data>
+  <data name="Title.Text" xml:space="preserve">
+    <value>設定模式</value>
+  </data>
   <data name="TouchOverlay.Header" xml:space="preserve">
     <value>啟用觸屏輔助</value>
   </data>

+ 10 - 5
winrt/SDLPal.Common/WinRTUtil.cpp

@@ -6,6 +6,7 @@
 #include <ppltasks.h>
 #include "../SDLPal.Common/AsyncHelper.h"
 #include "../SDLPal.Common/StringHelper.h"
+#include "../../global.h"
 
 #include "SDL.h"
 #include "SDL_endian.h"
@@ -20,11 +21,15 @@ LPCSTR UTIL_BasePath(VOID)
 	if (g_basepath.empty())
 	{
 		auto mru_list = Windows::Storage::AccessCache::StorageApplicationPermissions::MostRecentlyUsedList;
-		if (mru_list->Entries->Size > 0)
+		for each (auto entry in mru_list->Entries)
 		{
-			auto localfolder = mru_list->Entries->First()->Current.Metadata;
-			if (localfolder->End()[-1] != L'\\') localfolder += "\\";
-			ConvertString(localfolder, g_basepath);
+			if (dynamic_cast<Windows::Storage::StorageFolder^>(AWait(mru_list->GetItemAsync(entry.Token), g_eventHandle)) != nullptr)
+			{
+				auto localfolder = entry.Metadata;
+				if (localfolder->End()[-1] != L'\\') localfolder += "\\";
+				ConvertString(localfolder, g_basepath);
+				break;
+			}
 		}
 	}
 	return g_basepath.c_str();
@@ -51,7 +56,7 @@ LPCSTR UTIL_ConfigPath(VOID)
 extern "C"
 LPCSTR UTIL_ScreenShotPath(VOID)
 {
-	return UTIL_BasePath();
+	return gConfig.pszGamePath;
 }
 
 extern "C"