Skip to content

Commit

Permalink
Merge pull request #3 from GTNewHorizons/new_features
Browse files Browse the repository at this point in the history
Fixes and stuff
  • Loading branch information
Dream-Master authored Jan 2, 2020
2 parents 3a95518 + 9359df3 commit 9ed2314
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ mc_version=1.7.10
forge_version=10.13.4.1614-1.7.10
ccl_version=1.1.3.138
ccc_version=1.0.7.+
mod_version=2.0.0-pre-8-GTNH
mod_version=2.0.0-pre-9-GTNH
30 changes: 24 additions & 6 deletions src/codechicken/nei/TextField.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

public abstract class TextField extends Widget
{
protected final GuiTextField field;
protected GuiTextField field;

private static final int maxSearchLength = 256;

Expand All @@ -15,27 +15,45 @@ public abstract class TextField extends Widget

private boolean previousKeyboardRepeatEnabled;

public TextField(String ident) {
identifier = ident;
protected void initInternalTextField() {
field = new GuiTextField(Minecraft.getMinecraft().fontRenderer, 0, 0, 0, 0);
field.setMaxStringLength(maxSearchLength);
field.setCursorPositionZero();
}

public TextField(String ident) {
identifier = ident;
initInternalTextField();
// Keyboard.enableRepeatEvents(true);
}

public int getTextColour() {
return focused() ? 0xFFE0E0E0 : 0xFF909090;
}

@Override
public void draw(int mousex, int mousey) {
protected void setDimensionsAndColor() {
field.xPosition = this.x + 2;
field.yPosition = this.y + 2;
field.width = this.w - 4;
field.height = this.h - 4;
field.setTextColor(getTextColour());
}

field.drawTextBox();
@Override
public void draw(int mousex, int mousey) {
try {
setDimensionsAndColor();
field.drawTextBox();
} catch(NullPointerException npe) {
// Hack to deal with a null font renderer... recreate the field and it should work
GuiTextField oldField = field;

initInternalTextField();
setDimensionsAndColor();

field.setText(oldField.getText());
field.drawTextBox();
}
}

@Override
Expand Down
3 changes: 1 addition & 2 deletions src/codechicken/nei/config/OptionTextField.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
public class OptionTextField extends Option
{
private boolean focused = false;
private final TextField textField = new TextField("")
private TextField textField = new TextField("test")
{

@Override
public void onTextChange(String oldText) {
if(focused() && isValidValue(text()))
Expand Down

0 comments on commit 9ed2314

Please sign in to comment.