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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines