Example #1
0
def WorkingDir():
    """
    Finds the appropriate working directory for temporary files.
    Makes it in the resources directory if not existing.
    """
    folderName = 'latex_workingdir'
    workingDir = resource('resources',folderName)
    if workingDir is not None:
        return workingDir
    workingDir = os.path.join(resource('resources'),
                              folderName)
    os.makedirs(workingDir)
    return workingDir
Example #2
0
def LatexString(char):
    latexChar = open(resource('resources','char.tex')).read()
    latexChar = multiple_replace({'PYCHARGEN_STATS_OVERVIEW':_statsString(char),
                                  'PYCHARGEN_COMMON_SKILLS_OVERVIEW':_skillOverviewString(char),
                                  'PYCHARGEN_RESISTANCES_OVERVIEW':_resistanceString(char),
                                  'PYCHARGEN_SKILL_FULLLIST':_skillFullListString(char),
                                  'PYCHARGEN_CHARACTER_NAME':char.GetMisc('Name'),
                                  'PYCHARGEN_LEVEL':str(char.GetMisc('Level')),
                                  'PYCHARGEN_PROFESSION':char.GetMisc('Profession'),
                                  },latexChar)
    return latexChar
Example #3
0
def FindExecutable():
    """Attempts to find the latex executable"""
    if sys.platform=='win32':
        #executable = resource('resources','pdflatex.exe')
        executable = resource('resources','texlive-small','bin','win32','pdflatex.exe')
        if executable is None:
            raise EnvironmentError("""Could not find resources\pdflatex.exe""")
    else:
        executable = 'pdflatex'
        with open(os.devnull,'w') as devnull:
            if subprocess.call(['which',executable],stdout=devnull,stdin=devnull):
                raise EnvironmentError("""Could not find pdflatex.  Please install using 'sudo apt-get texlive-latex-base'""")
    return executable
Example #4
0
    def __init__(self):
        builderfile = resource('resources','MainWindow.ui')
        self.char = None
        self.changed_since_save = False

        self.b = gtk.Builder()
        self.b.add_from_file(builderfile)
        self.window = self['mainWindow']
        self.window.connect('delete_event',self.Exit)

        #Menu commands
        self.Connect(self['fileNew'],'activate',self.New)
        self.Connect(self['fileOpen'],'activate',self.Open)
        self.Connect(self['fileSave'],'activate',self.Save)
        self.Connect(self['fileSaveAs'],'activate',self.SaveAs)
        self.Connect(self['fileExport'],'activate',self.Export)
        self.Connect(self['fileQuit'],'activate',self.Exit)
        self.Connect(self['actionLevelUp'],'activate',self.FromLevelUp)
        self.Connect(self.window,'key-press-event',self.KeyPressEvent)
        #The About window.
        self.Connect(self['helpAbout'],'activate',self.ShowAbout)
        self.Connect(self['aboutWindow'],'delete_event',self.HideAbout)
        self.Connect(self['aboutOkay'],'clicked',self.HideAbout)
        #Updating overview text boxes
        self.Connect(self['characterName'],'changed',self.FromNameChange)
        self.Connect(self['playerName'],'changed',self.FromPlayerNameChange)
        self.Connect(self['experience'],'changed',self.FromXPChange)
        #Skill right-clicking commands
        self.Connect(self['skillView'],'button-press-event',self.FromSkillRightClick)
        self.Connect(self['rcAddChildSkill'],'button-press-event',self.FromAddChildSkill)
        self.Connect(self['rcAddSiblingSkill'],'button-press-event',self.FromAddSiblingSkill)
        self.Connect(self['rcDeleteSkill'],'button-press-event',self.FromRemoveSkill)
        #Item modifying commands
        self.Connect(self['itemView'],'button-press-event',self.FromItemRightClick)
        self.Connect(self['rcAddItem'],'button-press-event',self.FromAddItem)
        self.Connect(self['newItemButton'],'clicked',self.FromAddItem)
        self.Connect(self['rcDeleteItem'],'button-press-event',self.FromRemoveBonus)
        self.Connect(self['deleteBonusButton'],'clicked',self.FromRemoveBonus)
        #Talent/Flaw modifying commands
        self.Connect(self['talentView'],'button-press-event',self.FromTalentRightClick)
        self.Connect(self['rcAddTalent'],'button-press-event',self.FromAddTalent)
        self.Connect(self['newTalentButton'],'clicked',self.FromAddTalent)
        self.Connect(self['rcDeleteTalent'],'button-press-event',self.FromRemoveBonus)
        #Character progression
        self.Connect(self['startingCharacterNextButton'],'clicked',self.NextTab)
        self.Connect(self['statNextButton'],'clicked',self.NextTab)
        self.Connect(self['skillLevelUpButton'],'clicked',self.FromLevelUp)

        #Stat modifications.
        self.activeStat = None
        self.SetUpStatView()
        self.FromStatSelected()
        self.Connect(self['statView'],'cursor-changed',self.FromStatSelected)
        self.Connect(self['statNameBox'],'changed',self.FromActiveStatNameChange)
        self.Connect(self['statCurrentBox'],'changed',self.FromActiveStatCurrentChange)
        self.Connect(self['statPotentialBox'],'changed',self.FromActiveStatPotentialChange)
        self.Connect(self['statDescriptionBox'].get_buffer(),
                     'changed',self.FromActiveStatDescriptionChange)
        self.Connect(self['levellingStatGain'],'changed',self.FromActiveStatLevellingChange)
        self.Connect(self['levellingStatGain'],'value-changed',self.FromActiveStatLevellingChange)

        #Skill modifications
        self.activeSkill = None
        self.SetUpSkillView()
        self.FromSkillSelected()
        self.SetUpCommonlyUsedSkillView()
        self.Connect(self['skillView'],'cursor-changed',self.FromSkillSelected)
        self.Connect(self['skillNameBox'],'changed',self.FromActiveSkillNameChange)
        self.Connect(self['skillRankBox'],'changed',self.FromActiveSkillRankChange)
        self.Connect(self['skillDescriptionBox'].get_buffer(),
                     'changed',self.FromActiveSkillDescriptionChange)
        self.Connect(self['skillView'],'drag-data-received',self.FromSkillReordered,False)

        #Weapon reorderings
        self.SetUpWeaponSkillView()
        self.Connect(self['weaponOrderingView'],'drag-data-received',self.FromSkillReordered,True)

        #Item, Talent/Flaw modifications
        self.activeBonus = None
        self.MakeTalentList()
        self.SetUpItemView()
        self.SetUpTalentView()
        self.FromItemSelected()
        self.Connect(self['itemView'],'cursor-changed',self.FromItemSelected)
        self.Connect(self['talentView'],'cursor-changed',self.FromTalentSelected)
        self.Connect(self['bonusNameBox'],'changed',self.FromActiveBonusNameChange)
        self.Connect(self['bonusBonusBox'],'changed',self.FromActiveBonusBonusChange)
        self.Connect(self['bonusEnabledButton'],'toggled',self.FromActiveBonusEnabledChange)
        self.Connect(self['bonusDescriptionBox'].get_buffer(),'changed',self.FromActiveBonusDescriptionChange)

        #Profession setup
        self.MakeProfessionList()
        self.Connect(self['profBox'],'changed',self.FromProfessionSelect)

        #Culture setup
        self.MakeCultureList()
        self.Connect(self['cultureBox'],'changed',self.FromCultureSelect)

        #Race setup
        self.MakeRaceList()
        self.Connect(self['raceBox'],'changed',self.FromRaceSelect)

        #Set up a default character.
        self.registered = []
        self.LoadFile(resource('tables','BaseChar.txt'))
        self.filename = None
Example #5
0
 def MakeTalentList(self):
     self._talents = Parser.talentFile(resource('tables','Talents.txt'))
     talentBox = self['talentBox']
     combobox_boilerplate(talentBox)
     for talent in self._talents:
         talentBox.append_text(talent.Name)
Example #6
0
 def MakeRaceList(self):
     self._races = Parser.raceFile(resource('tables','Races.txt'))
     raceBox = self['raceBox']
     combobox_boilerplate(raceBox)
     for race in self._races:
         raceBox.append_text(race.Name)
Example #7
0
 def MakeCultureList(self):
     self._cultures = Parser.cultureFile(resource('tables','Cultures.txt'))
     cultureBox = self['cultureBox']
     combobox_boilerplate(cultureBox)
     for proto in self._cultures:
         cultureBox.append_text(proto.Name)
Example #8
0
 def MakeProfessionList(self):
     self._professions = Parser.professionFile(resource('tables','Professions.txt'))
     profBox = self['profBox']
     combobox_boilerplate(profBox)
     for prof in self._professions:
         profBox.append_text(prof.Name)
Example #9
0
 def New(self,*args):
     if self.OkayWithoutSaving():
         self.LoadFile(resource('tables','BaseChar.txt'))
         self['mainTabs'].set_current_page(1)
         self.changed_since_save = False