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.4 by root, Fri Apr 7 18:49:53 2006 UTC vs.
Revision 1.10 by root, Fri Apr 7 20:34:44 2006 UTC

1package Client::Widget; 1package Crossfire::Client::Widget;
2
2use strict; 3use strict;
3 4
4our $FOCUS; # the widget with current focus 5our $FOCUS; # the widget with current focus
5our %ACTIVE_WIDGETS; 6our %ACTIVE_WIDGETS;
6 7
10sub feed_sdl_button_down_event { $FOCUS->button_down ($_[0]) if $FOCUS } 11sub feed_sdl_button_down_event { $FOCUS->button_down ($_[0]) if $FOCUS }
11sub feed_sdl_button_up_event { $FOCUS->button_up ($_[0]) if $FOCUS } 12sub feed_sdl_button_up_event { $FOCUS->button_up ($_[0]) if $FOCUS }
12 13
13sub new { 14sub new {
14 my $class = shift; 15 my $class = shift;
15 my $self = { @_ }; 16
16 bless $self, $class; 17 bless { @_ }, $class
17 return $self;
18} 18}
19 19
20sub activate { 20sub activate {
21 $ACTIVE_WIDGETS{$_[0]} = $_[0]; 21 $ACTIVE_WIDGETS{$_[0]} = $_[0];
22} 22}
56 56
57sub bbox { 57sub bbox {
58 my ($widget) = @_; 58 my ($widget) = @_;
59} 59}
60 60
61package 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;
62 94
63use strict; 95use strict;
96
64our @ISA = qw/Client::Widget/; 97our @ISA = qw/Crossfire::Client::Widget/;
65 98
66use SDL::OpenGL; 99use SDL::OpenGL;
67use SDL::OpenGL::Constants; 100use SDL::OpenGL::Constants;
68 101
69sub add_line { 102sub add_line {
74sub draw { 107sub draw {
75 my ($self) = @_; 108 my ($self) = @_;
76 109
77} 110}
78 111
79package Client::MapWidget; 112package Crossfire::Client::Widget::MapWidget;
80 113
81use strict; 114use strict;
115
82our @ISA = qw/Client::Widget/; 116our @ISA = qw/Crossfire::Client::Widget/;
83 117
84use SDL::OpenGL; 118use SDL::OpenGL;
85use SDL::OpenGL::Constants; 119use SDL::OpenGL::Constants;
86 120
87sub key_down { 121sub key_down {
110 my $tex = $::CONN->{face}[$num]{texture} || next; 144 my $tex = $::CONN->{face}[$num]{texture} || next;
111 145
112 glBindTexture GL_TEXTURE_2D, $tex->{name}; 146 glBindTexture GL_TEXTURE_2D, $tex->{name};
113 147
114 glBegin GL_QUADS; 148 glBegin GL_QUADS;
115 glTexCoord 0, 0; glVertex $x, $y; 149 glTexCoord 0, 0; glVertex $x * 32 , $y * 32;
116 glTexCoord 0, 1; glVertex $x, $y + 1; 150 glTexCoord 0, 1; glVertex $x * 32 , $y * 32 + 32;
117 glTexCoord 1, 1; glVertex $x + 1, $y + 1; 151 glTexCoord 1, 1; glVertex $x * 32 + 32, $y * 32 + 32;
118 glTexCoord 1, 0; glVertex $x + 1, $y; 152 glTexCoord 1, 0; glVertex $x * 32 + 32, $y * 32;
119 glEnd; 153 glEnd;
120 } 154 }
121 } 155 }
122 } 156 }
123 157
124 glDisable GL_TEXTURE_2D; 158 glDisable GL_TEXTURE_2D;
125 glDisable GL_BLEND; 159 glDisable GL_BLEND;
126} 160}
127 161
1281; 1621;
163

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines