Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add block win audio base on tiers #1533

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ jobs:
prerelease: true
includeDebug: false
includeRelease: true
args: ${{ matrix.args }} --features "${{ env.TS_FEATURES }}"
args: ${{ matrix.args }} --features "audio ${{ env.TS_FEATURES }}"

- name: Debug Step - artifactPaths
if: ${{ ( github.event_name == 'schedule' ) || ( ! startsWith(github.ref, 'refs/heads/release') ) }}
Expand Down
14 changes: 14 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,20 @@
<body>
<main id="main">
<div id="root"></div>

<audio id="notification-player" preload="auto">
<source src="/assets/Notification.wav" type="audio/wav" />
</audio>
<audio id="success1-player" preload="auto">
<source src="/assets/Success_Level_01.wav" type="audio/wav" />
</audio>
<audio id="success2-player" preload="auto">
<source src="/assets/Success_Level_02.wav" type="audio/wav" />
</audio>
<audio id="success3-player" preload="auto">
<source src="/assets/Success_Level_03.wav" type="audio/wav" />
</audio>

<canvas id="canvas" style="opacity: 0"></canvas>
<script type="module" src="src/main.tsx"></script>
<script>
Expand Down
9 changes: 9 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@sentry/react": "^8.48.0",
"@tauri-apps/api": "^2.2.0",
"@tauri-apps/plugin-clipboard-manager": "^2.2.0",
"@tauri-apps/plugin-fs": "^2.2.0",
"@tauri-apps/plugin-os": "^2.2.0",
"@tauri-apps/plugin-process": "^2.2.0",
"@tauri-apps/plugin-shell": "^2.2.0",
Expand Down
Binary file added public/assets/Notification.wav
Binary file not shown.
Binary file added public/assets/Success_Level_01.wav
Binary file not shown.
Binary file added public/assets/Success_Level_02.wav
Binary file not shown.
Binary file added public/assets/Success_Level_03.wav
Binary file not shown.
364 changes: 182 additions & 182 deletions public/assets/glApp.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions public/locales/af/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"app-restart-required": "App herbegin benodig",
"application-info": "Aansoek Inligting",
"applyInviteCode": "Pas Uitnodigingskode Toe",
"audio-enabled": "Audio enabled",
"cancel": "Cancel",
"change-language": "Verander taal",
"confirm": "Bevestig",
Expand Down
1 change: 1 addition & 0 deletions public/locales/cn/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"app-restart-required": "需要重启应用",
"application-info": "应用信息",
"applyInviteCode": "应用邀请代码",
"audio-enabled": "Audio enabled",
"cancel": "取消",
"change-language": "更改语言",
"confirm": "确认",
Expand Down
1 change: 1 addition & 0 deletions public/locales/de/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"app-restart-required": "App-Neustart erforderlich",
"application-info": "Anwendungsinformationen",
"applyInviteCode": "Einladungscode anwenden",
"audio-enabled": "Audio enabled",
"cancel": "Abbrechen",
"change-language": "Sprache",
"confirm": "Bestätigen",
Expand Down
3 changes: 2 additions & 1 deletion public/locales/en/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"app-restart-required": "App restart required",
"application-info": "Application Information",
"applyInviteCode": "Apply Invite Code",
"audio-enabled": "Audio enabled",
"cancel": "Cancel",
"change-language": "Language",
"confirm": "Confirm",
Expand Down Expand Up @@ -150,4 +151,4 @@
"yes": "Yes",
"your-feedback": "Describe your issue, including your Telegram handle if you have one, so that we can contact you with updates.",
"your-reference": "Your reference:<br/><bold>{{logRef}}</bold>"
}
}
1 change: 1 addition & 0 deletions public/locales/fr/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"app-restart-required": "Redémarrage de l\"application requis",
"application-info": "Informations sur l\"application",
"applyInviteCode": "Appliquer le code d\"invitation",
"audio-enabled": "Audio enabled",
"cancel": "Cancel",
"change-language": "Langue",
"confirm": "Confirmer",
Expand Down
1 change: 1 addition & 0 deletions public/locales/hi/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"app-restart-required": "ऐप पुनः प्रारंभ आवश्यक है",
"application-info": "एप्लिकेशन जानकारी",
"applyInviteCode": "आमंत्रण कोड लागू करें",
"audio-enabled": "Audio enabled",
"cancel": "रद्द करें",
"change-language": "भाषा",
"confirm": "पुष्टि करें",
Expand Down
1 change: 1 addition & 0 deletions public/locales/id/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"app-restart-required": "Diperlukan restart aplikasi",
"application-info": "Informasi Aplikasi",
"applyInviteCode": "Terapkan Kode Undangan",
"audio-enabled": "Audio enabled",
"cancel": "Batal",
"change-language": "Bahasa",
"confirm": "Konfirmasi",
Expand Down
1 change: 1 addition & 0 deletions public/locales/ja/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"app-restart-required": "アプリの再起動が必要です",
"application-info": "アプリケーション情報",
"applyInviteCode": "招待コードを適用",
"audio-enabled": "Audio enabled",
"cancel": "キャンセル",
"change-language": "言語",
"confirm": "確認",
Expand Down
1 change: 1 addition & 0 deletions public/locales/ko/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"app-restart-required": "앱 재시작 필요",
"application-info": "애플리케이션 정보",
"applyInviteCode": "초대 코드 적용",
"audio-enabled": "Audio enabled",
"cancel": "취소",
"change-language": "언어",
"confirm": "확인",
Expand Down
1 change: 1 addition & 0 deletions public/locales/pl/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"app-restart-required": "Wymagany restart aplikacji",
"application-info": "Informacje o aplikacji",
"applyInviteCode": "Zastosuj Kod Zaproszenia",
"audio-enabled": "Audio enabled",
"cancel": "Anuluj",
"change-language": "Zmień język",
"confirm": "Potwierdź",
Expand Down
1 change: 1 addition & 0 deletions public/locales/ru/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"app-restart-required": "Требуется перезапуск приложения",
"application-info": "Информация о приложении",
"applyInviteCode": "Применить код приглашения",
"audio-enabled": "Audio enabled",
"cancel": "Отмена",
"change-language": "Язык",
"confirm": "Подтвердить",
Expand Down
3 changes: 2 additions & 1 deletion public/locales/tr/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"app-restart-required": "Uygulama yeniden başlatılması gerekiyor",
"application-info": "Uygulama Bilgileri",
"applyInviteCode": "Davet Kodunu Uygula",
"audio-enabled": "Audio enabled",
"cancel": "İptal",
"change-language": "Dil Değiştir",
"confirm": "Onayla",
Expand Down Expand Up @@ -150,4 +151,4 @@
"yes": "Evet",
"your-feedback": "Lütfen sorununuzu açıklayın",
"your-reference": "Referansınız"
}
}
31 changes: 31 additions & 0 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ tari_key_manager = { git = "https://github.com/tari-project/tari.git", tag = "v1
tari_shutdown = { git = "https://github.com/tari-project/tari.git", tag = "v1.11.0-pre.0" }
tari_utilities = "0.8.0"
tauri = { version = "2", features = [
"protocol-asset",
"isolation",
"macos-private-api",
"image-png",
Expand Down Expand Up @@ -97,6 +98,7 @@ ring-compat = "0.8.0"
der = "0.7.9"
tonic = "0.12.3"
tauri-plugin-clipboard-manager = "2.2.0"
tauri-plugin-fs = "2"
urlencoding = "2.1.3"
reqwest-middleware = "0.4.0"
reqwest-retry = "0.7.0"
Expand Down Expand Up @@ -125,6 +127,7 @@ custom-protocol = [
] # This feature is used for production builds or when a dev server is not specified, DO NOT REMOVE!!
release-ci = ["tauri/custom-protocol"]
release-ci-beta = ["tauri/custom-protocol"]
audio = []

[package.metadata.cargo-machete]
ignored = [
Expand Down
Binary file added src-tauri/audio/block_win.mp3
Binary file not shown.
10 changes: 9 additions & 1 deletion src-tauri/capabilities/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
"sentry:default",
"process:allow-restart",
"process:default",
"clipboard-manager:allow-write-text"
"clipboard-manager:allow-write-text",
{
"identifier": "fs:allow-read-file",
"allow": [{ "path": "$RESOURCE/audio/block_win.mp3" }]
},
{
"identifier": "fs:allow-read-dir",
"allow": [{ "path": "$RESOURCE/audio" }]
}
]
}
17 changes: 17 additions & 0 deletions src-tauri/src/app_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ pub struct AppConfigFromFile {
last_changelog_version: String,
#[serde(default)]
airdrop_tokens: Option<AirdropTokens>,
#[serde(default = "default_true")]
audio_enabled: bool,
}

impl Default for AppConfigFromFile {
Expand Down Expand Up @@ -161,6 +163,7 @@ impl Default for AppConfigFromFile {
pre_release: false,
last_changelog_version: default_changelog_version(),
airdrop_tokens: None,
audio_enabled: true,
}
}
}
Expand Down Expand Up @@ -281,6 +284,7 @@ pub(crate) struct AppConfig {
pre_release: bool,
last_changelog_version: String,
airdrop_tokens: Option<AirdropTokens>,
audio_enabled: bool,
}

impl AppConfig {
Expand Down Expand Up @@ -327,6 +331,7 @@ impl AppConfig {
pre_release: false,
last_changelog_version: default_changelog_version(),
airdrop_tokens: None,
audio_enabled: true,
}
}

Expand Down Expand Up @@ -406,6 +411,7 @@ impl AppConfig {
self.pre_release = config.pre_release;
self.last_changelog_version = config.last_changelog_version;
self.airdrop_tokens = config.airdrop_tokens;
self.audio_enabled = config.audio_enabled;

KEYRING_ACCESSED.store(
config.keyring_accessed,
Expand Down Expand Up @@ -542,6 +548,16 @@ impl AppConfig {
Ok(())
}

pub fn audio_enabled(&self) -> bool {
self.audio_enabled
}

pub async fn set_audio_enabled(&mut self, audio_enabled: bool) -> Result<(), anyhow::Error> {
self.audio_enabled = audio_enabled;
self.update_config_file().await?;
Ok(())
}

pub async fn set_max_gpu_usage(
&mut self,
custom_max_gpu_usage: Vec<GpuThreads>,
Expand Down Expand Up @@ -833,6 +849,7 @@ impl AppConfig {
pre_release: self.pre_release,
last_changelog_version: self.last_changelog_version.clone(),
airdrop_tokens: self.airdrop_tokens.clone(),
audio_enabled: self.audio_enabled,
};
let config = serde_json::to_string(config)?;
debug!(target: LOG_TARGET, "Updating config file: {:?} {:?}", file, self.clone());
Expand Down
39 changes: 38 additions & 1 deletion src-tauri/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ use log::{debug, error, info, warn};
use monero_address_creator::Seed as MoneroSeed;
use regex::Regex;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use serde_json::{json, Value};
use std::fmt::Debug;
use std::fs::{read_dir, remove_dir_all, remove_file, File};
use std::sync::atomic::Ordering;
Expand Down Expand Up @@ -244,6 +244,11 @@ pub async fn download_and_start_installer(
Ok(())
}

#[tauri::command]
pub async fn is_audio_feature_enabled() -> bool {
cfg!(feature = "audio")
}

#[tauri::command]
pub async fn exit_application(_window: tauri::Window, app: tauri::AppHandle) -> Result<(), String> {
stop_all_processes(app.clone(), true).await?;
Expand Down Expand Up @@ -1388,6 +1393,38 @@ pub async fn set_airdrop_tokens<'r>(
Ok(())
}

#[tauri::command]
pub async fn get_audio_enabled(state: tauri::State<'_, UniverseAppState>) -> Result<bool, String> {
let enabled = state.config.read().await.audio_enabled();
Ok(enabled)
}

#[tauri::command]
pub async fn set_audio_enabled(
audio_enabled: bool,
state: tauri::State<'_, UniverseAppState>,
) -> Result<(), String> {
state
.config
.write()
.await
.set_audio_enabled(audio_enabled)
.await
.map_err(|e| e.to_string())?;
let telemetry_service = state.telemetry_service.read().await;
telemetry_service
.send("audio-enabled".to_string(), json!(audio_enabled))
.await
.inspect_err(|e| {
error!(
"error at sending telemetry data for get_audio_enabled {:?}",
e
)
})
.map_err(|e| e.to_string())?;
Ok(())
}

#[allow(clippy::too_many_lines)]
#[tauri::command]
pub async fn start_mining<'r>(
Expand Down
Loading
Loading