Adding images to the log.

Game development with Board Game Arena Studio
Post Reply
User avatar
RicardoRix
Posts: 742
Joined: 29 April 2012, 23:43

Adding images to the log.

Post by RicardoRix » 28 April 2019, 14:01

Looking at this cookbook section.

http://en.doc.boardgamearena.com/BGA_St ... in_the_log

I think there should be a better in-built BGA framework for this.
I don't really understand it and looks like fat too many hoops to jump through for something that should be quite simple. :D

I've settled for <span'>s in game.php

User avatar
Een
Posts: 2359
Joined: 16 June 2010, 19:52

Re: Adding images to the log.

Post by Een » 29 April 2019, 11:02

Yes, that's not really simple.

Here is an example of what I did for Terra Mystica which seems more straightforward to me:

Code: Select all

//Define the proper message
		$message = clienttranslate('${player_name} gets ${power_income} via Structures');
		if ($price > 0) {
			self::DbQuery("UPDATE player SET player_score = player_score - $price WHERE player_id = $player_id");
			$message = clienttranslate('${player_name} pays ${vp_price} and gets ${power_income} via Structures');
		}

// Notify
		self::notifyAllPlayers( "powerViaStructures", $message, array(
			'i18n' => array( ),
			'player_id' => $player_id,
			'player_name' => self::getUniqueValueFromDb( "SELECT player_name FROM player WHERE player_id = $player_id" ),
			'power_tokens' => $power_tokens,
			'vp_price' => self::getLogsVPAmount($price),
			'power_income' => self::getLogsPowerAmount($power_income),
			'newScore' => self::getUniqueValueFromDb( "SELECT player_score FROM player WHERE player_id = $player_id" ),
			'counters' => $this->getGameCounters(null),
		) );
With some functions to have the needed html added inside the substitution variable, such as:

Code: Select all

function getLogsPowerAmount( $amount ) 
{
		return "<div class='tmlogs_icon' title='Power'><div class='power_amount'>$amount</div></div>";
}

User avatar
RicardoRix
Posts: 742
Joined: 29 April 2012, 23:43

Re: Adding images to the log.

Post by RicardoRix » 29 April 2019, 11:16

Yes, this is pretty much what I've settled on. You're missing the css which I guess has an image-background.

I am thinking that the answer is just to separate out the 'message', and make sure you get something clean within the clienttranslate();
So you want nice pictures in the game log, what do you do? First idea that come to mind is to send html from php in notifications. This is bad idea for many reasons

Its bad architecture, ui elements leak into server now you have to manage ui in many places
If you decided to change something in ui in future version, old games reply and tutorials may not work, since they use stored notifications
When you read log preview for old games its unreadable (this is log before you enter the game reply, useful for troubleshooting or game analysis)
Its more data to transfer and store in db
Its nightmare for translators

VanHlebar
Posts: 37
Joined: 24 September 2019, 02:30

Re: Adding images to the log.

Post by VanHlebar » 18 January 2020, 20:46

Just have to say this should be added to the Cook Book! I spent probably 3 days attempting to get this to work properly using the method listed in the Cook Book and just could not get it to work properly.

Found this thread today and got it working in just a few minutes!

Eric

User avatar
Een
Posts: 2359
Joined: 16 June 2010, 19:52

Re: Adding images to the log.

Post by Een » 19 January 2020, 10:51

VanHlebar wrote:
18 January 2020, 20:46
Just have to say this should be added to the Cook Book! I spent probably 3 days attempting to get this to work properly using the method listed in the Cook Book and just could not get it to work properly.

Found this thread today and got it working in just a few minutes!

Eric
Ok, done!
Btw, the cookbook has been created by developers (mainly Victoria_La), like all the studio documentation it's a wiki, don't hesitate to add to it and improve it.

Post Reply

Return to “Developers”