From 6945d6e6f458bd5df950c729964a7e8c1f6cf93d Mon Sep 17 00:00:00 2001 From: devZoGok Date: Mon, 23 Jun 2025 08:18:43 +0300 Subject: [PATCH] stopping music in the map editor --- Assets/Scripts/Gui/mapEditor.lua | 1 + Assets/Scripts/Gui/singlePlayerMenu.lua | 6 ++++++ concreteGuiManager.cpp | 9 ++++++++- external/gameBase | 2 +- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/Gui/mapEditor.lua b/Assets/Scripts/Gui/mapEditor.lua index b17dda4..9fb8576 100644 --- a/Assets/Scripts/Gui/mapEditor.lua +++ b/Assets/Scripts/Gui/mapEditor.lua @@ -1,3 +1,4 @@ +music = {tracks = {}} numGui = 6 Size = {x = 140, y = 20} diff --git a/Assets/Scripts/Gui/singlePlayerMenu.lua b/Assets/Scripts/Gui/singlePlayerMenu.lua index 3653569..5d13e8f 100644 --- a/Assets/Scripts/Gui/singlePlayerMenu.lua +++ b/Assets/Scripts/Gui/singlePlayerMenu.lua @@ -1,4 +1,10 @@ Size = {x = 100, y = 20} +music = { + loop = true, + shuffle = false, + delay = 2000, + tracks = {'intro.ogg'} +} gui = { { diff --git a/concreteGuiManager.cpp b/concreteGuiManager.cpp index 1b6c301..fe32be2 100644 --- a/concreteGuiManager.cpp +++ b/concreteGuiManager.cpp @@ -543,6 +543,13 @@ namespace battleship{ if(musicTblOpt == sol::nullopt) return; sol::table musicTbl = SOL_STATE_VIEW["music"], tracksTbl = musicTbl["tracks"]; + SoundManager *sm = SoundManager::getSingleton(); + + if(tracksTbl.size() == 0){ + sm->clearPlaylist(); + return; + } + bool loop = musicTbl["loop"], shuffle = musicTbl["shuffle"]; int delay = musicTbl["delay"].get_or(0); int numTracks = tracksTbl.size(); @@ -554,7 +561,7 @@ namespace battleship{ trackPaths.push_back(GameManager::getSingleton()->getPath() + "Sounds/Music/" + track); } - SoundManager::getSingleton()->play(trackPaths, 100, delay, loop, shuffle); + sm->play(trackPaths, 100, delay, loop, shuffle); } void ConcreteGuiManager::readLuaScreenScript( diff --git a/external/gameBase b/external/gameBase index 201f50f..b3d81ab 160000 --- a/external/gameBase +++ b/external/gameBase @@ -1 +1 @@ -Subproject commit 201f50f6cfaf4b8745bad785b844e7946c2a88e8 +Subproject commit b3d81ab78b51071dda170fd01d3ee0d93e10f9d4