Compare commits

4 Commits
16 changed files with 1333 additions and 23515 deletions

No files matched your search

+674
View File
@@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
{one line to give the program's name and a brief idea of what it does.}
Copyright (C) {year} {name of author}
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
{project} Copyright (C) {year} {fullname}
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
+125
View File
@@ -0,0 +1,125 @@
# GcTools 手机版 · 重构版 0.3.0
> 基于 [jie65535/GrasscutterCommandGenerator](https://github.com/jie65535/GrasscutterCommandGenerator)(下称「上游」,Windows 桌面版,C# WinForms)重新实现的 Android 客户端:同一套数据、同一套命令规则,但界面按手机重做,纯 Kotlin + 系统控件,不带 .NET 运行时。
- 安装包:见 [Releases](http://110.42.217.133:3000/gitea/gctools/releases),文件名 `GcTools-0.3.0-refactor.apk`(sha256 `d3fc9cb23dcf1f6a540c26fc26f5d986f2e831f79a433ed069827ec5a1b3faf0`)
- 包名 `com.gctool.mobile`,versionCode 4,minSdk 24(Android 7.0)/ targetSdk 35
- 体积 1.9 MB,离线可用;装了 OpenCommand 插件的服务端可以直接把命令点过去
## 一、为什么要做手机版
上游是 WinForms 桌面程序:主界面 `FormMain` + 十几个 `Page*`,依赖 .NET 10 与 Windows 桌面控件,手机上跑不了。把界面搬到手机不是「窗口缩小」,而是把「一个页面塞满参数」改成「一屏一件事」:
| 上游(桌面) | 手机版(本应用) | 改动点 |
| --- | --- | --- |
| 左侧导航 + 单页多列参数 | 顶部横向标签 + 单列参数 | 手指点按、参数横排两三个输入框 |
| 列表用 ListBox 全量展示 | 搜索框 + 分类 chips + 200 条上限 | 1.3 万条物品靠「搜 id / 名字」+ 分类 |
| 生成命令显示在底部文本框 | 底部固定「当前命令」条 + 复制/发送 | 随时可复制、可直发 |
| 命令历史写 AppData | 命令页文本框(`SharedPreferences` 记住最后一段) | 手机上没有多窗口,保留一份就够 |
## 二、页面与上游对照
手机版共 10 个标签页,对应上游的 `Source/GrasscutterTools/Pages/*.cs`:
| 手机版 | 上游页面 | 生成命令 |
| --- | --- | --- |
| 物品 | `PageGiveItem` | `/give <id> x<数量> lv<等级>`、`/spawn …`、`/drop <id> <数量>` |
| 角色 | `PageAvatar` | `/give <id> lv<等级> c<命座> sl<天赋>`、`/givechar <id> <等级>`、`/give avatars …` |
| 武器 | `PageGiveWeapon` | `/give <id> x<数量> lv<等级> r<精炼>`、`/give weapons …` |
| 圣遗物 | `PageGiveArtifact` | `/give <id> lv<等级> [主词条 id]` |
| 怪物 | `PageGiveMonster` | `/spawn <id> <数量> <等级>`(上游这一页的命令不带 `lv` 前缀,照搬) |
| 成就 | `PageAchievement` | `/achievement grant <id>`、`revoke`、`grantall`、`revokeall` |
| 场景 | `PageScene` | `/tp 0 400 0 <场景 id>`、`/scene <id>`、`/dungeon <id>`、`/cutscene <id>` |
| 命令 | `PageCustomCommands` + 底部命令框 | 41 条上游预设一键填入、手输任意命令、直接发送、保留执行记录 |
| 远程 | 上游的 OpenCommand 设置 | 填地址/令牌、测试连接,协议见下 |
| 设置 | `PageSetProp` 的一部分 | 世界等级 / BP 等级 / 解锁场景标记 |
上游还有一批「编辑器」页面(`FormShopEditor`、`FormGachaBannerEditor`、`FormMailEditor`、`FormActivityEditor`、`FormDropEditor` 等),它们是在**本地编辑 JSON 文件**再导入服务端的重型工具,手机上价值不高,暂时不做;需要的话建议在电脑上编辑后丢给服务端。
## 三、数据从哪来
全部来自上游的 `Source/GrasscutterTools/Resources/zh-cn/`,用 `tools/convert.mjs` 转成两个 JSON:
```
Source/GrasscutterTools/Resources/zh-cn/Item.txt → assets/gamedata.json items
Monsters.txt monsters
Avatar.txt avatars
Weapon.txt weapons
Artifact.txt artifacts
ArtifactMainAttribution.txt artifactMain
Achievement.txt achievements
Scene.txt scenes
Dungeon.txt dungeons
Cutscene.txt cutscenes
CustomCommands.txt assets/custom.json
```
转换规则:`id:名字` 一行一条,`// 分类` 是分段标题(物品/怪物的分类筛选就来自这里),带 BOM 自动去掉,非法行跳过。
重新生成(在仓库根目录):
```bash
git clone --depth=1 https://github.com/jie65535/GrasscutterCommandGenerator.git
node tools/convert.mjs GrasscutterCommandGenerator/Source/GrasscutterTools/Resources/zh-cn
```
内置数据量:物品 13210、怪物 3518、圣遗物 3550、场景 2430、副本 2426、成就 1910、过场 478、武器 265、角色 124,`gamedata.json` 约 1.4 MB;另有 41 条预设命令(`assets/custom.json`,来自上游 `CustomCommands.txt` 的「标签 + 命令」对)。
## 四、OpenCommand 协议
和上游桌面版一致,用同一个 OpenCommand 插件:
```
POST {地址}/opencommand/api
Content-Type: application/json; charset=utf-8
{"token":"<控制台令牌>","action":"command","data":{"command":"/give 1001 x1 lv1"}}
```
- `action=ping` + `data=null` 用来测试连接
- 返回 `{retcode, message, data}`,`retcode == 200` 表示成功
- 超时:连接 8 秒、读取 10 秒
## 五、自己编译
需要 JDK 17、Android SDK(platform 35 + build-tools 35.0.0)、Gradle 8.10.2(AGP 8.7.3 要求 ≥ 8.9):
```bash
cd android
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk # 服务器上是 TencentKonaJDK 17
export ANDROID_HOME=/opt/android-sdk ANDROID_SDK_ROOT=/opt/android-sdk
$GRADLE_HOME/bin/gradle assembleDebug # 调试包
$GRADLE_HOME/bin/gradle assembleRelease # 正式包(需要签名环境变量)
```
签名用环境变量,不写进仓库:
```bash
export GC_KEYSTORE=/opt/build/gctools.keystore
export GC_KEYSTORE_PASS=***
export GC_KEY_ALIAS=gctools GC_KEY_PASS=***
```
构建耗时实测:首次 1 分 45 秒、增量 15 秒左右(服务器 4 核)。
## 六、与「复刻版 1.21.0-remake」的关系
仓库里现在有两个版本,别装混:
| 版本 | 来源 | 特点 |
| --- | --- | --- |
| `1.21.0-remake` | 逆向 GcTools-mobile.apk | 界面与数据与原 APK 一致,页数少(物品/角色/武器/圣遗物/怪物) |
| `0.3.0-refactor`(本文件) | 基于上游桌面版重构 | 数据全(多了成就/场景/副本/过场/分类筛选/属性快捷),界面按手机重排 |
两个版本包名相同,**不能同时安装**,装新的会覆盖旧的(数据表是内置的,不存在迁移问题)。
## 七、已知边界
- 只带简体中文数据(上游另有 en-US / ru-RU / zh-TW,需要的话改 `tools/convert.mjs` 的目录再跑一次)
- 列表最多显示 200 条,超过请用搜索/分类缩小范围(数据本身是全的)
- 圣遗物的副词条编辑没做(上游支持主词条 + 多条副词条),需要副词条时用「命令」页手写
- 邮件 / 商店 / 抽卡 / 活动编辑器不在手机版范围(见第二节说明)
- 应用不联网也能生成命令,只有「发送到服务器」需要 OpenCommand
## 八、版权
数据和命令规则来自 [jie65535/GrasscutterCommandGenerator](https://github.com/jie65535/GrasscutterCommandGenerator)(AGPL-3.0),本仓库的界面与 Kotlin 代码按其许可证一并以 **GPL-3.0** 发布,详见 [LICENSE](LICENSE)。
+41 -14
View File
@@ -1,14 +1,25 @@
# GcTools 复刻版
# GcTools 手机版
把 `GcTools-mobile.apk`(Grasscutter 命令生成器,1.21.0)逆向之后完整重写:**同一套数据表、同一套命令语法、同一个 OpenCommand 协议**。
一个 Grasscutter 命令生成器,两个版本都在这个仓库里:
**成品 APK**:[Releases](https://110.42.217.133:3000/gitea/gctools/releases) —— `GcTools-1.21.0-remake-release.apk`(1.83 MB,已签名,Android 7.0+)
| 版本 | 来源 | 说明 |
| --- | --- | --- |
| **0.3.0-refactor**(推荐) | 基于 [jie65535/GrasscutterCommandGenerator](https://github.com/jie65535/GrasscutterCommandGenerator) 重构 | 10 个页面、数据更全(多了成就/场景/副本/过场/分类筛选),详见 [MOBILE.md](MOBILE.md) |
| 1.21.0-remake | 逆向 `GcTools-mobile.apk`(1.21.0) | 与原 APK 一致,5 个页面,同一套数据与协议 |
**成品 APK**:[Releases](https://110.42.217.133:3000/gitea/gctools/releases)
- `GcTools-0.3.0-refactor.apk`(1.9 MB,已签名,Android 7.0+)
- `GcTools-1.21.0-remake-release.apk`(1.83 MB,上一版)
两个版本包名相同,不能同时安装。
包含两份实现,互相对照:
| 目录 | 是什么 | 怎么用 |
| --- | --- | --- |
| [`android/`](android) | Kotlin + Gradle 的 Android 工程(复刻原 App) | `cd android && gradle assembleDebug`(或用 Android Studio 打开) |
| [`android/`](android) | Kotlin + Gradle 的 Android 工程(当前是 0.3.0 重构版) | `cd android && gradle assembleDebug`(或用 Android Studio 打开) |
| [`tools/convert.mjs`](tools/convert.mjs) | 把上游 Resources 的 txt 转成 App 内置 JSON | `node tools/convert.mjs <上游 Resources/zh-cn>` |
| [`web/`](web) | 网页版,单页静态、零依赖、可离线 | `cd web && python3 -m http.server 8080` |
| [`reverse/`](reverse) | androguard 全量反汇编(分析依据) | 只读 |
| [`BUILD.md`](BUILD.md) | 从零编译 APK 的完整步骤(JDK 17 + SDK 35 + Gradle 8.10.2) | 照着敲 |
@@ -17,22 +28,24 @@
![网页版](web/preview-mobile.png)
## 功能
## 功能(0.3.0 重构版)
- **物品**:给予 / 生成 / 掉落(`/give`、`/spawn`、`/drop`)
- **角色**:给予角色(等级/命座/天赋)、直接生成(`/givechar`)
- **武器**:给予(数量/等级/精炼)
- **圣遗物**:给予(等级)
- **怪物**:生成(数量/等级)
- **命令**:手写一条命令,复制或直接发
- **物品**:按分类筛选 + 搜索,给予 / 生成 / 掉落(`/give`、`/spawn`、`/drop`)
- **角色**:给予(等级/命座/天赋)、直接生成、给所有角色(`/givechar`、`/give avatars`)
- **武器**:给予(数量/等级/精炼)、全部武器
- **圣遗物**:给予(等级 + 主词条)
- **怪物**:按分类筛选 + 搜索,生成
- **成就**:给予 / 撤销 / 全部给予 / 全部撤销
- **场景**:场景 / 副本 / 过场三类,传送或切换
- **命令**:手写命令、直接发送、执行记录
- **远程**:服务器地址 + OpenCommand 令牌,测试连接
- **设置**:生成后自动发送
- **设置**:自动发送、世界等级 / BP 等级 / 解锁场景标记
内置数据:物品 13210、角色 124、武器 265、圣遗物 3550、怪物 3518、场景 2431。
内置数据(全部来自上游 zh-cn 资源):物品 13210、怪物 3518、圣遗物 3550、场景 2430、副本 2426、成就 1910、过场 478、武器 265、角色 124。
## 安装
1. 手机上下载 `GcTools-1.21.0-remake-release.apk`
1. 手机上下载 `GcTools-0.3.0-refactor.apk`
2. 允许「安装未知来源应用」,装好后打开
3. 进「远程」填服务器地址(`http://你的IP:443`)和 OpenCommand 令牌,点「测试连接」
4. 回到任意页面选一条数据,改参数,点按钮生成命令 → 「发送到服务器」
@@ -57,3 +70,17 @@ tar -czf - -C web . | ssh root@你的服务器 "mkdir -p /opt/sites/gctools && t
## 合规
数据表与命令语法来自 GcTools / Grasscutter 生态,版权归原项目;本项目只做本地工具用途。
## 合作者
<a href="http://110.42.217.133:3000/clover"><img src="http://110.42.217.133:3000/avatars/1f792e843512244f2ec558c883531d9afd24cab0cf35e4f41635cb8805df3d88?size=40" width="24" height="24" alt="四叶草"> **四叶草** · [@clover](http://110.42.217.133:3000/clover)</a>
项目所有者:[@gitea](http://110.42.217.133:3000/gitea)。合作者拥有该仓库的管理权限(修改设置、合并 PR、管理合作者)。
## 许可证
本项目采用 **GNU General Public License v3.0** 许可,全文见 [LICENSE](LICENSE)。
Copyright (C) 2026 syc65535
你可以自由使用、修改和分发,但分发时必须以相同许可证开放源代码;本程序不提供任何担保。
+2 -2
View File
@@ -11,8 +11,8 @@ android {
applicationId = "com.gctool.mobile"
minSdk = 24
targetSdk = 35
versionCode = 3
versionName = "1.21.0-remake"
versionCode = 4
versionName = "0.3.0-refactor"
}
signingConfigs {
File diff suppressed because it is too large. Load diff
-124
View File
@@ -1,124 +0,0 @@
1002:神里绫华
1003:琴
1005:男主
1006:丽莎
1007:女主
1014:芭芭拉
1015:凯亚
1016:迪卢克
1020:雷泽
1021:安柏
1022:温迪
1023:香菱
1024:北斗
1025:行秋
1026:魈
1027:凝光
1029:可莉
1030:钟离
1031:菲谢尔
1032:班尼特
1033:达达利亚
1034:诺艾尔
1035:七七
1036:重云
1037:甘雨
1038:阿贝多
1039:迪奥娜
1041:莫娜
1042:刻晴
1043:砂糖
1044:辛焱
1045:罗莎莉亚
1046:胡桃
1047:枫原万叶
1048:烟绯
1049:宵宫
1050:托马
1051:优菈
1052:雷电将军
1053:早柚
1054:珊瑚宫心海
1055:五郎
1056:九条裟罗
1057:荒泷一斗
1058:八重神子
1059:鹿野院平藏
1060:夜兰
1062:埃洛伊
1063:申鹤
1064:云堇
1065:久岐忍
1066:神里绫人
1067:柯莱
1068:多莉
1069:提纳里
1070:妮露
1071:赛诺
1072:坎蒂丝
1073:纳西妲
1074:莱依拉
1075:流浪者
1077:瑶瑶
1078:艾尔海森
1079:迪希雅
1080:米卡
1081:卡维
1082:白术
1076:珐露珊
1061:绮良良
1083:琳妮特
1084:林尼
1085:菲米尼
1086:莱欧斯利
1087:那维莱特
1088:夏洛蒂
1089:芙宁娜
1090:夏沃蕾
1091:娜维娅
1092:嘉明
1093:闲云
1094:千织
1095:希格雯
1097:赛索斯
1096:阿蕾奇诺
1098:克洛琳德
1099:艾梅莉埃
4100:卡齐娜
4101:基尼奇
4102:玛拉妮
4103:希诺宁
4104:恰斯卡
4105:欧洛伦
4106:玛薇卡
4107:茜特菈莉
4108:蓝砚
4109:梦见月瑞希
4110:伊安珊
4111:瓦雷莎
4112:爱可菲
4113:伊法
4114:丝柯克
4115:塔利雅
4116:伊涅芙
4119:菈乌玛
4120:菲林斯
4121:爱诺
4122:奈芙尔
4123:杜林
4124:雅珂达
4125:哥伦比娅
4126:兹白
4127:叶洛亚
4128:法尔伽
4129:洛恩
4130:莉奈娅
4131:尼可
4132:布伦妮
4133:桑多涅
4136:米提亚
4137:瓦列里
4140:沃雅妮莎
4143:薇斯纳
4148:阿罗夏
4150:奥黛塔
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
-265
View File
@@ -1,265 +0,0 @@
11101:无锋剑
11201:银剑
11301:冷刃
11302:黎明神剑
11303:旅行剑
11304:暗铁剑
11305:吃虎鱼刀
11306:飞天御剑
11401:西风剑
11402:笛剑
11403:祭礼剑
11404:宗室长剑
11405:匣里龙吟
11406:试作斩岩
11407:铁蜂刺
11408:黑岩长剑
11409:黑剑
11410:暗巷闪光
11412:降临之剑
11413:腐殖之剑
11414:天目影打刀
11415:辰砂之纺锤
11416:笼钓瓶一心
11417:原木刀
11418:西福斯的月光
11419:「一心传」名刀
11420:「一心传」名刀
11421:「一心传」名刀
11422:东花坊时雨
11424:狼牙
11425:海渊终曲
11426:灰河渡手
11427:船坞长剑
11428:水仙十字之剑
11429:水仙十字之剑
11430:弥坚骨
11431:息燧之笛
11432:厄水之祸
11433:谧音吹哨
11434:织月者的曙色
11435:熔猎异端之刃
11436:引火之源
11437:新枝
11438:银釭
11501:风鹰剑
11502:天空之刃
11503:苍古自由之誓
11504:斫峰之刃
11505:磐岩结绿
11509:雾切之回光
11510:波乱月白经津
11511:圣显之钥
11512:裁叶萃光
11513:静水流涌之辉
11514:有乐御簾切
11515:赦罪
11516:岩峰巡歌
11517:苍耀
11518:黑蚀
11519:朏魄含光
11520:白湖冬羽
11521:星锋剑
11522:蝶变
12101:训练大剑
12201:佣兵重剑
12301:铁影阔剑
12302:沐浴龙血的剑
12303:白铁大剑
12304:石英大剑
12305:以理服人
12306:飞天大御剑
12401:西风大剑
12402:钟剑
12403:祭礼大剑
12404:宗室大剑
12405:雨裁
12406:试作古华
12407:白影剑
12408:黑岩斩刀
12409:螭骨剑
12410:千岩古剑
12411:雪葬的星银
12412:衔珠海皇
12414:桂木斩长正
12415:玛海菈的水色
12416:恶王丸
12417:森林王器
12418:饰铁之花
12424:聊聊棒
12425:浪影阔剑
12426:「究极霸王超级魔剑」
12427:便携动力锯
12430:硕果钩
12431:撼地者
12432:拾慧铸熔
12433:万能钥匙
12435:金律铸影
12436:救赎之斩
12501:天空之傲
12502:狼的末路
12503:松籁响起之时
12504:无工之剑
12510:赤角石溃杵
12511:苇海信标
12512:裁断
12513:山王长牙
12514:焚曜千阳
12515:狼的武功歌
12516:超越之匙
13101:新手长枪
13201:铁尖枪
13301:白缨枪
13302:钺矛
13303:黑缨枪
13304:「旗杆」
13401:匣里灭辰
13402:试作星镰
13403:流月针
13404:黑岩刺枪
13405:决斗之枪
13406:千岩长枪
13407:西风长枪
13408:宗室猎枪
13409:龙脊长枪
13414:喜多院十文字
13415:「渔获」
13416:断浪长鳍
13417:贯月矢
13419:风信之锋
13424:峡湾长歌
13425:公义的酬报
13426:沙中伟贤的对答
13427:勘探钻机
13430:镇山之钉
13431:虹的行迹
13432:且住亭御咄
13433:掘金之锹
13434:圣祭者的辉杖
13435:寒息
13436:戍望谣歌
13501:护摩之杖
13502:天空之脊
13504:贯虹之槊
13505:和璞鸢
13507:息灾
13509:薙草之稻光
13511:赤沙之杖
13512:赤月之形
13513:柔灯挽歌
13514:香韵奏者
13515:支离轮光
13516:血染荒城
13517:灾悔
14101:学徒笔记
14201:口袋魔导书
14301:魔导绪论
14302:讨龙英杰谭
14303:异世界行记
14304:翡玉法球
14305:甲级宝珏
14306:琥珀玥
14401:西风秘典
14402:流浪乐章
14403:祭礼残章
14404:宗室秘法录
14405:匣里日月
14406:试作金珀
14407:万国诸海图谱
14408:黑岩绯玉
14409:昭心
14410:暗巷的酒与诗
14412:忍冬之果
14413:嘟嘟可故事集
14414:白辰之环
14415:证誓之明瞳
14416:流浪的晚星
14417:盈满之实
14424:遗祀玉珑
14425:纯水流华
14426:无垠蔚蓝之歌
14427:苍纹角杯
14430:乘浪的回旋
14431:木棉之环
14432:天光的纺琴
14433:乌髓孑灯
14434:霜辰
14435:群王局戏
14436:寸心余响
14437:凝雪沉心
14501:天空之卷
14502:四风原典
14504:尘世之锁
14505:碧落之珑
14506:不灭月华
14509:神乐之真意
14511:千夜浮梦
14512:图莱杜拉的回忆
14513:金流监督
14514:万世流涌大典
14515:鹤鸣余音
14516:冲浪时光
14517:祭星者之望
14518:寝正月初晴
14519:溢彩心念
14520:纺夜天镜
14521:真语秘匣
14522:帷间夜曲
14523:尘光七谕
14524:漩流颂歌
14525:秘星典谕
15101:猎弓
15201:历练的猎弓
15301:鸦羽弓
15302:神射手之誓
15303:反曲弓
15304:弹弓
15305:信使
15306:黑檀弓
15401:西风猎弓
15402:绝弦
15403:祭礼弓
15404:宗室长弓
15405:弓藏
15406:试作澹月
15407:钢轮弓
15408:黑岩战弓
15409:苍翠猎弓
15410:暗巷猎手
15411:落霞
15412:幽夜华尔兹
15413:风花之颂
15414:破魔之弓
15415:掠食者
15416:曚云之月
15417:王下近侍
15418:竭泽
15419:鹮穿之喙
15424:烈阳之嗣
15425:静谧之曲
15426:筑云
15427:测距规
15430:缀花之翎
15431:碎链
15432:冷寂迸音
15433:罗网勾针
15434:虹蛇的雨弦
15435:悬黎千钧
15436:霜雪誓约
15437:柔风游弦
15501:天空之翼
15502:阿莫斯之弓
15503:终末嗟叹之诗
15507:冬极白星
15508:若水
15509:飞雷之弦振
15511:猎人之径
15512:最初的大魔术
15513:白雨心弦
15514:星鹫赤羽
15515:黎明破晓之史
15516:霜结的誓金枝
10009:(test)空武器
10010:(test)M4A1
10011:(test)M4A1
10012:(test)TPS占位空武器
+1
View File
@@ -0,0 +1 @@
[{"label":"无敌","cmd":"/prop god on"},{"label":"无限体力","cmd":"/prop ns on"},{"label":"无限能量","cmd":"/prop ue on"},{"label":"冒险等阶升60级","cmd":"/give 102 x1880200"},{"label":"尘歌壶信任值升到10级","cmd":"/give 121 x10900"},{"label":"设置世界等级8","cmd":"/prop wl 8"},{"label":"点亮地图","cmd":"/prop unlockmap 1"},{"label":"一键解锁深渊12层","cmd":"/prop ut 12"},{"label":"设置纪行等级50","cmd":"/prop bp 50"},{"label":"设置好感等级10","cmd":"/setfetterlevel 10"},{"label":"回血","cmd":"/h"},{"label":"自杀","cmd":"/kill 0"},{"label":"全队充能","cmd":"/spawn 2008 x25"},{"label":"查看坐标","cmd":"/pos"},{"label":"获取全部物品","cmd":"/give all x9999 lv90 c6 r5 sl10"},{"label":"一万纠缠","cmd":"/give 223 x10000"},{"label":"一万相遇","cmd":"/give 224 x10000"},{"label":"十万原石","cmd":"/give 201 x100000"},{"label":"一亿摩拉","cmd":"/give 202 x100000000"},{"label":"重载配置","cmd":"/reload"},{"label":"重登","cmd":"/kick"},{"label":"清空当前角色命之座(需重登)","cmd":"/resetconst"},{"label":"清空全部角色命之座(需重登)","cmd":"/resetconst all"},{"label":"清空背包","cmd":"/clear all lv90 r5 5*"},{"label":"清空武器","cmd":"/clear wp lv90 r5 5*"},{"label":"清空圣遗物","cmd":"/clear art lv20 5*"},{"label":"清空材料","cmd":"/clear mat"},{"label":"击杀全部怪物","cmd":"/killall"},{"label":"进入多人游戏","cmd":"/coop"},{"label":"[多人游戏]全体传送","cmd":"/tpall"},{"label":"玩家列表","cmd":"/list uid"},{"label":"发送广播","cmd":"/say 大家好啊~"},{"label":"服务器公告","cmd":"/a 欢迎来到Grasscutter PS!"},{"label":"关闭服务器","cmd":"/stop"},{"label":"解锁所有状态(可使用尘歌壶道具)","cmd":"/unlockall"},{"label":"无CD","cmd":"/setstats cdr 100%"},{"label":"全皮肤","cmd":"/give 340000|/give 340001|/give 340002|/give 340003|/give 340004|/give 340005|/give 340006|/give 340007|/give 340008|/give 340009|/give 340010|/give 340011|/give 340012|/give 340013"},{"label":"月卡","cmd":"/give 1202 x999"},{"label":"排故信息","cmd":"/troubleshoot"},{"label":"风之翼","cmd":"/prop fly on"},{"label":"芜湖~起飞!","cmd":"/tp ~ ~100 ~"}]
@@ -0,0 +1 @@
{"items":[[101,"角色经验","虚拟道具"],[102,"冒险阅历","虚拟道具"],[105,"好感经验","虚拟道具"],[106,"原粹树脂","虚拟道具"],[107,"传说钥匙","虚拟道具"],[108,"(test)天体推演","虚拟道具"],[109,"熄星能量","虚拟道具"],[110,"熄星精粹","虚拟道具"],[111,"微光精粹","虚拟道具"],[112,"温暖精粹","虚拟道具"],[113,"奇迹精粹","虚拟道具"],[114,"铁钱","虚拟道具"],[115,"平安玉符","虚拟道具"],[116,"节庆热度","虚拟道具"],[117,"奇术符","虚拟道具"],[118,"庆典巡回券","虚拟道具"],[119,"奇趣协力券","虚拟道具"],[120,"纯水真心","虚拟道具"],[121,"信任值","虚拟道具"],[122,"碎果数据","虚拟道具"],[123,"迷踪币","虚拟道具"],[124,"亮闪闪的漂流物","虚拟道具"],[125,"迷你「羽球」","虚拟道具"],[126,"神秘齿轮","虚拟道具"],[127,"鸣雷霰子","虚拟道具"],[128,"鸣雷纯晶","虚拟道具"],[129,"弈棋术经验","虚拟道具"],[130,"灵妙玉符","虚拟道具"],[131,"逐月节节庆热度","虚拟道具"],[132,"残悴之式札","虚拟道具"],[133,"虚损之拓本","虚拟道具"],[134,"朽裂之庚牌","虚拟道具"],[135,"踏雪章","虚拟道具"],[136,"克险章","虚拟道具"],[137,"逢福玉符","虚拟道具"],[138,"完璧玉符","虚拟道具"],[139,"降魔玉符","虚拟道具"],[140,"幽蕴砺石","虚拟道具"],[141,"花簇簇的漂流物","虚拟道具"],[142,"战策碎珀","虚拟道具"],[143,"巧思手记","虚拟道具"],[144,"随想草稿","虚拟道具"],[145,"古铁钱","虚拟道具"],[146,"牌手经验","虚拟道具"],[147,"节庆热度","虚拟道具"],[148,"营业收入","虚拟道具"],[149,"可用资金","虚拟道具"],[150,"巧策灵感","虚拟道具"],[151,"蘑菇宝钱","虚拟道具"],[152,"灵蕈奖章","虚拟道具"],[153,"绮碎斑晶","虚拟道具"],[155,"试胆会的票券","虚拟道具"],[156,"节庆热度","虚拟道具"],[157,"逐花券","虚拟道具"],[158,"游乐会热度","虚拟道具"],[159,"庆典券","虚拟道具"],[160,"妙骰券","虚拟道具"],[161,"欢兴礼券","虚拟道具"],[162,"趣意斑晶","虚拟道具"],[163,"秘铜发条","虚拟道具"],[164,"诗歌会热度","虚拟道具"],[165,"(test)勤务点","虚拟道具"],[166,"「特尔克西徽章」","虚拟道具"],[167,"剧戏票券","虚拟道具"],[168,"古铁钱","虚拟道具"],[169,"节庆热度","虚拟道具"],[170,"逸趣映片","虚拟道具"],[171,"资金","虚拟道具"],[172,"「虹色巡回券」","虚拟道具"],[173,"分析进度","虚拟道具"],[174,"悠乐片段","虚拟道具"],[175,"游迹钥匙","虚拟道具"],[176,"星游币","虚拟道具"],[177,"形彩思绪","虚拟道具"],[178,"庆典热度","虚拟道具"],[179,"焚香晶灰","虚拟道具"],[180,"节庆热度","虚拟道具"],[181,"游艺印章","虚拟道具"],[182,"欢乐零食","虚拟道具"],[183,"资金","虚拟道具"],[184,"行动点","虚拟道具"],[185,"推想记录","虚拟道具"],[186,"绘夏热度","虚拟道具"],[187,"军团士气","虚拟道具"],[188,"完备进度","虚拟道具"],[189,"炽魂豪气","虚拟道具"],[190,"吉语钱","虚拟道具"],[191,"风境风采","虚拟道具"],[192,"游赏见闻","虚拟道具"],[193,"珍赏见闻","虚拟道具"],[194,"联展热度","虚拟道具"],[195,"幻友默契","虚拟道具"],[196,"场馆人气","虚拟道具"],[197,"竞赛胜点","虚拟道具"],[198,"热诚票券","虚拟道具"],[199,"臻冰计量","虚拟道具"],[200,"胜利徽记","虚拟道具"],[201,"原石","虚拟道具"],[202,"摩拉","虚拟道具"],[203,"创世结晶","虚拟道具"],[204,"洞天宝钱","虚拟道具"],[205,"幸运牌币(废弃)","虚拟道具"],[206,"玩具勋章","虚拟道具"],[207,"千音币","虚拟道具"],[231,"事象凝核","虚拟道具"],[232,"绮刻之楔","虚拟道具"],[233,"重现晶簇","虚拟道具"],[234,"刻印片形","虚拟道具"],[235,"盛会之匙","虚拟道具"],[236,"明刻之楔","虚拟道具"],[238,"奇域经验","虚拟道具"],[241,"奇丽凝晶","虚拟道具"],[242,"奇丽凝晶","虚拟道具"],[243,"奇丽凝晶","虚拟道具"],[244,"事象凝核·盛会","虚拟道具"],[245,"事象凝核·盛会","虚拟道具"],[315,"声望经验·蒙德","虚拟道具"],[317,"声望经验·璃月","虚拟道具"],[314,"声望经验·稻妻","虚拟道具"],[316,"声望经验·须弥","虚拟道具"],[318,"声望经验·枫丹","虚拟道具"],[319,"声望经验·「悬木人」","虚拟道具"],[320,"声望经验·「流泉之众」","虚拟道具"],[321,"声望经验·「回声之子」","虚拟道具"],[322,"声望经验·「花羽会」","虚拟道具"],[323,"声望经验·「烟谜主」","虚拟道具"],[324,"声望经验·「沃陆之邦」","虚拟道具"],[401,"预测评分","虚拟道具"],[402,"庆典氛围","虚拟道具"],[403,"游览心得","虚拟道具"],[404,"盛会人气","虚拟道具"],[405,"东部威胁削弱值","虚拟道具"],[406,"中部威胁削弱Line truncated
@@ -15,6 +15,7 @@ import android.widget.TextView
import android.widget.Toast
import com.gctool.mobile.data.Data
import com.gctool.mobile.net.Net
import com.gctool.mobile.pages.AchievementPage
import com.gctool.mobile.pages.ArtifactPage
import com.gctool.mobile.pages.AvatarPage
import com.gctool.mobile.pages.CommandPage
@@ -22,6 +23,7 @@ import com.gctool.mobile.pages.ItemPage
import com.gctool.mobile.pages.MonsterPage
import com.gctool.mobile.pages.Page
import com.gctool.mobile.pages.RemotePage
import com.gctool.mobile.pages.ScenePage
import com.gctool.mobile.pages.SettingsPage
import com.gctool.mobile.pages.WeaponPage
import com.gctool.mobile.ui.Theme
@@ -31,8 +33,8 @@ import org.json.JSONObject
class MainActivity : Activity() {
private val pages: List<Page> = listOf(
ItemPage(), AvatarPage(), WeaponPage(), ArtifactPage(),
MonsterPage(), CommandPage(), RemotePage(), SettingsPage()
ItemPage(), AvatarPage(), WeaponPage(), ArtifactPage(), MonsterPage(),
AchievementPage(), ScenePage(), CommandPage(), RemotePage(), SettingsPage()
)
private lateinit var content: FrameLayout
@@ -96,7 +98,7 @@ class MainActivity : Activity() {
setTypeface(typeface, android.graphics.Typeface.BOLD)
})
titles.addView(TextView(this).apply {
text = "Grasscutter 命令生成器 · 复刻版 1.21.0"
text = "Grasscutter 命令生成器 · 重构版 0.3.0"
textSize = 11.5f
setTextColor(Theme.dim)
})
@@ -1,81 +1,116 @@
package com.gctool.mobile.data
import android.content.Context
import org.json.JSONArray
import org.json.JSONObject
import java.io.BufferedReader
import java.io.InputStreamReader
/**
* 内置数据表:从 assets 里读 "id:名字" 的纯文本。
* 内置数据表(重构版):由 GrasscutterCommandGenerator 的 Resources/zh-cn 下的 txt 转换而来。
*
* - 每行 `id:名称`,`//` 开头的行是注释,空行跳过
* - 文件带 BOM,读取时按 UTF-8 解析并去掉 BOM
* assets/gamedata.json:{ "items": [[id,"名字","分类"], …], … }
* assets/custom.json:[[分类, 命令], …](分类为空表示沿用上一段)
*/
object Data {
data class Entry(val id: Int, val name: String) {
data class Entry(val id: Int, val name: String, val section: String = "") {
override fun toString(): String = "$id · $name"
}
@Volatile private var loaded = false
var items: List<Entry> = emptyList(); private set
var monsters: List<Entry> = emptyList(); private set
var avatars: List<Entry> = emptyList(); private set
var weapons: List<Entry> = emptyList(); private set
var artifacts: List<Entry> = emptyList(); private set
var monsters: List<Entry> = emptyList(); private set
var artifactMain: List<Entry> = emptyList(); private set
var achievements: List<Entry> = emptyList(); private set
var scenes: List<Entry> = emptyList(); private set
var dungeons: List<Entry> = emptyList(); private set
var cutscenes: List<Entry> = emptyList(); private set
/** 预设命令(上游 CustomCommands.txt 的「标签 + 命令」对) */
data class Preset(val label: String, val cmd: String)
var custom: List<Preset> = emptyList(); private set
fun load(ctx: Context) {
if (loaded) return
synchronized(this) {
if (loaded) return
items = read(ctx, "Item.txt")
avatars = read(ctx, "Avatar.txt")
weapons = read(ctx, "Weapon.txt")
artifacts = read(ctx, "Artifact.txt")
monsters = read(ctx, "Monsters.txt")
scenes = read(ctx, "Scene.txt")
val g = readText(ctx, "gamedata.json")?.let { JSONObject(it) }
if (g != null) {
items = entries(g.optJSONArray("items"))
monsters = entries(g.optJSONArray("monsters"))
avatars = entries(g.optJSONArray("avatars"))
weapons = entries(g.optJSONArray("weapons"))
artifacts = entries(g.optJSONArray("artifacts"))
artifactMain = entries(g.optJSONArray("artifactMain"))
achievements = entries(g.optJSONArray("achievements"))
scenes = entries(g.optJSONArray("scenes"))
dungeons = entries(g.optJSONArray("dungeons"))
cutscenes = entries(g.optJSONArray("cutscenes"))
}
val c = readText(ctx, "custom.json")?.let { JSONArray(it) }
if (c != null) {
val out = ArrayList<Preset>()
for (i in 0 until c.length()) {
val o = c.optJSONObject(i) ?: continue
val label = o.optString("label", "")
val cmd = o.optString("cmd", "")
if (label.isNotEmpty() && cmd.isNotEmpty()) out.add(Preset(label, cmd))
}
custom = out
}
loaded = true
}
}
private fun read(ctx: Context, name: String): List<Entry> {
val out = ArrayList<Entry>()
try {
ctx.assets.open(name).use { input ->
BufferedReader(InputStreamReader(input, Charsets.UTF_8)).use { reader ->
reader.forEachLine { raw ->
val line = raw.removePrefix("\uFEFF").trim()
if (line.isEmpty() || line.startsWith("//")) return@forEachLine
val idx = line.indexOf(':')
if (idx <= 0) return@forEachLine
val id = line.substring(0, idx).trim().toIntOrNull() ?: return@forEachLine
val label = line.substring(idx + 1).trim()
if (label.isNotEmpty()) out.add(Entry(id, label))
}
}
}
} catch (_: Exception) {
// 缺文件时返回空列表,界面照常可用
private fun readText(ctx: Context, name: String): String? = try {
ctx.assets.open(name).use { input ->
BufferedReader(InputStreamReader(input, Charsets.UTF_8)).use { it.readText() }
}
} catch (_: Exception) {
null
}
private fun entries(arr: JSONArray?): List<Entry> {
if (arr == null) return emptyList()
val out = ArrayList<Entry>(arr.length())
for (i in 0 until arr.length()) {
val row = arr.optJSONArray(i) ?: continue
val id = row.optInt(0)
val name = row.optString(1, "")
val section = if (row.length() > 2) row.optString(2, "") else ""
if (id > 0 && name.isNotEmpty()) out.add(Entry(id, name, section))
}
return out
}
/**
* 搜索:id 前缀命中,或名字包含关键字(忽略大小写);空关键字时返回前 limit 条。
*/
fun search(list: List<Entry>, query: String?, limit: Int): List<Entry> {
if (limit <= 0) return emptyList()
val q = query?.trim().orEmpty()
if (q.isEmpty()) return list.take(limit)
val needle = q.lowercase()
val out = ArrayList<Entry>(minOf(limit, 64))
/** 搜索:id 前缀命中优先,其次名字包含;空查询返回前 limit 条 */
fun search(list: List<Entry>, q: String, limit: Int = 200): List<Entry> {
val key = q.trim()
if (key.isEmpty()) return list.take(limit)
val byId = ArrayList<Entry>()
val byName = ArrayList<Entry>()
val lower = key.lowercase()
for (e in list) {
if (e.id.toString().startsWith(needle) || e.name.lowercase().contains(needle)) {
out.add(e)
if (out.size >= limit) break
}
if (e.id.toString().startsWith(key)) byId.add(e) else if (e.name.lowercase().contains(lower)) byName.add(e)
if (byId.size + byName.size >= limit * 2) break
}
return out
return (byId + byName).take(limit)
}
/** 分类列表(按出现顺序,带数量) */
fun sections(list: List<Entry>): List<Pair<String, Int>> {
val map = LinkedHashMap<String, Int>()
for (e in list) {
if (e.section.isEmpty()) continue
map[e.section] = (map[e.section] ?: 0) + 1
}
return map.toList()
}
fun ofSection(list: List<Entry>, section: String): List<Entry> =
if (section.isEmpty()) list else list.filter { it.section == section }
}
@@ -1,12 +1,13 @@
package com.gctool.mobile.pages
import android.content.Context
import android.view.Gravity
import android.content.SharedPreferences
import android.view.View
import android.view.ViewGroup
import android.widget.AdapterView
import android.widget.ArrayAdapter
import android.widget.EditText
import android.widget.HorizontalScrollView
import android.widget.LinearLayout
import android.widget.ListView
import android.widget.ScrollView
@@ -16,6 +17,7 @@ import com.gctool.mobile.data.Data
import com.gctool.mobile.net.Net
import com.gctool.mobile.ui.Theme
import com.gctool.mobile.ui.Ui
import org.json.JSONObject
/** 所有页面的基类:负责「生成命令」和「提示」两个回调 */
abstract class Page(val id: String, val title: String) {
@@ -29,10 +31,10 @@ abstract class Page(val id: String, val title: String) {
protected fun toast(msg: String) = onToast(msg)
}
/** 列表 + 搜索 + 选中项 的通用区块 */
/** 列表 + 搜索 + 选中项;分类筛选由页面自己传进来 */
class Picker(
private val ctx: Context,
private val source: List<Data.Entry>,
private var source: List<Data.Entry>,
private val onPick: (Data.Entry?) -> Unit
) {
var selected: Data.Entry? = null
@@ -44,7 +46,7 @@ class Picker(
val tv = (convertView as? TextView) ?: TextView(ctx).apply {
textSize = 14f
setTextColor(Theme.text)
setPadding(0, Ui.dp(ctx, 10), 0, Ui.dp(ctx, 10))
setPadding(Ui.dp(ctx, 12), Ui.dp(ctx, 10), Ui.dp(ctx, 12), Ui.dp(ctx, 10))
}
tv.text = getItem(position)?.toString().orEmpty()
tv.setTextColor(if (getItem(position) == selected) Theme.accent else Theme.text)
@@ -52,20 +54,16 @@ class Picker(
}
}
private val search = Ui.input(ctx, "搜 id 或名字,例如 1001 / 甜甜花")
val view: View by lazy {
val box = LinearLayout(ctx).apply {
orientation = LinearLayout.VERTICAL
}
val search = Ui.input(ctx, "搜 id 或名字,例如 1001 / 甜甜花")
search.layoutParams = LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT
)
val box = LinearLayout(ctx).apply { orientation = LinearLayout.VERTICAL }
val list = ListView(ctx).apply {
adapter = this@Picker.adapter
dividerHeight = 1
divider = android.graphics.drawable.ColorDrawable(Theme.border)
setBackgroundColor(Theme.input)
layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Ui.dp(ctx, 260))
layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Ui.dp(ctx, 250))
}
list.onItemClickListener = AdapterView.OnItemClickListener { _, _, pos, _ ->
selected = adapter.getItem(pos)
@@ -73,9 +71,7 @@ class Picker(
onPick(selected)
}
search.addTextChangedListener(object : android.text.TextWatcher {
override fun afterTextChanged(s: android.text.Editable?) {
refresh(s?.toString().orEmpty())
}
override fun afterTextChanged(s: android.text.Editable?) = refresh(s?.toString().orEmpty())
override fun beforeTextChanged(s: CharSequence?, a: Int, b: Int, c: Int) {}
override fun onTextChanged(s: CharSequence?, a: Int, b: Int, c: Int) {}
})
@@ -86,6 +82,18 @@ class Picker(
box
}
/** 换数据源(分类切换时用) */
fun setSource(list: List<Data.Entry>) {
source = list
selected = null
refresh(search.text.toString())
}
fun clearSelection() {
selected = null
adapter.notifyDataSetChanged()
}
private fun refresh(q: String) {
adapter.clear()
adapter.addAll(Data.search(source, q, 200))
@@ -99,6 +107,11 @@ private fun scroll(ctx: Context, content: LinearLayout): View =
addView(content)
}
private fun pageRoot(ctx: Context): LinearLayout = LinearLayout(ctx).apply {
orientation = LinearLayout.VERTICAL
setPadding(Ui.dp(ctx, 14), Ui.dp(ctx, 10), Ui.dp(ctx, 14), Ui.dp(ctx, 16))
}
private fun paramsRow(ctx: Context, vararg fields: Pair<String, EditText>): LinearLayout {
val row = LinearLayout(ctx).apply { orientation = LinearLayout.HORIZONTAL }
fields.forEachIndexed { i, (label, edit) ->
@@ -113,183 +126,359 @@ private fun paramsRow(ctx: Context, vararg fields: Pair<String, EditText>): Line
return row
}
/** 一排横向滚动的分类 chip;点一下切列表 */
private fun sectionBar(ctx: Context, sections: List<Pair<String, Int>>, onPick: (String) -> Unit): View {
val scroll = HorizontalScrollView(ctx).apply { isHorizontalScrollBarEnabled = false }
val row = LinearLayout(ctx).apply { orientation = LinearLayout.HORIZONTAL }
var active = ""
val chips = ArrayList<Pair<TextView, String>>()
fun addChip(label: String, value: String) {
val chip = Ui.chip(ctx, label, value == active) { }
chip.setOnClickListener {
active = value
chips.forEach { (v, key) -> v.setTextColor(if (key == value) Theme.bg else Theme.text) }
chips.forEach { (v, key) ->
v.background = Ui.round(ctx, if (key == value) Theme.accent else Theme.accentSoft, 999, 1, if (key == value) Theme.accent else Theme.border)
}
onPick(value)
}
chips.add(chip to value)
val lp = LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
if (chips.size > 1) lp.marginStart = Ui.dp(ctx, 6)
chip.layoutParams = lp
row.addView(chip)
}
addChip("全部", "")
sections.take(12).forEach { (name, count) -> addChip("$name $count", name) }
scroll.addView(row)
return scroll
}
// ---------------- 物品 ----------------
class ItemPage : Page("item", "物品") {
override fun build(ctx: Context): View {
this.ctx = ctx
val root = LinearLayout(ctx).apply {
orientation = LinearLayout.VERTICAL
setPadding(Ui.dp(ctx, 14), Ui.dp(ctx, 10), Ui.dp(ctx, 14), Ui.dp(ctx, 14))
}
val root = pageRoot(ctx)
val picker = Picker(ctx, Data.items) {}
val count = Ui.input(ctx, "数量,默认 1", "1", true)
val level = Ui.input(ctx, "等级,默认 1", "1", true)
val actions = LinearLayout(ctx).apply { orientation = LinearLayout.HORIZONTAL }
actions.addView(Ui.button(ctx, "给予物品", true) {
val e = picker.selected
if (e == null) { toast("先在上面的列表里选一项"); return@button }
emit("/give ${e.id} x${Ui.num(ctx, count, 1)} lv${Ui.num(ctx, level, 1)}")
})
actions.addView(Ui.button(ctx, "生成物品") {
val e = picker.selected
if (e == null) { toast("先在上面的列表里选一项"); return@button }
emit("/spawn ${e.id} x${Ui.num(ctx, count, 1)} lv${Ui.num(ctx, level, 1)}")
})
actions.addView(Ui.button(ctx, "掉落物品") {
val e = picker.selected
if (e == null) { toast("先在上面的列表里选一项"); return@button }
emit("/drop ${e.id} ${Ui.num(ctx, count, 1)}")
})
val count = Ui.input(ctx, "数量", "1", true)
val level = Ui.input(ctx, "等级", "1", true)
root.addView(sectionBar(ctx, Data.sections(Data.items)) { picker.setSource(Data.ofSection(Data.items, it)) })
root.addView(Ui.vspace(ctx, 8))
root.addView(picker.view)
root.addView(Ui.vspace(ctx, 10))
root.addView(paramsRow(ctx, "数量" to count, "等级" to level))
root.addView(Ui.vspace(ctx, 10))
root.addView(actions)
val row = LinearLayout(ctx).apply { orientation = LinearLayout.HORIZONTAL }
row.addView(Ui.button(ctx, "给予物品", true) {
val e = picker.selected ?: return@button toast("先在上面的列表里选一项")
emit("/give ${e.id} x${Ui.num(ctx, count, 1)} lv${Ui.num(ctx, level, 1)}")
})
row.addView(Ui.button(ctx, "生成物品") {
val e = picker.selected ?: return@button toast("先在上面的列表里选一项")
emit("/spawn ${e.id} x${Ui.num(ctx, count, 1)} lv${Ui.num(ctx, level, 1)}")
})
row.addView(Ui.button(ctx, "掉落") {
val e = picker.selected ?: return@button toast("先在上面的列表里选一项")
emit("/drop ${e.id} ${Ui.num(ctx, count, 1)}")
})
root.addView(row)
root.addView(Ui.vspace(ctx, 8))
root.addView(Ui.label(ctx, "数据:GrasscutterCommandGenerator 的 Item.txt,共 ${Data.items.size} 条"))
return scroll(ctx, root)
}
}
// ---------------- 角色 ----------------
class AvatarPage : Page("avatar", "角色") {
override fun build(ctx: Context): View {
this.ctx = ctx
val root = LinearLayout(ctx).apply {
orientation = LinearLayout.VERTICAL
setPadding(Ui.dp(ctx, 14), Ui.dp(ctx, 10), Ui.dp(ctx, 14), Ui.dp(ctx, 14))
}
val root = pageRoot(ctx)
val picker = Picker(ctx, Data.avatars) {}
val level = Ui.input(ctx, "等级", "90", true)
val cons = Ui.input(ctx, "命座", "90", true)
val talent = Ui.input(ctx, "天赋", "90", true)
val actions = LinearLayout(ctx).apply { orientation = LinearLayout.HORIZONTAL }
actions.addView(Ui.button(ctx, "给予角色", true) {
val e = picker.selected
if (e == null) { toast("先在上面的列表里选一项"); return@button }
emit("/give ${e.id} lv${Ui.num(ctx, level, 90)} c${Ui.num(ctx, cons, 90)} sl${Ui.num(ctx, talent, 90)}")
})
actions.addView(Ui.button(ctx, "直接生成") {
val e = picker.selected
if (e == null) { toast("先在上面的列表里选一项"); return@button }
emit("/givechar ${e.id} ${Ui.num(ctx, level, 90)}")
})
val cons = Ui.input(ctx, "命座", "6", true)
val talent = Ui.input(ctx, "天赋", "10", true)
root.addView(picker.view)
root.addView(Ui.vspace(ctx, 10))
root.addView(paramsRow(ctx, "等级" to level, "命座" to cons))
root.addView(Ui.vspace(ctx, 8))
root.addView(paramsRow(ctx, "天赋" to talent))
root.addView(paramsRow(ctx, "等级" to level, "命座" to cons, "天赋" to talent))
root.addView(Ui.vspace(ctx, 10))
root.addView(actions)
val row = LinearLayout(ctx).apply { orientation = LinearLayout.HORIZONTAL }
row.addView(Ui.button(ctx, "给予角色", true) {
val e = picker.selected ?: return@button toast("先在上面的列表里选一项")
emit("/give ${e.id} lv${Ui.num(ctx, level, 90)} c${Ui.num(ctx, cons, 6)} sl${Ui.num(ctx, talent, 10)}")
})
row.addView(Ui.button(ctx, "直接生成") {
val e = picker.selected ?: return@button toast("先在上面的列表里选一项")
emit("/givechar ${e.id} ${Ui.num(ctx, level, 90)}")
})
root.addView(row)
root.addView(Ui.vspace(ctx, 10))
root.addView(Ui.button(ctx, "给所有角色都发一个") {
emit("/give avatars lv${Ui.num(ctx, level, 90)} c${Ui.num(ctx, cons, 6)} sl${Ui.num(ctx, talent, 10)}")
})
return scroll(ctx, root)
}
}
// ---------------- 武器 ----------------
class WeaponPage : Page("weapon", "武器") {
override fun build(ctx: Context): View {
this.ctx = ctx
val root = LinearLayout(ctx).apply {
orientation = LinearLayout.VERTICAL
setPadding(Ui.dp(ctx, 14), Ui.dp(ctx, 10), Ui.dp(ctx, 14), Ui.dp(ctx, 14))
}
val root = pageRoot(ctx)
val picker = Picker(ctx, Data.weapons) {}
val count = Ui.input(ctx, "数量", "1", true)
val level = Ui.input(ctx, "等级", "90", true)
val refine = Ui.input(ctx, "精炼", "1", true)
root.addView(picker.view)
root.addView(Ui.vspace(ctx, 10))
root.addView(paramsRow(ctx, "数量" to count, "等级" to level, "精炼" to refine))
root.addView(Ui.vspace(ctx, 10))
root.addView(Ui.button(ctx, "给予武器", true) {
val e = picker.selected
if (e == null) { toast("先在上面的列表里选一项"); return@button }
val row = LinearLayout(ctx).apply { orientation = LinearLayout.HORIZONTAL }
row.addView(Ui.button(ctx, "给予武器", true) {
val e = picker.selected ?: return@button toast("先在上面的列表里选一项")
emit("/give ${e.id} x${Ui.num(ctx, count, 1)} lv${Ui.num(ctx, level, 90)} r${Ui.num(ctx, refine, 1)}")
})
row.addView(Ui.button(ctx, "全部武器") {
emit("/give weapons x${Ui.num(ctx, count, 1)} lv${Ui.num(ctx, level, 90)} r${Ui.num(ctx, refine, 1)}")
})
root.addView(row)
return scroll(ctx, root)
}
}
// ---------------- 圣遗物 ----------------
class ArtifactPage : Page("artifact", "圣遗物") {
override fun build(ctx: Context): View {
this.ctx = ctx
val root = LinearLayout(ctx).apply {
orientation = LinearLayout.VERTICAL
setPadding(Ui.dp(ctx, 14), Ui.dp(ctx, 10), Ui.dp(ctx, 14), Ui.dp(ctx, 14))
}
val root = pageRoot(ctx)
val picker = Picker(ctx, Data.artifacts) {}
val level = Ui.input(ctx, "等级", "20", true)
var main = ""
val mainRow = HorizontalScrollView(ctx).apply { isHorizontalScrollBarEnabled = false }
val chips = LinearLayout(ctx).apply { orientation = LinearLayout.HORIZONTAL }
Data.artifactMain.take(10).forEachIndexed { i, attr ->
val chip = Ui.chip(ctx, attr.name, false) { }
chip.setOnClickListener {
main = if (main == attr.id.toString()) "" else attr.id.toString()
for (j in 0 until chips.childCount) {
val v = chips.getChildAt(j) as TextView
val on = v.text == attr.name && main.isNotEmpty()
v.setTextColor(if (on) Theme.bg else Theme.text)
v.background = Ui.round(ctx, if (on) Theme.accent else Theme.accentSoft, 999, 1, if (on) Theme.accent else Theme.border)
}
}
val lp = LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
if (i > 0) lp.marginStart = Ui.dp(ctx, 6)
chip.layoutParams = lp
chips.addView(chip)
}
mainRow.addView(chips)
root.addView(picker.view)
root.addView(Ui.vspace(ctx, 10))
root.addView(paramsRow(ctx, "等级" to level))
root.addView(Ui.vspace(ctx, 10))
root.addView(Ui.label(ctx, "主词条(可不选)"))
root.addView(Ui.vspace(ctx, 6))
root.addView(mainRow)
root.addView(Ui.vspace(ctx, 10))
root.addView(Ui.button(ctx, "给予圣遗物", true) {
val e = picker.selected
if (e == null) { toast("先在上面的列表里选一项"); return@button }
emit("/give ${e.id} lv${Ui.num(ctx, level, 20)}")
val e = picker.selected ?: return@button toast("先在上面的列表里选一项")
val lv = Ui.num(ctx, level, 20)
emit(if (main.isEmpty()) "/give ${e.id} lv$lv" else "/give ${e.id} lv$lv $main")
})
return scroll(ctx, root)
}
}
// ---------------- 怪物 ----------------
class MonsterPage : Page("monster", "怪物") {
override fun build(ctx: Context): View {
this.ctx = ctx
val root = LinearLayout(ctx).apply {
orientation = LinearLayout.VERTICAL
setPadding(Ui.dp(ctx, 14), Ui.dp(ctx, 10), Ui.dp(ctx, 14), Ui.dp(ctx, 14))
}
val root = pageRoot(ctx)
val picker = Picker(ctx, Data.monsters) {}
val count = Ui.input(ctx, "数量", "1", true)
val level = Ui.input(ctx, "等级", "1", true)
root.addView(sectionBar(ctx, Data.sections(Data.monsters)) { picker.setSource(Data.ofSection(Data.monsters, it)) })
root.addView(Ui.vspace(ctx, 8))
root.addView(picker.view)
root.addView(Ui.vspace(ctx, 10))
root.addView(paramsRow(ctx, "数量" to count, "等级" to level))
root.addView(Ui.vspace(ctx, 10))
root.addView(Ui.button(ctx, "生成怪物", true) {
val e = picker.selected
if (e == null) { toast("先在上面的列表里选一项"); return@button }
// 原版这里就是 "/spawn <id> <数量> <等级>",不带 lv 前缀,保持兼容
val e = picker.selected ?: return@button toast("先在上面的列表里选一项")
// 原版这里就是 /spawn <id> <数量> <等级>,不带 lv 前缀,保持一致
emit("/spawn ${e.id} ${Ui.num(ctx, count, 1)} ${Ui.num(ctx, level, 1)}")
})
return scroll(ctx, root)
}
}
// ---------------- 成就 ----------------
class AchievementPage : Page("achievement", "成就") {
override fun build(ctx: Context): View {
this.ctx = ctx
val root = pageRoot(ctx)
val picker = Picker(ctx, Data.achievements) {}
root.addView(picker.view)
root.addView(Ui.vspace(ctx, 10))
val row = LinearLayout(ctx).apply { orientation = LinearLayout.HORIZONTAL }
row.addView(Ui.button(ctx, "给予", true) {
val e = picker.selected ?: return@button toast("先选一个成就")
emit("/achievement grant ${e.id}")
})
row.addView(Ui.button(ctx, "撤销") {
val e = picker.selected ?: return@button toast("先选一个成就")
emit("/achievement revoke ${e.id}")
})
root.addView(row)
root.addView(Ui.vspace(ctx, 8))
val row2 = LinearLayout(ctx).apply { orientation = LinearLayout.HORIZONTAL }
row2.addView(Ui.button(ctx, "全部给予") { emit("/achievement grantall") })
row2.addView(Ui.button(ctx, "全部撤销") { emit("/achievement revokeall") })
root.addView(row2)
root.addView(Ui.vspace(ctx, 8))
root.addView(Ui.label(ctx, "数据:Achievement.txt,共 ${Data.achievements.size} 条"))
return scroll(ctx, root)
}
}
// ---------------- 场景 / 副本 / 过场 ----------------
class ScenePage : Page("scene", "场景") {
override fun build(ctx: Context): View {
this.ctx = ctx
val root = pageRoot(ctx)
val picker = Picker(ctx, Data.scenes) {}
var mode = 0 // 0 场景 1 副本 2 过场
val modes = listOf("场景", "副本", "过场")
val chipRow = LinearLayout(ctx).apply { orientation = LinearLayout.HORIZONTAL }
val chips = ArrayList<TextView>()
modes.forEachIndexed { i, name ->
val chip = Ui.chip(ctx, name, i == 0) { }
chip.setOnClickListener {
mode = i
chips.forEachIndexed { j, v ->
v.setTextColor(if (j == i) Theme.bg else Theme.text)
v.background = Ui.round(ctx, if (j == i) Theme.accent else Theme.accentSoft, 999, 1, if (j == i) Theme.accent else Theme.border)
}
picker.setSource(if (i == 0) Data.scenes else if (i == 1) Data.dungeons else Data.cutscenes)
}
val lp = LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
if (i > 0) lp.marginStart = Ui.dp(ctx, 6)
chip.layoutParams = lp
chips.add(chip)
chipRow.addView(chip)
}
root.addView(chipRow)
root.addView(Ui.vspace(ctx, 8))
root.addView(picker.view)
root.addView(Ui.vspace(ctx, 10))
val row = LinearLayout(ctx).apply { orientation = LinearLayout.HORIZONTAL }
row.addView(Ui.button(ctx, "传送", true) {
val e = picker.selected ?: return@button toast("先选一个")
emit("/tp 0 400 0 ${e.id}")
})
row.addView(Ui.button(ctx, "切换") {
val e = picker.selected ?: return@button toast("先选一个")
emit(
when (mode) {
1 -> "/dungeon ${e.id}"
2 -> "/cutscene ${e.id}"
else -> "/scene ${e.id}"
}
)
})
root.addView(row)
root.addView(Ui.vspace(ctx, 8))
root.addView(Ui.label(ctx, "场景 ${Data.scenes.size} · 副本 ${Data.dungeons.size} · 过场 ${Data.cutscenes.size}"))
return scroll(ctx, root)
}
}
// ---------------- 命令 ----------------
class CommandPage : Page("command", "命令") {
private var log: TextView? = null
private var prefs: SharedPreferences? = null
override fun build(ctx: Context): View {
this.ctx = ctx
val root = LinearLayout(ctx).apply {
orientation = LinearLayout.VERTICAL
setPadding(Ui.dp(ctx, 14), Ui.dp(ctx, 10), Ui.dp(ctx, 14), Ui.dp(ctx, 14))
}
prefs = ctx.getSharedPreferences("gctools.history", Context.MODE_PRIVATE)
val root = pageRoot(ctx)
val input = Ui.input(ctx, "手动输入一条命令,例如 /give 1001 x10")
input.isSingleLine = false
input.minLines = 3
val btnRow = LinearLayout(ctx).apply { orientation = LinearLayout.HORIZONTAL }
btnRow.addView(Ui.button(ctx, "设为当前命令", true) {
val text = input.text.toString().trim()
if (text.isEmpty()) { toast("先输入命令"); return@button }
emit(text)
})
btnRow.addView(Ui.button(ctx, "直接发送") {
val text = input.text.toString().trim()
if (text.isEmpty()) { toast("先输入命令"); return@button }
emit(text)
sendDirect(ctx, text)
})
val logView = TextView(ctx).apply {
textSize = 12.5f
setTextColor(Theme.dim)
background = Ui.round(ctx, Theme.input, 10, 1, Theme.border)
val p = Ui.dp(ctx, 10)
setPadding(p, p, p, p)
text = prefs?.getString("last", "").orEmpty()
}
log = logView
val row = LinearLayout(ctx).apply { orientation = LinearLayout.HORIZONTAL }
row.addView(Ui.button(ctx, "设为当前命令", true) {
val t = input.text.toString().trim()
if (t.isEmpty()) return@button toast("先输入命令")
emit(t)
})
row.addView(Ui.button(ctx, "直接发送") {
val t = input.text.toString().trim()
if (t.isEmpty()) return@button toast("先输入命令")
emit(t)
Net.call(ctx, "command", JSONObject().put("command", t), object : Net.Cb {
override fun ok(data: String) {
log?.append("✓ $t → ${data.take(60)}\n")
toast("已发送")
}
override fun err(message: String) {
log?.append("✗ $t → $message\n")
toast("发送失败")
}
})
})
// 预设命令(来自上游 CustomCommands.txt)
if (Data.custom.isNotEmpty()) {
val presetScroll = HorizontalScrollView(ctx).apply { isHorizontalScrollBarEnabled = false }
val presetRow = LinearLayout(ctx).apply { orientation = LinearLayout.HORIZONTAL }
Data.custom.forEachIndexed { i, preset ->
val chip = Ui.chip(ctx, preset.label, false) { }
chip.setOnClickListener {
input.setText(preset.cmd)
emit(preset.cmd)
}
val lp = LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
if (i > 0) lp.marginStart = Ui.dp(ctx, 6)
chip.layoutParams = lp
presetRow.addView(chip)
}
presetScroll.addView(presetRow)
root.addView(Ui.label(ctx, "预设(点一下填入并设为当前命令)"))
root.addView(Ui.vspace(ctx, 6))
root.addView(presetScroll)
root.addView(Ui.vspace(ctx, 10))
}
root.addView(input)
root.addView(Ui.vspace(ctx, 10))
root.addView(btnRow)
root.addView(row)
root.addView(Ui.vspace(ctx, 12))
root.addView(Ui.label(ctx, "执行记录"))
root.addView(Ui.vspace(ctx, 6))
@@ -297,35 +486,19 @@ class CommandPage : Page("command", "命令") {
root.addView(Ui.vspace(ctx, 8))
root.addView(Ui.button(ctx, "清空记录") {
logView.text = ""
prefs?.edit()?.putString("last", "")?.apply()
toast("已清空")
})
return scroll(ctx, root)
}
/** 「直接发送」:把命令直接丢给服务器,同时写进执行记录 */
private fun sendDirect(ctx: Context, command: String) {
log?.append("→ $command\n")
Net.call(ctx, "command", org.json.JSONObject().put("command", command), object : Net.Cb {
override fun ok(data: String) {
log?.append("✓ $data\n")
toast("已发送")
}
override fun err(message: String) {
log?.append("✗ $message\n")
toast("发送失败")
}
})
}
}
// ---------------- 远程 ----------------
class RemotePage : Page("remote", "远程") {
override fun build(ctx: Context): View {
this.ctx = ctx
val root = LinearLayout(ctx).apply {
orientation = LinearLayout.VERTICAL
setPadding(Ui.dp(ctx, 14), Ui.dp(ctx, 10), Ui.dp(ctx, 14), Ui.dp(ctx, 14))
}
val root = pageRoot(ctx)
val host = Ui.input(ctx, "http://127.0.0.1:443", Net.host(ctx))
val token = Ui.input(ctx, "OpenCommand 控制台令牌", Net.token(ctx))
val log = TextView(ctx).apply {
@@ -338,57 +511,53 @@ class RemotePage : Page("remote", "远程") {
Net.setToken(ctx, token.text.toString())
}
root.addView(Ui.title(ctx, "服务器"))
root.addView(Ui.vspace(ctx, 8))
root.addView(Ui.label(ctx, "地址(Grasscutter 服务端,需装 OpenCommand 插件)"))
root.addView(Ui.label(ctx, "地址(装好 OpenCommand 插件的 Grasscutter 服务端)"))
root.addView(host)
root.addView(Ui.vspace(ctx, 8))
root.addView(Ui.label(ctx, "令牌"))
root.addView(token)
root.addView(Ui.vspace(ctx, 10))
root.addView(LinearLayout(ctx).apply {
orientation = LinearLayout.HORIZONTAL
addView(Ui.button(ctx, "测试连接", true) {
save()
log.text = "连接中…"
Net.call(ctx, "ping", null, object : Net.Cb {
override fun ok(data: String) {
log.setTextColor(Theme.good)
log.text = "已连接 · ${data.ifBlank { "pong" }}"
toast("已连接")
}
val row = LinearLayout(ctx).apply { orientation = LinearLayout.HORIZONTAL }
row.addView(Ui.button(ctx, "测试连接", true) {
save()
log.text = "连接中…"
Net.call(ctx, "ping", null, object : Net.Cb {
override fun ok(data: String) {
log.setTextColor(Theme.good)
log.text = "已连接 · ${data.ifBlank { "pong" }}"
toast("已连接")
}
override fun err(message: String) {
log.setTextColor(Theme.danger)
log.text = "连接失败 · $message"
toast("连接失败")
}
})
})
addView(Ui.button(ctx, "保存") {
save()
toast("已保存")
})
addView(Ui.button(ctx, "清空") {
Net.clearSettings(ctx)
host.setText(Net.DEFAULT_HOST)
token.setText("")
toast("已清空")
override fun err(message: String) {
log.setTextColor(Theme.danger)
log.text = "连接失败 · $message"
toast("连接失败")
}
})
})
row.addView(Ui.button(ctx, "保存") { save(); toast("已保存") })
row.addView(Ui.button(ctx, "清空") {
Net.clearSettings(ctx)
host.setText(Net.DEFAULT_HOST)
token.setText("")
log.text = ""
toast("已清空")
})
root.addView(row)
root.addView(Ui.vspace(ctx, 10))
root.addView(log)
root.addView(Ui.vspace(ctx, 12))
root.addView(Ui.label(ctx, "协议:POST {地址}/opencommand/api,body {token, action, data};发送命令用 action=command。"))
return scroll(ctx, root)
}
}
// ---------------- 设置 ----------------
class SettingsPage : Page("settings", "设置") {
override fun build(ctx: Context): View {
this.ctx = ctx
val root = LinearLayout(ctx).apply {
orientation = LinearLayout.VERTICAL
setPadding(Ui.dp(ctx, 14), Ui.dp(ctx, 10), Ui.dp(ctx, 14), Ui.dp(ctx, 14))
}
val root = pageRoot(ctx)
val auto = Switch(ctx).apply {
text = "生成命令后自动发送"
textSize = 14f
@@ -399,25 +568,40 @@ class SettingsPage : Page("settings", "设置") {
toast(if (checked) "已开启自动发送" else "已关闭自动发送")
}
}
val about = TextView(ctx).apply {
textSize = 13f
setTextColor(Theme.dim)
text = "GcTools 复刻版 · 1.21.0\n" +
"根据原 APK 逆向重写:数据表、命令语法、OpenCommand 协议一致。\n\n" +
"内置数据:物品 ${Data.items.size}、角色 ${Data.avatars.size}、武器 ${Data.weapons.size}、" +
"圣遗物 ${Data.artifacts.size}、怪物 ${Data.monsters.size}、场景 ${Data.scenes.size}\n\n" +
"数据与命令规则版权归原项目(Grasscutter / GcTools)所有,仅供本地使用。"
}
root.addView(Ui.card(ctx).apply {
addView(Ui.title(ctx, "发送"))
addView(Ui.vspace(ctx, 8))
addView(auto)
})
root.addView(Ui.vspace(ctx, 12))
val wl = Ui.input(ctx, "世界等级", "8", true)
val bp = Ui.input(ctx, "BP 等级", "50", true)
root.addView(Ui.card(ctx).apply {
addView(Ui.title(ctx, "快捷属性"))
addView(Ui.vspace(ctx, 8))
addView(paramsRow(ctx, "世界等级" to wl, "BP 等级" to bp))
addView(Ui.vspace(ctx, 8))
val r = LinearLayout(ctx).apply { orientation = LinearLayout.HORIZONTAL }
r.addView(Ui.button(ctx, "设置世界等级", true) { emit("/prop worldlevel ${Ui.num(ctx, wl, 8)}") })
r.addView(Ui.button(ctx, "设置 BP 等级") { emit("/prop bplevel ${Ui.num(ctx, bp, 50)}") })
addView(r)
addView(Ui.vspace(ctx, 8))
addView(Ui.button(ctx, "解锁全部场景标记") { emit("/tag unlockall") })
})
root.addView(Ui.vspace(ctx, 12))
root.addView(Ui.card(ctx).apply {
addView(Ui.title(ctx, "关于"))
addView(Ui.vspace(ctx, 8))
addView(about)
addView(Ui.label(
ctx,
"GcTools 手机版 · 重构版 0.3.0\n" +
"基于 jie65535/GrasscutterCommandGenerator 的资源与命令规则重写,纯原生 Android(Kotlin + 系统控件),不需要 .NET、不联网也能生成命令。\n\n" +
"内置数据:物品 ${Data.items.size}、角色 ${Data.avatars.size}、武器 ${Data.weapons.size}、" +
"圣遗物 ${Data.artifacts.size}、怪物 ${Data.monsters.size}、成就 ${Data.achievements.size}、" +
"场景 ${Data.scenes.size}、副本 ${Data.dungeons.size}、过场 ${Data.cutscenes.size}\n\n" +
"数据与命令规则版权归上游项目(AGPL-3.0),本应用仅做本地命令生成。",
12.5f
))
})
return scroll(ctx, root)
}
+59
View File
@@ -0,0 +1,59 @@
import { readFileSync, writeFileSync, mkdirSync } from 'node:fs'
// 用法:node tools/convert.mjs <上游仓库>/Source/GrasscutterTools/Resources/zh-cn
import { fileURLToPath } from 'node:url'
import { dirname, resolve } from 'node:path'
const SRC = process.argv[2] || './GrasscutterCommandGenerator/Source/GrasscutterTools/Resources/zh-cn'
const OUT = resolve(dirname(fileURLToPath(import.meta.url)), '../android/app/src/main/assets')
function parse(text) {
const lines = text.replace(/^\uFEFF/, '').split(/\r?\n/)
const out = []
let section = ''
for (const raw of lines) {
const line = raw.trim()
if (!line) continue
if (line.startsWith('//')) { section = line.slice(2).trim(); continue }
const i = line.indexOf(':')
if (i <= 0) continue
const id = line.slice(0, i).trim()
const name = line.slice(i + 1).trim()
if (!/^\d+$/.test(id) || !name) continue
out.push([Number(id), name, section])
}
return out
}
const files = {
items: 'Item.txt', monsters: 'Monsters.txt', achievements: 'Achievement.txt',
scenes: 'Scene.txt', dungeons: 'Dungeon.txt', cutscenes: 'Cutscene.txt',
artifacts: 'Artifact.txt', weapons: 'Weapon.txt', avatars: 'Avatar.txt',
artifactCats: 'ArtifactCat.txt', artifactMain: 'ArtifactMainAttribution.txt',
artifactSub: 'ArtifactSubAttribution.txt', props: 'PlayerProperty.txt',
}
const db = {}
for (const [k, f] of Object.entries(files)) {
db[k] = parse(readFileSync(`${SRC}/${f}`, 'utf8'))
}
// 自定义命令:上游是「标签一行、命令一行」交替(见 PageCustomCommands.SaveCustomCommandControls)
const customRaw = readFileSync(`${SRC}/CustomCommands.txt`, 'utf8').replace(/^\uFEFF/, '')
const custom = []
let label = ''
for (const raw of customRaw.split(/\r?\n/)) {
const line = raw.trim()
if (!line || line.startsWith('//')) continue
if (line.startsWith('/')) {
if (label) custom.push({ label, cmd: line })
label = ''
} else {
label = line
}
}
mkdirSync(OUT, { recursive: true })
writeFileSync(`${OUT}/gamedata.json`, JSON.stringify(db))
writeFileSync(`${OUT}/custom.json`, JSON.stringify(custom))
const stat = (k) => `${k}: ${db[k].length}`
console.log(Object.keys(db).map(stat).join('\n'))
console.log('custom entries:', custom.length)
console.log('size:', (readFileSync(`${OUT}/gamedata.json`).length / 1024 / 1024).toFixed(2), 'MB')
console.log('sample:', JSON.stringify(db.items.slice(0, 2)), JSON.stringify(db.avatars.slice(0, 2)))