stratagus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Stratagus-CVS] stratagus src/sound/sound_server.c src/ui/menus...


From: address@hidden
Subject: [Stratagus-CVS] stratagus src/sound/sound_server.c src/ui/menus...
Date: 2 Jan 2004 11:57:33 +1100

CVSROOT:        /home/strat
Module name:    stratagus
Changes by:      <address@hidden>       04/01/02 11:57:32

Modified files:
        src/sound      : sound_server.c 
        src/ui         : menus.c 
        data/ccl       : sound.lua stratagus.lua 

Log message:
        Added MusicStopped callback

Patches:
Index: stratagus/data/ccl/sound.lua
diff -u stratagus/data/ccl/sound.lua:1.1 stratagus/data/ccl/sound.lua:1.2
--- stratagus/data/ccl/sound.lua:1.1    Wed Dec  3 11:38:30 2003
+++ stratagus/data/ccl/sound.lua        Fri Jan  2 11:57:32 2004
@@ -26,7 +26,7 @@
 --      along with this program; if not, write to the Free Software
 --      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  
USA
 --
---     $Id: sound.lua,v 1.1 2003/12/03 00:38:30 jsalmon3 Exp $
+--     $Id: sound.lua,v 1.2 2004/01/02 00:57:32 jsalmon3 Exp $
 
 --     Uncomment this to enable threaded sound
 --SoundThread()
@@ -35,13 +35,20 @@
 --     Music part
 
 ------------------------------------------------------------------------------
---     (music-stopped) is called if the current music is finished.
+--     MusicStopped is called if the current music is finished.
 --
 --             This is a random music player demo
 --
---(define (music-stopped)
---  (if (not (= (length play-list) 0)) 
---    (play-music (nth (rand (length play-list)) play-list))))
+
+playlist = {
+  "music/default.mod"
+}
+
+function MusicStopped()
+  if (table.getn(playlist) ~= 0) then
+    PlayMusic(playlist[math.random(table.getn(playlist))])
+  end
+end
 
 ------------------------------------------------------------------------------
 --     (set-cd-mode!) set how your CD is played.
Index: stratagus/data/ccl/stratagus.lua
diff -u stratagus/data/ccl/stratagus.lua:1.9 
stratagus/data/ccl/stratagus.lua:1.10
--- stratagus/data/ccl/stratagus.lua:1.9        Fri Jan  2 11:37:26 2004
+++ stratagus/data/ccl/stratagus.lua    Fri Jan  2 11:57:32 2004
@@ -26,7 +26,7 @@
 --      along with this program; if not, write to the Free Software
 --      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  
USA
 --
---      $Id: stratagus.lua,v 1.9 2004/01/02 00:37:26 jsalmon3 Exp $
+--      $Id: stratagus.lua,v 1.10 2004/01/02 00:57:32 jsalmon3 Exp $
 
 -- For documentation see stratagus/doc/ccl/ccl.html
 --[[
@@ -82,46 +82,7 @@
 --  set the default map file.
 SetDefaultMap("puds/default.pud")
 
--------------------------------------------------------------------------------
---  Music play list - Insert your titles here
-
---
---  Create a list from the directory content
---
---[[
-(define (dir->list s . prepend)
-  (define (aux d rl p)
-    (let ((q (readdir d)))
-      (cond ((eof-object? q)
-             (closedir d)
-             rl)
-            (else
-             (if (or (equal? q ".") (equal? q ".."))
-                 (aux d rl p)
-                 (aux d (cons (string-append p q) rl) p))))))
-
-  (aux (opendir s) '() (if (string? (car prepend))
-                           (car prepend) 
-                           "")))
-
-;; hack to detect WC2 directory without data extracted
-(if (< (length (dir->list (library-path) nil)) 6)
-  (begin
-    (writes nil "You are trying to run the WC2 but your data seems 
incomplete.\n")
-    (writes nil "Use tools/wartool or specify another game with '-d 
/path/to/gamedir'!\n")))
-
-;; Uncomment to play automatic all music
-;; FIXME: Comments are wrong, system dependend stuff didn't belong into the
-;;       config files.
-(if (eq? (os-classification) (intern "win32"))
-  (define play-list
-    (dir->list (string-append (library-path) "/music/*") "music/"))
-  (define play-list
-    (dir->list (string-append (library-path) "/music") "music/")))
 
-;; Comment this, if you use above
-;(define play-list (list "music/default.mod"))
-]]
 SetSelectionStyle("corners")
 SetShowSightRange(false)
 SetShowAttackRange(false)
Index: stratagus/src/sound/sound_server.c
diff -u stratagus/src/sound/sound_server.c:1.128 
stratagus/src/sound/sound_server.c:1.129
--- stratagus/src/sound/sound_server.c:1.128    Tue Dec 23 14:48:04 2003
+++ stratagus/src/sound/sound_server.c  Fri Jan  2 11:57:28 2004
@@ -27,7 +27,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: sound_server.c,v 1.128 2003/12/23 03:48:04 jsalmon3 Exp $
+//     $Id: sound_server.c,v 1.129 2004/01/02 00:57:28 jsalmon3 Exp $
 
 //@{
 
@@ -152,10 +152,7 @@
 */
 global void PlayListAdvance(void)
 {
-#if defined(USE_GUILE) || defined(USE_SIOD)
        int proceed;
-       SCM cb;
-       SCM value;
 
 #ifdef USE_SDLA
        SDL_LockMutex(MusicTerminatedMutex);
@@ -167,17 +164,10 @@
 #endif
 
        if (proceed) {
-               cb = gh_symbol2scm("music-stopped");
-               if (symbol_boundp(cb, NIL)) {
-
-                       value = symbol_value(cb, NIL);
-                       if (!gh_null_p(value)) {
-                               gh_apply(value, NIL);
-                       }
-               }
+               lua_pushstring(Lua, "MusicStopped");
+               lua_gettable(Lua, LUA_GLOBALSINDEX);
+               LuaCall(0, 1);
        }
-#elif defined(USE_LUA)
-#endif
 }
 
 /**
Index: stratagus/src/ui/menus.c
diff -u stratagus/src/ui/menus.c:1.599 stratagus/src/ui/menus.c:1.600
--- stratagus/src/ui/menus.c:1.599      Sat Dec 20 16:33:41 2003
+++ stratagus/src/ui/menus.c    Fri Jan  2 11:57:29 2004
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: menus.c,v 1.599 2003/12/20 05:33:41 jsalmon3 Exp $
+//     $Id: menus.c,v 1.600 2004/01/02 00:57:29 jsalmon3 Exp $
 
 //@{
 
@@ -1842,28 +1842,17 @@
 local void SetMusicPower(Menuitem *mi __attribute__((unused)))
 {
 #ifdef WITH_SOUND
-#if defined(USE_GUILE) || defined(USE_SIOD)
-       SCM cb;
-
        if (PlayingMusic) {
                MusicOff = 1;
                StopMusic();
        } else {
                MusicOff = 0;
                if (CallbackMusic) {
-                       cb = gh_symbol2scm("music-stopped");
-                       if (symbol_boundp(cb, NIL)) {
-                               SCM value;
-
-                               value = symbol_value(cb, NIL);
-                               if (!gh_null_p(value)) {
-                                       gh_apply(value, NIL);
-                               }
-                       }
+                       lua_pushstring(Lua, "MusicStopped");
+                       lua_gettable(Lua, LUA_GLOBALSINDEX);
+                       LuaCall(0, 1);
                }
        }
-#elif defined(USE_LUA)
-#endif
 #endif // WITH_SOUND
        SoundOptionsInit(NULL);
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]