Switched (partially) to Maven-based dependency resolution. Further work

forthcoming to fix up the tests.

Peskily, it looks like I'm going to have to take one for the team and become
the maintainer of a Maven artifact for LWJGL. In spite of repeated requests
over the years for Mavenized artifacts for LWJGL, Mazon resists it (he seems to
think he has to use Maven to *build* LWJGL, which he certainly need not do).
There have been a variety of half-assed attempts to maintain third-party Maven
repositories, all of which have petered out a major version or two ago.


git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@1045 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Michael Bayne
2010-11-08 18:51:32 +00:00
parent f1a2fe5e81
commit 63a26726d1
32 changed files with 327 additions and 192 deletions
@@ -0,0 +1,155 @@
//
// $Id: CharSpriteViz.java 3355 2005-02-17 01:54:54Z mdb $
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2010 Three Rings Design, Inc., All Rights Reserved
// http://www.threerings.net/code/narya/
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.threerings.cast;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import javax.swing.JFrame;
import javax.swing.JPanel;
import com.samskivert.swing.util.SwingUtil;
import com.threerings.util.DirectionCodes;
import com.threerings.util.DirectionUtil;
import com.threerings.resource.ResourceManager;
import com.threerings.media.image.ClientImageManager;
import com.threerings.cast.bundle.BundledComponentRepository;
/**
* Displays a character sprite in all of the various orientations.
*/
public class CharSpriteViz extends JPanel
implements DirectionCodes, MouseMotionListener
{
public CharSpriteViz (
CharacterManager charmgr, CharacterComponent ccomp, String action)
{
// get a handle on our sprite
_sprite = charmgr.getCharacter(
new CharacterDescriptor(
new int[] { ccomp.componentId }, null));
// put the sprite in the appropriate action mode
_sprite.setRestingAction(action);
_sprite.setFollowingPathAction(action);
_sprite.setActionSequence(action);
addMouseMotionListener(this);
}
public void mouseDragged (MouseEvent event)
{
}
public void mouseMoved (MouseEvent event)
{
int orient = DirectionUtil.getFineDirection(
getWidth()/2, getHeight()/2, event.getX(), event.getY());
if (_orient != orient) {
System.out.println("Switching to " +
DirectionUtil.toShortString(orient) + ".");
_orient = orient;
repaint();
}
}
@Override
public void paintComponent (Graphics g)
{
super.paintComponent(g);
int width = getWidth(), height = getHeight();
int cx = width/2, cy = height/2;
g.setColor(Color.darkGray);
g.drawLine(cx, cy, 0, cy);
g.drawLine(cx, cy, 0, cy/2);
g.drawLine(cx, cy, 0, 0);
g.drawLine(cx, cy, cx/2, 0);
g.drawLine(cx, cy, cx, 0);
g.drawLine(cx, cy, 3*width/4, 0);
g.drawLine(cx, cy, width, 0);
g.drawLine(cx, cy, width, cy/2);
g.drawLine(cx, cy, width, cy);
g.drawLine(cx, cy, width, 3*height/4);
g.drawLine(cx, cy, width, height);
g.drawLine(cx, cy, 3*width/4, height);
g.drawLine(cx, cy, cx, height);
g.drawLine(cx, cy, cx/2, height);
g.drawLine(cx, cy, 0, height);
g.drawLine(cx, cy, 0, 3*height/4);
_sprite.setLocation(cx, cy);
_sprite.setOrientation(_orient);
_sprite.paint((Graphics2D)g);
}
public static void main (String[] args)
{
if (args.length < 3) {
System.err.println("Usage: CharSpriteViz cclass cname action");
System.err.println(" (eg. CharSpriteViz navsail smsloop sailing");
System.exit(-1);
}
JFrame frame = new JFrame("CharSpriteViz");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
try {
ResourceManager rmgr = new ResourceManager("rsrc");
rmgr.initBundles(
null, "config/resource/manager.properties", null);
ClientImageManager imgr = new ClientImageManager(rmgr, frame);
ComponentRepository crepo =
new BundledComponentRepository(rmgr, imgr, "components");
CharacterManager charmgr = new CharacterManager(imgr, crepo);
CharacterComponent ccomp = crepo.getComponent(args[0], args[1]);
frame.getContentPane().add(
new CharSpriteViz(charmgr, ccomp, args[2]),
BorderLayout.CENTER);
frame.setSize(200, 200);
SwingUtil.centerWindow(frame);
frame.setVisible(true);
} catch (NoSuchComponentException nsce) {
System.err.println("No component with specified class " +
"and name [cclass=" + args[0] +
", cname=" + args[1] + "].");
System.exit(-1);
} catch (Exception e) {
e.printStackTrace(System.err);
System.exit(-1);
}
}
protected CharacterSprite _sprite;
protected int _orient = NORTH;
}
@@ -0,0 +1,78 @@
//
// $Id: TestApp.java 3355 2005-02-17 01:54:54Z mdb $
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2010 Three Rings Design, Inc., All Rights Reserved
// http://www.threerings.net/code/narya/
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.threerings.cast.builder;
import java.io.IOException;
import javax.swing.JFrame;
import com.samskivert.swing.util.SwingUtil;
import com.threerings.resource.ResourceManager;
import com.threerings.media.image.ClientImageManager;
import com.threerings.cast.CharacterManager;
import com.threerings.cast.ComponentRepository;
import com.threerings.cast.bundle.BundledComponentRepository;
public class TestApp
{
public TestApp (String[] args)
throws IOException
{
_frame = new TestFrame();
_frame.setSize(800, 600);
SwingUtil.centerWindow(_frame);
ResourceManager rmgr = new ResourceManager("rsrc");
rmgr.initBundles(
null, "config/resource/manager.properties", null);
ClientImageManager imgr = new ClientImageManager(rmgr, _frame);
ComponentRepository crepo =
new BundledComponentRepository(rmgr, imgr, "components");
CharacterManager charmgr = new CharacterManager(imgr, crepo);
// initialize the frame
((TestFrame)_frame).init(charmgr, crepo);
}
public void run ()
{
_frame.pack();
_frame.setVisible(true);
}
public static void main (String[] args)
{
try {
TestApp app = new TestApp(args);
app.run();
} catch (IOException ioe) {
System.err.println("Error initializing app.");
ioe.printStackTrace();
}
}
protected JFrame _frame;
}
@@ -0,0 +1,43 @@
//
// $Id: TestFrame.java 3099 2004-08-27 02:21:06Z mdb $
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2010 Three Rings Design, Inc., All Rights Reserved
// http://www.threerings.net/code/narya/
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.threerings.cast.builder;
import javax.swing.JFrame;
import com.threerings.cast.CharacterManager;
import com.threerings.cast.ComponentRepository;
public class TestFrame extends JFrame
{
public TestFrame ()
{
super("Character Builder");
setResizable(false);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public void init (CharacterManager charmgr, ComponentRepository crepo)
{
getContentPane().add(new BuilderPanel(charmgr, crepo, "male/"));
}
}
@@ -0,0 +1,90 @@
//
// $Id: BundledComponentRepositoryTest.java 3720 2005-10-05 01:39:45Z mdb $
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2010 Three Rings Design, Inc., All Rights Reserved
// http://www.threerings.net/code/narya/
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.threerings.cast.bundle;
import java.util.Iterator;
import java.awt.Component;
import junit.framework.Test;
import junit.framework.TestCase;
import com.threerings.resource.ResourceManager;
import com.threerings.media.image.ClientImageManager;
import com.threerings.cast.ComponentClass;
public class BundledComponentRepositoryTest extends TestCase
{
public BundledComponentRepositoryTest ()
{
super(BundledComponentRepositoryTest.class.getName());
}
@Override
public void runTest ()
{
try {
ResourceManager rmgr = new ResourceManager("rsrc");
rmgr.initBundles(
null, "config/resource/manager.properties", null);
ClientImageManager imgr = new ClientImageManager(rmgr, (Component)null);
BundledComponentRepository repo =
new BundledComponentRepository(rmgr, imgr, "components");
// System.out.println("Classes: " + StringUtil.toString(
// repo.enumerateComponentClasses()));
// System.out.println("Actions: " + StringUtil.toString(
// repo.enumerateActionSequences()));
// System.out.println("Action sets: " + StringUtil.toString(
// repo._actionSets.values().iterator()));
Iterator<ComponentClass> iter = repo.enumerateComponentClasses();
while (iter.hasNext()) {
// ComponentClass cclass = (ComponentClass)
iter.next();
// System.out.println("IDs [" + cclass + "]: " +
// StringUtil.toString(
// repo.enumerateComponentIds(cclass)));
}
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
public static void main (String[] args)
{
BundledComponentRepositoryTest test =
new BundledComponentRepositoryTest();
test.runTest();
}
public static Test suite ()
{
return new BundledComponentRepositoryTest();
}
}