Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
ingame
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vladislav
ingame
Commits
41c7628f
Commit
41c7628f
authored
May 13, 2024
by
ADav
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GameAgent 13.05
parent
9a49b9d1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
85 additions
and
1 deletion
+85
-1
agentdata
ingame/agentdata
+2
-0
App.py
ingame/models/App.py
+11
-1
GameAgent.py
ingame/models/GameAgent.py
+70
-0
Game.qml
qml/delegates/Game.qml
+2
-0
No files found.
ingame/agentdata
0 → 100644
View file @
41c7628f
File added
ingame/models/App.py
View file @
41c7628f
...
...
@@ -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
...
...
@@ -47,6 +48,8 @@ class App(QtCore.QObject):
self
.
gamepad
.
l_clicked
=
lambda
:
self
.
gamepad_axis_left
.
emit
(
True
)
self
.
gamepad
.
r_clicked
=
lambda
:
self
.
gamepad_axis_right
.
emit
(
True
)
self
.
agent
=
GameAgent
()
self
.
setup
()
def
setup
(
self
):
...
...
@@ -107,13 +110,20 @@ class App(QtCore.QObject):
# event.accept() # let the window close
# else:
# event.ignore()
self
.
agent
.
clean_data
()
### SLOTS ###
@Slot
(
str
)
def
get_game_data
(
self
,
game_name
):
print
(
game_name
)
# self.agent.search_game("Risk of rain 2") # оригинальной osu в стиме нет =) Плейсхолдер
self
.
agent
.
search_game
(
game_name
)
# self.agent.search_game("asdjfiawefhawijefh")
@Slot
(
str
)
def
start_game
(
self
,
exec
):
self
.
game_started
.
emit
(
True
)
def
run_in_thread
(
t
,
_exec
):
t
.
running_game_process
=
subprocess
.
Popen
(
_exec
,
...
...
ingame/models/GameAgent.py
0 → 100644
View file @
41c7628f
import
os
import
pickle
from
steam_web_api
import
Steam
# TODO:
# -Определиться, используется ли люстресс. Если да, вместо этого будет обращение к нему. Если нет,
# продумать "рыбу" более логично.
# -Починить отображение системных требований (точнее, разобраться, что именно возвращает API
# -Додумать форматированные данные, что именно мы видим на странице игры?
class
GameAgent
:
tempgame
=
"Risk of rain 2"
datapath
=
"./ingame/agentdata"
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
:
gameid
=
data
[
'apps'
][
0
][
'id'
]
data
=
self
.
steam_process
.
apps
.
get_app_details
(
gameid
)
self
.
all_data
[
name
]
=
data
[
str
(
gameid
[
0
])][
'data'
]
with
open
(
self
.
datapath
,
"wb+"
)
as
datafile
:
pickle
.
dump
(
self
.
all_data
,
datafile
)
self
.
get_all_data
()
def
search_game
(
self
,
Gamename
):
self
.
get_all_data
()
if
Gamename
in
self
.
all_data
:
print
(
"ITS HERE!"
)
else
:
search_results
=
self
.
steam_process
.
apps
.
search_games
(
Gamename
)
self
.
add_game_info
(
search_results
,
Gamename
)
self
.
format_game_data
(
self
.
all_data
[
Gamename
])
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
,
gamedata
):
if
gamedata
!=
0
:
formated_data
=
dict
()
formated_data
[
'title'
]
=
gamedata
[
'name'
]
formated_data
[
'desc'
]
=
gamedata
[
'short_description'
]
formated_data
[
'languages'
]
=
gamedata
[
'supported_languages'
]
formated_data
[
'reqs'
]
=
gamedata
[
'linux_requirements'
]
for
key
,
value
in
formated_data
.
items
():
print
(
"{0}: {1}"
.
format
(
key
,
value
))
else
:
print
(
"Игра не распозана!"
)
def
clean_data
(
self
):
self
.
all_data
=
dict
()
with
open
(
self
.
datapath
,
"wb"
)
as
datafile
:
pickle
.
dump
(
self
.
all_data
,
datafile
)
print
(
"data cleaned"
)
\ No newline at end of file
qml/delegates/Game.qml
View file @
41c7628f
...
...
@@ -23,6 +23,8 @@ C.Button {
gameInfoScene
.
icon
=
game
.
gameIcon
;
gameInfoScene
.
exec
=
game
.
gameExec
;
window
.
scene
=
SceneConstants
.
gameInfoScene
;
if
(
core_app
===
undefined
)
return
;
core_app
.
get_game_data
(
gameTitle
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment