Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
Dustpuppy

My gui (Now with visual editor)

Recommended Posts

BIG UPDATE!

I've worked out some updates and a new visual editor for the gui system.

To use the gui just download http://pastebin.com/Dfgc6z0T to a computer as /lib/gui.lua and try your best. :)

 

If you don't want to fight with the placing of elements on the screen, then you want to use the visual editor.

It's alpha state, but i hope it will make no errors.

The editor will create a full lua code as frame work for your own program in resolution 80x25 like for a tier 2 screen. But you need a tier 3 screen to use the editor it self. The program you can run then on a tier 2 or tier 3 screen.

Please try it and let me know, what you think. It's a bit flickry when updating the screen, but i hope i get this fixed.

You can download the editor at https://pastebin.com/jdaM8FKG

If you like it, let me know and tell me, what i could change, or what you want me to put into the gui or the editor.

 

Have fun

 

Link to post
Share on other sites

Hey Dustpuppy..

 

I seriously like your design..!

I currently implementing a lot of computers to control our energy, economy, item, shops, farms, trains, roads and a lot of production and storage systems.

 

Your gui is exactly what I'm looking for, I was developing my own like you. But time constraints in the family aspect of life has left me searching alternatives.

Would you be so kind to send me the code for that image you have attached. I know I can create it from your code, but again. Time is not on my side.

I will let you know if I run into some bugs/errors, new features etc...

 

Thanks in advance

Kenneth

Link to post
Share on other sites

Here's the code of the screenshot.

local component = require("component")
local gpu = component.gpu
local gui = require("gui")

local prgName = "Gui-lib v"
local version = gui.Version()

function exitButtonCallback(guiID, id)
  local result = gui.getYesNo("", "Do you really want to exit?", "")
  if result == true then
    gui.exit()
  end
  gui.displayGui(myGui)
end

myGui = gui.newGui(2, 2, 78, 23, true)
exitbutton = gui.newButton(myGui, "center", 21, "exit", exitButtonCallback)

label1 = gui.newLabel(myGui, 2, 1, "A label")
label2 = gui.newLabel(myGui, 2, 3, "A colored label", 0xFF0000, 0xFFFF00)

frame = gui.newFrame(myGui, 2, 5, 40, 6, "A frame")

checkbox1 = gui.newCheckbox(myGui, 3, 7, false)
cbLabel1 = gui.newLabel(myGui, 7, 7, "Checkbox")

checkbox2 = gui.newCheckbox(myGui, 3, 8, true)
cbLabel2 = gui.newLabel(myGui, 7, 8, "Second checkbox")

text = gui.newText(myGui, 2, 12, 25, "Text input")

progress = gui.newProgress(myGui, 2, 16, 35, 100, 0, nil, true)

list = gui.newList(myGui, 50, 3, 25, 10, {"Entry 1", "Entry two", "Number 3", "44444"}, nil, "A List")

vprogress1 = gui.newVProgress(myGui, 44, 3, 10, 100, 0, nil)
vprogress2 = gui.newVProgress(myGui, 46, 3, 10, 100, 0, nil, 1)

radioframe = gui.newFrame(myGui, 48, 14, 25, 6)

radio1 = gui.newRadio(myGui, 50, 15)
radio2 = gui.newRadio(myGui, 50, 16)
radio3 = gui.newRadio(myGui, 50, 17)
radio4 = gui.newRadio(myGui, 50, 18)

radioLabel1 = gui.newLabel(myGui, 54, 15, "Radio button 1")
radioLabel2 = gui.newLabel(myGui, 54, 16, "Radio button 2")
radioLabel3 = gui.newLabel(myGui, 54, 17, "Radio button 3")
radioLabel4 = gui.newLabel(myGui, 54, 18, "Radio button 4")

hline = gui.newHLine(myGui, 5, 20, 40)

gui.clearScreen()
gui.setTop(prgName .. version)

local counter = 0
while true do
  gui.runGui(myGui)
  counter = counter + 1
  if counter <= 100 then
    gui.setValue(myGui, progress, counter)
    gui.setValue(myGui, vprogress1, counter)
    gui.setValue(myGui, vprogress2, counter)
  end
  if counter > 110 then
    counter = 0
  end
end



Link to post
Share on other sites

I have updated the lib. Now it has charts and some file handling for saving tables.

The documentation for the functions i do later. At the moment i am moving house and i have not that much time.

Download link is still the same.

To see all features i've made a program to control passive reactors with up to 25 rods.

http://pastebin.com/2xEFeZC9

 

Link to post
Share on other sites

This is the code, I only tweaked the colors in the gui.lua but didn't touch anything else. 

local component = require("component")
local gpu = component.gpu
local gui = require("gui")
local prgName = "Door control"
local version = "0.1"
local sides = require("sides")
local term = require("term")
local event = require("event")
local i = 0
local io = require("io")


function toggleRedstone(guiID, id)
  for address in component.list("redstone",true) do
    rs = component.proxy(address)
    rs.setOutput(5,15)
   end
end
function untoggleRedstone(guiID, id)
  for address in component.list("redstone",true) do
    rs = component.proxy(address)     
    rs.setOutput(5,0)  
  end
end


function buttonCallback(guiID, id)
  local result = gui.getYesNo("", "Sure?", "")
  if result == true then
    gui.exit()
  end
    gui.displayGui(myGui)
end
 


myGui = gui.newGui(2, 2, 160, 42, false)
exitbutton = gui.newButton(myGui, "center", 38, "exit", buttonCallback)
tButton = gui.newButton(myGui, 1, 2, "Open", toggleRedstone)
untButton = gui.newButton(myGui, 1, 3, "Close", untoggleRedstone)

gui.clearScreen()
gui.setTop(prgName .. " " .. version)
while true do
  gui.runGui(myGui)
end

 

Link to post
Share on other sites

Have done some work on the gui. Most internal, but also put in a vertical slider, a chart and some other elements.

Download link is the same as allways.

Here's an overview of all functions. I will do a proper documentation, if i find the time, but i think my code is good enough to understand it.

 

Quote

Version 2.3

 

---------------------------------------------------------------------------
Example:
---------------------------------------------------------------------------
local component = require("component")
local gpu = component.gpu
local gui = require("gui")

local prgName = "Test"
local version = gui.Version()

function buttonCallback(guiID, id)
  local result = gui.getYesNo("", "Do you really want to exit?", "")
  if result == true then
    gui.exit()
  end
  gui.displayGui(myGui)
end

myGui = gui.newGui(2, 2, 78, 23, true)
button = gui.newButton(myGui, "center", 21, "exit", buttonCallback)

gui.clearScreen()
gui.setTop(prgName .. " " .. version)
while true do
  gui.runGui(myGui)
end
---------------------------------------------------------------------------

 


---------------------------------------------------------------------------
Functions:
---------------------------------------------------------------------------
gui.checkVersion(major, minor)
gui.checkHardware(comp, msg)

gui.clearScreen()
gui.exit()
gui.setTop(text)
gui.setBottom(text)

gui.runGui(guiID)

gui.displayGui(myGui)

gui.closeGui(guiID)

gui.newGui(x, y, w, h, frame, text, bg, fg)
gui.newCheckbox(guiID, x, y, status)
gui.newRadio(guiID, x, y)
gui.newLabel(guiID, x, y, text, bg, fg)
gui.newMultiLineLabel(guiID, x, y, w, h, text, bg, fg)
gui.newButton(guiID, x, y, text, func)
gui.newText(guiID, x, y, lenght, text, func, fieldLenght, hide)
gui.newProgress(guiID, x, y, lenght, maxValue, value, func, number)
gui.newVProgress(guiID, x, y, lenght, width, maxValue, value, func, direction)
gui.newVSlider(guiID, x, y, lenght, min, max, value, func)
gui.newList(guiID, x, y, width, height, tab, func, text)
gui.newFrame(guiID, x, y, width, height, text)
gui.newHLine(guiID, x, y, width)
gui.newChart(guiID, x, y, minValue, maxValue, data, lenght, height, bg, fg)

gui.getSelected(guiID, listID)
gui.setSelected(guiID, listID, selection)
gui.setMax(guiID, widgetID, maxValue)
gui.setChartData(guiID, chartID, data)
gui.setValue(guiID, widgetID, value)
gui.resetProgress(guiID, progressID)
gui.setText(guiID, widgetID, text)
gui.getText(guiID, widgetID)
gui.getCheckboxStatus(guiID, widgetID)
gui.setEnable(guiID, widgetID, state)
gui.setVisible(guiID, widgetID, state)
gui.setBackground(guiID, widgetID, color)
gui.setForeground(guiID, widgetID, color)
gui.clearList(guiID, listID)
gui.insertList(guiID, listID, value)
gui.getRadio(guiID)
gui.setRadio(guiID, radioID)

gui.showError(msg1, msg2, msg3)
gui.showMsg(msg1, msg2, msg3)
gui.getYesNo(msg1, msg2, msg3)

gui.crypt(str, k, inv)
gui.string2key(str)

gui.saveTable(tbl,filename )
gui.loadTable( sfile )

gui.splitString(str, sep)
gui.sepString(str)

 

 

Link to post
Share on other sites

Looks like, i will leave it, like it is now.

Have started a new gui, because this one is not flexible enough :blink:

If someone want to test the new one, it's here https://pastebin.com/J4SXwzHa

Dokumentation is on top of the file.

At the moment it only has 2 elements, a button and a label, but i am working on more.

When i've finished it, i will make a new threat.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.