Add right click editor removal
Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com> Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
cd993296e6
commit
65d7ed8cce
Binary file not shown.
@ -62,7 +62,7 @@ public class KeyBind {
|
|||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
if (RabiClone.CONTROLLERS.length>port && id instanceof Identifier.Axis) {
|
if (RabiClone.CONTROLLERS.length>port && id instanceof Identifier.Axis) {
|
||||||
return Math.abs(RabiClone.CONTROLLERS[port].getComponent(id).getPollData())>=RabiClone.CONTROLLERS[port].getComponent(id).getDeadZone()&&Math.signum(RabiClone.CONTROLLERS[port].getComponent(id).getPollData())==Math.signum(val);
|
return Math.abs(RabiClone.CONTROLLERS[port].getComponent(id).getPollData())>=Math.max(RabiClone.CONTROLLERS[port].getComponent(id).getDeadZone(),0.2)&&Math.signum(RabiClone.CONTROLLERS[port].getComponent(id).getPollData())==Math.signum(val);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return false;
|
return false;
|
||||||
|
10
src/sig/events/DataEvent.java
Normal file
10
src/sig/events/DataEvent.java
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package sig.events;
|
||||||
|
|
||||||
|
public class DataEvent implements Event{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean perform(int x, int y) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,9 +1,6 @@
|
|||||||
package sig.events;
|
package sig.events;
|
||||||
|
|
||||||
import sig.engine.String;
|
|
||||||
|
|
||||||
public interface Event{
|
public interface Event{
|
||||||
public String getDescription();
|
|
||||||
/**
|
/**
|
||||||
* Perform this event at position {@code (x,y)}.
|
* Perform this event at position {@code (x,y)}.
|
||||||
* @return {@code True} to keep this event alive after it runs.
|
* @return {@code True} to keep this event alive after it runs.
|
||||||
|
@ -3,23 +3,15 @@ package sig.events;
|
|||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
||||||
import sig.RabiClone;
|
import sig.RabiClone;
|
||||||
import sig.engine.String;
|
|
||||||
import sig.engine.objects.Object;
|
import sig.engine.objects.Object;
|
||||||
import sig.map.Tile;
|
import sig.map.Tile;
|
||||||
|
|
||||||
public class SpawnEvent implements Event{
|
public class SpawnEvent implements Event{
|
||||||
|
|
||||||
Class<?> entity;
|
Class<?> entity;
|
||||||
String description;
|
|
||||||
|
|
||||||
public SpawnEvent(java.lang.String description,Class<?> o) {
|
public SpawnEvent(Class<?> o) {
|
||||||
this.entity=o;
|
this.entity=o;
|
||||||
this.description=new String(description);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
13
src/sig/events/WaterEvent.java
Normal file
13
src/sig/events/WaterEvent.java
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package sig.events;
|
||||||
|
|
||||||
|
import sig.RabiClone;
|
||||||
|
|
||||||
|
public class WaterEvent implements Event{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean perform(int x, int y) {
|
||||||
|
RabiClone.CURRENT_MAP.getMap().setWaterLevel(RabiClone.CURRENT_MAP.getMap().getDataTileValue(x+1, y));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,8 +1,10 @@
|
|||||||
package sig.map;
|
package sig.map;
|
||||||
|
|
||||||
import sig.engine.String;
|
import sig.engine.String;
|
||||||
|
import sig.events.DataEvent;
|
||||||
import sig.events.Event;
|
import sig.events.Event;
|
||||||
import sig.events.SpawnEvent;
|
import sig.events.SpawnEvent;
|
||||||
|
import sig.events.WaterEvent;
|
||||||
import sig.objects.enemies.BlueBun;
|
import sig.objects.enemies.BlueBun;
|
||||||
import sig.objects.Erinoah;
|
import sig.objects.Erinoah;
|
||||||
import sig.objects.enemies.GreenBun;
|
import sig.objects.enemies.GreenBun;
|
||||||
@ -11,11 +13,13 @@ import sig.objects.enemies.YellowBun;
|
|||||||
|
|
||||||
public enum DataTile {
|
public enum DataTile {
|
||||||
NULL, //File is populated by 0s by default. This represents nothing.
|
NULL, //File is populated by 0s by default. This represents nothing.
|
||||||
BUN0(new SpawnEvent("Spawns an Erinoa bun",Erinoah.class)),
|
BUN0("Spawns an Erinoa bun",new SpawnEvent(Erinoah.class)),
|
||||||
BUN1(new SpawnEvent("Spawns a red bun",RedBun.class)),
|
BUN1("Spawns a red bun",new SpawnEvent(RedBun.class)),
|
||||||
BUN2(new SpawnEvent("Spawns a blue bun",BlueBun.class)),
|
BUN2("Spawns a blue bun",new SpawnEvent(BlueBun.class)),
|
||||||
BUN3(new SpawnEvent("Spawns a yellow bun",YellowBun.class)),
|
BUN3("Spawns a yellow bun",new SpawnEvent(YellowBun.class)),
|
||||||
BUN4(new SpawnEvent("Spawns a green bun",GreenBun.class));
|
BUN4("Spawns a green bun",new SpawnEvent(GreenBun.class)),
|
||||||
|
WATERLEVEL("Sets the water level according to the data tile at X+1",new WaterEvent()),
|
||||||
|
DATATILE("Uses a value between 32768-65536 to represent extra data.",new DataEvent());
|
||||||
|
|
||||||
String description;
|
String description;
|
||||||
Event event;
|
Event event;
|
||||||
@ -23,8 +27,8 @@ public enum DataTile {
|
|||||||
DataTile(){
|
DataTile(){
|
||||||
this.description=new String("");
|
this.description=new String("");
|
||||||
}
|
}
|
||||||
DataTile(Event e) {
|
DataTile(java.lang.String description,Event e) {
|
||||||
this.description=e.getDescription();
|
this.description=new String(description);
|
||||||
this.event=e;
|
this.event=e;
|
||||||
}
|
}
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
|
@ -37,6 +37,8 @@ public class Map {
|
|||||||
byte[] types = new byte[MAP_SCREENS_X*MAP_SCREENS_Y];
|
byte[] types = new byte[MAP_SCREENS_X*MAP_SCREENS_Y];
|
||||||
char[] data = new char[MAP_WIDTH*MAP_HEIGHT];
|
char[] data = new char[MAP_WIDTH*MAP_HEIGHT];
|
||||||
|
|
||||||
|
char waterLevel = 144;
|
||||||
|
|
||||||
int eventTileCount=0;
|
int eventTileCount=0;
|
||||||
|
|
||||||
final static byte MAP_DATA = 0;
|
final static byte MAP_DATA = 0;
|
||||||
@ -238,4 +240,23 @@ public class Map {
|
|||||||
data[y*Map.MAP_WIDTH+x]=(char)(t.ordinal());
|
data[y*Map.MAP_WIDTH+x]=(char)(t.ordinal());
|
||||||
//System.out.println("Tile "+(y*MAP_WIDTH+x)+" is now "+tiles[y*MAP_WIDTH+x]+".");
|
//System.out.println("Tile "+(y*MAP_WIDTH+x)+" is now "+tiles[y*MAP_WIDTH+x]+".");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public char getWaterLevel() {
|
||||||
|
return waterLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWaterLevel(char waterLevel) {
|
||||||
|
this.waterLevel = waterLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This will return the tile's value minus 32768.
|
||||||
|
* This value represents a data tile value, but not
|
||||||
|
* necessarily a data tile.
|
||||||
|
*/
|
||||||
|
public char getDataTileValue(int x,int y) {
|
||||||
|
return (char)(data[y*Map.MAP_WIDTH+x]-32768);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,10 @@ public class EditorRenderer extends LevelRenderer{
|
|||||||
final static char CAMERA_SPD = 512;
|
final static char CAMERA_SPD = 512;
|
||||||
|
|
||||||
boolean dataTileView=false;
|
boolean dataTileView=false;
|
||||||
|
boolean inputDataTileValue=false;
|
||||||
|
char dataTileValue=0;
|
||||||
|
|
||||||
|
String inputMessageLogDisplay = new String();
|
||||||
|
|
||||||
public EditorRenderer(Panel panel) {
|
public EditorRenderer(Panel panel) {
|
||||||
super(panel);
|
super(panel);
|
||||||
@ -58,19 +62,33 @@ public class EditorRenderer extends LevelRenderer{
|
|||||||
if (up-down!=0) {
|
if (up-down!=0) {
|
||||||
setY(Math.max(0,getY()+(down-up)*CAMERA_SPD*updateMult));
|
setY(Math.max(0,getY()+(down-up)*CAMERA_SPD*updateMult));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!inputDataTileValue) {
|
||||||
boolean left_mb = MouseHeld(MouseEvent.BUTTON1);
|
boolean left_mb = MouseHeld(MouseEvent.BUTTON1);
|
||||||
// boolean middle_mb = MouseHeld(MouseEvent.BUTTON2);
|
// boolean middle_mb = MouseHeld(MouseEvent.BUTTON2);
|
||||||
// boolean right_mb = MouseHeld(MouseEvent.BUTTON3);
|
boolean right_mb = MouseHeld(MouseEvent.BUTTON3);
|
||||||
|
|
||||||
if(left_mb){
|
if(left_mb){
|
||||||
int tileX = (int)(RabiClone.MOUSE_POS.getX()+getX())/Tile.TILE_WIDTH;
|
int tileX = (int)(RabiClone.MOUSE_POS.getX()+getX())/Tile.TILE_WIDTH;
|
||||||
int tileY = (int)(RabiClone.MOUSE_POS.getY()+getY())/Tile.TILE_HEIGHT;
|
int tileY = (int)(RabiClone.MOUSE_POS.getY()+getY())/Tile.TILE_HEIGHT;
|
||||||
if (dataTileView) {
|
if (dataTileView) {
|
||||||
RabiClone.CURRENT_MAP.ModifyDataTile(tileX, tileY, selectedDataTile);
|
RabiClone.CURRENT_MAP.ModifyDataTile(tileX, tileY, selectedDataTile);
|
||||||
|
if (selectedDataTile==DataTile.DATATILE) {
|
||||||
|
inputDataTileValue=true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
RabiClone.CURRENT_MAP.ModifyTile(tileX, tileY, selectedTile);
|
RabiClone.CURRENT_MAP.ModifyTile(tileX, tileY, selectedTile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (right_mb) {
|
||||||
|
int tileX = (int)(RabiClone.MOUSE_POS.getX()+getX())/Tile.TILE_WIDTH;
|
||||||
|
int tileY = (int)(RabiClone.MOUSE_POS.getY()+getY())/Tile.TILE_HEIGHT;
|
||||||
|
if (dataTileView) {
|
||||||
|
RabiClone.CURRENT_MAP.ModifyDataTile(tileX, tileY, DataTile.NULL);
|
||||||
|
} else {
|
||||||
|
RabiClone.CURRENT_MAP.ModifyTile(tileX, tileY, Tile.VOID);
|
||||||
|
}
|
||||||
|
}
|
||||||
if(KeyHeld(Action.SLIDE)&&KeyHeld(Action.FALL)){
|
if(KeyHeld(Action.SLIDE)&&KeyHeld(Action.FALL)){
|
||||||
AddMessage("Saving map...");
|
AddMessage("Saving map...");
|
||||||
try {
|
try {
|
||||||
@ -81,6 +99,7 @@ public class EditorRenderer extends LevelRenderer{
|
|||||||
AddMessage(PaletteColor.RED,"Map failed to save: ",e.getLocalizedMessage());
|
AddMessage(PaletteColor.RED,"Map failed to save: ",e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
updateMessageLog();
|
updateMessageLog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user