update imgui and new versioned plugin api

This commit is contained in:
Green Sky 2024-01-18 18:35:11 +01:00
parent 1b6eaffeae
commit 15aa6cbede
No known key found for this signature in database
13 changed files with 85 additions and 174 deletions

@ -1 +1 @@
Subproject commit 158860e1b0f68ac95809280d9608998ce4eb2f6c
Subproject commit d9ee8f9dc48b5c178709de4d80de4093cde79f4c

@ -1 +1 @@
Subproject commit a488a255ff152a0b780b2cfaaa718838379663ab
Subproject commit 998794a6dd8faaa991a962d562f61ead7cd0b96b

@ -1 +1 @@
Subproject commit 5c3784e7ce33f86fa776a34804c508e2ff0555e7
Subproject commit 89ace56ade4bdfc36074dd5a595d26e304dde58d

@ -1 +1 @@
Subproject commit 60fc0d34eba30989ff634a797516d11aeb81e327
Subproject commit d3cc992d3e9eb2bb14bbc094c04e5e36eb662bed

@ -1 +1 @@
Subproject commit b50269062172b013d21fcc38b3693d09f91a2154
Subproject commit 9c54a508105d8bd69239f746f262f178edf8bc89

@ -1 +1 @@
Subproject commit ce760a800c6765009c4f49211b0a61c71756bfc0
Subproject commit b2a3cb7052041bea2d4793b8446fb2a00411773a

@ -1 +1 @@
Subproject commit 3df91258770ddaf12e8b4c6116890422d77438c1
Subproject commit fa4298d790b2a2adf19435239b96664cc40a09a8

@ -1 +1 @@
Subproject commit cd0506c955174552402348864b9e67802c4fe3ba
Subproject commit df2e1d6d42f3adfb71c14ae2f4ffb5a09fd81f97

@ -1 +1 @@
Subproject commit fa0a09df8743a502df69cddebf28f31790db3f06
Subproject commit db57a7c5e9181d771e83db5ed0d9010fba512881

View File

@ -7,18 +7,17 @@
#include <memory>
#include <iostream>
#define RESOLVE_INSTANCE(x) static_cast<x*>(solana_api->resolveInstance(#x))
#define PROVIDE_INSTANCE(x, p, v) solana_api->provideInstance(#x, p, static_cast<x*>(v))
static std::unique_ptr<NGCEXTEventProvider> g_ngcextep = nullptr;
// TODO: make sep plug
static std::unique_ptr<NGCFT1> g_ngcft1 = nullptr;
static std::unique_ptr<SHA1_NGCFT1> g_sha1_ngcft1 = nullptr;
constexpr const char* plugin_name = "NGCEXT";
extern "C" {
SOLANA_PLUGIN_EXPORT const char* solana_plugin_get_name(void) {
return "NGCEXT";
return plugin_name;
}
SOLANA_PLUGIN_EXPORT uint32_t solana_plugin_get_version(void) {
@ -26,70 +25,42 @@ SOLANA_PLUGIN_EXPORT uint32_t solana_plugin_get_version(void) {
}
SOLANA_PLUGIN_EXPORT uint32_t solana_plugin_start(struct SolanaAPI* solana_api) {
std::cout << "PLUGIN NGCEXT START()\n";
std::cout << "PLUGIN " << plugin_name << " START()\n";
if (solana_api == nullptr) {
return 1;
}
ToxI* tox_i = nullptr;
ToxEventProviderI* tox_event_provider_i = nullptr;
Contact3Registry* cr = nullptr;
RegistryMessageModel* rmm = nullptr;
ToxContactModel2* tcm = nullptr;
try {
auto* tox_i = PLUG_RESOLVE_INSTANCE(ToxI);
auto* tox_event_provider_i = PLUG_RESOLVE_INSTANCE(ToxEventProviderI);
auto* cr = PLUG_RESOLVE_INSTANCE_VERSIONED(Contact3Registry, "1");
auto* rmm = PLUG_RESOLVE_INSTANCE(RegistryMessageModel);
auto* tcm = PLUG_RESOLVE_INSTANCE(ToxContactModel2);
{ // make sure required types are loaded
tox_i = RESOLVE_INSTANCE(ToxI);
tox_event_provider_i = RESOLVE_INSTANCE(ToxEventProviderI);
cr = RESOLVE_INSTANCE(Contact3Registry);
rmm = RESOLVE_INSTANCE(RegistryMessageModel);
tcm = RESOLVE_INSTANCE(ToxContactModel2);
// static store, could be anywhere tho
// construct with fetched dependencies
g_ngcextep = std::make_unique<NGCEXTEventProvider>(*tox_event_provider_i);
g_ngcft1 = std::make_unique<NGCFT1>(*tox_i, *tox_event_provider_i, *g_ngcextep.get());
g_sha1_ngcft1 = std::make_unique<SHA1_NGCFT1>(*cr, *rmm, *g_ngcft1.get(), *tcm);
if (tox_i == nullptr) {
std::cerr << "PLUGIN NGCEXT missing ToxI\n";
return 2;
}
// register types
PLUG_PROVIDE_INSTANCE(NGCEXTEventProviderI, plugin_name, g_ngcextep.get());
if (tox_event_provider_i == nullptr) {
std::cerr << "PLUGIN NGCEXT missing ToxEventProviderI\n";
return 2;
}
PLUG_PROVIDE_INSTANCE(NGCFT1EventProviderI, plugin_name, g_ngcft1.get());
PLUG_PROVIDE_INSTANCE(NGCFT1, plugin_name, g_ngcft1.get());
if (cr == nullptr) {
std::cerr << "PLUGIN NGCEXT missing Contact3Registry\n";
return 2;
}
if (rmm == nullptr) {
std::cerr << "PLUGIN NGCEXT missing RegistryMessageModel\n";
return 2;
}
if (tcm == nullptr) {
std::cerr << "PLUGIN NGCEXT missing ToxContactModel2\n";
return 2;
}
PLUG_PROVIDE_INSTANCE(SHA1_NGCFT1, plugin_name, g_sha1_ngcft1.get());
} catch (const ResolveException& e) {
std::cerr << "PLUGIN " << plugin_name << " " << e.what << "\n";
return 2;
}
// static store, could be anywhere tho
// construct with fetched dependencies
g_ngcextep = std::make_unique<NGCEXTEventProvider>(*tox_event_provider_i);
g_ngcft1 = std::make_unique<NGCFT1>(*tox_i, *tox_event_provider_i, *g_ngcextep.get());
g_sha1_ngcft1 = std::make_unique<SHA1_NGCFT1>(*cr, *rmm, *g_ngcft1.get(), *tcm);
// register types
PROVIDE_INSTANCE(NGCEXTEventProviderI, "NGCEXT", g_ngcextep.get());
PROVIDE_INSTANCE(NGCFT1EventProviderI, "NGCEXT", g_ngcft1.get());
PROVIDE_INSTANCE(NGCFT1, "NGCEXT", g_ngcft1.get());
PROVIDE_INSTANCE(SHA1_NGCFT1, "NGCEXT", g_sha1_ngcft1.get());
return 0;
}
SOLANA_PLUGIN_EXPORT void solana_plugin_stop(void) {
std::cout << "PLUGIN NGCEXT STOP()\n";
std::cout << "PLUGIN " << plugin_name << " STOP()\n";
g_sha1_ngcft1.reset();
g_ngcft1.reset();

View File

@ -7,15 +7,14 @@
#include <limits>
#include <iostream>
#define RESOLVE_INSTANCE(x) static_cast<x*>(solana_api->resolveInstance(#x))
#define PROVIDE_INSTANCE(x, p, v) solana_api->provideInstance(#x, p, static_cast<x*>(v))
static std::unique_ptr<TransferAutoAccept> g_taa = nullptr;
constexpr const char* plugin_name = "TransferAutoAccept";
extern "C" {
SOLANA_PLUGIN_EXPORT const char* solana_plugin_get_name(void) {
return "TransferAutoAccept";
return plugin_name;
}
SOLANA_PLUGIN_EXPORT uint32_t solana_plugin_get_version(void) {
@ -23,49 +22,38 @@ SOLANA_PLUGIN_EXPORT uint32_t solana_plugin_get_version(void) {
}
SOLANA_PLUGIN_EXPORT uint32_t solana_plugin_start(struct SolanaAPI* solana_api) {
std::cout << "PLUGIN TAA START()\n";
std::cout << "PLUGIN " << plugin_name << " START()\n";
if (solana_api == nullptr) {
return 1;
}
RegistryMessageModel* rmm = nullptr;
ConfigModelI* conf = nullptr;
try {
auto* rmm = PLUG_RESOLVE_INSTANCE(RegistryMessageModel);
auto* conf = PLUG_RESOLVE_INSTANCE(ConfigModelI);
{ // make sure required types are loaded
rmm = RESOLVE_INSTANCE(RegistryMessageModel);
conf = RESOLVE_INSTANCE(ConfigModelI);
// static store, could be anywhere tho
// construct with fetched dependencies
g_taa = std::make_unique<TransferAutoAccept>(*rmm, *conf);
if (rmm == nullptr) {
std::cerr << "PLUGIN TAA missing RegistryMessageModel\n";
return 2;
}
if (conf == nullptr) {
std::cerr << "PLUGIN TAA missing ConfigModelI\n";
return 2;
}
// register types
PLUG_PROVIDE_INSTANCE(TransferAutoAccept, plugin_name, g_taa.get());
} catch (const ResolveException& e) {
std::cerr << "PLUGIN " << plugin_name << " " << e.what << "\n";
return 2;
}
// static store, could be anywhere tho
// construct with fetched dependencies
g_taa = std::make_unique<TransferAutoAccept>(*rmm, *conf);
// register types
PROVIDE_INSTANCE(TransferAutoAccept, "TransferAutoAccept", g_taa.get());
return 0;
}
SOLANA_PLUGIN_EXPORT void solana_plugin_stop(void) {
std::cout << "PLUGIN TAA STOP()\n";
std::cout << "PLUGIN " << plugin_name << " STOP()\n";
g_taa.reset();
}
SOLANA_PLUGIN_EXPORT float solana_plugin_tick(float delta) {
(void)delta;
//std::cout << "PLUGIN TAA TICK()\n";
g_taa->iterate();
return std::numeric_limits<float>::max();

View File

@ -6,18 +6,14 @@
#include <limits>
#include <iostream>
// fwd
class RegMessageModel;
#define RESOLVE_INSTANCE(x) static_cast<x*>(solana_api->resolveInstance(#x))
#define PROVIDE_INSTANCE(x, p, v) solana_api->provideInstance(#x, p, static_cast<x*>(v))
static std::unique_ptr<ZoxNGCEventProvider> g_zngc = nullptr;
constexpr const char* plugin_name = "ZoxNGC";
extern "C" {
SOLANA_PLUGIN_EXPORT const char* solana_plugin_get_name(void) {
return "ZoxNGC";
return plugin_name;
}
SOLANA_PLUGIN_EXPORT uint32_t solana_plugin_get_version(void) {
@ -25,42 +21,37 @@ SOLANA_PLUGIN_EXPORT uint32_t solana_plugin_get_version(void) {
}
SOLANA_PLUGIN_EXPORT uint32_t solana_plugin_start(struct SolanaAPI* solana_api) {
std::cout << "PLUGIN ZNGC START()\n";
std::cout << "PLUGIN " << plugin_name << " START()\n";
if (solana_api == nullptr) {
return 1;
}
ToxEventProviderI* tox_event_provider_i = nullptr;
try {
auto* tox_event_provider_i = PLUG_RESOLVE_INSTANCE(ToxEventProviderI);
{ // make sure required types are loaded
tox_event_provider_i = RESOLVE_INSTANCE(ToxEventProviderI);
// static store, could be anywhere tho
// construct with fetched dependencies
g_zngc = std::make_unique<ZoxNGCEventProvider>(*tox_event_provider_i);
if (tox_event_provider_i == nullptr) {
std::cerr << "PLUGIN ZNGC missing ToxEventProviderI\n";
return 2;
}
// register types
PLUG_PROVIDE_INSTANCE(ZoxNGCEventProviderI, plugin_name, g_zngc.get());
} catch (const ResolveException& e) {
std::cerr << "PLUGIN " << plugin_name << " " << e.what << "\n";
return 2;
}
// static store, could be anywhere tho
// construct with fetched dependencies
g_zngc = std::make_unique<ZoxNGCEventProvider>(*tox_event_provider_i);
// register types
PROVIDE_INSTANCE(ZoxNGCEventProviderI, "ZoxNGC", g_zngc.get());
return 0;
}
SOLANA_PLUGIN_EXPORT void solana_plugin_stop(void) {
std::cout << "PLUGIN ZNGC STOP()\n";
std::cout << "PLUGIN " << plugin_name << " STOP()\n";
g_zngc.reset();
}
SOLANA_PLUGIN_EXPORT float solana_plugin_tick(float delta) {
(void)delta;
//std::cout << "PLUGIN ZNGC TICK()\n";
return std::numeric_limits<float>::max();
}

View File

@ -2,23 +2,19 @@
#include <solanaceae/zox/ngc_hs.hpp>
#include <solanaceae/toxcore/tox_interface.hpp>
#include <solanaceae/tox_contacts/tox_contact_model2.hpp>
#include <memory>
#include <iostream>
// fwd
struct ContactModelI;
class RegistryMessageModel;
#define RESOLVE_INSTANCE(x) static_cast<x*>(solana_api->resolveInstance(#x))
#define PROVIDE_INSTANCE(x, p, v) solana_api->provideInstance(#x, p, static_cast<x*>(v))
static std::unique_ptr<ZoxNGCHistorySync> g_zngchs = nullptr;
constexpr const char* plugin_name = "ZoxNGCHistorySync";
extern "C" {
SOLANA_PLUGIN_EXPORT const char* solana_plugin_get_name(void) {
return "ZoxNGCHistorySync";
return plugin_name;
}
SOLANA_PLUGIN_EXPORT uint32_t solana_plugin_get_version(void) {
@ -26,76 +22,41 @@ SOLANA_PLUGIN_EXPORT uint32_t solana_plugin_get_version(void) {
}
SOLANA_PLUGIN_EXPORT uint32_t solana_plugin_start(struct SolanaAPI* solana_api) {
std::cout << "PLUGIN ZNGCHS START()\n";
std::cout << "PLUGIN " << plugin_name << " START()\n";
if (solana_api == nullptr) {
return 1;
}
ToxI* tox_i = nullptr;
ToxEventProviderI* tox_event_provider_i = nullptr;
ZoxNGCEventProviderI* zox_ngc_event_provider_i = nullptr;
Contact3Registry* cr = nullptr;
ToxContactModel2* tcm = nullptr;
RegistryMessageModel* rmm = nullptr;
try {
auto* tox_i = PLUG_RESOLVE_INSTANCE(ToxI);
auto* tox_event_provider_i = PLUG_RESOLVE_INSTANCE(ToxEventProviderI);
auto* zox_ngc_event_provider_i = PLUG_RESOLVE_INSTANCE(ZoxNGCEventProviderI);
auto* cr = PLUG_RESOLVE_INSTANCE_VERSIONED(Contact3Registry, "1");
auto* tcm = PLUG_RESOLVE_INSTANCE(ToxContactModel2);
auto* rmm = PLUG_RESOLVE_INSTANCE(RegistryMessageModel);
{ // make sure required types are loaded
tox_i = RESOLVE_INSTANCE(ToxI);
tox_event_provider_i = RESOLVE_INSTANCE(ToxEventProviderI);
zox_ngc_event_provider_i = RESOLVE_INSTANCE(ZoxNGCEventProviderI);
cr = RESOLVE_INSTANCE(Contact3Registry);
tcm = RESOLVE_INSTANCE(ToxContactModel2);
rmm = RESOLVE_INSTANCE(RegistryMessageModel);
// static store, could be anywhere tho
// construct with fetched dependencies
g_zngchs = std::make_unique<ZoxNGCHistorySync>(*tox_event_provider_i, *zox_ngc_event_provider_i, *tox_i, *cr, *tcm, *rmm);
if (tox_i == nullptr) {
std::cerr << "PLUGIN ZNGCHS missing ToxI\n";
return 2;
}
if (tox_event_provider_i == nullptr) {
std::cerr << "PLUGIN ZNGCHS missing ToxEventProviderI\n";
return 2;
}
if (zox_ngc_event_provider_i == nullptr) {
std::cerr << "PLUGIN ZNGCHS missing ZoxNGCEventProviderI\n";
return 2;
}
if (cr == nullptr) {
std::cerr << "PLUGIN ZNGCHS missing ContactModelI\n";
return 2;
}
if (tcm == nullptr) {
std::cerr << "PLUGIN ZNGCHS missing ToxContactModel2\n";
return 2;
}
if (rmm == nullptr) {
std::cerr << "PLUGIN ZNGCHS missing RegistryMessageModel\n";
return 2;
}
// register types
PLUG_PROVIDE_INSTANCE(ZoxNGCHistorySync, plugin_name, g_zngchs.get());
} catch (const ResolveException& e) {
std::cerr << "PLUGIN " << plugin_name << " " << e.what << "\n";
return 2;
}
// static store, could be anywhere tho
// construct with fetched dependencies
g_zngchs = std::make_unique<ZoxNGCHistorySync>(*tox_event_provider_i, *zox_ngc_event_provider_i, *tox_i, *cr, *tcm, *rmm);
// register types
PROVIDE_INSTANCE(ZoxNGCHistorySync, "ZoxNGCHistorySync", g_zngchs.get());
return 0;
}
SOLANA_PLUGIN_EXPORT void solana_plugin_stop(void) {
std::cout << "PLUGIN ZNGCHS STOP()\n";
std::cout << "PLUGIN " << plugin_name << " STOP()\n";
g_zngchs.reset();
}
SOLANA_PLUGIN_EXPORT float solana_plugin_tick(float delta) {
//std::cout << "PLUGIN ZNGCHS TICK()\n";
g_zngchs->tick(delta);
return 0.1f; // TODO: use the actual timers