Add label in Interface title

Wrote new code? Fixed a bug? Want to discuss technical stuff? Feel free to post it here.

Moderator: Moderators

chocobrowny
Noob
Noob
Posts: 19
Joined: 21 Jul 2011, 01:16
Noob?: No

Add label in Interface title

#1 Post by chocobrowny »

I think it easy to seperate group and monitor my kids.

Add label into in front of Interface title.

Image

Change code in function.pl

1. Add this code under "my $title;"

Code: Select all

#	Add label
if (defined($config{label})) {
	$title = TF("\[%s\]", $config{label});
}
2. Change "$title =" to "$title .="

Code: Select all

if ($net->getState() == Network::IN_GAME) {
	...
	# Translation Comment: Interface Title with character status
	$title .= TF("%s B%s (%s), J%s (%s) : w%s%s - %s",
		$charName, $char->{lv}, $basePercent . '%',
		$char->{lv_job}, $jobPercent . '%',
		$weight, $pos, $Settings::NAME);

} elsif ($net->getState() == Network::NOT_CONNECTED) {
	# Translation Comment: Interface Title
	$title .= TF("%sNot connected - %s", $charName, $Settings::NAME);
} else {
	# Translation Comment: Interface Title
	$title .= TF("%sConnecting - %s", $charName, $Settings::NAME);
}
Summary >>

Code: Select all

# Set interface title
my $charName;
my $title;

#	Add label
if (defined($config{label})) {
	$title = TF("\[%s\]", $config{label});
}

$charName = "$char->{name}: " if ($char);
if ($net->getState() == Network::IN_GAME) {
	my ($basePercent, $jobPercent, $weight, $pos);
	assert(defined $char);
	$basePercent = sprintf("%.2f", $char->{exp} / $char->{exp_max} * 100) if ($char->{exp_max});
	$jobPercent = sprintf("%.2f", $char->{exp_job} / $char->{exp_job_max} * 100) if ($char->{exp_job_max});
	$weight = int($char->{weight} / $char->{weight_max} * 100) . "%" if ($char->{weight_max});
	$pos = " : $char->{pos_to}{x},$char->{pos_to}{y} " . $field->name if ($char->{pos_to} && $field);

	# Translation Comment: Interface Title with character status
	$title .= TF("%s B%s (%s), J%s (%s) : w%s%s - %s",
		$charName, $char->{lv}, $basePercent . '%',
		$char->{lv_job}, $jobPercent . '%',
		$weight, $pos, $Settings::NAME);

} elsif ($net->getState() == Network::NOT_CONNECTED) {
	# Translation Comment: Interface Title
	$title .= TF("%sNot connected - %s", $charName, $Settings::NAME);
} else {
	# Translation Comment: Interface Title
	$title .= TF("%sConnecting - %s", $charName, $Settings::NAME);
}

my %args = (return => $title);
Plugins::callHook('mainLoop::setTitle',\%args);
$interface->title($args{return});
"...Every coin have two sides, think more widely and Not everything is black and white, there are shades of grey..."
Image