Add define parameters and support aliases and definitions in action files
This commit is contained in:
1 parent
fb8ef636bd
commit
0a6193f68e
12 files changed
+291
-63
No files matched your search
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "CommandBindings.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <cstddef>
|
||||
#include <filesystem>
|
||||
@@ -71,7 +73,7 @@ struct ActionProgram
|
||||
// Clicks optionally accept entry [t|b|s|n|w|e] (or full face names), with
|
||||
// the face immediately after entry. Existing shift and left-click destroy flags
|
||||
// may appear before or after entry; omitted entry retains block-click behavior.
|
||||
ActionProgram LoadActionFile(const std::filesystem::path &path);
|
||||
ActionProgram LoadActionFile(const std::filesystem::path &path, CommandBindings bindings = {});
|
||||
|
||||
// Parse one console game instruction using the .act grammar, without file I/O.
|
||||
// Blank/comment lines return nullopt. Wait/import require `run file.act` instead.
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
namespace Bilicraft
|
||||
{
|
||||
class CommandBindings
|
||||
{
|
||||
public:
|
||||
// Process one trimmed, comment-free line. Declarations return an empty string.
|
||||
// A console caller can supply display to enable list and lookup commands.
|
||||
std::string Expand(std::string_view line, std::size_t maxLength, std::string *display = nullptr);
|
||||
|
||||
private:
|
||||
using Bindings = std::map<std::string, std::string, std::less<>>;
|
||||
Bindings aliases;
|
||||
Bindings definitions;
|
||||
};
|
||||
} // namespace Bilicraft
|
||||
@@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
#include "ActionFile.h"
|
||||
#include <map>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
@@ -19,8 +18,10 @@ class ConsoleCommandParser
|
||||
public:
|
||||
ConsoleCommand Parse(std::string_view line);
|
||||
|
||||
const CommandBindings &GetBindings() const { return bindings; }
|
||||
|
||||
private:
|
||||
std::map<std::string, std::string, std::less<>> aliases;
|
||||
CommandBindings bindings;
|
||||
};
|
||||
std::string ConsoleHelp();
|
||||
} // namespace Bilicraft
|
||||
Reference in new issue
Block a user