
-----------------------------------
Tony
Sun Apr 20, 2003 12:43 am

[source code] Custom GUI
-----------------------------------
I'd like this thread to run the same way text effects does. If you have something to submit - do it here. An exelent way to fight boredem, start rewriting window's GUI in turing!

To start things off, here's something tuirng's GUI defenatly missed -> Percentage Bar


procedure GUIpercent(x1,y1,x2,y2,num:int)

drawfillbox(x1-2,y1-2,x2+2,y2+2, grey)
drawbox(x1-2,y1-2,x2+2,y2+2, black)

for i:1..round((x2-x1)*num/100) by 10
drawfillbox(x1 + i, y1, x1 + i + 7, y2, blue)
end for

end GUIpercent


Highly customizable. You use it the same way you use drawbox, just add additional parameter at the end - percentage as integer (where 50 means 50%) Ofcourse you can change the colors, size of boxes, etc.

And here's the code to make the procedure run:

for i:1..100
locate(1,1)
put i, "%"

GUIpercent(100,100,500,110,i)  % list

Basically it just lists your array into a box placed where you want. It is dynamically sized so you just need x1,y1,x2 parameters + your array.


procedure GUIlist(x1:int, y1:int, x2:int, name:array 1..* of string)

var fontID:int := Font.New("compsci:12")

drawfillbox(x1,y1,x2, y1 - round(sizeof(name)/256)*15 -4 ,grey)
drawbox(x1,y1,x2, y1 - round(sizeof(name)/256)*15 -4 ,black)

for i:1..round(sizeof(name)/256)
Font.Draw(name(i),x1+2, y1 - i*15-2, fontID, black)
end for

Font.Free(fontID)

end GUIlist


Once again, you can customize colors and fonts to suite your programming needs. Please note that alignmet was calculated for a size 12 font. Other values (the *15 one) needs to be adjusted if you change the font to align properly.

Ofcourse here's the code to test it quickly


var n:array 1..10 of string
n(1) := "Tony"
n(2) := "Dan"
n(3) := "compsci"
n(4) := "programming"
n(5) := "blah"
n(6) := "GUI"
n(7) := "custom"
n(8) := "wacom"
n(9) := "warcraft"
n(10) := "blizzard"

GUIlist(200,300,300,n)


-----------------------------------
Catalyst
Thu May 22, 2003 6:38 pm


-----------------------------------
heres a button class and interface module
it is set up so that it can be easily expanded upon

note:314th post (woo pi)

-----------------------------------
Tony
Thu May 22, 2003 6:57 pm


-----------------------------------
awesome.. looks much better (not to mention customazation options) then turing's GUI  :D 

+20Bits

-----------------------------------
Catalyst
Thu May 22, 2003 11:39 pm


-----------------------------------
updated the interface post, now has picture support (replace any fillcolor)
and scales the picture to fit the button

-----------------------------------
Homer_simpson
Fri May 23, 2003 2:13 pm


-----------------------------------
I had created some ccg before i will submit them when i get home

-----------------------------------
Andy
Sat Jun 07, 2003 6:40 pm


-----------------------------------
well, its been 2 weeks, and i'm pretty sure ur home by now, so can we see ur ccg?

-----------------------------------
Homer_simpson
Sat Jun 07, 2003 10:53 pm


-----------------------------------
oops... i totally forgot about that...
it aint completed but here it is :
Mouse.ButtonChoose ("multibutton")

var bfont : int := Font.New ("System:12")
type txtbox :
    record
        text : string
        active, cd, drawn : boolean
        ctime : int
    end record
function timedelay (var r : int, t : int) : boolean
    var tt : int
    if r = 0 then
        clock (r)
        result false
    end if
    clock (tt)
    if tt - r >= t then
        r := tt
        result true
    else
        result false
    end if
end timedelay
function mouseover (x1, y1, x2, y2 : int, var button : int) : boolean
    var x, y, b : int
    mousewhere (x, y, b)
    button := b
    if x >= x1 and x = y1 and y 