Source

Fat x Fast / FatxFast / config.py

The branch 'advanced-physics' does not exist.
Full commit
# This file is part of FatxFast.
#
#    FatxFast 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 3 of the License, or
#    (at your option) any later version.
#
#    FatxFast 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 FatxFast.  If not, see <http://www.gnu.org/licenses/>.

# Versioning based on: 
# http://en.wikipedia.org/wiki/Versioning#Designating_development_stage
__author__ = "dryatu (c) 2013"
__version__ = "1.2.4"
import pygame
import random
from collections import OrderedDict

class Config(object):
    
    def __init__(self, *args, **kwargs): 
        self.hotkeys = OrderedDict()
        self.version = __version__
        self.hotkeys["player1-up"] = pygame.K_w
        self.hotkeys["player1-down"] = pygame.K_s
        self.hotkeys["player1-left"] = pygame.K_a
        self.hotkeys["player1-right"] = pygame.K_d
        self.hotkeys["player1-turbo"] = pygame.K_LSHIFT
        self.hotkeys["player2-up"] = pygame.K_UP
        self.hotkeys["player2-down"] = pygame.K_DOWN
        self.hotkeys["player2-left"] = pygame.K_LEFT
        self.hotkeys["player2-right"] = pygame.K_RIGHT
        self.hotkeys["player2-turbo"] = pygame.K_RSHIFT
        self.hotkeys["map-zoom-in"] = pygame.K_PLUS
        self.hotkeys["map-zoom-out"] = pygame.K_MINUS
        self.hotkeys["player1-map"] = pygame.K_z
        self.hotkeys["player2-map"] = pygame.K_m
        #self.hotkeys["solve"] = pygame.K_o
        self.mapstyle = "auto"
        self.fullscreen = False
        self.music = True
        self.volume = 0.5
        self.games_played = 0

    def change_mapstyle(self):
        if self.mapstyle == "auto":
            self.mapstyle = "manual"
        else:
            self.mapstyle ="auto"

    def change_hotkey(self, action, key):
        self.hotkeys[action] = key
        
    def change_setting(self, setting, value):
        setattr(self, setting, value)
        
    def change_fullscreen(self):
        self.fullscreen = not self.fullscreen

    def change_music(self):
        self.music = not self.music

    def change_volume(self):
        if self.volume < 0.9:
            self.volume += 0.1
        else:
            self.volume = 0

    def get_hotkey_string(self, hotkey):
        return pygame.key.name(self.hotkeys[hotkey])