Ejemplo n.º 1
0
    def __init__(self):
        main_dir = core.ExecutionEnvironment.get_environment_variable(
            "MAIN_DIR")
        main_dir = core.Filename.from_os_specific(main_dir)
        core.load_prc_file(core.Filename(main_dir, "settings.prc"))

        ShowBase.__init__(self)
        self.disable_mouse()

        # Workaround for failure to load simplepbr shaders on macOS
        if getattr(sys, 'frozen', False) and sys.platform == 'darwin':
            simplepbr.__file__ = self.main_dir + '/'

        self.assume_gamepad = False

        DGG.setDefaultRolloverSound(loader.load_sfx('sfx/ui-a.ogg'))
        DGG.setDefaultClickSound(loader.load_sfx('sfx/ui-b.ogg'))

        base.setBackgroundColor((0, 0, 0, 1))

        self.quality_menu = Menu('quality.', [
            ('high.', self.setup_high),
            ('medium.', self.setup_medium),
            ('low.', self.setup_low),
            ('none.', self.setup_potato),
        ])
        self.quality_menu.show()

        self.gamepads = set()

        for dev in self.devices.get_devices(
                core.InputDevice.DeviceClass.gamepad):
            self._device_connected(dev)
        self.assume_gamepad = False

        self.accept('connect-device', self._device_connected)
        self.accept('disconnect-device', self._device_disconnected)
Ejemplo n.º 2
0
Archivo: app.py Proyecto: rdb/hexima
    def __init__(self):
        self.settings = core.load_prc_file(core.Filename.expand_from("$MAIN_DIR/settings.prc"))

        ShowBase.__init__(self, windowType='none')

        # Try opening "gl-version 3 2" window
        props = core.WindowProperties.get_default()
        have_window = False
        try:
            self.open_default_window(props=props)
            have_window = True
        except Exception:
            pass

        if not have_window:
            print("Failed to open window with OpenGL 3.2; falling back to older OpenGL.")
            core.load_prc_file_data("", "gl-version")
            self.open_default_window(props=props)
            print("The window seemed to have opened this time around.")

        gsg = self.win.gsg
        gl_version = (gsg.driver_version_major, gsg.driver_version_minor)
        self.has_fixed_function = gl_version < (3, 0) or gsg.max_lights > 0

        print("OpenGL version: {0}.{1} ({2})".format(*gl_version, 'compat' if self.has_fixed_function else 'core'))
        print("OpenGL renderer: {0}".format(gsg.driver_renderer))

        self.accept('escape', sys.exit)
        self.accept('f12', self.screenshot)
        self.disable_mouse()

        self.camLens.set_far(50)

        # Load in background
        self.set_background_color((0.31, 0.42, 0.53))
        if not self.win.get_fb_properties().srgb_color:
            print("Did not get an sRGB framebuffer.  The game may appear too dark.")

        # Load fonts
        self.symbol_font = loader.load_font("font/FreeSerif.otf")
        self.symbol_font.set_pixels_per_unit(64)

        self.regular_font = loader.load_font("font/Quicksand-Regular.otf")
        self.regular_font.set_pixels_per_unit(64)

        self.title_font = loader.load_font("font/Quicksand-Light.otf")
        self.title_font.set_pixels_per_unit(128)

        self.icon_fonts = {
            'solid': loader.load_font("font/font-awesome5-solid.otf"),
            'regular': loader.load_font("font/font-awesome5-regular.otf"),
        }
        for font in self.icon_fonts.values():
            font.set_pixels_per_unit(64)

        # Load sounds
        DGG.setDefaultClickSound(loader.load_sfx('sfx/menu-interact.wav'))
        DGG.setDefaultRolloverSound(loader.load_sfx('sfx/menu-focus.wav'))

        self.endtile_sound = loader.load_sfx('sfx/endtile.wav')
        self.move_sound = loader.load_sfx('sfx/die-move.wav')
        self.impassable_sound = loader.load_sfx('sfx/impassable.wav')
        self.button_sound = loader.load_sfx('sfx/button-press.wav')
        self.transport_sound = loader.load_sfx('sfx/transport-engage.wav')
        self.slide_sound = loader.load_sfx('sfx/ice-slide.wav')
        self.wind_sound = loader.load_sfx('sfx/wind.ogg')
        self.crack_sound = loader.load_sfx('sfx/tile-crack.wav')
        self.collapse_sound = loader.load_sfx('sfx/tile-collapse.wav')
        self.restart_sound = loader.load_sfx('sfx/menu-interact.wav')

        self.music = {
            'menu': loader.load_music('music/theme.ogg'),
            'one': loader.load_music('music/world1.ogg'),
            'two': loader.load_music('music/world2.ogg'),
            'three': loader.load_music('music/world3.ogg'),
            'four': loader.load_music('music/world4.ogg'),
            'five': loader.load_music('music/world5.ogg'),
            'six': loader.load_music('music/world6.ogg'),
        }
        self.playing_music = None
        self.music_on = True

        self.blur_shader = core.Shader.load(core.Shader.SL_GLSL, "shader/blur.vert", "shader/blur.frag")
        self.blur_scale = core.PTA_float([1.0])

        self.blurred_tex = None

        self.quality = None
        screen = ui.Screen("select quality")
        ui.Button(screen, 'sublime', pos=(0.0, 0), command=self.setup_game, extraArgs=[3])
        ui.Button(screen, 'mediocre', pos=(0.0, -0.15), command=self.setup_game, extraArgs=[2])
        ui.Button(screen, 'terrible', pos=(0.0, -0.3), command=self.setup_game, extraArgs=[1])
        self.quality_screen = screen

        screen.show_now()
        self.game_setup = False
        self.have_save = False
        self.blurred = True

        self.accept('connect-device', self.on_connect_device)
        self.accept('disconnect-device', self.on_disconnect_device)
        self.gamepads = set()

        dev_mgr = core.InputDeviceManager.get_global_ptr()
        for device in dev_mgr.get_devices(core.InputDevice.DeviceClass.gamepad):
            self.on_connect_device(device)

        self.gamepad_lstick_angle = None
        self.win_input = self.win.get_input_device(0)
        self.task_mgr.add(self.process_input)

        sys.stdout.flush()
        sys.stderr.flush()
Ejemplo n.º 3
0
ConfigVariableDouble('extractor-step-time').setValue(0.01)
backgroundNodePath = aspect2d.attachNewNode(backgroundNode, 0)
backgroundNodePath.setPos(0.0, 0.0, 0.0)
backgroundNodePath.setScale(render2d, VBase3(1))
backgroundNodePath.find('**/fg').hide()
logo = OnscreenImage(
    image='phase_3/maps/toontown-logo.png',
    scale=(1 / (4.0/3.0), 1, 1 / (4.0/3.0)),
    pos=backgroundNodePath.find('**/fg').getPos())
logo.setTransparency(TransparencyAttrib.MAlpha)
logo.setBin('fixed', 20)
logo.reparentTo(backgroundNodePath)
backgroundNodePath.find('**/bg').setBin('fixed', 10)
base.graphicsEngine.renderFrame()
DirectGuiGlobals.setDefaultRolloverSound(base.loadSfx('phase_3/audio/sfx/GUI_rollover.ogg'))
DirectGuiGlobals.setDefaultClickSound(base.loadSfx('phase_3/audio/sfx/GUI_create_toon_fwd.ogg'))
DirectGuiGlobals.setDefaultDialogGeom(loader.loadModel('phase_3/models/gui/dialog_box_gui'))
import TTLocalizer
from otp.otpbase import OTPGlobals
OTPGlobals.setDefaultProductPrefix(TTLocalizer.ProductPrefix)
if base.musicManagerIsValid:
    themeList = ('phase_3/audio/bgm/ttp_theme.ogg', 'phase_3/audio/bgm/ttp_theme_2.ogg')
    music = base.loadMusic(random.choice(themeList))
    if music:
        music.setLoop(1)
        music.setVolume(0.9)
        music.play()
    notify.info('Loading the default Toontown Planet GUI sounds...')
    DirectGuiGlobals.setDefaultRolloverSound(base.loadSfx('phase_3/audio/sfx/GUI_rollover.ogg'))
    DirectGuiGlobals.setDefaultClickSound(base.loadSfx('phase_3/audio/sfx/GUI_create_toon_fwd.ogg'))
else:
Ejemplo n.º 4
0
backgroundNodePath.find('**/fg').stash()

from direct.gui.DirectGui import OnscreenImage
logo = OnscreenImage('phase_3/maps/toontown-logo-new.png')
logo.reparentTo(backgroundNodePath)
logo.setBin('fixed', 20)
logo.setTransparency(TransparencyAttrib.MAlpha)
logo.setScale(.8, 1, .7)
logo.setZ(.3)

base.graphicsEngine.renderFrame()

# default DGG stuff
DirectGuiGlobals.setDefaultRolloverSound(
    base.loadSfx('phase_3/audio/sfx/GUI_rollover.ogg'))
DirectGuiGlobals.setDefaultClickSound(
    base.loadSfx('phase_3/audio/sfx/GUI_create_toon_fwd.ogg'))
DirectGuiGlobals.setDefaultDialogGeom(
    loader.loadModel('phase_3/models/gui/dialog_box_gui'))

# localizer
import TTLocalizer
from otp.otpbase import OTPGlobals
OTPGlobals.setDefaultProductPrefix(TTLocalizer.ProductPrefix)

# loading music
music = None
if base.musicManagerIsValid:
    music = base.musicManager.getSound('phase_3/audio/bgm/tt_theme.ogg')
    if music:
        music.setLoop(1)
        music.setVolume(0.9)
Ejemplo n.º 5
0
    base.preloader = PiratesPreloader.PiratesPreloader()

if base.win == None:
    print 'Unable to open window; aborting.'
    sys.exit()

launcher.setPandaErrorCode(0)
launcher.setPandaWindowOpen()
base.sfxPlayer.setCutoffDistance(500.0)
from pirates.audio import SoundGlobals
from pirates.audio.SoundGlobals import loadSfx
rolloverSound = loadSfx(SoundGlobals.SFX_GUI_ROLLOVER_01)
rolloverSound.setVolume(0.5)
DirectGuiGlobals.setDefaultRolloverSound(rolloverSound)
clickSound = loadSfx(SoundGlobals.SFX_GUI_CLICK_01)
DirectGuiGlobals.setDefaultClickSound(clickSound)
clearColor = Vec4(0.0, 0.0, 0.0, 1.0)
base.win.setClearColor(clearColor)
from pirates.shader.Hdr import *
hdr = Hdr()
from pirates.seapatch.Reflection import Reflection
Reflection.initialize(render)
serverVersion = base.config.GetString('server-version', 'no_version_set')
print 'serverVersion: ', serverVersion
from pirates.distributed import PiratesClientRepository
cr = PiratesClientRepository.PiratesClientRepository(serverVersion, launcher)
base.initNametagGlobals()
base.startShow(cr)
from otp.distributed import OtpDoGlobals
from pirates.piratesbase import UserFunnel
UserFunnel.logSubmit(1, 'CLIENT_OPENS')
Ejemplo n.º 6
0
    sm.doSunriseFor(sunrise=SHOWBASE_PREINIT)

    from src.mod.ModBase import ModBase
    base = ModBase()

    sm.doSunriseFor(sunrise=SHOWBASE_POSTINIT)

    ConfigVariableDouble('decompressor-step-time').setValue(0.01)
    ConfigVariableDouble('extractor-step-time').setValue(0.01)

    from direct.gui import DirectGuiGlobals
    DirectGuiGlobals.setDefaultFontFunc(CIGlobals.getToonFont)
    DirectGuiGlobals.setDefaultFont(CIGlobals.getToonFont())
    DirectGuiGlobals.setDefaultRolloverSound(
        loader.loadSfx("phase_3/audio/sfx/GUI_rollover.ogg"))
    DirectGuiGlobals.setDefaultClickSound(
        loader.loadSfx("phase_3/audio/sfx/GUI_create_toon_fwd.ogg"))
    DirectGuiGlobals.setDefaultDialogGeom(
        loader.loadModel("phase_3/models/gui/dialog_box_gui.bam"))

    from src.coginvasion.nametag import NametagGlobals
    NametagGlobals.setMe(base.cam)
    NametagGlobals.setCardModel('phase_3/models/props/panel.bam')
    NametagGlobals.setArrowModel('phase_3/models/props/arrow.bam')
    NametagGlobals.setChatBalloon3dModel('phase_3/models/props/chatbox.bam')
    NametagGlobals.setChatBalloon2dModel(
        'phase_3/models/props/chatbox_noarrow.bam')
    NametagGlobals.setThoughtBalloonModel(
        'phase_3/models/props/chatbox_thought_cutout.bam')
    chatButtonGui = loader.loadModel('phase_3/models/gui/chat_button_gui.bam')
    NametagGlobals.setPageButton(chatButtonGui.find('**/Horiz_Arrow_UP'),
                                 chatButtonGui.find('**/Horiz_Arrow_DN'),
    base.preloader = PiratesPreloader.PiratesPreloader()

if base.win == None:
    print 'Unable to open window; aborting.'
    sys.exit()

launcher.setPandaErrorCode(0)
launcher.setPandaWindowOpen()
base.sfxPlayer.setCutoffDistance(500.0)
from pirates.audio import SoundGlobals
from pirates.audio.SoundGlobals import loadSfx
rolloverSound = loadSfx(SoundGlobals.SFX_GUI_ROLLOVER_01)
rolloverSound.setVolume(0.5)
DirectGuiGlobals.setDefaultRolloverSound(rolloverSound)
clickSound = loadSfx(SoundGlobals.SFX_GUI_CLICK_01)
DirectGuiGlobals.setDefaultClickSound(clickSound)
clearColor = Vec4(0.0, 0.0, 0.0, 1.0)
base.win.setClearColor(clearColor)
from pirates.shader.Hdr import *
hdr = Hdr()
from pirates.seapatch.Reflection import Reflection
Reflection.initialize(render)
serverVersion = base.config.GetString('server-version', 'no_version_set')
print 'serverVersion:', serverVersion
from pirates.distributed import PiratesClientRepository
cr = PiratesClientRepository.PiratesClientRepository(serverVersion, launcher)
base.initNametagGlobals()
base.startShow(cr)
from otp.distributed import OtpDoGlobals
from pirates.piratesbase import UserFunnel
UserFunnel.logSubmit(1, 'CLIENT_OPENS')
vfs.mount(Filename("phase_3.5.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_4.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_5.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_5.5.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_6.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_7.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_8.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_9.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_10.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_11.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_12.mf"), ".", VirtualFileSystem.MFReadOnly)
vfs.mount(Filename("phase_13.mf"), ".", VirtualFileSystem.MFReadOnly)

DirectGuiGlobals.setDefaultRolloverSound(
    base.loadSfx("phase_5/audio/sfx/GUI_battlerollover.ogg"))
DirectGuiGlobals.setDefaultClickSound(
    base.loadSfx("phase_5/audio/sfx/GUI_battleselect.ogg"))

cbm = CullBinManager.getGlobalPtr()
cbm.addBin('ground', CullBinManager.BTUnsorted, 18)
cbm.addBin('shadow', CullBinManager.BTBackToFront, 19)
cbm.addBin('gui-popup', CullBinManager.BTUnsorted, 60)

port = base.config.GetInt('server-port')

ADMIN_ACCESS = 28001


class ServerBase(DirectObject):
    def __init__(self):
        base.sr = ServerRepository(
            tcpPort=port,
Ejemplo n.º 9
0
    print 'Unable to open window; aborting.'
    sys.exit()

launcher.setPandaErrorCode(0)
launcher.setPandaWindowOpen()
ConfigVariableDouble('decompressor-step-time').setValue(0.01)
ConfigVariableDouble('extractor-step-time').setValue(0.01)
backgroundNodePath = aspect2d.attachNewNode(backgroundNode, 0)
backgroundNodePath.setPos(0.0, 0.0, 0.0)
backgroundNodePath.setScale(render2d, VBase3(1))
backgroundNodePath.find('**/fg').setBin('fixed', 20)
backgroundNodePath.find('**/bg').setBin('fixed', 10)
base.graphicsEngine.renderFrame()
DirectGuiGlobals.setDefaultRolloverSound(
    base.loadSfx('phase_3/audio/sfx/GUI_rollover.mp3'))
DirectGuiGlobals.setDefaultClickSound(
    base.loadSfx('phase_3/audio/sfx/GUI_create_toon_fwd.mp3'))
DirectGuiGlobals.setDefaultDialogGeom(
    loader.loadModel('phase_3/models/gui/dialog_box_gui'))
import TTLocalizer
from otp.otpbase import OTPGlobals
OTPGlobals.setDefaultProductPrefix(TTLocalizer.ProductPrefix)
if base.musicManagerIsValid:
    music = base.musicManager.getSound(
        'phase_3/audio/bgm/tt_theme.mid'
    )  # Loads "The Toontown Theme" for the main theme
    if music:
        music.setLoop(1)
        music.setVolume(0.90000000000000002)
        music.play()

    print 'ToontownStart: Loading default gui sounds'
Ejemplo n.º 10
0
base.accept("f9", base.screenshot, ["screenshots/screenshot"])
from direct.filter.CommonFilters import CommonFilters

print "CIStart: Setting display preferences..."
sm.applySettings(jsonfile)
if base.win == None:
    print "CIStart: Unable to open window; aborting."
    sys.exit()
else:
    print "CIStart: Successfully opened window."
ConfigVariableDouble("decompressor-step-time").setValue(0.01)
ConfigVariableDouble("extractor-step-time").setValue(0.01)
DirectGuiGlobals.setDefaultFontFunc(CIGlobals.getToonFont)
DirectGuiGlobals.setDefaultFont(CIGlobals.getToonFont())
DirectGuiGlobals.setDefaultRolloverSound(loader.loadSfx("phase_3/audio/sfx/GUI_rollover.mp3"))
DirectGuiGlobals.setDefaultClickSound(loader.loadSfx("phase_3/audio/sfx/GUI_create_toon_fwd.mp3"))
DirectGuiGlobals.setDefaultDialogGeom(loader.loadModel("phase_3/models/gui/dialog_box_gui.bam"))


def maybeDoSomethingWithMusic(condition):
    width, height, fs, music, sfx, tex_detail, model_detail, aa, af = sm.getSettings(jsonfile)
    if condition == 0:
        if music == True:
            base.enableMusic(False)
    elif condition == 1:
        if music == True:
            base.enableMusic(True)


base.accept("PandaPaused", maybeDoSomethingWithMusic, [0])
base.accept("PandaRestarted", maybeDoSomethingWithMusic, [1])