-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Doubles are now editable within the inspector
- Loading branch information
Flafla2
committed
Jan 23, 2014
1 parent
4468785
commit 44a3f86
Showing
2 changed files
with
85 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
78 changes: 78 additions & 0 deletions
78
Remote2D/src/com/remote/remote2d/editor/inspector/GuiEditorInspectorSectionDouble.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,78 @@ | ||
package com.remote.remote2d.editor.inspector; | ||
|
||
import org.lwjgl.input.Keyboard; | ||
|
||
import com.remote.remote2d.editor.GuiEditor; | ||
import com.remote.remote2d.engine.Remote2D; | ||
import com.remote.remote2d.engine.art.Fonts; | ||
import com.remote.remote2d.engine.gui.GuiTextField; | ||
import com.remote.remote2d.engine.gui.TextLimiter; | ||
import com.remote.remote2d.engine.logic.Vector2; | ||
|
||
public class GuiEditorInspectorSectionDouble extends GuiEditorInspectorSection { | ||
|
||
GuiTextField textField; | ||
|
||
public GuiEditorInspectorSectionDouble(String name, GuiEditor inspector, Vector2 pos, int width) { | ||
super(name, inspector, pos, width); | ||
textField = new GuiTextField(pos.add(new Vector2(10,20)), new Vector2(width-20,20), 20); | ||
textField.limitToDigits = TextLimiter.LIMIT_TO_FLOAT; | ||
} | ||
|
||
@Override | ||
public int sectionHeight() { | ||
return 40; | ||
} | ||
|
||
@Override | ||
public Object getData() { | ||
if(textField.text.trim().equals("")) | ||
return new Double(0); | ||
return Double.parseDouble(textField.text); | ||
} | ||
|
||
@Override | ||
public void initSection() { | ||
|
||
} | ||
|
||
@Override | ||
public void tick(int i, int j, int k) { | ||
textField.tick(i, j, k); | ||
} | ||
|
||
@Override | ||
public void render(float interpolation) { | ||
Fonts.get("Arial").drawString(renderName, pos.x, pos.y, 20, isComplete() ? 0xffffff : 0xff7777); | ||
textField.render(interpolation); | ||
} | ||
|
||
@Override | ||
public void setData(Object o) { | ||
if(o instanceof Double) | ||
{ | ||
textField.text = o+""; | ||
} | ||
} | ||
|
||
@Override | ||
public void deselect() { | ||
textField.deselect(); | ||
} | ||
|
||
@Override | ||
public boolean isSelected() { | ||
return textField.isSelected(); | ||
} | ||
|
||
@Override | ||
public boolean isComplete() { | ||
return !textField.text.trim().equals("") && !textField.text.equals("-"); | ||
} | ||
|
||
@Override | ||
public boolean hasFieldBeenChanged() { | ||
return textField.isSelected() && isComplete() && Remote2D.getIntegerKeyboardList().contains(Keyboard.KEY_RETURN); | ||
} | ||
|
||
} |