This repository has been archived by the owner on Dec 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
scoreboard.pl
108 lines (97 loc) · 3.52 KB
/
scoreboard.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/usr/bin/perl
# SVN ID: $Id$
use warnings;
use strict;
my $title = "Mr. Voice Scorekeeper Plugin";
our $pluginmenu;
our $menubar;
our $mw;
our $icon;
my $font;
if ( $^O eq "darwin" )
{
$font = "charter";
}
else
{
$font = "times new roman";
}
if ( !$pluginmenu )
{
$pluginmenu = $menubar->cascade(
-label => 'Plugins',
-tearoff => 0
);
}
my $menu = $pluginmenu->cget( -menu );
$menu->add(
'command',
-label => 'Scoreboard',
-command => \&scoreboard_plugin
);
sub scoreboard_plugin
{
our $vis_score = defined($vis_score) ? $vis_score : 0;
our $home_score = defined($home_score) ? $home_score : 0;
my $scoreboard = $mw->Toplevel( -title => $title );
bind_hotkeys($scoreboard);
$scoreboard->Button(
-text => 'Close',
-command => sub { $scoreboard->destroy }
)->pack( -side => 'bottom' );
$scoreboard->withdraw();
$scoreboard->minsize( 45, 2 );
$scoreboard->Icon( -image => $icon );
my $vis_side = $scoreboard->Frame()->pack( -side => 'left', -padx => 5 );
my $home_side = $scoreboard->Frame()->pack( -side => 'right', -padx => 5 );
$vis_side->Label( -text => 'Visitor' )->pack( -side => 'top' );
$vis_side->Label(
-fg => 'blue',
-textvariable => \$vis_score,
-font => [ -family => $font, -size => 70 ]
)->pack( -side => 'top' );
my $vis_plus = $vis_side->Frame()->pack( -side => 'top' );
$vis_plus->Button( -text => '+1', -command => sub { $vis_score += 1 } )
->pack( -side => 'left' );
$vis_plus->Button( -text => '+5', -command => sub { $vis_score += 5 } )
->pack( -side => 'left' );
$vis_plus->Button( -text => '+10', -command => sub { $vis_score += 10 } )
->pack( -side => 'left' );
my $vis_minus = $vis_side->Frame()->pack( -side => 'top' );
$vis_minus->Button( -text => '-1', -command => sub { $vis_score -= 1 } )
->pack( -side => 'left' );
$vis_minus->Button( -text => '-5', -command => sub { $vis_score -= 5 } )
->pack( -side => 'left' );
$vis_minus->Button( -text => '-10', -command => sub { $vis_score -= 10 } )
->pack( -side => 'left' );
$vis_side->Button( -text => 'Reset', -command => sub { $vis_score = 0 } )
->pack( -side => 'top', -pady => '5' );
$home_side->Label( -text => 'Home' )->pack( -side => 'top' );
$home_side->Label(
-fg => 'red',
-textvariable => \$home_score,
-font => [ -family => $font, -size => 70 ]
)->pack( -side => 'top' );
my $home_plus = $home_side->Frame()->pack( -side => 'top' );
$home_plus->Button( -text => '+1', -command => sub { $home_score += 1 } )
->pack( -side => 'left' );
$home_plus->Button( -text => '+5', -command => sub { $home_score += 5 } )
->pack( -side => 'left' );
$home_plus->Button( -text => '+10', -command => sub { $home_score += 10 } )
->pack( -side => 'left' );
my $home_minus = $home_side->Frame()->pack( -side => 'top' );
$home_minus->Button( -text => '-1', -command => sub { $home_score -= 1 } )
->pack( -side => 'left' );
$home_minus->Button( -text => '-5', -command => sub { $home_score -= 5 } )
->pack( -side => 'left' );
$home_minus->Button(
-text => '-10',
-command => sub { $home_score -= 10 }
)->pack( -side => 'left' );
$home_side->Button( -text => 'Reset', -command => sub { $home_score = 0 } )
->pack( -side => 'top', -pady => '5' );
$scoreboard->update();
$scoreboard->deiconify();
$scoreboard->raise();
}
1;