Skip to content

Commit

Permalink
Overrides and statics
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRamenChef committed Jun 13, 2019
1 parent edd0bfe commit 25ef97a
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 12 deletions.
1 change: 0 additions & 1 deletion utiliti/src/de/gurkenlabs/utiliti/components/Editor.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ public class Editor extends Screen {

private final List<Runnable> loadedCallbacks;

private double padding;
private MapComponent mapComponent;
private ResourceBundle gameFile = new ResourceBundle();
private String projectPath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private void updateSelectionColor() {
this.colorSelectionBorder = Color.getHSBColor(0, 0, this.selectionBorderBrightness);
}

private void renderObjectId(Graphics2D g, IMapObject mapObject) {
private static void renderObjectId(Graphics2D g, IMapObject mapObject) {
if (!Editor.preferences().renderMapIds()) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public AssetTree getAssetTree() {
return this.assetTree;
}

@Override
public void refresh() {
this.assetTree.forceUpdate();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ public void mouseClicked(MouseEvent e) {
this.add(this.searchPanel, BorderLayout.NORTH);
}

@Override
public void select(final IMapObject mapObject) {
if (this.isFocussing) {
return;
Expand Down Expand Up @@ -235,6 +236,7 @@ public void select(final IMapObject mapObject) {
}
}

@Override
public void refresh() {
this.nodeRoot.setUserObject(new IconTreeListItem((Game.world().environment() == null ? 0 : Game.world().environment().getEntities().size()) + " " + Resources.strings().get("panel_mapselection_entities"), Icons.FOLDER));
for (DefaultMutableTreeNode node : this.entityNodes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public LayerList() {
if (selIndex < 0 || selIndex >= this.layerModel.size()) {
map.addLayer(layer);
} else {
map.addLayer(this.getAbsoluteIndex(map, this.getCurrentLayerIndex()), layer);
map.addLayer(getAbsoluteIndex(map, this.getCurrentLayerIndex()), layer);
}

this.list.setSelectedIndex(selIndex);
Expand All @@ -110,7 +110,7 @@ public LayerList() {

this.buttonDuplicateLayer = createButton(Icons.COPYX16, (map, selectedLayer) -> {
IMapObjectLayer copiedLayer = new MapObjectLayer((MapObjectLayer) selectedLayer);
map.addLayer(this.getAbsoluteIndex(map, this.getCurrentLayerIndex()), copiedLayer);
map.addLayer(getAbsoluteIndex(map, this.getCurrentLayerIndex()), copiedLayer);
this.refresh();
Editor.instance().getMapComponent().add(copiedLayer);
});
Expand Down Expand Up @@ -152,7 +152,7 @@ public LayerList() {
}

map.removeLayer(selectedLayer);
map.addLayer(this.getAbsoluteIndex(map, selLayerIndex), selectedLayer);
map.addLayer(getAbsoluteIndex(map, selLayerIndex), selectedLayer);
this.list.setSelectedIndex(selLayerIndex + 1);
});

Expand All @@ -163,7 +163,7 @@ public LayerList() {
}

map.removeLayer(selectedLayer);
map.addLayer(this.getAbsoluteIndex(map, selLayerIndex - 2), selectedLayer);
map.addLayer(getAbsoluteIndex(map, selLayerIndex - 2), selectedLayer);
this.list.setSelectedIndex(selLayerIndex - 1);
});

Expand Down Expand Up @@ -194,6 +194,7 @@ public LayerList() {
});
}

@Override
public IMapObjectLayer getCurrentLayer() {
JCheckBox current = this.list.getSelectedValue();
if (current == null) {
Expand Down Expand Up @@ -221,10 +222,12 @@ public void selectLayer(int index) {
this.list.setSelectedIndex(index);
}

@Override
public void clear() {
this.selectedLayers.clear();
}

@Override
public void refresh() {
this.refreshing = true;
try {
Expand Down Expand Up @@ -281,6 +284,7 @@ public void refresh() {
}
}

@Override
public void onLayersChanged(Consumer<IMap> consumer) {
this.layerChangedListeners.add(consumer);
}
Expand Down Expand Up @@ -332,7 +336,7 @@ private int getCurrentLayerIndex() {
return this.list.getModel().getSize() - 1 - this.list.getSelectedIndex();
}

private int getAbsoluteIndex(IMap map, int index) {
private static int getAbsoluteIndex(IMap map, int index) {
if (map.getMapObjectLayers().size() <= 1) {
return 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,12 @@ public MapList() {
UndoManager.onUndoStackChanged(manager -> this.bind(Editor.instance().getMapComponent().getMaps()));
}

@Override
public synchronized void bind(List<TmxMap> maps) {
this.bind(maps, false);
}

@Override
public synchronized void bind(List<TmxMap> maps, boolean clear) {
if (clear) {
this.model.clear();
Expand Down Expand Up @@ -100,6 +102,7 @@ public synchronized void bind(List<TmxMap> maps, boolean clear) {
this.refresh();
}

@Override
public void setSelection(String mapName) {
if (mapName == null || mapName.isEmpty()) {
list.clearSelection();
Expand All @@ -112,13 +115,15 @@ public void setSelection(String mapName) {
this.refresh();
}

@Override
public IMap getCurrentMap() {
if (this.list.getSelectedIndex() == -1) {
return null;
}
return Editor.instance().getMapComponent().getMaps().get(list.getSelectedIndex());
}

@Override
public void refresh() {
if (list.getSelectedIndex() == -1 && this.model.size() > 0) {
this.list.setSelectedIndex(0);
Expand Down
4 changes: 2 additions & 2 deletions utiliti/src/de/gurkenlabs/utiliti/swing/menus/RenderMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private void updateMenu(List<IMapObject> selectedMapObjects) {
this.setEnabled(true);
}

private void setRenderWithLayer(List<IMapObject> selectedMapObjects) {
private static void setRenderWithLayer(List<IMapObject> selectedMapObjects) {
UndoManager.instance().beginOperation();
for (IMapObject object : selectedMapObjects) {
UndoManager.instance().mapObjectChanging(object);
Expand All @@ -87,7 +87,7 @@ private void setRenderWithLayer(List<IMapObject> selectedMapObjects) {
UI.getInspector().bind(Editor.instance().getMapComponent().getFocusedMapObject());
}

private void setRenderType(List<IMapObject> selectedMapObjects, RenderType renderType) {
private static void setRenderType(List<IMapObject> selectedMapObjects, RenderType renderType) {
UndoManager.instance().beginOperation();
for (IMapObject object : selectedMapObjects) {
UndoManager.instance().mapObjectChanging(object);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ protected void clearControls() {
}


@Override
protected void setControlValues(IMapObject mapObject) {
this.comboBoxColl.setSelectedItem(mapObject.getEnumValue(MapObjectProperty.COLLISION_TYPE, Collision.class, Collision.STATIC));
this.chckbxIsObstructingLights.setSelected(mapObject.getBoolValue(MapObjectProperty.COLLISIONBOX_OBSTRUCTINGLIGHTS));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ public void updateSpinnerModels() {
}
}

@Override
public MapObjectType getObjectType() {
return this.type;
}
Expand Down Expand Up @@ -256,6 +257,7 @@ private void switchPanel() {
this.tabbedPanel.repaint();
}

@Override
public void setMapObjectType(MapObjectType type) {
this.type = type;
switchPanel();
Expand Down Expand Up @@ -292,15 +294,15 @@ protected void setControlValues(IMapObject mapObject) {
this.labelEntityID.setText(Integer.toString(mapObject.getId()));

this.lblLayer.setText("layer: " + mapObject.getLayer().getName());
String info = this.getRendering(mapObject);
String info = getRendering(mapObject);
if (info == null) {
this.lblRendering.setText("");
} else {
this.lblRendering.setText("render: " + this.getRendering(mapObject));
this.lblRendering.setText("render: " + getRendering(mapObject));
}
}

private String getRendering(IMapObject mapObject) {
private static String getRendering(IMapObject mapObject) {
switch (MapObjectType.get(mapObject.getType())) {
case PROP:
case EMITTER:
Expand Down

0 comments on commit 25ef97a

Please sign in to comment.