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.1 by elmex, Fri Apr 7 17:18:22 2006 UTC vs.
Revision 1.7 by elmex, Fri Apr 7 20:04:59 2006 UTC

1package Client::Widget; 1package Crossfire::Client::Widget;
2use strict; 2use strict;
3 3
4our $FOCUS; # the widget with current focus 4our $FOCUS; # the widget with current focus
5our @ACTIVE_WIDGETS; 5our %ACTIVE_WIDGETS;
6 6
7# class methods for events 7# class methods for events
8sub feed_sdl_key_down_event { $FOCUS->key_down ($_[0]) if $FOCUS } 8sub feed_sdl_key_down_event { $FOCUS->key_down ($_[0]) if $FOCUS }
9sub feed_sdl_key_up_event { $FOCUS->key_up ($_[0]) if $FOCUS } 9sub feed_sdl_key_up_event { $FOCUS->key_up ($_[0]) if $FOCUS }
10sub feed_sdl_button_down_event { $FOCUS->button_down ($_[0]) if $FOCUS } 10sub feed_sdl_button_down_event { $FOCUS->button_down ($_[0]) if $FOCUS }
15 my $self = { @_ }; 15 my $self = { @_ };
16 bless $self, $class; 16 bless $self, $class;
17 return $self; 17 return $self;
18} 18}
19 19
20sub activate {
21 $ACTIVE_WIDGETS{$_[0]} = $_[0];
22}
23
24sub deactivate {
25 delete $ACTIVE_WIDGETS{$_[0]};
26}
27
20sub focus_in { 28sub focus_in {
21 my ($widget) = @_; 29 my ($widget) = @_;
22 $FOCUS = $widget; 30 $FOCUS = $widget;
23} 31}
32
24sub focus_out { 33sub focus_out {
25 my ($widget) = @_; 34 my ($widget) = @_;
26} 35}
36
27sub key_down { 37sub key_down {
28 my ($widget, $sdlev) = @_; 38 my ($widget, $sdlev) = @_;
29} 39}
40
30sub key_up { 41sub key_up {
31 my ($widget, $sdlev) = @_; 42 my ($widget, $sdlev) = @_;
32} 43}
44
33sub button_down { 45sub button_down {
34 my ($widget, $sdlev) = @_; 46 my ($widget, $sdlev) = @_;
35} 47}
48
36sub button_up { 49sub button_up {
37 my ($widget, $sdlev) = @_; 50 my ($widget, $sdlev) = @_;
38} 51}
52
39sub draw { 53sub draw {
40 my ($widget) = @_; 54 my ($widget) = @_;
41} 55}
56
42sub bbox { 57sub bbox {
43 my ($widget) = @_; 58 my ($widget) = @_;
44} 59}
60
61package Client::TextView;
62
63use strict;
64our @ISA = qw/Client::Widget/;
65
66use SDL::OpenGL;
67use SDL::OpenGL::Constants;
68
69sub add_line {
70 my ($self, $line) = @_;
71 push @{$self->{lines}}, $line;
72}
73
74sub draw {
75 my ($self) = @_;
76
77}
78
79package Client::MapWidget;
80
81use strict;
82
83our @ISA = qw/Client::Widget/;
84
85use SDL::OpenGL;
86use SDL::OpenGL::Constants;
87
88sub key_down {
89 print "MAPKEYDOWN\n";
90}
91
92sub key_up {
93}
94
95my $x;
96
97sub draw {
98 glEnable GL_TEXTURE_2D;
99 glEnable GL_BLEND;
100
101 glPushMatrix;
102
103 my $map = $::CONN->{map};
104
105 for my $x (0 .. $::CONN->{mapw} - 1) {
106 for my $y (0 .. $::CONN->{maph} - 1) {
107
108 my $cell = $map->[$x][$y]
109 or next;
110
111 my $darkness = $cell->[3] * (1 / 255);
112 glColor $darkness, $darkness, $darkness;
113
114 for my $num (grep $_, $cell->[0], $cell->[1], $cell->[2]) {
115 my $tex = $::CONN->{face}[$num]{texture} || next;
116
117 glBindTexture GL_TEXTURE_2D, $tex->{name};
118
119 glBegin GL_QUADS;
120 glTexCoord 0, 0; glVertex $x, $y;
121 glTexCoord 0, 1; glVertex $x, $y + 1;
122 glTexCoord 1, 1; glVertex $x + 1, $y + 1;
123 glTexCoord 1, 0; glVertex $x + 1, $y;
124 glEnd;
125 }
126 }
127 }
128
129 glPopMatrix;
130
131 glDisable GL_TEXTURE_2D;
132 glDisable GL_BLEND;
133}
134
451; 1351;
136

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines