Showing preview only (356K chars total). Download the full file or copy to clipboard to get everything.
Repository: chi-rei-den/Localizer
Branch: master
Commit: eddcaa798702
Files: 132
Total size: 322.4 KB
Directory structure:
gitextract_1rgzmmn8/
├── .editorconfig
├── .gitattributes
├── .github/
│ └── workflows/
│ └── build.yml
├── .gitignore
├── .gitmodules
├── LICENSE
├── Localizer/
│ ├── Attributes/
│ │ ├── ModTranslationOwnerFieldAttribute.cs
│ │ ├── ModTranslationPropAttribute.cs
│ │ └── OperationTimingAttribute.cs
│ ├── Configuration.cs
│ ├── DataModel/
│ │ ├── Default/
│ │ │ ├── AttributeFile.cs
│ │ │ ├── BaseEntry.cs
│ │ │ ├── BasicBuffFile.cs
│ │ │ ├── BasicItemFile.cs
│ │ │ ├── BasicNPCFile.cs
│ │ │ ├── BasicPrefixFile.cs
│ │ │ ├── BasicProjectileFile.cs
│ │ │ ├── CustomModTranslationFile.cs
│ │ │ ├── ExportConfig.cs
│ │ │ ├── File.cs
│ │ │ ├── GitHubUpdateInfo.cs
│ │ │ ├── LdstrFile.cs
│ │ │ ├── LoadedModWrapper.cs
│ │ │ ├── ModWrapper.cs
│ │ │ ├── Package.cs
│ │ │ ├── PackageGroup.cs
│ │ │ └── PackageGroupState.cs
│ │ ├── IEntry.cs
│ │ ├── IExportConfig.cs
│ │ ├── IFile.cs
│ │ ├── IMod.cs
│ │ ├── IPackage.cs
│ │ ├── IPackageGroup.cs
│ │ └── IUpdateInfo.cs
│ ├── Disposable.cs
│ ├── Enums/
│ │ ├── AutoImportType.cs
│ │ ├── LogLevel.cs
│ │ ├── OperationTiming.cs
│ │ └── PackageType.cs
│ ├── Helpers/
│ │ ├── Extensions.cs
│ │ ├── Reflection.cs
│ │ ├── UI.cs
│ │ └── Utils.cs
│ ├── Hooks.cs
│ ├── Lang/
│ │ └── Lang.cs
│ ├── Localizer.cs
│ ├── Localizer.csproj
│ ├── Localizer.csproj.DotSettings
│ ├── LocalizerKernel.cs
│ ├── LocalizerPlugin.cs
│ ├── ModBrowser/
│ │ └── Patches.cs
│ ├── Modules/
│ │ ├── DefaultNetworkModule.cs
│ │ └── DefaultPackageModule.cs
│ ├── Network/
│ │ ├── DownloadManager.cs
│ │ ├── GitHubModUpdate.cs
│ │ ├── IDownloadManagerService.cs
│ │ ├── IPackageBrowserService.cs
│ │ ├── IUpdateService.cs
│ │ └── PackageBrowser.cs
│ ├── Package/
│ │ ├── Export/
│ │ │ ├── BasicFileExport.cs
│ │ │ ├── CustomModTranslationFileExport.cs
│ │ │ ├── IFileExportService.cs
│ │ │ ├── IPackageExportService.cs
│ │ │ ├── LdstrFileExport.cs
│ │ │ └── PackageExport.cs
│ │ ├── IPackageManageService.cs
│ │ ├── Import/
│ │ │ ├── AutoImportService.cs
│ │ │ ├── BasicImporter.cs
│ │ │ ├── CecilLdstrImporter.cs
│ │ │ ├── CustomModTranslationImporter.cs
│ │ │ ├── FileImporter.cs
│ │ │ ├── HarmonyLdstrImporter.cs
│ │ │ ├── IPackageImportService.cs
│ │ │ ├── LdstrImporterBase.cs
│ │ │ ├── MonoModLdstrImporter.cs
│ │ │ ├── PackageImportService.cs
│ │ │ └── RefreshLanguageService.cs
│ │ ├── Load/
│ │ │ ├── IFileLoadService.cs
│ │ │ ├── IPackageLoadService.cs
│ │ │ ├── JsonFileLoad.cs
│ │ │ ├── PackedPackageLoad.cs
│ │ │ └── SourcePackageLoad.cs
│ │ ├── Pack/
│ │ │ ├── IPackagePackService.cs
│ │ │ └── ZipPackagePackService.cs
│ │ ├── PackageManageService.cs
│ │ ├── Save/
│ │ │ ├── IFileSaveService.cs
│ │ │ ├── IPackageSaveService.cs
│ │ │ ├── JsonFileSaveService.cs
│ │ │ └── PackageSaveService.cs
│ │ └── Update/
│ │ ├── BasicFileUpdater.cs
│ │ ├── CustomModTranslationUpdater.cs
│ │ ├── FileUpdater.cs
│ │ ├── IPackageUpdateService.cs
│ │ ├── IUpdateLogger.cs
│ │ ├── LdstrFileUpdater.cs
│ │ ├── PackageUpdateService.cs
│ │ └── PlainUpdateLogger.cs
│ ├── Properties/
│ │ └── AssemblyInfo.cs
│ ├── UIs/
│ │ ├── Components/
│ │ │ ├── BasicListBox.cs
│ │ │ ├── BasicWindow.cs
│ │ │ ├── LabelListBoxItem.cs
│ │ │ └── TitleBar.cs
│ │ ├── MainWindow.cs
│ │ ├── Stylesheet.cs
│ │ ├── UIDesktop.cs
│ │ ├── UIHost.cs
│ │ ├── UIModsPatch.cs
│ │ ├── UIRenderer.cs
│ │ └── Views/
│ │ ├── ManagerView.cs
│ │ ├── ReloadPluginView.cs
│ │ └── TestView.cs
│ ├── build.txt
│ └── description.txt
├── Localizer.sln
├── Localizer.sln.DotSettings
├── LocalizerTest/
│ ├── DataModel/
│ │ └── GitHubUpdateInfoTest.cs
│ ├── Helper/
│ │ ├── ExtensionsTest.cs
│ │ └── UtilsTest.cs
│ ├── LocalizerTest.cs
│ ├── LocalizerTest.csproj
│ ├── Network/
│ │ └── GitHubModUpdateService.cs
│ ├── Ninject.cs
│ ├── NonTest/
│ │ └── UpdateLogger.cs
│ └── Package/
│ ├── Import/
│ │ ├── BasicFileImportTest.cs
│ │ ├── CustomModTranslationFileImportTest.cs
│ │ └── LdstrFileImportBaseTest.cs
│ └── Update/
│ ├── BasicFileUpdateTest.cs
│ ├── CustomModTranslationFileUpdateTest.cs
│ └── LdstrFileUpdateTest.cs
├── ModPatch/
│ ├── ModPatch.csproj
│ └── Program.cs
└── README.md
================================================
FILE CONTENTS
================================================
================================================
FILE: .editorconfig
================================================
# To learn more about .editorconfig see https://aka.ms/editorconfigdocs
###############################
# Core EditorConfig Options #
###############################
# All files
[*]
indent_style=space
# Code files
[*.{cs,csx,vb,vbx}]
indent_size=4
insert_final_newline=true
charset=utf-8
###############################
# .NET Coding Conventions #
###############################
[*.{cs,vb}]
# Organize usings
dotnet_sort_system_directives_first=true
# this. preferences
dotnet_style_qualification_for_field=false:silent
dotnet_style_qualification_for_property=false:silent
dotnet_style_qualification_for_method=false:silent
dotnet_style_qualification_for_event=false:silent
# Language keywords vs BCL types preferences
dotnet_style_predefined_type_for_locals_parameters_members=true:silent
dotnet_style_predefined_type_for_member_access=true:silent
# Parentheses preferences
dotnet_style_parentheses_in_arithmetic_binary_operators=always_for_clarity:silent
dotnet_style_parentheses_in_relational_binary_operators=always_for_clarity:silent
dotnet_style_parentheses_in_other_binary_operators=always_for_clarity:silent
dotnet_style_parentheses_in_other_operators=never_if_unnecessary:silent
# Modifier preferences
dotnet_style_require_accessibility_modifiers=for_non_interface_members:silent
dotnet_style_readonly_field=true:suggestion
# Expression-level preferences
dotnet_style_object_initializer=true:suggestion
dotnet_style_collection_initializer=true:suggestion
dotnet_style_explicit_tuple_names=true:suggestion
dotnet_style_null_propagation=true:suggestion
dotnet_style_coalesce_expression=true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method=true:silent
dotnet_prefer_inferred_tuple_names=true:suggestion
dotnet_prefer_inferred_anonymous_type_member_names=true:suggestion
dotnet_style_prefer_auto_properties=true:silent
dotnet_style_prefer_conditional_expression_over_assignment=true:silent
dotnet_style_prefer_conditional_expression_over_return=true:silent
###############################
# Naming Conventions #
###############################
# Style Definitions
dotnet_naming_style.pascal_case_style.capitalization=pascal_case
# Use PascalCase for constant fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity=suggestion
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols=constant_fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.style=pascal_case_style
dotnet_naming_symbols.constant_fields.applicable_kinds=field
dotnet_naming_symbols.constant_fields.applicable_accessibilities=*
dotnet_naming_symbols.constant_fields.required_modifiers=const
###############################
# C# Coding Conventions #
###############################
[*.cs]
# var preferences
csharp_style_var_for_built_in_types=true:silent
csharp_style_var_when_type_is_apparent=true:silent
csharp_style_var_elsewhere=true:silent
# Expression-bodied members
csharp_style_expression_bodied_methods=false:silent
csharp_style_expression_bodied_constructors=false:silent
csharp_style_expression_bodied_operators=false:silent
csharp_style_expression_bodied_properties=true:silent
csharp_style_expression_bodied_indexers=true:silent
csharp_style_expression_bodied_accessors=true:silent
# Pattern matching preferences
csharp_style_pattern_matching_over_is_with_cast_check=true:suggestion
csharp_style_pattern_matching_over_as_with_null_check=true:suggestion
# Null-checking preferences
csharp_style_throw_expression=true:suggestion
csharp_style_conditional_delegate_call=true:suggestion
# Modifier preferences
csharp_preferred_modifier_order=public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion
# Expression-level preferences
csharp_prefer_braces=true:silent
csharp_style_deconstructed_variable_declaration=true:suggestion
csharp_prefer_simple_default_expression=true:suggestion
csharp_style_pattern_local_over_anonymous_function=true:suggestion
csharp_style_inlined_variable_declaration=true:suggestion
csharp_using_directive_placement=outside_namespace:silent
###############################
# C# Formatting Rules #
###############################
# New line preferences
csharp_new_line_before_open_brace=all
csharp_new_line_before_else=true
csharp_new_line_before_catch=true
csharp_new_line_before_finally=true
csharp_new_line_before_members_in_object_initializers=true
csharp_new_line_before_members_in_anonymous_types=true
csharp_new_line_between_query_expression_clauses=true
# Indentation preferences
csharp_indent_case_contents=true
csharp_indent_switch_labels=true
csharp_indent_labels=flush_left
csharp_indent_braces=false
# Space preferences
csharp_space_after_cast=false
csharp_space_after_keywords_in_control_flow_statements=true
csharp_space_between_method_call_parameter_list_parentheses=false
csharp_space_between_method_declaration_parameter_list_parentheses=false
csharp_space_between_parentheses=false
csharp_space_before_colon_in_inheritance_clause=true
csharp_space_after_colon_in_inheritance_clause=true
csharp_space_around_binary_operators=before_and_after
csharp_space_between_method_declaration_empty_parameter_list_parentheses=false
csharp_space_between_method_call_name_and_opening_parenthesis=false
csharp_space_between_method_call_empty_parameter_list_parentheses=false
# Wrapping preferences
csharp_preserve_single_line_statements=true
csharp_preserve_single_line_blocks=true
###############################
# ReSharper Rules #
###############################
# ReSharper properties
resharper_align_linq_query=true
resharper_align_multiline_argument=true
resharper_align_multiline_calls_chain=true
resharper_align_multiline_extends_list=true
resharper_align_multline_type_parameter_constrains=true
resharper_align_multline_type_parameter_list=true
resharper_align_tuple_components=true
resharper_blank_lines_before_single_line_comment=1
resharper_csharp_align_multiline_parameter=true
resharper_csharp_align_multiple_declaration=true
resharper_csharp_empty_block_style=together
resharper_csharp_insert_final_newline=true
resharper_csharp_use_indent_from_vs=false
resharper_keep_existing_declaration_block_arrangement=false
resharper_keep_existing_switch_expression_arrangement=false
resharper_max_enum_members_on_line=1
resharper_max_initializer_elements_on_line=1
resharper_place_simple_anonymousmethod_on_single_line=false
resharper_place_simple_embedded_statement_on_same_line=False
resharper_place_simple_initializer_on_single_line=true
resharper_wrap_linq_expressions=chop_always
================================================
FILE: .gitattributes
================================================
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain
================================================
FILE: .github/workflows/build.yml
================================================
name: Mod Build
on: [push]
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v1
with:
submodules: recursive
- name: Installer NuGet client
uses: nuget/setup-nuget@v1
- name: Setup tModLoader
uses: chi-rei-den/ModLoaderTools@v1.1
with:
command: setup
- name: Restore NuGet Packages
run: nuget restore Localizer.sln
- name: Build Mod
run: |
& "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\MSBuild.exe" Localizer.sln /p:Configuration=Release /p:Platform=x86
- name: Patch Mod
run: '& "$ENV:GITHUB_WORKSPACE\ModPatch\bin\Release\net472\ModPatch.exe"'
- name: Publish Mod
if: github.ref == 'refs/heads/master'
uses: chi-rei-den/ModLoaderTools@v1
with:
command: publish
path: Localizer
env:
steamid64: ${{ secrets.steamid64 }}
passphrase: ${{ secrets.mod_browser_passphrase }}
- name: Clean artifact
run: |
mkdir .\Artifact\Artifact\
Copy-Item -Path "$ENV:UserProfile\Documents\My Games\Terraria\ModLoader\Mods\*" -Destination .\Artifact\Artifact
del .\Artifact\Artifact\enabled.json
- uses: actions/upload-artifact@master
with:
name: Build Artifact
path: Artifact
- name: Run Tests
run: |
copy .\LocalizerTest\bin\Release\net472\tModLoader.exe .\LocalizerTest\bin\Release\net472\Terraria.exe
& "$ENV:UserProfile\.nuget\packages\xunit.runner.console\2.4.1\tools\net472\xunit.console.x86.exe" ".\LocalizerTest\bin\Release\net472\LocalizerTest.dll"
================================================
FILE: .gitignore
================================================
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
Localizer/WPF/
# 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/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# 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
# DNX
project.lock.json
project.fragment.lock.json
artifacts/
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.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
# 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
# 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
# TODO: 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
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignoreable 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
# 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
node_modules/
orleans.codegen.cs
# 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
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# 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
/Localizer/Plugins
/Localizer/lib
================================================
FILE: .gitmodules
================================================
[submodule "Squid"]
path = Squid
url = https://github.com/chi-rei-den/Squid
================================================
FILE: LICENSE
================================================
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>.
================================================
FILE: Localizer/Attributes/ModTranslationOwnerFieldAttribute.cs
================================================
using System;
namespace Localizer.Attributes
{
/// <summary>
/// Indicates the field contains objects those have ModTranslations need to be localized.
/// </summary>
public class ModTranslationOwnerFieldAttribute : Attribute
{
public ModTranslationOwnerFieldAttribute(string fieldName)
{
FieldName = fieldName;
}
public string FieldName { get; }
}
}
================================================
FILE: Localizer/Attributes/ModTranslationPropAttribute.cs
================================================
using System;
namespace Localizer.Attributes
{
/// <summary>
/// Indicates the name of ModTranslation property.
/// </summary>
public class ModTranslationPropAttribute : Attribute
{
public ModTranslationPropAttribute(string propName)
{
PropName = propName;
}
public string PropName { get; }
}
}
================================================
FILE: Localizer/Attributes/OperationTimingAttribute.cs
================================================
using System;
namespace Localizer.Attributes
{
public class OperationTimingAttribute : Attribute
{
public OperationTiming Timing { get; }
public OperationTimingAttribute(OperationTiming timing = OperationTiming.Any)
{
Timing = timing;
}
}
}
================================================
FILE: Localizer/Configuration.cs
================================================
namespace Localizer
{
public class Configuration
{
public bool AutoImport { get; set; } = true;
public bool ImportLdstr { get; set; } = true;
public string LdstrImporter { get; set; } = "Cecil";
public bool ImporBasictAfterSetupContent { get; set; } = true;
public AutoImportType AutoImportType { get; set; } = AutoImportType.All;
public bool ShowUI { get; set; } = true;
public LogLevel LogLevel { get; set; } = LogLevel.Info;
public bool RebuildTooltips { get; set; } = true;
public bool RebuildTooltipsOnce { get; set; } = true;
public string[] ModListMirror { get; set; } = new[]
{
"mirror.sgkoi.dev",
"mirror7.sgkoi.dev",
"mirror8.sgkoi.dev",
"mirror5.sgkoi.dev",
};
public string[] ModDownloadMirror { get; set; } = new[]
{
"mirror.sgkoi.dev",
"mirror7.sgkoi.dev",
"mirror8.sgkoi.dev",
"mirror5.sgkoi.dev",
};
public string[] ModDescMirror { get; set; } = new[]
{
"mirror.sgkoi.dev",
"mirror7.sgkoi.dev",
"mirror8.sgkoi.dev",
"mirror5.sgkoi.dev",
};
}
}
================================================
FILE: Localizer/DataModel/Default/AttributeFile.cs
================================================
using System.Collections.Generic;
using System.Linq;
namespace Localizer.DataModel.Default
{
public class AttributeFile : IFile
{
public Dictionary<string, BaseEntry> Translations { get; set; } = new Dictionary<string, BaseEntry>();
public List<string> GetKeys()
{
return Translations.Keys.ToList();
}
public IEntry GetValue(string key)
{
return Translations[key];
}
}
}
================================================
FILE: Localizer/DataModel/Default/BaseEntry.cs
================================================
namespace Localizer.DataModel.Default
{
public class BaseEntry : IEntry
{
public string Origin { get; set; }
public string Translation { get; set; }
public IEntry Clone()
{
return new BaseEntry
{
Origin = Origin,
Translation = Translation
};
}
}
}
================================================
FILE: Localizer/DataModel/Default/BasicBuffFile.cs
================================================
using System.Collections.Generic;
using System.Linq;
using Localizer.Attributes;
namespace Localizer.DataModel.Default
{
public class BuffEntry : IEntry
{
[ModTranslationProp("DisplayName")] public BaseEntry Name { get; set; }
[ModTranslationProp("Description")] public BaseEntry Description { get; set; }
public IEntry Clone()
{
return new BuffEntry
{
Name = Name.Clone() as BaseEntry,
Description = Description.Clone() as BaseEntry
};
}
}
public class BasicBuffFile : IFile
{
[ModTranslationOwnerField("buffs")]
public Dictionary<string, BuffEntry> Buffs { get; set; } = new Dictionary<string, BuffEntry>();
public List<string> GetKeys()
{
return Buffs.Keys.ToList();
}
public IEntry GetValue(string key)
{
return Buffs[key];
}
}
}
================================================
FILE: Localizer/DataModel/Default/BasicItemFile.cs
================================================
using System.Collections.Generic;
using System.Linq;
using Localizer.Attributes;
namespace Localizer.DataModel.Default
{
public class ItemEntry : IEntry
{
[ModTranslationProp("DisplayName")] public BaseEntry Name { get; set; }
[ModTranslationProp("Tooltip")] public BaseEntry Tooltip { get; set; }
public IEntry Clone()
{
return new ItemEntry
{
Name = Name.Clone() as BaseEntry,
Tooltip = Tooltip.Clone() as BaseEntry
};
}
}
public class BasicItemFile : IFile
{
[ModTranslationOwnerField("items")]
public Dictionary<string, ItemEntry> Items { get; set; } = new Dictionary<string, ItemEntry>();
public List<string> GetKeys()
{
return Items.Keys.ToList();
}
public IEntry GetValue(string key)
{
return Items[key];
}
}
}
================================================
FILE: Localizer/DataModel/Default/BasicNPCFile.cs
================================================
using System.Collections.Generic;
using System.Linq;
using Localizer.Attributes;
namespace Localizer.DataModel.Default
{
public class NPCEntry : IEntry
{
[ModTranslationProp("DisplayName")] public BaseEntry Name { get; set; }
public IEntry Clone()
{
return new NPCEntry { Name = Name.Clone() as BaseEntry };
}
}
public class BasicNPCFile : IFile
{
[ModTranslationOwnerField("npcs")]
public Dictionary<string, NPCEntry> NPCs { get; set; } = new Dictionary<string, NPCEntry>();
public List<string> GetKeys()
{
return NPCs.Keys.ToList();
}
public IEntry GetValue(string key)
{
return NPCs[key];
}
}
}
================================================
FILE: Localizer/DataModel/Default/BasicPrefixFile.cs
================================================
using System.Collections.Generic;
using System.Linq;
using Localizer.Attributes;
namespace Localizer.DataModel.Default
{
public class PrefixEntry : IEntry
{
[ModTranslationProp("DisplayName")] public BaseEntry Name { get; set; }
public IEntry Clone()
{
return new PrefixEntry { Name = Name.Clone() as BaseEntry };
}
}
public class BasicPrefixFile : IFile
{
[ModTranslationOwnerField("prefixes")]
public Dictionary<string, PrefixEntry> Prefixes { get; set; } = new Dictionary<string, PrefixEntry>();
public List<string> GetKeys()
{
return Prefixes.Keys.ToList();
}
public IEntry GetValue(string key)
{
return Prefixes[key];
}
}
}
================================================
FILE: Localizer/DataModel/Default/BasicProjectileFile.cs
================================================
using System.Collections.Generic;
using System.Linq;
using Localizer.Attributes;
namespace Localizer.DataModel.Default
{
public class ProjectileEntry : IEntry
{
[ModTranslationProp("DisplayName")] public BaseEntry Name { get; set; }
public IEntry Clone()
{
return new ProjectileEntry { Name = Name.Clone() as BaseEntry };
}
}
public class BasicProjectileFile : IFile
{
[ModTranslationOwnerField("projectiles")]
public Dictionary<string, ProjectileEntry> Projectiles { get; set; } = new Dictionary<string, ProjectileEntry>();
public List<string> GetKeys()
{
return Projectiles.Keys.ToList();
}
public IEntry GetValue(string key)
{
return Projectiles[key];
}
}
}
================================================
FILE: Localizer/DataModel/Default/CustomModTranslationFile.cs
================================================
using System.Collections.Generic;
using System.Linq;
namespace Localizer.DataModel.Default
{
public class CustomModTranslationFile : IFile
{
public Dictionary<string, BaseEntry> Translations { get; set; } = new Dictionary<string, BaseEntry>();
public List<string> GetKeys()
{
return Translations.Keys.ToList();
}
public IEntry GetValue(string key)
{
return Translations[key];
}
}
}
================================================
FILE: Localizer/DataModel/Default/ExportConfig.cs
================================================
namespace Localizer.DataModel.Default
{
public class ExportConfig : IExportConfig
{
public bool MakeBackup { get; set; }
public bool ForceOverride { get; set; }
public bool WithTranslation { get; set; }
}
}
================================================
FILE: Localizer/DataModel/Default/File.cs
================================================
using System.Collections.Generic;
using Newtonsoft.Json;
namespace Localizer.DataModel.Default
{
public abstract class File : IFile
{
[JsonIgnore] public IPackage Owner { get; set; }
public abstract List<string> GetKeys();
public abstract IEntry GetValue(string key);
public abstract void AddEntry(string key, IEntry entry);
}
}
================================================
FILE: Localizer/DataModel/Default/GitHubUpdateInfo.cs
================================================
using System;
namespace Localizer.DataModel.Default
{
public class GitHubUpdateInfo : IUpdateInfo
{
public UpdateType Type { get; }
public Version Version { get; }
private string versionString;
public GitHubUpdateInfo(string versionString)
{
this.versionString = versionString;
Type = ParseType(versionString[0]);
Version = Version.Parse(versionString.Substring(1, versionString.Length - 1));
}
internal UpdateType ParseType(char t)
{
switch (t)
{
case 'a':
return UpdateType.Minor;
case 'b':
return UpdateType.Major;
case 'c':
return UpdateType.Critical;
default:
return UpdateType.None;
}
}
}
}
================================================
FILE: Localizer/DataModel/Default/LdstrFile.cs
================================================
using System.Collections.Generic;
using System.Linq;
using Localizer.Attributes;
namespace Localizer.DataModel.Default
{
public class LdstrEntry : IEntry
{
public List<BaseEntry> Instructions { get; set; }
public IEntry Clone()
{
var entry = new LdstrEntry { Instructions = new List<BaseEntry>() };
foreach (var ins in Instructions)
{
entry.Instructions.Add(ins.Clone() as BaseEntry);
}
return entry;
}
}
[OperationTiming]
public class LdstrFile : IFile
{
public Dictionary<string, LdstrEntry> LdstrEntries { get; set; } = new Dictionary<string, LdstrEntry>();
public List<string> GetKeys()
{
return LdstrEntries.Keys.ToList();
}
public IEntry GetValue(string key)
{
return LdstrEntries[key];
}
}
}
================================================
FILE: Localizer/DataModel/Default/LoadedModWrapper.cs
================================================
using System;
using System.Reflection;
using Terraria;
using Terraria.ModLoader;
using Terraria.ModLoader.Core;
namespace Localizer.DataModel.Default
{
public class LoadedModWrapper : IMod
{
internal readonly WeakReference<object> wrapped;
public LoadedModWrapper(object mod)
{
wrapped = new WeakReference<object>(mod);
name = mod.ValueOf<string>("Name");
Code = name == "ModLoader" ? Assembly.GetAssembly(typeof(Main)) : mod.ValueOf<Assembly>("assembly");
var buildProp = mod.ValueOf("properties");
displayName = buildProp.ValueOf<string>("displayName");
version = buildProp.ValueOf<Version>("version");
File = mod.ValueOf<TmodFile>("modFile");
}
public string Name => name ?? "";
private string name;
public Assembly Code { get; }
public string DisplayName => displayName ?? "";
private string displayName;
public Version Version => version ?? new Version();
private Version version;
public TmodFile File { get; }
public bool Enabled => (bool)typeof(ModLoader).Invoke("IsEnabled", Name);
}
}
================================================
FILE: Localizer/DataModel/Default/ModWrapper.cs
================================================
using System;
using System.Reflection;
using Terraria;
using Terraria.ModLoader;
using Terraria.ModLoader.Core;
namespace Localizer.DataModel.Default
{
public class ModWrapper : IMod
{
private readonly WeakReference<Mod> wrapped;
public ModWrapper(Mod mod)
{
if (mod is null)
{
throw new ArgumentNullException(nameof(mod));
}
wrapped = new WeakReference<Mod>(mod);
}
public Mod Mod
{
get
{
Mod mod = null;
wrapped?.TryGetTarget(out mod);
return mod;
}
}
public string Name => Mod?.Name ?? "";
public Assembly Code
{
get
{
if (Name == "ModLoader")
{
return Assembly.GetAssembly(typeof(Main));
}
else
{
return Mod?.Code;
}
}
}
public string DisplayName => Mod.DisplayName ?? "";
public Version Version => Mod?.Version;
public TmodFile File => Mod?.ValueOf<TmodFile>("File");
public bool Enabled => (bool)typeof(ModLoader).Invoke("IsEnabled", Name);
}
}
================================================
FILE: Localizer/DataModel/Default/Package.cs
================================================
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Newtonsoft.Json;
namespace Localizer.DataModel.Default
{
[JsonObject(MemberSerialization.OptIn)]
public class Package : IPackage
{
public Package()
{ }
public Package(string name, IMod mod, CultureInfo language)
{
Name = name;
Mod = mod;
ModName = mod.Name;
Description = string.Empty;
Language = language;
Version = new Version(1, 0, 0, 0);
FileList = new List<string>();
Files = new List<IFile>();
}
public bool Exported { get; set; }
[JsonProperty] public string Name { get; set; } = "";
[JsonProperty] public string Author { get; set; } = "";
[JsonProperty] public string ModName { get; set; } = "";
[JsonProperty] public string Description { get; set; } = "";
[JsonProperty] public string LocalizedModName { get; set; } = "";
[JsonProperty] public Version Version { get; set; }
[JsonProperty] public Version ModVersion { get; set; }
[JsonProperty] public CultureInfo Language { get; set; } = CultureInfo.GetCultureInfo("en-US");
[JsonProperty] public ICollection<string> FileList { get; set; } = new List<string>();
public ICollection<IFile> Files { get; set; } = new List<IFile>();
public int Count => Files.Sum(f => f.GetKeys().Count());
public bool Enabled { get; set; } = true;
public IMod Mod { get; set; }
public void AddFile(IFile file)
{
if (file == null)
{
return;
}
if (!FileList.Contains(file.GetType().Name))
{
FileList.Add(file.GetType().Name);
}
Files.Add(file);
}
public void RemoveFile(IFile file)
{
throw new NotImplementedException();
}
}
}
================================================
FILE: Localizer/DataModel/Default/PackageGroup.cs
================================================
using System.Collections.Generic;
namespace Localizer.DataModel.Default
{
public class PackageGroup : IPackageGroup
{
public IMod Mod { get; set; }
public ICollection<IPackage> Packages { get; set; }
}
}
================================================
FILE: Localizer/DataModel/Default/PackageGroupState.cs
================================================
using System.Collections.Specialized;
using Newtonsoft.Json;
namespace Localizer.DataModel.Default
{
[JsonObject(MemberSerialization.OptOut)]
public class PackageGroupState
{
public PackageGroupState()
{ }
public PackageGroupState(IPackageGroup pg)
{
ModName = pg.Mod.Name;
Packages = new OrderedDictionary();
foreach (var p in pg.Packages)
{
Packages.Add(p.Name, p.Enabled);
}
}
public string ModName { get; set; }
public OrderedDictionary Packages { get; set; }
}
}
================================================
FILE: Localizer/DataModel/IEntry.cs
================================================
namespace Localizer.DataModel
{
public interface IEntry
{
IEntry Clone();
}
}
================================================
FILE: Localizer/DataModel/IExportConfig.cs
================================================
namespace Localizer.DataModel
{
public interface IExportConfig
{
/// <summary>
/// Create backups before exportation.
/// </summary>
bool MakeBackup { get; set; }
/// <summary>
/// Overwrite or not if the file is already exists.
/// </summary>
bool ForceOverride { get; set; }
/// <summary>
/// If the ModTranslation already has a translation of current culture,
/// then export it.
/// </summary>
bool WithTranslation { get; set; }
}
}
================================================
FILE: Localizer/DataModel/IFile.cs
================================================
using System.Collections.Generic;
namespace Localizer.DataModel
{
public interface IFile
{
List<string> GetKeys();
IEntry GetValue(string key);
}
}
================================================
FILE: Localizer/DataModel/IMod.cs
================================================
using System;
using System.Reflection;
using Terraria.ModLoader.Core;
namespace Localizer.DataModel
{
public interface IMod
{
/// <summary>
/// Name of the mod.
/// </summary>
string Name { get; }
/// <summary>
/// Code of the mod.
/// </summary>
Assembly Code { get; }
/// <summary>
/// DisplayName of the mod.
/// </summary>
string DisplayName { get; }
/// <summary>
/// Version of the mod.
/// </summary>
Version Version { get; }
/// <summary>
/// File of the mod.
/// </summary>
TmodFile File { get; }
bool Enabled { get; }
}
}
================================================
FILE: Localizer/DataModel/IPackage.cs
================================================
using System;
using System.Collections.Generic;
using System.Globalization;
namespace Localizer.DataModel
{
public interface IPackage
{
/// <summary>
/// Name of the package.
/// </summary>
string Name { get; set; }
/// <summary>
/// Author of the package.
/// </summary>
string Author { get; set; }
/// <summary>
/// The name of the mod this package target for.
/// </summary>
string ModName { get; set; }
/// <summary>
/// The localized name of the mod.
/// </summary>
string LocalizedModName { get; set; }
/// <summary>
/// Description of the package.
/// </summary>
string Description { get; set; }
/// <summary>
/// Version of the package.
/// </summary>
Version Version { get; set; }
/// <summary>
/// Version of the targeted mod.
/// </summary>
Version ModVersion { get; set; }
/// <summary>
/// Culture of the package.
/// </summary>
CultureInfo Language { get; set; }
/// <summary>
/// File types this package including.
/// </summary>
ICollection<string> FileList { get; set; }
/// <summary>
/// Files this package including.
/// </summary>
ICollection<IFile> Files { get; set; }
int Count { get; }
/// <summary>
/// The enable status of the package.
/// </summary>
bool Enabled { get; set; }
/// <summary>
/// The mod this package target for.
/// </summary>
IMod Mod { get; set; }
/// <summary>
/// Add a file into Files and FileList
/// </summary>
/// <param name="file"></param>
void AddFile(IFile file);
/// <summary>
/// Remove a file from Files and FileList
/// </summary>
/// <param name="file"></param>
void RemoveFile(IFile file);
}
}
================================================
FILE: Localizer/DataModel/IPackageGroup.cs
================================================
using System.Collections.Generic;
namespace Localizer.DataModel
{
public interface IPackageGroup
{
/// <summary>
/// Mod of the group, every package in this group is for this mod.
/// </summary>
IMod Mod { get; set; }
ICollection<IPackage> Packages { get; set; }
}
}
================================================
FILE: Localizer/DataModel/IUpdateInfo.cs
================================================
using System;
namespace Localizer.DataModel
{
public enum UpdateType
{
None,
Minor,
Major,
Critical,
}
public interface IUpdateInfo
{
UpdateType Type { get; }
Version Version { get; }
}
}
================================================
FILE: Localizer/Disposable.cs
================================================
using System;
namespace Localizer
{
public abstract class Disposable : IDisposable
{
protected bool disposed = false;
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
~Disposable()
{
Dispose(false);
}
protected virtual void Dispose(bool disposeManaged)
{
if (!disposed)
{
if (disposeManaged)
{
DisposeManaged();
}
DisposeUnmanaged();
disposed = true;
}
}
protected virtual void DisposeManaged() { }
protected virtual void DisposeUnmanaged() { }
}
}
================================================
FILE: Localizer/Enums/AutoImportType.cs
================================================
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace Localizer
{
[JsonConverter(typeof(StringEnumConverter))]
public enum AutoImportType
{
All,
DownloadedOnly,
SourceOnly,
}
}
================================================
FILE: Localizer/Enums/LogLevel.cs
================================================
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace Localizer
{
[JsonConverter(typeof(StringEnumConverter))]
public enum LogLevel : byte
{
Fatal = 0,
Error = 1,
Warn = 2,
Info = 3,
Debug = 4,
}
}
================================================
FILE: Localizer/Enums/OperationTiming.cs
================================================
using System;
namespace Localizer
{
[Flags]
public enum OperationTiming : byte
{
BeforeModCtor = 0b00000001,
BeforeModLoad = 0b00000010,
BeforeContentLoad = 0b00000100,
PostContentLoad = 0b00001000,
Any = 0b11111111,
}
}
================================================
FILE: Localizer/Enums/PackageType.cs
================================================
namespace Localizer
{
public enum PackageType
{
Packed,
Source,
}
}
================================================
FILE: Localizer/Helpers/Extensions.cs
================================================
using System;
using System.Globalization;
using System.Linq;
using System.Reflection;
using Localizer.Attributes;
using Localizer.DataModel.Default;
using Terraria.ModLoader;
namespace Localizer.Helpers
{
public static class Extensions
{
#region ModTranslation
public static void Import(this ModTranslation modTranslation, BaseEntry entry, CultureInfo culture)
{
if (entry != null)
{
if (entry.Origin != modTranslation.GetDefault()
&& modTranslation.GetDefault() != modTranslation.Key
&& !string.IsNullOrWhiteSpace(modTranslation.GetDefault())
&& !string.IsNullOrWhiteSpace(entry.Origin))
{
Utils.LogWarn(
$"Mismatch origin text when importing \"{modTranslation.Key}\"{Environment.NewLine}Origin in mod: {modTranslation.GetDefault()}{Environment.NewLine}Origin in package: {entry.Origin}{Environment.NewLine}Translation in package: {entry.Translation}");
return;
}
if (modTranslation.GetDefault() != null && !string.IsNullOrEmpty(entry.Translation) &&
entry.Translation != modTranslation.Key)
{
modTranslation.AddTranslation(Localizer.CultureInfoToGameCulture(culture), entry.Translation);
}
}
}
public static string GetTranslation(this ModTranslation modTranslation, CultureInfo culture)
{
var translation = modTranslation.GetTranslation(Localizer.CultureInfoToGameCulture(culture));
return string.IsNullOrWhiteSpace(translation) ? "" : translation;
}
public static string DefaultOrEmpty(this ModTranslation modTranslation)
{
var d = modTranslation.GetDefault();
return string.IsNullOrWhiteSpace(d) || d == modTranslation.Key ? "" : d;
}
#endregion
#region Reflection
public static PropertyInfo[] ModTranslationOwnerField(this Type type)
{
return type.GetProperties().Where(p => p.GetCustomAttribute<ModTranslationOwnerFieldAttribute>() != null)
.ToArray();
}
public static string ModTranslationOwnerFieldName(this PropertyInfo prop)
{
return prop.GetCustomAttribute<ModTranslationOwnerFieldAttribute>()?.FieldName;
}
public static PropertyInfo[] ModTranslationProp(this Type type)
{
return type.GetProperties().Where(p => p.GetCustomAttribute<ModTranslationPropAttribute>() != null)
.ToArray();
}
#endregion
}
}
================================================
FILE: Localizer/Helpers/Reflection.cs
================================================
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using Harmony;
namespace System.Reflection
{
public static class NoroHelper
{
public const BindingFlags AnyVisibility = BindingFlags.Public | BindingFlags.NonPublic;
public const BindingFlags Any = AnyVisibility | BindingFlags.Static | BindingFlags.Instance;
public static HarmonyMethod HarmonyMethod(Expression<Action> expression)
{
return new HarmonyMethod((expression.Body as MethodCallExpression)?.Method);
}
public static MethodInfo MethodInfo(Expression<Action> expression)
{
return (expression.Body as MethodCallExpression)?.Method;
}
public static Type Type(this string name)
{
//return AppDomain.CurrentDomain.GetAssemblies().SelectMany(a => a.DefinedTypes).FirstOrDefault(t => t.FullName == name);
return AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(a => a.DefinedTypes.Any(t => t.FullName == name))?.ManifestModule.GetType(name);
}
public static FieldInfo Field(this Type type, string name, BindingFlags flags = Any)
{
return type?.GetField(name, flags) ?? type?.BaseType?.Field(name, flags);
}
public static PropertyInfo Property(this Type type, string name, BindingFlags flags = Any)
{
return type?.GetProperty(name, flags) ?? type?.BaseType?.Property(name, flags);
}
public static MethodInfo Method(this Type t, string name, IEnumerable<Type> args)
{
return t.Method(name, args.ToArray());
}
public static MethodInfo Method(this Type t, string name, params Type[] args)
{
if (name is null)
{
throw new ArgumentNullException(nameof(name));
}
if (args == null || args.Length == 0)
{
return t.GetMethod(name, Any);
}
return t.GetMethod(name, Any, null, args, new ParameterModifier[] { });
}
public static object ValueOf(this Type type, string name, object value = null)
{
var field = type?.Field(name);
if (field != null)
{
return field.GetValue(value);
}
var prop = type?.Property(name);
if (prop != null)
{
return prop.GetValue(value);
}
throw new MemberAccessException($"{name} not found ({type})");
}
public static object ValueOf(this object obj, string name)
{
return obj?.GetType().ValueOf(name, obj);
}
public static T ValueOf<T>(this Type type, string name)
{
return (T)type?.ValueOf(name);
}
public static T ValueOf<T>(this object obj, string name)
{
return (T)obj?.ValueOf(name);
}
public static void SetField(this Type type, string name, object value)
{
type?.Field(name).SetValue(null, value);
}
public static void SetField(this object obj, string name, object value)
{
obj?.GetType().Field(name).SetValue(obj, value);
}
public static object Invoke(this object o, string name, params object[] args)
{
if (name is null)
{
throw new ArgumentNullException(nameof(name));
}
var method = (o is Type t
? t
: o.GetType()).Method(name, args.Select(a => a.GetType()))
?? throw new MissingMethodException($"{o.GetType().FullName}.{name}");
return method.Invoke(o, args);
}
}
}
================================================
FILE: Localizer/Helpers/UI.cs
================================================
using System;
using System.Reflection;
using Localizer.DataModel;
using Microsoft.Xna.Framework.Graphics;
using Terraria.UI;
using static Localizer.Lang;
namespace Localizer.Helpers
{
public static class UI
{
public static string GetPkgLabelText(IPackage p)
{
return _("PackageDisplay", _(p.Enabled ? "PackageEnabled" : "PackageDisabled"), p.Name, p.Version, p.Author);
}
public static void ShowInfoMessage(string message, int gotoMenu, UIState state = null, string altButtonText = "", Action altButtonAction = null)
{
var infoMsgUI = GetModLoaderUI("infoMessage") ?? throw new Exception("Cannot Find infoMessage field");
infoMsgUI.Invoke("Show", message, gotoMenu, state, altButtonText, altButtonAction);
}
public static object GetModLoaderUI(string uiName)
{
return "Terraria.ModLoader.UI.Interface".Type()?.ValueOf(uiName);
}
public static void SafeBegin(this SpriteBatch sb)
{
try
{
sb.Begin();
}
catch (InvalidOperationException)
{
}
}
public static void SafeBegin(this SpriteBatch sb, SamplerState sampler, RasterizerState rasterizer)
{
try
{
sb.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied, sampler, null, rasterizer);
}
catch (InvalidOperationException)
{
}
}
public static void SafeEnd(this SpriteBatch sb)
{
try
{
sb.End();
}
catch (InvalidOperationException)
{
}
}
}
}
================================================
FILE: Localizer/Helpers/Utils.cs
================================================
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Reflection.Emit;
using System.Text;
using System.Text.RegularExpressions;
using Harmony;
using Harmony.ILCopying;
using Localizer.Attributes;
using Localizer.DataModel;
using Localizer.DataModel.Default;
using Localizer.Helpers;
using Mono.Cecil;
using MonoMod.Utils;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Terraria.ModLoader;
using File = System.IO.File;
// ReSharper disable once CheckNamespace
namespace Localizer
{
public static partial class Utils
{
#region Zip
/// <summary>
/// Add a file into a ZipArchive as an entry.
/// </summary>
/// <param name="archive">Target archive.</param>
/// <param name="filePath">The path of the file.</param>
/// <param name="entryName">Entry name in the archive.</param>
public static void WriteZipArchiveEntry(ZipArchive archive, string filePath, string entryName)
{
var fileEntry = archive.CreateEntry(entryName);
using (var stream = fileEntry.Open())
{
var fileBytes = File.ReadAllBytes(filePath);
stream.Write(fileBytes, 0, fileBytes.Length);
}
}
#endregion
#region Reflection
/// <summary>
/// Return the method matched with the findableName in the given type.
/// Return null if fail.
/// </summary>
/// <param name="findableName"></param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public static MethodBase GetMethodBase<T>(string findableName)
{
var method = typeof(T).FindMethod(findableName);
return method != null ? MethodBase.GetMethodFromHandle(method.MethodHandle) : null;
}
private static Dictionary<Module, Dictionary<string, MethodBase>> _cachedMethod = new Dictionary<Module, Dictionary<string, MethodBase>>();
public static MethodBase FindMethodByID(Module m, string findableName)
{
if (!_cachedMethod.ContainsKey(m))
{
_cachedMethod.Add(m, new Dictionary<string, MethodBase>());
foreach (var t in m.GetTypes())
{
foreach (var method in t.GetMethods(NoroHelper.Any))
{
var key = method.GetID();
if (!_cachedMethod[m].ContainsKey(key))
{
_cachedMethod[m].Add(key, method);
}
}
}
}
return _cachedMethod[m].ContainsKey(findableName) ? _cachedMethod[m][findableName] : null;
}
private static Regex genericTypeMatch = new Regex(@"\[\[(.*?), .*?\]\]", RegexOptions.Compiled);
public static MethodDefinition FindMethodByID(ModuleDefinition m, string findableName)
{
var cecilName = genericTypeMatch.Replace(findableName, "<$1>");
foreach (var t in m.GetTypes())
{
foreach (var method in t.Methods)
{
var id = method.GetID();
if (id == findableName)
{
return method;
}
if (id == cecilName)
{
return method;
}
}
}
return null;
}
#endregion
#region Json
/// <summary>
/// Serialize an object and write to disk.
/// </summary>
/// <param name="obj">Object want to serialize.</param>
/// <param name="path">Store path of the serialized file.</param>
/// <param name="indent"></param>
public static void SerializeJsonAndCreateFile(object obj, string path, bool indent = true)
{
using (var fs = new FileStream(path, FileMode.Create, FileAccess.Write))
{
using (var sw = new StreamWriter(fs))
{
sw.Write(JsonConvert.SerializeObject(obj, indent ? Formatting.Indented : Formatting.None, new VersionConverter()));
}
}
}
/// <summary>
/// Read a file return the deserialized object.
/// </summary>
/// <param name="path">Path of the file.</param>
/// <typeparam name="T">The type of result.</typeparam>
/// <returns></returns>
public static T ReadFileAndDeserializeJson<T>(string path)
{
using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read))
{
return ReadFileAndDeserializeJson<T>(fs);
}
}
/// <summary>
/// Read a stream return the deserialized object.
/// </summary>
/// <param name="stream">Stream want to deserialize.</param>
/// <typeparam name="T">The type of result.</typeparam>
/// <returns></returns>
public static T ReadFileAndDeserializeJson<T>(Stream stream)
{
using (var sr = new StreamReader(stream))
{
var content = sr.ReadToEnd();
try
{
return JsonConvert.DeserializeObject<T>(content, new VersionConverter());
}
catch
{
return JsonConvert.DeserializeObject<T>(content);
}
}
}
/// <summary>
/// Read a file return the deserialized object.
/// </summary>
/// <param name="t">The type of result.</param>
/// <param name="path">Path of the file.</param>
/// <returns></returns>
public static object ReadFileAndDeserializeJson(Type t, string path)
{
using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read))
{
return ReadFileAndDeserializeJson(t, fs);
}
}
/// <summary>
/// Read a file return the deserialized object.
/// </summary>
/// <param name="t">The type of result.</param>
/// <param name="stream">Stream want to deserialize.</param>
/// <returns></returns>
public static object ReadFileAndDeserializeJson(Type t, Stream stream)
{
using (var sr = new StreamReader(stream))
{
return JsonConvert.DeserializeObject(sr.ReadToEnd(), t);
}
}
#endregion
#region GameCulture
#endregion
#region Log
public static void LogFatal(object o)
{
Localizer.Log.Fatal(o);
}
public static void LogError(object o)
{
if (Localizer.Config.LogLevel >= LogLevel.Error)
{
Localizer.Log.Error(o);
}
}
public static void LogWarn(object o)
{
if (Localizer.Config.LogLevel >= LogLevel.Warn)
{
Localizer.Log.Warn(o);
}
}
public static void LogInfo(object o)
{
if (Localizer.Config.LogLevel >= LogLevel.Info)
{
Localizer.Log.Info(o);
}
}
public static void LogDebug(object o)
{
if (Localizer.Config.LogLevel >= LogLevel.Debug)
{
Localizer.Log.Debug(o);
}
}
#endregion
#region Network
internal static string UserAgent(bool localizer = true)
{
if (!localizer)
{
// Request by tModLoader
return $"tModLoader/{ModLoader.versionTag} ({Environment.OSVersion}; {(Environment.Is64BitOperatingSystem ? "x64" : "x86")})";
}
return $"Localizer/{Localizer.Instance.Version} ({Environment.OSVersion}; {(Environment.Is64BitOperatingSystem ? "x64" : "x86")}) tModLoader/{ModLoader.versionTag} ({(Environment.Is64BitOperatingSystem ? "x64" : "x86")})";
}
public static HttpWebResponse GET(string url)
{
var request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "GET";
request.ContentType = "application/json;charset=UTF-8";
request.Accept = "application/vnd.github.v3+json";
request.UserAgent = UserAgent();
request.Timeout = 9000;
request.Headers["Accept-Language"] = Terraria.Localization.LanguageManager.Instance.ActiveCulture.CultureInfo.ToString();
return (HttpWebResponse)request.GetResponse();
}
public static string GetResponseBody(HttpWebResponse response)
{
if (response == null)
{
return null;
}
var encoding = Encoding.UTF8;
using (var myResponseStream = response.GetResponseStream())
{
using (var myStreamReader = new StreamReader(myResponseStream, encoding))
{
return myStreamReader.ReadToEnd();
}
}
}
#endregion
#region Others
public static string AsRainbow(string text, int frameCounter, int? unit = null)
{
var rainbowText = "";
var hueUnit = 4f / (unit ?? text.Length);
var baseHue = (frameCounter % 300) / 300f;
for (var i = 0; i < text.Length; i++)
{
var colorHue = baseHue + hueUnit * i / text.Length;
var color = Terraria.Main.hslToRgb(1.5f - colorHue, 1, 0.7f);
rainbowText += $"[c/{color.R:X2}{color.G:X2}{color.B:X2}:{text[i]}]";
}
return rainbowText;
}
/// <summary>
/// Create mappings from the name of actual ModTranslation container in the mod to the property
/// in the translation file.
/// </summary>
/// <param name="entryType"></param>
/// <returns></returns>
public static Dictionary<string, PropertyInfo> CreateEntryMappings(Type entryType)
{
if (entryType == null)
{
throw new ArgumentNullException();
}
var mappings = new Dictionary<string, PropertyInfo>();
foreach (var prop in entryType.ModTranslationProp())
{
var attr =
prop.GetCustomAttribute(typeof(ModTranslationPropAttribute)) as ModTranslationPropAttribute;
mappings.Add(attr.PropName, prop);
}
return mappings;
}
/// <summary>
/// Get the translation of the property of the entry.
/// eg: GetTranslation(*an ItemEntry*, *Name property*)
/// which returns ItemEntry.Name.Translation.
/// </summary>
/// <param name="entry"></param>
/// <param name="prop"></param>
/// <returns></returns>
public static string GetTranslationOfEntry(IEntry entry, PropertyInfo prop)
{
return (prop.GetValue(entry) as BaseEntry)?.Translation;
}
/// <summary>
/// Create directory if doesn't exist.
/// </summary>
/// <param name="path"></param>
public static void EnsureDir(string path)
{
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
}
public static ICollection<IMod> GetLoadedMods()
{
return ModLoader.Mods?.Select(m => Localizer.GetWrappedMod(m.Name)).ToArray();
}
public static Mod GetModByName(string name)
{
return ModLoader.Mods.FirstOrDefault(m => m.Name == name);
}
public static string DateTimeToFileName(DateTime dateTime)
{
return string.Format("{0:yyyy-MM-dd_hh-mm-ss-tt}", dateTime);
}
public static string EscapePath(string path)
{
return path.Trim(Path.GetInvalidPathChars());
}
public static List<ILInstruction> GetInstructions(MethodBase method)
{
var dummy = new DynamicMethod("Dummy", typeof(void), new Type[] { });
if (method.GetMethodBody() is null)
{
return null;
}
return MethodBodyReader.GetInstructions(dummy.GetILGenerator(), method);
}
public static void SafeWrap(Action action)
{
SafeWrap(action, out var ex);
}
public static void SafeWrap(Action action, out Exception ex)
{
try
{
ex = null;
action();
}
catch (Exception e)
{
ex = e;
LogError(e);
}
}
public static T SafeWrap<T>(Func<T> func)
{
return SafeWrap(func, out var ex);
}
public static T SafeWrap<T>(Func<T> func, out Exception ex)
{
try
{
ex = null;
return func();
}
catch (Exception e)
{
ex = e;
LogError(e);
}
return default;
}
public static void Patch(this HarmonyInstance instance, string @class, string method, bool exactMatch = true, HarmonyMethod prefix = null, HarmonyMethod postfix = null, HarmonyMethod transpiler = null)
{
if (exactMatch)
{
instance.Patch(@class.Type().Method(method),
prefix: prefix,
postfix: postfix,
transpiler: transpiler);
}
else
{
instance.Patch(@class.Type()
.GetMethods(NoroHelper.Any)
.FirstOrDefault(m => m.Name.Contains(method)),
prefix: prefix,
postfix: postfix,
transpiler: transpiler);
}
}
#endregion
}
}
================================================
FILE: Localizer/Hooks.cs
================================================
using Microsoft.Xna.Framework;
namespace Localizer
{
public class Hooks
{
public delegate void BeforeModCtorHandler(object mod);
public static event BeforeModCtorHandler BeforeModCtor;
internal static void InvokeBeforeModCtor(object mod)
{
BeforeModCtor?.Invoke(mod);
}
public delegate void BeforeLoadHandler();
public static event BeforeLoadHandler BeforeLoad;
internal static void InvokeBeforeLoad()
{
BeforeLoad?.Invoke();
}
public delegate void BeforeSetupContentHandler();
public static event BeforeSetupContentHandler BeforeSetupContent;
internal static void InvokeBeforeSetupContent()
{
BeforeSetupContent?.Invoke();
}
public delegate void PostSetupContentHandler();
public static event PostSetupContentHandler PostSetupContent;
internal static void InvokePostSetupContent()
{
PostSetupContent?.Invoke();
}
public delegate void GameUpdateHandler(GameTime gameTime);
public static event GameUpdateHandler GameUpdate;
internal static void InvokeOnGameUpdate(GameTime gameTime)
{
GameUpdate?.Invoke(gameTime);
}
public delegate void PostDrawHandler(GameTime gameTime);
public static event PostDrawHandler PostDraw;
internal static void InvokeOnPostDraw(GameTime gameTime)
{
PostDraw?.Invoke(gameTime);
}
}
}
================================================
FILE: Localizer/Lang/Lang.cs
================================================
using System.Collections.Generic;
using Terraria.Localization;
using Terraria.ModLoader;
// ReSharper disable once CheckNamespace
namespace Localizer
{
public static class Lang
{
private static List<string> _keys = new List<string>()
{
"NewVersion",
"PackageManage",
"Reload",
"ReloadDesc",
"OpenFolder",
"OpenFolderDesc",
"NoPackageFound",
"PackageEnabled",
"PackageDisabled",
"PackageDisplay",
"RefreshOnline",
"RefreshOnlineDesc",
"PackageOnline",
"Export",
"ExportDesc",
"ExportWithTranslation",
"ExportWithTranslationDesc",
"PackageUpdate",
"PackageLoading",
"OpenUI",
"TranslatedBy"
};
private static Dictionary<string, string> _en = new Dictionary<string, string>()
{
{ _keys[0], "Found new version of Localizer: {0} \nPlease go update it." },
{ _keys[1], "Package Management" },
{ _keys[2], "Reload" },
{ _keys[3], "Reload all packages" },
{ _keys[4], "Open Localizer Folder" },
{ _keys[5], "Find downloaded and exported packages" },
{ _keys[6], "No localization package found for this Mod" },
{ _keys[7], "Enabled" },
{ _keys[8], "Disabled" },
{ _keys[9], "({0}) {1} v{2} by {3}" },
{ _keys[10], "Refresh" },
{ _keys[11], "Refresh online package list" },
{ _keys[12], "Online" },
{ _keys[13], "Export" },
{ _keys[14], "Export without current translation" },
{ _keys[15], "Export T" },
{ _keys[16], "Export with translation" },
{ _keys[17], "New Version" },
{ _keys[18], "Packages loading" },
{ _keys[19], "{0}, Click to open {1} config" },
{ _keys[20], "{0}, translated by {1}" },
};
private static Dictionary<string, string> _zh = new Dictionary<string, string>()
{
{ _keys[0], "发现汉化者Mod有新版本: {0} \n请前往更新。" },
{ _keys[1], "汉化包管理" },
{ _keys[2], "重新加载" },
{ _keys[3], "重新读取所有汉化包" },
{ _keys[4], "打开文件夹" },
{ _keys[5], "查找下载、导出的汉化包及配置文件" },
{ _keys[6], "你没有这个Mod的汉化包,\n请下载或自己制作" },
{ _keys[7], "已启用" },
{ _keys[8], "未启用" },
{ _keys[9], "({0}) {1} v{2} 作者:{3}" },
{ _keys[10], "刷新" },
{ _keys[11], "刷新在线汉化包列表" },
{ _keys[12], "未下载" },
{ _keys[13], "导出" },
{ _keys[14], "导出不包含当前翻译的汉化包" },
{ _keys[15], "导出翻译" },
{ _keys[16], "导出包含翻译的汉化包" },
{ _keys[17], "可更新" },
{ _keys[18], "正在加载汉化包,请稍候查看或刷新" },
{ _keys[19], "{0},点击打开{1}设置界面" },
{ _keys[20], "{0},汉化:{1}" },
};
public static void AddModTranslations(Mod mod)
{
foreach (var k in _keys)
{
var translation = mod.CreateTranslation(k);
translation.SetDefault(_en[k]);
translation.AddTranslation(GameCulture.Chinese, _zh[k]);
mod.AddTranslation(translation);
}
}
public static string _(string key, params object[] args)
{
var value = Language.GetTextValue($"Mods.Localizer.{key}");
if (value == $"Mods.Localizer.{key}")
{
value = Language.GetTextValue($"Mods.!Localizer.{key}");
}
return string.Format(value, args);
}
}
}
================================================
FILE: Localizer/Localizer.cs
================================================
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Net;
using System.Reflection;
using System.Threading.Tasks;
using Harmony;
using Localizer.Attributes;
using Localizer.DataModel;
using Localizer.DataModel.Default;
using Localizer.Helpers;
using Localizer.Network;
using Localizer.Package.Import;
using Localizer.UIs;
using log4net;
using Microsoft.Xna.Framework;
using MonoMod.RuntimeDetour.HookGen;
using Ninject;
using Terraria;
using Terraria.Localization;
using Terraria.ModLoader;
using Terraria.ModLoader.Core;
using static Localizer.Lang;
using File = System.IO.File;
namespace Localizer
{
public sealed class Localizer : Mod
{
public static string SavePath;
public static string SourcePackageDirPath;
public static string DownloadPackageDirPath;
public static string ConfigPath;
public static Localizer Instance { get; private set; }
public static ILog Log { get; private set; }
public static TmodFile TmodFile { get; private set; }
public static Configuration Config { get; set; }
public static OperationTiming State { get; internal set; }
internal static LocalizerKernel Kernel { get; private set; }
internal static HarmonyInstance Harmony { get; set; }
internal static MainWindow PackageUI { get; set; }
internal static LoadedModWrapper LoadedLocalizer;
private static Dictionary<int, GameCulture> _gameCultures;
private static bool _initiated = false;
public Localizer()
{
Instance = this;
LoadedLocalizer = new LoadedModWrapper("Terraria.ModLoader.Core.AssemblyManager".Type().ValueOf("loadedMods").Invoke("get_Item", "!Localizer"));
this.SetField("<File>k__BackingField", LoadedLocalizer.File);
this.SetField("<Code>k__BackingField", LoadedLocalizer.Code);
Log = LogManager.GetLogger(nameof(Localizer));
Harmony = HarmonyInstance.Create(nameof(Localizer));
Harmony.Patch("Terraria.ModLoader.Core.AssemblyManager", "Instantiate",
prefix: NoroHelper.HarmonyMethod(() => AfterLocalizerCtorHook(null)));
State = OperationTiming.BeforeModCtor;
TmodFile = Instance.ValueOf<TmodFile>("File");
Init();
_initiated = true;
}
private static void AfterLocalizerCtorHook(object mod)
{
Hooks.InvokeBeforeModCtor(mod);
}
private static void Init()
{
_gameCultures = typeof(GameCulture).ValueOf<Dictionary<int, GameCulture>>("_legacyCultures");
ServicePointManager.ServerCertificateValidationCallback += (s, cert, chain, sslPolicyErrors) => true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
SavePath = "./Localizer/";
SourcePackageDirPath = SavePath + "/Source/";
DownloadPackageDirPath = SavePath + "/Download/";
ConfigPath = SavePath + "/Config.json";
Utils.EnsureDir(SavePath);
Utils.EnsureDir(SourcePackageDirPath);
Utils.EnsureDir(DownloadPackageDirPath);
LoadConfig();
AddModTranslations(Instance);
Kernel = new LocalizerKernel();
Kernel.Init();
ModBrowser.Patches.Patch();
var autoImportService = Kernel.Get<AutoImportService>();
}
public override void Load()
{
if (!_initiated)
{
throw new Exception("Localizer not initialized.");
}
State = OperationTiming.BeforeModLoad;
Hooks.InvokeBeforeLoad();
Kernel.Get<RefreshLanguageService>();
UIModsPatch.Patch();
}
public override void PostSetupContent()
{
State = OperationTiming.BeforeContentLoad;
Hooks.InvokeBeforeSetupContent();
CheckUpdate();
AddPostDrawHook();
}
public UIHost UIHost { get; private set; }
private void AddPostDrawHook()
{
if (Main.dedServ)
{
return;
}
UIHost = new UIHost();
Main.OnPostDraw += OnPostDraw;
}
private void OnPostDraw(GameTime time)
{
if (Main.dedServ)
{
return;
}
Main.spriteBatch.SafeBegin();
Hooks.InvokeOnPostDraw(time);
try
{
UIHost.Update(time);
UIHost.Draw(time);
}
catch
{
}
if (PackageUI?.Visible ?? false)
{
Main.DrawCursor(Main.DrawThickCursor(false), false);
}
Main.spriteBatch.SafeEnd();
}
public override void PostAddRecipes()
{
State = OperationTiming.PostContentLoad;
Hooks.InvokePostSetupContent();
}
public override void UpdateUI(GameTime gameTime)
{
Hooks.InvokeOnGameUpdate(gameTime);
}
public void CheckUpdate()
{
Task.Run(() =>
{
var curVersion = Version;
if (Kernel.Get<IUpdateService>().CheckUpdate(curVersion, out var updateInfo))
{
var msg = _("NewVersion", updateInfo.Version);
if (Main.gameMenu)
{
UI.ShowInfoMessage(msg, 0);
}
else
{
Main.NewText(msg, Color.Red);
}
}
});
}
public override void Unload()
{
try
{
SaveConfig();
// MonoModHooks.RemoveAll use mod.Name to unload the mod assembly
LoadedLocalizer.File.SetField("<name>k__BackingField", "!Localizer");
LoadedLocalizer.SetField("name", "!Localizer");
PackageUI?.Close();
UIHost.Dispose();
Main.OnPostDraw -= OnPostDraw;
HookEndpointManager.RemoveAllOwnedBy(this);
Harmony.UnpatchAll(nameof(Localizer));
Harmony.UnpatchAll(nameof(Patches));
Kernel.Dispose();
PackageUI = null;
Harmony = null;
Kernel = null;
_gameCultures = null;
Config = null;
Instance = null;
}
catch (Exception e)
{
Log.Error(e);
}
finally
{
_initiated = false;
Log = null;
}
base.Unload();
}
public static void LoadConfig()
{
Log.Info("Loading config");
if (File.Exists(ConfigPath))
{
Config = Utils.ReadFileAndDeserializeJson<Configuration>(ConfigPath);
if (Config is null)
{
Config = new Configuration();
}
}
else
{
Log.Info("No config file, creating...");
Config = new Configuration();
}
Utils.SerializeJsonAndCreateFile(Config, ConfigPath);
Log.Info("Config loaded");
}
public static void SaveConfig()
{
Log.Info("Saving config...");
Utils.SerializeJsonAndCreateFile(Config, ConfigPath);
Log.Info("Config saved");
}
public static GameCulture AddGameCulture(CultureInfo culture)
{
return GameCulture.FromName(culture.Name) != null
? null
: new GameCulture(culture.Name, _gameCultures.Count);
}
public static GameCulture CultureInfoToGameCulture(CultureInfo culture)
{
var gc = GameCulture.FromName(culture.Name);
return gc ?? AddGameCulture(culture);
}
public static void RefreshLanguages()
{
Kernel.Get<RefreshLanguageService>().Refresh();
}
public static IMod GetWrappedMod(string name)
{
if (State < OperationTiming.PostContentLoad)
{
var loadedMods = "Terraria.ModLoader.Core.AssemblyManager".Type().ValueOf("loadedMods");
return (bool)loadedMods.Invoke("ContainsKey", name)
? new LoadedModWrapper(loadedMods.Invoke("get_Item", name))
: null;
}
var mod = Utils.GetModByName(name);
if (mod is null)
{
return null;
}
return new ModWrapper(mod);
}
public static bool CanDoOperationNow(Type t)
{
var attribute = t.GetCustomAttribute<OperationTimingAttribute>();
return attribute == null || CanDoOperationNow(attribute.Timing);
}
public static bool CanDoOperationNow(OperationTiming t)
{
return (t & State) != 0;
}
}
}
================================================
FILE: Localizer/Localizer.csproj
================================================
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(USERPROFILE)\Documents\My Games\Terraria\ModLoader\references\tModLoader.targets" />
<PropertyGroup>
<AssemblyName>Localizer</AssemblyName>
<TargetFramework>net45</TargetFramework>
<PlatformTarget>x86</PlatformTarget>
<LangVersion>7.3</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Lib.Harmony">
<Version>1.2.0.1</Version>
</PackageReference>
<PackageReference Include="Ninject">
<Version>3.3.4</Version>
</PackageReference>
<PackageReference Include="tModLoader.CodeAssist" Version="0.1.*" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Squid\Squid.csproj">
<Project>{205c6e4a-4f9c-44fe-bb81-48f9914f048f}</Project>
<Name>Squid</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Reference Include="System.IO.Compression" />
</ItemGroup>
<Target Name="BuildMod" AfterTargets="Build">
<Exec Command="mkdir $(ProjectDir)lib" Condition="!Exists('$(ProjectDir)lib')" />
<Exec Command="copy $(OutDir)0Harmony.dll $(ProjectDir)lib\0Harmony.dll" />
<Exec Command="copy $(OutDir)Ninject.dll $(ProjectDir)lib\Ninject.dll" />
<Exec Command="copy $(OutDir)Squid.dll $(ProjectDir)lib\Squid.dll" />
<Exec Command=""$(tMLBuildServerPath)" -build $(ProjectDir) -eac $(TargetPath) -define $(DefineConstants) -unsafe $(AllowUnsafeBlocks)" />
<Exec Command="$(SolutionDir)ModPatch\bin\Debug\net472\ModPatch.exe" Condition=" '$(Configuration)' == 'Debug' " />
<Exec Command="$(SolutionDir)ModPatch\bin\Release\net472\ModPatch.exe" Condition=" '$(Configuration)' == 'Release' " />
</Target>
</Project>
================================================
FILE: Localizer/Localizer.csproj.DotSettings
================================================
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=enums/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
================================================
FILE: Localizer/LocalizerKernel.cs
================================================
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using Localizer.Modules;
using Ninject;
using Ninject.Modules;
namespace Localizer
{
public sealed class LocalizerKernel : StandardKernel
{
public List<LocalizerPlugin> Plugins { get; private set; }
public Dictionary<string, bool> PluginEnableStatus { get; private set; }
private static readonly string ExternalPluginDirPath = "./Localizer/Plugins/";
public LocalizerKernel()
{
AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolveHandler;
Plugins = new List<LocalizerPlugin>();
PluginEnableStatus = new Dictionary<string, bool>();
}
public void Init()
{
Load(new NinjectModule[]
{
new DefaultPackageModule(),
new DefaultNetworkModule(),
});
LoadPlugins();
}
public override void Dispose(bool disposing)
{
if (!IsDisposed)
{
AppDomain.CurrentDomain.AssemblyResolve -= AssemblyResolveHandler;
if (disposing)
{
UnloadAllPlugins();
Plugins = null;
}
}
base.Dispose(disposing);
}
internal void UnloadAllPlugins()
{
foreach (var plugin in Plugins)
{
plugin.Dispose();
}
Plugins.Clear();
}
internal void LoadPlugins()
{
Utils.EnsureDir(ExternalPluginDirPath);
var dirInfo = new DirectoryInfo(ExternalPluginDirPath);
foreach (var file in dirInfo.GetFiles("*.dll"))
{
var a = Assembly.Load(File.ReadAllBytes(file.FullName));
LoadPlugin(a);
}
}
internal void LoadPlugin(Assembly asm)
{
try
{
foreach (var type in asm.GetExportedTypes())
{
if (type.IsSubclassOf(typeof(LocalizerPlugin)) && type.IsPublic && !type.IsAbstract)
{
var instance = (LocalizerPlugin)Activator.CreateInstance(type);
Plugins.Add(instance);
instance.Initialize(this);
Utils.LogInfo($"Plugin [{instance.Name}] loaded.");
}
}
}
catch (Exception e)
{
Utils.LogError($"Error occured when loading Plugin [{asm.GetName()}]. \nError: {e}");
}
}
internal void UnloadPlugin(string pluginName)
{
if (string.IsNullOrWhiteSpace(pluginName))
{
throw new ArgumentException(nameof(pluginName));
}
var plugin = Plugins.SingleOrDefault(p => p.Name == pluginName)
?? throw new Exception($"Cannot find plugin [{pluginName}]");
UnloadPlugin(plugin);
}
internal void UnloadPlugin(LocalizerPlugin plugin)
{
if (plugin is null)
{
Utils.LogWarn("Plugin cannot be unloaded because it's null");
return;
}
if (Plugins.Contains(plugin))
{
Utils.LogWarn($"Plugin [{plugin.Name}] doesn't exist");
return;
}
plugin.Dispose();
Plugins.Remove(plugin);
Utils.LogInfo($"Plugin [{plugin.Name}] successfully unloaded.");
}
private static Assembly AssemblyResolveHandler(object sender, ResolveEventArgs args)
{
try
{
var asmName = new AssemblyName(args.Name);
if (asmName.Name == "Localizer")
{
return Localizer.Instance.Code;
}
var referencedAsm = Assembly.GetExecutingAssembly().GetReferencedAssemblies()
.FirstOrDefault(a => a.Name.StartsWith($"!Localizer_{asmName.Name}_"));
if (referencedAsm != null)
{
return Assembly.Load(referencedAsm);
}
var fileName = asmName.Name + ".dll";
var asmFile = GetExternalPluginFileBytes(fileName);
if (asmFile != null && asmFile.Length != 0)
{
return Assembly.Load(asmFile);
}
return null;
}
catch (Exception)
{
return null;
}
}
private static byte[] GetExternalPluginFileBytes(string fileName)
{
var path = Path.Combine(ExternalPluginDirPath, fileName);
if (!File.Exists(path))
{
return null;
}
return File.ReadAllBytes(path);
}
}
}
================================================
FILE: Localizer/LocalizerPlugin.cs
================================================
using System;
namespace Localizer
{
public abstract class LocalizerPlugin : Disposable
{
public abstract string Name { get; }
public abstract string Author { get; }
public virtual Version Version => new Version();
public abstract string Description { get; }
public abstract void Initialize(LocalizerKernel kernel);
}
}
================================================
FILE: Localizer/ModBrowser/Patches.cs
================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Reflection.Emit;
using System.Text.RegularExpressions;
using Harmony;
using Terraria.Localization;
using Terraria.ModLoader;
namespace Localizer.ModBrowser
{
public static class Patches
{
public static HarmonyInstance HarmonyInstance { get; set; }
public static void Patch()
{
Utils.LogInfo($"Patching ModBrowser, tML version: {ModLoader.version}");
HarmonyInstance = HarmonyInstance.Create(nameof(Patches));
if (LanguageManager.Instance.ActiveCulture == GameCulture.Chinese)
{
try
{
#region Download Mod List
if (!string.IsNullOrEmpty(GetModListURL()))
{
HarmonyInstance.Patch("Terraria.ModLoader.UI.ModBrowser.UIModBrowser", "<PopulateModBrowser>",
exactMatch: false,
transpiler: NoroHelper.HarmonyMethod(() => PopulateModBrowserTranspiler(null)));
Utils.LogInfo("PopulateModBrowser Patched");
}
#endregion
#region Get Mod Download URL
if (!string.IsNullOrEmpty(GetModDownloadURL()))
{
HarmonyInstance.Patch("Terraria.ModLoader.UI.ModBrowser.UIModDownloadItem", "FromJson",
transpiler: NoroHelper.HarmonyMethod(() => FromJSONTranspiler(null)));
Utils.LogInfo("FromJson Patched");
if (!string.IsNullOrEmpty(GetModDescURL()))
{
HarmonyInstance.Patch("Terraria.ModLoader.UI.UIModInfo", "<OnActivate>",
exactMatch: false,
transpiler: NoroHelper.HarmonyMethod(() => OnActivateTranspiler(null)));
Utils.LogInfo("OnActivate Patched");
}
}
#endregion
#region List My Mods
// Terraria.ModLoader.UI.UIManagePublished.OnActivate
// "http://javid.ddns.net/tModLoader/listmymods.php"
#endregion
#region Publish Mod
// Terraria.ModLoader.UI.UIModSourceItem.PublishMod
// "http://javid.ddns.net/tModLoader/publishmod.php"
#endregion
#region Unpublish Mod
// Terraria.ModLoader.UI.UIModManageItem.UnpublishMod
// "http://javid.ddns.net/tModLoader/unpublishmymod.php"
#endregion
#region Register Link
// Terraria.ModLoader.UI.UIEnterPassphraseMenu.VisitRegisterWebpage
// Terraria.ModLoader.UI.UIEnterSteamIDMenu.VisitRegisterWebpage
// "http://javid.ddns.net/tModLoader/register.php"
#endregion
#region Direct Mod Listing
// Terraria.ModLoader.UI.ModBrowser.UIModBrowser.<>c.<ShowOfflineTroubleshootingMessage>
// "http://javid.ddns.net/tModLoader/DirectModDownloadListing.php"
HarmonyInstance.Patch("Terraria.ModLoader.UI.ModBrowser.UIModBrowser.<>c", "<ShowOfflineTroubleshootingMessage>",
exactMatch: false,
transpiler: NoroHelper.HarmonyMethod(() => DirectModListingTranspiler(null)));
Utils.LogInfo("DirectModListing Patched");
#endregion
#region Query Mod Download URL
// Terraria.ModLoader.Interface.ServerModBrowserMenu
// "http://javid.ddns.net/tModLoader/tools/querymoddownloadurl.php?modname="
#endregion
#region Error Report
// No plan
#endregion
#region ModCompile
HarmonyInstance.Patch("Terraria.ModLoader.UI.UIDeveloperModeHelp", "DownloadModCompile",
transpiler: NoroHelper.HarmonyMethod(() => ModCompileTranspiler(null)));
Utils.LogInfo("DownloadModCompile Patched");
#endregion
#region Mod Update
HarmonyInstance.Patch("Terraria.ModLoader.UI.DownloadManager.DownloadModFile", "PreCopy",
prefix: NoroHelper.HarmonyMethod(() => PreCopyPrefix(null)));
Utils.LogInfo("PreCopy Patched");
#endregion
Utils.LogInfo("ModBrowser Patched");
}
catch (Exception e)
{
Utils.LogInfo($"ModBrowser Patch exception: {e}");
}
}
try
{
HarmonyInstance.Patch("Terraria.ModLoader.UI.DownloadManager.DownloadFile", "SetupDownloadRequest",
postfix: NoroHelper.HarmonyMethod(() => PostSetupDownloadRequest(null)));
Utils.LogInfo("SetupDownloadRequest Patched");
}
catch (Exception e)
{
Utils.LogInfo($"ModBrowser Patch exception: {e}");
}
}
private static readonly Regex _defaultMirror = new Regex(@"mirror(?:\d*)?\.sgkoi\.dev");
private static string GetModListURL()
{
var mirror = Localizer.Config.ModListMirror[0];
switch (mirror)
{
case "mirror2.sgkoi.dev":
return "http://www.mb.axeel.moe/tModLoader/listmods.php";
case "mirror3.sgkoi.dev":
return "https://trbbs.cc/trmod/listmods.php";
case "mirror4.sgkoi.dev":
return "http://www.mb2.axeel.moe:25555/tModLoader/listmods.php";
default:
return _defaultMirror.IsMatch(mirror) ? $"https://{mirror}/tModLoader/listmods.php" : mirror;
}
}
private static string GetModDownloadURL()
{
var mirror = Localizer.Config.ModDownloadMirror[0];
switch (mirror)
{
case "mirror2.sgkoi.dev":
return "http://www.mb.axeel.moe/tModLoader/download.php?Down=mods/";
case "mirror3.sgkoi.dev":
return "https://trbbs.cc/trmod/";
case "mirror4.sgkoi.dev":
return "http://www.mb2.axeel.moe:25555/tModLoader/download.php?Down=mods/";
default:
return _defaultMirror.IsMatch(mirror) ? $"https://{mirror}/tModLoader/download.php?Down=mods/" : mirror;
}
}
private static string GetModDescURL()
{
var mirror = Localizer.Config.ModDescMirror[0];
switch (mirror)
{
case "mirror2.sgkoi.dev":
return "http://www.mb.axeel.moe/tModLoader/moddescription.php";
case "mirror4.sgkoi.dev":
return "http://www.mb2.axeel.moe:25555/tModLoader/moddescription.php";
default:
return _defaultMirror.IsMatch(mirror) ? $"https://{mirror}/tModLoader/moddescription.php" : mirror;
}
}
private static void PreCopyPrefix(object ___ModBrowserItem)
{
if (___ModBrowserItem.ValueOf<string>("ModName") == "Localizer")
{
___ModBrowserItem.SetField("ModName", "!Localizer");
}
}
private static void PostSetupDownloadRequest(object __instance)
{
var request = __instance.ValueOf<HttpWebRequest>("<Request>k__BackingField");
request.UserAgent = Utils.UserAgent(false);
request.Headers[HttpRequestHeader.AcceptLanguage] = LanguageManager.Instance.ActiveCulture.CultureInfo.ToString();
}
public static void UpdateHeader(WebClient wc)
{
wc.Headers[HttpRequestHeader.UserAgent] = Utils.UserAgent(false);
wc.Headers[HttpRequestHeader.AcceptLanguage] = LanguageManager.Instance.ActiveCulture.CultureInfo.ToString();
}
private static IEnumerable<CodeInstruction> PopulateModBrowserTranspiler(IEnumerable<CodeInstruction> instructions)
{
var result = instructions.ToList();
ReplaceLdstr("http://javid.ddns.net/tModLoader/listmods.php", GetModListURL(), result);
for (int i = 0; i < result.Count; i++)
{
if (result[i].opcode == OpCodes.Callvirt && $"{result[i].operand}".Contains("UploadValuesCompleted"))
{
result.Insert(i + 1, new CodeInstruction(result[i + 1]));
result.Insert(i + 2, new CodeInstruction(OpCodes.Call, NoroHelper.MethodInfo(() => UpdateHeader(null))));
break;
}
}
return result;
}
private static IEnumerable<CodeInstruction> FromJSONTranspiler(IEnumerable<CodeInstruction> instructions)
{
var result = instructions.ToList();
ReplaceLdstr("http://javid.ddns.net/tModLoader/download.php?Down=mods/", GetModDownloadURL(), result);
ReplaceLdstr("&tls12=y", "", result);
return result;
}
private static IEnumerable<CodeInstruction> OnActivateTranspiler(IEnumerable<CodeInstruction> instructions)
{
var result = instructions.ToList();
ReplaceLdstr("http://javid.ddns.net/tModLoader/download.php?Down=mods/", GetModDownloadURL(), result);
ReplaceLdstr("http://javid.ddns.net/tModLoader/moddescription.php", GetModDescURL(), result);
return result;
}
private static IEnumerable<CodeInstruction> DirectModListingTranspiler(IEnumerable<CodeInstruction> instructions)
{
var result = instructions.ToList();
ReplaceLdstr("http://javid.ddns.net/tModLoader/DirectModDownloadListing.php", "https://mirror.sgkoi.dev/", result);
return result;
}
private static IEnumerable<CodeInstruction> ModCompileTranspiler(IEnumerable<CodeInstruction> instructions)
{
var result = instructions.ToList();
for (int i = 0; i < result.Count; i++)
{
if (result[i].opcode == OpCodes.Ldstr && $"{result[i].operand}" == "https://github.com/tModLoader/tModLoader/releases/download/")
{
result[i].operand = "https://mirror.sgkoi.dev/direct";
result[i + 1] = new CodeInstruction(OpCodes.Ldstr, "");
}
}
return result;
}
private static void ReplaceLdstr(string o, string n, IEnumerable<CodeInstruction> il)
{
var ins = il.FirstOrDefault(i => i?.operand?.ToString() == o);
if (ins != null)
{
ins.operand = n;
}
}
}
}
================================================
FILE: Localizer/Modules/DefaultNetworkModule.cs
================================================
using Localizer.Network;
using Ninject.Modules;
namespace Localizer.Modules
{
public class DefaultNetworkModule : NinjectModule
{
public override void Load()
{
Bind<IPackageBrowserService>().To<PackageBrowser>().InSingletonScope();
Bind<IDownloadManagerService>().To<DownloadManager>().InSingletonScope();
Bind<IUpdateService>().To<GitHubModUpdate>().InSingletonScope();
}
}
}
================================================
FILE: Localizer/Modules/DefaultPackageModule.cs
================================================
using System;
using System.Reflection;
using Localizer.DataModel;
using Localizer.DataModel.Default;
using Localizer.Package;
using Localizer.Package.Export;
using Localizer.Package.Import;
using Localizer.Package.Load;
using Localizer.Package.Pack;
using Localizer.Package.Save;
using Localizer.Package.Update;
using Ninject;
using Ninject.Modules;
namespace Localizer.Modules
{
public class DefaultPackageModule : NinjectModule
{
public override void Load()
{
BindLoadService();
BindManageService();
BindImportService();
BindSaveService();
BindPackService();
BindExportService();
BindUpdateService();
}
public override void Unload()
{
Kernel.Get<AutoImportService>().Dispose();
Kernel.Get<RefreshLanguageService>().Dispose();
Kernel.Get<PackageImportService>().Dispose();
}
private void BindLoadService()
{
Bind<IFileLoadService>().To<JsonFileLoad>().InSingletonScope();
Bind<IPackageLoadService<DataModel.Default.Package>>()
.To<SourcePackageLoad<DataModel.Default.Package>>().InSingletonScope();
Bind<SourcePackageLoad<DataModel.Default.Package>>().ToSelf().InSingletonScope();
Bind<IPackageLoadService<DataModel.Default.Package>>()
.To<PackedPackageLoad<DataModel.Default.Package>>().InSingletonScope();
Bind<PackedPackageLoad<DataModel.Default.Package>>().ToSelf().InSingletonScope();
}
private void BindManageService()
{
Bind<IPackageManageService>().To<PackageManageService>();
}
private void BindImportService()
{
Bind<IPackageImportService>().To<PackageImportService>().InSingletonScope();
var packageImportService = Kernel.Get<IPackageImportService>();
if (Localizer.Config.ImporBasictAfterSetupContent)
{
packageImportService.RegisterImporter<BasicItemFile>(typeof(BasicImporterPostContentLoad<BasicItemFile>));
packageImportService.RegisterImporter<BasicNPCFile>(typeof(BasicImporterPostContentLoad<BasicNPCFile>));
packageImportService.RegisterImporter<BasicBuffFile>(typeof(BasicImporterPostContentLoad<BasicBuffFile>));
packageImportService.RegisterImporter<BasicProjectileFile>(typeof(BasicImporterPostContentLoad<BasicProjectileFile>));
packageImportService.RegisterImporter<BasicPrefixFile>(typeof(BasicImporterPostContentLoad<BasicPrefixFile>));
}
else
{
packageImportService.RegisterImporter<BasicItemFile>(typeof(BasicImporterBeforeContentLoad<BasicItemFile>));
packageImportService.RegisterImporter<BasicNPCFile>(typeof(BasicImporterBeforeContentLoad<BasicNPCFile>));
packageImportService.RegisterImporter<BasicBuffFile>(typeof(BasicImporterBeforeContentLoad<BasicBuffFile>));
packageImportService.RegisterImporter<BasicProjectileFile>(typeof(BasicImporterBeforeContentLoad<BasicProjectileFile>));
packageImportService.RegisterImporter<BasicPrefixFile>(typeof(BasicImporterBeforeContentLoad<BasicPrefixFile>));
}
packageImportService.RegisterImporter<CustomModTranslationFile>(typeof(CustomModTranslationImporter));
if (!string.IsNullOrWhiteSpace(Localizer.Config.LdstrImporter))
{
packageImportService.RegisterImporter<LdstrFile>(Assembly.GetExecutingAssembly().GetType($"Localizer.Package.Import.{Localizer.Config.LdstrImporter}LdstrImporter"));
}
else
{
packageImportService.RegisterImporter<LdstrFile>(typeof(CecilLdstrImporter));
}
Bind<AutoImportService>().ToSelf().InSingletonScope();
Bind<RefreshLanguageService>().ToSelf().InSingletonScope();
}
private void BindSaveService()
{
Bind<IPackageSaveService>().To<PackageSave>().InSingletonScope();
Bind<IFileSaveService>().To<JsonFileSaveService>().InSingletonScope();
}
private void BindPackService()
{
Bind<IPackagePackService>().To<ZipPackagePackService<DataModel.Default.Package>>().InSingletonScope();
Bind<ZipPackagePackService<DataModel.Default.Package>>().ToSelf().InSingletonScope();
}
private void BindExportService()
{
Bind<IPackageExportService>().To<PackageExport>().InSingletonScope();
Bind<IFileExportService>().To<BasicFileExport<BasicItemFile>>().InSingletonScope();
Bind<IFileExportService>().To<BasicFileExport<BasicNPCFile>>().InSingletonScope();
Bind<IFileExportService>().To<BasicFileExport<BasicBuffFile>>().InSingletonScope();
Bind<IFileExportService>().To<BasicFileExport<BasicProjectileFile>>().InSingletonScope();
Bind<IFileExportService>().To<BasicFileExport<BasicPrefixFile>>().InSingletonScope();
Bind<IFileExportService>().To<CustomModTranslationFileExport>().InSingletonScope();
Bind<IFileExportService>().To<LdstrFileExport>().InSingletonScope();
}
private void BindUpdateService()
{
void BindUpdate<T>(Type serviceType) where T : IFile
{
var updateService = Kernel.Get<IPackageUpdateService>();
Bind(typeof(FileUpdater), serviceType).To(serviceType).InSingletonScope();
updateService.RegisterUpdater<T>(Kernel.Get(serviceType) as FileUpdater);
}
Bind<IPackageUpdateService>().To<PackageUpdateService>().InSingletonScope();
BindUpdate<BasicItemFile>(typeof(BasicFileUpdater<BasicItemFile>));
BindUpdate<BasicNPCFile>(typeof(BasicFileUpdater<BasicNPCFile>));
BindUpdate<BasicBuffFile>(typeof(BasicFileUpdater<BasicBuffFile>));
BindUpdate<BasicProjectileFile>(typeof(BasicFileUpdater<BasicProjectileFile>));
BindUpdate<BasicPrefixFile>(typeof(BasicFileUpdater<BasicPrefixFile>));
BindUpdate<CustomModTranslationFile>(typeof(CustomModTranslationUpdater));
BindUpdate<LdstrFile>(typeof(LdstrFileUpdater));
Bind<IUpdateLogger>().To<PlainUpdateLogger>();
}
}
}
================================================
FILE: Localizer/Network/DownloadManager.cs
================================================
using System;
using System.Net;
namespace Localizer.Network
{
public class DownloadManager : IDownloadManagerService
{
public void Download(string url, string path)
{
var wc= new WebClient();
wc.Headers[HttpRequestHeader.UserAgent] = Utils.UserAgent();
wc.Headers[HttpRequestHeader.AcceptLanguage] = Terraria.Localization.LanguageManager.Instance.ActiveCulture.CultureInfo.ToString();
wc.DownloadFile(new Uri(url), path);
}
public void Dispose()
{
}
}
}
================================================
FILE: Localizer/Network/GitHubModUpdate.cs
================================================
using System;
using System.Collections.Generic;
using Localizer.DataModel;
using Localizer.DataModel.Default;
using Newtonsoft.Json.Linq;
namespace Localizer.Network
{
public sealed class GitHubModUpdate : IUpdateService
{
private JObject lastCheckResult;
public bool CheckUpdate(Version curVersion, out IUpdateInfo updateInfo)
{
var url = "https://api.github.com/repos/chi-rei-den/Localizer/releases/latest";
var response = Utils.GET(url);
lastCheckResult = JObject.Parse(Utils.GetResponseBody(response));
updateInfo = GetUpdateInfo(lastCheckResult);
if (updateInfo.Type == UpdateType.None)
{
return false;
}
return updateInfo.Version > curVersion;
}
internal GitHubUpdateInfo GetUpdateInfo(JObject jObject)
{
return new GitHubUpdateInfo(jObject["tag_name"].ToObject<string>());
}
public Dictionary<Version, string> GetChangeLog(Version from, Version to)
{
throw new NotImplementedException();
}
public string GetDownloadURL()
{
return GetDownloadURLInternal(lastCheckResult);
}
internal string GetDownloadURLInternal(JObject jObject)
{
var assets = jObject["assets"] as JArray;
if (assets == null || assets.Count == 0)
{
throw new Exception("Release has no assets!");
}
return assets[0]["browser_download_url"].ToObject<string>();
}
public void Dispose()
{
}
}
}
================================================
FILE: Localizer/Network/IDownloadManagerService.cs
================================================
namespace Localizer.Network
{
public interface IDownloadManagerService
{
void Download(string url, string path);
}
}
================================================
FILE: Localizer/Network/IPackageBrowserService.cs
================================================
using System.Collections.Generic;
using Localizer.DataModel;
namespace Localizer.Network
{
public interface IPackageBrowserService
{
ICollection<IPackage> GetList();
int GetPageCount();
ICollection<IPackage> GetListByPage(int i);
string GetDownloadLinkOf(IPackage package);
}
}
================================================
FILE: Localizer/Network/IUpdateService.cs
================================================
using System;
using System.Collections.Generic;
using Localizer.DataModel;
namespace Localizer.Network
{
public interface IUpdateService
{
bool CheckUpdate(Version curVersion, out IUpdateInfo updateInfo);
Dictionary<Version, string> GetChangeLog(Version from, Version to);
string GetDownloadURL();
}
}
================================================
FILE: Localizer/Network/PackageBrowser.cs
================================================
using System;
using System.Collections.Generic;
using System.Globalization;
using Localizer.DataModel;
using Newtonsoft.Json.Linq;
namespace Localizer.Network
{
public class PackageBrowser : IPackageBrowserService
{
#if DEBUG
public string serverURL = "http://127.0.0.1:8000/api/";
#else
public string serverURL = "https://mirror.sgkoi.dev/Localizer/";
#endif
private Dictionary<IPackage, int> packages = new Dictionary<IPackage, int>();
public ICollection<IPackage> GetList()
{
packages.Clear();
var result = new List<IPackage>();
var response = Utils.GET($"{serverURL}List");
var jArray = JArray.Parse(Utils.GetResponseBody(response));
foreach (JObject jo in jArray)
{
Utils.SafeWrap(() =>
{
var pack = new DataModel.Default.Package()
{
Name = jo["name"].ToObject<string>(),
Author = jo["author"].ToObject<string>(),
Version = jo["version"].ToObject<Version>(),
ModName = jo["mod"].ToObject<string>(),
Language = jo["language"].ToObject<CultureInfo>(),
Description = jo["description"].ToObject<string>(),
};
packages.Add(pack, jo["id"].Value<int>());
result.Add(pack);
});
}
return result;
}
public int GetPageCount()
{
throw new NotImplementedException();
}
public ICollection<IPackage> GetListByPage(int i)
{
throw new NotImplementedException();
}
public string GetDownloadLinkOf(IPackage package)
{
if (!packages.ContainsKey(package))
{
return null;
}
return $"{serverURL}Download/{packages[package]}";
}
public void Dispose()
{
}
}
}
================================================
FILE: Localizer/Package/Export/BasicFileExport.cs
================================================
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Reflection;
using Localizer.DataModel;
using Localizer.DataModel.Default;
using Localizer.Helpers;
using Terraria.ModLoader;
namespace Localizer.Package.Export
{
public sealed class BasicFileExport<T> : IFileExportService where T : IFile
{
public void Export(IPackage package, IExportConfig config)
{
var modName = package.ModName;
var mod = Utils.GetModByName(modName);
if (mod == null)
{
return;
}
var file = Activator.CreateInstance(typeof(T)) as IFile;
foreach (var prop in typeof(T).ModTranslationOwnerField())
{
var fieldName = prop.ModTranslationOwnerFieldName();
var field = mod.ValueOf<IDictionary>(fieldName);
var entryType = prop.PropertyType.GenericTypeArguments
.FirstOrDefault(g => g.GetInterfaces().Contains(typeof(IEntry)));
var entries = CreateEntries(field, entryType, package.Language, config.WithTranslation);
var entriesOfFile = (IDictionary)prop.GetValue(file);
foreach (var e in entries)
{
entriesOfFile.Add(e.Key, e.Value);
}
}
package.AddFile(file);
}
private Dictionary<string, object> CreateEntries(IDictionary localizeOwners, Type entryType, CultureInfo lang,
bool withTranslation)
{
var entries = new Dictionary<string, object>();
var mappings = Utils.CreateEntryMappings(entryType);
foreach (string key in localizeOwners.Keys)
{
var entry = Activator.CreateInstance(entryType);
foreach (var mapping in mappings)
{
var owner = localizeOwners[key];
var localizeTrans = owner?.GetType().GetProperty(mapping.Key)?.GetValue(owner) as ModTranslation;
mapping.Value.SetValue(entry, new BaseEntry
{
Origin = localizeTrans.DefaultOrEmpty(),
Translation = withTranslation ? localizeTrans?.GetTranslation(lang) : ""
});
}
entries.Add(key, entry);
}
return entries;
}
}
}
================================================
FILE: Localizer/Package/Export/CustomModTranslationFileExport.cs
================================================
using System.Collections.Generic;
using System.Reflection;
using Localizer.DataModel;
using Localizer.DataModel.Default;
using Localizer.Helpers;
using Terraria.ModLoader;
namespace Localizer.Package.Export
{
public class CustomModTranslationFileExport : IFileExportService
{
public void Export(IPackage package, IExportConfig config)
{
if (package?.Mod == null)
{
return;
}
var translations = Utils.GetModByName(package.ModName).ValueOf<Dictionary<string, ModTranslation>>("translations");
if (translations == null)
{
return;
}
var file = new CustomModTranslationFile
{
Translations = new Dictionary<string, BaseEntry>()
};
foreach (var translation in translations)
{
file.Translations.Add(translation.Key, new BaseEntry
{
Origin = translation.Value.DefaultOrEmpty(),
Translation = config.WithTranslation ? translation.Value?.GetTranslation(package.Language) : ""
});
}
package.AddFile(file);
}
public void Dispose()
{
}
}
}
================================================
FILE: Localizer/Package/Export/IFileExportService.cs
================================================
using Localizer.DataModel;
namespace Localizer.Package.Export
{
public interface IFileExportService
{
/// <summary>
/// Extract texts from mod and add them into the package.
/// </summary>
/// <param name="package"></param>
/// <param name="config"></param>
void Export(IPackage package, IExportConfig config);
}
}
================================================
FILE: Localizer/Package/Export/IPackageExportService.cs
================================================
using Localizer.DataModel;
namespace Localizer.Package.Export
{
public interface IPackageExportService
{
/// <summary>
/// Extract texts from the mod and fill up the package's file list.
/// </summary>
/// <param name="package">Package with necessary information.</param>
/// <param name="config"></param>
void Export(IPackage package, IExportConfig config);
}
}
================================================
FILE: Localizer/Package/Export/LdstrFileExport.cs
================================================
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using Localizer.DataModel;
using Localizer.DataModel.Default;
using Mono.Cecil;
using MonoMod.Utils;
using Terraria.ModLoader;
using static Localizer.Utils;
using OpCodes = Mono.Cecil.Cil.OpCodes;
namespace Localizer.Package.Export
{
public sealed class LdstrFileExport : IFileExportService
{
private static List<MethodBase> _blackList1 = new List<MethodBase>
{
GetMethodBase<ModTranslation>(
"System.String Terraria.ModLoader.ModTranslation::GetTranslation(System.String)"),
GetMethodBase<ModTranslation>(
"System.Void Terraria.ModLoader.ModTranslation::AddTranslation(System.Int32,System.String)"),
GetMethodBase<ModTranslation>(
"System.Void Terraria.ModLoader.ModTranslation::AddTranslation(System.String,System.String)"),
GetMethodBase<ModTranslation>(
"System.Void Terraria.ModLoader.ModTranslation::AddTranslation(Terraria.Localization.GameCulture,System.String)"),
GetMethodBase<Mod>(
"Microsoft.Xna.Framework.Graphics.Texture2D Terraria.ModLoader.Mod::GetTexture(System.String)"),
GetMethodBase<Mod>(
"Microsoft.Xna.Framework.Audio.SoundEffect Terraria.ModLoader.Mod::GetSound(System.String)"),
GetMethodBase<Mod>("Terraria.ModLoader.Audio.Music Terraria.ModLoader.Mod::GetMusic(System.String)"),
GetMethodBase<Mod>("ReLogic.Graphics.DynamicSpriteFont Terraria.ModLoader.Mod::GetFont(System.String)"),
GetMethodBase<Mod>(
"Microsoft.Xna.Framework.Graphics.Effect Terraria.ModLoader.Mod::GetEffect(System.String)"),
GetMethodBase<Mod>(
"Terraria.ModLoader.Config.ModConfig Terraria.ModLoader.Mod::GetConfig(System.String)"),
GetMethodBase<Mod>(
"Terraria.ModLoader.GlobalProjectile Terraria.ModLoader.Mod::GetGlobalProjectile(System.String)"),
GetMethodBase<Mod>("Terraria.ModLoader.ModNPC Terraria.ModLoader.Mod::GetNPC(System.String)"),
GetMethodBase<Mod>("System.Int32 Terraria.ModLoader.Mod::NPCType(System.String)"),
GetMethodBase<Mod>("Terraria.ModLoader.GlobalNPC Terraria.ModLoader.Mod::GetGlobalNPC(System.String)"),
GetMethodBase<Mod>("Terraria.ModLoader.ModPlayer Terraria.ModLoader.Mod::GetPlayer(System.String)"),
GetMethodBase<Mod>("Terraria.ModLoader.ModBuff Terraria.ModLoader.Mod::GetBuff(System.String)"),
GetMethodBase<Mod>("System.Int32 Terraria.ModLoader.Mod::BuffType(System.String)"),
GetMethodBase<Mod>(
"Terraria.ModLoader.GlobalBuff Terraria.ModLoader.Mod::GetGlobalBuff(System.String)"),
GetMethodBase<Mod>("Terraria.ModLoader.ModMountData Terraria.ModLoader.Mod::GetMount(System.String)"),
GetMethodBase<Mod>("System.Int32 Terraria.ModLoader.Mod::MountType(System.String)"),
GetMethodBase<Mod>("Terraria.ModLoader.ModWorld Terraria.ModLoader.Mod::GetModWorld(System.String)"),
GetMethodBase<Mod>(
"Terraria.ModLoader.ModUgBgStyle Terraria.ModLoader.Mod::GetUgBgStyle(System.String)"),
GetMethodBase<Mod>(
"Terraria.ModLoader.ModSurfaceBgStyle Terraria.ModLoader.Mod::GetSurfaceBgStyle(System.String)"),
GetMethodBase<Mod>("System.Int32 Terraria.ModLoader.Mod::GetSurfaceBgStyleSlot(System.String)"),
GetMethodBase<Mod>(
"Terraria.ModLoader.GlobalBgStyle Terraria.ModLoader.Mod::GetGlobalBgStyle(System.String)"),
GetMethodBase<Mod>(
"Terraria.ModLoader.ModWaterStyle Terraria.ModLoader.Mod::GetWaterStyle(System.String)"),
GetMethodBase<Mod>(
"Terraria.ModLoader.ModWaterfallStyle Terraria.ModLoader.Mod::GetWaterfallStyle(System.String)"),
GetMethodBase<Mod>("System.Int32 Terraria.ModLoader.Mod::GetWaterfallStyleSlot(System.String)"),
GetMethodBase<Mod>("System.Int32 Terraria.ModLoader.Mod::GetGoreSlot(System.String)"),
GetMethodBase<Mod>("System.Void Terraria.ModLoader.Mod::AddBackgroundTexture(System.String)"),
GetMethodBase<Mod>("System.Int32 Terraria.ModLoader.Mod::GetBackgroundSlot(System.String)"),
GetMethodBase<Mod>(
"Terraria.ModLoader.ModTranslation Terraria.ModLoader.Mod::CreateTranslation(System.String)"),
GetMethodBase<Mod>("System.Byte[] Terraria.ModLoader.Mod::GetFileBytes(System.String)"),
GetMethodBase<Mod>("Terraria.ModLoader.ModItem Terraria.ModLoader.Mod::GetItem(System.String)"),
GetMethodBase<Mod>("System.Int32 Terraria.ModLoader.Mod::ItemType(System.String)"),
GetMethodBase<Mod>(
"Terraria.ModLoader.GlobalItem Terraria.ModLoader.Mod::GetGlobalItem(System.String)"),
GetMethodBase<Mod>("Terraria.ModLoader.ModPrefix Terraria.ModLoader.Mod::GetPrefix(System.String)"),
GetMethodBase<Mod>("System.Byte Terraria.ModLoader.Mod::PrefixType(System.String)"),
GetMethodBase<Mod>("Terraria.ModLoader.ModDust Terraria.ModLoader.Mod::GetDust(System.String)"),
GetMethodBase<Mod>("System.Int32 Terraria.ModLoader.Mod::DustType(System.String)"),
GetMethodBase<Mod>("Terraria.ModLoader.ModTile Terraria.ModLoader.Mod::GetTile(System.String)"),
GetMethodBase<Mod>("System.Int32 Terraria.ModLoader.Mod::TileType(System.String)"),
GetMethodBase<Mod>(
"Terraria.ModLoader.GlobalTile Terraria.ModLoader.Mod::GetGlobalTile(System.String)"),
GetMethodBase<Mod>(
"Terraria.ModLoader.ModTileEntity Terraria.ModLoader.Mod::GetTileEntity(System.String)"),
GetMethodBase<Mod>("System.Int32 Terraria.ModLoader.Mod::TileEntityType(System.String)"),
GetMethodBase<Mod>("Terraria.ModLoader.ModWall Terraria.ModLoader.Mod::GetWall(System.String)"),
GetMethodBase<Mod>("System.Int32 Terraria.ModLoader.Mod::WallType(System.String)"),
GetMethodBase<Mod>(
"Terraria.ModLoader.GlobalWall Terraria.ModLoader.Mod::GetGlobalWall(System.String)"),
GetMethodBase<Mod>(
"Terraria.ModLoader.ModProjectile Terraria.ModLoader.Mod::GetProjectile(System.String)"),
GetMethodBase<Mod>("System.Int32 Terraria.ModLoader.Mod::ProjectileType(System.String)"),
typeof(ModContent).FindMethod(
"Microsoft.Xna.Framework.Audio.SoundEffect Terraria.ModLoader.ModContent::GetSound(System.String)"),
typeof(ModContent).FindMethod("System.Byte[] Terraria.ModLoader.ModContent::GetFileBytes(System.String)"),
typeof(ModContent).FindMethod("System.Boolean Terraria.ModLoader.ModContent::FileExists(System.String)"),
typeof(ModContent).FindMethod(
"Microsoft.Xna.Framework.Graphics.Texture2D Terraria.ModLoader.ModContent::GetTexture(System.String)"),
typeof(ModContent).FindMethod("System.Boolean Terraria.ModLoader.ModContent::TextureExists(System.String)"),
typeof(ModContent).FindMethod(
"Microsoft.Xna.Framework.Audio.SoundEffect Terraria.ModLoader.ModContent::GetSound(System.String)"),
typeof(ModContent).FindMethod("System.Boolean Terraria.ModLoader.ModContent::SoundExists(System.String)"),
typeof(ModContent).FindMethod(
"Terraria.ModLoader.Audio.Music Terraria.ModLoader.ModContent::GetMusic(System.String)"),
typeof(ModContent).FindMethod("System.Boolean Terraria.ModLoader.ModContent::MusicExists(System.String)"),
typeof(ModContent).FindMethod(
"System.Int32 Terraria.ModLoader.ModContent::GetModBossHeadSlot(System.String)"),
typeof(ModContent).FindMethod("System.Int32 Terraria.ModLoader.ModContent::GetModHeadSlot(System.String)"),
typeof(ModContent).FindMethod(
"System.Int32 Terraria.ModLoader.ModContent::GetModBackgroundSlot(System.String)"),
typeof(ModContent).FindMethod("System.Boolean Terraria.ModLoader.ModContent::SoundExists(System.String)"),
typeof(ModContent).FindMethod("System.Boolean Terraria.ModLoader.ModContent::SoundExists(System.String)"),
typeof(ModContent).FindMethod("System.Boolean Terraria.ModLoader.ModContent::SoundExists(System.String)"),
GetMethodBase<ModRecipe>(
"System.Void Terraria.ModLoader.ModRecipe::AddTile(Terraria.ModLoader.Mod,System.String)"),
typeof(ModLoader).FindMethod("Terraria.ModLoader.Mod Terraria.ModLoader.ModLoader::GetMod(System.String)"),
};
private static List<MethodBase> _blackList2 = new List<MethodBase>
{
GetMethodBase<ModRecipe>(
"System.Void Terraria.ModLoader.ModRecipe::AddIngredient(Terraria.ModLoader.Mod,System.String,System.Int32)"),
};
public void Export(IPackage package, IExportConfig config)
{
if (package?.Mod == null)
{
return;
}
var modFile = package.Mod.File;
var asmManager = "Terraria.ModLoader.Core.AssemblyManager".Type();
var assemblyName = (string)asmManager.Invoke("GetModAssemblyFileName", modFile, true);
var loadedMod = asmManager.ValueOf("loadedMods").Invoke("get_Item", package.Mod.Name);
var reref = (byte[])asmManager.GetNestedType("LoadedMod", NoroHelper.Any).Method("EncapsulateReferences")
.Invoke(loadedMod, new object[] { modFile.GetBytes(assemblyName), null });
var asm = AssemblyDefinition.ReadAssembly(new MemoryStream(reref));
var file = new LdstrFile
{
LdstrEntries = new Dictionary<string, LdstrEntry>()
};
foreach (var type in asm.MainModule.GetTypes())
{
if (type.Namespace == null)
{
continue;
}
foreach (var method in type.Methods)
{
if (method.DeclaringType?.Namespace == null || method.IsAbstract)
{
continue;
}
try
{
LogDebug($"Exporting method: [{method.GetID()}]");
var entry = GetEntryFromMethod(method);
if (entry != null && !file.LdstrEntries.ContainsKey(method.GetID()))
{
file.LdstrEntries.Add(method.GetID(), entry);
}
}
catch (Exception e)
{
Localizer.Log.Error(e.ToString());
}
}
}
package.AddFile(file);
}
private LdstrEntry GetEntryFromMethod(MethodDefinition method)
{
var instructions = method?.Body?.Instructions;
if (instructions == null)
{
return null;
}
var entry = new LdstrEntry { Instructions = new List<BaseEntry>() };
for (var i = 0; i < instructions.Count; i++)
{
var ins = instructions[i];
if (ins.OpCode == OpCodes.Ldstr && !string.IsNullOrWhiteSpace(ins.Operand.ToString()))
{
// Filter methods in blacklist1
if (i < instructions.Count - 1)
{
var next = instructions[i + 1];
var operandId = "";
if (next.OpCode == OpCodes.Call || next.OpCode == OpCodes.Callvirt)
{
operandId = (next.Operand as MethodReference).GetID();
}
else if (next.OpCode == OpCodes.Calli)
{
operandId = (next.Operand as CallSite).GetID();
}
if (!string.IsNullOrWhiteSpace(operandId) && _blackList1.Any(m => operandId == m?.GetID()))
{
continue;
}
}
// Filter methods in blacklist2
if (i < instructions.Count - 2)
{
var afterNext = instructions[i + 2];
var operandId = "";
if (afterNext.OpCode == OpCodes.Call || afterNext.OpCode == OpCodes.Callvirt)
{
operandId = (afterNext.Operand as MethodReference).GetID();
}
else if (afterNext.OpCode == OpCodes.Calli)
{
operandId = (afterNext.Operand as CallSite).GetID();
}
if (!string.IsNullOrWhiteSpace(operandId) && _blackList2.Any(m => operandId == m?.GetID()))
{
continue;
}
}
// No need to add a same string
if (entry.Instructions.Exists(e => e.Origin == ins.Operand.ToString()))
{
continue;
}
entry.Instructions.Add(new BaseEntry
{
Origin = ins.Operand.ToString(),
Translation = ""
});
}
}
return entry.Instructions.Count == 0 ? null : entry;
}
public void Dispose()
{
_blackList1 = null;
_blackList2 = null;
}
}
}
================================================
FILE: Localizer/Package/Export/PackageExport.cs
================================================
using Localizer.DataModel;
using Ninject;
using Terraria.ModLoader;
namespace Localizer.Package.Export
{
public class PackageExport : IPackageExportService
{
public void Export(IPackage package, IExportConfig config)
{
var fileExportServices = Localizer.Kernel.GetAll<IFileExportService>();
if (package.Mod == null || package.Mod.GetType() != typeof(Mod))
{
package.Mod = Localizer.GetWrappedMod(package.ModName);
}
foreach (var service in fileExportServices)
{
service.Export(package, config);
}
}
}
}
================================================
FILE: Localizer/Package/IPackageManageService.cs
================================================
using System.Collections.Generic;
using Localizer.DataModel;
namespace Localizer.Package
{
public interface IPackageManageService
{
/// <summary>
/// All added packages sorted by mod.
/// </summary>
ICollection<IPackageGroup> PackageGroups { get; set; }
/// <summary>
/// Add a package.
/// </summary>
/// <param name="package"></param>
void AddPackage(IPackage package);
/// <summary>
/// Remove a package.
/// </summary>
/// <param name="package"></param>
void RemovePackage(IPackage package);
/// <summary>
/// Load saved package state.
/// </summary>
void LoadState();
/// <summary>
/// Save the package state.
/// </summary>
void SaveState();
}
}
================================================
FILE: Localizer/Package/Import/AutoImportService.cs
================================================
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Localizer.DataModel;
using Localizer.DataModel.Default;
using Localizer.Helpers;
using Localizer.Package.Load;
using Localizer.Package.Pack;
using Localizer.UIs;
using Ninject;
using PackageModel = Localizer.DataModel.Default.Package;
namespace Localizer.Package.Import
{
public sealed class AutoImportService : Disposable
{
public bool Imported => _imported;
private readonly IPackageManageService _packageManage;
private readonly SourcePackageLoad<PackageModel> _sourcePackageLoad;
private readonly PackedPackageLoad<PackageModel> _packedPackageLoad;
private readonly IPackageImportService _packageImport;
private readonly IPackagePackService _packagePack;
private readonly IFileLoadService _fileLoad;
private bool _imported = false;
[Inject]
public AutoImportService(IPackageManageService packageManage,
SourcePackageLoad<PackageModel> sourcePackageLoad,
PackedPackageLoad<PackageModel> packedPackageLoad,
IPackageImportService packageImport,
IPackagePackService packagePack,
IFileLoadService fileLoad)
{
_packageManage = packageManage ?? throw new ArgumentNullException(nameof(packageManage));
_sourcePackageLoad = sourcePackageLoad ?? throw new ArgumentNullException(nameof(sourcePackageLoad));
_packedPackageLoad = packedPackageLoad ?? throw new ArgumentNullException(nameof(packedPackageLoad));
_packageImport = packageImport ?? throw new ArgumentNullException(nameof(packageImport));
_packagePack = packagePack ?? throw new ArgumentNullException(nameof(packagePack));
_fileLoad = fileLoad ?? throw new ArgumentNullException(nameof(fileLoad));
LoadPackages();
Hooks.BeforeModCtor += OnBeforeModCtor;
Hooks.PostSetupContent += OnPostSetupContent;
}
private void OnBeforeModCtor(object mod)
{
if (_imported)
{
return;
}
try
{
if (Localizer.Config.AutoImport)
{
var wrapped = new LoadedModWrapper(mod);
Utils.LogInfo($"Early auto import for mod: [{wrapped.Name}]");
Import(wrapped);
}
}
catch
{
}
}
private void OnPostSetupContent()
{
if (_imported)
{
return;
}
try
{
if (Localizer.Config.AutoImport)
{
Utils.LogInfo($"Late auto import begin.");
Import();
}
}
catch (Exception e)
{
Utils.LogError(e);
}
finally
{
_imported = true;
}
}
private void LoadPackages()
{
try
{
_packageManage.PackageGroups = new List<IPackageGroup>();
var type = Localizer.Config.AutoImportType;
if (type != AutoImportType.DownloadedOnly)
{
LoadSourcePackages();
}
if (type != AutoImportType.SourceOnly)
{
LoadPackedPackages();
}
_packageManage.LoadState();
UIModsPatch.ModsExtraInfo = _packageManage.PackageGroups.ToDictionary(group => group.Mod.Name,
group =>
{
var localizedModName = group.Packages.FirstOrDefault(pack => !string.IsNullOrWhiteSpace(pack.LocalizedModName))?.LocalizedModName;
return $"{localizedModName}{Environment.NewLine}{string.Join(Environment.NewLine, group.Packages.Select(UI.GetPkgLabelText))}";
});
}
catch (Exception e)
{
Utils.LogError(e);
}
}
private void LoadSourcePackages()
{
foreach (var dir in new DirectoryInfo(Localizer.SourcePackageDirPath).GetDirectories())
{
try
{
var pack = _sourcePackageLoad.Load(dir.FullName, _fileLoad);
if (pack != null)
{
_packageManage.AddPackage(pack);
_packagePack.Pack(Path.Combine(dir.FullName, "Package.json"));
}
}
catch
{
}
}
}
private void LoadPackedPackages()
{
var list = Directory.GetFiles(Localizer.DownloadPackageDirPath).ToList();
list.AddRange(Directory.GetFiles(Path.Combine(Terraria.Main.SavePath, "Mods"), "*.locpack"));
foreach (var file in list)
{
try
{
var pack = _packedPackageLoad.Load(file, _fileLoad);
if (pack != null)
{
_packageManage.AddPackage(pack);
}
}
catch
{
}
}
}
private void Import(IMod mod = null)
{
try
{
_packageImport.Clear();
if (mod is null)
{
foreach (var pg in _packageManage.PackageGroups)
{
QueuePackageGroup(pg);
}
}
else
{
QueuePackageGroup(_packageManage.PackageGroups.FirstOrDefault(pg => pg.Mod.Name == mod.Name));
}
_packageImport.Import(true);
Localizer.RefreshLanguages();
Utils.LogDebug("Auto import end.");
}
catch
{
}
}
private void QueuePackageGroup(IPackageGroup packageGroup)
{
if (packageGroup is null || !packageGroup.Mod.Enabled)
{
return;
}
foreach (var p in packageGroup.Packages)
{
if (p.Enabled)
{
_packageImport.Queue(p);
}
}
}
protected override void DisposeUnmanaged()
{
Hooks.PostSetupContent -= OnPostSetupContent;
Hooks.BeforeModCtor -= OnBeforeModCtor;
}
}
}
================================================
FILE: Localizer/Package/Import/BasicImporter.cs
================================================
using System;
using System.Collections;
using System.Globalization;
using System.Linq;
using System.Reflection;
using Localizer.Attributes;
using Localizer.DataModel;
using Localizer.DataModel.Default;
using Localizer.Helpers;
using Terraria.ModLoader;
namespace Localizer.Package.Import
{
public class BasicImporter<T> : FileImporter where T : IFile
{
public override void Import(IFile file, IMod mod, CultureInfo culture)
{
ImportInternal((T)file, mod, culture);
}
private void ImportInternal(T file, IMod mod, CultureInfo culture)
{
foreach (var prop in typeof(T).ModTranslationOwnerField())
{
var fieldName = prop.ModTranslationOwnerFieldName();
var field = Utils.GetModByName(mod.Name).ValueOf<IDictionary>(fieldName);
var entryType = prop.PropertyType.GenericTypeArguments
.FirstOrDefault(g => g.GetInterfaces().Contains(typeof(IEntry)));
var entries = (IDictionary)prop.GetValue(file);
ApplyEntries(entries, field, entryType, culture);
}
}
public override IFile Merge(IFile main, IFile addition)
{
return MergeInternal((T)main, (T)addition);
}
internal T MergeInternal(T main, T addition)
{
var result = Activator.CreateInstance(typeof(T));
foreach (var prop in typeof(T).ModTranslationOwnerField())
{
var entries = (IDictionary)Activator.CreateInstance(prop.PropertyType);
var mainEntryDict = (IDictionary)prop.GetValue(main);
var additionEntryDict = (IDictionary)prop.GetValue(addition);
foreach (string key in mainEntryDict.Keys)
{
entries.Add(key, (mainEntryDict[key] as IEntry)?.Clone());
}
foreach (string key in additionEntryDict.Keys)
{
if (entries.Contains(key))
{
entries[key] = Merge((IEntry)mainEntryDict[key], (IEntry)additionEntryDict[key]);
}
else
{
entries.Add(key, additionEntryDict[key]);
}
}
prop.SetValue(result, entries);
}
return (T)result;
}
public IEntry Merge(IEntry main, IEntry addition)
{
if (main.GetType() != addition.GetType())
{
return main;
}
var result = Activator.CreateInstance(main.GetType()) as IEntry;
var props = result.GetType().ModTranslationProp();
foreach (var prop in props)
{
var merged = Utils.GetTranslationOfEntry(main, prop);
if (string.IsNullOrEmpty(merged))
{
merged = Utils.GetTranslationOfEntry(addition, prop) ?? "";
}
var baseEntry = Activator.CreateInstance(prop.PropertyType) as BaseEntry;
baseEntry.Translation = merged;
prop.SetValue(result, baseEntry);
}
return result;
}
private void ApplyEntries(IDictionary entries, IDictionary field, Type entryType, CultureInfo culture)
{
var mappings = Utils.CreateEntryMappings(entryType);
foreach (string eKey in entries.Keys)
{
if (!field.Contains(eKey))
{
continue;
}
foreach (var mapping in mappings)
{
var localizeOwner = field[eKey];
var modTrans =
localizeOwner?.GetType().GetProperty(mapping.Key)?.GetValue(localizeOwner) as ModTranslation;
modTrans?.Import(mapping.Value.GetValue(entries[eKey]) as BaseEntry, culture);
}
}
}
}
[OperationTiming(OperationTiming.PostContentLoad)]
public class BasicImporterPostContentLoad<T> : BasicImporter<T> where T : IFile { }
[OperationTiming(OperationTiming.BeforeContentLoad)]
public class BasicImporterBeforeContentLoad<T> : BasicImporter<T> where T : IFile { }
}
================================================
FILE: Localizer/Package/Import/CecilLdstrImporter.cs
================================================
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using Harmony;
using Localizer.Attributes;
using Localizer.DataModel;
using Localizer.DataModel.Default;
using Mono.Cecil;
using Mono.Cecil.Cil;
using Ninject;
namespace Localizer.Package.Import
{
[OperationTiming(OperationTiming.BeforeModCtor)]
public class CecilLdstrImporter : LdstrImporterBase
{
public bool Importing = false;
public LdstrFile ImportingFile;
public IMod ImportingMod;
private HarmonyInstance _harmony;
public CecilLdstrImporter()
{
_harmony = HarmonyInstance.Create(nameof(CecilLdstrImporter));
_harmony.Patch("Terraria.ModLoader.Core.AssemblyManager", "GetModAssembly",
postfix: new HarmonyMethod(typeof(CecilLdstrImporter).Method(nameof(PostGetModAssembly))));
}
public static void PostGetModAssembly(ref byte[] __result)
{
try
{
var instance = Localizer.Kernel.Get<CecilLdstrImporter>();
if (!instance.Importing || !Localizer.Config.ImportLdstr)
{
return;
}
using (var ms = new MemoryStream(__result))
{
var asmDef = AssemblyDefinition.ReadAssembly(ms);
instance.PatchAssembly(asmDef);
var result = new MemoryStream();
asmDef.Write(result);
__result = result.ToArray();
}
}
catch
{
}
}
private void PatchAssembly(AssemblyDefinition asm)
{
var module = asm.MainModule;
var entryDict = ImportingFile.LdstrEntries;
foreach (var entryPair in entryDict)
{
Utils.SafeWrap(() =>
{
if (!HaveTranslation(entryPair.Value))
{
return;
}
Utils.LogDebug($"Finding method: [{entryPair.Key}]");
var method = Utils.FindMethodByID(module, entryPair.Key);
if (method == null)
{
Utils.LogDebug($"Cannot find.");
return;
}
var instructions = method.Body?.Instructions;
if (instructions == null || !instructions.Any())
{
return;
}
var result = instructions.ToList();
foreach (var translation in entryPair.Value.Instructions)
{
ReplaceLdstr(translation.Origin, translation.Translation, result);
}
Utils.LogDebug($"Patched: {entryPair.Key}");
});
}
}
protected override void ImportInternal(LdstrFile file, IMod mod, CultureInfo culture)
{
Importing = true;
try
{
ImportingFile = file;
ImportingMod = mod;
if ((mod as LoadedModWrapper).wrapped.TryGetTarget(out var loadedMod))
{
loadedMod.Invoke("set_NeedsReload", true);
loadedMod.Invoke("LoadAssemblies");
}
}
finally
{
Importing = false;
}
}
private static void ReplaceLdstr(string o, string n, IEnumerable<Instruction> il)
{
if (string.IsNullOrEmpty(n))
{
return;
}
foreach (var i in il)
{
if (i.OpCode == OpCodes.Ldstr && i?.Operand?.ToString() == o)
{
i.Operand = n;
}
}
}
protected override void DisposeUnmanaged()
{
_harmony.UnpatchAll(nameof(CecilLdstrImporter));
}
}
}
================================================
FILE: Localizer/Package/Import/CustomModTranslationImporter.cs
================================================
using System.Collections.Generic;
using System.Globalization;
using System.Reflection;
using Localizer.Attributes;
using Localizer.DataModel;
using Localizer.DataModel.Default;
using Localizer.Helpers;
using Terraria.ModLoader;
namespace Localizer.Package.Import
{
[OperationTiming(OperationTiming.PostContentLoad)]
public class CustomModTranslationImporter : FileImporter
{
public override void Import(IFile file, IMod mod, CultureInfo culture)
{
ImportInternal(file as CustomModTranslationFile, mod, culture);
}
private void ImportInternal(CustomModTranslationFile file, IMod mod, CultureInfo culture)
{
var entryDict = file.Translations;
var translations = Utils.GetModByName(mod.Name).ValueOf<IDictionary<string, ModTranslation>>("translations");
if (translations == null)
{
return;
}
foreach (var pair in entryDict)
{
if (!translations.ContainsKey(pair.Key))
{
continue;
}
var translation = translations[pair.Key];
translation?.Import(pair.Value, culture);
translations[pair.Key] = translation;
}
}
public override IFile Merge(IFile main, IFile addition)
{
return MergeInternal(main as CustomModTranslationFile, addition as CustomModTranslationFile);
}
internal CustomModTranslationFile MergeInternal(CustomModTranslationFile main, CustomModTranslationFile addition)
{
var result = new CustomModTranslationFile
{
Translations = new Dictionary<string, BaseEntry>()
};
foreach (var t in main.Translations)
{
result.Translations.Add(t.Key, t.Value.Clone() as BaseEntry);
}
foreach (var pair in addition.Translations)
{
if (result.Translations.ContainsKey(pair.Key))
{
result.Translations[pair.Key] = Merge(main.Translations[pair.Key], pair.Value);
}
else
{
result.Translations.Add(pair.Key, pair.Value.Clone() as BaseEntry);
}
}
return result;
}
public BaseEntry Merge(BaseEntry main, BaseEntry addition)
{
var e = main.Clone() as BaseEntry;
if (string.IsNullOrWhiteSpace(main.Translation))
{
e.Translation = addition.Translation;
}
return e;
}
}
}
================================================
FILE: Localizer/Package/Import/FileImporter.cs
================================================
using System.Globalization;
using Localizer.DataModel;
namespace Localizer.Package.Import
{
public abstract class FileImporter : Disposable
{
/// <summary>
/// Import a file into correspond mod.
/// </summary>
/// <param name="file"></param>
/// <param name="mod"></param>
/// <param name="culture"></param>
public abstract void Import(IFile file, IMod mod, CultureInfo culture);
/// <summary>
/// Merge an entry into another one.
/// </summary>
/// <param name="main"></param>
/// <param name="addition"></param>
/// <returns></returns>
public abstract IFile Merge(IFile main, IFile addition);
public virtual void Reset() { }
}
}
================================================
FILE: Localizer/Package/Import/HarmonyLdstrImporter.cs
================================================
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Reflection;
using Harmony;
using Localizer.DataModel;
using Localizer.DataModel.Default;
namespace Localizer.Package.Import
{
public sealed class HarmonyLdstrImporter : LdstrImporterBase
{
private HarmonyInstance harmony;
private static Dictionary<MethodBase, LdstrEntry> entries;
public HarmonyLdstrImporter()
{
harmony = HarmonyInstance.Create("LdstrFileImport");
}
protected override void ImportInternal(LdstrFile file, IMod mod, CultureInfo culture)
{
entries = new Dictionary<MethodBase, LdstrEntry>();
var module = mod.Code.ManifestModule;
var entryDict = file.LdstrEntries;
foreach (var entryPair in entryDict)
{
Utils.SafeWrap(() =>
{
if (!HaveTranslation(entryPair.Value))
{
return;
}
Utils.LogDebug($"Finding method: [{entryPair.Key}]");
var method = Utils.FindMethodByID(module, entryPair.Key);
if (method == null)
{
Utils.LogDebug($"Cannot find.");
return;
}
entries.Add(method, entryPair.Value);
harmony.Patch(method, transpiler: new HarmonyMethod(NoroHelper.MethodInfo(() => Transpile(null, null))));
Utils.LogDebug($"Patched: {entryPair.Key}");
});
}
}
public override void Reset()
{
harmony.UnpatchAll("LdstrFileImport");
}
private static IEnumerable<CodeInstruction> Transpile(IEnumerable<CodeInstruction> instructions, MethodBase original)
{
if (!entries.ContainsKey(original) || instructions == null || instructions.Count() == 0)
{
return instructions;
}
var result = instructions.ToList();
var entry = entries[original];
foreach (var translation in entry.Instructions)
{
ReplaceLdstr(translation.Origin, translation.Translation, result);
}
return result;
}
private static void ReplaceLdstr(string o, string n, IEnumerable<CodeInstruction> il)
{
if (string.IsNullOrEmpty(n))
{
return;
}
var ins = il.FirstOrDefault(i => i?.operand?.ToString() == o);
if (ins != null)
{
ins.operand = n;
}
}
protected override void DisposeUnmanaged()
{
entries = null;
harmony.UnpatchAll("LdstrFileImport");
}
}
}
================================================
FILE: Localizer/Package/Import/IPackageImportService.cs
================================================
using System;
using Localizer.DataModel;
namespace Localizer.Package.Import
{
public interface IPackageImportService
{
void RegisterImporter<T>(Type importerType) where T : IFile;
void UnregisterImporter<T>() where T : IFile;
/// <summary>
/// Add a package into the internal queue,
/// earlier packages have more priorities.
/// </summary>
/// <param name="package"></param>
void Queue(IPackage package);
/// <summary>
/// Start the import process.
/// </summary>
void Import(bool preferEarly);
/// <summary>
/// Clear internal queue and ready for next work.
/// </summary>
void Reset();
/// <summary>
/// Clear internal queue.
/// </summary>
void Clear();
}
}
================================================
FILE: Localizer/Package/Import/LdstrImporterBase.cs
================================================
using System.Collections.Generic;
using System.Globalization;
using Localizer.DataModel;
using Localizer.DataModel.Default;
namespace Localizer.Package.Import
{
public abstract class LdstrImporterBase : FileImporter
{
internal bool HaveTranslation(LdstrEntry entry)
{
foreach (var ins in entry.Instructions)
{
if (!string.IsNullOrEmpty(ins.Translation))
{
return true;
}
}
return false;
}
public override void Import(IFile file, IMod mod, CultureInfo culture)
{
ImportInternal(file as LdstrFile, mod, culture);
}
public override IFile Merge(IFile main, IFile addition)
{
return MergeInternal(main as LdstrFile, addition as LdstrFile);
}
protected abstract void ImportInternal(LdstrFile file, IMod mod, CultureInfo culture);
internal LdstrFile MergeInternal(LdstrFile main, LdstrFile addition)
{
var result = new LdstrFile
{
LdstrEntries = new Dictionary<string, LdstrEntry>()
};
foreach (var e in main.LdstrEntries)
{
result.LdstrEntries.Add(e.Key, e.Value.Clone() as LdstrEntry);
}
foreach (var pair in addition.LdstrEntries)
{
if (result.LdstrEntries.ContainsKey(pair.Key))
{
result.LdstrEntries[pair.Key] = Merge(main.LdstrEntries[pair.Key], pair.Value);
}
else
{
result.LdstrEntries.Add(pair.Key, pair.Value);
}
}
return result;
}
internal LdstrEntry Merge(LdstrEntry main, LdstrEntry addition)
{
var result = new LdstrEntry { Instructions = new List<BaseEntry>() };
foreach (var ins in main.Instructions)
{
if (!result.Instructions.Exists(i => i.Origin == ins.Origin))
{
result.Instructions.Add(ins.Clone() as BaseEntry);
}
}
foreach (var ins in addition.Instructions)
{
if (!result.Instructions.Exists(i => i.Origin == ins.Origin))
{
result.Instructions.Add(ins.Clone() as BaseEntry);
}
}
return result;
}
}
}
================================================
FILE: Localizer/Package/Import/MonoModLdstrImporter.cs
================================================
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Reflection;
using Localizer.DataModel;
using Localizer.DataModel.Default;
using MonoMod.Cil;
using MonoMod.RuntimeDetour.HookGen;
namespace Localizer.Package.Import
{
public class MonoModLdstrImporter : LdstrImporterBase
{
private Dictionary<MethodBase, ILContext.Manipulator> modifications;
public MonoModLdstrImporter()
{
modifications = new Dictionary<MethodBase, ILContext.Manipulator>();
}
protected override void ImportInternal(LdstrFile file, IMod mod, CultureInfo culture)
{
Terraria.ModLoader.ContentInstance.Register(Utils.GetModByName(mod.Name));
var module = mod.Code.ManifestModule;
var entryDict = file.LdstrEntries;
foreach (var entryPair in entryDict)
{
var method = Utils.FindMethodByID(module, entryPair.Key);
if (method == null)
{
continue;
}
var e = entryPair.Value;
if (!HaveTranslation(e))
{
continue;
}
var modification = new ILContext.Manipulator(il =>
{
foreach (var instruction in il.Instrs)
{
var ins = e.Instructions.FirstOrDefault(i => instruction.MatchLdstr(i.Origin));
if (ins == null || string.IsNullOrEmpty(ins.Translation))
{
continue;
}
instruction.Operand = ins.Translation;
foreach (var label in il.Labels)
{
if (label.Target.MatchLdstr(ins.Origin))
{
label.Target = instruction;
}
}
}
});
if (!modifications.ContainsKey(method))
{
HookEndpointManager.Modify(method, modification);
modifications.Add(method, modification);
}
}
}
public override void Reset()
{
return;
}
protected override void DisposeUnmanaged()
{
modifications = null;
}
}
}
================================================
FILE: Localizer/Package/Import/PackageImportService.cs
================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Localizer.Attributes;
using Localizer.DataModel;
using Localizer.DataModel.Default;
using Ninject;
namespace Localizer.Package.Import
{
public class PackageImportService : IPackageImportService
{
private readonly List<IPackageGroup> packageGroups = new List<IPackageGroup>();
private Dictionary<Type, FileImporter> _importers;
public PackageImportService()
{
gitextract_1rgzmmn8/ ├── .editorconfig ├── .gitattributes ├── .github/ │ └── workflows/ │ └── build.yml ├── .gitignore ├── .gitmodules ├── LICENSE ├── Localizer/ │ ├── Attributes/ │ │ ├── ModTranslationOwnerFieldAttribute.cs │ │ ├── ModTranslationPropAttribute.cs │ │ └── OperationTimingAttribute.cs │ ├── Configuration.cs │ ├── DataModel/ │ │ ├── Default/ │ │ │ ├── AttributeFile.cs │ │ │ ├── BaseEntry.cs │ │ │ ├── BasicBuffFile.cs │ │ │ ├── BasicItemFile.cs │ │ │ ├── BasicNPCFile.cs │ │ │ ├── BasicPrefixFile.cs │ │ │ ├── BasicProjectileFile.cs │ │ │ ├── CustomModTranslationFile.cs │ │ │ ├── ExportConfig.cs │ │ │ ├── File.cs │ │ │ ├── GitHubUpdateInfo.cs │ │ │ ├── LdstrFile.cs │ │ │ ├── LoadedModWrapper.cs │ │ │ ├── ModWrapper.cs │ │ │ ├── Package.cs │ │ │ ├── PackageGroup.cs │ │ │ └── PackageGroupState.cs │ │ ├── IEntry.cs │ │ ├── IExportConfig.cs │ │ ├── IFile.cs │ │ ├── IMod.cs │ │ ├── IPackage.cs │ │ ├── IPackageGroup.cs │ │ └── IUpdateInfo.cs │ ├── Disposable.cs │ ├── Enums/ │ │ ├── AutoImportType.cs │ │ ├── LogLevel.cs │ │ ├── OperationTiming.cs │ │ └── PackageType.cs │ ├── Helpers/ │ │ ├── Extensions.cs │ │ ├── Reflection.cs │ │ ├── UI.cs │ │ └── Utils.cs │ ├── Hooks.cs │ ├── Lang/ │ │ └── Lang.cs │ ├── Localizer.cs │ ├── Localizer.csproj │ ├── Localizer.csproj.DotSettings │ ├── LocalizerKernel.cs │ ├── LocalizerPlugin.cs │ ├── ModBrowser/ │ │ └── Patches.cs │ ├── Modules/ │ │ ├── DefaultNetworkModule.cs │ │ └── DefaultPackageModule.cs │ ├── Network/ │ │ ├── DownloadManager.cs │ │ ├── GitHubModUpdate.cs │ │ ├── IDownloadManagerService.cs │ │ ├── IPackageBrowserService.cs │ │ ├── IUpdateService.cs │ │ └── PackageBrowser.cs │ ├── Package/ │ │ ├── Export/ │ │ │ ├── BasicFileExport.cs │ │ │ ├── CustomModTranslationFileExport.cs │ │ │ ├── IFileExportService.cs │ │ │ ├── IPackageExportService.cs │ │ │ ├── LdstrFileExport.cs │ │ │ └── PackageExport.cs │ │ ├── IPackageManageService.cs │ │ ├── Import/ │ │ │ ├── AutoImportService.cs │ │ │ ├── BasicImporter.cs │ │ │ ├── CecilLdstrImporter.cs │ │ │ ├── CustomModTranslationImporter.cs │ │ │ ├── FileImporter.cs │ │ │ ├── HarmonyLdstrImporter.cs │ │ │ ├── IPackageImportService.cs │ │ │ ├── LdstrImporterBase.cs │ │ │ ├── MonoModLdstrImporter.cs │ │ │ ├── PackageImportService.cs │ │ │ └── RefreshLanguageService.cs │ │ ├── Load/ │ │ │ ├── IFileLoadService.cs │ │ │ ├── IPackageLoadService.cs │ │ │ ├── JsonFileLoad.cs │ │ │ ├── PackedPackageLoad.cs │ │ │ └── SourcePackageLoad.cs │ │ ├── Pack/ │ │ │ ├── IPackagePackService.cs │ │ │ └── ZipPackagePackService.cs │ │ ├── PackageManageService.cs │ │ ├── Save/ │ │ │ ├── IFileSaveService.cs │ │ │ ├── IPackageSaveService.cs │ │ │ ├── JsonFileSaveService.cs │ │ │ └── PackageSaveService.cs │ │ └── Update/ │ │ ├── BasicFileUpdater.cs │ │ ├── CustomModTranslationUpdater.cs │ │ ├── FileUpdater.cs │ │ ├── IPackageUpdateService.cs │ │ ├── IUpdateLogger.cs │ │ ├── LdstrFileUpdater.cs │ │ ├── PackageUpdateService.cs │ │ └── PlainUpdateLogger.cs │ ├── Properties/ │ │ └── AssemblyInfo.cs │ ├── UIs/ │ │ ├── Components/ │ │ │ ├── BasicListBox.cs │ │ │ ├── BasicWindow.cs │ │ │ ├── LabelListBoxItem.cs │ │ │ └── TitleBar.cs │ │ ├── MainWindow.cs │ │ ├── Stylesheet.cs │ │ ├── UIDesktop.cs │ │ ├── UIHost.cs │ │ ├── UIModsPatch.cs │ │ ├── UIRenderer.cs │ │ └── Views/ │ │ ├── ManagerView.cs │ │ ├── ReloadPluginView.cs │ │ └── TestView.cs │ ├── build.txt │ └── description.txt ├── Localizer.sln ├── Localizer.sln.DotSettings ├── LocalizerTest/ │ ├── DataModel/ │ │ └── GitHubUpdateInfoTest.cs │ ├── Helper/ │ │ ├── ExtensionsTest.cs │ │ └── UtilsTest.cs │ ├── LocalizerTest.cs │ ├── LocalizerTest.csproj │ ├── Network/ │ │ └── GitHubModUpdateService.cs │ ├── Ninject.cs │ ├── NonTest/ │ │ └── UpdateLogger.cs │ └── Package/ │ ├── Import/ │ │ ├── BasicFileImportTest.cs │ │ ├── CustomModTranslationFileImportTest.cs │ │ └── LdstrFileImportBaseTest.cs │ └── Update/ │ ├── BasicFileUpdateTest.cs │ ├── CustomModTranslationFileUpdateTest.cs │ └── LdstrFileUpdateTest.cs ├── ModPatch/ │ ├── ModPatch.csproj │ └── Program.cs └── README.md
SYMBOL INDEX (535 symbols across 115 files)
FILE: Localizer/Attributes/ModTranslationOwnerFieldAttribute.cs
class ModTranslationOwnerFieldAttribute (line 8) | public class ModTranslationOwnerFieldAttribute : Attribute
method ModTranslationOwnerFieldAttribute (line 10) | public ModTranslationOwnerFieldAttribute(string fieldName)
FILE: Localizer/Attributes/ModTranslationPropAttribute.cs
class ModTranslationPropAttribute (line 8) | public class ModTranslationPropAttribute : Attribute
method ModTranslationPropAttribute (line 10) | public ModTranslationPropAttribute(string propName)
FILE: Localizer/Attributes/OperationTimingAttribute.cs
class OperationTimingAttribute (line 5) | public class OperationTimingAttribute : Attribute
method OperationTimingAttribute (line 9) | public OperationTimingAttribute(OperationTiming timing = OperationTimi...
FILE: Localizer/Configuration.cs
class Configuration (line 3) | public class Configuration
FILE: Localizer/DataModel/Default/AttributeFile.cs
class AttributeFile (line 6) | public class AttributeFile : IFile
method GetKeys (line 10) | public List<string> GetKeys()
method GetValue (line 15) | public IEntry GetValue(string key)
FILE: Localizer/DataModel/Default/BaseEntry.cs
class BaseEntry (line 3) | public class BaseEntry : IEntry
method Clone (line 9) | public IEntry Clone()
FILE: Localizer/DataModel/Default/BasicBuffFile.cs
class BuffEntry (line 7) | public class BuffEntry : IEntry
method Clone (line 13) | public IEntry Clone()
class BasicBuffFile (line 23) | public class BasicBuffFile : IFile
method GetKeys (line 28) | public List<string> GetKeys()
method GetValue (line 33) | public IEntry GetValue(string key)
FILE: Localizer/DataModel/Default/BasicItemFile.cs
class ItemEntry (line 7) | public class ItemEntry : IEntry
method Clone (line 13) | public IEntry Clone()
class BasicItemFile (line 23) | public class BasicItemFile : IFile
method GetKeys (line 28) | public List<string> GetKeys()
method GetValue (line 33) | public IEntry GetValue(string key)
FILE: Localizer/DataModel/Default/BasicNPCFile.cs
class NPCEntry (line 7) | public class NPCEntry : IEntry
method Clone (line 11) | public IEntry Clone()
class BasicNPCFile (line 17) | public class BasicNPCFile : IFile
method GetKeys (line 22) | public List<string> GetKeys()
method GetValue (line 27) | public IEntry GetValue(string key)
FILE: Localizer/DataModel/Default/BasicPrefixFile.cs
class PrefixEntry (line 7) | public class PrefixEntry : IEntry
method Clone (line 11) | public IEntry Clone()
class BasicPrefixFile (line 17) | public class BasicPrefixFile : IFile
method GetKeys (line 22) | public List<string> GetKeys()
method GetValue (line 27) | public IEntry GetValue(string key)
FILE: Localizer/DataModel/Default/BasicProjectileFile.cs
class ProjectileEntry (line 7) | public class ProjectileEntry : IEntry
method Clone (line 11) | public IEntry Clone()
class BasicProjectileFile (line 17) | public class BasicProjectileFile : IFile
method GetKeys (line 22) | public List<string> GetKeys()
method GetValue (line 27) | public IEntry GetValue(string key)
FILE: Localizer/DataModel/Default/CustomModTranslationFile.cs
class CustomModTranslationFile (line 6) | public class CustomModTranslationFile : IFile
method GetKeys (line 10) | public List<string> GetKeys()
method GetValue (line 15) | public IEntry GetValue(string key)
FILE: Localizer/DataModel/Default/ExportConfig.cs
class ExportConfig (line 3) | public class ExportConfig : IExportConfig
FILE: Localizer/DataModel/Default/File.cs
class File (line 6) | public abstract class File : IFile
method GetKeys (line 10) | public abstract List<string> GetKeys();
method GetValue (line 12) | public abstract IEntry GetValue(string key);
method AddEntry (line 14) | public abstract void AddEntry(string key, IEntry entry);
FILE: Localizer/DataModel/Default/GitHubUpdateInfo.cs
class GitHubUpdateInfo (line 5) | public class GitHubUpdateInfo : IUpdateInfo
method GitHubUpdateInfo (line 13) | public GitHubUpdateInfo(string versionString)
method ParseType (line 20) | internal UpdateType ParseType(char t)
FILE: Localizer/DataModel/Default/LdstrFile.cs
class LdstrEntry (line 7) | public class LdstrEntry : IEntry
method Clone (line 11) | public IEntry Clone()
class LdstrFile (line 24) | [OperationTiming]
method GetKeys (line 29) | public List<string> GetKeys()
method GetValue (line 34) | public IEntry GetValue(string key)
FILE: Localizer/DataModel/Default/LoadedModWrapper.cs
class LoadedModWrapper (line 9) | public class LoadedModWrapper : IMod
method LoadedModWrapper (line 13) | public LoadedModWrapper(object mod)
FILE: Localizer/DataModel/Default/ModWrapper.cs
class ModWrapper (line 9) | public class ModWrapper : IMod
method ModWrapper (line 13) | public ModWrapper(Mod mod)
FILE: Localizer/DataModel/Default/Package.cs
class Package (line 9) | [JsonObject(MemberSerialization.OptIn)]
method Package (line 12) | public Package()
method Package (line 15) | public Package(string name, IMod mod, CultureInfo language)
method AddFile (line 46) | public void AddFile(IFile file)
method RemoveFile (line 61) | public void RemoveFile(IFile file)
FILE: Localizer/DataModel/Default/PackageGroup.cs
class PackageGroup (line 5) | public class PackageGroup : IPackageGroup
FILE: Localizer/DataModel/Default/PackageGroupState.cs
class PackageGroupState (line 6) | [JsonObject(MemberSerialization.OptOut)]
method PackageGroupState (line 9) | public PackageGroupState()
method PackageGroupState (line 12) | public PackageGroupState(IPackageGroup pg)
FILE: Localizer/DataModel/IEntry.cs
type IEntry (line 3) | public interface IEntry
method Clone (line 5) | IEntry Clone();
FILE: Localizer/DataModel/IExportConfig.cs
type IExportConfig (line 3) | public interface IExportConfig
FILE: Localizer/DataModel/IFile.cs
type IFile (line 5) | public interface IFile
method GetKeys (line 7) | List<string> GetKeys();
method GetValue (line 8) | IEntry GetValue(string key);
FILE: Localizer/DataModel/IMod.cs
type IMod (line 7) | public interface IMod
FILE: Localizer/DataModel/IPackage.cs
type IPackage (line 7) | public interface IPackage
method AddFile (line 75) | void AddFile(IFile file);
method RemoveFile (line 81) | void RemoveFile(IFile file);
FILE: Localizer/DataModel/IPackageGroup.cs
type IPackageGroup (line 5) | public interface IPackageGroup
FILE: Localizer/DataModel/IUpdateInfo.cs
type UpdateType (line 5) | public enum UpdateType
type IUpdateInfo (line 13) | public interface IUpdateInfo
FILE: Localizer/Disposable.cs
class Disposable (line 5) | public abstract class Disposable : IDisposable
method Dispose (line 9) | public void Dispose()
method Dispose (line 20) | protected virtual void Dispose(bool disposeManaged)
method DisposeManaged (line 35) | protected virtual void DisposeManaged() { }
method DisposeUnmanaged (line 37) | protected virtual void DisposeUnmanaged() { }
FILE: Localizer/Enums/AutoImportType.cs
type AutoImportType (line 6) | [JsonConverter(typeof(StringEnumConverter))]
FILE: Localizer/Enums/LogLevel.cs
type LogLevel (line 6) | [JsonConverter(typeof(StringEnumConverter))]
FILE: Localizer/Enums/OperationTiming.cs
type OperationTiming (line 5) | [Flags]
FILE: Localizer/Enums/PackageType.cs
type PackageType (line 3) | public enum PackageType
FILE: Localizer/Helpers/Extensions.cs
class Extensions (line 11) | public static class Extensions
method Import (line 15) | public static void Import(this ModTranslation modTranslation, BaseEntr...
method GetTranslation (line 37) | public static string GetTranslation(this ModTranslation modTranslation...
method DefaultOrEmpty (line 43) | public static string DefaultOrEmpty(this ModTranslation modTranslation)
method ModTranslationOwnerField (line 52) | public static PropertyInfo[] ModTranslationOwnerField(this Type type)
method ModTranslationOwnerFieldName (line 58) | public static string ModTranslationOwnerFieldName(this PropertyInfo prop)
method ModTranslationProp (line 63) | public static PropertyInfo[] ModTranslationProp(this Type type)
FILE: Localizer/Helpers/Reflection.cs
class NoroHelper (line 8) | public static class NoroHelper
method HarmonyMethod (line 13) | public static HarmonyMethod HarmonyMethod(Expression<Action> expression)
method MethodInfo (line 18) | public static MethodInfo MethodInfo(Expression<Action> expression)
method Type (line 23) | public static Type Type(this string name)
method Field (line 29) | public static FieldInfo Field(this Type type, string name, BindingFlag...
method Property (line 34) | public static PropertyInfo Property(this Type type, string name, Bindi...
method Method (line 39) | public static MethodInfo Method(this Type t, string name, IEnumerable<...
method Method (line 44) | public static MethodInfo Method(this Type t, string name, params Type[...
method ValueOf (line 59) | public static object ValueOf(this Type type, string name, object value...
method ValueOf (line 76) | public static object ValueOf(this object obj, string name)
method ValueOf (line 81) | public static T ValueOf<T>(this Type type, string name)
method ValueOf (line 86) | public static T ValueOf<T>(this object obj, string name)
method SetField (line 91) | public static void SetField(this Type type, string name, object value)
method SetField (line 96) | public static void SetField(this object obj, string name, object value)
method Invoke (line 101) | public static object Invoke(this object o, string name, params object[...
FILE: Localizer/Helpers/UI.cs
class UI (line 10) | public static class UI
method GetPkgLabelText (line 12) | public static string GetPkgLabelText(IPackage p)
method ShowInfoMessage (line 17) | public static void ShowInfoMessage(string message, int gotoMenu, UISta...
method GetModLoaderUI (line 24) | public static object GetModLoaderUI(string uiName)
method SafeBegin (line 29) | public static void SafeBegin(this SpriteBatch sb)
method SafeBegin (line 39) | public static void SafeBegin(this SpriteBatch sb, SamplerState sampler...
method SafeEnd (line 50) | public static void SafeEnd(this SpriteBatch sb)
FILE: Localizer/Helpers/Utils.cs
class Utils (line 27) | public static partial class Utils
method WriteZipArchiveEntry (line 37) | public static void WriteZipArchiveEntry(ZipArchive archive, string fil...
method GetMethodBase (line 58) | public static MethodBase GetMethodBase<T>(string findableName)
method FindMethodByID (line 65) | public static MethodBase FindMethodByID(Module m, string findableName)
method FindMethodByID (line 87) | public static MethodDefinition FindMethodByID(ModuleDefinition m, stri...
method SerializeJsonAndCreateFile (line 120) | public static void SerializeJsonAndCreateFile(object obj, string path,...
method ReadFileAndDeserializeJson (line 137) | public static T ReadFileAndDeserializeJson<T>(string path)
method ReadFileAndDeserializeJson (line 151) | public static T ReadFileAndDeserializeJson<T>(Stream stream)
method ReadFileAndDeserializeJson (line 173) | public static object ReadFileAndDeserializeJson(Type t, string path)
method ReadFileAndDeserializeJson (line 187) | public static object ReadFileAndDeserializeJson(Type t, Stream stream)
method LogFatal (line 203) | public static void LogFatal(object o)
method LogError (line 208) | public static void LogError(object o)
method LogWarn (line 216) | public static void LogWarn(object o)
method LogInfo (line 224) | public static void LogInfo(object o)
method LogDebug (line 232) | public static void LogDebug(object o)
method UserAgent (line 243) | internal static string UserAgent(bool localizer = true)
method GET (line 253) | public static HttpWebResponse GET(string url)
method GetResponseBody (line 266) | public static string GetResponseBody(HttpWebResponse response)
method AsRainbow (line 288) | public static string AsRainbow(string text, int frameCounter, int? uni...
method CreateEntryMappings (line 308) | public static Dictionary<string, PropertyInfo> CreateEntryMappings(Typ...
method GetTranslationOfEntry (line 336) | public static string GetTranslationOfEntry(IEntry entry, PropertyInfo ...
method EnsureDir (line 345) | public static void EnsureDir(string path)
method GetLoadedMods (line 353) | public static ICollection<IMod> GetLoadedMods()
method GetModByName (line 358) | public static Mod GetModByName(string name)
method DateTimeToFileName (line 363) | public static string DateTimeToFileName(DateTime dateTime)
method EscapePath (line 368) | public static string EscapePath(string path)
method GetInstructions (line 373) | public static List<ILInstruction> GetInstructions(MethodBase method)
method SafeWrap (line 383) | public static void SafeWrap(Action action)
method SafeWrap (line 388) | public static void SafeWrap(Action action, out Exception ex)
method SafeWrap (line 402) | public static T SafeWrap<T>(Func<T> func)
method SafeWrap (line 407) | public static T SafeWrap<T>(Func<T> func, out Exception ex)
method Patch (line 423) | public static void Patch(this HarmonyInstance instance, string @class,...
FILE: Localizer/Hooks.cs
class Hooks (line 5) | public class Hooks
method InvokeBeforeModCtor (line 9) | internal static void InvokeBeforeModCtor(object mod)
method InvokeBeforeLoad (line 16) | internal static void InvokeBeforeLoad()
method InvokeBeforeSetupContent (line 23) | internal static void InvokeBeforeSetupContent()
method InvokePostSetupContent (line 30) | internal static void InvokePostSetupContent()
method InvokeOnGameUpdate (line 37) | internal static void InvokeOnGameUpdate(GameTime gameTime)
method InvokeOnPostDraw (line 44) | internal static void InvokeOnPostDraw(GameTime gameTime)
FILE: Localizer/Lang/Lang.cs
class Lang (line 8) | public static class Lang
method AddModTranslations (line 85) | public static void AddModTranslations(Mod mod)
method _ (line 96) | public static string _(string key, params object[] args)
FILE: Localizer/Localizer.cs
class Localizer (line 28) | public sealed class Localizer : Mod
method Localizer (line 48) | public Localizer()
method AfterLocalizerCtorHook (line 66) | private static void AfterLocalizerCtorHook(object mod)
method Init (line 71) | private static void Init()
method Load (line 97) | public override void Load()
method PostSetupContent (line 111) | public override void PostSetupContent()
method AddPostDrawHook (line 120) | private void AddPostDrawHook()
method OnPostDraw (line 132) | private void OnPostDraw(GameTime time)
method PostAddRecipes (line 158) | public override void PostAddRecipes()
method UpdateUI (line 165) | public override void UpdateUI(GameTime gameTime)
method CheckUpdate (line 170) | public void CheckUpdate()
method Unload (line 190) | public override void Unload()
method LoadConfig (line 229) | public static void LoadConfig()
method SaveConfig (line 250) | public static void SaveConfig()
method AddGameCulture (line 257) | public static GameCulture AddGameCulture(CultureInfo culture)
method CultureInfoToGameCulture (line 264) | public static GameCulture CultureInfoToGameCulture(CultureInfo culture)
method RefreshLanguages (line 270) | public static void RefreshLanguages()
method GetWrappedMod (line 275) | public static IMod GetWrappedMod(string name)
method CanDoOperationNow (line 294) | public static bool CanDoOperationNow(Type t)
method CanDoOperationNow (line 300) | public static bool CanDoOperationNow(OperationTiming t)
FILE: Localizer/LocalizerKernel.cs
class LocalizerKernel (line 12) | public sealed class LocalizerKernel : StandardKernel
method LocalizerKernel (line 20) | public LocalizerKernel()
method Init (line 28) | public void Init()
method Dispose (line 39) | public override void Dispose(bool disposing)
method UnloadAllPlugins (line 54) | internal void UnloadAllPlugins()
method LoadPlugins (line 64) | internal void LoadPlugins()
method LoadPlugin (line 76) | internal void LoadPlugin(Assembly asm)
method UnloadPlugin (line 97) | internal void UnloadPlugin(string pluginName)
method UnloadPlugin (line 110) | internal void UnloadPlugin(LocalizerPlugin plugin)
method AssemblyResolveHandler (line 131) | private static Assembly AssemblyResolveHandler(object sender, ResolveE...
method GetExternalPluginFileBytes (line 166) | private static byte[] GetExternalPluginFileBytes(string fileName)
FILE: Localizer/LocalizerPlugin.cs
class LocalizerPlugin (line 5) | public abstract class LocalizerPlugin : Disposable
method Initialize (line 12) | public abstract void Initialize(LocalizerKernel kernel);
FILE: Localizer/ModBrowser/Patches.cs
class Patches (line 14) | public static class Patches
method Patch (line 18) | public static void Patch()
method GetModListURL (line 128) | private static string GetModListURL()
method GetModDownloadURL (line 144) | private static string GetModDownloadURL()
method GetModDescURL (line 160) | private static string GetModDescURL()
method PreCopyPrefix (line 174) | private static void PreCopyPrefix(object ___ModBrowserItem)
method PostSetupDownloadRequest (line 182) | private static void PostSetupDownloadRequest(object __instance)
method UpdateHeader (line 189) | public static void UpdateHeader(WebClient wc)
method PopulateModBrowserTranspiler (line 195) | private static IEnumerable<CodeInstruction> PopulateModBrowserTranspil...
method FromJSONTranspiler (line 212) | private static IEnumerable<CodeInstruction> FromJSONTranspiler(IEnumer...
method OnActivateTranspiler (line 221) | private static IEnumerable<CodeInstruction> OnActivateTranspiler(IEnum...
method DirectModListingTranspiler (line 229) | private static IEnumerable<CodeInstruction> DirectModListingTranspiler...
method ModCompileTranspiler (line 237) | private static IEnumerable<CodeInstruction> ModCompileTranspiler(IEnum...
method ReplaceLdstr (line 252) | private static void ReplaceLdstr(string o, string n, IEnumerable<CodeI...
FILE: Localizer/Modules/DefaultNetworkModule.cs
class DefaultNetworkModule (line 6) | public class DefaultNetworkModule : NinjectModule
method Load (line 8) | public override void Load()
FILE: Localizer/Modules/DefaultPackageModule.cs
class DefaultPackageModule (line 17) | public class DefaultPackageModule : NinjectModule
method Load (line 19) | public override void Load()
method Unload (line 30) | public override void Unload()
method BindLoadService (line 37) | private void BindLoadService()
method BindManageService (line 50) | private void BindManageService()
method BindImportService (line 55) | private void BindImportService()
method BindSaveService (line 90) | private void BindSaveService()
method BindPackService (line 96) | private void BindPackService()
method BindExportService (line 102) | private void BindExportService()
method BindUpdateService (line 115) | private void BindUpdateService()
FILE: Localizer/Network/DownloadManager.cs
class DownloadManager (line 6) | public class DownloadManager : IDownloadManagerService
method Download (line 8) | public void Download(string url, string path)
method Dispose (line 16) | public void Dispose()
FILE: Localizer/Network/GitHubModUpdate.cs
class GitHubModUpdate (line 9) | public sealed class GitHubModUpdate : IUpdateService
method CheckUpdate (line 13) | public bool CheckUpdate(Version curVersion, out IUpdateInfo updateInfo)
method GetUpdateInfo (line 30) | internal GitHubUpdateInfo GetUpdateInfo(JObject jObject)
method GetChangeLog (line 35) | public Dictionary<Version, string> GetChangeLog(Version from, Version to)
method GetDownloadURL (line 40) | public string GetDownloadURL()
method GetDownloadURLInternal (line 45) | internal string GetDownloadURLInternal(JObject jObject)
method Dispose (line 57) | public void Dispose()
FILE: Localizer/Network/IDownloadManagerService.cs
type IDownloadManagerService (line 3) | public interface IDownloadManagerService
method Download (line 5) | void Download(string url, string path);
FILE: Localizer/Network/IPackageBrowserService.cs
type IPackageBrowserService (line 6) | public interface IPackageBrowserService
method GetList (line 8) | ICollection<IPackage> GetList();
method GetPageCount (line 10) | int GetPageCount();
method GetListByPage (line 12) | ICollection<IPackage> GetListByPage(int i);
method GetDownloadLinkOf (line 14) | string GetDownloadLinkOf(IPackage package);
FILE: Localizer/Network/IUpdateService.cs
type IUpdateService (line 7) | public interface IUpdateService
method CheckUpdate (line 9) | bool CheckUpdate(Version curVersion, out IUpdateInfo updateInfo);
method GetChangeLog (line 11) | Dictionary<Version, string> GetChangeLog(Version from, Version to);
method GetDownloadURL (line 13) | string GetDownloadURL();
FILE: Localizer/Network/PackageBrowser.cs
class PackageBrowser (line 9) | public class PackageBrowser : IPackageBrowserService
method GetList (line 19) | public ICollection<IPackage> GetList()
method GetPageCount (line 50) | public int GetPageCount()
method GetListByPage (line 55) | public ICollection<IPackage> GetListByPage(int i)
method GetDownloadLinkOf (line 60) | public string GetDownloadLinkOf(IPackage package)
method Dispose (line 70) | public void Dispose()
FILE: Localizer/Package/Export/BasicFileExport.cs
class BasicFileExport (line 14) | public sealed class BasicFileExport<T> : IFileExportService where T : IFile
method Export (line 16) | public void Export(IPackage package, IExportConfig config)
method CreateEntries (line 49) | private Dictionary<string, object> CreateEntries(IDictionary localizeO...
FILE: Localizer/Package/Export/CustomModTranslationFileExport.cs
class CustomModTranslationFileExport (line 10) | public class CustomModTranslationFileExport : IFileExportService
method Export (line 12) | public void Export(IPackage package, IExportConfig config)
method Dispose (line 43) | public void Dispose()
FILE: Localizer/Package/Export/IFileExportService.cs
type IFileExportService (line 5) | public interface IFileExportService
method Export (line 12) | void Export(IPackage package, IExportConfig config);
FILE: Localizer/Package/Export/IPackageExportService.cs
type IPackageExportService (line 5) | public interface IPackageExportService
method Export (line 12) | void Export(IPackage package, IExportConfig config);
FILE: Localizer/Package/Export/LdstrFileExport.cs
class LdstrFileExport (line 16) | public sealed class LdstrFileExport : IFileExportService
method Export (line 123) | public void Export(IPackage package, IExportConfig config)
method GetEntryFromMethod (line 176) | private LdstrEntry GetEntryFromMethod(MethodDefinition method)
method Dispose (line 248) | public void Dispose()
FILE: Localizer/Package/Export/PackageExport.cs
class PackageExport (line 7) | public class PackageExport : IPackageExportService
method Export (line 9) | public void Export(IPackage package, IExportConfig config)
FILE: Localizer/Package/IPackageManageService.cs
type IPackageManageService (line 6) | public interface IPackageManageService
method AddPackage (line 17) | void AddPackage(IPackage package);
method RemovePackage (line 23) | void RemovePackage(IPackage package);
method LoadState (line 28) | void LoadState();
method SaveState (line 33) | void SaveState();
FILE: Localizer/Package/Import/AutoImportService.cs
class AutoImportService (line 17) | public sealed class AutoImportService : Disposable
method AutoImportService (line 30) | [Inject]
method OnBeforeModCtor (line 50) | private void OnBeforeModCtor(object mod)
method OnPostSetupContent (line 71) | private void OnPostSetupContent()
method LoadPackages (line 96) | private void LoadPackages()
method LoadSourcePackages (line 129) | private void LoadSourcePackages()
method LoadPackedPackages (line 148) | private void LoadPackedPackages()
method Import (line 168) | private void Import(IMod mod = null)
method QueuePackageGroup (line 197) | private void QueuePackageGroup(IPackageGroup packageGroup)
method DisposeUnmanaged (line 213) | protected override void DisposeUnmanaged()
FILE: Localizer/Package/Import/BasicImporter.cs
class BasicImporter (line 14) | public class BasicImporter<T> : FileImporter where T : IFile
method Import (line 16) | public override void Import(IFile file, IMod mod, CultureInfo culture)
method ImportInternal (line 21) | private void ImportInternal(T file, IMod mod, CultureInfo culture)
method Merge (line 38) | public override IFile Merge(IFile main, IFile addition)
method MergeInternal (line 43) | internal T MergeInternal(T main, T addition)
method Merge (line 77) | public IEntry Merge(IEntry main, IEntry addition)
method ApplyEntries (line 103) | private void ApplyEntries(IDictionary entries, IDictionary field, Type...
class BasicImporterPostContentLoad (line 126) | [OperationTiming(OperationTiming.PostContentLoad)]
class BasicImporterBeforeContentLoad (line 129) | [OperationTiming(OperationTiming.BeforeContentLoad)]
FILE: Localizer/Package/Import/CecilLdstrImporter.cs
class CecilLdstrImporter (line 16) | [OperationTiming(OperationTiming.BeforeModCtor)]
method CecilLdstrImporter (line 25) | public CecilLdstrImporter()
method PostGetModAssembly (line 32) | public static void PostGetModAssembly(ref byte[] __result)
method PatchAssembly (line 56) | private void PatchAssembly(AssemblyDefinition asm)
method ImportInternal (line 96) | protected override void ImportInternal(LdstrFile file, IMod mod, Cultu...
method ReplaceLdstr (line 115) | private static void ReplaceLdstr(string o, string n, IEnumerable<Instr...
method DisposeUnmanaged (line 131) | protected override void DisposeUnmanaged()
FILE: Localizer/Package/Import/CustomModTranslationImporter.cs
class CustomModTranslationImporter (line 12) | [OperationTiming(OperationTiming.PostContentLoad)]
method Import (line 15) | public override void Import(IFile file, IMod mod, CultureInfo culture)
method ImportInternal (line 20) | private void ImportInternal(CustomModTranslationFile file, IMod mod, C...
method Merge (line 45) | public override IFile Merge(IFile main, IFile addition)
method MergeInternal (line 50) | internal CustomModTranslationFile MergeInternal(CustomModTranslationFi...
method Merge (line 77) | public BaseEntry Merge(BaseEntry main, BaseEntry addition)
FILE: Localizer/Package/Import/FileImporter.cs
class FileImporter (line 6) | public abstract class FileImporter : Disposable
method Import (line 14) | public abstract void Import(IFile file, IMod mod, CultureInfo culture);
method Merge (line 22) | public abstract IFile Merge(IFile main, IFile addition);
method Reset (line 24) | public virtual void Reset() { }
FILE: Localizer/Package/Import/HarmonyLdstrImporter.cs
class HarmonyLdstrImporter (line 11) | public sealed class HarmonyLdstrImporter : LdstrImporterBase
method HarmonyLdstrImporter (line 17) | public HarmonyLdstrImporter()
method ImportInternal (line 22) | protected override void ImportInternal(LdstrFile file, IMod mod, Cultu...
method Reset (line 55) | public override void Reset()
method Transpile (line 60) | private static IEnumerable<CodeInstruction> Transpile(IEnumerable<Code...
method ReplaceLdstr (line 79) | private static void ReplaceLdstr(string o, string n, IEnumerable<CodeI...
method DisposeUnmanaged (line 93) | protected override void DisposeUnmanaged()
FILE: Localizer/Package/Import/IPackageImportService.cs
type IPackageImportService (line 6) | public interface IPackageImportService
method RegisterImporter (line 8) | void RegisterImporter<T>(Type importerType) where T : IFile;
method UnregisterImporter (line 10) | void UnregisterImporter<T>() where T : IFile;
method Queue (line 17) | void Queue(IPackage package);
method Import (line 22) | void Import(bool preferEarly);
method Reset (line 27) | void Reset();
method Clear (line 32) | void Clear();
FILE: Localizer/Package/Import/LdstrImporterBase.cs
class LdstrImporterBase (line 8) | public abstract class LdstrImporterBase : FileImporter
method HaveTranslation (line 10) | internal bool HaveTranslation(LdstrEntry entry)
method Import (line 23) | public override void Import(IFile file, IMod mod, CultureInfo culture)
method Merge (line 28) | public override IFile Merge(IFile main, IFile addition)
method ImportInternal (line 32) | protected abstract void ImportInternal(LdstrFile file, IMod mod, Cultu...
method MergeInternal (line 34) | internal LdstrFile MergeInternal(LdstrFile main, LdstrFile addition)
method Merge (line 61) | internal LdstrEntry Merge(LdstrEntry main, LdstrEntry addition)
FILE: Localizer/Package/Import/MonoModLdstrImporter.cs
class MonoModLdstrImporter (line 12) | public class MonoModLdstrImporter : LdstrImporterBase
method MonoModLdstrImporter (line 16) | public MonoModLdstrImporter()
method ImportInternal (line 21) | protected override void ImportInternal(LdstrFile file, IMod mod, Cultu...
method Reset (line 73) | public override void Reset()
method DisposeUnmanaged (line 78) | protected override void DisposeUnmanaged()
FILE: Localizer/Package/Import/PackageImportService.cs
class PackageImportService (line 12) | public class PackageImportService : IPackageImportService
method PackageImportService (line 18) | public PackageImportService()
method RegisterImporter (line 23) | public void RegisterImporter<T>(Type importerType) where T : IFile
method UnregisterImporter (line 52) | public void UnregisterImporter<T>() where T : IFile
method Queue (line 61) | public void Queue(IPackage package)
method Import (line 79) | public void Import(bool preferEarly = true)
method Import (line 106) | private void Import(IFile f, IPackageGroup group, FileImporter importe...
method Reset (line 125) | public void Reset()
method Clear (line 136) | public void Clear()
method GetImporter (line 143) | private FileImporter GetImporter(IFile file)
method Merge (line 154) | internal DataModel.Default.Package Merge(IPackageGroup group)
method Dispose (line 194) | public void Dispose()
FILE: Localizer/Package/Import/RefreshLanguageService.cs
class RefreshLanguageService (line 12) | public sealed class RefreshLanguageService : Disposable
method RefreshLanguageService (line 27) | public RefreshLanguageService()
method OnModItemCtor (line 36) | private static void OnModItemCtor(ModItem __instance)
method Refresh (line 62) | public void Refresh()
method CleanUpItems (line 91) | private void CleanUpItems()
method DisposeUnmanaged (line 123) | protected override void DisposeUnmanaged()
FILE: Localizer/Package/Load/IFileLoadService.cs
type IFileLoadService (line 6) | public interface IFileLoadService
method Load (line 14) | IFile Load(Stream stream, string typeName);
FILE: Localizer/Package/Load/IPackageLoadService.cs
type IPackageLoadService (line 5) | public interface IPackageLoadService<T> where T : IPackage
method Load (line 13) | IPackage Load(string path, IFileLoadService fileLoadService);
FILE: Localizer/Package/Load/JsonFileLoad.cs
class JsonFileLoad (line 9) | public class JsonFileLoad : IFileLoadService
method Load (line 22) | public IFile Load(Stream stream, string typeName)
method RegisterType (line 42) | public void RegisterType(string typeName, Type type)
method Dispose (line 59) | public void Dispose()
FILE: Localizer/Package/Load/PackedPackageLoad.cs
class PackedPackageLoad (line 7) | public sealed class PackedPackageLoad<T> : IPackageLoadService<T> where ...
method Load (line 11) | public IPackage Load(string path, IFileLoadService fileLoadService)
method Dispose (line 60) | public void Dispose()
FILE: Localizer/Package/Load/SourcePackageLoad.cs
class SourcePackageLoad (line 7) | public sealed class SourcePackageLoad<T> : IPackageLoadService<T> where ...
method Load (line 11) | public IPackage Load(string path, IFileLoadService fileLoadService)
method Dispose (line 63) | public void Dispose()
FILE: Localizer/Package/Pack/IPackagePackService.cs
type IPackagePackService (line 3) | public interface IPackagePackService
method Pack (line 9) | void Pack(string path);
FILE: Localizer/Package/Pack/ZipPackagePackService.cs
class ZipPackagePackService (line 7) | public class ZipPackagePackService<T> : IPackagePackService where T : IP...
method Pack (line 11) | public void Pack(string path)
method Dispose (line 50) | public void Dispose()
FILE: Localizer/Package/PackageManageService.cs
class PackageManageService (line 9) | public class PackageManageService : IPackageManageService
method AddPackage (line 21) | public void AddPackage(IPackage package)
method RemovePackage (line 44) | public void RemovePackage(IPackage package)
method LoadState (line 49) | public void LoadState()
method SaveState (line 77) | public void SaveState()
method Dispose (line 93) | public void Dispose()
FILE: Localizer/Package/Save/IFileSaveService.cs
type IFileSaveService (line 5) | public interface IFileSaveService
method Save (line 12) | void Save(IFile file, string path);
FILE: Localizer/Package/Save/IPackageSaveService.cs
type IPackageSaveService (line 5) | public interface IPackageSaveService
method Save (line 13) | void Save(IPackage package, string path, IFileSaveService fileSaveDisp...
FILE: Localizer/Package/Save/JsonFileSaveService.cs
class JsonFileSaveService (line 5) | public class JsonFileSaveService : IFileSaveService
method Save (line 7) | public void Save(IFile file, string path)
method Dispose (line 12) | public void Dispose()
FILE: Localizer/Package/Save/PackageSaveService.cs
class PackageSave (line 6) | public class PackageSave : IPackageSaveService
method Save (line 8) | public void Save(IPackage package, string path, IFileSaveService fileS...
method Dispose (line 18) | public void Dispose()
FILE: Localizer/Package/Update/BasicFileUpdater.cs
class BasicFileUpdater (line 9) | public sealed class BasicFileUpdater<T> : FileUpdater where T : IFile
method Update (line 11) | public override void Update(IFile oldFile, IFile newFile, IUpdateLogge...
method UpdateInternal (line 17) | public void UpdateInternal(T oldFile, T newFile, IUpdateLogger logger)
method UpdateEntry (line 61) | internal void UpdateEntry(string key, IEntry oldEntry, IEntry newEntry...
FILE: Localizer/Package/Update/CustomModTranslationUpdater.cs
class CustomModTranslationUpdater (line 7) | public class CustomModTranslationUpdater : FileUpdater
method Update (line 9) | public override void Update(IFile oldFile, IFile newFile, IUpdateLogge...
method UpdateInternal (line 15) | public void UpdateInternal(CustomModTranslationFile oldFile, CustomMod...
method Dispose (line 50) | public void Dispose()
FILE: Localizer/Package/Update/FileUpdater.cs
class FileUpdater (line 6) | public abstract class FileUpdater
method Update (line 15) | public abstract void Update(IFile oldFile, IFile newFile, IUpdateLogge...
method CheckArgs (line 17) | internal void CheckArgs(IFile oldFile, IFile newFile, IUpdateLogger lo...
FILE: Localizer/Package/Update/IPackageUpdateService.cs
type IPackageUpdateService (line 5) | public interface IPackageUpdateService
method RegisterUpdater (line 7) | void RegisterUpdater<T>(FileUpdater updater) where T : IFile;
method UnregisterUpdater (line 9) | void UnregisterUpdater<T>() where T : IFile;
method Update (line 18) | void Update(IPackage oldPackage, IPackage newPackage, IUpdateLogger lo...
FILE: Localizer/Package/Update/IUpdateLogger.cs
type IUpdateLogger (line 3) | public interface IUpdateLogger
method Init (line 9) | void Init(string name);
method Add (line 15) | void Add(object content);
method Remove (line 21) | void Remove(object content);
method Change (line 27) | void Change(object content);
FILE: Localizer/Package/Update/LdstrFileUpdater.cs
class LdstrFileUpdater (line 7) | public class LdstrFileUpdater : FileUpdater
method Update (line 9) | public override void Update(IFile oldFile, IFile newFile, IUpdateLogge...
method UpdateInternal (line 15) | public void UpdateInternal(LdstrFile oldFile, LdstrFile newFile, IUpda...
method Dispose (line 52) | public void Dispose()
FILE: Localizer/Package/Update/PackageUpdateService.cs
class PackageUpdateService (line 8) | public sealed class PackageUpdateService : IPackageUpdateService
method PackageUpdateService (line 12) | public PackageUpdateService()
method RegisterUpdater (line 17) | public void RegisterUpdater<T>(FileUpdater updater) where T : IFile
method UnregisterUpdater (line 36) | public void UnregisterUpdater<T>() where T : IFile
method Update (line 45) | public void Update(IPackage oldPackage, IPackage newPackage, IUpdateLo...
method GetUpdater (line 75) | private FileUpdater GetUpdater<T>(T file) where T : IFile
FILE: Localizer/Package/Update/PlainUpdateLogger.cs
class PlainUpdateLogger (line 5) | public class PlainUpdateLogger : IUpdateLogger
method Init (line 11) | public void Init(string name)
method Add (line 17) | public void Add(object content)
method Remove (line 22) | public void Remove(object content)
method Change (line 27) | public void Change(object content)
method Dispose (line 32) | public void Dispose()
FILE: Localizer/UIs/Components/BasicListBox.cs
class BasicListBox (line 5) | public class BasicListBox : ListBox
method BasicListBox (line 7) | public BasicListBox()
FILE: Localizer/UIs/Components/BasicWindow.cs
class BasicWindow (line 5) | public class BasicWindow : Window
method BasicWindow (line 9) | public BasicWindow()
method Button_OnMouseClick (line 31) | private void Button_OnMouseClick(Control sender, MouseEventArgs args)
FILE: Localizer/UIs/Components/LabelListBoxItem.cs
class LabelListBoxItem (line 5) | public class LabelListBoxItem : ListBoxItem
method LabelListBoxItem (line 15) | public LabelListBoxItem(string text)
FILE: Localizer/UIs/Components/TitleBar.cs
class TitleBar (line 5) | public class TitleBar : Label
method TitleBar (line 9) | public TitleBar()
FILE: Localizer/UIs/MainWindow.cs
class MainWindow (line 25) | public class MainWindow : BasicWindow
method MainWindow (line 63) | public MainWindow()
method Export (line 159) | private void Export(bool withTranslation)
method RefreshOnlinePackages (line 230) | private Task RefreshOnlinePackages(Control sender)
method LoadPackages (line 253) | private Task LoadPackages()
method RefreshPkgList (line 307) | private void RefreshPkgList()
method DownloadPackage (line 415) | private void DownloadPackage(MouseEventArgs args, IPackage p)
method RefreshModList (line 438) | private void RefreshModList()
FILE: Localizer/UIs/Stylesheet.cs
class Stylesheet (line 6) | public class Stylesheet
method GetSkin (line 8) | public static Skin GetSkin()
method GetCursorSet (line 20) | public static CursorCollection GetCursorSet()
method GetControlStyles (line 38) | private static Dictionary<string, ControlStyle> GetControlStyles()
method GetTexturePath (line 282) | private static string GetTexturePath(string name)
FILE: Localizer/UIs/UIDesktop.cs
class UIDesktop (line 6) | public class UIDesktop : Desktop
method UIDesktop (line 10) | public UIDesktop()
method AddWindow (line 21) | public void AddWindow(Window window)
FILE: Localizer/UIs/UIHost.cs
class UIHost (line 10) | public class UIHost : Disposable
method UIHost (line 18) | public UIHost()
method Update (line 30) | internal void Update(GameTime time)
method Draw (line 56) | internal void Draw(GameTime time)
method DisposeUnmanaged (line 62) | protected override void DisposeUnmanaged()
FILE: Localizer/UIs/UIModsPatch.cs
class UIModsPatch (line 15) | internal static class UIModsPatch
method Patch (line 21) | public static void Patch()
method PopulateFromJsonPrefix (line 45) | private static void PopulateFromJsonPrefix()
method PopulateFromJsonPostfix (line 51) | private static void PopulateFromJsonPostfix()
method ModNeedsReloadPostfix (line 57) | private static void ModNeedsReloadPostfix(ref bool __result)
method DrawSelfPostfix (line 65) | private static void DrawSelfPostfix(object __instance, SpriteBatch spr...
method UIModItemPostfix (line 108) | private static void UIModItemPostfix(object __instance)
FILE: Localizer/UIs/UIRenderer.cs
class UIRenderer (line 17) | public class UIRenderer : ISquidRenderer
method UIRenderer (line 30) | public UIRenderer()
method AddFont (line 64) | public void AddFont(string key, DynamicSpriteFont font)
method AddTexture (line 71) | public void AddTexture(string key, Texture2D tex)
method Dispose (line 78) | public void Dispose()
method GetTexture (line 82) | public int GetTexture(string name)
method GetFont (line 87) | public int GetFont(string name)
method GetTextSize (line 92) | public Point GetTextSize(string text, int font)
method WordWrap (line 98) | public string WordWrap(string text, int width)
method GetTextureSize (line 104) | public Point GetTextureSize(int texture)
method Scissor (line 110) | public void Scissor(int x, int y, int w, int h)
method DrawBox (line 116) | public void DrawBox(int x, int y, int w, int h, int color)
method ColorFromtInt32 (line 122) | private Color ColorFromtInt32(int color)
method DrawText (line 128) | public void DrawText(string text, int x, int y, int font, int color)
method DrawTexture (line 140) | public void DrawTexture(int texture, int x, int y, int w, int h, Squid...
method TranslateKey (line 147) | public bool TranslateKey(int scancode, ref char character)
method StartBatch (line 153) | public void StartBatch()
method EndBatch (line 158) | public void EndBatch(bool final)
FILE: Localizer/UIs/Views/ReloadPluginView.cs
class ReloadPluginView (line 6) | public class ReloadPluginView : BasicWindow
method ReloadPluginView (line 8) | public ReloadPluginView()
FILE: Localizer/UIs/Views/TestView.cs
class TestView (line 6) | public class TestView : BasicWindow
method TestView (line 8) | public TestView()
FILE: LocalizerTest/DataModel/GitHubUpdateInfoTest.cs
class GitHubUpdateInfoTest (line 9) | public class GitHubUpdateInfoTest
method Parse_Correct (line 11) | [Fact]
FILE: LocalizerTest/Helper/ExtensionsTest.cs
class ExtensionsTest (line 9) | public class ExtensionsTest
method ModTranslationOwnerField_Correct (line 11) | [Theory]
method ModTranslationOwnerFieldName_Correct (line 23) | [Fact]
method ModTranslationProp_Correct (line 30) | [Fact]
FILE: LocalizerTest/Helper/UtilsTest.cs
class UtilsTest (line 8) | public class UtilsTest
method CreateEntryMappings_Correct (line 10) | [Fact]
method GetMethodBase_Correct (line 19) | [Fact]
method GetMethodBase_Wrong (line 26) | [Fact]
method GetTranslationEntry_Correct (line 33) | [Fact]
FILE: LocalizerTest/LocalizerTest.cs
class FooA (line 9) | [OperationTiming(OperationTiming.BeforeModCtor)]
class FooB (line 11) | [OperationTiming(OperationTiming.BeforeModLoad)]
class FooC (line 13) | [OperationTiming(OperationTiming.PostContentLoad)]
class FooD (line 15) | [OperationTiming(OperationTiming.Any)]
class FooE (line 18) | internal class FooE { }
class LocalizerTest (line 20) | public class LocalizerTest
method CanDoOperationNow_True (line 22) | [Theory]
method CanDoOperationNow_Type_True (line 36) | [Theory]
method CanDoOperationNow_False (line 48) | [Theory]
method CanDoOperationNow_Type_False (line 60) | [Theory]
FILE: LocalizerTest/Network/GitHubModUpdateService.cs
class GitHubModUpdateServiceTest (line 10) | public class GitHubModUpdateServiceTest
method GitHubModUpdateServiceTest (line 16) | public GitHubModUpdateServiceTest()
method GetUpdateInfo_Correct (line 27) | [Fact]
method GetDownlaodURL_Correct (line 36) | [Fact]
FILE: LocalizerTest/Ninject.cs
type IFoo (line 8) | public interface IFoo
type IBar (line 13) | public interface IBar<T> where T : IFoo
class A (line 18) | public sealed class A : IFoo
class B (line 23) | public sealed class B : IFoo
class ABar (line 28) | public sealed class ABar : IBar<A>
class BBar (line 33) | public sealed class BBar : IBar<B>
class NinjectTest (line 38) | public class NinjectTest
method NinjectTest (line 42) | public NinjectTest()
method GenericTypeBinding (line 47) | [Fact]
method MultiSingletonBinding (line 58) | [Fact]
FILE: LocalizerTest/NonTest/UpdateLogger.cs
class UpdateLogger (line 6) | public sealed class UpdateLogger : IUpdateLogger
method UpdateLogger (line 12) | public UpdateLogger()
method Dispose (line 19) | public void Dispose()
method Init (line 23) | public void Init(string name)
method Add (line 27) | public void Add(object content)
method Remove (line 32) | public void Remove(object content)
method Change (line 37) | public void Change(object content)
FILE: LocalizerTest/Package/Import/BasicFileImportTest.cs
class BasicFileImportTest (line 9) | public class BasicFileImportTest
method MergeFile_Correct (line 11) | [Fact]
method MergeEntry_Correct (line 154) | [Fact]
FILE: LocalizerTest/Package/Import/CustomModTranslationFileImportTest.cs
class CustomModTranslationFileImportTest (line 9) | public class CustomModTranslationFileImportTest
method Merge_Correct (line 11) | [Fact]
FILE: LocalizerTest/Package/Import/LdstrFileImportBaseTest.cs
class LdstrFileImportBaseTest (line 9) | public class LdstrFileImportBaseTest
method MergeEntry_Correct (line 11) | [Fact]
method MergeFile_Correct (line 65) | [Fact]
FILE: LocalizerTest/Package/Update/BasicFileUpdateTest.cs
class BasicFileUpdateTest (line 10) | public class BasicFileUpdateTest
method UpdateFile_Correct (line 12) | [Fact]
method UpdateEntry_Correct (line 144) | [Fact]
FILE: LocalizerTest/Package/Update/CustomModTranslationFileUpdateTest.cs
class CustomModTranslationFileUpdateTest (line 10) | public class CustomModTranslationFileUpdateTest
method Update_Correct (line 12) | [Fact]
FILE: LocalizerTest/Package/Update/LdstrFileUpdateTest.cs
class LdstrFileUpdateTest (line 10) | public class LdstrFileUpdateTest
method Update_Correct (line 12) | [Fact]
FILE: ModPatch/Program.cs
class Program (line 10) | internal class Program
method Main (line 12) | private static void Main(string[] args)
Condensed preview — 132 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (352K chars).
[
{
"path": ".editorconfig",
"chars": 6617,
"preview": "# To learn more about .editorconfig see https://aka.ms/editorconfigdocs\n############################### \n# Core EditorCo"
},
{
"path": ".gitattributes",
"chars": 2518,
"preview": "###############################################################################\n# Set default behavior to automatically "
},
{
"path": ".github/workflows/build.yml",
"chars": 1730,
"preview": "name: Mod Build\n\non: [push]\n\njobs:\n build:\n runs-on: windows-latest\n steps:\n - uses: actions/checkout@v1\n "
},
{
"path": ".gitignore",
"chars": 4357,
"preview": "## Ignore Visual Studio temporary files, build results, and\n## files generated by popular Visual Studio add-ons.\n\nLocali"
},
{
"path": ".gitmodules",
"chars": 78,
"preview": "[submodule \"Squid\"]\n\tpath = Squid\n\turl = https://github.com/chi-rei-den/Squid\n"
},
{
"path": "LICENSE",
"chars": 35149,
"preview": " GNU GENERAL PUBLIC LICENSE\n Version 3, 29 June 2007\n\n Copyright (C) 2007 Free "
},
{
"path": "Localizer/Attributes/ModTranslationOwnerFieldAttribute.cs",
"chars": 420,
"preview": "using System;\n\nnamespace Localizer.Attributes\n{\n /// <summary>\n /// Indicates the field contains objects those hav"
},
{
"path": "Localizer/Attributes/ModTranslationPropAttribute.cs",
"chars": 365,
"preview": "using System;\n\nnamespace Localizer.Attributes\n{\n /// <summary>\n /// Indicates the name of ModTranslation property."
},
{
"path": "Localizer/Attributes/OperationTimingAttribute.cs",
"chars": 299,
"preview": "using System;\n\nnamespace Localizer.Attributes\n{\n public class OperationTimingAttribute : Attribute\n {\n publ"
},
{
"path": "Localizer/Configuration.cs",
"chars": 1271,
"preview": "namespace Localizer\n{\n public class Configuration\n {\n public bool AutoImport { get; set; } = true;\n\n "
},
{
"path": "Localizer/DataModel/Default/AttributeFile.cs",
"chars": 466,
"preview": "using System.Collections.Generic;\nusing System.Linq;\n\nnamespace Localizer.DataModel.Default\n{\n public class Attribute"
},
{
"path": "Localizer/DataModel/Default/BaseEntry.cs",
"chars": 371,
"preview": "namespace Localizer.DataModel.Default\n{\n public class BaseEntry : IEntry\n {\n public string Origin { get; s"
},
{
"path": "Localizer/DataModel/Default/BasicBuffFile.cs",
"chars": 961,
"preview": "using System.Collections.Generic;\nusing System.Linq;\nusing Localizer.Attributes;\n\nnamespace Localizer.DataModel.Default"
},
{
"path": "Localizer/DataModel/Default/BasicItemFile.cs",
"chars": 945,
"preview": "using System.Collections.Generic;\nusing System.Linq;\nusing Localizer.Attributes;\n\nnamespace Localizer.DataModel.Default"
},
{
"path": "Localizer/DataModel/Default/BasicNPCFile.cs",
"chars": 760,
"preview": "using System.Collections.Generic;\nusing System.Linq;\nusing Localizer.Attributes;\n\nnamespace Localizer.DataModel.Default"
},
{
"path": "Localizer/DataModel/Default/BasicPrefixFile.cs",
"chars": 790,
"preview": "using System.Collections.Generic;\nusing System.Linq;\nusing Localizer.Attributes;\n\nnamespace Localizer.DataModel.Default\n"
},
{
"path": "Localizer/DataModel/Default/BasicProjectileFile.cs",
"chars": 822,
"preview": "using System.Collections.Generic;\nusing System.Linq;\nusing Localizer.Attributes;\n\nnamespace Localizer.DataModel.Default\n"
},
{
"path": "Localizer/DataModel/Default/CustomModTranslationFile.cs",
"chars": 477,
"preview": "using System.Collections.Generic;\nusing System.Linq;\n\nnamespace Localizer.DataModel.Default\n{\n public class CustomMod"
},
{
"path": "Localizer/DataModel/Default/ExportConfig.cs",
"chars": 243,
"preview": "namespace Localizer.DataModel.Default\n{\n public class ExportConfig : IExportConfig\n {\n public bool MakeBack"
},
{
"path": "Localizer/DataModel/Default/File.cs",
"chars": 378,
"preview": "using System.Collections.Generic;\nusing Newtonsoft.Json;\n\nnamespace Localizer.DataModel.Default\n{\n public abstract c"
},
{
"path": "Localizer/DataModel/Default/GitHubUpdateInfo.cs",
"chars": 902,
"preview": "using System;\n\nnamespace Localizer.DataModel.Default\n{\n public class GitHubUpdateInfo : IUpdateInfo\n {\n pub"
},
{
"path": "Localizer/DataModel/Default/LdstrFile.cs",
"chars": 922,
"preview": "using System.Collections.Generic;\nusing System.Linq;\nusing Localizer.Attributes;\n\nnamespace Localizer.DataModel.Default\n"
},
{
"path": "Localizer/DataModel/Default/LoadedModWrapper.cs",
"chars": 1202,
"preview": "using System;\nusing System.Reflection;\nusing Terraria;\nusing Terraria.ModLoader;\nusing Terraria.ModLoader.Core;\n\nnamespa"
},
{
"path": "Localizer/DataModel/Default/ModWrapper.cs",
"chars": 1311,
"preview": "using System;\nusing System.Reflection;\nusing Terraria;\nusing Terraria.ModLoader;\nusing Terraria.ModLoader.Core;\n\nnamespa"
},
{
"path": "Localizer/DataModel/Default/Package.cs",
"chars": 2016,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\nusing Newtonsoft.Json;\n\nn"
},
{
"path": "Localizer/DataModel/Default/PackageGroup.cs",
"chars": 234,
"preview": "using System.Collections.Generic;\n\nnamespace Localizer.DataModel.Default\n{\n public class PackageGroup : IPackageGroup"
},
{
"path": "Localizer/DataModel/Default/PackageGroupState.cs",
"chars": 620,
"preview": "using System.Collections.Specialized;\nusing Newtonsoft.Json;\n\nnamespace Localizer.DataModel.Default\n{\n [JsonObject(Me"
},
{
"path": "Localizer/DataModel/IEntry.cs",
"chars": 98,
"preview": "namespace Localizer.DataModel\n{\n public interface IEntry\n {\n IEntry Clone();\n }\n}\n"
},
{
"path": "Localizer/DataModel/IExportConfig.cs",
"chars": 571,
"preview": "namespace Localizer.DataModel\n{\n public interface IExportConfig\n {\n /// <summary>\n /// Create ba"
},
{
"path": "Localizer/DataModel/IFile.cs",
"chars": 177,
"preview": "using System.Collections.Generic;\n\nnamespace Localizer.DataModel\n{\n public interface IFile\n {\n List<string>"
},
{
"path": "Localizer/DataModel/IMod.cs",
"chars": 734,
"preview": "using System;\nusing System.Reflection;\nusing Terraria.ModLoader.Core;\n\nnamespace Localizer.DataModel\n{\n public interf"
},
{
"path": "Localizer/DataModel/IPackage.cs",
"chars": 2109,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\n\nnamespace Localizer.DataModel\n{\n public "
},
{
"path": "Localizer/DataModel/IPackageGroup.cs",
"chars": 325,
"preview": "using System.Collections.Generic;\n\nnamespace Localizer.DataModel\n{\n public interface IPackageGroup\n {\n /// "
},
{
"path": "Localizer/DataModel/IUpdateInfo.cs",
"chars": 263,
"preview": "using System;\n\nnamespace Localizer.DataModel\n{\n public enum UpdateType\n {\n None,\n Minor,\n Maj"
},
{
"path": "Localizer/Disposable.cs",
"chars": 756,
"preview": "using System;\n\nnamespace Localizer\n{\n public abstract class Disposable : IDisposable\n {\n protected bool dis"
},
{
"path": "Localizer/Enums/AutoImportType.cs",
"chars": 231,
"preview": "using Newtonsoft.Json;\nusing Newtonsoft.Json.Converters;\n\nnamespace Localizer\n{\n [JsonConverter(typeof(StringEnumConv"
},
{
"path": "Localizer/Enums/LogLevel.cs",
"chars": 268,
"preview": "using Newtonsoft.Json;\nusing Newtonsoft.Json.Converters;\n\nnamespace Localizer\n{\n [JsonConverter(typeof(StringEnumConv"
},
{
"path": "Localizer/Enums/OperationTiming.cs",
"chars": 278,
"preview": "using System;\n\nnamespace Localizer\n{\n [Flags]\n public enum OperationTiming : byte\n {\n BeforeModCtor = 0b"
},
{
"path": "Localizer/Enums/PackageType.cs",
"chars": 96,
"preview": "namespace Localizer\n{\n public enum PackageType\n {\n Packed,\n Source,\n }\n}\n"
},
{
"path": "Localizer/Helpers/Extensions.cs",
"chars": 2738,
"preview": "using System;\nusing System.Globalization;\nusing System.Linq;\nusing System.Reflection;\nusing Localizer.Attributes;\nusing "
},
{
"path": "Localizer/Helpers/Reflection.cs",
"chars": 3797,
"preview": "using System.Collections.Generic;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing Harmony;\n\nnamespace System.Ref"
},
{
"path": "Localizer/Helpers/UI.cs",
"chars": 1769,
"preview": "using System;\nusing System.Reflection;\nusing Localizer.DataModel;\nusing Microsoft.Xna.Framework.Graphics;\nusing Terraria"
},
{
"path": "Localizer/Helpers/Utils.cs",
"chars": 14446,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.IO.Compression;\nusing System.Linq;\nusing S"
},
{
"path": "Localizer/Hooks.cs",
"chars": 1542,
"preview": "using Microsoft.Xna.Framework;\n\nnamespace Localizer\n{\n public class Hooks\n {\n public delegate void BeforeMo"
},
{
"path": "Localizer/Lang/Lang.cs",
"chars": 3745,
"preview": "using System.Collections.Generic;\nusing Terraria.Localization;\nusing Terraria.ModLoader;\n\n// ReSharper disable once Chec"
},
{
"path": "Localizer/Localizer.cs",
"chars": 9372,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Net;\nusing System.Reflection;\nu"
},
{
"path": "Localizer/Localizer.csproj",
"chars": 1742,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project Sdk=\"Microsoft.NET.Sdk\">\n <Import Project=\"$(USERPROFILE)\\Documents\\My"
},
{
"path": "Localizer/Localizer.csproj.DotSettings",
"chars": 431,
"preview": "<wpf:ResourceDictionary xml:space=\"preserve\" xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\" xmlns:s=\"clr-namesp"
},
{
"path": "Localizer/LocalizerKernel.cs",
"chars": 5092,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Reflection;\nusing Local"
},
{
"path": "Localizer/LocalizerPlugin.cs",
"chars": 374,
"preview": "using System;\n\nnamespace Localizer\n{\n public abstract class LocalizerPlugin : Disposable\n {\n public abstra"
},
{
"path": "Localizer/ModBrowser/Patches.cs",
"chars": 11290,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Net;\nusing System.Reflection;\nusing Syst"
},
{
"path": "Localizer/Modules/DefaultNetworkModule.cs",
"chars": 450,
"preview": "using Localizer.Network;\nusing Ninject.Modules;\n\nnamespace Localizer.Modules\n{\n public class DefaultNetworkModule : N"
},
{
"path": "Localizer/Modules/DefaultPackageModule.cs",
"chars": 6469,
"preview": "using System;\nusing System.Reflection;\nusing Localizer.DataModel;\nusing Localizer.DataModel.Default;\nusing Localizer.Pac"
},
{
"path": "Localizer/Network/DownloadManager.cs",
"chars": 563,
"preview": "using System;\nusing System.Net;\n\nnamespace Localizer.Network\n{\n public class DownloadManager : IDownloadManagerServic"
},
{
"path": "Localizer/Network/GitHubModUpdate.cs",
"chars": 1666,
"preview": "using System;\nusing System.Collections.Generic;\nusing Localizer.DataModel;\nusing Localizer.DataModel.Default;\nusing Newt"
},
{
"path": "Localizer/Network/IDownloadManagerService.cs",
"chars": 137,
"preview": "namespace Localizer.Network\n{\n public interface IDownloadManagerService\n {\n void Download(string url, strin"
},
{
"path": "Localizer/Network/IPackageBrowserService.cs",
"chars": 326,
"preview": "using System.Collections.Generic;\nusing Localizer.DataModel;\n\nnamespace Localizer.Network\n{\n public interface IPackag"
},
{
"path": "Localizer/Network/IUpdateService.cs",
"chars": 341,
"preview": "using System;\nusing System.Collections.Generic;\nusing Localizer.DataModel;\n\nnamespace Localizer.Network\n{\n public int"
},
{
"path": "Localizer/Network/PackageBrowser.cs",
"chars": 2085,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing Localizer.DataModel;\nusing Newtonsoft."
},
{
"path": "Localizer/Package/Export/BasicFileExport.cs",
"chars": 2577,
"preview": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;"
},
{
"path": "Localizer/Package/Export/CustomModTranslationFileExport.cs",
"chars": 1297,
"preview": "using System.Collections.Generic;\nusing System.Reflection;\nusing Localizer.DataModel;\nusing Localizer.DataModel.Default;"
},
{
"path": "Localizer/Package/Export/IFileExportService.cs",
"chars": 380,
"preview": "using Localizer.DataModel;\n\nnamespace Localizer.Package.Export\n{\n public interface IFileExportService\n {\n /"
},
{
"path": "Localizer/Package/Export/IPackageExportService.cs",
"chars": 428,
"preview": "using Localizer.DataModel;\n\nnamespace Localizer.Package.Export\n{\n public interface IPackageExportService\n {\n "
},
{
"path": "Localizer/Package/Export/LdstrFileExport.cs",
"chars": 14052,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Reflection;\nusing Local"
},
{
"path": "Localizer/Package/Export/PackageExport.cs",
"chars": 658,
"preview": "using Localizer.DataModel;\nusing Ninject;\nusing Terraria.ModLoader;\n\nnamespace Localizer.Package.Export\n{\n public cla"
},
{
"path": "Localizer/Package/IPackageManageService.cs",
"chars": 865,
"preview": "using System.Collections.Generic;\nusing Localizer.DataModel;\n\nnamespace Localizer.Package\n{\n public interface IPackag"
},
{
"path": "Localizer/Package/Import/AutoImportService.cs",
"chars": 6918,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing Localizer.DataModel;\nusing Loc"
},
{
"path": "Localizer/Package/Import/BasicImporter.cs",
"chars": 4405,
"preview": "using System;\nusing System.Collections;\nusing System.Globalization;\nusing System.Linq;\nusing System.Reflection;\nusing Lo"
},
{
"path": "Localizer/Package/Import/CecilLdstrImporter.cs",
"chars": 4170,
"preview": "using System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Reflectio"
},
{
"path": "Localizer/Package/Import/CustomModTranslationImporter.cs",
"chars": 2719,
"preview": "using System.Collections.Generic;\nusing System.Globalization;\nusing System.Reflection;\nusing Localizer.Attributes;\nusing"
},
{
"path": "Localizer/Package/Import/FileImporter.cs",
"chars": 774,
"preview": "using System.Globalization;\nusing Localizer.DataModel;\n\nnamespace Localizer.Package.Import\n{\n public abstract class F"
},
{
"path": "Localizer/Package/Import/HarmonyLdstrImporter.cs",
"chars": 2916,
"preview": "using System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\nusing System.Reflection;\nusing Harmony;"
},
{
"path": "Localizer/Package/Import/IPackageImportService.cs",
"chars": 856,
"preview": "using System;\nusing Localizer.DataModel;\n\nnamespace Localizer.Package.Import\n{\n public interface IPackageImportServic"
},
{
"path": "Localizer/Package/Import/LdstrImporterBase.cs",
"chars": 2528,
"preview": "using System.Collections.Generic;\nusing System.Globalization;\nusing Localizer.DataModel;\nusing Localizer.DataModel.Defau"
},
{
"path": "Localizer/Package/Import/MonoModLdstrImporter.cs",
"chars": 2511,
"preview": "using System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\nusing System.Reflection;\nusing Localize"
},
{
"path": "Localizer/Package/Import/PackageImportService.cs",
"chars": 6719,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Reflection;\nusing Localizer.Attributes;\n"
},
{
"path": "Localizer/Package/Import/RefreshLanguageService.cs",
"chars": 3907,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Reflection;\nusing System.Threadin"
},
{
"path": "Localizer/Package/Load/IFileLoadService.cs",
"chars": 388,
"preview": "using System.IO;\nusing Localizer.DataModel;\n\nnamespace Localizer.Package.Load\n{\n public interface IFileLoadService\n "
},
{
"path": "Localizer/Package/Load/IPackageLoadService.cs",
"chars": 410,
"preview": "using Localizer.DataModel;\n\nnamespace Localizer.Package.Load\n{\n public interface IPackageLoadService<T> where T : IPa"
},
{
"path": "Localizer/Package/Load/JsonFileLoad.cs",
"chars": 1893,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing Localizer.DataModel;\nusing Localizer.DataModel.De"
},
{
"path": "Localizer/Package/Load/PackedPackageLoad.cs",
"chars": 2096,
"preview": "using System.IO;\nusing System.IO.Compression;\nusing Localizer.DataModel;\n\nnamespace Localizer.Package.Load\n{\n public "
},
{
"path": "Localizer/Package/Load/SourcePackageLoad.cs",
"chars": 2045,
"preview": "using System.IO;\nusing Localizer.DataModel;\nusing File = System.IO.File;\n\nnamespace Localizer.Package.Load\n{\n public "
},
{
"path": "Localizer/Package/Pack/IPackagePackService.cs",
"chars": 272,
"preview": "namespace Localizer.Package.Pack\n{\n public interface IPackagePackService\n {\n /// <summary>\n /// "
},
{
"path": "Localizer/Package/Pack/ZipPackagePackService.cs",
"chars": 1721,
"preview": "using System.IO;\nusing System.IO.Compression;\nusing Localizer.DataModel;\n\nnamespace Localizer.Package.Pack\n{\n public "
},
{
"path": "Localizer/Package/PackageManageService.cs",
"chars": 2894,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing Localizer.DataModel;\nusing Localizer.DataModel."
},
{
"path": "Localizer/Package/Save/IFileSaveService.cs",
"chars": 313,
"preview": "using Localizer.DataModel;\n\nnamespace Localizer.Package.Save\n{\n public interface IFileSaveService\n {\n /// <"
},
{
"path": "Localizer/Package/Save/IPackageSaveService.cs",
"chars": 433,
"preview": "using Localizer.DataModel;\n\nnamespace Localizer.Package.Save\n{\n public interface IPackageSaveService\n {\n //"
},
{
"path": "Localizer/Package/Save/JsonFileSaveService.cs",
"chars": 312,
"preview": "using Localizer.DataModel;\n\nnamespace Localizer.Package.Save\n{\n public class JsonFileSaveService : IFileSaveService\n "
},
{
"path": "Localizer/Package/Save/PackageSaveService.cs",
"chars": 575,
"preview": "using System.IO;\nusing Localizer.DataModel;\n\nnamespace Localizer.Package.Save\n{\n public class PackageSave : IPackageS"
},
{
"path": "Localizer/Package/Update/BasicFileUpdater.cs",
"chars": 2647,
"preview": "using System.Collections;\nusing System.Collections.Generic;\nusing Localizer.DataModel;\nusing Localizer.DataModel.Default"
},
{
"path": "Localizer/Package/Update/CustomModTranslationUpdater.cs",
"chars": 1769,
"preview": "using System.Linq;\nusing Localizer.DataModel;\nusing Localizer.DataModel.Default;\n\nnamespace Localizer.Package.Update\n{\n "
},
{
"path": "Localizer/Package/Update/FileUpdater.cs",
"chars": 1211,
"preview": "using System;\nusing Localizer.DataModel;\n\nnamespace Localizer.Package.Update\n{\n public abstract class FileUpdater\n "
},
{
"path": "Localizer/Package/Update/IPackageUpdateService.cs",
"chars": 630,
"preview": "using Localizer.DataModel;\n\nnamespace Localizer.Package.Update\n{\n public interface IPackageUpdateService\n {\n "
},
{
"path": "Localizer/Package/Update/IUpdateLogger.cs",
"chars": 790,
"preview": "namespace Localizer.Package.Update\n{\n public interface IUpdateLogger\n {\n /// <summary>\n /// Init"
},
{
"path": "Localizer/Package/Update/LdstrFileUpdater.cs",
"chars": 1806,
"preview": "using System.Linq;\nusing Localizer.DataModel;\nusing Localizer.DataModel.Default;\n\nnamespace Localizer.Package.Update\n{\n "
},
{
"path": "Localizer/Package/Update/PackageUpdateService.cs",
"chars": 2548,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing Localizer.DataModel;\n\nnamespace Localizer.Packa"
},
{
"path": "Localizer/Package/Update/PlainUpdateLogger.cs",
"chars": 906,
"preview": "using System.IO;\n\nnamespace Localizer.Package.Update\n{\n public class PlainUpdateLogger : IUpdateLogger\n {\n "
},
{
"path": "Localizer/Properties/AssemblyInfo.cs",
"chars": 88,
"preview": "using System.Runtime.CompilerServices;\n\n[assembly: InternalsVisibleTo(\"LocalizerTest\")]\n"
},
{
"path": "Localizer/UIs/Components/BasicListBox.cs",
"chars": 614,
"preview": "using Squid;\n\nnamespace Localizer.UIs.Components\n{\n public class BasicListBox : ListBox\n {\n public BasicLis"
},
{
"path": "Localizer/UIs/Components/BasicWindow.cs",
"chars": 1025,
"preview": "using Squid;\n\nnamespace Localizer.UIs.Components\n{\n public class BasicWindow : Window\n {\n public TitleBar T"
},
{
"path": "Localizer/UIs/Components/LabelListBoxItem.cs",
"chars": 516,
"preview": "using Squid;\n\nnamespace Localizer.UIs.Components\n{\n public class LabelListBoxItem : ListBoxItem\n {\n public "
},
{
"path": "Localizer/UIs/Components/TitleBar.cs",
"chars": 578,
"preview": "using Squid;\n\nnamespace Localizer.UIs.Components\n{\n public class TitleBar : Label\n {\n public Button Button "
},
{
"path": "Localizer/UIs/MainWindow.cs",
"chars": 17610,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Collections.ObjectModel;\nusing System.Diagnostics;\nusing Sy"
},
{
"path": "Localizer/UIs/Stylesheet.cs",
"chars": 10892,
"preview": "using System.Collections.Generic;\nusing Squid;\n\nnamespace Localizer.UIs\n{\n public class Stylesheet\n {\n publ"
},
{
"path": "Localizer/UIs/UIDesktop.cs",
"chars": 568,
"preview": "using Localizer.UIs.Views;\nusing Squid;\n\nnamespace Localizer.UIs\n{\n public class UIDesktop : Desktop\n {\n pu"
},
{
"path": "Localizer/UIs/UIHost.cs",
"chars": 1965,
"preview": "using Microsoft.Xna.Framework;\nusing Microsoft.Xna.Framework.Graphics;\nusing Microsoft.Xna.Framework.Input;\nusing Squid;"
},
{
"path": "Localizer/UIs/UIModsPatch.cs",
"chars": 5213,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Reflection;\nusing Harmony;\nusing Microsoft.Xna.Framework;\nu"
},
{
"path": "Localizer/UIs/UIRenderer.cs",
"chars": 5422,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Reflection;\nusing Localizer.Helpers;\nusi"
},
{
"path": "Localizer/UIs/Views/ManagerView.cs",
"chars": 34,
"preview": "namespace Localizer.UIs.Views\n{\n}\n"
},
{
"path": "Localizer/UIs/Views/ReloadPluginView.cs",
"chars": 685,
"preview": "using Localizer.UIs.Components;\nusing Squid;\n\nnamespace Localizer.UIs.Views\n{\n public class ReloadPluginView : BasicW"
},
{
"path": "Localizer/UIs/Views/TestView.cs",
"chars": 4266,
"preview": "using Localizer.UIs.Components;\nusing Squid;\n\nnamespace Localizer.UIs.Views\n{\n public class TestView : BasicWindow\n "
},
{
"path": "Localizer/build.txt",
"chars": 348,
"preview": "author = Chireiden Team\nversion = 1.5.0.19\ndisplayName = Localizer\nhideCode = true\nhideResources = false\nincludeSource ="
},
{
"path": "Localizer/description.txt",
"chars": 274,
"preview": "Provide localization functions include:\n - Extract texts from mods\n - Apply translations to mods\n - Create you"
},
{
"path": "Localizer.sln",
"chars": 3980,
"preview": "\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio Version 16\nVisualStudioVersion = 16.0.2932"
},
{
"path": "Localizer.sln.DotSettings",
"chars": 547,
"preview": "<wpf:ResourceDictionary xml:space=\"preserve\" xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\" xmlns:s=\"clr-namesp"
},
{
"path": "LocalizerTest/DataModel/GitHubUpdateInfoTest.cs",
"chars": 460,
"preview": "using System;\nusing FluentAssertions;\nusing Localizer.DataModel;\nusing Localizer.DataModel.Default;\nusing Xunit;\n\nnamesp"
},
{
"path": "LocalizerTest/Helper/ExtensionsTest.cs",
"chars": 1317,
"preview": "using System;\nusing FluentAssertions;\nusing Localizer.DataModel.Default;\nusing Localizer.Helpers;\nusing Xunit;\n\nnamespac"
},
{
"path": "LocalizerTest/Helper/UtilsTest.cs",
"chars": 1742,
"preview": "using FluentAssertions;\nusing Localizer.DataModel.Default;\nusing Xunit;\nusing ModUtils = Localizer.Utils;\n\nnamespace Loc"
},
{
"path": "LocalizerTest/LocalizerTest.cs",
"chars": 3153,
"preview": "using System;\nusing FluentAssertions;\nusing Localizer;\nusing Localizer.Attributes;\nusing Xunit;\n\nnamespace LocalizerTest"
},
{
"path": "LocalizerTest/LocalizerTest.csproj",
"chars": 1332,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project Sdk=\"Microsoft.NET.Sdk\">\n <Import Project=\"$(USERPROFILE)\\Documents\\My"
},
{
"path": "LocalizerTest/Network/GitHubModUpdateService.cs",
"chars": 4390,
"preview": "using System;\nusing FluentAssertions;\nusing Localizer.DataModel;\nusing Localizer.Network;\nusing Newtonsoft.Json.Linq;\nus"
},
{
"path": "LocalizerTest/Ninject.cs",
"chars": 1260,
"preview": "using System.Linq;\nusing FluentAssertions;\nusing Ninject;\nusing Xunit;\n\nnamespace LocalizerTest\n{\n public interface I"
},
{
"path": "LocalizerTest/NonTest/UpdateLogger.cs",
"chars": 947,
"preview": "using System.Collections.Generic;\nusing Localizer.Package.Update;\n\nnamespace LocalizerTest.NonTest\n{\n public sealed c"
},
{
"path": "LocalizerTest/Package/Import/BasicFileImportTest.cs",
"chars": 9333,
"preview": "using System.Collections.Generic;\nusing FluentAssertions;\nusing Localizer.DataModel.Default;\nusing Localizer.Package.Imp"
},
{
"path": "LocalizerTest/Package/Import/CustomModTranslationFileImportTest.cs",
"chars": 1624,
"preview": "using System.Collections.Generic;\nusing FluentAssertions;\nusing Localizer.DataModel.Default;\nusing Localizer.Package.Imp"
},
{
"path": "LocalizerTest/Package/Import/LdstrFileImportBaseTest.cs",
"chars": 5278,
"preview": "using System.Collections.Generic;\nusing FluentAssertions;\nusing Localizer.DataModel.Default;\nusing Localizer.Package.Imp"
},
{
"path": "LocalizerTest/Package/Update/BasicFileUpdateTest.cs",
"chars": 8620,
"preview": "using System.Collections.Generic;\nusing FluentAssertions;\nusing Localizer.DataModel.Default;\nusing Localizer.Package.Upd"
},
{
"path": "LocalizerTest/Package/Update/CustomModTranslationFileUpdateTest.cs",
"chars": 2494,
"preview": "using System.Collections.Generic;\nusing FluentAssertions;\nusing Localizer.DataModel.Default;\nusing Localizer.Package.Upd"
},
{
"path": "LocalizerTest/Package/Update/LdstrFileUpdateTest.cs",
"chars": 3970,
"preview": "using System.Collections.Generic;\nusing FluentAssertions;\nusing Localizer.DataModel.Default;\nusing Localizer.Package.Upd"
},
{
"path": "ModPatch/ModPatch.csproj",
"chars": 468,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project Sdk=\"Microsoft.NET.Sdk\">\n <Import Project=\"$(USERPROFILE)\\Documents\\My"
},
{
"path": "ModPatch/Program.cs",
"chars": 3871,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Security.Cryptography;\n"
},
{
"path": "README.md",
"chars": 375,
"preview": "# Localizer Mod\n\n\n. The extraction includes 132 files (322.4 KB), approximately 70.1k tokens, and a symbol index with 535 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.