Jump to content




fsEAPI (fsExpose graphics/GUI API) - to be expanded

api computer lua

12 replies to this topic

#1 Piorjade

  • Members
  • 244 posts
  • LocationComputer, Germany

Posted 30 December 2016 - 12:48 AM

fsEAPI - fsExpose graphics/GUI API


What does is it (currently) do?:
(Make an empty table, which will later contain your items (buttons, textboxes, etc) to use the API)
  • Create buttons (which get inserted in the specified table)
  • Create textboxes (which get inserted in the specified table)
  • Create ScrollBoxes (yes, they can scroll and you can select things)
  • Create Labels (they are the same as textboxes, but aren't editable)
  • Create Toggles (click on them to toggle them, obviously)
  • Add a context (right-click) menu for specific ScrollBoxes
  • Draw every item of a specified table (warning: screen gets cleared)
  • Update (redraw) a specified item (useful for editing text of a textbox)
  • Handle events for the items of the given table
    • Once you click on a button, the API queues an event "button_press", which contains the type of the item and the key of the item (e.g. myTable[clickedButton] ) for you to do something with that information

      It also blinks blue :P/>
    • Once you click on a textbox, it starts reading input and when you press enter, it saves your entered text and queues an event with the type of the item and key as value (e.g. myTable[editedTextBox] ) for you to do something with that information
    • Once you click on something inside a ScrollBox, it marks that line blue and queues an event "scrollBox_select", which returns "scrollBox", the indexkey (name) of the ScrollBox, the indexkey (index number) of the selected text (items.myScrollBox.childs[key])
    • Once you add a context menu and right click on something inside a ScrollBox, it marks that line blue and shows the context menu, if you click on something inside the context menu it gets marked blue, the context menu gets invisible shortly after that and then it queues an event "context_select", which returns the indexkey (name) of the ScrollBox, the indexkey (index number) of the selected text of the scrollBox, the selected text inside the context menu (--> NOT the key, but the actual text that was written on the context menu)

      If you click outside the context menu it gets invisible and you can continue clicking on other things
  • More items to be added~~
So how to do it? (example code containing every current function):
Pastebin


Small docu:
fsEAPI.addButton(TABLE, NAME, TEXT, LENGTH, XPOS, YPOS)
--add a button to the given table with the given name, which will be the key (TABLE[NAME] = {data} )

fsEAPI.addTextBox(TABLE, NAME, TEXT, LENGTH, XPOS, YPOS)
--add a textbox, the same as above

fsEAPI.addLabel(TABLE, NAME, TEXT, LENGTH, XPOS, YPOS)
--add a label, the same same as a textbox but they aren't editable

fsEAPI.update(DATATABLEOFITEM)
--update/redraw the given item , e.g. fsEAPI.update( TABLE[NAME] )

fsEAPI.updateAll(TABLE, BACKGROUNDCOLOR)
--clear the screen and draw every item of that given table

fsEAPI.run(TABLE)
--goes into a loop and returns interactions with items of the given table as events:
event, typeOfItem, nameOfItem

fsEAPI.addScrollBox(TABLE, NAME, LENGTHx, LENGTHy, XPOS, YPOS)
--add a scrollbox, with the given name and length in both dimension. an event gets queued when selecting an item inside the box returning:
event (scrollBox_select), typeOfItem (scrollBox), nameOfItem (name of the scrollbox), numberOfChild

fsEAPI.addChild(SCROLLBOXITEM, STRING)
--add a child (text) to the scrollbox

fsEAPI.addContextMenu(SCROLLBOXITEM, TABLEOFCHILDS)
--add a context menu to the scrollbox, enabling the right-click. when clicking on the context menu it returns:
event (context_select), nameOfScrollBox, numberOfSelectedChildInScrollBox, nameOfSelectedChildInContext

fsEAPI.removeChild(SCROLLBOXITEM, KEYNUMBER)
--remove a child from a scrollbox by it's key(index number)

fsEAPI.addToggle(TABLE, NAME, XPOS, YPOS)
--add a toggle, if you want to get the state, just look at TABLE[NAME].toggled (which is true or false)
  it returns: event (toggle), typeOfItem (toggle), nameOfToggle, nil

NOTE:
When adding or removing things, they won't get drawn or automatically removed, you need to call update(ITEM) on that specific thing or just updateAll(ÍTEMLIST, BACKGROUNDCOLOR) to redraw these things.

Ok where is the download?:
Pastebin
pastebin get 8JRrW0Va fsEAPI

Pics?:

Posted Image

Btw this was actually meant to be used in my second version of fsExpose buuut I thought I'd upload this so..yeah..

Edited by Piorjade, 15 February 2017 - 06:20 PM.


#2 TheRockettek

  • Members
  • 547 posts
  • LocationRem is best girl

Posted 30 December 2016 - 09:50 AM

omg iwas gonna make this over the weekend (known as "stacks") well i'll still do it anyway :D

#3 Piorjade

  • Members
  • 244 posts
  • LocationComputer, Germany

Posted 03 January 2017 - 06:25 PM

Coming up:
Scrollboxes, every line containing text inside the box is selectable (--> you can click on a line (which contains text) and it gets marked blue and also the API has a function to return which "text" got selected)

The scrollbox maybe even will have a scrollbar at the right, I'm not sure if I should do that tho...

#4 Piorjade

  • Members
  • 244 posts
  • LocationComputer, Germany

Posted 03 January 2017 - 08:42 PM

UPDATE:
  • Added scrollboxes, they have selectable items, will update documentation soon


#5 Piorjade

  • Members
  • 244 posts
  • LocationComputer, Germany

Posted 04 January 2017 - 05:41 PM

ANOTHER UPDATE:
  • added in context menus for scrollboxes, they even are optional, look on the example code for usage info or read the docu
Ongoing: I'll update the example code to show off some practical usage of the context menu and the textbox



ANOTHER ONE:
  • added removeChild(SCROLLBOXITEM, KEYNUMBER)
  • edited example code:
    • you can put something in the textbox and when you finish, it gets added to the scrollbox
    • you can delete childs from the scrollbox
I'm surprised how simple this is :P

Edited by Piorjade, 04 January 2017 - 07:48 PM.


#6 D3matt

  • Members
  • 830 posts

Posted 17 January 2017 - 06:53 AM

Does this support variables inside of textboxes? For example if I set a variable and call updateAll then change that variable and call updateAll again, will the value of that variable update?

#7 Piorjade

  • Members
  • 244 posts
  • LocationComputer, Germany

Posted 18 January 2017 - 06:02 PM

View PostD3matt, on 17 January 2017 - 06:53 AM, said:

Does this support variables inside of textboxes? For example if I set a variable and call updateAll then change that variable and call updateAll again, will the value of that variable update?

Sorry, but no it doesn't.

#8 D3matt

  • Members
  • 830 posts

Posted 21 January 2017 - 04:27 PM

I figured it out, you just need to manually edit the value in the table.

FYI, you declare maxX and maxY at the top of your API but never actually use those values when creating your window. This results in having a lot of empty and unusable space when run on a monitor.

#9 Piorjade

  • Members
  • 244 posts
  • LocationComputer, Germany

Posted 23 January 2017 - 02:57 PM

View PostD3matt, on 21 January 2017 - 04:27 PM, said:

I figured it out, you just need to manually edit the value in the table.

FYI, you declare maxX and maxY at the top of your API but never actually use those values when creating your window. This results in having a lot of empty and unusable space when run on a monitor.

Oh wow that was retarded, gonna fix that XD

EDIT:
Should be fixed now.

Edited by Piorjade, 23 January 2017 - 02:58 PM.


#10 D3matt

  • Members
  • 830 posts

Posted 29 January 2017 - 03:21 AM

Thanks for fixing that. If I may suggest, you should add a "label" object. Same as a text box, but can't be edited.

#11 Piorjade

  • Members
  • 244 posts
  • LocationComputer, Germany

Posted 29 January 2017 - 02:05 PM

View PostD3matt, on 29 January 2017 - 03:21 AM, said:

Thanks for fixing that. If I may suggest, you should add a "label" object. Same as a text box, but can't be edited.

Ok I'm on it.

#12 Piorjade

  • Members
  • 244 posts
  • LocationComputer, Germany

Posted 29 January 2017 - 02:52 PM

UPDATE:
  • added labels, they are the same as textboxes but not editable


#13 Piorjade

  • Members
  • 244 posts
  • LocationComputer, Germany

Posted 15 February 2017 - 06:19 PM

UPDATE:
  • Added in a toggle-button (click to toggle lol)
    • Queues an event "toggle", which returns the type of the item ("toggle") and the name of the toggle (key)






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users