mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-10-14 02:29:07 +00:00
chore: run devtool in dev mode
This commit is contained in:
2
.gitmodules
vendored
2
.gitmodules
vendored
@@ -21,4 +21,4 @@
|
|||||||
url = https://github.com/lz4/lz4.git
|
url = https://github.com/lz4/lz4.git
|
||||||
[submodule "thirdparty/webview"]
|
[submodule "thirdparty/webview"]
|
||||||
path = thirdparty/webview
|
path = thirdparty/webview
|
||||||
url = https://github.com/webview/webview.git
|
url = https://github.com/Laupetin/webview.git
|
||||||
|
@@ -2,32 +2,48 @@
|
|||||||
#include "webview/webview.h"
|
#include "webview/webview.h"
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
|
|
||||||
#include "Web/ViteAssets.h"
|
|
||||||
#include "Web/Edge/AssetHandlerEdge.h"
|
#include "Web/Edge/AssetHandlerEdge.h"
|
||||||
#include "Web/Gtk/AssetHandlerGtk.h"
|
#include "Web/Gtk/AssetHandlerGtk.h"
|
||||||
|
#include "Web/ViteAssets.h"
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <format>
|
#include <format>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
using namespace std::string_literals;
|
using namespace std::string_literals;
|
||||||
|
|
||||||
#ifdef _WIN32
|
namespace
|
||||||
int WINAPI WinMain(HINSTANCE /*hInst*/, HINSTANCE /*hPrevInst*/, LPSTR /*lpCmdLine*/, int /*nCmdShow*/)
|
|
||||||
{
|
{
|
||||||
#else
|
#ifdef _DEBUG
|
||||||
int main()
|
std::optional<webview::webview> devToolWindow;
|
||||||
{
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
void RunDevToolsWindow(webview::webview& parent)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
auto& newWindow = devToolWindow.emplace(false, nullptr);
|
||||||
|
newWindow.set_title("Devtools");
|
||||||
|
newWindow.set_size(640, 480, WEBVIEW_HINT_NONE);
|
||||||
|
newWindow.set_size(480, 320, WEBVIEW_HINT_MIN);
|
||||||
|
newWindow.navigate(std::format("http://localhost:{}/__devtools__/", VITE_DEV_SERVER_PORT));
|
||||||
|
}
|
||||||
|
catch (const webview::exception& e)
|
||||||
|
{
|
||||||
|
std::cerr << e.what() << '\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int RunMainWindow()
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
long count = 0;
|
|
||||||
webview::webview w(true, nullptr);
|
webview::webview w(true, nullptr);
|
||||||
w.set_title("OpenAssetTools ModMan");
|
w.set_title("OpenAssetTools ModMan");
|
||||||
w.set_size(480, 320, WEBVIEW_HINT_NONE);
|
w.set_size(1280, 640, WEBVIEW_HINT_NONE);
|
||||||
w.set_size(480, 320, WEBVIEW_HINT_MIN);
|
w.set_size(480, 320, WEBVIEW_HINT_MIN);
|
||||||
|
|
||||||
// A binding that counts up or down and immediately returns the new value.
|
// A binding that counts up or down and immediately returns the new value.
|
||||||
@@ -69,6 +85,15 @@ int main()
|
|||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
w.navigate(VITE_DEV_SERVER ? std::format("http://localhost:{}", VITE_DEV_SERVER_PORT) : std::format("{}index.html", urlPrefix));
|
w.navigate(VITE_DEV_SERVER ? std::format("http://localhost:{}", VITE_DEV_SERVER_PORT) : std::format("{}index.html", urlPrefix));
|
||||||
|
|
||||||
|
if (VITE_DEV_SERVER)
|
||||||
|
{
|
||||||
|
w.dispatch(
|
||||||
|
[&w]
|
||||||
|
{
|
||||||
|
RunDevToolsWindow(w);
|
||||||
|
});
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
w.navigate(std::format("{}index.html", urlPrefix));
|
w.navigate(std::format("{}index.html", urlPrefix));
|
||||||
#endif
|
#endif
|
||||||
@@ -82,3 +107,17 @@ int main()
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
int WINAPI WinMain(HINSTANCE /*hInst*/, HINSTANCE /*hPrevInst*/, LPSTR /*lpCmdLine*/, int /*nCmdShow*/)
|
||||||
|
{
|
||||||
|
#else
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const auto result = RunMainWindow();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
2
thirdparty/webview
vendored
2
thirdparty/webview
vendored
Submodule thirdparty/webview updated: 55b438dc11...1dfdba9f2b
Reference in New Issue
Block a user