Fixed: Missing graphics when running from a different working directory.

Open terrain.png and several other files from their location in dataDir instead of from the current directory.
This commit is contained in:
David Vierra 2013-01-29 18:48:31 -10:00
parent 85a7c61c99
commit eb26590fb5
2 changed files with 5 additions and 4 deletions

View File

@ -49,7 +49,7 @@ def alertException(func):
alert("Canceled.")
except pymclevel.infiniteworld.SessionLockLost as e:
alert(e.message + "\n\nYour changes cannot be saved.")
except Exception, e:
logging.exception("Exception:")
if ask("Error during {0}: {1!r}".format(func, e)[:1000], ["Report Error", "Okay"], default=1, cancel=0) == "Report Error":
@ -308,7 +308,7 @@ def loadAlphaTerrainTexture():
except Exception, e:
print repr(e), "while loading texture pack info."
texW, texH, terraindata = loadPNGFile("terrain.png")
texW, texH, terraindata = loadPNGFile(os.path.join(directories.dataDir, "terrain.png"))
def slurpZipExt(zipextfile):
# zipextfile.read() doesn't read all available data
@ -414,6 +414,7 @@ def loadTextureFunc(w, h, ndata):
def loadPNGTexture(filename):
filename = os.path.join(directories.dataDir, filename)
try:
w, h, ndata = loadPNGFile(filename)

View File

@ -12,7 +12,7 @@ def get_version():
except:
return 'unknown'
fin = open('RELEASE-VERSION', 'rb')
fin = open(os.path.join(directories.dataDir, 'RELEASE-VERSION'), 'rb')
v = fin.read().strip()
fin.close()
@ -28,7 +28,7 @@ def get_commit():
except:
return 'unknown'
fin = open('GIT-COMMIT', 'rb')
fin = open(os.path.join(directories.dataDir, 'GIT-COMMIT'), 'rb')
v = fin.read().strip()
fin.close()