From e7be4a8a9f15c677194f4b575c0e967de7ae2995 Mon Sep 17 00:00:00 2001 From: Gabriel Machado <97042217+GabrielBRDeveloper@users.noreply.github.com> Date: Wed, 17 Jul 2024 21:46:57 -0400 Subject: [PATCH] Full isolate texel core!! --- src/br/nullexcept/mux/app/Activity.java | 3 +- src/br/nullexcept/mux/app/Application.java | 9 +++--- src/br/nullexcept/mux/app/Context.java | 3 +- src/br/nullexcept/mux/app/CoreBoostrap.java | 3 ++ src/br/nullexcept/mux/app/Project.java | 24 +------------- .../nullexcept/mux/core/texel/TexelAPI.java | 7 ++++- .../mux/core/texel/TexelFontFactory.java | 2 +- .../mux/core/texel/TexelFontMetrics.java | 2 +- .../mux/core/texel/TexelProject.java | 31 +++++++++++++++++++ src/br/nullexcept/mux/test/Example.java | 3 +- 10 files changed, 52 insertions(+), 35 deletions(-) create mode 100644 src/br/nullexcept/mux/core/texel/TexelProject.java diff --git a/src/br/nullexcept/mux/app/Activity.java b/src/br/nullexcept/mux/app/Activity.java index 9efa757..bdeec1e 100644 --- a/src/br/nullexcept/mux/app/Activity.java +++ b/src/br/nullexcept/mux/app/Activity.java @@ -1,6 +1,5 @@ package br.nullexcept.mux.app; -import br.nullexcept.mux.core.texel.TexelAPI; import br.nullexcept.mux.res.AttributeList; import br.nullexcept.mux.view.View; import br.nullexcept.mux.view.Window; @@ -84,7 +83,7 @@ public void startActivity(Launch launch) { Activity nw = launch.make(); nw._args = launch; nw.stack = new ActivityStack(nw); - Application.boot(TexelAPI.createWindow(), nw); + Application.boot(Application.getProject().getCoreBootstrap().makeWindow(), nw); } } diff --git a/src/br/nullexcept/mux/app/Application.java b/src/br/nullexcept/mux/app/Application.java index 19dfcae..4a76b8a 100644 --- a/src/br/nullexcept/mux/app/Application.java +++ b/src/br/nullexcept/mux/app/Application.java @@ -1,6 +1,5 @@ package br.nullexcept.mux.app; -import br.nullexcept.mux.core.texel.TexelAPI; import br.nullexcept.mux.view.Window; import java.io.File; @@ -14,10 +13,12 @@ public class Application { private static final ArrayList activities = new ArrayList<>(); private static Project current; - public static void initialize(Project project){ - initialize(project, new TexelAPI()); + public static Project getProject() { + return current; } - public static void initialize(Project project, CoreBoostrap boostrap){ + + public static void initialize(Project project){ + CoreBoostrap boostrap = project.getCoreBootstrap();; Application.current = project; Looper loop = new Looper(); Looper.mainLooper = loop; diff --git a/src/br/nullexcept/mux/app/Context.java b/src/br/nullexcept/mux/app/Context.java index 96aba69..8e83daf 100644 --- a/src/br/nullexcept/mux/app/Context.java +++ b/src/br/nullexcept/mux/app/Context.java @@ -1,6 +1,5 @@ package br.nullexcept.mux.app; -import br.nullexcept.mux.core.texel.TexelAPI; import br.nullexcept.mux.lang.Parcel; import br.nullexcept.mux.res.AssetsManager; import br.nullexcept.mux.res.LayoutInflater; @@ -18,7 +17,7 @@ public class Context { public Context(){ mResource = new Resources(this); - applets.putAll(TexelAPI.obtainApplets()); + applets.putAll(Application.getProject().getCoreBootstrap().getSystemApplets()); } public File getFilesDir() { diff --git a/src/br/nullexcept/mux/app/CoreBoostrap.java b/src/br/nullexcept/mux/app/CoreBoostrap.java index 7c4f7d2..8b088c2 100644 --- a/src/br/nullexcept/mux/app/CoreBoostrap.java +++ b/src/br/nullexcept/mux/app/CoreBoostrap.java @@ -2,8 +2,11 @@ import br.nullexcept.mux.view.Window; +import java.util.Map; + public interface CoreBoostrap { void boot(); void finish(); Window makeWindow(); + Map getSystemApplets(); } diff --git a/src/br/nullexcept/mux/app/Project.java b/src/br/nullexcept/mux/app/Project.java index 69771fd..b91cbc5 100644 --- a/src/br/nullexcept/mux/app/Project.java +++ b/src/br/nullexcept/mux/app/Project.java @@ -4,27 +4,5 @@ public interface Project { String getPackage(); Launch getLaunch(); - static Project build(Launch init, String package_) { - return new SimpleProject(package_, init); - } -} - -class SimpleProject implements Project { - private final String package_; - private final Launch initial; - - SimpleProject(String package_, Launch initial) { - this.package_ = package_; - this.initial = initial; - } - - @Override - public String getPackage() { - return package_; - } - - @Override - public Launch getLaunch() { - return (Launch) initial; - } + CoreBoostrap getCoreBootstrap(); } \ No newline at end of file diff --git a/src/br/nullexcept/mux/core/texel/TexelAPI.java b/src/br/nullexcept/mux/core/texel/TexelAPI.java index 1f243cf..e2d3286 100644 --- a/src/br/nullexcept/mux/core/texel/TexelAPI.java +++ b/src/br/nullexcept/mux/core/texel/TexelAPI.java @@ -18,7 +18,7 @@ import static org.lwjgl.glfw.GLFW.*; import static org.lwjgl.glfw.GLFW.glfwSwapInterval; -public class TexelAPI implements CoreBoostrap { +class TexelAPI implements CoreBoostrap { static final HashMap applets = new HashMap<>(); private static final HashMap pointers = new HashMap<>(); @@ -96,4 +96,9 @@ public void finish() { public Window makeWindow() { return createWindow(); } + + @Override + public Map getSystemApplets() { + return TexelAPI.obtainApplets(); + } } diff --git a/src/br/nullexcept/mux/core/texel/TexelFontFactory.java b/src/br/nullexcept/mux/core/texel/TexelFontFactory.java index a58b2ae..81a7e6e 100644 --- a/src/br/nullexcept/mux/core/texel/TexelFontFactory.java +++ b/src/br/nullexcept/mux/core/texel/TexelFontFactory.java @@ -7,7 +7,7 @@ import java.io.InputStream; -public class TexelFontFactory extends TypefaceFactory { +class TexelFontFactory extends TypefaceFactory { public TexelFontFactory() { Typeface.DEFAULT = decodeTypeface(TexelFontFactory.class.getResourceAsStream("/res/fonts/Roboto/Roboto-Regular.ttf")); diff --git a/src/br/nullexcept/mux/core/texel/TexelFontMetrics.java b/src/br/nullexcept/mux/core/texel/TexelFontMetrics.java index 55e2925..a040439 100644 --- a/src/br/nullexcept/mux/core/texel/TexelFontMetrics.java +++ b/src/br/nullexcept/mux/core/texel/TexelFontMetrics.java @@ -3,7 +3,7 @@ import br.nullexcept.mux.graphics.Paint; import br.nullexcept.mux.graphics.fonts.FontMetrics; -public class TexelFontMetrics extends FontMetrics { +class TexelFontMetrics extends FontMetrics { private final Paint paint; protected TexelFontMetrics(Paint paint){ diff --git a/src/br/nullexcept/mux/core/texel/TexelProject.java b/src/br/nullexcept/mux/core/texel/TexelProject.java new file mode 100644 index 0000000..b922ce7 --- /dev/null +++ b/src/br/nullexcept/mux/core/texel/TexelProject.java @@ -0,0 +1,31 @@ +package br.nullexcept.mux.core.texel; + +import br.nullexcept.mux.app.Activity; +import br.nullexcept.mux.app.CoreBoostrap; +import br.nullexcept.mux.app.Launch; +import br.nullexcept.mux.app.Project; + +public class TexelProject implements Project { + private final String package_; + private final Launch initial; + + public TexelProject(String package_, Launch initial) { + this.package_ = package_; + this.initial = (Launch) initial; + } + + @Override + public String getPackage() { + return package_; + } + + @Override + public Launch getLaunch() { + return initial; + } + + @Override + public CoreBoostrap getCoreBootstrap() { + return new TexelAPI(); + } +} diff --git a/src/br/nullexcept/mux/test/Example.java b/src/br/nullexcept/mux/test/Example.java index ebf64ac..6fcc7cd 100644 --- a/src/br/nullexcept/mux/test/Example.java +++ b/src/br/nullexcept/mux/test/Example.java @@ -4,6 +4,7 @@ import br.nullexcept.mux.app.Application; import br.nullexcept.mux.app.Launch; import br.nullexcept.mux.app.Project; +import br.nullexcept.mux.core.texel.TexelProject; import br.nullexcept.mux.lang.Promise; import br.nullexcept.mux.utils.Log; import br.nullexcept.mux.view.View; @@ -11,7 +12,7 @@ public class Example extends Activity { private static int layer = 0; public static void main(String[] args) { - Application.initialize(Project.build(new Launch<>(Example.class), "br.nullexcept.test-master-ui")); + Application.initialize(new TexelProject("br.nullexcept.test-master-ui",new Launch<>(Example.class))); } private View animate; int x = 0;