Educational Purposes
here's all my current scripts for anyone that is interested
gqe.hta
gqe.bat
gqe/shell/script.js
gqe/shell/script.vbs
of course there will be some polishing done before I officially release this but, this is where all the job scripts are at the moment.
here's all my current scripts for anyone that is interested
gqe.hta
Code:
<!DOCTYPE html> <html> <head> <title>Gypsy's Quake Enginator</title> <HTA:APPLICATION ID="QE" APPLICATIONNAME="Gypsy's Quake Enginator" SINGLEINSTANCE="yes" CAPTION="yes" BORDER="thin" INNERBORDER="no" SCROLL="no" /> <link href="GQE/shell/style.css" type="text/css" rel="stylesheet" /> <script src="GQE/shell/jquery.js" type="text/javascript"></script> <script src="GQE/shell/script.js" type="text/javascript"></script> <script src="GQE/shell/script.vbs" type="text/vbscript"></script> </head> <body> <form id="menu" name="menu" action=""> <table> <tr> <td>engine:</td> <td> <select name="engine" id="engine"> <option value="darkplaces">Darkplaces</option> <option value="DirectQ">Direct Q</option> <option value="fitzquake085">FitzQuake</option> <option value="fteqw">FTEQW</option> <option value="glpro493">ProQuake</option> <option value="glQrack">Qrack</option> <option value="qbismS8">Qbism Super 8</option> <option value="quakespasm">Quakespasm</option> </select> </td> </tr> <tr> <td>-game:</td> <td><input type="text" id="gameName" value="id1" /></td> </tr> <tr> <td>+map:</td> <td><input type="text" id="mapName" value="start" /></td> </tr> <tr> <td>use default switches?</td> <td><input type="checkbox" id="default" disabled /></td> </tr> <tr> <td colspan="2"><textarea id="default_cmln" rows="4" cols="50"></textarea></td> </tr> <tr> <td>use engine specific switches?</td> <td><input type="checkbox" id="optional" disabled /></td> </tr> <tr> <td colspan="2"><textarea id="optional_cmln" rows="4" cols="50"></textarea></td> </tr> </table> <input type="submit" value="run" /> </form> </body> </html>
Code:
:: turn off console printing for a moment @echo off ::config some options :CONFIG set usedef=0 set useopt=0 ::set path to the directory which this bat resides in set path=%~dp0 set /p default=<%path%gqe\configs\cmln ::change CWD to current directory cd /d %path% cls ::check if this is being caslled from the hta menu :CHECK if not "%1"=="" goto FROM_HTA goto ENGINE ::if %1 was assigned these need to be assigned as well :FROM_HTA set engine=%1 if "%2"=="" (goto GAM_ERR) else set gameName=%2 if "%3"=="" (goto MAP_ERR) else set mapName=%~n3 if not "%4"=="y" (set usedef=n) else set usedef=y if not "%5"=="y" (set useopt=n) else set useopt=y set /p optional=<%path%gqe\configs\%engine%\cmln goto RUN ::unspecified stuff :GAM_ERR ECHO -game was unspecified :MAP_ERR ECHO +map was unspecified goto END :ENGINE ECHO. ECHO 1. darkplaces ECHO 2. directq ECHO 3. fitzquake ECHO 4. fteqw ECHO 5. proquake ECHO 6. qrack ECHO 7. qbismS8 ECHO 8. quakespasm set /p choice=Choose the number that corresponds to your desired engine and press enter: if not "%choice%"=="" set choice=%choice:~0,2% if "%choice%"=="1" set engine=darkplaces if "%choice%"=="2" set engine=DirectQ if "%choice%"=="3" set engine=fitzquake085 if "%choice%"=="4" set engine=fteqw if "%choice%"=="5" set engine=glpro493 if "%choice%"=="6" set engine=glQrack if "%choice%"=="7" set engine=qbismS8 if "%choice%"=="8" set engine=quakespasm if not "%engine%"=="0" goto FOLDER ECHO "%choice%" is not a valid choice. Try again ECHO. goto ENGINE :FOLDER set /p optional=<%path%gqe\configs\%engine%\cmln set /p gameName=Type the -game for your map and press enter. Press enter only for -game id1: if "%gameName%"=="" set gameName=id1 :MAP set /p mapName=type the name of your map and press enter: if not "%mapName%"=="" goto GO_CHOICE ECHO You didn't supply a mapName. Try again. ECHO. goto MAP :GO_CHOICE if not "%default%"=="" goto DEF_CHOICE if not "%optional%"=="" goto OPT_CHOICE goto RUN :DEF_CHOICE set /p usedef=Use default commandline options (y/n): if not "%optional%"=="" goto OPT_CHOICE goto RUN :OPT_CHOICE set /p useopt=Use default commandline options (y/n): goto RUN :RUN set "base=-basedir %path% -game %gameName% +map %mapName%" if "%usedef%"=="y" set "base=%base% %default%" if "%useopt%"=="y" set "base=%base% %optional%" Echo cmd line: %engine%.exe %base% set enginePath=%path%engines\%engine%\ cd /d %enginePath% %engine%.exe %base% goto END :END PAUSE EXIT
Code:
$(document).ready(function(){
$engine=$("#engine").val();
$(".btn").click(function(event){
event.preventDefault();
$("#menu").submit();
});
$("#menu").submit(function(event){
event.preventDefault();
var def = ($('#default').prop('checked'))?"y":"n";
var opt = ($('#optional').prop('checked'))?"y":"n";
var eng = $engine;
var gam = $("#gameName").val();
var map = "\""+$("#mapName").val()+"\"";
if($("#default").prop("checked"))IOFile(2, $("#default_cmln").text(), "GQE/configs/cmln");
if($("#optional").prop("checked"))IOFile(2, $("#optional_cmln").text(), "GQE/configs/"+$("#engine").val()+"/cmln");
cmdLine = eng+","+gam+","+map+","+def+","+opt;
initShell(cmdLine);
});
$("#default_cmln").change(function() {
if($(this).text() == "")
{ $("#default").prop("disabled", true);
$("#default").prop("checked", false);
} else
$("#default").prop("disabled", false);
});
$("#optional_cmln").change(function() {
if($(this).text() == "")
{ $("#optional").prop("disabled", true);
$("#optional").prop("checked", false);
} else
$("#optional").prop("disabled", false);
});
$("#engine").change(function() {
if($("#optional").prop("checked"))IOFile(2, $("#optional_cmln").text(), "GQE/configs/"+$engine+"/cmln");
$engine = $(this).val();
CheckOptional($engine);
});
});
function enable(target, data){
$("#"+target).prop("disabled", false);
$("#"+target).prop("checked", true);
$("#"+target+"_cmln").text(data);
}
function disable(target, data){
$("#"+target).prop("disabled", true);
$("#"+target).prop("checked", false);
$("#"+target+"_cmln").text(data);
}
function getEngine(){
return $("#engine").val();
}
Code:
Dim intX : Dim intY
Dim intWidth : Dim intHeight
' fires on load or refresh
Sub Window_onLoad
' get the file ready off screen
window.offscreenBuffering = True
eng = getEngine()
call DoIni()
CheckDefault()
CheckOptional eng
End Sub
' fires before window closes
Sub Window_onBeforeUnLoad
If CInt(intX) <> CInt(window.screenLeft) Or CInt(intY) <> CInt(window.screenTop) Then
intX = window.screenLeft
intY = window.screenTop
data = intWidth & "," & intHeight & "," & intX & "," & intY
IOFile 2, data, "GQE/shell/shell.ini"
End If
End Sub
' sets ini data (returnable)
Function DoIni
DoIni = IOFile(1,"","GQE/shell/shell.ini")
arrINI = Split(DoIni, ",")
For i = 0 To UBound(arrINI)
value = arrINI(i)
Select Case i
Case 0
intWidth = value
Case 1
intHeight = value
Case 2
intX = value
Case 3
intY = value
End Select
Next
window.moveTo intX, intY
window.resizeTo intWidth, intHeight
End Function
' sets ini data (returnable)
Sub CheckDefault
def = IOFile(1,"","GQE/configs/cmln")
If def <> "" Then
enable "default", def
Else disable "default", ""
End If
End Sub
' sets ini data (returnable)
Sub CheckOptional(engine)
path = "GQE/configs/" & engine & "/cmln"
opt = IOFile(1,"",path)
If opt <> "" Then
enable "optional", opt
Else disable "optional", ""
End If
End Sub
' run gqe.bat with commands
Sub initShell(cmds)
commandline="gqe.bat " & Replace(cmds , "," , " ")
Set objWshShell = CreateObject("Wscript.Shell")
objWshShell.run commandline, 1
End Sub
' read/writes any text file
Function IOFile(openType, data, path)
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
If openType > 8 Or openType < 1 Then
ReportError "IOFile Error: unrecognized openType value: " & openType
Else
Set objFSO = CreateObject("Scripting.FileSystemObject")
blank = True
If objFSO.FileExists(path) Then
If objFSO.GetFile(path).size <> 0 Then
Set objFile = objFSO.OpenTextFile(path, openType)
blank = False
End If
End If
Select Case openType
Case ForReading
If blank Then
IOFile = ""
Else
IOFile = objFile.ReadAll
End If
Case ForWriting
If blank <> True Then
If data <> "" Then
If data = "#" Then
objFile.Write ""
Else
objFile.Write data
End If
Else
ReportError "IOFile Error: There is no data to write"
End If
End If
case ForAppending
If blank <> True Then
If data <> "" Then
objFile.Write data
Else
ReportError "IOFile Error: There is no data to append"
End If
End If
End Select
if blank <> True Then objFile.Close
End If
End Function
Comment