diff --git a/layer_grid/SoftwareScreen.qml b/layer_grid/SoftwareScreen.qml index 5278504..7ba0bd8 100644 --- a/layer_grid/SoftwareScreen.qml +++ b/layer_grid/SoftwareScreen.qml @@ -65,7 +65,28 @@ FocusScope cycleSort(); return; } - } + // Cycle collection forward + if (api.keys.isNextPage(event) && !event.isAutoRepeat) { + event.accepted = true; + turnOnSfx.play(); + if (currentCollection < api.collections.count-1) { + nextCollection++; + } else { + nextCollection = -1; + } + } + + // Cycle collection back + if (api.keys.isPrevPage(event) && !event.isAutoRepeat) { + event.accepted = true; + turnOffSfx.play(); + if (currentCollection == -1) { + nextCollection = api.collections.count-1; + } else{ + nextCollection--; + } + } + } SequentialAnimation { id: na diff --git a/layer_help/ControllerHelp.qml b/layer_help/ControllerHelp.qml index fd46faf..1fe18aa 100644 --- a/layer_help/ControllerHelp.qml +++ b/layer_help/ControllerHelp.qml @@ -6,14 +6,9 @@ import "../utils.js" as Utils FocusScope { id: root property bool showBack: true - property bool showCollControls: true + property bool showCollControls: false property var gameData: softwareList[sortByIndex].currentGame(currentScreenID) - property string collectionShortName: { - if (currentCollection == -1) - Utils.processPlatformName(currentGame.collections.get(0).shortName) - else - Utils.processPlatformName(api.collections.get(currentCollection).shortName) - } + property string collectionShortName: Utils.processPlatformName(currentGame.collections.get(0).shortName) function processButtonArt(buttonModel) { var i; @@ -39,7 +34,7 @@ FocusScope { height: vpx(70) horizontalAlignment: Image.AlignLeft fillMode: Image.PreserveAspectFit - source: "../assets/images/controllers/" + collectionShortName + ".svg" + source: collectionShortName ? "../assets/images/controllers/" + collectionShortName + ".svg" : "../assets/images/controllers/switch.svg" visible: false anchors { diff --git a/layer_settings/SettingsScreen.qml b/layer_settings/SettingsScreen.qml index c76e9dc..981b620 100644 --- a/layer_settings/SettingsScreen.qml +++ b/layer_settings/SettingsScreen.qml @@ -14,11 +14,18 @@ id: root setting: "Screenshot,Fanart" } + ListElement { + settingName: "Background Music" + settingSubtitle: "(Requires Reload)" + setting: "No,Yes" + } + ListElement { settingName: "Word Wrap on Titles" settingSubtitle: "(Requires Reload)" setting: "Yes,No" } + } diff --git a/resources/Music.qml b/resources/Music.qml new file mode 100644 index 0000000..9ac8bff --- /dev/null +++ b/resources/Music.qml @@ -0,0 +1,80 @@ +import QtQuick 2.15 +import QtMultimedia 5.9 + +Item { + Playlist { + id: bgPlaylist; + + playbackMode: Playlist.Loop; + + // add music files into assets/audio/music + // uncomment PlaylistItem below and repeat for each music file + //PlaylistItem { source: '../assets/audio/music/whatever.mp3'; } + } + + function loud() { + bgMusic.volume = 0.3; + } + + function quiet() { + bgMusic.volume = 0.05; + } + + property bool isPlaying: { + return bgMusic.playbackState === Audio.PlayingState; + } + + Component.onCompleted: { + bgMusicTimer.start(); + + if (playBGM) { + bgPlaylist.shuffle(); + bgMusic.play(); + } else { + bgMusic.stop(); + } + } + + Connections { + target: Qt.application; + function onStateChanged() { + if (playBGM === false) { + console.log('playBGM was false') + return; + } + if (Qt.application.state === Qt.ApplicationActive) { + if (!isPlaying) bgMusic.play(); + } else { + if (isPlaying) bgMusic.pause(); + } + } + } + + Audio { + id: bgMusic; + + volume: 0.3; + playlist: bgPlaylist; + + Behavior on volume { + NumberAnimation { + duration: 250; + easing.type: Easing.InOutQuad; + } + } + } + + Timer { + id: bgMusicTimer; + + interval: 300; + repeat: false; + onTriggered: { + if (bgPlaylist.itemCount > 0 && playBGM) { + console.log('triggered') + bgPlaylist.shuffle(); + bgMusic.play(); + } + } + } +} diff --git a/theme.qml b/theme.qml index 03f7e7a..02853c1 100644 --- a/theme.qml +++ b/theme.qml @@ -12,6 +12,7 @@ import "layer_grid" import "layer_settings" import "layer_help" import "Lists" +import "resources" as Resources FocusScope { @@ -24,7 +25,8 @@ FocusScope timeFormat: api.memory.has("Time Format") ? api.memory.get("Time Format") : "12hr", wordWrap: api.memory.has("Word Wrap on Titles") ? api.memory.get("Word Wrap on Titles") : "Yes", batteryPercentSetting: api.memory.has("Display Battery Percentage") ? api.memory.get("Display Battery Percentage") : "No", - enableDropShadows: api.memory.has("Enable DropShadows") ? api.memory.get("Enable DropShadows") : "Yes" + enableDropShadows: api.memory.has("Enable DropShadows") ? api.memory.get("Enable DropShadows") : "Yes", + playBGM: api.memory.has("Background Music") ? api.memory.get("Background Music"): "No" } } @@ -36,6 +38,7 @@ FocusScope ListMostPlayed { id: listByMostPlayed} ListPublisher { id: listByPublisher} ListAllGames { id: listByTitle} + Resources.Music { id: music} property int currentCollection: api.memory.has('Last Collection') ? api.memory.get('Last Collection') : -1 property int nextCollection: api.memory.has('Last Collection') ? api.memory.get('Last Collection') : -1 @@ -45,7 +48,8 @@ FocusScope property string searchtext property bool wordWrap: (settings.wordWrap === "Yes") ? true : false; property bool showPercent: (settings.batteryPercentSetting === "Yes") ? true : false; - property bool enableDropShadows: (settings.enableDropShadows === "Yes") ? true: false; + property bool enableDropShadows: (settings.enableDropShadows === "Yes") ? true: false; + property bool playBGM: (settings.playBGM === "Yes") ? true : false; onNextCollectionChanged: { changeCollection() } @@ -83,6 +87,7 @@ FocusScope function showHomeScreen() { homeScreen.focus = true; + currentCollection = -1 homeSfx.play() } @@ -253,7 +258,7 @@ FocusScope //starting collection is set here Component.onCompleted: { state: "homescreen" - currentCollection = api.memory.has('Last Collection') ? api.memory.get('Last Collection') : -1 + currentCollection = -1 api.memory.unset('Last Collection'); homeSfx.play() } @@ -272,35 +277,13 @@ FocusScope } // List specific input - Keys.onPressed: { + /*Keys.onPressed: { // disabled /*if (api.keys.isFilters(event) && !event.isAutoRepeat) { event.accepted = true; toggleDarkMode(); - }*/ - - // Cycle collection forward - if (api.keys.isNextPage(event) && !event.isAutoRepeat) { - event.accepted = true; - turnOnSfx.play(); - if (currentCollection < api.collections.count-1) { - nextCollection++; - } else { - nextCollection = -1; - } } - - // Cycle collection back - if (api.keys.isPrevPage(event) && !event.isAutoRepeat) { - event.accepted = true; - turnOffSfx.play(); - if (currentCollection == -1) { - nextCollection = api.collections.count-1; - } else{ - nextCollection--; - } - } - } + }*/ SettingsScreen { id: settingsScreen @@ -371,7 +354,7 @@ FocusScope bottom: parent.bottom; } showBack: !homeScreen.focus - showCollControls: !settingsScreen.focus + showCollControls: softwareScreen.focus } }