Jump to content




[API] Mouse and graphic api V1.6.1 beta. Easy to use GUI API with full mouse support

api utility media

  • You cannot reply to this topic
108 replies to this topic

#21 bjornir90

  • Members
  • 378 posts
  • LocationFrance

Posted 12 December 2012 - 06:49 AM

I'm working on implement 2 buttons for the moment, but it's a bit difficult so you need to wait a bit :P

#22 Oct125

  • Members
  • 49 posts

Posted 13 December 2012 - 04:06 AM

Downloading the beta version right now!

--Edit!!

On line 161 "the bottom line" isn't commented! Beta version!

Testing the Non-beta

#23 bjornir90

  • Members
  • 378 posts
  • LocationFrance

Posted 13 December 2012 - 04:21 AM

Thanks you for testing it but I think I will remove this link because it is very buggy but I fixed most of them already :)

#24 Oct125

  • Members
  • 49 posts

Posted 13 December 2012 - 05:09 AM

View Postbjornir90, on 13 December 2012 - 04:21 AM, said:

Thanks you for testing it but I think I will remove this link because it is very buggy but I fixed most of them already :)
Ok!
Now i'm using the non-beta (1.4, i think) and it's working fine! B)

--Edit!

I tested the popUp function but didn't work... So i opened the code and i saw that your: gui.popUp(title, text, x, y, colorLine, colorBackground) function in this post, don't match to the code ( the "x", "y", and "colorLine")... Then i try to fix it and i got this: (Ignoring the popUp position...)
function popUp(title, text, colorLine, color)

And appears to work ;)
1.4 Version!

But... I'm having problems with multi line in the popUp... Any tip?

#25 bjornir90

  • Members
  • 378 posts
  • LocationFrance

Posted 13 December 2012 - 05:34 AM

View PostOct125, on 13 December 2012 - 05:09 AM, said:

View Postbjornir90, on 13 December 2012 - 04:21 AM, said:

Thanks you for testing it but I think I will remove this link because it is very buggy but I fixed most of them already :)/>
Ok!
Now i'm using the non-beta (1.4, i think) and it's working fine! B)
Thanks you ! What are you doing with my API ? Just to know :P

#26 Oct125

  • Members
  • 49 posts

Posted 13 December 2012 - 06:11 AM

View Postbjornir90, on 13 December 2012 - 05:34 AM, said:

View PostOct125, on 13 December 2012 - 05:09 AM, said:

View Postbjornir90, on 13 December 2012 - 04:21 AM, said:

Thanks you for testing it but I think I will remove this link because it is very buggy but I fixed most of them already :)/>
Ok!
Now i'm using the non-beta (1.4, i think) and it's working fine! B)
Thanks you ! What are you doing with my API ? Just to know :P
I'm using your API in my OS! And working very fine! I don't create a topic for the OS yet...

Just to know... I'm using the correct code to check if the button is clicked?
Check the code:
term.setTextColor(colors.white)
gui.drawButton(2, 6, 32, 8, "1", colors.gray)
while true do
btn3 = gui.buttonClick(2, 6, 32, 8)
if btn3 == "true" then    -- Press the button
term.setCursorPos(1,19)
term.setTextColor(colors.lime)
print("Ok!")
sleep(2)
end
end

Using this code, i have to press the button many times... Any tip??

#27 bjornir90

  • Members
  • 378 posts
  • LocationFrance

Posted 13 December 2012 - 07:05 AM

It's the good code but it will check only one time so if you don't click it the first time, it will not detect the click. I have created this to put it in a loop, you should use buttonWaitClick(coord) to wait until the user click this button :).

#28 Oct125

  • Members
  • 49 posts

Posted 13 December 2012 - 10:32 AM

View Postbjornir90, on 13 December 2012 - 07:05 AM, said:

It's the good code but it will check only one time so if you don't click it the first time, it will not detect the click. I have created this to put it in a loop, you should use buttonWaitClick(coord) to wait until the user click this button :).
Ok... But i have a problem... In the screen i have 3 buttons! And i have no idea to the program detect the button pressing!

#29 bjornir90

  • Members
  • 378 posts
  • LocationFrance

Posted 13 December 2012 - 07:06 PM

View PostOct125, on 13 December 2012 - 10:32 AM, said:

Ok... But i have a problem... In the screen i have 3 buttons! And i have no idea to the program detect the button pressing!
And here comes the getSelection() function ! With this powerful function, you can check every buttons actually drawn on the screen !:) It will return the number of your button. Look at the OP for more informations about it :P

#30 ArchAngel075

  • Members
  • 149 posts

Posted 13 December 2012 - 11:29 PM

Suggestion :
Pages Hook, it takes the options you provide it and generates pages with buttons to select the options, it self checks how many pages to gen by
NumPages = NumOptionsGiven / NumOptionCanFitOnScreen rounded to wholeNumber

say 10 options per screen
say we given 33 options, thus 33/10 rounded = 3Pages.

Also to detect what option is what button it uses the options number, ie option 1 = button 1

I could write this myself and you can add to your API if youd like, i feel pretty motivated to try :) i just need to make sure no conflict occur and if youd have any other suggestions (say color support, custom buttons, custom NumOptions per page, etc)

-end-

#31 ArchAngel075

  • Members
  • 149 posts

Posted 14 December 2012 - 12:00 AM

also pls update the pastebin of the non-beta to return version 1.4.1, i was confused when 'gui.render(reset)' was nil even though both versions (in pastebin and my DL file) were same :)Noticed the beta is 1.4.1 if im correct, sorry about that derp

Working on the angelTV update to support pastebin for pastebin movie sharing atlast! your API really makes things more easier :P

#32 ArchAngel075

  • Members
  • 149 posts

Posted 14 December 2012 - 12:42 AM

New Suggestion :P :

I noticed buttons dont auto size based on text, thats ok for when you can choose how long the buttons text is but what ive the text is too long ? It just prints the text longer than the buttons length.

Perhaps have it check over the text length and button length and if text length > BLength then print the text that would be going over the button under the text
ie
'This button'

might become instead

"This Butt
on"

use
ButtonSplit[index] = string.sub(TEXT, buttonLength,string.len(TEXT))
index = index+1

its a table because we might have multiple-runovers, so keep checking the lengths till it wont run over then print text by

index = 1
for index = 1,table.maxn(ButtonSplit)
print(ButtonSplit[index])
index = index+1
end

you could also then expand the Y of the box by b = table.maxn(ButtonSplit)+1 -- plus 1 is optional, its good for spacing inside buttons.

Summary of suggestion :
allow the text that is longer than a buttons length to print over to new lines within a button

-end-

#33 bjornir90

  • Members
  • 378 posts
  • LocationFrance

Posted 14 December 2012 - 04:56 AM

View PostArchAngel075, on 14 December 2012 - 12:00 AM, said:

also pls update the pastebin of the non-beta to return version 1.4.1, i was confused when 'gui.render(reset)' was nil even though both versions (in pastebin and my DL file) were same :)/>Noticed the beta is 1.4.1 if im correct, sorry about that derp

Working on the angelTV update to support pastebin for pastebin movie sharing atlast! your API really makes things more easier :P/>
Thanks you for all your suggestion, but I don't understand the point of the pages... Also the beta is already 1.5 but I didn't touch to render() so ... I didn't understand that too :P. In 1.5, everythings work but the button on the pop-up :)

#34 bjornir90

  • Members
  • 378 posts
  • LocationFrance

Posted 14 December 2012 - 05:00 AM

View PostArchAngel075, on 14 December 2012 - 12:42 AM, said:

New Suggestion :P/> :

I noticed buttons dont auto size based on text, thats ok for when you can choose how long the buttons text is but what ive the text is too long ? It just prints the text longer than the buttons length.

Perhaps have it check over the text length and button length and if text length > BLength then print the text that would be going over the button under the text
ie
'This button'

might become instead

"This Butt
on"

use
ButtonSplit[index] = string.sub(TEXT, buttonLength,string.len(TEXT))
index = index+1

its a table because we might have multiple-runovers, so keep checking the lengths till it wont run over then print text by

index = 1
for index = 1,table.maxn(ButtonSplit)
print(ButtonSplit[index])
index = index+1
end

you could also then expand the Y of the box by b = table.maxn(ButtonSplit)+1 -- plus 1 is optional, its good for spacing inside buttons.

Summary of suggestion :
allow the text that is longer than a buttons length to print over to new lines within a button

-end-
I have find this problem too and I think to make the button auto size with the text lenght, but I will probably add that too :P I think I will add you as a co-dev because of all your suggestion ;p
Oh and thanks, my goal is to make gui easy for everyone :)

#35 ArchAngel075

  • Members
  • 149 posts

Posted 14 December 2012 - 05:13 AM

co-dev lol, that be abit hard... it takes alot to get me typing in any program XD

The pages idea was an branch of how i could have done the previewer in my program(i instead whent for mouse scrolling) and i noticed its useful for some things such as displaying lists >

If you take AngelTV for example :
It is editor mode and you wish to select a file to edit, it outputs pages containing the files names as buttons(or with buttons attached) and vy clicking a file name or button you will open the file in an editor... if the file you need isnt on that page then you can "turn" the page and search that one, it might output say 10 files per page and you want file 22 etc

but this needs some indepth and as i will write this myself and give you the code if you want to use it in your API instead of my adding it to cpsAPI(which i am dropping)

#36 bjornir90

  • Members
  • 378 posts
  • LocationFrance

Posted 14 December 2012 - 05:25 AM

View PostArchAngel075, on 14 December 2012 - 05:13 AM, said:

co-dev lol, that be abit hard... it takes alot to get me typing in any program XD

The pages idea was an branch of how i could have done the previewer in my program(i instead whent for mouse scrolling) and i noticed its useful for some things such as displaying lists >

If you take AngelTV for example :
It is editor mode and you wish to select a file to edit, it outputs pages containing the files names as buttons(or with buttons attached) and vy clicking a file name or button you will open the file in an editor... if the file you need isnt on that page then you can "turn" the page and search that one, it might output say 10 files per page and you want file 22 etc

but this needs some indepth and as i will write this myself and give you the code if you want to use it in your API instead of my adding it to cpsAPI(which i am dropping)
Oh ok. That's a good idea but it shouldn't be very difficult, I will add that and we will see the one wich is better :P *Um Um* Finally I will let you do that because I have a lot of things to do #^^'#

#37 Oct125

  • Members
  • 49 posts

Posted 14 December 2012 - 07:54 AM

View Postbjornir90, on 13 December 2012 - 07:06 PM, said:

View PostOct125, on 13 December 2012 - 10:32 AM, said:

Ok... But i have a problem... In the screen i have 3 buttons! And i have no idea to the program detect the button pressing!
And here comes the getSelection() function ! With this powerful function, you can check every buttons actually drawn on the screen ! :) It will return the number of your button. Look at the OP for more informations about it :P

Hm ok! Thanks and sorry for not paying attention in the functions list :P

#38 ArchAngel075

  • Members
  • 149 posts

Posted 14 December 2012 - 08:16 AM

View PostOct125, on 14 December 2012 - 07:54 AM, said:

View Postbjornir90, on 13 December 2012 - 07:06 PM, said:

View PostOct125, on 13 December 2012 - 10:32 AM, said:

Ok... But i have a problem... In the screen i have 3 buttons! And i have no idea to the program detect the button pressing!
And here comes the getSelection() function ! With this powerful function, you can check every buttons actually drawn on the screen ! :) It will return the number of your button. Look at the OP for more informations about it :P

Hm ok! Thanks and sorry for not paying attention in the functions list :P

For future help i suggest adding this to the spoiler of the function :
gui.setButton(x,y,endx,endy,text,colorline,colorbackground)--button 1
gui.setButton(x,y,endx,endy,text,colorline,colorbackground)--button 2
gui.sRender()
gui.getSelection() --will return 1 if the button is clicked, 2 if the button 2 is clicked and so...


-end-

suggestion! : roundness, yes... i noticed we have rectangles but not round buttons, this can add a lot more, rendering out the button will be easy in my opinion, im not sure how to check its inside cords for the gui.getSelection() perhaps make it save the buttons radius as X (you can also in-depth for ovals if you save two radii X; Y.... I might write a temp of the render and the scan inside since circular buttons just climbed my priority more than pages :P

#39 bjornir90

  • Members
  • 378 posts
  • LocationFrance

Posted 14 December 2012 - 09:21 AM

I don't implement round button for 3 reasons:
1.It's too complicated for what it is
2.In minecraft, there is square and not round
3.It will be a bit ugly cause of the size of the pixel
Feel free to add it ;)

#40 Oct125

  • Members
  • 49 posts

Posted 14 December 2012 - 09:25 AM

View PostArchAngel075, on 14 December 2012 - 08:16 AM, said:

View PostOct125, on 14 December 2012 - 07:54 AM, said:

View Postbjornir90, on 13 December 2012 - 07:06 PM, said:

View PostOct125, on 13 December 2012 - 10:32 AM, said:

Ok... But i have a problem... In the screen i have 3 buttons! And i have no idea to the program detect the button pressing!
And here comes the getSelection() function ! With this powerful function, you can check every buttons actually drawn on the screen ! :) It will return the number of your button. Look at the OP for more informations about it :P

Hm ok! Thanks and sorry for not paying attention in the functions list :P

For future help i suggest adding this to the spoiler of the function :
gui.setButton(x,y,endx,endy,text,colorline,colorbackground)--button 1
gui.setButton(x,y,endx,endy,text,colorline,colorbackground)--button 2
gui.sRender()
gui.getSelection() --will return 1 if the button is clicked, 2 if the button 2 is clicked and so...


-end-

suggestion! : roundness, yes... i noticed we have rectangles but not round buttons, this can add a lot more, rendering out the button will be easy in my opinion, im not sure how to check its inside cords for the gui.getSelection() perhaps make it save the buttons radius as X (you can also in-depth for ovals if you save two radii X; Y.... I might write a temp of the render and the scan inside since circular buttons just climbed my priority more than pages :P

Thanks ArchAngel075!!
I'm programming in the right way now, but i'm having problems... And, one solution would be to create a function that clears the buffer without drawing it... So there is the suggestion :P

function bClear()
runButton = {}
runHeader = {}
coordButton = {}
end


--EDIT!!!

The current way to clear the buffer don't clear the buttons coordinates!!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users