Example #1
0
    def __init__(self, setting=None):
        if setting:
            self._setting = setting
        else:
            self._setting = Setting(app_name="",
                                    settings_file="./settings.xml")

        self.engine = fife.Engine()

        self.initLogging()
        self.loadSettings()

        self.engine.init()
        """
		we are giving users a valid screen resolution option that is supported
		"""
        screen_modes = self.engine.getDeviceCaps().getSupportedScreenModes()
        resolutions = list(
            set([(mode.getWidth(), mode.getHeight())
                 for mode in screen_modes]))

        resolutions = [
            "{0}x{1}".format(item[0], item[1])
            for item in sorted(resolutions)[1:]
        ]
        self._setting.setValidResolutions(resolutions)

        self.quitRequested = False
        self.breakRequested = False
        self.returnValues = []
Example #2
0
from fife import fife

print "Using the FIFE python module found here: ", os.path.dirname(
    fife.__file__)

from fife.extensions import *
from scripts import world
from scripts.common import eventlistenerbase
from fife.extensions.basicapplication import ApplicationBase
from fife.extensions import pychan
from fife.extensions.pychan import widgets
from fife.extensions.pychan.internal import get_manager
from fife.extensions.fife_settings import Setting
from fife.extensions.fife_utils import getUserDataDirectory

TDS = Setting(app_name="rio_de_hola")


class ApplicationListener(eventlistenerbase.EventListenerBase):
    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,
        ])
Example #3
0
from fife.extensions.savers import saveMapFile
from fife.extensions.fife_settings import Setting
from fife.extensions import pychan
from fife.extensions.pychan import widgets
from scripts.common.eventlistenerbase import EventListenerBase
from scripts.util import line_points
from agents.survivor import Survivor
from fife.extensions.fife_settings import Setting
from controller import Controller

from fife.fife import DoublePoint3D

from scripts.agents.mob import *
from scripts.extscheduler import ExtScheduler

TDS = Setting(app_name="zombieswtf")

DEFAULT_GLOBAL_LIGHT = {
    "R" : 0.0,
    "G" : 0.0,
    "B" : 0.0,
    "A" : 0.985
}

DEFAULT_SURVIVOR_LIGHT = {
    "intensity" : 1,
    "radius"    : 100,
    "subdivs"   : 32,
    "xstretch"  : 3,
    "ystretch"  : 2,
    "R"         : 150,
Example #4
0
# Import the main FIFE module
from fife import fife

# Import the FIFE Setting extension
from fife.extensions.fife_settings import Setting

# Import our Tutorial1Application class
from scripts.tutorial1 import Tutorial1Application

# This is required in order to use the ApplicationBase framework provided
# in the fife.extensions module.  app_name is the name of your application,
# settings_file is what to call your settings file.  If you don't provide
# a settings-dist.xml file a blank settings file will be created for you by
# the Setting extension.
settings = Setting(app_name="tutorial1",
                   settings_file="./settings.xml",
                   settings_gui_xml="")


def main():
    # This creates an instance of Tutorial1Application and passes it the
    # Setting instance you created above.  The ApplicationBase will
    # automatically create and configure an instance of the FIFE engine.
    app = Tutorial1Application(settings)

    # Start the application
    app.run()


if __name__ == '__main__':
    main()
Example #5
0
from fife.extensions import pychan
from fife.extensions.pychan.tools import callbackWithArguments as cbwa
from fife.extensions.pychan.internal import get_manager

from events import *
from gui import ToolBar, action
from gui.action import Action, ActionGroup
from gui.filemanager import FileManager
from gui.mainwindow import MainWindow
from gui.mapeditor import MapEditor
from gui.menubar import Menu, MenuBar
from gui.error import ErrorDialog
from mapview import MapView
from fife.extensions.fife_settings import Setting

TDS = Setting(app_name="editor")


def getEditor():
    """ Returns the Global editor instance """
    if Editor.editor is None:
        Editor(None)
    return Editor.editor


class Editor(ApplicationBase, MainWindow):
    """ Editor sets up all subsystems and provides access to them """
    editor = None

    def __init__(self, options, mapfile, *args, **kwargs):
        Editor.editor = self
Example #6
0
import sys, os, re

fife_path = os.path.join('..', '..', 'engine', 'python')
if os.path.isdir(fife_path) and fife_path not in sys.path:
    sys.path.insert(0, fife_path)

from fife import fife
from fife.extensions.fife_settings import Setting
from fife.extensions.cegui.ceguibasicapplication import CEGUIApplicationBase

import PyCEGUI

print "Using the FIFE python module found here: ", os.path.dirname(
    fife.__file__)

DemoSettings = Setting(app_name="CEGUI Demo")


class CEGUIDemo(CEGUIApplicationBase):
    def __init__(self, setting=None):
        super(CEGUIDemo, self).__init__(setting)

        self._loadSchemes()

        root = myRoot = PyCEGUI.WindowManager.getSingleton().createWindow(
            "DefaultWindow", "_MasterRoot")
        PyCEGUI.System.getSingleton().setGUISheet(myRoot)

        newWindow = PyCEGUI.WindowManager.getSingleton().loadWindowLayout(
            "MyConsole.layout", "second_")
        root.addChildWindow(newWindow)
Example #7
0
    sys.path.insert(0, fife_path)

from fife import fife
print "Using the FIFE python module found here: ", os.path.dirname(
    fife.__file__)

from fife.extensions import *
from scripts import world
from scripts.common import eventlistenerbase
from fife.extensions.basicapplication import ApplicationBase
from fife.extensions import pychan
from fife.extensions.pychan import widgets
from fife.extensions.fife_settings import Setting

TDS = Setting(app_name="shooter",
              settings_file="./settings.xml",
              settings_gui_xml="")

TDS.setAvailableScreenResolutions(["1024x768"])


class ApplicationListener(eventlistenerbase.EventListenerBase):
    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
Example #8
0
import os
import sys

fife_path = os.path.join('..', '..', 'engine', 'python', 'fife')
if os.path.isdir(fife_path) and fife_path not in sys.path:
    sys.path.insert(0, fife_path)

from fife import fife
print("Using the FIFE python module found here: ",
      os.path.dirname(fife.__file__))

from fife.extensions.fife_settings import Setting

from scripts.fife_test import FifeTestApplication

TDS = Setting(app_name="fife_test", settings_file="./settings.xml")


def main():
    app = FifeTestApplication(TDS)
    app.run()


if __name__ == '__main__':
    if TDS.get("FIFE", "ProfilingOn"):
        import hotshot
        import hotshot.stats
        print("Starting profiler")
        prof = hotshot.Profile("fife.prof")
        prof.runcall(main)
        prof.close()
Example #9
0
    def cb_map_loaded(self, game_map):
        """Callback for when a map was loaded"""

        fife_map = game_map.fife_map
        for layer in self.editor.get_layers(fife_map):
            for instance in layer.getInstances():
                filename = instance.getObject().getFilename()
                map_name = fife_map.getId()
                self.editor.increase_refcount(filename, map_name)

    def quit(self):
        """
        Quit the application. Really!
        """
        if self.current_dialog:
            return
        if self.editor_gui.ask_save_changed():
            self.quitRequested = True


if __name__ == '__main__':
    SETTING = Setting(app_name="frpg-editor", settings_file="./settings.xml")
    APP = EditorApplication(SETTING)
    VIEW = GameSceneView(APP)
    CONTROLLER = EditorController(VIEW, APP)
    APP.push_mode(CONTROLLER)
    CONTROLLER.listener.setup_cegui()
    APP.setup()
    APP.run()
Example #10
0
import os, sys

fife_path = os.path.join('..', 'fifengine', 'engine', 'python')
if os.path.isdir(fife_path) and fife_path not in sys.path:
    sys.path.insert(0, fife_path)

from fife.extensions.fife_settings import Setting
from fife.extensions.basicapplication import ApplicationBase

from scripts.common import eventlistenerbase
from scripts.world import World

settings = Setting(app_name="zombies", settings_file='settings.xml')


class ApplicationListener(eventlistenerbase.EventListenerBase):
    def __init__(self, engine, world):
        super(ApplicationListener, self).__init__(engine, regKeys=True)
        self.engine = engine
        self.world = world


class ZombiesApplication(ApplicationBase):
    def __init__(self, settings):
        super(ZombiesApplication, self).__init__(settings)
        self.world = World(self.engine)
        self.listener = ApplicationListener(self.engine, self.world)
        self.world.load('maps/country.xml')


def main():
Example #11
0
from fife import fife

from .common.eventlistenerbase import EventListenerBase
from agents.hero import Hero
from fife.extensions.fife_settings import Setting

TDS = Setting(app_name='zombies', settings_file='settings.xml')


class MapListener(fife.MapChangeListener):
    def __init__(self, map):
        fife.MapChangeListener.__init__(self)
        map.addChangeListener(self)


class World(EventListenerBase):
    def __init__(self, engine):
        super(World, self).__init__(engine, regKeys=True)
        self.engine = engine
        self.eventmanager = engine.getEventManager()
        self.model = engine.getModel()
        # self.filename = ''
        # self.pump_ctr = 0  # for testing purposis
        # self.ctrldown = False
        # self.instancemenu = None
        self.instance_to_agent = {}
        # self.dynamic_widgets = {}

    def load(self, filename):
        self.filename = filename
        # self.reset()