Skip to content

Commit

Permalink
Merge branch 'master' of github.com:stump/fofix
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzion committed Nov 27, 2010
2 parents da2a193 + dd3a7d8 commit 6bb081c
Show file tree
Hide file tree
Showing 15 changed files with 1,258 additions and 655 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Expand Up @@ -14,6 +14,7 @@ src/*.idb
src/build
src/pypitch/_pypitch.cpp
src/cmgl.c
src/VideoPlayer.c
gstreamer/*
data/library.zip
data/users/players/*
Expand All @@ -27,3 +28,6 @@ data/themes/*
!data/themes/MegaLight GH3
!data/themes/MegaLight V4
!data/themes/Uberlight
win32/*
!win32/*.sh
!win32/*.py
83 changes: 26 additions & 57 deletions doc/RunningFromSource.mkd
Expand Up @@ -8,9 +8,8 @@ Table of Contents
3. [Notes on PyOpenGL versions](#Notes-on-PyOpenGL-versions)
4. [Setting up Python and third-party dependencies](#Setting-up-Python-and-third-party-dependencies)
5. [Compiling the native modules](#Compiling-the-native-modules)
6. [Dependencies for video playback](#Dependencies-for-video-playback)
7. [Starting the game](#Starting-the-game)
8. [Making binaries](#Making-binaries)
6. [Starting the game](#Starting-the-game)
7. [Making binaries](#Making-binaries)

<a name="Checking-out-the-latest-code"></a>
Checking out the latest code
Expand Down Expand Up @@ -179,6 +178,20 @@ The following packages are optional:
Install all packages by double-clicking the .exe or .msi files that
you downloaded.

#### Installing the Win32 Dependency Pack

Some code in FoFiX depends on external libraries written in C. The
`win32/` directory contains build scripts, but it can be difficult to
get the proper environment set up to use them.

Since building and setting up these libraries can be difficult, we are
making available a prebuilt archive of everything you need to compile
FoFiX's native modules. Download the latest FoFiX Win32 Dependency Pack
from [here](http://www.mediafire.com/?x0000ohmctblb) and unzip it into the
`win32/` directory. (The `deps/` directory in the archive should become
a subdirectory of the `win32/` directory.) Now you are ready to compile
the native modules.


### Mac OS X

Expand Down Expand Up @@ -217,7 +230,8 @@ The following are required:
* Python's development headers
* A C++ compiler
* Cython
* The OpenGL and GLU development headers
* pkg-config
* The OpenGL, GLU, GLib, libogg, libtheora, and libswscale (part of ffmpeg) development headers

The following are optional (refer to the Windows instructions to see
what each one is needed for):
Expand All @@ -230,9 +244,10 @@ what each one is needed for):
For those of you on Debian or Ubuntu, this means installing the
following packages: `python-pygame`, `python-opengl`, `python-numpy`,
`python-imaging`, `python-ogg`, `python-pyvorbis`, `python-dev`,
`build-essential`, `cython`, `libgl1-mesa-dev`, `libglu1-mesa-dev`.
If you're stuck without pygame 1.9, also install `python-numeric`.
If you want Psyco, install `python-psyco`.
`build-essential`, `cython`, `pkg-config`, `libgl1-mesa-dev`,
`libglu1-mesa-dev`, `libglib2.0-dev`, `libogg-dev`, `libtheora-dev`,
`libswscale-dev`. If you're stuck without pygame 1.9, also install
`python-numeric`. If you want Psyco, install `python-psyco`.

Some packages can be troublesome, so we have notes below about certain
packages.
Expand Down Expand Up @@ -325,6 +340,10 @@ You will have to do this **every time** you receive changes to a `.c`,
are in danger of weird crashes, and our first question will probably be
whether or not you rebuilt the native modules.

(If `setup.py` complains about any programs or libraries being missing,
check that you have installed all of the dependencies, and for Windows
users, that the Win32 Dependency Pack is unpacked in the proper location.)

As for making sure you have a compiler, read the section for your
operating system.

Expand Down Expand Up @@ -355,56 +374,6 @@ Install the appropriate package from your distribution's repository.

Under Debian and Ubuntu, you want `build-essential`.

----
<a name="Dependencies-for-video-playback"></a>
Dependencies for video playback
-------------------------------

_This section is **optional**, and it is only necessary if you want to
try out the current implementation, which will be replaced soon._

To play videos in FoFiX you currently need to install GStreamer.
We'll be moving away from GStreamer soon (before 4.0), but for now,
here are the instructions.

_N.B.: While many types of video (i.e. anything the GStreamer installation
knows how to decode) work with the current code, the replacement video
code is likely not to support anything other than Theora._

Follow the instructions for your operating system.

### Windows

#### GStreamer binaries
Download a GStreamer binary repack:
<http://www.mediafire.com/file/zwzwzgyiggc/gstreamer.7z>

Use 7-Zip or a compatible archiving program to unpack it into the root of
the FoFiX environment. (If done correctly, this should create a folder
named `gstreamer` on the same level as `data`, `doc`, `pkg`, `src`, and
`svg`, and the `gstreamer` folder should have as its direct children
folders named `bin`, `etc`, `lib`, `share`, and `src` and a file named
`COPYING`. Carefully check how you unpacked it if this is not the case.)

#### PyGObject

Download and run this:
<http://ftp.gnome.org/pub/GNOME/binaries/win32/pygobject/2.14/pygobject-2.14.2-2.win32-py2.6.exe>

#### PyGst

Download and run this:
<http://www.mediafire.com/file/l2ntmxyqjdf/pygst-0.10.23.0.win32-py2.6.exe>

### Mac OS X

Someone with a Mac will have to expand this section.

### GNU/Linux

Install the Python GStreamer bindings (pygst) and all of their
dependencies. Under Debian and Ubuntu, the package to install is
`python-gst0.10`.

----
<a name="Starting-the-game"></a>
Expand Down
35 changes: 12 additions & 23 deletions src/Credits.py
Expand Up @@ -40,11 +40,7 @@
import Config
import Dialogs

try:
from VideoPlayer import VideoPlayer
videoAvailable = True
except:
videoAvailable = False
from VideoPlayer import VideoLayer, VideoPlayerError

class Element:
"""A basic element in the credits scroller."""
Expand Down Expand Up @@ -173,24 +169,17 @@ def __init__(self, engine, songName = None):
self.videoLayer = False
self.background = None

if videoAvailable:
# TODO: Parameters to add to theme.ini:
# - credits_video_file
# - credits_video_start_time
# - credits_video_end_time
vidSource = os.path.join(Version.dataPath(), 'themes', self.themename, \
'menu', 'credits.ogv')
if os.path.exists(vidSource):
winWidth, winHeight = self.engine.view.geometry[2:4]
songVideoStartTime = 0
songVideoEndTime = None
self.vidPlayer = VideoPlayer(-1, vidSource, (winWidth, winHeight),
mute = True, loop = True,
startTime = songVideoStartTime,
endTime = songVideoEndTime)
if self.vidPlayer.validFile:
self.engine.view.pushLayer(self.vidPlayer)
self.videoLayer = True
vidSource = os.path.join(Version.dataPath(), 'themes', self.themename, \
'menu', 'credits.ogv')
if os.path.isfile(vidSource):
try:
self.vidPlayer = VideoLayer(self.engine, vidSource, mute = True, loop = True)
except (IOError, VideoPlayerError):
Log.error('Error loading credits video:')
else:
self.vidPlayer.play()
self.engine.view.pushLayer(self.vidPlayer)
self.videoLayer = True

if not self.videoLayer and \
not self.engine.loadImgDrawing(self, 'background', os.path.join('themes', self.themename, 'menu', 'credits.png')):
Expand Down
45 changes: 18 additions & 27 deletions src/FoFiX.py
Expand Up @@ -45,6 +45,11 @@
import os
import Version

# Add the directory of DLL dependencies to the PATH if we're running
# from source on Windows so we pick them up when those bits are imported.
if os.name == 'nt' and not hasattr(sys, 'frozen'):
os.environ['PATH'] = os.path.abspath(os.path.join('..', 'win32', 'deps', 'bin')) + os.pathsep + os.environ['PATH']

def _usage(errmsg=None):
usage = """Usage: %(prog)s [options]
Expand Down Expand Up @@ -109,12 +114,7 @@ def _usage(errmsg=None):
import Resource
import pygame
import traceback

try:
from VideoPlayer import VideoPlayer
videoAvailable = True
except:
videoAvailable = False
from VideoPlayer import VideoLayer, VideoPlayerError

def main():
try:
Expand Down Expand Up @@ -218,33 +218,24 @@ def main():
# Play the intro video if it is present, we have the capability, and
# we are not in one-shot mode.
videoLayer = False
if videoAvailable and not engine.cmdPlay:
# TODO: Parameters to add to theme.ini:
# - intro_video_file
# - intro_video_start_time
# - intro_video_end_time
if not engine.cmdPlay:
themename = Config.get("coffee", "themename")
vidSource = os.path.join(Version.dataPath(), 'themes', themename, \
'menu', 'intro.ogv')
if os.path.isfile(vidSource):
winWidth, winHeight = engine.view.geometry[2:4]
songVideoStartTime = 0
songVideoEndTime = None
vidPlayer = VideoPlayer(-1, vidSource, (winWidth, winHeight),
startTime = songVideoStartTime,
endTime = songVideoEndTime)
if vidPlayer.validFile:
try:
vidPlayer = VideoLayer(engine, vidSource, cancellable=True)
except (IOError, VideoPlayerError):
Log.error("Error loading intro video:")
else:
vidPlayer.play()
engine.view.pushLayer(vidPlayer)
videoLayer = True
try:
engine.ticksAtStart = pygame.time.get_ticks()
while not vidPlayer.finished:
engine.run()
engine.view.popLayer(vidPlayer)
engine.view.pushLayer(MainMenu(engine))
except KeyboardInterrupt:
engine.view.popLayer(vidPlayer)
engine.view.pushLayer(MainMenu(engine))
engine.ticksAtStart = pygame.time.get_ticks()
while not vidPlayer.finished:
engine.run()
engine.view.popLayer(vidPlayer)
engine.view.pushLayer(MainMenu(engine))
if not videoLayer:
engine.setStartupLayer(MainMenu(engine))

Expand Down
37 changes: 16 additions & 21 deletions src/GuitarScene.py
Expand Up @@ -1309,22 +1309,17 @@ def __init__(self, engine, libraryName, songName):

# evilynux - Load stage background(s)
if self.stage.mode == 3:
if Stage.videoAvailable:
songVideo = None
if self.song.info.video is not None:
songVideo = self.song.info.video
songVideoStartTime = self.song.info.video_start_time
songVideoEndTime = self.song.info.video_end_time
if songVideoEndTime == -1:
songVideoEndTime = None
self.stage.loadVideo(self.libraryName, self.songName,
songVideo = songVideo,
songVideoStartTime = songVideoStartTime,
songVideoEndTime = songVideoEndTime)
else:
Log.warn("Video playback is not supported. GStreamer or its python bindings can't be found")
self.engine.config.set("game", "stage_mode", 1)
self.stage.mode = 1
songVideo = None
if self.song.info.video is not None:
songVideo = self.song.info.video
songVideoStartTime = self.song.info.video_start_time
songVideoEndTime = self.song.info.video_end_time
if songVideoEndTime == -1:
songVideoEndTime = None
self.stage.loadVideo(self.libraryName, self.songName,
songVideo = songVideo,
songVideoStartTime = songVideoStartTime,
songVideoEndTime = songVideoEndTime)

self.stage.load(self.libraryName, self.songName, self.playerList[0].practiceMode)

Expand Down Expand Up @@ -1757,7 +1752,7 @@ def freeResources(self):
if self.coOpType:
self.coOpScoreCard.lastNoteEvent = None

if self.stage.mode == 3 and Stage.videoAvailable:
if self.stage.mode == 3:
self.engine.view.popLayer(self.stage.vidPlayer)

def getHandicap(self):
Expand Down Expand Up @@ -3895,14 +3890,14 @@ def endPick(self, num):
self.scoring[num].addScore(scoreTemp)

def render3D(self):
if self.stage.mode == 3 and Stage.videoAvailable:
if self.stage.mode == 3:
if self.countdown <= 0:
if self.pause == True or self.failed == True:
self.stage.vidPlayer.paused = True
self.stage.vidPlayer.pause()
else:
self.stage.vidPlayer.paused = False
self.stage.vidPlayer.play()
else:
self.stage.vidPlayer.paused = True
self.stage.vidPlayer.pause()

self.stage.render(self.visibility)

Expand Down
32 changes: 11 additions & 21 deletions src/Stage.py
Expand Up @@ -34,12 +34,8 @@
from Language import _
import math

try:
from VideoPlayer import VideoPlayer
videoAvailable = True
except:
videoAvailable = False

from VideoPlayer import VideoLayer, VideoPlayerError

import Rockmeter #blazingamer - new 4.0 code for rendering rockmeters through stage.ini


Expand Down Expand Up @@ -356,8 +352,6 @@ def get(value, type = str, default = None):

def loadVideo(self, libraryName, songName, songVideo = None,
songVideoStartTime = None, songVideoEndTime = None):
if not videoAvailable:
raise NameError('Video (gstreamer) is not available!')
self.vidSource = None
if self.songStage == 1:
songAbsPath = os.path.join(libraryName, songName)
Expand All @@ -383,26 +377,22 @@ def loadVideo(self, libraryName, songName, songVideo = None,
self.mode = 1 # Fallback
self.vidSource = None
return

winWidth, winHeight = (self.engine.view.geometry[2],
self.engine.view.geometry[3])
Log.debug("Attempting to load video: %s" % self.vidSource)

try: # Catches invalid video files or unsupported formats
Log.debug("Attempting to load video: %s" % self.vidSource)
self.vidPlayer = VideoPlayer(-1, self.vidSource, (winWidth, winHeight),
mute = True, loop = True,
startTime = songVideoStartTime,
endTime = songVideoEndTime)
self.vidPlayer = VideoLayer(self.engine, self.vidSource,
mute = True, loop = True,
startTime = songVideoStartTime,
endTime = songVideoEndTime)
self.engine.view.pushLayer(self.vidPlayer)
self.vidPlayer.paused = True
except:
except (IOError, VideoPlayerError):
self.mode = 1
Log.warn("Failed to load video, fallback to default stage mode.")
Log.error("Failed to load song video (falling back to default stage mode):")

def restartVideo(self):
if not videoAvailable or not self.mode == 3:
if not self.mode == 3:
return
self.vidPlayer.loadVideo(self.vidSource)
self.vidPlayer.restart()

def load(self, libraryName, songName, practiceMode = False):
rm = os.path.join("themes", self.themename, "rockmeter.ini")
Expand Down

0 comments on commit 6bb081c

Please sign in to comment.