Screw shaders. Calculator looks like ass for now

This commit is contained in:
dan63047 2024-09-20 01:38:31 +03:00
parent 374293b275
commit b56d534cb3
2 changed files with 316 additions and 162 deletions

View File

@ -46,6 +46,7 @@ import 'package:tetra_stats/main.dart';
import 'package:tetra_stats/widgets/tl_progress_bar.dart'; import 'package:tetra_stats/widgets/tl_progress_bar.dart';
import 'package:tetra_stats/widgets/user_thingy.dart'; import 'package:tetra_stats/widgets/user_thingy.dart';
import 'package:transparent_image/transparent_image.dart'; import 'package:transparent_image/transparent_image.dart';
import 'package:vector_math/vector_math_64.dart' hide Colors;
var fDiff = NumberFormat("+#,###.####;-#,###.####"); var fDiff = NumberFormat("+#,###.####;-#,###.####");
late Future<FetchResults> _data; late Future<FetchResults> _data;
@ -202,6 +203,7 @@ class _MainState extends State<MainView> with TickerProviderStateMixin {
1 => DestinationGraphs(searchFor: _searchFor, constraints: constraints), 1 => DestinationGraphs(searchFor: _searchFor, constraints: constraints),
2 => DestinationLeaderboards(constraints: constraints), 2 => DestinationLeaderboards(constraints: constraints),
3 => DestinationCutoffs(constraints: constraints), 3 => DestinationCutoffs(constraints: constraints),
4 => DestinationCalculator(constraints: constraints),
_ => Text("Unknown destination $destination") _ => Text("Unknown destination $destination")
}, },
) )
@ -211,6 +213,120 @@ class _MainState extends State<MainView> with TickerProviderStateMixin {
} }
} }
class DestinationCalculator extends StatefulWidget{
final BoxConstraints constraints;
const DestinationCalculator({super.key, required this.constraints});
@override
State<DestinationCalculator> createState() => _DestinationCalculatorState();
}
class _DestinationCalculatorState extends State<DestinationCalculator> {
double? apm;
double? pps;
double? vs;
NerdStats? nerdStats;
EstTr? estTr;
Playstyle? playstyle;
TextEditingController ppsController = TextEditingController();
TextEditingController apmController = TextEditingController();
TextEditingController vsController = TextEditingController();
@override
void initState() {
super.initState();
}
@override
void dispose() {
super.dispose();
}
void calc() {
apm = double.tryParse(apmController.text);
pps = double.tryParse(ppsController.text);
vs = double.tryParse(vsController.text);
if (apm != null && pps != null && vs != null) {
nerdStats = NerdStats(apm!, pps!, vs!);
estTr = EstTr(apm!, pps!, vs!, nerdStats!.app, nerdStats!.dss, nerdStats!.dsp, nerdStats!.gbe);
playstyle = Playstyle(apm!, pps!, nerdStats!.app, nerdStats!.vsapm, nerdStats!.dsp, nerdStats!.gbe, estTr!.srarea, estTr!.statrank);
setState(() {});
} else {
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text("Please, enter valid values")));
}
}
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: Column(
children: [
Card(
child: Center(child: Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: Column(
children: [
Text("Stats Calucator", style: const TextStyle(fontFamily: "Eurostile Round Extended", fontSize: 42)),
],
),
)),
),
Card(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: [
Expanded(
child: Padding(
padding: const EdgeInsets.only(right: 12),
child: TextField(
onSubmitted: (value) => calc(),
controller: apmController,
keyboardType: TextInputType.number,
decoration: const InputDecoration(suffix: Text("APM"), alignLabelWithHint: true, hintText: "Enter your APM"),
),
)),
Expanded(
child: TextField(
onSubmitted: (value) => calc(),
controller: ppsController,
keyboardType: TextInputType.number,
decoration: const InputDecoration(suffix: Text("PPS"), alignLabelWithHint: true, hintText: "Enter your PPS"),
)),
Expanded(
child: Padding(
padding: const EdgeInsets.only(left: 12),
child: TextField(
onSubmitted: (value) => calc(),
controller: vsController,
keyboardType: TextInputType.number,
decoration: const InputDecoration(suffix: Text("VS"), alignLabelWithHint: true, hintText: "Enter your VS"),
),
)),
TextButton(
onPressed: () => calc(),
child: Text(t.calc),
),
],
),
),
),
if (nerdStats != null && playstyle != null) Card(
child: Row(
children: [
Expanded(child: NerdStatsThingy(nerdStats: nerdStats!)),
Expanded(child: GraphsThingy(nerdStats: nerdStats!, playstyle: playstyle!, apm: apm!, pps: pps!, vs: vs!))
],
),
)
],
),
);
}
}
class FetchCutoffsResults{ class FetchCutoffsResults{
late bool success; late bool success;
CutoffsTetrio? cutoffs; CutoffsTetrio? cutoffs;
@ -269,11 +385,38 @@ class _DestinationCutoffsState extends State<DestinationCutoffs> {
child: Column( child: Column(
children: [ children: [
Card( Card(
child: Center(child: Text("Tetra League State")), child: Center(child: Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: Column(
children: [
Text("Tetra League State", style: const TextStyle(fontFamily: "Eurostile Round Extended", fontSize: 42)),
Text("as of ${timestamp(snapshot.data!.timestamp)}"),
],
), ),
Card( )),
),
Padding(
padding: const EdgeInsets.only(bottom:4.0),
child: Card(
child: Column(
children: [
Row(
children: [
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Column(
children: [
Padding(
padding: const EdgeInsets.only(bottom: 12.0),
child: Text("Actual"),
),
Text("Target")
]
),
),
Expanded(
child: Padding( child: Padding(
padding: const EdgeInsets.fromLTRB(20.0, 8.0, 20.0, 8.0), padding: const EdgeInsets.fromLTRB(12.0, 8.0, 12.0, 8.0),
child: SfLinearGauge( child: SfLinearGauge(
minimum: 0.00000000, minimum: 0.00000000,
maximum: 25000.0000, maximum: 25000.0000,
@ -290,10 +433,7 @@ class _DestinationCutoffsState extends State<DestinationCutoffs> {
"x+" => snapshot.data!.data["top1"]!.tr, "x+" => snapshot.data!.data["top1"]!.tr,
_ => snapshot.data!.data[ranks[ranks.indexOf(cutoff)+1]]!.tr _ => snapshot.data!.data[ranks[ranks.indexOf(cutoff)+1]]!.tr
}, },
color: cutoff != "top1" ? rankColors[cutoff] : null, color: cutoff != "top1" ? rankColors[cutoff] : Colors.grey.shade800,
// shaderCallback: (bounds) {
// return ImageShader(Image.file(""), TileMode.repeated, TileMode.repeated, Matrix4.identity().storage);
// },
), ),
for (var cutoff in snapshot.data!.data.keys) LinearGaugeRange( for (var cutoff in snapshot.data!.data.keys) LinearGaugeRange(
position: LinearElementPosition.inside, position: LinearElementPosition.inside,
@ -304,15 +444,33 @@ class _DestinationCutoffsState extends State<DestinationCutoffs> {
_ => snapshot.data!.data[ranks[ranks.indexOf(cutoff)+1]]!.targetTr _ => snapshot.data!.data[ranks[ranks.indexOf(cutoff)+1]]!.targetTr
}, },
color: cutoff != "top1" ? rankColors[cutoff] : null, color: cutoff != "top1" ? rankColors[cutoff] : null,
) ),
for (var cutoff in snapshot.data!.data.keys.skip(1)) if (snapshot.data!.data[cutoff]!.tr < snapshot.data!.data[cutoff]!.targetTr) LinearGaugeRange(
position: LinearElementPosition.cross,
startValue: snapshot.data!.data[cutoff]!.tr,
endValue: snapshot.data!.data[cutoff]!.targetTr,
color: Colors.green,
),
for (var cutoff in snapshot.data!.data.keys.skip(1)) if (snapshot.data!.data[ranks[ranks.indexOf(cutoff)+1]]!.tr > snapshot.data!.data[ranks[ranks.indexOf(cutoff)+1]]!.targetTr)LinearGaugeRange(
position: LinearElementPosition.cross,
startValue: snapshot.data!.data[ranks[ranks.indexOf(cutoff)+1]]!.targetTr,
endValue: snapshot.data!.data[ranks[ranks.indexOf(cutoff)+1]]!.tr,
color: Colors.red,
),
],
markerPointers: [
for (var cutoff in snapshot.data!.data.keys) LinearWidgetPointer(child: Container(child: Text(intf.format(snapshot.data!.data[cutoff]!.tr), style: TextStyle(fontSize: 12)), transform: Matrix4.compose(Vector3(0, 35, 0), Quaternion.axisAngle(Vector3(0, 0, 1), -1), Vector3(1, 1, 1)), height: 45.0), value: snapshot.data!.data[cutoff]!.tr, position: LinearElementPosition.outside, offset: 20),
for (var cutoff in snapshot.data!.data.keys) LinearWidgetPointer(child: Container(child: Text(intf.format(snapshot.data!.data[cutoff]!.targetTr), textAlign: ui.TextAlign.right, style: TextStyle(fontSize: 12)), transform: Matrix4.compose(Vector3(-15, 0, 0), Quaternion.axisAngle(Vector3(0, 0, 1), -1), Vector3(1, 1, 1)), height: 45.0, transformAlignment: Alignment.topRight), value: snapshot.data!.data[cutoff]!.targetTr, position: LinearElementPosition.inside, offset: 6)
],
),
),
),
],
),
], ],
), ),
), ),
), ),
Card(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Table( Table(
defaultVerticalAlignment: TableCellVerticalAlignment.middle, defaultVerticalAlignment: TableCellVerticalAlignment.middle,
border: TableBorder.all(color: Colors.grey.shade900), border: TableBorder.all(color: Colors.grey.shade900),
@ -435,10 +593,6 @@ class _DestinationCutoffsState extends State<DestinationCutoffs> {
] ]
) )
], ],
),
Text(t.sprintAndBlitsRelevance(date: timestamp(snapshot.data!.timestamp)))
],
),
) )
] ]
), ),

View File

@ -358,9 +358,9 @@ class TlMatchResultState extends State<TlMatchResultView> {
CompareThingy( CompareThingy(
label: "Plonk", label: "Plonk",
greenSide: roundSelector == -2 ? timeWeightedStats[0].playstyle.plonk : greenSide: roundSelector == -2 ? timeWeightedStats[0].playstyle.plonk :
roundSelector.isNegative ? widget.record.results.leaderboard[greenSidePlayer].stats.playstyle.opener : widget.record.results.rounds[roundSelector].firstWhere((element) => element.id == widget.initPlayerId).stats.playstyle.plonk, roundSelector.isNegative ? widget.record.results.leaderboard[greenSidePlayer].stats.playstyle.plonk : widget.record.results.rounds[roundSelector].firstWhere((element) => element.id == widget.initPlayerId).stats.playstyle.plonk,
redSide: roundSelector == -2 ? timeWeightedStats[1].playstyle.plonk : redSide: roundSelector == -2 ? timeWeightedStats[1].playstyle.plonk :
roundSelector == -1 ? widget.record.results.leaderboard[redSidePlayer].stats.playstyle.opener : widget.record.results.rounds[roundSelector].firstWhere((element) => element.id != widget.initPlayerId).stats.playstyle.plonk, roundSelector == -1 ? widget.record.results.leaderboard[redSidePlayer].stats.playstyle.plonk : widget.record.results.rounds[roundSelector].firstWhere((element) => element.id != widget.initPlayerId).stats.playstyle.plonk,
fractionDigits: 3, fractionDigits: 3,
higherIsBetter: true, higherIsBetter: true,
), ),