Changes to jive with new rendering deal.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1288 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2002-04-23 01:19:04 +00:00
parent 0bde11ee81
commit 1ce70d6c5a
7 changed files with 93 additions and 35 deletions
@@ -1,5 +1,5 @@
//
// $Id: ScrollingFrame.java,v 1.2 2002/02/19 07:21:33 mdb Exp $
// $Id: ScrollingFrame.java,v 1.3 2002/04/23 01:19:04 mdb Exp $
package com.threerings.miso.scene;
@@ -8,7 +8,13 @@ import java.awt.Color;
import java.awt.Component;
import java.awt.GraphicsConfiguration;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import com.samskivert.swing.VGroupLayout;
import com.threerings.media.SafeScrollPane;
/**
* The main application window.
@@ -32,6 +38,19 @@ public class ScrollingFrame extends JFrame
// set the frame and content panel background to black
setBackground(Color.black);
getContentPane().setBackground(Color.black);
// create some interface elements to go with our scrolling panel
VGroupLayout vgl = new VGroupLayout(VGroupLayout.STRETCH);
vgl.setOffAxisPolicy(VGroupLayout.STRETCH);
getContentPane().setLayout(vgl);
vgl = new VGroupLayout(VGroupLayout.NONE);
vgl.setOffAxisPolicy(VGroupLayout.STRETCH);
JPanel stuff = new JPanel(vgl);
for (int i = 0; i < 10; i++) {
stuff.add(new JButton("Button " + i));
}
getContentPane().add(new SafeScrollPane(stuff));
}
/**
@@ -46,7 +65,7 @@ public class ScrollingFrame extends JFrame
// now add the new one
_panel = panel;
getContentPane().add(_panel, BorderLayout.CENTER);
getContentPane().add(_panel, 0);
}
protected Component _panel;
@@ -1,14 +1,19 @@
//
// $Id: ScrollingScene.java,v 1.4 2002/04/15 17:47:05 mdb Exp $
// $Id: ScrollingScene.java,v 1.5 2002/04/23 01:19:04 mdb Exp $
package com.threerings.miso.scene;
import java.util.Iterator;
import java.util.Random;
import com.samskivert.io.PersistenceException;
import com.threerings.media.tile.NoSuchTileException;
import com.threerings.media.tile.NoSuchTileSetException;
import com.threerings.media.tile.ObjectTile;
import com.threerings.media.tile.Tile;
import com.threerings.media.tile.TileSet;
import com.threerings.media.tile.TileSetRepository;
import com.threerings.miso.tile.BaseTile;
import com.threerings.miso.util.MisoContext;
@@ -19,14 +24,30 @@ import com.threerings.miso.util.MisoContext;
public class ScrollingScene implements DisplayMisoScene
{
public ScrollingScene (MisoContext ctx)
throws NoSuchTileSetException, NoSuchTileException
throws NoSuchTileSetException, NoSuchTileException, PersistenceException
{
// locate the water tileset
TileSetRepository tsrepo = ctx.getTileManager().getTileSetRepository();
Iterator iter = tsrepo.enumerateTileSets();
TileSet wtset = null;
while (iter.hasNext()) {
TileSet tset = (TileSet)iter.next();
// yay for built-in regex support!
if (tset.getName().matches(".*[Ww]ater.*")) {
wtset = tset;
break;
}
}
if (wtset == null) {
throw new RuntimeException("Unable to locate water tileset.");
}
// grab our four repeating tiles
_tiles[0] = (BaseTile)ctx.getTileManager().getTile(5, 0);
_tiles[1] = (BaseTile)ctx.getTileManager().getTile(5, 1);
_tiles[2] = (BaseTile)ctx.getTileManager().getTile(5, 2);
_tiles[3] = (BaseTile)ctx.getTileManager().getTile(5, 3);
_tiles[4] = (BaseTile)ctx.getTileManager().getTile(5, 4);
_tiles = new BaseTile[wtset.getTileCount()];
for (int ii = 0; ii < wtset.getTileCount(); ii++) {
_tiles[ii] = (BaseTile)wtset.getTile(ii);
}
}
// documentation inherited from interface
@@ -34,7 +55,7 @@ public class ScrollingScene implements DisplayMisoScene
{
long seed = ((x^y) ^ multiplier) & mask;
long hash = (seed * multiplier + addend) & mask;
int tidx = (int)((hash >> 10) % 5);
int tidx = (int)((hash >> 10) % _tiles.length);
return _tiles[tidx];
}
@@ -56,10 +77,12 @@ public class ScrollingScene implements DisplayMisoScene
return null;
}
protected BaseTile[] _tiles = new BaseTile[5];
protected BaseTile[] _tiles;
protected Random _rand = new Random();
protected final static long multiplier = 0x5DEECE66DL;
protected final static long addend = 0xBL;
protected final static long mask = (1L << 48) - 1;
protected static final int WATER_TILESET_ID = 8;
}
@@ -1,5 +1,5 @@
//
// $Id: ScrollingTestApp.java,v 1.10 2002/04/15 17:47:05 mdb Exp $
// $Id: ScrollingTestApp.java,v 1.11 2002/04/23 01:19:04 mdb Exp $
package com.threerings.miso.scene;
@@ -16,6 +16,7 @@ import com.samskivert.swing.util.SwingUtil;
import com.samskivert.util.Config;
import com.threerings.resource.ResourceManager;
import com.threerings.media.FrameManager;
import com.threerings.media.ImageManager;
import com.threerings.media.sprite.Sprite;
@@ -67,6 +68,9 @@ public class ScrollingTestApp
// create the window
_frame = new ScrollingFrame(gc);
// set up our frame manager
_framemgr = new FrameManager(_frame);
// we don't need to configure anything
ResourceManager rmgr = new ResourceManager(
"rsrc", null, "config/resource/manager.properties");
@@ -88,12 +92,7 @@ public class ScrollingTestApp
charmgr.setCharacterClass(MisoCharacterSprite.class);
// create our scene view panel
_panel = new SceneViewPanel(new IsoSceneViewModel()) {
public void start () {
super.start();
// kick things off
viewFinishedScrolling();
}
_panel = new SceneViewPanel(_framemgr, new IsoSceneViewModel()) {
protected void viewFinishedScrolling () {
// keep scrolling for a spell
if (++_sidx < DX.length) {
@@ -104,6 +103,7 @@ public class ScrollingTestApp
protected final int[] DX = { 0, 1000, -1000, 1000, 2000 };
protected final int[] DY = { 1000, 0, 1000, -1000, 1000 };
};
_panel.setScrolling(0, 1000, 10000l);
_frame.setPanel(_panel);
// create our "ship" sprite
@@ -131,7 +131,6 @@ public class ScrollingTestApp
// set the scene to our scrolling scene
try {
_panel.setScene(new ScrollingScene(ctx));
_panel.start();
} catch (Exception e) {
Log.warning("Error creating scene: " + e);
@@ -147,7 +146,8 @@ public class ScrollingTestApp
} else {
Log.warning("Full-screen exclusive mode not available.");
_frame.pack();
// _frame.pack();
_frame.setSize(200, 300);
SwingUtil.centerWindow(_frame);
}
}
@@ -171,6 +171,7 @@ public class ScrollingTestApp
{
// show the window
_frame.show();
_framemgr.start();
}
/**
@@ -190,6 +191,9 @@ public class ScrollingTestApp
/** The tile manager object. */
protected MisoTileManager _tilemgr;
/** The frame manager. */
protected FrameManager _framemgr;
/** The main application window. */
protected ScrollingFrame _frame;