-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
542 additions
and
298 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package dev.lazurite.hexaplex; | ||
|
||
import blue.endless.jankson.api.SyntaxError; | ||
import dev.lazurite.hexaplex.config.Config; | ||
import dev.lazurite.hexaplex.rendering.ShaderManager; | ||
import dev.lazurite.hexaplex.rendering.MatrixLoader; | ||
import net.fabricmc.api.ClientModInitializer; | ||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
|
||
import java.io.IOException; | ||
|
||
@Environment(EnvType.CLIENT) | ||
public final class Hexaplex implements ClientModInitializer { | ||
public static final String MOD_ID = "hexaplex"; | ||
public static final Logger LOGGER = LogManager.getLogger("Hexaplex"); | ||
|
||
@Override | ||
public void onInitializeClient() { | ||
try { | ||
MatrixLoader.loadMatrices(this.getClass().getResourceAsStream("/assets/hexaplex/shaders/uniform/matrix4x4/filter.json")); | ||
} catch (SyntaxError | IOException e) { | ||
Hexaplex.LOGGER.error("Error loading Hexaplex shader matrices!"); | ||
e.printStackTrace(); | ||
} | ||
|
||
ShaderManager.registerRenderer(); | ||
Config.INSTANCE.load(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,98 +1,131 @@ | ||
package dev.lazurite.hexaplex.config; | ||
|
||
import dev.lazurite.hexaplex.graphics.ShaderManager; | ||
import dev.lazurite.hexaplex.init.ClientInitializer; | ||
import dev.lazurite.hexaplex.Hexaplex; | ||
import dev.lazurite.hexaplex.rendering.Profiles; | ||
import io.github.fablabsmc.fablabs.api.fiber.v1.annotation.AnnotatedSettings; | ||
import io.github.fablabsmc.fablabs.api.fiber.v1.annotation.Setting; | ||
import io.github.fablabsmc.fablabs.api.fiber.v1.annotation.Settings; | ||
import io.github.fablabsmc.fablabs.api.fiber.v1.exception.FiberException; | ||
import io.github.fablabsmc.fablabs.api.fiber.v1.serialization.FiberSerialization; | ||
import io.github.fablabsmc.fablabs.api.fiber.v1.serialization.JanksonValueSerializer; | ||
import io.github.fablabsmc.fablabs.api.fiber.v1.tree.ConfigTree; | ||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
import net.fabricmc.loader.api.FabricLoader; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
@Environment(EnvType.CLIENT) | ||
@Settings(onlyAnnotated = true) | ||
public class Config { | ||
public final class Config { | ||
|
||
public static final Config INSTANCE = new Config(); | ||
|
||
private boolean dirty; | ||
private static final Path PATH = FabricLoader.getInstance().getConfigDir().resolve(Hexaplex.MOD_ID + ".json"); | ||
|
||
@Setting(name = "filterProfile") | ||
private ShaderManager.Profiles profile; | ||
@Setting(name = "profile") | ||
private Profiles profile; | ||
|
||
@Setting(name = "filterStrength") | ||
@Setting(name = "strength") | ||
@Setting.Constrain.Range(min = 0.0, max = 1.0, step = 0.01) | ||
private double strength; | ||
|
||
private Config() { | ||
this.profile = ShaderManager.Profiles.NORMAL; | ||
this.strength = 0.0; | ||
this.dirty = true; | ||
} | ||
|
||
private void markDirty() { | ||
this.dirty = true; | ||
} | ||
@Setting(name = "skew") | ||
@Setting.Constrain.Range(min = 0.0, max = 1.0, step = 0.01) | ||
private double skew; | ||
|
||
public void markClean() { | ||
this.dirty = true; | ||
} | ||
private boolean dirty; | ||
|
||
public boolean isDirty() { | ||
return this.dirty; | ||
private Config() { | ||
this.setProfile(Profiles.NORMAL); | ||
this.setStrength(0.0); | ||
this.setSkew(0.5); | ||
this.markDirty(); | ||
} | ||
|
||
public void save() { | ||
try { | ||
FiberSerialization.serialize( | ||
ConfigTree.builder().applyFromPojo(INSTANCE, AnnotatedSettings.builder().collectOnlyAnnotatedMembers().build()).build(), | ||
Files.newOutputStream(FabricLoader.getInstance().getConfigDir().resolve("hexaplex.json")), | ||
ConfigTree.builder() | ||
.applyFromPojo( | ||
INSTANCE, | ||
AnnotatedSettings.builder() | ||
.collectOnlyAnnotatedMembers() | ||
.build() | ||
) | ||
.build(), | ||
Files.newOutputStream(PATH), | ||
new JanksonValueSerializer(false) | ||
); | ||
} catch (IOException e) { | ||
ClientInitializer.LOGGER.error("Error saving Hexaplex config."); | ||
Hexaplex.LOGGER.error("Error saving Hexaplex config!"); | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
public void load() { | ||
if (Files.exists(FabricLoader.getInstance().getConfigDir().resolve("hexaplex.json"))) { | ||
if (Files.exists(PATH)) { | ||
try { | ||
FiberSerialization.deserialize( | ||
ConfigTree.builder().applyFromPojo(INSTANCE, AnnotatedSettings.builder().collectOnlyAnnotatedMembers().build()).build(), | ||
Files.newInputStream(FabricLoader.getInstance().getConfigDir().resolve("hexaplex.json")), | ||
ConfigTree.builder() | ||
.applyFromPojo( | ||
INSTANCE, | ||
AnnotatedSettings.builder() | ||
.collectOnlyAnnotatedMembers() | ||
.build() | ||
) | ||
.build(), | ||
Files.newInputStream(PATH), | ||
new JanksonValueSerializer(false) | ||
); | ||
} catch (IOException | FiberException e) { | ||
ClientInitializer.LOGGER.error("Error loading Hexaplex config."); | ||
} catch (FiberException | IOException e) { | ||
Hexaplex.LOGGER.error("Error loading Hexaplex config!"); | ||
e.printStackTrace(); | ||
} | ||
} else { | ||
ClientInitializer.LOGGER.info("Creating Hexaplex config."); | ||
Hexaplex.LOGGER.info("Creating Hexaplex config."); | ||
this.save(); | ||
} | ||
} | ||
|
||
public void setProfile(ShaderManager.Profiles profile) { | ||
public void setProfile(Profiles profile) { | ||
this.profile = profile; | ||
this.markDirty(); | ||
this.save(); | ||
} | ||
|
||
public ShaderManager.Profiles getProfile() { | ||
public Profiles getProfile() { | ||
return this.profile; | ||
} | ||
|
||
public void setStrength(double strength) { | ||
this.strength = strength; | ||
this.save(); | ||
this.markDirty(); | ||
} | ||
|
||
public double getStrength() { | ||
return this.strength; | ||
} | ||
|
||
public void setSkew(double skew) { | ||
this.skew = skew; | ||
this.markDirty(); | ||
} | ||
|
||
public double getSkew() { | ||
return this.skew; | ||
} | ||
|
||
private void markDirty() { | ||
this.dirty = true; | ||
} | ||
|
||
public void markClean() { | ||
this.dirty = false; | ||
} | ||
|
||
public boolean isDirty() { | ||
return this.dirty; | ||
} | ||
} |
77 changes: 0 additions & 77 deletions
77
src/main/java/dev/lazurite/hexaplex/graphics/ShaderManager.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.