From b4309ab4e95edf149a9c4b7b1723270545e20012 Mon Sep 17 00:00:00 2001 From: Nathan Date: Mon, 12 May 2025 16:28:27 -0500 Subject: [PATCH] reintegration complete --- .../Calculator/Calculator.cpp | 113 ++++++++ .../Calculator/Calculator.h | 26 ++ .../Chat/ChatClient/ChatClient.cpp | 129 +++++++++ .../Chat/ChatClient/ChatClient.h | 28 ++ .../Chat/ChatServer/ChatServer.cpp | 56 ++++ .../Chat/ChatServer/ChatServer.h | 34 +++ .../ChatClientVoice/ChatClientVoice.cpp | 250 ++++++++++++++++++ .../ChatClientVoice/ChatClientVoice.h | 36 +++ .../ChatServerVoice/ChatServerVoice.cpp | 68 +++++ .../ChatServerVoice/ChatServerVoice.h | 34 +++ .../Chess/ChessClient/ChessClient.cpp | 0 .../Chess/ChessClient/ChessClient.h | 0 .../Chess/ChessServer/ChessServer.cpp | 0 .../Chess/ChessServer/ChessServer.h | 0 .../DependsOnPrint/DependsOnPrint.cpp | 16 ++ .../DependsOnPrint/DependsOnPrint.h | 16 ++ .../DependsOnPrintStatic.cpp | 19 ++ .../DependsOnPrintStatic.h | 16 ++ modules/Archimedes-Modules/Ollama/Ollama.cpp | 126 +++++++++ modules/Archimedes-Modules/Ollama/Ollama.h | 26 ++ modules/Archimedes-Modules/Print/Print.cpp | 17 ++ modules/Archimedes-Modules/Print/Print.h | 15 ++ modules/Archimedes-Modules/README.md | 1 + .../Archimedes-Modules/Terminal/Terminal.cpp | 93 +++++++ .../Archimedes-Modules/Terminal/Terminal.h | 21 ++ .../Archimedes-Modules/TestClay/TestClay.cpp | 35 +++ .../Archimedes-Modules/TestClay/TestClay.h | 25 ++ .../TestImgui/TestImgui.cpp | 56 ++++ .../Archimedes-Modules/TestImgui/TestImgui.h | 24 ++ .../Archimedes-Modules/TestMenu/TestMenu.cpp | 37 +++ .../Archimedes-Modules/TestMenu/TestMenu.h | 20 ++ .../TestNotCurses/TestNotCurses.cpp | 28 ++ .../TestNotCurses/TestNotCurses.h | 19 ++ 33 files changed, 1384 insertions(+) create mode 100644 modules/Archimedes-Modules/Calculator/Calculator.cpp create mode 100644 modules/Archimedes-Modules/Calculator/Calculator.h create mode 100644 modules/Archimedes-Modules/Chat/ChatClient/ChatClient.cpp create mode 100644 modules/Archimedes-Modules/Chat/ChatClient/ChatClient.h create mode 100644 modules/Archimedes-Modules/Chat/ChatServer/ChatServer.cpp create mode 100644 modules/Archimedes-Modules/Chat/ChatServer/ChatServer.h create mode 100644 modules/Archimedes-Modules/ChatVoice/ChatClientVoice/ChatClientVoice.cpp create mode 100644 modules/Archimedes-Modules/ChatVoice/ChatClientVoice/ChatClientVoice.h create mode 100644 modules/Archimedes-Modules/ChatVoice/ChatServerVoice/ChatServerVoice.cpp create mode 100644 modules/Archimedes-Modules/ChatVoice/ChatServerVoice/ChatServerVoice.h create mode 100644 modules/Archimedes-Modules/Chess/ChessClient/ChessClient.cpp create mode 100644 modules/Archimedes-Modules/Chess/ChessClient/ChessClient.h create mode 100644 modules/Archimedes-Modules/Chess/ChessServer/ChessServer.cpp create mode 100644 modules/Archimedes-Modules/Chess/ChessServer/ChessServer.h create mode 100644 modules/Archimedes-Modules/DependsOnPrint/DependsOnPrint.cpp create mode 100644 modules/Archimedes-Modules/DependsOnPrint/DependsOnPrint.h create mode 100644 modules/Archimedes-Modules/DependsOnPrintStatic/DependsOnPrintStatic.cpp create mode 100644 modules/Archimedes-Modules/DependsOnPrintStatic/DependsOnPrintStatic.h create mode 100644 modules/Archimedes-Modules/Ollama/Ollama.cpp create mode 100644 modules/Archimedes-Modules/Ollama/Ollama.h create mode 100644 modules/Archimedes-Modules/Print/Print.cpp create mode 100644 modules/Archimedes-Modules/Print/Print.h create mode 100644 modules/Archimedes-Modules/README.md create mode 100644 modules/Archimedes-Modules/Terminal/Terminal.cpp create mode 100644 modules/Archimedes-Modules/Terminal/Terminal.h create mode 100644 modules/Archimedes-Modules/TestClay/TestClay.cpp create mode 100644 modules/Archimedes-Modules/TestClay/TestClay.h create mode 100644 modules/Archimedes-Modules/TestImgui/TestImgui.cpp create mode 100644 modules/Archimedes-Modules/TestImgui/TestImgui.h create mode 100644 modules/Archimedes-Modules/TestMenu/TestMenu.cpp create mode 100644 modules/Archimedes-Modules/TestMenu/TestMenu.h create mode 100644 modules/Archimedes-Modules/TestNotCurses/TestNotCurses.cpp create mode 100644 modules/Archimedes-Modules/TestNotCurses/TestNotCurses.h diff --git a/modules/Archimedes-Modules/Calculator/Calculator.cpp b/modules/Archimedes-Modules/Calculator/Calculator.cpp new file mode 100644 index 0000000..4723f5e --- /dev/null +++ b/modules/Archimedes-Modules/Calculator/Calculator.cpp @@ -0,0 +1,113 @@ +#include "Calculator.h" +#include "modules/ImguiModule/ImguiModule.h" + + +Calculator::Calculator(Archimedes::App* a, void* h) : Archimedes::Module(a, h) { + + name = "Calculator"; + + ImguiModule* im = new ImguiModule(a, h); + deps[*im] = im; +} + +Calculator::~Calculator() { + + if(app) { + ImguiModule* im; { im = (ImguiModule*) moduleInstances[ImguiModule()]; } + im->releaseContext(ImGui::GetCurrentContext()); + } +} + +void Calculator::onLoad() { + + ImguiModule* im; { im = (ImguiModule*) moduleInstances[ImguiModule()]; } + + if(!im) { + std::cout << "No ImguiModule for Calculator!\n"; + std::abort(); + } + + ImGui::SetCurrentContext(im->aquireContext()); + +} + +void Calculator::run() { + + if(open) { + basicCalculator(); + } else { + app->emitEvent(new Archimedes::DoUnloadModuleEvent(name)); + } + +} + +void Calculator::basicCalculator() { + + static bool b = true; + + static std::string s; + + if(b) { + + ImGui::Begin("Basic Calculator", &open); + + ImGui::InputText("equation", &s); + + if(ImGui::Button("7")) { + s += "7"; + } + ImGui::SameLine(); + if(ImGui::Button("8")) { + s += "8"; + } + ImGui::SameLine(); + if(ImGui::Button("9")) { + s += "9"; + } + if(ImGui::Button("4")) { + s += "4"; + } + ImGui::SameLine(); + if(ImGui::Button("5")) { + s += "5"; + } + ImGui::SameLine(); + if(ImGui::Button("6")) { + s += "6"; + } + if(ImGui::Button("1")) { + s += "1"; + } + ImGui::SameLine(); + if(ImGui::Button("2")) { + s += "2"; + } + ImGui::SameLine(); + if(ImGui::Button("3")) { + s += "3"; + } + if(ImGui::Button("0")) { + s += "1"; + } + ImGui::SameLine(); + if(ImGui::Button(".")) { + s += "2"; + } + ImGui::SameLine(); + if(ImGui::Button("󰭜")) { + if(s.back() == ' ') { + s.pop_back(); + s.pop_back(); + s.pop_back(); + } else { + s.pop_back(); + } + } + + ImGui::End(); + } +} + +void Calculator::graphingCalculator() { + +} diff --git a/modules/Archimedes-Modules/Calculator/Calculator.h b/modules/Archimedes-Modules/Calculator/Calculator.h new file mode 100644 index 0000000..6b4d14c --- /dev/null +++ b/modules/Archimedes-Modules/Calculator/Calculator.h @@ -0,0 +1,26 @@ +#include "Archimedes.h" + +class Calculator : public Archimedes::Module { + + public: + Calculator(Archimedes::App*, void*); + + Calculator() { name = "Calculator"; } + + ~Calculator(); + + void onLoad(); + + void run(); + private: + bool open = true; + + void basicCalculator(); + + void graphingCalculator(); +}; + +#ifdef CALCULATOR_DYNAMIC +typedef Calculator mtype; +#include "endModule.h" +#endif diff --git a/modules/Archimedes-Modules/Chat/ChatClient/ChatClient.cpp b/modules/Archimedes-Modules/Chat/ChatClient/ChatClient.cpp new file mode 100644 index 0000000..3d7cc1c --- /dev/null +++ b/modules/Archimedes-Modules/Chat/ChatClient/ChatClient.cpp @@ -0,0 +1,129 @@ + +#include "modules/ImguiModule/ImguiModule.h" + +#include "modules/ClientModule/ClientModule.h" + +#include "ChatClient.h" + + +ChatClient::ChatClient(Archimedes::App* a, void* h) : Module(a, h) { + + name = "ChatClient"; + + ClientModule* cm = new ClientModule(a, h); + deps[*cm] = cm; + cm->shouldHandleEvents(ClientModule::CMEventEnum::ConnectionStatusChanged | ClientModule::CMEventEnum::DataSent); + + ImguiModule* im = new ImguiModule(a, h); + + deps[*im] = im; + +} + +ChatClient::~ChatClient() { + if(app) { + + ImguiModule* im; { im = (ImguiModule*) moduleInstances[ImguiModule()]; } + + im->releaseContext(ImGui::GetCurrentContext()); + } +} + +void ChatClient::onLoad() { + + ImguiModule* im; { im = (ImguiModule*) moduleInstances[ImguiModule()]; } + + if(!im) { + std::cout << "No ImguiModule for ChatClient!\n"; + std::abort(); + } + + ImGui::SetCurrentContext(im->aquireContext()); + + ClientModule* cm; { cm = (ClientModule*) moduleInstances[ClientModule()]; } + + if(!cm) { + std::cout << "No ClientModule for ChatClient!\n"; + std::abort(); + } +} + +void ChatClient::run() { + + static ClientModule* cm; { cm = (ClientModule*) moduleInstances[ClientModule()]; } + + if(!cm) { + std::cout << "No ClientModule for ChatClient!\n"; + std::abort(); + } + + if(open) { + static std::string s, addr = "127.0.0.1:9932"; + + ImGui::Begin("ChatClient Module", &open); + + ImGui::InputText("Server Address: ", &addr); + + if(cm->isRunning() && cm->isConnected()) { + + if(ImGui::Button("Disconnect") && cm->isRunning()) { + cm->stopClient(); + } + + } else { + + if(ImGui::Button("Connect") && !cm->isRunning()) { + static SteamNetworkingIPAddr serverAddr; + serverAddr.ParseString(addr.c_str()); + cm->startClient(serverAddr); + } + } + + + ImGui::Text("%s", messages.c_str()); + + ImGui::InputText("Message: ", &s); + + ImGui::SameLine(); + + if(ImGui::Button("send")) { + cm->sendReliable(s.c_str(), (uint32) s.length()); + } + + ImGui::End(); + } else { + app->emitEvent(new Archimedes::DoUnloadModuleEvent(*cm)); + } +} + +bool ChatClient::onEvent(const Archimedes::Event& event) { + + unsigned int type = app->getEventType(event); + + /*if(type == app->getEventType("DataSentEvent")) { + //we did this? + return true; + } else */ + + if(type == app->getEventType(Archimedes::DataRecievedEvent())) { + + Archimedes::DataRecievedEvent& e = (Archimedes::DataRecievedEvent&) event; + + static std::string s; s = std::string((const char*)e.msg->m_pData, e.msg->m_cbSize); + + std::cerr << "Client Recieved: " << s << std::endl; + + messages += "\n\n" + s; + + return true; + } + /*else if(type == app->getEventType("ConnectionStatusChangedEvent")) { + + //Archimedes::ConnectionStatusChangedEvent& e = (Archimedes::ConnectionStatusChangedEvent&) event; + + return false; + + }*/ + + return false; +} diff --git a/modules/Archimedes-Modules/Chat/ChatClient/ChatClient.h b/modules/Archimedes-Modules/Chat/ChatClient/ChatClient.h new file mode 100644 index 0000000..73bd6dc --- /dev/null +++ b/modules/Archimedes-Modules/Chat/ChatClient/ChatClient.h @@ -0,0 +1,28 @@ +#include "Archimedes.h" + + +class ChatClient : public Archimedes::Module { + + public: + + ChatClient(Archimedes::App* a, void* h); + + ChatClient() { name = "ChatClient"; } + + ~ChatClient(); + + void onLoad() override; + + void run() override; + + bool onEvent(const Archimedes::Event&) override; + + private: + std::string messages = ""; + bool open = true; +}; + +#ifdef CHATCLIENT_DYNAMIC +typedef ChatClient mtype; +#include "endModule.h" +#endif diff --git a/modules/Archimedes-Modules/Chat/ChatServer/ChatServer.cpp b/modules/Archimedes-Modules/Chat/ChatServer/ChatServer.cpp new file mode 100644 index 0000000..6974ce8 --- /dev/null +++ b/modules/Archimedes-Modules/Chat/ChatServer/ChatServer.cpp @@ -0,0 +1,56 @@ +#include "ChatServer.h" + +void ChatServer::onLoad() { + ServerModule* sm = (ServerModule*) moduleInstances[ServerModule()]; + + sm->startServer(9932); +} + +//void ChatServer::run() {} + +bool ChatServer::onEvent(const Archimedes::Event& event) { + + unsigned int type = app->getEventType(event); + + + /*if(type == app->getEventType("DataSentEvent")) { + //we did this? + return true; + } else */ + + if(type == app->getEventType(Archimedes::DataRecievedEvent())) { + + static ServerModule* sm; { sm = (ServerModule*) moduleInstances[ServerModule()]; } + + Archimedes::DataRecievedEvent& e = (Archimedes::DataRecievedEvent&) event; + + static std::string s; s = std::string((const char*)e.msg->m_pData, e.msg->m_cbSize); + + if(s == "/quit") { + sm->disconnectClient(e.msg->m_conn); + } else if(s == "/shutdown") { + sm->stopServer(); + app->end(); + } + + std::cerr << "Server Recieved: " << s << std::endl; + + for(auto& it : sm->getClients()) { + if(it.first != e.msg->m_conn) + sm->sendReliable(it.first, s.c_str(), s.length()); + else + sm->sendReliable(e.msg->m_conn, "\nMessage sent\n", strlen("\nMessage sent\n")); + } + + return true; + + } /*else if(type == app->getEventType("ConnectionStatusChangedEvent")) { + + //Archimedes::ConnectionStatusChangedEvent& e = (Archimedes::ConnectionStatusChangedEvent&) event; + + return false; + + }*/ + + return false; +} diff --git a/modules/Archimedes-Modules/Chat/ChatServer/ChatServer.h b/modules/Archimedes-Modules/Chat/ChatServer/ChatServer.h new file mode 100644 index 0000000..7d31051 --- /dev/null +++ b/modules/Archimedes-Modules/Chat/ChatServer/ChatServer.h @@ -0,0 +1,34 @@ +#include "Archimedes.h" + +#include "modules/ServerModule/ServerModule.h" + +class ChatServer : public Archimedes::Module { + + public: + + ChatServer(Archimedes::App* a, void* h) : Module(a, h) { + + name = "ChatServer"; + + ServerModule* sm = new ServerModule(a, h); + deps[*sm] = sm; + sm->shouldHandleEvents(ServerModule::SMEventEnum::ConnectionStatusChanged | ServerModule::SMEventEnum::DataSent); + } + + ChatServer() { name = "ChatServer"; } + + ~ChatServer() { + if(app) {} + } + + void onLoad(); + + //void run(); + + bool onEvent(const Archimedes::Event&); +}; + +#ifdef CHATSERVER_DYNAMIC +typedef ChatServer mtype; +#include "endModule.h" +#endif diff --git a/modules/Archimedes-Modules/ChatVoice/ChatClientVoice/ChatClientVoice.cpp b/modules/Archimedes-Modules/ChatVoice/ChatClientVoice/ChatClientVoice.cpp new file mode 100644 index 0000000..4963627 --- /dev/null +++ b/modules/Archimedes-Modules/ChatVoice/ChatClientVoice/ChatClientVoice.cpp @@ -0,0 +1,250 @@ + +#include "modules/ImguiModule/ImguiModule.h" + +#include "modules/ClientModule/ClientModule.h" + +#include "ChatClientVoice.h" + + +ChatClientVoice::ChatClientVoice(Archimedes::App* a, void* h) : Module(a, h) { + + name = "ChatClientVoice"; + + ClientModule* cm = new ClientModule(a, h); + deps[*cm] = cm; + cm->shouldHandleEvents(ClientModule::CMEventEnum::ConnectionStatusChanged | ClientModule::CMEventEnum::DataSent); + + ImguiModule* im = new ImguiModule(a, h); + + deps[*im] = im; + +} + +ChatClientVoice::~ChatClientVoice() { + if(app) { + + ImguiModule* im; { im = (ImguiModule*) moduleInstances[ImguiModule()]; } + + im->releaseContext(ImGui::GetCurrentContext()); + + //if(buf) + // delete [] buf; + } +} + +void ChatClientVoice::onLoad() { + + ImguiModule* im; { im = (ImguiModule*) moduleInstances[ImguiModule()]; } + + if(!im) { + std::cout << "No ImguiModule for ChatClientVoice!\n"; + std::abort(); + } + + ImGui::SetCurrentContext(im->aquireContext()); + + ClientModule* cm; { cm = (ClientModule*) moduleInstances[ClientModule()]; } + + if(!cm) { + std::cout << "No ClientModule for ChatClientVoice!\n"; + std::abort(); + } + + if(!SDL_Init(SDL_INIT_AUDIO)) { + std::cout << "Audio init failed!\n"; + std::abort(); + } + + mic = SDL_OpenAudioDeviceStream(SDL_AUDIO_DEVICE_DEFAULT_RECORDING, NULL, NULL, NULL); + SDL_GetAudioStreamFormat(mic, &spec, NULL); + speaker = SDL_OpenAudioDeviceStream(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &spec, NULL, NULL); + + //buf = new unsigned char[len]; + +} + +void ChatClientVoice::run() { + + static ClientModule* cm; { cm = (ClientModule*) moduleInstances[ClientModule()]; } + + static unsigned char buf[10 * 1024]; + + if(!cm) { + std::cout << "No ClientModule for ChatClientVoice!\n"; + std::abort(); + } + + if(open) { + static std::string s, addr = "127.0.0.1:9932"; + + ImGui::Begin("ChatClientVoice Module", &open); + + ImGui::InputText("Server Address: ", &addr); + + if(cm->isRunning() && cm->isConnected()) { + + if(ImGui::Button("Disconnect") && cm->isRunning()) { + cm->stopClient(); + } + + } else { + + if(ImGui::Button("Connect") && !cm->isRunning()) { + static SteamNetworkingIPAddr serverAddr; + serverAddr.ParseString(addr.c_str()); + cm->startClient(serverAddr); + } + } + + + ImGui::Text("%s", messages.c_str()); + + ImGui::InputText("Message: ", &s); + + if(cm->isConnected()) { + ImGui::SameLine(); + + if(ImGui::Button("send")) { + s.insert(s.begin(), 'o'); + s.insert(s.begin(), ' '); + s.insert(s.begin(), '0'); + s.insert(s.begin(), 'a'); + cm->sendReliable(s.c_str(), (uint32) s.length()); + s.clear(); + } + } + + static float micVol = 1.0f; + static float speakerVol = 1.0f; + + static bool micTest = false; + + ImGui::SliderFloat("Mic Volume", &micVol, 0.0f, 1.0f); + ImGui::SliderFloat("Speaker Volume", &speakerVol, 0.0f, 1.0f); + + ImGui::Checkbox("Mic test", &micTest); + + if(!SDL_AudioStreamDevicePaused(mic)) { + SDL_SetAudioStreamGain(mic, micVol); + } else if(micTest) { + SDL_ClearAudioStream(mic); + SDL_ResumeAudioStreamDevice(mic); + SDL_SetAudioStreamGain(mic, micVol); + } else if(!cm->isConnected()) { + SDL_PauseAudioStreamDevice(mic); + SDL_ClearAudioStream(mic); + } + + if(!SDL_AudioStreamDevicePaused(speaker)) { + SDL_SetAudioStreamGain(speaker, speakerVol); + } else if(micTest) { + SDL_ClearAudioStream(speaker); + SDL_ResumeAudioStreamDevice(speaker); + SDL_SetAudioStreamGain(speaker, speakerVol); + } else if(!cm->isConnected()) { + SDL_PauseAudioStreamDevice(speaker); + SDL_ClearAudioStream(speaker); + + } + + static int avail = 0; + + if(micTest) { + + avail = SDL_min(len, SDL_GetAudioStreamAvailable(mic)); + avail = SDL_GetAudioStreamData(mic, buf, avail); + + SDL_PutAudioStreamData(speaker, buf, avail); + + } else if(cm->isConnected()){ + // if not testing, send to server. + + avail = SDL_min(len, SDL_GetAudioStreamAvailable(mic)); + if(avail > 10) { + avail = SDL_GetAudioStreamData(mic, buf, avail); + cm->sendReliable(buf, avail); + } + } + + + ImGui::End(); + } else { + app->emitEvent(new Archimedes::DoUnloadModuleEvent(*cm)); + } +} + +bool ChatClientVoice::onEvent(const Archimedes::Event& event) { + + unsigned int type = app->getEventType(event); + + /*if(type == app->getEventType("DataSentEvent")) { + //we did this? + return true; + } else */ + + if(type == app->getEventType(Archimedes::DataRecievedEvent())) { + + Archimedes::DataRecievedEvent& e = (Archimedes::DataRecievedEvent&) event; + + static std::string s; + + if(((char*)e.msg->m_pData)[0] == 'a' && ((char*)e.msg->m_pData)[1] == '0' && ((char*)e.msg->m_pData)[2] == ' ' && ((char*)e.msg->m_pData)[3] == 'o') { + s = std::string((const char*)e.msg->m_pData + 4, e.msg->m_cbSize - 4); + + messages += "\n\n" + s; + } else { + s = "audio data"; + + SDL_PutAudioStreamData(speaker, e.msg->m_pData, e.msg->m_cbSize); + } + + std::cerr << "Client Recieved: " << s << std::endl; + + return true; + } else if(type == app->getEventType("ConnectionStatusChangedEvent")) { + + Archimedes::ConnectionStatusChangedEvent& e = (Archimedes::ConnectionStatusChangedEvent&) event; + + switch(e.info->m_info.m_eState) { + + case k_ESteamNetworkingConnectionState_None: + // NOTE: We will get callbacks here when we destroy connections. You can ignore these. + break; + + case k_ESteamNetworkingConnectionState_ClosedByPeer: + case k_ESteamNetworkingConnectionState_ProblemDetectedLocally: + { + + SDL_PauseAudioStreamDevice(mic); + SDL_PauseAudioStreamDevice(speaker); + SDL_ClearAudioStream(mic); + SDL_ClearAudioStream(speaker); + + break; + } + + case k_ESteamNetworkingConnectionState_Connecting: + { + break; + } + + case k_ESteamNetworkingConnectionState_Connected: + //OnConnect + SDL_ClearAudioStream(mic); + SDL_ClearAudioStream(speaker); + SDL_ResumeAudioStreamDevice(mic); + SDL_ResumeAudioStreamDevice(speaker); + + break; + + default: + // Silences -Wswitch + break; + } + + return false; + + } + + return false; +} diff --git a/modules/Archimedes-Modules/ChatVoice/ChatClientVoice/ChatClientVoice.h b/modules/Archimedes-Modules/ChatVoice/ChatClientVoice/ChatClientVoice.h new file mode 100644 index 0000000..d05cd25 --- /dev/null +++ b/modules/Archimedes-Modules/ChatVoice/ChatClientVoice/ChatClientVoice.h @@ -0,0 +1,36 @@ +#include "Archimedes.h" + + +#include +#include + +class ChatClientVoice : public Archimedes::Module { + + public: + + ChatClientVoice(Archimedes::App* a, void* h); + + ChatClientVoice() { name = "ChatClientVoice"; } + + ~ChatClientVoice(); + + void onLoad() override; + + void run() override; + + bool onEvent(const Archimedes::Event&) override; + + private: + std::string messages = ""; + bool open = true; + + SDL_AudioSpec spec; + SDL_AudioStream *mic, *speaker; + + const int len = 10 * 1024; +}; + +#ifdef CHATCLIENTVOICE_DYNAMIC +typedef ChatClientVoice mtype; +#include "endModule.h" +#endif diff --git a/modules/Archimedes-Modules/ChatVoice/ChatServerVoice/ChatServerVoice.cpp b/modules/Archimedes-Modules/ChatVoice/ChatServerVoice/ChatServerVoice.cpp new file mode 100644 index 0000000..c2b5d4e --- /dev/null +++ b/modules/Archimedes-Modules/ChatVoice/ChatServerVoice/ChatServerVoice.cpp @@ -0,0 +1,68 @@ +#include "ChatServerVoice.h" + +void ChatServerVoice::onLoad() { + ServerModule* sm = (ServerModule*) moduleInstances[ServerModule()]; + + sm->startServer(9932); +} + +//void ChatServerVoice::run() {} + +bool ChatServerVoice::onEvent(const Archimedes::Event& event) { + + unsigned int type = app->getEventType(event); + + + /*if(type == app->getEventType("DataSentEvent")) { + //we did this? + return true; + } else */ + + if(type == app->getEventType(Archimedes::DataRecievedEvent())) { + + static ServerModule* sm; { sm = (ServerModule*) moduleInstances[ServerModule()]; } + + Archimedes::DataRecievedEvent& e = (Archimedes::DataRecievedEvent&) event; + static std::string s; + + if(((char*)e.msg->m_pData)[0] == 'a' && ((char*)e.msg->m_pData)[1] == '0' && ((char*)e.msg->m_pData)[2] == ' ' && ((char*)e.msg->m_pData)[3] == 'o') { + s = std::string((const char*)e.msg->m_pData + 4, e.msg->m_cbSize - 4); + + if(s == "/quit") { + sm->disconnectClient(e.msg->m_conn); + } else if(s == "/shutdown") { + sm->stopServer(); + app->end(); + } + + for(auto& it : sm->getClients()) { + if(it.first != e.msg->m_conn) + sm->sendReliable(it.first, e.msg->m_pData, e.msg->m_cbSize); + else + sm->sendReliable(e.msg->m_conn, "a0 o\nMessage sent\n", strlen("a0 o\nMessage sent\n")); + } + + + } else { + s = "audio data"; + + for(auto& it : sm->getClients()) { + if(it.first != e.msg->m_conn) + sm->sendReliable(it.first, e.msg->m_pData, e.msg->m_cbSize); + } + } + + std::cerr << "Server Recieved: " << s << std::endl; + + return true; + + } /*else if(type == app->getEventType("ConnectionStatusChangedEvent")) { + + //Archimedes::ConnectionStatusChangedEvent& e = (Archimedes::ConnectionStatusChangedEvent&) event; + + return false; + + }*/ + + return false; +} diff --git a/modules/Archimedes-Modules/ChatVoice/ChatServerVoice/ChatServerVoice.h b/modules/Archimedes-Modules/ChatVoice/ChatServerVoice/ChatServerVoice.h new file mode 100644 index 0000000..93884aa --- /dev/null +++ b/modules/Archimedes-Modules/ChatVoice/ChatServerVoice/ChatServerVoice.h @@ -0,0 +1,34 @@ +#include "Archimedes.h" + +#include "modules/ServerModule/ServerModule.h" + +class ChatServerVoice : public Archimedes::Module { + + public: + + ChatServerVoice(Archimedes::App* a, void* h) : Module(a, h) { + + name = "ChatServerVoice"; + + ServerModule* sm = new ServerModule(a, h); + deps[*sm] = sm; + sm->shouldHandleEvents(ServerModule::SMEventEnum::ConnectionStatusChanged | ServerModule::SMEventEnum::DataSent); + } + + ChatServerVoice() { name = "ChatServerVoice"; } + + ~ChatServerVoice() { + if(app) {} + } + + void onLoad(); + + //void run(); + + bool onEvent(const Archimedes::Event&); +}; + +#ifdef CHATSERVERVOICE_DYNAMIC +typedef ChatServerVoice mtype; +#include "endModule.h" +#endif diff --git a/modules/Archimedes-Modules/Chess/ChessClient/ChessClient.cpp b/modules/Archimedes-Modules/Chess/ChessClient/ChessClient.cpp new file mode 100644 index 0000000..e69de29 diff --git a/modules/Archimedes-Modules/Chess/ChessClient/ChessClient.h b/modules/Archimedes-Modules/Chess/ChessClient/ChessClient.h new file mode 100644 index 0000000..e69de29 diff --git a/modules/Archimedes-Modules/Chess/ChessServer/ChessServer.cpp b/modules/Archimedes-Modules/Chess/ChessServer/ChessServer.cpp new file mode 100644 index 0000000..e69de29 diff --git a/modules/Archimedes-Modules/Chess/ChessServer/ChessServer.h b/modules/Archimedes-Modules/Chess/ChessServer/ChessServer.h new file mode 100644 index 0000000..e69de29 diff --git a/modules/Archimedes-Modules/DependsOnPrint/DependsOnPrint.cpp b/modules/Archimedes-Modules/DependsOnPrint/DependsOnPrint.cpp new file mode 100644 index 0000000..22d1f9d --- /dev/null +++ b/modules/Archimedes-Modules/DependsOnPrint/DependsOnPrint.cpp @@ -0,0 +1,16 @@ +#include "DependsOnPrint.h" + +DependsOnPrint::DependsOnPrint(Archimedes::App* a, void* h) : Module(a, h) { + name = "DependsOnPrint"; + + deps["Print"] = "/home/nathan/Projects/Archimedes/result-1/bin/Print"; +} + +DependsOnPrint::~DependsOnPrint() { + std::cout << "DependsOnPrint Destroyed!\n"; +} + +void DependsOnPrint::run() { + std::cout << "DependsOnPrint lib loaded and run!\n"; + app->emitEvent(new Archimedes::DoUnloadModuleEvent(name)); +} diff --git a/modules/Archimedes-Modules/DependsOnPrint/DependsOnPrint.h b/modules/Archimedes-Modules/DependsOnPrint/DependsOnPrint.h new file mode 100644 index 0000000..38ed9ad --- /dev/null +++ b/modules/Archimedes-Modules/DependsOnPrint/DependsOnPrint.h @@ -0,0 +1,16 @@ +#include "Archimedes.h" + +class DependsOnPrint : public Archimedes::Module { + + public: + DependsOnPrint(Archimedes::App*, void*); + ~DependsOnPrint(); + void run(); + void onLoad() {} + +}; + +#ifdef DEPENDSONPRINT_DYNAMIC +typedef DependsOnPrint mtype; +#include "endModule.h" +#endif diff --git a/modules/Archimedes-Modules/DependsOnPrintStatic/DependsOnPrintStatic.cpp b/modules/Archimedes-Modules/DependsOnPrintStatic/DependsOnPrintStatic.cpp new file mode 100644 index 0000000..f08b3c4 --- /dev/null +++ b/modules/Archimedes-Modules/DependsOnPrintStatic/DependsOnPrintStatic.cpp @@ -0,0 +1,19 @@ +#include "DependsOnPrintStatic.h" + +#include "modules/Archimedes-Modules/Print/Print.h" + +DependsOnPrintStatic::DependsOnPrintStatic(Archimedes::App* a, void* h) : Module(a, h) { + name = "DependsOnPrintStatic"; + + Print* p = new Print(a, h); + deps[*p] = p; +} + +DependsOnPrintStatic::~DependsOnPrintStatic() { + std::cout << "DependsOnPrintStatic Destroyed!\n"; +} + +void DependsOnPrintStatic::run() { + std::cout << "DependsOnPrintStatic lib loaded and run!\n"; + app->emitEvent(new Archimedes::DoUnloadModuleEvent(name)); +} diff --git a/modules/Archimedes-Modules/DependsOnPrintStatic/DependsOnPrintStatic.h b/modules/Archimedes-Modules/DependsOnPrintStatic/DependsOnPrintStatic.h new file mode 100644 index 0000000..0221c89 --- /dev/null +++ b/modules/Archimedes-Modules/DependsOnPrintStatic/DependsOnPrintStatic.h @@ -0,0 +1,16 @@ +#include "Archimedes.h" + +class DependsOnPrintStatic : public Archimedes::Module { + + public: + DependsOnPrintStatic(Archimedes::App*, void*); + ~DependsOnPrintStatic(); + void run(); + void onLoad() {} + +}; + +#ifdef DEPENDSONPRINTSTATIC_DYNAMIC +typedef DependsOnPrintStatic mtype; +#include "endModule.h" +#endif diff --git a/modules/Archimedes-Modules/Ollama/Ollama.cpp b/modules/Archimedes-Modules/Ollama/Ollama.cpp new file mode 100644 index 0000000..cd78134 --- /dev/null +++ b/modules/Archimedes-Modules/Ollama/Ollama.cpp @@ -0,0 +1,126 @@ +#include "Ollama.h" +#include "modules/ImguiModule/ImguiModule.h" + +#include + +Ollama::Ollama(Archimedes::App* a, void* h) : Archimedes::Module(a, h) { + + name = "Ollama"; + + ImguiModule* im = new ImguiModule(a, h); + deps[*im] = im; +} + +Ollama::~Ollama() { + if(app) { + if(curl) { + curl_easy_cleanup(curl); + curl = nullptr; + } + curl_global_cleanup(); + + ImguiModule* im; { im = (ImguiModule*) moduleInstances[ImguiModule()]; } + im->releaseContext(ImGui::GetCurrentContext()); + } +} + +static size_t WriteCallback(void* contents, size_t size, size_t nmemb, std::ostream* userp) +{ + userp->write(static_cast(contents), size * nmemb); + return size * nmemb; +} + +void Ollama::onLoad() { + + ImguiModule* im; { im = (ImguiModule*) moduleInstances[ImguiModule()]; } + + if(!im) { + std::cout << "No ImguiModule for Ollama!\n"; + std::abort(); + } + + ImGui::SetCurrentContext(im->aquireContext()); + + curl_global_init(CURL_GLOBAL_ALL); + curl = curl_easy_init(); + +} + +void Ollama::run() { + + ImGuiIO& io = ImGui::GetIO(); + + static std::string s, url = "https://ollama.blunkall.us", response = ""; + + static nlohmann::json sendObj; + + static std::ostringstream oss; + + static nlohmann::json jsonObj; + + static std::future result; + + static bool inFlight = false; + + ImGui::Begin("Ollama Module"); + + ImGui::InputText("url: ", &url); + + static const std::string replace = "\\n"; + static const std::string replace_by = "\n"; + static std::string print = jsonObj["response"].dump(); print = jsonObj["response"].dump(); + static auto pos = print.find(replace); pos = print.find(replace); + + while (pos != std::string::npos) { + // Replace the substring with the specified string + print.replace(pos, replace.size(), replace_by); + + // Find the next occurrence of the substring + pos = print.find(replace, + pos + replace_by.size()); + } + print = "\n\n\n" + print + "\n\n\n"; + ImGui::TextWrapped("%s", print.c_str()); + + ImGui::InputTextMultiline("prompt: ", &s); + + if(ImGui::Button("send")) { + sendObj["model"] = "llama3.2"; + sendObj["stream"] = false; + sendObj["prompt"] = s; + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback); + curl_easy_setopt(curl, CURLOPT_URL, (url + "/api/generate").c_str()); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, &oss); + //curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L); + //curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 2L); + curl_easy_setopt(curl, CURLOPT_POST, 1L); + curl_easy_setopt(curl, CURLOPT_COPYPOSTFIELDS, sendObj.dump().c_str()); + result = std::async(std::launch::async, curl_easy_perform, curl); + inFlight = true; + } + + ImGui::Text("ms per frame: %f", 1000 / io.Framerate); + + ImGui::End(); + + if(curl) { + } + + if(inFlight && result.wait_for(std::chrono::seconds(0)) == std::future_status::ready) { + CURLcode code = result.get(); + response = oss.str(); + oss.str(""); + + + if(code != CURLE_OK) { + std::cerr << "curl_easy_perform() failed!: " << curl_easy_strerror(code) << std::endl; + app->emitEvent(new Archimedes::DoUnloadModuleEvent(name)); + return; + } else { + jsonObj = nlohmann::json::parse(response); + + std::cout << "Full json object:\n" << jsonObj.dump() << std::endl; + } + inFlight = false; + } +} diff --git a/modules/Archimedes-Modules/Ollama/Ollama.h b/modules/Archimedes-Modules/Ollama/Ollama.h new file mode 100644 index 0000000..19c1ff4 --- /dev/null +++ b/modules/Archimedes-Modules/Ollama/Ollama.h @@ -0,0 +1,26 @@ +#include "Archimedes.h" + +#include +#include + +class Ollama : public Archimedes::Module { + + public: + Ollama(Archimedes::App*, void*); + + Ollama() { name = "Ollama"; } + ~Ollama(); + + void onLoad(); + + void run(); + + private: + CURL* curl; + +}; + +#ifdef OLLAMA_DYNAMIC +typedef Ollama mtype; +#include "endModule.h" +#endif diff --git a/modules/Archimedes-Modules/Print/Print.cpp b/modules/Archimedes-Modules/Print/Print.cpp new file mode 100644 index 0000000..f988706 --- /dev/null +++ b/modules/Archimedes-Modules/Print/Print.cpp @@ -0,0 +1,17 @@ +#include "Print.h" + +Print::Print(Archimedes::App* a, void* h) : Archimedes::Module(a, h) { + name = "Print"; +} + +Print::~Print() { + if(app) { + std::cout << "Print Destroyed!\n"; + } +} + +void Print::run() { + std::cout << "Print lib loaded and run!\n"; + + app->stopModule(name); +} diff --git a/modules/Archimedes-Modules/Print/Print.h b/modules/Archimedes-Modules/Print/Print.h new file mode 100644 index 0000000..ec3bbe5 --- /dev/null +++ b/modules/Archimedes-Modules/Print/Print.h @@ -0,0 +1,15 @@ +#include "Archimedes.h" + +class Print : public Archimedes::Module { + + public: + Print(Archimedes::App*, void*); + Print() { name = "Print"; } + ~Print(); + void run(); +}; + +#ifdef PRINT_DYNAMIC +typedef Print mtype; +#include "endModule.h" +#endif diff --git a/modules/Archimedes-Modules/README.md b/modules/Archimedes-Modules/README.md new file mode 100644 index 0000000..aac3e62 --- /dev/null +++ b/modules/Archimedes-Modules/README.md @@ -0,0 +1 @@ +Example modules for Archimedes diff --git a/modules/Archimedes-Modules/Terminal/Terminal.cpp b/modules/Archimedes-Modules/Terminal/Terminal.cpp new file mode 100644 index 0000000..fe0d93e --- /dev/null +++ b/modules/Archimedes-Modules/Terminal/Terminal.cpp @@ -0,0 +1,93 @@ +#include + +#include +#include +#include + +#include "Terminal.h" +#include "modules/ImguiModule/ImguiModule.h" + + +Terminal::Terminal(Archimedes::App* a, void* h) : Archimedes::Module(a, h) { + + name = "Terminal"; + + ImguiModule* im = new ImguiModule(a, h); + deps[*im] = im; +} + +Terminal::~Terminal() { + if(app) { + ImguiModule* im; { im = (ImguiModule*) moduleInstances[ImguiModule()]; } + + im->releaseContext(ImGui::GetCurrentContext()); + } +} + +void Terminal::onLoad() { + + ImguiModule* im; { im = (ImguiModule*) moduleInstances[ImguiModule()]; } + + if(!im) { + std::cout << "No ImguiModule for Terminal!\n"; + std::abort(); + } + + ImGui::SetCurrentContext(im->aquireContext()); + + child_pid = forkpty(&master, nullptr, nullptr, nullptr); + + if(!child_pid) { + char* const* args = nullptr; + execvp("bash", args); + } + + //fcntl(master, F_SETFL, fcntl(master, F_GETFL, 0) | O_NONBLOCK); +/* + if (master >= 0) + (void)write(master, "ls\n", 3); +*/ +} + +void Terminal::run() { + + static fd_set fds; + static int rc; + static char opArr[150]; + static std::string input, output; + static timeval to; to = { 0, 0 }; + + FD_ZERO(&fds); + FD_SET(master, &fds); + + rc = select(master + 1, &fds, NULL, NULL, &to); + + switch(rc) { + case -1: + std::cerr << "Error " << errno << " on select()\n"; + exit(1); + default: + if(FD_ISSET(master, &fds)) { + rc = read(master, opArr, 150); + if(rc < 0) { + //error on read + app->emitEvent(new Archimedes::DoUnloadModuleEvent(name)); + } else { + if(input == "clear") output = ""; + output += opArr; + } + } + } + + ImGui::Begin("Terminal Module"); + + ImGui::TextWrapped("%s", output.c_str()); + ImGui::InputText("input", &input); + + if(ImGui::Button("send")) { + (void)write(master, (input + "\n").c_str(), input.length() + 1); + } + + + ImGui::End(); +} diff --git a/modules/Archimedes-Modules/Terminal/Terminal.h b/modules/Archimedes-Modules/Terminal/Terminal.h new file mode 100644 index 0000000..b2460b8 --- /dev/null +++ b/modules/Archimedes-Modules/Terminal/Terminal.h @@ -0,0 +1,21 @@ +#include "Archimedes.h" + +class Terminal : public Archimedes::Module { + + public: + Terminal(Archimedes::App*, void*); + + Terminal() { name = "Terminal"; } + ~Terminal(); + + void onLoad(); + + void run(); + private: + int child_pid, master; +}; + +#ifdef TERMINAL_DYNAMIC +typedef Terminal mtype; +#include "endModule.h" +#endif diff --git a/modules/Archimedes-Modules/TestClay/TestClay.cpp b/modules/Archimedes-Modules/TestClay/TestClay.cpp new file mode 100644 index 0000000..33a2bc3 --- /dev/null +++ b/modules/Archimedes-Modules/TestClay/TestClay.cpp @@ -0,0 +1,35 @@ +#include "TestClay.h" + +#define CLAY_IMPLIMENTATION +#include "clay.h" + +#include + +TestClay::TestClay(void* h, Archimedes::App& a) : Archimedes::GuiModule(h, a) { + + name = "TestClay"; +} + +TestClay::~TestClay() { +} + +void TestClay::onLoad() { + + createWindow(); + + window->getRenderer().init(); + + +} + +void TestClay::run() { + + window->getRenderer().addRenderCmd([](){ + + }); + + if(window->shouldClose()) + app.end(); + window->doFrame(); + +} diff --git a/modules/Archimedes-Modules/TestClay/TestClay.h b/modules/Archimedes-Modules/TestClay/TestClay.h new file mode 100644 index 0000000..e74916d --- /dev/null +++ b/modules/Archimedes-Modules/TestClay/TestClay.h @@ -0,0 +1,25 @@ +#include "Archimedes.h" + + +class TestClay : public Archimedes::Module { + + public: + TestClay(void*, Archimedes::App&); + + ~TestClay(); + + void onLoad(); + + void run(); + + private: +}; + + +extern "C" { + Archimedes::Module* create(void* handle, Archimedes::App& app) { + return new TestClay(handle, app); + } +} + + diff --git a/modules/Archimedes-Modules/TestImgui/TestImgui.cpp b/modules/Archimedes-Modules/TestImgui/TestImgui.cpp new file mode 100644 index 0000000..e166a5b --- /dev/null +++ b/modules/Archimedes-Modules/TestImgui/TestImgui.cpp @@ -0,0 +1,56 @@ +#include "TestImgui.h" +#include "modules/ImguiModule/ImguiModule.h" + +TestImgui::TestImgui(Archimedes::App* a, void* h) : Archimedes::Module(a, h) { + + name = "TestImgui"; + + ImguiModule* im = new ImguiModule(a, h); + deps[*im] = im; +} + +TestImgui::~TestImgui() { + + ImguiModule* im; { im = (ImguiModule*) moduleInstances[ImguiModule()]; } + im->releaseContext(ImGui::GetCurrentContext()); +} + +void TestImgui::onLoad() { + + ImguiModule* im; { im = (ImguiModule*) moduleInstances[ImguiModule()]; } + + if(!im) { + std::cout << "No ImguiModule for TestImgui!\n"; + std::abort(); + } + + ImGui::SetCurrentContext(im->aquireContext()); + +} + +void TestImgui::run() { + if(demo) + ImGui::ShowDemoWindow(&this->demo); + else + app->emitEvent(new Archimedes::DoUnloadModuleEvent(name)); + + { + ImGuiIO& io = ImGui::GetIO(); + static float f = 0.0f; + static int counter = 0; + + ImGui::Begin("TestImgui Module"); // Create a window called "Hello, world!" and append into it. + + ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too) + + ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f + + if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated) + counter++; + ImGui::SameLine(); + ImGui::Text("counter = %d", counter); + + ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate); + ImGui::End(); + } +} diff --git a/modules/Archimedes-Modules/TestImgui/TestImgui.h b/modules/Archimedes-Modules/TestImgui/TestImgui.h new file mode 100644 index 0000000..d6dc70f --- /dev/null +++ b/modules/Archimedes-Modules/TestImgui/TestImgui.h @@ -0,0 +1,24 @@ +#include "Archimedes.h" + +class TestImgui : public Archimedes::Module { + + public: + TestImgui(Archimedes::App*, void*); + + TestImgui() { name = "TestImgui"; } + + ~TestImgui(); + + void onLoad(); + + void run(); + + + private: + bool demo = true; +}; + +#ifdef TESTIMGUI_DYNAMIC +typedef TestImgui mtype; +#include "endModule.h" +#endif diff --git a/modules/Archimedes-Modules/TestMenu/TestMenu.cpp b/modules/Archimedes-Modules/TestMenu/TestMenu.cpp new file mode 100644 index 0000000..d393cf4 --- /dev/null +++ b/modules/Archimedes-Modules/TestMenu/TestMenu.cpp @@ -0,0 +1,37 @@ +#include "TestMenu.h" + +TestMenu::TestMenu(Archimedes::App* a, void* h) : Module(a, h) { + name = "TestMenu"; +} + +TestMenu::~TestMenu() { + std::cout << "TestMenu Destroyed!\n"; +} + +void TestMenu::run() { + + std::cout << "Your number is: " << num << "\n" + << "1. Add 1\n" + << "2. Subtract 1\n" + << "3. Unload Module\n\n" + << "4. Quit\n\n"; + + std::cin >> choice; + + switch(choice) { + case 1: + num++; + break; + case 2: + num--; + break; + case 3: + app->emitEvent(new Archimedes::DoUnloadModuleEvent(name)); + break; + case 4: + app->end(); + break; + default: + break; + } +} diff --git a/modules/Archimedes-Modules/TestMenu/TestMenu.h b/modules/Archimedes-Modules/TestMenu/TestMenu.h new file mode 100644 index 0000000..9547813 --- /dev/null +++ b/modules/Archimedes-Modules/TestMenu/TestMenu.h @@ -0,0 +1,20 @@ +#include "Archimedes.h" + +class TestMenu : public Archimedes::Module { + + public: + TestMenu(Archimedes::App*, void*); + TestMenu() { name = "TestMenu"; } + ~TestMenu(); + void run(); + void onLoad() {} + + private: + int choice; + int num = 5; +}; + +#ifdef TESTMENU_DYNAMIC +typedef TestMenu mtype; +#include "endModule.h" +#endif diff --git a/modules/Archimedes-Modules/TestNotCurses/TestNotCurses.cpp b/modules/Archimedes-Modules/TestNotCurses/TestNotCurses.cpp new file mode 100644 index 0000000..aed68c8 --- /dev/null +++ b/modules/Archimedes-Modules/TestNotCurses/TestNotCurses.cpp @@ -0,0 +1,28 @@ +#include "TestNotCurses.h" + +TestNotCurses::TestNotCurses(Archimedes::App* a, void* h) : Archimedes::Module(a, h) { + name = "TestNotCurses"; +} + +TestNotCurses::~TestNotCurses() { + notcurses_stop(ncInstance); +} + +void TestNotCurses::onLoad() { + + setlocale(LC_ALL, ""); + + notcurses_options opts; + + ncInstance = notcurses_init(&opts, NULL); + + if(!ncInstance) { + app->stopModule(getName()); + return; + } +} + +void TestNotCurses::run() { + + notcurses_render(ncInstance); +} diff --git a/modules/Archimedes-Modules/TestNotCurses/TestNotCurses.h b/modules/Archimedes-Modules/TestNotCurses/TestNotCurses.h new file mode 100644 index 0000000..148d7ed --- /dev/null +++ b/modules/Archimedes-Modules/TestNotCurses/TestNotCurses.h @@ -0,0 +1,19 @@ +#include "Archimedes.h" + +#include + +class TestNotCurses : public Archimedes::Module { + + public: + TestNotCurses(Archimedes::App*, void*); + ~TestNotCurses(); + void run(); + void onLoad(); + private: + notcurses* ncInstance; +}; + +#ifdef TESTNOTCURSES_DYNAMIC +typedef TestNotCurses mtype; +#include "endModule.h" +#endif