def setPreviewText(self): self.tilePreviewSave.set_text( datafiles.getTilesetPath("tiles.png", True)) self.parallaxPreviewSave.set_text( datafiles.getParallaxPath("parallax.png", True)) self.tilePreviewLoad.set_text(datafiles.getTilesetPath("tiles.png")) self.parallaxPreviewLoad.set_text( datafiles.getParallaxPath("parallax.png"))
def setPreviewText(self): self.tilePreviewSave.set_text(datafiles.getTilesetPath("tiles.png", True)) self.parallaxPreviewSave.set_text(datafiles.getParallaxPath( "parallax.png", True)) self.tilePreviewLoad.set_text(datafiles.getTilesetPath("tiles.png")) self.parallaxPreviewLoad.set_text(datafiles.getParallaxPath( "parallax.png"))
def __writeParallax(self, parallax, index): dictionary = {} dictionary["index"] = index dictionary["fileName"] = datafiles.getParallaxPath(parallax.fileName, True) dictionary["vTile"] = parallax.vTile dictionary["hTile"] = parallax.hTile dictionary["vScroll"] = parallax.vScroll dictionary["hScroll"] = parallax.hScroll dictionary["vScrollSpeed"] = parallax.vScrollSpeed dictionary["hScrollSpeed"] = parallax.hScrollSpeed dictionary["visible"] = parallax.visible return dictionary
def __init__(self, parent, parallax): if parallax is not None: self.parallax = parallax else: self.parallax = background.ParallaxLayer() if self.parallax.fileName is None: fileName = "New Background" else: fileName = self.parallax.fileName gtk.Dialog.__init__(self, os.path.basename(fileName), parent, gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_APPLY, gtk.RESPONSE_ACCEPT)) builder = HIGTableBuilder() builder.addSectionHeader("Appearance") fFilter = graphics.getFileFilter() self.fileChooser = gtk.FileChooserDialog( "Choose Background Image", self, gtk.FILE_CHOOSER_ACTION_OPEN, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_ACCEPT)) self.fileChooser.add_filter(fFilter) self.fileButton = gtk.FileChooserButton(self.fileChooser) if self.parallax.fileName is not None: self.fileChooser.set_filename(self.parallax.fileName) self.fileButton.set_width_chars(6) # Set the default directory of the file chooser based on the file prefix # setting from the preferences. This should save a few clicks. path = datafiles.getParallaxPath("") print path if path != "": print "set_current_folder" self.fileChooser.set_current_folder(path) builder.addLabeledWidget("_Image", self.fileButton) builder.addSectionHeader("Repeat") self.tileHorizontally = gtk.CheckButton("Repeat Horizontally", True) self.tileHorizontally.set_active(self.parallax.hTile) builder.addWidget(self.tileHorizontally) self.tileVertically = gtk.CheckButton("Repeat Vertically", True) self.tileVertically.set_active(self.parallax.vTile) builder.addWidget(self.tileVertically) builder.addSectionHeader("Scrolling") self.scrollHorizontally = gtk.CheckButton("Scroll Horizontally", True) self.scrollHorizontally.connect("toggled", self.scrollHorizontallyChanged) builder.addWidget(self.scrollHorizontally) self.scrollHorizontallySpeed = gtk.SpinButton( gtk.Adjustment(self.parallax.hScrollSpeed, 0, 20.0, 0.1, 1.0, 0.0), 0.1, 2) builder.addLabeledWidget("Horizontal Scroll Speed", self.scrollHorizontallySpeed) self.scrollVertically = gtk.CheckButton("Scroll Vertically", True) self.scrollVertically.connect("toggled", self.scrollVerticallyChanged) builder.addWidget(self.scrollVertically) self.scrollVerticallySpeed = gtk.SpinButton( gtk.Adjustment(self.parallax.vScrollSpeed, 0, 20.0, 0.1, 1.0, 0.0), 0.1, 2) builder.addLabeledWidget("Vertical Scroll Speed", self.scrollVerticallySpeed) self.scrollHorizontally.set_active(self.parallax.hScroll) self.scrollHorizontallySpeed.set_sensitive(self.parallax.hScroll) self.scrollVertically.set_active(self.parallax.vScroll) self.scrollVerticallySpeed.set_sensitive(self.parallax.vScroll) self.vbox.add(builder.getTable()) self.show_all() self.set_resizable(False)
def __readParallax(self, dictionary): p = background.ParallaxLayer() index = -1 if "index" in dictionary: if type(dictionary["index"]) == int: index = dictionary["index"] else: log.error("The index of a parallax layer must be an integer.") else: log.error("Layer index not specified. This may lead to file corruption.") if "fileName" in dictionary: p.fileName = datafiles.getParallaxPath( dictionary["fileName"]) else: log.error("No file name specified in file for parallax") if "vTile" in dictionary: if type(dictionary["vTile"]) == bool: p.vTile = dictionary["vTile"] else: log.error("vTile for a parallax background must be \"true\" or \"false\". Defaulting to false.") else: log.error("Vertical tiling not specified for parallax. Defaulting to false.") p.vTile = False if "hTile" in dictionary: p.hTile = bool(dictionary["hTile"]) else: log.error("Horizontal tiling not specified for parallax. Defaulting to false.") p.hTile = False if "vScroll" in dictionary: p.vScroll = bool(dictionary["vScroll"]) else: log.error("No vertical scroll specified for parallax. Defaulting to false.") p.vScroll = False if "hScroll" in dictionary: p.hScroll = bool(dictionary["hScroll"]) else: log.error("No horizontal scroll specified for parallax. Defaulting to false.") p.hScroll = False if "vScrollSpeed" in dictionary: # The others are easy because a bool conversion never throws an # exception try: p.vScrollSpeed = float(dictionary["vScrollSpeed"]) except ValueError: log.error("Could not convert %s to a decimal number for parallax vertical scroll speed. Defaulting to 1.0" % dictionary["vScrollSpeed"]) p.vScrollSpeed = 1.0 else: log.error("No vertical scroll speed specified for parallax. Defaulting to 1.0") p.vScrollSpeed = 1.0 if "hScrollSpeed" in dictionary: try: p.hScrollSpeed = float(dictionary["hScrollSpeed"]) except ValueError: log.error("Could not convert %s to a decimal number for parallax horizontal scroll speed. Defaulting to 1.0" % dictionary["hScrollSpeed"]) p.hScrollSpeed = 1.0 else: log.error("No horizontal scroll speed specified for parallax. Defaulting to 1.0") p.hScrollSpeed = 1.0 if "visible" in dictionary: p.visible = bool(dictionary["visible"]) else: log.error("No visibility specified for parallax. Defaulting to true.") p.visibile = True return p, index
def __init__(self, parent, parallax): if parallax is not None: self.parallax = parallax else: self.parallax = background.ParallaxLayer() if self.parallax.fileName is None: fileName = "New Background" else: fileName = self.parallax.fileName gtk.Dialog.__init__(self, os.path.basename(fileName), parent, gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_APPLY, gtk.RESPONSE_ACCEPT)) builder = HIGTableBuilder() builder.addSectionHeader("Appearance") fFilter = graphics.getFileFilter() self.fileChooser = gtk.FileChooserDialog("Choose Background Image", self, gtk.FILE_CHOOSER_ACTION_OPEN, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_ACCEPT)) self.fileChooser.add_filter(fFilter) self.fileButton = gtk.FileChooserButton(self.fileChooser) if self.parallax.fileName is not None: self.fileChooser.set_filename(self.parallax.fileName) self.fileButton.set_width_chars(6) # Set the default directory of the file chooser based on the file prefix # setting from the preferences. This should save a few clicks. path = datafiles.getParallaxPath("") print path if path != "": print "set_current_folder" self.fileChooser.set_current_folder(path) builder.addLabeledWidget("_Image", self.fileButton) builder.addSectionHeader("Repeat") self.tileHorizontally = gtk.CheckButton("Repeat Horizontally", True) self.tileHorizontally.set_active(self.parallax.hTile) builder.addWidget(self.tileHorizontally) self.tileVertically = gtk.CheckButton("Repeat Vertically", True) self.tileVertically.set_active(self.parallax.vTile) builder.addWidget(self.tileVertically) builder.addSectionHeader("Scrolling") self.scrollHorizontally = gtk.CheckButton("Scroll Horizontally", True) self.scrollHorizontally.connect("toggled", self.scrollHorizontallyChanged) builder.addWidget(self.scrollHorizontally) self.scrollHorizontallySpeed = gtk.SpinButton( gtk.Adjustment(self.parallax.hScrollSpeed, 0, 20.0, 0.1, 1.0, 0.0), 0.1, 2) builder.addLabeledWidget("Horizontal Scroll Speed", self.scrollHorizontallySpeed) self.scrollVertically = gtk.CheckButton("Scroll Vertically", True) self.scrollVertically.connect("toggled", self.scrollVerticallyChanged) builder.addWidget(self.scrollVertically) self.scrollVerticallySpeed = gtk.SpinButton( gtk.Adjustment(self.parallax.vScrollSpeed, 0, 20.0, 0.1, 1.0, 0.0), 0.1, 2) builder.addLabeledWidget("Vertical Scroll Speed", self.scrollVerticallySpeed) self.scrollHorizontally.set_active(self.parallax.hScroll) self.scrollHorizontallySpeed.set_sensitive(self.parallax.hScroll) self.scrollVertically.set_active(self.parallax.vScroll) self.scrollVerticallySpeed.set_sensitive(self.parallax.vScroll) self.vbox.add(builder.getTable()) self.show_all() self.set_resizable(False)