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.8 by root, Fri Apr 7 20:08:57 2006 UTC vs.
Revision 1.10 by root, Fri Apr 7 20:34:44 2006 UTC

11sub feed_sdl_button_down_event { $FOCUS->button_down ($_[0]) if $FOCUS } 11sub feed_sdl_button_down_event { $FOCUS->button_down ($_[0]) if $FOCUS }
12sub feed_sdl_button_up_event { $FOCUS->button_up ($_[0]) if $FOCUS } 12sub feed_sdl_button_up_event { $FOCUS->button_up ($_[0]) if $FOCUS }
13 13
14sub new { 14sub new {
15 my $class = shift; 15 my $class = shift;
16 my $self = { @_ }; 16
17 bless $self, $class; 17 bless { @_ }, $class
18 return $self;
19} 18}
20 19
21sub activate { 20sub activate {
22 $ACTIVE_WIDGETS{$_[0]} = $_[0]; 21 $ACTIVE_WIDGETS{$_[0]} = $_[0];
23} 22}
57 56
58sub bbox { 57sub bbox {
59 my ($widget) = @_; 58 my ($widget) = @_;
60} 59}
61 60
62package Client::TextView; 61package Crossfire::Client::Widget::Label;
62
63use SDL::OpenGL;
64
65sub new {
66 my ($class, $ttf, $text) = @_;
67
68 my $self = $class->SUPER::new;
69
70 $self->{texture} = new_from_ttf Crossfire::Client::Texture $ttf, $text;
71
72 $self
73}
74
75sub draw {
76 my ($self) = @_;
77
78 my $tex = $self->{texture};
79
80 glEnable GL_TEXTURE_2D;
81 glBindTexture GL_TEXTURE_2D, $tex->{name};
82
83 glBegin GL_QUADS;
84 glTexCoord 0, 0; glVertex 0 , 0;
85 glTexCoord 0, 1; glVertex 0 , $tex->{height};
86 glTexCoord 1, 1; glVertex $tex->{width}, $tex->{height};
87 glTexCoord 1, 0; glVertex $tex->{width}, 0;
88 glEnd;
89
90 glDisable GL_TEXTURE_2D;
91}
92
93package Crossfire::Client::Widget::TextView;
63 94
64use strict; 95use strict;
65 96
66our @ISA = qw/Client::Widget/; 97our @ISA = qw/Crossfire::Client::Widget/;
67 98
68use SDL::OpenGL; 99use SDL::OpenGL;
69use SDL::OpenGL::Constants; 100use SDL::OpenGL::Constants;
70 101
71sub add_line { 102sub add_line {
76sub draw { 107sub draw {
77 my ($self) = @_; 108 my ($self) = @_;
78 109
79} 110}
80 111
81package Client::MapWidget; 112package Crossfire::Client::Widget::MapWidget;
82 113
83use strict; 114use strict;
84 115
85our @ISA = qw/Client::Widget/; 116our @ISA = qw/Crossfire::Client::Widget/;
86 117
87use SDL::OpenGL; 118use SDL::OpenGL;
88use SDL::OpenGL::Constants; 119use SDL::OpenGL::Constants;
89 120
90sub key_down { 121sub key_down {
113 my $tex = $::CONN->{face}[$num]{texture} || next; 144 my $tex = $::CONN->{face}[$num]{texture} || next;
114 145
115 glBindTexture GL_TEXTURE_2D, $tex->{name}; 146 glBindTexture GL_TEXTURE_2D, $tex->{name};
116 147
117 glBegin GL_QUADS; 148 glBegin GL_QUADS;
118 glTexCoord 0, 0; glVertex $x, $y; 149 glTexCoord 0, 0; glVertex $x * 32 , $y * 32;
119 glTexCoord 0, 1; glVertex $x, $y + 1; 150 glTexCoord 0, 1; glVertex $x * 32 , $y * 32 + 32;
120 glTexCoord 1, 1; glVertex $x + 1, $y + 1; 151 glTexCoord 1, 1; glVertex $x * 32 + 32, $y * 32 + 32;
121 glTexCoord 1, 0; glVertex $x + 1, $y; 152 glTexCoord 1, 0; glVertex $x * 32 + 32, $y * 32;
122 glEnd; 153 glEnd;
123 } 154 }
124 } 155 }
125 } 156 }
126 157

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines