浏览代码

WinRT: add checks after downloading completes

Lou Yihua 7 年之前
父节点
当前提交
a67138b670

+ 8 - 2
winrt/SDLPal.Common/DownloadDialog.xaml.cpp

@@ -11,6 +11,7 @@
 #include "NativeBuffer.h"
 #include "StringHelper.h"
 #include "minizip/unzip.h"
+#include "util.h"
 
 using namespace SDLPal;
 
@@ -47,8 +48,8 @@ struct zip_file
 	zip_file(IStream* s) : stream(s), hr(S_OK), cbBytes(0) {}
 };
 
-SDLPal::DownloadDialog::DownloadDialog(Windows::ApplicationModel::Resources::ResourceLoader^ ldr, StorageFolder^ folder, IRandomAccessStream^ stream, double w, double h, bool from_url)
-	: m_stream(stream), m_Closable(false), m_InitialPhase(true), m_totalBytes(0), m_resLdr(ldr), m_folder(folder), m_width(w), m_height(h)
+SDLPal::DownloadDialog::DownloadDialog(Windows::ApplicationModel::Resources::ResourceLoader^ ldr, StorageFolder^ folder, IRandomAccessStream^ stream, Platform::String^ msgfile, double w, double h, bool from_url)
+	: m_stream(stream), m_Closable(false), m_InitialPhase(true), m_totalBytes(0), m_resLdr(ldr), m_folder(folder), m_width(w), m_height(h), m_msgfile(msgfile)
 {
 	InitializeComponent();
 
@@ -266,6 +267,11 @@ void SDLPal::DownloadDialog::DoDownload(Platform::String^ url)
 					string = String::Concat(m_resLdr->GetString("MBDownloadError"), ex->Message);
 					Result = ContentDialogResult::Secondary;
 				}
+				else if (PAL_MISSING_REQUIRED(UTIL_CheckResourceFiles(ConvertString(m_folder->Path).c_str(), ConvertString(m_msgfile).c_str())))
+				{
+					string = String::Concat(m_resLdr->GetString("MBDownloadError"), m_resLdr->GetString("MBDownloadIncomplete"));
+					Result = ContentDialogResult::Secondary;
+				}
 				else
 				{
 					string = m_resLdr->GetString("MBDownloadOK");

+ 2 - 1
winrt/SDLPal.Common/DownloadDialog.xaml.h

@@ -13,7 +13,7 @@ namespace SDLPal
 	public ref class DownloadDialog sealed
 	{
 	public:
-		DownloadDialog(Windows::ApplicationModel::Resources::ResourceLoader^ ldr, Windows::Storage::StorageFolder^ folder, Windows::Storage::Streams::IRandomAccessStream^ stream, double w, double h, bool from_url);
+		DownloadDialog(Windows::ApplicationModel::Resources::ResourceLoader^ ldr, Windows::Storage::StorageFolder^ folder, Windows::Storage::Streams::IRandomAccessStream^ stream, Platform::String^ msgfile, double w, double h, bool from_url);
 
 		property Windows::UI::Xaml::Controls::ContentDialogResult Result;
 
@@ -22,6 +22,7 @@ namespace SDLPal
 		Windows::Storage::StorageFolder^ m_folder;
 		Windows::Storage::Streams::IRandomAccessStream^ m_stream;
 		Platform::Object^ m_title;
+		Platform::String^ m_msgfile;
 		double m_width, m_height;
 		uint64_t m_totalBytes;
 		bool m_Closable, m_InitialPhase;

+ 1 - 1
winrt/SDLPal.Common/MainPage.xaml.cpp

@@ -238,7 +238,7 @@ void SDLPal::MainPage::CheckResourceFolder()
 				auto stream = AWait(file->OpenAsync(FileAccessMode::ReadWrite), g_eventHandle);
 				bool from_url = ((int)command->Id == 1);
 				concurrency::create_task(this->Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler([this, folder, file, stream, from_url]() {
-					m_dlg = ref new DownloadDialog(m_resLdr, folder, stream, ActualWidth, ActualHeight, from_url);
+					m_dlg = ref new DownloadDialog(m_resLdr, folder, stream, tbMsgFile->Text, ActualWidth, ActualHeight, from_url);
 				}))).then([this]()->IAsyncOperation<ContentDialogResult>^ {
 					return m_dlg->ShowAsync();
 				}).then([this, file, stream](ContentDialogResult result) {

+ 3 - 0
winrt/SDLPal.Common/Strings/en/Resources.resw

@@ -365,4 +365,7 @@ Please choose the correct folder or download game resource from the offical webs
   <data name="MBFolderManually" xml:space="preserve">
     <value>Please put game resource files into the folder before you select it.</value>
   </data>
+  <data name="MBDownloadIncomplete" xml:space="preserve">
+    <value>The downloaded archive does not contain necessary game resource files!</value>
+  </data>
 </root>

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

@@ -364,4 +364,7 @@
   <data name="MBFolderManually" xml:space="preserve">
     <value>请先将游戏资源文件放入后再选取该文件夹!</value>
   </data>
+  <data name="MBDownloadIncomplete" xml:space="preserve">
+    <value>已下载的压缩包中未包含全部必备的游戏资源文件!</value>
+  </data>
 </root>

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

@@ -364,4 +364,7 @@
   <data name="MBFolderManually" xml:space="preserve">
     <value>請先將遊戲資源檔放入後再選取該資料夾!</value>
   </data>
+  <data name="MBDownloadIncomplete" xml:space="preserve">
+    <value>已下載的壓縮包中未包含全部必備的遊戲資源檔!</value>
+  </data>
 </root>