Example #1
0
def getCascadingAttribute(game,node,attr):
    settings = game.getSettings();
    res = Parser.parseDimension(settings.getString(Settings.RESOLUTION))
    
    if node.hasAttribute(attr):
        return node.getAttribute(attr)
    else:
        if node.nodeName=="dialog":
            if(attr=="width"): return str(int(res.getWidth()))
            elif(attr=="height"): return str(int(res.getHeight()))
        else:
            return getCascadingAttribute(game,node.parentNode,attr)
Example #2
0
def createLayoutManager(jpanel,sLayout):
    if sLayout=="absolute": return None
    elif sLayout=="flow": return FlowLayout()
    elif sLayout=="border": return BorderLayout()
    elif sLayout.startswith("grid-"):#"grid-1x1"
        dim = Parser.parseDimension(sLayout.split("-")[1])
        return GridLayout(int(dim.getWidth()),int(dim.getHeight()))
    elif sLayout.startswith("box-y"):
        return BoxLayout(jpanel,BoxLayout.Y_AXIS)
    elif sLayout.startswith("box-x"):
        return BoxLayout(jpanel,BoxLayout.X_AXIS)
    elif sLayout.startswith("gridbag"):
        return GridBagLayout()
Example #3
0
def compile_dialog(dialog,game,filename,id):
    "@sig public void compile_dialog(nova.library.graphics.gui.TulipDialog dialog, nova.library.core.Game game, java.lang.String filename, java.lang.String id)"
    #print "Compiling Dialog "+id+" from "+filename
    
    doc = minidom.parse(filename)
    xmlGUI = doc.getElementsByTagName("gui")[0]
    xmlDialog = None
    for node in xmlGUI.getElementsByTagName("dialog"):
        if(node.getAttribute("id")==id):
            xmlDialog = node
            break
    
    settings = game.getSettings();
    res = Parser.parseDimension(settings.getString(Settings.RESOLUTION))
    w = int(xmlDialog.getAttribute("width")) if xmlDialog.hasAttribute("width") else -1
    h = int(xmlDialog.getAttribute("height")) if xmlDialog.hasAttribute("height") else -1
    dialog.setDynamicSize(w,h)
    dialog.setBounds(0,0,(w if w >= 0 else int(res.getWidth())),(h if h >= 0 else int(res.getHeight())))
    dialog.add(reloadComponent(game,dialog,getChild("jpanel",xmlDialog)))
Example #4
0
def reload_dialog(game,gui,filename,id):
    "@sig public javax.swing.JPanel load(nova.library.core.Game game, nova.library.gui.GUI gui, java.lang.String filename, java.lang.String id)"
    #((javax.swing.plaf.basic.BasicInternalFrameUI)myInternalFrame.getUI()).setNorthPane(null);

    doc = minidom.parse(filename)
    xmlGUI = doc.getElementsByTagName("gui")[0]
    xmlJDialog = None
    for node in xmlGUI.getElementsByTagName("dialog"):
        if(node.getAttribute("id")==id):
            xmlJDialog = node   
            break
    
    settings = game.getSettings();
    res = Parser.parseDimension(settings.getString(Settings.RESOLUTION))
    w = int(xmlJDialog.getAttribute("width")) if node.hasAttribute("width") else -1
    h = int(xmlJDialog.getAttribute("height")) if node.hasAttribute("height") else -1
    
    
    jdialog = JDialog(owner,(xmlJDialog.getAttribute("title") if xmlJDialog.hasAttribute("title") else ""),(xmlJDialog.getAttribute("modal") if xmlJDialog.hasAttribute("modal") else "true")=="true")
    #jdialog.setUndecorated((xmlJDialog.getAttribute("undecorated") if xmlJDialog.hasAttribute("undecorated") else "true")=="true")
    jdialog.setSize((w if w >= 0 else int(res.getWidth())),(h if h >= 0 else int(res.getHeight())))
    jdialog.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE)
    jdialog.setContentPane(reloadComponent(game,gui,int(xmlJDialog.getAttribute("id")),getChild("jpanel",xmlJDialog)))
    return jdialog