Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
Argent77 committed May 2, 2020
2 parents 1b2fd57 + 1bdf71e commit 7cd1990
Show file tree
Hide file tree
Showing 20 changed files with 424 additions and 182 deletions.
2 changes: 1 addition & 1 deletion .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry exported="true" kind="lib" path="lib/jorbis/jorbis.jar" sourcepath="lib/jorbis/jorbis-0.0.17.zip"/>
<classpathentry exported="true" kind="lib" path="lib/rsyntaxtextarea/rsyntaxtextarea.jar" sourcepath="lib/rsyntaxtextarea/RSyntaxTextArea-2.6.0-light.zip"/>
<classpathentry exported="true" kind="lib" path="lib/rsyntaxtextarea/rsyntaxtextarea.jar" sourcepath="lib/rsyntaxtextarea/RSyntaxTextArea-3.1.1-light.zip"/>
<classpathentry exported="true" kind="lib" path="lib/jhexview/jhexview.jar" sourcepath="lib/jhexview/jhexview-current.zip"/>
<classpathentry exported="true" kind="lib" path="lib/montemedia/montemedia.jar" sourcepath="lib/montemedia/MonteMedia-0.7.7.zip"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre8"/>
Expand Down
Binary file removed lib/rsyntaxtextarea/RSyntaxTextArea-2.6.0-light.zip
Binary file not shown.
Binary file not shown.
4 changes: 2 additions & 2 deletions lib/rsyntaxtextarea/RSyntaxTextArea.License.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2012, Robert Futrell
Copyright (c) 2019, Robert Futrell
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand All @@ -21,4 +21,4 @@ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Binary file modified lib/rsyntaxtextarea/rsyntaxtextarea.jar
Binary file not shown.
22 changes: 15 additions & 7 deletions src/org/infinity/NearInfinity.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import javax.swing.ProgressMonitor;
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
import javax.swing.ToolTipManager;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;
import javax.swing.filechooser.FileFilter;
Expand Down Expand Up @@ -116,6 +117,7 @@ public final class NearInfinity extends JFrame implements ActionListener, Viewab
private static final String LAST_GAMEDIR = "LastGameDir";
private static final String TABLE_WIDTH_ATTR = "TableColWidthAttr";
private static final String TABLE_WIDTH_OFS = "TableColWidthOfs";
private static final String TABLE_WIDTH_SIZE = "TableColWidthSize";
private static final String TABLE_PANEL_HEIGHT = "TablePanelHeight";
private static final String OPTION_GLOBAL_FONT_SIZE = "GlobalFontSize";

Expand All @@ -129,7 +131,7 @@ public final class NearInfinity extends JFrame implements ActionListener, Viewab
private final StatusBar statusBar;
private final WindowBlocker blocker = new WindowBlocker(this);
// stores table column widths for "Attribute", "Value" and "Offset"
private final int[] tableColumnWidth = { -1, -1, -1 };
private final int[] tableColumnWidth = { -1, -1, -1, -1 };

private Viewable viewable;
private ButtonPopupWindow bpwQuickSearch;
Expand Down Expand Up @@ -281,6 +283,9 @@ private NearInfinity(Path gameOverride, Profile.Game forcedGame)
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
setAppIcon();

// setting more reasonable tooltip timings
ToolTipManager.sharedInstance().setDismissDelay(8000);

// FileDeletionHook provides a way to delete files when the Java Virtual Machine shuts down
Runtime.getRuntime().addShutdownHook(FileDeletionHook.getInstance());

Expand Down Expand Up @@ -474,6 +479,7 @@ public void run()
tableColumnWidth[0] = Math.max(15, prefs.getInt(TABLE_WIDTH_ATTR, 300));
tableColumnWidth[1] = 0;
tableColumnWidth[2] = Math.max(15, prefs.getInt(TABLE_WIDTH_OFS, 100));
tableColumnWidth[3] = Math.max(15, prefs.getInt(TABLE_WIDTH_SIZE, 75));
tablePanelHeight = Math.max(50, prefs.getInt(TABLE_PANEL_HEIGHT, 250));

// enabling file drag and drop for whole window
Expand Down Expand Up @@ -648,7 +654,6 @@ else if (viewable instanceof Closeable) {
}
viewable = newViewable;
tree.select(resource.getResourceEntry());
BrowserMenuBar.getInstance().resourceShown(resource);
statusBar.setMessage(resource.getResourceEntry().getActualPath().toString());
containerpanel.removeAll();
containerpanel.add(viewable.makeViewer(this), BorderLayout.CENTER);
Expand Down Expand Up @@ -703,7 +708,6 @@ public boolean removeViewable()
}
}
viewable = null;
BrowserMenuBar.getInstance().resourceShown(null);
tree.select(null);
containerpanel.removeAll();
containerpanel.revalidate();
Expand Down Expand Up @@ -783,11 +787,11 @@ public boolean editGameIni(Component parent)

/**
* Returns the current column width for tables of structured resources.
* @param index The column index (0 = Attribute, 1 = Value and, optionally, 2 = Offset)
* @param index The column index (0 = Attribute, 1 = Value and, optionally, 2 = Offset, 3 = Size)
*/
public int getTableColumnWidth(int index)
{
index = Math.min(Math.max(0, index), 2);
index = Math.min(Math.max(0, index), tableColumnWidth.length - 1);
if (tableColumnWidth[index] < 0) {
switch (index) {
case 0: // "Attribute" column
Expand All @@ -799,20 +803,23 @@ public int getTableColumnWidth(int index)
case 2: // optional "Offset" column
tableColumnWidth[index] = 100;
break;
case 3: // optional "Size" column
tableColumnWidth[index] = 75;
break;
}
}
return tableColumnWidth[index];
}

/**
* Updates the current default column width for tables of structured resources.
* @param index The column index (0 = Attribute, 1 = Value and, optionally, 2 = Offset)
* @param index The column index (0 = Attribute, 1 = Value and, optionally, 2 = Offset, 3 = Size)
* @param newValue New width in pixels for the specified column
* @return Old column width
*/
public int updateTableColumnWidth(int index, int newValue)
{
index = Math.min(Math.max(0, index), 2);
index = Math.min(Math.max(0, index), tableColumnWidth.length - 1);
int retVal = tableColumnWidth[index];
tableColumnWidth[index] = Math.max(15, newValue);
return retVal;
Expand Down Expand Up @@ -930,6 +937,7 @@ private void storePreferences()
prefs.put(LAST_GAMEDIR, Profile.getGameRoot().toString());
prefs.putInt(TABLE_WIDTH_ATTR, getTableColumnWidth(0));
prefs.putInt(TABLE_WIDTH_OFS, getTableColumnWidth(2));
prefs.putInt(TABLE_WIDTH_SIZE, getTableColumnWidth(3));
prefs.putInt(TABLE_PANEL_HEIGHT, getTablePanelHeight());
prefs.putInt(OPTION_GLOBAL_FONT_SIZE, BrowserMenuBar.getInstance().getGlobalFontSize());
BrowserMenuBar.getInstance().storePreferences();
Expand Down
4 changes: 2 additions & 2 deletions src/org/infinity/RSyntaxTextArea.License.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2012, Robert Futrell
Copyright (c) 2019, Robert Futrell
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand All @@ -21,4 +21,4 @@ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
10 changes: 8 additions & 2 deletions src/org/infinity/datatype/Flag.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package org.infinity.datatype;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.Insets;
Expand All @@ -19,6 +20,7 @@
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.UIManager;

import org.infinity.gui.StructViewer;
import org.infinity.resource.AbstractStruct;
Expand Down Expand Up @@ -91,10 +93,14 @@ else if (event.getSource() == bNone) {
public JComponent edit(ActionListener container)
{
this.container = container;
Color colBright = (Color)UIManager.get("Label.disabledForeground");
if (colBright == null)
colBright = Color.GRAY;
checkBoxes = new JCheckBox[table.length];
for (int i = 0; i < table.length; i++) {
if (table[i] == null || table[i].isEmpty()) {
checkBoxes[i] = new JCheckBox("Unknown (" + i + ')');
checkBoxes[i].setForeground(colBright);
} else {
checkBoxes[i] = new JCheckBox(table[i] + " (" + i + ')');
}
Expand Down Expand Up @@ -264,7 +270,7 @@ private long calcValue()
*
* @param desc If {@code null}, then {@link #DESC_NONE} will be used as description
*/
protected final void setEmptyDesc(String desc)
public void setEmptyDesc(String desc)
{
nodesc = (desc != null) ? desc : DESC_NONE;
}
Expand All @@ -279,7 +285,7 @@ protected final void setEmptyDesc(String desc)
* labels and tooltips
* @param startOfs Offset to {@code stable} from which data begins
*/
protected final void setFlagDescriptions(int size, String[] stable, int startOfs)
public void setFlagDescriptions(int size, String[] stable, int startOfs)
{
table = new String[8*size];
toolTable = new String[8*size];
Expand Down
3 changes: 2 additions & 1 deletion src/org/infinity/datatype/ProRef.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public static synchronized void clearCache()
proList.clear();
}

private static List<RefEntry> createRefList(boolean useMissile)
/** Returns a list of projectiles with associated indices and search names. */
public static List<RefEntry> createRefList(boolean useMissile)
{
if (useMissile) {
return createProMissileRefList();
Expand Down
15 changes: 7 additions & 8 deletions src/org/infinity/datatype/StringRef.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,20 +115,19 @@ public StringRef(ByteBuffer buffer, int offset, String name)
@Override
public void actionPerformed(ActionEvent event)
{
final int newvalue = getValueFromEditor();
if (event.getSource() == bUpdate) {
taRefText.setText(StringTable.getStringRef(newvalue));
enablePlay(newvalue);
taRefText.setText(StringTable.getStringRef(value));
enablePlay(value);
}
else if (event.getSource() == bEdit) {
StringEditor.edit(value);
}
else if (event.getSource() == bPlay) {
final ResourceEntry entry = ResourceFactory.getResourceEntry(StringTable.getSoundResource(newvalue) + ".WAV");
final ResourceEntry entry = ResourceFactory.getResourceEntry(StringTable.getSoundResource(value) + ".WAV");
new ViewFrame(bPlay.getTopLevelAncestor(), ResourceFactory.getResource(entry));
}
else if (event.getSource() == bSearch) {
new StringReferenceSearcher(newvalue, bSearch.getTopLevelAncestor());
new StringReferenceSearcher(value, bSearch.getTopLevelAncestor());
}
}

Expand All @@ -139,9 +138,9 @@ else if (event.getSource() == bSearch) {
@Override
public void stateChanged(ChangeEvent e)
{
final int newvalue = getValueFromEditor();
taRefText.setText(StringTable.getStringRef(newvalue));
enablePlay(newvalue);
value = getValueFromEditor();
taRefText.setText(StringTable.getStringRef(value));
enablePlay(value);
}

// --------------------- End Interface ChangeListener ---------------------
Expand Down
Loading

0 comments on commit 7cd1990

Please sign in to comment.