home *** CD-ROM | disk | FTP | other *** search
/ CyberMycha 2006 April / SGP.iso / dema / Keepsake-Demo-en-li-v1.0.exe / res / interface / common / itf.sidebar.tcl < prev    next >
Text File  |  2005-10-31  |  5KB  |  167 lines

  1. proc create_itf {this itf class prop} {
  2.     upvar $itf i
  3.     if {$i == 0} {
  4.         set $itf [new $class]
  5.         eval "oz'widget::property $i $prop"
  6.         oz'widget::child [FOREGROUNDWIDGET] $i 0.5
  7.             
  8.         oz'event {oz'delay 0.001}
  9.         oz'event {itf'sidebar::unselect_all $this}
  10.         oz'event {oz'widget::fadeto $i 1}
  11.     } else {
  12.         if {![oz'widget::usable? $i]} {
  13.             itf'sidebar::unselect_all $this
  14.             oz'widget::fadeto $i 1
  15.         }
  16.     }
  17. }
  18.     
  19. proc hide_widget {w} {
  20.         if {$w != 0} {
  21.             if [oz'widget::usable? $w] {
  22.                 oz'widget::fadeto $w 0
  23.             }
  24.         }
  25. }
  26.     
  27. proc delete_widget {object} {
  28.     upvar $object o
  29.     if {$o != 0} {
  30.         oz'event {
  31.             if [oz'widget::usable?  $o] {oz'return remove}
  32.             if [oz'widget::visible? $o] {oz'return queue}
  33.             delete $o
  34.             set $object 0
  35.         }
  36.     }
  37. }
  38.     
  39.  
  40. class itf'sidebar {
  41.     proc itf'sidebar {this} oz'widget {itf'sidebar} {
  42.         set dirname "interface/[MODE]/sidebar"
  43.  
  44.         set ($this,bg)       [new oz'sprite "$dirname/sidebar.bg"]
  45.         set ($this,inv)      [new oz'button "$dirname/sidebar.inv"]
  46.         set ($this,notebook) [new oz'button "$dirname/sidebar.notebook"]
  47.         set ($this,vision)   [new oz'button "$dirname/sidebar.vision"]
  48.         set ($this,option)   [new oz'button "$dirname/sidebar.option"]
  49.         set ($this,quit)     [new oz'button "$dirname/sidebar.quit"]
  50.  
  51.         oz'widget::bind $this enter itf'sidebar::enter $this
  52.         oz'widget::bind $this leave itf'sidebar::leave $this
  53.  
  54.         oz'widget::property $this -isize [oz'widget::width $($this,bg)] [oz'widget::height $($this,bg)]
  55.  
  56.         oz'button::property $($this,inv)      -click itf'sidebar::inv      $this
  57.         oz'button::property $($this,notebook) -click itf'sidebar::notebook $this
  58.         oz'button::property $($this,vision)   -click itf'sidebar::vision   $this
  59.         oz'button::property $($this,option)   -click itf'sidebar::option   $this
  60.         oz'button::property $($this,quit)     -click itf'sidebar::quit     $this
  61.         oz'widget::property $($this,inv)      -pos 0.005859 0.131510
  62.         oz'widget::property $($this,notebook) -pos 0.005859 0.235677
  63.         oz'widget::property $($this,vision)   -pos 0.005859 0.339844
  64.         oz'widget::property $($this,option)   -pos 0.005859 0.444010
  65.         oz'widget::property $($this,quit)     -pos 0.005859 0.549479
  66.  
  67.         oz'widget::child $this $($this,bg)       1
  68.         oz'widget::child $this $($this,inv)      0
  69.         oz'widget::child $this $($this,notebook) 0
  70.         oz'widget::child $this $($this,vision)   0
  71.         oz'widget::child $this $($this,option)   0
  72.         oz'widget::child $this $($this,quit)     0  
  73.     }
  74.  
  75.     proc ~itf'sidebar {this} {
  76.         delete $($this,bg)
  77.         delete $($this,inv)
  78.         delete $($this,notebook)
  79.         delete $($this,visiov)
  80.         delete $($this,option)
  81.         delete $($this,quit)
  82.     }
  83.  
  84.     proc show {this} {
  85.         oz'widget::fadeto $this 1
  86.     }
  87.  
  88.     proc hide {this} {
  89.         unselect_all $this
  90.         oz'widget::fadeto $this 0
  91.     }
  92.  
  93.     proc unselect_all {this} {
  94.         oz'button::unselect $($this,inv)
  95.         oz'button::unselect $($this,notebook)
  96.         oz'button::unselect $($this,vision)
  97.         oz'button::unselect $($this,option)
  98.         oz'button::unselect $($this,quit)
  99.  
  100.         unselect_inv $this
  101.         unselect_notebook $this
  102.         unselect_vision $this
  103.         unselect_option $this
  104.         unselect_quit $this
  105.     }
  106.         
  107.     proc notebook {this} {
  108.         itf'sidebar::unselect_all $this
  109.         oz'button::select $($this,notebook)
  110.         itf'inventory::show $::itf::inventory 2
  111.     }
  112.  
  113.     proc unselect_notebook {this} {
  114.         itf'inventory::hide $::itf::inventory
  115.     }
  116.  
  117.     proc vision {this} {
  118.         itf'sidebar::unselect_all $this
  119.         oz'button::select $($this,vision)
  120.         itf'vision::show $::itf::vision
  121.     }
  122.  
  123.     proc unselect_vision {this} {
  124.         itf'vision::hide $::itf::vision
  125.     }
  126.  
  127.     proc option {this} {
  128.         itf'sidebar::unselect_all $this
  129.         oz'button::select $($this,option)
  130.         oz'widget::fadeto $::itf::option 1
  131.     }
  132.  
  133.     proc unselect_option {this} {
  134.         oz'widget::fadeto $::itf::option 0
  135.     }
  136.  
  137.     proc inv {this} {
  138.         itf'sidebar::unselect_all $this
  139.         oz'button::select $($this,inv)
  140.         itf'inventory::show $::itf::inventory 1
  141.     }
  142.  
  143.     proc unselect_inv {this} {
  144.         itf'inventory::hide $::itf::inventory
  145.     }
  146.  
  147.     proc quit {this} {
  148.         itf'sidebar::unselect_all $this
  149.         oz'button::select $($this,quit)
  150.         oz'widget::fadeto $::itf::quit 1
  151.     }
  152.  
  153.     proc unselect_quit {this} {
  154.         oz'widget::fadeto $::itf::quit 0
  155.     }
  156.  
  157.     proc enter {this} {
  158.         oz'mouse::cursor +100
  159.     }
  160.  
  161.     proc leave {this} {
  162.         oz'mouse::cursor -100
  163.     }
  164. }
  165.  
  166.  
  167.