Zforms example gzdoom crash

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
User avatar
ramon.dexter
Posts: 1529
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Zforms example gzdoom crash

Post by ramon.dexter »

Hi, I wanted to learn how to make menus using the Zforms, but I have necountered serious problem.

I downloaded the github example from (https://github.com/Doom2fan/ZFormsExamples) and tried running it to see how it looks.
Console command "openmenu Samples_ZF_DynamicElementCreation" works and brings the sample dyamic element showing owned weapons.
Console command "openmenu Samples_ZF_SimpleMenu" brings gzdoom to desktop crash with the only error saying "Access violation - trying to read from adress zero". Nothing else, so I cannot provide more info, neither I can debug anything. It certainly cannot access something, but I don't know what, because it shows no other error.
I'm using gzdoom 4.6.0.

What is going on? I mean, how an I supposed to run this example? It certainly is bugged, but my skill is too low to debug this. Would anyone help me?
Jarewill
 
 
Posts: 1768
Joined: Sun Jul 21, 2019 8:54 am

Re: Zforms example gzdoom crash

Post by Jarewill »

I have encountered the same issue and the reason to it is that the version 1.0 of ZForms is broken with the current GZDoom.
If you want to use ZForms, you have to download the newest master here.

However all the code provided in the ZFormsExamples is valid and works with the newest master of ZForms, so it's still a good source of learning how to use it.
Another source of information that helped me a ton is the documentation.
User avatar
Enjay
 
 
Posts: 26534
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Zforms example gzdoom crash

Post by Enjay »

I can't check things right now, but any idea if this bug in zforms will affect Nash's PDA starter kit? I have used the PDA kit quite recently and did not experience a crash but perhaps I simply didn't do something that would trigger it?
Jarewill
 
 
Posts: 1768
Joined: Sun Jul 21, 2019 8:54 am

Re: Zforms example gzdoom crash

Post by Jarewill »

The crash happens when you define a button in the 1.0 release of ZForms.
Nash's PDA however works fine while having a lot of buttons, so I assume Nash either fixed it or used a newer version of ZForms.
User avatar
Enjay
 
 
Posts: 26534
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Zforms example gzdoom crash

Post by Enjay »

Thanks for the info. Looking at the relevant forum, it looks like Nash released the most recent version of the PDA kit in November 2020 which, presumably, is before the bug with 4.6.1 raised its head and prompted a fix in ZForms? If so, I guess Nash must have fixed it in the PDA starter kit code. Thanks again.
User avatar
ramon.dexter
Posts: 1529
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: Zforms example gzdoom crash

Post by ramon.dexter »

Jarewill wrote:I have encountered the same issue and the reason to it is that the version 1.0 of ZForms is broken with the current GZDoom.
If you want to use ZForms, you have to download the newest master here.

However all the code provided in the ZFormsExamples is valid and works with the newest master of ZForms, so it's still a good source of learning how to use it.
Another source of information that helped me a ton is the documentation.
Oh, great. I actually already downloaded the zforms master and personalized it for my use with the python script.
So, all I have to do now is actually make the menu and try it. Great, just great.
Jarewill
 
 
Posts: 1768
Joined: Sun Jul 21, 2019 8:54 am

Re: Zforms example gzdoom crash

Post by Jarewill »

If you copy the menus from the Examples file and change a few class names, it should still work.
The issue was with the ZForms files and not with the menus provided in Examples.
User avatar
ramon.dexter
Posts: 1529
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: Zforms example gzdoom crash

Post by ramon.dexter »

Umm, not actucally completely true. I tried following the example, making new menu...and some methods used in the example looks like being changed.

Code: Select all

class soaMenuHandler : soa_ZF_Handler {
    soaMenu link;
    override void buttonClickCommand(soa_ZF_Button caller, string command) {
        if ( command == "soaButton01" ) {
            //button action here
            link.soaLabel.setTextColor = random [textColor] (Font.CR_BRICK, Font.CR_TEAL);
        }
    }
}
class soaMenu : soa_ZF_GenericMenu {
    soaMenuHandler handler;
    Font smallfont;
    soa_ZF_Image background;
    soa_ZF_Button soaButton01;
    soa_ZF_Label soaLabel;

    override void Init (Menu parent) {
        Vector2 baseRes = (320, 200);

        Super.Init(parent);

        SetBaseResolution(baseRes);

        smallfont = OptionFont();

        handler = new("soaMenuHandler");
        handler.link = self;

        background = soa_ZF_Image.Create (
            (0, 0),//position
            (320, 200), //size
            "graphics/soaMenu/Panel.png",//image path/name
            soa_ZF_Image.AlignType_TopLeft
        );
        background.Pack(mainFrame);

        // Create the box image's textures.
        let boxTexture = soa_ZF_BoxTextures.CreateTexturePixels (
            "graphics/soaMenu/BoxTexture.png",//the texture itself
            (32, 32), //top-left corner of the middle of the box
            (64, 64), //bottom-right corner of the middle of the box
            false, //scale-true, tile-false the sides
            false //scale-true, tile-false the middle
        );
        //add a box image
        let boxSize = (128, 128);
        let aBoxImage = soa_ZF_BoxImage.Create (
            ((baseRes.X - boxSize.X) / 2.0, (baseRes.Y - boxSize.Y) / 2.0), //position
            boxSize, //size
            boxTexture, //texture
            (0.25, 0.25) //scale
        );
        aBoxImage.Pack(mainFrame);

        //create the button's textures
        let buttonIdle = soa_ZF_BoxTextures.CreateSingleTexture("graphics/soaMenu/SmallButtonIdle.png", true);
        let buttonHover = soa_ZF_BoxTextures.CreateSingleTexture("graphics/soaMenu/SmallButtonHovered.png", false);
        let buttonClick = soa_ZF_BoxTextures.CreateSingleTexture("graphics/soaMenu/SmallButtonClicked.png", false);

        //add a button
        soaButton01 = soa_ZF_Button.Create (
            ((baseRes.X - 18.0) / 2.0, (baseRes.Y - 18.0) / 2.0),//position
            (18, 18), //size
            cmdHandler : handler, //command handler
            command : "soaButton01", //command string for button
            inactive: buttonIdle,
            hover: buttonHover,
            click: buttonClick
        );
        soaButton01.Pack(mainFrame);

        //add a label
        soaLabel = soa_ZF_Label.Create(
            (0, soaButton01.box.pos.Y + soaButton01.box.size.Y + 4), //position  //<<<Getting error here, saying the protected member 'box' cannot be accessed. I don't know how to change this, since I cant figure out where the box is defined...
            (0, smallFont.GetHeight()),
            text: "Click me!", //label's text
            fnt: smallFont, //font to use
            wrap: false, //auto text wrap
            autoSize: true, //auto resize elements
            textColor: Font.CR_WHITE //text color
        );
        // Calculate the horizontal position for the label so that it's centered on the screen.
        soaLabel.box.pos.X = baseRes.x - smallFont/stringWidth(soaLabel.text) / 2.0; //<<<Also, Getting error here, saying the protected member 'box' cannot be accessed. I don't know how to change this, since I cant figure out where the box is defined...
        //add element ot mainframe
        soaLabel.Pack(mainFrame);
    }
}
(0, soaButton01.box.pos.Y + soaButton01.box.size.Y + 4), //position //<<<Getting error here, saying the protected member 'box' cannot be accessed. I don't know how to change this, since I cant figure out where the box is defined...
Jarewill
 
 
Posts: 1768
Joined: Sun Jul 21, 2019 8:54 am

Re: Zforms example gzdoom crash

Post by Jarewill »

Ah, yeah, a few things have to be changed it seems.
You cannot access the pos and size variables like this anymore, now you have to use the GetPos and GetSize functions.

Also you can specify a label directly in the button as the third argument (after size, before cmdHandler)
User avatar
Nash
 
 
Posts: 17439
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: Zforms example gzdoom crash

Post by Nash »

No, I actually didn't "fix" anything in the ZForms of my PDA Starter Kit. I was using just whatever stock release that was available at the time. Unfortunately I don't remember if it was a "stable" release or not.

Fair warning, ZForms "latest master" as of today is WIP code, it's ZForms 2.0, which is incompatible with ZForms 1.0 (very big API changes). It's not complete yet and there's no official documentation and even I myself haven't upgraded in my ZForms-based projects... not wise to work with moving targets...
User avatar
ramon.dexter
Posts: 1529
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: Zforms example gzdoom crash

Post by ramon.dexter »

jarewill: Many thanks. I've never workd with UI before, so it is pretty new to me.
User avatar
Enjay
 
 
Posts: 26534
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Zforms example gzdoom crash

Post by Enjay »

Nash wrote:No, I actually didn't "fix" anything in the ZForms of my PDA Starter Kit. I was using just whatever stock release that was available at the time. Unfortunately I don't remember if it was a "stable" release or not.
Well, either by luck or design, the PDA starter kit (and projects based off it) seem to still be working as intended. :thumb:
User avatar
phantombeta
Posts: 2089
Joined: Thu May 02, 2013 1:27 am
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: Brazil

Re: Zforms example gzdoom crash

Post by phantombeta »

The PDA starter kit is probably not using any tiling textures, nor box/multi-textures. It's also using a version of ZForms from before single-texture button rendering and API was unified with box/multi-textures, so that doesn't use Shape2D either.
Also, this crash has been fixed in GZDoom itself, as far as I know, it's just not in a stable release yet.
User avatar
Enjay
 
 
Posts: 26534
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Zforms example gzdoom crash

Post by Enjay »

So, it's not using any of the features that cause the crash and uses a version of ZForms that didn't even have one of the features where the crash could happen. That would certainly explain the lack of crashing with the PDA Starter kit. :yup:

And a GZDoom-side fix is pending an official release. Also good to know.

Thank you kindly.
Jarewill
 
 
Posts: 1768
Joined: Sun Jul 21, 2019 8:54 am

Re: Zforms example gzdoom crash

Post by Jarewill »

phantombeta wrote:The PDA starter kit is probably not using any tiling textures, nor box/multi-textures. It's also using a version of ZForms from before single-texture button rendering and API was unified with box/multi-textures, so that doesn't use Shape2D either.
Also, this crash has been fixed in GZDoom itself, as far as I know, it's just not in a stable release yet.
Oh, I see. Thanks for the information!
However I already started using a master of ZForms, (not current one, but a recent one, unsure which) so should I switch back to 1.0 or wait for the 2.0 version that's in the works?
Post Reply

Return to “Scripting”