summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2022-10-24 12:21:41 -0300
committerJesusaves <cpntb1@ymail.com>2022-10-24 12:21:41 -0300
commit7a8e6b39722d3568358b9a0c3b2a6226bf9e680b (patch)
treeca75448607ce1073f087effc97839e709481e58c
parentb9ac8ed0dc8eabe11616596c5f17fd2ce4156127 (diff)
downloadtools-7a8e6b39722d3568358b9a0c3b2a6226bf9e680b.tar.gz
tools-7a8e6b39722d3568358b9a0c3b2a6226bf9e680b.tar.bz2
tools-7a8e6b39722d3568358b9a0c3b2a6226bf9e680b.tar.xz
tools-7a8e6b39722d3568358b9a0c3b2a6226bf9e680b.zip
Split everything in its own folder, but 2nd degree recursivity breaks stuff
-rwxr-xr-xmerge-client.py113
1 files changed, 77 insertions, 36 deletions
diff --git a/merge-client.py b/merge-client.py
index 50c0a45..33f2f44 100755
--- a/merge-client.py
+++ b/merge-client.py
@@ -25,55 +25,96 @@ def fix_id(l, offset):
l="\"".join(tmp)
return l
-## This is to find misc files and copy them over, but
-## We probably could just c/p one over the other >.>
-def hp(l, WHERE):
+## This is to find misc files and copy them over with new path
+## TODO: sfx makes it confuse (has "quotes" but is enclosed in >arrows<)
+## ALSO: Dyed items e.g. "equipment/chest/cottonshirt.png|W"
+## ALSO: Sprites may have "quotes" but be enclosed in >arrows<
+def hp(l, WHERE, sub):
global paths
if "<include" in l:
return l
if ".png" in l or ".ogg" in l or ".xml" in l:
- tmpi=l.split("\"")
- if len(tmpi) == 1:
+ ## Determine the type of split
+ if "<sprite" in l or "sprite>" in l:
tmpi=l.split("sprite")
- for e in tmpi:
+ ori=0
+ #elif "sound" in l:
+ else:
+ tmpi=l.split("\"")
+ ori=1
+
+ ## Process it
+ for i, e in enumerate(tmpi):
+ raw=str(e)
+ if ">" in e:
+ e=raw[raw.index('>')+1:]
e=e.replace(">", "").replace("<", "")
+ e=e.split("|")[0] # Remove dye
if e.endswith("/"):
e=e[:-1]
- if e.endswith(".png"):
- paths.append(e)
- elif e.endswith(".ogg"):
+ if e.endswith(".png") or e.endswith(".ogg"):
paths.append(e)
+ if ">" in raw:
+ tmpi[i]="%s>%s/%s" % (raw[:raw.index('>')], sub, raw[raw.index('>')+1:])
+ else:
+ tmpi[i]="%s/%s" % (sub, raw)
elif e.endswith(".xml"):
- paths.append(e)
+ #paths.append(e)
+ if ">" in raw:
+ tmpi[i]="%s>%s/%s" % (raw[:raw.index('>')], sub, raw[raw.index('>')+1:])
+ else:
+ tmpi[i]="%s/%s" % (sub, raw)
## We must also open the XML and extract paths from it
pt="NO PATH FOUND"
if os.path.exists("%s/%s" % (WHERE, e)):
pt = "%s/%s" % (WHERE, e)
+ TARG = "%s/%s/%s" % (MYSELF, sub, e)
elif os.path.exists("%s/graphics/sprites/%s" % (WHERE, e)):
pt = "%s/graphics/sprites/%s" % (WHERE, e)
+ TARG = "%s/graphics/sprites/%s/%s" % (MYSELF, sub, e)
elif os.path.exists("%s/graphics/%s" % (WHERE, e)):
pt = "%s/graphics/%s" % (WHERE, e)
-
- with open(pt, 'r') as j:
- for k in j:
- i=k.split("\"")
- for n in i:
- if n.endswith(".png"):
- paths.append(n)
- # TODO: Update the line with a prefix
+ TARG = "%s/graphics/%s/%s" % (MYSELF, sub, e)
+ else:
+ print("\033[1mNO path: %s\033[0m" % e)
+
+ if pt != "NO PATH FOUND":
+ bf=[]
+ with open(pt, 'r') as j:
+ for k in j:
+ h=k.split("\"")
+ for g, n in enumerate(h):
+ ## TODO: Dye
+ if n.split("|")[0].endswith(".png"):
+ paths.append(n.split("|")[0])
+ h[g]="%s/%s" % (sub, n)
+ bf.append("\"".join(h))
+
+ ## Unfortunately, we must save 'bf' here so it is safely done
+ os.makedirs(os.path.abspath("/".join(TARG.split("/")[:-1])), exist_ok=True)
+ with open("%s" % (TARG), "w") as j:
+ for k in bf:
+ j.write(k)
+
+ ## Update the line
+ if ori == 0:
+ l="sprite".join(tmpi)
+ else:
+ l="\"".join(tmpi)
+ # Send the line with the prefix
return l
-def unify(YESELF):
+def unify(YESELF, sub):
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)
+ os.makedirs(os.path.abspath("%s/%s/%s" % (MYSELF, sub, i)), exist_ok=True)
shutil.copy2("%s/%s" % (YESELF, f),
- "%s/%s" % (MYSELF, f))
+ "%s/%s/%s" % (MYSELF, sub, f))
continue
except FileNotFoundError:
pass
@@ -82,9 +123,9 @@ def unify(YESELF):
## Raw2 Copy
try:
- os.makedirs(os.path.abspath("%s/graphics/%s" % (MYSELF, i)), exist_ok=True)
+ os.makedirs(os.path.abspath("%s/graphics/%s/%s" % (MYSELF, sub, i)), exist_ok=True)
shutil.copy2("%s/graphics/%s" % (YESELF, f),
- "%s/graphics/%s" % (MYSELF, f))
+ "%s/graphics/%s/%s" % (MYSELF, sub, f))
continue
except FileNotFoundError:
pass
@@ -93,9 +134,9 @@ def unify(YESELF):
## Item Icon Copy
try:
- os.makedirs(os.path.abspath("%s/graphics/items/%s" % (MYSELF, i)), exist_ok=True)
+ os.makedirs(os.path.abspath("%s/graphics/items/%s/%s" % (MYSELF, sub, i)), exist_ok=True)
shutil.copy2("%s/graphics/items/%s" % (YESELF, f),
- "%s/graphics/items/%s" % (MYSELF, f))
+ "%s/graphics/items/%s/%s" % (MYSELF, sub, f))
continue
except FileNotFoundError:
pass
@@ -104,9 +145,9 @@ def unify(YESELF):
## Spritesheet Copy
try:
- os.makedirs(os.path.abspath("%s/graphics/sprites/%s" % (YESELF, i)), exist_ok=True)
+ os.makedirs(os.path.abspath("%s/graphics/sprites/%s/%s" % (MYSELF, sub, i)), exist_ok=True)
shutil.copy2("%s/graphics/sprites/%s" % (YESELF, f),
- "%s/graphics/sprites/%s" % (MYSELF, f))
+ "%s/graphics/sprites/%s/%s" % (MYSELF, sub, f))
continue
except FileNotFoundError:
print("\033[1mFailed to copy: %s\033[0m" % f)
@@ -143,12 +184,12 @@ with open("%s/items.xml" % MOUBOO, "r") as f:
continue
if "</items>" in j:
break
- j=hp(j, MOUBOO)
+ j=hp(j, MOUBOO, 'ml')
item_db.append(j)
continue
## Save the line
- l=hp(l, MOUBOO)
+ l=hp(l, MOUBOO, 'ml')
item_db.append(l)
while not "</items>" in item_db[-1]:
item_db=item_db[:-1]
@@ -157,7 +198,7 @@ print("\033[32;1mMoubootaur Legends OK\033[0m")
## Handle copy pastes
-unify(MOUBOO)
+unify(MOUBOO, 'ml')
################################################################################
## Legacy/Evolved has an offset of 10k
@@ -184,7 +225,7 @@ with open("%s/items.xml" % EVOLVED, "r") as f:
if "</items>" in j:
break
j=fix_id(j, 10000)
- j=hp(j, EVOLVED)
+ j=hp(j, EVOLVED, 'tmw')
item_db.append(j)
continue
@@ -193,7 +234,7 @@ with open("%s/items.xml" % EVOLVED, "r") as f:
if "<items>" in l:
saving=True
continue
- l=hp(l, EVOLVED)
+ l=hp(l, EVOLVED, 'tmw')
item_db.append(l)
while not "</items>" in item_db[-1]:
item_db=item_db[:-1]
@@ -203,7 +244,7 @@ print("\033[32;1mLegacy/Evolved OK\033[0m")
## Handle copy pastes
-unify(EVOLVED)
+unify(EVOLVED, 'tmw')
################################################################################
## rEvolt has an offset of 20k
@@ -230,7 +271,7 @@ with open("%s/items.xml" % REVOLT, "r") as f:
if "</items>" in j:
break
j=fix_id(j, 20000)
- j=hp(j, REVOLT)
+ j=hp(j, REVOLT, 're')
item_db.append(j)
continue
@@ -239,7 +280,7 @@ with open("%s/items.xml" % REVOLT, "r") as f:
if "<items>" in l:
saving=True
continue
- l=hp(l, REVOLT)
+ l=hp(l, REVOLT, 're')
item_db.append(l)
while not "</items>" in item_db[-1]:
item_db=item_db[:-1]
@@ -249,7 +290,7 @@ print("\033[32;1mrEvolt OK\033[0m")
## Handle copy pastes
-unify(REVOLT)
+unify(REVOLT, 're')