~ubuntu-branches/ubuntu/saucy/ricochet/saucy

« back to all changes in this revision

Viewing changes to client-draw.5c

  • Committer: Package Import Robot
  • Author(s): Keith Packard
  • Date: 2012-06-11 13:37:57 UTC
  • Revision ID: package-import@ubuntu.com-20120611133757-zn0ukd22vz56ymto
Tags: 0.3
* Improve appearance of board
* Fix user list when removing/adding same user

Show diffs side-by-side

added added

removed removed

Lines of Context:
92
92
                }
93
93
 
94
94
                dimensions_t cell_dim  = get_dimensions(cell[0].svg);
 
95
                dimensions_t wall_dim  = get_dimensions(wall.svg);
95
96
 
96
97
                public int cell_width = cell_dim.width;
97
98
                public int cell_height = cell_dim.height;
98
99
 
99
 
                void draw_cached_sprite(&sprite_t sprite, cairo_t cr, &transform_t t) {
 
100
                public int wall_thickness = wall_dim.height;
 
101
 
 
102
                void draw_cached_sprite(&sprite_t sprite, cairo_t cr, &transform_t t, real alpha) {
100
103
                        int     width = ceil(cell_width * t.xscale);
101
104
                        int     height = ceil(cell_width * t.yscale);
102
105
 
118
121
                        }
119
122
                        if (sprite.width > 0 && sprite.height > 0) {
120
123
                                set_source_surface(cr, sprite.surface, 0, 0);
121
 
                                paint(cr);
 
124
                                if (alpha != 1)
 
125
                                        paint_with_alpha(cr, alpha);
 
126
                                else
 
127
                                        paint(cr);
122
128
                        }
123
129
                        restore(cr);
124
130
                }
127
133
                        save(cr);
128
134
                        translate(cr, x * cell_width * t.xscale + t.xoff, y * cell_height * t.yscale + t.yoff);
129
135
 
130
 
                        draw_cached_sprite(&cell[x+y & 1], cr, &t);
 
136
                        draw_cached_sprite(&cell[x+y & 1], cr, &t, 1);
131
137
                        restore(cr);
132
138
                }
133
139
                
136
142
                        translate(cr, t.xoff, t.yoff);
137
143
                        scale(cr, t.xscale, t.yscale);
138
144
                        translate(cr, x * cell_width, y * cell_height);
 
145
                        /*
139
146
                        rectangle(cr, 0, 0, cell_width, cell_height);
140
147
                        clip(cr);
 
148
                        */
141
149
 
142
150
                        void draw_wall (bool doit, bool vertical, bool shift) {
143
151
                                if (!doit) return;
153
161
                        }
154
162
                        draw_wall (object.walls.left, true, false);
155
163
                        draw_wall (object.walls.above, false, false);
156
 
                        draw_wall (object.walls.right, true, true);
157
 
                        draw_wall (object.walls.below, false, true);
 
164
                        if (x == 15)
 
165
                                draw_wall (object.walls.right, true, true);
 
166
                        if (y == 15)
 
167
                                draw_wall (object.walls.below, false, true);
158
168
                        restore(cr);
159
169
                }
160
170
                
161
 
                public void contents (cairo_t cr, int x, int y, RR::Object object, RR::RobotOrNone active_robot,
 
171
                public void contents (cairo_t cr, int x, int y, RR::Object object,
 
172
                                      RR::TargetOrNone active_target,
 
173
                                      RR::RobotOrNone active_robot,
162
174
                                      &transform_t t) {
163
175
                        save(cr);
164
176
                        translate(cr, x * cell_width * t.xscale + t.xoff, y * cell_height * t.yscale + t.yoff);
167
179
                        case none:
168
180
                                break;
169
181
                        case target target:
170
 
                                draw_cached_sprite(&targets[target.color][target.shape], cr, &t);
 
182
                                real alpha = 1;
 
183
                                if (object.target != active_target)
 
184
                                        alpha = 0.25;
 
185
                                draw_cached_sprite(&targets[target.color][target.shape], cr, &t, alpha);
171
186
                                break;
172
187
                        }
173
188
                        union switch(object.robot) {
187
202
                                        break;
188
203
                                default:
189
204
                                }
190
 
                                draw_cached_sprite(&robots[r.color], cr, &t);
 
205
                                draw_cached_sprite(&robots[r.color], cr, &t, 1);
191
206
                                break;
192
207
                        }
193
208
                        restore(cr);