Skip to content

Commit

Permalink
[Windows] Updated runner files
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolfteam committed Feb 27, 2022
1 parent b862a4b commit 3d896ec
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 135 deletions.
2 changes: 1 addition & 1 deletion .gitignore
@@ -1,5 +1,5 @@
#Secrets
/lib/infrastructure/telemetry/secrets.dart
/lib/infrastructure/secrets.dart
/android/key.properties
*.g.dart
*.freezed.dart
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Expand Up @@ -15,7 +15,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.3.1+48
version: 1.3.2+49

environment:
sdk: '>=2.15.1 <3.0.0'
Expand Down Expand Up @@ -138,7 +138,7 @@ msix_config:
display_name: "Shiori for Genshin: Unofficial"
publisher_display_name: MiraiSoft
identity_name: 52493MiraiSoft.ShioriforGenshinUnofficial
msix_version: 1.3.1.0
msix_version: 1.3.2.0
publisher: CN=58BF90DC-3D34-433E-A12B-4C504DF78641
logo_path: assets\icon\icon.png
languages: en
Expand Down
2 changes: 1 addition & 1 deletion windows/CMakeLists.txt
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.15)
cmake_minimum_required(VERSION 3.14)
project(shiori LANGUAGES CXX)

set(BINARY_NAME "shiori")
Expand Down
2 changes: 1 addition & 1 deletion windows/flutter/CMakeLists.txt
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.15)
cmake_minimum_required(VERSION 3.14)

set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")

Expand Down
3 changes: 1 addition & 2 deletions windows/runner/CMakeLists.txt
@@ -1,10 +1,9 @@
cmake_minimum_required(VERSION 3.15)
cmake_minimum_required(VERSION 3.14)
project(runner LANGUAGES CXX)

add_executable(${BINARY_NAME} WIN32
"flutter_window.cpp"
"main.cpp"
"run_loop.cpp"
"utils.cpp"
"win32_window.cpp"
"${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
Expand Down
6 changes: 3 additions & 3 deletions windows/runner/Runner.rc
Expand Up @@ -63,13 +63,13 @@ IDI_APP_ICON ICON "resources\\app_icon.ico"
#ifdef FLUTTER_BUILD_NUMBER
#define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER
#else
#define VERSION_AS_NUMBER 1,2,6
#define VERSION_AS_NUMBER 1,3,2
#endif

#ifdef FLUTTER_BUILD_NAME
#define VERSION_AS_STRING #FLUTTER_BUILD_NAME
#else
#define VERSION_AS_STRING "1.2.6"
#define VERSION_AS_STRING "1.3.2"
#endif

VS_VERSION_INFO VERSIONINFO
Expand All @@ -90,7 +90,7 @@ BEGIN
BLOCK "040904e4"
BEGIN
VALUE "CompanyName", "com.miraisoft" "\0"
VALUE "FileDescription", "A new Flutter project." "\0"
VALUE "FileDescription", "Shiori for Genshin: Unofficial" "\0"
VALUE "FileVersion", VERSION_AS_STRING "\0"
VALUE "InternalName", "shiori" "\0"
VALUE "LegalCopyright", "Copyright (C) 2021 com.miraisoft. All rights reserved." "\0"
Expand Down
9 changes: 3 additions & 6 deletions windows/runner/flutter_window.cpp
Expand Up @@ -4,9 +4,8 @@

#include "flutter/generated_plugin_registrant.h"

FlutterWindow::FlutterWindow(RunLoop* run_loop,
const flutter::DartProject& project)
: run_loop_(run_loop), project_(project) {}
FlutterWindow::FlutterWindow(const flutter::DartProject& project)
: project_(project) {}

FlutterWindow::~FlutterWindow() {}

Expand All @@ -26,14 +25,12 @@ bool FlutterWindow::OnCreate() {
return false;
}
RegisterPlugins(flutter_controller_->engine());
run_loop_->RegisterFlutterInstance(flutter_controller_->engine());
SetChildContent(flutter_controller_->view()->GetNativeWindow());
return true;
}

void FlutterWindow::OnDestroy() {
if (flutter_controller_) {
run_loop_->UnregisterFlutterInstance(flutter_controller_->engine());
flutter_controller_ = nullptr;
}

Expand All @@ -44,7 +41,7 @@ LRESULT
FlutterWindow::MessageHandler(HWND hwnd, UINT const message,
WPARAM const wparam,
LPARAM const lparam) noexcept {
// Give Flutter, including plugins, an opporutunity to handle window messages.
// Give Flutter, including plugins, an opportunity to handle window messages.
if (flutter_controller_) {
std::optional<LRESULT> result =
flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam,
Expand Down
10 changes: 2 additions & 8 deletions windows/runner/flutter_window.h
Expand Up @@ -6,16 +6,13 @@

#include <memory>

#include "run_loop.h"
#include "win32_window.h"

// A window that does nothing but host a Flutter view.
class FlutterWindow : public Win32Window {
public:
// Creates a new FlutterWindow driven by the |run_loop|, hosting a
// Flutter view running |project|.
explicit FlutterWindow(RunLoop* run_loop,
const flutter::DartProject& project);
// Creates a new FlutterWindow hosting a Flutter view running |project|.
explicit FlutterWindow(const flutter::DartProject& project);
virtual ~FlutterWindow();

protected:
Expand All @@ -26,9 +23,6 @@ class FlutterWindow : public Win32Window {
LPARAM const lparam) noexcept override;

private:
// The run loop driving events for this window.
RunLoop* run_loop_;

// The project to run.
flutter::DartProject project_;

Expand Down
11 changes: 6 additions & 5 deletions windows/runner/main.cpp
Expand Up @@ -3,7 +3,6 @@
#include <windows.h>

#include "flutter_window.h"
#include "run_loop.h"
#include "utils.h"

int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
Expand All @@ -18,24 +17,26 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
// plugins.
::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);

RunLoop run_loop;

flutter::DartProject project(L"data");

std::vector<std::string> command_line_arguments =
GetCommandLineArguments();

project.set_dart_entrypoint_arguments(std::move(command_line_arguments));

FlutterWindow window(&run_loop, project);
FlutterWindow window(project);
Win32Window::Point origin(10, 10);
Win32Window::Size size(1280, 720);
if (!window.CreateAndShow(L"Shiori", origin, size)) {
return EXIT_FAILURE;
}
window.SetQuitOnClose(true);

run_loop.Run();
::MSG msg;
while (::GetMessage(&msg, nullptr, 0, 0)) {
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}

::CoUninitialize();
return EXIT_SUCCESS;
Expand Down
66 changes: 0 additions & 66 deletions windows/runner/run_loop.cpp

This file was deleted.

40 changes: 0 additions & 40 deletions windows/runner/run_loop.h

This file was deleted.

0 comments on commit 3d896ec

Please sign in to comment.