package MonitorGUI::View;
use strict;
my @server_list;
my $max_port;
my $regions;
sub screen_header {
return << "HEADER";
Region Monitor GUI, 3Di
HEADER
}
sub screen_footer {
return << "FOOTER";
FOOTER
}
sub html {
my $grid_info = shift;
my $regions_list = $grid_info->{"sim-profiles"};
$regions = undef;
foreach(@$regions_list) {
my $ip = $_->{sim_ip} || "UNKNOWN";
my $port = $_->{sim_port} || "UNKNOWN";
$regions->{$ip}->{$port} = $_;
if (!$regions->{max_port} || $regions->{max_port} < $port) {
$regions->{max_port} = $port;
}
}
@server_list = keys %$regions;
$max_port = $regions->{max_port};
my $html = "";
foreach my $machine (@server_list) {
next if ($machine eq "max_port");
$html .= &_machine_view($machine, $regions->{$machine});
}
return $html;
}
sub _machine_view {
my ($ip, $info) = @_;
my $region_html = "";
foreach my $region (keys %$info) {
$region_html .= &_region_html($info->{$region});
}
my $html =<< "MACHINE_HTML";
$ip
$region_html
MACHINE_HTML
}
sub _region_html {
my $region_info = shift;
my $name = $region_info->{name} || "UNKNOWN";
my $x = $region_info->{x} || -1;
my $y = $region_info->{y} || -1;
my $ip = $region_info->{sim_ip} || "UNKNOWN";
my $port = $region_info->{sim_port} || "UNKNOWN";
my $get_scene_presence_filter = $region_info->{get_scene_presence_filter};
my $get_scene_presence = $region_info->{get_scene_presence};
my $get_avatar_filter = $region_info->{get_avatar_filter};
my $get_avatar = $region_info->{get_avatar};
my $avatar_names = $region_info->{avatar_names};
my $action_forms = &_action_forms($region_info);
my $html = <<"REGION_HTML";
$name
$ip:$port | X: $x Y: $y
get_avatar
$get_avatar
get_avatar_filter
$get_avatar_filter
$avatar_names
get_scene_presence
$get_scene_presence
get_scene_presence_filter
$get_scene_presence_filter
$action_forms
REGION_HTML
return $html;
}
sub _action_forms {
my $region_info = shift;
my $ip = $region_info->{sim_ip};
my $port = $region_info->{sim_port};
my $default_input_port = $max_port + 1;
my $move_to_options = "";
my $split_to_options = "";
my $merge_ip_options = "";
foreach(@server_list) {
next if ($_ eq "max_port");
$merge_ip_options .= "