Browse Source

[WIP] Download zipped game resource file: WinRT

[skip ci]
Lou Yihua 6 years ago
parent
commit
02110e43e3

+ 3 - 0
.gitmodules

@@ -7,3 +7,6 @@
 [submodule "3rd/mingw-std-threads"]
 	path = 3rd/mingw-std-threads
 	url = https://github.com/sdlpal/mingw-std-threads.git
+[submodule "3rd/zlib"]
+	path = 3rd/zlib
+	url = https://github.com/sdlpal/zlib.git

+ 1 - 0
3rd/zlib

@@ -0,0 +1 @@
+Subproject commit e550ae3658d8f1be6dc26d4fceb18c32b08557a8

+ 2 - 0
palcommon.h

@@ -147,6 +147,8 @@ typedef enum tagPALFILE {
 	PALFILE_MIDI = 0x00040000,
 	PALFILE_MUS = 0x00080000,
 	PALFILE_MUSIC_MASK = 0x000c0000,
+	PALFILE_ALL_ORIGIN = 0x000fdfff,
+	PALFILE_ALL_CUSTOM = 0x000f3fff
 } PALFILE;
 
 #define PAL_MISSING_REQUIRED(x) (((x) & PALFILE_REQUIRED_MASK) != 0)

+ 2 - 3
winrt/SDLPal.Common/AsyncHelper.h

@@ -1,4 +1,4 @@
-/* -*- mode: c; tab-width: 4; c-basic-offset: 4; c-file-style: "linux" -*- */
+/* -*- mode: c; tab-width: 4; c-basic-offset: 4; c-file-style: "windows" -*- */
 //
 // AsyncHelper.h: UWP support library for SDLPal.
 //
@@ -7,8 +7,7 @@
 //
 // Modified by: Lou Yihua @ 2016
 //
-// Copyright (c) 2009-2011, Wei Mingzhi <whistler_wmz@users.sf.net>.
-// Copyright (c) 2011-2017 SDLPAL development team.
+// Copyright (c) 2016-2017 SDLPAL development team.
 // All rights reserved.
 //
 // This file is part of SDLPAL.

+ 19 - 0
winrt/SDLPal.Common/DownloadDialog.xaml

@@ -0,0 +1,19 @@
+<ContentDialog
+    x:Uid="Downloading"
+    x:Class="SDLPal.DownloadDialog"
+    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+    xmlns:local="using:SDLPal"
+    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+    mc:Ignorable="d"
+    Title="正在下载……"
+    PrimaryButtonText="停止"
+    PrimaryButtonClick="OnPrimaryButtonClick"
+    MinHeight="0" MinWidth="0" Closing="OnClosing" Opened="OnOpened">
+
+    <StackPanel Orientation="Vertical">
+        <ProgressBar x:Name="pbDownload" HorizontalAlignment="Stretch" Height="10" VerticalAlignment="Top" />
+        <TextBlock x:Name="tbProgress" HorizontalAlignment="Right" Text="0 / 0" />
+    </StackPanel>
+</ContentDialog>

+ 261 - 0
winrt/SDLPal.Common/DownloadDialog.xaml.cpp

@@ -0,0 +1,261 @@
+//
+// DownloadDialog.xaml.cpp
+// DownloadDialog 类的实现
+//
+
+#include "pch.h"
+#include <wrl.h>
+#include <shcore.h>
+#include "DownloadDialog.xaml.h"
+#include "AsyncHelper.h"
+#include "NativeBuffer.h"
+#include "StringHelper.h"
+#include "minizip/unzip.h"
+
+using namespace SDLPal;
+
+using namespace Platform;
+using namespace Windows::Foundation;
+using namespace Windows::Foundation::Collections;
+using namespace Windows::Storage;
+using namespace Windows::Storage::Compression;
+using namespace Windows::Storage::Streams;
+using namespace Windows::UI::Core;
+using namespace Windows::UI::Popups;
+using namespace Windows::UI::Xaml;
+using namespace Windows::UI::Xaml::Controls;
+using namespace Windows::UI::Xaml::Controls::Primitives;
+using namespace Windows::UI::Xaml::Data;
+using namespace Windows::UI::Xaml::Input;
+using namespace Windows::UI::Xaml::Media;
+using namespace Windows::UI::Xaml::Navigation;
+using namespace Windows::Web::Http;
+
+// https://go.microsoft.com/fwlink/?LinkId=234238 上介绍了“内容对话框”项模板
+
+static const uint32_t _buffer_size = 65536;
+
+struct zip_file
+{
+	IStream* stream;
+	HRESULT  hr;
+	ULONG    cbBytes;
+
+	zip_file(IStream* s) : stream(s), hr(S_OK), cbBytes(0) {}
+};
+
+SDLPal::DownloadDialog::DownloadDialog(Platform::String^ link, Windows::ApplicationModel::Resources::ResourceLoader^ ldr, Windows::Storage::StorageFolder^ folder, Windows::Storage::Streams::IRandomAccessStream^ stream)
+	: m_link(link), m_stream(stream), m_Closable(false), m_InitialPhase(true), m_totalBytes(0), m_resLdr(ldr), m_folder(folder)
+{
+	InitializeComponent();
+
+	this->IsSecondaryButtonEnabled = false;
+}
+
+Platform::String^ SDLPal::DownloadDialog::FormatProgress()
+{
+	static auto format = [](wchar_t* buf, double v)->wchar_t* {
+		if (v <= 1024.0)
+			swprintf_s(buf, 32, L"%0.0f B", v);
+		else if (v <= 1048576.0)
+			swprintf_s(buf, 32, L"%0.2f KB", v / 1024.0);
+		else if (v <= 1073741824.0)
+			swprintf_s(buf, 32, L"%0.2f MB", v / 1048576.0);
+		else
+			swprintf_s(buf, 32, L"%0.2f GB", v / 1073741824.0);
+		return buf;
+	};
+
+	wchar_t buf[64], buf1[32], buf2[32];
+	swprintf_s(buf, L"%s / %s", format(buf1, pbDownload->Value), format(buf2, pbDownload->Maximum));
+	return ref new Platform::String(buf);
+}
+
+void SDLPal::DownloadDialog::OnPrimaryButtonClick(Windows::UI::Xaml::Controls::ContentDialog^ sender, Windows::UI::Xaml::Controls::ContentDialogButtonClickEventArgs^ args)
+{
+	m_Closable = true;
+}
+
+
+void SDLPal::DownloadDialog::OnClosing(Windows::UI::Xaml::Controls::ContentDialog^ sender, Windows::UI::Xaml::Controls::ContentDialogClosingEventArgs^ args)
+{
+	args->Cancel = !m_Closable;
+}
+
+
+void SDLPal::DownloadDialog::OnOpened(Windows::UI::Xaml::Controls::ContentDialog^ sender, Windows::UI::Xaml::Controls::ContentDialogOpenedEventArgs^ args)
+{
+	concurrency::create_task([this]() {
+		Exception^ ex = nullptr;
+		auto client = ref new HttpClient();
+		try
+		{
+			concurrency::create_task(client->GetAsync(ref new Uri(m_link), HttpCompletionOption::ResponseHeadersRead)).then(
+				[this](HttpResponseMessage^ response)->IAsyncOperationWithProgress<IInputStream^, uint64_t>^ {
+				response->EnsureSuccessStatusCode();
+
+				bool determinate = response->Content->Headers->HasKey("Content-Length");
+				if (determinate)
+				{
+					m_totalBytes = wcstoull(response->Content->Headers->Lookup("Content-Length")->Data(), nullptr, 10);
+				}
+				this->Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler([this, determinate]() {
+					pbDownload->Maximum = (double)m_totalBytes;
+					pbDownload->IsIndeterminate = !determinate;
+				}));
+				return response->Content->ReadAsInputStreamAsync();
+			}).then([this, client](IInputStream^ input) {
+				auto buffer = ref new Buffer(_buffer_size);
+				uint64_t bytes = 0;
+				HANDLE hEvent = CreateEventEx(nullptr, nullptr, 0, EVENT_ALL_ACCESS);
+				for (bool looping = true; looping; )
+				{
+					concurrency::create_task(input->ReadAsync(buffer, _buffer_size, InputStreamOptions::None)).then(
+						[this, &bytes, &looping](IBuffer^ result)->IAsyncOperationWithProgress<uint32_t, uint32_t>^ {
+						looping = (result->Length == _buffer_size) && !m_Closable;
+						bytes += result->Length;
+						this->Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler([this, bytes]() {
+							pbDownload->Value = (double)bytes;
+							tbProgress->Text = FormatProgress();
+							UpdateLayout();
+						}));
+						return m_stream->WriteAsync(result);
+					}).then([this](uint32_t)->IAsyncOperation<bool>^ {
+						return m_stream->FlushAsync();
+					}).wait();
+				}
+				delete buffer;
+				delete client;
+				delete input;
+
+				this->Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler([this, bytes]() {
+					this->Title = m_resLdr->GetString("Extracting");
+					pbDownload->Value = 0.0;
+					UpdateLayout();
+				}));
+
+				m_stream->Seek(0);
+
+				Microsoft::WRL::ComPtr<IStream> strm;
+				HRESULT hr;
+				if (FAILED(hr = CreateStreamOverRandomAccessStream(m_stream, IID_PPV_ARGS(&strm)))) throw ref new Platform::Exception(hr);
+
+				zlib_filefunc_def funcs = {
+					/* open  */ [](voidpf opaque, const char* filename, int mode)->voidpf { return new zip_file((IStream*)opaque); },
+					/* read  */ [](voidpf opaque, voidpf stream, void* buf, uLong size)->uLong {
+					auto zip = (zip_file*)stream;
+					return SUCCEEDED(zip->hr = zip->stream->Read(buf, size, &zip->cbBytes)) ? zip->cbBytes : 0;
+				},
+					/* write */ [](voidpf opaque, voidpf stream, const void* buf, uLong size)->uLong {
+					auto zip = (zip_file*)stream;
+					return SUCCEEDED(zip->hr = zip->stream->Write(buf, size, &zip->cbBytes)) ? zip->cbBytes : 0;
+				},
+					/* tell  */ [](voidpf opaque, voidpf stream)->long {
+					auto zip = (zip_file*)stream;
+					LARGE_INTEGER liPos = { 0 };
+					ULARGE_INTEGER uliPos;
+					return SUCCEEDED(zip->hr = zip->stream->Seek(liPos, STREAM_SEEK_CUR, &uliPos)) ? uliPos.LowPart : UNZ_ERRNO;
+				},
+					/* seek  */ [](voidpf opaque, voidpf stream, uLong offset, int origin)->long {
+					auto zip = (zip_file*)stream;
+					LARGE_INTEGER liPos = { offset };
+					ULARGE_INTEGER uliPos;
+					return SUCCEEDED(zip->hr = zip->stream->Seek(liPos, origin, &uliPos)) ? 0 : UNZ_ERRNO;
+				},
+					/* close */ [](voidpf opaque, voidpf stream)->int { delete (zip_file*)stream; return 0; },
+					/* error */ [](voidpf opaque, voidpf stream)->int { return reinterpret_cast<zip_file*>(stream)->hr; },
+					strm.Get()
+				};
+				unz_global_info ugi;
+				char szFilename[65536];
+				uLong filenum = 0;
+				bool success = true;
+
+				auto uzf = unzOpen2("", &funcs);
+				unzGetGlobalInfo(uzf, &ugi);
+				this->Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler([this, ugi]() { pbDownload->Maximum = ugi.number_entry; UpdateLayout(); }));
+				for (auto ret = unzGoToFirstFile(uzf); ret == UNZ_OK; ret = unzGoToNextFile(uzf))
+				{
+					unz_file_info ufi;
+					if (UNZ_OK == unzGetCurrentFileInfo(uzf, &ufi, szFilename, sizeof(szFilename), nullptr, 0, nullptr, 0) &&
+						UNZ_OK == unzOpenCurrentFile(uzf))
+					{
+						std::auto_ptr<uint8_t> buf(new uint8_t[ufi.uncompressed_size]);
+						auto len = unzReadCurrentFile(uzf, buf.get(), ufi.uncompressed_size);
+						unzCloseCurrentFile(uzf);
+						if (len != ufi.uncompressed_size)
+						{
+							success = false;
+							break;
+						}
+
+						auto local = m_folder;
+						uLong prev = 0;
+						for (uLong i = 0; i < ufi.size_filename; i++)
+						{
+							if (szFilename[i] != '/') continue;
+							try
+							{
+								concurrency::create_task(local->GetFolderAsync(ConvertString(szFilename + prev, i - prev))).then([&local](StorageFolder^ sub) { local = sub; }).wait();
+							}
+							catch (Exception^ e)
+							{
+								concurrency::create_task(local->CreateFolderAsync(ConvertString(szFilename + prev, i - prev))).then([&local](StorageFolder^ sub) { local = sub; }).wait();
+							}
+							prev = i + 1;
+						}
+						if (prev < ufi.size_filename)
+						{
+							IRandomAccessStream^ stm = nullptr;
+							StorageFile^ file = nullptr;
+							auto filename = ConvertString(szFilename + prev, ufi.size_filename - prev);
+							concurrency::create_task(local->CreateFileAsync(filename, CreationCollisionOption::ReplaceExisting)).then([&](StorageFile^ f)->IAsyncOperation<IRandomAccessStream^>^ {
+								return (file = f)->OpenAsync(Windows::Storage::FileAccessMode::ReadWrite);
+							}).then([&](IRandomAccessStream^ s)->IAsyncOperationWithProgress<uint32_t, uint32_t>^ {
+								return (stm = s)->WriteAsync(NativeBuffer::GetIBuffer(buf.get(), ufi.uncompressed_size));
+							}).then([&](uint32_t size)->IAsyncOperation<bool>^ {
+								if (size < ufi.uncompressed_size) throw ref new Exception(E_FAIL);
+								return stm->FlushAsync();
+							}).wait();
+							delete stm;
+							delete file;
+						}
+					}
+					else
+					{
+						success = false;
+						break;
+					}
+					filenum++;
+					this->Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler([this, filenum, &ugi]() {
+						wchar_t buf[64];
+						swprintf_s(buf, L"%lu/%lu", filenum, ugi.number_entry);
+						pbDownload->Value = (double)filenum;
+						tbProgress->Text = ref new Platform::String(buf);
+						UpdateLayout();
+					}));
+				}
+				unzClose(uzf);
+
+				if (!success) throw ref new Exception(E_FAIL);
+			}).wait();
+		}
+		catch (Exception^ e)
+		{
+			ex = e; 
+		}
+
+		this->Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler([this, ex]() {
+			Platform::String^ string;
+			if (m_Closable)
+				string = m_resLdr->GetString("MBDownloadCanceled");
+			else if (ex)
+				string = String::Concat(m_resLdr->GetString("MBDownloadError"), ex->Message);
+			else
+				string = m_resLdr->GetString("MBDownloadOK");
+			(ref new MessageDialog(string, m_resLdr->GetString("MBDownloadTitle")))->ShowAsync();
+			m_Closable = true;
+			Hide();
+		}));
+	});
+}

+ 32 - 0
winrt/SDLPal.Common/DownloadDialog.xaml.h

@@ -0,0 +1,32 @@
+//
+// DownloadDialog.xaml.h
+// DownloadDialog 类的声明
+//
+
+#pragma once
+
+#include "DownloadDialog.g.h"
+
+namespace SDLPal
+{
+	[Windows::Foundation::Metadata::WebHostHidden]
+	public ref class DownloadDialog sealed
+	{
+	public:
+		DownloadDialog(Platform::String^ link, Windows::ApplicationModel::Resources::ResourceLoader^ ldr, Windows::Storage::StorageFolder^ folder, Windows::Storage::Streams::IRandomAccessStream^ stream);
+
+	private:
+		Platform::String^ m_link;
+		Windows::ApplicationModel::Resources::ResourceLoader^ m_resLdr;
+		Windows::Storage::StorageFolder^ m_folder;
+		Windows::Storage::Streams::IRandomAccessStream^ m_stream;
+		uint64_t m_totalBytes;
+		bool m_Closable, m_InitialPhase;
+
+		Platform::String^ FormatProgress();
+
+		void OnPrimaryButtonClick(Windows::UI::Xaml::Controls::ContentDialog^ sender, Windows::UI::Xaml::Controls::ContentDialogButtonClickEventArgs^ args);
+		void OnClosing(Windows::UI::Xaml::Controls::ContentDialog^ sender, Windows::UI::Xaml::Controls::ContentDialogClosingEventArgs^ args);
+		void OnOpened(Windows::UI::Xaml::Controls::ContentDialog^ sender, Windows::UI::Xaml::Controls::ContentDialogOpenedEventArgs^ args);
+	};
+}

+ 12 - 0
winrt/SDLPal.Common/MainPage.xaml

@@ -27,6 +27,18 @@
                     <TextBox x:Name="tbGamePath" x:Uid="GamePath" Grid.Column="0" TextWrapping="Wrap" VerticalAlignment="Top" Header="游戏资源文件夹" IsReadOnly="True" PlaceholderText="未选择游戏资源文件夹"/>
                     <Button x:Name="btnBrowseGame" x:Uid="ButtonBrowse" Grid.Column="1" Content="浏览" HorizontalAlignment="Left" VerticalAlignment="Bottom" Click="btnBrowseFolder_Click" />
                 </Grid>
+                <Grid>
+                    <Grid.ColumnDefinitions>
+                        <ColumnDefinition/>
+                        <ColumnDefinition/>
+                        <ColumnDefinition/>
+                        <ColumnDefinition Width="Auto"/>
+                    </Grid.ColumnDefinitions>
+                    <RadioButton x:Name="rbDownloadLink1" x:Uid="DownloadLink1" Grid.Column="0" GroupName="DownloadLink" Content="地址 1" Tag="http://pal5q.baiyou100.com/pal5/download/98xjrq.html" />
+                    <RadioButton x:Name="rbDownloadLink2" x:Uid="DownloadLink2" Grid.Column="1" GroupName="DownloadLink" Content="地址 2" Tag="http://pal5q.baiyou100.com/pal5/download/98xjrq.html" />
+                    <RadioButton x:Name="rbDownloadLink3" x:Uid="DownloadLink3" Grid.Column="2" GroupName="DownloadLink" Content="地址 3" Tag="http://pal5q.baiyou100.com/pal5/download/98xjrq.html" />
+                    <Button x:Name="btnDownloadGame" x:Uid="ButtonDownload" Grid.Column="3" Content="下载游戏" HorizontalAlignment="Center" VerticalAlignment="Center" Click="btnDownloadGame_Click" IsEnabled="False" />
+                </Grid>
                 <CheckBox x:Name="cbUseMsgFile" x:Uid="UseMessageFile" Content="自定义语言文件" Checked="cbUseFile_CheckChanged" Unchecked="cbUseFile_CheckChanged" />
                 <Grid x:Name="gridMsgFile">
                     <Grid.ColumnDefinitions>

+ 100 - 8
winrt/SDLPal.Common/MainPage.xaml.cpp

@@ -5,17 +5,20 @@
 
 #include "pch.h"
 #include "MainPage.xaml.h"
+#include "DownloadDialog.xaml.h"
 #include "StringHelper.h"
 #include "AsyncHelper.h"
-#include "../../global.h"
-#include "../../palcfg.h"
-#include "../../generated.h"
+#include "global.h"
+#include "palcfg.h"
+#include "util.h"
+#include "generated.h"
 
 using namespace SDLPal;
 
 using namespace Platform;
 using namespace Windows::Foundation;
 using namespace Windows::Foundation::Collections;
+using namespace Windows::UI::Popups;
 using namespace Windows::UI::Xaml;
 using namespace Windows::UI::Xaml::Controls;
 using namespace Windows::UI::Xaml::Controls::Primitives;
@@ -54,10 +57,25 @@ MainPage::MainPage()
 
 	LoadControlContents(false);
 
+	btnDownloadGame->IsEnabled = (tbGamePath->Text->Length() > 0);
+
+	RadioButton^ links[] = { rbDownloadLink1, rbDownloadLink2, rbDownloadLink3 };
+	srand(time(NULL));
+	links[rand() % 3]->IsChecked = true;
+
 	m_resLdr = Windows::ApplicationModel::Resources::ResourceLoader::GetForCurrentView();
 	if (static_cast<App^>(Application::Current)->LastCrashed)
 	{
-		(ref new Windows::UI::Popups::MessageDialog(m_resLdr->GetString("MBCrashContent")))->ShowAsync();
+		(ref new MessageDialog(m_resLdr->GetString("MBCrashContent")))->ShowAsync();
+	}
+
+	try
+	{
+		delete AWait(Windows::Storage::ApplicationData::Current->LocalFolder->GetFileAsync("sdlpal.cfg"));
+	}
+	catch (Exception^)
+	{
+		(ref new MessageDialog(m_resLdr->GetString("MBStartupMessage"), m_resLdr->GetString("MBStartupTitle")))->ShowAsync();
 	}
 }
 
@@ -188,6 +206,15 @@ void SDLPal::MainPage::btnFinish_Click(Platform::Object^ sender, Windows::UI::Xa
 {
 	if (tbGamePath->Text->Length() > 0)
 	{
+		if (PAL_MISSING_REQUIRED(UTIL_CheckResourceFiles(ConvertString(tbGamePath->Text).c_str(), ConvertString(tbMsgFile->Text).c_str())))
+		{
+			auto msg = std::wstring(m_resLdr->GetString("MBRequired")->Data());
+			msg.replace(msg.find(L"{0}", 0), 3, tbGamePath->Text->Data());
+			(ref new MessageDialog(ref new Platform::String(msg.c_str())))->ShowAsync();
+			tbGamePath->Focus(Windows::UI::Xaml::FocusState::Programmatic);
+			return;
+		}
+
 		auto fal = Windows::Storage::AccessCache::StorageApplicationPermissions::FutureAccessList;
 		for (auto i = m_acl.begin(); i != m_acl.end(); i++)
 		{
@@ -203,15 +230,13 @@ void SDLPal::MainPage::btnFinish_Click(Platform::Object^ sender, Windows::UI::Xa
 		gConfig.fLaunchSetting = FALSE;
 		PAL_SaveConfig();
 
-		auto dlg = ref new Windows::UI::Popups::MessageDialog(m_resLdr->GetString("MBExitContent"));
-		dlg->Title = m_resLdr->GetString("MBExitTitle");
-		concurrency::create_task(dlg->ShowAsync()).then([] (Windows::UI::Popups::IUICommand^ command) {
+		concurrency::create_task((ref new MessageDialog(m_resLdr->GetString("MBExitContent"), m_resLdr->GetString("MBExitTitle")))->ShowAsync()).then([] (IUICommand^ command) {
 			Application::Current->Exit();
 		});
 	}
 	else
 	{
-		(ref new Windows::UI::Popups::MessageDialog(m_resLdr->GetString("MBEmptyContent")))->ShowAsync();
+		(ref new MessageDialog(m_resLdr->GetString("MBEmptyContent")))->ShowAsync();
 	}
 }
 
@@ -303,3 +328,70 @@ void SDLPal::MainPage::Page_Loaded(Platform::Object^ sender, Windows::UI::Xaml::
 	concurrency::create_task(statusBar->ShowAsync()).then([statusBar]() { statusBar->BackgroundOpacity = 1.0; });
 #endif
 }
+
+
+void SDLPal::MainPage::btnDownloadGame_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
+{
+	Platform::String^ link = nullptr;
+	Windows::UI::Xaml::Controls::RadioButton^ controls[] = {
+		this->rbDownloadLink1, this->rbDownloadLink2, this->rbDownloadLink3
+	};
+	for (int i = 0; i < 3; i++)
+	{
+		if (controls[i]->IsChecked->Value)
+		{
+			link = static_cast<Platform::String^>(controls[i]->Tag);
+			break;
+		}
+	}
+	auto folder = dynamic_cast<Windows::Storage::StorageFolder^>(tbGamePath->Tag);
+	auto msgbox = ref new MessageDialog(m_resLdr->GetString("MBDownloadMessage"), m_resLdr->GetString("MBDownloadTitle"));
+	msgbox->Commands->Append(ref new UICommand(m_resLdr->GetString("MBButtonOK"), nullptr, 1));
+	msgbox->Commands->Append(ref new UICommand(m_resLdr->GetString("MBButtonCancel"), nullptr, nullptr));
+	msgbox->DefaultCommandIndex = 0;
+	msgbox->CancelCommandIndex = 1;
+	concurrency::create_task(msgbox->ShowAsync()).then([this](IUICommand^ command)->IAsyncOperation<IUICommand^>^ {
+		if (command->Id != nullptr)
+		{
+			if (UTIL_CheckResourceFiles(ConvertString(tbGamePath->Text).c_str(), ConvertString(tbMsgFile->Text).c_str()) != PALFILE_ALL_ORIGIN)
+			{
+				auto msgbox = ref new MessageDialog(m_resLdr->GetString("MBDownloadOverwrite"), m_resLdr->GetString("MBDownloadTitle"));
+				msgbox->Commands->Append(ref new UICommand(m_resLdr->GetString("MBButtonYes"), nullptr, 1));
+				msgbox->Commands->Append(ref new UICommand(m_resLdr->GetString("MBButtonNo"), nullptr, nullptr));
+				msgbox->DefaultCommandIndex = 0;
+				msgbox->CancelCommandIndex = 1;
+				return msgbox->ShowAsync();
+			}
+			else
+			{
+				return concurrency::create_async([command]()->IUICommand^ { return command; });
+			}
+		}
+		else
+		{
+			return concurrency::create_async([command]()->IUICommand^ { return command; });
+		}
+	}).then([this, folder, link](IUICommand^ command) {
+		if (command->Id != nullptr)
+		{
+			HANDLE hEvent = CreateEventEx(nullptr, nullptr, 0, EVENT_ALL_ACCESS);
+			try
+			{
+				auto file = AWait(folder->CreateFileAsync("pal98.zip", Windows::Storage::CreationCollisionOption::ReplaceExisting), hEvent);
+				auto stream = AWait(file->OpenAsync(Windows::Storage::FileAccessMode::ReadWrite), hEvent);
+				concurrency::create_task((ref new DownloadDialog(link, m_resLdr, folder, stream))->ShowAsync()).then(
+					[this, file, stream, hEvent](ContentDialogResult result) {
+					delete stream;
+					AWait(file->DeleteAsync(), hEvent);
+					delete file;
+					CloseHandle(hEvent);
+				});
+			}
+			catch (Exception^ e)
+			{
+				(ref new MessageDialog(String::Concat(m_resLdr->GetString("MBDownloadError"), e)))->ShowAsync();
+				CloseHandle(hEvent);
+			}
+		}
+	});
+}

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

@@ -75,5 +75,7 @@ namespace SDLPal
 
 	internal:
 		static MainPage^ Current;
+	private:
+		void btnDownloadGame_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
 	};
 }

+ 2 - 2
winrt/SDLPal.Common/NativeBuffer.h

@@ -77,10 +77,10 @@ public:
 		return S_OK;
 	}
 
-	static Windows::Storage::Streams::IBuffer^ GetIBuffer(byte *buffer, uint32_t totalSize)
+	static Windows::Storage::Streams::IBuffer^ GetIBuffer(void *buffer, uint32_t totalSize)
 	{
 		Microsoft::WRL::ComPtr<NativeBuffer> nativeBuffer;
-		Microsoft::WRL::Details::MakeAndInitialize<NativeBuffer>(&nativeBuffer, buffer, totalSize);
+		Microsoft::WRL::Details::MakeAndInitialize<NativeBuffer>(&nativeBuffer, (byte*)buffer, totalSize);
 		auto obj = reinterpret_cast<IInspectable*>(nativeBuffer.Get());
 		return reinterpret_cast<Windows::Storage::Streams::IBuffer^>(obj);
 	}

+ 15 - 0
winrt/SDLPal.Common/StringHelper.h

@@ -78,6 +78,21 @@ static Platform::String^ ConvertString(const char* src)
 		return "";
 }
 
+static Platform::String^ ConvertString(const char* src, int length)
+{
+	if (src)
+	{
+		int len = MultiByteToWideChar(CP_ACP, 0, src, length, nullptr, 0);
+		auto wc = new wchar_t[len];
+		MultiByteToWideChar(CP_ACP, 0, src, length, wc, len);
+		auto dst = ref new Platform::String(wc, len);
+		delete[] wc;
+		return dst;
+	}
+	else
+		return "";
+}
+
 static Platform::String^ ConvertString(const std::string& src)
 {
 	return ConvertString(src.c_str());

+ 68 - 4
winrt/SDLPal.Common/Strings/en/Resources.resw

@@ -142,16 +142,19 @@
     <value>Choose format of BGM</value>
   </data>
   <data name="ButtonBrowse.Content" xml:space="preserve">
-    <value>Browse</value>
+    <value>browse</value>
   </data>
   <data name="ButtonDefault.Content" xml:space="preserve">
-    <value>Default setting</value>
+    <value>default setting</value>
+  </data>
+  <data name="ButtonDownload.Content" xml:space="preserve">
+    <value>download game</value>
   </data>
   <data name="ButtonFinish.Content" xml:space="preserve">
-    <value>Finish setting</value>
+    <value>finish setting</value>
   </data>
   <data name="ButtonReset.Content" xml:space="preserve">
-    <value>Reset setting</value>
+    <value>reset setting</value>
   </data>
   <data name="CD.Header" xml:space="preserve">
     <value>Format of CD track</value>
@@ -162,6 +165,21 @@
   <data name="Debug.Content" xml:space="preserve">
     <value>Debug</value>
   </data>
+  <data name="Downloading.PrimaryButtonText" xml:space="preserve">
+    <value>Stop</value>
+  </data>
+  <data name="Downloading.Title" xml:space="preserve">
+    <value>Downloading...</value>
+  </data>
+  <data name="DownloadLink1.Content" xml:space="preserve">
+    <value>link 1</value>
+  </data>
+  <data name="DownloadLink2.Content" xml:space="preserve">
+    <value>link 2</value>
+  </data>
+  <data name="DownloadLink3.Content" xml:space="preserve">
+    <value>link 3</value>
+  </data>
   <data name="EnableAVI.Header" xml:space="preserve">
     <value>Enable AVI animation</value>
   </data>
@@ -174,6 +192,9 @@
   <data name="Error.Content" xml:space="preserve">
     <value>Error</value>
   </data>
+  <data name="Extracting" xml:space="preserve">
+    <value>Extracting...</value>
+  </data>
   <data name="Fatal.Content" xml:space="preserve">
     <value>Fatal</value>
   </data>
@@ -201,9 +222,32 @@
   <data name="LogLevel.PlaceholderText" xml:space="preserve">
     <value>Choose logging level</value>
   </data>
+  <data name="MBButtonCancel" xml:space="preserve">
+    <value>&amp;cancel</value>
+  </data>
+  <data name="MBButtonOK" xml:space="preserve">
+    <value>&amp;ok</value>
+  </data>
   <data name="MBCrashContent" xml:space="preserve">
     <value>The program is abnormally terminated last time. The setting page has been launched for you. Please check if there are any incorrect settings.</value>
   </data>
+  <data name="MBDownloadCanceled" xml:space="preserve">
+    <value>Download aborted by user!</value>
+  </data>
+  <data name="MBDownloadError" xml:space="preserve">
+    <value>Download aborted due to error: </value>
+  </data>
+  <data name="MBDownloadMessage" xml:space="preserve">
+    <value>This App is about to download the free &amp; publicly available game resource from baiyou100.com to the folder you've just chosen.
+Please notice that all the copyright of the downloaded game resource belongs to its creator, Softstar, Inc. This App provides the download function here only for convenient purpose, and Softstar, Inc. may remove the download links at any time. Furthermore, you should take full responsibility for using the downloaded game resource which is completely irrelevant to the developers of this App.
+You have to agree the above declaration before you click 'ok' to start the downloading process. Otherwise, please click 'cancel' to return.</value>
+  </data>
+  <data name="MBDownloadOK" xml:space="preserve">
+    <value>Game resource has been successfully downloaded!</value>
+  </data>
+  <data name="MBDownloadTitle" xml:space="preserve">
+    <value>Download hint</value>
+  </data>
   <data name="MBEmptyContent" xml:space="preserve">
     <value>The game resource folder must be specified!</value>
   </data>
@@ -214,6 +258,13 @@ You can use the main menu option inside the game to return to this page.</value>
   <data name="MBExitTitle" xml:space="preserve">
     <value>Setting finished</value>
   </data>
+  <data name="MBStartupMessage" xml:space="preserve">
+    <value>You need to choose the game resource folder before you can start the game. And for anyone who doesn't have the game resource for now, you can download it from its publisher for free by clicking the 'downloading game' button.
+Once you've finished the setting process, you will be brought to the game directly at next launch.</value>
+  </data>
+  <data name="MBStartupTitle" xml:space="preserve">
+    <value>Welcome to SDLPal!</value>
+  </data>
   <data name="MessageFile.PlaceholderText" xml:space="preserve">
     <value>No customized message file</value>
   </data>
@@ -292,4 +343,17 @@ You can use the main menu option inside the game to return to this page.</value>
   <data name="Warning.Content" xml:space="preserve">
     <value>Warning</value>
   </data>
+  <data name="MBButtonNo" xml:space="preserve">
+    <value>No</value>
+  </data>
+  <data name="MBButtonYes" xml:space="preserve">
+    <value>Yes</value>
+  </data>
+  <data name="MBDownloadOverwrite" xml:space="preserve">
+    <value>The current game resource in destination folder will be overwrited on a successful download. Continue?</value>
+  </data>
+  <data name="MBRequired" xml:space="preserve">
+    <value>Missing required game resource in folder '{0}'.
+Please choose the correct folder or download game resource from the offical website!</value>
+  </data>
 </root>

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

@@ -147,6 +147,9 @@
   <data name="ButtonDefault.Content" xml:space="preserve">
     <value>默认设置</value>
   </data>
+  <data name="ButtonDownload.Content" xml:space="preserve">
+    <value>下载游戏资源</value>
+  </data>
   <data name="ButtonFinish.Content" xml:space="preserve">
     <value>完成设置</value>
   </data>
@@ -162,6 +165,21 @@
   <data name="Debug.Content" xml:space="preserve">
     <value>调试信息</value>
   </data>
+  <data name="Downloading.PrimaryButtonText" xml:space="preserve">
+    <value>停止</value>
+  </data>
+  <data name="Downloading.Title" xml:space="preserve">
+    <value>正在下载……</value>
+  </data>
+  <data name="DownloadLink1.Content" xml:space="preserve">
+    <value>地址 1</value>
+  </data>
+  <data name="DownloadLink2.Content" xml:space="preserve">
+    <value>地址 2</value>
+  </data>
+  <data name="DownloadLink3.Content" xml:space="preserve">
+    <value>地址 3</value>
+  </data>
   <data name="EnableAVI.Header" xml:space="preserve">
     <value>启用 AVI 过场动画</value>
   </data>
@@ -174,6 +192,9 @@
   <data name="Error.Content" xml:space="preserve">
     <value>严重错误</value>
   </data>
+  <data name="Extracting" xml:space="preserve">
+    <value>正在解压缩……</value>
+  </data>
   <data name="Fatal.Content" xml:space="preserve">
     <value>致命错误</value>
   </data>
@@ -201,9 +222,32 @@
   <data name="LogLevel.PlaceholderText" xml:space="preserve">
     <value>选择日志记录级别</value>
   </data>
+  <data name="MBButtonCancel" xml:space="preserve">
+    <value>取消</value>
+  </data>
+  <data name="MBButtonOK" xml:space="preserve">
+    <value>确定(&amp;O)</value>
+  </data>
   <data name="MBCrashContent" xml:space="preserve">
     <value>上次程序异常退出,已显示设置页供您检查设置是否正确。</value>
   </data>
+  <data name="MBDownloadCanceled" xml:space="preserve">
+    <value>下载已被用户中止!</value>
+  </data>
+  <data name="MBDownloadError" xml:space="preserve">
+    <value>下载已被如下错误中止:</value>
+  </data>
+  <data name="MBDownloadMessage" xml:space="preserve">
+    <value>本应用即将为您从baiyou100.com网站下载免费的《仙剑奇侠传 98柔情篇》游戏资源文件并保存于您所选择的文件夹中。
+您应知晓,该数据文件的版权归游戏开发方大宇资讯所有,本应用仅出于方便您进行游戏的目的在此提供下载功能,游戏开发方可能会随时移除相关下载链接。您同意,您对下载资源文件的使用仅代表您个人意愿,与本应用的开发者无关。
+如您同意此约定,请点击“确定”按钮开始下载,否则请点击“取消”返回设置页面。</value>
+  </data>
+  <data name="MBDownloadOK" xml:space="preserve">
+    <value>游戏资源下载已成功完成!</value>
+  </data>
+  <data name="MBDownloadTitle" xml:space="preserve">
+    <value>下载提示</value>
+  </data>
   <data name="MBEmptyContent" xml:space="preserve">
     <value>必须指定游戏资源文件夹!</value>
   </data>
@@ -214,6 +258,13 @@
   <data name="MBExitTitle" xml:space="preserve">
     <value>设置已完成</value>
   </data>
+  <data name="MBStartupMessage" xml:space="preserve">
+    <value>请您首先在设置页面中选择游戏资源所在文件夹后方可进入游戏;如您尚未拥有可执行的游戏资源,您也可以在选择文件夹后点击“下载游戏”按钮从游戏发行方网站下载免费游戏资源。
+一旦您完成设置,在您下一次启动本应用时将直接开始游戏进程。</value>
+  </data>
+  <data name="MBStartupTitle" xml:space="preserve">
+    <value>欢迎您使用 SDLPal!</value>
+  </data>
   <data name="MessageFile.PlaceholderText" xml:space="preserve">
     <value>无自定义语言文件</value>
   </data>
@@ -292,4 +343,16 @@
   <data name="Warning.Content" xml:space="preserve">
     <value>普通警告</value>
   </data>
+  <data name="MBButtonNo" xml:space="preserve">
+    <value>否</value>
+  </data>
+  <data name="MBButtonYes" xml:space="preserve">
+    <value>是</value>
+  </data>
+  <data name="MBDownloadOverwrite" xml:space="preserve">
+    <value>检测到目标文件夹中已存在游戏资源,下载成功后将会覆盖现有的资源文件,是否继续?</value>
+  </data>
+  <data name="MBRequired" xml:space="preserve">
+    <value>在文件夹“{0}”中缺少必需的游戏资源文件,请选择正确的文件夹或从官方网站下载游戏数据文件!</value>
+  </data>
 </root>

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

@@ -147,6 +147,9 @@
   <data name="ButtonDefault.Content" xml:space="preserve">
     <value>默認設定</value>
   </data>
+  <data name="ButtonDownload.Content" xml:space="preserve">
+    <value>下載遊戲</value>
+  </data>
   <data name="ButtonFinish.Content" xml:space="preserve">
     <value>完成設定</value>
   </data>
@@ -162,6 +165,21 @@
   <data name="Debug.Content" xml:space="preserve">
     <value>調試信息</value>
   </data>
+  <data name="Downloading.PrimaryButtonText" xml:space="preserve">
+    <value>停止</value>
+  </data>
+  <data name="Downloading.Title" xml:space="preserve">
+    <value>正在下載……</value>
+  </data>
+  <data name="DownloadLink1.Content" xml:space="preserve">
+    <value>地址 1</value>
+  </data>
+  <data name="DownloadLink2.Content" xml:space="preserve">
+    <value>地址 2</value>
+  </data>
+  <data name="DownloadLink3.Content" xml:space="preserve">
+    <value>地址 3</value>
+  </data>
   <data name="EnableAVI.Header" xml:space="preserve">
     <value>啟用 AVI 過場動畫</value>
   </data>
@@ -174,6 +192,9 @@
   <data name="Error.Content" xml:space="preserve">
     <value>嚴重錯誤</value>
   </data>
+  <data name="Extracting" xml:space="preserve">
+    <value>正在解壓縮……</value>
+  </data>
   <data name="Fatal.Content" xml:space="preserve">
     <value>致命錯誤</value>
   </data>
@@ -201,9 +222,32 @@
   <data name="LogLevel.PlaceholderText" xml:space="preserve">
     <value>選擇日誌記錄級別</value>
   </data>
+  <data name="MBButtonCancel" xml:space="preserve">
+    <value>取消(&amp;C)</value>
+  </data>
+  <data name="MBButtonOK" xml:space="preserve">
+    <value>確定(&amp;O)</value>
+  </data>
   <data name="MBCrashContent" xml:space="preserve">
     <value>上次程式異常退出,已顯示設定頁供您檢查設定是否正確。</value>
   </data>
+  <data name="MBDownloadCanceled" xml:space="preserve">
+    <value>下載已被用戶中止!</value>
+  </data>
+  <data name="MBDownloadError" xml:space="preserve">
+    <value>下載已被如下錯誤中止:</value>
+  </data>
+  <data name="MBDownloadMessage" xml:space="preserve">
+    <value>本應用即將為您從baiyou100.com網站下載免費的《仙劍奇俠傳 98柔情篇》遊戲資源檔並保存於您所選擇的資料夾中。
+您應知曉,該資源檔的版權歸遊戲開發方大宇資訊所有,本應用僅出於方便您進行遊戲的目的在此提供下載功能,遊戲開發方可能會隨時移除相關下載連結。您同意,您對下載資源檔的使用僅代表您個人意願,與本應用的開發者無關。
+如您同意此約定,請點擊「確定」按鈕開始下載,否則請點擊「取消」返回設置頁面。</value>
+  </data>
+  <data name="MBDownloadOK" xml:space="preserve">
+    <value>遊戲資源下載已成功完成!</value>
+  </data>
+  <data name="MBDownloadTitle" xml:space="preserve">
+    <value>下載提示</value>
+  </data>
   <data name="MBEmptyContent" xml:space="preserve">
     <value>必須指定遊戲資源檔案夾!</value>
   </data>
@@ -214,6 +258,13 @@
   <data name="MBExitTitle" xml:space="preserve">
     <value>設定已完成</value>
   </data>
+  <data name="MBStartupMessage" xml:space="preserve">
+    <value>請您首先在設置頁面中選擇遊戲資源所在資料夾後方可進入遊戲;如您尚未擁有可執行的遊戲資源,您也可以在選擇資料夾後點擊「下載遊戲」按鈕從遊戲發行方網站下載免費遊戲資源。
+一旦您完成設置,在您下一次啟動本應用時將直接開始遊戲進程。</value>
+  </data>
+  <data name="MBStartupTitle" xml:space="preserve">
+    <value>歡迎您使用 SDLPal!</value>
+  </data>
   <data name="MessageFile.PlaceholderText" xml:space="preserve">
     <value>無自訂語言檔案</value>
   </data>
@@ -292,4 +343,16 @@
   <data name="Warning.Content" xml:space="preserve">
     <value>普通警告</value>
   </data>
+  <data name="MBButtonNo" xml:space="preserve">
+    <value>否</value>
+  </data>
+  <data name="MBButtonYes" xml:space="preserve">
+    <value>是</value>
+  </data>
+  <data name="MBDownloadOverwrite" xml:space="preserve">
+    <value>檢測到目的檔案夾中已存在遊戲資源,下載成功後將會覆蓋現有的資源檔,是否繼續?</value>
+  </data>
+  <data name="MBRequired" xml:space="preserve">
+    <value>在檔案夾「{0}」中缺少必需的遊戲資源檔,請選擇正確的檔案夾或從官方網站下載遊戲資料檔案!</value>
+  </data>
 </root>

+ 17 - 2
winrt/SDLPal.UWP.sln

@@ -1,7 +1,7 @@
 
 Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 14
-VisualStudioVersion = 14.0.25123.0
+# Visual Studio 15
+VisualStudioVersion = 15.0.26403.0
 MinimumVisualStudioVersion = 10.0.40219.1
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDLPal.Core", "SDLPal.UWP\SDLPal.Core.vcxproj", "{96D34C5D-CE4D-43F7-822C-C34775AAFEA8}"
 EndProject
@@ -9,6 +9,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDLPal.Common", "SDLPal.UWP
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDLPal", "SDLPal.UWP\SDLPal.UWP.vcxproj", "{B1809B68-0D9A-4E0E-ADDB-272CA1C9FA38}"
 	ProjectSection(ProjectDependencies) = postProject
+		{CA32282B-2122-4BEC-AFB1-2F3103FB9198} = {CA32282B-2122-4BEC-AFB1-2F3103FB9198}
 		{89E9B32E-A86A-47C3-A948-D2B1622925CE} = {89E9B32E-A86A-47C3-A948-D2B1622925CE}
 		{96D34C5D-CE4D-43F7-822C-C34775AAFEA8} = {96D34C5D-CE4D-43F7-822C-C34775AAFEA8}
 		{0425A2D9-BB80-4C35-8C69-1DA6E3494FA6} = {0425A2D9-BB80-4C35-8C69-1DA6E3494FA6}
@@ -19,6 +20,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2-UWP", "..\3rd\SDL\Visu
 		{0425A2D9-BB80-4C35-8C69-1DA6E3494FA6} = {0425A2D9-BB80-4C35-8C69-1DA6E3494FA6}
 	EndProjectSection
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "..\3rd\zlib\zlib.uwp.vcxproj", "{CA32282B-2122-4BEC-AFB1-2F3103FB9198}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|ARM = Debug|ARM
@@ -83,6 +86,18 @@ Global
 		{89E9B32E-A86A-47C3-A948-D2B1622925CE}.Release|x64.Build.0 = Release|x64
 		{89E9B32E-A86A-47C3-A948-D2B1622925CE}.Release|x86.ActiveCfg = Release|Win32
 		{89E9B32E-A86A-47C3-A948-D2B1622925CE}.Release|x86.Build.0 = Release|Win32
+		{CA32282B-2122-4BEC-AFB1-2F3103FB9198}.Debug|ARM.ActiveCfg = Debug|ARM
+		{CA32282B-2122-4BEC-AFB1-2F3103FB9198}.Debug|ARM.Build.0 = Debug|ARM
+		{CA32282B-2122-4BEC-AFB1-2F3103FB9198}.Debug|x64.ActiveCfg = Debug|x64
+		{CA32282B-2122-4BEC-AFB1-2F3103FB9198}.Debug|x64.Build.0 = Debug|x64
+		{CA32282B-2122-4BEC-AFB1-2F3103FB9198}.Debug|x86.ActiveCfg = Debug|Win32
+		{CA32282B-2122-4BEC-AFB1-2F3103FB9198}.Debug|x86.Build.0 = Debug|Win32
+		{CA32282B-2122-4BEC-AFB1-2F3103FB9198}.Release|ARM.ActiveCfg = Release|ARM
+		{CA32282B-2122-4BEC-AFB1-2F3103FB9198}.Release|ARM.Build.0 = Release|ARM
+		{CA32282B-2122-4BEC-AFB1-2F3103FB9198}.Release|x64.ActiveCfg = Release|x64
+		{CA32282B-2122-4BEC-AFB1-2F3103FB9198}.Release|x64.Build.0 = Release|x64
+		{CA32282B-2122-4BEC-AFB1-2F3103FB9198}.Release|x86.ActiveCfg = Release|Win32
+		{CA32282B-2122-4BEC-AFB1-2F3103FB9198}.Release|x86.Build.0 = Release|Win32
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

+ 3 - 0
winrt/SDLPal.UWP/Package.appxmanifest

@@ -25,4 +25,7 @@
       </uap:VisualElements>
     </Application>
   </Applications>
+  <Capabilities>
+    <Capability Name="internetClient" />
+  </Capabilities>
 </Package>

+ 27 - 18
winrt/SDLPal.UWP/SDLPal.UWP.vcxproj

@@ -108,29 +108,29 @@
     <PackageCertificateThumbprint>9B6928946F268F65424754A037F1F924B819C954</PackageCertificateThumbprint>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <IncludePath>..\..\3rd\SDL\include;$(IncludePath)</IncludePath>
+    <IncludePath>..\..\3rd\SDL\include;..\..\3rd\zlib;$(IncludePath)</IncludePath>
     <IntDir>$(Platform)\$(Configuration)\$(MSBuildProjectName)\</IntDir>
     <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\$(MSBuildProjectName)\</OutDir>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <IncludePath>..\..\3rd\SDL\include;$(IncludePath)</IncludePath>
+    <IncludePath>..\..\3rd\SDL\include;..\..\3rd\zlib;$(IncludePath)</IncludePath>
     <IntDir>$(Platform)\$(Configuration)\$(MSBuildProjectName)\</IntDir>
     <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\$(MSBuildProjectName)\</OutDir>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
-    <IncludePath>..\..\3rd\SDL\include;$(IncludePath)</IncludePath>
+    <IncludePath>..\..\3rd\SDL\include;..\..\3rd\zlib;$(IncludePath)</IncludePath>
     <IntDir>$(Platform)\$(Configuration)\$(MSBuildProjectName)\</IntDir>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
-    <IncludePath>..\..\3rd\SDL\include;$(IncludePath)</IncludePath>
+    <IncludePath>..\..\3rd\SDL\include;..\..\3rd\zlib;$(IncludePath)</IncludePath>
     <IntDir>$(Platform)\$(Configuration)\$(MSBuildProjectName)\</IntDir>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
-    <IncludePath>..\..\3rd\SDL\include;$(IncludePath)</IncludePath>
+    <IncludePath>..\..\3rd\SDL\include;..\..\3rd\zlib;$(IncludePath)</IncludePath>
     <IntDir>$(Platform)\$(Configuration)\$(MSBuildProjectName)\</IntDir>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
-    <IncludePath>..\..\3rd\SDL\include;$(IncludePath)</IncludePath>
+    <IncludePath>..\..\3rd\SDL\include;..\..\3rd\zlib;$(IncludePath)</IncludePath>
     <IntDir>$(Platform)\$(Configuration)\$(MSBuildProjectName)\</IntDir>
   </PropertyGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
@@ -141,8 +141,8 @@
       <AdditionalIncludeDirectories>..\;..\..\;..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ClCompile>
     <Link>
-      <AdditionalLibraryDirectories>$(OutDir)../SDLPal.Common;$(OutDir)../SDLPal.Core</AdditionalLibraryDirectories>
-      <AdditionalDependencies>dxgi.lib;dxguid.lib;sdlpal.common.lib;sdlpal.core.lib;vccorlibd.lib;msvcrtd.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalLibraryDirectories>$(OutDir)../SDLPal.Common;$(OutDir)../SDLPal.Core;$(OutDir)../zlib.uwp</AdditionalLibraryDirectories>
+      <AdditionalDependencies>dxgi.lib;dxguid.lib;sdlpal.common.lib;sdlpal.core.lib;zlib.uwp.lib;vccorlibd.lib;msvcrtd.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <IgnoreSpecificDefaultLibraries>vccorlibd.lib;msvcrtd.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
     </Link>
   </ItemDefinitionGroup>
@@ -154,8 +154,8 @@
       <AdditionalIncludeDirectories>..\;..\..\;..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ClCompile>
     <Link>
-      <AdditionalLibraryDirectories>$(OutDir)../SDLPal.Common;$(OutDir)../SDLPal.Core</AdditionalLibraryDirectories>
-      <AdditionalDependencies>dxgi.lib;dxguid.lib;sdlpal.common.lib;sdlpal.core.lib;vccorlib.lib;msvcrt.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalLibraryDirectories>$(OutDir)../SDLPal.Common;$(OutDir)../SDLPal.Core;$(OutDir)../zlib.uwp</AdditionalLibraryDirectories>
+      <AdditionalDependencies>dxgi.lib;dxguid.lib;sdlpal.common.lib;sdlpal.core.lib;zlib.uwp.lib;vccorlib.lib;msvcrt.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <IgnoreSpecificDefaultLibraries>vccorlib.lib;msvcrt.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
     </Link>
   </ItemDefinitionGroup>
@@ -167,8 +167,8 @@
       <AdditionalIncludeDirectories>..\;..\..\;..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ClCompile>
     <Link>
-      <AdditionalLibraryDirectories>$(OutDir)../SDLPal.Common;$(OutDir)../SDLPal.Core</AdditionalLibraryDirectories>
-      <AdditionalDependencies>dxgi.lib;dxguid.lib;sdlpal.common.lib;sdlpal.core.lib;vccorlibd.lib;msvcrtd.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalLibraryDirectories>$(OutDir)../SDLPal.Common;$(OutDir)../SDLPal.Core;$(OutDir)../zlib.uwp</AdditionalLibraryDirectories>
+      <AdditionalDependencies>dxgi.lib;dxguid.lib;sdlpal.common.lib;sdlpal.core.lib;zlib.uwp.lib;vccorlibd.lib;msvcrtd.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <IgnoreSpecificDefaultLibraries>vccorlibd.lib;msvcrtd.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
     </Link>
   </ItemDefinitionGroup>
@@ -180,8 +180,8 @@
       <AdditionalIncludeDirectories>..\;..\..\;..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ClCompile>
     <Link>
-      <AdditionalLibraryDirectories>$(OutDir)../SDLPal.Common;$(OutDir)../SDLPal.Core</AdditionalLibraryDirectories>
-      <AdditionalDependencies>dxgi.lib;dxguid.lib;sdlpal.common.lib;sdlpal.core.lib;vccorlib.lib;msvcrt.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalLibraryDirectories>$(OutDir)../SDLPal.Common;$(OutDir)../SDLPal.Core;$(OutDir)../zlib.uwp</AdditionalLibraryDirectories>
+      <AdditionalDependencies>dxgi.lib;dxguid.lib;sdlpal.common.lib;sdlpal.core.lib;zlib.uwp.lib;vccorlib.lib;msvcrt.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <IgnoreSpecificDefaultLibraries>vccorlib.lib;msvcrt.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
     </Link>
   </ItemDefinitionGroup>
@@ -193,8 +193,8 @@
       <AdditionalIncludeDirectories>..\;..\..\;..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ClCompile>
     <Link>
-      <AdditionalLibraryDirectories>$(OutDir)../SDLPal.Common;$(OutDir)../SDLPal.Core</AdditionalLibraryDirectories>
-      <AdditionalDependencies>dxgi.lib;dxguid.lib;sdlpal.common.lib;sdlpal.core.lib;vccorlibd.lib;msvcrtd.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalLibraryDirectories>$(OutDir)../SDLPal.Common;$(OutDir)../SDLPal.Core;$(OutDir)../zlib.uwp</AdditionalLibraryDirectories>
+      <AdditionalDependencies>dxgi.lib;dxguid.lib;sdlpal.common.lib;sdlpal.core.lib;zlib.uwp.lib;vccorlibd.lib;msvcrtd.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <IgnoreSpecificDefaultLibraries>vccorlibd.lib;msvcrtd.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
     </Link>
   </ItemDefinitionGroup>
@@ -206,13 +206,16 @@
       <AdditionalIncludeDirectories>..\;..\..\;..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ClCompile>
     <Link>
-      <AdditionalLibraryDirectories>$(OutDir)../SDLPal.Common;$(OutDir)../SDLPal.Core</AdditionalLibraryDirectories>
-      <AdditionalDependencies>dxgi.lib;dxguid.lib;sdlpal.common.lib;sdlpal.core.lib;vccorlib.lib;msvcrt.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalLibraryDirectories>$(OutDir)../SDLPal.Common;$(OutDir)../SDLPal.Core;$(OutDir)../zlib.uwp</AdditionalLibraryDirectories>
+      <AdditionalDependencies>dxgi.lib;dxguid.lib;sdlpal.common.lib;sdlpal.core.lib;zlib.uwp.lib;vccorlib.lib;msvcrt.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <IgnoreSpecificDefaultLibraries>vccorlib.lib;msvcrt.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
     </Link>
   </ItemDefinitionGroup>
   <ItemGroup>
     <ClInclude Include="..\SDLPal.Common\AsyncHelper.h" />
+    <ClInclude Include="..\SDLPal.Common\DownloadDialog.xaml.h">
+      <DependentUpon>..\SDLPal.Common\DownloadDialog.xaml</DependentUpon>
+    </ClInclude>
     <ClInclude Include="..\SDLPal.Common\StringHelper.h" />
     <ClInclude Include="pch.h" />
     <ClInclude Include="App.xaml.h">
@@ -229,6 +232,9 @@
     <Page Include="..\SDLPal.Common\MainPage.xaml">
       <SubType>Designer</SubType>
     </Page>
+    <Page Include="..\SDLPal.Common\DownloadDialog.xaml">
+      <SubType>Designer</SubType>
+    </Page>
   </ItemGroup>
   <ItemGroup>
     <AppxManifest Include="Package.appxmanifest">
@@ -238,6 +244,9 @@
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\native_midi.cpp" />
+    <ClCompile Include="..\SDLPal.Common\DownloadDialog.xaml.cpp">
+      <DependentUpon>..\SDLPal.Common\DownloadDialog.xaml</DependentUpon>
+    </ClCompile>
     <ClCompile Include="..\SDLPal.Common\SDLPal.cpp" />
     <ClCompile Include="..\SDLPal.Common\WinRTUtil.cpp" />
     <ClCompile Include="App.xaml.cpp">

+ 3 - 0
winrt/SDLPal.UWP/SDLPal.UWP.vcxproj.filters

@@ -35,6 +35,7 @@
       <Filter>Common</Filter>
     </ClCompile>
     <ClCompile Include="..\native_midi.cpp" />
+    <ClCompile Include="..\SDLPal.Common\DownloadDialog.xaml.cpp" />
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="pch.h" />
@@ -46,6 +47,7 @@
     <ClInclude Include="..\SDLPal.Common\StringHelper.h">
       <Filter>Common</Filter>
     </ClInclude>
+    <ClInclude Include="..\SDLPal.Common\DownloadDialog.xaml.h" />
   </ItemGroup>
   <ItemGroup>
     <AppxManifest Include="Package.appxmanifest" />
@@ -55,6 +57,7 @@
   </ItemGroup>
   <ItemGroup>
     <Page Include="..\SDLPal.Common\MainPage.xaml" />
+    <Page Include="..\SDLPal.Common\DownloadDialog.xaml" />
   </ItemGroup>
   <ItemGroup>
     <Image Include="Assets\Badge.scale-100.png">

+ 12 - 4
winrt/SDLPal.WindowsPhone.sln

@@ -14,10 +14,14 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDLPal", "SDLPal.WindowsPho
 	ProjectSection(ProjectDependencies) = postProject
 		{35839F1B-8B1C-4858-91FA-807A693E703F} = {35839F1B-8B1C-4858-91FA-807A693E703F}
 		{704D3871-2E86-42EF-A607-CBCFB7A7EBAB} = {704D3871-2E86-42EF-A607-CBCFB7A7EBAB}
+		{D8B19451-4633-4660-82BD-467B08FA2652} = {D8B19451-4633-4660-82BD-467B08FA2652}
+		{48FADC0E-964D-4DAB-BCED-372E0AD19577} = {48FADC0E-964D-4DAB-BCED-372E0AD19577}
 	EndProjectSection
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDLPal.Common", "SDLPal.WindowsPhone\SDLPal.Common.vcxproj", "{35839F1B-8B1C-4858-91FA-807A693E703F}"
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "..\3rd\zlib\zlib.windowsphone.vcxproj", "{D8B19451-4633-4660-82BD-467B08FA2652}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|ARM = Debug|ARM
@@ -36,16 +40,12 @@ Global
 		{48FADC0E-964D-4DAB-BCED-372E0AD19577}.Release|Win32.Build.0 = Release|Win32
 		{704D3871-2E86-42EF-A607-CBCFB7A7EBAB}.Debug|ARM.ActiveCfg = Debug|ARM
 		{704D3871-2E86-42EF-A607-CBCFB7A7EBAB}.Debug|ARM.Build.0 = Debug|ARM
-		{704D3871-2E86-42EF-A607-CBCFB7A7EBAB}.Debug|ARM.Deploy.0 = Debug|ARM
 		{704D3871-2E86-42EF-A607-CBCFB7A7EBAB}.Debug|Win32.ActiveCfg = Debug|Win32
 		{704D3871-2E86-42EF-A607-CBCFB7A7EBAB}.Debug|Win32.Build.0 = Debug|Win32
-		{704D3871-2E86-42EF-A607-CBCFB7A7EBAB}.Debug|Win32.Deploy.0 = Debug|Win32
 		{704D3871-2E86-42EF-A607-CBCFB7A7EBAB}.Release|ARM.ActiveCfg = Release|ARM
 		{704D3871-2E86-42EF-A607-CBCFB7A7EBAB}.Release|ARM.Build.0 = Release|ARM
-		{704D3871-2E86-42EF-A607-CBCFB7A7EBAB}.Release|ARM.Deploy.0 = Release|ARM
 		{704D3871-2E86-42EF-A607-CBCFB7A7EBAB}.Release|Win32.ActiveCfg = Release|Win32
 		{704D3871-2E86-42EF-A607-CBCFB7A7EBAB}.Release|Win32.Build.0 = Release|Win32
-		{704D3871-2E86-42EF-A607-CBCFB7A7EBAB}.Release|Win32.Deploy.0 = Release|Win32
 		{4C240E16-F6F6-4D60-B29B-7F7ACB4815D7}.Debug|ARM.ActiveCfg = Debug|ARM
 		{4C240E16-F6F6-4D60-B29B-7F7ACB4815D7}.Debug|ARM.Build.0 = Debug|ARM
 		{4C240E16-F6F6-4D60-B29B-7F7ACB4815D7}.Debug|ARM.Deploy.0 = Debug|ARM
@@ -66,6 +66,14 @@ Global
 		{35839F1B-8B1C-4858-91FA-807A693E703F}.Release|ARM.Build.0 = Release|ARM
 		{35839F1B-8B1C-4858-91FA-807A693E703F}.Release|Win32.ActiveCfg = Release|Win32
 		{35839F1B-8B1C-4858-91FA-807A693E703F}.Release|Win32.Build.0 = Release|Win32
+		{D8B19451-4633-4660-82BD-467B08FA2652}.Debug|ARM.ActiveCfg = Debug|ARM
+		{D8B19451-4633-4660-82BD-467B08FA2652}.Debug|ARM.Build.0 = Debug|ARM
+		{D8B19451-4633-4660-82BD-467B08FA2652}.Debug|Win32.ActiveCfg = Debug|Win32
+		{D8B19451-4633-4660-82BD-467B08FA2652}.Debug|Win32.Build.0 = Debug|Win32
+		{D8B19451-4633-4660-82BD-467B08FA2652}.Release|ARM.ActiveCfg = Release|ARM
+		{D8B19451-4633-4660-82BD-467B08FA2652}.Release|ARM.Build.0 = Release|ARM
+		{D8B19451-4633-4660-82BD-467B08FA2652}.Release|Win32.ActiveCfg = Release|Win32
+		{D8B19451-4633-4660-82BD-467B08FA2652}.Release|Win32.Build.0 = Release|Win32
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

+ 3 - 0
winrt/SDLPal.WindowsPhone/Package.appxmanifest

@@ -23,4 +23,7 @@
       </m3:VisualElements>
     </Application>
   </Applications>
+  <Capabilities>
+    <Capability Name="internetClient" />
+  </Capabilities>
 </Package>

+ 15 - 15
winrt/SDLPal.WindowsPhone/SDLPal.Core.vcxproj.filters

@@ -1,6 +1,14 @@
 <?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <ItemGroup>
+    <Filter Include="Header Files">
+      <UniqueIdentifier>{4844f59c-c0f1-4395-9e5b-0b0ab0ff70e5}</UniqueIdentifier>
+      <Extensions>h;hpp;hxx;hm;inl</Extensions>
+    </Filter>
+    <Filter Include="Source Files">
+      <UniqueIdentifier>{1a7b7589-37a9-4516-b280-45eb081680b6}</UniqueIdentifier>
+      <Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions>
+    </Filter>
     <Filter Include="adplug">
       <UniqueIdentifier>{e0154447-2329-47d7-8713-a66a8cc6b0c8}</UniqueIdentifier>
     </Filter>
@@ -20,18 +28,18 @@
     <Filter Include="liboggvorbis\src">
       <UniqueIdentifier>{f0c1a2b5-d532-48df-8882-61310afb9699}</UniqueIdentifier>
     </Filter>
-    <Filter Include="liboggvorbis\include\vorbis">
-      <UniqueIdentifier>{672e9674-8ef1-40e1-b7c1-61e38e95cb3f}</UniqueIdentifier>
-    </Filter>
     <Filter Include="liboggvorbis\include\ogg">
       <UniqueIdentifier>{1cfbe453-cd2e-4cc6-8fe7-697858f695e1}</UniqueIdentifier>
     </Filter>
-    <Filter Include="liboggvorbis\src\modes">
-      <UniqueIdentifier>{ae768a83-ddd4-4d80-820f-2152ac4a561b}</UniqueIdentifier>
+    <Filter Include="liboggvorbis\include\vorbis">
+      <UniqueIdentifier>{672e9674-8ef1-40e1-b7c1-61e38e95cb3f}</UniqueIdentifier>
     </Filter>
     <Filter Include="liboggvorbis\src\books">
       <UniqueIdentifier>{a6026f32-f75b-4d0b-b2c1-061ee818d7db}</UniqueIdentifier>
     </Filter>
+    <Filter Include="liboggvorbis\src\modes">
+      <UniqueIdentifier>{ae768a83-ddd4-4d80-820f-2152ac4a561b}</UniqueIdentifier>
+    </Filter>
     <Filter Include="liboggvorbis\src\books\coupled">
       <UniqueIdentifier>{27265bac-1f69-4fe3-bfe4-ae319e4821c7}</UniqueIdentifier>
     </Filter>
@@ -41,14 +49,6 @@
     <Filter Include="liboggvorbis\src\books\uncoupled">
       <UniqueIdentifier>{004a5ad8-1fcb-4c4b-bbf7-809256e2eefe}</UniqueIdentifier>
     </Filter>
-    <Filter Include="Header Files">
-      <UniqueIdentifier>{4844f59c-c0f1-4395-9e5b-0b0ab0ff70e5}</UniqueIdentifier>
-      <Extensions>h;hpp;hxx;hm;inl</Extensions>
-    </Filter>
-    <Filter Include="Source Files">
-      <UniqueIdentifier>{1a7b7589-37a9-4516-b280-45eb081680b6}</UniqueIdentifier>
-      <Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions>
-    </Filter>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\adplug\binfile.h">
@@ -575,7 +575,7 @@
     <ClCompile Include="..\..\map.c">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\map.c">
+    <ClCompile Include="..\..\midi.c">
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="..\..\palcommon.c">

+ 23 - 16
winrt/SDLPal.WindowsPhone/SDLPal.vcxproj

@@ -74,22 +74,22 @@
     <AppxBundlePlatforms>arm</AppxBundlePlatforms>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <IncludePath>..\..\3rd\SDL\include;$(IncludePath)</IncludePath>
+    <IncludePath>..\..\3rd\SDL\include;..\..\3rd\zlib;$(IncludePath)</IncludePath>
     <IntDir>$(Platform)\$(Configuration)\$(MSBuildProjectName)\</IntDir>
     <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\$(MSBuildProjectName).WindowsPhone\</OutDir>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <IncludePath>..\..\3rd\SDL\include;$(IncludePath)</IncludePath>
+    <IncludePath>..\..\3rd\SDL\include;..\..\3rd\zlib;$(IncludePath)</IncludePath>
     <IntDir>$(Platform)\$(Configuration)\$(MSBuildProjectName)\</IntDir>
     <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\$(MSBuildProjectName).WindowsPhone\</OutDir>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
-    <IncludePath>..\..\3rd\SDL\include;$(IncludePath)</IncludePath>
+    <IncludePath>..\..\3rd\SDL\include;..\..\3rd\zlib;$(IncludePath)</IncludePath>
     <IntDir>$(Platform)\$(Configuration)\$(MSBuildProjectName)\</IntDir>
     <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\$(MSBuildProjectName).WindowsPhone\</OutDir>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
-    <IncludePath>..\..\3rd\SDL\include;$(IncludePath)</IncludePath>
+    <IncludePath>..\..\3rd\SDL\include;..\..\3rd\zlib;$(IncludePath)</IncludePath>
     <IntDir>$(Platform)\$(Configuration)\$(MSBuildProjectName)\</IntDir>
     <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\$(MSBuildProjectName).WindowsPhone\</OutDir>
   </PropertyGroup>
@@ -98,12 +98,12 @@
       <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
       <DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
       <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <AdditionalIncludeDirectories>..\;..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\;..\..\;..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>dxgi.lib;dxguid.lib;sdlpal.core.lib;sdlpal.common.lib;vccorlibd.lib;msvcrtd.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>dxgi.lib;dxguid.lib;shcore.lib;sdlpal.core.lib;sdlpal.common.lib;zlib.windowsphone.lib;vccorlibd.lib;msvcrtd.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <IgnoreSpecificDefaultLibraries>vccorlibd.lib;msvcrtd.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
-      <AdditionalLibraryDirectories>$(OutDir)../SDLPal.Common.WindowsPhone;$(OutDir)../SDLPal.Core.WindowsPhone</AdditionalLibraryDirectories>
+      <AdditionalLibraryDirectories>$(OutDir)../SDLPal.Common.WindowsPhone;$(OutDir)../SDLPal.Core.WindowsPhone;$(OutDir)../zlib.windowsphone</AdditionalLibraryDirectories>
     </Link>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
@@ -111,12 +111,12 @@
       <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
       <DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
       <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <AdditionalIncludeDirectories>..\;..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\;..\..\;..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>dxgi.lib;dxguid.lib;sdlpal.core.lib;sdlpal.common.lib;vccorlib.lib;msvcrt.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>dxgi.lib;dxguid.lib;shcore.lib;sdlpal.core.lib;sdlpal.common.lib;zlib.windowsphone.lib;vccorlib.lib;msvcrt.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <IgnoreSpecificDefaultLibraries>vccorlib.lib;msvcrt.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
-      <AdditionalLibraryDirectories>$(OutDir)../SDLPal.Common.WindowsPhone;$(OutDir)../SDLPal.Core.WindowsPhone</AdditionalLibraryDirectories>
+      <AdditionalLibraryDirectories>$(OutDir)../SDLPal.Common.WindowsPhone;$(OutDir)../SDLPal.Core.WindowsPhone;$(OutDir)../zlib.windowsphone</AdditionalLibraryDirectories>
     </Link>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
@@ -124,12 +124,12 @@
       <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
       <DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
       <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <AdditionalIncludeDirectories>..\;..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\;..\..\;..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>dxgi.lib;dxguid.lib;sdlpal.core.lib;sdlpal.common.lib;vccorlibd.lib;msvcrtd.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>dxgi.lib;dxguid.lib;shcore.lib;sdlpal.core.lib;sdlpal.common.lib;zlib.windowsphone.lib;vccorlibd.lib;msvcrtd.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <IgnoreSpecificDefaultLibraries>vccorlibd.lib;msvcrtd.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
-      <AdditionalLibraryDirectories>$(OutDir)../SDLPal.Common.WindowsPhone;$(OutDir)../SDLPal.Core.WindowsPhone</AdditionalLibraryDirectories>
+      <AdditionalLibraryDirectories>$(OutDir)../SDLPal.Common.WindowsPhone;$(OutDir)../SDLPal.Core.WindowsPhone;$(OutDir)../zlib.windowsphone</AdditionalLibraryDirectories>
     </Link>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@@ -137,12 +137,12 @@
       <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
       <DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
       <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <AdditionalIncludeDirectories>..\;..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\;..\..\;..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>dxgi.lib;dxguid.lib;sdlpal.core.lib;sdlpal.common.lib;vccorlib.lib;msvcrt.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>dxgi.lib;dxguid.lib;shcore.lib;sdlpal.core.lib;sdlpal.common.lib;zlib.windowsphone.lib;vccorlib.lib;msvcrt.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <IgnoreSpecificDefaultLibraries>vccorlib.lib;msvcrt.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
-      <AdditionalLibraryDirectories>$(OutDir)../SDLPal.Common.WindowsPhone;$(OutDir)../SDLPal.Core.WindowsPhone</AdditionalLibraryDirectories>
+      <AdditionalLibraryDirectories>$(OutDir)../SDLPal.Common.WindowsPhone;$(OutDir)../SDLPal.Core.WindowsPhone;$(OutDir)../zlib.windowsphone</AdditionalLibraryDirectories>
     </Link>
   </ItemDefinitionGroup>
   <ItemGroup>
@@ -197,6 +197,9 @@
     <Image Include="Assets\WideLogo.scale-240.png" />
   </ItemGroup>
   <ItemGroup>
+    <ClCompile Include="..\SDLPal.Common\DownloadDialog.xaml.cpp">
+      <DependentUpon>..\SDLPal.Common\DownloadDialog.xaml</DependentUpon>
+    </ClCompile>
     <ClCompile Include="..\SDLPal.Common\MainPage.xaml.cpp">
       <DependentUpon>..\SDLPal.Common\MainPage.xaml</DependentUpon>
     </ClCompile>
@@ -227,6 +230,9 @@
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\SDLPal.Common\AsyncHelper.h" />
+    <ClInclude Include="..\SDLPal.Common\DownloadDialog.xaml.h">
+      <DependentUpon>..\SDLPal.Common\DownloadDialog.xaml</DependentUpon>
+    </ClInclude>
     <ClInclude Include="..\SDLPal.Common\MainPage.xaml.h">
       <DependentUpon>..\SDLPal.Common\MainPage.xaml</DependentUpon>
     </ClInclude>
@@ -243,6 +249,7 @@
   </ItemGroup>
   <ItemGroup>
     <Page Include="..\SDLPal.Common\MainPage.xaml" />
+    <Page Include="..\SDLPal.Common\DownloadDialog.xaml" />
   </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">

+ 3 - 0
winrt/SDLPal.WindowsPhone/SDLPal.vcxproj.filters

@@ -48,6 +48,7 @@
     <ClCompile Include="..\SDLPal.Common\WinRTUtil.cpp">
       <Filter>Common</Filter>
     </ClCompile>
+    <ClCompile Include="..\SDLPal.Common\DownloadDialog.xaml.cpp" />
     <ClCompile Include="..\SDLPal.Common\MainPage.xaml.cpp" />
   </ItemGroup>
   <ItemGroup>
@@ -100,6 +101,7 @@
     <ClInclude Include="..\SDLPal.Common\StringHelper.h">
       <Filter>Common</Filter>
     </ClInclude>
+    <ClInclude Include="..\SDLPal.Common\DownloadDialog.xaml.h" />
     <ClInclude Include="..\SDLPal.Common\MainPage.xaml.h" />
   </ItemGroup>
   <ItemGroup>
@@ -117,6 +119,7 @@
     </PRIResource>
   </ItemGroup>
   <ItemGroup>
+    <Page Include="..\SDLPal.Common\DownloadDialog.xaml" />
     <Page Include="..\SDLPal.Common\MainPage.xaml" />
   </ItemGroup>
 </Project>