God why am i so slow

This commit is contained in:
dan63047 2024-10-16 01:17:24 +03:00
parent 36aa31a061
commit ceb22716cc
5 changed files with 149 additions and 6 deletions

View File

@ -95,7 +95,7 @@ class TetrioPlayer {
// data['_id'] = userId;
// data['username'] = username;
data['role'] = role;
if (registrationTime != null) data['ts'] = registrationTime?.toString();
data['ts'] = registrationTime.toString();
if (badges.isNotEmpty) data['badges'] = badges.map((v) => v.toJson()).toList();
if (xp >= 0) data['xp'] = xp;
if (gamesPlayed >= 0) data['gamesplayed'] = gamesPlayed;

View File

@ -16,7 +16,7 @@ import 'package:sqflite_common_ffi/sqflite_ffi.dart';
import 'package:sqflite_common_ffi_web/sqflite_ffi_web.dart';
import 'package:tetra_stats/gen/strings.g.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:tetra_stats/views/main_view.dart';
import 'package:tetra_stats/views/main_view_tiles.dart';
import 'package:tetra_stats/views/settings_view.dart';
import 'package:tetra_stats/views/tracked_players_view.dart';
import 'package:tetra_stats/views/calc_view.dart';

View File

@ -150,6 +150,8 @@ class CompareState extends State<CompareView> {
"Pieces Per Second",
"Key Presses Per Second",
""
// TODO: line clears
// TODO: spins
],
"Blitz": [
"Score",
@ -407,7 +409,7 @@ class CompareState extends State<CompareView> {
Text(s.sprint != null ? f4.format(s.sprint!.stats.kps) : "---")
]);
formattedValues[5].add([
Text(s.blitz != null ? getMoreNormalTime(s.blitz!.stats.finalTime) : "---"),
Text(s.blitz != null ? intf.format(s.sprint!.stats.score) : "---"),
Text(s.blitz != null ? intf.format(s.blitz!.stats.piecesPlaced) : "---"),
Text(s.blitz != null ? intf.format(s.blitz!.stats.inputs) : "---"),
Text(s.blitz != null ? f4.format(s.blitz!.stats.kpp) : "---"),
@ -640,7 +642,7 @@ class CompareState extends State<CompareView> {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
for (int l = 0; l < formattedValues[i][k].length; l++) Container(decoration: BoxDecoration(color: (rawValues[0].length > 1 && rawValues[i][k][l] != null && best[i][l] == rawValues[i][k][l]) ? Colors.cyanAccent.withAlpha(96) : null), child: formattedValues[i][k][l]),
for (int l = 0; l < formattedValues[i][k].length; l++) Container(decoration: (rawValues[0].length > 1 && rawValues[i][k][l] != null && best[i][l] == rawValues[i][k][l]) ? BoxDecoration(boxShadow: [BoxShadow(color: Colors.cyanAccent.withAlpha(96), spreadRadius: 0, blurRadius: 4)]) : null, child: formattedValues[i][k][l]),
],
),
),

View File

@ -26,6 +26,7 @@ import 'package:tetra_stats/data_objects/record_single.dart';
import 'package:tetra_stats/data_objects/singleplayer_stream.dart';
import 'package:tetra_stats/data_objects/summaries.dart';
import 'package:tetra_stats/data_objects/tetra_league.dart';
import 'package:tetra_stats/data_objects/tetra_league_alpha_record.dart';
import 'package:tetra_stats/data_objects/tetra_league_beta_stream.dart';
import 'package:tetra_stats/data_objects/tetrio_constants.dart';
import 'package:tetra_stats/data_objects/tetrio_player.dart';
@ -208,6 +209,7 @@ class _MainState extends State<MainView> with TickerProviderStateMixin {
2 => DestinationLeaderboards(constraints: constraints),
3 => DestinationCutoffs(constraints: constraints),
4 => DestinationCalculator(constraints: constraints),
6 => DestinationSavedData(constraints: constraints),
_ => Text("Unknown destination $destination")
},
)
@ -217,6 +219,139 @@ class _MainState extends State<MainView> with TickerProviderStateMixin {
}
}
class DestinationSavedData extends StatefulWidget{
final BoxConstraints constraints;
const DestinationSavedData({super.key, required this.constraints});
@override
State<DestinationSavedData> createState() => _DestinationSavedData();
}
class _DestinationSavedData extends State<DestinationSavedData> {
String? selectedID;
Future<(List<TetraLeague>, List<TetraLeague>, List<TetraLeagueAlphaRecord>)> getDataAbout(String id) async {
return (await teto.getStates(id), await teto.getStates(id, season: 1), await teto.getTLMatchesbyPlayerID(id));
}
Widget getTetraLeagueListTile(TetraLeague data){
return ListTile(
title: Text(timestamp(data.timestamp)),
subtitle: Text("${intf.format(data.gamesPlayed)} games"),
);
}
@override
Widget build(BuildContext context) {
return FutureBuilder<Map<String, String>>(
future: teto.getAllPlayers(),
builder: (context, snapshot) {
switch (snapshot.connectionState){
case ConnectionState.none:
case ConnectionState.waiting:
case ConnectionState.active:
return const Center(child: CircularProgressIndicator());
case ConnectionState.done:
if (snapshot.hasError){ return FutureError(snapshot); }
if (snapshot.hasData){
return Row(
children: [
SizedBox(
width: 450,
child: Column(
children: [
const Card(
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Spacer(),
Text("Saved Data", style: TextStyle(fontFamily: "Eurostile Round Extended", fontSize: 36)),
Spacer()
],
),
),
for (String id in snapshot.data!.keys) Card(
child: ListTile(
title: Text(snapshot.data![id]!),
subtitle: Text("NaN states, NaN TL records", style: TextStyle(color: Colors.grey)),
onTap: () => setState(() {
selectedID = id;
}),
),
)
],
),
),
SizedBox(
width: widget.constraints.maxWidth - 450 - 80,
child: selectedID != null ? FutureBuilder<(List<TetraLeague>, List<TetraLeague>, List<TetraLeagueAlphaRecord>)>(
future: getDataAbout(selectedID!),
builder: (context, snapshot) {
switch(snapshot.connectionState){
case ConnectionState.none:
case ConnectionState.waiting:
case ConnectionState.active:
return const Center(child: CircularProgressIndicator());
case ConnectionState.done:
if (snapshot.hasError){ return FutureError(snapshot); }
if (snapshot.hasData){
return DefaultTabController(
length: 3,
child: Card(
child: Column(
children: [
Card(
child: TabBar(tabs: [
Tab(text: "S${currentSeason} TL States"),
Tab(text: "S1 TL States"),
Tab(text: "TL Records")
]),
),
SizedBox(
height: widget.constraints.maxHeight - 164,
child: TabBarView(children: [
ListView.builder(
itemCount: snapshot.data!.$1.length,
itemBuilder: (context, index) {
return getTetraLeagueListTile(snapshot.data!.$1[index]);
},),
ListView.builder(
itemCount: snapshot.data!.$2.length,
itemBuilder: (context, index) {
return getTetraLeagueListTile(snapshot.data!.$2[index]);
},),
ListView.builder(
itemCount: snapshot.data!.$3.length,
itemBuilder: (context, index) {
return ListTile(
title: Text(snapshot.data!.$3[index].toString()),
);
},),
]
),
)
],
),
),
);
}
return Text("what?");
}
}
) :
Text("Select nickname on the left to see data assosiated with it")
)
],
);
}
}
return const Text("End of FutureBuilder<FetchResults>");
},
);
}
}
class DestinationCalculator extends StatefulWidget{
final BoxConstraints constraints;
@ -682,7 +817,13 @@ class _DestinationCalculatorState extends State<DestinationCalculator> {
SizedBox(
width: widget.constraints.maxWidth - 350 - 80,
height: widget.constraints.maxHeight - 148,
child: clears.isEmpty ? Center(child: Text("Click on the actions on the left to add them here", textAlign: ui.TextAlign.center)) :
child: clears.isEmpty ? Center(child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.info_outline, size: 128.0, color: Colors.grey.shade800),
Text("Click on the actions on the left to add them here", textAlign: ui.TextAlign.center),
],
)) :
Card(
child: Column(
children: [

View File

@ -131,7 +131,7 @@
}
</style>
<!-- This script adds the flutter initialization JS code -->
<script src="flutter.js" defer></script>
<script src="flutter.js?version=1.6.12" defer></script>
</head>
<body>
<div id="preloader">