Skip to content

Commit 7837238

Browse files
authored
Merge pull request #65 from gabber235/develop
V0.3.1 Simple Bugfixes
2 parents d79dcde + 39ffdc6 commit 7837238

File tree

26 files changed

+485
-210
lines changed

26 files changed

+485
-210
lines changed

adapters/BasicAdapter/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ repositories {
2222

2323
dependencies {
2424
compileOnly(kotlin("stdlib"))
25-
compileOnly("io.papermc.paper:paper-api:1.19.4-R0.1-SNAPSHOT")
25+
compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT")
2626

2727
compileOnly("me.gabber235:typewriter:$version")
2828

adapters/BasicAdapter/src/main/kotlin/me/gabber235/typewriter/entries/cinematic/BlindingCinematicEntry.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import me.gabber235.typewriter.utils.GenericPlayerStateProvider.LOCATION
1818
import org.bukkit.GameMode
1919
import org.bukkit.entity.Player
2020
import org.bukkit.potion.PotionEffect
21+
import org.bukkit.potion.PotionEffect.INFINITE_DURATION
2122
import org.bukkit.potion.PotionEffectType.BLINDNESS
2223

2324
@Entry("blinding_cinematic", "Blind the player so the screen looks black", Colors.CYAN, Icons.SOLID_EYE_SLASH)
@@ -64,10 +65,10 @@ class BlindingCinematicAction(
6465

6566
override suspend fun startSegment(segment: BlindingSegment) {
6667
super.startSegment(segment)
67-
state = player.state(LOCATION, GAME_MODE)
68+
state = player.state(LOCATION, GAME_MODE, EffectStateProvider(BLINDNESS))
6869

6970
withContext(plugin.minecraftDispatcher) {
70-
player.addPotionEffect(PotionEffect(BLINDNESS, Int.MAX_VALUE, 0, false, false, false))
71+
player.addPotionEffect(PotionEffect(BLINDNESS, INFINITE_DURATION, 0, false, false, false))
7172

7273
if (segment.teleport) {
7374
/// Teleport the player high up to prevent them from seeing the world
@@ -85,9 +86,7 @@ class BlindingCinematicAction(
8586
val state = state ?: return
8687
this.state = null
8788
withContext(plugin.minecraftDispatcher) {
88-
player.removePotionEffect(BLINDNESS)
8989
player.restore(state)
9090
}
9191
}
92-
93-
}
92+
}

adapters/BasicAdapter/src/main/kotlin/me/gabber235/typewriter/entries/cinematic/CameraCinematicEntry.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ import me.gabber235.typewriter.utils.GenericPlayerStateProvider.*
2121
import org.bukkit.Location
2222
import org.bukkit.entity.EntityType
2323
import org.bukkit.entity.Player
24+
import org.bukkit.potion.PotionEffect
25+
import org.bukkit.potion.PotionEffect.INFINITE_DURATION
26+
import org.bukkit.potion.PotionEffectType.INVISIBILITY
2427

2528
@Entry("camera_cinematic", "Create a cinematic camera path", Colors.CYAN, Icons.VIDEO)
2629
/**
@@ -86,11 +89,19 @@ class CameraCinematicAction(
8689
}
8790
segments.forEach { it.setup() }
8891

89-
originalState = player.state(LOCATION, ALLOW_FLIGHT, FLYING, VISIBLE_PLAYERS, SHOWING_PLAYER)
92+
originalState = player.state(
93+
LOCATION,
94+
ALLOW_FLIGHT,
95+
FLYING,
96+
VISIBLE_PLAYERS,
97+
SHOWING_PLAYER,
98+
EffectStateProvider(INVISIBILITY)
99+
)
90100

91101
withContext(plugin.minecraftDispatcher) {
92102
player.allowFlight = true
93103
player.isFlying = true
104+
player.addPotionEffect(PotionEffect(INVISIBILITY, INFINITE_DURATION, 0, false, false))
94105
server.onlinePlayers.forEach {
95106
it.hidePlayer(plugin, player)
96107
player.hidePlayer(plugin, it)

adapters/BasicAdapter/src/main/kotlin/me/gabber235/typewriter/entries/cinematic/DisplayDialogueCinematicAction.kt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
package me.gabber235.typewriter.entries.cinematic
22

3+
import com.github.shynixn.mccoroutine.bukkit.minecraftDispatcher
4+
import kotlinx.coroutines.withContext
35
import me.gabber235.typewriter.adapters.modifiers.Colored
46
import me.gabber235.typewriter.adapters.modifiers.Help
57
import me.gabber235.typewriter.adapters.modifiers.Placeholder
68
import me.gabber235.typewriter.entry.dialogue.playSpeakerSound
79
import me.gabber235.typewriter.entry.entries.*
810
import me.gabber235.typewriter.extensions.placeholderapi.parsePlaceholders
9-
import me.gabber235.typewriter.utils.GenericPlayerStateProvider
11+
import me.gabber235.typewriter.plugin
12+
import me.gabber235.typewriter.utils.GenericPlayerStateProvider.EXP
13+
import me.gabber235.typewriter.utils.GenericPlayerStateProvider.LEVEL
1014
import me.gabber235.typewriter.utils.PlayerState
1115
import me.gabber235.typewriter.utils.restore
1216
import me.gabber235.typewriter.utils.state
@@ -52,7 +56,7 @@ class DisplayDialogueCinematicAction(
5256

5357
override suspend fun setup() {
5458
super.setup()
55-
state = player.state(GenericPlayerStateProvider.EXP, GenericPlayerStateProvider.LEVEL)
59+
state = player.state(EXP, LEVEL)
5660
player.exp = 0f
5761
player.level = 0
5862
setup?.invoke(player)
@@ -91,9 +95,11 @@ class DisplayDialogueCinematicAction(
9195

9296
override suspend fun teardown() {
9397
super.teardown()
94-
player.restore(state)
9598
teardown?.invoke(player)
9699
reset?.invoke(player)
100+
withContext(plugin.minecraftDispatcher) {
101+
player.restore(state)
102+
}
97103
}
98104

99105
override fun canFinish(frame: Int): Boolean = segments canFinishAt frame

adapters/CitizensAdapter/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ repositories {
2525

2626
dependencies {
2727
compileOnly(kotlin("stdlib"))
28-
compileOnly("io.papermc.paper:paper-api:1.19.4-R0.1-SNAPSHOT")
28+
compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT")
2929

3030
compileOnly("me.gabber235:typewriter:$version")
3131

adapters/CombatLogXAdapter/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ repositories {
2525

2626
dependencies {
2727
compileOnly(kotlin("stdlib"))
28-
compileOnly("io.papermc.paper:paper-api:1.19.4-R0.1-SNAPSHOT")
28+
compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT")
2929

3030
compileOnly("me.gabber235:typewriter:$version")
3131

app/lib/models/adapter.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,12 @@ extension FieldTypeExtension on FieldInfo {
241241

242242
/// If the [ObjectEditor] needs to show a default layout or if a field declares a custom layout.
243243
bool get hasCustomLayout {
244+
if (this is CustomField) {
245+
final editor = (this as CustomField).editor;
246+
if (editor == "optional") {
247+
return true;
248+
}
249+
}
244250
if (this is ObjectField) {
245251
return true;
246252
}

app/lib/utils/color_filter.dart

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import "package:flutter/material.dart";
2+
3+
// https://api.flutter.dev/flutter/dart-ui/ColorFilter/ColorFilter.matrix.html
4+
const ColorFilter greyscale = ColorFilter.matrix(<double>[
5+
0.2126,
6+
0.7152,
7+
0.0722,
8+
0,
9+
0,
10+
0.2126,
11+
0.7152,
12+
0.0722,
13+
0,
14+
0,
15+
0.2126,
16+
0.7152,
17+
0.0722,
18+
0,
19+
0,
20+
0,
21+
0,
22+
0,
23+
1,
24+
0,
25+
]);

app/lib/widgets/components/general/toasts.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ class ToastDisplay extends HookConsumerWidget {
182182
bottom: 0,
183183
child: SingleChildScrollView(
184184
child: Column(
185+
mainAxisSize: MainAxisSize.min,
185186
children: [
186187
for (final toast in toasts)
187188
if (toast is TemporaryToast)
@@ -259,6 +260,10 @@ class _TemporaryToast extends HookConsumerWidget {
259260
return Card(
260261
color: toast.color,
261262
elevation: 4.0,
263+
shape: RoundedRectangleBorder(
264+
borderRadius: BorderRadius.circular(8.0),
265+
),
266+
clipBehavior: Clip.antiAlias,
262267
child: SizedBox(
263268
width: width,
264269
child: Column(
Lines changed: 96 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
import "package:flutter/material.dart";
2+
import "package:typewriter/utils/color_filter.dart";
23
import "package:flutter_animate/flutter_animate.dart";
34
import "package:hooks_riverpod/hooks_riverpod.dart";
45
import "package:typewriter/models/adapter.dart";
56
import "package:typewriter/utils/passing_reference.dart";
67
import "package:typewriter/widgets/inspector/editors.dart";
78
import "package:typewriter/widgets/inspector/editors/field.dart";
9+
import "package:typewriter/widgets/inspector/header.dart";
810
import "package:typewriter/widgets/inspector/inspector.dart";
911

1012
class OptionalEditorFilter extends EditorFilter {
1113
@override
12-
bool canEdit(FieldInfo info) => info is CustomField && info.editor == "optional";
14+
bool canEdit(FieldInfo info) =>
15+
info is CustomField && info.editor == "optional";
1316

1417
@override
15-
Widget build(String path, FieldInfo info) => OptionalEditor(path: path, field: info as CustomField);
18+
Widget build(String path, FieldInfo info) =>
19+
OptionalEditor(path: path, field: info as CustomField);
1620
}
1721

1822
class OptionalEditor extends HookConsumerWidget {
@@ -44,32 +48,100 @@ class OptionalEditor extends HookConsumerWidget {
4448
);
4549
}
4650

47-
return Row(
48-
children: [
49-
Checkbox(
50-
value: enabled,
51-
onChanged: (value) {
52-
ref.read(inspectingEntryDefinitionProvider)?.updateField(ref.passing, "$path.enabled", value ?? false);
53-
},
54-
),
55-
Expanded(
56-
child: AnimatedOpacity(
57-
opacity: enabled ? 1 : 0.6,
58-
duration: 200.ms,
59-
curve: Curves.easeOut,
60-
child: MouseRegion(
61-
cursor: enabled ? MouseCursor.defer : SystemMouseCursors.forbidden,
62-
child: AbsorbPointer(
63-
absorbing: !enabled,
64-
child: FieldEditor(
65-
path: "$path.value",
66-
type: subField,
51+
final subPath = "$path.value";
52+
final headerActionFilters = ref.watch(headerActionFiltersProvider);
53+
final subFieldActions = headerActionFilters
54+
.where((filter) => filter.shouldShow(subPath, subField))
55+
.toList();
56+
57+
return FieldHeader(
58+
field: field,
59+
path: path,
60+
leading: _buildActions(
61+
HeaderActionLocation.leading,
62+
subFieldActions,
63+
subPath,
64+
subField,
65+
enabled: enabled,
66+
),
67+
trailing: _buildActions(
68+
HeaderActionLocation.trailing,
69+
subFieldActions,
70+
subPath,
71+
subField,
72+
enabled: enabled,
73+
),
74+
actions: _buildActions(
75+
HeaderActionLocation.actions,
76+
subFieldActions,
77+
subPath,
78+
subField,
79+
enabled: enabled,
80+
),
81+
child: Row(
82+
children: [
83+
Checkbox(
84+
value: enabled,
85+
onChanged: (value) {
86+
ref
87+
.read(inspectingEntryDefinitionProvider)
88+
?.updateField(ref.passing, "$path.enabled", value ?? false);
89+
},
90+
),
91+
Expanded(
92+
child: AnimatedOpacity(
93+
opacity: enabled ? 1 : 0.6,
94+
duration: 200.ms,
95+
curve: Curves.easeOut,
96+
child: MouseRegion(
97+
cursor:
98+
enabled ? MouseCursor.defer : SystemMouseCursors.forbidden,
99+
child: AbsorbPointer(
100+
absorbing: !enabled,
101+
child: FieldEditor(
102+
path: "$path.value",
103+
type: subField,
104+
),
67105
),
68106
),
69107
),
70108
),
71-
),
72-
],
109+
],
110+
),
73111
);
74112
}
113+
114+
List<Widget> _buildActions(
115+
HeaderActionLocation location,
116+
List<HeaderActionFilter> actions,
117+
String path,
118+
FieldInfo field, {
119+
bool enabled = true,
120+
}) {
121+
final children = actions
122+
.where((action) => action.location(path, field) == location)
123+
.map((action) => action.build(path, field))
124+
.toList();
125+
if (enabled) {
126+
return children;
127+
}
128+
129+
return [
130+
for (final child in children)
131+
MouseRegion(
132+
cursor: SystemMouseCursors.forbidden,
133+
child: AbsorbPointer(
134+
child: AnimatedOpacity(
135+
opacity: 0.6,
136+
duration: 200.ms,
137+
curve: Curves.easeOut,
138+
child: ColorFiltered(
139+
colorFilter: greyscale,
140+
child: child,
141+
),
142+
),
143+
),
144+
),
145+
];
146+
}
75147
}

0 commit comments

Comments
 (0)