For anyone who wants Bold/Italic/Colors in report log

Hi Folks,

I’ve made a drop-in replacement for the normal Chat/Log window in Vassal, in case anyone wants to use it in their modules. It’s a java custom class that replaces only the chat/log window, and gives you easy access to bold/italic/underline text, multiple colors for report messages, and if you want it full HTML functionality and styling.

I’ve demonstrated it in a little “mini module” that I uploaded here: vassalengine.org/mediawiki/i … tDemo.vmod

(If you want to see it in a “full module” then Paths of Glory 9.7 and For the People 3.2 are both using it).

Below is a sample screenshot, and instructions if you want to try it out in your own module.

Brian

[attachment=0]htmlchat.png[/attachment]

Installation instructions:
(1) Back up your whole module -- you're going to be editing your buildFile manually here, so in case something goes wrong make a backup first so you won't lose any work.
(2) You'll need to pull out the entire "HTMLChatter" subdirectory from the HTMLChatDemo.vmod -- remember, vmod's are really just renamed zip files, so if you rename it to HTMLChatDemo.zip you will be able to open it up like a zip file. Copy out the entire contents of the "HTMLChatter" subdirectory.
(3) Open your OWN module as a zip file (renaming it if necessary), and insert the "HTMLChatter" subdirectory into it.
(4) Now, copy out the file called "buildFile" from your own module.
(5) Open your buildFile with a text editor.
(6) Find the line that says... <VASSAL.build.module.Chatter/>
(7) Replace that line with... <HTMLChatter.HTMLChatter/>
(8) Save your new buildFile. 
(9) Insert it into your module, copying it over your old buildFile (remember, I told you to make a backup first!)
(10) Now rename your module file from .zip to .vmod.
(11) Start your module up!

At the risk of being the guy who says “fantastic” to everything, let me say, fantastic. Module formatted text was in my top five most wanted vassal thingies.

wow ! Can we give different colors in the log, based on the PlayerSide ?
I have to check this !!!

Aha. I see how I can use this log to mention how PlayerSide changed.
But … The colors are based on preferences.
I see how important is the work you’ve done in this dev, and I really like it.
Is there a way to impose the colors, instead of using preferences ? Or to impose the preferences from a saved module ?
I’d like to either write all reports coming from Active Player activity written with their color (one of the 5 present in TM game), or, if this is really to heavy, to use an explicit : “Player’s Turn” report written in their color. Should I use to impose it ?

So, as I have this PlayerSeat GP numbered between 1 and 5, I can use this calculated property named color now (even if nested Ifs are not that nice)If($PlayerSeat$=="1","!",If($PlayerSeat$=="2","?",If($PlayerSeat$=="3","~",If($PlayerSeat$=="4","'","")))) And I need to edit my reports so they all start with $color$.
This way, colors 2,3,4 and 5 will be assigned to players 1,2,3 and 4. And if we have a 5th player, they would use the default color.
But this means the preferences have to be edited for each game by all the players, so they map the color and the playerseat … I can have my friends do that. It may not be that easy to tell every other player.
But really, I like it !!!

Hehe yes I clearly did not think of ALL possible use cases – I’m used to 2-player games, but this can clearly be done. Obviously someone could extend the custom class too.

Meanwhile it would be fantastic if in Vassal 4 we could assign individual colors for every player in a multiplayer game. If Vassal sent some form of Player ID (number or “Side” string or whatever) around with every Chat Message, then if would be easy to conform Chat colors to each player individually.

this is amazing!

I’ve found I can even type pictures in jpg in the chat window :slight_smile:

Kerkael, could you explain a bit your method? I’m trying to report dice rolls and action on different color depending on player side (red for British or blue for French). Can’t think of a way to achieve this.

Oh you can totally do that – just put direct HTML/CSS styling into a in your report lines.

In fact, if you pull down that demo module and try rolling the dice in it, you will see that I actually put PICTURES OF THE DICE in the line!

So you could also put stuff in like <span style=“color:red”;>THIS IS THE RED TEXT in the report line, or if you want to get into funky colors use “color:#20ab2e” and stuff.

yep I tried that and it works. I can even send animated gifs to the chat window :slight_smile:
Btw I have already stolen your inline dice.

But I would like to report something like this in a Report:

(If $PlayerSide$="French", "<span style="color:blue";>") 

But I don’t think I can use If sentences in report lines?

I would create a new variable, PlayerColor for instance, and set it based on PlayerSide; then you could set the span color to PlayerColor.

I’m afraid I’m not skilled enough to do that. How do I create a variable?

Sorry, didn’t think that through; I’m new to VASSAL myself, but am an amateur programmer. I’m thinking a Calculated Property whose value depends on PlayerSide.

Edit. Something like Property Name: PlayerColor, Expression: (If $PlayerSide$ = “French”, “blue”, “red”)

And then your report would use <span style=“color:$PlayerColor$”;>

Someone correct me if my syntax is wrong.

  • Set your Calculated Property name to PlayerColor
  • In the expression line type: If(PlayerSide==“French”,“blue”,“red”)
  • In report line put at the beginning.
  • Properly speaking you can put at the end of the report line, but it probably works fine without it.

If you want fancier RGB colors then instead of e.g. “blue” put “#0000ff” would be full blue or you could change to “#0030ff” for a bit more toward cyan, etc, etc. Values are two hexadecimal digits for each of r, g, and b.

I decided to avoid the calculated field, and go that way (completely compatible with PlayerSide being HTML colors in Terraforming Mars : Black, Blue, Green, Red and Yellow):
All reports say this before anything else.
<span style=“background-color:$PlayerSide$”;>        
This makes them showing a colored rectangle before text.
I added some extra settings in the middle of strings as with:
 Oceans 
All in all, this makes the code easier to manipulate with bulk edition for the BuildFile.