aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbuild_release.sh7
-rw-r--r--dchat.desktop10
-rwxr-xr-xinstall.sh22
-rw-r--r--src/main.cpp16
4 files changed, 41 insertions, 14 deletions
diff --git a/build_release.sh b/build_release.sh
deleted file mode 100755
index 5df2034..0000000
--- a/build_release.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-
-set -e
-
-git submodule update --remote --merge
-sibs build --release
-echo "To run dchat, execute ./sibs-build/release/dchat"
diff --git a/dchat.desktop b/dchat.desktop
new file mode 100644
index 0000000..4f194d4
--- /dev/null
+++ b/dchat.desktop
@@ -0,0 +1,10 @@
+[Desktop Entry]
+Version=1.0
+Encoding=UTF-8
+Name=Dchat
+GenericName=Decentralized chat
+Type=Application
+Categories=Chat;
+Terminal=false
+StartupNotify=true
+Exec=DCHAT_BIN_PATH DCHAT_RESOURCES_PATH
diff --git a/install.sh b/install.sh
new file mode 100755
index 0000000..7023db3
--- /dev/null
+++ b/install.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+set -e
+
+cd "$(dirname "$0")"
+sibs build --release
+chmod +x ./sibs-build/release/dchat
+
+dchat_resource_dir=~/.local/share/dchat/resources
+desktop_file=~/.local/share/applications/dchat.desktop
+mkdir -p ~/.local/bin
+mkdir -p ~/.local/share/applications
+mkdir -p ${dchat_resource_dir}
+
+target_path=~/.local/bin/dchat
+cp ./sibs-build/release/dchat $target_path
+cp ./dchat.desktop ${desktop_file}
+sed -i "s;DCHAT_BIN_PATH;${target_path};g" ${desktop_file}
+sed -i "s;DCHAT_RESOURCES_PATH;${dchat_resource_dir};g" ${desktop_file}
+cp -r ./shaders "${dchat_resource_dir}/shaders"
+cp -r ./fonts "${dchat_resource_dir}/fonts"
+echo "Installed dchat to directory $target_path"
diff --git a/src/main.cpp b/src/main.cpp
index ef4c20f..0836278 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -14,7 +14,7 @@
#include <string>
#include <SFML/Graphics.hpp>
#include <cstring>
-#include <boost/filesystem/path.hpp>
+#include <boost/filesystem.hpp>
#include <odhtdb/Database.hpp>
#include <odhtdb/Signature.hpp>
#include <odhtdb/bin2hex.hpp>
@@ -200,12 +200,14 @@ static void channelAddStoredMessage(Channel *channel, const odhtdb::Hash &reques
int main(int argc, char **argv)
{
- /*
- boost::filesystem::path programPath(argv[0]);
- auto parentPath = programPath.parent_path();
- printf("parent path: %s\n", parentPath.string().c_str());
- boost::filesystem::current_path(parentPath); // Ensures loading of resources works no matter which path we run this executable from
- */
+ if(argc > 1)
+ {
+ boost::filesystem::path resourcesPath(argv[1]);
+ boost::filesystem::current_path(resourcesPath);
+ printf("Resource path set to: %s\n", resourcesPath.string().c_str());
+ }
+ else
+ printf("Resource directory not defined, using currently directory");
const sf::Int64 FRAMERATE_FOCUSED = 144;
const sf::Int64 FRAMERATE_NOT_FOCUSED = 10;