Skip to content

Commit 00f66f2

Browse files
committed
final commit (for now)
- finished all screens - added compilation info
1 parent 971d39c commit 00f66f2

File tree

13 files changed

+514
-86
lines changed

13 files changed

+514
-86
lines changed

lib/components/global.dart

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@ class GlobalVariables {
1010
static List<Map<String, dynamic>> games = [
1111
{'name': 'Test', 'path': 'Testpath'},
1212
];
13-
static List gamesList = games.sublist(1);
14-
// variable List of games excluding the test game (games[0])
13+
static bool get gamesEmpty => games.length == 1;
14+
static List<Map<String, dynamic>> get gamesList => games.sublist(1);
15+
static int index = 0;
1516

16-
17-
static bool gamesEmpty = games[1].isEmpty;
1817
static Future<void> loadConfig() async {
1918
final appDirectory = await getApplicationCacheDirectory();
2019
final configFile = File('${appDirectory.path}/config.json');
@@ -76,23 +75,13 @@ void copyB2Exe() async {
7675
}
7776
}
7877

79-
Future<void> testAdd(String name, String path) async {
80-
print("Adding test game");
81-
print("Name: $name");
82-
print("Path: $path");
83-
final batName = path.split('/').last.split('.').first;
84-
// Create a .bat file with the following content:
85-
// @echo off
86-
// start "$path"
87-
// and save it as $name.bata in the cache directory
78+
Future<void> testAdd(String name, String gamepath) async {
79+
final batName = gamepath.split('/').last.split('.').first;
8880
final appDirectory = await getApplicationCacheDirectory();
89-
final batFile = File('${appDirectory.path}/$batName.bat');
90-
final batContent = '@echo off\nstart "" "$path"';
81+
final batFile = File('${appDirectory.path}/$name.$batName.bat');
82+
final batContent = '@echo off\nstart "" "$gamepath"';
9183
await batFile.writeAsString(batContent);
92-
// Run b2exe.exe with the following arguments: /bat $batFile.bat /exe $batFile.exe /invisible
93-
final process = await Process.run('${appDirectory.path}/b2exe.exe', ['/bat', '${appDirectory.path}/$batName.bat', '/exe', '${appDirectory.path}/$batName.exe', '/invisible']);
94-
print(process.stdout);
95-
print(process.stderr);
84+
await Process.run('${appDirectory.path}/b2exe.exe', ['/bat', '${appDirectory.path}/$name.$batName.bat', '/exe', '${appDirectory.path}/$name.$batName.exe', '/invisible']);
9685
}
9786

9887
void bitFiestaCleanup() async {
@@ -128,7 +117,6 @@ void bitFiestaCleanup() async {
128117
Directory('${destinationDir.path}/$filename').create(recursive: true);
129118
}
130119
}
131-
print('Unzip successful');
132120
} catch (e) {
133121
print('Failed to unzip: $e');
134122
}

lib/components/window.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ void WindowSetup() async {
99
size: Size(800, 600),
1010
center: true,
1111
backgroundColor: Colors.transparent,
12-
title: "Maxi's Steam Remote Play Launcher",
12+
title: "Maxi's Remote Play Launcher",
1313
);
1414

1515
windowManager.waitUntilReadyToShow(windowOptions, () async {

lib/main.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import 'screens/config.dart';
66
import 'screens/error.dart';
77
import 'screens/main.dart';
88
import 'screens/tutorial.dart';
9+
import 'screens/add.dart';
10+
import 'screens/edit.dart';
911
import 'package:path/path.dart' as path;
1012

1113
void main() async {
@@ -41,6 +43,8 @@ class App extends StatelessWidget {
4143
'/error': (context) => const Error(),
4244
'/main': (context) => const Main(),
4345
'/config': (context) => const Config(),
46+
'/add': (context) => const Add(),
47+
'/edit': (context) => const Edit(),
4448
},
4549
);
4650
}

lib/screens/add.dart

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:introduction_screen/introduction_screen.dart';
3+
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
4+
import 'package:file_picker/file_picker.dart';
5+
import '../components/global.dart';
6+
7+
class Add extends StatefulWidget {
8+
const Add({super.key});
9+
10+
@override
11+
AddScreen createState() => AddScreen();
12+
13+
}
14+
class AddScreen extends State<Add> {
15+
String name = '';
16+
String gamepath = '';
17+
int screenValue = 0;
18+
late TextEditingController nameController;
19+
20+
@override
21+
void initState() {
22+
super.initState();
23+
nameController = TextEditingController(text: name);
24+
}
25+
26+
List<PageViewModel> getPages() {
27+
return [
28+
PageViewModel(
29+
title: "Adding a game",
30+
body: "First off, type the game's name.",
31+
footer: Container (
32+
margin: const EdgeInsets.only(left: 200.0, right: 200.0, top: 25.0),
33+
child: Column(
34+
children: [
35+
TextField(
36+
controller: nameController,
37+
onChanged: (value) {
38+
setState(() {
39+
name = value;
40+
});
41+
},
42+
decoration: const InputDecoration(
43+
prefixIcon: Icon(FontAwesomeIcons.gamepad),
44+
filled: false,
45+
labelText: "Game name",
46+
hintText: "Write the game's name here.",
47+
),
48+
),
49+
],
50+
),
51+
),
52+
image: const Center(child: Icon(FontAwesomeIcons.edit, size: 50.0)),
53+
),
54+
PageViewModel(
55+
title: "Adding a game",
56+
body: "Please specify the game's executable's path.",
57+
footer: Container (
58+
margin: const EdgeInsets.only(left: 200.0, right: 200.0, top: 25.0),
59+
child: Column(
60+
children: [
61+
ElevatedButton(
62+
onPressed: () async {
63+
// Open file picker to select 8 Bit Fiesta's nw.exe
64+
FilePickerResult? result = await FilePicker.platform.pickFiles(
65+
type: FileType.custom,
66+
allowedExtensions: ['exe'],
67+
);
68+
if (result != null) {
69+
setState(() {
70+
gamepath = result.files.single.path!;
71+
// Replace all backslashes with forward slashes for compatibility
72+
gamepath = gamepath.replaceAll('\\', '/');
73+
});
74+
}
75+
},
76+
style: ElevatedButton.styleFrom(
77+
fixedSize: const Size(200, 50),
78+
),
79+
child: const Text("Find the executable.", style: TextStyle(fontSize: 15.0)),
80+
),
81+
Container(
82+
margin: const EdgeInsets.only(top: 10.0),
83+
child: Text(gamepath, style: const TextStyle(fontSize: 10.0)),
84+
),
85+
],
86+
),
87+
),
88+
image: const Center(child: Icon(FontAwesomeIcons.edit, size: 50.0)),
89+
),
90+
PageViewModel(
91+
title: "And that's it!",
92+
body: "Let's get started!",
93+
image: const Center(child: Icon(FontAwesomeIcons.checkCircle, size: 100.0)),
94+
),
95+
];
96+
}
97+
98+
@override
99+
Widget build(BuildContext context) {
100+
return IntroductionScreen(
101+
pages: getPages(),
102+
onDone: () async {
103+
104+
if(name != '' && gamepath != ''){
105+
testAdd(name, gamepath.toString());
106+
GlobalVariables.addGame(name, gamepath.toString());
107+
}
108+
Navigator.pushNamedAndRemoveUntil(context, '/main', (route) => false);
109+
ScaffoldMessenger.of(context).showSnackBar(
110+
SnackBar(
111+
content: Text('Game $name added!'),
112+
animation: CurvedAnimation(parent: const AlwaysStoppedAnimation(1), curve: Curves.easeInOut),
113+
behavior: SnackBarBehavior.floating,
114+
),
115+
);
116+
},
117+
showSkipButton: screenValue == 0 ? true : false,
118+
showNextButton: true,
119+
showBackButton: screenValue == 0 ? false : true,
120+
back: const Text("Go Back"),
121+
overrideSkip: screenValue == 0 ? ElevatedButton(
122+
onPressed: () {
123+
Navigator.pushNamedAndRemoveUntil(context, '/main', (route) => false);
124+
},
125+
style: ElevatedButton.styleFrom(
126+
fixedSize: const Size(100, 25),
127+
),
128+
// If screenValue is 0, the skip button will be "Skip", else it will be "Cancel"
129+
child: Text(screenValue == 0 ? "Cancel" : "Go Back"),
130+
) : null,
131+
onChange: (value) {
132+
setState(() {
133+
screenValue = value;
134+
});
135+
},
136+
next: const Text("Next"),
137+
done: const Text("Done!", style: TextStyle(fontWeight: FontWeight.w600)),
138+
);
139+
}
140+
141+
@override
142+
void dispose() {
143+
// Dispose of the TextEditingController when the widget is disposed
144+
nameController.dispose();
145+
super.dispose();
146+
}
147+
}

lib/screens/config.dart

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ class ConfigScreen extends State<Config> {
4141
Center(
4242
child: Container(
4343
margin: const EdgeInsets.only(top: 10.0),
44-
child: ElevatedButton(
44+
child: Tooltip(
45+
message: '500mb required.',
46+
child: ElevatedButton(
4547
onPressed: () async {
4648
await launchUrl(Uri.parse('https://store.steampowered.com/about/download'));
4749
},
@@ -50,12 +52,14 @@ class ConfigScreen extends State<Config> {
5052
),
5153
child: const Text("Install Steam"),
5254
)
53-
)
55+
))
5456
),
5557
Center(
5658
child: Container(
5759
margin: const EdgeInsets.only(top: 10.0),
58-
child: ElevatedButton(
60+
child: Tooltip(
61+
message: '200mb required for initial download.',
62+
child: ElevatedButton(
5963
onPressed: () async {
6064
await launchUrl(Uri.parse('steam://install/382260'));
6165
},
@@ -64,6 +68,7 @@ class ConfigScreen extends State<Config> {
6468
),
6569
child: const Text("Install 8 Bit Fiesta"),
6670
)
71+
)
6772
)
6873
),
6974
],)),

lib/screens/delete.dart

Whitespace-only changes.

0 commit comments

Comments
 (0)