Skip to content

Commit

Permalink
New branch. Starts game mode change.
Browse files Browse the repository at this point in the history
Goals:
-streamline menus and game settings to coherence.
--without sacrificing customizability!

some magic numbers; remove unused options.
  • Loading branch information
akedrou committed Apr 7, 2011
1 parent e911be4 commit f7c21cb
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 91 deletions.
2 changes: 1 addition & 1 deletion src/Drum.py
Expand Up @@ -67,7 +67,7 @@ def __init__(self, engine, playerObj, editorMode = False, player = 0):

self.drumsHeldDown = [0, 0, 0, 0, 0]

self.gameMode2p = self.engine.world.multiMode
self.gameMode2p = self.engine.world.multiplayer

self.lastFretWasBassDrum = False
self.lastFretWasT1 = False #Faaa Drum sound
Expand Down
4 changes: 2 additions & 2 deletions src/GameEngine.py
Expand Up @@ -767,8 +767,8 @@ def resizeScreen(self, width, height):
self.view.setGeometry((0, 0, width, height))
self.svg.setGeometry((0, 0, width, height))

def startWorld(self, players, maxplayers = None, gameMode = 0, multiMode = 0, allowGuitar = True, allowDrum = True, allowMic = False, tutorial = False):
self.world = World(self, players, maxplayers, gameMode, multiMode, allowGuitar, allowDrum, allowMic, tutorial)
def startWorld(self, mode = QUICKPLAY, multiplayer = None, tutorial = False):
self.world = World(self, mode, multiplayer, tutorial)

def finishGame(self):
if not self.world:
Expand Down
2 changes: 1 addition & 1 deletion src/Guitar.py
Expand Up @@ -47,7 +47,7 @@ def __init__(self, engine, playerObj, editorMode = False, player = 0, bass = Fal
self.strings = 5

self.debugMode = False
self.gameMode2p = self.engine.world.multiMode
self.gameMode2p = self.engine.world.multiplayer
self.matchingNotes = []

self.logClassInits = self.engine.config.get("game", "log_class_inits")
Expand Down
10 changes: 5 additions & 5 deletions src/GuitarScene.py
Expand Up @@ -98,8 +98,8 @@ def __init__(self, engine, libraryName, songName):

#MFH - retrieve game parameters:
self.gamePlayers = len(self.engine.world.players)
self.gameMode1p = self.engine.world.gameMode
self.gameMode2p = self.engine.world.multiMode
self.gameMode1p = self.engine.world.mode
self.gameMode2p = self.engine.world.multiplayer
self.lostFocusPause = self.engine.config.get("game", "lost_focus_pause")

if self.sinfo.bossBattle == "True" and self.gameMode1p == 2 and self.gamePlayers == 1:
Expand Down Expand Up @@ -2059,11 +2059,11 @@ def practiceSong(self):
self.engine.view.popLayer(self.menu)
self.engine.view.popLayer(self.failMenu)
self.freeResources()
self.engine.world.gameMode = 1
self.engine.world.mode = PRACTICE
self.engine.world.createScene("SongChoosingScene")

def changeSong(self):
prevMode = self.engine.world.gameMode
prevMode = self.engine.world.mode
if self.song:
self.song.stop()
self.song = None
Expand All @@ -2074,7 +2074,7 @@ def changeSong(self):
self.engine.view.popLayer(self.menu)
self.engine.view.popLayer(self.failMenu)
self.freeResources()
self.engine.world.gameMode = prevMode
self.engine.world.mode = prevMode
self.engine.world.createScene("SongChoosingScene")

def changeAfterFail(self):
Expand Down
39 changes: 14 additions & 25 deletions src/Lobby.py
Expand Up @@ -50,8 +50,6 @@ def __init__(self, engine):
self.minPlayers = self.engine.world.minPlayers
self.maxPlayers = self.engine.world.maxPlayers
self.tutorial = self.engine.world.tutorial
self.gameMode = self.engine.world.gameMode
self.multiMode = self.engine.world.multiMode
self.time = 0.0
self.keyControl = 0
self.keyGrab = False
Expand Down Expand Up @@ -92,31 +90,22 @@ def __init__(self, engine):
for i, type in enumerate(self.engine.input.controls.type):
self.types.append(type)
if type in GUITARTYPES:
if not self.engine.world.allowGuitar:
self.allowed[i] = False
else:
self.yes.extend([Player.CONTROLS[i][Player.KEY1], Player.CONTROLS[i][Player.KEY1A], Player.CONTROLS[i][Player.START]])
self.no.extend([Player.CONTROLS[i][Player.KEY2], Player.CONTROLS[i][Player.KEY2A], Player.CONTROLS[i][Player.CANCEL]])
self.conf.extend([Player.CONTROLS[i][Player.KEY3], Player.CONTROLS[i][Player.KEY3A]])
self.up.extend([Player.CONTROLS[i][Player.ACTION1], Player.CONTROLS[i][Player.UP]])
self.down.extend([Player.CONTROLS[i][Player.ACTION2], Player.CONTROLS[i][Player.DOWN]])
self.yes.extend([Player.CONTROLS[i][Player.KEY1], Player.CONTROLS[i][Player.KEY1A], Player.CONTROLS[i][Player.START]])
self.no.extend([Player.CONTROLS[i][Player.KEY2], Player.CONTROLS[i][Player.KEY2A], Player.CONTROLS[i][Player.CANCEL]])
self.conf.extend([Player.CONTROLS[i][Player.KEY3], Player.CONTROLS[i][Player.KEY3A]])
self.up.extend([Player.CONTROLS[i][Player.ACTION1], Player.CONTROLS[i][Player.UP]])
self.down.extend([Player.CONTROLS[i][Player.ACTION2], Player.CONTROLS[i][Player.DOWN]])
elif type in DRUMTYPES:
if not self.engine.world.allowDrum:
self.allowed[i] = False
else:
self.yes.extend([Player.CONTROLS[i][Player.DRUM5], Player.CONTROLS[i][Player.DRUM5A], Player.CONTROLS[i][Player.START]])
self.no.extend([Player.CONTROLS[i][Player.DRUM1], Player.CONTROLS[i][Player.DRUM1A], Player.CONTROLS[i][Player.CANCEL]])
self.conf.extend([Player.CONTROLS[i][Player.DRUMBASS], Player.CONTROLS[i][Player.DRUMBASSA]])
self.up.extend([Player.CONTROLS[i][Player.DRUM2], Player.CONTROLS[i][Player.DRUM2A], Player.CONTROLS[i][Player.UP]])
self.down.extend([Player.CONTROLS[i][Player.DRUM3], Player.CONTROLS[i][Player.DRUM3A], Player.CONTROLS[i][Player.DOWN]])
self.yes.extend([Player.CONTROLS[i][Player.DRUM5], Player.CONTROLS[i][Player.DRUM5A], Player.CONTROLS[i][Player.START]])
self.no.extend([Player.CONTROLS[i][Player.DRUM1], Player.CONTROLS[i][Player.DRUM1A], Player.CONTROLS[i][Player.CANCEL]])
self.conf.extend([Player.CONTROLS[i][Player.DRUMBASS], Player.CONTROLS[i][Player.DRUMBASSA]])
self.up.extend([Player.CONTROLS[i][Player.DRUM2], Player.CONTROLS[i][Player.DRUM2A], Player.CONTROLS[i][Player.UP]])
self.down.extend([Player.CONTROLS[i][Player.DRUM3], Player.CONTROLS[i][Player.DRUM3A], Player.CONTROLS[i][Player.DOWN]])
elif type in MICTYPES:
if not self.engine.world.allowMic:
self.allowed[i] = False
else:
self.yes.extend([Player.CONTROLS[i][Player.START]])
self.no.extend([Player.CONTROLS[i][Player.CANCEL]])
self.up.extend([Player.CONTROLS[i][Player.UP]])
self.down.extend([Player.CONTROLS[i][Player.DOWN]])
self.yes.extend([Player.CONTROLS[i][Player.START]])
self.no.extend([Player.CONTROLS[i][Player.CANCEL]])
self.up.extend([Player.CONTROLS[i][Player.UP]])
self.down.extend([Player.CONTROLS[i][Player.DOWN]])

for i, control in enumerate(self.engine.input.controls.controls):
if control == "None":
Expand Down
42 changes: 19 additions & 23 deletions src/MainMenu.py
Expand Up @@ -37,6 +37,7 @@
from Shader import shaders
import sys
import os
from constants import *

#myfingershurt: needed for random menu music:
import random
Expand All @@ -62,27 +63,27 @@ def __init__(self, engine):
self.gfxVersionTag = Config.get("game", "gfx_version_tag")

self.chosenNeck = Config.get("game", "default_neck")
exists = 0
exists = False

if engine.loadImgDrawing(self, "ok", os.path.join("necks",self.chosenNeck+".png")):
exists = 1
exists = True
elif engine.loadImgDrawing(self, "ok", os.path.join("necks","Neck_"+self.chosenNeck+".png")):
exists = 1
exists = True

#MFH - fallback logic now supports a couple valid default neck filenames
#MFH - check for Neck_1
if exists == 0:
if not exists:
if engine.loadImgDrawing(self, "ok", os.path.join("necks","Neck_1.png")):
Config.set("game", "default_neck", "1")
Log.warn("Default chosen neck not valid; fallback Neck_1.png forced.")
exists = 1
exists = True

#MFH - check for defaultneck
if exists == 0:
if not exists:
if engine.loadImgDrawing(self, "ok", os.path.join("necks","defaultneck.png")):
Log.warn("Default chosen neck not valid; fallback defaultneck.png forced.")
Config.set("game", "default_neck", "defaultneck")
exists = 1
exists = True
else:
Log.error("Default chosen neck not valid; fallbacks Neck_1.png and defaultneck.png also not valid!")

Expand All @@ -92,8 +93,6 @@ def __init__(self, engine):
self.themename = self.engine.data.themeLabel
self.useSoloMenu = self.engine.theme.use_solo_submenu

allowMic = True

self.menux = self.engine.theme.menuPos[0]
self.menuy = self.engine.theme.menuPos[1]

Expand Down Expand Up @@ -146,7 +145,7 @@ def __init__(self, engine):

trainingMenu = [
(_("Tutorials"), self.showTutorial),
(_("Practice"), lambda: self.newLocalGame(mode1p = 1)),
(_("Practice"), lambda: self.newLocalGame(mode = PRACTICE)),
]

self.opt_bkg_size = [float(i) for i in self.engine.theme.opt_bkg_size]
Expand All @@ -160,20 +159,17 @@ def __init__(self, engine):
strQuit = ""

multPlayerMenu = [
(_("Face-Off"), lambda: self.newLocalGame(players = 2, maxplayers = 4)),
(_("Pro Face-Off"), lambda: self.newLocalGame(players = 2, mode2p = 1, maxplayers = 4)),
(_("Party Mode"), lambda: self.newLocalGame( mode2p = 2)),
(_("FoFiX Co-Op"), lambda: self.newLocalGame(players = 2, mode2p = 3, maxplayers = 4, allowMic = allowMic)),
(_("RB Co-Op"), lambda: self.newLocalGame(players = 2, mode2p = 4, maxplayers = 4, allowMic = allowMic)),
(_("GH Co-Op"), lambda: self.newLocalGame(players = 2, mode2p = 5, maxplayers = 4)),
(_("GH Battle"), lambda: self.newLocalGame(players = 2, mode2p = 6, allowDrum = False)), #akedrou- so you can block drums
(_("Face-Off"), lambda: self.newLocalGame(multiplayer = FACEOFF)),
(_("Pro Face-Off"), lambda: self.newLocalGame(multiplayer = SKILL)),
(_("Co-Op"), lambda: self.newLocalGame(multiplayer = COOP)),
(_("Co-Op Tour"), lambda: self.newLocalGame(mode = TOUR, multiplayer = COOP))
]

if not self.useSoloMenu:

mainMenu = [
(strCareer, lambda: self.newLocalGame(mode1p = 2, allowMic = allowMic)),
(strQuickplay, lambda: self.newLocalGame(allowMic = allowMic)),
(strCareer, lambda: self.newLocalGame(mode = TOUR)),
(strQuickplay, lambda: self.newLocalGame()),
((strMultiplayer,"multiplayer"), multPlayerMenu),
((strTraining,"training"), trainingMenu),
((strSettings,"settings"), self.settingsMenu),
Expand All @@ -183,8 +179,8 @@ def __init__(self, engine):
else:

soloMenu = [
(_("Solo Tour"), lambda: self.newLocalGame(mode1p = 2, allowMic = allowMic)),
(_("Quickplay"), lambda: self.newLocalGame(allowMic = allowMic)),
(_("Solo Tour"), lambda: self.newLocalGame(mode = TOUR)),
(_("Quickplay"), lambda: self.newLocalGame()),
]

mainMenu = [
Expand Down Expand Up @@ -297,9 +293,9 @@ def showTutorial(self):
def newSinglePlayerGame(self):
self.newLocalGame() #just call start function with default settings = 1p quickplay

def newLocalGame(self, players=1, mode1p=0, mode2p=0, maxplayers = None, allowGuitar = True, allowDrum = True, allowMic = False): #mode1p=0(quickplay),1(practice),2(career) / mode2p=0(faceoff),1(profaceoff)
def newLocalGame(self, mode = QUICKPLAY, multiplayer = None):
self.engine.data.acceptSound.play()
self.engine.startWorld(players, maxplayers, mode1p, mode2p, allowGuitar, allowDrum, allowMic)
self.engine.startWorld(mode, multiplayer)
self.launchLayer(lambda: Lobby(self.engine))

def restartGame(self):
Expand Down
9 changes: 5 additions & 4 deletions src/Song.py
Expand Up @@ -41,6 +41,7 @@
import time
from Language import _
import VFS
from constants import *

DEFAULT_BPM = 120.0
DEFAULT_LIBRARY = "songs"
Expand Down Expand Up @@ -3797,8 +3798,8 @@ def getAvailableSongs(engine, library = DEFAULT_LIBRARY, includeTutorials = Fals
includeTutorials = True

#MFH - Career Mode determination:
gameMode1p = engine.world.gameMode
if gameMode1p == 2:
gameMode1p = engine.world.mode
if gameMode1p == TOUR:
careerMode = True
else:
careerMode = False
Expand Down Expand Up @@ -3959,7 +3960,7 @@ def getSortingTitles(engine, songList = []):


def getAvailableTitles(engine, library = DEFAULT_LIBRARY):
gameMode1p = engine.world.gameMode
gameMode1p = engine.world.mode
if library == None:
return []

Expand Down Expand Up @@ -3992,7 +3993,7 @@ def getAvailableSongsAndTitles(engine, library = DEFAULT_LIBRARY, includeTutoria
return []

#MFH - Career Mode determination:
careerMode = (engine.world.gameMode == 2)
careerMode = (engine.world.mode == TOUR)
career = False
quickPlayCareerTiers = engine.config.get("game", "quickplay_tiers")

Expand Down
10 changes: 4 additions & 6 deletions src/SongChoosingScene.py
Expand Up @@ -41,9 +41,7 @@
from Texture import Texture

import Log #MFH

PRACTICE = 1
CAREER = 2
from constants import *

instrumentDiff = {
0 : (lambda a: a.diffGuitar),
Expand Down Expand Up @@ -76,10 +74,10 @@ def __init__(self, engine, libraryName = None, songName = None):
self.libraryName = Song.DEFAULT_LIBRARY
if not self.songName:
self.songName = self.engine.config.get("setlist", "selected_song")
self.gameMode = self.engine.world.gameMode
self.careerMode = (self.gameMode == CAREER)
self.gameMode = self.engine.world.mode
self.careerMode = (self.gameMode == TOUR)
self.practiceMode = (self.gameMode == PRACTICE)
self.gameMode2p = self.engine.world.multiMode
self.gameMode2p = self.engine.world.multiplayer
self.autoPreview = not self.engine.config.get("audio", "disable_preview")
self.sortOrder = self.engine.config.get("game", "sort_order")
self.tut = self.engine.world.tutorial
Expand Down
41 changes: 17 additions & 24 deletions src/World.py
Expand Up @@ -26,20 +26,18 @@
import Dialogs
from Song import SongQueue
from Language import _
from constants import *

STARTUP_SCENE = "SongChoosingScene"

class World:
def __init__(self, engine, players, maxplayers = None, gameMode = 0, multiMode = 0, allowGuitar = True, allowDrum = True, allowMic = False, tutorial = False):
def __init__(self, engine, mode = QUICKPLAY, multiplayer = False, tutorial = False):
self.engine = engine
self.players = []
self.minPlayers = players
self.maxPlayers = maxplayers or players
self.gameMode = gameMode #Quickplay, Practice, Career
self.multiMode = multiMode #Face-Off, Pro FO, Party, Co-Op, RB Co-Op, GH Co-Op, Battle
self.allowGuitar = allowGuitar
self.allowDrum = allowDrum
self.allowMic = allowMic
self.minPlayers = multiplayer and 2 or 1
self.maxPlayers = multiplayer and self.engine.config.get("performance", "max_players") or 1
self.mode = mode
self.multiplayer = multiplayer
self.tutorial = tutorial
self.scene = None
self.sceneName = ""
Expand All @@ -49,27 +47,22 @@ def __init__(self, engine, players, maxplayers = None, gameMode = 0, multiMode =
self.setGameName()

def setGameName(self):
if self.minPlayers > 1:
if self.gameMode == 0:
if self.multiplayer:
if self.multiplayer == FACEOFF:
self.gameName = _("Face-Off")
elif self.gameMode == 1:
elif self.multiplayer == SKILL:
self.gameName = _("Pro Face-Off")
elif self.gameMode == 2:
self.gameName = _("Party Mode")
elif self.gameMode == 3:
self.gameName = _("FoFiX Co-Op Mode")
elif self.gameMode == 4:
self.gameName = _("RB Co-Op Mode")
elif self.gameMode == 5:
self.gameName = _("GH Co-Op Mode")
elif self.gameMode == 6:
self.gameName = _("Battle Mode")
elif self.multiplayer == COOP:
if self.mode == TOUR:
self.gameName = _("Co-Op Tour")
else:
self.gameName = _("Co-Op Mode")
else:
if self.gameMode == 0:
if self.mode == QUICKPLAY:
self.gameName = _("Quickplay")
elif self.gameMode == 1:
elif self.mode == PRACTICE:
self.gameName = _("Practice")
elif self.gameMode == 2:
elif self.mode == TOUR:
self.gameName = _("Career Mode")

def finishGame(self):
Expand Down
10 changes: 10 additions & 0 deletions src/constants.py
Expand Up @@ -27,3 +27,13 @@
TOP = 0
MIDDLE = 1
BOTTOM = 2

# Game modes
QUICKPLAY = 0
PRACTICE = 1
TOUR = 2

# Multiplayer modes
FACEOFF = 1
SKILL = 2
COOP = 3

0 comments on commit f7c21cb

Please sign in to comment.