mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 00:38:35 +01:00
Added better mouse controls to the booklet
This commit is contained in:
parent
0494da1fb6
commit
32a42643c9
3 changed files with 36 additions and 17 deletions
|
@ -335,10 +335,12 @@ public class BookletUtils{
|
||||||
booklet.buttonBackward.visible = getPrevPage(booklet.currentEntrySet.chapter, booklet.currentEntrySet.page) != null;
|
booklet.buttonBackward.visible = getPrevPage(booklet.currentEntrySet.chapter, booklet.currentEntrySet.page) != null;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
if(booklet.currentEntrySet.pageInIndex+1 <= booklet.indexPageAmount){
|
||||||
openIndexEntry(booklet, booklet.currentEntrySet.entry, booklet.currentEntrySet.pageInIndex+1, !(booklet.currentEntrySet.entry instanceof BookletEntryAllSearch));
|
openIndexEntry(booklet, booklet.currentEntrySet.entry, booklet.currentEntrySet.pageInIndex+1, !(booklet.currentEntrySet.entry instanceof BookletEntryAllSearch));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the "previous page"-button is pressed
|
* Called when the "previous page"-button is pressed
|
||||||
|
@ -355,10 +357,12 @@ public class BookletUtils{
|
||||||
booklet.buttonBackward.visible = getPrevPage(booklet.currentEntrySet.chapter, booklet.currentEntrySet.page) != null;
|
booklet.buttonBackward.visible = getPrevPage(booklet.currentEntrySet.chapter, booklet.currentEntrySet.page) != null;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
if(booklet.currentEntrySet.pageInIndex-1 > 0){
|
||||||
openIndexEntry(booklet, booklet.currentEntrySet.entry, booklet.currentEntrySet.pageInIndex-1, !(booklet.currentEntrySet.entry instanceof BookletEntryAllSearch));
|
openIndexEntry(booklet, booklet.currentEntrySet.entry, booklet.currentEntrySet.pageInIndex-1, !(booklet.currentEntrySet.entry instanceof BookletEntryAllSearch));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static BookletPage getFirstPageForStack(ItemStack stack){
|
public static BookletPage getFirstPageForStack(ItemStack stack){
|
||||||
ArrayList<BookletPage> pages = getPagesForStack(stack);
|
ArrayList<BookletPage> pages = getPagesForStack(stack);
|
||||||
|
|
|
@ -20,7 +20,6 @@ import ellpeck.actuallyadditions.config.GuiConfiguration;
|
||||||
import ellpeck.actuallyadditions.proxy.ClientProxy;
|
import ellpeck.actuallyadditions.proxy.ClientProxy;
|
||||||
import ellpeck.actuallyadditions.update.UpdateChecker;
|
import ellpeck.actuallyadditions.update.UpdateChecker;
|
||||||
import ellpeck.actuallyadditions.util.AssetUtil;
|
import ellpeck.actuallyadditions.util.AssetUtil;
|
||||||
import ellpeck.actuallyadditions.util.KeyUtil;
|
|
||||||
import ellpeck.actuallyadditions.util.ModUtil;
|
import ellpeck.actuallyadditions.util.ModUtil;
|
||||||
import ellpeck.actuallyadditions.util.StringUtil;
|
import ellpeck.actuallyadditions.util.StringUtil;
|
||||||
import ellpeck.actuallyadditions.util.playerdata.PersistentClientData;
|
import ellpeck.actuallyadditions.util.playerdata.PersistentClientData;
|
||||||
|
@ -34,6 +33,7 @@ import net.minecraft.util.EnumChatFormatting;
|
||||||
import net.minecraft.util.IChatComponent;
|
import net.minecraft.util.IChatComponent;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
|
import org.lwjgl.input.Mouse;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -151,6 +151,21 @@ public class GuiBooklet extends GuiScreen{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
//For scrolling through pages
|
||||||
|
public void handleMouseInput(){
|
||||||
|
int wheel = Mouse.getEventDWheel();
|
||||||
|
if(wheel != 0){
|
||||||
|
if(wheel > 0){
|
||||||
|
BookletUtils.handleNextPage(this);
|
||||||
|
}
|
||||||
|
else if(wheel < 0){
|
||||||
|
BookletUtils.handlePreviousPage(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
super.handleMouseInput();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void keyTyped(char theChar, int key){
|
public void keyTyped(char theChar, int key){
|
||||||
if(key == Keyboard.KEY_ESCAPE && this.parentScreen != null){
|
if(key == Keyboard.KEY_ESCAPE && this.parentScreen != null){
|
||||||
|
@ -181,10 +196,19 @@ public class GuiBooklet extends GuiScreen{
|
||||||
@Override
|
@Override
|
||||||
protected void mouseClicked(int par1, int par2, int par3){
|
protected void mouseClicked(int par1, int par2, int par3){
|
||||||
this.searchField.mouseClicked(par1, par2, par3);
|
this.searchField.mouseClicked(par1, par2, par3);
|
||||||
//Notifys the booklet of the mouse being pressed
|
//Left mouse button
|
||||||
if(par3 == 0 && this.currentEntrySet.chapter != null){
|
if(par3 == 0 && this.currentEntrySet.chapter != null){
|
||||||
this.mousePressed = true;
|
this.mousePressed = true;
|
||||||
}
|
}
|
||||||
|
//Right mouse button
|
||||||
|
else if(par3 == 1){
|
||||||
|
if(this.currentEntrySet.chapter != null){
|
||||||
|
BookletUtils.openIndexEntry(this, this.currentEntrySet.entry, this.currentEntrySet.pageInIndex, true);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
BookletUtils.openIndexEntry(this, null, 1, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
super.mouseClicked(par1, par2, par3);
|
super.mouseClicked(par1, par2, par3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,7 +244,6 @@ public class GuiBooklet extends GuiScreen{
|
||||||
}
|
}
|
||||||
//Handles gonig from page to chapter or from chapter to index
|
//Handles gonig from page to chapter or from chapter to index
|
||||||
else if(button == this.buttonPreviousScreen){
|
else if(button == this.buttonPreviousScreen){
|
||||||
if(KeyUtil.isShiftPressed()){
|
|
||||||
if(this.currentEntrySet.chapter != null){
|
if(this.currentEntrySet.chapter != null){
|
||||||
BookletUtils.openIndexEntry(this, this.currentEntrySet.entry, this.currentEntrySet.pageInIndex, true);
|
BookletUtils.openIndexEntry(this, this.currentEntrySet.entry, this.currentEntrySet.pageInIndex, true);
|
||||||
}
|
}
|
||||||
|
@ -228,10 +251,6 @@ public class GuiBooklet extends GuiScreen{
|
||||||
BookletUtils.openIndexEntry(this, null, 1, true);
|
BookletUtils.openIndexEntry(this, null, 1, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
|
||||||
//TODO History
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//Handles Bookmark button
|
//Handles Bookmark button
|
||||||
else if(button instanceof BookmarkButton){
|
else if(button instanceof BookmarkButton){
|
||||||
((BookmarkButton)button).onPressed();
|
((BookmarkButton)button).onPressed();
|
||||||
|
@ -253,11 +272,7 @@ public class GuiBooklet extends GuiScreen{
|
||||||
this.buttonBackward = new TexturedButton(1, this.guiLeft+8, this.guiTop+this.ySize+1, 146, 0, 18, 10, Collections.singletonList(EnumChatFormatting.GOLD+"Previous Page"));
|
this.buttonBackward = new TexturedButton(1, this.guiLeft+8, this.guiTop+this.ySize+1, 146, 0, 18, 10, Collections.singletonList(EnumChatFormatting.GOLD+"Previous Page"));
|
||||||
this.buttonList.add(this.buttonBackward);
|
this.buttonList.add(this.buttonBackward);
|
||||||
|
|
||||||
List prevScreenHover = new ArrayList<>();
|
this.buttonPreviousScreen = new TexturedButton(2, this.guiLeft+this.xSize/2-7, this.guiTop+this.ySize+1, 182, 0, 15, 10, Collections.singletonList(EnumChatFormatting.GOLD+"Back"));
|
||||||
prevScreenHover.add(EnumChatFormatting.GOLD+"Back");
|
|
||||||
prevScreenHover.add("Click for last item in history");
|
|
||||||
prevScreenHover.add(EnumChatFormatting.ITALIC+"Shift-Click for Chapter");
|
|
||||||
this.buttonPreviousScreen = new TexturedButton(2, this.guiLeft+this.xSize/2-7, this.guiTop+this.ySize+1, 182, 0, 15, 10, prevScreenHover);
|
|
||||||
this.buttonList.add(this.buttonPreviousScreen);
|
this.buttonList.add(this.buttonPreviousScreen);
|
||||||
|
|
||||||
ArrayList updateHover = new ArrayList();
|
ArrayList updateHover = new ArrayList();
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 34 KiB |
Loading…
Reference in a new issue