]> git.zerfleddert.de Git - micropolis/blob - res/wscen.tcl
src/tk/tkrawtcp.c: Micropolis build fixes for recent macOS
[micropolis] / res / wscen.tcl
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 micropolis@laptop.org.
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 global ScenarioPanelWidth
79 global ScenarioPanelHeight
80
81 wm title $win "Micropolis Scenarios"
82 wm iconname $win {Micropolis Scenarios}
83 wm geometry $win ${ScenarioPanelWidth}x${ScenarioPanelHeight}+0+0
84 wm withdraw $win
85 wm protocol $win delete "DeleteScenarioWindow $win ;"
86 wm fullscreen $win on
87
88 set ScenarioWindows [linsert $ScenarioWindows 0 $win]
89
90 SetHelp $win Scenario
91
92 canvas $win.canvas \
93 -scrollincrement 0 \
94 -borderwidth 0 \
95 -background #BFBFBF \
96 -width $ScenarioPanelWidth -height $ScenarioPanelHeight
97 LinkWindow $win.canvas $win.canvas
98 LinkWindow $win.canvas.w $win
99
100 global ScenarioBackground
101
102 $win.canvas create bitmap 0 0 \
103 -tags background \
104 -bitmap $ScenarioBackground \
105 -anchor nw
106
107 $win.canvas bind background <ButtonPress> {HandleScenarioDown %W %x %y}
108 $win.canvas bind background <ButtonRelease-1> {HandleScenarioUp %W %x %y}
109 $win.canvas bind background <ButtonRelease-2> {HandleScenarioUp %W %x %y}
110 $win.canvas bind background <ButtonRelease-3> {HandleScenarioUp %W %x %y}
111 $win.canvas bind background <Motion> {HandleScenarioMove %W %x %y}
112 $win.canvas bind background <Button1-Motion> {HandleScenarioMove %W %x %y}
113 $win.canvas bind background <Button2-Motion> {HandleScenarioMove %W %x %y}
114 $win.canvas bind background <Button3-Motion> {HandleScenarioMove %W %x %y}
115
116 global ScenarioButtons
117 set i 0
118 set len [llength $ScenarioButtons]
119 while {$i < $len} {
120 set data [lindex $ScenarioButtons $i]
121 set type [lindex $data 0]
122 set id [lindex $data 1]
123 set xx [lindex $data 5]
124 set yy [lindex $data 6]
125 set ww [lindex $data 7]
126 set hh [lindex $data 8]
127
128 $win.canvas create bitmap $xx $yy \
129 -tags $id \
130 -anchor nw
131
132 $win.canvas bind $id <ButtonPress> {HandleScenarioDown %W %x %y}
133 $win.canvas bind $id <ButtonRelease-1> {HandleScenarioUp %W %x %y}
134 $win.canvas bind $id <ButtonRelease-2> {HandleScenarioUp %W %x %y}
135 $win.canvas bind $id <ButtonRelease-3> {HandleScenarioUp %W %x %y}
136 $win.canvas bind $id <Motion> {HandleScenarioMove %W %x %y}
137 $win.canvas bind $id <Button1-Motion> {HandleScenarioMove %W %x %y}
138 $win.canvas bind $id <Button2-Motion> {HandleScenarioMove %W %x %y}
139 $win.canvas bind $id <Button3-Motion> {HandleScenarioMove %W %x %y}
140
141 set i [expr "$i + 1"]
142 }
143
144 mapview $win.canvas.view \
145 -font [Font $win Large]
146 LinkWindow $win.view $win.canvas.view
147 $win.canvas.view size [expr "[sim WorldX] * 3"] [expr "[sim WorldY] * 3"]
148
149 # Hide the editor rectangles.
150 $win.canvas.view ShowEditors 0
151
152 frame $win.canvas.name \
153 -borderwidth 2\
154 -relief flat
155
156 SetHelp $win.name Scenario.Name
157
158 label $win.canvas.name.namelabel \
159 -text {City Name:} \
160 -font [Font $win Text]
161
162 entry $win.canvas.name.cityname \
163 -text {}\
164 -textvariable CityName \
165 -font [Font $win Text] \
166 -width 33
167 bind $win.canvas.name.cityname <Return> "DoEnterCityName $win"
168 bind $win.canvas.name.cityname <Any-Enter> {focus %W}
169 LinkWindow $win.cityname $win.canvas.name.cityname
170
171 pack append $win.canvas.name \
172 $win.canvas.name.namelabel {left frame e}\
173 $win.canvas.name.cityname {left frame e}
174
175 place $win.canvas -x 0 -y 0
176
177 global ScenarioMapX
178 global ScenarioMapY
179 if {$ScenarioMapX != -1} {
180 place $win.canvas.view -x $ScenarioMapX -y $ScenarioMapY
181 }
182
183 global ScenarioCityNameX
184 global ScenarioCityNameY
185 place $win.canvas.name -x $ScenarioCityNameX -y $ScenarioCityNameY
186
187 InitScenario $win
188
189 update idletasks
Impressum, Datenschutz