diff --git a/.metadata b/.metadata index cbf1dc0..bd14d1f 100644 --- a/.metadata +++ b/.metadata @@ -4,7 +4,7 @@ # This file should be version controlled and should not be manually edited. version: - revision: "a14f74ff3a1cbd521163c5f03d68113d50af93d3" + revision: "5874a72aa4c779a02553007c47dacbefba2374dc" channel: "stable" project_type: app @@ -13,26 +13,11 @@ project_type: app migration: platforms: - platform: root - create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 - base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 - - platform: android - create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 - base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 - - platform: ios - create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 - base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 - - platform: linux - create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 - base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 - - platform: macos - create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 - base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 + create_revision: 5874a72aa4c779a02553007c47dacbefba2374dc + base_revision: 5874a72aa4c779a02553007c47dacbefba2374dc - platform: web - create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 - base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 - - platform: windows - create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 - base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 + create_revision: 5874a72aa4c779a02553007c47dacbefba2374dc + base_revision: 5874a72aa4c779a02553007c47dacbefba2374dc # User provided section diff --git a/assets/backgrounds/SC_01_Wallpaper_3840x2160.webp b/assets/backgrounds/SC_01_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..5e315b3 Binary files /dev/null and b/assets/backgrounds/SC_01_Wallpaper_3840x2160.webp differ diff --git a/assets/backgrounds/SC_02_Wallpaper_3840x2160.webp b/assets/backgrounds/SC_02_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..77150ab Binary files /dev/null and b/assets/backgrounds/SC_02_Wallpaper_3840x2160.webp differ diff --git a/assets/backgrounds/SC_03_Wallpaper_3840x2160.webp b/assets/backgrounds/SC_03_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..43267f7 Binary files /dev/null and b/assets/backgrounds/SC_03_Wallpaper_3840x2160.webp differ diff --git a/assets/backgrounds/SC_04_Wallpaper_3840x2160.webp b/assets/backgrounds/SC_04_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..8d0b3b0 Binary files /dev/null and b/assets/backgrounds/SC_04_Wallpaper_3840x2160.webp differ diff --git a/assets/backgrounds/SC_05_Wallpaper_3840x2160.webp b/assets/backgrounds/SC_05_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..a5d753f Binary files /dev/null and b/assets/backgrounds/SC_05_Wallpaper_3840x2160.webp differ diff --git a/assets/backgrounds/SC_06_Wallpaper_3840x2160.webp b/assets/backgrounds/SC_06_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..7803a62 Binary files /dev/null and b/assets/backgrounds/SC_06_Wallpaper_3840x2160.webp differ diff --git a/assets/backgrounds/SC_07_Wallpaper_3840x2160.webp b/assets/backgrounds/SC_07_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..eb50423 Binary files /dev/null and b/assets/backgrounds/SC_07_Wallpaper_3840x2160.webp differ diff --git a/assets/backgrounds/SC_08_Wallpaper_3840x2160.webp b/assets/backgrounds/SC_08_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..f6a1514 Binary files /dev/null and b/assets/backgrounds/SC_08_Wallpaper_3840x2160.webp differ diff --git a/assets/backgrounds/SC_09_Wallpaper_3840x2160.webp b/assets/backgrounds/SC_09_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..22f273c Binary files /dev/null and b/assets/backgrounds/SC_09_Wallpaper_3840x2160.webp differ diff --git a/assets/backgrounds/SC_10_Wallpaper_3840x2160.webp b/assets/backgrounds/SC_10_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..cad3c1b Binary files /dev/null and b/assets/backgrounds/SC_10_Wallpaper_3840x2160.webp differ diff --git a/assets/backgrounds/SC_11_Wallpaper_3840x2160.webp b/assets/backgrounds/SC_11_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..569bfc4 Binary files /dev/null and b/assets/backgrounds/SC_11_Wallpaper_3840x2160.webp differ diff --git a/assets/backgrounds/SC_12_Wallpaper_3840x2160.webp b/assets/backgrounds/SC_12_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..fa8b598 Binary files /dev/null and b/assets/backgrounds/SC_12_Wallpaper_3840x2160.webp differ diff --git a/assets/backgrounds/SC_13_Wallpaper_3840x2160.webp b/assets/backgrounds/SC_13_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..0c0b7b4 Binary files /dev/null and b/assets/backgrounds/SC_13_Wallpaper_3840x2160.webp differ diff --git a/assets/backgrounds/SC_14_Wallpaper_3840x2160.webp b/assets/backgrounds/SC_14_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..72da7b3 Binary files /dev/null and b/assets/backgrounds/SC_14_Wallpaper_3840x2160.webp differ diff --git a/assets/backgrounds/SC_15_Wallpaper_3840x2160.webp b/assets/backgrounds/SC_15_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..2915b70 Binary files /dev/null and b/assets/backgrounds/SC_15_Wallpaper_3840x2160.webp differ diff --git a/assets/backgrounds/SC_16_Wallpaper_3840x2160.webp b/assets/backgrounds/SC_16_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..c6eb567 Binary files /dev/null and b/assets/backgrounds/SC_16_Wallpaper_3840x2160.webp differ diff --git a/assets/backgrounds/SC_17_Wallpaper_3840x2160.webp b/assets/backgrounds/SC_17_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..40da70b Binary files /dev/null and b/assets/backgrounds/SC_17_Wallpaper_3840x2160.webp differ diff --git a/assets/backgrounds/SC_18_Wallpaper_3840x2160.webp b/assets/backgrounds/SC_18_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..a6203a0 Binary files /dev/null and b/assets/backgrounds/SC_18_Wallpaper_3840x2160.webp differ diff --git a/assets/backgrounds/SC_19_Wallpaper_3840x2160.webp b/assets/backgrounds/SC_19_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..cd884bd Binary files /dev/null and b/assets/backgrounds/SC_19_Wallpaper_3840x2160.webp differ diff --git a/assets/backgrounds/SC_20_Wallpaper_3840x2160.webp b/assets/backgrounds/SC_20_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..0653552 Binary files /dev/null and b/assets/backgrounds/SC_20_Wallpaper_3840x2160.webp differ diff --git a/assets/backgrounds/SC_21_Wallpaper_3840x2160.webp b/assets/backgrounds/SC_21_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..7a1f23f Binary files /dev/null and b/assets/backgrounds/SC_21_Wallpaper_3840x2160.webp differ diff --git a/assets/backgrounds/SC_22_Wallpaper_3840x2160.webp b/assets/backgrounds/SC_22_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..12b8a46 Binary files /dev/null and b/assets/backgrounds/SC_22_Wallpaper_3840x2160.webp differ diff --git a/assets/backgrounds/SC_23_Wallpaper_3840x2160.webp b/assets/backgrounds/SC_23_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..b789fd2 Binary files /dev/null and b/assets/backgrounds/SC_23_Wallpaper_3840x2160.webp differ diff --git a/assets/backgrounds/SC_24_Wallpaper_3840x2160.webp b/assets/backgrounds/SC_24_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..c91ba0e Binary files /dev/null and b/assets/backgrounds/SC_24_Wallpaper_3840x2160.webp differ diff --git a/assets/backgrounds/SC_25_Wallpaper_3840x2160.webp b/assets/backgrounds/SC_25_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..c67e601 Binary files /dev/null and b/assets/backgrounds/SC_25_Wallpaper_3840x2160.webp differ diff --git a/assets/backgrounds/SC_26_Wallpaper_3840x2160.webp b/assets/backgrounds/SC_26_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..d5e1ac9 Binary files /dev/null and b/assets/backgrounds/SC_26_Wallpaper_3840x2160.webp differ diff --git a/assets/backgrounds/SC_27_Wallpaper_3840x2160.webp b/assets/backgrounds/SC_27_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..ddf1963 Binary files /dev/null and b/assets/backgrounds/SC_27_Wallpaper_3840x2160.webp differ diff --git a/assets/backgrounds/SC_28_Wallpaper_3840x2160.webp b/assets/backgrounds/SC_28_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..a1b1adc Binary files /dev/null and b/assets/backgrounds/SC_28_Wallpaper_3840x2160.webp differ diff --git a/assets/backgrounds/SC_29_Wallpaper_3840x2160.webp b/assets/backgrounds/SC_29_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..085a5be Binary files /dev/null and b/assets/backgrounds/SC_29_Wallpaper_3840x2160.webp differ diff --git a/assets/backgrounds/SC_30_Wallpaper_3840x2160.webp b/assets/backgrounds/SC_30_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..777bbf3 Binary files /dev/null and b/assets/backgrounds/SC_30_Wallpaper_3840x2160.webp differ diff --git a/assets/backgrounds/SC_31_Wallpaper_3840x2160.webp b/assets/backgrounds/SC_31_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..4957f30 Binary files /dev/null and b/assets/backgrounds/SC_31_Wallpaper_3840x2160.webp differ diff --git a/assets/backgrounds/SC_32_Wallpaper_3840x2160.webp b/assets/backgrounds/SC_32_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..5166c1c Binary files /dev/null and b/assets/backgrounds/SC_32_Wallpaper_3840x2160.webp differ diff --git a/assets/backgrounds/SC_33_Wallpaper_3840x2160.webp b/assets/backgrounds/SC_33_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..1b4c49b Binary files /dev/null and b/assets/backgrounds/SC_33_Wallpaper_3840x2160.webp differ diff --git a/assets/backgrounds/SC_34_Wallpaper_3840x2160.webp b/assets/backgrounds/SC_34_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..e17e760 Binary files /dev/null and b/assets/backgrounds/SC_34_Wallpaper_3840x2160.webp differ diff --git a/assets/backgrounds/SC_35_Wallpaper_3840x2160.webp b/assets/backgrounds/SC_35_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..b3f583e Binary files /dev/null and b/assets/backgrounds/SC_35_Wallpaper_3840x2160.webp differ diff --git a/assets/backgrounds/SC_36_Wallpaper_3840x2160.webp b/assets/backgrounds/SC_36_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..38dc682 Binary files /dev/null and b/assets/backgrounds/SC_36_Wallpaper_3840x2160.webp differ diff --git a/assets/backgrounds/SC_37_Wallpaper_3840x2160.webp b/assets/backgrounds/SC_37_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..ef83ced Binary files /dev/null and b/assets/backgrounds/SC_37_Wallpaper_3840x2160.webp differ diff --git a/assets/backgrounds/SC_38_Wallpaper_3840x2160.webp b/assets/backgrounds/SC_38_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..d9e39c2 Binary files /dev/null and b/assets/backgrounds/SC_38_Wallpaper_3840x2160.webp differ diff --git a/assets/backup/SC_01_Wallpaper_3840x2160.jpg b/assets/backup/SC_01_Wallpaper_3840x2160.jpg new file mode 100644 index 0000000..1328859 Binary files /dev/null and b/assets/backup/SC_01_Wallpaper_3840x2160.jpg differ diff --git a/assets/backup/SC_02_Wallpaper_3840x2160.jpg b/assets/backup/SC_02_Wallpaper_3840x2160.jpg new file mode 100644 index 0000000..463e7bf Binary files /dev/null and b/assets/backup/SC_02_Wallpaper_3840x2160.jpg differ diff --git a/assets/backup/SC_03_Wallpaper_3840x2160.jpg b/assets/backup/SC_03_Wallpaper_3840x2160.jpg new file mode 100644 index 0000000..8e0d776 Binary files /dev/null and b/assets/backup/SC_03_Wallpaper_3840x2160.jpg differ diff --git a/assets/backup/SC_04_Wallpaper_3840x2160.jpg b/assets/backup/SC_04_Wallpaper_3840x2160.jpg new file mode 100644 index 0000000..ea65e76 Binary files /dev/null and b/assets/backup/SC_04_Wallpaper_3840x2160.jpg differ diff --git a/assets/backup/SC_05_Wallpaper_3840x2160.jpg b/assets/backup/SC_05_Wallpaper_3840x2160.jpg new file mode 100644 index 0000000..d18879f Binary files /dev/null and b/assets/backup/SC_05_Wallpaper_3840x2160.jpg differ diff --git a/assets/backup/SC_06_Wallpaper_3840x2160.jpg b/assets/backup/SC_06_Wallpaper_3840x2160.jpg new file mode 100644 index 0000000..ef3e3e7 Binary files /dev/null and b/assets/backup/SC_06_Wallpaper_3840x2160.jpg differ diff --git a/assets/backup/SC_07_Wallpaper_3840x2160.jpg b/assets/backup/SC_07_Wallpaper_3840x2160.jpg new file mode 100644 index 0000000..ad8d78e Binary files /dev/null and b/assets/backup/SC_07_Wallpaper_3840x2160.jpg differ diff --git a/assets/backup/SC_08_Wallpaper_3840x2160.jpg b/assets/backup/SC_08_Wallpaper_3840x2160.jpg new file mode 100644 index 0000000..ba28ee3 Binary files /dev/null and b/assets/backup/SC_08_Wallpaper_3840x2160.jpg differ diff --git a/assets/backup/SC_09_Wallpaper_3840x2160.jpg b/assets/backup/SC_09_Wallpaper_3840x2160.jpg new file mode 100644 index 0000000..5061c64 Binary files /dev/null and b/assets/backup/SC_09_Wallpaper_3840x2160.jpg differ diff --git a/assets/backup/SC_10_Wallpaper_3840x2160.jpg b/assets/backup/SC_10_Wallpaper_3840x2160.jpg new file mode 100644 index 0000000..5b8a23f Binary files /dev/null and b/assets/backup/SC_10_Wallpaper_3840x2160.jpg differ diff --git a/assets/backup/SC_11_Wallpaper_3840x2160.jpg b/assets/backup/SC_11_Wallpaper_3840x2160.jpg new file mode 100644 index 0000000..2c0aa24 Binary files /dev/null and b/assets/backup/SC_11_Wallpaper_3840x2160.jpg differ diff --git a/assets/backup/SC_12_Wallpaper_3840x2160.jpg b/assets/backup/SC_12_Wallpaper_3840x2160.jpg new file mode 100644 index 0000000..dda31a3 Binary files /dev/null and b/assets/backup/SC_12_Wallpaper_3840x2160.jpg differ diff --git a/assets/backup/SC_13_Wallpaper_3840x2160.jpg b/assets/backup/SC_13_Wallpaper_3840x2160.jpg new file mode 100644 index 0000000..2e3b6ac Binary files /dev/null and b/assets/backup/SC_13_Wallpaper_3840x2160.jpg differ diff --git a/assets/backup/SC_14_Wallpaper_3840x2160.jpg b/assets/backup/SC_14_Wallpaper_3840x2160.jpg new file mode 100644 index 0000000..3f0165b Binary files /dev/null and b/assets/backup/SC_14_Wallpaper_3840x2160.jpg differ diff --git a/assets/backup/SC_15_Wallpaper_3840x2160.jpg b/assets/backup/SC_15_Wallpaper_3840x2160.jpg new file mode 100644 index 0000000..1ffdd18 Binary files /dev/null and b/assets/backup/SC_15_Wallpaper_3840x2160.jpg differ diff --git a/assets/backup/SC_16_Wallpaper_3840x2160.jpg b/assets/backup/SC_16_Wallpaper_3840x2160.jpg new file mode 100644 index 0000000..641584a Binary files /dev/null and b/assets/backup/SC_16_Wallpaper_3840x2160.jpg differ diff --git a/assets/backup/SC_17_Wallpaper_3840x2160.jpg b/assets/backup/SC_17_Wallpaper_3840x2160.jpg new file mode 100644 index 0000000..118f914 Binary files /dev/null and b/assets/backup/SC_17_Wallpaper_3840x2160.jpg differ diff --git a/assets/backup/SC_18_Wallpaper_3840x2160.jpg b/assets/backup/SC_18_Wallpaper_3840x2160.jpg new file mode 100644 index 0000000..9847c36 Binary files /dev/null and b/assets/backup/SC_18_Wallpaper_3840x2160.jpg differ diff --git a/assets/backup/SC_19_Wallpaper_3840x2160.jpg b/assets/backup/SC_19_Wallpaper_3840x2160.jpg new file mode 100644 index 0000000..5edfa03 Binary files /dev/null and b/assets/backup/SC_19_Wallpaper_3840x2160.jpg differ diff --git a/assets/backup/SC_20_Wallpaper_3840x2160.jpg b/assets/backup/SC_20_Wallpaper_3840x2160.jpg new file mode 100644 index 0000000..59759aa Binary files /dev/null and b/assets/backup/SC_20_Wallpaper_3840x2160.jpg differ diff --git a/assets/backup/SC_21_Wallpaper_3840x2160.jpg b/assets/backup/SC_21_Wallpaper_3840x2160.jpg new file mode 100644 index 0000000..f5b116b Binary files /dev/null and b/assets/backup/SC_21_Wallpaper_3840x2160.jpg differ diff --git a/assets/backup/SC_22_Wallpaper_3840x2160.jpg b/assets/backup/SC_22_Wallpaper_3840x2160.jpg new file mode 100644 index 0000000..4dbcb0e Binary files /dev/null and b/assets/backup/SC_22_Wallpaper_3840x2160.jpg differ diff --git a/assets/backup/SC_23_Wallpaper_3840x2160.jpg b/assets/backup/SC_23_Wallpaper_3840x2160.jpg new file mode 100644 index 0000000..edca435 Binary files /dev/null and b/assets/backup/SC_23_Wallpaper_3840x2160.jpg differ diff --git a/assets/backup/SC_24_Wallpaper_3840x2160.jpg b/assets/backup/SC_24_Wallpaper_3840x2160.jpg new file mode 100644 index 0000000..b915f66 Binary files /dev/null and b/assets/backup/SC_24_Wallpaper_3840x2160.jpg differ diff --git a/assets/backup/SC_25_Wallpaper_3840x2160.jpg b/assets/backup/SC_25_Wallpaper_3840x2160.jpg new file mode 100644 index 0000000..0dc32a1 Binary files /dev/null and b/assets/backup/SC_25_Wallpaper_3840x2160.jpg differ diff --git a/assets/backup/SC_26_Wallpaper_3840x2160.jpg b/assets/backup/SC_26_Wallpaper_3840x2160.jpg new file mode 100644 index 0000000..237422c Binary files /dev/null and b/assets/backup/SC_26_Wallpaper_3840x2160.jpg differ diff --git a/assets/backup/SC_27_Wallpaper_3840x2160.jpg b/assets/backup/SC_27_Wallpaper_3840x2160.jpg new file mode 100644 index 0000000..3bf6c55 Binary files /dev/null and b/assets/backup/SC_27_Wallpaper_3840x2160.jpg differ diff --git a/assets/backup/SC_28_Wallpaper_3840x2160.jpg b/assets/backup/SC_28_Wallpaper_3840x2160.jpg new file mode 100644 index 0000000..37b1c43 Binary files /dev/null and b/assets/backup/SC_28_Wallpaper_3840x2160.jpg differ diff --git a/assets/backup/SC_29_Wallpaper_3840x2160.jpg b/assets/backup/SC_29_Wallpaper_3840x2160.jpg new file mode 100644 index 0000000..3e66fa6 Binary files /dev/null and b/assets/backup/SC_29_Wallpaper_3840x2160.jpg differ diff --git a/assets/backup/SC_30_Wallpaper_3840x2160.jpg b/assets/backup/SC_30_Wallpaper_3840x2160.jpg new file mode 100644 index 0000000..f1a74b0 Binary files /dev/null and b/assets/backup/SC_30_Wallpaper_3840x2160.jpg differ diff --git a/assets/backup/SC_31_Wallpaper_3840x2160.jpg b/assets/backup/SC_31_Wallpaper_3840x2160.jpg new file mode 100644 index 0000000..1e58d17 Binary files /dev/null and b/assets/backup/SC_31_Wallpaper_3840x2160.jpg differ diff --git a/assets/backup/SC_32_Wallpaper_3840x2160.jpg b/assets/backup/SC_32_Wallpaper_3840x2160.jpg new file mode 100644 index 0000000..b68dd9f Binary files /dev/null and b/assets/backup/SC_32_Wallpaper_3840x2160.jpg differ diff --git a/assets/backup/SC_33_Wallpaper_3840x2160.jpg b/assets/backup/SC_33_Wallpaper_3840x2160.jpg new file mode 100644 index 0000000..c45d450 Binary files /dev/null and b/assets/backup/SC_33_Wallpaper_3840x2160.jpg differ diff --git a/assets/backup/SC_34_Wallpaper_3840x2160.jpg b/assets/backup/SC_34_Wallpaper_3840x2160.jpg new file mode 100644 index 0000000..34716aa Binary files /dev/null and b/assets/backup/SC_34_Wallpaper_3840x2160.jpg differ diff --git a/assets/backup/SC_35_Wallpaper_3840x2160.jpg b/assets/backup/SC_35_Wallpaper_3840x2160.jpg new file mode 100644 index 0000000..e2dae77 Binary files /dev/null and b/assets/backup/SC_35_Wallpaper_3840x2160.jpg differ diff --git a/assets/backup/SC_36_Wallpaper_3840x2160.jpg b/assets/backup/SC_36_Wallpaper_3840x2160.jpg new file mode 100644 index 0000000..8be5402 Binary files /dev/null and b/assets/backup/SC_36_Wallpaper_3840x2160.jpg differ diff --git a/assets/backup/SC_37_Wallpaper_3840x2160.jpg b/assets/backup/SC_37_Wallpaper_3840x2160.jpg new file mode 100644 index 0000000..fe3ace2 Binary files /dev/null and b/assets/backup/SC_37_Wallpaper_3840x2160.jpg differ diff --git a/assets/backup/SC_38_Wallpaper_3840x2160.jpg b/assets/backup/SC_38_Wallpaper_3840x2160.jpg new file mode 100644 index 0000000..8b485e2 Binary files /dev/null and b/assets/backup/SC_38_Wallpaper_3840x2160.jpg differ diff --git a/assets/backup/webp/SC_01_Wallpaper_3840x2160.webp b/assets/backup/webp/SC_01_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..5e315b3 Binary files /dev/null and b/assets/backup/webp/SC_01_Wallpaper_3840x2160.webp differ diff --git a/assets/backup/webp/SC_02_Wallpaper_3840x2160.webp b/assets/backup/webp/SC_02_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..77150ab Binary files /dev/null and b/assets/backup/webp/SC_02_Wallpaper_3840x2160.webp differ diff --git a/assets/backup/webp/SC_03_Wallpaper_3840x2160.webp b/assets/backup/webp/SC_03_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..43267f7 Binary files /dev/null and b/assets/backup/webp/SC_03_Wallpaper_3840x2160.webp differ diff --git a/assets/backup/webp/SC_04_Wallpaper_3840x2160.webp b/assets/backup/webp/SC_04_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..8d0b3b0 Binary files /dev/null and b/assets/backup/webp/SC_04_Wallpaper_3840x2160.webp differ diff --git a/assets/backup/webp/SC_05_Wallpaper_3840x2160.webp b/assets/backup/webp/SC_05_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..a5d753f Binary files /dev/null and b/assets/backup/webp/SC_05_Wallpaper_3840x2160.webp differ diff --git a/assets/backup/webp/SC_06_Wallpaper_3840x2160.webp b/assets/backup/webp/SC_06_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..7803a62 Binary files /dev/null and b/assets/backup/webp/SC_06_Wallpaper_3840x2160.webp differ diff --git a/assets/backup/webp/SC_07_Wallpaper_3840x2160.webp b/assets/backup/webp/SC_07_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..eb50423 Binary files /dev/null and b/assets/backup/webp/SC_07_Wallpaper_3840x2160.webp differ diff --git a/assets/backup/webp/SC_08_Wallpaper_3840x2160.webp b/assets/backup/webp/SC_08_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..f6a1514 Binary files /dev/null and b/assets/backup/webp/SC_08_Wallpaper_3840x2160.webp differ diff --git a/assets/backup/webp/SC_09_Wallpaper_3840x2160.webp b/assets/backup/webp/SC_09_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..22f273c Binary files /dev/null and b/assets/backup/webp/SC_09_Wallpaper_3840x2160.webp differ diff --git a/assets/backup/webp/SC_10_Wallpaper_3840x2160.webp b/assets/backup/webp/SC_10_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..cad3c1b Binary files /dev/null and b/assets/backup/webp/SC_10_Wallpaper_3840x2160.webp differ diff --git a/assets/backup/webp/SC_11_Wallpaper_3840x2160.webp b/assets/backup/webp/SC_11_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..569bfc4 Binary files /dev/null and b/assets/backup/webp/SC_11_Wallpaper_3840x2160.webp differ diff --git a/assets/backup/webp/SC_12_Wallpaper_3840x2160.webp b/assets/backup/webp/SC_12_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..fa8b598 Binary files /dev/null and b/assets/backup/webp/SC_12_Wallpaper_3840x2160.webp differ diff --git a/assets/backup/webp/SC_13_Wallpaper_3840x2160.webp b/assets/backup/webp/SC_13_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..0c0b7b4 Binary files /dev/null and b/assets/backup/webp/SC_13_Wallpaper_3840x2160.webp differ diff --git a/assets/backup/webp/SC_14_Wallpaper_3840x2160.webp b/assets/backup/webp/SC_14_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..72da7b3 Binary files /dev/null and b/assets/backup/webp/SC_14_Wallpaper_3840x2160.webp differ diff --git a/assets/backup/webp/SC_15_Wallpaper_3840x2160.webp b/assets/backup/webp/SC_15_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..2915b70 Binary files /dev/null and b/assets/backup/webp/SC_15_Wallpaper_3840x2160.webp differ diff --git a/assets/backup/webp/SC_16_Wallpaper_3840x2160.webp b/assets/backup/webp/SC_16_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..c6eb567 Binary files /dev/null and b/assets/backup/webp/SC_16_Wallpaper_3840x2160.webp differ diff --git a/assets/backup/webp/SC_17_Wallpaper_3840x2160.webp b/assets/backup/webp/SC_17_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..40da70b Binary files /dev/null and b/assets/backup/webp/SC_17_Wallpaper_3840x2160.webp differ diff --git a/assets/backup/webp/SC_18_Wallpaper_3840x2160.webp b/assets/backup/webp/SC_18_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..a6203a0 Binary files /dev/null and b/assets/backup/webp/SC_18_Wallpaper_3840x2160.webp differ diff --git a/assets/backup/webp/SC_19_Wallpaper_3840x2160.webp b/assets/backup/webp/SC_19_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..cd884bd Binary files /dev/null and b/assets/backup/webp/SC_19_Wallpaper_3840x2160.webp differ diff --git a/assets/backup/webp/SC_20_Wallpaper_3840x2160.webp b/assets/backup/webp/SC_20_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..0653552 Binary files /dev/null and b/assets/backup/webp/SC_20_Wallpaper_3840x2160.webp differ diff --git a/assets/backup/webp/SC_21_Wallpaper_3840x2160.webp b/assets/backup/webp/SC_21_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..7a1f23f Binary files /dev/null and b/assets/backup/webp/SC_21_Wallpaper_3840x2160.webp differ diff --git a/assets/backup/webp/SC_22_Wallpaper_3840x2160.webp b/assets/backup/webp/SC_22_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..12b8a46 Binary files /dev/null and b/assets/backup/webp/SC_22_Wallpaper_3840x2160.webp differ diff --git a/assets/backup/webp/SC_23_Wallpaper_3840x2160.webp b/assets/backup/webp/SC_23_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..b789fd2 Binary files /dev/null and b/assets/backup/webp/SC_23_Wallpaper_3840x2160.webp differ diff --git a/assets/backup/webp/SC_24_Wallpaper_3840x2160.webp b/assets/backup/webp/SC_24_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..c91ba0e Binary files /dev/null and b/assets/backup/webp/SC_24_Wallpaper_3840x2160.webp differ diff --git a/assets/backup/webp/SC_25_Wallpaper_3840x2160.webp b/assets/backup/webp/SC_25_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..c67e601 Binary files /dev/null and b/assets/backup/webp/SC_25_Wallpaper_3840x2160.webp differ diff --git a/assets/backup/webp/SC_26_Wallpaper_3840x2160.webp b/assets/backup/webp/SC_26_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..d5e1ac9 Binary files /dev/null and b/assets/backup/webp/SC_26_Wallpaper_3840x2160.webp differ diff --git a/assets/backup/webp/SC_27_Wallpaper_3840x2160.webp b/assets/backup/webp/SC_27_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..ddf1963 Binary files /dev/null and b/assets/backup/webp/SC_27_Wallpaper_3840x2160.webp differ diff --git a/assets/backup/webp/SC_28_Wallpaper_3840x2160.webp b/assets/backup/webp/SC_28_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..a1b1adc Binary files /dev/null and b/assets/backup/webp/SC_28_Wallpaper_3840x2160.webp differ diff --git a/assets/backup/webp/SC_29_Wallpaper_3840x2160.webp b/assets/backup/webp/SC_29_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..085a5be Binary files /dev/null and b/assets/backup/webp/SC_29_Wallpaper_3840x2160.webp differ diff --git a/assets/backup/webp/SC_30_Wallpaper_3840x2160.webp b/assets/backup/webp/SC_30_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..777bbf3 Binary files /dev/null and b/assets/backup/webp/SC_30_Wallpaper_3840x2160.webp differ diff --git a/assets/backup/webp/SC_31_Wallpaper_3840x2160.webp b/assets/backup/webp/SC_31_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..4957f30 Binary files /dev/null and b/assets/backup/webp/SC_31_Wallpaper_3840x2160.webp differ diff --git a/assets/backup/webp/SC_32_Wallpaper_3840x2160.webp b/assets/backup/webp/SC_32_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..5166c1c Binary files /dev/null and b/assets/backup/webp/SC_32_Wallpaper_3840x2160.webp differ diff --git a/assets/backup/webp/SC_33_Wallpaper_3840x2160.webp b/assets/backup/webp/SC_33_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..1b4c49b Binary files /dev/null and b/assets/backup/webp/SC_33_Wallpaper_3840x2160.webp differ diff --git a/assets/backup/webp/SC_34_Wallpaper_3840x2160.webp b/assets/backup/webp/SC_34_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..e17e760 Binary files /dev/null and b/assets/backup/webp/SC_34_Wallpaper_3840x2160.webp differ diff --git a/assets/backup/webp/SC_35_Wallpaper_3840x2160.webp b/assets/backup/webp/SC_35_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..b3f583e Binary files /dev/null and b/assets/backup/webp/SC_35_Wallpaper_3840x2160.webp differ diff --git a/assets/backup/webp/SC_36_Wallpaper_3840x2160.webp b/assets/backup/webp/SC_36_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..38dc682 Binary files /dev/null and b/assets/backup/webp/SC_36_Wallpaper_3840x2160.webp differ diff --git a/assets/backup/webp/SC_37_Wallpaper_3840x2160.webp b/assets/backup/webp/SC_37_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..ef83ced Binary files /dev/null and b/assets/backup/webp/SC_37_Wallpaper_3840x2160.webp differ diff --git a/assets/backup/webp/SC_38_Wallpaper_3840x2160.webp b/assets/backup/webp/SC_38_Wallpaper_3840x2160.webp new file mode 100644 index 0000000..d9e39c2 Binary files /dev/null and b/assets/backup/webp/SC_38_Wallpaper_3840x2160.webp differ diff --git a/assets/binary/aria2c.zip b/assets/binary/aria2c.zip deleted file mode 100644 index f7ab6e9..0000000 Binary files a/assets/binary/aria2c.zip and /dev/null differ diff --git a/assets/binary/unp4kc.zip b/assets/binary/unp4kc.zip deleted file mode 100644 index 4069956..0000000 Binary files a/assets/binary/unp4kc.zip and /dev/null differ diff --git a/flutter_rust_bridge.yaml b/flutter_rust_bridge.yaml index bf091fc..69a7fb9 100644 --- a/flutter_rust_bridge.yaml +++ b/flutter_rust_bridge.yaml @@ -1,4 +1,4 @@ rust_input: rust/src/api/**/*.rs dart_output: lib/common/rust/ full_dep: true -web: false \ No newline at end of file +web: true \ No newline at end of file diff --git a/lib/app.dart b/lib/app.dart index 03cc72a..30838b9 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -1,37 +1,27 @@ import 'dart:async'; -import 'dart:io'; +import 'dart:math'; import 'package:fluent_ui/fluent_ui.dart'; -import 'package:flutter_acrylic/flutter_acrylic.dart'; +import 'package:flutter/services.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:go_router/go_router.dart'; import 'package:hexcolor/hexcolor.dart'; import 'package:hive/hive.dart'; -import 'package:path_provider/path_provider.dart'; import 'package:riverpod_annotation/riverpod_annotation.dart'; import 'package:starcitizen_doctor/common/conf/const_conf.dart'; import 'package:starcitizen_doctor/common/utils/log.dart'; import 'package:starcitizen_doctor/ui/home/performance/performance_ui.dart'; import 'package:starcitizen_doctor/ui/splash_ui.dart'; -import 'package:device_info_plus/device_info_plus.dart'; import 'package:starcitizen_doctor/widgets/widgets.dart'; import 'package:uuid/uuid.dart'; -import 'package:window_manager/window_manager.dart'; -import 'api/analytics.dart'; import 'api/api.dart'; -import 'common/helper/system_helper.dart'; import 'common/io/rs_http.dart'; import 'common/rust/frb_generated.dart'; -import 'common/rust/api/win32_api.dart' as win32; import 'data/app_version_data.dart'; import 'generated/no_l10n_strings.dart'; -import 'ui/home/downloader/home_downloader_ui.dart'; -import 'ui/home/game_doctor/game_doctor_ui.dart'; import 'ui/home/localization/advanced_localization_ui.dart'; import 'ui/index_ui.dart'; -import 'ui/settings/upgrade_dialog.dart'; -import 'ui/tools/unp4kc/unp4kc_ui.dart'; part 'app.g.dart'; @@ -47,32 +37,26 @@ class AppGlobalState with _$AppGlobalState { @Default(ThemeConf()) ThemeConf themeConf, Locale? appLocale, Box? appConfBox, + @Default("assets/backgrounds/SC_01_Wallpaper_3840x2160.webp") + String backgroundImageAssetsPath, }) = _AppGlobalState; } @riverpod GoRouter router(RouterRef ref) { return GoRouter( + initialLocation: "/splash", routes: [ GoRoute( - path: '/', + path: '/splash', pageBuilder: (context, state) => myPageBuilder(context, state, const SplashUI()), ), GoRoute( - path: '/index', + path: '/', pageBuilder: (context, state) => myPageBuilder(context, state, const IndexUI()), routes: [ - GoRoute( - path: "downloader", - pageBuilder: (context, state) => - myPageBuilder(context, state, const HomeDownloaderUI())), - GoRoute( - path: 'game_doctor', - pageBuilder: (context, state) => - myPageBuilder(context, state, const HomeGameDoctorUI()), - ), GoRoute( path: 'performance', pageBuilder: (context, state) => @@ -84,13 +68,7 @@ GoRouter router(RouterRef ref) { myPageBuilder(context, state, const AdvancedLocalizationUI())) ], ), - GoRoute(path: '/tools', builder: (_, __) => const SizedBox(), routes: [ - GoRoute( - path: 'unp4kc', - pageBuilder: (context, state) => - myPageBuilder(context, state, const UnP4kcUI()), - ), - ]), + GoRoute(path: '/tools', builder: (_, __) => const SizedBox()), ], ); } @@ -115,7 +93,7 @@ class AppGlobalModel extends _$AppGlobalModel { Future initApp() async { if (_initialized) return; // init Data - final applicationSupportDir = await _initAppDir(); + // final applicationSupportDir = await _initAppDir(); // init Rust bridge await RustLib.init(); @@ -124,12 +102,12 @@ class AppGlobalModel extends _$AppGlobalModel { // init Hive try { - Hive.init("$applicationSupportDir/db"); + // Hive.init("$applicationSupportDir/db"); final box = await Hive.openBox("app_conf"); state = state.copyWith(appConfBox: box); if (box.get("install_id", defaultValue: "") == "") { await box.put("install_id", const Uuid().v4()); - AnalyticsApi.touch("firstLaunch"); + // AnalyticsApi.touch("firstLaunch"); } final deviceUUID = box.get("install_id", defaultValue: ""); final localeCode = box.get("app_locale", defaultValue: null); @@ -144,66 +122,50 @@ class AppGlobalModel extends _$AppGlobalModel { } state = state.copyWith(deviceUUID: deviceUUID, appLocale: locale); } catch (e) { - await win32.setForegroundWindow(windowName: "SCToolBox"); + // await win32.setForegroundWindow(windowName: "SCToolBox"); dPrint("exit: db is locking ..."); - exit(0); + // exit(0); } - // init powershell - if (Platform.isWindows) { - try { - await SystemHelper.initPowershellPath(); - dPrint("---- Powershell init -----"); - } catch (e) { - dPrint("powershell init failed : $e"); - } - } - - // get windows info - WindowsDeviceInfo? windowsDeviceInfo; - try { - DeviceInfoPlugin deviceInfo = DeviceInfoPlugin(); - windowsDeviceInfo = await deviceInfo.windowsInfo; - } catch (e) { - dPrint("DeviceInfo.windowsInfo error: $e"); - } - - // init windows - windowManager.waitUntilReadyToShow().then((_) async { - await windowManager.setTitle("SCToolBox"); - await windowManager.setSkipTaskbar(false); - await windowManager.show(); - if (Platform.isWindows) { - await Window.initialize(); - await Window.hideWindowControls(); - if (windowsDeviceInfo?.productName.contains("Windows 11") ?? false) { - await Window.setEffect( - effect: WindowEffect.acrylic, - ); - } - } - }); - dPrint("---- Window init -----"); + _startBackgroundLoop(); _initialized = true; ref.keepAlive(); } + Timer? _loopTimer; + + _startBackgroundLoop() async { + _loopTimer?.cancel(); + _loopTimer = null; + final assetManifest = await AssetManifest.loadFromAssetBundle(rootBundle); + final imageAssetsList = assetManifest + .listAssets() + .where((string) => string.startsWith("assets/backgrounds")) + .toList(); + + void rollImage() { + final random = Random(); + final index = random.nextInt(imageAssetsList.length); + final image = imageAssetsList[index]; + state = state.copyWith(backgroundImageAssetsPath: image); + dPrint("rollImage: [$index] $image"); + } + + rollImage(); + // 使用 timer 每 30 秒 更换一次随机图片 + _loopTimer = Timer.periodic(const Duration(seconds: 30), (timer) { + rollImage(); + }); + } + String getUpgradePath() { return "${state.applicationSupportDir}/._upgrade"; } // ignore: avoid_build_context_in_providers Future checkUpdate(BuildContext context) async { - if (!ConstConf.isMSE) { - final dir = Directory(getUpgradePath()); - if (await dir.exists()) { - dir.delete(recursive: true); - } - } - dynamic checkUpdateError; - try { final networkVersionData = await Api.getAppVersion(); checkActivityThemeColor(networkVersionData); @@ -229,26 +191,6 @@ class AppGlobalModel extends _$AppGlobalModel { ConstConf.appVersionDate, checkUpdateError.toString())); return false; } - if (!Platform.isWindows) return false; - final lastVersion = ConstConf.isMSE - ? state.networkVersionData?.mSELastVersionCode - : state.networkVersionData?.lastVersionCode; - if ((lastVersion ?? 0) > ConstConf.appVersionCode) { - // need update - if (!context.mounted) return false; - - final r = await showDialog( - dismissWithEsc: false, - context: context, - builder: (context) => const UpgradeDialogUI()); - - if (r != true) { - if (!context.mounted) return false; - await showToast(context, S.current.app_common_upgrade_info_error); - return false; - } - return true; - } return false; } @@ -314,44 +256,6 @@ class AppGlobalModel extends _$AppGlobalModel { state = state.copyWith(appLocale: value); } } - - Future _initAppDir() async { - if (Platform.isWindows) { - final userProfileDir = Platform.environment["USERPROFILE"]; - final applicationSupportDir = - (await getApplicationSupportDirectory()).absolute.path; - String? applicationBinaryModuleDir; - try { - await initDPrintFile(applicationSupportDir); - } catch (e) { - dPrint("initDPrintFile Error: $e"); - } - if (ConstConf.isMSE && userProfileDir != null) { - applicationBinaryModuleDir = - "$userProfileDir\\AppData\\Local\\Temp\\SCToolbox\\modules"; - } else { - applicationBinaryModuleDir = "$applicationSupportDir\\modules"; - } - dPrint("applicationSupportDir == $applicationSupportDir"); - dPrint("applicationBinaryModuleDir == $applicationBinaryModuleDir"); - state = state.copyWith( - applicationSupportDir: applicationSupportDir, - applicationBinaryModuleDir: applicationBinaryModuleDir, - ); - return applicationSupportDir; - } else { - final applicationSupportDir = - (await getApplicationSupportDirectory()).absolute.path; - final applicationBinaryModuleDir = "$applicationSupportDir/modules"; - dPrint("applicationSupportDir == $applicationSupportDir"); - dPrint("applicationBinaryModuleDir == $applicationBinaryModuleDir"); - state = state.copyWith( - applicationSupportDir: applicationSupportDir, - applicationBinaryModuleDir: applicationBinaryModuleDir, - ); - return applicationSupportDir; - } - } } @freezed diff --git a/lib/app.freezed.dart b/lib/app.freezed.dart index a57de0f..b239a30 100644 --- a/lib/app.freezed.dart +++ b/lib/app.freezed.dart @@ -23,6 +23,7 @@ mixin _$AppGlobalState { ThemeConf get themeConf => throw _privateConstructorUsedError; Locale? get appLocale => throw _privateConstructorUsedError; Box? get appConfBox => throw _privateConstructorUsedError; + String get backgroundImageAssetsPath => throw _privateConstructorUsedError; /// Create a copy of AppGlobalState /// with the given fields replaced by the non-null parameter values. @@ -44,7 +45,8 @@ abstract class $AppGlobalStateCopyWith<$Res> { AppVersionData? networkVersionData, ThemeConf themeConf, Locale? appLocale, - Box? appConfBox}); + Box? appConfBox, + String backgroundImageAssetsPath}); $ThemeConfCopyWith<$Res> get themeConf; } @@ -71,6 +73,7 @@ class _$AppGlobalStateCopyWithImpl<$Res, $Val extends AppGlobalState> Object? themeConf = null, Object? appLocale = freezed, Object? appConfBox = freezed, + Object? backgroundImageAssetsPath = null, }) { return _then(_value.copyWith( deviceUUID: freezed == deviceUUID @@ -101,6 +104,10 @@ class _$AppGlobalStateCopyWithImpl<$Res, $Val extends AppGlobalState> ? _value.appConfBox : appConfBox // ignore: cast_nullable_to_non_nullable as Box?, + backgroundImageAssetsPath: null == backgroundImageAssetsPath + ? _value.backgroundImageAssetsPath + : backgroundImageAssetsPath // ignore: cast_nullable_to_non_nullable + as String, ) as $Val); } @@ -130,7 +137,8 @@ abstract class _$$AppGlobalStateImplCopyWith<$Res> AppVersionData? networkVersionData, ThemeConf themeConf, Locale? appLocale, - Box? appConfBox}); + Box? appConfBox, + String backgroundImageAssetsPath}); @override $ThemeConfCopyWith<$Res> get themeConf; @@ -156,6 +164,7 @@ class __$$AppGlobalStateImplCopyWithImpl<$Res> Object? themeConf = null, Object? appLocale = freezed, Object? appConfBox = freezed, + Object? backgroundImageAssetsPath = null, }) { return _then(_$AppGlobalStateImpl( deviceUUID: freezed == deviceUUID @@ -186,6 +195,10 @@ class __$$AppGlobalStateImplCopyWithImpl<$Res> ? _value.appConfBox : appConfBox // ignore: cast_nullable_to_non_nullable as Box?, + backgroundImageAssetsPath: null == backgroundImageAssetsPath + ? _value.backgroundImageAssetsPath + : backgroundImageAssetsPath // ignore: cast_nullable_to_non_nullable + as String, )); } } @@ -200,7 +213,9 @@ class _$AppGlobalStateImpl implements _AppGlobalState { this.networkVersionData, this.themeConf = const ThemeConf(), this.appLocale, - this.appConfBox}); + this.appConfBox, + this.backgroundImageAssetsPath = + "assets/backgrounds/SC_01_Wallpaper_3840x2160.jpg"}); @override final String? deviceUUID; @@ -217,10 +232,13 @@ class _$AppGlobalStateImpl implements _AppGlobalState { final Locale? appLocale; @override final Box? appConfBox; + @override + @JsonKey() + final String backgroundImageAssetsPath; @override String toString() { - return 'AppGlobalState(deviceUUID: $deviceUUID, applicationSupportDir: $applicationSupportDir, applicationBinaryModuleDir: $applicationBinaryModuleDir, networkVersionData: $networkVersionData, themeConf: $themeConf, appLocale: $appLocale, appConfBox: $appConfBox)'; + return 'AppGlobalState(deviceUUID: $deviceUUID, applicationSupportDir: $applicationSupportDir, applicationBinaryModuleDir: $applicationBinaryModuleDir, networkVersionData: $networkVersionData, themeConf: $themeConf, appLocale: $appLocale, appConfBox: $appConfBox, backgroundImageAssetsPath: $backgroundImageAssetsPath)'; } @override @@ -243,7 +261,10 @@ class _$AppGlobalStateImpl implements _AppGlobalState { (identical(other.appLocale, appLocale) || other.appLocale == appLocale) && (identical(other.appConfBox, appConfBox) || - other.appConfBox == appConfBox)); + other.appConfBox == appConfBox) && + (identical(other.backgroundImageAssetsPath, + backgroundImageAssetsPath) || + other.backgroundImageAssetsPath == backgroundImageAssetsPath)); } @override @@ -255,7 +276,8 @@ class _$AppGlobalStateImpl implements _AppGlobalState { networkVersionData, themeConf, appLocale, - appConfBox); + appConfBox, + backgroundImageAssetsPath); /// Create a copy of AppGlobalState /// with the given fields replaced by the non-null parameter values. @@ -275,7 +297,8 @@ abstract class _AppGlobalState implements AppGlobalState { final AppVersionData? networkVersionData, final ThemeConf themeConf, final Locale? appLocale, - final Box? appConfBox}) = _$AppGlobalStateImpl; + final Box? appConfBox, + final String backgroundImageAssetsPath}) = _$AppGlobalStateImpl; @override String? get deviceUUID; @@ -291,6 +314,8 @@ abstract class _AppGlobalState implements AppGlobalState { Locale? get appLocale; @override Box? get appConfBox; + @override + String get backgroundImageAssetsPath; /// Create a copy of AppGlobalState /// with the given fields replaced by the non-null parameter values. diff --git a/lib/app.g.dart b/lib/app.g.dart index b71d858..20c5ca0 100644 --- a/lib/app.g.dart +++ b/lib/app.g.dart @@ -6,7 +6,7 @@ part of 'app.dart'; // RiverpodGenerator // ************************************************************************** -String _$routerHash() => r'4fb9802d06347972b530f17ea7d66724a6ded997'; +String _$routerHash() => r'b35ab7db63955c2d8507e811a5e0d202f65c04be'; /// See also [router]. @ProviderFor(router) @@ -20,7 +20,7 @@ final routerProvider = AutoDisposeProvider.internal( ); typedef RouterRef = AutoDisposeProviderRef; -String _$appGlobalModelHash() => r'cf3d526a61cbadea4252c6f8e096a527d5cef50f'; +String _$appGlobalModelHash() => r'1fb13f5be4249fdeb2d78906e1bfe94031b76afc'; /// See also [AppGlobalModel]. @ProviderFor(AppGlobalModel) diff --git a/lib/common/conf/binary_conf.dart b/lib/common/conf/binary_conf.dart deleted file mode 100644 index 41a4aae..0000000 --- a/lib/common/conf/binary_conf.dart +++ /dev/null @@ -1,47 +0,0 @@ -import 'dart:io'; - -import 'package:archive/archive.dart'; -import 'package:flutter/foundation.dart'; -import 'package:flutter/services.dart'; -import 'package:starcitizen_doctor/common/utils/log.dart'; - -class BinaryModuleConf { - static const _modules = { - "aria2c": "0", - "unp4kc": "1", - }; - - static Future extractModule(List modules, String workingDir) async { - for (var m in _modules.entries) { - if (!modules.contains(m.key)) continue; - final name = m.key; - final version = m.value; - final dir = "$workingDir\\$name"; - final versionFile = File("$dir\\version"); - if (kReleaseMode && - await versionFile.exists() && - (await versionFile.readAsString()).trim() == version) { - dPrint( - "BinaryModuleConf.extractModule skip $name version == $version"); - continue; - } - // write model file - final zipBuffer = await rootBundle.load("assets/binary/$name.zip"); - final decoder = ZipDecoder().decodeBytes(zipBuffer.buffer.asUint8List()); - for (var value in decoder.files) { - final filename = value.name; - if (value.isFile) { - final data = value.content as List; - final file = File('$dir\\$filename'); - await file.create(recursive: true); - await file.writeAsBytes(data); - } else { - await Directory('$dir\\$filename').create(recursive: true); - } - } - // write version file - await versionFile.writeAsString(version); - dPrint("BinaryModuleConf.extractModule $name $dir"); - } - } -} diff --git a/lib/common/conf/const_conf.dart b/lib/common/conf/const_conf.dart index 034bfc7..7a913a0 100644 --- a/lib/common/conf/const_conf.dart +++ b/lib/common/conf/const_conf.dart @@ -1,8 +1,7 @@ class ConstConf { - static const String appVersion = "2.12.0"; - static const int appVersionCode = 54; - static const String appVersionDate = "2024-6-28"; + static const String appVersion = "Lite"; + static const int appVersionCode = 0; + static const String appVersionDate = "2024-09-04"; static const gameChannels = ["LIVE", "PTU", "EPTU", "TECH-PREVIEW"]; - static const isMSE = - String.fromEnvironment("MSE", defaultValue: "false") == "true"; + static const isMSE = true; } diff --git a/lib/common/conf/url_conf.dart b/lib/common/conf/url_conf.dart index b2e9a38..ba3ae27 100644 --- a/lib/common/conf/url_conf.dart +++ b/lib/common/conf/url_conf.dart @@ -37,24 +37,7 @@ class URLConf { static String get devReleaseUrl => "$gitApiHome/SCToolBox/Release/releases"; static Future checkHost() async { - // 使用 DNS 获取可用列表 - final gitApiList = - _genFinalList(await RSHttp.dnsLookupTxt("git.dns.scbox.org")); - dPrint("DNS gitApiList ==== $gitApiList"); - final fasterGit = await getFasterUrl(gitApiList); - dPrint("gitApiList.Faster ==== $fasterGit"); - if (fasterGit != null) { - gitApiHome = fasterGit; - } - final rssApiList = - _genFinalList(await RSHttp.dnsLookupTxt("rss.dns.scbox.org")); - final fasterRss = await getFasterUrl(rssApiList); - dPrint("DNS rssApiList ==== $rssApiList"); - dPrint("rssApiList.Faster ==== $fasterRss"); - if (fasterRss != null) { - rssApiHome = fasterRss; - } - isUrlCheckPass = fasterGit != null && fasterRss != null; + isUrlCheckPass = true; return isUrlCheckPass; } @@ -87,14 +70,4 @@ class URLConf { } } - static List _genFinalList(List sList) { - List list = []; - for (var ll in sList) { - final ssList = ll.split(","); - for (var value in ssList) { - list.add(value); - } - } - return list; - } } diff --git a/lib/common/helper/log_helper.dart b/lib/common/helper/log_helper.dart deleted file mode 100644 index 0a2c7c1..0000000 --- a/lib/common/helper/log_helper.dart +++ /dev/null @@ -1,209 +0,0 @@ -import 'dart:convert'; -import 'dart:io'; - -import 'package:hive/hive.dart'; -import 'package:starcitizen_doctor/common/conf/const_conf.dart'; -import 'package:starcitizen_doctor/common/utils/log.dart'; - -class SCLoggerHelper { - static Future getLogFilePath() async { - if (!Platform.isWindows) return null; - Map envVars = Platform.environment; - final appDataPath = envVars["appdata"]; - if (appDataPath == null) { - return null; - } - final rsiLauncherPath = "$appDataPath\\rsilauncher"; - dPrint("rsiLauncherPath:$rsiLauncherPath"); - final jsonLogPath = "$rsiLauncherPath\\logs\\log.log"; - return jsonLogPath; - } - - static Future getShaderCachePath() async { - Map envVars = Platform.environment; - final appDataPath = envVars["LOCALAPPDATA"]; - if (appDataPath == null) { - return null; - } - final scCachePath = "$appDataPath\\Star Citizen"; - dPrint("getShaderCachePath === $scCachePath"); - return scCachePath; - } - - static Future getLauncherLogList() async { - if (!Platform.isWindows) return []; - try { - final jsonLogPath = await getLogFilePath(); - if (jsonLogPath == null) throw "no file path"; - var jsonString = utf8.decode(await File(jsonLogPath).readAsBytes()); - if (jsonString.endsWith("\n")) { - jsonString = jsonString.substring(0, jsonString.length - 3); - } - if (jsonString.endsWith(" ")) { - jsonString = jsonString.substring(0, jsonString.length - 3); - } - if (jsonString.endsWith(",")) { - jsonString = jsonString.substring(0, jsonString.length - 3); - } - return json.decode("[$jsonString]"); - } catch (e) { - dPrint(e); - return []; - } - } - - static Future> getGameInstallPath(List listData, - {bool checkExists = true, - List withVersion = const ["LIVE"]}) async { - List scInstallPaths = []; - - checkAndAddPath(String path, bool checkExists) async { - if (path.isNotEmpty && !scInstallPaths.contains(path)) { - if (!checkExists) { - dPrint("find installPath == $path"); - scInstallPaths.add(path); - } else if (await File("$path/Bin64/StarCitizen.exe").exists() && - await File("$path/Data.p4k").exists()) { - dPrint("find installPath == $path"); - scInstallPaths.add(path); - } - } - } - - final confBox = await Hive.openBox("app_conf"); - final path = confBox.get("custom_game_path"); - if (path != null && path != "") { - for (var v in withVersion) { - await checkAndAddPath("$path\\$v", checkExists); - } - } - - try { - for (var v in withVersion) { - for (var i = listData.length - 1; i > 0; i--) { - final m = listData[i]; - final info = m["[browser][info] "]; - if (info is String) { - String installPath = ""; - if (info.contains("Installing Star Citizen $v")) { - installPath = "${info.split(" at ")[1]}\\$v"; - } - if (info.contains("Verifying Star Citizen $v")) { - installPath = "${info.split(" at ")[1]}\\$v"; - } - if (info.contains("Launching Star Citizen $v from")) { - installPath = info - .replaceAll("Launching Star Citizen $v from (", "") - .replaceAll(")", ""); - } - await checkAndAddPath(installPath, checkExists); - } - } - - if (scInstallPaths.isNotEmpty) { - // 动态检测更多位置 - for (var v in withVersion) { - for (var fileName in List.from(scInstallPaths)) { - if (fileName.toString().endsWith(v)) { - for (var nv in withVersion) { - final nextName = - "${fileName.toString().replaceAll("\\$v", "")}\\$nv"; - await checkAndAddPath(nextName, true); - } - } - } - } - } - } - } catch (e) { - dPrint(e); - if (scInstallPaths.isEmpty) rethrow; - } - - return scInstallPaths; - } - - static String getGameChannelID(String installPath) { - for (var value in ConstConf.gameChannels) { - if (installPath.endsWith("\\$value")) { - return value; - } - } - return "UNKNOWN"; - } - - static Future?> getGameRunningLogs(String gameDir) async { - final logFile = File("$gameDir/Game.log"); - if (!await logFile.exists()) { - return null; - } - return await logFile.readAsLines( - encoding: const Utf8Codec(allowMalformed: true)); - } - - static MapEntry? getGameRunningLogInfo(List logs) { - for (var i = logs.length - 1; i > 0; i--) { - final line = logs[i]; - final r = _checkRunningLine(line); - if (r != null) { - return r; - } - } - return null; - } - - static MapEntry? _checkRunningLine(String line) { - if (line.contains("STATUS_CRYENGINE_OUT_OF_SYSMEM")) { - return MapEntry(S.current.doctor_game_error_low_memory, - S.current.doctor_game_error_low_memory_info); - } - if (line.contains("EXCEPTION_ACCESS_VIOLATION")) { - return MapEntry(S.current.doctor_game_error_generic_info, - "https://docs.qq.com/doc/DUURxUVhzTmZoY09Z"); - } - if (line.contains("DXGI_ERROR_DEVICE_REMOVED")) { - return MapEntry(S.current.doctor_game_error_gpu_crash, - "https://www.bilibili.com/read/cv19335199"); - } - if (line.contains("Wakeup socket sendto error")) { - return MapEntry(S.current.doctor_game_error_socket_error, - S.current.doctor_game_error_socket_error_info); - } - - if (line.contains("The requested operation requires elevated")) { - return MapEntry(S.current.doctor_game_error_permissions_error, - S.current.doctor_game_error_permissions_error_info); - } - if (line.contains( - "The process cannot access the file because is is being used by another process")) { - return MapEntry(S.current.doctor_game_error_game_process_error, - S.current.doctor_game_error_game_process_error_info); - } - if (line.contains("0xc0000043")) { - return MapEntry(S.current.doctor_game_error_game_damaged_file, - S.current.doctor_game_error_game_damaged_file_info); - } - if (line.contains("option to verify the content of the Data.p4k file")) { - return MapEntry(S.current.doctor_game_error_game_damaged_p4k_file, - S.current.doctor_game_error_game_damaged_p4k_file_info); - } - if (line.contains("OUTOFMEMORY Direct3D could not allocate")) { - return MapEntry(S.current.doctor_game_error_low_gpu_memory, - S.current.doctor_game_error_low_gpu_memory_info); - } - if (line.contains( - "try disabling with r_vulkanDisableLayers = 1 in your user.cfg")) { - return MapEntry(S.current.doctor_game_error_gpu_vulkan_crash, - S.current.doctor_game_error_gpu_vulkan_crash_info); - } - - /// Unknown - if (line.contains("network.replicatedEntityHandle")) { - return const MapEntry("_", "network.replicatedEntityHandle"); - } - if (line.contains("Exception Unknown")) { - return const MapEntry("_", "Exception Unknown"); - } - return null; - } -} diff --git a/lib/common/helper/system_helper.dart b/lib/common/helper/system_helper.dart deleted file mode 100644 index db1dc47..0000000 --- a/lib/common/helper/system_helper.dart +++ /dev/null @@ -1,280 +0,0 @@ -import 'dart:io'; - -import 'package:hive/hive.dart'; -import 'package:starcitizen_doctor/common/utils/log.dart'; - -class SystemHelper { - static String powershellPath = "powershell.exe"; - - static initPowershellPath() async { - try { - var result = await Process.run(powershellPath, ["echo", "ping"]); - if (!result.stdout.toString().startsWith("ping") && - powershellPath == "powershell.exe") { - throw "powershell check failed"; - } - } catch (e) { - Map envVars = Platform.environment; - final systemRoot = envVars["SYSTEMROOT"]; - if (systemRoot != null) { - final autoSearchPath = - "$systemRoot\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"; - dPrint("auto search powershell path === $autoSearchPath"); - powershellPath = autoSearchPath; - } - } - } - - static Future checkNvmePatchStatus() async { - try { - var result = await Process.run(SystemHelper.powershellPath, [ - "Get-ItemProperty", - "-Path", - "\"HKLM:\\SYSTEM\\CurrentControlSet\\Services\\stornvme\\Parameters\\Device\"", - "-Name", - "\"ForcedPhysicalSectorSizeInBytes\"" - ]); - dPrint("checkNvmePatchStatus result ==== ${result.stdout}"); - if (result.stderr == "" && - result.stdout.toString().contains("{* 4095}")) { - return true; - } else { - return false; - } - } catch (e) { - return false; - } - } - - static Future addNvmePatch() async { - var result = await Process.run(powershellPath, [ - 'New-ItemProperty', - "-Path", - "\"HKLM:\\SYSTEM\\CurrentControlSet\\Services\\stornvme\\Parameters\\Device\"", - "-Name", - "ForcedPhysicalSectorSizeInBytes", - "-PropertyType MultiString", - "-Force -Value", - "\"* 4095\"" - ]); - dPrint("nvme_PhysicalBytes result == ${result.stdout}"); - return result.stderr; - } - - static doRemoveNvmePath() async { - try { - var result = await Process.run(powershellPath, [ - "Clear-ItemProperty", - "-Path", - "\"HKLM:\\SYSTEM\\CurrentControlSet\\Services\\stornvme\\Parameters\\Device\"", - "-Name", - "\"ForcedPhysicalSectorSizeInBytes\"" - ]); - dPrint("doRemoveNvmePath result ==== ${result.stdout}"); - if (result.stderr == "") { - return true; - } else { - return false; - } - } catch (e) { - return false; - } - } - - /// 获取 RSI 启动器 目录 - static Future getRSILauncherPath({bool skipEXE = false}) async { - final confBox = await Hive.openBox("app_conf"); - final path = confBox.get("custom_launcher_path"); - if (path != null && path != "") { - if (await File(path).exists()) { - if (skipEXE) { - return "${path.toString().replaceAll("\\RSI Launcher.exe", "")}\\"; - } - return path; - } - } - - Map envVars = Platform.environment; - final programDataPath = envVars["programdata"]; - final rsiFilePath = - "$programDataPath\\Microsoft\\Windows\\Start Menu\\Programs\\Roberts Space Industries\\RSI Launcher.lnk"; - final rsiLinkFile = File(rsiFilePath); - if (await rsiLinkFile.exists()) { - final r = await Process.run(SystemHelper.powershellPath, [ - "(New-Object -ComObject WScript.Shell).CreateShortcut(\"$rsiFilePath\").targetpath" - ]); - if (r.stdout.toString().contains("RSI Launcher.exe")) { - final start = r.stdout.toString().split("RSI Launcher.exe"); - if (skipEXE) { - return start[0]; - } - return "${start[0]}RSI Launcher.exe"; - } - } - return ""; - } - - static killRSILauncher() async { - var psr = await Process.run( - powershellPath, ["ps", "\"RSI Launcher\"", "|select -expand id"]); - if (psr.stderr == "") { - for (var value in (psr.stdout ?? "").toString().split("\n")) { - dPrint(value); - if (value != "") { - Process.killPid(int.parse(value)); - } - } - } - } - - static Future> getPID(String name) async { - final r = await Process.run(powershellPath, ["(ps $name).Id"]); - final str = r.stdout.toString().trim(); - dPrint(str); - if (str.isEmpty) return []; - return str.split("\n"); - } - - static checkAndLaunchRSILauncher(String path) async { - // check running and kill - await killRSILauncher(); - // launch - final processorAffinity = await SystemHelper.getCpuAffinity(); - if (processorAffinity == null) { - Process.run(path, []); - } else { - Process.run("cmd.exe", [ - '/C', - 'Start', - '""', - '/High', - '/Affinity', - processorAffinity, - path, - ]); - } - dPrint(path); - } - - static Future getSystemMemorySizeGB() async { - final r = await Process.run(powershellPath, [ - "(Get-CimInstance Win32_PhysicalMemory | Measure-Object -Property capacity -Sum).sum /1gb" - ]); - return int.tryParse(r.stdout.toString().trim()) ?? 0; - } - - static Future getSystemCimInstance(String win32InstanceName, - {pathName = "Name"}) async { - final r = await Process.run( - powershellPath, ["(Get-CimInstance $win32InstanceName).$pathName"]); - return r.stdout.toString().trim(); - } - - static Future getSystemName() async { - final r = await Process.run( - powershellPath, ["(Get-ComputerInfo | Select-Object -expand OsName)"]); - return r.stdout.toString().trim(); - } - - static Future getCpuName() async { - final r = await Process.run( - powershellPath, ["(Get-WmiObject -Class Win32_Processor).Name"]); - return r.stdout.toString().trim(); - } - - static Future getGpuInfo() async { - const cmd = r""" - $adapterMemory = (Get-ItemProperty -Path "HKLM:\SYSTEM\ControlSet001\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}\0*" -Name "HardwareInformation.AdapterString", "HardwareInformation.qwMemorySize" -Exclude PSPath -ErrorAction SilentlyContinue) -foreach ($adapter in $adapterMemory) { - [PSCustomObject] @{ - Model=$adapter."HardwareInformation.AdapterString" - "VRAM (GB)"=[math]::round($adapter."HardwareInformation.qwMemorySize"/1GB) - } -} - """; - final r = await Process.run(powershellPath, [cmd]); - return r.stdout.toString().trim(); - } - - static Future getDiskInfo() async { - return (await Process.run(powershellPath, - ["Get-PhysicalDisk | format-table BusType,FriendlyName,Size"])) - .stdout - .toString() - .trim(); - } - - static Future getDirLen(String path, {List? skipPath}) async { - if (path == "") return 0; - int totalSize = 0; - try { - final l = await Directory(path).list(recursive: true).toList(); - for (var element in l) { - if (element is File) { - bool skip = false; - if (skipPath != null) { - for (var value in skipPath) { - if (element.absolute.path.startsWith(value)) { - skip = true; - break; - } - } - } - if (!skip) totalSize += await element.length(); - } - } - } catch (_) {} - return totalSize; - } - - static Future getNumberOfLogicalProcessors() async { - final cpuNumberResult = await Process.run(powershellPath, - ["(Get-WmiObject -Class Win32_Processor).NumberOfLogicalProcessors"]); - if (cpuNumberResult.exitCode != 0) return 0; - return int.tryParse(cpuNumberResult.stdout.toString().trim()) ?? 0; - } - - static Future getCpuAffinity() async { - final confBox = await Hive.openBox("app_conf"); - final eCoreCount = int.tryParse( - confBox.get("gameLaunch_eCore_count", defaultValue: "0")) ?? - 0; - final cpuNumber = await getNumberOfLogicalProcessors(); - if (cpuNumber == 0 || eCoreCount == 0 || eCoreCount > cpuNumber) { - return null; - } - - StringBuffer sb = StringBuffer(); - for (var i = 0; i < cpuNumber; i++) { - if (i < eCoreCount) { - sb.write("0"); - } else { - sb.write("1"); - } - } - final binaryString = sb.toString(); - int hexDigits = (binaryString.length / 4).ceil(); - dPrint("Affinity sb ==== $sb"); - return int.parse(binaryString, radix: 2) - .toRadixString(16) - .padLeft(hexDigits, '0') - .toUpperCase(); - } - - static Future openDir(path, {bool isFile = false}) async { - dPrint("SystemHelper.openDir path === $path"); - if (Platform.isWindows) { - await Process.run(SystemHelper.powershellPath, - ["explorer.exe", isFile ? "/select,$path" : "\"/select,\"$path\"\""]); - } - } - - static String getHostsFilePath() { - if (Platform.isWindows) { - final envVars = Platform.environment; - final systemRoot = envVars["SYSTEMROOT"]; - return "$systemRoot\\System32\\drivers\\etc\\hosts"; - } - return "/etc/hosts"; - } -} diff --git a/lib/common/io/rs_http.dart b/lib/common/io/rs_http.dart index 662a861..e91763a 100644 --- a/lib/common/io/rs_http.dart +++ b/lib/common/io/rs_http.dart @@ -17,10 +17,7 @@ class RSHttp { static Future get(String url, {Map? headers, String? withIpAddress}) async { final r = await rust_http.fetch( - method: MyMethod.gets, - url: url, - headers: headers, - withIpAddress: withIpAddress); + method: MyMethod.gets, url: url, headers: headers); return r; } @@ -42,29 +39,14 @@ class RSHttp { headers["Content-Type"] = contentType; } final r = await rust_http.fetch( - method: MyMethod.post, - url: url, - headers: headers, - inputData: data, - withIpAddress: withIpAddress); + method: MyMethod.post, url: url, headers: headers, inputData: data); return r; } static Future head(String url, {Map? headers, String? withIpAddress}) async { final r = await rust_http.fetch( - method: MyMethod.head, - url: url, - headers: headers, - withIpAddress: withIpAddress); + method: MyMethod.head, url: url, headers: headers); return r; } - - static Future> dnsLookupTxt(String host) async { - return await rust_http.dnsLookupTxt(host: host); - } - - static Future> dnsLookupIps(String host) async { - return await rust_http.dnsLookupIps(host: host); - } } diff --git a/lib/common/rust/api/asar_api.dart b/lib/common/rust/api/asar_api.dart deleted file mode 100644 index 45aa007..0000000 --- a/lib/common/rust/api/asar_api.dart +++ /dev/null @@ -1,41 +0,0 @@ -// This file is automatically generated, so please do not edit it. -// Generated by `flutter_rust_bridge`@ 2.3.0. - -// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import - -import '../frb_generated.dart'; -import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; - -Future getRsiLauncherAsarData( - {required String asarPath}) => - RustLib.instance.api - .crateApiAsarApiGetRsiLauncherAsarData(asarPath: asarPath); - -class RsiLauncherAsarData { - final String asarPath; - final String mainJsPath; - final Uint8List mainJsContent; - - const RsiLauncherAsarData({ - required this.asarPath, - required this.mainJsPath, - required this.mainJsContent, - }); - - Future writeMainJs({required List content}) => - RustLib.instance.api.crateApiAsarApiRsiLauncherAsarDataWriteMainJs( - that: this, content: content); - - @override - int get hashCode => - asarPath.hashCode ^ mainJsPath.hashCode ^ mainJsContent.hashCode; - - @override - bool operator ==(Object other) => - identical(this, other) || - other is RsiLauncherAsarData && - runtimeType == other.runtimeType && - asarPath == other.asarPath && - mainJsPath == other.mainJsPath && - mainJsContent == other.mainJsContent; -} diff --git a/lib/common/rust/api/http_api.dart b/lib/common/rust/api/http_api.dart index 56ea8bc..d047814 100644 --- a/lib/common/rust/api/http_api.dart +++ b/lib/common/rust/api/http_api.dart @@ -16,20 +16,9 @@ Future fetch( {required MyMethod method, required String url, Map? headers, - Uint8List? inputData, - String? withIpAddress}) => + Uint8List? inputData}) => RustLib.instance.api.crateApiHttpApiFetch( - method: method, - url: url, - headers: headers, - inputData: inputData, - withIpAddress: withIpAddress); - -Future> dnsLookupTxt({required String host}) => - RustLib.instance.api.crateApiHttpApiDnsLookupTxt(host: host); - -Future> dnsLookupIps({required String host}) => - RustLib.instance.api.crateApiHttpApiDnsLookupIps(host: host); + method: method, url: url, headers: headers, inputData: inputData); enum MyMethod { options, diff --git a/lib/common/rust/api/rs_process.dart b/lib/common/rust/api/rs_process.dart deleted file mode 100644 index 2597fb3..0000000 --- a/lib/common/rust/api/rs_process.dart +++ /dev/null @@ -1,54 +0,0 @@ -// This file is automatically generated, so please do not edit it. -// Generated by `flutter_rust_bridge`@ 2.3.0. - -// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import - -import '../frb_generated.dart'; -import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; - -// These functions are ignored because they are not marked as `pub`: `_process_output` -// These types are ignored because they are not used by any `pub` functions: `RsProcess` -// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `clone` - -Stream start( - {required String executable, - required List arguments, - required String workingDirectory}) => - RustLib.instance.api.crateApiRsProcessStart( - executable: executable, - arguments: arguments, - workingDirectory: workingDirectory); - -Future write({required int rsPid, required String data}) => - RustLib.instance.api.crateApiRsProcessWrite(rsPid: rsPid, data: data); - -class RsProcessStreamData { - final RsProcessStreamDataType dataType; - final String data; - final int rsPid; - - const RsProcessStreamData({ - required this.dataType, - required this.data, - required this.rsPid, - }); - - @override - int get hashCode => dataType.hashCode ^ data.hashCode ^ rsPid.hashCode; - - @override - bool operator ==(Object other) => - identical(this, other) || - other is RsProcessStreamData && - runtimeType == other.runtimeType && - dataType == other.dataType && - data == other.data && - rsPid == other.rsPid; -} - -enum RsProcessStreamDataType { - output, - error, - exit, - ; -} diff --git a/lib/common/rust/api/win32_api.dart b/lib/common/rust/api/win32_api.dart deleted file mode 100644 index 71a7a1a..0000000 --- a/lib/common/rust/api/win32_api.dart +++ /dev/null @@ -1,16 +0,0 @@ -// This file is automatically generated, so please do not edit it. -// Generated by `flutter_rust_bridge`@ 2.3.0. - -// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import - -import '../frb_generated.dart'; -import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; - -Future sendNotify( - {String? summary, String? body, String? appName, String? appId}) => - RustLib.instance.api.crateApiWin32ApiSendNotify( - summary: summary, body: body, appName: appName, appId: appId); - -Future setForegroundWindow({required String windowName}) => - RustLib.instance.api - .crateApiWin32ApiSetForegroundWindow(windowName: windowName); diff --git a/lib/common/rust/frb_generated.dart b/lib/common/rust/frb_generated.dart index c189ab7..b841792 100644 --- a/lib/common/rust/frb_generated.dart +++ b/lib/common/rust/frb_generated.dart @@ -3,10 +3,7 @@ // ignore_for_file: unused_import, unused_element, unnecessary_import, duplicate_ignore, invalid_use_of_internal_member, annotate_overrides, non_constant_identifier_names, curly_braces_in_flow_control_structures, prefer_const_literals_to_create_immutables, unused_field -import 'api/asar_api.dart'; import 'api/http_api.dart'; -import 'api/rs_process.dart'; -import 'api/win32_api.dart'; import 'dart:async'; import 'dart:convert'; import 'frb_generated.dart'; @@ -70,7 +67,7 @@ class RustLib extends BaseEntrypoint { String get codegenVersion => '2.3.0'; @override - int get rustContentHash => 1832496273; + int get rustContentHash => -669496402; static const kDefaultExternalLibraryLoaderConfig = ExternalLibraryLoaderConfig( @@ -81,39 +78,14 @@ class RustLib extends BaseEntrypoint { } abstract class RustLibApi extends BaseApi { - Future crateApiAsarApiGetRsiLauncherAsarData( - {required String asarPath}); - - Future crateApiAsarApiRsiLauncherAsarDataWriteMainJs( - {required RsiLauncherAsarData that, required List content}); - - Future> crateApiHttpApiDnsLookupIps({required String host}); - - Future> crateApiHttpApiDnsLookupTxt({required String host}); - Future crateApiHttpApiFetch( {required MyMethod method, required String url, Map? headers, - Uint8List? inputData, - String? withIpAddress}); + Uint8List? inputData}); Future crateApiHttpApiSetDefaultHeader( {required Map headers}); - - Stream crateApiRsProcessStart( - {required String executable, - required List arguments, - required String workingDirectory}); - - Future crateApiRsProcessWrite( - {required int rsPid, required String data}); - - Future crateApiWin32ApiSendNotify( - {String? summary, String? body, String? appName, String? appId}); - - Future crateApiWin32ApiSetForegroundWindow( - {required String windowName}); } class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { @@ -124,134 +96,34 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { required super.portManager, }); - @override - Future crateApiAsarApiGetRsiLauncherAsarData( - {required String asarPath}) { - return handler.executeNormal(NormalTask( - callFfi: (port_) { - var arg0 = cst_encode_String(asarPath); - return wire.wire__crate__api__asar_api__get_rsi_launcher_asar_data( - port_, arg0); - }, - codec: DcoCodec( - decodeSuccessData: dco_decode_rsi_launcher_asar_data, - decodeErrorData: dco_decode_AnyhowException, - ), - constMeta: kCrateApiAsarApiGetRsiLauncherAsarDataConstMeta, - argValues: [asarPath], - apiImpl: this, - )); - } - - TaskConstMeta get kCrateApiAsarApiGetRsiLauncherAsarDataConstMeta => - const TaskConstMeta( - debugName: "get_rsi_launcher_asar_data", - argNames: ["asarPath"], - ); - - @override - Future crateApiAsarApiRsiLauncherAsarDataWriteMainJs( - {required RsiLauncherAsarData that, required List content}) { - return handler.executeNormal(NormalTask( - callFfi: (port_) { - var arg0 = cst_encode_box_autoadd_rsi_launcher_asar_data(that); - var arg1 = cst_encode_list_prim_u_8_loose(content); - return wire - .wire__crate__api__asar_api__rsi_launcher_asar_data_write_main_js( - port_, arg0, arg1); - }, - codec: DcoCodec( - decodeSuccessData: dco_decode_unit, - decodeErrorData: dco_decode_AnyhowException, - ), - constMeta: kCrateApiAsarApiRsiLauncherAsarDataWriteMainJsConstMeta, - argValues: [that, content], - apiImpl: this, - )); - } - - TaskConstMeta get kCrateApiAsarApiRsiLauncherAsarDataWriteMainJsConstMeta => - const TaskConstMeta( - debugName: "rsi_launcher_asar_data_write_main_js", - argNames: ["that", "content"], - ); - - @override - Future> crateApiHttpApiDnsLookupIps({required String host}) { - return handler.executeNormal(NormalTask( - callFfi: (port_) { - var arg0 = cst_encode_String(host); - return wire.wire__crate__api__http_api__dns_lookup_ips(port_, arg0); - }, - codec: DcoCodec( - decodeSuccessData: dco_decode_list_String, - decodeErrorData: dco_decode_AnyhowException, - ), - constMeta: kCrateApiHttpApiDnsLookupIpsConstMeta, - argValues: [host], - apiImpl: this, - )); - } - - TaskConstMeta get kCrateApiHttpApiDnsLookupIpsConstMeta => - const TaskConstMeta( - debugName: "dns_lookup_ips", - argNames: ["host"], - ); - - @override - Future> crateApiHttpApiDnsLookupTxt({required String host}) { - return handler.executeNormal(NormalTask( - callFfi: (port_) { - var arg0 = cst_encode_String(host); - return wire.wire__crate__api__http_api__dns_lookup_txt(port_, arg0); - }, - codec: DcoCodec( - decodeSuccessData: dco_decode_list_String, - decodeErrorData: dco_decode_AnyhowException, - ), - constMeta: kCrateApiHttpApiDnsLookupTxtConstMeta, - argValues: [host], - apiImpl: this, - )); - } - - TaskConstMeta get kCrateApiHttpApiDnsLookupTxtConstMeta => - const TaskConstMeta( - debugName: "dns_lookup_txt", - argNames: ["host"], - ); - @override Future crateApiHttpApiFetch( {required MyMethod method, required String url, Map? headers, - Uint8List? inputData, - String? withIpAddress}) { + Uint8List? inputData}) { return handler.executeNormal(NormalTask( callFfi: (port_) { var arg0 = cst_encode_my_method(method); var arg1 = cst_encode_String(url); var arg2 = cst_encode_opt_Map_String_String(headers); var arg3 = cst_encode_opt_list_prim_u_8_strict(inputData); - var arg4 = cst_encode_opt_String(withIpAddress); return wire.wire__crate__api__http_api__fetch( - port_, arg0, arg1, arg2, arg3, arg4); + port_, arg0, arg1, arg2, arg3); }, codec: DcoCodec( decodeSuccessData: dco_decode_rust_http_response, decodeErrorData: dco_decode_AnyhowException, ), constMeta: kCrateApiHttpApiFetchConstMeta, - argValues: [method, url, headers, inputData, withIpAddress], + argValues: [method, url, headers, inputData], apiImpl: this, )); } TaskConstMeta get kCrateApiHttpApiFetchConstMeta => const TaskConstMeta( debugName: "fetch", - argNames: ["method", "url", "headers", "inputData", "withIpAddress"], + argNames: ["method", "url", "headers", "inputData"], ); @override @@ -278,113 +150,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { argNames: ["headers"], ); - @override - Stream crateApiRsProcessStart( - {required String executable, - required List arguments, - required String workingDirectory}) { - final streamSink = RustStreamSink(); - unawaited(handler.executeNormal(NormalTask( - callFfi: (port_) { - var arg0 = cst_encode_String(executable); - var arg1 = cst_encode_list_String(arguments); - var arg2 = cst_encode_String(workingDirectory); - var arg3 = cst_encode_StreamSink_rs_process_stream_data_Dco(streamSink); - return wire.wire__crate__api__rs_process__start( - port_, arg0, arg1, arg2, arg3); - }, - codec: DcoCodec( - decodeSuccessData: dco_decode_unit, - decodeErrorData: null, - ), - constMeta: kCrateApiRsProcessStartConstMeta, - argValues: [executable, arguments, workingDirectory, streamSink], - apiImpl: this, - ))); - return streamSink.stream; - } - - TaskConstMeta get kCrateApiRsProcessStartConstMeta => const TaskConstMeta( - debugName: "start", - argNames: ["executable", "arguments", "workingDirectory", "streamSink"], - ); - - @override - Future crateApiRsProcessWrite( - {required int rsPid, required String data}) { - return handler.executeNormal(NormalTask( - callFfi: (port_) { - var arg0 = cst_encode_u_32(rsPid); - var arg1 = cst_encode_String(data); - return wire.wire__crate__api__rs_process__write(port_, arg0, arg1); - }, - codec: DcoCodec( - decodeSuccessData: dco_decode_unit, - decodeErrorData: null, - ), - constMeta: kCrateApiRsProcessWriteConstMeta, - argValues: [rsPid, data], - apiImpl: this, - )); - } - - TaskConstMeta get kCrateApiRsProcessWriteConstMeta => const TaskConstMeta( - debugName: "write", - argNames: ["rsPid", "data"], - ); - - @override - Future crateApiWin32ApiSendNotify( - {String? summary, String? body, String? appName, String? appId}) { - return handler.executeNormal(NormalTask( - callFfi: (port_) { - var arg0 = cst_encode_opt_String(summary); - var arg1 = cst_encode_opt_String(body); - var arg2 = cst_encode_opt_String(appName); - var arg3 = cst_encode_opt_String(appId); - return wire.wire__crate__api__win32_api__send_notify( - port_, arg0, arg1, arg2, arg3); - }, - codec: DcoCodec( - decodeSuccessData: dco_decode_unit, - decodeErrorData: dco_decode_AnyhowException, - ), - constMeta: kCrateApiWin32ApiSendNotifyConstMeta, - argValues: [summary, body, appName, appId], - apiImpl: this, - )); - } - - TaskConstMeta get kCrateApiWin32ApiSendNotifyConstMeta => const TaskConstMeta( - debugName: "send_notify", - argNames: ["summary", "body", "appName", "appId"], - ); - - @override - Future crateApiWin32ApiSetForegroundWindow( - {required String windowName}) { - return handler.executeNormal(NormalTask( - callFfi: (port_) { - var arg0 = cst_encode_String(windowName); - return wire.wire__crate__api__win32_api__set_foreground_window( - port_, arg0); - }, - codec: DcoCodec( - decodeSuccessData: dco_decode_bool, - decodeErrorData: dco_decode_AnyhowException, - ), - constMeta: kCrateApiWin32ApiSetForegroundWindowConstMeta, - argValues: [windowName], - apiImpl: this, - )); - } - - TaskConstMeta get kCrateApiWin32ApiSetForegroundWindowConstMeta => - const TaskConstMeta( - debugName: "set_foreground_window", - argNames: ["windowName"], - ); - @protected AnyhowException dco_decode_AnyhowException(dynamic raw) { // Codec=Dco (DartCObject based), see doc to use other codecs @@ -398,32 +163,12 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { .map((e) => MapEntry(e.$1, e.$2))); } - @protected - RustStreamSink - dco_decode_StreamSink_rs_process_stream_data_Dco(dynamic raw) { - // Codec=Dco (DartCObject based), see doc to use other codecs - throw UnimplementedError(); - } - @protected String dco_decode_String(dynamic raw) { // Codec=Dco (DartCObject based), see doc to use other codecs return raw as String; } - @protected - bool dco_decode_bool(dynamic raw) { - // Codec=Dco (DartCObject based), see doc to use other codecs - return raw as bool; - } - - @protected - RsiLauncherAsarData dco_decode_box_autoadd_rsi_launcher_asar_data( - dynamic raw) { - // Codec=Dco (DartCObject based), see doc to use other codecs - return dco_decode_rsi_launcher_asar_data(raw); - } - @protected BigInt dco_decode_box_autoadd_u_64(dynamic raw) { // Codec=Dco (DartCObject based), see doc to use other codecs @@ -436,18 +181,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { return raw as int; } - @protected - List dco_decode_list_String(dynamic raw) { - // Codec=Dco (DartCObject based), see doc to use other codecs - return (raw as List).map(dco_decode_String).toList(); - } - - @protected - List dco_decode_list_prim_u_8_loose(dynamic raw) { - // Codec=Dco (DartCObject based), see doc to use other codecs - return raw as List; - } - @protected Uint8List dco_decode_list_prim_u_8_strict(dynamic raw) { // Codec=Dco (DartCObject based), see doc to use other codecs @@ -460,12 +193,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { return (raw as List).map(dco_decode_record_string_string).toList(); } - @protected - MyHttpVersion dco_decode_my_http_version(dynamic raw) { - // Codec=Dco (DartCObject based), see doc to use other codecs - return MyHttpVersion.values[raw as int]; - } - @protected MyMethod dco_decode_my_method(dynamic raw) { // Codec=Dco (DartCObject based), see doc to use other codecs @@ -478,12 +205,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { return raw == null ? null : dco_decode_Map_String_String(raw); } - @protected - String? dco_decode_opt_String(dynamic raw) { - // Codec=Dco (DartCObject based), see doc to use other codecs - return raw == null ? null : dco_decode_String(raw); - } - @protected BigInt? dco_decode_opt_box_autoadd_u_64(dynamic raw) { // Codec=Dco (DartCObject based), see doc to use other codecs @@ -509,52 +230,18 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { ); } - @protected - RsProcessStreamData dco_decode_rs_process_stream_data(dynamic raw) { - // Codec=Dco (DartCObject based), see doc to use other codecs - final arr = raw as List; - if (arr.length != 3) - throw Exception('unexpected arr length: expect 3 but see ${arr.length}'); - return RsProcessStreamData( - dataType: dco_decode_rs_process_stream_data_type(arr[0]), - data: dco_decode_String(arr[1]), - rsPid: dco_decode_u_32(arr[2]), - ); - } - - @protected - RsProcessStreamDataType dco_decode_rs_process_stream_data_type(dynamic raw) { - // Codec=Dco (DartCObject based), see doc to use other codecs - return RsProcessStreamDataType.values[raw as int]; - } - - @protected - RsiLauncherAsarData dco_decode_rsi_launcher_asar_data(dynamic raw) { - // Codec=Dco (DartCObject based), see doc to use other codecs - final arr = raw as List; - if (arr.length != 3) - throw Exception('unexpected arr length: expect 3 but see ${arr.length}'); - return RsiLauncherAsarData( - asarPath: dco_decode_String(arr[0]), - mainJsPath: dco_decode_String(arr[1]), - mainJsContent: dco_decode_list_prim_u_8_strict(arr[2]), - ); - } - @protected RustHttpResponse dco_decode_rust_http_response(dynamic raw) { // Codec=Dco (DartCObject based), see doc to use other codecs final arr = raw as List; - if (arr.length != 7) - throw Exception('unexpected arr length: expect 7 but see ${arr.length}'); + if (arr.length != 5) + throw Exception('unexpected arr length: expect 5 but see ${arr.length}'); return RustHttpResponse( statusCode: dco_decode_u_16(arr[0]), headers: dco_decode_Map_String_String(arr[1]), url: dco_decode_String(arr[2]), contentLength: dco_decode_opt_box_autoadd_u_64(arr[3]), - version: dco_decode_my_http_version(arr[4]), - remoteAddr: dco_decode_String(arr[5]), - data: dco_decode_opt_list_prim_u_8_strict(arr[6]), + data: dco_decode_opt_list_prim_u_8_strict(arr[4]), ); } @@ -564,12 +251,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { return raw as int; } - @protected - int dco_decode_u_32(dynamic raw) { - // Codec=Dco (DartCObject based), see doc to use other codecs - return raw as int; - } - @protected BigInt dco_decode_u_64(dynamic raw) { // Codec=Dco (DartCObject based), see doc to use other codecs @@ -603,14 +284,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { return Map.fromEntries(inner.map((e) => MapEntry(e.$1, e.$2))); } - @protected - RustStreamSink - sse_decode_StreamSink_rs_process_stream_data_Dco( - SseDeserializer deserializer) { - // Codec=Sse (Serialization based), see doc to use other codecs - throw UnimplementedError('Unreachable ()'); - } - @protected String sse_decode_String(SseDeserializer deserializer) { // Codec=Sse (Serialization based), see doc to use other codecs @@ -618,19 +291,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { return utf8.decoder.convert(inner); } - @protected - bool sse_decode_bool(SseDeserializer deserializer) { - // Codec=Sse (Serialization based), see doc to use other codecs - return deserializer.buffer.getUint8() != 0; - } - - @protected - RsiLauncherAsarData sse_decode_box_autoadd_rsi_launcher_asar_data( - SseDeserializer deserializer) { - // Codec=Sse (Serialization based), see doc to use other codecs - return (sse_decode_rsi_launcher_asar_data(deserializer)); - } - @protected BigInt sse_decode_box_autoadd_u_64(SseDeserializer deserializer) { // Codec=Sse (Serialization based), see doc to use other codecs @@ -643,25 +303,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { return deserializer.buffer.getInt32(); } - @protected - List sse_decode_list_String(SseDeserializer deserializer) { - // Codec=Sse (Serialization based), see doc to use other codecs - - var len_ = sse_decode_i_32(deserializer); - var ans_ = []; - for (var idx_ = 0; idx_ < len_; ++idx_) { - ans_.add(sse_decode_String(deserializer)); - } - return ans_; - } - - @protected - List sse_decode_list_prim_u_8_loose(SseDeserializer deserializer) { - // Codec=Sse (Serialization based), see doc to use other codecs - var len_ = sse_decode_i_32(deserializer); - return deserializer.buffer.getUint8List(len_); - } - @protected Uint8List sse_decode_list_prim_u_8_strict(SseDeserializer deserializer) { // Codec=Sse (Serialization based), see doc to use other codecs @@ -682,13 +323,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { return ans_; } - @protected - MyHttpVersion sse_decode_my_http_version(SseDeserializer deserializer) { - // Codec=Sse (Serialization based), see doc to use other codecs - var inner = sse_decode_i_32(deserializer); - return MyHttpVersion.values[inner]; - } - @protected MyMethod sse_decode_my_method(SseDeserializer deserializer) { // Codec=Sse (Serialization based), see doc to use other codecs @@ -708,17 +342,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { } } - @protected - String? sse_decode_opt_String(SseDeserializer deserializer) { - // Codec=Sse (Serialization based), see doc to use other codecs - - if (sse_decode_bool(deserializer)) { - return (sse_decode_String(deserializer)); - } else { - return null; - } - } - @protected BigInt? sse_decode_opt_box_autoadd_u_64(SseDeserializer deserializer) { // Codec=Sse (Serialization based), see doc to use other codecs @@ -750,38 +373,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { return (var_field0, var_field1); } - @protected - RsProcessStreamData sse_decode_rs_process_stream_data( - SseDeserializer deserializer) { - // Codec=Sse (Serialization based), see doc to use other codecs - var var_dataType = sse_decode_rs_process_stream_data_type(deserializer); - var var_data = sse_decode_String(deserializer); - var var_rsPid = sse_decode_u_32(deserializer); - return RsProcessStreamData( - dataType: var_dataType, data: var_data, rsPid: var_rsPid); - } - - @protected - RsProcessStreamDataType sse_decode_rs_process_stream_data_type( - SseDeserializer deserializer) { - // Codec=Sse (Serialization based), see doc to use other codecs - var inner = sse_decode_i_32(deserializer); - return RsProcessStreamDataType.values[inner]; - } - - @protected - RsiLauncherAsarData sse_decode_rsi_launcher_asar_data( - SseDeserializer deserializer) { - // Codec=Sse (Serialization based), see doc to use other codecs - var var_asarPath = sse_decode_String(deserializer); - var var_mainJsPath = sse_decode_String(deserializer); - var var_mainJsContent = sse_decode_list_prim_u_8_strict(deserializer); - return RsiLauncherAsarData( - asarPath: var_asarPath, - mainJsPath: var_mainJsPath, - mainJsContent: var_mainJsContent); - } - @protected RustHttpResponse sse_decode_rust_http_response(SseDeserializer deserializer) { // Codec=Sse (Serialization based), see doc to use other codecs @@ -789,16 +380,12 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { var var_headers = sse_decode_Map_String_String(deserializer); var var_url = sse_decode_String(deserializer); var var_contentLength = sse_decode_opt_box_autoadd_u_64(deserializer); - var var_version = sse_decode_my_http_version(deserializer); - var var_remoteAddr = sse_decode_String(deserializer); var var_data = sse_decode_opt_list_prim_u_8_strict(deserializer); return RustHttpResponse( statusCode: var_statusCode, headers: var_headers, url: var_url, contentLength: var_contentLength, - version: var_version, - remoteAddr: var_remoteAddr, data: var_data); } @@ -808,12 +395,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { return deserializer.buffer.getUint16(); } - @protected - int sse_decode_u_32(SseDeserializer deserializer) { - // Codec=Sse (Serialization based), see doc to use other codecs - return deserializer.buffer.getUint32(); - } - @protected BigInt sse_decode_u_64(SseDeserializer deserializer) { // Codec=Sse (Serialization based), see doc to use other codecs @@ -832,9 +413,9 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { } @protected - bool cst_encode_bool(bool raw) { - // Codec=Cst (C-struct based), see doc to use other codecs - return raw; + bool sse_decode_bool(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return deserializer.buffer.getUint8() != 0; } @protected @@ -843,36 +424,18 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { return raw; } - @protected - int cst_encode_my_http_version(MyHttpVersion raw) { - // Codec=Cst (C-struct based), see doc to use other codecs - return cst_encode_i_32(raw.index); - } - @protected int cst_encode_my_method(MyMethod raw) { // Codec=Cst (C-struct based), see doc to use other codecs return cst_encode_i_32(raw.index); } - @protected - int cst_encode_rs_process_stream_data_type(RsProcessStreamDataType raw) { - // Codec=Cst (C-struct based), see doc to use other codecs - return cst_encode_i_32(raw.index); - } - @protected int cst_encode_u_16(int raw) { // Codec=Cst (C-struct based), see doc to use other codecs return raw; } - @protected - int cst_encode_u_32(int raw) { - // Codec=Cst (C-struct based), see doc to use other codecs - return raw; - } - @protected int cst_encode_u_8(int raw) { // Codec=Cst (C-struct based), see doc to use other codecs @@ -900,38 +463,12 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { self.entries.map((e) => (e.key, e.value)).toList(), serializer); } - @protected - void sse_encode_StreamSink_rs_process_stream_data_Dco( - RustStreamSink self, SseSerializer serializer) { - // Codec=Sse (Serialization based), see doc to use other codecs - sse_encode_String( - self.setupAndSerialize( - codec: DcoCodec( - decodeSuccessData: dco_decode_rs_process_stream_data, - decodeErrorData: dco_decode_AnyhowException, - )), - serializer); - } - @protected void sse_encode_String(String self, SseSerializer serializer) { // Codec=Sse (Serialization based), see doc to use other codecs sse_encode_list_prim_u_8_strict(utf8.encoder.convert(self), serializer); } - @protected - void sse_encode_bool(bool self, SseSerializer serializer) { - // Codec=Sse (Serialization based), see doc to use other codecs - serializer.buffer.putUint8(self ? 1 : 0); - } - - @protected - void sse_encode_box_autoadd_rsi_launcher_asar_data( - RsiLauncherAsarData self, SseSerializer serializer) { - // Codec=Sse (Serialization based), see doc to use other codecs - sse_encode_rsi_launcher_asar_data(self, serializer); - } - @protected void sse_encode_box_autoadd_u_64(BigInt self, SseSerializer serializer) { // Codec=Sse (Serialization based), see doc to use other codecs @@ -944,24 +481,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { serializer.buffer.putInt32(self); } - @protected - void sse_encode_list_String(List self, SseSerializer serializer) { - // Codec=Sse (Serialization based), see doc to use other codecs - sse_encode_i_32(self.length, serializer); - for (final item in self) { - sse_encode_String(item, serializer); - } - } - - @protected - void sse_encode_list_prim_u_8_loose( - List self, SseSerializer serializer) { - // Codec=Sse (Serialization based), see doc to use other codecs - sse_encode_i_32(self.length, serializer); - serializer.buffer - .putUint8List(self is Uint8List ? self : Uint8List.fromList(self)); - } - @protected void sse_encode_list_prim_u_8_strict( Uint8List self, SseSerializer serializer) { @@ -980,13 +499,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { } } - @protected - void sse_encode_my_http_version( - MyHttpVersion self, SseSerializer serializer) { - // Codec=Sse (Serialization based), see doc to use other codecs - sse_encode_i_32(self.index, serializer); - } - @protected void sse_encode_my_method(MyMethod self, SseSerializer serializer) { // Codec=Sse (Serialization based), see doc to use other codecs @@ -1004,16 +516,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { } } - @protected - void sse_encode_opt_String(String? self, SseSerializer serializer) { - // Codec=Sse (Serialization based), see doc to use other codecs - - sse_encode_bool(self != null, serializer); - if (self != null) { - sse_encode_String(self, serializer); - } - } - @protected void sse_encode_opt_box_autoadd_u_64(BigInt? self, SseSerializer serializer) { // Codec=Sse (Serialization based), see doc to use other codecs @@ -1043,31 +545,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { sse_encode_String(self.$2, serializer); } - @protected - void sse_encode_rs_process_stream_data( - RsProcessStreamData self, SseSerializer serializer) { - // Codec=Sse (Serialization based), see doc to use other codecs - sse_encode_rs_process_stream_data_type(self.dataType, serializer); - sse_encode_String(self.data, serializer); - sse_encode_u_32(self.rsPid, serializer); - } - - @protected - void sse_encode_rs_process_stream_data_type( - RsProcessStreamDataType self, SseSerializer serializer) { - // Codec=Sse (Serialization based), see doc to use other codecs - sse_encode_i_32(self.index, serializer); - } - - @protected - void sse_encode_rsi_launcher_asar_data( - RsiLauncherAsarData self, SseSerializer serializer) { - // Codec=Sse (Serialization based), see doc to use other codecs - sse_encode_String(self.asarPath, serializer); - sse_encode_String(self.mainJsPath, serializer); - sse_encode_list_prim_u_8_strict(self.mainJsContent, serializer); - } - @protected void sse_encode_rust_http_response( RustHttpResponse self, SseSerializer serializer) { @@ -1076,8 +553,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { sse_encode_Map_String_String(self.headers, serializer); sse_encode_String(self.url, serializer); sse_encode_opt_box_autoadd_u_64(self.contentLength, serializer); - sse_encode_my_http_version(self.version, serializer); - sse_encode_String(self.remoteAddr, serializer); sse_encode_opt_list_prim_u_8_strict(self.data, serializer); } @@ -1087,12 +562,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { serializer.buffer.putUint16(self); } - @protected - void sse_encode_u_32(int self, SseSerializer serializer) { - // Codec=Sse (Serialization based), see doc to use other codecs - serializer.buffer.putUint32(self); - } - @protected void sse_encode_u_64(BigInt self, SseSerializer serializer) { // Codec=Sse (Serialization based), see doc to use other codecs @@ -1109,4 +578,10 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { void sse_encode_unit(void self, SseSerializer serializer) { // Codec=Sse (Serialization based), see doc to use other codecs } + + @protected + void sse_encode_bool(bool self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + serializer.buffer.putUint8(self ? 1 : 0); + } } diff --git a/lib/common/rust/frb_generated.io.dart b/lib/common/rust/frb_generated.io.dart index 67668b4..2574621 100644 --- a/lib/common/rust/frb_generated.io.dart +++ b/lib/common/rust/frb_generated.io.dart @@ -3,10 +3,7 @@ // ignore_for_file: unused_import, unused_element, unnecessary_import, duplicate_ignore, invalid_use_of_internal_member, annotate_overrides, non_constant_identifier_names, curly_braces_in_flow_control_structures, prefer_const_literals_to_create_immutables, unused_field -import 'api/asar_api.dart'; import 'api/http_api.dart'; -import 'api/rs_process.dart'; -import 'api/win32_api.dart'; import 'dart:async'; import 'dart:convert'; import 'dart:ffi' as ffi; @@ -28,50 +25,27 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { @protected Map dco_decode_Map_String_String(dynamic raw); - @protected - RustStreamSink - dco_decode_StreamSink_rs_process_stream_data_Dco(dynamic raw); - @protected String dco_decode_String(dynamic raw); - @protected - bool dco_decode_bool(dynamic raw); - - @protected - RsiLauncherAsarData dco_decode_box_autoadd_rsi_launcher_asar_data( - dynamic raw); - @protected BigInt dco_decode_box_autoadd_u_64(dynamic raw); @protected int dco_decode_i_32(dynamic raw); - @protected - List dco_decode_list_String(dynamic raw); - - @protected - List dco_decode_list_prim_u_8_loose(dynamic raw); - @protected Uint8List dco_decode_list_prim_u_8_strict(dynamic raw); @protected List<(String, String)> dco_decode_list_record_string_string(dynamic raw); - @protected - MyHttpVersion dco_decode_my_http_version(dynamic raw); - @protected MyMethod dco_decode_my_method(dynamic raw); @protected Map? dco_decode_opt_Map_String_String(dynamic raw); - @protected - String? dco_decode_opt_String(dynamic raw); - @protected BigInt? dco_decode_opt_box_autoadd_u_64(dynamic raw); @@ -81,24 +55,12 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { @protected (String, String) dco_decode_record_string_string(dynamic raw); - @protected - RsProcessStreamData dco_decode_rs_process_stream_data(dynamic raw); - - @protected - RsProcessStreamDataType dco_decode_rs_process_stream_data_type(dynamic raw); - - @protected - RsiLauncherAsarData dco_decode_rsi_launcher_asar_data(dynamic raw); - @protected RustHttpResponse dco_decode_rust_http_response(dynamic raw); @protected int dco_decode_u_16(dynamic raw); - @protected - int dco_decode_u_32(dynamic raw); - @protected BigInt dco_decode_u_64(dynamic raw); @@ -115,33 +77,15 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { Map sse_decode_Map_String_String( SseDeserializer deserializer); - @protected - RustStreamSink - sse_decode_StreamSink_rs_process_stream_data_Dco( - SseDeserializer deserializer); - @protected String sse_decode_String(SseDeserializer deserializer); - @protected - bool sse_decode_bool(SseDeserializer deserializer); - - @protected - RsiLauncherAsarData sse_decode_box_autoadd_rsi_launcher_asar_data( - SseDeserializer deserializer); - @protected BigInt sse_decode_box_autoadd_u_64(SseDeserializer deserializer); @protected int sse_decode_i_32(SseDeserializer deserializer); - @protected - List sse_decode_list_String(SseDeserializer deserializer); - - @protected - List sse_decode_list_prim_u_8_loose(SseDeserializer deserializer); - @protected Uint8List sse_decode_list_prim_u_8_strict(SseDeserializer deserializer); @@ -149,9 +93,6 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { List<(String, String)> sse_decode_list_record_string_string( SseDeserializer deserializer); - @protected - MyHttpVersion sse_decode_my_http_version(SseDeserializer deserializer); - @protected MyMethod sse_decode_my_method(SseDeserializer deserializer); @@ -159,9 +100,6 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { Map? sse_decode_opt_Map_String_String( SseDeserializer deserializer); - @protected - String? sse_decode_opt_String(SseDeserializer deserializer); - @protected BigInt? sse_decode_opt_box_autoadd_u_64(SseDeserializer deserializer); @@ -172,27 +110,12 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { (String, String) sse_decode_record_string_string( SseDeserializer deserializer); - @protected - RsProcessStreamData sse_decode_rs_process_stream_data( - SseDeserializer deserializer); - - @protected - RsProcessStreamDataType sse_decode_rs_process_stream_data_type( - SseDeserializer deserializer); - - @protected - RsiLauncherAsarData sse_decode_rsi_launcher_asar_data( - SseDeserializer deserializer); - @protected RustHttpResponse sse_decode_rust_http_response(SseDeserializer deserializer); @protected int sse_decode_u_16(SseDeserializer deserializer); - @protected - int sse_decode_u_32(SseDeserializer deserializer); - @protected BigInt sse_decode_u_64(SseDeserializer deserializer); @@ -202,6 +125,9 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { @protected void sse_decode_unit(SseDeserializer deserializer); + @protected + bool sse_decode_bool(SseDeserializer deserializer); + @protected ffi.Pointer cst_encode_AnyhowException( AnyhowException raw) { @@ -217,58 +143,18 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { raw.entries.map((e) => (e.key, e.value)).toList()); } - @protected - ffi.Pointer - cst_encode_StreamSink_rs_process_stream_data_Dco( - RustStreamSink raw) { - // Codec=Cst (C-struct based), see doc to use other codecs - return cst_encode_String(raw.setupAndSerialize( - codec: DcoCodec( - decodeSuccessData: dco_decode_rs_process_stream_data, - decodeErrorData: dco_decode_AnyhowException, - ))); - } - @protected ffi.Pointer cst_encode_String(String raw) { // Codec=Cst (C-struct based), see doc to use other codecs return cst_encode_list_prim_u_8_strict(utf8.encoder.convert(raw)); } - @protected - ffi.Pointer - cst_encode_box_autoadd_rsi_launcher_asar_data(RsiLauncherAsarData raw) { - // Codec=Cst (C-struct based), see doc to use other codecs - final ptr = wire.cst_new_box_autoadd_rsi_launcher_asar_data(); - cst_api_fill_to_wire_rsi_launcher_asar_data(raw, ptr.ref); - return ptr; - } - @protected ffi.Pointer cst_encode_box_autoadd_u_64(BigInt raw) { // Codec=Cst (C-struct based), see doc to use other codecs return wire.cst_new_box_autoadd_u_64(cst_encode_u_64(raw)); } - @protected - ffi.Pointer cst_encode_list_String(List raw) { - // Codec=Cst (C-struct based), see doc to use other codecs - final ans = wire.cst_new_list_String(raw.length); - for (var i = 0; i < raw.length; ++i) { - ans.ref.ptr[i] = cst_encode_String(raw[i]); - } - return ans; - } - - @protected - ffi.Pointer cst_encode_list_prim_u_8_loose( - List raw) { - // Codec=Cst (C-struct based), see doc to use other codecs - final ans = wire.cst_new_list_prim_u_8_loose(raw.length); - ans.ref.ptr.asTypedList(raw.length).setAll(0, raw); - return ans; - } - @protected ffi.Pointer cst_encode_list_prim_u_8_strict( Uint8List raw) { @@ -296,13 +182,6 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { return raw == null ? ffi.nullptr : cst_encode_Map_String_String(raw); } - @protected - ffi.Pointer cst_encode_opt_String( - String? raw) { - // Codec=Cst (C-struct based), see doc to use other codecs - return raw == null ? ffi.nullptr : cst_encode_String(raw); - } - @protected ffi.Pointer cst_encode_opt_box_autoadd_u_64(BigInt? raw) { // Codec=Cst (C-struct based), see doc to use other codecs @@ -322,13 +201,6 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { return raw.toSigned(64).toInt(); } - @protected - void cst_api_fill_to_wire_box_autoadd_rsi_launcher_asar_data( - RsiLauncherAsarData apiObj, - ffi.Pointer wireObj) { - cst_api_fill_to_wire_rsi_launcher_asar_data(apiObj, wireObj.ref); - } - @protected void cst_api_fill_to_wire_record_string_string( (String, String) apiObj, wire_cst_record_string_string wireObj) { @@ -336,23 +208,6 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { wireObj.field1 = cst_encode_String(apiObj.$2); } - @protected - void cst_api_fill_to_wire_rs_process_stream_data( - RsProcessStreamData apiObj, wire_cst_rs_process_stream_data wireObj) { - wireObj.data_type = cst_encode_rs_process_stream_data_type(apiObj.dataType); - wireObj.data = cst_encode_String(apiObj.data); - wireObj.rs_pid = cst_encode_u_32(apiObj.rsPid); - } - - @protected - void cst_api_fill_to_wire_rsi_launcher_asar_data( - RsiLauncherAsarData apiObj, wire_cst_rsi_launcher_asar_data wireObj) { - wireObj.asar_path = cst_encode_String(apiObj.asarPath); - wireObj.main_js_path = cst_encode_String(apiObj.mainJsPath); - wireObj.main_js_content = - cst_encode_list_prim_u_8_strict(apiObj.mainJsContent); - } - @protected void cst_api_fill_to_wire_rust_http_response( RustHttpResponse apiObj, wire_cst_rust_http_response wireObj) { @@ -361,32 +216,18 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { wireObj.url = cst_encode_String(apiObj.url); wireObj.content_length = cst_encode_opt_box_autoadd_u_64(apiObj.contentLength); - wireObj.version = cst_encode_my_http_version(apiObj.version); - wireObj.remote_addr = cst_encode_String(apiObj.remoteAddr); wireObj.data = cst_encode_opt_list_prim_u_8_strict(apiObj.data); } - @protected - bool cst_encode_bool(bool raw); - @protected int cst_encode_i_32(int raw); - @protected - int cst_encode_my_http_version(MyHttpVersion raw); - @protected int cst_encode_my_method(MyMethod raw); - @protected - int cst_encode_rs_process_stream_data_type(RsProcessStreamDataType raw); - @protected int cst_encode_u_16(int raw); - @protected - int cst_encode_u_32(int raw); - @protected int cst_encode_u_8(int raw); @@ -401,32 +242,15 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { void sse_encode_Map_String_String( Map self, SseSerializer serializer); - @protected - void sse_encode_StreamSink_rs_process_stream_data_Dco( - RustStreamSink self, SseSerializer serializer); - @protected void sse_encode_String(String self, SseSerializer serializer); - @protected - void sse_encode_bool(bool self, SseSerializer serializer); - - @protected - void sse_encode_box_autoadd_rsi_launcher_asar_data( - RsiLauncherAsarData self, SseSerializer serializer); - @protected void sse_encode_box_autoadd_u_64(BigInt self, SseSerializer serializer); @protected void sse_encode_i_32(int self, SseSerializer serializer); - @protected - void sse_encode_list_String(List self, SseSerializer serializer); - - @protected - void sse_encode_list_prim_u_8_loose(List self, SseSerializer serializer); - @protected void sse_encode_list_prim_u_8_strict( Uint8List self, SseSerializer serializer); @@ -435,9 +259,6 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { void sse_encode_list_record_string_string( List<(String, String)> self, SseSerializer serializer); - @protected - void sse_encode_my_http_version(MyHttpVersion self, SseSerializer serializer); - @protected void sse_encode_my_method(MyMethod self, SseSerializer serializer); @@ -445,9 +266,6 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { void sse_encode_opt_Map_String_String( Map? self, SseSerializer serializer); - @protected - void sse_encode_opt_String(String? self, SseSerializer serializer); - @protected void sse_encode_opt_box_autoadd_u_64(BigInt? self, SseSerializer serializer); @@ -459,18 +277,6 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { void sse_encode_record_string_string( (String, String) self, SseSerializer serializer); - @protected - void sse_encode_rs_process_stream_data( - RsProcessStreamData self, SseSerializer serializer); - - @protected - void sse_encode_rs_process_stream_data_type( - RsProcessStreamDataType self, SseSerializer serializer); - - @protected - void sse_encode_rsi_launcher_asar_data( - RsiLauncherAsarData self, SseSerializer serializer); - @protected void sse_encode_rust_http_response( RustHttpResponse self, SseSerializer serializer); @@ -478,9 +284,6 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { @protected void sse_encode_u_16(int self, SseSerializer serializer); - @protected - void sse_encode_u_32(int self, SseSerializer serializer); - @protected void sse_encode_u_64(BigInt self, SseSerializer serializer); @@ -489,6 +292,9 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { @protected void sse_encode_unit(void self, SseSerializer serializer); + + @protected + void sse_encode_bool(bool self, SseSerializer serializer); } // Section: wire_class @@ -532,96 +338,12 @@ class RustLibWire implements BaseWire { late final _store_dart_post_cobject = _store_dart_post_cobjectPtr .asFunction(); - void wire__crate__api__asar_api__get_rsi_launcher_asar_data( - int port_, - ffi.Pointer asar_path, - ) { - return _wire__crate__api__asar_api__get_rsi_launcher_asar_data( - port_, - asar_path, - ); - } - - late final _wire__crate__api__asar_api__get_rsi_launcher_asar_dataPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Int64, ffi.Pointer)>>( - 'frbgen_starcitizen_doctor_wire__crate__api__asar_api__get_rsi_launcher_asar_data'); - late final _wire__crate__api__asar_api__get_rsi_launcher_asar_data = - _wire__crate__api__asar_api__get_rsi_launcher_asar_dataPtr.asFunction< - void Function(int, ffi.Pointer)>(); - - void wire__crate__api__asar_api__rsi_launcher_asar_data_write_main_js( - int port_, - ffi.Pointer that, - ffi.Pointer content, - ) { - return _wire__crate__api__asar_api__rsi_launcher_asar_data_write_main_js( - port_, - that, - content, - ); - } - - late final _wire__crate__api__asar_api__rsi_launcher_asar_data_write_main_jsPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Int64, - ffi.Pointer, - ffi.Pointer)>>( - 'frbgen_starcitizen_doctor_wire__crate__api__asar_api__rsi_launcher_asar_data_write_main_js'); - late final _wire__crate__api__asar_api__rsi_launcher_asar_data_write_main_js = - _wire__crate__api__asar_api__rsi_launcher_asar_data_write_main_jsPtr - .asFunction< - void Function(int, ffi.Pointer, - ffi.Pointer)>(); - - void wire__crate__api__http_api__dns_lookup_ips( - int port_, - ffi.Pointer host, - ) { - return _wire__crate__api__http_api__dns_lookup_ips( - port_, - host, - ); - } - - late final _wire__crate__api__http_api__dns_lookup_ipsPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Int64, ffi.Pointer)>>( - 'frbgen_starcitizen_doctor_wire__crate__api__http_api__dns_lookup_ips'); - late final _wire__crate__api__http_api__dns_lookup_ips = - _wire__crate__api__http_api__dns_lookup_ipsPtr.asFunction< - void Function(int, ffi.Pointer)>(); - - void wire__crate__api__http_api__dns_lookup_txt( - int port_, - ffi.Pointer host, - ) { - return _wire__crate__api__http_api__dns_lookup_txt( - port_, - host, - ); - } - - late final _wire__crate__api__http_api__dns_lookup_txtPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Int64, ffi.Pointer)>>( - 'frbgen_starcitizen_doctor_wire__crate__api__http_api__dns_lookup_txt'); - late final _wire__crate__api__http_api__dns_lookup_txt = - _wire__crate__api__http_api__dns_lookup_txtPtr.asFunction< - void Function(int, ffi.Pointer)>(); - void wire__crate__api__http_api__fetch( int port_, int method, ffi.Pointer url, ffi.Pointer headers, ffi.Pointer input_data, - ffi.Pointer with_ip_address, ) { return _wire__crate__api__http_api__fetch( port_, @@ -629,7 +351,6 @@ class RustLibWire implements BaseWire { url, headers, input_data, - with_ip_address, ); } @@ -640,7 +361,6 @@ class RustLibWire implements BaseWire { ffi.Int32, ffi.Pointer, ffi.Pointer, - ffi.Pointer, ffi.Pointer)>>( 'frbgen_starcitizen_doctor_wire__crate__api__http_api__fetch'); late final _wire__crate__api__http_api__fetch = @@ -650,7 +370,6 @@ class RustLibWire implements BaseWire { int, ffi.Pointer, ffi.Pointer, - ffi.Pointer, ffi.Pointer)>(); void wire__crate__api__http_api__set_default_header( @@ -673,128 +392,6 @@ class RustLibWire implements BaseWire { void Function( int, ffi.Pointer)>(); - void wire__crate__api__rs_process__start( - int port_, - ffi.Pointer executable, - ffi.Pointer arguments, - ffi.Pointer working_directory, - ffi.Pointer stream_sink, - ) { - return _wire__crate__api__rs_process__start( - port_, - executable, - arguments, - working_directory, - stream_sink, - ); - } - - late final _wire__crate__api__rs_process__startPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Int64, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>>( - 'frbgen_starcitizen_doctor_wire__crate__api__rs_process__start'); - late final _wire__crate__api__rs_process__start = - _wire__crate__api__rs_process__startPtr.asFunction< - void Function( - int, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>(); - - void wire__crate__api__rs_process__write( - int port_, - int rs_pid, - ffi.Pointer data, - ) { - return _wire__crate__api__rs_process__write( - port_, - rs_pid, - data, - ); - } - - late final _wire__crate__api__rs_process__writePtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Int64, ffi.Uint32, - ffi.Pointer)>>( - 'frbgen_starcitizen_doctor_wire__crate__api__rs_process__write'); - late final _wire__crate__api__rs_process__write = - _wire__crate__api__rs_process__writePtr.asFunction< - void Function( - int, int, ffi.Pointer)>(); - - void wire__crate__api__win32_api__send_notify( - int port_, - ffi.Pointer summary, - ffi.Pointer body, - ffi.Pointer app_name, - ffi.Pointer app_id, - ) { - return _wire__crate__api__win32_api__send_notify( - port_, - summary, - body, - app_name, - app_id, - ); - } - - late final _wire__crate__api__win32_api__send_notifyPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Int64, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>>( - 'frbgen_starcitizen_doctor_wire__crate__api__win32_api__send_notify'); - late final _wire__crate__api__win32_api__send_notify = - _wire__crate__api__win32_api__send_notifyPtr.asFunction< - void Function( - int, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>(); - - void wire__crate__api__win32_api__set_foreground_window( - int port_, - ffi.Pointer window_name, - ) { - return _wire__crate__api__win32_api__set_foreground_window( - port_, - window_name, - ); - } - - late final _wire__crate__api__win32_api__set_foreground_windowPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Int64, ffi.Pointer)>>( - 'frbgen_starcitizen_doctor_wire__crate__api__win32_api__set_foreground_window'); - late final _wire__crate__api__win32_api__set_foreground_window = - _wire__crate__api__win32_api__set_foreground_windowPtr.asFunction< - void Function(int, ffi.Pointer)>(); - - ffi.Pointer - cst_new_box_autoadd_rsi_launcher_asar_data() { - return _cst_new_box_autoadd_rsi_launcher_asar_data(); - } - - late final _cst_new_box_autoadd_rsi_launcher_asar_dataPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function()>>( - 'frbgen_starcitizen_doctor_cst_new_box_autoadd_rsi_launcher_asar_data'); - late final _cst_new_box_autoadd_rsi_launcher_asar_data = - _cst_new_box_autoadd_rsi_launcher_asar_dataPtr.asFunction< - ffi.Pointer Function()>(); - ffi.Pointer cst_new_box_autoadd_u_64( int value, ) { @@ -809,36 +406,6 @@ class RustLibWire implements BaseWire { late final _cst_new_box_autoadd_u_64 = _cst_new_box_autoadd_u_64Ptr .asFunction Function(int)>(); - ffi.Pointer cst_new_list_String( - int len, - ) { - return _cst_new_list_String( - len, - ); - } - - late final _cst_new_list_StringPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Int32)>>('frbgen_starcitizen_doctor_cst_new_list_String'); - late final _cst_new_list_String = _cst_new_list_StringPtr - .asFunction Function(int)>(); - - ffi.Pointer cst_new_list_prim_u_8_loose( - int len, - ) { - return _cst_new_list_prim_u_8_loose( - len, - ); - } - - late final _cst_new_list_prim_u_8_loosePtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Int32)>>( - 'frbgen_starcitizen_doctor_cst_new_list_prim_u_8_loose'); - late final _cst_new_list_prim_u_8_loose = _cst_new_list_prim_u_8_loosePtr - .asFunction Function(int)>(); - ffi.Pointer cst_new_list_prim_u_8_strict( int len, ) { @@ -899,21 +466,6 @@ final class wire_cst_list_prim_u_8_strict extends ffi.Struct { external int len; } -final class wire_cst_rsi_launcher_asar_data extends ffi.Struct { - external ffi.Pointer asar_path; - - external ffi.Pointer main_js_path; - - external ffi.Pointer main_js_content; -} - -final class wire_cst_list_prim_u_8_loose extends ffi.Struct { - external ffi.Pointer ptr; - - @ffi.Int32() - external int len; -} - final class wire_cst_record_string_string extends ffi.Struct { external ffi.Pointer field0; @@ -927,23 +479,6 @@ final class wire_cst_list_record_string_string extends ffi.Struct { external int len; } -final class wire_cst_list_String extends ffi.Struct { - external ffi.Pointer> ptr; - - @ffi.Int32() - external int len; -} - -final class wire_cst_rs_process_stream_data extends ffi.Struct { - @ffi.Int32() - external int data_type; - - external ffi.Pointer data; - - @ffi.Uint32() - external int rs_pid; -} - final class wire_cst_rust_http_response extends ffi.Struct { @ffi.Uint16() external int status_code; @@ -954,10 +489,5 @@ final class wire_cst_rust_http_response extends ffi.Struct { external ffi.Pointer content_length; - @ffi.Int32() - external int version; - - external ffi.Pointer remote_addr; - external ffi.Pointer data; } diff --git a/lib/common/rust/frb_generated.web.dart b/lib/common/rust/frb_generated.web.dart new file mode 100644 index 0000000..788d90e --- /dev/null +++ b/lib/common/rust/frb_generated.web.dart @@ -0,0 +1,316 @@ +// This file is automatically generated, so please do not edit it. +// Generated by `flutter_rust_bridge`@ 2.3.0. + +// ignore_for_file: unused_import, unused_element, unnecessary_import, duplicate_ignore, invalid_use_of_internal_member, annotate_overrides, non_constant_identifier_names, curly_braces_in_flow_control_structures, prefer_const_literals_to_create_immutables, unused_field + +// Static analysis wrongly picks the IO variant, thus ignore this +// ignore_for_file: argument_type_not_assignable + +import 'api/http_api.dart'; +import 'dart:async'; +import 'dart:convert'; +import 'frb_generated.dart'; +import 'http_package.dart'; +import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated_web.dart'; + +abstract class RustLibApiImplPlatform extends BaseApiImpl { + RustLibApiImplPlatform({ + required super.handler, + required super.wire, + required super.generalizedFrbRustBinding, + required super.portManager, + }); + + @protected + AnyhowException dco_decode_AnyhowException(dynamic raw); + + @protected + Map dco_decode_Map_String_String(dynamic raw); + + @protected + String dco_decode_String(dynamic raw); + + @protected + BigInt dco_decode_box_autoadd_u_64(dynamic raw); + + @protected + int dco_decode_i_32(dynamic raw); + + @protected + Uint8List dco_decode_list_prim_u_8_strict(dynamic raw); + + @protected + List<(String, String)> dco_decode_list_record_string_string(dynamic raw); + + @protected + MyMethod dco_decode_my_method(dynamic raw); + + @protected + Map? dco_decode_opt_Map_String_String(dynamic raw); + + @protected + BigInt? dco_decode_opt_box_autoadd_u_64(dynamic raw); + + @protected + Uint8List? dco_decode_opt_list_prim_u_8_strict(dynamic raw); + + @protected + (String, String) dco_decode_record_string_string(dynamic raw); + + @protected + RustHttpResponse dco_decode_rust_http_response(dynamic raw); + + @protected + int dco_decode_u_16(dynamic raw); + + @protected + BigInt dco_decode_u_64(dynamic raw); + + @protected + int dco_decode_u_8(dynamic raw); + + @protected + void dco_decode_unit(dynamic raw); + + @protected + AnyhowException sse_decode_AnyhowException(SseDeserializer deserializer); + + @protected + Map sse_decode_Map_String_String( + SseDeserializer deserializer); + + @protected + String sse_decode_String(SseDeserializer deserializer); + + @protected + BigInt sse_decode_box_autoadd_u_64(SseDeserializer deserializer); + + @protected + int sse_decode_i_32(SseDeserializer deserializer); + + @protected + Uint8List sse_decode_list_prim_u_8_strict(SseDeserializer deserializer); + + @protected + List<(String, String)> sse_decode_list_record_string_string( + SseDeserializer deserializer); + + @protected + MyMethod sse_decode_my_method(SseDeserializer deserializer); + + @protected + Map? sse_decode_opt_Map_String_String( + SseDeserializer deserializer); + + @protected + BigInt? sse_decode_opt_box_autoadd_u_64(SseDeserializer deserializer); + + @protected + Uint8List? sse_decode_opt_list_prim_u_8_strict(SseDeserializer deserializer); + + @protected + (String, String) sse_decode_record_string_string( + SseDeserializer deserializer); + + @protected + RustHttpResponse sse_decode_rust_http_response(SseDeserializer deserializer); + + @protected + int sse_decode_u_16(SseDeserializer deserializer); + + @protected + BigInt sse_decode_u_64(SseDeserializer deserializer); + + @protected + int sse_decode_u_8(SseDeserializer deserializer); + + @protected + void sse_decode_unit(SseDeserializer deserializer); + + @protected + bool sse_decode_bool(SseDeserializer deserializer); + + @protected + String cst_encode_AnyhowException(AnyhowException raw) { + // Codec=Cst (C-struct based), see doc to use other codecs + throw UnimplementedError(); + } + + @protected + JSAny cst_encode_Map_String_String(Map raw) { + // Codec=Cst (C-struct based), see doc to use other codecs + return cst_encode_list_record_string_string( + raw.entries.map((e) => (e.key, e.value)).toList()); + } + + @protected + String cst_encode_String(String raw) { + // Codec=Cst (C-struct based), see doc to use other codecs + return raw; + } + + @protected + JSAny cst_encode_box_autoadd_u_64(BigInt raw) { + // Codec=Cst (C-struct based), see doc to use other codecs + return cst_encode_u_64(raw); + } + + @protected + JSAny cst_encode_list_prim_u_8_strict(Uint8List raw) { + // Codec=Cst (C-struct based), see doc to use other codecs + return raw.jsify()!; + } + + @protected + JSAny cst_encode_list_record_string_string(List<(String, String)> raw) { + // Codec=Cst (C-struct based), see doc to use other codecs + return raw.map(cst_encode_record_string_string).toList().jsify()!; + } + + @protected + JSAny? cst_encode_opt_Map_String_String(Map? raw) { + // Codec=Cst (C-struct based), see doc to use other codecs + return raw == null ? null : cst_encode_Map_String_String(raw); + } + + @protected + JSAny? cst_encode_opt_box_autoadd_u_64(BigInt? raw) { + // Codec=Cst (C-struct based), see doc to use other codecs + return raw == null ? null : cst_encode_box_autoadd_u_64(raw); + } + + @protected + JSAny? cst_encode_opt_list_prim_u_8_strict(Uint8List? raw) { + // Codec=Cst (C-struct based), see doc to use other codecs + return raw == null ? null : cst_encode_list_prim_u_8_strict(raw); + } + + @protected + JSAny cst_encode_record_string_string((String, String) raw) { + // Codec=Cst (C-struct based), see doc to use other codecs + return [cst_encode_String(raw.$1), cst_encode_String(raw.$2)].jsify()!; + } + + @protected + JSAny cst_encode_rust_http_response(RustHttpResponse raw) { + // Codec=Cst (C-struct based), see doc to use other codecs + return [ + cst_encode_u_16(raw.statusCode), + cst_encode_Map_String_String(raw.headers), + cst_encode_String(raw.url), + cst_encode_opt_box_autoadd_u_64(raw.contentLength), + cst_encode_opt_list_prim_u_8_strict(raw.data) + ].jsify()!; + } + + @protected + JSAny cst_encode_u_64(BigInt raw) { + // Codec=Cst (C-struct based), see doc to use other codecs + return castNativeBigInt(raw); + } + + @protected + int cst_encode_i_32(int raw); + + @protected + int cst_encode_my_method(MyMethod raw); + + @protected + int cst_encode_u_16(int raw); + + @protected + int cst_encode_u_8(int raw); + + @protected + void cst_encode_unit(void raw); + + @protected + void sse_encode_AnyhowException( + AnyhowException self, SseSerializer serializer); + + @protected + void sse_encode_Map_String_String( + Map self, SseSerializer serializer); + + @protected + void sse_encode_String(String self, SseSerializer serializer); + + @protected + void sse_encode_box_autoadd_u_64(BigInt self, SseSerializer serializer); + + @protected + void sse_encode_i_32(int self, SseSerializer serializer); + + @protected + void sse_encode_list_prim_u_8_strict( + Uint8List self, SseSerializer serializer); + + @protected + void sse_encode_list_record_string_string( + List<(String, String)> self, SseSerializer serializer); + + @protected + void sse_encode_my_method(MyMethod self, SseSerializer serializer); + + @protected + void sse_encode_opt_Map_String_String( + Map? self, SseSerializer serializer); + + @protected + void sse_encode_opt_box_autoadd_u_64(BigInt? self, SseSerializer serializer); + + @protected + void sse_encode_opt_list_prim_u_8_strict( + Uint8List? self, SseSerializer serializer); + + @protected + void sse_encode_record_string_string( + (String, String) self, SseSerializer serializer); + + @protected + void sse_encode_rust_http_response( + RustHttpResponse self, SseSerializer serializer); + + @protected + void sse_encode_u_16(int self, SseSerializer serializer); + + @protected + void sse_encode_u_64(BigInt self, SseSerializer serializer); + + @protected + void sse_encode_u_8(int self, SseSerializer serializer); + + @protected + void sse_encode_unit(void self, SseSerializer serializer); + + @protected + void sse_encode_bool(bool self, SseSerializer serializer); +} + +// Section: wire_class + +class RustLibWire implements BaseWire { + RustLibWire.fromExternalLibrary(ExternalLibrary lib); + + void wire__crate__api__http_api__fetch(NativePortType port_, int method, + String url, JSAny? headers, JSAny? input_data) => + wasmModule.wire__crate__api__http_api__fetch( + port_, method, url, headers, input_data); + + void wire__crate__api__http_api__set_default_header( + NativePortType port_, JSAny headers) => + wasmModule.wire__crate__api__http_api__set_default_header(port_, headers); +} + +@JS('wasm_bindgen') +external RustLibWasmModule get wasmModule; + +@JS() +@anonymous +extension type RustLibWasmModule._(JSObject _) implements JSObject { + external void wire__crate__api__http_api__fetch(NativePortType port_, + int method, String url, JSAny? headers, JSAny? input_data); + + external void wire__crate__api__http_api__set_default_header( + NativePortType port_, JSAny headers); +} diff --git a/lib/common/rust/http_package.dart b/lib/common/rust/http_package.dart index 1cc13b2..b9118bf 100644 --- a/lib/common/rust/http_package.dart +++ b/lib/common/rust/http_package.dart @@ -6,23 +6,11 @@ import 'frb_generated.dart'; import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; -enum MyHttpVersion { - http09, - http10, - http11, - http2, - http3, - httpUnknown, - ; -} - class RustHttpResponse { final int statusCode; final Map headers; final String url; final BigInt? contentLength; - final MyHttpVersion version; - final String remoteAddr; final Uint8List? data; const RustHttpResponse({ @@ -30,8 +18,6 @@ class RustHttpResponse { required this.headers, required this.url, this.contentLength, - required this.version, - required this.remoteAddr, this.data, }); @@ -41,8 +27,6 @@ class RustHttpResponse { headers.hashCode ^ url.hashCode ^ contentLength.hashCode ^ - version.hashCode ^ - remoteAddr.hashCode ^ data.hashCode; @override @@ -54,7 +38,5 @@ class RustHttpResponse { headers == other.headers && url == other.url && contentLength == other.contentLength && - version == other.version && - remoteAddr == other.remoteAddr && data == other.data; } diff --git a/lib/generated/intl/messages_en.dart b/lib/generated/intl/messages_en.dart index 1e2b317..267c03a 100644 --- a/lib/generated/intl/messages_en.dart +++ b/lib/generated/intl/messages_en.dart @@ -25,7 +25,7 @@ class MessageLookup extends MessageLookupByLibrary { static String m1(v0, v1) => "Network anomaly!\nThis may be that your network environment has DNS pollution, please try to replace DNS.\nOr the server is being maintained or attacked and tried it later.\nEnter the offline mode ...\n\nPlease use it carefully in the offline mode.\nThe current version of the construction date: ${v0}\n QQ group: 940696487\nError message: ${v1}"; - static String m2(v0, v1) => "SCToolBox V ${v0} ${v1}"; + static String m2(v0, v1) => "SCToolBox ${v0} ${v1}"; static String m3(v0) => "Initialization failure: ${v0}"; @@ -198,7 +198,7 @@ class MessageLookup extends MessageLookupByLibrary { "about_app_description": MessageLookupByLibrary.simpleMessage( "Not just about localization!\n\nThe SCToolBox is your helper to explore the verse. We are committed to solving common in-game problems for citizens, in addition to facilitating localization from the community, game performance tuning, and localization of some commonly used website."), "about_check_update": - MessageLookupByLibrary.simpleMessage("Check for updates"), + MessageLookupByLibrary.simpleMessage("Get the full version"), "about_disclaimer": MessageLookupByLibrary.simpleMessage( "This is an unofficial Star Citizen fan-made tools, not affiliated with the Cloud Imperium group of companies. All content on this Software not authored by its host or users are property of their respective owners. \nStar Citizen®, Roberts Space Industries® and Cloud Imperium® are registered trademarks of Cloud Imperium Rights LLC."), "about_info_latest_version": MessageLookupByLibrary.simpleMessage( diff --git a/lib/generated/intl/messages_ja.dart b/lib/generated/intl/messages_ja.dart index 00be6e7..b2fc83a 100644 --- a/lib/generated/intl/messages_ja.dart +++ b/lib/generated/intl/messages_ja.dart @@ -20,7 +20,7 @@ typedef String MessageIfAbsent(String messageStr, List args); class MessageLookup extends MessageLookupByLibrary { String get localeName => 'ja'; - static String m2(v0, v1) => "SCToolBox V ${v0} ${v1}"; + static String m2(v0, v1) => "SCToolBox ${v0} ${v1}"; static String m19(v0, v1) => "ダウンロード: ${v0}/s アップロード:${v1}/s"; diff --git a/lib/generated/intl/messages_zh_CN.dart b/lib/generated/intl/messages_zh_CN.dart index 08c47c8..a7da628 100644 --- a/lib/generated/intl/messages_zh_CN.dart +++ b/lib/generated/intl/messages_zh_CN.dart @@ -25,7 +25,7 @@ class MessageLookup extends MessageLookupByLibrary { static String m1(v0, v1) => "网络异常!\n这可能是您的网络环境存在DNS污染,请尝试更换DNS。\n或服务器正在维护或遭受攻击,稍后再试。 \n进入离线模式... \n\n请谨慎在离线模式中使用。 \n当前版本构建日期:${v0}\n QQ群:940696487 \n错误信息:${v1}"; - static String m2(v0, v1) => "SC汉化盒子 V${v0} ${v1}"; + static String m2(v0, v1) => "SC汉化盒子 ${v0} ${v1}"; static String m3(v0) => "初始化失败:${v0}"; @@ -180,7 +180,7 @@ class MessageLookup extends MessageLookupByLibrary { "about_analytics_units_user": MessageLookupByLibrary.simpleMessage("位"), "about_app_description": MessageLookupByLibrary.simpleMessage( "不仅仅是汉化!\n\nSC汉化盒子是你探索宇宙的好帮手,我们致力于为各位公民解决游戏中的常见问题,并为社区汉化、性能调优、常用网站汉化 等操作提供便利。"), - "about_check_update": MessageLookupByLibrary.simpleMessage("检查更新"), + "about_check_update": MessageLookupByLibrary.simpleMessage("安装完整版"), "about_disclaimer": MessageLookupByLibrary.simpleMessage( "这是一个非官方的星际公民工具,不隶属于 Cloud Imperium 公司集团。 本软件中非由其主机或用户创作的所有内容均为其各自所有者的财产。 \nStar Citizen®、Roberts Space Industries® 和 Cloud Imperium® 是 Cloud Imperium Rights LLC 的注册商标。"), "about_info_latest_version": diff --git a/lib/generated/intl/messages_zh_TW.dart b/lib/generated/intl/messages_zh_TW.dart index 9d8869e..b9d10c4 100644 --- a/lib/generated/intl/messages_zh_TW.dart +++ b/lib/generated/intl/messages_zh_TW.dart @@ -25,7 +25,7 @@ class MessageLookup extends MessageLookupByLibrary { static String m1(v0, v1) => "網路異常!\n這可能是您的網路環境存在DNS汙染,請嘗試更換DNS。\n或伺服器正在維護或遭受攻擊,稍後再試。 \n進入離線模式... \n\n請謹慎在離線模式中使用。 \n目前版本構建日期:${v0}\n QQ群:940696487 \n錯誤資訊:${v1}"; - static String m2(v0, v1) => "SC工具箱 V${v0} ${v1}"; + static String m2(v0, v1) => "SC工具箱 ${v0} ${v1}"; static String m3(v0) => "初始化失敗:${v0}"; @@ -179,7 +179,7 @@ class MessageLookup extends MessageLookupByLibrary { "about_analytics_units_user": MessageLookupByLibrary.simpleMessage("位"), "about_app_description": MessageLookupByLibrary.simpleMessage( "這個工具能做的不僅僅是翻譯!\n\nSC工具箱是你探索宇宙的好幫手,我們致力於為各位公民解決遊戲中的常見問題,並為社群翻譯、性能改善、常用網站翻譯 等操作提供便利。"), - "about_check_update": MessageLookupByLibrary.simpleMessage("檢查更新"), + "about_check_update": MessageLookupByLibrary.simpleMessage("安裝完整版"), "about_disclaimer": MessageLookupByLibrary.simpleMessage( "SC工具箱非官方的星際公民工具,不隸屬於 Cloud Imperium 公司集團。 本軟體中非由其主機或使用者創作的所有內容均為其各自所有者的財產。 \nStar Citizen®、Roberts Space Industries® 和 Cloud Imperium® 是 Cloud Imperium Rights LLC 的註冊商標。"), "about_info_latest_version": diff --git a/lib/generated/l10n.dart b/lib/generated/l10n.dart index 75d3e22..9fe6d91 100644 --- a/lib/generated/l10n.dart +++ b/lib/generated/l10n.dart @@ -70,10 +70,10 @@ class S { ); } - /// `SCToolBox V {v0} {v1}` + /// `SCToolBox {v0} {v1}` String app_index_version_info(Object v0, Object v1) { return Intl.message( - 'SCToolBox V $v0 $v1', + 'SCToolBox $v0 $v1', name: 'app_index_version_info', desc: '', args: [v0, v1], @@ -90,10 +90,10 @@ class S { ); } - /// `Check for updates` + /// `Get the full version` String get about_check_update { return Intl.message( - 'Check for updates', + 'Get the full version', name: 'about_check_update', desc: '', args: [], diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index f280011..52914a5 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -5,11 +5,11 @@ "@app_language_name": {}, "app_language_code": "en", "@app_language_code": {}, - "app_index_version_info": "SCToolBox V {v0} {v1}", + "app_index_version_info": "SCToolBox {v0} {v1}", "@app_index_version_info": {}, "app_shortcut_name": "SCToolBox.lnk", "@app_shortcut_name": {}, - "about_check_update": "Check for updates", + "about_check_update": "Get the full version", "@about_check_update": {}, "about_app_description": "Not just about localization!\n\nThe SCToolBox is your helper to explore the verse. We are committed to solving common in-game problems for citizens, in addition to facilitating localization from the community, game performance tuning, and localization of some commonly used website.", "@about_app_description": {}, diff --git a/lib/l10n/intl_ja.arb b/lib/l10n/intl_ja.arb index 11821ef..9bbdbbd 100644 --- a/lib/l10n/intl_ja.arb +++ b/lib/l10n/intl_ja.arb @@ -5,7 +5,7 @@ "@app_language_name": {}, "app_language_code": "ja", "@app_language_code": {}, - "app_index_version_info": "SCToolBox V {v0} {v1}", + "app_index_version_info": "SCToolBox {v0} {v1}", "@app_index_version_info": {}, "about_check_update": "更新チェック", "@about_check_update": {}, diff --git a/lib/l10n/intl_zh_CN.arb b/lib/l10n/intl_zh_CN.arb index 2ba83b4..69d13bc 100644 --- a/lib/l10n/intl_zh_CN.arb +++ b/lib/l10n/intl_zh_CN.arb @@ -4,11 +4,11 @@ "app_language_name": "简体中文", "@app_language_name": {}, "app_language_code": "zh_CN", - "app_index_version_info": "SC汉化盒子 V{v0} {v1}", + "app_index_version_info": "SC汉化盒子 {v0} {v1}", "@app_index_version_info": {}, "app_shortcut_name": "SC汉化盒子DEV.lnk", "@app_shortcut_name": {}, - "about_check_update": "检查更新", + "about_check_update": "安装完整版", "@about_check_update": {}, "about_app_description": "不仅仅是汉化!\n\nSC汉化盒子是你探索宇宙的好帮手,我们致力于为各位公民解决游戏中的常见问题,并为社区汉化、性能调优、常用网站汉化 等操作提供便利。", "@about_app_description": {}, diff --git a/lib/l10n/intl_zh_TW.arb b/lib/l10n/intl_zh_TW.arb index ed017bf..99bc7a9 100644 --- a/lib/l10n/intl_zh_TW.arb +++ b/lib/l10n/intl_zh_TW.arb @@ -4,11 +4,11 @@ "app_language_name": "繁體中文", "@app_language_name": {}, "app_language_code": "zh_TW", - "app_index_version_info": "SC工具箱 V{v0} {v1}", + "app_index_version_info": "SC工具箱 {v0} {v1}", "@app_index_version_info": {}, "app_shortcut_name": "SC工具箱DEV.lnk", "@app_shortcut_name": {}, - "about_check_update": "檢查更新", + "about_check_update": "安裝完整版", "@about_check_update": {}, "about_app_description": "這個工具能做的不僅僅是翻譯!\n\nSC工具箱是你探索宇宙的好幫手,我們致力於為各位公民解決遊戲中的常見問題,並為社群翻譯、性能改善、常用網站翻譯 等操作提供便利。", "@about_app_description": {}, diff --git a/lib/main.dart b/lib/main.dart index 7420cae..d5f82dd 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,36 +1,16 @@ -import 'dart:io'; -import 'package:desktop_webview_window/desktop_webview_window.dart'; import 'package:fluent_ui/fluent_ui.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:starcitizen_doctor/generated/l10n.dart'; -import 'package:window_manager/window_manager.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'app.dart'; void main(List args) async { - // webview window - if (runWebViewTitleBarWidget(args, - backgroundColor: const Color.fromRGBO(19, 36, 49, 1), - builder: _defaultWebviewTitleBar)) { - return; - } WidgetsFlutterBinding.ensureInitialized(); - await _initWindow(); // run app runApp(const ProviderScope(child: App())); } -_initWindow() async { - await windowManager.ensureInitialized(); - await windowManager.setTitleBarStyle( - TitleBarStyle.hidden, - windowButtonVisibility: false, - ); - await windowManager.setSize(const Size(1280, 810)); - await windowManager.setMinimumSize(const Size(1280, 810)); - await windowManager.center(animate: true); -} class App extends HookConsumerWidget { const App({super.key}); @@ -81,46 +61,3 @@ class App extends HookConsumerWidget { } } -Widget _defaultWebviewTitleBar(BuildContext context) { - final state = TitleBarWebViewState.of(context); - final controller = TitleBarWebViewController.of(context); - return FluentTheme( - data: FluentThemeData.dark(), - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - if (Platform.isMacOS) const SizedBox(width: 96), - IconButton( - onPressed: !state.canGoBack ? null : controller.back, - icon: const Icon(FluentIcons.chevron_left), - ), - const SizedBox(width: 12), - IconButton( - onPressed: !state.canGoForward ? null : controller.forward, - icon: const Icon(FluentIcons.chevron_right), - ), - const SizedBox(width: 12), - if (state.isLoading) - IconButton( - onPressed: controller.stop, - icon: const Icon(FluentIcons.chrome_close), - ) - else - IconButton( - onPressed: controller.reload, - icon: const Icon(FluentIcons.refresh), - ), - const SizedBox(width: 12), - (state.isLoading) - ? const SizedBox( - width: 24, - height: 24, - child: ProgressRing(), - ) - : const SizedBox(width: 24), - const SizedBox(width: 12), - SelectableText(state.url ?? ""), - const Spacer() - ], - )); -} diff --git a/lib/provider/aria2c.dart b/lib/provider/aria2c.dart deleted file mode 100644 index 0c03b98..0000000 --- a/lib/provider/aria2c.dart +++ /dev/null @@ -1,216 +0,0 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:riverpod_annotation/riverpod_annotation.dart'; -import 'package:starcitizen_doctor/common/conf/binary_conf.dart'; -import 'dart:io'; -import 'dart:math'; -import 'package:aria2/aria2.dart'; -import 'package:flutter/foundation.dart'; -import 'package:hive/hive.dart'; -import 'package:starcitizen_doctor/api/api.dart'; -import 'package:starcitizen_doctor/common/helper/system_helper.dart'; -import 'package:starcitizen_doctor/common/rust/api/rs_process.dart' - as rs_process; - -import 'package:starcitizen_doctor/common/utils/log.dart'; -import 'package:starcitizen_doctor/common/utils/provider.dart'; - -part 'aria2c.g.dart'; - -part 'aria2c.freezed.dart'; - -@freezed -class Aria2cModelState with _$Aria2cModelState { - const factory Aria2cModelState({ - required String aria2cDir, - Aria2c? aria2c, - Aria2GlobalStat? aria2globalStat, - }) = _Aria2cModelState; -} - -extension Aria2cModelExt on Aria2cModelState { - bool get isRunning => aria2c != null; - - bool get hasDownloadTask => aria2globalStat != null && aria2TotalTaskNum > 0; - - int get aria2TotalTaskNum => aria2globalStat == null - ? 0 - : ((aria2globalStat!.numActive ?? 0) + - (aria2globalStat!.numWaiting ?? 0)); -} - -@riverpod -class Aria2cModel extends _$Aria2cModel { - bool _disposed = false; - - @override - Aria2cModelState build() { - if (appGlobalState.applicationBinaryModuleDir == null) { - throw Exception("applicationBinaryModuleDir is null"); - } - ref.onDispose(() { - _disposed = true; - }); - ref.keepAlive(); - final aria2cDir = "${appGlobalState.applicationBinaryModuleDir}\\aria2c"; - // LazyLoad init - () async { - try { - final sessionFile = File("$aria2cDir\\aria2.session"); - // 有下载任务则第一时间初始化 - if (await sessionFile.exists() && - (await sessionFile.readAsString()).trim().isNotEmpty) { - dPrint("launch Aria2c daemon"); - await launchDaemon(appGlobalState.applicationBinaryModuleDir!); - } else { - dPrint("LazyLoad Aria2c daemon"); - } - } catch (e) { - dPrint("Aria2cManager.checkLazyLoad Error:$e"); - } - }(); - - return Aria2cModelState(aria2cDir: aria2cDir); - } - - Future launchDaemon(String applicationBinaryModuleDir) async { - if (state.aria2c != null) return; - await BinaryModuleConf.extractModule( - ["aria2c"], applicationBinaryModuleDir); - - /// skip for debug hot reload - if (kDebugMode) { - if ((await SystemHelper.getPID("aria2c")).isNotEmpty) { - dPrint("[Aria2cManager] debug skip for hot reload"); - return; - } - } - - final sessionFile = File("${state.aria2cDir}\\aria2.session"); - if (!await sessionFile.exists()) { - await sessionFile.create(recursive: true); - } - - final exePath = "${state.aria2cDir}\\aria2c.exe"; - final port = await getFreePort(); - final pwd = generateRandomPassword(16); - dPrint("pwd === $pwd"); - final trackerList = await Api.getTorrentTrackerList(); - dPrint("trackerList === $trackerList"); - dPrint("Aria2cManager .----- aria2c start $port------"); - - final stream = rs_process.start( - executable: exePath, - arguments: [ - "-V", - "-c", - "-x 16", - "--dir=${state.aria2cDir}\\downloads", - "--disable-ipv6", - "--enable-rpc", - "--pause", - "--rpc-listen-port=$port", - "--rpc-secret=$pwd", - "--input-file=${sessionFile.absolute.path.trim()}", - "--save-session=${sessionFile.absolute.path.trim()}", - "--save-session-interval=60", - "--file-allocation=trunc", - "--seed-time=0", - ], - workingDirectory: state.aria2cDir); - - String launchError = ""; - - stream.listen((event) { - dPrint("Aria2cManager.rs_process event === $event"); - switch (event.dataType) { - case rs_process.RsProcessStreamDataType.output: - if (event.data.contains("IPv4 RPC: listening on TCP port")) { - _onLaunch(port, pwd, trackerList); - } - break; - case rs_process.RsProcessStreamDataType.error: - launchError = event.data; - state = state.copyWith(aria2c: null); - break; - case rs_process.RsProcessStreamDataType.exit: - launchError = event.data; - state = state.copyWith(aria2c: null); - break; - } - }); - - while (true) { - if (state.aria2c != null) return; - if (launchError.isNotEmpty) throw launchError; - await Future.delayed(const Duration(milliseconds: 100)); - } - } - - Future getFreePort() async { - final serverSocket = await ServerSocket.bind("127.0.0.1", 0); - final port = serverSocket.port; - await serverSocket.close(); - return port; - } - - String generateRandomPassword(int length) { - const String charset = - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; - Random random = Random(); - StringBuffer buffer = StringBuffer(); - for (int i = 0; i < length; i++) { - int randomIndex = random.nextInt(charset.length); - buffer.write(charset[randomIndex]); - } - return buffer.toString(); - } - - int textToByte(String text) { - if (text.length == 1) { - return 0; - } - if (int.tryParse(text) != null) { - return int.parse(text); - } - if (text.endsWith("k")) { - return int.parse(text.substring(0, text.length - 1)) * 1024; - } - if (text.endsWith("m")) { - return int.parse(text.substring(0, text.length - 1)) * 1024 * 1024; - } - return 0; - } - - Future _onLaunch(int port, String pwd, String trackerList) async { - final aria2c = Aria2c("ws://127.0.0.1:$port/jsonrpc", "websocket", pwd); - state = state.copyWith(aria2c: aria2c); - aria2c.getVersion().then((value) { - dPrint("Aria2cManager.connected! version == ${value.version}"); - _listenState(aria2c); - }); - final box = await Hive.openBox("app_conf"); - aria2c.changeGlobalOption(Aria2Option() - ..maxOverallUploadLimit = - textToByte(box.get("downloader_up_limit", defaultValue: "0")) - ..maxOverallDownloadLimit = - textToByte(box.get("downloader_down_limit", defaultValue: "0")) - ..btTracker = trackerList); - } - - Future _listenState(Aria2c aria2c) async { - dPrint("Aria2cModel._listenState start"); - while (true) { - if (_disposed || state.aria2c == null) { - dPrint("Aria2cModel._listenState end"); - return; - } - try { - final aria2globalStat = await aria2c.getGlobalStat(); - state = state.copyWith(aria2globalStat: aria2globalStat); - } catch (e) { - dPrint("aria2globalStat update error:$e"); - } - await Future.delayed(const Duration(seconds: 1)); - } - } -} diff --git a/lib/provider/aria2c.freezed.dart b/lib/provider/aria2c.freezed.dart deleted file mode 100644 index 98689ba..0000000 --- a/lib/provider/aria2c.freezed.dart +++ /dev/null @@ -1,197 +0,0 @@ -// coverage:ignore-file -// GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark - -part of 'aria2c.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -T _$identity(T value) => value; - -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); - -/// @nodoc -mixin _$Aria2cModelState { - String get aria2cDir => throw _privateConstructorUsedError; - Aria2c? get aria2c => throw _privateConstructorUsedError; - Aria2GlobalStat? get aria2globalStat => throw _privateConstructorUsedError; - - /// Create a copy of Aria2cModelState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $Aria2cModelStateCopyWith get copyWith => - throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $Aria2cModelStateCopyWith<$Res> { - factory $Aria2cModelStateCopyWith( - Aria2cModelState value, $Res Function(Aria2cModelState) then) = - _$Aria2cModelStateCopyWithImpl<$Res, Aria2cModelState>; - @useResult - $Res call( - {String aria2cDir, Aria2c? aria2c, Aria2GlobalStat? aria2globalStat}); -} - -/// @nodoc -class _$Aria2cModelStateCopyWithImpl<$Res, $Val extends Aria2cModelState> - implements $Aria2cModelStateCopyWith<$Res> { - _$Aria2cModelStateCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of Aria2cModelState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? aria2cDir = null, - Object? aria2c = freezed, - Object? aria2globalStat = freezed, - }) { - return _then(_value.copyWith( - aria2cDir: null == aria2cDir - ? _value.aria2cDir - : aria2cDir // ignore: cast_nullable_to_non_nullable - as String, - aria2c: freezed == aria2c - ? _value.aria2c - : aria2c // ignore: cast_nullable_to_non_nullable - as Aria2c?, - aria2globalStat: freezed == aria2globalStat - ? _value.aria2globalStat - : aria2globalStat // ignore: cast_nullable_to_non_nullable - as Aria2GlobalStat?, - ) as $Val); - } -} - -/// @nodoc -abstract class _$$Aria2cModelStateImplCopyWith<$Res> - implements $Aria2cModelStateCopyWith<$Res> { - factory _$$Aria2cModelStateImplCopyWith(_$Aria2cModelStateImpl value, - $Res Function(_$Aria2cModelStateImpl) then) = - __$$Aria2cModelStateImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {String aria2cDir, Aria2c? aria2c, Aria2GlobalStat? aria2globalStat}); -} - -/// @nodoc -class __$$Aria2cModelStateImplCopyWithImpl<$Res> - extends _$Aria2cModelStateCopyWithImpl<$Res, _$Aria2cModelStateImpl> - implements _$$Aria2cModelStateImplCopyWith<$Res> { - __$$Aria2cModelStateImplCopyWithImpl(_$Aria2cModelStateImpl _value, - $Res Function(_$Aria2cModelStateImpl) _then) - : super(_value, _then); - - /// Create a copy of Aria2cModelState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? aria2cDir = null, - Object? aria2c = freezed, - Object? aria2globalStat = freezed, - }) { - return _then(_$Aria2cModelStateImpl( - aria2cDir: null == aria2cDir - ? _value.aria2cDir - : aria2cDir // ignore: cast_nullable_to_non_nullable - as String, - aria2c: freezed == aria2c - ? _value.aria2c - : aria2c // ignore: cast_nullable_to_non_nullable - as Aria2c?, - aria2globalStat: freezed == aria2globalStat - ? _value.aria2globalStat - : aria2globalStat // ignore: cast_nullable_to_non_nullable - as Aria2GlobalStat?, - )); - } -} - -/// @nodoc - -class _$Aria2cModelStateImpl - with DiagnosticableTreeMixin - implements _Aria2cModelState { - const _$Aria2cModelStateImpl( - {required this.aria2cDir, this.aria2c, this.aria2globalStat}); - - @override - final String aria2cDir; - @override - final Aria2c? aria2c; - @override - final Aria2GlobalStat? aria2globalStat; - - @override - String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) { - return 'Aria2cModelState(aria2cDir: $aria2cDir, aria2c: $aria2c, aria2globalStat: $aria2globalStat)'; - } - - @override - void debugFillProperties(DiagnosticPropertiesBuilder properties) { - super.debugFillProperties(properties); - properties - ..add(DiagnosticsProperty('type', 'Aria2cModelState')) - ..add(DiagnosticsProperty('aria2cDir', aria2cDir)) - ..add(DiagnosticsProperty('aria2c', aria2c)) - ..add(DiagnosticsProperty('aria2globalStat', aria2globalStat)); - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$Aria2cModelStateImpl && - (identical(other.aria2cDir, aria2cDir) || - other.aria2cDir == aria2cDir) && - (identical(other.aria2c, aria2c) || other.aria2c == aria2c) && - (identical(other.aria2globalStat, aria2globalStat) || - other.aria2globalStat == aria2globalStat)); - } - - @override - int get hashCode => - Object.hash(runtimeType, aria2cDir, aria2c, aria2globalStat); - - /// Create a copy of Aria2cModelState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$Aria2cModelStateImplCopyWith<_$Aria2cModelStateImpl> get copyWith => - __$$Aria2cModelStateImplCopyWithImpl<_$Aria2cModelStateImpl>( - this, _$identity); -} - -abstract class _Aria2cModelState implements Aria2cModelState { - const factory _Aria2cModelState( - {required final String aria2cDir, - final Aria2c? aria2c, - final Aria2GlobalStat? aria2globalStat}) = _$Aria2cModelStateImpl; - - @override - String get aria2cDir; - @override - Aria2c? get aria2c; - @override - Aria2GlobalStat? get aria2globalStat; - - /// Create a copy of Aria2cModelState - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$Aria2cModelStateImplCopyWith<_$Aria2cModelStateImpl> get copyWith => - throw _privateConstructorUsedError; -} diff --git a/lib/provider/aria2c.g.dart b/lib/provider/aria2c.g.dart deleted file mode 100644 index a437498..0000000 --- a/lib/provider/aria2c.g.dart +++ /dev/null @@ -1,25 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'aria2c.dart'; - -// ************************************************************************** -// RiverpodGenerator -// ************************************************************************** - -String _$aria2cModelHash() => r'55dea5bd2e1c81fec0ef8ef1a10f41179775d7ee'; - -/// See also [Aria2cModel]. -@ProviderFor(Aria2cModel) -final aria2cModelProvider = - AutoDisposeNotifierProvider.internal( - Aria2cModel.new, - name: r'aria2cModelProvider', - debugGetCreateSourceHash: - const bool.fromEnvironment('dart.vm.product') ? null : _$aria2cModelHash, - dependencies: null, - allTransitiveDependencies: null, -); - -typedef _$Aria2cModel = AutoDisposeNotifier; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member diff --git a/lib/provider/unp4kc.dart b/lib/provider/unp4kc.dart deleted file mode 100644 index c3a77fd..0000000 --- a/lib/provider/unp4kc.dart +++ /dev/null @@ -1,278 +0,0 @@ -import 'dart:convert'; -import 'dart:io'; - -import 'package:file/memory.dart'; -import 'package:flutter/foundation.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:path_provider/path_provider.dart'; -import 'package:riverpod_annotation/riverpod_annotation.dart'; -import 'package:starcitizen_doctor/api/analytics.dart'; -import 'package:starcitizen_doctor/common/conf/binary_conf.dart'; -import 'package:starcitizen_doctor/common/helper/log_helper.dart'; -import 'package:starcitizen_doctor/common/rust/api/rs_process.dart'; -import 'package:starcitizen_doctor/common/utils/log.dart'; -import 'package:starcitizen_doctor/common/utils/provider.dart'; -import 'package:starcitizen_doctor/data/app_unp4k_p4k_item_data.dart'; -import 'package:starcitizen_doctor/ui/tools/tools_ui_model.dart'; -import 'package:starcitizen_doctor/common/rust/api/rs_process.dart' - as rs_process; - -part 'unp4kc.freezed.dart'; - -part 'unp4kc.g.dart'; - -@freezed -class Unp4kcState with _$Unp4kcState { - const factory Unp4kcState({ - required bool startUp, - Map? files, - MemoryFileSystem? fs, - required String curPath, - String? endMessage, - MapEntry? tempOpenFile, - @Default("") String errorMessage, - }) = _Unp4kcState; -} - -@riverpod -class Unp4kCModel extends _$Unp4kCModel { - int? _rsPid; - - @override - Unp4kcState build() { - state = Unp4kcState( - startUp: false, - curPath: '\\', - endMessage: S.current.tools_unp4k_msg_init); - _init(); - return state; - } - - ToolsUIState get _toolsState => ref.read(toolsUIModelProvider); - - String getGamePath() => _toolsState.scInstalledPath; - - bool _hasUnp4kRunTimeError = false; - - void _init() async { - final execDir = "${appGlobalState.applicationBinaryModuleDir}\\unp4kc"; - await BinaryModuleConf.extractModule( - ["unp4kc"], appGlobalState.applicationBinaryModuleDir!); - final exec = "$execDir\\unp4kc.exe"; - - final stream = rs_process.start( - executable: exec, arguments: [], workingDirectory: execDir); - - stream.listen((event) async { - switch (event.dataType) { - case RsProcessStreamDataType.output: - _rsPid = event.rsPid; - try { - final eventJson = await compute(json.decode, event.data); - _handleMessage(eventJson, event.rsPid); - } catch (e) { - dPrint("[unp4kc] json error: $e"); - } - break; - case RsProcessStreamDataType.error: - dPrint("[unp4kc] stderr: ${event.data}"); - if (state.errorMessage.isEmpty) { - state = state.copyWith(errorMessage: event.data); - } else { - state = state.copyWith( - errorMessage: "${state.errorMessage}\n${event.data}"); - } - if (!_hasUnp4kRunTimeError) { - if (checkRunTimeError(state.errorMessage)) { - _hasUnp4kRunTimeError = true; - AnalyticsApi.touch("unp4k_no_runtime"); - } - } - break; - case RsProcessStreamDataType.exit: - dPrint("[unp4kc] exit: ${event.data}"); - break; - } - }); - - ref.onDispose(() { - state = state.copyWith(fs: null); - if (_rsPid != null) { - Process.killPid(_rsPid!); - dPrint("[unp4kc] kill ..."); - } - }); - } - - DateTime? _loadStartTime; - - void _handleMessage(Map eventJson, int rsPid) async { - final action = eventJson["action"]; - final data = eventJson["data"]; - final gamePath = getGamePath(); - final gameP4kPath = "$gamePath\\Data.p4k"; - switch (action.toString().trim()) { - case "info: startup": - rs_process.write(rsPid: rsPid, data: "$gameP4kPath\n"); - break; - case "info: Reading_p4k_file": - _loadStartTime = DateTime.now(); - state = state.copyWith(endMessage: S.current.tools_unp4k_msg_reading); - break; - case "info: All Ready": - state = state.copyWith(endMessage: S.current.tools_unp4k_msg_reading2); - break; - case "data: P4K_Files": - final p4kFiles = (data as List); - final files = {}; - final fs = MemoryFileSystem(style: FileSystemStyle.posix); - - var nextAwait = 0; - for (var i = 0; i < p4kFiles.length; i++) { - final item = AppUnp4kP4kItemData.fromJson(p4kFiles[i]); - item.name = "${item.name}"; - files["\\${item.name}"] = item; - await fs - .file(item.name?.replaceAll("\\", "/") ?? "") - .create(recursive: true); - if (i == nextAwait) { - state = state.copyWith( - endMessage: - S.current.tools_unp4k_msg_reading3(i, p4kFiles.length)); - await Future.delayed(Duration.zero); - nextAwait += 20000; - } - } - final endTime = DateTime.now(); - state = state.copyWith( - files: files, - fs: fs, - endMessage: S.current.tools_unp4k_msg_read_completed(files.length, - endTime.difference(_loadStartTime!).inMilliseconds)); - _loadStartTime = null; - break; - case "info: Extracted_Open": - final filePath = data.toString(); - dPrint("[unp4kc] Extracted_Open file: $filePath"); - const textExt = [".txt", ".xml", ".json", ".lua", ".cfg", ".ini"]; - const imgExt = [".png"]; - String openType = "unknown"; - for (var element in textExt) { - if (filePath.toLowerCase().endsWith(element)) { - openType = "text"; - } - } - for (var element in imgExt) { - if (filePath.endsWith(element)) { - openType = "image"; - } - } - state = state.copyWith( - tempOpenFile: MapEntry(openType, filePath), - endMessage: S.current.tools_unp4k_msg_open_file(filePath)); - break; - default: - dPrint("[unp4kc] unknown action: $action"); - break; - } - } - - List? getFiles() { - final path = state.curPath.replaceAll("\\", "/"); - final fs = state.fs; - if (fs == null) return null; - final dir = fs.directory(path); - if (!dir.existsSync()) return []; - final files = dir.listSync(recursive: false, followLinks: false); - files.sort((a, b) { - if (a is Directory && b is File) { - return -1; - } else if (a is File && b is Directory) { - return 1; - } else { - return a.path.compareTo(b.path); - } - }); - final result = []; - for (var file in files) { - if (file is File) { - final f = state.files?[file.path.replaceAll("/", "\\")]; - if (f != null) { - if (!(f.name?.startsWith("\\") ?? true)) { - f.name = "\\${f.name}"; - } - result.add(f); - } - } else { - result.add(AppUnp4kP4kItemData( - name: file.path.replaceAll("/", "\\"), isDirectory: true)); - } - } - return result; - } - - void changeDir(String name, {bool fullPath = false}) { - if (fullPath) { - state = state.copyWith(curPath: name); - } else { - state = state.copyWith(curPath: "${state.curPath}$name\\"); - } - } - - openFile(String filePath) async { - final tempDir = await getTemporaryDirectory(); - final tempPath = - "${tempDir.absolute.path}\\SCToolbox_unp4kc\\${SCLoggerHelper.getGameChannelID(getGamePath())}\\"; - state = state.copyWith( - tempOpenFile: const MapEntry("loading", ""), - endMessage: S.current.tools_unp4k_msg_open_file(filePath)); - extractFile(filePath, tempPath, mode: "extract_open"); - } - - extractFile(String filePath, String outputPath, - {String mode = "extract"}) async { - // remove first \\ - if (filePath.startsWith("\\")) { - filePath = filePath.substring(1); - } - outputPath = "$outputPath$filePath"; - dPrint("extractFile .... $filePath"); - if (_rsPid != null) { - rs_process.write( - rsPid: _rsPid!, data: "$mode<:,:>$filePath<:,:>$outputPath\n"); - } - } - - static bool checkRunTimeError(String errorMessage) { - if (errorMessage - .contains("You must install .NET to run this application") || - errorMessage.contains( - "You must install or update .NET to run this application") || - errorMessage.contains( - "It was not possible to find any compatible framework version")) { - AnalyticsApi.touch("unp4k_no_runtime"); - return true; - } - return false; - } - - static Future unp4kTools( - String applicationBinaryModuleDir, List args) async { - await BinaryModuleConf.extractModule( - ["unp4kc"], applicationBinaryModuleDir); - final execDir = "$applicationBinaryModuleDir\\unp4kc"; - final exec = "$execDir\\unp4kc.exe"; - final r = await Process.run(exec, args); - if (r.exitCode != 0) { - Process.killPid(r.pid); - throw Exception( - "error: ${r.exitCode} , info= ${r.stdout} , err= ${r.stderr}"); - } - final eventJson = await compute(json.decode, r.stdout.toString()); - if (eventJson["action"] == "data: Uint8List") { - final data = eventJson["data"]; - return Uint8List.fromList((data as List).cast()); - } - throw Exception("error: data error"); - } -} diff --git a/lib/provider/unp4kc.freezed.dart b/lib/provider/unp4kc.freezed.dart deleted file mode 100644 index 5940016..0000000 --- a/lib/provider/unp4kc.freezed.dart +++ /dev/null @@ -1,304 +0,0 @@ -// coverage:ignore-file -// GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark - -part of 'unp4kc.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -T _$identity(T value) => value; - -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); - -/// @nodoc -mixin _$Unp4kcState { - bool get startUp => throw _privateConstructorUsedError; - Map? get files => - throw _privateConstructorUsedError; - MemoryFileSystem? get fs => throw _privateConstructorUsedError; - String get curPath => throw _privateConstructorUsedError; - String? get endMessage => throw _privateConstructorUsedError; - MapEntry? get tempOpenFile => - throw _privateConstructorUsedError; - String get errorMessage => throw _privateConstructorUsedError; - - /// Create a copy of Unp4kcState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $Unp4kcStateCopyWith get copyWith => - throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $Unp4kcStateCopyWith<$Res> { - factory $Unp4kcStateCopyWith( - Unp4kcState value, $Res Function(Unp4kcState) then) = - _$Unp4kcStateCopyWithImpl<$Res, Unp4kcState>; - @useResult - $Res call( - {bool startUp, - Map? files, - MemoryFileSystem? fs, - String curPath, - String? endMessage, - MapEntry? tempOpenFile, - String errorMessage}); -} - -/// @nodoc -class _$Unp4kcStateCopyWithImpl<$Res, $Val extends Unp4kcState> - implements $Unp4kcStateCopyWith<$Res> { - _$Unp4kcStateCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of Unp4kcState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? startUp = null, - Object? files = freezed, - Object? fs = freezed, - Object? curPath = null, - Object? endMessage = freezed, - Object? tempOpenFile = freezed, - Object? errorMessage = null, - }) { - return _then(_value.copyWith( - startUp: null == startUp - ? _value.startUp - : startUp // ignore: cast_nullable_to_non_nullable - as bool, - files: freezed == files - ? _value.files - : files // ignore: cast_nullable_to_non_nullable - as Map?, - fs: freezed == fs - ? _value.fs - : fs // ignore: cast_nullable_to_non_nullable - as MemoryFileSystem?, - curPath: null == curPath - ? _value.curPath - : curPath // ignore: cast_nullable_to_non_nullable - as String, - endMessage: freezed == endMessage - ? _value.endMessage - : endMessage // ignore: cast_nullable_to_non_nullable - as String?, - tempOpenFile: freezed == tempOpenFile - ? _value.tempOpenFile - : tempOpenFile // ignore: cast_nullable_to_non_nullable - as MapEntry?, - errorMessage: null == errorMessage - ? _value.errorMessage - : errorMessage // ignore: cast_nullable_to_non_nullable - as String, - ) as $Val); - } -} - -/// @nodoc -abstract class _$$Unp4kcStateImplCopyWith<$Res> - implements $Unp4kcStateCopyWith<$Res> { - factory _$$Unp4kcStateImplCopyWith( - _$Unp4kcStateImpl value, $Res Function(_$Unp4kcStateImpl) then) = - __$$Unp4kcStateImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {bool startUp, - Map? files, - MemoryFileSystem? fs, - String curPath, - String? endMessage, - MapEntry? tempOpenFile, - String errorMessage}); -} - -/// @nodoc -class __$$Unp4kcStateImplCopyWithImpl<$Res> - extends _$Unp4kcStateCopyWithImpl<$Res, _$Unp4kcStateImpl> - implements _$$Unp4kcStateImplCopyWith<$Res> { - __$$Unp4kcStateImplCopyWithImpl( - _$Unp4kcStateImpl _value, $Res Function(_$Unp4kcStateImpl) _then) - : super(_value, _then); - - /// Create a copy of Unp4kcState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? startUp = null, - Object? files = freezed, - Object? fs = freezed, - Object? curPath = null, - Object? endMessage = freezed, - Object? tempOpenFile = freezed, - Object? errorMessage = null, - }) { - return _then(_$Unp4kcStateImpl( - startUp: null == startUp - ? _value.startUp - : startUp // ignore: cast_nullable_to_non_nullable - as bool, - files: freezed == files - ? _value._files - : files // ignore: cast_nullable_to_non_nullable - as Map?, - fs: freezed == fs - ? _value.fs - : fs // ignore: cast_nullable_to_non_nullable - as MemoryFileSystem?, - curPath: null == curPath - ? _value.curPath - : curPath // ignore: cast_nullable_to_non_nullable - as String, - endMessage: freezed == endMessage - ? _value.endMessage - : endMessage // ignore: cast_nullable_to_non_nullable - as String?, - tempOpenFile: freezed == tempOpenFile - ? _value.tempOpenFile - : tempOpenFile // ignore: cast_nullable_to_non_nullable - as MapEntry?, - errorMessage: null == errorMessage - ? _value.errorMessage - : errorMessage // ignore: cast_nullable_to_non_nullable - as String, - )); - } -} - -/// @nodoc - -class _$Unp4kcStateImpl with DiagnosticableTreeMixin implements _Unp4kcState { - const _$Unp4kcStateImpl( - {required this.startUp, - final Map? files, - this.fs, - required this.curPath, - this.endMessage, - this.tempOpenFile, - this.errorMessage = ""}) - : _files = files; - - @override - final bool startUp; - final Map? _files; - @override - Map? get files { - final value = _files; - if (value == null) return null; - if (_files is EqualUnmodifiableMapView) return _files; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(value); - } - - @override - final MemoryFileSystem? fs; - @override - final String curPath; - @override - final String? endMessage; - @override - final MapEntry? tempOpenFile; - @override - @JsonKey() - final String errorMessage; - - @override - String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) { - return 'Unp4kcState(startUp: $startUp, files: $files, fs: $fs, curPath: $curPath, endMessage: $endMessage, tempOpenFile: $tempOpenFile, errorMessage: $errorMessage)'; - } - - @override - void debugFillProperties(DiagnosticPropertiesBuilder properties) { - super.debugFillProperties(properties); - properties - ..add(DiagnosticsProperty('type', 'Unp4kcState')) - ..add(DiagnosticsProperty('startUp', startUp)) - ..add(DiagnosticsProperty('files', files)) - ..add(DiagnosticsProperty('fs', fs)) - ..add(DiagnosticsProperty('curPath', curPath)) - ..add(DiagnosticsProperty('endMessage', endMessage)) - ..add(DiagnosticsProperty('tempOpenFile', tempOpenFile)) - ..add(DiagnosticsProperty('errorMessage', errorMessage)); - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$Unp4kcStateImpl && - (identical(other.startUp, startUp) || other.startUp == startUp) && - const DeepCollectionEquality().equals(other._files, _files) && - (identical(other.fs, fs) || other.fs == fs) && - (identical(other.curPath, curPath) || other.curPath == curPath) && - (identical(other.endMessage, endMessage) || - other.endMessage == endMessage) && - (identical(other.tempOpenFile, tempOpenFile) || - other.tempOpenFile == tempOpenFile) && - (identical(other.errorMessage, errorMessage) || - other.errorMessage == errorMessage)); - } - - @override - int get hashCode => Object.hash( - runtimeType, - startUp, - const DeepCollectionEquality().hash(_files), - fs, - curPath, - endMessage, - tempOpenFile, - errorMessage); - - /// Create a copy of Unp4kcState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$Unp4kcStateImplCopyWith<_$Unp4kcStateImpl> get copyWith => - __$$Unp4kcStateImplCopyWithImpl<_$Unp4kcStateImpl>(this, _$identity); -} - -abstract class _Unp4kcState implements Unp4kcState { - const factory _Unp4kcState( - {required final bool startUp, - final Map? files, - final MemoryFileSystem? fs, - required final String curPath, - final String? endMessage, - final MapEntry? tempOpenFile, - final String errorMessage}) = _$Unp4kcStateImpl; - - @override - bool get startUp; - @override - Map? get files; - @override - MemoryFileSystem? get fs; - @override - String get curPath; - @override - String? get endMessage; - @override - MapEntry? get tempOpenFile; - @override - String get errorMessage; - - /// Create a copy of Unp4kcState - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$Unp4kcStateImplCopyWith<_$Unp4kcStateImpl> get copyWith => - throw _privateConstructorUsedError; -} diff --git a/lib/provider/unp4kc.g.dart b/lib/provider/unp4kc.g.dart deleted file mode 100644 index b5a5a80..0000000 --- a/lib/provider/unp4kc.g.dart +++ /dev/null @@ -1,25 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'unp4kc.dart'; - -// ************************************************************************** -// RiverpodGenerator -// ************************************************************************** - -String _$unp4kCModelHash() => r'636da3fe20d1fa94917dd63934f08f8dbffc8a9d'; - -/// See also [Unp4kCModel]. -@ProviderFor(Unp4kCModel) -final unp4kCModelProvider = - AutoDisposeNotifierProvider.internal( - Unp4kCModel.new, - name: r'unp4kCModelProvider', - debugGetCreateSourceHash: - const bool.fromEnvironment('dart.vm.product') ? null : _$unp4kCModelHash, - dependencies: null, - allTransitiveDependencies: null, -); - -typedef _$Unp4kCModel = AutoDisposeNotifier; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member diff --git a/lib/ui/home/dialogs/home_game_login_dialog_ui.dart b/lib/ui/home/dialogs/home_game_login_dialog_ui.dart deleted file mode 100644 index ab56b5d..0000000 --- a/lib/ui/home/dialogs/home_game_login_dialog_ui.dart +++ /dev/null @@ -1,121 +0,0 @@ -import 'package:fluent_ui/fluent_ui.dart'; -import 'package:flutter_hooks/flutter_hooks.dart'; -import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:starcitizen_doctor/widgets/widgets.dart'; - -import 'home_game_login_dialog_ui_model.dart'; - -class HomeGameLoginDialogUI extends HookConsumerWidget { - final BuildContext launchContext; - - const HomeGameLoginDialogUI(this.launchContext, {super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final loginState = ref.watch(homeGameLoginUIModelProvider); - useEffect(() { - ref - .read(homeGameLoginUIModelProvider.notifier) - .launchWebLogin(launchContext); - return null; - }, []); - return ContentDialog( - constraints: BoxConstraints( - maxWidth: MediaQuery.of(context).size.width * .56, - ), - title: (loginState.loginStatus == 2) - ? null - : Text(S.current.home_action_one_click_launch), - content: AnimatedSize( - duration: const Duration(milliseconds: 230), - child: Padding( - padding: const EdgeInsets.only(top: 12, bottom: 0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - const Row(), - if (loginState.loginStatus == 0) ...[ - Center( - child: Column( - children: [ - Text(S.current.home_title_logging_in), - const SizedBox(height: 12), - const ProgressRing(), - ], - ), - ), - ] else if (loginState.loginStatus == 2 || - loginState.loginStatus == 3) ...[ - Center( - child: Column( - children: [ - const SizedBox(height: 12), - Text( - S.current.home_login_title_welcome_back, - style: const TextStyle(fontSize: 20), - ), - const SizedBox(height: 24), - if (loginState.avatarUrl != null) - ClipRRect( - borderRadius: BorderRadius.circular(1000), - child: CacheNetImage( - url: loginState.avatarUrl!, - width: 128, - height: 128, - fit: BoxFit.fill, - ), - ), - const SizedBox(height: 12), - Text( - loginState.nickname ?? "", - style: const TextStyle( - fontSize: 24, fontWeight: FontWeight.bold), - ), - const SizedBox(height: 12), - if (loginState.libraryData?.games != null) ...[ - Container( - padding: const EdgeInsets.all(6), - decoration: BoxDecoration( - color: FluentTheme.of(context).cardColor, - borderRadius: BorderRadius.circular(12), - ), - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - for (final game in loginState.libraryData!.games!) - Padding( - padding: const EdgeInsets.only( - left: 12, right: 12), - child: Row( - children: [ - Icon( - FluentIcons.skype_circle_check, - color: Colors.green, - ), - const SizedBox(width: 6), - Text("${game.name}"), - ], - ), - ) - ], - ), - ), - const SizedBox(height: 24) - ], - const SizedBox(height: 12), - Text(S.current.home_login_title_launching_game), - const SizedBox(height: 12), - const ProgressRing(), - const SizedBox(height: 12), - ], - ), - ) - ] - ], - ), - ), - ), - ); - } -} diff --git a/lib/ui/home/dialogs/home_game_login_dialog_ui_model.dart b/lib/ui/home/dialogs/home_game_login_dialog_ui_model.dart deleted file mode 100644 index 3ee1917..0000000 --- a/lib/ui/home/dialogs/home_game_login_dialog_ui_model.dart +++ /dev/null @@ -1,227 +0,0 @@ -import 'dart:convert'; -import 'dart:io'; - -import 'package:fluent_ui/fluent_ui.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:hive/hive.dart'; -import 'package:riverpod_annotation/riverpod_annotation.dart'; -import 'package:desktop_webview_window/desktop_webview_window.dart'; -import 'package:jwt_decode/jwt_decode.dart'; -import 'package:starcitizen_doctor/common/helper/system_helper.dart'; -import 'package:starcitizen_doctor/common/utils/base_utils.dart'; -import 'package:starcitizen_doctor/common/utils/log.dart'; -import 'package:starcitizen_doctor/common/utils/provider.dart'; -import 'package:starcitizen_doctor/data/rsi_game_library_data.dart'; -import 'package:starcitizen_doctor/ui/home/home_ui_model.dart'; -import 'package:starcitizen_doctor/ui/webview/webview.dart'; -import 'package:url_launcher/url_launcher_string.dart'; -import 'package:uuid/uuid.dart'; - -part 'home_game_login_dialog_ui_model.freezed.dart'; - -part 'home_game_login_dialog_ui_model.g.dart'; - -@freezed -class HomeGameLoginState with _$HomeGameLoginState { - factory HomeGameLoginState({ - required int loginStatus, - String? nickname, - String? avatarUrl, - String? authToken, - String? webToken, - Map? releaseInfo, - RsiGameLibraryData? libraryData, - String? installPath, - bool? isDeviceSupportWinHello, - }) = _LoginStatus; -} - -@riverpod -class HomeGameLoginUIModel extends _$HomeGameLoginUIModel { - @override - HomeGameLoginState build() { - return HomeGameLoginState(loginStatus: 0); - } - - // ignore: avoid_build_context_in_providers - Future launchWebLogin(BuildContext context) async { - final homeState = ref.read(homeUIModelProvider); - if (!context.mounted) return; - goWebView(context, S.current.home_action_login_rsi_account, - "https://robertsspaceindustries.com/connect?jumpto=/connect", - loginMode: true, rsiLoginCallback: (message, ok) async { - // dPrint( - // "======rsiLoginCallback=== $ok ===== data==\n${json.encode(message)}"); - if (message == null || !ok) { - Navigator.pop(context); - return; - } - - // final emailBox = await Hive.openBox("quick_login_email"); - final data = message["data"]; - final authToken = data["authToken"]; - final webToken = data["webToken"]; - final releaseInfo = data["releaseInfo"]; - final libraryData = RsiGameLibraryData.fromJson(data["libraryData"]); - final avatarUrl = data["avatar"] - ?.toString() - .replaceAll("url(\"", "") - .replaceAll("\")", ""); - final Map payload = Jwt.parseJwt(authToken!); - final nickname = payload["nickname"] ?? ""; - - state = state.copyWith( - nickname: nickname, - avatarUrl: avatarUrl, - authToken: authToken, - webToken: webToken, - releaseInfo: releaseInfo, - libraryData: libraryData, - ); - - final buildInfoFile = - File("${homeState.scInstalledPath}\\build_manifest.id"); - if (await buildInfoFile.exists()) { - final buildInfo = - json.decode(await buildInfoFile.readAsString())["Data"]; - - if (releaseInfo?["versionLabel"] != null && - buildInfo["RequestedP4ChangeNum"] != null) { - if (!(releaseInfo!["versionLabel"]! - .toString() - .endsWith(buildInfo["RequestedP4ChangeNum"]!.toString()))) { - if (!context.mounted) return; - final ok = await showConfirmDialogs( - context, - S.current.home_login_info_game_version_outdated, - Text(S.current.home_login_info_rsi_server_report( - releaseInfo?["versionLabel"], - buildInfo["RequestedP4ChangeNum"])), - constraints: BoxConstraints( - maxWidth: MediaQuery.of(context).size.width * .4), - cancel: S.current.home_login_info_action_ignore); - if (ok == true) { - if (!context.mounted) return; - Navigator.pop(context); - return; - } - } - } - } - - if (!context.mounted) return; - _readyForLaunch(homeState, context); - }, useLocalization: true, homeState: homeState); - } - - // ignore: avoid_build_context_in_providers - goWebView(BuildContext context, String title, String url, - {bool useLocalization = false, - bool loginMode = false, - RsiLoginCallback? rsiLoginCallback, - required HomeUIModelState homeState}) async { - if (useLocalization) { - const tipVersion = 2; - final box = await Hive.openBox("app_conf"); - final skip = await box.get("skip_web_login_version", defaultValue: 0); - if (skip != tipVersion) { - if (!context.mounted) return; - final ok = await showConfirmDialogs( - context, - S.current.home_login_action_title_box_one_click_launch, - Text( - S.current.home_login_info_one_click_launch_description, - style: const TextStyle(fontSize: 16), - ), - constraints: BoxConstraints( - maxWidth: MediaQuery.of(context).size.width * .6)); - if (!ok) { - if (loginMode) { - rsiLoginCallback?.call(null, false); - } - return; - } - await box.put("skip_web_login_version", tipVersion); - } - } - if (!await WebviewWindow.isWebviewAvailable()) { - if (!context.mounted) return; - await showToast( - context, S.current.home_login_action_title_need_webview2_runtime); - if (!context.mounted) return; - await launchUrlString( - "https://developer.microsoft.com/en-us/microsoft-edge/webview2/"); - if (!context.mounted) return; - Navigator.pop(context); - return; - } - if (!context.mounted) return; - final webViewModel = WebViewModel(context, - loginMode: loginMode, - loginCallback: rsiLoginCallback, - loginChannel: getChannelID(homeState.scInstalledPath!)); - if (useLocalization) { - try { - await webViewModel - .initLocalization(homeState.webLocalizationVersionsData!); - } catch (_) {} - } - await Future.delayed(const Duration(milliseconds: 500)); - await webViewModel.initWebView( - title: title, - applicationSupportDir: appGlobalState.applicationSupportDir!, - appVersionData: appGlobalState.networkVersionData!, - ); - await webViewModel.launch(url, appGlobalState.networkVersionData!); - } - - Future _readyForLaunch( - HomeUIModelState homeState, - // ignore: avoid_build_context_in_providers - BuildContext context) async { - final userBox = await Hive.openBox("rsi_account_data"); - state = state.copyWith(loginStatus: 2); - final launchData = { - "username": userBox.get("account_email", defaultValue: ""), - "token": state.webToken, - "auth_token": state.authToken, - "star_network": { - "services_endpoint": state.releaseInfo?["servicesEndpoint"], - "hostname": state.releaseInfo?["universeHost"], - "port": state.releaseInfo?["universePort"], - }, - "TMid": const Uuid().v4(), - }; - final executable = state.releaseInfo?["executable"]; - final launchOptions = state.releaseInfo?["launchOptions"]; - // dPrint("----------launch data ====== -----------\n$launchData"); - // dPrint( - // "----------executable data ====== -----------\n${homeState.scInstalledPath}\\$executable $launchOptions"); - - final launchFile = File("${homeState.scInstalledPath}\\loginData.json"); - if (await launchFile.exists()) { - await launchFile.delete(); - } - await launchFile.create(); - await launchFile.writeAsString(json.encode(launchData)); - final processorAffinity = await SystemHelper.getCpuAffinity(); - final homeUIModel = ref.read(homeUIModelProvider.notifier); - if (!context.mounted) return; - homeUIModel.doLaunchGame( - context, - '${homeState.scInstalledPath}\\$executable', - ["-no_login_dialog", ...launchOptions.toString().split(" ")], - homeState.scInstalledPath!, - processorAffinity); - await Future.delayed(const Duration(seconds: 1)); - if (!context.mounted) return; - Navigator.pop(context); - } - - String getChannelID(String installPath) { - if (installPath.endsWith("\\LIVE")) { - return "LIVE"; - } - return "PTU"; - } -} diff --git a/lib/ui/home/dialogs/home_game_login_dialog_ui_model.freezed.dart b/lib/ui/home/dialogs/home_game_login_dialog_ui_model.freezed.dart deleted file mode 100644 index f2c23cb..0000000 --- a/lib/ui/home/dialogs/home_game_login_dialog_ui_model.freezed.dart +++ /dev/null @@ -1,336 +0,0 @@ -// coverage:ignore-file -// GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark - -part of 'home_game_login_dialog_ui_model.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -T _$identity(T value) => value; - -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); - -/// @nodoc -mixin _$HomeGameLoginState { - int get loginStatus => throw _privateConstructorUsedError; - String? get nickname => throw _privateConstructorUsedError; - String? get avatarUrl => throw _privateConstructorUsedError; - String? get authToken => throw _privateConstructorUsedError; - String? get webToken => throw _privateConstructorUsedError; - Map? get releaseInfo => throw _privateConstructorUsedError; - RsiGameLibraryData? get libraryData => throw _privateConstructorUsedError; - String? get installPath => throw _privateConstructorUsedError; - bool? get isDeviceSupportWinHello => throw _privateConstructorUsedError; - - /// Create a copy of HomeGameLoginState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $HomeGameLoginStateCopyWith get copyWith => - throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $HomeGameLoginStateCopyWith<$Res> { - factory $HomeGameLoginStateCopyWith( - HomeGameLoginState value, $Res Function(HomeGameLoginState) then) = - _$HomeGameLoginStateCopyWithImpl<$Res, HomeGameLoginState>; - @useResult - $Res call( - {int loginStatus, - String? nickname, - String? avatarUrl, - String? authToken, - String? webToken, - Map? releaseInfo, - RsiGameLibraryData? libraryData, - String? installPath, - bool? isDeviceSupportWinHello}); -} - -/// @nodoc -class _$HomeGameLoginStateCopyWithImpl<$Res, $Val extends HomeGameLoginState> - implements $HomeGameLoginStateCopyWith<$Res> { - _$HomeGameLoginStateCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of HomeGameLoginState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? loginStatus = null, - Object? nickname = freezed, - Object? avatarUrl = freezed, - Object? authToken = freezed, - Object? webToken = freezed, - Object? releaseInfo = freezed, - Object? libraryData = freezed, - Object? installPath = freezed, - Object? isDeviceSupportWinHello = freezed, - }) { - return _then(_value.copyWith( - loginStatus: null == loginStatus - ? _value.loginStatus - : loginStatus // ignore: cast_nullable_to_non_nullable - as int, - nickname: freezed == nickname - ? _value.nickname - : nickname // ignore: cast_nullable_to_non_nullable - as String?, - avatarUrl: freezed == avatarUrl - ? _value.avatarUrl - : avatarUrl // ignore: cast_nullable_to_non_nullable - as String?, - authToken: freezed == authToken - ? _value.authToken - : authToken // ignore: cast_nullable_to_non_nullable - as String?, - webToken: freezed == webToken - ? _value.webToken - : webToken // ignore: cast_nullable_to_non_nullable - as String?, - releaseInfo: freezed == releaseInfo - ? _value.releaseInfo - : releaseInfo // ignore: cast_nullable_to_non_nullable - as Map?, - libraryData: freezed == libraryData - ? _value.libraryData - : libraryData // ignore: cast_nullable_to_non_nullable - as RsiGameLibraryData?, - installPath: freezed == installPath - ? _value.installPath - : installPath // ignore: cast_nullable_to_non_nullable - as String?, - isDeviceSupportWinHello: freezed == isDeviceSupportWinHello - ? _value.isDeviceSupportWinHello - : isDeviceSupportWinHello // ignore: cast_nullable_to_non_nullable - as bool?, - ) as $Val); - } -} - -/// @nodoc -abstract class _$$LoginStatusImplCopyWith<$Res> - implements $HomeGameLoginStateCopyWith<$Res> { - factory _$$LoginStatusImplCopyWith( - _$LoginStatusImpl value, $Res Function(_$LoginStatusImpl) then) = - __$$LoginStatusImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {int loginStatus, - String? nickname, - String? avatarUrl, - String? authToken, - String? webToken, - Map? releaseInfo, - RsiGameLibraryData? libraryData, - String? installPath, - bool? isDeviceSupportWinHello}); -} - -/// @nodoc -class __$$LoginStatusImplCopyWithImpl<$Res> - extends _$HomeGameLoginStateCopyWithImpl<$Res, _$LoginStatusImpl> - implements _$$LoginStatusImplCopyWith<$Res> { - __$$LoginStatusImplCopyWithImpl( - _$LoginStatusImpl _value, $Res Function(_$LoginStatusImpl) _then) - : super(_value, _then); - - /// Create a copy of HomeGameLoginState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? loginStatus = null, - Object? nickname = freezed, - Object? avatarUrl = freezed, - Object? authToken = freezed, - Object? webToken = freezed, - Object? releaseInfo = freezed, - Object? libraryData = freezed, - Object? installPath = freezed, - Object? isDeviceSupportWinHello = freezed, - }) { - return _then(_$LoginStatusImpl( - loginStatus: null == loginStatus - ? _value.loginStatus - : loginStatus // ignore: cast_nullable_to_non_nullable - as int, - nickname: freezed == nickname - ? _value.nickname - : nickname // ignore: cast_nullable_to_non_nullable - as String?, - avatarUrl: freezed == avatarUrl - ? _value.avatarUrl - : avatarUrl // ignore: cast_nullable_to_non_nullable - as String?, - authToken: freezed == authToken - ? _value.authToken - : authToken // ignore: cast_nullable_to_non_nullable - as String?, - webToken: freezed == webToken - ? _value.webToken - : webToken // ignore: cast_nullable_to_non_nullable - as String?, - releaseInfo: freezed == releaseInfo - ? _value._releaseInfo - : releaseInfo // ignore: cast_nullable_to_non_nullable - as Map?, - libraryData: freezed == libraryData - ? _value.libraryData - : libraryData // ignore: cast_nullable_to_non_nullable - as RsiGameLibraryData?, - installPath: freezed == installPath - ? _value.installPath - : installPath // ignore: cast_nullable_to_non_nullable - as String?, - isDeviceSupportWinHello: freezed == isDeviceSupportWinHello - ? _value.isDeviceSupportWinHello - : isDeviceSupportWinHello // ignore: cast_nullable_to_non_nullable - as bool?, - )); - } -} - -/// @nodoc - -class _$LoginStatusImpl implements _LoginStatus { - _$LoginStatusImpl( - {required this.loginStatus, - this.nickname, - this.avatarUrl, - this.authToken, - this.webToken, - final Map? releaseInfo, - this.libraryData, - this.installPath, - this.isDeviceSupportWinHello}) - : _releaseInfo = releaseInfo; - - @override - final int loginStatus; - @override - final String? nickname; - @override - final String? avatarUrl; - @override - final String? authToken; - @override - final String? webToken; - final Map? _releaseInfo; - @override - Map? get releaseInfo { - final value = _releaseInfo; - if (value == null) return null; - if (_releaseInfo is EqualUnmodifiableMapView) return _releaseInfo; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(value); - } - - @override - final RsiGameLibraryData? libraryData; - @override - final String? installPath; - @override - final bool? isDeviceSupportWinHello; - - @override - String toString() { - return 'HomeGameLoginState(loginStatus: $loginStatus, nickname: $nickname, avatarUrl: $avatarUrl, authToken: $authToken, webToken: $webToken, releaseInfo: $releaseInfo, libraryData: $libraryData, installPath: $installPath, isDeviceSupportWinHello: $isDeviceSupportWinHello)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$LoginStatusImpl && - (identical(other.loginStatus, loginStatus) || - other.loginStatus == loginStatus) && - (identical(other.nickname, nickname) || - other.nickname == nickname) && - (identical(other.avatarUrl, avatarUrl) || - other.avatarUrl == avatarUrl) && - (identical(other.authToken, authToken) || - other.authToken == authToken) && - (identical(other.webToken, webToken) || - other.webToken == webToken) && - const DeepCollectionEquality() - .equals(other._releaseInfo, _releaseInfo) && - (identical(other.libraryData, libraryData) || - other.libraryData == libraryData) && - (identical(other.installPath, installPath) || - other.installPath == installPath) && - (identical( - other.isDeviceSupportWinHello, isDeviceSupportWinHello) || - other.isDeviceSupportWinHello == isDeviceSupportWinHello)); - } - - @override - int get hashCode => Object.hash( - runtimeType, - loginStatus, - nickname, - avatarUrl, - authToken, - webToken, - const DeepCollectionEquality().hash(_releaseInfo), - libraryData, - installPath, - isDeviceSupportWinHello); - - /// Create a copy of HomeGameLoginState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$LoginStatusImplCopyWith<_$LoginStatusImpl> get copyWith => - __$$LoginStatusImplCopyWithImpl<_$LoginStatusImpl>(this, _$identity); -} - -abstract class _LoginStatus implements HomeGameLoginState { - factory _LoginStatus( - {required final int loginStatus, - final String? nickname, - final String? avatarUrl, - final String? authToken, - final String? webToken, - final Map? releaseInfo, - final RsiGameLibraryData? libraryData, - final String? installPath, - final bool? isDeviceSupportWinHello}) = _$LoginStatusImpl; - - @override - int get loginStatus; - @override - String? get nickname; - @override - String? get avatarUrl; - @override - String? get authToken; - @override - String? get webToken; - @override - Map? get releaseInfo; - @override - RsiGameLibraryData? get libraryData; - @override - String? get installPath; - @override - bool? get isDeviceSupportWinHello; - - /// Create a copy of HomeGameLoginState - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$LoginStatusImplCopyWith<_$LoginStatusImpl> get copyWith => - throw _privateConstructorUsedError; -} diff --git a/lib/ui/home/dialogs/home_game_login_dialog_ui_model.g.dart b/lib/ui/home/dialogs/home_game_login_dialog_ui_model.g.dart deleted file mode 100644 index 5e4d4b3..0000000 --- a/lib/ui/home/dialogs/home_game_login_dialog_ui_model.g.dart +++ /dev/null @@ -1,27 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'home_game_login_dialog_ui_model.dart'; - -// ************************************************************************** -// RiverpodGenerator -// ************************************************************************** - -String _$homeGameLoginUIModelHash() => - r'e8afccb7bba7c79e766e30a27f64128918a63dd7'; - -/// See also [HomeGameLoginUIModel]. -@ProviderFor(HomeGameLoginUIModel) -final homeGameLoginUIModelProvider = AutoDisposeNotifierProvider< - HomeGameLoginUIModel, HomeGameLoginState>.internal( - HomeGameLoginUIModel.new, - name: r'homeGameLoginUIModelProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$homeGameLoginUIModelHash, - dependencies: null, - allTransitiveDependencies: null, -); - -typedef _$HomeGameLoginUIModel = AutoDisposeNotifier; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member diff --git a/lib/ui/home/downloader/home_downloader_ui.dart b/lib/ui/home/downloader/home_downloader_ui.dart deleted file mode 100644 index 5df51c9..0000000 --- a/lib/ui/home/downloader/home_downloader_ui.dart +++ /dev/null @@ -1,260 +0,0 @@ -import 'package:fluent_ui/fluent_ui.dart'; -import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:starcitizen_doctor/widgets/widgets.dart'; -import 'package:file_sizes/file_sizes.dart'; - -import 'home_downloader_ui_model.dart'; - -class HomeDownloaderUI extends HookConsumerWidget { - const HomeDownloaderUI({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(homeDownloaderUIModelProvider); - final model = ref.read(homeDownloaderUIModelProvider.notifier); - - return makeDefaultPage(context, - content: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const SizedBox(height: 12), - Row( - children: [ - const Spacer(), - const SizedBox(width: 24), - const SizedBox(width: 12), - for (final item in , String>{ - const MapEntry("settings", FluentIcons.settings): - S.current.downloader_speed_limit_settings, - if (state.tasks.isNotEmpty) - const MapEntry("pause_all", FluentIcons.pause): - S.current.downloader_action_pause_all, - if (state.waitingTasks.isNotEmpty) - const MapEntry("resume_all", FluentIcons.download): - S.current.downloader_action_resume_all, - if (state.tasks.isNotEmpty || state.waitingTasks.isNotEmpty) - const MapEntry("cancel_all", FluentIcons.cancel): - S.current.downloader_action_cancel_all, - }.entries) - Padding( - padding: const EdgeInsets.only(left: 6, right: 6), - child: Button( - child: Padding( - padding: const EdgeInsets.all(4), - child: Row( - children: [ - Icon(item.key.value), - const SizedBox(width: 6), - Text(item.value), - ], - ), - ), - onPressed: () => - model.onTapButton(context, item.key.key)), - ), - const SizedBox(width: 12), - ], - ), - if (model.getTasksLen() == 0) - Expanded( - child: Center( - child: Text(S.current.downloader_info_no_download_tasks), - )) - else - Expanded( - child: ListView.builder( - itemBuilder: (BuildContext context, int index) { - final (task, type, isFirstType) = model.getTaskAndType(index); - final nt = HomeDownloaderUIModel.getTaskTypeAndName(task); - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - if (isFirstType) - Column( - children: [ - Container( - padding: EdgeInsets.only( - left: 24, - right: 24, - top: index == 0 ? 0 : 12, - bottom: 12), - margin: const EdgeInsets.only(top: 6, bottom: 6), - child: Row( - children: [ - Expanded( - child: Row( - children: [ - Text( - "${model.listHeaderStatusMap[type]}", - style: const TextStyle( - fontSize: 24, - fontWeight: FontWeight.bold), - ), - ], - )), - ], - ), - ), - ], - ), - Container( - padding: const EdgeInsets.only( - left: 12, right: 12, top: 12, bottom: 12), - margin: const EdgeInsets.only( - left: 12, right: 12, top: 6, bottom: 6), - decoration: BoxDecoration( - color: FluentTheme.of(context) - .cardColor - .withOpacity(.06), - borderRadius: BorderRadius.circular(7), - ), - child: Row( - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - nt.value, - style: const TextStyle( - fontSize: 18, - fontWeight: FontWeight.bold), - ), - const SizedBox(height: 6), - Row( - children: [ - Text( - S.current.downloader_info_total_size( - FileSize.getSize( - task.totalLength ?? 0)), - style: const TextStyle(fontSize: 14), - ), - const SizedBox(width: 12), - if (nt.key == "torrent" && - task.verifiedLength != null && - task.verifiedLength != 0) - Text( - S.current.downloader_info_verifying( - FileSize.getSize( - task.verifiedLength)), - style: const TextStyle(fontSize: 14), - ) - else if (task.status == "active") - Text(S.current - .downloader_info_downloading( - ((task.completedLength ?? 0) * - 100 / - (task.totalLength ?? 1)) - .toStringAsFixed(4))) - else - Text(S.current.downloader_info_status( - model.statusMap[task.status] ?? - "Unknown")), - const SizedBox(width: 24), - if (task.status == "active" && - task.verifiedLength == null) - Text( - "ETA: ${model.formatter.format(DateTime.now().add(Duration(seconds: model.getETA(task))))}"), - ], - ), - ], - ), - const Spacer(), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text(S.current.downloader_info_uploaded( - FileSize.getSize(task.uploadLength))), - Text(S.current.downloader_info_downloaded( - FileSize.getSize(task.completedLength))), - ], - ), - const SizedBox(width: 18), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "↑:${FileSize.getSize(task.uploadSpeed)}/s"), - Text( - "↓:${FileSize.getSize(task.downloadSpeed)}/s"), - ], - ), - const SizedBox(width: 32), - if (type != "stopped") - DropDownButton( - closeAfterClick: false, - title: Padding( - padding: const EdgeInsets.all(3), - child: - Text(S.current.downloader_action_options), - ), - items: [ - if (task.status == "paused") - MenuFlyoutItem( - leading: - const Icon(FluentIcons.download), - text: Text(S.current - .downloader_action_continue_download), - onPressed: () => - model.resumeTask(task.gid)) - else if (task.status == "active") - MenuFlyoutItem( - leading: const Icon(FluentIcons.pause), - text: Text(S.current - .downloader_action_pause_download), - onPressed: () => - model.pauseTask(task.gid)), - const MenuFlyoutSeparator(), - MenuFlyoutItem( - leading: const Icon( - FluentIcons.chrome_close, - size: 14, - ), - text: Text(S.current - .downloader_action_cancel_download), - onPressed: () => - model.cancelTask(context, task.gid)), - MenuFlyoutItem( - leading: const Icon( - FluentIcons.folder_open, - size: 14, - ), - text: Text(S.current.action_open_folder), - onPressed: () => model.openFolder(task)), - ], - ), - const SizedBox(width: 12), - ], - ), - ), - ], - ); - }, - itemCount: model.getTasksLen(), - )), - Container( - color: FluentTheme.of(context).cardColor.withOpacity(.06), - child: Padding( - padding: const EdgeInsets.only(left: 12, bottom: 3, top: 3), - child: Row( - children: [ - Container( - width: 8, - height: 8, - decoration: BoxDecoration( - color: state.isAvailable ? Colors.green : Colors.white, - borderRadius: BorderRadius.circular(1000), - ), - ), - const SizedBox(width: 12), - Text(S.current.downloader_info_download_upload_speed( - FileSize.getSize(state.globalStat?.downloadSpeed ?? 0), - FileSize.getSize(state.globalStat?.uploadSpeed ?? 0))) - ], - ), - ), - ), - ], - ), - useBodyContainer: true); - } -} diff --git a/lib/ui/home/downloader/home_downloader_ui_model.dart b/lib/ui/home/downloader/home_downloader_ui_model.dart deleted file mode 100644 index 5e2aaf0..0000000 --- a/lib/ui/home/downloader/home_downloader_ui_model.dart +++ /dev/null @@ -1,310 +0,0 @@ -// ignore_for_file: avoid_build_context_in_providers, avoid_public_notifier_properties -import 'dart:io'; - -import 'package:aria2/aria2.dart'; -import 'package:fluent_ui/fluent_ui.dart'; -import 'package:flutter/services.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:hive/hive.dart'; -import 'package:intl/intl.dart'; -import 'package:riverpod_annotation/riverpod_annotation.dart'; -import 'package:starcitizen_doctor/common/helper/system_helper.dart'; -import 'package:starcitizen_doctor/common/utils/log.dart'; -import 'package:starcitizen_doctor/common/utils/provider.dart'; -import 'package:starcitizen_doctor/provider/aria2c.dart'; - -import '../../../widgets/widgets.dart'; - -part 'home_downloader_ui_model.g.dart'; - -part 'home_downloader_ui_model.freezed.dart'; - -@freezed -class HomeDownloaderUIState with _$HomeDownloaderUIState { - factory HomeDownloaderUIState({ - @Default([]) List tasks, - @Default([]) List waitingTasks, - @Default([]) List stoppedTasks, - Aria2GlobalStat? globalStat, - }) = _HomeDownloaderUIState; -} - -extension HomeDownloaderUIStateExtension on HomeDownloaderUIState { - bool get isAvailable => globalStat != null; -} - -@riverpod -class HomeDownloaderUIModel extends _$HomeDownloaderUIModel { - final DateFormat formatter = DateFormat('yyyy-MM-dd HH:mm:ss'); - - bool _disposed = false; - - final statusMap = { - "active": S.current.downloader_info_downloading_status, - "waiting": S.current.downloader_info_waiting, - "paused": S.current.downloader_info_paused, - "error": S.current.downloader_info_download_failed, - "complete": S.current.downloader_info_download_completed, - "removed": S.current.downloader_info_deleted, - }; - - final listHeaderStatusMap = { - "active": S.current.downloader_title_downloading, - "waiting": S.current.downloader_info_waiting, - "stopped": S.current.downloader_title_ended, - }; - - @override - HomeDownloaderUIState build() { - state = HomeDownloaderUIState(); - _listenDownloader(); - ref.onDispose(() { - _disposed = true; - }); - return state; - } - - onTapButton(BuildContext context, String key) async { - final aria2cState = ref.read(aria2cModelProvider); - switch (key) { - case "pause_all": - if (!aria2cState.isRunning) return; - await aria2cState.aria2c?.pauseAll(); - await aria2cState.aria2c?.saveSession(); - return; - case "resume_all": - if (!aria2cState.isRunning) return; - await aria2cState.aria2c?.unpauseAll(); - await aria2cState.aria2c?.saveSession(); - return; - case "cancel_all": - final userOK = await showConfirmDialogs( - context, - S.current.downloader_action_confirm_cancel_all_tasks, - Text(S.current.downloader_info_manual_file_deletion_note)); - if (userOK == true) { - if (!aria2cState.isRunning) return; - try { - for (var value in [...state.tasks, ...state.waitingTasks]) { - await aria2cState.aria2c?.remove(value.gid!); - } - await aria2cState.aria2c?.saveSession(); - } catch (e) { - dPrint("DownloadsUIModel cancel_all Error: $e"); - } - } - return; - case "settings": - _showDownloadSpeedSettings(context); - return; - } - } - - int getTasksLen() { - return state.tasks.length + - state.waitingTasks.length + - state.stoppedTasks.length; - } - - (Aria2Task, String, bool) getTaskAndType(int index) { - final tempList = [ - ...state.tasks, - ...state.waitingTasks, - ...state.stoppedTasks - ]; - if (index >= 0 && index < state.tasks.length) { - return (tempList[index], "active", index == 0); - } - if (index >= state.tasks.length && - index < state.tasks.length + state.waitingTasks.length) { - return (tempList[index], "waiting", index == state.tasks.length); - } - if (index >= state.tasks.length + state.waitingTasks.length && - index < tempList.length) { - return ( - tempList[index], - "stopped", - index == state.tasks.length + state.waitingTasks.length - ); - } - throw Exception("Index out of range or element is null"); - } - - static MapEntry getTaskTypeAndName(Aria2Task task) { - if (task.bittorrent == null) { - String uri = task.files?[0]['uris'][0]['uri'] as String; - return MapEntry("url", uri.split('/').last); - } else if (task.bittorrent != null) { - if (task.bittorrent!.containsKey('info')) { - var btName = task.bittorrent?["info"]["name"]; - return MapEntry("torrent", btName ?? 'torrent'); - } else { - return MapEntry("magnet", '[METADATA]${task.infoHash}'); - } - } else { - return const MapEntry("metaLink", '==========metaLink============'); - } - } - - int getETA(Aria2Task task) { - if (task.downloadSpeed == null || task.downloadSpeed == 0) return 0; - final remainingBytes = - (task.totalLength ?? 0) - (task.completedLength ?? 0); - return remainingBytes ~/ (task.downloadSpeed!); - } - - Future resumeTask(String? gid) async { - final aria2c = ref.read(aria2cModelProvider).aria2c; - if (gid != null) { - await aria2c?.unpause(gid); - } - } - - Future pauseTask(String? gid) async { - final aria2c = ref.read(aria2cModelProvider).aria2c; - if (gid != null) { - await aria2c?.pause(gid); - } - } - - Future cancelTask(BuildContext context, String? gid) async { - await Future.delayed(const Duration(milliseconds: 300)); - if (gid != null) { - if (!context.mounted) return; - final ok = await showConfirmDialogs( - context, - S.current.downloader_action_confirm_cancel_download, - Text(S.current.downloader_info_manual_file_deletion_note)); - if (ok == true) { - final aria2c = ref.read(aria2cModelProvider).aria2c; - await aria2c?.remove(gid); - await aria2c?.saveSession(); - } - } - } - - List getFilesFormTask(Aria2Task task) { - List l = []; - if (task.files != null) { - for (var element in task.files!) { - final f = Aria2File.fromJson(element); - l.add(f); - } - } - return l; - } - - openFolder(Aria2Task task) { - final f = getFilesFormTask(task).firstOrNull; - if (f != null) { - SystemHelper.openDir(File(f.path!).absolute.path.replaceAll("/", "\\")); - } - } - - _listenDownloader() async { - try { - while (true) { - final aria2cState = ref.read(aria2cModelProvider); - if (_disposed) return; - if (aria2cState.isRunning) { - final aria2c = aria2cState.aria2c!; - final tasks = await aria2c.tellActive(); - final waitingTasks = await aria2c.tellWaiting(0, 1000000); - final stoppedTasks = await aria2c.tellStopped(0, 1000000); - final globalStat = await aria2c.getGlobalStat(); - state = state.copyWith( - tasks: tasks, - waitingTasks: waitingTasks, - stoppedTasks: stoppedTasks, - globalStat: globalStat, - ); - } else { - state = state.copyWith( - tasks: [], - waitingTasks: [], - stoppedTasks: [], - globalStat: null, - ); - } - await Future.delayed(const Duration(seconds: 1)); - } - } catch (e) { - dPrint("[DownloadsUIModel]._listenDownloader Error: $e"); - } - } - - Future _showDownloadSpeedSettings(BuildContext context) async { - final box = await Hive.openBox("app_conf"); - - final upCtrl = TextEditingController( - text: box.get("downloader_up_limit", defaultValue: "")); - final downCtrl = TextEditingController( - text: box.get("downloader_down_limit", defaultValue: "")); - - final ifr = FilteringTextInputFormatter.allow(RegExp(r'^\d*[km]?$')); - - if (!context.mounted) return; - final ok = await showConfirmDialogs( - context, - S.current.downloader_speed_limit_settings, - Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - S.current.downloader_info_p2p_network_note, - style: TextStyle( - fontSize: 14, - color: Colors.white.withOpacity(.6), - ), - ), - const SizedBox(height: 24), - Text(S.current.downloader_info_download_unit_input_prompt), - const SizedBox(height: 12), - Text(S.current.downloader_input_upload_speed_limit), - const SizedBox(height: 6), - TextFormBox( - placeholder: "1、100k、10m、0", - controller: upCtrl, - placeholderStyle: TextStyle(color: Colors.white.withOpacity(.6)), - inputFormatters: [ifr], - ), - const SizedBox(height: 12), - Text(S.current.downloader_input_download_speed_limit), - const SizedBox(height: 6), - TextFormBox( - placeholder: "1、100k、10m、0", - controller: downCtrl, - placeholderStyle: TextStyle(color: Colors.white.withOpacity(.6)), - inputFormatters: [ifr], - ), - const SizedBox(height: 24), - Text( - S.current.downloader_input_info_p2p_upload_note, - style: TextStyle( - fontSize: 13, - color: Colors.white.withOpacity(.6), - ), - ) - ], - )); - if (ok == true) { - final aria2cState = ref.read(aria2cModelProvider); - final aria2cModel = ref.read(aria2cModelProvider.notifier); - await aria2cModel - .launchDaemon(appGlobalState.applicationBinaryModuleDir!); - final aria2c = aria2cState.aria2c!; - final upByte = aria2cModel.textToByte(upCtrl.text.trim()); - final downByte = aria2cModel.textToByte(downCtrl.text.trim()); - final r = await aria2c - .changeGlobalOption(Aria2Option() - ..maxOverallUploadLimit = upByte - ..maxOverallDownloadLimit = downByte) - .unwrap(); - if (r != null) { - await box.put('downloader_up_limit', upCtrl.text.trim()); - await box.put('downloader_down_limit', downCtrl.text.trim()); - } - } - } -} diff --git a/lib/ui/home/downloader/home_downloader_ui_model.freezed.dart b/lib/ui/home/downloader/home_downloader_ui_model.freezed.dart deleted file mode 100644 index 88957e1..0000000 --- a/lib/ui/home/downloader/home_downloader_ui_model.freezed.dart +++ /dev/null @@ -1,243 +0,0 @@ -// coverage:ignore-file -// GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark - -part of 'home_downloader_ui_model.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -T _$identity(T value) => value; - -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); - -/// @nodoc -mixin _$HomeDownloaderUIState { - List get tasks => throw _privateConstructorUsedError; - List get waitingTasks => throw _privateConstructorUsedError; - List get stoppedTasks => throw _privateConstructorUsedError; - Aria2GlobalStat? get globalStat => throw _privateConstructorUsedError; - - /// Create a copy of HomeDownloaderUIState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $HomeDownloaderUIStateCopyWith get copyWith => - throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $HomeDownloaderUIStateCopyWith<$Res> { - factory $HomeDownloaderUIStateCopyWith(HomeDownloaderUIState value, - $Res Function(HomeDownloaderUIState) then) = - _$HomeDownloaderUIStateCopyWithImpl<$Res, HomeDownloaderUIState>; - @useResult - $Res call( - {List tasks, - List waitingTasks, - List stoppedTasks, - Aria2GlobalStat? globalStat}); -} - -/// @nodoc -class _$HomeDownloaderUIStateCopyWithImpl<$Res, - $Val extends HomeDownloaderUIState> - implements $HomeDownloaderUIStateCopyWith<$Res> { - _$HomeDownloaderUIStateCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of HomeDownloaderUIState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? tasks = null, - Object? waitingTasks = null, - Object? stoppedTasks = null, - Object? globalStat = freezed, - }) { - return _then(_value.copyWith( - tasks: null == tasks - ? _value.tasks - : tasks // ignore: cast_nullable_to_non_nullable - as List, - waitingTasks: null == waitingTasks - ? _value.waitingTasks - : waitingTasks // ignore: cast_nullable_to_non_nullable - as List, - stoppedTasks: null == stoppedTasks - ? _value.stoppedTasks - : stoppedTasks // ignore: cast_nullable_to_non_nullable - as List, - globalStat: freezed == globalStat - ? _value.globalStat - : globalStat // ignore: cast_nullable_to_non_nullable - as Aria2GlobalStat?, - ) as $Val); - } -} - -/// @nodoc -abstract class _$$HomeDownloaderUIStateImplCopyWith<$Res> - implements $HomeDownloaderUIStateCopyWith<$Res> { - factory _$$HomeDownloaderUIStateImplCopyWith( - _$HomeDownloaderUIStateImpl value, - $Res Function(_$HomeDownloaderUIStateImpl) then) = - __$$HomeDownloaderUIStateImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {List tasks, - List waitingTasks, - List stoppedTasks, - Aria2GlobalStat? globalStat}); -} - -/// @nodoc -class __$$HomeDownloaderUIStateImplCopyWithImpl<$Res> - extends _$HomeDownloaderUIStateCopyWithImpl<$Res, - _$HomeDownloaderUIStateImpl> - implements _$$HomeDownloaderUIStateImplCopyWith<$Res> { - __$$HomeDownloaderUIStateImplCopyWithImpl(_$HomeDownloaderUIStateImpl _value, - $Res Function(_$HomeDownloaderUIStateImpl) _then) - : super(_value, _then); - - /// Create a copy of HomeDownloaderUIState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? tasks = null, - Object? waitingTasks = null, - Object? stoppedTasks = null, - Object? globalStat = freezed, - }) { - return _then(_$HomeDownloaderUIStateImpl( - tasks: null == tasks - ? _value._tasks - : tasks // ignore: cast_nullable_to_non_nullable - as List, - waitingTasks: null == waitingTasks - ? _value._waitingTasks - : waitingTasks // ignore: cast_nullable_to_non_nullable - as List, - stoppedTasks: null == stoppedTasks - ? _value._stoppedTasks - : stoppedTasks // ignore: cast_nullable_to_non_nullable - as List, - globalStat: freezed == globalStat - ? _value.globalStat - : globalStat // ignore: cast_nullable_to_non_nullable - as Aria2GlobalStat?, - )); - } -} - -/// @nodoc - -class _$HomeDownloaderUIStateImpl implements _HomeDownloaderUIState { - _$HomeDownloaderUIStateImpl( - {final List tasks = const [], - final List waitingTasks = const [], - final List stoppedTasks = const [], - this.globalStat}) - : _tasks = tasks, - _waitingTasks = waitingTasks, - _stoppedTasks = stoppedTasks; - - final List _tasks; - @override - @JsonKey() - List get tasks { - if (_tasks is EqualUnmodifiableListView) return _tasks; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_tasks); - } - - final List _waitingTasks; - @override - @JsonKey() - List get waitingTasks { - if (_waitingTasks is EqualUnmodifiableListView) return _waitingTasks; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_waitingTasks); - } - - final List _stoppedTasks; - @override - @JsonKey() - List get stoppedTasks { - if (_stoppedTasks is EqualUnmodifiableListView) return _stoppedTasks; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_stoppedTasks); - } - - @override - final Aria2GlobalStat? globalStat; - - @override - String toString() { - return 'HomeDownloaderUIState(tasks: $tasks, waitingTasks: $waitingTasks, stoppedTasks: $stoppedTasks, globalStat: $globalStat)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$HomeDownloaderUIStateImpl && - const DeepCollectionEquality().equals(other._tasks, _tasks) && - const DeepCollectionEquality() - .equals(other._waitingTasks, _waitingTasks) && - const DeepCollectionEquality() - .equals(other._stoppedTasks, _stoppedTasks) && - (identical(other.globalStat, globalStat) || - other.globalStat == globalStat)); - } - - @override - int get hashCode => Object.hash( - runtimeType, - const DeepCollectionEquality().hash(_tasks), - const DeepCollectionEquality().hash(_waitingTasks), - const DeepCollectionEquality().hash(_stoppedTasks), - globalStat); - - /// Create a copy of HomeDownloaderUIState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$HomeDownloaderUIStateImplCopyWith<_$HomeDownloaderUIStateImpl> - get copyWith => __$$HomeDownloaderUIStateImplCopyWithImpl< - _$HomeDownloaderUIStateImpl>(this, _$identity); -} - -abstract class _HomeDownloaderUIState implements HomeDownloaderUIState { - factory _HomeDownloaderUIState( - {final List tasks, - final List waitingTasks, - final List stoppedTasks, - final Aria2GlobalStat? globalStat}) = _$HomeDownloaderUIStateImpl; - - @override - List get tasks; - @override - List get waitingTasks; - @override - List get stoppedTasks; - @override - Aria2GlobalStat? get globalStat; - - /// Create a copy of HomeDownloaderUIState - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$HomeDownloaderUIStateImplCopyWith<_$HomeDownloaderUIStateImpl> - get copyWith => throw _privateConstructorUsedError; -} diff --git a/lib/ui/home/downloader/home_downloader_ui_model.g.dart b/lib/ui/home/downloader/home_downloader_ui_model.g.dart deleted file mode 100644 index 7866b14..0000000 --- a/lib/ui/home/downloader/home_downloader_ui_model.g.dart +++ /dev/null @@ -1,27 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'home_downloader_ui_model.dart'; - -// ************************************************************************** -// RiverpodGenerator -// ************************************************************************** - -String _$homeDownloaderUIModelHash() => - r'ece2e6da4576b945ead5767aea2ccacf5e3e17aa'; - -/// See also [HomeDownloaderUIModel]. -@ProviderFor(HomeDownloaderUIModel) -final homeDownloaderUIModelProvider = AutoDisposeNotifierProvider< - HomeDownloaderUIModel, HomeDownloaderUIState>.internal( - HomeDownloaderUIModel.new, - name: r'homeDownloaderUIModelProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$homeDownloaderUIModelHash, - dependencies: null, - allTransitiveDependencies: null, -); - -typedef _$HomeDownloaderUIModel = AutoDisposeNotifier; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member diff --git a/lib/ui/home/game_doctor/game_doctor_ui.dart b/lib/ui/home/game_doctor/game_doctor_ui.dart deleted file mode 100644 index 84017be..0000000 --- a/lib/ui/home/game_doctor/game_doctor_ui.dart +++ /dev/null @@ -1,305 +0,0 @@ -import 'package:fluent_ui/fluent_ui.dart'; -import 'package:flutter/scheduler.dart'; -import 'package:flutter_hooks/flutter_hooks.dart'; -import 'package:flutter_tilt/flutter_tilt.dart'; -import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:starcitizen_doctor/api/analytics.dart'; -import 'package:starcitizen_doctor/common/helper/log_helper.dart'; -import 'package:starcitizen_doctor/common/helper/system_helper.dart'; -import 'package:starcitizen_doctor/common/utils/log.dart'; -import 'package:starcitizen_doctor/ui/home/home_ui_model.dart'; -import 'package:starcitizen_doctor/widgets/widgets.dart'; -import 'package:url_launcher/url_launcher_string.dart'; - -import 'game_doctor_ui_model.dart'; - -class HomeGameDoctorUI extends HookConsumerWidget { - const HomeGameDoctorUI({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(homeGameDoctorUIModelProvider); - final homeState = ref.watch(homeUIModelProvider); - final model = ref.read(homeGameDoctorUIModelProvider.notifier); - - useEffect(() { - AnalyticsApi.touch("auto_scan_issues"); - SchedulerBinding.instance.addPostFrameCallback((timeStamp) { - dPrint("HomeGameDoctorUI useEffect doCheck timeStamp === $timeStamp"); - model.doCheck(context); - }); - return null; - }, []); - - return makeDefaultPage(context, - title: S.current - .doctor_title_one_click_diagnosis(homeState.scInstalledPath ?? ""), - useBodyContainer: true, - content: Stack( - children: [ - Column( - children: [ - const SizedBox(height: 12), - Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - for (final item in { - "rsi_log": S.current.doctor_action_rsi_launcher_log, - "game_log": S.current.doctor_action_game_run_log, - }.entries) - Padding( - padding: const EdgeInsets.only(left: 6, right: 6), - child: Button( - child: Padding( - padding: const EdgeInsets.all(4), - child: Row( - children: [ - const Icon(FluentIcons.folder_open), - const SizedBox(width: 6), - Text(item.value), - ], - ), - ), - onPressed: () => - _onTapButton(context, item.key, homeState)), - ), - ], - ), - if (state.isChecking) - Expanded( - child: Center( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - const ProgressRing(), - const SizedBox(height: 12), - Text(state.lastScreenInfo) - ], - ), - )) - else if (state.checkResult == null || - state.checkResult!.isEmpty) ...[ - Expanded( - child: Center( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - const SizedBox(height: 12), - Text(S.current.doctor_info_scan_complete_no_issues, - maxLines: 1), - const SizedBox(height: 64), - ], - ), - )) - ] else - ...makeResult(context, state, model), - ], - ), - if (state.isFixing) - Container( - decoration: BoxDecoration( - color: Colors.black.withAlpha(150), - ), - child: Center( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - const ProgressRing(), - const SizedBox(height: 12), - Text(state.isFixingString.isNotEmpty - ? state.isFixingString - : S.current.doctor_info_processing), - ], - ), - ), - ), - Positioned( - bottom: 20, - right: 20, - child: makeRescueBanner(context), - ) - ], - )); - } - - Widget makeRescueBanner(BuildContext context) { - return GestureDetector( - onTap: () async { - await showToast( - context, S.current.doctor_info_game_rescue_service_note); - launchUrlString( - "https://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=-M4wEme_bCXbUGT4LFKLH0bAYTFt70Ad&authKey=vHVr0TNgRmKu%2BHwywoJV6EiLa7La2VX74Vkyixr05KA0H9TqB6qWlCdY%2B9jLQ4Ha&noverify=0&group_code=536454632"); - }, - child: Tilt( - shadowConfig: const ShadowConfig(maxIntensity: .2), - borderRadius: BorderRadius.circular(12), - child: Container( - decoration: BoxDecoration( - color: FluentTheme.of(context).cardColor, - ), - child: Padding( - padding: const EdgeInsets.all(12), - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Image.asset("assets/rescue.png", width: 24, height: 24), - const SizedBox(width: 12), - Text(S.current.doctor_info_need_help), - ], - ), - )), - ), - ); - } - - List makeResult(BuildContext context, HomeGameDoctorState state, - HomeGameDoctorUIModel model) { - return [ - const SizedBox(height: 24), - Text(state.lastScreenInfo, maxLines: 1), - const SizedBox(height: 12), - Text( - S.current.doctor_info_tool_check_result_note, - style: TextStyle(color: Colors.red, fontSize: 16), - ), - const SizedBox(height: 24), - ListView.builder( - itemCount: state.checkResult!.length, - shrinkWrap: true, - physics: const NeverScrollableScrollPhysics(), - itemBuilder: (BuildContext context, int index) { - final item = state.checkResult![index]; - return makeResultItem(context, item, state, model); - }, - ), - const SizedBox(height: 64), - ]; - } - - Widget makeResultItem(BuildContext context, MapEntry item, - HomeGameDoctorState state, HomeGameDoctorUIModel model) { - final errorNames = { - "unSupport_system": MapEntry(S.current.doctor_info_result_unsupported_os, - S.current.doctor_info_result_upgrade_system(item.value)), - "no_live_path": MapEntry(S.current.doctor_info_result_missing_live_folder, - S.current.doctor_info_result_create_live_folder(item.value)), - "nvme_PhysicalBytes": MapEntry( - S.current.doctor_info_result_incompatible_nvme_device, - S.current.doctor_info_result_add_registry_value(item.value)), - "eac_file_miss": MapEntry( - S.current.doctor_info_result_missing_easyanticheat_files, - S.current.doctor_info_result_verify_files_with_rsi_launcher), - "eac_not_install": MapEntry( - S.current.doctor_info_result_easyanticheat_not_installed, - S.current.doctor_info_result_install_easyanticheat), - "cn_user_name": MapEntry(S.current.doctor_info_result_chinese_username, - S.current.doctor_info_result_chinese_username_error), - "cn_install_path": MapEntry( - S.current.doctor_info_result_chinese_install_path, - S.current.doctor_info_result_chinese_install_path_error(item.value)), - "low_ram": MapEntry(S.current.doctor_info_result_low_physical_memory, - S.current.doctor_info_result_memory_requirement(item.value)), - }; - bool isCheckedError = errorNames.containsKey(item.key); - - if (isCheckedError) { - return Container( - decoration: BoxDecoration( - color: FluentTheme.of(context).cardColor, - ), - margin: const EdgeInsets.only(bottom: 12), - child: ListTile( - title: Text( - errorNames[item.key]?.key ?? "", - style: const TextStyle(fontSize: 18), - ), - subtitle: Padding( - padding: const EdgeInsets.only(top: 4, bottom: 4), - child: Column( - children: [ - const SizedBox(height: 4), - Text( - S.current.doctor_info_result_fix_suggestion( - errorNames[item.key]?.value ?? - S.current.doctor_info_result_no_solution), - style: TextStyle( - fontSize: 14, color: Colors.white.withOpacity(.7)), - ), - ], - ), - ), - trailing: Button( - onPressed: (errorNames[item.key]?.value == null || state.isFixing) - ? null - : () async { - await model.doFix(context, item); - }, - child: Padding( - padding: - const EdgeInsets.only(left: 8, right: 8, top: 4, bottom: 4), - child: Text(S.current.doctor_info_action_fix), - ), - ), - ), - ); - } - - final isSubTitleUrl = item.value.startsWith("https://"); - - return Container( - decoration: BoxDecoration( - color: FluentTheme.of(context).cardColor, - ), - margin: const EdgeInsets.only(bottom: 12), - child: ListTile( - title: Text( - item.key, - style: const TextStyle(fontSize: 18), - ), - subtitle: isSubTitleUrl - ? null - : Column( - children: [ - const SizedBox(height: 4), - Text( - item.value, - style: TextStyle( - fontSize: 14, color: Colors.white.withOpacity(.7)), - ), - ], - ), - trailing: isSubTitleUrl - ? Button( - onPressed: () { - launchUrlString(item.value); - }, - child: Padding( - padding: const EdgeInsets.only( - left: 8, right: 8, top: 4, bottom: 4), - child: Text(S.current.doctor_action_view_solution), - ), - ) - : null, - ), - ); - } - - _onTapButton( - BuildContext context, String key, HomeUIModelState homeState) async { - switch (key) { - case "rsi_log": - final path = await SCLoggerHelper.getLogFilePath(); - if (path == null) return; - SystemHelper.openDir(path); - return; - case "game_log": - if (homeState.scInstalledPath == "not_install" || - homeState.scInstalledPath == null) { - showToast(context, S.current.doctor_tip_title_select_game_directory); - return; - } - SystemHelper.openDir("${homeState.scInstalledPath}\\Game.log"); - return; - } - } -} diff --git a/lib/ui/home/game_doctor/game_doctor_ui_model.dart b/lib/ui/home/game_doctor/game_doctor_ui_model.dart deleted file mode 100644 index 822fe37..0000000 --- a/lib/ui/home/game_doctor/game_doctor_ui_model.dart +++ /dev/null @@ -1,284 +0,0 @@ -import 'dart:convert'; -import 'dart:io'; - -import 'package:fluent_ui/fluent_ui.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:riverpod_annotation/riverpod_annotation.dart'; -import 'package:starcitizen_doctor/common/helper/log_helper.dart'; -import 'package:starcitizen_doctor/common/helper/system_helper.dart'; -import 'package:starcitizen_doctor/common/utils/base_utils.dart'; -import 'package:starcitizen_doctor/common/utils/log.dart'; -import 'package:starcitizen_doctor/ui/home/home_ui_model.dart'; -import 'package:url_launcher/url_launcher_string.dart'; - -part 'game_doctor_ui_model.g.dart'; - -part 'game_doctor_ui_model.freezed.dart'; - -@freezed -class HomeGameDoctorState with _$HomeGameDoctorState { - factory HomeGameDoctorState({ - @Default(false) bool isChecking, - @Default(false) bool isFixing, - @Default("") String lastScreenInfo, - @Default("") String isFixingString, - List>? checkResult, - }) = _HomeGameDoctorState; -} - -@riverpod -class HomeGameDoctorUIModel extends _$HomeGameDoctorUIModel { - @override - HomeGameDoctorState build() { - state = HomeGameDoctorState(); - return state; - } - - Future doFix( - // ignore: avoid_build_context_in_providers - BuildContext context, - MapEntry item) async { - final checkResult = - List>.from(state.checkResult ?? []); - state = state.copyWith(isFixing: true, isFixingString: ""); - switch (item.key) { - case "unSupport_system": - showToast(context, S.current.doctor_action_result_try_latest_windows); - break; - case "no_live_path": - try { - await Directory(item.value).create(recursive: true); - if (!context.mounted) break; - showToast( - context, S.current.doctor_action_result_create_folder_success); - checkResult.remove(item); - state = state.copyWith(checkResult: checkResult); - } catch (e) { - showToast(context, - S.current.doctor_action_result_create_folder_fail(item.value, e)); - } - break; - case "nvme_PhysicalBytes": - final r = await SystemHelper.addNvmePatch(); - if (r == "") { - if (!context.mounted) break; - showToast(context, S.current.doctor_action_result_fix_success); - checkResult.remove(item); - state = state.copyWith(checkResult: checkResult); - } else { - if (!context.mounted) break; - showToast(context, S.current.doctor_action_result_fix_fail(r)); - } - break; - case "eac_file_miss": - showToast(context, - S.current.doctor_info_result_verify_files_with_rsi_launcher); - break; - case "eac_not_install": - final eacJsonPath = "${item.value}\\Settings.json"; - final eacJsonData = await File(eacJsonPath).readAsBytes(); - final Map eacJson = json.decode(utf8.decode(eacJsonData)); - final eacID = eacJson["productid"]; - try { - var result = await Process.run( - "${item.value}\\EasyAntiCheat_EOS_Setup.exe", ["install", eacID]); - dPrint("${item.value}\\EasyAntiCheat_EOS_Setup.exe install $eacID"); - if (result.stderr == "") { - if (!context.mounted) break; - showToast( - context, S.current.doctor_action_result_game_start_success); - checkResult.remove(item); - state = state.copyWith(checkResult: checkResult); - } else { - if (!context.mounted) break; - showToast(context, - S.current.doctor_action_result_fix_fail(result.stderr)); - } - } catch (e) { - if (!context.mounted) break; - showToast(context, S.current.doctor_action_result_fix_fail(e)); - } - break; - case "cn_user_name": - showToast(context, S.current.doctor_action_result_redirect_warning); - await Future.delayed(const Duration(milliseconds: 300)); - launchUrlString( - "https://jingyan.baidu.com/article/59703552a318a08fc0074021.html"); - break; - default: - showToast(context, S.current.doctor_action_result_issue_not_supported); - break; - } - state = state.copyWith(isFixing: false, isFixingString: ""); - } - - // ignore: avoid_build_context_in_providers - doCheck(BuildContext context) async { - if (state.isChecking) return; - state = state.copyWith( - isChecking: true, lastScreenInfo: S.current.doctor_action_analyzing); - dPrint("-------- start docker check -----"); - if (!context.mounted) return; - await _statCheck(context); - state = state.copyWith(isChecking: false); - } - - // ignore: avoid_build_context_in_providers - _statCheck(BuildContext context) async { - final homeState = ref.read(homeUIModelProvider); - final scInstalledPath = homeState.scInstalledPath!; - - final checkResult = >[]; - // TODO for debug - // checkResult?.add(MapEntry("unSupport_system", "android")); - // checkResult?.add(MapEntry("nvme_PhysicalBytes", "C")); - // checkResult?.add(MapEntry("no_live_path", "")); - - await _checkPreInstall(context, scInstalledPath, checkResult); - if (!context.mounted) return; - await _checkEAC(context, scInstalledPath, checkResult); - if (!context.mounted) return; - await _checkGameRunningLog(context, scInstalledPath, checkResult); - - if (checkResult.isEmpty) { - final lastScreenInfo = S.current.doctor_action_result_analysis_no_issue; - state = state.copyWith(checkResult: null, lastScreenInfo: lastScreenInfo); - } else { - final lastScreenInfo = S.current - .doctor_action_result_analysis_issues_found( - checkResult.length.toString()); - state = state.copyWith( - checkResult: checkResult, lastScreenInfo: lastScreenInfo); - } - - if (scInstalledPath == "not_install" && (checkResult.isEmpty)) { - if (!context.mounted) return; - showToast(context, S.current.doctor_action_result_toast_scan_no_issue); - } - } - - // ignore: avoid_build_context_in_providers - Future _checkGameRunningLog(BuildContext context, String scInstalledPath, - List> checkResult) async { - if (scInstalledPath == "not_install") return; - final lastScreenInfo = S.current.doctor_action_tip_checking_game_log; - state = state.copyWith(lastScreenInfo: lastScreenInfo); - final logs = await SCLoggerHelper.getGameRunningLogs(scInstalledPath); - if (logs == null) return; - final info = SCLoggerHelper.getGameRunningLogInfo(logs); - if (info != null) { - if (info.key != "_") { - checkResult.add(MapEntry( - S.current.doctor_action_info_game_abnormal_exit(info.key), - info.value)); - } else { - checkResult.add(MapEntry( - S.current.doctor_action_info_game_abnormal_exit_unknown, - S.current.doctor_action_info_info_feedback(info.value))); - } - } - } - - // ignore: avoid_build_context_in_providers - Future _checkEAC(BuildContext context, String scInstalledPath, - List> checkResult) async { - if (scInstalledPath == "not_install") return; - final lastScreenInfo = S.current.doctor_action_info_checking_eac; - state = state.copyWith(lastScreenInfo: lastScreenInfo); - - final eacPath = "$scInstalledPath\\EasyAntiCheat"; - final eacJsonPath = "$eacPath\\Settings.json"; - if (!await Directory(eacPath).exists() || - !await File(eacJsonPath).exists()) { - checkResult.add(const MapEntry("eac_file_miss", "")); - return; - } - final eacJsonData = await File(eacJsonPath).readAsBytes(); - final Map eacJson = json.decode(utf8.decode(eacJsonData)); - final eacID = eacJson["productid"]; - final eacDeploymentId = eacJson["deploymentid"]; - if (eacID == null || eacDeploymentId == null) { - checkResult.add(const MapEntry("eac_file_miss", "")); - return; - } - final eacFilePath = - "${Platform.environment["appdata"]}\\EasyAntiCheat\\$eacID\\$eacDeploymentId\\anticheatlauncher.log"; - if (!await File(eacFilePath).exists()) { - checkResult.add(MapEntry("eac_not_install", eacPath)); - return; - } - } - - final _cnExp = RegExp(r"[^\x00-\xff]"); - - // ignore: avoid_build_context_in_providers - Future _checkPreInstall(BuildContext context, String scInstalledPath, - List> checkResult) async { - final lastScreenInfo = S.current.doctor_action_info_checking_runtime; - state = state.copyWith(lastScreenInfo: lastScreenInfo); - - if (!(Platform.operatingSystemVersion.contains("Windows 10") || - Platform.operatingSystemVersion.contains("Windows 11"))) { - checkResult - .add(MapEntry("unSupport_system", Platform.operatingSystemVersion)); - final lastScreenInfo = S.current.doctor_action_result_info_unsupported_os( - Platform.operatingSystemVersion); - state = state.copyWith(lastScreenInfo: lastScreenInfo); - await showToast(context, lastScreenInfo); - } - - if (_cnExp.hasMatch(await SCLoggerHelper.getLogFilePath() ?? "")) { - checkResult.add(const MapEntry("cn_user_name", "")); - } - - // 检查 RAM - final ramSize = await SystemHelper.getSystemMemorySizeGB(); - if (ramSize < 16) { - checkResult.add(MapEntry("low_ram", "$ramSize")); - } - state = state.copyWith( - lastScreenInfo: S.current.doctor_action_info_checking_install_info); - // 检查安装分区 - try { - final listData = await SCLoggerHelper.getGameInstallPath( - await SCLoggerHelper.getLauncherLogList() ?? []); - final p = []; - final checkedPath = []; - for (var installPath in listData) { - if (!checkedPath.contains(installPath)) { - if (_cnExp.hasMatch(installPath)) { - checkResult.add(MapEntry("cn_install_path", installPath)); - } - if (scInstalledPath == "not_install") { - checkedPath.add(installPath); - if (!await Directory(installPath).exists()) { - checkResult.add(MapEntry("no_live_path", installPath)); - } - } - final tp = installPath.split(":")[0]; - if (!p.contains(tp)) { - p.add(tp); - } - } - } - - // call check - for (var element in p) { - var result = await Process.run('powershell', [ - "(fsutil fsinfo sectorinfo $element: | Select-String 'PhysicalBytesPerSectorForPerformance').ToString().Split(':')[1].Trim()" - ]); - dPrint( - "fsutil info sector info: ->>> ${result.stdout.toString().trim()}"); - if (result.stderr == "") { - final rs = result.stdout.toString().trim(); - final physicalBytesPerSectorForPerformance = (int.tryParse(rs) ?? 0); - if (physicalBytesPerSectorForPerformance > 4096) { - checkResult.add(MapEntry("nvme_PhysicalBytes", element)); - } - } - } - } catch (e) { - dPrint(e); - } - } -} diff --git a/lib/ui/home/game_doctor/game_doctor_ui_model.freezed.dart b/lib/ui/home/game_doctor/game_doctor_ui_model.freezed.dart deleted file mode 100644 index 1090d6b..0000000 --- a/lib/ui/home/game_doctor/game_doctor_ui_model.freezed.dart +++ /dev/null @@ -1,253 +0,0 @@ -// coverage:ignore-file -// GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark - -part of 'game_doctor_ui_model.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -T _$identity(T value) => value; - -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); - -/// @nodoc -mixin _$HomeGameDoctorState { - bool get isChecking => throw _privateConstructorUsedError; - bool get isFixing => throw _privateConstructorUsedError; - String get lastScreenInfo => throw _privateConstructorUsedError; - String get isFixingString => throw _privateConstructorUsedError; - List>? get checkResult => - throw _privateConstructorUsedError; - - /// Create a copy of HomeGameDoctorState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $HomeGameDoctorStateCopyWith get copyWith => - throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $HomeGameDoctorStateCopyWith<$Res> { - factory $HomeGameDoctorStateCopyWith( - HomeGameDoctorState value, $Res Function(HomeGameDoctorState) then) = - _$HomeGameDoctorStateCopyWithImpl<$Res, HomeGameDoctorState>; - @useResult - $Res call( - {bool isChecking, - bool isFixing, - String lastScreenInfo, - String isFixingString, - List>? checkResult}); -} - -/// @nodoc -class _$HomeGameDoctorStateCopyWithImpl<$Res, $Val extends HomeGameDoctorState> - implements $HomeGameDoctorStateCopyWith<$Res> { - _$HomeGameDoctorStateCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of HomeGameDoctorState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? isChecking = null, - Object? isFixing = null, - Object? lastScreenInfo = null, - Object? isFixingString = null, - Object? checkResult = freezed, - }) { - return _then(_value.copyWith( - isChecking: null == isChecking - ? _value.isChecking - : isChecking // ignore: cast_nullable_to_non_nullable - as bool, - isFixing: null == isFixing - ? _value.isFixing - : isFixing // ignore: cast_nullable_to_non_nullable - as bool, - lastScreenInfo: null == lastScreenInfo - ? _value.lastScreenInfo - : lastScreenInfo // ignore: cast_nullable_to_non_nullable - as String, - isFixingString: null == isFixingString - ? _value.isFixingString - : isFixingString // ignore: cast_nullable_to_non_nullable - as String, - checkResult: freezed == checkResult - ? _value.checkResult - : checkResult // ignore: cast_nullable_to_non_nullable - as List>?, - ) as $Val); - } -} - -/// @nodoc -abstract class _$$HomeGameDoctorStateImplCopyWith<$Res> - implements $HomeGameDoctorStateCopyWith<$Res> { - factory _$$HomeGameDoctorStateImplCopyWith(_$HomeGameDoctorStateImpl value, - $Res Function(_$HomeGameDoctorStateImpl) then) = - __$$HomeGameDoctorStateImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {bool isChecking, - bool isFixing, - String lastScreenInfo, - String isFixingString, - List>? checkResult}); -} - -/// @nodoc -class __$$HomeGameDoctorStateImplCopyWithImpl<$Res> - extends _$HomeGameDoctorStateCopyWithImpl<$Res, _$HomeGameDoctorStateImpl> - implements _$$HomeGameDoctorStateImplCopyWith<$Res> { - __$$HomeGameDoctorStateImplCopyWithImpl(_$HomeGameDoctorStateImpl _value, - $Res Function(_$HomeGameDoctorStateImpl) _then) - : super(_value, _then); - - /// Create a copy of HomeGameDoctorState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? isChecking = null, - Object? isFixing = null, - Object? lastScreenInfo = null, - Object? isFixingString = null, - Object? checkResult = freezed, - }) { - return _then(_$HomeGameDoctorStateImpl( - isChecking: null == isChecking - ? _value.isChecking - : isChecking // ignore: cast_nullable_to_non_nullable - as bool, - isFixing: null == isFixing - ? _value.isFixing - : isFixing // ignore: cast_nullable_to_non_nullable - as bool, - lastScreenInfo: null == lastScreenInfo - ? _value.lastScreenInfo - : lastScreenInfo // ignore: cast_nullable_to_non_nullable - as String, - isFixingString: null == isFixingString - ? _value.isFixingString - : isFixingString // ignore: cast_nullable_to_non_nullable - as String, - checkResult: freezed == checkResult - ? _value._checkResult - : checkResult // ignore: cast_nullable_to_non_nullable - as List>?, - )); - } -} - -/// @nodoc - -class _$HomeGameDoctorStateImpl implements _HomeGameDoctorState { - _$HomeGameDoctorStateImpl( - {this.isChecking = false, - this.isFixing = false, - this.lastScreenInfo = "", - this.isFixingString = "", - final List>? checkResult}) - : _checkResult = checkResult; - - @override - @JsonKey() - final bool isChecking; - @override - @JsonKey() - final bool isFixing; - @override - @JsonKey() - final String lastScreenInfo; - @override - @JsonKey() - final String isFixingString; - final List>? _checkResult; - @override - List>? get checkResult { - final value = _checkResult; - if (value == null) return null; - if (_checkResult is EqualUnmodifiableListView) return _checkResult; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(value); - } - - @override - String toString() { - return 'HomeGameDoctorState(isChecking: $isChecking, isFixing: $isFixing, lastScreenInfo: $lastScreenInfo, isFixingString: $isFixingString, checkResult: $checkResult)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$HomeGameDoctorStateImpl && - (identical(other.isChecking, isChecking) || - other.isChecking == isChecking) && - (identical(other.isFixing, isFixing) || - other.isFixing == isFixing) && - (identical(other.lastScreenInfo, lastScreenInfo) || - other.lastScreenInfo == lastScreenInfo) && - (identical(other.isFixingString, isFixingString) || - other.isFixingString == isFixingString) && - const DeepCollectionEquality() - .equals(other._checkResult, _checkResult)); - } - - @override - int get hashCode => Object.hash( - runtimeType, - isChecking, - isFixing, - lastScreenInfo, - isFixingString, - const DeepCollectionEquality().hash(_checkResult)); - - /// Create a copy of HomeGameDoctorState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$HomeGameDoctorStateImplCopyWith<_$HomeGameDoctorStateImpl> get copyWith => - __$$HomeGameDoctorStateImplCopyWithImpl<_$HomeGameDoctorStateImpl>( - this, _$identity); -} - -abstract class _HomeGameDoctorState implements HomeGameDoctorState { - factory _HomeGameDoctorState( - {final bool isChecking, - final bool isFixing, - final String lastScreenInfo, - final String isFixingString, - final List>? checkResult}) = - _$HomeGameDoctorStateImpl; - - @override - bool get isChecking; - @override - bool get isFixing; - @override - String get lastScreenInfo; - @override - String get isFixingString; - @override - List>? get checkResult; - - /// Create a copy of HomeGameDoctorState - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$HomeGameDoctorStateImplCopyWith<_$HomeGameDoctorStateImpl> get copyWith => - throw _privateConstructorUsedError; -} diff --git a/lib/ui/home/game_doctor/game_doctor_ui_model.g.dart b/lib/ui/home/game_doctor/game_doctor_ui_model.g.dart deleted file mode 100644 index 0356c88..0000000 --- a/lib/ui/home/game_doctor/game_doctor_ui_model.g.dart +++ /dev/null @@ -1,27 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'game_doctor_ui_model.dart'; - -// ************************************************************************** -// RiverpodGenerator -// ************************************************************************** - -String _$homeGameDoctorUIModelHash() => - r'b69a19a937ca375214a7c7e73b8288f577265625'; - -/// See also [HomeGameDoctorUIModel]. -@ProviderFor(HomeGameDoctorUIModel) -final homeGameDoctorUIModelProvider = AutoDisposeNotifierProvider< - HomeGameDoctorUIModel, HomeGameDoctorState>.internal( - HomeGameDoctorUIModel.new, - name: r'homeGameDoctorUIModelProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$homeGameDoctorUIModelHash, - dependencies: null, - allTransitiveDependencies: null, -); - -typedef _$HomeGameDoctorUIModel = AutoDisposeNotifier; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member diff --git a/lib/ui/home/home_ui.dart b/lib/ui/home/home_ui.dart index 6a78ed6..f312ecd 100644 --- a/lib/ui/home/home_ui.dart +++ b/lib/ui/home/home_ui.dart @@ -7,8 +7,6 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:go_router/go_router.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:starcitizen_doctor/api/analytics.dart'; -import 'package:starcitizen_doctor/common/helper/system_helper.dart'; -import 'package:starcitizen_doctor/ui/tools/tools_ui_model.dart'; import 'package:starcitizen_doctor/widgets/widgets.dart'; import 'package:url_launcher/url_launcher_string.dart'; @@ -117,76 +115,6 @@ class HomeUI extends HookConsumerWidget { ), ], ), - const SizedBox(height: 24), - Padding( - padding: const EdgeInsets.only(left: 24, right: 24), - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Text(S.current.home_install_location), - const SizedBox(width: 6), - Expanded( - child: ComboBox( - value: homeState.scInstalledPath, - isExpanded: true, - items: [ - ComboBoxItem( - value: "not_install", - child: Text(S.current.home_not_installed_or_failed), - ), - for (final path in homeState.scInstallPaths) - ComboBoxItem( - value: path, - child: Row( - children: [Text(path)], - ), - ) - ], - onChanged: model.onChangeInstallPath, - ), - ), - const SizedBox(width: 12), - Button( - onPressed: homeState.webLocalizationVersionsData == null - ? null - : () => model.launchRSI(context), - style: homeState.isCurGameRunning - ? null - : ButtonStyle( - backgroundColor: - WidgetStateProperty.resolveWith(_getRunButtonColor), - ), - child: Padding( - padding: const EdgeInsets.all(6), - child: Icon( - homeState.isCurGameRunning - ? FluentIcons.stop_solid - : FluentIcons.play_solid, - color: homeState.isCurGameRunning - ? Colors.red.withOpacity(.8) - : Colors.white, - ), - )), - const SizedBox(width: 12), - Button( - onPressed: () => - SystemHelper.openDir("${homeState.scInstalledPath}"), - child: const Padding( - padding: EdgeInsets.all(6), - child: Icon(FluentIcons.folder_open), - ), - ), - const SizedBox(width: 12), - Button( - onPressed: model.reScanPath, - child: const Padding( - padding: EdgeInsets.all(6), - child: Icon(FluentIcons.refresh), - ), - ), - ], - ), - ), const SizedBox(height: 8), Text(homeState.lastScreenInfo, maxLines: 1), makeIndexActionLists(context, model, homeState, ref), @@ -796,7 +724,8 @@ class HomeUI extends HookConsumerWidget { switch (key) { case "localization": if (homeState.scInstalledPath == "not_install") { - ToolsUIModel.rsiEnhance(context, showNotGameInstallMsg: true); + // TODO + // ToolsUIModel.English(context, showNotGameInstallMsg: true); break; } final model = ref.watch(homeUIModelProvider.notifier); diff --git a/lib/ui/home/home_ui_model.dart b/lib/ui/home/home_ui_model.dart index d7cb6db..bebc142 100644 --- a/lib/ui/home/home_ui_model.dart +++ b/lib/ui/home/home_ui_model.dart @@ -1,22 +1,15 @@ import 'dart:async'; import 'dart:convert'; -import 'dart:io'; import 'package:dart_rss/domain/rss_item.dart'; -import 'package:desktop_webview_window/desktop_webview_window.dart'; import 'package:fluent_ui/fluent_ui.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:hive/hive.dart'; import 'package:riverpod_annotation/riverpod_annotation.dart'; -import 'package:starcitizen_doctor/api/analytics.dart'; import 'package:starcitizen_doctor/api/api.dart'; import 'package:starcitizen_doctor/api/rss.dart'; -import 'package:starcitizen_doctor/common/conf/const_conf.dart'; import 'package:starcitizen_doctor/common/conf/url_conf.dart'; -import 'package:starcitizen_doctor/common/helper/log_helper.dart'; -import 'package:starcitizen_doctor/common/helper/system_helper.dart'; import 'package:starcitizen_doctor/common/io/rs_http.dart'; -import 'package:starcitizen_doctor/common/rust/api/win32_api.dart' as win32; import 'package:starcitizen_doctor/common/utils/async.dart'; import 'package:starcitizen_doctor/common/utils/base_utils.dart'; import 'package:starcitizen_doctor/common/utils/log.dart'; @@ -24,12 +17,10 @@ import 'package:starcitizen_doctor/common/utils/provider.dart'; import 'package:starcitizen_doctor/data/app_placard_data.dart'; import 'package:starcitizen_doctor/data/app_web_localization_versions_data.dart'; import 'package:starcitizen_doctor/data/countdown_festival_item_data.dart'; -import 'package:starcitizen_doctor/ui/home/dialogs/home_game_login_dialog_ui.dart'; -import 'package:url_launcher/url_launcher_string.dart'; import 'package:html/parser.dart' as html; import 'package:html/dom.dart' as html_dom; +import 'package:url_launcher/url_launcher_string.dart'; -import '../webview/webview.dart'; import 'localization/localization_ui_model.dart'; part 'home_ui_model.freezed.dart'; @@ -76,40 +67,7 @@ class HomeUIModel extends _$HomeUIModel { } Future reScanPath() async { - state = state.copyWith( - scInstalledPath: "not_install", - lastScreenInfo: S.current.home_action_info_scanning); - try { - final listData = await SCLoggerHelper.getLauncherLogList(); - if (listData == null) { - state = state.copyWith(scInstalledPath: "not_install"); - return; - } - final scInstallPaths = await SCLoggerHelper.getGameInstallPath(listData, - withVersion: ["LIVE", "PTU", "EPTU"], checkExists: true); - - String scInstalledPath = "not_install"; - - if (scInstallPaths.isNotEmpty) { - if (scInstallPaths.first.isNotEmpty) { - scInstalledPath = scInstallPaths.first; - } - } - final lastScreenInfo = S.current - .home_action_info_scan_complete_valid_directories_found( - scInstallPaths.length.toString()); - state = state.copyWith( - scInstalledPath: scInstalledPath, - scInstallPaths: scInstallPaths, - lastScreenInfo: lastScreenInfo); - } catch (e) { - state = state.copyWith( - scInstalledPath: "not_install", - lastScreenInfo: S.current.home_action_info_log_file_parse_fail); - AnalyticsApi.touch("error_launchLogs"); - // showToast(context!, - // "${S.current.home_action_info_log_file_parse_fail} \n请关闭游戏,退出RSI启动器后重试,若仍有问题,请使用工具箱中的 RSI Launcher log 修复。"); - } + state = state.copyWith(scInstalledPath: "not_install", lastScreenInfo: ""); } String getRssImage(RssItem item) { @@ -134,65 +92,8 @@ class HomeUIModel extends _$HomeUIModel { // ignore: avoid_build_context_in_providers Future goWebView(BuildContext context, String title, String url, - {bool useLocalization = false, - bool loginMode = false, - RsiLoginCallback? rsiLoginCallback}) async { - if (useLocalization) { - const tipVersion = 2; - final box = await Hive.openBox("app_conf"); - final skip = - await box.get("skip_web_localization_tip_version", defaultValue: 0); - if (skip != tipVersion) { - if (!context.mounted) return; - final ok = await showConfirmDialogs( - context, - S.current.home_action_title_star_citizen_website_localization, - Text( - S.current.home_action_info_web_localization_plugin_disclaimer, - style: const TextStyle(fontSize: 16), - ), - constraints: BoxConstraints( - maxWidth: MediaQuery.of(context).size.width * .6)); - if (!ok) { - if (loginMode) { - rsiLoginCallback?.call(null, false); - } - return; - } - await box.put("skip_web_localization_tip_version", tipVersion); - } - } - if (!await WebviewWindow.isWebviewAvailable()) { - if (!context.mounted) return; - showToast( - context, S.current.home_login_action_title_need_webview2_runtime); - launchUrlString( - "https://developer.microsoft.com/en-us/microsoft-edge/webview2/"); - return; - } - if (!context.mounted) return; - final webViewModel = WebViewModel(context, - loginMode: loginMode, loginCallback: rsiLoginCallback); - if (useLocalization) { - state = state.copyWith( - isFixing: true, - isFixingString: S.current.home_action_info_initializing_resources); - try { - await webViewModel.initLocalization(state.webLocalizationVersionsData!); - } catch (e) { - if (!context.mounted) return; - showToast(context, S.current.home_action_info_initialization_failed(e)); - } - state = state.copyWith(isFixingString: "", isFixing: false); - } - await webViewModel.initWebView( - title: title, - applicationSupportDir: appGlobalState.applicationSupportDir!, - appVersionData: appGlobalState.networkVersionData!, - ); - - await Future.delayed(const Duration(milliseconds: 500)); - await webViewModel.launch(url, appGlobalState.networkVersionData!); + {bool useLocalization = false, bool loginMode = false}) async { + launchUrlString(url); } bool isRSIServerStatusOK(Map map) { @@ -277,28 +178,9 @@ class HomeUIModel extends _$HomeUIModel { Future checkLocalizationUpdate({bool skipReload = false}) async { dPrint("_checkLocalizationUpdate"); - final updates = await (ref.read(localizationUIModelProvider.notifier)) + await (ref.read(localizationUIModelProvider.notifier)) .checkLangUpdate(skipReload: skipReload) .unwrap>(); - if (updates == null || updates.isEmpty) { - state = state.copyWith(localizationUpdateInfo: null); - return; - } - state = - state.copyWith(localizationUpdateInfo: MapEntry(updates.first, true)); - if (_appUpdateTimer != null) { - _appUpdateTimer?.cancel(); - _appUpdateTimer = null; - // 发送通知 - await win32.sendNotify( - summary: S.current.home_localization_new_version_available, - body: - S.current.home_localization_new_version_installed(updates.first), - appName: S.current.home_title_app_name, - appId: ConstConf.isMSE - ? "56575xkeyC.MSE_bsn1nexg8e4qe!starcitizendoctor" - : "{6D809377-6AF0-444B-8957-A3773F02200E}\\Starcitizen_Doctor\\starcitizen_doctor.exe"); - } } // ignore: avoid_build_context_in_providers @@ -307,109 +189,10 @@ class HomeUIModel extends _$HomeUIModel { showToast(context, S.current.home_info_valid_installation_required); return; } - - if (ConstConf.isMSE) { - if (state.isCurGameRunning) { - await Process.run( - SystemHelper.powershellPath, ["ps \"StarCitizen\" | kill"]); - return; - } - AnalyticsApi.touch("gameLaunch"); - showDialog( - context: context, - dismissWithEsc: false, - builder: (context) => HomeGameLoginDialogUI(context)); - } else { - final ok = await showConfirmDialogs( - context, - S.current.home_info_one_click_launch_warning, - Text(S.current.home_info_account_security_warning), - confirm: S.current.home_action_install_microsoft_store_version, - cancel: S.current.home_action_cancel); - if (ok == true) { - await launchUrlString( - "https://apps.microsoft.com/detail/9NF3SWFWNKL1?launch=true"); - await Future.delayed(const Duration(seconds: 2)); - exit(0); - } - } } void onChangeInstallPath(String? value) { if (value == null) return; state = state.copyWith(scInstalledPath: value); } - - doLaunchGame( - // ignore: avoid_build_context_in_providers - BuildContext context, - String launchExe, - List args, - String installPath, - String? processorAffinity) async { - var runningMap = Map.from(state.isGameRunning); - runningMap[installPath] = true; - state = state.copyWith(isGameRunning: runningMap); - try { - late ProcessResult result; - if (processorAffinity == null) { - result = await Process.run(launchExe, args); - } else { - dPrint("set Affinity === $processorAffinity launchExe === $launchExe"); - result = await Process.run("cmd.exe", [ - '/C', - 'Start', - '"StarCitizen"', - '/High', - '/Affinity', - processorAffinity, - launchExe, - ...args - ]); - } - dPrint('Exit code: ${result.exitCode}'); - dPrint('stdout: ${result.stdout}'); - dPrint('stderr: ${result.stderr}'); - - if (result.exitCode != 0) { - final logs = await SCLoggerHelper.getGameRunningLogs(installPath); - MapEntry? exitInfo; - bool hasUrl = false; - if (logs != null) { - exitInfo = SCLoggerHelper.getGameRunningLogInfo(logs); - if (exitInfo!.value.startsWith("https://")) { - hasUrl = true; - } - } - if (!context.mounted) return; - // showToast(context, - // "游戏非正常退出\nexitCode=${result.exitCode}\nstdout=${result.stdout ?? ""}\nstderr=${result.stderr ?? ""}\n\n诊断信息:${exitInfo == null ? "未知错误,请通过一键诊断加群反馈。" : exitInfo.key} \n${hasUrl ? "请查看弹出的网页链接获得详细信息。" : exitInfo?.value ?? ""}"); - // S.current.home_action_info_abnormal_game_exit - showToast( - context, - S.current.home_action_info_abnormal_game_exit( - result.exitCode.toString(), - result.stdout ?? "", - result.stderr ?? "", - exitInfo == null - ? S.current.home_action_info_unknown_error - : exitInfo.key, - hasUrl - ? S.current.home_action_info_check_web_link - : exitInfo?.value ?? "")); - if (hasUrl) { - await Future.delayed(const Duration(seconds: 3)); - launchUrlString(exitInfo!.value); - } - } - - final launchFile = File("$installPath\\loginData.json"); - if (await launchFile.exists()) { - await launchFile.delete(); - } - } catch (_) {} - runningMap = Map.from(state.isGameRunning); - runningMap[installPath] = false; - state = state.copyWith(isGameRunning: runningMap); - } } diff --git a/lib/ui/home/home_ui_model.g.dart b/lib/ui/home/home_ui_model.g.dart index 1ce3987..f20a01d 100644 --- a/lib/ui/home/home_ui_model.g.dart +++ b/lib/ui/home/home_ui_model.g.dart @@ -6,7 +6,7 @@ part of 'home_ui_model.dart'; // RiverpodGenerator // ************************************************************************** -String _$homeUIModelHash() => r'85d3242abb4264a814768a2d5ce108df46df38d9'; +String _$homeUIModelHash() => r'6a768281606856766737a63aaeebb392c4613d2b'; /// See also [HomeUIModel]. @ProviderFor(HomeUIModel) diff --git a/lib/ui/home/localization/advanced_localization_ui.dart b/lib/ui/home/localization/advanced_localization_ui.dart index 1ab010e..03326d6 100644 --- a/lib/ui/home/localization/advanced_localization_ui.dart +++ b/lib/ui/home/localization/advanced_localization_ui.dart @@ -10,7 +10,6 @@ import 'package:starcitizen_doctor/api/analytics.dart'; import 'package:starcitizen_doctor/data/app_advanced_localization_data.dart'; import 'package:starcitizen_doctor/ui/home/home_ui_model.dart'; import 'package:starcitizen_doctor/ui/home/localization/advanced_localization_ui_model.dart'; -import 'package:starcitizen_doctor/ui/tools/unp4kc/unp4kc_ui.dart'; import 'package:starcitizen_doctor/widgets/widgets.dart'; import 'package:super_sliver_list/super_sliver_list.dart'; @@ -58,7 +57,7 @@ class AdvancedLocalizationUI extends HookConsumerWidget { : Column( children: [ if (state.errorMessage.isNotEmpty) - UnP4kErrorWidget( + ErrorMessageWidget( errorMessage: state.errorMessage, ) else ...[ @@ -313,3 +312,32 @@ class AdvancedLocalizationUI extends HookConsumerWidget { ); } } + +class ErrorMessageWidget extends HookConsumerWidget { + final String errorMessage; + + const ErrorMessageWidget({super.key, required this.errorMessage}); + + @override + Widget build(BuildContext context, WidgetRef ref) { + return Container( + padding: const EdgeInsets.all(12), + decoration: BoxDecoration( + color: Colors.red.withOpacity(.1), + borderRadius: BorderRadius.circular(4), + ), + child: Row( + children: [ + const Icon(FluentIcons.error), + const SizedBox(width: 12), + Expanded( + child: Text( + errorMessage, + style: TextStyle(color: Colors.red), + ), + ), + ], + ), + ); + } +} diff --git a/lib/ui/home/localization/advanced_localization_ui_model.dart b/lib/ui/home/localization/advanced_localization_ui_model.dart index 127d4de..5d20651 100644 --- a/lib/ui/home/localization/advanced_localization_ui_model.dart +++ b/lib/ui/home/localization/advanced_localization_ui_model.dart @@ -6,10 +6,8 @@ import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:riverpod_annotation/riverpod_annotation.dart'; import 'package:starcitizen_doctor/api/analytics.dart'; import 'package:starcitizen_doctor/common/utils/log.dart'; -import 'package:starcitizen_doctor/common/utils/provider.dart'; import 'package:starcitizen_doctor/data/app_advanced_localization_data.dart'; import 'package:starcitizen_doctor/data/sc_localization_data.dart'; -import 'package:starcitizen_doctor/provider/unp4kc.dart'; import '../home_ui_model.dart'; import 'advanced_localization_ui.json.dart'; @@ -217,32 +215,7 @@ class AdvancedLocalizationUIModel extends _$AdvancedLocalizationUIModel { } Future readEnglishInI(String gameDir) async { - try { - var data = await Unp4kCModel.unp4kTools( - appGlobalState.applicationBinaryModuleDir!, [ - "extract_memory", - "$gameDir\\Data.p4k", - "Data\\Localization\\english\\global.ini" - ]); - // remove bom - if (data.length > 3 && - data[0] == 0xEF && - data[1] == 0xBB && - data[2] == 0xBF) { - data = data.sublist(3); - } - final iniData = String.fromCharCodes(data); - return iniData; - } catch (e) { - final errorMessage = e.toString(); - if (Unp4kCModel.checkRunTimeError(errorMessage)) { - AnalyticsApi.touch("advanced_localization_no_runtime"); - } - state = state.copyWith( - errorMessage: errorMessage, - ); - // rethrow; - } + // TODO read English p4kGlobalIni return ""; } diff --git a/lib/ui/home/localization/advanced_localization_ui_model.g.dart b/lib/ui/home/localization/advanced_localization_ui_model.g.dart index 6a25938..6a3fd17 100644 --- a/lib/ui/home/localization/advanced_localization_ui_model.g.dart +++ b/lib/ui/home/localization/advanced_localization_ui_model.g.dart @@ -7,7 +7,7 @@ part of 'advanced_localization_ui_model.dart'; // ************************************************************************** String _$advancedLocalizationUIModelHash() => - r'8241143c6dec93cd705e6b2e65cbca711cdfe2fb'; + r'60ccd50f54b948d16be001f5ea07972a0fd9ed3f'; /// See also [AdvancedLocalizationUIModel]. @ProviderFor(AdvancedLocalizationUIModel) diff --git a/lib/ui/home/localization/localization_dialog_ui.dart b/lib/ui/home/localization/localization_dialog_ui.dart index 1d08508..5dd4d63 100644 --- a/lib/ui/home/localization/localization_dialog_ui.dart +++ b/lib/ui/home/localization/localization_dialog_ui.dart @@ -5,7 +5,6 @@ import 'package:flutter_tilt/flutter_tilt.dart'; import 'package:go_router/go_router.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:starcitizen_doctor/data/sc_localization_data.dart'; -import 'package:starcitizen_doctor/ui/tools/tools_ui_model.dart'; import 'package:starcitizen_doctor/widgets/widgets.dart'; import 'localization_form_file_dialog_ui.dart'; @@ -495,7 +494,7 @@ class LocalizationDialogUI extends HookConsumerWidget { ? () async { switch (item.key) { case "launcher_mod": - ToolsUIModel.rsiEnhance(context); + // ToolsUIModel.rsiEnhance(context); break; case "advanced": context.push("/index/advanced_localization"); diff --git a/lib/ui/home/performance/performance_ui_model.dart b/lib/ui/home/performance/performance_ui_model.dart index da5ebd0..ccde537 100644 --- a/lib/ui/home/performance/performance_ui_model.dart +++ b/lib/ui/home/performance/performance_ui_model.dart @@ -6,8 +6,6 @@ import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:hive/hive.dart'; import 'package:riverpod_annotation/riverpod_annotation.dart'; import 'package:starcitizen_doctor/api/analytics.dart'; -import 'package:starcitizen_doctor/common/helper/log_helper.dart'; -import 'package:starcitizen_doctor/common/utils/base_utils.dart'; import 'package:starcitizen_doctor/data/game_performance_data.dart'; import 'package:starcitizen_doctor/generated/l10n.dart'; import 'package:starcitizen_doctor/ui/home/home_ui_model.dart'; @@ -165,20 +163,20 @@ class HomePerformanceUIModel extends _$HomePerformanceUIModel { } cleanShaderCache(BuildContext? context) async { - final gameShaderCachePath = await SCLoggerHelper.getShaderCachePath(); - final l = - await Directory(gameShaderCachePath!).list(recursive: false).toList(); - for (var value in l) { - if (value is Directory) { - if (!value.absolute.path.contains("Crashes")) { - await value.delete(recursive: true); - } - } - } - await Future.delayed(const Duration(milliseconds: 300)); - if (context != null && context.mounted) { - showToast(context, S.current.performance_info_shader_clearing_warning); - } + // final gameShaderCachePath = await SCLoggerHelper.getShaderCachePath(); + // final l = + // await Directory(gameShaderCachePath!).list(recursive: false).toList(); + // for (var value in l) { + // if (value is Directory) { + // if (!value.absolute.path.contains("Crashes")) { + // await value.delete(recursive: true); + // } + // } + // } + // await Future.delayed(const Duration(milliseconds: 300)); + // if (context != null && context.mounted) { + // showToast(context, S.current.performance_info_shader_clearing_warning); + // } } applyProfile(bool cleanShader) async { diff --git a/lib/ui/home/performance/performance_ui_model.g.dart b/lib/ui/home/performance/performance_ui_model.g.dart index 4ec76d4..417ebeb 100644 --- a/lib/ui/home/performance/performance_ui_model.g.dart +++ b/lib/ui/home/performance/performance_ui_model.g.dart @@ -7,7 +7,7 @@ part of 'performance_ui_model.dart'; // ************************************************************************** String _$homePerformanceUIModelHash() => - r'83fbdbbae287892dd0c67f5fd86d42a73d0ab91f'; + r'a33d8c621f4cd150b1a091bfd0243d578f4a705c'; /// See also [HomePerformanceUIModel]. @ProviderFor(HomePerformanceUIModel) diff --git a/lib/ui/index_ui.dart b/lib/ui/index_ui.dart index b86ca16..087b6c9 100644 --- a/lib/ui/index_ui.dart +++ b/lib/ui/index_ui.dart @@ -1,19 +1,15 @@ +import 'package:extended_image/extended_image.dart'; import 'package:fluent_ui/fluent_ui.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; -import 'package:go_router/go_router.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:starcitizen_doctor/app.dart'; import 'package:starcitizen_doctor/common/conf/const_conf.dart'; -import 'package:starcitizen_doctor/provider/aria2c.dart'; import 'package:starcitizen_doctor/ui/home/home_ui_model.dart'; -import 'package:starcitizen_doctor/ui/settings/settings_ui_model.dart'; +import 'package:starcitizen_doctor/widgets/src/blur_oval_widget.dart'; import 'package:starcitizen_doctor/widgets/widgets.dart'; -import 'package:window_manager/window_manager.dart'; import 'about/about_ui.dart'; import 'home/home_ui.dart'; -import 'settings/settings_ui.dart'; -import 'tools/tools_ui.dart'; class IndexUI extends HookConsumerWidget { const IndexUI({super.key}); @@ -22,67 +18,65 @@ class IndexUI extends HookConsumerWidget { Widget build(BuildContext context, WidgetRef ref) { // pre init child ref.watch(homeUIModelProvider.select((value) => null)); - ref.watch(settingsUIModelProvider.select((value) => null)); - ref.watch(appGlobalModelProvider); + // ref.watch(settingsUIModelProvider.select((value) => null)); + final globalState = ref.watch(appGlobalModelProvider); final curIndex = useState(0); - return NavigationView( - appBar: NavigationAppBar( - automaticallyImplyLeading: false, - title: () { - return DragToMoveArea( - child: Align( - alignment: AlignmentDirectional.centerStart, - child: Row( - children: [ - Image.asset( - "assets/app_logo_mini.png", - width: 20, - height: 20, - fit: BoxFit.cover, - ), - const SizedBox(width: 12), - Text(S.current.app_index_version_info( - ConstConf.appVersion, ConstConf.isMSE ? "" : " Dev")), - ], - ), - ), - ); - }(), - actions: Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - IconButton( - icon: Stack( - children: [ - Padding( - padding: const EdgeInsets.all(6), - child: Icon( - FluentIcons.installation, - size: 22, - color: Colors.white.withOpacity(.6), - ), - ), - _makeAria2TaskNumWidget() - ], - ), - onPressed: () => _goDownloader(context), - // onPressed: model.goDownloader - ), - const SizedBox(width: 24), - const WindowButtons() - ], - )), - pane: NavigationPane( - key: Key("NavigationPane_${S.current.app_language_code}"), - selected: curIndex.value, - items: getNavigationPaneItems(curIndex), - size: NavigationPaneSize( - openWidth: S.current.app_language_code.startsWith("zh") ? 64 : 74), + return Container( + decoration: BoxDecoration( + image: DecorationImage( + image: + ExtendedAssetImageProvider(globalState.backgroundImageAssetsPath), + fit: BoxFit.cover, + ), + ), + child: Center( + child: ClipRRect( + borderRadius: BorderRadius.circular(12), + child: BlurOvalWidget( + child: Container( + constraints: + const BoxConstraints(maxWidth: 1440, maxHeight: 1000), + child: NavigationView( + appBar: NavigationAppBar( + automaticallyImplyLeading: false, + title: () { + return Align( + alignment: AlignmentDirectional.centerStart, + child: Row( + children: [ + Image.asset( + "assets/app_logo_mini.png", + width: 20, + height: 20, + fit: BoxFit.cover, + ), + const SizedBox(width: 12), + Text(S.current.app_index_version_info( + ConstConf.appVersion, + ConstConf.isMSE ? "" : " Dev")), + ], + ), + ); + }(), + ), + pane: NavigationPane( + key: Key("NavigationPane_${S.current.app_language_code}"), + selected: curIndex.value, + items: getNavigationPaneItems(curIndex), + size: NavigationPaneSize( + openWidth: S.current.app_language_code.startsWith("zh") + ? 64 + : 74), + ), + paneBodyBuilder: (item, child) { + return item!.body; + }, + ), + ), + ), + ), ), - paneBodyBuilder: (item, child) { - return item!.body; - }, ); } @@ -93,11 +87,11 @@ class IndexUI extends HookConsumerWidget { ), FluentIcons.toolbox: ( S.current.app_index_menu_tools, - const ToolsUI(), + const SizedBox(), ), FluentIcons.settings: ( S.current.app_index_menu_settings, - const SettingsUI() + const SizedBox() ), FluentIcons.info: ( S.current.app_index_menu_about, @@ -140,37 +134,4 @@ class IndexUI extends HookConsumerWidget { pageMenus.values.toList().indexWhere((element) => element.$1 == value); curIndexState.value = pageIndex; } - - Widget _makeAria2TaskNumWidget() { - return Consumer( - builder: (BuildContext context, WidgetRef ref, Widget? child) { - final aria2cState = ref.watch(aria2cModelProvider); - if (!aria2cState.hasDownloadTask) { - return const SizedBox(); - } - return Positioned( - bottom: 0, - right: 0, - child: Container( - decoration: BoxDecoration( - color: Colors.red, - borderRadius: BorderRadius.circular(12), - ), - padding: const EdgeInsets.only( - left: 6, right: 6, bottom: 1.5, top: 1.5), - child: Text( - "${aria2cState.aria2TotalTaskNum}", - style: const TextStyle( - fontSize: 8, - color: Colors.white, - ), - ), - )); - }, - ); - } - - _goDownloader(BuildContext context) { - context.push('/index/downloader'); - } } diff --git a/lib/ui/party_room/party_room_ui.dart b/lib/ui/party_room/party_room_ui.dart deleted file mode 100644 index c86f270..0000000 --- a/lib/ui/party_room/party_room_ui.dart +++ /dev/null @@ -1,41 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:starcitizen_doctor/generated/l10n.dart'; -import 'package:url_launcher/url_launcher_string.dart'; - -class PartyRoomUI extends HookConsumerWidget { - const PartyRoomUI({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - return Center( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - S.current.lobby_online_lobby_coming_soon, - style: const TextStyle(fontSize: 20), - ), - const SizedBox(height: 12), - GestureDetector( - onTap: () { - launchUrlString("https://wj.qq.com/s2/14112124/f4c8/"); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Text(S.current.lobby_invitation_to_participate), - Text( - S.current.lobby_survey, - style: const TextStyle( - color: Colors.blue, - ), - ) - ], - ), - ), - ], - ), - ); - } -} diff --git a/lib/ui/settings/settings_ui.dart b/lib/ui/settings/settings_ui.dart deleted file mode 100644 index 1ebc4fd..0000000 --- a/lib/ui/settings/settings_ui.dart +++ /dev/null @@ -1,161 +0,0 @@ -import 'package:fluent_ui/fluent_ui.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:starcitizen_doctor/app.dart'; -import 'package:starcitizen_doctor/generated/l10n.dart'; -import 'package:starcitizen_doctor/ui/settings/settings_ui_model.dart'; - -class SettingsUI extends HookConsumerWidget { - const SettingsUI({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final sate = ref.watch(settingsUIModelProvider); - final model = ref.read(settingsUIModelProvider.notifier); - final appGlobalState = ref.watch(appGlobalModelProvider); - final appGlobalModel = ref.read(appGlobalModelProvider.notifier); - return ListView(padding: const EdgeInsets.all(16), children: [ - makeSettingsItem( - const Icon(FontAwesomeIcons.language, size: 20), - S.current.settings_app_language, - subTitle: S.current.settings_app_language_switch_info, - onTap: () {}, - onComboChanged: appGlobalModel.changeLocale, - comboMenus: AppGlobalModel.appLocaleSupport, - selectedComboValue: appGlobalState.appLocale ?? const Locale("auto"), - showGoIcon: false, - ), - const SizedBox(height: 12), - makeSettingsItem(const Icon(FluentIcons.link, size: 20), - S.current.setting_action_create_settings_shortcut, - subTitle: S.current.setting_action_create_desktop_shortcut, - onTap: () => model.addShortCut(context)), - const SizedBox(height: 12), - makeSettingsItem(const Icon(FontAwesomeIcons.microchip, size: 20), - S.current.setting_action_ignore_efficiency_cores_on_launch, - subTitle: S.current - .setting_action_set_core_count(sate.inputGameLaunchECore), - onTap: () => model.setGameLaunchECore(context)), - const SizedBox(height: 12), - makeSettingsItem(const Icon(FluentIcons.folder_open, size: 20), - S.current.setting_action_set_launcher_file, - subTitle: sate.customLauncherPath != null - ? "${sate.customLauncherPath}" - : S.current.setting_action_info_manual_launcher_location_setting, - onTap: () => model.setLauncherPath(context), - onDel: () { - model.delName("custom_launcher_path"); - }), - const SizedBox(height: 12), - makeSettingsItem(const Icon(FluentIcons.game, size: 20), - S.current.setting_action_set_game_file, - subTitle: sate.customGamePath != null - ? "${sate.customGamePath}" - : S.current.setting_action_info_manual_game_location_setting, - onTap: () => model.setGamePath(context), - onDel: () { - model.delName("custom_game_path"); - }), - const SizedBox(height: 12), - makeSettingsItem(const Icon(FluentIcons.delete, size: 20), - S.current.setting_action_clear_translation_file_cache, - subTitle: S.current.setting_action_info_cache_clearing_info( - (sate.locationCacheSize / 1024 / 1024).toStringAsFixed(2)), - onTap: () => model.cleanLocationCache(context)), - const SizedBox(height: 12), - makeSettingsItem(const Icon(FluentIcons.speed_high, size: 20), - S.current.setting_action_tool_site_access_acceleration, - onTap: () => - model.onChangeToolSiteMirror(!sate.isEnableToolSiteMirrors), - subTitle: S.current.setting_action_info_mirror_server_info, - onSwitch: model.onChangeToolSiteMirror, - switchStatus: sate.isEnableToolSiteMirrors), - const SizedBox(height: 12), - makeSettingsItem(const Icon(FluentIcons.document_set, size: 20), - S.current.setting_action_view_log, - onTap: () => model.showLogs(), - subTitle: S.current.setting_action_info_view_log_file), - ]); - } - - Widget makeSettingsItem( - Widget icon, - String title, { - String? subTitle, - VoidCallback? onTap, - VoidCallback? onDel, - void Function(bool? b)? onSwitch, - bool switchStatus = false, - bool showGoIcon = true, - Map comboMenus = const {}, - ValueChanged? onComboChanged, - dynamic selectedComboValue, - }) { - return Button( - onPressed: onTap, - child: Padding( - padding: const EdgeInsets.only(top: 12, bottom: 12), - child: Row( - children: [ - icon, - const SizedBox(width: 18), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Text(title), - const Spacer(), - ], - ), - if (subTitle != null) ...[ - const SizedBox(height: 3), - Padding( - padding: const EdgeInsets.only(right: 12), - child: Text( - subTitle, - textAlign: TextAlign.start, - style: TextStyle( - fontSize: 12, color: Colors.white.withOpacity(.6)), - ), - ), - ] - ], - ), - ), - if (onDel != null) ...[ - Button( - onPressed: onDel, - child: const Padding( - padding: EdgeInsets.all(6), - child: Icon(FluentIcons.delete), - )), - ], - if (onSwitch != null) ...[ - ToggleSwitch(checked: switchStatus, onChanged: onSwitch), - ], - if (comboMenus.isNotEmpty) ...[ - SizedBox( - height: 36, - child: ComboBox( - value: selectedComboValue, - items: [ - for (final mkv in comboMenus.entries) - ComboBoxItem( - value: mkv.key, - child: Text(mkv.value), - ) - ], - onChanged: onComboChanged, - ), - ) - ], - const SizedBox(width: 12), - if (showGoIcon) const Icon(FluentIcons.chevron_right), - ], - ), - ), - ); - } -} diff --git a/lib/ui/settings/settings_ui_model.dart b/lib/ui/settings/settings_ui_model.dart deleted file mode 100644 index 1c05a1d..0000000 --- a/lib/ui/settings/settings_ui_model.dart +++ /dev/null @@ -1,196 +0,0 @@ -// ignore_for_file: avoid_build_context_in_providers -import 'dart:io'; - -import 'package:file_picker/file_picker.dart'; -import 'package:fluent_ui/fluent_ui.dart'; -import 'package:flutter/services.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:hive/hive.dart'; -import 'package:riverpod_annotation/riverpod_annotation.dart'; -import 'package:starcitizen_doctor/common/conf/const_conf.dart'; -import 'package:starcitizen_doctor/common/helper/system_helper.dart'; -import 'package:starcitizen_doctor/common/utils/log.dart'; -import 'package:starcitizen_doctor/common/utils/provider.dart'; -import 'package:starcitizen_doctor/widgets/widgets.dart'; - -part 'settings_ui_model.g.dart'; - -part 'settings_ui_model.freezed.dart'; - -@freezed -class SettingsUIState with _$SettingsUIState { - factory SettingsUIState({ - @Default(false) bool isEnableToolSiteMirrors, - @Default("0") String inputGameLaunchECore, - String? customLauncherPath, - String? customGamePath, - @Default(0) int locationCacheSize, - }) = _SettingsUIState; -} - -@riverpod -class SettingsUIModel extends _$SettingsUIModel { - @override - SettingsUIState build() { - state = SettingsUIState(); - _initState(); - return state; - } - - void _initState() async { - _updateGameLaunchECore(); - _loadCustomPath(); - _loadLocationCacheSize(); - _loadToolSiteMirrorState(); - } - - Future setGameLaunchECore(BuildContext context) async { - final userBox = await Hive.openBox("app_conf"); - final defaultInput = - userBox.get("gameLaunch_eCore_count", defaultValue: "0"); - if (!context.mounted) return; - final input = await showInputDialogs(context, - title: S.current.setting_action_info_enter_cpu_core_to_ignore, - content: S.current.setting_action_info_cpu_core_tip, - initialValue: defaultInput, - inputFormatters: [FilteringTextInputFormatter.digitsOnly]); - if (input == null) return; - userBox.put("gameLaunch_eCore_count", input); - _initState(); - } - - Future _updateGameLaunchECore() async { - final userBox = await Hive.openBox("app_conf"); - final inputGameLaunchECore = - userBox.get("gameLaunch_eCore_count", defaultValue: "0"); - state = state.copyWith(inputGameLaunchECore: inputGameLaunchECore); - } - - Future setLauncherPath(BuildContext context) async { - final r = await FilePicker.platform.pickFiles( - dialogTitle: S.current.setting_action_info_select_rsi_launcher_location, - type: FileType.custom, - allowedExtensions: ["exe"]); - if (r == null || r.files.firstOrNull?.path == null) return; - final fileName = r.files.first.path!; - if (fileName.endsWith("\\RSI Launcher.exe")) { - await _saveCustomPath("custom_launcher_path", fileName); - if (!context.mounted) return; - showToast(context, S.current.setting_action_info_setting_success); - _initState(); - } else { - if (!context.mounted) return; - showToast(context, S.current.setting_action_info_file_error); - } - } - - Future setGamePath(BuildContext context) async { - final r = await FilePicker.platform.pickFiles( - dialogTitle: S.current.setting_action_info_select_game_install_location, - type: FileType.custom, - allowedExtensions: ["exe"]); - if (r == null || r.files.firstOrNull?.path == null) return; - final fileName = r.files.first.path!; - dPrint(fileName); - final fileNameRegExp = - RegExp(r"^(.*\\StarCitizen\\.*\\)Bin64\\StarCitizen\.exe$"); - if (fileNameRegExp.hasMatch(fileName)) { - RegExp pathRegex = RegExp(r"\\[^\\]+\\Bin64\\StarCitizen\.exe$"); - String extractedPath = fileName.replaceFirst(pathRegex, ''); - await _saveCustomPath("custom_game_path", extractedPath); - if (!context.mounted) return; - showToast(context, S.current.setting_action_info_setting_success); - _initState(); - } else { - if (!context.mounted) return; - showToast(context, S.current.setting_action_info_file_error); - } - } - - _saveCustomPath(String pathKey, String dir) async { - final confBox = await Hive.openBox("app_conf"); - await confBox.put(pathKey, dir); - } - - _loadCustomPath() async { - final confBox = await Hive.openBox("app_conf"); - final customLauncherPath = confBox.get("custom_launcher_path"); - final customGamePath = confBox.get("custom_game_path"); - state = state.copyWith( - customLauncherPath: customLauncherPath, customGamePath: customGamePath); - } - - Future delName(String key) async { - final confBox = await Hive.openBox("app_conf"); - await confBox.delete(key); - _initState(); - } - - _loadLocationCacheSize() async { - final len = await SystemHelper.getDirLen( - "${appGlobalState.applicationSupportDir}/Localizations"); - final locationCacheSize = len; - state = state.copyWith(locationCacheSize: locationCacheSize); - } - - Future cleanLocationCache(BuildContext context) async { - final ok = await showConfirmDialogs( - context, - S.current.setting_action_info_confirm_clear_cache, - Text(S.current.setting_action_info_clear_cache_warning)); - if (ok == true) { - final dir = - Directory("${appGlobalState.applicationSupportDir}/Localizations"); - if (!context.mounted) return; - await dir.delete(recursive: true).unwrap(context: context); - _initState(); - } - } - - Future addShortCut(BuildContext context) async { - if (ConstConf.isMSE) { - showToast( - context, S.current.setting_action_info_microsoft_version_limitation); - await Future.delayed(const Duration(seconds: 1)); - Process.run("explorer.exe", ["shell:AppsFolder"]); - return; - } - dPrint(Platform.resolvedExecutable); - final shortCuntName = S.current.app_shortcut_name; - final script = """ - \$targetPath = "${Platform.resolvedExecutable}"; - \$shortcutPath = [System.IO.Path]::Combine([System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::DesktopDirectory), "$shortCuntName"); - \$shell = New-Object -ComObject WScript.Shell - \$shortcut = \$shell.CreateShortcut(\$shortcutPath) - if (\$shortcut -eq \$null) { - Write-Host "Failed to create shortcut." - } else { - \$shortcut.TargetPath = \$targetPath - \$shortcut.Save() - Write-Host "Shortcut created successfully." - } -"""; - await Process.run(SystemHelper.powershellPath, [script]); - if (!context.mounted) return; - showToast(context, S.current.setting_action_info_shortcut_created); - } - - _loadToolSiteMirrorState() async { - final userBox = await Hive.openBox("app_conf"); - final isEnableToolSiteMirrors = - userBox.get("isEnableToolSiteMirrors", defaultValue: false); - state = state.copyWith(isEnableToolSiteMirrors: isEnableToolSiteMirrors); - } - - void onChangeToolSiteMirror(bool? b) async { - final userBox = await Hive.openBox("app_conf"); - final isEnableToolSiteMirrors = b == true; - await userBox.put("isEnableToolSiteMirrors", isEnableToolSiteMirrors); - _initState(); - } - - showLogs() async { - SystemHelper.openDir(getDPrintFile()?.absolute.path.replaceAll("/", "\\"), - isFile: true); - } -} diff --git a/lib/ui/settings/settings_ui_model.freezed.dart b/lib/ui/settings/settings_ui_model.freezed.dart deleted file mode 100644 index 50ecdd5..0000000 --- a/lib/ui/settings/settings_ui_model.freezed.dart +++ /dev/null @@ -1,243 +0,0 @@ -// coverage:ignore-file -// GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark - -part of 'settings_ui_model.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -T _$identity(T value) => value; - -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); - -/// @nodoc -mixin _$SettingsUIState { - bool get isEnableToolSiteMirrors => throw _privateConstructorUsedError; - String get inputGameLaunchECore => throw _privateConstructorUsedError; - String? get customLauncherPath => throw _privateConstructorUsedError; - String? get customGamePath => throw _privateConstructorUsedError; - int get locationCacheSize => throw _privateConstructorUsedError; - - /// Create a copy of SettingsUIState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $SettingsUIStateCopyWith get copyWith => - throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $SettingsUIStateCopyWith<$Res> { - factory $SettingsUIStateCopyWith( - SettingsUIState value, $Res Function(SettingsUIState) then) = - _$SettingsUIStateCopyWithImpl<$Res, SettingsUIState>; - @useResult - $Res call( - {bool isEnableToolSiteMirrors, - String inputGameLaunchECore, - String? customLauncherPath, - String? customGamePath, - int locationCacheSize}); -} - -/// @nodoc -class _$SettingsUIStateCopyWithImpl<$Res, $Val extends SettingsUIState> - implements $SettingsUIStateCopyWith<$Res> { - _$SettingsUIStateCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of SettingsUIState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? isEnableToolSiteMirrors = null, - Object? inputGameLaunchECore = null, - Object? customLauncherPath = freezed, - Object? customGamePath = freezed, - Object? locationCacheSize = null, - }) { - return _then(_value.copyWith( - isEnableToolSiteMirrors: null == isEnableToolSiteMirrors - ? _value.isEnableToolSiteMirrors - : isEnableToolSiteMirrors // ignore: cast_nullable_to_non_nullable - as bool, - inputGameLaunchECore: null == inputGameLaunchECore - ? _value.inputGameLaunchECore - : inputGameLaunchECore // ignore: cast_nullable_to_non_nullable - as String, - customLauncherPath: freezed == customLauncherPath - ? _value.customLauncherPath - : customLauncherPath // ignore: cast_nullable_to_non_nullable - as String?, - customGamePath: freezed == customGamePath - ? _value.customGamePath - : customGamePath // ignore: cast_nullable_to_non_nullable - as String?, - locationCacheSize: null == locationCacheSize - ? _value.locationCacheSize - : locationCacheSize // ignore: cast_nullable_to_non_nullable - as int, - ) as $Val); - } -} - -/// @nodoc -abstract class _$$SettingsUIStateImplCopyWith<$Res> - implements $SettingsUIStateCopyWith<$Res> { - factory _$$SettingsUIStateImplCopyWith(_$SettingsUIStateImpl value, - $Res Function(_$SettingsUIStateImpl) then) = - __$$SettingsUIStateImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {bool isEnableToolSiteMirrors, - String inputGameLaunchECore, - String? customLauncherPath, - String? customGamePath, - int locationCacheSize}); -} - -/// @nodoc -class __$$SettingsUIStateImplCopyWithImpl<$Res> - extends _$SettingsUIStateCopyWithImpl<$Res, _$SettingsUIStateImpl> - implements _$$SettingsUIStateImplCopyWith<$Res> { - __$$SettingsUIStateImplCopyWithImpl( - _$SettingsUIStateImpl _value, $Res Function(_$SettingsUIStateImpl) _then) - : super(_value, _then); - - /// Create a copy of SettingsUIState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? isEnableToolSiteMirrors = null, - Object? inputGameLaunchECore = null, - Object? customLauncherPath = freezed, - Object? customGamePath = freezed, - Object? locationCacheSize = null, - }) { - return _then(_$SettingsUIStateImpl( - isEnableToolSiteMirrors: null == isEnableToolSiteMirrors - ? _value.isEnableToolSiteMirrors - : isEnableToolSiteMirrors // ignore: cast_nullable_to_non_nullable - as bool, - inputGameLaunchECore: null == inputGameLaunchECore - ? _value.inputGameLaunchECore - : inputGameLaunchECore // ignore: cast_nullable_to_non_nullable - as String, - customLauncherPath: freezed == customLauncherPath - ? _value.customLauncherPath - : customLauncherPath // ignore: cast_nullable_to_non_nullable - as String?, - customGamePath: freezed == customGamePath - ? _value.customGamePath - : customGamePath // ignore: cast_nullable_to_non_nullable - as String?, - locationCacheSize: null == locationCacheSize - ? _value.locationCacheSize - : locationCacheSize // ignore: cast_nullable_to_non_nullable - as int, - )); - } -} - -/// @nodoc - -class _$SettingsUIStateImpl implements _SettingsUIState { - _$SettingsUIStateImpl( - {this.isEnableToolSiteMirrors = false, - this.inputGameLaunchECore = "0", - this.customLauncherPath, - this.customGamePath, - this.locationCacheSize = 0}); - - @override - @JsonKey() - final bool isEnableToolSiteMirrors; - @override - @JsonKey() - final String inputGameLaunchECore; - @override - final String? customLauncherPath; - @override - final String? customGamePath; - @override - @JsonKey() - final int locationCacheSize; - - @override - String toString() { - return 'SettingsUIState(isEnableToolSiteMirrors: $isEnableToolSiteMirrors, inputGameLaunchECore: $inputGameLaunchECore, customLauncherPath: $customLauncherPath, customGamePath: $customGamePath, locationCacheSize: $locationCacheSize)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$SettingsUIStateImpl && - (identical( - other.isEnableToolSiteMirrors, isEnableToolSiteMirrors) || - other.isEnableToolSiteMirrors == isEnableToolSiteMirrors) && - (identical(other.inputGameLaunchECore, inputGameLaunchECore) || - other.inputGameLaunchECore == inputGameLaunchECore) && - (identical(other.customLauncherPath, customLauncherPath) || - other.customLauncherPath == customLauncherPath) && - (identical(other.customGamePath, customGamePath) || - other.customGamePath == customGamePath) && - (identical(other.locationCacheSize, locationCacheSize) || - other.locationCacheSize == locationCacheSize)); - } - - @override - int get hashCode => Object.hash( - runtimeType, - isEnableToolSiteMirrors, - inputGameLaunchECore, - customLauncherPath, - customGamePath, - locationCacheSize); - - /// Create a copy of SettingsUIState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$SettingsUIStateImplCopyWith<_$SettingsUIStateImpl> get copyWith => - __$$SettingsUIStateImplCopyWithImpl<_$SettingsUIStateImpl>( - this, _$identity); -} - -abstract class _SettingsUIState implements SettingsUIState { - factory _SettingsUIState( - {final bool isEnableToolSiteMirrors, - final String inputGameLaunchECore, - final String? customLauncherPath, - final String? customGamePath, - final int locationCacheSize}) = _$SettingsUIStateImpl; - - @override - bool get isEnableToolSiteMirrors; - @override - String get inputGameLaunchECore; - @override - String? get customLauncherPath; - @override - String? get customGamePath; - @override - int get locationCacheSize; - - /// Create a copy of SettingsUIState - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$SettingsUIStateImplCopyWith<_$SettingsUIStateImpl> get copyWith => - throw _privateConstructorUsedError; -} diff --git a/lib/ui/settings/settings_ui_model.g.dart b/lib/ui/settings/settings_ui_model.g.dart deleted file mode 100644 index e315053..0000000 --- a/lib/ui/settings/settings_ui_model.g.dart +++ /dev/null @@ -1,26 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'settings_ui_model.dart'; - -// ************************************************************************** -// RiverpodGenerator -// ************************************************************************** - -String _$settingsUIModelHash() => r'2be0fe230d23f84796e0a3a39dd3248c2aa90f23'; - -/// See also [SettingsUIModel]. -@ProviderFor(SettingsUIModel) -final settingsUIModelProvider = - AutoDisposeNotifierProvider.internal( - SettingsUIModel.new, - name: r'settingsUIModelProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$settingsUIModelHash, - dependencies: null, - allTransitiveDependencies: null, -); - -typedef _$SettingsUIModel = AutoDisposeNotifier; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member diff --git a/lib/ui/settings/upgrade_dialog.dart b/lib/ui/settings/upgrade_dialog.dart deleted file mode 100644 index 9042759..0000000 --- a/lib/ui/settings/upgrade_dialog.dart +++ /dev/null @@ -1,265 +0,0 @@ -import 'dart:io'; - -import 'package:dio/dio.dart'; -import 'package:fluent_ui/fluent_ui.dart'; -import 'package:flutter/material.dart' show Material; -import 'package:flutter_hooks/flutter_hooks.dart'; -import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:markdown/markdown.dart' as markdown; -import 'package:starcitizen_doctor/api/api.dart'; -import 'package:starcitizen_doctor/app.dart'; -import 'package:starcitizen_doctor/common/conf/const_conf.dart'; -import 'package:starcitizen_doctor/common/conf/url_conf.dart'; -import 'package:starcitizen_doctor/common/helper/system_helper.dart'; -import 'package:starcitizen_doctor/common/utils/log.dart'; -import 'package:starcitizen_doctor/widgets/widgets.dart'; -import 'package:html/parser.dart' as html_parser; -import 'package:url_launcher/url_launcher_string.dart'; - -class UpgradeDialogUI extends HookConsumerWidget { - const UpgradeDialogUI({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final appState = ref.watch(appGlobalModelProvider); - final appModel = ref.read(appGlobalModelProvider.notifier); - final description = useState(null); - final isUsingDiversion = useState(false); - final isUpgrading = useState(false); - final progress = useState(0.0); - final downloadUrl = useState(""); - - final targetVersion = ConstConf.isMSE - ? appState.networkVersionData!.mSELastVersion! - : appState.networkVersionData!.lastVersion!; - - final minVersionCode = ConstConf.isMSE - ? appState.networkVersionData?.mSEMinVersionCode - : appState.networkVersionData?.minVersionCode; - - useEffect(() { - _getUpdateInfo(context, targetVersion, description, downloadUrl); - return null; - }, []); - - return Material( - child: ContentDialog( - title: - Text(S.current.app_upgrade_title_new_version_found(targetVersion)), - constraints: - BoxConstraints(maxWidth: MediaQuery.of(context).size.width * .55), - content: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Expanded( - child: SingleChildScrollView( - child: Padding( - padding: const EdgeInsets.only(left: 24, right: 24), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - if (description.value == null) ...[ - Center( - child: Column( - children: [ - const ProgressRing(), - const SizedBox(height: 16), - Text(S.current - .app_upgrade_info_getting_new_version_details) - ], - ), - ) - ] else - ...makeMarkdownView(description.value!, - attachmentsUrl: URLConf.giteaAttachmentsUrl), - ], - ), - ), - )), - if (isUsingDiversion.value) ...[ - const SizedBox(height: 24), - GestureDetector( - onTap: _launchReleaseUrl, - child: Container( - padding: const EdgeInsets.all(12), - decoration: BoxDecoration( - color: Colors.white.withOpacity(.1), - borderRadius: BorderRadius.circular(7)), - child: Text( - S.current.app_upgrade_info_update_server_tip, - style: TextStyle( - fontSize: 14, color: Colors.white.withOpacity(.7)), - ), - ), - ), - ], - if (isUpgrading.value) ...[ - const SizedBox(height: 24), - Row( - children: [ - Text(progress.value == 100 - ? S.current.app_upgrade_info_installing - : S.current.app_upgrade_info_downloading( - progress.value.toStringAsFixed(2))), - Expanded( - child: ProgressBar( - value: progress.value == 100 ? null : progress.value, - )), - ], - ), - ], - ], - ), - actions: isUpgrading.value - ? null - : [ - if (downloadUrl.value.isNotEmpty) - FilledButton( - onPressed: () => _doUpgrade( - context, - appState, - isUpgrading, - appModel, - downloadUrl, - description, - isUsingDiversion, - progress), - child: Padding( - padding: const EdgeInsets.only( - top: 4, bottom: 4, left: 8, right: 8), - child: Text(S.current.app_upgrade_action_update_now), - )), - if (ConstConf.appVersionCode >= (minVersionCode ?? 0)) - Button( - onPressed: () => _doCancel(context), - child: Padding( - padding: const EdgeInsets.only( - top: 4, bottom: 4, left: 8, right: 8), - child: Text(S.current.app_upgrade_action_next_time), - )), - ], - ), - ); - } - - Future _getUpdateInfo( - BuildContext context, - String targetVersion, - ValueNotifier description, - ValueNotifier downloadUrl) async { - try { - final r = await Api.getAppReleaseDataByVersionName(targetVersion); - description.value = r["body"]; - final assets = List.of(r["assets"] ?? []); - for (var asset in assets) { - if (asset["name"].toString().endsWith("SETUP.exe")) { - downloadUrl.value = asset["browser_download_url"]; - } - } - } catch (e) { - dPrint("UpgradeDialogUIModel.loadData Error : $e"); - if (!context.mounted) return; - Navigator.pop(context, false); - } - } - - void _launchReleaseUrl() { - launchUrlString(URLConf.devReleaseUrl); - } - - void _doCancel(BuildContext context) { - Navigator.pop(context, true); - } - - String _getDiversionUrl(String description) { - try { - final htmlStr = markdown.markdownToHtml(description); - final html = html_parser.parse(htmlStr); - for (var element in html.querySelectorAll('a')) { - String linkText = element.text; - String linkUrl = element.attributes['href'] ?? ''; - if (linkText.trim().endsWith("_SETUP.exe")) { - final diversionDownloadUrl = linkUrl.trim(); - dPrint("diversionDownloadUrl === $diversionDownloadUrl"); - return diversionDownloadUrl; - } - } - } catch (e) { - dPrint("_checkDiversionUrl Error:$e"); - } - return ""; - } - - Future _doUpgrade( - BuildContext context, - AppGlobalState appState, - ValueNotifier isUpgrading, - AppGlobalModel appModel, - ValueNotifier downloadUrl, - ValueNotifier description, - ValueNotifier isUsingDiversion, - ValueNotifier progress) async { - if (ConstConf.isMSE) { - launchUrlString("ms-windows-store://pdp/?productid=9NF3SWFWNKL1"); - await Future.delayed(const Duration(seconds: 3)); - if (ConstConf.appVersionCode < - (appState.networkVersionData?.minVersionCode ?? 0)) { - exit(0); - } - if (!context.mounted) return; - _doCancel(context); - return; - } - isUpgrading.value = true; - final fileName = "${appModel.getUpgradePath()}/next_SETUP.exe"; - try { - // check diversionDownloadUrl - var url = downloadUrl.value; - final diversionDownloadUrl = _getDiversionUrl(description.value!); - final dio = Dio(); - if (diversionDownloadUrl.isNotEmpty) { - try { - final resp = await dio.head(diversionDownloadUrl, - options: Options( - sendTimeout: const Duration(seconds: 10), - receiveTimeout: const Duration(seconds: 10))); - if (resp.statusCode == 200) { - isUsingDiversion.value = true; - url = diversionDownloadUrl; - } else { - isUsingDiversion.value = false; - } - dPrint("diversionDownloadUrl head resp == ${resp.headers}"); - } catch (e) { - dPrint("diversionDownloadUrl err:$e"); - } - } - await dio.download(url, fileName, - onReceiveProgress: (int count, int total) { - progress.value = (count / total) * 100; - }); - } catch (_) { - isUpgrading.value = false; - progress.value = 0; - if (!context.mounted) return; - showToast(context, S.current.app_upgrade_info_download_failed); - return; - } - - try { - final r = await (Process.run( - SystemHelper.powershellPath, ["start", fileName, "/SILENT"])); - if (r.stderr.toString().isNotEmpty) { - throw r.stderr; - } - exit(0); - } catch (_) { - isUpgrading.value = false; - progress.value = 0; - if (!context.mounted) return; - showToast(context, S.current.app_upgrade_info_run_failed); - SystemHelper.openDir(fileName); - } - } -} diff --git a/lib/ui/splash_ui.dart b/lib/ui/splash_ui.dart index 2d60548..d388573 100644 --- a/lib/ui/splash_ui.dart +++ b/lib/ui/splash_ui.dart @@ -12,7 +12,6 @@ import 'package:starcitizen_doctor/app.dart'; import 'package:starcitizen_doctor/common/conf/const_conf.dart'; import 'package:starcitizen_doctor/common/conf/url_conf.dart'; import 'package:starcitizen_doctor/common/utils/log.dart'; -import 'package:starcitizen_doctor/provider/aria2c.dart'; import 'package:starcitizen_doctor/widgets/widgets.dart'; class SplashUI extends HookConsumerWidget { @@ -86,17 +85,18 @@ class SplashUI extends HookConsumerWidget { dPrint("_initApp checkUpdate"); await appModel.checkUpdate(context); stepState.value = 2; - dPrint("_initApp aria2cModelProvider"); - ref.read(aria2cModelProvider); if (!context.mounted) return; - context.go("/index"); + context.go("/"); } _showAlert(BuildContext context, Box appConf) async { final userOk = await showConfirmDialogs( context, S.current.app_splash_dialog_u_a_p_p, - MarkdownWidget(data: S.current.app_splash_dialog_u_a_p_p_content), + MarkdownWidget( + data: S.current.app_splash_dialog_u_a_p_p_content, + shrinkWrap: true, + ), constraints: BoxConstraints(maxWidth: MediaQuery.of(context).size.width * .5)); if (userOk) { diff --git a/lib/ui/tools/dialogs/hosts_booster_dialog_ui.dart b/lib/ui/tools/dialogs/hosts_booster_dialog_ui.dart deleted file mode 100644 index 3177476..0000000 --- a/lib/ui/tools/dialogs/hosts_booster_dialog_ui.dart +++ /dev/null @@ -1,296 +0,0 @@ -import 'dart:io'; - -import 'package:fluent_ui/fluent_ui.dart'; -import 'package:flutter_hooks/flutter_hooks.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:starcitizen_doctor/api/analytics.dart'; -import 'package:starcitizen_doctor/common/helper/system_helper.dart'; -import 'package:starcitizen_doctor/common/io/rs_http.dart'; -import 'package:starcitizen_doctor/common/utils/async.dart'; -import 'package:starcitizen_doctor/common/utils/log.dart'; - -class HostsBoosterDialogUI extends HookConsumerWidget { - const HostsBoosterDialogUI({super.key}); - - static final _hostsMap = { - "Recaptcha": ["www.recaptcha.net", "recaptcha.net"], - S.current.tools_hosts_info_rsi_official_website: [ - "robertsspaceindustries.com" - ], - S.current.tools_hosts_info_rsi_customer_service: [ - "support.robertsspaceindustries.com" - ], - }; - - @override - Widget build(BuildContext context, WidgetRef ref) { - final checkedMap = useState>({}); - final workingMap = useState>({}); - final workingText = useState(""); - - doHost(BuildContext context) async { - if (workingMap.value.isEmpty) { - final hasTrue = - checkedMap.value.values.where((element) => element).firstOrNull != - null; - if (!hasTrue) { - for (var k in _hostsMap.keys) { - checkedMap.value[k] = true; - } - checkedMap.value = Map.from(checkedMap.value); - } - } - workingText.value = S.current.tools_hosts_info_dns_query_and_test; - final ipsMap = await _doCheckDns(workingMap, checkedMap); - workingText.value = S.current.tools_hosts_info_writing_hosts; - if (!context.mounted) return; - await _doWriteHosts(ipsMap).unwrap(context: context); - workingText.value = S.current.tools_hosts_info_reading_config; - await _readHostsState(workingMap, checkedMap); - workingText.value = ""; - } - - useEffect(() { - AnalyticsApi.touch("host_dns_boost"); - // 监听 Hosts 文件变更 - _readHostsState(workingMap, checkedMap); - return null; - }, []); - - return ContentDialog( - constraints: - BoxConstraints(maxWidth: MediaQuery.of(context).size.width * .55), - title: Row( - children: [ - IconButton( - icon: const Icon( - FluentIcons.back, - size: 22, - ), - onPressed: - workingText.value.isEmpty ? Navigator.of(context).pop : null), - const SizedBox(width: 12), - Text(S.current.tools_hosts_info_hosts_acceleration), - const Spacer(), - Button( - onPressed: () => _openHostsFile(context), - child: Padding( - padding: const EdgeInsets.all(3), - child: Row( - children: [ - const Icon(FluentIcons.open_file), - const SizedBox(width: 6), - Text(S.current.tools_hosts_info_open_hosts_file), - ], - ), - )) - ], - ), - content: AnimatedSize( - duration: const Duration(milliseconds: 200), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - const SizedBox(height: 12), - Row( - children: [ - const SizedBox(width: 12), - Text(S.current.tools_hosts_info_status), - const SizedBox(width: 38), - Text(S.current.tools_hosts_info_site), - const Spacer(), - Text(S.current.tools_hosts_info_enable), - const SizedBox(width: 12), - ], - ), - const SizedBox(height: 12), - ListView.builder( - itemCount: _hostsMap.length, - shrinkWrap: true, - padding: const EdgeInsets.all(6), - physics: const NeverScrollableScrollPhysics(), - itemBuilder: (BuildContext context, int index) { - final isEnable = - checkedMap.value[_hostsMap.keys.elementAt(index)] ?? false; - final workingState = - workingMap.value[_hostsMap.keys.elementAt(index)]; - return Container( - padding: const EdgeInsets.all(12), - margin: const EdgeInsets.only(bottom: 12), - decoration: BoxDecoration( - color: FluentTheme.of(context).cardColor, - borderRadius: BorderRadius.circular(12), - ), - child: Row( - children: [ - if (workingState == null) - Icon(FontAwesomeIcons.xmark, - size: 24, color: Colors.red), - if (workingState == 0) - const SizedBox( - width: 24, height: 24, child: ProgressRing()), - if (workingState == 1) - Icon(FontAwesomeIcons.check, - size: 24, color: Colors.green), - const SizedBox(width: 24), - const SizedBox(width: 12), - Text(_hostsMap.keys.elementAt(index)), - const Spacer(), - ToggleSwitch( - onChanged: (value) { - checkedMap.value[_hostsMap.keys.elementAt(index)] = - value; - checkedMap.value = Map.from(checkedMap.value); - }, - checked: isEnable, - ), - ], - ), - ); - }, - ), - const SizedBox(height: 12), - if (workingText.value.isNotEmpty) - SizedBox( - height: 86, - child: Column( - children: [ - const SizedBox( - height: 42, width: 42, child: ProgressRing()), - const SizedBox(height: 12), - Text(workingText.value), - ], - ), - ) - else - Padding( - padding: const EdgeInsets.all(12), - child: FilledButton( - onPressed: () => doHost(context), - child: Padding( - padding: const EdgeInsets.only( - top: 3, bottom: 3, left: 12, right: 12), - child: Text( - S.current.tools_hosts_action_one_click_acceleration), - ), - ), - ), - ], - ), - ), - ); - } - - Future _openHostsFile(BuildContext context) async { - // 使用管理员权限调用记事本${S.current.tools_hosts_info_open_hosts_file} - Process.run(SystemHelper.powershellPath, [ - "-Command", - "Start-Process notepad.exe -Verb runAs -ArgumentList ${SystemHelper.getHostsFilePath()}" - // ignore: use_build_context_synchronously - ]).unwrap(context: context); - } - - Future> _doCheckDns( - ValueNotifier> workingMap, - ValueNotifier> checkedMap) async { - Map result = {}; - final trueLen = checkedMap.value.values.where((element) => element).length; - if (trueLen == 0) { - return result; - } - for (var kv in _hostsMap.entries) { - final siteName = kv.key; - final siteHost = kv.value.first; - if (!(checkedMap.value[siteName] ?? false)) { - continue; - } - workingMap.value[siteName] = 0; - workingMap.value = Map.from(workingMap.value); - RSHttp.dnsLookupIps(siteHost).then((ips) async { - int tryCount = ips.length; - try { - for (var ip in ips) { - final resp = - await RSHttp.head("https://$siteHost", withIpAddress: ip); - dPrint( - "[HostsBooster] host== $siteHost ip== $ip resp== ${resp.headers}"); - if (resp.headers.isNotEmpty) { - if (result[siteName] == null) { - result[siteName] = ip; - workingMap.value[siteName] = 1; - workingMap.value = Map.from(workingMap.value); - break; - } - } - } - } catch (e) { - tryCount--; - if (tryCount == 0) { - workingMap.value[siteName] = null; - workingMap.value = Map.from(workingMap.value); - result[siteName] = ""; - } - } - }, onError: (e) { - workingMap.value[siteName] = null; - workingMap.value = Map.from(workingMap.value); - result[siteName] = ""; - }); - } - while (true) { - await Future.delayed(const Duration(milliseconds: 100)); - if (result.length == trueLen) { - return result; - } - } - } - - Future _doWriteHosts(Map ipsMap) async { - // 读取 hosts 文件 - final hostsFile = File(SystemHelper.getHostsFilePath()); - final hostsFileString = await hostsFile.readAsString(); - final hostsFileLines = hostsFileString.split("\n"); - final newHostsFileLines = []; - - // copy Lines - for (var line in hostsFileLines) { - if (line.contains("#StarCitizenToolBox")) { - break; - } - newHostsFileLines.add(line); - } - dPrint("userHostsFile == $hostsFileString"); - for (var kv in ipsMap.entries) { - final domains = _hostsMap[kv.key] ?? []; - for (var domain in domains) { - if (kv.value != "") { - newHostsFileLines - .add("${kv.value} $domain #StarCitizenToolBox"); - } - } - } - await hostsFile.writeAsString(newHostsFileLines.join("\n"), flush: true); - } - - Future _readHostsState(ValueNotifier> workingMap, - ValueNotifier> checkedMap) async { - workingMap.value.clear(); - final hostsFile = File(SystemHelper.getHostsFilePath()); - final hostsFileString = await hostsFile.readAsString(); - final hostsFileLines = hostsFileString.split("\n"); - dPrint("userHostsFile == $hostsFileString"); - for (var line in hostsFileLines) { - if (line.contains("#StarCitizenToolBox")) { - for (var host in _hostsMap.entries) { - if (line.contains(" ${host.value.first}")) { - workingMap.value[host.key] = 1; - workingMap.value = Map.from(workingMap.value); - checkedMap.value[host.key] = true; - checkedMap.value = Map.from(checkedMap.value); - } - } - } - } - } -} diff --git a/lib/ui/tools/dialogs/rsi_launcher_enhance_dialog_ui.dart b/lib/ui/tools/dialogs/rsi_launcher_enhance_dialog_ui.dart deleted file mode 100644 index b350d3a..0000000 --- a/lib/ui/tools/dialogs/rsi_launcher_enhance_dialog_ui.dart +++ /dev/null @@ -1,482 +0,0 @@ -import 'dart:async'; -import 'dart:convert'; -import 'dart:io'; - -import 'package:archive/archive_io.dart'; -import 'package:fluent_ui/fluent_ui.dart'; -import 'package:flutter/foundation.dart'; -import 'package:flutter_hooks/flutter_hooks.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:starcitizen_doctor/api/analytics.dart'; -import 'package:starcitizen_doctor/app.dart'; -import 'package:starcitizen_doctor/common/conf/url_conf.dart'; -import 'package:starcitizen_doctor/common/helper/system_helper.dart'; -import 'package:starcitizen_doctor/common/io/rs_http.dart'; -import 'package:starcitizen_doctor/common/rust/api/asar_api.dart' as asar_api; -import 'package:starcitizen_doctor/common/utils/log.dart'; -import 'package:starcitizen_doctor/generated/no_l10n_strings.dart'; -import 'package:starcitizen_doctor/widgets/widgets.dart'; - -part 'rsi_launcher_enhance_dialog_ui.freezed.dart'; - -@freezed -class RSILauncherStateData with _$RSILauncherStateData { - const factory RSILauncherStateData({ - required String version, - required asar_api.RsiLauncherAsarData data, - required String serverData, - @Default(false) bool isPatchInstalled, - String? enabledLocalization, - bool? enableDownloaderBoost, - }) = _RSILauncherStateData; -} - -class RsiLauncherEnhanceDialogUI extends HookConsumerWidget { - final bool showNotGameInstallMsg; - - const RsiLauncherEnhanceDialogUI( - {super.key, this.showNotGameInstallMsg = false}); - - static const supportLocalizationMap = { - "en": NoL10n.langEn, - "zh_CN": NoL10n.langZHS, - "zh_TW": NoL10n.langZHT, - "fr": NoL10n.langFR, - }; - - @override - Widget build(BuildContext context, WidgetRef ref) { - final workingText = useState(""); - - final assarState = useState(null); - - final expandEnhance = useState(false); - - Future readState() async { - workingText.value = S.current.tools_rsi_launcher_enhance_init_msg1; - assarState.value = await _readState(context).unwrap(context: context); - if (assarState.value == null) { - workingText.value = ""; - return; - } - workingText.value = S.current.tools_rsi_launcher_enhance_init_msg2; - if (!context.mounted) return; - await _loadEnhanceData(context, ref, assarState) - .unwrap(context: context) - .unwrap(context: context); - workingText.value = ""; - } - - void doInstall() async { - if ((await SystemHelper.getPID("\"RSI Launcher\"")).isNotEmpty) { - if (!context.mounted) return; - showToast( - context, S.current.tools_action_info_rsi_launcher_running_warning, - constraints: BoxConstraints( - maxWidth: MediaQuery.of(context).size.width * .35)); - return; - } - if (!context.mounted) return; - workingText.value = S.current.tools_rsi_launcher_enhance_working_msg1; - final newScript = - await _genNewScript(assarState).unwrap(context: context); - workingText.value = S.current.tools_rsi_launcher_enhance_working_msg2; - if (!context.mounted) return; - await assarState.value?.data - .writeMainJs(content: utf8.encode(newScript)) - .unwrap(context: context); - AnalyticsApi.touch("rsi_launcher_mod_apply"); - await readState(); - } - - useEffect(() { - AnalyticsApi.touch("rsi_launcher_mod_launch"); - readState(); - return null; - }, const []); - - return ContentDialog( - constraints: - BoxConstraints(maxWidth: MediaQuery.of(context).size.width * .48), - title: Row(children: [ - IconButton( - icon: const Icon( - FluentIcons.back, - size: 22, - ), - onPressed: - workingText.value.isEmpty ? Navigator.of(context).pop : null), - const SizedBox(width: 12), - Text(S.current.tools_rsi_launcher_enhance_title), - ]), - content: AnimatedSize( - duration: const Duration(milliseconds: 130), - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - if (showNotGameInstallMsg) ...[ - InfoBar( - title: const SizedBox(), - content: Text(S.current - .home_localization_action_rsi_launcher_no_game_path_msg), - style: InfoBarThemeData(decoration: (severity) { - return BoxDecoration( - color: Colors.orange, - ); - }, iconColor: (severity) { - return Colors.white; - }), - ), - const SizedBox( - height: 12, - ), - ], - if (workingText.value.isNotEmpty) ...[ - Center( - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - const Row(), - const SizedBox(height: 12), - const ProgressRing(), - const SizedBox(height: 12), - Text(workingText.value), - const SizedBox(height: 12), - ], - ), - ), - ] else ...[ - Row( - children: [ - Expanded( - child: Text( - S.current.tools_rsi_launcher_enhance_msg_version( - assarState.value?.version ?? ""), - style: TextStyle( - color: Colors.white.withOpacity(.6), - ), - ), - ), - Text( - S.current.tools_rsi_launcher_enhance_msg_patch_status( - (assarState.value?.isPatchInstalled ?? false) - ? S.current.localization_info_installed - : S.current.tools_action_info_not_installed), - style: TextStyle( - color: Colors.white.withOpacity(.6), - ), - ) - ], - ), - if (assarState.value?.serverData.isEmpty ?? true) ...[ - Text(S.current.tools_rsi_launcher_enhance_msg_error), - ] else ...[ - const SizedBox(height: 24), - if (assarState.value?.enabledLocalization != null) - Container( - padding: const EdgeInsets.all(12), - margin: const EdgeInsets.only(bottom: 12), - decoration: BoxDecoration( - color: FluentTheme.of(context).cardColor, - borderRadius: BorderRadius.circular(12), - ), - child: Row( - children: [ - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text(S.current - .tools_rsi_launcher_enhance_title_localization), - const SizedBox(height: 3), - Text( - S.current - .tools_rsi_launcher_enhance_subtitle_localization, - style: TextStyle( - fontSize: 13, - color: Colors.white.withOpacity(.6), - ), - ), - ], - )), - ComboBox( - items: [ - for (final key in supportLocalizationMap.keys) - ComboBoxItem( - value: key, - child: Text(supportLocalizationMap[key]!)) - ], - value: assarState.value?.enabledLocalization, - onChanged: (v) { - assarState.value = assarState.value! - .copyWith(enabledLocalization: v); - }, - ), - ], - )), - const SizedBox(height: 3), - if (assarState.value?.enableDownloaderBoost != null) ...[ - IconButton( - icon: Padding( - padding: const EdgeInsets.only(top: 3, bottom: 3), - child: Row( - children: [ - Expanded( - child: Center( - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Icon(expandEnhance.value - ? FluentIcons.chevron_up - : FluentIcons.chevron_down), - const SizedBox(width: 12), - Text(expandEnhance.value - ? S.current - .tools_rsi_launcher_enhance_action_fold - : S.current - .tools_rsi_launcher_enhance_action_expand), - ], - ))), - ], - ), - ), - onPressed: () async { - if (!expandEnhance.value) { - final userOK = await showConfirmDialogs( - context, - S.current.tools_rsi_launcher_enhance_note_title, - Column( - mainAxisSize: MainAxisSize.min, - children: [ - Text(S.current - .tools_rsi_launcher_enhance_note_msg), - ], - ), - constraints: BoxConstraints( - maxWidth: - MediaQuery.of(context).size.width * .55)); - if (!userOK) return; - } - expandEnhance.value = !expandEnhance.value; - }, - ), - if (expandEnhance.value) - Container( - padding: const EdgeInsets.all(12), - margin: const EdgeInsets.only(bottom: 12), - decoration: BoxDecoration( - color: FluentTheme.of(context).cardColor, - borderRadius: BorderRadius.circular(12), - ), - child: Row(children: [ - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text(S.current - .tools_rsi_launcher_enhance_title_download_booster), - const SizedBox(height: 3), - Text( - S.current - .tools_rsi_launcher_enhance_subtitle_download_booster, - style: TextStyle( - fontSize: 13, - color: Colors.white.withOpacity(.6), - ), - ), - ], - )), - ToggleSwitch( - onChanged: (value) { - assarState.value = assarState.value - ?.copyWith(enableDownloaderBoost: value); - }, - checked: assarState.value?.enableDownloaderBoost ?? - false, - ) - ])), - ], - const SizedBox(height: 12), - Center( - child: FilledButton( - onPressed: doInstall, - child: Padding( - padding: const EdgeInsets.symmetric( - vertical: 4, horizontal: 6), - child: Text(S.current - .tools_rsi_launcher_enhance_action_install), - ))), - ], - const SizedBox(height: 16), - Text( - S.current.tools_rsi_launcher_enhance_msg_uninstall, - style: TextStyle( - color: Colors.white.withOpacity(.6), fontSize: 13), - ), - ], - ], - ), - ), - ); - } - - Future _readState(BuildContext context) async { - final lPath = await SystemHelper.getRSILauncherPath(skipEXE: true); - if (lPath.isEmpty) { - if (!context.mounted) return null; - showToast(context, - S.current.tools_rsi_launcher_enhance_msg_error_launcher_notfound); - return null; - } - dPrint("[RsiLauncherEnhanceDialogUI] rsiLauncherPath ==== $lPath"); - final dataPath = "${lPath}resources\\app.asar"; - dPrint("[RsiLauncherEnhanceDialogUI] rsiLauncherDataPath ==== $dataPath"); - try { - final data = await asar_api.getRsiLauncherAsarData(asarPath: dataPath); - dPrint( - "[RsiLauncherEnhanceDialogUI] rsiLauncherPath main.js path == ${data.mainJsPath}"); - final version = - RegExp(r"main\.(\w+)\.js").firstMatch(data.mainJsPath)?.group(1); - if (version == null) { - if (!context.mounted) return null; - showToast( - context, - S.current - .tools_rsi_launcher_enhance_msg_error_get_launcher_info_error); - return null; - } - dPrint( - "[RsiLauncherEnhanceDialogUI] rsiLauncherPath main.js version == $version"); - - final mainJsString = String.fromCharCodes(data.mainJsContent); - - final (enabledLocalization, enableDownloaderBoost) = - _readScriptState(mainJsString); - - return RSILauncherStateData( - version: version, - data: data, - serverData: "", - isPatchInstalled: mainJsString.contains("SC_TOOLBOX"), - enabledLocalization: enabledLocalization, - enableDownloaderBoost: enableDownloaderBoost, - ); - } catch (e) { - if (!context.mounted) return null; - showToast( - context, - S.current - .tools_rsi_launcher_enhance_msg_error_get_launcher_info_error_with_args( - e)); - return null; - } - } - - Future _loadEnhanceData(BuildContext context, WidgetRef ref, - ValueNotifier assarState) async { - final globalModel = ref.read(appGlobalModelProvider); - final enhancePath = - "${globalModel.applicationSupportDir}/launcher_enhance_data"; - final enhanceFile = - File("$enhancePath/${assarState.value?.version}.tar.gz"); - if (!await enhanceFile.exists()) { - final downloadUrl = - "${URLConf.gitApiRSILauncherEnhanceUrl}/archive/${assarState.value?.version}.tar.gz"; - final r = await RSHttp.get(downloadUrl).unwrap(); - if (r.statusCode != 200 || r.data == null) { - return ""; - } - await enhanceFile.create(recursive: true); - await enhanceFile.writeAsBytes(r.data!, flush: true); - } - final severMainJS = - await compute(_readArchive, (enhanceFile.path, "main.js")); - final serverMainJSString = severMainJS.toString(); - final scriptState = _readScriptState(serverMainJSString); - if (assarState.value?.enabledLocalization == null) { - assarState.value = - assarState.value?.copyWith(enabledLocalization: scriptState.$1); - dPrint( - "[RsiLauncherEnhanceDialogUI] _loadEnhanceData enabledLocalization == ${scriptState.$1}"); - } - if (assarState.value?.enableDownloaderBoost == null) { - assarState.value = - assarState.value?.copyWith(enableDownloaderBoost: scriptState.$2); - dPrint( - "[RsiLauncherEnhanceDialogUI] _loadEnhanceData enableDownloaderBoost == ${scriptState.$2}"); - } - assarState.value = - assarState.value?.copyWith(serverData: serverMainJSString); - return serverMainJSString; - } - - static StringBuffer _readArchive((String savePath, String fileName) data) { - final inputStream = InputFileStream(data.$1); - final archive = - TarDecoder().decodeBytes(GZipDecoder().decodeBuffer(inputStream)); - StringBuffer dataBuffer = StringBuffer(""); - for (var element in archive.files) { - if (element.name.endsWith(data.$2)) { - for (var value - in (element.rawContent?.readString() ?? "").split("\n")) { - final tv = value; - if (tv.isNotEmpty) dataBuffer.writeln(tv); - } - } - } - archive.clear(); - return dataBuffer; - } - - // ignore: constant_identifier_names - static const SC_TOOLBOX_ENABLED_LOCALIZATION_SCRIPT_START = - "const SC_TOOLBOX_ENABLED_LOCALIZATION = "; - - // ignore: constant_identifier_names - static const SC_TOOLBOX_ENABLE_DOWNLOADER_BOOST_SCRIPT_START = - "const SC_TOOLBOX_ENABLE_DOWNLOADER_BOOST = "; - - (String?, bool?) _readScriptState(String mainJsString) { - String? enabledLocalization; - bool? enableDownloaderBoost; - for (final line in mainJsString.split("\n")) { - final lineTrim = line.trim(); - if (lineTrim.startsWith(SC_TOOLBOX_ENABLED_LOCALIZATION_SCRIPT_START)) { - enabledLocalization = lineTrim - .substring(SC_TOOLBOX_ENABLED_LOCALIZATION_SCRIPT_START.length) - .replaceAll("\"", "") - .replaceAll(";", ""); - } else if (lineTrim - .startsWith(SC_TOOLBOX_ENABLE_DOWNLOADER_BOOST_SCRIPT_START)) { - enableDownloaderBoost = lineTrim - .substring( - SC_TOOLBOX_ENABLE_DOWNLOADER_BOOST_SCRIPT_START.length) - .toLowerCase() == - "true;"; - } - } - return (enabledLocalization, enableDownloaderBoost); - } - - Future _genNewScript( - ValueNotifier assarState) async { - final serverScriptLines = assarState.value!.serverData.split("\n"); - final StringBuffer scriptBuffer = StringBuffer(""); - for (final line in serverScriptLines) { - final lineTrim = line.trim(); - if (lineTrim.startsWith(SC_TOOLBOX_ENABLED_LOCALIZATION_SCRIPT_START)) { - scriptBuffer.writeln( - "$SC_TOOLBOX_ENABLED_LOCALIZATION_SCRIPT_START\"${assarState.value!.enabledLocalization}\";"); - } else if (lineTrim - .startsWith(SC_TOOLBOX_ENABLE_DOWNLOADER_BOOST_SCRIPT_START)) { - scriptBuffer.writeln( - "$SC_TOOLBOX_ENABLE_DOWNLOADER_BOOST_SCRIPT_START${assarState.value!.enableDownloaderBoost};"); - } else { - scriptBuffer.writeln(line); - } - } - return scriptBuffer.toString(); - } -} diff --git a/lib/ui/tools/dialogs/rsi_launcher_enhance_dialog_ui.freezed.dart b/lib/ui/tools/dialogs/rsi_launcher_enhance_dialog_ui.freezed.dart deleted file mode 100644 index b3016ad..0000000 --- a/lib/ui/tools/dialogs/rsi_launcher_enhance_dialog_ui.freezed.dart +++ /dev/null @@ -1,256 +0,0 @@ -// coverage:ignore-file -// GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark - -part of 'rsi_launcher_enhance_dialog_ui.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -T _$identity(T value) => value; - -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); - -/// @nodoc -mixin _$RSILauncherStateData { - String get version => throw _privateConstructorUsedError; - asar_api.RsiLauncherAsarData get data => throw _privateConstructorUsedError; - String get serverData => throw _privateConstructorUsedError; - bool get isPatchInstalled => throw _privateConstructorUsedError; - String? get enabledLocalization => throw _privateConstructorUsedError; - bool? get enableDownloaderBoost => throw _privateConstructorUsedError; - - /// Create a copy of RSILauncherStateData - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $RSILauncherStateDataCopyWith get copyWith => - throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $RSILauncherStateDataCopyWith<$Res> { - factory $RSILauncherStateDataCopyWith(RSILauncherStateData value, - $Res Function(RSILauncherStateData) then) = - _$RSILauncherStateDataCopyWithImpl<$Res, RSILauncherStateData>; - @useResult - $Res call( - {String version, - asar_api.RsiLauncherAsarData data, - String serverData, - bool isPatchInstalled, - String? enabledLocalization, - bool? enableDownloaderBoost}); -} - -/// @nodoc -class _$RSILauncherStateDataCopyWithImpl<$Res, - $Val extends RSILauncherStateData> - implements $RSILauncherStateDataCopyWith<$Res> { - _$RSILauncherStateDataCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of RSILauncherStateData - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? version = null, - Object? data = null, - Object? serverData = null, - Object? isPatchInstalled = null, - Object? enabledLocalization = freezed, - Object? enableDownloaderBoost = freezed, - }) { - return _then(_value.copyWith( - version: null == version - ? _value.version - : version // ignore: cast_nullable_to_non_nullable - as String, - data: null == data - ? _value.data - : data // ignore: cast_nullable_to_non_nullable - as asar_api.RsiLauncherAsarData, - serverData: null == serverData - ? _value.serverData - : serverData // ignore: cast_nullable_to_non_nullable - as String, - isPatchInstalled: null == isPatchInstalled - ? _value.isPatchInstalled - : isPatchInstalled // ignore: cast_nullable_to_non_nullable - as bool, - enabledLocalization: freezed == enabledLocalization - ? _value.enabledLocalization - : enabledLocalization // ignore: cast_nullable_to_non_nullable - as String?, - enableDownloaderBoost: freezed == enableDownloaderBoost - ? _value.enableDownloaderBoost - : enableDownloaderBoost // ignore: cast_nullable_to_non_nullable - as bool?, - ) as $Val); - } -} - -/// @nodoc -abstract class _$$RSILauncherStateDataImplCopyWith<$Res> - implements $RSILauncherStateDataCopyWith<$Res> { - factory _$$RSILauncherStateDataImplCopyWith(_$RSILauncherStateDataImpl value, - $Res Function(_$RSILauncherStateDataImpl) then) = - __$$RSILauncherStateDataImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {String version, - asar_api.RsiLauncherAsarData data, - String serverData, - bool isPatchInstalled, - String? enabledLocalization, - bool? enableDownloaderBoost}); -} - -/// @nodoc -class __$$RSILauncherStateDataImplCopyWithImpl<$Res> - extends _$RSILauncherStateDataCopyWithImpl<$Res, _$RSILauncherStateDataImpl> - implements _$$RSILauncherStateDataImplCopyWith<$Res> { - __$$RSILauncherStateDataImplCopyWithImpl(_$RSILauncherStateDataImpl _value, - $Res Function(_$RSILauncherStateDataImpl) _then) - : super(_value, _then); - - /// Create a copy of RSILauncherStateData - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? version = null, - Object? data = null, - Object? serverData = null, - Object? isPatchInstalled = null, - Object? enabledLocalization = freezed, - Object? enableDownloaderBoost = freezed, - }) { - return _then(_$RSILauncherStateDataImpl( - version: null == version - ? _value.version - : version // ignore: cast_nullable_to_non_nullable - as String, - data: null == data - ? _value.data - : data // ignore: cast_nullable_to_non_nullable - as asar_api.RsiLauncherAsarData, - serverData: null == serverData - ? _value.serverData - : serverData // ignore: cast_nullable_to_non_nullable - as String, - isPatchInstalled: null == isPatchInstalled - ? _value.isPatchInstalled - : isPatchInstalled // ignore: cast_nullable_to_non_nullable - as bool, - enabledLocalization: freezed == enabledLocalization - ? _value.enabledLocalization - : enabledLocalization // ignore: cast_nullable_to_non_nullable - as String?, - enableDownloaderBoost: freezed == enableDownloaderBoost - ? _value.enableDownloaderBoost - : enableDownloaderBoost // ignore: cast_nullable_to_non_nullable - as bool?, - )); - } -} - -/// @nodoc - -class _$RSILauncherStateDataImpl implements _RSILauncherStateData { - const _$RSILauncherStateDataImpl( - {required this.version, - required this.data, - required this.serverData, - this.isPatchInstalled = false, - this.enabledLocalization, - this.enableDownloaderBoost}); - - @override - final String version; - @override - final asar_api.RsiLauncherAsarData data; - @override - final String serverData; - @override - @JsonKey() - final bool isPatchInstalled; - @override - final String? enabledLocalization; - @override - final bool? enableDownloaderBoost; - - @override - String toString() { - return 'RSILauncherStateData(version: $version, data: $data, serverData: $serverData, isPatchInstalled: $isPatchInstalled, enabledLocalization: $enabledLocalization, enableDownloaderBoost: $enableDownloaderBoost)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$RSILauncherStateDataImpl && - (identical(other.version, version) || other.version == version) && - (identical(other.data, data) || other.data == data) && - (identical(other.serverData, serverData) || - other.serverData == serverData) && - (identical(other.isPatchInstalled, isPatchInstalled) || - other.isPatchInstalled == isPatchInstalled) && - (identical(other.enabledLocalization, enabledLocalization) || - other.enabledLocalization == enabledLocalization) && - (identical(other.enableDownloaderBoost, enableDownloaderBoost) || - other.enableDownloaderBoost == enableDownloaderBoost)); - } - - @override - int get hashCode => Object.hash(runtimeType, version, data, serverData, - isPatchInstalled, enabledLocalization, enableDownloaderBoost); - - /// Create a copy of RSILauncherStateData - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$RSILauncherStateDataImplCopyWith<_$RSILauncherStateDataImpl> - get copyWith => - __$$RSILauncherStateDataImplCopyWithImpl<_$RSILauncherStateDataImpl>( - this, _$identity); -} - -abstract class _RSILauncherStateData implements RSILauncherStateData { - const factory _RSILauncherStateData( - {required final String version, - required final asar_api.RsiLauncherAsarData data, - required final String serverData, - final bool isPatchInstalled, - final String? enabledLocalization, - final bool? enableDownloaderBoost}) = _$RSILauncherStateDataImpl; - - @override - String get version; - @override - asar_api.RsiLauncherAsarData get data; - @override - String get serverData; - @override - bool get isPatchInstalled; - @override - String? get enabledLocalization; - @override - bool? get enableDownloaderBoost; - - /// Create a copy of RSILauncherStateData - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$RSILauncherStateDataImplCopyWith<_$RSILauncherStateDataImpl> - get copyWith => throw _privateConstructorUsedError; -} diff --git a/lib/ui/tools/tools_ui.dart b/lib/ui/tools/tools_ui.dart deleted file mode 100644 index a69ab1b..0000000 --- a/lib/ui/tools/tools_ui.dart +++ /dev/null @@ -1,265 +0,0 @@ -import 'package:fluent_ui/fluent_ui.dart'; -import 'package:flutter_hooks/flutter_hooks.dart'; -import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; -import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:starcitizen_doctor/ui/tools/tools_ui_model.dart'; -import 'package:starcitizen_doctor/widgets/widgets.dart'; - -class ToolsUI extends HookConsumerWidget { - const ToolsUI({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(toolsUIModelProvider); - final model = ref.read(toolsUIModelProvider.notifier); - - useEffect(() { - addPostFrameCallback(() { - model.loadToolsCard(context, skipPathScan: false); - }); - return null; - }, []); - - return Stack( - children: [ - Column( - children: [ - const SizedBox(height: 12), - Padding( - padding: const EdgeInsets.only(left: 22, right: 22), - child: Row( - children: [ - Expanded( - child: Column( - children: [ - makeGameLauncherPathSelect(context, model, state), - const SizedBox(height: 12), - makeGamePathSelect(context, model, state), - ], - ), - ), - const SizedBox(width: 12), - Button( - onPressed: state.working - ? null - : () => - model.loadToolsCard(context, skipPathScan: false), - child: const Padding( - padding: EdgeInsets.only( - top: 30, bottom: 30, left: 12, right: 12), - child: Icon(FluentIcons.refresh), - ), - ), - ], - ), - ), - const SizedBox(height: 12), - if (state.items.isEmpty) - Expanded( - child: Center( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - const ProgressRing(), - const SizedBox(height: 12), - Text(S.current.tools_info_scanning), - ], - ), - ), - ) - else - Expanded( - child: SingleChildScrollView( - padding: const EdgeInsets.all(16), - child: MasonryGridView.count( - crossAxisCount: 3, - mainAxisSpacing: 12, - crossAxisSpacing: 12, - itemCount: (state.isItemLoading) - ? state.items.length + 1 - : state.items.length, - shrinkWrap: true, - itemBuilder: (context, index) { - if (index == state.items.length) { - return Container( - width: 300, - height: 200, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(12), - color: FluentTheme.of(context).cardColor, - ), - child: makeLoading(context)); - } - final item = state.items[index]; - return Container( - width: 300, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(12), - color: FluentTheme.of(context).cardColor, - ), - child: Padding( - padding: const EdgeInsets.all(12), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Container( - decoration: BoxDecoration( - color: Colors.white.withOpacity(.2), - borderRadius: - BorderRadius.circular(1000)), - child: Padding( - padding: const EdgeInsets.all(12), - child: item.icon, - ), - ), - const SizedBox(width: 8), - Expanded( - child: Text( - item.name, - style: const TextStyle(fontSize: 16), - )), - const SizedBox(width: 12), - ], - ), - const SizedBox(height: 12), - Text( - item.infoString, - style: TextStyle( - fontSize: 14, - color: Colors.white.withOpacity(.6)), - ), - const SizedBox(height: 12), - Row( - children: [ - const Spacer(), - Button( - onPressed: state.working - ? null - : item.onTap == null - ? null - : () { - try { - item.onTap?.call(); - } catch (e) { - showToast( - context, - S.current - .tools_info_processing_failed( - e)); - } - }, - child: const Padding( - padding: EdgeInsets.all(6), - child: Icon(FluentIcons.play), - ), - ), - ], - ) - ], - ), - ), - ); - }, - ), - ), - ) - ], - ), - if (state.working) - Container( - decoration: BoxDecoration( - color: Colors.black.withAlpha(150), - ), - child: Center( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - const ProgressRing(), - const SizedBox(height: 12), - Text(S.current.doctor_info_processing), - ], - ), - ), - ) - ], - ); - } - - Widget makeGamePathSelect( - BuildContext context, ToolsUIModel model, ToolsUIState state) { - return Row( - mainAxisSize: MainAxisSize.min, - children: [ - Text(S.current.tools_info_game_install_location), - const SizedBox(width: 6), - Expanded( - child: SizedBox( - height: 36, - child: ComboBox( - isExpanded: true, - value: state.scInstalledPath, - items: [ - for (final path in state.scInstallPaths) - ComboBoxItem( - value: path, - child: Text(path), - ) - ], - onChanged: (v) { - model.loadToolsCard(context, skipPathScan: true); - model.onChangeGamePath(v!); - }, - ), - ), - ), - const SizedBox(width: 8), - Button( - child: const Padding( - padding: EdgeInsets.all(6), - child: Icon(FluentIcons.folder_open), - ), - onPressed: () => model.openDir(state.scInstalledPath)) - ], - ); - } - - Widget makeGameLauncherPathSelect( - BuildContext context, ToolsUIModel model, ToolsUIState state) { - return Row( - mainAxisSize: MainAxisSize.min, - children: [ - Text(S.current.tools_info_rsi_launcher_location), - const SizedBox(width: 6), - Expanded( - child: SizedBox( - height: 36, - child: ComboBox( - isExpanded: true, - value: state.rsiLauncherInstalledPath, - items: [ - for (final path in state.rsiLauncherInstallPaths) - ComboBoxItem( - value: path, - child: Text(path), - ) - ], - onChanged: (v) { - model.loadToolsCard(context, skipPathScan: true); - model.onChangeLauncherPath(v!); - }, - ), - ), - ), - const SizedBox(width: 8), - Button( - child: const Padding( - padding: EdgeInsets.all(6), - child: Icon(FluentIcons.folder_open), - ), - onPressed: () => model.openDir(state.rsiLauncherInstalledPath)) - ], - ); - } -} diff --git a/lib/ui/tools/tools_ui_model.dart b/lib/ui/tools/tools_ui_model.dart deleted file mode 100644 index 8b40709..0000000 --- a/lib/ui/tools/tools_ui_model.dart +++ /dev/null @@ -1,613 +0,0 @@ -// ignore_for_file: avoid_build_context_in_providers -import 'dart:convert'; -import 'dart:io'; - -import 'package:file_picker/file_picker.dart'; -import 'package:fluent_ui/fluent_ui.dart'; -import 'package:flutter/foundation.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:go_router/go_router.dart'; -import 'package:riverpod_annotation/riverpod_annotation.dart'; -import 'package:starcitizen_doctor/api/analytics.dart'; -import 'package:starcitizen_doctor/api/api.dart'; -import 'package:starcitizen_doctor/common/helper/log_helper.dart'; -import 'package:starcitizen_doctor/common/helper/system_helper.dart'; -import 'package:starcitizen_doctor/common/io/rs_http.dart'; -import 'package:starcitizen_doctor/common/utils/log.dart'; -import 'package:starcitizen_doctor/common/utils/provider.dart'; -import 'package:starcitizen_doctor/provider/aria2c.dart'; -import 'package:starcitizen_doctor/ui/home/downloader/home_downloader_ui_model.dart'; -import 'package:starcitizen_doctor/widgets/widgets.dart'; -import 'package:url_launcher/url_launcher_string.dart'; -import 'package:xml/xml.dart'; - -import 'dialogs/hosts_booster_dialog_ui.dart'; -import 'dialogs/rsi_launcher_enhance_dialog_ui.dart'; - -part 'tools_ui_model.g.dart'; - -part 'tools_ui_model.freezed.dart'; - -class ToolsItemData { - String key; - - ToolsItemData(this.key, this.name, this.infoString, this.icon, {this.onTap}); - - String name; - String infoString; - Widget icon; - AsyncCallback? onTap; -} - -@freezed -class ToolsUIState with _$ToolsUIState { - factory ToolsUIState({ - @Default(false) bool working, - @Default("") String scInstalledPath, - @Default("") String rsiLauncherInstalledPath, - @Default([]) List scInstallPaths, - @Default([]) List rsiLauncherInstallPaths, - @Default([]) List items, - @Default(false) bool isItemLoading, - }) = _ToolsUIState; -} - -@riverpod -class ToolsUIModel extends _$ToolsUIModel { - @override - ToolsUIState build() { - state = ToolsUIState(); - return state; - } - - loadToolsCard(BuildContext context, {bool skipPathScan = false}) async { - if (state.isItemLoading) return; - var items = []; - state = state.copyWith(items: items, isItemLoading: true); - if (!skipPathScan) { - await reScanPath(context); - } - try { - items = [ - ToolsItemData( - "systemnfo", - S.current.tools_action_view_system_info, - S.current.tools_action_info_view_critical_system_info, - const Icon(FluentIcons.system, size: 24), - onTap: () => _showSystemInfo(context), - ), - ToolsItemData( - "p4k_downloader", - S.current.tools_action_p4k_download_repair, - S.current.tools_action_info_p4k_download_repair_tip, - const Icon(FontAwesomeIcons.download, size: 24), - onTap: () => _downloadP4k(context), - ), - ToolsItemData( - "hosts_booster", - S.current.tools_action_hosts_acceleration_experimental, - S.current.tools_action_info_hosts_acceleration_experimental_tip, - const Icon(FluentIcons.virtual_network, size: 24), - onTap: () => _doHostsBooster(context), - ), - ToolsItemData( - "rsilauncher_enhance_mod", - S.current.tools_rsi_launcher_enhance_title, - S.current.tools_action_rsi_launcher_enhance_info, - const Icon(FluentIcons.c_plus_plus, size: 24), - onTap: () => rsiEnhance(context), - ), - ToolsItemData( - "reinstall_eac", - S.current.tools_action_reinstall_easyanticheat, - S.current.tools_action_info_reinstall_eac, - const Icon(FluentIcons.game, size: 24), - onTap: () => _reinstallEAC(context), - ), - ToolsItemData( - "rsilauncher_admin_mode", - S.current.tools_action_rsi_launcher_admin_mode, - S.current.tools_action_info_run_rsi_as_admin, - const Icon(FluentIcons.admin, size: 24), - onTap: () => _adminRSILauncher(context), - ), - ToolsItemData( - "unp4kc", - S.current.tools_action_unp4k, - S.current.tools_action_unp4k_info, - const Icon(FontAwesomeIcons.fileZipper, size: 24), - onTap: () => _unp4kc(context), - ), - ]; - - state = state.copyWith(items: items); - if (!context.mounted) return; - items.add(await _addShaderCard(context)); - state = state.copyWith(items: items); - if (!context.mounted) return; - items.add(await _addPhotographyCard(context)); - state = state.copyWith(items: items); - if (!context.mounted) return; - items.addAll(await _addLogCard(context)); - state = state.copyWith(items: items); - if (!context.mounted) return; - items.addAll(await _addNvmePatchCard(context)); - state = state.copyWith(items: items, isItemLoading: false); - } catch (e) { - if (!context.mounted) return; - showToast(context, S.current.tools_action_info_init_failed(e)); - } - } - - Future> _addLogCard(BuildContext context) async { - double logPathLen = 0; - try { - logPathLen = - (await File(await SCLoggerHelper.getLogFilePath() ?? "").length()) / - 1024 / - 1024; - } catch (_) {} - return [ - ToolsItemData( - "rsilauncher_log_fix", - S.current.tools_action_rsi_launcher_log_fix, - S.current.tools_action_info_rsi_launcher_log_issue( - logPathLen.toStringAsFixed(4)), - const Icon(FontAwesomeIcons.bookBible, size: 24), - onTap: () => _rsiLogFix(context), - ), - ]; - } - - Future> _addNvmePatchCard(BuildContext context) async { - final nvmePatchStatus = await SystemHelper.checkNvmePatchStatus(); - return [ - if (nvmePatchStatus) - ToolsItemData( - "remove_nvme_settings", - S.current.tools_action_remove_nvme_registry_patch, - S.current.tools_action_info_nvme_patch_issue(nvmePatchStatus - ? S.current.localization_info_installed - : S.current.tools_action_info_not_installed), - const Icon(FluentIcons.hard_drive, size: 24), - onTap: nvmePatchStatus - ? () async { - state = state.copyWith(working: true); - await SystemHelper.doRemoveNvmePath(); - state = state.copyWith(working: false); - if (!context.mounted) return; - showToast(context, - S.current.tools_action_info_removed_restart_effective); - loadToolsCard(context, skipPathScan: true); - } - : null, - ), - if (!nvmePatchStatus) - ToolsItemData( - "add_nvme_settings", - S.current.tools_action_write_nvme_registry_patch, - S.current.tools_action_info_manual_nvme_patch, - const Icon(FontAwesomeIcons.cashRegister, size: 24), - onTap: () async { - state = state.copyWith(working: true); - final r = await SystemHelper.addNvmePatch(); - if (r == "") { - if (!context.mounted) return; - showToast( - context, S.current.tools_action_info_fix_success_restart); - } else { - if (!context.mounted) return; - showToast(context, S.current.doctor_action_result_fix_fail(r)); - } - state = state.copyWith(working: false); - loadToolsCard(context, skipPathScan: true); - }, - ) - ]; - } - - Future _addShaderCard(BuildContext context) async { - final gameShaderCachePath = await SCLoggerHelper.getShaderCachePath(); - final shaderSize = ((await SystemHelper.getDirLen(gameShaderCachePath ?? "", - skipPath: ["$gameShaderCachePath\\Crashes"])) / - 1024 / - 1024) - .toStringAsFixed(4); - return ToolsItemData( - "clean_shaders", - S.current.tools_action_clear_shader_cache, - S.current.tools_action_info_shader_cache_issue(shaderSize), - const Icon(FontAwesomeIcons.shapes, size: 24), - onTap: () => _cleanShaderCache(context), - ); - } - - Future _addPhotographyCard(BuildContext context) async { - // 获取配置文件状态 - final isEnable = await _checkPhotographyStatus(context); - - return ToolsItemData( - "photography_mode", - isEnable - ? S.current.tools_action_close_photography_mode - : S.current.tools_action_open_photography_mode, - isEnable - ? S.current.tools_action_info_restore_lens_shake - : S.current.tools_action_info_one_key_close_lens_shake, - const Icon(FontAwesomeIcons.camera, size: 24), - onTap: () => _onChangePhotographyMode(context, isEnable), - ); - } - - /// ---------------------------- func ------------------------------------------------------- - /// ----------------------------------------------------------------------------------------- - /// ----------------------------------------------------------------------------------------- - /// ----------------------------------------------------------------------------------------- - - Future reScanPath(BuildContext context) async { - var scInstallPaths = []; - var rsiLauncherInstallPaths = []; - var scInstalledPath = ""; - var rsiLauncherInstalledPath = ""; - - state = state.copyWith( - scInstalledPath: scInstalledPath, - rsiLauncherInstalledPath: rsiLauncherInstalledPath, - scInstallPaths: scInstallPaths, - rsiLauncherInstallPaths: rsiLauncherInstallPaths, - ); - - try { - rsiLauncherInstalledPath = await SystemHelper.getRSILauncherPath(); - rsiLauncherInstallPaths.add(rsiLauncherInstalledPath); - final listData = await SCLoggerHelper.getLauncherLogList(); - if (listData == null) { - return; - } - scInstallPaths = await SCLoggerHelper.getGameInstallPath(listData, - checkExists: false, withVersion: ["LIVE", "PTU", "EPTU"]); - if (scInstallPaths.isNotEmpty) { - scInstalledPath = scInstallPaths.first; - } - state = state.copyWith( - scInstalledPath: scInstalledPath, - rsiLauncherInstalledPath: rsiLauncherInstalledPath, - scInstallPaths: scInstallPaths, - rsiLauncherInstallPaths: rsiLauncherInstallPaths, - ); - } catch (e) { - dPrint(e); - if (!context.mounted) return; - showToast(context, S.current.tools_action_info_log_file_parse_failed); - } - - if (rsiLauncherInstalledPath == "") { - if (!context.mounted) return; - showToast(context, S.current.tools_action_info_rsi_launcher_not_found); - } - if (scInstalledPath == "") { - if (!context.mounted) return; - showToast(context, S.current.tools_action_info_star_citizen_not_found); - } - } - - /// 重装EAC - Future _reinstallEAC(BuildContext context) async { - if (state.scInstalledPath.isEmpty) { - showToast( - context, S.current.tools_action_info_valid_game_directory_needed); - return; - } - state = state.copyWith(working: true); - try { - final eacPath = "${state.scInstalledPath}\\EasyAntiCheat"; - final eacJsonPath = "$eacPath\\Settings.json"; - if (await File(eacJsonPath).exists()) { - Map envVars = Platform.environment; - final eacJsonData = await File(eacJsonPath).readAsString(); - final Map eacJson = json.decode(eacJsonData); - final eacID = eacJson["productid"]; - if (eacID != null) { - final eacCacheDir = - Directory("${envVars["appdata"]}\\EasyAntiCheat\\$eacID"); - if (await eacCacheDir.exists()) { - await eacCacheDir.delete(recursive: true); - } - } - } - final dir = Directory(eacPath); - if (await dir.exists()) { - await dir.delete(recursive: true); - } - final eacLauncher = - File("${state.scInstalledPath}\\StarCitizen_Launcher.exe"); - if (await eacLauncher.exists()) { - await eacLauncher.delete(recursive: true); - } - if (!context.mounted) return; - showToast(context, S.current.tools_action_info_eac_file_removed); - _adminRSILauncher(context); - } catch (e) { - showToast(context, S.current.tools_action_info_error_occurred(e)); - } - state = state.copyWith(working: false); - loadToolsCard(context, skipPathScan: true); - } - - Future getSystemInfo() async { - return S.current.tools_action_info_system_info_content( - await SystemHelper.getSystemName(), - await SystemHelper.getCpuName(), - await SystemHelper.getSystemMemorySizeGB(), - await SystemHelper.getGpuInfo(), - await SystemHelper.getDiskInfo()); - } - - /// 管理员模式运行 RSI 启动器 - Future _adminRSILauncher(BuildContext context) async { - if (state.rsiLauncherInstalledPath == "") { - showToast(context, - S.current.tools_action_info_rsi_launcher_directory_not_found); - } - SystemHelper.checkAndLaunchRSILauncher(state.rsiLauncherInstalledPath); - } - - Future _rsiLogFix(BuildContext context) async { - state = state.copyWith(working: true); - final path = await SCLoggerHelper.getLogFilePath(); - if (!await File(path!).exists()) { - if (!context.mounted) return; - showToast(context, S.current.tools_action_info_log_file_not_exist); - return; - } - try { - SystemHelper.killRSILauncher(); - await File(path).delete(recursive: true); - if (!context.mounted) return; - showToast(context, S.current.tools_action_info_cleanup_complete); - SystemHelper.checkAndLaunchRSILauncher(state.rsiLauncherInstalledPath); - } catch (_) { - if (!context.mounted) return; - showToast(context, S.current.tools_action_info_cleanup_failed(path)); - } - - state = state.copyWith(working: false); - } - - openDir(path) async { - SystemHelper.openDir(path); - } - - Future _showSystemInfo(BuildContext context) async { - state = state.copyWith(working: true); - final systemInfo = await getSystemInfo(); - if (!context.mounted) return; - showDialog( - context: context, - builder: (context) => ContentDialog( - title: Text(S.current.tools_action_info_system_info_title), - content: Text(systemInfo), - constraints: BoxConstraints( - maxWidth: MediaQuery.of(context).size.width * .65, - ), - actions: [ - FilledButton( - child: Padding( - padding: - const EdgeInsets.only(top: 2, bottom: 2, left: 8, right: 8), - child: Text(S.current.action_close), - ), - onPressed: () => Navigator.pop(context), - ), - ], - ), - ); - state = state.copyWith(working: false); - } - - Future _cleanShaderCache(BuildContext context) async { - state = state.copyWith(working: true); - final gameShaderCachePath = await SCLoggerHelper.getShaderCachePath(); - final l = - await Directory(gameShaderCachePath!).list(recursive: false).toList(); - for (var value in l) { - if (value is Directory) { - if (!value.absolute.path.contains("Crashes")) { - await value.delete(recursive: true); - } - } - } - if (!context.mounted) return; - loadToolsCard(context, skipPathScan: true); - state = state.copyWith(working: false); - } - - Future _downloadP4k(BuildContext context) async { - String savePath = state.scInstalledPath; - String fileName = "Data.p4k"; - - if ((await SystemHelper.getPID("\"RSI Launcher\"")).isNotEmpty) { - if (!context.mounted) return; - showToast( - context, S.current.tools_action_info_rsi_launcher_running_warning, - constraints: BoxConstraints( - maxWidth: MediaQuery.of(context).size.width * .35)); - return; - } - - if (!context.mounted) return; - await showToast(context, S.current.tools_action_info_p4k_file_description); - try { - state = state.copyWith(working: true); - final aria2cManager = ref.read(aria2cModelProvider.notifier); - await aria2cManager - .launchDaemon(appGlobalState.applicationBinaryModuleDir!); - final aria2c = ref.read(aria2cModelProvider).aria2c!; - - // check download task list - for (var value in [ - ...await aria2c.tellActive(), - ...await aria2c.tellWaiting(0, 100000) - ]) { - final t = HomeDownloaderUIModel.getTaskTypeAndName(value); - if (t.key == "torrent" && t.value.contains("Data.p4k")) { - if (!context.mounted) return; - showToast( - context, S.current.tools_action_info_p4k_download_in_progress); - state = state.copyWith(working: false); - return; - } - } - - var torrentUrl = ""; - final l = await Api.getAppTorrentDataList(); - for (var torrent in l) { - if (torrent.name == "Data.p4k") { - torrentUrl = torrent.url!; - } - } - if (torrentUrl == "") { - state = state.copyWith(working: false); - if (!context.mounted) return; - showToast( - context, S.current.tools_action_info_function_under_maintenance); - return; - } - - final userSelect = await FilePicker.platform.saveFile( - initialDirectory: savePath, - fileName: fileName, - lockParentWindow: true); - if (userSelect == null) { - state = state.copyWith(working: false); - return; - } - - savePath = userSelect; - dPrint(savePath); - - if (savePath.endsWith("\\$fileName")) { - savePath = savePath.substring(0, savePath.length - fileName.length - 1); - } - - if (!context.mounted) return; - final btData = await RSHttp.get(torrentUrl).unwrap(context: context); - if (btData == null || btData.data == null) { - state = state.copyWith(working: false); - return; - } - final b64Str = base64Encode(btData.data!); - - final gid = - await aria2c.addTorrent(b64Str, extraParams: {"dir": savePath}); - state = state.copyWith(working: false); - dPrint("Aria2cManager.aria2c.addUri resp === $gid"); - await aria2c.saveSession(); - AnalyticsApi.touch("p4k_download"); - if (!context.mounted) return; - context.push("/index/downloader"); - } catch (e) { - state = state.copyWith(working: false); - if (!context.mounted) return; - showToast(context, S.current.app_init_failed_with_reason(e)); - } - await Future.delayed(const Duration(seconds: 3)); - launchUrlString( - "https://citizenwiki.cn/SC%E6%B1%89%E5%8C%96%E7%9B%92%E5%AD%90#%E5%88%86%E6%B5%81%E4%B8%8B%E8%BD%BD%E6%95%99%E7%A8%8B"); - } - - Future _checkPhotographyStatus(BuildContext context, - {bool? setMode}) async { - final scInstalledPath = state.scInstalledPath; - final keys = ["AudioShakeStrength", "CameraSpringMovement", "ShakeScale"]; - final attributesFile = File( - "$scInstalledPath\\USER\\Client\\0\\Profiles\\default\\attributes.xml"); - if (setMode == null) { - bool isEnable = false; - if (scInstalledPath.isNotEmpty) { - if (await attributesFile.exists()) { - final xmlFile = - XmlDocument.parse(await attributesFile.readAsString()); - isEnable = true; - for (var k in keys) { - if (!isEnable) break; - final e = xmlFile.rootElement.children - .where((element) => element.getAttribute("name") == k) - .firstOrNull; - if (e != null && e.getAttribute("value") == "0") { - } else { - isEnable = false; - } - } - } - } - return isEnable; - } else { - if (!await attributesFile.exists()) { - if (!context.mounted) return false; - showToast(context, S.current.tools_action_info_config_file_not_exist); - return false; - } - final xmlFile = XmlDocument.parse(await attributesFile.readAsString()); - // clear all - xmlFile.rootElement.children.removeWhere( - (element) => keys.contains(element.getAttribute("name"))); - if (setMode) { - for (var element in keys) { - XmlElement newNode = XmlElement(XmlName('Attr'), [ - XmlAttribute(XmlName('name'), element), - XmlAttribute(XmlName('value'), '0'), - ]); - xmlFile.rootElement.children.add(newNode); - } - } - dPrint(xmlFile); - await attributesFile.delete(); - await attributesFile.writeAsString(xmlFile.toXmlString(pretty: true)); - } - return true; - } - - _onChangePhotographyMode(BuildContext context, bool isEnable) async { - _checkPhotographyStatus(context, setMode: !isEnable) - .unwrap(context: context); - loadToolsCard(context, skipPathScan: true); - } - - void onChangeGamePath(String v) { - state = state.copyWith(scInstalledPath: v); - } - - void onChangeLauncherPath(String s) { - state = state.copyWith(rsiLauncherInstalledPath: s); - } - - _doHostsBooster(BuildContext context) async { - showDialog( - context: context, - builder: (BuildContext context) => const HostsBoosterDialogUI()); - } - - _unp4kc(BuildContext context) async { - context.push("/tools/unp4kc"); - } - - static rsiEnhance(BuildContext context, - {bool showNotGameInstallMsg = false}) async { - if ((await SystemHelper.getPID("\"RSI Launcher\"")).isNotEmpty) { - if (!context.mounted) return; - showToast( - context, S.current.tools_action_info_rsi_launcher_running_warning, - constraints: BoxConstraints( - maxWidth: MediaQuery.of(context).size.width * .35)); - return; - } - if (!context.mounted) return; - showDialog( - context: context, - builder: (BuildContext context) => RsiLauncherEnhanceDialogUI( - showNotGameInstallMsg: showNotGameInstallMsg, - )); - } -} diff --git a/lib/ui/tools/tools_ui_model.freezed.dart b/lib/ui/tools/tools_ui_model.freezed.dart deleted file mode 100644 index 7b0d934..0000000 --- a/lib/ui/tools/tools_ui_model.freezed.dart +++ /dev/null @@ -1,311 +0,0 @@ -// coverage:ignore-file -// GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark - -part of 'tools_ui_model.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -T _$identity(T value) => value; - -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); - -/// @nodoc -mixin _$ToolsUIState { - bool get working => throw _privateConstructorUsedError; - String get scInstalledPath => throw _privateConstructorUsedError; - String get rsiLauncherInstalledPath => throw _privateConstructorUsedError; - List get scInstallPaths => throw _privateConstructorUsedError; - List get rsiLauncherInstallPaths => - throw _privateConstructorUsedError; - List get items => throw _privateConstructorUsedError; - bool get isItemLoading => throw _privateConstructorUsedError; - - /// Create a copy of ToolsUIState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $ToolsUIStateCopyWith get copyWith => - throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $ToolsUIStateCopyWith<$Res> { - factory $ToolsUIStateCopyWith( - ToolsUIState value, $Res Function(ToolsUIState) then) = - _$ToolsUIStateCopyWithImpl<$Res, ToolsUIState>; - @useResult - $Res call( - {bool working, - String scInstalledPath, - String rsiLauncherInstalledPath, - List scInstallPaths, - List rsiLauncherInstallPaths, - List items, - bool isItemLoading}); -} - -/// @nodoc -class _$ToolsUIStateCopyWithImpl<$Res, $Val extends ToolsUIState> - implements $ToolsUIStateCopyWith<$Res> { - _$ToolsUIStateCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of ToolsUIState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? working = null, - Object? scInstalledPath = null, - Object? rsiLauncherInstalledPath = null, - Object? scInstallPaths = null, - Object? rsiLauncherInstallPaths = null, - Object? items = null, - Object? isItemLoading = null, - }) { - return _then(_value.copyWith( - working: null == working - ? _value.working - : working // ignore: cast_nullable_to_non_nullable - as bool, - scInstalledPath: null == scInstalledPath - ? _value.scInstalledPath - : scInstalledPath // ignore: cast_nullable_to_non_nullable - as String, - rsiLauncherInstalledPath: null == rsiLauncherInstalledPath - ? _value.rsiLauncherInstalledPath - : rsiLauncherInstalledPath // ignore: cast_nullable_to_non_nullable - as String, - scInstallPaths: null == scInstallPaths - ? _value.scInstallPaths - : scInstallPaths // ignore: cast_nullable_to_non_nullable - as List, - rsiLauncherInstallPaths: null == rsiLauncherInstallPaths - ? _value.rsiLauncherInstallPaths - : rsiLauncherInstallPaths // ignore: cast_nullable_to_non_nullable - as List, - items: null == items - ? _value.items - : items // ignore: cast_nullable_to_non_nullable - as List, - isItemLoading: null == isItemLoading - ? _value.isItemLoading - : isItemLoading // ignore: cast_nullable_to_non_nullable - as bool, - ) as $Val); - } -} - -/// @nodoc -abstract class _$$ToolsUIStateImplCopyWith<$Res> - implements $ToolsUIStateCopyWith<$Res> { - factory _$$ToolsUIStateImplCopyWith( - _$ToolsUIStateImpl value, $Res Function(_$ToolsUIStateImpl) then) = - __$$ToolsUIStateImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {bool working, - String scInstalledPath, - String rsiLauncherInstalledPath, - List scInstallPaths, - List rsiLauncherInstallPaths, - List items, - bool isItemLoading}); -} - -/// @nodoc -class __$$ToolsUIStateImplCopyWithImpl<$Res> - extends _$ToolsUIStateCopyWithImpl<$Res, _$ToolsUIStateImpl> - implements _$$ToolsUIStateImplCopyWith<$Res> { - __$$ToolsUIStateImplCopyWithImpl( - _$ToolsUIStateImpl _value, $Res Function(_$ToolsUIStateImpl) _then) - : super(_value, _then); - - /// Create a copy of ToolsUIState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? working = null, - Object? scInstalledPath = null, - Object? rsiLauncherInstalledPath = null, - Object? scInstallPaths = null, - Object? rsiLauncherInstallPaths = null, - Object? items = null, - Object? isItemLoading = null, - }) { - return _then(_$ToolsUIStateImpl( - working: null == working - ? _value.working - : working // ignore: cast_nullable_to_non_nullable - as bool, - scInstalledPath: null == scInstalledPath - ? _value.scInstalledPath - : scInstalledPath // ignore: cast_nullable_to_non_nullable - as String, - rsiLauncherInstalledPath: null == rsiLauncherInstalledPath - ? _value.rsiLauncherInstalledPath - : rsiLauncherInstalledPath // ignore: cast_nullable_to_non_nullable - as String, - scInstallPaths: null == scInstallPaths - ? _value._scInstallPaths - : scInstallPaths // ignore: cast_nullable_to_non_nullable - as List, - rsiLauncherInstallPaths: null == rsiLauncherInstallPaths - ? _value._rsiLauncherInstallPaths - : rsiLauncherInstallPaths // ignore: cast_nullable_to_non_nullable - as List, - items: null == items - ? _value._items - : items // ignore: cast_nullable_to_non_nullable - as List, - isItemLoading: null == isItemLoading - ? _value.isItemLoading - : isItemLoading // ignore: cast_nullable_to_non_nullable - as bool, - )); - } -} - -/// @nodoc - -class _$ToolsUIStateImpl implements _ToolsUIState { - _$ToolsUIStateImpl( - {this.working = false, - this.scInstalledPath = "", - this.rsiLauncherInstalledPath = "", - final List scInstallPaths = const [], - final List rsiLauncherInstallPaths = const [], - final List items = const [], - this.isItemLoading = false}) - : _scInstallPaths = scInstallPaths, - _rsiLauncherInstallPaths = rsiLauncherInstallPaths, - _items = items; - - @override - @JsonKey() - final bool working; - @override - @JsonKey() - final String scInstalledPath; - @override - @JsonKey() - final String rsiLauncherInstalledPath; - final List _scInstallPaths; - @override - @JsonKey() - List get scInstallPaths { - if (_scInstallPaths is EqualUnmodifiableListView) return _scInstallPaths; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_scInstallPaths); - } - - final List _rsiLauncherInstallPaths; - @override - @JsonKey() - List get rsiLauncherInstallPaths { - if (_rsiLauncherInstallPaths is EqualUnmodifiableListView) - return _rsiLauncherInstallPaths; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_rsiLauncherInstallPaths); - } - - final List _items; - @override - @JsonKey() - List get items { - if (_items is EqualUnmodifiableListView) return _items; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_items); - } - - @override - @JsonKey() - final bool isItemLoading; - - @override - String toString() { - return 'ToolsUIState(working: $working, scInstalledPath: $scInstalledPath, rsiLauncherInstalledPath: $rsiLauncherInstalledPath, scInstallPaths: $scInstallPaths, rsiLauncherInstallPaths: $rsiLauncherInstallPaths, items: $items, isItemLoading: $isItemLoading)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$ToolsUIStateImpl && - (identical(other.working, working) || other.working == working) && - (identical(other.scInstalledPath, scInstalledPath) || - other.scInstalledPath == scInstalledPath) && - (identical( - other.rsiLauncherInstalledPath, rsiLauncherInstalledPath) || - other.rsiLauncherInstalledPath == rsiLauncherInstalledPath) && - const DeepCollectionEquality() - .equals(other._scInstallPaths, _scInstallPaths) && - const DeepCollectionEquality().equals( - other._rsiLauncherInstallPaths, _rsiLauncherInstallPaths) && - const DeepCollectionEquality().equals(other._items, _items) && - (identical(other.isItemLoading, isItemLoading) || - other.isItemLoading == isItemLoading)); - } - - @override - int get hashCode => Object.hash( - runtimeType, - working, - scInstalledPath, - rsiLauncherInstalledPath, - const DeepCollectionEquality().hash(_scInstallPaths), - const DeepCollectionEquality().hash(_rsiLauncherInstallPaths), - const DeepCollectionEquality().hash(_items), - isItemLoading); - - /// Create a copy of ToolsUIState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$ToolsUIStateImplCopyWith<_$ToolsUIStateImpl> get copyWith => - __$$ToolsUIStateImplCopyWithImpl<_$ToolsUIStateImpl>(this, _$identity); -} - -abstract class _ToolsUIState implements ToolsUIState { - factory _ToolsUIState( - {final bool working, - final String scInstalledPath, - final String rsiLauncherInstalledPath, - final List scInstallPaths, - final List rsiLauncherInstallPaths, - final List items, - final bool isItemLoading}) = _$ToolsUIStateImpl; - - @override - bool get working; - @override - String get scInstalledPath; - @override - String get rsiLauncherInstalledPath; - @override - List get scInstallPaths; - @override - List get rsiLauncherInstallPaths; - @override - List get items; - @override - bool get isItemLoading; - - /// Create a copy of ToolsUIState - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$ToolsUIStateImplCopyWith<_$ToolsUIStateImpl> get copyWith => - throw _privateConstructorUsedError; -} diff --git a/lib/ui/tools/tools_ui_model.g.dart b/lib/ui/tools/tools_ui_model.g.dart deleted file mode 100644 index 8ea2157..0000000 --- a/lib/ui/tools/tools_ui_model.g.dart +++ /dev/null @@ -1,25 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'tools_ui_model.dart'; - -// ************************************************************************** -// RiverpodGenerator -// ************************************************************************** - -String _$toolsUIModelHash() => r'b61ae444063db4c550fbf71e724eddd0f7104dc5'; - -/// See also [ToolsUIModel]. -@ProviderFor(ToolsUIModel) -final toolsUIModelProvider = - AutoDisposeNotifierProvider.internal( - ToolsUIModel.new, - name: r'toolsUIModelProvider', - debugGetCreateSourceHash: - const bool.fromEnvironment('dart.vm.product') ? null : _$toolsUIModelHash, - dependencies: null, - allTransitiveDependencies: null, -); - -typedef _$ToolsUIModel = AutoDisposeNotifier; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member diff --git a/lib/ui/tools/unp4kc/unp4kc_ui.dart b/lib/ui/tools/unp4kc/unp4kc_ui.dart deleted file mode 100644 index d4acc6e..0000000 --- a/lib/ui/tools/unp4kc/unp4kc_ui.dart +++ /dev/null @@ -1,330 +0,0 @@ -import 'dart:io'; - -import 'package:file_sizes/file_sizes.dart'; -import 'package:fluent_ui/fluent_ui.dart'; -import 'package:flutter_hooks/flutter_hooks.dart'; -import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:re_editor/re_editor.dart'; -import 'package:starcitizen_doctor/api/analytics.dart'; -import 'package:starcitizen_doctor/common/helper/system_helper.dart'; -import 'package:starcitizen_doctor/data/app_unp4k_p4k_item_data.dart'; -import 'package:starcitizen_doctor/provider/unp4kc.dart'; -import 'package:starcitizen_doctor/widgets/widgets.dart'; -import 'package:super_sliver_list/super_sliver_list.dart'; -import 'package:url_launcher/url_launcher_string.dart'; - -class UnP4kcUI extends HookConsumerWidget { - const UnP4kcUI({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(unp4kCModelProvider); - final model = ref.read(unp4kCModelProvider.notifier); - final files = model.getFiles(); - final paths = state.curPath.trim().split("\\"); - - useEffect(() { - AnalyticsApi.touch("unp4k_launch"); - return null; - }, const []); - - return makeDefaultPage(context, - title: S.current.tools_unp4k_title(model.getGamePath()), - useBodyContainer: false, - content: makeBody(context, state, model, files, paths)); - } - - Widget makeBody(BuildContext context, Unp4kcState state, Unp4kCModel model, - List? files, List paths) { - if (state.errorMessage.isNotEmpty) { - return UnP4kErrorWidget(errorMessage: state.errorMessage); - } - return state.files == null - ? Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded(child: makeLoading(context)), - if (state.endMessage != null) - Padding( - padding: const EdgeInsets.all(8.0), - child: Text( - "${state.endMessage}", - style: const TextStyle(fontSize: 12), - ), - ), - ], - ) - : Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - decoration: BoxDecoration( - color: FluentTheme.of(context).cardColor.withOpacity(.06)), - height: 36, - padding: const EdgeInsets.only(left: 12, right: 12), - child: SuperListView.builder( - itemCount: paths.length - 1, - scrollDirection: Axis.horizontal, - itemBuilder: (BuildContext context, int index) { - var path = paths[index]; - if (path.isEmpty) { - path = "\\"; - } - final fullPath = - "${paths.sublist(0, index + 1).join("\\")}\\"; - return Row( - children: [ - IconButton( - icon: Text(path), - onPressed: () { - model.changeDir(fullPath, fullPath: true); - }, - ), - const Icon( - FluentIcons.chevron_right, - size: 12, - ), - ], - ); - }, - ), - ), - Expanded( - child: Row( - children: [ - Container( - width: MediaQuery.of(context).size.width * .3, - decoration: BoxDecoration( - color: FluentTheme.of(context).cardColor.withOpacity(.01), - ), - child: SuperListView.builder( - padding: const EdgeInsets.only( - top: 6, bottom: 6, left: 3, right: 12), - itemBuilder: (BuildContext context, int index) { - final item = files![index]; - final fileName = - item.name?.replaceAll(state.curPath.trim(), "") ?? - "?"; - return Container( - margin: const EdgeInsets.only(top: 4, bottom: 4), - decoration: BoxDecoration( - color: FluentTheme.of(context) - .cardColor - .withOpacity(.05), - ), - child: IconButton( - onPressed: () { - if (item.isDirectory ?? false) { - model.changeDir(fileName); - } else { - model.openFile(item.name ?? ""); - } - }, - icon: Padding( - padding: const EdgeInsets.only(left: 4, right: 4), - child: Row( - children: [ - if (item.isDirectory ?? false) - const Icon( - FluentIcons.folder_fill, - color: Color.fromRGBO(255, 224, 138, 1), - ) - else if (fileName.endsWith(".xml")) - const Icon( - FluentIcons.file_code, - ) - else - const Icon( - FluentIcons.open_file, - ), - const SizedBox(width: 12), - Expanded( - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Row( - children: [ - Expanded( - child: Text( - fileName, - style: const TextStyle( - fontSize: 13), - textAlign: TextAlign.start, - ), - ), - ], - ), - if (!(item.isDirectory ?? true)) ...[ - const SizedBox(height: 1), - Row( - children: [ - Text( - FileSize.getSize(item.size), - style: TextStyle( - fontSize: 10, - color: Colors.white - .withOpacity(.6)), - ), - const SizedBox(width: 12), - Text( - "${item.dateTime}", - style: TextStyle( - fontSize: 10, - color: Colors.white - .withOpacity(.6)), - ), - ], - ), - ], - ], - ), - ), - const SizedBox(width: 3), - Icon( - FluentIcons.chevron_right, - size: 14, - color: Colors.white.withOpacity(.6), - ) - ], - ), - ), - ), - ); - }, - itemCount: files?.length ?? 0, - ), - ), - Expanded( - child: Container( - child: state.tempOpenFile == null - ? Center( - child: Text(S.current.tools_unp4k_view_file), - ) - : state.tempOpenFile?.key == "loading" - ? makeLoading(context) - : Padding( - padding: const EdgeInsets.all(12), - child: Column( - children: [ - if (state.tempOpenFile?.key == "text") - Expanded( - child: _TextTempWidget( - state.tempOpenFile?.value ?? "")) - else - Expanded( - child: Center( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Text(S.current - .tools_unp4k_msg_unknown_file_type( - state.tempOpenFile - ?.value ?? - "")), - const SizedBox(height: 32), - FilledButton( - child: Padding( - padding: - const EdgeInsets.all(4), - child: Text(S.current - .action_open_folder), - ), - onPressed: () { - SystemHelper.openDir(state - .tempOpenFile - ?.value ?? - ""); - }) - ], - ), - ), - ) - ], - ), - ), - )) - ], - )), - if (state.endMessage != null) - Padding( - padding: const EdgeInsets.all(8.0), - child: Text( - "${state.endMessage}", - style: const TextStyle(fontSize: 12), - ), - ), - ], - ); - } -} - -class _TextTempWidget extends HookConsumerWidget { - final String filePath; - - const _TextTempWidget(this.filePath); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final textData = useState(null); - - useEffect(() { - File(filePath).readAsString().then((value) { - textData.value = value; - }).catchError((err) { - textData.value = "Error: $err"; - }); - return null; - }, const []); - - if (textData.value == null) return makeLoading(context); - - return CodeEditor( - controller: CodeLineEditingController.fromText('${textData.value}'), - readOnly: true, - ); - } -} - -class UnP4kErrorWidget extends StatelessWidget { - final String errorMessage; - - const UnP4kErrorWidget({super.key, required this.errorMessage}); - - static const _downloadUrl = - "https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=win-x64&os=win10&apphost_version=8.0.0"; - - @override - Widget build(BuildContext context) { - return Padding( - padding: const EdgeInsets.all(24), - child: Center( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - if (Unp4kCModel.checkRunTimeError(errorMessage)) ...[ - Text( - S.current.tools_unp4k_missing_runtime, - style: const TextStyle(fontSize: 16), - ), - const SizedBox(height: 6), - Text(S.current.tools_unp4k_missing_runtime_info), - const SizedBox(height: 16), - FilledButton( - child: Padding( - padding: - const EdgeInsets.symmetric(horizontal: 12, vertical: 3), - child: Text( - S.current.tools_unp4k_missing_runtime_action_install), - ), - onPressed: () { - launchUrlString(_downloadUrl); - }), - ] else - Text(errorMessage), - ], - ), - ), - ); - } -} diff --git a/lib/ui/webview/webview.dart b/lib/ui/webview/webview.dart deleted file mode 100644 index dff1bfe..0000000 --- a/lib/ui/webview/webview.dart +++ /dev/null @@ -1,304 +0,0 @@ -// ignore_for_file: use_build_context_synchronously - -import 'dart:async'; -import 'dart:convert'; -import 'dart:io'; - -import 'package:desktop_webview_window/desktop_webview_window.dart'; -import 'package:flutter/services.dart'; -import 'package:flutter/widgets.dart'; -import 'package:hive/hive.dart'; -import 'package:starcitizen_doctor/api/analytics.dart'; -import 'package:starcitizen_doctor/common/conf/url_conf.dart'; -import 'package:starcitizen_doctor/common/io/rs_http.dart'; -import 'package:starcitizen_doctor/common/utils/base_utils.dart'; -import 'package:starcitizen_doctor/common/utils/log.dart'; -import 'package:starcitizen_doctor/data/app_version_data.dart'; -import 'package:starcitizen_doctor/data/app_web_localization_versions_data.dart'; - -typedef RsiLoginCallback = void Function(Map? data, bool success); - -class WebViewModel { - late Webview webview; - final BuildContext context; - - bool _isClosed = false; - - bool get isClosed => _isClosed; - - WebViewModel(this.context, - {this.loginMode = false, this.loginCallback, this.loginChannel = "LIVE"}); - - String url = ""; - bool canGoBack = false; - - final localizationResource = {}; - - var localizationScript = ""; - - bool enableCapture = false; - - bool isEnableToolSiteMirrors = false; - - Map? _curReplaceWords; - - Map? get curReplaceWords => _curReplaceWords; - - final bool loginMode; - final String loginChannel; - - bool _loginModeSuccess = false; - - final RsiLoginCallback? loginCallback; - - initWebView( - {String title = "", - required String applicationSupportDir, - required AppVersionData appVersionData}) async { - try { - final userBox = await Hive.openBox("app_conf"); - isEnableToolSiteMirrors = - userBox.get("isEnableToolSiteMirrors", defaultValue: false); - webview = await WebviewWindow.create( - configuration: CreateConfiguration( - windowWidth: loginMode ? 960 : 1920, - windowHeight: loginMode ? 720 : 1080, - userDataFolderWindows: "$applicationSupportDir/webview_data", - title: Platform.isMacOS ? "" : title)); - // webview.openDevToolsWindow(); - webview.isNavigating.addListener(() async { - if (!webview.isNavigating.value && localizationResource.isNotEmpty) { - dPrint("webview Navigating url === $url"); - if (url.contains("robertsspaceindustries.com")) { - // SC 官网 - dPrint("load script"); - await Future.delayed(const Duration(milliseconds: 100)); - await webview.evaluateJavaScript(localizationScript); - dPrint("update replaceWords"); - final replaceWords = _getLocalizationResource("zh-CN"); - - const org = "https://robertsspaceindustries.com/orgs"; - const citizens = "https://robertsspaceindustries.com/citizens"; - const organization = - "https://robertsspaceindustries.com/account/organization"; - const concierge = - "https://robertsspaceindustries.com/account/concierge"; - const referral = - "https://robertsspaceindustries.com/account/referral-program"; - const address = - "https://robertsspaceindustries.com/account/addresses"; - - const hangar = "https://robertsspaceindustries.com/account/pledges"; - - const spectrum = - "https://robertsspaceindustries.com/spectrum/community/"; - // 跳过光谱论坛 https://github.com/StarCitizenToolBox/StarCitizenBoxBrowserEx/issues/1 - if (url.startsWith(spectrum)) { - return; - } - - if (url.startsWith(org) || - url.startsWith(citizens) || - url.startsWith(organization)) { - replaceWords.add({ - "word": 'members', - "replacement": S.current.webview_localization_name_member - }); - replaceWords.addAll(_getLocalizationResource("orgs")); - } - - if (address.startsWith(address)) { - replaceWords.addAll(_getLocalizationResource("address")); - } - - if (url.startsWith(referral)) { - replaceWords.addAll([ - { - "word": 'Total recruits: ', - "replacement": - S.current.webview_localization_total_invitations - }, - { - "word": 'Prospects ', - "replacement": - S.current.webview_localization_unfinished_invitations - }, - { - "word": 'Recruits', - "replacement": - S.current.webview_localization_finished_invitations - }, - ]); - } - - if (url.startsWith(concierge)) { - replaceWords.clear(); - replaceWords.addAll(_getLocalizationResource("concierge")); - } - if (url.startsWith(hangar)) { - replaceWords.addAll(_getLocalizationResource("hangar")); - } - - _curReplaceWords = {}; - for (var element in replaceWords) { - _curReplaceWords?[element["word"] ?? ""] = - element["replacement"] ?? ""; - } - await Future.delayed(const Duration(milliseconds: 100)); - await webview.evaluateJavaScript( - "WebLocalizationUpdateReplaceWords(${json.encode(replaceWords)},$enableCapture)"); - - /// loginMode - if (loginMode) { - dPrint( - "--- do rsi login ---\n run === getRSILauncherToken(\"$loginChannel\");"); - await Future.delayed(const Duration(milliseconds: 200)); - webview.evaluateJavaScript( - "getRSILauncherToken(\"$loginChannel\");"); - } - } else if (url.startsWith(await _handleMirrorsUrl( - "https://www.erkul.games", appVersionData))) { - dPrint("load script"); - await Future.delayed(const Duration(milliseconds: 100)); - await webview.evaluateJavaScript(localizationScript); - dPrint("update replaceWords"); - final replaceWords = _getLocalizationResource("DPS"); - await webview.evaluateJavaScript( - "WebLocalizationUpdateReplaceWords(${json.encode(replaceWords)},$enableCapture)"); - } else if (url.startsWith(await _handleMirrorsUrl( - "https://uexcorp.space", appVersionData))) { - dPrint("load script"); - await Future.delayed(const Duration(milliseconds: 100)); - await webview.evaluateJavaScript(localizationScript); - dPrint("update replaceWords"); - final replaceWords = _getLocalizationResource("UEX"); - await webview.evaluateJavaScript( - "WebLocalizationUpdateReplaceWords(${json.encode(replaceWords)},$enableCapture)"); - } - } - }); - webview.addOnUrlRequestCallback((url) { - dPrint("OnUrlRequestCallback === $url"); - this.url = url; - }); - webview.onClose.whenComplete(dispose); - if (loginMode) { - webview.addOnWebMessageReceivedCallback((messageString) { - final message = json.decode(messageString); - if (message["action"] == "webview_rsi_login_show_window") { - webview.setWebviewWindowVisibility(true); - } else if (message["action"] == "webview_rsi_login_success") { - _loginModeSuccess = true; - loginCallback?.call(message, true); - webview.close(); - } - }); - Future.delayed(const Duration(seconds: 1)) - .then((value) => {webview.setWebviewWindowVisibility(false)}); - } - } catch (e) { - showToast(context, S.current.app_init_failed_with_reason(e)); - } - } - - Future _handleMirrorsUrl( - String url, AppVersionData appVersionData) async { - var finalUrl = url; - if (isEnableToolSiteMirrors) { - for (var kv in appVersionData.webMirrors!.entries) { - if (url.startsWith(kv.key)) { - finalUrl = url.replaceFirst(kv.key, kv.value); - AnalyticsApi.touch("webLocalization_with_boost_mirror"); - } - } - } - return finalUrl; - } - - launch(String url, AppVersionData appVersionData) async { - webview.launch(await _handleMirrorsUrl(url, appVersionData)); - } - - initLocalization(AppWebLocalizationVersionsData v) async { - localizationScript = await rootBundle.loadString('assets/web_script.js'); - - /// https://github.com/CxJuice/Uex_Chinese_Translate - // get versions - final hostUrl = URLConf.webTranslateHomeUrl; - dPrint("AppWebLocalizationVersionsData === ${v.toJson()}"); - - localizationResource["zh-CN"] = await _getJson("$hostUrl/zh-CN-rsi.json", - cacheKey: "rsi", version: v.rsi); - localizationResource["concierge"] = await _getJson( - "$hostUrl/concierge.json", - cacheKey: "concierge", - version: v.concierge); - localizationResource["orgs"] = - await _getJson("$hostUrl/orgs.json", cacheKey: "orgs", version: v.orgs); - localizationResource["address"] = await _getJson("$hostUrl/addresses.json", - cacheKey: "addresses", version: v.addresses); - localizationResource["hangar"] = await _getJson("$hostUrl/hangar.json", - cacheKey: "hangar", version: v.hangar); - localizationResource["UEX"] = await _getJson("$hostUrl/zh-CN-uex.json", - cacheKey: "uex", version: v.uex); - localizationResource["DPS"] = await _getJson("$hostUrl/zh-CN-dps.json", - cacheKey: "dps", version: v.dps); - } - - List> _getLocalizationResource(String key) { - final List> localizations = []; - final dict = localizationResource[key]; - if (dict is Map) { - for (var element in dict.entries) { - final k = element.key - .toString() - .trim() - .toLowerCase() - .replaceAll(RegExp("/\xa0/g"), ' ') - .replaceAll(RegExp("/s{2,}/g"), ' '); - localizations - .add({"word": k, "replacement": element.value.toString().trim()}); - } - } - return localizations; - } - - Future _getJson(String url, - {String cacheKey = "", String? version}) async { - final box = await Hive.openBox("web_localization_cache_data"); - if (cacheKey.isNotEmpty) { - final localVersion = box.get("${cacheKey}_version}", defaultValue: ""); - var data = box.get(cacheKey, defaultValue: {}); - if (data is Map && data.isNotEmpty && localVersion == version) { - return data; - } - } - final startTime = DateTime.now(); - final r = await RSHttp.getText(url); - final endTime = DateTime.now(); - final data = json.decode(r); - if (cacheKey.isNotEmpty) { - dPrint( - "update $cacheKey v == $version time == ${(endTime.microsecondsSinceEpoch - startTime.microsecondsSinceEpoch) / 1000 / 1000}s"); - await box.put(cacheKey, data); - await box.put("${cacheKey}_version}", version); - } - return data; - } - - void addOnWebMessageReceivedCallback(OnWebMessageReceivedCallback callback) { - webview.addOnWebMessageReceivedCallback(callback); - } - - void removeOnWebMessageReceivedCallback( - OnWebMessageReceivedCallback callback) { - webview.removeOnWebMessageReceivedCallback(callback); - } - - FutureOr dispose() { - if (loginMode && !_loginModeSuccess) { - loginCallback?.call(null, false); - } - _isClosed = true; - } -} diff --git a/lib/widgets/src/blur_oval_widget.dart b/lib/widgets/src/blur_oval_widget.dart new file mode 100644 index 0000000..d81afae --- /dev/null +++ b/lib/widgets/src/blur_oval_widget.dart @@ -0,0 +1,37 @@ +import 'dart:ui'; + +import 'package:flutter/material.dart'; + +class BlurOvalWidget extends StatelessWidget { + final Widget child; + final double padding; + final Color blurColor; + final BorderRadius borderRadius; + final ImageFilter? imageFilter; + + const BlurOvalWidget( + {super.key, + required this.child, + this.padding = 0, + this.blurColor = Colors.white10, + this.borderRadius = BorderRadius.zero, + this.imageFilter}); + + @override + Widget build(BuildContext context) { + return ClipRRect( + borderRadius: borderRadius, + child: BackdropFilter( + filter: imageFilter ?? + ImageFilter.blur( + sigmaX: 10, + sigmaY: 10, + ), + child: Container( + color: blurColor, + child: child, + ), + ), + ); + } +} diff --git a/lib/widgets/widgets.dart b/lib/widgets/widgets.dart index 28dde4a..2fc0f0d 100644 --- a/lib/widgets/widgets.dart +++ b/lib/widgets/widgets.dart @@ -7,7 +7,6 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:starcitizen_doctor/generated/l10n.dart'; import 'package:url_launcher/url_launcher_string.dart'; -import 'package:window_manager/window_manager.dart'; import 'package:markdown_widget/config/all.dart'; import 'package:markdown_widget/widget/all.dart'; import 'package:extended_image/extended_image.dart'; @@ -43,28 +42,24 @@ Widget makeDefaultPage(BuildContext context, return NavigationView( appBar: NavigationAppBar( automaticallyImplyLeading: automaticallyImplyLeading, - title: DragToMoveArea( - child: titleRow ?? - Column( + title: Column( + children: [ + Expanded( + child: Row( children: [ - Expanded( - child: Row( - children: [ - Text(title), - ], - ), - ) + Text(title), ], ), + ) + ], ), actions: Row( mainAxisAlignment: MainAxisAlignment.end, - children: [...?actions, const WindowButtons()], + children: [...?actions], )), content: useBodyContainer ? Container( decoration: BoxDecoration( - color: FluentTheme.of(context).scaffoldBackgroundColor, borderRadius: BorderRadius.circular(9), ), child: content, @@ -73,23 +68,6 @@ Widget makeDefaultPage(BuildContext context, ); } -class WindowButtons extends StatelessWidget { - const WindowButtons({super.key}); - - @override - Widget build(BuildContext context) { - final FluentThemeData theme = FluentTheme.of(context); - return SizedBox( - width: 138, - height: 50, - child: WindowCaption( - brightness: theme.brightness, - backgroundColor: Colors.transparent, - ), - ); - } -} - List makeMarkdownView(String description, {String? attachmentsUrl}) { return MarkdownGenerator().buildWidgets(description, config: MarkdownConfig(configs: [ diff --git a/linux/.gitignore b/linux/.gitignore deleted file mode 100644 index d3896c9..0000000 --- a/linux/.gitignore +++ /dev/null @@ -1 +0,0 @@ -flutter/ephemeral diff --git a/linux/CMakeLists.txt b/linux/CMakeLists.txt deleted file mode 100644 index b99d63d..0000000 --- a/linux/CMakeLists.txt +++ /dev/null @@ -1,145 +0,0 @@ -# Project-level configuration. -cmake_minimum_required(VERSION 3.10) -project(runner LANGUAGES CXX) - -# The name of the executable created for the application. Change this to change -# the on-disk name of your application. -set(BINARY_NAME "app") -# The unique GTK application identifier for this application. See: -# https://wiki.gnome.org/HowDoI/ChooseApplicationID -set(APPLICATION_ID "com.example.app") - -# Explicitly opt in to modern CMake behaviors to avoid warnings with recent -# versions of CMake. -cmake_policy(SET CMP0063 NEW) - -# Load bundled libraries from the lib/ directory relative to the binary. -set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") - -# Root filesystem for cross-building. -if(FLUTTER_TARGET_PLATFORM_SYSROOT) - set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) - set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) - set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) - set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) - set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) - set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) -endif() - -# Define build configuration options. -if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) - set(CMAKE_BUILD_TYPE "Debug" CACHE - STRING "Flutter build mode" FORCE) - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS - "Debug" "Profile" "Release") -endif() - -# Compilation settings that should be applied to most targets. -# -# Be cautious about adding new options here, as plugins use this function by -# default. In most cases, you should add new options to specific targets instead -# of modifying this function. -function(APPLY_STANDARD_SETTINGS TARGET) - target_compile_features(${TARGET} PUBLIC cxx_std_14) - target_compile_options(${TARGET} PRIVATE -Wall -Werror) - target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") - target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") -endfunction() - -# Flutter library and tool build rules. -set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") -add_subdirectory(${FLUTTER_MANAGED_DIR}) - -# System-level dependencies. -find_package(PkgConfig REQUIRED) -pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) - -add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") - -# Define the application target. To change its name, change BINARY_NAME above, -# not the value here, or `flutter run` will no longer work. -# -# Any new source files that you add to the application should be added here. -add_executable(${BINARY_NAME} - "main.cc" - "my_application.cc" - "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" -) - -# Apply the standard set of build settings. This can be removed for applications -# that need different build settings. -apply_standard_settings(${BINARY_NAME}) - -# Add dependency libraries. Add any application-specific dependencies here. -target_link_libraries(${BINARY_NAME} PRIVATE flutter) -target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) - -# Run the Flutter tool portions of the build. This must not be removed. -add_dependencies(${BINARY_NAME} flutter_assemble) - -# Only the install-generated bundle's copy of the executable will launch -# correctly, since the resources must in the right relative locations. To avoid -# people trying to run the unbundled copy, put it in a subdirectory instead of -# the default top-level location. -set_target_properties(${BINARY_NAME} - PROPERTIES - RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" -) - - -# Generated plugin build rules, which manage building the plugins and adding -# them to the application. -include(flutter/generated_plugins.cmake) - - -# === Installation === -# By default, "installing" just makes a relocatable bundle in the build -# directory. -set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") -if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) -endif() - -# Start with a clean build bundle directory every time. -install(CODE " - file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") - " COMPONENT Runtime) - -set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") -set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") - -install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" - COMPONENT Runtime) - -install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" - COMPONENT Runtime) - -install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" - COMPONENT Runtime) - -foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) - install(FILES "${bundled_library}" - DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" - COMPONENT Runtime) -endforeach(bundled_library) - -# Copy the native assets provided by the build.dart from all packages. -set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") -install(DIRECTORY "${NATIVE_ASSETS_DIR}" - DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" - COMPONENT Runtime) - -# Fully re-copy the assets directory on each build to avoid having stale files -# from a previous install. -set(FLUTTER_ASSET_DIR_NAME "flutter_assets") -install(CODE " - file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") - " COMPONENT Runtime) -install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" - DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) - -# Install the AOT library on non-Debug builds only. -if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") - install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" - COMPONENT Runtime) -endif() diff --git a/linux/flutter/CMakeLists.txt b/linux/flutter/CMakeLists.txt deleted file mode 100644 index d5bd016..0000000 --- a/linux/flutter/CMakeLists.txt +++ /dev/null @@ -1,88 +0,0 @@ -# This file controls Flutter-level build steps. It should not be edited. -cmake_minimum_required(VERSION 3.10) - -set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") - -# Configuration provided via flutter tool. -include(${EPHEMERAL_DIR}/generated_config.cmake) - -# TODO: Move the rest of this into files in ephemeral. See -# https://github.com/flutter/flutter/issues/57146. - -# Serves the same purpose as list(TRANSFORM ... PREPEND ...), -# which isn't available in 3.10. -function(list_prepend LIST_NAME PREFIX) - set(NEW_LIST "") - foreach(element ${${LIST_NAME}}) - list(APPEND NEW_LIST "${PREFIX}${element}") - endforeach(element) - set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) -endfunction() - -# === Flutter Library === -# System-level dependencies. -find_package(PkgConfig REQUIRED) -pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) -pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) -pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) - -set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") - -# Published to parent scope for install step. -set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) -set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) -set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) -set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) - -list(APPEND FLUTTER_LIBRARY_HEADERS - "fl_basic_message_channel.h" - "fl_binary_codec.h" - "fl_binary_messenger.h" - "fl_dart_project.h" - "fl_engine.h" - "fl_json_message_codec.h" - "fl_json_method_codec.h" - "fl_message_codec.h" - "fl_method_call.h" - "fl_method_channel.h" - "fl_method_codec.h" - "fl_method_response.h" - "fl_plugin_registrar.h" - "fl_plugin_registry.h" - "fl_standard_message_codec.h" - "fl_standard_method_codec.h" - "fl_string_codec.h" - "fl_value.h" - "fl_view.h" - "flutter_linux.h" -) -list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") -add_library(flutter INTERFACE) -target_include_directories(flutter INTERFACE - "${EPHEMERAL_DIR}" -) -target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") -target_link_libraries(flutter INTERFACE - PkgConfig::GTK - PkgConfig::GLIB - PkgConfig::GIO -) -add_dependencies(flutter flutter_assemble) - -# === Flutter tool backend === -# _phony_ is a non-existent file to force this command to run every time, -# since currently there's no way to get a full input/output list from the -# flutter tool. -add_custom_command( - OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} - ${CMAKE_CURRENT_BINARY_DIR}/_phony_ - COMMAND ${CMAKE_COMMAND} -E env - ${FLUTTER_TOOL_ENVIRONMENT} - "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" - ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} - VERBATIM -) -add_custom_target(flutter_assemble DEPENDS - "${FLUTTER_LIBRARY}" - ${FLUTTER_LIBRARY_HEADERS} -) diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc deleted file mode 100644 index a143220..0000000 --- a/linux/flutter/generated_plugin_registrant.cc +++ /dev/null @@ -1,31 +0,0 @@ -// -// Generated file. Do not edit. -// - -// clang-format off - -#include "generated_plugin_registrant.h" - -#include -#include -#include -#include -#include - -void fl_register_plugins(FlPluginRegistry* registry) { - g_autoptr(FlPluginRegistrar) desktop_webview_window_registrar = - fl_plugin_registry_get_registrar_for_plugin(registry, "DesktopWebviewWindowPlugin"); - desktop_webview_window_plugin_register_with_registrar(desktop_webview_window_registrar); - g_autoptr(FlPluginRegistrar) flutter_acrylic_registrar = - fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterAcrylicPlugin"); - flutter_acrylic_plugin_register_with_registrar(flutter_acrylic_registrar); - g_autoptr(FlPluginRegistrar) screen_retriever_registrar = - fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverPlugin"); - screen_retriever_plugin_register_with_registrar(screen_retriever_registrar); - g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = - fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); - url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); - g_autoptr(FlPluginRegistrar) window_manager_registrar = - fl_plugin_registry_get_registrar_for_plugin(registry, "WindowManagerPlugin"); - window_manager_plugin_register_with_registrar(window_manager_registrar); -} diff --git a/linux/flutter/generated_plugin_registrant.h b/linux/flutter/generated_plugin_registrant.h deleted file mode 100644 index e0f0a47..0000000 --- a/linux/flutter/generated_plugin_registrant.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// Generated file. Do not edit. -// - -// clang-format off - -#ifndef GENERATED_PLUGIN_REGISTRANT_ -#define GENERATED_PLUGIN_REGISTRANT_ - -#include - -// Registers Flutter plugins. -void fl_register_plugins(FlPluginRegistry* registry); - -#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake deleted file mode 100644 index 16988cd..0000000 --- a/linux/flutter/generated_plugins.cmake +++ /dev/null @@ -1,29 +0,0 @@ -# -# Generated file, do not edit. -# - -list(APPEND FLUTTER_PLUGIN_LIST - desktop_webview_window - flutter_acrylic - screen_retriever - url_launcher_linux - window_manager -) - -list(APPEND FLUTTER_FFI_PLUGIN_LIST - rust_builder -) - -set(PLUGIN_BUNDLED_LIBRARIES) - -foreach(plugin ${FLUTTER_PLUGIN_LIST}) - add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) - target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) - list(APPEND PLUGIN_BUNDLED_LIBRARIES $) - list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) -endforeach(plugin) - -foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) - add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) - list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) -endforeach(ffi_plugin) diff --git a/linux/main.cc b/linux/main.cc deleted file mode 100644 index e7c5c54..0000000 --- a/linux/main.cc +++ /dev/null @@ -1,6 +0,0 @@ -#include "my_application.h" - -int main(int argc, char** argv) { - g_autoptr(MyApplication) app = my_application_new(); - return g_application_run(G_APPLICATION(app), argc, argv); -} diff --git a/linux/my_application.cc b/linux/my_application.cc deleted file mode 100644 index c4b824f..0000000 --- a/linux/my_application.cc +++ /dev/null @@ -1,124 +0,0 @@ -#include "my_application.h" - -#include -#ifdef GDK_WINDOWING_X11 -#include -#endif - -#include "flutter/generated_plugin_registrant.h" - -struct _MyApplication { - GtkApplication parent_instance; - char** dart_entrypoint_arguments; -}; - -G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) - -// Implements GApplication::activate. -static void my_application_activate(GApplication* application) { - MyApplication* self = MY_APPLICATION(application); - GtkWindow* window = - GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); - - // Use a header bar when running in GNOME as this is the common style used - // by applications and is the setup most users will be using (e.g. Ubuntu - // desktop). - // If running on X and not using GNOME then just use a traditional title bar - // in case the window manager does more exotic layout, e.g. tiling. - // If running on Wayland assume the header bar will work (may need changing - // if future cases occur). - gboolean use_header_bar = TRUE; -#ifdef GDK_WINDOWING_X11 - GdkScreen* screen = gtk_window_get_screen(window); - if (GDK_IS_X11_SCREEN(screen)) { - const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); - if (g_strcmp0(wm_name, "GNOME Shell") != 0) { - use_header_bar = FALSE; - } - } -#endif - if (use_header_bar) { - GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); - gtk_widget_show(GTK_WIDGET(header_bar)); - gtk_header_bar_set_title(header_bar, "app"); - gtk_header_bar_set_show_close_button(header_bar, TRUE); - gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); - } else { - gtk_window_set_title(window, "app"); - } - - gtk_window_set_default_size(window, 1280, 720); - gtk_widget_show(GTK_WIDGET(window)); - - g_autoptr(FlDartProject) project = fl_dart_project_new(); - fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); - - FlView* view = fl_view_new(project); - gtk_widget_show(GTK_WIDGET(view)); - gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); - - fl_register_plugins(FL_PLUGIN_REGISTRY(view)); - - gtk_widget_grab_focus(GTK_WIDGET(view)); -} - -// Implements GApplication::local_command_line. -static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { - MyApplication* self = MY_APPLICATION(application); - // Strip out the first argument as it is the binary name. - self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); - - g_autoptr(GError) error = nullptr; - if (!g_application_register(application, nullptr, &error)) { - g_warning("Failed to register: %s", error->message); - *exit_status = 1; - return TRUE; - } - - g_application_activate(application); - *exit_status = 0; - - return TRUE; -} - -// Implements GApplication::startup. -static void my_application_startup(GApplication* application) { - //MyApplication* self = MY_APPLICATION(object); - - // Perform any actions required at application startup. - - G_APPLICATION_CLASS(my_application_parent_class)->startup(application); -} - -// Implements GApplication::shutdown. -static void my_application_shutdown(GApplication* application) { - //MyApplication* self = MY_APPLICATION(object); - - // Perform any actions required at application shutdown. - - G_APPLICATION_CLASS(my_application_parent_class)->shutdown(application); -} - -// Implements GObject::dispose. -static void my_application_dispose(GObject* object) { - MyApplication* self = MY_APPLICATION(object); - g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); - G_OBJECT_CLASS(my_application_parent_class)->dispose(object); -} - -static void my_application_class_init(MyApplicationClass* klass) { - G_APPLICATION_CLASS(klass)->activate = my_application_activate; - G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; - G_APPLICATION_CLASS(klass)->startup = my_application_startup; - G_APPLICATION_CLASS(klass)->shutdown = my_application_shutdown; - G_OBJECT_CLASS(klass)->dispose = my_application_dispose; -} - -static void my_application_init(MyApplication* self) {} - -MyApplication* my_application_new() { - return MY_APPLICATION(g_object_new(my_application_get_type(), - "application-id", APPLICATION_ID, - "flags", G_APPLICATION_NON_UNIQUE, - nullptr)); -} diff --git a/linux/my_application.h b/linux/my_application.h deleted file mode 100644 index 72271d5..0000000 --- a/linux/my_application.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef FLUTTER_MY_APPLICATION_H_ -#define FLUTTER_MY_APPLICATION_H_ - -#include - -G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, - GtkApplication) - -/** - * my_application_new: - * - * Creates a new Flutter-based application. - * - * Returns: a new #MyApplication. - */ -MyApplication* my_application_new(); - -#endif // FLUTTER_MY_APPLICATION_H_ diff --git a/macos/.gitignore b/macos/.gitignore deleted file mode 100644 index 746adbb..0000000 --- a/macos/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -# Flutter-related -**/Flutter/ephemeral/ -**/Pods/ - -# Xcode-related -**/dgph -**/xcuserdata/ diff --git a/macos/Flutter/Flutter-Debug.xcconfig b/macos/Flutter/Flutter-Debug.xcconfig deleted file mode 100644 index 4b81f9b..0000000 --- a/macos/Flutter/Flutter-Debug.xcconfig +++ /dev/null @@ -1,2 +0,0 @@ -#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" -#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/macos/Flutter/Flutter-Release.xcconfig b/macos/Flutter/Flutter-Release.xcconfig deleted file mode 100644 index 5caa9d1..0000000 --- a/macos/Flutter/Flutter-Release.xcconfig +++ /dev/null @@ -1,2 +0,0 @@ -#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" -#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift deleted file mode 100644 index f535591..0000000 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ /dev/null @@ -1,24 +0,0 @@ -// -// Generated file. Do not edit. -// - -import FlutterMacOS -import Foundation - -import desktop_webview_window -import device_info_plus -import macos_window_utils -import path_provider_foundation -import screen_retriever -import url_launcher_macos -import window_manager - -func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { - DesktopWebviewWindowPlugin.register(with: registry.registrar(forPlugin: "DesktopWebviewWindowPlugin")) - DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin")) - MacOSWindowUtilsPlugin.register(with: registry.registrar(forPlugin: "MacOSWindowUtilsPlugin")) - PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) - ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin")) - UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) - WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin")) -} diff --git a/macos/Podfile b/macos/Podfile deleted file mode 100644 index b52666a..0000000 --- a/macos/Podfile +++ /dev/null @@ -1,43 +0,0 @@ -platform :osx, '10.15' - -# CocoaPods analytics sends network stats synchronously affecting flutter build latency. -ENV['COCOAPODS_DISABLE_STATS'] = 'true' - -project 'Runner', { - 'Debug' => :debug, - 'Profile' => :release, - 'Release' => :release, -} - -def flutter_root - generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) - unless File.exist?(generated_xcode_build_settings_path) - raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" - end - - File.foreach(generated_xcode_build_settings_path) do |line| - matches = line.match(/FLUTTER_ROOT\=(.*)/) - return matches[1].strip if matches - end - raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" -end - -require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) - -flutter_macos_podfile_setup - -target 'Runner' do - use_frameworks! - use_modular_headers! - - flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) - target 'RunnerTests' do - inherit! :search_paths - end -end - -post_install do |installer| - installer.pods_project.targets.each do |target| - flutter_additional_macos_build_settings(target) - end -end diff --git a/macos/Podfile.lock b/macos/Podfile.lock deleted file mode 100644 index 1b97e58..0000000 --- a/macos/Podfile.lock +++ /dev/null @@ -1,65 +0,0 @@ -PODS: - - desktop_webview_window (0.0.1): - - FlutterMacOS - - device_info_plus (0.0.1): - - FlutterMacOS - - FlutterMacOS (1.0.0) - - macos_window_utils (1.0.0): - - FlutterMacOS - - path_provider_foundation (0.0.1): - - Flutter - - FlutterMacOS - - rust_builder (0.0.1): - - FlutterMacOS - - screen_retriever (0.0.1): - - FlutterMacOS - - url_launcher_macos (0.0.1): - - FlutterMacOS - - window_manager (0.2.0): - - FlutterMacOS - -DEPENDENCIES: - - desktop_webview_window (from `Flutter/ephemeral/.symlinks/plugins/desktop_webview_window/macos`) - - device_info_plus (from `Flutter/ephemeral/.symlinks/plugins/device_info_plus/macos`) - - FlutterMacOS (from `Flutter/ephemeral`) - - macos_window_utils (from `Flutter/ephemeral/.symlinks/plugins/macos_window_utils/macos`) - - path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`) - - rust_builder (from `Flutter/ephemeral/.symlinks/plugins/rust_builder/macos`) - - screen_retriever (from `Flutter/ephemeral/.symlinks/plugins/screen_retriever/macos`) - - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`) - - window_manager (from `Flutter/ephemeral/.symlinks/plugins/window_manager/macos`) - -EXTERNAL SOURCES: - desktop_webview_window: - :path: Flutter/ephemeral/.symlinks/plugins/desktop_webview_window/macos - device_info_plus: - :path: Flutter/ephemeral/.symlinks/plugins/device_info_plus/macos - FlutterMacOS: - :path: Flutter/ephemeral - macos_window_utils: - :path: Flutter/ephemeral/.symlinks/plugins/macos_window_utils/macos - path_provider_foundation: - :path: Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin - rust_builder: - :path: Flutter/ephemeral/.symlinks/plugins/rust_builder/macos - screen_retriever: - :path: Flutter/ephemeral/.symlinks/plugins/screen_retriever/macos - url_launcher_macos: - :path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos - window_manager: - :path: Flutter/ephemeral/.symlinks/plugins/window_manager/macos - -SPEC CHECKSUMS: - desktop_webview_window: d4365e71bcd4e1aa0c14cf0377aa24db0c16a7e2 - device_info_plus: ce1b7762849d3ec103d0e0517299f2db7ad60720 - FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 - macos_window_utils: 933f91f64805e2eb91a5bd057cf97cd097276663 - path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46 - rust_builder: 4b521d57bf67224da65f32b529be8fab420fca32 - screen_retriever: 59634572a57080243dd1bf715e55b6c54f241a38 - url_launcher_macos: 5f437abeda8c85500ceb03f5c1938a8c5a705399 - window_manager: 3a1844359a6295ab1e47659b1a777e36773cd6e8 - -PODFILE CHECKSUM: 9ebaf0ce3d369aaa26a9ea0e159195ed94724cf3 - -COCOAPODS: 1.15.2 diff --git a/macos/Runner.xcodeproj/project.pbxproj b/macos/Runner.xcodeproj/project.pbxproj deleted file mode 100644 index df23c3e..0000000 --- a/macos/Runner.xcodeproj/project.pbxproj +++ /dev/null @@ -1,797 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 54; - objects = { - -/* Begin PBXAggregateTarget section */ - 33CC111A2044C6BA0003C045 /* Flutter Assemble */ = { - isa = PBXAggregateTarget; - buildConfigurationList = 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */; - buildPhases = ( - 33CC111E2044C6BF0003C045 /* ShellScript */, - ); - dependencies = ( - ); - name = "Flutter Assemble"; - productName = FLX; - }; -/* End PBXAggregateTarget section */ - -/* Begin PBXBuildFile section */ - 331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C80D7294CF71000263BE5 /* RunnerTests.swift */; }; - 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; }; - 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; }; - 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; - 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; - 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; - 5D997FCC084EEDC755392183 /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9408B1BF071E733725B4B689 /* Pods_RunnerTests.framework */; }; - 955C59A6B4A1B5CE345F2E3E /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B4C40EC7A2C78A6065285544 /* Pods_Runner.framework */; settings = {ATTRIBUTES = (Required, ); }; }; -/* End PBXBuildFile section */ - -/* Begin PBXContainerItemProxy section */ - 331C80D9294CF71000263BE5 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 33CC10E52044A3C60003C045 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 33CC10EC2044A3C60003C045; - remoteInfo = Runner; - }; - 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 33CC10E52044A3C60003C045 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 33CC111A2044C6BA0003C045; - remoteInfo = FLX; - }; -/* End PBXContainerItemProxy section */ - -/* Begin PBXFileReference section */ - 02451A4BA4B40C760076F2B8 /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = ""; }; - 2B7928003DA956B0CA3054C5 /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = ""; }; - 331C80D5294CF71000263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 331C80D7294CF71000263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; - 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; - 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; - 33CC10ED2044A3C60003C045 /* SCToolBox.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SCToolBox.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; - 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; }; - 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; - 33CC10F72044A3C60003C045 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Runner/Info.plist; sourceTree = ""; }; - 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainFlutterWindow.swift; sourceTree = ""; }; - 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = ""; }; - 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = ""; }; - 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = ""; }; - 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; - 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; - 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; - 43FCA8E50F6C13577C7B3E18 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; - 4B6FFF210C41E489F5B6DF73 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; - 6A748F382C1E82D600F92386 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; - 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; - 8A62B92DD472D6FEBD5DFA05 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; - 9408B1BF071E733725B4B689 /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; - B4C40EC7A2C78A6065285544 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - F0A918B7DC1C155A0EF288B7 /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 331C80D2294CF70F00263BE5 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 5D997FCC084EEDC755392183 /* Pods_RunnerTests.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 33CC10EA2044A3C60003C045 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 955C59A6B4A1B5CE345F2E3E /* Pods_Runner.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 331C80D6294CF71000263BE5 /* RunnerTests */ = { - isa = PBXGroup; - children = ( - 331C80D7294CF71000263BE5 /* RunnerTests.swift */, - ); - path = RunnerTests; - sourceTree = ""; - }; - 33BA886A226E78AF003329D5 /* Configs */ = { - isa = PBXGroup; - children = ( - 33E5194F232828860026EE4D /* AppInfo.xcconfig */, - 9740EEB21CF90195004384FC /* Debug.xcconfig */, - 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, - 333000ED22D3DE5D00554162 /* Warnings.xcconfig */, - ); - path = Configs; - sourceTree = ""; - }; - 33CC10E42044A3C60003C045 = { - isa = PBXGroup; - children = ( - 33FAB671232836740065AC1E /* Runner */, - 33CEB47122A05771004F2AC0 /* Flutter */, - 331C80D6294CF71000263BE5 /* RunnerTests */, - 33CC10EE2044A3C60003C045 /* Products */, - D73912EC22F37F3D000D13A0 /* Frameworks */, - DF1543E9F07C7B4884188F0D /* Pods */, - ); - sourceTree = ""; - }; - 33CC10EE2044A3C60003C045 /* Products */ = { - isa = PBXGroup; - children = ( - 33CC10ED2044A3C60003C045 /* SCToolBox.app */, - 331C80D5294CF71000263BE5 /* RunnerTests.xctest */, - ); - name = Products; - sourceTree = ""; - }; - 33CC11242044D66E0003C045 /* Resources */ = { - isa = PBXGroup; - children = ( - 33CC10F22044A3C60003C045 /* Assets.xcassets */, - 33CC10F42044A3C60003C045 /* MainMenu.xib */, - 33CC10F72044A3C60003C045 /* Info.plist */, - ); - name = Resources; - path = ..; - sourceTree = ""; - }; - 33CEB47122A05771004F2AC0 /* Flutter */ = { - isa = PBXGroup; - children = ( - 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */, - 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */, - 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */, - 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */, - ); - path = Flutter; - sourceTree = ""; - }; - 33FAB671232836740065AC1E /* Runner */ = { - isa = PBXGroup; - children = ( - 33CC10F02044A3C60003C045 /* AppDelegate.swift */, - 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */, - 33E51913231747F40026EE4D /* DebugProfile.entitlements */, - 33E51914231749380026EE4D /* Release.entitlements */, - 33CC11242044D66E0003C045 /* Resources */, - 33BA886A226E78AF003329D5 /* Configs */, - ); - path = Runner; - sourceTree = ""; - }; - D73912EC22F37F3D000D13A0 /* Frameworks */ = { - isa = PBXGroup; - children = ( - 6A748F382C1E82D600F92386 /* SystemConfiguration.framework */, - B4C40EC7A2C78A6065285544 /* Pods_Runner.framework */, - 9408B1BF071E733725B4B689 /* Pods_RunnerTests.framework */, - ); - name = Frameworks; - sourceTree = ""; - }; - DF1543E9F07C7B4884188F0D /* Pods */ = { - isa = PBXGroup; - children = ( - 4B6FFF210C41E489F5B6DF73 /* Pods-Runner.debug.xcconfig */, - 8A62B92DD472D6FEBD5DFA05 /* Pods-Runner.release.xcconfig */, - 43FCA8E50F6C13577C7B3E18 /* Pods-Runner.profile.xcconfig */, - 2B7928003DA956B0CA3054C5 /* Pods-RunnerTests.debug.xcconfig */, - 02451A4BA4B40C760076F2B8 /* Pods-RunnerTests.release.xcconfig */, - F0A918B7DC1C155A0EF288B7 /* Pods-RunnerTests.profile.xcconfig */, - ); - path = Pods; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 331C80D4294CF70F00263BE5 /* RunnerTests */ = { - isa = PBXNativeTarget; - buildConfigurationList = 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; - buildPhases = ( - 300725451D4DD3AACE302066 /* [CP] Check Pods Manifest.lock */, - 331C80D1294CF70F00263BE5 /* Sources */, - 331C80D2294CF70F00263BE5 /* Frameworks */, - 331C80D3294CF70F00263BE5 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - 331C80DA294CF71000263BE5 /* PBXTargetDependency */, - ); - name = RunnerTests; - productName = RunnerTests; - productReference = 331C80D5294CF71000263BE5 /* RunnerTests.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; - 33CC10EC2044A3C60003C045 /* Runner */ = { - isa = PBXNativeTarget; - buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; - buildPhases = ( - 04B56771D78F13E7D7054D37 /* [CP] Check Pods Manifest.lock */, - 33CC10E92044A3C60003C045 /* Sources */, - 33CC10EA2044A3C60003C045 /* Frameworks */, - 33CC10EB2044A3C60003C045 /* Resources */, - 3399D490228B24CF009A79C7 /* ShellScript */, - 3AEDD360A251A3172684EAB9 /* [CP] Embed Pods Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - 33CC11202044C79F0003C045 /* PBXTargetDependency */, - ); - name = Runner; - productName = Runner; - productReference = 33CC10ED2044A3C60003C045 /* SCToolBox.app */; - productType = "com.apple.product-type.application"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 33CC10E52044A3C60003C045 /* Project object */ = { - isa = PBXProject; - attributes = { - BuildIndependentTargetsInParallel = YES; - LastSwiftUpdateCheck = 0920; - LastUpgradeCheck = 1510; - ORGANIZATIONNAME = ""; - TargetAttributes = { - 331C80D4294CF70F00263BE5 = { - CreatedOnToolsVersion = 14.0; - TestTargetID = 33CC10EC2044A3C60003C045; - }; - 33CC10EC2044A3C60003C045 = { - CreatedOnToolsVersion = 9.2; - LastSwiftMigration = 1100; - ProvisioningStyle = Automatic; - SystemCapabilities = { - com.apple.Sandbox = { - enabled = 1; - }; - }; - }; - 33CC111A2044C6BA0003C045 = { - CreatedOnToolsVersion = 9.2; - ProvisioningStyle = Manual; - }; - }; - }; - buildConfigurationList = 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */; - compatibilityVersion = "Xcode 9.3"; - developmentRegion = en; - hasScannedForEncodings = 0; - knownRegions = ( - en, - Base, - ); - mainGroup = 33CC10E42044A3C60003C045; - productRefGroup = 33CC10EE2044A3C60003C045 /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 33CC10EC2044A3C60003C045 /* Runner */, - 331C80D4294CF70F00263BE5 /* RunnerTests */, - 33CC111A2044C6BA0003C045 /* Flutter Assemble */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 331C80D3294CF70F00263BE5 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 33CC10EB2044A3C60003C045 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */, - 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXShellScriptBuildPhase section */ - 04B56771D78F13E7D7054D37 /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; - 300725451D4DD3AACE302066 /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-RunnerTests-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; - 3399D490228B24CF009A79C7 /* ShellScript */ = { - isa = PBXShellScriptBuildPhase; - alwaysOutOfDate = 1; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - ); - outputFileListPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; - }; - 33CC111E2044C6BF0003C045 /* ShellScript */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - Flutter/ephemeral/FlutterInputs.xcfilelist, - ); - inputPaths = ( - Flutter/ephemeral/tripwire, - ); - outputFileListPaths = ( - Flutter/ephemeral/FlutterOutputs.xcfilelist, - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; - }; - 3AEDD360A251A3172684EAB9 /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", - ); - name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; -/* End PBXShellScriptBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 331C80D1294CF70F00263BE5 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 33CC10E92044A3C60003C045 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */, - 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */, - 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXTargetDependency section */ - 331C80DA294CF71000263BE5 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 33CC10EC2044A3C60003C045 /* Runner */; - targetProxy = 331C80D9294CF71000263BE5 /* PBXContainerItemProxy */; - }; - 33CC11202044C79F0003C045 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 33CC111A2044C6BA0003C045 /* Flutter Assemble */; - targetProxy = 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - -/* Begin PBXVariantGroup section */ - 33CC10F42044A3C60003C045 /* MainMenu.xib */ = { - isa = PBXVariantGroup; - children = ( - 33CC10F52044A3C60003C045 /* Base */, - ); - name = MainMenu.xib; - path = Runner; - sourceTree = ""; - }; -/* End PBXVariantGroup section */ - -/* Begin XCBuildConfiguration section */ - 331C80DB294CF71000263BE5 /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 2B7928003DA956B0CA3054C5 /* Pods-RunnerTests.debug.xcconfig */; - buildSettings = { - BUNDLE_LOADER = "$(TEST_HOST)"; - CURRENT_PROJECT_VERSION = 1; - GENERATE_INFOPLIST_FILE = YES; - MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.example.app.RunnerTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 5.0; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/app.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/app"; - }; - name = Debug; - }; - 331C80DC294CF71000263BE5 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 02451A4BA4B40C760076F2B8 /* Pods-RunnerTests.release.xcconfig */; - buildSettings = { - BUNDLE_LOADER = "$(TEST_HOST)"; - CURRENT_PROJECT_VERSION = 1; - GENERATE_INFOPLIST_FILE = YES; - MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.example.app.RunnerTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 5.0; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/app.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/app"; - }; - name = Release; - }; - 331C80DD294CF71000263BE5 /* Profile */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = F0A918B7DC1C155A0EF288B7 /* Pods-RunnerTests.profile.xcconfig */; - buildSettings = { - BUNDLE_LOADER = "$(TEST_HOST)"; - CURRENT_PROJECT_VERSION = 1; - GENERATE_INFOPLIST_FILE = YES; - MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.example.app.RunnerTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 5.0; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/app.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/app"; - }; - name = Profile; - }; - 338D0CE9231458BD00FA5F75 /* Profile */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CODE_SIGN_IDENTITY = "-"; - COPY_PHASE_STRIP = NO; - DEAD_CODE_STRIPPING = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_USER_SCRIPT_SANDBOXING = NO; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.14; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = macosx; - SWIFT_COMPILATION_MODE = wholemodule; - SWIFT_OPTIMIZATION_LEVEL = "-O"; - }; - name = Profile; - }; - 338D0CEA231458BD00FA5F75 /* Profile */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CLANG_ENABLE_MODULES = YES; - CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; - CODE_SIGN_STYLE = Automatic; - COMBINE_HIDPI_IMAGES = YES; - INFOPLIST_FILE = Runner/Info.plist; - INFOPLIST_KEY_CFBundleDisplayName = SCToolBox; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/../Frameworks", - ); - MACOSX_DEPLOYMENT_TARGET = 10.15; - PRODUCT_BUNDLE_IDENTIFIER = com.xkeyc.tools.sctoolbox; - PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_VERSION = 5.0; - }; - name = Profile; - }; - 338D0CEB231458BD00FA5F75 /* Profile */ = { - isa = XCBuildConfiguration; - buildSettings = { - CODE_SIGN_STYLE = Manual; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Profile; - }; - 33CC10F92044A3C60003C045 /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CODE_SIGN_IDENTITY = "-"; - COPY_PHASE_STRIP = NO; - DEAD_CODE_STRIPPING = YES; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - ENABLE_USER_SCRIPT_SANDBOXING = NO; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.14; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = macosx; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - }; - name = Debug; - }; - 33CC10FA2044A3C60003C045 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CODE_SIGN_IDENTITY = "-"; - COPY_PHASE_STRIP = NO; - DEAD_CODE_STRIPPING = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_USER_SCRIPT_SANDBOXING = NO; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.14; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = macosx; - SWIFT_COMPILATION_MODE = wholemodule; - SWIFT_OPTIMIZATION_LEVEL = "-O"; - }; - name = Release; - }; - 33CC10FC2044A3C60003C045 /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CLANG_ENABLE_MODULES = YES; - CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; - CODE_SIGN_STYLE = Automatic; - COMBINE_HIDPI_IMAGES = YES; - INFOPLIST_FILE = Runner/Info.plist; - INFOPLIST_KEY_CFBundleDisplayName = SCToolBox; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/../Frameworks", - ); - MACOSX_DEPLOYMENT_TARGET = 10.15; - PRODUCT_BUNDLE_IDENTIFIER = com.xkeyc.tools.sctoolbox; - PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 5.0; - }; - name = Debug; - }; - 33CC10FD2044A3C60003C045 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CLANG_ENABLE_MODULES = YES; - CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; - CODE_SIGN_STYLE = Automatic; - COMBINE_HIDPI_IMAGES = YES; - INFOPLIST_FILE = Runner/Info.plist; - INFOPLIST_KEY_CFBundleDisplayName = SCToolBox; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/../Frameworks", - ); - MACOSX_DEPLOYMENT_TARGET = 10.15; - PRODUCT_BUNDLE_IDENTIFIER = com.xkeyc.tools.sctoolbox; - PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_VERSION = 5.0; - }; - name = Release; - }; - 33CC111C2044C6BA0003C045 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CODE_SIGN_STYLE = Manual; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Debug; - }; - 33CC111D2044C6BA0003C045 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CODE_SIGN_STYLE = Automatic; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 331C80DB294CF71000263BE5 /* Debug */, - 331C80DC294CF71000263BE5 /* Release */, - 331C80DD294CF71000263BE5 /* Profile */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 33CC10F92044A3C60003C045 /* Debug */, - 33CC10FA2044A3C60003C045 /* Release */, - 338D0CE9231458BD00FA5F75 /* Profile */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 33CC10FC2044A3C60003C045 /* Debug */, - 33CC10FD2044A3C60003C045 /* Release */, - 338D0CEA231458BD00FA5F75 /* Profile */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 33CC111C2044C6BA0003C045 /* Debug */, - 33CC111D2044C6BA0003C045 /* Release */, - 338D0CEB231458BD00FA5F75 /* Profile */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 33CC10E52044A3C60003C045 /* Project object */; -} diff --git a/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist deleted file mode 100644 index 18d9810..0000000 --- a/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - IDEDidComputeMac32BitWarning - - - diff --git a/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme deleted file mode 100644 index 4e26a6f..0000000 --- a/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ /dev/null @@ -1,98 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/macos/Runner.xcworkspace/contents.xcworkspacedata b/macos/Runner.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index 21a3cc1..0000000 --- a/macos/Runner.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - diff --git a/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist deleted file mode 100644 index 18d9810..0000000 --- a/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - IDEDidComputeMac32BitWarning - - - diff --git a/macos/Runner/AppDelegate.swift b/macos/Runner/AppDelegate.swift deleted file mode 100644 index d53ef64..0000000 --- a/macos/Runner/AppDelegate.swift +++ /dev/null @@ -1,9 +0,0 @@ -import Cocoa -import FlutterMacOS - -@NSApplicationMain -class AppDelegate: FlutterAppDelegate { - override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { - return true - } -} diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/1024.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/1024.png deleted file mode 100644 index c4261f1..0000000 Binary files a/macos/Runner/Assets.xcassets/AppIcon.appiconset/1024.png and /dev/null differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/128.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/128.png deleted file mode 100644 index 2755c18..0000000 Binary files a/macos/Runner/Assets.xcassets/AppIcon.appiconset/128.png and /dev/null differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/16.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/16.png deleted file mode 100644 index 5cdae44..0000000 Binary files a/macos/Runner/Assets.xcassets/AppIcon.appiconset/16.png and /dev/null differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/256.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/256.png deleted file mode 100644 index 5559258..0000000 Binary files a/macos/Runner/Assets.xcassets/AppIcon.appiconset/256.png and /dev/null differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/32.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/32.png deleted file mode 100644 index 0ad5973..0000000 Binary files a/macos/Runner/Assets.xcassets/AppIcon.appiconset/32.png and /dev/null differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/512.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/512.png deleted file mode 100644 index b11c9a2..0000000 Binary files a/macos/Runner/Assets.xcassets/AppIcon.appiconset/512.png and /dev/null differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/64.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/64.png deleted file mode 100644 index 23c17b6..0000000 Binary files a/macos/Runner/Assets.xcassets/AppIcon.appiconset/64.png and /dev/null differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json deleted file mode 100644 index 2003d5b..0000000 --- a/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json +++ /dev/null @@ -1 +0,0 @@ -{"images":[{"size":"128x128","expected-size":"128","filename":"128.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"mac","scale":"1x"},{"size":"256x256","expected-size":"256","filename":"256.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"mac","scale":"1x"},{"size":"128x128","expected-size":"256","filename":"256.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"mac","scale":"2x"},{"size":"256x256","expected-size":"512","filename":"512.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"mac","scale":"2x"},{"size":"32x32","expected-size":"32","filename":"32.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"mac","scale":"1x"},{"size":"512x512","expected-size":"512","filename":"512.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"mac","scale":"1x"},{"size":"16x16","expected-size":"16","filename":"16.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"mac","scale":"1x"},{"size":"16x16","expected-size":"32","filename":"32.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"mac","scale":"2x"},{"size":"32x32","expected-size":"64","filename":"64.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"mac","scale":"2x"},{"size":"512x512","expected-size":"1024","filename":"1024.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"mac","scale":"2x"}]} \ No newline at end of file diff --git a/macos/Runner/Base.lproj/MainMenu.xib b/macos/Runner/Base.lproj/MainMenu.xib deleted file mode 100644 index 80e867a..0000000 --- a/macos/Runner/Base.lproj/MainMenu.xib +++ /dev/null @@ -1,343 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/macos/Runner/Configs/AppInfo.xcconfig b/macos/Runner/Configs/AppInfo.xcconfig deleted file mode 100644 index 0fdc46d..0000000 --- a/macos/Runner/Configs/AppInfo.xcconfig +++ /dev/null @@ -1,14 +0,0 @@ -// Application-level settings for the Runner target. -// -// This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the -// future. If not, the values below would default to using the project name when this becomes a -// 'flutter create' template. - -// The application's name. By default this is also the title of the Flutter window. -PRODUCT_NAME = SCToolBox - -// The application's bundle identifier -PRODUCT_BUNDLE_IDENTIFIER = com.xkeyc.tools.sctoolbox - -// The copyright displayed in application information -PRODUCT_COPYRIGHT = Copyright © 2024 xkeyC Studio All rights reserved. diff --git a/macos/Runner/Configs/Debug.xcconfig b/macos/Runner/Configs/Debug.xcconfig deleted file mode 100644 index 36b0fd9..0000000 --- a/macos/Runner/Configs/Debug.xcconfig +++ /dev/null @@ -1,2 +0,0 @@ -#include "../../Flutter/Flutter-Debug.xcconfig" -#include "Warnings.xcconfig" diff --git a/macos/Runner/Configs/Release.xcconfig b/macos/Runner/Configs/Release.xcconfig deleted file mode 100644 index dff4f49..0000000 --- a/macos/Runner/Configs/Release.xcconfig +++ /dev/null @@ -1,2 +0,0 @@ -#include "../../Flutter/Flutter-Release.xcconfig" -#include "Warnings.xcconfig" diff --git a/macos/Runner/Configs/Warnings.xcconfig b/macos/Runner/Configs/Warnings.xcconfig deleted file mode 100644 index 42bcbf4..0000000 --- a/macos/Runner/Configs/Warnings.xcconfig +++ /dev/null @@ -1,13 +0,0 @@ -WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings -GCC_WARN_UNDECLARED_SELECTOR = YES -CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES -CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE -CLANG_WARN__DUPLICATE_METHOD_MATCH = YES -CLANG_WARN_PRAGMA_PACK = YES -CLANG_WARN_STRICT_PROTOTYPES = YES -CLANG_WARN_COMMA = YES -GCC_WARN_STRICT_SELECTOR_MATCH = YES -CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES -CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES -GCC_WARN_SHADOW = YES -CLANG_WARN_UNREACHABLE_CODE = YES diff --git a/macos/Runner/DebugProfile.entitlements b/macos/Runner/DebugProfile.entitlements deleted file mode 100644 index 91f41fb..0000000 --- a/macos/Runner/DebugProfile.entitlements +++ /dev/null @@ -1,18 +0,0 @@ - - - - - com.apple.security.app-sandbox - - com.apple.security.cs.allow-jit - - com.apple.security.files.downloads.read-write - - com.apple.security.files.user-selected.read-write - - com.apple.security.network.client - - com.apple.security.network.server - - - diff --git a/macos/Runner/Info.plist b/macos/Runner/Info.plist deleted file mode 100644 index 90a8d29..0000000 --- a/macos/Runner/Info.plist +++ /dev/null @@ -1,37 +0,0 @@ - - - - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIconFile - - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - APPL - CFBundleShortVersionString - $(FLUTTER_BUILD_NAME) - CFBundleVersion - $(FLUTTER_BUILD_NUMBER) - LSMinimumSystemVersion - $(MACOSX_DEPLOYMENT_TARGET) - NSAppTransportSecurity - - NSAllowsArbitraryLoads - - - NSHumanReadableCopyright - $(PRODUCT_COPYRIGHT) - NSMainNibFile - MainMenu - NSPrincipalClass - NSApplication - - diff --git a/macos/Runner/MainFlutterWindow.swift b/macos/Runner/MainFlutterWindow.swift deleted file mode 100644 index 3cc05eb..0000000 --- a/macos/Runner/MainFlutterWindow.swift +++ /dev/null @@ -1,15 +0,0 @@ -import Cocoa -import FlutterMacOS - -class MainFlutterWindow: NSWindow { - override func awakeFromNib() { - let flutterViewController = FlutterViewController() - let windowFrame = self.frame - self.contentViewController = flutterViewController - self.setFrame(windowFrame, display: true) - - RegisterGeneratedPlugins(registry: flutterViewController) - - super.awakeFromNib() - } -} diff --git a/macos/Runner/Release.entitlements b/macos/Runner/Release.entitlements deleted file mode 100644 index 02ce7ec..0000000 --- a/macos/Runner/Release.entitlements +++ /dev/null @@ -1,16 +0,0 @@ - - - - - com.apple.security.app-sandbox - - com.apple.security.files.downloads.read-write - - com.apple.security.files.user-selected.read-write - - com.apple.security.network.client - - com.apple.security.network.server - - - diff --git a/macos/RunnerTests/RunnerTests.swift b/macos/RunnerTests/RunnerTests.swift deleted file mode 100644 index 61f3bd1..0000000 --- a/macos/RunnerTests/RunnerTests.swift +++ /dev/null @@ -1,12 +0,0 @@ -import Cocoa -import FlutterMacOS -import XCTest - -class RunnerTests: XCTestCase { - - func testExample() { - // If you add code to the Runner application, consider adding tests here. - // See https://developer.apple.com/documentation/xctest for more information about using XCTest. - } - -} diff --git a/pubspec.yaml b/pubspec.yaml index ed60d01..a319cd7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,7 +5,7 @@ publish_to: 'none' version: 1.0.0+1 environment: - sdk: '>=3.0.0 <4.0.0' + sdk: ^3.5.1 dependencies: flutter: @@ -18,23 +18,18 @@ dependencies: hooks_riverpod: ^2.4.10 json_annotation: ^4.8.1 go_router: ^14.0.1 - window_manager: ^0.4.0 fluent_ui: ^4.8.6 flutter_staggered_grid_view: ^0.7.0 - flutter_acrylic: ^1.1.4 url_launcher: ^6.1.10 font_awesome_flutter: ^10.5.0 cupertino_icons: ^1.0.2 hive: ^2.2.3 - path_provider: ^2.1.1 dio: ^5.3.3 markdown: ^7.2.1 markdown_widget: ^2.2.0 extended_image: ^8.2.0 - device_info_plus: ^10.0.1 file_picker: ^8.0.0+1 file_sizes: ^1.0.6 - desktop_webview_window: ^0.2.3 flutter_svg: ^2.0.7 archive: ^3.4.4 jwt_decode: ^0.3.1 @@ -50,17 +45,12 @@ dependencies: html: ^0.15.4 xml: ^6.5.0 fixnum: ^1.1.0 - protobuf: ^3.1.0 - grpc: ^4.0.0 rust_builder: path: rust_builder - aria2: - git: https://github.com/xkeyC/dart_aria2_rpc.git # path: ../../xkeyC/dart_aria2_rpc intl: ^0.19.0 synchronized: ^3.1.0+1 super_sliver_list: ^0.4.1 - file: ^7.0.0 re_editor: ^0.3.0 re_highlight: ^0.0.3 dependency_overrides: @@ -87,24 +77,13 @@ flutter: uses-material-design: true assets: - assets/ - - assets/binary/ - assets/countdown/ + - assets/backgrounds/ fonts: - family: SourceHanSansCN-Regular fonts: - asset: assets/SourceHanSansCN-Regular.otf -msix_config: - display_name: SC汉化盒子 - publisher_display_name: xkeyC Studio - identity_name: 56575xkeyC.MSE - publisher: CN=B54C897B-C263-4680-B6AB-4913C603DF87 - msix_version: 2.12.0.0 - logo_path: ./assets/app_logo.png - capabilities: internetClient,allowElevation - languages: zh-cn - windows_build_args: --dart-define="MSE=true" - store: true flutter_intl: enabled: true \ No newline at end of file diff --git a/rust/Cargo.toml b/rust/Cargo.toml index d0b26ee..6af425d 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -12,18 +12,8 @@ crate-type = ["cdylib", "staticlib"] [dependencies] flutter_rust_bridge = "=2.3.0" -tokio = { version = "1", features = ["rt", "rt-multi-thread", "macros", "process"] } -futures = { version = "0.3", default-features = false, features = ["executor"] } -url = "2.5" once_cell = "1.19" -reqwest = { version = "0.12", features = ["rustls-tls-webpki-roots", "cookies", "gzip", "json", "stream"] } -hickory-resolver = { version = "0.24" } +reqwest = { version = "0.12", features = ["json", "stream"] } anyhow = "1.0" scopeguard = "1.2" -notify-rust = "4" -asar = "0.3.0" - -[target.'cfg(windows)'.dependencies] -windows = { version = "0.58.0", features = ["Win32_UI_WindowsAndMessaging"] } -win32job = "2" diff --git a/rust/src/api/asar_api.rs b/rust/src/api/asar_api.rs deleted file mode 100644 index 66be349..0000000 --- a/rust/src/api/asar_api.rs +++ /dev/null @@ -1,52 +0,0 @@ -use std::fs::File; - -use asar::{AsarReader, AsarWriter}; -use tokio::fs; - -pub struct RsiLauncherAsarData { - pub asar_path: String, - pub main_js_path: String, - pub main_js_content: Vec, -} - -impl RsiLauncherAsarData { - pub async fn write_main_js(&self, content: Vec) -> anyhow::Result<()> { - let mut asar_writer = AsarWriter::new(); - let asar_mem_file = fs::read(self.asar_path.clone()).await?; - let asar = AsarReader::new(&asar_mem_file, None)?; - asar.files().iter().for_each(|v| { - let (path, file) = v; - let path_string = path.clone().into_os_string().into_string().unwrap(); - if path_string == self.main_js_path { - asar_writer.write_file(path, &content, true).unwrap(); - } else { - asar_writer.write_file(path, file.data(), true).unwrap(); - } - }); - // rm old asar - fs::remove_file(&self.asar_path).await?; - // write new asar - asar_writer.finalize(File::create(&self.asar_path)?)?; - Ok(()) - } -} - -pub async fn get_rsi_launcher_asar_data(asar_path: &str) -> anyhow::Result { - let asar_mem_file = fs::read(asar_path).await?; - let asar = AsarReader::new(&asar_mem_file, None)?; - let mut main_js_path = String::from(""); - let mut main_js_content: Vec = Vec::new(); - asar.files().iter().for_each(|v| { - let (path, file) = v; - let path_string = path.clone().into_os_string().into_string().unwrap(); - if path_string.starts_with("app\\static\\js\\main.") && path_string.ends_with(".js") { - main_js_path = path_string; - main_js_content = file.data().to_vec(); - } - }); - Ok(RsiLauncherAsarData { - asar_path: asar_path.to_string(), - main_js_path, - main_js_content, - }) -} \ No newline at end of file diff --git a/rust/src/api/http_api.rs b/rust/src/api/http_api.rs index c19729c..e03008f 100644 --- a/rust/src/api/http_api.rs +++ b/rust/src/api/http_api.rs @@ -16,7 +16,7 @@ pub enum MyMethod { } fn _my_method_to_hyper_method(m: MyMethod) -> Method { - return match m { + match m { MyMethod::Options => Method::OPTIONS, MyMethod::Gets => Method::GET, MyMethod::Post => Method::POST, @@ -26,7 +26,7 @@ fn _my_method_to_hyper_method(m: MyMethod) -> Method { MyMethod::Trace => Method::TRACE, MyMethod::Connect => Method::CONNECT, MyMethod::Patch => Method::PATCH, - }; + } } pub fn set_default_header(headers: HashMap) { @@ -38,22 +38,12 @@ pub async fn fetch( url: String, headers: Option>, input_data: Option>, - with_ip_address: Option, ) -> anyhow::Result { http_package::fetch( _my_method_to_hyper_method(method), url, headers, input_data, - with_ip_address, ) - .await -} - -pub async fn dns_lookup_txt(host: String) -> anyhow::Result> { - http_package::dns_lookup_txt(host).await -} - -pub async fn dns_lookup_ips(host: String) -> anyhow::Result> { - http_package::dns_lookup_ips(host).await + .await } diff --git a/rust/src/api/mod.rs b/rust/src/api/mod.rs index cb0e8f9..4aad6df 100644 --- a/rust/src/api/mod.rs +++ b/rust/src/api/mod.rs @@ -2,6 +2,3 @@ // Do not put code in `mod.rs`, but put in e.g. `simple.rs`. // pub mod http_api; -pub mod rs_process; -pub mod win32_api; -pub mod asar_api; diff --git a/rust/src/api/rs_process.rs b/rust/src/api/rs_process.rs deleted file mode 100644 index 043d40b..0000000 --- a/rust/src/api/rs_process.rs +++ /dev/null @@ -1,180 +0,0 @@ -use std::collections::HashMap; -use std::sync::Arc; -use flutter_rust_bridge::frb; -use futures::executor::block_on; -use once_cell::sync::Lazy; -use scopeguard::defer; -use tokio::io::AsyncBufReadExt; -use tokio::io::AsyncWriteExt; -use tokio::io::BufReader; -use tokio::process::ChildStdin; -use tokio::sync::Mutex; - -use crate::frb_generated::StreamSink; - -#[derive(Clone, Copy)] -pub enum RsProcessStreamDataType { - Output, - Error, - Exit, -} - -pub struct RsProcessStreamData { - pub data_type: RsProcessStreamDataType, - pub data: String, - pub rs_pid: u32, -} - -#[frb(non_opaque)] -pub struct RsProcess { - pub child_stdin: ChildStdin, - pub rs_pid: u32, -} - -static RS_PROCESS_MAP: Lazy>> = Lazy::new(|| Mutex::new(HashMap::new())); - -pub async fn start( - executable: &str, - arguments: Vec, - working_directory: &str, - stream_sink: StreamSink, -) { - let stream_sink_arc = Arc::from(stream_sink); - let mut command = tokio::process::Command::new(executable); - command - .args(arguments) - .current_dir(working_directory) - .stdin(std::process::Stdio::piped()) - .stdout(std::process::Stdio::piped()) - .stderr(std::process::Stdio::piped()) - .kill_on_drop(true); - #[cfg(target_os = "windows")] - command.creation_flags(0x08000000); - - #[cfg(target_os = "windows")] - let job = win32job::Job::create().unwrap(); - #[cfg(target_os = "windows")] - let mut info = job.query_extended_limit_info().unwrap(); - #[cfg(target_os = "windows")] - info.limit_kill_on_job_close(); - #[cfg(target_os = "windows")] - job.set_extended_limit_info(&mut info).unwrap(); - - #[cfg(target_os = "windows")] - let job_arc = Arc::from(job); - - if let Ok(mut child) = command.spawn() { - #[cfg(target_os = "windows")] - { - let raw_handle = child.raw_handle(); - if raw_handle.is_some() { - job_arc - .assign_process(raw_handle.unwrap() as isize) - .unwrap(); - } - } - let stdin = child - .stdin - .take() - .expect("[rs_process] Failed to open stdin"); - let pid = child.id().expect("[rs_process] Failed to get pid"); - { - let mut map = RS_PROCESS_MAP.lock().await; - map.insert( - pid, - RsProcess { - child_stdin: stdin, - rs_pid: pid, - }, - ); - } - - defer! { - let mut map = block_on(RS_PROCESS_MAP.lock()); - map.remove(&pid); - println!("RS_PROCESS_MAP ..defer ..len() = {}", map.len()); - } - - let stdout = child - .stdout - .take() - .expect("[rs_process] Failed to open stdout"); - let stderr = child - .stderr - .take() - .expect("[rs_process] Failed to open stderr"); - - let output_task = tokio::spawn(_process_output( - stdout, - stream_sink_arc.clone(), - RsProcessStreamDataType::Output, - pid, - )); - let error_task = tokio::spawn(_process_output( - stderr, - stream_sink_arc.clone(), - RsProcessStreamDataType::Error, - pid, - )); - - tokio::select! {_ = output_task => (), _ = error_task => () } - - let exit_status = child - .wait() - .await - .expect("[rs_process] Failed to wait for child process"); - - if !exit_status.success() { - println!( - "[rs_process] Child process exited with an error: {:?}", - exit_status - ); - let message = RsProcessStreamData { - data_type: RsProcessStreamDataType::Exit, - data: "exit".to_string(), - rs_pid: pid, - }; - stream_sink_arc.add(message).unwrap(); - } - } else { - println!("Failed to start"); - let message = RsProcessStreamData { - data_type: RsProcessStreamDataType::Error, - data: "Failed to start".to_string(), - rs_pid: 0, - }; - stream_sink_arc.add(message).unwrap(); - } -} - - -pub async fn write(rs_pid: &u32, data: String) { - let mut map = RS_PROCESS_MAP.lock().await; - let process = map.get_mut(rs_pid).unwrap(); - process - .child_stdin - .write_all(data.as_bytes()) - .await - .unwrap(); -} - -async fn _process_output( - stdout: R, - stream_sink: Arc>, - data_type: RsProcessStreamDataType, - pid: u32, -) where - R: tokio::io::AsyncRead + Unpin, -{ - let reader = BufReader::new(stdout); - let mut lines = reader.lines(); - - while let Some(line) = lines.next_line().await.unwrap() { - let message = RsProcessStreamData { - data_type, - data: line.trim().parse().unwrap(), - rs_pid: pid, - }; - stream_sink.add(message).unwrap(); - } -} diff --git a/rust/src/api/win32_api.rs b/rust/src/api/win32_api.rs deleted file mode 100644 index aea7837..0000000 --- a/rust/src/api/win32_api.rs +++ /dev/null @@ -1,52 +0,0 @@ -use notify_rust::Notification; - -pub fn send_notify( - summary: Option, - body: Option, - app_name: Option, - app_id: Option, -) -> anyhow::Result<()> { - let mut n = Notification::new(); - if let Some(summary) = summary { - n.summary(&summary); - } - if let Some(body) = body { - n.body(&body); - } - if let Some(app_name) = app_name { - n.appname(&app_name); - } - #[cfg(target_os = "windows")] - if let Some(app_id) = app_id { - n.app_id(&app_id); - } - #[cfg(not(target_os = "windows"))] - println!("send_notify (unix) appid: {:?}", app_id); - n.show()?; - Ok(()) -} - - -#[cfg(target_os = "windows")] -pub fn set_foreground_window(window_name: &str) -> anyhow::Result { - use windows::core::{HSTRING, PCWSTR}; - use windows::Win32::Foundation::HWND; - use windows::Win32::UI::WindowsAndMessaging; - let window_name_p: PCWSTR = PCWSTR(HSTRING::from(window_name).as_ptr()); - let h = unsafe { WindowsAndMessaging::FindWindowW(PCWSTR::null(), window_name_p)? }; - if h == HWND::default() { - return Ok(false); - } - let sr = unsafe { WindowsAndMessaging::ShowWindow(h, WindowsAndMessaging::SW_RESTORE) }; - if !sr.as_bool() { - return Ok(false); - } - let r = unsafe { WindowsAndMessaging::SetForegroundWindow(h) }; - Ok(r.as_bool()) -} - -#[cfg(not(target_os = "windows"))] -pub fn set_foreground_window(window_name: &str) -> anyhow::Result { - println!("set_foreground_window (unix): {}", window_name); - return Ok(false); -} \ No newline at end of file diff --git a/rust/src/frb_generated.rs b/rust/src/frb_generated.rs index d1a6ae9..d5d9bf0 100644 --- a/rust/src/frb_generated.rs +++ b/rust/src/frb_generated.rs @@ -37,7 +37,7 @@ flutter_rust_bridge::frb_generated_boilerplate!( default_rust_auto_opaque = RustAutoOpaqueNom, ); pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_VERSION: &str = "2.3.0"; -pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_CONTENT_HASH: i32 = 1832496273; +pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_CONTENT_HASH: i32 = -669496402; // Section: executor @@ -45,117 +45,12 @@ flutter_rust_bridge::frb_generated_default_handler!(); // Section: wire_funcs -fn wire__crate__api__asar_api__get_rsi_launcher_asar_data_impl( - port_: flutter_rust_bridge::for_generated::MessagePort, - asar_path: impl CstDecode, -) { - FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::( - flutter_rust_bridge::for_generated::TaskInfo { - debug_name: "get_rsi_launcher_asar_data", - port: Some(port_), - mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, - }, - move || { - let api_asar_path = asar_path.cst_decode(); - move |context| async move { - transform_result_dco::<_, _, flutter_rust_bridge::for_generated::anyhow::Error>( - (move || async move { - let output_ok = - crate::api::asar_api::get_rsi_launcher_asar_data(&api_asar_path) - .await?; - Ok(output_ok) - })() - .await, - ) - } - }, - ) -} -fn wire__crate__api__asar_api__rsi_launcher_asar_data_write_main_js_impl( - port_: flutter_rust_bridge::for_generated::MessagePort, - that: impl CstDecode, - content: impl CstDecode>, -) { - FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::( - flutter_rust_bridge::for_generated::TaskInfo { - debug_name: "rsi_launcher_asar_data_write_main_js", - port: Some(port_), - mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, - }, - move || { - let api_that = that.cst_decode(); - let api_content = content.cst_decode(); - move |context| async move { - transform_result_dco::<_, _, flutter_rust_bridge::for_generated::anyhow::Error>( - (move || async move { - let output_ok = crate::api::asar_api::RsiLauncherAsarData::write_main_js( - &api_that, - api_content, - ) - .await?; - Ok(output_ok) - })() - .await, - ) - } - }, - ) -} -fn wire__crate__api__http_api__dns_lookup_ips_impl( - port_: flutter_rust_bridge::for_generated::MessagePort, - host: impl CstDecode, -) { - FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::( - flutter_rust_bridge::for_generated::TaskInfo { - debug_name: "dns_lookup_ips", - port: Some(port_), - mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, - }, - move || { - let api_host = host.cst_decode(); - move |context| async move { - transform_result_dco::<_, _, flutter_rust_bridge::for_generated::anyhow::Error>( - (move || async move { - let output_ok = crate::api::http_api::dns_lookup_ips(api_host).await?; - Ok(output_ok) - })() - .await, - ) - } - }, - ) -} -fn wire__crate__api__http_api__dns_lookup_txt_impl( - port_: flutter_rust_bridge::for_generated::MessagePort, - host: impl CstDecode, -) { - FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::( - flutter_rust_bridge::for_generated::TaskInfo { - debug_name: "dns_lookup_txt", - port: Some(port_), - mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, - }, - move || { - let api_host = host.cst_decode(); - move |context| async move { - transform_result_dco::<_, _, flutter_rust_bridge::for_generated::anyhow::Error>( - (move || async move { - let output_ok = crate::api::http_api::dns_lookup_txt(api_host).await?; - Ok(output_ok) - })() - .await, - ) - } - }, - ) -} fn wire__crate__api__http_api__fetch_impl( port_: flutter_rust_bridge::for_generated::MessagePort, method: impl CstDecode, url: impl CstDecode, headers: impl CstDecode>>, input_data: impl CstDecode>>, - with_ip_address: impl CstDecode>, ) { FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::( flutter_rust_bridge::for_generated::TaskInfo { @@ -168,7 +63,6 @@ fn wire__crate__api__http_api__fetch_impl( let api_url = url.cst_decode(); let api_headers = headers.cst_decode(); let api_input_data = input_data.cst_decode(); - let api_with_ip_address = with_ip_address.cst_decode(); move |context| async move { transform_result_dco::<_, _, flutter_rust_bridge::for_generated::anyhow::Error>( (move || async move { @@ -177,7 +71,6 @@ fn wire__crate__api__http_api__fetch_impl( api_url, api_headers, api_input_data, - api_with_ip_address, ) .await?; Ok(output_ok) @@ -211,164 +104,15 @@ fn wire__crate__api__http_api__set_default_header_impl( }, ) } -fn wire__crate__api__rs_process__start_impl( - port_: flutter_rust_bridge::for_generated::MessagePort, - executable: impl CstDecode, - arguments: impl CstDecode>, - working_directory: impl CstDecode, - stream_sink: impl CstDecode< - StreamSink< - crate::api::rs_process::RsProcessStreamData, - flutter_rust_bridge::for_generated::DcoCodec, - >, - >, -) { - FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::( - flutter_rust_bridge::for_generated::TaskInfo { - debug_name: "start", - port: Some(port_), - mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, - }, - move || { - let api_executable = executable.cst_decode(); - let api_arguments = arguments.cst_decode(); - let api_working_directory = working_directory.cst_decode(); - let api_stream_sink = stream_sink.cst_decode(); - move |context| async move { - transform_result_dco::<_, _, ()>( - (move || async move { - let output_ok = Result::<_, ()>::Ok({ - crate::api::rs_process::start( - &api_executable, - api_arguments, - &api_working_directory, - api_stream_sink, - ) - .await; - })?; - Ok(output_ok) - })() - .await, - ) - } - }, - ) -} -fn wire__crate__api__rs_process__write_impl( - port_: flutter_rust_bridge::for_generated::MessagePort, - rs_pid: impl CstDecode, - data: impl CstDecode, -) { - FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::( - flutter_rust_bridge::for_generated::TaskInfo { - debug_name: "write", - port: Some(port_), - mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, - }, - move || { - let api_rs_pid = rs_pid.cst_decode(); - let api_data = data.cst_decode(); - move |context| async move { - transform_result_dco::<_, _, ()>( - (move || async move { - let output_ok = Result::<_, ()>::Ok({ - crate::api::rs_process::write(&api_rs_pid, api_data).await; - })?; - Ok(output_ok) - })() - .await, - ) - } - }, - ) -} -fn wire__crate__api__win32_api__send_notify_impl( - port_: flutter_rust_bridge::for_generated::MessagePort, - summary: impl CstDecode>, - body: impl CstDecode>, - app_name: impl CstDecode>, - app_id: impl CstDecode>, -) { - FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::( - flutter_rust_bridge::for_generated::TaskInfo { - debug_name: "send_notify", - port: Some(port_), - mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, - }, - move || { - let api_summary = summary.cst_decode(); - let api_body = body.cst_decode(); - let api_app_name = app_name.cst_decode(); - let api_app_id = app_id.cst_decode(); - move |context| { - transform_result_dco::<_, _, flutter_rust_bridge::for_generated::anyhow::Error>( - (move || { - let output_ok = crate::api::win32_api::send_notify( - api_summary, - api_body, - api_app_name, - api_app_id, - )?; - Ok(output_ok) - })(), - ) - } - }, - ) -} -fn wire__crate__api__win32_api__set_foreground_window_impl( - port_: flutter_rust_bridge::for_generated::MessagePort, - window_name: impl CstDecode, -) { - FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::( - flutter_rust_bridge::for_generated::TaskInfo { - debug_name: "set_foreground_window", - port: Some(port_), - mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, - }, - move || { - let api_window_name = window_name.cst_decode(); - move |context| { - transform_result_dco::<_, _, flutter_rust_bridge::for_generated::anyhow::Error>( - (move || { - let output_ok = - crate::api::win32_api::set_foreground_window(&api_window_name)?; - Ok(output_ok) - })(), - ) - } - }, - ) -} // Section: dart2rust -impl CstDecode for bool { - // Codec=Cst (C-struct based), see doc to use other codecs - fn cst_decode(self) -> bool { - self - } -} impl CstDecode for i32 { // Codec=Cst (C-struct based), see doc to use other codecs fn cst_decode(self) -> i32 { self } } -impl CstDecode for i32 { - // Codec=Cst (C-struct based), see doc to use other codecs - fn cst_decode(self) -> crate::http_package::MyHttpVersion { - match self { - 0 => crate::http_package::MyHttpVersion::HTTP_09, - 1 => crate::http_package::MyHttpVersion::HTTP_10, - 2 => crate::http_package::MyHttpVersion::HTTP_11, - 3 => crate::http_package::MyHttpVersion::HTTP_2, - 4 => crate::http_package::MyHttpVersion::HTTP_3, - 5 => crate::http_package::MyHttpVersion::HTTP_UNKNOWN, - _ => unreachable!("Invalid variant for MyHttpVersion: {}", self), - } - } -} impl CstDecode for i32 { // Codec=Cst (C-struct based), see doc to use other codecs fn cst_decode(self) -> crate::api::http_api::MyMethod { @@ -386,29 +130,12 @@ impl CstDecode for i32 { } } } -impl CstDecode for i32 { - // Codec=Cst (C-struct based), see doc to use other codecs - fn cst_decode(self) -> crate::api::rs_process::RsProcessStreamDataType { - match self { - 0 => crate::api::rs_process::RsProcessStreamDataType::Output, - 1 => crate::api::rs_process::RsProcessStreamDataType::Error, - 2 => crate::api::rs_process::RsProcessStreamDataType::Exit, - _ => unreachable!("Invalid variant for RsProcessStreamDataType: {}", self), - } - } -} impl CstDecode for u16 { // Codec=Cst (C-struct based), see doc to use other codecs fn cst_decode(self) -> u16 { self } } -impl CstDecode for u32 { - // Codec=Cst (C-struct based), see doc to use other codecs - fn cst_decode(self) -> u32 { - self - } -} impl CstDecode for u64 { // Codec=Cst (C-struct based), see doc to use other codecs fn cst_decode(self) -> u64 { @@ -437,19 +164,6 @@ impl SseDecode for std::collections::HashMap { } } -impl SseDecode - for StreamSink< - crate::api::rs_process::RsProcessStreamData, - flutter_rust_bridge::for_generated::DcoCodec, - > -{ - // Codec=Sse (Serialization based), see doc to use other codecs - fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { - let mut inner = ::sse_decode(deserializer); - return StreamSink::deserialize(inner); - } -} - impl SseDecode for String { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { @@ -458,13 +172,6 @@ impl SseDecode for String { } } -impl SseDecode for bool { - // Codec=Sse (Serialization based), see doc to use other codecs - fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { - deserializer.cursor.read_u8().unwrap() != 0 - } -} - impl SseDecode for i32 { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { @@ -472,18 +179,6 @@ impl SseDecode for i32 { } } -impl SseDecode for Vec { - // Codec=Sse (Serialization based), see doc to use other codecs - fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { - let mut len_ = ::sse_decode(deserializer); - let mut ans_ = vec![]; - for idx_ in 0..len_ { - ans_.push(::sse_decode(deserializer)); - } - return ans_; - } -} - impl SseDecode for Vec { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { @@ -508,22 +203,6 @@ impl SseDecode for Vec<(String, String)> { } } -impl SseDecode for crate::http_package::MyHttpVersion { - // Codec=Sse (Serialization based), see doc to use other codecs - fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { - let mut inner = ::sse_decode(deserializer); - return match inner { - 0 => crate::http_package::MyHttpVersion::HTTP_09, - 1 => crate::http_package::MyHttpVersion::HTTP_10, - 2 => crate::http_package::MyHttpVersion::HTTP_11, - 3 => crate::http_package::MyHttpVersion::HTTP_2, - 4 => crate::http_package::MyHttpVersion::HTTP_3, - 5 => crate::http_package::MyHttpVersion::HTTP_UNKNOWN, - _ => unreachable!("Invalid variant for MyHttpVersion: {}", inner), - }; - } -} - impl SseDecode for crate::api::http_api::MyMethod { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { @@ -556,17 +235,6 @@ impl SseDecode for Option> { } } -impl SseDecode for Option { - // Codec=Sse (Serialization based), see doc to use other codecs - fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { - if (::sse_decode(deserializer)) { - return Some(::sse_decode(deserializer)); - } else { - return None; - } - } -} - impl SseDecode for Option { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { @@ -598,48 +266,6 @@ impl SseDecode for (String, String) { } } -impl SseDecode for crate::api::rs_process::RsProcessStreamData { - // Codec=Sse (Serialization based), see doc to use other codecs - fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { - let mut var_dataType = - ::sse_decode(deserializer); - let mut var_data = ::sse_decode(deserializer); - let mut var_rsPid = ::sse_decode(deserializer); - return crate::api::rs_process::RsProcessStreamData { - data_type: var_dataType, - data: var_data, - rs_pid: var_rsPid, - }; - } -} - -impl SseDecode for crate::api::rs_process::RsProcessStreamDataType { - // Codec=Sse (Serialization based), see doc to use other codecs - fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { - let mut inner = ::sse_decode(deserializer); - return match inner { - 0 => crate::api::rs_process::RsProcessStreamDataType::Output, - 1 => crate::api::rs_process::RsProcessStreamDataType::Error, - 2 => crate::api::rs_process::RsProcessStreamDataType::Exit, - _ => unreachable!("Invalid variant for RsProcessStreamDataType: {}", inner), - }; - } -} - -impl SseDecode for crate::api::asar_api::RsiLauncherAsarData { - // Codec=Sse (Serialization based), see doc to use other codecs - fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { - let mut var_asarPath = ::sse_decode(deserializer); - let mut var_mainJsPath = ::sse_decode(deserializer); - let mut var_mainJsContent = >::sse_decode(deserializer); - return crate::api::asar_api::RsiLauncherAsarData { - asar_path: var_asarPath, - main_js_path: var_mainJsPath, - main_js_content: var_mainJsContent, - }; - } -} - impl SseDecode for crate::http_package::RustHttpResponse { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { @@ -647,16 +273,12 @@ impl SseDecode for crate::http_package::RustHttpResponse { let mut var_headers = >::sse_decode(deserializer); let mut var_url = ::sse_decode(deserializer); let mut var_contentLength = >::sse_decode(deserializer); - let mut var_version = ::sse_decode(deserializer); - let mut var_remoteAddr = ::sse_decode(deserializer); let mut var_data = >>::sse_decode(deserializer); return crate::http_package::RustHttpResponse { status_code: var_statusCode, headers: var_headers, url: var_url, content_length: var_contentLength, - version: var_version, - remote_addr: var_remoteAddr, data: var_data, }; } @@ -669,13 +291,6 @@ impl SseDecode for u16 { } } -impl SseDecode for u32 { - // Codec=Sse (Serialization based), see doc to use other codecs - fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { - deserializer.cursor.read_u32::().unwrap() - } -} - impl SseDecode for u64 { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { @@ -695,6 +310,13 @@ impl SseDecode for () { fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {} } +impl SseDecode for bool { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + deserializer.cursor.read_u8().unwrap() != 0 + } +} + fn pde_ffi_dispatcher_primary_impl( func_id: i32, port: flutter_rust_bridge::for_generated::MessagePort, @@ -722,31 +344,6 @@ fn pde_ffi_dispatcher_sync_impl( // Section: rust2dart -// Codec=Dco (DartCObject based), see doc to use other codecs -impl flutter_rust_bridge::IntoDart for crate::http_package::MyHttpVersion { - fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { - match self { - Self::HTTP_09 => 0.into_dart(), - Self::HTTP_10 => 1.into_dart(), - Self::HTTP_11 => 2.into_dart(), - Self::HTTP_2 => 3.into_dart(), - Self::HTTP_3 => 4.into_dart(), - Self::HTTP_UNKNOWN => 5.into_dart(), - _ => unreachable!(), - } - } -} -impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive - for crate::http_package::MyHttpVersion -{ -} -impl flutter_rust_bridge::IntoIntoDart - for crate::http_package::MyHttpVersion -{ - fn into_into_dart(self) -> crate::http_package::MyHttpVersion { - self - } -} // Codec=Dco (DartCObject based), see doc to use other codecs impl flutter_rust_bridge::IntoDart for crate::api::http_api::MyMethod { fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { @@ -776,72 +373,6 @@ impl flutter_rust_bridge::IntoIntoDart } } // Codec=Dco (DartCObject based), see doc to use other codecs -impl flutter_rust_bridge::IntoDart for crate::api::rs_process::RsProcessStreamData { - fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { - [ - self.data_type.into_into_dart().into_dart(), - self.data.into_into_dart().into_dart(), - self.rs_pid.into_into_dart().into_dart(), - ] - .into_dart() - } -} -impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive - for crate::api::rs_process::RsProcessStreamData -{ -} -impl flutter_rust_bridge::IntoIntoDart - for crate::api::rs_process::RsProcessStreamData -{ - fn into_into_dart(self) -> crate::api::rs_process::RsProcessStreamData { - self - } -} -// Codec=Dco (DartCObject based), see doc to use other codecs -impl flutter_rust_bridge::IntoDart for crate::api::rs_process::RsProcessStreamDataType { - fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { - match self { - Self::Output => 0.into_dart(), - Self::Error => 1.into_dart(), - Self::Exit => 2.into_dart(), - _ => unreachable!(), - } - } -} -impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive - for crate::api::rs_process::RsProcessStreamDataType -{ -} -impl flutter_rust_bridge::IntoIntoDart - for crate::api::rs_process::RsProcessStreamDataType -{ - fn into_into_dart(self) -> crate::api::rs_process::RsProcessStreamDataType { - self - } -} -// Codec=Dco (DartCObject based), see doc to use other codecs -impl flutter_rust_bridge::IntoDart for crate::api::asar_api::RsiLauncherAsarData { - fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { - [ - self.asar_path.into_into_dart().into_dart(), - self.main_js_path.into_into_dart().into_dart(), - self.main_js_content.into_into_dart().into_dart(), - ] - .into_dart() - } -} -impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive - for crate::api::asar_api::RsiLauncherAsarData -{ -} -impl flutter_rust_bridge::IntoIntoDart - for crate::api::asar_api::RsiLauncherAsarData -{ - fn into_into_dart(self) -> crate::api::asar_api::RsiLauncherAsarData { - self - } -} -// Codec=Dco (DartCObject based), see doc to use other codecs impl flutter_rust_bridge::IntoDart for crate::http_package::RustHttpResponse { fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { [ @@ -849,8 +380,6 @@ impl flutter_rust_bridge::IntoDart for crate::http_package::RustHttpResponse { self.headers.into_into_dart().into_dart(), self.url.into_into_dart().into_dart(), self.content_length.into_into_dart().into_dart(), - self.version.into_into_dart().into_dart(), - self.remote_addr.into_into_dart().into_dart(), self.data.into_into_dart().into_dart(), ] .into_dart() @@ -882,18 +411,6 @@ impl SseEncode for std::collections::HashMap { } } -impl SseEncode - for StreamSink< - crate::api::rs_process::RsProcessStreamData, - flutter_rust_bridge::for_generated::DcoCodec, - > -{ - // Codec=Sse (Serialization based), see doc to use other codecs - fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { - unimplemented!("") - } -} - impl SseEncode for String { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { @@ -901,13 +418,6 @@ impl SseEncode for String { } } -impl SseEncode for bool { - // Codec=Sse (Serialization based), see doc to use other codecs - fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { - serializer.cursor.write_u8(self as _).unwrap(); - } -} - impl SseEncode for i32 { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { @@ -915,16 +425,6 @@ impl SseEncode for i32 { } } -impl SseEncode for Vec { - // Codec=Sse (Serialization based), see doc to use other codecs - fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { - ::sse_encode(self.len() as _, serializer); - for item in self { - ::sse_encode(item, serializer); - } - } -} - impl SseEncode for Vec { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { @@ -945,26 +445,6 @@ impl SseEncode for Vec<(String, String)> { } } -impl SseEncode for crate::http_package::MyHttpVersion { - // Codec=Sse (Serialization based), see doc to use other codecs - fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { - ::sse_encode( - match self { - crate::http_package::MyHttpVersion::HTTP_09 => 0, - crate::http_package::MyHttpVersion::HTTP_10 => 1, - crate::http_package::MyHttpVersion::HTTP_11 => 2, - crate::http_package::MyHttpVersion::HTTP_2 => 3, - crate::http_package::MyHttpVersion::HTTP_3 => 4, - crate::http_package::MyHttpVersion::HTTP_UNKNOWN => 5, - _ => { - unimplemented!(""); - } - }, - serializer, - ); - } -} - impl SseEncode for crate::api::http_api::MyMethod { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { @@ -998,16 +478,6 @@ impl SseEncode for Option> { } } -impl SseEncode for Option { - // Codec=Sse (Serialization based), see doc to use other codecs - fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { - ::sse_encode(self.is_some(), serializer); - if let Some(value) = self { - ::sse_encode(value, serializer); - } - } -} - impl SseEncode for Option { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { @@ -1036,41 +506,6 @@ impl SseEncode for (String, String) { } } -impl SseEncode for crate::api::rs_process::RsProcessStreamData { - // Codec=Sse (Serialization based), see doc to use other codecs - fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { - ::sse_encode(self.data_type, serializer); - ::sse_encode(self.data, serializer); - ::sse_encode(self.rs_pid, serializer); - } -} - -impl SseEncode for crate::api::rs_process::RsProcessStreamDataType { - // Codec=Sse (Serialization based), see doc to use other codecs - fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { - ::sse_encode( - match self { - crate::api::rs_process::RsProcessStreamDataType::Output => 0, - crate::api::rs_process::RsProcessStreamDataType::Error => 1, - crate::api::rs_process::RsProcessStreamDataType::Exit => 2, - _ => { - unimplemented!(""); - } - }, - serializer, - ); - } -} - -impl SseEncode for crate::api::asar_api::RsiLauncherAsarData { - // Codec=Sse (Serialization based), see doc to use other codecs - fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { - ::sse_encode(self.asar_path, serializer); - ::sse_encode(self.main_js_path, serializer); - >::sse_encode(self.main_js_content, serializer); - } -} - impl SseEncode for crate::http_package::RustHttpResponse { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { @@ -1078,8 +513,6 @@ impl SseEncode for crate::http_package::RustHttpResponse { >::sse_encode(self.headers, serializer); ::sse_encode(self.url, serializer); >::sse_encode(self.content_length, serializer); - ::sse_encode(self.version, serializer); - ::sse_encode(self.remote_addr, serializer); >>::sse_encode(self.data, serializer); } } @@ -1091,13 +524,6 @@ impl SseEncode for u16 { } } -impl SseEncode for u32 { - // Codec=Sse (Serialization based), see doc to use other codecs - fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { - serializer.cursor.write_u32::(self).unwrap(); - } -} - impl SseEncode for u64 { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { @@ -1117,6 +543,13 @@ impl SseEncode for () { fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {} } +impl SseEncode for bool { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + serializer.cursor.write_u8(self as _).unwrap(); + } +} + #[cfg(not(target_family = "wasm"))] mod io { // This file is automatically generated, so please do not edit it. @@ -1154,25 +587,6 @@ mod io { vec.into_iter().collect() } } - impl - CstDecode< - StreamSink< - crate::api::rs_process::RsProcessStreamData, - flutter_rust_bridge::for_generated::DcoCodec, - >, - > for *mut wire_cst_list_prim_u_8_strict - { - // Codec=Cst (C-struct based), see doc to use other codecs - fn cst_decode( - self, - ) -> StreamSink< - crate::api::rs_process::RsProcessStreamData, - flutter_rust_bridge::for_generated::DcoCodec, - > { - let raw: String = self.cst_decode(); - StreamSink::deserialize(raw) - } - } impl CstDecode for *mut wire_cst_list_prim_u_8_strict { // Codec=Cst (C-struct based), see doc to use other codecs fn cst_decode(self) -> String { @@ -1180,38 +594,12 @@ mod io { String::from_utf8(vec).unwrap() } } - impl CstDecode for *mut wire_cst_rsi_launcher_asar_data { - // Codec=Cst (C-struct based), see doc to use other codecs - fn cst_decode(self) -> crate::api::asar_api::RsiLauncherAsarData { - let wrap = unsafe { flutter_rust_bridge::for_generated::box_from_leak_ptr(self) }; - CstDecode::::cst_decode(*wrap).into() - } - } impl CstDecode for *mut u64 { // Codec=Cst (C-struct based), see doc to use other codecs fn cst_decode(self) -> u64 { unsafe { *flutter_rust_bridge::for_generated::box_from_leak_ptr(self) } } } - impl CstDecode> for *mut wire_cst_list_String { - // Codec=Cst (C-struct based), see doc to use other codecs - fn cst_decode(self) -> Vec { - let vec = unsafe { - let wrap = flutter_rust_bridge::for_generated::box_from_leak_ptr(self); - flutter_rust_bridge::for_generated::vec_from_leak_ptr(wrap.ptr, wrap.len) - }; - vec.into_iter().map(CstDecode::cst_decode).collect() - } - } - impl CstDecode> for *mut wire_cst_list_prim_u_8_loose { - // Codec=Cst (C-struct based), see doc to use other codecs - fn cst_decode(self) -> Vec { - unsafe { - let wrap = flutter_rust_bridge::for_generated::box_from_leak_ptr(self); - flutter_rust_bridge::for_generated::vec_from_leak_ptr(wrap.ptr, wrap.len) - } - } - } impl CstDecode> for *mut wire_cst_list_prim_u_8_strict { // Codec=Cst (C-struct based), see doc to use other codecs fn cst_decode(self) -> Vec { @@ -1237,26 +625,6 @@ mod io { (self.field0.cst_decode(), self.field1.cst_decode()) } } - impl CstDecode for wire_cst_rs_process_stream_data { - // Codec=Cst (C-struct based), see doc to use other codecs - fn cst_decode(self) -> crate::api::rs_process::RsProcessStreamData { - crate::api::rs_process::RsProcessStreamData { - data_type: self.data_type.cst_decode(), - data: self.data.cst_decode(), - rs_pid: self.rs_pid.cst_decode(), - } - } - } - impl CstDecode for wire_cst_rsi_launcher_asar_data { - // Codec=Cst (C-struct based), see doc to use other codecs - fn cst_decode(self) -> crate::api::asar_api::RsiLauncherAsarData { - crate::api::asar_api::RsiLauncherAsarData { - asar_path: self.asar_path.cst_decode(), - main_js_path: self.main_js_path.cst_decode(), - main_js_content: self.main_js_content.cst_decode(), - } - } - } impl CstDecode for wire_cst_rust_http_response { // Codec=Cst (C-struct based), see doc to use other codecs fn cst_decode(self) -> crate::http_package::RustHttpResponse { @@ -1265,8 +633,6 @@ mod io { headers: self.headers.cst_decode(), url: self.url.cst_decode(), content_length: self.content_length.cst_decode(), - version: self.version.cst_decode(), - remote_addr: self.remote_addr.cst_decode(), data: self.data.cst_decode(), } } @@ -1284,34 +650,6 @@ mod io { Self::new_with_null_ptr() } } - impl NewWithNullPtr for wire_cst_rs_process_stream_data { - fn new_with_null_ptr() -> Self { - Self { - data_type: Default::default(), - data: core::ptr::null_mut(), - rs_pid: Default::default(), - } - } - } - impl Default for wire_cst_rs_process_stream_data { - fn default() -> Self { - Self::new_with_null_ptr() - } - } - impl NewWithNullPtr for wire_cst_rsi_launcher_asar_data { - fn new_with_null_ptr() -> Self { - Self { - asar_path: core::ptr::null_mut(), - main_js_path: core::ptr::null_mut(), - main_js_content: core::ptr::null_mut(), - } - } - } - impl Default for wire_cst_rsi_launcher_asar_data { - fn default() -> Self { - Self::new_with_null_ptr() - } - } impl NewWithNullPtr for wire_cst_rust_http_response { fn new_with_null_ptr() -> Self { Self { @@ -1319,8 +657,6 @@ mod io { headers: core::ptr::null_mut(), url: core::ptr::null_mut(), content_length: core::ptr::null_mut(), - version: Default::default(), - remote_addr: core::ptr::null_mut(), data: core::ptr::null_mut(), } } @@ -1331,39 +667,6 @@ mod io { } } - #[no_mangle] - pub extern "C" fn frbgen_starcitizen_doctor_wire__crate__api__asar_api__get_rsi_launcher_asar_data( - port_: i64, - asar_path: *mut wire_cst_list_prim_u_8_strict, - ) { - wire__crate__api__asar_api__get_rsi_launcher_asar_data_impl(port_, asar_path) - } - - #[no_mangle] - pub extern "C" fn frbgen_starcitizen_doctor_wire__crate__api__asar_api__rsi_launcher_asar_data_write_main_js( - port_: i64, - that: *mut wire_cst_rsi_launcher_asar_data, - content: *mut wire_cst_list_prim_u_8_loose, - ) { - wire__crate__api__asar_api__rsi_launcher_asar_data_write_main_js_impl(port_, that, content) - } - - #[no_mangle] - pub extern "C" fn frbgen_starcitizen_doctor_wire__crate__api__http_api__dns_lookup_ips( - port_: i64, - host: *mut wire_cst_list_prim_u_8_strict, - ) { - wire__crate__api__http_api__dns_lookup_ips_impl(port_, host) - } - - #[no_mangle] - pub extern "C" fn frbgen_starcitizen_doctor_wire__crate__api__http_api__dns_lookup_txt( - port_: i64, - host: *mut wire_cst_list_prim_u_8_strict, - ) { - wire__crate__api__http_api__dns_lookup_txt_impl(port_, host) - } - #[no_mangle] pub extern "C" fn frbgen_starcitizen_doctor_wire__crate__api__http_api__fetch( port_: i64, @@ -1371,16 +674,8 @@ mod io { url: *mut wire_cst_list_prim_u_8_strict, headers: *mut wire_cst_list_record_string_string, input_data: *mut wire_cst_list_prim_u_8_strict, - with_ip_address: *mut wire_cst_list_prim_u_8_strict, ) { - wire__crate__api__http_api__fetch_impl( - port_, - method, - url, - headers, - input_data, - with_ip_address, - ) + wire__crate__api__http_api__fetch_impl(port_, method, url, headers, input_data) } #[no_mangle] @@ -1391,89 +686,11 @@ mod io { wire__crate__api__http_api__set_default_header_impl(port_, headers) } - #[no_mangle] - pub extern "C" fn frbgen_starcitizen_doctor_wire__crate__api__rs_process__start( - port_: i64, - executable: *mut wire_cst_list_prim_u_8_strict, - arguments: *mut wire_cst_list_String, - working_directory: *mut wire_cst_list_prim_u_8_strict, - stream_sink: *mut wire_cst_list_prim_u_8_strict, - ) { - wire__crate__api__rs_process__start_impl( - port_, - executable, - arguments, - working_directory, - stream_sink, - ) - } - - #[no_mangle] - pub extern "C" fn frbgen_starcitizen_doctor_wire__crate__api__rs_process__write( - port_: i64, - rs_pid: u32, - data: *mut wire_cst_list_prim_u_8_strict, - ) { - wire__crate__api__rs_process__write_impl(port_, rs_pid, data) - } - - #[no_mangle] - pub extern "C" fn frbgen_starcitizen_doctor_wire__crate__api__win32_api__send_notify( - port_: i64, - summary: *mut wire_cst_list_prim_u_8_strict, - body: *mut wire_cst_list_prim_u_8_strict, - app_name: *mut wire_cst_list_prim_u_8_strict, - app_id: *mut wire_cst_list_prim_u_8_strict, - ) { - wire__crate__api__win32_api__send_notify_impl(port_, summary, body, app_name, app_id) - } - - #[no_mangle] - pub extern "C" fn frbgen_starcitizen_doctor_wire__crate__api__win32_api__set_foreground_window( - port_: i64, - window_name: *mut wire_cst_list_prim_u_8_strict, - ) { - wire__crate__api__win32_api__set_foreground_window_impl(port_, window_name) - } - - #[no_mangle] - pub extern "C" fn frbgen_starcitizen_doctor_cst_new_box_autoadd_rsi_launcher_asar_data( - ) -> *mut wire_cst_rsi_launcher_asar_data { - flutter_rust_bridge::for_generated::new_leak_box_ptr( - wire_cst_rsi_launcher_asar_data::new_with_null_ptr(), - ) - } - #[no_mangle] pub extern "C" fn frbgen_starcitizen_doctor_cst_new_box_autoadd_u_64(value: u64) -> *mut u64 { flutter_rust_bridge::for_generated::new_leak_box_ptr(value) } - #[no_mangle] - pub extern "C" fn frbgen_starcitizen_doctor_cst_new_list_String( - len: i32, - ) -> *mut wire_cst_list_String { - let wrap = wire_cst_list_String { - ptr: flutter_rust_bridge::for_generated::new_leak_vec_ptr( - <*mut wire_cst_list_prim_u_8_strict>::new_with_null_ptr(), - len, - ), - len, - }; - flutter_rust_bridge::for_generated::new_leak_box_ptr(wrap) - } - - #[no_mangle] - pub extern "C" fn frbgen_starcitizen_doctor_cst_new_list_prim_u_8_loose( - len: i32, - ) -> *mut wire_cst_list_prim_u_8_loose { - let ans = wire_cst_list_prim_u_8_loose { - ptr: flutter_rust_bridge::for_generated::new_leak_vec_ptr(Default::default(), len), - len, - }; - flutter_rust_bridge::for_generated::new_leak_box_ptr(ans) - } - #[no_mangle] pub extern "C" fn frbgen_starcitizen_doctor_cst_new_list_prim_u_8_strict( len: i32, @@ -1499,18 +716,6 @@ mod io { flutter_rust_bridge::for_generated::new_leak_box_ptr(wrap) } - #[repr(C)] - #[derive(Clone, Copy)] - pub struct wire_cst_list_String { - ptr: *mut *mut wire_cst_list_prim_u_8_strict, - len: i32, - } - #[repr(C)] - #[derive(Clone, Copy)] - pub struct wire_cst_list_prim_u_8_loose { - ptr: *mut u8, - len: i32, - } #[repr(C)] #[derive(Clone, Copy)] pub struct wire_cst_list_prim_u_8_strict { @@ -1531,29 +736,196 @@ mod io { } #[repr(C)] #[derive(Clone, Copy)] - pub struct wire_cst_rs_process_stream_data { - data_type: i32, - data: *mut wire_cst_list_prim_u_8_strict, - rs_pid: u32, - } - #[repr(C)] - #[derive(Clone, Copy)] - pub struct wire_cst_rsi_launcher_asar_data { - asar_path: *mut wire_cst_list_prim_u_8_strict, - main_js_path: *mut wire_cst_list_prim_u_8_strict, - main_js_content: *mut wire_cst_list_prim_u_8_strict, - } - #[repr(C)] - #[derive(Clone, Copy)] pub struct wire_cst_rust_http_response { status_code: u16, headers: *mut wire_cst_list_record_string_string, url: *mut wire_cst_list_prim_u_8_strict, content_length: *mut u64, - version: i32, - remote_addr: *mut wire_cst_list_prim_u_8_strict, data: *mut wire_cst_list_prim_u_8_strict, } } #[cfg(not(target_family = "wasm"))] pub use io::*; + +/// cbindgen:ignore +#[cfg(target_family = "wasm")] +mod web { + // This file is automatically generated, so please do not edit it. + // Generated by `flutter_rust_bridge`@ 2.3.0. + + // Section: imports + + use super::*; + use flutter_rust_bridge::for_generated::byteorder::{ + NativeEndian, ReadBytesExt, WriteBytesExt, + }; + use flutter_rust_bridge::for_generated::wasm_bindgen; + use flutter_rust_bridge::for_generated::wasm_bindgen::prelude::*; + use flutter_rust_bridge::for_generated::{transform_result_dco, Lifetimeable, Lockable}; + use flutter_rust_bridge::{Handler, IntoIntoDart}; + + // Section: boilerplate + + flutter_rust_bridge::frb_generated_boilerplate_web!(); + + // Section: dart2rust + + impl CstDecode for String { + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode(self) -> flutter_rust_bridge::for_generated::anyhow::Error { + unimplemented!() + } + } + impl CstDecode for String { + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode(self) -> String { + self + } + } + impl CstDecode> for Box<[u8]> { + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode(self) -> Vec { + self.into_vec() + } + } + impl CstDecode> + for flutter_rust_bridge::for_generated::wasm_bindgen::JsValue + { + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode(self) -> Vec<(String, String)> { + self.dyn_into::() + .unwrap() + .iter() + .map(CstDecode::cst_decode) + .collect() + } + } + impl CstDecode>> for Option> { + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode(self) -> Option> { + self.map(CstDecode::cst_decode) + } + } + impl CstDecode<(String, String)> for flutter_rust_bridge::for_generated::wasm_bindgen::JsValue { + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode(self) -> (String, String) { + let self_ = self + .dyn_into::() + .unwrap(); + assert_eq!( + self_.length(), + 2, + "Expected 2 elements, got {}", + self_.length() + ); + (self_.get(0).cst_decode(), self_.get(1).cst_decode()) + } + } + impl CstDecode + for flutter_rust_bridge::for_generated::wasm_bindgen::JsValue + { + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode(self) -> crate::http_package::RustHttpResponse { + let self_ = self + .dyn_into::() + .unwrap(); + assert_eq!( + self_.length(), + 5, + "Expected 5 elements, got {}", + self_.length() + ); + crate::http_package::RustHttpResponse { + status_code: self_.get(0).cst_decode(), + headers: self_.get(1).cst_decode(), + url: self_.get(2).cst_decode(), + content_length: self_.get(3).cst_decode(), + data: self_.get(4).cst_decode(), + } + } + } + impl CstDecode + for flutter_rust_bridge::for_generated::wasm_bindgen::JsValue + { + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode(self) -> flutter_rust_bridge::for_generated::anyhow::Error { + unimplemented!() + } + } + impl CstDecode> + for flutter_rust_bridge::for_generated::wasm_bindgen::JsValue + { + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode(self) -> std::collections::HashMap { + let vec: Vec<(String, String)> = self.cst_decode(); + vec.into_iter().collect() + } + } + impl CstDecode for flutter_rust_bridge::for_generated::wasm_bindgen::JsValue { + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode(self) -> String { + self.as_string().expect("non-UTF-8 string, or not a string") + } + } + impl CstDecode for flutter_rust_bridge::for_generated::wasm_bindgen::JsValue { + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode(self) -> i32 { + self.unchecked_into_f64() as _ + } + } + impl CstDecode> for flutter_rust_bridge::for_generated::wasm_bindgen::JsValue { + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode(self) -> Vec { + self.unchecked_into::() + .to_vec() + .into() + } + } + impl CstDecode + for flutter_rust_bridge::for_generated::wasm_bindgen::JsValue + { + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode(self) -> crate::api::http_api::MyMethod { + (self.unchecked_into_f64() as i32).cst_decode() + } + } + impl CstDecode for flutter_rust_bridge::for_generated::wasm_bindgen::JsValue { + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode(self) -> u16 { + self.unchecked_into_f64() as _ + } + } + impl CstDecode for flutter_rust_bridge::for_generated::wasm_bindgen::JsValue { + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode(self) -> u64 { + ::std::convert::TryInto::::try_into(self).unwrap() as _ + } + } + impl CstDecode for flutter_rust_bridge::for_generated::wasm_bindgen::JsValue { + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode(self) -> u8 { + self.unchecked_into_f64() as _ + } + } + + #[wasm_bindgen] + pub fn wire__crate__api__http_api__fetch( + port_: flutter_rust_bridge::for_generated::MessagePort, + method: i32, + url: String, + headers: flutter_rust_bridge::for_generated::wasm_bindgen::JsValue, + input_data: Option>, + ) { + wire__crate__api__http_api__fetch_impl(port_, method, url, headers, input_data) + } + + #[wasm_bindgen] + pub fn wire__crate__api__http_api__set_default_header( + port_: flutter_rust_bridge::for_generated::MessagePort, + headers: flutter_rust_bridge::for_generated::wasm_bindgen::JsValue, + ) { + wire__crate__api__http_api__set_default_header_impl(port_, headers) + } +} +#[cfg(target_family = "wasm")] +pub use web::*; diff --git a/rust/src/http_package/dns.rs b/rust/src/http_package/dns.rs deleted file mode 100644 index adea52e..0000000 --- a/rust/src/http_package/dns.rs +++ /dev/null @@ -1,98 +0,0 @@ -use hickory_resolver::config::{NameServerConfigGroup, ResolverConfig, ResolverOpts}; -use hickory_resolver::{lookup_ip::LookupIpIntoIter, TokioAsyncResolver}; -use once_cell::sync::{Lazy, OnceCell}; -use reqwest::dns::{Addrs, Name, Resolve, Resolving}; -use std::collections::HashMap; -use std::io; -use std::net::{IpAddr, Ipv4Addr, SocketAddr}; -use std::sync::{Arc, RwLock}; - -pub static MY_HOSTS_MAP: Lazy>> = - Lazy::new(|| RwLock::from(HashMap::new())); - -/// Wrapper around an `AsyncResolver`, which implements the `Resolve` trait. -#[derive(Debug, Default, Clone)] -pub(crate) struct MyHickoryDnsResolver { - /// Since we might not have been called in the context of a - /// Tokio Runtime in initialization, so we must delay the actual - /// construction of the resolver. - state: Arc>, -} - -struct SocketAddrs { - iter: LookupIpIntoIter, -} - -impl Resolve for MyHickoryDnsResolver { - fn resolve(&self, name: Name) -> Resolving { - let my_hosts = MY_HOSTS_MAP.read().unwrap(); - let name_str = name.as_str(); - if let Some(ip) = my_hosts.get(name_str) { - let addrs: Addrs = Box::new(std::iter::once(SocketAddr::new(*ip, 0))); - println!("using host map === {:?}", name_str); - return Box::pin(async move { Ok(addrs) }); - } - - let resolver = self.clone(); - Box::pin(async move { - let resolver = resolver.state.get_or_try_init(new_resolver)?; - let lookup = resolver.lookup_ip(name.as_str()).await?; - let addrs: Addrs = Box::new(SocketAddrs { - iter: lookup.into_iter(), - }); - Ok(addrs) - }) - } -} - -impl MyHickoryDnsResolver { - pub(crate) async fn lookup_txt(&self, name: String) -> anyhow::Result> { - let resolver = self.state.get_or_try_init(new_resolver)?; - let txt = resolver.txt_lookup(name).await?; - let t = txt - .iter() - .map(|rdata| rdata.to_string()) - .collect::>(); - Ok(t) - } - pub(crate) async fn lookup_ips(&self, name: String) -> anyhow::Result> { - let resolver = self.state.get_or_try_init(new_resolver)?; - let ips = resolver.ipv4_lookup(name).await?; - let t = ips.iter().map(|ip| ip.to_string()).collect::>(); - Ok(t) - } -} - -impl Iterator for SocketAddrs { - type Item = SocketAddr; - - fn next(&mut self) -> Option { - self.iter.next().map(|ip_addr| SocketAddr::new(ip_addr, 0)) - } -} - -fn new_resolver() -> io::Result { - let group = NameServerConfigGroup::from_ips_clear( - &[ - IpAddr::V4(Ipv4Addr::new(119, 29, 29, 29)), - IpAddr::V4(Ipv4Addr::new(223, 6, 6, 6)), - IpAddr::V4(Ipv4Addr::new(1, 1, 1, 1)), - IpAddr::V4(Ipv4Addr::new(8, 8, 8, 8)), - IpAddr::V4(Ipv4Addr::new(180, 76, 76, 76)), - IpAddr::V4(Ipv4Addr::new(1, 2, 4, 8)), - IpAddr::V4(Ipv4Addr::new(166, 111, 8, 28)), - IpAddr::V4(Ipv4Addr::new(101, 226, 4, 6)), - IpAddr::V4(Ipv4Addr::new(114, 114, 114, 114)), - ], - 53, - false, - ); - let cfg = ResolverConfig::from_parts(None, vec![], group); - let mut opts = ResolverOpts::default(); - opts.edns0 = true; - opts.timeout = std::time::Duration::from_secs(5); - opts.try_tcp_on_error = true; - opts.ip_strategy = hickory_resolver::config::LookupIpStrategy::Ipv4thenIpv6; - opts.num_concurrent_reqs = 3; - Ok(TokioAsyncResolver::tokio(cfg, opts)) -} diff --git a/rust/src/http_package/mod.rs b/rust/src/http_package/mod.rs index aff9feb..b24feb5 100644 --- a/rust/src/http_package/mod.rs +++ b/rust/src/http_package/mod.rs @@ -1,25 +1,10 @@ -pub mod dns; - use once_cell::sync::Lazy; use reqwest::header::{HeaderMap, HeaderName, HeaderValue}; use reqwest::{Method, RequestBuilder}; -use scopeguard::defer; use std::collections::HashMap; use std::str::FromStr; -use std::sync::{Arc, RwLock}; -use std::time::Duration; -use url::Url; +use std::sync::RwLock; -#[derive(Debug)] -#[allow(non_camel_case_types)] -pub enum MyHttpVersion { - HTTP_09, - HTTP_10, - HTTP_11, - HTTP_2, - HTTP_3, - HTTP_UNKNOWN, -} #[derive(Debug)] pub struct RustHttpResponse { @@ -27,41 +12,15 @@ pub struct RustHttpResponse { pub headers: HashMap, pub url: String, pub content_length: Option, - pub version: MyHttpVersion, - pub remote_addr: String, pub data: Option>, } -fn _hyper_version_to_my_version(v: reqwest::Version) -> MyHttpVersion { - match v { - reqwest::Version::HTTP_09 => MyHttpVersion::HTTP_09, - reqwest::Version::HTTP_10 => MyHttpVersion::HTTP_10, - reqwest::Version::HTTP_11 => MyHttpVersion::HTTP_11, - reqwest::Version::HTTP_2 => MyHttpVersion::HTTP_2, - reqwest::Version::HTTP_3 => MyHttpVersion::HTTP_3, - _ => MyHttpVersion::HTTP_UNKNOWN, - } -} - static DEFAULT_HEADER: Lazy> = Lazy::new(|| RwLock::from(HeaderMap::new())); -static DNS_CLIENT: Lazy> = - Lazy::new(|| Arc::from(dns::MyHickoryDnsResolver::default())); +static HTTP_CLIENT: Lazy = Lazy::new(|| new_http_client()); -static HTTP_CLIENT: Lazy = Lazy::new(|| new_http_client(true)); - -fn new_http_client(keep_alive: bool) -> reqwest::Client { - let mut c = reqwest::Client::builder() - .dns_resolver(DNS_CLIENT.clone()) - .use_rustls_tls() - .connect_timeout(Duration::from_secs(10)) - .gzip(true) - .no_proxy(); - if !keep_alive { - c = c.tcp_keepalive(None); - } else { - c = c.tcp_keepalive(Duration::from_secs(120)); - } +fn new_http_client() -> reqwest::Client { + let c = reqwest::Client::builder(); c.build().unwrap() } @@ -81,34 +40,10 @@ pub async fn fetch( url: String, headers: Option>, input_data: Option>, - with_ip_address: Option, ) -> anyhow::Result { - let address_clone = with_ip_address.clone(); let url_clone = url.clone(); - if address_clone.is_some() { - let addr = std::net::IpAddr::from_str(with_ip_address.unwrap().as_str()).unwrap(); - let mut hosts = dns::MY_HOSTS_MAP.write().unwrap(); - let url_host = Url::from_str(url.as_str()) - .unwrap() - .host() - .unwrap() - .to_string(); - hosts.insert(url_host, addr); - } - - defer! { - if address_clone.is_some() { - let mut hosts = dns::MY_HOSTS_MAP.write().unwrap(); - hosts.remove(url.clone().as_str()); - } - } - - let mut req = if address_clone.is_some() { - _mix_header(new_http_client(false).request(method, url_clone), headers) - } else { - _mix_header(HTTP_CLIENT.request(method, url_clone), headers) - }; + let mut req = _mix_header(HTTP_CLIENT.request(method, url_clone), headers); if input_data.is_some() { req = req.body(input_data.unwrap()); } @@ -117,40 +52,23 @@ pub async fn fetch( let status_code = resp.status().as_u16(); let resp_headers = _reade_resp_header(resp.headers()); let content_length = resp.content_length(); - let version = resp.version(); - let mut remote_addr = "".to_string(); - if resp.remote_addr().is_some() { - remote_addr = resp.remote_addr().unwrap().to_string(); - } + let mut data: Option> = None; let bytes = resp.bytes().await; if bytes.is_ok() { - data = Some(bytes.unwrap().to_vec()); + data = Some(bytes?.to_vec()); } - - let version = _hyper_version_to_my_version(version); - let resp = RustHttpResponse { status_code, headers: resp_headers, url, content_length, - version, - remote_addr, data, }; Ok(resp) } -pub async fn dns_lookup_txt(name: String) -> anyhow::Result> { - DNS_CLIENT.lookup_txt(name).await -} - -pub async fn dns_lookup_ips(name: String) -> anyhow::Result> { - DNS_CLIENT.lookup_ips(name).await -} - fn _reade_resp_header(r_header: &HeaderMap) -> HashMap { let mut resp_headers = HashMap::new(); for ele in r_header { diff --git a/rust_builder/android/.gitignore b/rust_builder/android/.gitignore deleted file mode 100644 index 161bdcd..0000000 --- a/rust_builder/android/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -*.iml -.gradle -/local.properties -/.idea/workspace.xml -/.idea/libraries -.DS_Store -/build -/captures -.cxx diff --git a/rust_builder/android/build.gradle b/rust_builder/android/build.gradle deleted file mode 100644 index 9b6f628..0000000 --- a/rust_builder/android/build.gradle +++ /dev/null @@ -1,56 +0,0 @@ -// The Android Gradle Plugin builds the native code with the Android NDK. - -group 'com.flutter_rust_bridge.rust_builder' -version '1.0' - -buildscript { - repositories { - google() - mavenCentral() - } - - dependencies { - // The Android Gradle Plugin knows how to build native code with the NDK. - classpath 'com.android.tools.build:gradle:7.3.0' - } -} - -rootProject.allprojects { - repositories { - google() - mavenCentral() - } -} - -apply plugin: 'com.android.library' - -android { - if (project.android.hasProperty("namespace")) { - namespace 'com.flutter_rust_bridge.rust_builder' - } - - // Bumping the plugin compileSdkVersion requires all clients of this plugin - // to bump the version in their app. - compileSdkVersion 33 - - // Use the NDK version - // declared in /android/app/build.gradle file of the Flutter project. - // Replace it with a version number if this plugin requires a specfic NDK version. - // (e.g. ndkVersion "23.1.7779620") - ndkVersion android.ndkVersion - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - - defaultConfig { - minSdkVersion 19 - } -} - -apply from: "../cargokit/gradle/plugin.gradle" -cargokit { - manifestDir = "../../rust" - libname = "rust" -} diff --git a/rust_builder/android/settings.gradle b/rust_builder/android/settings.gradle deleted file mode 100644 index af87477..0000000 --- a/rust_builder/android/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -rootProject.name = 'rust_builder' diff --git a/rust_builder/android/src/main/AndroidManifest.xml b/rust_builder/android/src/main/AndroidManifest.xml deleted file mode 100644 index 5c0538a..0000000 --- a/rust_builder/android/src/main/AndroidManifest.xml +++ /dev/null @@ -1,3 +0,0 @@ - - diff --git a/rust_builder/ios/Classes/dummy_file.c b/rust_builder/ios/Classes/dummy_file.c deleted file mode 100644 index e06dab9..0000000 --- a/rust_builder/ios/Classes/dummy_file.c +++ /dev/null @@ -1 +0,0 @@ -// This is an empty file to force CocoaPods to create a framework. diff --git a/rust_builder/ios/rust_builder.podspec b/rust_builder/ios/rust_builder.podspec deleted file mode 100644 index 0cce23f..0000000 --- a/rust_builder/ios/rust_builder.podspec +++ /dev/null @@ -1,45 +0,0 @@ -# -# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. -# Run `pod lib lint rust_builder.podspec` to validate before publishing. -# -Pod::Spec.new do |s| - s.name = 'rust_builder' - s.version = '0.0.1' - s.summary = 'A new Flutter FFI plugin project.' - s.description = <<-DESC -A new Flutter FFI plugin project. - DESC - s.homepage = 'http://example.com' - s.license = { :file => '../LICENSE' } - s.author = { 'Your Company' => 'email@example.com' } - - # This will ensure the source files in Classes/ are included in the native - # builds of apps using this FFI plugin. Podspec does not support relative - # paths, so Classes contains a forwarder C file that relatively imports - # `../src/*` so that the C sources can be shared among all target platforms. - s.source = { :path => '.' } - s.source_files = 'Classes/**/*' - s.dependency 'Flutter' - s.platform = :ios, '11.0' - - # Flutter.framework does not contain a i386 slice. - s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' } - s.swift_version = '5.0' - - s.script_phase = { - :name => 'Build Rust library', - # First argument is relative path to the `rust` folder, second is name of rust library - :script => 'sh "$PODS_TARGET_SRCROOT/../cargokit/build_pod.sh" ../../rust rust', - :execution_position => :before_compile, - :input_files => ['${BUILT_PRODUCTS_DIR}/cargokit_phony'], - # Let XCode know that the static library referenced in -force_load below is - # created by this build step. - :output_files => ["${BUILT_PRODUCTS_DIR}/librust.a"], - } - s.pod_target_xcconfig = { - 'DEFINES_MODULE' => 'YES', - # Flutter.framework does not contain a i386 slice. - 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386', - 'OTHER_LDFLAGS' => '-force_load ${BUILT_PRODUCTS_DIR}/librust.a', - } -end diff --git a/rust_builder/linux/CMakeLists.txt b/rust_builder/linux/CMakeLists.txt deleted file mode 100644 index 6214557..0000000 --- a/rust_builder/linux/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -# The Flutter tooling requires that developers have CMake 3.10 or later -# installed. You should not increase this version, as doing so will cause -# the plugin to fail to compile for some customers of the plugin. -cmake_minimum_required(VERSION 3.10) - -# Project-level configuration. -set(PROJECT_NAME "rust_builder") -project(${PROJECT_NAME} LANGUAGES CXX) - -include("../cargokit/cmake/cargokit.cmake") -apply_cargokit(${PROJECT_NAME} ../../rust rust "") - -# List of absolute paths to libraries that should be bundled with the plugin. -# This list could contain prebuilt libraries, or libraries created by an -# external build triggered from this build file. -set(rust_builder_bundled_libraries - "${${PROJECT_NAME}_cargokit_lib}" - PARENT_SCOPE -) diff --git a/rust_builder/macos/Classes/dummy_file.c b/rust_builder/macos/Classes/dummy_file.c deleted file mode 100644 index e06dab9..0000000 --- a/rust_builder/macos/Classes/dummy_file.c +++ /dev/null @@ -1 +0,0 @@ -// This is an empty file to force CocoaPods to create a framework. diff --git a/rust_builder/macos/rust_builder.podspec b/rust_builder/macos/rust_builder.podspec deleted file mode 100644 index ff19726..0000000 --- a/rust_builder/macos/rust_builder.podspec +++ /dev/null @@ -1,44 +0,0 @@ -# -# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. -# Run `pod lib lint rust_builder.podspec` to validate before publishing. -# -Pod::Spec.new do |s| - s.name = 'rust_builder' - s.version = '0.0.1' - s.summary = 'A new Flutter FFI plugin project.' - s.description = <<-DESC -A new Flutter FFI plugin project. - DESC - s.homepage = 'http://example.com' - s.license = { :file => '../LICENSE' } - s.author = { 'Your Company' => 'email@example.com' } - - # This will ensure the source files in Classes/ are included in the native - # builds of apps using this FFI plugin. Podspec does not support relative - # paths, so Classes contains a forwarder C file that relatively imports - # `../src/*` so that the C sources can be shared among all target platforms. - s.source = { :path => '.' } - s.source_files = 'Classes/**/*' - s.frameworks = 'SystemConfiguration' - s.dependency 'FlutterMacOS' - s.platform = :osx, '10.11' - s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' } - s.swift_version = '5.0' - - s.script_phase = { - :name => 'Build Rust library', - # First argument is relative path to the `rust` folder, second is name of rust library - :script => 'sh "$PODS_TARGET_SRCROOT/../cargokit/build_pod.sh" ../../rust rust', - :execution_position => :before_compile, - :input_files => ['${BUILT_PRODUCTS_DIR}/cargokit_phony'], - # Let XCode know that the static library referenced in -force_load below is - # created by this build step. - :output_files => ["${BUILT_PRODUCTS_DIR}/librust.a"], - } - s.pod_target_xcconfig = { - 'DEFINES_MODULE' => 'YES', - # Flutter.framework does not contain a i386 slice. - 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386', - 'OTHER_LDFLAGS' => '-force_load ${BUILT_PRODUCTS_DIR}/librust.a', - } -end diff --git a/rust_builder/windows/.gitignore b/rust_builder/windows/.gitignore deleted file mode 100644 index b3eb2be..0000000 --- a/rust_builder/windows/.gitignore +++ /dev/null @@ -1,17 +0,0 @@ -flutter/ - -# Visual Studio user-specific files. -*.suo -*.user -*.userosscache -*.sln.docstates - -# Visual Studio build-related files. -x64/ -x86/ - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!*.[Cc]ache/ diff --git a/rust_builder/windows/CMakeLists.txt b/rust_builder/windows/CMakeLists.txt deleted file mode 100644 index 5d429d7..0000000 --- a/rust_builder/windows/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -# The Flutter tooling requires that developers have a version of Visual Studio -# installed that includes CMake 3.14 or later. You should not increase this -# version, as doing so will cause the plugin to fail to compile for some -# customers of the plugin. -cmake_minimum_required(VERSION 3.14) - -# Project-level configuration. -set(PROJECT_NAME "rust_builder") -project(${PROJECT_NAME} LANGUAGES CXX) - -include("../cargokit/cmake/cargokit.cmake") -apply_cargokit(${PROJECT_NAME} ../../../../../../rust rust "") - -# List of absolute paths to libraries that should be bundled with the plugin. -# This list could contain prebuilt libraries, or libraries created by an -# external build triggered from this build file. -set(rust_builder_bundled_libraries - "${${PROJECT_NAME}_cargokit_lib}" - PARENT_SCOPE -) diff --git a/web/favicon.png b/web/favicon.png new file mode 100644 index 0000000..8aaa46a Binary files /dev/null and b/web/favicon.png differ diff --git a/web/icons/Icon-192.png b/web/icons/Icon-192.png new file mode 100644 index 0000000..b749bfe Binary files /dev/null and b/web/icons/Icon-192.png differ diff --git a/web/icons/Icon-512.png b/web/icons/Icon-512.png new file mode 100644 index 0000000..88cfd48 Binary files /dev/null and b/web/icons/Icon-512.png differ diff --git a/web/icons/Icon-maskable-192.png b/web/icons/Icon-maskable-192.png new file mode 100644 index 0000000..eb9b4d7 Binary files /dev/null and b/web/icons/Icon-maskable-192.png differ diff --git a/web/icons/Icon-maskable-512.png b/web/icons/Icon-maskable-512.png new file mode 100644 index 0000000..d69c566 Binary files /dev/null and b/web/icons/Icon-maskable-512.png differ diff --git a/web/index.html b/web/index.html new file mode 100644 index 0000000..10b208f --- /dev/null +++ b/web/index.html @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + starcitizentoolbox_web + + + + + + + + diff --git a/web/manifest.json b/web/manifest.json new file mode 100644 index 0000000..08065f4 --- /dev/null +++ b/web/manifest.json @@ -0,0 +1,35 @@ +{ + "name": "starcitizentoolbox_web", + "short_name": "starcitizentoolbox_web", + "start_url": ".", + "display": "standalone", + "background_color": "#0175C2", + "theme_color": "#0175C2", + "description": "A new Flutter project.", + "orientation": "portrait-primary", + "prefer_related_applications": false, + "icons": [ + { + "src": "icons/Icon-192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "icons/Icon-512.png", + "sizes": "512x512", + "type": "image/png" + }, + { + "src": "icons/Icon-maskable-192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "icons/Icon-maskable-512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "maskable" + } + ] +} diff --git a/windows/.gitignore b/windows/.gitignore deleted file mode 100644 index d492d0d..0000000 --- a/windows/.gitignore +++ /dev/null @@ -1,17 +0,0 @@ -flutter/ephemeral/ - -# Visual Studio user-specific files. -*.suo -*.user -*.userosscache -*.sln.docstates - -# Visual Studio build-related files. -x64/ -x86/ - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!*.[Cc]ache/ diff --git a/windows/CMakeLists.txt b/windows/CMakeLists.txt deleted file mode 100644 index 54a670c..0000000 --- a/windows/CMakeLists.txt +++ /dev/null @@ -1,100 +0,0 @@ -# Project-level configuration. -cmake_minimum_required(VERSION 3.14) -project(starcitizen_doctor LANGUAGES CXX) - -# The name of the executable created for the application. Change this to change -# the on-disk name of your application. -set(BINARY_NAME "starcitizen_doctor") - -# Explicitly opt in to modern CMake behaviors to avoid warnings with recent -# versions of CMake. -cmake_policy(SET CMP0063 NEW) - -# Define build configuration option. -get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) -if(IS_MULTICONFIG) - set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" - CACHE STRING "" FORCE) -else() - if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) - set(CMAKE_BUILD_TYPE "Debug" CACHE - STRING "Flutter build mode" FORCE) - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS - "Debug" "Profile" "Release") - endif() -endif() -# Define settings for the Profile build mode. -set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") -set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") -set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") -set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") - - -# Use Unicode for all projects. -add_definitions(-DUNICODE -D_UNICODE) - -# Compilation settings that should be applied to most targets. -# -# Be cautious about adding new options here, as plugins use this function by -# default. In most cases, you should add new options to specific targets instead -# of modifying this function. -function(APPLY_STANDARD_SETTINGS TARGET) - target_compile_features(${TARGET} PUBLIC cxx_std_17) - target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") - target_compile_options(${TARGET} PRIVATE /EHsc) - target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") - target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") -endfunction() - -# Flutter library and tool build rules. -set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") -add_subdirectory(${FLUTTER_MANAGED_DIR}) - -# Application build; see runner/CMakeLists.txt. -add_subdirectory("runner") - -# Generated plugin build rules, which manage building the plugins and adding -# them to the application. -include(flutter/generated_plugins.cmake) -# === Installation === -# Support files are copied into place next to the executable, so that it can -# run in place. This is done instead of making a separate bundle (as on Linux) -# so that building and running from within Visual Studio will work. -set(BUILD_BUNDLE_DIR "$") -# Make the "install" step default, as it's required to run. -set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) -if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) -endif() - -set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") -set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") - -install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" - COMPONENT Runtime) - -install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" - COMPONENT Runtime) - -install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" - COMPONENT Runtime) - -if(PLUGIN_BUNDLED_LIBRARIES) - install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" - DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" - COMPONENT Runtime) -endif() - -# Fully re-copy the assets directory on each build to avoid having stale files -# from a previous install. -set(FLUTTER_ASSET_DIR_NAME "flutter_assets") -install(CODE " - file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") - " COMPONENT Runtime) -install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" - DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) - -# Install the AOT library on non-Debug builds only. -install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" - CONFIGURATIONS Profile;Release - COMPONENT Runtime) diff --git a/windows/flutter/CMakeLists.txt b/windows/flutter/CMakeLists.txt deleted file mode 100644 index 903f489..0000000 --- a/windows/flutter/CMakeLists.txt +++ /dev/null @@ -1,109 +0,0 @@ -# This file controls Flutter-level build steps. It should not be edited. -cmake_minimum_required(VERSION 3.14) - -set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") - -# Configuration provided via flutter tool. -include(${EPHEMERAL_DIR}/generated_config.cmake) - -# TODO: Move the rest of this into files in ephemeral. See -# https://github.com/flutter/flutter/issues/57146. -set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") - -# Set fallback configurations for older versions of the flutter tool. -if (NOT DEFINED FLUTTER_TARGET_PLATFORM) - set(FLUTTER_TARGET_PLATFORM "windows-x64") -endif() - -# === Flutter Library === -set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") - -# Published to parent scope for install step. -set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) -set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) -set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) -set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) - -list(APPEND FLUTTER_LIBRARY_HEADERS - "flutter_export.h" - "flutter_windows.h" - "flutter_messenger.h" - "flutter_plugin_registrar.h" - "flutter_texture_registrar.h" -) -list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") -add_library(flutter INTERFACE) -target_include_directories(flutter INTERFACE - "${EPHEMERAL_DIR}" -) -target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") -add_dependencies(flutter flutter_assemble) - -# === Wrapper === -list(APPEND CPP_WRAPPER_SOURCES_CORE - "core_implementations.cc" - "standard_codec.cc" -) -list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") -list(APPEND CPP_WRAPPER_SOURCES_PLUGIN - "plugin_registrar.cc" -) -list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") -list(APPEND CPP_WRAPPER_SOURCES_APP - "flutter_engine.cc" - "flutter_view_controller.cc" -) -list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") - -# Wrapper sources needed for a plugin. -add_library(flutter_wrapper_plugin STATIC - ${CPP_WRAPPER_SOURCES_CORE} - ${CPP_WRAPPER_SOURCES_PLUGIN} -) -apply_standard_settings(flutter_wrapper_plugin) -set_target_properties(flutter_wrapper_plugin PROPERTIES - POSITION_INDEPENDENT_CODE ON) -set_target_properties(flutter_wrapper_plugin PROPERTIES - CXX_VISIBILITY_PRESET hidden) -target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) -target_include_directories(flutter_wrapper_plugin PUBLIC - "${WRAPPER_ROOT}/include" -) -add_dependencies(flutter_wrapper_plugin flutter_assemble) - -# Wrapper sources needed for the runner. -add_library(flutter_wrapper_app STATIC - ${CPP_WRAPPER_SOURCES_CORE} - ${CPP_WRAPPER_SOURCES_APP} -) -apply_standard_settings(flutter_wrapper_app) -target_link_libraries(flutter_wrapper_app PUBLIC flutter) -target_include_directories(flutter_wrapper_app PUBLIC - "${WRAPPER_ROOT}/include" -) -add_dependencies(flutter_wrapper_app flutter_assemble) - -# === Flutter tool backend === -# _phony_ is a non-existent file to force this command to run every time, -# since currently there's no way to get a full input/output list from the -# flutter tool. -set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") -set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) -add_custom_command( - OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} - ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} - ${CPP_WRAPPER_SOURCES_APP} - ${PHONY_OUTPUT} - COMMAND ${CMAKE_COMMAND} -E env - ${FLUTTER_TOOL_ENVIRONMENT} - "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" - ${FLUTTER_TARGET_PLATFORM} $ - VERBATIM -) -add_custom_target(flutter_assemble DEPENDS - "${FLUTTER_LIBRARY}" - ${FLUTTER_LIBRARY_HEADERS} - ${CPP_WRAPPER_SOURCES_CORE} - ${CPP_WRAPPER_SOURCES_PLUGIN} - ${CPP_WRAPPER_SOURCES_APP} -) diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc deleted file mode 100644 index e6e4ff9..0000000 --- a/windows/flutter/generated_plugin_registrant.cc +++ /dev/null @@ -1,26 +0,0 @@ -// -// Generated file. Do not edit. -// - -// clang-format off - -#include "generated_plugin_registrant.h" - -#include -#include -#include -#include -#include - -void RegisterPlugins(flutter::PluginRegistry* registry) { - DesktopWebviewWindowPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("DesktopWebviewWindowPlugin")); - FlutterAcrylicPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("FlutterAcrylicPlugin")); - ScreenRetrieverPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("ScreenRetrieverPlugin")); - UrlLauncherWindowsRegisterWithRegistrar( - registry->GetRegistrarForPlugin("UrlLauncherWindows")); - WindowManagerPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("WindowManagerPlugin")); -} diff --git a/windows/flutter/generated_plugin_registrant.h b/windows/flutter/generated_plugin_registrant.h deleted file mode 100644 index dc139d8..0000000 --- a/windows/flutter/generated_plugin_registrant.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// Generated file. Do not edit. -// - -// clang-format off - -#ifndef GENERATED_PLUGIN_REGISTRANT_ -#define GENERATED_PLUGIN_REGISTRANT_ - -#include - -// Registers Flutter plugins. -void RegisterPlugins(flutter::PluginRegistry* registry); - -#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake deleted file mode 100644 index 8a96cc6..0000000 --- a/windows/flutter/generated_plugins.cmake +++ /dev/null @@ -1,29 +0,0 @@ -# -# Generated file, do not edit. -# - -list(APPEND FLUTTER_PLUGIN_LIST - desktop_webview_window - flutter_acrylic - screen_retriever - url_launcher_windows - window_manager -) - -list(APPEND FLUTTER_FFI_PLUGIN_LIST - rust_builder -) - -set(PLUGIN_BUNDLED_LIBRARIES) - -foreach(plugin ${FLUTTER_PLUGIN_LIST}) - add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) - target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) - list(APPEND PLUGIN_BUNDLED_LIBRARIES $) - list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) -endforeach(plugin) - -foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) - add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) - list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) -endforeach(ffi_plugin) diff --git a/windows/runner/CMakeLists.txt b/windows/runner/CMakeLists.txt deleted file mode 100644 index fe3b29b..0000000 --- a/windows/runner/CMakeLists.txt +++ /dev/null @@ -1,42 +0,0 @@ -cmake_minimum_required(VERSION 3.14) -project(runner LANGUAGES CXX) - -# Define the application target. To change its name, change BINARY_NAME in the -# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer -# work. -# -# Any new source files that you add to the application should be added here. -add_executable(${BINARY_NAME} WIN32 - "flutter_window.cpp" - "main.cpp" - "utils.cpp" - "win32_window.cpp" - "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" - "Runner.rc" - "runner.exe.manifest" -) - -SET_TARGET_PROPERTIES(${BINARY_NAME} PROPERTIES LINK_FLAGS "/MANIFESTUAC:\"level='requireAdministrator' uiAccess='false'\" /SUBSYSTEM:WINDOWS") - -# Apply the standard set of build settings. This can be removed for applications -# that need different build settings. -apply_standard_settings(${BINARY_NAME}) - -# Add preprocessor definitions for the build version. -target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") -target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") -target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") -target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") -target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") - -# Disable Windows macros that collide with C++ standard library functions. -target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") - -# Add dependency libraries and include directories. Add any application-specific -# dependencies here. -target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) -target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") -target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") - -# Run the Flutter tool portions of the build. This must not be removed. -add_dependencies(${BINARY_NAME} flutter_assemble) diff --git a/windows/runner/Runner.rc b/windows/runner/Runner.rc deleted file mode 100644 index 62a4643..0000000 --- a/windows/runner/Runner.rc +++ /dev/null @@ -1,121 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#pragma code_page(65001) -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "winres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (United States) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""winres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_APP_ICON ICON "resources\\app_icon.ico" - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -#if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) -#define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD -#else -#define VERSION_AS_NUMBER 1,0,0,0 -#endif - -#if defined(FLUTTER_VERSION) -#define VERSION_AS_STRING FLUTTER_VERSION -#else -#define VERSION_AS_STRING "1.0.0" -#endif - -VS_VERSION_INFO VERSIONINFO - FILEVERSION VERSION_AS_NUMBER - PRODUCTVERSION VERSION_AS_NUMBER - FILEFLAGSMASK VS_FFI_FILEFLAGSMASK -#ifdef _DEBUG - FILEFLAGS VS_FF_DEBUG -#else - FILEFLAGS 0x0L -#endif - FILEOS VOS__WINDOWS32 - FILETYPE VFT_APP - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904e4" - BEGIN - VALUE "CompanyName", "com.xkeyc.tools.starcitizen.doctor" "\0" - VALUE "FileDescription", "starcitizen_doctor" "\0" - VALUE "FileVersion", VERSION_AS_STRING "\0" - VALUE "InternalName", "starcitizen_doctor" "\0" - VALUE "LegalCopyright", "Copyright (C) 2023 com.xkeyc.tools.starcitizen.doctor. All rights reserved." "\0" - VALUE "OriginalFilename", "starcitizen_doctor.exe" "\0" - VALUE "ProductName", "starcitizen_doctor" "\0" - VALUE "ProductVersion", VERSION_AS_STRING "\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1252 - END -END - -#endif // English (United States) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED diff --git a/windows/runner/flutter_window.cpp b/windows/runner/flutter_window.cpp deleted file mode 100644 index 955ee30..0000000 --- a/windows/runner/flutter_window.cpp +++ /dev/null @@ -1,71 +0,0 @@ -#include "flutter_window.h" - -#include - -#include "flutter/generated_plugin_registrant.h" - -FlutterWindow::FlutterWindow(const flutter::DartProject& project) - : project_(project) {} - -FlutterWindow::~FlutterWindow() {} - -bool FlutterWindow::OnCreate() { - if (!Win32Window::OnCreate()) { - return false; - } - - RECT frame = GetClientArea(); - - // The size here must match the window dimensions to avoid unnecessary surface - // creation / destruction in the startup path. - flutter_controller_ = std::make_unique( - frame.right - frame.left, frame.bottom - frame.top, project_); - // Ensure that basic setup of the controller was successful. - if (!flutter_controller_->engine() || !flutter_controller_->view()) { - return false; - } - RegisterPlugins(flutter_controller_->engine()); - SetChildContent(flutter_controller_->view()->GetNativeWindow()); - - flutter_controller_->engine()->SetNextFrameCallback([&]() { - this->Show(); - }); - - // Flutter can complete the first frame before the "show window" callback is - // registered. The following call ensures a frame is pending to ensure the - // window is shown. It is a no-op if the first frame hasn't completed yet. - flutter_controller_->ForceRedraw(); - - return true; -} - -void FlutterWindow::OnDestroy() { - if (flutter_controller_) { - flutter_controller_ = nullptr; - } - - Win32Window::OnDestroy(); -} - -LRESULT -FlutterWindow::MessageHandler(HWND hwnd, UINT const message, - WPARAM const wparam, - LPARAM const lparam) noexcept { - // Give Flutter, including plugins, an opportunity to handle window messages. - if (flutter_controller_) { - std::optional result = - flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, - lparam); - if (result) { - return *result; - } - } - - switch (message) { - case WM_FONTCHANGE: - flutter_controller_->engine()->ReloadSystemFonts(); - break; - } - - return Win32Window::MessageHandler(hwnd, message, wparam, lparam); -} diff --git a/windows/runner/flutter_window.h b/windows/runner/flutter_window.h deleted file mode 100644 index 6da0652..0000000 --- a/windows/runner/flutter_window.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef RUNNER_FLUTTER_WINDOW_H_ -#define RUNNER_FLUTTER_WINDOW_H_ - -#include -#include - -#include - -#include "win32_window.h" - -// A window that does nothing but host a Flutter view. -class FlutterWindow : public Win32Window { - public: - // Creates a new FlutterWindow hosting a Flutter view running |project|. - explicit FlutterWindow(const flutter::DartProject& project); - virtual ~FlutterWindow(); - - protected: - // Win32Window: - bool OnCreate() override; - void OnDestroy() override; - LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, - LPARAM const lparam) noexcept override; - - private: - // The project to run. - flutter::DartProject project_; - - // The Flutter instance hosted by this window. - std::unique_ptr flutter_controller_; -}; - -#endif // RUNNER_FLUTTER_WINDOW_H_ diff --git a/windows/runner/main.cpp b/windows/runner/main.cpp deleted file mode 100644 index f8453d2..0000000 --- a/windows/runner/main.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include -#include - -#include "flutter_window.h" -#include "utils.h" - -int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, - _In_ wchar_t *command_line, _In_ int show_command) { - // Attach to console when present (e.g., 'flutter run') or create a - // new console when running with a debugger. - if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { - CreateAndAttachConsole(); - } - - // Initialize COM, so that it is available for use in the library and/or - // plugins. - ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); - - flutter::DartProject project(L"data"); - - std::vector command_line_arguments = - GetCommandLineArguments(); - - project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); - - FlutterWindow window(project); - Win32Window::Point origin(0, 0); - Win32Window::Size size(1280, 720); - if (!window.Create(L"SCToolBox_init", origin, size)) { - return EXIT_FAILURE; - } - window.SetQuitOnClose(true); - - ::MSG msg; - while (::GetMessage(&msg, nullptr, 0, 0)) { - ::TranslateMessage(&msg); - ::DispatchMessage(&msg); - } - - ::CoUninitialize(); - return EXIT_SUCCESS; -} diff --git a/windows/runner/resource.h b/windows/runner/resource.h deleted file mode 100644 index 66a65d1..0000000 --- a/windows/runner/resource.h +++ /dev/null @@ -1,16 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by Runner.rc -// -#define IDI_APP_ICON 101 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 102 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1001 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/windows/runner/resources/app_icon.ico b/windows/runner/resources/app_icon.ico deleted file mode 100644 index f17875a..0000000 Binary files a/windows/runner/resources/app_icon.ico and /dev/null differ diff --git a/windows/runner/runner.exe.manifest b/windows/runner/runner.exe.manifest deleted file mode 100644 index a42ea76..0000000 --- a/windows/runner/runner.exe.manifest +++ /dev/null @@ -1,20 +0,0 @@ - - - - - PerMonitorV2 - - - - - - - - - - - - - - - diff --git a/windows/runner/utils.cpp b/windows/runner/utils.cpp deleted file mode 100644 index f5bf9fa..0000000 --- a/windows/runner/utils.cpp +++ /dev/null @@ -1,64 +0,0 @@ -#include "utils.h" - -#include -#include -#include -#include - -#include - -void CreateAndAttachConsole() { - if (::AllocConsole()) { - FILE *unused; - if (freopen_s(&unused, "CONOUT$", "w", stdout)) { - _dup2(_fileno(stdout), 1); - } - if (freopen_s(&unused, "CONOUT$", "w", stderr)) { - _dup2(_fileno(stdout), 2); - } - std::ios::sync_with_stdio(); - FlutterDesktopResyncOutputStreams(); - } -} - -std::vector GetCommandLineArguments() { - // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. - int argc; - wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); - if (argv == nullptr) { - return std::vector(); - } - - std::vector command_line_arguments; - - // Skip the first argument as it's the binary name. - for (int i = 1; i < argc; i++) { - command_line_arguments.push_back(Utf8FromUtf16(argv[i])); - } - - ::LocalFree(argv); - - return command_line_arguments; -} - -std::string Utf8FromUtf16(const wchar_t* utf16_string) { - if (utf16_string == nullptr) { - return std::string(); - } - int target_length = ::WideCharToMultiByte( - CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, - -1, nullptr, 0, nullptr, nullptr); - std::string utf8_string; - if (target_length == 0 || target_length > utf8_string.max_size()) { - return utf8_string; - } - utf8_string.resize(target_length); - int converted_length = ::WideCharToMultiByte( - CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, - -1, utf8_string.data(), - target_length, nullptr, nullptr); - if (converted_length == 0) { - return std::string(); - } - return utf8_string; -} diff --git a/windows/runner/utils.h b/windows/runner/utils.h deleted file mode 100644 index 3879d54..0000000 --- a/windows/runner/utils.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef RUNNER_UTILS_H_ -#define RUNNER_UTILS_H_ - -#include -#include - -// Creates a console for the process, and redirects stdout and stderr to -// it for both the runner and the Flutter library. -void CreateAndAttachConsole(); - -// Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string -// encoded in UTF-8. Returns an empty std::string on failure. -std::string Utf8FromUtf16(const wchar_t* utf16_string); - -// Gets the command line arguments passed in as a std::vector, -// encoded in UTF-8. Returns an empty std::vector on failure. -std::vector GetCommandLineArguments(); - -#endif // RUNNER_UTILS_H_ diff --git a/windows/runner/win32_window.cpp b/windows/runner/win32_window.cpp deleted file mode 100644 index 041a385..0000000 --- a/windows/runner/win32_window.cpp +++ /dev/null @@ -1,288 +0,0 @@ -#include "win32_window.h" - -#include -#include - -#include "resource.h" - -namespace { - -/// Window attribute that enables dark mode window decorations. -/// -/// Redefined in case the developer's machine has a Windows SDK older than -/// version 10.0.22000.0. -/// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute -#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE -#define DWMWA_USE_IMMERSIVE_DARK_MODE 20 -#endif - -constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; - -/// Registry key for app theme preference. -/// -/// A value of 0 indicates apps should use dark mode. A non-zero or missing -/// value indicates apps should use light mode. -constexpr const wchar_t kGetPreferredBrightnessRegKey[] = - L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"; -constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme"; - -// The number of Win32Window objects that currently exist. -static int g_active_window_count = 0; - -using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); - -// Scale helper to convert logical scaler values to physical using passed in -// scale factor -int Scale(int source, double scale_factor) { - return static_cast(source * scale_factor); -} - -// Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. -// This API is only needed for PerMonitor V1 awareness mode. -void EnableFullDpiSupportIfAvailable(HWND hwnd) { - HMODULE user32_module = LoadLibraryA("User32.dll"); - if (!user32_module) { - return; - } - auto enable_non_client_dpi_scaling = - reinterpret_cast( - GetProcAddress(user32_module, "EnableNonClientDpiScaling")); - if (enable_non_client_dpi_scaling != nullptr) { - enable_non_client_dpi_scaling(hwnd); - } - FreeLibrary(user32_module); -} - -} // namespace - -// Manages the Win32Window's window class registration. -class WindowClassRegistrar { - public: - ~WindowClassRegistrar() = default; - - // Returns the singleton registar instance. - static WindowClassRegistrar* GetInstance() { - if (!instance_) { - instance_ = new WindowClassRegistrar(); - } - return instance_; - } - - // Returns the name of the window class, registering the class if it hasn't - // previously been registered. - const wchar_t* GetWindowClass(); - - // Unregisters the window class. Should only be called if there are no - // instances of the window. - void UnregisterWindowClass(); - - private: - WindowClassRegistrar() = default; - - static WindowClassRegistrar* instance_; - - bool class_registered_ = false; -}; - -WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; - -const wchar_t* WindowClassRegistrar::GetWindowClass() { - if (!class_registered_) { - WNDCLASS window_class{}; - window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); - window_class.lpszClassName = kWindowClassName; - window_class.style = CS_HREDRAW | CS_VREDRAW; - window_class.cbClsExtra = 0; - window_class.cbWndExtra = 0; - window_class.hInstance = GetModuleHandle(nullptr); - window_class.hIcon = - LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); - window_class.hbrBackground = 0; - window_class.lpszMenuName = nullptr; - window_class.lpfnWndProc = Win32Window::WndProc; - RegisterClass(&window_class); - class_registered_ = true; - } - return kWindowClassName; -} - -void WindowClassRegistrar::UnregisterWindowClass() { - UnregisterClass(kWindowClassName, nullptr); - class_registered_ = false; -} - -Win32Window::Win32Window() { - ++g_active_window_count; -} - -Win32Window::~Win32Window() { - --g_active_window_count; - Destroy(); -} - -bool Win32Window::Create(const std::wstring& title, - const Point& origin, - const Size& size) { - Destroy(); - - const wchar_t* window_class = - WindowClassRegistrar::GetInstance()->GetWindowClass(); - - const POINT target_point = {static_cast(origin.x), - static_cast(origin.y)}; - HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); - UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); - double scale_factor = dpi / 96.0; - - HWND window = CreateWindow( - window_class, title.c_str(), WS_OVERLAPPEDWINDOW, - Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), - Scale(size.width, scale_factor), Scale(size.height, scale_factor), - nullptr, nullptr, GetModuleHandle(nullptr), this); - - if (!window) { - return false; - } - - UpdateTheme(window); - - return OnCreate(); -} - -bool Win32Window::Show() { - return ShowWindow(window_handle_, SW_SHOWNORMAL); -} - -// static -LRESULT CALLBACK Win32Window::WndProc(HWND const window, - UINT const message, - WPARAM const wparam, - LPARAM const lparam) noexcept { - if (message == WM_NCCREATE) { - auto window_struct = reinterpret_cast(lparam); - SetWindowLongPtr(window, GWLP_USERDATA, - reinterpret_cast(window_struct->lpCreateParams)); - - auto that = static_cast(window_struct->lpCreateParams); - EnableFullDpiSupportIfAvailable(window); - that->window_handle_ = window; - } else if (Win32Window* that = GetThisFromHandle(window)) { - return that->MessageHandler(window, message, wparam, lparam); - } - - return DefWindowProc(window, message, wparam, lparam); -} - -LRESULT -Win32Window::MessageHandler(HWND hwnd, - UINT const message, - WPARAM const wparam, - LPARAM const lparam) noexcept { - switch (message) { - case WM_DESTROY: - window_handle_ = nullptr; - Destroy(); - if (quit_on_close_) { - PostQuitMessage(0); - } - return 0; - - case WM_DPICHANGED: { - auto newRectSize = reinterpret_cast(lparam); - LONG newWidth = newRectSize->right - newRectSize->left; - LONG newHeight = newRectSize->bottom - newRectSize->top; - - SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, - newHeight, SWP_NOZORDER | SWP_NOACTIVATE); - - return 0; - } - case WM_SIZE: { - RECT rect = GetClientArea(); - if (child_content_ != nullptr) { - // Size and position the child window. - MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, - rect.bottom - rect.top, TRUE); - } - return 0; - } - - case WM_ACTIVATE: - if (child_content_ != nullptr) { - SetFocus(child_content_); - } - return 0; - - case WM_DWMCOLORIZATIONCOLORCHANGED: - UpdateTheme(hwnd); - return 0; - } - - return DefWindowProc(window_handle_, message, wparam, lparam); -} - -void Win32Window::Destroy() { - OnDestroy(); - - if (window_handle_) { - DestroyWindow(window_handle_); - window_handle_ = nullptr; - } - if (g_active_window_count == 0) { - WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); - } -} - -Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { - return reinterpret_cast( - GetWindowLongPtr(window, GWLP_USERDATA)); -} - -void Win32Window::SetChildContent(HWND content) { - child_content_ = content; - SetParent(content, window_handle_); - RECT frame = GetClientArea(); - - MoveWindow(content, frame.left, frame.top, frame.right - frame.left, - frame.bottom - frame.top, true); - - SetFocus(child_content_); -} - -RECT Win32Window::GetClientArea() { - RECT frame; - GetClientRect(window_handle_, &frame); - return frame; -} - -HWND Win32Window::GetHandle() { - return window_handle_; -} - -void Win32Window::SetQuitOnClose(bool quit_on_close) { - quit_on_close_ = quit_on_close; -} - -bool Win32Window::OnCreate() { - // No-op; provided for subclasses. - return true; -} - -void Win32Window::OnDestroy() { - // No-op; provided for subclasses. -} - -void Win32Window::UpdateTheme(HWND const window) { - DWORD light_mode; - DWORD light_mode_size = sizeof(light_mode); - LSTATUS result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey, - kGetPreferredBrightnessRegValue, - RRF_RT_REG_DWORD, nullptr, &light_mode, - &light_mode_size); - - if (result == ERROR_SUCCESS) { - BOOL enable_dark_mode = light_mode == 0; - DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE, - &enable_dark_mode, sizeof(enable_dark_mode)); - } -} diff --git a/windows/runner/win32_window.h b/windows/runner/win32_window.h deleted file mode 100644 index c86632d..0000000 --- a/windows/runner/win32_window.h +++ /dev/null @@ -1,102 +0,0 @@ -#ifndef RUNNER_WIN32_WINDOW_H_ -#define RUNNER_WIN32_WINDOW_H_ - -#include - -#include -#include -#include - -// A class abstraction for a high DPI-aware Win32 Window. Intended to be -// inherited from by classes that wish to specialize with custom -// rendering and input handling -class Win32Window { - public: - struct Point { - unsigned int x; - unsigned int y; - Point(unsigned int x, unsigned int y) : x(x), y(y) {} - }; - - struct Size { - unsigned int width; - unsigned int height; - Size(unsigned int width, unsigned int height) - : width(width), height(height) {} - }; - - Win32Window(); - virtual ~Win32Window(); - - // Creates a win32 window with |title| that is positioned and sized using - // |origin| and |size|. New windows are created on the default monitor. Window - // sizes are specified to the OS in physical pixels, hence to ensure a - // consistent size this function will scale the inputted width and height as - // as appropriate for the default monitor. The window is invisible until - // |Show| is called. Returns true if the window was created successfully. - bool Create(const std::wstring& title, const Point& origin, const Size& size); - - // Show the current window. Returns true if the window was successfully shown. - bool Show(); - - // Release OS resources associated with window. - void Destroy(); - - // Inserts |content| into the window tree. - void SetChildContent(HWND content); - - // Returns the backing Window handle to enable clients to set icon and other - // window properties. Returns nullptr if the window has been destroyed. - HWND GetHandle(); - - // If true, closing this window will quit the application. - void SetQuitOnClose(bool quit_on_close); - - // Return a RECT representing the bounds of the current client area. - RECT GetClientArea(); - - protected: - // Processes and route salient window messages for mouse handling, - // size change and DPI. Delegates handling of these to member overloads that - // inheriting classes can handle. - virtual LRESULT MessageHandler(HWND window, - UINT const message, - WPARAM const wparam, - LPARAM const lparam) noexcept; - - // Called when CreateAndShow is called, allowing subclass window-related - // setup. Subclasses should return false if setup fails. - virtual bool OnCreate(); - - // Called when Destroy is called. - virtual void OnDestroy(); - - private: - friend class WindowClassRegistrar; - - // OS callback called by message pump. Handles the WM_NCCREATE message which - // is passed when the non-client area is being created and enables automatic - // non-client DPI scaling so that the non-client area automatically - // responsponds to changes in DPI. All other messages are handled by - // MessageHandler. - static LRESULT CALLBACK WndProc(HWND const window, - UINT const message, - WPARAM const wparam, - LPARAM const lparam) noexcept; - - // Retrieves a class instance pointer for |window| - static Win32Window* GetThisFromHandle(HWND const window) noexcept; - - // Update the window frame's theme to match the system theme. - static void UpdateTheme(HWND const window); - - bool quit_on_close_ = false; - - // window handle for top level window. - HWND window_handle_ = nullptr; - - // window handle for hosted content. - HWND child_content_ = nullptr; -}; - -#endif // RUNNER_WIN32_WINDOW_H_