def paintScreen(self): """Paints the Avatar Editor background on screen. """ imgPath = GG.genteguada.GenteGuada.getInstance().getDataPath( BACKGROUND_LEFT) self.imgBackgroundLeft = guiobjects.OcempImageMapTransparent(imgPath) self.window.add_child(self.imgBackgroundLeft) imgPath = GG.genteguada.GenteGuada.getInstance().getDataPath( BACKGROUND_RIGHT) imgBackgroundRight = guiobjects.OcempImageMapTransparent(imgPath) imgBackgroundRight.topleft = 297, 0 self.window.add_child(imgBackgroundRight)
def __showPolicyDialog(self): if self.dialog: return self.container = ocempgui.widgets.Box(516, 197) filePath = GG.genteguada.GenteGuada.getInstance().getDataPath(os.path.join(GG.utils.BACKGROUNDS, "alertWindow.png")) imgBackground = guiobjects.OcempImageMapTransparent(filePath) imgBackground.topleft = 0, 0 self.container.add_child(imgBackground) self.dialog = ocempgui.widgets.DialogWindow("Error") self.dialog.topleft = 254, 50 self.dialog.child = self.container self.widgetContainer.add_widget(self.dialog) buttonCancel = guiobjects.OcempImageButtonTransparent(GG.genteguada.GenteGuada.getInstance().getDataPath(BUTTON_CANCEL)) buttonCancel.topleft = [400, 140] buttonCancel.connect_signal(ocempgui.widgets.Constants.SIG_CLICKED, self.__closeDialog) self.container.add_child(buttonCancel) buttonOK = guiobjects.OcempImageButtonTransparent(GG.genteguada.GenteGuada.getInstance().getDataPath(BUTTON_OK)) buttonOK.topleft = [280, 140] buttonOK.connect_signal(ocempgui.widgets.Constants.SIG_CLICKED, self.__showPolicy) self.container.add_child(buttonOK) labelAlert = guiobjects.OcempLabel("Debe aceptar las normas del juego", guiobjects.STYLES["dialogFont"]) labelAlert.topleft = 160, 50 labelAlert2 = guiobjects.OcempLabel("antes de poder acceder", guiobjects.STYLES["dialogFont"]) labelAlert2.topleft = 160, 65 labelAlert3 = guiobjects.OcempLabel("Continuar .... ", guiobjects.STYLES["dialogFont"]) labelAlert3.topleft = 160, 100 self.container.add_child(labelAlert) self.container.add_child(labelAlert2) self.container.add_child(labelAlert3) return self.dialog
def drawAccessMode(self): """ Draws the admin access screen. """ self.__finish = False self.widgetContainer = ocempgui.widgets.Renderer() self.widgetContainer.set_screen(self.__screen) self.window = ocempgui.widgets.Box(GG.utils.SCREEN_SZ[0], GG.utils.SCREEN_SZ[1]) imgBackgroundRight = guiobjects.OcempImageMapTransparent(GG.genteguada.GenteGuada.getInstance().getDataPath(os.path.join(GG.utils.BACKGROUNDS, "TEMP_accessMode.png"))) imgBackgroundRight.topleft = 0, 0 self.window.add_child(imgBackgroundRight) cad = "¿Desea entrar como administrador?" notificationLabel = guiobjects.OcempLabel(cad, ocempgui.widgets.WidgetStyle(guiobjects.STYLES["labelLogin"])) notificationLabel.topleft = 100, 300 notificationLabel.border = 1 notificationLabel.set_minimum_size(230, 40) self.window.add_child(notificationLabel) imgPath = os.path.join(GG.utils.EDITOR, "ok_button.png") buttonOK = guiobjects.OcempImageButtonTransparent(GG.genteguada.GenteGuada.getInstance().getDataPath(imgPath)) buttonOK.topleft = [370, 450] buttonOK.connect_signal(ocempgui.widgets.Constants.SIG_CLICKED, self.accessModeAdmin) self.window.add_child(buttonOK) imgPath = os.path.join(GG.utils.EDITOR, "cancel_button.png") buttonCancel = guiobjects.OcempImageButtonTransparent(GG.genteguada.GenteGuada.getInstance().getDataPath(imgPath)) buttonCancel.topleft = [550, 450] buttonCancel.connect_signal(ocempgui.widgets.Constants.SIG_CLICKED, self.accessModeNormal) self.window.add_child(buttonCancel) self.widgetContainer.add_widget(self.window) return self.__startAccessMode()
def openFileDialog(self): """ Opens the OpenFile dialog. """ self.dialog = ocempgui.widgets.Box(373, 372) self.dialog.topleft = 528, 205 background = guiobjects.OcempImageMapTransparent( GG.genteguada.GenteGuada.getInstance().getDataPath(WINDOW_UPLOAD)) self.dialog.add_child(background) self.listDir = guiobjects.OcempImageFileList(310, 239) self.listDir.topleft = 31, 60 self.dialog.add_child(self.listDir) buttonOK = guiobjects.OcempImageButtonTransparent( GG.genteguada.GenteGuada.getInstance().getDataPath(BUTTON_OK), self.buttonTooltips["ok"], self.parent.showTooltip, self.parent.removeTooltip) buttonOK.topleft = [233, 308] buttonOK.connect_signal(ocempgui.widgets.Constants.SIG_CLICKED, self.closeFileDialog, "OK") self.dialog.add_child(buttonOK) buttonCancel = guiobjects.OcempImageButtonTransparent( GG.genteguada.GenteGuada.getInstance().getDataPath(BUTTON_CANCEL), self.buttonTooltips["cancel"], self.parent.showTooltip, self.parent.removeTooltip) buttonCancel.topleft = [122, 308] buttonCancel.connect_signal(ocempgui.widgets.Constants.SIG_CLICKED, self.closeFileDialog, "KO") self.dialog.add_child(buttonCancel) self.window.add_child(self.dialog)
def __paintBackground(self): """ Paints the exchange window background. """ dir = os.path.join(GG.utils.BACKGROUNDS, "exchangeWindow.png") filePath = GG.genteguada.GenteGuada.getInstance().getDataPath( os.path.join(GG.utils.BACKGROUNDS, "exchangeWindow.png")) imgBackground = guiobjects.OcempImageMapTransparent(filePath) imgBackground.topleft = 0, 0 self.container.add_child(imgBackground)
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 newAvatarImage(self, imgPath, imgName): """ Sets a new avatar image. imgPath: image file path. imgName: image file name. """ img = ocempgui.draw.Image.load_image(imgPath) if not self.images[imgName]: imgOcemp = guiobjects.OcempImageMapTransparent(img) imgOcemp.topleft = 528, 114 self.window.add_child(imgOcemp) self.images[imgName] = imgOcemp else: self.images[imgName].picture = img
def __paintBackground(self): """ Paints the window background. """ filePath = GG.genteguada.GenteGuada.getInstance().getDataPath( PRIVATE_CHAT_BACKGROUND) imgBackground = guiobjects.OcempImageMapTransparent(filePath) imgBackground.topleft = 0, 0 self.container.add_child(imgBackground) self.window.child = self.container labelChat = guiobjects.OcempLabel("Contactos", guiobjects.STYLES["userName"]) labelChat.topleft = 20, 10 self.container.add_child(labelChat) labelContacts = guiobjects.OcempLabel("Chat", guiobjects.STYLES["userName"]) labelContacts.topleft = 160, 10 self.container.add_child(labelContacts)
def __init__(self, model, screen, isohud, message, header): """ Class constructor. model: chat message model. screen: screen handler. isohud: isometric hud handler. """ self.__isohud = isohud self.__message = message self.__header = header self.position = model.position positioned_view.PositionedView.__init__(self, model, screen) self.style = self.getStyleMessageChat() self.label = guiobjects.OcempLabelNotTransparent(message, 140) self.label.set_style( ocempgui.widgets.WidgetStyle(self.style["balloon"])) self.label.padding = 5 self.label.set_minimum_size(150, 50) self.balloon = self.drawBalloon(message) if model.type != 3: pos = GG.utils.p3dToP2d(self.position, [0, 0]) if (pos[0] + 10 + self.balloon.size[0]) > GG.utils.SCREEN_SZ[0]: xCord = GG.utils.SCREEN_SZ[0] - self.balloon.size[0] else: xCord = pos[0] + 10 if (pos[1] - 30 - (self.label.height)) > 0: yCord = pos[1] - 30 - (self.balloon.height) else: yCord = 0 self.balloon.topleft = [xCord, yCord] else: self.balloon.topleft = [ GG.utils.SCREEN_SZ[0] / 2 - (self.balloon.size[0] / 2), GG.utils.SCREEN_SZ[1] / 3 ] self.balloon.zOrder = 20000 self.__isohud.addSprite(self.balloon) if model.type != 3: imgPath = GG.genteguada.GenteGuada.getInstance().getDataPath( os.path.join(CHAT_PATH, TAIL[model.type])) self.tail = guiobjects.OcempImageMapTransparent(imgPath) self.tail.topleft = [ self.balloon.topleft[0] + 30, self.balloon.topleft[1] + self.balloon.size[1] - 5 ] self.tail.zOrder = 20002 self.__isohud.addSprite(self.tail)
def __showErrorDialog (self): """ Shows an error dialog. """ if self.dialog: return self.container = ocempgui.widgets.Box(516, 197) filePath = GG.genteguada.GenteGuada.getInstance().getDataPath(os.path.join(GG.utils.BACKGROUNDS, "alertWindow.png")) imgBackground = guiobjects.OcempImageMapTransparent(filePath) imgBackground.topleft = 0, 0 self.container.add_child(imgBackground) self.dialog = ocempgui.widgets.DialogWindow("Error") self.dialog.topleft = 254, 50 self.dialog.child = self.container self.widgetContainer.add_widget(self.dialog) buttonCancel = guiobjects.OcempImageButtonTransparent(GG.genteguada.GenteGuada.getInstance().getDataPath(BUTTON_CANCEL)) buttonCancel.topleft = [400, 140] buttonCancel.connect_signal(ocempgui.widgets.Constants.SIG_CLICKED, self.__closeDialog) self.container.add_child(buttonCancel) labelAlert = guiobjects.OcempLabel("Error: Usuario o password incorrectos.", guiobjects.STYLES["dialogFont"]) labelAlert.topleft = 160, 80 self.container.add_child(labelAlert) return self.dialog
def __paintScreen(self): """ Paints the screen background. """ imgBackgroundRight = guiobjects.OcempImageMapTransparent(os.path.join(GG.utils.INIT_IMAGE_PATH, "startGG.png")) imgBackgroundRight.topleft = 1, 0 self.window.add_child(imgBackgroundRight)
def __paintScreen(self): """ Paints the screen background. """ imgBackgroundRight = guiobjects.OcempImageMapTransparent(GG.genteguada.GenteGuada.getInstance().getDataPath(os.path.join(GG.utils.BACKGROUNDS, "startGG.png"))) imgBackgroundRight.topleft = 1, 0 self.window.add_child(imgBackgroundRight)
def drawBalloon(self, message): """ Draws a balloon containing a given message. message: message to be included on the balloon. """ label = guiobjects.OcempLabelNotTransparent(message, 140) label.set_style(ocempgui.widgets.WidgetStyle(self.style["balloon"])) label.padding = 5 label.set_minimum_size(100, 30) label.opacity = 200 width = label.width height = label.height num = width / 10 + 1 num2 = height / 10 + 1 label.set_minimum_size((num) * 10, (num2) * 10) label.set_maximum_size((num) * 10, (num2) * 10) balloon = ocempgui.widgets.VFrame() balloon.border = 0 balloon.padding = 0 balloon.set_spacing(0) balloon.set_minimum_size((num + 1) * 10, (num2 + 1) * 10) modelType = self.getModel().type topRow = ocempgui.widgets.HFrame() bottomRow = ocempgui.widgets.HFrame() topRow.add_child( guiobjects.OcempImageMapTransparent( GG.genteguada.GenteGuada.getInstance().getDataPath( os.path.join(CHAT_PATH, CORNER_TOPLEFT[modelType])))) bottomRow.add_child( guiobjects.OcempImageMapTransparent( GG.genteguada.GenteGuada.getInstance().getDataPath( os.path.join(CHAT_PATH, CORNER_BOTTOMLEFT[modelType])))) for i in range(0, num): topRow.add_child( guiobjects.OcempImageMapTransparent( GG.genteguada.GenteGuada.getInstance().getDataPath( os.path.join(CHAT_PATH, BORDER_TOP[modelType])))) bottomRow.add_child( guiobjects.OcempImageMapTransparent( GG.genteguada.GenteGuada.getInstance().getDataPath( os.path.join(CHAT_PATH, BORDER_BOTTOM[modelType])))) topRow.add_child( guiobjects.OcempImageMapTransparent( GG.genteguada.GenteGuada.getInstance().getDataPath( os.path.join(CHAT_PATH, CORNER_TOPRIGHT[modelType])))) bottomRow.add_child( guiobjects.OcempImageMapTransparent( GG.genteguada.GenteGuada.getInstance().getDataPath( os.path.join(CHAT_PATH, CORNER_BOTTOMRIGHT[modelType])))) topRow.border = 0 topRow.padding = 0 topRow.set_minimum_size((num + 2) * 10, 10) topRow.set_spacing(10) topRow.set_align(ocempgui.widgets.Constants.ALIGN_TOP) bottomRow.border = 0 bottomRow.padding = 0 bottomRow.set_minimum_size((num + 2) * 10, 10) bottomRow.set_spacing(10) bottomRow.set_align(ocempgui.widgets.Constants.ALIGN_TOP) # ***** middleRow = ocempgui.widgets.HFrame() midVerticalColumn1 = ocempgui.widgets.VFrame() midVerticalColumn2 = ocempgui.widgets.VFrame() for i in range(0, num2): midVerticalColumn1.add_child( guiobjects.OcempImageMapTransparent( GG.genteguada.GenteGuada.getInstance().getDataPath( os.path.join(CHAT_PATH, BORDER_LEFT[modelType])))) midVerticalColumn2.add_child( guiobjects.OcempImageMapTransparent( GG.genteguada.GenteGuada.getInstance().getDataPath( os.path.join(CHAT_PATH, BORDER_RIGHT[modelType])))) midVerticalColumn1.border = 0 midVerticalColumn1.padding = 0 midVerticalColumn1.set_minimum_size(10, (num2) * 10) midVerticalColumn1.set_spacing(10) midVerticalColumn1.set_align(ocempgui.widgets.Constants.ALIGN_LEFT) midVerticalColumn2.border = 0 midVerticalColumn2.padding = 0 midVerticalColumn2.set_minimum_size(10, (num2) * 10) midVerticalColumn2.set_spacing(10) midVerticalColumn2.set_align(ocempgui.widgets.Constants.ALIGN_LEFT) label.set_align(ocempgui.widgets.Constants.ALIGN_LEFT) middleRow.border = 0 middleRow.padding = 0 middleRow.add_child(midVerticalColumn1) middleRow.add_child(label) middleRow.add_child(midVerticalColumn2) middleRow.set_minimum_size((num + 1) * 10, (num2) * 10) middleRow.set_spacing(0) middleRow.set_align(ocempgui.widgets.Constants.ALIGN_LEFT) # ***** balloon.add_child(topRow) balloon.add_child(middleRow) balloon.add_child(bottomRow) return balloon
def __init__(self, model, screen, isohud): """ Class constructor. model: chat message model. screen: screen handler. isohud: isoview_hud handler. """ self.__isohud = isohud infoPackage = model.getInfoPackage() self.__answers = infoPackage["answers"] self.__position = infoPackage["position"] positioned_view.PositionedView.__init__(self, model, screen) self.container = ocempgui.widgets.Box(585, 258) filePath = GG.genteguada.GenteGuada.getInstance().getDataPath( os.path.join(GG.utils.BACKGROUNDS, "trivialWindow2.png")) imgBackground = guiobjects.OcempImageMapTransparent(filePath) imgBackground.topleft = 0, 0 self.container.add_child(imgBackground) label = guiobjects.OcempLabel(infoPackage["message"], guiobjects.STYLES["quizLabel"]) label.set_style( ocempgui.widgets.WidgetStyle(guiobjects.STYLES["quizLabel"])) label.topleft = 20, 40 self.container.add_child(label) i = 0 for answer in self.__answers: label = guiobjects.OcempLabel(answer, guiobjects.STYLES["quizLabel"]) label.set_style( ocempgui.widgets.WidgetStyle(guiobjects.STYLES["quizLabel"])) label.topleft = 80, 85 + i * 50 self.container.add_child(label) i = i + 1 buttonA = guiobjects.OcempImageButtonTransparent( GG.genteguada.GenteGuada.getInstance().getDataPath( os.path.join(GG.utils.HUD_PATH, "answerA.png"))) buttonA.topleft = [22, 70] buttonA.connect_signal(ocempgui.widgets.Constants.SIG_CLICKED, self.actionButton, 1) buttonB = guiobjects.OcempImageButtonTransparent( GG.genteguada.GenteGuada.getInstance().getDataPath( os.path.join(GG.utils.HUD_PATH, "answerB.png"))) buttonB.topleft = [22, 120] buttonB.connect_signal(ocempgui.widgets.Constants.SIG_CLICKED, self.actionButton, 2) buttonC = guiobjects.OcempImageButtonTransparent( GG.genteguada.GenteGuada.getInstance().getDataPath( os.path.join(GG.utils.HUD_PATH, "answerC.png"))) buttonC.topleft = [22, 170] buttonC.connect_signal(ocempgui.widgets.Constants.SIG_CLICKED, self.actionButton, 3) self.container.add_child(buttonA) self.container.add_child(buttonB) self.container.add_child(buttonC) self.container.topleft = [20, 20] self.container.border = 0 self.container.zOrder = 20000 self.__isohud.addSprite(self.container) self.__isohud.widgetContainer.add_widget(self.container) self.__isohud.setActiveWindow(True)