Cleaned up; don't attempt to edit classes with no components; no need to
use the FrameManager and MediaPanel for displaying sprites since we're not doing things properly anyway (properly meaning using a sprite manager and all the associated business). git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1497 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,13 +1,11 @@
|
|||||||
//
|
//
|
||||||
// $Id: BuilderPanel.java,v 1.6 2002/04/23 01:17:28 mdb Exp $
|
// $Id: BuilderPanel.java,v 1.7 2002/06/19 23:24:04 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.cast.builder;
|
package com.threerings.cast.builder;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import com.samskivert.swing.*;
|
import com.samskivert.swing.*;
|
||||||
|
|
||||||
import com.threerings.media.FrameManager;
|
|
||||||
|
|
||||||
import com.threerings.cast.CharacterManager;
|
import com.threerings.cast.CharacterManager;
|
||||||
import com.threerings.cast.ComponentRepository;
|
import com.threerings.cast.ComponentRepository;
|
||||||
|
|
||||||
@@ -21,8 +19,8 @@ public class BuilderPanel extends JPanel
|
|||||||
/**
|
/**
|
||||||
* Constructs the builder panel.
|
* Constructs the builder panel.
|
||||||
*/
|
*/
|
||||||
public BuilderPanel (FrameManager framemgr, CharacterManager charmgr,
|
public BuilderPanel (CharacterManager charmgr,
|
||||||
ComponentRepository crepo)
|
ComponentRepository crepo, String cprefix)
|
||||||
{
|
{
|
||||||
setLayout(new VGroupLayout());
|
setLayout(new VGroupLayout());
|
||||||
|
|
||||||
@@ -37,8 +35,8 @@ public class BuilderPanel extends JPanel
|
|||||||
|
|
||||||
// create the component selection and sprite display panels
|
// create the component selection and sprite display panels
|
||||||
JPanel sub = new JPanel(gl);
|
JPanel sub = new JPanel(gl);
|
||||||
sub.add(new ComponentPanel(model));
|
sub.add(new ComponentPanel(model, cprefix));
|
||||||
sub.add(new SpritePanel(framemgr, charmgr, model));
|
sub.add(new SpritePanel(charmgr, model));
|
||||||
add(sub);
|
add(sub);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: ComponentPanel.java,v 1.6 2001/11/27 08:09:35 mdb Exp $
|
// $Id: ComponentPanel.java,v 1.7 2002/06/19 23:24:04 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.cast.builder;
|
package com.threerings.cast.builder;
|
||||||
|
|
||||||
@@ -24,27 +24,35 @@ public class ComponentPanel extends JPanel
|
|||||||
/**
|
/**
|
||||||
* Constructs the component panel.
|
* Constructs the component panel.
|
||||||
*/
|
*/
|
||||||
public ComponentPanel (BuilderModel model)
|
public ComponentPanel (BuilderModel model, String cprefix)
|
||||||
{
|
{
|
||||||
setLayout(new VGroupLayout(GroupLayout.STRETCH));
|
setLayout(new VGroupLayout(GroupLayout.STRETCH));
|
||||||
// set up a border
|
// set up a border
|
||||||
setBorder(BorderFactory.createEtchedBorder());
|
setBorder(BorderFactory.createEtchedBorder());
|
||||||
// add the component editors to the panel
|
// add the component editors to the panel
|
||||||
addClassEditors(model);
|
addClassEditors(model, cprefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds editor user interface elements for each component class to
|
* Adds editor user interface elements for each component class to
|
||||||
* allow the user to select the desired component.
|
* allow the user to select the desired component.
|
||||||
*/
|
*/
|
||||||
protected void addClassEditors (BuilderModel model)
|
protected void addClassEditors (BuilderModel model, String cprefix)
|
||||||
{
|
{
|
||||||
List classes = model.getComponentClasses();
|
List classes = model.getComponentClasses();
|
||||||
int size = classes.size();
|
int size = classes.size();
|
||||||
for (int ii = 0; ii < size; ii++) {
|
for (int ii = 0; ii < size; ii++) {
|
||||||
ComponentClass cclass = (ComponentClass)classes.get(ii);
|
ComponentClass cclass = (ComponentClass)classes.get(ii);
|
||||||
|
if (!cclass.name.startsWith(cprefix)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
List ccomps = model.getComponents(cclass);
|
List ccomps = model.getComponents(cclass);
|
||||||
add(new ClassEditor(model, cclass, ccomps));
|
if (ccomps.size() > 0) {
|
||||||
|
add(new ClassEditor(model, cclass, ccomps));
|
||||||
|
} else {
|
||||||
|
Log.info("Not creating editor for empty class " +
|
||||||
|
"[class=" + cclass + "].");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: SpritePanel.java,v 1.13 2002/04/23 01:17:28 mdb Exp $
|
// $Id: SpritePanel.java,v 1.14 2002/06/19 23:24:04 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.cast.builder;
|
package com.threerings.cast.builder;
|
||||||
|
|
||||||
@@ -9,10 +9,9 @@ import java.awt.Graphics;
|
|||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
|
|
||||||
import java.util.List;
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
import com.threerings.media.FrameManager;
|
import java.util.List;
|
||||||
import com.threerings.media.MediaPanel;
|
|
||||||
|
|
||||||
import com.threerings.util.DirectionCodes;
|
import com.threerings.util.DirectionCodes;
|
||||||
|
|
||||||
@@ -26,17 +25,14 @@ import com.threerings.cast.StandardActions;
|
|||||||
* The sprite panel displays a character sprite centered in the panel
|
* The sprite panel displays a character sprite centered in the panel
|
||||||
* suitable for user perusal.
|
* suitable for user perusal.
|
||||||
*/
|
*/
|
||||||
public class SpritePanel extends MediaPanel
|
public class SpritePanel extends JPanel
|
||||||
implements DirectionCodes, BuilderModelListener
|
implements DirectionCodes, BuilderModelListener
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Constructs the sprite panel.
|
* Constructs the sprite panel.
|
||||||
*/
|
*/
|
||||||
public SpritePanel (FrameManager framemgr, CharacterManager charmgr,
|
public SpritePanel (CharacterManager charmgr, BuilderModel model)
|
||||||
BuilderModel model)
|
|
||||||
{
|
{
|
||||||
super(framemgr);
|
|
||||||
|
|
||||||
// save off references
|
// save off references
|
||||||
_charmgr = charmgr;
|
_charmgr = charmgr;
|
||||||
_model = model;
|
_model = model;
|
||||||
@@ -47,17 +43,10 @@ public class SpritePanel extends MediaPanel
|
|||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
protected void paintMiddle (Graphics2D gfx, List invalidRects)
|
public void paintComponent (Graphics g)
|
||||||
{
|
{
|
||||||
// clear the background
|
super.paintComponent(g);
|
||||||
gfx.setColor(Color.lightGray);
|
Graphics2D gfx = (Graphics2D)g;
|
||||||
Dimension d = getSize();
|
|
||||||
gfx.fillRect(0, 0, d.width - 1, d.height - 1);
|
|
||||||
|
|
||||||
if (_sprite == null) {
|
|
||||||
// create the sprite if it's not yet extant
|
|
||||||
generateSprite();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_sprite != null) {
|
if (_sprite != null) {
|
||||||
// render the sprite
|
// render the sprite
|
||||||
@@ -66,9 +55,10 @@ public class SpritePanel extends MediaPanel
|
|||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
public void setBounds (Rectangle r)
|
public void doLayout ()
|
||||||
{
|
{
|
||||||
super.setBounds(r);
|
super.doLayout();
|
||||||
|
generateSprite();
|
||||||
centerSprite();
|
centerSprite();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user