浏览代码

Add servis files

rachels 3 年之前
父节点
当前提交
0974c20015
共有 9 个文件被更改,包括 490 次插入0 次删除
  1. 29 0
      .gitignore
  2. 102 0
      MakeQSPAddedFlavour.bat
  3. 31 0
      check_consistency.py
  4. 39 0
      check_images.py
  5. 153 0
      keywords_en.xml
  6. 二进制
      txt2gam.exe
  7. 44 0
      txtmerge.py
  8. 46 0
      txtsplit.py
  9. 46 0
      txtsplit3.py

+ 29 - 0
.gitignore

@@ -0,0 +1,29 @@
+images/
+sound/
+music/
+.*
+*.qsp
+*.sav
+glife.txt
+qgen.cfg
+qspgui.cfg
+avatar.*
+*.jpg
+*.jpeg
+*.sublime-*
+VideoDecodeStats/
+
+glmf.code-workspace
+
+Music Life Wiki/
+
+images.zip
+
+*.png
+
+#ignore Visual Studio build files
+/tools/qsp-analyser/QSP_Analyser/[Bb]in/
+/tools/qsp-analyser/QSP_Analyser/[Oo]bj/
+
+#don't ignore this file
+!.gitignore

+ 102 - 0
MakeQSPAddedFlavour.bat

@@ -0,0 +1,102 @@
+@ECHO off
+
+:: Set those lines to fit your setup. 
+:: This is where mod_Ibiza.qsp will be copied. If you don't want to move it just comment (::) the line below.
+:: set CP_TO=..\GL_ECV
+
+:: This is the program used to open the QSPFILE. If you comment this line windows will launch the default app for the ".qsp" extension.
+set QSPGUI=QSP\Player-video\qspgui.exe
+set QGEN=QSP\QGen5\QGen.exe
+
+:: The file that will be generated or open
+set QSPFILE=AddedFlavour.qsp
+
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+
+:menu
+cls
+echo.
+echo :: QSP Compiler and Launcher
+echo.
+
+if defined QGEN (
+	if not exist "%QGEN%" ( 
+		echo QGEN     : [ERROR] - %QGEN%  not found. Using DEFAULT application.
+		set QGEN=
+	) else ( echo QGEN     : [OK] - "%QGEN%")
+) else echo QGEN     : [NOT DEFINED] - Using DEFAULT application.
+
+if defined QSPGUI (
+	if not exist "%QSPGUI%" ( 
+		echo QSP EXEC : [ERROR] - %QSPGUI% not found.
+		set QSPGUI=
+	) else ( echo QSP EXEC : [OK] - "%QSPGUI%")
+) else ( echo QSP EXEC : [NOT DEFINED] - Using Windows DEFAULT.)
+
+if defined QSPFILE (
+	if not exist "%QSPFILE%" ( 
+		echo QSP FILE : [WARNING] - %QSPFILE% not found.
+	) else ( echo QSP FILE : [OK] - "%QSPFILE%")
+) else ( echo QSP FILE : [NOT DEFINED] - ERROR: CAN'T CONTINUE.)
+
+if defined CP_TO (
+	if not exist "%CP_TO%" (
+		echo COPY     : [ERROR] - Destination "%CP_TO%" not found. Copy DISABLED.
+		set CP_TO=
+	) else ( echo COPY     : [OK] - "%CP_TO%")
+) else (  echo COPY     : [DISABLED] )
+
+echo.
+
+if defined NOT_FOUND (
+	echo ERROR: Option '%action%' wasn't recognized. Is it lowercase? 
+	set NOT_FOUND=
+)
+
+echo.
+echo ACTIONS: (B)uild  (R)un  (F)ull  (Q)Gen  (E)xit
+echo.
+set /p action=Choose an action:
+
+if defined QSPFILE (
+	if %action% == b goto build
+	if %action% == r goto run
+	if %action% == f goto build
+	if %action% == q goto qgen
+)
+
+if %action% == e goto exit
+
+set NOT_FOUND=1
+goto menu
+
+:build
+echo.
+echo Building ...
+
+@ECHO ON
+python -3 txtmerge.py locations mod_AddedFlavour.txt
+txt2gam.exe mod_AddedFlavour.txt %QSPFILE% > nul
+@ECHO OFF
+
+echo.
+if defined CP_TO ( echo Copying %QSPFILE% to "%CP_TO%" ... & copy %QSPFILE% %CP_TO% > nul )
+
+echo.
+echo Done.
+pause
+if %action% == f ( goto run ) else ( goto menu )
+
+:qgen
+echo.
+echo Running ...
+if defined CP_TO ( start %QGEN% %CP_TO%\%QSPFILE% ) else ( start %QGEN% %QSPFILE% )
+goto exit
+
+:run
+echo.
+echo Running ...
+
+if defined CP_TO ( start %QSPGUI% %CP_TO%\%QSPFILE% ) else ( start %QSPGUI% %QSPFILE% )
+
+:exit

+ 31 - 0
check_consistency.py

@@ -0,0 +1,31 @@
+#!/usr/bin/env python
+# checks to make sure that mod_Ibiza.qproj is in sync with the location files
+
+import os
+import sys
+import re
+import io
+import xml.etree.ElementTree as ET
+import os.path
+
+# read the project xml file first
+tree = ET.parse('mod_AddedFlavour.qproj')
+root = tree.getroot()
+
+
+xml_locations = []
+os_locations = os.listdir("locations")
+
+print "Locations missing from ./locations/:"
+for location in root.iter('Location'):
+    name = location.attrib['name'].replace("$","_")
+    xml_locations.append(name)
+    
+    if name not in os_locations:
+        print name
+
+
+print "Locations missing from .qproj:"
+for name in os_locations:
+    if name not in xml_locations:
+        print name

+ 39 - 0
check_images.py

@@ -0,0 +1,39 @@
+#!/usr/bin/env python
+
+import io
+import os
+import re
+
+#path = os.getcwd()
+#print path
+
+startpattern = """images/"""
+imgFormats = ['jpg','gif']
+
+infile = io.open('mod_AddedFlavour.txt',mode='r',encoding='utf-16')
+lines = infile.readlines()
+
+images = []
+
+for name in os.listdir("locations"):
+    ifile = io.open(
+        os.path.join("locations", name),
+        mode='rt',
+        encoding='utf-8'
+    )
+    text = ifile.read()
+    for match in re.finditer(r"images.+?[.](gif|jpg|png)", text, flags=re.U):
+        imgfile = match.group().encode("utf-8")
+        randmatch = re.search(r"'\s*[+]\s*rand\s*[(]\s*(\d+)\s*[,]\s*(\d+)\s*[)]\s*[+]\s*'", imgfile)
+        if randmatch != None:
+            for i in range(int(randmatch.group(1)), 1+int(randmatch.group(2))):
+                images.append(re.sub(r"'\s*[+]\s*rand\s*[(].*?[)]\s*[+]\s*'", str(i), imgfile))
+        else:
+            images.append(imgfile)
+    
+    ifile.close()
+
+
+for image in images:
+    if not re.search(r"[<$]", image) and not os.path.isfile(image):
+        print "Image not found:", image

+ 153 - 0
keywords_en.xml

@@ -0,0 +1,153 @@
+<?xml version="1.0" encoding="utf-8"?>
+<QGen-keywords>
+  <Statements>
+    <Keyword name="pl" desc="PL [expression] / *PL [expression] - output text to an additional / main description window, then a new line"/>
+    <Keyword name="clear" desc="CLEAR / *CLEAR - cleaning additional / the main description window"/>
+    <Keyword name="clr" desc="CLR / *CLR - cleaning additional / the main description window"/>
+    <Keyword name="p" desc="P [expression] / *P [expression] - output text to an additional / main description window"/>
+    <Keyword name="nl" desc="NL [expression] / *NL [expression] - transition to a new line, then output the text to an additional/ main description window"/>
+    <Keyword name="msg" desc="MSG [expression] - output of the message in the information window"/>
+    <Keyword name="wait" desc="WAIT [#expression] - stop execution of the program for a specified number of milliseconds"/>
+    <Keyword name="act" desc="ACT [$variable],[$path to the image]:[operator] &amp; [operator] &amp; ... - adding an action"/>
+    <Keyword name="delact" desc="DELACT [$variable] / DEL ACT [$variable] - deleting an action"/>
+    <Keyword name="cla" desc="CLA - clearing the action list"/>
+    <Keyword name="cmdclear" desc="CMDCLEAR - clearing input line"/>
+    <Keyword name="cmdclr" desc="CMDCLEAR - clearing input line"/>
+    <Keyword name="cls" desc="CLS - clears the screen, leaving only a list of items"/>
+    <Keyword name="menu" desc="MENU [$expression] - displaying a menu with a given name"/>
+    <Keyword name="settimer" desc="SETTIMER [#expression] - specifies the timer interval for the counter location"/>
+    <Keyword name="dynamic" desc="DYNAMIC [$line of code],[parameter 1],[parameter 2], ... - dynamic code execution"/>
+    <Keyword name="set" desc="SET [variable name]=[expression] - setting the value of a variable"/>
+    <Keyword name="let" desc="LET [variable name]=[expression] - setting the value of a variable"/>
+    <Keyword name="killvar" desc="KILLVAR [$name],[#index] - delete all variables / specified variable"/>
+    <Keyword name="copyarr" desc="COPYARR [$array-receiver],[$source array] - copying the contents of an array to another array"/>
+    <Keyword name="addobj" desc="ADDOBJ [$variable],[$path to the image],[#position] / ADD OBJ [$variable],[$path to the image],[#position] - adding an item"/>
+    <Keyword name="delobj" desc="DELOBJ [$variable] / DEL OBJ [$variable] - object removal"/>
+    <Keyword name="killobj" desc="KILLOBJ [#position] - removal of all items / of the item in the given position"/>
+    <Keyword name="unselect" desc="UNSELECT - cancellation of object selection"/>
+    <Keyword name="unsel" desc="UNSEL - cancellation of object selection"/>
+    <Keyword name="killall" desc="KILLALL - delete all variables and items"/>
+    <Keyword name="opengame" desc="OPENGAME [$expression] - Loading the game state"/>
+    <Keyword name="openqst" desc="OPENQST [$expression] - opening and launching a game file"/>
+    <Keyword name="addqst" desc="ADDQST [$expression] - adding locations from the specified file"/>
+    <Keyword name="killqst" desc="KILLQST - delete all added via ADDQST locations"/>
+    <Keyword name="savegame" desc="SAVEGAME [$expression] - preservation of the game state"/>
+    <Keyword name="refint" desc="REFINT - interface update"/>
+    <Keyword name="showacts" desc="SHOWACTS [#expression] - display / hiding action list"/>
+    <Keyword name="showinput" desc="SHOWINPUT [#expression] - display / hiding the input line"/>
+    <Keyword name="showobjs" desc="SHOWOBJS [#expression] - display / hiding a list of items"/>
+    <Keyword name="showstat" desc="SHOWSTAT [#expression] - display / hiding an additional description window"/>
+    <Keyword name="if" desc="IF [#expression]:[operator1] &amp; [operator2] &amp; ... ELSE [operator3] &amp; [operator4] &amp; ... - condition"/>
+    <Keyword name="else" desc="IF [#expression]:[operator1] &amp; [operator2] &amp; ... ELSE [operator3] &amp; [operator4] &amp; ... - condition"/>
+    <Keyword name="elseif" desc="ELSEIF [#expression]:[operator1] &amp; [operator2] &amp; ... - alternate state"/>
+    <Keyword name="exit" desc="EXIT - completion of the current code"/>
+    <Keyword name="end" desc="END - completion of a multi-line form IF / ACT"/>
+    <Keyword name="jump" desc="JUMP [$expression] - go to the specified label"/>
+    <Keyword name="gosub" desc="GOSUB [$expression],[parameter 1],[parameter 2], ... - processing of the specified location"/>
+    <Keyword name="gs" desc="GS [$expression],[parameter 1],[parameter 2], ... - processing of the specified location"/>
+    <Keyword name="goto" desc="GOTO [$expression],[parameter 1],[parameter 2], ... - go to the specified location"/>
+    <Keyword name="gt" desc="GT [$expression],[parameter 1],[parameter 2], ... - go to the specified location"/>
+    <Keyword name="xgoto" desc="XGOTO [$expression],[parameter 1],[parameter 2], ... - go to the specified location without clearing the main description window"/>
+    <Keyword name="xgt" desc="XGT [$expression],[parameter 1],[parameter 2], ... - go to the specified location without clearing the main description window"/>
+    <Keyword name="play" desc="PLAY [$path to an audio file],[#volume] - playing an audio file with a specified volume"/>
+    <Keyword name="close" desc="CLOSE [$path to an audio file] / CLOSE ALL - stop playing a sound file / all sound files"/>
+    <Keyword name="view" desc="VIEW [$path to the graphic file] - image view"/>
+  </Statements>
+  <Expressions>
+    <Keyword name="and" desc="[#expression 1] AND [#expression 2] - logical &quot;and=&quot;"/>
+    <Keyword name="or" desc="[#expression 1] OR [#expression 2] - logical &quot;or&quot;"/>
+    <Keyword name="obj" desc="OBJ [$subject] - checking the presence of an object in a backpack"/>
+    <Keyword name="loc" desc="LOC [$location] - checking the existence of a location"/>
+    <Keyword name="no" desc="NO [#expression] - negation"/>
+    <Keyword name="mod" desc="[#expression 1] MOD [#expression 2] - calculation of the remainder from division"/>
+    <Keyword name="desc" desc="DESC([$expression]) - returns the text of the basic description of the location"/>
+    <Keyword name="$desc" desc="$DESC([$expression]) - returns the text of the basic description of the location"/>
+    <Keyword name="iif" desc="IIF([#expression],[Expression_Yes],[expression_no]) - возвращает одно из выражений по условию"/>
+    <Keyword name="$iif" desc="$IIF([#expression],[Expression_Yes],[expression_no]) - возвращает одно из выражений по условию"/>
+    <Keyword name="input" desc="INPUT([expression]) - shows the text input window and returns the entered value"/>
+    <Keyword name="$input" desc="$INPUT([expression]) - shows the text input window and returns the entered value"/>
+    <Keyword name="isplay" desc="ISPLAY([$expression]) - checks if the specified file is currently playing"/>
+    <Keyword name="max" desc="MAX([expression 1],[expression 2], ...) - returns the maximum of the argument values"/>
+    <Keyword name="$max" desc="$MAX([expression 1],[expression 2], ...) - returns the maximum of the argument values"/>
+    <Keyword name="min" desc="MIN([expression 1],[expression 2], ...) - returns the minimum of the argument values"/>
+    <Keyword name="$min" desc="$MIN([expression 1],[expression 2], ...) - returns the minimum of the argument values"/>
+    <Keyword name="rand" desc="RAND([#expression 1],[#expression 2]) - returns a random number between the given"/>
+    <Keyword name="rgb" desc="RGB([#red],[#green],[#blue]) - returns color code based on 3 components"/>
+    <Keyword name="getobj" desc="GETOBJ([#position]) - returns the name of the item located in the given position"/>
+    <Keyword name="$getobj" desc="$GETOBJ([#position]) - returns the name of the item located in the given position"/>
+    <Keyword name="dyneval" desc="DYNEVAL([$expression],[parameter 1],[parameter 2], ...) - returns the value of the dynamically evaluated expression"/>
+    <Keyword name="$dyneval" desc="$DYNEVAL([$expression],[parameter 1],[parameter 2], ...) - returns the value of the dynamically evaluated expression"/>
+    <Keyword name="func" desc="FUNC([$expression],[parameter 1],[parameter 2], ...) - processing specified location as a function"/>
+    <Keyword name="$func" desc="$FUNC([$expression],[parameter 1],[parameter 2], ...) - processing specified location as a function"/>
+    <Keyword name="arrsize" desc="ARRSIZE([$expression]) - returns the number of elements in the specified array"/>
+    <Keyword name="arrpos" desc="ARRPOS([#starting index],[$array name],[value]) - search in an array of an element with a given value"/>
+    <Keyword name="instr" desc="INSTR([#initial position],[$text],[$search text]) - search for text occurrences"/>
+    <Keyword name="isnum" desc="ISNUM([$expression]) - checks if the specified string is a number"/>
+    <Keyword name="trim" desc="TRIM([$expression]) - removes adjacent spaces and tabs from text"/>
+    <Keyword name="$trim" desc="$TRIM([$expression]) - removes adjacent spaces and tabs from text"/>
+    <Keyword name="ucase" desc="UCASE([$expression]) - converts small letters of text to large"/>
+    <Keyword name="$ucase" desc="$UCASE([$expression]) - converts small letters of text to large"/>
+    <Keyword name="lcase" desc="LCASE([$expression]) - converts large letters of text into small"/>
+    <Keyword name="$lcase" desc="$LCASE([$expression]) - converts large letters of text into small"/>
+    <Keyword name="len" desc="LEN([$expression]) - returns the length of the specified string"/>
+    <Keyword name="mid" desc="MID([$text],[#start],[#length]) - cuts out a string of the specified length starting from the specified location"/>
+    <Keyword name="$mid" desc="$MID([$text],[#start],[#length]) - cuts out a string of the specified length starting from the specified location"/>
+    <Keyword name="replace" desc="REPLACE([$text],[$search text],[$text to replace]) - replaces the specified string in the text"/>
+    <Keyword name="$replace" desc="$REPLACE([$text],[$search text],[$text to replace]) - replaces the specifieed string in the text"/>
+    <Keyword name="str" desc="STR([#expression]) - converts a number to a string"/>
+    <Keyword name="$str" desc="$STR([#expression]) - converts a number to a string"/>
+    <Keyword name="val" desc="VAL([$expression]) - converts a string to a number"/>
+    <Keyword name="arrcomp" desc="ARRCOMP([#starting index],[$array name],[$template]) - search in an array of an element corresponding to a regular expression"/>
+    <Keyword name="strcomp" desc="STRCOMP([$expression],[$template]) - checks the specified text for consistency with a regular expression"/>
+    <Keyword name="strfind" desc="STRFIND([$expression],[$template],[#number]) - returns a substring, corresponding to the group numbered [#number] regular expression"/>
+    <Keyword name="$strfind" desc="$STRFIND([$expression],[$template],[#number]) - returns a substring, corresponding to the group numbered [#number] regular expression"/>
+    <Keyword name="strpos" desc="STRPOS([$expression],[$template],[#number]) - returns the position of the substring, corresponding to the group with the number [#number] regular expression"/>
+    <Keyword name="countobj" desc="COUNTOBJ -returns the current number of items"/>
+    <Keyword name="msecscount" desc="MSECSCOUNT - returns the number of milliseconds, elapsed since the start of the game"/>
+    <Keyword name="rnd" desc="RND - returns a random value from 1 to 1000"/>
+    <Keyword name="curloc" desc="CURLOC - returns the name of the current location"/>
+    <Keyword name="$curloc" desc="$CURLOC - returns the name of the current location"/>
+    <Keyword name="qspver" desc="QSPVER - returns the version of the interpreter"/>
+    <Keyword name="$qspver" desc="$QSPVER - returns the version of the interpreter"/>
+    <Keyword name="selobj" desc="SELOBJ - returns the name of the selected item"/>
+    <Keyword name="$selobj" desc="$SELOBJ - returns the name of the selected item"/>
+    <Keyword name="selact" desc="SELACT - returns the name of the selected action"/>
+    <Keyword name="$selact" desc="$SELACT - returns the name of the selected action"/>
+    <Keyword name="curacts" desc="CURACTS - returns all current actions as code"/>
+    <Keyword name="$curacts" desc="$CURACTS - returns all current actions as code"/>
+    <Keyword name="user_text" desc="USER_TEXT - returns text in the input line"/>
+    <Keyword name="$user_text" desc="$USER_TEXT - returns text in the input line"/>
+    <Keyword name="usrtxt" desc="USRTXT - returns text in the input line"/>
+    <Keyword name="$usrtxt" desc="$USRTXT - returns text in the input line"/>
+    <Keyword name="maintxt" desc="MAINTXT - returns text in the main description window"/>
+    <Keyword name="$maintxt" desc="$MAINTXT - returns text in the main description window"/>
+    <Keyword name="stattxt" desc="STATTXT - returns text in an additional description window"/>
+    <Keyword name="$stattxt" desc="$STATTXT - returns text in an additional description window"/>
+  </Expressions>
+  <Variables>
+    <Keyword name="args" desc="ARGS - array with procedure parametersarray with procedure parameters / function"/>
+    <Keyword name="$args" desc="$ARGS - array with procedure parameters / function"/>
+    <Keyword name="result" desc="RESULT - the variable contains the result, returned by the current function"/>
+    <Keyword name="$result" desc="$RESULT - the variable contains the result, returned by the current function"/>
+    <Keyword name="disablescroll" desc="DISABLESCROLL - if the variable is not equal to 0, it prohibits auto-scrolling of the text in the output"/>
+    <Keyword name="disablesubex" desc="DISABLESUBEX - if the variable is not equal to 0, it prohibits the use of &quot;subexpressions&quot; in the text"/>
+    <Keyword name="nosave" desc="NOSAVE - if the variable is not equal to 0, the user can not save the game state"/>
+    <Keyword name="debug" desc="DEBUG - if the variable is not equal to 0, then disabling the game ID check when the state is loaded"/>
+    <Keyword name="$counter" desc="$COUNTER - variable contains the name of the location-counter"/>
+    <Keyword name="$ongload" desc="$ONGLOAD - variable contains the name of the location-the state load handler"/>
+    <Keyword name="$ongsave" desc="$ONGSAVE - variable contains the name of the location-a stateful handler"/>
+    <Keyword name="$onnewloc" desc="$ONNEWLOC - variable contains the name of the location-new location handler"/>
+    <Keyword name="$onactsel" desc="$ONACTSEL - variable contains the name of the location-the action selector"/>
+    <Keyword name="$onobjsel" desc="$ONOBJSEL - variable contains the name of the location-object selector handler"/>
+    <Keyword name="$onobjadd" desc="$ONOBJADD - variable contains the name of the location-addon handler"/>
+    <Keyword name="$onobjdel" desc="$ONOBJDEL - variable contains the name of the location-object removal handler"/>
+    <Keyword name="$usercom" desc="$USERCOM - variable contains the name of the location-input line handler"/>
+    <Keyword name="usehtml" desc="USEHTML - if the variable is not equal to 0, then includes the possibility of using HTML"/>
+    <Keyword name="bcolor" desc="BCOLOR - the variable contains the background color"/>
+    <Keyword name="fcolor" desc="FCOLOR - variable contains the main font color"/>
+    <Keyword name="lcolor" desc="LCOLOR - variable contains the main color of links"/>
+    <Keyword name="fsize" desc="FSIZE - variable contains the main font size"/>
+    <Keyword name="$fname" desc="$FNAME - variable contains the name of the main font"/>
+    <Keyword name="$backimage" desc="$BACKIMAGE - the variable contains the path to the background image"/>
+  </Variables>
+</QGen-keywords>

二进制
txt2gam.exe


+ 44 - 0
txtmerge.py

@@ -0,0 +1,44 @@
+#!/usr/bin/env python
+# usage: txtmerge.py <input_dir> <output_file_name> 
+# does the exact opposite of txtsplit.py
+
+import os
+import sys
+import re
+import io 
+import xml.etree.ElementTree as ET
+
+assert len(sys.argv) == 3, "usage:\ntxtmerge.py <input_dir> <output_file_name>"
+idir = str(sys.argv[1])
+oname = str(sys.argv[2])
+
+# read the project xml file first
+# let's do this later in order to implement directory structure
+tree = ET.parse('mod_AddedFlavour.qproj')
+root = tree.getroot()
+
+
+ofile = io.open(oname, 'w', encoding='utf-16', newline='\r\n')
+
+for location in root.iter('Location'):
+    iname = location.attrib['name']
+    iname = iname.replace("$","_")
+
+    try:
+        ifile = io.open(os.path.join(idir,iname + '.qsrc'), 'rt', encoding='utf-8')
+        text = ifile.read()
+
+        # make sure there's a line at the end of file
+        # (why wouldn't there be one? WINDOWS!
+        if text[-1] != u'\n':
+            text += u'\n\n'
+
+        ofile.write(text)
+        ifile.close()
+    except IOError:
+        print("WARNING: missing location %s" % iname)
+        pass
+
+ofile.close()
+    
+        

+ 46 - 0
txtsplit.py

@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+# usage: txtsplit.py <input_file_name> <output_dir>
+# splits a txt2gam file into individual location files
+# encoded in utf-8, for git to better handle
+
+import os
+import sys
+import re
+import io
+import xml.etree.ElementTree as ET
+
+assert len(sys.argv) == 3, "usage:\ntxtsplit.py <input_file_name> <output_dir>"
+iname = str(sys.argv[1])
+odir = str(sys.argv[2])
+
+# read the project xml file first
+# let's do this later in order to implement directory structure
+"""
+tree = ET.parse('mod_AddedFlavour.qproj')
+root = tree.getroot()
+"""
+
+ifile = io.open(iname, 'rt', encoding='utf-16')
+
+counter = 1
+
+oname = None
+firstline = ifile.readline().replace(u'\ufeff','')
+match = re.search(ur'^#\s(\$?[_.\w]+)$', firstline)
+if match:
+    oname = os.path.join(odir, match.group(1).replace("$","_") + '.qsrc' )
+    counter += 1
+assert oname, "file is in the wrong format, must start with a location name"
+
+ofile = io.open(oname, 'w', encoding='utf-8')
+ofile.write(firstline)
+
+for line in ifile:
+    match = re.search(ur'^#\s(\$?[_.\w]+)$', line)
+    if match:
+        ofile.close()
+        oname = os.path.join(odir, match.group(1).replace("$","_") + '.qsrc' )
+        counter += 1
+        ofile = io.open(oname, 'w', encoding='utf-8')
+    ofile.write(line)
+        

+ 46 - 0
txtsplit3.py

@@ -0,0 +1,46 @@
+#!/usr/bin/env python3
+# usage: txtsplit.py <input_file_name> <output_dir>
+# splits a txt2gam file into individual location files
+# encoded in utf-8, for git to better handle
+
+import os
+import sys
+import re
+import io
+import xml.etree.ElementTree as ET
+
+assert len(sys.argv) == 3, "usage:\ntxtsplit.py <input_file_name> <output_dir>"
+iname = str(sys.argv[1])
+odir = str(sys.argv[2])
+
+# read the project xml file first
+# let's do this later in order to implement directory structure
+"""
+tree = ET.parse('mod_AddedFlavour.qproj')
+root = tree.getroot()
+"""
+
+ifile = io.open(iname, 'rt', encoding='utf-16')
+
+counter = 1
+
+oname = None
+firstline = ifile.readline().replace(u'\ufeff','')
+match = re.search('^#\s(\$?[_.\w]+)$', firstline)
+if match:
+    oname = os.path.join(odir, match.group(1).replace("$","_") + '.qsrc' )
+    counter += 1
+assert oname, "file is in the wrong format, must start with a location name"
+
+ofile = io.open(oname, 'w', encoding='utf-8')
+ofile.write(firstline)
+
+for line in ifile:
+    match = re.search('^#\s(\$?[_.\w]+)$', line)
+    if match:
+        ofile.close()
+        oname = os.path.join(odir, match.group(1).replace("$","_") + '.qsrc' )
+        counter += 1
+        ofile = io.open(oname, 'w', encoding='utf-8')
+    ofile.write(line)
+