1 #######################################################################
2 # Micropolis.tcl, by Don Hopkins.
3 # Copyright (C) 2002 by Electronic Arts.
4 # This file defines the user interface of Micropolis.
5 # Modify at your own risk!
6 ########################################################################
7 # Micropolis, Unix Version. This game was released for the Unix platform
8 # in or about 1990 and has been modified for inclusion in the One Laptop
9 # Per Child program. Copyright (C) 1989 - 2007 Electronic Arts Inc. If
10 # you need assistance with this program, you may contact:
11 # http://wiki.laptop.org/go/Micropolis or email micropolis@laptop.org.
13 # This program is free software: you can redistribute it and/or modify
14 # it under the terms of the GNU General Public License as published by
15 # the Free Software Foundation, either version 3 of the License, or (at
16 # your option) any later version.
18 # This program is distributed in the hope that it will be useful, but
19 # WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 # General Public License for more details. You should have received a
22 # copy of the GNU General Public License along with this program. If
23 # not, see <http://www.gnu.org/licenses/>.
25 # ADDITIONAL TERMS per GNU GPL Section 7
27 # No trademark or publicity rights are granted. This license does NOT
28 # give you any right, title or interest in the trademark SimCity or any
29 # other Electronic Arts trademark. You may not distribute any
30 # modification of this program using the trademark SimCity or claim any
31 # affliation or association with Electronic Arts Inc. or its employees.
33 # Any propagation or conveyance of this program must include this
34 # copyright notice and these terms.
36 # If you convey this program (or any modifications of it) and assume
37 # contractual liability for the program to recipients of it, you agree
38 # to indemnify Electronic Arts for any liability that those contractual
39 # assumptions impose on Electronic Arts.
41 # You may not misrepresent the origins of this program; modified
42 # versions of the program must be marked as such and not identified as
43 # the original program.
45 # This disclaimer supplements the one included in the General Public
46 # License. TO THE FULLEST EXTENT PERMISSIBLE UNDER APPLICABLE LAW, THIS
47 # PROGRAM IS PROVIDED TO YOU "AS IS," WITH ALL FAULTS, WITHOUT WARRANTY
48 # OF ANY KIND, AND YOUR USE IS AT YOUR SOLE RISK. THE ENTIRE RISK OF
49 # SATISFACTORY QUALITY AND PERFORMANCE RESIDES WITH YOU. ELECTRONIC ARTS
50 # DISCLAIMS ANY AND ALL EXPRESS, IMPLIED OR STATUTORY WARRANTIES,
51 # INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY, SATISFACTORY QUALITY,
52 # FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT OF THIRD PARTY
53 # RIGHTS, AND WARRANTIES (IF ANY) ARISING FROM A COURSE OF DEALING,
54 # USAGE, OR TRADE PRACTICE. ELECTRONIC ARTS DOES NOT WARRANT AGAINST
55 # INTERFERENCE WITH YOUR ENJOYMENT OF THE PROGRAM; THAT THE PROGRAM WILL
56 # MEET YOUR REQUIREMENTS; THAT OPERATION OF THE PROGRAM WILL BE
57 # UNINTERRUPTED OR ERROR-FREE, OR THAT THE PROGRAM WILL BE COMPATIBLE
58 # WITH THIRD PARTY SOFTWARE OR THAT ANY ERRORS IN THE PROGRAM WILL BE
59 # CORRECTED. NO ORAL OR WRITTEN ADVICE PROVIDED BY ELECTRONIC ARTS OR
60 # ANY AUTHORIZED REPRESENTATIVE SHALL CREATE A WARRANTY. SOME
61 # JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF OR LIMITATIONS ON IMPLIED
62 # WARRANTIES OR THE LIMITATIONS ON THE APPLICABLE STATUTORY RIGHTS OF A
63 # CONSUMER, SO SOME OR ALL OF THE ABOVE EXCLUSIONS AND LIMITATIONS MAY
67 ########################################################################
69 ########################################################################
75 source $tk_library/wish.tcl
78 ########################################################################
80 ########################################################################
84 set State uninitialized
85 set CityName
"Micropolis"
88 set CityLibDir
$SimHome/cities
89 set CityDir
$CityLibDir
93 set BudgetPoliceFund
0
111 set AudioChannels
{mode edit fancy warning intercom
}
114 set BudgetTimerActive
0
116 set EvaluationsVisible
0
117 set SplashScreenDelay
5000
120 set ChatServer
"localhost"
122 set ChatConnection
{}
123 set NickName
"nickname"
124 set UserName
"username"
125 set ServerName
"servername"
126 set RealName
"realname"
127 set ChannelName
"#Micropolis"
131 set LocalHostName
"[exec hostname]"
139 set ShowingPicture
300
143 set VoteNames
{UseThisMap Ask Zone
}
144 set VotesForUseThisMap
{}
147 set VotesForBudget
{}
155 set EvaluationWindows
{}
157 set ScenarioWindows
{}
165 set HeadPanelWidth
360
166 set HeadPanelHeight
200
168 set MapPanelWidth
360
169 set MapPanelHeight
330
171 set NoticePanelWidth
360
172 set NoticePanelHeight
250
174 set SplashPanelWidth
1200
175 set SplashPanelHeight
900
177 #set ScenarioPanelWidth 420
178 #set ScenarioPanelHeight 440
179 set ScenarioPanelWidth
1200
180 set ScenarioPanelHeight
900
189 {editor EditorWindows
}
192 {budget BudgetWindows
}
193 {evaluation EvaluationWindows
}
194 {scenario ScenarioWindows
}
195 {splash SplashWindows
}
198 {player PlayerWindows
}
199 {notice NoticeWindows
}
206 # 0 1 2 3 4 5 6 7 8 9 10 11 12 13
207 # type id callback param var x y w h normal over disabled checked checkedover
208 # ----------- --------------- --------------- ------- ------- --- --- --- --- ------- ---- -------- ------- -----------
209 set ScenarioButtons1200x900
{
210 { button load DoLoad
"" "" 70 238 157 90 "" @images
/button1hilite.xpm
"" }
211 { button generate DoGenerate
"" "" 62 392 157 90 "" @images
/button2hilite.xpm
"" }
212 { button quit DoQuit
"" "" 68 544 157 90 "" @images
/button3hilite.xpm
"" }
213 { button about DoAbout
"" "" 101 705 157 90 "" @images
/button4hilite.xpm
"" }
214 { checkbox easy DoLevel
0 "" 982 106 190 70 "" @images
/checkbox1hilite.xpm
"" @images
/checkbox1checked.xpm
@images
/checkbox1hilitechecked.xpm
}
215 { checkbox medium DoLevel
1 "" 982 176 190 70 "" @images
/checkbox2hilite.xpm
"" @images
/checkbox2checked.xpm
@images
/checkbox2hilitechecked.xpm
}
216 { checkbox hard DoLevel
2 "" 982 246 190 70 "" @images
/checkbox3hilite.xpm
"" @images
/checkbox3checked.xpm
@images
/checkbox3hilitechecked.xpm
}
217 { button left DoLeft
"" "" 540 375 50 50 "" @images
/lefthilite.xpm
@images
/leftdisabled.xpm
}
218 { button right DoRight
"" "" 841 375 50 50 "" @images
/righthilite.xpm
@images
/rightdisabled.xpm
}
219 { button play DoPlay
"" "" 625 376 180 50 "" @images
/playhilite.xpm
"" }
220 { button scenario1 DoPickScenario
"1" "" 310 451 209 188 "" @images
/scenario1hilite.xpm
"" }
221 { button scenario2 DoPickScenario
"2" "" 519 451 209 188 "" @images
/scenario2hilite.xpm
"" }
222 { button scenario3 DoPickScenario
"3" "" 727 450 209 188 "" @images
/scenario3hilite.xpm
"" }
223 { button scenario4 DoPickScenario
"4" "" 936 450 209 188 "" @images
/scenario4hilite.xpm
"" }
224 { button scenario5 DoPickScenario
"5" "" 310 639 209 188 "" @images
/scenario5hilite.xpm
"" }
225 { button scenario6 DoPickScenario
"8" "" 519 639 209 188 "" @images
/scenario6hilite.xpm
"" }
226 { button scenario7 DoPickScenario
"7" "" 728 638 209 188 "" @images
/scenario7hilite.xpm
"" }
227 { button scenario8 DoPickScenario
"6" "" 937 638 209 188 "" @images
/scenario8hilite.xpm
"" }
230 set ScenarioButtons600x450
{
231 { button load DoLoad
"" "" 35 119 79 45 "" @images
/button1hilite-small.xpm
"" }
232 { button generate DoGenerate
"" "" 31 196 79 45 "" @images
/button2hilite-small.xpm
"" }
233 { button quit DoQuit
"" "" 34 272 79 45 "" @images
/button3hilite-small.xpm
"" }
234 { button about DoAbout
"" "" 51 353 79 45 "" @images
/button4hilite-small.xpm
"" }
235 { checkbox easy DoLevel
0 "" 491 53 95 35 "" @images
/checkbox1hilite-small.xpm
"" @images
/checkbox1checked-small.xpm
@images
/checkbox1hilitechecked-small.xpm
}
236 { checkbox medium DoLevel
1 "" 491 88 95 35 "" @images
/checkbox2hilite-small.xpm
"" @images
/checkbox2checked-small.xpm
@images
/checkbox2hilitechecked-small.xpm
}
237 { checkbox hard DoLevel
2 "" 491 123 95 35 "" @images
/checkbox3hilite-small.xpm
"" @images
/checkbox3checked-small.xpm
@images
/checkbox3hilitechecked-small.xpm
}
238 { button left DoLeft
"" "" 270 187 25 25 "" @images
/lefthilite-small.xpm
@images
/leftdisabled-small.xpm
}
239 { button right DoRight
"" "" 420 187 25 25 "" @images
/righthilite-small.xpm
@images
/rightdisabled-small.xpm
}
240 { button play DoPlay
"" "" 312 188 90 25 "" @images
/playhilite-small.xpm
"" }
241 { button scenario1 DoPickScenario
"1" "" 155 225 105 94 "" @images
/scenario1hilite-small.xpm
"" }
242 { button scenario2 DoPickScenario
"2" "" 259 225 105 94 "" @images
/scenario2hilite-small.xpm
"" }
243 { button scenario3 DoPickScenario
"3" "" 363 225 105 94 "" @images
/scenario3hilite-small.xpm
"" }
244 { button scenario4 DoPickScenario
"4" "" 468 225 105 94 "" @images
/scenario4hilite-small.xpm
"" }
245 { button scenario5 DoPickScenario
"5" "" 155 319 105 94 "" @images
/scenario5hilite-small.xpm
"" }
246 { button scenario6 DoPickScenario
"8" "" 259 319 105 94 "" @images
/scenario6hilite-small.xpm
"" }
247 { button scenario7 DoPickScenario
"7" "" 363 319 105 94 "" @images
/scenario7hilite-small.xpm
"" }
248 { button scenario8 DoPickScenario
"6" "" 468 319 105 94 "" @images
/scenario8hilite-small.xpm
"" }
249 { button map DoMap
"" "" 267 24 180 150 "" "" "" }
252 set ScenarioButtons
$ScenarioButtons1200x900
253 set ScenarioBackground
"@images/background-micropolis.xpm"
256 set ScenarioMapFloatX
-1
257 set ScenarioMapFloatY
-1
258 set ScenarioCityNameX
530
259 set ScenarioCityNameY
0
260 set ScenarioDescX
232
261 set ScenarioDescY
170
262 set ScenarioDescWidth
280
263 set ScenarioDescHeight
285
264 set ScenarioDescFont Medium
267 set screenwidth
[winfo screenwidth .
]
268 set screenheight
[winfo screenheight .
]
270 if {($screenwidth < $ScenarioPanelWidth) ||
271 ($screenheight < $ScenarioPanelHeight)} {
272 puts stdout
"Screen too small for normal scenario window, using resized version.\n"
273 set ScenarioBackground
"@images/background-micropolis-small.xpm"
274 set ScenarioPanelWidth
600
275 set ScenarioPanelHeight
450
278 set ScenarioMapFloatX
140
279 set ScenarioMapFloatY
2
280 set ScenarioCityNameX
162
281 set ScenarioCityNameY
422
282 set ScenarioDescX
250
284 set ScenarioDescWidth
240
285 set ScenarioDescHeight
210
286 set ScenarioDescFont Tiny
287 set ScenarioButtons
$ScenarioButtons600x450
291 # Disabled until we handle mouse events on the map itself.
292 # { button map DoMap "" "" 516 30 396 338 "" @images/maphilite.xpm }
295 ########################################################################
301 {-*-helvetica-medium
-r
-normal
-*-20-*-*-*-*-*-*-*}
302 {-*-dejavu lgc sans-medium-r-normal-
*-90-*}
305 {-*-helvetica-medium
-r
-normal
-*-18-*-*-*-*-*-*-*}
306 {-*-dejavu lgc sans-medium-r-normal-
*-80-*}
309 {-*-helvetica-medium
-r
-normal
-*-14-*-*-*-*-*-*-*}
310 {-*-dejavu lgc sans-medium-r-normal-
*-70-*}
313 {-*-helvetica-medium
-r
-normal
-*-12-*-*-*-*-*-*-*}
314 {-*-dejavu lgc sans-medium-r-normal-
*-60-*}
317 {-*-helvetica-medium
-r
-normal
-*-12-*-*-*-*-*-*-*}
318 {-*-dejavu lgc sans-medium-r-normal-
*-60-*}
321 {-*-helvetica-medium
-r
-normal
-*-12-*-*-*-*-*-*-*}
322 {-*-dejavu lgc sans-medium-r-normal-
*-60-*}
325 {-*-helvetica-medium
-r
-normal
-*-14-*-*-*-*-*-*-*}
326 {-*-dejavu lgc sans-medium-r-normal-
*-70-*}
329 {-*-helvetica-medium
-r
-normal
-*-14-*-*-*-*-*-*-*}
330 {-*-dejavu lgc sans-medium-r-normal-
*-70-*}
333 {-*-helvetica-medium
-r
-normal
-*-14-*-*-*-*-*-*-*}
334 {-*-dejavu lgc sans-medium-r-normal-
*-70-*}
339 ########################################################################
343 {Micropolis Overall Map
}
344 {Residential Zone Map
}
345 {Commercial Zone Map
}
346 {Industrial Zone Map
}
349 {Population Density Map
}
351 {Traffic Density Map
}
352 {Pollution Desity Map
}
356 {Police Coverage Map
}
362 leftframe.tools.palletres
363 leftframe.tools.palletcom
364 leftframe.tools.palletind
365 leftframe.tools.palletfire
366 leftframe.tools.palletquery
367 leftframe.tools.palletpolice
368 leftframe.tools.palletwire
369 leftframe.tools.palletbulldozer
370 leftframe.tools.palletrail
371 leftframe.tools.palletroad
372 leftframe.tools.palletchalk
373 leftframe.tools.palleteraser
374 leftframe.tools.palletstadium
375 leftframe.tools.palletpark
376 leftframe.tools.palletseaport
377 leftframe.tools.palletcoal
378 leftframe.tools.palletnuclear
379 leftframe.tools.palletairport
383 set EditorPalletImages
{
384 res com ind fire qry pol
385 wire dozr rail road chlk ersr
386 stad park seap coal nuc airp
390 set EditorPalletSounds
{
391 Res Com Ind Fire Query Police
392 Wire Bulldozer Rail Road Chalk Eraser
393 Stadium Park Seaport Coal Nuclear Airport
401 leftframe.right.money
402 leftframe.right.crime
403 leftframe.right.pollution
407 set GraphPalletImages
{
408 res com ind mony crim poll
412 set GraphYearPallets
{
413 leftframe.year.year10
414 leftframe.year.year120
418 set GraphYearPalletImages
{ 10 120 }
422 { {a
} {Residential Zone
} {$100}}
423 { {a
} {Commercial Zone
} {$100}}
424 { {an
} {Industrial Zone
} {$100}}
425 { {a
} {Fire Station
} {$500}}
426 { {a
} {Query
} {free
}}
427 { {a
} {Police Station
} {$500}}
429 { {a
} {Bulldozer
} {$1}}
432 { {a
} {Chalk
} {free
}}
433 { {an
} {Eraser
} {free
}}
434 { {a
} {Stadium
} {$5,000}}
436 { {a
} {Seaport
} {$3,000}}
437 { {a
} {Coal Power Plant
} {$3,000}}
438 { {a
} {Nuclear Power Plant
} {$5,000}}
439 { {an
} {Airport
} {$10,000}}
440 { {a
} {Network
} {$1,000}}
444 set DynamicDataNames
{
455 ########################################################################
457 ########################################################################
460 wm title .
{Micropolis Root
}
463 if {"[sim Platform]" == "msdos"} {
484 # Ignore SIGCHLD for spawned sound-player childs, this should lead to them
485 # being reaped by init
486 signal ignore SIGCHLD
489 ########################################################################
491 ########################################################################
494 proc Message
{id color title msg
{props
{}}} {
496 set Messages
($id) [list $color $title $msg $props]
500 Message
1 #7f7fff {DULLSVILLE, USA 1900} \
501 {Things haven't changed much around here in the last hundred years or so and the residents are beginning to get bored. They think Dullsville could be the next great city with the right leader.
503 It is your job to attract new growth and development
, turning Dullsville into a Metropolis within
30 years.
}
505 Message
2 #7f7fff {SAN FRANCISCO, CA. 1906} \
506 {Damage from the earthquake was minor compared to that of the ensuing fires
, which took days to control.
1500 people died.
508 Controlling the fires should be your initial concern. Then clear the rubble and start rebuilding. You have
5 years.
}
510 Message
3 #7f7fff {HAMBURG, GERMANY 1944} \
511 {Allied fire-bombing of German cities in WWII caused tremendous damage and loss of life. People living in the inner cities were at greatest risk.
513 You must control the firestorms during the bombing and then rebuild the city
after the war. You have
5 years.
}
515 Message
4 #7f7fff {BERN, SWITZERLAND 1965} \
516 {The roads here are becoming more congested every day
, and the residents are upset. They demand that you do something about it.
518 Some have suggested a mass transit system as the answer
, but this would require major rezoning in the downtown area. You have
10 years.
}
520 Message
5 #7f7fff {TOKYO, JAPAN 1957} \
521 {A large reptilian creature has been spotted heading
for Tokyo bay. It seems to be attracted to the heavy levels of industrial pollution there.
523 Try to control the fires
, then rebuild the industrial center. You have
5 years.
}
525 Message
6 #7f7fff {DETROIT, MI. 1972} \
526 {By
1970, competition from overseas and other economic factors pushed the once
"automobile capital of the world" into recession. Plummeting land values and unemployment then increased crime in the inner-city to chronic levels.
528 You have
10 years to reduce crime and rebuild the industrial base of the city.
}
530 Message
7 #7f7fff {BOSTON, MA. 2010} \
531 {A major meltdown is about to occur at one of the new downtown nuclear reactors. The area in the vicinity of the reactor will be severly contaminated by radiation
, forcing you to restructure the city around it.
533 You have
5 years to get the situation under control.
}
535 Message
8 #7f7fff {RIO DE JANEIRO, BRAZIL 2047} \
536 {In the mid-21st century
, the greenhouse effect raised
global temperatures
6 degrees F. Polar icecaps melted and raised sea levels worldwide. Coastal areas were devastated by flood and erosion.
538 You have
10 years to turn this swamp back into a city again.
}
540 Message
9 #ffa500 {Query Zone Status} \
548 {{view
{PanView
$v $QueryX $QueryY}}}
550 Message
10 #ff4f4f {POLLUTION ALERT!} \
551 {Pollution in your city has exceeded the maximum allowable amounts established by the Micropolis Pollution Agency. You are running the risk of grave ecological consequences.
553 Either clean up your act or
open a gas mask concession at city hall.
} \
554 {{view
{PanView
$v [sim PolMaxX
] [sim PolMaxY
]}}}
556 Message
11 #ff4f4f {CRIME ALERT!} \
557 {Crime in your city is out of hand. Angry mobs are looting and vandalizing the central city. The president will
send in the national guard soon
if you cannot control the problem.
} \
558 {{view
{PanView
$v [sim CrimeMaxX
] [sim CrimeMaxY
]}}}
560 Message
12 #ff4f4f {TRAFFIC WARNING!} \
561 {Traffic in this city is horrible. The city gridlock is expanding. The commuters are getting militant.
563 Either build more roads and rails or get a bulletproof limo.
} \
564 {{view
{PanView
$v [sim TrafMaxX
] [sim TrafMaxY
]}}}
566 Message
20 #ff4f4f {FIRE REPORTED!} \
567 "A fire has been reported!" \
568 {{view
{PanView
$v [sim CrashX
] [sim CrashY
]}}}
570 Message
21 #ff4f4f {MONSTER ATTACK!} \
571 "A large reptilian creature has been spotted in the water. It seems to be attracted to areas of high pollution. There is a trail of destruction wherever it goes. \
572 All you can do is wait till he leaves, then rebuild from the rubble." \
573 {{view
{FollowView
$v monster
}}}
575 # XXX: write more text
576 Message
22 #ff4f4f {TORNADO ALERT!} \
577 {A tornado has been reported
! There's nothing you can do to stop it
, so you'd better prepare to clean up
after the disaster
!} \
578 {{view
{FollowView
$v tornado
}}}
580 # XXX: write more text
581 Message
23 #ff4f4f {EARTHQUAKE!} \
582 {A major earthquake has occurred
! Put out the fires as quickly as possible
, before they spread
, then reconnect the power
grid and rebuild the city.
} \
583 {{view
{PanView
$v [sim CenterX
] [sim CenterY
]}}}
585 # XXX: write more text
586 Message
24 #ff4f4f {PLANE CRASH!} \
587 {A plane has crashed
!} \
588 {{view
{PanView
$v [sim CrashX
] [sim CrashY
]}}}
590 # XXX: write more text
591 Message
25 #ff4f4f {SHIPWRECK!} \
592 {A ship has wrecked
!} \
593 {{view
{PanView
$v [sim CrashX
] [sim CrashY
]}}}
595 # XXX: write more text
596 Message
26 #ff4f4f {TRAIN CRASH!} \
597 {A train has crashed
!} \
598 {{view
{PanView
$v [sim CrashX
] [sim CrashY
]}}}
600 # XXX: write more text
601 Message
27 #ff4f4f {HELICOPTER CRASH!} \
602 {A helicopter has crashed
!} \
603 {{view
{PanView
$v [sim CrashX
] [sim CrashY
]}}}
605 Message
30 #ff4f4f {FIREBOMBING REPORTED!} \
606 {Firebombs are falling
!!} \
607 {{view
{PanView
$v [sim CrashX
] [sim CrashY
]}}}
609 Message
35 #7fff7f {TOWN} \
610 {Congratulations
, your village has grown to town status. You now have
2,000 citizens.
} \
611 {{view
{PanView
$v [sim CenterX
] [sim CenterY
]}}}
613 Message
36 #7fff7f {CITY} \
614 {Your town has grown into a full sized city
, with a current population of
10,000. Keep up the good work
!} \
615 {{view
{PanView
$v [sim CenterX
] [sim CenterY
]}}}
617 Message
37 #7fff7f {CAPITAL} \
618 {Your city has become a capital. The current population here is
50,000. Your political future looks bright.
} \
619 {{view
{PanView
$v [sim CenterX
] [sim CenterY
]}}}
621 Message
38 #7fff7f {METROPOLIS} \
622 {Your capital city has now achieved the status of metropolis. The current population is
100,000. With your management skills
, you should seriously consider running
for governor.
} \
623 {{view
{PanView
$v [sim CenterX
] [sim CenterY
]}}}
625 Message
39 #7fff7f {MEGALOPOLIS} \
626 {Congratulation
, you have reached the highest category of urban development
, the megalopolis.
628 If you manage to reach this level
, send us email at micropolis
@laptop.org or
send us a copy of your city. We might do something interesting with it.
} \
629 {{view
{PanView
$v [sim CenterX
] [sim CenterY
]}}}
631 Message
40 #7fff7f {MEGALINIUM} \
632 {Congratulation
, you have reached the end of
time!
634 Because of the toroidal nature of the the Micropolis Space
/Time Continuum
, your city has wrapped back in
time to
1900!} \
635 {{view
{PanView
$v [sim CenterX
] [sim CenterY
]}}}
637 # XXX: write more text
638 Message
41 #ff4f4f {HEAVY TRAFFIC!} \
640 reporting heavy traffic
!} \
641 {{view
{FollowView
$v helicopter
}}}
643 # XXX: write more text
644 Message
42 #ff4f4f {FLOODING REPORTED!} \
645 {Flooding has been been reported along the water's edge
!} \
646 {{view
{PanView
$v [sim FloodX
] [sim FloodY
]}}}
648 Message
43 #ff4f4f {NUCLEAR MELTDOWN!} \
649 {A nuclear meltdown has occured at your power plant. You are advised to avoid the area until the radioactive isotopes decay.
651 Many generations will confront this problem before it goes away
, so don't hold your breath.
} \
652 {{view
{PanView
$v [sim MeltX
] [sim MeltY
]}}}
655 Message
44 #ff4f4f {RIOTS!} \
656 {The citizens are rioting in the streets
, setting cars and houses on fire
, and bombing government buildings and businesses
!
658 All media coverage is blacked out
, while the fascist pigs beat the poor citizens into submission.
}
660 Message
46 #ff4f4f {NO SOUND SERVER!} \
661 {There is no sound server running on your X11 display
"%s". You won't hear any noise unless you run a sound server
, and turn the sound back on in the
"Options" menu.
}
663 Message
48 #7f7fff {Start a New City} \
664 {Build your very own city from the ground up
, starting with this map of uninhabited land.
}
666 Message
49 #7f7fff {Restore a Saved City} \
667 {This city was saved in the
file named
: %s
}
669 Message
100 #7fff7f {YOU'RE A WINNER!} \
670 {Your mayorial skill and city planning expertise have earned you the KEY TO THE CITY. Local residents will erect monuments to your glory and name their first-born children
after you. Why not run
for governor?
} \
671 {{middle
{@images
/key2city.xpm
}}}
673 Message
200 #ff4f4f {IMPEACHMENT NOTICE!} \
674 {The entire population of this city has finally had enough of your inept planning and incompetant management. An angry mob
-- led by your mother
-- has been spotted in the vicinity of city hall.
676 You should seriously consider taking an extended vacation
-- NOW.
(Or
read the manual and try again.
)}
678 Message
300 #ffd700 {About Micropolis} \
679 "Micropolis Version [sim Version] Copyright (C) 2007
681 Based on the Original Micropolis Concept and Design
683 TCL/Tk User Interface Designed and Created
684 by Don Hopkins, DUX Software.
685 Ported to Linux, Optimized and Adapted for OLPC
687 Licensed under the GNU General Public License,
688 version 3, with additional conditions."
691 ########################################################################
693 ########################################################################
696 option add
*CheckButton.relief flat
697 option add
*Dialog.cursor top_left_arrow
698 option add
*Entry.relief sunken
699 option add
*Frame.borderWidth
0
700 option add
*Listbox.relief sunken
701 option add
*Scrollbar.relief sunken
702 option add
*RadioButton.anchor w
703 option add
*RadioButton.relief flat
705 option add
*background
#b0b0b0
706 option add
*foreground
#000000
707 option add
*activeBackground
#d0d0d0
708 option add
*activeForeground
#000000
709 option add
*disabledForeground
""
710 option add
*selectBackground
#d0d0d0
711 option add
*selectForeground
#000000
712 #option add *selector #ffff80
713 option add
*selector
#bf0000
715 option add
*Scrollbar.Background
#b0b0b0
716 option add
*Scrollbar.Foreground
#d0d0d0
717 option add
*Interval.Background
#b0b0b0
718 option add
*Interval.Foreground
#000000
719 option add
*Interval.activeForeground
#d0d0d0
720 option add
*Interval.sliderForeground
#b0b0b0
721 option add
*Scale.activeForeground
#d0d0d0
722 option add
*Scale.sliderForeground
#b0b0b0
723 option add
*PieMenu.activeBackground
#b0b0b0
725 option add Mwm
*Micropolis.clientDecoration
-maximize
728 ########################################################################
730 ########################################################################
733 bind all
<Help
> {HandleHelp
%W
%x
%y
%X
%Y
}
734 bind all
<Shift-ButtonPress
> {HandleHelp
%W
%x
%y
%X
%Y
}
735 bind all
<Meta-ButtonPress
> {HandleHelp
%W
%x
%y
%X
%Y
}
736 bind all
<Shift-Meta-ButtonPress
> {HandleHelp
%W
%x
%y
%X
%Y
}
739 ########################################################################
741 ########################################################################
760 puts stderr
"$errorInfo"
768 proc NoFunction
{args
} {}
771 proc LinkWindow
{fromname to
} {
773 set WindowLinks
($fromname) $to
777 proc WindowLink
{fromname
} {
780 catch {set to
$WindowLinks($fromname)}
785 proc DeleteWindow
{sym name win
} {
786 set head
[WindowLink
$win.head
]
787 LinkWindow
$head.
$sym {}
789 set wins
[eval ident
"\$$name"]
790 set i
[lsearch $wins $win]
792 set $name [lreplace $wins $i $i]
798 proc Font
{win name
} {
799 global FontInfo FontCache HeadWindows
800 set scr
[winfo screen
$win]
803 set font $FontCache($scr,$name)
808 set label $FontCache($scr)
810 if {"$label" == ""} {
811 foreach head
$HeadWindows {
812 if {"[winfo screen $head]" == "$scr"} {
813 set label $head.fontlabel
814 label $label -text "X11 Sucks" -font fixed
815 set FontCache
($scr) $label
820 set fonts
[keylget FontInfo
$name]
821 foreach font $fonts {
822 #echo "Configuring font $font on $label"
823 if {[catch "$label config -font \"$font\""] == 0} {
836 set FontCache
($scr,$name) $font
842 proc Color
{win color mono
} {
843 if {[winfo screendepth
$win] == 1} {
851 ########################################################################
852 # Window Definition Functions
853 ########################################################################
856 proc MakeWindow.head
{{display
":0"}} {
858 source $ResourceDir/whead.tcl
863 proc MakeWindow.editor
{head
{display
":0"}} {
865 source $ResourceDir/weditor.tcl
870 proc MakeWindow.map
{head
{display
":0"}} {
872 source $ResourceDir/wmap.tcl
877 proc MakeWindow.graph
{head
{display
":0"}} {
879 source $ResourceDir/wgraph.tcl
884 proc MakeWindow.budget
{head
{display
":0"}} {
886 source $ResourceDir/wbudget.tcl
891 proc MakeWindow.evaluation
{head
{display
":0"}} {
893 source $ResourceDir/weval.tcl
898 proc MakeWindow.splash
{head
{display
":0"}} {
900 source $ResourceDir/wsplash.tcl
905 proc MakeWindow.scenario
{head
{display
":0"}} {
907 source $ResourceDir/wscen.tcl
912 proc MakeWindow.
file {head
{display
":0"}} {
914 source $ResourceDir/wfile.tcl
919 proc MakeWindow.ask
{head
{display
":0"}} {
921 source $ResourceDir/wask.tcl
926 proc MakeWindow.player
{head
{display
":0"}} {
928 source $ResourceDir/wplayer.tcl
933 proc MakeWindow.notice
{head
{display
":0"}} {
935 source $ResourceDir/wnotice.tcl
939 proc MakeWindow.help
{head
{display
":0"}} {
941 source $ResourceDir/whelp.tcl
945 proc MakeWindow.frob
{head
{display
":0"}} {
947 source $ResourceDir/wfrob.tcl
952 ########################################################################
954 ########################################################################
957 proc UIInitializeSound
{} {
961 proc UIShutDownSound
{} {
965 proc UIDoSoundOn
{win cmd
} {
966 global Sound SoundServers
968 set win
[WindowLink
[winfo toplevel $win].head
]
969 if {[lsearch $SoundServers $win] != -1} {
970 set cmd
"send -quick -server $win Sound sound $cmd"
972 # XXX: Lost a sound server...
980 proc UIDoSound
{cmd
} {
981 global Sound SoundServers
983 foreach win
$SoundServers {
984 set foo
"send -quick -server $win Sound $cmd"
986 # XXX: Lost a sound server...
994 proc KillSoundServers
{} {
996 foreach win
$SoundServers {
997 set foo
"send -quick -server $win Sound KillSoundServer"
1004 proc UISetChannelVolume
{win chan vol
} {
1005 UIDoSoundOn
$win "channel $chan -volume $vol"
1009 proc EchoPlaySound
{soundspec
} {
1013 proc UIMakeSoundOn
{win chan sound
{opts
""}} {
1014 playsound
$chan $sound $opts
1018 proc UIStartSoundOn
{win chan sound
{opts
""}} {
1019 # Send message to Python to play sound.
1020 EchoPlaySound
$sound
1022 #UIDoSoundOn $win "play $sound -replay -channel $chan -repeat 100 $opts"
1026 proc UIMakeSound
{chan sound
{opts
""}} {
1027 playsound
$chan $sound $opts
1031 proc UIStartSound
{chan sound
{opts
""}} {
1032 # Send message to Python to play sound.
1033 EchoPlaySound
$sound
1035 #UIDoSound "sound play $sound -channel $chan -repeat 100 $opts"
1039 proc SetupSoundServer
{win
} {
1044 proc AddSoundServer
{win
} {
1046 set i
[lsearch $SoundServers $win]
1048 set SoundServers
[linsert $SoundServers 0 $win]
1053 proc LostSoundServer
{win
} {
1054 DeleteSoundServer
$win
1055 # UIShowPictureOn [WindowLink $win.head] 46 [winfo screen $win]
1059 proc DeleteSoundServer
{win
} {
1061 set i
[lsearch $SoundServers $win]
1063 set SoundServers
[lreplace $SoundServers $i $i]
1068 proc UISoundOff
{} {
1072 proc MonsterSpeed
{} {
1073 return [expr "[sim Rand 40] + 70"]
1077 proc ExplosionPitch
{} {
1078 return [expr "[sim Rand 20] + 90"]
1083 return [expr "[sim Rand 20] + 90"]
1087 ########################################################################
1088 # Global Window Handlers
1091 proc WithdrawAll
{} {
1109 proc ShowInitial
{} {
1117 ########################################################################
1118 # Head Window Handlers
1121 proc PrepHead
{head
} {
1128 WithdrawHeadOf
$head
1132 after 1000 "WithdrawSplashOf $head"
1133 WithdrawHeadOf
$head
1134 ShowScenarioOf
$head
1138 WithdrawSplashOf
$head
1139 WithdrawScenarioOf
$head
1144 ReShowPictureOn
$head
1152 proc ShowHeadOf
{head
} {
1157 proc WithdrawHeadOf
{head
} {
1164 foreach win
$HeadWindows {
1170 proc WithdrawHeads
{} {
1172 foreach win
$HeadWindows {
1178 proc DeleteHeadWindow
{head
} {
1185 foreach win
$HeadWindows {
1191 proc InitHead
{win
} {
1192 set w
[WindowLink
$win.
text]
1193 $w configure
-state normal
1196 $w configure
-state disabled
1198 if {[sim MultiPlayerMode
]} {
1199 set w
[WindowLink
$win.
entry]
1210 proc InitAllHeadMenus
{} {
1213 foreach win
$HeadWindows {
1219 proc InitHeadMenus
{win
} {
1221 set m0
[WindowLink
$win.m0
]
1222 set m1
[WindowLink
$win.m1
]
1223 set m2
[WindowLink
$win.m2
]
1224 set m3
[WindowLink
$win.m3
]
1225 set m4
[WindowLink
$win.m4
]
1226 set b0
[WindowLink
$win.b0
]
1227 set b1
[WindowLink
$win.b1
]
1228 set b2
[WindowLink
$win.b2
]
1229 set b3
[WindowLink
$win.b3
]
1230 set b4
[WindowLink
$win.b4
]
1244 # When in multi player mode there is an extra menu
1245 # item to add another player, before the quit item,
1246 # so compensate for it here.
1247 if {[sim MultiPlayerMode
]} {
1252 $b0 config
-state normal
1253 $b2 config
-state disabled
1254 $b4 config
-state disabled
1259 # When in multi player mode there is an extra menu
1260 # item to add another player, before the quit item,
1261 # so compensate for it here.
1262 if {[sim MultiPlayerMode
]} {
1267 $b0 config
-state normal
1268 $b2 config
-state normal
1269 $b4 config
-state normal
1275 proc UIDisaster
{win cmd action
} {
1276 AskQuestion
[Color
$win #ff0000 #ffffff] "Cause a Disaster" \
1277 "Oh no! Do you really want to $action" \
1278 "{No way!} Disaster.No {WithdrawAsks}" \
1280 "{I guess so.} Disaster.Yes {WithdrawAsks ; $cmd}"
1284 proc CrushHead
{head
} {
1285 global SubWindows VoteNames
1287 foreach foo
$VoteNames {
1289 set votes
[eval ident
\$VotesFor$foo]
1290 set i
[lsearch $votes $head]
1292 set VotesFor
$foo [lreplace $votes $i $i]
1296 foreach foo
$SubWindows {
1297 set sym
[lindex $foo 0]
1298 set name
[lindex $foo 1]
1300 set wins
[eval ident
"\$$name"]
1302 if {[WindowLink
$win.head
] == $head} {
1303 DeleteWindow
$sym $name $win
1310 proc ChatDown
{win
} {
1332 global ChatConnection
1334 DoSendMessage
"Opening Connection to Chat Server $ChatServer socket $ChatSocket ..." status
1336 set ChatConnection
{}
1338 set ChatConnection
[connect
$ChatServer $ChatSocket]
1341 if {$ChatConnection == {}} then
{
1342 DoSendMessage
"Sorry, I could not open a connection to chat server $ChatServer socket $ChatSocket." status
1345 filehandler
$ChatConnection r
"ReceiveChat"
1356 puts $ChatConnection "USER $UserName $HostName $ServerName $RealName\r\n" nonewline
1357 puts $ChatConnection "NICK $NickName\r\n" nonewline
1358 puts $ChatConnection "JOIN $ChannelName\r\n" nonewline
1359 flush $ChatConnection
1364 proc ReceiveChat
{mode f
} {
1365 # DoSendMessage "ReceiveChat: MODE $mode F $f"
1369 if {[string first
{:} $msg]} {
1373 set from
[lindex $msg 0]
1374 set cmd
[string tolower
[lindex $msg 1]]
1378 if {($cmd == "privmsg") ||
1379 ($cmd == "notice")} then
{
1381 set chan
[lindex $msg 2]
1382 set i
[expr "[string length $from] + 1 + [string length $cmd] + 1 + [string length $chan] + 2"]
1383 set j
[expr "[string length $msg] - 2"]
1384 set line
[string range
$msg $i $j]
1385 set chan
[string range
$chan 1 [string length
$chan]]
1386 set from
[string range
$from 1 [expr "[string length $from] - 1"]]
1387 set from
[split $from {!}]
1388 set from
[lindex $from 0]
1389 DoSendMessage
"$from> $line"
1392 if {$handled == 0} {
1393 set msg
[string range
$msg \
1394 [expr "[string length $from] + 1"] \
1395 [expr "[string length $msg] - 2"]]
1401 proc SendChatMessage
{msg win
} {
1402 global ChatConnection ChannelName NickName
1408 if {[string range
$msg 0 0] == "/"} {
1409 set cmd
[string range
$msg 1 [string length
$msg]]
1410 DoSendMessage
"$NickName> \[$cmd\]"
1413 set cmd
"PRIVMSG $ChannelName :$msg\r\n"
1414 DoSendMessage
"$NickName> $msg"
1421 puts $ChatConnection $cmd nonewline
1422 flush $ChatConnection
1427 DoSendMessage
"IRC Broke the connection"
1437 global ChatConnection
1439 DoSendMessage
"Closing Connection to Chat Server." status
1442 puts $ChatConnection "QUIT\r\n" nonewline
1443 flush $ChatConnection
1444 $ChatConnection close
1447 set ChatConnection
{}
1452 proc DoEnterMessage
{win var
} {
1455 set msg
[eval ident
"\$\{$var\}"]
1457 if {$Chatting} then
{
1458 SendChatMessage
$msg $win
1466 proc DoEvalMessage
{win var
} {
1468 set command
[eval ident
"\$\{$var\}"]
1470 DoSendMessage
"Evaluating TCL: $command"
1471 catch {uplevel #0 $command} result
1472 DoSendMessage
"Result: $result"
1476 proc DoSendMessage
{msg
{tag
message}} {
1478 foreach win
$HeadWindows {
1479 appendWithTag
[WindowLink
$win.
text] $tag "$msg"
1484 proc UISetMessage
{msg
{tag status
}} {
1485 global DoMessages EditorWindows HeadWindows
1487 if {$DoMessages == 0} {
1491 foreach win
$EditorWindows {
1492 [WindowLink
$win.
message] configure
-text "$msg"
1495 foreach win
$HeadWindows {
1496 appendWithTag
[WindowLink
$win.
text] $tag "$msg"
1503 proc appendWithTag
{w tag
text} {
1507 set start
[$w index end
]
1508 $w configure
-state normal
1509 if {$start > $MaxLines} then
{
1510 $w delete
0.0 $ShrinkLines.0
1511 set start
[$w index end
]
1513 $w insert end
"${text}\n"
1514 $w tag add
$tag $start {end
- 1 char
}
1515 $w configure
-state disabled
1516 $w yview
-pickplace {end
- 1 char
}
1520 ########################################################################
1521 # Budget Window Handlers
1524 proc ShowBudgetOf
{head
} {
1525 set win
[WindowLink
$head.budget
]
1527 set win
[MakeWindow.budget
$head [winfo screen
$head]]
1536 proc ShowBudgets
{} {
1537 global HeadWindows BudgetsVisible
1538 set BudgetsVisible
1
1539 foreach win
$HeadWindows {
1545 proc WithdrawBudgets
{} {
1546 global BudgetWindows BudgetsVisible
1547 foreach win
$BudgetWindows {
1551 set BudgetsVisible
0
1555 proc BudgetContinue
{{win
""}} {
1556 global OldBudget BudgetRoadFund BudgetFireFund BudgetPoliceFund BudgetTaxRate
1558 if {([sim RoadFund
] != $BudgetRoadFund) ||
1559 ([sim FireFund
] != $BudgetFireFund) ||
1560 ([sim PoliceFund
] != $BudgetPoliceFund) ||
1561 ([sim TaxRate
] != $BudgetTaxRate)} {
1562 UISetMessage
"The budget was changed."
1564 UISetMessage
"The budget wasn't changed."
1572 proc BudgetReset
{{win
""}} {
1573 global OldBudget BudgetRoadFund BudgetFireFund BudgetPoliceFund BudgetTaxRate
1574 if {([sim RoadFund
] != $BudgetRoadFund) ||
1575 ([sim FireFund
] != $BudgetFireFund) ||
1576 ([sim PoliceFund
] != $BudgetPoliceFund) ||
1577 ([sim TaxRate
] != $BudgetTaxRate)} {
1578 UISetMessage
"The budget was reset."
1579 if {[sim Players
] > 1} {
1580 UIMakeSound edit Sorry
1583 UISetMessage
"The budget was reset."
1585 sim RoadFund
$BudgetRoadFund
1586 sim FireFund
$BudgetFireFund
1587 sim PoliceFund
$BudgetPoliceFund
1588 sim TaxRate
$BudgetTaxRate
1594 proc BudgetCancel
{{win
""}} {
1602 proc SetTaxRate
{rate
} {
1607 proc BudgetSetTaxRate
{rate
} {
1613 proc BudgetSetRoadFund
{percent
} {
1614 sim RoadFund
$percent
1619 proc BudgetSetFireFund
{percent
} {
1620 sim FireFund
$percent
1625 proc BudgetSetPoliceFund
{percent
} {
1626 sim PoliceFund
$percent
1631 proc UIShowBudgetAndWait
{} {
1632 global OldBudget BudgetRoadFund BudgetFireFund BudgetPoliceFund BudgetTaxRate
1633 if {$OldBudget == 0} {
1634 set BudgetRoadFund
[sim RoadFund
]
1635 set BudgetFireFund
[sim FireFund
]
1636 set BudgetPoliceFund
[sim PoliceFund
]
1637 set BudgetTaxRate
[sim TaxRate
]
1641 UISetMessage
"Pausing to set the budget ..."
1647 sim UpdateBudgetWindow
1651 proc ToggleBudgetTimer
{} {
1652 global BudgetTimerActive
1653 if {$BudgetTimerActive} {
1661 proc StopBudgetTimer
{} {
1662 global BudgetTimerActive
1663 set BudgetTimerActive
0
1668 proc StartBudgetTimer
{} {
1669 global BudgetTimerActive BudgetTimer BudgetTimeout
1671 set BudgetTimerActive
$me
1672 set BudgetTimer
$BudgetTimeout
1674 after 1000 TickBudgetTimer
$me
1678 proc RestartBudgetTimer
{} {
1679 global BudgetTimerActive
1680 if {$BudgetTimerActive} {
1687 proc UpdateBudgetTimer
{} {
1688 global BudgetWindows BudgetTimerActive BudgetTimer
1689 if {$BudgetTimerActive} {
1690 set text [format "Auto Cancel In %d Seconds (click to disable)" $BudgetTimer]
1692 set text [format "Enable Auto Cancel (currently disabled)"]
1694 foreach win
$BudgetWindows {
1695 set t
[WindowLink
$win.timer
]
1696 $t config
-text "$text"
1701 proc TickBudgetTimer
{me
} {
1702 global BudgetTimerActive BudgetTimer BudgetTimeout
1703 if {$BudgetTimerActive == $me} {
1705 if {$BudgetTimer < 0} {
1711 after 1000 TickBudgetTimer
$me
1717 proc FireBudgetTimer
{} {
1727 proc ToggleAutoBudget
{} {
1730 #echo "ToggleAutoBudget found on, clearing"
1733 #echo "ToggleAutoBudget found off, setting"
1739 proc UIUpdateBudget
{} {
1744 proc UpdateAutoBudget
{} {
1745 global BudgetWindows AutoBudget
1746 if {[sim AutoBudget
]} {
1747 set text "Disable Auto Budget (currently enabled)"
1749 set text "Enable Auto Budget (currently disabled)"
1751 #echo "UpdateAutoBudget $AutoBudget $text"
1752 foreach win
$BudgetWindows {
1753 set t
[WindowLink
$win.autobudget
]
1754 $t config
-text "$text"
1759 proc UISetBudget
{cashflow previous current collected taxrate
} {
1760 global BudgetWindows BudgetsVisible
1762 #echo "UISetBudgetValues $taxrate $BudgetsVisible"
1764 if {$BudgetsVisible} {
1766 foreach win
$BudgetWindows {
1767 set w
[WindowLink
$win.cashflow
]
1768 set old
[lindex [$w configure
-text] 4]
1769 if {$old != $cashflow} {
1770 $w configure
-text $cashflow
1772 set w
[WindowLink
$win.previous
]
1773 set old
[lindex [$w configure
-text] 4]
1774 if {$old != $previous} {
1775 $w configure
-text $previous
1777 set w
[WindowLink
$win.current
]
1778 set old
[lindex [$w configure
-text] 4]
1779 if {$old != $current} {
1780 $w configure
-text $current
1782 set w
[WindowLink
$win.collected
]
1783 set old
[lindex [$w configure
-text] 4]
1784 if {$old != $collected} {
1785 $w configure
-text $collected
1788 set w
[WindowLink
$win.taxrate
]
1790 if {$old != $taxrate} {
1794 set w
[WindowLink
$win.taxlabel
]
1795 set old
[lindex [$w configure
-text] 4]
1798 $w configure
-text $new
1804 foreach win
$HeadWindows {
1806 set w
[WindowLink
$win.taxrate
]
1808 if {$old != $taxrate} {
1809 # FIXME: this might not work if the slider is disabled in multi player mode.
1813 set w
[WindowLink
$win.taxlabel
]
1814 set old
[lindex [$w configure
-text] 4]
1815 set new
"Tax Rate: $taxrate%"
1817 $w configure
-text $new
1823 proc UISetBudgetValues
{roadgot roadwant roadpercent policegot policewant policepercent firegot firewant firepercent
} {
1824 global BudgetWindows BudgetsVisible
1826 if {$BudgetsVisible == 0} {
1830 foreach win
$BudgetWindows {
1831 set w
[WindowLink
$win.fire
].request
1832 set old
[lindex [$w configure
-text] 4]
1833 set new
"$firepercent% of $firewant = $firegot"
1835 $w configure
-text $new
1837 set w
[WindowLink
$win.fire
].fund
1839 if {$old != $firepercent} {
1843 set w
[WindowLink
$win.police
].request
1844 set old
[lindex [$w configure
-text] 4]
1845 set new
"$policepercent% of $policewant = $policegot"
1847 $w configure
-text $new
1849 set w
[WindowLink
$win.police
].fund
1851 if {$old != $policepercent} {
1852 $w set $policepercent
1855 set w
[WindowLink
$win.road
].request
1856 set old
[lindex [$w configure
-text] 4]
1857 set new
"$roadpercent% of $roadwant = $roadgot"
1859 $w configure
-text $new
1861 set w
[WindowLink
$win.road
].fund
1863 if {$old != $roadpercent} {
1870 proc ChangeBudget
{} {
1871 global VotesForBudget
1872 if {"$VotesForBudget" != ""} {
1879 proc InitVotesForBudget
{} {
1880 global VotesForBudget BudgetWindows
1881 set VotesForBudget
{}
1882 foreach win
$BudgetWindows {
1883 [WindowLink
$win.vote
] config
-relief raised
1885 UpdateVotesForBudget
1889 proc UpdateVotesForBudget
{} {
1890 global BudgetWindows
1891 UpdateVotesFor Budget
$BudgetWindows
1895 proc UpdateTaxRateSliders
{} {
1897 set players
[sim Players
]
1898 foreach win
$HeadWindows {
1899 set slider
[WindowLink
$win.taxrate
]
1900 #echo "UpdateTaxRateSliders players $players win $win slider $slider"
1901 if {$players == 1} {
1902 $slider configure
-state normal
1904 $slider configure
-state disabled
1910 ########################################################################
1911 # Evaluation Window Handlers
1914 proc ToggleEvaluationOf
{head
} {
1916 if {"$State" != "play"} {
1921 set win
[WindowLink
$head.evaluation
]
1923 set mapped
[winfo ismapped
$win]
1927 WithdrawEvaluationOf
$head
1929 ShowEvaluationOf
$head
1935 proc WithdrawEvaluationOf
{head
} {
1936 set win
[WindowLink
$head.evaluation
]
1943 proc ShowEvaluationOf
{head
} {
1944 set win
[WindowLink
$head.evaluation
]
1946 set win
[MakeWindow.evaluation
$head [winfo screen
$head]]
1950 set parent
[WindowLink
$win.parent
]
1951 #pack append [WindowLink $head.col2]\
1952 # $parent {top frame nw fill}
1953 pack append $parent\
1954 $win {top
frame nw fillx
}
1956 sim UpdateEvaluation
1960 proc WithdrawEvaluations
{} {
1961 global EvaluationWindows EvaluationsVisible
1962 foreach win
$EvaluationWindows {
1964 #set parent [WindowLink $win.parent]
1965 #pack unpack $parent
1968 set EvaluationsVisible
0
1972 proc EvaluationVisible
{w v
} {
1973 global EvaluationsVisible
1974 global [set var
$w.visible
]
1979 set EvaluationsVisible
[expr "$EvaluationsVisible + 1"]
1981 set EvaluationsVisible
[expr "$EvaluationsVisible - 1"]
1986 proc UISetEvaluation
{changed score ps0 ps1 ps2 ps3 pv0 pv1 pv2 pv3 pop delta assessed cityclass citylevel goodyes goodno title
} {
1987 global EvaluationWindows EvaluationsVisible CurrentDate
1989 set class
[string tolower
$cityclass]
1990 UISetMessage
"$CurrentDate: Score $score, $class population $pop."
1992 if {$EvaluationsVisible} {
1994 foreach win
$EvaluationWindows {
1996 global [set var
$win.visible
]
1997 set visible
[eval ident
"\$\{$var\}"]
2001 # TODO: set evaluation window and icon title
2002 #wm title $win "$title"
2003 #wm iconname $win "$title"
2005 set w
[WindowLink
$win.goodjob
]
2006 set old
[lindex [$w configure
-text] 4]
2007 set new
"$goodyes\n$goodno"
2009 $w configure
-text $new
2012 set w
[WindowLink
$win.problemnames
]
2013 set old
[lindex [$w configure
-text] 4]
2014 set new
"$ps0\n$ps1\n$ps2\n$ps3"
2016 $w configure
-text $new
2019 set w
[WindowLink
$win.problempercents
]
2020 set old
[lindex [$w configure
-text] 4]
2021 set new
"$pv0\n$pv1\n$pv2\n$pv3"
2023 $w configure
-text $new
2026 set w
[WindowLink
$win.stats
]
2027 set old
[lindex [$w configure
-text] 4]
2028 set new
"$pop\n$delta\n\n$assessed\n$cityclass\n$citylevel"
2030 $w configure
-text $new
2033 set w
[WindowLink
$win.score
]
2034 set old
[lindex [$w configure
-text] 4]
2035 set new
"$score\n$changed"
2037 $w configure
-text $new
2045 ########################################################################
2046 # File Window Handlers
2049 proc ShowFileOf
{head
} {
2050 set win
[WindowLink
$head.
file]
2052 set win
[MakeWindow.
file $head [winfo screen
$head]]
2062 foreach win
$HeadWindows {
2068 proc WithdrawFiles
{} {
2070 foreach win
$FileWindows {
2076 proc DoFileDialog
{win Message Path Pattern FileName ActionOk ActionCancel
} {
2077 ShowFileDialog
$win "$Path" "$Pattern"
2078 $win.message1 configure
-text "$Message"
2079 $win.path.path delete
0 end
2080 $win.path.path insert
0 $Path
2081 $win.
file.
file delete
0 end
2082 $win.
file.
file insert
0 "$FileName"
2083 $win.frame1.ok config
-command "
2084 $ActionOk \[$win.file.file get\] \[$win.path.path get\]
2086 $win.frame1.rescan config
-command "
2087 ShowFileDialog $win \[$win.path.path get\] $Pattern"
2088 $win.frame1.cancel config
-command "
2091 bind $win.files.files
"<Double-Button-1>" "\
2092 FileSelectDouble $win %W %y $Pattern \"
2093 $ActionOk {\[$win.file.file get\]} {\[$win.path.path get\]}\""
2094 bind $win.path.path
<Return
> "
2095 ShowFileDialog $win \[$win.path.path get\] $Pattern
2096 $win.file.file cursor 0
2097 focus $win.file.file"
2098 bind $win.
file.
file <Return
> "\
2099 $ActionOk \[$win.file.file get\] \[$win.path.path get\]
2104 proc BindSelectOne
{win Y
} {
2105 set Nearest
[$win nearest
$Y]
2106 if {$Nearest >= 0} {
2107 $win select from
$Nearest
2108 $win select to
$Nearest
2113 proc FileSelect
{win widget Y
} {
2114 BindSelectOne
$widget $Y
2115 set Nearest
[$widget nearest
$Y]
2116 if {$Nearest >= 0} {
2117 set Path
[$win.path.path get
]
2118 set TmpEntry
[$widget get
$Nearest]
2119 if {[string compare
"/" [string index
$TmpEntry \
2120 [expr [string length
$TmpEntry]-1]]] == 0 ||
\
2121 [string compare
"@" [string index
$TmpEntry \
2122 [expr [string length
$TmpEntry]-1]]] == 0} {
2123 # handle directories, and symbolic links to directories
2124 set FileName
[string range
$TmpEntry 0 \
2125 [expr [string length
$TmpEntry]-2]]
2126 # whoops / or @ is part of the name
2127 if {[MiscIsDir
$Path/$FileName] != 1} {
2128 set FileName
$TmpEntry
2131 if {[string compare
"*" [string index
$TmpEntry \
2132 [expr [string length
$TmpEntry]-1]]] == 0} {
2133 # handle executable filenames
2134 set FileName
[string range
$TmpEntry 0 \
2135 [expr [string length
$TmpEntry]-2]]
2136 # whoops * is part of the name
2137 if {[file executable
$Path/$FileName] != 1} {
2138 set FileName
$TmpEntry
2141 # a ordinary filename
2142 set FileName
$TmpEntry
2145 # enter the selected filename into the filename field
2146 if {[MiscIsDir
$Path/$FileName] != 1} {
2147 $win.
file.
file delete
0 end
2148 $win.
file.
file insert
0 $FileName
2154 proc FileSelectDouble
{win widget Y Pattern Action
} {
2155 BindSelectOne
$widget $Y
2156 set Nearest
[$widget nearest
$Y]
2157 if {$Nearest >= 0} {
2158 set Path
[$win.path.path get
]
2159 set TmpEntry
[$widget get
$Nearest]
2160 if {[string compare
$TmpEntry "../"] == 0} {
2161 # go up one directory
2163 [string trimright
[string trimright
[string trim
$Path] /] @]
2164 if {[string length
$TmpEntry] <= 0} {
2167 set Path
[file dirname
$TmpEntry]
2168 $win.path.path delete
0 end
2169 $win.path.path insert
0 $Path
2170 ShowFileDialog
$win $Path $Pattern
2172 if {[string compare
"/" [string index
$TmpEntry \
2173 [expr [string length
$TmpEntry]-1]]] == 0 ||
\
2174 [string compare
"@" [string index
$TmpEntry \
2175 [expr [string length
$TmpEntry]-1]]] == 0} {
2176 # handle directorys, and symbolic links to directorys
2177 set FileName
[string range
$TmpEntry 0 \
2178 [expr [string length
$TmpEntry]-2]]
2179 # whoops / or @ is part of the name
2180 if {[MiscIsDir
$Path/$FileName] != 1} {
2181 set FileName
$TmpEntry
2184 if {[string compare
"*" [string index
$TmpEntry \
2185 [expr [string length
$TmpEntry]-1]]] == 0} {
2186 # handle executable filenames
2187 set FileName
[string range
$TmpEntry 0 \
2188 [expr [string length
$TmpEntry]-2]]
2189 # whoops * is part of the name
2190 if {[file executable
$Path/$FileName] != 1} {
2191 set FileName
$TmpEntry
2194 # a ordinary filename
2195 set FileName
$TmpEntry
2199 if {[MiscIsDir
$Path/$FileName] == 1} {
2200 if {[string compare
"/" [string index
$Path \
2201 [expr [string length
$Path]-1]]] == 0} {
2202 append Path
$FileName
2204 append Path
/ $FileName
2206 $win.path.path delete
0 end
2207 $win.path.path insert
0 $Path
2208 ShowFileDialog
$win $Path $Pattern
2210 # enter the selected filename into the filename field
2211 $win.
file.
file delete
0 end
2212 $win.
file.
file insert
0 "$FileName"
2213 if {[string length
$Action] > 0} {
2223 proc NameComplete
{win Type
} {
2228 if {[string compare
$Type path
] == 0} {
2229 set DirName
[file dirname
[$win.path.path get
]]
2230 set FileName
[file tail
[$win.path.path get
]]
2232 set DirName
[file dirname
[$win.path.path get
]/]
2233 set FileName
[file tail
[$win.
file.
file get
]]
2237 if {[MiscIsDir
$DirName] == 1} {
2238 catch "exec ls $DirName/" Result
2240 set ListLength
[llength $Result]
2242 while {$Counter < $ListLength} {
2243 if {[string length
$FileName] == 0} {
2244 if {$FoundCounter == 0} {
2245 set NewFile
[lindex $Result $Counter]
2248 set TmpFile1
$NewFile
2249 set TmpFile2
[lindex $Result $Counter]
2250 set Length1
[string length
$TmpFile1]
2251 set Length2
[string length
$TmpFile2]
2253 if {$Length1 > $Length2} {
2254 set Length1
$Length2
2256 while {$Counter1 < $Length1} {
2257 if {[string compare
[string index
$TmpFile1 $Counter1] \
2258 [string index
$TmpFile2 $Counter1]] == 0} {
2259 append NewFile
[string index
$TmpFile1 $Counter1]
2268 if {[regexp "^$FileName" [lindex $Result $Counter] \
2270 if {$FoundCounter == 0} {
2271 set NewFile
[lindex $Result $Counter]
2274 set TmpFile1
$NewFile
2275 set TmpFile2
[lindex $Result $Counter]
2276 set Length1
[string length
$TmpFile1]
2277 set Length2
[string length
$TmpFile2]
2279 if {$Length1 > $Length2} {
2280 set Length1
$Length2
2282 while {$Counter1 < $Length1} {
2283 if {[string compare
[string index
$TmpFile1 $Counter1] \
2284 [string index
$TmpFile2 $Counter1]] == 0} {
2285 append NewFile
[string index
$TmpFile1 $Counter1]
2299 if {$FoundCounter == 1} {
2300 if {[MiscIsDir
$DirName/$NewFile] == 1} {
2301 if {[string compare
$DirName "/"] == 0} {
2302 $win.path.path delete
0 end
2303 $win.path.path insert
0 "/[string trim [string trim $NewFile /] @]/"
2305 $win.path.path delete
0 end
2306 $win.path.path insert
0 "[string trimright $DirName /]/[string trim [string trim $NewFile /] @]/"
2309 $win.path.path delete
0 end
2310 $win.path.path insert
0 \
2311 "[string trim [string trimright $DirName /] @]/"
2312 $win.
file.
file delete
0 end
2313 $win.
file.
file insert
0 "$NewFile"
2316 if {[MiscIsDir
$DirName/$NewFile] == 1 ||
2317 [string compare
$Type path
] == 0} {
2318 $win.path.path delete
0 end
2319 $win.path.path insert
0 \
2320 "[string trimright $DirName /]/[string trim [string trim $NewFile /] @]"
2322 $win.path.path delete
0 end
2323 $win.path.path insert
0 "$DirName"
2324 if {[string length
$NewFile] > 0} {
2325 $win.
file.
file delete
0 end
2326 $win.
file.
file insert
0 "$NewFile"
2333 proc ShowFileDialog
{win Path Pattern
} {
2335 #set Path [lindex [split $Path] 0]
2336 if {[$win.files.files size
] > 0} {
2337 $win.files.files delete
0 end
2340 if {[catch "exec ls -F \"$Path\"" Result
]} {
2343 if {[string match
$Result "* not found"]} {
2346 set ElementList
[lsort [split $Result "\n"]]
2349 if {[string compare
$Path "/"]} {
2350 $win.files.files insert end
"../"
2354 foreach Counter
$ElementList {
2356 if {[string match
$Pattern $Counter] == 1} {
2357 if {[string compare
$Counter "../"] &&
2358 [string compare
$Counter "./"]} {
2359 $win.files.files insert end
$Counter
2362 set fn
$Path/[string trim
[string trim
[string trim
$Counter /] @] *]
2363 if {[MiscIsDir
$fn]} {
2364 $win.files.files insert end
$Counter
2372 proc MiscIsDir
{PathName
} {
2374 if {[file isdirectory
$PathName] == 1} {
2377 catch "file type $PathName" Type
2378 if {[string compare
$Type link
] == 0} {
2379 set LinkName
[file readlink
$PathName]
2380 catch "file type $LinkName" Type
2381 while {[string compare
$Type link
] == 0} {
2382 set LinkName
[file readlink
$LinkName]
2384 return [file isdirectory
$LinkName]
2391 proc busy
{win cmds
} {
2393 set list [winfo children
$win]
2395 while {$list != ""} {
2398 set class
[winfo class
$w]
2399 set cursor
[lindex [$w config
-cursor] 4]
2400 if {[winfo toplevel $w] == $w} {
2401 lappend busy
[list $w $cursor]
2403 set next
[concat $next [winfo children
$w]]
2409 catch {[lindex $w 0] config
-cursor watch
}
2414 set error [catch {uplevel eval [list $cmds]} result
]
2417 catch {[lindex $w 0] config
-cursor [lindex $w 1]}
2428 ########################################################################
2429 # Editor Window Handlers
2431 proc ShowEditorOf
{head
} {
2432 global EditorWindows
2434 foreach win
$EditorWindows {
2435 if {[WindowLink
$win.head
] == $head} {
2436 set parent
[WindowLink
$win.parent
]
2437 #pack append [WindowLink $head.col2]\
2438 # $parent {top frame nw expand fill}
2439 pack append $parent\
2440 $win {top
frame nw expand fill
}
2454 proc NewEditorOf
{head
} {
2455 set win
[MakeWindow.editor
$head [winfo screen
$head]]
2457 set parent
[WindowLink
$win.parent
]
2458 pack append $parent\
2459 $win {top
frame nw expand fill
}
2466 proc ShowEditors
{} {
2468 foreach win
$HeadWindows {
2474 proc WithdrawEditors
{} {
2475 global EditorWindows
2476 foreach win
$EditorWindows {
2477 #set parent [WindowLink $win.parent]
2478 #pack unpack $parent
2484 proc InitEditors
{} {
2485 global EditorWindows
2486 foreach win
$EditorWindows {
2492 proc InitEditor
{win
} {
2493 set e
[WindowLink
$win.view
]
2494 UISetToolState
$win 7
2499 global $e.TrackState
2500 set $e.TrackState
{}
2504 proc SetEditorAutoGoto
{win val
} {
2505 global AutoGoto.
$win
2506 set AutoGoto.
$win $val
2507 set e
[WindowLink
$win.view
]
2512 proc SetEditorControls
{win val
} {
2513 global Controls.
$win
2514 set Controls.
$win $val
2516 pack append $win $win.leftframe
{left
frame center filly
}
2518 pack unpack
$win.leftframe
2523 proc SetEditorOverlay
{win val
} {
2525 set Overlay.
$win $val
2526 set e
[WindowLink
$win.view
]
2531 proc SetEditorDynamicFilter
{win val
} {
2532 global DynamicFilter.
$win
2533 set DynamicFilter.
$win $val
2534 set e
[WindowLink
$win.view
]
2535 $e DynamicFilter
$val
2536 if {$val == 1} then
{
2537 ShowFrobOf
[WindowLink
$win.head
]
2542 proc SetEditorSkip
{win val
} {
2543 set e
[WindowLink
$win.view
]
2548 proc EditorToolDown
{mod w x y
} {
2549 global [set var
$w.TrackState
]
2553 case
[$w ToolState
] in
\
2555 UIMakeSoundOn
$w edit Rumble
"-repeat 4"
2563 set $var [list constrain_start
$x $y]
2564 $w ToolConstrain
$x $y
2569 EditorTool ToolDown
$w $x $y
2574 proc EditorToolDrag
{w x y
} {
2575 EditorTool ToolDrag
$w $x $y
2580 proc EditorToolUp
{w x y
} {
2581 global [set var
$w.TrackState
]
2584 case
[$w ToolState
] in
\
2592 EditorTool ToolUp
$w $x $y
2594 $w ToolConstrain
-1 -1
2601 proc EditorTool
{action w x y
} {
2602 global [set var
$w.TrackState
]
2603 set state
[eval ident
"\$\{$var\}"]
2604 case
[lindex $state 0] in
\
2606 set x0
[lindex $state 1]
2607 set y0
[lindex $state 2]
2608 set dx
[expr "$x - $x0"]
2609 set dy
[expr "$y - $y0"]
2610 if [expr "($dx > 16) || ($dx < -16)"] then
{
2611 $w ToolConstrain
-1 $y0
2614 if [expr "($dy > 16) || ($dy < -16)"] then
{
2615 $w ToolConstrain
$x0 -1
2624 proc StartChalk
{w
} {
2625 sim CollapseMotion
0
2629 proc StopChalk
{w
} {
2630 sim CollapseMotion
1
2634 proc EditorPanDown
{mod w x y
} {
2635 global [set var
$w.TrackState
]
2639 set $var [list constrain_start
$x $y]
2640 $w ToolConstrain
$x $y
2645 EditorTool PanStart
$w $x $y
2649 proc EditorPanDrag
{w x y
} {
2650 EditorTool PanTo
$w $x $y
2654 proc EditorPanUp
{w x y
} {
2657 EditorTool PanTo
$w $x $y
2658 $w ToolConstrain
-1 -1
2664 proc EditorKeyDown
{w k
} {
2669 proc EditorKeyUp
{w k
} {
2674 proc BindEditorButtons
{win
} {
2675 set w
[WindowLink
$win.top
]
2677 bind $win <1> "CancelPie $win ; EditorToolDown none %W %x %y"
2678 bind $win <B1-Motion
> {EditorToolDrag
%W
%x
%y
}
2679 bind $win <ButtonRelease-1
> {EditorToolUp
%W
%x
%y
}
2681 bind $win <Control-1
> "CancelPie $win ; EditorToolDown constrain %W %x %y"
2682 bind $win <Control-B1-Motion
> {EditorToolDrag
%W
%x
%y
}
2683 bind $win <Control-ButtonRelease-1
> {EditorToolUp
%W
%x
%y
}
2685 bind $win <2> "CancelPie $win ; EditorPanDown none %W %x %y"
2686 bind $win <B2-Motion
> {EditorPanDrag
%W
%x
%y
}
2687 bind $win <ButtonRelease-2
> {EditorPanUp
%W
%x
%y
}
2689 bind $win <Control-2
> "CancelPie $win ; EditorPanDown constrain %W %x %y"
2690 bind $win <Control-B2-Motion
> {EditorPanDrag
%W
%x
%y
}
2691 bind $win <Control-ButtonRelease-2
> {EditorPanUp
%W
%x
%y
}
2693 InitPie
$win $w.toolpie
2697 proc UISetFunds
{funds
} {
2699 foreach win
$HeadWindows {
2700 [WindowLink
$win.funds
] configure
-text "$funds"
2705 proc UISetDate
{date month year
} {
2709 set CurrentDate
"$date"
2711 foreach win
$HeadWindows {
2712 [WindowLink
$win.date
] Set
$month $year
2717 proc SetPriority
{index
} {
2743 proc UISetDemand
{r c i
} {
2744 global HeadWindows DemandRes DemandCom DemandInd
2750 if {$r <= 0} then
{set ry0
32} else {set ry0
24}
2751 set ry1
[expr "$ry0 - $r"]
2752 if {$c <= 0} then
{set cy0
32} else {set cy0
24}
2753 set cy1
[expr "$cy0 - $c"]
2754 if {$i <= 0} then
{set iy0
32} else {set iy0
24}
2755 set iy1
[expr "$iy0 - $i"]
2757 foreach win
$HeadWindows {
2758 set can
[WindowLink
$win.demand
]
2759 # $can coords r 8 $ry0 14 $ry1
2760 # $can coords c 17 $cy0 23 $cy1
2761 # $can coords i 26 $iy0 32 $iy1
2762 $can coords r
49 $ry0 55 $ry1
2763 $can coords c
58 $cy0 64 $cy1
2764 $can coords i
67 $iy0 73 $iy1
2769 proc UISetOptions
{autobudget autogoto autobulldoze disasters sound animation messages notices
} {
2770 global AutoBudget AutoGoto AutoBulldoze Disasters Sound
2771 set AutoBudget
$autobudget
2772 set AutoGoto
$autogoto
2773 set AutoBulldoze
$autobulldoze
2774 set Disasters
$disasters
2776 set DoAnimation
$animation
2777 set DoMessages
$messages
2778 set DoNotices
$notices
2782 proc UIDidToolRes
{win x y
} {
2783 UIMakeSoundOn
$win edit O
"-speed 140"
2787 proc UIDidToolCom
{win x y
} {
2788 UIMakeSoundOn
$win edit A
"-speed 140"
2792 proc UIDidToolInd
{win x y
} {
2793 UIMakeSoundOn
$win edit E
"-speed 140"
2797 proc UIDidToolFire
{win x y
} {
2798 UIMakeSoundOn
$win edit O
"-speed 130"
2802 proc UIDidToolQry
{win x y
} {
2803 UIMakeSoundOn
$win edit E
"-speed 200"
2807 proc UIDidToolPol
{win x y
} {
2808 UIMakeSoundOn
$win edit E
"-speed 130"
2812 proc UIDidToolWire
{win x y
} {
2813 UIMakeSoundOn
$win edit O
"-speed 120"
2817 proc UIDidToolDozr
{win x y
} {
2818 UIMakeSoundOn
$win edit Rumble
2822 proc UIDidToolRail
{win x y
} {
2823 UIMakeSoundOn
$win edit O
"-speed 100"
2827 proc UIDidToolRoad
{win x y
} {
2828 UIMakeSoundOn
$win edit E
"-speed 100"
2832 proc UIDidToolChlk
{win x y
} {
2836 proc UIDidToolEraser
{win x y
} {
2840 proc UIDidToolStad
{win x y
} {
2841 UIMakeSoundOn
$win edit O
"-speed 90"
2845 proc UIDidToolPark
{win x y
} {
2846 UIMakeSoundOn
$win edit A
"-speed 130"
2850 proc UIDidToolSeap
{win x y
} {
2851 UIMakeSoundOn
$win edit E
"-speed 90"
2855 proc UIDidToolCoal
{win x y
} {
2856 UIMakeSoundOn
$win edit O
"-speed 75"
2860 proc UIDidToolNuc
{win x y
} {
2861 UIMakeSoundOn
$win edit E
"-speed 75"
2865 proc UIDidToolAirp
{win x y
} {
2866 UIMakeSoundOn
$win edit A
"-speed 50"
2870 proc UISetToolState
{w state
} {
2871 global EditorPallets EditorPalletImages ToolInfo
2872 set win
[WindowLink
$w.top
]
2873 #echo "UISETTOOLSTATE w $w win $win $state"
2874 ExclusivePallet
$state $win $EditorPallets ic
$EditorPalletImages \
2875 raised sunken
{NoFunction
}
2877 set c1
[WindowLink
$w.cost1
]
2879 set info [lindex $ToolInfo $state]
2880 set cost1
[lindex $info 1]
2881 set cost2
[lindex $info 2]
2882 $c1 configure
-text "$cost1"
2883 [WindowLink
$w.cost2
] configure
-text "$cost2"
2888 proc UIShowZoneStatus
{zone density value crime pollution growth x y
} {
2889 global QueryX QueryY
2890 set QueryX
[expr "8 + 16 * $x"]
2891 set QueryY
[expr "8 + 16 * $y"]
2892 UIShowPicture
9 [list $zone $density $value $crime $pollution $growth]
2896 ########################################################################
2897 # Map Window Handlers
2900 proc ShowMapOf
{head
} {
2903 foreach win
$MapWindows {
2904 if {"[WindowLink $win.head]" == "$head"} {
2905 global MapPanelWidth MapPanelHeight
2906 #place configure $win -x 0 -y 0 -width $MapPanelWidth -height $MapPanelHeight
2907 #[WindowLink $win.parent] configure -width $MapPanelWidth -height $MapPanelHeight
2908 set parent
[WindowLink
$win.parent
]
2909 pack append [WindowLink
$head.w2
] \
2910 $win {top
frame nw expand fill
}
2923 proc NewMapOf
{head
} {
2924 set win
[MakeWindow.map
$head [winfo screen
$head]]
2925 global MapPanelWidth MapPanelHeight
2926 #place configure $win -x 0 -y 0 -width $MapPanelWidth -height $MapPanelHeight
2927 #[WindowLink $win.parent] configure -width $MapPanelWidth -height $MapPanelHeight
2928 set parent
[WindowLink
$win.parent
]
2929 #pack append [WindowLink $head.col1]\
2930 # $parent {top frame nw fillx}
2931 pack append [WindowLink
$head.w2
] \
2932 $win {top
frame nw expand fill
}
2939 foreach win
$HeadWindows {
2945 proc WithdrawMaps
{} {
2947 foreach win
$MapWindows {
2956 foreach win
$MapWindows {
2962 proc InitMap
{win
} {
2967 proc EnableMaps
{} {
2969 foreach win
$MapWindows {
2975 proc EnableMap
{win
} {
2976 [WindowLink
$win.view
] ShowEditors
1
2977 [WindowLink
$win.zones
] config
-state normal
2978 [WindowLink
$win.overlays
] config
-state normal
2982 proc DisableMaps
{} {
2984 foreach win
$MapWindows {
2990 proc DisableMap
{win
} {
2991 [WindowLink
$win.view
] ShowEditors
0
2992 [WindowLink
$win.zones
] config
-state disabled
2993 [WindowLink
$win.overlays
] config
-state disabled
2997 proc SetMapState
{win state
} {
2998 set m
[WindowLink
$win.view
]
3000 if {$state == 14} then
{
3001 ShowFrobOf
[WindowLink
$win.head
]
3006 proc MapPanDown
{w x y
} {
3011 proc MapPanDrag
{w x y
} {
3016 proc MapPanUp
{w x y
} {
3023 proc UISetMapState
{w state
} {
3025 #set win [winfo toplevel $w]
3026 set win
[WindowLink
$w.win
]
3027 set m
[WindowLink
$win.view
]
3028 set title
[lindex $MapTitles $state]
3030 # TODO: set map text field header to title
3031 #wm title $win "$title"
3032 #wm iconname $win "$title"
3034 global [set var MapState.
$win]
3038 {6 8 9 10 11 12 13} {
3039 [WindowLink
$win.legend
] config
-bitmap "@images/legendmm.xpm"
3042 [WindowLink
$win.legend
] config
-bitmap "@images/legendpm.xpm"
3045 [WindowLink
$win.legend
] config
-bitmap "@images/legendn.xpm"
3051 ########################################################################
3052 # Graph Window Handlers
3055 proc ToggleGraphOf
{head
} {
3057 if {"$State" != "play"} {
3062 set win
[WindowLink
$head.graph
]
3064 set mapped
[winfo ismapped
$win]
3068 WithdrawGraphOf
$head
3076 proc WithdrawGraphOf
{head
} {
3077 set win
[WindowLink
$head.graph
]
3084 proc ShowGraphOf
{head
} {
3085 set win
[WindowLink
$head.graph
]
3087 set win
[MakeWindow.graph
$head [winfo screen
$head]]
3091 set parent
[WindowLink
$win.parent
]
3092 pack append $parent\
3093 $win {top
frame nw fillx
}
3099 proc WithdrawGraphs
{} {
3101 foreach win
$GraphWindows {
3108 proc InitGraphs
{} {
3110 foreach win
$GraphWindows {
3116 proc InitGraph
{win
} {
3117 UISetGraphState
$win 1 1 1 1 1 1 0
3121 proc UISetGraphState
{win t0 t1 t2 t3 t4 t5 range
} {
3122 set g
[WindowLink
$win.graphview
]
3123 GraphPalletMask
$win [expr "$t0 + ($t1<<1) + ($t2<<2) + ($t3<<3) + ($t4<<4) + ($t5<<5)"]
3124 GraphYearPallet
$win $range
3128 ########################################################################
3129 # Splash Window Handlers
3132 proc ShowSplashOf
{head
} {
3133 set win
[WindowLink
$head.splash
]
3135 set win
[MakeWindow.splash
$head [winfo screen
$head]]
3137 set splashscreen
[WindowLink
$win.splashscreen
]
3139 catch {$splashscreen config
-bitmap "@images/splashscreen.xpm"; set success 1}
3142 global SplashScreenDelay
3143 after $SplashScreenDelay "UIPickScenarioMode"
3150 proc WithdrawSplashOf
{head
} {
3151 set win
[WindowLink
$head.splash
]
3158 proc ShowSplashes
{} {
3160 foreach win
$HeadWindows {
3166 proc WithdrawSplashes
{} {
3167 global SplashWindows
3168 foreach win
$SplashWindows {
3170 set splashscreen
[WindowLink
$win.splashscreen
]
3171 $splashscreen config
-bitmap ""
3176 proc InitSplashes
{} {
3180 proc InitSplash
{win
} {
3184 proc DeleteSplashWindow
{win
} {
3189 ########################################################################
3190 # Scenario Window Handlers
3193 proc ShowScenarioOf
{head
} {
3194 set win
[WindowLink
$head.scenario
]
3196 set win
[MakeWindow.scenario
$head [winfo screen
$head]]
3198 # TODO: load background bitmap
3203 proc WithdrawScenarioOf
{head
} {
3204 set win
[WindowLink
$head.scenario
]
3211 proc ShowScenarios
{} {
3213 foreach win
$HeadWindows {
3219 proc WithdrawScenarios
{} {
3220 global ScenarioWindows
3221 foreach win
$ScenarioWindows {
3223 # TODO: flush background bitmap
3228 proc InitScenarios
{} {
3229 global MapHistory MapHistoryNum
3230 if {$MapHistoryNum < 1} {
3235 if {$MapHistoryNum == ([llength $MapHistory] - 1)} {
3240 global ScenarioWindows
3241 foreach win
$ScenarioWindows {
3243 #[WindowLink $win.previous] config -state $prev
3244 #[WindowLink $win.next] config -state $next
3249 proc InitScenario
{win
} {
3250 global MapHistory MapHistoryNum
3251 if {$MapHistoryNum < 1} {
3257 if {$MapHistoryNum == ([llength $MapHistory] - 1)} {
3264 #[WindowLink $win.previous] config -state $prev
3265 #[WindowLink $win.next] config -state $next
3267 LinkWindow
$win.scenarioTarget
-1
3268 LinkWindow
$win.scenarioTargetDown
-1
3270 global ScenarioButtons
3272 set len
[llength $ScenarioButtons]
3274 set data
[lindex $ScenarioButtons $i]
3275 set type
[lindex $data 0]
3276 set id
[lindex $data 1]
3280 LinkWindow
$win.
$id.over
0
3281 LinkWindow
$win.
$id.enabled
1
3282 LinkWindow
$win.
$id.checked
0
3283 #echo "SETTING WIN $win ID $id"
3285 set i
[expr "$i + 1"]
3288 UpdateLevelSelection
$win
3289 UpdateLeftRightEnabled
$win
3293 proc UpdateLevelSelection
{win
} {
3294 #echo UpdateLevelSelection
3296 if {$GameLevel == 0} then
{
3297 LinkWindow
$win.easy.checked
1
3298 LinkWindow
$win.medium.checked
0
3299 LinkWindow
$win.hard.checked
0
3301 if {$GameLevel == 1} then
{
3302 LinkWindow
$win.easy.checked
0
3303 LinkWindow
$win.medium.checked
1
3304 LinkWindow
$win.hard.checked
0
3306 if {$GameLevel == 2} then
{
3307 LinkWindow
$win.easy.checked
0
3308 LinkWindow
$win.medium.checked
0
3309 LinkWindow
$win.hard.checked
1
3312 UpdateScenarioButtonID
$win easy
3313 UpdateScenarioButtonID
$win medium
3314 UpdateScenarioButtonID
$win hard
3319 proc UpdateLeftRightEnabled
{win
} {
3320 #echo UpdateLeftRightEnabled
3322 global MapHistory MapHistoryNum
3323 if {$MapHistoryNum < 1} {
3324 LinkWindow
$win.left.enabled
0
3326 LinkWindow
$win.left.enabled
1
3329 if {$MapHistoryNum == ([llength $MapHistory] - 1)} {
3330 LinkWindow
$win.right.enabled
0
3332 LinkWindow
$win.right.enabled
1
3335 UpdateScenarioButtonID
$win left
3336 UpdateScenarioButtonID
$win right
3340 proc UpdateScenarioButtonID
{win id
} {
3342 global ScenarioButtons
3344 set len
[llength $ScenarioButtons]
3346 set data
[lindex $ScenarioButtons $i]
3348 if {$id == [lindex $data 1]} then
{
3349 UpdateScenarioButton
$win $data
3353 set i
[expr "$i + 1"]
3358 proc UpdateScenarioButton
{win data
} {
3361 set type
[lindex $data 0]
3362 set id
[lindex $data 1]
3363 set over
[WindowLink
$win.
$id.over
]
3364 set enabled
[WindowLink
$win.
$id.enabled
]
3365 set checked
[WindowLink
$win.
$id.checked
]
3366 #echo "WIN $win TYPE $type ID $id OVER $over ENABLED $enabled CHECKED $checked"
3368 if {[lindex ${data
} 2] == "DoPickScenario"} {
3369 global ScenarioDescX ScenarioDescY ScenarioDescWidth ScenarioDescHeight ScenarioDescFont
3370 catch {text $win.desc
\
3375 -font [Font
$win $ScenarioDescFont]}
3377 $win.desc configure
-state normal
3378 $win.desc delete
0.0 end
3379 $win.desc insert end
"[lindex $Messages([lindex ${data} 3]) 1]\n\n[lindex $Messages([lindex ${data} 3]) 2]"
3380 $win.desc configure
-state disabled
3382 place $win.desc
-x $ScenarioDescX -y $ScenarioDescY -width $ScenarioDescWidth -height $ScenarioDescHeight
3384 if {[lindex ${data
} 2] == "DoMap"} {
3385 global ScenarioMapFloatX ScenarioMapFloatY
3386 if { $ScenarioMapFloatX != "-1" } {
3387 place $win.
canvas.view
-x $ScenarioMapFloatX -y $ScenarioMapFloatY
3391 catch {destroy $win.desc
}
3392 global ScenarioMapFloatX
3393 if { $ScenarioMapFloatX != "-1" } {
3394 catch {place forget
$win.
canvas.view
}
3400 set bm
[lindex $data 13]
3402 set bm
[lindex $data 12]
3406 set bm
[lindex $data 10]
3408 set bm
[lindex $data 9]
3412 set bm
[lindex $data 11]
3415 [WindowLink
$win.
canvas] itemconfig
$id -bitmap $bm
3419 proc DoEnterCityName
{win
} {
3423 proc InitVotesForUseThisMap
{} {
3424 # TODO: Disabled for new scenario window.
3427 global VotesForUseThisMap ScenarioWindows
3428 set VotesForUseThisMap
{}
3429 foreach win
$ScenarioWindows {
3430 [WindowLink
$win.vote
] config
-relief raised
3432 UpdateVotesForUseThisMap
3436 proc UpdateVotesForUseThisMap
{} {
3437 global ScenarioWindows
3438 UpdateVotesFor UseThisMap
$ScenarioWindows
3442 proc UIUseThisMap
{} {
3443 global CityName GameLevel Scenario
3445 # special handling for scenarios?
3446 if {$GameLevel != -1} {
3447 sim GameLevel
$GameLevel
3449 sim CityName
$CityName
3452 if {$Scenario != -1} {
3453 UIShowPicture
$Scenario
3458 proc HandleScenarioDown
{win x y
} {
3459 #echo HandleScenarioDown $win $x $y
3460 HandleScenarioMove
$win $x $y
3461 set w
[WindowLink
$win.w
]
3462 set target
[WindowLink
$w.scenarioTarget
]
3463 LinkWindow
$w.scenarioTargetDown
$target
3467 proc HandleScenarioUp
{win x y
} {
3468 #echo HandleScenarioUp $win $x $y
3469 HandleScenarioMove
$win $x $y
3470 global ScenarioButtons
3471 set w
[WindowLink
$win.w
]
3472 set target
[WindowLink
$w.scenarioTarget
]
3473 set targetDown
[WindowLink
$w.scenarioTargetDown
]
3474 if {($target != -1) &&
3475 ($target == $targetDown)} {
3476 set data
[lindex $ScenarioButtons $target]
3477 set type
[lindex $data 0]
3478 set id
[lindex $data 1]
3479 set callback
[lindex $data 2]
3480 set param
[lindex $data 3]
3481 set var
[lindex $data 4]
3482 set xx
[lindex $data 5]
3483 set yy
[lindex $data 6]
3484 set ww
[lindex $data 7]
3485 set hh
[lindex $data 8]
3486 set normal
[lindex $data 9]
3487 set over
[lindex $data 10]
3488 set disabled
[lindex $data 11]
3489 if {$type == "button"} {
3490 #echo callback $callback w $w param $param
3491 eval "$callback $w {$param}"
3493 if {$type == "checkbox"} {
3494 #echo checkbox callback $callback w $w param $param
3495 eval "$callback $w {$param}"
3502 proc HandleScenarioMove
{win x y
} {
3503 #echo HandleScenarioMove $win $x $y
3504 global ScenarioButtons
3505 set w
[WindowLink
$win.w
]
3506 set target
[WindowLink
$w.scenarioTarget
]
3509 set len
[llength $ScenarioButtons]
3511 set data
[lindex $ScenarioButtons $i]
3512 set type
[lindex $data 0]
3513 set id
[lindex $data 1]
3514 set callback
[lindex $data 2]
3515 set param
[lindex $data 3]
3516 set var
[lindex $data 4]
3517 set xx
[lindex $data 5]
3518 set yy
[lindex $data 6]
3519 set ww
[lindex $data 7]
3520 set hh
[lindex $data 8]
3522 set enabled
[WindowLink
$w.
$id.enabled
]
3523 set checked
[WindowLink
$w.
$id.checked
]
3525 #echo "ID $id ENABLED $enabled CHECKED $checked w $w id $id"
3527 if {($enabled != 0) &&
3529 ($x < ($xx + $ww)) &
3531 ($y < ($yy + $hh))} {
3536 set i
[expr "$i + 1"]
3539 if {$found != $target} {
3542 if {$target != -1} {
3544 #echo OUT $w $found $xx $yy $normal
3545 LinkWindow
$w.scenarioTarget
-1
3547 set targetdata
[lindex $ScenarioButtons $target]
3548 set targetid
[lindex $targetdata 1]
3549 LinkWindow
$w.
$targetid.over
0
3550 UpdateScenarioButton
$w $targetdata
3555 #echo IN $w $found $xx $yy $over
3556 LinkWindow
$w.scenarioTarget
$found
3557 LinkWindow
$w.
$id.over
1
3559 if {$target != -1} {
3560 set targetdata
[lindex $ScenarioButtons $target]
3561 set targetid
[lindex $targetdata 1]
3562 LinkWindow
$w.
$targetid.over
0
3563 UpdateScenarioButton
$w $targetdata
3566 UpdateScenarioButton
$w $data
3572 proc DoLoad
{win param
} {
3573 #echo DOLOAD $win $param
3578 proc DoGenerate
{win param
} {
3579 #echo DOGENERATE $win $param
3584 proc DoQuit
{win param
} {
3585 #echo DOQUIT $win $param
3590 proc DoAbout
{win param
} {
3591 #echo DOABOUT $win $param
3592 MakeHistory
"DoLoadCity cities/about.cty"
3596 proc DoMap
{win param
} {
3597 #echo DOMAP $win $param
3601 proc DoLevel
{win param
} {
3602 #echo DOLEVEL $win $param
3603 DoSetGameLevel
$param
3607 proc DoLeft
{win param
} {
3608 #echo DOLEFT $win $param
3613 proc DoRight
{win param
} {
3614 #echo DORIGHT $win $param
3619 proc DoPlay
{win param
} {
3620 #echo DOPLAY $win $param
3625 proc DoPickScenario
{win param
} {
3626 #echo DOPICKSCENARIO $win $param
3627 UILoadScenario
$param
3630 proc DeleteScenarioWindow
{win
} {
3635 ########################################################################
3636 # Undo/Redo Facility
3639 proc InitHistory
{} {
3641 global MapHistoryNum
3643 set MapHistoryNum
-1
3647 proc MakeHistory
{cmd
} {
3649 set len
[llength $MapHistory]
3651 ($cmd != [lindex $MapHistory [expr $len-1]])} {
3652 lappend MapHistory
$cmd
3660 proc GotoHistory
{i
} {
3662 global MapHistoryNum
3663 InitVotesForUseThisMap
3664 if {$i != $MapHistoryNum} {
3665 set MapHistoryNum
$i
3666 set cmd
[lindex $MapHistory $i]
3669 if {$MapHistoryNum == 0} {
3674 if {$MapHistoryNum == ([llength $MapHistory] - 1)} {
3680 global ScenarioWindows
3681 foreach win
$ScenarioWindows {
3682 UpdateLeftRightEnabled
$win
3688 proc NextHistory
{} {
3690 global MapHistoryNum
3691 set len
[llength $MapHistory]
3692 set i
[expr "$MapHistoryNum + 1"]
3699 proc PrevHistory
{} {
3701 global MapHistoryNum
3702 set i
[expr "$MapHistoryNum - 1"]
3709 ########################################################################
3710 # Ask Window Handlers
3712 proc ShowAskOf
{head
} {
3713 set win
[WindowLink
$head.ask
]
3715 set win
[MakeWindow.ask
$head [winfo screen
$head]]
3725 foreach win
$HeadWindows {
3731 proc WithdrawAsks
{} {
3733 foreach win
$AskWindows {
3739 proc WithdrawAskOf
{win
} {
3740 set ask
[WindowLink
$win.ask
]
3747 proc AskQuestion
{color title
text left middle right
} {
3749 foreach win
$HeadWindows {
3750 AskQuestionOn
$win $color $title $text $left $middle $right
3755 proc AskQuestionOn
{head color title
text left middle right
} {
3758 set win
[WindowLink
$head.ask
]
3759 set t
[WindowLink
$win.title
]
3760 $t configure
-text $title
3761 $t configure
-background $color
3763 set t
[WindowLink
$win.
text]
3764 $t configure
-state normal
3766 $t insert end
"${text}\n"
3767 $t configure
-state disabled
3769 set bf
[WindowLink
$win.
frame]
3770 set l
[WindowLink
$win.left
]
3771 set m
[WindowLink
$win.middle
]
3772 set r
[WindowLink
$win.vote
]
3773 set rf
[WindowLink
$win.voteframe
]
3777 -text [lindex $left 0] \
3778 -command [format [lindex $left 2] $head]
3779 SetHelp
$l [lindex $left 1]
3780 pack append $bf $l {left
frame center
}
3785 if {$middle != ""} {
3787 -text [lindex $middle 0] \
3788 -command [format [lindex $middle 2] $head]
3789 SetHelp
$m [lindex $middle 1]
3790 pack append $bf $m {left
frame center expand
}
3796 set notify
[format [lindex $right 2] $head]
3797 set preview
[format [lindex $right 3] $head]
3798 set cmd
[list DoVote
$win Ask
$notify $preview]
3800 -text [lindex $right 0] \
3802 SetHelp
$r [lindex $right 1]
3803 pack append $bf $rf {right
frame center
}
3812 proc BindVotingButton
{win but name
} {
3813 set w
[WindowLink
$win.top
]
3815 bind $but <Any-Enter
> "VoteButtonEnter $win $but"
3816 bind $but <Any-Leave
> "VoteButtonLeave $win $but"
3817 bind $but <1> "VoteButtonDown $win $but $name"
3818 bind $but <ButtonRelease-1
> "VoteButtonUp $win $but $name"
3819 bind $but <2> "VoteButtonDown $win $but $name"
3820 bind $but <ButtonRelease-2
> "VoteButtonUp $win $but $name"
3821 bind $but <3> "VoteButtonDown $win $but $name"
3822 bind $but <ButtonRelease-3
> "VoteButtonUp $win $but $name"
3826 proc VoteButtonEnter
{win but
} {
3828 set screen
[winfo screen
$but]
3829 if {[lindex [$but config
-state] 4] != "disabled"} {
3830 $but config
-state active
3831 set tk_priv
(window
@$screen) $but
3833 set tk_priv
(window
@$screen) ""
3838 proc VoteButtonLeave
{win but
} {
3840 if {[lindex [$but config
-state] 4] != "disabled"} {
3841 $but config
-state normal
3843 set screen
[winfo screen
$but]
3844 set tk_priv
(window
@$screen) ""
3848 proc VoteButtonDown
{win but name
} {
3850 set screen
[winfo screen
$but]
3851 set rel
[lindex [$but config
-relief] 4]
3852 set tk_priv
(relief
@$screen) $rel
3853 if {[lindex [$but config
-state] 4] != "disabled"} {
3854 set head
[WindowLink
$win.head
]
3855 if {[IsVotingFor
$head $name]} {
3856 $but config
-relief raised
3858 $but config
-relief sunken
3864 proc VoteButtonUp
{win but name
} {
3866 set screen
[winfo screen
$but]
3867 $but config
-relief $tk_priv(relief
@$screen)
3868 if {($but == $tk_priv(window
@$screen))
3869 && ([lindex [$but config
-state] 4] != "disabled")} {
3870 uplevel #0 [list $but invoke]
3871 set head
[WindowLink
$win.head
]
3872 if {[IsVotingFor
$head $name]} {
3873 $but config
-relief sunken
3875 $but config
-relief raised
3881 proc PressVoteButton
{win but name
} {
3883 uplevel #0 [list $but invoke]
3884 set head
[WindowLink
$win.head
]
3885 if {[IsVotingFor
$head $name]} {
3886 $but config
-relief sunken
3888 $but config
-relief raised
3893 proc IsVotingFor
{win name
} {
3894 global VotesFor
$name
3895 set votes
[eval ident
"\$\{VotesFor$name\}"]
3896 if {[lsearch $votes $win] == -1} {
3904 proc DoVote
{win name notify preview
} {
3905 global VotesFor
$name
3906 set votes
[eval ident
"\$\{VotesFor$name\}"]
3908 set win
[WindowLink
$win.head
]
3909 set i
[lsearch $votes $win]
3911 lappend VotesFor
$name $win
3913 set VotesFor
$name [lreplace $votes $i $i]
3916 set votes
[eval ident
"\$\{VotesFor$name\}"]
3917 if {[llength $votes] >= [NeededVotes
]} {
3925 proc UpdateVotesFor
{name wins
} {
3926 global VotesFor
$name
3927 set votes
[eval llength "\$\{VotesFor$name\}"]
3928 set needed
[NeededVotes
]
3931 set head
[WindowLink
$win.head
]
3932 if {[IsVotingFor
$head $name]} {
3933 set border
[expr "($needed - $votes) * 1"]
3934 set pad
[expr "6 - $border"]
3935 [WindowLink
$win.vote
] config
-padx $pad -pady $pad
3936 [WindowLink
$win.voteframe
] config
-borderwidth $border
3938 set border
[expr "($needed - $votes - 1) * 1"]
3939 set pad
[expr "6 - $border"]
3940 [WindowLink
$win.vote
] config
-padx $pad -pady $pad
3941 [WindowLink
$win.voteframe
] config
-borderwidth $border
3947 proc InitVotesForAsk
{} {
3948 global VotesForAsk AskWindows
3950 foreach win
$AskWindows {
3951 [WindowLink
$win.vote
] config
-relief raised
3958 proc UpdateVotesForAsk
{} {
3960 UpdateVotesFor Ask
$AskWindows
3964 ########################################################################
3965 # Player Window Handlers
3967 proc ShowPlayerOf
{head
} {
3968 set win
[WindowLink
$head.player
]
3970 set win
[MakeWindow.player
$head [winfo screen
$head]]
3978 proc ShowPlayers
{} {
3980 foreach win
$HeadWindows {
3986 proc WithdrawPlayers
{} {
3987 global PlayerWindows
3988 foreach win
$PlayerWindows {
3994 proc UpdatePlayers
{} {
3995 # TODO: Disabled for new scenario window.
3998 global HeadWindows PlayerWindows
4001 foreach win
$HeadWindows {
4002 set server
[winfo screen
$win]
4003 # if {[string first : $server] == 0} {
4004 # set server "[exec hostname]:0"
4006 lappend players
$server
4009 sim Players
[llength $players]
4011 foreach win
$PlayerWindows {
4012 set list [WindowLink
$win.players
]
4014 eval "$list insert 0 $players"
4017 UpdateVotesForUseThisMap
4019 UpdateVotesForBudget
4020 UpdateTaxRateSliders
4024 proc UIShowPlayer
{win
} {
4029 proc DoNewPlayer
{win
} {
4030 set field
[WindowLink
$win.display
]
4031 set dpy
[$field get
]
4036 if {[AddPlayer
$dpy] != ""} {
4042 ########################################################################
4043 # Notice Window Handlers
4046 proc ShowNoticeOf
{head
} {
4047 set win
[WindowLink
$head.notice
]
4049 set win
[MakeWindow.notice
$head [winfo screen
$head]]
4051 global NoticePanelWidth NoticePanelHeight
4052 #place configure $win -x 0 -y 0 -width $NoticePanelWidth -height $NoticePanelHeight
4053 pack append [WindowLink
$head.w3
] \
4054 $win {bottom
frame sw expand fill
}
4059 proc ShowNotices
{} {
4061 foreach win
$HeadWindows {
4067 proc WithdrawNotices
{} {
4068 global NoticeWindows
4069 foreach win
$NoticeWindows {
4076 proc ReShowPictureOn
{{head
""}} {
4077 global ShowingPicture ShowingParms
4078 UIShowPictureOn
$head $ShowingPicture $ShowingParms
4082 proc UIShowPicture
{id
{parms
""}} {
4083 UIShowPictureOn
"" $id $parms
4087 proc UIShowPictureOn
{where id
{parms
""}} {
4088 global DoNotices Messages ShowingPicture ShowingParms
4089 if {$DoNotices == 0} {
4093 set ShowingPicture
$id
4094 set ShowingParms
$parms
4095 set msg
$Messages($id)
4096 set color
[lindex $msg 0]
4097 set title
[lindex $msg 1]
4098 set body
[lindex $msg 2]
4100 set cmd
"format {$body} $parms"
4101 set body
[uplevel #0 $cmd]
4103 set props
[lindex $msg 3]
4104 if {"$where" == ""} {
4106 set where
$HeadWindows
4108 foreach head
$where {
4109 NoticeMessageOn
$head "$title" $color "$body" Medium
$props
4114 proc NoticeMessageOn
{head title color
text font props
} {
4116 set win
[WindowLink
$head.notice
]
4118 set t
[WindowLink
$win.title
]
4119 $t configure
-text $title -background $color
4121 set t
[WindowLink
$win.
text]
4122 $t configure
-state normal
-font [Font
$head $font]
4124 $t insert end
"${text}\n"
4125 $t configure
-state disabled
4128 catch {set left
[keylget props left
]}
4129 set l
[WindowLink
$win.left
]
4131 $l config
-bitmap $left
4132 place $l -in $t -anchor sw
-relx .05 -rely .95
4138 catch {set middle
[keylget props middle
]}
4139 set m
[WindowLink
$win.middle
]
4140 if {$middle != ""} {
4141 $m config
-bitmap $middle
4142 place $m -in $t -anchor s
-relx .5 -rely .95
4148 catch {set right
[keylget props right
]}
4149 set r
[WindowLink
$win.right
]
4151 $r config
-bitmap $right
4152 place $r -in $t -anchor se
-relx .95 -rely .95
4158 catch {set view
[keylget props view
]}
4159 set vf
[WindowLink
$win.viewframe
]
4161 set v
[WindowLink
$win.view
]
4162 set bg
[WindowLink
$win.background
]
4166 pack append $bg $vf {left
frame center fill
}
4167 pack append $bg $t {right
frame center fill expand
}
4174 proc UIPopUpMessage
{msg
} {
4179 proc ComeToMe
{view
} {
4180 set win
[winfo toplevel $view]
4183 set x
[expr "[lindex $xy 0] >>4"]
4184 set y
[expr "[lindex $xy 1] >>4"]
4190 proc ComeTo
{win x y
} {
4191 global EditorWindows
4192 set head
[WindowLink
$win.head
]
4195 foreach ed
$EditorWindows {
4196 if {"[WindowLink $ed.head]" == "$head"} {
4198 set view
[WindowLink
$ed.view
]
4199 if {[$view AutoGoto
]} {
4200 lappend myautoeds
$ed
4204 if {[llength $myautoeds]} {
4205 UIAutoGotoOn
$x $y $myautoeds
4207 if {[llength $myeds]} {
4208 UIAutoGotoOn
$x $y $myeds
4214 proc FollowView
{view id
} {
4218 if {[sim DoAnimation
]} {
4219 set head
[WindowLink
[winfo toplevel $view].head
]
4220 global EditorWindows
4221 foreach win
$EditorWindows {
4222 if {"[WindowLink $win.head]" == "$head"} {
4223 set s
[[WindowLink
$win.view
] Skip
]
4224 set skips
[min
$skips $s]
4228 if {$skips == 999999} {
4238 proc PanView
{view x y
} {
4244 ########################################################################
4245 # Help Window Handlers
4248 proc ShowHelpOf
{head
} {
4249 set win
[WindowLink
$head.help
]
4251 set win
[MakeWindow.help
$head [winfo screen
$head]]
4261 foreach win
$HeadWindows {
4267 proc WithdrawHelps
{} {
4269 foreach win
$HelpWindows {
4275 ########################################################################
4276 # Frob Window Handlers
4279 proc ShowFrobOf
{head
} {
4280 set win
[WindowLink
$head.frob
]
4282 set win
[MakeWindow.frob
$head [winfo screen
$head]]
4293 foreach win
$HeadWindows {
4299 proc WithdrawFrobs
{} {
4301 foreach win
$FrobWindows {
4307 proc UISetDynamic
{i min max
} {
4308 sim DynamicData
[expr "$i*2"] $min
4309 sim DynamicData
[expr "$i*2+1"] $max
4313 ########################################################################
4320 source $ResourceDir/help.tcl
4323 proc HandleHelp
{win x y rootx rooty
} {
4324 global HelpLoaded HelpWidgets Messages
4326 if {$HelpLoaded == 0} {
4332 set head
[WindowLink
[winfo toplevel $win].head
]
4335 catch {set id
$HelpWidgets($win)}
4339 set list [split $win .
]
4340 set len
[expr "[llength $list] - 2"]
4341 set list [lrange $list 0 $len]
4342 if {[llength $list] <= 1} {
4346 set win
[join $list .
]
4348 if [info exists Messages
($id)] {
4349 UIShowHelpOn
$head $id
4351 UIShowHelpOn
$head Window
4356 proc UIShowHelpOn
{win id
{parms
""}} {
4357 global Messages ShowingPicture ShowingParms ResourceDir
4358 set head
[WindowLink
$win.head
]
4359 set msg
$Messages($id)
4360 set color
[lindex $msg 0]
4361 set title
[lindex $msg 1]
4362 set body
[lindex $msg 2]
4364 set cmd
"format {$body} $parms"
4365 set body
[uplevel #0 $cmd]
4367 set props
[lindex $msg 3]
4370 set win
[WindowLink
$head.help
]
4372 set t
[WindowLink
$win.title
]
4373 $t configure
-text $title -background $color
4375 set t
[WindowLink
$win.
text]
4376 $t configure
-state normal
-font [Font
$head Large
]
4378 $t insert end
"${body}\n"
4379 FormatHTML
$ResourceDir/doc
/$id.html
$t
4380 $t configure
-state disabled
4384 proc FormatHTML
{filename text} {
4387 set f
[open $filename]
4394 while {[gets $f line
] >= 0} {
4395 if {"$line" == "</body>"} {
4398 if {([string index
$line 0] == "#") ||
([string length
$line] == 0)} {
4401 $text insert end
"$line\n"
4410 proc SetHelp
{win id
} {
4412 set HelpWidgets
($win) $id
4416 proc Help
{id title
{msg
{}} {props
{}}} {
4417 Message
$id #7f7fff $title $msg $props
4420 ########################################################################
4424 # Set up the bindings to pop up $pie when the right button is clicked in $win
4425 proc InitPie
{win pie
} {
4426 bind $win <Motion
> {}
4427 bind $win <3> "PieMenuDown $win $pie $pie Initial %X %Y"
4428 bind $win <B3-Motion
> {}
4429 bind $win <B3-ButtonRelease
> {}
4433 # Set up the bindings to continue tracking $pie
4434 # Get this: we keep the tracking machine state in the bindings!
4435 proc ActivatePie
{win root pie state
} {
4436 bind $win <Motion
> "PieMenuMotion $win $root $pie $state %X %Y"
4437 bind $win <3> "PieMenuDown $win $root $pie $state %X %Y"
4438 bind $win <B3-Motion
> "PieMenuMotion $win $root $pie $state %X %Y"
4439 bind $win <B3-ButtonRelease
> "PieMenuUp $win $root $pie $state %X %Y"
4443 # Cancel and reset a pie menu
4444 proc CancelPie
{win
} {
4445 set binding
[bind $win <3>]
4446 set root
[lindex $binding 2]
4447 set pie
[lindex $binding 3]
4448 set state
[lindex $binding 4]
4449 if {"$state" != "Initial"} {
4450 catch {$root ungrab
$win}
4453 UIMakeSoundOn
$win fancy Oop
4459 # Handle pie menu button down
4460 proc PieMenuDown
{win root pie state x y
} {
4463 ActivatePie
$win $root $pie FirstDown
4465 catch {$root grab $win}
4468 PreviewPieMenu
$win $pie $x $y
4472 TrackPieMenu
$pie $x $y
4473 ActivatePie
$win $root $pie SecondDown
4479 PreviewPieMenu
$win $pie $x $y
4480 ActivatePie
$win $root $pie SecondDown
4485 SecondDown
{ # error
4492 # Handle pie menu button motion
4493 proc PieMenuMotion
{win root pie state x y
} {
4496 TrackPieMenu
$pie $x $y
4504 TrackPieMenu
$pie $x $y
4518 # Handle pie menu button up
4519 proc PieMenuUp
{win root pie state x y
} {
4522 TrackPieMenu
$pie $x $y
4523 set active
[$pie index active
]
4524 if {$active == "none"} {
4526 catch {$root grab $win}
4527 ActivatePie
$win $root $pie ClickedUp
4529 set label [lindex [$pie entryconfig
$active -label] 4]
4530 set submenu
[lindex [$pie entryconfig
$active -piemenu] 4]
4531 UIMakeSoundOn
$win mode
$label
4532 if {$submenu == {}} {
4533 set reward
[$pie pending
]
4534 catch {$root ungrab
$win}
4538 sim Funds
[expr "[sim Funds] + 5"]
4539 UIMakeSoundOn
$win fancy Aaah
4541 eval [lindex [$pie entryconfig
$active -command] 4]
4546 $submenu activate none
4548 PreviewPieMenu
$win $submenu $x $y
4549 catch {$root grab $win}
4550 ActivatePie
$win $root $submenu SelectedUp
4555 TrackPieMenu
$pie $x $y
4556 set active
[$pie index active
]
4557 if {$active == "none"} {
4560 set label [lindex [$pie entryconfig
$active -label] 4]
4561 set submenu
[lindex [$pie entryconfig
$active -piemenu] 4]
4562 UIMakeSoundOn
$win mode
$label
4563 if {$submenu == {}} {
4564 set reward
[$pie pending
]
4565 catch {$root ungrab
$win}
4569 sim Funds
[expr "[sim Funds] + 5"]
4570 UIMakeSoundOn
$win fancy Aaah
4572 eval [lindex [$pie entryconfig
$active -command] 4]
4577 $submenu activate none
4579 PreviewPieMenu
$win $submenu $x $y
4580 catch {$root grab $win}
4581 ActivatePie
$win $root $submenu SelectedUp
4591 SelectedUp
{ # error
4598 # Track the selected item
4599 proc TrackPieMenu
{pie x y
} {
4600 $pie activate
@$x,$y
4604 proc PreviewPieMenu
{win pie x y
} {
4605 set preview
[lindex [$pie config
-preview] 4]
4606 if {"$preview" != ""} {
4607 set rx
[winfo rootx
$win]
4608 set ry
[winfo rooty
$win]
4609 set x
[expr "$x - $rx"]
4610 set y
[expr "$y - $ry"]
4611 eval [format $preview $x $y]
4616 ########################################################################
4620 proc ExclusivePallet
{state parent children prefix images inactive active cmd
} {
4621 #echo "ExclusivePallet state $state parent $parent children $children prefix $prefix images $images inactive $inactive active $active cmd $cmd"
4623 foreach child
$children {
4624 set name
[lindex $images $i]
4625 if {$i == $state} then
{
4626 $parent.
$child config
\
4627 -bitmap "@images/${prefix}${name}hi.xpm" \
4630 $parent.
$child config
\
4631 -bitmap "@images/${prefix}${name}.xpm" \
4636 eval [concat $cmd $state]
4640 proc NonExclusivePallet
{mask parent children prefix images
4641 inactive active cmd
} {
4643 foreach child
$children {
4644 set name
[lindex $images $i]
4645 if {$mask & (1<<$i)} then
{
4646 $parent.
$child config
\
4647 -bitmap "@images/${prefix}${name}hi.xpm" \
4650 $parent.
$child config
\
4651 -bitmap "@images/${prefix}${name}.xpm" \
4656 eval [concat $cmd $mask]
4660 proc EditorPallet
{win state
} {
4661 global EditorPalletSounds
4662 UIMakeSoundOn
$win mode
[lindex $EditorPalletSounds $state]
4663 EditorSetTool
$win $state
4667 proc EditorSetTool
{win state
} {
4668 global EditorPallets
4669 global EditorPalletImages
4670 ExclusivePallet
$state $win $EditorPallets ic
$EditorPalletImages \
4671 flat raised
"$win.centerframe.view ToolState"
4675 proc GraphPallet
{win state
} {
4676 set mask
[[WindowLink
$win.graphview
] Mask
]
4677 set mask
[expr "$mask ^ (1<<$state)"]
4678 GraphPalletMask
$win $mask
4682 proc GraphPalletMask
{win mask
} {
4684 global GraphPalletImages
4685 NonExclusivePallet
$mask $win $GraphPallets gr
$GraphPalletImages \
4686 flat flat
"SetGraphState $win"
4690 proc GraphYearPallet
{win state
} {
4691 global GraphYearPallets
4692 global GraphYearPalletImages
4693 ExclusivePallet
$state $win $GraphYearPallets gr
$GraphYearPalletImages \
4694 flat flat
"SetGraphYearState $win"
4698 proc SetGraphYearState
{win state
} {
4699 set graph
[WindowLink
$win.graphview
]
4708 proc SetGraphState
{win mask
} {
4710 set graph
[WindowLink
$win.graphview
]
4715 ########################################################################
4718 proc sim_butEnter
{w
} {
4720 set screen
[winfo screen
$w]
4721 set tk_priv
(window
@$screen) $w
4725 proc sim_butLeave
{w
} {
4727 set screen
[winfo screen
$w]
4728 set tk_priv
(window
@$screen) ""
4732 proc sim_butDown
{w
} {
4734 set screen
[winfo screen
$w]
4735 set pict
[lindex [$w config
-bitmap] 4]
4736 set tk_priv
(relief
@$screen) $pict
4737 $w config
-bitmap [lindex [split $pict .
] 0]hi.xpm
4742 proc sim_butUp
{w
} {
4744 set screen
[winfo screen
$w]
4745 $w config
-bitmap $tk_priv(relief
@$screen)
4747 if {$w == $tk_priv(window
@$screen)} {
4748 uplevel #0 [list $w invoke]
4753 proc BindSimButton
{w
} {
4754 bind $w <Any-Enter
> {sim_butEnter
%W
}
4755 bind $w <Any-Leave
> {sim_butLeave
%W
}
4756 bind $w <1> {sim_butDown
%W
}
4757 bind $w <ButtonRelease-1
> {sim_butUp
%W
}
4758 bind $w <2> {sim_butDown
%W
}
4759 bind $w <ButtonRelease-2
> {sim_butUp
%W
}
4760 bind $w <3> {sim_butDown
%W
}
4761 bind $w <ButtonRelease-3
> {sim_butUp
%W
}
4765 ########################################################################
4766 # Internal Callbacks
4769 proc UIStartMicropolis
{homedir resourcedir hostname
} {
4770 global HomeDir ResourceDir HostName HeadWindows
4771 set HomeDir
$homedir
4772 set ResourceDir
$resourcedir
4773 set HostName
$hostname
4778 foreach display
[sim Displays
] {
4779 if {"[AddPlayer $display]" == ""} {
4780 echo Couldn't add a player on
$display ...
4784 if {"$HeadWindows" == ""} {
4785 echo Micropolis is exiting because it couldn't connect to any players.
4791 proc UISelectCity
{win
} {
4792 AskQuestion
[Color
$win #ff0000 #ffffff] "Choose Another City" \
4793 "Do you want to abandon this city and choose another one?" \
4794 "{Keep playing.} SelectCity.No {RejectPlan}" \
4796 "{Another city!} SelectCity.Yes {UIPickScenarioMode}"
4800 proc UIQuit
{head
} {
4801 if {[sim Players
] == 1} {
4802 set l
"{Keep playing.} Quit.No {RejectPlan}"
4804 set r
"{I quit!} Quit.IQuit {DoReallyQuit %s}"
4806 set l
"{Keep playing.} Quit.No {RejectPlan}"
4807 set m
"{I quit!} Quit.IResign {DoIResign %s}"
4808 set r
"{Everyone quit!} Quit.AllQuit {DoReallyQuit %s}"
4810 AskQuestion
[Color
$head #ff0000 #ffffff] "Quit Playing Micropolis" \
4811 "Do you want to quit playing Micropolis?" \
4816 proc DoIResign
{head
} {
4818 set display
[winfo screen
$head]
4820 DecRefDisplay
$display
4821 UISetMessage
"The player on X11 Display $display has resigned."
4823 if {([sim Players
] == 0) ||
4824 ([llength $VotesForAsk] >= [sim Players
])} {
4830 proc DoReallyQuit
{head
} {
4836 proc UISplashMode
{} {
4846 proc UIPickScenarioMode
{} {
4855 InitVotesForUseThisMap
4860 proc ForcePickScenarioMode
{} {
4862 if {"$State" != "scenario"} {
4868 proc UIGenerateCityNow
{} {
4869 global CityName GameLevel
4870 sim CityName NowHere
4876 proc UIGenerateNewCity
{} {
4877 global CityName GameLevel
4878 if {$GameLevel == -1} {
4881 MakeHistory
"DoNewCity NowHere $GameLevel [sim Rand] [sim TreeLevel] [sim LakeLevel] [sim CurveLevel] [sim CreateIsland]"
4885 proc DoNewCity
{name level
{r
""} {tl
-1} {ll
-1} {cl
-1} {ci
-1}} {
4891 sim CreateIsland
$ci
4895 sim GenerateSomeCity
$r
4898 sim GameLevel
$level
4903 proc UIDidGenerateNewCity
{} {
4908 proc IncRefDisplay
{display
} {
4909 global DisplayRegistry
4910 if ![info exists DisplayRegistry
($display)] {
4911 set DisplayRegistry
($display) 0
4913 incr DisplayRegistry
($display)
4917 proc DecRefDisplay
{display
} {
4918 global DisplayRegistry
4919 incr DisplayRegistry
($display) -1
4920 if {$DisplayRegistry($display) <= 0} {
4921 CloseDisplay
$display
4926 proc CloseDisplay
{display
} {
4930 proc DoStopMicropolis
{} {
4936 proc AddPlayer
{display
} {
4937 set i
[string first
: $display]
4941 set display
"$display:0"
4945 echo Adding a player on
$display ...
4947 set head
[MakeWindow.head
$display]
4949 if {"$head" != ""} {
4950 set display
[winfo screen
$head]
4951 IncRefDisplay
$display
4953 UISetMessage
"Added a player on X11 Display \"$display\"."
4956 UISetMessage
"Couldn't add a player on X11 Display \"$display\"!"
4966 proc DropFireBombs
{} {
4974 proc UIMakeMonster
{} {
4975 sim MakeMonster
[sim Rand
120] [sim Rand
100]
4998 proc TogglePause
{} {
5001 if {"$State" != "play" ||
[sim Speed
]} {
5012 proc SetSpeedTime
{time} {
5018 proc MakeRunningSound
{} {
5021 if {"$State" == "play" && [sim Speed
]} {
5022 UIMakeSound edit Boing
"-speed 1[sim Speed]0"
5024 UIMakeSound edit Boing
"-speed 90"
5029 proc SayDemands
{} {
5030 global DemandRes DemandCom DemandInd
5032 set r
[expr "100 + ($DemandRes * $slope)"]
5033 set c
[expr "100 + ($DemandCom * $slope)"]
5034 set i
[expr "100 + ($DemandInd * $slope)"]
5035 after 020 "UIMakeSound edit O \"-speed $r\""
5036 after 220 "UIMakeSound edit A \"-speed $c\""
5037 after 440 "UIMakeSound edit E \"-speed $i\""
5041 proc UISaveCity
{win
} {
5043 set SaveCityWin
$win
5048 proc UISaveCityAs
{{win
""}} {
5050 if {"$win" == ""} {set win
$SaveCityWin}
5051 set SaveCityWin
$win
5054 set file [ShowFileOf
$win]
5055 DoFileDialog
$file "Choose a File to Save the City" $CityDir "*.cty" "" \
5056 "UIDoReallySaveCity" ""
5060 proc UIDoReallySaveCity
{name path
} {
5062 if {![string match
*.cty
$name]} {
5066 sim SaveCityAs
$path/$name
5070 proc UIDidSaveCity
{} {
5071 DoSendMessage
"Saved the city in \"[sim CityFileName]\"." status
5075 proc UIDidntSaveCity
{msg
} {
5076 DoSendMessage
$msg alert
5077 UIMakeSound warning Sorry
"-speed 85"
5081 proc UILoadScenario
{scen
} {
5082 MakeHistory
"DoScenario $scen"
5086 proc DoScenario
{scen
} {
5089 sim LoadScenario
$scen
5094 proc UIDidLoadScenario
{} {
5098 proc UIStartScenario
{id
} {
5107 proc UIPlayNewCity
{} {
5113 proc UIStartLoad
{} {
5118 proc UIReallyStartGame
{} {
5124 proc UIPlayGame
{} {
5131 SetPriority
$Priority
5139 proc UISetSpeed
{speed
} {
5142 if {"$State" == "play"} {
5143 UISetMessage
[lindex {
5146 {Time flows medium.
}
5154 proc UIUpdateRunning
{} {
5155 global HeadWindows Time State
5157 if {($State == "play") && $Time} {
5158 set pict
"@images/micropolisg.xpm"
5160 set pict
"@images/micropoliss.xpm"
5163 foreach win
$HeadWindows {
5164 set can
[WindowLink
$win.demand
]
5165 $can itemconfig micropolis
-bitmap $pict
5170 proc DoSetGameLevel
{level
} {
5171 sim GameLevel
$level
5175 proc UISetGameLevel
{level
} {
5177 set GameLevel
$level
5178 global ScenarioWindows
5179 foreach win
$ScenarioWindows {
5180 UpdateLevelSelection
$win
5185 proc UISetCityName
{name
} {
5186 global EditorWindows
5189 set title
"Micropolis Editor on $name"
5190 foreach win
$EditorWindows {
5191 # TODO: set editor window and icon title
5192 #wm title $win "$title"
5193 #wm iconname $win "$title"
5198 proc UILoadCity
{win
} {
5199 # if changed, r-u-sure?
5201 set file [ShowFileOf
$win]
5202 DoFileDialog
$file "Choose a City to Load" $CityDir "*.cty" "" \
5207 proc UIDoLoadCity
{name path
} {
5210 if {![string match
*.cty
$name]} {
5213 MakeHistory
"DoLoadCity {$path/$name}"
5217 proc DoLoadCity
{filename} {
5218 sim LoadCity
$filename
5221 proc UIDidLoadCity
{} {
5222 global State GameLevel Scenario
5225 if {$State == "play"} {
5228 UIShowPicture
49 [sim CityFileName
]
5233 proc UIDidntLoadCity
{msg
} {
5234 DoSendMessage
$msg alert
5235 UIMakeSound warning Sorry
"-speed 85"
5236 UIShowPicture
49 [sim CityFileName
]
5255 proc UIDidPan
{w x y
} {
5256 if {[$w ToolMode
] == 1} {
5257 EditorToolDrag
$w $x $y
5263 proc UIDidStopPan
{win
} {
5264 UIMakeSoundOn
$win fancy Skid
"-volume 25"
5269 proc UIEarthQuake
{} {
5273 proc UIAutoGoto
{x y
{except
{}}} {
5274 global EditorWindows
5276 set x
[expr "$x * 16 + 8"]
5277 set y
[expr "$y * 16 + 8"]
5278 foreach win
$EditorWindows {
5279 if {"$win" != "$except"} {
5280 set view
[WindowLink
$win.view
]
5281 if {[$view AutoGoto
]} {
5283 $view AutoGoal
$x $y
5293 proc UIAutoGotoOn
{x y eds
} {
5294 set x
[expr "$x * 16 + 8"]
5295 set y
[expr "$y * 16 + 8"]
5297 [WindowLink
$win.view
] AutoGoal
$x $y
5303 proc DoLeaveGame
{head
} {
5307 proc UILoseGame
{} {
5311 AskQuestion
[Color .
#ff0000 #ffffff] [lindex $Messages(200) 1] \
5312 [lindex $Messages(200) 2] \
5315 "{Ok} SelectCity.Yes {UIPickScenarioMode}"
5324 proc DoPendTool
{view tool x y
} {
5325 global HeadWindows ToolInfo VotesForAsk
5327 set win
[WindowLink
$view.top
]
5328 set head
[WindowLink
$win.head
]
5330 if {($tool == [sim PendingTool
]) &&
5331 ($x == [sim PendingX
]) &&
5332 ($y == [sim PendingY
])} {
5333 if {[lsearch $VotesForAsk $head] != -1} {
5334 # you can only vote once
5335 UIMakeSound edit Oop
5337 UIMakeSound edit Boing
5338 set ask
[WindowLink
$head.ask
]
5339 PressVoteButton
$ask [WindowLink
$ask.vote
] Ask
5342 UIAutoGoto
$x $y $win
5344 UIMakeSound edit Boing
5345 set info [lindex $ToolInfo $tool]
5346 set a
[lindex $info 0]
5347 set name
[lindex $info 1]
5348 set cost
[lindex $info 2]
5349 set title
"Build $a $name"
5350 set question
"Do you support the plan to build $a $name for $cost?"
5351 AskQuestion
[Color
$win #00ff00 #ffffff] "$title" \
5353 "{Veto plan.} Plan.Veto
5355 "{Goto plan.} Plan.Goto
5356 {ComeTo %s $x $y}" \
5357 "{Support plan!} Plan.Support
5358 {SupportPlan $view %s $tool $x $y}
5359 {PreviewSupportPlan $view %s $tool $x $y}"
5360 set VotesForAsk
$head
5361 set ask
[WindowLink
$head.ask
]
5362 [WindowLink
$ask.vote
] config
-relief sunken
5366 sim PendingTool
$tool
5369 sim Votes
[llength $VotesForAsk]
5374 proc RejectPlan
{} {
5376 if {[sim Players
] > 1} {
5377 UIMakeSound edit Sorry
5383 proc NeededVotes
{} {
5385 set players
[sim Players
]
5386 set needed
[expr "$players - $FreeVotes"]
5387 return [max
0 $needed]
5391 proc SupportPlan
{view h tool x y
} {
5393 sim Votes
[llength $VotesForAsk]
5396 $view DoTool
$tool $x $y
5399 UIMakeSound edit Aaah
5403 proc PreviewSupportPlan
{view h tool x y
} {
5405 sim Votes
[llength $VotesForAsk]
5409 proc SugarStartUp
{uri
} {
5413 # TODO: Load the city file at the given URI, or configure according to URI parameters.
5417 proc SugarNickName
{nick
} {
5418 global SugarNickName
5419 set SugarNickName
$nick
5423 proc SugarActivate
{} {
5424 global SugarActivated
5425 set SugarActivated
1
5429 proc SugarDeactivate
{} {
5430 global SugarActivated
5431 set SugarActivated
0
5435 proc SugarShare
{} {
5441 proc SugarBuddyAdd
{key nick color address
} {
5443 set buddy
[list $key $nick $color $address]
5444 lappend SugarBuddies
$buddy
5448 proc SugarBuddyDel
{key nick color address
} {
5450 set buddy
[list $key $nick $color $address]
5451 set i
[lsearch $wins $win]
5453 set SugarBuddies
[lreplace $wins $i $i]
5463 ########################################################################