def update(self): self.list.resetList() self.items = [] if self.application.world.current_character_turn: self.items.append(PyCEGUI.ListboxTextItem(self.application.world.current_character_turn.name + "'s turn (current)")) self.items[-1].setAutoDeleted(False) self.items[-1].setTextColours(PyCEGUI.Colour(0xFFFFD000)) self.list.addItem(self.items[-1]) last_timer_name = None duplicate_timer_count = 1 for timer in self.application.world.timeline.timers: if last_timer_name: if last_timer_name == timer.name: duplicate_timer_count += 1 else: if duplicate_timer_count > 1: last_timer_name += (" (x" + str(duplicate_timer_count) + ")") self.items.append(PyCEGUI.ListboxTextItem(last_timer_name)) self.items[-1].setAutoDeleted(False) self.list.addItem(self.items[-1]) duplicate_timer_count = 1 last_timer_name = timer.name if last_timer_name: if duplicate_timer_count > 1: last_timer_name += (" (x" + str(duplicate_timer_count) + ")") self.items.append(PyCEGUI.ListboxTextItem(last_timer_name)) self.items[-1].setAutoDeleted(False) self.list.addItem(self.items[-1])
def cb_add_clicked(self, args): """Called when the add button was clicked Args: args: PyCEGUI.WindowEventArgs """ key = self.key_input.getText() value = self.value_input.getText() item = self.edit_dict.findColumnItemWithText(key, 0, None) if item is not None: row = self.edit_dict.getItemRowIndex(item) pos = PyCEGUI.MCLGridRef(row, 1) item = self.edit_dict.getItemAtGridReference(pos) item.setText(value) else: row = self.edit_dict.addRow() item = PyCEGUI.ListboxTextItem(str(key)) item.setSelectionBrushImage("TaharezLook/" "MultiListSelectionBrush") self.edit_dict.setItem(item, 0, row) self.items.append(item) item = PyCEGUI.ListboxTextItem(str(value)) item.setSelectionBrushImage("TaharezLook/" "MultiListSelectionBrush") self.edit_dict.setItem(item, 1, row) self.items.append(item) self.values[key] = value self.edit_dict.performChildWindowLayout() self.edit_dict.invalidate(True)
def normaliseSize(self, widgetPath): manipulator = self.visual.scene.getManipulatorByPath(widgetPath) pixelSize = manipulator.widget.getPixelSize() baseSize = manipulator.getBaseSize() return PyCEGUI.USize(PyCEGUI.UDim(pixelSize.d_width / baseSize.d_width, 0), PyCEGUI.UDim(pixelSize.d_height / baseSize.d_height, 0))
def update(self): # clear all portraits #for portrait in self.current_portraits: # self.portrait_container.removeChild(portrait) while self.portrait_container.getChildCount(): self.portrait_container.removeChild( self.portrait_container.getChildAtIdx(0).getID()) self.current_portraits = [] # and make new ones for combatant in self.combat.combatants: new_portrait = PyCEGUI.WindowManager.getSingleton().createWindow( "TaharezLook/StaticImage", "Portrait-" + combatant.ID) new_portrait.setSize( PyCEGUI.USize(PyCEGUI.UDim(0, 100), PyCEGUI.UDim(0, 100))) new_portrait.setProperty("HorzFormatting", "CentreAligned") new_portrait.setProperty("VertFormatting", "CentreAligned") new_portrait.setProperty("BackgroundEnabled", "False") new_portrait.setProperty("FrameEnabled", "False") new_portrait.setProperty("MousePassThroughEnabled", "False") if combatant != self.combat.combatants[ self.combat.current_combatant]: new_portrait.setProperty("ImageColours", "FF808080") else: new_portrait.setProperty("ImageColours", "FFFFFFFF") if combatant.portrait: # portrait present new_portrait.setProperty("Image", combatant.portrait) else: # no portrait, using default new_portrait.setProperty("Image", "TaharezLook/CloseButtonHover") self.portrait_container.addChild(new_portrait) self.current_portraits.append(new_portrait)
def show(self, args=None): settings = self.application.settings # shortcut # load gameplay settings self.time_acceleration_edit.setText( str(settings.get("gameplay", "TimeAcceleration", 1))) self.walk_speed_edit.setText( str(settings.get("gameplay", "WalkSpeed", 1.8))) self.run_speed_edit.setText( str(settings.get("gameplay", "RunSpeed", 4.0))) self.preload_sprites_checkbox.setSelected( settings.get("gameplay", "PreloadSprites", True)) # load video and audio settings self.resolution_list.resetList() self.resolution_items = [] for resolution in self.application.settings._resolutions: self.resolution_items.append(PyCEGUI.ListboxTextItem(resolution)) self.resolution_items[-1].setAutoDeleted(False) self.resolution_items[-1].setSelectionBrushImage( "TaharezLook/MultiListSelectionBrush") self.resolution_items[-1].setSelectionColours( PyCEGUI.Colour(0.33, 0.295, 0.244)) self.resolution_items[-1].setTextColours( PyCEGUI.Colour(0.98, 0.886, 0.733)) self.resolution_list.addItem(self.resolution_items[-1]) if resolution == settings.get("FIFE", "ScreenResolution", "1024x768"): self.resolution_list.setItemSelectState( self.resolution_items[-1], True) self.fullscreen_checkbox.setSelected( settings.get("FIFE", "FullScreen", False)) self.vsync_checkbox.setSelected(settings.get("FIFE", "VSync", True)) self.native_cursor_checkbox.setSelected( settings.get("FIFE", "NativeImageCursor", False)) self.enable_sound_checkbox.setSelected( settings.get("FIFE", "PlaySounds", True)) self.volume_slider.setScrollPosition( settings.get("FIFE", "InitialVolume", 10.0)) # load hotkeys for action in self.hotkey_actions: if action[1] == "-": # skip separator labels continue hotkey_edit = self.page_controls_scrollable.getChild( "HotkeyEdit-" + action) fife_key = settings.get("hotkeys", action) try: cegui_key = self.toCeguiKey(fife_key) except KeyError: hotkey_edit.setProperty("Text", "") hotkey_edit.setProperty("HiddenData", "") else: hotkey_edit.setProperty("Text", str(cegui_key)) hotkey_edit.setProperty("HiddenData", str(fife_key)) self.window.show() self.window.moveToFront()
def addSaveToList(self, save_name): self.file_items.append(PyCEGUI.ListboxTextItem(save_name)) self.file_items[-1].setAutoDeleted(False) #self.file_items[-1].setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush") self.file_items[-1].setSelectionBrushImage("TaharezLook/MultiListSelectionBrush") self.file_items[-1].setSelectionColours(PyCEGUI.Colour(0.33, 0.295, 0.244)) self.file_items[-1].setTextColours(PyCEGUI.Colour(0.98, 0.886, 0.733)) self.file_list.addItem(self.file_items[-1])
def roundAbsolutePosition(oldPosition): return PyCEGUI.UVector2( PyCEGUI.UDim( oldPosition.d_x.d_scale, PyCEGUI.CoordConverter.alignToPixels( oldPosition.d_x.d_offset)), PyCEGUI.UDim( oldPosition.d_y.d_scale, PyCEGUI.CoordConverter.alignToPixels( oldPosition.d_y.d_offset)))
def show(self, pos_x, pos_y): for menu_item in self.menu_items: self.window.removeChild(menu_item) self.menu_items = [] self.window.show() self.window.moveToFront() #print pos_x, pos_y #print PyCEGUI.UVector2(PyCEGUI.UDim(0, pos_x), PyCEGUI.UDim(0, pos_y)) self.window.setPosition( PyCEGUI.UVector2(PyCEGUI.UDim(0, pos_x), PyCEGUI.UDim(0, pos_y)))
def roundAbsoluteSize(oldSize): return PyCEGUI.USize( PyCEGUI.UDim( oldSize.d_width.d_scale, PyCEGUI.CoordConverter.alignToPixels( oldSize.d_width.d_offset)), PyCEGUI.UDim( oldSize.d_height.d_scale, PyCEGUI.CoordConverter.alignToPixels( oldSize.d_height.d_offset)))
def notifyMoveProgress(self, newPos): super(Manipulator, self).notifyMoveProgress(newPos) # absolute pixel deltas pixelDeltaPos = newPos - self.moveOldPos deltaPos = None if self.useAbsoluteCoordsForMove(): if self.useIntegersForAbsoluteMove(): deltaPos = PyCEGUI.UVector2( PyCEGUI.UDim(0, math.floor(pixelDeltaPos.x())), PyCEGUI.UDim(0, math.floor(pixelDeltaPos.y()))) else: deltaPos = PyCEGUI.UVector2(PyCEGUI.UDim(0, pixelDeltaPos.x()), PyCEGUI.UDim(0, pixelDeltaPos.y())) else: baseSize = self.getBaseSize() deltaPos = PyCEGUI.UVector2( PyCEGUI.UDim(pixelDeltaPos.x() / baseSize.d_width, 0), PyCEGUI.UDim(pixelDeltaPos.y() / baseSize.d_height, 0)) self.widget.setPosition(self.preMovePos + deltaPos) self.lastMoveNewPos = newPos
def normalisePosition(self, widgetPath, position): manipulator = self.visual.scene.getManipulatorByPath(widgetPath) baseSize = manipulator.getBaseSize() return PyCEGUI.UVector2( PyCEGUI.UDim( 0, position.d_x.d_offset + position.d_x.d_scale * baseSize.d_width), PyCEGUI.UDim( 0, position.d_y.d_offset + position.d_y.d_scale * baseSize.d_height))
def setup_widget(self, root): """Sets up the widget for this property Args: root: The root widget to which to add the widget to """ self._create_base_widget(root, "VerticalLayoutContainer") base_widget = self.base_widget font = base_widget.getFont() input_mode = PyCEGUI.Spinner.TextInputMode.FloatingPoint property_layout = base_widget.createChild( "HorizontalLayoutContainer", "%s_x_layout" % (self.base_text)) widget_height = self.editor.WIDGET_HEIGHT widget_margin = self.editor.WIDGET_MARGIN property_layout.setHeight(widget_height) property_layout.setMargin(widget_margin) property_label = property_layout.createChild( "TaharezLook/Label", "%s_x_label" % (self.base_text)) property_label.setText("X") text_width = font.getTextExtent(property_label.getText()) + 10 property_label.setWidth(PyCEGUI.UDim(0, text_width)) property_label.setHeight(widget_height) property_input = property_layout.createChild( "TaharezLook/Spinner", "%s_x_input" % (self.base_text)) property_input.setWidth(PyCEGUI.UDim(1, -text_width)) property_input.setHeight(widget_height) property_input.setTextInputMode(input_mode) property_input.subscribeEvent(PyCEGUI.Spinner.EventValueChanged, self.cb_value_changed) self.property_input_x = property_input property_layout = base_widget.createChild( "HorizontalLayoutContainer", "%s_y_layout" % (self.base_text)) property_layout.setHeight(widget_height) property_layout.setMargin(widget_margin) property_label = property_layout.createChild( "TaharezLook/Label", "%s_y_label" % (self.base_text)) property_label.setText("Y") text_width = font.getTextExtent(property_label.getText()) + 10 property_label.setWidth(PyCEGUI.UDim(0, text_width)) property_label.setHeight(widget_height) property_input = property_layout.createChild( "TaharezLook/Spinner", "%s_y_input" % (self.base_text)) property_input.setWidth(PyCEGUI.UDim(1, -text_width)) property_input.setHeight(widget_height) property_input.setTextInputMode(input_mode) property_input.subscribeEvent(PyCEGUI.Spinner.EventValueChanged, self.cb_value_changed) self.property_input_y = property_input self.update_input_widgets()
def updateTextBox(self): """Display HP and AP on the action menu text box.""" self.text_box.resetList() self.messages = [] if self.application.current_character: self.messages.append( PyCEGUI.ListboxTextItem( str(self.application.current_character.cur_AP) + " AP")) self.messages.append( PyCEGUI.ListboxTextItem( str(self.application.current_character.cur_HP) + " HP")) self.messages[-2].setAutoDeleted(False) self.messages[-1].setAutoDeleted(False) self.text_box.addItem(self.messages[-2]) self.text_box.addItem(self.messages[-1])
def chatSend(self, args=None): self.chat_messages.append( PyCEGUI.ListboxTextItem(self.chatEdit.getText())) self.chat_messages[-1].setAutoDeleted(False) self.chatBox.addItem(self.chat_messages[-1]) self.chatBox.ensureItemIsVisible(self.chat_messages[-1]) self.chatEdit.setText("")
def onCatChanged(self, notUsed=None): selCatName = self.cbxCat.getSelectedItem().getText() #print("onCatChanged(%s)" % selCatName) # Re-initialise track combo-box. self.cbxTrack.clearAllSelections() self.cbxTrack.resetList() self.cbxTrackItems = [] for track in self.Tracks[selCatName].values(): # auto_delete=False => items are not deleted when removed from the list by CEGUI ; # it's up to Python to take care of this, as it instanciates them ! cbxItem = PyCEGUI.ListboxTextItem(track.name, auto_delete=False) cbxItem.setSelectionBrushImage("CEGUIDemo", "ComboboxSelectionBrush") cbxItem.setSelectionColours(0xFF3FFFEE) self.cbxTrack.addItem(cbxItem) self.cbxTrackItems.append( cbxItem) # Avoid its being GC'd at return ! self.cbxTrackItems[0].setSelected(True) # Select first track. self.cbxTrack.setText(self.cbxTrackItems[0].getText()) self.onTrackChanged()
def onTrackChanged(self, notUsed=None): selCatName = self.cbxCat.getSelectedItem().getText() selTrackName = self.cbxTrack.getSelectedItem().getText() print("onTrackChanged(cat=%s, track=%s)" % (selCatName, selTrackName)) track = self.Tracks[selCatName][selTrackName] self.txtDesc.setText(track.description) self.txtLength.setText("%d m" % track.length) self.txtWidth.setText("%d m" % track.width) self.txtNPits.setText("%d m" % track.nPits) self.txtAuthors.setText(track.authors) # Update outline image. imgSetMgr = PyCEGUI.ImagesetManager.getSingleton() #if not imgSetMgr.???(track.outline): imgSetMgr.createFromImageFile(track.outline, track.outline) self.imgOutline.setProperty("Image", "set:%s image:full_image" % track.outline) # Update background image, respecting its aspect ratio through clipping. #if not imgSetMgr.???(track.preview): self.imgSetPreview = imgSetMgr.createFromImageFile( track.preview, track.preview) self.onWindowSized(PyCEGUI.WindowEventArgs(self.window))
def _create_base_widget(self, root, w_type="HorizontalLayoutContainer"): """Create the base widget for the editor Args: root: The root widget to which to add the widget to y_pos: The vertical position of the widget w_type: The widget type to create for the container. """ base_text = "/".join((self.section, self.name)) widget_margin = self.editor.WIDGET_MARGIN property_container = root.createChild(w_type, "%s_container" % (base_text)) property_container.setMargin(widget_margin) property_label = property_container.createChild( "TaharezLook/Label", "%s_label" % (base_text)) property_label.setProperty("HorzFormatting", "LeftAligned") property_label.setWidth(PyCEGUI.UDim(0.5, 0)) property_label.setHeight(self.editor.WIDGET_HEIGHT) property_label.setText(self.name) property_label.setTooltipText(self.name) self.base_widget = property_container self.base_text = base_text
def initialize(self): name = "MenuOptions" # No code written for this menu : use mandatory layout. window = Menu.initialize(self, name=name, title="Options", layout="menuoptions") # Retrieve window descendants created here. self.btnAccept = window.getChild(name + "/BtnAccept") self.btnCancel = window.getChild(name + "/BtnCancel") self.cbxWinSize = window.getChild(name + "/CbxWindowSize") # Complete widget initialization. self.cbxWinSizeItems = [] for size in (" 800 x 512", "1024 x 640", "1280 x 800", "1680 x 1050"): cbxItem = PyCEGUI.ListboxTextItem(size) cbxItem.setSelectionBrushImage("CEGUIDemo", "ComboboxSelectionBrush") cbxItem.setSelectionColours(0xFF3FFFEE) self.cbxWinSize.addItem(cbxItem) self.cbxWinSizeItems.append( cbxItem) # Avoid its being GC'd at return ! if size.startswith("1024"): self.cbxWinSize.setText(cbxItem.getText()) # TODO. return window
def addItem(self, item, x, y, width=1, height=1): #if not self.checkSpace(x, y, width, height): # return False self.item_list.append(( item, x, y, width, height, )) self.addChild(item) item.setPosition( PyCEGUI.UVector2(PyCEGUI.UDim(0, x * self.cell_width), PyCEGUI.UDim(0, y * self.cell_height))) self.invalidate() return True
def __init__(self, app): ToolbarPage.__init__(self, app, "Objects") self.namespaces = {} self.images = {} self.image_directions = {} self.selected_object = [None, None] self.is_active = False self.cur_rotation = 0 x_adjust = 5 pos = self.gui.getPosition() y_pos = pos.d_y x_pos = PyCEGUI.UDim(0, x_adjust) width = PyCEGUI.UDim(0.9, 0.0) label = self.gui.createChild("TaharezLook/Label", "ObjectsLabel") label.setText(_("Objects")) label.setWidth(width) label.setXPosition(x_pos) label.setProperty("HorzFormatting", "LeftAligned") items_panel = self.gui.createChild("TaharezLook/ScrollablePane", "Items_panel") y_pos.d_scale = y_pos.d_scale + 0.045 items_panel.setXPosition(x_pos) items_panel.setYPosition(y_pos) size = self.gui.getSize() size.d_height.d_scale = size.d_height.d_scale - y_pos.d_scale size.d_width.d_offset = size.d_width.d_offset - x_adjust items_panel.setSize(size) self.items_panel = items_panel self.items = self.items_panel.createChild("VerticalLayoutContainer", "Items") self.have_objects_changed = False self.app.add_map_switch_callback(self.cb_map_changed) self.last_mouse_pos = None self.last_instance = None mode = self.app.current_mode mode.listener.add_callback("mouse_pressed", self.cb_map_clicked) mode.listener.add_callback("mouse_dragged", self.cb_map_clicked) mode.listener.add_callback("mouse_moved", self.cb_map_moved) mode.listener.add_callback("key_pressed", self.cb_key_pressed) self.app.add_map_switch_callback(self.map_switch) self.app.add_objects_imported_callback(self.cb_objects_imported) self.objects = Queue() self.images_lock = _thread.allocate_lock() self.namespaces_lock = _thread.allocate_lock()
def handlerReshape(self, width, height): glViewport(0, 0, width, height) glMatrixMode(GL_PROJECTION) glLoadIdentity() gluPerspective(60.0, width / height, 1.0, 50.0) glMatrixMode(GL_MODELVIEW) PyCEGUI.System.getSingleton().notifyDisplaySizeChanged( PyCEGUI.Size(width, height))
def create_toolbars(self): """Creates the editors toolbars""" new_toolbar = BasicToolbar(self.app) if new_toolbar.name in self.toolbars: raise RuntimeError("Toolbar with name %s already exists" % (new_toolbar.name)) self.toolbar.setTabHeight(PyCEGUI.UDim(0, -1)) self.toolbars[new_toolbar.name] = new_toolbar gui = new_toolbar.gui self.toolbar.addTab(gui) new_toolbar = ObjectToolbar(self.app) if new_toolbar.name in self.toolbars: raise RuntimeError("Toolbar with name %s already exists" % (new_toolbar.name)) self.toolbar.setTabHeight(PyCEGUI.UDim(0, -1)) self.toolbars[new_toolbar.name] = new_toolbar gui = new_toolbar.gui self.toolbar.addTab(gui) self.toolbar.setSelectedTabAtIndex(0)
def initialize(self): name = "MenuResults" # No code written for this menu : use mandatory layout. window = Menu.initialize(self, name=name, title="Results", layout="menuresults") # Retrieve window descendants created here. self.mclTable = window.getChild(name + "/MclTable") self.btnContinue = window.getChild(name + "/BtnContinue") # Complete widget initialization (whatever creation mode : code or .layout). self.mclTable.addColumn("Rk", self.CIdRank, PyCEGUI.UDim(0.05, 0)) self.mclTable.addColumn("Adv", self.CIdAdvance, PyCEGUI.UDim(0.05, 0)) self.mclTable.addColumn("Driver", self.CIdDriver, PyCEGUI.UDim(0.18, 0)) self.mclTable.addColumn("Robot", self.CIdRobot, PyCEGUI.UDim(0.10, 0)) self.mclTable.addColumn("Car", self.CIdCar, PyCEGUI.UDim(0.17, 0)) self.mclTable.addColumn("Time", self.CIdTime, PyCEGUI.UDim(0.12, 0)) self.mclTable.addColumn("Best", self.CIdBestLap, PyCEGUI.UDim(0.10, 0)) self.mclTable.addColumn("Laps", self.CIdNLaps, PyCEGUI.UDim(0.05, 0)) self.mclTable.addColumn("Top spd", self.CIdTopSpeed, PyCEGUI.UDim(0.05, 0)) self.mclTable.addColumn("Damages", self.CIdDamages, PyCEGUI.UDim(0.05, 0)) self.mclTable.addColumn("Pits", self.CIdNPits, PyCEGUI.UDim(0.05, 0)) # Note: Keep a reference to each listbox item, # otherwise they get garbage collected at the end of this function, # and then CEGUI crashes of course (see below : self.mclItems.append). self.mclItems = [] for row in self.Results: rowId = self.mclTable.addRow() colId = 0 for col in row: mclItem = PyCEGUI.ListboxTextItem(unicode(col)) if colId == self.CIdAdvance: if col > 0: mclItem.setTextColours(PyCEGUI.colour(0xFFFFE000)) elif col < 0: mclItem.setTextColours(PyCEGUI.colour(0xFFA0A0A0)) self.mclTable.setItem(mclItem, colId, rowId) colId += 1 self.mclItems.append(mclItem) return window
def getWidgetPreviewImage(self, widgetType, previewWidth=128, previewHeight=64): """Renders and retrieves a widget preview image (as QImage). This is useful for various widget selection lists as a preview. """ self.ensureIsInitialised() self.makeGLContextCurrent() system = PyCEGUI.System.getSingleton() renderer = system.getRenderer() renderTarget = PyCEGUIOpenGLRenderer.OpenGLViewportTarget(renderer) renderTarget.setArea(PyCEGUI.Rectf(0, 0, previewWidth, previewHeight)) renderingSurface = PyCEGUI.RenderingSurface(renderTarget) widgetInstance = PyCEGUI.WindowManager.getSingleton().createWindow( widgetType, "preview") widgetInstance.setRenderingSurface(renderingSurface) # set it's size and position so that it shows up widgetInstance.setPosition( PyCEGUI.UVector2(PyCEGUI.UDim(0, 0), PyCEGUI.UDim(0, 0))) widgetInstance.setSize( PyCEGUI.USize(PyCEGUI.UDim(0, previewWidth), PyCEGUI.UDim(0, previewHeight))) # fake update to ensure everything is set widgetInstance.update(1) temporaryFBO = QtOpenGL.QGLFramebufferObject(previewWidth, previewHeight, GL.GL_TEXTURE_2D) temporaryFBO.bind() renderingSurface.invalidate() renderer.beginRendering() try: widgetInstance.render() finally: # no matter what happens we have to clean after ourselves! renderer.endRendering() temporaryFBO.release() PyCEGUI.WindowManager.getSingleton().destroyWindow(widgetInstance) return temporaryFBO.toImage()
def setCEGUIDisplaySize(self, width, height, lazyUpdate=True): self.ceguiDisplaySize = PyCEGUI.Sizef(width, height) self.setSceneRect( QtCore.QRectF(-self.scenePadding, -self.scenePadding, width + 2 * self.scenePadding, height + 2 * self.scenePadding)) if not lazyUpdate: PyCEGUI.System.getSingleton().notifyDisplaySizeChanged( self.ceguiDisplaySize) self.fbo = None
def onWindowSized(self, args): selCatName = self.cbxCat.getSelectedItem().getText() selTrackName = self.cbxTrack.getSelectedItem().getText() track = self.Tracks[selCatName][selTrackName] # Update background image clipping, according to new window size, # as we want to keep its aspect ratio. # Note the image assignment to the always existing "full_image" one # before undefining the target "undeformed" : prevents crashes :-) imgSize = self.imgSetPreview.getNativeResolution() clipX, clipY = self.getPreviewClipping(imgSize) self.window.setProperty("Image", "set:%s image:full_image" % track.preview) self.imgSetPreview.undefineImage("undeformed") self.imgSetPreview.defineImage( "undeformed", PyCEGUI.Vector2(clipX, clipY), PyCEGUI.Size(imgSize.d_width - 2 * clipX, imgSize.d_height - 2 * clipY), PyCEGUI.Vector2(0, 0)) self.window.setProperty("Image", "set:%s image:undeformed" % track.preview)
def getStringSetOfWidgetLookFeelNames(self): """ Returns a PyCEGUI.StringSet containing all (mapped) names of WidgetLookFeels that the file is associated with according to the editor :return: PyCEGUI.StringSet """ # We add every WidgetLookFeel name of this Look N' Feel to a StringSet nameSet = PyCEGUI.StringSet() for nameTuple in self.nameMappingsOfOwnedWidgetLooks: nameSet.add(nameTuple[1]) return nameSet
def setPreviewWidget(self, widgetType): if self.currentPreviewWidget is not None: self.rootPreviewWidget.removeChild(self.currentPreviewWidget) PyCEGUI.WindowManager.getSingleton().destroyWindow( self.currentPreviewWidget) self.currentPreviewWidget = None if widgetType != "": try: self.currentPreviewWidget = PyCEGUI.WindowManager.getSingleton( ).createWindow(widgetType, "PreviewWidget") except Exception as ex: QtGui.QMessageBox.warning( self, "Unable to comply!", "Your selected preview widget of type '%s' can't be used as a preview widget, error occured ('%s')." % (widgetType, ex)) self.currentPreviewWidget = None self.synchInstanceAndWidget() return self.currentPreviewWidget.setPosition( PyCEGUI.UVector2(PyCEGUI.UDim(0.25, 0), PyCEGUI.UDim(0.25, 0))) self.currentPreviewWidget.setSize( PyCEGUI.USize(PyCEGUI.UDim(0.5, 0), PyCEGUI.UDim(0.5, 0))) self.rootPreviewWidget.addChild(self.currentPreviewWidget) self.synchInstanceAndWidget()
def __init__(self, root, app): self.app = app size = PyCEGUI.USize(PyCEGUI.UDim(1.0, 0), PyCEGUI.UDim(1.0, 0)) self.properties_box = root.createChild("TaharezLook/GroupBox", "properties_box") self.properties_box.setSize(size) self.properties_box.setText("Properties") self.properties_pane = self.properties_box.createChild( "TaharezLook/ScrollablePane", "property_container") self.properties_pane.setShowVertScrollbar(True) self.properties_pane.setSize(size) self.properties_area = self.properties_pane.createChild( "VerticalLayoutContainer") self.sections = {} self.__value_changed_callbacks = [] self.__list_items = [] self.property_types = [] self.remove_callbacks = set() self.__enable_add = False self.__add_callback = None self.add_button = None self.__add_text = None
def clear(self): # scroll the log to the beginning (workaround) args = PyCEGUI.MouseEventArgs(self.output) args.wheelChange = 1000 #self.output.fireEvent(PyCEGUI.GUISheet.EventMouseWheel, args) self.messages = "" self.last_message = "" self.duplicate_count = 1 self.length_before_last = 0 self.output.setText("") for link in self.links: self.output.removeChild(link)
def initialize(self): name = "MenuProfiles" # No code written for this menu : use mandatory layout. window = Menu.initialize(self, name=name, title="Profiles", layout="menuprofiles") # Retrieve window descendants created here. self.btnAccept = window.getChild(name + "/BtnAccept") self.btnCancel = window.getChild(name + "/BtnCancel") self.edxName = window.getChild(name + "/EdxName") self.cbxSkill = window.getChild(name + "/CbxSkill") self.lbxProfiles = window.getChild(name + "/LbxProfiles") self.btnAdd = window.getChild(name + "/BtnAdd") self.btnRemove = window.getChild(name + "/BtnRemove") # Complete widget initialization. self.cbxSkillItems = [] for skill in ("Rookie", "Amateur", "Semi-pro", "Pro"): cbxItem = PyCEGUI.ListboxTextItem(skill) cbxItem.setSelectionBrushImage("CEGUIDemo", "ComboboxSelectionBrush") cbxItem.setSelectionColours(0xFF3FFFEE) self.cbxSkill.addItem(cbxItem) self.cbxSkillItems.append( cbxItem) # Avoid its being GC'd at return ! if skill.startswith("Rookie"): self.cbxSkill.setText(cbxItem.getText()) #self.lbProfItems = [] self.lbItemId = 0 for name in ("Mike", "Horst", "Paolo", "Albert", "Yuuki", "Bjorn", "Jane", "Henri", "Francesca", "Joao", "Klaus"): # Obsolete Listbox use case. #lbItem = PyCEGUI.ListboxTextItem(name, auto_delete=False) #lbItem.setSelectionBrushImage("CEGUIDemo", "ListboxSelectionBrush") #lbItem.setSelectionColours(0xFF3FFFEE) #lbItem.setSelectionBrushImage("CEGUIDemo", "ListboxSelectionBrush") #lbItem.setSelectionColours(0xFF3FFFEE) #self.lbProfItems.append(lbItem) # Avoid its being GC'd at return ! lbItem = PyCEGUI.WindowManager.getSingleton().createWindow( "CEGUIDemo/ListboxItem", "profile_%d" % self.lbItemId) self.lbItemId += 1 lbItem.setText(name) self.lbxProfiles.addItem(lbItem) return window