commit d2e5ffbfe49d148c0dc1887e6fb046ad863de51d Author: Anna Clemens Date: Wed Aug 19 02:55:02 2020 -0400 chore: initial commit diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..03b3248 --- /dev/null +++ b/.editorconfig @@ -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 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..99b6890 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +* text eol=lf +*.wav binary diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1ee5385 --- /dev/null +++ b/.gitignore @@ -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 diff --git a/CCMM.sln b/CCMM.sln new file mode 100644 index 0000000..9e53a1f --- /dev/null +++ b/CCMM.sln @@ -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 diff --git a/Custom Commands and Macro Macros/CCMMPlugin.cs b/Custom Commands and Macro Macros/CCMMPlugin.cs new file mode 100644 index 0000000..9dfc01f --- /dev/null +++ b/Custom Commands and Macro Macros/CCMMPlugin.cs @@ -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 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); + } + } +} diff --git a/Custom Commands and Macro Macros/Commands.cs b/Custom Commands and Macro Macros/Commands.cs new file mode 100644 index 0000000..87e25f1 --- /dev/null +++ b/Custom Commands and Macro Macros/Commands.cs @@ -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 COMMANDS = new Dictionary { + ["/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 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); + } + } +} diff --git a/Custom Commands and Macro Macros/Configuration.cs b/Custom Commands and Macro Macros/Configuration.cs new file mode 100644 index 0000000..0a0ac08 --- /dev/null +++ b/Custom Commands and Macro Macros/Configuration.cs @@ -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 Nodes { get; private set; } = new List(); + + 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(configText); + } + return new Configuration(); + } + + private static IEnumerable Traverse(T item, Func> childSelector) { + var stack = new Stack(); + 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 Children { get; } + + INode Duplicate(); + } + + public class Folder : INode { + public Guid Id { get; set; } + public string Name { get; set; } + public List Children { get; private set; } = new List(); + + public Folder(string name, List children = null) { + this.Id = Guid.NewGuid(); + this.Name = name; + if (children != null) { + this.Children = children; + } + } + + internal Folder(Guid id, string name, List 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 Children => new List(); + + 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 list = new List(); + foreach (JToken token in jsonArray) { + JObject jsonObject = (JObject)token; + INode node; + if (jsonObject.ContainsKey("Contents")) { + node = new Macro( + jsonObject["Id"].ToObject(), + jsonObject["Name"].ToObject(), + jsonObject["Contents"].ToObject() + ); + } else { + node = new Folder( + jsonObject["Id"].ToObject(), + jsonObject["Name"].ToObject(), + (List)this.ReadJson(jsonObject["Children"].CreateReader(), typeof(List), null, serializer) + ); + } + list.Add(node); + } + return list; + } + } +} diff --git a/Custom Commands and Macro Macros/Custom Commands and Macro Macros.csproj b/Custom Commands and Macro Macros/Custom Commands and Macro Macros.csproj new file mode 100644 index 0000000..db00058 --- /dev/null +++ b/Custom Commands and Macro Macros/Custom Commands and Macro Macros.csproj @@ -0,0 +1,83 @@ + + + + + Debug + AnyCPU + {09B0F618-89E6-4CEE-9835-A4686DE9B716} + Library + Properties + CCMM + Custom Commands and Macro Macros + v4.8 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + true + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + true + + + + $(AppData)\XIVLauncher\addon\Hooks\Dalamud.dll + + + $(AppData)\XIVLauncher\addon\Hooks\ImGui.NET.dll + + + $(AppData)\XIVLauncher\addon\Hooks\ImGuiScene.dll + + + $(AppData)\XIVLauncher\addon\Hooks\Newtonsoft.Json.dll + + + + + + False + $(AppData)\XIVLauncher\addon\Hooks\System.Runtime.CompilerServices.Unsafe.dll + + + ..\packages\System.Threading.Channels.4.7.1\lib\net461\System.Threading.Channels.dll + + + False + $(AppData)\XIVLauncher\addon\Hooks\System.Threading.Tasks.Extensions.dll + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Custom Commands and Macro Macros/GameFunctions.cs b/Custom Commands and Macro Macros/GameFunctions.cs new file mode 100644 index 0000000..2f37e9a --- /dev/null +++ b/Custom Commands and Macro Macros/GameFunctions.cs @@ -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(getUIBasePtr); + this.GetUIModule = Marshal.GetDelegateForFunctionPointer(getUIModulePtr); + this._ProcessChatBox = Marshal.GetDelegateForFunctionPointer(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); + } + } +} diff --git a/Custom Commands and Macro Macros/MacroHandler.cs b/Custom Commands and Macro Macros/MacroHandler.cs new file mode 100644 index 0000000..8b340f0 --- /dev/null +++ b/Custom Commands and Macro Macros/MacroHandler.cs @@ -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(@"", RegexOptions.Compiled | RegexOptions.IgnoreCase); + + private readonly CCMMPlugin plugin; + private readonly Channel commands = Channel.CreateUnbounded(); + public ConcurrentDictionary Running { get; } = new ConcurrentDictionary(); + private readonly ConcurrentDictionary cancelled = new ConcurrentDictionary(); + private readonly ConcurrentDictionary paused = new ConcurrentDictionary(); + + 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; + } + } +} diff --git a/Custom Commands and Macro Macros/PluginUI.cs b/Custom Commands and Macro Macros/PluginUI.cs new file mode 100644 index 0000000..5ddffc1 --- /dev/null +++ b/Custom Commands and Macro Macros/PluginUI.cs @@ -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 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 toRemove = new List(); + 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 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 DrawNode(INode node) { + List toRemove = new List(); + 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(); + } + } + } +} diff --git a/Custom Commands and Macro Macros/Properties/AssemblyInfo.cs b/Custom Commands and Macro Macros/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..2495c37 --- /dev/null +++ b/Custom Commands and Macro Macros/Properties/AssemblyInfo.cs @@ -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")] diff --git a/Custom Commands and Macro Macros/app.config b/Custom Commands and Macro Macros/app.config new file mode 100644 index 0000000..58b89cf --- /dev/null +++ b/Custom Commands and Macro Macros/app.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Custom Commands and Macro Macros/packages.config b/Custom Commands and Macro Macros/packages.config new file mode 100644 index 0000000..9239c90 --- /dev/null +++ b/Custom Commands and Macro Macros/packages.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/LICENCE b/LICENCE new file mode 100644 index 0000000..4153cd3 --- /dev/null +++ b/LICENCE @@ -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, +- lend and rent the Work or copies thereof, +- sublicense rights in the Work or copies thereof. + +Those rights can be exercised on any media, supports and formats, whether now +known or later invented, as far as the applicable law permits so. + +In the countries where moral rights apply, the Licensor waives his right to +exercise his moral right to the extent allowed by law in order to make effective +the licence of the economic rights here above listed. + +The Licensor grants to the Licensee royalty-free, non-exclusive usage rights to +any patents held by the Licensor, to the extent necessary to make use of the +rights granted on the Work under this Licence. + +3. Communication of the Source Code + +The Licensor may provide the Work either in its Source Code form, or as +Executable Code. If the Work is provided as Executable Code, the Licensor +provides in addition a machine-readable copy of the Source Code of the Work +along with each copy of the Work that the Licensor distributes or indicates, in +a notice following the copyright notice attached to the Work, a repository where +the Source Code is easily and freely accessible for as long as the Licensor +continues to distribute or communicate the Work. + +4. Limitations on copyright + +Nothing in this Licence is intended to deprive the Licensee of the benefits from +any exception or limitation to the exclusive rights of the rights owners in the +Work, of the exhaustion of those rights or of other applicable limitations +thereto. + +5. Obligations of the Licensee + +The grant of the rights mentioned above is subject to some restrictions and +obligations imposed on the Licensee. Those obligations are the following: + +Attribution right: The Licensee shall keep intact all copyright, patent or +trademarks notices and all notices that refer to the Licence and to the +disclaimer of warranties. The Licensee must include a copy of such notices and a +copy of the Licence with every copy of the Work he/she distributes or +communicates. The Licensee must cause any Derivative Work to carry prominent +notices stating that the Work has been modified and the date of modification. + +Copyleft clause: If the Licensee distributes or communicates copies of the +Original Works or Derivative Works, this Distribution or Communication will be +done under the terms of this Licence or of a later version of this Licence +unless the Original Work is expressly distributed only under this version of the +Licence — for example by communicating ‘EUPL v. 1.2 only’. The Licensee +(becoming Licensor) cannot offer or impose any additional terms or conditions on +the Work or Derivative Work that alter or restrict the terms of the Licence. + +Compatibility clause: If the Licensee Distributes or Communicates Derivative +Works or copies thereof based upon both the Work and another work licensed under +a Compatible Licence, this Distribution or Communication can be done under the +terms of this Compatible Licence. For the sake of this clause, ‘Compatible +Licence’ refers to the licences listed in the appendix attached to this Licence. +Should the Licensee's obligations under the Compatible Licence conflict with +his/her obligations under this Licence, the obligations of the Compatible +Licence shall prevail. + +Provision of Source Code: When distributing or communicating copies of the Work, +the Licensee will provide a machine-readable copy of the Source Code or indicate +a repository where this Source will be easily and freely available for as long +as the Licensee continues to distribute or communicate the Work. + +Legal Protection: This Licence does not grant permission to use the trade names, +trademarks, service marks, or names of the Licensor, except as required for +reasonable and customary use in describing the origin of the Work and +reproducing the content of the copyright notice. + +6. Chain of Authorship + +The original Licensor warrants that the copyright in the Original Work granted +hereunder is owned by him/her or licensed to him/her and that he/she has the +power and authority to grant the Licence. + +Each Contributor warrants that the copyright in the modifications he/she brings +to the Work are owned by him/her or licensed to him/her and that he/she has the +power and authority to grant the Licence. + +Each time You accept the Licence, the original Licensor and subsequent +Contributors grant You a licence to their contributions to the Work, under the +terms of this Licence. + +7. Disclaimer of Warranty + +The Work is a work in progress, which is continuously improved by numerous +Contributors. It is not a finished work and may therefore contain defects or +‘bugs’ inherent to this type of development. + +For the above reason, the Work is provided under the Licence on an ‘as is’ basis +and without warranties of any kind concerning the Work, including without +limitation merchantability, fitness for a particular purpose, absence of defects +or errors, accuracy, non-infringement of intellectual property rights other than +copyright as stated in Article 6 of this Licence. + +This disclaimer of warranty is an essential part of the Licence and a condition +for the grant of any rights to the Work. + +8. Disclaimer of Liability + +Except in the cases of wilful misconduct or damages directly caused to natural +persons, the Licensor will in no event be liable for any direct or indirect, +material or moral, damages of any kind, arising out of the Licence or of the use +of the Work, including without limitation, damages for loss of goodwill, work +stoppage, computer failure or malfunction, loss of data or any commercial +damage, even if the Licensor has been advised of the possibility of such damage. +However, the Licensor will be liable under statutory product liability laws as +far such laws apply to the Work. + +9. Additional agreements + +While distributing the Work, You may choose to conclude an additional agreement, +defining obligations or services consistent with this Licence. However, if +accepting obligations, You may act only on your own behalf and on your sole +responsibility, not on behalf of the original Licensor or any other Contributor, +and only if You agree to indemnify, defend, and hold each Contributor harmless +for any liability incurred by, or claims asserted against such Contributor by +the fact You have accepted any warranty or additional liability. + +10. Acceptance of the Licence + +The provisions of this Licence can be accepted by clicking on an icon ‘I agree’ +placed under the bottom of a window displaying the text of this Licence or by +affirming consent in any other similar way, in accordance with the rules of +applicable law. Clicking on that icon indicates your clear and irrevocable +acceptance of this Licence and all of its terms and conditions. + +Similarly, you irrevocably accept this Licence and all of its terms and +conditions by exercising any rights granted to You by Article 2 of this Licence, +such as the use of the Work, the creation by You of a Derivative Work or the +Distribution or Communication by You of the Work or copies thereof. + +11. Information to the public + +In case of any Distribution or Communication of the Work by means of electronic +communication by You (for example, by offering to download the Work from a +remote location) the distribution channel or media (for example, a website) must +at least provide to the public the information requested by the applicable law +regarding the Licensor, the Licence and the way it may be accessible, concluded, +stored and reproduced by the Licensee. + +12. Termination of the Licence + +The Licence and the rights granted hereunder will terminate automatically upon +any breach by the Licensee of the terms of the Licence. + +Such a termination will not terminate the licences of any person who has +received the Work from the Licensee under the Licence, provided such persons +remain in full compliance with the Licence. + +13. Miscellaneous + +Without prejudice of Article 9 above, the Licence represents the complete +agreement between the Parties as to the Work. + +If any provision of the Licence is invalid or unenforceable under applicable +law, this will not affect the validity or enforceability of the Licence as a +whole. Such provision will be construed or reformed so as necessary to make it +valid and enforceable. + +The European Commission may publish other linguistic versions or new versions of +this Licence or updated versions of the Appendix, so far this is required and +reasonable, without reducing the scope of the rights granted by the Licence. New +versions of the Licence will be published with a unique version number. + +All linguistic versions of this Licence, approved by the European Commission, +have identical value. Parties can take advantage of the linguistic version of +their choice. + +14. Jurisdiction + +Without prejudice to specific agreement between parties, + +- any litigation resulting from the interpretation of this License, arising + between the European Union institutions, bodies, offices or agencies, as a + Licensor, and any Licensee, will be subject to the jurisdiction of the Court + of Justice of the European Union, as laid down in article 272 of the Treaty on + the Functioning of the European Union, + +- any litigation arising between other parties and resulting from the + interpretation of this License, will be subject to the exclusive jurisdiction + of the competent court where the Licensor resides or conducts its primary + business. + +15. Applicable Law + +Without prejudice to specific agreement between parties, + +- this Licence shall be governed by the law of the European Union Member State + where the Licensor has his seat, resides or has his registered office, + +- this licence shall be governed by Belgian law if the Licensor has no seat, + residence or registered office inside a European Union Member State. + +Appendix + +‘Compatible Licences’ according to Article 5 EUPL are: + +- GNU General Public License (GPL) v. 2, v. 3 +- GNU Affero General Public License (AGPL) v. 3 +- Open Software License (OSL) v. 2.1, v. 3.0 +- Eclipse Public License (EPL) v. 1.0 +- CeCILL v. 2.0, v. 2.1 +- Mozilla Public Licence (MPL) v. 2 +- GNU Lesser General Public Licence (LGPL) v. 2.1, v. 3 +- Creative Commons Attribution-ShareAlike v. 3.0 Unported (CC BY-SA 3.0) for + works other than software +- European Union Public Licence (EUPL) v. 1.1, v. 1.2 +- Québec Free and Open-Source Licence — Reciprocity (LiLiQ-R) or Strong + Reciprocity (LiLiQ-R+). + +The European Commission may update this Appendix to later versions of the above +licences without producing a new version of the EUPL, as long as they provide +the rights granted in Article 2 of this Licence and protect the covered Source +Code from exclusive appropriation. + +All other changes or additions to this Appendix require the production of a new +EUPL version. diff --git a/README.md b/README.md new file mode 100644 index 0000000..c778009 --- /dev/null +++ b/README.md @@ -0,0 +1,56 @@ +# Custom Commands and Macro Macros + +**This plugin is still under heavy development and is not +stable. Proceed with caution.** + +## Description + +This command allows you to create custom commands (not yet +implemented) and unrestricted macros. + +**Custom commands** are commands that run a specific macro. For +example, you could bind `/h` to `/tp Estate Hall (Free Company)`, or +even multiple commands in sequence. In order to do this, you need... + +**Macro macros** are like normal macros but different. Unlike normal +macros, you can't assign them to hotbar buttons (yet?), but you can +execute them using commands (and custom commands), run multiple at the +same time, pause them, make them loop, use `` with fractional +seconds, and, of course, make them as long as you please (the *macro* +part of macro macros). + +Lastly, you can also organise macros into folders (and nest folders) +for easier access. + +## Commands + +- `/ccmm` - opens the main interface +- `/mmacro ` - executes the macro with the given UUID +- `/mmcancel ` - either cancels all currently-running macros + or cancels the first instance of the macro represented by the given + UUID + +## Special macro properties + +### Looping + +Macro macros can loop by using the `/loop` command. Whenever this +command is encountered in a macro, it will start the macro over from +the beginning. + +### Pausing + +In the main interface, there is a list of currently-running macros. If +you click on one and click "Pause" below, it will pause the +macro. Clicking "Resume" after will resume it from where it left off. + +### Parallel macros + +You can run more than one macro macro at the same time. This is an +inherent feature and you don't have to do anything to enable it. Just +run two or more macros, and they'll run in parallel. + +### Fractional `` + +When using `` in a macro, you can use decimal points, like +``.