Commit bb84ba2f authored by Vladislav's avatar Vladislav

Added Time= in desktop file

parent 1d1ccdfb
......@@ -742,11 +742,29 @@ unpack () {
debug_timer () {
if [[ "$1" == "--start" ]] ; then
START=$(date +%s%N)
if [[ "$2" == "-s" ]] ; then
case $3 in
PW_TIME_IN_GAME)
START_PW_TIME_IN_GAME=$START ;;
UPDATE_ETERFUND)
START_UPDATE_ETERFUND=$START ;;
UPDATE_GITHUB)
START_UPDATE_GITHUB=$START ;;
esac
fi
elif [[ "$1" == "--end" ]] ; then
END=$(date +%s%N)
if [[ -n "$2" ]] ; then
if [[ "$2" == "-s" ]] ; then
export "$3"=$((( END - START )/1000000 ))
case $3 in
PW_TIME_IN_GAME)
START=$START_PW_TIME_IN_GAME ;;
UPDATE_ETERFUND)
START=$START_UPDATE_ETERFUND ;;
UPDATE_GITHUB)
START=$START_UPDATE_GITHUB ;;
esac
export "$3"="$((( END - START )/1000000 ))"
else
DIFF=$((( END - START )/1000000 ))
print_warning "It took $DIFF milliseconds for $2"
......@@ -1301,6 +1319,23 @@ stop_portwine () {
pw_exit_tray
pw_auto_create_shortcut
add_in_stop_portwine
debug_timer --end -s "PW_TIME_IN_GAME"
while IFS= read -r line ; do
if [[ $line =~ ^Time= ]] ; then
export SKIP_GAME_TIME="1"
TIME_CURRENT=${line//Time=/}
TIME_TOTAL=$(( TIME_CURRENT + PW_TIME_IN_GAME ))
fi
done < "$LAST_DESKTOP_FILE"
IFS="$orig_IFS"
if [[ $SKIP_GAME_TIME != 1 ]] ; then
echo "Time=$PW_TIME_IN_GAME" >> "$LAST_DESKTOP_FILE"
else
sed -i '/^Time=/d' "$LAST_DESKTOP_FILE"
echo "Time=$TIME_TOTAL" >> "$LAST_DESKTOP_FILE"
fi
case "$1" in
--restart)
restart_pp ;;
......@@ -1758,7 +1793,7 @@ pw_port_update () {
URL_GITHUB="https://raw.githubusercontent.com/Castro-Fidel/PortWINE/${BRANCH}/data_from_portwine/scripts/var"
pw_check_update () {
debug_timer --start
debug_timer --start -s "UPDATE_ETERFUND"
if ! timeout 2 curl -f -s --list-only "$URL_ETERFUND" > "${PORT_WINE_TMP_PATH}/curent_var_ver"
then
print_warning "https://gitlab.eterfund.ru/ broken. Skip it..."
......@@ -1766,7 +1801,7 @@ pw_port_update () {
fi
debug_timer --end -s "UPDATE_ETERFUND"
debug_timer --start
debug_timer --start -s "UPDATE_GITHUB"
if ! timeout 2 curl -f -s --list-only "$URL_GITHUB" > "${PORT_WINE_TMP_PATH}/curent_var_ver"
then
print_warning "https://raw.githubusercontent.com/ broken. Skip it..."
......@@ -3532,6 +3567,7 @@ portwine_launch () {
PW_VD_TMP=(explorer "/desktop=PortProton,${PW_SCREEN_RESOLUTION}")
fi
debug_timer --start -s "PW_TIME_IN_GAME"
case "$portwine_exe" in
*.[Ee][Xx][Ee])
pw_run ${PW_VD_TMP[@]} ${WINE_WIN_START} "$portwine_exe"
......@@ -5859,6 +5895,7 @@ button_click () {
(( count++ ))
done
fi
export LAST_DESKTOP_FILE="$PW_YAD_SET"
if check_flatpak
then PW_EXEC_FROM_DESKTOP="$(grep Exec "$PW_YAD_SET" | head -n 1 | sed 's|flatpak run ru.linux_gaming.PortProton|\"${PORT_SCRIPTS_PATH}/start.sh\"|' | awk -F'=' '{print $2}')"
else PW_EXEC_FROM_DESKTOP="$(grep Exec "$PW_YAD_SET" | head -n 1 | awk -F"=env " '{print $2}')"
......
......@@ -607,17 +607,20 @@ else
gui_userconf
fi
debug_timer --start
AMOUNT_GENERATE_BUTTONS="0"
for desktop_file in "${PORT_WINE_PATH}"/* ; do
if [[ $desktop_file =~ .desktop ]] ; then
if [[ ! $desktop_file =~ (/PortProton|/readme) ]] ; then
while IFS= read -r line ; do
[[ $line =~ ^Exec= ]] && PW_NAME_D_ICON["$AMOUNT_GENERATE_BUTTONS"]="${line//Exec=/}"
[[ $line =~ ^Icon= ]] && PW_ICON_PATH["$AMOUNT_GENERATE_BUTTONS"]="${line//Icon=/}"
[[ $line =~ ^Time= ]] && PW_GAME_TIME["${line//Time=/}"]="${desktop_file//"${PORT_WINE_PATH}"\//}"
done < "$desktop_file"
desktop_file="${desktop_file//"${PORT_WINE_PATH}"\//}"
PW_ALL_DF["$AMOUNT_GENERATE_BUTTONS"]="${desktop_file}"
DESKTOP_FILE_ARRAY+=($AMOUNT_GENERATE_BUTTONS)
if [[ -z ${PW_GAME_TIME["${line//Time=/}"]} ]] ; then
PW_ALL_DF["$AMOUNT_GENERATE_BUTTONS"]="${desktop_file//"${PORT_WINE_PATH}"\//}"
fi
(( AMOUNT_GENERATE_BUTTONS++ ))
fi
fi
......@@ -625,15 +628,14 @@ else
IFS=$'\n'
PW_GENERATE_BUTTONS="--field= ${translations[Create shortcut...]}!${PW_GUI_ICON_PATH}/find_48.svg!:FBTNR%@bash -c \"button_click --normal pw_find_exe\"%"
for df in "${DESKTOP_FILE_ARRAY[@]}" ; do
PW_DESKTOP_FILES="${PW_ALL_DF[$df]}"
if [[ -n ${PW_NAME_D_ICON[$df]} ]] ; then
PW_NAME_D_ICON_48="${PW_ICON_PATH[$df]%.png}_48"
PW_NAME_D_ICON_128="${PW_ICON_PATH[$df]%.png}"
for PW_DESKTOP_FILES in "${PW_GAME_TIME[@]}" "${PW_ALL_DF[@]}" ; do
if [[ -n ${PW_NAME_D_ICON} ]] ; then
PW_NAME_D_ICON_48="${PW_ICON_PATH%.png}_48"
PW_NAME_D_ICON_128="${PW_ICON_PATH%.png}"
if check_flatpak ; then
PW_NAME_D_ICON_NEW=${PW_NAME_D_ICON[$df]//flatpak run ru.linux_gaming.PortProton /}
PW_NAME_D_ICON_NEW=${PW_NAME_D_ICON//flatpak run ru.linux_gaming.PortProton /}
else
PW_NAME_D_ICON_NEW=${PW_NAME_D_ICON[$df]//"${PORT_SCRIPTS_PATH}/start.sh" /}
PW_NAME_D_ICON_NEW=${PW_NAME_D_ICON//"${PORT_SCRIPTS_PATH}/start.sh" /}
fi
PW_NAME_D_ICON_NEW="${PW_NAME_D_ICON_NEW//\"/}"
resize_png "${PW_NAME_D_ICON_NEW}" "${PW_NAME_D_ICON_48//"${PORT_WINE_PATH}/data/img/"/}" "48"
......@@ -657,6 +659,7 @@ else
fi
PW_GENERATE_BUTTONS+="--field= $(print_wrapped "${PW_DESKTOP_FILES_SHOW//".desktop"/""}" "25" "...")!${PW_NAME_D_ICON_48}.png!:FBTNR%@bash -c \"button_click --desktop "${PW_DESKTOP_FILES// /#@_@#}"\"%"
done
MAIN_GUI_ROWS="$(( ( AMOUNT_GENERATE_BUTTONS + 1 ) / MAIN_GUI_COLUMNS + 1 ))"
if [[ -z "${PW_ALL_DF[0]}" ]]
......@@ -755,6 +758,7 @@ else
export AI_SKIP="1"
fi
debug_timer --end
IFS="%"
"${pw_yad}" --plug=$KEY_MENU --tabnum="${PW_GUI_SORT_TABS[1]}" --form --columns="$MAIN_GUI_ROWS_EMULS" --align-buttons --scroll --homogeneous-column \
......
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