def paintOptions(self, options, tag): """ Paints the tag options on screen. options: active options. tag: active tag. """ if len(options) > 1: img = options[int(self.avatarConfiguration[tag]) - 1] buttonLeft = guiobjects.OcempImageButtonTransparent(GG.genteguada.GenteGuada.getInstance().getDataPath(BUTTON_LEFT), self.buttonTooltips["before"], self.showTooltip, self.removeTooltip) buttonLeft.topleft = 30, 400 buttonLeft.connect_signal(ocempgui.widgets.Constants.SIG_CLICKED, self.moveOptions, "left", options, tag) self.window.add_child(buttonLeft) self.activeWidget.append(buttonLeft) buttonRight = guiobjects.OcempImageButtonTransparent(GG.genteguada.GenteGuada.getInstance().getDataPath(BUTTON_RIGHT), self.buttonTooltips["next"], self.showTooltip, self.removeTooltip) buttonRight.topleft = 200, 400 buttonRight.connect_signal(ocempgui.widgets.Constants.SIG_CLICKED, self.moveOptions, "right", options, tag) self.window.add_child(buttonRight) self.activeWidget.append(buttonRight) else: img = options[0] if tag == "mask" and self.avatarConfiguration["mask"]: if not os.path.isfile(IMG_UPLOAD): image = self.parent.getPlayer().getImageLabel() filePath = GG.genteguada.GenteGuada.getInstance().getDataPath(image) guiobjects.generateImageSize(filePath, [244, 244], IMG_UPLOAD) self.imgOptionsTab = guiobjects.OcempImageMapTransparent(IMG_UPLOAD) else: self.imgOptionsTab = guiobjects.OcempImageMapTransparent(GG.genteguada.GenteGuada.getInstance().getDataPath(os.path.join(GG.utils.PATH_EDITOR_INTERFACE, img))) self.imgOptionsTab.topleft = 30, 150 self.activeWidget.append(self.imgOptionsTab) self.window.add_child(self.imgOptionsTab)
def showImage(self, filePath): """ Show a loaded image. filePath: image path. """ size = 244, 244 try: guiobjects.generateImageSize(filePath, [244, 244], IMG_UPLOAD) except: return imgPath = IMG_UPLOAD img = ocempgui.draw.Image.load_image(imgPath) self.imgOptionsTab.picture = img self.generateMask("imgUpload.png")
def paintMask(self): """ Paints the avatar's mask. """ if self.avatarConfiguration["mask"]: if not os.path.isfile(MASK_UPLOAD): image = self.parent.getPlayer().getImageLabel() filePath = GG.genteguada.GenteGuada.getInstance().getDataPath(image) guiobjects.generateImageSize(filePath, [244, 244], IMG_UPLOAD) self.generateMask("imgUpload.png") imgPath = MASK_UPLOAD else: imgPath = GG.genteguada.GenteGuada.getInstance().getDataPath(os.path.join(PATH_EDITOR_IMG, self.avatarConfiguration["gender"], self.avatarConfiguration["headSize"], "mask.png")) self.newAvatarImage(imgPath, "mask")
def __init__(self, model, screen, room, parent, position=None, image=None): """ Class constructor. model: isometric view model. screen: screen handler. room: item's isometric room object. parent: isoview_hud handler. position: isometric view's initial position. imagePath: item's image path. """ if image: imgPath = GG.genteguada.GenteGuada.getInstance().getDataPath(os.path.join(model.getImagePath(), model.getSpriteName())) tempFileName = model.getSpriteName().replace(os.sep, "-") guiobjects.generateImageSize(imgPath, NEW_SIZE, os.path.join(GG.utils.LOCAL_DATA_PATH,tempFileName)) IsoViewItem.__init__(self, model, screen, room, parent)
def draw(self, render): """ Draws an inventory item. render: widget container. """ imgPath = GG.genteguada.GenteGuada.getInstance().getDataPath(self.__spriteName) tempFileName = os.path.join( GG.utils.LOCAL_DATA_PATH, "INVENTORY-" + str(self.__spriteName.replace(os.sep, "-")) ) guiobjects.generateImageSize(imgPath, NEW_SIZE, tempFileName) imgInventory = ocempgui.widgets.ImageButton(tempFileName) imgInventory.border = 0 imgInventory.connect_signal(ocempgui.widgets.Constants.SIG_CLICKED, self.selected) render.get_managers()[0].add_high_priority_object(imgInventory, ocempgui.widgets.Constants.SIG_MOUSEDOWN) return imgInventory
def draw(self, render): """ Draws an inventory item. render: widget container. """ imgPath = GG.genteguada.GenteGuada.getInstance().getDataPath( self.__spriteName) tempFileName = os.path.join( GG.utils.LOCAL_DATA_PATH, "INVENTORY-" + str(self.__spriteName.replace(os.sep, "-"))) guiobjects.generateImageSize(imgPath, NEW_SIZE, tempFileName) imgInventory = ocempgui.widgets.ImageButton(tempFileName) imgInventory.border = 0 imgInventory.connect_signal(ocempgui.widgets.Constants.SIG_CLICKED, self.selected) render.get_managers()[0].add_high_priority_object( imgInventory, ocempgui.widgets.Constants.SIG_MOUSEDOWN) return imgInventory
def paintMask(self): """ Paints the avatar's mask. """ if self.avatarConfiguration["mask"]: if not os.path.isfile(MASK_UPLOAD): image = self.parent.getPlayer().getImageLabel() filePath = GG.genteguada.GenteGuada.getInstance().getDataPath( image) guiobjects.generateImageSize(filePath, [244, 244], IMG_UPLOAD) self.generateMask("imgUpload.png") imgPath = MASK_UPLOAD else: imgPath = GG.genteguada.GenteGuada.getInstance().getDataPath( os.path.join(PATH_EDITOR_IMG, self.avatarConfiguration["gender"], self.avatarConfiguration["headSize"], "mask.png")) self.newAvatarImage(imgPath, "mask")
def paintOptions(self, options, tag): """ Paints the tag options on screen. options: active options. tag: active tag. """ if len(options) > 1: img = options[int(self.avatarConfiguration[tag]) - 1] buttonLeft = guiobjects.OcempImageButtonTransparent( GG.genteguada.GenteGuada.getInstance().getDataPath( BUTTON_LEFT), self.buttonTooltips["before"], self.showTooltip, self.removeTooltip) buttonLeft.topleft = 30, 400 buttonLeft.connect_signal(ocempgui.widgets.Constants.SIG_CLICKED, self.moveOptions, "left", options, tag) self.window.add_child(buttonLeft) self.activeWidget.append(buttonLeft) buttonRight = guiobjects.OcempImageButtonTransparent( GG.genteguada.GenteGuada.getInstance().getDataPath( BUTTON_RIGHT), self.buttonTooltips["next"], self.showTooltip, self.removeTooltip) buttonRight.topleft = 200, 400 buttonRight.connect_signal(ocempgui.widgets.Constants.SIG_CLICKED, self.moveOptions, "right", options, tag) self.window.add_child(buttonRight) self.activeWidget.append(buttonRight) else: img = options[0] if tag == "mask" and self.avatarConfiguration["mask"]: if not os.path.isfile(IMG_UPLOAD): image = self.parent.getPlayer().getImageLabel() filePath = GG.genteguada.GenteGuada.getInstance().getDataPath( image) guiobjects.generateImageSize(filePath, [244, 244], IMG_UPLOAD) self.imgOptionsTab = guiobjects.OcempImageMapTransparent( IMG_UPLOAD) else: self.imgOptionsTab = guiobjects.OcempImageMapTransparent( GG.genteguada.GenteGuada.getInstance().getDataPath( os.path.join(GG.utils.PATH_EDITOR_INTERFACE, img))) self.imgOptionsTab.topleft = 30, 150 self.activeWidget.append(self.imgOptionsTab) self.window.add_child(self.imgOptionsTab)