def getCascadingAttribute(self,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 self.getCascadingAttribute(game,node.parentNode,attr)
def createLayoutManager(self,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()
def compileDialog(self,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(self.compileComponent(game,dialog,self.getChild("jpanel",xmlDialog)))