Skip to content

Commit

Permalink
Backport ALL changes to 1.18.2
Browse files Browse the repository at this point in the history
  • Loading branch information
BloCamLimb committed Nov 9, 2023
1 parent 5f1c4c9 commit 7e161dc
Show file tree
Hide file tree
Showing 59 changed files with 4,363 additions and 4,160 deletions.
32 changes: 19 additions & 13 deletions forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ dependencies {
modCompileOnly "mezz.jei:jei-${minecraft_version}:${jei_version}:api"
modRuntimeOnly "mezz.jei:jei-${minecraft_version}:${jei_version}"

if (rootProject.file('../ModernUI').exists()) {
implementation(forgeDependencies("icyllis.modernui:ModernUI-Core"))
shadow("icyllis.modernui:ModernUI-Core") {
if (rootProject.file('../Arc3D').exists() && rootProject.file('../ModernUI').exists()) {
implementation(forgeDependencies("icyllis.arc3d:Arc3D"))
shadow("icyllis.arc3d:Arc3D") {
transitive = false
}
implementation(forgeDependencies("icyllis.modernui:ModernUI-ViewPager"))
shadow("icyllis.modernui:ModernUI-ViewPager") {
implementation(forgeDependencies("icyllis.modernui:ModernUI-Core"))
shadow("icyllis.modernui:ModernUI-Core") {
transitive = false
}
implementation(forgeDependencies("icyllis.modernui:ModernUI-Markdown"))
Expand All @@ -84,10 +84,6 @@ dependencies {
shadow("icyllis.modernui:ModernUI-Core:${core_version}") {
transitive = false
}
implementation(forgeDependencies("icyllis.modernui:ModernUI-ViewPager:${core_version}"))
shadow("icyllis.modernui:ModernUI-ViewPager:${core_version}") {
transitive = false
}
implementation(forgeDependencies("icyllis.modernui:ModernUI-Markdown:${core_version}"))
shadow("icyllis.modernui:ModernUI-Markdown:${core_version}") {
transitive = false
Expand All @@ -104,8 +100,18 @@ dependencies {

//implementation(forgeDependencies("io.reactivex.rxjava3:rxjava:${rxjava_version}"))

shadow "com.github.ben-manes.caffeine:caffeine:${caffeine_version}"
shadow "com.vladsch.flexmark:flexmark:${flexmark_version}"
include "com.github.ben-manes.caffeine:caffeine:${caffeine_version}"
include "com.vladsch.flexmark:flexmark:${flexmark_version}"
include "com.vladsch.flexmark:flexmark-util-ast:${flexmark_version}"
include "com.vladsch.flexmark:flexmark-util-builder:${flexmark_version}"
include "com.vladsch.flexmark:flexmark-util-collection:${flexmark_version}"
include "com.vladsch.flexmark:flexmark-util-data:${flexmark_version}"
include "com.vladsch.flexmark:flexmark-util-dependency:${flexmark_version}"
include "com.vladsch.flexmark:flexmark-util-format:${flexmark_version}"
include "com.vladsch.flexmark:flexmark-util-html:${flexmark_version}"
include "com.vladsch.flexmark:flexmark-util-misc:${flexmark_version}"
include "com.vladsch.flexmark:flexmark-util-sequence:${flexmark_version}"
include "com.vladsch.flexmark:flexmark-util-visitor:${flexmark_version}"

//shadow "io.reactivex.rxjava3:rxjava:${rxjava_version}"

Expand All @@ -129,7 +135,7 @@ shadowJar {
archiveClassifier.set("shadow")
configurations = [project.configurations.shadow]

dependencies {
/*dependencies {
exclude 'icu4j-59.1.jar'
exclude 'commons-logging-1.2.jar'
}
Expand All @@ -148,7 +154,7 @@ shadowJar {
exclude 'META-INF/LICENSE**'
exclude 'META-INF/NOTICE**'
exclude 'META-INF/README**'
exclude 'META-INF/maven/**'
exclude 'META-INF/maven/**'*/
}

remapJar {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class AdvancedOptionsFragment extends Fragment {

ViewGroup mContent;
TextView mUIManagerDump;
TextView mResourceCacheDump;
TextView mGPUResourceDump;
TextView mPSOStatsDump;
TextView mGPUStatsDump;

Expand Down Expand Up @@ -111,58 +111,58 @@ LinearLayout createPage(Context context) {
}

{
var button = createDebugButton(context, "Take UI Screenshot (Y)");
var button = createDebugButton(context, "Take UI screenshot (Y)");
button.setOnClickListener((__) ->
Core.executeOnRenderThread(() -> UIManager.getInstance().takeScreenshot()));
category.addView(button);
}
{
var button = createDebugButton(context, "Dump UI Manager (P)");
var button = createDebugButton(context, "Dump UI manager (P)");
button.setOnClickListener((__) ->
Core.executeOnMainThread(() -> UIManager.getInstance().dump()));
category.addView(button);
}
{
var button = createDebugButton(context, "Debug Glyph Manager (G)");
var button = createDebugButton(context, "Dump font atlases (G)");
button.setOnClickListener((__) ->
Core.executeOnMainThread(() -> GlyphManager.getInstance().debug()));
category.addView(button);
}
if (ModernUIForge.isTextEngineEnabled()) {
if (ModernUIForge.Client.isTextEngineEnabled()) {
{
var button = createDebugButton(context, "Dump BitmapFonts and EmojiAtlas (V)");
var button = createDebugButton(context, "Dump bitmap fonts (V)");
button.setOnClickListener((__) ->
Core.executeOnMainThread(() -> {
TextLayoutEngine.getInstance().dumpEmojiAtlas();
//TextLayoutEngine.getInstance().dumpEmojiAtlas();
TextLayoutEngine.getInstance().dumpBitmapFonts();
}));
category.addView(button);
}
{
var button = createDebugButton(context, "Reload TextLayoutEngine");
var button = createDebugButton(context, "Reload text layout (MC)");
button.setOnClickListener((__) ->
Core.executeOnMainThread(() -> TextLayoutEngine.getInstance().reload()));
category.addView(button);
}
{
var button = createDebugButton(context, "Reload TextLayoutEngine (Fully)");
button.setOnClickListener((__) ->
Core.executeOnMainThread(() -> TextLayoutEngine.getInstance().reloadAll()));
category.addView(button);
}
}
{
var button = createDebugButton(context, "Reload GlyphManager");
var button = createDebugButton(context, "Reload glyph manager");
button.setOnClickListener((__) ->
Core.executeOnMainThread(() -> GlyphManager.getInstance().reload()));
category.addView(button);
}
{
var button = createDebugButton(context, "Reset LayoutCache");
var button = createDebugButton(context, "Reset layout cache");
button.setOnClickListener((__) ->
Core.executeOnMainThread(LayoutCache::clear));
category.addView(button);
}
{
var button = createDebugButton(context, "Reload full text engine");
button.setOnClickListener((__) ->
ModernUIForge.Client.getInstance().reloadFontStrike());
category.addView(button);
}
{
var button = createDebugButton(context, "GC (F)");
button.setOnClickListener((__) -> System.gc());
Expand Down Expand Up @@ -201,39 +201,39 @@ LinearLayout createPage(Context context) {
var tv = new TextView(context);
tv.setTextSize(12);
tv.setPadding(dp6, dp6, dp6, dp6);
tv.setText("Rectangle Packing Algorithm: Skyline (Silhouette)");
tv.setText("Rendering pipeline: Arc 3D OpenGL");
content.addView(tv);
}

{
var tv = new TextView(context);
tv.setTextSize(12);
tv.setPadding(dp6, dp6, dp6, dp6);
mResourceCacheDump = tv;
tv.setText("Rectangle packing algorithm: Skyline (silhouette)");
content.addView(tv);
}

{
var tv = new TextView(context);
tv.setTextSize(12);
tv.setPadding(dp6, dp6, dp6, dp6);
mPSOStatsDump = tv;
mGPUResourceDump = tv;
content.addView(tv);
}

{
var tv = new TextView(context);
tv.setTextSize(12);
tv.setPadding(dp6, dp6, dp6, dp6);
mGPUStatsDump = tv;
mPSOStatsDump = tv;
content.addView(tv);
}

{
var tv = new TextView(context);
tv.setTextSize(12);
tv.setPadding(dp6, dp6, dp6, dp6);
tv.setText("Rendering Pipeline: Arc 3D OpenGL");
mGPUStatsDump = tv;
content.addView(tv);
}

Expand Down Expand Up @@ -265,31 +265,32 @@ void refreshPage() {
mUIManagerDump.post(() -> mUIManagerDump.setText(s));
});
}
if (mResourceCacheDump != null) {
if (mGPUResourceDump != null) {
Core.executeOnRenderThread(() -> {
var rc = Core.requireDirectContext().getResourceCache();
var s = String.format("Resource Bytes: %s (%s bytes)",
TextUtils.binaryCompact(rc.getResourceBytes()),
rc.getResourceBytes()) +
", " +
String.format("Budgeted Resource Bytes: %s (%s bytes)",
var s = "GPU Resource Cache:\n" +
String.format("Resource bytes: %s (%s bytes)",
TextUtils.binaryCompact(rc.getResourceBytes()),
rc.getResourceBytes()) +
"\n" +
String.format("Budgeted resource bytes: %s (%s bytes)",
TextUtils.binaryCompact(rc.getBudgetedResourceBytes()),
rc.getBudgetedResourceBytes()) +
", " +
String.format("Resource Count: %s",
"\n" +
String.format("Resource count: %s",
rc.getResourceCount()) +
", " +
String.format("Budgeted Resource Count: %s",
"\n" +
String.format("Budgeted resource count: %s",
rc.getBudgetedResourceCount()) +
", " +
String.format("Cleanable Resource Bytes: %s (%s bytes)",
TextUtils.binaryCompact(rc.getCleanableResourceBytes()),
rc.getCleanableResourceBytes()) +
", " +
String.format("Max Resource Bytes: %s (%s bytes)",
"\n" +
String.format("Free resource bytes: %s (%s bytes)",
TextUtils.binaryCompact(rc.getFreeResourceBytes()),
rc.getFreeResourceBytes()) +
"\n" +
String.format("Max resource bytes: %s (%s bytes)",
TextUtils.binaryCompact(rc.getMaxResourceBytes()),
rc.getMaxResourceBytes());
mResourceCacheDump.post(() -> mResourceCacheDump.setText(s));
mGPUResourceDump.post(() -> mGPUResourceDump.setText(s));
});
}
if (mPSOStatsDump != null) {
Expand All @@ -302,7 +303,7 @@ void refreshPage() {
}
if (mGPUStatsDump != null) {
Core.executeOnRenderThread(() -> {
var s = Core.requireDirectContext().getServer().getStats().toString();
var s = Core.requireDirectContext().getDevice().getStats().toString();
mGPUStatsDump.post(() -> mGPUStatsDump.setText(s));
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

package icyllis.modernui.mc.forge;

import icyllis.modernui.util.BinaryIO;
import icyllis.modernui.util.DataSet;
import icyllis.modernui.util.IOStreamParcel;
import io.netty.buffer.ByteBufInputStream;
import io.netty.buffer.ByteBufOutputStream;
import io.netty.handler.codec.DecoderException;
Expand All @@ -34,7 +34,6 @@
/**
* Contains {@link DataSet} and {@link CompoundTag} utilities.
*/
@SuppressWarnings("unchecked")
public final class BinaryDataUtils {

private BinaryDataUtils() {
Expand All @@ -49,9 +48,9 @@ private BinaryDataUtils() {
*/
@Nonnull
public static FriendlyByteBuf writeDataSet(@Nonnull FriendlyByteBuf buf, @Nullable DataSet source) {
try {
BinaryIO.writeDataSet(new ByteBufOutputStream(buf), source);
} catch (IOException e) {
try (var p = new IOStreamParcel(null, new ByteBufOutputStream(buf))) {
p.writeDataSet(source);
} catch (Exception e) {
throw new EncoderException(e);
}
return buf;
Expand All @@ -65,9 +64,9 @@ public static FriendlyByteBuf writeDataSet(@Nonnull FriendlyByteBuf buf, @Nullab
*/
@Nullable
public static DataSet readDataSet(@Nonnull FriendlyByteBuf buf, @Nullable ClassLoader loader) {
try {
return BinaryIO.readDataSet(new ByteBufInputStream(buf), loader);
} catch (IOException e) {
try (var p = new IOStreamParcel(new ByteBufInputStream(buf), null)) {
return p.readDataSet(loader);
} catch (Exception e) {
throw new DecoderException(e);
}
}
Expand Down
36 changes: 19 additions & 17 deletions forge/src/main/java/icyllis/modernui/mc/forge/CenterFragment2.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
package icyllis.modernui.mc.forge;

import icyllis.modernui.R;
import icyllis.modernui.TestFragment;
import icyllis.modernui.annotation.NonNull;
import icyllis.modernui.annotation.Nullable;
import icyllis.modernui.core.Context;
import icyllis.modernui.fragment.*;
import icyllis.modernui.mc.forge.ui.DividerDrawable;
import icyllis.modernui.mc.forge.ui.ThemeControl;
import icyllis.modernui.text.Typeface;
import icyllis.modernui.util.*;
Expand Down Expand Up @@ -72,7 +72,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
var base = new LinearLayout(getContext());
base.setOrientation(LinearLayout.VERTICAL);
base.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
base.setDividerDrawable(new DividerDrawable(base));
base.setDividerDrawable(ThemeControl.makeDivider(base));
base.setDividerPadding(base.dp(8));

// TITLE
Expand All @@ -98,33 +98,35 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
buttonGroup.addView(createNavButton(1001, "modernui.center.tab.dashboard"));
buttonGroup.addView(createNavButton(1002, "modernui.center.tab.preferences"));
buttonGroup.addView(createNavButton(1003, "modernui.center.tab.developerOptions"));
buttonGroup.addView(createNavButton(1005, "Dev"));

buttonGroup.check(1001);

buttonGroup.setOnCheckedChangeListener((group, checkedId) -> {
var fm = getChildFragmentManager();
FragmentTransaction ft = null;
switch (checkedId) {
case 1001 -> {
fm.beginTransaction()
.replace(id_tab_container, DashboardFragment.class, null, "dashboard")
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
.setReorderingAllowed(true)
.commit();
ft = fm.beginTransaction()
.replace(id_tab_container, DashboardFragment.class, null, "dashboard");
}
case 1002 -> {
fm.beginTransaction()
.replace(id_tab_container, PreferencesFragment.class, null, "preferences")
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
.setReorderingAllowed(true)
.commit();
ft = fm.beginTransaction()
.replace(id_tab_container, PreferencesFragment.class, null, "preferences");
}
case 1003 -> {
fm.beginTransaction()
.replace(id_tab_container, AdvancedOptionsFragment.class, null, "developerOptions")
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
.setReorderingAllowed(true)
.commit();
ft = fm.beginTransaction()
.replace(id_tab_container, AdvancedOptionsFragment.class, null, "developerOptions");
}
case 1005 -> {
ft = fm.beginTransaction()
.replace(id_tab_container, TestFragment.class, null, "dev");
}
}
if (ft != null) {
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
.setReorderingAllowed(true)
.commit();
}
});

Expand Down
Loading

0 comments on commit 7e161dc

Please sign in to comment.