Archive incari-client (client, 26.3, clean)
This commit is contained in:
+24
@@ -0,0 +1,24 @@
|
||||
package incari.features.clearchat;
|
||||
|
||||
import incari.framework.Category;
|
||||
import incari.framework.Module;
|
||||
import incari.framework.game.GameOption;
|
||||
|
||||
/**
|
||||
* Clear Chat: no dark box behind the chat's lines. It holds the game's own Text Background Opacity
|
||||
* (Chat Settings) at 0 while on, so the game's slider shows it; moving that slider hands control
|
||||
* back to the player and turns the module off. Turning the module off puts the player's opacity
|
||||
* back.
|
||||
*/
|
||||
public final class ClearChat extends Module {
|
||||
|
||||
/** Clear Chat, off until the player turns it on. */
|
||||
public ClearChat() {
|
||||
super(
|
||||
"clearchat",
|
||||
"Clear Chat",
|
||||
"Removes the dark box behind chat (the game's Text Background Opacity, set to 0%).",
|
||||
Category.HUD);
|
||||
holdOption(GameOption.TEXT_BACKGROUND_OPACITY, () -> 0);
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
/** Clear Chat (ADR 0050): chat without the dark box behind its lines. */
|
||||
@NullMarked
|
||||
package incari.features.clearchat;
|
||||
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package incari.features.clearchat;
|
||||
|
||||
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.classes;
|
||||
|
||||
import com.tngtech.archunit.core.importer.ImportOption;
|
||||
import com.tngtech.archunit.junit.AnalyzeClasses;
|
||||
import com.tngtech.archunit.junit.ArchTest;
|
||||
import com.tngtech.archunit.lang.ArchRule;
|
||||
|
||||
/** A feature sees the module framework and the JDK's basics: no game, platform or other feature. */
|
||||
@AnalyzeClasses(packages = "incari.features.clearchat", importOptions = ImportOption.DoNotIncludeTests.class)
|
||||
class BoundaryTest {
|
||||
|
||||
@ArchTest
|
||||
static final ArchRule onlyTheFramework = classes()
|
||||
.should()
|
||||
.onlyDependOnClassesThat()
|
||||
.resideInAnyPackage(
|
||||
"java.lang..",
|
||||
"java.util..",
|
||||
"org.jspecify..",
|
||||
"incari.framework..",
|
||||
"incari.features.clearchat..");
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
package incari.features.clearchat;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.data.Offset.offset;
|
||||
|
||||
import incari.framework.game.GameOption;
|
||||
import incari.framework.testing.TestGame;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class ClearChatTest {
|
||||
|
||||
private final ClearChat module = new ClearChat();
|
||||
private final TestGame game = new TestGame(module);
|
||||
|
||||
@Test
|
||||
void setsTheChatsBackgroundOpacityToZeroWhileOn() {
|
||||
game.setOption(GameOption.TEXT_BACKGROUND_OPACITY, 0.7);
|
||||
module.setEnabled(true);
|
||||
assertThat(game.option(GameOption.TEXT_BACKGROUND_OPACITY)).isZero();
|
||||
game.ticks(5);
|
||||
assertThat(module.isEnabled()).isTrue();
|
||||
|
||||
module.setEnabled(false);
|
||||
assertThat(game.option(GameOption.TEXT_BACKGROUND_OPACITY)).isEqualTo(0.7, offset(1e-4));
|
||||
}
|
||||
|
||||
@Test
|
||||
void raisingTheSliderInChatSettingsTurnsItOffAndKeepsTheNewValue() {
|
||||
module.setEnabled(true);
|
||||
game.setOption(GameOption.TEXT_BACKGROUND_OPACITY, 0.3);
|
||||
game.tick();
|
||||
assertThat(module.isEnabled()).isFalse();
|
||||
assertThat(game.option(GameOption.TEXT_BACKGROUND_OPACITY)).isEqualTo(0.3);
|
||||
}
|
||||
|
||||
@Test
|
||||
void givesThePlayersOpacityBackAfterARestartWithItOn() {
|
||||
game.setOption(GameOption.TEXT_BACKGROUND_OPACITY, 0.6);
|
||||
module.setEnabled(true);
|
||||
game.system().flush();
|
||||
|
||||
// A new start: the game's options kept the 0, the profile has the module on.
|
||||
ClearChat again = new ClearChat();
|
||||
TestGame restarted = new TestGame(again);
|
||||
restarted.files.putAll(game.files);
|
||||
restarted.setOption(GameOption.TEXT_BACKGROUND_OPACITY, 0);
|
||||
restarted.system().load();
|
||||
assertThat(again.isEnabled()).isTrue();
|
||||
|
||||
again.setEnabled(false);
|
||||
assertThat(restarted.option(GameOption.TEXT_BACKGROUND_OPACITY)).isEqualTo(0.6, offset(1e-4));
|
||||
}
|
||||
|
||||
@Test
|
||||
void theHeldValueIsntInTheSettingsScreen() {
|
||||
assertThat(module.settings().anyShown()).isTrue(); // the toggle key
|
||||
assertThat(module.settings().get("before-text-background-opacity").isVisible())
|
||||
.isFalse();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user