ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/kgsueme/kgsueme/room.pl
(Generate patch)

Comparing kgsueme/kgsueme/room.pl (file contents):
Revision 1.23 by pcg, Sun May 30 06:40:21 2004 UTC vs.
Revision 1.33 by elmex, Tue Jun 8 19:00:39 2004 UTC

7use Glib::Object::Subclass 7use Glib::Object::Subclass
8 Gtk2::Frame; 8 Gtk2::Frame;
9 9
10sub new { 10sub new {
11 my ($self, %arg) = @_; 11 my ($self, %arg) = @_;
12
12 $self = $self->Glib::Object::new; 13 $self = $self->Glib::Object::new;
13 $self->{$_} = delete $arg{$_} for keys %arg; 14 $self->{$_} = delete $arg{$_} for keys %arg;
14 15
15 $self->signal_connect (destroy => sub { 16 $self->signal_connect (destroy => sub {
16 delete $::config->{rooms}{$self->{channel}}; 17 delete $::config->{rooms}{$self->{channel}};
22 23
23 $self->listen ($self->{conn}, qw(msg_room:)); 24 $self->listen ($self->{conn}, qw(msg_room:));
24 25
25 $self->signal_connect (delete_event => sub { $self->part; 1 }); 26 $self->signal_connect (delete_event => sub { $self->part; 1 });
26 27
27 $self->add (my $hbox = new Gtk2::HBox); 28 $self->add (my $hpane = new Gtk2::HPaned);
29 gtk::state $hpane, "room::hpane", undef, position => 500;
28 30
29 $hbox->pack_start ((my $vbox = new Gtk2::VBox), 1, 1, 0); 31 $hpane->pack1 (($self->{chat} = new chat app => $self->{app}), 1, 0);
30 32
31 $vbox->add ($self->{chat} = new chat);
32
33 $self->{chat}->signal_connect(command => sub { 33 $self->{chat}->signal_connect (command => sub {
34 my ($chat, $cmd, $arg) = @_; 34 my ($chat, $cmd, $arg) = @_;
35 $self->{app}->do_command ($chat, $cmd, $arg, userlist => $self->{userlist}, room => $self); 35 $self->{app}->do_command ($chat, $cmd, $arg, userlist => $self->{userlist}, room => $self);
36 }); 36 });
37 37
38 $hbox->pack_start ((my $vbox = new Gtk2::VBox), 0, 1, 0); 38 $hpane->pack2 ((my $vbox = new Gtk2::VBox), 1, 0);
39 39
40 $vbox->pack_start ((my $button = new_with_label Gtk2::Button "Close"), 0, 1, 0); 40 $vbox->pack_start ((my $button = new_with_label Gtk2::Button "Leave"), 0, 1, 0);
41 $button->signal_connect (clicked => sub { $self->part }); 41 $button->signal_connect (clicked => sub { $self->part });
42 42
43 $vbox->pack_start ((my $button = new_with_label Gtk2::Button "New Game"), 0, 1, 0); 43 $vbox->pack_start ((my $button = new_with_label Gtk2::Button "New Game"), 0, 1, 0);
44 $button->signal_connect (clicked => sub { $self->new_game }); 44 $button->signal_connect (clicked => sub { $self->new_game });
45 $vbox->pack_start((my $sw = new Gtk2::ScrolledWindow), 1, 1, 0);
45 46
46 $vbox->pack_start ((my $sw = new Gtk2::ScrolledWindow), 1, 1, 0);
47 $sw->set_policy("automatic", "always"); 47 $sw->set_policy ("automatic", "always");
48 48
49 $sw->add ($self->{userlist} = new userlist); 49 $sw->add ($self->{userlist} = new userlist);
50 50
51 $self; 51 $self;
52} 52}
53 53
54sub FINALIZE_INSTANCE { print "FIN room\n" } # never called MEMLEAK #d#TODO# 54sub FINALIZE_INSTANCE { print "FIN room\n" } # never called MEMLEAK #d#TODO#
55 55
56sub part { 56sub part {
57 my ($self) = @_; 57 my ($self) = @_;
58
59 $self->hide;
58 $self->SUPER::part; 60 $self->SUPER::part;
59
60 $self->hide_all;
61} 61}
62 62
63sub inject_msg_room { 63sub inject_msg_room {
64 my ($self, $msg) = @_; 64 my ($self, $msg) = @_;
65 65
66 # secret typoe ;-) 66 # secret typoe ;-)
67 $self->{chat}->append_text ("\n<header><user>" . (util::toxml $msg->{name}) 67 $self->{chat}->append_text ("\n<user>" . (util::toxml $msg->{name})
68 . "</user>: </header>" . (util::toxml $msg->{message})); 68 . "</user>: " . (util::toxml $msg->{message}));
69} 69}
70 70
71sub event_update_users { 71sub event_update_users {
72 my ($self, $add, $update, $remove) = @_; 72 my ($self, $add, $update, $remove) = @_;
73 73
114 114
115 $self->SUPER::event_part; 115 $self->SUPER::event_part;
116 $self->destroy; 116 $self->destroy;
117} 117}
118 118
119sub event_quit {
120 my ($self) = @_;
121
122 $self->SUPER::event_quit;
123 $self->destroy;
124}
125
119sub event_update_roominfo { 126sub event_update_roominfo {
120 my ($self) = @_; 127 my ($self) = @_;
121 128
122 $self->{chat}->append_text("\n<user>" . (util::toxml $self->{owner}) . "</user>\n" 129 $self->{chat}->append_text("\n<user>" . (util::toxml $self->{owner}) . "</user>\n"
123 . "<description>" . (util::toxml $self->{description}) . "</description>\n"); 130 . "<description>" . (util::toxml $self->{description}) . "</description>\n");
124} 131}
125 132
126sub new_game { 133sub new_game {
127 my ($self) = @_; 134 my ($self) = @_;
128 135
129 my $d = $self->{app}{defaults};
130
131 my $game = new game conn => $self->{conn}, app => $self->{app}, roomid => $self->{channel}; 136 my $game = new game conn => $self->{conn}, app => $self->{app}, roomid => $self->{channel};
132 $game->{challenge}{""} = { 137 $game->new_game_challenge;
133 gametype => $d->{gametype},
134 flags => 0,
135 notes => $d->{stones},
136 rules => {
137 ruleset => $d->{ruleset},
138 size => $d->{size},
139 timesys => $d->{timesys},
140 time => $d->{time},
141 interval => $d->{timesys} == TIMESYS_BYO_YOMI ? $d->{byo_time} : $d->{can_time},
142 count => $d->{timesys} == TIMESYS_BYO_YOMI ? $d->{byo_periods} : $d->{can_stones},
143 },
144
145 inlay => $game->{chat}->new_inlay,
146 };
147 $game->draw_challenge ("");
148 $game->show_all; 138 $game->show_all;
149 139
150 push @{$self->{new_game}}, $game; 140 push @{$self->{new_game}}, $game;
151} 141}
152 142

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines