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 Large
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 {-*-dejavu lgc sans-medium-r-normal-
*-90-*}
304 {-*-dejavu lgc sans-medium-r-normal-
*-80-*}
307 {-*-dejavu lgc sans-medium-r-normal-
*-70-*}
310 {-*-dejavu lgc sans-medium-r-normal-
*-60-*}
313 {-*-dejavu lgc sans-medium-r-normal-
*-60-*}
316 {-*-dejavu lgc sans-medium-r-normal-
*-60-*}
319 {-*-dejavu lgc sans-medium-r-normal-
*-70-*}
322 {-*-dejavu lgc sans-medium-r-normal-
*-70-*}
325 {-*-dejavu lgc sans-medium-r-normal-
*-70-*}
330 ########################################################################
334 {Micropolis Overall Map
}
335 {Residential Zone Map
}
336 {Commercial Zone Map
}
337 {Industrial Zone Map
}
340 {Population Density Map
}
342 {Traffic Density Map
}
343 {Pollution Desity Map
}
347 {Police Coverage Map
}
353 leftframe.tools.palletres
354 leftframe.tools.palletcom
355 leftframe.tools.palletind
356 leftframe.tools.palletfire
357 leftframe.tools.palletquery
358 leftframe.tools.palletpolice
359 leftframe.tools.palletwire
360 leftframe.tools.palletbulldozer
361 leftframe.tools.palletrail
362 leftframe.tools.palletroad
363 leftframe.tools.palletchalk
364 leftframe.tools.palleteraser
365 leftframe.tools.palletstadium
366 leftframe.tools.palletpark
367 leftframe.tools.palletseaport
368 leftframe.tools.palletcoal
369 leftframe.tools.palletnuclear
370 leftframe.tools.palletairport
374 set EditorPalletImages
{
375 res com ind fire qry pol
376 wire dozr rail road chlk ersr
377 stad park seap coal nuc airp
381 set EditorPalletSounds
{
382 Res Com Ind Fire Query Police
383 Wire Bulldozer Rail Road Chalk Eraser
384 Stadium Park Seaport Coal Nuclear Airport
392 leftframe.right.money
393 leftframe.right.crime
394 leftframe.right.pollution
398 set GraphPalletImages
{
399 res com ind mony crim poll
403 set GraphYearPallets
{
404 leftframe.year.year10
405 leftframe.year.year120
409 set GraphYearPalletImages
{ 10 120 }
413 { {a
} {Residential Zone
} {$100}}
414 { {a
} {Commercial Zone
} {$100}}
415 { {an
} {Industrial Zone
} {$100}}
416 { {a
} {Fire Station
} {$500}}
417 { {a
} {Query
} {free
}}
418 { {a
} {Police Station
} {$500}}
420 { {a
} {Bulldozer
} {$1}}
423 { {a
} {Chalk
} {free
}}
424 { {an
} {Eraser
} {free
}}
425 { {a
} {Stadium
} {$5,000}}
427 { {a
} {Seaport
} {$3,000}}
428 { {a
} {Coal Power Plant
} {$3,000}}
429 { {a
} {Nuclear Power Plant
} {$5,000}}
430 { {an
} {Airport
} {$10,000}}
431 { {a
} {Network
} {$1,000}}
435 set DynamicDataNames
{
446 ########################################################################
448 ########################################################################
451 wm title .
{Micropolis Root
}
454 if {"[sim Platform]" == "msdos"} {
475 # The next three lines have no effect on the OLPC, where we don't provide
476 # the font in res (because it's already in the system fonts). These lines
477 # are for other systems that lack the font.
478 set FontPath
"[pwd]/res/dejavu-lgc"
479 system
"xset -fp \"$FontPath\" >/dev/null 2>&1"
480 system
"xset +fp \"$FontPath\" >/dev/null 2>&1"
482 # Ignore SIGCHLD for spawned sound-player childs, this should lead to them
483 # being reaped by init
484 signal ignore SIGCHLD
487 ########################################################################
489 ########################################################################
492 proc Message
{id color title msg
{props
{}}} {
494 set Messages
($id) [list $color $title $msg $props]
498 Message
1 #7f7fff {DULLSVILLE, USA 1900} \
499 {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.
501 It is your job to attract new growth and development
, turning Dullsville into a Metropolis within
30 years.
}
503 Message
2 #7f7fff {SAN FRANCISCO, CA. 1906} \
504 {Damage from the earthquake was minor compared to that of the ensuing fires
, which took days to control.
1500 people died.
506 Controlling the fires should be your initial concern. Then clear the rubble and start rebuilding. You have
5 years.
}
508 Message
3 #7f7fff {HAMBURG, GERMANY 1944} \
509 {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.
511 You must control the firestorms during the bombing and then rebuild the city
after the war. You have
5 years.
}
513 Message
4 #7f7fff {BERN, SWITZERLAND 1965} \
514 {The roads here are becoming more congested every day
, and the residents are upset. They demand that you do something about it.
516 Some have suggested a mass transit system as the answer
, but this would require major rezoning in the downtown area. You have
10 years.
}
518 Message
5 #7f7fff {TOKYO, JAPAN 1957} \
519 {A large reptilian creature has been spotted heading
for Tokyo bay. It seems to be attracted to the heavy levels of industrial pollution there.
521 Try to control the fires
, then rebuild the industrial center. You have
5 years.
}
523 Message
6 #7f7fff {DETROIT, MI. 1972} \
524 {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.
526 You have
10 years to reduce crime and rebuild the industrial base of the city.
}
528 Message
7 #7f7fff {BOSTON, MA. 2010} \
529 {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.
531 You have
5 years to get the situation under control.
}
533 Message
8 #7f7fff {RIO DE JANEIRO, BRAZIL 2047} \
534 {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.
536 You have
10 years to turn this swamp back into a city again.
}
538 Message
9 #ffa500 {Query Zone Status} \
546 {{view
{PanView
$v $QueryX $QueryY}}}
548 Message
10 #ff4f4f {POLLUTION ALERT!} \
549 {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.
551 Either clean up your act or
open a gas mask concession at city hall.
} \
552 {{view
{PanView
$v [sim PolMaxX
] [sim PolMaxY
]}}}
554 Message
11 #ff4f4f {CRIME ALERT!} \
555 {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.
} \
556 {{view
{PanView
$v [sim CrimeMaxX
] [sim CrimeMaxY
]}}}
558 Message
12 #ff4f4f {TRAFFIC WARNING!} \
559 {Traffic in this city is horrible. The city gridlock is expanding. The commuters are getting militant.
561 Either build more roads and rails or get a bulletproof limo.
} \
562 {{view
{PanView
$v [sim TrafMaxX
] [sim TrafMaxY
]}}}
564 Message
20 #ff4f4f {FIRE REPORTED!} \
565 "A fire has been reported!" \
566 {{view
{PanView
$v [sim CrashX
] [sim CrashY
]}}}
568 Message
21 #ff4f4f {MONSTER ATTACK!} \
569 "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. \
570 All you can do is wait till he leaves, then rebuild from the rubble." \
571 {{view
{FollowView
$v monster
}}}
573 # XXX: write more text
574 Message
22 #ff4f4f {TORNADO ALERT!} \
575 {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
!} \
576 {{view
{FollowView
$v tornado
}}}
578 # XXX: write more text
579 Message
23 #ff4f4f {EARTHQUAKE!} \
580 {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.
} \
581 {{view
{PanView
$v [sim CenterX
] [sim CenterY
]}}}
583 # XXX: write more text
584 Message
24 #ff4f4f {PLANE CRASH!} \
585 {A plane has crashed
!} \
586 {{view
{PanView
$v [sim CrashX
] [sim CrashY
]}}}
588 # XXX: write more text
589 Message
25 #ff4f4f {SHIPWRECK!} \
590 {A ship has wrecked
!} \
591 {{view
{PanView
$v [sim CrashX
] [sim CrashY
]}}}
593 # XXX: write more text
594 Message
26 #ff4f4f {TRAIN CRASH!} \
595 {A train has crashed
!} \
596 {{view
{PanView
$v [sim CrashX
] [sim CrashY
]}}}
598 # XXX: write more text
599 Message
27 #ff4f4f {HELICOPTER CRASH!} \
600 {A helicopter has crashed
!} \
601 {{view
{PanView
$v [sim CrashX
] [sim CrashY
]}}}
603 Message
30 #ff4f4f {FIREBOMBING REPORTED!} \
604 {Firebombs are falling
!!} \
605 {{view
{PanView
$v [sim CrashX
] [sim CrashY
]}}}
607 Message
35 #7fff7f {TOWN} \
608 {Congratulations
, your village has grown to town status. You now have
2,000 citizens.
} \
609 {{view
{PanView
$v [sim CenterX
] [sim CenterY
]}}}
611 Message
36 #7fff7f {CITY} \
612 {Your town has grown into a full sized city
, with a current population of
10,000. Keep up the good work
!} \
613 {{view
{PanView
$v [sim CenterX
] [sim CenterY
]}}}
615 Message
37 #7fff7f {CAPITAL} \
616 {Your city has become a capital. The current population here is
50,000. Your political future looks bright.
} \
617 {{view
{PanView
$v [sim CenterX
] [sim CenterY
]}}}
619 Message
38 #7fff7f {METROPOLIS} \
620 {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.
} \
621 {{view
{PanView
$v [sim CenterX
] [sim CenterY
]}}}
623 Message
39 #7fff7f {MEGALOPOLIS} \
624 {Congratulation
, you have reached the highest category of urban development
, the megalopolis.
626 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.
} \
627 {{view
{PanView
$v [sim CenterX
] [sim CenterY
]}}}
629 Message
40 #7fff7f {MEGALINIUM} \
630 {Congratulation
, you have reached the end of
time!
632 Because of the toroidal nature of the the Micropolis Space
/Time Continuum
, your city has wrapped back in
time to
1900!} \
633 {{view
{PanView
$v [sim CenterX
] [sim CenterY
]}}}
635 # XXX: write more text
636 Message
41 #ff4f4f {HEAVY TRAFFIC!} \
638 reporting heavy traffic
!} \
639 {{view
{FollowView
$v helicopter
}}}
641 # XXX: write more text
642 Message
42 #ff4f4f {FLOODING REPORTED!} \
643 {Flooding has been been reported along the water's edge
!} \
644 {{view
{PanView
$v [sim FloodX
] [sim FloodY
]}}}
646 Message
43 #ff4f4f {NUCLEAR MELTDOWN!} \
647 {A nuclear meltdown has occured at your power plant. You are advised to avoid the area until the radioactive isotopes decay.
649 Many generations will confront this problem before it goes away
, so don't hold your breath.
} \
650 {{view
{PanView
$v [sim MeltX
] [sim MeltY
]}}}
653 Message
44 #ff4f4f {RIOTS!} \
654 {The citizens are rioting in the streets
, setting cars and houses on fire
, and bombing government buildings and businesses
!
656 All media coverage is blacked out
, while the fascist pigs beat the poor citizens into submission.
}
658 Message
46 #ff4f4f {NO SOUND SERVER!} \
659 {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.
}
661 Message
48 #7f7fff {Start a New City} \
662 {Build your very own city from the ground up
, starting with this map of uninhabited land.
}
664 Message
49 #7f7fff {Restore a Saved City} \
665 {This city was saved in the
file named
: %s
}
667 Message
100 #7fff7f {YOU'RE A WINNER!} \
668 {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?
} \
669 {{middle
{@images
/key2city.xpm
}}}
671 Message
200 #ff4f4f {IMPEACHMENT NOTICE!} \
672 {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.
674 You should seriously consider taking an extended vacation
-- NOW.
(Or
read the manual and try again.
)}
676 Message
300 #ffd700 {About Micropolis} \
677 "Micropolis Version [sim Version] Copyright (C) 2007
679 Based on the Original Micropolis Concept and Design
681 TCL/Tk User Interface Designed and Created
682 by Don Hopkins, DUX Software.
683 Ported to Linux, Optimized and Adapted for OLPC
685 Licensed under the GNU General Public License,
686 version 3, with additional conditions."
689 ########################################################################
691 ########################################################################
694 option add
*CheckButton.relief flat
695 option add
*Dialog.cursor top_left_arrow
696 option add
*Entry.relief sunken
697 option add
*Frame.borderWidth
0
698 option add
*Listbox.relief sunken
699 option add
*Scrollbar.relief sunken
700 option add
*RadioButton.anchor w
701 option add
*RadioButton.relief flat
703 option add
*background
#b0b0b0
704 option add
*foreground
#000000
705 option add
*activeBackground
#d0d0d0
706 option add
*activeForeground
#000000
707 option add
*disabledForeground
""
708 option add
*selectBackground
#d0d0d0
709 option add
*selectForeground
#000000
710 #option add *selector #ffff80
711 option add
*selector
#bf0000
713 option add
*Scrollbar.Background
#b0b0b0
714 option add
*Scrollbar.Foreground
#d0d0d0
715 option add
*Interval.Background
#b0b0b0
716 option add
*Interval.Foreground
#000000
717 option add
*Interval.activeForeground
#d0d0d0
718 option add
*Interval.sliderForeground
#b0b0b0
719 option add
*Scale.activeForeground
#d0d0d0
720 option add
*Scale.sliderForeground
#b0b0b0
721 option add
*PieMenu.activeBackground
#b0b0b0
723 option add Mwm
*Micropolis.clientDecoration
-maximize
726 ########################################################################
728 ########################################################################
731 bind all
<Help
> {HandleHelp
%W
%x
%y
%X
%Y
}
732 bind all
<Shift-ButtonPress
> {HandleHelp
%W
%x
%y
%X
%Y
}
733 bind all
<Meta-ButtonPress
> {HandleHelp
%W
%x
%y
%X
%Y
}
734 bind all
<Shift-Meta-ButtonPress
> {HandleHelp
%W
%x
%y
%X
%Y
}
737 ########################################################################
739 ########################################################################
758 puts stderr
"$errorInfo"
766 proc NoFunction
{args
} {}
769 proc LinkWindow
{fromname to
} {
771 set WindowLinks
($fromname) $to
775 proc WindowLink
{fromname
} {
778 catch {set to
$WindowLinks($fromname)}
783 proc DeleteWindow
{sym name win
} {
784 set head
[WindowLink
$win.head
]
785 LinkWindow
$head.
$sym {}
787 set wins
[eval ident
"\$$name"]
788 set i
[lsearch $wins $win]
790 set $name [lreplace $wins $i $i]
796 proc Font
{win name
} {
797 global FontInfo FontCache HeadWindows
798 set scr
[winfo screen
$win]
801 set font $FontCache($scr,$name)
806 set label $FontCache($scr)
808 if {"$label" == ""} {
809 foreach head
$HeadWindows {
810 if {"[winfo screen $head]" == "$scr"} {
811 set label $head.fontlabel
812 label $label -text "X11 Sucks" -font fixed
813 set FontCache
($scr) $label
818 set fonts
[keylget FontInfo
$name]
819 foreach font $fonts {
820 #echo "Configuring font $font on $label"
821 if {[catch "$label config -font \"$font\""] == 0} {
834 set FontCache
($scr,$name) $font
840 proc Color
{win color mono
} {
841 if {[winfo screendepth
$win] == 1} {
849 ########################################################################
850 # Window Definition Functions
851 ########################################################################
854 proc MakeWindow.head
{{display
":0"}} {
856 source $ResourceDir/whead.tcl
861 proc MakeWindow.editor
{head
{display
":0"}} {
863 source $ResourceDir/weditor.tcl
868 proc MakeWindow.map
{head
{display
":0"}} {
870 source $ResourceDir/wmap.tcl
875 proc MakeWindow.graph
{head
{display
":0"}} {
877 source $ResourceDir/wgraph.tcl
882 proc MakeWindow.budget
{head
{display
":0"}} {
884 source $ResourceDir/wbudget.tcl
889 proc MakeWindow.evaluation
{head
{display
":0"}} {
891 source $ResourceDir/weval.tcl
896 proc MakeWindow.splash
{head
{display
":0"}} {
898 source $ResourceDir/wsplash.tcl
903 proc MakeWindow.scenario
{head
{display
":0"}} {
905 source $ResourceDir/wscen.tcl
910 proc MakeWindow.
file {head
{display
":0"}} {
912 source $ResourceDir/wfile.tcl
917 proc MakeWindow.ask
{head
{display
":0"}} {
919 source $ResourceDir/wask.tcl
924 proc MakeWindow.player
{head
{display
":0"}} {
926 source $ResourceDir/wplayer.tcl
931 proc MakeWindow.notice
{head
{display
":0"}} {
933 source $ResourceDir/wnotice.tcl
937 proc MakeWindow.help
{head
{display
":0"}} {
939 source $ResourceDir/whelp.tcl
943 proc MakeWindow.frob
{head
{display
":0"}} {
945 source $ResourceDir/wfrob.tcl
950 ########################################################################
952 ########################################################################
955 proc UIInitializeSound
{} {
959 proc UIShutDownSound
{} {
963 proc UIDoSoundOn
{win cmd
} {
964 global Sound SoundServers
966 set win
[WindowLink
[winfo toplevel $win].head
]
967 if {[lsearch $SoundServers $win] != -1} {
968 set cmd
"send -quick -server $win Sound sound $cmd"
970 # XXX: Lost a sound server...
978 proc UIDoSound
{cmd
} {
979 global Sound SoundServers
981 foreach win
$SoundServers {
982 set foo
"send -quick -server $win Sound $cmd"
984 # XXX: Lost a sound server...
992 proc KillSoundServers
{} {
994 foreach win
$SoundServers {
995 set foo
"send -quick -server $win Sound KillSoundServer"
1002 proc UISetChannelVolume
{win chan vol
} {
1003 UIDoSoundOn
$win "channel $chan -volume $vol"
1007 proc EchoPlaySound
{soundspec
} {
1011 proc UIMakeSoundOn
{win chan sound
{opts
""}} {
1012 playsound
$chan $sound $opts
1016 proc UIStartSoundOn
{win chan sound
{opts
""}} {
1017 # Send message to Python to play sound.
1018 EchoPlaySound
$sound
1020 #UIDoSoundOn $win "play $sound -replay -channel $chan -repeat 100 $opts"
1024 proc UIMakeSound
{chan sound
{opts
""}} {
1025 playsound
$chan $sound $opts
1029 proc UIStartSound
{chan sound
{opts
""}} {
1030 # Send message to Python to play sound.
1031 EchoPlaySound
$sound
1033 #UIDoSound "sound play $sound -channel $chan -repeat 100 $opts"
1037 proc SetupSoundServer
{win
} {
1042 proc AddSoundServer
{win
} {
1044 set i
[lsearch $SoundServers $win]
1046 set SoundServers
[linsert $SoundServers 0 $win]
1051 proc LostSoundServer
{win
} {
1052 DeleteSoundServer
$win
1053 # UIShowPictureOn [WindowLink $win.head] 46 [winfo screen $win]
1057 proc DeleteSoundServer
{win
} {
1059 set i
[lsearch $SoundServers $win]
1061 set SoundServers
[lreplace $SoundServers $i $i]
1066 proc UISoundOff
{} {
1070 proc MonsterSpeed
{} {
1071 return [expr "[sim Rand 40] + 70"]
1075 proc ExplosionPitch
{} {
1076 return [expr "[sim Rand 20] + 90"]
1081 return [expr "[sim Rand 20] + 90"]
1085 ########################################################################
1086 # Global Window Handlers
1089 proc WithdrawAll
{} {
1107 proc ShowInitial
{} {
1115 ########################################################################
1116 # Head Window Handlers
1119 proc PrepHead
{head
} {
1126 WithdrawHeadOf
$head
1130 after 1000 "WithdrawSplashOf $head"
1131 WithdrawHeadOf
$head
1132 ShowScenarioOf
$head
1136 WithdrawSplashOf
$head
1137 WithdrawScenarioOf
$head
1142 ReShowPictureOn
$head
1150 proc ShowHeadOf
{head
} {
1155 proc WithdrawHeadOf
{head
} {
1162 foreach win
$HeadWindows {
1168 proc WithdrawHeads
{} {
1170 foreach win
$HeadWindows {
1176 proc DeleteHeadWindow
{head
} {
1183 foreach win
$HeadWindows {
1189 proc InitHead
{win
} {
1190 set w
[WindowLink
$win.
text]
1191 $w configure
-state normal
1194 $w configure
-state disabled
1196 if {[sim MultiPlayerMode
]} {
1197 set w
[WindowLink
$win.
entry]
1208 proc InitAllHeadMenus
{} {
1211 foreach win
$HeadWindows {
1217 proc InitHeadMenus
{win
} {
1219 set m0
[WindowLink
$win.m0
]
1220 set m1
[WindowLink
$win.m1
]
1221 set m2
[WindowLink
$win.m2
]
1222 set m3
[WindowLink
$win.m3
]
1223 set m4
[WindowLink
$win.m4
]
1224 set b0
[WindowLink
$win.b0
]
1225 set b1
[WindowLink
$win.b1
]
1226 set b2
[WindowLink
$win.b2
]
1227 set b3
[WindowLink
$win.b3
]
1228 set b4
[WindowLink
$win.b4
]
1242 # When in multi player mode there is an extra menu
1243 # item to add another player, before the quit item,
1244 # so compensate for it here.
1245 if {[sim MultiPlayerMode
]} {
1250 $b0 config
-state normal
1251 $b2 config
-state disabled
1252 $b4 config
-state disabled
1257 # When in multi player mode there is an extra menu
1258 # item to add another player, before the quit item,
1259 # so compensate for it here.
1260 if {[sim MultiPlayerMode
]} {
1265 $b0 config
-state normal
1266 $b2 config
-state normal
1267 $b4 config
-state normal
1273 proc UIDisaster
{win cmd action
} {
1274 AskQuestion
[Color
$win #ff0000 #ffffff] "Cause a Disaster" \
1275 "Oh no! Do you really want to $action" \
1276 "{No way!} Disaster.No {WithdrawAsks}" \
1278 "{I guess so.} Disaster.Yes {WithdrawAsks ; $cmd}"
1282 proc CrushHead
{head
} {
1283 global SubWindows VoteNames
1285 foreach foo
$VoteNames {
1287 set votes
[eval ident
\$VotesFor$foo]
1288 set i
[lsearch $votes $head]
1290 set VotesFor
$foo [lreplace $votes $i $i]
1294 foreach foo
$SubWindows {
1295 set sym
[lindex $foo 0]
1296 set name
[lindex $foo 1]
1298 set wins
[eval ident
"\$$name"]
1300 if {[WindowLink
$win.head
] == $head} {
1301 DeleteWindow
$sym $name $win
1308 proc ChatDown
{win
} {
1330 global ChatConnection
1332 DoSendMessage
"Opening Connection to Chat Server $ChatServer socket $ChatSocket ..." status
1334 set ChatConnection
{}
1336 set ChatConnection
[connect
$ChatServer $ChatSocket]
1339 if {$ChatConnection == {}} then
{
1340 DoSendMessage
"Sorry, I could not open a connection to chat server $ChatServer socket $ChatSocket." status
1343 filehandler
$ChatConnection r
"ReceiveChat"
1354 puts $ChatConnection "USER $UserName $HostName $ServerName $RealName\r\n" nonewline
1355 puts $ChatConnection "NICK $NickName\r\n" nonewline
1356 puts $ChatConnection "JOIN $ChannelName\r\n" nonewline
1357 flush $ChatConnection
1362 proc ReceiveChat
{mode f
} {
1363 # DoSendMessage "ReceiveChat: MODE $mode F $f"
1367 if {[string first
{:} $msg]} {
1371 set from
[lindex $msg 0]
1372 set cmd
[string tolower
[lindex $msg 1]]
1376 if {($cmd == "privmsg") ||
1377 ($cmd == "notice")} then
{
1379 set chan
[lindex $msg 2]
1380 set i
[expr "[string length $from] + 1 + [string length $cmd] + 1 + [string length $chan] + 2"]
1381 set j
[expr "[string length $msg] - 2"]
1382 set line
[string range
$msg $i $j]
1383 set chan
[string range
$chan 1 [string length
$chan]]
1384 set from
[string range
$from 1 [expr "[string length $from] - 1"]]
1385 set from
[split $from {!}]
1386 set from
[lindex $from 0]
1387 DoSendMessage
"$from> $line"
1390 if {$handled == 0} {
1391 set msg
[string range
$msg \
1392 [expr "[string length $from] + 1"] \
1393 [expr "[string length $msg] - 2"]]
1399 proc SendChatMessage
{msg win
} {
1400 global ChatConnection ChannelName NickName
1406 if {[string range
$msg 0 0] == "/"} {
1407 set cmd
[string range
$msg 1 [string length
$msg]]
1408 DoSendMessage
"$NickName> \[$cmd\]"
1411 set cmd
"PRIVMSG $ChannelName :$msg\r\n"
1412 DoSendMessage
"$NickName> $msg"
1419 puts $ChatConnection $cmd nonewline
1420 flush $ChatConnection
1425 DoSendMessage
"IRC Broke the connection"
1435 global ChatConnection
1437 DoSendMessage
"Closing Connection to Chat Server." status
1440 puts $ChatConnection "QUIT\r\n" nonewline
1441 flush $ChatConnection
1442 $ChatConnection close
1445 set ChatConnection
{}
1450 proc DoEnterMessage
{win var
} {
1453 set msg
[eval ident
"\$\{$var\}"]
1455 if {$Chatting} then
{
1456 SendChatMessage
$msg $win
1464 proc DoEvalMessage
{win var
} {
1466 set command
[eval ident
"\$\{$var\}"]
1468 DoSendMessage
"Evaluating TCL: $command"
1469 catch {uplevel #0 $command} result
1470 DoSendMessage
"Result: $result"
1474 proc DoSendMessage
{msg
{tag
message}} {
1476 foreach win
$HeadWindows {
1477 appendWithTag
[WindowLink
$win.
text] $tag "$msg"
1482 proc UISetMessage
{msg
{tag status
}} {
1483 global DoMessages EditorWindows HeadWindows
1485 if {$DoMessages == 0} {
1489 foreach win
$EditorWindows {
1490 [WindowLink
$win.
message] configure
-text "$msg"
1493 foreach win
$HeadWindows {
1494 appendWithTag
[WindowLink
$win.
text] $tag "$msg"
1501 proc appendWithTag
{w tag
text} {
1505 set start
[$w index end
]
1506 $w configure
-state normal
1507 if {$start > $MaxLines} then
{
1508 $w delete
0.0 $ShrinkLines.0
1509 set start
[$w index end
]
1511 $w insert end
"${text}\n"
1512 $w tag add
$tag $start {end
- 1 char
}
1513 $w configure
-state disabled
1514 $w yview
-pickplace {end
- 1 char
}
1518 ########################################################################
1519 # Budget Window Handlers
1522 proc ShowBudgetOf
{head
} {
1523 set win
[WindowLink
$head.budget
]
1525 set win
[MakeWindow.budget
$head [winfo screen
$head]]
1534 proc ShowBudgets
{} {
1535 global HeadWindows BudgetsVisible
1536 set BudgetsVisible
1
1537 foreach win
$HeadWindows {
1543 proc WithdrawBudgets
{} {
1544 global BudgetWindows BudgetsVisible
1545 foreach win
$BudgetWindows {
1549 set BudgetsVisible
0
1553 proc BudgetContinue
{{win
""}} {
1554 global OldBudget BudgetRoadFund BudgetFireFund BudgetPoliceFund BudgetTaxRate
1556 if {([sim RoadFund
] != $BudgetRoadFund) ||
1557 ([sim FireFund
] != $BudgetFireFund) ||
1558 ([sim PoliceFund
] != $BudgetPoliceFund) ||
1559 ([sim TaxRate
] != $BudgetTaxRate)} {
1560 UISetMessage
"The budget was changed."
1562 UISetMessage
"The budget wasn't changed."
1570 proc BudgetReset
{{win
""}} {
1571 global OldBudget BudgetRoadFund BudgetFireFund BudgetPoliceFund BudgetTaxRate
1572 if {([sim RoadFund
] != $BudgetRoadFund) ||
1573 ([sim FireFund
] != $BudgetFireFund) ||
1574 ([sim PoliceFund
] != $BudgetPoliceFund) ||
1575 ([sim TaxRate
] != $BudgetTaxRate)} {
1576 UISetMessage
"The budget was reset."
1577 if {[sim Players
] > 1} {
1578 UIMakeSound edit Sorry
1581 UISetMessage
"The budget was reset."
1583 sim RoadFund
$BudgetRoadFund
1584 sim FireFund
$BudgetFireFund
1585 sim PoliceFund
$BudgetPoliceFund
1586 sim TaxRate
$BudgetTaxRate
1592 proc BudgetCancel
{{win
""}} {
1600 proc SetTaxRate
{rate
} {
1605 proc BudgetSetTaxRate
{rate
} {
1611 proc BudgetSetRoadFund
{percent
} {
1612 sim RoadFund
$percent
1617 proc BudgetSetFireFund
{percent
} {
1618 sim FireFund
$percent
1623 proc BudgetSetPoliceFund
{percent
} {
1624 sim PoliceFund
$percent
1629 proc UIShowBudgetAndWait
{} {
1630 global OldBudget BudgetRoadFund BudgetFireFund BudgetPoliceFund BudgetTaxRate
1631 if {$OldBudget == 0} {
1632 set BudgetRoadFund
[sim RoadFund
]
1633 set BudgetFireFund
[sim FireFund
]
1634 set BudgetPoliceFund
[sim PoliceFund
]
1635 set BudgetTaxRate
[sim TaxRate
]
1639 UISetMessage
"Pausing to set the budget ..."
1645 sim UpdateBudgetWindow
1649 proc ToggleBudgetTimer
{} {
1650 global BudgetTimerActive
1651 if {$BudgetTimerActive} {
1659 proc StopBudgetTimer
{} {
1660 global BudgetTimerActive
1661 set BudgetTimerActive
0
1666 proc StartBudgetTimer
{} {
1667 global BudgetTimerActive BudgetTimer BudgetTimeout
1669 set BudgetTimerActive
$me
1670 set BudgetTimer
$BudgetTimeout
1672 after 1000 TickBudgetTimer
$me
1676 proc RestartBudgetTimer
{} {
1677 global BudgetTimerActive
1678 if {$BudgetTimerActive} {
1685 proc UpdateBudgetTimer
{} {
1686 global BudgetWindows BudgetTimerActive BudgetTimer
1687 if {$BudgetTimerActive} {
1688 set text [format "Auto Cancel In %d Seconds (click to disable)" $BudgetTimer]
1690 set text [format "Enable Auto Cancel (currently disabled)"]
1692 foreach win
$BudgetWindows {
1693 set t
[WindowLink
$win.timer
]
1694 $t config
-text "$text"
1699 proc TickBudgetTimer
{me
} {
1700 global BudgetTimerActive BudgetTimer BudgetTimeout
1701 if {$BudgetTimerActive == $me} {
1703 if {$BudgetTimer < 0} {
1709 after 1000 TickBudgetTimer
$me
1715 proc FireBudgetTimer
{} {
1725 proc ToggleAutoBudget
{} {
1728 #echo "ToggleAutoBudget found on, clearing"
1731 #echo "ToggleAutoBudget found off, setting"
1737 proc UIUpdateBudget
{} {
1742 proc UpdateAutoBudget
{} {
1743 global BudgetWindows AutoBudget
1744 if {[sim AutoBudget
]} {
1745 set text "Disable Auto Budget (currently enabled)"
1747 set text "Enable Auto Budget (currently disabled)"
1749 #echo "UpdateAutoBudget $AutoBudget $text"
1750 foreach win
$BudgetWindows {
1751 set t
[WindowLink
$win.autobudget
]
1752 $t config
-text "$text"
1757 proc UISetBudget
{cashflow previous current collected taxrate
} {
1758 global BudgetWindows BudgetsVisible
1760 #echo "UISetBudgetValues $taxrate $BudgetsVisible"
1762 if {$BudgetsVisible} {
1764 foreach win
$BudgetWindows {
1765 set w
[WindowLink
$win.cashflow
]
1766 set old
[lindex [$w configure
-text] 4]
1767 if {$old != $cashflow} {
1768 $w configure
-text $cashflow
1770 set w
[WindowLink
$win.previous
]
1771 set old
[lindex [$w configure
-text] 4]
1772 if {$old != $previous} {
1773 $w configure
-text $previous
1775 set w
[WindowLink
$win.current
]
1776 set old
[lindex [$w configure
-text] 4]
1777 if {$old != $current} {
1778 $w configure
-text $current
1780 set w
[WindowLink
$win.collected
]
1781 set old
[lindex [$w configure
-text] 4]
1782 if {$old != $collected} {
1783 $w configure
-text $collected
1786 set w
[WindowLink
$win.taxrate
]
1788 if {$old != $taxrate} {
1792 set w
[WindowLink
$win.taxlabel
]
1793 set old
[lindex [$w configure
-text] 4]
1796 $w configure
-text $new
1802 foreach win
$HeadWindows {
1804 set w
[WindowLink
$win.taxrate
]
1806 if {$old != $taxrate} {
1807 # FIXME: this might not work if the slider is disabled in multi player mode.
1811 set w
[WindowLink
$win.taxlabel
]
1812 set old
[lindex [$w configure
-text] 4]
1813 set new
"Tax Rate: $taxrate%"
1815 $w configure
-text $new
1821 proc UISetBudgetValues
{roadgot roadwant roadpercent policegot policewant policepercent firegot firewant firepercent
} {
1822 global BudgetWindows BudgetsVisible
1824 if {$BudgetsVisible == 0} {
1828 foreach win
$BudgetWindows {
1829 set w
[WindowLink
$win.fire
].request
1830 set old
[lindex [$w configure
-text] 4]
1831 set new
"$firepercent% of $firewant = $firegot"
1833 $w configure
-text $new
1835 set w
[WindowLink
$win.fire
].fund
1837 if {$old != $firepercent} {
1841 set w
[WindowLink
$win.police
].request
1842 set old
[lindex [$w configure
-text] 4]
1843 set new
"$policepercent% of $policewant = $policegot"
1845 $w configure
-text $new
1847 set w
[WindowLink
$win.police
].fund
1849 if {$old != $policepercent} {
1850 $w set $policepercent
1853 set w
[WindowLink
$win.road
].request
1854 set old
[lindex [$w configure
-text] 4]
1855 set new
"$roadpercent% of $roadwant = $roadgot"
1857 $w configure
-text $new
1859 set w
[WindowLink
$win.road
].fund
1861 if {$old != $roadpercent} {
1868 proc ChangeBudget
{} {
1869 global VotesForBudget
1870 if {"$VotesForBudget" != ""} {
1877 proc InitVotesForBudget
{} {
1878 global VotesForBudget BudgetWindows
1879 set VotesForBudget
{}
1880 foreach win
$BudgetWindows {
1881 [WindowLink
$win.vote
] config
-relief raised
1883 UpdateVotesForBudget
1887 proc UpdateVotesForBudget
{} {
1888 global BudgetWindows
1889 UpdateVotesFor Budget
$BudgetWindows
1893 proc UpdateTaxRateSliders
{} {
1895 set players
[sim Players
]
1896 foreach win
$HeadWindows {
1897 set slider
[WindowLink
$win.taxrate
]
1898 #echo "UpdateTaxRateSliders players $players win $win slider $slider"
1899 if {$players == 1} {
1900 $slider configure
-state normal
1902 $slider configure
-state disabled
1908 ########################################################################
1909 # Evaluation Window Handlers
1912 proc ToggleEvaluationOf
{head
} {
1914 if {"$State" != "play"} {
1919 set win
[WindowLink
$head.evaluation
]
1921 set mapped
[winfo ismapped
$win]
1925 WithdrawEvaluationOf
$head
1927 ShowEvaluationOf
$head
1933 proc WithdrawEvaluationOf
{head
} {
1934 set win
[WindowLink
$head.evaluation
]
1941 proc ShowEvaluationOf
{head
} {
1942 set win
[WindowLink
$head.evaluation
]
1944 set win
[MakeWindow.evaluation
$head [winfo screen
$head]]
1948 set parent
[WindowLink
$win.parent
]
1949 #pack append [WindowLink $head.col2]\
1950 # $parent {top frame nw fill}
1951 pack append $parent\
1952 $win {top
frame nw fillx
}
1954 sim UpdateEvaluation
1958 proc WithdrawEvaluations
{} {
1959 global EvaluationWindows EvaluationsVisible
1960 foreach win
$EvaluationWindows {
1962 #set parent [WindowLink $win.parent]
1963 #pack unpack $parent
1966 set EvaluationsVisible
0
1970 proc EvaluationVisible
{w v
} {
1971 global EvaluationsVisible
1972 global [set var
$w.visible
]
1977 set EvaluationsVisible
[expr "$EvaluationsVisible + 1"]
1979 set EvaluationsVisible
[expr "$EvaluationsVisible - 1"]
1984 proc UISetEvaluation
{changed score ps0 ps1 ps2 ps3 pv0 pv1 pv2 pv3 pop delta assessed cityclass citylevel goodyes goodno title
} {
1985 global EvaluationWindows EvaluationsVisible CurrentDate
1987 set class
[string tolower
$cityclass]
1988 UISetMessage
"$CurrentDate: Score $score, $class population $pop."
1990 if {$EvaluationsVisible} {
1992 foreach win
$EvaluationWindows {
1994 global [set var
$win.visible
]
1995 set visible
[eval ident
"\$\{$var\}"]
1999 # TODO: set evaluation window and icon title
2000 #wm title $win "$title"
2001 #wm iconname $win "$title"
2003 set w
[WindowLink
$win.goodjob
]
2004 set old
[lindex [$w configure
-text] 4]
2005 set new
"$goodyes\n$goodno"
2007 $w configure
-text $new
2010 set w
[WindowLink
$win.problemnames
]
2011 set old
[lindex [$w configure
-text] 4]
2012 set new
"$ps0\n$ps1\n$ps2\n$ps3"
2014 $w configure
-text $new
2017 set w
[WindowLink
$win.problempercents
]
2018 set old
[lindex [$w configure
-text] 4]
2019 set new
"$pv0\n$pv1\n$pv2\n$pv3"
2021 $w configure
-text $new
2024 set w
[WindowLink
$win.stats
]
2025 set old
[lindex [$w configure
-text] 4]
2026 set new
"$pop\n$delta\n\n$assessed\n$cityclass\n$citylevel"
2028 $w configure
-text $new
2031 set w
[WindowLink
$win.score
]
2032 set old
[lindex [$w configure
-text] 4]
2033 set new
"$score\n$changed"
2035 $w configure
-text $new
2043 ########################################################################
2044 # File Window Handlers
2047 proc ShowFileOf
{head
} {
2048 set win
[WindowLink
$head.
file]
2050 set win
[MakeWindow.
file $head [winfo screen
$head]]
2060 foreach win
$HeadWindows {
2066 proc WithdrawFiles
{} {
2068 foreach win
$FileWindows {
2074 proc DoFileDialog
{win Message Path Pattern FileName ActionOk ActionCancel
} {
2075 ShowFileDialog
$win "$Path" "$Pattern"
2076 $win.message1 configure
-text "$Message"
2077 $win.path.path delete
0 end
2078 $win.path.path insert
0 $Path
2079 $win.
file.
file delete
0 end
2080 $win.
file.
file insert
0 "$FileName"
2081 $win.frame1.ok config
-command "
2082 $ActionOk \[$win.file.file get\] \[$win.path.path get\]
2084 $win.frame1.rescan config
-command "
2085 ShowFileDialog $win \[$win.path.path get\] $Pattern"
2086 $win.frame1.cancel config
-command "
2089 bind $win.files.files
"<Double-Button-1>" "\
2090 FileSelectDouble $win %W %y $Pattern \"
2091 $ActionOk {\[$win.file.file get\]} {\[$win.path.path get\]}\""
2092 bind $win.path.path
<Return
> "
2093 ShowFileDialog $win \[$win.path.path get\] $Pattern
2094 $win.file.file cursor 0
2095 focus $win.file.file"
2096 bind $win.
file.
file <Return
> "\
2097 $ActionOk \[$win.file.file get\] \[$win.path.path get\]
2102 proc BindSelectOne
{win Y
} {
2103 set Nearest
[$win nearest
$Y]
2104 if {$Nearest >= 0} {
2105 $win select from
$Nearest
2106 $win select to
$Nearest
2111 proc FileSelect
{win widget Y
} {
2112 BindSelectOne
$widget $Y
2113 set Nearest
[$widget nearest
$Y]
2114 if {$Nearest >= 0} {
2115 set Path
[$win.path.path get
]
2116 set TmpEntry
[$widget get
$Nearest]
2117 if {[string compare
"/" [string index
$TmpEntry \
2118 [expr [string length
$TmpEntry]-1]]] == 0 ||
\
2119 [string compare
"@" [string index
$TmpEntry \
2120 [expr [string length
$TmpEntry]-1]]] == 0} {
2121 # handle directories, and symbolic links to directories
2122 set FileName
[string range
$TmpEntry 0 \
2123 [expr [string length
$TmpEntry]-2]]
2124 # whoops / or @ is part of the name
2125 if {[MiscIsDir
$Path/$FileName] != 1} {
2126 set FileName
$TmpEntry
2129 if {[string compare
"*" [string index
$TmpEntry \
2130 [expr [string length
$TmpEntry]-1]]] == 0} {
2131 # handle executable filenames
2132 set FileName
[string range
$TmpEntry 0 \
2133 [expr [string length
$TmpEntry]-2]]
2134 # whoops * is part of the name
2135 if {[file executable
$Path/$FileName] != 1} {
2136 set FileName
$TmpEntry
2139 # a ordinary filename
2140 set FileName
$TmpEntry
2143 # enter the selected filename into the filename field
2144 if {[MiscIsDir
$Path/$FileName] != 1} {
2145 $win.
file.
file delete
0 end
2146 $win.
file.
file insert
0 $FileName
2152 proc FileSelectDouble
{win widget Y Pattern Action
} {
2153 BindSelectOne
$widget $Y
2154 set Nearest
[$widget nearest
$Y]
2155 if {$Nearest >= 0} {
2156 set Path
[$win.path.path get
]
2157 set TmpEntry
[$widget get
$Nearest]
2158 if {[string compare
$TmpEntry "../"] == 0} {
2159 # go up one directory
2161 [string trimright
[string trimright
[string trim
$Path] /] @]
2162 if {[string length
$TmpEntry] <= 0} {
2165 set Path
[file dirname
$TmpEntry]
2166 $win.path.path delete
0 end
2167 $win.path.path insert
0 $Path
2168 ShowFileDialog
$win $Path $Pattern
2170 if {[string compare
"/" [string index
$TmpEntry \
2171 [expr [string length
$TmpEntry]-1]]] == 0 ||
\
2172 [string compare
"@" [string index
$TmpEntry \
2173 [expr [string length
$TmpEntry]-1]]] == 0} {
2174 # handle directorys, and symbolic links to directorys
2175 set FileName
[string range
$TmpEntry 0 \
2176 [expr [string length
$TmpEntry]-2]]
2177 # whoops / or @ is part of the name
2178 if {[MiscIsDir
$Path/$FileName] != 1} {
2179 set FileName
$TmpEntry
2182 if {[string compare
"*" [string index
$TmpEntry \
2183 [expr [string length
$TmpEntry]-1]]] == 0} {
2184 # handle executable filenames
2185 set FileName
[string range
$TmpEntry 0 \
2186 [expr [string length
$TmpEntry]-2]]
2187 # whoops * is part of the name
2188 if {[file executable
$Path/$FileName] != 1} {
2189 set FileName
$TmpEntry
2192 # a ordinary filename
2193 set FileName
$TmpEntry
2197 if {[MiscIsDir
$Path/$FileName] == 1} {
2198 if {[string compare
"/" [string index
$Path \
2199 [expr [string length
$Path]-1]]] == 0} {
2200 append Path
$FileName
2202 append Path
/ $FileName
2204 $win.path.path delete
0 end
2205 $win.path.path insert
0 $Path
2206 ShowFileDialog
$win $Path $Pattern
2208 # enter the selected filename into the filename field
2209 $win.
file.
file delete
0 end
2210 $win.
file.
file insert
0 "$FileName"
2211 if {[string length
$Action] > 0} {
2221 proc NameComplete
{win Type
} {
2226 if {[string compare
$Type path
] == 0} {
2227 set DirName
[file dirname
[$win.path.path get
]]
2228 set FileName
[file tail
[$win.path.path get
]]
2230 set DirName
[file dirname
[$win.path.path get
]/]
2231 set FileName
[file tail
[$win.
file.
file get
]]
2235 if {[MiscIsDir
$DirName] == 1} {
2236 catch "exec ls $DirName/" Result
2238 set ListLength
[llength $Result]
2240 while {$Counter < $ListLength} {
2241 if {[string length
$FileName] == 0} {
2242 if {$FoundCounter == 0} {
2243 set NewFile
[lindex $Result $Counter]
2246 set TmpFile1
$NewFile
2247 set TmpFile2
[lindex $Result $Counter]
2248 set Length1
[string length
$TmpFile1]
2249 set Length2
[string length
$TmpFile2]
2251 if {$Length1 > $Length2} {
2252 set Length1
$Length2
2254 while {$Counter1 < $Length1} {
2255 if {[string compare
[string index
$TmpFile1 $Counter1] \
2256 [string index
$TmpFile2 $Counter1]] == 0} {
2257 append NewFile
[string index
$TmpFile1 $Counter1]
2266 if {[regexp "^$FileName" [lindex $Result $Counter] \
2268 if {$FoundCounter == 0} {
2269 set NewFile
[lindex $Result $Counter]
2272 set TmpFile1
$NewFile
2273 set TmpFile2
[lindex $Result $Counter]
2274 set Length1
[string length
$TmpFile1]
2275 set Length2
[string length
$TmpFile2]
2277 if {$Length1 > $Length2} {
2278 set Length1
$Length2
2280 while {$Counter1 < $Length1} {
2281 if {[string compare
[string index
$TmpFile1 $Counter1] \
2282 [string index
$TmpFile2 $Counter1]] == 0} {
2283 append NewFile
[string index
$TmpFile1 $Counter1]
2297 if {$FoundCounter == 1} {
2298 if {[MiscIsDir
$DirName/$NewFile] == 1} {
2299 if {[string compare
$DirName "/"] == 0} {
2300 $win.path.path delete
0 end
2301 $win.path.path insert
0 "/[string trim [string trim $NewFile /] @]/"
2303 $win.path.path delete
0 end
2304 $win.path.path insert
0 "[string trimright $DirName /]/[string trim [string trim $NewFile /] @]/"
2307 $win.path.path delete
0 end
2308 $win.path.path insert
0 \
2309 "[string trim [string trimright $DirName /] @]/"
2310 $win.
file.
file delete
0 end
2311 $win.
file.
file insert
0 "$NewFile"
2314 if {[MiscIsDir
$DirName/$NewFile] == 1 ||
2315 [string compare
$Type path
] == 0} {
2316 $win.path.path delete
0 end
2317 $win.path.path insert
0 \
2318 "[string trimright $DirName /]/[string trim [string trim $NewFile /] @]"
2320 $win.path.path delete
0 end
2321 $win.path.path insert
0 "$DirName"
2322 if {[string length
$NewFile] > 0} {
2323 $win.
file.
file delete
0 end
2324 $win.
file.
file insert
0 "$NewFile"
2331 proc ShowFileDialog
{win Path Pattern
} {
2333 #set Path [lindex [split $Path] 0]
2334 if {[$win.files.files size
] > 0} {
2335 $win.files.files delete
0 end
2338 if {[catch "exec ls -F \"$Path\"" Result
]} {
2341 if {[string match
$Result "* not found"]} {
2344 set ElementList
[lsort [split $Result "\n"]]
2347 if {[string compare
$Path "/"]} {
2348 $win.files.files insert end
"../"
2352 foreach Counter
$ElementList {
2354 if {[string match
$Pattern $Counter] == 1} {
2355 if {[string compare
$Counter "../"] &&
2356 [string compare
$Counter "./"]} {
2357 $win.files.files insert end
$Counter
2360 set fn
$Path/[string trim
[string trim
[string trim
$Counter /] @] *]
2361 if {[MiscIsDir
$fn]} {
2362 $win.files.files insert end
$Counter
2370 proc MiscIsDir
{PathName
} {
2372 if {[file isdirectory
$PathName] == 1} {
2375 catch "file type $PathName" Type
2376 if {[string compare
$Type link
] == 0} {
2377 set LinkName
[file readlink
$PathName]
2378 catch "file type $LinkName" Type
2379 while {[string compare
$Type link
] == 0} {
2380 set LinkName
[file readlink
$LinkName]
2382 return [file isdirectory
$LinkName]
2389 proc busy
{win cmds
} {
2391 set list [winfo children
$win]
2393 while {$list != ""} {
2396 set class
[winfo class
$w]
2397 set cursor
[lindex [$w config
-cursor] 4]
2398 if {[winfo toplevel $w] == $w} {
2399 lappend busy
[list $w $cursor]
2401 set next
[concat $next [winfo children
$w]]
2407 catch {[lindex $w 0] config
-cursor watch
}
2412 set error [catch {uplevel eval [list $cmds]} result
]
2415 catch {[lindex $w 0] config
-cursor [lindex $w 1]}
2426 ########################################################################
2427 # Editor Window Handlers
2429 proc ShowEditorOf
{head
} {
2430 global EditorWindows
2432 foreach win
$EditorWindows {
2433 if {[WindowLink
$win.head
] == $head} {
2434 set parent
[WindowLink
$win.parent
]
2435 #pack append [WindowLink $head.col2]\
2436 # $parent {top frame nw expand fill}
2437 pack append $parent\
2438 $win {top
frame nw expand fill
}
2452 proc NewEditorOf
{head
} {
2453 set win
[MakeWindow.editor
$head [winfo screen
$head]]
2455 set parent
[WindowLink
$win.parent
]
2456 pack append $parent\
2457 $win {top
frame nw expand fill
}
2464 proc ShowEditors
{} {
2466 foreach win
$HeadWindows {
2472 proc WithdrawEditors
{} {
2473 global EditorWindows
2474 foreach win
$EditorWindows {
2475 #set parent [WindowLink $win.parent]
2476 #pack unpack $parent
2482 proc InitEditors
{} {
2483 global EditorWindows
2484 foreach win
$EditorWindows {
2490 proc InitEditor
{win
} {
2491 set e
[WindowLink
$win.view
]
2492 UISetToolState
$win 7
2497 global $e.TrackState
2498 set $e.TrackState
{}
2502 proc SetEditorAutoGoto
{win val
} {
2503 global AutoGoto.
$win
2504 set AutoGoto.
$win $val
2505 set e
[WindowLink
$win.view
]
2510 proc SetEditorControls
{win val
} {
2511 global Controls.
$win
2512 set Controls.
$win $val
2514 pack append $win $win.leftframe
{left
frame center filly
}
2516 pack unpack
$win.leftframe
2521 proc SetEditorOverlay
{win val
} {
2523 set Overlay.
$win $val
2524 set e
[WindowLink
$win.view
]
2529 proc SetEditorDynamicFilter
{win val
} {
2530 global DynamicFilter.
$win
2531 set DynamicFilter.
$win $val
2532 set e
[WindowLink
$win.view
]
2533 $e DynamicFilter
$val
2534 if {$val == 1} then
{
2535 ShowFrobOf
[WindowLink
$win.head
]
2540 proc SetEditorSkip
{win val
} {
2541 set e
[WindowLink
$win.view
]
2546 proc EditorToolDown
{mod w x y
} {
2547 global [set var
$w.TrackState
]
2551 case
[$w ToolState
] in
\
2553 UIMakeSoundOn
$w edit Rumble
"-repeat 4"
2561 set $var [list constrain_start
$x $y]
2562 $w ToolConstrain
$x $y
2567 EditorTool ToolDown
$w $x $y
2572 proc EditorToolDrag
{w x y
} {
2573 EditorTool ToolDrag
$w $x $y
2578 proc EditorToolUp
{w x y
} {
2579 global [set var
$w.TrackState
]
2582 case
[$w ToolState
] in
\
2590 EditorTool ToolUp
$w $x $y
2592 $w ToolConstrain
-1 -1
2599 proc EditorTool
{action w x y
} {
2600 global [set var
$w.TrackState
]
2601 set state
[eval ident
"\$\{$var\}"]
2602 case
[lindex $state 0] in
\
2604 set x0
[lindex $state 1]
2605 set y0
[lindex $state 2]
2606 set dx
[expr "$x - $x0"]
2607 set dy
[expr "$y - $y0"]
2608 if [expr "($dx > 16) || ($dx < -16)"] then
{
2609 $w ToolConstrain
-1 $y0
2612 if [expr "($dy > 16) || ($dy < -16)"] then
{
2613 $w ToolConstrain
$x0 -1
2622 proc StartChalk
{w
} {
2623 sim CollapseMotion
0
2627 proc StopChalk
{w
} {
2628 sim CollapseMotion
1
2632 proc EditorPanDown
{mod w x y
} {
2633 global [set var
$w.TrackState
]
2637 set $var [list constrain_start
$x $y]
2638 $w ToolConstrain
$x $y
2643 EditorTool PanStart
$w $x $y
2647 proc EditorPanDrag
{w x y
} {
2648 EditorTool PanTo
$w $x $y
2652 proc EditorPanUp
{w x y
} {
2655 EditorTool PanTo
$w $x $y
2656 $w ToolConstrain
-1 -1
2662 proc EditorKeyDown
{w k
} {
2667 proc EditorKeyUp
{w k
} {
2672 proc BindEditorButtons
{win
} {
2673 set w
[WindowLink
$win.top
]
2675 bind $win <1> "CancelPie $win ; EditorToolDown none %W %x %y"
2676 bind $win <B1-Motion
> {EditorToolDrag
%W
%x
%y
}
2677 bind $win <ButtonRelease-1
> {EditorToolUp
%W
%x
%y
}
2679 bind $win <Control-1
> "CancelPie $win ; EditorToolDown constrain %W %x %y"
2680 bind $win <Control-B1-Motion
> {EditorToolDrag
%W
%x
%y
}
2681 bind $win <Control-ButtonRelease-1
> {EditorToolUp
%W
%x
%y
}
2683 bind $win <2> "CancelPie $win ; EditorPanDown none %W %x %y"
2684 bind $win <B2-Motion
> {EditorPanDrag
%W
%x
%y
}
2685 bind $win <ButtonRelease-2
> {EditorPanUp
%W
%x
%y
}
2687 bind $win <Control-2
> "CancelPie $win ; EditorPanDown constrain %W %x %y"
2688 bind $win <Control-B2-Motion
> {EditorPanDrag
%W
%x
%y
}
2689 bind $win <Control-ButtonRelease-2
> {EditorPanUp
%W
%x
%y
}
2691 InitPie
$win $w.toolpie
2695 proc UISetFunds
{funds
} {
2697 foreach win
$HeadWindows {
2698 [WindowLink
$win.funds
] configure
-text "$funds"
2703 proc UISetDate
{date month year
} {
2707 set CurrentDate
"$date"
2709 foreach win
$HeadWindows {
2710 [WindowLink
$win.date
] Set
$month $year
2715 proc SetPriority
{index
} {
2741 proc UISetDemand
{r c i
} {
2742 global HeadWindows DemandRes DemandCom DemandInd
2748 if {$r <= 0} then
{set ry0
32} else {set ry0
24}
2749 set ry1
[expr "$ry0 - $r"]
2750 if {$c <= 0} then
{set cy0
32} else {set cy0
24}
2751 set cy1
[expr "$cy0 - $c"]
2752 if {$i <= 0} then
{set iy0
32} else {set iy0
24}
2753 set iy1
[expr "$iy0 - $i"]
2755 foreach win
$HeadWindows {
2756 set can
[WindowLink
$win.demand
]
2757 # $can coords r 8 $ry0 14 $ry1
2758 # $can coords c 17 $cy0 23 $cy1
2759 # $can coords i 26 $iy0 32 $iy1
2760 $can coords r
49 $ry0 55 $ry1
2761 $can coords c
58 $cy0 64 $cy1
2762 $can coords i
67 $iy0 73 $iy1
2767 proc UISetOptions
{autobudget autogoto autobulldoze disasters sound animation messages notices
} {
2768 global AutoBudget AutoGoto AutoBulldoze Disasters Sound
2769 set AutoBudget
$autobudget
2770 set AutoGoto
$autogoto
2771 set AutoBulldoze
$autobulldoze
2772 set Disasters
$disasters
2774 set DoAnimation
$animation
2775 set DoMessages
$messages
2776 set DoNotices
$notices
2780 proc UIDidToolRes
{win x y
} {
2781 UIMakeSoundOn
$win edit O
"-speed 140"
2785 proc UIDidToolCom
{win x y
} {
2786 UIMakeSoundOn
$win edit A
"-speed 140"
2790 proc UIDidToolInd
{win x y
} {
2791 UIMakeSoundOn
$win edit E
"-speed 140"
2795 proc UIDidToolFire
{win x y
} {
2796 UIMakeSoundOn
$win edit O
"-speed 130"
2800 proc UIDidToolQry
{win x y
} {
2801 UIMakeSoundOn
$win edit E
"-speed 200"
2805 proc UIDidToolPol
{win x y
} {
2806 UIMakeSoundOn
$win edit E
"-speed 130"
2810 proc UIDidToolWire
{win x y
} {
2811 UIMakeSoundOn
$win edit O
"-speed 120"
2815 proc UIDidToolDozr
{win x y
} {
2816 UIMakeSoundOn
$win edit Rumble
2820 proc UIDidToolRail
{win x y
} {
2821 UIMakeSoundOn
$win edit O
"-speed 100"
2825 proc UIDidToolRoad
{win x y
} {
2826 UIMakeSoundOn
$win edit E
"-speed 100"
2830 proc UIDidToolChlk
{win x y
} {
2834 proc UIDidToolEraser
{win x y
} {
2838 proc UIDidToolStad
{win x y
} {
2839 UIMakeSoundOn
$win edit O
"-speed 90"
2843 proc UIDidToolPark
{win x y
} {
2844 UIMakeSoundOn
$win edit A
"-speed 130"
2848 proc UIDidToolSeap
{win x y
} {
2849 UIMakeSoundOn
$win edit E
"-speed 90"
2853 proc UIDidToolCoal
{win x y
} {
2854 UIMakeSoundOn
$win edit O
"-speed 75"
2858 proc UIDidToolNuc
{win x y
} {
2859 UIMakeSoundOn
$win edit E
"-speed 75"
2863 proc UIDidToolAirp
{win x y
} {
2864 UIMakeSoundOn
$win edit A
"-speed 50"
2868 proc UISetToolState
{w state
} {
2869 global EditorPallets EditorPalletImages ToolInfo
2870 set win
[WindowLink
$w.top
]
2871 #echo "UISETTOOLSTATE w $w win $win $state"
2872 ExclusivePallet
$state $win $EditorPallets ic
$EditorPalletImages \
2873 raised sunken
{NoFunction
}
2875 set c1
[WindowLink
$w.cost1
]
2877 set info [lindex $ToolInfo $state]
2878 set cost1
[lindex $info 1]
2879 set cost2
[lindex $info 2]
2880 $c1 configure
-text "$cost1"
2881 [WindowLink
$w.cost2
] configure
-text "$cost2"
2886 proc UIShowZoneStatus
{zone density value crime pollution growth x y
} {
2887 global QueryX QueryY
2888 set QueryX
[expr "8 + 16 * $x"]
2889 set QueryY
[expr "8 + 16 * $y"]
2890 UIShowPicture
9 [list $zone $density $value $crime $pollution $growth]
2894 ########################################################################
2895 # Map Window Handlers
2898 proc ShowMapOf
{head
} {
2901 foreach win
$MapWindows {
2902 if {"[WindowLink $win.head]" == "$head"} {
2903 global MapPanelWidth MapPanelHeight
2904 #place configure $win -x 0 -y 0 -width $MapPanelWidth -height $MapPanelHeight
2905 #[WindowLink $win.parent] configure -width $MapPanelWidth -height $MapPanelHeight
2906 set parent
[WindowLink
$win.parent
]
2907 pack append [WindowLink
$head.w2
] \
2908 $win {top
frame nw expand fill
}
2921 proc NewMapOf
{head
} {
2922 set win
[MakeWindow.map
$head [winfo screen
$head]]
2923 global MapPanelWidth MapPanelHeight
2924 #place configure $win -x 0 -y 0 -width $MapPanelWidth -height $MapPanelHeight
2925 #[WindowLink $win.parent] configure -width $MapPanelWidth -height $MapPanelHeight
2926 set parent
[WindowLink
$win.parent
]
2927 #pack append [WindowLink $head.col1]\
2928 # $parent {top frame nw fillx}
2929 pack append [WindowLink
$head.w2
] \
2930 $win {top
frame nw expand fill
}
2937 foreach win
$HeadWindows {
2943 proc WithdrawMaps
{} {
2945 foreach win
$MapWindows {
2954 foreach win
$MapWindows {
2960 proc InitMap
{win
} {
2965 proc EnableMaps
{} {
2967 foreach win
$MapWindows {
2973 proc EnableMap
{win
} {
2974 [WindowLink
$win.view
] ShowEditors
1
2975 [WindowLink
$win.zones
] config
-state normal
2976 [WindowLink
$win.overlays
] config
-state normal
2980 proc DisableMaps
{} {
2982 foreach win
$MapWindows {
2988 proc DisableMap
{win
} {
2989 [WindowLink
$win.view
] ShowEditors
0
2990 [WindowLink
$win.zones
] config
-state disabled
2991 [WindowLink
$win.overlays
] config
-state disabled
2995 proc SetMapState
{win state
} {
2996 set m
[WindowLink
$win.view
]
2998 if {$state == 14} then
{
2999 ShowFrobOf
[WindowLink
$win.head
]
3004 proc MapPanDown
{w x y
} {
3009 proc MapPanDrag
{w x y
} {
3014 proc MapPanUp
{w x y
} {
3021 proc UISetMapState
{w state
} {
3023 #set win [winfo toplevel $w]
3024 set win
[WindowLink
$w.win
]
3025 set m
[WindowLink
$win.view
]
3026 set title
[lindex $MapTitles $state]
3028 # TODO: set map text field header to title
3029 #wm title $win "$title"
3030 #wm iconname $win "$title"
3032 global [set var MapState.
$win]
3036 {6 8 9 10 11 12 13} {
3037 [WindowLink
$win.legend
] config
-bitmap "@images/legendmm.xpm"
3040 [WindowLink
$win.legend
] config
-bitmap "@images/legendpm.xpm"
3043 [WindowLink
$win.legend
] config
-bitmap "@images/legendn.xpm"
3049 ########################################################################
3050 # Graph Window Handlers
3053 proc ToggleGraphOf
{head
} {
3055 if {"$State" != "play"} {
3060 set win
[WindowLink
$head.graph
]
3062 set mapped
[winfo ismapped
$win]
3066 WithdrawGraphOf
$head
3074 proc WithdrawGraphOf
{head
} {
3075 set win
[WindowLink
$head.graph
]
3082 proc ShowGraphOf
{head
} {
3083 set win
[WindowLink
$head.graph
]
3085 set win
[MakeWindow.graph
$head [winfo screen
$head]]
3089 set parent
[WindowLink
$win.parent
]
3090 pack append $parent\
3091 $win {top
frame nw fillx
}
3097 proc WithdrawGraphs
{} {
3099 foreach win
$GraphWindows {
3106 proc InitGraphs
{} {
3108 foreach win
$GraphWindows {
3114 proc InitGraph
{win
} {
3115 UISetGraphState
$win 1 1 1 1 1 1 0
3119 proc UISetGraphState
{win t0 t1 t2 t3 t4 t5 range
} {
3120 set g
[WindowLink
$win.graphview
]
3121 GraphPalletMask
$win [expr "$t0 + ($t1<<1) + ($t2<<2) + ($t3<<3) + ($t4<<4) + ($t5<<5)"]
3122 GraphYearPallet
$win $range
3126 ########################################################################
3127 # Splash Window Handlers
3130 proc ShowSplashOf
{head
} {
3131 set win
[WindowLink
$head.splash
]
3133 set win
[MakeWindow.splash
$head [winfo screen
$head]]
3135 set splashscreen
[WindowLink
$win.splashscreen
]
3137 catch {$splashscreen config
-bitmap "@images/splashscreen.xpm"; set success 1}
3140 global SplashScreenDelay
3141 after $SplashScreenDelay "UIPickScenarioMode"
3148 proc WithdrawSplashOf
{head
} {
3149 set win
[WindowLink
$head.splash
]
3156 proc ShowSplashes
{} {
3158 foreach win
$HeadWindows {
3164 proc WithdrawSplashes
{} {
3165 global SplashWindows
3166 foreach win
$SplashWindows {
3168 set splashscreen
[WindowLink
$win.splashscreen
]
3169 $splashscreen config
-bitmap ""
3174 proc InitSplashes
{} {
3178 proc InitSplash
{win
} {
3182 proc DeleteSplashWindow
{win
} {
3187 ########################################################################
3188 # Scenario Window Handlers
3191 proc ShowScenarioOf
{head
} {
3192 set win
[WindowLink
$head.scenario
]
3194 set win
[MakeWindow.scenario
$head [winfo screen
$head]]
3196 # TODO: load background bitmap
3201 proc WithdrawScenarioOf
{head
} {
3202 set win
[WindowLink
$head.scenario
]
3209 proc ShowScenarios
{} {
3211 foreach win
$HeadWindows {
3217 proc WithdrawScenarios
{} {
3218 global ScenarioWindows
3219 foreach win
$ScenarioWindows {
3221 # TODO: flush background bitmap
3226 proc InitScenarios
{} {
3227 global MapHistory MapHistoryNum
3228 if {$MapHistoryNum < 1} {
3233 if {$MapHistoryNum == ([llength $MapHistory] - 1)} {
3238 global ScenarioWindows
3239 foreach win
$ScenarioWindows {
3241 #[WindowLink $win.previous] config -state $prev
3242 #[WindowLink $win.next] config -state $next
3247 proc InitScenario
{win
} {
3248 global MapHistory MapHistoryNum
3249 if {$MapHistoryNum < 1} {
3255 if {$MapHistoryNum == ([llength $MapHistory] - 1)} {
3262 #[WindowLink $win.previous] config -state $prev
3263 #[WindowLink $win.next] config -state $next
3265 LinkWindow
$win.scenarioTarget
-1
3266 LinkWindow
$win.scenarioTargetDown
-1
3268 global ScenarioButtons
3270 set len
[llength $ScenarioButtons]
3272 set data
[lindex $ScenarioButtons $i]
3273 set type
[lindex $data 0]
3274 set id
[lindex $data 1]
3278 LinkWindow
$win.
$id.over
0
3279 LinkWindow
$win.
$id.enabled
1
3280 LinkWindow
$win.
$id.checked
0
3281 #echo "SETTING WIN $win ID $id"
3283 set i
[expr "$i + 1"]
3286 UpdateLevelSelection
$win
3287 UpdateLeftRightEnabled
$win
3291 proc UpdateLevelSelection
{win
} {
3292 #echo UpdateLevelSelection
3294 if {$GameLevel == 0} then
{
3295 LinkWindow
$win.easy.checked
1
3296 LinkWindow
$win.medium.checked
0
3297 LinkWindow
$win.hard.checked
0
3299 if {$GameLevel == 1} then
{
3300 LinkWindow
$win.easy.checked
0
3301 LinkWindow
$win.medium.checked
1
3302 LinkWindow
$win.hard.checked
0
3304 if {$GameLevel == 2} then
{
3305 LinkWindow
$win.easy.checked
0
3306 LinkWindow
$win.medium.checked
0
3307 LinkWindow
$win.hard.checked
1
3310 UpdateScenarioButtonID
$win easy
3311 UpdateScenarioButtonID
$win medium
3312 UpdateScenarioButtonID
$win hard
3317 proc UpdateLeftRightEnabled
{win
} {
3318 #echo UpdateLeftRightEnabled
3320 global MapHistory MapHistoryNum
3321 if {$MapHistoryNum < 1} {
3322 LinkWindow
$win.left.enabled
0
3324 LinkWindow
$win.left.enabled
1
3327 if {$MapHistoryNum == ([llength $MapHistory] - 1)} {
3328 LinkWindow
$win.right.enabled
0
3330 LinkWindow
$win.right.enabled
1
3333 UpdateScenarioButtonID
$win left
3334 UpdateScenarioButtonID
$win right
3338 proc UpdateScenarioButtonID
{win id
} {
3340 global ScenarioButtons
3342 set len
[llength $ScenarioButtons]
3344 set data
[lindex $ScenarioButtons $i]
3346 if {$id == [lindex $data 1]} then
{
3347 UpdateScenarioButton
$win $data
3351 set i
[expr "$i + 1"]
3356 proc UpdateScenarioButton
{win data
} {
3359 set type
[lindex $data 0]
3360 set id
[lindex $data 1]
3361 set over
[WindowLink
$win.
$id.over
]
3362 set enabled
[WindowLink
$win.
$id.enabled
]
3363 set checked
[WindowLink
$win.
$id.checked
]
3364 #echo "WIN $win TYPE $type ID $id OVER $over ENABLED $enabled CHECKED $checked"
3366 if {[lindex ${data
} 2] == "DoPickScenario"} {
3367 global ScenarioDescX ScenarioDescY ScenarioDescWidth ScenarioDescHeight ScenarioDescFont
3368 catch {text $win.desc
\
3373 -font [Font
$win $ScenarioDescFont]}
3375 $win.desc configure
-state normal
3376 $win.desc delete
0.0 end
3377 $win.desc insert end
"[lindex $Messages([lindex ${data} 3]) 1]\n\n[lindex $Messages([lindex ${data} 3]) 2]"
3378 $win.desc configure
-state disabled
3380 place $win.desc
-x $ScenarioDescX -y $ScenarioDescY -width $ScenarioDescWidth -height $ScenarioDescHeight
3382 if {[lindex ${data
} 2] == "DoMap"} {
3383 global ScenarioMapFloatX ScenarioMapFloatY
3384 if { $ScenarioMapFloatX != "-1" } {
3385 place $win.
canvas.view
-x $ScenarioMapFloatX -y $ScenarioMapFloatY
3389 catch {destroy $win.desc
}
3390 global ScenarioMapFloatX
3391 if { $ScenarioMapFloatX != "-1" } {
3392 catch {place forget
$win.
canvas.view
}
3398 set bm
[lindex $data 13]
3400 set bm
[lindex $data 12]
3404 set bm
[lindex $data 10]
3406 set bm
[lindex $data 9]
3410 set bm
[lindex $data 11]
3413 [WindowLink
$win.
canvas] itemconfig
$id -bitmap $bm
3417 proc DoEnterCityName
{win
} {
3421 proc InitVotesForUseThisMap
{} {
3422 # TODO: Disabled for new scenario window.
3425 global VotesForUseThisMap ScenarioWindows
3426 set VotesForUseThisMap
{}
3427 foreach win
$ScenarioWindows {
3428 [WindowLink
$win.vote
] config
-relief raised
3430 UpdateVotesForUseThisMap
3434 proc UpdateVotesForUseThisMap
{} {
3435 global ScenarioWindows
3436 UpdateVotesFor UseThisMap
$ScenarioWindows
3440 proc UIUseThisMap
{} {
3441 global CityName GameLevel Scenario
3443 # special handling for scenarios?
3444 if {$GameLevel != -1} {
3445 sim GameLevel
$GameLevel
3447 sim CityName
$CityName
3450 if {$Scenario != -1} {
3451 UIShowPicture
$Scenario
3456 proc HandleScenarioDown
{win x y
} {
3457 #echo HandleScenarioDown $win $x $y
3458 HandleScenarioMove
$win $x $y
3459 set w
[WindowLink
$win.w
]
3460 set target
[WindowLink
$w.scenarioTarget
]
3461 LinkWindow
$w.scenarioTargetDown
$target
3465 proc HandleScenarioUp
{win x y
} {
3466 #echo HandleScenarioUp $win $x $y
3467 HandleScenarioMove
$win $x $y
3468 global ScenarioButtons
3469 set w
[WindowLink
$win.w
]
3470 set target
[WindowLink
$w.scenarioTarget
]
3471 set targetDown
[WindowLink
$w.scenarioTargetDown
]
3472 if {($target != -1) &&
3473 ($target == $targetDown)} {
3474 set data
[lindex $ScenarioButtons $target]
3475 set type
[lindex $data 0]
3476 set id
[lindex $data 1]
3477 set callback
[lindex $data 2]
3478 set param
[lindex $data 3]
3479 set var
[lindex $data 4]
3480 set xx
[lindex $data 5]
3481 set yy
[lindex $data 6]
3482 set ww
[lindex $data 7]
3483 set hh
[lindex $data 8]
3484 set normal
[lindex $data 9]
3485 set over
[lindex $data 10]
3486 set disabled
[lindex $data 11]
3487 if {$type == "button"} {
3488 #echo callback $callback w $w param $param
3489 eval "$callback $w {$param}"
3491 if {$type == "checkbox"} {
3492 #echo checkbox callback $callback w $w param $param
3493 eval "$callback $w {$param}"
3500 proc HandleScenarioMove
{win x y
} {
3501 #echo HandleScenarioMove $win $x $y
3502 global ScenarioButtons
3503 set w
[WindowLink
$win.w
]
3504 set target
[WindowLink
$w.scenarioTarget
]
3507 set len
[llength $ScenarioButtons]
3509 set data
[lindex $ScenarioButtons $i]
3510 set type
[lindex $data 0]
3511 set id
[lindex $data 1]
3512 set callback
[lindex $data 2]
3513 set param
[lindex $data 3]
3514 set var
[lindex $data 4]
3515 set xx
[lindex $data 5]
3516 set yy
[lindex $data 6]
3517 set ww
[lindex $data 7]
3518 set hh
[lindex $data 8]
3520 set enabled
[WindowLink
$w.
$id.enabled
]
3521 set checked
[WindowLink
$w.
$id.checked
]
3523 #echo "ID $id ENABLED $enabled CHECKED $checked w $w id $id"
3525 if {($enabled != 0) &&
3527 ($x < ($xx + $ww)) &
3529 ($y < ($yy + $hh))} {
3534 set i
[expr "$i + 1"]
3537 if {$found != $target} {
3540 if {$target != -1} {
3542 #echo OUT $w $found $xx $yy $normal
3543 LinkWindow
$w.scenarioTarget
-1
3545 set targetdata
[lindex $ScenarioButtons $target]
3546 set targetid
[lindex $targetdata 1]
3547 LinkWindow
$w.
$targetid.over
0
3548 UpdateScenarioButton
$w $targetdata
3553 #echo IN $w $found $xx $yy $over
3554 LinkWindow
$w.scenarioTarget
$found
3555 LinkWindow
$w.
$id.over
1
3557 if {$target != -1} {
3558 set targetdata
[lindex $ScenarioButtons $target]
3559 set targetid
[lindex $targetdata 1]
3560 LinkWindow
$w.
$targetid.over
0
3561 UpdateScenarioButton
$w $targetdata
3564 UpdateScenarioButton
$w $data
3570 proc DoLoad
{win param
} {
3571 #echo DOLOAD $win $param
3576 proc DoGenerate
{win param
} {
3577 #echo DOGENERATE $win $param
3582 proc DoQuit
{win param
} {
3583 #echo DOQUIT $win $param
3588 proc DoAbout
{win param
} {
3589 #echo DOABOUT $win $param
3590 MakeHistory
"DoLoadCity cities/about.cty"
3594 proc DoMap
{win param
} {
3595 #echo DOMAP $win $param
3599 proc DoLevel
{win param
} {
3600 #echo DOLEVEL $win $param
3601 DoSetGameLevel
$param
3605 proc DoLeft
{win param
} {
3606 #echo DOLEFT $win $param
3611 proc DoRight
{win param
} {
3612 #echo DORIGHT $win $param
3617 proc DoPlay
{win param
} {
3618 #echo DOPLAY $win $param
3623 proc DoPickScenario
{win param
} {
3624 #echo DOPICKSCENARIO $win $param
3625 UILoadScenario
$param
3628 proc DeleteScenarioWindow
{win
} {
3633 ########################################################################
3634 # Undo/Redo Facility
3637 proc InitHistory
{} {
3639 global MapHistoryNum
3641 set MapHistoryNum
-1
3645 proc MakeHistory
{cmd
} {
3647 set len
[llength $MapHistory]
3649 ($cmd != [lindex $MapHistory [expr $len-1]])} {
3650 lappend MapHistory
$cmd
3658 proc GotoHistory
{i
} {
3660 global MapHistoryNum
3661 InitVotesForUseThisMap
3662 if {$i != $MapHistoryNum} {
3663 set MapHistoryNum
$i
3664 set cmd
[lindex $MapHistory $i]
3667 if {$MapHistoryNum == 0} {
3672 if {$MapHistoryNum == ([llength $MapHistory] - 1)} {
3678 global ScenarioWindows
3679 foreach win
$ScenarioWindows {
3680 UpdateLeftRightEnabled
$win
3686 proc NextHistory
{} {
3688 global MapHistoryNum
3689 set len
[llength $MapHistory]
3690 set i
[expr "$MapHistoryNum + 1"]
3697 proc PrevHistory
{} {
3699 global MapHistoryNum
3700 set i
[expr "$MapHistoryNum - 1"]
3707 ########################################################################
3708 # Ask Window Handlers
3710 proc ShowAskOf
{head
} {
3711 set win
[WindowLink
$head.ask
]
3713 set win
[MakeWindow.ask
$head [winfo screen
$head]]
3723 foreach win
$HeadWindows {
3729 proc WithdrawAsks
{} {
3731 foreach win
$AskWindows {
3737 proc WithdrawAskOf
{win
} {
3738 set ask
[WindowLink
$win.ask
]
3745 proc AskQuestion
{color title
text left middle right
} {
3747 foreach win
$HeadWindows {
3748 AskQuestionOn
$win $color $title $text $left $middle $right
3753 proc AskQuestionOn
{head color title
text left middle right
} {
3756 set win
[WindowLink
$head.ask
]
3757 set t
[WindowLink
$win.title
]
3758 $t configure
-text $title
3759 $t configure
-background $color
3761 set t
[WindowLink
$win.
text]
3762 $t configure
-state normal
3764 $t insert end
"${text}\n"
3765 $t configure
-state disabled
3767 set bf
[WindowLink
$win.
frame]
3768 set l
[WindowLink
$win.left
]
3769 set m
[WindowLink
$win.middle
]
3770 set r
[WindowLink
$win.vote
]
3771 set rf
[WindowLink
$win.voteframe
]
3775 -text [lindex $left 0] \
3776 -command [format [lindex $left 2] $head]
3777 SetHelp
$l [lindex $left 1]
3778 pack append $bf $l {left
frame center
}
3783 if {$middle != ""} {
3785 -text [lindex $middle 0] \
3786 -command [format [lindex $middle 2] $head]
3787 SetHelp
$m [lindex $middle 1]
3788 pack append $bf $m {left
frame center expand
}
3794 set notify
[format [lindex $right 2] $head]
3795 set preview
[format [lindex $right 3] $head]
3796 set cmd
[list DoVote
$win Ask
$notify $preview]
3798 -text [lindex $right 0] \
3800 SetHelp
$r [lindex $right 1]
3801 pack append $bf $rf {right
frame center
}
3810 proc BindVotingButton
{win but name
} {
3811 set w
[WindowLink
$win.top
]
3813 bind $but <Any-Enter
> "VoteButtonEnter $win $but"
3814 bind $but <Any-Leave
> "VoteButtonLeave $win $but"
3815 bind $but <1> "VoteButtonDown $win $but $name"
3816 bind $but <ButtonRelease-1
> "VoteButtonUp $win $but $name"
3817 bind $but <2> "VoteButtonDown $win $but $name"
3818 bind $but <ButtonRelease-2
> "VoteButtonUp $win $but $name"
3819 bind $but <3> "VoteButtonDown $win $but $name"
3820 bind $but <ButtonRelease-3
> "VoteButtonUp $win $but $name"
3824 proc VoteButtonEnter
{win but
} {
3826 set screen
[winfo screen
$but]
3827 if {[lindex [$but config
-state] 4] != "disabled"} {
3828 $but config
-state active
3829 set tk_priv
(window
@$screen) $but
3831 set tk_priv
(window
@$screen) ""
3836 proc VoteButtonLeave
{win but
} {
3838 if {[lindex [$but config
-state] 4] != "disabled"} {
3839 $but config
-state normal
3841 set screen
[winfo screen
$but]
3842 set tk_priv
(window
@$screen) ""
3846 proc VoteButtonDown
{win but name
} {
3848 set screen
[winfo screen
$but]
3849 set rel
[lindex [$but config
-relief] 4]
3850 set tk_priv
(relief
@$screen) $rel
3851 if {[lindex [$but config
-state] 4] != "disabled"} {
3852 set head
[WindowLink
$win.head
]
3853 if {[IsVotingFor
$head $name]} {
3854 $but config
-relief raised
3856 $but config
-relief sunken
3862 proc VoteButtonUp
{win but name
} {
3864 set screen
[winfo screen
$but]
3865 $but config
-relief $tk_priv(relief
@$screen)
3866 if {($but == $tk_priv(window
@$screen))
3867 && ([lindex [$but config
-state] 4] != "disabled")} {
3868 uplevel #0 [list $but invoke]
3869 set head
[WindowLink
$win.head
]
3870 if {[IsVotingFor
$head $name]} {
3871 $but config
-relief sunken
3873 $but config
-relief raised
3879 proc PressVoteButton
{win but name
} {
3881 uplevel #0 [list $but invoke]
3882 set head
[WindowLink
$win.head
]
3883 if {[IsVotingFor
$head $name]} {
3884 $but config
-relief sunken
3886 $but config
-relief raised
3891 proc IsVotingFor
{win name
} {
3892 global VotesFor
$name
3893 set votes
[eval ident
"\$\{VotesFor$name\}"]
3894 if {[lsearch $votes $win] == -1} {
3902 proc DoVote
{win name notify preview
} {
3903 global VotesFor
$name
3904 set votes
[eval ident
"\$\{VotesFor$name\}"]
3906 set win
[WindowLink
$win.head
]
3907 set i
[lsearch $votes $win]
3909 lappend VotesFor
$name $win
3911 set VotesFor
$name [lreplace $votes $i $i]
3914 set votes
[eval ident
"\$\{VotesFor$name\}"]
3915 if {[llength $votes] >= [NeededVotes
]} {
3923 proc UpdateVotesFor
{name wins
} {
3924 global VotesFor
$name
3925 set votes
[eval llength "\$\{VotesFor$name\}"]
3926 set needed
[NeededVotes
]
3929 set head
[WindowLink
$win.head
]
3930 if {[IsVotingFor
$head $name]} {
3931 set border
[expr "($needed - $votes) * 1"]
3932 set pad
[expr "6 - $border"]
3933 [WindowLink
$win.vote
] config
-padx $pad -pady $pad
3934 [WindowLink
$win.voteframe
] config
-borderwidth $border
3936 set border
[expr "($needed - $votes - 1) * 1"]
3937 set pad
[expr "6 - $border"]
3938 [WindowLink
$win.vote
] config
-padx $pad -pady $pad
3939 [WindowLink
$win.voteframe
] config
-borderwidth $border
3945 proc InitVotesForAsk
{} {
3946 global VotesForAsk AskWindows
3948 foreach win
$AskWindows {
3949 [WindowLink
$win.vote
] config
-relief raised
3956 proc UpdateVotesForAsk
{} {
3958 UpdateVotesFor Ask
$AskWindows
3962 ########################################################################
3963 # Player Window Handlers
3965 proc ShowPlayerOf
{head
} {
3966 set win
[WindowLink
$head.player
]
3968 set win
[MakeWindow.player
$head [winfo screen
$head]]
3976 proc ShowPlayers
{} {
3978 foreach win
$HeadWindows {
3984 proc WithdrawPlayers
{} {
3985 global PlayerWindows
3986 foreach win
$PlayerWindows {
3992 proc UpdatePlayers
{} {
3993 # TODO: Disabled for new scenario window.
3996 global HeadWindows PlayerWindows
3999 foreach win
$HeadWindows {
4000 set server
[winfo screen
$win]
4001 # if {[string first : $server] == 0} {
4002 # set server "[exec hostname]:0"
4004 lappend players
$server
4007 sim Players
[llength $players]
4009 foreach win
$PlayerWindows {
4010 set list [WindowLink
$win.players
]
4012 eval "$list insert 0 $players"
4015 UpdateVotesForUseThisMap
4017 UpdateVotesForBudget
4018 UpdateTaxRateSliders
4022 proc UIShowPlayer
{win
} {
4027 proc DoNewPlayer
{win
} {
4028 set field
[WindowLink
$win.display
]
4029 set dpy
[$field get
]
4034 if {[AddPlayer
$dpy] != ""} {
4040 ########################################################################
4041 # Notice Window Handlers
4044 proc ShowNoticeOf
{head
} {
4045 set win
[WindowLink
$head.notice
]
4047 set win
[MakeWindow.notice
$head [winfo screen
$head]]
4049 global NoticePanelWidth NoticePanelHeight
4050 #place configure $win -x 0 -y 0 -width $NoticePanelWidth -height $NoticePanelHeight
4051 pack append [WindowLink
$head.w3
] \
4052 $win {bottom
frame sw expand fill
}
4057 proc ShowNotices
{} {
4059 foreach win
$HeadWindows {
4065 proc WithdrawNotices
{} {
4066 global NoticeWindows
4067 foreach win
$NoticeWindows {
4074 proc ReShowPictureOn
{{head
""}} {
4075 global ShowingPicture ShowingParms
4076 UIShowPictureOn
$head $ShowingPicture $ShowingParms
4080 proc UIShowPicture
{id
{parms
""}} {
4081 UIShowPictureOn
"" $id $parms
4085 proc UIShowPictureOn
{where id
{parms
""}} {
4086 global DoNotices Messages ShowingPicture ShowingParms
4087 if {$DoNotices == 0} {
4091 set ShowingPicture
$id
4092 set ShowingParms
$parms
4093 set msg
$Messages($id)
4094 set color
[lindex $msg 0]
4095 set title
[lindex $msg 1]
4096 set body
[lindex $msg 2]
4098 set cmd
"format {$body} $parms"
4099 set body
[uplevel #0 $cmd]
4101 set props
[lindex $msg 3]
4102 if {"$where" == ""} {
4104 set where
$HeadWindows
4106 foreach head
$where {
4107 NoticeMessageOn
$head "$title" $color "$body" Medium
$props
4112 proc NoticeMessageOn
{head title color
text font props
} {
4114 set win
[WindowLink
$head.notice
]
4116 set t
[WindowLink
$win.title
]
4117 $t configure
-text $title -background $color
4119 set t
[WindowLink
$win.
text]
4120 $t configure
-state normal
-font [Font
$head $font]
4122 $t insert end
"${text}\n"
4123 $t configure
-state disabled
4126 catch {set left
[keylget props left
]}
4127 set l
[WindowLink
$win.left
]
4129 $l config
-bitmap $left
4130 place $l -in $t -anchor sw
-relx .05 -rely .95
4136 catch {set middle
[keylget props middle
]}
4137 set m
[WindowLink
$win.middle
]
4138 if {$middle != ""} {
4139 $m config
-bitmap $middle
4140 place $m -in $t -anchor s
-relx .5 -rely .95
4146 catch {set right
[keylget props right
]}
4147 set r
[WindowLink
$win.right
]
4149 $r config
-bitmap $right
4150 place $r -in $t -anchor se
-relx .95 -rely .95
4156 catch {set view
[keylget props view
]}
4157 set vf
[WindowLink
$win.viewframe
]
4159 set v
[WindowLink
$win.view
]
4160 set bg
[WindowLink
$win.background
]
4164 pack append $bg $vf {left
frame center fill
}
4165 pack append $bg $t {right
frame center fill expand
}
4172 proc UIPopUpMessage
{msg
} {
4177 proc ComeToMe
{view
} {
4178 set win
[winfo toplevel $view]
4181 set x
[expr "[lindex $xy 0] >>4"]
4182 set y
[expr "[lindex $xy 1] >>4"]
4188 proc ComeTo
{win x y
} {
4189 global EditorWindows
4190 set head
[WindowLink
$win.head
]
4193 foreach ed
$EditorWindows {
4194 if {"[WindowLink $ed.head]" == "$head"} {
4196 set view
[WindowLink
$ed.view
]
4197 if {[$view AutoGoto
]} {
4198 lappend myautoeds
$ed
4202 if {[llength $myautoeds]} {
4203 UIAutoGotoOn
$x $y $myautoeds
4205 if {[llength $myeds]} {
4206 UIAutoGotoOn
$x $y $myeds
4212 proc FollowView
{view id
} {
4216 if {[sim DoAnimation
]} {
4217 set head
[WindowLink
[winfo toplevel $view].head
]
4218 global EditorWindows
4219 foreach win
$EditorWindows {
4220 if {"[WindowLink $win.head]" == "$head"} {
4221 set s
[[WindowLink
$win.view
] Skip
]
4222 set skips
[min
$skips $s]
4226 if {$skips == 999999} {
4236 proc PanView
{view x y
} {
4242 ########################################################################
4243 # Help Window Handlers
4246 proc ShowHelpOf
{head
} {
4247 set win
[WindowLink
$head.help
]
4249 set win
[MakeWindow.help
$head [winfo screen
$head]]
4259 foreach win
$HeadWindows {
4265 proc WithdrawHelps
{} {
4267 foreach win
$HelpWindows {
4273 ########################################################################
4274 # Frob Window Handlers
4277 proc ShowFrobOf
{head
} {
4278 set win
[WindowLink
$head.frob
]
4280 set win
[MakeWindow.frob
$head [winfo screen
$head]]
4291 foreach win
$HeadWindows {
4297 proc WithdrawFrobs
{} {
4299 foreach win
$FrobWindows {
4305 proc UISetDynamic
{i min max
} {
4306 sim DynamicData
[expr "$i*2"] $min
4307 sim DynamicData
[expr "$i*2+1"] $max
4311 ########################################################################
4318 source $ResourceDir/help.tcl
4321 proc HandleHelp
{win x y rootx rooty
} {
4322 global HelpLoaded HelpWidgets Messages
4324 if {$HelpLoaded == 0} {
4330 set head
[WindowLink
[winfo toplevel $win].head
]
4333 catch {set id
$HelpWidgets($win)}
4337 set list [split $win .
]
4338 set len
[expr "[llength $list] - 2"]
4339 set list [lrange $list 0 $len]
4340 if {[llength $list] <= 1} {
4344 set win
[join $list .
]
4346 if [info exists Messages
($id)] {
4347 UIShowHelpOn
$head $id
4349 UIShowHelpOn
$head Window
4354 proc UIShowHelpOn
{win id
{parms
""}} {
4355 global Messages ShowingPicture ShowingParms ResourceDir
4356 set head
[WindowLink
$win.head
]
4357 set msg
$Messages($id)
4358 set color
[lindex $msg 0]
4359 set title
[lindex $msg 1]
4360 set body
[lindex $msg 2]
4362 set cmd
"format {$body} $parms"
4363 set body
[uplevel #0 $cmd]
4365 set props
[lindex $msg 3]
4368 set win
[WindowLink
$head.help
]
4370 set t
[WindowLink
$win.title
]
4371 $t configure
-text $title -background $color
4373 set t
[WindowLink
$win.
text]
4374 $t configure
-state normal
-font [Font
$head Large
]
4376 $t insert end
"${body}\n"
4377 FormatHTML
$ResourceDir/doc
/$id.html
$t
4378 $t configure
-state disabled
4382 proc FormatHTML
{filename text} {
4385 set f
[open $filename]
4392 while {[gets $f line
] >= 0} {
4393 if {"$line" == "</body>"} {
4396 if {([string index
$line 0] == "#") ||
([string length
$line] == 0)} {
4399 $text insert end
"$line\n"
4408 proc SetHelp
{win id
} {
4410 set HelpWidgets
($win) $id
4414 proc Help
{id title
{msg
{}} {props
{}}} {
4415 Message
$id #7f7fff $title $msg $props
4418 ########################################################################
4422 # Set up the bindings to pop up $pie when the right button is clicked in $win
4423 proc InitPie
{win pie
} {
4424 bind $win <Motion
> {}
4425 bind $win <3> "PieMenuDown $win $pie $pie Initial %X %Y"
4426 bind $win <B3-Motion
> {}
4427 bind $win <B3-ButtonRelease
> {}
4431 # Set up the bindings to continue tracking $pie
4432 # Get this: we keep the tracking machine state in the bindings!
4433 proc ActivatePie
{win root pie state
} {
4434 bind $win <Motion
> "PieMenuMotion $win $root $pie $state %X %Y"
4435 bind $win <3> "PieMenuDown $win $root $pie $state %X %Y"
4436 bind $win <B3-Motion
> "PieMenuMotion $win $root $pie $state %X %Y"
4437 bind $win <B3-ButtonRelease
> "PieMenuUp $win $root $pie $state %X %Y"
4441 # Cancel and reset a pie menu
4442 proc CancelPie
{win
} {
4443 set binding
[bind $win <3>]
4444 set root
[lindex $binding 2]
4445 set pie
[lindex $binding 3]
4446 set state
[lindex $binding 4]
4447 if {"$state" != "Initial"} {
4448 catch {$root ungrab
$win}
4451 UIMakeSoundOn
$win fancy Oop
4457 # Handle pie menu button down
4458 proc PieMenuDown
{win root pie state x y
} {
4461 ActivatePie
$win $root $pie FirstDown
4463 catch {$root grab $win}
4466 PreviewPieMenu
$win $pie $x $y
4470 TrackPieMenu
$pie $x $y
4471 ActivatePie
$win $root $pie SecondDown
4477 PreviewPieMenu
$win $pie $x $y
4478 ActivatePie
$win $root $pie SecondDown
4483 SecondDown
{ # error
4490 # Handle pie menu button motion
4491 proc PieMenuMotion
{win root pie state x y
} {
4494 TrackPieMenu
$pie $x $y
4502 TrackPieMenu
$pie $x $y
4516 # Handle pie menu button up
4517 proc PieMenuUp
{win root pie state x y
} {
4520 TrackPieMenu
$pie $x $y
4521 set active
[$pie index active
]
4522 if {$active == "none"} {
4524 catch {$root grab $win}
4525 ActivatePie
$win $root $pie ClickedUp
4527 set label [lindex [$pie entryconfig
$active -label] 4]
4528 set submenu
[lindex [$pie entryconfig
$active -piemenu] 4]
4529 UIMakeSoundOn
$win mode
$label
4530 if {$submenu == {}} {
4531 set reward
[$pie pending
]
4532 catch {$root ungrab
$win}
4536 sim Funds
[expr "[sim Funds] + 5"]
4537 UIMakeSoundOn
$win fancy Aaah
4539 eval [lindex [$pie entryconfig
$active -command] 4]
4544 $submenu activate none
4546 PreviewPieMenu
$win $submenu $x $y
4547 catch {$root grab $win}
4548 ActivatePie
$win $root $submenu SelectedUp
4553 TrackPieMenu
$pie $x $y
4554 set active
[$pie index active
]
4555 if {$active == "none"} {
4558 set label [lindex [$pie entryconfig
$active -label] 4]
4559 set submenu
[lindex [$pie entryconfig
$active -piemenu] 4]
4560 UIMakeSoundOn
$win mode
$label
4561 if {$submenu == {}} {
4562 set reward
[$pie pending
]
4563 catch {$root ungrab
$win}
4567 sim Funds
[expr "[sim Funds] + 5"]
4568 UIMakeSoundOn
$win fancy Aaah
4570 eval [lindex [$pie entryconfig
$active -command] 4]
4575 $submenu activate none
4577 PreviewPieMenu
$win $submenu $x $y
4578 catch {$root grab $win}
4579 ActivatePie
$win $root $submenu SelectedUp
4589 SelectedUp
{ # error
4596 # Track the selected item
4597 proc TrackPieMenu
{pie x y
} {
4598 $pie activate
@$x,$y
4602 proc PreviewPieMenu
{win pie x y
} {
4603 set preview
[lindex [$pie config
-preview] 4]
4604 if {"$preview" != ""} {
4605 set rx
[winfo rootx
$win]
4606 set ry
[winfo rooty
$win]
4607 set x
[expr "$x - $rx"]
4608 set y
[expr "$y - $ry"]
4609 eval [format $preview $x $y]
4614 ########################################################################
4618 proc ExclusivePallet
{state parent children prefix images inactive active cmd
} {
4619 #echo "ExclusivePallet state $state parent $parent children $children prefix $prefix images $images inactive $inactive active $active cmd $cmd"
4621 foreach child
$children {
4622 set name
[lindex $images $i]
4623 if {$i == $state} then
{
4624 $parent.
$child config
\
4625 -bitmap "@images/${prefix}${name}hi.xpm" \
4628 $parent.
$child config
\
4629 -bitmap "@images/${prefix}${name}.xpm" \
4634 eval [concat $cmd $state]
4638 proc NonExclusivePallet
{mask parent children prefix images
4639 inactive active cmd
} {
4641 foreach child
$children {
4642 set name
[lindex $images $i]
4643 if {$mask & (1<<$i)} then
{
4644 $parent.
$child config
\
4645 -bitmap "@images/${prefix}${name}hi.xpm" \
4648 $parent.
$child config
\
4649 -bitmap "@images/${prefix}${name}.xpm" \
4654 eval [concat $cmd $mask]
4658 proc EditorPallet
{win state
} {
4659 global EditorPalletSounds
4660 UIMakeSoundOn
$win mode
[lindex $EditorPalletSounds $state]
4661 EditorSetTool
$win $state
4665 proc EditorSetTool
{win state
} {
4666 global EditorPallets
4667 global EditorPalletImages
4668 ExclusivePallet
$state $win $EditorPallets ic
$EditorPalletImages \
4669 flat raised
"$win.centerframe.view ToolState"
4673 proc GraphPallet
{win state
} {
4674 set mask
[[WindowLink
$win.graphview
] Mask
]
4675 set mask
[expr "$mask ^ (1<<$state)"]
4676 GraphPalletMask
$win $mask
4680 proc GraphPalletMask
{win mask
} {
4682 global GraphPalletImages
4683 NonExclusivePallet
$mask $win $GraphPallets gr
$GraphPalletImages \
4684 flat flat
"SetGraphState $win"
4688 proc GraphYearPallet
{win state
} {
4689 global GraphYearPallets
4690 global GraphYearPalletImages
4691 ExclusivePallet
$state $win $GraphYearPallets gr
$GraphYearPalletImages \
4692 flat flat
"SetGraphYearState $win"
4696 proc SetGraphYearState
{win state
} {
4697 set graph
[WindowLink
$win.graphview
]
4706 proc SetGraphState
{win mask
} {
4708 set graph
[WindowLink
$win.graphview
]
4713 ########################################################################
4716 proc sim_butEnter
{w
} {
4718 set screen
[winfo screen
$w]
4719 set tk_priv
(window
@$screen) $w
4723 proc sim_butLeave
{w
} {
4725 set screen
[winfo screen
$w]
4726 set tk_priv
(window
@$screen) ""
4730 proc sim_butDown
{w
} {
4732 set screen
[winfo screen
$w]
4733 set pict
[lindex [$w config
-bitmap] 4]
4734 set tk_priv
(relief
@$screen) $pict
4735 $w config
-bitmap [lindex [split $pict .
] 0]hi.xpm
4740 proc sim_butUp
{w
} {
4742 set screen
[winfo screen
$w]
4743 $w config
-bitmap $tk_priv(relief
@$screen)
4745 if {$w == $tk_priv(window
@$screen)} {
4746 uplevel #0 [list $w invoke]
4751 proc BindSimButton
{w
} {
4752 bind $w <Any-Enter
> {sim_butEnter
%W
}
4753 bind $w <Any-Leave
> {sim_butLeave
%W
}
4754 bind $w <1> {sim_butDown
%W
}
4755 bind $w <ButtonRelease-1
> {sim_butUp
%W
}
4756 bind $w <2> {sim_butDown
%W
}
4757 bind $w <ButtonRelease-2
> {sim_butUp
%W
}
4758 bind $w <3> {sim_butDown
%W
}
4759 bind $w <ButtonRelease-3
> {sim_butUp
%W
}
4763 ########################################################################
4764 # Internal Callbacks
4767 proc UIStartMicropolis
{homedir resourcedir hostname
} {
4768 global HomeDir ResourceDir HostName HeadWindows
4769 set HomeDir
$homedir
4770 set ResourceDir
$resourcedir
4771 set HostName
$hostname
4776 foreach display
[sim Displays
] {
4777 if {"[AddPlayer $display]" == ""} {
4778 echo Couldn't add a player on
$display ...
4782 if {"$HeadWindows" == ""} {
4783 echo Micropolis is exiting because it couldn't connect to any players.
4789 proc UISelectCity
{win
} {
4790 AskQuestion
[Color
$win #ff0000 #ffffff] "Choose Another City" \
4791 "Do you want to abandon this city and choose another one?" \
4792 "{Keep playing.} SelectCity.No {RejectPlan}" \
4794 "{Another city!} SelectCity.Yes {UIPickScenarioMode}"
4798 proc UIQuit
{head
} {
4799 if {[sim Players
] == 1} {
4800 set l
"{Keep playing.} Quit.No {RejectPlan}"
4802 set r
"{I quit!} Quit.IQuit {DoReallyQuit %s}"
4804 set l
"{Keep playing.} Quit.No {RejectPlan}"
4805 set m
"{I quit!} Quit.IResign {DoIResign %s}"
4806 set r
"{Everyone quit!} Quit.AllQuit {DoReallyQuit %s}"
4808 AskQuestion
[Color
$head #ff0000 #ffffff] "Quit Playing Micropolis" \
4809 "Do you want to quit playing Micropolis?" \
4814 proc DoIResign
{head
} {
4816 set display
[winfo screen
$head]
4818 DecRefDisplay
$display
4819 UISetMessage
"The player on X11 Display $display has resigned."
4821 if {([sim Players
] == 0) ||
4822 ([llength $VotesForAsk] >= [sim Players
])} {
4828 proc DoReallyQuit
{head
} {
4834 proc UISplashMode
{} {
4844 proc UIPickScenarioMode
{} {
4853 InitVotesForUseThisMap
4858 proc ForcePickScenarioMode
{} {
4860 if {"$State" != "scenario"} {
4866 proc UIGenerateCityNow
{} {
4867 global CityName GameLevel
4868 sim CityName NowHere
4874 proc UIGenerateNewCity
{} {
4875 global CityName GameLevel
4876 if {$GameLevel == -1} {
4879 MakeHistory
"DoNewCity NowHere $GameLevel [sim Rand] [sim TreeLevel] [sim LakeLevel] [sim CurveLevel] [sim CreateIsland]"
4883 proc DoNewCity
{name level
{r
""} {tl
-1} {ll
-1} {cl
-1} {ci
-1}} {
4889 sim CreateIsland
$ci
4893 sim GenerateSomeCity
$r
4896 sim GameLevel
$level
4901 proc UIDidGenerateNewCity
{} {
4906 proc IncRefDisplay
{display
} {
4907 global DisplayRegistry
4908 if ![info exists DisplayRegistry
($display)] {
4909 set DisplayRegistry
($display) 0
4911 incr DisplayRegistry
($display)
4915 proc DecRefDisplay
{display
} {
4916 global DisplayRegistry
4917 incr DisplayRegistry
($display) -1
4918 if {$DisplayRegistry($display) <= 0} {
4919 CloseDisplay
$display
4924 proc CloseDisplay
{display
} {
4928 proc DoStopMicropolis
{} {
4934 proc AddPlayer
{display
} {
4935 set i
[string first
: $display]
4939 set display
"$display:0"
4943 echo Adding a player on
$display ...
4945 set head
[MakeWindow.head
$display]
4947 if {"$head" != ""} {
4948 set display
[winfo screen
$head]
4949 IncRefDisplay
$display
4951 UISetMessage
"Added a player on X11 Display \"$display\"."
4954 UISetMessage
"Couldn't add a player on X11 Display \"$display\"!"
4964 proc DropFireBombs
{} {
4972 proc UIMakeMonster
{} {
4973 sim MakeMonster
[sim Rand
120] [sim Rand
100]
4996 proc TogglePause
{} {
4999 if {"$State" != "play" ||
[sim Speed
]} {
5010 proc SetSpeedTime
{time} {
5016 proc MakeRunningSound
{} {
5019 if {"$State" == "play" && [sim Speed
]} {
5020 UIMakeSound edit Boing
"-speed 1[sim Speed]0"
5022 UIMakeSound edit Boing
"-speed 90"
5027 proc SayDemands
{} {
5028 global DemandRes DemandCom DemandInd
5030 set r
[expr "100 + ($DemandRes * $slope)"]
5031 set c
[expr "100 + ($DemandCom * $slope)"]
5032 set i
[expr "100 + ($DemandInd * $slope)"]
5033 after 020 "UIMakeSound edit O \"-speed $r\""
5034 after 220 "UIMakeSound edit A \"-speed $c\""
5035 after 440 "UIMakeSound edit E \"-speed $i\""
5039 proc UISaveCity
{win
} {
5041 set SaveCityWin
$win
5046 proc UISaveCityAs
{{win
""}} {
5048 if {"$win" == ""} {set win
$SaveCityWin}
5049 set SaveCityWin
$win
5052 set file [ShowFileOf
$win]
5053 DoFileDialog
$file "Choose a File to Save the City" $CityDir "*.cty" "" \
5054 "UIDoReallySaveCity" ""
5058 proc UIDoReallySaveCity
{name path
} {
5060 if {![string match
*.cty
$name]} {
5064 sim SaveCityAs
$path/$name
5068 proc UIDidSaveCity
{} {
5069 DoSendMessage
"Saved the city in \"[sim CityFileName]\"." status
5073 proc UIDidntSaveCity
{msg
} {
5074 DoSendMessage
$msg alert
5075 UIMakeSound warning Sorry
"-speed 85"
5079 proc UILoadScenario
{scen
} {
5080 MakeHistory
"DoScenario $scen"
5084 proc DoScenario
{scen
} {
5087 sim LoadScenario
$scen
5092 proc UIDidLoadScenario
{} {
5096 proc UIStartScenario
{id
} {
5105 proc UIPlayNewCity
{} {
5111 proc UIStartLoad
{} {
5116 proc UIReallyStartGame
{} {
5122 proc UIPlayGame
{} {
5129 SetPriority
$Priority
5137 proc UISetSpeed
{speed
} {
5140 if {"$State" == "play"} {
5141 UISetMessage
[lindex {
5144 {Time flows medium.
}
5152 proc UIUpdateRunning
{} {
5153 global HeadWindows Time State
5155 if {($State == "play") && $Time} {
5156 set pict
"@images/micropolisg.xpm"
5158 set pict
"@images/micropoliss.xpm"
5161 foreach win
$HeadWindows {
5162 set can
[WindowLink
$win.demand
]
5163 $can itemconfig micropolis
-bitmap $pict
5168 proc DoSetGameLevel
{level
} {
5169 sim GameLevel
$level
5173 proc UISetGameLevel
{level
} {
5175 set GameLevel
$level
5176 global ScenarioWindows
5177 foreach win
$ScenarioWindows {
5178 UpdateLevelSelection
$win
5183 proc UISetCityName
{name
} {
5184 global EditorWindows
5187 set title
"Micropolis Editor on $name"
5188 foreach win
$EditorWindows {
5189 # TODO: set editor window and icon title
5190 #wm title $win "$title"
5191 #wm iconname $win "$title"
5196 proc UILoadCity
{win
} {
5197 # if changed, r-u-sure?
5199 set file [ShowFileOf
$win]
5200 DoFileDialog
$file "Choose a City to Load" $CityDir "*.cty" "" \
5205 proc UIDoLoadCity
{name path
} {
5208 if {![string match
*.cty
$name]} {
5211 MakeHistory
"DoLoadCity {$path/$name}"
5215 proc DoLoadCity
{filename} {
5216 sim LoadCity
$filename
5219 proc UIDidLoadCity
{} {
5220 global State GameLevel Scenario
5223 if {$State == "play"} {
5226 UIShowPicture
49 [sim CityFileName
]
5231 proc UIDidntLoadCity
{msg
} {
5232 DoSendMessage
$msg alert
5233 UIMakeSound warning Sorry
"-speed 85"
5234 UIShowPicture
49 [sim CityFileName
]
5253 proc UIDidPan
{w x y
} {
5254 if {[$w ToolMode
] == 1} {
5255 EditorToolDrag
$w $x $y
5261 proc UIDidStopPan
{win
} {
5262 UIMakeSoundOn
$win fancy Skid
"-volume 25"
5267 proc UIEarthQuake
{} {
5271 proc UIAutoGoto
{x y
{except
{}}} {
5272 global EditorWindows
5274 set x
[expr "$x * 16 + 8"]
5275 set y
[expr "$y * 16 + 8"]
5276 foreach win
$EditorWindows {
5277 if {"$win" != "$except"} {
5278 set view
[WindowLink
$win.view
]
5279 if {[$view AutoGoto
]} {
5281 $view AutoGoal
$x $y
5291 proc UIAutoGotoOn
{x y eds
} {
5292 set x
[expr "$x * 16 + 8"]
5293 set y
[expr "$y * 16 + 8"]
5295 [WindowLink
$win.view
] AutoGoal
$x $y
5301 proc DoLeaveGame
{head
} {
5305 proc UILoseGame
{} {
5309 AskQuestion
[Color .
#ff0000 #ffffff] [lindex $Messages(200) 1] \
5310 [lindex $Messages(200) 2] \
5313 "{Ok} SelectCity.Yes {UIPickScenarioMode}"
5322 proc DoPendTool
{view tool x y
} {
5323 global HeadWindows ToolInfo VotesForAsk
5325 set win
[WindowLink
$view.top
]
5326 set head
[WindowLink
$win.head
]
5328 if {($tool == [sim PendingTool
]) &&
5329 ($x == [sim PendingX
]) &&
5330 ($y == [sim PendingY
])} {
5331 if {[lsearch $VotesForAsk $head] != -1} {
5332 # you can only vote once
5333 UIMakeSound edit Oop
5335 UIMakeSound edit Boing
5336 set ask
[WindowLink
$head.ask
]
5337 PressVoteButton
$ask [WindowLink
$ask.vote
] Ask
5340 UIAutoGoto
$x $y $win
5342 UIMakeSound edit Boing
5343 set info [lindex $ToolInfo $tool]
5344 set a
[lindex $info 0]
5345 set name
[lindex $info 1]
5346 set cost
[lindex $info 2]
5347 set title
"Build $a $name"
5348 set question
"Do you support the plan to build $a $name for $cost?"
5349 AskQuestion
[Color
$win #00ff00 #ffffff] "$title" \
5351 "{Veto plan.} Plan.Veto
5353 "{Goto plan.} Plan.Goto
5354 {ComeTo %s $x $y}" \
5355 "{Support plan!} Plan.Support
5356 {SupportPlan $view %s $tool $x $y}
5357 {PreviewSupportPlan $view %s $tool $x $y}"
5358 set VotesForAsk
$head
5359 set ask
[WindowLink
$head.ask
]
5360 [WindowLink
$ask.vote
] config
-relief sunken
5364 sim PendingTool
$tool
5367 sim Votes
[llength $VotesForAsk]
5372 proc RejectPlan
{} {
5374 if {[sim Players
] > 1} {
5375 UIMakeSound edit Sorry
5381 proc NeededVotes
{} {
5383 set players
[sim Players
]
5384 set needed
[expr "$players - $FreeVotes"]
5385 return [max
0 $needed]
5389 proc SupportPlan
{view h tool x y
} {
5391 sim Votes
[llength $VotesForAsk]
5394 $view DoTool
$tool $x $y
5397 UIMakeSound edit Aaah
5401 proc PreviewSupportPlan
{view h tool x y
} {
5403 sim Votes
[llength $VotesForAsk]
5407 proc SugarStartUp
{uri
} {
5411 # TODO: Load the city file at the given URI, or configure according to URI parameters.
5415 proc SugarNickName
{nick
} {
5416 global SugarNickName
5417 set SugarNickName
$nick
5421 proc SugarActivate
{} {
5422 global SugarActivated
5423 set SugarActivated
1
5427 proc SugarDeactivate
{} {
5428 global SugarActivated
5429 set SugarActivated
0
5433 proc SugarShare
{} {
5439 proc SugarBuddyAdd
{key nick color address
} {
5441 set buddy
[list $key $nick $color $address]
5442 lappend SugarBuddies
$buddy
5446 proc SugarBuddyDel
{key nick color address
} {
5448 set buddy
[list $key $nick $color $address]
5449 set i
[lsearch $wins $win]
5451 set SugarBuddies
[lreplace $wins $i $i]
5461 ########################################################################