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
a2989022
Commit
a2989022
authored
Jun 28, 2024
by
Yankovskiy Georgiy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Commits
918563db
,
a19804a8
refactor (part 2 of 2)
parent
e96ebca9
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
62 additions
and
47 deletions
+62
-47
.gitignore
.gitignore
+2
-6
App.py
ingame/models/App.py
+11
-11
GameAgent.py
ingame/models/GameAgent.py
+14
-9
GameDescription.py
ingame/models/GameDescription.py
+1
-0
Tabs.qml
qml/components/Tabs.qml
+17
-10
OpenSans-VariableFont.ttf
qml/fonts/OpenSans-VariableFont.ttf
+0
-0
qml.qml
qml/qml.qml
+4
-1
HomeScene.qml
qml/scenes/HomeScene.qml
+13
-10
No files found.
.gitignore
View file @
a2989022
...
...
@@ -131,8 +131,4 @@ pyvenv.cfg
venv
pip-selfcheck.json
# End of https://www.toptal.com/developers/gitignore/api/pycharm,venv
### Extra
.agent-data
\ No newline at end of file
# End of https://www.toptal.com/developers/gitignore/api/pycharm,venv
\ No newline at end of file
ingame/models/App.py
View file @
a2989022
...
...
@@ -17,18 +17,12 @@ from ingame.models.GameEntry import GameEntry
from
ingame.models.GameAgent
import
GameAgent
from
PySide6.QtCore
import
Property
,
Signal
,
Slot
,
QObject
,
Qt
class
GameShortcut
:
def
__init__
(
self
,
filename
,
product_name
,
icon
):
self
.
filename
=
filename
self
.
product_name
=
product_name
self
.
icon
=
icon
class
App
(
QtCore
.
QObject
):
app_name
=
"ingame"
app_author
=
"foss"
game_list_details_retrieving_progress
=
Signal
(
float
,
name
=
"gameListDetailsRetrievingProgress"
)
game_started
=
Signal
(
bool
,
name
=
"gameStarted"
)
game_ended
=
Signal
(
bool
,
name
=
"gameEnded"
)
data_found
=
Signal
(
dict
,
name
=
"gotGameData"
)
...
...
@@ -108,13 +102,19 @@ class App(QtCore.QObject):
print
(
'An error occurred'
,
e
)
pass
# TODO:
refactor!
# TODO:
fix: progress=1.0 not emitted if details already cached/downloaded
def
retrieve_games_details
(
self
):
def
retrieve_games_details_thread
(
t
):
t
.
game_list_details_retrieving_progress
.
emit
(
0.0
)
all_count
:
int
=
len
(
self
.
games_model
.
games_list
)
game_entry
:
GameEntry
i
:
int
=
0
for
game_entry
in
self
.
games_model
.
games_list
:
game_description
=
t
.
agent
.
retrieve_game_description
(
game_entry
.
name
)
game_entry
.
icon
=
game_description
[
'image_location_path'
]
or
game_entry
.
icon
t
.
game_list_details_retrieving_progress
.
emit
(
float
(
i
)
/
all_count
)
i
+=
1
t
.
game_list_details_retrieving_progress
.
emit
(
1.0
)
thread
=
threading
.
Thread
(
target
=
retrieve_games_details_thread
,
args
=
(
self
,))
thread
.
start
()
...
...
@@ -130,12 +130,12 @@ class App(QtCore.QObject):
@Slot
(
str
,
result
=
dict
)
def
get_game_data
(
self
,
game_name
):
def
search
_thread
(
t
,
name
):
def
get_game_data
_thread
(
t
,
name
):
search_result
=
t
.
agent
.
retrieve_game_description
(
name
)
t
.
data_found
.
emit
(
search_result
)
return
thread
=
threading
.
Thread
(
target
=
search
_thread
,
args
=
(
self
,
game_name
))
thread
=
threading
.
Thread
(
target
=
get_game_data
_thread
,
args
=
(
self
,
game_name
))
thread
.
start
()
@Slot
(
str
)
...
...
ingame/models/GameAgent.py
View file @
a2989022
...
...
@@ -4,6 +4,7 @@ import requests
from
steam_web_api
import
Steam
from
steamgrid
import
SteamGridDB
from
ingame.models.GameDescription
import
GameDescription
import
time
class
GameAgent
:
...
...
@@ -15,7 +16,7 @@ class GameAgent:
def
__init__
(
self
,
config_path
,
cache_path
):
super
()
.
__init__
()
# TODO: move API tokens to GUI settings tab / environmental variables
self
.
steam_grid_db_client
=
SteamGridDB
(
'66827eabea66de47d036777ed2be87b2'
)
self
.
steam_grid_db_client
=
SteamGridDB
(
"66827eabea66de47d036777ed2be87b2"
)
self
.
steam_client
=
Steam
(
"SOME_KEY_HERE_I_GUESS"
)
self
.
config_path
=
config_path
...
...
@@ -32,15 +33,19 @@ class GameAgent:
''' USAGE '''
def
retrieve_game_description
(
self
,
game_name
):
if
game_name
not
in
self
.
data
:
# TODO: checkup for failed requests
search_results
=
self
.
steam_client
.
apps
.
search_games
(
game_name
)
self
.
add_game_description
(
search_results
,
game_name
)
self
.
__
add_game_description
(
search_results
,
game_name
)
game_description
=
self
.
data
[
game_name
]
return
game_description
.
as_dict
()
def
steam_grid_db_retrieve_image
(
self
,
game_name
):
''' DATABASE '''
def
__steam_grid_db_retrieve_image
(
self
,
game_name
):
try
:
save_path
=
f
"{self.steam_grid_db_images_path}/{game_name}.png"
if
os
.
path
.
exists
(
save_path
):
...
...
@@ -49,6 +54,7 @@ class GameAgent:
# TODO: checkup for failed requests
result
=
self
.
steam_grid_db_client
.
search_game
(
game_name
)
grids
=
self
.
steam_grid_db_client
.
get_grids_by_gameid
(
list
([
result
[
0
]
.
id
]))
# TODO: too slow, replace loop o(n) with o(1) if possible
for
grid
in
grids
:
if
grid
.
height
==
900
and
grid
.
width
==
600
:
...
...
@@ -62,10 +68,10 @@ class GameAgent:
except
:
return
''
''' DATABASE '''
def
add_game_description
(
self
,
search_results
,
game_name
):
def
__add_game_description
(
self
,
search_results
,
game_name
):
game_description
=
GameDescription
()
game_description
.
locked
=
True
self
.
data
[
game_name
]
=
game_description
# Steam game info
if
search_results
[
'apps'
]:
...
...
@@ -90,9 +96,8 @@ class GameAgent:
game_description
.
languages
=
app_data
[
'supported_languages'
]
# Steam Grid DB image retrieving
game_description
.
image_location_path
=
self
.
steam_grid_db_retrieve_image
(
game_name
)
self
.
data
[
game_name
]
=
game_description
game_description
.
image_location_path
=
self
.
__steam_grid_db_retrieve_image
(
game_name
)
game_description
.
locked
=
False
self
.
save_db
()
def
save_db
(
self
):
...
...
ingame/models/GameDescription.py
View file @
a2989022
...
...
@@ -3,6 +3,7 @@ from dataclasses import dataclass
@dataclass
class
GameDescription
:
locked
:
bool
=
False
title
:
str
=
'Информация не найдена!'
desc
:
str
=
'Информация не найдена!'
languages
:
str
=
'Информация не найдена!'
...
...
qml/components/Tabs.qml
View file @
a2989022
...
...
@@ -293,6 +293,7 @@ Rectangle {
// Повторитель
Repeater
{
id
:
gamesGridRepeater
model
:
core_app
.
games
// Карточка игры
Game
{
...
...
@@ -346,6 +347,7 @@ Rectangle {
// LOGIC
property
int
focusedItems
:
0
;
property
int
focusedTabs
:
0
;
...
...
@@ -393,28 +395,33 @@ Rectangle {
// c[tabs.focusedItems].clicked();
}
function
onGamepadClickedLB
(
done
){
if
(
window
.
scene
!==
S
.
homeScene
)
return
;
/* SIGNALS */
function
onGamepadClickedLB
(
args
){
tabs
.
applyTabsFocus
(
-
1
)
}
function
onGamepadClickedRB
(
done
){
if
(
window
.
scene
!==
S
.
homeScene
)
return
;
function
onGamepadClickedRB
(
args
){
tabs
.
applyTabsFocus
(
1
)
}
function
onGamepadAxisLeft
(
done
){
if
(
window
.
scene
!==
S
.
homeScene
)
return
;
function
onGamepadAxisLeft
(
args
){
tabs
.
applyItemsFocus
(
-
1
)
}
function
onGamepadAxisRight
(
done
){
if
(
window
.
scene
!==
S
.
homeScene
)
return
;
function
onGamepadAxisRight
(
args
){
tabs
.
applyItemsFocus
(
1
)
}
function
onGamepadClickedApply
(
done
){
function
onGamepadClickedApply
(
args
){
if
(
window
.
scene
!==
S
.
homeScene
)
return
;
// console.log("onGamepadClickedApply");
let
c
=
gamesGrid
.
children
;
c
[
tabs
.
focusedItems
].
press
();
}
function
onGameListDetailsRetrievingProgress
(
args
)
{
let
progress
=
args
[
0
];
console
.
log
(
progress
);
if
(
progress
===
1.0
){
gamesGridRepeater
.
model
=
[];
gamesGridRepeater
.
model
=
core_app
.
games
;
}
}
}
...
...
qml/fonts/OpenSans-VariableFont.ttf
0 → 100644
View file @
a2989022
File added
qml/qml.qml
View file @
a2989022
...
...
@@ -14,7 +14,7 @@ Window {
}
FontLoader
{
id
:
globalFont
;
source
:
"./fonts/OpenSans-VariableFont
_wdth
.ttf"
source
:
"./fonts/OpenSans-VariableFont.ttf"
}
...
...
@@ -50,6 +50,9 @@ Window {
function
onGamepadClickedBack
(
done
){
window
.
_trigger
(
"onGamepadClickedBack"
,
done
);
}
function
onGameListDetailsRetrievingProgress
(
progress
){
homeScene
.
onGameListDetailsRetrievingProgress
([
progress
]);
}
}
function
_trigger
(
_method
,
...
args
){
...
...
qml/scenes/HomeScene.qml
View file @
a2989022
...
...
@@ -42,20 +42,23 @@ Rectangle {
anchors.rightMargin
:
0
}
function
onGamepadClickedLB
(
done
){
tabs
.
onGamepadClickedLB
(
done
)
function
onGamepadClickedLB
(
args
){
tabs
.
onGamepadClickedLB
(
args
)
}
function
onGamepadClickedRB
(
done
){
tabs
.
onGamepadClickedRB
(
done
)
function
onGamepadClickedRB
(
args
){
tabs
.
onGamepadClickedRB
(
args
)
}
function
onGamepadAxisLeft
(
done
){
tabs
.
onGamepadAxisLeft
(
done
)
function
onGamepadAxisLeft
(
args
){
tabs
.
onGamepadAxisLeft
(
args
)
}
function
onGamepadAxisRight
(
done
){
tabs
.
onGamepadAxisRight
(
done
)
function
onGamepadAxisRight
(
args
){
tabs
.
onGamepadAxisRight
(
args
)
}
function
onGamepadClickedApply
(
done
){
tabs
.
onGamepadClickedApply
(
done
)
function
onGamepadClickedApply
(
args
){
tabs
.
onGamepadClickedApply
(
args
)
}
function
onGameListDetailsRetrievingProgress
(
args
){
tabs
.
onGameListDetailsRetrievingProgress
(
args
)
}
}
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