… | |
… | |
291 | |
291 | |
292 | our @ISA = Crossfire::Client::Widget::Frame::; |
292 | our @ISA = Crossfire::Client::Widget::Frame::; |
293 | |
293 | |
294 | use SDL::OpenGL; |
294 | use SDL::OpenGL; |
295 | |
295 | |
296 | #TODO: implement themed frame |
296 | sub new { |
|
|
297 | my ($self, $theme) = @_; |
|
|
298 | $self = $self->SUPER::new; |
|
|
299 | |
|
|
300 | $self->{txts} = [ |
|
|
301 | map { new_from_file Crossfire::Client::Texture Crossfire::Client::find_rcfile $_ } |
|
|
302 | qw/d1_bg.png d1_border_top.png d1_border_right.png d1_border_left.png d1_border_bottom.png/ |
|
|
303 | ]; |
|
|
304 | $self |
|
|
305 | |
|
|
306 | } |
|
|
307 | |
|
|
308 | sub size_request { |
|
|
309 | my ($self) = @_; |
|
|
310 | my ($w, $h) = $self->get->size_request; |
|
|
311 | |
|
|
312 | $h += $self->{txts}->[1]->{height}; |
|
|
313 | $h += $self->{txts}->[4]->{height}; |
|
|
314 | $w += $self->{txts}->[2]->{width}; |
|
|
315 | $w += $self->{txts}->[3]->{width}; |
|
|
316 | |
|
|
317 | $self->get->move ($self->{txts}->[3]->{width}, $self->{txts}->[1]->{height}); |
|
|
318 | |
|
|
319 | ($w, $h) |
|
|
320 | } |
|
|
321 | |
|
|
322 | sub _draw { |
|
|
323 | my ($self) = @_; |
|
|
324 | |
|
|
325 | my ($w, $h) = $self->size_request; |
|
|
326 | my ($cw, $ch) = $self->get->size_request; |
|
|
327 | |
|
|
328 | glEnable GL_BLEND; |
|
|
329 | glEnable GL_TEXTURE_2D; |
|
|
330 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
|
|
331 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; |
|
|
332 | |
|
|
333 | |
|
|
334 | my $top = $self->{txts}->[1]; |
|
|
335 | glBindTexture GL_TEXTURE_2D, $top->{name}; |
|
|
336 | |
|
|
337 | glColor 1, 1, 1, 0.8; |
|
|
338 | |
|
|
339 | glBegin GL_QUADS; |
|
|
340 | glTexCoord 0, 0; glVertex 0 , 0; |
|
|
341 | glTexCoord 0, 1; glVertex 0 , $top->{height}; |
|
|
342 | glTexCoord 1, 1; glVertex $w , $top->{height}; |
|
|
343 | glTexCoord 1, 0; glVertex $w , 0; |
|
|
344 | glEnd; |
|
|
345 | |
|
|
346 | my $left = $self->{txts}->[3]; |
|
|
347 | glBindTexture GL_TEXTURE_2D, $left->{name}; |
|
|
348 | |
|
|
349 | glColor 1, 1, 1, 0.8; |
|
|
350 | |
|
|
351 | glBegin GL_QUADS; |
|
|
352 | glTexCoord 0, 0; glVertex 0 , $top->{height}; |
|
|
353 | glTexCoord 0, 1; glVertex 0 , $top->{height} + $ch; |
|
|
354 | glTexCoord 1, 1; glVertex $left->{width}, $top->{height} + $ch; |
|
|
355 | glTexCoord 1, 0; glVertex $left->{width}, $top->{height}; |
|
|
356 | glEnd; |
|
|
357 | |
|
|
358 | my $right = $self->{txts}->[2]; |
|
|
359 | glBindTexture GL_TEXTURE_2D, $right->{name}; |
|
|
360 | |
|
|
361 | glColor 1, 1, 1, 0.8; |
|
|
362 | |
|
|
363 | glBegin GL_QUADS; |
|
|
364 | glTexCoord 0, 0; glVertex $w - $right->{width}, $top->{height}; |
|
|
365 | glTexCoord 0, 1; glVertex $w - $right->{width}, $top->{height} + $ch; |
|
|
366 | glTexCoord 1, 1; glVertex $w , $top->{height} + $ch; |
|
|
367 | glTexCoord 1, 0; glVertex $w , $top->{height}; |
|
|
368 | glEnd; |
|
|
369 | |
|
|
370 | my $bottom = $self->{txts}->[4]; |
|
|
371 | glBindTexture GL_TEXTURE_2D, $bottom->{name}; |
|
|
372 | |
|
|
373 | glColor 1, 1, 1, 0.8; |
|
|
374 | |
|
|
375 | glBegin GL_QUADS; |
|
|
376 | glTexCoord 0, 0; glVertex 0 , $h - $bottom->{height}; |
|
|
377 | glTexCoord 0, 1; glVertex 0 , $h; |
|
|
378 | glTexCoord 1, 1; glVertex $w , $h; |
|
|
379 | glTexCoord 1, 0; glVertex $w , $h - $bottom->{height}; |
|
|
380 | glEnd; |
|
|
381 | |
|
|
382 | my $bg = $self->{txts}->[0]; |
|
|
383 | glBindTexture GL_TEXTURE_2D, $bg->{name}; |
|
|
384 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT; |
|
|
385 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT; |
|
|
386 | |
|
|
387 | glColor 1, 1, 1, 0.8; |
|
|
388 | |
|
|
389 | my $rep_x = $cw / $bg->{width}; |
|
|
390 | my $rep_y = $ch / $bg->{height}; |
|
|
391 | |
|
|
392 | glBegin GL_QUADS; |
|
|
393 | glTexCoord 0, 0; glVertex $left->{width}, $top->{height}; |
|
|
394 | glTexCoord 0, $rep_y; glVertex $left->{width}, $top->{height} + $ch; |
|
|
395 | glTexCoord $rep_x, $rep_y; glVertex $left->{width} + $cw , $top->{height} + $ch; |
|
|
396 | glTexCoord $rep_x, 0; glVertex $left->{width} + $cw , $top->{height}; |
|
|
397 | glEnd; |
|
|
398 | |
|
|
399 | $self->get->draw; |
|
|
400 | |
|
|
401 | glDisable GL_BLEND; |
|
|
402 | glDisable GL_TEXTURE_2D; |
|
|
403 | } |
297 | |
404 | |
298 | package Crossfire::Client::Widget::Table; |
405 | package Crossfire::Client::Widget::Table; |
299 | |
406 | |
300 | our @ISA = Crossfire::Client::Widget::Container::; |
407 | our @ISA = Crossfire::Client::Widget::Container::; |
301 | |
408 | |