-
-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-added a method to add abstractwidgets -added a override method for key presses, so they can be used in components (for example allow the editbox to work). -added a test case component with an editbox.
- Loading branch information
1 parent
1db331b
commit 2d408ef
Showing
11 changed files
with
135 additions
and
0 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
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
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
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
55 changes: 55 additions & 0 deletions
55
Common/src/main/java/vazkii/patchouli/client/book/template/test/EditBoxComponentTest.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,55 @@ | ||
package vazkii.patchouli.client.book.template.test; | ||
|
||
import java.util.function.UnaryOperator; | ||
|
||
import com.mojang.blaze3d.vertex.PoseStack; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.components.EditBox; | ||
import net.minecraft.network.chat.TextComponent; | ||
import net.minecraft.world.entity.vehicle.Minecart; | ||
import vazkii.patchouli.api.IComponentRenderContext; | ||
import vazkii.patchouli.api.ICustomComponent; | ||
import vazkii.patchouli.api.IVariable; | ||
import vazkii.patchouli.client.book.BookPage; | ||
|
||
public class EditBoxComponentTest implements ICustomComponent{ | ||
private transient int x, y, page; | ||
private Object editbox; | ||
|
||
@Override | ||
public void onVariablesAvailable(UnaryOperator<IVariable> lookup) { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
@Override | ||
public void build(int componentX, int componentY, int pageNum) { | ||
x = componentX; | ||
y = componentY; | ||
page = pageNum; | ||
this.editbox = new EditBox(Minecraft.getInstance().font, x, y, 120, 20, new TextComponent("")); | ||
} | ||
|
||
@Override | ||
public void render(PoseStack ms, IComponentRenderContext context, float pticks, int mouseX, int mouseY) { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
@Override | ||
public void onDisplayed(IComponentRenderContext context) { | ||
this.editbox = new EditBox(Minecraft.getInstance().font, x, y, 100, 20, new TextComponent("")); | ||
context.addAbstractWidget((EditBox) editbox, page); | ||
} | ||
|
||
@Override | ||
public boolean overwriteKeyPressed(BookPage page, int keyCode, int scanCode, int modifiers) { | ||
if (((EditBox)editbox).isFocused()) { | ||
((EditBox)editbox).keyPressed(keyCode, scanCode, modifiers); | ||
return true; | ||
} | ||
return ICustomComponent.super.overwriteKeyPressed(page, keyCode, scanCode, modifiers); | ||
} | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
...houli_books/comprehensive_test_book/en_us/entries/templates/custom_widget_components.json
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,10 @@ | ||
{ | ||
"name": "Custom Widget Components", | ||
"category": "patchouli:templates", | ||
"icon": "minecraft:written_book", | ||
"pages": [ | ||
{ | ||
"type": "patchouli:custom_widget_component" | ||
} | ||
] | ||
} |
10 changes: 10 additions & 0 deletions
10
...ouli/patchouli_books/comprehensive_test_book/en_us/templates/custom_widget_component.json
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,10 @@ | ||
{ | ||
"components": [ | ||
{ | ||
"type": "patchouli:custom", | ||
"class": "vazkii.patchouli.client.book.template.test.EditBoxComponentTest", | ||
"x": 10, | ||
"y": 40 | ||
} | ||
] | ||
} |