Removing UWP support (#858)
@@ -196,7 +196,6 @@ ModelManifest.xml
|
||||
/WickedEngine/Release_RT
|
||||
/WickedEngine/Debug_RT
|
||||
/Debug_RT/WickedEngine
|
||||
/WickedEngine/Debug_UWP
|
||||
/.vs/WickedEngine/v15
|
||||
/.vs/WickedEngine/v15
|
||||
/.vs/WickedEngine/v15/Browse.VC.db
|
||||
@@ -210,11 +209,6 @@ ModelManifest.xml
|
||||
# CMake build cache files
|
||||
.cache/
|
||||
|
||||
# WINRT Generated files
|
||||
/Editor/Generated Files/winrt
|
||||
/Template_UWP/Generated Files/winrt
|
||||
/WickedEngine/Generated Files/winrt
|
||||
|
||||
*.cso
|
||||
*.wishadermeta
|
||||
wiShaderdump.h
|
||||
|
||||
@@ -1,320 +0,0 @@
|
||||
#include "stdafx.h"
|
||||
#include "Editor.h"
|
||||
|
||||
// Use the C++ standard templated min/max
|
||||
#define NOMINMAX
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <exception>
|
||||
#include <future>
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <filesystem>
|
||||
|
||||
#include "winrt/Windows.ApplicationModel.h"
|
||||
#include "winrt/Windows.ApplicationModel.Core.h"
|
||||
#include "winrt/Windows.ApplicationModel.Activation.h"
|
||||
#include "winrt/Windows.Foundation.h"
|
||||
#include "winrt/Windows.Graphics.Display.h"
|
||||
#include "winrt/Windows.System.h"
|
||||
#include "winrt/Windows.UI.Core.h"
|
||||
#include "winrt/Windows.UI.Input.h"
|
||||
#include "winrt/Windows.UI.ViewManagement.h"
|
||||
#include <winrt/Windows.Storage.h>
|
||||
#include <winrt/Windows.Foundation.Collections.h>
|
||||
|
||||
|
||||
using namespace winrt::Windows::ApplicationModel;
|
||||
using namespace winrt::Windows::ApplicationModel::Core;
|
||||
using namespace winrt::Windows::ApplicationModel::Activation;
|
||||
using namespace winrt::Windows::UI::Core;
|
||||
using namespace winrt::Windows::UI::Input;
|
||||
using namespace winrt::Windows::UI::ViewManagement;
|
||||
using namespace winrt::Windows::System;
|
||||
using namespace winrt::Windows::Foundation;
|
||||
using namespace winrt::Windows::Graphics::Display;
|
||||
using namespace winrt::Windows::Storage;
|
||||
|
||||
winrt::fire_and_forget copy_folder(StorageFolder src, StorageFolder dst)
|
||||
{
|
||||
auto items = co_await src.GetItemsAsync();
|
||||
for (auto item : items)
|
||||
{
|
||||
if (item.IsOfType(StorageItemTypes::File))
|
||||
{
|
||||
StorageFile file = item.as<StorageFile>();
|
||||
try {
|
||||
file.CopyAsync(dst);
|
||||
}
|
||||
catch (...) {
|
||||
// file already exists, we don't want to overwrite
|
||||
}
|
||||
}
|
||||
else if (item.IsOfType(StorageItemTypes::Folder))
|
||||
{
|
||||
StorageFolder src_child = item.as<StorageFolder>();
|
||||
auto dst_child = co_await dst.CreateFolderAsync(item.Name(), CreationCollisionOption::OpenIfExists);
|
||||
if (dst_child)
|
||||
{
|
||||
copy_folder(src_child, dst_child);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
winrt::fire_and_forget uwp_copy_assets()
|
||||
{
|
||||
// On UWP we will copy the base content from application folder to 3D Objects directory
|
||||
// for easy access to the user:
|
||||
StorageFolder location = KnownFolders::Objects3D();
|
||||
|
||||
// Objects3D/WickedEngine
|
||||
auto destfolder = co_await location.CreateFolderAsync(L"WickedEngine", CreationCollisionOption::OpenIfExists);
|
||||
|
||||
std::string rootdir = std::filesystem::current_path().string() + "\\";
|
||||
std::wstring wstr;
|
||||
|
||||
// scripts:
|
||||
{
|
||||
wi::helper::StringConvert(rootdir + "scripts\\", wstr);
|
||||
auto src = co_await StorageFolder::GetFolderFromPathAsync(wstr.c_str());
|
||||
if (src)
|
||||
{
|
||||
auto dst = co_await destfolder.CreateFolderAsync(L"scripts", CreationCollisionOption::OpenIfExists);
|
||||
if (dst)
|
||||
{
|
||||
copy_folder(src, dst);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// models:
|
||||
{
|
||||
wi::helper::StringConvert(rootdir + "models\\", wstr);
|
||||
auto src = co_await StorageFolder::GetFolderFromPathAsync(wstr.c_str());
|
||||
if (src)
|
||||
{
|
||||
auto dst = co_await destfolder.CreateFolderAsync(L"models", CreationCollisionOption::OpenIfExists);
|
||||
if (dst)
|
||||
{
|
||||
copy_folder(src, dst);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Documentation:
|
||||
{
|
||||
wi::helper::StringConvert(rootdir + "Documentation\\", wstr);
|
||||
auto src = co_await StorageFolder::GetFolderFromPathAsync(wstr.c_str());
|
||||
if (src)
|
||||
{
|
||||
auto dst = destfolder.CreateFolderAsync(L"Documentation", CreationCollisionOption::OpenIfExists).get();
|
||||
if (dst)
|
||||
{
|
||||
copy_folder(src, dst);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ViewProvider : public winrt::implements<ViewProvider, IFrameworkView>
|
||||
{
|
||||
public:
|
||||
|
||||
// IFrameworkView methods
|
||||
void Initialize(CoreApplicationView const& applicationView)
|
||||
{
|
||||
applicationView.Activated({ this, &ViewProvider::OnActivated });
|
||||
|
||||
CoreApplication::Suspending({ this, &ViewProvider::OnSuspending });
|
||||
|
||||
CoreApplication::Resuming({ this, &ViewProvider::OnResuming });
|
||||
|
||||
uwp_copy_assets();
|
||||
|
||||
//wi::Timer timer;
|
||||
//if (editor.config.Open("config.ini"))
|
||||
//{
|
||||
// editor.allow_hdr = editor.config.GetBool("allow_hdr");
|
||||
|
||||
// wi::backlog::post("config.ini loaded in " + std::to_string(timer.elapsed_milliseconds()) + " milliseconds\n");
|
||||
//}
|
||||
}
|
||||
|
||||
void Uninitialize() noexcept
|
||||
{
|
||||
}
|
||||
|
||||
void SetWindow(CoreWindow const& window)
|
||||
{
|
||||
window.SizeChanged({ this, &ViewProvider::OnWindowSizeChanged });
|
||||
|
||||
window.VisibilityChanged({ this, &ViewProvider::OnVisibilityChanged });
|
||||
|
||||
window.Closed([this](auto&&, auto&&) { m_exit = true; });
|
||||
|
||||
auto dispatcher = CoreWindow::GetForCurrentThread().Dispatcher();
|
||||
|
||||
dispatcher.AcceleratorKeyActivated({ this, &ViewProvider::OnAcceleratorKeyActivated });
|
||||
|
||||
auto navigation = SystemNavigationManager::GetForCurrentView();
|
||||
|
||||
// UWP on Xbox One triggers a back request whenever the B button is pressed
|
||||
// which can result in the app being suspended if unhandled
|
||||
navigation.BackRequested([](const winrt::Windows::Foundation::IInspectable&, const BackRequestedEventArgs& args)
|
||||
{
|
||||
args.Handled(true);
|
||||
});
|
||||
|
||||
auto currentDisplayInformation = DisplayInformation::GetForCurrentView();
|
||||
|
||||
currentDisplayInformation.DpiChanged({ this, &ViewProvider::OnDpiChanged });
|
||||
|
||||
DisplayInformation::DisplayContentsInvalidated({ this, &ViewProvider::OnDisplayContentsInvalidated });
|
||||
|
||||
m_DPI = currentDisplayInformation.LogicalDpi();
|
||||
|
||||
m_logicalWidth = window.Bounds().Width;
|
||||
m_logicalHeight = window.Bounds().Height;
|
||||
|
||||
editor.SetWindow(&window);
|
||||
}
|
||||
|
||||
void Load(winrt::hstring const&) noexcept
|
||||
{
|
||||
}
|
||||
|
||||
void Run()
|
||||
{
|
||||
while (!m_exit)
|
||||
{
|
||||
if (m_visible)
|
||||
{
|
||||
editor.Run();
|
||||
|
||||
CoreWindow::GetForCurrentThread().Dispatcher().ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent);
|
||||
}
|
||||
else
|
||||
{
|
||||
CoreWindow::GetForCurrentThread().Dispatcher().ProcessEvents(CoreProcessEventsOption::ProcessOneAndAllPending);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
// Event handlers
|
||||
void OnActivated(CoreApplicationView const& /*applicationView*/, IActivatedEventArgs const& args)
|
||||
{
|
||||
CoreWindow::GetForCurrentThread().Activate();
|
||||
}
|
||||
|
||||
void OnSuspending(IInspectable const& /*sender*/, SuspendingEventArgs const& args)
|
||||
{
|
||||
auto deferral = args.SuspendingOperation().GetDeferral();
|
||||
|
||||
auto f = std::async(std::launch::async, [this, deferral]()
|
||||
{
|
||||
deferral.Complete();
|
||||
});
|
||||
}
|
||||
|
||||
void OnResuming(IInspectable const& /*sender*/, IInspectable const& /*args*/)
|
||||
{
|
||||
}
|
||||
|
||||
void OnWindowSizeChanged(CoreWindow const& sender, WindowSizeChangedEventArgs const& /*args*/)
|
||||
{
|
||||
editor.SetWindow(&sender);
|
||||
}
|
||||
|
||||
void OnVisibilityChanged(CoreWindow const& /*sender*/, VisibilityChangedEventArgs const& args)
|
||||
{
|
||||
m_visible = args.Visible();
|
||||
}
|
||||
|
||||
void OnAcceleratorKeyActivated(CoreDispatcher const&, AcceleratorKeyEventArgs const& args)
|
||||
{
|
||||
if (args.EventType() == CoreAcceleratorKeyEventType::SystemKeyDown
|
||||
&& args.VirtualKey() == VirtualKey::Enter
|
||||
&& args.KeyStatus().IsMenuKeyDown
|
||||
&& !args.KeyStatus().WasKeyDown)
|
||||
{
|
||||
// Implements the classic ALT+ENTER fullscreen toggle
|
||||
auto view = ApplicationView::GetForCurrentView();
|
||||
|
||||
if (view.IsFullScreenMode())
|
||||
view.ExitFullScreenMode();
|
||||
else
|
||||
view.TryEnterFullScreenMode();
|
||||
|
||||
args.Handled(true);
|
||||
}
|
||||
|
||||
if (args.EventType() == CoreAcceleratorKeyEventType::Character && args.VirtualKey() != VirtualKey::Enter)
|
||||
{
|
||||
wchar_t c = (wchar_t)args.VirtualKey();
|
||||
|
||||
if (c == '\b')
|
||||
{
|
||||
wi::gui::TextInputField::DeleteFromInput();
|
||||
}
|
||||
else
|
||||
{
|
||||
wi::gui::TextInputField::AddInput(c);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void OnDpiChanged(DisplayInformation const& sender, IInspectable const& /*args*/)
|
||||
{
|
||||
editor.SetWindow(&CoreWindow::GetForCurrentThread());
|
||||
}
|
||||
|
||||
void OnDisplayContentsInvalidated(DisplayInformation const& /*sender*/, IInspectable const& /*args*/)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
bool m_exit = false;
|
||||
bool m_visible = true;
|
||||
float m_DPI = 96;
|
||||
float m_logicalWidth = 800;
|
||||
float m_logicalHeight = 600;
|
||||
Editor editor;
|
||||
|
||||
inline int ConvertDipsToPixels(float dips) const noexcept
|
||||
{
|
||||
return int(dips * m_DPI / 96.f + 0.5f);
|
||||
}
|
||||
|
||||
inline float ConvertPixelsToDips(int pixels) const noexcept
|
||||
{
|
||||
return (float(pixels) * 96.f / m_DPI);
|
||||
}
|
||||
};
|
||||
|
||||
class ViewProviderFactory : public winrt::implements<ViewProviderFactory, IFrameworkViewSource>
|
||||
{
|
||||
public:
|
||||
IFrameworkView CreateView()
|
||||
{
|
||||
return winrt::make<ViewProvider>();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Entry point
|
||||
int WINAPI wWinMain(
|
||||
_In_ HINSTANCE /*hInstance*/,
|
||||
_In_ HINSTANCE /*hPrevInstance*/,
|
||||
_In_ LPWSTR /*lpCmdLine*/,
|
||||
_In_ int /*nCmdShow*/
|
||||
)
|
||||
{
|
||||
auto viewProviderFactory = winrt::make<ViewProviderFactory>();
|
||||
CoreApplication::Run(viewProviderFactory);
|
||||
return 0;
|
||||
}
|
||||
|
Before Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 106 KiB |
|
Before Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 6.4 KiB |
|
Before Width: | Height: | Size: 1007 B |
|
Before Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 40 KiB |
@@ -140,9 +140,6 @@ void ContentBrowserWindow::ResizeLayout()
|
||||
|
||||
void ContentBrowserWindow::RefreshContent()
|
||||
{
|
||||
#ifdef PLATFORM_UWP
|
||||
content_folder = wi::helper::GetCurrentPath() + "/";
|
||||
#else
|
||||
content_folder = wi::helper::GetCurrentPath() + "/Content/";
|
||||
wi::helper::MakePathAbsolute(content_folder);
|
||||
if (!wi::helper::FileExists(content_folder))
|
||||
@@ -150,7 +147,6 @@ void ContentBrowserWindow::RefreshContent()
|
||||
content_folder = wi::helper::GetCurrentPath() + "/../Content/";
|
||||
wi::helper::MakePathAbsolute(content_folder);
|
||||
}
|
||||
#endif // PLATFORM_UWP
|
||||
|
||||
float hei = 25;
|
||||
float wid = 120;
|
||||
|
||||
@@ -14,8 +14,6 @@ using namespace wi::ecs;
|
||||
#if defined(PLATFORM_WINDOWS_DESKTOP)
|
||||
extern BOOL CreateEditorWindow(int nCmdShow);
|
||||
extern bool window_recreating;
|
||||
#elif defined(PLATFORM_UWP)
|
||||
#include "winrt/Windows.UI.ViewManagement.h"
|
||||
#elif defined(PLATFORM_LINUX)
|
||||
#include "sdl2.h"
|
||||
#endif // PLATFORM_WINDOWS
|
||||
@@ -787,16 +785,6 @@ void EditorComponent::Load()
|
||||
DestroyWindow(main->window);
|
||||
main->window = {};
|
||||
CreateEditorWindow(SW_SHOWNORMAL);
|
||||
#elif defined(PLATFORM_UWP)
|
||||
auto applicationView = winrt::Windows::UI::ViewManagement::ApplicationView::GetForCurrentView();
|
||||
if (applicationView.IsFullScreenMode())
|
||||
{
|
||||
applicationView.ExitFullScreenMode();
|
||||
}
|
||||
else
|
||||
{
|
||||
applicationView.TryEnterFullScreenMode();
|
||||
}
|
||||
#elif defined(PLATFORM_LINUX)
|
||||
SDL_SetWindowFullscreen(main->window, fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
|
||||
#endif // PLATFORM_WINDOWS_DESKTOP
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<Package
|
||||
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
|
||||
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
|
||||
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
|
||||
IgnorableNamespaces="uap mp">
|
||||
|
||||
<Identity
|
||||
Name="b626bf72-86dc-4688-8b44-6347c7b57a82"
|
||||
Publisher="CN=turan"
|
||||
Version="1.0.0.0" />
|
||||
|
||||
<mp:PhoneIdentity PhoneProductId="b626bf72-86dc-4688-8b44-6347c7b57a82" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
|
||||
|
||||
<Properties>
|
||||
<DisplayName>Wicked Engine Editor</DisplayName>
|
||||
<PublisherDisplayName>Janos Turanszki</PublisherDisplayName>
|
||||
<Logo>Assets\StoreLogo.png</Logo>
|
||||
</Properties>
|
||||
|
||||
<Dependencies>
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
|
||||
</Dependencies>
|
||||
|
||||
<Resources>
|
||||
<Resource Language="x-generate"/>
|
||||
</Resources>
|
||||
|
||||
<Applications>
|
||||
<Application Id="App"
|
||||
Executable="$targetnametoken$.exe"
|
||||
EntryPoint="Editor_UWP.App">
|
||||
<uap:VisualElements
|
||||
DisplayName="Wicked Engine Editor"
|
||||
Square150x150Logo="Assets\Square150x150Logo.png"
|
||||
Square44x44Logo="Assets\Square44x44Logo.png"
|
||||
Description="Wicked Engine Editor"
|
||||
BackgroundColor="transparent">
|
||||
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png"/>
|
||||
<uap:SplashScreen Image="Assets\SplashScreen.png" />
|
||||
</uap:VisualElements>
|
||||
</Application>
|
||||
</Applications>
|
||||
|
||||
<Capabilities>
|
||||
<uap:Capability Name="objects3D"/>
|
||||
<uap:Capability Name="musicLibrary"/>
|
||||
<uap:Capability Name="picturesLibrary"/>
|
||||
</Capabilities>
|
||||
</Package>
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "sdl2.h"
|
||||
#include <fstream>
|
||||
|
||||
#include "Assets/Icon.c"
|
||||
#include "icon.c"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.Windows.CppWinRT" version="2.0.230706.1" targetFramework="native" />
|
||||
</packages>
|
||||
@@ -4,11 +4,10 @@
|
||||
|
||||
[](https://github.com/turanszkij/WickedEngine/actions)
|
||||
[](https://discord.gg/CFjRYmE)
|
||||
[](https://wickedengine.net/forum/)
|
||||
[](https://wickedengine.net/forum/)
|
||||
<a href="https://twitter.com/intent/follow?screen_name=turanszkij"><img src="https://img.shields.io/twitter/follow/turanszkij.svg?style=social" alt="follow on Twitter"></a>
|
||||
<br/>
|
||||
[](https://store.steampowered.com/app/1967460/Wicked_Engine/)
|
||||
[](https://www.microsoft.com/store/productId/9PPMV065W9QJ)
|
||||
|
||||
|
||||
<br/>
|
||||
@@ -31,7 +30,6 @@ You can get the full source code by using Git version control and cloning https:
|
||||
### Platforms:
|
||||
- Windows 10 or newer
|
||||
- Linux
|
||||
- UWP
|
||||
- Xbox Series X|S
|
||||
- PlayStation 5
|
||||
|
||||
@@ -72,13 +70,6 @@ You can also download prebuilt and packaged versions of the Editor and Tests her
|
||||
|
||||
If you have questions or stuck, please use the `linux` communication channel on Discord: [](https://discord.gg/CFjRYmE)
|
||||
|
||||
|
||||
#### UWP
|
||||
To build for UWP platform, use the latest version of Visual Studio and the provided `WickedEngine.sln` solution file. The WickedEngine_UWP Project will build the engine for UWP platform as static library. The Template_UWP and Editor_UWP are two applications that will work on UWP platform that you can try. But first you must also build the binary shaders and embed them into the executable. To build and embed shaders, run the `OfflineShaderCompiler` projects with the `hlsl6 shaderdump` command line arguments. Then Rebuild the WickedEngine_UWP to create the engine with embedded shaders included. Now you can build an UWP application and run it on PC or Xbox.
|
||||
|
||||
- To run the UWP application on **Xbox**, enable developer mode on your Xbox, and choose "Remote Machine" as a debugging target in Visual Studio. Enter the IP address of the Xbox into the Machine Name field of debugging project settings (make sure that you are modifying the debug settings for Remote Machine). The authentication mode should be set to "Universal (Unencrypted Protocol)" and upon launching the application from Visual Studio, you will need to enter the security PIN that you can view on the Xbox developer settings.<br/>
|
||||
**Note that to utilize the full performance of Xbox Series, it is required to build with the native Xbox SDK build tools instead of UWP**
|
||||
|
||||
#### Xbox Series X|S
|
||||
To build for Xbox Series natively, download and install the Xbox SDK from your Xbox developer account. Using the latest version of Visual Studio, create a new static library project for the Xbox Series platform and reference the WickedEngine_SOURCE shared project. Xbox specific extension files required for building, or sample projects will be provided for registered Xbox developers on request.
|
||||
|
||||
@@ -264,7 +255,6 @@ You can specify command line arguments (without any prefix) to switch between re
|
||||
If you are having trouble getting the applications to run, make sure that you satisfy the following conditions:
|
||||
- If you built the application with Visual Studio, run it from the Visual Studio environment, where the executable working directory is set up to be the Project directory (not the build directory where the exe will be found)
|
||||
- If you want to run an application without Visual Studio, either copy the executable from the BUILD directory to the correct project directory, or set the working directory appropriately. You can also check the Working directory setting in Visual Studio to find out the right working directory of every project.
|
||||
- If you want to build UWP application, then you will first need to build the shaders into a shader dump. For that, build and run the `offlineshadercompiler` project with the `hlsl6 shaderdump` command line arguments. If the `wiShaderDump.h` file is successfully generated, rebuilding the engine will embed all the shader files so they are not loaded separately. But embedded shaders also cannot be recompiled during runtime.
|
||||
|
||||
<img align="right" src="https://github.com/turanszkij/wickedengine-gifs/raw/main/weather.gif" width="320px"/>
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 91 KiB |
|
Before Width: | Height: | Size: 41 KiB |
|
Before Width: | Height: | Size: 7.5 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 45 KiB |
@@ -1,228 +0,0 @@
|
||||
#include "pch.h"
|
||||
|
||||
// Use the C++ standard templated min/max
|
||||
#define NOMINMAX
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <exception>
|
||||
#include <future>
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "winrt/Windows.ApplicationModel.h"
|
||||
#include "winrt/Windows.ApplicationModel.Core.h"
|
||||
#include "winrt/Windows.ApplicationModel.Activation.h"
|
||||
#include "winrt/Windows.Foundation.h"
|
||||
#include "winrt/Windows.Graphics.Display.h"
|
||||
#include "winrt/Windows.System.h"
|
||||
#include "winrt/Windows.UI.Core.h"
|
||||
#include "winrt/Windows.UI.Input.h"
|
||||
#include "winrt/Windows.UI.ViewManagement.h"
|
||||
|
||||
using namespace winrt::Windows::ApplicationModel;
|
||||
using namespace winrt::Windows::ApplicationModel::Core;
|
||||
using namespace winrt::Windows::ApplicationModel::Activation;
|
||||
using namespace winrt::Windows::UI::Core;
|
||||
using namespace winrt::Windows::UI::Input;
|
||||
using namespace winrt::Windows::UI::ViewManagement;
|
||||
using namespace winrt::Windows::System;
|
||||
using namespace winrt::Windows::Foundation;
|
||||
using namespace winrt::Windows::Graphics::Display;
|
||||
|
||||
class ViewProvider : public winrt::implements<ViewProvider, IFrameworkView>
|
||||
{
|
||||
public:
|
||||
|
||||
// IFrameworkView methods
|
||||
void Initialize(CoreApplicationView const & applicationView)
|
||||
{
|
||||
applicationView.Activated({ this, &ViewProvider::OnActivated });
|
||||
|
||||
CoreApplication::Suspending({ this, &ViewProvider::OnSuspending });
|
||||
|
||||
CoreApplication::Resuming({ this, &ViewProvider::OnResuming });
|
||||
|
||||
application.infoDisplay.active = true;
|
||||
application.infoDisplay.watermark = true;
|
||||
application.infoDisplay.resolution = true;
|
||||
application.infoDisplay.fpsinfo = true;
|
||||
}
|
||||
|
||||
void Uninitialize() noexcept
|
||||
{
|
||||
}
|
||||
|
||||
void SetWindow(CoreWindow const & window)
|
||||
{
|
||||
window.SizeChanged({ this, &ViewProvider::OnWindowSizeChanged });
|
||||
|
||||
window.VisibilityChanged({ this, &ViewProvider::OnVisibilityChanged });
|
||||
|
||||
window.Closed([this](auto&&, auto&&) { m_exit = true; });
|
||||
|
||||
auto dispatcher = CoreWindow::GetForCurrentThread().Dispatcher();
|
||||
|
||||
dispatcher.AcceleratorKeyActivated({ this, &ViewProvider::OnAcceleratorKeyActivated });
|
||||
|
||||
auto navigation = SystemNavigationManager::GetForCurrentView();
|
||||
|
||||
// UWP on Xbox One triggers a back request whenever the B button is pressed
|
||||
// which can result in the app being suspended if unhandled
|
||||
navigation.BackRequested([](const winrt::Windows::Foundation::IInspectable&, const BackRequestedEventArgs& args)
|
||||
{
|
||||
args.Handled(true);
|
||||
});
|
||||
|
||||
auto currentDisplayInformation = DisplayInformation::GetForCurrentView();
|
||||
|
||||
currentDisplayInformation.DpiChanged({ this, &ViewProvider::OnDpiChanged });
|
||||
|
||||
DisplayInformation::DisplayContentsInvalidated({ this, &ViewProvider::OnDisplayContentsInvalidated });
|
||||
|
||||
m_DPI = currentDisplayInformation.LogicalDpi();
|
||||
|
||||
m_logicalWidth = window.Bounds().Width;
|
||||
m_logicalHeight = window.Bounds().Height;
|
||||
|
||||
application.SetWindow(&window);
|
||||
}
|
||||
|
||||
void Load(winrt::hstring const &) noexcept
|
||||
{
|
||||
}
|
||||
|
||||
void Run()
|
||||
{
|
||||
while (!m_exit)
|
||||
{
|
||||
if (m_visible)
|
||||
{
|
||||
application.Run();
|
||||
|
||||
CoreWindow::GetForCurrentThread().Dispatcher().ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent);
|
||||
}
|
||||
else
|
||||
{
|
||||
CoreWindow::GetForCurrentThread().Dispatcher().ProcessEvents(CoreProcessEventsOption::ProcessOneAndAllPending);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
// Event handlers
|
||||
void OnActivated(CoreApplicationView const & /*applicationView*/, IActivatedEventArgs const & args)
|
||||
{
|
||||
CoreWindow::GetForCurrentThread().Activate();
|
||||
}
|
||||
|
||||
void OnSuspending(IInspectable const & /*sender*/, SuspendingEventArgs const & args)
|
||||
{
|
||||
auto deferral = args.SuspendingOperation().GetDeferral();
|
||||
|
||||
auto f = std::async(std::launch::async, [this, deferral]()
|
||||
{
|
||||
deferral.Complete();
|
||||
});
|
||||
}
|
||||
|
||||
void OnResuming(IInspectable const & /*sender*/, IInspectable const & /*args*/)
|
||||
{
|
||||
}
|
||||
|
||||
void OnWindowSizeChanged(CoreWindow const & sender, WindowSizeChangedEventArgs const & /*args*/)
|
||||
{
|
||||
application.SetWindow(&sender);
|
||||
}
|
||||
|
||||
void OnVisibilityChanged(CoreWindow const & /*sender*/, VisibilityChangedEventArgs const & args)
|
||||
{
|
||||
m_visible = args.Visible();
|
||||
}
|
||||
|
||||
void OnAcceleratorKeyActivated(CoreDispatcher const &, AcceleratorKeyEventArgs const & args)
|
||||
{
|
||||
if (args.EventType() == CoreAcceleratorKeyEventType::SystemKeyDown
|
||||
&& args.VirtualKey() == VirtualKey::Enter
|
||||
&& args.KeyStatus().IsMenuKeyDown
|
||||
&& !args.KeyStatus().WasKeyDown)
|
||||
{
|
||||
// Implements the classic ALT+ENTER fullscreen toggle
|
||||
auto view = ApplicationView::GetForCurrentView();
|
||||
|
||||
if (view.IsFullScreenMode())
|
||||
view.ExitFullScreenMode();
|
||||
else
|
||||
view.TryEnterFullScreenMode();
|
||||
|
||||
args.Handled(true);
|
||||
}
|
||||
|
||||
if (args.EventType() == CoreAcceleratorKeyEventType::Character && args.VirtualKey() != VirtualKey::Enter)
|
||||
{
|
||||
wchar_t c = (wchar_t)args.VirtualKey();
|
||||
|
||||
if (c == '\b')
|
||||
{
|
||||
wi::gui::TextInputField::DeleteFromInput();
|
||||
}
|
||||
else
|
||||
{
|
||||
wi::gui::TextInputField::AddInput(c);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void OnDpiChanged(DisplayInformation const & sender, IInspectable const & /*args*/)
|
||||
{
|
||||
application.SetWindow(&CoreWindow::GetForCurrentThread());
|
||||
}
|
||||
|
||||
void OnDisplayContentsInvalidated(DisplayInformation const & /*sender*/, IInspectable const & /*args*/)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
bool m_exit = false;
|
||||
bool m_visible = true;
|
||||
float m_DPI = 96;
|
||||
float m_logicalWidth = 800;
|
||||
float m_logicalHeight = 600;
|
||||
wi::Application application;
|
||||
|
||||
inline int ConvertDipsToPixels(float dips) const noexcept
|
||||
{
|
||||
return int(dips * m_DPI / 96.f + 0.5f);
|
||||
}
|
||||
|
||||
inline float ConvertPixelsToDips(int pixels) const noexcept
|
||||
{
|
||||
return (float(pixels) * 96.f / m_DPI);
|
||||
}
|
||||
};
|
||||
|
||||
class ViewProviderFactory : public winrt::implements<ViewProviderFactory, IFrameworkViewSource>
|
||||
{
|
||||
public:
|
||||
IFrameworkView CreateView()
|
||||
{
|
||||
return winrt::make<ViewProvider>();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Entry point
|
||||
int WINAPI wWinMain(
|
||||
_In_ HINSTANCE /*hInstance*/,
|
||||
_In_ HINSTANCE /*hPrevInstance*/,
|
||||
_In_ LPWSTR /*lpCmdLine*/,
|
||||
_In_ int /*nCmdShow*/
|
||||
)
|
||||
{
|
||||
auto viewProviderFactory = winrt::make<ViewProviderFactory>();
|
||||
CoreApplication::Run(viewProviderFactory);
|
||||
return 0;
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<Package
|
||||
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
|
||||
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
|
||||
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
|
||||
IgnorableNamespaces="uap mp">
|
||||
|
||||
<Identity
|
||||
Name="555fcb24-6bf0-4117-8199-4bd0e1b3435c"
|
||||
Publisher="CN=turan"
|
||||
Version="1.0.0.0" />
|
||||
|
||||
<mp:PhoneIdentity PhoneProductId="555fcb24-6bf0-4117-8199-4bd0e1b3435c" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
|
||||
|
||||
<Properties>
|
||||
<DisplayName>Template_UWP</DisplayName>
|
||||
<PublisherDisplayName>Janos Turanszki</PublisherDisplayName>
|
||||
<Logo>Assets\StoreLogo.png</Logo>
|
||||
</Properties>
|
||||
|
||||
<Dependencies>
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
|
||||
</Dependencies>
|
||||
|
||||
<Resources>
|
||||
<Resource Language="x-generate"/>
|
||||
</Resources>
|
||||
|
||||
<Applications>
|
||||
<Application Id="App"
|
||||
Executable="$targetnametoken$.exe"
|
||||
EntryPoint="Template_UWP.App">
|
||||
<uap:VisualElements
|
||||
DisplayName="Wicked Engine UWP Template"
|
||||
Square150x150Logo="Assets\Square150x150Logo.png"
|
||||
Square44x44Logo="Assets\Square44x44Logo.png"
|
||||
Description="Wicked Engine UWP Template"
|
||||
BackgroundColor="transparent">
|
||||
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png"/>
|
||||
<uap:SplashScreen Image="Assets\SplashScreen.png" />
|
||||
</uap:VisualElements>
|
||||
</Application>
|
||||
</Applications>
|
||||
|
||||
<Capabilities>
|
||||
<Capability Name="internetClient" />
|
||||
</Capabilities>
|
||||
</Package>
|
||||
@@ -1,46 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Assets">
|
||||
<UniqueIdentifier>ffee1550-5669-47a8-9efa-342070932f48</UniqueIdentifier>
|
||||
<Extensions>bmp;fbx;gif;jpg;jpeg;tga;tiff;tif;png</Extensions>
|
||||
</Filter>
|
||||
<Image Include="Assets\LockScreenLogo.scale-200.png">
|
||||
<Filter>Assets</Filter>
|
||||
</Image>
|
||||
<Image Include="Assets\SplashScreen.scale-200.png">
|
||||
<Filter>Assets</Filter>
|
||||
</Image>
|
||||
<Image Include="Assets\Square150x150Logo.scale-200.png">
|
||||
<Filter>Assets</Filter>
|
||||
</Image>
|
||||
<Image Include="Assets\Square44x44Logo.scale-200.png">
|
||||
<Filter>Assets</Filter>
|
||||
</Image>
|
||||
<Image Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png">
|
||||
<Filter>Assets</Filter>
|
||||
</Image>
|
||||
<Image Include="Assets\Wide310x150Logo.scale-200.png">
|
||||
<Filter>Assets</Filter>
|
||||
</Image>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="pch.cpp" />
|
||||
<ClCompile Include="Main.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="pch.h" />
|
||||
<ClInclude Include="StepTimer.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="Assets\StoreLogo.png">
|
||||
<Filter>Assets</Filter>
|
||||
</Image>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AppxManifest Include="Package.appxmanifest" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.Windows.CppWinRT" version="2.0.230706.1" targetFramework="native" />
|
||||
</packages>
|
||||
@@ -1 +0,0 @@
|
||||
#include "pch.h"
|
||||
@@ -1,2 +0,0 @@
|
||||
#pragma once
|
||||
#include "WickedEngine.h"
|
||||
@@ -5,28 +5,16 @@ VisualStudioVersion = 17.2.32616.157
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Editor_Windows", "Editor\Editor_Windows.vcxproj", "{5FE97B9B-A445-4EEA-A42D-9DE60B891D48}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Editor_UWP", "Editor\Editor_UWP.vcxproj", "{FA78BFAD-4B23-4A6B-92FA-A48CE56BED03}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{60DA258F-E95F-4CF4-A46B-17D80644464B} = {60DA258F-E95F-4CF4-A46B-17D80644464B}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Editor_SOURCE", "Editor\Editor_SOURCE.vcxitems", "{867FEBCA-09C4-4FE7-8A4C-4D9B1C27E7D0}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tests", "Tests\Tests.vcxproj", "{3A9EA3D0-A795-46ED-A737-7164E90DC309}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Template_Windows", "Template_Windows\Template_Windows.vcxproj", "{76AA3D37-3252-4785-9334-3FC6B8CC07DE}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Template_UWP", "Template_UWP\Template_UWP.vcxproj", "{C222218B-B6D1-406B-B2C0-8C1CED4A8D19}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{60DA258F-E95F-4CF4-A46B-17D80644464B} = {60DA258F-E95F-4CF4-A46B-17D80644464B}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WickedEngine_SOURCE", "WickedEngine\WickedEngine_SOURCE.vcxitems", "{45D41ACC-2C3C-43D2-BC10-02AA73FFC7C7}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WickedEngine_Windows", "WickedEngine\WickedEngine_Windows.vcxproj", "{06163DCB-B183-4ED9-9C62-13EF1658E049}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WickedEngine_UWP", "WickedEngine\WickedEngine_UWP.vcxproj", "{60DA258F-E95F-4CF4-A46B-17D80644464B}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Supplementary", "Supplementary", "{BF8FCAB8-D7D3-4DAE-92DE-4B5037E9A0ED}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
.editorconfig = .editorconfig
|
||||
@@ -57,17 +45,6 @@ EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Example_ImGui_Docking", "Example_ImGui_Docking\Example_ImGui_Docking.vcxproj", "{5646F9FB-C9E3-4DA4-8AAA-EB7A46DD777E}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SharedMSBuildProjectFiles) = preSolution
|
||||
WickedEngine\WickedEngine_SOURCE.vcxitems*{06163dcb-b183-4ed9-9c62-13ef1658e049}*SharedItemsImports = 4
|
||||
WickedEngine\WickedEngine_SOURCE.vcxitems*{45d41acc-2c3c-43d2-bc10-02aa73ffc7c7}*SharedItemsImports = 9
|
||||
Editor\Editor_SOURCE.vcxitems*{5fe97b9b-a445-4eea-a42d-9de60b891d48}*SharedItemsImports = 4
|
||||
WickedEngine\WickedEngine_SOURCE.vcxitems*{60da258f-e95f-4cf4-a46b-17d80644464b}*SharedItemsImports = 4
|
||||
Editor\Editor_SOURCE.vcxitems*{867febca-09c4-4fe7-8a4c-4d9b1c27e7d0}*SharedItemsImports = 9
|
||||
WickedEngine\shaders\Shaders_SOURCE.vcxitems*{92e86448-0724-4387-abac-96e63edf4190}*SharedItemsImports = 9
|
||||
Content\Content.vcxitems*{c48f6bff-f91b-4db5-98b5-15287dfb7c95}*SharedItemsImports = 9
|
||||
Content\Content.vcxitems*{fa78bfad-4b23-4a6b-92fa-a48ce56bed03}*SharedItemsImports = 4
|
||||
Editor\Editor_SOURCE.vcxitems*{fa78bfad-4b23-4a6b-92fa-a48ce56bed03}*SharedItemsImports = 4
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Release|x64 = Release|x64
|
||||
@@ -77,12 +54,6 @@ Global
|
||||
{5FE97B9B-A445-4EEA-A42D-9DE60B891D48}.Debug|x64.Build.0 = Debug|x64
|
||||
{5FE97B9B-A445-4EEA-A42D-9DE60B891D48}.Release|x64.ActiveCfg = Release|x64
|
||||
{5FE97B9B-A445-4EEA-A42D-9DE60B891D48}.Release|x64.Build.0 = Release|x64
|
||||
{FA78BFAD-4B23-4A6B-92FA-A48CE56BED03}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{FA78BFAD-4B23-4A6B-92FA-A48CE56BED03}.Debug|x64.Build.0 = Debug|x64
|
||||
{FA78BFAD-4B23-4A6B-92FA-A48CE56BED03}.Debug|x64.Deploy.0 = Debug|x64
|
||||
{FA78BFAD-4B23-4A6B-92FA-A48CE56BED03}.Release|x64.ActiveCfg = Release|x64
|
||||
{FA78BFAD-4B23-4A6B-92FA-A48CE56BED03}.Release|x64.Build.0 = Release|x64
|
||||
{FA78BFAD-4B23-4A6B-92FA-A48CE56BED03}.Release|x64.Deploy.0 = Release|x64
|
||||
{3A9EA3D0-A795-46ED-A737-7164E90DC309}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{3A9EA3D0-A795-46ED-A737-7164E90DC309}.Debug|x64.Build.0 = Debug|x64
|
||||
{3A9EA3D0-A795-46ED-A737-7164E90DC309}.Release|x64.ActiveCfg = Release|x64
|
||||
@@ -91,20 +62,10 @@ Global
|
||||
{76AA3D37-3252-4785-9334-3FC6B8CC07DE}.Debug|x64.Build.0 = Debug|x64
|
||||
{76AA3D37-3252-4785-9334-3FC6B8CC07DE}.Release|x64.ActiveCfg = Release|x64
|
||||
{76AA3D37-3252-4785-9334-3FC6B8CC07DE}.Release|x64.Build.0 = Release|x64
|
||||
{C222218B-B6D1-406B-B2C0-8C1CED4A8D19}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{C222218B-B6D1-406B-B2C0-8C1CED4A8D19}.Debug|x64.Build.0 = Debug|x64
|
||||
{C222218B-B6D1-406B-B2C0-8C1CED4A8D19}.Debug|x64.Deploy.0 = Debug|x64
|
||||
{C222218B-B6D1-406B-B2C0-8C1CED4A8D19}.Release|x64.ActiveCfg = Release|x64
|
||||
{C222218B-B6D1-406B-B2C0-8C1CED4A8D19}.Release|x64.Build.0 = Release|x64
|
||||
{C222218B-B6D1-406B-B2C0-8C1CED4A8D19}.Release|x64.Deploy.0 = Release|x64
|
||||
{06163DCB-B183-4ED9-9C62-13EF1658E049}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{06163DCB-B183-4ED9-9C62-13EF1658E049}.Debug|x64.Build.0 = Debug|x64
|
||||
{06163DCB-B183-4ED9-9C62-13EF1658E049}.Release|x64.ActiveCfg = Release|x64
|
||||
{06163DCB-B183-4ED9-9C62-13EF1658E049}.Release|x64.Build.0 = Release|x64
|
||||
{60DA258F-E95F-4CF4-A46B-17D80644464B}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{60DA258F-E95F-4CF4-A46B-17D80644464B}.Debug|x64.Build.0 = Debug|x64
|
||||
{60DA258F-E95F-4CF4-A46B-17D80644464B}.Release|x64.ActiveCfg = Release|x64
|
||||
{60DA258F-E95F-4CF4-A46B-17D80644464B}.Release|x64.Build.0 = Release|x64
|
||||
{3B74A7FE-CED7-4723-8824-AC708A865B98}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{3B74A7FE-CED7-4723-8824-AC708A865B98}.Debug|x64.Build.0 = Debug|x64
|
||||
{3B74A7FE-CED7-4723-8824-AC708A865B98}.Release|x64.ActiveCfg = Release|x64
|
||||
@@ -128,4 +89,12 @@ Global
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {E3FF044A-B72E-4ED5-BE05-AB641BA048CD}
|
||||
EndGlobalSection
|
||||
GlobalSection(SharedMSBuildProjectFiles) = preSolution
|
||||
WickedEngine\WickedEngine_SOURCE.vcxitems*{06163dcb-b183-4ed9-9c62-13ef1658e049}*SharedItemsImports = 4
|
||||
WickedEngine\WickedEngine_SOURCE.vcxitems*{45d41acc-2c3c-43d2-bc10-02aa73ffc7c7}*SharedItemsImports = 9
|
||||
Editor\Editor_SOURCE.vcxitems*{5fe97b9b-a445-4eea-a42d-9de60b891d48}*SharedItemsImports = 4
|
||||
Editor\Editor_SOURCE.vcxitems*{867febca-09c4-4fe7-8a4c-4d9b1c27e7d0}*SharedItemsImports = 9
|
||||
WickedEngine\shaders\Shaders_SOURCE.vcxitems*{92e86448-0724-4387-abac-96e63edf4190}*SharedItemsImports = 9
|
||||
Content\Content.vcxitems*{c48f6bff-f91b-4db5-98b5-15287dfb7c95}*SharedItemsImports = 9
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
@@ -199,7 +199,6 @@ add_library(${TARGET_NAME} ${WICKED_LIBRARY_TYPE}
|
||||
wiNetwork_BindLua.cpp
|
||||
wiNetwork_Linux.cpp
|
||||
wiNetwork_Windows.cpp
|
||||
wiNetwork_UWP.cpp
|
||||
wiOcean.cpp
|
||||
wiPhysics_Bullet.cpp
|
||||
wiPhysics_BindLua.cpp
|
||||
|
||||
@@ -80,10 +80,6 @@
|
||||
#pragma comment(lib,"WickedEngine_Windows.lib")
|
||||
#endif // PLATFORM_WINDOWS_DESKTOP
|
||||
|
||||
#ifdef PLATFORM_UWP
|
||||
#pragma comment(lib,"WickedEngine_UWP.lib")
|
||||
#endif // PLATFORM_UWP
|
||||
|
||||
#ifdef PLATFORM_XBOX
|
||||
#pragma comment(lib,"WickedEngine_XBOX.lib")
|
||||
#endif // PLATFORM_XBOX
|
||||
|
||||
@@ -696,7 +696,6 @@
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)wiPrimitive.cpp" />
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)wiPrimitive_BindLua.cpp" />
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)wiJobSystem.cpp" />
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)wiNetwork_UWP.cpp" />
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)wiNetwork_Windows.cpp" />
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)wiPhysics_Bullet.cpp" />
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)wiLua.cpp" />
|
||||
|
||||
@@ -1826,9 +1826,6 @@
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)wiNetwork_Windows.cpp">
|
||||
<Filter>ENGINE\Network</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)wiNetwork_UWP.cpp">
|
||||
<Filter>ENGINE\Network</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)wiInput.cpp">
|
||||
<Filter>ENGINE\Input</Filter>
|
||||
</ClCompile>
|
||||
|
||||
@@ -1,122 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.230706.1\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.230706.1\build\native\Microsoft.Windows.CppWinRT.props')" />
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{60da258f-e95f-4cf4-a46b-17d80644464b}</ProjectGuid>
|
||||
<Keyword>StaticLibrary</Keyword>
|
||||
<RootNamespace>WickedEngine_UWP</RootNamespace>
|
||||
<DefaultLanguage>en-US</DefaultLanguage>
|
||||
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
|
||||
<AppContainerApplication>true</AppContainerApplication>
|
||||
<ApplicationType>Windows Store</ApplicationType>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
<ApplicationTypeRevision>10.0</ApplicationTypeRevision>
|
||||
<WindowsTargetPlatformMinVersion>10.0.19041.0</WindowsTargetPlatformMinVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
<Import Project="WickedEngine_SOURCE.vcxitems" Label="Shared" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<GenerateManifest>false</GenerateManifest>
|
||||
<IntDir>$(MSBuildProjectName)\$(Platform)\$(Configuration)\</IntDir>
|
||||
<OutDir>$(SolutionDir)BUILD\$(Platform)\$(Configuration)\</OutDir>
|
||||
<MultiProcFXC>true</MultiProcFXC>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<GenerateManifest>false</GenerateManifest>
|
||||
<IntDir>$(MSBuildProjectName)\$(Platform)\$(Configuration)\</IntDir>
|
||||
<OutDir>$(SolutionDir)BUILD\$(Platform)\$(Configuration)\</OutDir>
|
||||
<MultiProcFXC>true</MultiProcFXC>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<CompileAsWinRT>false</CompileAsWinRT>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>BULLET;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
||||
<GenerateWindowsMetadata>false</GenerateWindowsMetadata>
|
||||
</Link>
|
||||
<FxCompile>
|
||||
<ObjectFileOutput>shaders/%(Filename).cso</ObjectFileOutput>
|
||||
<DisableOptimizations>false</DisableOptimizations>
|
||||
<EnableDebuggingInformation>false</EnableDebuggingInformation>
|
||||
<ShaderModel>5.0</ShaderModel>
|
||||
</FxCompile>
|
||||
<Lib />
|
||||
<Lib />
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<CompileAsWinRT>false</CompileAsWinRT>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>BULLET;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
||||
<GenerateWindowsMetadata>false</GenerateWindowsMetadata>
|
||||
</Link>
|
||||
<FxCompile>
|
||||
<ObjectFileOutput>shaders/%(Filename).cso</ObjectFileOutput>
|
||||
<ShaderModel>5.0</ShaderModel>
|
||||
</FxCompile>
|
||||
<Lib />
|
||||
<Lib />
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.230706.1\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.230706.1\build\native\Microsoft.Windows.CppWinRT.targets')" />
|
||||
</ImportGroup>
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.230706.1\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.CppWinRT.2.0.230706.1\build\native\Microsoft.Windows.CppWinRT.props'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.230706.1\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.CppWinRT.2.0.230706.1\build\native\Microsoft.Windows.CppWinRT.targets'))" />
|
||||
</Target>
|
||||
</Project>
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.Windows.CppWinRT" version="2.0.230706.1" targetFramework="native" />
|
||||
</packages>
|
||||
@@ -343,10 +343,6 @@ namespace wi
|
||||
infodisplay_str += "[32-bit]";
|
||||
#endif // _ARM
|
||||
|
||||
#ifdef PLATFORM_UWP
|
||||
infodisplay_str += "[UWP]";
|
||||
#endif // PLATFORM_UWP
|
||||
|
||||
#ifdef WICKEDENGINE_BUILD_DX12
|
||||
if (dynamic_cast<GraphicsDevice_DX12*>(graphicsDevice.get()))
|
||||
{
|
||||
|
||||
@@ -53,11 +53,6 @@ namespace dx12_internal
|
||||
static PFN_D3D12_CREATE_VERSIONED_ROOT_SIGNATURE_DESERIALIZER D3D12CreateVersionedRootSignatureDeserializer = nullptr;
|
||||
#endif // PLATFORM_WINDOWS_DESKTOP
|
||||
|
||||
#ifdef PLATFORM_UWP
|
||||
#pragma comment(lib,"d3d12.lib")
|
||||
#pragma comment(lib,"dxgi.lib")
|
||||
#endif // PLATFORM_UWP
|
||||
|
||||
// Engine -> Native converters
|
||||
constexpr uint32_t _ParseColorWriteMask(ColorWrite value)
|
||||
{
|
||||
|
||||
@@ -25,19 +25,8 @@
|
||||
#if defined(_WIN32)
|
||||
#include <direct.h>
|
||||
#include <Psapi.h> // GetProcessMemoryInfo
|
||||
#ifdef PLATFORM_UWP
|
||||
#include <winrt/Windows.UI.Popups.h>
|
||||
#include <winrt/Windows.Storage.h>
|
||||
#include <winrt/Windows.Storage.Pickers.h>
|
||||
#include <winrt/Windows.Storage.AccessCache.h>
|
||||
#include <winrt/Windows.Storage.Streams.h>
|
||||
#include <winrt/Windows.Foundation.h>
|
||||
#include <winrt/Windows.Foundation.Collections.h>
|
||||
#include <winrt/Windows.System.h>
|
||||
#else
|
||||
#include <Commdlg.h> // openfile
|
||||
#include <WinBase.h>
|
||||
#endif // PLATFORM_UWP
|
||||
#elif defined(PLATFORM_PS5)
|
||||
#else
|
||||
#include "Utility/portable-file-dialogs.h"
|
||||
@@ -73,16 +62,6 @@ namespace wi::helper
|
||||
MessageBoxA(GetActiveWindow(), msg.c_str(), caption.c_str(), 0);
|
||||
#endif // PLATFORM_WINDOWS_DESKTOP
|
||||
|
||||
#ifdef PLATFORM_UWP
|
||||
std::wstring wmessage, wcaption;
|
||||
StringConvert(msg, wmessage);
|
||||
StringConvert(caption, wcaption);
|
||||
// UWP can only show message box on main thread:
|
||||
wi::eventhandler::Subscribe_Once(wi::eventhandler::EVENT_THREAD_SAFE_POINT, [=](uint64_t userdata) {
|
||||
winrt::Windows::UI::Popups::MessageDialog(wmessage, wcaption).ShowAsync();
|
||||
});
|
||||
#endif // PLATFORM_UWP
|
||||
|
||||
#ifdef SDL2
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, caption.c_str(), msg.c_str(), NULL);
|
||||
#endif // SDL2
|
||||
@@ -970,16 +949,6 @@ namespace wi::helper
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef PLATFORM_UWP
|
||||
|
||||
size_t found = path.rfind(rootdir);
|
||||
if (found != std::string::npos)
|
||||
{
|
||||
path = path.substr(found + rootdir.length());
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
std::filesystem::path filepath = ToNativeString(path);
|
||||
if (filepath.is_absolute())
|
||||
{
|
||||
@@ -991,8 +960,6 @@ namespace wi::helper
|
||||
}
|
||||
}
|
||||
|
||||
#endif // PLATFORM_UWP
|
||||
|
||||
}
|
||||
|
||||
void MakePathAbsolute(std::string& path)
|
||||
@@ -1012,7 +979,6 @@ namespace wi::helper
|
||||
template<template<typename T, typename A> typename vector_interface>
|
||||
bool FileRead_Impl(const std::string& fileName, vector_interface<uint8_t, std::allocator<uint8_t>>& data, size_t max_read, size_t offset)
|
||||
{
|
||||
#ifndef PLATFORM_UWP
|
||||
#if defined(PLATFORM_LINUX) || defined(PLATFORM_PS5)
|
||||
std::string filepath = fileName;
|
||||
std::replace(filepath.begin(), filepath.end(), '\\', '/'); // Linux cannot handle backslash in file path, need to convert it to forward slash
|
||||
@@ -1020,6 +986,7 @@ namespace wi::helper
|
||||
#else
|
||||
std::ifstream file(ToNativeString(fileName), std::ios::binary | std::ios::ate);
|
||||
#endif // PLATFORM_LINUX || PLATFORM_PS5
|
||||
|
||||
if (file.is_open())
|
||||
{
|
||||
size_t dataSize = (size_t)file.tellg() - offset;
|
||||
@@ -1030,60 +997,6 @@ namespace wi::helper
|
||||
file.close();
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
using namespace winrt::Windows::Storage;
|
||||
using namespace winrt::Windows::Storage::Streams;
|
||||
using namespace winrt::Windows::Foundation;
|
||||
std::wstring wstr;
|
||||
std::filesystem::path filepath = fileName;
|
||||
filepath = std::filesystem::absolute(filepath);
|
||||
StringConvert(filepath.string(), wstr);
|
||||
bool success = false;
|
||||
|
||||
auto async_helper = [&]() -> IAsyncAction {
|
||||
try
|
||||
{
|
||||
auto file = co_await StorageFile::GetFileFromPathAsync(wstr);
|
||||
auto buffer = co_await FileIO::ReadBufferAsync(file);
|
||||
auto reader = DataReader::FromBuffer(buffer);
|
||||
size_t dataSize = (size_t)buffer.Length();
|
||||
dataSize = std::min(dataSize, max_read);
|
||||
data.resize((size_t)dataSize);
|
||||
for (auto& x : data)
|
||||
{
|
||||
x = reader.ReadByte();
|
||||
}
|
||||
success = true;
|
||||
}
|
||||
catch (winrt::hresult_error const& ex)
|
||||
{
|
||||
switch (ex.code())
|
||||
{
|
||||
case E_ACCESSDENIED:
|
||||
wi::backlog::post("Opening file failed: " + fileName + " | Reason: Permission Denied!");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
if (winrt::impl::is_sta_thread())
|
||||
{
|
||||
std::thread([&] { async_helper().get(); }).join(); // can't block coroutine from ui thread
|
||||
}
|
||||
else
|
||||
{
|
||||
async_helper().get();
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif // PLATFORM_UWP
|
||||
|
||||
wi::backlog::post("File not found: " + fileName, wi::backlog::LogLevel::Warning);
|
||||
return false;
|
||||
@@ -1106,7 +1019,6 @@ namespace wi::helper
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifndef PLATFORM_UWP
|
||||
std::ofstream file(ToNativeString(fileName), std::ios::binary | std::ios::trunc);
|
||||
if (file.is_open())
|
||||
{
|
||||
@@ -1114,158 +1026,20 @@ namespace wi::helper
|
||||
file.close();
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
|
||||
using namespace winrt::Windows::Storage;
|
||||
using namespace winrt::Windows::Storage::Streams;
|
||||
using namespace winrt::Windows::Foundation;
|
||||
std::wstring wstr;
|
||||
std::filesystem::path filepath = fileName;
|
||||
filepath = std::filesystem::absolute(filepath);
|
||||
StringConvert(filepath.string(), wstr);
|
||||
|
||||
CREATEFILE2_EXTENDED_PARAMETERS params = {};
|
||||
params.dwSize = (DWORD)size;
|
||||
params.dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
|
||||
HANDLE filehandle = CreateFile2FromAppW(wstr.c_str(), GENERIC_READ | GENERIC_WRITE, 0, CREATE_ALWAYS, ¶ms);
|
||||
assert(filehandle);
|
||||
CloseHandle(filehandle);
|
||||
|
||||
bool success = false;
|
||||
auto async_helper = [&]() -> IAsyncAction {
|
||||
try
|
||||
{
|
||||
auto file = co_await StorageFile::GetFileFromPathAsync(wstr);
|
||||
winrt::array_view<const uint8_t> dataarray(data, (winrt::array_view<const uint8_t>::size_type)size);
|
||||
co_await FileIO::WriteBytesAsync(file, dataarray);
|
||||
success = true;
|
||||
}
|
||||
catch (winrt::hresult_error const& ex)
|
||||
{
|
||||
switch (ex.code())
|
||||
{
|
||||
case E_ACCESSDENIED:
|
||||
wi::backlog::post("Opening file failed: " + fileName + " | Reason: Permission Denied!");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
if (winrt::impl::is_sta_thread())
|
||||
{
|
||||
std::thread([&] { async_helper().get(); }).join(); // can't block coroutine from ui thread
|
||||
}
|
||||
else
|
||||
{
|
||||
async_helper().get();
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
#endif // PLATFORM_UWP
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FileExists(const std::string& fileName)
|
||||
{
|
||||
#ifndef PLATFORM_UWP
|
||||
bool exists = std::filesystem::exists(ToNativeString(fileName));
|
||||
return exists;
|
||||
#else
|
||||
using namespace winrt::Windows::Storage;
|
||||
using namespace winrt::Windows::Storage::Streams;
|
||||
using namespace winrt::Windows::Foundation;
|
||||
std::wstring wstr;
|
||||
std::filesystem::path filepath = fileName;
|
||||
filepath = std::filesystem::absolute(filepath);
|
||||
StringConvert(filepath.string(), wstr);
|
||||
bool success = false;
|
||||
|
||||
auto async_helper = [&]() -> IAsyncAction {
|
||||
try
|
||||
{
|
||||
auto file = co_await StorageFile::GetFileFromPathAsync(wstr);
|
||||
success = true;
|
||||
}
|
||||
catch (winrt::hresult_error const& ex)
|
||||
{
|
||||
switch (ex.code())
|
||||
{
|
||||
case E_ACCESSDENIED:
|
||||
wi::backlog::post("Opening file failed: " + fileName + " | Reason: Permission Denied!");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
if (winrt::impl::is_sta_thread())
|
||||
{
|
||||
std::thread([&] { async_helper().get(); }).join(); // can't block coroutine from ui thread
|
||||
}
|
||||
else
|
||||
{
|
||||
async_helper().get();
|
||||
}
|
||||
|
||||
return success;
|
||||
#endif // PLATFORM_UWP
|
||||
}
|
||||
|
||||
bool DirectoryExists(const std::string& fileName)
|
||||
{
|
||||
#ifndef PLATFORM_UWP
|
||||
bool exists = std::filesystem::exists(ToNativeString(fileName));
|
||||
return exists;
|
||||
#else
|
||||
using namespace winrt::Windows::Storage;
|
||||
using namespace winrt::Windows::Storage::Streams;
|
||||
using namespace winrt::Windows::Foundation;
|
||||
std::wstring wstr;
|
||||
std::filesystem::path filepath = fileName;
|
||||
filepath = std::filesystem::absolute(filepath);
|
||||
StringConvert(filepath.string(), wstr);
|
||||
bool success = false;
|
||||
|
||||
auto async_helper = [&]() -> IAsyncAction {
|
||||
try
|
||||
{
|
||||
auto file = co_await StorageFolder::GetFolderFromPathAsync(wstr);
|
||||
success = true;
|
||||
}
|
||||
catch (winrt::hresult_error const& ex)
|
||||
{
|
||||
switch (ex.code())
|
||||
{
|
||||
case E_ACCESSDENIED:
|
||||
wi::backlog::post("Opening folder failed: " + fileName + " | Reason: Permission Denied!");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
if (winrt::impl::is_sta_thread())
|
||||
{
|
||||
std::thread([&] { async_helper().get(); }).join(); // can't block coroutine from ui thread
|
||||
}
|
||||
else
|
||||
{
|
||||
async_helper().get();
|
||||
}
|
||||
|
||||
return success;
|
||||
#endif // PLATFORM_UWP
|
||||
}
|
||||
|
||||
uint64_t FileTimestamp(const std::string& fileName)
|
||||
@@ -1390,81 +1164,6 @@ namespace wi::helper
|
||||
}).detach();
|
||||
#endif // PLATFORM_WINDOWS_DESKTOP
|
||||
|
||||
#ifdef PLATFORM_UWP
|
||||
auto filedialoghelper = [](FileDialogParams params, std::function<void(std::string fileName)> onSuccess) -> winrt::fire_and_forget {
|
||||
|
||||
using namespace winrt::Windows::Storage;
|
||||
using namespace winrt::Windows::Storage::Pickers;
|
||||
using namespace winrt::Windows::Storage::AccessCache;
|
||||
|
||||
switch (params.type)
|
||||
{
|
||||
default:
|
||||
case FileDialogParams::OPEN:
|
||||
{
|
||||
FileOpenPicker picker;
|
||||
picker.ViewMode(PickerViewMode::List);
|
||||
picker.SuggestedStartLocation(PickerLocationId::Objects3D);
|
||||
|
||||
for (auto& x : params.extensions)
|
||||
{
|
||||
std::wstring wstr;
|
||||
StringConvert(x, wstr);
|
||||
wstr = L"." + wstr;
|
||||
picker.FileTypeFilter().Append(wstr);
|
||||
}
|
||||
|
||||
auto file = co_await picker.PickSingleFileAsync();
|
||||
|
||||
if (file)
|
||||
{
|
||||
auto futureaccess = StorageApplicationPermissions::FutureAccessList();
|
||||
futureaccess.Clear();
|
||||
futureaccess.Add(file);
|
||||
std::wstring wstr = file.Path().data();
|
||||
std::string str;
|
||||
StringConvert(wstr, str);
|
||||
|
||||
onSuccess(str);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case FileDialogParams::SAVE:
|
||||
{
|
||||
FileSavePicker picker;
|
||||
picker.SuggestedStartLocation(PickerLocationId::Objects3D);
|
||||
|
||||
std::wstring wdesc;
|
||||
StringConvert(params.description, wdesc);
|
||||
winrt::Windows::Foundation::Collections::IVector<winrt::hstring> extensions{ winrt::single_threaded_vector<winrt::hstring>() };
|
||||
for (auto& x : params.extensions)
|
||||
{
|
||||
std::wstring wstr;
|
||||
StringConvert(x, wstr);
|
||||
wstr = L"." + wstr;
|
||||
extensions.Append(wstr);
|
||||
}
|
||||
picker.FileTypeChoices().Insert(wdesc, extensions);
|
||||
|
||||
auto file = co_await picker.PickSaveFileAsync();
|
||||
if (file)
|
||||
{
|
||||
auto futureaccess = StorageApplicationPermissions::FutureAccessList();
|
||||
futureaccess.Clear();
|
||||
futureaccess.Add(file);
|
||||
std::wstring wstr = file.Path().data();
|
||||
std::string str;
|
||||
StringConvert(wstr, str);
|
||||
onSuccess(str);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
};
|
||||
filedialoghelper(params, onSuccess);
|
||||
|
||||
#endif // PLATFORM_UWP
|
||||
|
||||
#ifdef PLATFORM_LINUX
|
||||
if (!pfd::settings::available()) {
|
||||
const char *message = "No dialog backend available";
|
||||
@@ -1703,10 +1402,6 @@ namespace wi::helper
|
||||
|
||||
void OpenUrl(const std::string& url)
|
||||
{
|
||||
#ifdef PLATFORM_UWP
|
||||
winrt::Windows::System::Launcher::LaunchUriAsync(winrt::Windows::Foundation::Uri(winrt::to_hstring(url)));
|
||||
return;
|
||||
#endif // PLATFORM_UWP
|
||||
|
||||
#ifdef PLATFORM_WINDOWS_DESKTOP
|
||||
std::string op = "start \"\" \"" + url + "\"";
|
||||
|
||||
@@ -18,12 +18,6 @@
|
||||
#include <SDL2/SDL.h>
|
||||
#endif // SDL2
|
||||
|
||||
#ifdef PLATFORM_UWP
|
||||
#include <winrt/Windows.Foundation.h>
|
||||
#include <winrt/Windows.UI.Input.h>
|
||||
#include <winrt/Windows.Devices.Input.h>
|
||||
#endif // PLATFORM_UWP
|
||||
|
||||
#ifdef PLATFORM_PS5
|
||||
#include "wiInput_PS5.h"
|
||||
#endif // PLATFORM_PS5
|
||||
@@ -31,14 +25,9 @@
|
||||
namespace wi::input
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#ifndef PLATFORM_UWP
|
||||
#define KEY_DOWN(vk_code) (GetAsyncKeyState(vk_code) < 0)
|
||||
#define KEY_TOGGLE(vk_code) ((GetAsyncKeyState(vk_code) & 1) != 0)
|
||||
#else
|
||||
#define KEY_DOWN(vk_code) ((int)winrt::Windows::UI::Core::CoreWindow::GetForCurrentThread().GetAsyncKeyState((winrt::Windows::System::VirtualKey)vk_code) < 0)
|
||||
#define KEY_TOGGLE(vk_code) (((int)winrt::Windows::UI::Core::CoreWindow::GetForCurrentThread().GetAsyncKeyState((winrt::Windows::System::VirtualKey)vk_code) & 1) != 0)
|
||||
#endif //PLATFORM_UWP
|
||||
#else
|
||||
#define KEY_DOWN(vk_code) 0
|
||||
#define KEY_TOGGLE(vk_code) 0
|
||||
#endif // WIN32
|
||||
@@ -136,7 +125,6 @@ namespace wi::input
|
||||
mouse.middle_button_press |= KEY_DOWN(VK_MBUTTON);
|
||||
mouse.right_button_press |= KEY_DOWN(VK_RBUTTON);
|
||||
|
||||
#ifndef PLATFORM_UWP
|
||||
// Since raw input doesn't contain absolute mouse position, we get it with regular winapi:
|
||||
POINT p;
|
||||
GetCursorPos(&p);
|
||||
@@ -145,7 +133,6 @@ namespace wi::input
|
||||
mouse.position.y = (float)p.y;
|
||||
mouse.position.x /= canvas.GetDPIScaling();
|
||||
mouse.position.y /= canvas.GetDPIScaling();
|
||||
#endif // PLATFORM_UWP
|
||||
|
||||
#elif SDL2
|
||||
wi::input::sdlinput::GetMouseState(&mouse);
|
||||
@@ -156,89 +143,6 @@ namespace wi::input
|
||||
//TODO touch
|
||||
#endif
|
||||
|
||||
#ifdef PLATFORM_UWP
|
||||
static bool isRegisteredUWP = false;
|
||||
if (!isRegisteredUWP)
|
||||
{
|
||||
isRegisteredUWP = true;
|
||||
using namespace winrt::Windows::UI::Core;
|
||||
using namespace winrt::Windows::Devices::Input;
|
||||
|
||||
auto window = CoreWindow::GetForCurrentThread();
|
||||
window.PointerPressed([](CoreWindow, PointerEventArgs args) {
|
||||
auto p = args.CurrentPoint();
|
||||
|
||||
if (p.Properties().IsPrimary())
|
||||
{
|
||||
mouse.position = XMFLOAT2(p.Position().X, p.Position().Y);
|
||||
// UWP mouse position already has DPI applied, so only apply custom scale factor in here:
|
||||
mouse.position.x /= canvas.scaling;
|
||||
mouse.position.y /= canvas.scaling;
|
||||
mouse.left_button_press = p.Properties().IsLeftButtonPressed();
|
||||
mouse.middle_button_press = p.Properties().IsMiddleButtonPressed();
|
||||
mouse.right_button_press = p.Properties().IsRightButtonPressed();
|
||||
mouse.pressure = p.Properties().Pressure();
|
||||
}
|
||||
|
||||
Touch touch;
|
||||
touch.state = Touch::TOUCHSTATE_PRESSED;
|
||||
touch.pos = XMFLOAT2(p.Position().X, p.Position().Y);
|
||||
touches.push_back(touch);
|
||||
});
|
||||
window.PointerReleased([](CoreWindow, PointerEventArgs args) {
|
||||
auto p = args.CurrentPoint();
|
||||
|
||||
if (p.Properties().IsPrimary())
|
||||
{
|
||||
mouse.left_button_press = p.Properties().IsLeftButtonPressed();
|
||||
mouse.middle_button_press = p.Properties().IsMiddleButtonPressed();
|
||||
mouse.right_button_press = p.Properties().IsRightButtonPressed();
|
||||
mouse.pressure = p.Properties().Pressure();
|
||||
}
|
||||
|
||||
Touch touch;
|
||||
touch.state = Touch::TOUCHSTATE_RELEASED;
|
||||
touch.pos = XMFLOAT2(p.Position().X, p.Position().Y);
|
||||
touches.push_back(touch);
|
||||
});
|
||||
window.PointerMoved([](CoreWindow, PointerEventArgs args) {
|
||||
auto p = args.CurrentPoint();
|
||||
|
||||
if (p.Properties().IsPrimary())
|
||||
{
|
||||
mouse.position = XMFLOAT2(p.Position().X, p.Position().Y);
|
||||
// UWP mouse position already has DPI applied, so only apply custom scale factor in here:
|
||||
mouse.position.x /= canvas.scaling;
|
||||
mouse.position.y /= canvas.scaling;
|
||||
mouse.pressure = p.Properties().Pressure();
|
||||
}
|
||||
|
||||
Touch touch;
|
||||
touch.state = Touch::TOUCHSTATE_MOVED;
|
||||
touch.pos = XMFLOAT2(p.Position().X, p.Position().Y);
|
||||
touches.push_back(touch);
|
||||
});
|
||||
window.PointerWheelChanged([](CoreWindow, PointerEventArgs args) {
|
||||
auto p = args.CurrentPoint();
|
||||
|
||||
if (p.Properties().IsPrimary())
|
||||
{
|
||||
mouse.delta_wheel += (float)p.Properties().MouseWheelDelta() / WHEEL_DELTA;
|
||||
}
|
||||
|
||||
Touch touch;
|
||||
touch.state = Touch::TOUCHSTATE_RELEASED;
|
||||
touch.pos = XMFLOAT2(p.Position().X, p.Position().Y);
|
||||
touches.push_back(touch);
|
||||
});
|
||||
MouseDevice::GetForCurrentView().MouseMoved([](MouseDevice, MouseEventArgs args) {
|
||||
mouse.delta_position.x += float(args.MouseDelta().X);
|
||||
mouse.delta_position.y += float(args.MouseDelta().Y);
|
||||
});
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if (pen_override)
|
||||
{
|
||||
mouse.position = pen.position;
|
||||
@@ -762,10 +666,6 @@ namespace wi::input
|
||||
p.y = (LONG)(props.y * dpiscaling);
|
||||
ClientToScreen(hWnd, &p);
|
||||
SetCursorPos(p.x, p.y);
|
||||
#elif defined(PLATFORM_UWP)
|
||||
auto window = winrt::Windows::UI::Core::CoreWindow::GetForCurrentThread();
|
||||
auto& bounds = window.Bounds();
|
||||
window.PointerPosition(winrt::Windows::Foundation::Point(props.x + bounds.X, props.y + bounds.Y));
|
||||
#elif defined(SDL2)
|
||||
// Keeping with the trend of 'Set Pointer' API on different platforms,
|
||||
// SDL_WarpMouseInWindow is used in the case of SDL2. This unfortunately
|
||||
@@ -788,7 +688,6 @@ namespace wi::input
|
||||
void HidePointer(bool value)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#ifndef PLATFORM_UWP
|
||||
if (value)
|
||||
{
|
||||
while (ShowCursor(false) >= 0) {};
|
||||
@@ -797,18 +696,6 @@ namespace wi::input
|
||||
{
|
||||
while (ShowCursor(true) < 0) {};
|
||||
}
|
||||
#else
|
||||
auto window = winrt::Windows::UI::Core::CoreWindow::GetForCurrentThread();
|
||||
static auto cursor = window.PointerCursor();
|
||||
if (value)
|
||||
{
|
||||
window.PointerCursor(nullptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
window.PointerCursor(cursor);
|
||||
}
|
||||
#endif
|
||||
#elif SDL2
|
||||
SDL_ShowCursor(value ? SDL_DISABLE : SDL_ENABLE);
|
||||
#endif // _WIN32
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
#include "wiPlatform.h"
|
||||
|
||||
#if defined(_WIN32) && defined(PLATFORM_UWP)
|
||||
#include "wiNetwork.h"
|
||||
#include "wiBacklog.h"
|
||||
|
||||
namespace wi::network
|
||||
{
|
||||
bool CreateSocket(Socket* sock)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool Destroy(Socket* sock)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Send(const Socket* sock, const Connection* connection, const void* data, size_t dataSize)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ListenPort(const Socket* sock, uint16_t port)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CanReceive(const Socket* sock, long timeout_microseconds)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Receive(const Socket* sock, Connection* connection, void* data, size_t dataSize)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // _WIN32 && PLATFORM_UWP
|
||||
@@ -13,14 +13,6 @@
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#if WINAPI_FAMILY == WINAPI_FAMILY_APP
|
||||
#define PLATFORM_UWP
|
||||
#define wiLoadLibrary(name) LoadPackagedLibrary(_T(name),0)
|
||||
#define wiGetProcAddress(handle,name) GetProcAddress(handle, name)
|
||||
#include <winrt/Windows.UI.Core.h>
|
||||
#include <winrt/Windows.Graphics.Display.h>
|
||||
#include <winrt/Windows.ApplicationModel.Core.h>
|
||||
#else
|
||||
#if WINAPI_FAMILY == WINAPI_FAMILY_GAMES
|
||||
#define PLATFORM_XBOX
|
||||
#else
|
||||
@@ -28,7 +20,6 @@
|
||||
#endif // WINAPI_FAMILY_GAMES
|
||||
#define wiLoadLibrary(name) LoadLibraryA(name)
|
||||
#define wiGetProcAddress(handle,name) GetProcAddress(handle, name)
|
||||
#endif // WINAPI_FAMILY_APP
|
||||
#elif defined(__SCE__)
|
||||
#define PLATFORM_PS5
|
||||
#else
|
||||
@@ -49,11 +40,7 @@ typedef void* HMODULE;
|
||||
namespace wi::platform
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#ifdef PLATFORM_UWP
|
||||
using window_type = const winrt::Windows::UI::Core::CoreWindow*;
|
||||
#else
|
||||
using window_type = HWND;
|
||||
#endif // PLATFORM_UWP
|
||||
#elif SDL2
|
||||
using window_type = SDL_Window*;
|
||||
#else
|
||||
@@ -63,11 +50,7 @@ namespace wi::platform
|
||||
inline void Exit()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#ifndef PLATFORM_UWP
|
||||
PostQuitMessage(0);
|
||||
#else
|
||||
winrt::Windows::ApplicationModel::Core::CoreApplication::Exit();
|
||||
#endif // PLATFORM_UWP
|
||||
#endif // _WIN32
|
||||
#ifdef SDL2
|
||||
SDL_Event quit_event;
|
||||
@@ -99,13 +82,6 @@ namespace wi::platform
|
||||
dest->height = int(rect.bottom - rect.top);
|
||||
#endif // PLATFORM_WINDOWS_DESKTOP || PLATFORM_XBOX
|
||||
|
||||
#ifdef PLATFORM_UWP
|
||||
dest->dpi = winrt::Windows::Graphics::Display::DisplayInformation::GetForCurrentView().LogicalDpi();
|
||||
float dpiscale = dest->dpi / 96.f;
|
||||
dest->width = uint32_t(window->Bounds().Width * dpiscale);
|
||||
dest->height = uint32_t(window->Bounds().Height * dpiscale);
|
||||
#endif // PLATFORM_UWP
|
||||
|
||||
#ifdef PLATFORM_LINUX
|
||||
int window_width, window_height;
|
||||
SDL_GetWindowSize(window, &window_width, &window_height);
|
||||
|
||||
@@ -281,10 +281,6 @@ namespace wi
|
||||
size_t container_fileoffset
|
||||
)
|
||||
{
|
||||
#ifdef PLATFORM_UWP
|
||||
flags &= ~Flags::STREAMING; // disable streaming on UWP because of crappy file API that can't seek
|
||||
#endif // PLATFORM_UWP
|
||||
|
||||
locker.lock();
|
||||
std::weak_ptr<ResourceInternal>& weak_resource = resources[name];
|
||||
std::shared_ptr<ResourceInternal> resource = weak_resource.lock();
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
#if __has_include("xinput.h")
|
||||
|
||||
#if defined(PLATFORM_WINDOWS_DESKTOP) || defined(PLATFORM_UWP)
|
||||
#if defined(PLATFORM_WINDOWS_DESKTOP)
|
||||
#include <xinput.h>
|
||||
#pragma comment(lib,"xinput.lib")
|
||||
#endif // PLATFORM_WINDOWS_DESKTOP || PLATFORM_UWP
|
||||
#endif // PLATFORM_WINDOWS_DESKTOP
|
||||
|
||||
#ifdef PLATFORM_XBOX
|
||||
#include <XInputOnGameInput.h>
|
||||
|
||||