ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/UI.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/UI.pm (file contents):
Revision 1.10 by root, Fri Apr 7 20:34:44 2006 UTC vs.
Revision 1.12 by root, Fri Apr 7 20:55:32 2006 UTC

1package Crossfire::Client::Widget; 1package Crossfire::Client::Widget;
2 2
3use strict; 3use strict;
4use SDL::OpenGL;
5use SDL::OpenGL::Constants;
4 6
5our $FOCUS; # the widget with current focus 7our $FOCUS; # the widget with current focus
6our %ACTIVE_WIDGETS; 8our %ACTIVE_WIDGETS;
7 9
8# class methods for events 10# class methods for events
48 50
49sub button_up { 51sub button_up {
50 my ($widget, $sdlev) = @_; 52 my ($widget, $sdlev) = @_;
51} 53}
52 54
55sub x { $_[0]->{x} = $_[1] if $_[1]; $_[0]->{x} }
56sub y { $_[0]->{y} = $_[1] if $_[1]; $_[0]->{y} }
57
53sub draw { 58sub draw {
59 my ($self) = @_;
60
61 glPushMatrix;
62 glTranslate $self->{x}, $self->{y}, 0;
63 $self->_draw;
64 glPopMatrix;
65}
66
67sub _draw {
54 my ($widget) = @_; 68 my ($widget) = @_;
55} 69}
56 70
57sub bbox { 71sub bbox {
58 my ($widget) = @_; 72 my ($widget) = @_;
59} 73}
60 74
61package Crossfire::Client::Widget::Label; 75package Crossfire::Client::Widget::Label;
62 76
77our @ISA = Crossfire::Client::Widget::;
78
63use SDL::OpenGL; 79use SDL::OpenGL;
64 80
65sub new { 81sub new {
66 my ($class, $ttf, $text) = @_; 82 my ($class, $x, $y, $z, $ttf, $text) = @_;
67 83
68 my $self = $class->SUPER::new; 84 my $self = $class->SUPER::new (x => $x, y => $y, z => $z);
69 85
70 $self->{texture} = new_from_ttf Crossfire::Client::Texture $ttf, $text; 86 $self->{texture} = new_from_ttf Crossfire::Client::Texture $ttf, $text;
71 87
72 $self 88 $self
73} 89}
74 90
75sub draw { 91sub _draw {
76 my ($self) = @_; 92 my ($self) = @_;
77 93
78 my $tex = $self->{texture}; 94 my $tex = $self->{texture};
79 95
96 $self->{x}--;
97
98 glEnable GL_BLEND;
80 glEnable GL_TEXTURE_2D; 99 glEnable GL_TEXTURE_2D;
100 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE;
81 glBindTexture GL_TEXTURE_2D, $tex->{name}; 101 glBindTexture GL_TEXTURE_2D, $tex->{name};
102
103 glColor 1, 1, 1;
82 104
83 glBegin GL_QUADS; 105 glBegin GL_QUADS;
84 glTexCoord 0, 0; glVertex 0 , 0; 106 glTexCoord 0, 0; glVertex 0 , 0;
85 glTexCoord 0, 1; glVertex 0 , $tex->{height}; 107 glTexCoord 0, 1; glVertex 0 , $tex->{height};
86 glTexCoord 1, 1; glVertex $tex->{width}, $tex->{height}; 108 glTexCoord 1, 1; glVertex $tex->{width}, $tex->{height};
87 glTexCoord 1, 0; glVertex $tex->{width}, 0; 109 glTexCoord 1, 0; glVertex $tex->{width}, 0;
88 glEnd; 110 glEnd;
89 111
112 glDisable GL_BLEND;
90 glDisable GL_TEXTURE_2D; 113 glDisable GL_TEXTURE_2D;
91} 114}
92 115
93package Crossfire::Client::Widget::TextView; 116package Crossfire::Client::Widget::TextView;
94 117
102sub add_line { 125sub add_line {
103 my ($self, $line) = @_; 126 my ($self, $line) = @_;
104 push @{$self->{lines}}, $line; 127 push @{$self->{lines}}, $line;
105} 128}
106 129
107sub draw { 130sub _draw {
108 my ($self) = @_; 131 my ($self) = @_;
109 132
110} 133}
111 134
112package Crossfire::Client::Widget::MapWidget; 135package Crossfire::Client::Widget::MapWidget;
123} 146}
124 147
125sub key_up { 148sub key_up {
126} 149}
127 150
128sub draw { 151sub _draw {
129 glEnable GL_TEXTURE_2D; 152 glEnable GL_TEXTURE_2D;
130 glEnable GL_BLEND; 153 glEnable GL_BLEND;
154 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE;
131 155
132 my $map = $::CONN->{map}; 156 my $map = $::CONN->{map};
133 157
134 for my $x (0 .. $::CONN->{mapw} - 1) { 158 for my $x (0 .. $::CONN->{mapw} - 1) {
135 for my $y (0 .. $::CONN->{maph} - 1) { 159 for my $y (0 .. $::CONN->{maph} - 1) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines