Преглед на файлове

update `BuildModFiles.py`

Stephan Fuchs преди 2 месеца
родител
ревизия
29954c454b
променени са 6 файла, в които са добавени 3 реда и са изтрити 106 реда
  1. 3 14
      mods/util/BuildModFiles.py
  2. 0 3
      mods/util/MakeMod.bat
  3. 0 40
      mods/util/MakeMod.py
  4. 0 3
      mods/util/MakeModableHtml.bat
  5. 0 21
      mods/util/MakeModableHtml.py
  6. 0 25
      mods/util/ModloaderScript.txt

+ 3 - 14
mods/util/BuildModFiles.py

@@ -9,10 +9,6 @@ modTag = "mod"
 
 file_path_html = 'glife.html'
 file_path_mod = 'mods/mod.html'
-file_path_localmod = 'mods/glife_local_mod.html'
-file_path_remotemod = 'mods/glife_remote_mod.html'
-
-file_path_modloader = 'mods/util/ModloaderScript.txt'
 
 data = ''
 modData = ''
@@ -42,21 +38,14 @@ for match in re.finditer(regex,data,re.S):
     scripts += match.group(1)
     dataWithoutModStuff = dataWithoutModStuff.replace(match.group(0),'')
 
-modData += '<script>'+scripts+'</script>'
+modData += "\n.-.-.-. STORYDATA / SCRIPT .-.-.-.\n"
+
+modData += scripts
 
 with open(file_path_mod, 'w') as file:
     file.write(modData)
 
 
-data_localmod = dataWithoutModStuff.replace('</tw-storydata>',modData+'</tw-storydata>',1)
-with open(file_path_localmod, 'w') as file:
-    file.write(data_localmod)
-
 
-with open(file_path_modloader, 'r') as file:
-    modloader_data = file.read()
-data_remtotemod = re.sub(r"""(<script id="script-sugarcube" type="text/javascript">)(.*?)(</script>)""",r"""\1"""+modloader_data+r""" \2}\3""",dataWithoutModStuff,1, re.S)
-with open(file_path_remotemod, 'w') as file:
-    file.write(data_remtotemod)
 
 print('Done')

+ 0 - 3
mods/util/MakeMod.bat

@@ -1,3 +0,0 @@
-@ECHO off
-
-Python -X utf8 mods/util/MakeMod.py

+ 0 - 40
mods/util/MakeMod.py

@@ -1,40 +0,0 @@
-#!/usr/bin/env python3
-import os
-import fileinput
-import re
-import sys
-
-
-modTag = "mod"
-
-file_path_html = 'glife.html'
-file_path_mod = 'mods/mod.html'
-
-data = ''
-modData = ''
-scripts = ''
-
-with open(file_path_html, 'r') as file:
-    data = file.read()
-
-i = 0
-regex = r"""<tw-passagedata pid="(\d+)" name="([\s\w]+)" tags="(.*?)" (?:position="\d+,\d+" )?(?:size="\d+,\d+")?>(.*?)</tw-passagedata>"""
-for match in re.finditer(regex,data,re.S):
-    tags = match.group(3).split()
-
-    if(modTag in tags):
-        modData += match.group(0)+'\n'
-    i += 1
-    if(i % 100 == 0):
-        print(i)
-
-regex = r"""/\*\s*Start Mod:\s*"Mod"\s*\*/(.*?)/\*\s*End Mod:\s*"Mod"\s*\*/"""
-for match in re.finditer(regex,data,re.S):
-    scripts += match.group(1)
-
-modData += '<script>'+scripts+'</script>'
-
-with open(file_path_mod, 'w') as file:
-    file.write(modData)
-
-print('Done')

+ 0 - 3
mods/util/MakeModableHtml.bat

@@ -1,3 +0,0 @@
-@ECHO off
-
-Python -X utf8 mods/util/MakeModableHtml.py

+ 0 - 21
mods/util/MakeModableHtml.py

@@ -1,21 +0,0 @@
-#!/usr/bin/env python3
-import os
-import fileinput
-import re
-import sys
-
-file_path_html = 'glife.html'
-file_path_out = 'mods/modable_glife.html'
-
-data = ''
-with open(file_path_html, 'r') as file:
-    data = file.read()
-
-
-data = re.sub(r"""(<script id="script-sugarcube" type="text/javascript">)(.*?)(</script>)""",r"""\1$.ajax({  url: "mod.html",  cache: false})  .done(function( html ) {    $( "tw-storydata" ).append( html );\2});\3""",data,1, re.S)
-
-
-with open(file_path_out, 'w') as file:
-    file.write(data)
-
-print('Done')

+ 0 - 25
mods/util/ModloaderScript.txt

@@ -1,25 +0,0 @@
-let modSettings = JSON.parse(localStorage.getItem("glife_mods") || "{}")
-let modsToBeLoadedCount = 0;
-let modsToBeLoadedPaths = [];
-
-for (const [modId, modData] of Object.entries(modSettings)) {
-    if(modData.enabled){
-        modsToBeLoadedCount += 1;
-        modsToBeLoadedPaths.push(modData.path);
-    }
-}
-
-if(modsToBeLoadedCount == 0)
-    executeDefaultSC()
-else{
-    for(let modsToBeLoadedPath of modsToBeLoadedPaths){
-        $.ajax({  url: modsToBeLoadedPath,  cache: false}).done(function( html ) {
-            $( "tw-storydata" ).append( html );
-            modsToBeLoadedCount -= 1;
-            if(modsToBeLoadedCount <= 0)
-                executeDefaultSC();
-        });
-    }
-}
-
-function executeDefaultSC(){