send poly regions to wecui, take 2
This commit is contained in:
@@ -150,8 +150,13 @@ public class CuboidRegionSelector implements RegionSelector, CUIPointBasedRegion
|
||||
return "cuboid";
|
||||
}
|
||||
|
||||
public Vector[] getCUIPoints() {
|
||||
return new Vector[] { pos1, pos2 };
|
||||
public void describeCUI(LocalPlayer player) {
|
||||
if (pos1 != null)
|
||||
player.dispatchCUIEvent(
|
||||
new SelectionPointEvent(0, pos1, getArea()));
|
||||
if (pos2 != null)
|
||||
player.dispatchCUIEvent(
|
||||
new SelectionPointEvent(1, pos2, getArea()));
|
||||
}
|
||||
|
||||
public int getArea() {
|
||||
|
||||
@@ -27,13 +27,18 @@ import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.cui.CUIPointBasedRegion;
|
||||
import com.sk89q.worldedit.cui.SelectionMinMaxEvent;
|
||||
import com.sk89q.worldedit.cui.SelectionPoint2DEvent;
|
||||
import com.sk89q.worldedit.cui.SelectionPointEvent;
|
||||
import com.sk89q.worldedit.cui.SelectionShapeEvent;
|
||||
|
||||
/**
|
||||
* Selector for polygonal regions.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class Polygonal2DRegionSelector implements RegionSelector {
|
||||
public class Polygonal2DRegionSelector implements RegionSelector, CUIPointBasedRegion {
|
||||
protected BlockVector pos1;
|
||||
protected Polygonal2DRegion region = new Polygonal2DRegion();
|
||||
|
||||
@@ -70,14 +75,23 @@ public class Polygonal2DRegionSelector implements RegionSelector {
|
||||
public void explainPrimarySelection(LocalPlayer player,
|
||||
LocalSession session, Vector pos) {
|
||||
player.print("Starting a new polygon at " + pos + ".");
|
||||
session.dispatchCUIEvent(player, new SelectionShapeEvent(getTypeId()));
|
||||
session.dispatchCUIEvent(player, new SelectionPoint2DEvent(0, pos, getArea()));
|
||||
session.dispatchCUIEvent(player, new SelectionMinMaxEvent(region.minY, region.maxY));
|
||||
}
|
||||
|
||||
public void explainSecondarySelection(LocalPlayer player,
|
||||
LocalSession session, Vector pos) {
|
||||
player.print("Added point #" + region.size() + " at " + pos + ".");
|
||||
session.dispatchCUIEvent(player,
|
||||
new SelectionPoint2DEvent(region.size() - 1, pos, getArea()));
|
||||
session.dispatchCUIEvent(player,
|
||||
new SelectionMinMaxEvent(region.minY, region.maxY));
|
||||
}
|
||||
|
||||
public void explainRegionAdjust(LocalPlayer player, LocalSession session) {
|
||||
session.dispatchCUIEvent(player,
|
||||
new SelectionMinMaxEvent(region.minY, region.maxY));
|
||||
}
|
||||
|
||||
public BlockVector getPrimaryPosition() throws IncompleteRegionException {
|
||||
@@ -136,4 +150,14 @@ public class Polygonal2DRegionSelector implements RegionSelector {
|
||||
return region.getPoints().size();
|
||||
}
|
||||
|
||||
public void describeCUI(LocalPlayer player) {
|
||||
List<BlockVector2D> points = region.getPoints();
|
||||
for (int id = 0; id < points.size(); id++) {
|
||||
player.dispatchCUIEvent(
|
||||
new SelectionPoint2DEvent(id, points.get(id), getArea()));
|
||||
}
|
||||
player.dispatchCUIEvent(
|
||||
new SelectionMinMaxEvent(region.minY, region.maxY));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user