Add a new wacky feature to the editor - ctrl-clicking in add tile mode will select the tile you've clicked on as the new selected tile for future placement.
git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@977 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -525,6 +525,11 @@ public class EditorFrame extends ManagedJFrame
|
|||||||
_svpanel.redo();
|
_svpanel.redo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateTileInfo ()
|
||||||
|
{
|
||||||
|
_tpanel.updateTileTable();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles a request to open the preferences dialog.
|
* Handles a request to open the preferences dialog.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -334,6 +334,20 @@ public class EditorScenePanel extends StageScenePanel
|
|||||||
EditorDialogUtil.display(_frame, _objEditor);
|
EditorDialogUtil.display(_frame, _objEditor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void selectTile (int x, int y)
|
||||||
|
{
|
||||||
|
// bail if we're not hovering over a scene object
|
||||||
|
if (_hobject == null || !(_hobject instanceof SceneObject)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SceneObject scObj = (SceneObject)_hobject;
|
||||||
|
int tileSetId = TileUtil.getTileSetId(scObj.info.tileId);
|
||||||
|
int tileIndex = TileUtil.getTileIndex(scObj.info.tileId);
|
||||||
|
_emodel.setTile(scObj.tile.key.tileSet, tileSetId, tileIndex);
|
||||||
|
_emodel.setLayerIndex(EditorModel.OBJECT_LAYER);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by the {@link ObjectEditorDialog} when it is dismissed.
|
* Called by the {@link ObjectEditorDialog} when it is dismissed.
|
||||||
*/
|
*/
|
||||||
@@ -459,8 +473,14 @@ public class EditorScenePanel extends StageScenePanel
|
|||||||
case EditorModel.ACTION_PLACE_TILE:
|
case EditorModel.ACTION_PLACE_TILE:
|
||||||
switch (e.getButton()) {
|
switch (e.getButton()) {
|
||||||
case MouseEvent.BUTTON1:
|
case MouseEvent.BUTTON1:
|
||||||
placeTile(tc.x, tc.y);
|
if ((e.getModifiers() & MouseEvent.CTRL_MASK) != 0) {
|
||||||
_refreshBox = true;
|
// They've got ctrl down, let's select that tile instead.
|
||||||
|
clearTileSelectRegion(tc.x, tc.y);
|
||||||
|
selectTile(tc.x, tc.y);
|
||||||
|
} else {
|
||||||
|
placeTile(tc.x, tc.y);
|
||||||
|
_refreshBox = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MouseEvent.BUTTON2:
|
case MouseEvent.BUTTON2:
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ import static com.threerings.stage.Log.log;
|
|||||||
* tile to be applied to the scene.
|
* tile to be applied to the scene.
|
||||||
*/
|
*/
|
||||||
public class TileInfoPanel extends JSplitPane
|
public class TileInfoPanel extends JSplitPane
|
||||||
implements ListSelectionListener, TreeSelectionListener
|
implements ListSelectionListener, TreeSelectionListener, EditorModelListener
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Constructs the tile info panel.
|
* Constructs the tile info panel.
|
||||||
@@ -92,6 +92,7 @@ public class TileInfoPanel extends JSplitPane
|
|||||||
registerKeyListener(ctx);
|
registerKeyListener(ctx);
|
||||||
|
|
||||||
_model = model;
|
_model = model;
|
||||||
|
_model.addListener(this);
|
||||||
_ctx = ctx;
|
_ctx = ctx;
|
||||||
|
|
||||||
// we're going to sort all of the available tilesets into those
|
// we're going to sort all of the available tilesets into those
|
||||||
@@ -110,7 +111,8 @@ public class TileInfoPanel extends JSplitPane
|
|||||||
// determine which layer to which this tileset applies
|
// determine which layer to which this tileset applies
|
||||||
int lidx = TileSetUtil.getLayerIndex(set);
|
int lidx = TileSetUtil.getLayerIndex(set);
|
||||||
if (lidx != -1) {
|
if (lidx != -1) {
|
||||||
_layerSets.get(lidx).add(new TileSetRecord(lidx, tsid.intValue(), set));
|
TileSetRecord rec = new TileSetRecord(lidx, tsid.intValue(), set);
|
||||||
|
_layerSets.get(lidx).add(rec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,6 +197,19 @@ public class TileInfoPanel extends JSplitPane
|
|||||||
setDividerLocation(230);
|
setDividerLocation(230);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// documentation inherited
|
||||||
|
public void modelChanged (int event)
|
||||||
|
{
|
||||||
|
if (event == TILE_CHANGED && !_settingTileOurselves) {
|
||||||
|
updateTileTable();
|
||||||
|
|
||||||
|
// Find the selected tileset and select it.
|
||||||
|
TreePath path = _idToTreePathMap.get(_model.getTileSetId());
|
||||||
|
_tsettree.setSelectionPath(path);
|
||||||
|
_tsettree.scrollPathToVisible(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register key listeners to do things with the quick list.
|
* Register key listeners to do things with the quick list.
|
||||||
*/
|
*/
|
||||||
@@ -300,7 +315,9 @@ public class TileInfoPanel extends JSplitPane
|
|||||||
|
|
||||||
// update the model to reflect new tile set and select tile
|
// update the model to reflect new tile set and select tile
|
||||||
// zero by default
|
// zero by default
|
||||||
|
_settingTileOurselves = true;
|
||||||
_model.setTile(trec.tileSet, trec.tileSetId, 0);
|
_model.setTile(trec.tileSet, trec.tileSetId, 0);
|
||||||
|
_settingTileOurselves = false;
|
||||||
|
|
||||||
// update the tile table to reflect the new tileset
|
// update the tile table to reflect the new tileset
|
||||||
updateTileTable();
|
updateTileTable();
|
||||||
@@ -342,7 +359,8 @@ public class TileInfoPanel extends JSplitPane
|
|||||||
int lidx = TileSetUtil.getLayerIndex(set);
|
int lidx = TileSetUtil.getLayerIndex(set);
|
||||||
if (lidx != -1) {
|
if (lidx != -1) {
|
||||||
// make up a negative number to refer to this temporary tileset
|
// make up a negative number to refer to this temporary tileset
|
||||||
_layerSets.get(lidx).add(new TileSetRecord(lidx, tsid, set));
|
TileSetRecord rec = new TileSetRecord(lidx, tsid, set);
|
||||||
|
_layerSets.get(lidx).add(rec);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tileMgr instanceof EditorTileManager) {
|
if (tileMgr instanceof EditorTileManager) {
|
||||||
@@ -359,6 +377,7 @@ public class TileInfoPanel extends JSplitPane
|
|||||||
*/
|
*/
|
||||||
public void updateTileSetTree ()
|
public void updateTileSetTree ()
|
||||||
{
|
{
|
||||||
|
_idToTreePathMap.clear();
|
||||||
// first clear out the tree
|
// first clear out the tree
|
||||||
DefaultTreeModel model = (DefaultTreeModel) _tsettree.getModel();
|
DefaultTreeModel model = (DefaultTreeModel) _tsettree.getModel();
|
||||||
DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
|
DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
|
||||||
@@ -448,6 +467,8 @@ public class TileInfoPanel extends JSplitPane
|
|||||||
_selected = item;
|
_selected = item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_idToTreePathMap.put(list[ii].tileSetId, new TreePath(item.getPath()));
|
||||||
|
|
||||||
ii++;
|
ii++;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -537,7 +558,9 @@ public class TileInfoPanel extends JSplitPane
|
|||||||
// otherwise they clicked on the tile table.
|
// otherwise they clicked on the tile table.
|
||||||
ListSelectionModel lsm = (ListSelectionModel) src;
|
ListSelectionModel lsm = (ListSelectionModel) src;
|
||||||
if (!lsm.isSelectionEmpty()) {
|
if (!lsm.isSelectionEmpty()) {
|
||||||
|
_settingTileOurselves = true;
|
||||||
_model.setTileId(lsm.getMinSelectionIndex());
|
_model.setTileId(lsm.getMinSelectionIndex());
|
||||||
|
_settingTileOurselves = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -711,6 +734,9 @@ public class TileInfoPanel extends JSplitPane
|
|||||||
/** An ArrayList of TileSetRecords for each layer. */
|
/** An ArrayList of TileSetRecords for each layer. */
|
||||||
protected Map<Integer,List<TileSetRecord>> _layerSets = Maps.newHashMap();
|
protected Map<Integer,List<TileSetRecord>> _layerSets = Maps.newHashMap();
|
||||||
|
|
||||||
|
/** Map of tileset ID to TreePath. */
|
||||||
|
protected Map<Integer, TreePath> _idToTreePathMap = Maps.newHashMap();
|
||||||
|
|
||||||
/** The original number of TileSetRecords for each layer. */
|
/** The original number of TileSetRecords for each layer. */
|
||||||
protected int[] _layerLengths;
|
protected int[] _layerLengths;
|
||||||
|
|
||||||
@@ -743,4 +769,6 @@ public class TileInfoPanel extends JSplitPane
|
|||||||
|
|
||||||
/** The tile table data model. */
|
/** The tile table data model. */
|
||||||
protected TileTableModel _tablemodel;
|
protected TileTableModel _tablemodel;
|
||||||
|
|
||||||
|
protected boolean _settingTileOurselves;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user