Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion micropolis-java/src/micropolisj/engine/Micropolis.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ public class Micropolis
static final int DEFAULT_WIDTH = 120;
static final int DEFAULT_HEIGHT = 100;

public boolean keepHeader = false;
byte [] bbHeader = new byte[128];

public final CityBudget budget = new CityBudget(this);
public boolean autoBulldoze = true;
public boolean autoBudget = false;
Expand Down Expand Up @@ -2085,7 +2088,7 @@ public void load(File filename)
// but otherwise use the same format as us,
// so read in that 128-byte header and continue
// as before.
byte [] bbHeader = new byte[128];
keepHeader = true;
fis.read(bbHeader);
}
load(fis);
Expand Down Expand Up @@ -2146,6 +2149,9 @@ public void save(OutputStream outStream)
throws IOException
{
DataOutputStream out = new DataOutputStream(outStream);
if (keepHeader) {
out.write(bbHeader);
}
writeHistoryArray(history.res, out);
writeHistoryArray(history.com, out);
writeHistoryArray(history.ind, out);
Expand Down Expand Up @@ -2181,6 +2187,12 @@ public void setSpeed(Speed newSpeed)
fireOptionsChanged();
}

public void toggleKeepHeader()
{
keepHeader = !keepHeader;
fireOptionsChanged();
}

public void animate()
{
this.acycle = (this.acycle+1) % 960;
Expand Down
19 changes: 19 additions & 0 deletions micropolis-java/src/micropolisj/gui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,17 @@ public void actionPerformed(ActionEvent ev)
}}));
optionsMenu.add(menuItem);

keepHeaderMenuItem = new JCheckBoxMenuItem(strings.getString("menu.options.keep_header"));
setupKeys(keepHeaderMenuItem, "menu.options.keep_header");
keepHeaderMenuItem.addActionListener(wrapActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent ev)
{
onKeepHeaderClicked();
}
}));
optionsMenu.add(keepHeaderMenuItem);

JMenu disastersMenu = new JMenu(strings.getString("menu.disasters"));
setupKeys(disastersMenu, "menu.disasters");
menuBar.add(disastersMenu);
Expand Down Expand Up @@ -795,6 +806,7 @@ private Micropolis getEngine()
JMenuItem autoBulldozeMenuItem;
JMenuItem disastersMenuItem;
JMenuItem soundsMenuItem;
JMenuItem keepHeaderMenuItem;
Map<Speed,JMenuItem> priorityMenuItems;
Map<Integer,JMenuItem> difficultyMenuItems;

Expand Down Expand Up @@ -825,6 +837,12 @@ private void onSoundClicked()
reloadOptions();
}

private void onKeepHeaderClicked()
{
dirty1 = true;
getEngine().toggleKeepHeader();
}

void makeClean()
{
dirty1 = false;
Expand Down Expand Up @@ -1582,6 +1600,7 @@ private void reloadOptions()
autoBulldozeMenuItem.setSelected(getEngine().autoBulldoze);
disastersMenuItem.setSelected(!getEngine().noDisasters);
soundsMenuItem.setSelected(doSounds);
keepHeaderMenuItem.setSelected(getEngine().keepHeader);
for (Speed spd : priorityMenuItems.keySet())
{
priorityMenuItems.get(spd).setSelected(getEngine().simSpeed == spd);
Expand Down
2 changes: 2 additions & 0 deletions micropolis-java/strings/GuiStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ menu.options.zoom_in = Zoom In
menu.options.zoom_in.shortcut = PLUS
menu.options.zoom_out = Zoom Out
menu.options.zoom_out.shortcut = MINUS
menu.options.keep_header = Keep 128 bytes header
menu.options.keep_header.key = H

menu.difficulty = Difficulty
menu.difficulty.key = F
Expand Down