コード例 #1
0
ファイル: GMH.py プロジェクト: ShadeAnimator/GMHelper
def saveGameAs():
    config = dataFiles.configFile
    path  = str(dataFiles.config_path) if not dataFiles.first_save_load \
        else os.path.join(
            os.path.dirname(dataFiles.config_path),
            'saved_games',
            'untitled.cfg')
    saves_dir = os.path.dirname(path)
    print("GUU: %s"%path)
    #ask for new name
    newName = QtGui.QFileDialog.getSaveFileName(window, 'Save game as... (Create new config file and data files)', path, selectedFilter='*.cfg', filter='*.cfg')
    if newName:
        newName = str(newName)
        log ("New name is: "+ newName)
    #write new file names into cfg dict
    config['Items'] = \
        os.path.basename(newName).replace('.cfg','')+'_items.txt'
    config['Actions'] = \
        os.path.basename(newName).replace('.cfg','')+'_actions.txt'
    config['Characters'] = \
        os.path.basename(newName).replace('.cfg','')+'_chars.txt'
    #save new cfg dict with new name
    dataFiles.saveJSON(newName, config)
    #save data files with new names
    dataFiles.saveJSON (os.path.join(saves_dir, config['Characters']), dataFiles.Characters)
    dataFiles.saveJSON(os.path.join(saves_dir, config['Actions']),dataFiles.Actions)
    dataFiles.saveJSON(os.path.join(saves_dir, config['Items']), dataFiles.Items)
    window.setWindowTitle('GMH - '+newName)
    dataFiles.first_save_load = False
    log ("Game saved as %s"%newName)
コード例 #2
0
def saveGameAs():
    config = dataFiles.configFile
    path  = str(dataFiles.config_path) if not dataFiles.first_save_load \
        else os.path.join(
            os.path.dirname(dataFiles.config_path),
            'saved_games',
            'untitled.cfg')
    saves_dir = os.path.dirname(path)
    print("GUU: %s" % path)
    #ask for new name
    newName = QtGui.QFileDialog.getSaveFileName(
        window,
        'Save game as... (Create new config file and data files)',
        path,
        selectedFilter='*.cfg',
        filter='*.cfg')
    if newName:
        newName = str(newName)
        log("New name is: " + newName)
    #write new file names into cfg dict
    config['Items'] = \
        os.path.basename(newName).replace('.cfg','')+'_items.txt'
    config['Actions'] = \
        os.path.basename(newName).replace('.cfg','')+'_actions.txt'
    config['Characters'] = \
        os.path.basename(newName).replace('.cfg','')+'_chars.txt'
    #save new cfg dict with new name
    dataFiles.saveJSON(newName, config)
    #save data files with new names
    dataFiles.saveJSON(os.path.join(saves_dir, config['Characters']),
                       dataFiles.Characters)
    dataFiles.saveJSON(os.path.join(saves_dir, config['Actions']),
                       dataFiles.Actions)
    dataFiles.saveJSON(os.path.join(saves_dir, config['Items']),
                       dataFiles.Items)
    window.setWindowTitle('GMH - ' + newName)
    dataFiles.first_save_load = False
    log("Game saved as %s" % newName)
コード例 #3
0
ファイル: charOps.py プロジェクト: hades-imagine/GMHelper
def saveAllChars(data):
    dataFiles.saveJSON(dataFiles.configFile['Characters'], data)
コード例 #4
0
ファイル: charOps.py プロジェクト: ShadeAnimator/GMHelper
def saveAllChars(data):
    dataFiles.saveJSON(dataFiles.configFile['Characters'], data)