Skip to content

Commit

Permalink
add annoying prompts; fix some ordering; add viewMode
Browse files Browse the repository at this point in the history
  • Loading branch information
mootw committed Apr 4, 2024
1 parent 50df952 commit 7b39578
Show file tree
Hide file tree
Showing 10 changed files with 213 additions and 89 deletions.
46 changes: 38 additions & 8 deletions app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,26 @@ class MyApp extends StatelessWidget {
],
child: MaterialApp(
title: 'Snout Scout',
// TODO this kinda thing to automatically set parameters for the app???
// onGenerateRoute: (settings) {
// final dataProvider = context.read<DataProvider>();
// print("asdf");
// () async {
// final uri = Uri.parse(settings.name ?? "");
// print(uri.toString());
// final server = uri.queryParameters['server'];
// if (server != null) {
// print("set server");
// dataProvider.setServer(server);
// }
// final event = uri.queryParameters['event'];
// if (event != null) {
// await dataProvider.setSelectedEvent(event);
// dataProvider.setDataSource(DataSource.remoteServer);
// }
// }();
// return null;
// },
theme: defaultTheme,
home: const MyHomePage(),
));
Expand Down Expand Up @@ -96,6 +116,13 @@ class _MyHomePageState extends State<MyHomePage> with WidgetsBindingObserver {
));
}
});

Future.delayed(const Duration(seconds: 1), () {
final identityProvider = context.read<IdentityProvider>();
if (identityProvider.identity == unknownIdentity) {
editIdentityFunction(context, identityProvider);
}
});
}

@override
Expand Down Expand Up @@ -129,7 +156,7 @@ class _MyHomePageState extends State<MyHomePage> with WidgetsBindingObserver {
appBar: AppBar(
bottom: const LoadOrErrorStatusBar(),
titleSpacing: 0,
title: Text(data.event.config.name),
title: Text('${identityProvider.identity} @ ${data.event.config.name}'),
actions: [
if (tbaKey != null)
Padding(
Expand Down Expand Up @@ -202,13 +229,7 @@ class _MyHomePageState extends State<MyHomePage> with WidgetsBindingObserver {
child: ListView(children: [
ListTile(
title: const Text("Identity"),
onTap: () async {
final result = await showStringInputDialog(
context, "Identity", identityProvider.identity);
if (result != null) {
await identityProvider.setIdentity(result);
}
},
onTap: () => editIdentityFunction(context, identityProvider),
subtitle: Text(identityProvider.identity),
leading: const Icon(Icons.edit),
),
Expand Down Expand Up @@ -371,3 +392,12 @@ class _MyHomePageState extends State<MyHomePage> with WidgetsBindingObserver {
);
}
}

Future editIdentityFunction(
BuildContext context, IdentityProvider identityProvider) async {
final result = await showStringInputDialog(
context, "Identity", identityProvider.identity);
if (result != null) {
await identityProvider.setIdentity(result);
}
}
22 changes: 21 additions & 1 deletion app/lib/screens/analysis/match_preview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class _AnalysisMatchPreviewState extends State<AnalysisMatchPreview> {
style:
Theme.of(context).textTheme.titleMedium),
PathsViewer(
size: 300,
size: 280,
paths: [
for (final match
in data.event.teamRecordedMatches(team))
Expand All @@ -224,6 +224,26 @@ class _AnalysisMatchPreviewState extends State<AnalysisMatchPreview> {
],
),
const SizedBox(height: 8),
Column(
children: [
const SizedBox(height: 8),
Text("Starting Positions",
style:
Theme.of(context).textTheme.titleMedium),
FieldHeatMap(
events: [
for (final match
in data.event.teamRecordedMatches(team))
match.value.robot[team.toString()]!
.timelineInterpolatedBlueNormalized(
data.event.config.fieldStyle)
.where((element) =>
element.isPositionEvent)
.first
].nonNulls.toList(),
),
],
),
Text("Autos Heatmap",
style: Theme.of(context).textTheme.titleMedium),
FieldHeatMap(
Expand Down
1 change: 0 additions & 1 deletion app/lib/screens/configure_source.dart
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ class _ConfigureSourceScreenState extends State<ConfigureSourceScreen> {
context, "Server", provider.serverURL);
if (result != null) {
await provider.setServer(result);

}
updateEvents();
},
Expand Down
2 changes: 1 addition & 1 deletion app/lib/screens/documentation_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class _DocumentationScreenState extends State<DocumentationScreen> {

String result;
try {
// FOR THE PIT MAP ALLOW FOR resolution higher than the standard scouting
// FOR THE PIT MAP ALLOW FOR resolution higher than the standard scouting
// image. This is because the pitmap might contain super small text
final photo =
await pickOrTakeImageDialog(context, scoutImageSize * 1.5);
Expand Down
3 changes: 2 additions & 1 deletion app/lib/screens/edit_schedule.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ class _EditSchedulePageState extends State<EditSchedulePage> {
Navigator.pop(context);
}
},
child: const Text("Apply"))
child: const Text(
"Apply (Wait for dialog to close after pressing ik its jank)"))
],
);
});
Expand Down
2 changes: 1 addition & 1 deletion app/lib/screens/match_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ class _MatchPageState extends State<MatchPage> {
],
rows: [
for (final team in <int>{
...match.red,
...match.blue,
...match.red,
//Also include all of the surrogate robots
...match.robot.keys.map((e) => int.tryParse(e)).whereNotNull()
})
Expand Down
32 changes: 24 additions & 8 deletions app/lib/screens/scout_leaderboard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,51 @@ class ScoutLeaderboardPage extends StatelessWidget {
Widget build(BuildContext context) {
final data = context.watch<DataProvider>().database.patches;

final expression = RegExp(r'\/matches\/.+\/robot\/');

Map<String, int> scores = SplayTreeMap<String, int>();
Map<String, int> edits = SplayTreeMap<String, int>();

for (final patch in data) {
if (scores[patch.identity] == null) {
scores[patch.identity] = 0;
edits[patch.identity] = 0;
}

int addValue = 1;
if (patch.path.startsWith("/matches")) {
//MATCH SCOUTS ARE WORTH DOUBLE POINTS!
addValue = 2;
if (expression.hasMatch(patch.path)) {
addValue = 5;
}

edits[patch.identity] = edits[patch.identity]! + 1;
scores[patch.identity] = scores[patch.identity]! + addValue;
}

var sortedByKeyMap = SplayTreeMap<String, int>.from(
scores, (k1, k2) => scores[k2]!.compareTo(scores[k1]!));
print(scores);

List<({String identity, int score, int edits})> sorted = [
for (final scout in scores.entries)
(
identity: scout.key,
score: scout.value,
edits: edits[scout.key]!,
),
];

sorted.sort((k1, k2) => k2.score.compareTo(k1.score));

return Scaffold(
appBar: AppBar(
title: const Text("Edits Leaderboard"),
),
body: ListView(
children: [
for (final item in sortedByKeyMap.entries)
const Text(
"This is just for fun! Each normal edit is worth 1 point (pit scouting is worth 1 point per field). A edits that match 'r'\\/matches\\/.+\\/robot\\/'' are worth 5 points because match recordings take longer."),
for (final item in sorted)
ListTile(
title: Text(item.key),
subtitle: Text("${item.value}"),
title: Text(item.identity),
subtitle: Text("Score: ${item.score}\nEdits: ${item.edits}"),
)
],
),
Expand Down
36 changes: 27 additions & 9 deletions app/lib/screens/view_team_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -218,24 +218,18 @@ class _TeamViewPageState extends State<TeamViewPage> {
events: [
for (final match in data.event
.teamRecordedMatches(widget.teamNumber))
match.value.robot[widget.teamNumber.toString()]!
...match
.value.robot[widget.teamNumber.toString()]!
.timelineInterpolatedBlueNormalized(
data.event.config.fieldStyle)
.where((element) => element.isInAuto)
.last
].nonNulls.toList(),
],
),
],
),
],
),
const Divider(height: 32),
Center(
child: Text("Scouting",
style: Theme.of(context).textTheme.titleLarge)),
ScoutingResultsViewer(
teamNumber: widget.teamNumber, snoutData: data),
const Divider(height: 32),
DataSheet(
title: 'Matches',
//Data is a list of rows and columns
Expand Down Expand Up @@ -309,6 +303,24 @@ class _TeamViewPageState extends State<TeamViewPage> {
],
),
const Divider(),
Column(
children: [
const SizedBox(height: 16),
Text("Starting Positions",
style: Theme.of(context).textTheme.titleMedium),
FieldHeatMap(
events: [
for (final match in data.event
.teamRecordedMatches(widget.teamNumber))
match.value.robot[widget.teamNumber.toString()]!
.timelineInterpolatedBlueNormalized(
data.event.config.fieldStyle)
.where((element) => element.isPositionEvent)
.first
].nonNulls.toList(),
),
],
),
for (final eventType in data.event.config.matchscouting.events)
Column(children: [
const SizedBox(height: 16),
Expand Down Expand Up @@ -358,6 +370,12 @@ class _TeamViewPageState extends State<TeamViewPage> {
),
],
),
const Divider(height: 32),
Center(
child: Text("Scouting",
style: Theme.of(context).textTheme.titleLarge)),
ScoutingResultsViewer(
teamNumber: widget.teamNumber, snoutData: data),
],
));
}
Expand Down
2 changes: 1 addition & 1 deletion app/lib/services/tba_autofill.dart
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ Future<List<Patch>> loadScheduleFromTBA(
robot: const {});

Patch patch = Patch(
identity: identity,
identity: 'schedule autofill - $identity',
time: DateTime.now(),
path: Patch.buildPath([
'matches',
Expand Down
Loading

0 comments on commit 7b39578

Please sign in to comment.