-
Notifications
You must be signed in to change notification settings - Fork 18
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
1 parent
b487d9c
commit 2fcbe42
Showing
10 changed files
with
204 additions
and
23 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
49 changes: 49 additions & 0 deletions
49
src/main/java/com/nomiceu/nomilabs/integration/betterp2p/SortWidgetButton.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,49 @@ | ||
package com.nomiceu.nomilabs.integration.betterp2p; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.renderer.Tessellator; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
import com.nomiceu.nomilabs.LabsTextures; | ||
import com.projecturanus.betterp2p.client.gui.GuiAdvancedMemoryCard; | ||
import com.projecturanus.betterp2p.client.gui.widget.WidgetButton; | ||
|
||
public class SortWidgetButton extends WidgetButton { | ||
|
||
public SortWidgetButton(@NotNull GuiAdvancedMemoryCard gui, int x, int y, int width, int height) { | ||
super(gui, x, y, width, height); | ||
|
||
setHoverText(ImmutableList.of(getAccessibleGui().labs$getSortMode().getName())); | ||
} | ||
|
||
@Override | ||
public boolean mousePressed(int mouseX, int mouseY, int button) { | ||
if (!canPress(mouseX, mouseY)) return false; | ||
|
||
getAccessibleGui().labs$changeSort(button == 0); | ||
setHoverText(ImmutableList.of(getAccessibleGui().labs$getSortMode().getName())); | ||
return true; | ||
} | ||
|
||
@Override | ||
public void draw(@NotNull Minecraft mc, int mouseX, int mouseY, float partial) { | ||
var tessellator = Tessellator.getInstance(); | ||
|
||
drawBG(tessellator, mouseX, mouseY, partial); | ||
|
||
// Button Icon | ||
LabsTextures.P2P_SORTING_MODES[getAccessibleGui().labs$getSortMode().ordinal()] | ||
.draw(x + 1.0, y + 1.0, width - 2, height - 2); | ||
} | ||
|
||
// From GuiButton#mousePressed | ||
private boolean canPress(int mouseX, int mouseY) { | ||
return enabled && visible && mouseX >= x && mouseY >= y && mouseX < x + width && mouseY < y + height; | ||
} | ||
|
||
private AccessibleGuiAdvancedMemoryCard getAccessibleGui() { | ||
return ((AccessibleGuiAdvancedMemoryCard) (Object) getGui()); | ||
} | ||
} |
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
Binary file added
BIN
+681 Bytes
...n/resources/assets/nomilabs/textures/gui/advanced_memory_card/sorting_modes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.