-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change log v1.5 ## New Features - User Interface - Text - TextInput Vector2 - Added a new methods Add() - Added a new methods Subtract() - Added a new methods Divide() - Added a new methods Multiply()
- Loading branch information
1 parent
1eefd72
commit b089fd1
Showing
22 changed files
with
479 additions
and
6 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
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
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
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
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
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
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,9 @@ | ||
package dev.jabo.kree.ui; | ||
|
||
public class Constraint { | ||
|
||
public Constraint() { | ||
|
||
} | ||
|
||
} |
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,114 @@ | ||
package dev.jabo.kree.ui; | ||
|
||
import java.awt.Color; | ||
import java.awt.Graphics; | ||
|
||
import dev.jabo.kree.Scene; | ||
import dev.jabo.kree.Vector2; | ||
|
||
public class ProgressBar extends UserInterface { | ||
|
||
private Vector2 position = new Vector2(0, 0); | ||
private Vector2 scale = new Vector2(128, 32); | ||
|
||
private float value = 100, maxValue = 150; | ||
|
||
private Color backgroundColor = new Color(25, 25, 25); | ||
private Color foregroundColor = new Color(255, 125, 25); | ||
|
||
private int padding = 4; | ||
|
||
public ProgressBar(Scene parentScene) { | ||
|
||
|
||
|
||
AddToScene(parentScene); | ||
} | ||
|
||
public ProgressBar(Scene parentScene, Vector2 position) { | ||
|
||
this.position = position; | ||
|
||
AddToScene(parentScene); | ||
} | ||
|
||
public ProgressBar(Scene parentScene, Vector2 position, Vector2 scale) { | ||
|
||
this.position = position; | ||
this.scale = scale; | ||
|
||
AddToScene(parentScene); | ||
} | ||
|
||
@Override | ||
public void Update() { | ||
if(value > maxValue) { | ||
value = maxValue; | ||
} | ||
if(value <= 0) { | ||
value = 0; | ||
} | ||
} | ||
|
||
@Override | ||
public void Render(Graphics g) { | ||
|
||
g.setColor(backgroundColor); | ||
g.fillRect(position.x, position.y, scale.x, scale.y); | ||
g.setColor(foregroundColor); | ||
g.fillRect(position.x + padding, position.y + padding, (int) ((value / maxValue) * (scale.x - (padding * 2))), scale.y - (padding * 2)); | ||
} | ||
|
||
// Misc | ||
public void Add(float value) { | ||
this.value += value; | ||
} | ||
|
||
public void Subtract(float value) { | ||
this.value -= value; | ||
} | ||
|
||
// Setters | ||
public void SetValue(float value) { | ||
this.value = value; | ||
} | ||
|
||
public void SetMaxValue(float maxValue) { | ||
this.maxValue = maxValue; | ||
} | ||
|
||
public void SetColor(Color foregroundColor, Color backgroundColor) { | ||
this.foregroundColor = foregroundColor; | ||
this.backgroundColor = backgroundColor; | ||
} | ||
|
||
public void SetPosition(Vector2 position) { | ||
this.position = position; | ||
} | ||
|
||
public void SetScale(Vector2 scale) { | ||
this.scale = scale; | ||
} | ||
|
||
public void SetPadding(int padding) { | ||
this.padding = padding; | ||
} | ||
|
||
// Getters | ||
public float GetValue() { | ||
return value; | ||
} | ||
|
||
public float GetMaxValue() { | ||
return maxValue; | ||
} | ||
|
||
public Vector2 GetPosition() { | ||
return position; | ||
} | ||
|
||
public Vector2 GetScale() { | ||
return scale; | ||
} | ||
|
||
} |
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,109 @@ | ||
package dev.jabo.kree.ui; | ||
|
||
import java.awt.Color; | ||
import java.awt.Font; | ||
import java.awt.Graphics; | ||
|
||
import dev.jabo.kree.Scene; | ||
import dev.jabo.kree.Vector2; | ||
|
||
public class Text extends UserInterface { | ||
|
||
private String text; | ||
|
||
private Font font = new Font("Times New Roman", Font.PLAIN, 14); | ||
|
||
private int width = 0; | ||
private int height = 0; | ||
|
||
private boolean showBorder = false; | ||
|
||
private Color color = Color.black; | ||
|
||
public Text(Scene parentScene, String text, Vector2 position, int width) { | ||
this.position = position; | ||
this.text = text; | ||
|
||
this.width = width; | ||
|
||
AddToScene(parentScene); | ||
} | ||
|
||
@Override | ||
public void Update() { | ||
|
||
|
||
|
||
} | ||
|
||
@Override | ||
public void Render(Graphics g) { | ||
if(showBorder) { | ||
g.drawRect(position.x, position.y, width, height); | ||
} | ||
|
||
g.setFont(this.font); | ||
g.setColor(color); | ||
drawTextLineByLine(g); | ||
} | ||
|
||
public void drawTextLineByLine(Graphics g) { | ||
|
||
this.height = 0; | ||
|
||
String[] s = text.split(" "); | ||
|
||
int line = 1; | ||
int col = 0; | ||
|
||
String last = ""; | ||
boolean endl = false; | ||
|
||
int curWidth = 0; | ||
|
||
for(String str : s) { | ||
int width = g.getFontMetrics(font).stringWidth(last); | ||
curWidth += width + (col * 2); | ||
if(curWidth > this.width) { | ||
endl = true; | ||
} | ||
if(endl) { | ||
line++; | ||
endl = false; | ||
curWidth = 0; | ||
col = 0; | ||
last = ""; | ||
} | ||
last = str; | ||
g.drawString(str, this.position.x + (curWidth), this.position.y + font.getSize() * line); | ||
col++; | ||
this.height = font.getSize() * line; | ||
} | ||
|
||
} | ||
|
||
public void SetColor(Color color) { | ||
this.color = color; | ||
} | ||
|
||
public void ShowBorder() { | ||
showBorder = true; | ||
} | ||
|
||
public void HideBorder() { | ||
showBorder = false; | ||
} | ||
|
||
public void SetFont(Font font) { | ||
this.font = font; | ||
} | ||
|
||
public void SetText(String text) { | ||
this.text = text; | ||
} | ||
|
||
public String GetText() { | ||
return text; | ||
} | ||
|
||
} |
Oops, something went wrong.