Initial Commit
-
This commit is contained in:
commit
42033b8c60
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
bin/python/
|
||||||
|
games/*/
|
||||||
|
mods/*/
|
9
launch.bat
Normal file
9
launch.bat
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
@echo off
|
||||||
|
:start
|
||||||
|
cls
|
||||||
|
cd %~dp0
|
||||||
|
::set tmp=%~dp0\bin\tmp
|
||||||
|
::set temp=%tmp%
|
||||||
|
bin\python\python.exe py\modloader.py
|
||||||
|
pause
|
||||||
|
goto start
|
162
py/modloader.py
Normal file
162
py/modloader.py
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
#Imports
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
import stat
|
||||||
|
import ctypes
|
||||||
|
|
||||||
|
#Working variables
|
||||||
|
version = 0.1
|
||||||
|
scriptPath = os.path.join(os.path.dirname(os.path.realpath(__file__)),"..")
|
||||||
|
gamesPath = os.path.join(scriptPath,"games")
|
||||||
|
baseTitle = "Universal ModLoader " +str(version)
|
||||||
|
|
||||||
|
def main():
|
||||||
|
while True:
|
||||||
|
title(baseTitle)
|
||||||
|
clear()
|
||||||
|
print("Games:")
|
||||||
|
|
||||||
|
index = 1
|
||||||
|
for root,dirs,files in walklevel(gamesPath,0):
|
||||||
|
for dir in dirs:
|
||||||
|
print(str(index)+ ") " +dir)
|
||||||
|
index = index + 1
|
||||||
|
|
||||||
|
print("")
|
||||||
|
print("S) Search Games, A) Add Game")
|
||||||
|
choice = input("Choice: ")
|
||||||
|
if choice.lower() == "a": addGame(); continue
|
||||||
|
if choice.lower() == "s": searchGames(); continue
|
||||||
|
if isType(int,choice) == False: continue;
|
||||||
|
if int(choice) > index - 1 or int(choice) < 1: continue
|
||||||
|
|
||||||
|
game = getFolderByIndex(gamesPath,int(choice)-1)
|
||||||
|
if game == "": continue
|
||||||
|
manageGame(game)
|
||||||
|
|
||||||
|
def manageGame(game):
|
||||||
|
gamePath = os.path.join(gamesPath,game)
|
||||||
|
profilesPath = os.path.join(gamePath,"profiles")
|
||||||
|
|
||||||
|
while True:
|
||||||
|
title(baseTitle+ " - " +game)
|
||||||
|
clear()
|
||||||
|
print("B) Back")
|
||||||
|
print("E) Edit Game, R) Reload Mods, U) Unload Mods")
|
||||||
|
print("")
|
||||||
|
print("Profiles:")
|
||||||
|
|
||||||
|
index = 1
|
||||||
|
for root,dirs,files in walklevel(profilesPath,0):
|
||||||
|
for dir in dirs:
|
||||||
|
print(str(index)+ ") " +dir)
|
||||||
|
index = index + 1
|
||||||
|
|
||||||
|
print("")
|
||||||
|
print("S) Search Profiles, A) Add Profile")
|
||||||
|
choice = input("Choice: ")
|
||||||
|
|
||||||
|
|
||||||
|
def getFolderByIndex(searchFolder,wanted):
|
||||||
|
index = 0
|
||||||
|
for root,dirs,files in walklevel(searchFolder,0):
|
||||||
|
for dir in dirs:
|
||||||
|
if index == wanted: return dir
|
||||||
|
index = index + 1
|
||||||
|
|
||||||
|
return ""
|
||||||
|
|
||||||
|
def walklevel(some_dir, level=1):
|
||||||
|
some_dir = some_dir.rstrip(os.path.sep)
|
||||||
|
assert os.path.isdir(some_dir)
|
||||||
|
num_sep = some_dir.count(os.path.sep)
|
||||||
|
for root, dirs, files in os.walk(some_dir):
|
||||||
|
yield root, dirs, files
|
||||||
|
num_sep_this = root.count(os.path.sep)
|
||||||
|
if num_sep + level <= num_sep_this:
|
||||||
|
del dirs[:]
|
||||||
|
|
||||||
|
def clear():
|
||||||
|
if os.name == "nt":
|
||||||
|
os.system("cls")
|
||||||
|
else:
|
||||||
|
os.system("clear")
|
||||||
|
|
||||||
|
def title(titleText):
|
||||||
|
if os.name == "nt":
|
||||||
|
ctypes.windll.kernel32.SetConsoleTitleW(titleText)
|
||||||
|
else:
|
||||||
|
sys.stdout.write("\x1b]2;" +titleText+ "\x07") #needs testing
|
||||||
|
|
||||||
|
def isType(type,value):
|
||||||
|
try:
|
||||||
|
type(value)
|
||||||
|
return True
|
||||||
|
except ValueError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
########################################OLD########################################
|
||||||
|
def setupFolder():
|
||||||
|
while True:
|
||||||
|
gameFolder = input("Drag + Drop GTA SA's folder in here and press enter:\n")
|
||||||
|
gameFolder = gameFolder.replace("\"","")
|
||||||
|
if os.path.isfile(os.path.join(gameFolder,"gta_sa.exe")):
|
||||||
|
file = open(os.path.join(scriptPath,"gtasafolder.txt"),"w")
|
||||||
|
file.write(gameFolder)
|
||||||
|
file.close()
|
||||||
|
return True
|
||||||
|
clear()
|
||||||
|
print("'gta_sa.exe' was not found in this path. Try again.")
|
||||||
|
|
||||||
|
def loadMods():
|
||||||
|
clear()
|
||||||
|
print("Please wait...")
|
||||||
|
originalFolder = gameFolder+ " - Original"
|
||||||
|
if not os.path.isdir(originalFolder): os.rename(gameFolder,originalFolder)
|
||||||
|
if os.path.isdir(gameFolder): shutil.rmtree(gameFolder)
|
||||||
|
for root,dirs,files in walklevel(os.path.join(scriptPath,"mods"),0):
|
||||||
|
for dir in dirs:
|
||||||
|
if dir[0] != "-": cloneFolder(os.path.join(root,dir),gameFolder,True)
|
||||||
|
|
||||||
|
cloneFolder(originalFolder,gameFolder,False)
|
||||||
|
input("\nMods have been successfully loaded. Press any key to continue.")
|
||||||
|
return True
|
||||||
|
|
||||||
|
def unloadMods():
|
||||||
|
clear()
|
||||||
|
print("Please wait...")
|
||||||
|
originalFolder = gameFolder+ " - Original"
|
||||||
|
if not os.path.isdir(originalFolder):
|
||||||
|
clear()
|
||||||
|
input("Mods are already unloaded. Press any key to continue.")
|
||||||
|
return True
|
||||||
|
|
||||||
|
shutil.rmtree(gameFolder)
|
||||||
|
os.rename(originalFolder,gameFolder)
|
||||||
|
input("\nMods have been successfully unloaded. Press any key to continue.")
|
||||||
|
return True
|
||||||
|
|
||||||
|
def getGameFolder():
|
||||||
|
file = open(os.path.join(scriptPath,"gtasafolder.txt"))
|
||||||
|
for line in file:
|
||||||
|
file.close()
|
||||||
|
return line.replace("\n","")
|
||||||
|
|
||||||
|
def cloneFolder(src,dest,overwrite):
|
||||||
|
for root,dirs,files in os.walk(src):
|
||||||
|
for file in files:
|
||||||
|
srcFile = os.path.join(root,file)
|
||||||
|
newFile = srcFile.replace(src,dest)
|
||||||
|
newFolder = os.path.dirname(newFile)
|
||||||
|
if not os.path.isdir(newFolder): os.makedirs(newFolder)
|
||||||
|
|
||||||
|
if overwrite == True:
|
||||||
|
if os.path.isfile(newFile): os.remove(newFile)
|
||||||
|
|
||||||
|
if not os.path.isfile(newFile):
|
||||||
|
#os.system('mklink /H "' +newFile+ '" "' +srcFile+ '"')
|
||||||
|
os.link(srcFile,newFile)
|
||||||
|
print("Linking '" +srcFile+ "' to '" +newFile+ "'...")
|
Loading…
Reference in New Issue
Block a user