color to the log

Game development with Board Game Arena Studio
Post Reply
User avatar
tchobello
Posts: 694
Joined: 18 March 2012, 13:19

color to the log

Post by tchobello »

hello,
by now, log displays "huntelaar0 moves Troll" and I would like to show "huntelaar0 moves Troll".


I'm using this trick :

Code: Select all

function moveCharacter( $type,...
...
$color = self::getUniqueValueFromDB( "SELECT player_color FROM player WHERE player_id = '$player_id' ");

self::notifyAllPlayers( 'simpleNote', clienttranslate('${player_name} moves ${colorhtml}${character}${colorend}'), 
    array(
    'i18n' => array( 'character' ),
    'player_name' => self::getActivePlayerName(),
    'character' => $this->token_types[ $type ]['name'],
    'colorhtml' => "<span style='font-weight:bold;color:#$color'>",
    'colorend' => "</span>" 
     ) );
in material.inc, I have lots of characters like this :

Code: Select all

    'troll' => array(
        'name' => clienttranslate('Troll'),

Is there a proper way to do this because I don't want translation to be upside down ?
User avatar
tchobello
Posts: 694
Joined: 18 March 2012, 13:19

Re: color to the log

Post by tchobello »

Oh, I forgot about another problem with arrays of arguments :

Code: Select all

        $items_list = array();
        $items_args = array();
        $items_i18n = array();
        $i=0;
        foreach( $token_to_place as $token_id => $token_type )
        {
            $items_list[] = '${item'.$i.'}';
            $items_args[ 'item'.$i ] = $this->token_types[ $token_type ]['name'];
            $items_i18n[] = 'item'.$i;
            $i++;
        }

        // Notify
        self::notifyAllPlayers( "roomDiscovered", clienttranslate( '${player_name} reveals a room (1 action) with the following: ${items_list}' ), array(
            'player_name' => self::getActivePlayerName(),
            'items_list' => array(
                'log' => implode( ', ', $items_list ),
                'args' => $items_args,
                'i18n' => $items_i18n
            )
        ) );
Names of tokens in the items_list are not translated. What is wrong ?
vincentt
Posts: 254
Joined: 01 September 2017, 17:25

Re: color to the log

Post by vincentt »

Hi,

About the color, I think you may be able to do it by overridding the display log function "format_string_recursive" you can look in the cookbook http://en.doc.boardgamearena.com/BGA_Studio_Cookbook

About the translation, it looks like the i118n should be a level higher (you nested it in items_list and it should be as the same level than player_name

Cheers,

Vincent
User avatar
tchobello
Posts: 694
Joined: 18 March 2012, 13:19

Re: color to the log

Post by tchobello »

Thanks a lot, i've have look at this...
User avatar
tchobello
Posts: 694
Joined: 18 March 2012, 13:19

Re: color to the log

Post by tchobello »

hello, I've tried this

Code: Select all

$color = self::getUniqueValueFromDB( "SELECT player_color FROM player WHERE player_id = '$player_id' ");

 self::notifyAllPlayers( 'simpleNote', clienttranslate('${player_name} moves ${sb}${character}${se}'), array(
            'i18n' => array( 'character' ),
            'player_name' => self::getActivePlayerName(),
            'character' => $this->token_types[ $type ]['name'],
            'sb' => "<span style='font-weight:bold;color:#$color'>",
            'se' => "</span>"
        ) );
It's working

and this

Code: Select all

        self::notifyAllPlayers( 'simpleNote', clienttranslate('${character} moves '), array(
            'i18n' => array( 'character' ),
            'player_name' => self::getActivePlayerName(),
            'character' => "<span style='font-weight:bold;color:#$color'>".$this->token_types[ $type ]['name']."</span>"
        ) );
Not working

I've had a look at the Cookbook : sorry, I've understood absolutely nothing.

The items_list doesn't work either and I don't remember in what project I've seen one.
Post Reply

Return to “Developers”