home *** CD-ROM | disk | FTP | other *** search
/ CyberMycha 2006 April / SGP.iso / dema / Keepsake-Demo-en-li-v1.0.exe / res / init.tcl < prev    next >
Text File  |  2005-10-29  |  7KB  |  232 lines

  1. proc const { name value } {
  2.     eval [subst {proc $name {} {return $value}}]
  3. }
  4.  
  5. const ROOT    "../res"
  6. const SCRIPTS "[ROOT]/scripts"
  7. const SCENES  "[ROOT]/scenes/common"
  8. const BIN     "[ROOT]/bin"
  9. const PUZZLES "[ROOT]/puzzles"
  10. const AUTO    "[ROOT]/auto"
  11. const ITF     "[ROOT]/interface/common"
  12.  
  13. source "[ROOT]/config.tcl"
  14. const MODE ${config::screen::width}x${config::screen::height}
  15. const MOVIE_QUALITY ${config::movie::width}x${config::movie::height}
  16.  
  17. namespace eval movie {}
  18.  
  19. set SCENES  [SCENES]
  20. set SCRIPTS [SCRIPTS]
  21. set PUZZLES [PUZZLES]
  22.  
  23. const TRUE  1
  24. const FALSE 0
  25.  
  26. source "[BIN]/prime/stooop.tcl"
  27. namespace import stooop::*
  28.  
  29. source "[BIN]/prime/cmdinterp.tcl"
  30.  
  31. source "[BIN]/prime/oz'event.tcl"
  32. source "[BIN]/prime/wtcl.tcl"
  33.  
  34. const BACKGROUNDWIDGET [new oz'widget background]
  35. const FOREGROUNDWIDGET [new oz'widget foreground]
  36. const INTERFACEWIDGET  [new oz'widget interface]
  37.  
  38. source "[BIN]/prime/oz'widget.tcl"
  39. source "[BIN]/prime/oz'label.tcl"
  40. source "[BIN]/prime/oz'sprite.tcl"
  41. source "[BIN]/prime/oz'button.tcl"
  42.  
  43. source "[BIN]/prime/oz'sound.tcl"
  44. source "[BIN]/prime/oz'track.tcl"
  45.  
  46. source "../res/bin/wizardofoz.tcl"
  47. source "[SCRIPTS]/tools.tcl"
  48.  
  49. namespace eval sfx {}
  50.  
  51. proc SetAmbient {type name pos ref vol {roll 1}} {
  52.     if ![info exists ::sfx::$name] {set ::sfx::$name 0}
  53.     
  54.     set factor 1
  55.     if {![set ::sfx::$name] && $vol} {
  56.         set ::sfx::$name [new oz'sound "sound/$name.ogg"]
  57.         oz'sound::volume [set ::sfx::$name] 0.01
  58.         if {$type == "3d"} {oz'sound::streaming [set ::sfx::$name] 0}
  59.         oz'sound::repeat [set ::sfx::$name] 1
  60.         oz'sound::play [set ::sfx::$name]
  61.         set factor 5
  62.     }
  63.  
  64.     if [set ::sfx::$name] {
  65.         if !$vol {
  66.             set factor 2
  67.         }
  68.  
  69.         oz'sound::fadeto [set ::sfx::$name] \
  70.                          [expr [set config::ambient${type}::volume] * $vol] \
  71.                          [expr [set config::ambient${type}::crosstime] * $factor]
  72.  
  73.         oz'sound::position [set ::sfx::$name] $pos
  74.         oz'sound::reference_distance [set ::sfx::$name] $ref
  75.         oz'sound::rolloff [set ::sfx::$name] $roll
  76.  
  77.         if !$vol {set ::sfx::$name 0}
  78.     }
  79. }
  80.  
  81. proc Play3DSound {name {entity Lydia}} {
  82.     ozqSound::New3DFX s "sound/$name.ogg"
  83.     oz'event {
  84.     ozqSound::Position $s [wizEntityGetPosition $entity]
  85.     }
  86.     ozqSound::Volume $s 1
  87.     ozqSound::ReferenceDistance $s 30
  88.     ozqSound::Rolloff $s 0.6
  89.     ozqSound::Play $s
  90.     unset s
  91. }    
  92.  
  93. proc PlayMovieSound {scene movie sound args} {
  94.     oz'event {
  95.         ozSet mvDisableMouse 0
  96.         if [ozIsEnable mouse] {
  97.             wizDisableMouse
  98.             ozSet mvDisableMouse 1
  99.         }
  100.     }
  101.    
  102.     eval "${scene}::new $movie $args"
  103.     ozqSound::NewFX  "sound/$sound.ogg"
  104.     wq'widget::waitfor [set ${scene}::$movie] -animate
  105.     wq'widget::delete&  ${scene}::$movie
  106.  
  107.     oz'event {
  108.          if [ozGet mvDisableMouse] {
  109.             wizEnableMouse
  110.          }
  111.     }
  112. }
  113.  
  114. proc SetModelLydia {} {
  115.     set book    [expr {[ozGet "itemNoteBook"] == "pickedUp"}]
  116.     set circlet [expr {[ozGet "itemCirclet"]  == "pickedUp"}]
  117.     set doll    [expr {[ozGet "itemDoll"]     == "pickedUp"}]
  118.     set staff   [expr {[ozGet "itemStaff"]    == "pickedUp"}]
  119.     set suffix  ""
  120.  
  121.     if { $book && !$circlet && !$doll && !$staff} {set suffix  "-book"}
  122.     if { $book &&  $circlet &&  $doll && !$staff} {set suffix  "-book-circlet-doll"}
  123.     if { $book &&  $circlet &&  $doll &&  $staff} {set suffix  "-book-circlet-doll-staff"}
  124.     if { $book && !$circlet &&  $doll && !$staff} {set suffix  "-book-doll"}
  125.     if { $book && !$circlet &&  $doll &&  $staff} {set suffix  "-book-doll-staff"}
  126.     if {!$book &&  $circlet &&  $doll && !$staff} {set suffix  "-circlet-doll"}
  127.     if {!$book &&  $circlet &&  $doll &&  $staff} {set suffix  "-circlet-doll-staff"}
  128.     if {!$book && !$circlet &&  $doll && !$staff} {set suffix  "-doll"}
  129.     if {!$book && !$circlet &&  $doll &&  $staff} {set suffix  "-doll-staff"}
  130.  
  131.     ozEntityLydia model "/character/lydia/lydia$suffix.cal3d"
  132. }
  133.  
  134. proc tclGet {var} {
  135.     set value "UNDEFINED!"
  136.     catch {set value [set $var]}
  137.     return $value
  138. }
  139.  
  140. proc PlaySound {name} {
  141.     set v [new oz'sound "sound/$name.ogg"]
  142.     oz'sound::volume $v $config::soundfx::volume
  143.     oz'sound::play $v
  144.     unset v
  145. }
  146.  
  147. proc Load1 {} {
  148.     oz'event {set ::isGameReady 0}
  149.     oz'event {hideInterface}
  150.     oz'event {wizDisableMouse}
  151.     oz'event {oz'delay 0.01}
  152.     oz'event {standardFadeout}
  153.         
  154.     oz'event {oz'track::stop $::music_track}
  155.     oz'event {source "[ROOT]/save/savegame1.tcl"}
  156.     oz'event {initializeGame}
  157.     oz'event {showInterface}
  158.     oz'event {oz'delay 0.01}
  159.     oz'event {standardFadein}
  160.     oz'event {wizEnableMouse}
  161.     oz'event {set ::isGameReady 1}
  162. }
  163.  
  164. proc Load2 {} {
  165.     oz'event {set ::isGameReady 0}
  166.     oz'event {hideInterface}
  167.     oz'event {wizDisableMouse}
  168.     oz'event {oz'delay 0.01}
  169.     oz'event {standardFadeout}
  170.         
  171.     oz'event {oz'track::stop $::music_track}
  172.     oz'event {source "[ROOT]/save/savegame2.tcl"}
  173.     oz'event {initializeGame}
  174.     oz'event {showInterface}
  175.     oz'event {oz'delay 0.01}
  176.     oz'event {standardFadein}
  177.     oz'event {wizEnableMouse}
  178.     oz'event {set ::isGameReady 1}
  179. }
  180.  
  181. proc Load3 {} {
  182.     oz'event {set ::isGameReady 0}
  183.     oz'event {hideInterface}
  184.     oz'event {wizDisableMouse}
  185.     oz'event {oz'delay 0.01}
  186.     oz'event {standardFadeout}
  187.         
  188.     oz'event {oz'track::stop $::music_track}
  189.     oz'event {source "[ROOT]/save/savegame3.tcl"}
  190.     oz'event {initializeGame}
  191.     oz'event {showInterface}
  192.     oz'event {oz'delay 0.01}
  193.     oz'event {standardFadein}
  194.     oz'event {wizEnableMouse}
  195.     oz'event {set ::isGameReady 1}
  196. }
  197.  
  198. proc Load4 {} {
  199.     oz'event {set ::isGameReady 0}
  200.     oz'event {hideInterface}
  201.     oz'event {wizDisableMouse}
  202.     oz'event {oz'delay 0.01}
  203.     oz'event {standardFadeout}
  204.         
  205.     oz'event {oz'track::stop $::music_track}
  206.     oz'event {source "[ROOT]/save/savegame4.tcl"}
  207.     oz'event {initializeGame}
  208.     oz'event {showInterface}
  209.     oz'event {oz'delay 0.01}
  210.     oz'event {standardFadein}
  211.     oz'event {wizEnableMouse}
  212.     oz'event {set ::isGameReady 1}
  213. }
  214.  
  215. proc Load5 {} {
  216.     oz'event {set ::isGameReady 0}
  217.     oz'event {hideInterface}
  218.     oz'event {wizDisableMouse}
  219.     oz'event {oz'delay 0.01}
  220.     oz'event {standardFadeout}
  221.         
  222.     oz'event {oz'track::stop $::music_track}
  223.     oz'event {source "[ROOT]/save/savegame5.tcl"}
  224.     oz'event {initializeGame}
  225.     oz'event {showInterface}
  226.     oz'event {oz'delay 0.01}
  227.     oz'event {standardFadein}
  228.     oz'event {wizEnableMouse}
  229.     oz'event {set ::isGameReady 1}
  230. }
  231.  
  232.