chore: initial commit

This commit is contained in:
Anna 2020-08-19 02:55:02 -04:00
commit d2e5ffbfe4
Signed by: anna
GPG Key ID: 0B391D8F06FCD9E0
16 changed files with 1807 additions and 0 deletions

203
.editorconfig Normal file
View File

@ -0,0 +1,203 @@
# Remove the line below if you want to inherit .editorconfig settings from higher directories
root = true
# C# files
[*.{cs,json}]
#### Core EditorConfig Options ####
# Indentation and spacing
indent_size = 4
indent_style = space
tab_width = 4
# New line preferences
end_of_line = lf
insert_final_newline = true
[*.cs]
#### .NET Coding Conventions ####
# Organize usings
dotnet_separate_import_directive_groups = false
dotnet_sort_system_directives_first = false
file_header_template = unset
# this. and Me. preferences
dotnet_style_qualification_for_event = true:silent
dotnet_style_qualification_for_field = true:silent
dotnet_style_qualification_for_method = true:silent
dotnet_style_qualification_for_property = true: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_other_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
# Modifier preferences
dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
# Expression-level preferences
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_object_initializer = true:suggestion
dotnet_style_operator_placement_when_wrapping = beginning_of_line
dotnet_style_prefer_auto_properties = true:silent
dotnet_style_prefer_compound_assignment = true:suggestion
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
dotnet_style_prefer_conditional_expression_over_return = true:silent
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
dotnet_style_prefer_simplified_interpolation = true:suggestion
# Field preferences
dotnet_style_readonly_field = true:suggestion
# Parameter preferences
dotnet_code_quality_unused_parameters = all:suggestion
#### C# Coding Conventions ####
# var preferences
csharp_style_var_elsewhere = false:silent
csharp_style_var_for_built_in_types = false:silent
csharp_style_var_when_type_is_apparent = false:silent
# Expression-bodied members
csharp_style_expression_bodied_accessors = true:silent
csharp_style_expression_bodied_constructors = false:silent
csharp_style_expression_bodied_indexers = true:silent
csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = false:silent
csharp_style_expression_bodied_methods = false:silent
csharp_style_expression_bodied_operators = false:silent
csharp_style_expression_bodied_properties = true:silent
# Pattern matching preferences
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
csharp_style_prefer_switch_expression = true:suggestion
# Null-checking preferences
csharp_style_conditional_delegate_call = true:suggestion
# Modifier preferences
csharp_prefer_static_local_function = true:suggestion
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:silent
# Code-block preferences
csharp_prefer_braces = true:silent
csharp_prefer_simple_using_statement = true:suggestion
# Expression-level preferences
csharp_prefer_simple_default_expression = true:suggestion
csharp_style_deconstructed_variable_declaration = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion
csharp_style_pattern_local_over_anonymous_function = true:suggestion
csharp_style_prefer_index_operator = true:suggestion
csharp_style_prefer_range_operator = true:suggestion
csharp_style_throw_expression = true:suggestion
csharp_style_unused_value_assignment_preference = discard_variable:suggestion
csharp_style_unused_value_expression_statement_preference = discard_variable:silent
# 'using' directive preferences
csharp_using_directive_placement = outside_namespace:silent
#### C# Formatting Rules ####
# New line preferences
csharp_new_line_before_catch = false
csharp_new_line_before_else = false
csharp_new_line_before_finally = false
csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_open_brace = none
csharp_new_line_between_query_expression_clauses = true
# Indentation preferences
csharp_indent_block_contents = true
csharp_indent_braces = false
csharp_indent_case_contents = true
csharp_indent_case_contents_when_block = true
csharp_indent_labels = one_less_than_current
csharp_indent_switch_labels = true
# Space preferences
csharp_space_after_cast = false
csharp_space_after_colon_in_inheritance_clause = true
csharp_space_after_comma = true
csharp_space_after_dot = false
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_after_semicolon_in_for_statement = true
csharp_space_around_binary_operators = before_and_after
csharp_space_around_declaration_statements = false
csharp_space_before_colon_in_inheritance_clause = true
csharp_space_before_comma = false
csharp_space_before_dot = false
csharp_space_before_open_square_brackets = false
csharp_space_before_semicolon_in_for_statement = false
csharp_space_between_empty_square_brackets = false
csharp_space_between_method_call_empty_parameter_list_parentheses = false
csharp_space_between_method_call_name_and_opening_parenthesis = false
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
csharp_space_between_method_declaration_name_and_open_parenthesis = false
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_parentheses = false
csharp_space_between_square_brackets = false
# Wrapping preferences
csharp_preserve_single_line_blocks = true
csharp_preserve_single_line_statements = true
#### Naming styles ####
# Naming rules
dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
# Symbol specifications
dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.interface.required_modifiers =
dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.types.required_modifiers =
dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.non_field_members.required_modifiers =
# Naming styles
dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case
dotnet_naming_style.begins_with_i.required_prefix = I
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.capitalization = pascal_case

2
.gitattributes vendored Normal file
View File

@ -0,0 +1,2 @@
* text eol=lf
*.wav binary

362
.gitignore vendored Normal file
View File

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

30
CCMM.sln Normal file
View File

@ -0,0 +1,30 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30330.147
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Custom Commands and Macro Macros", "Custom Commands and Macro Macros\Custom Commands and Macro Macros.csproj", "{09B0F618-89E6-4CEE-9835-A4686DE9B716}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D9C29BDA-B9DA-4E1D-AAFA-55B898E33593}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{09B0F618-89E6-4CEE-9835-A4686DE9B716}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{09B0F618-89E6-4CEE-9835-A4686DE9B716}.Debug|Any CPU.Build.0 = Debug|Any CPU
{09B0F618-89E6-4CEE-9835-A4686DE9B716}.Release|Any CPU.ActiveCfg = Release|Any CPU
{09B0F618-89E6-4CEE-9835-A4686DE9B716}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {475362F2-FC86-44B0-815B-DBDBB533AD8F}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,61 @@
using Dalamud.Game.Command;
using Dalamud.Plugin;
using System;
using System.Collections.Generic;
namespace CCMM {
public class CCMMPlugin : IDalamudPlugin {
private bool disposedValue;
public string Name => "Custom Commands and Macro Macros";
public DalamudPluginInterface Interface { get; private set; }
public GameFunctions Functions { get; private set; }
public PluginUI Ui { get; private set; }
public MacroHandler MacroHandler { get; private set; }
public Configuration Config { get; private set; }
private Commands Commands { get; set; }
public void Initialize(DalamudPluginInterface pluginInterface) {
this.Interface = pluginInterface ?? throw new ArgumentNullException(nameof(pluginInterface), "DalamudPluginInterface cannot be null");
this.Functions = new GameFunctions(this);
this.Ui = new PluginUI(this);
this.MacroHandler = new MacroHandler(this);
this.Config = Configuration.Load(this) ?? new Configuration();
this.Config.Initialise(this);
this.Commands = new Commands(this);
this.Interface.UiBuilder.OnBuildUi += this.Ui.Draw;
this.Interface.UiBuilder.OnOpenConfigUi += this.Ui.OpenSettings;
this.Interface.Framework.OnUpdateEvent += this.MacroHandler.OnFrameworkUpdate;
foreach (KeyValuePair<string, string> entry in Commands.COMMANDS) {
this.Interface.CommandManager.AddHandler(entry.Key, new CommandInfo(this.Commands.OnCommand) {
HelpMessage = entry.Value,
});
}
}
protected virtual void Dispose(bool disposing) {
if (!disposedValue) {
if (disposing) {
this.Interface.UiBuilder.OnBuildUi -= this.Ui.Draw;
this.Interface.UiBuilder.OnOpenConfigUi -= this.Ui.OpenSettings;
this.Interface.Framework.OnUpdateEvent -= this.MacroHandler.OnFrameworkUpdate;
foreach (string command in Commands.COMMANDS.Keys) {
this.Interface.CommandManager.RemoveHandler(command);
}
}
// TODO: free unmanaged resources (unmanaged objects) and override finalizer
// TODO: set large fields to null
disposedValue = true;
}
}
public void Dispose() {
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
Dispose(disposing: true);
GC.SuppressFinalize(this);
}
}
}

View File

@ -0,0 +1,80 @@
using Dalamud.Plugin;
using System;
using System.Collections.Generic;
using System.Linq;
namespace CCMM {
public class Commands {
private readonly CCMMPlugin plugin;
public static readonly IReadOnlyDictionary<string, string> COMMANDS = new Dictionary<string, string> {
["/ccmm"] = "Open the CCMM interface",
["/mmacro"] = "Execute a CCMM macro",
["/mmcancel"] = "Cancel the first CCMM macro of a given type or all if \"all\" is passed",
};
public Commands(CCMMPlugin plugin) {
this.plugin = plugin ?? throw new ArgumentNullException(nameof(plugin), "CCMMPlugin cannot be null");
}
public void OnCommand(string command, string args) {
switch (command) {
case "/ccmm":
this.OnMainCommand();
break;
case "/mmacro":
this.OnMacroCommand(args);
break;
case "/mmcancel":
this.OnMacroCancelCommand(args);
break;
default:
this.plugin.Interface.Framework.Gui.Chat.PrintError($"The command {command} was passed to CCMM, but there is no handler available.");
break;
}
}
private void OnMainCommand() {
this.plugin.Ui.SettingsVisible = !this.plugin.Ui.SettingsVisible;
}
private void OnMacroCommand(string args) {
string first = args.Trim().Split(' ').FirstOrDefault() ?? "";
if (!Guid.TryParse(first, out Guid id)) {
this.plugin.Interface.Framework.Gui.Chat.PrintError("First argument must be the UUID of the macro to execute.");
return;
}
Macro macro = this.plugin.Config.FindMacro(id);
if (macro == null) {
this.plugin.Interface.Framework.Gui.Chat.PrintError($"No macro with ID {id} found.");
return;
}
this.plugin.MacroHandler.SpawnMacro(macro);
}
private void OnMacroCancelCommand(string args) {
string first = args.Trim().Split(' ').FirstOrDefault() ?? "";
if (first == "all") {
foreach (Guid running in this.plugin.MacroHandler.Running.Keys) {
this.plugin.MacroHandler.CancelMacro(running);
}
return;
}
if (!Guid.TryParse(first, out Guid id)) {
this.plugin.Interface.Framework.Gui.Chat.PrintError("First argument must either be \"all\" or the UUID of the macro to cancel.");
return;
}
Macro macro = this.plugin.Config.FindMacro(id);
if (macro == null) {
this.plugin.Interface.Framework.Gui.Chat.PrintError($"No macro with ID {id} found.");
return;
}
KeyValuePair<Guid, Macro> entry = this.plugin.MacroHandler.Running.FirstOrDefault(e => e.Value.Id == id);
if (entry.Value == null) {
this.plugin.Interface.Framework.Gui.Chat.PrintError($"That macro is not running.");
return;
}
this.plugin.MacroHandler.CancelMacro(entry.Key);
}
}
}

View File

@ -0,0 +1,173 @@
using Dalamud.Configuration;
using Dalamud.Plugin;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace CCMM {
public class Configuration : IPluginConfiguration {
private CCMMPlugin plugin;
public int Version { get; set; } = 1;
[JsonProperty]
[JsonConverter(typeof(NodeConverter))]
public List<INode> Nodes { get; private set; } = new List<INode>();
public int MaxLength { get; set; } = 10_000;
internal void Initialise(CCMMPlugin plugin) {
this.plugin = plugin ?? throw new ArgumentNullException(nameof(plugin), "CCMMPlugin cannot be null");
}
internal void Save() {
string configPath = ConfigPath(plugin);
string configText = JsonConvert.SerializeObject(this, Formatting.Indented);
File.WriteAllText(configPath, configText);
}
private static string ConfigPath(CCMMPlugin plugin) {
string[] paths = {
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
"XIVLauncher",
"pluginConfigs",
$"{plugin.Name}.json",
};
return Path.Combine(paths);
}
internal static Configuration Load(CCMMPlugin plugin) {
string configPath = ConfigPath(plugin);
if (File.Exists(configPath)) {
string configText;
try {
configText = File.ReadAllText(configPath);
} catch (IOException e) {
PluginLog.Log($"Could not read config at {configPath}: {e.Message}.");
return null;
}
return JsonConvert.DeserializeObject<Configuration>(configText);
}
return new Configuration();
}
private static IEnumerable<T> Traverse<T>(T item, Func<T, IEnumerable<T>> childSelector) {
var stack = new Stack<T>();
stack.Push(item);
while (stack.Any()) {
var next = stack.Pop();
yield return next;
foreach (var child in childSelector(next))
stack.Push(child);
}
}
public Macro FindMacro(Guid id) {
foreach (INode node in this.Nodes) {
Macro macro = (Macro)Traverse(node, n => n.Children).FirstOrDefault(n => n.Id == id && n is Macro);
if (macro != null) {
return macro;
}
}
return null;
}
}
public interface INode {
Guid Id { get; set; }
string Name { get; set; }
List<INode> Children { get; }
INode Duplicate();
}
public class Folder : INode {
public Guid Id { get; set; }
public string Name { get; set; }
public List<INode> Children { get; private set; } = new List<INode>();
public Folder(string name, List<INode> children = null) {
this.Id = Guid.NewGuid();
this.Name = name;
if (children != null) {
this.Children = children;
}
}
internal Folder(Guid id, string name, List<INode> children) {
this.Id = id;
this.Name = name;
this.Children = children;
}
public INode Duplicate() {
return new Folder(this.Id, this.Name, this.Children);
}
}
public class Macro : INode {
public Guid Id { get; set; }
public string Name { get; set; }
public string Contents { get; set; }
public List<INode> Children => new List<INode>();
public Macro(string name, string contents) {
this.Id = Guid.NewGuid();
this.Name = name;
this.Contents = contents;
}
internal Macro(Guid id, string name, string contents) {
this.Id = id;
this.Name = name;
this.Contents = contents;
}
public INode Duplicate() {
return new Macro(this.Id, this.Name, this.Contents);
}
}
// This custom converter is necessary to enable live reloading of the assembly. Without this converter, trying to use type information will fail
// when a new version of the assembly is loaded. Instead, don't use type information and just check for the presence of a "Contents" key, then
// manually do the deserialisation. It's gross, but it works.
public class NodeConverter : JsonConverter {
public override bool CanWrite => false;
public override bool CanRead => true;
public override bool CanConvert(Type objectType) {
return objectType == typeof(INode);
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) {
throw new InvalidOperationException("Use default serialization.");
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) {
JArray jsonArray = JArray.Load(reader);
List<INode> list = new List<INode>();
foreach (JToken token in jsonArray) {
JObject jsonObject = (JObject)token;
INode node;
if (jsonObject.ContainsKey("Contents")) {
node = new Macro(
jsonObject["Id"].ToObject<Guid>(),
jsonObject["Name"].ToObject<string>(),
jsonObject["Contents"].ToObject<string>()
);
} else {
node = new Folder(
jsonObject["Id"].ToObject<Guid>(),
jsonObject["Name"].ToObject<string>(),
(List<INode>)this.ReadJson(jsonObject["Children"].CreateReader(), typeof(List<INode>), null, serializer)
);
}
list.Add(node);
}
return list;
}
}
}

View File

@ -0,0 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{09B0F618-89E6-4CEE-9835-A4686DE9B716}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CCMM</RootNamespace>
<AssemblyName>Custom Commands and Macro Macros</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="Dalamud">
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\Dalamud.dll</HintPath>
</Reference>
<Reference Include="ImGui.NET">
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\ImGui.NET.dll</HintPath>
</Reference>
<Reference Include="ImGuiScene">
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\ImGuiScene.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Numerics" />
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.6.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Channels, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Channels.4.7.1\lib\net461\System.Threading.Channels.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="CCMMPlugin.cs" />
<Compile Include="Commands.cs" />
<Compile Include="Configuration.cs" />
<Compile Include="GameFunctions.cs" />
<Compile Include="MacroHandler.cs" />
<Compile Include="PluginUI.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -0,0 +1,70 @@
using Dalamud.Plugin;
using System;
using System.Runtime.InteropServices;
using System.Text;
namespace CCMM {
public class GameFunctions {
private readonly CCMMPlugin plugin;
private delegate IntPtr GetUIBaseDelegate();
private delegate IntPtr GetUIModuleDelegate(IntPtr basePtr);
private delegate void ProcessChatBoxDelegate(IntPtr raptureModule, IntPtr message, IntPtr uiModule);
private readonly GetUIBaseDelegate GetUIBase;
private readonly GetUIModuleDelegate GetUIModule;
private readonly ProcessChatBoxDelegate _ProcessChatBox;
public GameFunctions(CCMMPlugin plugin) {
this.plugin = plugin ?? throw new ArgumentNullException(nameof(plugin), "CCMMPlugin cannot be null");
IntPtr getUIBasePtr = this.plugin.Interface.TargetModuleScanner.ScanText("E8 ?? ?? ?? ?? 41 b8 01 00 00 00 48 8d 15 ?? ?? ?? ?? 48 8b 48 20 e8 ?? ?? ?? ?? 48 8b cf");
IntPtr getUIModulePtr = this.plugin.Interface.TargetModuleScanner.ScanText("E8 ?? ?? ?? ?? 48 83 7F ?? 00 48 8B F0");
IntPtr processChatBoxPtr = this.plugin.Interface.TargetModuleScanner.ScanText("40 53 56 57 48 83 EC 70 48 8B 05 ?? ?? ?? ?? 48 33 C4 48 89 44 24 ?? 48 8B 02");
if (getUIBasePtr == IntPtr.Zero || getUIModulePtr == IntPtr.Zero || processChatBoxPtr == IntPtr.Zero) {
PluginLog.Log($"getUIBasePtr: {getUIBasePtr.ToInt64():x}");
PluginLog.Log($"getUIModulePtr: {getUIModulePtr.ToInt64():x}");
PluginLog.Log($"processChatBoxPtr: {processChatBoxPtr.ToInt64():x}");
throw new ApplicationException("Got null pointers for game signature(s)");
}
this.GetUIBase = Marshal.GetDelegateForFunctionPointer<GetUIBaseDelegate>(getUIBasePtr);
this.GetUIModule = Marshal.GetDelegateForFunctionPointer<GetUIModuleDelegate>(getUIModulePtr);
this._ProcessChatBox = Marshal.GetDelegateForFunctionPointer<ProcessChatBoxDelegate>(processChatBoxPtr);
}
public void ProcessChatBox(string message) {
IntPtr uiBase = this.GetUIBase();
IntPtr uiModule = this.GetUIModule(Marshal.ReadIntPtr(this.plugin.Interface.TargetModuleScanner.Module.BaseAddress + 0x1ce80b8));
if (uiBase == IntPtr.Zero || uiModule == IntPtr.Zero) {
throw new ApplicationException("uiBase or uiModule was null");
}
IntPtr raptureModule = uiModule + 0xA4D00;
byte[] bytes = Encoding.UTF8.GetBytes(message);
IntPtr mem1 = Marshal.AllocHGlobal(400);
IntPtr mem2 = Marshal.AllocHGlobal(bytes.Length + 30);
Marshal.Copy(bytes, 0, mem2, bytes.Length);
Marshal.WriteByte(mem2 + bytes.Length, 0);
Marshal.WriteInt64(mem1, mem2.ToInt64());
Marshal.WriteInt64(mem1 + 8, 64);
Marshal.WriteInt64(mem1 + 8 + 8, bytes.Length + 1);
Marshal.WriteInt64(mem1 + 8 + 8 + 8, 0);
Marshal.WriteByte(uiModule + 675757, 1);
Marshal.WriteInt16(uiModule + 169921, 0);
this._ProcessChatBox(raptureModule, mem1, uiModule);
Marshal.WriteByte(uiModule + 675757, 0);
Marshal.FreeHGlobal(mem1);
Marshal.FreeHGlobal(mem2);
}
}
}

View File

@ -0,0 +1,116 @@
using Dalamud.Game.Internal;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Channels;
using System.Threading.Tasks;
namespace CCMM {
public class MacroHandler {
private readonly static Regex WAIT = new Regex(@"<wait\.(\d+(?:\.\d+)?)>", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private readonly CCMMPlugin plugin;
private readonly Channel<string> commands = Channel.CreateUnbounded<string>();
public ConcurrentDictionary<Guid, Macro> Running { get; } = new ConcurrentDictionary<Guid, Macro>();
private readonly ConcurrentDictionary<Guid, bool> cancelled = new ConcurrentDictionary<Guid, bool>();
private readonly ConcurrentDictionary<Guid, bool> paused = new ConcurrentDictionary<Guid, bool>();
public MacroHandler(CCMMPlugin plugin) {
this.plugin = plugin ?? throw new ArgumentNullException(nameof(plugin), "CCMMPlugin cannot be null");
}
private static string[] ExtractCommands(string macro) {
return macro.Split('\n')
.Where(line => !line.Trim().StartsWith("#"))
.ToArray();
}
public Guid SpawnMacro(Macro macro) {
string[] commands = ExtractCommands(macro.Contents);
Guid id = Guid.NewGuid();
if (commands.Length == 0) {
// pretend we spawned a task, but actually don't
return id;
}
this.Running.TryAdd(id, macro);
Task.Run(async () => {
int i = 0;
do {
if (this.cancelled.TryRemove(id, out bool cancel) && cancel) {
break;
}
if (this.paused.TryGetValue(id, out bool paused) && paused) {
await Task.Delay(TimeSpan.FromSeconds(1));
continue;
}
string command = commands[i];
TimeSpan? wait = this.ExtractWait(ref command);
if (command == "/loop") {
i = -1;
} else {
await this.commands.Writer.WriteAsync(command);
}
if (wait != null) {
await Task.Delay((TimeSpan)wait);
}
i += 1;
} while (i < commands.Length);
this.Running.TryRemove(id, out Macro _);
});
return id;
}
public bool IsRunning(Guid id) {
return this.Running.ContainsKey(id);
}
public void CancelMacro(Guid id) {
if (!this.IsRunning(id)) {
return;
}
this.cancelled.TryAdd(id, true);
}
public void PauseMacro(Guid id) {
this.paused.TryAdd(id, true);
}
public void ResumeMacro(Guid id) {
this.paused.TryRemove(id, out _);
}
public bool IsPaused(Guid id) {
this.paused.TryGetValue(id, out bool paused);
return paused;
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "delegate")]
public void OnFrameworkUpdate(Framework framework) {
if (!this.commands.Reader.TryRead(out string command)) {
return;
}
this.plugin.Functions.ProcessChatBox(command);
}
private TimeSpan? ExtractWait(ref string command) {
MatchCollection matches = WAIT.Matches(command);
if (matches.Count == 0) {
return null;
}
Match match = matches[matches.Count - 1];
string waitTime = match.Groups[1].Captures[0].Value;
if (double.TryParse(waitTime, out double seconds)) {
command = WAIT.Replace(command, "");
return TimeSpan.FromSeconds(seconds);
}
return null;
}
}
}

View File

@ -0,0 +1,227 @@
using Dalamud.Interface;
using ImGuiNET;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
namespace CCMM {
public class PluginUI {
private readonly CCMMPlugin plugin;
private INode dragged = null;
private Guid runningChoice = Guid.Empty;
private uint spawned = 0;
private bool _settingsVisible = false;
public bool SettingsVisible { get => this._settingsVisible; set => this._settingsVisible = value; }
public PluginUI(CCMMPlugin plugin) {
this.plugin = plugin ?? throw new ArgumentNullException(nameof(plugin), "CCMMPlugin cannot be null");
}
public void OpenSettings(object sender, EventArgs e) {
this.SettingsVisible = true;
}
public void Draw() {
if (this.SettingsVisible) {
this.DrawSettings();
}
}
private bool RemoveNode(List<INode> list, INode toRemove) {
if (list.Remove(toRemove)) {
return true;
}
foreach (INode node in list) {
if (node.Children.Count > 0 && this.RemoveNode(node.Children, toRemove)) {
return true;
}
}
return false;
}
private void DrawSettings() {
// unset the cancel choice if no longer running
if (this.runningChoice != Guid.Empty && !this.plugin.MacroHandler.IsRunning(this.runningChoice)) {
this.runningChoice = Guid.Empty;
}
if (ImGui.Begin(this.plugin.Name, ref this._settingsVisible)) {
ImGui.Columns(2);
if (IconButton(FontAwesomeIcon.Plus)) {
this.plugin.Config.Nodes.Add(new Macro("Untitled macro", ""));
this.plugin.Config.Save();
}
Tooltip("Add macro");
ImGui.SameLine();
if (IconButton(FontAwesomeIcon.FolderPlus)) {
this.plugin.Config.Nodes.Add(new Folder("Untitled folder"));
this.plugin.Config.Save();
}
Tooltip("Add folder");
List<INode> toRemove = new List<INode>();
foreach (INode node in this.plugin.Config.Nodes) {
toRemove.AddRange(this.DrawNode(node));
}
foreach (INode node in toRemove) {
this.RemoveNode(this.plugin.Config.Nodes, node);
}
if (toRemove.Count != 0) {
this.plugin.Config.Save();
}
ImGui.NextColumn();
ImGui.Text("Running macros");
ImGui.PushItemWidth(-1f);
if (ImGui.ListBoxHeader("##running-macros", this.plugin.MacroHandler.Running.Count, 5)) {
foreach (KeyValuePair<Guid, Macro> entry in this.plugin.MacroHandler.Running) {
if (ImGui.Selectable($"{entry.Value.Name}##{entry.Key}", this.runningChoice == entry.Key)) {
this.runningChoice = entry.Key;
}
}
ImGui.ListBoxFooter();
}
ImGui.PopItemWidth();
if (ImGui.Button("Cancel") && this.runningChoice != Guid.Empty) {
this.plugin.MacroHandler.CancelMacro(this.runningChoice);
}
ImGui.SameLine();
bool paused = this.runningChoice != Guid.Empty && this.plugin.MacroHandler.IsPaused(this.runningChoice);
if (ImGui.Button(paused ? "Resume" : "Pause") && this.runningChoice != Guid.Empty) {
if (paused) {
this.plugin.MacroHandler.ResumeMacro(this.runningChoice);
} else {
this.plugin.MacroHandler.PauseMacro(this.runningChoice);
}
}
ImGui.Columns(1);
ImGui.End();
}
}
private List<INode> DrawNode(INode node) {
List<INode> toRemove = new List<INode>();
ImGui.PushID($"{node.Id}");
bool open = ImGui.TreeNode($"{node.Id}", $"{node.Name}");
if (ImGui.BeginPopupContextItem()) {
string name = node.Name;
if (ImGui.InputText($"##{node.Id}-rename", ref name, (uint)this.plugin.Config.MaxLength, ImGuiInputTextFlags.AutoSelectAll)) {
node.Name = name;
this.plugin.Config.Save();
}
if (ImGui.Button("Delete")) {
toRemove.Add(node);
}
ImGui.SameLine();
if (ImGui.Button("Copy UUID")) {
ImGui.SetClipboardText($"{node.Id}");
}
if (node is Macro macro) {
ImGui.SameLine();
if (ImGui.Button("Run##context")) {
this.RunMacro(macro);
}
}
ImGui.EndPopup();
}
if (ImGui.BeginDragDropSource()) {
ImGui.Text(node.Name);
this.dragged = node;
ImGui.SetDragDropPayload("CCMM-GUID", IntPtr.Zero, 0);
ImGui.EndDragDropSource();
}
if (node is Folder dfolder && ImGui.BeginDragDropTarget()) {
ImGuiPayloadPtr payloadPtr = ImGui.AcceptDragDropPayload("CCMM-GUID");
bool nullPtr;
unsafe {
nullPtr = payloadPtr.NativePtr == null;
}
if (!nullPtr && payloadPtr.IsDelivery() && this.dragged != null) {
dfolder.Children.Add(this.dragged.Duplicate());
this.dragged.Id = Guid.NewGuid();
toRemove.Add(this.dragged);
this.dragged = null;
}
ImGui.EndDragDropTarget();
}
ImGui.PopID();
if (open) {
if (node is Macro macro) {
this.DrawMacro(macro);
} else if (node is Folder folder) {
this.DrawFolder(folder);
foreach (INode child in node.Children) {
toRemove.AddRange(this.DrawNode(child));
}
}
ImGui.TreePop();
}
return toRemove;
}
private void DrawMacro(Macro macro) {
string contents = macro.Contents;
ImGui.PushItemWidth(-1f);
if (ImGui.InputTextMultiline($"##{macro.Id}-editor", ref contents, (uint)this.plugin.Config.MaxLength, new Vector2(0, 250))) {
macro.Contents = contents;
this.plugin.Config.Save();
}
ImGui.PopItemWidth();
if (ImGui.Button("Run")) {
this.RunMacro(macro);
}
}
private void DrawFolder(Folder folder) {
}
private void RunMacro(Macro macro) {
this.plugin.MacroHandler.SpawnMacro(macro);
}
private static bool IconButton(FontAwesomeIcon icon) {
ImGui.PushFont(UiBuilder.IconFont);
bool ret = ImGui.Button(icon.ToIconString());
ImGui.PopFont();
return ret;
}
private static void Tooltip(string text) {
if (ImGui.IsItemHovered()) {
ImGui.BeginTooltip();
ImGui.TextUnformatted(text);
ImGui.EndTooltip();
}
}
}
}

View File

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

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.4.1" newVersion="4.0.4.1" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" targetFramework="net48" />
<package id="System.Threading.Channels" version="4.7.1" targetFramework="net48" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net48" />
</packages>

287
LICENCE Normal file
View File

@ -0,0 +1,287 @@
EUROPEAN UNION PUBLIC LICENCE v. 1.2
EUPL © the European Union 2007, 2016
This European Union Public Licence (the EUPL) applies to the Work (as defined
below) which is provided under the terms of this Licence. Any use of the Work,
other than as authorised under this Licence is prohibited (to the extent such
use is covered by a right of the copyright holder of the Work).
The Work is provided under the terms of this Licence when the Licensor (as
defined below) has placed the following notice immediately following the
copyright notice for the Work:
Licensed under the EUPL
or has expressed by any other means his willingness to license under the EUPL.
1. Definitions
In this Licence, the following terms have the following meaning:
- The Licence: this Licence.
- The Original Work: the work or software distributed or communicated by the
Licensor under this Licence, available as Source Code and also as Executable
Code as the case may be.
- Derivative Works: the works or software that could be created by the
Licensee, based upon the Original Work or modifications thereof. This Licence
does not define the extent of modification or dependence on the Original Work
required in order to classify a work as a Derivative Work; this extent is
determined by copyright law applicable in the country mentioned in Article 15.
- The Work: the Original Work or its Derivative Works.
- The Source Code: the human-readable form of the Work which is the most
convenient for people to study and modify.
- The Executable Code: any code which has generally been compiled and which is
meant to be interpreted by a computer as a program.
- The Licensor: the natural or legal person that distributes or communicates
the Work under the Licence.
- Contributor(s): any natural or legal person who modifies the Work under the
Licence, or otherwise contributes to the creation of a Derivative Work.
- The Licensee or You: any natural or legal person who makes any usage of
the Work under the terms of the Licence.
- Distribution or Communication: any act of selling, giving, lending,
renting, distributing, communicating, transmitting, or otherwise making
available, online or offline, copies of the Work or providing access to its
essential functionalities at the disposal of any other natural or legal
person.
2. Scope of the rights granted by the Licence
The Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
sublicensable licence to do the following, for the duration of copyright vested
in the Original Work:
- use the Work in any circumstance and for all usage,
- reproduce the Work,
- modify the Work, and make Derivative Works based upon the Work,
- communicate to the public, including the right to make available or display
the Work or copies thereof to the public and perform publicly, as the case may
be, the Work,
- distribute the Work or copies thereof,