mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-11-25 16:34:00 +00:00
tidying
This commit is contained in:
parent
f6562b9ce2
commit
529d20ca18
@ -50,10 +50,10 @@ public abstract class AbstractFile implements DataSource
|
|||||||
if (buffer == null || buffer.length == 0)
|
if (buffer == null || buffer.length == 0)
|
||||||
return "No buffer";
|
return "No buffer";
|
||||||
|
|
||||||
if (buffer.length <= 99999)
|
if (buffer.length <= 999999)
|
||||||
return HexFormatter.format (buffer, 0, buffer.length);
|
return HexFormatter.format (buffer, 0, buffer.length);
|
||||||
|
|
||||||
return HexFormatter.format (buffer, 0, 99999);
|
return HexFormatter.format (buffer, 0, 999999);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -257,7 +257,7 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
|
|||||||
return childNode;
|
return childNode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
System.out.println ("Node not found : " + name);
|
// System.out.println ("Node not found : " + name);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,8 +135,7 @@ abstract class AbstractTab extends JPanel implements Tab
|
|||||||
{
|
{
|
||||||
TreePath tp = getPathToNode (showNode);
|
TreePath tp = getPathToNode (showNode);
|
||||||
tree.setSelectionPath (tp);
|
tree.setSelectionPath (tp);
|
||||||
if (!tree.isVisible (tp))
|
tree.scrollPathToVisible (tp);
|
||||||
tree.scrollPathToVisible (tp);
|
|
||||||
tree.requestFocusInWindow ();
|
tree.requestFocusInWindow ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ class FileSystemTab extends AbstractTab
|
|||||||
Map<String, List<DiskDetails>> duplicateDisks;
|
Map<String, List<DiskDetails>> duplicateDisks;
|
||||||
|
|
||||||
public FileSystemTab (File folder, DiskAndFileSelector selector, RedoHandler navMan,
|
public FileSystemTab (File folder, DiskAndFileSelector selector, RedoHandler navMan,
|
||||||
Font font, DiskSelectedEvent diskEvent) // throws NoDisksFoundException
|
Font font, DiskSelectedEvent diskEvent) // throws NoDisksFoundException
|
||||||
{
|
{
|
||||||
super (navMan, selector, font);
|
super (navMan, selector, font);
|
||||||
this.rootFolder = folder;
|
this.rootFolder = folder;
|
||||||
@ -76,13 +76,13 @@ class FileSystemTab extends AbstractTab
|
|||||||
}
|
}
|
||||||
for (File file : tb.dosMap.get (key))
|
for (File file : tb.dosMap.get (key))
|
||||||
System.out.printf (" %s%n",
|
System.out.printf (" %s%n",
|
||||||
file.getAbsolutePath ().substring (beginIndex));
|
file.getAbsolutePath ().substring (beginIndex));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileSystemTab (File folder, DiskAndFileSelector selector, RedoHandler navMan,
|
public FileSystemTab (File folder, DiskAndFileSelector selector, RedoHandler navMan,
|
||||||
Font font)
|
Font font)
|
||||||
// throws NoDisksFoundException
|
// throws NoDisksFoundException
|
||||||
{
|
{
|
||||||
this (folder, selector, navMan, font, null); // default to first available disk
|
this (folder, selector, navMan, font, null); // default to first available disk
|
||||||
@ -177,7 +177,7 @@ class FileSystemTab extends AbstractTab
|
|||||||
return childNode;
|
return childNode;
|
||||||
|
|
||||||
if (fn2.file.isDirectory () && absolutePath.startsWith (path)
|
if (fn2.file.isDirectory () && absolutePath.startsWith (path)
|
||||||
&& absolutePath.charAt (path.length ()) == '/')
|
&& absolutePath.charAt (path.length ()) == '/')
|
||||||
{
|
{
|
||||||
DefaultMutableTreeNode node2 = search (childNode, absolutePath);
|
DefaultMutableTreeNode node2 = search (childNode, absolutePath);
|
||||||
if (node2 != null)
|
if (node2 != null)
|
||||||
@ -231,7 +231,8 @@ class FileSystemTab extends AbstractTab
|
|||||||
public void treeWillExpand (TreeExpansionEvent e) throws ExpandVetoException
|
public void treeWillExpand (TreeExpansionEvent e) throws ExpandVetoException
|
||||||
{
|
{
|
||||||
TreePath path = e.getPath ();
|
TreePath path = e.getPath ();
|
||||||
DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent ();
|
DefaultMutableTreeNode node =
|
||||||
|
(DefaultMutableTreeNode) path.getLastPathComponent ();
|
||||||
FileNode fn = (FileNode) node.getUserObject ();
|
FileNode fn = (FileNode) node.getUserObject ();
|
||||||
if (node.getChildCount () == 0)
|
if (node.getChildCount () == 0)
|
||||||
fn.readFiles ();
|
fn.readFiles ();
|
||||||
|
@ -112,23 +112,29 @@ class MazeLevel extends AbstractFile
|
|||||||
cell.stairs = true;
|
cell.stairs = true;
|
||||||
cell.addressTo = getAddress (b);
|
cell.addressTo = getAddress (b);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
cell.pit = true;
|
cell.pit = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
cell.chute = true;
|
cell.chute = true;
|
||||||
cell.addressTo = getAddress (b);
|
cell.addressTo = getAddress (b);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
cell.spinner = true;
|
cell.spinner = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5:
|
case 5:
|
||||||
cell.darkness = true;
|
cell.darkness = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 6:
|
case 6:
|
||||||
cell.teleport = true;
|
cell.teleport = true;
|
||||||
cell.addressTo = getAddress (b);
|
cell.addressTo = getAddress (b);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 8:
|
case 8:
|
||||||
cell.elevator = true;
|
cell.elevator = true;
|
||||||
cell.elevatorTo =
|
cell.elevatorTo =
|
||||||
@ -136,23 +142,28 @@ class MazeLevel extends AbstractFile
|
|||||||
cell.elevatorFrom =
|
cell.elevatorFrom =
|
||||||
HexFormatter.intValue (buffer[832 + b * 2], buffer[833 + b * 2]);
|
HexFormatter.intValue (buffer[832 + b * 2], buffer[833 + b * 2]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 9:
|
case 9:
|
||||||
cell.rock = true;
|
cell.rock = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 10:
|
case 10:
|
||||||
cell.spellsBlocked = true;
|
cell.spellsBlocked = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 11:
|
case 11:
|
||||||
int messageNum = HexFormatter.intValue (buffer[800 + b * 2], buffer[801 + b * 2]);
|
int messageNum = HexFormatter.intValue (buffer[800 + b * 2], buffer[801 + b * 2]);
|
||||||
if (messages != null)
|
if (messages != null)
|
||||||
|
{
|
||||||
for (Message m : messages)
|
for (Message m : messages)
|
||||||
if (m.match (messageNum))
|
if (m.match (messageNum))
|
||||||
{
|
{
|
||||||
cell.message = m;
|
cell.message = m;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (cell.message == null)
|
if (cell.message == null)
|
||||||
System.out.println ("message not found : " + messageNum);
|
System.out.println ("message not found : " + messageNum);
|
||||||
|
}
|
||||||
cell.messageType =
|
cell.messageType =
|
||||||
HexFormatter.intValue (buffer[832 + b * 2], buffer[833 + b * 2]);
|
HexFormatter.intValue (buffer[832 + b * 2], buffer[833 + b * 2]);
|
||||||
|
|
||||||
@ -190,10 +201,12 @@ class MazeLevel extends AbstractFile
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 12:
|
case 12:
|
||||||
cell.monsterID = HexFormatter.intValue (buffer[832 + b * 2], buffer[833 + b * 2]);
|
cell.monsterID = HexFormatter.intValue (buffer[832 + b * 2], buffer[833 + b * 2]);
|
||||||
cell.monsters = monsters;
|
cell.monsters = monsters;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
cell.unknown = d;
|
cell.unknown = d;
|
||||||
break;
|
break;
|
||||||
|
@ -27,7 +27,7 @@ public class MessageBlock implements Iterable<MessageDataBlock>
|
|||||||
byte[] data = new byte[512];
|
byte[] data = new byte[512];
|
||||||
System.arraycopy (buffer, i * 512, data, 0, data.length);
|
System.arraycopy (buffer, i * 512, data, 0, data.length);
|
||||||
MessageDataBlock messageDataBlock = new MessageDataBlock (
|
MessageDataBlock messageDataBlock = new MessageDataBlock (
|
||||||
"Block " + i + " Msg " + firstMessageNo, data, firstMessageNo, huffman);
|
" Message " + firstMessageNo, data, firstMessageNo, huffman);
|
||||||
messageDataBlocks.add (messageDataBlock);
|
messageDataBlocks.add (messageDataBlock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ public class MessageDataBlock extends AbstractFile
|
|||||||
Huffman huffman)
|
Huffman huffman)
|
||||||
{
|
{
|
||||||
super (name, buffer);
|
super (name, buffer);
|
||||||
|
|
||||||
this.firstMessageNo = firstMessageNo;
|
this.firstMessageNo = firstMessageNo;
|
||||||
this.huffman = huffman;
|
this.huffman = huffman;
|
||||||
|
|
||||||
@ -62,6 +63,9 @@ public class MessageDataBlock extends AbstractFile
|
|||||||
currentMessageNo += skip;
|
currentMessageNo += skip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (currentMessageNo > firstMessageNo)
|
||||||
|
this.name += " - " + (currentMessageNo - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] getMessage (int messageNo)
|
byte[] getMessage (int messageNo)
|
||||||
@ -79,12 +83,15 @@ public class MessageDataBlock extends AbstractFile
|
|||||||
@Override
|
@Override
|
||||||
public String getText ()
|
public String getText ()
|
||||||
{
|
{
|
||||||
|
if (messages.size () == 0)
|
||||||
|
return "No Messages";
|
||||||
|
|
||||||
if (huffman == null)
|
if (huffman == null)
|
||||||
return toString ();
|
return toString ();
|
||||||
|
|
||||||
StringBuilder text = new StringBuilder ();
|
StringBuilder text = new StringBuilder ();
|
||||||
text.append ("\n");
|
|
||||||
int lastMessageNo = messages.get (0).msgNo - 1;
|
int lastMessageNo = messages.get (0).msgNo - 1;
|
||||||
|
|
||||||
for (Message message : messages)
|
for (Message message : messages)
|
||||||
{
|
{
|
||||||
if (message.msgNo != lastMessageNo + 1)
|
if (message.msgNo != lastMessageNo + 1)
|
||||||
|
@ -19,16 +19,17 @@ import com.bytezone.diskbrowser.wizardry.Header.ScenarioData;
|
|||||||
public class Wizardry4BootDisk extends PascalDisk
|
public class Wizardry4BootDisk extends PascalDisk
|
||||||
{
|
{
|
||||||
public Header scenarioHeader;
|
public Header scenarioHeader;
|
||||||
List<AppleDisk> disks = new ArrayList<AppleDisk> ();
|
private final List<AppleDisk> disks = new ArrayList<AppleDisk> ();
|
||||||
private Relocator relocator;
|
private Relocator relocator;
|
||||||
private MessageBlock messageBlock;
|
private MessageBlock messageBlock;
|
||||||
private Huffman huffman;
|
private Huffman huffman;
|
||||||
|
private final int version;
|
||||||
|
|
||||||
public Wizardry4BootDisk (AppleDisk[] dataDisks)
|
public Wizardry4BootDisk (AppleDisk[] dataDisks)
|
||||||
{
|
{
|
||||||
super (dataDisks[0]);
|
super (dataDisks[0]);
|
||||||
|
|
||||||
// this.dataDisks = dataDisks;
|
version = dataDisks.length == 6 ? 4 : dataDisks.length == 10 ? 5 : 0;
|
||||||
|
|
||||||
DefaultTreeModel model = (DefaultTreeModel) catalogTree.getModel ();
|
DefaultTreeModel model = (DefaultTreeModel) catalogTree.getModel ();
|
||||||
DefaultMutableTreeNode currentRoot = (DefaultMutableTreeNode) model.getRoot ();
|
DefaultMutableTreeNode currentRoot = (DefaultMutableTreeNode) model.getRoot ();
|
||||||
@ -53,25 +54,37 @@ public class Wizardry4BootDisk extends PascalDisk
|
|||||||
fileEntry.getDataSource ();
|
fileEntry.getDataSource ();
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultMutableTreeNode scenarioNode = findNode (currentRoot, "SCENARIO.DATA");
|
if (version == 4)
|
||||||
fileEntry = (FileEntry) scenarioNode.getUserObject ();
|
|
||||||
if (fileEntry != null)
|
|
||||||
{
|
{
|
||||||
fileEntry.setFile (null);
|
DefaultMutableTreeNode scenarioNode = findNode (currentRoot, "SCENARIO.DATA");
|
||||||
|
|
||||||
scenarioNode.setAllowsChildren (true);
|
if (scenarioNode != null)
|
||||||
scenarioHeader = new Header (scenarioNode, this);
|
{
|
||||||
linkMazeLevels (scenarioNode, fileEntry);
|
fileEntry = (FileEntry) scenarioNode.getUserObject ();
|
||||||
|
if (fileEntry != null)
|
||||||
|
{
|
||||||
|
fileEntry.setFile (null);
|
||||||
|
scenarioNode.setAllowsChildren (true);
|
||||||
|
scenarioHeader = new Header (scenarioNode, this);
|
||||||
|
linkMazeLevels4 (scenarioNode, fileEntry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (version == 5)
|
||||||
|
{
|
||||||
|
DefaultMutableTreeNode scenarioNode = findNode (currentRoot, "DRAGON.DATA");
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultMutableTreeNode monstersNode = findNode (currentRoot, "200.MONSTERS");
|
if (version == 4)
|
||||||
fileEntry = (FileEntry) monstersNode.getUserObject ();
|
|
||||||
if (fileEntry != null)
|
|
||||||
{
|
{
|
||||||
fileEntry.setFile (null);
|
DefaultMutableTreeNode monstersNode = findNode (currentRoot, "200.MONSTERS");
|
||||||
|
fileEntry = (FileEntry) monstersNode.getUserObject ();
|
||||||
monstersNode.setAllowsChildren (true);
|
if (fileEntry != null)
|
||||||
linkMonsterImages (monstersNode, fileEntry);
|
{
|
||||||
|
fileEntry.setFile (null);
|
||||||
|
monstersNode.setAllowsChildren (true);
|
||||||
|
linkMonsterImages4 (monstersNode, fileEntry);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultMutableTreeNode huffNode = findNode (currentRoot, "ASCII.HUFF");
|
DefaultMutableTreeNode huffNode = findNode (currentRoot, "ASCII.HUFF");
|
||||||
@ -91,15 +104,19 @@ public class Wizardry4BootDisk extends PascalDisk
|
|||||||
{
|
{
|
||||||
messageBlock = new MessageBlock (fileEntry.getDataSource ().buffer, huffman);
|
messageBlock = new MessageBlock (fileEntry.getDataSource ().buffer, huffman);
|
||||||
messagesNode.setAllowsChildren (true);
|
messagesNode.setAllowsChildren (true);
|
||||||
|
List<DiskAddress> blocks = fileEntry.getSectors ();
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
for (MessageDataBlock mdb : messageBlock)
|
for (MessageDataBlock mdb : messageBlock)
|
||||||
{
|
{
|
||||||
List<DiskAddress> messageBlocks = new ArrayList<DiskAddress> ();
|
List<DiskAddress> messageBlocks = new ArrayList<DiskAddress> ();
|
||||||
|
messageBlocks.add (blocks.get (count++));
|
||||||
addToNode (mdb, messagesNode, messageBlocks);
|
addToNode (mdb, messagesNode, messageBlocks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void linkMazeLevels (DefaultMutableTreeNode scenarioNode, FileEntry fileEntry)
|
private void linkMazeLevels4 (DefaultMutableTreeNode scenarioNode, FileEntry fileEntry)
|
||||||
{
|
{
|
||||||
ScenarioData mazeData = scenarioHeader.data.get (Header.MAZE_AREA);
|
ScenarioData mazeData = scenarioHeader.data.get (Header.MAZE_AREA);
|
||||||
|
|
||||||
@ -110,18 +127,21 @@ public class Wizardry4BootDisk extends PascalDisk
|
|||||||
for (int i = 0; i < 15; i++)
|
for (int i = 0; i < 15; i++)
|
||||||
{
|
{
|
||||||
byte[] level = new byte[896];
|
byte[] level = new byte[896];
|
||||||
System.arraycopy (buffer, mazeData.dataOffset * 512 + i * 1024, level, 0,
|
int offset = mazeData.dataOffset * 512 + i * 1024;
|
||||||
level.length);
|
if (offset + level.length < buffer.length)
|
||||||
|
{
|
||||||
|
System.arraycopy (buffer, offset, level, 0, level.length);
|
||||||
|
|
||||||
List<DiskAddress> mazeBlocks = new ArrayList<DiskAddress> ();
|
List<DiskAddress> mazeBlocks = new ArrayList<DiskAddress> ();
|
||||||
int ptr = mazeData.dataOffset + i * 2;
|
int ptr = mazeData.dataOffset + i * 2;
|
||||||
mazeBlocks.add (blocks.get (ptr));
|
mazeBlocks.add (blocks.get (ptr));
|
||||||
mazeBlocks.add (blocks.get (ptr + 1));
|
mazeBlocks.add (blocks.get (ptr + 1));
|
||||||
addToNode (new MazeLevel (level, i), mazeNode, mazeBlocks);
|
addToNode (new MazeLevel (level, i), mazeNode, mazeBlocks);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void linkMonsterImages (DefaultMutableTreeNode monstersNode,
|
private void linkMonsterImages4 (DefaultMutableTreeNode monstersNode,
|
||||||
FileEntry fileEntry)
|
FileEntry fileEntry)
|
||||||
{
|
{
|
||||||
byte[] pictureBuffer = fileEntry.getDataSource ().buffer;
|
byte[] pictureBuffer = fileEntry.getDataSource ().buffer;
|
||||||
@ -149,8 +169,8 @@ public class Wizardry4BootDisk extends PascalDisk
|
|||||||
DefaultAppleFileSource dafs =
|
DefaultAppleFileSource dafs =
|
||||||
new DefaultAppleFileSource (af.getName (), af, this, blocks);
|
new DefaultAppleFileSource (af.getName (), af, this, blocks);
|
||||||
DefaultMutableTreeNode childNode = new DefaultMutableTreeNode (dafs);
|
DefaultMutableTreeNode childNode = new DefaultMutableTreeNode (dafs);
|
||||||
node.add (childNode);
|
|
||||||
childNode.setAllowsChildren (false);
|
childNode.setAllowsChildren (false);
|
||||||
|
node.add (childNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
private DefaultMutableTreeNode linkNode (String name, String text,
|
private DefaultMutableTreeNode linkNode (String name, String text,
|
||||||
|
@ -84,8 +84,8 @@ public class WizardryScenarioDisk extends PascalDisk
|
|||||||
|
|
||||||
// Process SCENARIO.MESGS (requires scenario)
|
// Process SCENARIO.MESGS (requires scenario)
|
||||||
AppleFileSource afs = (AppleFileSource) msgNode.getUserObject ();
|
AppleFileSource afs = (AppleFileSource) msgNode.getUserObject ();
|
||||||
DefaultMutableTreeNode node = linkNode ("Messages", "Messages string", msgNode);
|
// DefaultMutableTreeNode node = linkNode ("Messages", "Messages string", msgNode);
|
||||||
extractMessages (node, afs.getSectors ());
|
extractMessages (msgNode, afs.getSectors ());
|
||||||
// makeNodeVisible (node);
|
// makeNodeVisible (node);
|
||||||
|
|
||||||
// Process SCENARIO.DATA (requires scenario and messages)
|
// Process SCENARIO.DATA (requires scenario and messages)
|
||||||
@ -100,7 +100,7 @@ public class WizardryScenarioDisk extends PascalDisk
|
|||||||
extractExperienceLevels (linkNode ("Experience", "Experience string", dataNode),
|
extractExperienceLevels (linkNode ("Experience", "Experience string", dataNode),
|
||||||
sectors);
|
sectors);
|
||||||
// node = linkNode ("Spells", "Spells string", dataNode);
|
// node = linkNode ("Spells", "Spells string", dataNode);
|
||||||
node = null;
|
DefaultMutableTreeNode node = null;
|
||||||
extractSpells (node, sectors);
|
extractSpells (node, sectors);
|
||||||
extractLevels (linkNode ("Maze", "Levels string", dataNode), sectors);
|
extractLevels (linkNode ("Maze", "Levels string", dataNode), sectors);
|
||||||
// Make the Spells node (and its siblings) visible
|
// Make the Spells node (and its siblings) visible
|
||||||
@ -467,9 +467,6 @@ public class WizardryScenarioDisk extends PascalDisk
|
|||||||
totalLines = 0;
|
totalLines = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultAppleFileSource afs = (DefaultAppleFileSource) node.getUserObject ();
|
|
||||||
afs.setSectors (sectors);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void extractLevels (DefaultMutableTreeNode node, List<DiskAddress> sectors)
|
private void extractLevels (DefaultMutableTreeNode node, List<DiskAddress> sectors)
|
||||||
|
Loading…
Reference in New Issue
Block a user