Add Files

This commit is contained in:
Scobalula 2019-11-22 01:55:07 +00:00
commit a545324002
60 changed files with 7718 additions and 0 deletions

337
.gitignore vendored Normal file
View file

@ -0,0 +1,337 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Ignore Libraries and tests
Misc
PhilLibX
Tyrant.Testing
Tyrant.UITests
Tyrant.AssetNameFinder
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
**/Properties/launchSettings.json
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush
.cr/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/

674
LICENSE Normal file
View file

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://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 <https://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:
<program> Copyright (C) <year> <name of author>
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
<https://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
<https://www.gnu.org/licenses/why-not-lgpl.html>.

48
README.md Normal file
View file

@ -0,0 +1,48 @@
# Tyrant - RE Engine Extractor
[![Releases](https://img.shields.io/github/downloads/Scobalula/Tyrant/total.svg)](https://github.com/Scobalula/Tyrant/releases) [![License](https://img.shields.io/github/license/Scobalula/Tyrant.svg)](https://github.com/Scobalula/Tyrant/blob/master/LICENSE) [![Discord](https://img.shields.io/badge/chat-Discord-blue.svg)](https://discord.gg/fGVpV39)
Tyrant is an asset extractor for games running on Capcom's RE Engine. It can currently extract:
* [Models](https://i.imgur.com/Zct9kXR.png)
* [Animations](https://i.imgur.com/exfBs6p.gifv)
* Textures
And possibly more in the future!
Current the following games are known to work:
* Resident Evil 7
* Resident Evil 2
* Devil May Cry 5
## Requirements
* Windows 10 x64 or above (Windows 7/8/8.1 should work, but are untested)
* Microsoft Visual Studio 2017 Runtime ([x86](https://aka.ms/vs/16/release/vc_redist.x86.exe) and [x64](https://aka.ms/vs/16/release/vc_redist.x64.exe)) and .NET Framework 4.7.2
* Official copies of the games (only the latest copies from official distributors are tested)
The following tools/plugins are required/recommended for some assets/games:
* [SETools](https://github.com/dtzxporter/SETools) by DTZxPorter (.seanim & .semodel) (Autodesk Maya)
* [io_anim_seanim](https://github.com/SE2Dev/io_anim_seanim) by SE2Dev (.seanim) (Blender)
* [io_model_semodel](https://github.com/dtzxporter/io_model_semodel) by DTZxPorter (.semodel) (Blender)
* [FileTypeDDS](https://github.com/dtzxporter/FileTypeDDS) by DTZxPorter (support in Paint .NET for newer DXGI formats) (Paint .NET)
* [Intel TextureWorks](https://software.intel.com/en-us/articles/intel-texture-works-plugin) by Intel (DDS + Utils) (Photoshop)
* [DarkIris](https://aviacreations.com/modme/index.php?view=topic&tid=831) by DTZxPorter (Texture Utils) (Paint .NET)
## Links:
* Discord Server: [https://discord.gg/fGVpV39](https://discord.gg/fGVpV39)
* Github Repo: [https://github.com/Scobalula/Tyrant](https://github.com/Scobalula/Tyrant)
* Latest Release: [ttps://github.com/Scobalula/Tyrant/releases](https://github.com/Scobalula/Tyrant/releases)
## License/Disclaimer
Tyrant is licensed under the General Public License 3.0, you are free to use it under the terms of the GPL. Tyrant is distributed in the hope it will be useful to, but it comes WITHOU ANY WARRANTY, without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, see the [LICENSE](https://github.com/Scobalula/Greyhound/blob/master/LICENSE) file for more information.
Asset extracted are property of their respective owners, Tyrant's purpose to allow non-commercial creation of fan art, etc. using Capcom's asset.
Greyhound is distributed with an automatic updater that will check for updates each time the application is launched by requesting the releases data via the Github API. If you do not wish for Greyhound to check for updates you can simply delete the Greyhound Updater executable.
## Reporting Bugs
Bugs can be reported through the Github issues or through the Discord server. Please make sure to provide a log when reporting bugs and any info you can possibly give.

BIN
latest/Tyrant.1.0.0.0.zip Normal file

Binary file not shown.

View file

@ -0,0 +1,115 @@
using PhilLibX;
using PhilLibX.Cryptography.Hash;
using PhilLibX.IO;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace Tyrant.Logic
{
/// <summary>
/// A class to handle loading a Material Defs file
/// </summary>
public static class MaterialDefs
{
/// <summary>
/// Resident Evil 7 Material Header
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct MaterialHeaderRE7
{
public uint Magic;
public ushort Version;
public ushort MaterialCount;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public byte[] Padding;
}
/// <summary>
/// Resident Evil 7 Material Entry
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct MaterialEntryRE2
{
public long NamePointer;
public uint Hash; // MurMur3
public int SettingsBufferSize;
public int SettingsInfoCount;
public int TextureCount;
public int Unk03;
public int Unk04;
public long SettingsInfoPointer;
public long TexturesPointer;
public long SettingsBufferPointer;
public long ShaderNamePointer;
}
/// <summary>
/// Resident Evil 7 Material Texture Entry
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct MaterialTextureEntryRE7
{
public long TypePointer;
public uint TypeHash;
public uint UnkHash;
public long TextureNamePointer;
}
/// <summary>
/// Resident Evil 7 Material Texture Entry
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct MaterialSettingsInfoRE7
{
public long NamePointer;
public uint NameHash;
public uint UnkHash;
public int DataCount;
public int DataOffset; // Relative to Material.SettingsBufferPointer
}
/// <summary>
/// Converts the given material file
/// </summary>
public static Dictionary<string, Model.Material> Convert(byte[] buffer)
{
using (var stream = new MemoryStream(buffer))
{
return Convert(stream);
}
}
/// <summary>
/// Converts the given material file
/// </summary>
public static Dictionary<string, Model.Material> Convert(Stream stream)
{
var results = new Dictionary<string, Model.Material>();
using (var reader = new BinaryReader(stream))
{
var header = reader.ReadStruct<MaterialHeaderRE7>();
var materials = reader.ReadArray<MaterialEntryRE2>(header.MaterialCount);
foreach(var material in materials)
{
var result = new Model.Material(reader.ReadUTF16NullTerminatedString(material.NamePointer));
foreach (var texture in reader.ReadArray<MaterialTextureEntryRE7>(material.TexturesPointer, material.TextureCount))
result.Images[reader.ReadUTF16NullTerminatedString(texture.TypePointer)] = reader.ReadUTF16NullTerminatedString(texture.TextureNamePointer).ToLower();
foreach (var setting in reader.ReadArray<MaterialSettingsInfoRE7>(material.SettingsInfoPointer, material.SettingsInfoCount))
result.Settings[reader.ReadUTF16NullTerminatedString(setting.NamePointer)] = reader.ReadArray<float>(material.SettingsBufferPointer + setting.DataOffset, setting.DataCount);
results[result.Name] = result;
}
}
return results;
}
}
}

View file

@ -0,0 +1,742 @@
// ------------------------------------------------------------------------
// Tyrant - RE Engine Extractor
// Copyright (C) 2018 Philip/Scobalula
//
// 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/>.
// ------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using PhilLibX.Mathematics;
using PhilLibX.IO;
using PhilLibX;
namespace Tyrant.Logic
{
public class Mesh
{
/// <summary>
/// Resident Evil 7 Mesh Header
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct MeshHeaderRE7
{
public uint Magic;
public uint Version;
public int FileSize;
public ushort Unk;
public ushort StringCount;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public long[] ModelPointers;
public long BoneDataHeaderPointer;
public long UnkPointer01;
public long UnkPointer02;
public long GeometryPointer;
public long UnkPointer03;
public long MaterialNamesPointer;
public long BoneNamesPointer;
public long UnkPointer04;
public long StringTablePointer;
}
/// <summary>
/// Resident Evil 2 Mesh Header
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct MeshHeaderRE2
{
public uint Magic;
public uint Version;
public long FileSize;
public ushort Unk;
public ushort StringCount;
public uint Padding;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public long[] ModelPointers;
public long BoneDataHeaderPointer;
public long UnkPointer01;
public long UnkPointer02;
public long UnkPointer03;
public long GeometryPointer;
public long UnkPointer05;
public long MaterialNamesPointer;
public long BoneNamesPointer;
public long UnkPointer08;
public long StringTablePointer;
}
/// <summary>
/// Resident Evil 7 Bone Data Header
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct BoneDataHeaderRE7
{
public short BoneCount;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 14)]
public byte[] Padding;
public long BoneTablePointer;
public long MatricesPointer;
public long UnkMatricesPointer01;
public long UnkMatricesPointer02;
}
/// <summary>
/// Resident Evil 2 Bone Data Header
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct BoneDataHeaderRE2
{
public int BoneCount;
public int SkinnedBoneCount;
public long Padding;
public long BoneTablePointer;
public long MatricesPointer;
public long UnkMatricesPointer01;
public long UnkMatricesPointer02;
}
/// <summary>
/// Resident Evil 7 Bone Data
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1, Size = 16)]
internal struct BoneDataRE7
{
public short BoneIndex;
public short ParentIndex;
public short NextSibling;
public short FirstChild;
public short Unk; // Sometimes == BoneIndex, Sometimes -1
}
/// <summary>
/// Resident Evil 7 Model
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct ModelHeaderRE7
{
public byte LODCount;
public byte MaterialCount;
public byte UVCount;
public byte Unk01;
public int Unk02;
}
/// <summary>
/// Resident Evil 7 LOD
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct LODHeaderRE7
{
public ushort MeshCount;
public byte Flags;
public byte BoneCount;
public float LODDistance;
public long MeshesPointer;
}
/// <summary>
/// Resident Evil 7 LOD Mesh
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct LODMeshRE7
{
public byte MeshIndex;
public byte SubMeshCount;
public byte Unk01;
public byte Unk02;
public int Unk03;
public int VertexCount;
public int FaceCount;
}
/// <summary>
/// Resident Evil 7 LOD Submesh
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct LODSubMeshRE7
{
public int MaterialIndex;
public int FaceCount;
public int FaceIndex;
public int VertexIndex;
}
/// <summary>
/// Resident Evil 7 Geometry Header
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct GeometryHeaderRE7
{
public uint VertexBufferSize;
public long UnkPointer;
public int Padding;
public int FaceBufferSize;
public long UnkPointer01;
public int Padding01;
public long Unk01;
public long FaceBufferOffset;
}
/// <summary>
/// Resident Evil 2 Geometry Header
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct GeometryHeaderRE2
{
public long VertexBlocksOffset;
public long VertexDataOffset;
public long FaceBufferOffset;
public int VertexBufferSize;
public int FaceBufferSize;
public short VertexBlockCount;
public short UnkBlockCount; // Always = Above?
public long Unk01;
public int Unk02; // Some value and 0xFFFF usually
}
/// <summary>
/// Resident Evil 2 Vertex Block
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct VertexBlockRE2
{
public short ID; // 0 = XYZ, 1 = Normal/Tangent, 2 = UVLayer1, 3 = UVLayer2, 4 = Weights
public short ElementSize;
public int Offset; // Relative to GeometryHeaderRE2.VertexDataOffset
}
/// <summary>
/// Packed Padded 3-Byte 3-D Vector
/// </summary>
public struct PackedVector3
{
public sbyte X { get; set; }
public sbyte Y { get; set; }
public sbyte Z { get; set; }
public sbyte W { get; set; }
public Vector3 Unpack()
{
return new Vector3(X / 127.0f, Y / 127.0f, Z / 127.0f);
}
}
/// <summary>
/// Face Buffer;
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct Face
{
public ushort FaceIndex1;
public ushort FaceIndex2;
public ushort FaceIndex3;
}
/// <summary>
/// 4x4 Transformation Matrix
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct Matrix4x4
{
public Vector4 X;
public Vector4 Y;
public Vector4 Z;
public Vector4 W;
public Quaternion ToQuaternion()
{
var result = new Quaternion(0, 0, 0, 1.0f);
float divisor;
float transRemain = X.X + Y.Y + Z.Z;
if (transRemain > 0)
{
divisor = (float)Math.Sqrt(transRemain + 1.0f) * 2.0f;
result.W = 0.25f * divisor;
result.X = (Y.Z - Z.Y) / divisor;
result.Y = (Z.X - X.Z) / divisor;
result.Z = (X.Y - Y.X) / divisor;
}
else if ((X.X > Y.Y) && (X.X > Z.Z))
{
divisor = (float)Math.Sqrt(1.0f + X.X - Y.Y - Z.Z) * 2.0f;
result.W = (Y.Z - Z.Y) / divisor;
result.X = 0.25f * divisor;
result.Y = (Y.X + X.Y) / divisor;
result.Z = (Z.X + X.Z) / divisor;
}
else if (Y.Y > Z.Z)
{
divisor = (float)Math.Sqrt(1.0f + Y.Y - X.X - Z.Z) * 2.0f;
result.W = (Z.X - X.Z) / divisor;
result.X = (Y.X + X.Y) / divisor;
result.Y = 0.25f * divisor;
result.Z = (Z.Y + Y.Z) / divisor;
}
else
{
divisor = (float)Math.Sqrt(1.0f + Z.Z - X.X - Y.Y) * 2.0f;
result.W = (X.Y - Y.X) / divisor;
result.X = (Z.X + X.Z) / divisor;
result.Y = (Z.Y + Y.Z) / divisor;
result.Z = 0.25f * divisor;
}
// Return resulting vector
return result;
}
}
/// <summary>
/// Loads Meshes from a Resident Evil 7 Mesh File
/// </summary>
private static List<List<Model>> ConvertRE7(BinaryReader reader)
{
var results = new List<List<Model>>(3);
var header = reader.ReadStruct<MeshHeaderRE7>();
var boneDataHeader = new BoneDataHeaderRE7();
var geometryHeader = new GeometryHeaderRE7();
if (header.BoneDataHeaderPointer > 0)
boneDataHeader = reader.ReadStruct<BoneDataHeaderRE7>(header.BoneDataHeaderPointer);
if (header.GeometryPointer > 0)
geometryHeader = reader.ReadStruct<GeometryHeaderRE7>(header.GeometryPointer);
// Parse all strings for bones, materials, etc. into lists to make it easier to pass around, etc.
var strings = new List<string>(header.StringCount);
foreach (var offset in reader.ReadArray<long>(header.StringTablePointer, header.StringCount))
strings.Add(reader.ReadNullTerminatedString(offset));
var boneNames = new List<string>(boneDataHeader.BoneCount);
foreach (var boneNameIndex in reader.ReadArray<ushort>(header.BoneNamesPointer, boneDataHeader.BoneCount))
boneNames.Add(strings[boneNameIndex]);
Model model = new Model();
if (header.BoneDataHeaderPointer > 0)
{
var boneDatas = reader.ReadArray<BoneDataRE7>(boneDataHeader.BoneTablePointer, boneDataHeader.BoneCount);
var boneMatrices = reader.ReadArray<Matrix4x4>(boneDataHeader.MatricesPointer, boneDataHeader.BoneCount);
for (ushort i = 0; i < boneDataHeader.BoneCount; i++)
{
var bone = new Model.Bone(boneNames[i], boneDatas[i].ParentIndex, new Vector3(
boneMatrices[i].W.X,
boneMatrices[i].W.Y,
boneMatrices[i].W.Z), boneMatrices[i].ToQuaternion());
model.Bones.Add(bone);
}
}
var modelHeader = reader.ReadStruct<ModelHeaderRE7>(header.ModelPointers[0]);
var vertexSize = 20 + (modelHeader.UVCount * 4) + (boneDataHeader.BoneCount > 0 ? 16 : 0);
reader.BaseStream.Position = header.ModelPointers[0] + 64;
var materialIndices = reader.ReadArray<short>(header.MaterialNamesPointer, modelHeader.MaterialCount);
var lodPointers = reader.ReadArray<long>(reader.ReadInt64(), modelHeader.LODCount);
var uniqueMaterials = new List<string>(modelHeader.MaterialCount);
foreach (var lodPointer in lodPointers)
{
var lodHeader = reader.ReadStruct<LODHeaderRE7>(lodPointer);
var boneIndices = reader.ReadArray<short>(lodPointer + 16, lodHeader.BoneCount);
var meshPointers = reader.ReadArray<long>(lodHeader.MeshesPointer, lodHeader.MeshCount);
foreach (var meshPointer in meshPointers)
{
var mesh = reader.ReadStruct<LODMeshRE7>(meshPointer);
var subMeshes = reader.ReadArray<LODSubMeshRE7>(meshPointer + 16, mesh.SubMeshCount);
int verticesRead = 0;
for (int i = 0; i < subMeshes.Length; i++)
{
var materialName = strings[materialIndices[subMeshes[i].MaterialIndex]];
if (!uniqueMaterials.Contains(materialName))
uniqueMaterials.Add(materialName);
var subMesh = new Model.Mesh();
subMesh.MaterialIndices.Add(uniqueMaterials.IndexOf(materialName));
int subMeshVertexCount = 0;
int subMeshFaceCount = subMeshes[i].FaceCount;
// Since the counts aren't stored in each, we can use this to determine the counts
if (i != subMeshes.Length - 1)
subMeshVertexCount = subMeshes[i + 1].VertexIndex - subMeshes[i].VertexIndex;
else
subMeshVertexCount = mesh.VertexCount - verticesRead;
verticesRead += subMeshVertexCount;
reader.BaseStream.Position = header.GeometryPointer + 48 + (vertexSize * subMeshes[i].VertexIndex);
for (int v = 0; v < subMeshVertexCount; v++)
{
// Base vertex data
var vertex = new Model.Vertex(
reader.ReadStruct<Vector3>(),
reader.ReadStruct<PackedVector3>().Unpack(),
reader.ReadStruct<PackedVector3>().Unpack());
vertex.UVs.Add(new Vector2(reader.ReadStruct<Half>(), reader.ReadStruct<Half>()));
// Skip unnsupported UV layers
reader.BaseStream.Position += 4 * (modelHeader.UVCount - 1);
// Check if we have bones
if (lodHeader.BoneCount > 0)
{
var localBoneIndices = reader.ReadBytes(8);
var weights = reader.ReadBytes(8);
var weightSum = 0.0f;
for (int w = 0; w < 8 && weights[w] != 0; w++)
{
vertex.Weights.Add(new Model.Vertex.Weight()
{
BoneIndex = boneIndices[localBoneIndices[w]],
Influence = weights[w] / 255.0f
});
weightSum += vertex.Weights[w].Influence;
}
var multiplier = 1.0f / weightSum;
foreach (var weight in vertex.Weights)
weight.Influence *= multiplier;
}
subMesh.Vertices.Add(vertex);
}
switch (lodHeader.Flags)
{
case 0:
reader.BaseStream.Position = geometryHeader.FaceBufferOffset + (2 * subMeshes[i].FaceIndex);
for (int f = 0; f < subMeshes[i].FaceCount / 3; f++)
{
var v1 = reader.ReadUInt16();
var v2 = reader.ReadUInt16();
var v3 = reader.ReadUInt16();
if (v1 != v2 && v2 != v3 && v3 != v1)
subMesh.Faces.Add(new Model.Face(v1, v2, v3));
}
break;
case 1:
reader.BaseStream.Position = geometryHeader.FaceBufferOffset + (4 * subMeshes[i].FaceIndex);
for (int f = 0; f < subMeshes[i].FaceCount / 3; f++)
{
var v1 = reader.ReadInt32();
var v2 = reader.ReadInt32();
var v3 = reader.ReadInt32();
if (v1 != v2 && v2 != v3 && v3 != v1)
subMesh.Faces.Add(new Model.Face(v1, v2, v3));
}
break;
}
model.Meshes.Add(subMesh);
}
}
foreach (var materialName in uniqueMaterials)
{
var material = new Model.Material(materialName);
}
break;
}
results.Add(new List<Model>
{
model
});
return results;
}
/// <summary>
/// Loads Meshes from a Resident Evil 2 Mesh
/// </summary>
private static List<List<Model>> ConvertRE2(BinaryReader reader)
{
var results = new List<List<Model>>(3);
var header = reader.ReadStruct<MeshHeaderRE2>();
var boneDataHeader = new BoneDataHeaderRE2();
var geometryHeader = new GeometryHeaderRE2();
var vertexBlocks = new Dictionary<short, long>();
short[] skinnedBones = null;
if (header.BoneDataHeaderPointer > 0)
{
boneDataHeader = reader.ReadStruct<BoneDataHeaderRE2>(header.BoneDataHeaderPointer);
skinnedBones = reader.ReadArray<short>(header.BoneDataHeaderPointer + 48, boneDataHeader.SkinnedBoneCount);
}
if (header.GeometryPointer > 0)
{
geometryHeader = reader.ReadStruct<GeometryHeaderRE2>(header.GeometryPointer);
var blocks = reader.ReadArray<VertexBlockRE2>(geometryHeader.VertexBlocksOffset, geometryHeader.VertexBlockCount);
foreach(var block in blocks)
{
vertexBlocks[block.ID] = geometryHeader.VertexDataOffset + block.Offset;
}
}
// Parse all strings for bones, materials, etc. into lists to make it easier to pass around, etc.
var strings = new List<string>(header.StringCount);
foreach (var offset in reader.ReadArray<long>(header.StringTablePointer, header.StringCount))
strings.Add(reader.ReadNullTerminatedString(offset));
var boneNames = new List<string>(boneDataHeader.BoneCount);
foreach (var boneNameIndex in reader.ReadArray<ushort>(header.BoneNamesPointer, boneDataHeader.BoneCount))
boneNames.Add(strings[boneNameIndex]);
var bones = new List<Model.Bone>(boneDataHeader.BoneCount);
if (header.BoneDataHeaderPointer > 0)
{
var boneDatas = reader.ReadArray<BoneDataRE7>(boneDataHeader.BoneTablePointer, boneDataHeader.BoneCount);
var boneMatrices = reader.ReadArray<Matrix4x4>(boneDataHeader.MatricesPointer, boneDataHeader.BoneCount);
for (ushort i = 0; i < boneDataHeader.BoneCount; i++)
{
var bone = new Model.Bone(boneNames[i], boneDatas[i].ParentIndex, new Vector3(
boneMatrices[i].W.X,
boneMatrices[i].W.Y,
boneMatrices[i].W.Z), boneMatrices[i].ToQuaternion());
bones.Add(bone);
}
}
bool firstMdlProcessed = false;
for (int mdl = 0; mdl < 3; mdl++)
{
if (header.ModelPointers[mdl] == 0)
continue;
var lods = new List<Model>();
var modelHeader = reader.ReadStruct<ModelHeaderRE7>(header.ModelPointers[mdl]);
reader.BaseStream.Position = header.ModelPointers[mdl] + (firstMdlProcessed ? 16 : 64);
var materialIndices = reader.ReadArray<short>(header.MaterialNamesPointer, modelHeader.MaterialCount);
firstMdlProcessed = true;
var lodPointers = reader.ReadArray<long>(reader.ReadInt64(), modelHeader.LODCount);
foreach (var lodPointer in lodPointers)
{
var model = new Model()
{
Bones = bones
};
var uniqueMaterials = new List<string>(modelHeader.MaterialCount);
var lodHeader = reader.ReadStruct<LODHeaderRE7>(lodPointer);
var meshPointers = reader.ReadArray<long>(lodHeader.MeshesPointer, lodHeader.MeshCount);
foreach (var meshPointer in meshPointers)
{
var mesh = reader.ReadStruct<LODMeshRE7>(meshPointer);
var subMeshes = reader.ReadArray<LODSubMeshRE7>(meshPointer + 16, mesh.SubMeshCount);
int verticesRead = 0;
for (int i = 0; i < subMeshes.Length; i++)
{
var materialName = strings[materialIndices[subMeshes[i].MaterialIndex]];
if (!uniqueMaterials.Contains(materialName))
uniqueMaterials.Add(materialName);
int subMeshVertexCount = 0;
int subMeshFaceCount = subMeshes[i].FaceCount;
// Since the counts aren't stored in each, we can use this to determine the counts
if (i != subMeshes.Length - 1)
subMeshVertexCount = subMeshes[i + 1].VertexIndex - subMeshes[i].VertexIndex;
else
subMeshVertexCount = mesh.VertexCount - verticesRead;
verticesRead += subMeshVertexCount;
var subMesh = new Model.Mesh(subMeshVertexCount, subMeshFaceCount);
subMesh.MaterialIndices.Add(uniqueMaterials.IndexOf(materialName));
// Positions
if (vertexBlocks.TryGetValue(0, out var positionsOffset))
{
reader.BaseStream.Position = positionsOffset + (12 * subMeshes[i].VertexIndex);
for (int v = 0; v < subMeshVertexCount; v++)
{
subMesh.Vertices.Add(new Model.Vertex(reader.ReadStruct<Vector3>()));
}
}
// Normals/Tangents
if (vertexBlocks.TryGetValue(1, out var normalsTangentsOffset))
{
reader.BaseStream.Position = normalsTangentsOffset + (8 * subMeshes[i].VertexIndex);
for (int v = 0; v < subMeshVertexCount; v++)
{
subMesh.Vertices[v].Normal = reader.ReadStruct<PackedVector3>().Unpack();
subMesh.Vertices[v].Tangent = reader.ReadStruct<PackedVector3>().Unpack();
}
}
// UVs
if (vertexBlocks.TryGetValue(2, out var uvsOffset))
{
reader.BaseStream.Position = uvsOffset + (4 * subMeshes[i].VertexIndex);
for (int v = 0; v < subMeshVertexCount; v++)
{
subMesh.Vertices[v].UVs.Add(new Vector2(reader.ReadStruct<Half>(), reader.ReadStruct<Half>()));
}
}
// Weights
if (vertexBlocks.TryGetValue(4, out var weightsOffset))
{
reader.BaseStream.Position = weightsOffset + (16 * subMeshes[i].VertexIndex);
for (int v = 0; v < subMeshVertexCount; v++)
{
var localBoneIndices = reader.ReadBytes(8);
var weights = reader.ReadBytes(8);
var weightSum = 0.0f;
for (int w = 0; w < 8 && weights[w] != 0; w++)
{
subMesh.Vertices[v].Weights.Add(new Model.Vertex.Weight()
{
BoneIndex = skinnedBones[localBoneIndices[w]],
Influence = weights[w] / 255.0f
});
weightSum += subMesh.Vertices[v].Weights[w].Influence;
}
var multiplier = 1.0f / weightSum;
foreach (var weight in subMesh.Vertices[v].Weights)
weight.Influence *= multiplier;
}
}
switch (lodHeader.Flags)
{
case 0:
reader.BaseStream.Position = geometryHeader.FaceBufferOffset + (2 * subMeshes[i].FaceIndex);
for (int f = 0; f < subMeshes[i].FaceCount / 3; f++)
{
var v1 = reader.ReadUInt16();
var v2 = reader.ReadUInt16();
var v3 = reader.ReadUInt16();
if (v1 != v2 && v2 != v3 && v3 != v1)
subMesh.Faces.Add(new Model.Face(v1, v2, v3));
}
break;
case 1:
reader.BaseStream.Position = geometryHeader.FaceBufferOffset + (4 * subMeshes[i].FaceIndex);
for (int f = 0; f < subMeshes[i].FaceCount / 3; f++)
{
var v1 = reader.ReadInt32();
var v2 = reader.ReadInt32();
var v3 = reader.ReadInt32();
if (v1 != v2 && v2 != v3 && v3 != v1)
subMesh.Faces.Add(new Model.Face(v1, v2, v3));
}
break;
}
model.Meshes.Add(subMesh);
}
}
foreach (var materialName in uniqueMaterials)
{
model.Materials.Add(new Model.Material(materialName));
}
lods.Add(model);
}
results.Add(lods);
}
return results;
}
/// <summary>
/// Converts Mesh
/// </summary>
public static List<List<Model>> Convert(byte[] buffer)
{
using (var stream = new MemoryStream(buffer))
return Convert(stream);
}
/// <summary>
/// Converts Mesh
/// </summary>
public static List<List<Model>> Convert(Stream stream)
{
using (var reader = new BinaryReader(stream))
{
var magic = reader.ReadUInt32();
var version = reader.ReadUInt16();
reader.BaseStream.Position = 0;
switch (version)
{
case 0x2800: return ConvertRE7(reader);
case 0x0600: return ConvertRE2(reader);
default: throw new Exception("Invalid Motion Version");
}
}
}
}
}

View file

@ -0,0 +1,830 @@
// ------------------------------------------------------------------------
// Tyrant - RE Engine Extractor
// Copyright (C) 2018 Philip/Scobalula
//
// 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/>.
// ------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using PhilLibX;
using PhilLibX.Mathematics;
using PhilLibX.IO;
namespace Tyrant.Logic
{
/// <summary>
/// Data Decompressor Alias (for Vector3/Quat Decompressors)
/// </summary>
using DataDecompressorList = Dictionary<uint, Action<BinaryReader, Animation.Bone, int[], float[], long>>;
/// <summary>
/// Structs and Logic for Extracting Motion Files
/// </summary>
public static class Motion
{
/// <summary>
/// Animation Data Precense Flags
/// </summary>
internal enum DataPrecenseFlags : ushort
{
Translations = 1 << 0,
Rotations = 1 << 1,
Scales = 1 << 2,
};
/// <summary>
/// Resident Evil 7 Motion Header
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct MotionHeaderRE7
{
public uint Version;
public uint Magic;
public long Padding;
public long BoneBaseDataPointer;
public long BoneDataPointer;
public long UnkPointer;
public long UnkPointer1;
public long UnkPointer2;
public long UnkPointer3;
public long UnkPointer4;
public long UnkPointer5;
public long NamePointer;
public float FrameCount;
public float UnkFloat;
public float UnkFloat1;
public float UnkFloat2;
public ushort BoneCount;
public ushort BoneDataCount;
public byte UnkPointer2Count;
public byte UnkPointer3Count;
public ushort Unk;
public ushort UnkPointerCount;
public ushort Unk1;
}
/// <summary>
/// Resident Evil 2 Motion Header
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct MotionHeaderRE2
{
public uint Version;
public uint Magic;
public long Padding;
public long BoneBaseDataPointer;
public long BoneDataPointer;
public long UnkPointer;
public long UnkPointer1;
public long UnkPointer2;
public long UnkPointer3;
public long UnkPointer4;
public long UnkPointer5;
public long NamePointer;
public float FrameCount;
public float UnkFloat;
public float UnkFloat1;
public float UnkFloat2;
public ushort BoneCount;
public ushort BoneDataCount;
public byte UnkPointer2Count;
public byte UnkPointer3Count;
public ushort Unk;
public ushort UnkPointerCount;
public ushort Unk1;
}
/// <summary>
/// Resident Evil 7 Bone Base Data
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct BoneBaseDataRE7
{
public long NamePointer;
public long UnkPointer;
public long UnkPointer1;
public long UnkPointer2; // These 3 seem to point to other bones
public Vector4 Translation;
public Quaternion Rotation;
public uint Index;
public uint Hash; // MurMur3
public long Padding2;
}
/// <summary>
/// Resident Evil 7 Bone Data
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct BoneDataRE7
{
public ushort BoneIndex;
public DataPrecenseFlags Flags;
public uint BoneHash; // MurMur3;
public long KeysPointer;
}
/// <summary>
/// Resident Evil 2 Bone Data
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct BoneDataRE2
{
public ushort BoneIndex;
public DataPrecenseFlags Flags;
public uint BoneHash; // MurMur3;
public float Unk; // Always 1.0?
public int Padding;
public long KeysPointer;
}
/// <summary>
/// Resident Evil 7 Key Data (per channel per bone)
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct KeyDataRE7
{
public uint Flags;
public int KeyCount;
public int Unk;
public float MaxFrame;
public long FramesPointer;
public long DataPointer;
public long UnpackDataPointer;
}
/// <summary>
/// Packed 16-Bit Vector 3
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct PackedVector3
{
public ushort X;
public ushort Y;
public ushort Z;
}
/// <summary>
/// Vector 3 Decompressors, used by Translations and Scales
/// </summary>
private static DataDecompressorList Vector3Decompressors = new DataDecompressorList()
{
{ 0x00000, LoadVector3sFull },
{ 0x20000, LoadVector3s5Bit },
{ 0x30000, LoadVector3s10Bit },
{ 0x70000, LoadVector3s21Bit },
{ 0x31000, LoadVector3sXAxis },
{ 0x32000, LoadVector3sYAxis },
{ 0x33000, LoadVector3sZAxis },
{ 0x21000, LoadVector3sXAxis16Bit },
{ 0x22000, LoadVector3sYAxis16Bit },
{ 0x23000, LoadVector3sZAxis16Bit },
};
/// <summary>
/// Quaternion Decompressors, used by Rotations
/// </summary>
private static DataDecompressorList QuaternionDecompressors = new DataDecompressorList()
{
{ 0x00000, LoadQuaternionsFull },
{ 0xB0000, LoadQuaternions3Component },
{ 0x30000, LoadQuaternions10Bit },
{ 0x50000, LoadQuaternions16Bit },
{ 0x70000, LoadQuaternions21Bit },
{ 0x21000, LoadQuaternionsXAxis16Bit },
{ 0x22000, LoadQuaternionsYAxis16Bit },
{ 0x23000, LoadQuaternionsZAxis16Bit },
{ 0x31000, LoadQuaternionsXAxis },
{ 0x32000, LoadQuaternionsYAxis },
{ 0x33000, LoadQuaternionsZAxis },
};
/// <summary>
/// Loads Vector3s with all components
/// </summary>
private static void LoadVector3sFull(BinaryReader reader, Animation.Bone bone, int[] frames, float[] unpackData, long dataPointer)
{
var data = reader.ReadArray<Vector3>(dataPointer, frames.Length);
for (int i = 0; i < data.Length; i++)
{
var x = data[i].X;
var y = data[i].Y;
var z = data[i].Z;
bone.Translations[frames[i]] = new Vector3(x, y, z);
}
}
/// <summary>
/// Loads 5Bit Vector3s
/// </summary>
private static void LoadVector3s5Bit(BinaryReader reader, Animation.Bone bone, int[] frames, float[] unpackData, long dataPointer)
{
var data = reader.ReadArray<ushort>(dataPointer, frames.Length);
for (int i = 0; i < data.Length; i++)
{
var x = (unpackData[0] * ((data[i] >> 00) & 0x1F) / 31.0f) + unpackData[4];
var y = (unpackData[1] * ((data[i] >> 05) & 0x1F) / 31.0f) + unpackData[5];
var z = (unpackData[2] * ((data[i] >> 10) & 0x1F) / 31.0f) + unpackData[6];
bone.Translations[frames[i]] = new Vector3(x, y, z);
}
}
/// <summary>
/// Loads 10Bit Vector3s
/// </summary>
private static void LoadVector3s10Bit(BinaryReader reader, Animation.Bone bone, int[] frames, float[] unpackData, long dataPointer)
{
var data = reader.ReadArray<uint>(dataPointer, frames.Length);
for (int i = 0; i < data.Length; i++)
{
var x = (unpackData[0] * ((data[i] >> 00) & 0x3FF) / 1023.0f) + unpackData[4];
var y = (unpackData[1] * ((data[i] >> 10) & 0x3FF) / 1023.0f) + unpackData[5];
var z = (unpackData[2] * ((data[i] >> 20) & 0x3FF) / 1023.0f) + unpackData[6];
bone.Translations[frames[i]] = new Vector3(x, y, z);
}
}
/// <summary>
/// Loads 21Bit Vector3s
/// </summary>
private static void LoadVector3s21Bit(BinaryReader reader, Animation.Bone bone, int[] frames, float[] unpackData, long dataPointer)
{
var data = reader.ReadArray<ulong>(dataPointer, frames.Length);
for (int i = 0; i < data.Length; i++)
{
var x = (unpackData[0] * ((data[i] >> 00) & 0x1FFFFF) / 2097151.0f) + unpackData[4];
var y = (unpackData[1] * ((data[i] >> 21) & 0x1FFFFF) / 2097151.0f) + unpackData[5];
var z = (unpackData[2] * ((data[i] >> 42) & 0x1FFFFF) / 2097151.0f) + unpackData[6];
bone.Translations[frames[i]] = new Vector3(x, y, z);
}
}
/// <summary>
/// Loads Vector3s with 1 Component on X Axis
/// </summary>
private static void LoadVector3sXAxis(BinaryReader reader, Animation.Bone bone, int[] frames, float[] unpackData, long dataPointer)
{
var data = reader.ReadArray<float>(dataPointer, frames.Length);
for (int i = 0; i < data.Length; i++)
{
var x = data[i];
var y = unpackData[1];
var z = unpackData[2];
bone.Translations[frames[i]] = new Vector3(x, y, z);
}
}
/// <summary>
/// Loads Vector3s with 1 Component on Y Axis
/// </summary>
private static void LoadVector3sYAxis(BinaryReader reader, Animation.Bone bone, int[] frames, float[] unpackData, long dataPointer)
{
var data = reader.ReadArray<float>(dataPointer, frames.Length);
for (int i = 0; i < data.Length; i++)
{
var x = unpackData[0];
var y = data[i];
var z = unpackData[2];
bone.Translations[frames[i]] = new Vector3(x, y, z);
}
}
/// <summary>
/// Loads Vector3s with 1 Component on Z Axis
/// </summary>
private static void LoadVector3sZAxis(BinaryReader reader, Animation.Bone bone, int[] frames, float[] unpackData, long dataPointer)
{
var data = reader.ReadArray<float>(dataPointer, frames.Length);
for (int i = 0; i < data.Length; i++)
{
var x = unpackData[0];
var y = unpackData[1];
var z = data[i];
bone.Translations[frames[i]] = new Vector3(x, y, z);
}
}
/// <summary>
/// Loads Vector3s with 1 Component on X Axis
/// </summary>
private static void LoadVector3sXAxis16Bit(BinaryReader reader, Animation.Bone bone, int[] frames, float[] unpackData, long dataPointer)
{
var data = reader.ReadArray<ushort>(dataPointer, frames.Length);
for (int i = 0; i < data.Length; i++)
{
var x = unpackData[0] * (data[i] / 65535.0f) + unpackData[1];
var y = unpackData[2];
var z = unpackData[3];
bone.Translations[frames[i]] = new Vector3(x, y, z);
}
}
/// <summary>
/// Loads Vector3s with 1 Component on Y Axis
/// </summary>
private static void LoadVector3sYAxis16Bit(BinaryReader reader, Animation.Bone bone, int[] frames, float[] unpackData, long dataPointer)
{
var data = reader.ReadArray<ushort>(dataPointer, frames.Length);
for (int i = 0; i < data.Length; i++)
{
var x = unpackData[1];
var y = unpackData[0] * (data[i] / 65535.0f) + unpackData[2];
var z = unpackData[3];
bone.Translations[frames[i]] = new Vector3(x, y, z);
}
}
/// <summary>
/// Loads Vector3s with 1 Component on Y Axis
/// </summary>
private static void LoadVector3sZAxis16Bit(BinaryReader reader, Animation.Bone bone, int[] frames, float[] unpackData, long dataPointer)
{
var data = reader.ReadArray<ushort>(dataPointer, frames.Length);
for (int i = 0; i < data.Length; i++)
{
var x = unpackData[1];
var y = unpackData[2];
var z = unpackData[0] * (data[i] / 65535.0f) + unpackData[3];
bone.Translations[frames[i]] = new Vector3(x, y, z);
}
}
/// <summary>
/// Loads Quaternions with all components
/// </summary>
private static void LoadQuaternionsFull(BinaryReader reader, Animation.Bone bone, int[] frames, float[] unpackData, long dataPointer)
{
var data = reader.ReadArray<Quaternion>(dataPointer, frames.Length);
for (int i = 0; i < data.Length; i++)
{
var x = data[i].X;
var y = data[i].Y;
var z = data[i].Z;
var w = data[i].W;
bone.Rotations[frames[i]] = new Quaternion(x, y, z, w);
}
}
/// <summary>
/// Loads Quaternions with 3 Components
/// </summary>
private static void LoadQuaternions3Component(BinaryReader reader, Animation.Bone bone, int[] frames, float[] unpackData, long dataPointer)
{
var data = reader.ReadArray<Vector3>(dataPointer, frames.Length);
for (int i = 0; i < data.Length; i++)
{
var x = data[i].X;
var y = data[i].Y;
var z = data[i].Z;
var w = (float)Math.Sqrt(1 - x * x - y * y - z * z);
bone.Rotations[frames[i]] = new Quaternion(x, y, z, w);
}
}
/// <summary>
/// Loads 10Bit Quaternions
/// </summary>
private static void LoadQuaternions10Bit(BinaryReader reader, Animation.Bone bone, int[] frames, float[] unpackData, long dataPointer)
{
var data = reader.ReadArray<uint>(dataPointer, frames.Length);
for (int i = 0; i < data.Length; i++)
{
var x = (unpackData[0] * ((data[i] >> 00) & 0x3FF) / 1023.0f) + unpackData[4];
var y = (unpackData[1] * ((data[i] >> 10) & 0x3FF) / 1023.0f) + unpackData[5];
var z = (unpackData[2] * ((data[i] >> 20) & 0x3FF) / 1023.0f) + unpackData[6];
var w = (float)Math.Sqrt(1 - x * x - y * y - z * z);
bone.Rotations[frames[i]] = new Quaternion(x, y, z, w);
}
}
/// <summary>
/// Loads 10Bit Quaternions
/// </summary>
private static void LoadQuaternions16Bit(BinaryReader reader, Animation.Bone bone, int[] frames, float[] unpackData, long dataPointer)
{
var data = reader.ReadArray<PackedVector3>(dataPointer, frames.Length);
for (int i = 0; i < data.Length; i++)
{
var x = (unpackData[0] * (data[i].X / 65535.0f)) + unpackData[4];
var y = (unpackData[1] * (data[i].Y / 65535.0f)) + unpackData[5];
var z = (unpackData[2] * (data[i].Z / 65535.0f)) + unpackData[6];
var w = (float)Math.Sqrt(1 - x * x - y * y - z * z);
bone.Rotations[frames[i]] = new Quaternion(x, y, z, w);
}
}
/// <summary>
/// Loads 21Bit Quaternions
/// </summary>
private static void LoadQuaternions21Bit(BinaryReader reader, Animation.Bone bone, int[] frames, float[] unpackData, long dataPointer)
{
var data = reader.ReadArray<ulong>(dataPointer, frames.Length);
for (int i = 0; i < data.Length; i++)
{
var x = (unpackData[0] * ((data[i] >> 00) & 0x1FFFFF) / 2097151.0f) + unpackData[4];
var y = (unpackData[1] * ((data[i] >> 21) & 0x1FFFFF) / 2097151.0f) + unpackData[5];
var z = (unpackData[2] * ((data[i] >> 42) & 0x1FFFFF) / 2097151.0f) + unpackData[6];
var w = (float)Math.Sqrt(1 - x * x - y * y - z * z);
bone.Rotations[frames[i]] = new Quaternion(x, y, z, w);
}
}
/// <summary>
/// Loads Quaternions with 1 Component on X Axis
/// </summary>
private static void LoadQuaternionsXAxis(BinaryReader reader, Animation.Bone bone, int[] frames, float[] unpackData, long dataPointer)
{
var data = reader.ReadArray<float>(dataPointer, frames.Length);
for (int i = 0; i < data.Length; i++)
{
var x = data[i];
var y = 0.0f;
var z = 0.0f;
var w = (float)Math.Sqrt(1 - x * x - y * y - z * z);
bone.Rotations[frames[i]] = new Quaternion(x, y, z, w);
}
}
/// <summary>
/// Loads Quaternions with 1 Component on Y Axis
/// </summary>
private static void LoadQuaternionsYAxis(BinaryReader reader, Animation.Bone bone, int[] frames, float[] unpackData, long dataPointer)
{
var data = reader.ReadArray<float>(dataPointer, frames.Length);
for (int i = 0; i < data.Length; i++)
{
var x = 0.0f;
var y = data[i];
var z = 0.0f;
var w = (float)Math.Sqrt(1 - x * x - y * y - z * z);
bone.Rotations[frames[i]] = new Quaternion(x, y, z, w);
}
}
/// <summary>
/// Loads Quaternions with 1 Component on Z Axis
/// </summary>
private static void LoadQuaternionsZAxis(BinaryReader reader, Animation.Bone bone, int[] frames, float[] unpackData, long dataPointer)
{
var data = reader.ReadArray<float>(dataPointer, frames.Length);
for (int i = 0; i < data.Length; i++)
{
var x = 0.0f;
var y = 0.0f;
var z = data[i];
var w = (float)Math.Sqrt(1 - x * x - y * y - z * z);
bone.Rotations[frames[i]] = new Quaternion(x, y, z, w);
}
}
/// <summary>
/// Loads Quaternions with 1 Component on X Axis
/// </summary>
private static void LoadQuaternionsXAxis16Bit(BinaryReader reader, Animation.Bone bone, int[] frames, float[] unpackData, long dataPointer)
{
var data = reader.ReadArray<ushort>(dataPointer, frames.Length);
for (int i = 0; i < data.Length; i++)
{
var x = unpackData[0] * (data[i] / 65535.0f) + unpackData[1];
var y = 0.0f;
var z = 0.0f;
var w = (float)Math.Sqrt(1 - x * x - y * y - z * z);
bone.Rotations[frames[i]] = new Quaternion(x, y, z, w);
}
}
/// <summary>
/// Loads Quaternions with 1 Component on Y Axis
/// </summary>
private static void LoadQuaternionsYAxis16Bit(BinaryReader reader, Animation.Bone bone, int[] frames, float[] unpackData, long dataPointer)
{
var data = reader.ReadArray<ushort>(dataPointer, frames.Length);
for (int i = 0; i < data.Length; i++)
{
var x = 0.0f;
var y = unpackData[0] * (data[i] / 65535.0f) + unpackData[1];
var z = 0.0f;
var w = (float)Math.Sqrt(1 - x * x - y * y - z * z);
bone.Rotations[frames[i]] = new Quaternion(x, y, z, w);
}
}
/// <summary>
/// Loads Quaternions with 1 Component on Z Axis
/// </summary>
private static void LoadQuaternionsZAxis16Bit(BinaryReader reader, Animation.Bone bone, int[] frames, float[] unpackData, long dataPointer)
{
var data = reader.ReadArray<ushort>(dataPointer, frames.Length);
for (int i = 0; i < data.Length; i++)
{
var x = 0.0f;
var y = 0.0f;
var z = unpackData[0] * (data[i] / 65535.0f) + unpackData[1];
var w = (float)Math.Sqrt(1 - x * x - y * y - z * z);
bone.Rotations[frames[i]] = new Quaternion(x, y, z, w);
}
}
/// <summary>
/// Loads Frame Indices at the given offset of the given type
/// </summary>
private static int[] LoadFrames(BinaryReader reader, long framesPointer, int frameCount, uint frameDataType)
{
var results = new int[frameCount];
reader.BaseStream.Position = framesPointer;
switch (frameDataType)
{
case 0x200000:
{
for (int i = 0; i < frameCount; i++)
results[i] = reader.ReadByte();
break;
}
case 0x400000:
{
for (int i = 0; i < frameCount; i++)
results[i] = reader.ReadUInt16();
break;
}
case 0x500000:
{
for (int i = 0; i < frameCount; i++)
results[i] = reader.ReadInt32();
break;
}
default:
{
for (int i = 0; i < frameCount; i++)
results[i] = (int)reader.ReadSingle();
break;
}
}
return results;
}
/// <summary>
/// Converts an RE7 Motion File to a SEAnim
/// </summary>
private static Tuple<string, Animation> ConvertRE7(BinaryReader reader)
{
var animation = new Animation(Animation.DataType.Absolute);
var header = reader.ReadStruct<MotionHeaderRE7>();
var bones = new Dictionary<uint, Animation.Bone>(header.BoneCount);
// Check for bone base data (this is required, so if it doesn't exit, quit)
if (header.BoneBaseDataPointer > 0)
{
reader.BaseStream.Position = header.BoneBaseDataPointer;
var baseDataOffset = reader.ReadInt64();
var baseDataCount = reader.ReadInt32();
var size = Marshal.SizeOf<BoneBaseDataRE7>();
var boneBaseData = reader.ReadArray<BoneBaseDataRE7>(baseDataOffset, baseDataCount);
foreach (var boneBase in boneBaseData)
{
var bone = new Animation.Bone(reader.ReadUTF16NullTerminatedString(boneBase.NamePointer));
bone.Translations[0] = boneBase.Translation.ToVector3();
bone.Rotations[0] = boneBase.Rotation;
bones[boneBase.Hash] = bone;
}
if (header.BoneDataPointer > 0)
{
var boneData = reader.ReadArray<BoneDataRE7>(header.BoneDataPointer, header.BoneDataCount);
foreach (var bone in boneData)
{
var keyDataOffset = bone.KeysPointer;
if (bone.Flags.HasFlag(DataPrecenseFlags.Translations))
{
var keyData = reader.ReadStruct<KeyDataRE7>(keyDataOffset);
float[] unpackData = null;
uint keyFrameDataType = keyData.Flags & 0xF00000;
uint compression = keyData.Flags & 0xFF000;
uint unkFlag = keyData.Flags & 0xFFF;
if (keyData.UnpackDataPointer > 0)
unpackData = reader.ReadArray<float>(keyData.UnpackDataPointer, 8);
var keyFrames = LoadFrames(reader, keyData.FramesPointer, keyData.KeyCount, keyFrameDataType);
if (Vector3Decompressors.TryGetValue(compression, out var decompressionMethod))
decompressionMethod(reader, bones[bone.BoneHash], keyFrames, unpackData, keyData.DataPointer);
else
throw new Exception(string.Format("Unknown Vector3 compression type: 0x{0:X}", compression));
keyDataOffset += Marshal.SizeOf<KeyDataRE7>();
}
if (bone.Flags.HasFlag(DataPrecenseFlags.Rotations))
{
var keyData = reader.ReadStruct<KeyDataRE7>(keyDataOffset);
float[] unpackData = null;
uint keyFrameDataType = keyData.Flags & 0xF00000;
uint compression = keyData.Flags & 0xFF000;
uint unkFlag = keyData.Flags & 0xFFF;
if (keyData.UnpackDataPointer > 0)
unpackData = reader.ReadArray<float>(keyData.UnpackDataPointer, 8);
var keyFrames = LoadFrames(reader, keyData.FramesPointer, keyData.KeyCount, keyFrameDataType);
if (QuaternionDecompressors.TryGetValue(compression, out var decompressionMethod))
decompressionMethod(reader, bones[bone.BoneHash], keyFrames, unpackData, keyData.DataPointer);
else
throw new Exception(string.Format("Unknown Quaternion compression type: 0x{0:X}", compression));
keyDataOffset += Marshal.SizeOf<KeyDataRE7>();
}
animation.Bones.Add(bones[bone.BoneHash]);
}
}
}
return new Tuple<string, Animation>(reader.ReadUTF16NullTerminatedString(header.NamePointer), animation);
}
/// <summary>
/// Converts an RE2 Motion File to a SEAnim
/// </summary>
private static Tuple<string, Animation> ConvertRE2(BinaryReader reader)
{
var animation = new Animation(Animation.DataType.Absolute);
var header = reader.ReadStruct<MotionHeaderRE2>();
var bones = new Dictionary<uint, Animation.Bone>(header.BoneCount);
var name = reader.ReadUTF16NullTerminatedString(header.NamePointer);
// Check for bone base data (this is required, so if it doesn't exit, quit)
if (header.BoneBaseDataPointer > 0)
{
reader.BaseStream.Position = header.BoneBaseDataPointer;
var baseDataOffset = reader.ReadInt64();
var baseDataCount = reader.ReadInt32();
var size = Marshal.SizeOf<BoneBaseDataRE7>();
var boneBaseData = reader.ReadArray<BoneBaseDataRE7>(baseDataOffset, baseDataCount);
foreach (var boneBase in boneBaseData)
{
var bone = new Animation.Bone(reader.ReadUTF16NullTerminatedString(boneBase.NamePointer));
bone.Translations[0] = boneBase.Translation.ToVector3();
bone.Rotations[0] = boneBase.Rotation;
bones[boneBase.Hash] = bone;
}
if (header.BoneDataPointer > 0)
{
var boneData = reader.ReadArray<BoneDataRE2>(header.BoneDataPointer, header.BoneDataCount);
foreach (var bone in boneData)
{
var keyDataOffset = bone.KeysPointer;
if (bone.Flags.HasFlag(DataPrecenseFlags.Translations))
{
var keyData = reader.ReadStruct<KeyDataRE7>(keyDataOffset);
float[] unpackData = null;
uint keyFrameDataType = keyData.Flags & 0xF00000;
uint compression = keyData.Flags & 0xFF000;
uint unkFlag = keyData.Flags & 0xFFF;
if (keyData.UnpackDataPointer > 0)
unpackData = reader.ReadArray<float>(keyData.UnpackDataPointer, 8);
var keyFrames = LoadFrames(reader, keyData.FramesPointer, keyData.KeyCount, keyFrameDataType);
if (Vector3Decompressors.TryGetValue(compression, out var decompressionMethod))
decompressionMethod(reader, bones[bone.BoneHash], keyFrames, unpackData, keyData.DataPointer);
else
throw new Exception(string.Format("Unknown Vector3 compression type: 0x{0:X}", compression));
keyDataOffset += Marshal.SizeOf<KeyDataRE7>();
}
if (bone.Flags.HasFlag(DataPrecenseFlags.Rotations))
{
var keyData = reader.ReadStruct<KeyDataRE7>(keyDataOffset);
float[] unpackData = null;
uint keyFrameDataType = keyData.Flags & 0xF00000;
uint compression = keyData.Flags & 0xFF000;
uint unkFlag = keyData.Flags & 0xFFF;
if (keyData.UnpackDataPointer > 0)
unpackData = reader.ReadArray<float>(keyData.UnpackDataPointer, 8);
var keyFrames = LoadFrames(reader, keyData.FramesPointer, keyData.KeyCount, keyFrameDataType);
if (QuaternionDecompressors.TryGetValue(compression, out var decompressionMethod))
decompressionMethod(reader, bones[bone.BoneHash], keyFrames, unpackData, keyData.DataPointer);
else
throw new Exception(string.Format("Unknown Quaternion compression type: 0x{0:X}", compression));
keyDataOffset += Marshal.SizeOf<KeyDataRE7>();
}
animation.Bones.Add(bones[bone.BoneHash]);
}
}
}
return new Tuple<string, Animation>(reader.ReadUTF16NullTerminatedString(header.NamePointer), animation);
}
/// <summary>
/// Converts the given Motion
/// </summary>
public static Tuple<string, Animation> Convert(Stream stream)
{
using (var reader = new BinaryReader(stream))
{
var version = reader.ReadUInt32();
reader.BaseStream.Position = 0;
switch (version)
{
case 0x2B: return ConvertRE7(reader);
case 0x41: return ConvertRE2(reader);
default: throw new Exception("Invalid Motion Version");
}
}
}
}
}

View file

@ -0,0 +1,162 @@
// ------------------------------------------------------------------------
// Tyrant - RE Engine Extractor
// Copyright (C) 2018 Philip/Scobalula
//
// 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/>.
// ------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using PhilLibX;
using PhilLibX.IO;
namespace Tyrant.Logic
{
/// <summary>
/// Structs and Logic for Extracting Motion List Files
/// </summary>
public class MotionList
{
/// <summary>
/// Resident Evil 7 Motion List Header
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct MotionListHeaderRE7
{
public uint Version;
public uint Magic;
public long Padding;
public long AssetsPointer;
public long UnkPointer;
public long NamePointer;
public int AssetCount;
}
/// <summary>
/// Resident Evil 2 Motion List Header
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct MotionListHeaderRE2
{
public uint Version;
public uint Magic;
public long Padding;
public long AssetsPointer;
public long UnkPointer;
public long NamePointer;
public long UnkPointer01;
public int AssetCount;
}
/// <summary>
/// Loads Motions from a Resident Evil 7 Motion List
/// </summary>
private static Tuple<string, List<Tuple<string, Animation>>> ConvertRE7(BinaryReader reader)
{
var header = reader.ReadStruct<MotionListHeaderRE7>();
var results = new List<Tuple<string, Animation>>();
// Sort by offsets since they don't store sizes, we also need to remove dupes as some entries point to another
var offsets = reader.ReadArray<long>(header.AssetsPointer, header.AssetCount).Distinct().OrderBy(x => x).ToArray();
for (int i = 0; i < offsets.Length; i++)
{
// Determine if this is a motion file, since lists can contain other misc. anim data
reader.BaseStream.Position = offsets[i];
var version = reader.ReadUInt32();
var magic = reader.ReadUInt32();
if (magic != 0x20746F6D)
continue;
// Use the next or end to get size
var endOffset = i == offsets.Length - 1 ? reader.BaseStream.Length : offsets[i + 1];
reader.BaseStream.Position = offsets[i];
using (var stream = new MemoryStream(reader.ReadBytes((int)(endOffset - offsets[i]))))
{
results.Add(Motion.Convert(stream));
}
}
return new Tuple<string, List<Tuple<string, Animation>>>(reader.ReadUTF16NullTerminatedString(header.NamePointer), results);
}
/// <summary>
/// Loads Motions from a Resident Evil 2 Motion List
/// </summary>
private static Tuple<string, List<Tuple<string, Animation>>> ConvertRE2(BinaryReader reader)
{
var header = reader.ReadStruct<MotionListHeaderRE2>();
var results = new List<Tuple<string, Animation>>();
// Sort by offsets since they don't store sizes, we also need to remove dupes as some entries point to another
var offsets = reader.ReadArray<long>(header.AssetsPointer, header.AssetCount).Distinct().OrderBy(x => x).ToArray();
for (int i = 0; i < offsets.Length; i++)
{
// Determine if this is a motion file, since lists can contain other misc. anim data
reader.BaseStream.Position = offsets[i];
var version = reader.ReadUInt32();
var magic = reader.ReadUInt32();
if (magic != 0x20746F6D)
continue;
// Use the next or end to get size
var endOffset = i == offsets.Length - 1 ? reader.BaseStream.Length : offsets[i + 1];
reader.BaseStream.Position = offsets[i];
using (var stream = new MemoryStream(reader.ReadBytes((int)(endOffset - offsets[i]))))
{
results.Add(Motion.Convert(stream));
}
}
return new Tuple<string, List<Tuple<string, Animation>>>(reader.ReadUTF16NullTerminatedString(header.NamePointer), results);
}
/// <summary>
/// Converts Motions from the given Motion List
/// </summary>
public static Tuple<string, List<Tuple<string, Animation>>> Convert(byte[] buffer)
{
using (var stream = new MemoryStream(buffer))
return Convert(stream);
}
/// <summary>
/// Converts Motions from the given Motion List
/// </summary>
public static Tuple<string, List<Tuple<string, Animation>>> Convert(Stream stream)
{
using (var reader = new BinaryReader(stream))
{
var version = reader.ReadUInt32();
reader.BaseStream.Position = 0;
switch (version)
{
case 0x3C: return ConvertRE7(reader);
case 0x55: return ConvertRE2(reader);
default: throw new Exception("Invalid Motion List Version");
}
}
}
}
}

View file

@ -0,0 +1,86 @@
// ------------------------------------------------------------------------
// Tyrant - RE Engine Extractor
// Copyright (C) 2018 Philip/Scobalula
//
// 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/>.
// ------------------------------------------------------------------------
using PhilLibX.Compression;
using PhilLibX.IO;
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
namespace Tyrant.Logic
{
/// <summary>
/// Structs and Logic for Extracting Wwise Banks
/// </summary>
public static class SoundBank
{
private static object ConvertWwise(BinaryReader reader)
{
return null;
}
private static object ConvertPCK(BinaryReader reader)
{
// Skip name and header
reader.BaseStream.Position = 32;
var nameSize = reader.ReadInt64();
var name = reader.ReadUTF16NullTerminatedString();
var entries = reader.ReadInt32();
Directory.CreateDirectory("Files");
reader.BaseStream.Position = 40 + nameSize;
var tableOffset = 40 + nameSize;
for (int i = 0; i < entries; i++)
{
reader.BaseStream.Position = tableOffset + i * 20;
var entryID = reader.ReadUInt32();
var unk = reader.ReadUInt32();
var size = reader.ReadInt32();
var offset = reader.ReadInt64();
reader.BaseStream.Position = offset;
Console.WriteLine(entryID);
File.WriteAllBytes("Files\\" + entryID.ToString("X") + ".wav", reader.ReadBytes(size));
}
return null;
}
public static object Convert(Stream stream)
{
// Determine if this is a PCK or BNK file
using (var reader = new BinaryReader(stream))
{
var magic = reader.ReadUInt32();
switch(magic)
{
case 0x4B504B41: return ConvertPCK(reader);
default: throw new Exception("Invalid Sound Bank Magic");
}
}
}
}
}

View file

@ -0,0 +1,108 @@
// ------------------------------------------------------------------------
// Tyrant - RE Engine Extractor
// Copyright (C) 2018 Philip/Scobalula
//
// 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/>.
// ------------------------------------------------------------------------
using PhilLibX.Imaging;
using PhilLibX.IO;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
namespace Tyrant.Logic
{
/// <summary>
/// Structs and Logic for Extracting Texture Files
/// </summary>
public static class Texture
{
/// <summary>
/// Resident Evil 7 Texture Header
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct TextureHeaderRE7
{
public int Magic;
public int Version;
public ushort Width;
public short Height;
public ushort Depth;
public byte MipMapCount;
public byte Unknown1;
public ScratchImage.DXGIFormat Format;
public uint Unknown2;
public long Padding;
}
/// <summary>
/// Resident Evil 7 Mip Map
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct MipMapRE7
{
public long Offset;
public int Unkown; // (Mip Width * 2) + (Mip Height * 2)
public int Size;
}
/// <summary>
/// Converts the given Texture
/// </summary>
public static ScratchImage Convert(byte[] buffer)
{
using (var stream = new MemoryStream(buffer))
{
return Convert(stream);
}
}
/// <summary>
/// Converts the given Texture
/// </summary>
public static ScratchImage Convert(Stream stream)
{
using (var reader = new BinaryReader(stream))
{
// Only grab the highest mip
var header = reader.ReadStruct<TextureHeaderRE7>();
var mip = reader.ReadArray<MipMapRE7>(header.MipMapCount).OrderBy(x => x.Size).ToArray()[header.MipMapCount - 1];
reader.BaseStream.Position = mip.Offset;
// Switch SRGB
switch(header.Format)
{
case ScratchImage.DXGIFormat.BC7UNORMSRGB: header.Format = ScratchImage.DXGIFormat.BC7UNORM; break;
case ScratchImage.DXGIFormat.BC3UNORMSRGB: header.Format = ScratchImage.DXGIFormat.BC3UNORM; break;
case ScratchImage.DXGIFormat.BC2UNORMSRGB: header.Format = ScratchImage.DXGIFormat.BC2UNORM; break;
case ScratchImage.DXGIFormat.BC1UNORMSRGB: header.Format = ScratchImage.DXGIFormat.BC1UNORM; break;
}
return new ScratchImage(new ScratchImage.TexMetadata()
{
Width = header.Width,
Height = header.Height,
Depth = 1,
ArraySize = 1,
MiscFlags = ScratchImage.TexMiscFlags.NONE,
MiscFlags2 = ScratchImage.TexMiscFlags2.NONE,
Dimension = ScratchImage.TexDimension.TEXTURE2D,
MipLevels = 1,
Format = header.Format
}, reader.ReadBytes(mip.Size));
}
}
}
}

View file

@ -0,0 +1,147 @@
// ------------------------------------------------------------------------
// Tyrant - RE Engine Extractor
// Copyright (C) 2018 Philip/Scobalula
//
// 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/>.
// ------------------------------------------------------------------------
using PhilLibX.Compression;
using PhilLibX.IO;
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
namespace Tyrant.Logic
{
/// <summary>
/// A class to hold and process RE Engine Package File
/// </summary>
public class Package : IDisposable
{
/// <summary>
/// Package File Entry
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct Entry
{
/// <summary>
/// Gets or Sets the lower case hash
/// </summary>
public uint LowerCaseHash { get; set; }
/// <summary>
/// Gets or Sets the upper case hash
/// </summary>
public uint UpperCaseHash { get; set; }
/// <summary>
/// Gets or Sets the offset of the data
/// </summary>
public long Offset { get; set; }
/// <summary>
/// Gets or Sets the compressed size
/// </summary>
public long CompressedSize { get; set; }
/// <summary>
/// Gets or Sets the decompressed size
/// </summary>
public long DecompressedSize { get; set; }
/// <summary>
/// Gets or Sets the Flags
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x8)]
public byte[] Flags;
/// <summary>
/// Gets or Sets the Checksum
/// </summary>
public long Checksum { get; set; }
}
/// <summary>
/// Gets or Sets the File Reader
/// </summary>
private BinaryReader Reader { get; set; }
/// <summary>
/// Gets or Sets the Entries
/// </summary>
public Dictionary<uint, Entry> Entries { get; set; }
/// <summary>
/// Creates a new Package File and loads from the given file
/// </summary>
public Package(string filePath)
{
Reader = new BinaryReader(File.OpenRead(filePath));
var magic = Reader.ReadUInt32();
var version = Reader.ReadUInt32();
var count = Reader.ReadInt32();
var checksum = Reader.ReadUInt32();
if (magic != 0x414B504B)
throw new Exception("Invalid Package Magic");
Entries = new Dictionary<uint, Entry>();
switch (version)
{
case 0x4:
{
var entries = Reader.ReadArray<Entry>(count);
foreach (var entry in entries)
Entries[entry.LowerCaseHash] = entry;
break;
}
default:
throw new Exception("Invalid Package Version");
}
}
/// <summary>
/// Loads the data for the given entry
/// </summary>
public byte[] LoadEntry(Entry entry)
{
lock(Reader)
{
Reader.BaseStream.Position = entry.Offset;
switch (entry.Flags[0] & 0x0F)
{
case 0:
return Reader.ReadBytes((int)entry.CompressedSize);
case 1:
return ZLIB.Decompress(Reader.ReadBytes((int)entry.CompressedSize), -15);
case 2:
return ZStandard.Decompress(Reader.ReadBytes((int)entry.CompressedSize));
default:
throw new Exception("Invalid Entry Compression");
}
}
}
/// <summary>
/// Disposes of the File Reader
/// </summary>
public void Dispose()
{
Reader?.Dispose();
}
}
}

View file

@ -0,0 +1,158 @@
// ------------------------------------------------------------------------
// Tyrant - RE Engine Extractor
// Copyright (C) 2018 Philip/Scobalula
//
// 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/>.
// ------------------------------------------------------------------------
using PhilLibX.Compression;
using PhilLibX.IO;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
namespace Tyrant.Logic
{
/// <summary>
/// A class to hold a Name Cache
/// </summary>
public class NameCache
{
/// <summary>
/// Gets or Sets the Entries/Names
/// </summary>
public Dictionary<ulong, string> Entries { get; set; }
/// <summary>
/// Creates a new name cache
/// </summary>
public NameCache()
{
Entries = new Dictionary<ulong, string>();
}
/// <summary>
/// Loads entries from all files in the given folder
/// </summary>
/// <param name="folder">Folder to load from</param>
public void LoadFolder(string folder)
{
try
{
foreach (var file in Directory.EnumerateFiles(folder, "*.*"))
{
if (Path.GetExtension(file) == ".tcache")
LoadBinary(file);
else if (Path.GetExtension(file) == ".tcache_ascii")
LoadASCII(file);
}
}
catch { }
}
/// <summary>
/// Loads entries from a binary file
/// </summary>
/// <param name="fileName">File to load from</param>
public void LoadBinary(string fileName)
{
try
{
using (var fileReader = new BinaryReader(File.OpenRead(fileName)))
{
var magic = fileReader.ReadUInt64();
var compression = fileReader.ReadUInt64();
var compressedSize = fileReader.ReadInt64();
var decompressedSize = fileReader.ReadInt64();
byte[] buffer = null;
switch(compression)
{
case 0: buffer = fileReader.ReadBytes((int)compressedSize); break;
case 1: buffer = ZLIB.Decompress(fileReader.ReadBytes((int)compressedSize)); break;
case 2: buffer = ZStandard.Decompress(fileReader.ReadBytes((int)compressedSize)); break;
case 3: buffer = LZ4.Decompress(fileReader.ReadBytes((int)compressedSize), (int)decompressedSize); break;
default: throw new Exception("Invalid cache compression");
}
using (var reader = new BinaryReader(new MemoryStream(buffer)))
{
var count = (int)reader.ReadUInt64();
switch (magic)
{
// 32Bit Cache
case 0x3130454843414354:
{
for(int i = 0; i < count; i++)
Entries[reader.ReadUInt32()] = reader.ReadNullTerminatedString();
break;
}
// 64Bit Cache
case 0x3230454843414354:
{
for (int i = 0; i < count; i++)
Entries[reader.ReadUInt64()] = reader.ReadNullTerminatedString();
break;
}
}
}
}
}
#if DEBUG
catch(Exception e)
{
Console.WriteLine("Failed to load {0}: {1}", fileName, e);
}
#else
catch { }
#endif
}
/// <summary>
/// Loads entries from an ASCII/Plain Text file
/// </summary>
/// <param name="fileName">File to load from</param>
public void LoadASCII(string fileName)
{
try
{
foreach(var line in File.ReadLines(fileName))
{
var lineSplit = line.Trim().Split(',');
if(lineSplit.Length >= 2)
{
if (ulong.TryParse(lineSplit[0], NumberStyles.HexNumber, CultureInfo.CurrentCulture, out ulong id))
{
Entries[id] = lineSplit[1];
}
}
}
}
#if DEBUG
catch (Exception e)
{
Console.WriteLine("Failed to load {0}: {1}", fileName, e);
}
#else
catch { }
#endif
}
}
}

View file

@ -0,0 +1,885 @@
using System.Diagnostics;
using System.Globalization;
using System.Runtime.InteropServices;
namespace System
{
/// <summary>
/// Represents a half-precision floating point number.
/// </summary>
/// <remarks>
/// Note:
/// Half is not fast enought and precision is also very bad,
/// so is should not be used for matemathical computation (use Single instead).
/// The main advantage of Half type is lower memory cost: two bytes per number.
/// Half is typically used in graphical applications.
///
/// Note:
/// All functions, where is used conversion half->float/float->half,
/// are approx. ten times slower than float->double/double->float, i.e. ~3ns on 2GHz CPU.
///
/// References:
/// - Fast Half Float Conversions, Jeroen van der Zijp, link: http://www.fox-toolkit.org/ftp/fasthalffloatconversion.pdf
/// - IEEE 754 revision, link: http://grouper.ieee.org/groups/754/
/// </remarks>
[Serializable]
public struct Half : IComparable, IFormattable, IConvertible, IComparable<Half>, IEquatable<Half>
{
/// <summary>
/// Internal representation of the half-precision floating-point number.
/// </summary>
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
internal ushort value;
#region Constants
/// <summary>
/// Represents the smallest positive System.Half value greater than zero. This field is constant.
/// </summary>
public static readonly Half Epsilon = ToHalf(0x0001);
/// <summary>
/// Represents the largest possible value of System.Half. This field is constant.
/// </summary>
public static readonly Half MaxValue = ToHalf(0x7bff);
/// <summary>
/// Represents the smallest possible value of System.Half. This field is constant.
/// </summary>
public static readonly Half MinValue = ToHalf(0xfbff);
/// <summary>
/// Represents not a number (NaN). This field is constant.
/// </summary>
public static readonly Half NaN = ToHalf(0xfe00);
/// <summary>
/// Represents negative infinity. This field is constant.
/// </summary>
public static readonly Half NegativeInfinity = ToHalf(0xfc00);
/// <summary>
/// Represents positive infinity. This field is constant.
/// </summary>
public static readonly Half PositiveInfinity = ToHalf(0x7c00);
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of System.Half to the value of the specified single-precision floating-point number.
/// </summary>
/// <param name="value">The value to represent as a System.Half.</param>
public Half(float value) { this = HalfHelper.SingleToHalf(value); }
/// <summary>
/// Initializes a new instance of System.Half to the value of the specified 32-bit signed integer.
/// </summary>
/// <param name="value">The value to represent as a System.Half.</param>
public Half(int value) : this((float)value) { }
/// <summary>
/// Initializes a new instance of System.Half to the value of the specified 64-bit signed integer.
/// </summary>
/// <param name="value">The value to represent as a System.Half.</param>
public Half(long value) : this((float)value) { }
/// <summary>
/// Initializes a new instance of System.Half to the value of the specified double-precision floating-point number.
/// </summary>
/// <param name="value">The value to represent as a System.Half.</param>
public Half(double value) : this((float)value) { }
/// <summary>
/// Initializes a new instance of System.Half to the value of the specified decimal number.
/// </summary>
/// <param name="value">The value to represent as a System.Half.</param>
public Half(decimal value) : this((float)value) { }
/// <summary>
/// Initializes a new instance of System.Half to the value of the specified 32-bit unsigned integer.
/// </summary>
/// <param name="value">The value to represent as a System.Half.</param>
public Half(uint value) : this((float)value) { }
/// <summary>
/// Initializes a new instance of System.Half to the value of the specified 64-bit unsigned integer.
/// </summary>
/// <param name="value">The value to represent as a System.Half.</param>
public Half(ulong value) : this((float)value) { }
#endregion
#region Numeric operators
/// <summary>
/// Returns the result of multiplying the specified System.Half value by negative one.
/// </summary>
/// <param name="half">A System.Half.</param>
/// <returns>A System.Half with the value of half, but the opposite sign. -or- Zero, if half is zero.</returns>
public static Half Negate(Half half) { return -half; }
/// <summary>
/// Adds two specified System.Half values.
/// </summary>
/// <param name="half1">A System.Half.</param>
/// <param name="half2">A System.Half.</param>
/// <returns>A System.Half value that is the sum of half1 and half2.</returns>
public static Half Add(Half half1, Half half2) { return half1 + half2; }
/// <summary>
/// Subtracts one specified System.Half value from another.
/// </summary>
/// <param name="half1">A System.Half (the minuend).</param>
/// <param name="half2">A System.Half (the subtrahend).</param>
/// <returns>The System.Half result of subtracting half2 from half1.</returns>
public static Half Subtract(Half half1, Half half2) { return half1 - half2; }
/// <summary>
/// Multiplies two specified System.Half values.
/// </summary>
/// <param name="half1">A System.Half (the multiplicand).</param>
/// <param name="half2">A System.Half (the multiplier).</param>
/// <returns>A System.Half that is the result of multiplying half1 and half2.</returns>
public static Half Multiply(Half half1, Half half2) { return half1 * half2; }
/// <summary>
/// Divides two specified System.Half values.
/// </summary>
/// <param name="half1">A System.Half (the dividend).</param>
/// <param name="half2">A System.Half (the divisor).</param>
/// <returns>The System.Half that is the result of dividing half1 by half2.</returns>
/// <exception cref="System.DivideByZeroException">half2 is zero.</exception>
public static Half Divide(Half half1, Half half2) { return half1 / half2; }
/// <summary>
/// Returns the value of the System.Half operand (the sign of the operand is unchanged).
/// </summary>
/// <param name="half">The System.Half operand.</param>
/// <returns>The value of the operand, half.</returns>
public static Half operator +(Half half) { return half; }
/// <summary>
/// Negates the value of the specified System.Half operand.
/// </summary>
/// <param name="half">The System.Half operand.</param>
/// <returns>The result of half multiplied by negative one (-1).</returns>
public static Half operator -(Half half) { return HalfHelper.Negate(half); }
/// <summary>
/// Increments the System.Half operand by 1.
/// </summary>
/// <param name="half">The System.Half operand.</param>
/// <returns>The value of half incremented by 1.</returns>
public static Half operator ++(Half half) { return (Half)(half + 1f); }
/// <summary>
/// Decrements the System.Half operand by one.
/// </summary>
/// <param name="half">The System.Half operand.</param>
/// <returns>The value of half decremented by 1.</returns>
public static Half operator --(Half half) { return (Half)(half - 1f); }
/// <summary>
/// Adds two specified System.Half values.
/// </summary>
/// <param name="half1">A System.Half.</param>
/// <param name="half2">A System.Half.</param>
/// <returns>The System.Half result of adding half1 and half2.</returns>
public static Half operator +(Half half1, Half half2) { return (Half)((float)half1 + (float)half2); }
/// <summary>
/// Subtracts two specified System.Half values.
/// </summary>
/// <param name="half1">A System.Half.</param>
/// <param name="half2">A System.Half.</param>
/// <returns>The System.Half result of subtracting half1 and half2.</returns>
public static Half operator -(Half half1, Half half2) { return (Half)((float)half1 - (float)half2); }
/// <summary>
/// Multiplies two specified System.Half values.
/// </summary>
/// <param name="half1">A System.Half.</param>
/// <param name="half2">A System.Half.</param>
/// <returns>The System.Half result of multiplying half1 by half2.</returns>
public static Half operator *(Half half1, Half half2) { return (Half)((float)half1 * (float)half2); }
/// <summary>
/// Divides two specified System.Half values.
/// </summary>
/// <param name="half1">A System.Half (the dividend).</param>
/// <param name="half2">A System.Half (the divisor).</param>
/// <returns>The System.Half result of half1 by half2.</returns>
public static Half operator /(Half half1, Half half2) { return (Half)((float)half1 / (float)half2); }
/// <summary>
/// Returns a value indicating whether two instances of System.Half are equal.
/// </summary>
/// <param name="half1">A System.Half.</param>
/// <param name="half2">A System.Half.</param>
/// <returns>true if half1 and half2 are equal; otherwise, false.</returns>
public static bool operator ==(Half half1, Half half2) { return (!IsNaN(half1) && (half1.value == half2.value)); }
/// <summary>
/// Returns a value indicating whether two instances of System.Half are not equal.
/// </summary>
/// <param name="half1">A System.Half.</param>
/// <param name="half2">A System.Half.</param>
/// <returns>true if half1 and half2 are not equal; otherwise, false.</returns>
public static bool operator !=(Half half1, Half half2) { return !(half1.value == half2.value); }
/// <summary>
/// Returns a value indicating whether a specified System.Half is less than another specified System.Half.
/// </summary>
/// <param name="half1">A System.Half.</param>
/// <param name="half2">A System.Half.</param>
/// <returns>true if half1 is less than half1; otherwise, false.</returns>
public static bool operator <(Half half1, Half half2) { return (float)half1 < (float)half2; }
/// <summary>
/// Returns a value indicating whether a specified System.Half is greater than another specified System.Half.
/// </summary>
/// <param name="half1">A System.Half.</param>
/// <param name="half2">A System.Half.</param>
/// <returns>true if half1 is greater than half2; otherwise, false.</returns>
public static bool operator >(Half half1, Half half2) { return (float)half1 > (float)half2; }
/// <summary>
/// Returns a value indicating whether a specified System.Half is less than or equal to another specified System.Half.
/// </summary>
/// <param name="half1">A System.Half.</param>
/// <param name="half2">A System.Half.</param>
/// <returns>true if half1 is less than or equal to half2; otherwise, false.</returns>
public static bool operator <=(Half half1, Half half2) { return (half1 == half2) || (half1 < half2); }
/// <summary>
/// Returns a value indicating whether a specified System.Half is greater than or equal to another specified System.Half.
/// </summary>
/// <param name="half1">A System.Half.</param>
/// <param name="half2">A System.Half.</param>
/// <returns>true if half1 is greater than or equal to half2; otherwise, false.</returns>
public static bool operator >=(Half half1, Half half2) { return (half1 == half2) || (half1 > half2); }
#endregion
#region Type casting operators
/// <summary>
/// Converts an 8-bit unsigned integer to a System.Half.
/// </summary>
/// <param name="value">An 8-bit unsigned integer.</param>
/// <returns>A System.Half that represents the converted 8-bit unsigned integer.</returns>
public static implicit operator Half(byte value) { return new Half((float)value); }
/// <summary>
/// Converts a 16-bit signed integer to a System.Half.
/// </summary>
/// <param name="value">A 16-bit signed integer.</param>
/// <returns>A System.Half that represents the converted 16-bit signed integer.</returns>
public static implicit operator Half(short value) { return new Half((float)value); }
/// <summary>
/// Converts a Unicode character to a System.Half.
/// </summary>
/// <param name="value">A Unicode character.</param>
/// <returns>A System.Half that represents the converted Unicode character.</returns>
public static implicit operator Half(char value) { return new Half((float)value); }
/// <summary>
/// Converts a 32-bit signed integer to a System.Half.
/// </summary>
/// <param name="value">A 32-bit signed integer.</param>
/// <returns>A System.Half that represents the converted 32-bit signed integer.</returns>
public static implicit operator Half(int value) { return new Half((float)value); }
/// <summary>
/// Converts a 64-bit signed integer to a System.Half.
/// </summary>
/// <param name="value">A 64-bit signed integer.</param>
/// <returns>A System.Half that represents the converted 64-bit signed integer.</returns>
public static implicit operator Half(long value) { return new Half((float)value); }
/// <summary>
/// Converts a single-precision floating-point number to a System.Half.
/// </summary>
/// <param name="value">A single-precision floating-point number.</param>
/// <returns>A System.Half that represents the converted single-precision floating point number.</returns>
public static explicit operator Half(float value) { return new Half((float)value); }
/// <summary>
/// Converts a double-precision floating-point number to a System.Half.
/// </summary>
/// <param name="value">A double-precision floating-point number.</param>
/// <returns>A System.Half that represents the converted double-precision floating point number.</returns>
public static explicit operator Half(double value) { return new Half((float)value); }
/// <summary>
/// Converts a decimal number to a System.Half.
/// </summary>
/// <param name="value">decimal number</param>
/// <returns>A System.Half that represents the converted decimal number.</returns>
public static explicit operator Half(decimal value) { return new Half((float)value); }
/// <summary>
/// Converts a System.Half to an 8-bit unsigned integer.
/// </summary>
/// <param name="value">A System.Half to convert.</param>
/// <returns>An 8-bit unsigned integer that represents the converted System.Half.</returns>
public static explicit operator byte(Half value) { return (byte)(float)value; }
/// <summary>
/// Converts a System.Half to a Unicode character.
/// </summary>
/// <param name="value">A System.Half to convert.</param>
/// <returns>A Unicode character that represents the converted System.Half.</returns>
public static explicit operator char(Half value) { return (char)(float)value; }
/// <summary>
/// Converts a System.Half to a 16-bit signed integer.
/// </summary>
/// <param name="value">A System.Half to convert.</param>
/// <returns>A 16-bit signed integer that represents the converted System.Half.</returns>
public static explicit operator short(Half value) { return (short)(float)value; }
/// <summary>
/// Converts a System.Half to a 32-bit signed integer.
/// </summary>
/// <param name="value">A System.Half to convert.</param>
/// <returns>A 32-bit signed integer that represents the converted System.Half.</returns>
public static explicit operator int(Half value) { return (int)(float)value; }
/// <summary>
/// Converts a System.Half to a 64-bit signed integer.
/// </summary>
/// <param name="value">A System.Half to convert.</param>
/// <returns>A 64-bit signed integer that represents the converted System.Half.</returns>
public static explicit operator long(Half value) { return (long)(float)value; }
/// <summary>
/// Converts a System.Half to a single-precision floating-point number.
/// </summary>
/// <param name="value">A System.Half to convert.</param>
/// <returns>A single-precision floating-point number that represents the converted System.Half.</returns>
public static implicit operator float(Half value) { return (float)HalfHelper.HalfToSingle(value); }
/// <summary>
/// Converts a System.Half to a double-precision floating-point number.
/// </summary>
/// <param name="value">A System.Half to convert.</param>
/// <returns>A double-precision floating-point number that represents the converted System.Half.</returns>
public static implicit operator double(Half value) { return (double)(float)value; }
/// <summary>
/// Converts a System.Half to a decimal number.
/// </summary>
/// <param name="value">A System.Half to convert.</param>
/// <returns>A decimal number that represents the converted System.Half.</returns>
public static explicit operator decimal(Half value) { return (decimal)(float)value; }
/// <summary>
/// Converts an 8-bit signed integer to a System.Half.
/// </summary>
/// <param name="value">An 8-bit signed integer.</param>
/// <returns>A System.Half that represents the converted 8-bit signed integer.</returns>
public static implicit operator Half(sbyte value) { return new Half((float)value); }
/// <summary>
/// Converts a 16-bit unsigned integer to a System.Half.
/// </summary>
/// <param name="value">A 16-bit unsigned integer.</param>
/// <returns>A System.Half that represents the converted 16-bit unsigned integer.</returns>
public static implicit operator Half(ushort value) { return new Half((float)value); }
/// <summary>
/// Converts a 32-bit unsigned integer to a System.Half.
/// </summary>
/// <param name="value">A 32-bit unsigned integer.</param>
/// <returns>A System.Half that represents the converted 32-bit unsigned integer.</returns>
public static implicit operator Half(uint value) { return new Half((float)value); }
/// <summary>
/// Converts a 64-bit unsigned integer to a System.Half.
/// </summary>
/// <param name="value">A 64-bit unsigned integer.</param>
/// <returns>A System.Half that represents the converted 64-bit unsigned integer.</returns>
public static implicit operator Half(ulong value) { return new Half((float)value); }
/// <summary>
/// Converts a System.Half to an 8-bit signed integer.
/// </summary>
/// <param name="value">A System.Half to convert.</param>
/// <returns>An 8-bit signed integer that represents the converted System.Half.</returns>
public static explicit operator sbyte(Half value) { return (sbyte)(float)value; }
/// <summary>
/// Converts a System.Half to a 16-bit unsigned integer.
/// </summary>
/// <param name="value">A System.Half to convert.</param>
/// <returns>A 16-bit unsigned integer that represents the converted System.Half.</returns>
public static explicit operator ushort(Half value) { return (ushort)(float)value; }
/// <summary>
/// Converts a System.Half to a 32-bit unsigned integer.
/// </summary>
/// <param name="value">A System.Half to convert.</param>
/// <returns>A 32-bit unsigned integer that represents the converted System.Half.</returns>
public static explicit operator uint(Half value) { return (uint)(float)value; }
/// <summary>
/// Converts a System.Half to a 64-bit unsigned integer.
/// </summary>
/// <param name="value">A System.Half to convert.</param>
/// <returns>A 64-bit unsigned integer that represents the converted System.Half.</returns>
public static explicit operator ulong(Half value) { return (ulong)(float)value; }
#endregion
/// <summary>
/// Compares this instance to a specified System.Half object.
/// </summary>
/// <param name="other">A System.Half object.</param>
/// <returns>
/// A signed number indicating the relative values of this instance and value.
/// Return Value Meaning Less than zero This instance is less than value. Zero
/// This instance is equal to value. Greater than zero This instance is greater than value.
/// </returns>
public int CompareTo(Half other)
{
int result = 0;
if (this < other)
{
result = -1;
}
else if (this > other)
{
result = 1;
}
else if (this != other)
{
if (!IsNaN(this))
{
result = 1;
}
else if (!IsNaN(other))
{
result = -1;
}
}
return result;
}
/// <summary>
/// Compares this instance to a specified System.Object.
/// </summary>
/// <param name="obj">An System.Object or null.</param>
/// <returns>
/// A signed number indicating the relative values of this instance and value.
/// Return Value Meaning Less than zero This instance is less than value. Zero
/// This instance is equal to value. Greater than zero This instance is greater
/// than value. -or- value is null.
/// </returns>
/// <exception cref="System.ArgumentException">value is not a System.Half</exception>
public int CompareTo(object obj)
{
int result = 0;
if (obj == null)
{
result = 1;
}
else
{
if (obj is Half)
{
result = CompareTo((Half)obj);
}
else
{
throw new ArgumentException("Object must be of type Half.");
}
}
return result;
}
/// <summary>
/// Returns a value indicating whether this instance and a specified System.Half object represent the same value.
/// </summary>
/// <param name="other">A System.Half object to compare to this instance.</param>
/// <returns>true if value is equal to this instance; otherwise, false.</returns>
public bool Equals(Half other)
{
return ((other == this) || (IsNaN(other) && IsNaN(this)));
}
/// <summary>
/// Returns a value indicating whether this instance and a specified System.Object
/// represent the same type and value.
/// </summary>
/// <param name="obj">An System.Object.</param>
/// <returns>true if value is a System.Half and equal to this instance; otherwise, false.</returns>
public override bool Equals(object obj)
{
bool result = false;
if (obj is Half half)
{
if ((half == this) || (IsNaN(half) && IsNaN(this)))
{
result = true;
}
}
return result;
}
/// <summary>
/// Returns the hash code for this instance.
/// </summary>
/// <returns>A 32-bit signed integer hash code.</returns>
public override int GetHashCode()
{
return value.GetHashCode();
}
/// <summary>
/// Returns the System.TypeCode for value type System.Half.
/// </summary>
/// <returns>The enumerated constant (TypeCode)255.</returns>
public TypeCode GetTypeCode()
{
return (TypeCode)255;
}
#region BitConverter & Math methods for Half
/// <summary>
/// Returns the specified half-precision floating point value as an array of bytes.
/// </summary>
/// <param name="value">The number to convert.</param>
/// <returns>An array of bytes with length 2.</returns>
public static byte[] GetBytes(Half value)
{
return BitConverter.GetBytes(value.value);
}
/// <summary>
/// Converts the value of a specified instance of System.Half to its equivalent binary representation.
/// </summary>
/// <param name="value">A System.Half value.</param>
/// <returns>A 16-bit unsigned integer that contain the binary representation of value.</returns>
public static ushort GetBits(Half value)
{
return value.value;
}
/// <summary>
/// Returns a half-precision floating point number converted from two bytes
/// at a specified position in a byte array.
/// </summary>
/// <param name="value">An array of bytes.</param>
/// <param name="startIndex">The starting position within value.</param>
/// <returns>A half-precision floating point number formed by two bytes beginning at startIndex.</returns>
/// <exception cref="System.ArgumentException">
/// startIndex is greater than or equal to the length of value minus 1, and is
/// less than or equal to the length of value minus 1.
/// </exception>
/// <exception cref="System.ArgumentNullException">value is null.</exception>
/// <exception cref="System.ArgumentOutOfRangeException">startIndex is less than zero or greater than the length of value minus 1.</exception>
public static Half ToHalf(byte[] value, int startIndex)
{
return ToHalf((ushort)BitConverter.ToInt16(value, startIndex));
}
/// <summary>
/// Returns a half-precision floating point number converted from its binary representation.
/// </summary>
/// <param name="bits">Binary representation of System.Half value</param>
/// <returns>A half-precision floating point number formed by its binary representation.</returns>
public static Half ToHalf(ushort bits)
{
return new Half { value = bits };
}
/// <summary>
/// Returns a value indicating the sign of a half-precision floating-point number.
/// </summary>
/// <param name="value">A signed number.</param>
/// <returns>
/// A number indicating the sign of value. Number Description -1 value is less
/// than zero. 0 value is equal to zero. 1 value is greater than zero.
/// </returns>
/// <exception cref="System.ArithmeticException">value is equal to System.Half.NaN.</exception>
public static int Sign(Half value)
{
if (value < 0)
{
return -1;
}
else if (value > 0)
{
return 1;
}
else
{
if (value != 0)
{
throw new ArithmeticException("Function does not accept floating point Not-a-Number values.");
}
}
return 0;
}
/// <summary>
/// Returns the absolute value of a half-precision floating-point number.
/// </summary>
/// <param name="value">A number in the range System.Half.MinValue ≤ value ≤ System.Half.MaxValue.</param>
/// <returns>A half-precision floating-point number, x, such that 0 ≤ x ≤System.Half.MaxValue.</returns>
public static Half Abs(Half value)
{
return HalfHelper.Abs(value);
}
/// <summary>
/// Returns the larger of two half-precision floating-point numbers.
/// </summary>
/// <param name="value1">The first of two half-precision floating-point numbers to compare.</param>
/// <param name="value2">The second of two half-precision floating-point numbers to compare.</param>
/// <returns>
/// Parameter value1 or value2, whichever is larger. If value1, or value2, or both val1
/// and value2 are equal to System.Half.NaN, System.Half.NaN is returned.
/// </returns>
public static Half Max(Half value1, Half value2)
{
return (value1 < value2) ? value2 : value1;
}
/// <summary>
/// Returns the smaller of two half-precision floating-point numbers.
/// </summary>
/// <param name="value1">The first of two half-precision floating-point numbers to compare.</param>
/// <param name="value2">The second of two half-precision floating-point numbers to compare.</param>
/// <returns>
/// Parameter value1 or value2, whichever is smaller. If value1, or value2, or both val1
/// and value2 are equal to System.Half.NaN, System.Half.NaN is returned.
/// </returns>
public static Half Min(Half value1, Half value2)
{
return (value1 < value2) ? value1 : value2;
}
#endregion
/// <summary>
/// Returns a value indicating whether the specified number evaluates to not a number (System.Half.NaN).
/// </summary>
/// <param name="half">A half-precision floating-point number.</param>
/// <returns>true if value evaluates to not a number (System.Half.NaN); otherwise, false.</returns>
public static bool IsNaN(Half half)
{
return HalfHelper.IsNaN(half);
}
/// <summary>
/// Returns a value indicating whether the specified number evaluates to negative or positive infinity.
/// </summary>
/// <param name="half">A half-precision floating-point number.</param>
/// <returns>true if half evaluates to System.Half.PositiveInfinity or System.Half.NegativeInfinity; otherwise, false.</returns>
public static bool IsInfinity(Half half)
{
return HalfHelper.IsInfinity(half);
}
/// <summary>
/// Returns a value indicating whether the specified number evaluates to negative infinity.
/// </summary>
/// <param name="half">A half-precision floating-point number.</param>
/// <returns>true if half evaluates to System.Half.NegativeInfinity; otherwise, false.</returns>
public static bool IsNegativeInfinity(Half half)
{
return HalfHelper.IsNegativeInfinity(half);
}
/// <summary>
/// Returns a value indicating whether the specified number evaluates to positive infinity.
/// </summary>
/// <param name="half">A half-precision floating-point number.</param>
/// <returns>true if half evaluates to System.Half.PositiveInfinity; otherwise, false.</returns>
public static bool IsPositiveInfinity(Half half)
{
return HalfHelper.IsPositiveInfinity(half);
}
#region String operations (Parse and ToString)
/// <summary>
/// Converts the string representation of a number to its System.Half equivalent.
/// </summary>
/// <param name="value">The string representation of the number to convert.</param>
/// <returns>The System.Half number equivalent to the number contained in value.</returns>
/// <exception cref="System.ArgumentNullException">value is null.</exception>
/// <exception cref="System.FormatException">value is not in the correct format.</exception>
/// <exception cref="System.OverflowException">value represents a number less than System.Half.MinValue or greater than System.Half.MaxValue.</exception>
public static Half Parse(string value)
{
return (Half)float.Parse(value, CultureInfo.InvariantCulture);
}
/// <summary>
/// Converts the string representation of a number to its System.Half equivalent
/// using the specified culture-specific format information.
/// </summary>
/// <param name="value">The string representation of the number to convert.</param>
/// <param name="provider">An System.IFormatProvider that supplies culture-specific parsing information about value.</param>
/// <returns>The System.Half number equivalent to the number contained in s as specified by provider.</returns>
/// <exception cref="System.ArgumentNullException">value is null.</exception>
/// <exception cref="System.FormatException">value is not in the correct format.</exception>
/// <exception cref="System.OverflowException">value represents a number less than System.Half.MinValue or greater than System.Half.MaxValue.</exception>
public static Half Parse(string value, IFormatProvider provider)
{
return (Half)float.Parse(value, provider);
}
/// <summary>
/// Converts the string representation of a number in a specified style to its System.Half equivalent.
/// </summary>
/// <param name="value">The string representation of the number to convert.</param>
/// <param name="style">
/// A bitwise combination of System.Globalization.NumberStyles values that indicates
/// the style elements that can be present in value. A typical value to specify is
/// System.Globalization.NumberStyles.Number.
/// </param>
/// <returns>The System.Half number equivalent to the number contained in s as specified by style.</returns>
/// <exception cref="System.ArgumentNullException">value is null.</exception>
/// <exception cref="System.ArgumentException">
/// style is not a System.Globalization.NumberStyles value. -or- style is the
/// System.Globalization.NumberStyles.AllowHexSpecifier value.
/// </exception>
/// <exception cref="System.FormatException">value is not in the correct format.</exception>
/// <exception cref="System.OverflowException">value represents a number less than System.Half.MinValue or greater than System.Half.MaxValue.</exception>
public static Half Parse(string value, NumberStyles style)
{
return (Half)float.Parse(value, style, CultureInfo.InvariantCulture);
}
/// <summary>
/// Converts the string representation of a number to its System.Half equivalent
/// using the specified style and culture-specific format.
/// </summary>
/// <param name="value">The string representation of the number to convert.</param>
/// <param name="style">
/// A bitwise combination of System.Globalization.NumberStyles values that indicates
/// the style elements that can be present in value. A typical value to specify is
/// System.Globalization.NumberStyles.Number.
/// </param>
/// <param name="provider">An System.IFormatProvider object that supplies culture-specific information about the format of value.</param>
/// <returns>The System.Half number equivalent to the number contained in s as specified by style and provider.</returns>
/// <exception cref="System.ArgumentNullException">value is null.</exception>
/// <exception cref="System.ArgumentException">
/// style is not a System.Globalization.NumberStyles value. -or- style is the
/// System.Globalization.NumberStyles.AllowHexSpecifier value.
/// </exception>
/// <exception cref="System.FormatException">value is not in the correct format.</exception>
/// <exception cref="System.OverflowException">value represents a number less than System.Half.MinValue or greater than System.Half.MaxValue.</exception>
public static Half Parse(string value, NumberStyles style, IFormatProvider provider)
{
return (Half)float.Parse(value, style, provider);
}
/// <summary>
/// Converts the string representation of a number to its System.Half equivalent.
/// A return value indicates whether the conversion succeeded or failed.
/// </summary>
/// <param name="value">The string representation of the number to convert.</param>
/// <param name="result">
/// When this method returns, contains the System.Half number that is equivalent
/// to the numeric value contained in value, if the conversion succeeded, or is zero
/// if the conversion failed. The conversion fails if the s parameter is null,
/// is not a number in a valid format, or represents a number less than System.Half.MinValue
/// or greater than System.Half.MaxValue. This parameter is passed uninitialized.
/// </param>
/// <returns>true if s was converted successfully; otherwise, false.</returns>
public static bool TryParse(string value, out Half result)
{
if (float.TryParse(value, out float f))
{
result = (Half)f;
return true;
}
result = new Half();
return false;
}
/// <summary>
/// Converts the string representation of a number to its System.Half equivalent
/// using the specified style and culture-specific format. A return value indicates
/// whether the conversion succeeded or failed.
/// </summary>
/// <param name="value">The string representation of the number to convert.</param>
/// <param name="style">
/// A bitwise combination of System.Globalization.NumberStyles values that indicates
/// the permitted format of value. A typical value to specify is System.Globalization.NumberStyles.Number.
/// </param>
/// <param name="provider">An System.IFormatProvider object that supplies culture-specific parsing information about value.</param>
/// <param name="result">
/// When this method returns, contains the System.Half number that is equivalent
/// to the numeric value contained in value, if the conversion succeeded, or is zero
/// if the conversion failed. The conversion fails if the s parameter is null,
/// is not in a format compliant with style, or represents a number less than
/// System.Half.MinValue or greater than System.Half.MaxValue. This parameter is passed uninitialized.
/// </param>
/// <returns>true if s was converted successfully; otherwise, false.</returns>
/// <exception cref="System.ArgumentException">
/// style is not a System.Globalization.NumberStyles value. -or- style
/// is the System.Globalization.NumberStyles.AllowHexSpecifier value.
/// </exception>
public static bool TryParse(string value, NumberStyles style, IFormatProvider provider, out Half result)
{
bool parseResult = false;
if (float.TryParse(value, style, provider, out float f))
{
result = (Half)f;
parseResult = true;
}
else
{
result = new Half();
}
return parseResult;
}
/// <summary>
/// Converts the numeric value of this instance to its equivalent string representation.
/// </summary>
/// <returns>A string that represents the value of this instance.</returns>
public override string ToString()
{
return ((float)this).ToString(CultureInfo.InvariantCulture);
}
/// <summary>
/// Converts the numeric value of this instance to its equivalent string representation
/// using the specified culture-specific format information.
/// </summary>
/// <param name="formatProvider">An System.IFormatProvider that supplies culture-specific formatting information.</param>
/// <returns>The string representation of the value of this instance as specified by provider.</returns>
public string ToString(IFormatProvider formatProvider)
{
return ((float)this).ToString(formatProvider);
}
/// <summary>
/// Converts the numeric value of this instance to its equivalent string representation, using the specified format.
/// </summary>
/// <param name="format">A numeric format string.</param>
/// <returns>The string representation of the value of this instance as specified by format.</returns>
public string ToString(string format)
{
return ((float)this).ToString(format, CultureInfo.InvariantCulture);
}
/// <summary>
/// Converts the numeric value of this instance to its equivalent string representation
/// using the specified format and culture-specific format information.
/// </summary>
/// <param name="format">A numeric format string.</param>
/// <param name="formatProvider">An System.IFormatProvider that supplies culture-specific formatting information.</param>
/// <returns>The string representation of the value of this instance as specified by format and provider.</returns>
/// <exception cref="System.FormatException">format is invalid.</exception>
public string ToString(string format, IFormatProvider formatProvider)
{
return ((float)this).ToString(format, formatProvider);
}
#endregion
#region IConvertible Members
float IConvertible.ToSingle(IFormatProvider provider)
{
return (float)this;
}
TypeCode IConvertible.GetTypeCode()
{
return GetTypeCode();
}
bool IConvertible.ToBoolean(IFormatProvider provider)
{
return Convert.ToBoolean((float)this);
}
byte IConvertible.ToByte(IFormatProvider provider)
{
return Convert.ToByte((float)this);
}
char IConvertible.ToChar(IFormatProvider provider)
{
throw new InvalidCastException(string.Format(CultureInfo.CurrentCulture, "Invalid cast from '{0}' to '{1}'.", "Half", "Char"));
}
DateTime IConvertible.ToDateTime(IFormatProvider provider)
{
throw new InvalidCastException(string.Format(CultureInfo.CurrentCulture, "Invalid cast from '{0}' to '{1}'.", "Half", "DateTime"));
}
decimal IConvertible.ToDecimal(IFormatProvider provider)
{
return Convert.ToDecimal((float)this);
}
double IConvertible.ToDouble(IFormatProvider provider)
{
return Convert.ToDouble((float)this);
}
short IConvertible.ToInt16(IFormatProvider provider)
{
return Convert.ToInt16((float)this);
}
int IConvertible.ToInt32(IFormatProvider provider)
{
return Convert.ToInt32((float)this);
}
long IConvertible.ToInt64(IFormatProvider provider)
{
return Convert.ToInt64((float)this);
}
sbyte IConvertible.ToSByte(IFormatProvider provider)
{
return Convert.ToSByte((float)this);
}
string IConvertible.ToString(IFormatProvider provider)
{
return Convert.ToString((float)this, CultureInfo.InvariantCulture);
}
object IConvertible.ToType(Type conversionType, IFormatProvider provider)
{
return (((float)this) as IConvertible).ToType(conversionType, provider);
}
ushort IConvertible.ToUInt16(IFormatProvider provider)
{
return Convert.ToUInt16((float)this);
}
uint IConvertible.ToUInt32(IFormatProvider provider)
{
return Convert.ToUInt32((float)this);
}
ulong IConvertible.ToUInt64(IFormatProvider provider)
{
return Convert.ToUInt64((float)this);
}
#endregion
}
}

View file

@ -0,0 +1,217 @@
using System.Runtime.InteropServices;
namespace System
{
/// <summary>
/// Helper class for Half conversions and some low level operations.
/// This class is internally used in the Half class.
/// </summary>
/// <remarks>
/// References:
/// - Fast Half Float Conversions, Jeroen van der Zijp, link: http://www.fox-toolkit.org/ftp/fasthalffloatconversion.pdf
/// </remarks>
[ComVisible(false)]
internal static class HalfHelper
{
/// <summary>
/// A class that contains both a float and an int in the same bytes, to mimick C++ Unions
/// </summary>
[StructLayout(LayoutKind.Explicit)]
internal class FloatConverter
{
/// <summary>
/// Integer Value
/// </summary>
[FieldOffset(0)]
public uint Integer;
/// <summary>
/// Floating Point Value
/// </summary>
[FieldOffset(0)]
public float Float;
}
private static readonly uint[] mantissaTable = GenerateMantissaTable();
private static readonly uint[] exponentTable = GenerateExponentTable();
private static readonly ushort[] offsetTable = GenerateOffsetTable();
private static readonly ushort[] baseTable = GenerateBaseTable();
private static readonly sbyte[] shiftTable = GenerateShiftTable();
// Transforms the subnormal representation to a normalized one.
private static uint ConvertMantissa(int i)
{
uint m = (uint)(i << 13); // Zero pad mantissa bits
uint e = 0; // Zero exponent
// While not normalized
while ((m & 0x00800000) == 0)
{
e -= 0x00800000; // Decrement exponent (1<<23)
m <<= 1; // Shift mantissa
}
m &= unchecked((uint)~0x00800000); // Clear leading 1 bit
e += 0x38800000; // Adjust bias ((127-14)<<23)
return m | e; // Return combined number
}
private static uint[] GenerateMantissaTable()
{
uint[] mantissaTable = new uint[2048];
mantissaTable[0] = 0;
for (int i = 1; i < 1024; i++)
{
mantissaTable[i] = ConvertMantissa(i);
}
for (int i = 1024; i < 2048; i++)
{
mantissaTable[i] = (uint)(0x38000000 + ((i - 1024) << 13));
}
return mantissaTable;
}
private static uint[] GenerateExponentTable()
{
uint[] exponentTable = new uint[64];
exponentTable[0] = 0;
for (int i = 1; i < 31; i++)
{
exponentTable[i] = (uint)(i << 23);
}
exponentTable[31] = 0x47800000;
exponentTable[32] = 0x80000000;
for (int i = 33; i < 63; i++)
{
exponentTable[i] = (uint)(0x80000000 + ((i - 32) << 23));
}
exponentTable[63] = 0xc7800000;
return exponentTable;
}
private static ushort[] GenerateOffsetTable()
{
ushort[] offsetTable = new ushort[64];
offsetTable[0] = 0;
for (int i = 1; i < 32; i++)
{
offsetTable[i] = 1024;
}
offsetTable[32] = 0;
for (int i = 33; i < 64; i++)
{
offsetTable[i] = 1024;
}
return offsetTable;
}
private static ushort[] GenerateBaseTable()
{
ushort[] baseTable = new ushort[512];
for (int i = 0; i < 256; ++i)
{
sbyte e = (sbyte)(127 - i);
if (e > 24)
{ // Very small numbers map to zero
baseTable[i | 0x000] = 0x0000;
baseTable[i | 0x100] = 0x8000;
}
else if (e > 14)
{ // Small numbers map to denorms
baseTable[i | 0x000] = (ushort)(0x0400 >> (18 + e));
baseTable[i | 0x100] = (ushort)((0x0400 >> (18 + e)) | 0x8000);
}
else if (e >= -15)
{ // Normal numbers just lose precision
baseTable[i | 0x000] = (ushort)((15 - e) << 10);
baseTable[i | 0x100] = (ushort)(((15 - e) << 10) | 0x8000);
}
else if (e > -128)
{ // Large numbers map to Infinity
baseTable[i | 0x000] = 0x7c00;
baseTable[i | 0x100] = 0xfc00;
}
else
{ // Infinity and NaN's stay Infinity and NaN's
baseTable[i | 0x000] = 0x7c00;
baseTable[i | 0x100] = 0xfc00;
}
}
return baseTable;
}
private static sbyte[] GenerateShiftTable()
{
sbyte[] shiftTable = new sbyte[512];
for (int i = 0; i < 256; ++i)
{
sbyte e = (sbyte)(127 - i);
if (e > 24)
{ // Very small numbers map to zero
shiftTable[i | 0x000] = 24;
shiftTable[i | 0x100] = 24;
}
else if (e > 14)
{ // Small numbers map to denorms
shiftTable[i | 0x000] = (sbyte)(e - 1);
shiftTable[i | 0x100] = (sbyte)(e - 1);
}
else if (e >= -15)
{ // Normal numbers just lose precision
shiftTable[i | 0x000] = 13;
shiftTable[i | 0x100] = 13;
}
else if (e > -128)
{ // Large numbers map to Infinity
shiftTable[i | 0x000] = 24;
shiftTable[i | 0x100] = 24;
}
else
{ // Infinity and NaN's stay Infinity and NaN's
shiftTable[i | 0x000] = 13;
shiftTable[i | 0x100] = 13;
}
}
return shiftTable;
}
public static float HalfToSingle(Half half)
{
uint result = mantissaTable[offsetTable[half.value >> 10] + (half.value & 0x3ff)] + exponentTable[half.value >> 10];
return new FloatConverter() { Integer = result }.Float;
}
public static Half SingleToHalf(float single)
{
uint value = new FloatConverter() { Float = single }.Integer;
ushort result = (ushort)(baseTable[(value >> 23) & 0x1ff] + ((value & 0x007fffff) >> shiftTable[value >> 23]));
return Half.ToHalf(result);
}
public static Half Negate(Half half)
{
return Half.ToHalf((ushort)(half.value ^ 0x8000));
}
public static Half Abs(Half half)
{
return Half.ToHalf((ushort)(half.value & 0x7fff));
}
public static bool IsNaN(Half half)
{
return ((half.value & 0x7fff) > 0x7c00);
}
public static bool IsInfinity(Half half)
{
return ((half.value & 0x7fff) == 0x7c00);
}
public static bool IsPositiveInfinity(Half half)
{
return (half.value == 0x7c00);
}
public static bool IsNegativeInfinity(Half half)
{
return (half.value == 0xfc00);
}
}
}

View file

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Tyrant.Logic")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Tyrant.Logic")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("2d3ceff1-8f47-40e9-8597-cdfd6b5ccf73")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{2D3CEFF1-8F47-40E9-8597-CDFD6B5CCF73}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Tyrant.Logic</RootNamespace>
<AssemblyName>Tyrant.Logic</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AssetHandlers\MaterialDefs.cs" />
<Compile Include="AssetHandlers\Mesh.cs" />
<Compile Include="AssetHandlers\Motion.cs" />
<Compile Include="AssetHandlers\MotionList.cs" />
<Compile Include="Helpers\NameCache.cs" />
<Compile Include="FileHandlers\Package.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="AssetHandlers\SoundBank.cs" />
<Compile Include="Helpers\System.Half.cs" />
<Compile Include="Helpers\System.HalfHelper.cs" />
<Compile Include="AssetHandlers\Texture.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PhilLibX\src\PhilLibX\PhilLibX.Interop\PhilLibX.Interop.vcxproj">
<Project>{eb08d910-0050-4d56-a799-ca04c41b7014}</Project>
<Name>PhilLibX.Interop</Name>
</ProjectReference>
<ProjectReference Include="..\PhilLibX\src\PhilLibX\PhilLibX\PhilLibX.csproj">
<Project>{0f468d5b-2f30-42f5-9043-920040d83d9d}</Project>
<Name>PhilLibX</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

172
src/Tyrant.sln Normal file
View file

@ -0,0 +1,172 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.489
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tyrant.Logic", "Tyrant.Logic\Tyrant.Logic.csproj", "{2D3CEFF1-8F47-40E9-8597-CDFD6B5CCF73}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tyrant.Testing", "Tyrant.Testing\Tyrant.Testing.csproj", "{EA1DBB67-568E-4DBF-B96B-CC0F1C4E429A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PhilLibX", "PhilLibX\src\PhilLibX\PhilLibX\PhilLibX.csproj", "{0F468D5B-2F30-42F5-9043-920040D83D9D}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PhilLibX.Interop", "PhilLibX\src\PhilLibX\PhilLibX.Interop\PhilLibX.Interop.vcxproj", "{EB08D910-0050-4D56-A799-CA04C41B7014}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ExternalLibraries", "ExternalLibraries", "{FA642BA8-BB50-4325-AF2D-A71001B3DF33}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Imaging", "Imaging", "{BCA87C99-563F-459E-B93A-DE9E78D46192}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Compression", "Compression", "{495BB9D5-6381-4457-9EC2-45F1C66D1CE2}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libzstd", "PhilLibX\src\PhilLibX\ExternalLibraries\zstd\build\VS2010\libzstd\libzstd.vcxproj", "{8BFD8150-94D5-4BF9-8A50-7BD9929A0850}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LZ4", "PhilLibX\src\PhilLibX\ExternalLibraries\lz4\LZ4.vcxproj", "{57754C97-3F92-42CD-9F61-3A905DB5CCA0}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MiniZ", "PhilLibX\src\PhilLibX\ExternalLibraries\MiniZ\MiniZ.vcxproj", "{DBA0D3E8-5E3A-48F1-BDE2-AA0976A478DB}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DirectXTex", "PhilLibX\src\PhilLibX\ExternalLibraries\DirectXTex\DirectXTex\DirectXTex_Desktop_2019_Win10.vcxproj", "{371B9FA9-4C90-4AC6-A123-ACED756D6C77}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tyrant", "Tyrant\Tyrant.csproj", "{E2F82202-0E17-4901-B360-BE6F175FBCA2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tyrant.UITests", "Tyrant.UITests\Tyrant.UITests.csproj", "{91DA52B5-C79A-40E9-82C5-C957855D1397}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tyrant.AssetNameFinder", "Tyrant.AssetNameFinder\Tyrant.AssetNameFinder.csproj", "{B577AB13-8179-449B-B822-B62D127A03ED}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Profile|Any CPU = Profile|Any CPU
Profile|x64 = Profile|x64
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2D3CEFF1-8F47-40E9-8597-CDFD6B5CCF73}.Debug|Any CPU.ActiveCfg = Debug|x64
{2D3CEFF1-8F47-40E9-8597-CDFD6B5CCF73}.Debug|x64.ActiveCfg = Debug|x64
{2D3CEFF1-8F47-40E9-8597-CDFD6B5CCF73}.Debug|x64.Build.0 = Debug|x64
{2D3CEFF1-8F47-40E9-8597-CDFD6B5CCF73}.Profile|Any CPU.ActiveCfg = Release|x64
{2D3CEFF1-8F47-40E9-8597-CDFD6B5CCF73}.Profile|Any CPU.Build.0 = Release|x64
{2D3CEFF1-8F47-40E9-8597-CDFD6B5CCF73}.Profile|x64.ActiveCfg = Release|x64
{2D3CEFF1-8F47-40E9-8597-CDFD6B5CCF73}.Profile|x64.Build.0 = Release|x64
{2D3CEFF1-8F47-40E9-8597-CDFD6B5CCF73}.Release|Any CPU.ActiveCfg = Release|x64
{2D3CEFF1-8F47-40E9-8597-CDFD6B5CCF73}.Release|x64.ActiveCfg = Release|x64
{2D3CEFF1-8F47-40E9-8597-CDFD6B5CCF73}.Release|x64.Build.0 = Release|x64
{EA1DBB67-568E-4DBF-B96B-CC0F1C4E429A}.Debug|Any CPU.ActiveCfg = Debug|x64
{EA1DBB67-568E-4DBF-B96B-CC0F1C4E429A}.Debug|x64.ActiveCfg = Debug|x64
{EA1DBB67-568E-4DBF-B96B-CC0F1C4E429A}.Debug|x64.Build.0 = Debug|x64
{EA1DBB67-568E-4DBF-B96B-CC0F1C4E429A}.Profile|Any CPU.ActiveCfg = Release|x64
{EA1DBB67-568E-4DBF-B96B-CC0F1C4E429A}.Profile|Any CPU.Build.0 = Release|x64
{EA1DBB67-568E-4DBF-B96B-CC0F1C4E429A}.Profile|x64.ActiveCfg = Release|x64
{EA1DBB67-568E-4DBF-B96B-CC0F1C4E429A}.Profile|x64.Build.0 = Release|x64
{EA1DBB67-568E-4DBF-B96B-CC0F1C4E429A}.Release|Any CPU.ActiveCfg = Release|x64
{EA1DBB67-568E-4DBF-B96B-CC0F1C4E429A}.Release|x64.ActiveCfg = Release|x64
{EA1DBB67-568E-4DBF-B96B-CC0F1C4E429A}.Release|x64.Build.0 = Release|x64
{0F468D5B-2F30-42F5-9043-920040D83D9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0F468D5B-2F30-42F5-9043-920040D83D9D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0F468D5B-2F30-42F5-9043-920040D83D9D}.Debug|x64.ActiveCfg = Debug|x64
{0F468D5B-2F30-42F5-9043-920040D83D9D}.Debug|x64.Build.0 = Debug|x64
{0F468D5B-2F30-42F5-9043-920040D83D9D}.Profile|Any CPU.ActiveCfg = Release|Any CPU
{0F468D5B-2F30-42F5-9043-920040D83D9D}.Profile|Any CPU.Build.0 = Release|Any CPU
{0F468D5B-2F30-42F5-9043-920040D83D9D}.Profile|x64.ActiveCfg = Release|x64
{0F468D5B-2F30-42F5-9043-920040D83D9D}.Profile|x64.Build.0 = Release|x64
{0F468D5B-2F30-42F5-9043-920040D83D9D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0F468D5B-2F30-42F5-9043-920040D83D9D}.Release|Any CPU.Build.0 = Release|Any CPU
{0F468D5B-2F30-42F5-9043-920040D83D9D}.Release|x64.ActiveCfg = Release|x64
{0F468D5B-2F30-42F5-9043-920040D83D9D}.Release|x64.Build.0 = Release|x64
{EB08D910-0050-4D56-A799-CA04C41B7014}.Debug|Any CPU.ActiveCfg = Debug|Win32
{EB08D910-0050-4D56-A799-CA04C41B7014}.Debug|x64.ActiveCfg = Debug|x64
{EB08D910-0050-4D56-A799-CA04C41B7014}.Debug|x64.Build.0 = Debug|x64
{EB08D910-0050-4D56-A799-CA04C41B7014}.Profile|Any CPU.ActiveCfg = Release|Win32
{EB08D910-0050-4D56-A799-CA04C41B7014}.Profile|Any CPU.Build.0 = Release|Win32
{EB08D910-0050-4D56-A799-CA04C41B7014}.Profile|x64.ActiveCfg = Release|x64
{EB08D910-0050-4D56-A799-CA04C41B7014}.Profile|x64.Build.0 = Release|x64
{EB08D910-0050-4D56-A799-CA04C41B7014}.Release|Any CPU.ActiveCfg = Release|Win32
{EB08D910-0050-4D56-A799-CA04C41B7014}.Release|x64.ActiveCfg = Release|x64
{EB08D910-0050-4D56-A799-CA04C41B7014}.Release|x64.Build.0 = Release|x64
{8BFD8150-94D5-4BF9-8A50-7BD9929A0850}.Debug|Any CPU.ActiveCfg = Debug|Win32
{8BFD8150-94D5-4BF9-8A50-7BD9929A0850}.Debug|x64.ActiveCfg = Debug|x64
{8BFD8150-94D5-4BF9-8A50-7BD9929A0850}.Debug|x64.Build.0 = Debug|x64
{8BFD8150-94D5-4BF9-8A50-7BD9929A0850}.Profile|Any CPU.ActiveCfg = Release|Win32
{8BFD8150-94D5-4BF9-8A50-7BD9929A0850}.Profile|Any CPU.Build.0 = Release|Win32
{8BFD8150-94D5-4BF9-8A50-7BD9929A0850}.Profile|x64.ActiveCfg = Release|x64
{8BFD8150-94D5-4BF9-8A50-7BD9929A0850}.Profile|x64.Build.0 = Release|x64
{8BFD8150-94D5-4BF9-8A50-7BD9929A0850}.Release|Any CPU.ActiveCfg = Release|Win32
{8BFD8150-94D5-4BF9-8A50-7BD9929A0850}.Release|x64.ActiveCfg = Release|x64
{8BFD8150-94D5-4BF9-8A50-7BD9929A0850}.Release|x64.Build.0 = Release|x64
{57754C97-3F92-42CD-9F61-3A905DB5CCA0}.Debug|Any CPU.ActiveCfg = Debug|Win32
{57754C97-3F92-42CD-9F61-3A905DB5CCA0}.Debug|x64.ActiveCfg = Debug|x64
{57754C97-3F92-42CD-9F61-3A905DB5CCA0}.Debug|x64.Build.0 = Debug|x64
{57754C97-3F92-42CD-9F61-3A905DB5CCA0}.Profile|Any CPU.ActiveCfg = Release|Win32
{57754C97-3F92-42CD-9F61-3A905DB5CCA0}.Profile|Any CPU.Build.0 = Release|Win32
{57754C97-3F92-42CD-9F61-3A905DB5CCA0}.Profile|x64.ActiveCfg = Release|x64
{57754C97-3F92-42CD-9F61-3A905DB5CCA0}.Profile|x64.Build.0 = Release|x64
{57754C97-3F92-42CD-9F61-3A905DB5CCA0}.Release|Any CPU.ActiveCfg = Release|Win32
{57754C97-3F92-42CD-9F61-3A905DB5CCA0}.Release|x64.ActiveCfg = Release|x64
{57754C97-3F92-42CD-9F61-3A905DB5CCA0}.Release|x64.Build.0 = Release|x64
{DBA0D3E8-5E3A-48F1-BDE2-AA0976A478DB}.Debug|Any CPU.ActiveCfg = Debug|Win32
{DBA0D3E8-5E3A-48F1-BDE2-AA0976A478DB}.Debug|x64.ActiveCfg = Debug|x64
{DBA0D3E8-5E3A-48F1-BDE2-AA0976A478DB}.Debug|x64.Build.0 = Debug|x64
{DBA0D3E8-5E3A-48F1-BDE2-AA0976A478DB}.Profile|Any CPU.ActiveCfg = Release|Win32
{DBA0D3E8-5E3A-48F1-BDE2-AA0976A478DB}.Profile|Any CPU.Build.0 = Release|Win32
{DBA0D3E8-5E3A-48F1-BDE2-AA0976A478DB}.Profile|x64.ActiveCfg = Release|x64
{DBA0D3E8-5E3A-48F1-BDE2-AA0976A478DB}.Profile|x64.Build.0 = Release|x64
{DBA0D3E8-5E3A-48F1-BDE2-AA0976A478DB}.Release|Any CPU.ActiveCfg = Release|Win32
{DBA0D3E8-5E3A-48F1-BDE2-AA0976A478DB}.Release|x64.ActiveCfg = Release|x64
{DBA0D3E8-5E3A-48F1-BDE2-AA0976A478DB}.Release|x64.Build.0 = Release|x64
{371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Debug|Any CPU.ActiveCfg = Debug|Win32
{371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Debug|x64.ActiveCfg = Debug|x64
{371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Debug|x64.Build.0 = Debug|x64
{371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Profile|Any CPU.ActiveCfg = Profile|Win32
{371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Profile|x64.ActiveCfg = Profile|x64
{371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Profile|x64.Build.0 = Profile|x64
{371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Release|Any CPU.ActiveCfg = Release|Win32
{371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Release|x64.ActiveCfg = Release|x64
{371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Release|x64.Build.0 = Release|x64
{E2F82202-0E17-4901-B360-BE6F175FBCA2}.Debug|Any CPU.ActiveCfg = Debug|x64
{E2F82202-0E17-4901-B360-BE6F175FBCA2}.Debug|x64.ActiveCfg = Debug|x64
{E2F82202-0E17-4901-B360-BE6F175FBCA2}.Debug|x64.Build.0 = Debug|x64
{E2F82202-0E17-4901-B360-BE6F175FBCA2}.Profile|Any CPU.ActiveCfg = Release|x64
{E2F82202-0E17-4901-B360-BE6F175FBCA2}.Profile|Any CPU.Build.0 = Release|x64
{E2F82202-0E17-4901-B360-BE6F175FBCA2}.Profile|x64.ActiveCfg = Release|x64
{E2F82202-0E17-4901-B360-BE6F175FBCA2}.Profile|x64.Build.0 = Release|x64
{E2F82202-0E17-4901-B360-BE6F175FBCA2}.Release|Any CPU.ActiveCfg = Release|x64
{E2F82202-0E17-4901-B360-BE6F175FBCA2}.Release|x64.ActiveCfg = Release|x64
{E2F82202-0E17-4901-B360-BE6F175FBCA2}.Release|x64.Build.0 = Release|x64
{91DA52B5-C79A-40E9-82C5-C957855D1397}.Debug|Any CPU.ActiveCfg = Debug|x64
{91DA52B5-C79A-40E9-82C5-C957855D1397}.Debug|x64.ActiveCfg = Debug|x64
{91DA52B5-C79A-40E9-82C5-C957855D1397}.Debug|x64.Build.0 = Debug|x64
{91DA52B5-C79A-40E9-82C5-C957855D1397}.Profile|Any CPU.ActiveCfg = Release|x64
{91DA52B5-C79A-40E9-82C5-C957855D1397}.Profile|Any CPU.Build.0 = Release|x64
{91DA52B5-C79A-40E9-82C5-C957855D1397}.Profile|x64.ActiveCfg = Release|x64
{91DA52B5-C79A-40E9-82C5-C957855D1397}.Profile|x64.Build.0 = Release|x64
{91DA52B5-C79A-40E9-82C5-C957855D1397}.Release|Any CPU.ActiveCfg = Release|x64
{91DA52B5-C79A-40E9-82C5-C957855D1397}.Release|x64.ActiveCfg = Release|x64
{91DA52B5-C79A-40E9-82C5-C957855D1397}.Release|x64.Build.0 = Release|x64
{B577AB13-8179-449B-B822-B62D127A03ED}.Debug|Any CPU.ActiveCfg = Debug|x64
{B577AB13-8179-449B-B822-B62D127A03ED}.Debug|x64.ActiveCfg = Debug|x64
{B577AB13-8179-449B-B822-B62D127A03ED}.Debug|x64.Build.0 = Debug|x64
{B577AB13-8179-449B-B822-B62D127A03ED}.Profile|Any CPU.ActiveCfg = Release|x64
{B577AB13-8179-449B-B822-B62D127A03ED}.Profile|Any CPU.Build.0 = Release|x64
{B577AB13-8179-449B-B822-B62D127A03ED}.Profile|x64.ActiveCfg = Release|x64
{B577AB13-8179-449B-B822-B62D127A03ED}.Profile|x64.Build.0 = Release|x64
{B577AB13-8179-449B-B822-B62D127A03ED}.Release|Any CPU.ActiveCfg = Release|x64
{B577AB13-8179-449B-B822-B62D127A03ED}.Release|x64.ActiveCfg = Release|x64
{B577AB13-8179-449B-B822-B62D127A03ED}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{0F468D5B-2F30-42F5-9043-920040D83D9D} = {FA642BA8-BB50-4325-AF2D-A71001B3DF33}
{EB08D910-0050-4D56-A799-CA04C41B7014} = {FA642BA8-BB50-4325-AF2D-A71001B3DF33}
{BCA87C99-563F-459E-B93A-DE9E78D46192} = {FA642BA8-BB50-4325-AF2D-A71001B3DF33}
{495BB9D5-6381-4457-9EC2-45F1C66D1CE2} = {FA642BA8-BB50-4325-AF2D-A71001B3DF33}
{8BFD8150-94D5-4BF9-8A50-7BD9929A0850} = {495BB9D5-6381-4457-9EC2-45F1C66D1CE2}
{57754C97-3F92-42CD-9F61-3A905DB5CCA0} = {495BB9D5-6381-4457-9EC2-45F1C66D1CE2}
{DBA0D3E8-5E3A-48F1-BDE2-AA0976A478DB} = {495BB9D5-6381-4457-9EC2-45F1C66D1CE2}
{371B9FA9-4C90-4AC6-A123-ACED756D6C77} = {BCA87C99-563F-459E-B93A-DE9E78D46192}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {770D2D52-890B-4E7B-9698-F3989D6B3AC9}
EndGlobalSection
EndGlobal

6
src/Tyrant/App.config Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>

26
src/Tyrant/App.xaml Normal file
View file

@ -0,0 +1,26 @@
<Application x:Class="Tyrant.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="Windows/MainWindow.xaml">
<Application.Resources>
<!-- Resources scoped at the Application level should be defined here. -->
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Styles/CheckBoxStyle.xaml"/>
<ResourceDictionary Source="Styles/ProgressBarStyle.xaml"/>
<ResourceDictionary Source="Styles/RadioButtonStyle.xaml"/>
<ResourceDictionary Source="Styles/ButtonStyle.xaml"/>
<ResourceDictionary Source="Styles/IconButtonStyle.xaml"/>
<ResourceDictionary Source="Styles/ListViewStyle.xaml"/>
<ResourceDictionary Source="Styles/SliderStyle.xaml"/>
<ResourceDictionary Source="Styles/TabStyle.xaml"/>
<ResourceDictionary Source="Styles/TextBoxStyle.xaml"/>
<ResourceDictionary Source="Icons/SettingsIcon.xaml"/>
<ResourceDictionary Source="Icons/ExportIcon.xaml"/>
<ResourceDictionary Source="Icons/ExportAllIcon.xaml"/>
<ResourceDictionary Source="Icons/OpenFileIcon.xaml"/>
<ResourceDictionary Source="Icons/AboutIcon.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>

17
src/Tyrant/App.xaml.cs Normal file
View file

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace Tyrant
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}

View file

@ -0,0 +1,64 @@
// ------------------------------------------------------------------------
// Tyrant - RE Engine Extractor
// Copyright (C) 2018 Philip/Scobalula
//
// 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/>.
// ------------------------------------------------------------------------
using Tyrant.Logic;
using ByteSizeLib;
namespace Tyrant
{
/// <summary>
/// A class to hold an Asset that is displayed
/// </summary>
public class Asset
{
/// <summary>
/// Gets or Sets the name of the asset
/// </summary>
public string Name { get; set; }
/// <summary>
/// Gets or Sets the asset type
/// </summary>
public string Type { get; set; }
/// <summary>
/// Gets or Sets the display info
/// </summary>
public string DisplaySize
{
get
{
return ByteSize.FromBytes(PackageEntry.CompressedSize).ToString();
}
}
/// <summary>
/// Gets or Sets the package entry
/// </summary>
public Package.Entry PackageEntry { get; set; }
/// <summary>
/// Creates a new Asset for UI
/// </summary>
public Asset(string name, string type, Package.Entry entry)
{
Name = name;
Type = type;
PackageEntry = entry;
}
}
}

View file

@ -0,0 +1,70 @@
// ------------------------------------------------------------------------
// Tyrant - RE Engine Extractor
// Copyright (C) 2018 Philip/Scobalula
//
// 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/>.
// ------------------------------------------------------------------------
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Collections.Generic;
namespace Tyrant
{
/// <summary>
/// A class to hold an Asset List
/// </summary>
public class AssetList : ObservableCollection<Asset>
{
/// <summary>
/// Gets or Sets if we are loading assets
/// </summary>
private bool Loading = false;
/// <summary>
/// Adds assets to the UI without notfying each time
/// </summary>
/// <param name="assets">List of Assets</param>
public void AddAssets(IEnumerable<Asset> assets)
{
Loading = true;
foreach (var asset in assets)
Add(asset);
Loading = false;
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
}
/// <summary>
/// Clears all loaded assets
/// </summary>
public void ClearAssets()
{
Loading = true;
Clear();
Loading = false;
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
}
/// <summary>
/// Overrides On Collection Changed to disable notifying each time the list is updated
/// </summary>
/// <param name="e">Args</param>
protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
{
if (!Loading)
base.OnCollectionChanged(e);
}
}
}

View file

@ -0,0 +1,104 @@
// ------------------------------------------------------------------------
// Tyrant - RE Engine Extractor
// Copyright (C) 2018 Philip/Scobalula
//
// 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/>.
// ------------------------------------------------------------------------
using System.ComponentModel;
using System.Windows.Data;
namespace Tyrant
{
public class MainViewModel : INotifyPropertyChanged
{
#region BackingVariables
/// <summary>
/// Gets or Sets the Filter String
/// </summary>
private string BackingFilterString { get; set; }
/// <summary>
/// Gets or Sets the Filter Strings
/// </summary>
private string[] FilterStrings { get; set; }
#endregion
public string FilterString
{
get
{
return BackingFilterString;
}
set
{
if (value != BackingFilterString)
{
BackingFilterString = value;
FilterStrings = string.IsNullOrWhiteSpace(BackingFilterString) ? null : BackingFilterString.Split(' ');
AssetsView.Refresh();
OnPropertyChanged("FilterString");
}
}
}
/// <summary>
/// Gets or Sets the Collection View for the Assets
/// </summary>
private ICollectionView AssetsView { get; set; }
/// <summary>
/// Gets the observable collection of assets
/// </summary>
public AssetList Assets { get; } = new AssetList();
/// <summary>
/// Property Changed Event
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
public MainViewModel()
{
AssetsView = CollectionViewSource.GetDefaultView(Assets);
AssetsView.Filter = delegate (object obj)
{
if(FilterStrings != null && FilterStrings.Length > 0 && obj is Asset asset)
{
var assetName = asset.Name.ToLower();
foreach(var filterString in FilterStrings)
{
if(!string.IsNullOrWhiteSpace(filterString) && assetName.Contains(filterString.ToLower()))
{
return true;
}
}
return false;
}
return true;
};
}
/// <summary>
/// Updates the Property on Change
/// </summary>
/// <param name="name">Property Name</param>
protected void OnPropertyChanged(string name)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
}
}

View file

@ -0,0 +1,119 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tyrant
{
public class TyrantSettings
{
/// <summary>
/// Setting Values
/// </summary>
private Dictionary<string, string> Values = new Dictionary<string, string>();
/// <summary>
/// Gets the setting with the given name, if not found, returns defaultVal
/// </summary>
public string this[string key, string defaultVal]
{
get
{
if (Values.TryGetValue(key, out var val))
{
return val;
}
else
{
Values[key] = defaultVal;
return defaultVal;
}
}
}
/// <summary>
/// Sets the setting with the given name
/// </summary>
public string this[string key]
{
set
{
Values[key] = value;
}
}
/// <summary>
/// Initializes an instance of the Settings Class
/// </summary>
public TyrantSettings() { }
/// <summary>
/// Initializes an instance of the Settings Class and loads the settings
/// </summary>
/// <param name="fileName">File Name</param>
public TyrantSettings(string fileName)
{
Load(fileName);
}
/// <summary>
/// Loads Settings from a file
/// </summary>
/// <param name="fileName">File Name</param>
public void Load(string fileName)
{
try
{
if (!File.Exists(fileName))
{
Save(fileName);
}
else
{
using (var reader = new BinaryReader(new FileStream(fileName, FileMode.Open)))
{
if (reader.ReadUInt32() == 0x47464354)
{
int count = reader.ReadInt32();
for (int i = 0; i < count; i++)
Values[reader.ReadString()] = reader.ReadString();
}
}
}
}
catch
{
return;
}
}
/// <summary>
/// Saves all settings to a file
/// </summary>
/// <param name="fileName">File Name</param>
public void Save(string fileName)
{
try
{
using (var writer = new BinaryWriter(new FileStream(fileName, FileMode.Create)))
{
writer.Write(0x47464354);
writer.Write(Values.Count);
foreach (var value in Values)
{
writer.Write(value.Key);
writer.Write(value.Value);
}
}
}
catch
{
return;
}
}
}
}

BIN
src/Tyrant/Icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 KiB

View file

@ -0,0 +1,22 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<DataTemplate x:Key="AboutIcon">
<Viewbox xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Stretch="Uniform">
<Canvas Canvas.Left="0" Canvas.Top="0" Width="512" Height="512">
<Canvas.RenderTransform>
<TranslateTransform X="0" Y="0"/>
</Canvas.RenderTransform>
<Canvas.Resources/>
<Canvas>
<Canvas>
<Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path2" Fill="#FF909090">
<Path.Data>
<PathGeometry Figures="M256 0C114.51 0 0 114.497 0 256c0 141.49 114.497 256 256 256c141.49 0 256-114.497 256-256C512 114.51 397.503 0 256 0z M273.063 370.811c0 9.425-7.641 17.067-17.067 17.067s-17.067-7.641-17.067-17.067V226.843c0-9.425 7.641-17.067 17.067-17.067 s17.067 7.641 17.067 17.067V370.811z M256 192.389c-18.821 0-34.133-15.312-34.133-34.133c0-18.821 15.312-34.133 34.133-34.133 s34.133 15.312 34.133 34.133S274.821 192.389 256 192.389z" FillRule="NonZero"/>
</Path.Data>
</Path>
</Canvas>
</Canvas>
</Canvas>
</Viewbox>
</DataTemplate>
</ResourceDictionary>

View file

@ -0,0 +1,23 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<DataTemplate x:Key="ExportAllIcon">
<Viewbox xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Stretch="Uniform">
<Canvas Canvas.Left="0" Canvas.Top="0" Width="334.5" Height="334.5">
<Canvas.RenderTransform>
<TranslateTransform X="0" Y="0"/>
</Canvas.RenderTransform>
<Canvas.Resources/>
<Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Fill="#FF909090">
<Path.Data>
<PathGeometry Figures="M332.797 13.699c-1.489-1.306-3.608-1.609-5.404-0.776L2.893 163.695c-1.747 0.812-2.872 2.555-2.893 4.481 s1.067 3.693 2.797 4.542l91.833 45.068c1.684 0.827 3.692 0.64 5.196-0.484l89.287-66.734l-70.094 72.1 c-1 1.029-1.51 2.438-1.4 3.868l6.979 90.889c0.155 2.014 1.505 3.736 3.424 4.367c0.513 0.168 1.04 0.25 1.561 0.25 c1.429 0 2.819-0.613 3.786-1.733l48.742-56.482l60.255 28.79c1.308 0.625 2.822 0.651 4.151 0.073 c1.329-0.579 2.341-1.705 2.775-3.087L334.27 18.956C334.864 17.066 334.285 15.005 332.797 13.699z" FillRule="NonZero"/>
</Path.Data>
</Path>
<Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Fill="#FF909090" StrokeThickness="0.36689347">
<Path.Data>
<PathGeometry Figures="m 133.07149 8.7206168 c -0.5463 -0.47916 -1.32375 -0.59033 -1.98269 -0.28471 L 12.031851 63.753177 c -0.64096 0.29791 -1.05372 0.93741 -1.06142 1.64405 -0.008 0.70663 0.39147 1.35493 1.0262 1.66643 l 33.69293 16.53515 c 0.61785 0.30342 1.35457 0.23481 1.90638 -0.17757 l 32.75882 -24.48427 -25.71704 26.45302 c -0.36689 0.37753 -0.55401 0.89448 -0.51365 1.41914 l 2.56055 33.346583 c 0.0569 0.73893 0.55218 1.37072 1.25625 1.60223 0.18821 0.0616 0.38157 0.0917 0.57272 0.0917 0.52429 0 1.03427 -0.22491 1.38906 -0.63583 l 17.88312 -20.72287 22.10717 10.56286 c 0.479889 0.22931 1.035369 0.23885 1.522969 0.0268 0.4876 -0.21243 0.8589 -0.62555 1.01813 -1.1326 l 31.17788 -99.298623 c 0.21794 -0.6934302 0.006 -1.4495902 -0.54043 -1.9287602 z" FillRule="NonZero"/>
</Path.Data>
</Path>
</Canvas>
</Viewbox>
</DataTemplate>
</ResourceDictionary>

View file

@ -0,0 +1,18 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<DataTemplate x:Key="ExportIcon">
<Viewbox xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Stretch="Uniform">
<Canvas Canvas.Left="0" Canvas.Top="0" Width="334.5" Height="334.5">
<Canvas.RenderTransform>
<TranslateTransform X="0" Y="0"/>
</Canvas.RenderTransform>
<Canvas.Resources/>
<Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Fill="#FF909090">
<Path.Data>
<PathGeometry Figures="M332.797 13.699c-1.489-1.306-3.608-1.609-5.404-0.776L2.893 163.695c-1.747 0.812-2.872 2.555-2.893 4.481 s1.067 3.693 2.797 4.542l91.833 45.068c1.684 0.827 3.692 0.64 5.196-0.484l89.287-66.734l-70.094 72.1 c-1 1.029-1.51 2.438-1.4 3.868l6.979 90.889c0.155 2.014 1.505 3.736 3.424 4.367c0.513 0.168 1.04 0.25 1.561 0.25 c1.429 0 2.819-0.613 3.786-1.733l48.742-56.482l60.255 28.79c1.308 0.625 2.822 0.651 4.151 0.073 c1.329-0.579 2.341-1.705 2.775-3.087L334.27 18.956C334.864 17.066 334.285 15.005 332.797 13.699z" FillRule="NonZero"/>
</Path.Data>
</Path>
</Canvas>
</Viewbox>
</DataTemplate>
</ResourceDictionary>

View file

@ -0,0 +1,23 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<DataTemplate x:Key="OpenFileIcon">
<Viewbox xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Stretch="Uniform">
<Canvas Canvas.Left="0" Canvas.Top="0" Width="58" Height="58">
<Canvas.RenderTransform>
<TranslateTransform X="0" Y="0"/>
</Canvas.RenderTransform>
<Canvas.Resources/>
<Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Fill="#FF909090">
<Path.Data>
<PathGeometry Figures="M55.981 54.5H2.019C0.904 54.5 0 53.596 0 52.481V20.5h58v31.981C58 53.596 57.096 54.5 55.981 54.5z " FillRule="NonZero"/>
</Path.Data>
</Path>
<Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Fill="#FF909090">
<Path.Data>
<PathGeometry Figures="M26.019 11.5V5.519C26.019 4.404 25.115 3.5 24 3.5H2.019C0.904 3.5 0 4.404 0 5.519V10.5v10h58 v-6.981c0-1.115-0.904-2.019-2.019-2.019H26.019z" FillRule="NonZero"/>
</Path.Data>
</Path>
</Canvas>
</Viewbox>
</DataTemplate>
</ResourceDictionary>

View file

@ -0,0 +1,18 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<DataTemplate x:Key="SettingsIcon">
<Viewbox xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Stretch="Uniform">
<Canvas Canvas.Left="0" Canvas.Top="0" Width="231.233" Height="231.233">
<Canvas.RenderTransform>
<TranslateTransform X="0" Y="0"/>
</Canvas.RenderTransform>
<Canvas.Resources/>
<Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Fill="#FF909090">
<Path.Data>
<PathGeometry Figures="M230.505 102.78c-0.365-3.25-4.156-5.695-7.434-5.695c-10.594 0-19.996-6.218-23.939-15.842 c-4.025-9.855-1.428-21.346 6.465-28.587c2.486-2.273 2.789-6.079 0.705-8.721c-5.424-6.886-11.586-13.107-18.316-18.498 c-2.633-2.112-6.502-1.818-8.787 0.711c-6.891 7.632-19.27 10.468-28.836 6.477c-9.951-4.187-16.232-14.274-15.615-25.101 c0.203-3.403-2.285-6.36-5.676-6.755c-8.637-1-17.35-1.029-26.012-0.068c-3.348 0.37-5.834 3.257-5.723 6.617 c0.375 10.721-5.977 20.63-15.832 24.667c-9.451 3.861-21.744 1.046-28.621-6.519c-2.273-2.492-6.074-2.798-8.725-0.731 c-6.928 5.437-13.229 11.662-18.703 18.492c-2.133 2.655-1.818 6.503 0.689 8.784c8.049 7.289 10.644 18.879 6.465 28.849 c-3.99 9.505-13.859 15.628-25.156 15.628c-3.666-0.118-6.275 2.345-6.68 5.679c-1.016 8.683-1.027 17.535-0.049 26.289 c0.365 3.264 4.268 5.688 7.582 5.688c10.07-0.256 19.732 5.974 23.791 15.841c4.039 9.855 1.439 21.341-6.467 28.592 c-2.473 2.273-2.789 6.07-0.701 8.709c5.369 6.843 11.537 13.068 18.287 18.505c2.65 2.134 6.504 1.835 8.801-0.697 c6.918-7.65 19.295-10.481 28.822-6.482c9.98 4.176 16.258 14.262 15.645 25.092c-0.201 3.403 2.293 6.369 5.672 6.755 c4.42 0.517 8.863 0.773 13.32 0.773c4.23 0 8.461-0.231 12.692-0.702c3.352-0.37 5.834-3.26 5.721-6.621 c-0.387-10.716 5.979-20.626 15.822-24.655c9.514-3.886 21.752-1.042 28.633 6.512c2.285 2.487 6.063 2.789 8.725 0.73 c6.916-5.423 13.205-11.645 18.703-18.493c2.135-2.65 1.832-6.503-0.689-8.788c-8.047-7.284-10.656-18.879-6.477-28.839 c3.928-9.377 13.43-15.673 23.65-15.673l1.43 0.038c3.318 0.269 6.367-2.286 6.768-5.671 C231.476 120.379 231.487 111.537 230.505 102.78z M115.616 182.27c-36.813 0-66.654-29.841-66.654-66.653 s29.842-66.653 66.654-66.653s66.654 29.841 66.654 66.653c0 12.495-3.445 24.182-9.428 34.176l-29.186-29.187 c2.113-4.982 3.229-10.383 3.228-15.957c0-10.915-4.251-21.176-11.97-28.893c-7.717-7.717-17.978-11.967-28.891-11.967 c-3.642 0-7.267 0.484-10.774 1.439c-1.536 0.419-2.792 1.685-3.201 3.224c-0.418 1.574 0.053 3.187 1.283 4.418 c0 0 14.409 14.52 19.23 19.34c0.505 0.505 0.504 1.71 0.433 2.144l-0.045 0.317c-0.486 5.3-1.423 11.662-2.196 14.107 c-0.104 0.103-0.202 0.19-0.308 0.296c-0.111 0.111-0.213 0.218-0.32 0.328c-2.477 0.795-8.937 1.743-14.321 2.225l0.001-0.029 l-0.242 0.061c-0.043 0.005-0.123 0.011-0.229 0.011c-0.582 0-1.438-0.163-2.216-0.94c-5.018-5.018-18.862-18.763-18.862-18.763 c-1.242-1.238-2.516-1.498-3.365-1.498c-1.979 0-3.751 1.43-4.309 3.481c-3.811 14.103 0.229 29.273 10.546 39.591 c7.719 7.718 17.981 11.968 28.896 11.968c5.574 0 10.975-1.115 15.956-3.228l29.503 29.503 C141.125 178.412 128.825 182.27 115.616 182.27z" FillRule="NonZero"/>
</Path.Data>
</Path>
</Canvas>
</Viewbox>
</DataTemplate>
</ResourceDictionary>

BIN
src/Tyrant/Images/Icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 KiB

BIN
src/Tyrant/Images/Icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 760 KiB

View file

@ -0,0 +1,55 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Tyrant")]
[assembly: AssemblyDescription("Tyrant - RE Engine Extractor")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Philip/Scobalula")]
[assembly: AssemblyProduct("Tyrant")]
[assembly: AssemblyCopyright("Copyright © Philip/Scobalula 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Tyrant.Properties
{
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Tyrant.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}

View file

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Tyrant.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

View file

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View file

@ -0,0 +1,39 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="{x:Type Button}">
<Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
<Setter Property="Background" Value="#FF2D2D2D"/>
<Setter Property="BorderBrush" Value="#FF2D2D2D"/>
<Setter Property="Foreground" Value="#FFFFFFFF"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Padding" Value="1"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="true">
<ContentPresenter x:Name="contentPresenter" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsDefaulted" Value="true">
<Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Background" TargetName="border" Value="#FF3D3D3D"/>
<Setter Property="BorderBrush" TargetName="border" Value="#FF3D3D3D"/>
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter Property="Background" TargetName="border" Value="#FF2A2A2A"/>
<Setter Property="BorderBrush" TargetName="border" Value="#FF2A2A2A"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Background" TargetName="border" Value="#FF909090"/>
<Setter Property="BorderBrush" TargetName="border" Value="#FF909090"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

View file

@ -0,0 +1,75 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style x:Key="FocusVisual">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Rectangle Margin="2" SnapsToDevicePixels="true" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" StrokeThickness="1" StrokeDashArray="1 2"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<SolidColorBrush x:Key="OptionMark.Static.Background" Color="#FFFFFFFF"/>
<SolidColorBrush x:Key="OptionMark.Static.Border" Color="#FF707070"/>
<Style x:Key="OptionMarkFocusVisual">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Rectangle Margin="14,0,0,0" SnapsToDevicePixels="true" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" StrokeThickness="1" StrokeDashArray="1 2"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type CheckBox}">
<Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
<Setter Property="Background" Value="{x:Null}"/>
<Setter Property="BorderBrush" Value="#FF7f8c8d"/>
<Setter Property="Foreground" Value="#FF000000"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type CheckBox}">
<Grid x:Name="templateRoot" Background="Transparent" SnapsToDevicePixels="True">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border x:Name="checkBoxBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="1" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
<Grid x:Name="markGrid">
<Path x:Name="optionMark" Data="F1 M 9.97498,1.22334L 4.6983,9.09834L 4.52164,9.09834L 0,5.19331L 1.27664,3.52165L 4.255,6.08833L 8.33331,1.52588e-005L 9.97498,1.22334 Z " Fill="#FF000000" Margin="1" Opacity="0" Stretch="None"/>
<Rectangle x:Name="indeterminateMark" Fill="#FF000000" Margin="2" Opacity="0"/>
</Grid>
</Border>
<ContentPresenter x:Name="contentPresenter" Grid.Column="1" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="HasContent" Value="true">
<Setter Property="FocusVisualStyle" Value="{StaticResource OptionMarkFocusVisual}"/>
<Setter Property="Padding" Value="4,-1,0,0"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="BorderBrush" TargetName="checkBoxBorder" Value="#FFFFFFFF"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Background" TargetName="checkBoxBorder" Value="#FF7f8c8d"/>
<Setter Property="BorderBrush" TargetName="checkBoxBorder" Value="#FF7f8c8d"/>
</Trigger>
<Trigger Property="IsChecked" Value="true">
<Setter Property="Background" TargetName="checkBoxBorder" Value="#FFFFFFFF"/>
<Setter Property="BorderBrush" TargetName="checkBoxBorder" Value="#FFFFFFFF"/>
<Setter Property="Opacity" TargetName="optionMark" Value="1"/>
<Setter Property="Opacity" TargetName="indeterminateMark" Value="0"/>
</Trigger>
<Trigger Property="IsChecked" Value="{x:Null}">
<Setter Property="Background" TargetName="checkBoxBorder" Value="#FFFFFFFF"/>
<Setter Property="BorderBrush" TargetName="checkBoxBorder" Value="#FFFFFFFF"/>
<Setter Property="Foreground" Value="#FFFFFFFF"/>
<Setter Property="Opacity" TargetName="optionMark" Value="0"/>
<Setter Property="Opacity" TargetName="indeterminateMark" Value="1"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

View file

@ -0,0 +1,39 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="{x:Type Button}" x:Key="IconButtonStyle">
<Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
<Setter Property="Background" Value="{x:Null}"/>
<Setter Property="BorderBrush" Value="{x:Null}"/>
<Setter Property="Foreground" Value="#FFFFFFFF"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Padding" Value="1"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="true">
<ContentPresenter x:Name="contentPresenter" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsDefaulted" Value="true">
<Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Background" TargetName="border" Value="#FF505050"/>
<Setter Property="BorderBrush" TargetName="border" Value="#FF505050"/>
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter Property="Background" TargetName="border" Value="#FF404040"/>
<Setter Property="BorderBrush" TargetName="border" Value="#FF404040"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Background" TargetName="border" Value="#FF7f8c8d"/>
<Setter Property="BorderBrush" TargetName="border" Value="#FF7f8c8d"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

View file

@ -0,0 +1,93 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero2">
<!-- List View Style -->
<Style TargetType="{x:Type ListView}">
<Setter Property="Background" Value="#FF2D2D2D"/>
<Setter Property="BorderBrush" Value="#FF2D2D2D"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Foreground" Value="#FFD0D0D0"/>
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
<Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
<Setter Property="ScrollViewer.PanningMode" Value="Both"/>
<Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListView}">
<Themes:ListBoxChrome x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" RenderMouseOver="{TemplateBinding IsMouseOver}" RenderFocused="{TemplateBinding IsKeyboardFocusWithin}" SnapsToDevicePixels="true">
<ScrollViewer Padding="{TemplateBinding Padding}" Style="{DynamicResource {x:Static GridView.GridViewScrollViewerStyleKey}}">
<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</ScrollViewer>
</Themes:ListBoxChrome>
<ControlTemplate.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsGrouping" Value="true"/>
<Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false"/>
</MultiTrigger.Conditions>
<Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- List View Item Style -->
<Style TargetType="{x:Type ListViewItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListViewItem}">
<Border x:Name="Border" BorderBrush="{x:Null}" BorderThickness="0" Background="{TemplateBinding Background}" SnapsToDevicePixels="true">
<GridViewRowPresenter Columns="{TemplateBinding GridView.ColumnCollection}" Content="{TemplateBinding Content}"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="true">
<Setter Property="Background" Value="#FF808080"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- Grid View Column Grip -->
<Style x:Key="GridViewColumnHeaderGripper" TargetType="Thumb">
<Setter Property="Width" Value="18"/>
<Setter Property="Background" Value="{x:Null}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Thumb}">
<Border Padding="{TemplateBinding Padding}" Background="Transparent">
<Rectangle HorizontalAlignment="Center" Width="1" Fill="{TemplateBinding Background}"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="BorderBrush">
<Setter.Value>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="0"/>
<GradientStop Color="White" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type GridViewColumnHeader}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GridViewColumnHeader}">
<Grid>
<Border BorderThickness="1,2,1,0" BorderBrush="{x:Null}" Background="#FF464646">
<TextBlock x:Name="ContentHeader" Text="{TemplateBinding Content}" Padding="5,5,5,5" Width="{TemplateBinding Width}" VerticalAlignment="Center" />
</Border>
<Thumb x:Name="PART_HeaderGripper" HorizontalAlignment="Right" Margin="0,0,-9,0" Style="{StaticResource GridViewColumnHeaderGripper}" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Foreground" Value="#FFB0B0B0" />
<Setter Property="IsHitTestVisible" Value="True"/>
<Setter Property="HorizontalContentAlignment" Value="Left"></Setter>
</Style>
</ResourceDictionary>

View file

@ -0,0 +1,64 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Greyhound.UI">
<Style TargetType="{x:Type ProgressBar}">
<Setter Property="Foreground" Value="#FF2980b9"/>
<Setter Property="Background" Value="#FF252526"/>
<Setter Property="BorderBrush" Value="#FF252526"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ProgressBar}">
<Grid x:Name="TemplateRoot">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Determinate"/>
<VisualState x:Name="Indeterminate">
<Storyboard RepeatBehavior="Forever">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="Animation">
<EasingDoubleKeyFrame KeyTime="0" Value="0.25"/>
<EasingDoubleKeyFrame KeyTime="0:0:1" Value="0.25"/>
<EasingDoubleKeyFrame KeyTime="0:0:2" Value="0.25"/>
</DoubleAnimationUsingKeyFrames>
<PointAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransformOrigin)" Storyboard.TargetName="Animation">
<EasingPointKeyFrame KeyTime="0" Value="-0.5,0.5"/>
<EasingPointKeyFrame KeyTime="0:0:1" Value="0.5,0.5"/>
<EasingPointKeyFrame KeyTime="0:0:2" Value="1.5,0.5"/>
</PointAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}"/>
<Rectangle x:Name="PART_Track"/>
<Grid x:Name="PART_Indicator" ClipToBounds="true" HorizontalAlignment="Left">
<Rectangle x:Name="Indicator" Fill="{TemplateBinding Foreground}"/>
<Rectangle x:Name="Animation" Fill="{TemplateBinding Foreground}" RenderTransformOrigin="0.5,0.5">
<Rectangle.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</Rectangle.RenderTransform>
</Rectangle>
</Grid>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="Orientation" Value="Vertical">
<Setter Property="LayoutTransform" TargetName="TemplateRoot">
<Setter.Value>
<RotateTransform Angle="-90"/>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsIndeterminate" Value="true">
<Setter Property="Visibility" TargetName="Indicator" Value="Collapsed"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

View file

@ -0,0 +1,50 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="{x:Type RadioButton}">
<Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
<Setter Property="Background" Value="{x:Null}"/>
<Setter Property="BorderBrush" Value="#FF7f8c8d"/>
<Setter Property="Foreground" Value="#FFFFFFFF"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RadioButton}">
<Grid x:Name="templateRoot" Background="Transparent" SnapsToDevicePixels="True">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border x:Name="radioButtonBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="1,1,2,1" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
<Grid x:Name="markGrid" Margin="2">
<Ellipse x:Name="optionMark" Fill="#FF000000" MinWidth="6" MinHeight="6" Opacity="0"/>
</Grid>
</Border>
<ContentPresenter x:Name="contentPresenter" Grid.Column="1" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="HasContent" Value="true">
<Setter Property="FocusVisualStyle" Value="{StaticResource OptionMarkFocusVisual}"/>
<Setter Property="Padding" Value="4,-1,0,0"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="BorderBrush" TargetName="radioButtonBorder" Value="#FFFFFFFF"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Background" TargetName="radioButtonBorder" Value="#FFFFFFFF"/>
<Setter Property="BorderBrush" TargetName="radioButtonBorder" Value="#FFFFFFFF"/>
</Trigger>
<Trigger Property="IsChecked" Value="true">
<Setter Property="Background" TargetName="radioButtonBorder" Value="#FFFFFFFF"/>
<Setter Property="BorderBrush" TargetName="radioButtonBorder" Value="#FFFFFFFF"/>
<Setter Property="Opacity" TargetName="optionMark" Value="1"/>
</Trigger>
<Trigger Property="IsChecked" Value="{x:Null}">
<Setter Property="Opacity" TargetName="optionMark" Value="0.56"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

View file

@ -0,0 +1,246 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ControlTemplate x:Key="SliderThumbHorizontalTop" TargetType="{x:Type Thumb}">
<Grid HorizontalAlignment="Center" UseLayoutRounding="True" VerticalAlignment="Center">
<Path x:Name="grip" Data="M 0,6 C0,6 5.5,0 5.5,0 5.5,0 11,6 11,6 11,6 11,18 11,18 11,18 0,18 0,18 0,18 0,6 0,6 z" Fill="#FF2980b9" Stretch="Fill" SnapsToDevicePixels="True" Stroke="#FF2980b9" StrokeThickness="1" UseLayoutRounding="True" VerticalAlignment="Center"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Fill" TargetName="grip" Value="#FF00CCFF"/>
<Setter Property="Stroke" TargetName="grip" Value="#FF00CCFF"/>
</Trigger>
<Trigger Property="IsDragging" Value="true">
<Setter Property="Fill" TargetName="grip" Value="#FF3498db"/>
<Setter Property="Stroke" TargetName="grip" Value="#FF3498db"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Fill" TargetName="grip" Value="#FF7f8c8d"/>
<Setter Property="Stroke" TargetName="grip" Value="#FF7f8c8d"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<ControlTemplate x:Key="SliderThumbHorizontalBottom" TargetType="{x:Type Thumb}">
<Grid HorizontalAlignment="Center" UseLayoutRounding="True" VerticalAlignment="Center">
<Path x:Name="grip" Data="M 0,12 C0,12 5.5,18 5.5,18 5.5,18 11,12 11,12 11,12 11,0 11,0 11,0 0,0 0,0 0,0 0,12 0,12 z" Fill="#FF2980b9" Stretch="Fill" SnapsToDevicePixels="True" Stroke="#FF2980b9" StrokeThickness="1" UseLayoutRounding="True" VerticalAlignment="Center"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Fill" TargetName="grip" Value="#FF00CCFF"/>
<Setter Property="Stroke" TargetName="grip" Value="#FF00CCFF"/>
</Trigger>
<Trigger Property="IsDragging" Value="true">
<Setter Property="Fill" TargetName="grip" Value="#FF3498db"/>
<Setter Property="Stroke" TargetName="grip" Value="#FF3498db"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Fill" TargetName="grip" Value="#FF7f8c8d"/>
<Setter Property="Stroke" TargetName="grip" Value="#FF7f8c8d"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<SolidColorBrush x:Key="SliderThumb.Track.Border" Color="#FFD6D6D6"/>
<SolidColorBrush x:Key="SliderThumb.Track.Background" Color="#FFE7EAEA"/>
<Style x:Key="RepeatButtonTransparent" TargetType="{x:Type RepeatButton}">
<Setter Property="OverridesDefaultStyle" Value="true"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Focusable" Value="false"/>
<Setter Property="IsTabStop" Value="false"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RepeatButton}">
<Rectangle Fill="{TemplateBinding Background}" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<ControlTemplate x:Key="SliderThumbHorizontalDefault" TargetType="{x:Type Thumb}">
<Grid HorizontalAlignment="Center" UseLayoutRounding="True" VerticalAlignment="Center">
<Path x:Name="grip" Data="M 0,0 C0,0 11,0 11,0 11,0 11,18 11,18 11,18 0,18 0,18 0,18 0,0 0,0 z" Fill="#FF2980b9" Stretch="Fill" SnapsToDevicePixels="True" Stroke="#FF2980b9" StrokeThickness="1" UseLayoutRounding="True" VerticalAlignment="Center"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Fill" TargetName="grip" Value="#FF00CCFF"/>
<Setter Property="Stroke" TargetName="grip" Value="#FF00CCFF"/>
</Trigger>
<Trigger Property="IsDragging" Value="true">
<Setter Property="Fill" TargetName="grip" Value="#FF3498db"/>
<Setter Property="Stroke" TargetName="grip" Value="#FF3498db"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Fill" TargetName="grip" Value="#FF7f8c8d"/>
<Setter Property="Stroke" TargetName="grip" Value="#FF7f8c8d"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<ControlTemplate x:Key="SliderHorizontal" TargetType="{x:Type Slider}">
<Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto" MinHeight="{TemplateBinding MinHeight}"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TickBar x:Name="TopTick" Fill="{TemplateBinding Foreground}" Height="4" Margin="0,0,0,2" Placement="Top" Grid.Row="0" Visibility="Collapsed"/>
<TickBar x:Name="BottomTick" Fill="{TemplateBinding Foreground}" Height="4" Margin="0,2,0,0" Placement="Bottom" Grid.Row="2" Visibility="Collapsed"/>
<Border x:Name="TrackBackground" BorderBrush="#FF252526" BorderThickness="1" Background="#FF252526" Height="8.0" Margin="5,0" Grid.Row="1" VerticalAlignment="center">
<Canvas Margin="-6,-1">
<Rectangle x:Name="PART_SelectionRange" Fill="#FF252526" Height="4.0" Visibility="Hidden"/>
</Canvas>
</Border>
<Track x:Name="PART_Track" Grid.Row="1">
<Track.DecreaseRepeatButton>
<RepeatButton Command="{x:Static Slider.DecreaseLarge}" Style="{StaticResource RepeatButtonTransparent}"/>
</Track.DecreaseRepeatButton>
<Track.IncreaseRepeatButton>
<RepeatButton Command="{x:Static Slider.IncreaseLarge}" Style="{StaticResource RepeatButtonTransparent}"/>
</Track.IncreaseRepeatButton>
<Track.Thumb>
<Thumb x:Name="Thumb" Focusable="False" Height="18" OverridesDefaultStyle="True" Template="{StaticResource SliderThumbHorizontalDefault}" VerticalAlignment="Center" Width="11"/>
</Track.Thumb>
</Track>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="TickPlacement" Value="TopLeft">
<Setter Property="Visibility" TargetName="TopTick" Value="Visible"/>
<Setter Property="Template" TargetName="Thumb" Value="{StaticResource SliderThumbHorizontalTop}"/>
<Setter Property="Margin" TargetName="TrackBackground" Value="5,2,5,0"/>
</Trigger>
<Trigger Property="TickPlacement" Value="BottomRight">
<Setter Property="Visibility" TargetName="BottomTick" Value="Visible"/>
<Setter Property="Template" TargetName="Thumb" Value="{StaticResource SliderThumbHorizontalBottom}"/>
<Setter Property="Margin" TargetName="TrackBackground" Value="5,0,5,2"/>
</Trigger>
<Trigger Property="TickPlacement" Value="Both">
<Setter Property="Visibility" TargetName="TopTick" Value="Visible"/>
<Setter Property="Visibility" TargetName="BottomTick" Value="Visible"/>
</Trigger>
<Trigger Property="IsSelectionRangeEnabled" Value="true">
<Setter Property="Visibility" TargetName="PART_SelectionRange" Value="Visible"/>
</Trigger>
<Trigger Property="IsKeyboardFocused" Value="true">
<Setter Property="Foreground" TargetName="Thumb" Value="Blue"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<ControlTemplate x:Key="SliderThumbVerticalLeft" TargetType="{x:Type Thumb}">
<Grid HorizontalAlignment="Center" UseLayoutRounding="True" VerticalAlignment="Center">
<Path x:Name="grip" Data="M 6,11 C6,11 0,5.5 0,5.5 0,5.5 6,0 6,0 6,0 18,0 18,0 18,0 18,11 18,11 18,11 6,11 6,11 z" Fill="#FF2980b9" Stretch="Fill" Stroke="#FF2980b9"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Fill" TargetName="grip" Value="#FF00CCFF"/>
<Setter Property="Stroke" TargetName="grip" Value="#FF00CCFF"/>
</Trigger>
<Trigger Property="IsDragging" Value="true">
<Setter Property="Fill" TargetName="grip" Value="#FF3498db"/>
<Setter Property="Stroke" TargetName="grip" Value="#FF3498db"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Fill" TargetName="grip" Value="#FF7f8c8d"/>
<Setter Property="Stroke" TargetName="grip" Value="#FF7f8c8d"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<ControlTemplate x:Key="SliderThumbVerticalRight" TargetType="{x:Type Thumb}">
<Grid HorizontalAlignment="Center" UseLayoutRounding="True" VerticalAlignment="Center">
<Path x:Name="grip" Data="M 12,11 C12,11 18,5.5 18,5.5 18,5.5 12,0 12,0 12,0 0,0 0,0 0,0 0,11 0,11 0,11 12,11 12,11 z" Fill="#FF2980b9" Stretch="Fill" Stroke="#FF2980b9"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Fill" TargetName="grip" Value="#FF00CCFF"/>
<Setter Property="Stroke" TargetName="grip" Value="#FF00CCFF"/>
</Trigger>
<Trigger Property="IsDragging" Value="true">
<Setter Property="Fill" TargetName="grip" Value="#FF3498db"/>
<Setter Property="Stroke" TargetName="grip" Value="#FF3498db"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Fill" TargetName="grip" Value="#FF7f8c8d"/>
<Setter Property="Stroke" TargetName="grip" Value="#FF7f8c8d"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<ControlTemplate x:Key="SliderThumbVerticalDefault" TargetType="{x:Type Thumb}">
<Grid HorizontalAlignment="Center" UseLayoutRounding="True" VerticalAlignment="Center">
<Path x:Name="grip" Data="M0.5,0.5 L18.5,0.5 18.5,11.5 0.5,11.5z" Fill="#FF2980b9" Stretch="Fill" Stroke="#FF2980b9"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Fill" TargetName="grip" Value="#FF00CCFF"/>
<Setter Property="Stroke" TargetName="grip" Value="#FF00CCFF"/>
</Trigger>
<Trigger Property="IsDragging" Value="true">
<Setter Property="Fill" TargetName="grip" Value="#FF3498db"/>
<Setter Property="Stroke" TargetName="grip" Value="#FF3498db"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Fill" TargetName="grip" Value="#FF7f8c8d"/>
<Setter Property="Stroke" TargetName="grip" Value="#FF7f8c8d"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<ControlTemplate x:Key="SliderVertical" TargetType="{x:Type Slider}">
<Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition MinWidth="{TemplateBinding MinWidth}" Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TickBar x:Name="TopTick" Grid.Column="0" Fill="{TemplateBinding Foreground}" Margin="0,0,2,0" Placement="Left" Visibility="Collapsed" Width="4"/>
<TickBar x:Name="BottomTick" Grid.Column="2" Fill="{TemplateBinding Foreground}" Margin="2,0,0,0" Placement="Right" Visibility="Collapsed" Width="4"/>
<Border x:Name="TrackBackground" BorderBrush="#FF252526" BorderThickness="1" Background="#FF252526" Grid.Column="1" HorizontalAlignment="center" Margin="0,5" Width="4.0">
<Canvas Margin="-1,-6">
<Rectangle x:Name="PART_SelectionRange" Fill="#FF252526" Visibility="Hidden" Width="4.0"/>
</Canvas>
</Border>
<Track x:Name="PART_Track" Grid.Column="1">
<Track.DecreaseRepeatButton>
<RepeatButton Command="{x:Static Slider.DecreaseLarge}" Style="{StaticResource RepeatButtonTransparent}"/>
</Track.DecreaseRepeatButton>
<Track.IncreaseRepeatButton>
<RepeatButton Command="{x:Static Slider.IncreaseLarge}" Style="{StaticResource RepeatButtonTransparent}"/>
</Track.IncreaseRepeatButton>
<Track.Thumb>
<Thumb x:Name="Thumb" Focusable="False" Height="11" OverridesDefaultStyle="True" Template="{StaticResource SliderThumbVerticalDefault}" VerticalAlignment="Top" Width="18"/>
</Track.Thumb>
</Track>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="TickPlacement" Value="TopLeft">
<Setter Property="Visibility" TargetName="TopTick" Value="Visible"/>
<Setter Property="Template" TargetName="Thumb" Value="{StaticResource SliderThumbVerticalLeft}"/>
<Setter Property="Margin" TargetName="TrackBackground" Value="2,5,0,5"/>
</Trigger>
<Trigger Property="TickPlacement" Value="BottomRight">
<Setter Property="Visibility" TargetName="BottomTick" Value="Visible"/>
<Setter Property="Template" TargetName="Thumb" Value="{StaticResource SliderThumbVerticalRight}"/>
<Setter Property="Margin" TargetName="TrackBackground" Value="0,5,2,5"/>
</Trigger>
<Trigger Property="TickPlacement" Value="Both">
<Setter Property="Visibility" TargetName="TopTick" Value="Visible"/>
<Setter Property="Visibility" TargetName="BottomTick" Value="Visible"/>
</Trigger>
<Trigger Property="IsSelectionRangeEnabled" Value="true">
<Setter Property="Visibility" TargetName="PART_SelectionRange" Value="Visible"/>
</Trigger>
<Trigger Property="IsKeyboardFocused" Value="true">
<Setter Property="Foreground" TargetName="Thumb" Value="Blue"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<Style TargetType="{x:Type Slider}">
<Setter Property="Stylus.IsPressAndHoldEnabled" Value="false"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="Foreground" Value="#FF2980b9"/>
<Setter Property="Template" Value="{StaticResource SliderHorizontal}"/>
<Style.Triggers>
<Trigger Property="Orientation" Value="Vertical">
<Setter Property="Template" Value="{StaticResource SliderVertical}"/>
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary>

View file

@ -0,0 +1,198 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<LinearGradientBrush x:Key="TabItem.Static.Background" EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#F0F0F0" Offset="0.0"/>
<GradientStop Color="#E5E5E5" Offset="1.0"/>
</LinearGradientBrush>
<SolidColorBrush x:Key="TabItem.Static.Border" Color="#FFFFFF"/>
<SolidColorBrush x:Key="TabItem.MouseOver.Background" Color="#FFFFFF"/>
<SolidColorBrush x:Key="TabItem.MouseOver.Border" Color="#7EB4EA"/>
<SolidColorBrush x:Key="TabItem.Disabled.Background" Color="#F0F0F0"/>
<SolidColorBrush x:Key="TabItem.Disabled.Border" Color="#D9D9D9"/>
<SolidColorBrush x:Key="TabItem.Selected.Border" Color="#ACACAC"/>
<SolidColorBrush x:Key="TabItem.Selected.Background" Color="#FFFFFF"/>
<Style TargetType="{x:Type TabItem}">
<Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
<Setter Property="Foreground" Value="Black"/>
<Setter Property="Background" Value="{StaticResource TabItem.Static.Background}"/>
<Setter Property="BorderBrush" Value="{StaticResource TabItem.Static.Border}"/>
<Setter Property="Margin" Value="0"/>
<Setter Property="Padding" Value="6,2,6,2"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="VerticalContentAlignment" Value="Stretch"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabItem}">
<Grid x:Name="templateRoot" SnapsToDevicePixels="true">
<Border x:Name="mainBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1,1,1,0" Background="{TemplateBinding Background}" Margin="0">
<Border x:Name="innerBorder" BorderBrush="{StaticResource TabItem.Selected.Border}" BorderThickness="1,1,1,0" Background="{StaticResource TabItem.Selected.Background}" Margin="-1" Opacity="0"/>
</Border>
<ContentPresenter x:Name="contentPresenter" ContentSource="Header" Focusable="False" HorizontalAlignment="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
</Grid>
<ControlTemplate.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true"/>
<Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Left"/>
</MultiDataTrigger.Conditions>
<Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Background}"/>
<Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Border}"/>
<Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,0,1"/>
<Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,0,1"/>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true"/>
<Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Bottom"/>
</MultiDataTrigger.Conditions>
<Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Background}"/>
<Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Border}"/>
<Setter Property="BorderThickness" TargetName="innerBorder" Value="1,0,1,1"/>
<Setter Property="BorderThickness" TargetName="mainBorder" Value="1,0,1,1"/>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true"/>
<Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Right"/>
</MultiDataTrigger.Conditions>
<Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Background}"/>
<Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Border}"/>
<Setter Property="BorderThickness" TargetName="innerBorder" Value="0,1,1,1"/>
<Setter Property="BorderThickness" TargetName="mainBorder" Value="0,1,1,1"/>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true"/>
<Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Top"/>
</MultiDataTrigger.Conditions>
<Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Background}"/>
<Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Border}"/>
<Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,1,0"/>
<Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,1,0"/>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="false"/>
<Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Left"/>
</MultiDataTrigger.Conditions>
<Setter Property="Opacity" TargetName="contentPresenter" Value="0.56"/>
<Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Background}"/>
<Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Border}"/>
<Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,0,1"/>
<Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,0,1"/>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="false"/>
<Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Bottom"/>
</MultiDataTrigger.Conditions>
<Setter Property="Opacity" TargetName="contentPresenter" Value="0.56"/>
<Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Background}"/>
<Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Border}"/>
<Setter Property="BorderThickness" TargetName="innerBorder" Value="1,0,1,1"/>
<Setter Property="BorderThickness" TargetName="mainBorder" Value="1,0,1,1"/>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="false"/>
<Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Right"/>
</MultiDataTrigger.Conditions>
<Setter Property="Opacity" TargetName="contentPresenter" Value="0.56"/>
<Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Background}"/>
<Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Border}"/>
<Setter Property="BorderThickness" TargetName="innerBorder" Value="0,1,1,1"/>
<Setter Property="BorderThickness" TargetName="mainBorder" Value="0,1,1,1"/>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="false"/>
<Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Top"/>
</MultiDataTrigger.Conditions>
<Setter Property="Opacity" TargetName="contentPresenter" Value="0.56"/>
<Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Background}"/>
<Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Border}"/>
<Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,1,0"/>
<Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,1,0"/>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="false"/>
<Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Left"/>
</MultiDataTrigger.Conditions>
<Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,0,1"/>
<Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,0,1"/>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="true"/>
<Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Left"/>
</MultiDataTrigger.Conditions>
<Setter Property="Panel.ZIndex" Value="1"/>
<Setter Property="Margin" Value="-2,-2,0,-2"/>
<Setter Property="Opacity" TargetName="innerBorder" Value="1"/>
<Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,0,1"/>
<Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,0,1"/>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="false"/>
<Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Bottom"/>
</MultiDataTrigger.Conditions>
<Setter Property="BorderThickness" TargetName="innerBorder" Value="1,0,1,1"/>
<Setter Property="BorderThickness" TargetName="mainBorder" Value="1,0,1,1"/>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="true"/>
<Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Bottom"/>
</MultiDataTrigger.Conditions>
<Setter Property="Panel.ZIndex" Value="1"/>
<Setter Property="Margin" Value="-2,0,-2,-2"/>
<Setter Property="Opacity" TargetName="innerBorder" Value="1"/>
<Setter Property="BorderThickness" TargetName="innerBorder" Value="1,0,1,1"/>
<Setter Property="BorderThickness" TargetName="mainBorder" Value="1,0,1,1"/>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="false"/>
<Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Right"/>
</MultiDataTrigger.Conditions>
<Setter Property="BorderThickness" TargetName="innerBorder" Value="0,1,1,1"/>
<Setter Property="BorderThickness" TargetName="mainBorder" Value="0,1,1,1"/>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="true"/>
<Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Right"/>
</MultiDataTrigger.Conditions>
<Setter Property="Panel.ZIndex" Value="1"/>
<Setter Property="Margin" Value="0,-2,-2,-2"/>
<Setter Property="Opacity" TargetName="innerBorder" Value="1"/>
<Setter Property="BorderThickness" TargetName="innerBorder" Value="0,1,1,1"/>
<Setter Property="BorderThickness" TargetName="mainBorder" Value="0,1,1,1"/>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="false"/>
<Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Top"/>
</MultiDataTrigger.Conditions>
<Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,1,0"/>
<Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,1,0"/>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="true"/>
<Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Top"/>
</MultiDataTrigger.Conditions>
<Setter Property="Panel.ZIndex" Value="1"/>
<Setter Property="Margin" Value="-2,-2,-2,0"/>
<Setter Property="Opacity" TargetName="innerBorder" Value="1"/>
<Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,1,0"/>
<Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,1,0"/>
</MultiDataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

View file

@ -0,0 +1,46 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="{x:Type TextBox}">
<Setter Property="OverridesDefaultStyle" Value="True"/>
<Setter Property="Background" Value="#FF3C3C3C"/>
<Setter Property="BorderBrush" Value="#FF3C3C3C"/>
<Setter Property="Foreground" Value="#FFD0D0D0"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
<Setter Property="HorizontalContentAlignment" Value="Left"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="AllowDrop" Value="true"/>
<Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
<Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBox}">
<Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
<ScrollViewer x:Name="PART_ContentHost" Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Opacity" TargetName="border" Value="0.56"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="BorderBrush" TargetName="border" Value="#FF2980b9"/>
</Trigger>
<Trigger Property="IsKeyboardFocused" Value="true">
<Setter Property="BorderBrush" TargetName="border" Value="#FF2980b9"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsInactiveSelectionHighlightEnabled" Value="true"/>
<Condition Property="IsSelectionActive" Value="false"/>
</MultiTrigger.Conditions>
<Setter Property="SelectionBrush" Value="{DynamicResource {x:Static SystemColors.InactiveSelectionHighlightBrushKey}}"/>
</MultiTrigger>
</Style.Triggers>
</Style>
</ResourceDictionary>

211
src/Tyrant/Tyrant.csproj Normal file
View file

@ -0,0 +1,211 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{E2F82202-0E17-4901-B360-BE6F175FBCA2}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>Tyrant</RootNamespace>
<AssemblyName>Tyrant</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>Icon.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="ByteSize, Version=1.3.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ByteSize.1.3.0\lib\net45\ByteSize.dll</HintPath>
</Reference>
<Reference Include="PresentationFramework.Aero2" />
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Windows\AboutWindow.xaml.cs">
<DependentUpon>AboutWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Helpers\AssetList.cs" />
<Compile Include="Windows\ProgressWindow.xaml.cs">
<DependentUpon>ProgressWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Windows\SettingsWindow.xaml.cs">
<DependentUpon>SettingsWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Helpers\TyrantSettings.cs" />
<Page Include="Icons\AboutIcon.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Windows\AboutWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Icons\ExportIcon.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\OpenFileIcon.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\ExportAllIcon.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\SettingsIcon.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Windows\MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Helpers\Asset.cs" />
<Compile Include="Helpers\MainViewModel.cs" />
<Compile Include="Windows\MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="Windows\ProgressWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Windows\SettingsWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Styles\TabStyle.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Styles\IconButtonStyle.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Styles\ButtonStyle.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Styles\CheckBoxStyle.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Styles\ListViewStyle.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Styles\ProgressBarStyle.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Styles\RadioButtonStyle.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Styles\SliderStyle.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Styles\TextBoxStyle.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="app.manifest">
<SubType>Designer</SubType>
</None>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PhilLibX\src\PhilLibX\PhilLibX.Interop\PhilLibX.Interop.vcxproj">
<Project>{eb08d910-0050-4d56-a799-ca04c41b7014}</Project>
<Name>PhilLibX.Interop</Name>
</ProjectReference>
<ProjectReference Include="..\PhilLibX\src\PhilLibX\PhilLibX\PhilLibX.csproj">
<Project>{0f468d5b-2f30-42f5-9043-920040d83d9d}</Project>
<Name>PhilLibX</Name>
</ProjectReference>
<ProjectReference Include="..\Tyrant.Logic\Tyrant.Logic.csproj">
<Project>{2d3ceff1-8f47-40e9-8597-cdfd6b5ccf73}</Project>
<Name>Tyrant.Logic</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Resource Include="Icon.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,17 @@
<Window x:Class="Tyrant.AboutWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="Tyrant | About" Height="170.5" Width="400" WindowStartupLocation="CenterOwner"
ResizeMode="NoResize">
<Grid Background="#FF373737">
<Label Content="Tyrant - RE Engine Extractor" HorizontalAlignment="Left" Margin="105,10,0,0" VerticalAlignment="Top" Height="27" Width="279" Background="{x:Null}" Foreground="White"/>
<Label Content="Developed by Scobalula" HorizontalAlignment="Left" Margin="105,37,0,0" VerticalAlignment="Top" Height="27" Width="279" Background="{x:Null}" Foreground="White"/>
<Label x:Name="VersionLabel" Content="Version: {0}" HorizontalAlignment="Left" Margin="105,64,0,0" VerticalAlignment="Top" Height="27" Width="279" Background="{x:Null}" Foreground="White"/>
<Button Click="HomePageButtonClick" Content="Github" HorizontalAlignment="Left" Margin="10,0,0,10" Width="90" Height="27" VerticalAlignment="Bottom"/>
<Image Margin="10,10,0,0" Stretch="Fill" HorizontalAlignment="Left" Width="84" Height="62" VerticalAlignment="Top"/>
<Image Margin="10,10,295,42" Source="/Tyrant;component/Icon.ico" Stretch="Fill"/>
</Grid>
</Window>

View file

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Tyrant
{
/// <summary>
/// Interaction logic for AboutWindow.xaml
/// </summary>
public partial class AboutWindow : Window
{
public AboutWindow()
{
InitializeComponent();
VersionLabel.Content = string.Format("Version: {0}", Assembly.GetExecutingAssembly().GetName().Version);
}
/// <summary>
/// Opens homepage
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void HomePageButtonClick(object sender, RoutedEventArgs e)
{
Process.Start("https://github.com/Scobalula/Tyrant");
}
}
}

View file

@ -0,0 +1,52 @@
<Window x:Class="Tyrant.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="Tyrant | RE Engine Extractor"
Background="#FF373737"
Width="960" Height="540"
MinWidth="640" MinHeight="360"
Closing="MainWindowClosing">
<Window.TaskbarItemInfo>
<TaskbarItemInfo x:Name="TaskBarProgress"></TaskbarItemInfo>
</Window.TaskbarItemInfo>
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<!-- Side Bar -->
<TextBox VerticalContentAlignment="Center"
Text="{Binding Path=FilterString, UpdateSourceTrigger=PropertyChanged}"
Height="28" Margin="41,0,0,0"
TextWrapping="NoWrap"
VerticalAlignment="Top"/>
<!-- Asset List -->
<ListView x:Name="AssetList"
MouseDoubleClick="AssetListMouseDoubleClick"
VirtualizingStackPanel.IsVirtualizing="True"
VirtualizingStackPanel.VirtualizationMode="Recycling"
AllowDrop="True"
Margin="41,28,0,0"
Foreground="White"
ItemsSource="{Binding Assets}">
<ListView.View>
<GridView>
<GridViewColumn Width="512" Header="Name" DisplayMemberBinding="{Binding Name}"/>
<GridViewColumn Width="128" Header="Type" DisplayMemberBinding="{Binding Type}"/>
<GridViewColumn Width="128" Header="Size" DisplayMemberBinding="{Binding DisplaySize}"/>
</GridView>
</ListView.View>
</ListView>
<Button ContentTemplate="{StaticResource SettingsIcon}" Style="{StaticResource IconButtonStyle}" Click="SettingsClick" HorizontalAlignment="Left" Width="41" Height="41" VerticalAlignment="Bottom"/>
<Button ContentTemplate="{StaticResource ExportAllIcon}" Style="{StaticResource IconButtonStyle}" Click="ExportAllClick" HorizontalAlignment="Left" Width="41" Margin="0,41,0,0" Height="41" VerticalAlignment="Top"/>
<Button ContentTemplate="{StaticResource OpenFileIcon}" Style="{StaticResource IconButtonStyle}" Click="OpenFileClick" HorizontalAlignment="Left" Width="41" Height="41" VerticalAlignment="Top"/>
<Button ContentTemplate="{StaticResource AboutIcon}" Style="{StaticResource IconButtonStyle}" Click="AboutClick" HorizontalAlignment="Left" Width="41" Height="41" VerticalAlignment="Bottom" Margin="0,0,0,41"/>
<Button ContentTemplate="{StaticResource ExportIcon}" Style="{StaticResource IconButtonStyle}" Click="ExportSelectedClick" HorizontalAlignment="Left" Width="41" Margin="0,82,0,0" Height="41" VerticalAlignment="Top"/>
<Rectangle x:Name="Dimmer" Fill="#7F000000" Visibility="Hidden"/>
</Grid>
</Window>

View file

@ -0,0 +1,640 @@
// ------------------------------------------------------------------------
// Tyrant - RE Engine Extractor
// Copyright (C) 2018 Philip/Scobalula
//
// 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/>.
// ------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using Tyrant.Logic;
using PhilLibX;
using PhilLibX.Imaging;
using Microsoft.Win32;
using PhilLibX.Cryptography.Hash;
using System.Threading;
namespace Tyrant
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
/// <summary>
/// Gets or Sets the current loaded package
/// </summary>
private Package ActivePackage { get; set; }
/// <summary>
/// Gets the name cache
/// </summary>
private NameCache Cache { get; } = new NameCache();
/// <summary>
/// Gets the Settings
/// </summary>
private TyrantSettings Settings { get; } = new TyrantSettings("Settings.tcfg");
/// <summary>
/// Gets the Log
/// </summary>
private StreamWriter LogStream { get; } = new StreamWriter("Log.txt", true);
/// <summary>
/// Gets or Sets whether or not to end the current thread
/// </summary>
private bool EndThread = false;
/// <summary>
/// Directory prefixes
/// </summary>
private string[] DirectoryPrefixes =
{
"natives/x64/streaming/",
"natives/x64/",
};
/// <summary>
/// Suffixes to try when resolving linked assets
/// </summary>
private string[] FileSuffixes =
{
".mdf2.10",
"_mat.mdf2.10",
".10",
".11",
};
/// <summary>
/// Supported Image Formats
/// </summary>
private string[] ImageFormats =
{
"dds",
"png",
"tiff",
"jpg",
"bmp",
"tga",
};
/// <summary>
/// Supported Model Formats
/// </summary>
private string[] ModelFormats =
{
"ma",
"semodel",
"obj",
"smd",
"ascii",
};
/// <summary>
/// Supported Image Formats
/// </summary>
private string[] AnimationFormats =
{
"seanim",
};
/// <summary>
/// Gets the ViewModel
/// </summary>
public MainViewModel ViewModel { get; } = new MainViewModel();
/// <summary>
///
/// </summary>
public MainWindow()
{
Cache.LoadFolder("TyrantCache");
InitializeComponent();
DataContext = ViewModel;
}
/// <summary>
/// Loads a Package
/// </summary>
public void LoadPackage(string path)
{
try
{
ViewModel.Assets.ClearAssets();
ActivePackage?.Dispose();
ActivePackage = new Package(path);
List<Asset> results = new List<Asset>(ActivePackage.Entries.Count);
foreach(var entry in ActivePackage.Entries)
{
if(Cache.Entries.TryGetValue(entry.Key, out var name))
{
string type = "Unknown";
if (name.Contains(".tex."))
{
if (Settings["ShowTextures", "Yes"] == "Yes")
type = "Texture";
else
continue;
}
else if (name.Contains(".mesh."))
{
if (Settings["ShowModels", "Yes"] == "Yes")
type = "Mesh";
else
continue;
}
else if (name.Contains(".motlist."))
{
if (Settings["ShowAnims", "Yes"] == "Yes")
type = "MotionList";
else
continue;
}
else if (name.Contains(".mot."))
{
if (Settings["ShowAnims", "Yes"] == "Yes")
type = "Motion";
else
continue;
}
//else if (name.Contains(".bnk.") && Settings["ShowSounds", "Yes"] == "Yes")
// type = "SoundBank";
else if (Settings["ShowAll", "No"] == "Yes")
type = "Unknown";
else
continue;
results.Add(new Asset(name, type, entry.Value));
}
else if (Settings["ShowAll", "No"] == "Yes")
{
results.Add(new Asset("asset_" + entry.Key.ToString("x"), "Unknown", entry.Value));
}
}
ViewModel.Assets.AddAssets(results.OrderBy(x => x.Name).OrderBy(x => x.Type));
}
catch(Exception e)
{
ActivePackage?.Dispose();
ActivePackage = null;
MessageBox.Show(string.Format("An error occured while loading the package:\n\n{0}", e), "Tryant | Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
/// <summary>
/// Handles cleaning up on close
/// </summary>
private void MainWindowClosing(object sender, CancelEventArgs e)
{
ActivePackage?.Dispose();
Settings.Save("Settings.tcfg");
}
/// <summary>
/// Exports the Image Asset
/// </summary>
private string ExportImage(Package.Entry entry, string name)
{
var path = name.Split('.')[0];
var result = path + ".png";
bool requiresExport = false;
// Determine if we should even bother loading
foreach (var format in ImageFormats)
{
// PNG is default
if (Settings["Export" + format.ToUpper(), format == "png" ? "Yes" : "No"] == "Yes")
{
// Set our path to the last exported type
result = path + "." + format;
if(!File.Exists(path + "." + format))
{
requiresExport = true;
}
}
}
if(requiresExport)
{
using (var image = Texture.Convert(ActivePackage.LoadEntry(entry)))
{
Directory.CreateDirectory(Path.GetDirectoryName(path));
foreach (var format in ImageFormats)
{
if (Settings["Export" + format.ToUpper(), format == "png" ? "Yes" : "No"] == "Yes" && !File.Exists(path + "." + format))
{
// Everything besides DDS we need to decompress & convert
if (format != "dds")
image.ConvertImage(ScratchImage.DXGIFormat.R8G8B8A8UNORM);
image.Save(path + "." + format);
}
}
}
}
return result;
}
/// <summary>
/// Exports a Motion List Asset
/// </summary>
private string ExportMotionList(Package.Entry entry, string name)
{
var scale = float.TryParse(Settings["ModelScale", "1.0"], out var val) ? val : 1.0f;
var motions = MotionList.Convert(ActivePackage.LoadEntry(entry));
var path = name.Split('.')[0];
var folder = Path.Combine(path, motions.Item1);
var result = path;
Directory.CreateDirectory(folder);
foreach(var motion in motions.Item2)
{
var motionPath = Path.Combine(folder, motion.Item1);
if (Settings["ExportSEAnim", "Yes"] == "Yes")
{
motion.Item2.Scale(scale);
motion.Item2.ToSEAnim(motionPath + ".seanim");
}
}
return result;
}
/// <summary>
/// Exports Material Info to a .txt file
/// </summary>
private void ExportMaterialInfo(Model.Material material, string path)
{
try
{
using (var writer = new StreamWriter(path))
{
writer.WriteLine("# Textures");
foreach (var texture in material.Images)
writer.WriteLine("{0}:{1}", texture.Key, texture.Value);
writer.WriteLine("# Settings");
foreach (var setting in material.Settings)
{
writer.Write("{0}:", setting.Key);
var things = (float[])setting.Value;
foreach (var thing in things)
writer.Write("{0} ", thing);
writer.WriteLine();
}
}
}
catch
{
return;
}
}
/// <summary>
/// Exports Material Images
/// </summary>
private void ExportMaterialImages(Model.Material material, string folder)
{
var imageKeys = material.Images.Keys.ToArray();
foreach (var key in imageKeys)
{
// Resolve, we try the streaming folder first, as they contain the highest quality images
// vs the lowest ones loaded in memory
foreach (var prefix in DirectoryPrefixes)
{
var fullPath = prefix + material.Images[key];
foreach (var suffix in FileSuffixes)
{
if (ActivePackage.Entries.TryGetValue(MurMur3.Calculate(Encoding.Unicode.GetBytes(fullPath + suffix)), out var imageFile))
{
try
{
var imagePath = ExportImage(imageFile, Path.Combine(folder, "_images", Path.GetFileNameWithoutExtension(fullPath)));
Directory.CreateDirectory(Path.GetDirectoryName(imagePath));
material.Images[key] = Path.Combine("_images", Path.GetFileName(imagePath));
break;
}
catch
{
continue;
}
}
}
}
}
}
/// <summary>
/// Exports a Model Asset
/// </summary>
private void ExportModel(Package.Entry entry, string name)
{
var scale = float.TryParse(Settings["ModelScale", "1.0"], out var val) ? val : 1.0f;
var models = Mesh.Convert(ActivePackage.LoadEntry(entry));
var path = name.Split('.')[0];
var materials = new Dictionary<string, Model.Material>();
// Attempt to load the materials file
foreach (var prefix in FileSuffixes)
{
if (ActivePackage.Entries.TryGetValue(MurMur3.Calculate(Encoding.Unicode.GetBytes(path.Replace("exported_files\\", "") + prefix)), out var result))
{
try
{
materials = MaterialDefs.Convert(ActivePackage.LoadEntry(result));
break;
}
catch
{
continue;
}
}
}
var folder = Path.GetDirectoryName(path);
Directory.CreateDirectory(folder);
for (int mdl = 0; mdl < models.Count; mdl++)
{
for (int lod = 0; lod < models[mdl].Count; lod++)
{
// Must generate for formats that need it
models[mdl][lod].GenerateGlobalBoneData();
models[mdl][lod].Scale(scale);
foreach (var material in models[mdl][lod].Materials)
{
if (materials.TryGetValue(material.Name, out var fileMtl))
{
material.Images = fileMtl.Images;
material.Settings = fileMtl.Settings;
// Determine image keys as they change depending on shader/type
if (material.Images.ContainsKey("BaseMetalMap"))
material.DiffuseMapName = "BaseMetalMap";
else if (material.Images.ContainsKey("BaseMap"))
material.DiffuseMapName = "BaseMap";
if (material.Images.ContainsKey("NormalRoughnessMap"))
material.NormalMapName = "NormalRoughnessMap";
else if (material.Images.ContainsKey("NormalMap"))
material.NormalMapName = "NormalMap";
}
}
foreach (var material in models[mdl][lod].Materials)
{
if(Settings["ExportMaterialInfo", "Yes"] == "Yes")
ExportMaterialInfo(material, Path.Combine(folder, material.Name + ".txt"));
if (Settings["ExportImagesWithModel", "Yes"] == "Yes")
ExportMaterialImages(material, folder);
}
var result = Path.Combine(folder, string.Format("{0}_model{1}_lod{2}", Path.GetFileNameWithoutExtension(path), mdl, lod));
foreach(var format in ModelFormats)
{
// PNG is default
if (Settings["Export" + format.ToUpper(), format == "semodel" ? "Yes" : "No"] == "Yes")
{
models[mdl][lod].Save(result + "." + format);
}
}
}
}
}
/// <summary>
/// Exports the given asset
/// </summary>
/// <param name="asset"></param>
private void ExportAsset(Asset asset)
{
try
{
Log(string.Format("Exporting {0}", Path.GetFileNameWithoutExtension(asset.Name)), "INFO");
switch (asset.Type)
{
case "Mesh":
ExportModel(asset.PackageEntry, Path.Combine("exported_files", asset.Name));
break;
case "Texture":
ExportImage(asset.PackageEntry, Path.Combine("exported_files", asset.Name));
break;
case "MotionList":
ExportMotionList(asset.PackageEntry, Path.Combine("exported_files", asset.Name));
break;
default:
break;
}
Log(string.Format("Exported {0}", Path.GetFileNameWithoutExtension(asset.Name)), "INFO");
}
catch (Exception e)
{
Log(string.Format("Error has occured while exporting {0}: {1}", Path.GetFileNameWithoutExtension(asset.Name), e), "ERROR");
}
}
/// <summary>
/// Exports the asset on double click
/// </summary>
private void AssetListMouseDoubleClick(object sender, MouseButtonEventArgs e)
{
if (((FrameworkElement)e.OriginalSource).DataContext is Asset asset)
{
ExportAssets(new List<Asset>()
{
asset
});
}
}
/// <summary>
/// Writes to the log in debug
/// </summary>
private void Log(string value, string messageType)
{
lock(LogStream)
{
LogStream.WriteLine("{0} [ {1} ] {2}", DateTime.Now.ToString("dd-MM-yyyy - HH:mm:ss"), messageType.PadRight(12), value);
LogStream.Flush();
}
}
/// <summary>
/// Opens file dialog to open a package
/// </summary>
private void OpenFileClick(object sender, RoutedEventArgs e)
{
ViewModel.Assets.ClearAssets();
ActivePackage?.Dispose();
ActivePackage = null;
GC.Collect();
var dialog = new OpenFileDialog()
{
Title = "Tyrant | Open File",
Filter = "Package files (*.pak)|*.pak|All files (*.*)|*.*"
};
if(dialog.ShowDialog() == true)
{
if(Path.GetExtension(dialog.FileName).ToLower() == ".pak")
{
LoadPackage(dialog.FileName);
}
}
}
/// <summary>
/// Opens settings window
/// </summary>
private void SettingsClick(object sender, RoutedEventArgs e)
{
var settings = new SettingsWindow()
{
Owner = this
};
Dimmer.Visibility = Visibility.Visible;
settings.SetUIFromSettings(Settings);
settings.ShowDialog();
settings.SetSettingsFromUI(Settings);
Dimmer.Visibility = Visibility.Hidden;
}
/// <summary>
/// Sets the dimmer
/// </summary>
private void SetDimmer(Visibility visibility) => Dispatcher.BeginInvoke(new Action(() => Dimmer.Visibility = visibility));
/// <summary>
/// Exports the list of assets
/// </summary>
public void ExportAssets(List<Asset> assets)
{
if (ActivePackage == null)
return;
var progressWindow = new ProgressWindow()
{
Owner = this,
};
Dispatcher.BeginInvoke(new Action(() => progressWindow.ShowDialog()));
progressWindow.SetProgressCount(assets.Count);
new Thread(() =>
{
SetDimmer(Visibility.Visible);
Parallel.ForEach(assets, new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount }, (asset, loop) =>
{
ExportAsset(asset);
if (progressWindow.IncrementProgress() || EndThread)
loop.Break();
});
Dispatcher.BeginInvoke(new Action(() =>
{
GC.Collect();
progressWindow.Complete();
SetDimmer(Visibility.Hidden);
}));
}).Start();
}
/// <summary>
/// Exports selected assets
/// </summary>
private void ExportSelectedClick(object sender, RoutedEventArgs e)
{
var assets = AssetList.Items.Cast<Asset>().ToList();
if (assets.Count == 0)
{
SetDimmer(Visibility.Visible);
MessageBox.Show("There are no assets selected to export. Select assets in the list first.", "Tyrant | Error", MessageBoxButton.OK, MessageBoxImage.Error);
SetDimmer(Visibility.Hidden);
return;
}
ExportAssets(assets);
}
/// <summary>
/// Exports all loaded assets
/// </summary>
private void ExportAllClick(object sender, RoutedEventArgs e)
{
var assets = AssetList.Items.Cast<Asset>().ToList();
if (assets.Count == 0)
{
MessageBox.Show("There are no assets listed to export. Load a Package file first.", "Tyrant | Error", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
ExportAssets(assets);
}
/// <summary>
/// Opens about window
/// </summary>
private void AboutClick(object sender, RoutedEventArgs e)
{
SetDimmer(Visibility.Visible);
new AboutWindow()
{
Owner = this
}.ShowDialog();
SetDimmer(Visibility.Hidden);
}
}
}

View file

@ -0,0 +1,18 @@
<Window x:Class="Tyrant.ProgressWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="#FF373737"
Title="Tyrant | Working"
Height="183" Width="400"
WindowStartupLocation="CenterOwner"
Closing="WindowClosing"
ResizeMode="NoResize">
<Grid>
<Label x:Name="Message" Content="Exporting Assets" Margin="10,10,10,0" VerticalAlignment="Top" Height="52" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Foreground="White" FontSize="22"/>
<Button Content="Cancel" Margin="0,0,10,10" Click="CancelClick" VerticalAlignment="Bottom" Height="25" ToolTip="Cancel the current task." HorizontalAlignment="Right" Width="75"/>
<ProgressBar x:Name="ProgressBar" Height="Auto" Margin="10,67,10,51" Foreground="White"/>
</Grid>
</Window>

View file

@ -0,0 +1,102 @@
// ------------------------------------------------------------------------
// Tyrant - RE Engine Extractor
// Copyright (C) 2018 Philip/Scobalula
//
// 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/>.
// ------------------------------------------------------------------------
using System;
using System.Windows;
using System.Windows.Controls;
namespace Tyrant
{
/// <summary>
/// Interaction logic for ProgressWindow.xaml
/// </summary>
public partial class ProgressWindow : Window
{
/// <summary>
/// Whether we cancelled or not
/// </summary>
private bool HasCancelled = false;
/// <summary>
/// Initializes Progress Window
/// </summary>
public ProgressWindow()
{
InitializeComponent();
}
/// <summary>
/// Sets Cancelled to true to update current task
/// </summary>
private void WindowClosing(object sender, System.ComponentModel.CancelEventArgs e)
{
e.Cancel = !HasCancelled;
}
/// <summary>
/// Closes Window on Cancel click
/// </summary>
private void CancelClick(object sender, RoutedEventArgs e)
{
HasCancelled = true;
}
/// <summary>
/// Closes Progress Window on Complete
/// </summary>
public void Complete()
{
ProgressBar.Value = ProgressBar.Maximum;
HasCancelled = true;
Close();
}
public void SetProgressCount(double value)
{
// Invoke dispatcher to update UI
Dispatcher.BeginInvoke(new Action(() =>
{
ProgressBar.Maximum = value;
ProgressBar.Value = 0;
}));
}
public void SetProgressMessage(string value)
{
// Invoke dispatcher to update UI
Dispatcher.BeginInvoke(new Action(() =>
{
Message.Content = value;
}));
}
/// <summary>
/// Update Progress and checks for cancel
/// </summary>
public bool IncrementProgress()
{
// Invoke dispatcher to update UI
Dispatcher.BeginInvoke(new Action(() =>
{
ProgressBar.Value++;
}));
// Return whether we've cancelled or not
return HasCancelled;
}
}
}

View file

@ -0,0 +1,55 @@
<Window x:Class="Tyrant.SettingsWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="Tyrant | Settings"
Background="#FF373737"
Height="480" Width="848"
WindowStartupLocation="CenterOwner"
ResizeMode="NoResize">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<!-- General -->
<Rectangle Margin="10,19,10,10" Stroke="White"/>
<Label Content="General" HorizontalAlignment="Left" Margin="32,0,0,0" VerticalAlignment="Top" Background="#FF373737" Foreground="White" FontSize="18" Height="34"/>
<CheckBox x:Name="ShowModels" IsChecked="True" Content="Show Models (Mesh)" HorizontalAlignment="Left" Margin="32,39,0,0" VerticalAlignment="Top" Foreground="White"/>
<CheckBox x:Name="ShowTextures" IsChecked="True" Content="Show Textures" HorizontalAlignment="Left" Margin="32,79,0,0" VerticalAlignment="Top" Foreground="White"/>
<CheckBox x:Name="ShowAnims" IsChecked="True" Content="Show Animations (Motion/Motion Bank)" HorizontalAlignment="Left" Margin="32,59,0,0" VerticalAlignment="Top" Foreground="White"/>
<CheckBox x:Name="ShowAll" Content="Show Unnamed/Non-Supported Assets" HorizontalAlignment="Left" Margin="32,99,0,0" VerticalAlignment="Top" Foreground="White"/>
<!-- Textures -->
<Rectangle Margin="10,19,10,10" Stroke="White" Grid.Column="1"/>
<Label Content="Textures" HorizontalAlignment="Left" Margin="32,0,0,0" VerticalAlignment="Top" Background="#FF373737" Foreground="White" FontSize="18" Height="34" Grid.Column="1"/>
<CheckBox x:Name="ExportPNG" Foreground="White" Content="Export as PNG" IsChecked="True" Grid.Column="1" HorizontalAlignment="Left" Margin="32,39,0,0" VerticalAlignment="Top"/>
<CheckBox x:Name="ExportTIFF" Foreground="White" Content="Export as TIFF" Grid.Column="1" HorizontalAlignment="Left" Margin="219,39,0,0" VerticalAlignment="Top"/>
<CheckBox x:Name="ExportDDS" Foreground="White" Content="Export as DDS" Grid.Column="1" HorizontalAlignment="Left" Margin="32,59,0,0" VerticalAlignment="Top"/>
<CheckBox x:Name="ExportJPG" Foreground="White" Content="Export as JPG" Grid.Column="1" HorizontalAlignment="Left" Margin="219,59,0,0" VerticalAlignment="Top"/>
<CheckBox x:Name="ExportBMP" Foreground="White" Content="Export as BMP" Grid.Column="1" HorizontalAlignment="Left" Margin="32,79,0,0" VerticalAlignment="Top"/>
<CheckBox x:Name="ExportTGA" Foreground="White" Content="Export as TGA" Grid.Column="1" HorizontalAlignment="Left" Margin="219,79,0,0" VerticalAlignment="Top"/>
<!-- Models -->
<Rectangle Margin="10,19,10,9" Stroke="White" Grid.Row="1"/>
<Label Content="Models" HorizontalAlignment="Left" Margin="32,0,0,0" VerticalAlignment="Top" Background="#FF373737" Foreground="White" FontSize="18" Height="34" Grid.Row="1"/>
<CheckBox x:Name="ExportSEMODEL" Content="Export as SEModel" IsChecked="True" HorizontalAlignment="Left" Margin="32,39,0,0" VerticalAlignment="Top" Foreground="White" Grid.Row="1"/>
<CheckBox x:Name="ExportOBJ" Content="Export as OBJ" HorizontalAlignment="Right" Margin="0,39,26,0" VerticalAlignment="Top" Foreground="White" Grid.Row="1" Width="178"/>
<CheckBox x:Name="ExportSMD" Content="Export as SMD (Valve)" HorizontalAlignment="Left" Margin="32,59,0,0" VerticalAlignment="Top" Foreground="White" Grid.Row="1"/>
<CheckBox x:Name="ExportASCII" Content="Export as XNALara ASCII" Margin="0,59,26,0" VerticalAlignment="Top" Foreground="White" Grid.Row="1" HorizontalAlignment="Right" Width="178"/>
<CheckBox x:Name="ExportImagesWithModel" IsChecked="True" Content="Export Images with Model" HorizontalAlignment="Left" Margin="32,0,0,43" VerticalAlignment="Bottom" Foreground="White" Grid.Row="1"/>
<CheckBox x:Name="ExportMaterialInfo" IsChecked="True" Content="Export Material Info to .txt" HorizontalAlignment="Left" Margin="32,0,0,23" VerticalAlignment="Bottom" Foreground="White" Grid.Row="1"/>
<Label Content="Scale" HorizontalAlignment="Right" Margin="0,0,73,23" Grid.Row="1" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" VerticalAlignment="Bottom" Height="30" Foreground="White"/>
<TextBox x:Name="FloatModelScale" HorizontalAlignment="Right" Height="30" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Margin="0,0,26,23" Grid.Row="1" TextWrapping="NoWrap" Text="1.0" VerticalAlignment="Bottom" Width="42"/>
<!-- Animations -->
<Rectangle Margin="10,19,10,9" Stroke="White" Grid.Column="1" Grid.Row="1"/>
<Label Content="Animations" HorizontalAlignment="Left" Margin="32,0,0,0" VerticalAlignment="Top" Background="#FF373737" Foreground="White" FontSize="18" Height="34" Grid.Column="1" Grid.Row="1"/>
<CheckBox x:Name="ExportSEANIM" IsChecked="True" Content="Export as SEAnim" HorizontalAlignment="Left" Margin="32,39,0,0" VerticalAlignment="Top" Foreground="White" Grid.Row="1" Grid.Column="1"/>
<Label Content="Scale" HorizontalAlignment="Right" Margin="0,0,73,23" Grid.Row="1" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" VerticalAlignment="Bottom" Height="30" Foreground="White" Grid.Column="1"/>
<TextBox x:Name="FloatAnimationScale" HorizontalAlignment="Right" Height="30" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Margin="0,0,26,23" Grid.Row="1" TextWrapping="NoWrap" Text="1.0" VerticalAlignment="Bottom" Width="42" Grid.Column="1"/>
</Grid>
</Window>

View file

@ -0,0 +1,80 @@
// ------------------------------------------------------------------------
// Tyrant - RE Engine Extractor
// Copyright (C) 2018 Philip/Scobalula
//
// 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/>.
// ------------------------------------------------------------------------
using System.Windows;
using System.Windows.Controls;
namespace Tyrant
{
/// <summary>
/// Interaction logic for SettingsWindow.xaml
/// </summary>
public partial class SettingsWindow : Window
{
public SettingsWindow()
{
InitializeComponent();
}
public void SetUIFromSettings(TyrantSettings settings)
{
var grid = (Grid)Content;
foreach (var item in grid.Children)
{
if (item is CheckBox checkbox)
{
// Use default XAML value to determine if it this is default to on/off
checkbox.IsChecked = settings[checkbox.Name, checkbox.IsChecked == true ? "Yes" : "No"] == "Yes";
}
else if (item is TextBox box)
{
if (box.Name.StartsWith("Float"))
box.Text = settings[box.Name.Substring(5), "1.0"];
else if (box.Name.StartsWith("Integer"))
box.Text = settings[box.Name.Substring(7), "1"];
else
box.Text = settings[box.Name, ""];
}
}
}
public void SetSettingsFromUI(TyrantSettings settings)
{
var grid = (Grid)Content;
foreach (var item in grid.Children)
{
if (item is CheckBox checkbox)
{
// Use default XAML value to determine if it this is default to on/off
settings[checkbox.Name] = checkbox.IsChecked == true ? "Yes" : "No";
}
else if(item is TextBox box)
{
if (box.Name.StartsWith("Float"))
settings[box.Name.Substring(5)] = float.TryParse(box.Text, out var val) ? box.Text : "1.0";
else if (box.Name.StartsWith("Integer"))
settings[box.Name.Substring(7)] = int.TryParse(box.Text, out var val) ? box.Text : "1";
else
settings[box.Name] = box.Text;
}
}
}
}
}

74
src/Tyrant/app.manifest Normal file
View file

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC Manifest Options
If you want to change the Windows User Account Control level replace the
requestedExecutionLevel node with one of the following.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
Specifying requestedExecutionLevel element will disable file and registry virtualization.
Remove this element if your application requires this virtualization for backwards
compatibility.
-->
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of the Windows versions that this application has been tested on
and is designed to work with. Uncomment the appropriate elements
and Windows will automatically select the most compatible environment. -->
<!-- Windows Vista -->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
<!-- Windows 7 -->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
<!-- Windows 8 -->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
<!-- Windows 8.1 -->
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
<!-- Windows 10 -->
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->
</application>
</compatibility>
<!-- Indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher
DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need
to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should
also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config. -->
<!--
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
</windowsSettings>
</application>
-->
<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="ByteSize" version="1.3.0" targetFramework="net472" />
</packages>