Mercurial > traipse_dev
comparison orpg/mapper/fog_msg.py @ 20:072ffc1d466f traipse_dev
2nd attempt. Still untested.
author | sirebral |
---|---|
date | Sat, 25 Jul 2009 19:23:25 -0500 |
parents | 4385a7d0efd1 |
children | 449a8900f9ac |
comparison
equal
deleted
inserted
replaced
19:78407d627cba | 20:072ffc1d466f |
---|---|
39 self.fogregion=IRegion() | 39 self.fogregion=IRegion() |
40 self.fogregion.Clear() | 40 self.fogregion.Clear() |
41 | 41 |
42 def get_line(self,outline,action,output_act): | 42 def get_line(self,outline,action,output_act): |
43 elem = Element( "poly" ) | 43 elem = Element( "poly" ) |
44 if ( output_act ): | 44 if ( output_act ): elem.setAttribute( "action", action ) |
45 elem.setAttribute( "action", action ) | 45 if ( outline == 'all' ) or ( outline == 'none' ): elem.setAttribute( "outline", outline ) |
46 if ( outline == 'all' ) or ( outline == 'none' ): | |
47 elem.setAttribute( "outline", outline ) | |
48 else: | 46 else: |
49 elem.setAttribute( "outline", "points" ) | 47 elem.setAttribute( "outline", "points" ) |
50 for pair in string.split( outline, ";" ): | 48 for pair in string.split( outline, ";" ): |
51 p = string.split( pair, "," ) | 49 p = string.split( pair, "," ) |
52 point = Element( "point" ) | 50 point = Element( "point" ) |
75 def toxml(self,action,output_action): | 73 def toxml(self,action,output_action): |
76 #print "fog_msg.toxml called" | 74 #print "fog_msg.toxml called" |
77 #print "use_fog :",self.use_fog | 75 #print "use_fog :",self.use_fog |
78 #print "output_action :",output_action | 76 #print "output_action :",output_action |
79 #print "action :",action | 77 #print "action :",action |
80 if not (self.use_fog): | 78 if not (self.use_fog): return "" |
81 return "" | |
82 fog_string = "" | 79 fog_string = "" |
83 if self.fogregion.isEmpty(): | 80 if self.fogregion.isEmpty(): fog_string=self.get_line("all","del",output_action) |
84 fog_string=self.get_line("all","del",output_action) | |
85 for ri in self.fogregion.GetRectList(): | 81 for ri in self.fogregion.GetRectList(): |
86 x1=ri.GetX() | 82 x1=ri.GetX() |
87 x2=x1+ri.GetW()-1 | 83 x2=x1+ri.GetW()-1 |
88 y1=ri.GetY() | 84 y1=ri.GetY() |
89 y2=y1+ri.GetH()-1 | 85 y2=y1+ri.GetH()-1 |
94 s = "<fog" | 90 s = "<fog" |
95 if fog_string: | 91 if fog_string: |
96 s += ">" | 92 s += ">" |
97 s += fog_string | 93 s += fog_string |
98 s += "</fog>" | 94 s += "</fog>" |
99 else: | 95 else: s+="/>" |
100 s+="/>" | |
101 return s | 96 return s |
102 | 97 |
103 def interpret_dom(self,xml_dom): | 98 def interpret_dom(self,xml_dom): |
104 self.use_fog=1 | 99 self.use_fog=1 |
105 #print 'fog_msg.interpret_dom called' | 100 #print 'fog_msg.interpret_dom called' |
125 # for m in range(len(pointarray)): | 120 # for m in range(len(pointarray)): |
126 # pt=pointarray[m].split(",") | 121 # pt=pointarray[m].split(",") |
127 # polyline.append(IPoint().make(int(pt[0]),int(pt[1]))) | 122 # polyline.append(IPoint().make(int(pt[0]),int(pt[1]))) |
128 #print "length of polyline", len(polyline) | 123 #print "length of polyline", len(polyline) |
129 if (len(polyline)>2): | 124 if (len(polyline)>2): |
130 if action=="del": | 125 if action=="del": self.fogregion.FromPolygon(polyline,0) |
131 self.fogregion.FromPolygon(polyline,0) | 126 else: self.fogregion.FromPolygon(polyline,1) |
132 else: | |
133 self.fogregion.FromPolygon(polyline,1) | |
134 | 127 |
135 def init_from_dom(self,xml_dom): | 128 def init_from_dom(self,xml_dom): |
136 self.interpret_dom(xml_dom) | 129 self.interpret_dom(xml_dom) |