Skip to content

Commit

Permalink
Added a .travis.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
mploux committed Sep 2, 2017
1 parent 3805449 commit 30512ed
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 38 deletions.
8 changes: 8 additions & 0 deletions .travis.yml
@@ -0,0 +1,8 @@
language: java

jdk:
- oraclejdk8

script:
- mvn package
- mvn test
4 changes: 2 additions & 2 deletions src/main/java/fr/veridiangames/client/inputs/Keyboard.java
Expand Up @@ -42,8 +42,8 @@ public class Keyboard implements GLFWKeyCallbackI
public boolean[] keys = new boolean[65536];

public ArrayList<Integer> currentKeys = new ArrayList<>();
private ArrayList<Integer> downKeys = new ArrayList<>();
private ArrayList<Integer> upKeys = new ArrayList<>();
public ArrayList<Integer> downKeys = new ArrayList<>();
public ArrayList<Integer> upKeys = new ArrayList<>();

public void invoke(long window, int key, int scancode, int action, int mods) {
//System.out.println("KEY(" + String.valueOf(Character.valueOf((char) key)) + "): 0x" + Integer.toHexString(key));
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/fr/veridiangames/client/inputs/TextInput.java
Expand Up @@ -9,11 +9,10 @@ public class TextInput implements GLFWCharCallbackI
{
private List<Integer> keyCodes = new ArrayList<>();

private int keyCode = 0;
private int keyCode = -1;

public void invoke(long window, int codepoint)
{
System.out.println("LOL: " + codepoint);
keyCode = codepoint;
}

Expand Down
Expand Up @@ -83,8 +83,7 @@ public void update()
{
super.update();

if (Display.getInstance().getInput().getKeyDown(Input.KEY_T) ||
Display.getInstance().getInput().getKeyDown(Input.KEY_ENTER))
if (Display.getInstance().getInput().getKeyDown(Input.KEY_T) || Display.getInstance().getInput().getKeyDown(Input.KEY_ENTER))
{
console = true;
this.setRendered(true);
Expand All @@ -101,7 +100,7 @@ public void update()
}
Ubercube.getInstance().setInConsole(console);
bg.setUseable(console);
write.setUseable(console);
write.setRendered(console);

if (Display.getInstance().getInput().getKeyDown(Input.KEY_ENTER) && console && write.getText().length() > 0)
{
Expand Down Expand Up @@ -131,7 +130,7 @@ public void render(GuiShader shader)
if (console)
{
glEnable(GL_SCISSOR_TEST);
glScissor(bg.getX(), Display.getInstance().getHeight() - bg.getY() - bg.getH(), bg.getW(), bg.getH());
glScissor(bg.getX() + 4, Display.getInstance().getHeight() - bg.getY() - bg.getH() + 4, bg.getW() - 8, bg.getH() - 8);
}
for (int i = 0; i < messageList.size(); i++)
{
Expand Down Expand Up @@ -193,7 +192,6 @@ void update(int x, int y, boolean console)
{
color.setAlpha(1.0f);
}

}

void render(GuiShader shader)
Expand Down
Expand Up @@ -41,6 +41,7 @@ public class GuiCanvas
private List<GuiCanvas> canvasOverlays;

private GuiShader shader;
private boolean enabled;

public GuiCanvas(GuiCanvas parent)
{
Expand All @@ -50,6 +51,7 @@ public GuiCanvas(GuiCanvas parent)
canvasOverlays = new ArrayList<>();
rendered = true;
updated = true;
enabled = true;
}

public void update()
Expand All @@ -62,7 +64,7 @@ public void update()

for (int i = 0; i < canvasOverlays.size(); i++)
{
if (canvasOverlays.get(i).isUpdated())
if (canvasOverlays.get(i).isUpdated() && canvasOverlays.get(i).isEnabled())
canvasOverlays.get(i).update();
}
}
Expand All @@ -79,7 +81,7 @@ public void render(Display display)
gui.renderSteps(shader);

for (GuiCanvas canvas : canvasOverlays)
if (canvas.isRendered())
if (canvas.isRendered() && canvas.isEnabled())
canvas.render(display);

render(shader);
Expand Down Expand Up @@ -133,4 +135,12 @@ public void setUpdated(boolean updated)
}

public GuiCanvas getParent() { return parent; }

public void setEnabled(boolean enabled) {
this.enabled = enabled;
}

public boolean isEnabled() {
return enabled;
}
}
Expand Up @@ -40,6 +40,7 @@ public enum GuiCorner
}

protected boolean useable = true;
protected boolean rendered = true;
protected boolean mouseFocused;
protected boolean mouseEnter, mouseIn, mouseExit;
protected boolean mouseButtonDown, mouseButtonPressed, mouseButtonUp;
Expand Down Expand Up @@ -289,6 +290,8 @@ public void update()

public void renderSteps(GuiShader shader)
{
if (!rendered)
return;
render(shader);
}

Expand Down Expand Up @@ -398,4 +401,12 @@ public void setCanvas(GuiCanvas canvas) {
public GuiCanvas getCanvas() {
return canvas;
}

public void setRendered(boolean rendered) {
this.rendered = rendered;
}

public boolean isRendered() {
return rendered;
}
}
Expand Up @@ -19,7 +19,6 @@

package fr.veridiangames.client.rendering.guis;


import java.util.ArrayList;
import java.util.List;

Expand Down
Expand Up @@ -20,7 +20,6 @@
package fr.veridiangames.client.rendering.guis.components;

import fr.veridiangames.client.inputs.Input;
import fr.veridiangames.client.inputs.Mouse;
import fr.veridiangames.client.rendering.Display;
import fr.veridiangames.client.rendering.guis.GuiComponent;
import fr.veridiangames.client.rendering.guis.StaticFont;
Expand All @@ -29,8 +28,6 @@
import fr.veridiangames.core.utils.Color4f;
import fr.veridiangames.core.utils.Log;

import java.awt.Font;

public class GuiTextBox extends GuiComponent
{
private boolean firstLoop = true;
Expand Down Expand Up @@ -87,7 +84,6 @@ public void update() {
if (Display.getInstance().getInput().getMouse().getButtonUp(0) && !mouseIn) {
focused = false;
}
Log.println("Caretpos: " + caretPosition);
caretDistance = 0;
for (int i = 0; i < caretPosition; i++) {
char c = text.charAt(i);
Expand Down Expand Up @@ -140,20 +136,9 @@ public void removeChar(int offset) {
caretPosition--;
showCaret = true;
}

public void render(GuiShader shader) {
// if (focused)
// {
// shader.setColor(selectionColor);
// int selectionWidth =
// StaticPrimitive.quadPrimitive().render(shader,
// x + w / 2,
// y + h / 2,
// 0,
// w / 2,
// 11,
// 0);
// }

public void render(GuiShader shader)
{
shader.setColor(color);
StaticPrimitive.quadPrimitive().render(shader, x +w/2, y +h/2, 0, w/2, h/2, 0);
if (!focused)
Expand All @@ -178,9 +163,14 @@ private void moveCaret(int dir)
private void manageKeys() {
Input input = Display.getInstance().getInput();
int keycode = input.getKeyCode();
boolean activation = input.getKeyboardCallback().currentKeys.size() == 0 &&
input.getKeyboardCallback().upKeys.size() == 0 &&
input.getKeyboardCallback().downKeys.size() == 0 && keycode == 0;

Log.println("Can use console: " + activation + " is first loop ? " + firstLoop);
if (firstLoop)
{
if (input.getKeyUp(Input.KEY_T))
if (activation)
firstLoop = false;
return;
}
Expand All @@ -191,16 +181,14 @@ private void manageKeys() {
if (getKey(input.KEY_LEFT)) moveCaret(-1);
if (getKey(input.KEY_RIGHT)) moveCaret(1);
}

int keyCode = -1;
boolean keyDown = false;
int keyTime = 0;
boolean keyBurse = false;
public boolean getKey(int key) {
Input input = Display.getInstance().getInput();
if (input.getKeyboardCallback().currentKeys.size() > 2) return false;
// if (input.getKeyDown(key))
// return true;
if (input.getKey(key)) {
if (keyDown) {
if (keyCode == key) {
Expand All @@ -211,10 +199,8 @@ public boolean getKey(int key) {
else return false;
}
}

keyCode = key;
keyDown = input.getKey(key);

return keyDown;
}
if (keyCode == key) {
Expand All @@ -226,15 +212,15 @@ public boolean getKey(int key) {

return false;
}

public void dispose() {

}

public String getText() {
return text;
}

public void clear() {
text = "";
textWidth = 0;
Expand Down

0 comments on commit 30512ed

Please sign in to comment.