Merge remote-tracking branch 'gogs/master'
This commit is contained in:
commit
2ea86cf76f
1
.gitignore
vendored
1
.gitignore
vendored
@ -18,6 +18,7 @@ font_gputest4.png
|
||||
font_gputest4.xcf
|
||||
manager2/
|
||||
VBO_Example.java
|
||||
math-rules-cache.zip
|
||||
|
||||
/target/
|
||||
!/target/*.jar
|
||||
|
@ -6,7 +6,9 @@ import it.cavallium.warppi.device.Keyboard;
|
||||
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
|
||||
import it.cavallium.warppi.gui.graphicengine.Renderer;
|
||||
import it.cavallium.warppi.gui.graphicengine.Skin;
|
||||
import it.cavallium.warppi.gui.screens.Screen;
|
||||
import it.cavallium.warppi.util.Utils;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
|
||||
public class CalculatorHUD extends HUD {
|
||||
|
||||
@ -30,40 +32,40 @@ public class CalculatorHUD extends HUD {
|
||||
|
||||
@Override
|
||||
public void renderTopmostBackground() {
|
||||
final Renderer renderer = d.renderer;
|
||||
final Renderer r = d.renderer;
|
||||
final GraphicEngine engine = d.engine;
|
||||
|
||||
renderer.glColor(0xFFc5c2af);
|
||||
renderer.glFillColor(0, 0, engine.getWidth(), 20);
|
||||
r.glColor(0xFFc5c2af);
|
||||
r.glFillColor(0, 0, engine.getWidth(), 20);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTopmost() {
|
||||
final Renderer renderer = d.renderer;
|
||||
final Renderer r = d.renderer;
|
||||
final GraphicEngine engine = d.engine;
|
||||
final Skin guiSkin = d.guiSkin;
|
||||
|
||||
//DRAW TOP
|
||||
renderer.glColor3i(0, 0, 0);
|
||||
renderer.glDrawLine(0, 20, engine.getWidth() - 1, 20);
|
||||
renderer.glColor3i(255, 255, 255);
|
||||
r.glColor3i(0, 0, 0);
|
||||
r.glDrawLine(0, 20, engine.getWidth() - 1, 20);
|
||||
r.glColor3i(255, 255, 255);
|
||||
guiSkin.use(engine);
|
||||
if (Keyboard.shift) {
|
||||
renderer.glFillRect(2 + 18 * 0, 2, 16, 16, 16 * 2, 16 * 0, 16, 16);
|
||||
r.glFillRect(2 + 18 * 0, 2, 16, 16, 16 * 2, 16 * 0, 16, 16);
|
||||
} else {
|
||||
renderer.glFillRect(2 + 18 * 0, 2, 16, 16, 16 * 3, 16 * 0, 16, 16);
|
||||
r.glFillRect(2 + 18 * 0, 2, 16, 16, 16 * 3, 16 * 0, 16, 16);
|
||||
}
|
||||
if (Keyboard.alpha) {
|
||||
renderer.glFillRect(2 + 18 * 1, 2, 16, 16, 16 * 0, 16 * 0, 16, 16);
|
||||
r.glFillRect(2 + 18 * 1, 2, 16, 16, 16 * 0, 16 * 0, 16, 16);
|
||||
} else {
|
||||
renderer.glFillRect(2 + 18 * 1, 2, 16, 16, 16 * 1, 16 * 0, 16, 16);
|
||||
r.glFillRect(2 + 18 * 1, 2, 16, 16, 16 * 1, 16 * 0, 16, 16);
|
||||
}
|
||||
|
||||
int padding = 2;
|
||||
|
||||
final int brightness = (int) Math.ceil(Engine.INSTANCE.getHardwareDevice().getDisplayManager().getBrightness() * 9);
|
||||
if (brightness <= 10) {
|
||||
renderer.glFillRect(StaticVars.screenSize[0] - (padding + 16), 2, 16, 16, 16 * brightness, 16 * 1, 16, 16);
|
||||
r.glFillRect(StaticVars.screenSize[0] - (padding + 16), 2, 16, 16, 16 * brightness, 16 * 1, 16, 16);
|
||||
} else {
|
||||
Engine.getPlatform().getConsoleUtils().out().println(1, "Brightness error");
|
||||
}
|
||||
@ -74,34 +76,68 @@ public class CalculatorHUD extends HUD {
|
||||
final boolean canGoForward = Engine.INSTANCE.getHardwareDevice().getDisplayManager().canGoForward();
|
||||
|
||||
if (Engine.getPlatform().getSettings().isDebugEnabled()) {
|
||||
renderer.glFillRect(StaticVars.screenSize[0] - (padding + 16), 2, 16, 16, 16 * 18, 16 * 0, 16, 16);
|
||||
r.glFillRect(StaticVars.screenSize[0] - (padding + 16), 2, 16, 16, 16 * 18, 16 * 0, 16, 16);
|
||||
padding += 18 + 6;
|
||||
}
|
||||
|
||||
if (canGoBack && canGoForward) {
|
||||
renderer.glFillRect(StaticVars.screenSize[0] - (padding + 16), 2, 16, 16, 16 * 14, 16 * 0, 16, 16);
|
||||
r.glFillRect(StaticVars.screenSize[0] - (padding + 16), 2, 16, 16, 16 * 14, 16 * 0, 16, 16);
|
||||
} else if (canGoBack) {
|
||||
renderer.glFillRect(StaticVars.screenSize[0] - (padding + 16), 2, 16, 16, 16 * 15, 16 * 0, 16, 16);
|
||||
r.glFillRect(StaticVars.screenSize[0] - (padding + 16), 2, 16, 16, 16 * 15, 16 * 0, 16, 16);
|
||||
} else if (canGoForward) {
|
||||
renderer.glFillRect(StaticVars.screenSize[0] - (padding + 16), 2, 16, 16, 16 * 16, 16 * 0, 16, 16);
|
||||
r.glFillRect(StaticVars.screenSize[0] - (padding + 16), 2, 16, 16, 16 * 16, 16 * 0, 16, 16);
|
||||
} else {
|
||||
renderer.glFillRect(StaticVars.screenSize[0] - (padding + 16), 2, 16, 16, 16 * 17, 16 * 0, 16, 16);
|
||||
r.glFillRect(StaticVars.screenSize[0] - (padding + 16), 2, 16, 16, 16 * 17, 16 * 0, 16, 16);
|
||||
}
|
||||
|
||||
padding += 18;
|
||||
|
||||
//DRAW BOTTOM
|
||||
d.renderer.glDrawStringLeft(2, 90, d.displayDebugString);
|
||||
r.glDrawStringLeft(2, 90, d.displayDebugString);
|
||||
|
||||
Utils.getFont(true, false).use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor4i(255, 0, 0, 40);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringLeft(1 + 1, StaticVars.screenSize[1] - 7 - 7 + 1, "WORK IN");
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor4i(255, 0, 0, 80);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringLeft(1, StaticVars.screenSize[1] - 7 - 7, "WORK IN");
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor4i(255, 0, 0, 40);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringLeft(1 + 1, StaticVars.screenSize[1] - 7 + 1, "PROGRESS.");
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor4i(255, 0, 0, 80);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringLeft(1, StaticVars.screenSize[1] - 7, "PROGRESS.");
|
||||
Utils.getFont(true, false).use(engine);
|
||||
r.glColor4i(255, 0, 0, 40);
|
||||
r.glDrawStringLeft(1 + 1, StaticVars.screenSize[1] - 7 - 7 + 1, "WORK IN");
|
||||
r.glColor4i(255, 0, 0, 80);
|
||||
r.glDrawStringLeft(1, StaticVars.screenSize[1] - 7 - 7, "WORK IN");
|
||||
r.glColor4i(255, 0, 0, 40);
|
||||
r.glDrawStringLeft(1 + 1, StaticVars.screenSize[1] - 7 + 1, "PROGRESS.");
|
||||
r.glColor4i(255, 0, 0, 80);
|
||||
r.glDrawStringLeft(1, StaticVars.screenSize[1] - 7, "PROGRESS.");
|
||||
|
||||
int currentDebugLine = 2;
|
||||
if (Engine.getPlatform().getSettings().isDebugEnabled()) {
|
||||
ObjectArrayList<Screen> allSessions = new ObjectArrayList<>();
|
||||
for (Screen session : Engine.INSTANCE.getHardwareDevice().getDisplayManager().sessions) {
|
||||
allSessions.add(0, session);
|
||||
}
|
||||
Screen curScreen = Engine.INSTANCE.getHardwareDevice().getDisplayManager().getScreen();
|
||||
if (curScreen.canBeInHistory == false) {
|
||||
allSessions.add(curScreen);
|
||||
}
|
||||
|
||||
for (Screen session : allSessions) {
|
||||
if (session != null) {
|
||||
String title = session.getSessionTitle();
|
||||
if (title != null && title.length() > 0) {
|
||||
Utils.getFont(true).use(engine);
|
||||
if (session.canBeInHistory == false) {
|
||||
r.glColor(0xFF3333FF);
|
||||
} else {
|
||||
r.glColor(0xFF990000);
|
||||
}
|
||||
r.glDrawStringLeft(0, StaticVars.screenSize[1] - ((currentDebugLine+1) * (r.getCurrentFont().getCharacterHeight()+1)), "[" + String.format("%1$03d", session.debugScreenID) + "] " + title.toUpperCase());
|
||||
if (session == Engine.INSTANCE.getHardwareDevice().getDisplayManager().getScreen()) {
|
||||
r.glColor(0xFF00CC00);
|
||||
} else {
|
||||
r.glColor(0xFF990000);
|
||||
}
|
||||
r.glDrawStringLeft(0, StaticVars.screenSize[1] - ((currentDebugLine+1) * (r.getCurrentFont().getCharacterHeight()+1)), " " + title.toUpperCase());
|
||||
}
|
||||
currentDebugLine++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -166,7 +166,15 @@ public final class DisplayManager implements RenderingLoop {
|
||||
}
|
||||
|
||||
public void setScreen(final Screen screen) {
|
||||
if (screen.initialized == false) {
|
||||
boolean mustBeAddedToHistory = screen.initialized == false;
|
||||
if (!mustBeAddedToHistory) {
|
||||
boolean found = false;
|
||||
for (Screen s : sessions) {
|
||||
found = found | s == screen;
|
||||
}
|
||||
mustBeAddedToHistory |= !found;
|
||||
}
|
||||
if (mustBeAddedToHistory) {
|
||||
if (screen.canBeInHistory) {
|
||||
if (currentSession > 0) {
|
||||
final int sl = sessions.length + 5; //TODO: I don't know why if i don't add +5 or more some items disappear
|
||||
@ -183,7 +191,9 @@ public final class DisplayManager implements RenderingLoop {
|
||||
}
|
||||
screen.d = this;
|
||||
try {
|
||||
screen.create();
|
||||
if (screen.created == false) {
|
||||
screen.create();
|
||||
}
|
||||
this.screen = screen;
|
||||
screenChange.release();
|
||||
if (screen.initialized == false) {
|
||||
@ -345,12 +355,14 @@ public final class DisplayManager implements RenderingLoop {
|
||||
if (fonts[0] != null && fonts[0] != engine.getRenderer().getCurrentFont()) {
|
||||
fonts[0].use(engine);
|
||||
}
|
||||
hud.renderBackground();
|
||||
if (hud.visible) hud.renderBackground();
|
||||
screen.render();
|
||||
hud.render();
|
||||
hud.renderTopmostBackground();
|
||||
if (hud.visible) {
|
||||
hud.render();
|
||||
hud.renderTopmostBackground();
|
||||
}
|
||||
screen.renderTopmost();
|
||||
hud.renderTopmost();
|
||||
if (hud.visible) hud.renderTopmost();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,8 @@ public abstract class HUD implements GraphicalInterface {
|
||||
public DisplayManager d;
|
||||
public boolean created = false;
|
||||
public boolean initialized = false;
|
||||
|
||||
public boolean visible = true;
|
||||
|
||||
public HUD() {}
|
||||
|
||||
@Override
|
||||
@ -45,4 +46,12 @@ public abstract class HUD implements GraphicalInterface {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
visible = false;
|
||||
}
|
||||
|
||||
public void show() {
|
||||
visible = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package it.cavallium.warppi.gui.expression;
|
||||
|
||||
public class Caret {
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Caret implements Serializable {
|
||||
|
||||
private int pos;
|
||||
private int remaining;
|
||||
|
@ -1,5 +1,7 @@
|
||||
package it.cavallium.warppi.gui.expression;
|
||||
|
||||
public enum CaretState {
|
||||
import java.io.Serializable;
|
||||
|
||||
public enum CaretState implements Serializable {
|
||||
VISIBLE_ON, VISIBLE_OFF, HIDDEN
|
||||
}
|
||||
|
@ -1,12 +1,13 @@
|
||||
package it.cavallium.warppi.gui.expression;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
|
||||
import it.cavallium.warppi.gui.expression.blocks.BlockVariable;
|
||||
import it.cavallium.warppi.math.MathematicalSymbols;
|
||||
import it.cavallium.warppi.math.functions.Variable.V_TYPE;
|
||||
|
||||
public class InputContext {
|
||||
public class InputContext implements Serializable {
|
||||
public final HashMap<Character, V_TYPE> variableTypes;
|
||||
public BlockVariable variableTypeDirtyID = null;
|
||||
|
||||
|
@ -8,6 +8,7 @@ import it.cavallium.warppi.gui.graphicengine.Renderer;
|
||||
import it.cavallium.warppi.math.MathContext;
|
||||
import it.cavallium.warppi.math.parser.features.interfaces.Feature;
|
||||
import it.cavallium.warppi.util.Error;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
|
||||
public abstract class Block implements TreeBlock, GraphicalElement {
|
||||
|
||||
@ -34,7 +35,15 @@ public abstract class Block implements TreeBlock, GraphicalElement {
|
||||
public abstract boolean delBlock(Caret caret);
|
||||
|
||||
public abstract BlockReference<?> getBlock(Caret caret);
|
||||
|
||||
/**
|
||||
* Used only to get inner blocks when deleting the parent block.
|
||||
* @return every block of every inner container, or null if empty
|
||||
*/
|
||||
public abstract ObjectArrayList<Block> getInnerBlocks();
|
||||
|
||||
public abstract int getInnerContainersCount();
|
||||
|
||||
@Override
|
||||
public abstract void recomputeDimensions();
|
||||
|
||||
|
@ -6,6 +6,7 @@ import it.cavallium.warppi.gui.graphicengine.Renderer;
|
||||
import it.cavallium.warppi.math.MathContext;
|
||||
import it.cavallium.warppi.math.parser.features.FeatureChar;
|
||||
import it.cavallium.warppi.math.parser.features.interfaces.Feature;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
|
||||
public class BlockChar extends Block {
|
||||
|
||||
@ -65,4 +66,14 @@ public class BlockChar extends Block {
|
||||
return new FeatureChar(getChar());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectArrayList<Block> getInnerBlocks() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInnerContainersCount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import it.cavallium.warppi.math.parser.features.interfaces.Feature;
|
||||
import it.cavallium.warppi.util.Error;
|
||||
import it.cavallium.warppi.util.Errors;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectListIterator;
|
||||
|
||||
public class BlockContainer implements TreeContainer, GraphicalElement {
|
||||
|
||||
@ -218,8 +219,22 @@ public class BlockContainer implements TreeContainer, GraphicalElement {
|
||||
final int deltaCaret = caret.getRemaining();
|
||||
removed = removed | b.delBlock(caret);
|
||||
if (caret.getRemaining() == 0 || removed == false && deltaCaret >= 0 && caret.getRemaining() < 0) {
|
||||
ObjectArrayList<Block> blocks = this.getBlockAt(pos - 1).get().getInnerBlocks();
|
||||
int innerContainersCount = this.getBlockAt(pos - 1).get().getInnerContainersCount();
|
||||
if (innerContainersCount > 0) {
|
||||
innerContainersCount--;
|
||||
}
|
||||
removeAt(pos - 1);
|
||||
caret.setPosition(caret.getPosition() - deltaCaret);
|
||||
if (blocks != null) {
|
||||
ObjectListIterator<Block> blocksIterator = blocks.iterator();
|
||||
int blockNum = 0;
|
||||
while (blocksIterator.hasNext()) {
|
||||
Block block = blocksIterator.next();
|
||||
addBlockUnsafe(pos - 1 + blockNum, block);
|
||||
blockNum++;
|
||||
}
|
||||
}
|
||||
caret.setPosition(caret.getPosition() - innerContainersCount);
|
||||
removed = true;
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,8 @@ import it.cavallium.warppi.math.MathContext;
|
||||
import it.cavallium.warppi.math.parser.features.FeatureDivision;
|
||||
import it.cavallium.warppi.math.parser.features.interfaces.Feature;
|
||||
import it.cavallium.warppi.util.Error;
|
||||
import it.unimi.dsi.fastutil.objects.AbstractObjectList;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
|
||||
public class BlockDivision extends Block {
|
||||
|
||||
@ -118,4 +120,16 @@ public class BlockDivision extends Block {
|
||||
final Function lower = getLowerContainer().toFunction(context);
|
||||
return new FeatureDivision(upper, lower);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectArrayList<Block> getInnerBlocks() {
|
||||
ObjectArrayList<Block> output = containerUp.getContent();
|
||||
output.addAll(containerDown.getContent());
|
||||
return output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInnerContainersCount() {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
@ -121,7 +121,6 @@ public class BlockLogarithm extends Block implements IParenthesis {
|
||||
height = toph + nmbh;
|
||||
}
|
||||
} else {
|
||||
System.out.println("b");
|
||||
toph = 0;
|
||||
line = toph + nl;
|
||||
if (nmbh + bh - bl > toph + nmbh) {
|
||||
@ -160,4 +159,16 @@ public class BlockLogarithm extends Block implements IParenthesis {
|
||||
return new FeatureLogarithm(base, number);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectArrayList<Block> getInnerBlocks() {
|
||||
ObjectArrayList<Block> output = containerBase.getContent();
|
||||
output.addAll(containerNumber.getContent());
|
||||
return output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInnerContainersCount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,4 +20,14 @@ public class BlockParenthesis extends BlockParenthesisAbstract {
|
||||
return new FeatureParenthesis(cont);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectArrayList<Block> getInnerBlocks() {
|
||||
return getNumberContainer().getContent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInnerContainersCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -115,4 +115,15 @@ public abstract class BlockParenthesisAbstract extends Block implements IParenth
|
||||
@Override
|
||||
public abstract Feature toFeature(MathContext context) throws Error;
|
||||
|
||||
|
||||
@Override
|
||||
public ObjectArrayList<Block> getInnerBlocks() {
|
||||
return containerNumber.getContent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInnerContainersCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import it.cavallium.warppi.math.MathContext;
|
||||
import it.cavallium.warppi.math.parser.features.FeaturePowerChar;
|
||||
import it.cavallium.warppi.math.parser.features.interfaces.Feature;
|
||||
import it.cavallium.warppi.util.Error;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
|
||||
public class BlockPower extends Block {
|
||||
|
||||
@ -80,4 +81,14 @@ public class BlockPower extends Block {
|
||||
final Function exp = getExponentContainer().toFunction(context);
|
||||
return new FeaturePowerChar(exp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectArrayList<Block> getInnerBlocks() {
|
||||
return this.containerExponent.getContent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInnerContainersCount() {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import it.cavallium.warppi.math.MathContext;
|
||||
import it.cavallium.warppi.math.parser.features.FeaturePowerChar;
|
||||
import it.cavallium.warppi.math.parser.features.interfaces.Feature;
|
||||
import it.cavallium.warppi.util.Error;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
|
||||
public class BlockPower2 extends Block {
|
||||
|
||||
@ -86,4 +87,14 @@ public class BlockPower2 extends Block {
|
||||
final Function exp = getExponentContainer().toFunction(context);
|
||||
return new FeaturePowerChar(exp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectArrayList<Block> getInnerBlocks() {
|
||||
return containerExponent.getContent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInnerContainersCount() {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import it.cavallium.warppi.math.MathContext;
|
||||
import it.cavallium.warppi.math.parser.features.FeatureSine;
|
||||
import it.cavallium.warppi.math.parser.features.interfaces.Feature;
|
||||
import it.cavallium.warppi.util.Error;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
|
||||
public class BlockSine extends BlockParenthesisAbstract {
|
||||
public BlockSine() {
|
||||
|
@ -8,6 +8,7 @@ import it.cavallium.warppi.math.MathContext;
|
||||
import it.cavallium.warppi.math.parser.features.FeatureSquareRoot;
|
||||
import it.cavallium.warppi.math.parser.features.interfaces.Feature;
|
||||
import it.cavallium.warppi.util.Error;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
|
||||
public class BlockSquareRoot extends Block {
|
||||
|
||||
@ -95,4 +96,16 @@ public class BlockSquareRoot extends Block {
|
||||
final Function contnt = getNumberContainer().toFunction(context);
|
||||
return new FeatureSquareRoot(contnt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectArrayList<Block> getInnerBlocks() {
|
||||
ObjectArrayList<Block> output = containerNumber.getContent();
|
||||
// output.addAll();
|
||||
return output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInnerContainersCount() {
|
||||
return 1; //2
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import it.cavallium.warppi.math.MathContext;
|
||||
import it.cavallium.warppi.math.MathematicalSymbols;
|
||||
import it.cavallium.warppi.math.parser.features.FeatureChar;
|
||||
import it.cavallium.warppi.math.parser.features.interfaces.Feature;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
|
||||
public class BlockUndefined extends Block {
|
||||
|
||||
@ -59,4 +60,14 @@ public class BlockUndefined extends Block {
|
||||
return new FeatureChar(MathematicalSymbols.UNDEFINED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectArrayList<Block> getInnerBlocks() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInnerContainersCount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import it.cavallium.warppi.math.functions.Variable.V_TYPE;
|
||||
import it.cavallium.warppi.math.parser.features.FeatureVariable;
|
||||
import it.cavallium.warppi.math.parser.features.interfaces.Feature;
|
||||
import it.cavallium.warppi.util.Error;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
|
||||
public class BlockVariable extends Block {
|
||||
|
||||
@ -255,4 +256,14 @@ public class BlockVariable extends Block {
|
||||
public Feature toFeature(final MathContext context) throws Error {
|
||||
return new FeatureVariable(ch, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectArrayList<Block> getInnerBlocks() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInnerContainersCount() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package it.cavallium.warppi.gui.expression.blocks;
|
||||
|
||||
public interface TreeBlock {
|
||||
import java.io.Serializable;
|
||||
|
||||
public interface TreeBlock extends Serializable {
|
||||
TreeContainer getParentContainer();
|
||||
|
||||
boolean hasParent();
|
||||
|
@ -1,6 +1,8 @@
|
||||
package it.cavallium.warppi.gui.expression.blocks;
|
||||
|
||||
public interface TreeContainer {
|
||||
import java.io.Serializable;
|
||||
|
||||
public interface TreeContainer extends Serializable {
|
||||
TreeBlock getParentBlock();
|
||||
|
||||
boolean hasParent();
|
||||
|
@ -78,4 +78,9 @@ public class ChooseVariableValueScreen extends Screen {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSessionTitle() {
|
||||
return "Choose a value for the variable.";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -33,4 +33,9 @@ public class EmptyScreen extends Screen {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSessionTitle() {
|
||||
return "empty";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -222,4 +222,9 @@ public class KeyboardDebugScreen extends Screen {
|
||||
KeyboardDebugScreen.log = newlog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSessionTitle() {
|
||||
return "Keyboard debug";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ public class LoadingScreen extends Screen {
|
||||
public float loadingTextTranslation = 0.0f;
|
||||
public boolean loaded = false;
|
||||
private float previousZoomValue = 1;
|
||||
private volatile boolean ended = false;
|
||||
|
||||
public LoadingScreen() {
|
||||
super();
|
||||
@ -28,6 +29,7 @@ public class LoadingScreen extends Screen {
|
||||
@Override
|
||||
public void initialized() throws InterruptedException {
|
||||
previousZoomValue = StaticVars.windowZoomFunction.apply(StaticVars.windowZoom.getLastValue());
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().getHUD().hide();
|
||||
StaticVars.windowZoom.onNext(1f);
|
||||
}
|
||||
|
||||
@ -36,8 +38,10 @@ public class LoadingScreen extends Screen {
|
||||
loadingTextTranslation = GraphicUtils.sinDeg(endLoading * 90f) * 10f;
|
||||
|
||||
endLoading += dt;
|
||||
if (loaded && (Engine.getPlatform().getSettings().isDebugEnabled() || endLoading >= 3.5f)) {
|
||||
if (!ended && loaded && (Engine.getPlatform().getSettings().isDebugEnabled() || endLoading >= 3.5f)) {
|
||||
ended = true;
|
||||
StaticVars.windowZoom.onNext(previousZoomValue);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().getHUD().show();
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().setScreen(new MathInputScreen());
|
||||
}
|
||||
mustRefresh = true;
|
||||
@ -65,4 +69,9 @@ public class LoadingScreen extends Screen {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSessionTitle() {
|
||||
return "Loading...";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -197,4 +197,9 @@ public class MarioScreen extends Screen {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSessionTitle() {
|
||||
return "Absolutely not Super Mario";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
package it.cavallium.warppi.gui.screens;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.apache.commons.lang3.SerializationUtils;
|
||||
|
||||
import it.cavallium.warppi.Engine;
|
||||
import it.cavallium.warppi.Platform.ConsoleUtils;
|
||||
@ -27,6 +30,7 @@ import it.cavallium.warppi.math.MathematicalSymbols;
|
||||
import it.cavallium.warppi.math.functions.Expression;
|
||||
import it.cavallium.warppi.math.functions.Number;
|
||||
import it.cavallium.warppi.math.functions.Variable;
|
||||
import it.cavallium.warppi.math.functions.Variable.V_TYPE;
|
||||
import it.cavallium.warppi.math.functions.Variable.VariableValue;
|
||||
import it.cavallium.warppi.math.parser.MathParser;
|
||||
import it.cavallium.warppi.math.solver.MathSolver;
|
||||
@ -238,6 +242,7 @@ public class MathInputScreen extends Screen {
|
||||
// currentExpression = newExpression;
|
||||
// simplify();
|
||||
// });
|
||||
this.swapInputScreen();
|
||||
}
|
||||
} catch (final InterruptedException ex) {
|
||||
Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "Computing thread stopped.");
|
||||
@ -464,6 +469,24 @@ public class MathInputScreen extends Screen {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void swapInputScreen() {
|
||||
MathInputScreen mis = new MathInputScreen();
|
||||
mis.calc = SerializationUtils.clone(calc);
|
||||
mis.canBeInHistory = true;
|
||||
mis.currentStep = currentStep;
|
||||
mis.created = created;
|
||||
mis.d = d;
|
||||
mis.errorLevel = errorLevel;
|
||||
mis.ic = SerializationUtils.clone(ic);
|
||||
mis.initialized = initialized;
|
||||
mis.mustRefresh = true;
|
||||
mis.result = SerializationUtils.clone(result);
|
||||
mis.userInput = SerializationUtils.clone(userInput);
|
||||
mis.d = d;
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().setScreen(mis);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Deprecated
|
||||
private ObjectArrayList<Function> solveExpression(final ObjectArrayList<Function> f22) {
|
||||
@ -688,17 +711,8 @@ public class MathInputScreen extends Screen {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public MathInputScreen clone() {
|
||||
throw new UnsupportedOperationException();
|
||||
// final MathInputScreen es = this;
|
||||
// final MathInputScreen es2 = new MathInputScreen();
|
||||
// es2.errorLevel = es.errorLevel;
|
||||
// es2.mustRefresh = es.mustRefresh;
|
||||
// es2.calc = Utils.cloner.deepClone(es.calc);
|
||||
// es2.userInput = Utils.cloner.deepClone(es.userInput);
|
||||
// es2.result = Utils.cloner.deepClone(es.result);
|
||||
// return es2;
|
||||
public String getSessionTitle() {
|
||||
return "Calculator";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package it.cavallium.warppi.gui.screens;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import it.cavallium.warppi.event.KeyboardEventListener;
|
||||
import it.cavallium.warppi.event.TouchEventListener;
|
||||
import it.cavallium.warppi.gui.DisplayManager;
|
||||
@ -10,8 +12,13 @@ public abstract class Screen implements KeyboardEventListener, TouchEventListene
|
||||
public boolean created = false;
|
||||
public boolean initialized = false;
|
||||
public boolean canBeInHistory = false;
|
||||
|
||||
public static long lastDebugScreenID = 1;
|
||||
public final long debugScreenID;
|
||||
|
||||
public Screen() {}
|
||||
public Screen() {
|
||||
debugScreenID = lastDebugScreenID++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() throws InterruptedException {
|
||||
@ -46,4 +53,6 @@ public abstract class Screen implements KeyboardEventListener, TouchEventListene
|
||||
|
||||
@Override
|
||||
public abstract boolean mustBeRefreshed();
|
||||
|
||||
public abstract String getSessionTitle();
|
||||
}
|
||||
|
@ -67,4 +67,9 @@ public class SolveForXScreen extends Screen {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSessionTitle() {
|
||||
return "Solve for X";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package it.cavallium.warppi.math;
|
||||
|
||||
public enum AngleMode {
|
||||
import java.io.Serializable;
|
||||
|
||||
public enum AngleMode implements Serializable {
|
||||
DEG, RAD, GRA
|
||||
}
|
||||
|
@ -1,11 +1,13 @@
|
||||
package it.cavallium.warppi.math;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import it.cavallium.warppi.gui.expression.blocks.Block;
|
||||
import it.cavallium.warppi.math.rules.Rule;
|
||||
import it.cavallium.warppi.util.Error;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
|
||||
public interface Function {
|
||||
public interface Function extends Serializable {
|
||||
|
||||
/**
|
||||
* Returns this function and its children in a string form.
|
||||
|
@ -1,5 +1,9 @@
|
||||
package it.cavallium.warppi.math;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.lang3.SerializationUtils;
|
||||
|
||||
import it.cavallium.warppi.math.functions.Variable.VariableValue;
|
||||
import it.cavallium.warppi.math.rules.Rule;
|
||||
import it.cavallium.warppi.math.rules.RuleType;
|
||||
@ -7,7 +11,7 @@ import it.cavallium.warppi.math.rules.RulesManager;
|
||||
import it.cavallium.warppi.util.Error;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
|
||||
public class MathContext {
|
||||
public class MathContext implements Serializable {
|
||||
|
||||
public AngleMode angleMode = AngleMode.DEG;
|
||||
public boolean exactMode = false;
|
||||
@ -126,20 +130,6 @@ public class MathContext {
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public MathContext clone() {
|
||||
// MathContext mc = new MathContext();
|
||||
// mc.angleMode = this.angleMode;
|
||||
// mc.exactMode = this.exactMode;
|
||||
// mc.f = this.f;
|
||||
// mc.f2 = this.f2;
|
||||
// mc.variablesValues = this.variablesValues;
|
||||
// mc.resultsCount = this.resultsCount;
|
||||
// return mc;
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public ObjectArrayList<Rule> getAcceptableRules(final RuleType currentAcceptedRules) {
|
||||
return RulesManager.rules[currentAcceptedRules.ordinal()];
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package it.cavallium.warppi.math.functions;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import it.cavallium.warppi.gui.expression.blocks.Block;
|
||||
import it.cavallium.warppi.gui.expression.blocks.BlockChar;
|
||||
import it.cavallium.warppi.math.Function;
|
||||
@ -45,7 +47,8 @@ public class Variable implements Function {
|
||||
return "" + getChar();
|
||||
}
|
||||
|
||||
public static class VariableValue {
|
||||
public static class VariableValue implements Serializable {
|
||||
private static final long serialVersionUID = -5656281021874324571L;
|
||||
public final Variable v;
|
||||
public final Number n;
|
||||
|
||||
|
Binary file not shown.
@ -124,17 +124,19 @@ public class SwingRenderer implements Renderer {
|
||||
newColors[idx] = getSkinColorAt(currentSkin.skinData, skinIndex);
|
||||
}
|
||||
newColor = joinColors(newColors);
|
||||
if (transparent) {
|
||||
oldColor = SwingRenderer.canvas2d[index];
|
||||
final float a2 = (newColor >> 24 & 0xFF) / 255f;
|
||||
final float a1 = 1f - a2;
|
||||
final int r = (int) ((oldColor >> 16 & 0xFF) * a1 + (newColor >> 16 & 0xFF) * a2);
|
||||
final int g = (int) ((oldColor >> 8 & 0xFF) * a1 + (newColor >> 8 & 0xFF) * a2);
|
||||
final int b = (int) ((oldColor & 0xFF) * a1 + (newColor & 0xFF) * a2);
|
||||
newColor = 0xFF000000 | r << 16 | g << 8 | b;
|
||||
if (index >= 0 && index < SwingRenderer.canvas2d.length) {
|
||||
if (transparent) {
|
||||
oldColor = SwingRenderer.canvas2d[index];
|
||||
final float a2 = (newColor >> 24 & 0xFF) / 255f;
|
||||
final float a1 = 1f - a2;
|
||||
final int r = (int) ((oldColor >> 16 & 0xFF) * a1 + (newColor >> 16 & 0xFF) * a2);
|
||||
final int g = (int) ((oldColor >> 8 & 0xFF) * a1 + (newColor >> 8 & 0xFF) * a2);
|
||||
final int b = (int) ((oldColor & 0xFF) * a1 + (newColor & 0xFF) * a2);
|
||||
newColor = 0xFF000000 | r << 16 | g << 8 | b;
|
||||
}
|
||||
|
||||
SwingRenderer.canvas2d[index] = stackColors(SwingRenderer.canvas2d[index], newColor);
|
||||
}
|
||||
|
||||
SwingRenderer.canvas2d[index] = stackColors(SwingRenderer.canvas2d[index], newColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ public class SwingWindow extends JFrame {
|
||||
|
||||
@Override
|
||||
public void componentResized(final ComponentEvent e) {
|
||||
onResize.onNext(new Integer[] { getWidth(), getHeight() });
|
||||
onResize.onNext(new Integer[] { c.getWidth(), c.getHeight() });
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user