Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update gui #74

Open
wants to merge 70 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
b7d8e95
add demo pyqt ui
Mar 4, 2018
07c73fc
update demo ui
Mar 4, 2018
4ff5810
update pyqt gui
Mar 11, 2018
eecab36
update ui
Mar 12, 2018
c6e0bef
Merge branch 'dev' of https://github.com/appcell/OverwatchDataAnalysi…
Mar 14, 2018
4e42311
start write ui in code
Mar 14, 2018
48f17c0
update demo ui
Mar 18, 2018
9377774
Merge branches 'dev' and 'gui' of https://github.com/appcell/Overwatc…
Mar 25, 2018
4035a55
update demo ui
Mar 27, 2018
0a98976
add ui group
chroming Mar 31, 2018
c8f0f16
add group bgs
Mar 31, 2018
e8cca69
update style
Apr 2, 2018
cd3a164
update style
Apr 9, 2018
80766a5
update video style
Apr 14, 2018
bb4ece7
more style;mixin class;functions
Apr 22, 2018
bfeef91
update style
chroming May 1, 2018
4de1e18
update gui
chroming May 14, 2018
9bafa2e
add tab
chroming May 21, 2018
0ce1427
Merge remote-tracking branch 'origin/dev' into gui
chroming Jun 16, 2018
40e45a5
add gui api
chroming Jun 16, 2018
4781848
update videoitem class
chroming Jun 18, 2018
641e5d3
update ui
chroming Jun 18, 2018
33ac4b3
add default text
chroming Jun 18, 2018
9cc5501
add readme
chroming Jun 18, 2018
463d983
add video selected color
chroming Jun 24, 2018
a688fe9
add some property
chroming Jun 24, 2018
670548f
update ui
chroming Jul 8, 2018
2057db6
add select file/folder
chroming Jul 10, 2018
77632bd
Merge branch 'dev' into gui
GenesisX Jul 11, 2018
1e8947f
Merge pull request #61 from GenesisX/gui
appcell Jul 12, 2018
2fba617
Merge pull request #1 from appcell/dev
Foreveryou3344 Jul 22, 2018
6b36e27
Merge pull request #3 from appcell/dev
Foreveryou3344 Jul 25, 2018
1ac134f
add player basic data
Foreveryou3344 Jul 25, 2018
bc9f09b
add some notes and modify variable name
Foreveryou3344 Jul 26, 2018
f899a5c
abstract _get_actions
Foreveryou3344 Jul 26, 2018
8ef1dad
Update TUTORIAL.md
appcell Aug 19, 2018
5f8bacc
同步到最新版ora
KomorebiL Aug 21, 2018
9382308
Merge pull request #70 from KomorebiL/dev
appcell Aug 29, 2018
075ae49
translate help info
Aug 29, 2018
44e8336
Merge pull request #66 from Foreveryou3344/dev
appcell Aug 29, 2018
a00705e
modify data structure
Sep 7, 2018
b1b9bc7
Merge pull request #5 from appcell/dev
Foreveryou3344 Sep 10, 2018
c060e03
add some player data
Foreveryou3344 Sep 10, 2018
9a295b8
add some player data and modify some bug
Foreveryou3344 Sep 10, 2018
1a0fdc2
more .
Foreveryou3344 Sep 11, 2018
8084be7
add player data function
Foreveryou3344 Sep 11, 2018
c2b32ba
add chara categories
Sep 11, 2018
acb454d
Merge pull request #72 from Foreveryou3344/dev
appcell Sep 11, 2018
a37001b
dps tank support
Foreveryou3344 Sep 11, 2018
49a6f24
Merge pull request #73 from Foreveryou3344/dev
appcell Sep 11, 2018
cac0c91
modify stats structure
appcell Sep 18, 2018
7ad64ce
finish player stats
appcell Sep 18, 2018
528d35c
modify stats struct
appcell Sep 20, 2018
6ebb4c2
update gui file name and gui/readme
chroming Feb 8, 2019
09f0055
fix video list select error
chroming Mar 11, 2019
19d3a77
fix line edit and checkbox text color
chroming Mar 17, 2019
34d28ba
add click analyze button function
chroming Apr 5, 2019
bef9bfb
add run_qt_gui.py
chroming Apr 14, 2019
75a0139
update file path
chroming Apr 14, 2019
0677580
rename gui.py
chroming Apr 14, 2019
9b2e0f6
update analyze button click method
chroming Apr 14, 2019
f99de8b
remove max button
chroming Jun 10, 2019
948db7c
update ui
chroming Jun 10, 2019
f35b344
add margins
chroming Jun 11, 2019
d7a8a9a
update ui
chroming Jun 11, 2019
95f99e3
update .gitignore
chroming Oct 7, 2019
4fe6317
Merge branch 'dev' into gui
chroming Oct 7, 2019
3b4abb4
update requests
chroming Oct 7, 2019
f0387c5
catch qt error
chroming Oct 7, 2019
34e63df
Add "Add video" to right click menu
chroming Oct 7, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
/credentials
/gui
/ui_design/source
/ui_design/images
/ui_design/ui_design
.idea/
*.DS_Store
*.pyc
*.orig
__pycache__/
env/
venv/
2 changes: 1 addition & 1 deletion TUTORIAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ In the prompt Powershell console, input `python main.py`, then you can run the c

# Windows 下 Python 运行环境搭建教程

## 安装Anaconda Python 2.x
## 安装Anaconda Python 3.x

点击 https://www.anaconda.com/download/ , 64位电脑按如下选择:

Expand Down
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ora.gui as Gui
import ora.gui_ as Gui
import multiprocessing as mp

def main():
Expand Down
162 changes: 92 additions & 70 deletions ora/command_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from . import overwatch as OW
from . import game
from . import pool
from json import load
from sys import argv
import json


def log(*args):
Expand All @@ -15,98 +15,112 @@ def log(*args):
class Program(object):
def __init__(self):
self.game_instance = None
self.argv = argv
self.argv = argv[:4]
self.msg = self._msg()
self.data = self._get_data_to_dict(argv)

def _get_data(self, key):
"""
Extract key from sys.argv, then delete the key
"""
key += '='
key_index = len(key)
for i, s in enumerate(self.argv):
if s[:key_index] == key:
string = s[key_index:]
del self.argv[i]
return string
return None

def _user_input(self):
"""
Retrieving info from user input in command line
"""
# Getting fps
if 'help' in self.argv:
print("""
def _get_data_to_dict(self, argv):
if 'help' in argv:
print(self.msg.get('help'))
exit(0)
if len(self.argv) < 4:
raise ValueError(self.msg.get('need_help'))

result = {}
argv = argv[4:]
if argv:
for i, s in enumerate(argv):
if '=' not in s:
raise ValueError('<{}> {}'.format(s, self.msg.get('lack')))
k, v = s.split('=')
result[k] = v
return result
return result

@staticmethod
def _msg():
result = {}
result['help'] = """
Example:
main_cli.exe <video_path> <output_path> <number> players=player.txt fps=2 start_time=0 end_time=0
main_cli.exe <video_path> <output_path> <number> version=0 players=player.txt fps=2 start_time=0 end_time=0

Mandatory arguments:
<video_path> Absolute path of video(example: F:/video.mp4)
<output_path> Absolute path of output file(example: F:/)
<number> A number representing game type. 0: OWL, 1: Non-OWL

Optional:
version=0 OWL stage number(0=preseason, 1, 2, 3, 4)
players=players.txt A text file saving info of all 12 players with JSON formatting
fps=2 FPS of analyzer (2 by default)
start_time=0 Starting time in seconds
end_time=0 Ending time in seconds (If both are 0, then the whole video is analyzed)
""")
exit(0)
fps = self._get_data('fps')
"""
result['need_help'] = """
Please input with proper amount of arguments.
If you need any help, please type: main_cli.py help
"""
result['lack'] = "optional lack of token '='"
result['json'] = """
JSON format:
{
"right": {
"players": [
"player7",
"player8",
"player9",
"player10",
"player11",
"player12"
],
"team": "Team B"
},
"left": {
"players": [
"player1",
"player2",
"player3",
"player4",
"player5",
"player6",
],
"team": "Team A"
}
}
"""
return result

def _user_input(self):
"""
Retrieving info from user input in command line
"""
info = {
'fps': 2 if fps is None else fps,
'_player': self._get_data('player'),
'start_time': self._get_data('start_time') or 0,
'end_time': self._get_data('end_time') or 0,
'fps': self.data.get('fps', 2),
'_players': self.data.get('players'),
'start_time': self.data.get('start_time', 0),
'end_time': self.data.get('end_time', 0),
'game_version': self.data.get('version', 0),
'video_path': self.argv[1],
'output_path': self.argv[2],
'game_type': self.argv[3]
}
if len(self.argv) <= 3 or len(self.argv) > 4:
raise ValueError("""
Please input with proper amount of arguments.
如需帮助请输入 main_cli.py help
""")
info['video_path'] = self.argv[1]
info['output_path'] = self.argv[2]
info['game_type'] = self.argv[3]
return info

def info(self):
info = self._user_input()
player_path = info.pop('_player')
player_path = info.pop('_players')
if player_path is None:
info['name_team_left'] = 'Team A'
info['name_team_right'] = 'Team B'
info['name_players_team_left'] = ['player' + str(i) for i in range(1, 7)]
info['name_players_team_right'] = ['player' + str(i) for i in range(7, 13)]
else:
with open(player_path, 'r') as f:
data = load(f)
"""
JSON format:
{
"right": {
"players": [
"player7",
"player8",
"player9",
"player10",
"player11",
"player12"
],
"team": "Team B"
},
"left": {
"players": [
"player1",
"player2",
"player3",
"player4",
"player5",
"player6",
],
"team": "Team A"
}
}
"""
try:
with open(player_path, 'r') as f:
data = json.load(f)
except json.decoder.JSONDecodeError:
print(self.msg.get('json'))
exit(0)
info['name_team_left'] = data['left']['team']
info['name_team_right'] = data['right']['team']
info['name_players_team_left'] = data['left']['players']
Expand Down Expand Up @@ -140,6 +154,15 @@ def info(self):

if not (info['game_type'] == 0 or info['game_type'] == 1):
raise ValueError('Invalid game type!')

try:
print(info['game_version'])
info['game_version'] = int(info['game_version'])
except ValueError:
log('Invalid OWL stage number!')

if info['game_type'] == 0 and info['game_version'] not in [0, 1, 2, 3, 4]:
raise ValueError('Invalid OWL stage number!')
return info

def run(self):
Expand All @@ -150,8 +173,7 @@ def run(self):
self.game_instance.analyze(info['start_time'], info['end_time'], is_test=False)
pool.PROCESS_POOL.close()
pool.PROCESS_POOL.join()
self.game_instance.output_to_json()
self.game_instance.output_to_excel()
self.game_instance.output()
log('ok')

program = Program()
Empty file added ora/gui/__init__.py
Empty file.
6 changes: 6 additions & 0 deletions ora/gui/default.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

COPY_RIGHT = '''
COPYRIGHT

'''

51 changes: 51 additions & 0 deletions ora/gui/functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
from os.path import join

from PyQt5.Qt import QIcon, QSize
from PyQt5.QtWidgets import QFileDialog

SRC_PATH = './ora/gui/images'


def dynamic_base_class(instance, cls, cls_name):
instance.__class__ = type(cls_name, (cls, instance.__class__), {})
return instance


def set_background_img(widget, file_name, path='/bgs/'):
widget.setStyleSheet("background-image: url(%s)" % (SRC_PATH + path + file_name))


def set_background_color(widget, color):
widget.setStyleSheet("background-color: %s" % color)


def set_plain_text(widget, text):
widget.setPlainText(text)


def pic_to_icon(file_name, path='icons'):
return QIcon(join(SRC_PATH, path, file_name))


def set_full_icon(widget, file_name, path='icons'):
qicon = pic_to_icon(file_name, path)
widget.setIcon(qicon)
widget.setIconSize(QSize(100, 100))


def remove_listwidget_item(listwidget):
listwidget.takeItem(listwidget.currentRow())

def open_file_dialog(parent):
filename, _ = QFileDialog.getOpenFileName(parent, u'select video')
return filename

def set_qclass_child_widgets_style(widget, qclass, style):
for c in get_qclass_child_widgets(widget, qclass):
c.setStyleSheet(style)


def get_qclass_child_widgets(widget, qclass):
for c in widget.children():
if isinstance(c, qclass):
yield c
Loading