Skip to content

Commit

Permalink
- VDF loader/writer improved
Browse files Browse the repository at this point in the history
- Flatpak file configuration to package into flatpak
  • Loading branch information
hexdump2002 committed Dec 22, 2022
1 parent ccb2e05 commit 69bd94b
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"connectivity_plus","path":"/home/hexdump/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.9/","native_build":true,"dependencies":[]},{"name":"file_picker","path":"/home/hexdump/.pub-cache/hosted/pub.dartlang.org/file_picker-5.2.3/","native_build":true,"dependencies":[]},{"name":"path_provider_ios","path":"/home/hexdump/.pub-cache/hosted/pub.dartlang.org/path_provider_ios-2.0.11/","native_build":true,"dependencies":[]},{"name":"shared_preferences_ios","path":"/home/hexdump/.pub-cache/hosted/pub.dartlang.org/shared_preferences_ios-2.1.1/","native_build":true,"dependencies":[]}],"android":[{"name":"connectivity_plus","path":"/home/hexdump/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.9/","native_build":true,"dependencies":[]},{"name":"file_picker","path":"/home/hexdump/.pub-cache/hosted/pub.dartlang.org/file_picker-5.2.3/","native_build":true,"dependencies":["flutter_plugin_android_lifecycle"]},{"name":"flutter_plugin_android_lifecycle","path":"/home/hexdump/.pub-cache/hosted/pub.dartlang.org/flutter_plugin_android_lifecycle-2.0.7/","native_build":true,"dependencies":[]},{"name":"path_provider_android","path":"/home/hexdump/.pub-cache/hosted/pub.dartlang.org/path_provider_android-2.0.22/","native_build":true,"dependencies":[]},{"name":"shared_preferences_android","path":"/home/hexdump/.pub-cache/hosted/pub.dartlang.org/shared_preferences_android-2.0.14/","native_build":true,"dependencies":[]}],"macos":[{"name":"connectivity_plus_macos","path":"/home/hexdump/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_macos-1.2.6/","native_build":true,"dependencies":[]},{"name":"path_provider_macos","path":"/home/hexdump/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-2.0.6/","native_build":true,"dependencies":[]},{"name":"shared_preferences_macos","path":"/home/hexdump/.pub-cache/hosted/pub.dartlang.org/shared_preferences_macos-2.0.4/","native_build":true,"dependencies":[]}],"linux":[{"name":"connectivity_plus_linux","path":"/home/hexdump/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_linux-1.3.1/","native_build":false,"dependencies":[]},{"name":"path_provider_linux","path":"/home/hexdump/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-2.1.7/","native_build":false,"dependencies":[]},{"name":"shared_preferences_linux","path":"/home/hexdump/.pub-cache/hosted/pub.dartlang.org/shared_preferences_linux-2.1.2/","native_build":false,"dependencies":["path_provider_linux"]}],"windows":[{"name":"connectivity_plus_windows","path":"/home/hexdump/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_windows-1.2.2/","native_build":true,"dependencies":[]},{"name":"path_provider_windows","path":"/home/hexdump/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-2.1.3/","native_build":false,"dependencies":[]},{"name":"shared_preferences_windows","path":"/home/hexdump/.pub-cache/hosted/pub.dartlang.org/shared_preferences_windows-2.1.2/","native_build":false,"dependencies":["path_provider_windows"]}],"web":[{"name":"connectivity_plus_web","path":"/home/hexdump/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_web-1.2.5/","dependencies":[]},{"name":"file_picker","path":"/home/hexdump/.pub-cache/hosted/pub.dartlang.org/file_picker-5.2.3/","dependencies":[]},{"name":"shared_preferences_web","path":"/home/hexdump/.pub-cache/hosted/pub.dartlang.org/shared_preferences_web-2.0.4/","dependencies":[]}]},"dependencyGraph":[{"name":"connectivity_plus","dependencies":["connectivity_plus_linux","connectivity_plus_macos","connectivity_plus_web","connectivity_plus_windows"]},{"name":"connectivity_plus_linux","dependencies":[]},{"name":"connectivity_plus_macos","dependencies":[]},{"name":"connectivity_plus_web","dependencies":[]},{"name":"connectivity_plus_windows","dependencies":[]},{"name":"file_picker","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_ios","path_provider_linux","path_provider_macos","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_ios","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_android","shared_preferences_ios","shared_preferences_linux","shared_preferences_macos","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_android","dependencies":[]},{"name":"shared_preferences_ios","dependencies":[]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]}],"date_created":"2022-12-20 18:17:39.876831","version":"3.3.9"}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"connectivity_plus","path":"/home/hexdump/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.9/","native_build":true,"dependencies":[]},{"name":"file_picker","path":"/home/hexdump/.pub-cache/hosted/pub.dartlang.org/file_picker-5.2.3/","native_build":true,"dependencies":[]},{"name":"path_provider_ios","path":"/home/hexdump/.pub-cache/hosted/pub.dartlang.org/path_provider_ios-2.0.11/","native_build":true,"dependencies":[]},{"name":"shared_preferences_ios","path":"/home/hexdump/.pub-cache/hosted/pub.dartlang.org/shared_preferences_ios-2.1.1/","native_build":true,"dependencies":[]}],"android":[{"name":"connectivity_plus","path":"/home/hexdump/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.9/","native_build":true,"dependencies":[]},{"name":"file_picker","path":"/home/hexdump/.pub-cache/hosted/pub.dartlang.org/file_picker-5.2.3/","native_build":true,"dependencies":["flutter_plugin_android_lifecycle"]},{"name":"flutter_plugin_android_lifecycle","path":"/home/hexdump/.pub-cache/hosted/pub.dartlang.org/flutter_plugin_android_lifecycle-2.0.7/","native_build":true,"dependencies":[]},{"name":"path_provider_android","path":"/home/hexdump/.pub-cache/hosted/pub.dartlang.org/path_provider_android-2.0.22/","native_build":true,"dependencies":[]},{"name":"shared_preferences_android","path":"/home/hexdump/.pub-cache/hosted/pub.dartlang.org/shared_preferences_android-2.0.14/","native_build":true,"dependencies":[]}],"macos":[{"name":"connectivity_plus_macos","path":"/home/hexdump/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_macos-1.2.6/","native_build":true,"dependencies":[]},{"name":"path_provider_macos","path":"/home/hexdump/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-2.0.6/","native_build":true,"dependencies":[]},{"name":"shared_preferences_macos","path":"/home/hexdump/.pub-cache/hosted/pub.dartlang.org/shared_preferences_macos-2.0.4/","native_build":true,"dependencies":[]}],"linux":[{"name":"connectivity_plus_linux","path":"/home/hexdump/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_linux-1.3.1/","native_build":false,"dependencies":[]},{"name":"path_provider_linux","path":"/home/hexdump/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-2.1.7/","native_build":false,"dependencies":[]},{"name":"shared_preferences_linux","path":"/home/hexdump/.pub-cache/hosted/pub.dartlang.org/shared_preferences_linux-2.1.2/","native_build":false,"dependencies":["path_provider_linux"]}],"windows":[{"name":"connectivity_plus_windows","path":"/home/hexdump/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_windows-1.2.2/","native_build":true,"dependencies":[]},{"name":"path_provider_windows","path":"/home/hexdump/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-2.1.3/","native_build":false,"dependencies":[]},{"name":"shared_preferences_windows","path":"/home/hexdump/.pub-cache/hosted/pub.dartlang.org/shared_preferences_windows-2.1.2/","native_build":false,"dependencies":["path_provider_windows"]}],"web":[{"name":"connectivity_plus_web","path":"/home/hexdump/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_web-1.2.5/","dependencies":[]},{"name":"file_picker","path":"/home/hexdump/.pub-cache/hosted/pub.dartlang.org/file_picker-5.2.3/","dependencies":[]},{"name":"shared_preferences_web","path":"/home/hexdump/.pub-cache/hosted/pub.dartlang.org/shared_preferences_web-2.0.4/","dependencies":[]}]},"dependencyGraph":[{"name":"connectivity_plus","dependencies":["connectivity_plus_linux","connectivity_plus_macos","connectivity_plus_web","connectivity_plus_windows"]},{"name":"connectivity_plus_linux","dependencies":[]},{"name":"connectivity_plus_macos","dependencies":[]},{"name":"connectivity_plus_web","dependencies":[]},{"name":"connectivity_plus_windows","dependencies":[]},{"name":"file_picker","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_ios","path_provider_linux","path_provider_macos","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_ios","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_android","shared_preferences_ios","shared_preferences_linux","shared_preferences_macos","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_android","dependencies":[]},{"name":"shared_preferences_ios","dependencies":[]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]}],"date_created":"2022-12-22 23:43:52.326045","version":"3.3.9"}
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@ doc/api/
*.js.map


settings.cfg
settings.cfg
/FlutterApp-Linux-Portable.tar.gz
/build-dir/
/.flatpak-builder/
/GameMiner-Linux-Portable.tar.gz
4 changes: 3 additions & 1 deletion com.hexdump.GameMiner.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"--socket=wayland",
"--device=dri",
"--socket=pulseaudio",
"--share=network"
"--share=network",
"--filesystem=host",
"--filesystem=home"
],
"modules": [
{
Expand Down
4 changes: 2 additions & 2 deletions lib/data/Stats.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:io';

import 'package:steamdeck_toolbox/data/game_folder_stats.dart';
import 'package:steamdeck_toolbox/logic/Tools/VMGameTools.dart';
import 'package:steamdeck_toolbox/logic/blocs/non_steam_games_cubit.dart';
import 'package:universal_disk_space/universal_disk_space.dart';
Expand Down Expand Up @@ -36,7 +35,8 @@ class Stats {
final diskSpace = DiskSpace();
await diskSpace.scan();
var disks = diskSpace.disks;
var homeDisk = diskSpace.getDisk(Directory('/home'));
//Originally it was just /home but it didn't worked when I created a flatpak bundle
var homeDisk = diskSpace.getDisk(Directory('/home/hexdump/.var/app'));
var sdDisk = diskSpace.getDisk(Directory('/run/media/mmcblk0p1'));

return {
Expand Down
30 changes: 17 additions & 13 deletions lib/data/non_steam_game_exe.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class NonSteamGameExe {
bool openVr = false;
bool devkit = false;
String devkitGameId = "";
String devkitOverrideAppId = "";
int devkitOverrideAppId = 0;
int lastPlayTime = 0;
String flatPackAppId = "";
String exePath = "";
Expand All @@ -45,22 +45,22 @@ class NonSteamGameExe {
switch(propertyName)
{
case "entry_id": {entryId = propertyValue;}break;
case "appid" : {appId = _convertBEIntStringToInt(propertyValue);}break;
case "appid" : {appId = propertyValue;}break;
case "AppName" : {appName = propertyValue;}break;
case "StartDir" : {startDir = _cleanPathString(propertyValue);}break;
case "icon" : {icon = _removeQuotes(propertyValue);}break;
case "StartDir" : {startDir = /*_cleanPathString(*/propertyValue/*)*/;}break;
case "icon" : {icon = /*_removeQuotes(*/propertyValue/*)*/;}break;
case "ShortcutPath" : {shortcutPath = propertyValue;}break;
case "LaunchOptions" : {launchOptions = _removeQuotes(propertyValue);}break;
case "IsHidden" : {isHidden = _convertStrToBool(propertyValue);}break;
case "AllowDesktopConfig" : {allowDdesktopCconfig = _convertStrToBool(propertyValue);}break;
case "AllowOverlay" : {allowOverlay = _convertStrToBool(propertyValue);}break;
case "OpenVR" : {openVr = _convertStrToBool(propertyValue);}break;
case "Devkit" : {devkit = _convertStrToBool(propertyValue);}break;
case "LaunchOptions" : {launchOptions = /*_removeQuotes(*/propertyValue/*)*/;}break;
case "IsHidden" : {isHidden = _convertIntToBool(propertyValue);}break;
case "AllowDesktopConfig" : {allowDdesktopCconfig = _convertIntToBool(propertyValue);}break;
case "AllowOverlay" : {allowOverlay = _convertIntToBool(propertyValue);}break;
case "OpenVR" : {openVr = _convertIntToBool(propertyValue);}break;
case "Devkit" : {devkit = _convertIntToBool(propertyValue);}break;
case "DevkitGameID" : {devkitGameId = propertyValue;}break;
case "DevkitOverrideAppID" : {devkitOverrideAppId = propertyValue;}break;
case "LastPlayTime" : {lastPlayTime = _convertBEIntStringToInt(propertyValue);}break;
case "LastPlayTime" : {lastPlayTime = propertyValue;}break;
case "FlatpakAppID" : {flatPackAppId = propertyValue;}break;
case "Exe" : { propertyValue = _cleanPathString(propertyValue); exePath = propertyValue;}break;
case "Exe" : { propertyValue = /*_cleanPathString(propertyValue);*/ exePath = propertyValue;}break;
case "tags": {tags = propertyValue; } break;
default: throw Exception("$propertyName with value $propertyValue is not a known steam game property");
}
Expand Down Expand Up @@ -150,7 +150,7 @@ class NonSteamGameExe {
{
var value = dataView.getUint32(movingFrom,Endian.little);
movingFrom += 4;
propertyValue = value.toString();
propertyValue = value;
} break;
default:
assert(false, "Unknown vdf value type");
Expand Down Expand Up @@ -231,4 +231,8 @@ class NonSteamGameExe {

return Tuple2(tags, movingFrom);
}

bool _convertIntToBool(propertyValue) {
return propertyValue == 0 ? false:true;
}
}
41 changes: 23 additions & 18 deletions lib/data/user_game.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'dart:convert';
import 'dart:ffi';
import 'dart:io';
import 'dart:math';
Expand Down Expand Up @@ -30,7 +31,7 @@ class UserGameExe {
bool openVr = false;
bool devkit = false;
String devkitGameId = "";
String devkitOverrideAppId = "";
int devkitOverrideAppId = 0;
int lastPlayTime = 0;
String flatPackAppId = "";

Expand Down Expand Up @@ -165,21 +166,21 @@ class UserGame {
await _writeBlockId(raf, blockId++);

await _writeInt32BEProperty(raf, "appid", ef.appId);
await _writeStringProperty(raf, "AppName", ef.name);
await _writeStringProperty(raf, "AppName", ef.name, addQuotes:false);
isExternal
? await _writeStringProperty(raf, "Exe", "\"${ef.relativeExePath}\"")
: await _writeStringProperty(raf, "Exe", "\"$path/${ef.relativeExePath}\"");
await _writeStringProperty(raf, "StartDir", "\"${ef.startDir}\"");
await _writeStringProperty(raf, "icon", "\"${ef.icon}\"");
? await _writeStringProperty(raf, "Exe", "${ef.relativeExePath}")
: await _writeStringProperty(raf, "Exe", "$path/${ef.relativeExePath}");
await _writeStringProperty(raf, "StartDir", "${ef.startDir}");
await _writeStringProperty(raf, "icon", "${ef.icon}");
await _writeStringProperty(raf, "ShortcutPath", "${ef.shortcutPath}");
await _writeStringProperty(raf, "LaunchOptions", "\"${ef.launchOptions}\"");
await _writeStringProperty(raf, "LaunchOptions", "${ef.launchOptions}");
await _writeBoolProperty(raf, "IsHidden", ef.isHidden);
await _writeBoolProperty(raf, "AllowDesktopConfig", ef.allowDdesktopConfig);
await _writeBoolProperty(raf, "AllowOverlay", ef.allowOverlay);
await _writeBoolProperty(raf, "OpenVR", ef.openVr);
await _writeBoolProperty(raf, "Devkit", ef.devkit);
await _writeStringProperty(raf, "DevkitGameID", ef.devkitGameId);
await _writeStringProperty(raf, "DevkitOverrideAppID", ef.devkitOverrideAppId);
await _writeInt32BEProperty(raf, "DevkitOverrideAppID", ef.devkitOverrideAppId);
await _writeInt32BEProperty(raf, "LastPlayTime", ef.lastPlayTime);
await _writeStringProperty(raf, "FlatpakAppID", ef.flatPackAppId);
await _writeListProperty(raf, "tags", ef.tags);
Expand All @@ -189,9 +190,9 @@ class UserGame {


//Tags are not supported (Tags type is 0)
await raf.writeByte(0);
/*await raf.writeByte(0);7
await raf.writeString("tags");
await raf.writeByte(0);
await raf.writeByte(0);*/
await raf.writeByte(8);
await raf.writeByte(8);
}
Expand All @@ -201,7 +202,7 @@ class UserGame {

Future<void> _writeBlockId(RandomAccessFile raf, int num) async {
await raf.writeByte(0);
await raf.writeString(num.toString());
await raf.writeString(num.toString(), encoding:Latin1Codec());
await raf.writeByte(0);
/*if (num > 999) {
throw Exception("Can't write more than 999 non steam games");
Expand All @@ -224,18 +225,22 @@ class UserGame {
await raf.writeByte(0);*/
}

Future<void> _writeStringProperty(RandomAccessFile raf, String propName, String propValue) async {
Future<void> _writeStringProperty(RandomAccessFile raf, String propName, String propValue, {bool addQuotes = false}) async {
await raf.writeByte(0x01);
await raf.writeString(propName);
await raf.writeString(propName, encoding:Latin1Codec());
await raf.writeByte(0);
await raf.writeString(propValue);

if(propValue.isNotEmpty && addQuotes) {
propValue = "\"$propValue\"";
}
await raf.writeString(propValue, encoding:Latin1Codec());
await raf.writeByte(0);
}

Future<void> _writeInt32BEProperty(RandomAccessFile raf, String propName, int value) async {
await raf.writeByte(0x02);

await raf.writeString(propName);
await raf.writeString(propName, encoding:Latin1Codec());
await raf.writeByte(0);

await raf.writeByte((value & 0x000000FF));
Expand All @@ -251,13 +256,13 @@ class UserGame {

Future<void> _writeListProperty(RandomAccessFile raf, String propName, List<String> tags) async {
await raf.writeByte(0x00);
await raf.writeString(propName);
await raf.writeString(propName, encoding:Latin1Codec());
await raf.writeByte(0);
for(int i=0; i<tags.length; ++i) {
await raf.writeByte(0x01); //more items comming?
await raf.writeString(i.toString());
await raf.writeString(i.toString(), encoding:Latin1Codec());
await raf.writeByte(0);
await raf.writeString(tags[i]);
await raf.writeString(tags[i], encoding:Latin1Codec());
await raf.writeByte(0);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/logic/Tools/steam_tools.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'dart:io';
import 'dart:math';
import 'package:steamdeck_toolbox/logic/Tools/vdf_tools.dart';

import 'crc32.dart';
Expand Down Expand Up @@ -61,7 +60,8 @@ class SteamTools {

static Future<String> getUserId() async{
String homeFolder = FileTools.getHomeFolder();
String path = "$homeFolder/.steam/steam/userdata";
//String path = "$homeFolder/.local/Steam/steam/userdata";
String path = "$homeFolder/.local/share/Steam/userdata"; //Changed because of flatpak

//Todo, check for empty folder
var folders = await FileTools.getFolderFilesAsync(path,retrieveRelativePaths: true, recursive: false,regExFilter: "",onlyFolders: true);
Expand Down
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ late SettingsCubit _settingsCubit;

void main() async {
//Close steam client
SteamTools.closeSteamClient();
//SteamTools.closeSteamClient();

_settingsCubit = SettingsCubit();
await _settingsCubit.initialize();
Expand Down
2 changes: 2 additions & 0 deletions pack.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tar -C build/linux/x64/release/bundle -acvf GameMiner-Linux-Portable.tar.gz .
flatpak-builder --force-clean build-dir com.hexdump.GameMiner.json

0 comments on commit 69bd94b

Please sign in to comment.