Posted 01 June 2014 - 07:10 PM
MGTK is my API for GUI creation. I wanted it to be as simple as it could be, and in fact it is.
Example application:
Download:
Pastebin way:
http://pastebin.com/pinmtsYg
MPT Way:
Installing the second way will also give you demo program 'mgtkdemo' and in-game documentation 'man mgtk'
Methods:
Frame creation:
Actual code, source of in-game documentation and demo can be accessed HERE, just click [more] button at mgtk package.
CHANGES:
Use it wherever you want, but if you do, do not tell that you made this API. A note about usage of this with link to this post would be appreciated.
Example application:
Download:
Pastebin way:
http://pastebin.com/pinmtsYg
pastebin get pinmtsYg mgtk
MPT Way:
mpt ppa add magik6k
mpt install mgtk
or
mpt ppa add sysx
mpt install sysx
reboot
mpt ppa add magik6k
mpt install mgtk
Installing the second way will also give you demo program 'mgtkdemo' and in-game documentation 'man mgtk'
Methods:
Frame creation:
- newTermFrame(term)
- newVframe(size)
- newHframe(size)
- newBorderFrame(p1[,p2[,p3,p4]])
- newClickableFrame(action)
- newTextLabel(text)
- newTextButton(text[, action])
- newToggleButton(text1, text2[, action])
- newTextInput(width[, default])
- newPasswordInput(width[, default])
- newEventLoop(termFrame)
Spoiler
require "mgtk"
local n = 0
local main = mgtk.newTermFrame(term)
local eventLoop = mgtk.newEventLoop(main)
local label1 = mgtk.newTextButton("button", function(this)this.setText("button"..tostring(n))n=n+1 main.render()end)
local label2 = mgtk.newTextLabel("label2")
local label3 = mgtk.newToggleButton("toggle", "elggot", function()label2.setText("...")main.render()end)
local label4 = mgtk.newTextLabel("label4")
local label5 = mgtk.newTextInput(10, "textin")
local label6 = mgtk.newTextLabel("label6")
local label7 = mgtk.newPasswordInput(10, "pwd")
local label8 = mgtk.newTextLabel("label8")
local label9 = mgtk.newTextButton("quit", function(this)eventLoop.stop() end)
local vcon1 = mgtk.newVframe(3)
vcon1.put(1, label1)
vcon1.put(2, label2)
vcon1.put(3, label3)
local vcon2 = mgtk.newVframe(3)
vcon2.put(1, label4)
vcon2.put(2, label5)
vcon2.put(3, label6)
local vcon3 = mgtk.newVframe(3)
vcon3.put(1, label7)
vcon3.put(2, label8)
vcon3.put(3, label9)
local hcon = mgtk.newHframe(3)
local bframe1 = mgtk.newBorderFrame(1)
local bframe2 = mgtk.newBorderFrame(1)
local bframe3 = mgtk.newBorderFrame(1)
bframe1.put(vcon1)
bframe2.put(vcon2)
bframe3.put(vcon3)
hcon.put(1, bframe1)
hcon.put(2, bframe2)
hcon.put(3, bframe3)
main.put(hcon)
main.render()
eventLoop.setClickEvent("mouse_click")
eventLoop.setKeyEvent("key")
eventLoop.start()
Actual code, source of in-game documentation and demo can be accessed HERE, just click [more] button at mgtk package.
CHANGES:
- 0.2:
- Added TextInput
- Added PasswordInput
- Added focus support
- Added Key event
- Colors
Text input- Selection lists
- Text area
- Terminal widget
- Intelligent rendering
- Screenies
- Documentation here
Use it wherever you want, but if you do, do not tell that you made this API. A note about usage of this with link to this post would be appreciated.
Edited on 03 June 2014 - 11:48 AM