diff options
| -rw-r--r-- | .github/workflows/label.yml | 19 | ||||
| -rw-r--r-- | .travis.yml | 4 | ||||
| -rwxr-xr-x | scripts/macos_post_build.sh | 2 | ||||
| -rwxr-xr-x | scripts/release_macos.sh | 22 | ||||
| -rw-r--r-- | src/aomusicplayer.cpp | 12 | ||||
| -rw-r--r-- | src/path_functions.cpp | 386 |
6 files changed, 209 insertions, 236 deletions
diff --git a/.github/workflows/label.yml b/.github/workflows/label.yml deleted file mode 100644 index e90b599b..00000000 --- a/.github/workflows/label.yml +++ /dev/null @@ -1,19 +0,0 @@ -# This workflow will triage pull requests and apply a label based on the -# paths that are modified in the pull request. -# -# To use this workflow, you will need to set up a .github/labeler.yml -# file with configuration. For more information, see: -# https://github.com/actions/labeler/blob/master/README.md - -name: Labeler -on: [pull_request] - -jobs: - label: - - runs-on: ubuntu-latest - - steps: - - uses: actions/labeler@v2 - with: - repo-token: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.travis.yml b/.travis.yml index 5d384b0c..dbd19cdc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,8 @@ deploy: provider: releases api_key: secure: mZCNwnqKeqJP5CqgYOanYnr/KHydxueGPRhvGLpY0Pop7MiH3CIHMN5dhHbtgJvE5GGMR4xUIEhPpmkCEJw7YiPREMqT4mkV4DR531ZLB3t/FizyvIwXuP6jFwzTofZ51qHfBpcurVc9sMFeD9Pw+rLTTgIiXL2sZxUUXc8U+ZZug1lYndgcO6P00fUJd6V9lyFQUGmbSca97YbG6KuCym0fEpyRnMqzKLjYsUUo8UKRBADtmD822O6z2FSldNZDn45Mkx0MYfHWyT5hzTb7WGa+DrTB/0un1HqqsNPlb/ahjrFQQNR2qd7HNGZa+Mvwi6egTDug+k15x8lbkacUoi34U1eFq9LSTYm8dSO5g23I1OvGvjTCkDj1jOLPqB99XlbAJ0E/9Jzw7wtlLaAzvFzTj/B63TQnO3IsgHBWR14CZlf05WMOFf2irwl+kL6ktspIHnlGgaiWYYrKeAt7QJAXiQOdYDz6SaWVC6TyOE/SszXRU6xFotmCjkP2irM5yGE8SUw2uIzKjD9uG0ZXtbLcdQEFD316+qglqFTCjnKsRfbtQs2u5spZPsZSdsOZCbLfNIn0GSTFRymFsK6gsvji8AD8AZo0zcOZ/7NMVC6A8RnF3Ve+vU/xljhsIOxoLZDvZPia7WozdV99xmnepWBwkuoQs/K0xmWcnLZDcb0= - file: "../bin/Attorney_Online.app" + file: "../bin/Attorney_Online_mac_x86_64.zip" + draft: true on: + tags: true repo: AttorneyOnline/AO2-Client diff --git a/scripts/macos_post_build.sh b/scripts/macos_post_build.sh index 25400bf5..df1475c4 100755 --- a/scripts/macos_post_build.sh +++ b/scripts/macos_post_build.sh @@ -20,3 +20,5 @@ cp ../lib/* ../bin/Attorney_Online.app/Contents/Frameworks # libbass has a funny path for some reason, just use rpath install_name_tool -change @loader_path/libbass.dylib @rpath/libbass.dylib ../bin/Attorney_Online.app/Contents/MacOS/Attorney_Online + +zip -r -9 ../bin/Attorney_Online_mac_x86_64.zip ../bin/
\ No newline at end of file diff --git a/scripts/release_macos.sh b/scripts/release_macos.sh deleted file mode 100755 index 50acb408..00000000 --- a/scripts/release_macos.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -# This script prepares the compiled bundle for shipping as a standalone release -# Assumes the Qt bin folder is in PATH -# Should be used on a "Release" build from QT creator -# Note that this DOES NOT add the base/ folder - -# Exit on errors and unset variables -set -eu - -ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" - -cd ${ROOT_DIR} - -# This thing basically does all the work -macdeployqt ../bin/Attorney_Online.app - -# Need to add the dependencies -cp ../lib/* ../bin/Attorney_Online.app/Contents/Frameworks - -# libbass has a funny path for some reason, just use rpath -install_name_tool -change @loader_path/libbass.dylib @rpath/libbass.dylib ../bin/Attorney_Online.app/Contents/MacOS/Attorney_Online diff --git a/src/aomusicplayer.cpp b/src/aomusicplayer.cpp index e767435f..3ba9cf1d 100644 --- a/src/aomusicplayer.cpp +++ b/src/aomusicplayer.cpp @@ -16,9 +16,15 @@ void AOMusicPlayer::play(QString p_song) f_path = ao_app->get_music_path(p_song); - m_stream = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, - BASS_STREAM_AUTOFREE | BASS_UNICODE | - BASS_ASYNCFILE); + if (p_song.startsWith("http")) { + m_stream = BASS_StreamCreateURL(f_path.toStdWString().c_str(), 0, + BASS_STREAM_AUTOFREE | BASS_UNICODE | + BASS_ASYNCFILE, NULL, NULL); + } else { + m_stream = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, + BASS_STREAM_AUTOFREE | BASS_UNICODE | + BASS_ASYNCFILE); + } this->set_volume(m_volume); diff --git a/src/path_functions.cpp b/src/path_functions.cpp index 678543ee..bd41b068 100644 --- a/src/path_functions.cpp +++ b/src/path_functions.cpp @@ -1,191 +1,195 @@ -#include "aoapplication.h"
-#include "courtroom.h"
-#include "file_functions.h"
-
-#include <QDir>
-#include <QRegExp>
-#include <QStandardPaths>
-
-#ifdef BASE_OVERRIDE
-#include "base_override.h"
-#endif
-
-// this is a quite broad generalization
-// the most common OSes(mac and windows) are _usually_ case insensitive
-// however, there do exist mac installations with case sensitive filesystems
-// in that case, define CASE_SENSITIVE_FILESYSTEM and compile on a mac
-#if (defined(LINUX) || defined(__linux__))
-#define CASE_SENSITIVE_FILESYSTEM
-#endif
-
-QString AOApplication::get_base_path()
-{
- QString base_path = "";
-#ifdef ANDROID
- QString sdcard_storage = getenv("SECONDARY_STORAGE");
- if (dir_exists(sdcard_storage + "/AO2/")) {
- base_path = sdcard_storage + "/AO2/";
- }
- else {
- QString external_storage = getenv("EXTERNAL_STORAGE");
- base_path = external_storage + "/AO2/";
- }
-#elif defined __APPLE__
- base_path = applicationDirPath() + "/../../../base/";
-#else
- base_path = applicationDirPath() + "/base/";
-#endif
-
- return base_path;
-}
-
-QString AOApplication::get_data_path() { return get_base_path() + "data/"; }
-
-QString AOApplication::get_default_theme_path(QString p_file)
-{
- QString path = get_base_path() + "themes/default/" + p_file;
-#ifndef CASE_SENSITIVE_FILESYSTEM
- return path;
-#else
- return get_case_sensitive_path(path);
-#endif
-}
-
-QString AOApplication::get_custom_theme_path(QString p_theme, QString p_file)
-{
- QString path = get_base_path() + "themes/" + p_theme + "/" + p_file;
-#ifndef CASE_SENSITIVE_FILESYSTEM
- return path;
-#else
- return get_case_sensitive_path(path);
-#endif
-}
-
-QString AOApplication::get_theme_path(QString p_file)
-{
- QString path = get_base_path() + "themes/" + current_theme + "/" + p_file;
-#ifndef CASE_SENSITIVE_FILESYSTEM
- return path;
-#else
- return get_case_sensitive_path(path);
-#endif
-}
-
-QString AOApplication::get_character_path(QString p_char, QString p_file)
-{
- QString path = get_base_path() + "characters/" + p_char + "/" + p_file;
-#ifndef CASE_SENSITIVE_FILESYSTEM
- return path;
-#else
- return get_case_sensitive_path(path);
-#endif
-}
-
-QString AOApplication::get_sounds_path(QString p_file)
-{
- QString path = get_base_path() + "sounds/general/" + p_file;
-#ifndef CASE_SENSITIVE_FILESYSTEM
- return path;
-#else
- return get_case_sensitive_path(path);
-#endif
-}
-
-QString AOApplication::get_music_path(QString p_song)
-{
- QString withending_check = get_base_path() + "sounds/music/" + p_song;
- QString mp3_check = get_base_path() + "sounds/music/" + p_song + ".mp3";
- QString opus_check = get_base_path() + "sounds/music/" + p_song + ".opus";
- if (file_exists(opus_check)) {
-#ifndef CASE_SENSITIVE_FILESYSTEM
- return opus_check;
-#else
- return get_case_sensitive_path(opus_check);
-#endif
- }
- else if (file_exists(mp3_check)) {
-#ifndef CASE_SENSITIVE_FILESYSTEM
- return mp3_check;
-#else
- return get_case_sensitive_path(mp3_check);
-#endif
- }
- else if (file_exists(withending_check)) {
-#ifndef CASE_SENSITIVE_FILESYSTEM
- return withending_check;
-#else
- return get_case_sensitive_path(withending_check);
-#endif
- }
-#ifndef CASE_SENSITIVE_FILESYSTEM
- return get_base_path() + "sounds/music/" + p_song + ".wav";
- ;
-#else
- return get_case_sensitive_path(get_base_path() + "sounds/music/" + p_song +
- ".wav");
-#endif
-}
-
-QString AOApplication::get_background_path(QString p_file)
-{
- QString path = get_base_path() + "background/" +
- w_courtroom->get_current_background() + "/" + p_file;
- if (courtroom_constructed) {
-#ifndef CASE_SENSITIVE_FILESYSTEM
- return path;
-#else
- return get_case_sensitive_path(path);
-#endif
- }
- return get_default_background_path(p_file);
-}
-
-QString AOApplication::get_default_background_path(QString p_file)
-{
- QString path = get_base_path() + "background/default/" + p_file;
-#ifndef CASE_SENSITIVE_FILESYSTEM
- return path;
-#else
- return get_case_sensitive_path(path);
-#endif
-}
-
-QString AOApplication::get_evidence_path(QString p_file)
-{
- QString path = get_base_path() + "evidence/" + p_file;
-#ifndef CASE_SENSITIVE_FILESYSTEM
- return path;
-#else
- return get_case_sensitive_path(path);
-#endif
-}
-
-QString AOApplication::get_case_sensitive_path(QString p_file)
-{
- // first, check to see if it's actually there (also serves as base case for
- // recursion)
- if (exists(p_file))
- return p_file;
-
- QFileInfo file(p_file);
-
- QString file_basename = file.fileName();
- QString file_parent_dir = get_case_sensitive_path(file.absolutePath());
-
- // second, does it exist in the new parent dir?
- if (exists(file_parent_dir + "/" + file_basename))
- return file_parent_dir + "/" + file_basename;
-
- // last resort, dirlist parent dir and find case insensitive match
- QRegExp file_rx =
- QRegExp(file_basename, Qt::CaseInsensitive, QRegExp::FixedString);
- QStringList files = QDir(file_parent_dir).entryList();
-
- int result = files.indexOf(file_rx);
-
- if (result != -1)
- return file_parent_dir + "/" + files.at(result);
-
- // if nothing is found, let the caller handle the missing file
- return file_parent_dir + "/" + file_basename;
-}
+#include "aoapplication.h" +#include "courtroom.h" +#include "file_functions.h" + +#include <QDir> +#include <QRegExp> +#include <QStandardPaths> + +#ifdef BASE_OVERRIDE +#include "base_override.h" +#endif + +// this is a quite broad generalization +// the most common OSes(mac and windows) are _usually_ case insensitive +// however, there do exist mac installations with case sensitive filesystems +// in that case, define CASE_SENSITIVE_FILESYSTEM and compile on a mac +#if (defined(LINUX) || defined(__linux__)) +#define CASE_SENSITIVE_FILESYSTEM +#endif + +QString AOApplication::get_base_path() +{ + QString base_path = ""; +#ifdef ANDROID + QString sdcard_storage = getenv("SECONDARY_STORAGE"); + if (dir_exists(sdcard_storage + "/AO2/")) { + base_path = sdcard_storage + "/AO2/"; + } + else { + QString external_storage = getenv("EXTERNAL_STORAGE"); + base_path = external_storage + "/AO2/"; + } +#elif defined __APPLE__ + base_path = applicationDirPath() + "/../../../base/"; +#else + base_path = applicationDirPath() + "/base/"; +#endif + + return base_path; +} + +QString AOApplication::get_data_path() { return get_base_path() + "data/"; } + +QString AOApplication::get_default_theme_path(QString p_file) +{ + QString path = get_base_path() + "themes/default/" + p_file; +#ifndef CASE_SENSITIVE_FILESYSTEM + return path; +#else + return get_case_sensitive_path(path); +#endif +} + +QString AOApplication::get_custom_theme_path(QString p_theme, QString p_file) +{ + QString path = get_base_path() + "themes/" + p_theme + "/" + p_file; +#ifndef CASE_SENSITIVE_FILESYSTEM + return path; +#else + return get_case_sensitive_path(path); +#endif +} + +QString AOApplication::get_theme_path(QString p_file) +{ + QString path = get_base_path() + "themes/" + current_theme + "/" + p_file; +#ifndef CASE_SENSITIVE_FILESYSTEM + return path; +#else + return get_case_sensitive_path(path); +#endif +} + +QString AOApplication::get_character_path(QString p_char, QString p_file) +{ + QString path = get_base_path() + "characters/" + p_char + "/" + p_file; +#ifndef CASE_SENSITIVE_FILESYSTEM + return path; +#else + return get_case_sensitive_path(path); +#endif +} + +QString AOApplication::get_sounds_path(QString p_file) +{ + QString path = get_base_path() + "sounds/general/" + p_file; +#ifndef CASE_SENSITIVE_FILESYSTEM + return path; +#else + return get_case_sensitive_path(path); +#endif +} + +QString AOApplication::get_music_path(QString p_song) +{ + QString withending_check = get_base_path() + "sounds/music/" + p_song; + QString mp3_check = get_base_path() + "sounds/music/" + p_song + ".mp3"; + QString opus_check = get_base_path() + "sounds/music/" + p_song + ".opus"; + if (p_song.startsWith("http")) { + //it's an URL + return p_song; + } + else if (file_exists(opus_check)) +#ifndef CASE_SENSITIVE_FILESYSTEM + return opus_check; +#else + return get_case_sensitive_path(opus_check); +#endif + } + else if (file_exists(mp3_check)) { +#ifndef CASE_SENSITIVE_FILESYSTEM + return mp3_check; +#else + return get_case_sensitive_path(mp3_check); +#endif + } + else if (file_exists(withending_check)) { +#ifndef CASE_SENSITIVE_FILESYSTEM + return withending_check; +#else + return get_case_sensitive_path(withending_check); +#endif + } +#ifndef CASE_SENSITIVE_FILESYSTEM + return get_base_path() + "sounds/music/" + p_song + ".wav"; + ; +#else + return get_case_sensitive_path(get_base_path() + "sounds/music/" + p_song + + ".wav"); +#endif +} + +QString AOApplication::get_background_path(QString p_file) +{ + QString path = get_base_path() + "background/" + + w_courtroom->get_current_background() + "/" + p_file; + if (courtroom_constructed) { +#ifndef CASE_SENSITIVE_FILESYSTEM + return path; +#else + return get_case_sensitive_path(path); +#endif + } + return get_default_background_path(p_file); +} + +QString AOApplication::get_default_background_path(QString p_file) +{ + QString path = get_base_path() + "background/default/" + p_file; +#ifndef CASE_SENSITIVE_FILESYSTEM + return path; +#else + return get_case_sensitive_path(path); +#endif +} + +QString AOApplication::get_evidence_path(QString p_file) +{ + QString path = get_base_path() + "evidence/" + p_file; +#ifndef CASE_SENSITIVE_FILESYSTEM + return path; +#else + return get_case_sensitive_path(path); +#endif +} + +QString AOApplication::get_case_sensitive_path(QString p_file) +{ + // first, check to see if it's actually there (also serves as base case for + // recursion) + if (exists(p_file)) + return p_file; + + QFileInfo file(p_file); + + QString file_basename = file.fileName(); + QString file_parent_dir = get_case_sensitive_path(file.absolutePath()); + + // second, does it exist in the new parent dir? + if (exists(file_parent_dir + "/" + file_basename)) + return file_parent_dir + "/" + file_basename; + + // last resort, dirlist parent dir and find case insensitive match + QRegExp file_rx = + QRegExp(file_basename, Qt::CaseInsensitive, QRegExp::FixedString); + QStringList files = QDir(file_parent_dir).entryList(); + + int result = files.indexOf(file_rx); + + if (result != -1) + return file_parent_dir + "/" + files.at(result); + + // if nothing is found, let the caller handle the missing file + return file_parent_dir + "/" + file_basename; +} |
