Commit ac8c42df authored by Georgiy Yankovskiy's avatar Georgiy Yankovskiy

Integrated info to GUI, poetry dependencies

parents e968fb03 41c7628f
......@@ -132,3 +132,7 @@ venv
pip-selfcheck.json
# End of https://www.toptal.com/developers/gitignore/api/pycharm,venv
### Extra
.agent-data
\ No newline at end of file
......@@ -12,6 +12,7 @@ from desktop_parser import DesktopFile
from ingame.models.Gamepad import Gamepad
from ingame.models.GamesModel import Game, GamesModel
from ingame.models.GameAgent import GameAgent
from PySide6.QtCore import Property, Signal, Slot, QObject, Qt
......@@ -49,6 +50,8 @@ class App(QtCore.QObject):
self.gamepad.r_clicked = lambda: self.gamepad_axis_right.emit(True)
self.gamepad.back_clicked = lambda: self.gamepad_clicked_back.emit(True)
self.agent = GameAgent()
self.setup()
def setup(self):
......@@ -112,9 +115,17 @@ class App(QtCore.QObject):
# event.accept() # let the window close
# else:
# event.ignore()
self.agent.clean_data()
### SLOTS ###
@Slot(str, result=dict)
def get_game_data(self, game_name):
print(game_name)
# self.agent.search_game("Risk of rain 2") # оригинальной osu в стиме нет =) Плейсхолдер
return self.agent.search_game(game_name)
# self.agent.search_game("asdjfiawefhawijefh")
@Slot(str)
def start_game(self, exec):
self.game_started.emit(True)
......
import os
import pickle
from steam_web_api import Steam
# TODO:
# - Определиться, используется ли Lutris. Если да, вместо этого будет обращение к нему. Если нет,
# продумать "рыбу" более логично.
# - Починить отображение системных требований (точнее, разобраться, что именно возвращает API.
# - Додумать форматированные данные, что именно мы видим на странице игры?
class GameAgent:
generic_name = "Risk of rain 2"
datapath = ".agent-data"
all_data = dict()
scenario = 0
def __init__(self):
super().__init__()
agent_key = "SOME_KEY_HERE_I_GUESS"
self.steam_process = Steam(agent_key)
self.get_all_data()
def add_game_info(self, data, name):
if not data['apps']:
self.all_data[name] = 0
else:
game_id = data['apps'][0]['id']
data = self.steam_process.apps.get_app_details(game_id)
self.all_data[name] = data[str(game_id[0])]['data']
with open(self.datapath, "wb+") as datafile:
pickle.dump(self.all_data, datafile)
self.get_all_data()
def search_game(self, game_name):
self.get_all_data()
if game_name in self.all_data:
print("ITS HERE!")
else:
search_results = self.steam_process.apps.search_games(game_name)
self.add_game_info(search_results, game_name)
return self.format_game_data(self.all_data[game_name])
def get_all_data(self):
try:
with open(self.datapath, "rb") as datafile:
self.all_data = pickle.load(datafile)
except FileNotFoundError:
self.all_data = dict()
def format_game_data(self, game_data):
formatted_data = dict()
if game_data != 0:
formatted_data['title'] = game_data['name']
formatted_data['desc'] = game_data['short_description']
formatted_data['languages'] = game_data['supported_languages']
formatted_data['reqs'] = game_data['linux_requirements']
# for key, value in formatted_data.items():
# print("{0}: {1}".format(key, value))
else:
print("Игра не распознана!")
return formatted_data
def clean_data(self):
self.all_data = dict()
with open(self.datapath, "wb") as datafile:
pickle.dump(self.all_data, datafile)
print("data cleaned")
# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand.
[[package]]
name = "beautifulsoup4"
version = "4.12.3"
description = "Screen-scraping library"
optional = false
python-versions = ">=3.6.0"
files = [
{file = "beautifulsoup4-4.12.3-py3-none-any.whl", hash = "sha256:b80878c9f40111313e55da8ba20bdba06d8fa3969fc68304167741bbf9e082ed"},
{file = "beautifulsoup4-4.12.3.tar.gz", hash = "sha256:74e3d1928edc070d21748185c46e3fb33490f22f52a3addee9aee0f4f7781051"},
]
[package.dependencies]
soupsieve = ">1.2"
[package.extras]
cchardet = ["cchardet"]
chardet = ["chardet"]
charset-normalizer = ["charset-normalizer"]
html5lib = ["html5lib"]
lxml = ["lxml"]
[[package]]
name = "certifi"
version = "2024.2.2"
description = "Python package for providing Mozilla's CA Bundle."
......@@ -366,6 +387,27 @@ files = [
shiboken6 = "6.7.0"
[[package]]
name = "python-steam-api"
version = "2.0"
description = "Python Client wrapper for Steam API."
optional = false
python-versions = ">=3.9"
files = [
{file = "python-steam-api-2.0.tar.gz", hash = "sha256:4532b742215efc4a39206381ad6fc9b181042c245a63cefdc30e4d5bc26f67bb"},
{file = "python_steam_api-2.0-py3-none-any.whl", hash = "sha256:f201760a765e1b264fd07d111389ebe3efcfc22099a4b0bf4ce1925a21b71e48"},
]
[package.dependencies]
beautifulsoup4 = "*"
requests = "*"
[package.extras]
all = ["python-steam-api[build]", "python-steam-api[style]"]
build = ["build", "twine"]
full = ["python-steam-api[all]"]
style = ["codespell[toml] (>=2.2.4)", "isort", "ruff (>=0.1.8)", "toml-sort", "yamllint"]
[[package]]
name = "requests"
version = "2.31.0"
description = "Python HTTP for Humans."
......@@ -400,6 +442,17 @@ files = [
]
[[package]]
name = "soupsieve"
version = "2.5"
description = "A modern CSS selector implementation for Beautiful Soup."
optional = false
python-versions = ">=3.8"
files = [
{file = "soupsieve-2.5-py3-none-any.whl", hash = "sha256:eaa337ff55a1579b6549dc679565eac1e3d000563bcb1c8ab0d0fefbc0c2cdc7"},
{file = "soupsieve-2.5.tar.gz", hash = "sha256:5663d5a7b3bfaeee0bc4372e7fc48f9cff4940b3eec54a6451cc5299f1097690"},
]
[[package]]
name = "typing-extensions"
version = "4.11.0"
description = "Backported and Experimental Type Hints for Python 3.8+"
......@@ -430,4 +483,4 @@ zstd = ["zstandard (>=0.18.0)"]
[metadata]
lock-version = "2.0"
python-versions = ">=3.11,<3.13"
content-hash = "eb8f0983d734285d3ecb312cb9109e04a91a8ab6a0c28731fa0e061144da90a0"
content-hash = "b95841911a1ee38641ce2df79eb3e79b69dbb9e9d8ad9067929e7a4d813539ff"
......@@ -15,6 +15,7 @@ pyqtgraph = "^0.13.6"
requests = "^2.31.0"
desktop-parser = "^0.1.1"
pygame = "^2.5.2"
python-steam-api = "^2.0"
[tool.poetry.group.dev.dependencies]
mypy = "^1.9.0"
......
......@@ -30,7 +30,19 @@ Rectangle {
gameRect.anchors.left = startPos.left
gameRect.anchors.top = startPos.top
runGameButton.focus = true
root.state = "completed"
root.state = "completed";
let v = core_app.get_game_data(root.title);
let _t = v['title'];
let _d = v['desc'];
let _l = v['languages'];
let _r = v['reqs'];
// console.log(_t, _d, _l, _r);
let pretty_title = ((_t === undefined) ? "Нет информации об игре" : _t);
let pretty_description = ((_d === undefined) ? "Нет информации об игре" : _d);
description.text = "Наименование игры:\n" + pretty_title + "\n\nОписание игры:\n" + pretty_description;
}
states: [
......@@ -72,6 +84,8 @@ Rectangle {
// if(visible){
if(window.scene !== S.gameInfoScene) return;
root.setItemsFocus(0);
// console.log("Game data: ", v, _t, _d, _l, _r);
// }
}
......@@ -323,24 +337,13 @@ Rectangle {
Text {
horizontalAlignment: Text.AlignJustif
Layout.alignment: Qt.AlignRight | Qt.AlignTop
id: title2
id: description
Layout.maximumWidth: root.width / 100 * 30
Layout.maximumHeight: root.height / 100 * 70
elide: Text.ElideRight
wrapMode: Text.Wrap
text:
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. " +
"Sed a ligula dolor. Cras eu sapien felis. Praesent placerat " +
"interdum mi at commodo. Nulla leo lacus, semper sed neque a, " +
"viverra convallis enim. Maecenas eget ligula eu augue posuere " +
"tincidunt sit amet et orci. In hac habitasse platea dictumst. " +
"Donec rutrum pharetra scelerisque. Sed quam mi, accumsan eget " +
"bibendum non, varius a nisi. Vivamus commodo turpis vitae " +
"vulputate tempus. Pellentesque efficitur risus nibh, sit amet " +
"interdum ante pulvinar sit amet. Ut hendrerit diam eu felis " +
"ornare, a sollicitudin lacus auctor. In hac habitasse platea dictumst. " +
"Vivamus sodales, purus at fermentum mattis, nulla libero porttitor " +
"orci, vitae scelerisque quam elit sit amet eros."
"..."
font.pixelSize: Math.max(13, root.height / 100 * 2.2)
color: "white"
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment