mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
level editor uses CVS directories
This commit is contained in:
parent
0821c7c48a
commit
e766a6bb62
@ -21,6 +21,12 @@ import __builtin__
|
|||||||
|
|
||||||
visualizeZones = base.config.GetBool("visualize-zones", 0)
|
visualizeZones = base.config.GetBool("visualize-zones", 0)
|
||||||
|
|
||||||
|
# Temporary try..except for old Pandas.
|
||||||
|
try:
|
||||||
|
dnaDirectory = Filename.expandFrom(base.config.GetString("dna-directory", "$TTMODELS/src/dna"))
|
||||||
|
except:
|
||||||
|
dnaDirectory = Filename.fromOsSpecific(base.config.GetString("dna-directory", "/"))
|
||||||
|
|
||||||
# Colors used by all color menus
|
# Colors used by all color menus
|
||||||
DEFAULT_COLORS = [
|
DEFAULT_COLORS = [
|
||||||
Vec4(1,1,1,1),
|
Vec4(1,1,1,1),
|
||||||
@ -2360,9 +2366,7 @@ class LevelEditor(NodePath, PandaObject):
|
|||||||
|
|
||||||
# STYLE/DNA FILE FUNCTIONS
|
# STYLE/DNA FILE FUNCTIONS
|
||||||
def loadSpecifiedDNAFile(self):
|
def loadSpecifiedDNAFile(self):
|
||||||
f = Filename(self.styleManager.stylePathPrefix +
|
path = dnaDirectory.toOsSpecific()
|
||||||
'/alpha/DIRECT/LevelEditor/DNAFiles')
|
|
||||||
path = os.path.join(f.toOsSpecific(), self.outputDir)
|
|
||||||
if not os.path.isdir(path):
|
if not os.path.isdir(path):
|
||||||
print 'LevelEditor Warning: Invalid default DNA directory!'
|
print 'LevelEditor Warning: Invalid default DNA directory!'
|
||||||
print 'Using current directory'
|
print 'Using current directory'
|
||||||
@ -2377,9 +2381,7 @@ class LevelEditor(NodePath, PandaObject):
|
|||||||
self.loadDNAFromFile(dnaFilename)
|
self.loadDNAFromFile(dnaFilename)
|
||||||
|
|
||||||
def saveToSpecifiedDNAFile(self):
|
def saveToSpecifiedDNAFile(self):
|
||||||
f = Filename(self.styleManager.stylePathPrefix +
|
path = dnaDirectory.toOsSpecific()
|
||||||
'/alpha/DIRECT/LevelEditor/DNAFiles')
|
|
||||||
path = os.path.join(f.toOsSpecific(), self.outputDir)
|
|
||||||
if not os.path.isdir(path):
|
if not os.path.isdir(path):
|
||||||
print 'LevelEditor Warning: Invalid DNA save directory!'
|
print 'LevelEditor Warning: Invalid DNA save directory!'
|
||||||
print 'Using current directory'
|
print 'Using current directory'
|
||||||
@ -2433,9 +2435,7 @@ class LevelEditor(NodePath, PandaObject):
|
|||||||
self.panel.sceneGraphExplorer.update()
|
self.panel.sceneGraphExplorer.update()
|
||||||
|
|
||||||
def outputDNADefaultFile(self):
|
def outputDNADefaultFile(self):
|
||||||
f = Filename(self.styleManager.stylePathPrefix +
|
file = os.path.join(dnaDirectory.toOsSpecific(), self.outputFile)
|
||||||
'/alpha/DIRECT/LevelEditor/DNAFiles')
|
|
||||||
file = os.path.join(f.toOsSpecific(), self.outputDir, self.outputFile)
|
|
||||||
self.outputDNA(file)
|
self.outputDNA(file)
|
||||||
|
|
||||||
def outputDNA(self,filename):
|
def outputDNA(self,filename):
|
||||||
@ -2467,10 +2467,9 @@ class LevelEditor(NodePath, PandaObject):
|
|||||||
return
|
return
|
||||||
# Valid type, add color to file
|
# Valid type, add color to file
|
||||||
filename = self.neighborhood + '_colors.txt'
|
filename = self.neighborhood + '_colors.txt'
|
||||||
fname = Filename(self.styleManager.stylePathPrefix +
|
fname = Filename(dnaDirectory.getFullpath() +
|
||||||
'/alpha/DIRECT/LevelEditor/StyleFiles/' +
|
'/stylefiles/' + filename)
|
||||||
filename)
|
f = open(fname.toOsSpecific(), 'ab')
|
||||||
f = open(fname.toOsSpecific(), 'a')
|
|
||||||
f.write('%s Vec4(%.2f, %.2f, %.2f, 1.0)\n' %
|
f.write('%s Vec4(%.2f, %.2f, %.2f, 1.0)\n' %
|
||||||
(tag,
|
(tag,
|
||||||
color[0]/255.0,
|
color[0]/255.0,
|
||||||
@ -2478,37 +2477,34 @@ class LevelEditor(NodePath, PandaObject):
|
|||||||
color[2]/255.0))
|
color[2]/255.0))
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
def saveStyle(self, filename, style):
|
||||||
|
# A generic routine to append a new style definition to one of
|
||||||
|
# the style files.
|
||||||
|
|
||||||
|
fname = Filename(dnaDirectory.getFullpath() +
|
||||||
|
'/stylefiles/' + filename)
|
||||||
|
# We use binary mode to avoid Windows' end-of-line convention
|
||||||
|
f = open(fname.toOsSpecific(), 'ab')
|
||||||
|
# Add a blank line
|
||||||
|
f.write('\n')
|
||||||
|
# Now output style details to file
|
||||||
|
style.output(f)
|
||||||
|
# Close the file
|
||||||
|
f.close()
|
||||||
|
|
||||||
def saveBaselineStyle(self):
|
def saveBaselineStyle(self):
|
||||||
if self.panel.currentBaselineDNA:
|
if self.panel.currentBaselineDNA:
|
||||||
# Valid baseline, add style to file
|
# Valid baseline, add style to file
|
||||||
filename = self.neighborhood + '_baseline_styles.txt'
|
filename = self.neighborhood + '_baseline_styles.txt'
|
||||||
fname = Filename(self.styleManager.stylePathPrefix +
|
style = DNABaselineStyle(self.panel.currentBaselineDNA)
|
||||||
'/alpha/DIRECT/LevelEditor/StyleFiles/' +
|
self.saveStyle(filename, style)
|
||||||
filename)
|
|
||||||
f = open(fname.toOsSpecific(), 'a')
|
|
||||||
# Add a blank line
|
|
||||||
f.write('\n')
|
|
||||||
# Now output style details to file
|
|
||||||
style = DNABaselineStyle(baseline = self.panel.currentBaselineDNA)
|
|
||||||
style.output(f)
|
|
||||||
# Close the file
|
|
||||||
f.close()
|
|
||||||
|
|
||||||
def saveWallStyle(self):
|
def saveWallStyle(self):
|
||||||
if self.lastWall:
|
if self.lastWall:
|
||||||
# Valid wall, add style to file
|
# Valid wall, add style to file
|
||||||
filename = self.neighborhood + '_wall_styles.txt'
|
filename = self.neighborhood + '_wall_styles.txt'
|
||||||
fname = Filename(self.styleManager.stylePathPrefix +
|
style = DNAWallStyle(self.lastWall)
|
||||||
'/alpha/DIRECT/LevelEditor/StyleFiles/' +
|
self.saveStyle(filename, style)
|
||||||
filename)
|
|
||||||
f = open(fname.toOsSpecific(), 'a')
|
|
||||||
# Add a blank line
|
|
||||||
f.write('\n')
|
|
||||||
# Now output style details to file
|
|
||||||
style = DNAWallStyle(wall = self.lastWall)
|
|
||||||
style.output(f)
|
|
||||||
# Close the file
|
|
||||||
f.close()
|
|
||||||
|
|
||||||
def saveBuildingStyle(self):
|
def saveBuildingStyle(self):
|
||||||
dnaObject = self.selectedDNARoot
|
dnaObject = self.selectedDNARoot
|
||||||
@ -2516,17 +2512,8 @@ class LevelEditor(NodePath, PandaObject):
|
|||||||
if DNAClassEqual(dnaObject, DNA_FLAT_BUILDING):
|
if DNAClassEqual(dnaObject, DNA_FLAT_BUILDING):
|
||||||
# Valid wall, add style to file
|
# Valid wall, add style to file
|
||||||
filename = self.neighborhood + '_building_styles.txt'
|
filename = self.neighborhood + '_building_styles.txt'
|
||||||
fname = Filename(self.styleManager.stylePathPrefix +
|
style = DNAFlatBuildingStyle(dnaObject)
|
||||||
'/alpha/DIRECT/LevelEditor/StyleFiles/' +
|
self.saveStyle(filename, style)
|
||||||
filename)
|
|
||||||
f = open(fname.toOsSpecific(), 'a')
|
|
||||||
# Add a blank line
|
|
||||||
f.write('\n')
|
|
||||||
# Now output style details to file
|
|
||||||
style = DNAFlatBuildingStyle(building = dnaObject)
|
|
||||||
style.output(f)
|
|
||||||
# Close the file
|
|
||||||
f.close()
|
|
||||||
return
|
return
|
||||||
print 'Must select building before saving building style'
|
print 'Must select building before saving building style'
|
||||||
|
|
||||||
@ -3168,8 +3155,6 @@ class LevelEditor(NodePath, PandaObject):
|
|||||||
class LevelStyleManager:
|
class LevelStyleManager:
|
||||||
"""Class which reads in style files and manages class variables"""
|
"""Class which reads in style files and manages class variables"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
# Used to locate the alpha mount on windows (i.e. on what drive)
|
|
||||||
self.stylePathPrefix = base.config.GetString('style-path-prefix', '')
|
|
||||||
# The main dictionary holding all attribute objects
|
# The main dictionary holding all attribute objects
|
||||||
self.attributeDictionary = {}
|
self.attributeDictionary = {}
|
||||||
# Create the style samples
|
# Create the style samples
|
||||||
@ -4009,10 +3994,11 @@ class LevelStyleManager:
|
|||||||
Open the specified file and strip out unwanted whitespace and
|
Open the specified file and strip out unwanted whitespace and
|
||||||
empty lines. Return file as list, one file line per element.
|
empty lines. Return file as list, one file line per element.
|
||||||
"""
|
"""
|
||||||
fname = Filename(self.stylePathPrefix +
|
fname = Filename(dnaDirectory.getFullpath() +
|
||||||
'/alpha/DIRECT/LevelEditor/StyleFiles/' +
|
'/stylefiles/' + filename)
|
||||||
filename)
|
|
||||||
f = open(fname.toOsSpecific(), 'r')
|
# We use binary mode to avoid Windows' end-of-line convention
|
||||||
|
f = open(fname.toOsSpecific(), 'rb')
|
||||||
rawData = f.readlines()
|
rawData = f.readlines()
|
||||||
f.close()
|
f.close()
|
||||||
styleData = []
|
styleData = []
|
||||||
|
Loading…
x
Reference in New Issue
Block a user