Re: How To: ZSCRIPT MENUS?

Sat Sep 16, 2017 7:04 pm

Does anyone have some kind of example of a simple buy/sell menu?
I'd like to convert my mod's shop system to ZScript, as right now it's a messy ACS script, but I don't really see much info on menus on the wiki...

(Also, please don't tell me to download a huge mod and look at its source code. I'm using my phone's internet connection, and it has an usage cap, so I can't download anything big. Right now I have less than 300 MB left, and if I use all that up it'll stop working completely.)

Re: How To: ZSCRIPT MENUS?

Tue Sep 26, 2017 9:03 am

Well D4D has a custom purchase menu, although it's a bit primitive and difficult to understand.

And, sorry, but all I can recommend is you download it. Here's the thread, however the data itself has been split from the resources so at the very least, you can open the code package.

Re: How To: ZSCRIPT MENUS?

Thu Oct 12, 2017 7:04 pm

How can I perform word wrapping with strings?

Re: How To: ZSCRIPT MENUS?

Thu Oct 12, 2017 7:16 pm

Use the the Font.BreakLines function.

Something like this (untested - copy/pasted and simplified from working code in Blade of Agony's skill menus - variable names should be self explanatory):
Code:
    double fontheight = SmallFont.GetHeight();

    BrokenLines message = SmallFont.BreakLines(inputstring, desiredmaxwidth);

    int c = message.Count();

    for (int i = 0; i < c; i++)
    {
        screen.DrawText (SmallFont, Font.CR_UNTRANSLATED, x, y, message.StringAt(i));
        y += fontheight;
    


This was cobbled together based on some exiting code in messagebox.txt (that's spread across two functions and uses a class level declaration).

Re: How To: ZSCRIPT MENUS?

Fri Oct 13, 2017 12:14 am

What is the second int parameter for BreakLines supposed to be? It's confusing. At first I thought it was maximum amount of characters, but it's not. So pixels (as in real pixels relative to your resolution)? Or scaled (virtual) pixels?

Re: How To: ZSCRIPT MENUS?

Fri Oct 13, 2017 4:23 am

Nash wrote:What is the second int parameter for BreakLines supposed to be? It's confusing. At first I thought it was maximum amount of characters, but it's not. So pixels (as in real pixels relative to your resolution)? Or scaled (virtual) pixels?

It's just pixels, no scaling. If the font has 8 pixel wide chars, 64 width would break it at roughly every 8 characters.

Re: How To: ZSCRIPT MENUS?

Mon Oct 16, 2017 8:31 am

Okay, next question. Say I want to draw text as if I did SetHudSize(640, 480, 1); in ACS. How do I do this?

Re: How To: ZSCRIPT MENUS?

Mon Oct 16, 2017 3:59 pm

Use DTA_VirtualWidth and DTA_VirtualHeight in the draw calls. I can't remember whether SetHudSize preserves aspect ratio, but if you want that, you can use DTA_KeepRatio.

Re: How To: ZSCRIPT MENUS?

Mon Oct 16, 2017 4:03 pm

So (DTA_VirtualWidth,640,DTA_VirtualHeight,480) for the parameters?

Re: How To: ZSCRIPT MENUS?

Tue Oct 17, 2017 5:11 am

Yes.