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.8 by root, Fri Apr 7 20:08:57 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 Client::TextView;
63
64use strict;
65
66our @ISA = qw/Client::Widget/;
67
68use SDL::OpenGL;
69use SDL::OpenGL::Constants;
70
71sub add_line {
72 my ($self, $line) = @_;
73 push @{$self->{lines}}, $line;
74}
75
76sub draw {
77 my ($self) = @_;
78
79}
80
81package Client::MapWidget;
82
83use strict;
84
85our @ISA = qw/Client::Widget/;
86
87use SDL::OpenGL;
88use SDL::OpenGL::Constants;
89
90sub key_down {
91 print "MAPKEYDOWN\n";
92}
93
94sub key_up {
95}
96
97sub draw {
98 glEnable GL_TEXTURE_2D;
99 glEnable GL_BLEND;
100
101 my $map = $::CONN->{map};
102
103 for my $x (0 .. $::CONN->{mapw} - 1) {
104 for my $y (0 .. $::CONN->{maph} - 1) {
105
106 my $cell = $map->[$x][$y]
107 or next;
108
109 my $darkness = $cell->[3] * (1 / 255);
110 glColor $darkness, $darkness, $darkness;
111
112 for my $num (grep $_, $cell->[0], $cell->[1], $cell->[2]) {
113 my $tex = $::CONN->{face}[$num]{texture} || next;
114
115 glBindTexture GL_TEXTURE_2D, $tex->{name};
116
117 glBegin GL_QUADS;
118 glTexCoord 0, 0; glVertex $x, $y;
119 glTexCoord 0, 1; glVertex $x, $y + 1;
120 glTexCoord 1, 1; glVertex $x + 1, $y + 1;
121 glTexCoord 1, 0; glVertex $x + 1, $y;
122 glEnd;
123 }
124 }
125 }
126
127 glDisable GL_TEXTURE_2D;
128 glDisable GL_BLEND;
129}
130
451; 1311;
132

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines