Compare commits

..

33 Commits

Author SHA1 Message Date
c107ce732c start ChessServer and remove basic redundant examples 2025-05-20 17:25:50 -05:00
ad658d914c improve ChatVoice 2025-05-20 16:06:11 -05:00
f6ad110880 add ^ 2025-05-19 14:13:55 -05:00
cb5762a3fe Calculator works 2025-05-18 16:17:14 -05:00
45f1d0f69d Calculator 2025-05-13 15:35:41 -05:00
dffca865dc spellcheck 2025-05-13 08:35:22 -05:00
32223cfa05 Calculator 2025-05-13 01:58:46 -05:00
3196f7b81a buttons 2025-05-12 16:39:34 -05:00
08bccb1e70 lock 2025-05-12 16:36:51 -05:00
2e0341a12e build 2025-05-12 16:35:42 -05:00
b4309ab4e9 reintegration complete 2025-05-12 16:28:27 -05:00
2350592424 ... 2025-05-12 16:26:11 -05:00
9d63e16032 reintegrate modules 2025-05-12 16:24:02 -05:00
501649d236 build 2025-05-12 16:06:25 -05:00
e139696d6a ... 2025-05-12 16:04:21 -05:00
79f4a5288f return of endModule 2025-05-12 15:28:08 -05:00
80e0709278 build 2025-05-12 15:23:44 -05:00
9f1e77cb9e help 2025-05-12 14:59:44 -05:00
d3fe8598cd remove endModule 2025-05-12 14:53:50 -05:00
38e398e367 define 2025-05-12 14:46:19 -05:00
3a82e9b4ec use typedef 2025-05-12 14:32:13 -05:00
5319e2309b build 2025-05-12 14:15:23 -05:00
f86eb4ab90 spellcheck 2025-05-12 14:08:42 -05:00
bab30c6124 include 2025-05-12 14:06:49 -05:00
700e422270 no src 2025-05-12 00:14:11 -05:00
ec4b85587b add extra modules as git submodule 2025-05-11 19:17:33 -05:00
cb56bd302d fix headers? 2025-05-11 14:11:24 -05:00
0e1bae3123 build 2025-05-10 15:08:14 -05:00
7e4fad568b undo 2025-05-10 15:05:31 -05:00
37383c3ed7 try again 2025-05-10 14:58:52 -05:00
045f97e9b0 try something 2025-05-10 14:48:30 -05:00
eac9abc839 move example modules elsewhere 2025-05-10 13:50:58 -05:00
cc5efa8424 work on Audio 2025-05-10 13:40:27 -05:00
52 changed files with 941 additions and 430 deletions

View File

@@ -6,6 +6,8 @@
src = ./.; src = ./.;
outputs = [ "out" "dev" ];
nativeBuildInputs = with pkgs; [ nativeBuildInputs = with pkgs; [
clang clang
]; ];
@@ -24,6 +26,10 @@
installPhase = '' installPhase = ''
mkdir -p $out/bin mkdir -p $out/bin
cp $name $out/bin cp $name $out/bin
mkdir -p $dev/include/modules
cp -r include/* $dev/include
cp -r modules $dev/include/modules
''; '';
}; };
@@ -48,16 +54,16 @@
buildPhase = '' buildPhase = ''
clang++ \ clang++ \
src/example_apps/ImguiEmbed/*.cpp \ src/example_apps/ImguiEmbed/*.cpp \
modules/examples/TestImgui/src/*.cpp \ modules/Archimedes-Modules/TestImgui/*.cpp \
modules/WindowModule/src/*.cpp \ modules/WindowModule/*.cpp \
modules/ImguiModule/src/*.cpp \ modules/ImguiModule/*.cpp \
$imgui/backends/imgui_impl_glfw.cpp \ $imgui/backends/imgui_impl_glfw.cpp \
$imgui/backends/imgui_impl_opengl3.cpp \ $imgui/backends/imgui_impl_opengl3.cpp \
$imgui/misc/cpp/*.cpp \ $imgui/misc/cpp/*.cpp \
$imgui/*.cpp \ $imgui/*.cpp \
-DRENDERER_OPENGL \ -DRENDERER=1 \
-DWINDOW_GLFW \ -DWINDOW=1 \
-I src -I include -I $imgui -I . \ -I include -I $imgui -I . \
-lGL -lglfw -lGLEW \ -lGL -lglfw -lGLEW \
-Wall \ -Wall \
-o $name -o $name
@@ -90,16 +96,16 @@
buildPhase = '' buildPhase = ''
clang++ \ clang++ \
src/example_apps/TerminalEmbed/*.cpp \ src/example_apps/TerminalEmbed/*.cpp \
modules/Terminal/src/*.cpp \ modules/Archimedes-Modules/Terminal/*.cpp \
modules/WindowModule/src/*.cpp \ modules/WindowModule/*.cpp \
modules/ImguiModule/src/*.cpp \ modules/ImguiModule/*.cpp \
$imgui/backends/imgui_impl_glfw.cpp \ $imgui/backends/imgui_impl_glfw.cpp \
$imgui/backends/imgui_impl_opengl3.cpp \ $imgui/backends/imgui_impl_opengl3.cpp \
$imgui/misc/cpp/*.cpp \ $imgui/misc/cpp/*.cpp \
$imgui/*.cpp \ $imgui/*.cpp \
-DRENDERER_OPENGL \ -DRENDERER=1 \
-DWINDOW_GLFW \ -DWINDOW=1 \
-I src -I include -I $imgui -I . \ -I include -I $imgui -I . \
-lGL -lglfw -lGLEW \ -lGL -lglfw -lGLEW \
-Wall \ -Wall \
-o $name -o $name

View File

@@ -12,9 +12,8 @@
buildPhase = '' buildPhase = ''
clang++ \ clang++ \
modules/examples/TestMenu/src/*.cpp \ modules/Archimedes-Modules/TestMenu/*.cpp \
-fpic -shared \ -fpic -shared \
-I src \
-Wall \ -Wall \
-DTESTMENU_DYNAMIC \ -DTESTMENU_DYNAMIC \
-o $name -o $name
@@ -43,9 +42,9 @@
buildPhase = '' buildPhase = ''
clang++ \ clang++ \
modules/examples/TestNotCurses/src/*.cpp \ modules/Archimedes-Modules/TestNotCurses/*.cpp \
-fpic -shared \ -fpic -shared \
-I src -I include \ -I include \
-Wall \ -Wall \
-lnotcurses \ -lnotcurses \
-DTESTNOTCURSES_DYNAMIC \ -DTESTNOTCURSES_DYNAMIC \
@@ -71,9 +70,9 @@
buildPhase = '' buildPhase = ''
clang++ \ clang++ \
modules/examples/Print/src/*.cpp \ modules/Archimedes-Modules/Print/*.cpp \
-fpic -shared \ -fpic -shared \
-I src -I include \ -I include \
-Wall \ -Wall \
-DPRINT_DYNAMIC \ -DPRINT_DYNAMIC \
-o $name -o $name
@@ -98,9 +97,9 @@
buildPhase = '' buildPhase = ''
clang++ \ clang++ \
modules/examples/DependsOnPrint/src/*.cpp \ modules/Archimedes-Modules/DependsOnPrint/*.cpp \
-fpic -shared \ -fpic -shared \
-I src -I include \ -I include \
-Wall \ -Wall \
-DDEPENDSONPRINT_DYNAMIC \ -DDEPENDSONPRINT_DYNAMIC \
-o $name -o $name
@@ -125,10 +124,10 @@
buildPhase = '' buildPhase = ''
clang++ \ clang++ \
modules/examples/DependsOnPrintStatic/src/*.cpp \ modules/Archimedes-Modules/DependsOnPrintStatic/*.cpp \
modules/examples/Print/src/*.cpp \ modules/Archimedes-Modules/Print/*.cpp \
-fpic -shared \ -fpic -shared \
-I src -I include -I . \ -I include -I . \
-DDEPENDSONPRINTSTATIC_DYNAMIC \ -DDEPENDSONPRINTSTATIC_DYNAMIC \
-Wall \ -Wall \
-o $name -o $name
@@ -160,18 +159,61 @@
buildPhase = '' buildPhase = ''
clang++ \ clang++ \
modules/examples/TestImgui/src/*.cpp \ modules/Archimedes-Modules/TestImgui/*.cpp \
modules/WindowModule/src/*.cpp \ modules/WindowModule/*.cpp \
modules/ImguiModule/src/*.cpp \ modules/ImguiModule/*.cpp \
$imgui/backends/imgui_impl_glfw.cpp \ $imgui/backends/imgui_impl_glfw.cpp \
$imgui/backends/imgui_impl_opengl3.cpp \ $imgui/backends/imgui_impl_opengl3.cpp \
$imgui/misc/cpp/*.cpp \ $imgui/misc/cpp/*.cpp \
$imgui/*.cpp \ $imgui/*.cpp \
-DRENDERER_OPENGL \ -DRENDERER=1 \
-DWINDOW_GLFW \ -DWINDOW=1 \
-DTESTIMGUI_DYNAMIC \ -DTESTIMGUI_DYNAMIC \
-fpic -shared \ -fpic -shared \
-I src -I include -I $imgui -I . \ -I include -I $imgui -I . \
-lGL -lglfw -lGLEW \
-Wall \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
Calculator = pkgs.stdenvNoCC.mkDerivation {
name = "Calculator";
src = ./.;
imgui = inputs.imgui;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
glfw
glew
];
buildPhase = ''
clang++ \
modules/Archimedes-Modules/Calculator/*.cpp \
modules/WindowModule/*.cpp \
modules/ImguiModule/*.cpp \
$imgui/backends/imgui_impl_glfw.cpp \
$imgui/backends/imgui_impl_opengl3.cpp \
$imgui/misc/cpp/*.cpp \
$imgui/*.cpp \
-DRENDERER=1 \
-DWINDOW=1 \
-DCALCULATOR_DYNAMIC \
-fpic -shared \
-I include -I $imgui -I . \
-lGL -lglfw -lGLEW \ -lGL -lglfw -lGLEW \
-Wall \ -Wall \
-o $name -o $name
@@ -198,11 +240,11 @@
buildPhase = '' buildPhase = ''
clang++ \ clang++ \
modules/examples/TestClay/src/*.cpp \ modules/Archimedes-Modules/TestClay/*.cpp \
-fpic -shared \ -fpic -shared \
-I src -I include \ -I include \
-DRENDERER_OPENGL \ -DRENDERER=1 \
-DWINDOW_GLFW \ -DWINDOW=1 \
-DTESTCLAY_DYNAMIC \ -DTESTCLAY_DYNAMIC \
-Wall \ -Wall \
-o $name -o $name
@@ -231,11 +273,11 @@
buildPhase = '' buildPhase = ''
clang++ \ clang++ \
modules/examples/ChatServer/src/*.cpp \ modules/Archimedes-Modules/Chat/ChatServer/*.cpp \
modules/ServerModule/src/*.cpp \ modules/ServerModule/*.cpp \
-fpic -shared \ -fpic -shared \
-I ${pkgs.gamenetworkingsockets}/include/GameNetworkingSockets \ -I ${pkgs.gamenetworkingsockets}/include/GameNetworkingSockets \
-I src -I include -I . \ -I include -I . \
-lGameNetworkingSockets \ -lGameNetworkingSockets \
-DCHATSERVER_DYNAMIC \ -DCHATSERVER_DYNAMIC \
-Wall \ -Wall \
@@ -265,11 +307,11 @@
buildPhase = '' buildPhase = ''
clang++ \ clang++ \
modules/examples/ChatServerVoice/src/*.cpp \ modules/Archimedes-Modules/ChatVoice/ChatServerVoice/*.cpp \
modules/ServerModule/src/*.cpp \ modules/ServerModule/*.cpp \
-fpic -shared \ -fpic -shared \
-I ${pkgs.gamenetworkingsockets}/include/GameNetworkingSockets \ -I ${pkgs.gamenetworkingsockets}/include/GameNetworkingSockets \
-I src -I include -I . \ -I include -I . \
-lGameNetworkingSockets \ -lGameNetworkingSockets \
-DCHATSERVERVOICE_DYNAMIC \ -DCHATSERVERVOICE_DYNAMIC \
-Wall \ -Wall \
@@ -303,21 +345,21 @@
buildPhase = '' buildPhase = ''
clang++ \ clang++ \
modules/examples/ChatClient/src/*.cpp \ modules/Archimedes-Modules/Chat/ChatClient/*.cpp \
modules/ClientModule/src/*.cpp \ modules/ClientModule/*.cpp \
-I ${pkgs.gamenetworkingsockets}/include/GameNetworkingSockets \ -I ${pkgs.gamenetworkingsockets}/include/GameNetworkingSockets \
-lGameNetworkingSockets \ -lGameNetworkingSockets \
-DCHATCLIENT_DYNAMIC \ -DCHATCLIENT_DYNAMIC \
modules/WindowModule/src/*.cpp \ modules/WindowModule/*.cpp \
modules/ImguiModule/src/*.cpp \ modules/ImguiModule/*.cpp \
$imgui/backends/imgui_impl_glfw.cpp \ $imgui/backends/imgui_impl_glfw.cpp \
$imgui/backends/imgui_impl_opengl3.cpp \ $imgui/backends/imgui_impl_opengl3.cpp \
$imgui/misc/cpp/*.cpp \ $imgui/misc/cpp/*.cpp \
$imgui/*.cpp \ $imgui/*.cpp \
-DRENDERER_OPENGL \ -DRENDERER=1 \
-DWINDOW_GLFW \ -DWINDOW=1 \
-fpic -shared \ -fpic -shared \
-I src -I include -I $imgui -I . \ -I include -I $imgui -I . \
-lGL -lglfw -lGLEW \ -lGL -lglfw -lGLEW \
-Wall \ -Wall \
-o $name -o $name
@@ -350,13 +392,13 @@
buildPhase = '' buildPhase = ''
clang++ \ clang++ \
modules/examples/ChatClientVoice/src/*.cpp \ modules/Archimedes-Modules/ChatVoice/ChatClientVoice/*.cpp \
modules/ClientModule/src/*.cpp \ modules/ClientModule/*.cpp \
-I ${pkgs.gamenetworkingsockets}/include/GameNetworkingSockets \ -I ${pkgs.gamenetworkingsockets}/include/GameNetworkingSockets \
-lGameNetworkingSockets \ -lGameNetworkingSockets \
-DCHATCLIENTVOICE_DYNAMIC \ -DCHATCLIENTVOICE_DYNAMIC \
modules/WindowModule/src/*.cpp \ modules/WindowModule/*.cpp \
modules/ImguiModule/src/*.cpp \ modules/ImguiModule/*.cpp \
$imgui/backends/imgui_impl_sdl3.cpp \ $imgui/backends/imgui_impl_sdl3.cpp \
$imgui/backends/imgui_impl_opengl3.cpp \ $imgui/backends/imgui_impl_opengl3.cpp \
$imgui/misc/cpp/*.cpp \ $imgui/misc/cpp/*.cpp \
@@ -364,7 +406,7 @@
-DRENDERER=1 \ -DRENDERER=1 \
-DWINDOW=2 \ -DWINDOW=2 \
-fpic -shared \ -fpic -shared \
-I src -I include -I $imgui -I . \ -I include -I $imgui -I . \
-lGL -lSDL3 -lGLEW \ -lGL -lSDL3 -lGLEW \
-Wall \ -Wall \
-o $name -o $name
@@ -376,4 +418,96 @@
''; '';
}; };
Terminal = pkgs.stdenvNoCC.mkDerivation {
name = "Terminal";
src = ./.;
imgui = inputs.imgui;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
glfw
glew
];
buildPhase = ''
clang++ \
modules/Archimedes-Modules/Terminal/*.cpp \
modules/ImguiModule/*.cpp \
modules/WindowModule/*.cpp \
$imgui/backends/imgui_impl_glfw.cpp \
$imgui/backends/imgui_impl_opengl3.cpp \
$imgui/misc/cpp/*.cpp \
$imgui/*.cpp \
-DRENDERER=1 \
-DWINDOW=1 \
-DTERMINAL_DYNAMIC \
-fpic -shared \
-I include -I $imgui -I . \
-lGL -lglfw -lGLEW \
-Wall \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
Ollama = pkgs.stdenvNoCC.mkDerivation {
name = "Ollama";
src = ./.;
imgui = inputs.imgui;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
glfw
glew
curl
nlohmann_json
];
buildPhase = ''
clang++ \
modules/Archimedes-Modules/Ollama/*.cpp \
modules/ImguiModule/*.cpp \
modules/WindowModule/*.cpp \
$imgui/backends/imgui_impl_glfw.cpp \
$imgui/backends/imgui_impl_opengl3.cpp \
$imgui/misc/cpp/*.cpp \
$imgui/*.cpp \
-DRENDERER=1 \
-DWINDOW=1 \
-DOLLAMA_DYNAMIC \
-fpic -shared \
-I include -I $imgui -I . \
-lGL -lglfw -lGLEW \
$(curl-config --cflags) \
$(curl-config --libs) \
-Wall \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
} }

18
flake.lock generated
View File

@@ -3,11 +3,11 @@
"clay": { "clay": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1742509368, "lastModified": 1746753934,
"narHash": "sha256-XSaMuWCADZgZnRaGcBgf+u40O6jS5kkpq3Xruy6z+I0=", "narHash": "sha256-7Kx536YsmPTXUjs/jBknGAmqYsqqDh6T11AlarTeGLM=",
"owner": "nicbarker", "owner": "nicbarker",
"repo": "clay", "repo": "clay",
"rev": "ad49977f1b37ccd7664333181f30f575d08d3838", "rev": "76265e4c3c97ebe5a4aab081d5c5a05e5a979d5d",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -19,11 +19,11 @@
"imgui": { "imgui": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1741968903, "lastModified": 1747034542,
"narHash": "sha256-4L37NRR+dlkhdxuDjhLR45kgjyZK2uelKBlGZ1nQzgY=", "narHash": "sha256-kVbyG7LXXHIOiI6dlZVID9DLErR+XNoAGp/R82TEpgo=",
"owner": "ocornut", "owner": "ocornut",
"repo": "imgui", "repo": "imgui",
"rev": "126d004f9e1eef062bf4b044b3b2faaf58d48c51", "rev": "e33069ce56d07751ca875eb239f41febef0ebcd3",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -35,11 +35,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1742136038, "lastModified": 1746957726,
"narHash": "sha256-DDe16FJk18sadknQKKG/9FbwEro7A57tg9vB5kxZ8kY=", "narHash": "sha256-k9ut1LSfHCr0AW82ttEQzXVCqmyWVA5+SHJkS5ID/Jo=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "a1185f4064c18a5db37c5c84e5638c78b46e3341", "rev": "a39ed32a651fdee6842ec930761e31d1f242cb94",
"type": "github" "type": "github"
}, },
"original": { "original": {

131
flake.nix
View File

@@ -13,7 +13,7 @@
}; };
}; };
outputs = { self, nixpkgs, imgui, clay }@inputs: let outputs = { self, nixpkgs, imgui, clay, ... }@inputs: let
system = "x86_64-linux"; system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; }; pkgs = import nixpkgs { inherit system; };
in { in {
@@ -41,9 +41,9 @@
buildPhase = '' buildPhase = ''
clang++ \ clang++ \
modules/ServerModule/src/*.cpp \ modules/ServerModule/*.cpp \
-fpic -shared \ -fpic -shared \
-I src -I include \ -I include \
-I ${pkgs.gamenetworkingsockets}/include/GameNetworkingSockets \ -I ${pkgs.gamenetworkingsockets}/include/GameNetworkingSockets \
-lGameNetworkingSockets \ -lGameNetworkingSockets \
-DSERVERMODULE_DYNAMIC \ -DSERVERMODULE_DYNAMIC \
@@ -74,9 +74,9 @@
buildPhase = '' buildPhase = ''
clang++ \ clang++ \
modules/ClientModule/src/*.cpp \ modules/ClientModule/*.cpp \
-fpic -shared \ -fpic -shared \
-I src -I include \ -I include \
-I ${pkgs.gamenetworkingsockets}/include/GameNetworkingSockets \ -I ${pkgs.gamenetworkingsockets}/include/GameNetworkingSockets \
-lGameNetworkingSockets \ -lGameNetworkingSockets \
-DCLIENTMODULE_DYNAMIC \ -DCLIENTMODULE_DYNAMIC \
@@ -108,9 +108,9 @@
buildPhase = '' buildPhase = ''
clang++ \ clang++ \
modules/WindowModule/src/*.cpp \ modules/WindowModule/*.cpp \
-fpic -shared \ -fpic -shared \
-I src -I include \ -I include \
-DRENDERER=1 \ -DRENDERER=1 \
-DWINDOW=1 \ -DWINDOW=1 \
-DWINDOWMODULE_DYNAMIC \ -DWINDOWMODULE_DYNAMIC \
@@ -145,8 +145,8 @@
buildPhase = '' buildPhase = ''
clang++ \ clang++ \
modules/ImguiModule/src/*.cpp \ modules/ImguiModule/*.cpp \
modules/WindowModule/src/*.cpp \ modules/WindowModule/*.cpp \
$imgui/backends/imgui_impl_glfw.cpp \ $imgui/backends/imgui_impl_glfw.cpp \
$imgui/backends/imgui_impl_opengl3.cpp \ $imgui/backends/imgui_impl_opengl3.cpp \
$imgui/misc/cpp/*.cpp \ $imgui/misc/cpp/*.cpp \
@@ -156,7 +156,7 @@
-DIMGUIMODULE_DYNAMIC \ -DIMGUIMODULE_DYNAMIC \
-DCUSTOMFONT=${pkgs.fira-code}/share/fonts/truetype/FiraCode-VF.ttf \ -DCUSTOMFONT=${pkgs.fira-code}/share/fonts/truetype/FiraCode-VF.ttf \
-fpic -shared \ -fpic -shared \
-I src -I include -I $imgui -I . \ -I include -I $imgui -I . \
-lGL -lglfw -lGLEW \ -lGL -lglfw -lGLEW \
-Wall \ -Wall \
-o $name -o $name
@@ -168,6 +168,7 @@
''; '';
}; };
MainGUIsdl = pkgs.stdenvNoCC.mkDerivation { MainGUIsdl = pkgs.stdenvNoCC.mkDerivation {
name = "MainGUI"; name = "MainGUI";
@@ -186,9 +187,9 @@
buildPhase = '' buildPhase = ''
clang++ \ clang++ \
modules/MainGUI/src/*.cpp \ modules/MainGUI/*.cpp \
modules/ImguiModule/src/*.cpp \ modules/ImguiModule/*.cpp \
modules/WindowModule/src/*.cpp \ modules/WindowModule/*.cpp \
$imgui/backends/imgui_impl_sdl3.cpp \ $imgui/backends/imgui_impl_sdl3.cpp \
$imgui/backends/imgui_impl_sdlrenderer3.cpp \ $imgui/backends/imgui_impl_sdlrenderer3.cpp \
$imgui/misc/cpp/*.cpp \ $imgui/misc/cpp/*.cpp \
@@ -197,7 +198,7 @@
-DWINDOW=2 \ -DWINDOW=2 \
-DMAINGUI_DYNAMIC \ -DMAINGUI_DYNAMIC \
-fpic -shared \ -fpic -shared \
-I src -I include -I $imgui -I . \ -I include -I $imgui -I . \
-lSDL3 \ -lSDL3 \
-Wall \ -Wall \
-o $name -o $name
@@ -230,9 +231,9 @@
buildPhase = '' buildPhase = ''
clang++ \ clang++ \
modules/MainGUI/src/*.cpp \ modules/MainGUI/*.cpp \
modules/ImguiModule/src/*.cpp \ modules/ImguiModule/*.cpp \
modules/WindowModule/src/*.cpp \ modules/WindowModule/*.cpp \
$imgui/backends/imgui_impl_glfw.cpp \ $imgui/backends/imgui_impl_glfw.cpp \
$imgui/backends/imgui_impl_opengl3.cpp \ $imgui/backends/imgui_impl_opengl3.cpp \
$imgui/misc/cpp/*.cpp \ $imgui/misc/cpp/*.cpp \
@@ -241,7 +242,7 @@
-DWINDOW=1 \ -DWINDOW=1 \
-DMAINGUI_DYNAMIC \ -DMAINGUI_DYNAMIC \
-fpic -shared \ -fpic -shared \
-I src -I include -I $imgui -I . \ -I include -I $imgui -I . \
-lGL -lglfw -lGLEW \ -lGL -lglfw -lGLEW \
-Wall \ -Wall \
-o $name -o $name
@@ -254,101 +255,9 @@
}; };
Terminal = pkgs.stdenvNoCC.mkDerivation {
name = "Terminal";
src = ./.;
inherit imgui;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
glfw
glew
];
buildPhase = ''
clang++ \
modules/Terminal/src/*.cpp \
modules/ImguiModule/src/*.cpp \
modules/WindowModule/src/*.cpp \
$imgui/backends/imgui_impl_glfw.cpp \
$imgui/backends/imgui_impl_opengl3.cpp \
$imgui/misc/cpp/*.cpp \
$imgui/*.cpp \
-DRENDERER=1 \
-DWINDOW=1 \
-DTERMINAL_DYNAMIC \
-fpic -shared \
-I src -I include -I $imgui -I . \
-lGL -lglfw -lGLEW \
-Wall \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
}; };
Ollama = pkgs.stdenvNoCC.mkDerivation { packages.${system}.default = self.Archimedes.examples.MinimalApp;
name = "Ollama";
src = ./.;
inherit imgui;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
glfw
glew
curl
nlohmann_json
];
buildPhase = ''
clang++ \
modules/Ollama/src/*.cpp \
modules/ImguiModule/src/*.cpp \
modules/WindowModule/src/*.cpp \
$imgui/backends/imgui_impl_glfw.cpp \
$imgui/backends/imgui_impl_opengl3.cpp \
$imgui/misc/cpp/*.cpp \
$imgui/*.cpp \
-DRENDERER=1 \
-DWINDOW=1 \
-DOLLAMA_DYNAMIC \
-fpic -shared \
-I src -I include -I $imgui -I . \
-lGL -lglfw -lGLEW \
$(curl-config --cflags) \
$(curl-config --libs) \
-Wall \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
};
packages.${system}.default = self.Archimedes;
apps.${system}.default = { apps.${system}.default = {
type = "app"; type = "app";

View File

@@ -1,12 +1,5 @@
#include "Archimedes.h"
#ifdef MODULE_TYPE
extern "C" { extern "C" {
Archimedes::Module* create(Archimedes::App* app, void* handle) { Archimedes::Module* create(Archimedes::App* app, void* handle) {
return new MODULE_TYPE(app, handle); return new mtype(app, handle);
} }
} }
#undef MODULE_TYPE
#endif

View File

@@ -1,6 +1,8 @@
#ifndef AUDIO_H #ifndef AUDIO_H
#define AUDIO_H #define AUDIO_H
#include "pch.hpp"
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <SDL3/SDL_audio.h> #include <SDL3/SDL_audio.h>
@@ -10,10 +12,38 @@ namespace Archimedes {
public: public:
Audio() {} Audio() {
if(!SDL_Init(SDL_INIT_AUDIO)) {
~Audio() {} std::abort();
}
pDevices = SDL_GetAudioPlaybackDevices(&pDeviceCount);
rDevices = SDL_GetAudioPlaybackDevices(&rDeviceCount);
}
~Audio() {
for(SDL_AudioStream* s : streams) {
DestroyAudioStream(s);
}
SDL_QuitSubsystem(SDL_INIT_AUDIO);
}
private:
SDL_AudioDeviceID* pDevices;
int pDeviceCount = 0;
SDL_AudioDeviceID* rDevices;
int rDeviceCount = 0;
std::vector<SDL_AudioStream*> streams;
std::vector<SDL_AudioSpec> specs;
}; };
} }

View File

@@ -0,0 +1,353 @@
#include "Calculator.h"
#include "modules/ImguiModule/ImguiModule.h"
#include <sstream>
#include <cmath>
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::index(std::string equation, std::unordered_map<unsigned int, std::string>& nodes) {
unsigned int idx = 0;
nodes.clear();
const static std::string operators[] = {
"(",
")",
"^",
"*",
"/",
"+",
"-"
};
for(const std::string& s : operators) {
while(equation.find(s, idx) != std::string::npos) {
int next = equation.find(s, idx);
nodes[next] = equation.substr(next, s.length());
idx = next + s.length();
}
idx = 0;
}
// -3+8*6-(8+4)^9/5
for(unsigned int i = 0; i < equation.length(); i++) {
static unsigned int begin = 0, end = 0;
if(nodes.find(i) == nodes.end()) {
if(nodes.find(i - 1) != nodes.end() || i == 0) {
//first digit of expression
begin = i;
}
if(nodes.find(i + 1) != nodes.end() || i == equation.length() - 1) {
//character after last digit of expression
end = i + 1;
nodes[begin] = equation.substr(begin, end - begin);
nodes[end - 1] = equation.substr(begin, end - begin);
}
}
}
}
double Calculator::evaluate(std::string equation, std::unordered_map<char, std::string>& evalStr) {
char op = '^';
while(equation.find(op) == std::string::npos) {
switch(op) {
case '^':
op = '*';
break;
case '*':
op = '/';
break;
case '/':
op = '+';
break;
case '+':
op = '-';
break;
case '-':
//no operator
if(evalStr.find(equation.front()) != evalStr.end()) {
return evaluate(evalStr[equation.front()], evalStr);
} else {
return std::stod(equation);
}
break;
default:
break;
}
}
//op is now the appropriate operator
//if either term is a placeholder, evaluate and substitute.
double a, b;
if(evalStr.find(equation.front()) != evalStr.end()) {
a = evaluate(evalStr[equation.front()], evalStr);
} else {
if(equation.find(op) == 0 && op == '-') {
a = 0;
} else {
a = std::stod(equation.substr(0, equation.find(op)));
}
}
if(evalStr.find(equation.back()) != evalStr.end()) {
b = evaluate(evalStr[equation.back()], evalStr);
} else {
b = std::stod(equation.substr(equation.find(op) + 1));
}
switch(op) {
case '^':
return pow(a, b);
case '*':
return a * b;
case '/':
return a / b;
case '+':
return a + b;
case '-':
return a - b;
default:
break;
}
}
std::string Calculator::calculate(std::string equation) {
//PEMDAS
while(equation.find(' ') != std::string::npos) {
equation.erase(equation.find(' '), 1);
}
while(equation.find('\t') != std::string::npos) {
equation.erase(equation.find('\t'), 1);
}
while(equation.find('\n') != std::string::npos) {
equation.erase(equation.find('\n'), 1);
}
std::unordered_map<unsigned int, std::string> nodes;
std::unordered_map<char, std::string> evalStr;
std::string eval = "a";
unsigned int idx = 0;
index(equation, nodes);
idx = 0;
// ()
while(equation.find(')', idx) != std::string::npos) {
int end = equation.find(')');
int begin = equation.rfind('(', end);
evalStr[eval.front()] = calculate(equation.substr(begin + 1, (end - begin) - 1));
equation.replace(begin, (end - begin) + 1, eval);
eval.front()++;
idx = end + 1;
}
idx = 0;
index(equation, nodes);
// ^
while(equation.find('^', idx) != std::string::npos) {
int mid = equation.find('^');
int begin = equation.find(nodes[mid - 1] + nodes[mid]);
int end = equation.find(nodes[mid] + nodes[mid + 1], begin) + (nodes[mid] + nodes[mid + 1]).length();
evalStr[eval.front()] = equation.substr(begin, end - begin);
equation.replace(begin, end - begin, eval);
eval.front()++;
idx = end + 1;
}
idx = 0;
index(equation, nodes);
// * or /
while(equation.find('*', idx) != std::string::npos || equation.find('/', idx) != std::string::npos) {
if(equation.find('*', idx) < equation.find('/', idx) && equation.find('*', idx) != std::string::npos) {
int mid = equation.find('*');
int begin = equation.find(nodes[mid - 1] + nodes[mid]);
int end = equation.find(nodes[mid] + nodes[mid + 1], begin) + (nodes[mid] + nodes[mid + 1]).length();
evalStr[eval.front()] = equation.substr(begin, end - begin);
equation.replace(begin, end - begin, eval);
eval.front()++;
idx = end + 1;
} else if(equation.find('/', idx) != std::string::npos) {
int mid = equation.find('/');
int begin = equation.find(nodes[mid - 1] + nodes[mid]);
int end = equation.find(nodes[mid] + nodes[mid + 1], begin) + (nodes[mid] + nodes[mid + 1]).length();
evalStr[eval.front()] = equation.substr(begin, end - begin);
equation.replace(begin, end - begin, eval);
eval.front()++;
idx = end + 1;
}
}
idx = 0;
index(equation, nodes);
// + or -
while(equation.find('+', idx) != std::string::npos || equation.find('-', idx) != std::string::npos) {
if(equation.find('+', idx) < equation.find('-', idx) && equation.find('+', idx) != std::string::npos) {
int mid = equation.find('+');
int begin = equation.find(nodes[mid - 1] + nodes[mid]);
int end = equation.find(nodes[mid] + nodes[mid + 1], begin) + (nodes[mid] + nodes[mid + 1]).length();
evalStr[eval.front()] = equation.substr(begin, end - begin);
equation.replace(begin, end - begin, eval);
eval.front()++;
idx = end + 1;
} else if(equation.find('-', idx) != std::string::npos) {
int mid = equation.find('-');
int begin = mid;
if(nodes.find(mid - 1) != nodes.end()) {
begin = equation.find(nodes[mid - 1] + nodes[mid]);
}
int end = equation.find(nodes[mid] + nodes[mid + 1], begin) + (nodes[mid] + nodes[mid + 1]).length();
evalStr[eval.front()] = equation.substr(begin, end - begin);
equation.replace(begin, end - begin, eval);
eval.front()++;
idx = end + 1;
}
}
return std::to_string(evaluate(equation, evalStr));
}
void Calculator::basicCalculator() {
static bool b = true;
static std::string s;
if(b) {
ImGui::Begin("Basic Calculator", &open);
ImGui::Text("%s", s.c_str());
ImGui::BeginGroup();
{
if(ImGui::Button("AC")) {
s.clear();
}
ImGui::SameLine();
if(ImGui::Button("(")) {
s += " ( ";
}
ImGui::SameLine();
if(ImGui::Button(")")) {
s += " ) ";
}
ImGui::SameLine();
if(ImGui::Button("^")) {
s += " ^ ";
}
ImGui::SameLine();
if(ImGui::Button("=")) {
s = calculate(s);
}
}
ImGui::EndGroup();
ImGui::BeginGroup();
{
for(int i = 1; i < 4; i++) {
ImGui::BeginGroup();
for(int j = 6; j >= 0; j -= 3) {
if(ImGui::Button(std::to_string(i + j).c_str())) {
s += std::to_string(i + j);
}
}
ImGui::EndGroup();
if(i < 3) {
ImGui::SameLine();
}
}
if(ImGui::Button("0")) {
s += "0";
}
ImGui::SameLine();
if(ImGui::Button(".")) {
s += ".";
}
ImGui::SameLine();
if(ImGui::Button("del")) {
if(!s.empty()) {
if(s.back() == ' ') {
s.pop_back();
if(s.back() == '(' || s.back() == ')') {
parenthesis = !parenthesis;
}
s.pop_back();
s.pop_back();
} else {
s.pop_back();
}
}
}
}
ImGui::EndGroup();
ImGui::SameLine();
ImGui::BeginGroup();
if(ImGui::Button("+")) {
s += " + ";
}
if(ImGui::Button("-")) {
s += " - ";
}
if(ImGui::Button("*")) {
s += " * ";
}
if(ImGui::Button("/")) {
s += " / ";
}
ImGui::EndGroup();
ImGui::End();
}
}
void Calculator::graphingCalculator() {
}

View File

@@ -0,0 +1,35 @@
#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;
bool parenthesis = true;
bool graphing = false;
void basicCalculator();
std::string calculate(std::string);
double evaluate(std::string, std::unordered_map<char, std::string>&);
void index(std::string, std::unordered_map<unsigned int, std::string>&);
void graphingCalculator();
};
#ifdef CALCULATOR_DYNAMIC
typedef Calculator mtype;
#include "endModule.h"
#endif

View File

@@ -1,7 +1,7 @@
#include "modules/ImguiModule/src/ImguiModule.h" #include "modules/ImguiModule/ImguiModule.h"
#include "modules/ClientModule/src/ClientModule.h" #include "modules/ClientModule/ClientModule.h"
#include "ChatClient.h" #include "ChatClient.h"

View File

@@ -23,6 +23,6 @@ class ChatClient : public Archimedes::Module {
}; };
#ifdef CHATCLIENT_DYNAMIC #ifdef CHATCLIENT_DYNAMIC
#define MODULE_TYPE ChatClient typedef ChatClient mtype;
#include "endModule.h" #include "endModule.h"
#endif #endif

View File

@@ -1,6 +1,6 @@
#include "Archimedes.h" #include "Archimedes.h"
#include "modules/ServerModule/src/ServerModule.h" #include "modules/ServerModule/ServerModule.h"
class ChatServer : public Archimedes::Module { class ChatServer : public Archimedes::Module {
@@ -29,6 +29,6 @@ class ChatServer : public Archimedes::Module {
}; };
#ifdef CHATSERVER_DYNAMIC #ifdef CHATSERVER_DYNAMIC
#define MODULE_TYPE ChatServer typedef ChatServer mtype;
#include "endModule.h" #include "endModule.h"
#endif #endif

View File

@@ -1,7 +1,7 @@
#include "modules/ImguiModule/src/ImguiModule.h" #include "modules/ImguiModule/ImguiModule.h"
#include "modules/ClientModule/src/ClientModule.h" #include "modules/ClientModule/ClientModule.h"
#include "ChatClientVoice.h" #include "ChatClientVoice.h"
@@ -84,7 +84,8 @@ void ChatClientVoice::run() {
if(cm->isRunning() && cm->isConnected()) { if(cm->isRunning() && cm->isConnected()) {
if(ImGui::Button("Disconnect") && cm->isRunning()) { if(ImGui::Button("Disconnect") && cm->isRunning()) {
cm->stopClient(); cm->sendReliable("srvcmd1", strlen("srvcmd1"));
//cm->stopClient();
} }
} else { } else {
@@ -105,11 +106,16 @@ void ChatClientVoice::run() {
ImGui::SameLine(); ImGui::SameLine();
if(ImGui::Button("send")) { if(ImGui::Button("send")) {
s.insert(s.begin(), 'o'); if(s == "/quit") {
s.insert(s.begin(), ' '); cm->sendReliable("srvcmd1", strlen("srvcmd1"));
s.insert(s.begin(), '0'); cm->stopClient();
s.insert(s.begin(), 'a'); } else if(s == "/shutdown") {
cm->sendReliable("srvcmd2", strlen("srvcmd2"));
//cm->stopClient();
} else {
s.insert(0, "client");
cm->sendReliable(s.c_str(), (uint32) s.length()); cm->sendReliable(s.c_str(), (uint32) s.length());
}
s.clear(); s.clear();
} }
} }
@@ -130,9 +136,6 @@ void ChatClientVoice::run() {
SDL_ClearAudioStream(mic); SDL_ClearAudioStream(mic);
SDL_ResumeAudioStreamDevice(mic); SDL_ResumeAudioStreamDevice(mic);
SDL_SetAudioStreamGain(mic, micVol); SDL_SetAudioStreamGain(mic, micVol);
} else if(!cm->isConnected()) {
SDL_PauseAudioStreamDevice(mic);
SDL_ClearAudioStream(mic);
} }
if(!SDL_AudioStreamDevicePaused(speaker)) { if(!SDL_AudioStreamDevicePaused(speaker)) {
@@ -141,10 +144,6 @@ void ChatClientVoice::run() {
SDL_ClearAudioStream(speaker); SDL_ClearAudioStream(speaker);
SDL_ResumeAudioStreamDevice(speaker); SDL_ResumeAudioStreamDevice(speaker);
SDL_SetAudioStreamGain(speaker, speakerVol); SDL_SetAudioStreamGain(speaker, speakerVol);
} else if(!cm->isConnected()) {
SDL_PauseAudioStreamDevice(speaker);
SDL_ClearAudioStream(speaker);
} }
static int avail = 0; static int avail = 0;
@@ -152,9 +151,10 @@ void ChatClientVoice::run() {
if(micTest) { if(micTest) {
avail = SDL_min(len, SDL_GetAudioStreamAvailable(mic)); avail = SDL_min(len, SDL_GetAudioStreamAvailable(mic));
if(avail > 10) {
avail = SDL_GetAudioStreamData(mic, buf, avail); avail = SDL_GetAudioStreamData(mic, buf, avail);
SDL_PutAudioStreamData(speaker, buf, avail); SDL_PutAudioStreamData(speaker, buf, avail);
}
} else if(cm->isConnected()){ } else if(cm->isConnected()){
// if not testing, send to server. // if not testing, send to server.
@@ -176,6 +176,7 @@ void ChatClientVoice::run() {
bool ChatClientVoice::onEvent(const Archimedes::Event& event) { bool ChatClientVoice::onEvent(const Archimedes::Event& event) {
unsigned int type = app->getEventType(event); unsigned int type = app->getEventType(event);
static ClientModule* cm;
/*if(type == app->getEventType("DataSentEvent")) { /*if(type == app->getEventType("DataSentEvent")) {
//we did this? //we did this?
@@ -186,19 +187,49 @@ bool ChatClientVoice::onEvent(const Archimedes::Event& event) {
Archimedes::DataRecievedEvent& e = (Archimedes::DataRecievedEvent&) event; Archimedes::DataRecievedEvent& e = (Archimedes::DataRecievedEvent&) event;
{ cm = (ClientModule*) moduleInstances[ClientModule()]; }
static std::string s; 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') { if(std::string((const char*)e.msg->m_pData, 6) == "client") {
s = std::string((const char*)e.msg->m_pData + 4, e.msg->m_cbSize - 4); s = std::string((const char*)e.msg->m_pData + 6, e.msg->m_cbSize - 6);
messages += "\n\n" + s; messages += "\n\n" + s;
} else { } else if(std::string((const char*)e.msg->m_pData, 6) == "server") {
s = std::string((const char*)e.msg->m_pData + 6, e.msg->m_cbSize - 6);
int serverCode = stoi(s);
switch(serverCode) {
case 0:
//start voice
SDL_ClearAudioStream(mic);
SDL_ClearAudioStream(speaker);
SDL_ResumeAudioStreamDevice(mic);
SDL_ResumeAudioStreamDevice(speaker);
break;
case 1:
//stop voice and clear
SDL_PauseAudioStreamDevice(mic);
SDL_PauseAudioStreamDevice(speaker);
SDL_ClearAudioStream(mic);
SDL_ClearAudioStream(speaker);
break;
case 2:
//disconnect
cm->stopClient();
break;
default:
break;
}
} else /*if(std::string((const char*)e.msg->m_pData, 6) == "audio:")*/ {
s = "audio data"; s = "audio data";
SDL_PutAudioStreamData(speaker, e.msg->m_pData, e.msg->m_cbSize); SDL_PutAudioStreamData(speaker, e.msg->m_pData, e.msg->m_cbSize);
} }
std::cerr << "Client Recieved: " << s << std::endl; //std::cerr << "Client Recieved: " << s << std::endl;
return true; return true;
} else if(type == app->getEventType("ConnectionStatusChangedEvent")) { } else if(type == app->getEventType("ConnectionStatusChangedEvent")) {
@@ -230,11 +261,6 @@ bool ChatClientVoice::onEvent(const Archimedes::Event& event) {
case k_ESteamNetworkingConnectionState_Connected: case k_ESteamNetworkingConnectionState_Connected:
//OnConnect //OnConnect
SDL_ClearAudioStream(mic);
SDL_ClearAudioStream(speaker);
SDL_ResumeAudioStreamDevice(mic);
SDL_ResumeAudioStreamDevice(speaker);
break; break;
default: default:

View File

@@ -31,6 +31,6 @@ class ChatClientVoice : public Archimedes::Module {
}; };
#ifdef CHATCLIENTVOICE_DYNAMIC #ifdef CHATCLIENTVOICE_DYNAMIC
#define MODULE_TYPE ChatClientVoice typedef ChatClientVoice mtype;
#include "endModule.h" #include "endModule.h"
#endif #endif

View File

@@ -0,0 +1,131 @@
#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);
static ServerModule* sm;
/*if(type == app->getEventType("DataSentEvent")) {
//we did this?
return true;
} else */
if(type == app->getEventType(Archimedes::DataRecievedEvent())) {
{ sm = (ServerModule*) moduleInstances[ServerModule()]; }
Archimedes::DataRecievedEvent& e = (Archimedes::DataRecievedEvent&) event;
static std::string s;
if(std::string((const char*)e.msg->m_pData, 6) == "client") {
s = std::string((const char*)e.msg->m_pData + 6, e.msg->m_cbSize - 6);
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, "client\nMessage sent\n", strlen("client\nMessage sent\n"));
}
} else if(std::string((const char*)e.msg->m_pData, 6) == "srvcmd") {
s = std::string((const char*)e.msg->m_pData + 6, e.msg->m_cbSize - 6);
int cmdCode = stoi(s);
switch(cmdCode) {
case 0:
break;
case 1:
//disconnect
sm->disconnectClient(e.msg->m_conn);
break;
case 2:
for(auto& it : sm->getClients()) {
sm->sendReliable(it.first, "server2", strlen("server2"));
}
sm->stopServer();
app->end();
break;
default:
break;
}
} else /*if(std::string((const char*)e.msg->m_pData, 6) == "audio:")*/ {
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;
{ sm = (ServerModule*) moduleInstances[ServerModule()]; }
unsigned int numClients;
(void)sm->getClients(&numClients);
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:
{
if(numClients < 2) {
for(auto& it : sm->getClients()) {
sm->sendReliable(it.first, "server1", strlen("server1"));
}
}
break;
}
case k_ESteamNetworkingConnectionState_Connecting:
{
break;
}
case k_ESteamNetworkingConnectionState_Connected:
//OnConnect
if(numClients == 2) {
for(auto& it : sm->getClients()) {
sm->sendReliable(it.first, "server0", strlen("server0"));
}
} else if(numClients > 2) {
sm->sendReliable(e.info->m_hConn, "server0", strlen("server0"));
}
break;
default:
// Silences -Wswitch
break;
}
return false;
}
return false;
}

View File

@@ -1,6 +1,6 @@
#include "Archimedes.h" #include "Archimedes.h"
#include "modules/ServerModule/src/ServerModule.h" #include "modules/ServerModule/ServerModule.h"
class ChatServerVoice : public Archimedes::Module { class ChatServerVoice : public Archimedes::Module {
@@ -29,6 +29,6 @@ class ChatServerVoice : public Archimedes::Module {
}; };
#ifdef CHATSERVERVOICE_DYNAMIC #ifdef CHATSERVERVOICE_DYNAMIC
#define MODULE_TYPE ChatServerVoice typedef ChatServerVoice mtype;
#include "endModule.h" #include "endModule.h"
#endif #endif

View File

@@ -0,0 +1,46 @@
#include "ChessServer.h"
void ChessServer::onLoad() {
ServerModule* sm = (ServerModule*) moduleInstances[ServerModule()];
sm->startServer(9932);
}
//void ChessServer::run() {}
bool ChessServer::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);
for(auto& it : sm->getClients()) {
if(it.first != e.msg->m_conn)
sm->sendReliable(it.first, s.c_str(), s.length());
}
return true;
} /*else if(type == app->getEventType("ConnectionStatusChangedEvent")) {
//Archimedes::ConnectionStatusChangedEvent& e = (Archimedes::ConnectionStatusChangedEvent&) event;
return false;
}*/
return false;
}

View File

@@ -0,0 +1,34 @@
#include "Archimedes.h"
#include "modules/ServerModule/ServerModule.h"
class ChessServer : public Archimedes::Module {
public:
ChessServer(Archimedes::App* a, void* h) : Module(a, h) {
name = "ChessServer";
ServerModule* sm = new ServerModule(a, h);
deps[*sm] = sm;
sm->shouldHandleEvents(ServerModule::SMEventEnum::ConnectionStatusChanged | ServerModule::SMEventEnum::DataSent);
}
ChessServer() { name = "ChessServer"; }
~ChessServer() {
if(app) {}
}
void onLoad();
//void run();
bool onEvent(const Archimedes::Event&);
};
#ifdef CHESSSERVER_DYNAMIC
typedef ChessServer mtype;
#include "endModule.h"
#endif

View File

@@ -1,5 +1,5 @@
#include "Ollama.h" #include "Ollama.h"
#include "modules/ImguiModule/src/ImguiModule.h" #include "modules/ImguiModule/ImguiModule.h"
#include <sstream> #include <sstream>

View File

@@ -21,6 +21,6 @@ class Ollama : public Archimedes::Module {
}; };
#ifdef OLLAMA_DYNAMIC #ifdef OLLAMA_DYNAMIC
#define MODULE_TYPE Ollama typedef Ollama mtype;
#include "endModule.h" #include "endModule.h"
#endif #endif

View File

@@ -10,6 +10,6 @@ class Print : public Archimedes::Module {
}; };
#ifdef PRINT_DYNAMIC #ifdef PRINT_DYNAMIC
#define MODULE_TYPE Print typedef Print mtype;
#include "endModule.h" #include "endModule.h"
#endif #endif

View File

@@ -0,0 +1 @@
Example modules for Archimedes

View File

@@ -5,7 +5,7 @@
#include <fcntl.h> #include <fcntl.h>
#include "Terminal.h" #include "Terminal.h"
#include "modules/ImguiModule/src/ImguiModule.h" #include "modules/ImguiModule/ImguiModule.h"
Terminal::Terminal(Archimedes::App* a, void* h) : Archimedes::Module(a, h) { Terminal::Terminal(Archimedes::App* a, void* h) : Archimedes::Module(a, h) {

View File

@@ -16,6 +16,6 @@ class Terminal : public Archimedes::Module {
}; };
#ifdef TERMINAL_DYNAMIC #ifdef TERMINAL_DYNAMIC
#define MODULE_TYPE Terminal typedef Terminal mtype;
#include "endModule.h" #include "endModule.h"
#endif #endif

View File

@@ -1,7 +1,7 @@
#include "Archimedes.h" #include "Archimedes.h"
class TestClay : public Archimedes::GuiModule { class TestClay : public Archimedes::Module {
public: public:
TestClay(void*, Archimedes::App&); TestClay(void*, Archimedes::App&);

View File

@@ -1,5 +1,5 @@
#include "TestImgui.h" #include "TestImgui.h"
#include "modules/ImguiModule/src/ImguiModule.h" #include "modules/ImguiModule/ImguiModule.h"
TestImgui::TestImgui(Archimedes::App* a, void* h) : Archimedes::Module(a, h) { TestImgui::TestImgui(Archimedes::App* a, void* h) : Archimedes::Module(a, h) {

View File

@@ -19,6 +19,6 @@ class TestImgui : public Archimedes::Module {
}; };
#ifdef TESTIMGUI_DYNAMIC #ifdef TESTIMGUI_DYNAMIC
#define MODULE_TYPE TestImgui typedef TestImgui mtype;
#include "endModule.h" #include "endModule.h"
#endif #endif

View File

@@ -14,6 +14,6 @@ class TestNotCurses : public Archimedes::Module {
}; };
#ifdef TESTNOTCURSES_DYNAMIC #ifdef TESTNOTCURSES_DYNAMIC
#define MODULE_TYPE TestNotCurses typedef TestNotCurses mtype;
#include "endModule.h" #include "endModule.h"
#endif #endif

View File

@@ -68,6 +68,6 @@ class ClientModule : public Archimedes::Module {
}; };
#ifdef CLIENTMODULE_DYNAMIC #ifdef CLIENTMODULE_DYNAMIC
#define MODULE_TYPE ClientModule typedef ClientModule mtype;
#include "endModule.h" #include "endModule.h"
#endif #endif

View File

@@ -4,7 +4,7 @@
#include "imgui.h" #include "imgui.h"
#include "misc/cpp/imgui_stdlib.h" #include "misc/cpp/imgui_stdlib.h"
#include "modules/WindowModule/src/WindowModule.h" #include "modules/WindowModule/WindowModule.h"
#if RENDERER == 1 #if RENDERER == 1
@@ -106,7 +106,7 @@ class ImguiModule : public Archimedes::Module {
}; };
#ifdef IMGUIMODULE_DYNAMIC #ifdef IMGUIMODULE_DYNAMIC
#define MODULE_TYPE ImguiModule typedef ImguiModule mtype;
#include "endModule.h" #include "endModule.h"
#endif #endif

View File

@@ -1,5 +1,5 @@
#include "MainGUI.h" #include "MainGUI.h"
#include "modules/ImguiModule/src/ImguiModule.h" #include "modules/ImguiModule/ImguiModule.h"
MainGUI::MainGUI(Archimedes::App* a, void* h) : Archimedes::Module(a, h) { MainGUI::MainGUI(Archimedes::App* a, void* h) : Archimedes::Module(a, h) {

View File

@@ -17,6 +17,6 @@ class MainGUI : public Archimedes::Module {
}; };
#ifdef MAINGUI_DYNAMIC #ifdef MAINGUI_DYNAMIC
#define MODULE_TYPE MainGUI typedef MainGUI mtype;
#include "endModule.h" #include "endModule.h"
#endif #endif

View File

@@ -52,7 +52,12 @@ class ServerModule : public Archimedes::Module {
} }
} }
std::map<HSteamNetConnection, unsigned int> getClients() const { return clients; } std::map<HSteamNetConnection, unsigned int> getClients(unsigned int* num = nullptr) const {
if(num) {
*num = numClients;
}
return clients;
}
void pollIncomingData(); void pollIncomingData();
@@ -88,7 +93,7 @@ class ServerModule : public Archimedes::Module {
}; };
#ifdef SERVERMODULE_DYNAMIC #ifdef SERVERMODULE_DYNAMIC
#define MODULE_TYPE ServerModule typedef ServerModule mtype;
#include "endModule.h" #include "endModule.h"
#endif #endif

View File

@@ -80,7 +80,7 @@ class WindowModule : public Archimedes::Module {
#ifdef WINDOWMODULE_DYNAMIC #ifdef WINDOWMODULE_DYNAMIC
#define MODULE_TYPE WindowModule typedef WindowModule mtype;
#include "endModule.h" #include "endModule.h"
#endif #endif

View File

@@ -1,68 +0,0 @@
#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;
}

View File

@@ -1,16 +0,0 @@
#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));
}

View File

@@ -1,16 +0,0 @@
#include "Archimedes.h"
class DependsOnPrint : public Archimedes::Module {
public:
DependsOnPrint(Archimedes::App*, void*);
~DependsOnPrint();
void run();
void onLoad() {}
};
#ifdef DEPENDSONPRINT_DYNAMIC
#define MODULE_TYPE DependsOnPrint
#include "endModule.h"
#endif

View File

@@ -1,19 +0,0 @@
#include "DependsOnPrintStatic.h"
#include "modules/examples/Print/src/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));
}

View File

@@ -1,16 +0,0 @@
#include "Archimedes.h"
class DependsOnPrintStatic : public Archimedes::Module {
public:
DependsOnPrintStatic(Archimedes::App*, void*);
~DependsOnPrintStatic();
void run();
void onLoad() {}
};
#ifdef DEPENDSONPRINTSTATIC_DYNAMIC
#define MODULE_TYPE DependsOnPrintStatic
#include "endModule.h"
#endif

View File

@@ -1,37 +0,0 @@
#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;
}
}

View File

@@ -1,20 +0,0 @@
#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
#define MODULE_TYPE TestMenu
#include "endModule.h"
#endif

View File

@@ -1,7 +1,7 @@
#define ENTRYPOINT #define ENTRYPOINT
#include "Archimedes.h" #include "Archimedes.h"
#include "modules/examples/TestImgui/src/TestImgui.h" #include "modules/Archimedes-Modules/TestImgui/TestImgui.h"
class ImguiEmbed : public Archimedes::App { class ImguiEmbed : public Archimedes::App {

View File

@@ -1,7 +1,7 @@
#define ENTRYPOINT #define ENTRYPOINT
#include "Archimedes.h" #include "Archimedes.h"
#include "modules/Terminal/src/Terminal.h" #include "modules/Archimedes-Modules/Terminal/Terminal.h"
class TerminalEmbed : public Archimedes::App { class TerminalEmbed : public Archimedes::App {