Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<p>If you want a bug to be fixed, open up an issue on the Github Repo and describe the issue, with steps to reproduce, operating system information, and/or terminal logs if applicable. If the program doesn't automatically open up with a terminal by default, then open up a terminal either by right-clicking and clicking 'Open in Terminal' in the context menu that pops up on Linux systems or on Windows systems, click the bar that shows the path to Snark and type 'cmd', then type in the name of the executable and hit enter (on Linux systems you need to type in './' before the executable name, otherwise the system will think it's a terminal command and not an executable). If it is a feature request, tag it as a feature request and describe what you want to have implemented into Snark. You can check the <a href="https://github.com/users/PostScriptReal/projects/1">Official Snark Development Tracker</a> to see your bug report or feature request while it's in progress.</p>
<br>
<h2>External Libraries/Programs Used</h2>
<p>Snark uses some open-source libraries for proper usage, these libraries along with their licenses are shown in the table below:</p>
<p>Snark uses some libraries for proper usage, these libraries along with their licenses are shown in the table below:</p>
<table>
<tr>
<th>Library/Program</th>
Expand All @@ -65,5 +65,9 @@
<td><a href="https://github.com/jfcarter2358/jsonc">jsonc</a></td>
<td>MIT</td>
</tr>
<tr>
<td><a href="http://geckons.com/halflife/">GeckoN's v6 MDL Decompiler</a></td>
<td>Proprietary</td>
</tr>
</table>
</div>
255 changes: 139 additions & 116 deletions helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,50 +150,85 @@ def __init__(self, qc):
self.qcLoc = os.path.dirname(qc)
self.cbarFrmt = False

def crowbarFormatCheck(self):
def relPathCheck(self):
checks = 0
count = -1
cd = False
cdTex = 0
cd = ""
cdTex = ""
newCD = ""
cdRef = 0
cdLoc = 0
newCDtex = ""
cdTexR = 0
cdTexLoc = 0
self.newQC = self.qcf
self.newQCPath = ""
while checks < 2:
count += 1
qcL = self.qcf[count]
if qcL.startswith("$cdtex"):
if qcL.find('\"./textures/\"') != -1:
cdTex = 1
cdTexR = count
try:
qcL = self.qcf[count]
if qcL.startswith("$cdtex"):
cdTexLoc = count
# Getting the string inside the $cdtex command, y'know, the thing inside the quotes? Yeah, that thing.
start = 0
end = 0
if qcL.find('\"') != -1:
start = qcL.find('\"')
else:
start = qcL.find("\'")

if qcL.find('\"', start+1) != -1:
end = qcL.find('\"', start+1)
else:
end = qcL.find("\'", start+1)
cdTex = qcL[start+1:end]
print(f"cdtex directory: {cdTex}")
checks += 1
elif qcL.find('\".\"') != -1:
cdTex = 2
cdTexR = count
elif qcL.startswith("$cd"):
cdLoc = count
# Getting the string inside the $cdtex command, y'know, the thing inside the quotes? Yeah, that thing.
start = 0
end = 0
if qcL.find('\"') != -1:
start = qcL.find('\"')
else:
start = qcL.find("\'")

if qcL.find('\"', start+1) != -1:
end = qcL.find('\"', start+1)
else:
end = qcL.find("\'", start+1)
cd = qcL[start+1:end]
print(f"cdtex directory: {cdTex}")
checks += 1
elif qcL.startswith("$cd") and qcL.find('\".\"') != -1:
cd = True
cdRef = count
checks += 1
if cd or cdTex != 0:
except:
print("Something went wrong during cd checks! The model may not compile properly!")
break
if cd or cdTex != "":
self.cbarFrmt = True
print(cd)
print(cdTex)
if cd:
newCD = self.qcf[cdRef]
newCD = newCD.replace('\".\"', f'\"{self.qcLoc}\"')
self.newQC[cdRef] = newCD
if cd != "":
newCD = self.qcf[cdLoc]
if cd == "." or cd == "./":
newCD = newCD.replace(cd, f'{self.qcLoc}')
elif cd.startswith("./"):
newCD = newCD.replace(cd, f'{self.qcLoc}/{cd[2:]}')
else:
newCD = newCD.replace(cd, f'{self.qcLoc}/{cd}')
self.newQC[cdLoc] = newCD
print(newCD)
if cdTex == 1:
newCDtex = self.qcf[cdTexR]
newCDtex = newCDtex.replace('\"./textures/\"', f'\"{self.qcLoc}/textures/\"')
self.newQC[cdTexR] = newCDtex
if cdTex != "":
newCDtex = self.qcf[cdTexLoc]
if cdTex == "." or cdTex == "./":
newCDtex = newCDtex.replace(cdTex, f'{self.qcLoc}')
elif cdTex.startswith("./"):
newCDtex = newCDtex.replace(cdTex, f'{self.qcLoc}/{cdTex[2:]}')
else:
newCDtex = newCDtex.replace(cdTex, f'{self.qcLoc}/{cdTex}')
self.newQC[cdTexLoc] = newCDtex
elif cdTex == 2:
newCDtex = self.qcf[cdTexR]
newCDtex = self.qcf[cdTexLoc]
newCDtex = newCDtex.replace('\".\"', f'\"{self.qcLoc}\"')
self.newQC[cdTexR] = newCDtex
self.newQC[cdTexLoc] = newCDtex
self.newQCPath = os.path.join(self.qcLoc, "temp.qc")
f = open(self.newQCPath, "w")
f.write("".join(self.newQC))
Expand Down Expand Up @@ -221,6 +256,7 @@ def getMDLname(self):
def check1024px(self):
checks = 0
count = -1
cdTex = ""
newCDtex = ""
self.newQC = self.qcf
self.newQCPath = ""
Expand All @@ -229,53 +265,48 @@ def check1024px(self):
count += 1
qcL = self.qcf[count]
if qcL.startswith("$cdtex"):
if qcL.find('\"./textures/\"') != -1:
cdTex = 1
checks += 1
elif qcL.find('\".\"') != -1:
cdTex = 2
checks += 1
if cdTex != 0:
if cdTex == 1:
count = -1
texPath = os.path.join(self.qcLoc, "textures/")
textures = os.listdir(texPath)
while count < len(textures)-1:
count += 1
tex = textures[count]
fTex = os.path.join(self.qcLoc,tex)
if os.path.isfile(fTex):
try:
width, height = get_image_size.get_image_size(os.path.join(self.qcLoc,tex))
except get_image_size.UnknownImageFormat:
width, height = -1, -1
if width > 512 or height > 512:
self.found1024 = True
elif cdTex == 2:
count = -1
files = os.listdir(self.qcLoc)
textures = []
while count < len(files)-1:
count += 1
if files[count].endswith('.bmp'):
textures.append(files[count])
count = -1
while count < len(textures)-1:
count += 1
tex = textures[count]
fTex = os.path.join(self.qcLoc,tex)
if os.path.isfile(fTex):
try:
width, height = get_image_size.get_image_size(os.path.join(self.qcLoc,tex))
except get_image_size.UnknownImageFormat:
width, height = -1, -1
if width > 512 or height > 512:
self.found1024 = True
# Getting the string inside the $cdtex command, y'know, the thing inside the quotes? Yeah, that thing.
start = 0
end = 0
if qcL.find('\"') != -1:
start = qcL.find('\"')
else:
start = qcL.find("\'")

if qcL.find('\"', start+1) != -1:
end = qcL.find('\"', start+1)
else:
end = qcL.find("\'", start+1)
cdTex = qcL[start+1:end]
print(f"cdtex directory: {cdTex}")
checks += 1
if cdTex != "":
# if cdTex == 1:
count = -1
if cdTex == "." or cdTex == "./":
texPath = self.qcLoc
elif cdTex.startswith("./"):
texPath = os.path.join(self.qcLoc, cdTex[2:])
else:
texPath = os.path.join(self.qcLoc, cdTex)
textures = os.listdir(texPath)
while count < len(textures)-1:
count += 1
tex = textures[count]
fTex = os.path.join(self.qcLoc,tex)
if os.path.isfile(fTex) and tex.endswith(".bmp"):
try:
width, height = get_image_size.get_image_size(fTex)
except get_image_size.UnknownImageFormat:
width, height = -1, -1
if width > 512 or height > 512:
self.found1024 = True
return self.found1024

def checkCHROME(self):
checks = 0
count = -1
cdTex = ""
newCDtex = ""
texmodes = []
self.newQC = self.qcf
Expand All @@ -285,52 +316,44 @@ def checkCHROME(self):
count += 1
qcL = self.qcf[count]
if qcL.startswith("$cdtex"):
if qcL.find('\"./textures/\"') != -1:
cdTex = 1
checks += 1
elif qcL.find('\".\"') != -1:
cdTex = 2
checks += 1
if cdTex != 0:
if cdTex == 1:
count = -1
texPath = os.path.join(self.qcLoc, "textures/")
textures = os.listdir(texPath)
while count < len(textures)-1:
count += 1
tex = textures[count]
fTex = os.path.join(self.qcLoc,tex)
texL = tex.lower()
print(tex)
if texL.find("chrome") != -1 and os.path.isfile(fTex):
try:
width, height = get_image_size.get_image_size(os.path.join(texPath,tex))
except get_image_size.UnknownImageFormat:
width, height = -1, -1
if not width == 64 or not height == 64:
self.fndUnlChr = True
elif cdTex == 2:
count = -1
files = os.listdir(self.qcLoc)
textures = []
while count < len(files)-1:
count += 1
if files[count].endswith('.bmp'):
textures.append(files[count])
count = -1
while count < len(textures)-1:
count += 1
tex = textures[count]
fTex = os.path.join(self.qcLoc,tex)
texL = tex.lower()
print(tex)
if texL.find("chrome") != -1 and os.path.isfile(fTex):
try:
width, height = get_image_size.get_image_size(fTex)
except get_image_size.UnknownImageFormat:
width, height = -1, -1
if not width == 64 or not height == 64:
self.fndUnlChr = True
# Getting the string inside the $cdtex command, y'know, the thing inside the quotes? Yeah, that thing.
start = 0
end = 0
if qcL.find('\"') != -1:
start = qcL.find('\"')
else:
start = qcL.find("\'")

if qcL.find('\"', start+1) != -1:
end = qcL.find('\"', start+1)
else:
end = qcL.find("\'", start+1)
cdTex = qcL[start+1:end]
print(f"cdtex directory: {cdTex}")
checks += 1
if cdTex != "":
# if cdTex == 1:
count = -1
if cdTex == "." or cdTex == "./":
texPath = self.qcLoc
elif cdTex.startswith("./"):
texPath = os.path.join(self.qcLoc, cdTex[2:])
else:
texPath = os.path.join(self.qcLoc, cdTex)
textures = os.listdir(texPath)
while count < len(textures)-1:
count += 1
tex = textures[count]
fTex = os.path.join(self.qcLoc,tex)
texL = tex.lower()
print(tex)
if texL.find("chrome") != -1 and os.path.isfile(fTex) and tex.endswith('.bmp'):
try:
width, height = get_image_size.get_image_size(fTex)
except get_image_size.UnknownImageFormat:
width, height = -1, -1
if not width == 64 or not height == 64:
self.fndUnlChr = True
return self.fndUnlChr
def checkTRM(self, renderM:int):
count = -1
Expand Down
Loading