Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
666 commits
Select commit Hold shift + click to select a range
e2ab7f9
auto kill
JXSnack Jul 24, 2025
21344f7
use unwindOnFinish
JXSnack Jul 24, 2025
1613d5d
give autoUnwindAtEnd for monotone end
JXSnack Jul 24, 2025
feef5d9
add autoUnwindAtEnd setting for animations
JXSnack Jul 24, 2025
c1ac46d
cut back on loop modes
JXSnack Jul 27, 2025
4a2dc08
call animation begin event
JXSnack Aug 18, 2025
3db4292
test looping
JXSnack Aug 18, 2025
6d02481
fix ConcurrentModificationException
JXSnack Aug 18, 2025
cc2e307
kill ifn't looping
JXSnack Aug 18, 2025
98c8603
call animation finish event
JXSnack Aug 18, 2025
67b2146
move widgets to new system
JXSnack Aug 19, 2025
5c371f1
fix hover state being handled incorrectly
JXSnack Aug 19, 2025
50d05d3
fix hover state being handled incorrectly
JXSnack Aug 19, 2025
d832920
add QOL firstOf method
JXSnack Aug 19, 2025
9596eb0
add event postprocessor and therefore rename PreProcessorContext -> P…
JXSnack Aug 19, 2025
320ac21
increase keyframe time for testing
JXSnack Aug 19, 2025
09d4fec
attempt to make a hover style with transition
JXSnack Aug 19, 2025
be3cba9
implement event postprocessor as afterBuiltinEvent
JXSnack Aug 19, 2025
8cc3eb5
fire finish event
JXSnack Aug 19, 2025
55cb958
fire finish event
JXSnack Aug 19, 2025
595c52c
add all() to ColorModifier
JXSnack Aug 20, 2025
b354a4c
remove debug "updated" println
JXSnack Aug 20, 2025
cd99f95
very basic alignment
JXSnack Aug 20, 2025
9329103
height is now height and not max height
JXSnack Aug 20, 2025
e295ec1
do applyAlignment when posOf (should probably get cached though)
JXSnack Aug 20, 2025
37f4a95
add VLayoutAlignmentFlag
JXSnack Aug 20, 2025
900546f
calculate alignment for vertical
JXSnack Aug 20, 2025
44ac414
calculate horizontal alignment
JXSnack Aug 20, 2025
8025b8b
fix getting width
JXSnack Aug 20, 2025
175a7c7
parallelStream -> stream for less overhead
JXSnack Aug 20, 2025
1377f99
add the ability to keep the final style
JXSnack Aug 20, 2025
3d206da
add keepFinalStyle on hoverAnimation
JXSnack Aug 20, 2025
87467c7
new testing
JXSnack Aug 20, 2025
cde45eb
add effective transform
JXSnack Aug 20, 2025
6b2be3c
label padding is 0 by default now
JXSnack Aug 20, 2025
90f8415
use effective height & width
JXSnack Aug 20, 2025
751e752
render overlay
JXSnack Aug 20, 2025
3233d1a
rework label rendering
JXSnack Aug 20, 2025
7c74f39
note new discoveries
JXSnack Aug 20, 2025
a6bff54
fix center alignment halving original position
JXSnack Aug 25, 2025
efc1be6
Deprecate alsoAdd() and automatically add to add on object initializa…
JXSnack Aug 26, 2025
a4aabab
remove .alsoAdd from shortcuts
JXSnack Aug 26, 2025
e67e782
remove debug enable shortcut
JXSnack Aug 26, 2025
7aa3870
fully remove debug mode
JXSnack Aug 26, 2025
1217ded
empty layout alignment test app
JXSnack Aug 26, 2025
a03810d
fix mixin
JXSnack Sep 25, 2025
d47aa41
add featureset
JXSnack Sep 25, 2025
6dd49d4
fix animation unwinding random keyframe halt
JXSnack Oct 11, 2025
492d4d7
add INTERNAL_TRANSITION_ANIMATION_NAME
JXSnack Oct 23, 2025
bba50ce
add more to roadmap
JXSnack Oct 24, 2025
320739d
animation toString
JXSnack Oct 25, 2025
d747dbc
rename methods same -> isSame and sameColors -> hasSameColors for cla…
JXSnack Oct 25, 2025
f0fba4b
get keys methods
JXSnack Oct 25, 2025
45567a5
get keys methods
JXSnack Oct 25, 2025
8abfc4c
get keys method
JXSnack Oct 25, 2025
3aefa46
transition animation
JXSnack Oct 25, 2025
6f4e770
test transition animation
JXSnack Oct 25, 2025
53b42dd
make easings identifiable by name
JXSnack Oct 25, 2025
2c7aa71
register all easings in the registrar
JXSnack Oct 25, 2025
21458af
add caution message
JXSnack Oct 25, 2025
421998e
add easing SVT
JXSnack Oct 25, 2025
3f529af
add easing standard styles
JXSnack Oct 25, 2025
d33aa65
use transition style to test
JXSnack Oct 25, 2025
a929a91
add inherits metho
JXSnack Oct 25, 2025
a7fd747
better docstring
JXSnack Oct 25, 2025
dbbec95
mark codeblock
JXSnack Oct 25, 2025
f0c3128
prevStyleState -> handledPrevStyleState
JXSnack Oct 25, 2025
03b35a7
add after and before render
JXSnack Feb 2, 2026
aa5fddc
call before and after
JXSnack Feb 2, 2026
5970742
add demo thing
JXSnack Feb 2, 2026
88a62b0
final before total rewrite of animation system
JXSnack Feb 2, 2026
e15655b
begin animation engine
JXSnack Feb 13, 2026
e03aeb6
make rect follow initial background color
JXSnack Feb 13, 2026
1ec294f
Easings -> VEasings
JXSnack Feb 15, 2026
45bfb00
Events -> VEvents
JXSnack Feb 15, 2026
d519f82
Easings -> VEasings
JXSnack Feb 15, 2026
1b3e3b9
Once -> VOnce
JXSnack Feb 15, 2026
316c5b4
Geometry -> VGeometry
JXSnack Feb 15, 2026
770858c
Easings -> VEasings
JXSnack Feb 15, 2026
3a81c29
add StyleValue container to hold StyleValueType and an Object
JXSnack Feb 15, 2026
d95f798
new basic animation test
JXSnack Feb 15, 2026
d326e00
very basic animation system
JXSnack Feb 15, 2026
9500182
mark getKey methods as nullable
JXSnack Feb 15, 2026
7e29f35
add IMMEDIATE easing
JXSnack Feb 15, 2026
19f7635
immediate 0 0 keyframe
JXSnack Feb 15, 2026
718fd9f
filling -> populating
JXSnack Feb 15, 2026
0db1283
add unwindTime and unwindEasing
JXSnack Feb 15, 2026
3e68bac
implement per-widget animation engine
JXSnack Feb 22, 2026
a7f0bbe
fix NPE
JXSnack Feb 22, 2026
3bd2d17
make animation names case insensitive
JXSnack Feb 22, 2026
98e9ee6
add longer test animation
JXSnack Feb 22, 2026
5e3c2a6
very basic playback context
JXSnack Feb 22, 2026
65445f0
add getKeyframeIndexAtTime
JXSnack Feb 22, 2026
9969c88
change stay -> transition logic to transition -> stay
JXSnack Feb 22, 2026
f02df6c
remove redundant code
JXSnack Feb 22, 2026
76639b4
fix delta
JXSnack Feb 22, 2026
2671166
skip immediate keyframes
JXSnack Feb 22, 2026
e2848a9
calculate delta!
JXSnack Feb 22, 2026
ff00daa
fix fast single-frame flashes
JXSnack Feb 22, 2026
46a6688
work via entries
JXSnack Feb 22, 2026
e256f7a
mark TODO for loop modes
JXSnack Feb 22, 2026
6a712ed
limit getProgress() to 1.0f
JXSnack Feb 22, 2026
bbe20f7
add copyable way for keyframes with mutable transition and stay time
JXSnack Feb 22, 2026
a05d842
add getCurrentLoopNumber
JXSnack Feb 22, 2026
880247d
handle lifetimes
JXSnack Feb 22, 2026
bf29be5
implement loop modes
JXSnack Feb 22, 2026
067610b
implement winding functionality
JXSnack Feb 22, 2026
b785412
manage winding lifetimes
JXSnack Feb 22, 2026
d43ddbb
dont double unwind/rewind
JXSnack Feb 22, 2026
01c1766
fix stopping unwind
JXSnack Feb 22, 2026
0801fc8
fix stopping unwind
JXSnack Feb 22, 2026
0f3e427
remove winding todo
JXSnack Feb 22, 2026
f088073
Merge remote-tracking branch 'origin/v1.10' into v1.10
JXSnack Feb 22, 2026
ab71b38
add QOL animation methods to VWidget
JXSnack Feb 22, 2026
4b59874
reset winding
JXSnack Feb 22, 2026
ac3e32d
add relative unwinding
JXSnack Feb 22, 2026
f60ad55
add option for unwinding at end
JXSnack Feb 22, 2026
1b90415
add rewind method
JXSnack Feb 22, 2026
a404e27
call unwind begin event
JXSnack Feb 22, 2026
7e85660
call animation begin & finish events
JXSnack Feb 22, 2026
66ed6c7
add QOL isActive & getActive methods
JXSnack Feb 22, 2026
f8a366a
use entry value as winding value instead of stylesheet
JXSnack Feb 22, 2026
05d1028
dont stop animation while winding
JXSnack Feb 22, 2026
ac9cfd8
add animation transition name variable
JXSnack Feb 22, 2026
03fe990
add more animation QOL methods
JXSnack Feb 22, 2026
e8488cc
handle transitions
JXSnack Feb 22, 2026
be4906e
fix concurrency crash with multiple animations at once
JXSnack Feb 22, 2026
0d6e2df
test transitions
JXSnack Feb 22, 2026
367e9f3
clean up
JXSnack Feb 23, 2026
8b31c59
remove V prefix from easing classes as they are not meant to be inter…
JXSnack Feb 23, 2026
ac5c00e
generalise int apply method
JXSnack Feb 23, 2026
78045be
add getDefault method for easings
JXSnack Feb 23, 2026
98b2fe5
add sine easings
JXSnack Feb 23, 2026
bc9bab0
put all sine easings into one class instead of spreading them out
JXSnack Feb 23, 2026
764f4fd
remove extra easings, something is weird
JXSnack Feb 23, 2026
f88ebc7
add only xy constructor
JXSnack Feb 23, 2026
a9e2f6a
Resolve #2
JXSnack Feb 23, 2026
2d7055c
fix stack overflow error due to
JXSnack Feb 23, 2026
a56329a
add class tests
JXSnack Feb 23, 2026
07d0571
move test rect to fit the label
JXSnack Feb 23, 2026
5823515
fix point not working for moved apps
JXSnack Feb 23, 2026
af9a7e0
fi hierarchy doubles
JXSnack Feb 23, 2026
54e5777
add wanring message
JXSnack Feb 23, 2026
f33e1d6
add scheduling tasks to next frame
JXSnack Feb 23, 2026
e22ecaa
add hierarchy tests
JXSnack Feb 23, 2026
f89f331
add move thing for hierarchic app
JXSnack Feb 23, 2026
77e9c10
add visual indicator for hierarchy
JXSnack Feb 23, 2026
5d7196a
fix render order for hierarchic apps
JXSnack Feb 23, 2026
d84a942
fix hierarchy app selection
JXSnack Feb 23, 2026
5989403
add more QOL constructors to VRect
JXSnack Feb 23, 2026
5ed0f6b
add exit shortcut to hierarchy test
JXSnack Feb 23, 2026
b078dd0
fix hierarchic apps not respecting app visibility
JXSnack Feb 24, 2026
4a7d37a
better looking test
JXSnack Feb 24, 2026
0ac2178
turn hierarchy system into flag system
JXSnack Feb 24, 2026
b95ef73
move most mouse requirement tracking to window flag system
JXSnack Feb 24, 2026
273a0fd
VWindowFlag -> VAppFlag
JXSnack Feb 24, 2026
d3a0e17
VWindowPositioningFlag -> VAppPositioningFlag
JXSnack Feb 24, 2026
7654ec8
better naming for methods
JXSnack Feb 24, 2026
8b024fe
toInt -> toIntArgb
JXSnack Feb 24, 2026
9cd4c0a
add accessor
JXSnack Feb 24, 2026
ad86054
add quad rendering api
JXSnack Feb 24, 2026
545bdaa
add quad rendering test
JXSnack Feb 24, 2026
316d4be
1.9.2 -> 2.0.0
JXSnack Feb 24, 2026
c064f6f
update all 1.10 things to 2.0
JXSnack Feb 24, 2026
1e00099
prepare rendering 2.0
JXSnack Feb 24, 2026
59fbb21
add scale tests
JXSnack Feb 24, 2026
ff76edb
add transparency changing + event
JXSnack Feb 24, 2026
4292bbb
proper ctx receival
JXSnack Feb 24, 2026
6021ec3
migrate to new rendering system
JXSnack Feb 24, 2026
7e0a0d0
reserve scale thing
JXSnack Feb 24, 2026
b7cfc1f
add compat for int casting to float
JXSnack Feb 24, 2026
4f95573
undo compat for int casting to float
JXSnack Feb 24, 2026
03617f9
write test for rotation
JXSnack Feb 24, 2026
d2f479e
add rotation style
JXSnack Feb 24, 2026
4361c81
add rotation rendering
JXSnack Feb 24, 2026
4525a91
fix rendering
JXSnack Feb 24, 2026
e61f01c
test rotation
JXSnack Feb 24, 2026
a7a711d
better looking scaling
JXSnack Feb 24, 2026
cc63e6a
StyleState -> VStyleState
JXSnack Feb 25, 2026
b3571ef
render rect via quads
JXSnack Feb 25, 2026
338b198
render image via quads
JXSnack Feb 25, 2026
2dd5e4c
move VRenderContext to separate file and implement clip scissors
JXSnack Feb 25, 2026
ea209d9
ensure clips are empty
JXSnack Feb 25, 2026
382d6bb
proper scissoring
JXSnack Feb 25, 2026
e91adfd
remove weird respectAnimationLocks from VStyleState
JXSnack Feb 25, 2026
c7444a9
mark effective X and Y as deprecated as a note for self
JXSnack Feb 25, 2026
3b834c9
use proper effective methods
JXSnack Feb 25, 2026
45608e2
partly redo rendering
JXSnack Feb 25, 2026
1936e27
use effective width
JXSnack Feb 25, 2026
d2739cc
increase maxChars significantly
JXSnack Feb 25, 2026
8bcb84c
smaller
JXSnack Feb 25, 2026
c441c85
remove old render code
JXSnack Feb 25, 2026
9b52efd
text character selection
JXSnack Feb 25, 2026
648c4ad
replace manual cursorPos assignment with setCursorPos method invocations
JXSnack Feb 25, 2026
fb6cebd
remove change events
JXSnack Feb 25, 2026
544eed8
remove all usages of effectiveX and effectiveY
JXSnack Feb 25, 2026
b3bc2b0
move cursor getting to new getCursorPosAtX method
JXSnack Feb 25, 2026
2bb869c
ensure cursor is visible when changing its position
JXSnack Feb 25, 2026
6684127
stop using getEffectiveX
JXSnack Feb 25, 2026
6d5a097
add methods to get the relative mouse position
JXSnack Feb 25, 2026
75b526b
render text up until the end of the widget
JXSnack Feb 25, 2026
3136829
[Render Rework] Redo full rendering and implement proper text viewpor…
JXSnack Feb 25, 2026
e8f2854
resolve TODO: background won't be rendered if the bg color is transpa…
JXSnack Feb 25, 2026
6e19dd0
move VRenderContext from util to core
JXSnack Feb 25, 2026
8281508
add VFill to prepare for merge of colors and images
JXSnack Feb 25, 2026
a7d2b84
implement color and image fill
JXSnack Feb 25, 2026
0ed5f82
tests for fills
JXSnack Feb 25, 2026
ac72bd0
render fills, of course!
JXSnack Feb 25, 2026
33388a6
rect now supports fill
JXSnack Feb 25, 2026
8c63f96
retire VImage
JXSnack Feb 25, 2026
81274c0
retire VImage
JXSnack Feb 25, 2026
5048731
Merge remote-tracking branch 'origin/v1.10' into v2.0
JXSnack Feb 25, 2026
2a2437b
Merge remote-tracking branch 'origin/v1.10' into v2.0
JXSnack Feb 25, 2026
634c217
Merge remote-tracking branch 'origin/v1.10' into v2.0
JXSnack Feb 25, 2026
6ad1ed3
use VFill instead of VColor in VLineInput
JXSnack Feb 25, 2026
75aeadd
add & implement isVisible
JXSnack Feb 25, 2026
720acf6
fix isVisible
JXSnack Feb 25, 2026
a5a3bc7
label background color is now fill
JXSnack Feb 25, 2026
2942761
retire isTransparent in favour of isVisible
JXSnack Feb 25, 2026
b9d5e90
use background instead of background-color for labels
JXSnack Feb 25, 2026
6b5eb2d
fix NPE due to background-color style key
JXSnack Feb 25, 2026
52d0b3f
im dumb
JXSnack Feb 25, 2026
f712376
use fill instead of image
JXSnack Feb 25, 2026
376ed16
fix hover state for VRect
JXSnack Feb 25, 2026
f78dcc9
fix only first pixel of texture being rendered
JXSnack Feb 25, 2026
e9520da
ease rendering
JXSnack Feb 25, 2026
a502fb5
fix sizing
JXSnack Feb 25, 2026
129b40a
render via quad renderer so we can render the tint
JXSnack Feb 25, 2026
f001cdd
move ensureClearContext method up
JXSnack Feb 27, 2026
5d99922
rename render method to renderContent
JXSnack Feb 27, 2026
c619108
make ensureClearContext public
JXSnack Feb 27, 2026
1efa602
move widget rendering logic into the widget itself
JXSnack Feb 27, 2026
8f9785a
add VWidgetContainer interface
JXSnack Feb 27, 2026
e6ca47f
add getRawX and getRawY methods
JXSnack Feb 27, 2026
b88d052
undo VWidgetContainer
JXSnack Feb 27, 2026
a58eea8
add VAppAccess
JXSnack Feb 27, 2026
e6754a8
add add/get/remove methods to VAppAccess
JXSnack Feb 27, 2026
39c2030
add error message
JXSnack Feb 27, 2026
b04e83c
use appAccess to do adding/removing now
JXSnack Feb 27, 2026
4ff579f
add compound widgets
JXSnack Feb 27, 2026
9453b3e
layouts now use VAppAccess instead of VeraApp
JXSnack Feb 27, 2026
39eb5ad
add no limit layout
JXSnack Feb 27, 2026
a66da90
set layout size
JXSnack Feb 27, 2026
73267d0
give compound custom id
JXSnack Feb 27, 2026
106c123
add gradle wrapper
JXSnack Feb 28, 2026
480c09f
make getRawX and getRawY final so u cant override them
JXSnack Feb 28, 2026
daf8bc1
move/size via builtin methods instead of manual layout moving/sizing
JXSnack Feb 28, 2026
ea24d4a
fix items having double offset
JXSnack Feb 28, 2026
0994596
set transparency outside of constructor
JXSnack Feb 28, 2026
b8d633e
VTransparencyStateChangedEvent -> remove d to stay consistent with focus
JXSnack Feb 28, 2026
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
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Vera
Because UI should be simple.

Vera is a simple yet powerful Fabric UI library. There are currently no plans for a Forge version.\
[Submit a Logo](https://github.com/snackbag/vera/issues/new) [Visit Wiki](https://wiki.snackbag.net/w/vera)

## Features

- Various standard widgets
- Labels
- Checkboxes
- Dropdowns
- Images
- Text input
- Tabs
- Rectangles
- Easy creation of custom widgets
- Styling system written from the ground up
- Customizable animation system
- Style-composite rendering pipeline
- (Custom) easings!
- Layout system
- HUD-rendering
- 2D rendering developer QOL
- App hierarchy
- Simple keybindings
- Heavy optimization
- (Developer) QOL with [Verto](https://github.com/snackbag/verto)
- Extensive documentation

### Coming soon

- Full docstrings everywhere
- More standard composites
- Multi-versions
- More precise font options
- Vertex & fragment shaders
- Revised rendering API
- Double buffer rendering
- Vanilla-UI abilities
- Widget Compounds
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ yarn_mappings=1.20.1+build.10
loader_version=0.16.7

# Mod Properties
mod_version=1.9.2
mod_version=2.0.0
maven_group=net.snackbag.mcvera
archives_base_name=mcvera

Expand Down
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
5 changes: 2 additions & 3 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 64 additions & 0 deletions src/main/java/com/example/demo/DemoApplication.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package com.example.demo;

import net.snackbag.vera.Vera;
import net.snackbag.vera.core.VColor;
import net.snackbag.vera.core.VCursorShape;
import net.snackbag.vera.core.VeraApp;
import net.snackbag.vera.event.VShortcut;
import net.snackbag.vera.flag.VLayoutAlignmentFlag;
import net.snackbag.vera.layout.VHLayout;
import net.snackbag.vera.layout.VVLayout;
import net.snackbag.vera.style.VStyleState;
import net.snackbag.vera.widget.VLabel;

public class DemoApplication extends VeraApp {
private int clicks = 0;
private VHLayout layout;
private VVLayout centerLayout;

@Override
public void init() {
new VShortcut(this, "escape", this::hide);
setBackgroundColor(VColor.black().withOpacity(0.2f));

layout = new VHLayout(this, 0, 0);
layout.alignment = VLayoutAlignmentFlag.CENTER;

centerLayout = new VVLayout(layout);
centerLayout.alignment = VLayoutAlignmentFlag.CENTER;

VLabel label = new VLabel("Not clicked yet", this).alsoAddTo(centerLayout);
label.modifyFontColor().rgb(VColor.white());

VLabel button = new VLabel("Click me", this).alsoAddTo(centerLayout);

button.modifyFontColor().rgb(VColor.of(95, 180, 0));
button.setStyle("background-color", VColor.white());
button.setStyle("padding", 4);
button.setStyle("overlay", VStyleState.HOVERED, VColor.white().withOpacity(0.5f));
button.setStyle("border-size", 1);
button.setStyle("border-color", VColor.of(95, 180, 0));
button.setStyle("cursor", VCursorShape.POINTING_HAND);

button.onLeftClick(() -> {
clicks++;
label.setText("Clicks: " + clicks);
label.adjustSize();
});

new VShortcut(this, "leftctrl+d", () -> {
System.out.println("Debug hit");
});
}

@Override
public void update() {
super.update();

setWidth(Vera.provider.getScreenWidth());
setHeight(Vera.provider.getScreenHeight());

layout.setSize(getWidth(), getHeight());
centerLayout.setHeight(getHeight());
}
}
7 changes: 7 additions & 0 deletions src/main/java/com/example/demo/DemoMod.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.example.demo;

public class DemoMod {
public static void init() {
new DemoApplication().show();
}
}
63 changes: 63 additions & 0 deletions src/main/java/net/snackbag/mcvera/InternalCommands.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package net.snackbag.mcvera;

import com.example.demo.DemoMod;
import com.mojang.brigadier.CommandDispatcher;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.command.CommandRegistryAccess;
import net.snackbag.mcvera.test.*;

public class InternalCommands {
public static void register(
CommandDispatcher<FabricClientCommandSource> dispatcher,
CommandRegistryAccess ra
) {
if (!FabricLoader.getInstance().isDevelopmentEnvironment()) return;

dispatcher.register(
ClientCommandManager.literal("vera")
.then(ClientCommandManager.literal("test")
.then(ClientCommandManager.literal("generic").executes((ctx) -> {
TestApplication.INSTANCE.show();
return 1;
}))
.then(ClientCommandManager.literal("styles").executes((ctx) -> {
StyleTestApplication.INSTANCE.show();
return 1;
}))
.then(ClientCommandManager.literal("layout").executes((ctx) -> {
LayoutTestApplication.INSTANCE.show();
return 1;
}))
.then(ClientCommandManager.literal("layoutalignments").executes((ctx) -> {
LayoutCenteringTestApplication.INSTANCE.show();
return 1;
}))
.then(ClientCommandManager.literal("hierarchy").executes(ctx -> {
HierarchyTest.INSTANCE.start();
return 1;
}))
.then(ClientCommandManager.literal("quads").executes(ctx -> {
QuadTestApplication.INSTANCE.show();
return 1;
}))
.then(ClientCommandManager.literal("demo").executes(ctx -> {
DemoMod.init();
return 1;
}))
)
.then(ClientCommandManager.literal("clear-tests")
.executes((ctx) -> {
TestApplication.INSTANCE = new TestApplication();
StyleTestApplication.INSTANCE = new StyleTestApplication();
LayoutTestApplication.INSTANCE = new LayoutTestApplication();
LayoutCenteringTestApplication.INSTANCE = new LayoutCenteringTestApplication();
HierarchyTest.INSTANCE = new HierarchyTest();
QuadTestApplication.INSTANCE = new QuadTestApplication();
return 1;
})
)
);
}
}
55 changes: 47 additions & 8 deletions src/main/java/net/snackbag/mcvera/MCVeraData.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,56 @@
package net.snackbag.mcvera;

import net.snackbag.vera.core.VeraApp;
import net.snackbag.vera.flag.VAppFlag;
import net.snackbag.vera.flag.VAppPositioningFlag;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.*;
import java.util.function.Consumer;

public class MCVeraData {
public static Set<VeraApp> applications = new HashSet<>();
public static Set<VeraApp> visibleApplications = new HashSet<>();
public static LinkedHashSet<VeraApp> applications = new LinkedHashSet<>();
public static HashMap<VAppPositioningFlag, LinkedHashSet<VeraApp>> visibleApplications = new HashMap<>();
public static HashMap<VAppFlag, List<VeraApp>> appFlags = new HashMap<>();

public static int appsWithMouseRequired = 0;

public static final List<Integer> pressedKeys = new ArrayList<>();
public static List<Integer> previousPressedKeys = new ArrayList<>();
public static final Set<VeraApp> debugApps = new HashSet<>();
public static int appsWithMouseRequired = 0;

/**
* Executes a method as the top hierarchy app. If there is no top app it won't execute the specified code.
*
* @param runnable code to execute
* @return whether something has been executed
*/
public static boolean asTopHierarchy(@NotNull Consumer<VeraApp> runnable) {
if (!appFlags.containsKey(VAppFlag.HIERARCHIC)) return false;
runnable.accept(getTopHierarchy());
return true;
}

public static @Nullable VeraApp getTopHierarchy() {
List<VeraApp> apps = getAppsWithFlag(VAppFlag.HIERARCHIC);
if (apps.isEmpty()) return null;
return apps.get(0);
}

public static boolean isTopHierarchy(VeraApp app) {
return getTopHierarchy() == app;
}

/**
* Returns an UNMODIFIABLE version of the {@link #appFlags} entry for the given flag. If the entry is empty, it
* returns an empty unmodifiable list. If you want to access a modifiable version of the flag, you have to manually
* work with the {@link #appFlags} variable.
*
* @param flag the flag to check
* @return an unmodifiable list of the apps under the flag
*/
public static List<VeraApp> getAppsWithFlag(VAppFlag flag) {
if (!appFlags.containsKey(flag)) return Collections.unmodifiableList(new ArrayList<>());
return Collections.unmodifiableList(appFlags.get(flag));
}
}
13 changes: 13 additions & 0 deletions src/main/java/net/snackbag/mcvera/MinecraftVera.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import net.fabricmc.api.ModInitializer;

import net.snackbag.vera.Vera;
import net.snackbag.vera.style.standard.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -12,5 +14,16 @@ public class MinecraftVera implements ModInitializer {
@Override
public void onInitialize() {
LOGGER.info("Loading Vera...");

LOGGER.info("Registering standard styles");
// sorted by "complicatedness" & importance
Vera.registrar.registerStandardStyle(new WidgetStandardStyle());

Vera.registrar.registerStandardStyle(new RectStandardStyle());
Vera.registrar.registerStandardStyle(new CheckBoxStandardStyle());
Vera.registrar.registerStandardStyle(new LabelStandardStyle());
Vera.registrar.registerStandardStyle(new DropdownStandardStyle());
Vera.registrar.registerStandardStyle(new TabWidgetStandardStyle());
Vera.registrar.registerStandardStyle(new LineInputStandardStyle());
}
}
17 changes: 1 addition & 16 deletions src/main/java/net/snackbag/mcvera/MinecraftVeraClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@
import com.google.gson.JsonObject;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.util.InputUtil;
import net.minecraft.resource.Resource;
import net.minecraft.util.Identifier;
import net.snackbag.mcvera.impl.MCVeraProvider;
import net.snackbag.mcvera.impl.MCVeraRenderer;
import net.snackbag.mcvera.test.TestHandler;
import net.snackbag.vera.Vera;
import net.snackbag.vera.core.VeraApp;

import java.io.IOException;
import java.io.InputStreamReader;
Expand All @@ -25,24 +21,13 @@ public void onInitializeClient() {
MinecraftVera.LOGGER.info("Loading client Vera implementation...");
TestHandler.impl(false);

HudRenderCallback.EVENT.register((context, tickDelta) -> {
MCVeraRenderer.drawContext = context;
MCVeraRenderer renderer = MCVeraRenderer.getInstance();

for (VeraApp app : MCVeraData.visibleApplications) {
renderer.renderApp(app);
}
});

ClientTickEvents.END_CLIENT_TICK.register((client) -> {
// only when changing
if (MCVeraData.previousPressedKeys.equals(MCVeraData.pressedKeys)) return;
MCVeraData.previousPressedKeys = new ArrayList<>(MCVeraData.pressedKeys);

String combination = makeCombination(client);
for (VeraApp app : MCVeraData.visibleApplications) {
app.handleShortcut(combination);
}
Vera.forVisibleAndAllowedApps(app -> app.handleShortcut(combination));
});
}

Expand Down
Loading