Jump to content




cyanisaac's basic menu API


7 replies to this topic

#1 cyanisaac

  • Members
  • 369 posts
  • LocationSan Diego, CA

Posted 16 January 2016 - 10:47 PM

cyanisaac's basic menu API
For all of your basic, keyboard-controlled menu needs.

Download

Usage

Licensing

If you want to support me, consider sending Krist (KST) to my Krist address: kccec1d1aa


Edited by cyanisaac, 26 January 2016 - 12:11 AM.


#2 cyanisaac

  • Members
  • 369 posts
  • LocationSan Diego, CA

Posted 17 January 2016 - 01:16 AM

Posted Image
I made a small demo. Load the Basic Menu API as "menu", and then run this program:
pastebin run fSvFMJ5Z

This is a small mockup settings program. The menu API handles all of the rendering and control of the menus, so all you have to focus on are your other custom screens and your control flow.

(Please note that the mockup settings program is missing some screens as it isn't plugged into any end applications - it's a mockup).

#3 Lemmmy

  • Members
  • 218 posts

Posted 17 January 2016 - 01:23 AM

Nice, but the text centering looks a little broken. Try adding one to all centered text?

function center(text, height, color)
    local x,y=term.getSize()
    if height ~= nil then
        term.setCursorPos(((x - string.len(text)) / 2) + 1, height)
    else
        term.setCursorPos(((x - string.len(text)) / 2) + 1, y / 2)
    end
    if color ~= nil then
        term.setTextColor(color)
    end
    term.write(text)
    print("")
end


#4 Pyuu

  • Members
  • 203 posts

Posted 17 January 2016 - 01:23 AM

Does it come with a scroll feature with large lists?

#5 cyanisaac

  • Members
  • 369 posts
  • LocationSan Diego, CA

Posted 17 January 2016 - 01:30 AM

View PostMayushii, on 17 January 2016 - 01:23 AM, said:

Does it come with a scroll feature with large lists?

No, if the list is too long for the computer to display, the API will error. Hence why the name is "cyanisaac's basic menu API." (This API is really barebones). This is a known issue however, and I will be implementing a fix for it SoonTM. As you can see it is already in the "future improvements" list.

For now, just keep your lists short, or implement a button that says "More Options..." that links to another menu.

#6 cyanisaac

  • Members
  • 369 posts
  • LocationSan Diego, CA

Posted 17 January 2016 - 08:32 PM

In the event that anyone is wondering, ProjectB is fine with me releasing this as an API. I've also added him as a "copyright holder" in the license included with the API, since although he didn't write the code it's extremely similar to O's menu system (almost a copy).

So yeah, we're on good terms, this API is allowed to exist.

#7 cyanisaac

  • Members
  • 369 posts
  • LocationSan Diego, CA

Posted 19 January 2016 - 06:05 PM

Later today I will be pushing out an update with a bit of code cleanup, and a new doInfoScreen() function that will allow you to create a screen with information, and the user can press ENTER to exit the screen.

I am going to look to implement some further screens like Y/N info screens, and then after that I will look into colour options.

#8 cyanisaac

  • Members
  • 369 posts
  • LocationSan Diego, CA

Posted 23 January 2016 - 06:27 PM

Somehow I got a bit delayed.

Update to the API is available on Pastebin. Changes include:
  • Added doInfoScreen(title, info)
  • Some code cleanup and other miscellaneous changes.
Report any issues you find. Thanks for using this API! :D

EDIT: Having serious trouble editing the post because the forum software is glitching out with formatting. Going to try recreating the post.
EDIT 2: The forums really screwed up the post.
EDIT 3: After three attempts, several browsers, advanced text editors, and many prayers, I got the forums to cooperate with me and let me modify the post. Woot.

Edited by cyanisaac, 23 January 2016 - 06:55 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users