mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 00:32:57 -04:00
ParticlePanel: fixed an issue that prevented saving with Python 3
Since in Python 3 `str == bytes` no longer holds true, I modified the source to write a text file, which it actually is, instead of a binary file. Closes #553 Fixes #543
This commit is contained in:
parent
3875cc8259
commit
33d11dba27
@ -163,44 +163,41 @@ class ParticleEffect(NodePath):
|
||||
|
||||
def saveConfig(self, filename):
|
||||
filename = Filename(filename)
|
||||
f = open(filename.toOsSpecific(), 'wb')
|
||||
# Add a blank line
|
||||
f.write('\n')
|
||||
with open(filename.toOsSpecific(), 'w') as f:
|
||||
# Add a blank line
|
||||
f.write('\n')
|
||||
|
||||
# Make sure we start with a clean slate
|
||||
f.write('self.reset()\n')
|
||||
# Make sure we start with a clean slate
|
||||
f.write('self.reset()\n')
|
||||
|
||||
pos = self.getPos()
|
||||
hpr = self.getHpr()
|
||||
scale = self.getScale()
|
||||
f.write('self.setPos(%0.3f, %0.3f, %0.3f)\n' %
|
||||
(pos[0], pos[1], pos[2]))
|
||||
f.write('self.setHpr(%0.3f, %0.3f, %0.3f)\n' %
|
||||
(hpr[0], hpr[1], hpr[2]))
|
||||
f.write('self.setScale(%0.3f, %0.3f, %0.3f)\n' %
|
||||
(scale[0], scale[1], scale[2]))
|
||||
pos = self.getPos()
|
||||
hpr = self.getHpr()
|
||||
scale = self.getScale()
|
||||
f.write('self.setPos(%0.3f, %0.3f, %0.3f)\n' %
|
||||
(pos[0], pos[1], pos[2]))
|
||||
f.write('self.setHpr(%0.3f, %0.3f, %0.3f)\n' %
|
||||
(hpr[0], hpr[1], hpr[2]))
|
||||
f.write('self.setScale(%0.3f, %0.3f, %0.3f)\n' %
|
||||
(scale[0], scale[1], scale[2]))
|
||||
|
||||
# Save all the particles to file
|
||||
num = 0
|
||||
for p in list(self.particlesDict.values()):
|
||||
target = 'p%d' % num
|
||||
num = num + 1
|
||||
f.write(target + ' = Particles.Particles(\'%s\')\n' % p.getName())
|
||||
p.printParams(f, target)
|
||||
f.write('self.addParticles(%s)\n' % target)
|
||||
# Save all the particles to file
|
||||
num = 0
|
||||
for p in list(self.particlesDict.values()):
|
||||
target = 'p%d' % num
|
||||
num = num + 1
|
||||
f.write(target + ' = Particles.Particles(\'%s\')\n' % p.getName())
|
||||
p.printParams(f, target)
|
||||
f.write('self.addParticles(%s)\n' % target)
|
||||
|
||||
# Save all the forces to file
|
||||
num = 0
|
||||
for fg in list(self.forceGroupDict.values()):
|
||||
target = 'f%d' % num
|
||||
num = num + 1
|
||||
f.write(target + ' = ForceGroup.ForceGroup(\'%s\')\n' % \
|
||||
fg.getName())
|
||||
fg.printParams(f, target)
|
||||
f.write('self.addForceGroup(%s)\n' % target)
|
||||
|
||||
# Close the file
|
||||
f.close()
|
||||
# Save all the forces to file
|
||||
num = 0
|
||||
for fg in list(self.forceGroupDict.values()):
|
||||
target = 'f%d' % num
|
||||
num = num + 1
|
||||
f.write(target + ' = ForceGroup.ForceGroup(\'%s\')\n' % \
|
||||
fg.getName())
|
||||
fg.printParams(f, target)
|
||||
f.write('self.addForceGroup(%s)\n' % target)
|
||||
|
||||
def loadConfig(self, filename):
|
||||
data = vfs.readFile(filename, 1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user