mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-05 20:30:27 +08:00
Compare commits
4 Commits
feat/self_
...
refactor/a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2a7d2bb7f3 | ||
|
|
834a2b0294 | ||
|
|
d158150053 | ||
|
|
075fe5450b |
244
.clang-format
244
.clang-format
@@ -1,42 +1,35 @@
|
||||
# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
|
||||
# for clang-format 20.0.0
|
||||
Language: Json
|
||||
ColumnLimit: 1000
|
||||
IndentWidth: 4
|
||||
---
|
||||
Language: Cpp
|
||||
BasedOnStyle: "WebKit"
|
||||
# AccessModifierOffset: 2
|
||||
AlignAfterOpenBracket: "AlwaysBreak"
|
||||
AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignArrayOfStructures: None
|
||||
AlignConsecutiveMacros: None
|
||||
AlignConsecutiveAssignments: None
|
||||
AlignConsecutiveBitFields: None
|
||||
AlignConsecutiveDeclarations: None
|
||||
AlignConsecutiveMacros: None
|
||||
# AlignConsecutiveShortCaseStatements: None
|
||||
AlignEscapedNewlines: Left
|
||||
AlignOperands: Align
|
||||
AlignTrailingComments:
|
||||
Kind: Always
|
||||
OverEmptyLines: 1
|
||||
AllowAllArgumentsOnNextLine: false
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
# AllowShortCompoundRequirementOnASingleLine: true
|
||||
AlignTrailingComments: true
|
||||
AllowAllArgumentsOnNextLine: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowShortEnumsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: InlineOnly
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLambdasOnASingleLine: Inline
|
||||
AllowShortBlocksOnASingleLine: Empty
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: Inline
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: WithoutElse
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
BreakAfterReturnType: Automatic
|
||||
AlwaysBreakBeforeMultilineStrings: true
|
||||
BreakTemplateDeclarations: Yes
|
||||
# AttributeMacros:
|
||||
# - __pragma
|
||||
# - _Pragma
|
||||
# - __attribute__
|
||||
# - __declspec
|
||||
BinPackArguments: false
|
||||
BinPackParameters: false
|
||||
BitFieldColonSpacing: After
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: true
|
||||
AttributeMacros:
|
||||
- __capability
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: true
|
||||
@@ -44,148 +37,159 @@ BraceWrapping:
|
||||
AfterEnum: true
|
||||
AfterFunction: true
|
||||
AfterNamespace: true
|
||||
# AfterObjCDeclaration: true
|
||||
AfterObjCDeclaration: true
|
||||
AfterStruct: true
|
||||
AfterUnion: true
|
||||
AfterUnion: false
|
||||
AfterExternBlock: true
|
||||
BeforeCatch: true
|
||||
BeforeElse: true
|
||||
BeforeLambdaBody: false
|
||||
BeforeWhile: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: true
|
||||
SplitEmptyRecord: true
|
||||
SplitEmptyNamespace: true
|
||||
# BracedInitializerIndentWidth: 4
|
||||
BreakAfterAttributes: Never
|
||||
BreakAfterJavaFieldAnnotations: true
|
||||
BreakArrays: true
|
||||
SplitEmptyFunction: false
|
||||
SplitEmptyRecord: false
|
||||
SplitEmptyNamespace: false
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeConceptDeclarations: true
|
||||
BreakBeforeBraces: Custom
|
||||
BreakBeforeConceptDeclarations: Always
|
||||
BreakBeforeInlineASMColon: OnlyMultiline
|
||||
BreakBeforeInheritanceComma: false
|
||||
BreakInheritanceList: BeforeColon
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializers: AfterColon
|
||||
BreakInheritanceList: AfterColon
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakStringLiterals: true
|
||||
ColumnLimit: 120
|
||||
# CommentPragmas: '^ MEO pragma:'
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
QualifierAlignment: Leave
|
||||
CompactNamespaces: false
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: false
|
||||
DeriveLineEnding: true
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
EmptyLineAfterAccessModifier: Never
|
||||
EmptyLineBeforeAccessModifier: LogicalBlock
|
||||
# ExperimentalAutoDetectBinPacking: true
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
PackConstructorInitializers: BinPack
|
||||
BasedOnStyle: ''
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||
AllowAllConstructorInitializersOnNextLine: true
|
||||
FixNamespaceComments: true
|
||||
# ForEachMacros:
|
||||
# - foreach
|
||||
# - Q_FOREACH
|
||||
# - BOOST_FOREACH
|
||||
# IfMacros:
|
||||
# - 'KJ_IF_MAYBE'
|
||||
ForEachMacros:
|
||||
- foreach
|
||||
- Q_FOREACH
|
||||
- BOOST_FOREACH
|
||||
IfMacros:
|
||||
- KJ_IF_MAYBE
|
||||
IncludeBlocks: Preserve
|
||||
# IncludeCategories:
|
||||
# IncludeIsMainRegex:
|
||||
# IncludeIsMainSourceRegex:
|
||||
IncludeCategories:
|
||||
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
|
||||
Priority: 2
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
|
||||
Priority: 3
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
- Regex: '.*'
|
||||
Priority: 1
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
IncludeIsMainRegex: '(Test)?$'
|
||||
IncludeIsMainSourceRegex: ''
|
||||
IndentAccessModifiers: false
|
||||
IndentCaseBlocks: false
|
||||
IndentCaseLabels: false
|
||||
IndentExternBlock: AfterExternBlock
|
||||
IndentGotoLabels: false
|
||||
IndentCaseBlocks: false
|
||||
IndentGotoLabels: true
|
||||
IndentPPDirectives: None
|
||||
IndentExternBlock: AfterExternBlock
|
||||
IndentRequiresClause: false
|
||||
IndentWidth: 4
|
||||
IndentWrappedFunctionNames: true
|
||||
InsertBraces: true
|
||||
InsertNewlineAtEOF: true
|
||||
InsertTrailingCommas: Wrapped
|
||||
IntegerLiteralSeparator:
|
||||
Binary: 4
|
||||
BinaryMinDigits: 9
|
||||
Decimal: 3
|
||||
DecimalMinDigits: 7
|
||||
Hex: -1
|
||||
# JavaImportGroups:
|
||||
# JavaScriptQuotes:
|
||||
# JavaScriptWrapImports:
|
||||
KeepEmptyLinesAtEOF: true
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
IndentWrappedFunctionNames: false
|
||||
InsertTrailingCommas: None
|
||||
JavaScriptQuotes: Leave
|
||||
JavaScriptWrapImports: true
|
||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
LambdaBodyIndentation: Signature
|
||||
# LineEnding: LF
|
||||
# MacroBlockBegin: "MAA.*_NS_BEGIN$"
|
||||
# MacroBlockEnd: "MAA.*_NS_END$"
|
||||
# Macros:
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: None
|
||||
# NamespaceMacros:
|
||||
# ObjCBinPackProtocolList:
|
||||
# ObjCBlockIndentWidth:
|
||||
# ObjCBreakBeforeNestedBlockParam:
|
||||
# ObjCSpaceAfterProperty:
|
||||
# ObjCSpaceBeforeProtocolList:
|
||||
PackConstructorInitializers: Never
|
||||
# PenaltyBreakAssignment:
|
||||
# PenaltyBreakBeforeFirstCallParameter:
|
||||
# PenaltyBreakComment:
|
||||
# PenaltyBreakFirstLessLess:
|
||||
# PenaltyBreakOpenParenthesis:
|
||||
# PenaltyBreakTemplateDeclaration:
|
||||
# PenaltyExcessCharacter:
|
||||
# PenaltyIndentedWhitespace:
|
||||
# PenaltyReturnTypeOnItsOwnLine:
|
||||
NamespaceIndentation: All
|
||||
ObjCBinPackProtocolList: Auto
|
||||
ObjCBlockIndentWidth: 2
|
||||
ObjCBreakBeforeNestedBlockParam: true
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PenaltyBreakAssignment: 2
|
||||
PenaltyBreakBeforeFirstCallParameter: 19
|
||||
PenaltyBreakComment: 300
|
||||
PenaltyBreakFirstLessLess: 120
|
||||
PenaltyBreakOpenParenthesis: 0
|
||||
PenaltyBreakString: 1000
|
||||
PenaltyBreakTemplateDeclaration: 10
|
||||
PenaltyExcessCharacter: 1000000
|
||||
PenaltyReturnTypeOnItsOwnLine: 1000
|
||||
PenaltyIndentedWhitespace: 0
|
||||
PointerAlignment: Left
|
||||
# QualifierAlignment: Custom
|
||||
# QualifierOrder:
|
||||
# - inline
|
||||
# - static
|
||||
# - const
|
||||
# - constexpr
|
||||
# - type
|
||||
ReferenceAlignment: Left
|
||||
ReflowComments: Always
|
||||
PPIndentWidth: -1
|
||||
ReferenceAlignment: Pointer
|
||||
ReflowComments: true
|
||||
RemoveBracesLLVM: false
|
||||
RemoveParentheses: Leave
|
||||
RemoveSemicolon: false
|
||||
RequiresClausePosition: OwnLine
|
||||
RequiresExpressionIndentation: OuterScope
|
||||
SeparateDefinitionBlocks: Always
|
||||
ShortNamespaceLines: 1000
|
||||
SeparateDefinitionBlocks: Leave
|
||||
ShortNamespaceLines: 50
|
||||
SortIncludes: CaseSensitive
|
||||
# SortJavaStaticImport:
|
||||
SortUsingDeclarations: Lexicographic
|
||||
SortJavaStaticImport: Before
|
||||
SortUsingDeclarations: true
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: true
|
||||
SpaceAroundPointerQualifiers: Default
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCaseColon: false
|
||||
SpaceBeforeCpp11BracedList: true
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeJsonColon: false
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
# SpaceBeforeParensOptions:
|
||||
SpaceBeforeParensOptions:
|
||||
AfterControlStatements: true
|
||||
AfterForeachMacros: true
|
||||
AfterFunctionDefinitionName: false
|
||||
AfterFunctionDeclarationName: false
|
||||
AfterIfMacros: true
|
||||
AfterOverloadedOperator: false
|
||||
AfterRequiresInClause: true
|
||||
AfterRequiresInExpression: true
|
||||
BeforeNonEmptyParentheses: false
|
||||
SpaceAroundPointerQualifiers: Default
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceBeforeSquareBrackets: false
|
||||
SpaceInEmptyBlock: false
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: Never
|
||||
SpacesInConditionalStatement: false
|
||||
SpacesInContainerLiterals: true
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInLineCommentPrefix:
|
||||
Minimum: 1
|
||||
Maximum: -1
|
||||
SpacesInParens: Never
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
SpaceBeforeSquareBrackets: false
|
||||
BitFieldColonSpacing: Both
|
||||
Standard: c++20
|
||||
# StatementAttributeLikeMacros:
|
||||
# StatementMacros:
|
||||
StatementAttributeLikeMacros:
|
||||
- Q_EMIT
|
||||
StatementMacros:
|
||||
- Q_UNUSED
|
||||
- QT_REQUIRE_VERSION
|
||||
TabWidth: 4
|
||||
# TypeNames:
|
||||
# TypenameMacros:
|
||||
UseCRLF: false
|
||||
UseTab: Never
|
||||
# VerilogBreakBetweenInstancePorts:
|
||||
# WhitespaceSensitiveMacros:
|
||||
RemoveEmptyLinesInUnwrappedLines: true
|
||||
WhitespaceSensitiveMacros:
|
||||
- STRINGIZE
|
||||
- PP_STRINGIZE
|
||||
- BOOST_PP_STRINGIZE
|
||||
- NS_SWIFT_NAME
|
||||
- CF_SWIFT_NAME
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
FROM mcr.microsoft.com/devcontainers/base:ubuntu
|
||||
|
||||
USER vscode
|
||||
|
||||
ENV CONDA_DIR=/home/vscode/miniconda
|
||||
ENV PATH="$CONDA_DIR/bin:$PATH"
|
||||
|
||||
ARG PYTHON_VERSION=3.12
|
||||
ARG NODEJS_VERSION=24
|
||||
|
||||
# Install Miniconda
|
||||
RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh \
|
||||
&& bash ~/miniconda.sh -b -p $CONDA_DIR \
|
||||
&& rm ~/miniconda.sh \
|
||||
&& conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main \
|
||||
&& conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/r
|
||||
|
||||
# Configure conda environment
|
||||
RUN eval "$(conda shell.bash hook)" \
|
||||
&& conda create -n maa python=$PYTHON_VERSION -y \
|
||||
&& conda activate maa \
|
||||
&& conda install -y conda-forge::nodejs=$NODEJS_VERSION \
|
||||
&& pip install pre-commit black \
|
||||
&& npm install -g pnpm
|
||||
|
||||
# Finalize conda setup
|
||||
RUN conda init \
|
||||
&& conda config --set auto_activate false \
|
||||
&& echo "conda activate maa" >> ~/.bashrc
|
||||
@@ -1,50 +1,16 @@
|
||||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
|
||||
// README at: https://github.com/devcontainers/templates/tree/main/src/javascript-node
|
||||
{
|
||||
"name": "MAA",
|
||||
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
|
||||
// "image": "mcr.microsoft.com/devcontainers/base:ubuntu",
|
||||
"build": {
|
||||
"dockerfile": "Dockerfile"
|
||||
"image": "mcr.microsoft.com/devcontainers/cpp:ubuntu-22.04",
|
||||
"features": {
|
||||
"ghcr.io/devcontainers/features/python:1": {},
|
||||
"ghcr.io/devcontainers/features/sshd:1": {}
|
||||
},
|
||||
// Features to add to the dev container. More info: https://containers.dev/features.
|
||||
// "features": {},
|
||||
|
||||
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
||||
"forwardPorts": [3001],
|
||||
|
||||
// Use 'postCreateCommand' to run commands after the container is created.
|
||||
"postCreateCommand": "bash .devcontainer/post-create.sh",
|
||||
|
||||
// Configure tool-specific properties.
|
||||
"postCreateCommand": "sudo sh -ce 'apt update && apt install g++-12 -y && echo export CC=gcc-12 CXX=g++-12 >> /etc/profile.d/set-compiler.sh'",
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
"extensions": [
|
||||
"mkxml.vscode-filesize",
|
||||
"nekosu.maa-support",
|
||||
"DavidAnson.vscode-markdownlint",
|
||||
"esbenp.prettier-vscode",
|
||||
"vue.volar",
|
||||
"ms-python.python",
|
||||
"ms-python.black-formatter"
|
||||
],
|
||||
"settings": {
|
||||
// format
|
||||
"editor.formatOnSave": true,
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"[markdown]": {
|
||||
"editor.defaultFormatter": "DavidAnson.vscode-markdownlint"
|
||||
},
|
||||
"[python]": {
|
||||
"editor.defaultFormatter": "ms-python.black-formatter"
|
||||
},
|
||||
// python
|
||||
"python.terminal.launchArgs": ["-u"],
|
||||
"python.defaultInterpreterPath": "/home/vscode/miniconda/envs/maa/bin/python",
|
||||
"python.terminal.activateEnvironment": false
|
||||
}
|
||||
"llvm-vs-code-extensions.vscode-clangd",
|
||||
"DavidAnson.vscode-markdownlint"
|
||||
]
|
||||
}
|
||||
}
|
||||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
|
||||
// "remoteUser": "root"
|
||||
}
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
#!/bin/bash
|
||||
WORKSPACE=$(pwd)
|
||||
|
||||
# conda activate maa
|
||||
|
||||
echo "===================="
|
||||
echo "Setting up git safe.directory for $WORKSPACE and its submodules..."
|
||||
cd "$WORKSPACE"
|
||||
git config --global --add safe.directory "$WORKSPACE"
|
||||
git submodule foreach --recursive 'git config --global --add safe.directory "$toplevel/$path"'
|
||||
|
||||
echo "===================="
|
||||
cd "$WORKSPACE"
|
||||
echo "Installing dependencies for python..."
|
||||
# pip install -r tools/.../requirements.txt
|
||||
# pip install -r tools/.../requirements-dev.txt
|
||||
|
||||
echo "===================="
|
||||
echo "Installing dependencies for nodejs..."
|
||||
cd "$WORKSPACE"/docs
|
||||
pnpm install --frozen-lockfile
|
||||
@@ -10,3 +10,72 @@ end_of_line = lf
|
||||
[*.json]
|
||||
|
||||
indent_size = 4
|
||||
|
||||
[*.{c++,cc,cpp,cppm,cxx,h,h++,hh,hpp,hxx,inl,ipp,ixx,tlh,tli}]
|
||||
|
||||
indent_size = 4
|
||||
|
||||
# Visual C++ Code Style settings
|
||||
|
||||
cpp_generate_documentation_comments = xml
|
||||
|
||||
# Visual C++ Formatting settings
|
||||
|
||||
cpp_indent_braces = false
|
||||
cpp_indent_multi_line_relative_to = innermost_parenthesis
|
||||
cpp_indent_within_parentheses = indent
|
||||
cpp_indent_preserve_within_parentheses = true
|
||||
cpp_indent_case_contents = true
|
||||
cpp_indent_case_labels = false
|
||||
cpp_indent_case_contents_when_block = false
|
||||
cpp_indent_lambda_braces_when_parameter = true
|
||||
cpp_indent_goto_labels = one_left
|
||||
cpp_indent_preprocessor = leftmost_column
|
||||
cpp_indent_access_specifiers = false
|
||||
cpp_indent_namespace_contents = true
|
||||
cpp_indent_preserve_comments = false
|
||||
cpp_new_line_before_open_brace_namespace = new_line
|
||||
cpp_new_line_before_open_brace_type = new_line
|
||||
cpp_new_line_before_open_brace_function = new_line
|
||||
cpp_new_line_before_open_brace_block = same_line
|
||||
cpp_new_line_before_open_brace_lambda = same_line
|
||||
cpp_new_line_scope_braces_on_separate_lines = false
|
||||
cpp_new_line_close_brace_same_line_empty_type = false
|
||||
cpp_new_line_close_brace_same_line_empty_function = false
|
||||
cpp_new_line_before_catch = true
|
||||
cpp_new_line_before_else = true
|
||||
cpp_new_line_before_while_in_do_while = false
|
||||
cpp_space_before_function_open_parenthesis = remove
|
||||
cpp_space_within_parameter_list_parentheses = false
|
||||
cpp_space_between_empty_parameter_list_parentheses = false
|
||||
cpp_space_after_keywords_in_control_flow_statements = true
|
||||
cpp_space_within_control_flow_statement_parentheses = false
|
||||
cpp_space_before_lambda_open_parenthesis = false
|
||||
cpp_space_within_cast_parentheses = false
|
||||
cpp_space_after_cast_close_parenthesis = false
|
||||
cpp_space_within_expression_parentheses = false
|
||||
cpp_space_before_block_open_brace = true
|
||||
cpp_space_between_empty_braces = false
|
||||
cpp_space_before_initializer_list_open_brace = false
|
||||
cpp_space_within_initializer_list_braces = true
|
||||
cpp_space_preserve_in_initializer_list = true
|
||||
cpp_space_before_open_square_bracket = false
|
||||
cpp_space_within_square_brackets = false
|
||||
cpp_space_before_empty_square_brackets = false
|
||||
cpp_space_between_empty_square_brackets = false
|
||||
cpp_space_group_square_brackets = true
|
||||
cpp_space_within_lambda_brackets = false
|
||||
cpp_space_between_empty_lambda_brackets = false
|
||||
cpp_space_before_comma = false
|
||||
cpp_space_after_comma = true
|
||||
cpp_space_remove_around_member_operators = true
|
||||
cpp_space_before_inheritance_colon = true
|
||||
cpp_space_before_constructor_colon = true
|
||||
cpp_space_remove_before_semicolon = true
|
||||
cpp_space_after_semicolon = false
|
||||
cpp_space_remove_around_unary_operator = true
|
||||
cpp_space_around_binary_operator = insert
|
||||
cpp_space_around_assignment_operator = insert
|
||||
cpp_space_pointer_reference_alignment = left
|
||||
cpp_space_around_ternary_operator = insert
|
||||
cpp_wrap_preserve_blocks = one_liners
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
290cc30f153a0206bd870a0a58cb6338aa16ea34
|
||||
db9afdc77e85d5fc462d923fca5318be021656cd
|
||||
a5daac889a55baf8895918d4964f20dad1938470
|
||||
9ed30c5658c88edf1ef839771a53c7d599183b8b
|
||||
|
||||
# incorrect format of 3rdparty/resource/Arknights-Tile-Pos/levels.json
|
||||
65d654e54b9d04d1902c9ee9f9fb2679520adafd
|
||||
@@ -23,7 +22,6 @@ a5daac889a55baf8895918d4964f20dad1938470
|
||||
206df466fd5e3d8ef80387049b0c5011fb58cada
|
||||
c9b5aa638a97397ab8666031ea646904527afc09
|
||||
559c913fca0dd0966896396e251be13f76ea3e52
|
||||
|
||||
# Re-structure again.
|
||||
4b3b84df8f487be0ac86506c28dbebc4635f1282
|
||||
91abbb7f175b93a58368a136acf3799666f770d2
|
||||
@@ -31,24 +29,3 @@ c9b5aa638a97397ab8666031ea646904527afc09
|
||||
bae271c09bb79e5cc2a7f8491ce882d276ac97b4
|
||||
3d83b80dd67d996a5f4f1732fe1eb36cacc7605e
|
||||
21617270bcef2456cb7f89e54560ca6788450711
|
||||
|
||||
# resource/*.json prettier mass styling
|
||||
d84da5d01a872540d520bc87408d4524e07cfa39
|
||||
546bfc399cdd140a9812f44b5e6bc89fccfda5fa
|
||||
f0bdccdf0da7fac29f475951f0f43d3ab56a7ffe
|
||||
7a758bce844bc2778f04a789195efbd17681dac7
|
||||
5f3730b76785b1168125eb3b5edbed399722f8f9
|
||||
bc3ad67a02cb3b8e154c06955cf17091c4265000
|
||||
|
||||
# oxipng template optimization
|
||||
e3d63894b28b2ef5e2405e144a32a6981de5e1b2
|
||||
|
||||
# refactor: divide tasks.json into multiple jsons
|
||||
dce6e317c8e56836662b64ac4b3d1a69b4ff4dd8
|
||||
|
||||
# usage: add "[blame ignore]" to the commit message
|
||||
# This file is managed by an automated workflow
|
||||
# Do not add, remove or modify lines below this comment
|
||||
# as they are automatically appended
|
||||
# --------------------------------------------------- #
|
||||
f7772bc814c52f9a5e65af02404cf54b70fe0a32
|
||||
|
||||
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -8,5 +8,4 @@
|
||||
|
||||
*.json text eol=lf
|
||||
*.md text eol=lf
|
||||
*.yml text eol=lf
|
||||
*.yaml text eol=lf
|
||||
|
||||
1
.github/.last-blame-ignore-commit
vendored
1
.github/.last-blame-ignore-commit
vendored
@@ -1 +0,0 @@
|
||||
272d71fa2938f945832f86232532b86a9e5406b8
|
||||
60
.github/ISSUE_TEMPLATE/cn-bug-report.yaml
vendored
60
.github/ISSUE_TEMPLATE/cn-bug-report.yaml
vendored
@@ -1,22 +1,20 @@
|
||||
name: Bug 反馈(使用中文)
|
||||
description: 识别错误、操作异常、连接错误等
|
||||
labels: ["bug"]
|
||||
labels: ['bug']
|
||||
body:
|
||||
- type: checkboxes
|
||||
id: checks
|
||||
attributes:
|
||||
label: 请确认自己完成了下列必选项之后再进行勾选,若未完成必选项或勾选了"我未仔细阅读"选项将视为自愿接受被直接关闭 Issue
|
||||
label: 在提问之前...
|
||||
options:
|
||||
- label: 我理解 Issue 是用于反馈和解决问题的,而非吐槽评论区,将尽可能提供更多信息帮助问题解决
|
||||
required: false
|
||||
- label: 我未仔细阅读这些内容,只是一键已读[所有内容](/MaaAssistantArknights/MaaAssistantArknights/issues),并相信这不会影响问题的处理
|
||||
required: false
|
||||
- label: 我填写了简短且清晰明确的标题,以便开发者在翻阅 Issue 列表时能快速确定大致问题。而不是“一个建议”、“卡住了”等
|
||||
required: false
|
||||
- label: 我使用的是当前更新版本的最新版, 并已查看版本发布至今的 [更新内容](https://github.com/MaaAssistantArknights/MaaAssistantArknights/commits/dev/), [Pull Requests](https://github.com/MaaAssistantArknights/MaaAssistantArknights/pulls) 中尚未发布的更新内容并未提及该 Bug 已被修复的情况
|
||||
required: false
|
||||
- label: 我已检查了 [常见问题](https://docs.maa.plus/zh-cn/manual/faq.html), [公告](https://github.com/MaaAssistantArknights/MaaAssistantArknights/issues/7732), [活跃议题](https://github.com/MaaAssistantArknights/MaaAssistantArknights/issues), [已关闭议题](https://github.com/MaaAssistantArknights/MaaAssistantArknights/issues?q=is%3Aissue%20state%3Aclosed) 确认我的问题未被提及
|
||||
required: false
|
||||
- label: 我理解 Issue 是用于反馈和解决问题的,而非吐槽评论区,将尽可能提供更多信息帮助问题解决
|
||||
required: true
|
||||
- label: 我填写了简短且清晰明确的标题,以便开发者在翻阅 issue 列表时能快速确定大致问题。而不是“一个建议”、“卡住了”等
|
||||
required: true
|
||||
- label: 我已查看最新测试版本的更新内容,并未提及该 bug 已被修复的情况
|
||||
required: true
|
||||
- label: 我已检查了置顶议题(pinned issue),确认我的问题未被提及
|
||||
required: true
|
||||
- type: textarea
|
||||
id: describe
|
||||
attributes:
|
||||
@@ -28,49 +26,32 @@ body:
|
||||
id: version
|
||||
attributes:
|
||||
label: Version
|
||||
description: |
|
||||
请提供 MAA 版本。可在 MAA -> 设置 -> 软件更新中找到。点击图标可复制。
|
||||
请分别点击 `资源版本` 和 `MAA 版本` 并粘贴,最终应有 5 行版本信息。
|
||||
description: >-
|
||||
请提供 MAA 版本。可在 MAA -> 设置 -> 软件更新中找到。(点击图标可复制)
|
||||
placeholder: |
|
||||
Resource Version:
|
||||
MAA Version:
|
||||
UI Version:
|
||||
Core Version:
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: logs
|
||||
attributes:
|
||||
label: 日志和配置文件
|
||||
label: 日志文件
|
||||
description: |
|
||||
**请在 MAA -> 设置 -> 问题反馈中找到生成日志压缩包按钮,点击并上传压缩包**
|
||||
|
||||
**上传 `debug` 文件夹中的 `asst.log` 和 `gui.log` 日志文件,并说明问题出现的大致时间点**
|
||||
**请直接将完整的文件拖拽进来,而非自己裁切或复制的片段;若文件体积过大可压缩后再上传**
|
||||
|
||||
如果你在使用 MacBook,请点击屏幕左上角的“文件”,点击“打开日志文件夹”
|
||||
placeholder: |
|
||||
请确认上传文件前已关闭 MAA
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: configuration
|
||||
attributes:
|
||||
label: 配置信息
|
||||
description: |
|
||||
请说明操作系统及版本、模拟器品牌、模拟器分辨率、DPI、帧率;
|
||||
若正在使用 MuMu 或雷电 9,请说明截图增强是否开启;
|
||||
最后请说明 GPU 加速推理是否开启,若开启请提供 GPU 型号。
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: screenshots
|
||||
attributes:
|
||||
label: 截图或录屏
|
||||
label: 截图
|
||||
description: |
|
||||
`debug` 目录下按功能分类的文件夹内,有一些自动截图的错误图片,若有相关的,请一并打包上传
|
||||
|
||||
可上传屏幕截图或录制以帮助解释你的问题,包括但不限于 MAA 软件截图、游戏画面截图
|
||||
如果有,添加屏幕截图以帮助解释你的问题,包括但不限于 MAA 软件截图、游戏画面截图
|
||||
若是**识别相关问题**,请尽可能提供模拟器自带的截图工具截取的无遮挡的**原图**(或通过 adb 截取原图)
|
||||
用其他的工具(如QQ/微信)截取的图片包含窗口边框且长宽比、分辨率不固定,不利于我们排除bug
|
||||
若文件体积过大可压缩后再上传
|
||||
用其他的工具(如QQ)截取的图片包含窗口边框,不利于我们排除bug
|
||||
`debug` 文件夹下有一些自动截图的错误图片,若有相关的,请一并打包上传
|
||||
validations:
|
||||
required: false
|
||||
- type: textarea
|
||||
@@ -78,6 +59,7 @@ body:
|
||||
attributes:
|
||||
label: 还有别的吗?
|
||||
description: |
|
||||
使用的模拟器?操作系统?相关的配置?链接?参考资料?
|
||||
任何能让我们对你所遇到的问题有更多了解的东西
|
||||
validations:
|
||||
required: false
|
||||
|
||||
18
.github/ISSUE_TEMPLATE/cn-feature-request.yaml
vendored
18
.github/ISSUE_TEMPLATE/cn-feature-request.yaml
vendored
@@ -1,22 +1,16 @@
|
||||
name: 需求建议(使用中文)
|
||||
description: 新功能、建议等
|
||||
labels: ["enhancement"]
|
||||
labels: ['enhancement']
|
||||
body:
|
||||
- type: checkboxes
|
||||
id: checks
|
||||
attributes:
|
||||
label: 请确认自己完成了下列必选项之后再进行勾选,若未完成必选项或勾选了"我未仔细阅读"选项将视为自愿接受被直接关闭 Issue
|
||||
label: 在提问之前...
|
||||
options:
|
||||
- label: 我基本确定这是一个新功能/建议,而不是遇到了 Bug(不确定的话请附上日志)
|
||||
required: false
|
||||
- label: 我未仔细阅读这些内容,只是一键已读[所有内容](/MaaAssistantArknights/MaaAssistantArknights/issues),并相信这不会影响问题的处理
|
||||
required: false
|
||||
- label: 我填写了简短且清晰明确的标题,以便开发者在翻阅 Issue 列表时能快速确定大致问题。而不是“一个建议”、“卡住了”等
|
||||
required: false
|
||||
- label: 我使用的是当前更新版本的最新版, 并已查看版本发布至今的 [更新内容](https://github.com/MaaAssistantArknights/MaaAssistantArknights/commits/dev/), [Pull Requests](https://github.com/MaaAssistantArknights/MaaAssistantArknights/pulls) 中尚未发布的更新内容,确认我的建议未被提及
|
||||
required: false
|
||||
- label: 我已检查了 [常见问题](https://docs.maa.plus/zh-cn/manual/faq.html), [公告](https://github.com/MaaAssistantArknights/MaaAssistantArknights/issues/7732), [活跃议题](https://github.com/MaaAssistantArknights/MaaAssistantArknights/issues), [已关闭议题](https://github.com/MaaAssistantArknights/MaaAssistantArknights/issues?q=is%3Aissue%20state%3Aclosed) 确认我的建议未被提及
|
||||
required: false
|
||||
- label: 我填写了简短且清晰明确的标题,以便开发者在翻阅 issue 列表时能快速确定大致问题。而不是“一个建议”、“卡住了”等
|
||||
required: true
|
||||
- label: 我基本确定这是一个新功能/建议,而不是遇到了 bug(不确定的话请附上日志)
|
||||
required: true
|
||||
- type: textarea
|
||||
id: describe
|
||||
attributes:
|
||||
|
||||
85
.github/ISSUE_TEMPLATE/cn-ld-report.yaml
vendored
85
.github/ISSUE_TEMPLATE/cn-ld-report.yaml
vendored
@@ -1,85 +0,0 @@
|
||||
name: 雷电截图增强反馈(使用中文)
|
||||
description: 有关雷电 9 截图增强功能的集中反馈
|
||||
labels: ["LD9 API"]
|
||||
body:
|
||||
- type: checkboxes
|
||||
id: checks
|
||||
attributes:
|
||||
label: 在提问之前...
|
||||
options:
|
||||
- label: 我理解 Issue 是用于反馈和解决问题的,而非吐槽评论区,将尽可能提供更多信息帮助问题解决
|
||||
required: false
|
||||
- label: 我填写了简短且清晰明确的标题,以便开发者在翻阅 Issue 列表时能快速确定大致问题。而不是“一个建议”、“卡住了”等
|
||||
required: false
|
||||
- label: 我已检查了[公告](/MaaAssistantArknights/MaaAssistantArknights/issues/7732)、[活跃议题](https://github.com/MaaAssistantArknights/MaaAssistantArknights/issues)、[已关闭议题](https://github.com/MaaAssistantArknights/MaaAssistantArknights/issues?q=is%3Aissue%20state%3Aclosed),确认我的问题未被提及
|
||||
required: false
|
||||
- label: 我未仔细阅读这些内容,只是一键已读[所有内容](/MaaAssistantArknights/MaaAssistantArknights/issues),并相信这不会影响问题的处理
|
||||
required: false
|
||||
- label: 我正在使用最新的 MAA 公测版本和最新的官版雷电 9 模拟器
|
||||
required: false
|
||||
- label: 我已参考文档确定安装路径、实例编号填写正确,并确认在关闭截图增强模式后问题消失
|
||||
required: false
|
||||
- label: 我未开启高帧率,且模拟器帧数设置为 60
|
||||
required: false
|
||||
- type: textarea
|
||||
id: describe
|
||||
attributes:
|
||||
label: 问题描述
|
||||
description: 描述问题时请尽可能详细
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: version
|
||||
attributes:
|
||||
label: Version
|
||||
description: |
|
||||
请提供 MAA 版本和雷电 9 版本。MAA 版本可在 MAA -> 设置 -> 软件更新中找到(点击图标可复制)。
|
||||
雷电 9 版本可在右上角菜单按钮 -> 关于雷电 中找到。
|
||||
placeholder: |
|
||||
Resource Version:
|
||||
MAA Version:
|
||||
雷电 9 版本号:
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: logs
|
||||
attributes:
|
||||
label: MAA 日志和配置文件
|
||||
description: |
|
||||
**请在 MAA -> 设置 -> 问题反馈中找到生成日志压缩包按钮,点击并上传压缩包**
|
||||
|
||||
**请直接将完整的文件拖拽进来,而非自己裁切或复制的片段;若文件体积过大可压缩后再上传**
|
||||
placeholder: |
|
||||
请确认上传文件前已关闭 MAA
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: ldlogs
|
||||
attributes:
|
||||
label: 雷电 9 诊断信息
|
||||
description: |
|
||||
**在雷电 9 右上角菜单按钮 -> 诊断信息 中点击 复制信息,并将全部内容粘贴进来。**
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: screenshots
|
||||
attributes:
|
||||
label: 截图
|
||||
description: |
|
||||
`debug` 目录下按功能分类的文件夹内,有一些自动截图的错误图片,若有相关的,请一并打包上传
|
||||
|
||||
可上传屏幕截图或录制以帮助解释你的问题,包括但不限于 MAA 软件截图、游戏画面截图
|
||||
若是**识别相关问题**,请尽可能提供模拟器自带的截图工具截取的无遮挡的**原图**(或通过 adb 截取原图)
|
||||
用其他的工具(如QQ/微信)截取的图片包含窗口边框且长宽比、分辨率不固定,不利于我们排除bug
|
||||
若文件体积过大可压缩后再上传
|
||||
validations:
|
||||
required: false
|
||||
- type: textarea
|
||||
id: others
|
||||
attributes:
|
||||
label: 其他
|
||||
description: |
|
||||
GPU 加速推理是否开启,若开启请提供 GPU 型号。
|
||||
亦或者任何能让我们对你所遇到的问题有更多了解的东西
|
||||
validations:
|
||||
required: false
|
||||
86
.github/ISSUE_TEMPLATE/cn-mumu-report.yaml
vendored
86
.github/ISSUE_TEMPLATE/cn-mumu-report.yaml
vendored
@@ -1,86 +0,0 @@
|
||||
name: MuMu 截图增强反馈(使用中文)
|
||||
description: 有关 MuMu 截图增强功能的集中反馈
|
||||
labels: ["MuMu API"]
|
||||
body:
|
||||
- type: checkboxes
|
||||
id: checks
|
||||
attributes:
|
||||
label: 在提问之前...
|
||||
options:
|
||||
- label: 我理解 Issue 是用于反馈和解决问题的,而非吐槽评论区,将尽可能提供更多信息帮助问题解决
|
||||
required: false
|
||||
- label: 我填写了简短且清晰明确的标题,以便开发者在翻阅 Issue 列表时能快速确定大致问题。而不是“一个建议”、“卡住了”等
|
||||
required: false
|
||||
- label: 我已检查了[公告](/MaaAssistantArknights/MaaAssistantArknights/issues/7732)、[活跃议题](https://github.com/MaaAssistantArknights/MaaAssistantArknights/issues)、[已关闭议题](https://github.com/MaaAssistantArknights/MaaAssistantArknights/issues?q=is%3Aissue%20state%3Aclosed),确认我的问题未被提及
|
||||
required: false
|
||||
- label: 我未仔细阅读这些内容,只是一键已读[所有内容](/MaaAssistantArknights/MaaAssistantArknights/issues),并相信这不会影响问题的处理
|
||||
required: false
|
||||
- label: 我正在使用最新的 MAA 公测版本和最新的官版或方舟专版 MuMu 模拟器
|
||||
required: false
|
||||
- label: 我已参考文档确定安装路径、实例编号、屏幕编号填写正确,并确认在关闭截图增强模式后问题消失
|
||||
required: false
|
||||
- label: 我未开启动态帧率及后台保活,模拟器帧数为 60,显存使用策略为“画面表现更好”
|
||||
required: false
|
||||
- type: textarea
|
||||
id: describe
|
||||
attributes:
|
||||
label: 问题描述
|
||||
description: 描述问题时请尽可能详细
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: version
|
||||
attributes:
|
||||
label: Version
|
||||
description: |
|
||||
请提供 MAA 版本和 MuMu 版本。MAA 版本可在 MAA -> 设置 -> 软件更新中找到(点击图标可复制)。
|
||||
MuMu 版本可在右上角菜单按钮 -> 关于 MuMu 中找到。
|
||||
placeholder: |
|
||||
Resource Version:
|
||||
MAA Version:
|
||||
MuMu 版本号:
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: logs
|
||||
attributes:
|
||||
label: MAA 日志和配置文件
|
||||
description: |
|
||||
**请在 MAA -> 设置 -> 问题反馈中找到生成日志压缩包按钮,点击并上传压缩包**
|
||||
|
||||
**请直接将完整的文件拖拽进来,而非自己裁切或复制的片段;若文件体积过大可压缩后再上传**
|
||||
placeholder: |
|
||||
请确认上传文件前已关闭 MAA
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: mumulogs
|
||||
attributes:
|
||||
label: MuMu 问题诊断
|
||||
description: |
|
||||
**在 MuMu 右上角菜单按钮 -> 问题诊断 中点击 复制配置信息,并将全部内容粘贴进来。**
|
||||
**注意隐去 电脑出口IP地址 等以保护个人隐私**
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: screenshots
|
||||
attributes:
|
||||
label: 截图
|
||||
description: |
|
||||
`debug` 目录下按功能分类的文件夹内,有一些自动截图的错误图片,若有相关的,请一并打包上传
|
||||
|
||||
可上传屏幕截图或录制以帮助解释你的问题,包括但不限于 MAA 软件截图、游戏画面截图
|
||||
若是**识别相关问题**,请尽可能提供模拟器自带的截图工具截取的无遮挡的**原图**(或通过 adb 截取原图)
|
||||
用其他的工具(如QQ/微信)截取的图片包含窗口边框且长宽比、分辨率不固定,不利于我们排除bug
|
||||
若文件体积过大可压缩后再上传
|
||||
validations:
|
||||
required: false
|
||||
- type: textarea
|
||||
id: others
|
||||
attributes:
|
||||
label: 其他
|
||||
description: |
|
||||
GPU 加速推理是否开启,若开启请提供 GPU 型号。
|
||||
亦或者任何能让我们对你所遇到的问题有更多了解的东西
|
||||
validations:
|
||||
required: false
|
||||
4
.github/ISSUE_TEMPLATE/cn-others.yaml
vendored
4
.github/ISSUE_TEMPLATE/cn-others.yaml
vendored
@@ -1,6 +1,6 @@
|
||||
name: 其他议题(使用中文)
|
||||
description: 提出问题,而不是 Bug 反馈或需求建议
|
||||
labels: ["question"]
|
||||
description: 提出问题,而不是 bug 反馈或需求建议
|
||||
labels: ['question']
|
||||
body:
|
||||
- type: textarea
|
||||
id: describe
|
||||
|
||||
100
.github/ISSUE_TEMPLATE/en-bug-report.yaml
vendored
100
.github/ISSUE_TEMPLATE/en-bug-report.yaml
vendored
@@ -1,24 +1,33 @@
|
||||
name: Bug Report (in English)
|
||||
description: Recognition errors, operation abnormalities, connection errors, etc.
|
||||
labels: ["bug"]
|
||||
description: >-
|
||||
Recognition errors, operation abnormalities,
|
||||
connection errors, etc.
|
||||
labels: ['bug']
|
||||
body:
|
||||
- type: checkboxes
|
||||
id: checks
|
||||
attributes:
|
||||
label: |
|
||||
Please ensure that you have completed the required items before checking the boxes.
|
||||
Issues with incomplete required items or with the 'I did not read carefully' option checked will be considered voluntary acceptance of direct closure.
|
||||
label: Before raising the issue...
|
||||
options:
|
||||
- label: I understand that Issues are for feedback and problem solving, not trolling the comments section, and will provide as much information as possible to help solve the problem.
|
||||
required: true
|
||||
- label: I filled in a short, clear title so that developers could quickly identify the general problem when going through the issue list. Instead of "Some suggestions", "Stuck", etc.
|
||||
required: true
|
||||
- label: I am using the latest version of the current update version, and have reviewed the [update content](https://github.com/MaaAssistantArknights/MaaAssistantArknights/commits/dev/) released to date, [Pull Requests](https://github.com/MaaAssistantArknights/MaaAssistantArknights/pulls) unreleased update content and there is no mention of the bug being fixed.
|
||||
required: true
|
||||
- label: I have checked all the options without carefully reading the content and believe this will not affect issue resolution.
|
||||
required: false
|
||||
- label: I have reviewed the [FAQs](https://docs.maa.plus/en-us/manual/faq.html), [Announcement](/MaaAssistantArknights/MaaAssistantArknights/issues/7732), [Open Issues](https://github.com/MaaAssistantArknights/MaaAssistantArknights/issues), [Closed Issues](https://github.com/MaaAssistantArknights/MaaAssistantArknights/issues?q=is%3Aissue%20state%3Aclosed) to ensure that my issue has not been mentioned.
|
||||
required: true
|
||||
- label: >-
|
||||
I understand that Issues are for feedback and problem solving,
|
||||
not trolling the comments section, and will provide as
|
||||
much information as possible to help solve the problem.
|
||||
required: true
|
||||
- label: >-
|
||||
I filled in a short, clear title
|
||||
so that developers could quickly identify the general problem
|
||||
when going through the issue list.
|
||||
Instead of "Some suggestions", "Stuck", etc.
|
||||
required: true
|
||||
- label: >-
|
||||
I have checked the latest beta update and there is no mention
|
||||
of the bug being fixed.
|
||||
required: true
|
||||
- label: >-
|
||||
I have reviewed the pinned issues and confirmed that my issue
|
||||
is not mentioned.
|
||||
required: true
|
||||
- type: textarea
|
||||
id: describe
|
||||
attributes:
|
||||
@@ -30,48 +39,32 @@ body:
|
||||
id: version
|
||||
attributes:
|
||||
label: Version
|
||||
description: |
|
||||
Please provide the MAA version. Can be found in MAA -> Settings -> Update. Click to copy.
|
||||
Click on `Resource Version` and `MAA Version` and paste them respectively. There should be 5 lines of version information in total.
|
||||
description: >-
|
||||
Please provide the MAA version. Can be found in MAA -> Settings -> Update. (Click to copy)
|
||||
placeholder: |
|
||||
Resource Version:
|
||||
MAA Version:
|
||||
UI Version:
|
||||
Core Version:
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: logs
|
||||
attributes:
|
||||
label: Log and config files
|
||||
description: |
|
||||
**Please locate the Generate Support Payload button under MAA Settings -> Issue Report, click the button, and upload the generated zip file**
|
||||
label: Log files
|
||||
description: >-
|
||||
**Upload the `asst.log` and `gui.log` log file in the `debug` folder and**
|
||||
**indicate the approximate point in time when the problem occurred.**
|
||||
|
||||
**Please drag and drop the full file in, not your own cuttings or copies; compress it before uploading if too large.**
|
||||
|
||||
If you are using MacBook, please click the "File" option in the top-left corner of the screen, then click "Open Log Folder".
|
||||
placeholder: |
|
||||
Please confirm that MAA is not running before uploading files.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: configuration
|
||||
attributes:
|
||||
label: Configuration information
|
||||
description: |
|
||||
Please specify the operating system and version, emulator brand, emulator resolution, DPI, and frame rate;
|
||||
If you are using MuMu or LDPlayer 9, please specify whether Screenshot Enhancement is enabled;
|
||||
Finally, please specify whether GPU accelerated inference is enabled, and if so, provide the GPU model.
|
||||
**Please drag and drop the full file in, not your own cuttings or copies;**
|
||||
**compress it before uploading if too large.**
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: screenshots
|
||||
attributes:
|
||||
label: Screenshots or recordings
|
||||
description: |
|
||||
In the `debug` directory, within the functionally categorized folders,
|
||||
there are some error images captured automatically.
|
||||
If related to this issue, please upload them together.
|
||||
|
||||
If available, upload screenshots and recordings to help explain your problem,
|
||||
label: Screenshots
|
||||
description: >-
|
||||
If available, add screenshots to help explain your problem,
|
||||
including but not limited to screenshots of MAA software,
|
||||
screenshots of game screens.
|
||||
|
||||
@@ -79,18 +72,23 @@ body:
|
||||
the **original image** taken by the emulator's own screenshot tool
|
||||
(or via adb).
|
||||
|
||||
Screenshots taken with other tools may contain the frames of the window/emulator
|
||||
and their aspect ratio and resolution are inconsistent,
|
||||
which makes it harder for us to debug.
|
||||
Screenshots taken with other tools may contain the frames of the window/emulator, which makes it harder for us to debug.
|
||||
|
||||
The `debug` folder has some automatic screenshots of the error images,
|
||||
if you have any,
|
||||
please upload them together.
|
||||
|
||||
If the file size is too large, you may compress it before uploading.
|
||||
validations:
|
||||
required: false
|
||||
- type: textarea
|
||||
id: others
|
||||
attributes:
|
||||
label: Anything else?
|
||||
description: |
|
||||
Anything that will give us more insight into the problem you are having.
|
||||
label: Anthing else?
|
||||
description: >-
|
||||
Emulator used, operating system, related configuration, links,
|
||||
reference material, etc.
|
||||
|
||||
Anything that will give us more insight into the problem
|
||||
you are having.
|
||||
validations:
|
||||
required: false
|
||||
|
||||
20
.github/ISSUE_TEMPLATE/en-feature-request.yaml
vendored
20
.github/ISSUE_TEMPLATE/en-feature-request.yaml
vendored
@@ -1,24 +1,16 @@
|
||||
name: Feature Request (in English)
|
||||
description: New features, suggestions, etc.
|
||||
labels: ["enhancement"]
|
||||
labels: ['enhancement']
|
||||
body:
|
||||
- type: checkboxes
|
||||
id: checks
|
||||
attributes:
|
||||
label: |
|
||||
Please ensure that you have completed the required items before checking the boxes.
|
||||
Issues with incomplete required items or with the 'I did not read carefully' option checked will be considered voluntary acceptance of direct closure.
|
||||
label: Before raising the issue...
|
||||
options:
|
||||
- label: I'm probably sure this is a new feature/suggestion and not a bug encountered (please attach logs if you're not sure).
|
||||
required: true
|
||||
- label: I filled in a short, clear title so that developers could quickly identify the general problem when going through the issue list. Instead of "Some suggestions", "Stuck", etc.
|
||||
required: true
|
||||
- label: I am using the latest version of the current update version, and have reviewed the [update content](https://github.com/MaaAssistantArknights/MaaAssistantArknights/commits/dev/) released to date, [Pull Requests](https://github.com/MaaAssistantArknights/MaaAssistantArknights/pulls) unreleased update content and there is no mention of this feature/suggestion being added.
|
||||
required: true
|
||||
- label: I have checked all the options without carefully reading the content and believe this will not affect issue resolution.
|
||||
required: false
|
||||
- label: I have reviewed the [FAQs](https://docs.maa.plus/en-us/manual/faq.html), [Announcement](/MaaAssistantArknights/MaaAssistantArknights/issues/7732), [Open Issues](https://github.com/MaaAssistantArknights/MaaAssistantArknights/issues), [Closed Issues](https://github.com/MaaAssistantArknights/MaaAssistantArknights/issues?q=is%3Aissue%20state%3Aclosed) to ensure that my feature/suggestion has not been mentioned.
|
||||
required: true
|
||||
- label: I filled in a short, clear title so that developers could quickly identify the general problem when going through the issue list. Instead of "Some suggestions", "Stuck", etc.
|
||||
required: true
|
||||
- label: I'm probably sure this is a new feature/suggestion and not a bug encountered (please attach logs if you're not sure)
|
||||
required: true
|
||||
- type: textarea
|
||||
id: describe
|
||||
attributes:
|
||||
|
||||
2
.github/ISSUE_TEMPLATE/en-others.yaml
vendored
2
.github/ISSUE_TEMPLATE/en-others.yaml
vendored
@@ -1,6 +1,6 @@
|
||||
name: Others (in English)
|
||||
description: Ask a question rather than a bug report or feature request.
|
||||
labels: ["question"]
|
||||
labels: ['question']
|
||||
body:
|
||||
- type: textarea
|
||||
id: describe
|
||||
|
||||
18
.github/dependabot.yaml
vendored
18
.github/dependabot.yaml
vendored
@@ -1,18 +0,0 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: github-actions
|
||||
directory: /.github/workflows
|
||||
schedule:
|
||||
interval: weekly
|
||||
commit-message:
|
||||
prefix: ci
|
||||
assignees:
|
||||
- AnnAngela
|
||||
- Constrat
|
||||
groups:
|
||||
github-actions:
|
||||
patterns:
|
||||
- "*"
|
||||
ignore:
|
||||
- dependency-name: "Nerixyz/actionsx-prettier"
|
||||
versions: ["3.0.0"]
|
||||
1050
.github/issue-checker.yml
vendored
1050
.github/issue-checker.yml
vendored
File diff suppressed because it is too large
Load Diff
38
.github/pr_cache_remover.ps1
vendored
38
.github/pr_cache_remover.ps1
vendored
@@ -1,38 +0,0 @@
|
||||
$totalClearedSize = 0
|
||||
$cacheList = gh cache list --json id,ref,sizeInBytes | ConvertFrom-Json
|
||||
$prCaches = $cacheList | Where-Object { $_.ref -like "*merge*" }
|
||||
|
||||
if (-not $prCaches) {
|
||||
Write-Output "No PR caches found."
|
||||
exit
|
||||
}
|
||||
|
||||
foreach ($cache in $prCaches) {
|
||||
$cacheId = $cache.id
|
||||
$cacheRef = $cache.ref
|
||||
$cacheSizeInBytes = $cache.sizeInBytes
|
||||
|
||||
if ($cacheRef -match "refs/pull/(\d+)/merge") {
|
||||
$prNumber = $matches[1]
|
||||
|
||||
Write-Host "PR #${prNumber}: " -NoNewline
|
||||
|
||||
$prStatus = gh pr view $prNumber --json state | ConvertFrom-Json
|
||||
|
||||
Write-Host $prStatus.state -NoNewline
|
||||
|
||||
if ($prStatus.state -eq "MERGED" -or $prStatus.state -eq "CLOSED") {
|
||||
Write-Host " -> DELETING"
|
||||
|
||||
gh cache delete $cacheId
|
||||
|
||||
$totalClearedSize += $cacheSizeInBytes
|
||||
}
|
||||
else {
|
||||
Write-Host ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$formattedSize = "{0:N2}" -f ($totalClearedSize / 1MB)
|
||||
Write-Output "Cleared size: $formattedSize MB"
|
||||
158095
.github/qodana.sarif.json
vendored
Normal file
158095
.github/qodana.sarif.json
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
.github/release_reviewers.yaml
vendored
1
.github/release_reviewers.yaml
vendored
@@ -11,6 +11,7 @@ reviewers:
|
||||
# A list of assignees to be added to pull requests (GitHub user name)
|
||||
assignees:
|
||||
- AnnAngela
|
||||
|
||||
# A list of keywords to be skipped the process that add reviewers if pull requests include it
|
||||
# skipKeywords:
|
||||
# - wip
|
||||
|
||||
75
.github/stale_cache_cleanup.ps1
vendored
75
.github/stale_cache_cleanup.ps1
vendored
@@ -1,75 +0,0 @@
|
||||
$totalClearedSize = 0
|
||||
$cacheList = gh cache list --json id,key,ref,sizeInBytes,createdAt | ConvertFrom-Json
|
||||
|
||||
# List of keys to process
|
||||
$keyPatterns = @(
|
||||
"Windows-x64-nuget",
|
||||
"Windows-x64-maadeps",
|
||||
"Windows-arm64-nuget",
|
||||
"Windows-arm64-maadeps",
|
||||
"macOS-x64-maadeps",
|
||||
"macOS-arm64-maadeps",
|
||||
"Linux-x64-maadeps",
|
||||
"Linux-arm64-maadeps",
|
||||
"Smoke-testing"
|
||||
)
|
||||
|
||||
# Filter caches matching any of our key patterns
|
||||
$matchingCaches = $cacheList | Where-Object {
|
||||
$cache = $_
|
||||
($keyPatterns | Where-Object { $cache.key -like "*$_*" }).Count -gt 0
|
||||
}
|
||||
|
||||
# Get unique branch references from the matching caches
|
||||
$branches = $matchingCaches | Select-Object -Property ref -Unique | ForEach-Object { $_.ref }
|
||||
|
||||
Write-Output "Found caches across $($branches.Count) branches"
|
||||
|
||||
foreach ($branch in $branches) {
|
||||
# Extract branch name from ref for display
|
||||
$branchName = $branch -replace "refs/heads/", ""
|
||||
if ($branch -match "refs/pull/(\d+)/merge") {
|
||||
$branchName = "PR #$($matches[1])"
|
||||
}
|
||||
|
||||
Write-Output "Processing caches for branch: $branchName"
|
||||
|
||||
# Filter for current branch caches
|
||||
$branchCaches = $matchingCaches | Where-Object { $_.ref -eq $branch }
|
||||
|
||||
foreach ($pattern in $keyPatterns) {
|
||||
Write-Output " Processing $branchName branch caches for pattern: $pattern"
|
||||
|
||||
# Filter for caches matching the current key pattern within branch
|
||||
$patternCaches = $branchCaches | Where-Object { $_.key -like "*$pattern*" }
|
||||
|
||||
if (-not $patternCaches) {
|
||||
Write-Output " No $branchName branch caches found for pattern: $pattern"
|
||||
continue
|
||||
}
|
||||
|
||||
# Sort by creation time (newest first)
|
||||
$sortedCaches = $patternCaches | Sort-Object -Property createdAt -Descending
|
||||
|
||||
# Keep the first one (latest) and delete the rest
|
||||
$latestCache = $sortedCaches[0]
|
||||
Write-Output " Keeping latest cache for $branchName/${pattern}: '$($latestCache.key)' (ID: $($latestCache.id))"
|
||||
|
||||
# Delete all except the latest one
|
||||
for ($i = 1; $i -lt $sortedCaches.Count; $i++) {
|
||||
$cache = $sortedCaches[$i]
|
||||
$cacheId = $cache.id
|
||||
$cacheKey = $cache.key
|
||||
|
||||
Write-Output " Deleting cache for $branchName/${pattern}: '$cacheKey' (ID: $cacheId)"
|
||||
gh cache delete $cacheId
|
||||
|
||||
$totalClearedSize += $cache.sizeInBytes
|
||||
}
|
||||
}
|
||||
|
||||
Write-Output ""
|
||||
}
|
||||
|
||||
$formattedSize = "{0:N2}" -f ($totalClearedSize / 1MB)
|
||||
Write-Output "Total cleared size: $formattedSize MB"
|
||||
59
.github/stale_cache_dev.ps1
vendored
59
.github/stale_cache_dev.ps1
vendored
@@ -1,59 +0,0 @@
|
||||
$totalClearedSize = 0
|
||||
$cacheList = gh cache list --json id,key,ref,sizeInBytes,createdAt | ConvertFrom-Json
|
||||
|
||||
# Filter for dev branch caches only
|
||||
$devCaches = $cacheList | Where-Object { $_.ref -eq "refs/heads/dev" }
|
||||
|
||||
if (-not $devCaches) {
|
||||
Write-Output "No caches found for dev branch."
|
||||
exit
|
||||
}
|
||||
|
||||
# List of keys to process
|
||||
$keyPatterns = @(
|
||||
"Windows-x64-nuget",
|
||||
"Windows-x64-maadeps",
|
||||
"Windows-arm64-nuget",
|
||||
"Windows-arm64-maadeps",
|
||||
"macOS-x64-maadeps",
|
||||
"macOS-arm64-maadeps",
|
||||
"Linux-x64-maadeps",
|
||||
"Linux-arm64-maadeps",
|
||||
"Smoke-testing"
|
||||
)
|
||||
|
||||
foreach ($pattern in $keyPatterns) {
|
||||
Write-Output "Processing dev branch caches for pattern: $pattern"
|
||||
|
||||
# Filter for caches matching the current key pattern within dev branch
|
||||
$matchingCaches = $devCaches | Where-Object { $_.key -like "*$pattern*" }
|
||||
|
||||
if (-not $matchingCaches) {
|
||||
Write-Output " No dev branch caches found for pattern: $pattern"
|
||||
continue
|
||||
}
|
||||
|
||||
# Sort by creation time (newest first)
|
||||
$sortedCaches = $matchingCaches | Sort-Object -Property createdAt -Descending
|
||||
|
||||
# Keep the first one (latest) and delete the rest
|
||||
$latestCache = $sortedCaches[0]
|
||||
Write-Output " Keeping latest dev branch cache: '$($latestCache.key)' (ID: $($latestCache.id))"
|
||||
|
||||
# Delete all except the latest one
|
||||
for ($i = 1; $i -lt $sortedCaches.Count; $i++) {
|
||||
$cache = $sortedCaches[$i]
|
||||
$cacheId = $cache.id
|
||||
$cacheKey = $cache.key
|
||||
|
||||
Write-Output " Deleting dev branch cache: '$cacheKey' (ID: $cacheId)"
|
||||
gh cache delete $cacheId
|
||||
|
||||
$totalClearedSize += $cache.sizeInBytes
|
||||
}
|
||||
|
||||
Write-Output ""
|
||||
}
|
||||
|
||||
$formattedSize = "{0:N2}" -f ($totalClearedSize / 1MB)
|
||||
Write-Output "Total cleared size: $formattedSize MB"
|
||||
49
.github/workflows/blame-ignore.yml
vendored
49
.github/workflows/blame-ignore.yml
vendored
@@ -1,49 +0,0 @@
|
||||
name: Git Blame Ignore
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "45 21 * * *" # Runs daily at 22:00 UTC
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
blame-ignore:
|
||||
if: github.repository_owner == 'MaaAssistantArknights'
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
fetch-depth: 0
|
||||
persist-credentials: false # Needed to bypass protection rules in Push changes
|
||||
|
||||
- name: Check blame
|
||||
id: check_changes
|
||||
run: |
|
||||
LAST_CHECKED_COMMIT=$(cat .github/.last-blame-ignore-commit 2>/dev/null || git rev-list --max-parents=0 HEAD)
|
||||
|
||||
git log $LAST_CHECKED_COMMIT..HEAD --pretty=format:"%H %s" --grep="\[blame ignore\]" | awk '{print $1}' >> .git-blame-ignore-revs
|
||||
|
||||
git diff --quiet .git-blame-ignore-revs
|
||||
|
||||
- name: Commit and Push changes
|
||||
if: ${{ steps.check_changes.outcome == 'failure' }}
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
|
||||
git rev-parse HEAD > .github/.last-blame-ignore-commit
|
||||
|
||||
git add .github/.last-blame-ignore-commit .git-blame-ignore-revs
|
||||
git commit -m "chore: auto blame ignore" -m "[skip changelog]"
|
||||
|
||||
- name: Push changes
|
||||
if: ${{ steps.check_changes.outcome == 'failure' }}
|
||||
uses: ad-m/github-push-action@master
|
||||
with:
|
||||
branch: ${{ github.ref }}
|
||||
github_token: ${{ secrets.MAA_RESOURCE_SYNC }}
|
||||
|
||||
- name: Stop if no changes
|
||||
if: ${{ steps.check_changes.outcome == 'success' }}
|
||||
uses: andymckay/cancel-action@0.5
|
||||
39
.github/workflows/cache-delete.yml
vendored
39
.github/workflows/cache-delete.yml
vendored
@@ -1,39 +0,0 @@
|
||||
name: Delete Cache
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [closed]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
pr_number:
|
||||
description: "PR Number"
|
||||
required: true
|
||||
|
||||
jobs:
|
||||
cache-delete:
|
||||
# Run only on organization branches with PRs
|
||||
if: github.event_name == 'workflow_dispatch' ||
|
||||
github.event.pull_request.head.repo.full_name ==
|
||||
github.event.pull_request.base.repo.full_name
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Delete cache on PR merged
|
||||
run: |
|
||||
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
|
||||
PR_NUMBER=${{ github.event.inputs.pr_number }}
|
||||
else
|
||||
PR_NUMBER=${{ github.event.pull_request.number }}
|
||||
fi
|
||||
echo "PR Number: $PR_NUMBER"
|
||||
|
||||
curl -s -L https://api.github.com/repos/Maaassistantarknights/Maaassistantarknights/actions/caches |
|
||||
jq -r --arg PR_NUMBER "refs/pull/$PR_NUMBER/merge" '.actions_caches[] | select(.ref == $PR_NUMBER) | .id' |
|
||||
while read -r id; do
|
||||
echo "Deleting cache with ID: $id"
|
||||
|
||||
curl -L -X DELETE \
|
||||
-H "Accept: application/vnd.github+json" \
|
||||
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
|
||||
-H "X-GitHub-Api-Version: 2022-11-28" \
|
||||
"https://api.github.com/repos/MaaAssistantArknights/MaaAssistantArknights/actions/caches/$id"
|
||||
done
|
||||
350
.github/workflows/ci.yml
vendored
350
.github/workflows/ci.yml
vendored
@@ -12,9 +12,9 @@ on:
|
||||
- "src/**"
|
||||
- "cmake/**"
|
||||
- "CMakeLists.txt"
|
||||
- "MAA.sln"
|
||||
- ".github/workflows/ci.yml"
|
||||
- "!**/*.md"
|
||||
- "tools/maadeps-download.py"
|
||||
pull_request:
|
||||
branches:
|
||||
- "dev"
|
||||
@@ -24,28 +24,19 @@ on:
|
||||
- "src/**"
|
||||
- "cmake/**"
|
||||
- "CMakeLists.txt"
|
||||
- "MAA.sln"
|
||||
- "!**/*.md"
|
||||
- "tools/maadeps-download.py"
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
meta:
|
||||
# Prevent duplicate runs on organization branches with PRs
|
||||
if: github.event_name != 'pull_request' ||
|
||||
github.event.pull_request.head.repo.full_name !=
|
||||
github.event.pull_request.base.repo.full_name
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
tag: ${{ steps.set_tag.outputs.tag }}
|
||||
prerelease: ${{ steps.set_pre.outputs.prerelease }}
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: temp
|
||||
show-progress: false
|
||||
@@ -89,8 +80,6 @@ jobs:
|
||||
fi
|
||||
echo >> CHANGELOG.md
|
||||
echo "**Full Changelog**: [$last_tag -> $this_tag](https://github.com/MaaAssistantArknights/MaaAssistantArknights/compare/${last_tag}...${this_tag})" >> CHANGELOG.md
|
||||
echo >> CHANGELOG.md
|
||||
echo "[已有 Mirror酱 CDK?前往 Mirror酱 高速下载](https://mirrorchyan.com/zh/projects?rid=MAA&source=maagh-release)" >> CHANGELOG.md
|
||||
|
||||
- name: Upload changelog to Github
|
||||
uses: actions/upload-artifact@v4
|
||||
@@ -100,57 +89,24 @@ jobs:
|
||||
path: CHANGELOG.md
|
||||
|
||||
windows:
|
||||
# Prevent duplicate runs on organization branches with PRs
|
||||
if: github.event_name != 'pull_request' ||
|
||||
github.event.pull_request.head.repo.full_name !=
|
||||
github.event.pull_request.base.repo.full_name
|
||||
|
||||
needs: meta
|
||||
strategy:
|
||||
matrix:
|
||||
arch: [arm64, x64]
|
||||
fail-fast: false
|
||||
include:
|
||||
- msbuild_target: x64
|
||||
lowercase_target: x64
|
||||
- msbuild_target: ARM64
|
||||
lowercase_target: arm64
|
||||
env:
|
||||
MAABUILDER_TARGET_PLATFORM: ${{ matrix.msbuild_target }}
|
||||
runs-on: windows-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
show-progress: false
|
||||
|
||||
- name: Fetch submodules
|
||||
run: |
|
||||
git submodule update --init --depth 1 3rdparty/EmulatorExtras
|
||||
|
||||
- name: Cache MaaDeps
|
||||
id: cache-maadeps
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
./MaaDeps
|
||||
key: ${{ runner.os }}-${{ matrix.arch }}-maadeps-${{ hashFiles('tools/maadeps-download.py') }}
|
||||
|
||||
- name: Bootstrap MaaDeps
|
||||
if: steps.cache-maadeps.outputs.cache-hit != 'true'
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
python3 tools/maadeps-download.py ${{ matrix.arch }}-windows
|
||||
|
||||
- name: Config cmake
|
||||
run: |
|
||||
mkdir -p build
|
||||
cmake -B build ${{ matrix.arch == 'arm64' && '-A ARM64' }} -DCMAKE_BUILD_TYPE=Release -DMAADEPS_TRIPLET='maa-${{ matrix.arch }}-windows' -DINSTALL_RESOURCE=ON -DINSTALL_PYTHON=ON -DMAA_HASH_VERSION='${{ needs.meta.outputs.tag }}' -DBUILD_WPF_GUI=OFF
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
cmake --build build --config Release --parallel $env:NUMBER_OF_PROCESSORS
|
||||
|
||||
- name: Install
|
||||
run: |
|
||||
mkdir -p install
|
||||
cmake --install build --prefix install --config Release
|
||||
|
||||
- name: Cache .nuke/temp, ~/.nuget/packages
|
||||
id: cache-nuget
|
||||
uses: actions/cache@v4
|
||||
@@ -158,13 +114,29 @@ jobs:
|
||||
path: |
|
||||
.nuke/temp
|
||||
~/.nuget/packages
|
||||
key: ${{ runner.os }}-${{ matrix.arch }}-nuget-${{ hashFiles('**/*.csproj') }}
|
||||
key: ${{ runner.os }}-${{ matrix.msbuild_target }}-${{ hashFiles('**/global.json', '**/*.csproj') }}
|
||||
|
||||
- name: Restore dependencies
|
||||
if: steps.cache-nuget.outputs.cache-hit != 'true'
|
||||
run: dotnet restore src/MaaWpfGui/MaaWpfGui.csproj
|
||||
run: dotnet restore
|
||||
|
||||
- name: Taggify Version for csproj
|
||||
- name: Bootstrap MaaDeps
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
python3 maadeps-download.py ${{ matrix.lowercase_target }}-windows
|
||||
|
||||
- name: Create fake event file
|
||||
shell: bash
|
||||
run: cp -v "$GITHUB_EVENT_PATH" ./event.json
|
||||
|
||||
- name: Merge Event Data with Inputs
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
shell: bash
|
||||
run: |
|
||||
cat "$GITHUB_EVENT_PATH" | jq '. + { "inputs": {"ReleaseSimulation": "${{ needs.meta.outputs.tag }}"} }' | tee ./event.json
|
||||
|
||||
- name: Taggify Version
|
||||
run: |
|
||||
$csprojPath = "src/MaaWpfGui/MaaWpfGui.csproj"
|
||||
$csprojPath = Resolve-Path -Path $csprojPath
|
||||
@@ -181,103 +153,90 @@ jobs:
|
||||
$node.FileVersion = $match
|
||||
$node.AssemblyVersion = $match
|
||||
$csproj.Save($csprojPath)
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Publish WPF GUI
|
||||
continue-on-error: true
|
||||
- name: Build
|
||||
run: |
|
||||
dotnet publish src/MaaWpfGui/MaaWpfGui.csproj -c Release -o install
|
||||
$env:GITHUB_WORKFLOW = 'dev-build-win' # pretend this is a dev-build-win workflow
|
||||
$env:GITHUB_EVENT_PATH = "$pwd\\event.json"
|
||||
$env:GITHUB_REF = "refs/heads/not_master"
|
||||
$env:MAA_BUILDER_MAA_VERSION = '${{ needs.meta.outputs.tag }}'
|
||||
./build.cmd DevBuild
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Organize Install Files
|
||||
- name: Cleanup checksum file
|
||||
run: |
|
||||
rm -vf ./artifacts/checksum.json
|
||||
shell: bash
|
||||
run: |
|
||||
rm -rf install/*.pdb
|
||||
rm -rf install/msvc-debug
|
||||
rm -rf install/*.h
|
||||
|
||||
cp tools/DependencySetup_依赖库安装.bat install
|
||||
|
||||
- name: Zip files
|
||||
run: |
|
||||
cd install
|
||||
Compress-Archive -Destination MAA-${{ needs.meta.outputs.tag }}-win-${{ matrix.arch }}.zip -Path ./*
|
||||
|
||||
- name: Upload MAA to Github
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: MAA-win-${{ matrix.arch }}
|
||||
path: install/*.zip
|
||||
name: MAA-win-${{ matrix.lowercase_target }}
|
||||
path: artifacts
|
||||
|
||||
ubuntu:
|
||||
# Prevent duplicate runs on organization branches with PRs
|
||||
if: github.event_name != 'pull_request' ||
|
||||
github.event.pull_request.head.repo.full_name !=
|
||||
github.event.pull_request.base.repo.full_name
|
||||
|
||||
needs: meta
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
arch: [aarch64, x86_64]
|
||||
fail-fast: false
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
show-progress: false
|
||||
submodules: recursive
|
||||
|
||||
- name: Fetch submodules
|
||||
- name: Install cross compile toolchains
|
||||
if: ${{ matrix.arch != 'x86_64' }}
|
||||
run: |
|
||||
git submodule update --init --depth 1 3rdparty/EmulatorExtras
|
||||
git submodule update --init --depth 1 src/maa-cli
|
||||
sudo apt-get update
|
||||
sudo apt-get install g++-12-aarch64-linux-gnu g++-12-aarch64-linux-gnu
|
||||
|
||||
- name: Cache MaaDeps
|
||||
id: cache-maadeps
|
||||
uses: actions/cache@v4
|
||||
- name: Setup ccache
|
||||
uses: Chocobo1/setup-ccache-action@v1
|
||||
with:
|
||||
path: ./MaaDeps
|
||||
key: ${{ runner.os }}-${{ matrix.arch == 'x86_64' && 'x64' || 'arm64' }}-maadeps-${{ hashFiles('tools/maadeps-download.py') }}
|
||||
remove_stale_cache: false
|
||||
|
||||
- name: Bootstrap MaaDeps
|
||||
if: steps.cache-maadeps.outputs.cache-hit != 'true'
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
python3 tools/maadeps-download.py ${{ matrix.arch == 'x86_64' && 'x64' || 'arm64' }}-linux
|
||||
python3 maadeps-download.py ${{ matrix.arch == 'x86_64' && 'x64' || 'arm64' }}-linux
|
||||
|
||||
- name: Config cmake
|
||||
- name: Build MAA
|
||||
run: |
|
||||
mkdir -p build
|
||||
cmake -B build \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DMAADEPS_TRIPLET='maa-${{ matrix.arch == 'x86_64' && 'x64' || 'arm64' }}-linux' \
|
||||
-DINSTALL_THIRD_LIBS=ON \
|
||||
-DINSTALL_RESOURCE=ON \
|
||||
-DINSTALL_PYTHON=ON \
|
||||
-DMAA_HASH_VERSION='${{ needs.meta.outputs.tag }}' \
|
||||
-DCMAKE_TOOLCHAIN_FILE=MaaDeps/cmake/maa-${{ matrix.arch == 'x86_64' && 'x64' || 'arm64' }}-linux-toolchain.cmake
|
||||
-DMAA_VERSION='${{ needs.meta.outputs.tag }}'
|
||||
cmake --build build --parallel $(nproc --all)
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
cmake --build build --config Release --parallel $(nproc)
|
||||
env:
|
||||
CLICOLOR_FORCE: 1
|
||||
|
||||
- name: Install
|
||||
run: |
|
||||
mkdir -p install
|
||||
cmake --install build --prefix install --config Release
|
||||
cmake --install build --prefix install
|
||||
env:
|
||||
CC: ${{ matrix.arch == 'x86_64' && 'ccache gcc-12' || 'ccache aarch64-linux-gnu-gcc-12' }}
|
||||
CXX: ${{ matrix.arch == 'x86_64' && 'ccache g++-12' || 'ccache aarch64-linux-gnu-g++-12' }}
|
||||
|
||||
- name: Setup Cross Compile Toolchains for CLI
|
||||
- name: Setup Rust
|
||||
uses: ./src/maa-cli/.github/actions/setup
|
||||
with:
|
||||
os: ubuntu-latest
|
||||
target_arch: ${{ matrix.arch }}
|
||||
arch: ${{ matrix.arch }}
|
||||
|
||||
- name: Build CLI
|
||||
run: |
|
||||
cargo build --release --locked --package maa-cli --features vendored-openssl
|
||||
cargo build --release --locked --package maa-cli \
|
||||
${{ matrix.arch != 'x86_64' && '--features vendored-openssl' || '' }}
|
||||
cp -v target/$CARGO_BUILD_TARGET/release/maa $GITHUB_WORKSPACE/install/maa
|
||||
cargo build --release --locked --package maa-cli --no-default-features \
|
||||
--features git2,vendored-openssl
|
||||
--features ${{ matrix.arch != 'x86_64' && 'git2,vendored-openssl' || 'git2' }}
|
||||
cp -v target/$CARGO_BUILD_TARGET/release/maa $GITHUB_WORKSPACE/appimage-maa
|
||||
working-directory: src/maa-cli
|
||||
|
||||
@@ -309,11 +268,11 @@ jobs:
|
||||
ln -sv usr/share/maa/maa Maa.AppDir/AppRun
|
||||
mkdir -pv Maa.AppDir/usr/share/metainfo/
|
||||
cp -v tools/AppImage/io.github.maaassistantarknights.maaassistantarknights.metainfo.xml Maa.AppDir/usr/share/metainfo/
|
||||
wget "https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage"
|
||||
wget "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage"
|
||||
# appimagetool with embedded runtime does not support cross build, till AppImage/appimagetool 7a10b8
|
||||
wget "https://github.com/AppImage/type2-runtime/releases/download/old/runtime-fuse3-${{ matrix.arch }}"
|
||||
wget "https://github.com/AppImage/type2-runtime/releases/download/continuous/runtime-${{ matrix.arch }}"
|
||||
chmod a+x appimagetool-x86_64.AppImage
|
||||
ARCH=${{ matrix.arch }} ./appimagetool-x86_64.AppImage --runtime-file runtime-fuse3-${{ matrix.arch }} Maa.AppDir
|
||||
ARCH=${{ matrix.arch }} ./appimagetool-x86_64.AppImage --runtime-file runtime-${{ matrix.arch }} Maa.AppDir
|
||||
chmod a+x MaaAssistantArknights-${{ matrix.arch }}.AppImage
|
||||
mv -v MaaAssistantArknights-${{ matrix.arch }}.AppImage $GITHUB_WORKSPACE/release/MAA-${{ needs.meta.outputs.tag }}-linux-${{ matrix.arch }}.AppImage
|
||||
|
||||
@@ -332,56 +291,36 @@ jobs:
|
||||
release/*.tar.gz
|
||||
|
||||
macOS-Core:
|
||||
# Prevent duplicate runs on organization branches with PRs
|
||||
if: github.event_name != 'pull_request' ||
|
||||
github.event.pull_request.head.repo.full_name !=
|
||||
github.event.pull_request.base.repo.full_name
|
||||
|
||||
needs: meta
|
||||
runs-on: macos-latest
|
||||
runs-on: macos-13
|
||||
strategy:
|
||||
matrix:
|
||||
arch: [arm64, x86_64]
|
||||
fail-fast: false
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
show-progress: false
|
||||
|
||||
# ninja 1.13.1 is already installed and up-to-date.
|
||||
# - name: Install Dependencies
|
||||
# run: |
|
||||
# brew install ninja
|
||||
|
||||
- name: Cache MaaDeps
|
||||
id: cache-maadeps
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ./MaaDeps
|
||||
key: ${{ runner.os }}-${{ matrix.arch == 'x86_64' && 'x64' || 'arm64' }}-maadeps-${{ hashFiles('tools/maadeps-download.py') }}
|
||||
- name: Install Dependencies
|
||||
run: |
|
||||
brew install ninja
|
||||
|
||||
- name: Bootstrap MaaDeps
|
||||
run: |
|
||||
[[ ${{ matrix.arch }} = "arm64" ]] && triplet="arm64-osx" || triplet="x64-osx"
|
||||
python3 tools/maadeps-download.py ${triplet}
|
||||
python3 maadeps-download.py ${triplet}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Config cmake
|
||||
- name: Configure MaaCore
|
||||
run: |
|
||||
cmake -B build -GNinja \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_OSX_ARCHITECTURES='${{ matrix.arch }}' \
|
||||
-DMAA_HASH_VERSION='${{ needs.meta.outputs.tag }}'
|
||||
cmake -B build -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES='${{ matrix.arch }}' -DMAA_VERSION='${{ needs.meta.outputs.tag }}'
|
||||
|
||||
- name: Build
|
||||
- name: Build MaaCore
|
||||
run: |
|
||||
cmake --build build --config Release --parallel $(sysctl -n hw.logicalcpu)
|
||||
|
||||
- name: Install
|
||||
run: |
|
||||
cmake --install build --prefix install --config Release
|
||||
cmake --build build
|
||||
cmake --install build --prefix install
|
||||
|
||||
- name: Upload MAA to Github
|
||||
uses: actions/upload-artifact@v4
|
||||
@@ -390,62 +329,34 @@ jobs:
|
||||
path: "install/*.dylib"
|
||||
|
||||
macOS-GUI:
|
||||
# Prevent duplicate runs on organization branches with PRs
|
||||
if: github.event_name != 'pull_request' ||
|
||||
github.event.pull_request.head.repo.full_name !=
|
||||
github.event.pull_request.base.repo.full_name
|
||||
|
||||
needs: [meta, macOS-Core]
|
||||
runs-on: macos-latest
|
||||
runs-on: macos-13
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
show-progress: false
|
||||
|
||||
- name: Install Dependencies
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
run: |
|
||||
brew install graphicsmagick imagemagick
|
||||
npm install -g create-dmg
|
||||
|
||||
- name: Fetch submodules
|
||||
run: |
|
||||
git submodule update --init --depth 1 src/MaaMacGui
|
||||
submodules: recursive
|
||||
|
||||
- name: Download Arm64 MAA from Github
|
||||
uses: actions/download-artifact@v5
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: MAACore-macos-arm64
|
||||
path: install-arm64
|
||||
|
||||
- name: Download x64 MAA from Github
|
||||
uses: actions/download-artifact@v5
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: MAACore-macos-x86_64
|
||||
path: install-x86_64
|
||||
|
||||
- name: Install Developer ID Certificate
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
uses: apple-actions/import-codesign-certs@v5
|
||||
uses: ssrobins/import-codesign-certs@v2
|
||||
with:
|
||||
p12-file-base64: ${{ secrets.HGUANDL_SIGN_CERT_P12 }}
|
||||
p12-password: ${{ secrets.HGUANDL_SIGN_CERT_PASSWD }}
|
||||
|
||||
- name: Download Provisioning Profiles
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
uses: apple-actions/download-provisioning-profiles@v4
|
||||
with:
|
||||
bundle-id: "com.hguandl.MeoAsstMac"
|
||||
issuer-id: ${{ secrets.HGUANDL_APPSTORE_ISSUER }}
|
||||
api-key-id: ${{ secrets.HGUANDL_APPSTORE_KEYID }}
|
||||
api-private-key: ${{ secrets.HGUANDL_APPSTORE_KEY }}
|
||||
|
||||
- name: Setup Xcode Toolchain
|
||||
if: true
|
||||
run: |
|
||||
sudo xcode-select -s /Applications/Xcode_16.1.app/Contents/Developer
|
||||
|
||||
- name: Build Universal Binaries
|
||||
run: |
|
||||
mkdir build
|
||||
@@ -453,28 +364,10 @@ jobs:
|
||||
lipo -create install-arm64/$LIB_NAME install-x86_64/$LIB_NAME -output build/$LIB_NAME
|
||||
done
|
||||
|
||||
- name: Archive Runtime Files
|
||||
run: |
|
||||
mkdir runtime && cd runtime
|
||||
name='MAA-${{ needs.meta.outputs.tag }}-macos-runtime-universal'
|
||||
mkdir "$name" && cd "$name"
|
||||
cp -v ../../build/*.dylib .
|
||||
ln -vs libonnxruntime*.dylib libonnxruntime.dylib
|
||||
ln -vs libopencv_world4*.dylib libopencv_world4.dylib
|
||||
cp -vr ../../resource .
|
||||
cd .. || exit 1
|
||||
zip -yrX9 "$name.zip" "$name"
|
||||
|
||||
- name: Upload MAA runtime to Github
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: MAA-macos-runtime-universal
|
||||
path: runtime/MAA-${{ needs.meta.outputs.tag }}-macos-runtime-universal.zip
|
||||
|
||||
- name: Build XCFramework
|
||||
run: |
|
||||
xcodebuild -create-xcframework -library libMaaCore.dylib -headers ../include -output MaaCore.xcframework
|
||||
xcodebuild -create-xcframework -library libfastdeploy_ppocr.dylib -output fastdeploy_ppocr.xcframework
|
||||
xcodebuild -create-xcframework -library libMaaDerpLearning.dylib -output MaaDerpLearning.xcframework
|
||||
xcodebuild -create-xcframework -library libonnxruntime.*.dylib -output ONNXRuntime.xcframework
|
||||
xcodebuild -create-xcframework -library libopencv*.dylib -output OpenCV.xcframework
|
||||
working-directory: build
|
||||
@@ -488,9 +381,9 @@ jobs:
|
||||
- name: Build MAA
|
||||
run: |
|
||||
if ${{ startsWith(github.ref, 'refs/tags/v') }}; then
|
||||
xcodebuild -scheme MAA archive -archivePath MAA.xcarchive
|
||||
xcodebuild -project MeoAsstMac.xcodeproj -scheme MAA archive -archivePath MAA.xcarchive -configuration Release
|
||||
else
|
||||
xcodebuild CODE_SIGNING_ALLOWED=NO -scheme MAA archive -archivePath MAA.xcarchive
|
||||
xcodebuild CODE_SIGN_IDENTITY="-" DEVELOPMENT_TEAM="-" ONLY_ACTIVE_ARCH=NO -project MeoAsstMac.xcodeproj -scheme MAA archive -archivePath MAA.xcarchive -configuration Debug
|
||||
fi
|
||||
working-directory: src/MaaMacGui
|
||||
|
||||
@@ -503,8 +396,10 @@ jobs:
|
||||
- name: Create Disk Image
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
run: |
|
||||
create-dmg Export/MAA.app
|
||||
mv MAA*.dmg MAA.dmg
|
||||
mkdir Image
|
||||
mv Export/MAA.app Image/
|
||||
ln -s /Applications Image/
|
||||
hdiutil create -volname MAA -srcfolder Image -ov -fs APFS -format ULMO MAA.dmg
|
||||
working-directory: src/MaaMacGui
|
||||
|
||||
- name: Archive Debug Symbols
|
||||
@@ -524,26 +419,17 @@ jobs:
|
||||
mv src/MaaMacGui/MAA.xcarchive/dSYMs/MAA.app.dSYM.zip release/${APP_SYM}
|
||||
|
||||
- name: Notarize Image
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
uses: nick-fields/retry@v3
|
||||
with:
|
||||
max_attempts: 3
|
||||
timeout_minutes: 15
|
||||
command: |
|
||||
cd release
|
||||
echo "$APPSTORE_KEY" > "AuthKey_${APPSTORE_KEYID}.p8"
|
||||
dmg="MAA-${{ needs.meta.outputs.tag }}-macos-universal.dmg"
|
||||
xcrun notarytool submit -k "AuthKey_${APPSTORE_KEYID}.p8" -d "$APPSTORE_KEYID" -i "$ISSUER_ID" --wait ${dmg}
|
||||
env:
|
||||
APPSTORE_KEYID: ${{ secrets.HGUANDL_APPSTORE_KEYID }}
|
||||
APPSTORE_KEY: ${{ secrets.HGUANDL_APPSTORE_KEY }}
|
||||
ISSUER_ID: ${{ secrets.HGUANDL_APPSTORE_ISSUER }}
|
||||
|
||||
- name: Attach Notarization Tickets
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
run: |
|
||||
dmg="MAA-${{ needs.meta.outputs.tag }}-macos-universal.dmg"
|
||||
xcrun stapler staple ${dmg}
|
||||
find . -name "*.dmg" | while read dmg; do
|
||||
codesign -s "$NOTARY_TEAM" --timestamp ${dmg}
|
||||
xcrun notarytool submit --apple-id "$NOTARY_USER" --password "$NOTARY_PASSWD" --team-id "$NOTARY_TEAM" --wait ${dmg}
|
||||
xcrun stapler staple ${dmg}
|
||||
done
|
||||
env:
|
||||
NOTARY_USER: ${{ secrets.HGUANDL_NOTARY_AAPL_ID }}
|
||||
NOTARY_PASSWD: ${{ secrets.HGUANDL_NOTARY_PASSWD }}
|
||||
NOTARY_TEAM: ${{ secrets.HGUANDL_SIGN_IDENTITY }}
|
||||
working-directory: release
|
||||
|
||||
- name: Upload MAA to Github
|
||||
@@ -553,16 +439,12 @@ jobs:
|
||||
path: ${{ startsWith(github.ref, 'refs/tags/v') && 'release/MAA*' || 'src/MaaMacGui/MAA.xcarchive/**' }}
|
||||
|
||||
release:
|
||||
# Prevent duplicate runs on organization branches with PRs
|
||||
if: (github.event_name != 'pull_request' ||
|
||||
github.event.pull_request.head.repo.full_name !=
|
||||
github.event.pull_request.base.repo.full_name) && startsWith(github.ref, 'refs/tags/v')
|
||||
|
||||
needs: [meta, windows, ubuntu, macOS-Core, macOS-GUI]
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
needs: [meta, windows, ubuntu, macOS-GUI]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Download MAA from Github
|
||||
uses: actions/download-artifact@v5
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: assets
|
||||
|
||||
@@ -575,31 +457,15 @@ jobs:
|
||||
find . -type f | while read f; do mv -fvt . $f; done
|
||||
|
||||
- name: Release to Github
|
||||
uses: softprops/action-gh-release@v2.3.3
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
body_path: CHANGELOG.md
|
||||
files: |
|
||||
assets/*
|
||||
prerelease: ${{ needs.meta.outputs.prerelease != 'false' }}
|
||||
|
||||
- name: Trigger MirrorChyan
|
||||
run: |
|
||||
gh workflow run --repo $GITHUB_REPOSITORY mirrorchyan
|
||||
gh workflow run --repo $GITHUB_REPOSITORY mirrorchyan_release_note
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Trigger secondary workflows # ref: https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow
|
||||
run: |
|
||||
gh workflow run --repo $GITHUB_REPOSITORY release-ota
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.MISTEOWORKFLOW }}
|
||||
|
||||
- name: Create issue if failed
|
||||
if: failure()
|
||||
uses: actions-cool/issues-helper@v3
|
||||
with:
|
||||
actions: "create-issue"
|
||||
title: "Failed Release"
|
||||
body: |
|
||||
${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
||||
|
||||
57
.github/workflows/codeql-core.yml
vendored
57
.github/workflows/codeql-core.yml
vendored
@@ -1,57 +0,0 @@
|
||||
name: "CodeQL MaaCore and MaaWpfGui Analysis"
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: ["dev"]
|
||||
paths:
|
||||
- "3rdparty/include/**"
|
||||
- "include/**"
|
||||
- "src/**"
|
||||
- "cmake/**"
|
||||
- "CMakeLists.txt"
|
||||
- ".github/workflows/codeql-core.yml"
|
||||
- "!**/*.md"
|
||||
- "!**/*.xaml"
|
||||
schedule:
|
||||
- cron: "45 11 * * *" # Runs daily at 11:45 UTC
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
actions: write
|
||||
contents: read
|
||||
packages: read
|
||||
security-events: write
|
||||
|
||||
jobs:
|
||||
analyze-manual:
|
||||
name: Analyze MaaCore and MaaWpfGui
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
show-progress: false
|
||||
|
||||
- name: Setup CodeQL
|
||||
uses: github/codeql-action/init@v3
|
||||
with:
|
||||
languages: c-cpp,csharp
|
||||
build-mode: manual
|
||||
|
||||
- name: Run CodeQL
|
||||
uses: github/codeql-action/analyze@v3
|
||||
with:
|
||||
category: "/language:multi-manual"
|
||||
|
||||
- name: Delete old caches
|
||||
shell: pwsh
|
||||
run: |
|
||||
$oldCaches = gh cache list --key codeql --order asc --json key | ConvertFrom-Json | Select-Object -SkipLast 1
|
||||
foreach ($cache in $oldCaches) {
|
||||
if ($cache.key) {
|
||||
Write-Host "Deleting cache: $($cache.key)"
|
||||
gh cache delete $cache.key
|
||||
}
|
||||
}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
36
.github/workflows/codeql-wf.yml
vendored
36
.github/workflows/codeql-wf.yml
vendored
@@ -1,36 +0,0 @@
|
||||
name: "CodeQL Workflows Analysis"
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: ["dev"]
|
||||
paths:
|
||||
- ".github/**/*.yml"
|
||||
schedule:
|
||||
- cron: "00 12 * * *" # Runs daily at 12:00 UTC
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
actions: write
|
||||
contents: read
|
||||
security-events: write
|
||||
|
||||
jobs:
|
||||
analyze-workflows:
|
||||
name: Analyze GitHub Workflows
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
show-progress: false
|
||||
|
||||
- name: Setup CodeQL for GitHub Actions
|
||||
uses: github/codeql-action/init@v3
|
||||
with:
|
||||
languages: actions
|
||||
build-mode: none
|
||||
|
||||
- name: Run CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v3
|
||||
with:
|
||||
category: "/language:multi-none"
|
||||
48
.github/workflows/docs-build-test.yml
vendored
Normal file
48
.github/workflows/docs-build-test.yml
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
name: Build Test for docs
|
||||
|
||||
on:
|
||||
push:
|
||||
branches-ignore:
|
||||
- "master"
|
||||
paths:
|
||||
- "docs/**"
|
||||
pull_request:
|
||||
branches:
|
||||
- "dev"
|
||||
paths:
|
||||
- "docs/**"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build-test:
|
||||
timeout-minutes: 20
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
show-progress: false
|
||||
|
||||
- name: Setup Node.js environment
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm i
|
||||
working-directory: "./docs"
|
||||
|
||||
- name: Cleanup files
|
||||
run: rm tsconfig.json
|
||||
working-directory: "./docs"
|
||||
|
||||
- name: Build
|
||||
run: npm run build
|
||||
working-directory: "./docs"
|
||||
|
||||
- name: Upload artifact to GitHub
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: docs
|
||||
path: "./docs/.vuepress/dist"
|
||||
43
.github/workflows/gen-changelog.yml
vendored
43
.github/workflows/gen-changelog.yml
vendored
@@ -2,28 +2,22 @@ name: gen-changelog
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types:
|
||||
- opened
|
||||
- reopened
|
||||
- ready_for_review
|
||||
types: [opened, reopened, ready_for_review]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
gen:
|
||||
# startsWith 表达式不区分大小写
|
||||
if: github.event.pull_request.draft == false && startsWith(github.event.pull_request.title, 'Release v')
|
||||
if: github.event.pull_request.draft == false && startsWith(github.event.pull_request.title, 'Release v') # startsWith 表达式不区分大小写
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
show-progress: false
|
||||
|
||||
- name: Extract tag name
|
||||
id: extract_tag
|
||||
env:
|
||||
PR_BODY: ${{ format('{0}/{1}', runner.temp, 'output' ) }}
|
||||
run: |
|
||||
tag_name=$(echo "${{ github.event.pull_request.title }}" | sed -E 's/(Release|release)//' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
|
||||
echo "tag_name=$tag_name" >> $GITHUB_OUTPUT
|
||||
@@ -33,33 +27,19 @@ jobs:
|
||||
|
||||
latest_stable_tag=$(git tag -l 'v*' | grep -v '-' | sort -V | tail -n 1) # 上一个 stable 版本
|
||||
newest_tag=$(git describe --tags --match "v*" --abbrev=0) # 最新版本
|
||||
echo "latest_stable_tag=$latest_stable_tag" >> $GITHUB_OUTPUT
|
||||
echo "newest_tag=$newest_tag" >> $GITHUB_OUTPUT
|
||||
echo "latest_stable_tag: $latest_stable_tag"
|
||||
echo "newest_tag: $newest_tag"
|
||||
|
||||
if [[ $tag_name == *-* ]]; then # 判断新版本是否为 beta 版本
|
||||
latest=$newest_tag # 若是,则将 latest 参数设置为最新版本
|
||||
if [[ $tag_name == *-* ]]; then # 判断新版本是否为 beta 版本
|
||||
latest=$newest_tag # 若是,则将 latest 参数设置为最新版本
|
||||
else
|
||||
latest=$latest_stable_tag # 若否,则设置为上一个 stable 版本
|
||||
latest=$latest_stable_tag # 若否,则设置为上一个 stable 版本
|
||||
fi
|
||||
|
||||
echo "latest=$latest" >> $GITHUB_OUTPUT
|
||||
|
||||
cat $GITHUB_OUTPUT
|
||||
|
||||
echo '======='
|
||||
|
||||
echo 'Target PR: ${{ github.event.pull_request.html_url }}' >> $PR_BODY
|
||||
echo '' >> $PR_BODY
|
||||
echo '<details><summary>Debug info</summary>' >> $PR_BODY
|
||||
echo '' >> $PR_BODY
|
||||
echo '```' >> $PR_BODY
|
||||
sed 's/=/: /1' $GITHUB_OUTPUT >> $PR_BODY
|
||||
echo '```' >> $PR_BODY
|
||||
echo '' >> $PR_BODY
|
||||
echo '</details>' >> $PR_BODY
|
||||
|
||||
cat $PR_BODY
|
||||
|
||||
- name: Generate Changelog
|
||||
run: |
|
||||
git switch dev
|
||||
@@ -79,12 +59,11 @@ jobs:
|
||||
git commit -m "$commit_msg"
|
||||
|
||||
- name: Create PR
|
||||
uses: peter-evans/create-pull-request@v7
|
||||
uses: peter-evans/create-pull-request@v5
|
||||
with:
|
||||
sign-commits: true
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
title: ${{ steps.extract_tag.outputs.pr_title }}
|
||||
body-path: ${{ format('{0}/{1}', runner.temp, 'output' ) }}
|
||||
body: ${{ github.event.pull_request.html_url }}
|
||||
base: "dev"
|
||||
branch: "changelog"
|
||||
delete-branch: true
|
||||
@@ -94,6 +73,6 @@ jobs:
|
||||
AnnAngela
|
||||
|
||||
- name: Add reviewers to release PR
|
||||
uses: kentaro-m/auto-assign-action@v2.0.0
|
||||
uses: kentaro-m/auto-assign-action@v1.2.5
|
||||
with:
|
||||
configuration-path: ".github/release_reviewers.yaml"
|
||||
|
||||
152
.github/workflows/issue-checkbox-checker.yml
vendored
152
.github/workflows/issue-checkbox-checker.yml
vendored
@@ -1,152 +0,0 @@
|
||||
name: Auto Close not reading issues or Fold checkboxes
|
||||
|
||||
on:
|
||||
issues:
|
||||
types: [opened]
|
||||
|
||||
jobs:
|
||||
check-then-close-or-fold:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
issues: write
|
||||
|
||||
steps:
|
||||
- name: Check for duplicate issues in last hour
|
||||
id: duplicate-check
|
||||
uses: actions/github-script@v8
|
||||
with:
|
||||
script: |
|
||||
const oneHourAgo = new Date(Date.now() - 60 * 60 * 1000);
|
||||
const currentIssueCreatedAt = new Date(context.payload.issue.created_at);
|
||||
const issueAuthor = context.payload.issue.user.login;
|
||||
|
||||
// 重新获取该用户最近的 issues
|
||||
const { data: userIssues } = await github.rest.issues.listForRepo({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
creator: issueAuthor,
|
||||
state: 'all',
|
||||
since: oneHourAgo.toISOString(),
|
||||
per_page: 30
|
||||
});
|
||||
|
||||
// 过滤出1小时内创建的其他 issues(排除当前 issue)
|
||||
const recentIssues = userIssues.filter(issue => {
|
||||
const issueCreatedAt = new Date(issue.created_at);
|
||||
return issue.number !== context.issue.number &&
|
||||
issueCreatedAt >= oneHourAgo &&
|
||||
issueCreatedAt < currentIssueCreatedAt;
|
||||
});
|
||||
|
||||
if (recentIssues.length > 0) {
|
||||
// 给当前 issue 添加标签
|
||||
await github.rest.issues.addLabels({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.issue.number,
|
||||
labels: ['rapid-submission']
|
||||
});
|
||||
|
||||
// 给1小时内的其他 issues 也添加标签
|
||||
for (const issue of recentIssues) {
|
||||
try {
|
||||
await github.rest.issues.addLabels({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: issue.number,
|
||||
labels: ['rapid-submission']
|
||||
});
|
||||
console.log(`Added rapid-submission label to issue #${issue.number}`);
|
||||
} catch (error) {
|
||||
console.log(`Failed to add label to issue #${issue.number}: ${error.message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- name: Check checkbox status
|
||||
id: unread-checkbox-check
|
||||
uses: actions/github-script@v8
|
||||
with:
|
||||
script: |
|
||||
// 找不到###就算了
|
||||
if (!/###([^#]+)###/.test(context.payload.issue.body)) {
|
||||
return false;
|
||||
}
|
||||
var checkList = /###([^#]+)###/.exec(context.payload.issue.body)[1];
|
||||
const UnreadRegexCn = /- \[x\]\s*.*?我.*未仔细阅读/i;
|
||||
const UnreadRegexCn_ = /- \[ \]\s*.*?我.*未仔细阅读/i;
|
||||
if (/- \[(x| )\]\s*.*?[\u4e00-\u9fa5]+/i.test(checkList)) { // 中英区分
|
||||
if (UnreadRegexCn.test(checkList)) {
|
||||
return true;
|
||||
}
|
||||
checkList = checkList.replace(UnreadRegexCn_, "");
|
||||
return /- \[ \]\s*.*?[\u4e00-\u9fa5]+/i.test(checkList);
|
||||
}
|
||||
const texts = [
|
||||
'I have checked all the options without carefully reading the content and believe this will not affect issue resolution.'];
|
||||
return texts.some(text => new RegExp(`- \\[x\\]\\s*${text}`).test(context.payload.issue.body));
|
||||
|
||||
- name: Close and lock issue
|
||||
if: steps.unread-checkbox-check.outputs.result == 'true'
|
||||
uses: actions/github-script@v8
|
||||
with:
|
||||
script: |
|
||||
await github.rest.issues.update({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.issue.number,
|
||||
state: 'closed',
|
||||
state_reason: 'not_planned'
|
||||
});
|
||||
|
||||
await github.rest.issues.addLabels({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.issue.number,
|
||||
labels: ['low-quality-report']
|
||||
});
|
||||
|
||||
await github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.issue.number,
|
||||
body: '因为未阅读模板提示并正确提交,触发了自动关闭规则\n\nBecause the template prompt was not read and submitted correctly, the automatic closing rule was triggered'
|
||||
});
|
||||
|
||||
- name: Fold checkboxes
|
||||
if: steps.unread-checkbox-check.outputs.result == 'false'
|
||||
uses: actions/github-script@v8
|
||||
with:
|
||||
script: |
|
||||
const originalBody = context.payload.issue.body;
|
||||
if (originalBody.includes('<details><summary>Checkboxes</summary>\n\n')) {
|
||||
return;
|
||||
}
|
||||
const checkboxSectionRegex_cn_bug = /([\s\S]*?)(### 问题描述\n\n)/;
|
||||
const checkboxSectionRegex_cn_feat = /([\s\S]*?)(### 说说你遇到的问题?\n\n)/;
|
||||
const checkboxSectionRegex_en_bug = /([\s\S]*?)(### Description\n\n)/;
|
||||
const checkboxSectionRegex_en_feat = /([\s\S]*?)(### The problems you have encountered?\n\n)/;
|
||||
|
||||
const foldedBody_cn_bug = originalBody.replace(
|
||||
checkboxSectionRegex_cn_bug,
|
||||
`<details><summary>Checkboxes</summary>\n\n$1\n\n</details>\n\n$2`
|
||||
);
|
||||
const foldedBody_cn_feat = foldedBody_cn_bug.replace(
|
||||
checkboxSectionRegex_cn_feat,
|
||||
`<details><summary>Checkboxes</summary>\n\n$1\n\n</details>\n\n$2`
|
||||
);
|
||||
const foldedBody_en_bug = foldedBody_cn_feat.replace(
|
||||
checkboxSectionRegex_en_bug,
|
||||
`<details><summary>Checkboxes</summary>\n\n$1\n\n</details>\n\n$2`
|
||||
);
|
||||
const foldedBody = foldedBody_en_bug.replace(
|
||||
checkboxSectionRegex_en_feat,
|
||||
`<details><summary>Checkboxes</summary>\n\n$1\n\n</details>\n\n$2`
|
||||
);
|
||||
|
||||
await github.rest.issues.update({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.issue.number,
|
||||
body: foldedBody
|
||||
});
|
||||
3
.github/workflows/issue-checker.yml
vendored
3
.github/workflows/issue-checker.yml
vendored
@@ -1,5 +1,4 @@
|
||||
name: "Issue Checker"
|
||||
|
||||
on:
|
||||
issues:
|
||||
types: [opened, edited]
|
||||
@@ -17,7 +16,7 @@ jobs:
|
||||
triage:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: MaaAssistantArknights/issue-checker@v1.14
|
||||
- uses: zzyyyl/issue-checker@v1.7
|
||||
with:
|
||||
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
configuration-path: .github/issue-checker.yml
|
||||
|
||||
63
.github/workflows/markdown-checker.yml
vendored
63
.github/workflows/markdown-checker.yml
vendored
@@ -1,63 +0,0 @@
|
||||
name: Check Dead Links
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 0 * * 2" # Every Tuesday at 00:00 UTC
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
paths:
|
||||
- "**/*.md"
|
||||
- "docs/**"
|
||||
- ".github/workflows/markdown-checker.yml"
|
||||
pull_request:
|
||||
branches:
|
||||
- dev
|
||||
paths:
|
||||
- "**/*.md"
|
||||
- "docs/**"
|
||||
- ".github/workflows/markdown-checker.yml"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
check-links:
|
||||
if: github.repository_owner == 'MaaAssistantArknights' && github.event.head_commit.author.email != '41898282+github-actions[bot]@users.noreply.github.com'
|
||||
name: Check Dead Links
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
pull-requests: write
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
show-progress: false
|
||||
|
||||
- name: Cache Primes
|
||||
id: cache-primes
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: .lycheecache
|
||||
key: lychee-cache
|
||||
|
||||
- name: Check dead links
|
||||
uses: lycheeverse/lychee-action@v2
|
||||
with:
|
||||
# 仅检查内部链接,排除所有外部链接
|
||||
args: >
|
||||
--verbose --no-progress
|
||||
--cache --max-cache-age 1d --cache-exclude-status '429, 500..599'
|
||||
--exclude 'https?://.*'
|
||||
--exclude-path 'docs/zh-tw/manual/introduction/introduction_old.md'
|
||||
--exclude-path 'docs/ja-jp/manual/introduction/introduction_old.md'
|
||||
-- './docs/**/*.md' './README.md'
|
||||
|
||||
- name: Comment (only for PR)
|
||||
if: failure() && github.event_name == 'pull_request'
|
||||
uses: marocchino/sticky-pull-request-comment@v2
|
||||
with:
|
||||
message: |
|
||||
Dead links found in the documentation. Please fix them.
|
||||
Details: https://github.com/MaaAssistantArknights/MaaAssistantArknights/actions/runs/${{ github.run_id }}
|
||||
71
.github/workflows/mirrorchyan.yml
vendored
71
.github/workflows/mirrorchyan.yml
vendored
@@ -1,71 +0,0 @@
|
||||
name: mirrorchyan
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
mirrorchyan:
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- name: Upload MAA win x64
|
||||
uses: MirrorChyan/uploading-action@v1
|
||||
if: always()
|
||||
with:
|
||||
filetype: latest-release
|
||||
filename: "*MAA-*-win-x64.zip"
|
||||
mirrorchyan_rid: MAA
|
||||
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
owner: ${{ github.repository_owner }}
|
||||
repo: ${{ github.event.repository.name }}
|
||||
upload_token: ${{ secrets.MirrorChyanUploadToken }}
|
||||
os: win
|
||||
arch: x64
|
||||
|
||||
- name: Upload MAA win arm64
|
||||
uses: MirrorChyan/uploading-action@v1
|
||||
if: always()
|
||||
with:
|
||||
filetype: latest-release
|
||||
filename: "*MAA-*-win-arm64.zip"
|
||||
mirrorchyan_rid: MAA
|
||||
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
owner: ${{ github.repository_owner }}
|
||||
repo: ${{ github.event.repository.name }}
|
||||
upload_token: ${{ secrets.MirrorChyanUploadToken }}
|
||||
os: win
|
||||
arch: arm64
|
||||
|
||||
- name: Upload MAA macos arm64
|
||||
uses: MirrorChyan/uploading-action@v1
|
||||
if: always()
|
||||
with:
|
||||
filetype: latest-release
|
||||
filename: "MAA-*-macos-universal.dmg"
|
||||
extra_zip: true
|
||||
mirrorchyan_rid: MAA
|
||||
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
owner: ${{ github.repository_owner }}
|
||||
repo: ${{ github.event.repository.name }}
|
||||
upload_token: ${{ secrets.MirrorChyanUploadToken }}
|
||||
os: macos
|
||||
arch: arm64
|
||||
|
||||
- name: Upload MAA macos x64
|
||||
uses: MirrorChyan/uploading-action@v1
|
||||
if: always()
|
||||
with:
|
||||
filetype: latest-release
|
||||
filename: "MAA-*-macos-universal.dmg"
|
||||
extra_zip: true
|
||||
mirrorchyan_rid: MAA
|
||||
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
owner: ${{ github.repository_owner }}
|
||||
repo: ${{ github.event.repository.name }}
|
||||
upload_token: ${{ secrets.MirrorChyanUploadToken }}
|
||||
os: macos
|
||||
arch: x64
|
||||
19
.github/workflows/mirrorchyan_release_note.yml
vendored
19
.github/workflows/mirrorchyan_release_note.yml
vendored
@@ -1,19 +0,0 @@
|
||||
name: mirrorchyan_release_note
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
release:
|
||||
types: [edited]
|
||||
|
||||
jobs:
|
||||
mirrorchyan:
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- name: Release Note for MAA
|
||||
uses: MirrorChyan/release-note-action@v1
|
||||
with:
|
||||
mirrorchyan_rid: MAA
|
||||
|
||||
upload_token: ${{ secrets.MirrorChyanUploadToken }}
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
109
.github/workflows/optimize-templates.yml
vendored
109
.github/workflows/optimize-templates.yml
vendored
@@ -1,109 +0,0 @@
|
||||
name: Optimize PNG Templates
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- "dev"
|
||||
paths:
|
||||
- "resource/**/*.png"
|
||||
- "docs/.vuepress/public/images/**"
|
||||
- "website/apps/web/public/**"
|
||||
- "website/apps/web/src/assets/links/**"
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
commit_message:
|
||||
description: "Commit Message"
|
||||
type: string
|
||||
required: false
|
||||
|
||||
jobs:
|
||||
optimize-png:
|
||||
# Skip workflow to prevent double consecutive runs
|
||||
# Skip workflow on PR merges
|
||||
if: github.repository_owner == 'MaaAssistantArknights' && ${{ github.event.head_commit.author.email != '41898282+github-actions[bot]@users.noreply.github.com' }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check for direct push
|
||||
id: check_push
|
||||
run: |
|
||||
if [[ "${{ github.event_name }}" != "workflow_dispatch" ]]; then
|
||||
pr_merge_status=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
||||
"https://api.github.com/repos/${{ github.repository }}/commits/${{ github.event.after }}/pulls" | xargs)
|
||||
|
||||
if [[ "$pr_merge_status" == "[ ]" ]]; then
|
||||
echo "Direct push detected. Proceeding..."
|
||||
echo "is_pr=False" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "PR merge detected. Exiting."
|
||||
echo "is_pr=True" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
else
|
||||
echo "Manual trigger detected. Proceeding..."
|
||||
echo "is_pr=False" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Checkout repository
|
||||
if: steps.check_push.outputs.is_pr != 'True'
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
show-progress: false
|
||||
persist-credentials: false
|
||||
|
||||
- name: Setup python
|
||||
if: steps.check_push.outputs.is_pr != 'True'
|
||||
uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: "3.11"
|
||||
|
||||
# - name: Cache Python packages
|
||||
# id: cache_python
|
||||
# if: steps.check_push.outputs.is_pr != 'True' && always()
|
||||
# uses: actions/cache@v4
|
||||
# with:
|
||||
# path: ${{ env.pythonLocation }}/lib/python3.11/site-packages
|
||||
# key: ${{ runner.os }}-pip-optimize-templates-${{ hashFiles('./tools/OptimizeTemplates/requirements.txt') }}
|
||||
|
||||
- name: Install dependencies
|
||||
# if: steps.check_push.outputs.is_pr != 'True' && steps.cache_python.outputs.cache-hit != 'true'
|
||||
if: steps.check_push.outputs.is_pr != 'True'
|
||||
run: |
|
||||
pip install -r tools/OptimizeTemplates/requirements.txt
|
||||
|
||||
- name: Setup oxipng
|
||||
if: steps.check_push.outputs.is_pr != 'True'
|
||||
uses: baptiste0928/cargo-install@v3
|
||||
with:
|
||||
crate: oxipng
|
||||
|
||||
- name: Run optimize_templates
|
||||
if: steps.check_push.outputs.is_pr != 'True'
|
||||
run: |
|
||||
python3 tools/OptimizeTemplates/optimize_templates.py
|
||||
|
||||
- name: Commit changes
|
||||
id: commit_changes
|
||||
if: steps.check_push.outputs.is_pr != 'True'
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
|
||||
git add .
|
||||
|
||||
if git diff-index --quiet HEAD --; then
|
||||
echo "No changes to commit"
|
||||
else
|
||||
commit_msg="${{ github.event.inputs.commit_message }}"
|
||||
if [ -z "$commit_msg" ]; then
|
||||
commit_msg="chore: Auto Templates Optimization"
|
||||
fi
|
||||
git commit -m "$commit_msg" -m "Triggered by ${{github.sha}}" -m "[skip changelog]"
|
||||
git pull origin $(git rev-parse --abbrev-ref HEAD) --unshallow --rebase
|
||||
echo "have_commits=True" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Push changes
|
||||
if: steps.check_push.outputs.is_pr != 'True' && steps.commit_changes.outputs.have_commits == 'True' && github.repository_owner == 'MaaAssistantArknights'
|
||||
uses: ad-m/github-push-action@master
|
||||
with:
|
||||
github_token: ${{ secrets.MAA_RESOURCE_SYNC }}
|
||||
branch: ${{ github.ref }}
|
||||
3
.github/workflows/pr-auto-tag.yml
vendored
3
.github/workflows/pr-auto-tag.yml
vendored
@@ -9,7 +9,6 @@ on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: "Name of the tag to create for the release"
|
||||
type: string
|
||||
required: true
|
||||
|
||||
@@ -20,7 +19,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.MAARELEASE_RELEASE }}
|
||||
|
||||
17
.github/workflows/pr-checker.yml
vendored
17
.github/workflows/pr-checker.yml
vendored
@@ -1,17 +1,22 @@
|
||||
name: PR Checker
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
pull_request:
|
||||
types: [opened, edited, ready_for_review, reopened, synchronize]
|
||||
|
||||
permissions:
|
||||
issues: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
check_commit_name_in_pr:
|
||||
if: ${{ !github.event.pull_request.merged && github.base_ref != 'master' }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Cleanup Previous Comment
|
||||
uses: actions/github-script@v8
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
const { data: comments } = await github.rest.issues.listComments({
|
||||
owner: context.repo.owner,
|
||||
@@ -27,9 +32,11 @@ jobs:
|
||||
comment_id: previousComment.id
|
||||
});
|
||||
}
|
||||
|
||||
- name: Check Commits
|
||||
uses: actions/github-script@v8
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
const { data: commits } = await github.rest.pulls.listCommits({
|
||||
owner: context.repo.owner,
|
||||
@@ -38,7 +45,7 @@ jobs:
|
||||
per_page: 100
|
||||
});
|
||||
|
||||
const regex = /^((build|chore|ci|docs?|feat!?|fix|perf|refactor|rft|style|test|i18n|typo|debug)[\:\.\(\,]|[Rr]evert|[Rr]elease|[Rr]eapply)/;
|
||||
const regex = /^((build|chore|ci|docs?|feat|fix|perf|refactor|rft|style|test|i18n|typo)[\:\.\(\,]|[Rr]evert|[Rr]elease)/;
|
||||
const invalidCommits = commits.filter(commit => !regex.test(commit.commit.message) || commit.parents.length > 1);
|
||||
|
||||
console.log(`Checked ${commits.length} commit(s)`);
|
||||
@@ -51,7 +58,7 @@ jobs:
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.payload.pull_request.number,
|
||||
body: `## ⚠️ Found ${invalidCommits.length} invalid commit(s):\n\n${invalidCommitInfoList}\n\n---\nPlease follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) format, and **DO NOT** use merge commits.\n请遵循 [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) 格式,以及**不要**使用Merge Commit(修改 Commit Message 无法绕过检测)。`
|
||||
body: `## ⚠️ Found ${invalidCommits.length} invalid commit(s):\n\n${invalidCommitInfoList}\n\n---\nPlease follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) format.`
|
||||
});
|
||||
|
||||
core.setFailed(`Found ${invalidCommits.length} invalid commit(s):\n${invalidCommitNames.join("\n-------------------\n")}`);
|
||||
|
||||
45
.github/workflows/qodana.yml
vendored
Normal file
45
.github/workflows/qodana.yml
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
name: Qodana static analysis
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
pull_request: # 在 PR 更新的场合进行扫描
|
||||
paths:
|
||||
- ".github/workflows/qodana.yml"
|
||||
- "src/MaaWpfGui/*"
|
||||
- "qodana.yaml"
|
||||
- "src/MaaWpfGui/**"
|
||||
- "MAA.sln"
|
||||
push: # 在主分支推送代码的场合进行扫描
|
||||
branches:
|
||||
- master
|
||||
- "releases/*"
|
||||
- dev
|
||||
paths:
|
||||
- ".github/workflows/qodana.yml"
|
||||
- "src/MaaWpfGui/**"
|
||||
- "qodana.yaml"
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
checks: write
|
||||
|
||||
jobs:
|
||||
qodana:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }} # to check out the actual pull request commit, not the merge commit
|
||||
fetch-depth: 0 # a full history is required for pull request analysis
|
||||
show-progress: false
|
||||
|
||||
- name: Qodana Scan
|
||||
uses: JetBrains/qodana-action@main
|
||||
with:
|
||||
pr-mode: false
|
||||
post-pr-comment: true
|
||||
args: --baseline,.github/qodana.sarif.json
|
||||
env:
|
||||
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
|
||||
338
.github/workflows/release-nightly-ota.yml
vendored
338
.github/workflows/release-nightly-ota.yml
vendored
@@ -1,8 +1,6 @@
|
||||
name: release-nightly-ota
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 22 * * *" # Runs daily at 22:00 UTC
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
release_body:
|
||||
@@ -13,238 +11,73 @@ on:
|
||||
description: "Commit to build (git checkout)"
|
||||
type: string
|
||||
required: false
|
||||
limit_maa:
|
||||
limit:
|
||||
description: "Number of releases to fetch from MaaAssistantArknights"
|
||||
required: true
|
||||
default: 10
|
||||
default: 30
|
||||
type: number
|
||||
limit_maarelease:
|
||||
limit_2:
|
||||
description: "Number of releases to fetch from MaaRelease"
|
||||
required: true
|
||||
default: 10
|
||||
default: 30
|
||||
type: number
|
||||
|
||||
jobs:
|
||||
build-win-nightly:
|
||||
if: github.repository_owner == 'MaaAssistantArknights'
|
||||
runs-on: windows-latest
|
||||
strategy:
|
||||
matrix:
|
||||
arch: [x64]
|
||||
include:
|
||||
- msbuild_target: x64
|
||||
lowercase_target: x64
|
||||
fail-fast: false
|
||||
env:
|
||||
MAABUILDER_TARGET_PLATFORM: ${{ matrix.msbuild_target }}
|
||||
outputs:
|
||||
tag: ${{ steps.set_tag.outputs.tag }}
|
||||
pre_version: ${{ steps.set_tag.outputs.pre_version }}
|
||||
main_tag_name: ${{ steps.push_main_tag.outputs.main_tag_name }}
|
||||
changelog: ${{ steps.read_changelog.outputs.content }}
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
# repository: 'MaaAssistantArknights/MaaAssistantArknights'
|
||||
submodules: recursive
|
||||
#ref: ${{ inputs.ref }}
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
fetch-depth: 250
|
||||
|
||||
- name: Fetch tags
|
||||
- name: Checkout ref
|
||||
run: |
|
||||
git fetch --depth=250 --tags
|
||||
if ("${{ inputs.ref }}" -ne "") {
|
||||
git checkout --progress --recurse-submodules ${{ inputs.ref || 'dev' }}
|
||||
}
|
||||
|
||||
- name: Fetch submodules
|
||||
- name: Install semver
|
||||
run: |
|
||||
git submodule update --init --depth 1 3rdparty/EmulatorExtras
|
||||
npm install --global --progress semver
|
||||
|
||||
- name: Checkout ref (if provided)
|
||||
if: inputs.ref != ''
|
||||
run: |
|
||||
git checkout --progress --recurse-submodules ${{ inputs.ref }}
|
||||
|
||||
- name: Check for Changes and Set tag
|
||||
- name: Set tag
|
||||
id: set_tag
|
||||
run: |
|
||||
# Fetch the latest tag from the repository
|
||||
$latest_tag = git describe --tags --abbrev=0
|
||||
|
||||
Write-Output "Previous Tag: $latest_tag"
|
||||
Write-Output "latest_tag=$latest_tag" >> $env:GITHUB_OUTPUT
|
||||
|
||||
# Check for changes between the latest tag and HEAD
|
||||
$recent_changes = git log "$latest_tag..HEAD" --oneline
|
||||
|
||||
if (-not $recent_changes) {
|
||||
Write-Output "No commits. Cancelling workflow..."
|
||||
Write-Output "cancel_run=true" >> $env:GITHUB_ENV
|
||||
exit 0
|
||||
} else {
|
||||
Write-Output "Recent commits: $recent_changes"
|
||||
Write-Output "Commits found. Continuing build..."
|
||||
Write-Output "cancel_run=false" >> $env:GITHUB_ENV
|
||||
}
|
||||
|
||||
# Get the full description of the current commit
|
||||
$described = git describe --tags --long --match 'v*'
|
||||
Write-Output "New Described: $described"
|
||||
$ids = $described -split "-"
|
||||
|
||||
if ($ids.Length -eq 3) {
|
||||
# Extract and parse the current version
|
||||
$current_version = $ids[0].Substring(1)
|
||||
$parts = $current_version -split '\.'
|
||||
if ($parts.Length -ne 3) {
|
||||
Write-Error "Invalid version format: $current_version. Expected 'major.minor.patch'."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Increment the patch version
|
||||
$parts[2] = [int]$parts[2] + 1
|
||||
$new_version = "$($parts[0]).$($parts[1]).$($parts[2])"
|
||||
|
||||
# Construct the new tag and pre_version
|
||||
$ver = "v$new_version"
|
||||
$pre_version = $ids[0]
|
||||
$dist = "{0:D3}" -f [int]$ids[1]
|
||||
|
||||
Write-Output "pre_version=$pre_version" >> $env:GITHUB_OUTPUT
|
||||
Write-Output "New Tag: $ver-alpha.1.d$dist.$($ids[2])"
|
||||
Write-Output "tag=$ver-alpha.1.d$dist.$($ids[2])" >> $env:GITHUB_OUTPUT
|
||||
|
||||
$described = $(git describe --tags --long --match 'v*')
|
||||
$ids = $($described -split "-")
|
||||
if ($ids.length -eq 3) {
|
||||
$ver = "v$(semver --increment $ids[0].Substring(1))"
|
||||
$pre_version = "$($ids[0])"
|
||||
$dist = `printf "%03d"` $ids[1]
|
||||
echo "tag=$ver-alpha.1.d$($dist).$($ids[2])" >> $env:GITHUB_OUTPUT
|
||||
echo "pre_version=$pre_version" >> $env:GITHUB_OUTPUT
|
||||
exit 0
|
||||
}
|
||||
|
||||
if ($ids.Length -eq 4) {
|
||||
$dist = "{0:D3}" -f [int]$ids[2]
|
||||
$pre_version = "$($ids[0])-$($ids[1])"
|
||||
|
||||
Write-Output "Pre Version: $pre_version"
|
||||
Write-Output "pre_version=$pre_version" >> $env:GITHUB_OUTPUT
|
||||
|
||||
Write-Output "tag: $pre_version.d$dist.$($ids[3])"
|
||||
Write-Output "tag=$pre_version.d$dist.$($ids[3])" >> $env:GITHUB_OUTPUT
|
||||
|
||||
if ($ids.length -eq 4) {
|
||||
$dist = `printf "%03d"` $ids[2]
|
||||
$pre_version = "$($ids[0])""-""$($ids[1])"
|
||||
echo "tag=$($ids[0])-$($ids[1]).d$($dist).$($ids[3])" >> $env:GITHUB_OUTPUT
|
||||
echo "pre_version=$pre_version" >> $env:GITHUB_OUTPUT
|
||||
exit 0
|
||||
}
|
||||
|
||||
exit 1
|
||||
|
||||
- name: Stop if no changes
|
||||
if: env.cancel_run == 'true'
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
curl -s -L -X POST `
|
||||
-H "Accept: application/vnd.github+json" `
|
||||
-H "Authorization: Bearer ${{ secrets.MAA_ACTION_READ_WRITE }}" `
|
||||
-H "X-GitHub-Api-Version: 2022-11-28" `
|
||||
"https://api.github.com/repos/MaaAssistantArknights/MaaAssistantArknights/actions/runs/${{ github.run_id }}/cancel" > $null
|
||||
|
||||
gh run watch ${{ github.run_id }}
|
||||
|
||||
- name: Generate Changelog
|
||||
id: generate_changelog
|
||||
run: |
|
||||
python3 tools/ChangelogGenerator/changelog_generator.py --latest "${{ steps.set_tag.outputs.latest_tag }}" --tag "${{ steps.set_tag.outputs.tag }}"
|
||||
Get-Content .\changelog.md | Select-Object -Skip 2 | Out-File -FilePath changelog_notag.md -Encoding utf8
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
PYTHONIOENCODING: "utf-8"
|
||||
|
||||
- name: Stop if no changes
|
||||
if: steps.generate_changelog.outputs.cancel_run == 'true'
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
curl -s -L -X POST `
|
||||
-H "Accept: application/vnd.github+json" `
|
||||
-H "Authorization: Bearer ${{ secrets.MAA_ACTION_READ_WRITE }}" `
|
||||
-H "X-GitHub-Api-Version: 2022-11-28" `
|
||||
"https://api.github.com/repos/MaaAssistantArknights/MaaAssistantArknights/actions/runs/${{ github.run_id }}/cancel" > $null
|
||||
|
||||
gh run watch ${{ github.run_id }}
|
||||
|
||||
- name: Read Changelog to variable
|
||||
id: read_changelog
|
||||
uses: juliangruber/read-file-action@v1
|
||||
with:
|
||||
path: ./changelog_notag.md
|
||||
|
||||
- name: Cache MaaDeps
|
||||
id: cache-maadeps
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
./MaaDeps
|
||||
key: ${{ runner.os }}-${{ matrix.arch }}-maadeps-${{ hashFiles('tools/maadeps-download.py') }}
|
||||
|
||||
- name: Bootstrap MaaDeps
|
||||
if: steps.cache-maadeps.outputs.cache-hit != 'true'
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
python3 tools/maadeps-download.py ${{ matrix.arch }}-windows
|
||||
|
||||
- name: Config cmake
|
||||
run: |
|
||||
mkdir -p build
|
||||
cmake -B build ${{ matrix.arch == 'arm64' && '-A ARM64' }} -DCMAKE_BUILD_TYPE=Release -DMAADEPS_TRIPLET='maa-${{ matrix.arch }}-windows' -DINSTALL_RESOURCE=ON -DINSTALL_PYTHON=ON -DMAA_HASH_VERSION='${{ steps.set_tag.outputs.tag }}' -DBUILD_WPF_GUI=OFF
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
cmake --build build --config Release --parallel $env:NUMBER_OF_PROCESSORS
|
||||
|
||||
- name: Install
|
||||
run: |
|
||||
mkdir -p install
|
||||
cmake --install build --prefix install --config Release
|
||||
|
||||
- name: Cache .nuke/temp, ~/.nuget/packages
|
||||
id: cache-nuget
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
.nuke/temp
|
||||
~/.nuget/packages
|
||||
key: ${{ runner.os }}-${{ matrix.arch }}-nuget-${{ hashFiles('**/*.csproj') }}
|
||||
|
||||
- name: Restore dependencies
|
||||
if: steps.cache-nuget.outputs.cache-hit != 'true'
|
||||
run: dotnet restore src/MaaWpfGui/MaaWpfGui.csproj
|
||||
|
||||
- name: Taggify Version for csproj
|
||||
run: |
|
||||
$csprojPath = "src/MaaWpfGui/MaaWpfGui.csproj"
|
||||
$csprojPath = Resolve-Path -Path $csprojPath
|
||||
$tag = '${{ steps.set_tag.outputs.tag }}' -replace '.*?/', ''
|
||||
if ($tag -match '\d+(\.\d+){1,3}') {
|
||||
$match = $Matches[0]
|
||||
} else {
|
||||
$match = "0.0.1"
|
||||
}
|
||||
[xml]$csproj = Get-Content -Path $csprojPath
|
||||
$node = $csproj.Project.PropertyGroup | where {$_.ApplicationVersion -ne $null}
|
||||
$node.InformationalVersion = $tag
|
||||
$node.Version = $match
|
||||
$node.FileVersion = $match
|
||||
$node.AssemblyVersion = $match
|
||||
$csproj.Save($csprojPath)
|
||||
|
||||
- name: Publish WPF GUI
|
||||
run: |
|
||||
dotnet publish src/MaaWpfGui/MaaWpfGui.csproj -c Release -o install
|
||||
|
||||
- name: Organize Install Files
|
||||
shell: bash
|
||||
run: |
|
||||
rm -rf install/*.pdb
|
||||
rm -rf install/msvc-debug
|
||||
rm -rf install/*.h
|
||||
|
||||
cp tools/DependencySetup_依赖库安装.bat install
|
||||
|
||||
- name: Upload MAA to Github
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: MAA-win-${{ matrix.arch }}
|
||||
path: install
|
||||
|
||||
- name: Push tag to main repo
|
||||
id: push_main_tag
|
||||
run: |
|
||||
@@ -256,13 +89,70 @@ jobs:
|
||||
git push --tags origin HEAD:refs/tags/$main_tag_name -f
|
||||
echo "main_tag_name=$main_tag_name" >> $env:GITHUB_OUTPUT
|
||||
|
||||
- name: Cache .nuke/temp, ~/.nuget/packages
|
||||
id: cache-nuget
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
.nuke/temp
|
||||
~/.nuget/packages
|
||||
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj') }}
|
||||
|
||||
- name: Restore dependencies
|
||||
if: steps.cache-nuget.outputs.cache-hit != 'true'
|
||||
run: dotnet restore
|
||||
|
||||
- name: Bootstrap MaaDeps
|
||||
run: |
|
||||
python3 maadeps-download.py ${{ matrix.lowercase_target }}-windows
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Taggify Version
|
||||
run: |
|
||||
$csprojPath = "src/MaaWpfGui/MaaWpfGui.csproj"
|
||||
$csprojPath = Resolve-Path -Path $csprojPath
|
||||
$tag = '${{ steps.set_tag.outputs.tag }}' -replace '.*?/', ''
|
||||
if ($tag -match '\d+(\.\d+){1,3}') {
|
||||
$match = $Matches[0]
|
||||
} else {
|
||||
$match = "0.0.1"
|
||||
}
|
||||
echo "Tag value: $tag"
|
||||
echo "Version value: $match"
|
||||
[xml]$csproj = Get-Content -Path $csprojPath
|
||||
$node = $csproj.Project.PropertyGroup | where {$_.ApplicationVersion -ne $null}
|
||||
$node.InformationalVersion = $tag
|
||||
$node.Version = $match
|
||||
$node.FileVersion = $match
|
||||
$node.AssemblyVersion = $match
|
||||
$csproj.Save($csprojPath)
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Run './build.cmd DevBuild'
|
||||
run: |
|
||||
$env:GITHUB_WORKFLOW = 'dev-build-win' # pretend this is a dev-build-win workflow
|
||||
$env:MAA_BUILDER_MAA_VERSION = "${{ steps.set_tag.outputs.tag }}"
|
||||
echo "tag: " $env:MAA_BUILDER_MAA_VERSION
|
||||
|
||||
./build.cmd DevBuild
|
||||
env:
|
||||
Reason: "Build nightly version"
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Upload MAA to Github
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: MAA-win-${{ matrix.lowercase_target }}
|
||||
path: artifacts
|
||||
|
||||
push-tag:
|
||||
if: github.repository_owner == 'MaaAssistantArknights'
|
||||
needs: build-win-nightly
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Fetch MaaRelease
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: ${{ format('{0}/{1}', github.repository_owner, 'MaaRelease') }}
|
||||
fetch-depth: 0
|
||||
@@ -280,7 +170,6 @@ jobs:
|
||||
git push --tags origin HEAD:refs/tags/${{ needs.build-win-nightly.outputs.tag }}
|
||||
|
||||
make-ota:
|
||||
if: github.repository_owner == 'MaaAssistantArknights'
|
||||
needs: [build-win-nightly, push-tag]
|
||||
strategy:
|
||||
matrix:
|
||||
@@ -292,14 +181,14 @@ jobs:
|
||||
echo ${{ needs.build-win-nightly.outputs.tag }}
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: MaaAssistantArknights
|
||||
token: ${{ secrets.MAARELEASE_RELEASE }}
|
||||
show-progress: false
|
||||
|
||||
- name: Download MAA from Github
|
||||
uses: actions/download-artifact@v5
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: MAA-win-${{ matrix.target }}
|
||||
path: ${{ format('{0}/{1}', 'build-ota', needs.build-win-nightly.outputs.tag) }}
|
||||
@@ -308,17 +197,8 @@ jobs:
|
||||
run: |
|
||||
mkdir -pv build-ota && cd build-ota
|
||||
|
||||
# Convert inputs to integers
|
||||
limit_maa=${{ inputs.limit_maa || 10 }}
|
||||
limit_maa=${limit_maa%.*}
|
||||
echo "Parsed limit_maa: $limit_maa"
|
||||
|
||||
limit_maarelease=${{ inputs.limit_maarelease || 10 }}
|
||||
limit_maarelease=${limit_maarelease%.*}
|
||||
echo "Parsed limit_maarelease: $limit_maarelease"
|
||||
|
||||
gh release list --repo 'MaaAssistantArknights/MaaAssistantArknights' --limit $limit_maa | tee ./release_maa.txt
|
||||
gh release list --repo "${{ github.repository_owner }}/MaaRelease" --limit $limit_maarelease | tee ./release_mr.txt
|
||||
gh release list --repo 'MaaAssistantArknights/MaaAssistantArknights' --limit ${{ inputs.limit || 30 }} | tee ./release_maa.txt
|
||||
gh release list --repo "${{ github.repository_owner }}/MaaRelease" --limit ${{ inputs.limit_2 || 30 }} | tee ./release_mr.txt
|
||||
echo ${{ needs.build-win-nightly.outputs.tag }} > ./config
|
||||
|
||||
cat ./release_maa.txt | awk '{ print $1 }' > ./tags_maa.txt
|
||||
@@ -338,7 +218,8 @@ jobs:
|
||||
cd build-ota
|
||||
|
||||
pushd ${{ needs.build-win-nightly.outputs.tag }}
|
||||
zip -r MAA-${{ env.release_tag }}-win-${{ matrix.target }}.zip ./*
|
||||
zip -d *.zip '*.lib' '*.pdb' '*.exp' '*.config' '*.xml'
|
||||
mv *.zip MAA-${{ env.release_tag }}-win-${{ matrix.target }}.zip
|
||||
popd
|
||||
|
||||
$GITHUB_WORKSPACE/MaaAssistantArknights/tools/OTAPacker/build.sh 'MaaAssistantArknights/MaaAssistantArknights' ./config ${{ matrix.target }} "${{ github.repository_owner }}/MaaRelease"
|
||||
@@ -346,6 +227,22 @@ jobs:
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Make release body
|
||||
id: make_release_body
|
||||
shell: bash
|
||||
run: |
|
||||
pre_version=${{ needs.build-win-nightly.outputs.pre_version }}
|
||||
cur_version=${{ needs.build-win-nightly.outputs.main_tag_name }}
|
||||
echo -e "${{ inputs.release_body || '' }}\n\n**Full Changelog**: [$pre_version -> $cur_version](https://github.com/$GITHUB_REPOSITORY/compare/$pre_version...$cur_version)" > alpha_changelog.md
|
||||
export r=$(cat alpha_changelog.md)
|
||||
|
||||
# https://github.com/svenstaro/upload-release-action
|
||||
r="${r//'%'/'%25'}" # Multiline escape sequences for %
|
||||
r="${r//$'\n'/'%0A'}" # Multiline escape sequences for '\n'
|
||||
r="${r//$'\r'/'%0D'}" # Multiline escape sequences for '\r'
|
||||
echo $r
|
||||
echo "full_release_body=$r" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Upload to MaaRelease
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
with:
|
||||
@@ -356,17 +253,10 @@ jobs:
|
||||
tag: ${{ env.release_tag }}
|
||||
prerelease: true
|
||||
overwrite: true
|
||||
body: |
|
||||
${{ inputs.release_body || '' }}
|
||||
|
||||
${{ needs.build-win-nightly.outputs.changelog }}
|
||||
|
||||
**Full Changelog**: [${{ needs.build-win-nightly.outputs.pre_version }} -> ${{ needs.build-win-nightly.outputs.main_tag_name }}](https://github.com/${{ github.repository }}/compare/${{ needs.build-win-nightly.outputs.pre_version }}...${{ needs.build-win-nightly.outputs.main_tag_name }})
|
||||
body: ${{ steps.make_release_body.outputs.full_release_body }}
|
||||
|
||||
- name: Setup release mirror
|
||||
run: |
|
||||
gh workflow --repo MaaAssistantArknights/MaaRelease run release-mirrors.yml
|
||||
gh workflow --repo MaaAssistantArknights/MaaRelease run mirrorchyan_alpha.yml
|
||||
gh workflow --repo MaaAssistantArknights/MaaRelease run mirrorchyan_alpha_release_note.yml
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.MISTEOWORKFLOW }}
|
||||
|
||||
100
.github/workflows/release-ota.yml
vendored
100
.github/workflows/release-ota.yml
vendored
@@ -25,9 +25,8 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Fetch MaaRelease
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
show-progress: false
|
||||
repository: ${{ format('{0}/{1}', github.repository_owner, 'MaaRelease') }}
|
||||
path: MaaRelease
|
||||
fetch-depth: 0
|
||||
@@ -37,18 +36,8 @@ jobs:
|
||||
id: fetchReleaseInfo
|
||||
run: |
|
||||
mkdir -pv build-ota && cd build-ota
|
||||
|
||||
# Convert inputs to integers
|
||||
limit=${{ inputs.limit || 31 }}
|
||||
limit=${limit%.*}
|
||||
echo "Parsed limit: $limit"
|
||||
|
||||
limit_2=${{ inputs.limit_2 || 30 }}
|
||||
limit_2=${limit_2%.*}
|
||||
echo "Parsed limit_2: $limit_2"
|
||||
|
||||
gh release list --repo 'MaaAssistantArknights/MaaAssistantArknights' --limit $limit | tee ./release_maa.txt
|
||||
gh release list --repo "MaaAssistantArknights/MaaRelease" --limit $limit_2 | tee ./release_mr.txt
|
||||
gh release list --repo 'MaaAssistantArknights/MaaAssistantArknights' --limit ${{ inputs.limit || 31 }} | tee ./release_maa.txt
|
||||
gh release list --repo "MaaAssistantArknights/MaaRelease" --limit ${{ inputs.limit_2 || 30 }} | tee ./release_mr.txt
|
||||
head -n 1 ./release_maa.txt | awk '{ print $1 }' > ./config
|
||||
|
||||
tail -n +1 ./release_maa.txt | awk '{ print $1 }' > ./tags_maa.txt
|
||||
@@ -94,24 +83,19 @@ jobs:
|
||||
- x64
|
||||
steps:
|
||||
- name: Download release config
|
||||
uses: actions/download-artifact@v5
|
||||
with:
|
||||
name: MaaReleaseConfig
|
||||
path: ./MaaReleaseConfig
|
||||
uses: actions/download-artifact@v4
|
||||
|
||||
- name: Fetch MaaRelease
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
show-progress: false
|
||||
repository: ${{ format('{0}/{1}', github.repository_owner, 'MaaRelease') }}
|
||||
path: MaaRelease
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.MAARELEASE_RELEASE }}
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
show-progress: false
|
||||
path: MaaAssistantArknights
|
||||
|
||||
- name: Download latest version for server
|
||||
@@ -137,18 +121,9 @@ jobs:
|
||||
prerelease: ${{ fromJSON(needs.create-tag.outputs.prerelease) }}
|
||||
overwrite: true
|
||||
|
||||
- name: Create issue if failed
|
||||
if: failure()
|
||||
uses: actions-cool/issues-helper@v3
|
||||
with:
|
||||
actions: "create-issue"
|
||||
title: "Failed make release OTA for Windows"
|
||||
body: |
|
||||
${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
||||
|
||||
make-ota-mac:
|
||||
needs: create-tag
|
||||
runs-on: macos-14
|
||||
runs-on: macos-13
|
||||
steps:
|
||||
- name: Fetch release info
|
||||
run: gh release list --repo 'MaaAssistantArknights/MaaAssistantArknights' --limit ${{ inputs.limit || 31 }} | tee ./release_maa.txt
|
||||
@@ -178,6 +153,31 @@ jobs:
|
||||
run: |
|
||||
find ./packages -type f ! \( -name 'MAA-${{ needs.create-tag.outputs.release_tag }}-macos-universal.dmg' -o -name '*.delta' -o -name '*.xml' \) -print -delete
|
||||
|
||||
- name: Unpack the .dmg files for .dylib
|
||||
run: |
|
||||
cd ${{ runner.temp }}
|
||||
mkdir -p macos-runtime-temp
|
||||
echo ::group::Attaching release package...
|
||||
hdiutil attach ${{ github.workspace }}/packages/MAA-${{ needs.create-tag.outputs.release_tag }}-macos-universal.dmg
|
||||
echo ::endgroup::
|
||||
echo ::group::Copying files...
|
||||
cp -v /Volumes/MAA/MAA.app/Contents/Frameworks/*.dylib macos-runtime-temp/
|
||||
cp -vr /Volumes/MAA/MAA.app/Contents/Resources/resource macos-runtime-temp/resource
|
||||
echo ::endgroup::
|
||||
echo ::group::Linking files...
|
||||
libonnxruntime_file=$(basename macos-runtime-temp/libonnxruntime*.dylib)
|
||||
ln -vs $libonnxruntime_file macos-runtime-temp/libonnxruntime.dylib
|
||||
libopencv_world_file=$(basename macos-runtime-temp/libopencv_world*.dylib)
|
||||
ln -vs $libopencv_world_file macos-runtime-temp/libopencv_world4.dylib
|
||||
echo ::endgroup::
|
||||
cd macos-runtime-temp
|
||||
echo ::group::Compressing files...
|
||||
zip -yrX9 ${{ github.workspace }}/packages/MAA-${{ needs.create-tag.outputs.release_tag }}-macos-runtime-universal.zip *
|
||||
echo ::endgroup::
|
||||
echo ::group::Detaching release package...
|
||||
hdiutil detach /Volumes/MAA
|
||||
echo ::endgroup::
|
||||
|
||||
- name: Upload to MaaRelease
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
with:
|
||||
@@ -189,15 +189,6 @@ jobs:
|
||||
prerelease: ${{ fromJSON(needs.create-tag.outputs.prerelease) }}
|
||||
overwrite: true
|
||||
|
||||
- name: Create issue if failed
|
||||
if: failure()
|
||||
uses: actions-cool/issues-helper@v3
|
||||
with:
|
||||
actions: "create-issue"
|
||||
title: "Failed make release OTA for macos"
|
||||
body: |
|
||||
${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
||||
|
||||
release:
|
||||
needs:
|
||||
- make-ota
|
||||
@@ -209,3 +200,30 @@ jobs:
|
||||
- name: Setup release mirror
|
||||
run: |
|
||||
gh workflow --repo MaaAssistantArknights/MaaRelease run release-mirrors.yml
|
||||
|
||||
- name: Deploy docs
|
||||
run: |
|
||||
mkdir -p ${{ runner.temp }}/new
|
||||
mkdir -p ${{ runner.temp }}/old
|
||||
gh api /repos/MaaAssistantArknights/MaaAssistantArknights/tags --jq '.[].name' > ${{ runner.temp }}/release_maa.txt
|
||||
export NEW_VERSION=$(sed -n '1p' ${{ runner.temp }}/release_maa.txt)
|
||||
echo "NEW_VERSION: $NEW_VERSION"
|
||||
export OLD_VERSION=$(sed -n '2p' ${{ runner.temp }}/release_maa.txt)
|
||||
echo "OLD_VERSION: $OLD_VERSION"
|
||||
gh api "/repos/MaaAssistantArknights/MaaAssistantArknights/tarball/$NEW_VERSION" > ${{ runner.temp }}/new.tar.gz
|
||||
gh api "/repos/MaaAssistantArknights/MaaAssistantArknights/tarball/$OLD_VERSION" > ${{ runner.temp }}/old.tar.gz
|
||||
tar -xzf ${{ runner.temp }}/new.tar.gz -C ${{ runner.temp }}/new
|
||||
tar -xzf ${{ runner.temp }}/old.tar.gz -C ${{ runner.temp }}/old
|
||||
export NEW_PATH="${{ runner.temp }}/new/$(ls ${{ runner.temp }}/new)/docs"
|
||||
echo "NEW_PATH: $NEW_PATH"
|
||||
export OLD_PATH="${{ runner.temp }}/old/$(ls ${{ runner.temp }}/old)/docs"
|
||||
echo "OLD_PATH: $OLD_PATH"
|
||||
export DOCS_DIFF=$(diff -aqr $NEW_PATH $OLD_PATH)
|
||||
if [ -n "$DOCS_DIFF" ]; then
|
||||
echo "Found changes, start to deploy the docs:"
|
||||
echo "$DOCS_DIFF"
|
||||
gh workflow --repo MaaAssistantArknights/maa-website run build-and-deploy.yaml
|
||||
echo "Deploying the docs."
|
||||
else
|
||||
echo "Nothing changed, exit."
|
||||
fi
|
||||
|
||||
404
.github/workflows/res-update-game.yml
vendored
404
.github/workflows/res-update-game.yml
vendored
@@ -1,8 +1,8 @@
|
||||
name: Resource Updater
|
||||
name: res-update-game
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "*/20 * * * *" # Runs every 20 minutes
|
||||
- cron: "*/20 * * * *"
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
commit_message:
|
||||
@@ -11,18 +11,38 @@ on:
|
||||
required: false
|
||||
|
||||
jobs:
|
||||
clone-resources-official:
|
||||
update-game-resources:
|
||||
if: github.repository_owner == 'MaaAssistantArknights'
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: windows-latest
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.MISTEOWORKFLOW }}
|
||||
steps:
|
||||
- name: Checkout MAA
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
show-progress: false
|
||||
token: ${{ secrets.MISTEOWORKFLOW }}
|
||||
|
||||
- name: Bootstrap MaaDeps
|
||||
run: |
|
||||
python3 maadeps-download.py x64-windows
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Add msbuild to PATH
|
||||
uses: microsoft/setup-msbuild@v1
|
||||
|
||||
- name: Build Resource Updater
|
||||
run: |
|
||||
MSBUILD tools/ResourceUpdater/ResourceUpdater.vcxproj /t:rebuild /p:Configuration="Release" /p:Platform="x64" /p:BuildProjectReferences=false /m
|
||||
|
||||
- name: Clone ArknightsGameResource for Official
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
show-progress: false
|
||||
repository: yuanyan3060/ArknightsGameResource
|
||||
ref: main
|
||||
path: ./Official
|
||||
sparse-checkout-cone-mode: false
|
||||
path: .\tools\ResourceUpdater\x64\Release\Official
|
||||
sparse-checkout: |
|
||||
/levels.json
|
||||
/item
|
||||
@@ -34,319 +54,135 @@ jobs:
|
||||
/gamedata/excel/gacha_table.json
|
||||
/gamedata/excel/roguelike_topic_table.json
|
||||
/gamedata/excel/activity_table.json
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- name: Upload Official
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: official
|
||||
path: ./Official
|
||||
compression-level: 0
|
||||
|
||||
clone-resources-overseas:
|
||||
if: github.repository_owner == 'MaaAssistantArknights'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Clone ArknightsGameResource_Yostar for Overseas
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
show-progress: false
|
||||
repository: ArknightsAssets/ArknightsGamedata
|
||||
ref: master
|
||||
path: ./Overseas
|
||||
sparse-checkout-cone-mode: false
|
||||
repository: Kengxxiao/ArknightsGameData_YoStar
|
||||
ref: main
|
||||
path: .\tools\ResourceUpdater\x64\Release\Overseas
|
||||
sparse-checkout: |
|
||||
/en/gamedata/excel/item_table.json
|
||||
/en/gamedata/excel/building_data.json
|
||||
/en/gamedata/excel/range_table.json
|
||||
/en/gamedata/excel/character_table.json
|
||||
/en/gamedata/excel/gacha_table.json
|
||||
/en/gamedata/excel/roguelike_topic_table.json
|
||||
/en/gamedata/excel/activity_table.json
|
||||
/jp/gamedata/excel/item_table.json
|
||||
/jp/gamedata/excel/building_data.json
|
||||
/jp/gamedata/excel/range_table.json
|
||||
/jp/gamedata/excel/character_table.json
|
||||
/jp/gamedata/excel/gacha_table.json
|
||||
/jp/gamedata/excel/roguelike_topic_table.json
|
||||
/jp/gamedata/excel/activity_table.json
|
||||
/kr/gamedata/excel/item_table.json
|
||||
/kr/gamedata/excel/building_data.json
|
||||
/kr/gamedata/excel/range_table.json
|
||||
/kr/gamedata/excel/character_table.json
|
||||
/kr/gamedata/excel/gacha_table.json
|
||||
/kr/gamedata/excel/roguelike_topic_table.json
|
||||
/kr/gamedata/excel/activity_table.json
|
||||
/en_US/gamedata/excel/item_table.json
|
||||
/en_US/gamedata/excel/building_data.json
|
||||
/en_US/gamedata/excel/range_table.json
|
||||
/en_US/gamedata/excel/character_table.json
|
||||
/en_US/gamedata/excel/gacha_table.json
|
||||
/en_US/gamedata/excel/roguelike_topic_table.json
|
||||
/en_US/gamedata/excel/activity_table.json
|
||||
/ja_JP/gamedata/excel/item_table.json
|
||||
/ja_JP/gamedata/excel/building_data.json
|
||||
/ja_JP/gamedata/excel/range_table.json
|
||||
/ja_JP/gamedata/excel/character_table.json
|
||||
/ja_JP/gamedata/excel/gacha_table.json
|
||||
/ja_JP/gamedata/excel/roguelike_topic_table.json
|
||||
/ja_JP/gamedata/excel/activity_table.json
|
||||
/ko_KR/gamedata/excel/item_table.json
|
||||
/ko_KR/gamedata/excel/building_data.json
|
||||
/ko_KR/gamedata/excel/range_table.json
|
||||
/ko_KR/gamedata/excel/character_table.json
|
||||
/ko_KR/gamedata/excel/gacha_table.json
|
||||
/ko_KR/gamedata/excel/roguelike_topic_table.json
|
||||
/ko_KR/gamedata/excel/activity_table.json
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- name: Upload Official
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: overseas
|
||||
path: ./Overseas
|
||||
compression-level: 0
|
||||
|
||||
clone-resources-txwy:
|
||||
if: github.repository_owner == 'MaaAssistantArknights'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Clone arknights-toolbox-update for Taiwan
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
show-progress: false
|
||||
repository: arkntools/arknights-toolbox-update
|
||||
ref: data-tw
|
||||
path: ./excel
|
||||
path: .\tools\ResourceUpdater\x64\Release\Overseas\zh_TW\gamedata\excel
|
||||
token: ${{ secrets.ARKNTOOLS_MAA_RESOURCE_UPDATER}}
|
||||
|
||||
- name: Download stages.json from Penguin Stats
|
||||
run: |
|
||||
cd "./excel"
|
||||
|
||||
baseUrl="https://penguin-stats.io/PenguinStats/api/v2/stages?server="
|
||||
|
||||
parameters=("CN" "US" "JP" "KR")
|
||||
|
||||
for param in "${parameters[@]}"; do
|
||||
{
|
||||
if curl -s -o "stages_${param}.json" "${baseUrl}${param}"; then
|
||||
echo "Successfully fetched data for ${param}"
|
||||
else
|
||||
echo "Failed to fetch data for ${param}" >&2
|
||||
exit 1
|
||||
fi
|
||||
} &
|
||||
done
|
||||
wait
|
||||
|
||||
- name: Upload Official
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: txwy
|
||||
path: ./excel
|
||||
compression-level: 0
|
||||
|
||||
update-game-resources:
|
||||
# In case of rate limitations on the runners/instances, add dependency, by removing the comment
|
||||
|
||||
# needs: [clone-resources-official, clone-resources-overseas, clone-resources-txwy]
|
||||
if: github.repository_owner == 'MaaAssistantArknights'
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- name: Checkout MAA
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
# TL;DR https://github.com/MaaAssistantArknights/MaaAssistantArknights/issues/9872#issuecomment-2251378371
|
||||
# actions/checkout uses ${{ secrets.GITHUB_TOKEN }} by default, meaning all steps will inherit it
|
||||
persist-credentials: false # Needed to bypass protection rules in Push changes
|
||||
show-progress: false
|
||||
fetch-depth: 3
|
||||
|
||||
- name: Restore ResourceUpdater from cache
|
||||
id: resupd-cache
|
||||
uses: actions/cache/restore@v4
|
||||
with:
|
||||
key: ResourceUpdater-${{ runner.os }}-${{ hashFiles('tools/ResourceUpdater/main.cpp') }}
|
||||
path: |
|
||||
./tools/ResourceUpdater/libopencv_world4.4.11.0.dylib
|
||||
./tools/ResourceUpdater/res_updater
|
||||
|
||||
- name: Cache MaaDeps
|
||||
if: steps.resupd-cache.outputs.cache-hit != 'true'
|
||||
id: maadeps-cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
./MaaDeps
|
||||
key: ${{ runner.os }}-arm64-maadeps-${{ hashFiles('tools/maadeps-download.py') }}
|
||||
|
||||
- name: Bootstrap MaaDeps
|
||||
if: steps.resupd-cache.outputs.cache-hit != 'true' && steps.maadeps-cache.outputs.cache-hit != 'true'
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
python3 tools/maadeps-download.py arm64-osx
|
||||
|
||||
- name: Config cmake
|
||||
if: steps.resupd-cache.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
cd tools/ResourceUpdater
|
||||
mkdir -p build
|
||||
cmake -B build -GNinja \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DMAADEPS_TRIPLET='maa-arm64-osx' \
|
||||
-DWITH_HASH_VERSION=ON
|
||||
|
||||
- name: Build
|
||||
if: steps.resupd-cache.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
cmake --build tools/ResourceUpdater/build --config Release --parallel $(sysctl -n hw.logicalcpu)
|
||||
|
||||
- name: Install
|
||||
if: steps.resupd-cache.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
cmake --install tools/ResourceUpdater/build --prefix tools/ResourceUpdater --config Release
|
||||
|
||||
- name: Save ResourceUpdater to cache
|
||||
if: always() && steps.resupd-cache.outputs.cache-hit != 'true'
|
||||
uses: actions/cache/save@v4
|
||||
with:
|
||||
key: ResourceUpdater-${{ runner.os }}-${{ hashFiles('tools/ResourceUpdater/main.cpp') }}
|
||||
path: |
|
||||
./tools/ResourceUpdater/libopencv_world4.4.11.0.dylib
|
||||
./tools/ResourceUpdater/res_updater
|
||||
|
||||
- name: Download txwy
|
||||
id: download-txwy
|
||||
uses: actions/download-artifact@v5
|
||||
continue-on-error: true
|
||||
with:
|
||||
name: txwy
|
||||
path: ./tools/ResourceUpdater/Overseas/tw/gamedata/excel
|
||||
|
||||
- name: Delay txwy
|
||||
if: steps.download-txwy.outcome == 'failure'
|
||||
run: |
|
||||
sleep 10
|
||||
|
||||
- name: Re-download txwy
|
||||
if: steps.download-txwy.outcome == 'failure'
|
||||
uses: actions/download-artifact@v5
|
||||
with:
|
||||
name: txwy
|
||||
path: ./tools/ResourceUpdater/Overseas/tw/gamedata/excel
|
||||
|
||||
- name: Download Overseas
|
||||
id: download-overseas
|
||||
uses: actions/download-artifact@v5
|
||||
continue-on-error: true
|
||||
with:
|
||||
name: overseas
|
||||
path: ./tools/ResourceUpdater/Overseas
|
||||
|
||||
- name: Delay Overseas
|
||||
if: steps.download-overseas.outcome == 'failure'
|
||||
run: |
|
||||
sleep 10
|
||||
|
||||
- name: Re-download Overseas
|
||||
if: steps.download-overseas.outcome == 'failure'
|
||||
uses: actions/download-artifact@v5
|
||||
with:
|
||||
name: overseas
|
||||
path: ./tools/ResourceUpdater/Overseas
|
||||
|
||||
- name: Download Official
|
||||
id: download-official
|
||||
uses: actions/download-artifact@v5
|
||||
continue-on-error: true
|
||||
with:
|
||||
name: official
|
||||
path: ./tools/ResourceUpdater/Official
|
||||
|
||||
- name: Delay Official
|
||||
if: steps.download-official.outcome == 'failure'
|
||||
run: |
|
||||
sleep 10
|
||||
|
||||
- name: Re-download Official
|
||||
if: steps.download-official.outcome == 'failure'
|
||||
uses: actions/download-artifact@v5
|
||||
with:
|
||||
name: official
|
||||
path: ./tools/ResourceUpdater/Official
|
||||
|
||||
- name: Run Resource Updater
|
||||
run: |
|
||||
./tools/ResourceUpdater/res_updater
|
||||
.\tools\ResourceUpdater\x64\Release\ResourceUpdater.exe
|
||||
|
||||
- name: Task Sorting
|
||||
id: task_sorting
|
||||
- name: Overseas Tasks Ordering
|
||||
run: |
|
||||
python3 tools/TaskSorter/TaskSorter.py
|
||||
echo "gitdiff=$(echo $(git diff --name-only --diff-filter=ACM 2>/dev/null | grep '\.json$'))" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Run prettier
|
||||
uses: Nerixyz/actionsx-prettier@v3-adj
|
||||
with:
|
||||
args: -w ${{ steps.task_sorting.outputs.gitdiff }}
|
||||
|
||||
- name: Update version.json date if necessary
|
||||
id: update_version
|
||||
- name: Check if only sorted
|
||||
id: check_only_sorted
|
||||
run: |
|
||||
./tools/ResourceUpdater/version.zsh
|
||||
git status
|
||||
|
||||
- name: Setup python
|
||||
if: steps.update_version.outputs.contains_png == 'True'
|
||||
uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: "3.11"
|
||||
$diff = $(git diff --numstat HEAD | findstr -i resource)
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
echo "no diff"
|
||||
exit 0
|
||||
}
|
||||
|
||||
- name: Cache Python packages
|
||||
if: always() && steps.update_version.outputs.contains_png == 'True'
|
||||
id: cache_python
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ${{ env.pythonLocation }}/Lib/site-packages
|
||||
key: ${{ runner.os }}-pip-optimize-templates-${{ hashFiles('./tools/OptimizeTemplates/requirements.txt') }}
|
||||
echo "diff: "$diff
|
||||
$sp = $($diff -split "\s+")
|
||||
$numbers = $($sp | Where-Object { $_ -match "^\d+$" })
|
||||
echo "numbers: "$numbers
|
||||
|
||||
- name: Install dependencies
|
||||
if: steps.cache_python.outputs.cache-hit != 'true' && steps.update_version.outputs.contains_png == 'True'
|
||||
run: |
|
||||
pip install -r tools/OptimizeTemplates/requirements.txt
|
||||
$length = $numbers.Length
|
||||
$isAllEqual = $true
|
||||
for ($i = 0; $i -lt $length; $i += 2) {
|
||||
$firstNumber = $numbers[$i]
|
||||
$secondNumber = $numbers[$i+1]
|
||||
|
||||
- name: Setup oxipng
|
||||
if: steps.update_version.outputs.contains_png == 'True'
|
||||
uses: baptiste0928/cargo-install@v3
|
||||
with:
|
||||
crate: oxipng
|
||||
if ($firstNumber -gt 1) {
|
||||
$isAllEqual = $false
|
||||
break
|
||||
}
|
||||
|
||||
if ($firstNumber -ne $secondNumber) {
|
||||
$isAllEqual = $false
|
||||
break
|
||||
}
|
||||
}
|
||||
echo "isAllEqual: "$isAllEqual
|
||||
echo "only_sorted=$isAllEqual" >> $env:GITHUB_OUTPUT
|
||||
|
||||
- name: Run optimize_templates
|
||||
if: steps.update_version.outputs.contains_png == 'True'
|
||||
run: |
|
||||
python3 tools/OptimizeTemplates/optimize_templates.py -p resource/template/items/ resource/template/infrast/
|
||||
- name: Cancelling
|
||||
if: steps.check_only_sorted.outputs.only_sorted == 'True'
|
||||
uses: andymckay/cancel-action@0.3
|
||||
|
||||
- name: Add files to git
|
||||
if: steps.update_version.outputs.changes == 'True'
|
||||
if: steps.check_only_sorted.outputs.only_sorted != 'True'
|
||||
id: add_files
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
git status
|
||||
|
||||
git config user.name "$env:GITHUB_ACTOR"
|
||||
git config user.email "$env:GITHUB_ACTOR@users.noreply.github.com"
|
||||
git add .
|
||||
|
||||
commit_msg="${{ github.event.inputs.commit_message }}"
|
||||
if [ -z "$commit_msg" ]; then
|
||||
commit_msg="chore: Auto Update Game Resources - $(date '+%Y-%m-%d')"
|
||||
else
|
||||
commit_msg=$(echo "$commit_msg" | xargs) # Trim whitespace
|
||||
fi
|
||||
$commit_msg = "${{ github.event.inputs.commit_message }}"
|
||||
if (-not [string]::IsNullOrWhiteSpace($commit_msg)) {
|
||||
$commit_msg = $commit_msg.Trim()
|
||||
} else {
|
||||
$commit_msg = "chore: Auto Update Game Resources - $(Get-Date -Format 'yyyy-MM-dd')"
|
||||
}
|
||||
git commit -m "$commit_msg" -m "[skip changelog]"
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
echo "have_commits=True" >> $env:GITHUB_OUTPUT
|
||||
}
|
||||
|
||||
run_url="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
|
||||
git pull origin $(git rev-parse --abbrev-ref HEAD) --unshallow --rebase
|
||||
|
||||
git commit -m "$commit_msg" -m "$run_url" -m "[skip changelog]"
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "have_commits=True" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
- name: Cancelling
|
||||
if: steps.add_files.outputs.have_commits != 'True'
|
||||
uses: andymckay/cancel-action@0.3
|
||||
|
||||
git pull origin ${{ github.ref_name }} --rebase
|
||||
|
||||
- name: Push changes
|
||||
- name: Push changes # push the output folder to your repo
|
||||
if: steps.add_files.outputs.have_commits == 'True'
|
||||
uses: ad-m/github-push-action@master
|
||||
with:
|
||||
branch: ${{ github.ref }}
|
||||
github_token: ${{ secrets.MAA_RESOURCE_SYNC }}
|
||||
github_token: ${{ secrets.MISTEOWORKFLOW }}
|
||||
|
||||
# - name: Update OTA resource
|
||||
# if: steps.update_version.outputs.update_resources == 'True'
|
||||
# env:
|
||||
# GH_TOKEN: ${{ secrets.MISTEOWORKFLOW }}
|
||||
# run: |
|
||||
# gh workflow --repo MaaAssistantArknights/MaaRelease run update-resource.yml
|
||||
- name: Update OTA resource
|
||||
run: |
|
||||
gh workflow --repo MaaAssistantArknights/MaaRelease run update-resource.yml
|
||||
|
||||
- name: Add cancelled status
|
||||
if: steps.update_version.outputs.changes != 'True' || steps.add_files.outputs.have_commits != 'True'
|
||||
uses: andymckay/cancel-action@0.5
|
||||
|
||||
# - name: Release # ref: https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow
|
||||
# if: steps.add_files.outputs.have_commits == 'True'
|
||||
# run: |
|
||||
# gh workflow run release-nightly-ota -f release_body="Auto Release of Resource Updates"
|
||||
# - name: Release # ref: https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow
|
||||
# if: steps.add_files.outputs.have_commits == 'True'
|
||||
# run: |
|
||||
# gh workflow run release-nightly-ota -f release_body="Auto Release of Resource Updates"
|
||||
# env:
|
||||
# GH_TOKEN: ${{ github.token }}
|
||||
|
||||
127
.github/workflows/smoke-testing.yml
vendored
127
.github/workflows/smoke-testing.yml
vendored
@@ -1,128 +1,77 @@
|
||||
name: smoke-testing
|
||||
name: test
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- ".github/workflows/smoke-testing.yml"
|
||||
- "3rdparty/include/**"
|
||||
- "include/**"
|
||||
- "src/Cpp/**"
|
||||
- "src/MaaCore/**"
|
||||
- "resource/**"
|
||||
- "!**/*.md"
|
||||
- "src/**"
|
||||
- "cmake/**"
|
||||
- "CMakeLists.txt"
|
||||
- "tools/maadeps-download.py"
|
||||
- "MAA.sln"
|
||||
- "resource/**"
|
||||
- "MaaDeps/**"
|
||||
- "!**/*.md"
|
||||
pull_request:
|
||||
paths:
|
||||
- ".github/workflows/smoke-testing.yml"
|
||||
- "3rdparty/include/**"
|
||||
- "include/**"
|
||||
- "src/Cpp/**"
|
||||
- "src/MaaCore/**"
|
||||
- "resource/**"
|
||||
- "!**/*.md"
|
||||
- "src/**"
|
||||
- "cmake/**"
|
||||
- "CMakeLists.txt"
|
||||
- "tools/maadeps-download.py"
|
||||
- "MAA.sln"
|
||||
- "resource/**"
|
||||
- "MaaDeps/**"
|
||||
- "!**/*.md"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
smoke-testing:
|
||||
# Prevent duplicate runs on organization branches with PRs
|
||||
if: github.event_name != 'pull_request' ||
|
||||
github.event.pull_request.head.repo.full_name !=
|
||||
github.event.pull_request.base.repo.full_name
|
||||
runs-on: macos-latest
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
show-progress: false
|
||||
|
||||
- name: Generate cache key
|
||||
id: cache_key
|
||||
run: |
|
||||
echo "key=Smoke-testing-${{ hashFiles('src/Cpp/**', 'src/MaaCore/**', '3rdparty/include/**', 'include/**', 'cmake/**', 'CMakeLists.txt', 'tools/maadeps-download.py', 'tools/linux-toolchain-download.py') }}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Restore cache smoke-testing
|
||||
id: smoke-cache
|
||||
uses: actions/cache/restore@v4
|
||||
with:
|
||||
key: ${{ steps.cache_key.outputs.key }}
|
||||
path: |
|
||||
./install/libfastdeploy_ppocr.dylib
|
||||
./install/libMaaCore.dylib
|
||||
./install/libonnxruntime.1.19.2.dylib
|
||||
./install/libopencv_world4.4.11.0.dylib
|
||||
./install/smoke_test
|
||||
|
||||
- name: Fetch submodules
|
||||
if: steps.smoke-cache.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
git submodule update --init --depth 1 3rdparty/EmulatorExtras
|
||||
|
||||
- name: Cache MaaDeps
|
||||
if: steps.smoke-cache.outputs.cache-hit != 'true'
|
||||
id: maadeps-cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ./MaaDeps
|
||||
key: ${{ runner.os }}-arm64-maadeps-${{ hashFiles('tools/maadeps-download.py') }}
|
||||
|
||||
|
||||
- name: Restore dependencies
|
||||
run: dotnet restore
|
||||
|
||||
- name: Bootstrap MaaDeps
|
||||
if: steps.smoke-cache.outputs.cache-hit != 'true' && steps.maadeps-cache.outputs.cache-hit != 'true'
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
python3 tools/maadeps-download.py arm64-osx
|
||||
python3 maadeps-download.py x64-windows
|
||||
|
||||
- name: Config cmake
|
||||
if: steps.smoke-cache.outputs.cache-hit != 'true'
|
||||
- name: Add msbuild to PATH
|
||||
uses: microsoft/setup-msbuild@v1
|
||||
- name: Build MaaSample
|
||||
run: |
|
||||
mkdir -p build
|
||||
cmake -B build -GNinja \
|
||||
-DCMAKE_BUILD_TYPE=Debug \
|
||||
-DMAADEPS_TRIPLET='maa-arm64-osx' \
|
||||
-DBUILD_SMOKE_TEST=ON \
|
||||
-DINSTALL_RESOURCE=ON \
|
||||
-DWITH_HASH_VERSION=ON
|
||||
MSBUILD src/Cpp/MaaSample.slnf /t:rebuild /p:Configuration="Debug" /p:Platform="x64" /m
|
||||
|
||||
- name: Build
|
||||
if: steps.smoke-cache.outputs.cache-hit != 'true'
|
||||
- name: Run tests - Official #用来判断是不是国服资源出错导致外服全炸
|
||||
run: |
|
||||
cmake --build build --config Debug --parallel $(sysctl -n hw.logicalcpu)
|
||||
.\x64\Debug\Sample.exe
|
||||
|
||||
- name: Install
|
||||
if: steps.smoke-cache.outputs.cache-hit != 'true'
|
||||
- name: Run tests - YoStarJP
|
||||
run: |
|
||||
mkdir -p install
|
||||
cmake --install build --prefix install --config Debug
|
||||
|
||||
- name: Make link for cache smoke-testing
|
||||
if: steps.smoke-cache.outputs.cache-hit == 'true'
|
||||
.\x64\Debug\Sample.exe YoStarJP
|
||||
|
||||
- name: Run tests - YoStarEN
|
||||
run: |
|
||||
ln -s "$(pwd)/resource" install/resource
|
||||
|
||||
- name: Run tests
|
||||
.\x64\Debug\Sample.exe YoStarEN
|
||||
|
||||
- name: Run tests - YoStarKR
|
||||
run: |
|
||||
./tools/SmokeTesting/run_tests.zsh
|
||||
|
||||
- name: Save cache smoke-testing (only in dev)
|
||||
if: steps.smoke-cache.outputs.cache-hit != 'true' && github.ref == 'refs/heads/dev'
|
||||
uses: actions/cache/save@v4
|
||||
with:
|
||||
key: ${{ steps.cache_key.outputs.key }}
|
||||
path: |
|
||||
./install/libfastdeploy_ppocr.dylib
|
||||
./install/libMaaCore.dylib
|
||||
./install/libonnxruntime.1.19.2.dylib
|
||||
./install/libopencv_world4.4.11.0.dylib
|
||||
./install/smoke_test
|
||||
.\x64\Debug\Sample.exe YoStarKR
|
||||
|
||||
- name: Run tests - txwy
|
||||
run: |
|
||||
.\x64\Debug\Sample.exe txwy
|
||||
|
||||
- name: Upload logs
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: logs
|
||||
path: ./install/debug
|
||||
name: log
|
||||
path: .\x64\Debug\debug
|
||||
|
||||
39
.github/workflows/stale.yml
vendored
39
.github/workflows/stale.yml
vendored
@@ -1,39 +0,0 @@
|
||||
name: "Inactive Issues Closer"
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 0 * * *" # Runs daily at UTC 00:00
|
||||
workflow_dispatch: # Allows manual triggering
|
||||
|
||||
env: # config
|
||||
daysBeforeStale: 90 # Number of days of inactivity before marking as stale
|
||||
daysBeforeClose: 7 # Number of days to wait after marking as stale before closing
|
||||
|
||||
jobs:
|
||||
stale:
|
||||
if: github.repository_owner == 'MaaAssistantArknights'
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: write # Workaround for https://github.com/actions/stale/issues/1090
|
||||
issues: write
|
||||
# Completely disable stalling for PRs
|
||||
pull-requests: none
|
||||
contents: none
|
||||
steps:
|
||||
- name: Close inactive issues
|
||||
uses: actions/stale@v10
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
days-before-stale: ${{ env.daysBeforeStale }}
|
||||
days-before-close: ${{ env.daysBeforeClose }}
|
||||
stale-issue-label: "stale"
|
||||
stale-issue-message: |
|
||||
This issue has been inactive for a prolonged period and will be closed automatically in ${{ env.daysBeforeClose }} days.
|
||||
该问题已长时间处于闲置状态,${{ env.daysBeforeClose }} 天后将自动关闭。
|
||||
exempt-issue-labels: "keep-open, MAA Team, enhancement"
|
||||
days-before-pr-stale: -1 # Completely disable stalling for PRs
|
||||
days-before-pr-close: -1 # Completely disable closing for PRs
|
||||
|
||||
# Temporary to reduce the huge issues number
|
||||
operations-per-run: 100
|
||||
debug-only: false
|
||||
19
.github/workflows/sync-resource.yml
vendored
19
.github/workflows/sync-resource.yml
vendored
@@ -1,33 +1,32 @@
|
||||
name: sync-resource
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
paths:
|
||||
- "resource/**"
|
||||
- ".github/workflows/sync-resource.yml"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
sync-resource:
|
||||
if: github.repository_owner == 'MaaAssistantArknights'
|
||||
sync-reource:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout MaaAssistantArknights
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
show-progress: false
|
||||
|
||||
- name: Setup Git
|
||||
run: |
|
||||
git config --global user.name 'github-actions[bot]'
|
||||
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
|
||||
git config --global user.name "$GITHUB_ACTOR"
|
||||
git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com"
|
||||
git show -s
|
||||
|
||||
- name: Checkout MaaResource
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: MaaAssistantArknights/MaaResource
|
||||
show-progress: false
|
||||
@@ -49,3 +48,9 @@ jobs:
|
||||
git status
|
||||
git commit -m "$commit_msg" || exit 0
|
||||
git push
|
||||
|
||||
- name: Setup resource update
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.MISTEOWORKFLOW }}
|
||||
run: |
|
||||
gh workflow --repo MaaAssistantArknights/MaaRelease run update-resource.yml
|
||||
|
||||
72
.github/workflows/website-workflow.yml
vendored
72
.github/workflows/website-workflow.yml
vendored
@@ -1,72 +0,0 @@
|
||||
name: MaaWebsite Workflow
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- "master"
|
||||
- "dev"
|
||||
paths:
|
||||
- ".github/workflows/website-workflow.yml"
|
||||
- "docs/**"
|
||||
pull_request:
|
||||
paths:
|
||||
- ".github/workflows/website-workflow.yml"
|
||||
- "docs/**"
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
deploy-to-prod:
|
||||
description: "Deploy to prod"
|
||||
default: false
|
||||
required: true
|
||||
type: boolean
|
||||
|
||||
concurrency:
|
||||
group: "pages"
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 20
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
show-progress: false
|
||||
|
||||
- name: Setup Pages
|
||||
uses: actions/configure-pages@v5
|
||||
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 10
|
||||
run_install: false
|
||||
|
||||
- name: Setup Node.js environment
|
||||
uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: 24
|
||||
cache: pnpm
|
||||
cache-dependency-path: "./docs/pnpm-lock.yaml"
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
working-directory: "./docs"
|
||||
|
||||
- name: Build documentation
|
||||
run: pnpm run build
|
||||
working-directory: "./docs"
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-pages-artifact@v3
|
||||
with:
|
||||
path: "./docs/.vuepress/dist"
|
||||
|
||||
- name: Deploy to GitHub Pages
|
||||
uses: peaceiris/actions-gh-pages@v4
|
||||
if: ${{ inputs.deploy-to-prod == true || github.ref == 'refs/heads/master' }}
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
publish_dir: "./docs/.vuepress/dist"
|
||||
publish_branch: gh-pages
|
||||
30
.gitignore
vendored
30
.gitignore
vendored
@@ -437,9 +437,6 @@ tools/**/*.png
|
||||
.vscode
|
||||
enc_temp_folder/*
|
||||
|
||||
# RoguelikeRecruitmentTool 导出的 Excel 文件
|
||||
tools/RoguelikeRecruitmentTool/output
|
||||
|
||||
# Nuke
|
||||
.nuke/temp/*
|
||||
|
||||
@@ -451,30 +448,3 @@ tools/RoguelikeRecruitmentTool/output
|
||||
# CF 活动关卡(异格夜刀),手动改的地图
|
||||
/resource/Arknights-Tile-Pos/act24side_09-activities-act24side-level_act24side_09.json
|
||||
/src/MaaWpfGui/FodyWeavers.xml
|
||||
*.lnk
|
||||
|
||||
# 链接检查缓存
|
||||
.lycheecache
|
||||
|
||||
# MaaDeps
|
||||
/MaaDeps/*
|
||||
|
||||
# ResourceUpdater workflow
|
||||
/original/*
|
||||
|
||||
# Windows Explorer Shits
|
||||
desktop.ini
|
||||
Thumbs.db
|
||||
|
||||
# macOS Finder Shit
|
||||
.DS_Store
|
||||
|
||||
# MaaSupportExtension config
|
||||
/config/maa_pi_config.json
|
||||
|
||||
# build & install
|
||||
build
|
||||
install
|
||||
|
||||
# pnpm cache
|
||||
.pnpm-store
|
||||
|
||||
8
.gitmodules
vendored
8
.gitmodules
vendored
@@ -4,9 +4,11 @@
|
||||
[submodule "src/MaaMacGui"]
|
||||
path = src/MaaMacGui
|
||||
url = https://github.com/MaaAssistantArknights/MaaMacGui.git
|
||||
[submodule "MaaDeps"]
|
||||
path = MaaDeps
|
||||
url = https://github.com/MaaAssistantArknights/MaaDeps
|
||||
shallow = true
|
||||
branch = master
|
||||
[submodule "src/maa-cli"]
|
||||
path = src/maa-cli
|
||||
url = https://github.com/MaaAssistantArknights/maa-cli.git
|
||||
[submodule "3rdparty/EmulatorExtras"]
|
||||
path = 3rdparty/EmulatorExtras
|
||||
url = https://github.com/MaaXYZ/EmulatorExtras.git
|
||||
|
||||
132
.nuke/build.schema.json
Normal file
132
.nuke/build.schema.json
Normal file
@@ -0,0 +1,132 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"title": "Build Schema",
|
||||
"$ref": "#/definitions/build",
|
||||
"definitions": {
|
||||
"build": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"Continue": {
|
||||
"type": "boolean",
|
||||
"description": "Indicates to continue a previously failed build attempt"
|
||||
},
|
||||
"Help": {
|
||||
"type": "boolean",
|
||||
"description": "Shows the help text for this build assembly"
|
||||
},
|
||||
"Host": {
|
||||
"type": "string",
|
||||
"description": "Host for execution. Default is 'automatic'",
|
||||
"enum": [
|
||||
"AppVeyor",
|
||||
"AzurePipelines",
|
||||
"Bamboo",
|
||||
"Bitbucket",
|
||||
"Bitrise",
|
||||
"GitHubActions",
|
||||
"GitLab",
|
||||
"Jenkins",
|
||||
"Rider",
|
||||
"SpaceAutomation",
|
||||
"TeamCity",
|
||||
"Terminal",
|
||||
"TravisCI",
|
||||
"VisualStudio",
|
||||
"VSCode"
|
||||
]
|
||||
},
|
||||
"NoLogo": {
|
||||
"type": "boolean",
|
||||
"description": "Disables displaying the NUKE logo"
|
||||
},
|
||||
"Partition": {
|
||||
"type": "string",
|
||||
"description": "Partition to use on CI"
|
||||
},
|
||||
"Plan": {
|
||||
"type": "boolean",
|
||||
"description": "Shows the execution plan (HTML)"
|
||||
},
|
||||
"Profile": {
|
||||
"type": "array",
|
||||
"description": "Defines the profiles to load",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"Root": {
|
||||
"type": "string",
|
||||
"description": "Root directory during build execution"
|
||||
},
|
||||
"Skip": {
|
||||
"type": "array",
|
||||
"description": "List of targets to be skipped. Empty list skips all dependencies",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Default",
|
||||
"DevBuild",
|
||||
"DevBuildDefault",
|
||||
"DevBuildReleaseSimulation",
|
||||
"ReleaseMaa",
|
||||
"SetMaaChangeLog",
|
||||
"SetPackageBundled",
|
||||
"SetVersion",
|
||||
"UseClean",
|
||||
"UseCommitVersion",
|
||||
"UseMaaChangeLog",
|
||||
"UseMaaDevBundle",
|
||||
"UseMaaRelease",
|
||||
"UsePublishArtifact",
|
||||
"UsePublishRelease",
|
||||
"UseRsVersion",
|
||||
"UseTagVersion",
|
||||
"WithCompileCoreRelease",
|
||||
"WithCompileWpfRelease",
|
||||
"WithSyncRes"
|
||||
]
|
||||
}
|
||||
},
|
||||
"Target": {
|
||||
"type": "array",
|
||||
"description": "List of targets to be invoked. Default is '{default_target}'",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Default",
|
||||
"DevBuild",
|
||||
"DevBuildDefault",
|
||||
"DevBuildReleaseSimulation",
|
||||
"ReleaseMaa",
|
||||
"SetMaaChangeLog",
|
||||
"SetPackageBundled",
|
||||
"SetVersion",
|
||||
"UseClean",
|
||||
"UseCommitVersion",
|
||||
"UseMaaChangeLog",
|
||||
"UseMaaDevBundle",
|
||||
"UseMaaRelease",
|
||||
"UsePublishArtifact",
|
||||
"UsePublishRelease",
|
||||
"UseRsVersion",
|
||||
"UseTagVersion",
|
||||
"WithCompileCoreRelease",
|
||||
"WithCompileWpfRelease",
|
||||
"WithSyncRes"
|
||||
]
|
||||
}
|
||||
},
|
||||
"Verbosity": {
|
||||
"type": "string",
|
||||
"description": "Logging verbosity during build execution. Default is 'Normal'",
|
||||
"enum": [
|
||||
"Minimal",
|
||||
"Normal",
|
||||
"Quiet",
|
||||
"Verbose"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
4
.nuke/parameters.json
Normal file
4
.nuke/parameters.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"$schema": "./build.schema.json",
|
||||
"Solution": "tools/MaaBuilder.sln"
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
default_install_hook_types: [pre-commit, prepare-commit-msg]
|
||||
ci:
|
||||
autofix_commit_msg: "chore: Auto update by pre-commit hooks [skip changelog]"
|
||||
autofix_prs: true
|
||||
repos:
|
||||
- repo: https://github.com/shssoichiro/oxipng
|
||||
rev: v9.1.4
|
||||
hooks:
|
||||
- id: oxipng
|
||||
args: ["-q", "-o", "2", "-s", "--ng"]
|
||||
- repo: https://github.com/pre-commit/mirrors-clang-format
|
||||
rev: v20.1.0
|
||||
hooks:
|
||||
- id: clang-format
|
||||
files: ^src/MaaCore/.*
|
||||
args: ["--assume-filename", ".clang-format"]
|
||||
- repo: https://github.com/rbubley/mirrors-prettier
|
||||
rev: v3.5.3
|
||||
hooks:
|
||||
- id: prettier
|
||||
name: prettier (config files)
|
||||
files: ^((\.github/ISSUE_TEMPLATE|resource|src|tools)/.*|\.pre-commit-config\.yaml|package-definition\.json)
|
||||
types_or:
|
||||
- yaml
|
||||
- json
|
||||
- repo: https://github.com/rbubley/mirrors-prettier
|
||||
rev: v3.5.3
|
||||
hooks:
|
||||
- id: prettier
|
||||
name: prettier (docs)
|
||||
files: ^docs/.*
|
||||
- repo: https://github.com/DavidAnson/markdownlint-cli2
|
||||
rev: v0.17.2
|
||||
hooks:
|
||||
- id: markdownlint-cli2
|
||||
files: ^docs/.*|^README\.md$
|
||||
types:
|
||||
- markdown
|
||||
args: ["--fix", "--config", "docs/.markdownlint.yaml", "#**/node_modules"]
|
||||
@@ -1,18 +0,0 @@
|
||||
**/node_modules/
|
||||
**/pnpm-lock.yaml
|
||||
docs/**/*.md
|
||||
|
||||
MaaDeps/
|
||||
3rdparty/
|
||||
src/maa-cli
|
||||
src/MaaMacGui
|
||||
|
||||
# website/
|
||||
# docs/
|
||||
|
||||
resource/Arknights-Tile-Pos/
|
||||
tools/OptimizeTemplates/optimize_templates.json
|
||||
|
||||
CITATION.cff
|
||||
CHANGELOG.md
|
||||
## FUCK FUCK
|
||||
23
.prettierrc
23
.prettierrc
@@ -1,23 +0,0 @@
|
||||
{
|
||||
"tabWidth": 4,
|
||||
"printWidth": 120,
|
||||
"useTabs": false,
|
||||
"bracketSameLine": true,
|
||||
"bracketSpacing": true,
|
||||
"endOfLine": "auto",
|
||||
"overrides": [
|
||||
{
|
||||
"files": [".clang-format", "**/*.yml", "**/*.yaml"],
|
||||
"options": {
|
||||
"parser": "yaml",
|
||||
"tabWidth": 2
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": ["**/*.md"],
|
||||
"options": {
|
||||
"tabWidth": 2
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
6
.vscode/settings.json
vendored
6
.vscode/settings.json
vendored
@@ -2,8 +2,7 @@
|
||||
"json.schemas": [
|
||||
{
|
||||
"fileMatch": [
|
||||
"resource/tasks/**/*.json",
|
||||
"resource/global/**/resource/tasks/**/*.json",
|
||||
"resource/tasks.json"
|
||||
],
|
||||
"url": "./docs/maa_tasks_schema.json"
|
||||
}
|
||||
@@ -12,8 +11,5 @@
|
||||
"MaaDeps/vcpkg/buildtrees": true,
|
||||
"MaaDeps/vcpkg/packages": true
|
||||
},
|
||||
"files.associations": {
|
||||
"**/resource/tasks/**/*.json": "jsonc"
|
||||
},
|
||||
"C_Cpp.exclusionPolicy": "checkFilesAndFolders"
|
||||
}
|
||||
|
||||
1
3rdparty/EmulatorExtras
vendored
1
3rdparty/EmulatorExtras
vendored
Submodule 3rdparty/EmulatorExtras deleted from 54d3a3ad44
172
3rdparty/include/Arknights-Tile-Pos/TileCalc.hpp
vendored
Normal file
172
3rdparty/include/Arknights-Tile-Pos/TileCalc.hpp
vendored
Normal file
@@ -0,0 +1,172 @@
|
||||
#pragma once
|
||||
|
||||
#include <cmath>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <meojson/json.hpp>
|
||||
#include <opencv2/core.hpp>
|
||||
|
||||
#include "TileDef.hpp"
|
||||
|
||||
namespace Map
|
||||
{
|
||||
struct Tile
|
||||
{
|
||||
int heightType = 0;
|
||||
int buildableType = 0;
|
||||
std::string tileKey;
|
||||
};
|
||||
|
||||
class Level
|
||||
{
|
||||
public:
|
||||
Level(const json::value& data);
|
||||
int get_width() const { return width; }
|
||||
int get_height() const { return height; }
|
||||
Tile get_item(int y, int x) const { return tiles[y][x]; }
|
||||
std::vector<cv::Point3d> view;
|
||||
LevelKey key;
|
||||
|
||||
private:
|
||||
int height = 0;
|
||||
int width = 0;
|
||||
std::vector<std::vector<Tile>> tiles;
|
||||
};
|
||||
|
||||
class TileCalc
|
||||
{
|
||||
public:
|
||||
TileCalc(int width, int height);
|
||||
|
||||
bool run(const Level& level, bool side, std::vector<std::vector<cv::Point2d>>& out_pos,
|
||||
std::vector<std::vector<Tile>>& out_tiles, double shift_x = 0, double shift_y = 0) const;
|
||||
|
||||
private:
|
||||
bool adapter(double& x, double& y) const;
|
||||
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
const double degree = atan(1.0) * 4 / 180;
|
||||
std::vector<Level> levels;
|
||||
cv::Mat MatrixP = cv::Mat(4, 4, CV_64F);
|
||||
cv::Mat MatrixX = cv::Mat(4, 4, CV_64F);
|
||||
cv::Mat MatrixY = cv::Mat(4, 4, CV_64F);
|
||||
};
|
||||
|
||||
inline void InitMat4x4(cv::Mat& m, double (*num)[4])
|
||||
{
|
||||
for (int i = 0; i < m.rows; i++)
|
||||
for (int j = 0; j < m.cols; j++)
|
||||
m.at<double>(i, j) = num[i][j];
|
||||
}
|
||||
|
||||
inline Level::Level(const json::value& data)
|
||||
{
|
||||
key.stageId = data.at("stageId").as_string();
|
||||
key.code = data.at("code").as_string();
|
||||
key.levelId = data.at("levelId").as_string();
|
||||
key.name = data.get("name", "null");
|
||||
this->height = data.at("height").as_integer();
|
||||
this->width = data.at("width").as_integer();
|
||||
for (const json::value& point_data : data.at("view").as_array()) {
|
||||
cv::Point3d tmp;
|
||||
auto point_array = point_data.as_array();
|
||||
tmp.x = point_array[0].as_double();
|
||||
tmp.y = point_array[1].as_double();
|
||||
tmp.z = point_array[2].as_double();
|
||||
this->view.emplace_back(std::move(tmp));
|
||||
}
|
||||
for (const json::value& row : data.at("tiles").as_array()) {
|
||||
std::vector<Tile> tmp;
|
||||
tmp.reserve(this->width);
|
||||
for (const json::value& tile : row.as_array()) {
|
||||
tmp.emplace_back(Tile { tile.at("heightType").as_integer(), tile.at("buildableType").as_integer(),
|
||||
tile.get("tileKey", std::string()) });
|
||||
}
|
||||
tiles.emplace_back(std::move(tmp));
|
||||
}
|
||||
}
|
||||
|
||||
inline TileCalc::TileCalc(int width, int height)
|
||||
{
|
||||
this->width = width;
|
||||
this->height = height;
|
||||
double ratio = static_cast<double>(height) / width;
|
||||
double matrixP[4][4] { { ratio / tan(20 * degree), 0, 0, 0 },
|
||||
{ 0, 1 / tan(20 * degree), 0, 0 },
|
||||
{ 0, 0, -(1000 + 0.3) / (1000 - 0.3), -(1000 * 0.3 * 2) / (1000 - 0.3) },
|
||||
{ 0, 0, -1, 0 } };
|
||||
InitMat4x4(this->MatrixP, matrixP);
|
||||
double matrixX[4][4] { { 1, 0, 0, 0 },
|
||||
{ 0, cos(30 * degree), -sin(30 * degree), 0 },
|
||||
{ 0, -sin(30 * degree), -cos(30 * degree), 0 },
|
||||
{ 0, 0, 0, 1 } };
|
||||
InitMat4x4(this->MatrixX, matrixX);
|
||||
double matrixY[4][4] { { cos(10 * degree), 0, sin(10 * degree), 0 },
|
||||
{ 0, 1, 0, 0 },
|
||||
{ -sin(10 * degree), 0, cos(10 * degree), 0 },
|
||||
{ 0, 0, 0, 1 } };
|
||||
InitMat4x4(this->MatrixY, matrixY);
|
||||
}
|
||||
|
||||
inline bool TileCalc::run(const Level& level, bool side, std::vector<std::vector<cv::Point2d>>& out_pos,
|
||||
std::vector<std::vector<Tile>>& out_tiles, double shift_x, double shift_y) const
|
||||
{
|
||||
auto [x, y, z] = level.view[side ? 1 : 0];
|
||||
double adapter_y = 0, adapter_z = 0;
|
||||
this->adapter(adapter_y, adapter_z);
|
||||
double matrix[4][4] {
|
||||
{ 1, 0, 0, -x }, { 0, 1, 0, -y - adapter_y }, { 0, 0, 1, -z - adapter_z }, { 0, 0, 0, 1 }
|
||||
};
|
||||
auto raw = cv::Mat(cv::Size(4, 4), CV_64F);
|
||||
auto Finall_Matrix = cv::Mat(cv::Size(4, 4), CV_64F);
|
||||
InitMat4x4(raw, matrix);
|
||||
if (side) {
|
||||
Finall_Matrix = this->MatrixP * this->MatrixX * this->MatrixY * raw;
|
||||
}
|
||||
else {
|
||||
Finall_Matrix = this->MatrixP * this->MatrixX * raw;
|
||||
}
|
||||
int h = level.get_height();
|
||||
int w = level.get_width();
|
||||
auto map_point = cv::Mat(cv::Size(1, 4), CV_64F);
|
||||
map_point.at<double>(3, 0) = 1;
|
||||
auto tmp_pos = std::vector<cv::Point2d>(w);
|
||||
auto tmp_tiles = std::vector<Tile>(w);
|
||||
for (int i = 0; i < h; i++) {
|
||||
for (int j = 0; j < w; j++) {
|
||||
tmp_tiles[j] = level.get_item(i, j);
|
||||
map_point.at<double>(0, 0) = j - (w - 1) / 2.0 + shift_x;
|
||||
map_point.at<double>(1, 0) = (h - 1) / 2.0 - i + shift_y;
|
||||
map_point.at<double>(2, 0) = tmp_tiles[j].heightType * -0.4;
|
||||
cv::Mat view_point = Finall_Matrix * map_point;
|
||||
view_point = view_point / view_point.at<double>(3, 0);
|
||||
view_point = (view_point + 1) / 2;
|
||||
tmp_pos[j] = cv::Point2d(view_point.at<double>(0, 0) * this->width,
|
||||
(1 - view_point.at<double>(1, 0)) * this->height);
|
||||
}
|
||||
out_pos.emplace_back(tmp_pos);
|
||||
out_tiles.emplace_back(tmp_tiles);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool TileCalc::adapter(double& x, double& y) const
|
||||
{
|
||||
const double fromRatio = 9.0 / 16;
|
||||
const double toRatio = 3.0 / 4;
|
||||
double ratio = static_cast<double>(height) / width;
|
||||
if (ratio < fromRatio - 0.00001) {
|
||||
x = 0;
|
||||
y = 0;
|
||||
return false;
|
||||
}
|
||||
double t = (ratio - fromRatio) / (toRatio - fromRatio);
|
||||
x = -1.4 * t;
|
||||
y = -2.8 * t;
|
||||
return true;
|
||||
}
|
||||
} // namespace Map
|
||||
131
3rdparty/include/Arknights-Tile-Pos/TileCalc2.hpp
vendored
131
3rdparty/include/Arknights-Tile-Pos/TileCalc2.hpp
vendored
@@ -1,131 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <meojson/json.hpp>
|
||||
#include <numbers>
|
||||
#include <opencv2/core/matx.hpp>
|
||||
#include <opencv2/core/types.hpp>
|
||||
|
||||
#include "TileDef.hpp"
|
||||
|
||||
namespace Map::TileCalc2
|
||||
{
|
||||
using vec3d = cv::Vec3d;
|
||||
using matrix4x4 = cv::Matx44d;
|
||||
static constexpr double degree = std::numbers::pi / 180;
|
||||
|
||||
inline vec3d camera_pos(const Level& level, bool side = false, int width = 1280, int height = 720)
|
||||
{
|
||||
const auto [x, y, z] = level.view[side ? 1 : 0];
|
||||
|
||||
static constexpr double fromRatio = 9. / 16;
|
||||
static constexpr double toRatio = 3. / 4;
|
||||
const double ratio = static_cast<double>(height) / width;
|
||||
const double t = (fromRatio - ratio) / (fromRatio - toRatio);
|
||||
const vec3d pos_adj = { -1.4 * t, -2.8 * t, 0 };
|
||||
return { x + pos_adj[0], y + pos_adj[1], z + pos_adj[2] };
|
||||
}
|
||||
|
||||
inline vec3d camera_euler_angles_yxz(const Level& /*level*/, bool side = false)
|
||||
{
|
||||
if (side) {
|
||||
return { 10 * degree, 30 * degree, 0 };
|
||||
}
|
||||
|
||||
return { 0, 30 * degree, 0 };
|
||||
}
|
||||
|
||||
inline matrix4x4 camera_matrix_from_trans(
|
||||
const vec3d& pos,
|
||||
const vec3d& euler,
|
||||
double ratio,
|
||||
double fov_2_y = 20 * degree,
|
||||
double far_c = 1000,
|
||||
double near_c = 0.3)
|
||||
{
|
||||
const double cos_y = std::cos(euler[0]);
|
||||
const double sin_y = std::sin(euler[0]);
|
||||
const double cos_x = std::cos(euler[1]);
|
||||
const double sin_x = std::sin(euler[1]);
|
||||
const double tan_f = std::tan(fov_2_y);
|
||||
|
||||
const matrix4x4 translate = {
|
||||
1, 0, 0, -pos[0], //
|
||||
0, 1, 0, -pos[1], //
|
||||
0, 0, 1, -pos[2], //
|
||||
0, 0, 0, 1,
|
||||
};
|
||||
const matrix4x4 matrixY = {
|
||||
cos_y, 0, sin_y, 0, //
|
||||
0, 1, 0, 0, //
|
||||
-sin_y, 0, cos_y, 0, //
|
||||
0, 0, 0, 1,
|
||||
};
|
||||
const matrix4x4 matrixX = {
|
||||
1, 0, 0, 0, //
|
||||
0, cos_x, -sin_x, 0, //
|
||||
0, -sin_x, -cos_x, 0, //
|
||||
0, 0, 0, 1,
|
||||
};
|
||||
const matrix4x4 proj = matrix4x4 {
|
||||
// clang-format off
|
||||
ratio / tan_f, 0, 0, 0,
|
||||
0, 1 / tan_f, 0, 0,
|
||||
0, 0, -(far_c + near_c) / (far_c - near_c), -(far_c * near_c * 2) / (far_c - near_c),
|
||||
0, 0, -1, 0,
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
return proj * matrixX * matrixY * translate;
|
||||
}
|
||||
|
||||
inline cv::Point world_to_screen(const Level& level, const vec3d& world_pos, bool side, const vec3d& offset = {})
|
||||
{
|
||||
static constexpr int width = 1280;
|
||||
static constexpr int height = 720;
|
||||
const vec3d pos_cam = camera_pos(level, side, width, height) + offset;
|
||||
const vec3d euler = camera_euler_angles_yxz(level, side);
|
||||
const matrix4x4 matrix = camera_matrix_from_trans(pos_cam, euler, static_cast<double>(height) / width);
|
||||
auto result = matrix * cv::Point3d(world_pos);
|
||||
result = result / result(3);
|
||||
result = (result + cv::Vec4d::ones()) / 2.;
|
||||
return {
|
||||
static_cast<int>(std::round(result(0) * width)),
|
||||
static_cast<int>(std::round((1 - result(1)) * height)),
|
||||
};
|
||||
}
|
||||
|
||||
inline vec3d get_tile_world_pos(const Level& level, int tile_y, int tile_x)
|
||||
{
|
||||
const int h = level.get_height();
|
||||
const int w = level.get_width();
|
||||
const auto& tile = level.get_item(tile_y, tile_x);
|
||||
return {
|
||||
tile_x - (w - 1) / 2.,
|
||||
(h - 1) / 2. - tile_y,
|
||||
tile.heightType * -0.4,
|
||||
};
|
||||
}
|
||||
|
||||
inline auto get_tile_screen_pos(const Level& level, int tile_y, int tile_x, bool side = false, const vec3d& offset = {})
|
||||
{
|
||||
return world_to_screen(level, get_tile_world_pos(level, tile_y, tile_x), side, offset);
|
||||
}
|
||||
|
||||
static constexpr double rel_pos_x = 1.3143386840820312;
|
||||
static constexpr double rel_pos_y = 1.314337134361267;
|
||||
static constexpr double rel_pos_z = -0.3967874050140381;
|
||||
|
||||
inline auto get_retreat_screen_pos(const Level& level)
|
||||
{
|
||||
const vec3d relative_pos = { -rel_pos_x, +rel_pos_y, rel_pos_z };
|
||||
return world_to_screen(level, relative_pos, true);
|
||||
}
|
||||
|
||||
inline auto get_skill_screen_pos(const Level& level)
|
||||
{
|
||||
const vec3d relative_pos = { +rel_pos_x, -rel_pos_y, rel_pos_z };
|
||||
return world_to_screen(level, relative_pos, true);
|
||||
}
|
||||
|
||||
} // namespace Map::TileCalc2
|
||||
|
||||
104
3rdparty/include/Arknights-Tile-Pos/TileDef.hpp
vendored
104
3rdparty/include/Arknights-Tile-Pos/TileDef.hpp
vendored
@@ -1,94 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <meojson/json.hpp>
|
||||
#include <opencv2/core.hpp>
|
||||
|
||||
namespace Map
|
||||
{
|
||||
struct LevelKey
|
||||
{
|
||||
std::string stageId;
|
||||
std::string code;
|
||||
std::string levelId;
|
||||
std::string name;
|
||||
|
||||
bool empty_or_equal(const std::string& lhs, const std::string& rhs) const noexcept
|
||||
struct LevelKey
|
||||
{
|
||||
return (lhs.empty() || rhs.empty()) ? true : lhs == rhs;
|
||||
}
|
||||
std::string stageId;
|
||||
std::string code;
|
||||
std::string levelId;
|
||||
std::string name;
|
||||
|
||||
bool operator==(const LevelKey& other) const noexcept
|
||||
{
|
||||
return empty_or_equal(stageId, other.stageId) && empty_or_equal(code, other.code)
|
||||
&& empty_or_equal(levelId, other.levelId) && empty_or_equal(name, other.name);
|
||||
}
|
||||
|
||||
bool operator==(const std::string& any_key) const noexcept
|
||||
{
|
||||
if (any_key.empty()) {
|
||||
return false;
|
||||
bool empty_or_equal(const std::string& lhs, const std::string& rhs) const noexcept
|
||||
{
|
||||
return (lhs.empty() || rhs.empty()) ? true : lhs == rhs;
|
||||
}
|
||||
return empty_or_equal(stageId, any_key) || empty_or_equal(code, any_key)
|
||||
|| empty_or_equal(levelId, any_key) || empty_or_equal(name, any_key);
|
||||
}
|
||||
};
|
||||
|
||||
struct Tile
|
||||
{
|
||||
int heightType = 0;
|
||||
int buildableType = 0;
|
||||
std::string tileKey;
|
||||
};
|
||||
|
||||
class Level
|
||||
{
|
||||
public:
|
||||
explicit Level(const json::value& data);
|
||||
Level() = default;
|
||||
|
||||
int get_width() const { return width; }
|
||||
|
||||
int get_height() const { return height; }
|
||||
|
||||
Tile get_item(int y, int x) const { return tiles[y][x]; }
|
||||
|
||||
std::vector<cv::Point3d> view {};
|
||||
LevelKey key {};
|
||||
|
||||
private:
|
||||
int height = 0;
|
||||
int width = 0;
|
||||
std::vector<std::vector<Tile>> tiles;
|
||||
};
|
||||
|
||||
inline Level::Level(const json::value& data)
|
||||
{
|
||||
key.stageId = data.at("stageId").as_string();
|
||||
key.code = data.at("code").as_string();
|
||||
key.levelId = data.at("levelId").as_string();
|
||||
key.name = data.get("name", "null");
|
||||
this->height = data.at("height").as_integer();
|
||||
this->width = data.at("width").as_integer();
|
||||
for (const json::value& point_data : data.at("view").as_array()) {
|
||||
cv::Point3d tmp;
|
||||
auto point_array = point_data.as_array();
|
||||
tmp.x = point_array[0].as_double();
|
||||
tmp.y = point_array[1].as_double();
|
||||
tmp.z = point_array[2].as_double();
|
||||
this->view.emplace_back(tmp);
|
||||
}
|
||||
for (const json::value& row : data.at("tiles").as_array()) {
|
||||
std::vector<Tile> tmp;
|
||||
tmp.reserve(this->width);
|
||||
for (const json::value& tile : row.as_array()) {
|
||||
tmp.emplace_back(Tile { tile.at("heightType").as_integer(),
|
||||
tile.at("buildableType").as_integer(),
|
||||
tile.get("tileKey", std::string()) });
|
||||
bool operator==(const LevelKey& other) const noexcept
|
||||
{
|
||||
return empty_or_equal(stageId, other.stageId) && empty_or_equal(code, other.code) &&
|
||||
empty_or_equal(levelId, other.levelId) && empty_or_equal(name, other.name);
|
||||
}
|
||||
tiles.emplace_back(std::move(tmp));
|
||||
}
|
||||
bool operator==(const std::string& any_key) const noexcept
|
||||
{
|
||||
if (any_key.empty()) {
|
||||
return false;
|
||||
}
|
||||
return empty_or_equal(stageId, any_key) || empty_or_equal(code, any_key) ||
|
||||
empty_or_equal(levelId, any_key) || empty_or_equal(name, any_key);
|
||||
}
|
||||
};
|
||||
}
|
||||
} // namespace Map
|
||||
|
||||
195
3rdparty/include/meojson/.clang-format
vendored
Normal file
195
3rdparty/include/meojson/.clang-format
vendored
Normal file
@@ -0,0 +1,195 @@
|
||||
Language: Json
|
||||
ColumnLimit: 1000
|
||||
IndentWidth: 4
|
||||
---
|
||||
Language: Cpp
|
||||
AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignArrayOfStructures: None
|
||||
AlignConsecutiveMacros: None
|
||||
AlignConsecutiveAssignments: None
|
||||
AlignConsecutiveBitFields: None
|
||||
AlignConsecutiveDeclarations: None
|
||||
AlignEscapedNewlines: Left
|
||||
AlignOperands: Align
|
||||
AlignTrailingComments: true
|
||||
AllowAllArgumentsOnNextLine: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowShortEnumsOnASingleLine: false
|
||||
AllowShortBlocksOnASingleLine: Empty
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: Inline
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: WithoutElse
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: true
|
||||
AttributeMacros:
|
||||
- __capability
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: true
|
||||
AfterControlStatement: Never
|
||||
AfterEnum: true
|
||||
AfterFunction: true
|
||||
AfterNamespace: true
|
||||
AfterObjCDeclaration: true
|
||||
AfterStruct: true
|
||||
AfterUnion: false
|
||||
AfterExternBlock: true
|
||||
BeforeCatch: true
|
||||
BeforeElse: true
|
||||
BeforeLambdaBody: false
|
||||
BeforeWhile: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: false
|
||||
SplitEmptyRecord: false
|
||||
SplitEmptyNamespace: false
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeConceptDeclarations: true
|
||||
BreakBeforeBraces: Custom
|
||||
BreakBeforeInheritanceComma: false
|
||||
BreakInheritanceList: BeforeColon
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakStringLiterals: true
|
||||
ColumnLimit: 120
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
QualifierAlignment: Leave
|
||||
CompactNamespaces: false
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: false
|
||||
DeriveLineEnding: true
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
EmptyLineAfterAccessModifier: Never
|
||||
EmptyLineBeforeAccessModifier: LogicalBlock
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
PackConstructorInitializers: BinPack
|
||||
BasedOnStyle: ''
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||
AllowAllConstructorInitializersOnNextLine: true
|
||||
FixNamespaceComments: true
|
||||
ForEachMacros:
|
||||
- foreach
|
||||
- Q_FOREACH
|
||||
- BOOST_FOREACH
|
||||
IfMacros:
|
||||
- KJ_IF_MAYBE
|
||||
IncludeBlocks: Preserve
|
||||
IncludeCategories:
|
||||
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
|
||||
Priority: 2
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
|
||||
Priority: 3
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
- Regex: '.*'
|
||||
Priority: 1
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
IncludeIsMainRegex: '(Test)?$'
|
||||
IncludeIsMainSourceRegex: ''
|
||||
IndentAccessModifiers: false
|
||||
IndentCaseLabels: false
|
||||
IndentCaseBlocks: false
|
||||
IndentGotoLabels: true
|
||||
IndentPPDirectives: None
|
||||
IndentExternBlock: AfterExternBlock
|
||||
IndentRequiresClause: false
|
||||
IndentWidth: 4
|
||||
IndentWrappedFunctionNames: false
|
||||
InsertTrailingCommas: None
|
||||
JavaScriptQuotes: Leave
|
||||
JavaScriptWrapImports: true
|
||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
LambdaBodyIndentation: Signature
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: Inner
|
||||
ObjCBinPackProtocolList: Auto
|
||||
ObjCBlockIndentWidth: 2
|
||||
ObjCBreakBeforeNestedBlockParam: true
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PenaltyBreakAssignment: 2
|
||||
PenaltyBreakBeforeFirstCallParameter: 19
|
||||
PenaltyBreakComment: 300
|
||||
PenaltyBreakFirstLessLess: 120
|
||||
PenaltyBreakOpenParenthesis: 0
|
||||
PenaltyBreakString: 1000
|
||||
PenaltyBreakTemplateDeclaration: 10
|
||||
PenaltyExcessCharacter: 1000000
|
||||
PenaltyReturnTypeOnItsOwnLine: 1000
|
||||
PenaltyIndentedWhitespace: 0
|
||||
PointerAlignment: Left
|
||||
PPIndentWidth: -1
|
||||
ReferenceAlignment: Pointer
|
||||
ReflowComments: true
|
||||
RemoveBracesLLVM: false
|
||||
RequiresClausePosition: OwnLine
|
||||
SeparateDefinitionBlocks: Leave
|
||||
ShortNamespaceLines: 50
|
||||
SortIncludes: CaseSensitive
|
||||
SortJavaStaticImport: Before
|
||||
SortUsingDeclarations: true
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: true
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCaseColon: false
|
||||
SpaceBeforeCpp11BracedList: true
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeParensOptions:
|
||||
AfterControlStatements: true
|
||||
AfterForeachMacros: true
|
||||
AfterFunctionDefinitionName: false
|
||||
AfterFunctionDeclarationName: false
|
||||
AfterIfMacros: true
|
||||
AfterOverloadedOperator: false
|
||||
AfterRequiresInClause: true
|
||||
AfterRequiresInExpression: true
|
||||
BeforeNonEmptyParentheses: false
|
||||
SpaceAroundPointerQualifiers: Default
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceInEmptyBlock: false
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: Never
|
||||
SpacesInConditionalStatement: false
|
||||
SpacesInContainerLiterals: true
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInLineCommentPrefix:
|
||||
Minimum: 1
|
||||
Maximum: -1
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
SpaceBeforeSquareBrackets: false
|
||||
BitFieldColonSpacing: Both
|
||||
Standard: c++20
|
||||
StatementAttributeLikeMacros:
|
||||
- Q_EMIT
|
||||
StatementMacros:
|
||||
- Q_UNUSED
|
||||
- QT_REQUIRE_VERSION
|
||||
TabWidth: 4
|
||||
UseCRLF: false
|
||||
UseTab: Never
|
||||
WhitespaceSensitiveMacros:
|
||||
- STRINGIZE
|
||||
- PP_STRINGIZE
|
||||
- BOOST_PP_STRINGIZE
|
||||
- NS_SWIFT_NAME
|
||||
- CF_SWIFT_NAME
|
||||
@@ -1,17 +1,13 @@
|
||||
// IWYU pragma: private, include <meojson/json.hpp>
|
||||
|
||||
#pragma once
|
||||
|
||||
#if __cplusplus >= 202002L || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)
|
||||
#include <bit>
|
||||
|
||||
namespace json::_bitops
|
||||
{
|
||||
using std::countl_one;
|
||||
using std::countl_zero;
|
||||
using std::countr_one;
|
||||
using std::countr_zero;
|
||||
|
||||
inline constexpr bool is_little_endian()
|
||||
{
|
||||
return std::endian::native == std::endian::little;
|
||||
@@ -19,37 +15,25 @@ inline constexpr bool is_little_endian()
|
||||
}
|
||||
#else
|
||||
#include <cstdint>
|
||||
|
||||
namespace json::_bitops
|
||||
{
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
inline constexpr int countl_zero(uint32_t x)
|
||||
{
|
||||
if constexpr (sizeof(uint32_t) == sizeof(unsigned int)) {
|
||||
return x == 0 ? 32 : __builtin_clz(x);
|
||||
}
|
||||
if constexpr (sizeof(uint32_t) == sizeof(unsigned long)) {
|
||||
return x == 0 ? 32 : __builtin_clzl(x);
|
||||
}
|
||||
if constexpr (sizeof(uint32_t) == sizeof(unsigned int)) return x == 0 ? 32 : __builtin_clz(x);
|
||||
if constexpr (sizeof(uint32_t) == sizeof(unsigned long)) return x == 0 ? 32 : __builtin_clzl(x);
|
||||
return x == 0 ? 32 : __builtin_clzll(x);
|
||||
}
|
||||
|
||||
inline constexpr int countr_zero(uint32_t x)
|
||||
{
|
||||
if constexpr (sizeof(uint32_t) == sizeof(unsigned int)) {
|
||||
return x == 0 ? 32 : __builtin_ctz(x);
|
||||
}
|
||||
if constexpr (sizeof(uint32_t) == sizeof(unsigned long)) {
|
||||
return x == 0 ? 32 : __builtin_ctzl(x);
|
||||
}
|
||||
if constexpr (sizeof(uint32_t) == sizeof(unsigned int)) return x == 0 ? 32 : __builtin_ctz(x);
|
||||
if constexpr (sizeof(uint32_t) == sizeof(unsigned long)) return x == 0 ? 32 : __builtin_ctzl(x);
|
||||
return x == 0 ? 32 : __builtin_ctzll(x);
|
||||
}
|
||||
|
||||
inline constexpr int countl_zero(uint64_t x)
|
||||
{
|
||||
return x == 0 ? 64 : __builtin_clzll(x);
|
||||
}
|
||||
|
||||
inline constexpr int countr_zero(uint64_t x)
|
||||
{
|
||||
return x == 0 ? 64 : __builtin_ctzll(x);
|
||||
@@ -61,17 +45,14 @@ inline int countl_zero(uint32_t x)
|
||||
{
|
||||
return __lzcnt(x);
|
||||
}
|
||||
|
||||
inline int countr_zero(uint32_t x)
|
||||
{
|
||||
return _tzcnt_u32(x);
|
||||
}
|
||||
|
||||
inline int countl_zero(uint64_t x)
|
||||
{
|
||||
return (int)__lzcnt64(x);
|
||||
}
|
||||
|
||||
inline int countr_zero(uint64_t x)
|
||||
{
|
||||
return (int)_tzcnt_u64(x);
|
||||
@@ -82,19 +63,16 @@ inline constexpr int countl_zero(uint32_t x)
|
||||
unsigned long index = 0;
|
||||
return _BitScanReverse(&index, x) ? 31 - index : 32;
|
||||
}
|
||||
|
||||
inline constexpr int countr_zero(uint32_t x)
|
||||
{
|
||||
unsigned long index = 0;
|
||||
return _BitScanForward(&index, x) ? index : 32;
|
||||
}
|
||||
|
||||
inline constexpr int countl_zero(uint64_t x)
|
||||
{
|
||||
unsigned long index = 0;
|
||||
return _BitScanReverse64(&index, x) ? 63 - index : 64;
|
||||
}
|
||||
|
||||
inline constexpr int countr_zero(uint64_t x)
|
||||
{
|
||||
unsigned long index = 0;
|
||||
@@ -108,17 +86,14 @@ inline int countl_one(uint32_t x)
|
||||
{
|
||||
return countl_zero(~x);
|
||||
}
|
||||
|
||||
inline int countr_one(uint32_t x)
|
||||
{
|
||||
return countr_zero(~x);
|
||||
}
|
||||
|
||||
inline int countl_one(uint64_t x)
|
||||
{
|
||||
return countl_zero(~x);
|
||||
}
|
||||
|
||||
inline int countr_one(uint64_t x)
|
||||
{
|
||||
return countr_zero(~x);
|
||||
@@ -127,12 +102,10 @@ inline int countr_one(uint64_t x)
|
||||
// no constexpr endian awareness before C++20
|
||||
inline bool is_little_endian()
|
||||
{
|
||||
union
|
||||
{
|
||||
union {
|
||||
uint32_t u32;
|
||||
uint8_t u8;
|
||||
} u = { 0x01020304 };
|
||||
|
||||
return u.u8 == 4;
|
||||
}
|
||||
} // namespace json::_bitops
|
||||
688
3rdparty/include/meojson/common/array.hpp
vendored
688
3rdparty/include/meojson/common/array.hpp
vendored
@@ -1,688 +0,0 @@
|
||||
// IWYU pragma: private, include <meojson/json.hpp>
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <initializer_list>
|
||||
#include <optional>
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
#include "exception.hpp"
|
||||
#include "utils.hpp"
|
||||
|
||||
namespace json
|
||||
{
|
||||
template <typename string_t>
|
||||
class basic_array
|
||||
{
|
||||
friend class basic_value<string_t>;
|
||||
friend class basic_object<string_t>;
|
||||
|
||||
public:
|
||||
using raw_array = std::vector<basic_value<string_t>>;
|
||||
using value_type = typename raw_array::value_type;
|
||||
using iterator = typename raw_array::iterator;
|
||||
using const_iterator = typename raw_array::const_iterator;
|
||||
using reverse_iterator = typename raw_array::reverse_iterator;
|
||||
using const_reverse_iterator = typename raw_array::const_reverse_iterator;
|
||||
using char_t = typename string_t::value_type;
|
||||
|
||||
public:
|
||||
basic_array() = default;
|
||||
basic_array(const basic_array<string_t>& rhs) = default;
|
||||
basic_array(basic_array<string_t>&& rhs) noexcept = default;
|
||||
basic_array(std::initializer_list<value_type> init_list);
|
||||
basic_array(typename raw_array::size_type size);
|
||||
|
||||
// explicit basic_array(const basic_value<string_t>& val);
|
||||
// explicit basic_array(basic_value<string_t>&& val);
|
||||
|
||||
template <
|
||||
typename jsonization_t,
|
||||
std::enable_if_t<
|
||||
_utils::has_to_json_in_templ_spec<jsonization_t, string_t>::value
|
||||
&& !_utils::has_to_json_array_in_templ_spec<jsonization_t, string_t>::value,
|
||||
bool> = true>
|
||||
basic_array(const jsonization_t& value)
|
||||
: basic_array(ext::jsonization<string_t, jsonization_t>().to_json(value))
|
||||
{
|
||||
}
|
||||
|
||||
template <
|
||||
typename jsonization_t,
|
||||
std::enable_if_t<
|
||||
_utils::has_to_json_array_in_templ_spec<jsonization_t, string_t>::value,
|
||||
bool> = true>
|
||||
basic_array(const jsonization_t& value)
|
||||
: basic_array(ext::jsonization<string_t, jsonization_t>().to_json_array(value))
|
||||
{
|
||||
}
|
||||
|
||||
template <
|
||||
typename jsonization_t,
|
||||
std::enable_if_t<
|
||||
std::is_rvalue_reference_v<jsonization_t&&>
|
||||
&& _utils::has_move_to_json_in_templ_spec<jsonization_t, string_t>::value
|
||||
&& !_utils::has_move_to_json_array_in_templ_spec<jsonization_t, string_t>::value,
|
||||
bool> = true>
|
||||
basic_array(jsonization_t&& value)
|
||||
: basic_array(ext::jsonization<string_t, jsonization_t>().move_to_json(std::move(value)))
|
||||
{
|
||||
}
|
||||
|
||||
//template <
|
||||
// typename jsonization_t,
|
||||
// std::enable_if_t<
|
||||
// std::is_rvalue_reference_v<jsonization_t&&>
|
||||
// && _utils::has_move_to_json_array_in_templ_spec<jsonization_t, string_t>::value,
|
||||
// bool> = true>
|
||||
//basic_array(jsonization_t&& value)
|
||||
// : basic_array(
|
||||
// ext::jsonization<string_t, jsonization_t>().move_to_json_array(std::move(value)))
|
||||
//{
|
||||
//}
|
||||
|
||||
~basic_array() noexcept = default;
|
||||
|
||||
bool empty() const noexcept { return _array_data.empty(); }
|
||||
|
||||
size_t size() const noexcept { return _array_data.size(); }
|
||||
|
||||
bool contains(size_t pos) const { return pos < _array_data.size(); }
|
||||
|
||||
bool exists(size_t pos) const { return contains(pos); }
|
||||
|
||||
const basic_value<string_t>& at(size_t pos) const;
|
||||
|
||||
string_t dumps(std::optional<size_t> indent = std::nullopt) const
|
||||
{
|
||||
return indent ? format(*indent) : to_string();
|
||||
}
|
||||
|
||||
string_t to_string() const;
|
||||
|
||||
string_t format(size_t indent = 4) const { return format(indent, 0); }
|
||||
|
||||
template <typename value_t>
|
||||
bool all() const;
|
||||
template <typename value_t, template <typename...> typename collection_t = std::vector>
|
||||
collection_t<value_t> as_collection() const;
|
||||
template <
|
||||
typename value_t,
|
||||
size_t Size,
|
||||
template <typename, size_t> typename fixed_array_t = std::array>
|
||||
fixed_array_t<value_t, Size> as_fixed_array() const;
|
||||
template <typename... elem_ts>
|
||||
std::tuple<elem_ts...> as_tuple() const;
|
||||
template <typename first_t, typename second_t>
|
||||
std::pair<first_t, second_t> as_pair() const;
|
||||
|
||||
template <
|
||||
typename value_t,
|
||||
std::enable_if_t<
|
||||
_utils::has_from_json_array_in_templ_spec<value_t, string_t>::value,
|
||||
bool> = true>
|
||||
value_t as() const&
|
||||
{
|
||||
value_t res;
|
||||
ext::jsonization<string_t, value_t>().from_json_array(*this, res);
|
||||
return res;
|
||||
}
|
||||
|
||||
template <
|
||||
typename value_t,
|
||||
std::enable_if_t<
|
||||
_utils::has_move_from_json_array_in_templ_spec<value_t, string_t>::value,
|
||||
bool> = true>
|
||||
value_t as() &&
|
||||
{
|
||||
value_t res;
|
||||
ext::jsonization<string_t, value_t>().move_from_json_array(std::move(*this), res);
|
||||
return res;
|
||||
}
|
||||
|
||||
// Usage: get(key_1, key_2, ..., default_value);
|
||||
template <typename... key_then_default_value_t>
|
||||
auto get(key_then_default_value_t&&... keys_then_default_value) const;
|
||||
|
||||
template <typename value_t = basic_value<string_t>>
|
||||
std::optional<value_t> find(size_t pos) const;
|
||||
|
||||
template <typename... args_t>
|
||||
decltype(auto) emplace_back(args_t&&... args);
|
||||
template <typename... args_t>
|
||||
decltype(auto) push_back(args_t&&... args);
|
||||
|
||||
void clear() noexcept;
|
||||
bool erase(size_t pos);
|
||||
bool erase(iterator iter);
|
||||
|
||||
iterator begin() noexcept;
|
||||
iterator end() noexcept;
|
||||
const_iterator begin() const noexcept;
|
||||
const_iterator end() const noexcept;
|
||||
const_iterator cbegin() const noexcept;
|
||||
const_iterator cend() const noexcept;
|
||||
|
||||
reverse_iterator rbegin() noexcept;
|
||||
reverse_iterator rend() noexcept;
|
||||
const_reverse_iterator rbegin() const noexcept;
|
||||
const_reverse_iterator rend() const noexcept;
|
||||
const_reverse_iterator crbegin() const noexcept;
|
||||
const_reverse_iterator crend() const noexcept;
|
||||
|
||||
const basic_value<string_t>& operator[](size_t pos) const;
|
||||
basic_value<string_t>& operator[](size_t pos);
|
||||
|
||||
basic_array<string_t> operator+(const basic_array<string_t>& rhs) const&;
|
||||
basic_array<string_t> operator+(basic_array<string_t>&& rhs) const&;
|
||||
basic_array<string_t> operator+(const basic_array<string_t>& rhs) &&;
|
||||
basic_array<string_t> operator+(basic_array<string_t>&& rhs) &&;
|
||||
|
||||
basic_array<string_t>& operator+=(const basic_array<string_t>& rhs);
|
||||
basic_array<string_t>& operator+=(basic_array<string_t>&& rhs);
|
||||
|
||||
basic_array<string_t>& operator=(const basic_array<string_t>&) = default;
|
||||
basic_array<string_t>& operator=(basic_array<string_t>&&) noexcept = default;
|
||||
|
||||
template <
|
||||
typename value_t,
|
||||
std::enable_if_t<std::is_convertible_v<value_t, basic_array<string_t>>, bool> = true>
|
||||
basic_array<string_t>& operator=(value_t rhs)
|
||||
{
|
||||
return *this = basic_array<string_t>(std::move(rhs));
|
||||
}
|
||||
|
||||
bool operator==(const basic_array<string_t>& rhs) const;
|
||||
|
||||
bool operator!=(const basic_array<string_t>& rhs) const { return !(*this == rhs); }
|
||||
|
||||
template <
|
||||
typename value_t,
|
||||
template <typename...> typename collection_t = std::vector,
|
||||
std::enable_if_t<_utils::is_collection<collection_t<value_t>>, bool> = true>
|
||||
explicit operator collection_t<value_t>() const
|
||||
{
|
||||
return as_collection<value_t, collection_t>();
|
||||
}
|
||||
|
||||
template <
|
||||
typename value_t,
|
||||
size_t Size,
|
||||
template <typename, size_t> typename fixed_array_t = std::array,
|
||||
std::enable_if_t<_utils::is_fixed_array<fixed_array_t<value_t, Size>>, bool> = true>
|
||||
explicit operator fixed_array_t<value_t, Size>() const
|
||||
{
|
||||
return as<fixed_array_t<value_t, Size>>();
|
||||
}
|
||||
|
||||
template <
|
||||
typename jsonization_t,
|
||||
std::enable_if_t<
|
||||
_utils::has_from_json_in_templ_spec<jsonization_t, string_t>::value
|
||||
&& !_utils::has_from_json_array_in_templ_spec<jsonization_t, string_t>::value,
|
||||
bool> = true>
|
||||
explicit operator jsonization_t() const&
|
||||
{
|
||||
jsonization_t dst {};
|
||||
if (!ext::jsonization<string_t, jsonization_t>().from_json(*this, dst)) {
|
||||
throw exception("Wrong JSON");
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
|
||||
template <
|
||||
typename jsonization_t,
|
||||
std::enable_if_t<
|
||||
_utils::has_from_json_array_in_templ_spec<jsonization_t, string_t>::value,
|
||||
bool> = true>
|
||||
explicit operator jsonization_t() const&
|
||||
{
|
||||
jsonization_t dst {};
|
||||
if (!ext::jsonization<string_t, jsonization_t>().from_json_array(*this, dst)) {
|
||||
throw exception("Wrong JSON");
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
|
||||
template <
|
||||
typename jsonization_t,
|
||||
std::enable_if_t<
|
||||
_utils::has_move_from_json_in_templ_spec<jsonization_t, string_t>::value
|
||||
&& !_utils::has_move_from_json_array_in_templ_spec<jsonization_t, string_t>::value,
|
||||
bool> = true>
|
||||
explicit operator jsonization_t() &&
|
||||
{
|
||||
jsonization_t dst {};
|
||||
if (!ext::jsonization<string_t, jsonization_t>().from_json(std::move(*this), dst)) {
|
||||
throw exception("Wrong JSON");
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
|
||||
template <
|
||||
typename jsonization_t,
|
||||
std::enable_if_t<
|
||||
_utils::has_move_from_json_array_in_templ_spec<jsonization_t, string_t>::value,
|
||||
bool> = true>
|
||||
explicit operator jsonization_t() &&
|
||||
{
|
||||
jsonization_t dst {};
|
||||
if (!ext::jsonization<string_t, jsonization_t>().move_from_json_array(
|
||||
std::move(*this),
|
||||
dst)) {
|
||||
throw exception("Wrong JSON");
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename... key_then_default_value_t, size_t... keys_indexes_t>
|
||||
auto
|
||||
get(std::tuple<key_then_default_value_t...> keys_then_default_value,
|
||||
std::index_sequence<keys_indexes_t...>) const;
|
||||
template <typename value_t, typename... rest_keys_t>
|
||||
auto get_helper(const value_t& default_value, size_t pos, rest_keys_t&&... rest) const;
|
||||
template <typename value_t>
|
||||
auto get_helper(const value_t& default_value, size_t pos) const;
|
||||
|
||||
string_t format(size_t indent, size_t indent_times) const;
|
||||
|
||||
private:
|
||||
raw_array _array_data;
|
||||
};
|
||||
|
||||
template <typename string_t>
|
||||
inline basic_array<string_t>::basic_array(std::initializer_list<value_type> init_list)
|
||||
: _array_data(init_list)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline basic_array<string_t>::basic_array(typename raw_array::size_type size)
|
||||
: _array_data(size)
|
||||
{
|
||||
}
|
||||
|
||||
// template <typename string_t>
|
||||
// inline basic_array<string_t>::basic_array(const basic_value<string_t>& val) :
|
||||
// basic_array<string_t>(val.as_array())
|
||||
//{}
|
||||
//
|
||||
// template <typename string_t>
|
||||
// inline basic_array<string_t>::basic_array(basic_value<string_t>&& val)
|
||||
// : basic_array<string_t>(std::move(val.as_array()))
|
||||
//{}
|
||||
|
||||
template <typename string_t>
|
||||
inline void basic_array<string_t>::clear() noexcept
|
||||
{
|
||||
_array_data.clear();
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline bool basic_array<string_t>::erase(size_t pos)
|
||||
{
|
||||
return erase(_array_data.begin() + pos);
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline bool basic_array<string_t>::erase(iterator iter)
|
||||
{
|
||||
return _array_data.erase(iter) != _array_data.end();
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
template <typename... args_t>
|
||||
inline decltype(auto) basic_array<string_t>::emplace_back(args_t&&... args)
|
||||
{
|
||||
static_assert(
|
||||
std::is_constructible_v<value_type, args_t...>,
|
||||
"Parameter can't be used to construct a raw_array::value_type");
|
||||
return _array_data.emplace_back(std::forward<args_t>(args)...);
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
template <typename... args_t>
|
||||
inline decltype(auto) basic_array<string_t>::push_back(args_t&&... args)
|
||||
{
|
||||
return emplace_back(std::forward<args_t>(args)...);
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline const basic_value<string_t>& basic_array<string_t>::at(size_t pos) const
|
||||
{
|
||||
return _array_data.at(pos);
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline string_t basic_array<string_t>::to_string() const
|
||||
{
|
||||
string_t str { '[' };
|
||||
for (auto iter = _array_data.cbegin(); iter != _array_data.cend();) {
|
||||
str += iter->to_string();
|
||||
if (++iter != _array_data.cend()) {
|
||||
str += ',';
|
||||
}
|
||||
}
|
||||
str += char_t(']');
|
||||
return str;
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline string_t basic_array<string_t>::format(size_t indent, size_t indent_times) const
|
||||
{
|
||||
const string_t tail_indent(indent * indent_times, ' ');
|
||||
const string_t body_indent(indent * (indent_times + 1), ' ');
|
||||
|
||||
string_t str { '[', '\n' };
|
||||
for (auto iter = _array_data.cbegin(); iter != _array_data.cend();) {
|
||||
str += body_indent + iter->format(indent, indent_times + 1);
|
||||
if (++iter != _array_data.cend()) {
|
||||
str += ',';
|
||||
}
|
||||
str += '\n';
|
||||
}
|
||||
str += tail_indent + char_t(']');
|
||||
return str;
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
template <typename value_t>
|
||||
inline bool basic_array<string_t>::all() const
|
||||
{
|
||||
for (const auto& elem : _array_data) {
|
||||
if (!elem.template is<value_t>()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
template <typename value_t, template <typename...> typename collection_t>
|
||||
inline collection_t<value_t> basic_array<string_t>::as_collection() const
|
||||
{
|
||||
return as<collection_t<value_t>>();
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
template <typename value_t, size_t Size, template <typename, size_t> typename fixed_array_t>
|
||||
inline fixed_array_t<value_t, Size> basic_array<string_t>::as_fixed_array() const
|
||||
{
|
||||
return as<fixed_array_t<value_t, Size>>();
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
template <typename... elem_ts>
|
||||
inline std::tuple<elem_ts...> basic_array<string_t>::as_tuple() const
|
||||
{
|
||||
return as<std::tuple<elem_ts...>>();
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
template <typename first_t, typename second_t>
|
||||
inline std::pair<first_t, second_t> basic_array<string_t>::as_pair() const
|
||||
{
|
||||
return as<std::pair<first_t, second_t>>();
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
template <typename... key_then_default_value_t>
|
||||
inline auto basic_array<string_t>::get(key_then_default_value_t&&... keys_then_default_value) const
|
||||
{
|
||||
return get(
|
||||
std::forward_as_tuple(keys_then_default_value...),
|
||||
std::make_index_sequence<sizeof...(keys_then_default_value) - 1> {});
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
template <typename... key_then_default_value_t, size_t... keys_indexes_t>
|
||||
inline auto basic_array<string_t>::get(
|
||||
std::tuple<key_then_default_value_t...> keys_then_default_value,
|
||||
std::index_sequence<keys_indexes_t...>) const
|
||||
{
|
||||
constexpr unsigned long default_value_index = sizeof...(key_then_default_value_t) - 1;
|
||||
return get_helper(
|
||||
std::get<default_value_index>(keys_then_default_value),
|
||||
std::get<keys_indexes_t>(keys_then_default_value)...);
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
template <typename value_t, typename... rest_keys_t>
|
||||
inline auto basic_array<string_t>::get_helper(
|
||||
const value_t& default_value,
|
||||
size_t pos,
|
||||
rest_keys_t&&... rest) const
|
||||
{
|
||||
constexpr bool is_json = std::is_same_v<basic_value<string_t>, value_t>
|
||||
|| std::is_same_v<basic_array<string_t>, value_t>
|
||||
|| std::is_same_v<basic_object<string_t>, value_t>;
|
||||
constexpr bool is_string = std::is_constructible_v<string_t, value_t> && !is_json;
|
||||
|
||||
if (!contains(pos)) {
|
||||
if constexpr (is_string) {
|
||||
return string_t(default_value);
|
||||
}
|
||||
else {
|
||||
return value_t(default_value);
|
||||
}
|
||||
}
|
||||
|
||||
return at(pos).get_helper(default_value, std::forward<rest_keys_t>(rest)...);
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
template <typename value_t>
|
||||
inline auto basic_array<string_t>::get_helper(const value_t& default_value, size_t pos) const
|
||||
{
|
||||
constexpr bool is_json = std::is_same_v<basic_value<string_t>, value_t>
|
||||
|| std::is_same_v<basic_array<string_t>, value_t>
|
||||
|| std::is_same_v<basic_object<string_t>, value_t>;
|
||||
constexpr bool is_string = std::is_constructible_v<string_t, value_t> && !is_json;
|
||||
|
||||
if (!contains(pos)) {
|
||||
if constexpr (is_string) {
|
||||
return string_t(default_value);
|
||||
}
|
||||
else {
|
||||
return value_t(default_value);
|
||||
}
|
||||
}
|
||||
|
||||
auto val = _array_data.at(pos);
|
||||
if (val.template is<value_t>()) {
|
||||
if constexpr (is_string) {
|
||||
return val.template as<string_t>();
|
||||
}
|
||||
else {
|
||||
return val.template as<value_t>();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if constexpr (is_string) {
|
||||
return string_t(default_value);
|
||||
}
|
||||
else {
|
||||
return value_t(default_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
template <typename value_t>
|
||||
inline std::optional<value_t> basic_array<string_t>::find(size_t pos) const
|
||||
{
|
||||
if (!contains(pos)) {
|
||||
return std::nullopt;
|
||||
}
|
||||
const auto& val = _array_data.at(pos);
|
||||
return val.template is<value_t>() ? std::optional<value_t>(val.template as<value_t>())
|
||||
: std::nullopt;
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline typename basic_array<string_t>::iterator basic_array<string_t>::begin() noexcept
|
||||
{
|
||||
return _array_data.begin();
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline typename basic_array<string_t>::iterator basic_array<string_t>::end() noexcept
|
||||
{
|
||||
return _array_data.end();
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline typename basic_array<string_t>::const_iterator basic_array<string_t>::begin() const noexcept
|
||||
{
|
||||
return _array_data.begin();
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline typename basic_array<string_t>::const_iterator basic_array<string_t>::end() const noexcept
|
||||
{
|
||||
return _array_data.end();
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline typename basic_array<string_t>::const_iterator basic_array<string_t>::cbegin() const noexcept
|
||||
{
|
||||
return _array_data.cbegin();
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline typename basic_array<string_t>::const_iterator basic_array<string_t>::cend() const noexcept
|
||||
{
|
||||
return _array_data.cend();
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline typename basic_array<string_t>::reverse_iterator basic_array<string_t>::rbegin() noexcept
|
||||
{
|
||||
return _array_data.rbegin();
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline typename basic_array<string_t>::reverse_iterator basic_array<string_t>::rend() noexcept
|
||||
{
|
||||
return _array_data.rend();
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline typename basic_array<string_t>::const_reverse_iterator
|
||||
basic_array<string_t>::rbegin() const noexcept
|
||||
{
|
||||
return _array_data.rbegin();
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline typename basic_array<string_t>::const_reverse_iterator
|
||||
basic_array<string_t>::rend() const noexcept
|
||||
{
|
||||
return _array_data.rend();
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline typename basic_array<string_t>::const_reverse_iterator
|
||||
basic_array<string_t>::crbegin() const noexcept
|
||||
{
|
||||
return _array_data.crbegin();
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline typename basic_array<string_t>::const_reverse_iterator
|
||||
basic_array<string_t>::crend() const noexcept
|
||||
{
|
||||
return _array_data.crend();
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline basic_value<string_t>& basic_array<string_t>::operator[](size_t pos)
|
||||
{
|
||||
return _array_data[pos];
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline const basic_value<string_t>& basic_array<string_t>::operator[](size_t pos) const
|
||||
{
|
||||
return _array_data[pos];
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline basic_array<string_t>
|
||||
basic_array<string_t>::operator+(const basic_array<string_t>& rhs) const&
|
||||
{
|
||||
basic_array<string_t> temp = *this;
|
||||
temp._array_data.insert(_array_data.end(), rhs.begin(), rhs.end());
|
||||
return temp;
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline basic_array<string_t> basic_array<string_t>::operator+(basic_array<string_t>&& rhs) const&
|
||||
{
|
||||
basic_array<string_t> temp = *this;
|
||||
temp._array_data.insert(
|
||||
_array_data.end(),
|
||||
std::make_move_iterator(rhs.begin()),
|
||||
std::make_move_iterator(rhs.end()));
|
||||
return temp;
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline basic_array<string_t> basic_array<string_t>::operator+(const basic_array<string_t>& rhs) &&
|
||||
{
|
||||
_array_data.insert(_array_data.end(), rhs.begin(), rhs.end());
|
||||
return std::move(*this);
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline basic_array<string_t> basic_array<string_t>::operator+(basic_array<string_t>&& rhs) &&
|
||||
{
|
||||
_array_data.insert(
|
||||
_array_data.end(),
|
||||
std::make_move_iterator(rhs.begin()),
|
||||
std::make_move_iterator(rhs.end()));
|
||||
return std::move(*this);
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline basic_array<string_t>& basic_array<string_t>::operator+=(const basic_array<string_t>& rhs)
|
||||
{
|
||||
_array_data.insert(_array_data.end(), rhs.begin(), rhs.end());
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline basic_array<string_t>& basic_array<string_t>::operator+=(basic_array<string_t>&& rhs)
|
||||
{
|
||||
_array_data.insert(
|
||||
_array_data.end(),
|
||||
std::make_move_iterator(rhs.begin()),
|
||||
std::make_move_iterator(rhs.end()));
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline bool basic_array<string_t>::operator==(const basic_array<string_t>& rhs) const
|
||||
{
|
||||
return _array_data == rhs._array_data;
|
||||
}
|
||||
|
||||
template <
|
||||
typename ostream_t,
|
||||
typename string_t,
|
||||
typename std_ostream_t = std::basic_ostream<
|
||||
typename string_t::value_type,
|
||||
std::char_traits<typename string_t::value_type>>,
|
||||
typename enable_t = std::enable_if_t<
|
||||
std::is_same_v<std_ostream_t, ostream_t> || std::is_base_of_v<std_ostream_t, ostream_t>>>
|
||||
ostream_t& operator<<(ostream_t& out, const basic_array<string_t>& arr)
|
||||
{
|
||||
out << arr.format();
|
||||
return out;
|
||||
}
|
||||
} // namespace json
|
||||
35
3rdparty/include/meojson/common/exception.hpp
vendored
35
3rdparty/include/meojson/common/exception.hpp
vendored
@@ -1,35 +0,0 @@
|
||||
// IWYU pragma: private, include <meojson/json.hpp>
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <exception>
|
||||
#include <string>
|
||||
|
||||
namespace json
|
||||
{
|
||||
class exception : public std::exception
|
||||
{
|
||||
public:
|
||||
exception() = default;
|
||||
|
||||
exception(const std::string& msg)
|
||||
: _what(msg)
|
||||
{
|
||||
}
|
||||
|
||||
exception(const exception&) = default;
|
||||
exception& operator=(const exception&) = default;
|
||||
exception(exception&&) = default;
|
||||
exception& operator=(exception&&) = default;
|
||||
|
||||
virtual ~exception() noexcept override = default;
|
||||
|
||||
virtual const char* what() const noexcept override
|
||||
{
|
||||
return _what.empty() ? "Unknown exception" : _what.c_str();
|
||||
}
|
||||
|
||||
protected:
|
||||
std::string _what;
|
||||
};
|
||||
}
|
||||
605
3rdparty/include/meojson/common/object.hpp
vendored
605
3rdparty/include/meojson/common/object.hpp
vendored
@@ -1,605 +0,0 @@
|
||||
// IWYU pragma: private, include <meojson/json.hpp>
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <initializer_list>
|
||||
#include <map>
|
||||
#include <optional>
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
|
||||
#include "exception.hpp"
|
||||
#include "utils.hpp"
|
||||
|
||||
namespace json
|
||||
{
|
||||
template <typename string_t>
|
||||
class basic_object
|
||||
{
|
||||
friend class basic_value<string_t>;
|
||||
friend class basic_array<string_t>;
|
||||
|
||||
public:
|
||||
using raw_object = std::map<string_t, basic_value<string_t>>;
|
||||
using key_type = typename raw_object::key_type;
|
||||
using mapped_type = typename raw_object::mapped_type;
|
||||
using value_type = typename raw_object::value_type;
|
||||
using iterator = typename raw_object::iterator;
|
||||
using const_iterator = typename raw_object::const_iterator;
|
||||
using char_t = typename string_t::value_type;
|
||||
|
||||
public:
|
||||
basic_object() = default;
|
||||
basic_object(const basic_object<string_t>& rhs) = default;
|
||||
basic_object(basic_object<string_t>&& rhs) noexcept = default;
|
||||
basic_object(std::initializer_list<value_type> init_list);
|
||||
|
||||
// explicit basic_object(const basic_value<string_t>& val);
|
||||
// explicit basic_object(basic_value<string_t>&& val);
|
||||
|
||||
template <
|
||||
typename jsonization_t,
|
||||
std::enable_if_t<
|
||||
_utils::has_to_json_in_templ_spec<jsonization_t, string_t>::value
|
||||
&& !_utils::has_to_json_object_in_templ_spec<jsonization_t, string_t>::value,
|
||||
bool> = true>
|
||||
basic_object(const jsonization_t& value)
|
||||
: basic_object(ext::jsonization<string_t, jsonization_t>().to_json(value))
|
||||
{
|
||||
}
|
||||
|
||||
template <
|
||||
typename jsonization_t,
|
||||
std::enable_if_t<
|
||||
_utils::has_to_json_object_in_templ_spec<jsonization_t, string_t>::value,
|
||||
bool> = true>
|
||||
basic_object(const jsonization_t& value)
|
||||
: basic_object(ext::jsonization<string_t, jsonization_t>().to_json_object(value))
|
||||
{
|
||||
}
|
||||
|
||||
template <
|
||||
typename jsonization_t,
|
||||
std::enable_if_t<
|
||||
std::is_rvalue_reference_v<jsonization_t&&>
|
||||
&& _utils::has_move_to_json_in_templ_spec<jsonization_t, string_t>::value
|
||||
&& !_utils::has_move_to_json_object_in_templ_spec<jsonization_t, string_t>::value,
|
||||
bool> = true>
|
||||
basic_object(jsonization_t&& value)
|
||||
: basic_object(ext::jsonization<string_t, jsonization_t>().move_to_json(std::move(value)))
|
||||
{
|
||||
}
|
||||
|
||||
//template <
|
||||
// typename jsonization_t,
|
||||
// std::enable_if_t<
|
||||
// std::is_rvalue_reference_v<jsonization_t&&>
|
||||
// && _utils::has_move_to_json_object_in_templ_spec<jsonization_t, string_t>::value,
|
||||
// bool> = true>
|
||||
//basic_object(jsonization_t&& value)
|
||||
// : basic_object(
|
||||
// ext::jsonization<string_t, jsonization_t>().move_to_json_object(std::move(value)))
|
||||
//{
|
||||
//}
|
||||
|
||||
~basic_object() = default;
|
||||
|
||||
bool empty() const noexcept { return _object_data.empty(); }
|
||||
|
||||
size_t size() const noexcept { return _object_data.size(); }
|
||||
|
||||
bool contains(const string_t& key) const;
|
||||
|
||||
bool exists(const string_t& key) const { return contains(key); }
|
||||
|
||||
const basic_value<string_t>& at(const string_t& key) const;
|
||||
|
||||
string_t dumps(std::optional<size_t> indent = std::nullopt) const
|
||||
{
|
||||
return indent ? format(*indent) : to_string();
|
||||
}
|
||||
|
||||
string_t to_string() const;
|
||||
|
||||
string_t format(size_t indent = 4) const { return format(indent, 0); }
|
||||
|
||||
template <typename value_t>
|
||||
bool all() const;
|
||||
template <typename value_t, template <typename...> typename map_t = std::map>
|
||||
map_t<string_t, value_t> as_map() const;
|
||||
|
||||
template <
|
||||
typename value_t,
|
||||
std::enable_if_t<
|
||||
_utils::has_from_json_object_in_templ_spec<value_t, string_t>::value,
|
||||
bool> = true>
|
||||
value_t as() const&
|
||||
{
|
||||
value_t res;
|
||||
ext::jsonization<string_t, value_t>().from_json_object(*this, res);
|
||||
return res;
|
||||
}
|
||||
|
||||
template <
|
||||
typename value_t,
|
||||
std::enable_if_t<
|
||||
_utils::has_move_from_json_object_in_templ_spec<value_t, string_t>::value,
|
||||
bool> = true>
|
||||
value_t as() &&
|
||||
{
|
||||
value_t res;
|
||||
ext::jsonization<string_t, value_t>().move_from_json_object(std::move(*this), res);
|
||||
return res;
|
||||
}
|
||||
|
||||
// Usage: get(key_1, key_2, ..., default_value);
|
||||
template <typename... key_then_default_value_t>
|
||||
auto get(key_then_default_value_t&&... keys_then_default_value) const;
|
||||
|
||||
template <typename value_t = basic_value<string_t>>
|
||||
std::optional<value_t> find(const string_t& key) const;
|
||||
|
||||
template <typename... args_t>
|
||||
decltype(auto) emplace(args_t&&... args);
|
||||
template <typename... args_t>
|
||||
decltype(auto) insert(args_t&&... args);
|
||||
|
||||
void clear() noexcept;
|
||||
bool erase(const string_t& key);
|
||||
bool erase(iterator iter);
|
||||
|
||||
iterator begin() noexcept;
|
||||
iterator end() noexcept;
|
||||
const_iterator begin() const noexcept;
|
||||
const_iterator end() const noexcept;
|
||||
const_iterator cbegin() const noexcept;
|
||||
const_iterator cend() const noexcept;
|
||||
|
||||
basic_value<string_t>& operator[](const string_t& key);
|
||||
basic_value<string_t>& operator[](string_t&& key);
|
||||
|
||||
basic_object<string_t> operator|(const basic_object<string_t>& rhs) const&;
|
||||
basic_object<string_t> operator|(basic_object<string_t>&& rhs) const&;
|
||||
basic_object<string_t> operator|(const basic_object<string_t>& rhs) &&;
|
||||
basic_object<string_t> operator|(basic_object<string_t>&& rhs) &&;
|
||||
|
||||
basic_object<string_t>& operator|=(const basic_object<string_t>& rhs);
|
||||
basic_object<string_t>& operator|=(basic_object<string_t>&& rhs);
|
||||
|
||||
basic_object<string_t>& operator=(const basic_object<string_t>&) = default;
|
||||
basic_object<string_t>& operator=(basic_object<string_t>&&) = default;
|
||||
|
||||
template <
|
||||
typename value_t,
|
||||
std::enable_if_t<std::is_convertible_v<value_t, basic_object<string_t>>, bool> = true>
|
||||
basic_object<string_t>& operator=(value_t rhs)
|
||||
{
|
||||
return *this = basic_object<string_t>(std::move(rhs));
|
||||
}
|
||||
|
||||
bool operator==(const basic_object<string_t>& rhs) const;
|
||||
|
||||
bool operator!=(const basic_object<string_t>& rhs) const { return !(*this == rhs); }
|
||||
|
||||
template <
|
||||
typename value_t,
|
||||
template <typename...> typename map_t = std::map,
|
||||
std::enable_if_t<_utils::is_map<map_t<string_t, value_t>>, bool> = true>
|
||||
explicit operator map_t<string_t, value_t>() const
|
||||
{
|
||||
return as_map<value_t, map_t>();
|
||||
}
|
||||
|
||||
template <
|
||||
typename jsonization_t,
|
||||
std::enable_if_t<
|
||||
_utils::has_from_json_in_templ_spec<jsonization_t, string_t>::value
|
||||
&& !_utils::has_from_json_object_in_templ_spec<jsonization_t, string_t>::value,
|
||||
bool> = true>
|
||||
explicit operator jsonization_t() const&
|
||||
{
|
||||
jsonization_t dst {};
|
||||
if (!ext::jsonization<string_t, jsonization_t>().from_json(*this, dst)) {
|
||||
throw exception("Wrong JSON");
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
|
||||
template <
|
||||
typename jsonization_t,
|
||||
std::enable_if_t<
|
||||
_utils::has_from_json_object_in_templ_spec<jsonization_t, string_t>::value,
|
||||
bool> = true>
|
||||
explicit operator jsonization_t() const&
|
||||
{
|
||||
jsonization_t dst {};
|
||||
if (!ext::jsonization<string_t, jsonization_t>().from_json_object(*this, dst)) {
|
||||
throw exception("Wrong JSON");
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
|
||||
template <
|
||||
typename jsonization_t,
|
||||
std::enable_if_t<
|
||||
_utils::has_move_from_json_in_templ_spec<jsonization_t, string_t>::value
|
||||
&& !_utils::has_move_from_json_object_in_templ_spec<jsonization_t, string_t>::value,
|
||||
bool> = true>
|
||||
explicit operator jsonization_t() &&
|
||||
{
|
||||
jsonization_t dst {};
|
||||
if (!ext::jsonization<string_t, jsonization_t>().from_json(std::move(*this), dst)) {
|
||||
throw exception("Wrong JSON");
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
|
||||
template <
|
||||
typename jsonization_t,
|
||||
std::enable_if_t<
|
||||
_utils::has_move_from_json_object_in_templ_spec<jsonization_t, string_t>::value,
|
||||
bool> = true>
|
||||
explicit operator jsonization_t() &&
|
||||
{
|
||||
jsonization_t dst {};
|
||||
if (!ext::jsonization<string_t, jsonization_t>().move_from_json_object(
|
||||
std::move(*this),
|
||||
dst)) {
|
||||
throw exception("Wrong JSON");
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename... key_then_default_value_t, size_t... keys_indexes_t>
|
||||
auto
|
||||
get(std::tuple<key_then_default_value_t...> keys_then_default_value,
|
||||
std::index_sequence<keys_indexes_t...>) const;
|
||||
template <typename value_t, typename... rest_keys_t>
|
||||
auto get_helper(const value_t& default_value, const string_t& key, rest_keys_t&&... rest) const;
|
||||
template <typename value_t>
|
||||
auto get_helper(const value_t& default_value, const string_t& key) const;
|
||||
|
||||
string_t format(size_t indent, size_t indent_times) const;
|
||||
|
||||
private:
|
||||
raw_object _object_data;
|
||||
};
|
||||
|
||||
template <typename string_t>
|
||||
inline basic_object<string_t>::basic_object(std::initializer_list<value_type> init_list)
|
||||
: _object_data(
|
||||
std::make_move_iterator(init_list.begin()),
|
||||
std::make_move_iterator(init_list.end()))
|
||||
{
|
||||
}
|
||||
|
||||
// template <typename string_t>
|
||||
// inline basic_object<string_t>::basic_object(const basic_value<string_t>& val) :
|
||||
// basic_object<string_t>(val.as_object())
|
||||
//{}
|
||||
//
|
||||
// template <typename string_t>
|
||||
// inline basic_object<string_t>::basic_object(basic_value<string_t>&& val)
|
||||
// : basic_object<string_t>(std::move(val.as_object()))
|
||||
//{}
|
||||
|
||||
template <typename string_t>
|
||||
inline bool basic_object<string_t>::contains(const string_t& key) const
|
||||
{
|
||||
return _object_data.find(key) != _object_data.cend();
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline const basic_value<string_t>& basic_object<string_t>::at(const string_t& key) const
|
||||
{
|
||||
return _object_data.at(key);
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline void basic_object<string_t>::clear() noexcept
|
||||
{
|
||||
_object_data.clear();
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline bool basic_object<string_t>::erase(const string_t& key)
|
||||
{
|
||||
return _object_data.erase(key) > 0 ? true : false;
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline bool basic_object<string_t>::erase(iterator iter)
|
||||
{
|
||||
return _object_data.erase(iter) != _object_data.end();
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
template <typename... args_t>
|
||||
inline decltype(auto) basic_object<string_t>::emplace(args_t&&... args)
|
||||
{
|
||||
static_assert(
|
||||
std::is_constructible_v<value_type, args_t...>,
|
||||
"Parameter can't be used to construct a raw_object::value_type");
|
||||
return _object_data.insert_or_assign(std::forward<args_t>(args)...);
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
template <typename... args_t>
|
||||
inline decltype(auto) basic_object<string_t>::insert(args_t&&... args)
|
||||
{
|
||||
return emplace(std::forward<args_t>(args)...);
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline string_t basic_object<string_t>::to_string() const
|
||||
{
|
||||
string_t str { '{' };
|
||||
for (auto iter = _object_data.cbegin(); iter != _object_data.cend();) {
|
||||
const auto& [key, val] = *iter;
|
||||
str +=
|
||||
char_t('"') + _utils::unescape_string(key) + string_t { '\"', ':' } + val.to_string();
|
||||
if (++iter != _object_data.cend()) {
|
||||
str += ',';
|
||||
}
|
||||
}
|
||||
str += char_t('}');
|
||||
return str;
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline string_t basic_object<string_t>::format(size_t indent, size_t indent_times) const
|
||||
{
|
||||
const string_t tail_indent(indent * indent_times, ' ');
|
||||
const string_t body_indent(indent * (indent_times + 1), ' ');
|
||||
|
||||
string_t str { '{', '\n' };
|
||||
for (auto iter = _object_data.cbegin(); iter != _object_data.cend();) {
|
||||
const auto& [key, val] = *iter;
|
||||
str += body_indent + char_t('"') + _utils::unescape_string(key)
|
||||
+ string_t { '\"', ':', ' ' } + val.format(indent, indent_times + 1);
|
||||
if (++iter != _object_data.cend()) {
|
||||
str += ',';
|
||||
}
|
||||
str += '\n';
|
||||
}
|
||||
str += tail_indent + char_t('}');
|
||||
return str;
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
template <typename value_t>
|
||||
inline bool basic_object<string_t>::all() const
|
||||
{
|
||||
for (const auto& [_, val] : _object_data) {
|
||||
if (!val.template is<value_t>()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
template <typename value_t, template <typename...> typename map_t>
|
||||
inline map_t<string_t, value_t> basic_object<string_t>::as_map() const
|
||||
{
|
||||
return as<map_t<string_t, value_t>>();
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
template <typename... key_then_default_value_t>
|
||||
inline auto basic_object<string_t>::get(key_then_default_value_t&&... keys_then_default_value) const
|
||||
{
|
||||
return get(
|
||||
std::forward_as_tuple(keys_then_default_value...),
|
||||
std::make_index_sequence<sizeof...(keys_then_default_value) - 1> {});
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
template <typename... key_then_default_value_t, size_t... keys_indexes_t>
|
||||
inline auto basic_object<string_t>::get(
|
||||
std::tuple<key_then_default_value_t...> keys_then_default_value,
|
||||
std::index_sequence<keys_indexes_t...>) const
|
||||
{
|
||||
constexpr unsigned long default_value_index = sizeof...(key_then_default_value_t) - 1;
|
||||
return get_helper(
|
||||
std::get<default_value_index>(keys_then_default_value),
|
||||
std::get<keys_indexes_t>(keys_then_default_value)...);
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
template <typename value_t, typename... rest_keys_t>
|
||||
inline auto basic_object<string_t>::get_helper(
|
||||
const value_t& default_value,
|
||||
const string_t& key,
|
||||
rest_keys_t&&... rest) const
|
||||
{
|
||||
constexpr bool is_json = std::is_same_v<basic_value<string_t>, value_t>
|
||||
|| std::is_same_v<basic_array<string_t>, value_t>
|
||||
|| std::is_same_v<basic_object<string_t>, value_t>;
|
||||
constexpr bool is_string = std::is_constructible_v<string_t, value_t> && !is_json;
|
||||
|
||||
if (!contains(key)) {
|
||||
if constexpr (is_string) {
|
||||
return string_t(default_value);
|
||||
}
|
||||
else {
|
||||
return value_t(default_value);
|
||||
}
|
||||
}
|
||||
|
||||
return at(key).get_helper(default_value, std::forward<rest_keys_t>(rest)...);
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
template <typename value_t>
|
||||
inline auto
|
||||
basic_object<string_t>::get_helper(const value_t& default_value, const string_t& key) const
|
||||
{
|
||||
constexpr bool is_json = std::is_same_v<basic_value<string_t>, value_t>
|
||||
|| std::is_same_v<basic_array<string_t>, value_t>
|
||||
|| std::is_same_v<basic_object<string_t>, value_t>;
|
||||
constexpr bool is_string = std::is_constructible_v<string_t, value_t> && !is_json;
|
||||
|
||||
if (!contains(key)) {
|
||||
if constexpr (is_string) {
|
||||
return string_t(default_value);
|
||||
}
|
||||
else {
|
||||
return value_t(default_value);
|
||||
}
|
||||
}
|
||||
|
||||
auto val = _object_data.at(key);
|
||||
if (val.template is<value_t>()) {
|
||||
if constexpr (is_string) {
|
||||
return val.template as<string_t>();
|
||||
}
|
||||
else {
|
||||
return val.template as<value_t>();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if constexpr (is_string) {
|
||||
return string_t(default_value);
|
||||
}
|
||||
else {
|
||||
return value_t(default_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
template <typename value_t>
|
||||
inline std::optional<value_t> basic_object<string_t>::find(const string_t& key) const
|
||||
{
|
||||
auto iter = _object_data.find(key);
|
||||
if (iter == _object_data.end()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
const auto& val = iter->second;
|
||||
return val.template is<value_t>() ? std::optional<value_t>(val.template as<value_t>())
|
||||
: std::nullopt;
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline typename basic_object<string_t>::iterator basic_object<string_t>::begin() noexcept
|
||||
{
|
||||
return _object_data.begin();
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline typename basic_object<string_t>::iterator basic_object<string_t>::end() noexcept
|
||||
{
|
||||
return _object_data.end();
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline typename basic_object<string_t>::const_iterator
|
||||
basic_object<string_t>::begin() const noexcept
|
||||
{
|
||||
return _object_data.begin();
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline typename basic_object<string_t>::const_iterator basic_object<string_t>::end() const noexcept
|
||||
{
|
||||
return _object_data.end();
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline typename basic_object<string_t>::const_iterator
|
||||
basic_object<string_t>::cbegin() const noexcept
|
||||
{
|
||||
return _object_data.cbegin();
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline typename basic_object<string_t>::const_iterator basic_object<string_t>::cend() const noexcept
|
||||
{
|
||||
return _object_data.cend();
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline basic_value<string_t>& basic_object<string_t>::operator[](const string_t& key)
|
||||
{
|
||||
return _object_data[key];
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline basic_value<string_t>& basic_object<string_t>::operator[](string_t&& key)
|
||||
{
|
||||
return _object_data[std::move(key)];
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline basic_object<string_t>
|
||||
basic_object<string_t>::operator|(const basic_object<string_t>& rhs) const&
|
||||
{
|
||||
basic_object<string_t> temp = *this;
|
||||
temp._object_data.insert(rhs.begin(), rhs.end());
|
||||
return temp;
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline basic_object<string_t> basic_object<string_t>::operator|(basic_object<string_t>&& rhs) const&
|
||||
{
|
||||
basic_object<string_t> temp = *this;
|
||||
// temp._object_data.merge(std::move(rhs._object_data));
|
||||
temp._object_data.insert(
|
||||
std::make_move_iterator(rhs.begin()),
|
||||
std::make_move_iterator(rhs.end()));
|
||||
return temp;
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline basic_object<string_t>
|
||||
basic_object<string_t>::operator|(const basic_object<string_t>& rhs) &&
|
||||
{
|
||||
_object_data.insert(rhs.begin(), rhs.end());
|
||||
return std::move(*this);
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline basic_object<string_t> basic_object<string_t>::operator|(basic_object<string_t>&& rhs) &&
|
||||
{
|
||||
//_object_data.merge(std::move(rhs._object_data));
|
||||
_object_data.insert(std::make_move_iterator(rhs.begin()), std::make_move_iterator(rhs.end()));
|
||||
return std::move(*this);
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline basic_object<string_t>& basic_object<string_t>::operator|=(const basic_object<string_t>& rhs)
|
||||
{
|
||||
_object_data.insert(rhs.begin(), rhs.end());
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline basic_object<string_t>& basic_object<string_t>::operator|=(basic_object<string_t>&& rhs)
|
||||
{
|
||||
_object_data.insert(std::make_move_iterator(rhs.begin()), std::make_move_iterator(rhs.end()));
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline bool basic_object<string_t>::operator==(const basic_object<string_t>& rhs) const
|
||||
{
|
||||
return _object_data == rhs._object_data;
|
||||
}
|
||||
|
||||
template <
|
||||
typename ostream_t,
|
||||
typename string_t,
|
||||
typename std_ostream_t = std::basic_ostream<
|
||||
typename string_t::value_type,
|
||||
std::char_traits<typename string_t::value_type>>,
|
||||
typename enable_t = std::enable_if_t<
|
||||
std::is_same_v<std_ostream_t, ostream_t> || std::is_base_of_v<std_ostream_t, ostream_t>>>
|
||||
ostream_t& operator<<(ostream_t& out, const basic_object<string_t>& obj)
|
||||
{
|
||||
out << obj.format();
|
||||
return out;
|
||||
}
|
||||
} // namespace json
|
||||
207
3rdparty/include/meojson/common/serialization.hpp
vendored
207
3rdparty/include/meojson/common/serialization.hpp
vendored
@@ -1,207 +0,0 @@
|
||||
// IWYU pragma: private, include <meojson/json.hpp>
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include "types.hpp"
|
||||
#include "utils.hpp"
|
||||
|
||||
namespace json
|
||||
{
|
||||
namespace _serialization_helper
|
||||
{
|
||||
template <typename in_t, typename serializer_t>
|
||||
class is_serializable
|
||||
{
|
||||
template <typename U>
|
||||
static auto test(int)
|
||||
-> decltype(std::declval<serializer_t>()(std::declval<U>()), std::true_type());
|
||||
|
||||
template <typename U>
|
||||
static std::false_type test(...);
|
||||
|
||||
public:
|
||||
static constexpr bool value = decltype(test<in_t>(0))::value;
|
||||
};
|
||||
|
||||
struct empty_serializer
|
||||
{
|
||||
// sample:
|
||||
// json::value operator()(const type_1&) const { return ...; }
|
||||
// json::value operator()(const type_2&) const { return ...; }
|
||||
// json::value operator()(const type_3&) const { return ...; }
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
void unable_to_serialize()
|
||||
{
|
||||
static_assert(
|
||||
!sizeof(T),
|
||||
"Unable to serialize T. "
|
||||
#ifdef _MSC_VER
|
||||
"See T below: " __FUNCSIG__
|
||||
#else
|
||||
// "See T below: " __PRETTY_FUNCTION__
|
||||
|
||||
#endif
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
namespace _serialization_helper
|
||||
{
|
||||
template <typename out_t, typename deserializer_t, typename string_t = default_string_t>
|
||||
class is_deserializable
|
||||
{
|
||||
template <typename U>
|
||||
static auto test(int)
|
||||
-> decltype(std::declval<deserializer_t>()(std::declval<basic_value<string_t>>(), std::declval<U&>()), std::true_type());
|
||||
|
||||
template <typename U>
|
||||
static std::false_type test(...);
|
||||
|
||||
public:
|
||||
static constexpr bool value = decltype(test<out_t>(0))::value;
|
||||
};
|
||||
|
||||
struct empty_deserializer
|
||||
{
|
||||
// sample:
|
||||
// bool operator()(const json::value&, type_1&) const { return ...; }
|
||||
// bool operator()(const json::value&, type_2&) const { return ...; }
|
||||
// bool operator()(const json::value&, type_3&) const { return ...; }
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
void unable_to_deserialize()
|
||||
{
|
||||
static_assert(
|
||||
!sizeof(T),
|
||||
"Unable to deserialize T. "
|
||||
#ifdef _MSC_VER
|
||||
"See T below: " __FUNCSIG__
|
||||
#else
|
||||
// "See T below: " __PRETTY_FUNCTION__
|
||||
|
||||
#endif
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
template <
|
||||
typename in_t,
|
||||
typename serializer_t = _serialization_helper::empty_serializer,
|
||||
typename string_t = default_string_t>
|
||||
basic_value<string_t> serialize(in_t&& in, const serializer_t& serializer = {})
|
||||
{
|
||||
if constexpr (_serialization_helper::is_serializable<in_t, serializer_t>::value) {
|
||||
return serializer(std::forward<in_t>(in));
|
||||
}
|
||||
else if constexpr (
|
||||
_utils::is_collection<std::decay_t<in_t>> || _utils::is_fixed_array<std::decay_t<in_t>>) {
|
||||
basic_array<string_t> arr;
|
||||
for (auto&& elem : in) {
|
||||
using elem_t = decltype(elem);
|
||||
|
||||
auto j_elem =
|
||||
serialize<elem_t, serializer_t, string_t>(std::forward<elem_t>(elem), serializer);
|
||||
arr.emplace_back(std::move(j_elem));
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
else if constexpr (_utils::is_map<std::decay_t<in_t>>) {
|
||||
basic_object<string_t> obj;
|
||||
for (auto&& [key, elem] : in) {
|
||||
using key_t = decltype(key);
|
||||
using elem_t = decltype(elem);
|
||||
|
||||
auto j_elem =
|
||||
serialize<elem_t, serializer_t, string_t>(std::forward<elem_t>(elem), serializer);
|
||||
obj.emplace(std::forward<key_t>(key), std::move(j_elem));
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
else if constexpr (std::is_constructible_v<basic_value<string_t>, in_t>) {
|
||||
return basic_value<string_t>(std::forward<in_t>(in));
|
||||
}
|
||||
else {
|
||||
_serialization_helper::unable_to_serialize<in_t>();
|
||||
}
|
||||
}
|
||||
|
||||
template <
|
||||
typename out_t,
|
||||
typename deserializer_t = _serialization_helper::empty_deserializer,
|
||||
typename string_t = default_string_t>
|
||||
bool deserialize(
|
||||
const basic_value<string_t>& in,
|
||||
out_t& out,
|
||||
const deserializer_t& deserializer = {})
|
||||
{
|
||||
if constexpr (_serialization_helper::is_deserializable<out_t, deserializer_t>::value) {
|
||||
return deserializer(in, out);
|
||||
}
|
||||
else if constexpr (_utils::is_collection<std::decay_t<out_t>>) {
|
||||
if (!in.is_array()) {
|
||||
return false;
|
||||
}
|
||||
for (auto&& j_elem : in.as_array()) {
|
||||
using elem_t = typename out_t::value_type;
|
||||
elem_t elem {};
|
||||
if (!deserialize<elem_t, deserializer_t, string_t>(j_elem, elem, deserializer)) {
|
||||
return false;
|
||||
}
|
||||
if constexpr (_as_collection_helper::has_emplace_back<out_t>::value) {
|
||||
out.emplace_back(std::move(elem));
|
||||
}
|
||||
else {
|
||||
out.emplace(std::move(elem));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if constexpr (_utils::is_fixed_array<std::decay_t<out_t>>) {
|
||||
if (!in.is_array()) {
|
||||
return false;
|
||||
}
|
||||
auto&& in_as_arr = in.as_array();
|
||||
constexpr size_t out_size = _utils::fixed_array_size<out_t>;
|
||||
if (in_as_arr.size() != out_size) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < out_size; ++i) {
|
||||
auto&& j_elem = in_as_arr.at(i);
|
||||
using elem_t = typename out_t::value_type;
|
||||
elem_t elem {};
|
||||
if (!deserialize<elem_t, deserializer_t, string_t>(j_elem, elem, deserializer)) {
|
||||
return false;
|
||||
}
|
||||
out.at(i) = std::move(elem);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if constexpr (_utils::is_map<std::decay_t<out_t>>) {
|
||||
if (!in.is_object()) {
|
||||
return false;
|
||||
}
|
||||
for (auto&& [key, j_elem] : in.as_object()) {
|
||||
using elem_t = typename out_t::mapped_type;
|
||||
elem_t elem {};
|
||||
if (!deserialize<elem_t, deserializer_t, string_t>(j_elem, elem, deserializer)) {
|
||||
return false;
|
||||
}
|
||||
out.emplace(std::forward<decltype(key)>(key), std::move(elem));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if constexpr (std::is_constructible_v<out_t, basic_value<string_t>>) {
|
||||
out = out_t(in);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
_serialization_helper::unable_to_deserialize<out_t>();
|
||||
}
|
||||
}
|
||||
} // namespace json
|
||||
7
3rdparty/include/meojson/common/types.hpp
vendored
7
3rdparty/include/meojson/common/types.hpp
vendored
@@ -1,7 +0,0 @@
|
||||
// IWYU pragma: private, include <meojson/json.hpp>
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "array.hpp"
|
||||
#include "object.hpp"
|
||||
#include "value.hpp"
|
||||
473
3rdparty/include/meojson/common/utils.hpp
vendored
473
3rdparty/include/meojson/common/utils.hpp
vendored
@@ -1,473 +0,0 @@
|
||||
// IWYU pragma: private, include <meojson/json.hpp>
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <iomanip>
|
||||
#include <limits>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <variant>
|
||||
|
||||
namespace json
|
||||
{
|
||||
template <typename string_t>
|
||||
class basic_value;
|
||||
template <typename string_t>
|
||||
class basic_array;
|
||||
template <typename string_t>
|
||||
class basic_object;
|
||||
|
||||
using default_string_t = std::string;
|
||||
|
||||
using value = basic_value<default_string_t>;
|
||||
using array = basic_array<default_string_t>;
|
||||
using object = basic_object<default_string_t>;
|
||||
|
||||
using wvalue = basic_value<std::wstring>;
|
||||
using warray = basic_array<std::wstring>;
|
||||
using wobject = basic_object<std::wstring>;
|
||||
}
|
||||
|
||||
namespace json::ext
|
||||
{
|
||||
template <typename string_t, typename T, typename = void>
|
||||
class jsonization
|
||||
{
|
||||
public:
|
||||
// json::value to_json(const T&) const;
|
||||
// bool check_json(const json::value&) const;
|
||||
// bool from_json(const json::value&, T&) const;
|
||||
};
|
||||
}
|
||||
|
||||
namespace json::_utils
|
||||
{
|
||||
template <typename T>
|
||||
using iterator_t = decltype(std::declval<T&>().begin());
|
||||
template <typename T>
|
||||
using remove_cvref_t = std::remove_cv_t<std::remove_reference_t<T>>;
|
||||
template <typename T>
|
||||
using iter_value_t = typename std::iterator_traits<remove_cvref_t<T>>::value_type;
|
||||
template <typename R>
|
||||
using range_value_t = iter_value_t<iterator_t<R>>;
|
||||
|
||||
template <typename T, typename = void>
|
||||
constexpr bool is_string = false;
|
||||
template <typename T>
|
||||
constexpr bool is_string<T, std::void_t<typename T::traits_type>> =
|
||||
std::is_same_v<typename T::traits_type, std::char_traits<typename T::value_type>>;
|
||||
|
||||
template <typename T, typename = void>
|
||||
constexpr bool is_container = false;
|
||||
template <typename T>
|
||||
constexpr bool is_container<T, std::void_t<typename T::value_type, range_value_t<T>>> =
|
||||
std::is_same_v<typename T::value_type, range_value_t<T>> && !is_string<T>;
|
||||
|
||||
template <typename T, typename = void>
|
||||
constexpr bool is_map = false;
|
||||
template <typename T>
|
||||
constexpr bool is_map<T, std::void_t<typename T::key_type, typename T::mapped_type>> =
|
||||
is_container<T>;
|
||||
|
||||
template <typename T, typename = void>
|
||||
constexpr bool is_fixed_array = false;
|
||||
template <template <typename, size_t> typename arr_t, typename value_t, size_t size>
|
||||
constexpr bool is_fixed_array<arr_t<value_t, size>> = true;
|
||||
|
||||
template <typename T, typename = std::enable_if_t<is_fixed_array<T>>>
|
||||
constexpr size_t fixed_array_size = 0;
|
||||
template <template <typename, size_t> typename arr_t, typename value_t, size_t size>
|
||||
constexpr size_t fixed_array_size<arr_t<value_t, size>> = size;
|
||||
|
||||
template <typename T, typename = void>
|
||||
constexpr bool is_collection = false;
|
||||
template <typename T>
|
||||
constexpr bool is_collection<T> = is_container<T> && !is_map<T> && !is_fixed_array<T>;
|
||||
|
||||
template <typename T>
|
||||
constexpr bool is_variant = false;
|
||||
template <typename... args_t>
|
||||
constexpr bool is_variant<std::variant<args_t...>> = true;
|
||||
|
||||
template <typename T>
|
||||
constexpr bool is_tuple = false;
|
||||
template <typename... args_t>
|
||||
constexpr bool is_tuple<std::tuple<args_t...>> = true;
|
||||
|
||||
template <typename T>
|
||||
constexpr bool is_pair = false;
|
||||
template <typename... args_t>
|
||||
constexpr bool is_pair<std::pair<args_t...>> = true;
|
||||
|
||||
template <typename T, typename = void>
|
||||
constexpr bool is_tuple_like = false;
|
||||
template <template <typename...> typename tuple_t, typename... args_t>
|
||||
constexpr bool is_tuple_like<
|
||||
tuple_t<args_t...>,
|
||||
std::void_t<decltype(std::tuple_size<tuple_t<args_t...>>::value)>> =
|
||||
std::tuple_size<tuple_t<args_t...>>::value == sizeof...(args_t);
|
||||
|
||||
template <typename T>
|
||||
class has_emplace_back
|
||||
{
|
||||
template <typename U>
|
||||
static auto test(int) -> decltype(std::declval<U>().emplace_back(), std::true_type());
|
||||
|
||||
template <typename U>
|
||||
static std::false_type test(...);
|
||||
|
||||
public:
|
||||
static constexpr bool value = decltype(test<T>(0))::value;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class has_to_json_in_member
|
||||
{
|
||||
template <typename U>
|
||||
static auto test(int) -> decltype(std::declval<U>().to_json(), std::true_type());
|
||||
|
||||
template <typename U>
|
||||
static std::false_type test(...);
|
||||
|
||||
public:
|
||||
static constexpr bool value = decltype(test<T>(0))::value;
|
||||
};
|
||||
|
||||
template <typename T, typename string_t>
|
||||
class has_check_json_in_member
|
||||
{
|
||||
template <typename U>
|
||||
static auto test(int)
|
||||
-> decltype(std::declval<U>().check_json(std::declval<json::basic_value<string_t>>()), std::true_type());
|
||||
|
||||
template <typename U>
|
||||
static std::false_type test(...);
|
||||
|
||||
public:
|
||||
static constexpr bool value = decltype(test<T>(0))::value;
|
||||
};
|
||||
|
||||
template <typename T, typename string_t>
|
||||
class has_from_json_in_member
|
||||
{
|
||||
template <typename U>
|
||||
static auto test(int)
|
||||
-> decltype(std::declval<U>().from_json(std::declval<json::basic_value<string_t>>()), std::true_type());
|
||||
|
||||
template <typename U>
|
||||
static std::false_type test(...);
|
||||
|
||||
public:
|
||||
static constexpr bool value = decltype(test<T>(0))::value;
|
||||
};
|
||||
|
||||
template <typename T, typename string_t>
|
||||
class has_to_json_in_templ_spec
|
||||
{
|
||||
template <typename U>
|
||||
static auto test(int)
|
||||
-> decltype(std::declval<ext::jsonization<string_t, U>>().to_json(std::declval<U>()), std::true_type());
|
||||
|
||||
template <typename U>
|
||||
static std::false_type test(...);
|
||||
|
||||
public:
|
||||
static constexpr bool value = decltype(test<T>(0))::value;
|
||||
};
|
||||
|
||||
template <typename T, typename string_t>
|
||||
class has_check_json_in_templ_spec
|
||||
{
|
||||
template <typename U>
|
||||
static auto test(int)
|
||||
-> decltype(std::declval<ext::jsonization<string_t, U>>().check_json(std::declval<json::basic_value<string_t>>()), std::true_type());
|
||||
|
||||
template <typename U>
|
||||
static std::false_type test(...);
|
||||
|
||||
public:
|
||||
static constexpr bool value = decltype(test<T>(0))::value;
|
||||
};
|
||||
|
||||
template <typename T, typename string_t>
|
||||
class has_from_json_in_templ_spec
|
||||
{
|
||||
template <typename U>
|
||||
static auto test(int)
|
||||
-> decltype(std::declval<ext::jsonization<string_t, U>>().from_json(std::declval<json::basic_value<string_t>>(), std::declval<U&>()), std::true_type());
|
||||
|
||||
template <typename U>
|
||||
static std::false_type test(...);
|
||||
|
||||
public:
|
||||
static constexpr bool value = decltype(test<T>(0))::value;
|
||||
};
|
||||
|
||||
template <typename T, typename string_t>
|
||||
class has_move_to_json_in_templ_spec
|
||||
{
|
||||
template <typename U>
|
||||
static auto test(int)
|
||||
-> decltype(std::declval<ext::jsonization<string_t, U>>().move_to_json(std::declval<U>()), std::true_type());
|
||||
|
||||
template <typename U>
|
||||
static std::false_type test(...);
|
||||
|
||||
public:
|
||||
static constexpr bool value = decltype(test<T>(0))::value;
|
||||
};
|
||||
|
||||
template <typename T, typename string_t>
|
||||
class has_move_from_json_in_templ_spec
|
||||
{
|
||||
template <typename U>
|
||||
static auto test(int)
|
||||
-> decltype(std::declval<ext::jsonization<string_t, U>>().move_from_json(std::declval<json::basic_value<string_t>>(), std::declval<U&>()), std::true_type());
|
||||
|
||||
template <typename U>
|
||||
static std::false_type test(...);
|
||||
|
||||
public:
|
||||
static constexpr bool value = decltype(test<T>(0))::value;
|
||||
};
|
||||
|
||||
template <typename T, typename string_t>
|
||||
class has_to_json_array_in_templ_spec
|
||||
{
|
||||
template <typename U>
|
||||
static auto test(int)
|
||||
-> decltype(std::declval<ext::jsonization<string_t, U>>().to_json_array(std::declval<U>()), std::true_type());
|
||||
|
||||
template <typename U>
|
||||
static std::false_type test(...);
|
||||
|
||||
public:
|
||||
static constexpr bool value = decltype(test<T>(0))::value;
|
||||
};
|
||||
|
||||
template <typename T, typename string_t>
|
||||
class has_check_json_array_in_templ_spec
|
||||
{
|
||||
template <typename U>
|
||||
static auto test(int)
|
||||
-> decltype(std::declval<ext::jsonization<string_t, U>>().check_json_array(std::declval<json::basic_array<string_t>>()), std::true_type());
|
||||
|
||||
template <typename U>
|
||||
static std::false_type test(...);
|
||||
|
||||
public:
|
||||
static constexpr bool value = decltype(test<T>(0))::value;
|
||||
};
|
||||
|
||||
template <typename T, typename string_t>
|
||||
class has_from_json_array_in_templ_spec
|
||||
{
|
||||
template <typename U>
|
||||
static auto test(int)
|
||||
-> decltype(std::declval<ext::jsonization<string_t, U>>().from_json_array(std::declval<json::basic_array<string_t>>(), std::declval<U&>()), std::true_type());
|
||||
|
||||
template <typename U>
|
||||
static std::false_type test(...);
|
||||
|
||||
public:
|
||||
static constexpr bool value = decltype(test<T>(0))::value;
|
||||
};
|
||||
|
||||
template <typename T, typename string_t>
|
||||
class has_move_to_json_array_in_templ_spec
|
||||
{
|
||||
template <typename U>
|
||||
static auto test(int)
|
||||
-> decltype(std::declval<ext::jsonization<string_t, U>>().move_to_json_array(std::declval<U>()), std::true_type());
|
||||
|
||||
template <typename U>
|
||||
static std::false_type test(...);
|
||||
|
||||
public:
|
||||
static constexpr bool value = decltype(test<T>(0))::value;
|
||||
};
|
||||
|
||||
template <typename T, typename string_t>
|
||||
class has_move_from_json_array_in_templ_spec
|
||||
{
|
||||
template <typename U>
|
||||
static auto test(int)
|
||||
-> decltype(std::declval<ext::jsonization<string_t, U>>().move_from_json_array(std::declval<json::basic_array<string_t>>(), std::declval<U&>()), std::true_type());
|
||||
|
||||
template <typename U>
|
||||
static std::false_type test(...);
|
||||
|
||||
public:
|
||||
static constexpr bool value = decltype(test<T>(0))::value;
|
||||
};
|
||||
|
||||
template <typename T, typename string_t>
|
||||
class has_to_json_object_in_templ_spec
|
||||
{
|
||||
template <typename U>
|
||||
static auto test(int)
|
||||
-> decltype(std::declval<ext::jsonization<string_t, U>>().to_json_object(std::declval<U>()), std::true_type());
|
||||
|
||||
template <typename U>
|
||||
static std::false_type test(...);
|
||||
|
||||
public:
|
||||
static constexpr bool value = decltype(test<T>(0))::value;
|
||||
};
|
||||
|
||||
template <typename T, typename string_t>
|
||||
class has_check_json_object_in_templ_spec
|
||||
{
|
||||
template <typename U>
|
||||
static auto test(int)
|
||||
-> decltype(std::declval<ext::jsonization<string_t, U>>().check_json_object(std::declval<json::basic_object<string_t>>()), std::true_type());
|
||||
|
||||
template <typename U>
|
||||
static std::false_type test(...);
|
||||
|
||||
public:
|
||||
static constexpr bool value = decltype(test<T>(0))::value;
|
||||
};
|
||||
|
||||
template <typename T, typename string_t>
|
||||
class has_from_json_object_in_templ_spec
|
||||
{
|
||||
template <typename U>
|
||||
static auto test(int)
|
||||
-> decltype(std::declval<ext::jsonization<string_t, U>>().from_json_object(std::declval<json::basic_object<string_t>>(), std::declval<U&>()), std::true_type());
|
||||
|
||||
template <typename U>
|
||||
static std::false_type test(...);
|
||||
|
||||
public:
|
||||
static constexpr bool value = decltype(test<T>(0))::value;
|
||||
};
|
||||
|
||||
template <typename T, typename string_t>
|
||||
class has_move_to_json_object_in_templ_spec
|
||||
{
|
||||
template <typename U>
|
||||
static auto test(int)
|
||||
-> decltype(std::declval<ext::jsonization<string_t, U>>().move_to_json_object(std::declval<U>()), std::true_type());
|
||||
|
||||
template <typename U>
|
||||
static std::false_type test(...);
|
||||
|
||||
public:
|
||||
static constexpr bool value = decltype(test<T>(0))::value;
|
||||
};
|
||||
|
||||
template <typename T, typename string_t>
|
||||
class has_move_from_json_object_in_templ_spec
|
||||
{
|
||||
template <typename U>
|
||||
static auto test(int)
|
||||
-> decltype(std::declval<ext::jsonization<string_t, U>>().move_from_json_object(std::declval<json::basic_object<string_t>>(), std::declval<U&>()), std::true_type());
|
||||
|
||||
template <typename U>
|
||||
static std::false_type test(...);
|
||||
|
||||
public:
|
||||
static constexpr bool value = decltype(test<T>(0))::value;
|
||||
};
|
||||
|
||||
template <typename string_t>
|
||||
inline constexpr string_t unescape_string(const string_t& str)
|
||||
{
|
||||
using char_t = typename string_t::value_type;
|
||||
|
||||
string_t result {};
|
||||
auto cur = str.cbegin();
|
||||
auto end = str.cend();
|
||||
auto no_escape_beg = cur;
|
||||
char_t escape = 0;
|
||||
|
||||
for (; cur != end; ++cur) {
|
||||
switch (*cur) {
|
||||
case '"':
|
||||
escape = '"';
|
||||
break;
|
||||
case '\\':
|
||||
escape = '\\';
|
||||
break;
|
||||
case '\b':
|
||||
escape = 'b';
|
||||
break;
|
||||
case '\f':
|
||||
escape = 'f';
|
||||
break;
|
||||
case '\n':
|
||||
escape = 'n';
|
||||
break;
|
||||
case '\r':
|
||||
escape = 'r';
|
||||
break;
|
||||
case '\t':
|
||||
escape = 't';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (escape) {
|
||||
result += string_t(no_escape_beg, cur) + char_t('\\') + escape;
|
||||
no_escape_beg = cur + 1;
|
||||
escape = 0;
|
||||
}
|
||||
}
|
||||
result += string_t(no_escape_beg, cur);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline constexpr string_t true_string()
|
||||
{
|
||||
return { 't', 'r', 'u', 'e' };
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline constexpr string_t false_string()
|
||||
{
|
||||
return { 'f', 'a', 'l', 's', 'e' };
|
||||
}
|
||||
|
||||
template <typename string_t>
|
||||
inline constexpr string_t null_string()
|
||||
{
|
||||
return { 'n', 'u', 'l', 'l' };
|
||||
}
|
||||
|
||||
template <typename string_t, typename any_t>
|
||||
inline string_t to_basic_string(any_t&& arg)
|
||||
{
|
||||
#ifdef MEOJSON_KEEP_FLOATING_PRECISION
|
||||
using real_type = std::remove_reference_t<any_t>;
|
||||
if constexpr (std::is_floating_point_v<real_type>) {
|
||||
if constexpr (std::is_same_v<string_t, std::string>) {
|
||||
std::ostringstream oss;
|
||||
oss << std::setprecision(std::numeric_limits<real_type>::max_digits10) << arg;
|
||||
return oss.str();
|
||||
}
|
||||
else if constexpr (std::is_same_v<string_t, std::wstring>) {
|
||||
std::wostringstream oss;
|
||||
oss << std::setprecision(std::numeric_limits<real_type>::max_digits10) << arg;
|
||||
return oss.str();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if constexpr (std::is_same_v<string_t, std::string>) {
|
||||
return std::to_string(std::forward<any_t>(arg));
|
||||
}
|
||||
else if constexpr (std::is_same_v<string_t, std::wstring>) {
|
||||
return std::to_wstring(std::forward<any_t>(arg));
|
||||
}
|
||||
else {
|
||||
static_assert(!sizeof(any_t), "Unsupported type");
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace json::_utils
|
||||
|
||||
#include "../reflection/extensions.hpp"
|
||||
1142
3rdparty/include/meojson/common/value.hpp
vendored
1142
3rdparty/include/meojson/common/value.hpp
vendored
File diff suppressed because it is too large
Load Diff
2742
3rdparty/include/meojson/json.hpp
vendored
2742
3rdparty/include/meojson/json.hpp
vendored
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,3 @@
|
||||
// IWYU pragma: private, include <meojson/json.hpp>
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
@@ -30,13 +28,11 @@ struct packed_bytes
|
||||
};
|
||||
}
|
||||
|
||||
#ifndef MEOJSON_DISABLE_PACKED_BYTES
|
||||
#if defined(__SSE2__) || defined(_M_X64) || (defined(_M_IX86_FP) && _M_IX86_FP)
|
||||
#include "packed_bytes_x86.hpp"
|
||||
#elif defined(__ARM_NEON) || defined(_M_ARM) || defined(_M_ARM64)
|
||||
#include "packed_bytes_arm.hpp"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace json::_packed_bytes
|
||||
{
|
||||
@@ -70,19 +66,14 @@ struct packed_bytes_trait_uint64
|
||||
return is_zero_memberwise((x) ^ (UINT64_C(0x0101010101010101) * (n)));
|
||||
}
|
||||
|
||||
__packed_bytes_strong_inline static value_type bitwise_or(value_type a, value_type b)
|
||||
{
|
||||
return a | b;
|
||||
}
|
||||
__packed_bytes_strong_inline static value_type bitwise_or(value_type a, value_type b) { return a | b; }
|
||||
|
||||
__packed_bytes_strong_inline static size_t first_nonzero_byte(value_type x)
|
||||
{
|
||||
if (_bitops::is_little_endian()) {
|
||||
if (_bitops::is_little_endian())
|
||||
return _bitops::countr_zero(x) / 8;
|
||||
}
|
||||
else {
|
||||
else
|
||||
return _bitops::countl_zero(x) / 8;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -117,22 +108,16 @@ struct packed_bytes_trait_uint32
|
||||
return is_zero_memberwise((x) ^ (~UINT32_C(0) / 255 * (n)));
|
||||
}
|
||||
|
||||
__packed_bytes_strong_inline static value_type bitwise_or(value_type a, value_type b)
|
||||
{
|
||||
return a | b;
|
||||
}
|
||||
__packed_bytes_strong_inline static value_type bitwise_or(value_type a, value_type b) { return a | b; }
|
||||
|
||||
__packed_bytes_strong_inline static size_t first_nonzero_byte(value_type x)
|
||||
{
|
||||
if (_bitops::is_little_endian()) {
|
||||
if (_bitops::is_little_endian())
|
||||
return _bitops::countr_zero(x) / 8;
|
||||
}
|
||||
else {
|
||||
else
|
||||
return _bitops::countl_zero(x) / 8;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct packed_bytes<8>
|
||||
{
|
||||
@@ -148,14 +133,10 @@ struct packed_bytes<4>
|
||||
template <size_t N>
|
||||
using packed_bytes_trait = typename packed_bytes<N>::traits;
|
||||
|
||||
using packed_bytes_trait_max = std::conditional_t<
|
||||
packed_bytes_trait<32>::available,
|
||||
packed_bytes_trait<32>,
|
||||
std::conditional_t<
|
||||
packed_bytes_trait<16>::available,
|
||||
packed_bytes_trait<16>,
|
||||
std::conditional_t<
|
||||
packed_bytes_trait<8>::available,
|
||||
packed_bytes_trait<8>,
|
||||
packed_bytes_trait<4>>>>;
|
||||
using packed_bytes_trait_max =
|
||||
std::conditional_t<packed_bytes_trait<32>::available, packed_bytes_trait<32>,
|
||||
std::conditional_t<packed_bytes_trait<16>::available, packed_bytes_trait<16>,
|
||||
std::conditional_t<packed_bytes_trait<8>::available, packed_bytes_trait<8>,
|
||||
packed_bytes_trait<4>>>>;
|
||||
|
||||
} // namespace json::_packed_bytes
|
||||
@@ -1,5 +1,3 @@
|
||||
// IWYU pragma: private, include <meojson/json.hpp>
|
||||
|
||||
#pragma once
|
||||
|
||||
// current NEON implementation doesn't outperform 64-bit scalar implementation
|
||||
@@ -19,10 +17,7 @@ struct packed_bytes_trait_neon
|
||||
static constexpr auto step = 16;
|
||||
using value_type = uint8x16_t;
|
||||
|
||||
__packed_bytes_strong_inline static value_type load_unaligned(const void* ptr)
|
||||
{
|
||||
return vld1q_u8((uint8_t*)ptr);
|
||||
}
|
||||
__packed_bytes_strong_inline static value_type load_unaligned(const void* ptr) { return vld1q_u8((uint8_t*)ptr); }
|
||||
|
||||
__packed_bytes_strong_inline static value_type less(value_type x, uint8_t n)
|
||||
{
|
||||
@@ -31,31 +26,19 @@ struct packed_bytes_trait_neon
|
||||
return is_less;
|
||||
}
|
||||
|
||||
__packed_bytes_strong_inline static value_type equal(value_type x, uint8_t n)
|
||||
{
|
||||
return vceqq_u8(x, vdupq_n_u8(n));
|
||||
}
|
||||
__packed_bytes_strong_inline static value_type equal(value_type x, uint8_t n) { return vceqq_u8(x, vdupq_n_u8(n)); }
|
||||
|
||||
__packed_bytes_strong_inline static value_type equal(value_type x, value_type y)
|
||||
{
|
||||
return vceqq_u8(x, y);
|
||||
}
|
||||
__packed_bytes_strong_inline static value_type equal(value_type x, value_type y) { return vceqq_u8(x, y); }
|
||||
|
||||
__packed_bytes_strong_inline static value_type bitwise_or(value_type a, value_type b)
|
||||
{
|
||||
return vorrq_u8(a, b);
|
||||
}
|
||||
__packed_bytes_strong_inline static value_type bitwise_or(value_type a, value_type b) { return vorrq_u8(a, b); }
|
||||
|
||||
__packed_bytes_strong_inline static bool is_all_zero(value_type x)
|
||||
{
|
||||
#ifdef __packed_bytes_trait_arm64
|
||||
return vmaxvq_u8(x) == 0;
|
||||
#else
|
||||
auto fold64 = vorr_u64(
|
||||
vget_high_u64(vreinterpretq_u8_u64(x), 0),
|
||||
vget_low_u64(vreinterpretq_u8_u64(x), 1));
|
||||
auto fold32 = vget_lane_u32(vreinterpret_u64_u32(fold64), 0)
|
||||
| vget_lane_u32(vreinterpret_u64_u32(fold64), 1);
|
||||
auto fold64 = vorr_u64(vget_high_u64(vreinterpretq_u8_u64(x), 0), vget_low_u64(vreinterpretq_u8_u64(x), 1));
|
||||
auto fold32 = vget_lane_u32(vreinterpret_u64_u32(fold64), 0) | vget_lane_u32(vreinterpret_u64_u32(fold64), 1);
|
||||
return fold32 == 0;
|
||||
#endif
|
||||
}
|
||||
@@ -1,7 +1,4 @@
|
||||
// IWYU pragma: private, include <meojson/json.hpp>
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "packed_bytes.hpp"
|
||||
|
||||
#include <emmintrin.h>
|
||||
@@ -38,15 +35,9 @@ struct packed_bytes_trait_sse
|
||||
return _mm_cmpeq_epi8(x, _mm_set1_epi8(static_cast<char>(n)));
|
||||
}
|
||||
|
||||
__packed_bytes_strong_inline static value_type equal(value_type x, value_type y)
|
||||
{
|
||||
return _mm_cmpeq_epi8(x, y);
|
||||
}
|
||||
__packed_bytes_strong_inline static value_type equal(value_type x, value_type y) { return _mm_cmpeq_epi8(x, y); }
|
||||
|
||||
__packed_bytes_strong_inline static value_type bitwise_or(value_type a, value_type b)
|
||||
{
|
||||
return _mm_or_si128(a, b);
|
||||
}
|
||||
__packed_bytes_strong_inline static value_type bitwise_or(value_type a, value_type b) { return _mm_or_si128(a, b); }
|
||||
|
||||
__packed_bytes_strong_inline static bool is_all_zero(value_type x)
|
||||
{
|
||||
@@ -106,20 +97,14 @@ struct packed_bytes_trait_avx2
|
||||
return _mm256_cmpeq_epi8(x, _mm256_set1_epi8(static_cast<char>(n)));
|
||||
}
|
||||
|
||||
__packed_bytes_strong_inline static value_type equal(value_type x, value_type y)
|
||||
{
|
||||
return _mm256_cmpeq_epi8(x, y);
|
||||
}
|
||||
__packed_bytes_strong_inline static value_type equal(value_type x, value_type y) { return _mm256_cmpeq_epi8(x, y); }
|
||||
|
||||
__packed_bytes_strong_inline static value_type bitwise_or(value_type a, value_type b)
|
||||
{
|
||||
return _mm256_or_si256(a, b);
|
||||
}
|
||||
|
||||
__packed_bytes_strong_inline static bool is_all_zero(value_type x)
|
||||
{
|
||||
return (bool)_mm256_testz_si256(x, x);
|
||||
}
|
||||
__packed_bytes_strong_inline static bool is_all_zero(value_type x) { return (bool)_mm256_testz_si256(x, x); }
|
||||
|
||||
__packed_bytes_strong_inline static size_t first_nonzero_byte(value_type x)
|
||||
{
|
||||
862
3rdparty/include/meojson/parser/parser.hpp
vendored
862
3rdparty/include/meojson/parser/parser.hpp
vendored
@@ -1,862 +0,0 @@
|
||||
// IWYU pragma: private, include <meojson/json.hpp>
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cctype>
|
||||
#include <fstream>
|
||||
#include <optional>
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
|
||||
#include "../common/types.hpp"
|
||||
#include "packed_bytes.hpp"
|
||||
|
||||
namespace json
|
||||
{
|
||||
// ****************************
|
||||
// * parser declare *
|
||||
// ****************************
|
||||
|
||||
template <
|
||||
bool accept_jsonc = false,
|
||||
typename string_t = default_string_t,
|
||||
typename parsing_t = void,
|
||||
typename accel_traits = _packed_bytes::packed_bytes_trait_max>
|
||||
class parser
|
||||
{
|
||||
public:
|
||||
using parsing_iter_t = typename parsing_t::const_iterator;
|
||||
|
||||
public:
|
||||
~parser() noexcept = default;
|
||||
|
||||
static std::optional<basic_value<string_t>> parse(const parsing_t& content);
|
||||
|
||||
private:
|
||||
parser(parsing_iter_t cbegin, parsing_iter_t cend) noexcept
|
||||
: _cur(cbegin)
|
||||
, _end(cend)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
std::optional<basic_value<string_t>> parse();
|
||||
basic_value<string_t> parse_value();
|
||||
|
||||
basic_value<string_t> parse_null();
|
||||
basic_value<string_t> parse_boolean();
|
||||
basic_value<string_t> parse_number();
|
||||
// parse and return a basic_value<string_t> whose type is value_type::string
|
||||
basic_value<string_t> parse_string();
|
||||
basic_value<string_t> parse_array();
|
||||
basic_value<string_t> parse_object();
|
||||
|
||||
// parse and return a string_t
|
||||
std::optional<string_t> parse_stdstring();
|
||||
|
||||
bool skip_string_literal_with_accel();
|
||||
bool skip_whitespace() noexcept;
|
||||
bool skip_comment() noexcept;
|
||||
bool skip_digit();
|
||||
bool skip_unicode_escape(uint16_t& pair_high, string_t& result);
|
||||
|
||||
private:
|
||||
parsing_iter_t _cur;
|
||||
parsing_iter_t _end;
|
||||
};
|
||||
|
||||
// ***************************
|
||||
// * utils declare *
|
||||
// ***************************
|
||||
|
||||
template <typename parsing_t>
|
||||
auto parse(const parsing_t& content);
|
||||
|
||||
template <typename char_t>
|
||||
auto parse(char_t* content);
|
||||
|
||||
template <typename parsing_t>
|
||||
auto parsec(const parsing_t& content);
|
||||
|
||||
template <typename char_t>
|
||||
auto parsec(char_t* content);
|
||||
|
||||
template <
|
||||
typename istream_t,
|
||||
typename = std::enable_if_t<
|
||||
std::is_base_of_v<std::basic_istream<typename istream_t::char_type>, istream_t>>>
|
||||
auto parse(istream_t& istream, bool check_bom = false, bool with_commets = false);
|
||||
|
||||
template <typename ifstream_t = std::ifstream, typename path_t = void>
|
||||
auto open(const path_t& path, bool check_bom = false, bool with_commets = false);
|
||||
|
||||
namespace literals
|
||||
{
|
||||
value operator""_json(const char* str, size_t len);
|
||||
wvalue operator""_json(const wchar_t* str, size_t len);
|
||||
|
||||
value operator""_jvalue(const char* str, size_t len);
|
||||
wvalue operator""_jvalue(const wchar_t* str, size_t len);
|
||||
|
||||
array operator""_jarray(const char* str, size_t len);
|
||||
warray operator""_jarray(const wchar_t* str, size_t len);
|
||||
|
||||
object operator""_jobject(const char* str, size_t len);
|
||||
wobject operator""_jobject(const wchar_t* str, size_t len);
|
||||
}
|
||||
|
||||
template <typename string_t = default_string_t>
|
||||
const basic_value<string_t> invalid_value();
|
||||
|
||||
// *************************
|
||||
// * parser impl *
|
||||
// *************************
|
||||
|
||||
template <bool accept_jsonc, typename string_t, typename parsing_t, typename accel_traits>
|
||||
inline std::optional<basic_value<string_t>>
|
||||
parser<accept_jsonc, string_t, parsing_t, accel_traits>::parse(const parsing_t& content)
|
||||
{
|
||||
return parser<accept_jsonc, string_t, parsing_t, accel_traits>(content.cbegin(), content.cend())
|
||||
.parse();
|
||||
}
|
||||
|
||||
template <bool accept_jsonc, typename string_t, typename parsing_t, typename accel_traits>
|
||||
inline std::optional<basic_value<string_t>>
|
||||
parser<accept_jsonc, string_t, parsing_t, accel_traits>::parse()
|
||||
{
|
||||
if (!skip_whitespace()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
basic_value<string_t> result_value;
|
||||
switch (*_cur) {
|
||||
case '[':
|
||||
result_value = parse_array();
|
||||
break;
|
||||
case '{':
|
||||
result_value = parse_object();
|
||||
break;
|
||||
default: // A JSON payload should be an basic_object or basic_array
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
if (!result_value.valid()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
// After the parsing is complete, there should be no more content other than spaces behind
|
||||
if (skip_whitespace()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return result_value;
|
||||
}
|
||||
|
||||
template <bool accept_jsonc, typename string_t, typename parsing_t, typename accel_traits>
|
||||
inline basic_value<string_t> parser<accept_jsonc, string_t, parsing_t, accel_traits>::parse_value()
|
||||
{
|
||||
switch (*_cur) {
|
||||
case 'n':
|
||||
return parse_null();
|
||||
case 't':
|
||||
case 'f':
|
||||
return parse_boolean();
|
||||
case '-':
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
return parse_number();
|
||||
case '"':
|
||||
return parse_string();
|
||||
case '[':
|
||||
return parse_array();
|
||||
case '{':
|
||||
return parse_object();
|
||||
default:
|
||||
return invalid_value<string_t>();
|
||||
}
|
||||
}
|
||||
|
||||
template <bool accept_jsonc, typename string_t, typename parsing_t, typename accel_traits>
|
||||
inline basic_value<string_t> parser<accept_jsonc, string_t, parsing_t, accel_traits>::parse_null()
|
||||
{
|
||||
for (const auto& ch : _utils::null_string<string_t>()) {
|
||||
if (_cur != _end && *_cur == ch) {
|
||||
++_cur;
|
||||
}
|
||||
else {
|
||||
return invalid_value<string_t>();
|
||||
}
|
||||
}
|
||||
|
||||
return basic_value<string_t>();
|
||||
}
|
||||
|
||||
template <bool accept_jsonc, typename string_t, typename parsing_t, typename accel_traits>
|
||||
inline basic_value<string_t>
|
||||
parser<accept_jsonc, string_t, parsing_t, accel_traits>::parse_boolean()
|
||||
{
|
||||
switch (*_cur) {
|
||||
case 't':
|
||||
for (const auto& ch : _utils::true_string<string_t>()) {
|
||||
if (_cur != _end && *_cur == ch) {
|
||||
++_cur;
|
||||
}
|
||||
else {
|
||||
return invalid_value<string_t>();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
case 'f':
|
||||
for (const auto& ch : _utils::false_string<string_t>()) {
|
||||
if (_cur != _end && *_cur == ch) {
|
||||
++_cur;
|
||||
}
|
||||
else {
|
||||
return invalid_value<string_t>();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
default:
|
||||
return invalid_value<string_t>();
|
||||
}
|
||||
}
|
||||
|
||||
template <bool accept_jsonc, typename string_t, typename parsing_t, typename accel_traits>
|
||||
inline basic_value<string_t> parser<accept_jsonc, string_t, parsing_t, accel_traits>::parse_number()
|
||||
{
|
||||
const auto first = _cur;
|
||||
if (*_cur == '-') {
|
||||
++_cur;
|
||||
}
|
||||
|
||||
// numbers cannot have leading zeroes
|
||||
if (_cur != _end && *_cur == '0' && _cur + 1 != _end && std::isdigit(*(_cur + 1))) {
|
||||
return invalid_value<string_t>();
|
||||
}
|
||||
|
||||
if (!skip_digit()) {
|
||||
return invalid_value<string_t>();
|
||||
}
|
||||
|
||||
if (*_cur == '.') {
|
||||
++_cur;
|
||||
if (!skip_digit()) {
|
||||
return invalid_value<string_t>();
|
||||
}
|
||||
}
|
||||
|
||||
if (*_cur == 'e' || *_cur == 'E') {
|
||||
if (++_cur == _end) {
|
||||
return invalid_value<string_t>();
|
||||
}
|
||||
if (*_cur == '+' || *_cur == '-') {
|
||||
++_cur;
|
||||
}
|
||||
if (!skip_digit()) {
|
||||
return invalid_value<string_t>();
|
||||
}
|
||||
}
|
||||
|
||||
return basic_value<string_t>(basic_value<string_t>::value_type::number, string_t(first, _cur));
|
||||
}
|
||||
|
||||
template <bool accept_jsonc, typename string_t, typename parsing_t, typename accel_traits>
|
||||
inline basic_value<string_t> parser<accept_jsonc, string_t, parsing_t, accel_traits>::parse_string()
|
||||
{
|
||||
auto string_opt = parse_stdstring();
|
||||
if (!string_opt) {
|
||||
return invalid_value<string_t>();
|
||||
}
|
||||
return basic_value<string_t>(
|
||||
basic_value<string_t>::value_type::string,
|
||||
std::move(string_opt).value());
|
||||
}
|
||||
|
||||
template <bool accept_jsonc, typename string_t, typename parsing_t, typename accel_traits>
|
||||
inline basic_value<string_t> parser<accept_jsonc, string_t, parsing_t, accel_traits>::parse_array()
|
||||
{
|
||||
if (*_cur == '[') {
|
||||
++_cur;
|
||||
}
|
||||
else {
|
||||
return invalid_value<string_t>();
|
||||
}
|
||||
|
||||
if (!skip_whitespace()) {
|
||||
return invalid_value<string_t>();
|
||||
}
|
||||
else if (*_cur == ']') {
|
||||
++_cur;
|
||||
// empty basic_array
|
||||
return basic_array<string_t>();
|
||||
}
|
||||
|
||||
typename basic_array<string_t>::raw_array result;
|
||||
while (true) {
|
||||
if (!skip_whitespace()) {
|
||||
return invalid_value<string_t>();
|
||||
}
|
||||
|
||||
if constexpr (accept_jsonc) {
|
||||
if (*_cur == ']') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
basic_value<string_t> val = parse_value();
|
||||
|
||||
if (!val.valid() || !skip_whitespace()) {
|
||||
return invalid_value<string_t>();
|
||||
}
|
||||
|
||||
result.emplace_back(std::move(val));
|
||||
|
||||
if (*_cur == ',') {
|
||||
++_cur;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (skip_whitespace() && *_cur == ']') {
|
||||
++_cur;
|
||||
}
|
||||
else {
|
||||
return invalid_value<string_t>();
|
||||
}
|
||||
|
||||
return basic_array<string_t>(std::move(result));
|
||||
}
|
||||
|
||||
template <bool accept_jsonc, typename string_t, typename parsing_t, typename accel_traits>
|
||||
inline basic_value<string_t> parser<accept_jsonc, string_t, parsing_t, accel_traits>::parse_object()
|
||||
{
|
||||
if (*_cur == '{') {
|
||||
++_cur;
|
||||
}
|
||||
else {
|
||||
return invalid_value<string_t>();
|
||||
}
|
||||
|
||||
if (!skip_whitespace()) {
|
||||
return invalid_value<string_t>();
|
||||
}
|
||||
else if (*_cur == '}') {
|
||||
++_cur;
|
||||
// empty basic_object
|
||||
return basic_object<string_t>();
|
||||
}
|
||||
|
||||
typename basic_object<string_t>::raw_object result;
|
||||
while (true) {
|
||||
if (!skip_whitespace()) {
|
||||
return invalid_value<string_t>();
|
||||
}
|
||||
|
||||
if constexpr (accept_jsonc) {
|
||||
if (*_cur == '}') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
auto key_opt = parse_stdstring();
|
||||
|
||||
if (key_opt && skip_whitespace() && *_cur == ':') {
|
||||
++_cur;
|
||||
}
|
||||
else {
|
||||
return invalid_value<string_t>();
|
||||
}
|
||||
|
||||
if (!skip_whitespace()) {
|
||||
return invalid_value<string_t>();
|
||||
}
|
||||
|
||||
basic_value<string_t> val = parse_value();
|
||||
|
||||
if (!val.valid() || !skip_whitespace()) {
|
||||
return invalid_value<string_t>();
|
||||
}
|
||||
|
||||
auto emplaced = result.emplace(std::move(*key_opt), std::move(val)).second;
|
||||
if (!emplaced) {
|
||||
return invalid_value<string_t>();
|
||||
}
|
||||
|
||||
if (*_cur == ',') {
|
||||
++_cur;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (skip_whitespace() && *_cur == '}') {
|
||||
++_cur;
|
||||
}
|
||||
else {
|
||||
return invalid_value<string_t>();
|
||||
}
|
||||
|
||||
return basic_object<string_t>(std::move(result));
|
||||
}
|
||||
|
||||
template <bool accept_jsonc, typename string_t, typename parsing_t, typename accel_traits>
|
||||
inline std::optional<string_t>
|
||||
parser<accept_jsonc, string_t, parsing_t, accel_traits>::parse_stdstring()
|
||||
{
|
||||
if (*_cur == '"') {
|
||||
++_cur;
|
||||
}
|
||||
else {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
string_t result;
|
||||
auto no_escape_beg = _cur;
|
||||
uint16_t pair_high = 0;
|
||||
|
||||
while (_cur != _end) {
|
||||
if constexpr (sizeof(*_cur) == 1 && accel_traits::available) {
|
||||
if (!skip_string_literal_with_accel()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
switch (*_cur) {
|
||||
case '\t':
|
||||
case '\r':
|
||||
case '\n':
|
||||
return std::nullopt;
|
||||
case '\\': {
|
||||
result += string_t(no_escape_beg, _cur++);
|
||||
if (_cur == _end) {
|
||||
return std::nullopt;
|
||||
}
|
||||
if (pair_high && *_cur != 'u') {
|
||||
return std::nullopt;
|
||||
}
|
||||
switch (*_cur) {
|
||||
case '"':
|
||||
result.push_back('"');
|
||||
break;
|
||||
case '\\':
|
||||
result.push_back('\\');
|
||||
break;
|
||||
case '/':
|
||||
result.push_back('/');
|
||||
break;
|
||||
case 'b':
|
||||
result.push_back('\b');
|
||||
break;
|
||||
case 'f':
|
||||
result.push_back('\f');
|
||||
break;
|
||||
case 'n':
|
||||
result.push_back('\n');
|
||||
break;
|
||||
case 'r':
|
||||
result.push_back('\r');
|
||||
break;
|
||||
case 't':
|
||||
result.push_back('\t');
|
||||
break;
|
||||
case 'u':
|
||||
if (!skip_unicode_escape(pair_high, result)) {
|
||||
return std::nullopt;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// Illegal backslash escape
|
||||
return std::nullopt;
|
||||
}
|
||||
no_escape_beg = ++_cur;
|
||||
break;
|
||||
}
|
||||
case '"': {
|
||||
if (pair_high) {
|
||||
return std::nullopt;
|
||||
}
|
||||
result += string_t(no_escape_beg, _cur++);
|
||||
return result;
|
||||
}
|
||||
default:
|
||||
if (pair_high) {
|
||||
return std::nullopt;
|
||||
}
|
||||
++_cur;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
template <bool accept_jsonc, typename string_t, typename parsing_t, typename accel_traits>
|
||||
inline bool parser<accept_jsonc, string_t, parsing_t, accel_traits>::skip_unicode_escape(
|
||||
uint16_t& pair_high,
|
||||
string_t& result)
|
||||
{
|
||||
uint16_t cp = 0;
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
if (++_cur == _end) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!std::isxdigit(static_cast<unsigned char>(*_cur))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
cp <<= 4;
|
||||
|
||||
if ('0' <= *_cur && *_cur <= '9') {
|
||||
cp |= *_cur - '0';
|
||||
}
|
||||
else if ('a' <= *_cur && *_cur <= 'f') {
|
||||
cp |= *_cur - 'a' + 10;
|
||||
}
|
||||
else if ('A' <= *_cur && *_cur <= 'F') {
|
||||
cp |= *_cur - 'A' + 10;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t ext_cp = cp;
|
||||
uint16_t hi_cp = 0, lo_cp = 0;
|
||||
|
||||
if (0xD800 <= cp && cp <= 0xDBFF) {
|
||||
if (pair_high) {
|
||||
return false;
|
||||
}
|
||||
pair_high = cp;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (0xDC00 <= cp && cp <= 0xDFFF) {
|
||||
if (!pair_high) {
|
||||
return false;
|
||||
}
|
||||
ext_cp = (((pair_high - 0xD800) << 10) | (cp - 0xDC00)) + 0x10000;
|
||||
hi_cp = pair_high;
|
||||
lo_cp = cp;
|
||||
pair_high = 0;
|
||||
}
|
||||
|
||||
if constexpr (std::is_same_v<typename string_t::value_type, char>) {
|
||||
// utf8
|
||||
if (ext_cp <= 0x7F) {
|
||||
result.push_back(static_cast<char>(ext_cp));
|
||||
}
|
||||
else if (ext_cp <= 0x7FF) {
|
||||
result.push_back(static_cast<char>(((ext_cp >> 6) & 0b00011111) | 0b11000000u));
|
||||
result.push_back(static_cast<char>((ext_cp & 0b00111111) | 0b10000000u));
|
||||
}
|
||||
else if (ext_cp <= 0xFFFF) {
|
||||
result.push_back(static_cast<char>(((ext_cp >> 12) & 0b00001111) | 0b11100000u));
|
||||
result.push_back(static_cast<char>(((ext_cp >> 6) & 0b00111111) | 0b10000000u));
|
||||
result.push_back(static_cast<char>((ext_cp & 0b00111111) | 0b10000000u));
|
||||
}
|
||||
else {
|
||||
result.push_back(static_cast<char>(((ext_cp >> 18) & 0b00000111) | 0b11110000u));
|
||||
result.push_back(static_cast<char>(((ext_cp >> 12) & 0b00111111) | 0b10000000u));
|
||||
result.push_back(static_cast<char>(((ext_cp >> 6) & 0b00111111) | 0b10000000u));
|
||||
result.push_back(static_cast<char>((ext_cp & 0b00111111) | 0b10000000u));
|
||||
}
|
||||
}
|
||||
else if constexpr (std::is_same_v<typename string_t::value_type, wchar_t>) {
|
||||
if constexpr (sizeof(wchar_t) == 4) {
|
||||
result.push_back(static_cast<wchar_t>(ext_cp));
|
||||
}
|
||||
else if constexpr (sizeof(wchar_t) == 2) {
|
||||
if (ext_cp <= 0xFFFF) {
|
||||
result.push_back(static_cast<wchar_t>(ext_cp));
|
||||
}
|
||||
else {
|
||||
result.push_back(static_cast<wchar_t>(hi_cp));
|
||||
result.push_back(static_cast<wchar_t>(lo_cp));
|
||||
}
|
||||
}
|
||||
else {
|
||||
static_assert(!sizeof(typename string_t::value_type), "Unsupported wchar");
|
||||
}
|
||||
}
|
||||
else {
|
||||
static_assert(!sizeof(typename string_t::value_type), "Unsupported type");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <bool accept_jsonc, typename string_t, typename parsing_t, typename accel_traits>
|
||||
inline bool
|
||||
parser<accept_jsonc, string_t, parsing_t, accel_traits>::skip_string_literal_with_accel()
|
||||
{
|
||||
if constexpr (sizeof(*_cur) != 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
while (_end - _cur >= accel_traits::step) {
|
||||
auto pack = accel_traits::load_unaligned(&(*_cur));
|
||||
auto result = accel_traits::less(pack, 32);
|
||||
result =
|
||||
accel_traits::bitwise_or(result, accel_traits::equal(pack, static_cast<uint8_t>('"')));
|
||||
result =
|
||||
accel_traits::bitwise_or(result, accel_traits::equal(pack, static_cast<uint8_t>('\\')));
|
||||
|
||||
if (accel_traits::is_all_zero(result)) {
|
||||
_cur += accel_traits::step;
|
||||
}
|
||||
else {
|
||||
auto index = accel_traits::first_nonzero_byte(result);
|
||||
_cur += index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return _cur != _end;
|
||||
}
|
||||
|
||||
template <bool accept_jsonc, typename string_t, typename parsing_t, typename accel_traits>
|
||||
inline bool parser<accept_jsonc, string_t, parsing_t, accel_traits>::skip_whitespace() noexcept
|
||||
{
|
||||
while (_cur != _end) {
|
||||
switch (*_cur) {
|
||||
case ' ':
|
||||
case '\t':
|
||||
case '\r':
|
||||
case '\n':
|
||||
++_cur;
|
||||
break;
|
||||
case '/':
|
||||
if constexpr (accept_jsonc) {
|
||||
if (!skip_comment()) {
|
||||
return false;
|
||||
}
|
||||
// else continue;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case '\0':
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template <bool accept_jsonc, typename string_t, typename parsing_t, typename accel_traits>
|
||||
bool json::parser<accept_jsonc, string_t, parsing_t, accel_traits>::skip_comment() noexcept
|
||||
{
|
||||
if (_cur == _end || *_cur != '/') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (++_cur == _end) {
|
||||
return false;
|
||||
}
|
||||
|
||||
enum class comment_type
|
||||
{
|
||||
invalid,
|
||||
line,
|
||||
block,
|
||||
} t = comment_type::invalid;
|
||||
|
||||
switch (*_cur++) {
|
||||
case '/':
|
||||
t = comment_type::line;
|
||||
break;
|
||||
case '*':
|
||||
t = comment_type::block;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
while (_cur != _end) {
|
||||
switch (*_cur++) {
|
||||
case '\n':
|
||||
if (t == comment_type::line) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case '*':
|
||||
if (t == comment_type::block && _cur != _end && *_cur == '/') {
|
||||
++_cur;
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// _cur == _end
|
||||
return t == comment_type::line;
|
||||
}
|
||||
|
||||
template <bool accept_jsonc, typename string_t, typename parsing_t, typename accel_traits>
|
||||
inline bool parser<accept_jsonc, string_t, parsing_t, accel_traits>::skip_digit()
|
||||
{
|
||||
// At least one digit
|
||||
if (_cur != _end && std::isdigit(*_cur)) {
|
||||
++_cur;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
while (_cur != _end && std::isdigit(*_cur)) {
|
||||
++_cur;
|
||||
}
|
||||
|
||||
if (_cur != _end) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// *************************
|
||||
// * utils impl *
|
||||
// *************************
|
||||
|
||||
template <typename parsing_t>
|
||||
auto parse(const parsing_t& content)
|
||||
{
|
||||
using string_t = std::basic_string<typename parsing_t::value_type>;
|
||||
return parser<false, string_t, parsing_t>::parse(content);
|
||||
}
|
||||
|
||||
template <typename char_t>
|
||||
auto parse(char_t* content)
|
||||
{
|
||||
return parse(std::basic_string_view<std::decay_t<char_t>> { content });
|
||||
}
|
||||
|
||||
template <typename istream_t, typename _>
|
||||
auto parse(istream_t& ifs, bool check_bom, bool with_commets)
|
||||
{
|
||||
using string_t = std::basic_string<typename istream_t::char_type>;
|
||||
|
||||
ifs.seekg(0, std::ios::end);
|
||||
auto file_size = ifs.tellg();
|
||||
|
||||
ifs.seekg(0, std::ios::beg);
|
||||
string_t str(file_size, '\0');
|
||||
|
||||
ifs.read(str.data(), file_size);
|
||||
|
||||
if (check_bom) {
|
||||
using uchar = unsigned char;
|
||||
static constexpr uchar Bom_0 = 0xEF;
|
||||
static constexpr uchar Bom_1 = 0xBB;
|
||||
static constexpr uchar Bom_2 = 0xBF;
|
||||
|
||||
if (str.size() >= 3 && static_cast<uchar>(str.at(0)) == Bom_0
|
||||
&& static_cast<uchar>(str.at(1)) == Bom_1 && static_cast<uchar>(str.at(2)) == Bom_2) {
|
||||
str.assign(str.begin() + 3, str.end());
|
||||
}
|
||||
}
|
||||
return with_commets ? parsec(str) : parse(str);
|
||||
}
|
||||
|
||||
template <typename ifstream_t, typename path_t>
|
||||
auto open(const path_t& filepath, bool check_bom, bool with_commets)
|
||||
{
|
||||
using char_t = typename ifstream_t::char_type;
|
||||
using string_t = std::basic_string<char_t>;
|
||||
using json_t = json::basic_value<string_t>;
|
||||
using return_t = std::optional<json_t>;
|
||||
|
||||
ifstream_t ifs(filepath, std::ios::in);
|
||||
if (!ifs.is_open()) {
|
||||
return return_t(std::nullopt);
|
||||
}
|
||||
auto opt = parse(ifs, check_bom, with_commets);
|
||||
ifs.close();
|
||||
return opt;
|
||||
}
|
||||
|
||||
template <typename parsing_t>
|
||||
auto parsec(const parsing_t& content)
|
||||
{
|
||||
using string_t = std::basic_string<typename parsing_t::value_type>;
|
||||
return parser<true, string_t, parsing_t>::parse(content);
|
||||
}
|
||||
|
||||
template <typename char_t>
|
||||
auto parsec(char_t* content)
|
||||
{
|
||||
return parsec(std::basic_string_view<std::decay_t<char_t>> { content });
|
||||
}
|
||||
|
||||
namespace literals
|
||||
{
|
||||
inline value operator""_json(const char* str, size_t len)
|
||||
{
|
||||
return operator""_jvalue(str, len);
|
||||
}
|
||||
|
||||
inline wvalue operator""_json(const wchar_t* str, size_t len)
|
||||
{
|
||||
return operator""_jvalue(str, len);
|
||||
}
|
||||
|
||||
inline value operator""_jvalue(const char* str, size_t len)
|
||||
{
|
||||
return parse(std::string_view(str, len)).value_or(value());
|
||||
}
|
||||
|
||||
inline wvalue operator""_jvalue(const wchar_t* str, size_t len)
|
||||
{
|
||||
return parse(std::wstring_view(str, len)).value_or(wvalue());
|
||||
}
|
||||
|
||||
inline array operator""_jarray(const char* str, size_t len)
|
||||
{
|
||||
auto val = parse(std::string_view(str, len)).value_or(value());
|
||||
return val.is_array() ? val.as_array() : array();
|
||||
}
|
||||
|
||||
inline warray operator""_jarray(const wchar_t* str, size_t len)
|
||||
{
|
||||
auto val = parse(std::wstring_view(str, len)).value_or(wvalue());
|
||||
return val.is_array() ? val.as_array() : warray();
|
||||
}
|
||||
|
||||
inline object operator""_jobject(const char* str, size_t len)
|
||||
{
|
||||
auto val = parse(std::string_view(str, len)).value_or(value());
|
||||
return val.is_object() ? val.as_object() : object();
|
||||
}
|
||||
|
||||
inline wobject operator""_jobject(const wchar_t* str, size_t len)
|
||||
{
|
||||
auto val = parse(std::wstring_view(str, len)).value_or(wvalue());
|
||||
return val.is_object() ? val.as_object() : wobject();
|
||||
}
|
||||
} // namespace literals
|
||||
|
||||
template <typename string_t>
|
||||
const basic_value<string_t> invalid_value()
|
||||
{
|
||||
return basic_value<string_t>(
|
||||
basic_value<string_t>::value_type::invalid,
|
||||
typename basic_value<string_t>::var_t());
|
||||
}
|
||||
} // namespace json
|
||||
656
3rdparty/include/meojson/reflection/extensions.hpp
vendored
656
3rdparty/include/meojson/reflection/extensions.hpp
vendored
@@ -1,656 +0,0 @@
|
||||
// IWYU pragma: private, include <meojson/json.hpp>
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <filesystem>
|
||||
#include <queue>
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <variant>
|
||||
|
||||
#include "../common/types.hpp"
|
||||
|
||||
namespace json::ext
|
||||
{
|
||||
|
||||
template <typename string_t, typename impl_t, typename var_t, size_t len> // (size_t)-1 for no
|
||||
// restriction
|
||||
class __jsonization_array
|
||||
{
|
||||
public:
|
||||
json::basic_value<string_t> to_json(const var_t& value) const
|
||||
{
|
||||
return static_cast<const impl_t*>(this)->to_json_array(value);
|
||||
}
|
||||
|
||||
bool check_json(const json::basic_value<string_t>& json) const
|
||||
{
|
||||
if (!json.is_array()) {
|
||||
return false;
|
||||
}
|
||||
const auto& arr = json.as_array();
|
||||
if constexpr (len != static_cast<size_t>(-1)) {
|
||||
if (len != arr.size()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return static_cast<const impl_t*>(this)->check_json_array(arr);
|
||||
}
|
||||
|
||||
bool from_json(const json::basic_value<string_t>& json, var_t& value) const
|
||||
{
|
||||
if (!json.is_array()) {
|
||||
return false;
|
||||
}
|
||||
const auto& arr = json.as_array();
|
||||
if constexpr (len != static_cast<size_t>(-1)) {
|
||||
if (len != arr.size()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return static_cast<const impl_t*>(this)->from_json_array(arr, value);
|
||||
}
|
||||
|
||||
json::basic_value<string_t> move_to_json(var_t value) const
|
||||
{
|
||||
return static_cast<const impl_t*>(this)->move_to_json_array(std::move(value));
|
||||
}
|
||||
|
||||
bool move_from_json(json::basic_value<string_t> json, var_t& value) const
|
||||
{
|
||||
if (!json.is_array()) {
|
||||
return false;
|
||||
}
|
||||
auto& arr = json.as_array();
|
||||
if constexpr (len != static_cast<size_t>(-1)) {
|
||||
if (len != arr.size()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return static_cast<const impl_t*>(this)->move_from_json_array(std::move(arr), value);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename string_t, typename impl_t, typename var_t>
|
||||
class __jsonization_object
|
||||
{
|
||||
public:
|
||||
json::basic_value<string_t> to_json(const var_t& value) const
|
||||
{
|
||||
return static_cast<const impl_t*>(this)->to_json_object(value);
|
||||
}
|
||||
|
||||
bool check_json(const json::basic_value<string_t>& json) const
|
||||
{
|
||||
if (!json.is_object()) {
|
||||
return false;
|
||||
}
|
||||
const auto& obj = json.as_object();
|
||||
return static_cast<const impl_t*>(this)->check_json_object(obj);
|
||||
}
|
||||
|
||||
bool from_json(const json::basic_value<string_t>& json, var_t& value) const
|
||||
{
|
||||
if (!json.is_object()) {
|
||||
return false;
|
||||
}
|
||||
const auto& obj = json.as_object();
|
||||
return static_cast<const impl_t*>(this)->from_json_object(obj, value);
|
||||
}
|
||||
|
||||
json::basic_value<string_t> move_to_json(var_t value) const
|
||||
{
|
||||
return static_cast<const impl_t*>(this)->move_to_json_object(std::move(value));
|
||||
}
|
||||
|
||||
bool move_from_json(json::basic_value<string_t> json, var_t& value) const
|
||||
{
|
||||
if (!json.is_object()) {
|
||||
return false;
|
||||
}
|
||||
auto& obj = json.as_object();
|
||||
return static_cast<const impl_t*>(this)->move_from_json_object(std::move(obj), value);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename string_t>
|
||||
class jsonization<string_t, std::nullptr_t>
|
||||
{
|
||||
public:
|
||||
json::basic_value<string_t> to_json(const std::nullptr_t&) const
|
||||
{
|
||||
return json::basic_value<string_t> {};
|
||||
}
|
||||
|
||||
bool check_json(const json::basic_value<string_t>& json) const { return json.is_null(); }
|
||||
|
||||
bool from_json(const json::basic_value<string_t>& json, std::nullptr_t&)
|
||||
{
|
||||
return check_json(json);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename string_t>
|
||||
class jsonization<
|
||||
string_t,
|
||||
std::filesystem::path,
|
||||
std::enable_if_t<
|
||||
std::is_same_v<string_t, std::filesystem::path::string_type>
|
||||
|| std::is_same_v<string_t, std::string>>>
|
||||
{
|
||||
public:
|
||||
json::basic_value<string_t> to_json(const std::filesystem::path& path) const
|
||||
{
|
||||
if constexpr (std::is_same_v<string_t, std::filesystem::path::string_type>) {
|
||||
return path.native();
|
||||
}
|
||||
else if constexpr (std::is_same_v<string_t, std::string>) {
|
||||
#if __cplusplus >= 202002L
|
||||
std::u8string u8str = path.u8string();
|
||||
return std::string { u8str.begin(), u8str.end() };
|
||||
#else
|
||||
return path.u8string();
|
||||
#endif
|
||||
}
|
||||
#if __cplusplus >= 202002L
|
||||
else if constexpr (std::is_same_v<string_t, std::u8string>) {
|
||||
return path.u8string();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool check_json(const json::basic_value<string_t>& json) const { return json.is_string(); }
|
||||
|
||||
bool from_json(const json::basic_value<string_t>& json, std::filesystem::path& path) const
|
||||
{
|
||||
path = json.as_string();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template <
|
||||
typename string_t,
|
||||
template <typename, size_t> typename arr_t,
|
||||
typename value_t,
|
||||
size_t size>
|
||||
class jsonization<string_t, arr_t<value_t, size>>
|
||||
: public __jsonization_array<
|
||||
string_t,
|
||||
jsonization<string_t, arr_t<value_t, size>>,
|
||||
arr_t<value_t, size>,
|
||||
size>
|
||||
{
|
||||
public:
|
||||
json::basic_array<string_t> to_json_array(const arr_t<value_t, size>& value) const
|
||||
{
|
||||
json::basic_array<string_t> result;
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
result.emplace_back(value.at(i));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool check_json_array(const json::basic_array<string_t>& arr) const
|
||||
{
|
||||
return arr.template all<value_t>();
|
||||
}
|
||||
|
||||
bool from_json_array(const json::basic_array<string_t>& arr, arr_t<value_t, size>& value) const
|
||||
{
|
||||
if (!check_json_array(arr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
value.at(i) = arr[i].template as<value_t>();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
json::basic_array<string_t> move_to_json_array(arr_t<value_t, size> value) const
|
||||
{
|
||||
json::basic_array<string_t> result;
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
result.emplace_back(std::move(value.at(i)));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool move_from_json_array(json::basic_array<string_t> arr, arr_t<value_t, size>& value) const
|
||||
{
|
||||
if (!check_json_array(arr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
value.at(i) = std::move(arr[i]).template as<value_t>();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename string_t, typename collection_t>
|
||||
class jsonization<string_t, collection_t, std::enable_if_t<_utils::is_collection<collection_t>>>
|
||||
: public __jsonization_array<
|
||||
string_t,
|
||||
jsonization<string_t, collection_t>,
|
||||
collection_t,
|
||||
(size_t)-1>
|
||||
{
|
||||
public:
|
||||
json::basic_array<string_t> to_json_array(const collection_t& value) const
|
||||
{
|
||||
json::basic_array<string_t> result;
|
||||
for (const auto& val : value) {
|
||||
result.emplace_back(val);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool check_json_array(const json::basic_array<string_t>& arr) const
|
||||
{
|
||||
return arr.template all<typename collection_t::value_type>();
|
||||
}
|
||||
|
||||
bool from_json_array(const json::basic_array<string_t>& arr, collection_t& value) const
|
||||
{
|
||||
if (!check_json_array(arr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
value = {};
|
||||
for (const auto& val : arr) {
|
||||
if constexpr (_utils::has_emplace_back<collection_t>::value) {
|
||||
value.emplace_back(val.template as<typename collection_t::value_type>());
|
||||
}
|
||||
else {
|
||||
value.emplace(val.template as<typename collection_t::value_type>());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
json::basic_array<string_t> move_to_json_array(collection_t value) const
|
||||
{
|
||||
json::basic_array<string_t> result;
|
||||
for (auto& val : value) {
|
||||
result.emplace_back(std::move(val));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool move_from_json_array(json::basic_array<string_t> arr, collection_t& value) const
|
||||
{
|
||||
if (!check_json_array(arr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (auto& val : arr) {
|
||||
if constexpr (_utils::has_emplace_back<collection_t>::value) {
|
||||
value.emplace_back(std::move(val).template as<typename collection_t::value_type>());
|
||||
}
|
||||
else {
|
||||
value.emplace(std::move(val).template as<typename collection_t::value_type>());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename string_t, template <typename...> typename tuple_t, typename... args_t>
|
||||
class jsonization<
|
||||
string_t,
|
||||
tuple_t<args_t...>,
|
||||
std::enable_if_t<_utils::is_tuple_like<tuple_t<args_t...>>>>
|
||||
: public __jsonization_array<
|
||||
string_t,
|
||||
jsonization<string_t, tuple_t<args_t...>>,
|
||||
tuple_t<args_t...>,
|
||||
std::tuple_size_v<tuple_t<args_t...>>>
|
||||
{
|
||||
public:
|
||||
constexpr static size_t tuple_size = std::tuple_size_v<tuple_t<args_t...>>;
|
||||
|
||||
json::basic_array<string_t> to_json_array(const tuple_t<args_t...>& value) const
|
||||
{
|
||||
json::basic_array<string_t> result;
|
||||
to_json_impl(result, value, std::make_index_sequence<tuple_size>());
|
||||
return result;
|
||||
}
|
||||
|
||||
template <std::size_t... Is>
|
||||
void to_json_impl(
|
||||
json::basic_array<string_t>& arr,
|
||||
const tuple_t<args_t...>& t,
|
||||
std::index_sequence<Is...>) const
|
||||
{
|
||||
using std::get;
|
||||
(arr.emplace_back(get<Is>(t)), ...);
|
||||
}
|
||||
|
||||
bool check_json_array(const json::basic_array<string_t>& arr) const
|
||||
{
|
||||
return check_json_impl(arr, std::make_index_sequence<tuple_size>());
|
||||
}
|
||||
|
||||
template <std::size_t... Is>
|
||||
bool check_json_impl(const json::basic_array<string_t>& arr, std::index_sequence<Is...>) const
|
||||
{
|
||||
return (arr[Is].template is<std::tuple_element_t<Is, tuple_t<args_t...>>>() && ...);
|
||||
}
|
||||
|
||||
bool from_json_array(const json::basic_array<string_t>& arr, tuple_t<args_t...>& value) const
|
||||
{
|
||||
if (!check_json_array(arr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
from_json_impl(arr, value, std::make_index_sequence<tuple_size>());
|
||||
return true;
|
||||
}
|
||||
|
||||
template <std::size_t... Is>
|
||||
void from_json_impl(
|
||||
const json::basic_array<string_t>& arr,
|
||||
tuple_t<args_t...>& t,
|
||||
std::index_sequence<Is...>) const
|
||||
{
|
||||
using std::get;
|
||||
((get<Is>(t) = arr[Is].template as<std::tuple_element_t<Is, tuple_t<args_t...>>>()), ...);
|
||||
}
|
||||
|
||||
json::basic_array<string_t> move_to_json_array(tuple_t<args_t...> value) const
|
||||
{
|
||||
json::basic_array<string_t> result;
|
||||
move_to_json_impl(result, std::move(value), std::make_index_sequence<tuple_size>());
|
||||
return result;
|
||||
}
|
||||
|
||||
template <std::size_t... Is>
|
||||
void move_to_json_impl(
|
||||
json::basic_array<string_t>& arr,
|
||||
tuple_t<args_t...> t,
|
||||
std::index_sequence<Is...>) const
|
||||
{
|
||||
using std::get;
|
||||
(arr.emplace_back(std::move(get<Is>(t))), ...);
|
||||
}
|
||||
|
||||
bool move_from_json_array(json::basic_array<string_t> arr, tuple_t<args_t...>& value) const
|
||||
{
|
||||
if (!check_json_array(arr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
move_from_json_impl(arr, value, std::make_index_sequence<tuple_size>());
|
||||
return true;
|
||||
}
|
||||
|
||||
template <std::size_t... Is>
|
||||
void move_from_json_impl(
|
||||
json::basic_array<string_t> arr,
|
||||
tuple_t<args_t...>& t,
|
||||
std::index_sequence<Is...>) const
|
||||
{
|
||||
using std::get;
|
||||
((get<Is>(t) =
|
||||
std::move(arr[Is]).template as<std::tuple_element_t<Is, tuple_t<args_t...>>>()),
|
||||
...);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename string_t, typename map_t>
|
||||
class jsonization<
|
||||
string_t,
|
||||
map_t,
|
||||
std::enable_if_t<_utils::is_map<map_t> && std::is_same_v<typename map_t::key_type, string_t>>>
|
||||
: public __jsonization_object<string_t, jsonization<string_t, map_t>, map_t>
|
||||
{
|
||||
public:
|
||||
json::basic_object<string_t> to_json_object(const map_t& value) const
|
||||
{
|
||||
json::basic_object<string_t> result;
|
||||
for (const auto& [key, val] : value) {
|
||||
result.emplace(key, val);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool check_json_object(const json::basic_object<string_t>& arr) const
|
||||
{
|
||||
for (const auto& [key, val] : arr) {
|
||||
if (!val.template is<typename map_t::mapped_type>()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool from_json_object(const json::basic_object<string_t>& arr, map_t& value) const
|
||||
{
|
||||
// TODO: 是不是直接from不check了算了
|
||||
if (!check_json_object(arr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
value = {};
|
||||
for (const auto& [key, val] : arr) {
|
||||
value.emplace(key, val.template as<typename map_t::mapped_type>());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
json::basic_object<string_t> move_to_json_object(map_t value) const
|
||||
{
|
||||
json::basic_object<string_t> result;
|
||||
for (auto& [key, val] : value) {
|
||||
result.emplace(key, std::move(val));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool move_from_json_object(json::basic_object<string_t> arr, map_t& value) const
|
||||
{
|
||||
// TODO: 是不是直接from不check了算了
|
||||
if (!check_json_object(arr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
value = {};
|
||||
for (auto& [key, val] : arr) {
|
||||
value.emplace(key, std::move(val).template as<typename map_t::mapped_type>());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename string_t, typename... args_t>
|
||||
class jsonization<string_t, std::variant<args_t...>>
|
||||
{
|
||||
public:
|
||||
using variant_t = std::variant<args_t...>;
|
||||
constexpr static size_t variant_size = std::variant_size_v<variant_t>;
|
||||
|
||||
json::basic_value<string_t> to_json(const variant_t& value) const
|
||||
{
|
||||
json::basic_value<string_t> result;
|
||||
to_json_impl(result, value, std::make_index_sequence<variant_size>());
|
||||
return result;
|
||||
}
|
||||
|
||||
template <std::size_t... Is>
|
||||
void to_json_impl(
|
||||
json::basic_value<string_t>& val,
|
||||
const variant_t& t,
|
||||
std::index_sequence<Is...>) const
|
||||
{
|
||||
using std::get;
|
||||
std::ignore = ((t.index() == Is ? (val = get<Is>(t), true) : false) || ...);
|
||||
}
|
||||
|
||||
bool check_json(const json::basic_value<string_t>& json) const
|
||||
{
|
||||
return check_json_impl(json, std::make_index_sequence<variant_size>());
|
||||
}
|
||||
|
||||
template <std::size_t... Is>
|
||||
bool check_json_impl(const json::basic_value<string_t>& val, std::index_sequence<Is...>) const
|
||||
{
|
||||
return (val.template is<std::variant_alternative_t<Is, variant_t>>() || ...);
|
||||
}
|
||||
|
||||
bool from_json(const json::basic_value<string_t>& json, variant_t& value) const
|
||||
{
|
||||
if (!check_json_impl(json, std::make_index_sequence<variant_size>())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
from_json_impl(json, value, std::make_index_sequence<variant_size>());
|
||||
return true;
|
||||
}
|
||||
|
||||
template <std::size_t... Is>
|
||||
void from_json_impl(
|
||||
const json::basic_value<string_t>& json,
|
||||
variant_t& t,
|
||||
std::index_sequence<Is...>) const
|
||||
{
|
||||
std::ignore =
|
||||
((json.template is<std::variant_alternative_t<Is, variant_t>>()
|
||||
? (t = json.template as<std::variant_alternative_t<Is, variant_t>>(), true)
|
||||
: false)
|
||||
|| ...);
|
||||
}
|
||||
|
||||
json::basic_value<string_t> move_to_json(variant_t value) const
|
||||
{
|
||||
json::basic_value<string_t> result;
|
||||
move_to_json_impl(result, std::move(value), std::make_index_sequence<variant_size>());
|
||||
return result;
|
||||
}
|
||||
|
||||
template <std::size_t... Is>
|
||||
void
|
||||
move_to_json_impl(json::basic_value<string_t>& val, variant_t t, std::index_sequence<Is...>)
|
||||
const
|
||||
{
|
||||
using std::get;
|
||||
std::ignore = ((t.index() == Is ? (val = std::move(get<Is>(t)), true) : false) || ...);
|
||||
}
|
||||
|
||||
bool move_from_json(json::basic_value<string_t> json, variant_t& value) const
|
||||
{
|
||||
if (!check_json_impl(json, std::make_index_sequence<variant_size>())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
move_from_json_impl(std::move(json), value, std::make_index_sequence<variant_size>());
|
||||
return true;
|
||||
}
|
||||
|
||||
template <std::size_t... Is>
|
||||
void move_from_json_impl(
|
||||
json::basic_value<string_t> json,
|
||||
variant_t& t,
|
||||
std::index_sequence<Is...>) const
|
||||
{
|
||||
std::ignore =
|
||||
((json.template is<std::variant_alternative_t<Is, variant_t>>()
|
||||
? (t = std::move(json).template as<std::variant_alternative_t<Is, variant_t>>(),
|
||||
true)
|
||||
: false)
|
||||
|| ...);
|
||||
}
|
||||
};
|
||||
|
||||
// TODO: check if has move_xxx in member
|
||||
template <typename string_t, typename var_t>
|
||||
class jsonization<
|
||||
string_t,
|
||||
var_t,
|
||||
std::enable_if_t<
|
||||
_utils::has_to_json_in_member<var_t>::value
|
||||
&& _utils::has_check_json_in_member<var_t, string_t>::value
|
||||
&& _utils::has_from_json_in_member<var_t, string_t>::value>>
|
||||
{
|
||||
public:
|
||||
json::basic_value<string_t> to_json(const var_t& value) const { return value.to_json(); }
|
||||
|
||||
bool check_json(const json::basic_value<string_t>& json) const
|
||||
{
|
||||
var_t value;
|
||||
return value.check_json(json);
|
||||
}
|
||||
|
||||
bool from_json(const json::basic_value<string_t>& json, var_t& value) const
|
||||
{
|
||||
return value.from_json(json);
|
||||
}
|
||||
|
||||
json::basic_value<string_t> move_to_json(var_t value) const { return to_json(value); }
|
||||
|
||||
bool move_from_json(json::basic_value<string_t> json, var_t& value) const
|
||||
{
|
||||
return from_json(json, value);
|
||||
}
|
||||
};
|
||||
|
||||
// really need this fucking queue?
|
||||
template <typename string_t, typename value_t>
|
||||
class jsonization<string_t, std::queue<value_t>>
|
||||
: public __jsonization_array<
|
||||
string_t,
|
||||
jsonization<string_t, std::queue<value_t>>,
|
||||
std::queue<value_t>,
|
||||
(size_t)-1>
|
||||
{
|
||||
public:
|
||||
json::basic_array<string_t> to_json_array(const std::queue<value_t>& value) const
|
||||
{
|
||||
return move_to_json_array(value);
|
||||
}
|
||||
|
||||
bool check_json_array(const json::basic_array<string_t>& arr) const
|
||||
{
|
||||
return arr.template all<value_t>();
|
||||
}
|
||||
|
||||
bool from_json_array(const json::basic_array<string_t>& arr, std::queue<value_t>& value) const
|
||||
{
|
||||
if (!check_json_array(arr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
value = {};
|
||||
for (const auto& val : arr) {
|
||||
value.emplace(val.template as<value_t>());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
json::basic_array<string_t> move_to_json_array(std::queue<value_t> value) const
|
||||
{
|
||||
json::basic_array<string_t> result;
|
||||
while (!value.empty()) {
|
||||
result.emplace_back(std::move(value.front()));
|
||||
value.pop();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool move_from_json_array(json::basic_array<string_t> arr, std::queue<value_t>& value) const
|
||||
{
|
||||
if (!check_json_array(arr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (auto& val : arr) {
|
||||
value.emplace(std::move(val).template as<value_t>());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
648
3rdparty/include/meojson/reflection/jsonization.hpp
vendored
648
3rdparty/include/meojson/reflection/jsonization.hpp
vendored
@@ -1,648 +0,0 @@
|
||||
// IWYU pragma: private, include <meojson/json.hpp>
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#include "../common/types.hpp"
|
||||
#include "extensions.hpp"
|
||||
|
||||
namespace json::_jsonization_helper
|
||||
{
|
||||
|
||||
template <typename value_t>
|
||||
struct is_optional_t : public std::false_type
|
||||
{
|
||||
};
|
||||
|
||||
template <typename value_t>
|
||||
struct is_optional_t<std::optional<value_t>> : public std::true_type
|
||||
{
|
||||
};
|
||||
|
||||
template <typename value_t>
|
||||
inline constexpr bool is_optional_v = is_optional_t<value_t>::value;
|
||||
|
||||
struct next_is_optional_t
|
||||
{
|
||||
};
|
||||
|
||||
struct next_override_key_t
|
||||
{
|
||||
const char* key;
|
||||
};
|
||||
|
||||
struct next_state_t
|
||||
{
|
||||
bool is_optional = false;
|
||||
const char* override_key = nullptr;
|
||||
};
|
||||
|
||||
struct va_arg_end
|
||||
{
|
||||
};
|
||||
|
||||
template <typename tag_t>
|
||||
struct is_tag_t : public std::false_type
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
struct is_tag_t<next_is_optional_t> : public std::true_type
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
struct is_tag_t<next_override_key_t> : public std::true_type
|
||||
{
|
||||
};
|
||||
|
||||
struct dumper
|
||||
{
|
||||
void _to_json(json::object&, va_arg_end) const {}
|
||||
|
||||
template <typename... rest_t>
|
||||
void _to_json(json::object& result, const char* key, rest_t&&... rest) const
|
||||
{
|
||||
_to_json(result, next_state_t {}, key, std::forward<rest_t>(rest)...);
|
||||
}
|
||||
|
||||
template <
|
||||
typename var_t,
|
||||
typename... rest_t,
|
||||
typename _ = std::enable_if_t<!is_tag_t<var_t>::value, void>>
|
||||
void _to_json(
|
||||
json::object& result,
|
||||
next_state_t state,
|
||||
const char* key,
|
||||
const var_t& var,
|
||||
rest_t&&... rest) const
|
||||
{
|
||||
if (state.override_key) {
|
||||
key = state.override_key;
|
||||
}
|
||||
if constexpr (is_optional_v<var_t>) {
|
||||
if (!state.is_optional) {
|
||||
throw exception("std::optional must be used with MEO_OPT");
|
||||
}
|
||||
|
||||
if (var.has_value()) {
|
||||
result.emplace(key, var.value());
|
||||
}
|
||||
}
|
||||
else {
|
||||
result.emplace(key, var);
|
||||
}
|
||||
_to_json(result, std::forward<rest_t>(rest)...);
|
||||
}
|
||||
|
||||
template <typename... rest_t>
|
||||
void _to_json(
|
||||
json::object& result,
|
||||
next_state_t state,
|
||||
const char*,
|
||||
next_is_optional_t,
|
||||
rest_t&&... rest) const
|
||||
{
|
||||
state.is_optional = true;
|
||||
_to_json(result, state, std::forward<rest_t>(rest)...);
|
||||
}
|
||||
|
||||
template <typename... rest_t>
|
||||
void _to_json(
|
||||
json::object& result,
|
||||
next_state_t state,
|
||||
const char*,
|
||||
next_override_key_t override_key,
|
||||
rest_t&&... rest) const
|
||||
{
|
||||
state.override_key = override_key.key;
|
||||
_to_json(result, state, std::forward<rest_t>(rest)...);
|
||||
}
|
||||
};
|
||||
|
||||
struct checker
|
||||
{
|
||||
bool _check_json(const json::value&, std::string&, va_arg_end) const { return true; }
|
||||
|
||||
template <typename... rest_t>
|
||||
bool _check_json(
|
||||
const json::value& in,
|
||||
std::string& error_key,
|
||||
const char* key,
|
||||
rest_t&&... rest) const
|
||||
{
|
||||
return _check_json(in, error_key, next_state_t {}, key, std::forward<rest_t>(rest)...);
|
||||
}
|
||||
|
||||
template <
|
||||
typename var_t,
|
||||
typename... rest_t,
|
||||
typename _ = std::enable_if_t<!is_tag_t<var_t>::value, void>>
|
||||
bool _check_json(
|
||||
const json::value& in,
|
||||
std::string& error_key,
|
||||
next_state_t state,
|
||||
const char* key,
|
||||
const var_t&,
|
||||
rest_t&&... rest) const
|
||||
{
|
||||
if (state.override_key) {
|
||||
key = state.override_key;
|
||||
}
|
||||
auto opt = in.find(key);
|
||||
if constexpr (is_optional_v<var_t>) {
|
||||
if (!state.is_optional) {
|
||||
throw exception("std::optional must be used with MEO_OPT");
|
||||
}
|
||||
|
||||
if (opt && !opt->is<typename var_t::value_type>()) {
|
||||
error_key = key;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (state.is_optional) {
|
||||
if (opt && !opt->is<var_t>()) {
|
||||
error_key = key;
|
||||
return false;
|
||||
} // is_optional, ignore key not found
|
||||
}
|
||||
else if (!opt || !opt->is<var_t>()) {
|
||||
error_key = key;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return _check_json(in, error_key, std::forward<rest_t>(rest)...);
|
||||
}
|
||||
|
||||
template <typename... rest_t>
|
||||
bool _check_json(
|
||||
const json::value& in,
|
||||
std::string& error_key,
|
||||
next_state_t state,
|
||||
const char*,
|
||||
next_is_optional_t,
|
||||
rest_t&&... rest) const
|
||||
{
|
||||
state.is_optional = true;
|
||||
return _check_json(in, error_key, state, std::forward<rest_t>(rest)...);
|
||||
}
|
||||
|
||||
template <typename... rest_t>
|
||||
bool _check_json(
|
||||
const json::value& in,
|
||||
std::string& error_key,
|
||||
next_state_t state,
|
||||
const char*,
|
||||
next_override_key_t override_key,
|
||||
rest_t&&... rest) const
|
||||
{
|
||||
state.override_key = override_key.key;
|
||||
return _check_json(in, error_key, state, std::forward<rest_t>(rest)...);
|
||||
}
|
||||
};
|
||||
|
||||
struct loader
|
||||
{
|
||||
bool _from_json(const json::value&, std::string&, va_arg_end) const { return true; }
|
||||
|
||||
template <typename... rest_t>
|
||||
bool
|
||||
_from_json(const json::value& in, std::string& error_key, const char* key, rest_t&&... rest)
|
||||
{
|
||||
return _from_json(in, error_key, next_state_t {}, key, std::forward<rest_t>(rest)...);
|
||||
}
|
||||
|
||||
template <
|
||||
typename var_t,
|
||||
typename... rest_t,
|
||||
typename _ = std::enable_if_t<!is_tag_t<var_t>::value, void>>
|
||||
bool _from_json(
|
||||
const json::value& in,
|
||||
std::string& error_key,
|
||||
next_state_t state,
|
||||
const char* key,
|
||||
var_t& var,
|
||||
rest_t&&... rest)
|
||||
{
|
||||
if (state.override_key) {
|
||||
key = state.override_key;
|
||||
}
|
||||
auto opt = in.find(key);
|
||||
if constexpr (is_optional_v<var_t>) {
|
||||
if (!state.is_optional) {
|
||||
throw exception("std::optional must be used with MEO_OPT");
|
||||
}
|
||||
|
||||
if (opt && !opt->is<typename var_t::value_type>()) {
|
||||
error_key = key;
|
||||
return false;
|
||||
}
|
||||
if (opt) {
|
||||
var = std::move(opt)->as<typename var_t::value_type>();
|
||||
}
|
||||
else {
|
||||
var = std::nullopt;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (state.is_optional) {
|
||||
if (opt && !opt->is<var_t>()) {
|
||||
error_key = key;
|
||||
return false;
|
||||
} // is_optional, ignore key not found
|
||||
}
|
||||
else if (!opt || !opt->is<var_t>()) {
|
||||
error_key = key;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (opt) {
|
||||
var = std::move(opt)->as<var_t>();
|
||||
}
|
||||
}
|
||||
|
||||
return _from_json(in, error_key, std::forward<rest_t>(rest)...);
|
||||
}
|
||||
|
||||
template <typename... rest_t>
|
||||
bool _from_json(
|
||||
const json::value& in,
|
||||
std::string& error_key,
|
||||
next_state_t state,
|
||||
const char*,
|
||||
next_is_optional_t,
|
||||
rest_t&&... rest)
|
||||
{
|
||||
state.is_optional = true;
|
||||
return _from_json(in, error_key, state, std::forward<rest_t>(rest)...);
|
||||
}
|
||||
|
||||
template <typename... rest_t>
|
||||
bool _from_json(
|
||||
const json::value& in,
|
||||
std::string& error_key,
|
||||
next_state_t state,
|
||||
const char*,
|
||||
next_override_key_t override_key,
|
||||
rest_t&&... rest)
|
||||
{
|
||||
state.override_key = override_key.key;
|
||||
return _from_json(in, error_key, state, std::forward<rest_t>(rest)...);
|
||||
}
|
||||
};
|
||||
} // namespace json::_jsonization_helper
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
|
||||
#endif
|
||||
|
||||
namespace json::_private_macro
|
||||
{
|
||||
#define _MEOJSON_STRINGIZE(arg) _MEOJSON_STRINGIZE1(arg)
|
||||
#define _MEOJSON_STRINGIZE1(arg) _MEOJSON_STRINGIZE2(arg)
|
||||
#define _MEOJSON_STRINGIZE2(arg) #arg
|
||||
|
||||
#define _MEOJSON_CONCATENATE(arg1, arg2) _MEOJSON_CONCATENATE1(arg1, arg2)
|
||||
#define _MEOJSON_CONCATENATE1(arg1, arg2) _MEOJSON_CONCATENATE2(arg1, arg2)
|
||||
#define _MEOJSON_CONCATENATE2(arg1, arg2) arg1##arg2
|
||||
|
||||
#define _MEOJSON_EXPAND(x) x
|
||||
|
||||
#define _MEOJSON_FOR_EACH_1(pred, x) pred(x)
|
||||
#define _MEOJSON_FOR_EACH_2(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_1(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_3(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_2(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_4(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_3(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_5(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_4(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_6(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_5(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_7(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_6(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_8(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_7(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_9(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_8(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_10(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_9(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_11(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_10(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_12(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_11(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_13(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_12(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_14(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_13(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_15(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_14(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_16(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_15(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_17(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_16(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_18(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_17(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_19(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_18(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_20(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_19(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_21(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_20(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_22(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_21(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_23(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_22(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_24(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_23(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_25(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_24(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_26(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_25(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_27(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_26(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_28(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_27(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_29(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_28(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_30(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_29(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_31(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_30(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_32(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_31(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_33(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_32(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_34(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_33(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_35(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_34(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_36(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_35(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_37(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_36(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_38(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_37(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_39(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_38(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_40(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_39(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_41(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_40(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_42(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_41(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_43(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_42(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_44(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_43(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_45(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_44(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_46(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_45(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_47(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_46(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_48(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_47(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_49(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_48(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_50(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_49(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_51(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_50(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_52(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_51(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_53(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_52(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_54(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_53(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_55(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_54(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_56(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_55(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_57(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_56(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_58(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_57(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_59(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_58(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_60(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_59(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_61(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_60(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_62(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_61(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_63(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_62(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH_64(pred, x, ...) \
|
||||
pred(x) _MEOJSON_EXPAND(_MEOJSON_FOR_EACH_63(pred, __VA_ARGS__))
|
||||
|
||||
#define _MEOJSON_ARG_COUNT(...) \
|
||||
_MEOJSON_EXPAND(_MEOJSON_ARG_COUNT1( \
|
||||
0, \
|
||||
##__VA_ARGS__, \
|
||||
64, \
|
||||
63, \
|
||||
62, \
|
||||
61, \
|
||||
60, \
|
||||
59, \
|
||||
58, \
|
||||
57, \
|
||||
56, \
|
||||
55, \
|
||||
54, \
|
||||
53, \
|
||||
52, \
|
||||
51, \
|
||||
50, \
|
||||
49, \
|
||||
48, \
|
||||
47, \
|
||||
46, \
|
||||
45, \
|
||||
44, \
|
||||
43, \
|
||||
42, \
|
||||
41, \
|
||||
40, \
|
||||
39, \
|
||||
38, \
|
||||
37, \
|
||||
36, \
|
||||
35, \
|
||||
34, \
|
||||
33, \
|
||||
32, \
|
||||
31, \
|
||||
30, \
|
||||
29, \
|
||||
28, \
|
||||
27, \
|
||||
26, \
|
||||
25, \
|
||||
24, \
|
||||
23, \
|
||||
22, \
|
||||
21, \
|
||||
20, \
|
||||
19, \
|
||||
18, \
|
||||
17, \
|
||||
16, \
|
||||
15, \
|
||||
14, \
|
||||
13, \
|
||||
12, \
|
||||
11, \
|
||||
10, \
|
||||
9, \
|
||||
8, \
|
||||
7, \
|
||||
6, \
|
||||
5, \
|
||||
4, \
|
||||
3, \
|
||||
2, \
|
||||
1, \
|
||||
0))
|
||||
#define _MEOJSON_ARG_COUNT1( \
|
||||
_0, \
|
||||
_1, \
|
||||
_2, \
|
||||
_3, \
|
||||
_4, \
|
||||
_5, \
|
||||
_6, \
|
||||
_7, \
|
||||
_8, \
|
||||
_9, \
|
||||
_10, \
|
||||
_11, \
|
||||
_12, \
|
||||
_13, \
|
||||
_14, \
|
||||
_15, \
|
||||
_16, \
|
||||
_17, \
|
||||
_18, \
|
||||
_19, \
|
||||
_20, \
|
||||
_21, \
|
||||
_22, \
|
||||
_23, \
|
||||
_24, \
|
||||
_25, \
|
||||
_26, \
|
||||
_27, \
|
||||
_28, \
|
||||
_29, \
|
||||
_30, \
|
||||
_31, \
|
||||
_32, \
|
||||
_33, \
|
||||
_34, \
|
||||
_35, \
|
||||
_36, \
|
||||
_37, \
|
||||
_38, \
|
||||
_39, \
|
||||
_40, \
|
||||
_41, \
|
||||
_42, \
|
||||
_43, \
|
||||
_44, \
|
||||
_45, \
|
||||
_46, \
|
||||
_47, \
|
||||
_48, \
|
||||
_49, \
|
||||
_50, \
|
||||
_51, \
|
||||
_52, \
|
||||
_53, \
|
||||
_54, \
|
||||
_55, \
|
||||
_56, \
|
||||
_57, \
|
||||
_58, \
|
||||
_59, \
|
||||
_60, \
|
||||
_61, \
|
||||
_62, \
|
||||
_63, \
|
||||
_64, \
|
||||
N, \
|
||||
...) \
|
||||
N
|
||||
|
||||
#define _MEOJSON_FOR_EACH_(N, pred, ...) \
|
||||
_MEOJSON_EXPAND(_MEOJSON_CONCATENATE(_MEOJSON_FOR_EACH_, N)(pred, __VA_ARGS__))
|
||||
#define _MEOJSON_FOR_EACH(pred, ...) \
|
||||
_MEOJSON_EXPAND( \
|
||||
_MEOJSON_FOR_EACH_(_MEOJSON_EXPAND(_MEOJSON_ARG_COUNT(__VA_ARGS__)), pred, __VA_ARGS__))
|
||||
|
||||
#define _MEOJSON_VARNAME(x) _MEOJSON_CONCATENATE(_meojson_jsonization_, x)
|
||||
#define _MEOJSON_KEY_VALUE(x) _MEOJSON_STRINGIZE(x), x,
|
||||
} // namespace json::_private_macro
|
||||
|
||||
#define MEO_TOJSON(...) \
|
||||
json::value to_json() const \
|
||||
{ \
|
||||
json::object result; \
|
||||
json::_jsonization_helper::dumper()._to_json( \
|
||||
result, \
|
||||
_MEOJSON_EXPAND(_MEOJSON_FOR_EACH(_MEOJSON_KEY_VALUE, __VA_ARGS__)) \
|
||||
json::_jsonization_helper::va_arg_end {}); \
|
||||
return result; \
|
||||
}
|
||||
|
||||
#define MEO_CHECKJSON(...) \
|
||||
bool check_json(const json::value& _MEOJSON_VARNAME(in)) const \
|
||||
{ \
|
||||
std::string _MEOJSON_VARNAME(error_key); \
|
||||
return check_json(_MEOJSON_VARNAME(in), _MEOJSON_VARNAME(error_key)); \
|
||||
} \
|
||||
bool check_json( \
|
||||
const json::value& _MEOJSON_VARNAME(in), \
|
||||
std::string& _MEOJSON_VARNAME(error_key)) const \
|
||||
{ \
|
||||
return json::_jsonization_helper::checker()._check_json( \
|
||||
_MEOJSON_VARNAME(in), \
|
||||
_MEOJSON_VARNAME(error_key), \
|
||||
_MEOJSON_EXPAND(_MEOJSON_FOR_EACH(_MEOJSON_KEY_VALUE, __VA_ARGS__)) \
|
||||
json::_jsonization_helper::va_arg_end {}); \
|
||||
}
|
||||
|
||||
#define MEO_FROMJSON(...) \
|
||||
bool from_json(const json::value& _MEOJSON_VARNAME(in)) \
|
||||
{ \
|
||||
std::string _MEOJSON_VARNAME(error_key); \
|
||||
return from_json(_MEOJSON_VARNAME(in), _MEOJSON_VARNAME(error_key)); \
|
||||
} \
|
||||
bool from_json( \
|
||||
const json::value& _MEOJSON_VARNAME(in), \
|
||||
std::string& _MEOJSON_VARNAME(error_key)) \
|
||||
{ \
|
||||
return json::_jsonization_helper::loader()._from_json( \
|
||||
_MEOJSON_VARNAME(in), \
|
||||
_MEOJSON_VARNAME(error_key), \
|
||||
_MEOJSON_EXPAND(_MEOJSON_FOR_EACH(_MEOJSON_KEY_VALUE, __VA_ARGS__)) \
|
||||
json::_jsonization_helper::va_arg_end {}); \
|
||||
}
|
||||
|
||||
#define MEO_JSONIZATION(...) \
|
||||
_MEOJSON_EXPAND(MEO_TOJSON(__VA_ARGS__)) \
|
||||
_MEOJSON_EXPAND(MEO_CHECKJSON(__VA_ARGS__)) \
|
||||
_MEOJSON_EXPAND(MEO_FROMJSON(__VA_ARGS__))
|
||||
|
||||
#define MEO_OPT json::_jsonization_helper::next_is_optional_t {},
|
||||
#define MEO_KEY(key) json::_jsonization_helper::next_override_key_t { key },
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic pop // -Wgnu-zero-variadic-macro-arguments
|
||||
#endif
|
||||
300
CHANGELOG.md
300
CHANGELOG.md
@@ -1,228 +1,96 @@
|
||||
## v5.25.0
|
||||
## v5.1.0
|
||||
|
||||
### 依\~赖\~大\~更\~新\~ | Highlights
|
||||
|
||||
在这个版本,我们大幅更新了项目的依赖库,优化了 MAA 的性能,~~所以老电脑可能要更新运行库了。~~
|
||||
|
||||
**我们还为官网和 API 节点优化了网络,大幅优化了访问速度**。
|
||||
|
||||
#### 自动战斗方面
|
||||
|
||||
我们对【自动战斗】功能进行了一些改动,主要包括:
|
||||
|
||||
* 牛牛现在会自动识别作业集内各个作业的干员编组情况,如果上一份作业的干员编组与当前作业的一致,牛牛就不再重复进行干员编组了,从而节省时间
|
||||
* 战斗列表部分,对各个作业的设置按键的鼠标按键逻辑进行了调整:点击左键将可以查看该作业的说明和干员配置需求,点击右键将直接提取该作业并关闭战斗列表功能(即只打该作业)
|
||||
|
||||
#### 基建换班方面
|
||||
|
||||
我们优化了基建换班中与基建技能有关的功能:
|
||||
|
||||
* 我们为所有没有设置效率数据的基建技能都设置了效率数据,这样牛牛在【基建换班】任务中就能更好地为干员不全的玩家选择合适的基建技能了(但还是把 U 酱拿掉了,~~U 酱那么可爱为什么要工作~~)
|
||||
* 如果【基建换班】任务处于「自定义基建配置」模式,且牛牛正在工作中,那么班次将不再随时间切换,避免牛牛工作到一半班次被切了而产生的各种问题
|
||||
* 如果【基建换班】任务处于「队列轮换」模式,那么牛牛将不再进入未勾选的设施
|
||||
* 我们调整了会客室技能的排序逻辑,现在会优先选择更容易获得尚未拥有的线索的技能
|
||||
|
||||
#### 其他方面
|
||||
|
||||
我们增加了一些小的改动,值得注意的有:
|
||||
|
||||
* 我们在【自动肉鸽】任务中优化了丰川祥子相关招募策略 ~~saki酱、saki酱、saki酱~~
|
||||
* 牛牛在【生息演算】任务中将会自动识别当前的存档状态与任务的设置是否一致,如果不一致将会提示你检查存档状态
|
||||
* 当你设置 Mirror酱的 CDK 后,MAA 将会显示 CDK 的剩余有效时间,方便你掌握有效期
|
||||
|
||||
----
|
||||
|
||||
In this version, we have significantly updated the project's dependency libraries and optimized MAA's performance. ~~So you may need to update their runtime libraries if you use old computers.~~
|
||||
|
||||
**We have also optimized the network for the official website and API nodes, greatly improving access speed.**
|
||||
|
||||
#### *Copilot* Improvements
|
||||
|
||||
We have made some adjustments to the *Copilot* feature, which mainly include:
|
||||
|
||||
* MAA will now automatically recognize the operator formation in each job within the job set. If the operator formation of the previous job matches that of the current job, MAA will no longer repeat the operator squading process, thereby saving time.
|
||||
* In the Battle list section, the mouse button logic for each job's settings button has been adjusted: left-clicking will allow you to view the job's description and operator formation requirements, while right-clicking will directly extract that job and disable the combat list function (i.e., only run that specific operation).
|
||||
|
||||
#### *Base* Improvements
|
||||
|
||||
We have optimized the base skill-related functions in *Base* task:
|
||||
|
||||
* We have set efficiency data for all base skills that previously lacked that data, allowing MAA to better select suitable base skills for doctors with incomplete operator rosters during the *Base* task (though we did remove U-Offcial, ~~U-Offcial is so cute, why should she work~~)
|
||||
* If the *Base* task is in Custom Base Mode and the MAA is currently running, Base Plan will no longer switch over time to avoid various issues caused by interrupting the MAA's work by switching the Base Plan when MAA is running.
|
||||
* If the *Base* task is in One-click Rotation Mode, the MAA will no longer enter unchecked facilities.
|
||||
* We adjusted the sorting logic for reception room skills, now prioritizing skills that are more likely to obtain clues not yet owned.
|
||||
|
||||
#### Other Aspects
|
||||
|
||||
We've made some minor changes worth noting:
|
||||
|
||||
* [CN ONLY] In the *Auto I.S.* task, we've optimized the recruitment strategy related to Togawa Sakiko ~~Saki-chan, Saki-chan, Saki-chan~~
|
||||
* In the *Reclamation Algorithm* task, MAA will automatically detect whether the current save status matches the mission settings. If they don't match, it will prompt you to check your save status.
|
||||
* After setting MirrorChyan's CDK, MAA will display the remaining validity period of the CDK, making it easier for you to track its expiration
|
||||
|
||||
----
|
||||
|
||||
以下是详细内容:
|
||||
|
||||
### 新增 | New
|
||||
|
||||
* CustomTask 增加任务存在检测 @status102
|
||||
* core 崩溃后下次启动时 ui 输出提示 (#14022) @ABA2396 @momomochi987
|
||||
* 给自定义任务添加 ScreenshotTaskPlugin 插件 @ABA2396
|
||||
* 战斗列表点击作业时自动关闭列表, 原逻辑迁移至鼠标右键 @status102
|
||||
* 添加基建计划 ToolTip 提示 @ABA2396
|
||||
* 添加信息获取失败时的提示 @ABA2396
|
||||
* CDK 倒计时显示 @ABA2396
|
||||
* 成就设置中的图标颜色可以随着主题色动态更新 @ABA2396
|
||||
* 添加 CDK 到期时间显示 @ABA2396
|
||||
* 添加 ResourceReferenceHelper,允许绑定 前后景色 key @ABA2396
|
||||
* 自动战斗多作业支持保存干员组内编入的干员 (#14095) @status102
|
||||
* cli 支持新版战斗列表以及悖论模拟 (#14154) @wangl-cc
|
||||
* 为官网首页添加多语言支持 (#13943) @lucienshawls @momomochi987 @Manicsteiner @pre-commit-ci[bot] @Constrat
|
||||
* RunningState 统一状态变更事件 (#14141) @ABA2396
|
||||
* 生息盐酸任务添加对错误模式 (有/无存档) 的提示 (#14131) @Alan-Charred
|
||||
* custom clang (#14102) @neko-para
|
||||
* allow single copilot task execution @status102
|
||||
* convert ResourceUpdater to ubuntu-latest (#14076) @Constrat
|
||||
* support build resource updater @neko-para
|
||||
* use coreml OCR for apple (#14108) @MistEO
|
||||
- 生息演算2 (#8190) (Mac 版本需点加号手动添加) @SherkeyXD @hguandl @ABA2396
|
||||
- 开放每日免费单抽功能 (#8185) @SherkeyXD
|
||||
- 新增只购买折扣信用商品(白名单商品除外)和少于300信用点停止购物的选项 (#7659) @lpowo @status102
|
||||
- 基建领取专精功能 (#7754) @broken-paint @Constrat
|
||||
- 合成玉签到task (#8223) @Sherkey @status102
|
||||
- 抽卡提示不许勾下次不再提示 @ABA2396
|
||||
- 运行 ReclamationAlgorithm 时默认运行 Reclamation2 而不是旧演算 (#8229) @horror-proton @ABA2396
|
||||
- 强制定时启动添加提示对话框并可选是否显示窗口 (#8062) @moomiji
|
||||
- 在自动编队过程中缺少干员时停止并记录 (#8051) @KevinT3Hu
|
||||
|
||||
### 改进 | Improved
|
||||
|
||||
* 更新基建技能效率 @ABA2396
|
||||
* wpf 自动战斗列表中作业设置按钮左键单击还原为解析指定作业,新增行为修改至右键,解析作业并关闭列表 @status102
|
||||
* 优化更新设置中的徽标显示和逻辑 @ABA2396
|
||||
* add --parallel to cmake workflows @Constrat
|
||||
* 更新 markdownlint 规则 @SherkeyXD
|
||||
* 依赖大更新 (#13908) @MistEO @status102 @pre-commit-ci[bot]
|
||||
* 优化干员识别动画显示效果 @ABA2396
|
||||
* 加个try先 @status102
|
||||
* remove resource from smoke testing use the default location, do not duplicate @Constrat
|
||||
- 更新文档到.net8 @ABA2396
|
||||
- 移除CopilotTask不必要的传参 @status102
|
||||
- 更新部分step的版本 @SherkeyXD
|
||||
- 增加账号切换时登录键点击重试 @status102
|
||||
- 远程控制对非 https 连接仅提出警告 (#8061) @Sherkey
|
||||
- 肉鸽适配新干员用法 (#8273) @Lancarus
|
||||
- 肉鸽投资后结束本次战斗 (#8268) @status102
|
||||
- 优化肉鸽投资速度及输出 (#8177) @status102
|
||||
- 调整生息演算任务 @status102
|
||||
- 增加生稀盐酸跳过等待 @status102
|
||||
- 全反选排除生息演算 @ABA2396
|
||||
- Mac 全部启用任务时排除生息演算 @Hao Guan
|
||||
- 优化可变位置文字识别 @ABA2396
|
||||
- 部分需重启生效的选项添加重启确认弹窗 @ABA2396
|
||||
- 缓存待部署区识别,减少CPU占用 (#8275) @status102
|
||||
- ScreenCost截图失败次数为0时,不返回fault_times字段 @status102
|
||||
- 优化基建领取专精 (#8207) @broken-paint
|
||||
|
||||
### 修复 | Fix
|
||||
|
||||
* 修复 cmake copy_and_add_rpath_library 的失败逻辑 (#14097) @litwak913
|
||||
* 刷开局奖励只选票券时行为异常 @ABA2396
|
||||
* 自动编队缺少干员输出的额外换行 @status102
|
||||
* Copilot多任务编队时编队设置残留 @status102
|
||||
* 自定义基建换班的班次不会随时间切换 @ABA2396
|
||||
* "统一 WpfGui 工作目录"后,配置为外服无法运行 MAA @ABA2396
|
||||
* 移除 debug_demo (原Sample) 的对应 resource 额外查找逻辑 (#14081) @status102 @MistEO
|
||||
* 统一 WpfGui 工作目录 (#14072) @MistEO @pre-commit-ci[bot] @ABA2396 @status102
|
||||
* 重构依赖后 MaaWpfGui 的 resource 路径丢失 (#14077) @status102
|
||||
* 停止中或者空闲状态不允许点击停止按钮 @ABA2396
|
||||
* 鲍勃杂货店拥有四叶草化石且无抗干扰值时卡住 @ABA2396
|
||||
* 无法收取太鼓达人联动主题会客室信息板信用 @ABA2396
|
||||
* cdk 过期时间超过 2038 年会爆炸(但 10000 年还是会爆炸 @ABA2396
|
||||
* maa 变成前文明产物了 @ABA2396
|
||||
* 糊一下 debug_demo 资源路径读取 @MistEO
|
||||
* 修复 wpf gui 一些 resource path 读取 @MistEO
|
||||
* 入暂亭特殊选项 @Saratoga-Official
|
||||
* 特里蒙旅行社特派团多选项 @Saratoga-Official
|
||||
* IS5 同心 @Daydreamer114
|
||||
* 选择技能时可能会点出描述文字 @ABA2396
|
||||
* 基建使用队列轮换时如果未勾选对应设施则不进入 @ABA2396
|
||||
* 重构后无法使用刷开局刷仅精二 @ABA2396
|
||||
* 部分背景下 mujica 主题无法进入对应功能 @ABA2396
|
||||
* 萨米肉鸽刷源石锭可能卡在预见的密文板 @ABA2396
|
||||
* 允许生息演算任务反复点击存档位置直到画面改变 (#14005) @Alan-Charred
|
||||
* 肉鸽助战无法刷新 @Saratoga-Official
|
||||
* minitouch 触控 wait ms @ABA2396
|
||||
* 复核自定义干员时等待游戏动画 @ABA2396
|
||||
* 自动战斗无法读取下拉列表中的作业 @ABA2396
|
||||
* 成就列表解锁时间显示颜色错误 @ABA2396
|
||||
* GO 导航 @ABA2396
|
||||
* 勾选启动后直接运行时无法自动切换基建排班表 @ABA2396
|
||||
* 网络连接错误的情况下读取了本地缓存也提示了获取热更成功 @ABA2396
|
||||
* 萨米肉鸽未通关结局时探寻前路卡住 @Saratoga-Official
|
||||
* 文档站首页在窄屏下的响应式设计 (#14166) @lucienshawls
|
||||
* 暂时修复无法读取过去的评论的问题 (#14163) @lucienshawls
|
||||
* 为什么 mujikca 的图黑的不够纯粹 @ABA2396
|
||||
* 肉鸽在结算界面卡死 (#14145) @Saratoga-Official @pre-commit-ci[bot]
|
||||
* CopilotTask 参数可选项存在性检查 @status102
|
||||
* 异格推王的基建加成错误 @Saratoga-Official
|
||||
* 调低 MacOS PlayCover 下对 InfrastControl 识别的阈值 (#14139) @Alan-Charred
|
||||
* CurrentConfig 未刷新 @status102
|
||||
* CurrentConfig 悬空 @status102
|
||||
* 拥有全干员的情况下重启后进入干员识别界面不会自动选中选项卡 @ABA2396
|
||||
* 修复 DataGrid 虚拟化下 Tab 导航异常 @ABA2396
|
||||
* 萨卡兹肉鸽未通关结局时原初异途卡住 @Saratoga-Official
|
||||
* 肉鸽深入探索无法退出结算界面 (#14123) @Saratoga-Official
|
||||
* typo @Constrat
|
||||
* type number for nightly ota @Constrat
|
||||
* smoke testing upload logs @Constrat
|
||||
* move smoke testing working dir @Constrat
|
||||
* add component for install libcxx only @neko-para
|
||||
* prevent caching in non-dev branches @Constrat
|
||||
* stuck on max trust EN @Constrat
|
||||
* pthread linking problem @neko-para
|
||||
* nightly package zip @MistEO
|
||||
* global resource path @MistEO
|
||||
* linux cross compiling (#14048) @neko-para @pre-commit-ci[bot]
|
||||
* remove opencv highgui again @MistEO
|
||||
* remove opencv highgui @MistEO
|
||||
* build error of ASST_DEBUG @MistEO
|
||||
* Sami floor detection 3 Thanks again @lin4289 on discord @Constrat
|
||||
* EN Roguelike@ChooseOperConfirm (#14033) @Daydreamer114
|
||||
* Sami floor detection 2 Thanks again @lin4289 on discord @Constrat
|
||||
* Sami floor detection Thanks @lin4289 on discord @Constrat
|
||||
* smoke-testing script @Constrat
|
||||
* wrong default on type number @Constrat
|
||||
* Eye For an Eye encounter IS2 EN @Constrat
|
||||
* SettingsViewModel Idle @ABA2396
|
||||
* download to v5 with necessary fix (#14122) @Constrat
|
||||
|
||||
### 文档 | Docs
|
||||
|
||||
* 维护信用作战相关功能及其文档 (#14013) @Alan-Charred
|
||||
* 修复序号问题 @SherkeyXD
|
||||
* 更新文档 cmake 配置 @MistEO
|
||||
* 微调文档 @MistEO
|
||||
* 完善文档站的代码检查和涉及的文本替换 (#14156) @lucienshawls @pre-commit-ci[bot]
|
||||
* 完善自动肉鸽和其它文档中的部分内容 (#13924) @lucienshawls @Constrat @Manicsteiner
|
||||
* 切换文档主题至 vuepress-theme-plume (#13821) @SherkeyXD @lucienshawls @MistEO
|
||||
* typo @MistEO
|
||||
* reapply eebe0a9 (#14036) @wangl-cc
|
||||
* remove weblate @MistEO
|
||||
- 未开启吐司通知时仍弹出通知 @ABA2396
|
||||
- 生息演算开局教程对话有概率卡住 @status102
|
||||
- 修复无限提示远控地址为空的问题 @Sherkey
|
||||
- 连续截图出错30次 / 启动时连续截图出错10次 导致MAA崩溃 (#8280) @status102
|
||||
- 写剪贴板时应该用Unicode而不是ANSI (#8204) @Immueggpain
|
||||
- 修复肉鸽存款余额ocr错误 @status102
|
||||
- 修复干员小满概率性识别为`小/满` @status102
|
||||
- 延长进图等待时间 @ABA2396
|
||||
- 生息演算卡在主界面 @ABA2396
|
||||
- 修复没有赠送次数时单抽任务报错的问题 (#8233) @SherkeyXD
|
||||
- 修复生息演算部分情况下无法跳过开局对话 @status102
|
||||
- 尝试修复剩余理智连战次数无法选择 @status102
|
||||
- 干员识别修正: 红集 -> 红隼 @aur3l14no
|
||||
- 修复更新后弹窗错误 @ABA2396
|
||||
- 修复生息演算在卡顿情况下无法正常退出关卡 @ABA2396
|
||||
- 限制连续战斗次数调整失败重试次数 @status102
|
||||
- 生息演算卡在进入第四日 @ABA2396
|
||||
- screencap failure with amdgpu on some emulators (even with GeneralWithoutScreencapErr) (#8225) @aur3l14no
|
||||
- 修复部分分辨率下无法识别删除存档 @ABA2396
|
||||
- 内测版 wpf tag 错误 @ABA2396
|
||||
- 内测版修改ui版本号 @ABA2396
|
||||
- 修复模拟器自动检测失败时可能导致WpfGui崩溃 (#8288) @status102
|
||||
- gui.log 无法显示完整版本号 @ABA2396
|
||||
|
||||
### 其他 | Other
|
||||
|
||||
* 调整 锏 基建技能效率 @ABA2396
|
||||
* 自定义基建配置时间仍在有效期内时不检查其他时间段 @ABA2396
|
||||
* 界园萨卡兹肉鸽招募休谟斯优先级 @Saratoga-Official
|
||||
* 调整 y 存图时间间隔 @ABA2396
|
||||
* 调整定时器触发逻辑 @ABA2396
|
||||
* 调整未检测到模拟器的输出 @ABA2396
|
||||
* 按时间切换基建配置不在任务运行中或任务开始前切换 @ABA2396
|
||||
* 调整刷新助战日志 @ABA2396
|
||||
* 调整界面颜色 @ABA2396
|
||||
* 肉鸽丰川祥子招募策略 (#14035) @Saratoga-Official
|
||||
* 繁中服「大荒」介面主題 (#14064) @momomochi987 @pre-commit-ci[bot]
|
||||
* 删除一些遗留文件 @MistEO
|
||||
* 再糊点注释 @MistEO
|
||||
* 糊点注释 @MistEO
|
||||
* 管理员权限启动额外判断是否开启 UAC @ABA2396
|
||||
* 调整会客室中更容易获得线索板上尚未拥有的线索的技能优先级 @ABA2396
|
||||
* 基建把 u酱 ban 了 @ABA2396
|
||||
* 特征匹配过程函数拆入analyze() @status102
|
||||
* 繁中服「相見歡」活動導航 (#14137) @momomochi987
|
||||
* remove -DINSTALL_RESOURCES @Constrat
|
||||
* gitignore @status102
|
||||
* where and how did this come from? @Constrat
|
||||
* tweak workflow + remove .sln (#14074) @Constrat @neko-para
|
||||
* remove ninja from ci.yml @Constrat
|
||||
* restore older cache utilization for ci.yml (#14068) @Constrat
|
||||
* update interface.json @neko-para
|
||||
* update linux tutorial (en) @neko-para
|
||||
* EN @Constrat
|
||||
* remove MaaDeps @MistEO
|
||||
* bump maa-cli to 0.5.8 (#14032) @wangl-cc
|
||||
* BrightPointAnalyzer -> PixelAnalyzer (#13915) @Alan-Charred
|
||||
* mujika -> mujica (#14000) @weinibuliu
|
||||
* remove SyncRes @MistEO
|
||||
* use std::format instead of sprintf (#14107) @MistEO @pre-commit-ci[bot]
|
||||
* fix build warning (#14176) @soundofautumn
|
||||
* rename RecognizerViewModel -> ToolboxViewModel (#14177) @soundofautumn
|
||||
* YostarJP ocr fix (#14134) @Manicsteiner
|
||||
* file header @status102
|
||||
* fix build warning (#14120) @soundofautumn
|
||||
- 修复Mac生息演算任务名 @Hao Guan
|
||||
- ScreencapCost输出失败次数 @status102
|
||||
- fix typo and undefined behavior of minmax @Horror Proton
|
||||
- 生息演算高级设置文本框增加换行 @status102
|
||||
- EasterEggs 前两次点击不生效 @ABA2396
|
||||
- 抽卡风险提示 @ABA2396
|
||||
- 生息演算提示文本调整 @status102
|
||||
- 移除肉鸽结算输出多余空格 @status102
|
||||
- Update release-nightly-ota.yml @ABA2396
|
||||
- 更新界面文字 (#8206、#8214、#8218) @AnnAngela
|
||||
- fix appimage cross build issue @Horror Proton
|
||||
- 更新文档 (#8283) @Rbqwow
|
||||
- 添加等宽字体的备用字体 @SherkeyXD
|
||||
- added regex for module-reclamation (#8302) @Constrat
|
||||
- 升级依赖,移除package-lock.json @SherkeyXD
|
||||
- 更新连战文档 (#8308) @Rbqwow
|
||||
|
||||
### For Overseas
|
||||
|
||||
##### YoStarJP
|
||||
|
||||
- YoStarJP ocr fix shamare, ansel, nien (#8194) @Manicsteiner
|
||||
- YoStarJP ocr fix #8180 (#8184) @Manicsteiner
|
||||
- YoStarJP 理想都市 navigation (#8263) @Manicsteiner
|
||||
- YoStarJP ocr fix (#8260) @Manicsteiner
|
||||
|
||||
##### YoStarKR
|
||||
|
||||
- YoStarKR 理想都市 navigation (#8265) @HX3N
|
||||
- YoStarKR ocr fix (假日威龙陈/苍苔/青枳/淬羽赫默 etc) (#8246) @HX3N
|
||||
- YoStarKR update StageAnnihilation.png (#8239) @HX3N
|
||||
- YoStarKR ocr fix (#8236) @HX3N
|
||||
- modified ko-kr.xaml (#8235) @HX3N
|
||||
- YoStarKR add training template image and text (#8295) @HX3N
|
||||
|
||||
17
CITATION.cff
17
CITATION.cff
@@ -1,17 +0,0 @@
|
||||
# This CITATION.cff file was generated with cffinit.
|
||||
# Visit https://bit.ly/cffinit to generate yours today!
|
||||
|
||||
cff-version: 1.2.0
|
||||
title: MaaAssistantArknights
|
||||
message: >-
|
||||
If you use this software, please cite it using the
|
||||
metadata from this file.
|
||||
type: software
|
||||
authors:
|
||||
- name: Maa Team
|
||||
website: 'https://maa.plus/'
|
||||
date-start: '2021-07-10'
|
||||
repository-code: >-
|
||||
https://github.com/MaaAssistantArknights/MaaAssistantArknights/
|
||||
url: 'https://maa.plus/'
|
||||
license: AGPL-3.0-only
|
||||
169
CMakeLists.txt
169
CMakeLists.txt
@@ -1,61 +1,154 @@
|
||||
cmake_minimum_required(VERSION 3.28)
|
||||
project(MAA)
|
||||
cmake_minimum_required(VERSION 3.21)
|
||||
project(MaaAssistantArknights)
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
if (NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE)
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/modules")
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
|
||||
|
||||
option(BUILD_WPF_GUI "build MaaWpfGui" ${WIN32})
|
||||
option(BUILD_DEBUG_DEMO "build debug demo" OFF)
|
||||
option(BUILD_TEST "build a demo" OFF)
|
||||
option(BUILD_XCFRAMEWORK "build xcframework for macOS app" OFF)
|
||||
option(BUILD_SMOKE_TEST "build smoke_test" OFF)
|
||||
option(BUILD_UNIVERSAL "build both arm64 and x86_64 on macOS" OFF)
|
||||
option(INSTALL_PYTHON "install python ffi" OFF)
|
||||
option(INSTALL_RESOURCE "install resource" OFF)
|
||||
option(INSTALL_FLATTEN "do not use bin lib include directory" ON)
|
||||
option(WITH_EMULATOR_EXTRAS "build with emulator extras" ${WIN32})
|
||||
option(WITH_HASH_VERSION "generate version from git hash" OFF)
|
||||
option(INSTALL_DEVEL "install development files" OFF)
|
||||
option(INSTALL_THIRD_LIBS "install third party libraries" ON)
|
||||
option(USE_MAADEPS "use third-party libraries built by MaaDeps" ON)
|
||||
option(WITH_THRIFT "build with thrift" OFF)
|
||||
|
||||
include(${PROJECT_SOURCE_DIR}/MaaDeps/maadeps.cmake)
|
||||
|
||||
include(${PROJECT_SOURCE_DIR}/cmake/config.cmake)
|
||||
include(${PROJECT_SOURCE_DIR}/cmake/utils.cmake)
|
||||
include(${PROJECT_SOURCE_DIR}/cmake/version.cmake)
|
||||
include(${PROJECT_SOURCE_DIR}/cmake/thrift-gen.cmake)
|
||||
|
||||
if(USE_MAADEPS)
|
||||
include(${PROJECT_SOURCE_DIR}/MaaDeps/maadeps.cmake)
|
||||
endif()
|
||||
|
||||
if (MSVC)
|
||||
add_compile_options("/utf-8")
|
||||
add_compile_options("/MP")
|
||||
add_compile_options("/W4;/WX")
|
||||
add_compile_options("/wd4127") # conditional expression is constant
|
||||
add_compile_options("/Wv:19.35.32217") # disable warning introduced after this version
|
||||
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
|
||||
else ()
|
||||
add_compile_options("-Wall;-Werror;-Wextra;-Wpedantic;-Wno-missing-field-initializers")
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13)
|
||||
add_compile_options("-Wno-restrict")
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
|
||||
add_library(header_only_libraries INTERFACE)
|
||||
target_include_directories(header_only_libraries INTERFACE 3rdparty/include)
|
||||
|
||||
file(GLOB_RECURSE maa_src src/MaaCore/*.cpp)
|
||||
|
||||
add_library(MaaCore SHARED ${maa_src})
|
||||
|
||||
if (WIN32)
|
||||
#注意:相比VS版本缺少了 -D_CONSOLE -D_WINDLL 两项
|
||||
target_compile_definitions(MaaCore PRIVATE ASST_DLL_EXPORTS _UNICODE UNICODE)
|
||||
endif ()
|
||||
target_include_directories(MaaCore PUBLIC include PRIVATE src/MaaCore)
|
||||
set(MaaCore_PUBLIC_HEADERS include/AsstCaller.h include/AsstPort.h)
|
||||
target_sources(MaaCore PUBLIC ${MaaCore_PUBLIC_HEADERS})
|
||||
set_target_properties(MaaCore PROPERTIES
|
||||
CXX_STANDARD 20
|
||||
CXX_STANDARD_REQUIRED ON
|
||||
PUBLIC_HEADER "${MaaCore_PUBLIC_HEADERS}"
|
||||
)
|
||||
|
||||
if(APPLE)
|
||||
include(${PROJECT_SOURCE_DIR}/cmake/macos.cmake)
|
||||
set_target_properties(MaaCore PROPERTIES INSTALL_RPATH "@loader_path/")
|
||||
elseif(UNIX)
|
||||
set_target_properties(MaaCore PROPERTIES INSTALL_RPATH "$ORIGIN/")
|
||||
endif()
|
||||
|
||||
if(INSTALL_FLATTEN)
|
||||
set(MaaCore_install_flatten_args RUNTIME DESTINATION . LIBRARY DESTINATION . PUBLIC_HEADER DESTINATION .)
|
||||
endif()
|
||||
if (BUILD_TEST)
|
||||
add_executable(test src/Cpp/main.cpp)
|
||||
set_target_properties(test PROPERTIES
|
||||
CXX_STANDARD 20
|
||||
CXX_STANDARD_REQUIRED ON
|
||||
)
|
||||
target_link_libraries(test MaaCore)
|
||||
endif (BUILD_TEST)
|
||||
|
||||
add_library(HeaderOnlyLibraries INTERFACE)
|
||||
target_include_directories(HeaderOnlyLibraries INTERFACE 3rdparty/include)
|
||||
|
||||
find_package(OpenCV REQUIRED COMPONENTS core imgproc imgcodecs)
|
||||
find_package(Boost REQUIRED CONFIG COMPONENTS system)
|
||||
find_package(OpenCV REQUIRED COMPONENTS core imgproc imgcodecs videoio)
|
||||
find_package(ZLIB REQUIRED)
|
||||
find_package(fastdeploy_ppocr REQUIRED)
|
||||
find_package(ONNXRuntime REQUIRED)
|
||||
find_package(MaaDerpLearning REQUIRED)
|
||||
find_package(asio REQUIRED)
|
||||
find_package(ONNXRuntime)
|
||||
find_package(cpr CONFIG REQUIRED)
|
||||
if(WITH_THRIFT)
|
||||
find_package(Thrift CONFIG REQUIRED)
|
||||
endif(WITH_THRIFT)
|
||||
|
||||
add_subdirectory(src/MaaCore)
|
||||
target_link_libraries(MaaCore ${OpenCV_LIBS} MaaDerpLearning asio::asio ZLIB::ZLIB ONNXRuntime::ONNXRuntime cpr::cpr header_only_libraries)
|
||||
|
||||
if(BUILD_WPF_GUI)
|
||||
include_external_msproject(MaaWpfGui ${PROJECT_SOURCE_DIR}/src/MaaWpfGui/MaaWpfGui.csproj)
|
||||
if(WITH_THRIFT)
|
||||
add_subdirectory(src/MaaThriftController)
|
||||
target_link_libraries(MaaCore MaaThriftController)
|
||||
endif(WITH_THRIFT)
|
||||
|
||||
add_dependencies(MaaWpfGui MaaCore)
|
||||
if(WIN32)
|
||||
target_link_libraries(MaaCore ws2_32)
|
||||
endif()
|
||||
|
||||
if(INSTALL_PYTHON)
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
|
||||
find_package(range-v3 REQUIRED)
|
||||
target_link_libraries(MaaCore range-v3::range-v3)
|
||||
endif ()
|
||||
|
||||
if(INSTALL_DEVEL)
|
||||
set(MaaCore_install_extra_args PUBLIC_HEADER DESTINATION devel/include ARCHIVE DESTINATION devel/lib)
|
||||
endif()
|
||||
|
||||
install(TARGETS MaaCore
|
||||
RUNTIME DESTINATION .
|
||||
LIBRARY DESTINATION .
|
||||
PUBLIC_HEADER DESTINATION .
|
||||
${MaaCore_install_extra_args}
|
||||
)
|
||||
|
||||
if(INSTALL_THIRD_LIBS AND USE_MAADEPS)
|
||||
maadeps_install()
|
||||
endif()
|
||||
|
||||
if (INSTALL_PYTHON)
|
||||
install(DIRECTORY src/Python DESTINATION .)
|
||||
endif()
|
||||
|
||||
if(INSTALL_RESOURCE)
|
||||
endif (INSTALL_PYTHON)
|
||||
if (INSTALL_RESOURCE)
|
||||
install(DIRECTORY resource DESTINATION .)
|
||||
endif()
|
||||
endif (INSTALL_RESOURCE)
|
||||
|
||||
if(BUILD_DEBUG_DEMO OR BUILD_SMOKE_TEST)
|
||||
add_subdirectory(src/Cpp)
|
||||
endif()
|
||||
|
||||
if (APPLE)
|
||||
include(${PROJECT_SOURCE_DIR}/cmake/macos.cmake)
|
||||
endif (APPLE)
|
||||
|
||||
# define MAA_VERSION from git
|
||||
if (NOT DEFINED MAA_VERSION)
|
||||
find_package(Git)
|
||||
endif ()
|
||||
if (NOT DEFINED MAA_VERSION AND GIT_FOUND)
|
||||
execute_process(
|
||||
COMMAND "${GIT_EXECUTABLE}" rev-parse HEAD
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
RESULT_VARIABLE result
|
||||
OUTPUT_VARIABLE output
|
||||
ERROR_VARIABLE err
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
if (result EQUAL 0)
|
||||
set(MAA_VERSION "${output}")
|
||||
else ()
|
||||
message(WARNING "git rev-parse returning ${result}, output:\n${err}")
|
||||
endif ()
|
||||
endif ()
|
||||
if (NOT MAA_VERSION)
|
||||
set(MAA_VERSION "DEBUG VERSION")
|
||||
endif ()
|
||||
message(STATUS "MAA_VERSION=${MAA_VERSION}")
|
||||
add_compile_definitions(MAA_VERSION="${MAA_VERSION}")
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
SPDXVersion: SPDX-2.3
|
||||
DataLicense: CC0-1.0
|
||||
PackageName: MaaAssistantArknights
|
||||
PackageOriginator: Maa Team and all contributors
|
||||
PackageHomePage: https://github.com/MaaAssistantArknights/MaaAssistantArknights
|
||||
PackageLicenseDeclared: AGPL-3.0-only
|
||||
15
MAA.DotSettings
Normal file
15
MAA.DotSettings
Normal file
@@ -0,0 +1,15 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Arknights/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Bilibili/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Infrast/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=oper/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=opers/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Pallas/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Pormpt/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Rougelike/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=templ/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=thres/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Todays/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=txwy/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=vuvm/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=XYAZ/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||
106
MAA.sln
Normal file
106
MAA.sln
Normal file
@@ -0,0 +1,106 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.2.32616.157
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MaaWpfGui", "src\MaaWpfGui\MaaWpfGui.csproj", "{FFDC8F49-8EAF-45BE-B0A8-7EF0DB9875A2}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{362D1E30-F5AE-4279-9985-65C27B3BA300} = {362D1E30-F5AE-4279-9985-65C27B3BA300}
|
||||
{F860C043-4D86-41B6-A97E-4A75C9A6C4EC} = {F860C043-4D86-41B6-A97E-4A75C9A6C4EC}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MaaCore", "src\MaaCore\MaaCore.vcxproj", "{362D1E30-F5AE-4279-9985-65C27B3BA300}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MaaThriftController", "src\MaaThriftController\MaaThriftController.vcxproj", "{8238EDB1-19BF-4E3B-AF5B-016120D59D7B}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{11F02235-5785-408B-9651-8A4B41FF36F4}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
.editorconfig = .editorconfig
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SyncRes", "src\SyncRes\SyncRes.csproj", "{F860C043-4D86-41B6-A97E-4A75C9A6C4EC}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Sample", "src\Cpp\MaaSample.vcxproj", "{63B4F1A2-291C-4C85-91E1-A1F6DAE30D64}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{362D1E30-F5AE-4279-9985-65C27B3BA300} = {362D1E30-F5AE-4279-9985-65C27B3BA300}
|
||||
{F860C043-4D86-41B6-A97E-4A75C9A6C4EC} = {F860C043-4D86-41B6-A97E-4A75C9A6C4EC}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|ARM64 = Debug|ARM64
|
||||
Debug|x64 = Debug|x64
|
||||
Release|ARM64 = Release|ARM64
|
||||
Release|x64 = Release|x64
|
||||
RelWithDebInfo|ARM64 = RelWithDebInfo|ARM64
|
||||
RelWithDebInfo|x64 = RelWithDebInfo|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{FFDC8F49-8EAF-45BE-B0A8-7EF0DB9875A2}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{FFDC8F49-8EAF-45BE-B0A8-7EF0DB9875A2}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||
{FFDC8F49-8EAF-45BE-B0A8-7EF0DB9875A2}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{FFDC8F49-8EAF-45BE-B0A8-7EF0DB9875A2}.Debug|x64.Build.0 = Debug|x64
|
||||
{FFDC8F49-8EAF-45BE-B0A8-7EF0DB9875A2}.Release|ARM64.ActiveCfg = Release|ARM64
|
||||
{FFDC8F49-8EAF-45BE-B0A8-7EF0DB9875A2}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{FFDC8F49-8EAF-45BE-B0A8-7EF0DB9875A2}.Release|x64.ActiveCfg = Release|x64
|
||||
{FFDC8F49-8EAF-45BE-B0A8-7EF0DB9875A2}.Release|x64.Build.0 = Release|x64
|
||||
{FFDC8F49-8EAF-45BE-B0A8-7EF0DB9875A2}.RelWithDebInfo|ARM64.ActiveCfg = RelWithDebInfo|ARM64
|
||||
{FFDC8F49-8EAF-45BE-B0A8-7EF0DB9875A2}.RelWithDebInfo|ARM64.Build.0 = RelWithDebInfo|ARM64
|
||||
{FFDC8F49-8EAF-45BE-B0A8-7EF0DB9875A2}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
|
||||
{FFDC8F49-8EAF-45BE-B0A8-7EF0DB9875A2}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
|
||||
{362D1E30-F5AE-4279-9985-65C27B3BA300}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{362D1E30-F5AE-4279-9985-65C27B3BA300}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||
{362D1E30-F5AE-4279-9985-65C27B3BA300}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{362D1E30-F5AE-4279-9985-65C27B3BA300}.Debug|x64.Build.0 = Debug|x64
|
||||
{362D1E30-F5AE-4279-9985-65C27B3BA300}.Release|ARM64.ActiveCfg = Release|ARM64
|
||||
{362D1E30-F5AE-4279-9985-65C27B3BA300}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{362D1E30-F5AE-4279-9985-65C27B3BA300}.Release|x64.ActiveCfg = Release|x64
|
||||
{362D1E30-F5AE-4279-9985-65C27B3BA300}.Release|x64.Build.0 = Release|x64
|
||||
{362D1E30-F5AE-4279-9985-65C27B3BA300}.RelWithDebInfo|ARM64.ActiveCfg = RelWithDebInfo|ARM64
|
||||
{362D1E30-F5AE-4279-9985-65C27B3BA300}.RelWithDebInfo|ARM64.Build.0 = RelWithDebInfo|ARM64
|
||||
{362D1E30-F5AE-4279-9985-65C27B3BA300}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
|
||||
{362D1E30-F5AE-4279-9985-65C27B3BA300}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
|
||||
{8238EDB1-19BF-4E3B-AF5B-016120D59D7B}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{8238EDB1-19BF-4E3B-AF5B-016120D59D7B}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||
{8238EDB1-19BF-4E3B-AF5B-016120D59D7B}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{8238EDB1-19BF-4E3B-AF5B-016120D59D7B}.Debug|x64.Build.0 = Debug|x64
|
||||
{8238EDB1-19BF-4E3B-AF5B-016120D59D7B}.Release|ARM64.ActiveCfg = Release|ARM64
|
||||
{8238EDB1-19BF-4E3B-AF5B-016120D59D7B}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{8238EDB1-19BF-4E3B-AF5B-016120D59D7B}.Release|x64.ActiveCfg = Release|x64
|
||||
{8238EDB1-19BF-4E3B-AF5B-016120D59D7B}.Release|x64.Build.0 = Release|x64
|
||||
{8238EDB1-19BF-4E3B-AF5B-016120D59D7B}.RelWithDebInfo|ARM64.ActiveCfg = RelWithDebInfo|ARM64
|
||||
{8238EDB1-19BF-4E3B-AF5B-016120D59D7B}.RelWithDebInfo|ARM64.Build.0 = RelWithDebInfo|ARM64
|
||||
{8238EDB1-19BF-4E3B-AF5B-016120D59D7B}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
|
||||
{8238EDB1-19BF-4E3B-AF5B-016120D59D7B}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
|
||||
{F860C043-4D86-41B6-A97E-4A75C9A6C4EC}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{F860C043-4D86-41B6-A97E-4A75C9A6C4EC}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||
{F860C043-4D86-41B6-A97E-4A75C9A6C4EC}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{F860C043-4D86-41B6-A97E-4A75C9A6C4EC}.Debug|x64.Build.0 = Debug|x64
|
||||
{F860C043-4D86-41B6-A97E-4A75C9A6C4EC}.Release|ARM64.ActiveCfg = Release|ARM64
|
||||
{F860C043-4D86-41B6-A97E-4A75C9A6C4EC}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{F860C043-4D86-41B6-A97E-4A75C9A6C4EC}.Release|x64.ActiveCfg = Release|x64
|
||||
{F860C043-4D86-41B6-A97E-4A75C9A6C4EC}.Release|x64.Build.0 = Release|x64
|
||||
{F860C043-4D86-41B6-A97E-4A75C9A6C4EC}.RelWithDebInfo|ARM64.ActiveCfg = RelWithDebInfo|ARM64
|
||||
{F860C043-4D86-41B6-A97E-4A75C9A6C4EC}.RelWithDebInfo|ARM64.Build.0 = RelWithDebInfo|ARM64
|
||||
{F860C043-4D86-41B6-A97E-4A75C9A6C4EC}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
|
||||
{F860C043-4D86-41B6-A97E-4A75C9A6C4EC}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
|
||||
{63B4F1A2-291C-4C85-91E1-A1F6DAE30D64}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{63B4F1A2-291C-4C85-91E1-A1F6DAE30D64}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||
{63B4F1A2-291C-4C85-91E1-A1F6DAE30D64}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{63B4F1A2-291C-4C85-91E1-A1F6DAE30D64}.Debug|x64.Build.0 = Debug|x64
|
||||
{63B4F1A2-291C-4C85-91E1-A1F6DAE30D64}.Release|ARM64.ActiveCfg = Release|ARM64
|
||||
{63B4F1A2-291C-4C85-91E1-A1F6DAE30D64}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{63B4F1A2-291C-4C85-91E1-A1F6DAE30D64}.Release|x64.ActiveCfg = Release|x64
|
||||
{63B4F1A2-291C-4C85-91E1-A1F6DAE30D64}.Release|x64.Build.0 = Release|x64
|
||||
{63B4F1A2-291C-4C85-91E1-A1F6DAE30D64}.RelWithDebInfo|ARM64.ActiveCfg = RelWithDebInfo|ARM64
|
||||
{63B4F1A2-291C-4C85-91E1-A1F6DAE30D64}.RelWithDebInfo|ARM64.Build.0 = RelWithDebInfo|ARM64
|
||||
{63B4F1A2-291C-4C85-91E1-A1F6DAE30D64}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
|
||||
{63B4F1A2-291C-4C85-91E1-A1F6DAE30D64}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {4F2C0E4B-4FE9-47C6-A878-6BD2FAD8B9B2}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
117
MAA.sln.DotSettings
Normal file
117
MAA.sln.DotSettings
Normal file
@@ -0,0 +1,117 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=GUI/@EntryIndexedValue">GUI</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SWMINIMIZE/@EntryIndexedValue">SWMINIMIZE</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/Abbreviations/=AP/@EntryIndexedValue">AP</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/Abbreviations/=AP_002D/@EntryIndexedValue">AP-</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/Abbreviations/=CA/@EntryIndexedValue">CA</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/Abbreviations/=CA_002D/@EntryIndexedValue">CA-</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/Abbreviations/=CE/@EntryIndexedValue">CE</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/Abbreviations/=CE_002D/@EntryIndexedValue">CE-</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/Abbreviations/=EN/@EntryIndexedValue">EN</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/Abbreviations/=IS/@EntryIndexedValue">IS</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/Abbreviations/=JP/@EntryIndexedValue">JP</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/Abbreviations/=KR/@EntryIndexedValue">KR</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/Abbreviations/=LD/@EntryIndexedValue">LD</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/Abbreviations/=LS/@EntryIndexedValue">LS</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/Abbreviations/=LS_002D/@EntryIndexedValue">LS-</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/Abbreviations/=PR_002DA/@EntryIndexedValue">PR-A</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/Abbreviations/=PR_002DA_002D/@EntryIndexedValue">PR-A-</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/Abbreviations/=PR_002DB/@EntryIndexedValue">PR-B</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/Abbreviations/=PR_002DB_002D/@EntryIndexedValue">PR-B-</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/Abbreviations/=PR_002DC/@EntryIndexedValue">PR-C</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/Abbreviations/=PR_002DC_002D/@EntryIndexedValue">PR-C-</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/Abbreviations/=PR_002DD/@EntryIndexedValue">PR-D</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/Abbreviations/=PR_002DD_002D/@EntryIndexedValue">PR-D-</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/Abbreviations/=SK/@EntryIndexedValue">SK</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/Abbreviations/=SK_002D/@EntryIndexedValue">SK-</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/Abbreviations/=SSS/@EntryIndexedValue">SSS</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/Abbreviations/=WSA/@EntryIndexedValue">WSA</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/Abbreviations/=XYAZ/@EntryIndexedValue">XYAZ</s:String>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=acast/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Aero/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=aguard/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=amedic/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=amiya/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=apionr/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=arget/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Arknights/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=arkplanner/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=asnipe/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=autofill/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Bilibili/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Bluestacks/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=bsconsole/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=desp/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=dnplayer/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Ehem/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=esource/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Favourite/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=findstr/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=FLASHW/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=FLASHWINFO/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=foldartal/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=furni/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Gacha/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Gavial/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Grandet/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Hotkey/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=hwnd/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Infrast/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Inited/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=ldconsole/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Lolicon/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=lpwndpl/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=ls_005B_0022sub/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=luestacks/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=maatouch/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=memuc/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Minitouch/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Mizuki/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Nemu/@EntryIndexedValue">True</s:Boolean>
|
||||
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=netstat/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Nonfriend/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=notstationed/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=oper/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=opers/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Originite/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Originium/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=originiums/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Orundum/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Orundums/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=o_FF9Fv_FF9F/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Pallas/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=pidl/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Pormpt/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=ppidl/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Prts/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=pwfi/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=qodana/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=rcast/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=rdfend/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=rguard/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=rmean/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=rmedic/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Roguelike/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=rsnipe/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Sami/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Screencap/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=serilog/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Showminimized/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Shownormal/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=SSS/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=STGM/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=strlen/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Stylet/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=subtask/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Suppressions/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=SWMINIMIZE/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=taskchain/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Todays/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=txwy/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=ucrtbase/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=XYAZ/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Yahei/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=yituliu/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=_0020_0020_0020wp_002ELength_0020/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=_0020_003D_0020stri/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||
1
MaaDeps
Submodule
1
MaaDeps
Submodule
Submodule MaaDeps added at 1297324ea7
187
README.md
187
README.md
@@ -1,10 +1,8 @@
|
||||
<!-- markdownlint-disable -->
|
||||
|
||||
<div align="center">
|
||||
|
||||
<img alt="LOGO" src="./docs/.vuepress/public/images/maa-logo_512x512.png" width="256" height="256" />
|
||||
<img alt="LOGO" src="https://cdn.jsdelivr.net/gh/MaaAssistantArknights/design@main/logo/maa-logo_512x512.png" width="256" height="256" />
|
||||
|
||||
# MAA
|
||||
# MaaAssistantArknights
|
||||
|
||||
<br>
|
||||
<div>
|
||||
@@ -23,9 +21,7 @@
|
||||
</div>
|
||||
<br>
|
||||
|
||||
<!-- markdownlint-restore -->
|
||||
|
||||
[简体中文](https://docs.maa.plus/zh-cn/) | [繁體中文](https://docs.maa.plus/zh-tw/) | [English](https://docs.maa.plus/en-us/) | [日本語](https://docs.maa.plus/ja-jp/) | [한국어](https://docs.maa.plus/ko-kr/)
|
||||
[简体中文](https://maa.plus/docs/) | [繁體中文](https://maa.plus/docs/zh-tw/) | [English](https://maa.plus/docs/en-us/) | [日本語](https://maa.plus/docs/ja-jp/) | [한국어](https://maa.plus/docs/ko-kr/)
|
||||
|
||||
MAA 的意思是 MAA Assistant Arknights
|
||||
|
||||
@@ -33,66 +29,67 @@ MAA 的意思是 MAA Assistant Arknights
|
||||
|
||||
基于图像识别技术,一键完成全部日常任务!
|
||||
|
||||
绝赞更新中 ✿✿ヽ(°▽°)ノ✿
|
||||
绝赞更新中 ✿✿ヽ(°▽°)ノ✿<br>
|
||||
|
||||
</div>
|
||||
|
||||
## 下载与安装
|
||||
|
||||
请阅读 [文档](https://docs.maa.plus/zh-cn/manual/newbie.html) 后前往 [官网](https://maa.plus) 或 [Releases](https://github.com/MaaAssistantArknights/MaaAssistantArknights/releases) 下载,并参考 [新手上路](https://docs.maa.plus/zh-cn/manual/newbie.html) 进行安装。
|
||||
|
||||
## 亮点功能
|
||||
|
||||
- 刷理智,掉落识别及上传 [企鹅物流](https://penguin-stats.cn/),[一图流](https://ark.yituliu.cn/)
|
||||
- 智能基建换班,自动计算干员效率,单设施内最优解;同时也支持 [自定义排班](https://docs.maa.plus/zh-cn/protocol/base-scheduling-schema.html)
|
||||
- 自动公招,可选使用加急许可,一次全部刷完!公招数据自动上传 [企鹅物流](https://penguin-stats.cn/result/stage/recruit/recruit),[一图流](https://ark.yituliu.cn/survey/maarecruitdata)
|
||||
- 支持手动识别公招界面,方便对高星公招做出选择 ~~(你的这个高资回费出的是推王呢还是推王呢)~~
|
||||
- 支持识别干员列表,统计已有和未有干员及潜能,并在公招识别显示
|
||||
- 支持识别养成材料,并导出至 [企鹅物流刷图规划](https://penguin-stats.cn/planner)、[明日方舟工具箱](https://arkntools.app/#/material)、[ARK-NIGHTS 干员培养表](https://ark-nights.com/settings)
|
||||
- 访问好友、收取信用及购物、领取日常奖励等,一键全日常自动长草
|
||||
- 肉鸽全自动刷源石锭和等级,自动烧水和凹直升,智能识别干员及练度
|
||||
- 选择作业 JSON 文件,自动抄作业, [视频演示](https://www.bilibili.com/video/BV1H841177Fk/)
|
||||
- 刷理智,掉落识别及上传 [企鹅物流](https://penguin-stats.cn/);
|
||||
- 智能基建换班,自动计算干员效率,单设施内最优解;同时也支持 [自定义排班](https://maa.plus/docs/协议文档/基建排班协议.html);
|
||||
- 自动公招,可选使用加急许可,一次全部刷完!公招数据上传 [企鹅物流](https://penguin-stats.cn/result/stage/recruit/recruit),[一图流](https://yituliu.site/maarecruitdata);
|
||||
- 支持手动识别公招界面,方便对高星公招做出选择; ~~(你的这个高姿回费出的是推王呢还是推王呢)~~
|
||||
- 支持识别干员列表,统计已有和未有干员(还能为手动识别公招界面提供已有潜能数据提示);
|
||||
- 支持识别养成材料,并可导出至 [企鹅物流刷图规划](https://penguin-stats.cn/planner) 和 [明日方舟工具箱](https://arkn.lolicon.app/#/material) 计算缺少的养成材料;
|
||||
- 访问好友、收取信用及购物、领取日常奖励等,一键全日常自动长草;
|
||||
- 肉鸽全自动刷源石锭和蜡烛,自动识别干员及练度;
|
||||
- 选择作业 JSON 文件,自动抄作业, [视频演示](https://www.bilibili.com/video/BV1H841177Fk/);
|
||||
- 仓库识别并支持导出至 [企鹅物流刷图规划器](https://penguin-stats.cn/planner), [明日方舟工具箱](https://arkn.lolicon.app/#/material), [ARK-NIGHTS 干员培养表](https://ark-nights.com/settings);
|
||||
- 支持 C, Python, Java, Rust, Golang, Java HTTP, Rust HTTP 等多种接口,方便集成调用,自定义你的 MAA!
|
||||
|
||||
<!-- markdownlint-disable -->
|
||||
话不多说,看图!<br>
|
||||
|
||||
<details><summary>话不多说,看图!</summary>
|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="./docs/.vuepress/public/images/zh-cn/readme/1-dark.png">
|
||||
<img alt="zh1" src="./docs/.vuepress/public/images/zh-cn/readme/1-light.png">
|
||||
</picture>
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="./docs/.vuepress/public/images/zh-cn/readme/2-dark.png">
|
||||
<img alt="zh2" src="./docs/.vuepress/public/images/zh-cn/readme/2-light.png">
|
||||
</picture>
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="./docs/.vuepress/public/images/zh-cn/readme/3-dark.png">
|
||||
<img alt="zh3" src="./docs/.vuepress/public/images/zh-cn/readme/3-light.png">
|
||||
</picture>
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="./docs/.vuepress/public/images/zh-cn/readme/4-dark.png">
|
||||
<img alt="zh4" src="./docs/.vuepress/public/images/zh-cn/readme/4-light.png">
|
||||
</picture>
|
||||
## 下载地址
|
||||
|
||||
</details>
|
||||
|
||||
<!-- markdownlint-restore -->
|
||||
- [稳定版/公测版](https://github.com/MaaAssistantArknights/MaaAssistantArknights/releases)
|
||||
- [内测版](https://github.com/MaaAssistantArknights/MaaRelease/releases)
|
||||
|
||||
## 使用说明
|
||||
|
||||
### 功能介绍
|
||||
### 基本说明
|
||||
|
||||
请参阅 [用户手册](https://docs.maa.plus/zh-cn/manual/)。
|
||||
1. 请根据 [模拟器和设备支持情况](https://maa.plus/docs/用户手册/模拟器和设备支持),进行对应的操作;
|
||||
2. 修改模拟器分辨率为 `16:9` 比例,最低 `1280 * 720`,最高 `2K`;<br>
|
||||
对于国际服(美服)玩家,由于界面布局、字号等问题,我们则建议您将分辨率修改为 `1920 * 1080`;
|
||||
3. 开始使用吧!
|
||||
|
||||
更多使用说明请参考 [详细介绍](https://maa.plus/docs/用户手册/详细介绍.html)
|
||||
|
||||
### 常见问题
|
||||
|
||||
- 软件一打开就闪退;
|
||||
- 连接错误、不知道 adb 路径怎么填写;
|
||||
- 连接成功了,但没反应;
|
||||
- 如何连接自定义端口;
|
||||
- 下载速度慢,且镜像站无法打开网页;
|
||||
- 下载到一半提示“登陆”/“鉴权”;
|
||||
- 连接正常,任务开始了,但是没反应。
|
||||
|
||||
请参考 [常见问题](https://maa.plus/docs/用户手册/常见问题.html)
|
||||
|
||||
### 外服支持
|
||||
|
||||
目前国际服(美服)、日服、韩服、繁中服的绝大部分功能均已支持。但由于外服用户较少及项目人手不足,很多功能并没有进行全面的测试,所以请自行体验。
|
||||
若您遇到了 Bug,或对某个功能有强需求,欢迎在 [Issues](https://github.com/MaaAssistantArknights/MaaAssistantArknights/issues) 和 [讨论区](https://github.com/MaaAssistantArknights/MaaAssistantArknights/discussions) 催更;或加入我们一起建设 MAA!请参阅 [外服适配教程](https://docs.maa.plus/zh-cn/develop/overseas-client-adaptation.html)
|
||||
目前国际服(美服)、日服、韩服、繁中服的绝大部分功能均已支持。但由于外服用户较少及项目人手不足,很多功能并没有进行全面的测试,所以请自行体验。<br>
|
||||
若您遇到了 Bug,或对某个功能有强需求,欢迎在 [Issues](https://github.com/MaaAssistantArknights/MaaAssistantArknights/issues) 和 [讨论区](https://github.com/MaaAssistantArknights/MaaAssistantArknights/discussions) 催更;或加入我们一起建设 MAA!请参考 [外服适配教程](#外服适配)
|
||||
|
||||
### CLI 支持
|
||||
### CLI支持
|
||||
|
||||
MAA 支持命令行界面(CLI)操作,支持 Linux,macOS 和 Windows,可用于自动化脚本或在无图形界面的服务器上使用。请参阅 [CLI 使用指南](https://docs.maa.plus/zh-cn/manual/cli/)
|
||||
MAA 支持命令行界面(CLI)操作,支持 Linux,macOS 和 Windows,可用于自动化脚本或在无图形界面的服务器上使用。请参考 [CLI 使用指南](https://maa.plus/docs/用户手册/CLI使用指南.html)
|
||||
|
||||
## 加入我们
|
||||
|
||||
@@ -100,7 +97,8 @@ MAA 支持命令行界面(CLI)操作,支持 Linux,macOS 和 Windows,
|
||||
|
||||
**目前项目组非常缺前端大佬,若您有相关经验,欢迎加入我们!**
|
||||
|
||||
- 全新框架:[MaaFramework](https://github.com/MaaXYZ/MaaFramework)
|
||||
- 全新框架:[MaaFramework](https://github.com/MaaAssistantArknights/MaaFramework)
|
||||
- 全新 GUI:[MaaX](https://github.com/MaaAssistantArknights/MaaX)
|
||||
- [作业站](https://prts.plus) 前端:[maa-copilot-frontend](https://github.com/MaaAssistantArknights/maa-copilot-frontend)
|
||||
- [作业站](https://prts.plus) 后端:[MaaBackendCenter](https://github.com/MaaAssistantArknights/MaaBackendCenter)
|
||||
- [官网](https://maa.plus):[前端](https://github.com/MaaAssistantArknights/maa-website)
|
||||
@@ -108,45 +106,56 @@ MAA 支持命令行界面(CLI)操作,支持 Linux,macOS 和 Windows,
|
||||
|
||||
### 多语言 (i18n)
|
||||
|
||||
MAA 支持多国语言,并使用 Weblate 进行本地化管理。如果您通晓多门语言,欢迎前往 [MAA Weblate](https://weblate.maa-org.net) 帮助我们进行翻译。
|
||||
|
||||
MAA 以中文(简体)为第一语言,翻译词条均以中文(简体)为准。
|
||||
|
||||
### 参与开发
|
||||
[](https://weblate.maa-org.net/engage/maa-assistant-arknights/zh_Hans/)
|
||||
|
||||
#### Windows
|
||||
### Windows
|
||||
|
||||
请参阅 [开始开发](https://docs.maa.plus/zh-cn/develop/development.html)。
|
||||
1. 下载预构建的第三方库
|
||||
|
||||
#### Linux | macOS
|
||||
```cmd
|
||||
python maadeps-download.py
|
||||
```
|
||||
|
||||
请参阅 [Linux 编译教程](https://docs.maa.plus/zh-cn/develop/linux-tutorial.html)。
|
||||
2. 使用 Visual Studio 2022 打开 `MAA.sln`,右键 `MaaWpfGui`,设为启动项目
|
||||
3. VS 上方配置选择 `RelWithDebInfo` `x64` (如果编译 Release 包 或 ARM 平台,请忽略这步)
|
||||
4. 右键 `MaaWpfGui` - 属性 - 调试 - 启用本地调试(这样就能把断点挂到 C++ Core 那边了)
|
||||
5. (可选)若准备提交 PR,建议启用 [clang-format 支持](https://maa.plus/docs/开发文档/开始开发.html#在-visual-studio-中启用-clang-format)
|
||||
|
||||
#### API
|
||||
### Linux | macOS
|
||||
|
||||
请参考 [Linux 编译教程](https://maa.plus/docs/开发文档/Linux编译教程.html)
|
||||
|
||||
### API
|
||||
|
||||
- [C 接口](include/AsstCaller.h):[集成示例](src/Cpp/main.cpp)
|
||||
- [Python 接口](src/Python/asst/asst.py):[集成示例](src/Python/sample.py)
|
||||
- [Golang 接口](src/Golang):[集成示例](src/Golang/maa/maa.go)
|
||||
- [Dart 接口](src/Dart)
|
||||
- [Golang 接口](src/Golang/):[集成示例](src/Golang/maa/maa.go)
|
||||
- [Dart 接口](src/Dart/)
|
||||
- [Java 接口](src/Java/src/main/java/com/iguigui/maaj/easySample/MaaCore.java):[集成示例](src/Java/src/main/java/com/iguigui/maaj/easySample/MaaJavaSample.java)
|
||||
- [Java HTTP 接口](src/Java/Readme.md)
|
||||
- [Rust 接口](src/Rust/src/maa_sys):[HTTP 接口](src/Rust)
|
||||
- [TypeScript 接口](https://github.com/MaaAssistantArknights/MaaX/tree/main/packages/main/coreLoader)
|
||||
- [Woolang 接口](src/Woolang/maa.wo):[集成示例](src/Woolang/demo.wo)
|
||||
- [集成文档](https://docs.maa.plus/zh-cn/protocol/integration.html)
|
||||
- [回调消息协议](https://docs.maa.plus/zh-cn/protocol/callback-schema.html)
|
||||
- [任务流程协议](https://docs.maa.plus/zh-cn/protocol/task-schema.html)
|
||||
- [自动抄作业协议](https://docs.maa.plus/zh-cn/protocol/copilot-schema.html)
|
||||
- [Rust 接口](src/Rust/src/maa_sys/):[HTTP 接口](src/Rust)
|
||||
- [TypeScript 接口](https://github.com/MaaAssistantArknights/MaaAsstElectronUI/tree/main/packages/main/coreLoader)
|
||||
- [Woolang 接口](src/Woolang/maa.wo):[集成示例](src/Woolang/main.wo)
|
||||
- [集成文档](https://maa.plus/docs/协议文档/集成文档.html)
|
||||
- [回调消息协议](https://maa.plus/docs/协议文档/回调消息协议.html)
|
||||
- [任务流程协议](https://maa.plus/docs/协议文档/任务流程协议.html)
|
||||
- [自动抄作业协议](https://maa.plus/docs/协议文档/战斗流程协议.html)
|
||||
|
||||
#### 外服适配
|
||||
### 外服适配
|
||||
|
||||
请参阅 [外服适配教程](https://docs.maa.plus/zh-cn/develop/overseas-client-adaptation.html),对于国服已支持的功能,绝大部分的外服适配工作仅需要截图 + 简单的 JSON 修改即可。
|
||||
请参考 [外服适配教程](https://maa.plus/docs/开发文档/外服适配教程.html),对于国服已支持的功能,绝大部分的外服适配工作仅需要截图 + 简单的 JSON 修改即可。
|
||||
|
||||
#### 想参与开发,但不太会用 GitHub?
|
||||
### 想参与开发,但不太会用 GitHub?
|
||||
|
||||
[GitHub Pull Request 流程简述](https://docs.maa.plus/zh-cn/develop/development.html#github-pull-request-流程简述)
|
||||
[GitHub Pull Request 流程简述](https://maa.plus/docs/开发文档/开始开发.html#github-pull-request-流程简述)
|
||||
|
||||
#### Issue bot
|
||||
### Issue bot
|
||||
|
||||
请参阅 [Issue Bot 使用方法](https://docs.maa.plus/zh-cn/develop/issue-bot-usage.html)
|
||||
请参考 [Issue bot 使用方法](https://maa.plus/docs/开发文档/IssueBot使用方法.html)
|
||||
|
||||
## 致谢
|
||||
|
||||
@@ -159,52 +168,46 @@ MAA 以中文(简体)为第一语言,翻译词条均以中文(简体)
|
||||
- 机器学习加速器:[onnxruntime](https://github.com/microsoft/onnxruntime)
|
||||
- ~~关卡掉落识别:[企鹅物流识别](https://github.com/penguin-statistics/recognizer)~~
|
||||
- 地图格子识别:[Arknights-Tile-Pos](https://github.com/yuanyan3060/Arknights-Tile-Pos)
|
||||
- C++ JSON 库:[meojson](https://github.com/MistEO/meojson.git)
|
||||
- C++ JSON库:[meojson](https://github.com/MistEO/meojson.git)
|
||||
- C++ 运算符解析器:[calculator](https://github.com/kimwalisch/calculator)
|
||||
- ~~C++ base64 编解码:[cpp-base64](https://github.com/ReneNyffenegger/cpp-base64)~~
|
||||
- ~~C++ base64编解码:[cpp-base64](https://github.com/ReneNyffenegger/cpp-base64)~~
|
||||
- C++ 解压压缩库:[zlib](https://github.com/madler/zlib)
|
||||
- C++ Gzip 封装:[gzip-hpp](https://github.com/mapbox/gzip-hpp)
|
||||
- 安卓触控事件器:[Minitouch](https://github.com/DeviceFarmer/minitouch)
|
||||
- C++ Gzip封装:[gzip-hpp](https://github.com/mapbox/gzip-hpp)
|
||||
- 安卓触控事件器:[minitouch](https://github.com/openstf/minitouch)
|
||||
- 安卓触控事件器:[MaaTouch](https://github.com/MaaAssistantArknights/MaaTouch)
|
||||
- WPF MVVM 框架:[Stylet](https://github.com/canton7/Stylet)
|
||||
- WPF 控件库:[HandyControl](https://github.com/HandyOrg/HandyControl) -> [HandyControls](https://github.com/ghost1372/HandyControls)
|
||||
- WPF MVVM框架:[Stylet](https://github.com/canton7/Stylet)
|
||||
- WPF控件库:[HandyControl](https://github.com/HandyOrg/HandyControl) -> [HandyControls](https://github.com/ghost1372/HandyControls)
|
||||
- C# 日志:[Serilog](https://github.com/serilog/serilog)
|
||||
- C# JSON 库:[Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json) & [System.Text.Json](https://github.com/dotnet/runtime)
|
||||
- C# JSON库:[Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json) & [System.Text.Json](https://github.com/dotnet/runtime)
|
||||
- ~~下载器:[aria2](https://github.com/aria2/aria2)~~
|
||||
|
||||
### 数据源
|
||||
|
||||
- ~~公开招募数据:[明日方舟工具箱](https://www.bigfun.cn/tools/aktools/hr)~~
|
||||
- ~~干员及基建数据:[PRTS Wiki](http://prts.wiki/)~~
|
||||
- ~~干员及基建数据:[PRTS明日方舟中文WIKI](http://prts.wiki/)~~
|
||||
- 关卡数据:[企鹅物流数据统计](https://penguin-stats.cn/)
|
||||
- 游戏数据及资源:[明日方舟客户端素材](https://github.com/yuanyan3060/ArknightsGameResource)
|
||||
- 游戏数据:[《明日方舟》Yostar游戏数据](https://github.com/ArknightsAssets/ArknightsGamedata)
|
||||
- ~~游戏数据:[《明日方舟》游戏数据](https://github.com/Kengxxiao/ArknightsGameData)~~
|
||||
|
||||
### 贡献/参与者
|
||||
|
||||
感谢所有参与到开发/测试中的朋友们,是大家的帮助让 MAA 越来越好! (\*´▽`)ノノ
|
||||
|
||||
[](https://github.com/MaaAssistantArknights/MaaAssistantArknights/graphs/contributors)
|
||||
[](https://github.com/MaaAssistantArknights/MaaAssistantArknights/graphs/contributors)
|
||||
|
||||
## 声明
|
||||
|
||||
- 本软件使用 [GNU Affero General Public License v3.0 only](https://spdx.org/licenses/AGPL-3.0-only.html) 开源,并附带额外 [用户协议](https://github.com/MaaAssistantArknights/MaaAssistantArknights/blob/dev/terms-of-service.md)。
|
||||
- 本软件 logo 并非使用 AGPL 3.0 协议开源,[耗毛](https://weibo.com/u/3251357314)、vie 两位画师及软件全体开发者保留所有权利。不得以 AGPL 3.0 协议已授权为由在未经授权的情况下使用本软件 logo,不得在未经授权的情况下将本软件 logo 用于任何商业用途。
|
||||
- 本软件开源、免费,仅供学习交流使用。若您遇到商家使用本软件进行代练并收费,可能是设备与时间等费用,产生的问题及后果与本软件无关。
|
||||
|
||||
### DirectML 支持说明
|
||||
|
||||
本软件支持 GPU 加速功能,其在 Windows 平台上依赖于 Microsoft 提供的独立组件 [DirectML](https://learn.microsoft.com/en-us/windows/ai/directml/)。DirectML 并非本项目的开源部分,也不受 AGPL 3.0 的约束。为方便用户,我们随安装包附带了一个未经修改的 DirectML.dll 文件。如果您无需 GPU 加速功能,可安全删除该 DLL 文件,软件的核心功能仍可正常运行。
|
||||
|
||||
## 广告
|
||||
|
||||
用户交流 QQ 群:[MAA 使用 & 粥游交流 QQ 群](https://api.maa.plus/MaaAssistantArknights/api/qqgroup/index.html)
|
||||
Discord 服务器: [邀请链接](https://discord.gg/23DfZ9uA4V)
|
||||
用户交流 TG 群:[Telegram 群](https://t.me/+Mgc2Zngr-hs3ZjU1)
|
||||
自动战斗 JSON 作业分享:[prts.plus](https://prts.plus)
|
||||
Bilibili 直播间:[MrEO 直播间](https://live.bilibili.com/2808861) 直播敲代码 & [MAA-Official 直播间](https://live.bilibili.com/27548877) 游戏/杂谈
|
||||
用户交流 QQ 群:[MAA 使用 & 粥游交流 QQ 群](https://ota.maa.plus/MaaAssistantArknights/api/qqgroup/index.html)<br>
|
||||
用户交流 TG 群:[Telegram 群](https://t.me/+Mgc2Zngr-hs3ZjU1)<br>
|
||||
自动战斗 JSON 作业分享:[prts.plus](https://prts.plus) 或 [抄作业.com](http://抄作业.com)<br>
|
||||
Bilibili 直播间:[直播间](https://live.bilibili.com/2808861) 每晚直播敲代码,近期很长一段时间应该都是在写本软件~<br>
|
||||
|
||||
技术群(舟无关、禁水):[内卷地狱!(QQ 群)](https://jq.qq.com/?_wv=1027&k=ypbzXcA2)
|
||||
开发者群:[QQ 群](https://jq.qq.com/?_wv=1027&k=JM9oCk3C)
|
||||
技术群(舟无关、禁水):[内卷地狱!(QQ 群)](https://jq.qq.com/?_wv=1027&k=ypbzXcA2)<br>
|
||||
开发者群:[QQ 群](https://jq.qq.com/?_wv=1027&k=JM9oCk3C)<br>
|
||||
|
||||
如果觉得软件对你有帮助,帮忙点个 Star 吧!~(网页最上方右上角的小星星),这就是对我们最大的支持了!
|
||||
|
||||
7
build.cmd
Normal file
7
build.cmd
Normal file
@@ -0,0 +1,7 @@
|
||||
:; set -eo pipefail
|
||||
:; SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)
|
||||
:; ${SCRIPT_DIR}/build.sh "$@"
|
||||
:; exit $?
|
||||
|
||||
@ECHO OFF
|
||||
powershell -ExecutionPolicy ByPass -NoProfile -File "%~dp0build.ps1" %*
|
||||
69
build.ps1
Normal file
69
build.ps1
Normal file
@@ -0,0 +1,69 @@
|
||||
[CmdletBinding()]
|
||||
Param(
|
||||
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
|
||||
[string[]]$BuildArguments
|
||||
)
|
||||
|
||||
Write-Output "PowerShell $($PSVersionTable.PSEdition) version $($PSVersionTable.PSVersion)"
|
||||
|
||||
Set-StrictMode -Version 2.0; $ErrorActionPreference = "Stop"; $ConfirmPreference = "None"; trap { Write-Error $_ -ErrorAction Continue; exit 1 }
|
||||
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
|
||||
|
||||
###########################################################################
|
||||
# CONFIGURATION
|
||||
###########################################################################
|
||||
|
||||
$BuildProjectFile = "$PSScriptRoot\tools\MaaBuilder\MaaBuilder.csproj"
|
||||
$TempDirectory = "$PSScriptRoot\\.nuke\temp"
|
||||
|
||||
$DotNetGlobalFile = "$PSScriptRoot\\global.json"
|
||||
$DotNetInstallUrl = "https://dot.net/v1/dotnet-install.ps1"
|
||||
$DotNetChannel = "Current"
|
||||
|
||||
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1
|
||||
$env:DOTNET_CLI_TELEMETRY_OPTOUT = 1
|
||||
$env:DOTNET_MULTILEVEL_LOOKUP = 0
|
||||
|
||||
###########################################################################
|
||||
# EXECUTION
|
||||
###########################################################################
|
||||
|
||||
function ExecSafe([scriptblock] $cmd) {
|
||||
& $cmd
|
||||
if ($LASTEXITCODE) { exit $LASTEXITCODE }
|
||||
}
|
||||
|
||||
# If dotnet CLI is installed globally and it matches requested version, use for execution
|
||||
if ($null -ne (Get-Command "dotnet" -ErrorAction SilentlyContinue) -and `
|
||||
$(dotnet --version) -and $LASTEXITCODE -eq 0) {
|
||||
$env:DOTNET_EXE = (Get-Command "dotnet").Path
|
||||
}
|
||||
else {
|
||||
# Download install script
|
||||
$DotNetInstallFile = "$TempDirectory\dotnet-install.ps1"
|
||||
New-Item -ItemType Directory -Path $TempDirectory -Force | Out-Null
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallUrl, $DotNetInstallFile)
|
||||
|
||||
# If global.json exists, load expected version
|
||||
if (Test-Path $DotNetGlobalFile) {
|
||||
$DotNetGlobal = $(Get-Content $DotNetGlobalFile | Out-String | ConvertFrom-Json)
|
||||
if ($DotNetGlobal.PSObject.Properties["sdk"] -and $DotNetGlobal.sdk.PSObject.Properties["version"]) {
|
||||
$DotNetVersion = $DotNetGlobal.sdk.version
|
||||
}
|
||||
}
|
||||
|
||||
# Install by channel or version
|
||||
$DotNetDirectory = "$TempDirectory\dotnet-win"
|
||||
if (!(Test-Path variable:DotNetVersion)) {
|
||||
ExecSafe { & powershell $DotNetInstallFile -InstallDir $DotNetDirectory -Channel $DotNetChannel -NoPath }
|
||||
} else {
|
||||
ExecSafe { & powershell $DotNetInstallFile -InstallDir $DotNetDirectory -Version $DotNetVersion -NoPath }
|
||||
}
|
||||
$env:DOTNET_EXE = "$DotNetDirectory\dotnet.exe"
|
||||
}
|
||||
|
||||
Write-Output "Microsoft (R) .NET SDK version $(& $env:DOTNET_EXE --version)"
|
||||
|
||||
ExecSafe { & $env:DOTNET_EXE build $BuildProjectFile /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet }
|
||||
ExecSafe { & $env:DOTNET_EXE run --project $BuildProjectFile --no-build -- $BuildArguments }
|
||||
62
build.sh
Normal file
62
build.sh
Normal file
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
bash --version 2>&1 | head -n 1
|
||||
|
||||
set -eo pipefail
|
||||
SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)
|
||||
|
||||
###########################################################################
|
||||
# CONFIGURATION
|
||||
###########################################################################
|
||||
|
||||
BUILD_PROJECT_FILE="$SCRIPT_DIR/tools/MaaBuilder/MaaBuilder.csproj"
|
||||
TEMP_DIRECTORY="$SCRIPT_DIR//.nuke/temp"
|
||||
|
||||
DOTNET_GLOBAL_FILE="$SCRIPT_DIR//global.json"
|
||||
DOTNET_INSTALL_URL="https://dot.net/v1/dotnet-install.sh"
|
||||
DOTNET_CHANNEL="Current"
|
||||
|
||||
export DOTNET_CLI_TELEMETRY_OPTOUT=1
|
||||
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
|
||||
export DOTNET_MULTILEVEL_LOOKUP=0
|
||||
|
||||
###########################################################################
|
||||
# EXECUTION
|
||||
###########################################################################
|
||||
|
||||
function FirstJsonValue {
|
||||
perl -nle 'print $1 if m{"'"$1"'": "([^"]+)",?}' <<< "${@:2}"
|
||||
}
|
||||
|
||||
# If dotnet CLI is installed globally and it matches requested version, use for execution
|
||||
if [ -x "$(command -v dotnet)" ] && dotnet --version &>/dev/null; then
|
||||
export DOTNET_EXE="$(command -v dotnet)"
|
||||
else
|
||||
# Download install script
|
||||
DOTNET_INSTALL_FILE="$TEMP_DIRECTORY/dotnet-install.sh"
|
||||
mkdir -p "$TEMP_DIRECTORY"
|
||||
curl -Lsfo "$DOTNET_INSTALL_FILE" "$DOTNET_INSTALL_URL"
|
||||
chmod +x "$DOTNET_INSTALL_FILE"
|
||||
|
||||
# If global.json exists, load expected version
|
||||
if [[ -f "$DOTNET_GLOBAL_FILE" ]]; then
|
||||
DOTNET_VERSION=$(FirstJsonValue "version" "$(cat "$DOTNET_GLOBAL_FILE")")
|
||||
if [[ "$DOTNET_VERSION" == "" ]]; then
|
||||
unset DOTNET_VERSION
|
||||
fi
|
||||
fi
|
||||
|
||||
# Install by channel or version
|
||||
DOTNET_DIRECTORY="$TEMP_DIRECTORY/dotnet-unix"
|
||||
if [[ -z ${DOTNET_VERSION+x} ]]; then
|
||||
"$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --channel "$DOTNET_CHANNEL" --no-path
|
||||
else
|
||||
"$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --version "$DOTNET_VERSION" --no-path
|
||||
fi
|
||||
export DOTNET_EXE="$DOTNET_DIRECTORY/dotnet"
|
||||
fi
|
||||
|
||||
echo "Microsoft (R) .NET SDK version $("$DOTNET_EXE" --version)"
|
||||
|
||||
"$DOTNET_EXE" build "$BUILD_PROJECT_FILE" /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet
|
||||
"$DOTNET_EXE" run --project "$BUILD_PROJECT_FILE" --no-build -- "$@"
|
||||
22
cmake/FindFastDeploy.cmake
Normal file
22
cmake/FindFastDeploy.cmake
Normal file
@@ -0,0 +1,22 @@
|
||||
# TODO: replace with cmake-generated interface file
|
||||
|
||||
find_path(FastDeploy_INCLUDE_DIR NAMES fastdeploy/fastdeploy_model.h)
|
||||
|
||||
find_library(FastDeploy_LIBRARY NAMES fastdeploy)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(
|
||||
FastDeploy
|
||||
REQUIRED_VARS FastDeploy_LIBRARY FastDeploy_INCLUDE_DIR
|
||||
)
|
||||
|
||||
if(FastDeploy_FOUND)
|
||||
set(FastDeploy_INCLUDE_DIRS ${FastDeploy_INCLUDE_DIR})
|
||||
if(NOT TARGET FastDeploy::FastDeploy)
|
||||
add_library(FastDeploy::FastDeploy UNKNOWN IMPORTED)
|
||||
set_target_properties(FastDeploy::FastDeploy PROPERTIES
|
||||
IMPORTED_LOCATION "${FastDeploy_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${FastDeploy_INCLUDE_DIR}"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
20
cmake/FindONNXRuntime.cmake
Normal file
20
cmake/FindONNXRuntime.cmake
Normal file
@@ -0,0 +1,20 @@
|
||||
find_path(ONNXRuntime_INCLUDE_DIR NAMES onnxruntime/core/session/onnxruntime_c_api.h)
|
||||
|
||||
find_library(ONNXRuntime_LIBRARY NAMES onnxruntime)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(
|
||||
ONNXRuntime
|
||||
REQUIRED_VARS ONNXRuntime_LIBRARY ONNXRuntime_INCLUDE_DIR
|
||||
)
|
||||
|
||||
if(ONNXRuntime_FOUND)
|
||||
set(ONNXRuntime_INCLUDE_DIRS ${ONNXRuntime_INCLUDE_DIR})
|
||||
if(NOT TARGET ONNXRuntime::ONNXRuntime)
|
||||
add_library(ONNXRuntime::ONNXRuntime UNKNOWN IMPORTED)
|
||||
set_target_properties(ONNXRuntime::ONNXRuntime PROPERTIES
|
||||
IMPORTED_LOCATION "${ONNXRuntime_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${ONNXRuntime_INCLUDE_DIR}"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
@@ -1,83 +0,0 @@
|
||||
set(debug_comp_defs "_DEBUG;ASST_DEBUG")
|
||||
add_compile_definitions("$<$<CONFIG:Debug>:${debug_comp_defs}>")
|
||||
|
||||
if(APPLE)
|
||||
set(CMAKE_INSTALL_RPATH "@loader_path;@executable_path")
|
||||
set(CMAKE_BUILD_RPATH "@loader_path;@executable_path")
|
||||
elseif(UNIX)
|
||||
set(CMAKE_INSTALL_RPATH "$ORIGIN")
|
||||
set(CMAKE_BUILD_RPATH "$ORIGIN")
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
add_compile_options("/utf-8")
|
||||
add_compile_options("/MP")
|
||||
add_compile_options("/W4;/WX;/Gy;/permissive-;/sdl")
|
||||
add_compile_options("/wd4127") # conditional expression is constant
|
||||
add_compile_options("/wd4251") # export dll with templates
|
||||
|
||||
add_compile_options("/DWINVER=0x0A00")
|
||||
add_compile_options("/D_WIN32_WINNT=0x0A00")
|
||||
|
||||
# https://github.com/actions/runner-images/issues/10004 https://github.com/microsoft/STL/releases/tag/vs-2022-17.10
|
||||
add_compile_definitions("_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR")
|
||||
|
||||
set(release_link_options "/OPT:REF;/OPT:ICF")
|
||||
add_link_options("$<$<CONFIG:Release>:${release_link_options}>")
|
||||
SET(CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBINFO "RelWithDebInfo;Release;")
|
||||
SET(CMAKE_MAP_IMPORTED_CONFIG_MINSIZEREL "MinSizeRel;Release;")
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
|
||||
else()
|
||||
add_compile_options("-Wall;-Werror;-Wextra;-Wpedantic;-Wno-missing-field-initializers")
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13)
|
||||
add_compile_options("-Wno-restrict")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(LINUX)
|
||||
function(copy_and_add_rpath_library LIBNAME)
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_CXX_COMPILER} -print-file-name=${LIBNAME}.so.1 -target ${CMAKE_CXX_COMPILER_TARGET} --sysroot=${CMAKE_SYSROOT}
|
||||
OUTPUT_VARIABLE LIB_PATH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
if("${LIB_PATH}" STREQUAL "${LIBNAME}.so.1")
|
||||
message(FATAL_ERROR "Could not locate ${LIBNAME}.so.1 using compiler")
|
||||
endif()
|
||||
|
||||
file(READ_SYMLINK "${LIB_PATH}" LINK_TARGET)
|
||||
if(NOT LINK_TARGET)
|
||||
set(LIB_PATH_REAL "${LIB_PATH}")
|
||||
elseif(NOT IS_ABSOLUTE "${LINK_TARGET}")
|
||||
get_filename_component(LIB_PATH_DIR "${LIB_PATH}" DIRECTORY)
|
||||
file(REAL_PATH "${LIB_PATH_DIR}/${LINK_TARGET}" LIB_PATH_REAL)
|
||||
else()
|
||||
set(LIB_PATH_REAL "${LINK_TARGET}")
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS "${LIB_PATH_REAL}")
|
||||
message(FATAL_ERROR "File not found: ${LIB_PATH_REAL}")
|
||||
endif()
|
||||
|
||||
message(STATUS "${LIBNAME}.so.1 path: ${LIB_PATH_REAL}")
|
||||
|
||||
install(FILES "${LIB_PATH_REAL}" DESTINATION . RENAME "${LIBNAME}.so.1" COMPONENT libcxx)
|
||||
|
||||
get_filename_component(LIB_PATH_DIR "${LIB_PATH_REAL}" DIRECTORY)
|
||||
list(APPEND CMAKE_BUILD_RPATH "${LIB_PATH_DIR}")
|
||||
set(CMAKE_BUILD_RPATH "${CMAKE_BUILD_RPATH}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
copy_and_add_rpath_library(libc++)
|
||||
copy_and_add_rpath_library(libc++abi)
|
||||
copy_and_add_rpath_library(libunwind)
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||
50
cmake/fastdeploy.cmake
Normal file
50
cmake/fastdeploy.cmake
Normal file
@@ -0,0 +1,50 @@
|
||||
|
||||
|
||||
set(FASTDEPLOY_URL_PREFIX "https://github.com/MaaAssistantArknights/build-fastdeploy/releases/download")
|
||||
|
||||
set(FASTDEPLOY_TAG "gac255b8a")
|
||||
|
||||
set(COMPRESSED_SUFFIX ".tar.gz")
|
||||
|
||||
if(WIN32)
|
||||
set(FASTDEPLOY_FILENAME "FastDeploy-Windows")
|
||||
set(FASTDEPLOY_CHECKSUM "0a0700d4e8923bcd4c387a658e5e9a689ed9e0d114c260b11d082a2176c233d4")
|
||||
elseif(APPLE)
|
||||
if (CURRENT_OSX_ARCH STREQUAL "arm64")
|
||||
set(FASTDEPLOY_FILENAME "FastDeploy-macOS-arm64")
|
||||
set(FASTDEPLOY_CHECKSUM "28a771814d197ba8056f1fcb7cc0671facec90a8733a0dac2cf0b68a8cc36d24")
|
||||
else()
|
||||
set(FASTDEPLOY_FILENAME "FastDeploy-macOS-x86_64")
|
||||
set(FASTDEPLOY_CHECKSUM "76e97c7e944a18eb160646fa32ac0a7e24c87751b2b127dc33454f993f6d4b97")
|
||||
endif()
|
||||
else()
|
||||
set(FASTDEPLOY_FILENAME "FastDeploy-Linux")
|
||||
set(FASTDEPLOY_CHECKSUM "4d106e5499e9b5b29426667617215ac7e4e70d2353af10caccdfdf6c1f1534a7")
|
||||
endif(WIN32)
|
||||
|
||||
set(FASTDEPLOY_URL ${FASTDEPLOY_URL_PREFIX}/${FASTDEPLOY_TAG}/${FASTDEPLOY_FILENAME}${COMPRESSED_SUFFIX})
|
||||
|
||||
if (FASTDEPLOY_DIRECTORY)
|
||||
set(FastDeploy_DIR ${FASTDEPLOY_DIRECTORY})
|
||||
find_package(FastDeploy REQUIRED PATHS ${FastDeploy_DIR})
|
||||
include_directories(${FastDeploy_INCLUDE_DIRS})
|
||||
list(APPEND DEPEND_LIBS ${FastDeploy_LIBS})
|
||||
else ()
|
||||
download_and_decompress(${FASTDEPLOY_URL}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${FASTDEPLOY_FILENAME}${COMPRESSED_SUFFIX}
|
||||
${FASTDEPLOY_CHECKSUM}
|
||||
${THIRD_PARTY_PATH}/install/)
|
||||
set(FASTDEPLOY_FILENAME fastdeploy)
|
||||
set(FastDeploy_DIR ${THIRD_PARTY_PATH}/install/${FASTDEPLOY_FILENAME})
|
||||
|
||||
find_package(FastDeploy REQUIRED PATHS ${FastDeploy_DIR} NO_DEFAULT_PATH)
|
||||
include_directories(${FastDeploy_INCLUDE_DIRS})
|
||||
list(APPEND DEPEND_LIBS ${FastDeploy_LIBS})
|
||||
endif (FASTDEPLOY_DIRECTORY)
|
||||
|
||||
if (INSTALL_THIRD_LIBS)
|
||||
install(DIRECTORY ${FastDeploy_DIR}/lib/ DESTINATION . USE_SOURCE_PERMISSIONS)
|
||||
install(DIRECTORY ${ORT_LIB_PATH}/ DESTINATION . USE_SOURCE_PERMISSIONS)
|
||||
install(DIRECTORY ${FastDeploy_DIR}/third_libs/install/paddle2onnx/lib/
|
||||
DESTINATION . USE_SOURCE_PERMISSIONS)
|
||||
endif (INSTALL_THIRD_LIBS)
|
||||
@@ -7,21 +7,24 @@ if (BUILD_XCFRAMEWORK)
|
||||
|
||||
add_custom_command(OUTPUT OpenCV.xcframework
|
||||
COMMAND rm -rf OpenCV.xcframework
|
||||
COMMAND xcodebuild -create-xcframework -library "${PROJECT_SOURCE_DIR}/MaaDeps/runtime/${MAADEPS_TRIPLET}/libopencv_world4.408.dylib" -output OpenCV.xcframework
|
||||
COMMAND xcodebuild -create-xcframework -library "${PROJECT_SOURCE_DIR}/MaaDeps/runtime/${MAADEPS_TRIPLET}/libopencv_world4.407.dylib" -output OpenCV.xcframework
|
||||
)
|
||||
|
||||
add_custom_command(OUTPUT ONNXRuntime.xcframework
|
||||
COMMAND rm -rf ONNXRuntime.xcframework
|
||||
COMMAND xcodebuild -create-xcframework -library "${PROJECT_SOURCE_DIR}/MaaDeps/runtime/${MAADEPS_TRIPLET}/libonnxruntime.1.18.0.dylib" -output ONNXRuntime.xcframework
|
||||
COMMAND xcodebuild -create-xcframework -library "${PROJECT_SOURCE_DIR}/MaaDeps/runtime/${MAADEPS_TRIPLET}/libonnxruntime.1.14.1.dylib" -output ONNXRuntime.xcframework
|
||||
)
|
||||
|
||||
add_custom_command(OUTPUT fastdeploy_ppocr.xcframework
|
||||
COMMAND rm -rf fastdeploy_ppocr.xcframework
|
||||
COMMAND xcodebuild -create-xcframework -library "${PROJECT_SOURCE_DIR}/MaaDeps/runtime/${MAADEPS_TRIPLET}/libfastdeploy_ppocr.dylib" -output fastdeploy_ppocr.xcframework
|
||||
add_custom_command(OUTPUT MaaDerpLearning.xcframework
|
||||
COMMAND rm -rf MaaDerpLearning.xcframework
|
||||
COMMAND xcodebuild -create-xcframework -library "${PROJECT_SOURCE_DIR}/MaaDeps/runtime/${MAADEPS_TRIPLET}/libMaaDerpLearning.dylib" -output MaaDerpLearning.xcframework
|
||||
)
|
||||
|
||||
add_custom_target(MaaXCFramework ALL
|
||||
DEPENDS MaaCore MaaCore.xcframework OpenCV.xcframework ONNXRuntime.xcframework fastdeploy_ppocr.xcframework
|
||||
DEPENDS MaaCore MaaCore.xcframework OpenCV.xcframework ONNXRuntime.xcframework MaaDerpLearning.xcframework
|
||||
)
|
||||
endif (BUILD_XCFRAMEWORK)
|
||||
|
||||
target_compile_options(MaaCore PRIVATE
|
||||
-Wno-deprecated-declarations
|
||||
-Wno-gnu-zero-variadic-macro-arguments)
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
find_path(ONNXRuntime_INCLUDE_DIR NAMES onnxruntime/onnxruntime_c_api.h)
|
||||
|
||||
find_library(ONNXRuntime_LIBRARY_IMP NAMES onnxruntime)
|
||||
|
||||
if (WIN32)
|
||||
get_filename_component(ONNXRuntime_PATH_LIB ${ONNXRuntime_LIBRARY_IMP} DIRECTORY)
|
||||
find_file(ONNXRuntime_LIBRARY NAMES onnxruntime_maa.dll PATHS "${ONNXRuntime_PATH_LIB}/../bin")
|
||||
|
||||
find_file(ONNXRuntime_LIBRARY_IMP_DEBUG NAMES onnxruntime.lib PATHS "${ONNXRuntime_PATH_LIB}/../debug/lib")
|
||||
find_file(ONNXRuntime_LIBRARY_DEBUG NAMES onnxruntime_maa.dll PATHS "${ONNXRuntime_PATH_LIB}/../debug/bin")
|
||||
else ()
|
||||
set(ONNXRuntime_LIBRARY ${ONNXRuntime_LIBRARY_IMP})
|
||||
endif (WIN32)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(
|
||||
ONNXRuntime
|
||||
REQUIRED_VARS ONNXRuntime_LIBRARY_IMP ONNXRuntime_INCLUDE_DIR
|
||||
)
|
||||
|
||||
if(ONNXRuntime_FOUND)
|
||||
set(ONNXRuntime_INCLUDE_DIRS ${ONNXRuntime_INCLUDE_DIR})
|
||||
if(NOT TARGET ONNXRuntime::ONNXRuntime)
|
||||
add_library(ONNXRuntime::ONNXRuntime SHARED IMPORTED)
|
||||
set_property(TARGET ONNXRuntime::ONNXRuntime APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
|
||||
if (WIN32)
|
||||
set_property(TARGET ONNXRuntime::ONNXRuntime APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
|
||||
set_target_properties(ONNXRuntime::ONNXRuntime PROPERTIES
|
||||
IMPORTED_IMPLIB_RELEASE "${ONNXRuntime_LIBRARY_IMP}"
|
||||
)
|
||||
set_target_properties(ONNXRuntime::ONNXRuntime PROPERTIES
|
||||
IMPORTED_IMPLIB_DEBUG "${ONNXRuntime_LIBRARY_IMP_DEBUG}"
|
||||
IMPORTED_LOCATION_DEBUG "${ONNXRuntime_LIBRARY_DEBUG}"
|
||||
)
|
||||
endif (WIN32)
|
||||
set_target_properties(ONNXRuntime::ONNXRuntime PROPERTIES
|
||||
IMPORTED_LOCATION_RELEASE "${ONNXRuntime_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${ONNXRuntime_INCLUDE_DIR}"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
54
cmake/opencv.cmake
Normal file
54
cmake/opencv.cmake
Normal file
@@ -0,0 +1,54 @@
|
||||
|
||||
|
||||
set(OPENCV_URL_PREFIX "https://github.com/MaaAssistantArknights/build-opencv/releases/download")
|
||||
|
||||
set(OPENCV_TAG "4.5.3")
|
||||
|
||||
set(COMPRESSED_SUFFIX ".tar.gz")
|
||||
|
||||
if(WIN32)
|
||||
set(OPENCV_FILENAME "OpenCV-Windows")
|
||||
set(OPENCV_CHECKSUM "bf736b243bbdaa020f139e4dfa1e4f15633f4ce7a8ad885524645e660de47a8b")
|
||||
elseif(APPLE)
|
||||
if (CURRENT_OSX_ARCH STREQUAL "arm64")
|
||||
set(OPENCV_FILENAME "OpenCV-macOS-arm64")
|
||||
set(OPENCV_CHECKSUM "31beb633c033dd4ee789ffa50911c29c9580860f9a91f334f03d8aa9c85e9700")
|
||||
else()
|
||||
set(OPENCV_FILENAME "OpenCV-macOS-x86_64")
|
||||
set(OPENCV_CHECKSUM "249c5c97cc52257b68d35acf499b1cf1037f5e6f3b40752f82ad5abe7884bea9")
|
||||
endif()
|
||||
else(UNIX)
|
||||
set(OPENCV_FILENAME "OpenCV-Linux")
|
||||
set(OPENCV_CHECKSUM "edc4138456189c9e8bdf29114ad2be8ec152e8e31087d98e633f6cda59b141ea")
|
||||
endif(WIN32)
|
||||
|
||||
set(OPENCV_URL ${OPENCV_URL_PREFIX}/${OPENCV_TAG}/${OPENCV_FILENAME}${COMPRESSED_SUFFIX})
|
||||
|
||||
if(OPENCV_DIRECTORY)
|
||||
set(OpenCV_DIR ${OPENCV_DIRECTORY})
|
||||
find_package(OpenCV REQUIRED PATHS ${OpenCV_DIR})
|
||||
include_directories(${OpenCV_INCLUDE_DIRS})
|
||||
list(APPEND DEPEND_LIBS ${OpenCV_LIBS})
|
||||
else()
|
||||
download_and_decompress(${OPENCV_URL}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${OPENCV_FILENAME}${COMPRESSED_SUFFIX}
|
||||
${OPENCV_CHECKSUM}
|
||||
${THIRD_PARTY_PATH}/install/)
|
||||
set(OPENCV_FILENAME opencv)
|
||||
set(OpenCV_DIR ${THIRD_PARTY_PATH}/install/${OPENCV_FILENAME})
|
||||
set(OPENCV_DIRECTORY ${OpenCV_DIR})
|
||||
if (WIN32)
|
||||
set(OpenCV_DIR ${OpenCV_DIR}/lib)
|
||||
endif()
|
||||
find_package(OpenCV REQUIRED PATHS ${OpenCV_DIR} NO_DEFAULT_PATH)
|
||||
include_directories(${OpenCV_INCLUDE_DIRS})
|
||||
list(APPEND DEPEND_LIBS ${OpenCV_LIBS})
|
||||
endif(OPENCV_DIRECTORY)
|
||||
|
||||
if (INSTALL_THIRD_LIBS)
|
||||
if (OpenCV_SHARED)
|
||||
install(DIRECTORY ${OpenCV_INSTALL_PATH}/lib/
|
||||
DESTINATION .
|
||||
USE_SOURCE_PERMISSIONS PATTERN "cmake" EXCLUDE)
|
||||
endif (OpenCV_SHARED)
|
||||
endif (INSTALL_THIRD_LIBS)
|
||||
44
cmake/thrift-gen.cmake
Normal file
44
cmake/thrift-gen.cmake
Normal file
@@ -0,0 +1,44 @@
|
||||
macro(GENERATE_THRIFT_LIB LIB_NAME FILENAME OUTPUTDIR SOURCES)
|
||||
file(MAKE_DIRECTORY ${OUTPUTDIR})
|
||||
detect_host_triplet(HOST_TRIPLET)
|
||||
if (CMAKE_CROSSCOMPILING)
|
||||
if (CMAKE_HOST_WIN32)
|
||||
set(_host_executable_suffix ".exe")
|
||||
else()
|
||||
set(_host_executable_suffix "")
|
||||
endif()
|
||||
else()
|
||||
set(_host_executable_suffix ${CMAKE_EXECUTABLE_SUFFIX})
|
||||
endif()
|
||||
if(EXISTS ${PROJECT_SOURCE_DIR}/MaaDeps/vcpkg/installed/maa-${HOST_TRIPLET}/tools/thrift/thrift${_host_executable_suffix})
|
||||
set(THRIFT_COMPILER ${PROJECT_SOURCE_DIR}/MaaDeps/vcpkg/installed/maa-${HOST_TRIPLET}/tools/thrift/thrift${_host_executable_suffix})
|
||||
else()
|
||||
find_program(THRIFT_COMPILER thrift)
|
||||
endif()
|
||||
if(NOT THRIFT_COMPILER)
|
||||
message(FATAL_ERROR "Thrift compiler not found")
|
||||
endif()
|
||||
get_filename_component(THRIFT_IDL_NAME ${FILENAME} NAME_WE)
|
||||
set(THRIFT_IDL_TARGET "${LIB_NAME}_${THRIFT_IDL_NAME}_idl")
|
||||
set("${THRIFT_IDL_NAME}-gen-cpp"
|
||||
${OUTPUTDIR}/${THRIFT_IDL_NAME}.cpp
|
||||
${OUTPUTDIR}/${THRIFT_IDL_NAME}.h
|
||||
${OUTPUTDIR}/${THRIFT_IDL_NAME}_types.cpp
|
||||
${OUTPUTDIR}/${THRIFT_IDL_NAME}_types.h)
|
||||
|
||||
add_custom_command(OUTPUT ${${THRIFT_IDL_NAME}-gen-cpp}
|
||||
DEPENDS ${FILENAME}
|
||||
COMMAND ${THRIFT_COMPILER} --gen cpp:no_skeleton -out ${OUTPUTDIR} ${FILENAME}
|
||||
VERBATIM)
|
||||
add_custom_target(${THRIFT_IDL_TARGET} DEPENDS ${${THRIFT_IDL_NAME}-gen-cpp})
|
||||
add_library(${LIB_NAME} STATIC ${${THRIFT_IDL_NAME}-gen-cpp})
|
||||
add_dependencies(${LIB_NAME} ${THRIFT_IDL_TARGET})
|
||||
set_target_properties(${LIB_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
target_link_libraries(${LIB_NAME} PUBLIC thrift::thrift)
|
||||
target_include_directories(${LIB_NAME} PUBLIC ${OUTPUTDIR})
|
||||
set(${SOURCES} ${${SOURCES}} ${GENERATED_SOURCES} PARENT_SCOPE)
|
||||
endmacro(GENERATE_THRIFT_LIB)
|
||||
|
||||
if (WITH_THRIFT)
|
||||
add_compile_definitions(WITH_THRIFT)
|
||||
endif (WITH_THRIFT)
|
||||
@@ -1,73 +1,50 @@
|
||||
function(download_and_decompress url filename sha256_checksum decompress_dir)
|
||||
if(EXISTS ${filename})
|
||||
file(SHA256 ${filename} CHECKSUM_VARIABLE)
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS ${filename} OR NOT CHECKSUM_VARIABLE STREQUAL sha256_checksum)
|
||||
message("Downloading file from ${url} to ${filename} ...")
|
||||
file(
|
||||
DOWNLOAD ${url} "${filename}.tmp"
|
||||
SHOW_PROGRESS
|
||||
EXPECTED_HASH SHA256=${sha256_checksum})
|
||||
file(RENAME "${filename}.tmp" ${filename})
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS ${decompress_dir})
|
||||
file(MAKE_DIRECTORY ${decompress_dir})
|
||||
endif()
|
||||
|
||||
message("Decompress file ${filename} ...")
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E tar -xf ${filename} WORKING_DIRECTORY ${decompress_dir})
|
||||
if(EXISTS ${filename})
|
||||
file(SHA256 ${filename} CHECKSUM_VARIABLE)
|
||||
endif()
|
||||
if(NOT EXISTS ${filename} OR NOT CHECKSUM_VARIABLE STREQUAL sha256_checksum)
|
||||
message("Downloading file from ${url} to ${filename} ...")
|
||||
file(DOWNLOAD ${url} "${filename}.tmp" SHOW_PROGRESS EXPECTED_HASH SHA256=${sha256_checksum})
|
||||
file(RENAME "${filename}.tmp" ${filename})
|
||||
endif()
|
||||
if(NOT EXISTS ${decompress_dir})
|
||||
file(MAKE_DIRECTORY ${decompress_dir})
|
||||
endif()
|
||||
message("Decompress file ${filename} ...")
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E tar -xf ${filename} WORKING_DIRECTORY ${decompress_dir})
|
||||
endfunction()
|
||||
|
||||
function(get_osx_architecture)
|
||||
if(CMAKE_OSX_ARCHITECTURES STREQUAL "arm64")
|
||||
set(CURRENT_OSX_ARCH
|
||||
"arm64"
|
||||
PARENT_SCOPE)
|
||||
elseif(CMAKE_OSX_ARCHITECTURES STREQUAL "x86_64")
|
||||
set(CURRENT_OSX_ARCH
|
||||
"x86_64"
|
||||
PARENT_SCOPE)
|
||||
else()
|
||||
set(CURRENT_OSX_ARCH
|
||||
${CMAKE_HOST_SYSTEM_PROCESSOR}
|
||||
PARENT_SCOPE)
|
||||
endif()
|
||||
if (CMAKE_OSX_ARCHITECTURES STREQUAL "arm64")
|
||||
set(CURRENT_OSX_ARCH "arm64" PARENT_SCOPE)
|
||||
elseif(CMAKE_OSX_ARCHITECTURES STREQUAL "x86_64")
|
||||
set(CURRENT_OSX_ARCH "x86_64" PARENT_SCOPE)
|
||||
else()
|
||||
set(CURRENT_OSX_ARCH ${CMAKE_HOST_SYSTEM_PROCESSOR} PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
if(APPLE)
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET 13.3) # for to_chars
|
||||
get_osx_architecture()
|
||||
endif(APPLE)
|
||||
function(detect_host_triplet outvar)
|
||||
string(TOLOWER "${CMAKE_HOST_SYSTEM_NAME}" host_triplet_system)
|
||||
string(TOLOWER "${CMAKE_HOST_SYSTEM_PROCESSOR}" host_triplet_arch)
|
||||
if(host_triplet_system STREQUAL "darwin")
|
||||
set(host_triplet_system "osx")
|
||||
endif()
|
||||
message("host_triplet_system: ${host_triplet_system}")
|
||||
message("host_triplet_arch: ${host_triplet_arch}")
|
||||
if(host_triplet_arch MATCHES "(amd64|x86_64)")
|
||||
set(host_triplet_arch "x64")
|
||||
elseif(host_triplet_arch MATCHES "i[3456]86")
|
||||
set(host_triplet_arch "x86")
|
||||
elseif(host_triplet_arch MATCHES "(aarch64|armv8l|arm64)")
|
||||
set(host_triplet_arch "arm64")
|
||||
else()
|
||||
message(FATAL_ERROR "Unrecognized CMAKE_HOST_SYSTEM_PROCESSOR: ${CMAKE_HOST_SYSTEM_PROCESSOR}")
|
||||
endif()
|
||||
set(${outvar} "${host_triplet_arch}-${host_triplet_system}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
if(NOT DEFINED MAADEPS_TRIPLET)
|
||||
detect_maadeps_triplet(MAADEPS_TRIPLET)
|
||||
endif()
|
||||
|
||||
# 创建资源目录链接的函数
|
||||
function(create_resource_link TARGET_NAME OUTPUT_DIR)
|
||||
if(WIN32)
|
||||
# Windows 使用 mklink /J 创建目录链接(不需要管理员权限)
|
||||
add_custom_command(
|
||||
TARGET ${TARGET_NAME}
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "Creating resource directory link for ${TARGET_NAME}..."
|
||||
COMMAND ${CMAKE_COMMAND} -E remove_directory "${OUTPUT_DIR}/resource"
|
||||
COMMAND cmd /c "mklink /J \"${OUTPUT_DIR}/resource\" \"${PROJECT_SOURCE_DIR}/resource\""
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "Resource directory link created successfully"
|
||||
COMMENT "Creating junction for resource directory for ${TARGET_NAME}"
|
||||
)
|
||||
else()
|
||||
# Unix/Linux/macOS 使用符号链接
|
||||
add_custom_command(
|
||||
TARGET ${TARGET_NAME}
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "Creating resource directory link for ${TARGET_NAME}..."
|
||||
COMMAND ${CMAKE_COMMAND} -E remove "${OUTPUT_DIR}/resource"
|
||||
COMMAND ${CMAKE_COMMAND} -E create_symlink "${PROJECT_SOURCE_DIR}/resource" "${OUTPUT_DIR}/resource"
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "Resource directory link created successfully"
|
||||
COMMENT "Creating symlink for resource directory for ${TARGET_NAME}"
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
||||
if (APPLE)
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET 12.0)
|
||||
get_osx_architecture()
|
||||
endif (APPLE)
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
# define MAA_HASH_VERSION from git
|
||||
set(MAA_HASH_VERSION
|
||||
"DEBUG_VERSION"
|
||||
CACHE STRING "maa version")
|
||||
|
||||
if(WITH_HASH_VERSION AND MAA_HASH_VERSION STREQUAL "DEBUG_VERSION")
|
||||
find_package(Git)
|
||||
|
||||
if(GIT_FOUND)
|
||||
execute_process(
|
||||
COMMAND "${GIT_EXECUTABLE}" rev-parse HEAD
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
RESULT_VARIABLE result
|
||||
OUTPUT_VARIABLE output
|
||||
ERROR_VARIABLE err
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
if(result EQUAL 0)
|
||||
set(MAA_HASH_VERSION "${output}")
|
||||
else()
|
||||
message(WARNING "git rev-parse returning ${result}, output:\n${err}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
message(STATUS "MAA_HASH_VERSION=${MAA_HASH_VERSION}")
|
||||
add_compile_definitions(MAA_VERSION="${MAA_HASH_VERSION}")
|
||||
@@ -223,39 +223,6 @@ MD052: true
|
||||
# MD053/link-image-reference-definitions - Link and image reference definitions should be needed
|
||||
MD053:
|
||||
# Ignored definitions
|
||||
ignored_definitions: ["//"]
|
||||
|
||||
# MD054/link-image-style - Link and image style
|
||||
MD054:
|
||||
# Allow autolinks
|
||||
autolink: true
|
||||
# Allow collapsed reference links and images
|
||||
collapsed: true
|
||||
# Allow full reference links and images
|
||||
full: true
|
||||
# Allow inline links and images
|
||||
inline: true
|
||||
# Allow shortcut reference links and images
|
||||
shortcut: true
|
||||
# Allow URLs as inline links
|
||||
url_inline: true
|
||||
|
||||
# MD055/table-pipe-style - Table pipe style
|
||||
MD055:
|
||||
# Table pipe style
|
||||
style: "consistent"
|
||||
|
||||
# MD056/table-column-count - Table column count
|
||||
MD056: true
|
||||
|
||||
# MD057 - Table column count inconsistencies with table header column count
|
||||
# (Not documented in official rules list - MD057 appears to be missing or deprecated)
|
||||
|
||||
# MD058/blanks-around-tables - Tables should be surrounded by blank lines
|
||||
MD058: true
|
||||
|
||||
# MD059/descriptive-link-text - Link text should be descriptive
|
||||
MD059:
|
||||
false
|
||||
# Prohibited link texts
|
||||
#prohibited_texts: ["click here", "here", "link", "more"]
|
||||
ignored_definitions: [
|
||||
"//"
|
||||
]
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
**/pnpm-lock.yaml
|
||||
**/*.md
|
||||
@@ -1,40 +0,0 @@
|
||||
module.exports = {
|
||||
printWidth: 120,
|
||||
tabWidth: 2,
|
||||
useTabs: false,
|
||||
bracketSpacing: true,
|
||||
bracketSameLine: false,
|
||||
endOfLine: 'auto',
|
||||
semi: false,
|
||||
singleQuote: true,
|
||||
trailingComma: 'all',
|
||||
arrowParens: 'always',
|
||||
|
||||
overrides: [
|
||||
{
|
||||
files: ['**/*.ts'],
|
||||
options: {
|
||||
semi: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['**/*.*css'],
|
||||
options: {
|
||||
singleQuote: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['**/*.yml', '**/*.yaml'],
|
||||
options: {
|
||||
parser: 'yaml',
|
||||
singleQuote: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['**/*.json'],
|
||||
options: {
|
||||
tabWidth: 4,
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user