-
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
9 changed files
with
191 additions
and
42 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
31 changes: 23 additions & 8 deletions
31
test-mod/src/main/java/com/neptuneclient/voidui/testmod/ModEntry.java
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,29 +1,44 @@ | ||
package com.neptuneclient.voidui.testmod; | ||
|
||
import com.neptuneclient.voidui.VoidUI; | ||
import com.neptuneclient.voidui.testmod.example.TestScreen; | ||
import com.neptuneclient.voidui.testmod.example.TestTheme; | ||
import com.neptuneclient.voidui.testmod.impl.RendererImpl; | ||
import com.neptuneclient.voidui.utils.Font; | ||
import com.neptuneclient.voidui.testmod.impl.ScreenBridge; | ||
import net.fabricmc.api.ClientModInitializer; | ||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents; | ||
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; | ||
import net.minecraft.client.MinecraftClient; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.nio.file.Path; | ||
import static net.minecraft.server.command.CommandManager.literal; | ||
|
||
public class ModEntry implements ClientModInitializer { | ||
|
||
public static final Logger LOGGER = LoggerFactory.getLogger("TestMod"); | ||
|
||
public static VoidUI voidUI; | ||
|
||
@Override | ||
public void onInitializeClient() { | ||
LOGGER.info("VoidUI is best!"); | ||
|
||
ClientLifecycleEvents.CLIENT_STARTED.register((client) -> { | ||
VoidUI vui = new VoidUI(new RendererImpl()); | ||
ClientLifecycleEvents.CLIENT_STARTED.register((mc) -> { | ||
voidUI = new VoidUI(new RendererImpl(), new TestTheme()); | ||
}); | ||
|
||
// testing if nanovg will handle the font buffer | ||
new Font(vui, "testFont", Path.of("fonts/WorkSans-Regular.ttf"), 28); | ||
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> { | ||
dispatcher.register(literal("examplemod").executes(context -> { | ||
try { | ||
MinecraftClient.getInstance().submit(() -> { | ||
MinecraftClient.getInstance().setScreen(new ScreenBridge(new TestScreen())); | ||
}); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
return 1; | ||
})); | ||
}); | ||
LOGGER.info("VoidUI is best!"); | ||
} | ||
|
||
} |
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
26 changes: 26 additions & 0 deletions
26
test-mod/src/main/java/com/neptuneclient/voidui/testmod/impl/ScreenBridge.java
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,26 @@ | ||
package com.neptuneclient.voidui.testmod.impl; | ||
|
||
import net.minecraft.client.gui.DrawContext; | ||
import net.minecraft.client.gui.screen.Screen; | ||
import net.minecraft.text.Text; | ||
|
||
public class ScreenBridge extends Screen { | ||
|
||
private com.neptuneclient.voidui.widgets.Screen voidScreen; | ||
|
||
public ScreenBridge(com.neptuneclient.voidui.widgets.Screen voidScreen) { | ||
super(Text.of(voidScreen.getClass().getSimpleName())); | ||
this.voidScreen = voidScreen; | ||
} | ||
|
||
@Override | ||
protected void init() { | ||
voidScreen.init(); | ||
} | ||
|
||
@Override | ||
public void render(DrawContext context, int mouseX, int mouseY, float delta) { | ||
voidScreen.render(); | ||
} | ||
|
||
} |
29 changes: 0 additions & 29 deletions
29
test-mod/src/main/java/com/neptuneclient/voidui/testmod/mixins/MixinInGameHud.java
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
test-mod/src/main/kotlin/com/neptuneclient/voidui/testmod/example/TestScreen.kt
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,24 @@ | ||
package com.neptuneclient.voidui.testmod.example | ||
|
||
import com.neptuneclient.voidui.testmod.ModEntry | ||
import com.neptuneclient.voidui.widgets.* | ||
import com.neptuneclient.voidui.widgets.objects.EdgeInsets | ||
|
||
class TestScreen : Screen(ModEntry.voidUI) { | ||
|
||
override fun build(): Widget { | ||
return BackgroundPanel( | ||
child = Padding( | ||
padding = EdgeInsets.all(20F), | ||
child = Column( | ||
gap = 10, | ||
children = arrayOf( | ||
Text("Hello World"), | ||
Text("Heh") | ||
) | ||
) | ||
) | ||
) | ||
} | ||
|
||
} |
52 changes: 52 additions & 0 deletions
52
test-mod/src/main/kotlin/com/neptuneclient/voidui/testmod/example/TestTheme.kt
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,52 @@ | ||
package com.neptuneclient.voidui.testmod.example | ||
|
||
import com.neptuneclient.voidui.themes.Styles | ||
import com.neptuneclient.voidui.themes.Theme | ||
import com.neptuneclient.voidui.themes.objects.Border | ||
import com.neptuneclient.voidui.themes.styles.PanelStyleSheet | ||
import com.neptuneclient.voidui.themes.styles.TextStyleSheet | ||
import com.neptuneclient.voidui.widgets.objects.EdgeInsets | ||
import java.awt.Color | ||
import java.nio.file.Path | ||
|
||
class TestTheme : Theme( | ||
backgroundPanel = Styles( | ||
normal = PanelStyleSheet( | ||
color = Color(0x101216), | ||
radius = 10 | ||
) | ||
), | ||
accentBackgroundPanel = Styles( | ||
normal = PanelStyleSheet( | ||
color = Color(26, 31, 41, 220), | ||
radius = 10 | ||
) | ||
), | ||
panel = Styles( | ||
normal = PanelStyleSheet( | ||
color = Color(0x272935), | ||
radius = 10, | ||
border = Border( | ||
sides = EdgeInsets.all(1f), | ||
color = Color(255, 255, 255, 40) | ||
) | ||
) | ||
), | ||
accentPanel = Styles( | ||
normal = PanelStyleSheet( | ||
color = Color(0), | ||
radius = 10, | ||
border = Border( | ||
sides = EdgeInsets.all(1f), | ||
color = Color(255, 255, 255, 40) | ||
) | ||
) | ||
), | ||
text = Styles( | ||
normal = TextStyleSheet( | ||
color = Color.WHITE, | ||
font = Path.of("fonts/WorkSans-Regular.ttf"), | ||
size = 16 | ||
) | ||
) | ||
) |
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 |
---|---|---|
|
@@ -7,6 +7,5 @@ | |
"defaultRequire": 1 | ||
}, | ||
"client": [ | ||
"MixinInGameHud" | ||
] | ||
} |