1
0
Pārlūkot izejas kodu

fix image path, add python3 splitter, update gitignore

Mona Lisa 6 gadi atpakaļ
vecāks
revīzija
582d4bd524
3 mainītis faili ar 51 papildinājumiem un 3 dzēšanām
  1. 3 1
      .gitignore
  2. 2 2
      locations/Military
  3. 46 0
      txtsplit3.py

+ 3 - 1
.gitignore

@@ -8,4 +8,6 @@ glife.txt
 qgen.cfg
 qspgui.cfg
 avatar.*
-
+*.jpg
+*.jpeg
+*.sublime-*

+ 2 - 2
locations/Military

@@ -29,7 +29,7 @@ if $ARGS[0] = 'start':
 
 	act 'Take a walk in the woods':
 		cls
-		'<center><img <<$set_imgh>> src="images/img/_nuki/military/woman_forest.jpg"></center>'
+		'<center><img <<$set_imgh>> src="images/locations/city/shared/military/woman_forest.jpg"></center>'
 		minut += 60
 		milprorand = rand(0, 10)
 		gs 'stat'
@@ -126,7 +126,7 @@ if $ARGS[0] = 'pro1':
 	act 'Ignore it':gt 'military', 'rape'
 
 	act 'Run away':
-		'<center><img <<$set_imgh>> src="images/img/_nuki/military/forest_running.jpg"></center>'
+		'<center><img <<$set_imgh>> src="images/locations/city/shared/military/forest_running.jpg"></center>'
 		if pcs_run < 10:
 			peshimraperand = rand(0, 11)
 		elseif pcs_run < 20:

+ 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('glife.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("$","_") )
+    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("$","_") )
+        counter += 1
+        ofile = io.open(oname, 'w', encoding='utf-8')
+    ofile.write(line)
+