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.)
How To: ZSCRIPT MENUS?
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!)
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!)
-
- Posts: 2113
- Joined: Thu May 02, 2013 1:27 am
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia with Vulkan support
- Location: Brazil
-
- Posts: 8193
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: How To: ZSCRIPT MENUS?
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.
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.
-
- Posts: 8193
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: How To: ZSCRIPT MENUS?
How can I perform word wrapping with strings?
-
- Posts: 1337
- Joined: Tue Jul 15, 2003 4:18 pm
Re: How To: ZSCRIPT MENUS?
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):
This was cobbled together based on some exiting code in messagebox.txt (that's spread across two functions and uses a class level declaration).
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: Select all
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;
}
-
-
- Posts: 17455
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: How To: ZSCRIPT MENUS?
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?
-
- Posts: 469
- Joined: Sat Apr 16, 2016 6:01 am
- Preferred Pronouns: She/Her
Re: How To: ZSCRIPT MENUS?
It's just pixels, no scaling. If the font has 8 pixel wide chars, 64 width would break it at roughly every 8 characters.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?
-
- Posts: 8193
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: How To: ZSCRIPT MENUS?
Okay, next question. Say I want to draw text as if I did SetHudSize(640, 480, 1); in ACS. How do I do this?
-
- Posts: 469
- Joined: Sat Apr 16, 2016 6:01 am
- Preferred Pronouns: She/Her
Re: How To: ZSCRIPT MENUS?
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.
-
- Posts: 8193
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: How To: ZSCRIPT MENUS?
So (DTA_VirtualWidth,640,DTA_VirtualHeight,480) for the parameters?
-
- Posts: 469
- Joined: Sat Apr 16, 2016 6:01 am
- Preferred Pronouns: She/Her