draft generated help
This commit is contained in:
parent
bd30bc8fd5
commit
f83abab0a0
@ -379,6 +379,8 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
mc.iterate(0.02f);
|
mc.iterate(0.02f);
|
||||||
|
|
||||||
|
mcd.iterate(0.02f);
|
||||||
|
|
||||||
//std::this_thread::sleep_for( // time left to get to 60fps
|
//std::this_thread::sleep_for( // time left to get to 60fps
|
||||||
//std::chrono::duration<float, std::chrono::seconds::period>(0.0166f) // 60fps frame duration
|
//std::chrono::duration<float, std::chrono::seconds::period>(0.0166f) // 60fps frame duration
|
||||||
//- std::chrono::duration<float, std::chrono::seconds::period>(std::chrono::steady_clock::now() - new_time) // time used for rendering
|
//- std::chrono::duration<float, std::chrono::seconds::period>(std::chrono::steady_clock::now() - new_time) // time used for rendering
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
#include "./message_command_dispatcher.hpp"
|
#include "./message_command_dispatcher.hpp"
|
||||||
#include "nlohmann/detail/input/position_t.hpp"
|
|
||||||
#include "solanaceae/message3/registry_message_model.hpp"
|
|
||||||
|
|
||||||
#include <cwchar>
|
|
||||||
#include <solanaceae/util/config_model.hpp>
|
#include <solanaceae/util/config_model.hpp>
|
||||||
#include <solanaceae/message3/components.hpp>
|
#include <solanaceae/message3/components.hpp>
|
||||||
|
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
//MessageCommandDispatcher::Command::Command(Command&& other) :
|
//MessageCommandDispatcher::Command::Command(Command&& other) :
|
||||||
//m(std::move(other.m)),
|
//m(std::move(other.m)),
|
||||||
@ -44,7 +43,14 @@ MessageCommandDispatcher::MessageCommandDispatcher(
|
|||||||
MessageCommandDispatcher::~MessageCommandDispatcher(void) {
|
MessageCommandDispatcher::~MessageCommandDispatcher(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageCommandDispatcher::iterate(float time_delta) {
|
void MessageCommandDispatcher::iterate(float) {
|
||||||
|
if (!_message_queue.empty()) {
|
||||||
|
_rmm.sendText(
|
||||||
|
_message_queue.front().to,
|
||||||
|
_message_queue.front().message
|
||||||
|
);
|
||||||
|
_message_queue.pop_front();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string_view get_first_word(std::string_view text, std::string_view::size_type& out_next) {
|
static std::string_view get_first_word(std::string_view text, std::string_view::size_type& out_next) {
|
||||||
@ -101,10 +107,38 @@ void MessageCommandDispatcher::registerCommand(
|
|||||||
bool MessageCommandDispatcher::helpCommand(std::string_view params, Message3Handle m) {
|
bool MessageCommandDispatcher::helpCommand(std::string_view params, Message3Handle m) {
|
||||||
std::cout << "MCD: help got called '" << params << "'\n";
|
std::cout << "MCD: help got called '" << params << "'\n";
|
||||||
|
|
||||||
_rmm.sendText(
|
std::map<std::string, std::vector<decltype(_command_map.cbegin())>> module_command_list;
|
||||||
m.get<Message::Components::ContactFrom>().c,
|
for (auto it = _command_map.cbegin(); it != _command_map.cend(); it++) {
|
||||||
"I am still missing :), ping green for how it actually works."
|
if (true) { // have permission
|
||||||
);
|
module_command_list[it->second.m].push_back(it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto contact_from = m.get<Message::Components::ContactFrom>().c;
|
||||||
|
|
||||||
|
for (const auto& [module_name, command_list] : module_command_list) {
|
||||||
|
_message_queue.push_back({
|
||||||
|
contact_from,
|
||||||
|
"=== " + module_name + " ==="
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const auto& it : command_list) {
|
||||||
|
std::string help_line {" !"};
|
||||||
|
if (!it->second.m_prefix.empty()) {
|
||||||
|
help_line += it->second.m_prefix + " ";
|
||||||
|
}
|
||||||
|
|
||||||
|
help_line += it->second.command;
|
||||||
|
|
||||||
|
help_line += " - ";
|
||||||
|
help_line += it->second.help_text;
|
||||||
|
|
||||||
|
_message_queue.push_back({
|
||||||
|
contact_from,
|
||||||
|
help_line
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#include <solanaceae/message3/registry_message_model.hpp>
|
#include <solanaceae/message3/registry_message_model.hpp>
|
||||||
|
|
||||||
|
#include <deque>
|
||||||
|
|
||||||
// fwd
|
// fwd
|
||||||
struct ConfigModelI;
|
struct ConfigModelI;
|
||||||
|
|
||||||
@ -21,6 +23,12 @@ class MessageCommandDispatcher : public RegistryMessageModelEventI {
|
|||||||
};
|
};
|
||||||
std::unordered_map<std::string, Command> _command_map;
|
std::unordered_map<std::string, Command> _command_map;
|
||||||
|
|
||||||
|
struct QueuedMessage {
|
||||||
|
Contact3 to;
|
||||||
|
std::string message;
|
||||||
|
};
|
||||||
|
std::deque<QueuedMessage> _message_queue;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MessageCommandDispatcher(Contact3Registry& cr, RegistryMessageModel& rmm, ConfigModelI& conf);
|
MessageCommandDispatcher(Contact3Registry& cr, RegistryMessageModel& rmm, ConfigModelI& conf);
|
||||||
~MessageCommandDispatcher(void);
|
~MessageCommandDispatcher(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user