Compare commits
43 Commits
b8654659c7
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| c107ce732c | |||
| ad658d914c | |||
| f6ad110880 | |||
| cb5762a3fe | |||
| 45f1d0f69d | |||
| dffca865dc | |||
| 32223cfa05 | |||
| 3196f7b81a | |||
| 08bccb1e70 | |||
| 2e0341a12e | |||
| b4309ab4e9 | |||
| 2350592424 | |||
| 9d63e16032 | |||
| 501649d236 | |||
| e139696d6a | |||
| 79f4a5288f | |||
| 80e0709278 | |||
| 9f1e77cb9e | |||
| d3fe8598cd | |||
| 38e398e367 | |||
| 3a82e9b4ec | |||
| 5319e2309b | |||
| f86eb4ab90 | |||
| bab30c6124 | |||
| 700e422270 | |||
| ec4b85587b | |||
| cb56bd302d | |||
| 0e1bae3123 | |||
| 7e4fad568b | |||
| 37383c3ed7 | |||
| 045f97e9b0 | |||
| eac9abc839 | |||
| cc5efa8424 | |||
| 53695cbc60 | |||
| 101fcf4781 | |||
| 421bf37b75 | |||
| 2182abc714 | |||
| b8fba92ea7 | |||
| 21d07cab07 | |||
| 3198b91ebc | |||
| 62b7618ff4 | |||
| 03213c2c15 | |||
| 0fb63352a2 |
@@ -6,6 +6,8 @@
|
||||
|
||||
src = ./.;
|
||||
|
||||
outputs = [ "out" "dev" ];
|
||||
|
||||
nativeBuildInputs = with pkgs; [
|
||||
clang
|
||||
];
|
||||
@@ -19,12 +21,16 @@
|
||||
-I src -I include \
|
||||
-Wall \
|
||||
-o $name
|
||||
'';
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $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 = ''
|
||||
clang++ \
|
||||
src/example_apps/ImguiEmbed/*.cpp \
|
||||
modules/examples/TestImgui/src/*.cpp \
|
||||
modules/WindowModule/src/*.cpp \
|
||||
modules/ImguiModule/src/*.cpp \
|
||||
modules/Archimedes-Modules/TestImgui/*.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_OPENGL \
|
||||
-DWINDOW_GLFW \
|
||||
-I src -I include -I $imgui -I . \
|
||||
-DRENDERER=1 \
|
||||
-DWINDOW=1 \
|
||||
-I include -I $imgui -I . \
|
||||
-lGL -lglfw -lGLEW \
|
||||
-Wall \
|
||||
-o $name
|
||||
@@ -90,16 +96,16 @@
|
||||
buildPhase = ''
|
||||
clang++ \
|
||||
src/example_apps/TerminalEmbed/*.cpp \
|
||||
modules/Terminal/src/*.cpp \
|
||||
modules/WindowModule/src/*.cpp \
|
||||
modules/ImguiModule/src/*.cpp \
|
||||
modules/Archimedes-Modules/Terminal/*.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_OPENGL \
|
||||
-DWINDOW_GLFW \
|
||||
-I src -I include -I $imgui -I . \
|
||||
-DRENDERER=1 \
|
||||
-DWINDOW=1 \
|
||||
-I include -I $imgui -I . \
|
||||
-lGL -lglfw -lGLEW \
|
||||
-Wall \
|
||||
-o $name
|
||||
|
||||
@@ -12,9 +12,8 @@
|
||||
|
||||
buildPhase = ''
|
||||
clang++ \
|
||||
modules/examples/TestMenu/src/*.cpp \
|
||||
modules/Archimedes-Modules/TestMenu/*.cpp \
|
||||
-fpic -shared \
|
||||
-I src \
|
||||
-Wall \
|
||||
-DTESTMENU_DYNAMIC \
|
||||
-o $name
|
||||
@@ -43,9 +42,9 @@
|
||||
|
||||
buildPhase = ''
|
||||
clang++ \
|
||||
modules/examples/TestNotCurses/src/*.cpp \
|
||||
modules/Archimedes-Modules/TestNotCurses/*.cpp \
|
||||
-fpic -shared \
|
||||
-I src -I include \
|
||||
-I include \
|
||||
-Wall \
|
||||
-lnotcurses \
|
||||
-DTESTNOTCURSES_DYNAMIC \
|
||||
@@ -71,9 +70,9 @@
|
||||
|
||||
buildPhase = ''
|
||||
clang++ \
|
||||
modules/examples/Print/src/*.cpp \
|
||||
modules/Archimedes-Modules/Print/*.cpp \
|
||||
-fpic -shared \
|
||||
-I src -I include \
|
||||
-I include \
|
||||
-Wall \
|
||||
-DPRINT_DYNAMIC \
|
||||
-o $name
|
||||
@@ -98,9 +97,9 @@
|
||||
|
||||
buildPhase = ''
|
||||
clang++ \
|
||||
modules/examples/DependsOnPrint/src/*.cpp \
|
||||
modules/Archimedes-Modules/DependsOnPrint/*.cpp \
|
||||
-fpic -shared \
|
||||
-I src -I include \
|
||||
-I include \
|
||||
-Wall \
|
||||
-DDEPENDSONPRINT_DYNAMIC \
|
||||
-o $name
|
||||
@@ -125,10 +124,10 @@
|
||||
|
||||
buildPhase = ''
|
||||
clang++ \
|
||||
modules/examples/DependsOnPrintStatic/src/*.cpp \
|
||||
modules/examples/Print/src/*.cpp \
|
||||
modules/Archimedes-Modules/DependsOnPrintStatic/*.cpp \
|
||||
modules/Archimedes-Modules/Print/*.cpp \
|
||||
-fpic -shared \
|
||||
-I src -I include -I . \
|
||||
-I include -I . \
|
||||
-DDEPENDSONPRINTSTATIC_DYNAMIC \
|
||||
-Wall \
|
||||
-o $name
|
||||
@@ -160,18 +159,61 @@
|
||||
|
||||
buildPhase = ''
|
||||
clang++ \
|
||||
modules/examples/TestImgui/src/*.cpp \
|
||||
modules/WindowModule/src/*.cpp \
|
||||
modules/ImguiModule/src/*.cpp \
|
||||
modules/Archimedes-Modules/TestImgui/*.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_OPENGL \
|
||||
-DWINDOW_GLFW \
|
||||
-DRENDERER=1 \
|
||||
-DWINDOW=1 \
|
||||
-DTESTIMGUI_DYNAMIC \
|
||||
-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 \
|
||||
-Wall \
|
||||
-o $name
|
||||
@@ -198,11 +240,11 @@
|
||||
|
||||
buildPhase = ''
|
||||
clang++ \
|
||||
modules/examples/TestClay/src/*.cpp \
|
||||
modules/Archimedes-Modules/TestClay/*.cpp \
|
||||
-fpic -shared \
|
||||
-I src -I include \
|
||||
-DRENDERER_OPENGL \
|
||||
-DWINDOW_GLFW \
|
||||
-I include \
|
||||
-DRENDERER=1 \
|
||||
-DWINDOW=1 \
|
||||
-DTESTCLAY_DYNAMIC \
|
||||
-Wall \
|
||||
-o $name
|
||||
@@ -231,11 +273,11 @@
|
||||
|
||||
buildPhase = ''
|
||||
clang++ \
|
||||
modules/examples/ChatServer/src/*.cpp \
|
||||
modules/ServerModule/src/*.cpp \
|
||||
modules/Archimedes-Modules/Chat/ChatServer/*.cpp \
|
||||
modules/ServerModule/*.cpp \
|
||||
-fpic -shared \
|
||||
-I ${pkgs.gamenetworkingsockets}/include/GameNetworkingSockets \
|
||||
-I src -I include -I . \
|
||||
-I include -I . \
|
||||
-lGameNetworkingSockets \
|
||||
-DCHATSERVER_DYNAMIC \
|
||||
-Wall \
|
||||
@@ -249,6 +291,40 @@
|
||||
|
||||
};
|
||||
|
||||
ChatServerVoice = pkgs.stdenvNoCC.mkDerivation {
|
||||
|
||||
name = "ChatServerVoice";
|
||||
|
||||
src = ./.;
|
||||
|
||||
nativeBuildInputs = with pkgs; [
|
||||
clang
|
||||
];
|
||||
|
||||
buildInputs = with pkgs; [
|
||||
gamenetworkingsockets
|
||||
];
|
||||
|
||||
buildPhase = ''
|
||||
clang++ \
|
||||
modules/Archimedes-Modules/ChatVoice/ChatServerVoice/*.cpp \
|
||||
modules/ServerModule/*.cpp \
|
||||
-fpic -shared \
|
||||
-I ${pkgs.gamenetworkingsockets}/include/GameNetworkingSockets \
|
||||
-I include -I . \
|
||||
-lGameNetworkingSockets \
|
||||
-DCHATSERVERVOICE_DYNAMIC \
|
||||
-Wall \
|
||||
-o $name
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp $name $out/bin
|
||||
'';
|
||||
|
||||
};
|
||||
|
||||
ChatClient = pkgs.stdenvNoCC.mkDerivation {
|
||||
|
||||
name = "ChatClient";
|
||||
@@ -269,21 +345,21 @@
|
||||
|
||||
buildPhase = ''
|
||||
clang++ \
|
||||
modules/examples/ChatClient/src/*.cpp \
|
||||
modules/ClientModule/src/*.cpp \
|
||||
modules/Archimedes-Modules/Chat/ChatClient/*.cpp \
|
||||
modules/ClientModule/*.cpp \
|
||||
-I ${pkgs.gamenetworkingsockets}/include/GameNetworkingSockets \
|
||||
-lGameNetworkingSockets \
|
||||
-DCHATCLIENT_DYNAMIC \
|
||||
modules/WindowModule/src/*.cpp \
|
||||
modules/ImguiModule/src/*.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_OPENGL \
|
||||
-DWINDOW_GLFW \
|
||||
-DRENDERER=1 \
|
||||
-DWINDOW=1 \
|
||||
-fpic -shared \
|
||||
-I src -I include -I $imgui -I . \
|
||||
-I include -I $imgui -I . \
|
||||
-lGL -lglfw -lGLEW \
|
||||
-Wall \
|
||||
-o $name
|
||||
@@ -295,4 +371,143 @@
|
||||
'';
|
||||
|
||||
};
|
||||
|
||||
ChatClientVoice = pkgs.stdenvNoCC.mkDerivation {
|
||||
|
||||
name = "ChatClientVoice";
|
||||
|
||||
src = ./.;
|
||||
|
||||
imgui = inputs.imgui;
|
||||
|
||||
nativeBuildInputs = with pkgs; [
|
||||
clang
|
||||
];
|
||||
|
||||
buildInputs = with pkgs; [
|
||||
gamenetworkingsockets
|
||||
sdl3
|
||||
glew
|
||||
];
|
||||
|
||||
buildPhase = ''
|
||||
clang++ \
|
||||
modules/Archimedes-Modules/ChatVoice/ChatClientVoice/*.cpp \
|
||||
modules/ClientModule/*.cpp \
|
||||
-I ${pkgs.gamenetworkingsockets}/include/GameNetworkingSockets \
|
||||
-lGameNetworkingSockets \
|
||||
-DCHATCLIENTVOICE_DYNAMIC \
|
||||
modules/WindowModule/*.cpp \
|
||||
modules/ImguiModule/*.cpp \
|
||||
$imgui/backends/imgui_impl_sdl3.cpp \
|
||||
$imgui/backends/imgui_impl_opengl3.cpp \
|
||||
$imgui/misc/cpp/*.cpp \
|
||||
$imgui/*.cpp \
|
||||
-DRENDERER=1 \
|
||||
-DWINDOW=2 \
|
||||
-fpic -shared \
|
||||
-I include -I $imgui -I . \
|
||||
-lGL -lSDL3 -lGLEW \
|
||||
-Wall \
|
||||
-o $name
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp $name $out/bin
|
||||
'';
|
||||
|
||||
};
|
||||
|
||||
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
18
flake.lock
generated
@@ -3,11 +3,11 @@
|
||||
"clay": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1742509368,
|
||||
"narHash": "sha256-XSaMuWCADZgZnRaGcBgf+u40O6jS5kkpq3Xruy6z+I0=",
|
||||
"lastModified": 1746753934,
|
||||
"narHash": "sha256-7Kx536YsmPTXUjs/jBknGAmqYsqqDh6T11AlarTeGLM=",
|
||||
"owner": "nicbarker",
|
||||
"repo": "clay",
|
||||
"rev": "ad49977f1b37ccd7664333181f30f575d08d3838",
|
||||
"rev": "76265e4c3c97ebe5a4aab081d5c5a05e5a979d5d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -19,11 +19,11 @@
|
||||
"imgui": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1741968903,
|
||||
"narHash": "sha256-4L37NRR+dlkhdxuDjhLR45kgjyZK2uelKBlGZ1nQzgY=",
|
||||
"lastModified": 1747034542,
|
||||
"narHash": "sha256-kVbyG7LXXHIOiI6dlZVID9DLErR+XNoAGp/R82TEpgo=",
|
||||
"owner": "ocornut",
|
||||
"repo": "imgui",
|
||||
"rev": "126d004f9e1eef062bf4b044b3b2faaf58d48c51",
|
||||
"rev": "e33069ce56d07751ca875eb239f41febef0ebcd3",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -35,11 +35,11 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1742136038,
|
||||
"narHash": "sha256-DDe16FJk18sadknQKKG/9FbwEro7A57tg9vB5kxZ8kY=",
|
||||
"lastModified": 1746957726,
|
||||
"narHash": "sha256-k9ut1LSfHCr0AW82ttEQzXVCqmyWVA5+SHJkS5ID/Jo=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "a1185f4064c18a5db37c5c84e5638c78b46e3341",
|
||||
"rev": "a39ed32a651fdee6842ec930761e31d1f242cb94",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
138
flake.nix
138
flake.nix
@@ -13,7 +13,7 @@
|
||||
};
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, imgui, clay }@inputs: let
|
||||
outputs = { self, nixpkgs, imgui, clay, ... }@inputs: let
|
||||
system = "x86_64-linux";
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
in {
|
||||
@@ -41,9 +41,9 @@
|
||||
|
||||
buildPhase = ''
|
||||
clang++ \
|
||||
modules/ServerModule/src/*.cpp \
|
||||
modules/ServerModule/*.cpp \
|
||||
-fpic -shared \
|
||||
-I src -I include \
|
||||
-I include \
|
||||
-I ${pkgs.gamenetworkingsockets}/include/GameNetworkingSockets \
|
||||
-lGameNetworkingSockets \
|
||||
-DSERVERMODULE_DYNAMIC \
|
||||
@@ -74,9 +74,9 @@
|
||||
|
||||
buildPhase = ''
|
||||
clang++ \
|
||||
modules/ClientModule/src/*.cpp \
|
||||
modules/ClientModule/*.cpp \
|
||||
-fpic -shared \
|
||||
-I src -I include \
|
||||
-I include \
|
||||
-I ${pkgs.gamenetworkingsockets}/include/GameNetworkingSockets \
|
||||
-lGameNetworkingSockets \
|
||||
-DCLIENTMODULE_DYNAMIC \
|
||||
@@ -108,9 +108,9 @@
|
||||
|
||||
buildPhase = ''
|
||||
clang++ \
|
||||
modules/WindowModule/src/*.cpp \
|
||||
modules/WindowModule/*.cpp \
|
||||
-fpic -shared \
|
||||
-I src -I include \
|
||||
-I include \
|
||||
-DRENDERER=1 \
|
||||
-DWINDOW=1 \
|
||||
-DWINDOWMODULE_DYNAMIC \
|
||||
@@ -145,8 +145,8 @@
|
||||
|
||||
buildPhase = ''
|
||||
clang++ \
|
||||
modules/ImguiModule/src/*.cpp \
|
||||
modules/WindowModule/src/*.cpp \
|
||||
modules/ImguiModule/*.cpp \
|
||||
modules/WindowModule/*.cpp \
|
||||
$imgui/backends/imgui_impl_glfw.cpp \
|
||||
$imgui/backends/imgui_impl_opengl3.cpp \
|
||||
$imgui/misc/cpp/*.cpp \
|
||||
@@ -156,7 +156,7 @@
|
||||
-DIMGUIMODULE_DYNAMIC \
|
||||
-DCUSTOMFONT=${pkgs.fira-code}/share/fonts/truetype/FiraCode-VF.ttf \
|
||||
-fpic -shared \
|
||||
-I src -I include -I $imgui -I . \
|
||||
-I include -I $imgui -I . \
|
||||
-lGL -lglfw -lGLEW \
|
||||
-Wall \
|
||||
-o $name
|
||||
@@ -168,6 +168,7 @@
|
||||
'';
|
||||
|
||||
};
|
||||
|
||||
MainGUIsdl = pkgs.stdenvNoCC.mkDerivation {
|
||||
|
||||
name = "MainGUI";
|
||||
@@ -182,24 +183,23 @@
|
||||
|
||||
buildInputs = with pkgs; [
|
||||
sdl3
|
||||
glew
|
||||
];
|
||||
|
||||
buildPhase = ''
|
||||
clang++ \
|
||||
modules/MainGUI/src/*.cpp \
|
||||
modules/ImguiModule/src/*.cpp \
|
||||
modules/WindowModule/src/*.cpp \
|
||||
modules/MainGUI/*.cpp \
|
||||
modules/ImguiModule/*.cpp \
|
||||
modules/WindowModule/*.cpp \
|
||||
$imgui/backends/imgui_impl_sdl3.cpp \
|
||||
$imgui/backends/imgui_impl_opengl3.cpp \
|
||||
$imgui/backends/imgui_impl_sdlrenderer3.cpp \
|
||||
$imgui/misc/cpp/*.cpp \
|
||||
$imgui/*.cpp \
|
||||
-DRENDERER=1 \
|
||||
-DRENDERER=2 \
|
||||
-DWINDOW=2 \
|
||||
-DMAINGUI_DYNAMIC \
|
||||
-fpic -shared \
|
||||
-I src -I include -I $imgui -I . \
|
||||
-lGL -lSDL3 -lGLEW \
|
||||
-I include -I $imgui -I . \
|
||||
-lSDL3 \
|
||||
-Wall \
|
||||
-o $name
|
||||
'';
|
||||
@@ -231,9 +231,9 @@
|
||||
|
||||
buildPhase = ''
|
||||
clang++ \
|
||||
modules/MainGUI/src/*.cpp \
|
||||
modules/ImguiModule/src/*.cpp \
|
||||
modules/WindowModule/src/*.cpp \
|
||||
modules/MainGUI/*.cpp \
|
||||
modules/ImguiModule/*.cpp \
|
||||
modules/WindowModule/*.cpp \
|
||||
$imgui/backends/imgui_impl_glfw.cpp \
|
||||
$imgui/backends/imgui_impl_opengl3.cpp \
|
||||
$imgui/misc/cpp/*.cpp \
|
||||
@@ -242,7 +242,7 @@
|
||||
-DWINDOW=1 \
|
||||
-DMAINGUI_DYNAMIC \
|
||||
-fpic -shared \
|
||||
-I src -I include -I $imgui -I . \
|
||||
-I include -I $imgui -I . \
|
||||
-lGL -lglfw -lGLEW \
|
||||
-Wall \
|
||||
-o $name
|
||||
@@ -255,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 {
|
||||
|
||||
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;
|
||||
packages.${system}.default = self.Archimedes.examples.MinimalApp;
|
||||
|
||||
apps.${system}.default = {
|
||||
type = "app";
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
#include "Archimedes.h"
|
||||
|
||||
#ifdef MODULE_TYPE
|
||||
|
||||
extern "C" {
|
||||
Archimedes::Module* create(Archimedes::App* app, void* handle) {
|
||||
return new MODULE_TYPE(app, handle);
|
||||
return new mtype(app, handle);
|
||||
}
|
||||
}
|
||||
|
||||
#undef MODULE_TYPE
|
||||
#endif
|
||||
|
||||
51
include/utils/Audio/Audio.h
Normal file
51
include/utils/Audio/Audio.h
Normal file
@@ -0,0 +1,51 @@
|
||||
#ifndef AUDIO_H
|
||||
#define AUDIO_H
|
||||
|
||||
#include "pch.hpp"
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_audio.h>
|
||||
|
||||
namespace Archimedes {
|
||||
|
||||
class Audio {
|
||||
|
||||
public:
|
||||
|
||||
Audio() {
|
||||
if(!SDL_Init(SDL_INIT_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;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "pch.hpp"
|
||||
#include "RendererOpenGL/RendererOpenGL.h"
|
||||
#include "RendererSDL3/RendererSDL3.h"
|
||||
|
||||
namespace Archimedes {
|
||||
class Renderer {
|
||||
@@ -12,7 +13,7 @@ namespace Archimedes {
|
||||
|
||||
~Renderer() {}
|
||||
|
||||
bool init() { return r.init(); }
|
||||
bool init(void* ptr) { return r.init(ptr); }
|
||||
|
||||
void render() {
|
||||
r.render(rc, w, h);
|
||||
@@ -22,6 +23,8 @@ namespace Archimedes {
|
||||
return rc;
|
||||
}
|
||||
|
||||
RendererImpl& getRendererImpl() { return r; }
|
||||
|
||||
private:
|
||||
std::list<std::function<void()>> rc;
|
||||
RendererImpl r;
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Archimedes {
|
||||
RendererOpenGL() {};
|
||||
~RendererOpenGL() {};
|
||||
|
||||
bool init() {
|
||||
bool init(void* p) {
|
||||
return glewInit() == GLEW_OK;
|
||||
};
|
||||
|
||||
|
||||
49
include/utils/Renderer/RendererSDL3/RendererSDL3.h
Normal file
49
include/utils/Renderer/RendererSDL3/RendererSDL3.h
Normal file
@@ -0,0 +1,49 @@
|
||||
#if RENDERER == 2
|
||||
|
||||
#ifndef RENDERER_SDL3
|
||||
#define RENDERER_SDL3
|
||||
|
||||
#include "pch.hpp"
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
|
||||
namespace Archimedes {
|
||||
|
||||
class RendererSDL3 {
|
||||
|
||||
public:
|
||||
typedef void renderCmd();
|
||||
|
||||
RendererSDL3() {};
|
||||
~RendererSDL3() { SDL_DestroyRenderer(renderer); };
|
||||
|
||||
bool init(void* window) {
|
||||
renderer = SDL_CreateRenderer((SDL_Window*) window, nullptr);
|
||||
SDL_SetRenderVSync(renderer, 1);
|
||||
return renderer != nullptr;
|
||||
};
|
||||
|
||||
void render(std::list<std::function<void()>> cmdList, int& w, int& h) {
|
||||
|
||||
//SDL_SetRenderScale(renderer, w, h);
|
||||
|
||||
SDL_RenderClear(renderer);
|
||||
|
||||
for(auto f : cmdList)
|
||||
f();
|
||||
|
||||
SDL_RenderPresent(renderer);
|
||||
}
|
||||
|
||||
SDL_Renderer* renderer = nullptr;
|
||||
};
|
||||
|
||||
typedef RendererSDL3 RendererImpl;
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -25,11 +25,11 @@ namespace Archimedes {
|
||||
|
||||
void doFrame() {
|
||||
|
||||
window.pollEvents();
|
||||
|
||||
renderer->render();
|
||||
|
||||
window.doFrame();
|
||||
|
||||
window.pollEvents();
|
||||
}
|
||||
|
||||
Renderer* getRenderer() { return renderer; }
|
||||
|
||||
@@ -9,12 +9,63 @@
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#if RENDERER == 2
|
||||
|
||||
#include <SDL3/SDL_opengl.h>
|
||||
|
||||
#endif
|
||||
|
||||
namespace Archimedes {
|
||||
|
||||
class Window;
|
||||
|
||||
static bool EventCallback(void* ptr, SDL_Event* e) {
|
||||
|
||||
WindowData& data = *(WindowData*) ptr;
|
||||
|
||||
switch(e->type) {
|
||||
|
||||
case SDL_EVENT_WINDOW_CLOSE_REQUESTED:
|
||||
case SDL_EVENT_QUIT:
|
||||
data.sendEvent(new CloseWindowEvent(data.window, e));
|
||||
break;
|
||||
case SDL_EVENT_WINDOW_RESIZED:
|
||||
data.sendEvent(new ResizeWindowEvent(e->window.data1, e->window.data2, e));
|
||||
break;
|
||||
case SDL_EVENT_WINDOW_MOUSE_ENTER:
|
||||
case SDL_EVENT_WINDOW_FOCUS_GAINED:
|
||||
data.sendEvent(new FocusedWindowEvent(data.window, e));
|
||||
break;
|
||||
case SDL_EVENT_WINDOW_MOUSE_LEAVE:
|
||||
case SDL_EVENT_WINDOW_FOCUS_LOST:
|
||||
data.sendEvent(new FocusLostWindowEvent(data.window, e));
|
||||
break;
|
||||
case SDL_EVENT_KEY_DOWN:
|
||||
data.sendEvent(new KeyPressedWindowEvent(e->key.key, e->key.repeat ? 1 : 0, e));
|
||||
break;
|
||||
case SDL_EVENT_KEY_UP:
|
||||
data.sendEvent(new KeyReleasedWindowEvent(e->key.key, e));
|
||||
break;
|
||||
case SDL_EVENT_MOUSE_MOTION:
|
||||
data.sendEvent(new MouseMovedWindowEvent(e->motion.x, e->motion.y, e));
|
||||
break;
|
||||
case SDL_EVENT_MOUSE_BUTTON_DOWN:
|
||||
data.sendEvent(new MouseButtonPressedWindowEvent(e->button.button, e));
|
||||
break;
|
||||
case SDL_EVENT_MOUSE_BUTTON_UP:
|
||||
data.sendEvent(new MouseButtonReleasedWindowEvent(e->button.button, e));
|
||||
break;
|
||||
case SDL_EVENT_MOUSE_WHEEL:
|
||||
data.sendEvent(new ScrollWindowEvent(e->wheel.x, e->wheel.y, e));
|
||||
break;
|
||||
default:
|
||||
data.sendEvent(new AnonymousEvent(e));
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
class WindowSDL3 {
|
||||
|
||||
public:
|
||||
@@ -24,158 +75,93 @@ namespace Archimedes {
|
||||
data.window = p;
|
||||
data.sendEvent = sendEvent;
|
||||
|
||||
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMEPAD)) {
|
||||
std::cerr << "Error: SDL_Init(): " << SDL_GetError() << std::flush;
|
||||
std::abort();
|
||||
}
|
||||
|
||||
#if RENDERER == 1
|
||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
|
||||
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
|
||||
Uint32 window_flags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN;
|
||||
|
||||
SDL_WindowFlags window_flags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN;
|
||||
#elif RENDERER == 2
|
||||
SDL_WindowFlags window_flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN | SDL_WINDOW_HIGH_PIXEL_DENSITY;
|
||||
#endif
|
||||
|
||||
w = SDL_CreateWindow("Archimedes", 1280, 720, window_flags);
|
||||
if (w == nullptr)
|
||||
{
|
||||
printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError());
|
||||
std::cerr << "Error: SDL_CreateWindow(): " << SDL_GetError() << std::endl;
|
||||
std::abort();
|
||||
}
|
||||
SDL_SetWindowPosition(w, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
|
||||
|
||||
|
||||
#if RENDERER == 1
|
||||
gl_context = SDL_GL_CreateContext(w);
|
||||
|
||||
|
||||
if (gl_context == nullptr)
|
||||
{
|
||||
printf("Error: SDL_GL_CreateContext(): %s\n", SDL_GetError());
|
||||
std::cerr << "Error: SDL_GL_CreateContext(): " << SDL_GetError() << std::endl;
|
||||
std::abort();
|
||||
}
|
||||
|
||||
/*SDL_AddEventWatch([](void* ptr, SDL_Event* e) -> bool {
|
||||
|
||||
WindowData& data = (WindowData&) *ptr;
|
||||
|
||||
switch(e.type) {
|
||||
|
||||
case SDL_EVENT_WINDOW_CLOSE_REQUESTED:
|
||||
case SDL_EVENT_QUIT:
|
||||
data.sendEvent(new CloseWindowEvent(data.window, (void*) &e));
|
||||
break;
|
||||
case SDL_EVENT_WINDOW_RESIZED:
|
||||
width = e.window.data1;
|
||||
height = e.window.data2;
|
||||
data.sendEvent(new ResizeWindowEvent(e.window.data1, e.window.data2, (void*) &e));
|
||||
break;
|
||||
case SDL_EVENT_WINDOW_MOUSE_ENTER:
|
||||
case SDL_EVENT_WINDOW_FOCUS_GAINED:
|
||||
data.sendEvent(new FocusedWindowEvent(data.window, (void*) &e));
|
||||
break;
|
||||
case SDL_EVENT_WINDOW_MOUSE_LEAVE:
|
||||
case SDL_EVENT_WINDOW_FOCUS_LOST:
|
||||
data.sendEvent(new FocusLostWindowEvent(data.window, (void*) &e));
|
||||
break;
|
||||
case SDL_EVENT_KEY_DOWN:
|
||||
data.sendEvent(new KeyPressedWindowEvent(e.key.key, e.key.repeat ? 1 : 0, (void*) &e));
|
||||
break;
|
||||
case SDL_EVENT_KEY_UP:
|
||||
data.sendEvent(new KeyReleasedWindowEvent(e.key.key, (void*) &e));
|
||||
break;
|
||||
case SDL_EVENT_TEXT_EDITING:
|
||||
break;
|
||||
case SDL_EVENT_TEXT_INPUT:
|
||||
break;
|
||||
case SDL_EVENT_MOUSE_MOTION:
|
||||
data.sendEvent(new MouseMovedWindowEvent(e.motion.x, e.motion.y, (void*) &e));
|
||||
break;
|
||||
case SDL_EVENT_MOUSE_BUTTON_DOWN:
|
||||
data.sendEvent(new MouseButtonPressedWindowEvent(e.button.button, (void*) &e));
|
||||
break;
|
||||
case SDL_EVENT_MOUSE_BUTTON_UP:
|
||||
data.sendEvent(new MouseButtonReleasedWindowEvent(e.button.button, (void*) &e));
|
||||
break;
|
||||
case SDL_EVENT_MOUSE_WHEEL:
|
||||
data.sendEvent(new ScrollWindowEvent(e.wheel.x, e.wheel.y, (void*) &e));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}, &data);*/
|
||||
|
||||
|
||||
SDL_GL_MakeCurrent(w, gl_context);
|
||||
SDL_GL_SetSwapInterval(1); // Enable vsync
|
||||
#endif
|
||||
SDL_AddEventWatch(EventCallback, &data);
|
||||
|
||||
SDL_ShowWindow(w);
|
||||
}
|
||||
|
||||
~WindowSDL3() {
|
||||
#if RENDERER == 1
|
||||
SDL_GL_DestroyContext(gl_context);
|
||||
#endif
|
||||
SDL_RemoveEventWatch(EventCallback, &data);
|
||||
SDL_DestroyWindow(w);
|
||||
SDL_Quit();
|
||||
}
|
||||
|
||||
bool shouldClose() { return false; }
|
||||
|
||||
void doFrame() { restoreContext(); SDL_GL_SwapWindow(w); }
|
||||
|
||||
void pollEvents() {
|
||||
while(SDL_PollEvent(&e)) {
|
||||
switch(e.type) {
|
||||
|
||||
case SDL_EVENT_WINDOW_CLOSE_REQUESTED:
|
||||
case SDL_EVENT_QUIT:
|
||||
data.sendEvent(new CloseWindowEvent(data.window, &e));
|
||||
break;
|
||||
case SDL_EVENT_WINDOW_RESIZED:
|
||||
width = e.window.data1;
|
||||
height = e.window.data2;
|
||||
data.sendEvent(new ResizeWindowEvent(e.window.data1, e.window.data2, &e));
|
||||
break;
|
||||
case SDL_EVENT_WINDOW_MOUSE_ENTER:
|
||||
case SDL_EVENT_WINDOW_FOCUS_GAINED:
|
||||
data.sendEvent(new FocusedWindowEvent(data.window, &e));
|
||||
break;
|
||||
case SDL_EVENT_WINDOW_MOUSE_LEAVE:
|
||||
case SDL_EVENT_WINDOW_FOCUS_LOST:
|
||||
data.sendEvent(new FocusLostWindowEvent(data.window, &e));
|
||||
break;
|
||||
case SDL_EVENT_KEY_DOWN:
|
||||
data.sendEvent(new KeyPressedWindowEvent(e.key.key, e.key.repeat ? 1 : 0, &e));
|
||||
break;
|
||||
case SDL_EVENT_KEY_UP:
|
||||
data.sendEvent(new KeyReleasedWindowEvent(e.key.key, &e));
|
||||
break;
|
||||
case SDL_EVENT_MOUSE_MOTION:
|
||||
data.sendEvent(new MouseMovedWindowEvent(e.motion.x, e.motion.y, &e));
|
||||
break;
|
||||
case SDL_EVENT_MOUSE_BUTTON_DOWN:
|
||||
data.sendEvent(new MouseButtonPressedWindowEvent(e.button.button, &e));
|
||||
break;
|
||||
case SDL_EVENT_MOUSE_BUTTON_UP:
|
||||
data.sendEvent(new MouseButtonReleasedWindowEvent(e.button.button, &e));
|
||||
break;
|
||||
case SDL_EVENT_MOUSE_WHEEL:
|
||||
data.sendEvent(new ScrollWindowEvent(e.wheel.x, e.wheel.y, &e));
|
||||
break;
|
||||
default:
|
||||
data.sendEvent(new AnonymousEvent(&e));
|
||||
break;
|
||||
}
|
||||
}
|
||||
void doFrame() {
|
||||
#if RENDERER == 1
|
||||
restoreContext();
|
||||
SDL_GL_SwapWindow(w);
|
||||
#endif
|
||||
}
|
||||
|
||||
void pollEvents() {
|
||||
static SDL_Event e;
|
||||
while(SDL_PollEvent(&e)) {}
|
||||
}
|
||||
#if RENDERER == 1
|
||||
void restoreContext() { SDL_GL_MakeCurrent(w, gl_context); }
|
||||
|
||||
#endif
|
||||
void getSize(int& w, int& h) {
|
||||
w = this->width;
|
||||
h = this->height;
|
||||
}
|
||||
|
||||
SDL_Window* getWindow() { return w; }
|
||||
|
||||
SDL_GLContext getContext() { return gl_context; }
|
||||
void setSize(int& w, int& h) {
|
||||
this->width = w;
|
||||
this->height = h;
|
||||
}
|
||||
|
||||
SDL_Window* getWindow() { return w; }
|
||||
#if RENDERER == 1
|
||||
SDL_GLContext getContext() { return gl_context; }
|
||||
#endif
|
||||
WindowData data;
|
||||
|
||||
private:
|
||||
SDL_Window* w;
|
||||
int width = 0, height = 0;
|
||||
#if RENDERER == 1
|
||||
SDL_GLContext gl_context;
|
||||
SDL_Event e;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
|
||||
353
modules/Archimedes-Modules/Calculator/Calculator.cpp
Normal file
353
modules/Archimedes-Modules/Calculator/Calculator.cpp
Normal 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() {
|
||||
|
||||
}
|
||||
35
modules/Archimedes-Modules/Calculator/Calculator.h
Normal file
35
modules/Archimedes-Modules/Calculator/Calculator.h
Normal 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
|
||||
@@ -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"
|
||||
|
||||
@@ -23,6 +23,6 @@ class ChatClient : public Archimedes::Module {
|
||||
};
|
||||
|
||||
#ifdef CHATCLIENT_DYNAMIC
|
||||
#define MODULE_TYPE ChatClient
|
||||
typedef ChatClient mtype;
|
||||
#include "endModule.h"
|
||||
#endif
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "Archimedes.h"
|
||||
|
||||
#include "modules/ServerModule/src/ServerModule.h"
|
||||
#include "modules/ServerModule/ServerModule.h"
|
||||
|
||||
class ChatServer : public Archimedes::Module {
|
||||
|
||||
@@ -29,6 +29,6 @@ class ChatServer : public Archimedes::Module {
|
||||
};
|
||||
|
||||
#ifdef CHATSERVER_DYNAMIC
|
||||
#define MODULE_TYPE ChatServer
|
||||
typedef ChatServer mtype;
|
||||
#include "endModule.h"
|
||||
#endif
|
||||
@@ -0,0 +1,276 @@
|
||||
|
||||
#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->sendReliable("srvcmd1", strlen("srvcmd1"));
|
||||
//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")) {
|
||||
if(s == "/quit") {
|
||||
cm->sendReliable("srvcmd1", strlen("srvcmd1"));
|
||||
cm->stopClient();
|
||||
} else if(s == "/shutdown") {
|
||||
cm->sendReliable("srvcmd2", strlen("srvcmd2"));
|
||||
//cm->stopClient();
|
||||
} else {
|
||||
s.insert(0, "client");
|
||||
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);
|
||||
}
|
||||
|
||||
if(!SDL_AudioStreamDevicePaused(speaker)) {
|
||||
SDL_SetAudioStreamGain(speaker, speakerVol);
|
||||
} else if(micTest) {
|
||||
SDL_ClearAudioStream(speaker);
|
||||
SDL_ResumeAudioStreamDevice(speaker);
|
||||
SDL_SetAudioStreamGain(speaker, speakerVol);
|
||||
}
|
||||
|
||||
static int avail = 0;
|
||||
|
||||
if(micTest) {
|
||||
|
||||
avail = SDL_min(len, SDL_GetAudioStreamAvailable(mic));
|
||||
if(avail > 10) {
|
||||
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);
|
||||
static ClientModule* cm;
|
||||
|
||||
/*if(type == app->getEventType("DataSentEvent")) {
|
||||
//we did this?
|
||||
return true;
|
||||
} else */
|
||||
|
||||
if(type == app->getEventType(Archimedes::DataRecievedEvent())) {
|
||||
|
||||
Archimedes::DataRecievedEvent& e = (Archimedes::DataRecievedEvent&) event;
|
||||
|
||||
{ cm = (ClientModule*) moduleInstances[ClientModule()]; }
|
||||
|
||||
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);
|
||||
|
||||
messages += "\n\n" + s;
|
||||
} 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";
|
||||
|
||||
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
|
||||
break;
|
||||
|
||||
default:
|
||||
// Silences -Wswitch
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#include "Archimedes.h"
|
||||
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_audio.h>
|
||||
|
||||
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
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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
|
||||
46
modules/Archimedes-Modules/Chess/ChessServer/ChessServer.cpp
Normal file
46
modules/Archimedes-Modules/Chess/ChessServer/ChessServer.cpp
Normal 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;
|
||||
}
|
||||
34
modules/Archimedes-Modules/Chess/ChessServer/ChessServer.h
Normal file
34
modules/Archimedes-Modules/Chess/ChessServer/ChessServer.h
Normal 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
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "Ollama.h"
|
||||
#include "modules/ImguiModule/src/ImguiModule.h"
|
||||
#include "modules/ImguiModule/ImguiModule.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
@@ -21,6 +21,6 @@ class Ollama : public Archimedes::Module {
|
||||
};
|
||||
|
||||
#ifdef OLLAMA_DYNAMIC
|
||||
#define MODULE_TYPE Ollama
|
||||
typedef Ollama mtype;
|
||||
#include "endModule.h"
|
||||
#endif
|
||||
@@ -10,6 +10,6 @@ class Print : public Archimedes::Module {
|
||||
};
|
||||
|
||||
#ifdef PRINT_DYNAMIC
|
||||
#define MODULE_TYPE Print
|
||||
typedef Print mtype;
|
||||
#include "endModule.h"
|
||||
#endif
|
||||
1
modules/Archimedes-Modules/README.md
Normal file
1
modules/Archimedes-Modules/README.md
Normal file
@@ -0,0 +1 @@
|
||||
Example modules for Archimedes
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <fcntl.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) {
|
||||
@@ -16,6 +16,6 @@ class Terminal : public Archimedes::Module {
|
||||
};
|
||||
|
||||
#ifdef TERMINAL_DYNAMIC
|
||||
#define MODULE_TYPE Terminal
|
||||
typedef Terminal mtype;
|
||||
#include "endModule.h"
|
||||
#endif
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "Archimedes.h"
|
||||
|
||||
|
||||
class TestClay : public Archimedes::GuiModule {
|
||||
class TestClay : public Archimedes::Module {
|
||||
|
||||
public:
|
||||
TestClay(void*, Archimedes::App&);
|
||||
@@ -1,5 +1,5 @@
|
||||
#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) {
|
||||
|
||||
@@ -19,6 +19,6 @@ class TestImgui : public Archimedes::Module {
|
||||
};
|
||||
|
||||
#ifdef TESTIMGUI_DYNAMIC
|
||||
#define MODULE_TYPE TestImgui
|
||||
typedef TestImgui mtype;
|
||||
#include "endModule.h"
|
||||
#endif
|
||||
@@ -14,6 +14,6 @@ class TestNotCurses : public Archimedes::Module {
|
||||
};
|
||||
|
||||
#ifdef TESTNOTCURSES_DYNAMIC
|
||||
#define MODULE_TYPE TestNotCurses
|
||||
typedef TestNotCurses mtype;
|
||||
#include "endModule.h"
|
||||
#endif
|
||||
@@ -68,6 +68,6 @@ class ClientModule : public Archimedes::Module {
|
||||
};
|
||||
|
||||
#ifdef CLIENTMODULE_DYNAMIC
|
||||
#define MODULE_TYPE ClientModule
|
||||
typedef ClientModule mtype;
|
||||
#include "endModule.h"
|
||||
#endif
|
||||
@@ -39,6 +39,10 @@ void ImguiModule::onLoad() {
|
||||
}
|
||||
|
||||
window = wm->aquireWindow();
|
||||
|
||||
#if RENDERER == 2
|
||||
renderer = window->getRenderer()->getRendererImpl().renderer;
|
||||
#endif
|
||||
|
||||
IMGUI_CHECKVERSION();
|
||||
context = ImGui::CreateContext();
|
||||
@@ -4,12 +4,16 @@
|
||||
#include "imgui.h"
|
||||
#include "misc/cpp/imgui_stdlib.h"
|
||||
|
||||
#include "modules/WindowModule/src/WindowModule.h"
|
||||
#include "modules/WindowModule/WindowModule.h"
|
||||
|
||||
#if RENDERER == 1
|
||||
|
||||
#include "backends/imgui_impl_opengl3.h"
|
||||
|
||||
#elif RENDERER == 2
|
||||
|
||||
#include "backends/imgui_impl_sdlrenderer3.h"
|
||||
|
||||
#endif
|
||||
|
||||
#if WINDOW == 1
|
||||
@@ -69,6 +73,13 @@ class ImguiModule : public Archimedes::Module {
|
||||
void rendererNewFrame() { ImGui_ImplOpenGL3_NewFrame(); }
|
||||
void rendererRenderDrawData() { ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); }
|
||||
|
||||
#elif RENDERER == 2
|
||||
SDL_Renderer* renderer;
|
||||
auto rendererInit() { return ImGui_ImplSDLRenderer3_Init(renderer); }
|
||||
void rendererShutdown() { ImGui_ImplSDLRenderer3_Shutdown(); }
|
||||
|
||||
void rendererNewFrame() { ImGui_ImplSDLRenderer3_NewFrame(); }
|
||||
void rendererRenderDrawData() { ImGui_ImplSDLRenderer3_RenderDrawData(ImGui::GetDrawData(), renderer); }
|
||||
#endif
|
||||
|
||||
#if WINDOW == 1
|
||||
@@ -83,6 +94,8 @@ class ImguiModule : public Archimedes::Module {
|
||||
#elif WINDOW == 2
|
||||
#if RENDERER == 1
|
||||
auto windowInit() { return ImGui_ImplSDL3_InitForOpenGL(window->getWindowImpl().getWindow(), window->getWindowImpl().getContext()); }
|
||||
#elif RENDERER == 2
|
||||
auto windowInit() { return ImGui_ImplSDL3_InitForSDLRenderer(window->getWindowImpl().getWindow(), renderer); }
|
||||
#endif
|
||||
|
||||
void windowShutdown() { ImGui_ImplSDL3_Shutdown(); }
|
||||
@@ -93,7 +106,7 @@ class ImguiModule : public Archimedes::Module {
|
||||
};
|
||||
|
||||
#ifdef IMGUIMODULE_DYNAMIC
|
||||
#define MODULE_TYPE ImguiModule
|
||||
typedef ImguiModule mtype;
|
||||
#include "endModule.h"
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#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) {
|
||||
@@ -17,6 +17,6 @@ class MainGUI : public Archimedes::Module {
|
||||
};
|
||||
|
||||
#ifdef MAINGUI_DYNAMIC
|
||||
#define MODULE_TYPE MainGUI
|
||||
typedef MainGUI mtype;
|
||||
#include "endModule.h"
|
||||
#endif
|
||||
@@ -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();
|
||||
|
||||
@@ -88,7 +93,7 @@ class ServerModule : public Archimedes::Module {
|
||||
};
|
||||
|
||||
#ifdef SERVERMODULE_DYNAMIC
|
||||
#define MODULE_TYPE ServerModule
|
||||
typedef ServerModule mtype;
|
||||
#include "endModule.h"
|
||||
#endif
|
||||
|
||||
@@ -57,6 +57,9 @@ bool WindowModule::onEvent(const Archimedes::Event& e) {
|
||||
Archimedes::ResizeWindowEvent& event = (Archimedes::ResizeWindowEvent&) e;
|
||||
renderer->w = event.width;
|
||||
renderer->h = event.height;
|
||||
#if WINDOW == 2
|
||||
window->getWindowImpl().setSize(event.width, event.height);
|
||||
#endif
|
||||
return true;
|
||||
} else if(type == app->getEventType(Archimedes::CloseWindowEvent())) {
|
||||
app->emitEvent(new Archimedes::DoUnloadModuleEvent(name));
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "utils/Renderer/Renderer.h"
|
||||
#include "utils/Window/Window.h"
|
||||
|
||||
static_assert(!(WINDOW == 1 && RENDERER == 2), "Window and Renderer are incompatible!\n");
|
||||
|
||||
class WindowModule : public Archimedes::Module {
|
||||
|
||||
public:
|
||||
@@ -37,14 +39,16 @@ class WindowModule : public Archimedes::Module {
|
||||
window->setRenderer(renderer);
|
||||
|
||||
|
||||
if(!renderer->init()) {
|
||||
if(!renderer->init(window->getWindowImpl().getWindow())) {
|
||||
std::cout << "Renderer init failed!\n";
|
||||
std::abort();
|
||||
}
|
||||
}
|
||||
|
||||
windowRefs++;
|
||||
#if RENDERER == 1
|
||||
window->getWindowImpl().restoreContext();
|
||||
#endif
|
||||
return window;
|
||||
}
|
||||
|
||||
@@ -76,7 +80,7 @@ class WindowModule : public Archimedes::Module {
|
||||
|
||||
|
||||
#ifdef WINDOWMODULE_DYNAMIC
|
||||
#define MODULE_TYPE WindowModule
|
||||
typedef WindowModule mtype;
|
||||
#include "endModule.h"
|
||||
#endif
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
@@ -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
|
||||
@@ -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));
|
||||
}
|
||||
@@ -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
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -1,7 +1,7 @@
|
||||
#define ENTRYPOINT
|
||||
#include "Archimedes.h"
|
||||
|
||||
#include "modules/examples/TestImgui/src/TestImgui.h"
|
||||
#include "modules/Archimedes-Modules/TestImgui/TestImgui.h"
|
||||
|
||||
class ImguiEmbed : public Archimedes::App {
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ void MinimalApp::run() {
|
||||
modules[m]->onLoad();
|
||||
}
|
||||
|
||||
|
||||
// Main loop
|
||||
while (!done && !runOrder.empty()) {
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#define ENTRYPOINT
|
||||
#include "Archimedes.h"
|
||||
|
||||
#include "modules/Terminal/src/Terminal.h"
|
||||
#include "modules/Archimedes-Modules/Terminal/Terminal.h"
|
||||
|
||||
class TerminalEmbed : public Archimedes::App {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user