Skip to content

Commit

Permalink
Add rudimentary support for images at compiletime
Browse files Browse the repository at this point in the history
  • Loading branch information
Frotty committed Jun 22, 2019
1 parent dde4f98 commit 438757f
Show file tree
Hide file tree
Showing 3 changed files with 141 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public ReflectionNativeProvider(AbstractInterpreter interpreter) {
addProvider(new DialogProvider(interpreter));
addProvider(new EffectProvider(interpreter));
addProvider(new RegionProvider(interpreter));
addProvider(new ImageProvider(interpreter));
}

public NativeJassFunction getFunctionPair(String funcName) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
package de.peeeq.wurstio.jassinterpreter.mocks;

import de.peeeq.wurstscript.intermediatelang.ILconstBool;
import de.peeeq.wurstscript.intermediatelang.ILconstInt;
import de.peeeq.wurstscript.intermediatelang.ILconstReal;
import de.peeeq.wurstscript.intermediatelang.ILconstString;

public class ImageMock {
private final ILconstString file;
private final ILconstReal sizeX;
private final ILconstReal sizeY;
private final ILconstReal sizeZ;
private ILconstReal posX;
private ILconstReal posY;
private ILconstReal posZ;
private final ILconstReal originX;
private final ILconstReal originY;
private final ILconstReal originZ;
private final ILconstInt imageType;

private ILconstBool shown = ILconstBool.FALSE;

public ImageMock(ILconstString file, ILconstReal sizeX, ILconstReal sizeY, ILconstReal sizeZ, ILconstReal posX, ILconstReal posY, ILconstReal posZ,
ILconstReal originX, ILconstReal originY, ILconstReal originZ, ILconstInt imageType) {

this.file = file;
this.sizeX = sizeX;
this.sizeY = sizeY;
this.sizeZ = sizeZ;
this.posX = posX;
this.posY = posY;
this.posZ = posZ;
this.originX = originX;
this.originY = originY;
this.originZ = originZ;
this.imageType = imageType;
}

public ILconstString getFile() {
return file;
}

public ILconstReal getSizeX() {
return sizeX;
}

public ILconstReal getSizeY() {
return sizeY;
}

public ILconstReal getSizeZ() {
return sizeZ;
}

public ILconstReal getPosX() {
return posX;
}

public ILconstReal getPosY() {
return posY;
}

public ILconstReal getPosZ() {
return posZ;
}

public ILconstReal getOriginX() {
return originX;
}

public ILconstReal getOriginY() {
return originY;
}

public ILconstReal getOriginZ() {
return originZ;
}

public ILconstInt getImageType() {
return imageType;
}

public ILconstBool isShown() {
return shown;
}

public void setShown(ILconstBool shown) {
this.shown = shown;
}

public void setPosition(ILconstReal x, ILconstReal y, ILconstReal z) {
this.posX = x;
this.posY = y;
this.posZ = z;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package de.peeeq.wurstio.jassinterpreter.providers;

import de.peeeq.wurstio.jassinterpreter.mocks.ImageMock;
import de.peeeq.wurstscript.intermediatelang.*;
import de.peeeq.wurstscript.intermediatelang.interpreter.AbstractInterpreter;

public class ImageProvider extends Provider {

public ImageProvider(AbstractInterpreter interpreter) {
super(interpreter);
}

public IlConstHandle CreateImage(ILconstString file, ILconstReal sizeX, ILconstReal sizeY, ILconstReal sizeZ, ILconstReal posX, ILconstReal posY,
ILconstReal posZ, ILconstReal originX, ILconstReal originY, ILconstReal originZ, ILconstInt imageType) {
return new IlConstHandle(NameProvider.getRandomName("image"), new ImageMock(file, sizeX, sizeY, sizeZ, posX, posY, posZ,
originX, originY, originZ, imageType));
}

public void DestroyImage(IlConstHandle image) {
}

public void ShowImage(IlConstHandle image, ILconstBool flag) {
ImageMock imageMock = (ImageMock) image.getObj();
imageMock.setShown(flag);
}

public void SetImagePosition(IlConstHandle image, ILconstReal x, ILconstReal y, ILconstReal z) {
ImageMock imageMock = (ImageMock) image.getObj();
imageMock.setPosition(x, y, z);
}

public void SetImageRender(IlConstHandle image, ILconstBool flag) {
}

public void SetImageRenderAlways(IlConstHandle image, ILconstBool flag) {
}

public void SetImageAboveWater(IlConstHandle image, ILconstBool flag, ILconstBool useWaterAlpha) {
}

public void SetImageType(IlConstHandle image, ILconstInt type) {
}

}

0 comments on commit 438757f

Please sign in to comment.