コード例 #1
0
ファイル: settings.py プロジェクト: mvbarracuda/parpg
    def saveSettings(self):
        screen_resolution, render_backend, enable_fullscreen, enable_sound = self.OptionsDlg.collectData(
            "screen_resolution", "render_backend", "enable_fullscreen", "enable_sound"
        )
        render_backend = "OpenGL" if render_backend is 0 else "SDL"
        if render_backend != str(self.readSetting("RenderBackend")):
            self.setSetting("RenderBackend", render_backend)
            self.changesRequireRestart = True
        if int(enable_fullscreen) != int(self.readSetting("FullScreen")):
            self.setSetting("FullScreen", int(enable_fullscreen))
            self.changesRequireRestart = True
        if int(enable_sound) != int(self.readSetting("PlaySounds")):
            self.setSetting("PlaySounds", int(enable_sound))
            self.changesRequireRestart = True
        if screen_resolution != self.Resolutions.index(
            str(self.readSetting("ScreenWidth")) + "x" + str(self.readSetting("ScreenHeight"))
        ):
            self.setSetting("ScreenWidth", int(self.Resolutions[screen_resolution].partition("x")[0]))
            self.setSetting("ScreenHeight", int(self.Resolutions[screen_resolution].partition("x")[2]))
            self.changesRequireRestart = True

        if not self.isSetToDefault:
            self.tree.write("settings.xml")
        self.OptionsDlg.hide()
        if self.changesRequireRestart:
            RestartDlg = pychan.loadXML("gui/changes_require_restart.xml")
            RestartDlg.mapEvents({"closeButton": RestartDlg.hide})
            RestartDlg.show()
コード例 #2
0
ファイル: demoxml.py プロジェクト: weimingtom/iteration-zero
    def __init__(self, xmlfiles):
        self.engine = micron.Micron()

        self.engine.init(640, 640, 0)

        self.gui = guichan.Gui()
        self.gui.setGraphics(self.engine.getGraphics())
        self.gui.setInput(self.engine.getInput())

        self.font = micron.TTFont("content/fonts/vera.ttf", 12)

        guichan.Widget.setGlobalFont(self.font)

        self.top = guichan.Container()
        self.gui.setTop(self.top)
        self.top.setSize(640, 640)

        pychan.init(self.create_hook(), debug=True)
        for xmlfile in xmlfiles:
            self.widget = pychan.loadXML(xmlfile)
            self.widget.mapEvents(
                {
                    "okButton/mouseEntered": pychan.tools.attrSetCallback(base_color=(255, 0, 0)),
                    "okButton/mouseExited": pychan.tools.attrSetCallback(base_color=(255, 0, 255)),
                    "okButton": self.quit,
                }
            )
            self.widget.show()
コード例 #3
0
ファイル: settings.py プロジェクト: mvbarracuda/parpg
 def onOptionsPress(self):
     self.changesRequireRestart = False
     self.isSetToDefault = False
     self.Resolutions = ["640x480", "800x600", "1024x768", "1280x800", "1440x900"]
     if not hasattr(self, "OptionsDlg"):
         self.OptionsDlg = None
     if not self.OptionsDlg:
         self.OptionsDlg = pychan.loadXML("gui/settings.xml")
         self.OptionsDlg.distributeInitialData(
             {"screen_resolution": self.Resolutions, "render_backend": ["OpenGL", "SDL"]}
         )
         self.OptionsDlg.distributeData(
             {
                 "screen_resolution": self.Resolutions.index(
                     str(self.readSetting("ScreenWidth")) + "x" + str(self.readSetting("ScreenHeight"))
                 ),
                 "render_backend": 0 if str(self.readSetting("RenderBackend")) == "OpenGL" else 1,
                 "enable_fullscreen": int(self.readSetting("FullScreen")),
                 "enable_sound": int(self.readSetting("PlaySounds")),
             }
         )
         self.OptionsDlg.mapEvents(
             {"okButton": self.saveSettings, "cancelButton": self.OptionsDlg.hide, "defaultButton": self.setDefaults}
         )
     self.OptionsDlg.show()
コード例 #4
0
ファイル: hud.py プロジェクト: orlandov/parpg-game
 def initializeHelpMenu(self):
     """Initialize the help menu
        @return: None"""
     self.help_dialog = pychan.loadXML("gui/help.xml")
     help_events = {"closeButton":self.help_dialog.hide}
     self.help_dialog.mapEvents(help_events)
     main_help_text = u"Welcome to Post-Apocalyptic RPG or PARPG![br][br]"\
     "This game is still in development, so please expect for there to be "\
     "bugs and[br]feel free to tell us about them at "\
     "http://www.forums.parpg.net.[br]This game uses a "\
     "\"Point 'N' Click\" interface, which means that to move around,[br]"\
     "just click where you would like to go and your character will move "\
     "there.[br]PARPG also utilizes a context menu. To access this, just "\
     "right click anywhere[br]on the screen and a menu will come up. This "\
     "menu will change depending on[br]what you have clicked on, hence "\
     "it's name \"context menu\".[br][br]"
     
     k_text = u" Keybindings" 
     k_text += "[br] A : Add a test action to the actions display"
     k_text += "[br] I : Toggle the inventory screen"
     k_text += "[br] F5 : Take a screenshot"
     k_text += "[br]      (saves to <parpg>/screenshots/)"
     k_text += "[br] Q : Quit the game"
     self.help_dialog.distributeInitialData({
             "MainHelpText":main_help_text,
             "KeybindText":k_text
             })
コード例 #5
0
ファイル: world.py プロジェクト: mvbarracuda/parpg
	def show_instancemenu(self, clickpoint, instance):
		if instance.getFifeId() == self.hero.agent.getFifeId():
			return

		dynamicbuttons = ('moveButton', 'talkButton', 'kickButton', 'inspectButton')
		if not self.instancemenu:
			self.instancemenu = pychan.loadXML('gui/instancemenu.xml')
			self.instancemenu.mapEvents({
				'moveButton' : self.onMoveButtonPress,
				'talkButton' : self.onTalkButtonPress,
				'kickButton' : self.onKickButtonPress,
				'inspectButton' : self.onInspectButtonPress,
			})
			for btn in dynamicbuttons:
				self.dynamic_widgets[btn] = self.instancemenu.findChild(name=btn)
		for btn in dynamicbuttons:
			try:
				self.instancemenu.removeChild(self.dynamic_widgets[btn])
			except pychan.exceptions.RuntimeError:
				pass

		self.instancemenu.clickpoint = clickpoint
		self.instancemenu.instance = instance

		self.instancemenu.addChild(self.dynamic_widgets['inspectButton'])
		target_distance = self.hero.agent.getLocationRef().getLayerDistanceTo(instance.getLocationRef())
		if target_distance > 3.0:
			self.instancemenu.addChild(self.dynamic_widgets['moveButton'])
		else:
			if self.instance_to_agent.has_key(instance.getFifeId()):
				self.instancemenu.addChild(self.dynamic_widgets['talkButton'])
				self.instancemenu.addChild(self.dynamic_widgets['kickButton'])
		self.instancemenu.position = (clickpoint.x, clickpoint.y)
		self.instancemenu.show()
コード例 #6
0
ファイル: ObjectSelector.py プロジェクト: m64/PEG
	def buildGui(self):
		self.gui = pychan.loadXML('gui/objectselector.xml')

		# Add search field
		self._searchfield = self.gui.findChild(name="searchField")
		self._searchfield.capture(self._search)
		self._searchfield.capture(self._search, "keyPressed")
		self.gui.findChild(name="searchButton").capture(self._search)
		
		# Add the drop down with list of namespaces
		self.namespaces = self.gui.findChild(name="namespaceDropdown")
		self.namespaces.items = self.engine.getModel().getNamespaces()
		self.namespaces.selected = 0

		# TODO: Replace with SelectionEvent, once pychan supports it
		self.namespaces.capture(self.update_namespace, "action")
		self.namespaces.capture(self.update_namespace, "mouseWheelMovedUp")
		self.namespaces.capture(self.update_namespace, "mouseWheelMovedDown")
		self.namespaces.capture(self.update_namespace, "keyReleased")

		# Object list
		self.mainScrollArea = self.gui.findChild(name="mainScrollArea")
		self.objects = None
		if self.mode == 'list':
			self.setTextList()
		else: # Assuming self.mode is 'preview'
			self.setImageList()

		# Action buttons
		self.gui.findChild(name="toggleModeButton").capture(self.toggleMode)
		self.gui.findChild(name="closeButton").capture(self.hide)

		# Preview area
		self.gui.findChild(name="previewScrollArea").background_color = self.gui.base_color
		self.preview = self.gui.findChild(name="previewIcon")
コード例 #7
0
ファイル: inventorygui.py プロジェクト: m64/PEG
    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)
コード例 #8
0
ファイル: hud.py プロジェクト: mvbarracuda/parpg_mvbarracuda
 def requireRestartDialog(self):
     """Show a dialog asking the user to restart PARPG in order for their
        changes to take effect.
        @return: None"""
     require_restart_dialog = pychan.loadXML('gui/hud_require_restart.xml')
     require_restart_dialog.mapEvents({'okButton':require_restart_dialog.hide})
     require_restart_dialog.show()
コード例 #9
0
ファイル: dynamic.py プロジェクト: m64/PEG
	def start(self):
		self.widget = pychan.loadXML(self.xmlFile)
		self.widget.mapEvents({
			'okButton'   :self.stop,
			'addButton'  :self.addLabel,
		})
		self.labelBox = self.widget.findChild(name="labelBox")
		self.widget.show()
コード例 #10
0
ファイル: hud.py プロジェクト: orlandov/parpg-game
 def initializeMainMenu(self):
     """Initalize the main menu.
        @return: None"""
     self.main_menu = pychan.loadXML("gui/hud_main_menu.xml")
     self.menu_events = {"resumeButton":self.hideMenu, 
                         "optionsButton":self.displayOptions,
                         "helpButton":self.displayHelp}
     self.main_menu.mapEvents(self.menu_events)
コード例 #11
0
ファイル: dialogs.py プロジェクト: m64/PEG
 def __init__(self, xml, ok_field=None, cancel_field=None, initial_data={}, data={}):
     self.gui = loadXML(xml)
     self.ok_field = ok_field
     self.cancel_field = cancel_field
     self.initial_data = initial_data
     self.data = data
     self.max_size = None
     self.min_size = None
     self.gui.capture(print_event, "mouseEntered")
コード例 #12
0
ファイル: sliders.py プロジェクト: m64/PEG
	def start(self):
		self.widget = pychan.loadXML(self.xmlFile)
		self.widget.mapEvents({
			'xslider': self.update,
			'yslider': self.update,
			'closeButton':self.stop,
		})
		self.update()
		self.widget.show()
コード例 #13
0
ファイル: styling.py プロジェクト: m64/PEG
	def start(self):
		self.styledCredits = pychan.loadXML('gui/all_widgets.xml')
		self.styledCredits.distributeInitialData({
			'demoList' : map(lambda x:unicode(x,'utf8'),dir(pychan)),
			'demoText' : unicode(pychan.__doc__,'utf8')
		})

		self.widget = pychan.loadXML(self.xmlFile)
		self.widget.mapEvents({
			'testStyle' : self.testStyle,
			'closeButton':self.stop,
		})
		self.widget.distributeInitialData({
			'styleList' : self.styles
		})
		self.widget.position_technique = 'right-20:center'
		self.styledCredits.position_technique = 'left+20:center'
		self.widget.show()
		self.styledCredits.show()
コード例 #14
0
ファイル: hud.py プロジェクト: mvbarracuda/parpg_mvbarracuda
    def initializeOptionsMenu(self):
        """Initalize the options menu.
           @return: None"""
        self.options_menu = pychan.loadXML("gui/hud_options.xml")
        self.options_events = {"applyButton":self.applyOptions,
                               "closeButton":self.options_menu.hide,
                               "defaultsButton":self.setToDefaults,
                               "InitialVolumeSlider":self.updateVolumeText}
        
        settings = self.engine.getSettings()
        current_fullscreen = settings.isFullScreen()
        settings.setFullScreen(True)
        availableResolutions = settings.getPossibleResolutions()
        self.Resolutions = [str(x[0])+'x'+str(x[1]) for x in availableResolutions];
        settings.setFullScreen(current_fullscreen)
        self.RenderBackends = ['OpenGL', 'SDL']
        self.renderNumber = 0
        if (str(self.settings.readSetting('RenderBackend')) == "SDL"):
            self.renderNumber = 1
        initialVolume = float(self.settings.readSetting('InitialVolume'))
        initialVolumeText = str('Initial Volume: %.0f%s' %
                                (int(initialVolume*10), "%"))
        self.options_menu.distributeInitialData({
                'ResolutionBox': self.Resolutions,
                'RenderBox': self.RenderBackends,
                'InitialVolumeLabel' : initialVolumeText
                })

        sFullscreen = self.settings.readSetting(name="FullScreen")
        sSounds = self.settings.readSetting(name="PlaySounds")
        sRender = self.renderNumber
        sVolume = initialVolume

        screen_width = self.settings.readSetting(name="ScreenWidth")
        screen_height = self.settings.readSetting(name="ScreenHeight")
        indexRes = str(screen_width + 'x' + screen_height)
        try:
            sResolution = self.Resolutions.index(indexRes)
            resolutionInList = True
        except:
            resolutionInList = False

        dataToDistribute = {
                'FullscreenBox':int(sFullscreen), 
                'SoundsBox':int(sSounds),
                'RenderBox': sRender,
                'InitialVolumeSlider':sVolume
                }

        if (resolutionInList == True):
            dataToDistribute['ResolutionBox'] = sResolution

        self.options_menu.distributeData(dataToDistribute)

        self.options_menu.mapEvents(self.options_events)
コード例 #15
0
ファイル: error.py プロジェクト: m64/PEG
	def __init__(self, message):
		self._widget = pychan.loadXML('gui/error.xml')

		self._widget.mapEvents({
			'okButton'     : self._widget.hide
		})

		self._widget.distributeInitialData({
			'message' : message
		})
		self._widget.show()
		self._widget.adaptLayout() # Necessary to make scrollarea work properly
コード例 #16
0
ファイル: pychan_test.py プロジェクト: m64/PEG
	def __init__(self):
		# Let the ApplicationBase initialise FIFE
		super(DemoApplication,self).__init__()

		# Init Pychan
		pychan.init(self.engine,debug=False)
		pychan.loadFonts("fonts/freefont.fontdef")
		pychan.manager.setDefaultFont("FreeSans")
		pychan.setupModalExecution(self.mainLoop,self.breakFromMainLoop)

		# Build the main GUI
		self.gui = pychan.loadXML('gui/demoapp.xml')
		self.gui.min_size = self.engine.getRenderBackend().getScreenWidth(),self.engine.getRenderBackend().getScreenHeight()

		eventMap = {
			'creditsLink'  : self.showCredits,
			'closeButton'  : self.quit,
			'demoList' : self.selectExample,
		}
		self.gui.mapEvents(eventMap)

		# A simple hover-effect for the credits label
		credits = self.gui.findChild(name="creditsLink")
		# setEnterCallback is deprecated - we use it here to test it.
		credits.setEnterCallback(TextSetter(u"CREDITS"))
		# Note that we can't simply write:
		# credits.capture(credits._setText(u"Credits"), event_name="mouseExited")
		# that's because that would call credits._setText _NOW_ and we want to call
		# it later.
		credits.capture(lambda : credits._setText(u"Credits"), event_name="mouseExited")

		# Our list of examples
		# We keep a dictionary of these and fill
		# the ListBox on the left with its names.
		from dynamic import DynamicExample
		from styling import StylingExample
		from sliders import SliderExample
		self.examples = {
			'Absolute Positioning' : PyChanExample('gui/absolute.xml'),
			'All Widgets' : PyChanExample('gui/all_widgets.xml'),
			'Basic Styling' : StylingExample(),
			'Dynamic Widgets' : DynamicExample(),
			'Sliders' : SliderExample(),
			'ScrollArea' : PyChanExample('gui/scrollarea.xml'),
		}
		self.demoList = self.gui.findChild(name='demoList')
		self.demoList.items = sorted(self.examples.keys())

		# Finally show the main GUI
		self.gui.show()
		
		self.currentExample = None
		self.creditsWidget = None
コード例 #17
0
ファイル: editor.py プロジェクト: m64/PEG
	def _showHelpDialog(self, sender):
		""" Shows the help dialog """
		if self._help_dialog is not None:
			self._help_dialog.show()
			return
		
		self._help_dialog = pychan.loadXML("gui/help.xml")
		self._help_dialog.findChild(name="closeButton").capture(self._help_dialog.hide)
		
		f = open('lang/infotext.txt', 'r')
		self._help_dialog.findChild(name="helpText").text = unicode(f.read())
		f.close()
		
		self._help_dialog.show()
コード例 #18
0
ファイル: CameraEdit.py プロジェクト: m64/PEG
	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')
コード例 #19
0
ファイル: ObjectEdit.py プロジェクト: m64/PEG
	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")
コード例 #20
0
ファイル: yesnodialog.py プロジェクト: m64/PEG
	def __init__(self, prompt, onEntry, onCancel=None):
		self._callback = onEntry
		self._cancelCallback = onCancel

		self._widget = pychan.loadXML('gui/yesnodialog.xml')

		self._widget.mapEvents({
			'okButton'     : self._complete,
			'cancelButton' : self._cancel
		})

		self._widget.distributeInitialData({
			'prompt' : prompt
		})
		self._widget.show()
コード例 #21
0
ファイル: selection.py プロジェクト: m64/PEG
	def __init__(self, list, onSelection):
		self.list = list
		self._callback = onSelection

		self._widget = pychan.loadXML('gui/selection.xml')

		self._widget.mapEvents({
			'okButton'     : self._selected,
			'cancelButton' : self._widget.hide
		})

		self._widget.distributeInitialData({
			'optionDrop' : list
		})
		self._widget.show()
コード例 #22
0
	def showBrowser(self):
		if self._widget:
			self._widget.show()
			return
		self._widget = pychan.loadXML(self.guixmlpath)
		self._widget.mapEvents({
			'dirList'       : self._setDirectory,
			'selectButton'  : self._selectFile,
			'closeButton'   : self._widget.hide
		})
		self._setDirectory()
		if self.savefile:
			self._file_entry = widgets.TextField(name='saveField', text=u'')	
			self._widget.findChild(name="fileColumn").addChild(self._file_entry)
		self._widget.show()
コード例 #23
0
ファイル: pychan_test.py プロジェクト: m64/PEG
	def start(self):
		"""
		The Example Protocoll: start
		"""
		# For simplicity the most basic examples should define
		# a okButton and/or a closeButton. Those are mapped
		# to the stop handler.
		self.widget = pychan.loadXML(self.xmlFile)
		eventMap = {
			'closeButton':self.stop,
			'okButton'   :self.stop
		}
		# Since the basic example are not required to
		# supply close and ok button, we 'ignoreMissing'
		self.widget.mapEvents(eventMap, ignoreMissing = True)
		self.widget.show()
コード例 #24
0
ファイル: run.py プロジェクト: mvbarracuda/parpg
	def __init__(self, engine, world):
		super(ApplicationListener, self).__init__(engine,regKeys=True,regCmd=True, regMouse=False, regConsole=True, regWidget=True)
		self.engine = engine
		self.world = world
		engine.getEventManager().setNonConsumableKeys([
			fife.Key.ESCAPE,])

		self.quit = False
		self.aboutWindow = None

		self.rootpanel = pychan.loadXML('gui/rootpanel.xml')
		self.rootpanel.mapEvents({ 
			'quitButton' : self.onQuitButtonPress,
			'aboutButton' : self.onAboutButtonPress,
			'optionsButton' : TDS.onOptionsPress
		})
		self.rootpanel.show()
コード例 #25
0
ファイル: hud.py プロジェクト: orlandov/parpg-game
    def __init__(self, engine, settings, inv_model, callbacks):
        """Initialise the instance.
           @type engine: fife.Engine
           @param engine: An instance of the fife engine
           @type settings: settings.Setting
           @param settings: The settings data
           @type inv_model: dict
           @type callbacks: dict
           @param callbacks: a dict of callbacks
               saveGame: called when the user clicks on Save
               loadGame: called when the user clicks on Load
               quitGame: called when the user clicks on Quit
           @return: None"""
        pychan.init(engine, debug = True)

        # TODO: perhaps this should not be hard-coded here
        self.hud = pychan.loadXML("gui/hud.xml")
        self.engine = engine
        self.settings = settings

        inv_callbacks = {
            'refreshReadyImages': self.refreshReadyImages,
            'toggleInventoryButton': self.toggleInventoryButton,
        }

        self.inventory = inventory.Inventory(self.engine, \
                                             inv_model, inv_callbacks)
        self.refreshReadyImages()

        self.save_game_callback = callbacks['saveGame']
        self.load_game_callback = callbacks['loadGame']
        self.quit_callback     = callbacks['quitGame']

        self.box_container = None
        self.examine_box = None

        self.actions_box = self.hud.findChild(name="actionsBox")
        self.actions_text = []
        self.menu_displayed = False
        self.initializeHud()
        self.initializeMainMenu()
        self.initializeContextMenu()
        self.initializeOptionsMenu()
        self.initializeHelpMenu()
        self.initializeEvents()
        self.initializeQuitDialog()
コード例 #26
0
ファイル: layerdialog.py プロジェクト: m64/PEG
	def __init__(self, engine, map, callback=None, onCancel=None, layer=None):
		self.engine = engine
		self.model = engine.getModel()
		self.map = map
		self.layer = layer
		self.callback = callback
		self.onCancel = onCancel
		self._widget = pychan.loadXML('gui/layerdialog.xml')

		# TODO: Add access method for adopted grid types?
		self._widget.findChild(name="gridBox").items = ['square', 'hexagonal']
		
		# TODO: Ditto for pather?
		self._widget.findChild(name="pathingBox").items = ['cell_edges_only', 'cell_edges_and_diagonals', 'freeform']

		if layer:
			cg = layer.getCellGrid()
			cgtype = 0
			if cg.getType() == 'hexagonal':
				cgtype = 1
			
			self._widget.distributeData({
				"layerBox" : unicode(layer.getId()),
				"xScaleBox" : unicode(cg.getXScale()),
				"yScaleBox" : unicode(cg.getYScale()),
				"rotBox" : unicode(cg.getRotation()),
				"xOffsetBox" : unicode(cg.getXShift()),
				"yOffsetBox" : unicode(cg.getYShift()),
				"transBox" : unicode(layer.getLayerTransparency())
			})
			
			self._widget.findChild(name="pathingBox").selected = int(layer.getPathingStrategy())
			self._widget.findChild(name="gridBox").selected = int(cgtype)
		else:
			self._widget.findChild(name="pathingBox").selected = 0
			self._widget.findChild(name="gridBox").selected = 0

		self._widget.mapEvents({
			'okButton'     : self._finished,
			'cancelButton' : self._cancelled
		})

		self._widget.show()
コード例 #27
0
ファイル: LayerTool.py プロジェクト: m64/PEG
	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)
コード例 #28
0
ファイル: cameradialog.py プロジェクト: m64/PEG
	def __init__(self, engine, callback=None, onCancel=None, map=None, layer=None):
		self.engine = engine
		self.callback = callback
		self.onCancel = onCancel
		self._widget = pychan.loadXML('gui/cameradialog.xml')

		if map:
			self._widget.distributeData({
				'mapBox'	: unicode(map.getId()),
			})

		if layer:
			self._widget.distributeData({
				'layerBox'	: unicode(layer.getId()),
			})

		self._widget.mapEvents({
			'okButton'     : self._finished,
			'cancelButton' : self._cancelled
		})

		self._widget.show()
コード例 #29
0
ファイル: LightEdit.py プロジェクト: m64/PEG
	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"),			
		}
コード例 #30
0
ファイル: hud.py プロジェクト: mvbarracuda/parpg_mvbarracuda
    def __init__(self, engine, world, settings):
        """Initialise the instance.
           @type engine: fife.Engine
           @param engine: An instance of the fife engine
           @type settings: settings.Setting
           @param settings: The settings data
           @return: None"""
        pychan.init(engine, debug = True)

        # TODO: perhaps this should not be hard-coded here
        self.hud = pychan.loadXML("gui/hud.xml")
        self.engine = engine
        self.settings = settings
        self.world = weakref.proxy(world)
        self.actionsBox = self.hud.findChild(name="actionsBox")
        self.actionsText = []
        self.menu_displayed = False
        self.initializeHud()
        self.initializeMainMenu()
        self.initializeContextMenu()
        self.initializeOptionsMenu()
        self.initializeHelpMenu()
        self.initializeEvents()