Page 1 of 1

HTML Question

Posted: Mon Aug 04, 2014 12:58 am
by mfrizzell
Is it possible to use the following type of command in Maptool. background-image.
If so how would you go about doing it.
I would like to use an image of old paper as the background in a frame with the text written over the top of it.

Thanks

Re: HTML Question

Posted: Mon Aug 04, 2014 2:41 am
by aliasmask
Just use CSS and put the paper as a token somewhere on any map. You can put in a table or in a div.

Code: Select all

[H: bgImage = getImage("image:oldPaper")]
[H: text = "whatever"]
[H: text = replace(text,'"',""")]
[H: output = '<div width="400" style="background-image:url(' + stformat("'%{bgImage}'") + '">' + string(text) + "</div>"]
<!-- you may want to play with frame settings -->
[R, dialog("MyFrame","width=415;height=300;"): { [R: output] }]
Here's another example I use in my code:

Code: Select all

[H: output = strformat('
   <table style="padding:0px;border-style:solid;border-width:0pt;background-image:url(%{bgImage});background-color:%{bgColor};" width="100%">
      <tr style="padding:0px;border-style:solid;border-width:1pt;" valign=top>
         <td width="40" style="padding-right: 5px"><img src="%{tokenImage}-50" alt="%{playerName}" /></td>
         <td style="margin-right: 5px;" width="100%"><span id="icc">%{chatText}</span></td>
      </tr>
   </table>
')]

Re: HTML Question

Posted: Mon Aug 04, 2014 10:16 am
by mfrizzell
Thanks AM I'll give that a try asap.

Re: HTML Question

Posted: Mon Aug 04, 2014 11:05 am
by mfrizzell
Hmm. I get an error when I try the first method. I put an oldPaper token on the map with the name of Image:oldPaper. When I run the first method in the chat window it gives me the following error.

Code: Select all

java.util.EmptyStackException
	at java.util.Stack.peek(Unknown Source)
	at javax.swing.text.DefaultStyledDocument$ElementBuffer.insertElement(Unknown Source)
	at javax.swing.text.DefaultStyledDocument$ElementBuffer.insertUpdate(Unknown Source)
	at javax.swing.text.DefaultStyledDocument$ElementBuffer.insert(Unknown Source)
	at javax.swing.text.DefaultStyledDocument.insert(Unknown Source)
	at javax.swing.text.html.HTMLDocument.insert(Unknown Source)
	at javax.swing.text.html.HTMLDocument$HTMLReader.flushBuffer(Unknown Source)
	at javax.swing.text.html.HTMLDocument$HTMLReader.flush(Unknown Source)
	at javax.swing.text.html.HTMLDocument.insertHTML(Unknown Source)
	at javax.swing.text.html.HTMLDocument.insertBeforeEnd(Unknown Source)
	at net.rptools.maptool.client.ui.commandpanel.MessagePanel$5.run(MessagePanel.java:230)
	at java.awt.event.InvocationEvent.dispatch(Unknown Source)
	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.awt.EventQueue.access$400(Unknown Source)
	at java.awt.EventQueue$2.run(Unknown Source)
	at java.awt.EventQueue$2.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at net.rptools.maptool.client.swing.MapToolEventQueue.dispatchEvent(MapToolEventQueue.java:36)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
The second method looks dependent on some of the code from the first method. Not sure if it's meant a a direct replacement for this line or not.

[H: output = '<div width="400" style="background-image:url(' + stformat("'%{bgImage}'") + '">' + string(text) + "</div>"]

Clarification would be much appreciated. Thank you.

Re: HTML Question

Posted: Mon Aug 04, 2014 11:26 am
by aliasmask
The quotes were mixed up, but I tested this and it worked.

Code: Select all

[H: bgImage = getImage("image:oldPaper")]
[H: text = "whatever"]
[H: output = strformat('<div width="400" style="background-image:url(%{bgImage})">%{text}</div>')]
<!-- you may want to play with frame settings -->
[R, dialog("MyFrame","width=415;height=300;"): { [R: output] }]

Re: HTML Question

Posted: Mon Aug 04, 2014 2:51 pm
by mfrizzell
Thanks AM that works sort of. I probably wasn't clear. I was looking to completely fill the background with the image and then be able to cover it with writing. As it stands it seems to only reveal the background as you put text up. I would like to be able to use other macros to generate writing including token properties etc.

Here is an example of what I'm looking for.
http://www.w3schools.com/cssref/tryit.a ... ound-image

Thanks.

Re: HTML Question

Posted: Mon Aug 04, 2014 3:45 pm
by aliasmask
You can set the background image in the body tag then rather than a div or table.

Re: HTML Question

Posted: Mon Aug 04, 2014 3:59 pm
by mfrizzell
Ah thank you thank you thank you.

Re: HTML Question

Posted: Tue Aug 05, 2014 12:06 am
by mfrizzell
Is there an example you can give me that does not include the use of strformat? I lack the skills to roll up all of my output into a concise package.

Re: HTML Question

Posted: Tue Aug 05, 2014 1:16 am
by aliasmask

Code: Select all

<body style="background-image:url([r: getImage("image:oldPaper")])">
...
</body>

Re: HTML Question

Posted: Tue Aug 05, 2014 1:43 am
by mfrizzell
Thank you very much.