PDA

View Full Version : Getting windowclass from background image.



StoryWeaver
January 10th, 2019, 20:25
I'm having some problems trying to find windowclass instances of background images. With the regular image window. Using the following function:


function Interface.findWindow( windowclass, datasource )


Calling for example:


Interface.findWindow("imagewindow", imgParentContainer)

Returns the windowclass instance. But after using the arrows at the top right image window to set the image as a background image, this returns a nil value.

What is the windowclass name to call for finding the background image windowclass, as I'm assuming that is what's changing? Secondly where do I find the reference to that windoclass name in the xml of the CoreRPG.pak? Is there a new way to detect if the image is in background image mode?

Trenloe
January 10th, 2019, 20:48
Try "imagepanelwindow"

The definition is in CoreRPG campaign\record_image.xml

celestian
January 10th, 2019, 20:51
I'd be willing to bet the windowclass is not "imagewindow" for the background window/map. Add a override for Interface.onWindowOpened and get the windowclass name for every window opened and output, see what shows when you open up the background image (check the name).

edit: Trenloe saved you the trouble ;)

StoryWeaver
January 10th, 2019, 22:37
Thanks guys, appreciate your help! :)

Looks like I've been doing the right things in that case, but something is missing to make it work, it's like the window classes don't register in the scripts I'm working with after switching to background image mode.
I had been working with 'campaign/record_image.xml' and scripts outside of that directory tree, for example 'scripts/manager_maptoken.lua'.

So I'd tried a number of things before posting here, including trying to find the 'imagepanelwindow' instead of the 'imagewindow'. As 'imagewindow' is from what I can tell from reading the xml and how it appears the full dialog window, but 'imagepanelwindow' its first sub-window class that holds the content inside that window.

Having placed a number of Debut.chat(...) outputs throughout that part of the code to track the variables. I can see that as soon as I zoom to background mode, neither 'imagewindow' nor 'imagepanelwindow' registers anymore using the Interface.findWindow call, returning nil values. Which causes the subsequent code to fail.
Creating a new 'imagewindow' doesn't do anything when in background image mode, but creating a new 'imagepanelwindow' does create that actual section of the window on top of the actual background image, but in similar dimensions as a regular dialoged window. So not actually replacing the current background image, but placing another panel on top containing the same content, but without the dialog window options.

I added a Interface.onWindowOpened override and output the results from the window parameter, which works and is a great way to find the window class and details. However it only runs when actually opening the image, which opens in regular dialog windowed mode. Tried toggling it from background image mode using the hotbar, but that only opens a new dialog windowed version underneath, so registers that window but not the background image one.

Also tried adding a reference to for example the manager_maptoken.lua script within record_image.xml, within the <windowclass .. >. Similar to where you'd find calls to the 'updated_imagewindow.lua' in the Enhanced Images.ext above the <sheetdata>.
In attempts to have the windowclasses be visible within the manager_maptoken.lua script, to see if that made a difference. Unfortunately it didn't behave differently afterwards, still giving nil reference errors.

The only way I've found so far that registers the windowclass when in background mode is to open a new 'imagepanelwindow' window. But then I'm left with two image panels which isn't a solution in the end.

25924

Bidmaron
January 10th, 2019, 23:47
Why can’t you just close the new panel after you grab the windowclass? Or can you open it invisible or change it to invisible after opening?

Trenloe
January 11th, 2019, 18:41
The key thing here is that the windowclasses are within a panel on the desktop, so they don't act the same as normal floating windows.

Have a look at the global script ImageManager package scripts\manager_image.lua - I'm not exactly sure what you're trying to do, but some of the info in there might help understand what's going on.

StoryWeaver
January 12th, 2019, 06:33
The key thing here is that the windowclasses are within a panel on the desktop, so they don't act the same as normal floating windows.

Have a look at the global script ImageManager package scripts\manager_image.lua - I'm not exactly sure what you're trying to do, but some of the info in there might help understand what's going on.

Using a helper function in ImageManager I've now managed to retrieve the window class from background image panels. I hadn't noticed the manager_image.lua file, as soon as I poked around it knowing it dealt with the images and panel versions it didn't take me long to find what I needed.


ImageManager.ImageControl(tokeninstance, bOpen)

Returned the windowclass, so now I can plow ahead with the changes needed.

Many thanks Trenloe and others!

Moon Wizard
January 12th, 2019, 07:13
You'll need to use findWindow with the following calls to check every permutation:

For the floating windows, you can get an exact image window by using:
Interface.findWindow("imagewindow", path);

For the background panels, you will need to look up the value of the subwindow within each background panel (if the subwindow exists).
* Use "wBackPanel = Interface.findWindow("imagebackpanel", "")" and "wFullPanel = Interface.findWindow("imagefullpanel", "")" to get each top level panel window.
* If the panel is not nil, then use "sClass, sRecord = wBackPanel.getValue()" to get the contained windows class and path information.
* You don't need the class information, but then you can use the path information to see which image record value that the subwindow is pointing to.

Regards,
JPG

StoryWeaver
January 12th, 2019, 08:28
You'll need to use findWindow with the following calls to check every permutation:

For the floating windows, you can get an exact image window by using:
Interface.findWindow("imagewindow", path);

For the background panels, you will need to look up the value of the subwindow within each background panel (if the subwindow exists).
* Use "wBackPanel = Interface.findWindow("imagebackpanel", "")" and "wFullPanel = Interface.findWindow("imagefullpanel", "")" to get each top level panel window.
* If the panel is not nil, then use "sClass, sRecord = wBackPanel.getValue()" to get the contained windows class and path information.
* You don't need the class information, but then you can use the path information to see which image record value that the subwindow is pointing to.

Regards,
JPG

Thank you Moon Wizard, I've made those changes to another section of my code. It's all coming together now. : )