Mercurial > LightClone
changeset 52:2444937929ae
Update map building script
author | koryspansel <koryspansel@bendbroadband.com> |
---|---|
date | Tue, 27 Sep 2011 13:30:10 -0700 |
parents | efd2b1ca5b77 |
children | 8cefb65577cc |
files | Assets/Maps/map04.def Data/Maps/map04.map LightClone/LightClone.vcproj LightTools/build.py |
diffstat | 4 files changed, 155 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/Assets/Maps/map04.def Tue Sep 27 09:42:01 2011 -0700 +++ b/Assets/Maps/map04.def Tue Sep 27 13:30:10 2011 -0700 @@ -3,11 +3,11 @@ # 7,7 -0,0 +1,0 0 (1,1)(1,1)(1,1)(1,1)(1,1)(1,1)(1,1) -(1,1)(1,0)(1,0)(1,0)(1,0)(1,0)(1,1) +(1,0)(1,0)(1,0)(1,0)(1,0)(1,0)(1,1) (1,1)(1,0)(1,0)(1,0)(1,0)(1,0)(1,1) (1,1)(1,0)(1,0)(1,0)(1,0)(1,0)(1,1) (1,1)(1,0)(1,0)(1,0)(1,0)(1,0)(1,1)
--- a/LightClone/LightClone.vcproj Tue Sep 27 09:42:01 2011 -0700 +++ b/LightClone/LightClone.vcproj Tue Sep 27 13:30:10 2011 -0700 @@ -28,6 +28,8 @@ /> <Tool Name="VCCustomBuildTool" + Description="" + CommandLine="" /> <Tool Name="VCXMLDataGeneratorTool" @@ -88,6 +90,8 @@ /> <Tool Name="VCPostBuildEventTool" + Description="" + CommandLine="" /> </Configuration> <Configuration @@ -103,6 +107,8 @@ /> <Tool Name="VCCustomBuildTool" + Description="" + CommandLine="" /> <Tool Name="VCXMLDataGeneratorTool" @@ -165,6 +171,8 @@ /> <Tool Name="VCPostBuildEventTool" + Description="" + CommandLine="LightTools\Build.py" /> </Configuration> </Configurations> @@ -500,22 +508,132 @@ <File RelativePath="..\Assets\Maps\map00.def" > + <FileConfiguration + Name="Debug|Win32" + > + <Tool + Name="VCCustomBuildTool" + Description="Building $(InputName)..." + CommandLine="$(SolutionDir)LightTools\Build.py $(InputName).def" + AdditionalDependencies="$(SolutionDir)Assets\Maps\$(InputName).def" + Outputs="$(SolutionDir)Data\Maps\$(InputName).map" + /> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + > + <Tool + Name="VCCustomBuildTool" + Description="Building $(InputName)..." + CommandLine="$(SolutionDir)LightTools\Build.py $(InputName).def" + AdditionalDependencies="$(SolutionDir)Assets\Maps\$(InputName).def" + Outputs="$(SolutionDir)Data\Maps\$(InputName).map" + /> + </FileConfiguration> </File> <File RelativePath="..\Assets\Maps\map01.def" > + <FileConfiguration + Name="Debug|Win32" + > + <Tool + Name="VCCustomBuildTool" + Description="Building $(InputName)..." + CommandLine="$(SolutionDir)LightTools\Build.py $(InputName).def" + AdditionalDependencies="$(SolutionDir)Assets\Maps\$(InputName).def" + Outputs="$(SolutionDir)Data\Maps\$(InputName).map" + /> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + > + <Tool + Name="VCCustomBuildTool" + Description="Building $(InputName)..." + CommandLine="$(SolutionDir)LightTools\Build.py $(InputName).def" + AdditionalDependencies="$(SolutionDir)Assets\Maps\$(InputName).def" + Outputs="$(SolutionDir)Data\Maps\$(InputName).map" + /> + </FileConfiguration> </File> <File RelativePath="..\Assets\Maps\map02.def" > + <FileConfiguration + Name="Debug|Win32" + > + <Tool + Name="VCCustomBuildTool" + Description="Building $(InputName)..." + CommandLine="$(SolutionDir)LightTools\Build.py $(InputName).def" + AdditionalDependencies="$(SolutionDir)Assets\Maps\$(InputName).def" + Outputs="$(SolutionDir)Data\Maps\$(InputName).map" + /> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + > + <Tool + Name="VCCustomBuildTool" + Description="Building $(InputName)..." + CommandLine="$(SolutionDir)LightTools\Build.py $(InputName).def" + AdditionalDependencies="$(SolutionDir)Assets\Maps\$(InputName).def" + Outputs="$(SolutionDir)Data\Maps\$(InputName).map" + /> + </FileConfiguration> </File> <File RelativePath="..\Assets\Maps\map03.def" > + <FileConfiguration + Name="Debug|Win32" + > + <Tool + Name="VCCustomBuildTool" + Description="Building $(InputName)..." + CommandLine="$(SolutionDir)LightTools\Build.py $(InputName).def" + AdditionalDependencies="$(SolutionDir)Assets\Maps\$(InputName).def" + Outputs="$(SolutionDir)Data\Maps\$(InputName).map" + /> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + > + <Tool + Name="VCCustomBuildTool" + Description="Building $(InputName)..." + CommandLine="$(SolutionDir)LightTools\Build.py $(InputName).def" + AdditionalDependencies="$(SolutionDir)Assets\Maps\$(InputName).def" + Outputs="$(SolutionDir)Data\Maps\$(InputName).map" + /> + </FileConfiguration> </File> <File RelativePath="..\Assets\Maps\map04.def" > + <FileConfiguration + Name="Debug|Win32" + > + <Tool + Name="VCCustomBuildTool" + Description="Building $(InputName)..." + CommandLine="$(SolutionDir)LightTools\Build.py $(InputName).def" + AdditionalDependencies="$(SolutionDir)Assets\Maps\$(InputName).def" + Outputs="$(SolutionDir)Data\Maps\$(InputName).map" + /> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + > + <Tool + Name="VCCustomBuildTool" + Description="Building $(InputName)..." + CommandLine="$(SolutionDir)LightTools\Build.py $(InputName).def" + AdditionalDependencies="$(SolutionDir)Assets\Maps\$(InputName).def" + Outputs="$(SolutionDir)Data\Maps\$(InputName).map" + /> + </FileConfiguration> </File> </Filter> </Filter>
--- a/LightTools/build.py Tue Sep 27 09:42:01 2011 -0700 +++ b/LightTools/build.py Tue Sep 27 13:30:10 2011 -0700 @@ -33,22 +33,7 @@ return map(int, self.Parse(line)) def _ParseList(self, lines): - #return [self._ParseVector(line) for line in lines] - tuples = [] - - #print ''.join(lines) - #print _pattern.split(''.join(lines)) - - for item in _pattern.finditer(''.join(lines)): - #print item.groups() - #tuples.append((int(item.group(1)), int(item.group(2)))) - tuples.append(map(int, item.groups())) - - #print tuples - return tuples - #print tuples - - #return [map(int, item.groups()) for item in _pattern.finditer(''.join(lines))] + return [map(int, item.groups()) for item in _pattern.finditer(''.join(lines))] def ReadDefinition(filename): def FilterLines(lines): @@ -68,25 +53,46 @@ return MapDefinition(size, position, direction, grid) +def Compile(input_map, output_map): + if os.path.isfile(input_map): + definition = ReadDefinition(input_map) + if not definition: + print 'Failed to read definition "%s"' % input_map + + else: + folder = os.path.dirname(output_map) + + if not os.path.isdir(folder): + os.makedirs(folder) + + print 'Building %s from %s' % (os.path.basename(output_map), os.path.basename(input_map)) + definition.Write(output_map) + if __name__ == '__main__': path_root = os.path.dirname(sys.argv[0]) path_assets = os.path.abspath(os.path.join(path_root, '..', 'Assets', 'Maps')) path_build = os.path.abspath(os.path.join(path_root, '..', 'Data', 'Maps')) - if os.path.isdir(path_assets): - for filename in os.listdir(path_assets): - if not filename.endswith('.def'): - continue + if len(sys.argv) > 1: + Compile(os.path.join(path_assets, sys.argv[1]), os.path.join(path_build, os.path.splitext(sys.argv[1])[0] + '.map')) + + else: - definition = ReadDefinition(os.path.join(path_assets, filename)) - if not definition: - continue + if os.path.isdir(path_assets): + for filename in os.listdir(path_assets): + if not filename.endswith('.def'): + continue - output = os.path.join(path_build, os.path.splitext(filename)[0] + '.map') - folder = os.path.dirname(output) + Compile(os.path.join(path_assets, filename), os.path.join(path_build, os.path.splitext(filename)[0] + '.map')) + #definition = ReadDefinition(os.path.join(path_assets, filename)) + #if not definition: + # continue - if not os.path.isdir(folder): - os.makedirs(folder) + #output = os.path.join(path_build, os.path.splitext(filename)[0] + '.map') + #folder = os.path.dirname(output) - print 'Building %s from %s' % (os.path.basename(output), os.path.basename(filename)) - definition.Write(output) + #if not os.path.isdir(folder): + # os.makedirs(folder) + + #print 'Building %s from %s' % (os.path.basename(output), os.path.basename(filename)) + #definition.Write(output)