-
Notifications
You must be signed in to change notification settings - Fork 0
/
absolver.py
138 lines (108 loc) · 5.22 KB
/
absolver.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
import sys
import json
from PyQt5.QtWidgets import QMainWindow, QAction, QDesktopWidget, QApplication, QComboBox, QVBoxLayout, QHBoxLayout, QWidget, QSpacerItem, QGridLayout, QPushButton, QLayoutItem
from PyQt5.QtGui import QIcon, QImage, QBrush, QPalette
from PyQt5.QtCore import QSize, Qt
class Window(QMainWindow):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
# Menu creation
exitAct = QAction(QIcon('res/cat.jpeg'), 'Exit', self)
exitAct.setShortcut('Ctrl+Alt+Shift+Q')
exitAct.setStatusTip('Exit application')
exitAct.triggered.connect(self.close)
createAct = QAction(QIcon('res/HYPERBRUH.jpeg'), 'Create new block', self) # Dope icon(...?)
createAct.setShortcut('F5')
createAct.setStatusTip('Create new block')
# Creating a statusBar to show statusTips
self.statusBar()
# Adding stuff to the window
menubar = self.menuBar()
fileMenu = menubar.addMenu('&File')
fileMenu.addAction(exitAct)
fileMenu.addAction(createAct)
toolbar = self.addToolBar('Create')
toolbar.addAction(createAct)
toolbar.addAction(exitAct)
# QGridLayout setup
self.grid = QGridLayout()
self.combos = [
'1', '1', '1', '', '1.5', # 1: Attacks from top right
'2', '1', '1', '', '2.5', # 2: Attacks from top left
'1', '1', '1', '', '3.5', # 3: Attacks from bottom right (.5 means attacks ending in the starting position are taken out
'1', '1', '1', '', '4.5'] # 4: Attacks from bottom left because alternate attacks do not allow them)
comboList = {}
positions = [(i,j) for i in range(5) for j in range(5)]
for position, drawcombo in zip(positions, self.combos):
self.combo = QComboBox()
pcstr = """self.combo.setAutoFillBackground(True)
p = QPalette()
p.setColor(self.backgroundRole(), Qt.black)
self.setPalette(p)"""
self.combo.setStyleSheet("background-color: #333333; color: #FFFFFF; selection-background-color: #660000")
self.combo.palette().highlight().color().name()
if drawcombo == '':
continue
elif drawcombo == '1':
for x in range(0, 49):
data = json.loads("absolver_deck_reviewer/Absolver-Data/attacks/all.json")
self.combo.addItem(QIcon('absolver_deck_reviewer/Absolver-Data/AttackPictos.png/{}.png'.format(x)), "placeholder :D")
elif drawcombo == '2': #TODO: Combo selection
pass
elif drawcombo == '3':
pass
elif drawcombo == '4':
pass
elif drawcombo == '1.5':
pass
elif drawcombo == '2.5':
pass
elif drawcombo == '3.5':
pass
elif drawcombo == '4.5':
pass
else:
print("Error: Undefined combo at", position)
self.combo.setFixedSize(120,100)
self.combo.setIconSize(QSize(100,100))
self.grid.addWidget(self.combo, *position)
comboList['combo{0}'.format(position)] = position
self.combo.currentIndexChanged.connect(
lambda ix, p=position: self.logChange(comboList['combo{0}'.format(p)]))
self.grid.setColumnMinimumWidth(3, 150)
# Final window stuff
placeholder = QWidget()
placeholder.setLayout(self.grid)
# STOLEN CODE (this piece of stolen code sets a background, disabled because it causes lag)
bg = QImage("absolver_deck_reviewer/background.png")
sc_bg = bg.scaled(QSize(1200,800))
palette = QPalette()
palette.setBrush(10, QBrush(sc_bg)) # 10 = Windowrole (??? What does that even mean???)
self.setPalette(palette)
# END OF STOLEN CODE
self.setCentralWidget(placeholder)
self.setFixedSize(1200,800)
self.setWindowTitle('Deck builder')
self.centerOnScreen()
self.show()
def centerOnScreen (self):
resolution = QDesktopWidget().screenGeometry()
self.move((resolution.width() / 2) - (self.frameSize().width() / 2),
(resolution.height() / 2) - (self.frameSize().height() / 2))
def logChange(self, currentCombo):
print(str(currentCombo) + ' was changed')
print(self.combos)
changed_combo = self.grid.itemAtPosition(currentCombo[0], currentCombo[1])
coords = currentCombo[0], currentCombo[1]+1
adj_combo = self.grid.itemAtPosition(coords[0], coords[1])
if(adj_combo and adj_combo.widget()):
adj_combo.widget().deleteLater()
print("Changed combo is" + self.combos[coords[0]])
def get_json_data(self, count, drawcombo):
count += 1
if __name__ == '__main__':
app = QApplication(sys.argv)
window = Window()
sys.exit(app.exec_())