/usr/share/games/fretsonfire/game/MainMenu.py is in fretsonfire-game 1.3.110.dfsg2-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | #####################################################################
# -*- coding: iso-8859-1 -*- #
# #
# Frets on Fire #
# Copyright (C) 2006 Sami Kyöstilä #
# #
# This program is free software; you can redistribute it and/or #
# modify it under the terms of the GNU General Public License #
# as published by the Free Software Foundation; either version 2 #
# of the License, or (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program; if not, write to the Free Software #
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, #
# MA 02110-1301, USA. #
#####################################################################
from OpenGL.GL import *
import math
import socket
from View import BackgroundLayer
from Menu import Menu
from Editor import Editor, Importer, GHImporter
from Credits import Credits
from Lobby import Lobby
from Svg import SvgDrawing
from Language import _
import Dialogs
import Config
import Audio
import Settings
class MainMenu(BackgroundLayer):
def __init__(self, engine, songName = None):
self.engine = engine
self.time = 0.0
self.nextLayer = None
self.visibility = 0.0
self.songName = songName
self.engine.loadSvgDrawing(self, "background", "keyboard.svg")
self.engine.loadSvgDrawing(self, "guy", "pose.svg")
self.engine.loadSvgDrawing(self, "logo", "logo.svg")
self.song = Audio.Sound(self.engine.resource.fileName("menu.ogg"))
self.song.setVolume(self.engine.config.get("audio", "songvol"))
self.song.play(-1)
newMultiplayerMenu = [
(_("Host Multiplayer Game"), self.hostMultiplayerGame),
(_("Join Multiplayer Game"), self.joinMultiplayerGame),
]
editorMenu = Menu(self.engine, [
(_("Edit Existing Song"), self.startEditor),
(_("Import New Song"), self.startImporter),
(_("Import Guitar Hero(tm) Songs"), self.startGHImporter),
])
settingsMenu = Settings.SettingsMenu(self.engine)
mainMenu = [
(_("Play Game"), self.newSinglePlayerGame),
(_("Tutorial"), self.showTutorial),
(_("Song Editor"), editorMenu),
(_("Settings >"), settingsMenu),
(_("Credits"), self.showCredits),
(_("Quit"), self.quit),
]
self.menu = Menu(self.engine, mainMenu, onClose = lambda: self.engine.view.popLayer(self))
def shown(self):
self.engine.view.pushLayer(self.menu)
self.engine.stopServer()
if self.songName:
self.newSinglePlayerGame(self.songName)
def hidden(self):
self.engine.view.popLayer(self.menu)
if self.song:
self.song.fadeout(1000)
if self.nextLayer:
self.engine.view.pushLayer(self.nextLayer())
self.nextLayer = None
else:
self.engine.quit()
def quit(self):
self.engine.view.popLayer(self.menu)
def catchErrors(function):
def harness(self, *args, **kwargs):
try:
try:
function(self, *args, **kwargs)
except:
import traceback
traceback.print_exc()
raise
except socket.error, e:
Dialogs.showMessage(self.engine, unicode(e[1]))
except KeyboardInterrupt:
pass
except Exception, e:
if e:
Dialogs.showMessage(self.engine, unicode(e))
return harness
def launchLayer(self, layerFunc):
if not self.nextLayer:
self.nextLayer = layerFunc
self.engine.view.popAllLayers()
def showTutorial(self):
if self.engine.isServerRunning():
return
self.engine.startServer()
self.engine.resource.load(self, "session", lambda: self.engine.connect("127.0.0.1"), synch = True)
if Dialogs.showLoadingScreen(self.engine, lambda: self.session and self.session.isConnected):
self.launchLayer(lambda: Lobby(self.engine, self.session, singlePlayer = True, songName = "tutorial"))
showTutorial = catchErrors(showTutorial)
def newSinglePlayerGame(self, songName = None):
if self.engine.isServerRunning():
return
self.engine.startServer()
self.engine.resource.load(self, "session", lambda: self.engine.connect("127.0.0.1"), synch = True)
if Dialogs.showLoadingScreen(self.engine, lambda: self.session and self.session.isConnected):
self.launchLayer(lambda: Lobby(self.engine, self.session, singlePlayer = True, songName = songName))
newSinglePlayerGame = catchErrors(newSinglePlayerGame)
def hostMultiplayerGame(self):
self.engine.startServer()
self.engine.resource.load(self, "session", lambda: self.engine.connect("127.0.0.1"))
if Dialogs.showLoadingScreen(self.engine, lambda: self.session and self.session.isConnected):
self.launchLayer(lambda: Lobby(self.engine, self.session))
hostMultiplayerGame = catchErrors(hostMultiplayerGame)
def joinMultiplayerGame(self, address = None):
if not address:
address = Dialogs.getText(self.engine, _("Enter the server address:"), "127.0.0.1")
if not address:
return
self.engine.resource.load(self, "session", lambda: self.engine.connect(address))
if Dialogs.showLoadingScreen(self.engine, lambda: self.session and self.session.isConnected, text = _("Connecting...")):
self.launchLayer(lambda: Lobby(self.engine, self.session))
joinMultiplayerGame = catchErrors(joinMultiplayerGame)
def startEditor(self):
self.launchLayer(lambda: Editor(self.engine))
startEditor = catchErrors(startEditor)
def startImporter(self):
self.launchLayer(lambda: Importer(self.engine))
startImporter = catchErrors(startImporter)
def startGHImporter(self):
self.launchLayer(lambda: GHImporter(self.engine))
startGHImporter = catchErrors(startGHImporter)
def showCredits(self):
self.launchLayer(lambda: Credits(self.engine))
showCredits = catchErrors(showCredits)
def run(self, ticks):
self.time += ticks / 50.0
def render(self, visibility, topMost):
self.visibility = visibility
v = 1.0 - ((1 - visibility) ** 2)
t = self.time / 100
w, h, = self.engine.view.geometry[2:4]
r = .5
self.background.transform.reset()
self.background.transform.translate((1 - v) * 2 * w + w / 2 + math.cos(t / 2) * w / 2 * r, h / 2 + math.sin(t) * h / 2 * r)
self.background.transform.rotate(-t)
self.background.transform.scale(math.sin(t / 8) + 2, math.sin(t / 8) + 2)
self.background.draw()
self.logo.transform.reset()
self.logo.transform.translate(.5 * w, .8 * h + (1 - v) * h * 2 * 0)
f1 = math.sin(t * 16) * .025
f2 = math.cos(t * 17) * .025
self.logo.transform.scale(1 + f1 + (1 - v) ** 3, -1 + f2 + (1 - v) ** 3)
self.logo.draw()
self.guy.transform.reset()
self.guy.transform.translate(.75 * w + (1 - v) * 2 * w, .35 * h)
self.guy.transform.scale(-.9, .9)
self.guy.transform.rotate(math.pi)
self.guy.draw()
|