Book GUI System

Started by Babar, Yesterday at 16:27:17

Previous topic - Next topic

Babar

The plan is for my game to have maybe about a dozen books. These can be read where they are, and some maybe picked up and carried as inventory. I figured instead of making a dozen different GUIs or a dozen different rooms, I'd make a "book GUI system" instead. I haven't completed it yet, but I'd figure I'd mention how I'm planning on going about it here, and get input on if I'm doing something wrong or overcomplicating stuff.

Things I'm doing to simplify my life:
  • No page turn animations
  • Books always open to the middle (the border image would stay the same, and you'd never see the cover from the front)
  • There can be images, but if a page has an image, it'll only be in a fixed position (center top)
  • No position saving when you close and reopen a book

EDIT: I wanted to share a mockup, but imgur doesn't seem to work any more. Someone have an alternative?
My idea was to have a struct that would contain:
  • The text of the book (likely not going to be more than 5-6 "pages")
  • A variable to hold the colour of the cover (will be used to assign relevant images to the visible edges of the cover)
  • A variable to hold the colour of the pages (will be used to assign the relevant images for the edge of the paper, as well as the "page turn" button)
  • (Getting complicated for me here) An array holding all the images in the book, with the index having 0 if there is no image on a page

Then when the player picks up a book and reads it, set up the GUI with the variables of the relevant instance of the struct, and make it visible.

Two things are currently worrying me:
Could there be an easier way of having the book than just typing it all out as a string in the script?

Splitting the text of the book into pages- I'm guessing I'll need to figure out a max number of characters, and if a word extends beyond that, move it and the rest of the text to the next page. Will need to figure out a way to calculate that includes whether the page has an image or no image

Is there something I'm missing that vastly simplifies this all? Is there something that I'm missing that will complicate everything? Is there a better way to do this? Thanks in advance for your help!

EDIT; I wanted to share a mockup, but imgur doesn't seem to work anymore. Someone have an alternative?
The ultimate Professional Amateur

Now, with his very own game: Alien Time Zone

eri0o

I have used different implementations of ImgBB for file hosting sometimes - I think one of those is https://imgbb.com/ ? It's like a hosted by someone Imgur basic clone like thing I think.

About the book GUI system, you need the images? If you want you can try using the Fancy module to see if it can handle images in the strings themselves and assign the resulting image (with text and sprites) in a button to be the page contents. Not sure how well that will go but it's an idea.

I once did a text only book system and used a directory that I packaged along the game (using the option from general settings) and had a bunch of "book_001.txt" text files which I edited in a different text editor that had spellcheck and made they be loaded by the game (using the $DATA file token). It worked nice but I didn't have images or any need for complex layouts so there wasn't much testing of the text of each book to get it to render correctly in the engine.

Crimson Wizard

Quote from: Babar on Yesterday at 16:27:17EDIT; I wanted to share a mockup, but imgur doesn't seem to work anymore. Someone have an alternative?

Imgur worked a day ago, I've posted one image here, and it's still showing:
https://www.adventuregamestudio.co.uk/forums/index.php?msg=636684832

Are you sure you are using the correct BBCode link?

Babar

Quote from: Crimson Wizard on Yesterday at 17:28:52
Quote from: Babar on Yesterday at 16:27:17EDIT; I wanted to share a mockup, but imgur doesn't seem to work anymore. Someone have an alternative?

Imgur worked a day ago, I've posted one image here, and it's still showing:
https://www.adventuregamestudio.co.uk/forums/index.php?msg=636684832

Are you sure you are using the correct BBCode link?
It wasn't even letting me upload.
But I've shared an image now with imagebb, thanks eri0o.



Quote from: eri0o on Yesterday at 17:17:40About the book GUI system, you need the images? If you want you can try using the Fancy module to see if it can handle images in the strings themselves and assign the resulting image (with text and sprites) in a button to be the page contents. Not sure how well that will go but it's an idea.

I once did a text only book system and used a directory that I packaged along the game (using the option from general settings) and had a bunch of "book_001.txt" text files which I edited in a different text editor that had spellcheck and made they be loaded by the game (using the $DATA file token). It worked nice but I didn't have images or any need for complex layouts so there wasn't much testing of the text of each book to get it to render correctly in the engine.
I was thinking about simplifying the images by just having them be full page width in the background, and text on top of them, and manually spacing out the text if an image is there. So the images array could have one value for an empty page, and another for an image (could just be the sprite index, in fact).
The ultimate Professional Amateur

Now, with his very own game: Alien Time Zone

Snarky

Like Eri0o, I would suggest reading the contents from a separate text file rather than putting it directly in the script.

I always default to managed structs, which in AGS v3.x don't support strings or dynamic arrays, so that might be an issue.

As for the images, instead of using sprite IDs directly, I would suggest putting them in a view, and for example using the loop number for the book index and the frame number as the page index of the one to display. You have to do a little bit of work to retrieve the sprite, but it will make it easier to inspect and play around with the images.

SMF spam blocked by CleanTalk