|
|
1.1 root 1: # Window: Scenarios, for Unix Micropolis.
2: #
3: # Micropolis, Unix Version. This game was released for the Unix platform
4: # in or about 1990 and has been modified for inclusion in the One Laptop
5: # Per Child program. Copyright (C) 1989 - 2007 Electronic Arts Inc. If
6: # you need assistance with this program, you may contact:
7: # http://wiki.laptop.org/go/Micropolis or email [email protected].
8: #
9: # This program is free software: you can redistribute it and/or modify
10: # it under the terms of the GNU General Public License as published by
11: # the Free Software Foundation, either version 3 of the License, or (at
12: # your option) any later version.
13: #
14: # This program is distributed in the hope that it will be useful, but
15: # WITHOUT ANY WARRANTY; without even the implied warranty of
16: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17: # General Public License for more details. You should have received a
18: # copy of the GNU General Public License along with this program. If
19: # not, see <http://www.gnu.org/licenses/>.
20: #
21: # ADDITIONAL TERMS per GNU GPL Section 7
22: #
23: # No trademark or publicity rights are granted. This license does NOT
24: # give you any right, title or interest in the trademark SimCity or any
25: # other Electronic Arts trademark. You may not distribute any
26: # modification of this program using the trademark SimCity or claim any
27: # affliation or association with Electronic Arts Inc. or its employees.
28: #
29: # Any propagation or conveyance of this program must include this
30: # copyright notice and these terms.
31: #
32: # If you convey this program (or any modifications of it) and assume
33: # contractual liability for the program to recipients of it, you agree
34: # to indemnify Electronic Arts for any liability that those contractual
35: # assumptions impose on Electronic Arts.
36: #
37: # You may not misrepresent the origins of this program; modified
38: # versions of the program must be marked as such and not identified as
39: # the original program.
40: #
41: # This disclaimer supplements the one included in the General Public
42: # License. TO THE FULLEST EXTENT PERMISSIBLE UNDER APPLICABLE LAW, THIS
43: # PROGRAM IS PROVIDED TO YOU "AS IS," WITH ALL FAULTS, WITHOUT WARRANTY
44: # OF ANY KIND, AND YOUR USE IS AT YOUR SOLE RISK. THE ENTIRE RISK OF
45: # SATISFACTORY QUALITY AND PERFORMANCE RESIDES WITH YOU. ELECTRONIC ARTS
46: # DISCLAIMS ANY AND ALL EXPRESS, IMPLIED OR STATUTORY WARRANTIES,
47: # INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY, SATISFACTORY QUALITY,
48: # FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT OF THIRD PARTY
49: # RIGHTS, AND WARRANTIES (IF ANY) ARISING FROM A COURSE OF DEALING,
50: # USAGE, OR TRADE PRACTICE. ELECTRONIC ARTS DOES NOT WARRANT AGAINST
51: # INTERFERENCE WITH YOUR ENJOYMENT OF THE PROGRAM; THAT THE PROGRAM WILL
52: # MEET YOUR REQUIREMENTS; THAT OPERATION OF THE PROGRAM WILL BE
53: # UNINTERRUPTED OR ERROR-FREE, OR THAT THE PROGRAM WILL BE COMPATIBLE
54: # WITH THIRD PARTY SOFTWARE OR THAT ANY ERRORS IN THE PROGRAM WILL BE
55: # CORRECTED. NO ORAL OR WRITTEN ADVICE PROVIDED BY ELECTRONIC ARTS OR
56: # ANY AUTHORIZED REPRESENTATIVE SHALL CREATE A WARRANTY. SOME
57: # JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF OR LIMITATIONS ON IMPLIED
58: # WARRANTIES OR THE LIMITATIONS ON THE APPLICABLE STATUTORY RIGHTS OF A
59: # CONSUMER, SO SOME OR ALL OF THE ABOVE EXCLUSIONS AND LIMITATIONS MAY
60: # NOT APPLY TO YOU.
61: #
62: global ScenarioWindows
63: set n [Unique]
64: set win .scenario$n
65:
66: LinkWindow $head.scenario $win
67: LinkWindow $win.head $head
68: LinkWindow $win.scenarioTarget -1
69: LinkWindow $win.scenarioTargetDown -1
70:
71: catch "destroy $win"
72: if {[catch "toplevel $win -screen $display"]} {
73: puts stderr "Couldn't open X11 display \"$display\"."
74: set win ""
75: return ""
76: }
77:
78: wm title $win "Micropolis Scenarios"
79: wm iconname $win {Micropolis Scenarios}
80: wm geometry $win 1200x900+0+0
81: wm withdraw $win
82: wm protocol $win delete "DeleteScenarioWindow $win ;"
83: wm fullscreen $win on
84:
85: set ScenarioWindows [linsert $ScenarioWindows 0 $win]
86:
87: SetHelp $win Scenario
88:
89: canvas $win.canvas \
90: -scrollincrement 0 \
91: -borderwidth 0 \
92: -background #000000 \
93: -width 1200 -height 900
94: LinkWindow $win.canvas $win.canvas
95: LinkWindow $win.canvas.w $win
96:
97: $win.canvas create bitmap 0 0 \
98: -tags background \
99: -bitmap "@images/background-micropolis.xpm" \
100: -anchor nw
101:
102: $win.canvas bind background <ButtonPress> {HandleScenarioDown %W %x %y}
103: $win.canvas bind background <ButtonRelease-1> {HandleScenarioUp %W %x %y}
104: $win.canvas bind background <ButtonRelease-2> {HandleScenarioUp %W %x %y}
105: $win.canvas bind background <ButtonRelease-3> {HandleScenarioUp %W %x %y}
106: $win.canvas bind background <Motion> {HandleScenarioMove %W %x %y}
107: $win.canvas bind background <Button1-Motion> {HandleScenarioMove %W %x %y}
108: $win.canvas bind background <Button2-Motion> {HandleScenarioMove %W %x %y}
109: $win.canvas bind background <Button3-Motion> {HandleScenarioMove %W %x %y}
110:
111: global ScenarioButtons
112: set i 0
113: set len [llength $ScenarioButtons]
114: while {$i < $len} {
115: set data [lindex $ScenarioButtons $i]
116: set type [lindex $data 0]
117: set id [lindex $data 1]
118: set xx [lindex $data 5]
119: set yy [lindex $data 6]
120: set ww [lindex $data 7]
121: set hh [lindex $data 8]
122:
123: $win.canvas create bitmap $xx $yy \
124: -tags $id \
125: -anchor nw
126:
127: $win.canvas bind $id <ButtonPress> {HandleScenarioDown %W %x %y}
128: $win.canvas bind $id <ButtonRelease-1> {HandleScenarioUp %W %x %y}
129: $win.canvas bind $id <ButtonRelease-2> {HandleScenarioUp %W %x %y}
130: $win.canvas bind $id <ButtonRelease-3> {HandleScenarioUp %W %x %y}
131: $win.canvas bind $id <Motion> {HandleScenarioMove %W %x %y}
132: $win.canvas bind $id <Button1-Motion> {HandleScenarioMove %W %x %y}
133: $win.canvas bind $id <Button2-Motion> {HandleScenarioMove %W %x %y}
134: $win.canvas bind $id <Button3-Motion> {HandleScenarioMove %W %x %y}
135:
136: set i [expr "$i + 1"]
137: }
138:
139: mapview $win.canvas.view \
140: -font [Font $win Large]
141: LinkWindow $win.view $win.canvas.view
142: $win.canvas.view size [expr "[sim WorldX] * 3"] [expr "[sim WorldY] * 3"]
143:
144: # Hide the editor rectangles.
145: $win.canvas.view ShowEditors 0
146:
147: frame $win.canvas.name \
148: -borderwidth 2\
149: -relief flat
150:
151: SetHelp $win.name Scenario.Name
152:
153: label $win.canvas.name.namelabel \
154: -text {City Name:} \
155: -font [Font $win Text]
156:
157: entry $win.canvas.name.cityname \
158: -text {}\
159: -textvariable CityName \
160: -font [Font $win Text] \
161: -width 33
162: bind $win.canvas.name.cityname <Return> "DoEnterCityName $win"
163: bind $win.canvas.name.cityname <Any-Enter> {focus %W}
164: LinkWindow $win.cityname $win.canvas.name.cityname
165:
166: pack append $win.canvas.name \
167: $win.canvas.name.namelabel {left frame e}\
168: $win.canvas.name.cityname {left frame e}
169:
170: place $win.canvas -x 0 -y 0
171: place $win.canvas.view -x 534 -y 48
172: place $win.canvas.name -x 530 -y 0
173:
174: InitScenario $win
175:
176: update idletasks
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.