|
| 1 | +package pneumaticCraft.api.client; |
| 2 | + |
| 3 | +import java.awt.Rectangle; |
| 4 | +import java.util.List; |
| 5 | + |
| 6 | +import net.minecraft.client.gui.FontRenderer; |
| 7 | + |
| 8 | +/** |
| 9 | + * This interface doesn't have to be implemented. In PneumaticCraft there already is one class which implements this interface |
| 10 | + * which is used many times in PneumaticCraft (GUI stats, Pneumatic Helmet 2D and 3D stats). You can get an instance of this |
| 11 | + * class as well. Information about this you can find in GuiAnimatedStatSupplier.java. Implementing your own version of |
| 12 | + * animated stats can be implemented as well via this interface, and they will interact with the PneumaticCraft GuiAnimatedStats |
| 13 | + * if you implement it correctly. |
| 14 | + */ |
| 15 | + |
| 16 | +public interface IGuiAnimatedStat{ |
| 17 | + |
| 18 | + /** |
| 19 | + * When you call this method with a set of coordinates representing the button location and dimensions, you'll get |
| 20 | + * these parameters back scaled to the GuiAnimatedStat's scale. |
| 21 | + * @param origX Button start X. |
| 22 | + * @param origY Button start Y. |
| 23 | + * @param width Button width. |
| 24 | + * @param height Button height. |
| 25 | + * @return rectangle containing the new location and dimensions. |
| 26 | + */ |
| 27 | + public Rectangle getButtonScaledRectangle(int origX, int origY, int width, int height); |
| 28 | + |
| 29 | + /** |
| 30 | + * When passed 0.5F for example, the text of the stat will be half as big (so more text can fit into a certain area). |
| 31 | + * @param scale |
| 32 | + */ |
| 33 | + public void scaleTextSize(float scale); |
| 34 | + |
| 35 | + /** |
| 36 | + * Returns true if the statistic expands to the left. |
| 37 | + * @return |
| 38 | + */ |
| 39 | + public boolean isLeftSided(); |
| 40 | + |
| 41 | + /** |
| 42 | + * Returns true if the statistic is done with expanding (when text will be displayed). |
| 43 | + * @return |
| 44 | + */ |
| 45 | + public boolean isDoneExpanding(); |
| 46 | + |
| 47 | + /** |
| 48 | + * Pass true if the statistic should expand to the left, otherwise false. |
| 49 | + * @param leftSided |
| 50 | + */ |
| 51 | + public void setLeftSided(boolean leftSided); |
| 52 | + |
| 53 | + /** |
| 54 | + * Sets the main text of this stat. Every line should be stored in a seperate list element. Upon rendering, |
| 55 | + * EnumChatFormattings will be respected. When you call this method, Too long lines will be divided into multiple shorter ones |
| 56 | + * to fit in the GUI. |
| 57 | + * @param text |
| 58 | + */ |
| 59 | + public void setText(List<String> text); |
| 60 | + |
| 61 | + /** |
| 62 | + * Sets the line to a single line. Upon rendering, |
| 63 | + * EnumChatFormattings will be respected. When you call this method, Too long lines will be divided into multiple shorter ones |
| 64 | + * to fit in the GUI. |
| 65 | + * @param text |
| 66 | + */ |
| 67 | + public void setText(String text); |
| 68 | + |
| 69 | + /** |
| 70 | + * Sets the main text of this stat. Every line should be stored in a seperate list element. Upon rendering, |
| 71 | + * EnumChatFormattings will be respected. This version of the text setting doesn't handle too long lines. |
| 72 | + * @param text |
| 73 | + */ |
| 74 | + public void setTextWithoutCuttingString(List<String> text); |
| 75 | + |
| 76 | + /** |
| 77 | + * Sets the title of this stat. It will automatically get the yellow color assigned. |
| 78 | + * @param title |
| 79 | + */ |
| 80 | + public void setTitle(String title); |
| 81 | + |
| 82 | + /** |
| 83 | + * Returns the title of this stat (obviously without color prefix). |
| 84 | + * @return |
| 85 | + */ |
| 86 | + public String getTitle(); |
| 87 | + |
| 88 | + /** |
| 89 | + * Defines what dimensions the stat should have when it is not expanded (default 17x17) and resets the stat to these dimensions. |
| 90 | + * Used in PneumaticCraft by the block/entity tracker stats, they are 0x0 when not expanded so it looks like they expand |
| 91 | + * (and appear) from nothing. |
| 92 | + * @param minWidth |
| 93 | + * @param minHeight |
| 94 | + */ |
| 95 | + public void setMinDimensionsAndReset(int minWidth, int minHeight); |
| 96 | + |
| 97 | + /** |
| 98 | + * When this stat gets a parent stat assigned, the y of this stat will be the same as the parent's plus this stat's |
| 99 | + * baseY. This will cause this stat to move up and down when the parent's stat expands/moves. |
| 100 | + * @param stat |
| 101 | + */ |
| 102 | + public void setParentStat(IGuiAnimatedStat stat); |
| 103 | + |
| 104 | + /** |
| 105 | + * Sets the x location of this stat. |
| 106 | + * @param x |
| 107 | + */ |
| 108 | + public void setBaseX(int x); |
| 109 | + |
| 110 | + /** |
| 111 | + * Sets the base Y of this stat. |
| 112 | + * @param y |
| 113 | + */ |
| 114 | + public void setBaseY(int y); |
| 115 | + |
| 116 | + /** |
| 117 | + * Returns the real Y of this stat. This is the same as getBaseY when there is no parent stat, but if there is this method |
| 118 | + * returns the value described in setParentStat(IGuiAnimatedStat stat). |
| 119 | + * @return |
| 120 | + */ |
| 121 | + public int getAffectedY(); |
| 122 | + |
| 123 | + public int getBaseX(); |
| 124 | + |
| 125 | + public int getBaseY(); |
| 126 | + |
| 127 | + /** |
| 128 | + * Returns the Y size of this stat. |
| 129 | + * @return |
| 130 | + */ |
| 131 | + public int getHeight(); |
| 132 | + |
| 133 | + /** |
| 134 | + * Returns the X size of this stat. |
| 135 | + * @return |
| 136 | + */ |
| 137 | + public int getWidth(); |
| 138 | + |
| 139 | + /** |
| 140 | + * This method should be called every game tick to update the logic of the stat (expanding of the stat). |
| 141 | + * NOTE!! PneumaticCraft's version of GuiAnimatedStat registers the stat when it creates an instance to automatically invoke the |
| 142 | + * update() method every tick. This means that if you use GuiAnimatedStatSupplier.getAnimatedStat() you shouldn't call update() |
| 143 | + * yourself! |
| 144 | + */ |
| 145 | + public void update(); |
| 146 | + |
| 147 | + /** |
| 148 | + * Should be called every render tick when and where you want to render the stat. |
| 149 | + * @param fontRenderer |
| 150 | + * @param zLevel |
| 151 | + * @param partialTicks |
| 152 | + */ |
| 153 | + public void render(FontRenderer fontRenderer, float zLevel, float partialTicks); |
| 154 | + |
| 155 | + /** |
| 156 | + * This method will handle mouse clicks. This will handle open/closing of the stat when the mouse clicks it. |
| 157 | + * @param x |
| 158 | + * @param y |
| 159 | + * @param button |
| 160 | + * @return |
| 161 | + */ |
| 162 | + public boolean mouseClicked(int x, int y, int button); |
| 163 | + |
| 164 | + /** |
| 165 | + * Forces the stat to close. |
| 166 | + */ |
| 167 | + public void closeWindow(); |
| 168 | + |
| 169 | + /** |
| 170 | + * Forces the stat to expand. |
| 171 | + */ |
| 172 | + public void openWindow(); |
| 173 | + |
| 174 | + /** |
| 175 | + * Returns true if the stat is expanding. |
| 176 | + * @return |
| 177 | + */ |
| 178 | + public boolean isClicked(); |
| 179 | + |
| 180 | + /** |
| 181 | + * Will handle the tooltip. |
| 182 | + * @param fontRenderer |
| 183 | + * @param x |
| 184 | + * @param y |
| 185 | + */ |
| 186 | + public void onMouseHovering(FontRenderer fontRenderer, int x, int y); |
| 187 | +} |
0 commit comments