View Single Post
  #2  
Old 12-28-2004, 04:23 AM
daeken_bb
Discordant
 
Join Date: Mar 2003
Location: Chambersburg, PA
Posts: 469
Default

I love you, will you have my children?

Nice work man

Btw... the UI now supports: Windows, text boxes, and buttons fully. I cleaned up the API a good bit, and it's now getting to be really usable. I have a simple python debug console working perfectly

Here's the actual class that handles input from the user and writes output from the interpreter to the UI. It's derived from InteractiveInterpreter.
Code:
class DevConsole(code.InteractiveInterpreter):
    def write(self, data):
        ui.widgets['chat'].AddText(data.strip() + '\n')
    def Enter(self, textbox):
            if textbox.text == '/quit':
                return -1
            elif textbox.text[:7] == '/python':
                print self.runsource(textbox.text[8:], '<<console>>')
                textbox.SetText('/python ')
            else:
                ui.widgets['chat'].AddText(textbox.text + '\n')
                textbox.SetText('')
            return True
And this is the actual initialization code for the UI Test. Following this is all the implementation-specific rendering stuff. OpenEQ will render to OpenGL of course, but the current UI Test just renders to a pygame (SDL) window:

Code:
class UITest:
    size = (800, 600)
    def __init__(self):
        self.ui = ui.UI(self.size)
        win1 = self.ui.Window('win1', pos=(100, 100), size=(600, 600), bgcolor=(255, 255, 255, 255), outline=(255, 0, 0, 255))
        tb1 = win1.Textbox(name='tb1', pos=(10, 310), size=(580, 40), bgcolor=(0, 0, 0, 255), outline=(255, 0, 0, 255), fgcolor=(255, 255, 255, 255), center=(False, True))
        win1.Textbox(name='chat', pos=(10, 10), size=(580, 300), bgcolor=(0, 0, 0, 255), outline=(255, 0, 0, 255), fgcolor=(255, 255, 255, 255), center=(False, False), freeze=True)

        dc = DevConsole()
        tb1.Register('enter', dc.Enter)
If anyone has any ideas on the API, please let me know. Thanks!

(Btw... those keyword args to the Window and Textbox functions populate the `props' property of the widgets. Soon you'll be able to do win1['bgcolor'] = (255, 255, 255, 255) or whatever also... gotta implement that still )
__________________
Keep me unemployed and working on OpenEQ, PM me about donating

Check out my deviantART page at http://daeken.deviantart.com/
Reply With Quote