PDA

View Full Version : How do I get the applications window size (in pixel)?



Tommycore
March 23rd, 2020, 16:44
Hey all!

I'd like to make a window that stretches over the complete screen, horizontally. I got it to where I can open my window, fix it to the top left by code, and resize it manually and/or via code. So far so good, but what I can't find, neither in the forums, nor the refdoc (which, btw., could use a search function, for us lazy people ^^), nor the dev guide, is how to find out the current resolution of the Fantasy Grounds window. I'm not talking about my own window, I mean the complete application window.

I need something like Screen.width (https://docs.unity3d.com/ScriptReference/Screen-width.html) in the Unity Engine.

I've been looking for the sidebar in CoreRPG, which scales horizontal, but I didn't find out how it does that.

LordEntrails
March 23rd, 2020, 16:56
Don't know. But the map resize to background/full does what you want right? So perhaps you can find it in there?

As for RefDoc search, use a Google Search with the site specified?

Tommycore
March 23rd, 2020, 17:07
Don't know. But the map resize to background/full does what you want right? So perhaps you can find it in there?
I'll look into it. Thank you =)


As for RefDoc search, use a Google Search with the site specified?
That's why I said "us lazy people" ;)

Trenloe
March 23rd, 2020, 17:20
Or, to search the Wiki. From the new Wiki page (accessing from the Help menu at the top of the page) click the magnifying glass in the top left.

Then search for getsize maybe? And select the result for windowinstance

Tommycore
March 23rd, 2020, 21:11
Got it. You basically put a panel stretching over your whole screen on the desktop, and put an empty class in there, which doesn't do any size or position control on itself. Make sure your panel has the <disabled /> tag, so it doesn't interfere with the rest of the interface.

<root>
<windowclass name="dev_console">
<frame>default_framed</frame>
<nomove />
<placement>
<size width="150" height="100" />
<nosave />
</placement>
<sizelimits>
<minimum width="100" height="25" />
<maximum width="10000" height="500" />
<dynamic />
</sizelimits>
<sizelimits>
<dynamic>
<resize>both</resize>
</dynamic>
</sizelimits>
</windowclass>

<windowclass name="empty">
</windowclass>

<panel name="desktopfullpanel" modes="host,client">
<anchored>
<left />
<top />
<right />
<bottom />
</anchored>
<class>empty</class>
<disabled />
</panel>
</root>

Second, you need a Lua script that hangs onto the onDesktopInit function and sets the size:


function onInit()
local dc =Interface.openWindow("dev_console", "");
Interface.onDesktopInit = onDesktopInit;
end

function onDesktopInit ()
local devCon = Interface.findWindow("dev_console", "");
local empty = Interface.findWindow("empty", "");
devCon.setPosition(0,0);
devCon.setSize(empty.getSize (),25);
end

Very basic, and somewhat ugly as far as solutions go, but it works. If you want to I can clean it up, and pack it into an extension. Though, if you devs are reading - I don't know your codebase, I'm a developer myself, I hate such assumptions as well, but... shouldn't that be quite quick and easy to implement? Just another function for the Interface class.

zuilin
October 17th, 2020, 08:10
I don't know if it's exact, but imagefullpanel is what I'm using. So:


local sizeX, sizeY = Interface.findWindow("imagefullpanel","").getSize();

Close enough for my purposes. YMMV