Ejemplo n.º 1
0
def BU(A, B, P):  #radix-2 butterfly unit
    tmp_ay = np.zeros((1, 2), dtype=int)  #tmp_array
    tmp_a = Mod.AddMod(A, B, P)
    tmp_b = Mod.SubMod(A, B, P)
    tmp_ay[0][0] = tmp_a  #a+b
    tmp_ay[0][1] = tmp_b  #a-b
    return tmp_ay
Ejemplo n.º 2
0
def main1():

    img = cv2.imread('2.jpg', cv2.COLOR_BGR2GRAY)
    height, width = img.shape[:2]
    # resized = cv2.resize(img, (3*width,3*height), interpolation=cv2.INTER_CUBIC)
    #二值化
    (_, thresh) = cv2.threshold(img, 150, 255, cv2.THRESH_BINARY)
    #cv2.imshow('thresh', thresh)
    #扩大黑色面积,使效果更明显
    kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (10, 10))  #形态学处理,定义矩形结构
    closed = cv2.erode(thresh, None, iterations=5)
    # cv2.imshow('erode',closed)
    height, width = closed.shape[:2]
    v = [0] * width
    z = [0] * height

    #水平投影
    #统计每一行的黑点数
    a = 0
    emptyImage1 = numpy.zeros((height, width, 3), numpy.uint8)
    for y in range(0, height):
        for x in range(0, width):
            if closed[y, x][0] == 0:
                a = a + 1
            else:
                continue
        z[y] = a
        a = 0
    l = len(z)
    #绘制水平投影图

    listY = []
    for y in range(0, height):
        for x in range(0, z[y]):
            listY.append(y)

    listY = mod.Duplicate_removal(listY)
    listY = mod.continuity(listY)
    listY = mod.lxyz(listY, 75)

    cropImg = img[0:45, 1080:87]

    listXY = []

    for i in listY:
        # 画一个绿色边框的矩形,参数2:左上角坐标,参数3:右下角坐标
        cv2.rectangle(img, (0, int(i.split('-')[0])),
                      (width, int(i.split('-')[1])), (0, 255, 0), 3)
        listXY.append([(0, int(i.split('-')[0])),
                       (width, int(i.split('-')[1]))])

    cv2.namedWindow('shuipin', cv2.WINDOW_NORMAL)
    cv2.imshow('shuipin', img)
    cv2.waitKey(0)
    return listXY
Ejemplo n.º 3
0
def NTT(x,ROU,prime,n,inverse): #output is a numpy array
    IN = Mod.InvMod(n,prime)    # calculate inverse multiplication of n
    x = x % prime
    y_list = []
    for i in range(n):
        acm = 0                             #accumlation 
        for j in range(n):
            exp = Mod.MulMod(i,j,n)          #calculates power of i*j
            tmp = Mod.ExpMod(ROU,exp,prime)  #calculates w^(i*j)
            tmp = Mod.MulMod(x[j],tmp,prime) #calculate x[j]w^(ij)
            acm = Mod.AddMod(acm,tmp,prime)  
        y_list.append(acm)
    y = np.array(y_list)
    if(inverse == 1):
        y = y * IN
        y = y % prime
    return y
Ejemplo n.º 4
0
def PROU(ROU,n,Prime):
    f = open('ROU_table.txt','w')
    if((n%2) == 0):
        for i in range(n):
            tmp = Mod.ExpMod(ROU,i,Prime)
            print(i,"-th: ",tmp)
            ch = str(tmp)
            f.write(ch)
            f.write("\n")
            if tmp == 1 and i != 0:
                print("it is not primitive root of unity")
    else:
        for i in range(n):
            tmp = Mod.ExpMod(ROU,i,Prime)
            ch = str(tmp)
            f.write(ch)
            f.write("\n")
            if tmp==1 and i != 0:
                print("it is not primitve root of unity")
    return 0
Ejemplo n.º 5
0
    def __init__(self, world, modname, mapname):
        """Load the objects from the map"""

        #store instance variables
        self.world = world

        #Load from the XML file holding the entities
        filename = Mod.MapPath(modname, mapname) + "objects.mb2"
        self.ents = EntLoader.LoadEntsFromFile(filename, world,
                                               self.world.isServer)

        self.staticMeshScene = StaticMeshScene(self.ents)
        self.dynamicEnts = [x for x in self.ents if not x.isStatic]
Ejemplo n.º 6
0
 def readData(self):
     """Read mechanisms and parameters for this cell from its configuration file"""
     ini_path = Islet.env['config'] + 'Values/Islet_' + Islet.env[
         'id'] + '/' + self.type.lower() + '_' + str(self.id) + '.ini'
     config_path = Islet.env['config'] + '/Mechanisms/Islet_' + Islet.env[
         'id'] + '/' + self.type.lower() + '_' + str(self.id) + '.ini'
     print(
         str(datetime.datetime.now()) +
         '\tCells.readData Reading from configuration: configuration file',
         config_path)
     # read mechanism configuration
     config = configparser.ConfigParser(allow_no_value=True)
     config.optionxform = str
     config.read(config_path)
     types = {'A': 'Alpha', 'B': 'Beta', 'D': 'Delta'}
     print(str(datetime.datetime.now()) + '\tself type', self.type)
     for i in config[types[self.type]]:
         print(
             str(datetime.datetime.now()) +
             '\tCells.readData Writing "INITIAL" blocks of appropriate mod files for mechanisms: mechanism',
             i, 'cell type', self.type, types[self.type])
         if re.split('[0-9]',
                     i)[0] not in ['Glucagon', 'Somatostatin', 'Insulin']:
             self.mechs.append(i)
         # add pointers in config files to self.pointers
         if config[types[self.type]][i] is not None:
             self.pointers[i] = ast.literal_eval(
                 config[types[self.type]][i])
         # only write mod files when those mod files will be compiled
         if self.compile:
             print(
                 str(datetime.datetime.now()) +
                 '\tCells.readData Write mod file: cell', self.cell)
             modname = re.split('1|2|3|4|5|6|7|8|9|0', i)[0]
             mod_path = Islet.env['wd'] + types[
                 self.type] + '_' + modname + '.mod'
             Mod.writeMod(ini_path, mod_path)
Ejemplo n.º 7
0
def FFT(Array, P, root, N, inverse):  #radix-2 FFT
    # If inverse = 1, doing IFFT.
    # automatically compute inverse ROU.
    # root : foward root of unity
    # N : array length
    # P :Prime
    S = math.ceil(math.log2(N))  #Stage
    bias = N
    A_t = np.zeros((1, bias), dtype=int)

    #if inverse = 1,compute inverse ROU
    if (inverse == 1):
        root = Mod.InvMod(root, P)

    # DIT
    for i in range(S):
        nc = N // bias  #number of class
        ne = bias  #number of elements (in a class)
        A_t = np.reshape(A_t, (nc, ne))  # reshape array
        bias = bias >> 1  # each stage right shift one bit

        for j in range(nc):
            for jj in range(ne):
                index_tmp = j * ne + jj
                A_t[j][jj] = Array[0][index_tmp]

        if (i == 0):
            factor = root
        else:
            factor = Mod.MulMod(factor, factor, P)

        for s in range(nc):
            for ss in range(ne // 2):
                tmp = BU(A_t[s][ss], A_t[s][ss + bias], P)
                factor_t = Mod.ExpMod(factor, ss, P)
                A_t[s][ss] = tmp[0][0]
                A_t[s][ss + bias] = tmp[0][1]
                A_t[s][ss + bias] = Mod.MulMod(A_t[s][ss + bias], factor_t, P)

        for x in range(nc):
            for y in range(ne):
                Array[0][x * ne + y] = A_t[x][y]

    #data relocation
    #bitreverse
    for i in range(N):
        p_tmp = i
        exchange_position = 0
        for ls in range(S):
            bit = p_tmp % 2
            bit_weight = 1 << ((S - 1) - ls)
            if (bit == 1):
                exchange_position = exchange_position + bit_weight
            else:
                exchange_position = exchange_position
            p_tmp = p_tmp >> 1

        if (exchange_position > i):
            tmp = Array[0][i]
            Array[0][i] = Array[0][exchange_position]
            Array[0][exchange_position] = tmp

    #inverse FFT need to multiply each element by 1/n
    if (inverse == 1):
        IN = Mod.InvMod(N, P)
        Array = Array * IN
        Array = Array % P
    return Array
Ejemplo n.º 8
0
 def __init__(self, modname, mapname ):
     """Initialize the project description"""
     filename = Mod.MapPath( modname, mapname ) + "project.xml"
     tree = ET.parse( filename )
     root = tree.getroot()
     self._parseLevel( root )
Ejemplo n.º 9
0
    def __init__(self, engine):
        self.engine = engine
        applyItem = [(_("Apply New Settings"), self.applySettings)]

        modSettings = [
            ConfigChoice(engine.config, "mods", "mod_" + m)
            for m in Mod.getAvailableMods(engine)
        ] + applyItem

        gameSettings = [
            (_("Mod settings"), modSettings),
            ConfigChoice(engine.config, "game", "language"),
            ConfigChoice(engine.config, "game", "leftymode", autoApply=True),
            ConfigChoice(engine.config, "game", "tapping", autoApply=True),
            ConfigChoice(engine.config, "game", "uploadscores",
                         autoApply=True),
            ConfigChoice(engine.config, "game", "compactlist", autoApply=True),
            ConfigChoice(engine.config, "game", "autopreview", autoApply=True),
            ConfigChoice(engine.config, "game", "artistsort", autoApply=True),
        ]
        gameSettingsMenu = Menu.Menu(engine, gameSettings + applyItem)

        keySettings = [
            (_("Test Keys"), lambda: Dialogs.testKeys(engine)),
            KeyConfigChoice(engine, engine.config, "player", "key_action1"),
            KeyConfigChoice(engine, engine.config, "player", "key_action2"),
            KeyConfigChoice(engine, engine.config, "player", "key_1"),
            KeyConfigChoice(engine, engine.config, "player", "key_2"),
            KeyConfigChoice(engine, engine.config, "player", "key_3"),
            KeyConfigChoice(engine, engine.config, "player", "key_4"),
            KeyConfigChoice(engine, engine.config, "player", "key_5"),
            KeyConfigChoice(engine, engine.config, "player", "key_left"),
            KeyConfigChoice(engine, engine.config, "player", "key_right"),
            KeyConfigChoice(engine, engine.config, "player", "key_up"),
            KeyConfigChoice(engine, engine.config, "player", "key_down"),
            KeyConfigChoice(engine, engine.config, "player", "key_cancel"),
        ]
        keySettingsMenu = Menu.Menu(engine, keySettings)

        modes = engine.video.getVideoModes()
        modes.reverse()
        Config.define("video",
                      "resolution",
                      str,
                      "640x480",
                      text=_("Video Resolution"),
                      options=["%dx%d" % (m[0], m[1]) for m in modes])
        videoSettings = [
            ConfigChoice(engine.config, "video", "resolution"),
            ConfigChoice(engine.config, "video", "fullscreen"),
            ConfigChoice(engine.config, "video", "fps"),
            ConfigChoice(engine.config, "video", "multisamples"),
            #ConfigChoice(engine.config, "opengl", "svgshaders"),    # shaders broken at the moment
            #ConfigChoice(engine.config, "opengl", "svgquality"),
            ConfigChoice(engine.config, "video", "fontscale"),
        ]
        videoSettingsMenu = Menu.Menu(engine, videoSettings + applyItem)

        volumeSettings = [
            VolumeConfigChoice(engine, engine.config, "audio", "guitarvol"),
            VolumeConfigChoice(engine, engine.config, "audio", "songvol"),
            VolumeConfigChoice(engine, engine.config, "audio", "rhythmvol"),
            VolumeConfigChoice(engine, engine.config, "audio", "screwupvol"),
        ]
        volumeSettingsMenu = Menu.Menu(engine, volumeSettings + applyItem)

        audioSettings = [
            (_("Volume Settings"), volumeSettingsMenu),
            ConfigChoice(engine.config, "audio", "delay"),
            ConfigChoice(engine.config, "audio", "frequency"),
            ConfigChoice(engine.config, "audio", "bits"),
            ConfigChoice(engine.config, "audio", "buffersize"),
        ]
        audioSettingsMenu = Menu.Menu(engine, audioSettings + applyItem)

        settings = [
            (_("Game Settings"), gameSettingsMenu),
            (_("Key Settings"), keySettingsMenu),
            (_("Video Settings"), videoSettingsMenu),
            (_("Audio Settings"), audioSettingsMenu),
        ]

        self.settingsToApply = settings + \
                               videoSettings + \
                               audioSettings + \
                               volumeSettings + \
                               gameSettings + \
                               modSettings

        Menu.Menu.__init__(self, engine, settings)
Ejemplo n.º 10
0
rom bl3hotfixmod import Mod, Balance
from bl3data import BL3Data

#Might do auto barrel and material stuff? otherwise fill out later

mod=Mod('randomizer_hyp.txt',
'Hyperion Weapon Randomizer',
'SSpyR',
[
    'One in the set of many randomizer classes.',
    'This one for Hyperion. The reason this is by manufacturer',
    'is due to wanting the ability to keep the weapons on save-quit.',
    'In order to meet that only guns of the same Type and Manufacturer can',
    'be randomized with each other. I might make a runtime randomizer of everything',
    'in the future but we are starting here for now.'
],
lic=Mod.CC_BY_SA_40,
)

data=BL3Data()

#SMGs

#List the Balances
smg_bal_name=[
    '/Game/Gear/Weapons/SMGs/Hyperion/_Shared/_Design/BalanceState/Balance_SM_HYP_01_Common',
    '/Game/Gear/Weapons/SMGs/Hyperion/_Shared/_Design/BalanceState/Balance_SM_HYP_02_UnCommon',
    '/Game/Gear/Weapons/SMGs/Hyperion/_Shared/_Design/BalanceState/Balance_SM_HYP_03_Rare',
    '/Game/Gear/Weapons/SMGs/Hyperion/_Shared/_Design/BalanceState/Balance_SM_HYP_04_VeryRare',
    '/Game/Gear/Weapons/SMGs/Hyperion/_Shared/_Design/_Unique/Bitch/Balance/Balance_SM_HYP_Bitch',
    '/Game/Gear/Weapons/SMGs/Hyperion/_Shared/_Design/_Unique/Crossroad/Balance/Balance_SM_HYP_Crossroad',
Ejemplo n.º 11
0
  def __init__(self, engine):
    self.engine = engine
    applyItem = [(_("Apply New Settings"), self.applySettings)]

    modSettings = [
      ConfigChoice(engine.config, "mods",  "mod_" + m) for m in Mod.getAvailableMods(engine)
    ] + applyItem

    gameSettings = [
      (_("Mod settings"), modSettings),
      ConfigChoice(engine.config, "game",  "language"),
      ConfigChoice(engine.config, "game",  "leftymode", autoApply = True),
      ConfigChoice(engine.config, "game",  "tapping", autoApply = True),
      ConfigChoice(engine.config, "game",  "uploadscores", autoApply = True),
      ConfigChoice(engine.config, "game",  "compactlist", autoApply = True),
      ConfigChoice(engine.config, "game",  "autopreview", autoApply = True),
      ConfigChoice(engine.config, "game",  "artistsort", autoApply = True),
    ]
    gameSettingsMenu = Menu.Menu(engine, gameSettings + applyItem)

    keySettings = [
      (_("Test Keys"), lambda: Dialogs.testKeys(engine)),
      KeyConfigChoice(engine, engine.config, "player", "key_action1"),
      KeyConfigChoice(engine, engine.config, "player", "key_action2"),
      KeyConfigChoice(engine, engine.config, "player", "key_1"),
      KeyConfigChoice(engine, engine.config, "player", "key_2"),
      KeyConfigChoice(engine, engine.config, "player", "key_3"),
      KeyConfigChoice(engine, engine.config, "player", "key_4"),
      KeyConfigChoice(engine, engine.config, "player", "key_5"),
      KeyConfigChoice(engine, engine.config, "player", "key_left"),
      KeyConfigChoice(engine, engine.config, "player", "key_right"),
      KeyConfigChoice(engine, engine.config, "player", "key_up"),
      KeyConfigChoice(engine, engine.config, "player", "key_down"),
      KeyConfigChoice(engine, engine.config, "player", "key_cancel"),
    ]
    keySettingsMenu = Menu.Menu(engine, keySettings)

    modes = engine.video.getVideoModes()
    modes.reverse()
    Config.define("video",  "resolution", str,   "640x480", text = _("Video Resolution"), options = ["%dx%d" % (m[0], m[1]) for m in modes])
    videoSettings = [
      ConfigChoice(engine.config, "video",  "resolution"),
      ConfigChoice(engine.config, "video",  "fullscreen"),
      ConfigChoice(engine.config, "video",  "fps"),
      ConfigChoice(engine.config, "video",  "multisamples"),
      #ConfigChoice(engine.config, "opengl", "svgshaders"),    # shaders broken at the moment
      #ConfigChoice(engine.config, "opengl", "svgquality"),
      ConfigChoice(engine.config, "video", "fontscale"),
    ]
    videoSettingsMenu = Menu.Menu(engine, videoSettings + applyItem)

    volumeSettings = [
      VolumeConfigChoice(engine, engine.config, "audio",  "guitarvol"),
      VolumeConfigChoice(engine, engine.config, "audio",  "songvol"),
      VolumeConfigChoice(engine, engine.config, "audio",  "rhythmvol"),
      VolumeConfigChoice(engine, engine.config, "audio",  "screwupvol"),
    ]
    volumeSettingsMenu = Menu.Menu(engine, volumeSettings + applyItem)

    audioSettings = [
      (_("Volume Settings"), volumeSettingsMenu),
      ConfigChoice(engine.config, "audio",  "delay"),
      ConfigChoice(engine.config, "audio",  "frequency"),
      ConfigChoice(engine.config, "audio",  "bits"),
      ConfigChoice(engine.config, "audio",  "buffersize"),
    ]
    audioSettingsMenu = Menu.Menu(engine, audioSettings + applyItem)

    settings = [
      (_("Game Settings"),     gameSettingsMenu),
      (_("Key Settings"),      keySettingsMenu),
      (_("Video Settings"),    videoSettingsMenu),
      (_("Audio Settings"),    audioSettingsMenu),
    ]

    self.settingsToApply = settings + \
                           videoSettings + \
                           audioSettings + \
                           volumeSettings + \
                           gameSettings + \
                           modSettings

    Menu.Menu.__init__(self, engine, settings)
Ejemplo n.º 12
0
  def __init__(self, engine):
    Log.debug("SettingsMenu class init (Settings.py)...")
    
    self.engine = engine
    
    applyItem = [(_("Apply New Settings"), self.applySettings)]

    modSettings = [
      ConfigChoice(engine.config, "mods",  "mod_" + m) for m in Mod.getAvailableMods(engine)
    ] + applyItem
    
    gameSettings = [
      ConfigChoice(engine.config, "game",  "language"),
      ("Reset to English", self.resetLanguageToEnglish),
      ConfigChoice(engine.config, "game",  "uploadscores", autoApply = True),
      ConfigChoice(engine.config, "game", "party_time", autoApply = True),
      ConfigChoice(engine.config, "game", "lyric_mode", autoApply = True),      #myfingershurt
      ConfigChoice(engine.config, "game", "script_lyric_pos", autoApply = True),      #myfingershurt
      ConfigChoice(engine.config, "game", "rb_midi_lyrics", autoApply = True),      #myfingershurt
      ConfigChoice(engine.config, "game", "rb_midi_sections", autoApply = True),      #myfingershurt
      ConfigChoice(engine.config, "coffee", "failingEnabled", autoApply = True),
      ConfigChoice(engine.config, "game", "star_scoring", autoApply = True),#myfingershurt
      ConfigChoice(engine.config, "game", "congrats", autoApply = True),#blazingamer
      ConfigChoice(engine.config, "game", "jurgdef", autoApply = True),#Spikehead777
      ConfigChoice(engine.config, "game", "jurgtype", autoApply = True),#Spikehead777
      ConfigChoice(engine.config, "game", "jurglogic", autoApply = True),#MFH
      ConfigChoice(engine.config, "game", "bass_groove_enable", autoApply = True),#myfingershurt
      ConfigChoice(engine.config, "game", "lphrases", autoApply = True),#blazingamer
      ConfigChoice(engine.config, "game", "whammy_saves_starpower", autoApply = True),#myfingershurt
    ]
    gameSettingsMenu = Menu.Menu(engine, gameSettings + applyItem)

    drumKeySettings = [
      (_("Test Keys"), lambda: Dialogs.testDrums(engine)),
      ConfigChoice(engine.config, "game", "auto_drum_sp", autoApply = True),#myfingershurt
      KeyConfigChoice(engine, engine.config, "player0", "key_bass"),
      KeyConfigChoice(engine, engine.config, "player0", "key_drum1a"),
      KeyConfigChoice(engine, engine.config, "player0", "key_drum1b"),
      KeyConfigChoice(engine, engine.config, "player0", "key_drum2a"),
      KeyConfigChoice(engine, engine.config, "player0", "key_drum2b"),
      KeyConfigChoice(engine, engine.config, "player0", "key_drum3a"),
      KeyConfigChoice(engine, engine.config, "player0", "key_drum3b"),
      KeyConfigChoice(engine, engine.config, "player0", "key_drum4a"),
      KeyConfigChoice(engine, engine.config, "player0", "key_drum4b"),
      KeyConfigChoice(engine, engine.config, "player1", "player_2_key_bass"),
      KeyConfigChoice(engine, engine.config, "player1", "player_2_key_drum1a"),
      KeyConfigChoice(engine, engine.config, "player1", "player_2_key_drum1b"),
      KeyConfigChoice(engine, engine.config, "player1", "player_2_key_drum2a"),
      KeyConfigChoice(engine, engine.config, "player1", "player_2_key_drum2b"),
      KeyConfigChoice(engine, engine.config, "player1", "player_2_key_drum3a"),
      KeyConfigChoice(engine, engine.config, "player1", "player_2_key_drum3b"),
      KeyConfigChoice(engine, engine.config, "player1", "player_2_key_drum4a"),
      KeyConfigChoice(engine, engine.config, "player1", "player_2_key_drum4b"),
    ]       
    drumKeySettingsMenu = Menu.Menu(engine, drumKeySettings)


    player0Keys = [
      KeyConfigChoice(engine, engine.config, "player0", "key_action1"),
      KeyConfigChoice(engine, engine.config, "player0", "key_action2"),
      KeyConfigChoice(engine, engine.config, "player0", "key_1"),
      KeyConfigChoice(engine, engine.config, "player0", "key_2"),
      KeyConfigChoice(engine, engine.config, "player0", "key_3"),
      KeyConfigChoice(engine, engine.config, "player0", "key_4"),
      KeyConfigChoice(engine, engine.config, "player0", "key_5"),
      KeyConfigChoice(engine, engine.config, "player0", "key_left"),
      KeyConfigChoice(engine, engine.config, "player0", "key_right"),
      KeyConfigChoice(engine, engine.config, "player0", "key_up"),
      KeyConfigChoice(engine, engine.config, "player0", "key_down"),
      KeyConfigChoice(engine, engine.config, "player0", "key_cancel"),
      KeyConfigChoice(engine, engine.config, "player0", "key_star"),
      KeyConfigChoice(engine, engine.config, "player0", "key_kill"),
    ]
    player0KeyMenu = Menu.Menu(engine, player0Keys)

    player0AltKeys = [
      KeyConfigChoice(engine, engine.config, "player0", "akey_action1"),
      KeyConfigChoice(engine, engine.config, "player0", "akey_action2"),
      KeyConfigChoice(engine, engine.config, "player0", "akey_1"),
      KeyConfigChoice(engine, engine.config, "player0", "akey_2"),
      KeyConfigChoice(engine, engine.config, "player0", "akey_3"),
      KeyConfigChoice(engine, engine.config, "player0", "akey_4"),
      KeyConfigChoice(engine, engine.config, "player0", "akey_5"),
      KeyConfigChoice(engine, engine.config, "player0", "akey_left"),
      KeyConfigChoice(engine, engine.config, "player0", "akey_right"),
      KeyConfigChoice(engine, engine.config, "player0", "akey_up"),
      KeyConfigChoice(engine, engine.config, "player0", "akey_down"),
      KeyConfigChoice(engine, engine.config, "player0", "akey_cancel"),
      KeyConfigChoice(engine, engine.config, "player0", "akey_star"),
      KeyConfigChoice(engine, engine.config, "player0", "akey_kill"),
    ]
    player0AltKeyMenu = Menu.Menu(engine, player0AltKeys)

    player1Keys = [
      KeyConfigChoice(engine, engine.config, "player1", "player_2_key_action1"),
      KeyConfigChoice(engine, engine.config, "player1", "player_2_key_action2"),
      KeyConfigChoice(engine, engine.config, "player1", "player_2_key_1"),
      KeyConfigChoice(engine, engine.config, "player1", "player_2_key_2"),
      KeyConfigChoice(engine, engine.config, "player1", "player_2_key_3"),
      KeyConfigChoice(engine, engine.config, "player1", "player_2_key_4"),
      KeyConfigChoice(engine, engine.config, "player1", "player_2_key_5"),
      KeyConfigChoice(engine, engine.config, "player1", "player_2_key_left"),
      KeyConfigChoice(engine, engine.config, "player1", "player_2_key_right"),
      KeyConfigChoice(engine, engine.config, "player1", "player_2_key_up"),
      KeyConfigChoice(engine, engine.config, "player1", "player_2_key_down"),
      KeyConfigChoice(engine, engine.config, "player1", "player_2_key_cancel"),
      KeyConfigChoice(engine, engine.config, "player1", "player_2_key_star"),#added by ShiekOdaSandz
      KeyConfigChoice(engine, engine.config, "player1", "player_2_key_kill"),#added by ShiekOdaSandz
    ]
    player1KeyMenu = Menu.Menu(engine, player1Keys)

    player1AltKeys = [
      KeyConfigChoice(engine, engine.config, "player1", "aplayer_2_key_action1"),
      KeyConfigChoice(engine, engine.config, "player1", "aplayer_2_key_action2"),
      KeyConfigChoice(engine, engine.config, "player1", "aplayer_2_key_1"),
      KeyConfigChoice(engine, engine.config, "player1", "aplayer_2_key_2"),
      KeyConfigChoice(engine, engine.config, "player1", "aplayer_2_key_3"),
      KeyConfigChoice(engine, engine.config, "player1", "aplayer_2_key_4"),
      KeyConfigChoice(engine, engine.config, "player1", "aplayer_2_key_5"),
      KeyConfigChoice(engine, engine.config, "player1", "aplayer_2_key_left"),
      KeyConfigChoice(engine, engine.config, "player1", "aplayer_2_key_right"),
      KeyConfigChoice(engine, engine.config, "player1", "aplayer_2_key_up"),
      KeyConfigChoice(engine, engine.config, "player1", "aplayer_2_key_down"),
      KeyConfigChoice(engine, engine.config, "player1", "aplayer_2_key_cancel"),
      KeyConfigChoice(engine, engine.config, "player1", "aplayer_2_key_star"),#added by ShiekOdaSandz
      KeyConfigChoice(engine, engine.config, "player1", "aplayer_2_key_kill"),#added by ShiekOdaSandz
    ]
    player1AltKeyMenu = Menu.Menu(engine, player1AltKeys)

    keySettings = [
      ConfigChoice(engine.config, "game", "key_checker_mode", autoApply = True),#myfingershurt
      (_("Drum keys" ),            drumKeySettingsMenu),
      ConfigChoice(engine.config, "game", "alt_keys", autoApply = True),
      (_("Player 1 Keys"), player0KeyMenu),
      (_("Player 2 Keys"), player1KeyMenu),
      (_("Player 1 Alt. Keys"), player0AltKeyMenu),
      (_("Player 2 Alt. Keys"), player1AltKeyMenu),
      (_("Test Keys"), lambda: Dialogs.testKeys(engine)),
      ConfigChoice(engine.config, "game", "analog_killsw_mode", autoApply = True),#myfingershurt
      ConfigChoice(engine.config, "player0",  "two_chord_max", autoApply = True),
      ConfigChoice(engine.config, "player0",  "leftymode", autoApply = True),
      ConfigChoice(engine.config, "game", "analog_killsw_mode_p2", autoApply = True),#myfingershurt
      ConfigChoice(engine.config, "player1",  "two_chord_max", autoApply = True), #QQstarS
      ConfigChoice(engine.config, "player1",  "leftymode", autoApply = True), #QQstarS
      ConfigChoice(engine.config, "game", "drum_navigation", autoApply = True),#myfingershurt
      ConfigChoice(engine.config, "game", "p2_menu_nav", autoApply = True),#myfingershurt
    ]
    keySettingsMenu = Menu.Menu(engine, keySettings + applyItem)
    
    modes = engine.video.getVideoModes()
    modes.reverse()
    Config.define("video",  "resolution", str,   "1024x768", text = _("Video Resolution"), options = ["%dx%d" % (m[0], m[1]) for m in modes])
    videoSettings = [
      ConfigChoice(engine.config, "video",  "resolution"),
      ConfigChoice(engine.config, "video",  "fullscreen"),
      ConfigChoice(engine.config, "video",  "fps"),
      ConfigChoice(engine.config, "video",  "multisamples"),
      ConfigChoice(engine.config, "video", "disable_fretsfx"),
      ConfigChoice(engine.config, "game", "game_time", autoApply = True),      
      ConfigChoice(engine.config, "game", "accuracy_mode", autoApply = True),
      ConfigChoice(engine.config, "game", "accuracy_pos", autoApply = True),
      ConfigChoice(engine.config, "game", "gsolo_accuracy_disp", autoApply = True), #MFH
      ConfigChoice(engine.config, "game", "gsolo_acc_pos", autoApply = True), #MFH
      ConfigChoice(engine.config, "game", "decimal_places", autoApply = True), #MFH
      ConfigChoice(engine.config, "video", "hitglow_color"),
      ConfigChoice(engine.config, "opengl", "svgquality"),
      ConfigChoice(engine.config, "game", "gfx_version_tag", autoApply = True), #MFH
      ConfigChoice(engine.config, "coffee", "noterotate", autoApply = True), #blazingamer
    ]
    videoSettingsMenu = Menu.Menu(engine, videoSettings + applyItem)

    fretSettings = [
      ConfigChoice(engine.config, "coffee", "phrases", autoApply = True),
      ConfigChoice(engine.config, "game", "notedisappear", autoApply = True),
      ConfigChoice(engine.config, "game", "frets_under_notes", autoApply = True), #MFH
      ConfigChoice(engine.config, "game", "pov", autoApply = True),
      ConfigChoice(engine.config, "game", "ignore_open_strums", autoApply = True),      #myfingershurt
      ConfigChoice(engine.config, "game", "hopo_indicator", autoApply = True),      #myfingershurt
      ConfigChoice(engine.config, "game", "hopo_style", autoApply = True),      #myfingershurt
      ConfigChoice(engine.config, "coffee", "moreHopo", autoApply = True),
      ConfigChoice(engine.config, "game", "hopo_after_chord", autoApply = True),      #myfingershurt
      ConfigChoice(engine.config, "game", "nstype", autoApply = True),      #blazingamer
      ConfigChoice(engine.config, "coffee", "neckSpeed", autoApply = True),
      ConfigChoice(engine.config, "game",   "hit_window", autoApply = True), #alarian: defines hit window
      ConfigChoice(engine.config, "game", "large_drum_neck", autoApply = True),      #myfingershurt
      ConfigChoice(engine.config, "game", "bass_groove_neck", autoApply = True),      #myfingershurt
      ConfigChoice(engine.config, "game", "guitar_solo_neck", autoApply = True),      #myfingershurt
      ConfigChoice(engine.config, "game", "in_game_font_shadowing", autoApply = True),      #myfingershurt
    ]
    fretSettingsMenu = Menu.Menu(engine, fretSettings + applyItem)
    
    volumeSettings = [
      VolumeConfigChoice(engine, engine.config, "audio",  "guitarvol", autoApply = True),
      VolumeConfigChoice(engine, engine.config, "audio",  "songvol", autoApply = True),
      VolumeConfigChoice(engine, engine.config, "audio",  "rhythmvol", autoApply = True),
      VolumeConfigChoice(engine, engine.config, "audio",  "screwupvol", autoApply = True),
      VolumeConfigChoice(engine, engine.config, "audio",  "miss_volume", autoApply = True),
      VolumeConfigChoice(engine, engine.config, "audio",  "kill_volume", autoApply = True), #MFH
      VolumeConfigChoice(engine, engine.config, "audio",  "SFX_volume", autoApply = True), #MFH
    ]
    volumeSettingsMenu = Menu.Menu(engine, volumeSettings)

    audioSettings = [
      (_("Volume Settings"),    volumeSettingsMenu),
      ConfigChoice(engine.config, "audio",  "delay", autoApply = True),     #myfingershurt: so a/v delay can be set without restarting FoF
      ConfigChoice(engine.config, "audio",  "frequency"),
      ConfigChoice(engine.config, "audio",  "bits"),
      ConfigChoice(engine.config, "audio",  "buffersize"),
      ConfigChoice(engine.config, "game", "mute_sustain_releases", autoApply = True),   #myfingershurt
      ConfigChoice(engine.config, "game", "bass_kick_sound", autoApply = True),   #myfingershurt
      ConfigChoice(engine.config, "game", "T_sound", autoApply = True), #Faaa Drum sound
      ConfigChoice(engine.config, "audio", "mute_last_second", autoApply = True), #MFH
      ConfigChoice(engine.config, "game", "result_cheer_loop", autoApply = True), #MFH
      ConfigChoice(engine.config, "game", "cheer_loop_delay", autoApply = True), #MFH
      ConfigChoice(engine.config, "game", "star_claps", autoApply = True),      #myfingershurt
      ConfigChoice(engine.config, "game", "beat_claps", autoApply = True), #racer
    ]
    audioSettingsMenu = Menu.Menu(engine, audioSettings + applyItem)

    perfSettings = [
      ConfigChoice(engine.config, "performance", "game_priority", autoApply = True),
      ConfigChoice(engine.config, "performance", "disable_libcount", autoApply = True),
      ConfigChoice(engine.config, "performance", "disable_librotation", autoApply = True),
      ConfigChoice(engine.config, "performance", "starspin"),
      ConfigChoice(engine.config, "performance", "static_strings", autoApply = True),      #myfingershurt
      ConfigChoice(engine.config, "performance", "killfx", autoApply = True),   #blazingamer
      ConfigChoice(engine.config, "performance", "star_score_updates", autoApply = True),   #MFH
      ConfigChoice(engine.config, "performance", "in_game_stats", autoApply = True),#myfingershurt
      ConfigChoice(engine.config, "performance", "preload_glyph_cache", autoApply = True),#evilynux
    ]
    perfSettingsMenu = Menu.Menu(engine, perfSettings + applyItem)

    listSettings = [
      (_("Select Song Library >"), self.baseLibrarySelect),
      ConfigChoice(engine.config, "game",  "sort_order", autoApply = True),
      ConfigChoice(engine.config, "coffee", "songdisplay", autoApply = True),
      ConfigChoice(engine.config, "game", "quickplay_career_tiers", autoApply = True),  #myfingershurt
      ConfigChoice(engine.config, "coffee", "songfilepath", autoApply = True),
      ConfigChoice(engine.config, "audio", "disable_preview", autoApply = True),  #myfingershurt
      ConfigChoice(engine.config, "game", "songlist_difficulty", autoApply = True), #evilynux
      ConfigChoice(engine.config, "game", "songlist_extra_stats", autoApply = True), #evilynux
      ConfigChoice(engine.config, "game", "songlist_instrument", autoApply = True), #MFH
      ConfigChoice(engine.config, "game", "HSMovement", autoApply = True), #racer
    ]
    listSettingsMenu = Menu.Menu(engine, listSettings + applyItem)

    themeSettings = [
      ConfigChoice(engine.config, "coffee", "themename",    autoApply = True),
      ConfigChoice(engine.config, "game", "stage_mode", autoApply = True),   #myfingershurt
      ConfigChoice(engine.config, "game", "song_stage", autoApply = True),   #myfingershurt
      ConfigChoice(engine.config, "game", "rotate_stages", autoApply = True),   #myfingershurt
      ConfigChoice(engine.config, "game", "animated_stage_folder", autoApply = True),   #myfingershurt
      ConfigChoice(engine.config, "game", "miss_pauses_anim", autoApply = True),   #myfingershurt
      ConfigChoice(engine.config, "game", "stage_rotate_delay", autoApply = True),   #myfingershurt - user defined stage rotate delay
      ConfigChoice(engine.config, "game", "stage_animate_delay", autoApply = True),   #myfingershurt - user defined stage rotate delay
      ConfigChoice(engine.config, "game", "rb_sp_neck_glow", autoApply = True),
      ConfigChoice(engine.config, "game",   "rbmfx", autoApply = True), #blazingamer
      ConfigChoice(engine.config, "game", "starfx", autoApply = True),
      ConfigChoice(engine.config, "game", "rbnote", autoApply = True), #racer
      ConfigChoice(engine.config, "game", "in_game_stars", autoApply = True),#myfingershurt
      ConfigChoice(engine.config, "game", "partial_stars", autoApply = True),#myfingershurt
      ConfigChoice(engine.config, "game", "sp_notes_while_active", autoApply = True),   #myfingershurt - setting for gaining more SP while active
    ]
    themeSettingsMenu = Menu.Menu(engine, themeSettings + applyItem)


    #MFH - new menu
    debugSettings = [
      ConfigChoice(engine.config, "game", "kill_debug", autoApply = True),#myfingershurt
      ConfigChoice(engine.config, "game", "hopo_debug_disp", autoApply = True),#myfingershurt
      ConfigChoice(engine.config, "game", "rock_band_events", autoApply = True),#myfingershurt
      ConfigChoice(engine.config, "game", "show_unused_text_events", autoApply = True),#myfingershurt
    ]
    debugSettingsMenu = Menu.Menu(engine, debugSettings)


    settings = [
      (_(engine.versionString),   gameSettingsMenu),
      (_("Theme Settings"),      themeSettingsMenu),
      (_("Key Settings"),          keySettingsMenu),
      (_("Visual Settings"),     videoSettingsMenu),
      (_("Fretboard Settings"),   fretSettingsMenu),
      (_("Audio Settings"),      audioSettingsMenu),
      (_("Performance Settings"), perfSettingsMenu),
      (_("Song List Settings"),   listSettingsMenu),
      (_("Mod settings"), modSettings),
      (_("Debug Settings"),   debugSettingsMenu),
      (_("Choose Neck >"), lambda: Dialogs.chooseNeck(engine,prompt=_("Yellow (#3) / Blue (#4) to change:"))),
      (_("Credits"), lambda: Dialogs.showCredits(engine)) # evilynux - Show Credits!
    ]
  
    self.settingsToApply = settings + \
                           videoSettings + \
                           audioSettings + \
                           volumeSettings + \
                           keySettings + \
                           gameSettings + \
                           perfSettings + \
                           listSettings + \
                           modSettings

    

    self.opt_text_x = Theme.opt_text_xPos
    self.opt_text_y = Theme.opt_text_yPos

    if engine.data.theme == 0:
      if self.opt_text_x == None:
        self.opt_text_x = .44
      if self.opt_text_y == None:
        self.opt_text_y = .14
    elif engine.data.theme == 1:
      if self.opt_text_x == None:
        self.opt_text_x = .38
      if self.opt_text_y == None:
        self.opt_text_y = .15
    elif engine.data.theme == 2:
      if self.opt_text_x == None:
        self.opt_text_x = .25
      if self.opt_text_y == None:
        self.opt_text_y = .14


    self.opt_text_color = Theme.hexToColor(Theme.opt_text_colorVar)
    self.opt_selected_color = Theme.hexToColor(Theme.opt_selected_colorVar)

    Log.debug("Option text / selected hex colors: " + Theme.opt_text_colorVar + " / " + Theme.opt_selected_colorVar)


    if self.opt_text_color == None:
      self.opt_text_color = (1,1,1)
    if self.opt_selected_color == None:
      self.opt_selected_color = (1,0.75,0)

    Log.debug("Option text / selected colors: " + str(self.opt_text_color) + " / " + str(self.opt_selected_color))



    Menu.Menu.__init__(self, engine, settings, pos = (self.opt_text_x, self.opt_text_y), textColor = self.opt_text_color, selectedColor = self.opt_selected_color)   #MFH - add position to this so we can move it
Ejemplo n.º 13
0
def n_ROU(Prime,comprime,n):
    if((Prime % n) != 1):
        print("ERROR!!,n is not factor of (Prime-1) ")
    i = (Prime - 1)//n  ##integer quotient
    ROU = Mod.ExpMod(comprime,i,Prime)
    return ROU
Ejemplo n.º 14
0
            exp = Mod.MulMod(i,j,n)          #calculates power of i*j
            tmp = Mod.ExpMod(ROU,exp,prime)  #calculates w^(i*j)
            tmp = Mod.MulMod(x[j],tmp,prime) #calculate x[j]w^(ij)
            acm = Mod.AddMod(acm,tmp,prime)  
        y_list.append(acm)
    y = np.array(y_list)
    if(inverse == 1):
        y = y * IN
        y = y % prime
    return y

#main
p  =  7  #prime #20231
n =  3
#init parameter
ROU  = init.n_ROU(p,4,n)
init.PROU(ROU,n,p)
print("ROU:",str(ROU))
IROU = Mod.InvMod(ROU,p)
print("IROU:",str(IROU))
'''
x = np.zeros(n,dtype = int)
x[0] = 1
x[1] = 1
x[2] = 1
print(x)
inverse = 0 
y = NTT(x,ROU,p,n,inverse)
print(y)
'''
Ejemplo n.º 15
0
    def __init__ ( self, modname, mapname, is_server=False, graphics_enabled=True ):
        """Initialize the world from the given map"""
        self.modname = modname
        self.mapname = mapname
        self.playerEnt = None
        self.isServer = is_server
        self.graphicsEnabled = graphics_enabled
        self.idCounter = 0

        self.ninjasKilled   = 0
        self.piratesKilled  = 0
        self.treasuresTaken = 0
        self.deathBlotches = []

        path = Mod.MapPath( modname, mapname)
        hmap = path+"heightmap.bin"
        projectdesc = ProjectDesc ( modname, mapname )
        self.projectDesc = projectdesc
        self.seaLevel = float(projectdesc.SeaLevel)
        self.solver = Physics.Solver()
        self.solver.setMinimumFramerate(10)

        #create materials
        self.materialMap = Materials.DefaultMaterialMap(self.solver)

        #setup atmosphere
        self.atmosphere = Atmosphere.Atmosphere(projectdesc)
        self._extractShadowMap()
        self.terrainMaterial = TerrainMaterial.TerrainMaterial( modname, mapname )
        self.terrain = Terrain.TerrainPatch(  None, self, Heightmap.fromFile(hmap), self.terrainMaterial, projectdesc.Spacing )
        #if self.graphicsEnabled:
        #    self.terrain.initGraphics()
        self.ocean = Ocean.Ocean(float(projectdesc.SeaLevel),
                                 projectdesc.WaterTexture,
                                 self.terrain.getextent() )

        mx = self.terrain.getextent() / 2
        mz = self.terrain.getextent() / 2
        my = self.terrain.getWorldHeightValue( mx, mz ) + 2.0

        #Set the world size (Newton will disable anything that's not
        #within the world box
        extent = float(self.terrain.getextent())
        self.solver.setWorldSize( (-extent, -2000.0, -extent ), (extent, 2000.0, extent) )

        #Create scene. This should load all the entities as well
        self.scene   = SceneManager.SceneManager(self, modname, mapname)
        #set camera
        if not self.graphicsEnabled:
            self.playerEnt = None
            self.camera = None
        else:
            if self.playerEnt == None or Settings.RunPhysics == False:
                self.camera = Camera.Freecam()
                self.camera.position = vec3( mx, my, mz)
                self.camera.yaw = 0
                self.camera.pitch = 0
            else:
                self.camera = Camera.AttachableCamera( self.playerEnt )
            self.frustrum_camera = self.camera.asFreecam()
        print "World loaded"
Ejemplo n.º 16
0
    def __init__(self, engine):

        self.engine = engine

        self.logClassInits = self.engine.config.get("game", "log_class_inits")
        if self.logClassInits == 1:
            Log.debug("SettingsMenu class init (Settings.py)...")

        applyItem = [(_("Apply New Settings"), self.applySettings)]

        modSettings = [
            ConfigChoice(engine.config, "mods", "mod_" + m) for m in Mod.getAvailableMods(engine)
        ] + applyItem

        StagesOptions = [
            ConfigChoice(engine.config, "game", "stage_mode", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "game", "animated_stage_folder", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "game", "song_stage", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "game", "rotate_stages", autoApply=True),  # myfingershurt
            ConfigChoice(
                engine.config, "game", "stage_rotate_delay", autoApply=True
            ),  # myfingershurt - user defined stage rotate delay
            ConfigChoice(
                engine.config, "game", "stage_animate", autoApply=True
            ),  # myfingershurt - user defined stage rotate delay
            ConfigChoice(
                engine.config, "game", "stage_animate_delay", autoApply=True
            ),  # myfingershurt - user defined stage rotate delay
        ]
        StagesOptionsMenu = Menu.Menu(engine, StagesOptions)

        HOPOSettings = [
            ConfigChoice(engine.config, "game", "hopo_indicator", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "game", "hopo_style", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "coffee", "moreHopo", autoApply=True),
            ConfigChoice(engine.config, "game", "song_hopo_freq", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "game", "hopo_after_chord", autoApply=True),  # myfingershurt
        ]
        HOPOSettingsMenu = Menu.Menu(engine, HOPOSettings)

        LyricsSettings = [
            ConfigChoice(engine.config, "game", "lyric_mode", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "game", "script_lyric_pos", autoApply=True),  # myfingershurt
        ]
        LyricsSettingsMenu = Menu.Menu(engine, LyricsSettings)

        JurgenSettings = [
            ConfigChoice(engine.config, "game", "jurgmode", autoApply=True),  # Spikehead777
            ConfigChoice(engine.config, "game", "jurgtype", autoApply=True),  # Spikehead777
            ConfigChoice(engine.config, "game", "jurglogic", autoApply=True),  # MFH
            ConfigChoice(engine.config, "game", "jurgtext", autoApply=True),  # hman
        ]
        JurgenSettingsMenu = Menu.Menu(engine, JurgenSettings)

        FoFiXBasicSettings = [
            ConfigChoice(engine.config, "game", "language"),
            ConfigChoice(engine.config, "coffee", "themename", autoApply=True),
            (_("Stages Options"), StagesOptionsMenu),
            (_("HO/PO Settings"), HOPOSettingsMenu),
            (_("Lyrics Settings"), LyricsSettingsMenu),
            (
                _("Choose P1 Neck >"),
                lambda: Dialogs.chooseNeck(engine, player=0, prompt=_("Yellow (#3) / Blue (#4) to change:")),
            ),
            (
                _("Choose P2 Neck >"),
                lambda: Dialogs.chooseNeck(engine, player=1, prompt=_("Yellow (#3) / Blue (#4) to change:")),
            ),
            ConfigChoice(engine.config, "game", "ignore_open_strums", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "game", "star_scoring", autoApply=True),  # myfingershurt
            ConfigChoice(
                engine.config, "audio", "enable_crowd_tracks", autoApply=True
            ),  # akedrou: I don't like this here, but "audio" menu is empty of choices.
            ConfigChoice(engine.config, "game", "uploadscores", autoApply=True),
        ]
        FoFiXBasicSettingsMenu = Menu.Menu(engine, FoFiXBasicSettings)

        FoFiXAdvancedSettings = [
            ConfigChoice(engine.config, "game", "party_time", autoApply=True),
            ConfigChoice(engine.config, "game", "rb_midi_lyrics", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "game", "midi_lyric_mode", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "game", "rb_midi_sections", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "game", "bass_groove_enable", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "game", "lphrases", autoApply=True),  # blazingamer
            ConfigChoice(engine.config, "game", "whammy_saves_starpower", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "game", "starpower_mode", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "game", "big_rock_endings", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "game", "big_rock_logic", autoApply=True),  # volshebnyi
        ]
        FoFiXAdvancedSettingsMenu = Menu.Menu(engine, FoFiXAdvancedSettings)

        drumKeySettings = [
            (_("Test Keys"), lambda: Dialogs.testDrums(engine)),
            ConfigChoice(engine.config, "game", "auto_drum_sp", autoApply=True),  # myfingershurt
            KeyConfigChoice(engine, engine.config, "player0", "key_bass"),
            KeyConfigChoice(engine, engine.config, "player0", "key_drum1a"),
            KeyConfigChoice(engine, engine.config, "player0", "key_drum1b"),
            KeyConfigChoice(engine, engine.config, "player0", "key_drum2a"),
            KeyConfigChoice(engine, engine.config, "player0", "key_drum2b"),
            KeyConfigChoice(engine, engine.config, "player0", "key_drum3a"),
            KeyConfigChoice(engine, engine.config, "player0", "key_drum3b"),
            KeyConfigChoice(engine, engine.config, "player0", "key_drum4a"),
            KeyConfigChoice(engine, engine.config, "player0", "key_drum4b"),
            KeyConfigChoice(engine, engine.config, "player0", "key_drum_up"),  # shun - directionals
            KeyConfigChoice(engine, engine.config, "player0", "key_drum_down"),
            KeyConfigChoice(engine, engine.config, "player0", "key_drum_left"),
            KeyConfigChoice(engine, engine.config, "player0", "key_drum_right"),
            KeyConfigChoice(engine, engine.config, "player0", "key_drum_cancel"),
            KeyConfigChoice(engine, engine.config, "player1", "player_2_key_bass"),
            KeyConfigChoice(engine, engine.config, "player1", "player_2_key_drum1a"),
            KeyConfigChoice(engine, engine.config, "player1", "player_2_key_drum1b"),
            KeyConfigChoice(engine, engine.config, "player1", "player_2_key_drum2a"),
            KeyConfigChoice(engine, engine.config, "player1", "player_2_key_drum2b"),
            KeyConfigChoice(engine, engine.config, "player1", "player_2_key_drum3a"),
            KeyConfigChoice(engine, engine.config, "player1", "player_2_key_drum3b"),
            KeyConfigChoice(engine, engine.config, "player1", "player_2_key_drum4a"),
            KeyConfigChoice(engine, engine.config, "player1", "player_2_key_drum4b"),
            KeyConfigChoice(engine, engine.config, "player1", "player_2_key_drum_up"),  # shun - directionals
            KeyConfigChoice(engine, engine.config, "player1", "player_2_key_drum_down"),
            KeyConfigChoice(engine, engine.config, "player1", "player_2_key_drum_left"),
            KeyConfigChoice(engine, engine.config, "player1", "player_2_key_drum_right"),
            KeyConfigChoice(engine, engine.config, "player1", "player_2_key_drum_cancel"),
        ]
        drumKeySettingsMenu = Menu.Menu(engine, drumKeySettings)

        # shun - alternate drum keys
        altDrumKeySettings = [
            (_("Test Keys"), lambda: Dialogs.testDrums(engine)),
            # ConfigChoice(engine.config, "game", "auto_drum_sp", autoApply = True),#myfingershurt #shun- probably not needed for alt(?)
            KeyConfigChoice(engine, engine.config, "player0", "akey_bass"),
            KeyConfigChoice(engine, engine.config, "player0", "akey_drum1a"),
            KeyConfigChoice(engine, engine.config, "player0", "akey_drum1b"),
            KeyConfigChoice(engine, engine.config, "player0", "akey_drum2a"),
            KeyConfigChoice(engine, engine.config, "player0", "akey_drum2b"),
            KeyConfigChoice(engine, engine.config, "player0", "akey_drum3a"),
            KeyConfigChoice(engine, engine.config, "player0", "akey_drum3b"),
            KeyConfigChoice(engine, engine.config, "player0", "akey_drum4a"),
            KeyConfigChoice(engine, engine.config, "player0", "akey_drum4b"),
            KeyConfigChoice(engine, engine.config, "player0", "akey_drum_up"),
            KeyConfigChoice(engine, engine.config, "player0", "akey_drum_down"),  # shun - directionals
            KeyConfigChoice(engine, engine.config, "player0", "akey_drum_left"),
            KeyConfigChoice(engine, engine.config, "player0", "akey_drum_right"),
            KeyConfigChoice(engine, engine.config, "player0", "akey_drum_cancel"),
            KeyConfigChoice(engine, engine.config, "player1", "aplayer_2_key_bass"),
            KeyConfigChoice(engine, engine.config, "player1", "aplayer_2_key_drum1a"),
            KeyConfigChoice(engine, engine.config, "player1", "aplayer_2_key_drum1b"),
            KeyConfigChoice(engine, engine.config, "player1", "aplayer_2_key_drum2a"),
            KeyConfigChoice(engine, engine.config, "player1", "aplayer_2_key_drum2b"),
            KeyConfigChoice(engine, engine.config, "player1", "aplayer_2_key_drum3a"),
            KeyConfigChoice(engine, engine.config, "player1", "aplayer_2_key_drum3b"),
            KeyConfigChoice(engine, engine.config, "player1", "aplayer_2_key_drum4a"),
            KeyConfigChoice(engine, engine.config, "player1", "aplayer_2_key_drum4b"),
            KeyConfigChoice(engine, engine.config, "player1", "aplayer_2_key_drum_up"),  # shun -directionals
            KeyConfigChoice(engine, engine.config, "player1", "aplayer_2_key_drum_down"),
            KeyConfigChoice(engine, engine.config, "player1", "aplayer_2_key_drum_left"),
            KeyConfigChoice(engine, engine.config, "player1", "aplayer_2_key_drum_right"),
            KeyConfigChoice(engine, engine.config, "player1", "aplayer_2_key_drum_cancel"),
        ]
        altDrumKeySettingsMenu = Menu.Menu(engine, altDrumKeySettings)

        player0Keys = [
            KeyConfigChoice(engine, engine.config, "player0", "key_action1"),
            KeyConfigChoice(engine, engine.config, "player0", "key_action2"),
            KeyConfigChoice(engine, engine.config, "player0", "key_1"),
            KeyConfigChoice(engine, engine.config, "player0", "key_2"),
            KeyConfigChoice(engine, engine.config, "player0", "key_3"),
            KeyConfigChoice(engine, engine.config, "player0", "key_4"),
            KeyConfigChoice(engine, engine.config, "player0", "key_5"),
            KeyConfigChoice(engine, engine.config, "player0", "key_left"),
            KeyConfigChoice(engine, engine.config, "player0", "key_right"),
            KeyConfigChoice(engine, engine.config, "player0", "key_up"),
            KeyConfigChoice(engine, engine.config, "player0", "key_down"),
            KeyConfigChoice(engine, engine.config, "player0", "key_cancel"),
            KeyConfigChoice(engine, engine.config, "player0", "key_star"),
            KeyConfigChoice(engine, engine.config, "player0", "key_kill"),
        ]
        player0KeyMenu = Menu.Menu(engine, player0Keys)

        player0AltKeys = [
            KeyConfigChoice(engine, engine.config, "player0", "akey_action1"),
            KeyConfigChoice(engine, engine.config, "player0", "akey_action2"),
            KeyConfigChoice(engine, engine.config, "player0", "akey_1"),
            KeyConfigChoice(engine, engine.config, "player0", "akey_2"),
            KeyConfigChoice(engine, engine.config, "player0", "akey_3"),
            KeyConfigChoice(engine, engine.config, "player0", "akey_4"),
            KeyConfigChoice(engine, engine.config, "player0", "akey_5"),
            KeyConfigChoice(engine, engine.config, "player0", "akey_left"),
            KeyConfigChoice(engine, engine.config, "player0", "akey_right"),
            KeyConfigChoice(engine, engine.config, "player0", "akey_up"),
            KeyConfigChoice(engine, engine.config, "player0", "akey_down"),
            KeyConfigChoice(engine, engine.config, "player0", "akey_cancel"),
            KeyConfigChoice(engine, engine.config, "player0", "akey_star"),
            KeyConfigChoice(engine, engine.config, "player0", "akey_kill"),
        ]
        player0AltKeyMenu = Menu.Menu(engine, player0AltKeys)

        player1Keys = [
            KeyConfigChoice(engine, engine.config, "player1", "player_2_key_action1"),
            KeyConfigChoice(engine, engine.config, "player1", "player_2_key_action2"),
            KeyConfigChoice(engine, engine.config, "player1", "player_2_key_1"),
            KeyConfigChoice(engine, engine.config, "player1", "player_2_key_2"),
            KeyConfigChoice(engine, engine.config, "player1", "player_2_key_3"),
            KeyConfigChoice(engine, engine.config, "player1", "player_2_key_4"),
            KeyConfigChoice(engine, engine.config, "player1", "player_2_key_5"),
            KeyConfigChoice(engine, engine.config, "player1", "player_2_key_left"),
            KeyConfigChoice(engine, engine.config, "player1", "player_2_key_right"),
            KeyConfigChoice(engine, engine.config, "player1", "player_2_key_up"),
            KeyConfigChoice(engine, engine.config, "player1", "player_2_key_down"),
            KeyConfigChoice(engine, engine.config, "player1", "player_2_key_cancel"),
            KeyConfigChoice(engine, engine.config, "player1", "player_2_key_star"),  # added by ShiekOdaSandz
            KeyConfigChoice(engine, engine.config, "player1", "player_2_key_kill"),  # added by ShiekOdaSandz
        ]
        player1KeyMenu = Menu.Menu(engine, player1Keys)

        player1AltKeys = [
            KeyConfigChoice(engine, engine.config, "player1", "aplayer_2_key_action1"),
            KeyConfigChoice(engine, engine.config, "player1", "aplayer_2_key_action2"),
            KeyConfigChoice(engine, engine.config, "player1", "aplayer_2_key_1"),
            KeyConfigChoice(engine, engine.config, "player1", "aplayer_2_key_2"),
            KeyConfigChoice(engine, engine.config, "player1", "aplayer_2_key_3"),
            KeyConfigChoice(engine, engine.config, "player1", "aplayer_2_key_4"),
            KeyConfigChoice(engine, engine.config, "player1", "aplayer_2_key_5"),
            KeyConfigChoice(engine, engine.config, "player1", "aplayer_2_key_left"),
            KeyConfigChoice(engine, engine.config, "player1", "aplayer_2_key_right"),
            KeyConfigChoice(engine, engine.config, "player1", "aplayer_2_key_up"),
            KeyConfigChoice(engine, engine.config, "player1", "aplayer_2_key_down"),
            KeyConfigChoice(engine, engine.config, "player1", "aplayer_2_key_cancel"),
            KeyConfigChoice(engine, engine.config, "player1", "aplayer_2_key_star"),  # added by ShiekOdaSandz
            KeyConfigChoice(engine, engine.config, "player1", "aplayer_2_key_kill"),  # added by ShiekOdaSandz
        ]
        player1AltKeyMenu = Menu.Menu(engine, player1AltKeys)

        AdvancedKeySettings = [
            ConfigChoice(engine.config, "game", "analog_killsw_mode", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "player0", "two_chord_max", autoApply=True),
            ConfigChoice(engine.config, "player0", "leftymode", autoApply=True),
            ConfigChoice(engine.config, "game", "analog_killsw_mode_p2", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "player1", "two_chord_max", autoApply=True),  # QQstarS
            ConfigChoice(engine.config, "player1", "leftymode", autoApply=True),  # QQstarS
            ConfigChoice(engine.config, "game", "drum_navigation", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "game", "p2_menu_nav", autoApply=True),  # myfingershurt
        ]
        AdvancedKeySettingsMenu = Menu.Menu(engine, AdvancedKeySettings)

        keySettings = [
            ConfigChoice(engine.config, "game", "key_checker_mode", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "game", "alt_keys", autoApply=True),
            (_("Player 1 Keys"), player0KeyMenu),
            (_("Player 1 Alt. Keys"), player0AltKeyMenu),
            (_("Player 2 Keys"), player1KeyMenu),
            (_("Player 2 Alt. Keys"), player1AltKeyMenu),
            (_("Drum Keys"), drumKeySettingsMenu),
            (_("Alt. Drum Keys"), altDrumKeySettingsMenu),
            (_("Test Keys"), lambda: Dialogs.testKeys(engine)),
            (_("Advanced Controls"), AdvancedKeySettingsMenu),
        ]
        keySettingsMenu = Menu.Menu(engine, keySettings)

        AdvancedVideoSettings = [
            ConfigChoice(engine.config, "video", "fps"),
            ConfigChoice(engine.config, "game", "game_time", autoApply=True),
            ConfigChoice(engine.config, "game", "accuracy_mode", autoApply=True),
            ConfigChoice(engine.config, "game", "accuracy_pos", autoApply=True),
            ConfigChoice(engine.config, "game", "decimal_places", autoApply=True),  # MFH
            ConfigChoice(engine.config, "game", "gsolo_accuracy_disp", autoApply=True),  # MFH
            ConfigChoice(engine.config, "game", "gsolo_acc_pos", autoApply=True),  # MFH
            ConfigChoice(engine.config, "coffee", "noterotate", autoApply=True),  # blazingamer
            ConfigChoice(engine.config, "game", "gfx_version_tag", autoApply=True),  # MFH
        ]
        AdvancedVideoSettingsMenu = Menu.Menu(engine, AdvancedVideoSettings)

        modes = engine.video.getVideoModes()
        modes.reverse()
        Config.define(
            "video",
            "resolution",
            str,
            "1024x768",
            text=_("Video Resolution"),
            options=["%dx%d" % (m[0], m[1]) for m in modes],
        )
        videoSettings = [
            ConfigChoice(engine.config, "video", "resolution"),
            ConfigChoice(engine.config, "video", "fullscreen"),
            ConfigChoice(engine.config, "video", "multisamples"),
            ConfigChoice(engine.config, "video", "disable_fretsfx"),
            ConfigChoice(engine.config, "video", "hitglow_color"),
            ConfigChoice(engine.config, "video", "counting", autoApply=True),
            (_("Advanced Video Settings"), AdvancedVideoSettingsMenu),
        ]
        videoSettingsMenu = Menu.Menu(engine, videoSettings)

        fretSettings = [
            ConfigChoice(engine.config, "fretboard", "point_of_view", autoApply=True),
            ConfigChoice(engine.config, "coffee", "phrases", autoApply=True),
            ConfigChoice(engine.config, "game", "notedisappear", autoApply=True),
            ConfigChoice(engine.config, "game", "frets_under_notes", autoApply=True),  # MFH
            ConfigChoice(engine.config, "game", "nstype", autoApply=True),  # blazingamer
            ConfigChoice(engine.config, "coffee", "neckSpeed", autoApply=True),
            ConfigChoice(engine.config, "game", "hit_window", autoApply=True),  # alarian: defines hit window
            ConfigChoice(engine.config, "game", "large_drum_neck", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "game", "bass_groove_neck", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "game", "guitar_solo_neck", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "game", "incoming_neck_mode", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "game", "solo_frame", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "game", "in_game_font_shadowing", autoApply=True),  # myfingershurt
        ]
        fretSettingsMenu = Menu.Menu(engine, fretSettings)

        volumeSettings = [
            VolumeConfigChoice(engine, engine.config, "audio", "guitarvol", autoApply=True),
            VolumeConfigChoice(engine, engine.config, "audio", "songvol", autoApply=True),
            VolumeConfigChoice(engine, engine.config, "audio", "rhythmvol", autoApply=True),
            VolumeConfigChoice(engine, engine.config, "audio", "screwupvol", autoApply=True),
            VolumeConfigChoice(engine, engine.config, "audio", "miss_volume", autoApply=True),
            VolumeConfigChoice(engine, engine.config, "audio", "single_track_miss_volume", autoApply=True),
            VolumeConfigChoice(engine, engine.config, "audio", "crowd_volume", autoApply=True),  # akedrou
            VolumeConfigChoice(engine, engine.config, "audio", "kill_volume", autoApply=True),  # MFH
            VolumeConfigChoice(engine, engine.config, "audio", "SFX_volume", autoApply=True),  # MFH
        ]
        volumeSettingsMenu = Menu.Menu(engine, volumeSettings)

        AdvancedAudioSettings = [
            ConfigChoice(
                engine.config, "audio", "delay", autoApply=True
            ),  # myfingershurt: so a/v delay can be set without restarting FoF
            ConfigChoice(engine.config, "audio", "whammy_effect", autoApply=True),  # MFH
            ConfigChoice(engine.config, "audio", "frequency"),
            ConfigChoice(engine.config, "audio", "bits"),
            ConfigChoice(engine.config, "audio", "buffersize"),
            # ConfigChoice(engine.config, "game", "mute_sustain_releases", autoApply = True),   #myfingershurt
            ConfigChoice(engine.config, "game", "sustain_muting", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "audio", "mute_last_second", autoApply=True),  # MFH
            ConfigChoice(engine.config, "game", "bass_kick_sound", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "game", "T_sound", autoApply=True),  # Faaa Drum sound
            ConfigChoice(engine.config, "game", "result_cheer_loop", autoApply=True),  # MFH
            ConfigChoice(engine.config, "game", "cheer_loop_delay", autoApply=True),  # MFH
            ConfigChoice(engine.config, "game", "star_claps", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "game", "beat_claps", autoApply=True),  # racer
        ]
        AdvancedAudioSettingsMenu = Menu.Menu(engine, AdvancedAudioSettings)

        audioSettings = [
            (_("Volume Settings"), volumeSettingsMenu),
            (_("Advanced Audio Settings"), AdvancedAudioSettingsMenu),
        ]
        audioSettingsMenu = Menu.Menu(engine, audioSettings)

        # MFH - new menu
        logfileSettings = [
            ConfigChoice(engine.config, "game", "log_ini_reads", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "game", "log_class_inits", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "game", "log_loadings", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "game", "log_sections", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "game", "log_undefined_gets", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "game", "log_marker_notes", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "game", "log_starpower_misses", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "log", "log_unedited_midis", autoApply=True),  # myfingershurt
        ]
        logfileSettingsMenu = Menu.Menu(engine, logfileSettings)

        debugSettings = [
            ConfigChoice(engine.config, "video", "show_fps", autoApply=True),  # evilynux
            ConfigChoice(engine.config, "game", "kill_debug", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "game", "hopo_debug_disp", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "game", "rock_band_events", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "game", "show_unused_text_events", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "debug", "use_unedited_midis", autoApply=True),  # myfingershurt
            # ConfigChoice(engine.config, "game", "font_rendering_mode", autoApply = True),#myfingershurt
            ConfigChoice(engine.config, "debug", "show_freestyle_active", autoApply=True),  # myfingershurt
            (_("Log Settings"), logfileSettingsMenu),
        ]
        debugSettingsMenu = Menu.Menu(engine, debugSettings)

        ManualPerfSettings = [
            ConfigChoice(engine.config, "performance", "game_priority", autoApply=True),
            ConfigChoice(engine.config, "performance", "disable_libcount", autoApply=True),
            ConfigChoice(engine.config, "performance", "disable_librotation", autoApply=True),
            ConfigChoice(engine.config, "performance", "starspin"),
            ConfigChoice(engine.config, "performance", "static_strings", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "performance", "killfx", autoApply=True),  # blazingamer
            ConfigChoice(engine.config, "performance", "star_score_updates", autoApply=True),  # MFH
            ConfigChoice(engine.config, "performance", "in_game_stats", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "performance", "preload_glyph_cache", autoApply=True),  # evilynux
        ]
        ManualPerfSettingsMenu = Menu.Menu(engine, ManualPerfSettings)

        perfSettings = [
            ConfigChoice(engine.config, "performance", "autoset", autoApply=True),
            (_("Manual Settings (Autoset must be off)"), ManualPerfSettingsMenu),
            (_("Debug Settings"), debugSettingsMenu),
        ]
        perfSettingsMenu = Menu.Menu(engine, perfSettings)

        listSettings = [
            (_("Select Song Library >"), self.baseLibrarySelect),
            ConfigChoice(engine.config, "coffee", "songfilepath", autoApply=True),
            ConfigChoice(engine.config, "game", "sort_direction", autoApply=True),
            ConfigChoice(engine.config, "game", "sort_order", autoApply=True),
            ConfigChoice(engine.config, "coffee", "song_display_mode", autoApply=True),
            ConfigChoice(engine.config, "game", "song_listing_mode", autoApply=True),
            # (_("Select List All Folder >"), self.listAllFolderSelect), #- Not Working Yet - Qstick
            ConfigChoice(engine.config, "game", "songcovertype", autoApply=True),
            ConfigChoice(engine.config, "game", "songlistrotation", autoApply=True),
            ConfigChoice(engine.config, "game", "song_icons", autoApply=True),
            ConfigChoice(engine.config, "game", "preload_labels", autoApply=True),
            ConfigChoice(engine.config, "audio", "disable_preview", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "game", "songlist_instrument", autoApply=True),  # MFH
            ConfigChoice(engine.config, "game", "songlist_difficulty", autoApply=True),  # evilynux
            ConfigChoice(engine.config, "game", "songlist_extra_stats", autoApply=True),  # evilynux
            ConfigChoice(engine.config, "game", "HSMovement", autoApply=True),  # racer
            ConfigChoice(engine.config, "game", "quickplay_tiers", autoApply=True),  # myfingershurt
        ]
        listSettingsMenu = Menu.Menu(engine, listSettings)

        ThemeSettings = [
            ConfigChoice(engine.config, "game", "miss_pauses_anim", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "game", "rb_sp_neck_glow", autoApply=True),
            ConfigChoice(engine.config, "game", "rbmfx", autoApply=True),  # blazingamer
            ConfigChoice(engine.config, "game", "starfx", autoApply=True),
            ConfigChoice(engine.config, "game", "rbnote", autoApply=True),  # racer
            ConfigChoice(engine.config, "game", "in_game_stars", autoApply=True),  # myfingershurt
            ConfigChoice(engine.config, "game", "partial_stars", autoApply=True),  # myfingershurt
            ConfigChoice(
                engine.config, "game", "sp_notes_while_active", autoApply=True
            ),  # myfingershurt - setting for gaining more SP while active
        ]
        ThemeSettingsMenu = Menu.Menu(engine, ThemeSettings)

        AdvancedSettings = [
            (_("FoFix Advanced Settings"), FoFiXAdvancedSettingsMenu),
            (_("Theme Settings"), ThemeSettingsMenu),
            (_("Fretboard Settings"), fretSettingsMenu),
        ]
        AdvancedSettingsMenu = Menu.Menu(engine, AdvancedSettings)

        Cheats = [
            (_("Jurgen Settings"), JurgenSettingsMenu),
            ConfigChoice(engine.config, "coffee", "failingEnabled", autoApply=True),
            ConfigChoice(engine.config, "audio", "slow_down_divisor", autoApply=True),  # MFH
        ]
        CheatMenu = Menu.Menu(engine, Cheats)

        settings = [
            (_(engine.versionString + _(" Basic Settings")), FoFiXBasicSettingsMenu),
            (_("Controls"), keySettingsMenu),
            (_("Library"), listSettingsMenu),
            (_("Audio"), audioSettingsMenu),
            (_("Video"), videoSettingsMenu),
            (_("Performances/Debug"), perfSettingsMenu),
            (_("Advanced Settings"), AdvancedSettingsMenu),
            (_("Mod settings"), modSettings),
            (_("Cheats"), CheatMenu),
            (_("Credits"), lambda: Dialogs.showCredits(engine)),  # evilynux - Show Credits!
            (_("Apply New Settings"), self.applySettings),
        ]

        self.settingsToApply = (
            videoSettings
            + AdvancedAudioSettings
            + keySettings
            + AdvancedVideoSettings
            + FoFiXBasicSettings
            + perfSettings
            + modSettings
        )

        # -    self.settingsToApply = settings + \
        # -                           videoSettings + \
        # -                           AdvancedAudioSettings + \
        # -                           volumeSettings + \
        # -                           keySettings + \
        # -			                     AdvancedVideoSettings + \
        # -                           FoFiXBasicSettings + \11/26/2008 11:10:30 PM
        # -                           perfSettings + \
        # -                           listSettings + \
        # -                           modSettings

        self.opt_text_x = Theme.opt_text_xPos
        self.opt_text_y = Theme.opt_text_yPos

        if engine.data.theme == 0:
            if self.opt_text_x == None:
                self.opt_text_x = 0.44
            if self.opt_text_y == None:
                self.opt_text_y = 0.14
        elif engine.data.theme == 1:
            if self.opt_text_x == None:
                self.opt_text_x = 0.38
            if self.opt_text_y == None:
                self.opt_text_y = 0.15
        elif engine.data.theme == 2:
            if self.opt_text_x == None:
                self.opt_text_x = 0.25
            if self.opt_text_y == None:
                self.opt_text_y = 0.14

        self.opt_text_color = Theme.hexToColor(Theme.opt_text_colorVar)
        self.opt_selected_color = Theme.hexToColor(Theme.opt_selected_colorVar)

        Log.debug("Option text / selected hex colors: " + Theme.opt_text_colorVar + " / " + Theme.opt_selected_colorVar)

        if self.opt_text_color == None:
            self.opt_text_color = (1, 1, 1)
        if self.opt_selected_color == None:
            self.opt_selected_color = (1, 0.75, 0)

        Log.debug("Option text / selected colors: " + str(self.opt_text_color) + " / " + str(self.opt_selected_color))

        Menu.Menu.__init__(
            self,
            engine,
            settings,
            pos=(self.opt_text_x, self.opt_text_y),
            textColor=self.opt_text_color,
            selectedColor=self.opt_selected_color,
        )  # MFH - add position to this so we can move it
Ejemplo n.º 17
0
def fmod(x):
    return Mod(float(x))
Ejemplo n.º 18
0
    def __init__(self, config = None):

        Log.debug("GameEngine class init (GameEngine.py)...")
        self.mainMenu = None    #placeholder for main menu object - to prevent reinstantiation

        self.createdGuitarScene = False   #MFH - so we only create ONE guitarscene...!
        self.currentScene = None

        self.versionString = version  #stump: other version stuff moved to allow full version string to be retrieved without instantiating GameEngine
        self.uploadVersion = "%s-4.0" % Version.PROGRAM_NAME #akedrou - the version passed to the upload site.

        self.dataPath = Version.dataPath()
        Log.debug(self.versionString + " starting up...")
        Log.debug("Python version: " + sys.version.split(' ')[0])
        Log.debug("Pygame version: " + str(pygame.version.ver) )
        Log.debug("PyOpenGL version: " + OpenGL.__version__)
        Log.debug("Numpy version: " + np.__version__)
        Log.debug("PIL version: " + Image.VERSION)
        Log.debug("sys.argv: " + repr(sys.argv))
        Log.debug("os.name: " + os.name)
        Log.debug("sys.platform: " + sys.platform)
        if os.name == 'nt':
            import win32api
            Log.debug("win32api.GetVersionEx(1): " + repr(win32api.GetVersionEx(1)))
        elif os.name == 'posix':
            Log.debug("os.uname(): " + repr(os.uname()))

        """
        Constructor.
        @param config:  L{Config} instance for settings
        """

        self.tutorialFolder = "tutorials"

        if not config:
            config = Config.load()

        self.config  = config

        fps          = self.config.get("video", "fps")

        self.tasks = []
        self.frameTasks = []
        self.fps = fps
        self.currentTask = None
        self.paused = []
        self.running = True
        self.clock = pygame.time.Clock()

        self.title             = self.versionString
        self.restartRequested  = False

        # evilynux - Check if theme icon exists first, then fallback on FoFiX icon.
        themename = self.config.get("coffee", "themename")
        themeicon = os.path.join(Version.dataPath(), "themes", themename, "icon.png")
        fofixicon = os.path.join(Version.dataPath(), "fofix_icon.png")
        icon = None
        if os.path.exists(themeicon):
            icon = themeicon
        elif os.path.exists(fofixicon):
            icon = fofixicon

        self.video             = Video(self.title, icon)
        if self.config.get("video", "disable_screensaver"):
            self.video.disableScreensaver()

        self.audio             = Audio()
        self.frames            = 0
        self.fpsEstimate       = 0
        self.priority          = self.config.get("engine", "highpriority")
        self.show_fps          = self.config.get("video", "show_fps")
        self.advSettings       = self.config.get("game", "adv_settings")
        self.restartRequired   = False
        self.quicksetRestart   = False
        self.quicksetPerf      = self.config.get("quickset", "performance")
        self.scrollRate        = self.config.get("game", "scroll_rate")
        self.scrollDelay       = self.config.get("game", "scroll_delay")

        Log.debug("Initializing audio.")
        frequency    = self.config.get("audio", "frequency")
        bits         = self.config.get("audio", "bits")
        stereo       = self.config.get("audio", "stereo")
        bufferSize   = self.config.get("audio", "buffersize")
        self.audio.open(frequency = frequency, bits = bits, stereo = stereo, bufferSize = bufferSize)

        self.cmdPlay           = 0
        self.cmdMode           = None
        self.cmdDiff           = None
        self.cmdPart           = None

        self.gameStarted       = False
        self.world             = None

        self.audioSpeedFactor  = 1.0

        Log.debug("Initializing video.")
        #myfingershurt: ensuring windowed mode starts up in center of the screen instead of cascading positions:
        os.environ['SDL_VIDEO_WINDOW_POS'] = 'center'

        width, height = [int(s) for s in self.config.get("video", "resolution").split("x")]
        fullscreen    = self.config.get("video", "fullscreen")
        multisamples  = self.config.get("video", "multisamples")
        self.video.setMode((width, height), fullscreen = fullscreen, multisamples = multisamples)
        Log.debug("OpenGL version: " + glGetString(GL_VERSION))
        Log.debug("OpenGL vendor: " + glGetString(GL_VENDOR))
        Log.debug("OpenGL renderer: " + glGetString(GL_RENDERER))
        Log.debug("OpenGL extensions: " + ' '.join(sorted(glGetString(GL_EXTENSIONS).split())))

        if self.video.default:
            self.config.set("video", "fullscreen", False)
            self.config.set("video", "resolution", "800x600")

        if self.config.get("video", "shader_use"):
            shaders.set(os.path.join(Version.dataPath(), "shaders"))

        # Enable the high priority timer if configured
        if self.priority:
            Log.debug("Enabling high priority timer.")
            self.fps = 0 # High priority

        # evilynux - This was generating an error on the first pass (at least under
        #            GNU/Linux) as the Viewport was not set yet.
        try:
            viewport = glGetIntegerv(GL_VIEWPORT)
        except:
            viewport = [0, 0, width, height]
        h = viewport[3] - viewport[1]
        w = viewport[2] - viewport[0]
        geometry = (0, 0, w, h)
        self.svg = SvgContext(geometry)
        glViewport(int(viewport[0]), int(viewport[1]), int(viewport[2]), int(viewport[3]))

        self.startupMessages   = self.video.error
        self.input     = Input()
        self.view      = View(self, geometry)
        self.resizeScreen(w, h)

        self.resource  = Resource(Version.dataPath())
        self.mainloop  = self.loading
        self.menuMusic = False

        self.setlistMsg = None


        # Load game modifications
        Mod.init(self)
        self.addTask(self.input, synchronized = False)

        self.addTask(self.view, synchronized = False)

        self.addTask(self.resource, synchronized = False)

        self.data = Data(self.resource, self.svg)

        ##MFH: Animated stage folder selection option
        #<themename>\Stages still contains the backgrounds for when stage rotation is off, and practice.png
        #subfolders under Stages\ will each be treated as a separate animated stage set

        self.stageFolders = []
        currentTheme = themename

        stagespath = os.path.join(Version.dataPath(), "themes", currentTheme, "backgrounds")
        themepath  = os.path.join(Version.dataPath(), "themes", currentTheme)
        if os.path.exists(stagespath):
            self.stageFolders = []
            allFolders = os.listdir(stagespath)   #this also includes all the stage files - so check to see if there is at least one .png file inside each folder to be sure it's an animated stage folder
            for name in allFolders:
                aniStageFolderListing = []
                thisIsAnAnimatedStageFolder = False
                try:
                    aniStageFolderListing = os.listdir(os.path.join(stagespath,name))
                except Exception:
                    thisIsAnAnimatedStageFolder = False
                for aniFile in aniStageFolderListing:
                    if os.path.splitext(aniFile)[1] == ".png" or os.path.splitext(aniFile)[1] ==  ".jpg" or os.path.splitext(aniFile)[1] == ".jpeg":  #we've found at least one .png file here, chances are this is a valid animated stage folder
                        thisIsAnAnimatedStageFolder = True
                if thisIsAnAnimatedStageFolder:
                    self.stageFolders.append(name)


            i = len(self.stageFolders)
            if i > 0: #only set default to first animated subfolder if one exists - otherwise use Normal!
                defaultAniStage = str(self.stageFolders[0])
            else:
                defaultAniStage = "Normal"
            Log.debug("Default animated stage for " + currentTheme + " theme = " + defaultAniStage)
            aniStageOptions = dict([(str(self.stageFolders[n]),self.stageFolders[n]) for n in range(0, i)])
            aniStageOptions.update({"Normal":_("Slideshow")})
            if i > 1:   #only add Random setting if more than one animated stage exists
                aniStageOptions.update({"Random":_("Random")})
            Config.define("game", "animated_stage_folder", str, defaultAniStage, text = _("Animated Stage"), options = aniStageOptions )

            #MFH: here, need to track and check a new ini entry for last theme - so when theme changes we can re-default animated stage to first found
            lastTheme = self.config.get("game","last_theme")
            if lastTheme == "" or lastTheme != currentTheme:   #MFH - no last theme, and theme just changed:
                self.config.set("game","animated_stage_folder",defaultAniStage)   #force defaultAniStage
            self.config.set("game","last_theme",currentTheme)

            selectedAnimatedStage = self.config.get("game", "animated_stage_folder")
            if selectedAnimatedStage != "Normal" and selectedAnimatedStage != "Random":
                if not os.path.exists(os.path.join(stagespath,selectedAnimatedStage)):
                    Log.warn("Selected animated stage folder " + selectedAnimatedStage + " does not exist, forcing Normal.")
                    self.config.set("game","animated_stage_folder","Normal") #MFH: force "Standard" currently selected animated stage folder is invalid
        else:
            Config.define("game", "animated_stage_folder", str, "None", text = _("Animated Stage"), options = ["None",_("None")])
            Log.warn("No stages\ folder found, forcing None setting for Animated Stage.")
            self.config.set("game","animated_stage_folder", "None") #MFH: force "None" when Stages folder can't be found



        try:
            fp, pathname, description = imp.find_module("CustomTheme",[themepath])
            theme = imp.load_module("CustomTheme", fp, pathname, description)
            self.theme = theme.CustomTheme(themepath, themename)
        except ImportError:
            self.theme = Theme(themepath, themename)

        self.addTask(self.theme)


        self.input.addKeyListener(FullScreenSwitcher(self), priority = True)
        self.input.addSystemEventListener(SystemEventHandler(self))

        self.debugLayer         = None
        self.startupLayer       = None
        self.loadingScreenShown = False
        self.graphicMenuShown   = False

        Log.debug("Ready.")
Ejemplo n.º 19
0
import Mod


Mod.Mod("hi from other mod")
Ejemplo n.º 20
0
  def __init__(self, engine):
    applyItem = [(_("Apply New Settings"), self.applySettings)]

    modSettings = [
      ConfigChoice(engine.config, "mods",  "mod_" + m) for m in Mod.getAvailableMods(engine)
    ] + applyItem
    
    gameSettings = [
      (_("Mod settings"), modSettings),
      ConfigChoice(engine.config, "game",  "language"),
      #ConfigChoice(engine.config, "game",  "leftymode", autoApply = True),
      #ConfigChoice(engine.config, "game",  "tapping", autoApply = True),
      ConfigChoice(engine.config, "game",  "uploadscores", autoApply = True),
    ]
    gameSettingsMenu = Menu.Menu(engine, gameSettings + applyItem)

    keySettings = [
      (_("Test Keys"), lambda: Dialogs.testKeys(engine)),
      KeyConfigChoice(engine, engine.config, "player0", "key_action1"),
      KeyConfigChoice(engine, engine.config, "player0", "key_action2"),
      KeyConfigChoice(engine, engine.config, "player0", "key_1"),
      KeyConfigChoice(engine, engine.config, "player0", "key_2"),
      KeyConfigChoice(engine, engine.config, "player0", "key_3"),
      KeyConfigChoice(engine, engine.config, "player0", "key_4"),
      KeyConfigChoice(engine, engine.config, "player0", "key_5"),
      KeyConfigChoice(engine, engine.config, "player0", "key_left"),
      KeyConfigChoice(engine, engine.config, "player0", "key_right"),
      KeyConfigChoice(engine, engine.config, "player0", "key_up"),
      KeyConfigChoice(engine, engine.config, "player0", "key_down"),
      KeyConfigChoice(engine, engine.config, "player0", "key_cancel"),
      KeyConfigChoice(engine, engine.config, "player1", "player_2_key_action1"),
      KeyConfigChoice(engine, engine.config, "player1", "player_2_key_action2"),
      KeyConfigChoice(engine, engine.config, "player1", "player_2_key_1"),
      KeyConfigChoice(engine, engine.config, "player1", "player_2_key_2"),
      KeyConfigChoice(engine, engine.config, "player1", "player_2_key_3"),
      KeyConfigChoice(engine, engine.config, "player1", "player_2_key_4"),
      KeyConfigChoice(engine, engine.config, "player1", "player_2_key_5"),
      KeyConfigChoice(engine, engine.config, "player1", "player_2_key_left"),
      KeyConfigChoice(engine, engine.config, "player1", "player_2_key_right"),
      KeyConfigChoice(engine, engine.config, "player1", "player_2_key_up"),
      KeyConfigChoice(engine, engine.config, "player1", "player_2_key_down"),
      KeyConfigChoice(engine, engine.config, "player1", "player_2_key_cancel"),
    ]
    keySettingsMenu = Menu.Menu(engine, keySettings)
    
    modes = engine.video.getVideoModes()
    modes.reverse()
    Config.define("video",  "resolution", str,   "640x480", text = _("Video Resolution"), options = ["%dx%d" % (m[0], m[1]) for m in modes])
    videoSettings = [
      ConfigChoice(engine.config, "video",  "resolution"),
      ConfigChoice(engine.config, "video",  "fullscreen"),
      ConfigChoice(engine.config, "video",  "fps"),
      ConfigChoice(engine.config, "video",  "multisamples"),
      #ConfigChoice(engine.config, "opengl", "svgshaders"),    # shaders broken at the moment
      ConfigChoice(engine.config, "opengl", "svgquality"),
      ConfigChoice(engine.config, "video", "fontscale"),
    ]
    videoSettingsMenu = Menu.Menu(engine, videoSettings + applyItem)

    volumeSettings = [
      VolumeConfigChoice(engine, engine.config, "audio",  "guitarvol"),
      VolumeConfigChoice(engine, engine.config, "audio",  "songvol"),
      VolumeConfigChoice(engine, engine.config, "audio",  "rhythmvol"),
      VolumeConfigChoice(engine, engine.config, "audio",  "screwupvol"),
    ]
    volumeSettingsMenu = Menu.Menu(engine, volumeSettings + applyItem)

    audioSettings = [
      (_("Volume Settings"), volumeSettingsMenu),
      ConfigChoice(engine.config, "audio",  "delay"),
      ConfigChoice(engine.config, "audio",  "frequency"),
      ConfigChoice(engine.config, "audio",  "bits"),
      ConfigChoice(engine.config, "audio",  "buffersize"),
    ]
    audioSettingsMenu = Menu.Menu(engine, audioSettings + applyItem)

    rfModPlayer0Settings = [
      ConfigChoice(engine.config, "player0",  "two_chord_max", autoApply = True),
      ConfigChoice(engine.config, "player0",  "leftymode", autoApply = True),
    ]
    rfModPlayer0SettingsMenu = Menu.Menu(engine, rfModPlayer0Settings)

    rfModPlayer1Settings = [
      ConfigChoice(engine.config, "player1",  "two_chord_max", autoApply = True),
      ConfigChoice(engine.config, "player1",  "leftymode", autoApply = True),
    ]
    rfModPlayer1SettingsMenu = Menu.Menu(engine, rfModPlayer1Settings)    

    rfModHOPOSettings = [
      ConfigChoice(engine.config, "game",  "tapping", autoApply = True),
      HopoConfigChoice(engine.config, "game",  "hopo_mark", autoApply = True),
      HopoConfigChoice(engine.config, "game",  "hopo_style", autoApply = True),
    ]
    rfModHOPOSettingsMenu = Menu.Menu(engine, rfModHOPOSettings)    

    rfModGameSettings = [
      (_("Select Song Library >"), self.baseLibrarySelect), 
      ConfigChoice(engine.config, "game",  "alt_keys", autoApply = True),
      #ConfigChoice(engine.config, "game",  "strum_burst", autoApply = True),
      ConfigChoice(engine.config, "game",  "sort_order", autoApply = True),
      ConfigChoice(engine.config, "game",  "disable_vbpm", autoApply = True),
      ConfigChoice(engine.config, "game", "pov", autoApply = True),
      ConfigChoice(engine.config, "game", "party_time", autoApply = True),
      ConfigChoice(engine.config, "audio", "miss_volume", autoApply = True),
    ]
    rfModGameSettingsMenu = Menu.Menu(engine, rfModGameSettings)
    
    rfModPerfSettings = [
      ConfigChoice(engine.config, "engine",  "game_priority", autoApply = True),
      ConfigChoice(engine.config, "audio", "disable_preview", autoApply = True),
      ConfigChoice(engine.config, "video", "disable_stats", autoApply = True),
      ConfigChoice(engine.config, "video", "disable_notesfx", autoApply = True),
      ConfigChoice(engine.config, "video", "disable_fretsfx", autoApply = True),
      ConfigChoice(engine.config, "video", "disable_flamesfx", autoApply = True),
      ConfigChoice(engine.config, "game", "disable_spinny", autoApply = True),
      ConfigChoice(engine.config, "game", "disable_libcount", autoApply = True),
      ConfigChoice(engine.config, "game", "disable_librotation", autoApply = True),
    ]
    rfModPerfSettingsMenu = Menu.Menu(engine, rfModPerfSettings)

    rfModSettings = [
      ConfigChoice(engine.config, "game",  "players", autoApply = True),
      (_("Game settings"), rfModGameSettingsMenu),
      (_("HO/PO settings"), rfModHOPOSettingsMenu),
      (_("Performance settings"), rfModPerfSettingsMenu),
      (_("Player 1 settings"), rfModPlayer0SettingsMenu),
      (_("Player 2 settings"), rfModPlayer1SettingsMenu),
    ]
    rfModSettingsMenu = Menu.Menu(engine, rfModSettings)

    settings = [
      (_("Game Settings"),     gameSettingsMenu),
      (_("Key Settings"),      keySettingsMenu),
      (_("Video Settings"),    videoSettingsMenu),
      (_("Audio Settings"),    audioSettingsMenu),
      (_("RF-mod Settings"),   rfModSettingsMenu),
    ]
  
    self.settingsToApply = settings + \
                           videoSettings + \
                           audioSettings + \
                           volumeSettings + \
                           gameSettings + \
                           modSettings

    Menu.Menu.__init__(self, engine, settings)
Ejemplo n.º 21
0
    def __init__(self, config = None):
        """
        Constructor.

        @param config:  L{Config} instance for settings
        """

        if not config:
            config = Config.load()

        self.config  = config

        fps          = self.config.get("video", "fps")
        tickrate     = self.config.get("engine", "tickrate")
        Engine.__init__(self, fps = fps, tickrate = tickrate)

        pygame.init()

        self.title             = _("Frets on Fire")
        self.restartRequested  = False
        self.handlingException = False
        self.video             = Video(self.title)
        self.audio             = Audio()

        Log.debug("Initializing audio.")
        frequency    = self.config.get("audio", "frequency")
        bits         = self.config.get("audio", "bits")
        stereo       = self.config.get("audio", "stereo")
        bufferSize   = self.config.get("audio", "buffersize")

        self.audio.pre_open(frequency = frequency, bits = bits, stereo = stereo, bufferSize = bufferSize)
        pygame.init()
        self.audio.open(frequency = frequency, bits = bits, stereo = stereo, bufferSize = bufferSize)

        Log.debug("Initializing video.")
        width, height = [int(s) for s in self.config.get("video", "resolution").split("x")]
        fullscreen    = self.config.get("video", "fullscreen")
        multisamples  = self.config.get("video", "multisamples")
        self.video.setMode((width, height), fullscreen = fullscreen, multisamples = multisamples)

        # Enable the high priority timer if configured
        if self.config.get("engine", "highpriority"):
            Log.debug("Enabling high priority timer.")
            self.timer.highPriority = True

        viewport = glGetIntegerv(GL_VIEWPORT)
        h = viewport[3] - viewport[1]
        w = viewport[2] - viewport[0]
        geometry = (0, 0, w, h)
        self.img = ImgContext(geometry)
        glViewport(int(viewport[0]), int(viewport[1]), int(viewport[2]), int(viewport[3]))

        self.input     = Input()
        self.view      = View(self, geometry)
        self.resizeScreen(w, h)

        self.resource  = Resource(Version.dataPath())
        self.server    = None
        self.sessions  = []
        self.mainloop  = self.loading

        # Load game modifications
        Mod.init(self)
        theme = Config.load(self.resource.fileName("theme.ini"))
        Theme.open(theme)

        # Make sure we are using the new upload URL
        if self.config.get("game", "uploadurl").startswith("http://kempele.fi"):
            self.config.set("game", "uploadurl", "http://fretsonfire.sourceforge.net/play")

        self.addTask(self.audio, synchronized = False)
        self.addTask(self.input, synchronized = False)
        self.addTask(self.view)
        self.addTask(self.resource, synchronized = False)
        self.data = Data(self.resource, self.img)

        self.input.addKeyListener(FullScreenSwitcher(self), priority = True)
        self.input.addSystemEventListener(SystemEventHandler(self))

        self.debugLayer         = None
        self.startupLayer       = None
        self.loadingScreenShown = False

        Log.debug("Ready.")
Ejemplo n.º 22
0
 def __init__(self, modname, mapname ):
     self._shaderProgram = None
     self.layers = TerrainLayer.loadLayers( modname, mapname )
     self._colormapName = Mod.MapPath(modname,mapname) + 'colormap.png'
Ejemplo n.º 23
0
    def __init__(self, config=None):
        """
    Constructor.

    @param config:  L{Config} instance for settings
    """

        if not config:
            config = Config.load()

        self.config = config

        fps = self.config.get("video", "fps")
        tickrate = self.config.get("engine", "tickrate")
        Engine.__init__(self, fps=fps, tickrate=tickrate)

        pygame.init()

        self.title = _("Frets on Fire")
        self.restartRequested = False
        self.handlingException = False
        self.video = Video(self.title)
        self.audio = Audio()

        Log.debug("Initializing audio.")
        frequency = self.config.get("audio", "frequency")
        bits = self.config.get("audio", "bits")
        stereo = self.config.get("audio", "stereo")
        bufferSize = self.config.get("audio", "buffersize")

        self.audio.pre_open(frequency=frequency,
                            bits=bits,
                            stereo=stereo,
                            bufferSize=bufferSize)
        pygame.init()
        self.audio.open(frequency=frequency,
                        bits=bits,
                        stereo=stereo,
                        bufferSize=bufferSize)

        Log.debug("Initializing video.")
        width, height = [
            int(s) for s in self.config.get("video", "resolution").split("x")
        ]
        fullscreen = self.config.get("video", "fullscreen")
        multisamples = self.config.get("video", "multisamples")
        self.video.setMode((width, height),
                           fullscreen=fullscreen,
                           multisamples=multisamples)

        # Enable the high priority timer if configured
        if self.config.get("engine", "highpriority"):
            Log.debug("Enabling high priority timer.")
            self.timer.highPriority = True

        viewport = glGetIntegerv(GL_VIEWPORT)
        h = viewport[3] - viewport[1]
        w = viewport[2] - viewport[0]
        geometry = (0, 0, w, h)
        self.svg = SvgContext(geometry)
        self.svg.setRenderingQuality(self.config.get("opengl", "svgquality"))
        glViewport(int(viewport[0]), int(viewport[1]), int(viewport[2]),
                   int(viewport[3]))

        self.input = Input()
        self.view = View(self, geometry)
        self.resizeScreen(w, h)

        self.resource = Resource(Version.dataPath())
        self.server = None
        self.sessions = []
        self.mainloop = self.loading

        # Load game modifications
        Mod.init(self)
        theme = Config.load(self.resource.fileName("theme.ini"))
        Theme.open(theme)

        # Make sure we are using the new upload URL
        if self.config.get("game",
                           "uploadurl").startswith("http://kempele.fi"):
            self.config.set("game", "uploadurl",
                            "http://fretsonfire.sourceforge.net/play")

        self.addTask(self.audio, synchronized=False)
        self.addTask(self.input, synchronized=False)
        self.addTask(self.view)
        self.addTask(self.resource, synchronized=False)
        self.data = Data(self.resource, self.svg)

        self.input.addKeyListener(FullScreenSwitcher(self), priority=True)
        self.input.addSystemEventListener(SystemEventHandler(self))

        self.debugLayer = None
        self.startupLayer = None
        self.loadingScreenShown = False

        Log.debug("Ready.")
Ejemplo n.º 24
0
    def __init__(self, config=None):

        Log.debug("GameEngine class init (GameEngine.py)...")
        self.mainMenu = None  #placeholder for main menu object - to prevent reinstantiation

        self.currentScene = None

        self.versionString = version  #stump: other version stuff moved to allow full version string to be retrieved without instantiating GameEngine
        self.uploadVersion = "%s-4.0" % Version.PROGRAM_NAME  #akedrou - the version passed to the upload site.

        self.dataPath = Version.dataPath()
        Log.debug(self.versionString + " starting up...")
        Log.debug("Python version: " + sys.version.split(' ')[0])
        Log.debug("Pygame version: " + str(pygame.version.ver))
        Log.debug("PyOpenGL version: " + OpenGL.__version__)
        Log.debug("Numpy version: " + np.__version__)
        Log.debug("PIL version: " + Image.VERSION)
        Log.debug("sys.argv: " + repr(sys.argv))
        Log.debug("os.name: " + os.name)
        Log.debug("sys.platform: " + sys.platform)
        if os.name == 'nt':
            import win32api
            Log.debug("win32api.GetVersionEx(1): " +
                      repr(win32api.GetVersionEx(1)))
        elif os.name == 'posix':
            Log.debug("os.uname(): " + repr(os.uname()))
        """
        Constructor.
        @param config:  L{Config} instance for settings
        """

        self.tutorialFolder = "tutorials"

        if not config:
            config = Config.load()

        self.config = config

        fps = self.config.get("video", "fps")

        self.tasks = []
        self.frameTasks = []
        self.fps = fps
        self.currentTask = None
        self.paused = []
        self.running = True
        self.clock = pygame.time.Clock()

        self.title = self.versionString
        self.restartRequested = False

        # evilynux - Check if theme icon exists first, then fallback on FoFiX icon.
        themename = self.config.get("coffee", "themename")
        themeicon = os.path.join(Version.dataPath(), "themes", themename,
                                 "icon.png")
        fofixicon = os.path.join(Version.dataPath(), "fofix_icon.png")
        icon = None
        if os.path.exists(themeicon):
            icon = themeicon
        elif os.path.exists(fofixicon):
            icon = fofixicon

        self.video = Video(self.title, icon)
        if self.config.get("video", "disable_screensaver"):
            self.video.disableScreensaver()

        self.audio = Audio()
        self.frames = 0
        self.fpsEstimate = 0
        self.priority = self.config.get("engine", "highpriority")
        self.show_fps = self.config.get("video", "show_fps")
        self.advSettings = self.config.get("game", "adv_settings")
        self.restartRequired = False
        self.quicksetRestart = False
        self.quicksetPerf = self.config.get("quickset", "performance")
        self.scrollRate = self.config.get("game", "scroll_rate")
        self.scrollDelay = self.config.get("game", "scroll_delay")

        Log.debug("Initializing audio.")
        frequency = self.config.get("audio", "frequency")
        bits = self.config.get("audio", "bits")
        stereo = self.config.get("audio", "stereo")
        bufferSize = self.config.get("audio", "buffersize")
        self.audio.open(frequency=frequency,
                        bits=bits,
                        stereo=stereo,
                        bufferSize=bufferSize)

        self.cmdPlay = 0
        self.cmdMode = None
        self.cmdDiff = None
        self.cmdPart = None

        self.gameStarted = False
        self.world = None

        self.audioSpeedFactor = 1.0

        Log.debug("Initializing video.")
        #myfingershurt: ensuring windowed mode starts up in center of the screen instead of cascading positions:
        os.environ['SDL_VIDEO_WINDOW_POS'] = 'center'

        width, height = [
            int(s) for s in self.config.get("video", "resolution").split("x")
        ]
        fullscreen = self.config.get("video", "fullscreen")
        multisamples = self.config.get("video", "multisamples")
        self.video.setMode((width, height),
                           fullscreen=fullscreen,
                           multisamples=multisamples)
        Log.debug("OpenGL version: " + glGetString(GL_VERSION))
        Log.debug("OpenGL vendor: " + glGetString(GL_VENDOR))
        Log.debug("OpenGL renderer: " + glGetString(GL_RENDERER))
        Log.debug("OpenGL extensions: " +
                  ' '.join(sorted(glGetString(GL_EXTENSIONS).split())))

        if self.video.default:
            self.config.set("video", "fullscreen", False)
            self.config.set("video", "resolution", "800x600")

        if self.config.get("video", "shader_use"):
            shaders.set(os.path.join(Version.dataPath(), "shaders"))

        # Enable the high priority timer if configured
        if self.priority:
            Log.debug("Enabling high priority timer.")
            self.fps = 0  # High priority

        # evilynux - This was generating an error on the first pass (at least under
        #            GNU/Linux) as the Viewport was not set yet.
        try:
            viewport = glGetIntegerv(GL_VIEWPORT)
        except:
            viewport = [0, 0, width, height]
        h = viewport[3] - viewport[1]
        w = viewport[2] - viewport[0]
        geometry = (0, 0, w, h)
        self.svg = SvgContext(geometry)
        glViewport(int(viewport[0]), int(viewport[1]), int(viewport[2]),
                   int(viewport[3]))

        self.startupMessages = self.video.error
        self.input = Input()
        self.view = View(self, geometry)
        self.resizeScreen(w, h)

        self.resource = Resource(Version.dataPath())
        self.mainloop = self.loading
        self.menuMusic = False

        self.setlistMsg = None

        # Load game modifications
        Mod.init(self)
        self.addTask(self.input, synchronized=False)

        self.addTask(self.view, synchronized=False)

        self.addTask(self.resource, synchronized=False)

        self.data = Data(self.resource, self.svg)

        ##MFH: Animated stage folder selection option
        #<themename>\Stages still contains the backgrounds for when stage rotation is off, and practice.png
        #subfolders under Stages\ will each be treated as a separate animated stage set

        self.stageFolders = []
        currentTheme = themename

        stagespath = os.path.join(Version.dataPath(), "themes", currentTheme,
                                  "backgrounds")
        themepath = os.path.join(Version.dataPath(), "themes", currentTheme)
        if os.path.exists(stagespath):
            self.stageFolders = []
            allFolders = os.listdir(
                stagespath
            )  #this also includes all the stage files - so check to see if there is at least one .png file inside each folder to be sure it's an animated stage folder
            for name in allFolders:
                aniStageFolderListing = []
                thisIsAnAnimatedStageFolder = False
                try:
                    aniStageFolderListing = os.listdir(
                        os.path.join(stagespath, name))
                except Exception:
                    thisIsAnAnimatedStageFolder = False
                for aniFile in aniStageFolderListing:
                    if os.path.splitext(
                            aniFile
                    )[1] == ".png" or os.path.splitext(
                            aniFile
                    )[1] == ".jpg" or os.path.splitext(
                            aniFile
                    )[1] == ".jpeg":  #we've found at least one .png file here, chances are this is a valid animated stage folder
                        thisIsAnAnimatedStageFolder = True
                if thisIsAnAnimatedStageFolder:
                    self.stageFolders.append(name)

            i = len(self.stageFolders)
            if i > 0:  #only set default to first animated subfolder if one exists - otherwise use Normal!
                defaultAniStage = str(self.stageFolders[0])
            else:
                defaultAniStage = "Normal"
            Log.debug("Default animated stage for " + currentTheme +
                      " theme = " + defaultAniStage)
            aniStageOptions = dict([(str(self.stageFolders[n]),
                                     self.stageFolders[n])
                                    for n in range(0, i)])
            aniStageOptions.update({"Normal": _("Slideshow")})
            if i > 1:  #only add Random setting if more than one animated stage exists
                aniStageOptions.update({"Random": _("Random")})
            Config.define("game",
                          "animated_stage_folder",
                          str,
                          defaultAniStage,
                          text=_("Animated Stage"),
                          options=aniStageOptions)

            #MFH: here, need to track and check a new ini entry for last theme - so when theme changes we can re-default animated stage to first found
            lastTheme = self.config.get("game", "last_theme")
            if lastTheme == "" or lastTheme != currentTheme:  #MFH - no last theme, and theme just changed:
                self.config.set("game", "animated_stage_folder",
                                defaultAniStage)  #force defaultAniStage
            self.config.set("game", "last_theme", currentTheme)

            selectedAnimatedStage = self.config.get("game",
                                                    "animated_stage_folder")
            if selectedAnimatedStage != "Normal" and selectedAnimatedStage != "Random":
                if not os.path.exists(
                        os.path.join(stagespath, selectedAnimatedStage)):
                    Log.warn("Selected animated stage folder " +
                             selectedAnimatedStage +
                             " does not exist, forcing Normal.")
                    self.config.set(
                        "game", "animated_stage_folder", "Normal"
                    )  #MFH: force "Standard" currently selected animated stage folder is invalid
        else:
            Config.define("game",
                          "animated_stage_folder",
                          str,
                          "None",
                          text=_("Animated Stage"),
                          options=["None", _("None")])
            Log.warn(
                "No stages\ folder found, forcing None setting for Animated Stage."
            )
            self.config.set(
                "game", "animated_stage_folder",
                "None")  #MFH: force "None" when Stages folder can't be found

        try:
            fp, pathname, description = imp.find_module(
                "CustomTheme", [themepath])
            theme = imp.load_module("CustomTheme", fp, pathname, description)
            self.theme = theme.CustomTheme(themepath, themename)
        except ImportError:
            self.theme = Theme(themepath, themename)

        self.addTask(self.theme)

        self.input.addKeyListener(FullScreenSwitcher(self), priority=True)
        self.input.addSystemEventListener(SystemEventHandler(self))

        self.debugLayer = None
        self.startupLayer = None
        self.loadingScreenShown = False
        self.graphicMenuShown = False

        Log.debug("Ready.")
Ejemplo n.º 25
0
# -*- coding: utf-8 -*-
from com.ericsson.xn.commons import test_logger
import Mod

if __name__ == '__main__':
    test_logger.init('pm_main', 'pm')
    test_logger.info('This is info testing.')
    Mod.foo()
    test_logger.finish()
Ejemplo n.º 26
0
 def fsPath( self ):
     return Mod.MapPath( self.modname, self.mapname)