Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
* Add coloring for cards on field.
* Add Esc-exiting for subwindows.
  • Loading branch information
Wind2009-Louse committed Aug 2, 2020
1 parent 6981c39 commit 93e5330
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 20 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ __pycache__/
build/
dist/
main.spec
*.cdb
*.json
!version.json
4 changes: 4 additions & 0 deletions about.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ def check_update(self):
except Exception as e:
print(e)
self.label_3.setText("检查更新失败")

def keyPressEvent(self, event):
if event.key() == Qt.Key_Escape:
self.close()

if __name__ == "__main__":
app = QApplication(sys.argv)
Expand Down
9 changes: 6 additions & 3 deletions calculator.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#encoding:utf-8
import sys

from PyQt5 import QtCore
from PyQt5.QtCore import QRect, QRegExp
from PyQt5.QtCore import QRect, QRegExp, Qt
from PyQt5.QtGui import QColor, QRegExpValidator
from PyQt5.QtWidgets import (QApplication, QLabel, QLineEdit, QListWidget,
QTextBrowser, QWidget)
Expand Down Expand Up @@ -75,7 +74,7 @@ def __init__(self):

# hide scroll bar
for bar in [self.atk_line, self.def_line, self.add_line, self.sub_line, self.mul_line, self.div_line]:
bar.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
bar.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
bar.setTextColor(QColor('green'))

# connect
Expand Down Expand Up @@ -147,6 +146,10 @@ def show_ad(self):
args = self.card_data[cardname]
self.atk_line.setText(str(args[0]))
self.def_line.setText(str(args[1]))

def keyPressEvent(self, event):
if event.key() == Qt.Key_Escape:
self.close()

if __name__ == "__main__":
app = QApplication(sys.argv)
Expand Down
Binary file modified cards.cdb
Binary file not shown.
52 changes: 36 additions & 16 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
init_field = {"locations":{}, "desp":{}, "LP":[8000,8000], "fields":[]}
for t in range(len(idx_represent_str)):
init_field["fields"].append([])
version = 152
version = 153

class Update_Thread(Thread):
def __init__(self, window):
Expand Down Expand Up @@ -82,6 +82,13 @@ class Ui_MainWindow(QMainWindow):
update_signal = pyqtSignal(str)
download_signal = pyqtSignal(str)
process_signal = pyqtSignal(str)
bold_font = QFont()
bold_font.setBold(True)
italic_font = QFont()
italic_font.setItalic(True)
bold_italic_font = QFont()
bold_italic_font.setBold(True)
bold_italic_font.setItalic(True)

def placeframe(self):
menu_height = self.menuBar().height()
Expand Down Expand Up @@ -447,6 +454,10 @@ def __init__(self):
self.blur_search_bar.setChecked(True)
self.blur_search_bar.triggered.connect(self.search_card)
self.menu_bar_list.addAction(self.blur_search_bar)
self.coloring_field_card = QAction("按照卡片种类显示颜色",self,checkable=True)
self.coloring_field_card.setChecked(False)
self.coloring_field_card.triggered.connect(self.refresh_field)
self.menu_bar_list.addAction(self.coloring_field_card)

self.about_bar = QAction("关于", self)
self.about_bar.triggered.connect(self.open_about)
Expand Down Expand Up @@ -553,6 +564,7 @@ def __init__(self):
except Exception as e:
self.Newcard_List.addItem("无数据库")
self.Newcard_List.setEnabled(False)
self.coloring_field_card.setEnabled(False)

self.card_names = list(self.card_datas.keys())
self.card_names.sort(key=lambda x: (card_sorted[x]))
Expand Down Expand Up @@ -722,7 +734,7 @@ def retranslateUi(self):
def maketitle(self, process=""):
'''根据当前正在打开的文件修改窗口标题'''
if process is not None and process != "":
title_name = "DuelEditor(%s) - %s"%(process, self.filename)
title_name = "(%s)DuelEditor - %s"%(process, self.filename)
else:
title_name = "DuelEditor - %s"%self.filename
if self.unsave_changed:
Expand Down Expand Up @@ -1348,16 +1360,28 @@ def refresh_field(self):
# 获取卡片名字
card_name = self.operators["cards"][card_id]["Name"]
show_list.addItem(card_name)
# 若为最后操作对象之一,绿色高亮
if card_id in operation["args"]:
show_list.item(show_list.count()-1).setForeground(QColor('green'))
else:
show_list.item(show_list.count()-1).setForeground(QColor('black'))
# 若符合搜索对象,红色高亮
if len(searching_name) > 0 and searching_name in card_name:
show_list.item(show_list.count()-1).setForeground(QColor('red'))
# 若为最后操作对象之一,使用粗体
bl_font = card_id in operation["args"]
self.bold_font.setCapitalization
# 若为搜索对象,使用斜体
it_font = len(searching_name) > 0 and searching_name in card_name
if it_font:
if frame in searched_frames:
label_colors[searched_frames.index(frame)] = "QLabel{color:rgb(255,0,102,255)}"
if bl_font:
show_list.item(show_list.count()-1).setFont(self.bold_italic_font)
else:
show_list.item(show_list.count()-1).setFont(self.italic_font)
elif bl_font:
show_list.item(show_list.count()-1).setFont(self.bold_font)

# 根据卡片种类进行上色
if self.coloring_field_card.isChecked():
possible_name = [card_name, card_name[:-1]]
for name in possible_name:
if name in self.card_colors:
show_list.item(show_list.count()-1).setForeground(cardcolors_dict[self.card_colors[name]])
break

# 数量标注
self.label_enemy_ex.setText("对方额外(%d)"%self.Enemy_Ex.count())
Expand Down Expand Up @@ -1561,20 +1585,16 @@ def search_card(self):
elif self.blur_search_bar.isChecked() and self.text_check_legal(self.raw_datas[cardname], included, excluded):
hit_in_effect.append(cardname)
# 添加到列表
main_font = QFont()
main_font.setBold(True)
relevant_font = QFont()
relevant_font.setItalic(True)
for name in hit:
self.Newcard_List.addItem(name)
self.Newcard_List.item(self.Newcard_List.count()-1).setFont(main_font)
self.Newcard_List.item(self.Newcard_List.count()-1).setFont(self.bold_font)
self.Newcard_List.item(self.Newcard_List.count()-1).setForeground(cardcolors_dict[self.card_colors[name]])
for name in hit_in_name:
self.Newcard_List.addItem(name)
self.Newcard_List.item(self.Newcard_List.count()-1).setForeground(cardcolors_dict[self.card_colors[name]])
for name in hit_in_effect:
self.Newcard_List.addItem(name)
self.Newcard_List.item(self.Newcard_List.count()-1).setFont(relevant_font)
self.Newcard_List.item(self.Newcard_List.count()-1).setFont(self.italic_font)
self.Newcard_List.item(self.Newcard_List.count()-1).setForeground(cardcolors_dict[self.card_colors[name]])
self.label_cardsearch.setText("卡片搜索(%d)"%self.Newcard_List.count())

Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"name": "v1.15.2", "version":152}
{"name": "v1.15.3", "version":153}

0 comments on commit 93e5330

Please sign in to comment.