Beispiel #1
0
	def create_gui(self):
		"""
			- creates the gui skeleton by loading the xml file
			- finds some important childs and saves their widget in the object
			
		FIXME:
			- move all dynamic widgets to dict
		"""
		self.container = pychan.loadXML('gui/objectedit.xml')
		self.container.mapEvents({
			'x_offset_up' 		: cbwa(self.change_offset_x, 1),
			'x_offset_dn' 		: cbwa(self.change_offset_x, -1),
			
			'y_offset_up' 		: cbwa(self.change_offset_y, 1),
			'y_offset_dn' 		: cbwa(self.change_offset_y, -1),
			
			'use_data'			: self.use_user_data,
			'change_data'		: self.save_user_data,
			
			'anim_left'			: self.previous_anim_frame,
			'anim_right'		: self.next_anim_frame,
			'anim_start_pos' 	: self.anim_start_frame,
			'anim_end_pos'		: self.anim_end_frame,
		})

		self._gui_anim_panel_wrapper = self.container.findChild(name="animation_panel_wrapper")
		self._gui_anim_panel = self._gui_anim_panel_wrapper.findChild(name="animation_panel")
		
		self._gui_rotation_dropdown = self.container.findChild(name="select_rotations")
		self._gui_rotation_dropdown.capture(self.gui_rotate_instance,"mouseWheelMovedUp")
		self._gui_rotation_dropdown.capture(self.gui_rotate_instance,"mouseWheelMovedDown")
		self._gui_rotation_dropdown.capture(self.gui_rotate_instance,"action")	
		
		self._gui_anim_actions_dropdown = self._gui_anim_panel_wrapper.findChild(name="select_actions")	
		self._gui_anim_actions_dropdown.capture(self.eval_gui_anim_action,"mouseWheelMovedUp")
		self._gui_anim_actions_dropdown.capture(self.eval_gui_anim_action,"mouseWheelMovedDown")
		self._gui_anim_actions_dropdown.capture(self.eval_gui_anim_action,"action")	
		
		self._gui_anim_playback = self._gui_anim_panel_wrapper.findChild(name="anim_playback")
		self._gui_anim_playback.capture(self.anim_playback, "mousePressed")
		self._gui_anim_loop = self._gui_anim_panel_wrapper.findChild(name="anim_loop")

		self._gui_current_frame = self._gui_anim_panel_wrapper.findChild(name="anim_current_frame")
		self._gui_current_frame.capture(self.previous_anim_frame,"mouseWheelMovedUp")
		self._gui_current_frame.capture(self.next_anim_frame,"mouseWheelMovedDown")	
		
		self._gui_xoffset_textfield = self.container.findChild(name="x_offset")
		self._gui_yoffset_textfield = self.container.findChild(name="y_offset")
		
		self._gui_instance_id_textfield = self.container.findChild(name="instance_id")
Beispiel #2
0
	def _createGui(self):
		""" Create the basic gui container """
		self._container =  pychan.loadXML('gui/cameradialog.xml')
		
		self._ok_button = self._container.findChild(name="okButton")
		self._cancel_button = self._container.findChild(name="cancelButton")
		
		self._ok_button.capture(self.saveSettings)
		self._ok_button.capture(cbwa(self._editor.getStatusBar().showTooltip, unicode("Save changes to the camera")), 'mouseEntered')
		self._ok_button.capture(self._editor.getStatusBar().hideTooltip, 'mouseExited')

		self._cancel_button.capture(self.toggle)
		self._cancel_button.capture(cbwa(self._editor.getStatusBar().showTooltip, unicode("Discard any changes to the camera")), 'mouseEntered')
		self._cancel_button.capture(self._editor.getStatusBar().hideTooltip, 'mouseExited')
Beispiel #3
0
    def __init__(self, engine, inventory, callbacks):
        """Initialise the instance.
           @type engine: fife.Engine
           @param engine: An instance of the fife engine
           @type inventory: Inventory
           @param inventory: An inventory object to be displayed and manipulated
           @type callbacks: dict
           @param callbacks: a dict of callbacks
               refreshReadyImages:
                   Function that will make the ready slots on the HUD
                   reflect those within the inventory
               toggleInventoryButton:
                   Function that will toggle the state of the inventory button
           @return: None"""
        pychan.init(engine, debug = True)
        self.engine = engine
        self.readyCallback = callbacks['refreshReadyImages']
        self.toggleInventoryButtonCallback = callbacks['toggleInventoryButton']
        self.original_cursor_id = self.engine.getCursor().getId()

        self.inventory = pychan.loadXML("gui/inventory.xml")
        self.inventory_shown = False
        events_to_map = {}
        self.inventory_storage = inventory
        
        # Buttons of inventory arranged by slots

        self.slot_buttons = {'head': ('Head',), 'chest': ('Body',),
                             'left_arm': ('LeftHand',),
                             'right_arm': ('RightHand',),
                             'hips' : ('Belt',), 'left_leg': ('LeftFoot',),
                             'right_leg': ('RightFoot',),
                             'left_hand': ('LeftHeld',),
                             'right_hand': ('RightHeld',),
                             'backpack': ('A1', 'A2', 'A3', 'A4', 'A5',
                                          'B1', 'B2', 'B3', 'B4', 'B5',
                                          'C1', 'C2', 'C3', 'C4', 'C5',
                                          'D1', 'D2', 'D3', 'D4', 'D5'),
                             'ready': ('Ready1', 'Ready2', 'Ready3', 'Ready4')
        }
        # the images that should be used for the buttons when they are "empty"
        self.slot_empty_images = {'head':'gui/inv_images/inv_head.png',
                                  'chest':'gui/inv_images/inv_torso.png',
                                  'left_arm':'gui/inv_images/inv_lhand.png',
                                  'right_arm':'gui/inv_images/inv_rhand.png',
                                  'hips':'gui/inv_images/inv_belt.png',
                                  'left_leg':'gui/inv_images/inv_lfoot.png',
                                  'right_leg':'gui/inv_images/inv_rfoot.png',
                                  'left_hand':'gui/inv_images/inv_litem.png',
                                  'right_hand':'gui/inv_images/inv_ritem.png',
                                  'backpack':'gui/inv_images/inv_backpack.png',
                                  'ready':'gui/inv_images/inv_belt_pouches.png',
                                  }
        self.updateInventoryButtons()

        for slot in self.slot_buttons:
            for index, button in enumerate(self.slot_buttons[slot]):
                events_to_map[button] = cbwa(self.dragDrop, button)
        events_to_map['close_button'] = self.closeInventoryAndToggle
        self.inventory.mapEvents(events_to_map)
Beispiel #4
0
	def removeInstances(self, instances):
		""" Removes all provided instances """
		mname = 'removeInstances'
		if not instances:
			if self.debug: print 'No instances assigned in %s' % mname
			return
			
		for i in instances:
			if self.debug: print 'Deleting instance ' + i.getObject().getId() + ' at ' + str(i.getLocation().getExactLayerCoordinates())
			
			if not self._undo:
				object = i.getObject()
				position = i.getLocation().getExactLayerCoordinates()
				undocall = cbwa(self.placeInstance, position, object)
				redocall = cbwa(self.removeInstanceOfObjectAt, position, object)
				undoobject = undomanager.UndoObject(undocall, redocall, "Removed instance")
				self._undomanager.addAction(undoobject)
				
			self._layer.deleteInstance(i)
Beispiel #5
0
	def _createGui(self):
		""" Create the basic gui container """
		self._container =  pychan.loadXML('gui/layertool.xml')
		self._wrapper = self._container.findChild(name="layers_wrapper")
		self._remove_layer_button = self._container.findChild(name="remove_layer_button")
		self._create_layer_button = self._container.findChild(name="add_layer_button")
		self._edit_layer_button = self._container.findChild(name="edit_layer_button")
		
		self._remove_layer_button.capture(self.removeSelectedLayer)
		self._remove_layer_button.capture(cbwa(self._editor.getStatusBar().showTooltip, self._remove_layer_button.helptext), 'mouseEntered')
		self._remove_layer_button.capture(self._editor.getStatusBar().hideTooltip, 'mouseExited')
		
		self._create_layer_button.capture(self.showLayerWizard)
		self._create_layer_button.capture(cbwa(self._editor.getStatusBar().showTooltip, self._create_layer_button.helptext), 'mouseEntered')
		self._create_layer_button.capture(self._editor.getStatusBar().hideTooltip, 'mouseExited')
		
		self._edit_layer_button.capture(self.showEditDialog)
		self._edit_layer_button.capture(cbwa(self._editor.getStatusBar().showTooltip, self._edit_layer_button.helptext), 'mouseEntered')
		self._edit_layer_button.capture(self._editor.getStatusBar().hideTooltip, 'mouseExited')
		
		self.update(None)
Beispiel #6
0
    def initializeEvents(self):
        """Intialize Hud events
           @return: None"""
        events_to_map = {}
        events_to_map["inventoryButton"] = cbwa(self.displayInventory, True)
        events_to_map["saveButton"] = self.saveGame
        events_to_map["loadButton"] = self.loadGame

        hud_ready_buttons = ["hudReady1", "hudReady2", "hudReady3", "hudReady4"]

        for item in hud_ready_buttons:
            events_to_map[item] = cbwa(self.readyAction, item)

        self.hud.mapEvents(events_to_map)

        menu_events = {}
        menu_events["newButton"] = self.newGame
        menu_events["quitButton"] = self.quitGame
        menu_events["saveButton"] = self.saveGame
        menu_events["loadButton"] = self.loadGame
        self.main_menu.mapEvents(menu_events)
Beispiel #7
0
	def placeInstance(self, position, object):
		""" Places an instance of object at position. Any existing instances on position are removed. """
		mname = 'placeInstance'
		if not object:
			if self.debug: print 'No object assigned in %s' % mname
			return
		if not position:
			if self.debug: print 'No position assigned in %s' % mname
			return
		if not self._layer:
			if self.debug: print 'No layer assigned in %s' % mname
			return

		if self.debug: print 'Placing instance of ' + object.getId() + ' at ' + str(position)
		
		# Remove instances from target position
		if not self._undo:
			instances = self.getInstancesFromPosition(position)
			if len(instances) == 1:
				# Check if the only instance at position has the same object
				objectId = instances[0].getObject().getId()
				objectNs = instances[0].getObject().getNamespace()
				if objectId == object.getId() and objectNs == object.getNamespace():
					if self.debug: print "Tried to place duplicate instance"
					return
					
			self._undomanager.startGroup("Placed instance")
			self.removeInstances(instances)

		inst = self._layer.createInstance(object, position)
		fife.InstanceVisual.create(inst)
		
		if not self._undo:
			redocall = cbwa(self.placeInstance, position, object)
			undocall = cbwa(self.removeInstanceOfObjectAt, position, object)
			undoobject = undomanager.UndoObject(undocall, redocall, "Placed instance")
			self._undomanager.addAction(undoobject)
			self._undomanager.endGroup()
Beispiel #8
0
    def initializeEvents(self):
        """Intialize Hud events
           @return: None"""
        events_to_map = {}

        # when we click the toggle button don't change the image
        events_to_map["inventoryButton"] = cbwa(self.toggleInventory, False)
        events_to_map["saveButton"] = self.save_game_callback
        events_to_map["loadButton"] = self.load_game_callback

        hud_ready_buttons = ["hudReady1", "hudReady2", \
                             "hudReady3", "hudReady4"]

        for item in hud_ready_buttons:
            events_to_map[item] = cbwa(self.readyAction, item)

        self.hud.mapEvents(events_to_map)

        menu_events = {}
        menu_events["newButton"] = self.newGame
        menu_events["quitButton"] = self.quitGame
        menu_events["saveButton"] = self.save_game_callback
        menu_events["loadButton"] = self.load_game_callback
        self.main_menu.mapEvents(menu_events)
Beispiel #9
0
	def _buildGui(self):
		if self.gui is not None:
			self.removeChild(self.gui)
			self._buttonlist = []
			
		self.gui = widgets.HBox()
		for i, menu in enumerate(self.menulist):
			button = widgets.Button(name=menu.name, text=menu.name)
			button.hexpand = 0
			button.capture(cbwa(self._showMenu, i))
			self._buttonlist.append(button)
			self.gui.addChild(button)
			
		self.gui.addSpacer(widgets.Spacer())
		
		self.addChild(self.gui)
Beispiel #10
0
Datei: editor.py Projekt: m64/PEG
	def newMapView(self, map):
		""" Creates a new map view """
		mapview = MapView(map)
		
		self._mapviewlist.append(mapview)
		
		map_action = Action(unicode(map.getId()))
		action.activated.connect(cbwa(self.showMapView, mapview), sender=map_action, weak=False)
		self._mapgroup.addAction(map_action)
		
		self.showMapView(mapview)
		
		events.preMapClosed.connect(self._preMapRemoved)
		events.postMapClosed.connect(self._postMapRemoved)
		events.mapAdded.send(sender=self, map=map)
		
		return mapview
Beispiel #11
0
	def addTab(self, widget, title):
		for tab in self.tabs:
			if tab[1] == widget:
				return
	
		widget.max_size = (5000, 5000)
		widget.hexpand = 1
		widget.vexpand = 1
	
		button = widgets.ToggleButton(text=title, group="faketab_"+str(id(self)))
		self.buttonbox.addChild(button)
		
		tab = (title, widget, button)
		self.tabs.append( tab )

		button.capture(cbwa(self.showTab, tab))
		self.showTab(tab)
		
		return tab
Beispiel #12
0
Datei: editor.py Projekt: m64/PEG
	def openFile(self, path):
		if path in self._open_files:
			# Map is already open, ask user if he wants to reload the map
			mapview = self.getMapviewByPath(path)
			YesNoDialog(u"Map is already open. Do you want to reload it?", cbwa(self.reloadMapview, mapview=mapview))
			return
	
		""" Opens a file """
		try:
			map = loaders.loadMapFile(path, self.engine)
			mapview = self.newMapView(map)
			self._open_files.append(path)
			return mapview
		except:
			traceback.print_exc(sys.exc_info()[1])
			errormsg = u"Opening map failed:\n"
			errormsg += u"File: "+unicode(path, sys.getfilesystemencoding())+u"\n"
			errormsg += u"Error: "+unicode(sys.exc_info()[1])
			ErrorDialog(errormsg)
			return None
Beispiel #13
0
Datei: popups.py Projekt: m64/PEG
    def showContainer(self):
        """
        Show the container
        @return: None
        """
        # Prepare slots 1 through 9
        empty_image = "gui/inv_images/inv_backpack.png"
        slot_count = 9
        self.empty_images = dict()
        self.events_to_map = {}
        for counter in range(1, slot_count):
            slot_name = "Slot%i" % counter
            self.empty_images[slot_name] = empty_image
            widget = self.container_gui.findChild(name=slot_name)
            widget.item = self.container.items.get(counter-1)
            widget.index = counter-1
            self.updateImage(widget)
            self.events_to_map[slot_name] = cbwa(self.dragDrop, slot_name)

        self.container_gui.mapEvents(self.events_to_map)

        self.container_gui.show()
Beispiel #14
0
	def showEditDialog(self):
		""" Show layerdialog for active layer """
		if not self._mapview: return
		layer = self.getActiveLayer()
		if not layer: return
		
		if self._layer_wizard: self._layer_wizard._widget.hide()
		self._layer_wizard = LayerDialog(self._editor.getEngine(), self._mapview.getMap(), layer=layer, callback=cbwa(self.update, self._mapview))
Beispiel #15
0
	def __init__(self):
		self.editor = scripts.editor.getEditor()
		self.engine = self.editor.getEngine()
		self._map = None
		self._layer = None
		self._mapdlg = None
		self._layerdlg = None
		self._cameradlg = None
		
		self._filebrowser = None
		self._importbrowser = None
		self._savebrowser = None

		newAction = Action(u"New map", "gui/icons/new_map.png")
		loadAction = Action(u"Open", "gui/icons/load_map.png")
		closeAction = Action(u"Close", "gui/icons/close_map.png")
		saveAction = Action(u"Save", "gui/icons/save_map.png")
		saveAsAction = Action(u"Save as", "gui/icons/save_mapas.png")
		saveAllAction = Action(u"Save all", "gui/icons/save_allmaps.png")
		importFileAction = Action(u"Import file", "gui/icons/import_file.png")
		importDirAction = Action(u"Import directory", "gui/icons/import_dir.png")
		
		newAction.helptext = u"Create new map"
		loadAction.helptext = u"Open existing map"
		closeAction.helptext = u"Close map"
		saveAction.helptext = u"Save map"
		saveAsAction.helptext = u"Save map as"
		saveAllAction.helptext = u"Save all opened maps"
		importFileAction.helptext = u"Imports an object file"
		importDirAction.helptext = u"Recursively imports all objects from a directory"
		
		action.activated.connect(self.showMapWizard, sender=newAction)
		action.activated.connect(self.showLoadDialog, sender=loadAction)
		action.activated.connect(self.closeCurrentMap, sender=closeAction)
		action.activated.connect(self.save, sender=saveAction)
		action.activated.connect(self.saveAs, sender=saveAsAction)
		action.activated.connect(self.editor.saveAll, sender=saveAllAction)
		
		self._importFileCallback = cbwa(self.showImportDialog, self.importFile, False)
		self._importDirCallback = cbwa(self.showImportDialog, self.importDir, True)
		action.activated.connect(self._importFileCallback, sender=importFileAction)
		action.activated.connect(self._importDirCallback, sender=importDirAction)
		
		eventlistener = self.editor.getEventListener()
		eventlistener.getKeySequenceSignal(fife.Key.N, ["ctrl"]).connect(self.showMapWizard)
		eventlistener.getKeySequenceSignal(fife.Key.O, ["ctrl"]).connect(self.showLoadDialog)
		eventlistener.getKeySequenceSignal(fife.Key.W, ["ctrl"]).connect(self.closeCurrentMap)
		eventlistener.getKeySequenceSignal(fife.Key.S, ["ctrl"]).connect(self.save)
		eventlistener.getKeySequenceSignal(fife.Key.S, ["ctrl", "shift"]).connect(self.editor.saveAll)
		
		fileGroup = ActionGroup()
		fileGroup.addAction(newAction)
		fileGroup.addAction(loadAction)
		fileGroup.addSeparator()
		fileGroup.addAction(closeAction)
		fileGroup.addSeparator()
		fileGroup.addAction(saveAction)
		fileGroup.addAction(saveAsAction)
		fileGroup.addAction(saveAllAction)
		fileGroup.addSeparator()
		fileGroup.addAction(importFileAction)
		fileGroup.addAction(importDirAction)
		
		self.editor.getToolBar().insertAction(fileGroup, 0)
		self.editor.getToolBar().insertSeparator(None, 1)
		self.editor._file_menu.insertAction(fileGroup, 0)
		self.editor._file_menu.insertSeparator(None, 1)
    def __init__(self, engine, items, readyCallback, toggleInventoryButtonCallback):
        """Initialise the instance.
           @type engine: fife.Engine
           @param engine: An instance of the fife engine
           @type items: dict
           @param items: A dictionary for every slot that goes '{slot:item, slot:item}'
                         if a slot is not included in the dict, it is assumed to be empty
           @type readyCallback: function
           @param readyCallback: The function that will make the
                                 ready slots on the HUD reflect those
                                 within the inventory
           @type toggleInventoryButtonCallback: function
           @param toggleInventoryButtonCallback: Function that will toggle the state of the inventory button
           @return: None"""
        pychan.init(engine, debug = True)
        self.engine = engine
        self.readyCallback = readyCallback
        self.toggleInventoryButtonCallback = toggleInventoryButtonCallback
        self.original_cursor_id = self.engine.getCursor().getId()
        # TODO: remove hard-coded string?
        self.inventory = pychan.loadXML("gui/inventory.xml")
        self.inventoryShown = False 
        self.events_to_map = {}
        # the images that should be used for the buttons when they are "empty"
        self.empty_images = {'A1':'gui/inv_images/inv_backpack.png',
                             'A2':'gui/inv_images/inv_backpack.png',
                             'A3':'gui/inv_images/inv_backpack.png',
                             'A4':'gui/inv_images/inv_backpack.png',
                             'A5':'gui/inv_images/inv_backpack.png',
                             'B1':'gui/inv_images/inv_backpack.png',
                             'B2':'gui/inv_images/inv_backpack.png',
                             'B3':'gui/inv_images/inv_backpack.png',
                             'B4':'gui/inv_images/inv_backpack.png',
                             'B5':'gui/inv_images/inv_backpack.png',
                             'C1':'gui/inv_images/inv_backpack.png',
                             'C2':'gui/inv_images/inv_backpack.png',
                             'C3':'gui/inv_images/inv_backpack.png',
                             'C4':'gui/inv_images/inv_backpack.png',
                             'C5':'gui/inv_images/inv_backpack.png',
                             'D1':'gui/inv_images/inv_backpack.png',
                             'D2':'gui/inv_images/inv_backpack.png',
                             'D3':'gui/inv_images/inv_backpack.png',
                             'D4':'gui/inv_images/inv_backpack.png',
                             'D5':'gui/inv_images/inv_backpack.png',
                             'Head':'gui/inv_images/inv_head.png',
                             'LeftHeld':'gui/inv_images/inv_litem.png',
                             'RightHeld':'gui/inv_images/inv_ritem.png',
                             'LeftHand':'gui/inv_images/inv_lhand.png',
                             'RightHand':'gui/inv_images/inv_rhand.png',
                             'Body':'gui/inv_images/inv_torso.png',
                             'Belt':'gui/inv_images/inv_belt.png',
                             'Ready1':'gui/inv_images/inv_belt_pouches.png',
                             'Ready2':'gui/inv_images/inv_belt_pouches.png',
                             'Ready3':'gui/inv_images/inv_belt_pouches.png',
                             'Ready4':'gui/inv_images/inv_belt_pouches.png',
                             'LeftFoot':'gui/inv_images/inv_lfoot.png',
                             'RightFoot':'gui/inv_images/inv_rfoot.png'}
        # every button on the inventory and its category
        self.buttons = {'A1':'main_inv', 'A2':'main_inv', 'A3':'main_inv',
                        'A4':'main_inv', 'A5':'main_inv', 'B1':'main_inv',
                        'B2':'main_inv', 'B3':'main_inv', 'B4':'main_inv',
                        'B5':'main_inv', 'C1':'main_inv', 'C2':'main_inv',
                        'C3':'main_inv', 'C4':'main_inv', 'C5':'main_inv',
                        'D1':'main_inv', 'D2':'main_inv', 'D3':'main_inv',
                        'D4':'main_inv', 'D5':'main_inv',
                        'LeftFoot':'foot', 'RightFoot':'foot',
                        'LeftHand':'hand', 'RightHand':'hand',
                        'Head':'head', 'Ready1':'ready', 
                        'Ready2':'ready', 'Ready3':'ready', 
                        'Ready4':'ready', 'Belt':'belt', 'LeftHeld':'held',
                        'RightHeld':'held', 'Body':'body'}
        # all possible categories
        self.locations = ['ready', 'head', 'foot', 'hand',
                          'belt', 'held', 'body']

        for key in items:
            widget = self.inventory.findChild(name=key)
            item = items[key]
            image = item_image_dict[item]

            widget.item = item
            widget.up_image = image
            widget.down_image = image
            widget.hover_image = image            

        for button in self.buttons:
            # make every button's callback be self.dragDrop
            self.events_to_map[button] = cbwa(self.dragDrop, button)
            ch = self.inventory.findChild(name = button)
            # make every slot's item be none if it has not already been set
            if button not in items:
                ch.item = ""

        self.events_to_map['close_button'] = self.closeInventoryAndToggle
        self.inventory.mapEvents(self.events_to_map)   
        self.resetMouseCursor()
Beispiel #17
0
    def __init__(self, engine, title, data):
        """
        A class to create a window showing the contents of a container.
        
        @type engine: fife.Engine
        @param engine: an instance of the fife engine
        @type title: string
        @param title: The title of the window
        @type data: list or string
        @param data: A list of 9 items to use for the slots 1 - 9 
                     OR
                     one item to be used for all the slots
        @return: None
        """
        self.engine = engine
        pychan.init(self.engine, debug=True)
        
        self.container_gui = pychan.loadXML("gui/container_base.xml")
        self.container_gui.findChild(name="topWindow").title = title
    
        data_drag.dragging = False
        self.original_cursor_id = self.engine.getCursor().getId()
        
        
        # Prepare slots 1 through 9
        dataIsList = False
        emptyImage = "gui/inv_images/inv_backpack.png"
        slotCount = 9
        self.empty_images = dict()
        # Did this step because I'm unsure which is more costly , to check the
        # type of object or the value of boolean object. Change as you see fit.
        if type(data) == list:
            dataIsList = True
        for counter in range(1, slotCount):
            slotName = "Slot%i" % counter
            selectedData = None
            
            if dataIsList:
                selectedData = data[counter-1]
            else:
                selectedData = data
            
            self.setContainerImage(slotName, item_image_dict[selectedData])
            self.container_gui.findChild(name=slotName).item = selectedData
            self.empty_images[slotName] = emptyImage
        
        
        self.events_to_map = {}
        self.buttons = {}

        for key in self.empty_images:
            self.buttons[key] = "main_inv"

        for button in self.buttons:
            # make every button's callback be self.dragDrop
            self.events_to_map[button] = cbwa(self.dragDrop, button)

        self.locations = ["main_inv"]

        self.container_gui.mapEvents(self.events_to_map)   
        self.resetMouseCursor()
Beispiel #18
0
	def create_gui(self):
		""" create gui container and setup callbacks """
		self.container = pychan.loadXML('gui/lightedit.xml')
		self.container.mapEvents({
			"enable_global_light"	:	self.toggle_light,
			"random_global_light"	:	self.random_color,
			"reset_global_light"	:	self.reset_global_light,
			
			"increase_R"			:	cbwa(self.increase_color, r=True),
			"decrease_R"			:	cbwa(self.decrease_color, r=True),
			"value_R/mouseWheelMovedUp"			:	cbwa(self.increase_color, step=0.2, r=True),
			"value_R/mouseWheelMovedDown"		:	cbwa(self.decrease_color, step=0.2, r=True),
			
			"increase_G"			:	cbwa(self.increase_color, g=True),
			"decrease_G"			:	cbwa(self.decrease_color, g=True),
			"value_G/mouseWheelMovedUp"			:	cbwa(self.increase_color, step=0.2, g=True),
			"value_G/mouseWheelMovedDown"		:	cbwa(self.decrease_color, step=0.2, g=True),
			
			"increase_B"			:	cbwa(self.increase_color, b=True),
			"decrease_B"			:	cbwa(self.decrease_color, b=True),
			"value_B/mouseWheelMovedUp"			:	cbwa(self.increase_color, step=0.2, b=True),
			"value_B/mouseWheelMovedDown"		:	cbwa(self.decrease_color, step=0.2, b=True),
			
			"increase_A"			:	cbwa(self.increase_color, a=True),
			"decrease_A"			:	cbwa(self.decrease_color, a=True),			
			"value_A/mouseWheelMovedUp"			:	cbwa(self.increase_color, step=0.2, a=True),
			"value_A/mouseWheelMovedDown"		:	cbwa(self.decrease_color, step=0.2, a=True),			
		})
		self._widgets = {
			"enable_global_light"	:	self.container.findChild(name="enable_global_light"),
			"random_global_light"	:	self.container.findChild(name="random_global_light"),
			"reset_global_light"	:	self.container.findChild(name="reset_global_light"),
			
			"value_R"				:	self.container.findChild(name="value_R"),
			"value_G"				:	self.container.findChild(name="value_G"),
			"value_B"				:	self.container.findChild(name="value_B"),
			"value_A"				:	self.container.findChild(name="value_A"),			
		}