PDA

View Full Version : How to create a resizable chatwindow



joshuha
August 3rd, 2011, 22:17
I worked at creating this as an extension but due to the way the default chat is a panel and this is a pure windowclass it isn't working. Video will take a second to load. (https://www.bitsbyteswords.com/ResizableChatWindow/ResizableChatWindow.html)

You will be needing to modify 2 XML files and 1 LUA file.

File 1: desktop_panels.xml

Step 1: Comment out the current chat panel so that it looks like this:


<!--<panel name="chat" modes="host,client">
<class>chat</class>
<bounds>15,90,390,-118</bounds>
</panel>-->


Step 2: Change the anchors on the identity list not to use the chat panel. Note that you may need to play around with the coordinates here to place the identity list (the NPCs the GM speaks as) somewhere else you like it.

Comment out the parent node for the top anchor and left anchor and add a left offset to the identitylist control like so:


<top>
<!--<parent>chat</parent>-->
<anchor>bottom</anchor>
<offset>-50</offset>
</top>
<left>
<!--<parent>chat</parent>-->
<anchor>left</anchor>
<offset>100</offset>
</left>


File 2: desktop_classes.xml

Step 1: Add a width to the sizelimits maximum node of the chat windowclass. This will allow maximum stretchability.


<maximum>
<height>10000</height>
<width>10000</width>
</maximum>


Step 2: Modify the left anchor to use the right side of the chat panel in the "mode" genericcontrol under the "chat" windowclass..


<left>
<anchor>right</anchor>
<offset>-55</offset>
</left>


Step 3: Add functions to autoshare the window with client. If GM accidentally closed it pressing ALT will bring it back with no loss of info. Put these in the "chat" windowclass. I put mine right below the <placement> node.


<softclose />
<sharable />
<script>
function onInit()
User.onLogin = reshare
Input.onAlt = reopen
self.onMove = onMove
end
function reshare()
share()
end
function reopen()
Interface.openWindow("chat","")
share()
end
function onMove()
self.setSize(self.getSize())
end
</script>


Note if you want the default chat not to open in the middle you can add a set of position tags to the chat windowclass. This is optional though.

Also, if your ruleset does not have the current chat windowclass as dynamic you should add the following under the sizelimits node:


<dynamic>
<resize>both</resize>
</dynamic>


File 3: Scripts\desktop.lua

Step 1: Basically here we are adding in a call to the desktop initialization to open our modified chat windowclass for the GM. Modify the onInit function and add an Interface.openWindow right under the first if User.isHost() statement.


function onInit()
if not User.isLocal() then
if User.isHost() then
Interface.openWindow("chat","")

Zeus
August 3rd, 2011, 22:30
This is Cool. Two questions:

1) Am I right in understanding that you remove the underlying chat panel and simply call for the chatwindow to render as a standard window?
a) if so do dice rolls still fire OK when the chatwindow is sized larger than the original default?
2) do you not also need to add the <dynamic /> tag to the chat windowclass to allow for dynamic resizing of the chatwindow?

joshuha
August 3rd, 2011, 22:36
This is Cool. Two questions:

1) Am I right in understanding that you remove the underlying chat panel and simply call for the chatwindow to render as a standard window?
a) if so do dice rolls still fire OK when the chatwindow is sized larger than the original default?
2) do you not also need to add the <dynamic /> tag to the chat windowclass to allow for dynamic resizing of the chatwindow?

1) Yes
a) Yes they come across fine, I tested with several players. Whats neat is if the players window is bigger then your it seems to overlap the vector of where it fires but still lands in your smaller window and the results are still the same.

2) Yes but its already like that in the base 4E ruleset in 2.8 even though its tied to a panel and therefor not really dynamic. Will add a note though.

Oberoten
August 3rd, 2011, 23:12
It works beautifully. Just added this to the ArsMagica ruleset.

- Obe

Oberoten
August 4th, 2011, 00:16
Ouch. Noticed the first bug with this aproach... in it's current form the window can be accidentially closed by the clients.

- Obe

joshuha
August 4th, 2011, 02:07
Updated post so user's cannot close chat down. GM could still though and can get window back by pressing ALT. Might be a more elegant way to prevent GM from doing it or auto-reopen but can't think of it right this second.

psicodelix
August 4th, 2011, 15:11
Nice mod joshuha!

I've just added it to my ruleset and noticed a minor issue. When you move the chat window the subjacent area that receives the thrown dice is not updated to the new position until the chat window is resized.

joshuha
August 4th, 2011, 15:16
Hmm didn't notice that but will test it and see if I can figure out why its doing that.

Dakadin
August 4th, 2011, 16:50
Great job joshuha!

I was able to add it to a ruleset also. I did add the <placement> tag so I could set a default position and size which replicated the original placement before I made changes.

I am able to replicate psicodelix's issue. I did notice that it will still register the roll if you drop it in the old location before you moved it.

Sorcerer
August 4th, 2011, 21:33
a work around to the issue isto force a resize every time you move the window.

add an on move event handler to the chat window onInit and then set the onMove function to resize to the current window size and it should work


function onInit()
User.onLogin = reshare
Input.onAlt = reopen
self.onMove = onMove
end
function reshare()
share()
end
function reopen()
Interface.openWindow("chat","")
share()
end

function onMove(source)
source.setSize(source.getSize())
end

Dakadin
August 4th, 2011, 21:58
Thanks Sorcerer!

That took care of the issue with the dice not registering after moving the chat window.

psicodelix
August 5th, 2011, 07:30
Ok, it works! Thank you!

Doswelk
August 5th, 2011, 16:41
Just to prove you cannot please everyone... :p

Having had a play with the extending chatbox in 2.8 is there a way to turn it off?

I know it does not affect me right now (savage worlds ruleset does not support this yet)

I have a nice big screen and use the space under the chat box for the GM toolbox.

Given myself and players all have different screen sizes/number of screens when we play FGII is the following possibe to be coded in a ruleset or will it require an update to the FGII code?

1) The ability to turn it on or off completely
2) The ability to set a maximum size for the window
3) Leave as the default (auto-sizing)
4) Each FGII user can set their own perference

I think that way big moaners like me might be happy ;)

joshuha
August 5th, 2011, 16:54
Not sure what you are getting at. What I am posting is a way for each user to be able to size it from anywhere from 350 x 350 all the way up to 10000x10000.

Sorcerer
August 5th, 2011, 16:55
Hi Doswelk,

I guess I should point out that the resizable chat window in this post has actually nothing to do with the autosizing chat window for v2.8 take a look at the video in the first post. This version is completely customizable by GM and players and the size you set will be remembered on reload because Joshuha has in fact turned the chat window into "just another window"

with regard to the v2.8 version. if you go into desktop classes.xml
you should be able to set the max height. I thinks switching it off completely would need a recode.

but I would suggest you have P_W look at this version because its completely customizable.

joshuha
August 5th, 2011, 16:57
a work around to the issue isto force a resize every time you move the window.

add an on move event handler to the chat window onInit and then set the onMove function to resize to the current window size and it should work


function onInit()
User.onLogin = reshare
Input.onAlt = reopen
self.onMove = onMove
end
function reshare()
share()
end
function reopen()
Interface.openWindow("chat","")
share()
end

function onMove(source)
source.setSize(source.getSize())
end

Added this to the steps. Thanks.

As a side note Moon_Wizard is going to try and add a <noclose /> type of tag within the next couple of patches which will basically make all of these functions except the sharing part unnecessary. With a noclose tag and the ability to open windows from DesktopInit you basically have the same things as panels with the flexibility of moving them around and letting the ruleset define what can and can't be moved.

Doswelk
August 5th, 2011, 19:26
Hi Doswelk,

I guess I should point out that the resizable chat window in this post has actually nothing to do with the autosizing chat window for v2.8 take a look at the video in the first post. This version is completely customizable by GM and players and the size you set will be remembered on reload because Joshuha has in fact turned the chat window into "just another window"

with regard to the v2.8 version. if you go into desktop classes.xml
you should be able to set the max height. I thinks switching it off completely would need a recode.

but I would suggest you have P_W look at this version because its completely customizable.

D'oh!

Serves me right to only read up to Moon-wizard's comment about 2.8 :o:o:o

joshuha
August 15th, 2011, 00:46
Its like a giant dice cup!

https://bitsbyteswords.com/chat_trick/chat_trick.html

And yes I was able to replicate with multiple dice but you have to be quick hehe.

wbcreighton
August 15th, 2011, 18:21
I can hear the DM now: "Roll the damn dice already !" ;)

unerwünscht
October 3rd, 2011, 20:29
As a side note Moon_Wizard is going to try and add a <noclose /> type of tag within the next couple of patches which will basically make all of these functions except the sharing part unnecessary. With a noclose tag and the ability to open windows from DesktopInit you basically have the same things as panels with the flexibility of moving them around and letting the ruleset define what can and can't be moved.
Any updated information on this?

joshuha
October 3rd, 2011, 20:54
Any updated information on this?

Hopefully the next patch of FG but I don't know how hard it is to add.

Moon Wizard
October 5th, 2011, 23:45
I have no official timing on the next patch at this point. I am plugging away at a number of capabilities including a new installer/updater.

Regards,
JPG

lhide
October 20th, 2011, 03:01
this isnt working for me, dunno why. not even in the Ars Magick ruleset wich is supposed to have this already.

Oberoten
October 21st, 2011, 09:36
Ah... the Resizeable chatwindow in Ars Magica. Well, it used to be there but due to the dice-physics being what they are I opted to remove this because it made disrespancies between the dice rolled and the roll reported.

It'd show correct for the one rolling, but for GM and other players the dice shown and the result could differ. All the dice-function sends seemingly is direction, face up and speed and then simulates inside the landing area. If the landing area aka chatwindow is another size this gets somewhat erratic.

- Obe

dr_venture
October 21st, 2011, 18:11
I don't blame you, Obe - I love the chat window being resizable, but when the dice rolls all started being unreliable (at least the actual die graphics) then it was a big let down for me. It turns out I watch most of those rolls more closely than I realized - when the graphic die result differs from the actual result in the chat window, it can really be a letdown.

As a workaround to this problem, couldn't there be an option to synch the size of the chat windows, either to the GM's chat window, or maybe to the size of the smallest chat window in the group? I don't mind my chat window being small, but for some of my players on laptops, the bottom of the chat window hides behind part of the Modifiers box, which makes typing messages annoying. I'd love to be able to coordinate with them so that the windows were the same size (and thus die rolls work correctly) but also a convenient size for everyone.

Oberoten
October 21st, 2011, 23:39
My current compromise is a stretchable chatwindow... that adapts to the height of the screen. It seems to have less impact.

- Obe