-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsteamModLoad.py
193 lines (144 loc) · 5.84 KB
/
steamModLoad.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#2023
import os;
import shutil;
from PyQt5.QtWidgets import *;
from PyQt5.QtCore import pyqtSlot
from PyQt5.QtGui import QPixmap;
import sys;
#paths to Ravenfield Mod folder and saved folder
list = 'C:/Program Files (x86)/Steam/steamapps/workshop/content/636480'
destination = 'C:/Program Files (x86)/Steam/steamapps/workshop/content/636480/saved'
green = '\u001b[32m';
reset = '\u001b[0m';
os.system("cls");
#Gets folder mod is in (ID)
#Type is either 'LOADED or 'SAVED' to determine which path to check
def getModID(modName, type):
dirTarget = "";
if(type == "LOADED"):
dirTarget = list;
elif(type == "SAVED"):
dirTarget = destination;
for path, dirs, files in os.walk(dirTarget):
for d in dirs:
if(os.path.isfile(dirTarget + "/" + d + "/" + modName)):
return d;
def loadMod(name, id):
shutil.move(destination + "/" + id, list + "/" + id);
print("Loaded mod " + name + "! (" + id + ")");
def unloadMod(name, id):
shutil.move(list + "/" + id, destination + "/" + id);
print("Unloaded mod " + name + "! (" + id + ")");
def getLoaded():
loadedMods = [];
for path, dirs, files in os.walk(list):
dirname = path.split(os.path.sep)[-1];
if(dirname == "saved"):
break;
#print(green,"\n============================",dirname,"============================",reset);
for f in files:
if("rfc" in f or "rfl" in f):
loadedMods.append(f);
return loadedMods
def getSaved():
savedMods = [];
for path, dirs, files in os.walk(destination):
dirname = path.split(os.path.sep)[-1];
#print(green,"\n============================",dirname,"============================",reset);
for f in files:
if("rfc" in f or "rfl" in f):
savedMods.append(f);
return savedMods;
def unloadAll(modList):
for mod in modList:
for path, dirs, files in os.walk(list):
for d in dirs:
if(os.path.isfile(list + "/" + d + "/" + mod)):
unloadMod(mod, d);
def loadAll(modList):
for mod in modList:
for path, dirs, files in os.walk(list):
for d in dirs:
if(os.path.isfile(list + "/" + d + "/" + mod)):
loadMod(mod, d);
#Loads the icon png of the selected mod
def loadImg(id, type):
path = "";
if(type == "LOADED"):
path = list;
elif(type == "SAVED"):
path = destination;
path = path + "/"+id + "/icon.png";
print(path);
img = QPixmap(path)
img = img.scaled(256, 256);
return img
#Application class and GUI
class App(QWidget):
loadedMods = None
savedMods = None;
modIcon = None;
def __init__(self):
super().__init__()
self.title = 'Mod Manager'
self.left = 10
self.top = 100
self.width = 800
self.height = 800
self.initUI()
def initUI(self):
self.setWindowTitle(self.title)
self.setGeometry(self.left, self.top, self.width, self.height)
self.modIcon = QLabel("icon.png", self)
self.modIcon.setFixedSize(256, 256);
self.modIcon.move(450,20);
self.loadedMods = QListWidget()
self.loadedMods.setFixedSize(400, 400)
self.loadedMods.clicked.connect(self.show_loaded_icon)
loadList = getLoaded();
#populate QList with currently loaded mods
for mod in loadList:
QListWidgetItem(mod, self.loadedMods)
self.savedMods = QListWidget()
self.savedMods.setFixedSize(400, 400)
self.savedMods.clicked.connect(self.show_saved_icon)
savedList = getSaved();
#populate QList with currently unloaded mods
for mod in savedList:
QListWidgetItem(mod, self.savedMods)
window_layout = QVBoxLayout(self)
window_layout.addWidget(self.loadedMods)
window_layout.addWidget(self.savedMods)
self.setLayout(window_layout)
button = QPushButton('Load', self)
button.move(500,300)
button.clicked.connect(self.btn_load)
unloadBtn = QPushButton('Unload', self)
unloadBtn.move(600,300)
unloadBtn.clicked.connect(self.btn_unload)
self.show()
@pyqtSlot()
def btn_load(self): #load selected mod
item = self.savedMods.currentItem()
self.loadedMods.addItem(item.text());
self.savedMods.takeItem(self.savedMods.row(item))
loadMod(item.text(),getModID(item.text(), "SAVED"));
def btn_unload(self): #unload selected mod
item = self.loadedMods.currentItem()
if(item == None):
return;
self.savedMods.addItem(item.text());
self.loadedMods.takeItem(self.loadedMods.row(item))
unloadMod(item.text(),getModID(item.text(), "LOADED"));
def show_saved_icon(self, savedMods): #show icon.png of current mod selected (unloaded)
item = self.savedMods.currentItem()
print(item.text())
self.modIcon.setPixmap(loadImg(getModID(item.text(),"SAVED"), "SAVED"))
def show_loaded_icon(self, loadedMods): #show icon.png of current mod selected (loaded)
item = self.loadedMods.currentItem()
print(item.text())
self.modIcon.setPixmap(loadImg(getModID(item.text(),"LOADED"), "LOADED"))
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = App()
sys.exit(app.exec_())