summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2022-10-24 10:36:28 -0300
committerJesusaves <cpntb1@ymail.com>2022-10-24 10:36:28 -0300
commita19801b6dfbf62e5f962c9aed7574ac961c2c165 (patch)
treee56c053da7a1ae6c705cbd984f1a0466d633ef36
parent58b34f91d7013c3cc3652aa1dff3ce1c8d7260b0 (diff)
downloadtools-a19801b6dfbf62e5f962c9aed7574ac961c2c165.tar.gz
tools-a19801b6dfbf62e5f962c9aed7574ac961c2c165.tar.bz2
tools-a19801b6dfbf62e5f962c9aed7574ac961c2c165.tar.xz
tools-a19801b6dfbf62e5f962c9aed7574ac961c2c165.zip
Copy XML/PNG/etc. as well
-rwxr-xr-xmerge-client.py90
1 files changed, 87 insertions, 3 deletions
diff --git a/merge-client.py b/merge-client.py
index 988fc40..a960fe0 100755
--- a/merge-client.py
+++ b/merge-client.py
@@ -1,6 +1,6 @@
#!/usr/bin/python3
# This consolidates client XMLs
-import os, traceback
+import os, shutil, traceback, subprocess, time
MYSELF="clientdata/"
EVOLVED="../pre-renewal/client-data/"
@@ -12,6 +12,7 @@ REVOLT="../evol/client-data/"
os.chdir("..")
item_db=[]
+paths=[]
def fix_id(l, offset):
if "id=" in l:
@@ -24,6 +25,74 @@ def fix_id(l, offset):
l="\"".join(tmp)
return l
+def hp(l):
+ global paths
+ if "<include" in l:
+ return
+ if ".png" in l or ".ogg" in l or ".xml" in l:
+ tmpi=l.split("\"")
+ for e in tmpi:
+ if e.endswith(".png"):
+ paths.append(e)
+ elif e.endswith(".ogg"):
+ paths.append(e)
+ elif e.endswith(".xml"):
+ paths.append(e)
+ return
+
+def unify(YESELF):
+ global paths
+ for f in paths:
+ i="/".join(f.split("/")[:-1])
+ ## Raw Copy
+ try:
+ os.makedirs(os.path.abspath("%s/%s" % (MYSELF, i)), exist_ok=True)
+ shutil.copy2("%s/%s" % (YESELF, f),
+ "%s/%s" % (MYSELF, f))
+ continue
+ except FileNotFoundError:
+ pass
+ except:
+ traceback.print_exc()
+
+ ## Raw2 Copy
+ try:
+ os.makedirs(os.path.abspath("%s/graphics/%s" % (MYSELF, i)), exist_ok=True)
+ shutil.copy2("%s/graphics/%s" % (YESELF, f),
+ "%s/graphics/%s" % (MYSELF, f))
+ continue
+ except FileNotFoundError:
+ pass
+ except:
+ traceback.print_exc()
+
+ ## Item Icon Copy
+ try:
+ os.makedirs(os.path.abspath("%s/graphics/items/%s" % (MYSELF, i)), exist_ok=True)
+ shutil.copy2("%s/graphics/items/%s" % (YESELF, f),
+ "%s/graphics/items/%s" % (MYSELF, f))
+ continue
+ except FileNotFoundError:
+ pass
+ except:
+ traceback.print_exc()
+
+ ## Spritesheet Copy
+ try:
+ os.makedirs(os.path.abspath("%s/graphics/sprites/%s" % (YESELF, i)), exist_ok=True)
+ shutil.copy2("%s/graphics/sprites/%s" % (YESELF, f),
+ "%s/graphics/sprites/%s" % (MYSELF, f))
+ continue
+ except FileNotFoundError:
+ print("\033[1mFailed to copy: %s\033[0m" % f)
+ pass
+ except:
+ traceback.print_exc()
+
+ paths=[]
+ return
+
+#################################################################################
## Moubootaur Legends is a raw copy
with open("%s/items.xml" % MOUBOO, "r") as f:
for l in f:
@@ -49,10 +118,12 @@ with open("%s/items.xml" % MOUBOO, "r") as f:
continue
if "</items>" in j:
break
+ hp(j)
item_db.append(j)
continue
## Save the line
+ hp(l)
item_db.append(l)
while not "</items>" in item_db[-1]:
item_db=item_db[:-1]
@@ -60,7 +131,8 @@ item_db=item_db[:-1]
print("\033[32;1mMoubootaur Legends OK\033[0m")
-
+## Handle copy pastes
+unify(MOUBOO)
## Legacy/Evolved has an offset of 10k
with open("%s/items.xml" % EVOLVED, "r") as f:
@@ -87,6 +159,7 @@ with open("%s/items.xml" % EVOLVED, "r") as f:
break
j=fix_id(j, 10000)
item_db.append(j)
+ hp(j)
continue
## Save the line
@@ -95,6 +168,7 @@ with open("%s/items.xml" % EVOLVED, "r") as f:
saving=True
continue
item_db.append(l)
+ hp(l)
while not "</items>" in item_db[-1]:
item_db=item_db[:-1]
#item_db=item_db[:-1]
@@ -102,6 +176,11 @@ print("\033[32;1mLegacy/Evolved OK\033[0m")
+## Handle copy pastes
+unify(EVOLVED)
+
+
+
## Save the final item database
@@ -111,5 +190,10 @@ with open(MYSELF+"items.xml", "w") as f:
print("\033[33;1mSaved! Databases merged!\033[0m")
-## TODO: Sync files
+## Clean empty dirs
+time.sleep(1)
+print("Now deleting empty folders:")
+time.sleep(4)
+os.chdir(MYSELF)
+subprocess.call("""find . -type d -empty -not -iwholename "./.*" -print -delete""", shell=True)