Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.11-SNAPSHOT'
id 'fabric-loom' version '1.14-SNAPSHOT'
id 'maven-publish'
}

Expand All @@ -17,7 +17,8 @@ repositories {
maven { url "https://maven.shedaniel.me/" }
maven { url "https://maven.terraformersmc.com/releases/" }

maven {url "https://api.modrinth.com/maven" }
maven { url "https://api.modrinth.com/maven" }
maven { url "https://keksuccino.github.io/maven/" }
}

dependencies {
Expand All @@ -28,8 +29,8 @@ dependencies {

// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modImplementation "maven.modrinth:mcef-keksuccino:${project.mcef_version}"
modRuntimeOnly "maven.modrinth:mcef-keksuccino:${project.mcef_version}"
modImplementation "de.keksuccino:mcef-fabric:${project.mcef_version}"
modRuntimeOnly "de.keksuccino:mcef-fabric:${project.mcef_version}"
modApi("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}") {
exclude(group: "net.fabricmc.fabric-api")
}
Expand Down
25 changes: 12 additions & 13 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@
org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.21.10
yarn_mappings=1.21.10+build.2
loader_version=0.17.3
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.21.11
yarn_mappings=1.21.11+build.4
loader_version=0.18.4

# Mod Properties
mod_version = 1.3.3-Snapshot
maven_group = io.github.blobanium
archives_base_name = MCBrowser
mod_version = 1.3.3-Snapshot
maven_group = io.github.blobanium
archives_base_name = MCBrowser

# Dependencies
# check this on https://modmuss50.me/fabric.html
fabric_version=0.136.0+1.21.10

mcef_version=2.1.7-1.21.10-fabric
cloth_config_version=20.0.148
mod_menu_version=16.0.0-rc.1
# check this on https://modmuss50.me/fabric.html
fabric_version=0.141.1+1.21.11
mcef_version=2.1.9-1.21.11
cloth_config_version=21.11.153
mod_menu_version=16.0.0-rc.1
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public void initElements() {
}

public void updateWidgets() {
if (urlBox == null) return; // Screen not fully initialized yet
urlBox.setText(currentTab.getURL());
urlBox.setCursorToStart(false);
backButton.active = currentTab.canGoBack();
Expand All @@ -138,11 +139,10 @@ public void updateWidgets() {
currentTab.resize(BrowserUtil.scaleX(width, BD_OFFSET), BrowserUtil.scaleY(height, BD_OFFSET));
}

@Override
public void resize(MinecraftClient minecraft, int i, int j) {
ArrayList<TabButton> tempList = new ArrayList<>(tabButtons);
tabButtons.clear();
super.resize(minecraft, i, j);
super.resize(i, j);
resizeBrowser();
updateWidgets();
for (TabButton tabButton : tabButtons) { remove(tabButton); }
Expand Down Expand Up @@ -177,6 +177,7 @@ public void render(DrawContext context, int mouseX, int mouseY, float delta) {
}

private void renderWidgets(DrawContext context, int mouseX, int mouseY, float delta){
if (urlBox == null) return; // Screen not fully initialized yet
urlBox.renderWidget(context, mouseX, mouseY, delta);
for (PressableWidget button : navigationButtons) button.render(context, mouseX, mouseY, delta);
if (SpecialButtonHelper.isOnCompatableSite(TabManager.getCurrentUrl())) specialButton.render(context, mouseX, mouseY, delta);
Expand Down Expand Up @@ -247,7 +248,7 @@ public boolean keyReleased(KeyInput input) {
}

private void sendKeyActivityAndSetFocus(int keyCode, int scanCode, int modifiers, boolean isPress){
if (isPress ? !urlBox.isFocused() : !(client != null && client.isCtrlPressed()) || keyCode != GLFW.GLFW_KEY_TAB) BrowserUtil.runAsyncIfEnabled(() -> currentTab.sendKeyPressRelease(keyCode, scanCode, modifiers, isPress));
if (isPress ? !urlBox.isFocused() : !(client != null && client.isCtrlPressed()) || keyCode != GLFW.GLFW_KEY_LEFT_CONTROL) BrowserUtil.runAsyncIfEnabled(() -> currentTab.sendKeyPressRelease(keyCode, scanCode, modifiers, isPress));
setFocus();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public boolean isLoading() {
}

public void render(DrawContext context, int x, int y, int width, int height) {
Identifier textureLocation = getTextureLocation();
Identifier textureLocation = this.getTextureIdentifier();

if (isTextureReady()) {
context.drawTexture(RenderPipelines.GUI_TEXTURED, textureLocation, x, y, 0F, 0F, width, height, width, height, ColorHelper.getWhite(1F));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ protected void appendClickableNarrations(NarrationMessageBuilder builder) {
//Required for Implementation
}

@Override
protected void drawIcon(net.minecraft.client.gui.DrawContext context, int x, int y, float delta) {
// Draw the default button with the "+" text
}

@Override
public boolean mouseClicked(Click click, boolean doubled) {
if (this.isSelected()){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class ReloadButton extends PressableWidget {
);

public ReloadButton(int x, int y, int width, int height) {
super(x, y, height, width, null);
super(x, y, height, width, Text.empty());
}

@Override
Expand All @@ -33,20 +33,13 @@ protected void appendClickableNarrations(NarrationMessageBuilder builder) {
//Required for Implementation
}

/**
* Renders the widget on the screen.
*
* @param context the draw context
* @param mouseX the X coordinate of the mouse
* @param mouseY the Y coordinate of the mouse
* @param delta the time in ticks between the previous and current render
*/
@Override
protected void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) {
protected void drawIcon(DrawContext context, int x, int y, float delta) {
Identifier texture = TEXTURES.get(this.isInteractable(), this.isFocused());
MinecraftClient minecraftClient = MinecraftClient.getInstance();
context.drawGuiTexture(RenderPipelines.GUI_TEXTURED, texture, this.getX(), this.getY(), this.getWidth(), this.getHeight());
drawScrollableText(context, minecraftClient.textRenderer, Text.of(TabManager.getCurrentTab().isLoading() ? "❌" : "⟳"), this.getX() + 2, this.getY(), this.getX() + this.getWidth() - 2, this.getY() + this.getHeight(), 16777215 | MathHelper.ceil(this.alpha * 255.0F) << 24);
int color = 16777215 | MathHelper.ceil(this.alpha * 255.0F) << 24;
context.drawCenteredTextWithShadow(minecraftClient.textRenderer, Text.of(TabManager.getCurrentTab().isLoading() ? "❌" : "⟳"), this.getX() + this.getWidth() / 2, this.getY() + (this.getHeight() - 8) / 2, color);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class TabButton extends PressableWidget {
final int startX;

public TabButton(int startX, int y, int width, int height, int tab) {
super(0, y, width, height, null);
super(0, y, width, height, Text.empty());
this.startX = startX;
this.tab = tab;
}
Expand All @@ -57,19 +57,21 @@ protected void appendClickableNarrations(NarrationMessageBuilder builder) {
//Required For Implementation
}

private final boolean selected = TabManager.activeTab == tab;
private final boolean tooSmall = this.getWidth() < this.getHeight() * 3;

@Override
public void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) {
protected void drawIcon(DrawContext context, int x, int y, float delta) {
boolean selected = TabManager.activeTab == tab;
boolean tooSmall = this.getWidth() < this.getHeight() * 3;
Identifier texture = TEXTURES.get(this.isInteractable(), this.isFocused());

if (this.getX() > BrowserUtil.instance.width - BrowserScreen.BD_OFFSET - 35) { return; }
if (this.getWidth() > this.getHeight()) { context.drawGuiTexture(RenderPipelines.GUI_TEXTURED, texture, this.getX(), this.getY(), this.getWidth(), this.getHeight()); }
String name = TabManager.tabs.get(tab).getTitle();
if (name == null || name.isEmpty()) { name = "Loading..."; }
TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
drawScrollableText(context, textRenderer, Text.of(name), this.getX() + 2 + 15, this.getY(), this.getX() + this.getWidth() - (!tooSmall || selected ? 17 : 2), this.getY() + this.getHeight(), 16777215 | MathHelper.ceil(this.alpha * 255.0F) << 24);
int color = 16777215 | MathHelper.ceil(this.alpha * 255.0F) << 24;
int textWidth = this.getX() + this.getWidth() - (!tooSmall || selected ? 17 : 2) - (this.getX() + 2 + 15);
String displayName = textRenderer.trimToWidth(name, textWidth);
context.drawText(textRenderer, displayName, this.getX() + 2 + 15, this.getY() + (this.getHeight() - 8) / 2, color, true);

context.fill(this.getX(), this.getY(), this.getX() + this.getHeight(), this.getY() + this.getHeight(), 0x00FFFFFF);
renderIco(context);
Expand Down Expand Up @@ -158,6 +160,9 @@ public boolean mouseClicked(Click click, boolean doubled) {
return true;
}

boolean selected = TabManager.activeTab == tab;
boolean tooSmall = this.getWidth() < this.getHeight() * 3;

if (tooSmall && !selected) {
open();
return true;
Expand Down
23 changes: 7 additions & 16 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,18 @@
"icon": "assets/mcbrowser/icon.png",
"environment": "client",
"entrypoints": {
"client": [
"io.github.blobanium.mcbrowser.MCBrowser"
],
"modmenu": [
"io.github.blobanium.mcbrowser.config.ModMenuIntegration"
]
"client": ["io.github.blobanium.mcbrowser.MCBrowser"],
"modmenu": ["io.github.blobanium.mcbrowser.config.ModMenuIntegration"]
},
"mixins": [
"mcbrowser.mixins.json"
],
"mixins": ["mcbrowser.mixins.json"],
"suggests": {
"modmenu":"*"
},
"recommends": {
"mcef": ">=2.1.6-1.21.10"
"modmenu": "*"
},
"depends": {
"fabricloader": ">=${loader_version}",
"minecraft": "1.21.10",
"mcef": ">=2.1.6-1.21.10",
"cloth-config": "20.*.*",
"minecraft": "${minecraft_version}",
"mcef": ">=2.1.9-1.21.11",
"cloth-config": "21.11.*",
"fabric": "*"
},
"conflicts": {
Expand Down