]> git.zerfleddert.de Git - micropolis/blame - src/notes/Dynamic.tcl
rename setenv and unsetenv to not clash with functions provided by libc
[micropolis] / src / notes / Dynamic.tcl
CommitLineData
6a5fa4e0
MG
1option add *Interval.activeForeground #d0d0d0
2option add *Interval.sliderForeground #b0b0b0
3option add *Interval.activeForeground #d0d0d0
4option add *Interval.sliderForeground #b0b0b0
5
6########################################################################
7# Dynamic Map Handlers
8
9proc ShowDynamicPanel {win} {
10 if {! [winfo ismapped $win.bottomframe]} {
11 pack append $win $win.bottomframe {bottom frame center fill expand}
12 set x [winfo rootx $win]
13 set y [winfo rooty $win]
14 set width [winfo width $win]
15 set height 670
16 wm geometry $win ${width}x${height}
17 }
18}
19
20
21proc HideDynamicPanel {win} {
22 if {[winfo ismapped $win.bottomframe]} {
23 pack unpack $win.bottomframe
24 set x [winfo rootx $win]
25 set y [winfo rooty $win]
26 set width [winfo width $win]
27 set height 332
28 wm geometry $win ${width}x${height}
29 }
30}
31
32
33proc InitDynamic {} {
34 global MapWindows
35 sim ResetDynamic
36
37 for {set i 0} {$i < 8} {incr i} {
38 foreach win $MapWindows {
39 [WindowLink $win.interval]$i reset
40 }
41 }
42
43}
44
45
46proc SetDynamicData {win index min max} {
47 set MinIndex [expr "$index * 2"]
48 set MaxIndex [expr "$MinIndex + 1"]
49
50 sim DynamicData $MinIndex $min
51 sim DynamicData $MaxIndex $max
52
53 set int [WindowLink $win.interval]$index
54 set from [lindex [$int config -from] 4]
55 set to [lindex [$int config -to] 4]
56 set min [lindex [$int config -min] 4]
57 set max [lindex [$int config -max] 4]
58 set range [expr "${to}-${from}"]
59 set offset 80
60 set scale 100
61 set low [expr "(($min-$from)*$scale/$range) + $offset"]
62 set high [expr "(($max-$from)*$scale/$range) + $offset"]
63 set sound 29
64 set title Slider$index
65 set vol 70
66 set chan fancy
67
68 UIDoSound "\"sound replay $title -channel $chan -volume $vol ; sound replay $sound -channel $chan -volume $vol -speed $low ; sound play $sound -channel $chan -volume $vol -speed $high\""
69
70 global MapWindows
71 foreach win $MapWindows {
72 [WindowLink $win.interval]$index set $min $max
73 }
74}
75
76
77
78
79
80global MapTitles
81set MapTitles {
82 {Micropolis Map}
83 {Residential Zone Map}
84 {Commercial Zone Map}
85 {Industrial Zone Map}
86 {Power Grid Map}
87 {Transportation Map}
88 {Population Density Map}
89 {Rate of Growth Map}
90 {Traffic Map}
91 {Pollution Map}
92 {Crime Map}
93 {Land Value Map}
94 {Fire Station Map}
95 {Police Station Map}
96 {Dynamic Query Map}
97}
98
99
100
101
102proc UISetMapState {w state} {
103 global MapTitles
104 set win [winfo toplevel $w]
105 set m [WindowLink $win.view]
106 set title [lindex $MapTitles $state]
107 wm title $win "$title"
108 wm iconname $win "$title"
109 global [set var MapState.$win]
110 set $var $state
111
112 case $state { \
113 {6 8 9 10 11 12 13} {
114 [WindowLink $win.legend] config -bitmap "@Images/LegendMaxMin.xpm"
115 HideDynamicPanel $win
116 } \
117 {7} {
118 [WindowLink $win.legend] config -bitmap "@Images/LegendPlusMinus.xpm"
119 HideDynamicPanel $win
120 } \
121 {0 1 2 3 4 5 14} {
122 [WindowLink $win.legend] config -bitmap "@Images/LegendNone.xpm"
123 if {$state == 14} {
124 ShowDynamicPanel $win
125 } else {
126 HideDynamicPanel $win
127 }
128 }
129 }
130}
131
132
Impressum, Datenschutz