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: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
<br>
<h2>Why should I use Snark over Crowbar?</h2>
<h3><i>It's easier to configure and use!</i></h3>
<p>In Crowbar, to decompile a model you would have to fiddle around with settings in order to get your model decompiled properly for GoldSRC. With Snark, you don't need to do any extra configuration, just select an MDL file, select the output folder, set the appropriate preset for the compiler you'd like to use, hit the decompile button and you're set!</p>
<p>In Crowbar, to decompile a model, you would have to fiddle around with lots of settings in order to get your model decompiled properly for GoldSRC. With Snark, the whole process is streamlined and optimised for the engine. The options needed by the decompiler are much fewer, and there are quick setup presets ready to tailor it for your preferred compiler and modelling program in no time!</p>
<img src="git_images/decompWin.png" width="609" height="523" alt="Screenshot of decompile menu">
<p>On top of that, the compiling GUI includes all the command-line options as toggleable checks with tooltips to tell you what they do, so you don't need to check any sort of documentation, official or unofficial to use the advanced features StudioMDL offers its users.</p>
<p>On top of that, the compiling GUI includes all the command-line options as toggleable checks with tooltips to tell you what they do, so you don't need to check any sort of documentation, official or unofficial, to use the advanced features StudioMDL offers its users.</p>
<img src="git_images/compWin.png" width="609" height="523" alt="Screenshot of compile menu">
<h3><i>Natively runs on Windows and Linux!</i></h3>
<p>Snark is written using Python & Tkinter, which means that native support for the major operating systems can be easily offered. You no longer need to run Crowbar under Wine for Linux systems to make models for GoldSRC, instead you can run Snark natively with proper Linux binaries. <b>Wine will still be needed to run the compilers that Snark interfaces with, make sure you have the system package installed instead of the Flatpak!</b></p>
<h3><i>Better detection for unsupported features with compilers</i></h3>
<p>There are many different model compilers for GoldSRC, such as the Sven Co-op compiler that introduce new features that aren't supported in other games utilising the engine. Snark uses a profile system to track which compiler and game you're using so any discrepancies between what the compiler and game supports doesn't go unnoticed by the program. For example, if you use the Svengine compiler with Half-Life instead of Sven Co-op, the compiler will warn you that Half-Life doesn't support 1024px textures or chrome textures that aren't 64x64 resolution if any of them are included in the model files.</p>
<p>There are many different model compilers for GoldSRC, such as the Sven Co-op compiler, that introduce new features that aren't supported in other games utilising the engine. Snark uses a profile system to track which compiler and game you're using, so any discrepancies between what the compiler and game supports doesn't go unnoticed by the program. For example, if you use the Svengine compiler with Half-Life instead of Sven Co-op, the compiler will warn you that Half-Life doesn't support 1024px textures or chrome textures that aren't 64x64 resolution if any of them are included in the model files.</p>
<img src="git_images/compErr.png" width="609" height="523" alt="Screenshot of compile menu, showing a warning that Half-Life doesn't support high resolution textures">
<br>
<h2>Frequently Asked Questions</h2>
Expand Down
Binary file modified git_images/decompWin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 64 additions & 1 deletion helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,4 +433,67 @@ def __init__(self, name:str, qcLoc:str, output:str):
self.name = name
self.qcLoc, self.mdlLoc = qcLoc, qcLoc
self.skip = False
self.output = output
self.output = output

class AlphaPrettify():

def __init__(self, cmdOut:str, texSubFolder:bool, mdlDir:str):
self.cmdOut = cmdOut.split('\n')
self.texSF = texSubFolder
self.mDir = mdlDir
self.qcLoc = os.path.join(self.mDir, self.cmdOut[6].replace("QC script: MDL6job/", ""))
with open(self.qcLoc, 'r') as qc:
self.qcDat = qc.readlines()

self.qcDat.insert(6, "\nOutput modified by Snark, the alternative to Crowbar for GoldSRC!\n")
self.qcDat.insert(7, "Github: https://github.com/PostScriptReal/Snark_Compiler Gamebanana: https://gamebanana.com/tools/19255\n")
self.qcDat.insert(8, "\n")

texFolder = os.path.join(self.mDir, 'textures')
if self.texSF:
try:
os.mkdir(texFolder)
except:
pass
for f in os.listdir(self.mDir):
if f.endswith('.bmp'):
shutil.copy(os.path.join(self.mDir, f), texFolder)
os.remove(os.path.join(self.mDir, f))
cdLine = self.qcDat.index('$cd ".\\"\n')
cdtexLine = self.qcDat.index('$cdtexture \".\\"\n')
self.qcDat[cdLine] = '$cd \"./\"\n'
self.qcDat[cdtexLine] = '$cdtexture \"./textures/\"\n'
else:
cdLine = self.qcDat.index('$cd ".\\"\n')
cdtexLine = self.qcDat.index('$cdtexture \".\\"\n')
self.qcDat[cdLine] = '$cd \"./\"\n'
self.qcDat[cdtexLine] = '$cdtexture \"./\"\n'

try:
animsFolder = os.path.join(self.mDir, 'anims')
except:
pass
try:
os.mkdir(animsFolder)
except:
pass
count = -1
for l in self.cmdOut:
if l.startswith("Sequence:"):
animF = l.replace("Sequence: MDL6job/", "")
shutil.copy(os.path.join(self.mDir, animF), animsFolder)
os.remove(os.path.join(self.mDir, animF))
animName = f"\"{animF.replace('.smd', '')}\""
for s in self.qcDat:
count += 1
if s.startswith('$sequence'):
if s.find(animName) != -1:
substringStart = s.find(animName)+len(animName)+1
substring = s[substringStart:]
newSS = substring.replace(animName, f"\"anims/{animName.replace('\"', "", 1)}")
self.qcDat[count] = s.replace(substring, newSS)
break
count = -1
self.newQC = open(self.qcLoc, 'w')
self.newQC.write(''.join(self.qcDat))
self.newQC.close()
Loading
Loading