initFonts();
fSW = fGame.application().getWidth();
fSH = fGame.application().getHeight();
fTopBar = new Sprite("editor/topbar");
fTopBar.resize(new Vector2f(fSW, 28));
fTitle = new TextEntity("Dizgruntled Level Editor", TextEntity.ALIGN_LEFT, sFont, new Color(255, 220, 50));
fTitle.position(new Vector2f(5, 13));
fSave = new SaveButton();
fSave.position(new Vector2f(192, 8));
fLinks = new EntityQuery<Hyperlink>();
addChild(fLinks.add(new Hyperlink("Level", "level", sFont, true)).position(new Vector2f(210, 4)), 104);
addChild(fLinks.add(new Hyperlink("Tiles", "tiles", sFont)).position(new Vector2f(255, 4)), 105);
addChild(fLinks.add(new Hyperlink("Smarts", "smarts", sFont)).position(new Vector2f(297, 4)), 106);
addChild(fLinks.add(new Hyperlink("Logics", "logics", sFont)).position(new Vector2f(358, 4)), 107);
Minion<IEvent> clicker = new Minion<IEvent>() {
@Override
public long run(Dispatcher<IEvent> dispatcher, String type, IEvent event) {
if (!(event instanceof HyperlinkEvent)) return Minion.CONTINUE;
HyperlinkEvent ev = (HyperlinkEvent) event;
for (Hyperlink h: fLinks) if (!h.equals(ev.hyperlink())) h.deselect();
boolean showLogics = false;
boolean showCursor = false;
if (fAniCursor != null) {
fAniCursor.cleanup();
fAniCursor = null;
}
// Create correct side bar
if (ev.href().equals("level")) {
LevelSideBar s = new LevelSideBar();
setSideContainer(s);
s.init();
showLogics = true;
} else if (ev.href().equals("tiles")) {
TilesSideBar s = new TilesSideBar();
setSideContainer(s);
s.init();
showCursor = true;
} else if (ev.href().equals("smarts")) {
SmartsSideBar s = new SmartsSideBar();
setSideContainer(s);
s.init();
showCursor = true;
} else if (ev.href().equals("logics")) {
ObjectSideBar s = new ObjectSideBar();
setSideContainer(s);
s.init();
if (fSelectedLogic != null) s.editLogic(fSelectedLogic);
showLogics = true;
}
if (showLogics) fMapViewer.showLogics();
else fMapViewer.hideLogics();
if (showCursor) addChild(fCursor, 20);
else removeChild(fCursor);
return Minion.CONTINUE;
}
};
for (Hyperlink h: fLinks) h.dispatcher().addMinion("hyperlink", clicker);
fSideBar = new Sprite("editor/sidebar");
fSideBar.position(new Vector2f(fSW - 164, 28));
fSideBar.resize(new Vector2f(164, fSH - 28));
addChild(fTopBar, 100);
addChild(fTitle, 101);
addChild(fSave, 102);
addChild(fSideBar, 103);
fMapManager.importLevel(GruntzGame.resourceManager().rez().file("AREA1/WORLDZ/LEVEL1", "wwd"));
// Scroll bars
fScrollX = new ScrollBar(new Minion<SelectionEvent>(){
@Override
public long run(Dispatcher<SelectionEvent> dispatcher, String type, SelectionEvent event) {
fMapViewer.offset(new Vector2f(16 - event.value(), fMapViewer.offset().y));
return Minion.CONTINUE;
}
}, false);
fScrollX.resize(new Vector2f(fSW - 176, 12));
fScrollX.position(new Vector2f(0, fSH - 12));
fScrollX.barSpan(fSW - 176);
addChild(fScrollX, 104);
fScrollY = new ScrollBar(new Minion<SelectionEvent>() {
@Override
public long run(Dispatcher<SelectionEvent> dispatcher, String type, SelectionEvent event) {
fMapViewer.offset(new Vector2f(fMapViewer.offset().x, 16 - event.value()));
return Minion.CONTINUE;
}
}, true);
fScrollY.resize(new Vector2f(12, fSH - 40));
fScrollY.position(new Vector2f(fSW - 176, 28));
fScrollY.barSpan(fSH - 44);
addChild(fScrollY, 105);
try {
fCursor = new Sprite(new Image(0, 0)) {
/**
* Serial Key
*/
private static final long serialVersionUID = 1L;