Skip to content

Commit 110107f

Browse files
committed
added simple help screen
1 parent c56fd58 commit 110107f

3 files changed

Lines changed: 51 additions & 0 deletions

File tree

src/com/modsim/gui/HelpWindow.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.modsim.gui;
2+
3+
import java.awt.Dimension;
4+
import java.awt.Toolkit;
5+
6+
import javax.swing.BorderFactory;
7+
import javax.swing.JFrame;
8+
import javax.swing.JLabel;
9+
import javax.swing.JScrollPane;
10+
11+
public class HelpWindow extends JFrame {
12+
13+
public HelpWindow(){
14+
super("Help");
15+
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
16+
setVisible(true);
17+
JLabel text = new JLabel();
18+
//static help text
19+
text.setText("<html><h2>ModuleSim Help</h3><h3>General Operations</h3>You can zoom in and out by scrolling or pinching on a multi-touch touch pad. You can pan around using the right mouse key.<br><br>Dragging the left mouse key enables you to select all modules in a region.Standard operations like saving to and loading from file, undo and redo and copy and paste are available through menu bar and keyboard shortcuts.<br><br>Note to Mac users: right click is <i>probably</i> two finger tap.<h3>Adding Modules</h3>To use a module, left click on it (in the left sidebar) and then left click to drop in place. If you selected one in error press escape (ESC).<br><br>To delete a module select it with a left click and then either press the delete key or right click and select 'delete'.<br><br>Right clicking on modules brings up a context menu, where you can do things like label and rotate the modules.<h3>Adding Wires</h3>To connect two modules together, left click on the two sockets (indicated on the modules as coloured circles), one after the other. The wire will be drawn between the two sockets. If you start drawing a wire by accident press the ESC key.<br><br>You can change the shape of the wire by adding waypoints. This is done by left clicking as many times as you want before selecting the destination socket.<br><br>You can add waypoints afterwards by clicking on the wire and then again on the wire in the place where you want the waypoint. You can then drag this point around.<br><br>The software will naturally draw a curve between the points. This is so it can easily and dynamically re-draw the connection as you move the modules around. To create straight lines place two waypoints very close to each other where you want the corner.<br><br>To delete a wire right click on one of the ends and select delete.<br><br>To delete a waypoint right click it and select delete.<h3>Specific Modules</h3>The switches can be used to produce constants. Their value can be set by clicking on each of the four switches to toggle the bit value.<br><br>The clock module is what controls the timing of your circuits. Once it has been connected up you can put it in to reset mode by holding down the button on the module with the mouse. To progress the clock signal you can use the control panel underneath the menu bar. You can step the clock one step a time or press play and pause to run it automatically, adjusting the speed with the slider.<br><br>The RAM module write jumper is implemented as a switch. This needs to be switched on for the circuit to write data to it.<br><br>You can also load data in to the ram from a file. Right click on the NRAM and select 'View/Edit Data'. Then File->Load. The file must be a text file containing each byte written in hex (capital letters) delimited by spaces.</hmtl>");
20+
text.setPreferredSize(new Dimension(600, 1000));
21+
text.setBorder(BorderFactory.createEmptyBorder(50,50,50,50));
22+
JScrollPane scrollPane = new JScrollPane(text, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
23+
scrollPane.setPreferredSize(new Dimension(600, 800));
24+
add(scrollPane);
25+
pack();
26+
setResizable(false);
27+
//place in center of screen
28+
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
29+
int w = this.getSize().width;
30+
int h = this.getSize().height;
31+
int x = (dim.width-w)/2;
32+
int y = (dim.height-h)/2;
33+
setLocation(x, y);
34+
}
35+
}

src/com/modsim/gui/Menu.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.modsim.gui;
22

3+
import java.awt.Dimension;
34
import java.awt.event.KeyEvent;
45
import javax.swing.*;
56
import com.modsim.operations.Ops;
@@ -29,6 +30,10 @@ public Menu() {
2930
addEditMenu();
3031
addViewMenu();
3132
addSimMenu();
33+
JMenuItem help = new JMenuItem(Ops.showHelp);
34+
help.setMaximumSize(new Dimension(80, 100));
35+
help.setMnemonic(KeyEvent.VK_H);
36+
app_menu.add(help);
3237
}
3338

3439
private void addFileMenu() {

src/com/modsim/operations/Ops.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.modsim.operations;
22

33
import com.modsim.Main;
4+
import com.modsim.gui.HelpWindow;
45
import com.modsim.modules.BaseModule;
56
import com.modsim.simulator.PickableEntity;
67
import com.modsim.tools.PlaceTool;
@@ -22,6 +23,16 @@
2223
*/
2324
public class Ops {
2425

26+
public static DesignAction showHelp = new DesignAction(event -> {
27+
SwingUtilities.invokeLater(
28+
new Runnable() {
29+
@Override
30+
public void run() {
31+
new HelpWindow();
32+
}
33+
});
34+
}, "Show help");
35+
2536
public static class FileIO {
2637
private static final FilenameFilter simFileFilter = new FilenameFilter() {
2738
@Override

0 commit comments

Comments
 (0)