Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
Argent77 committed Mar 3, 2023
2 parents 6e66a76 + 29706ae commit a11d887
Show file tree
Hide file tree
Showing 35 changed files with 4,062 additions and 1,804 deletions.
2 changes: 1 addition & 1 deletion .classpath
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-3.3.0-sources.jar"/>
<classpathentry exported="true" kind="lib" path="lib/rsyntaxtextarea/rsyntaxtextarea.jar" sourcepath="lib/rsyntaxtextarea/rsyntaxtextarea-3.3.2-sources.jar"/>
<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 exported="true" kind="lib" path="lib/apng-writer/apng-writer-core.jar" sourcepath="lib/apng-writer/apng-writer-core-src.zip"/>
Expand Down
2 changes: 1 addition & 1 deletion lib/rsyntaxtextarea/RSyntaxTextArea.License.txt
@@ -1,4 +1,4 @@
Copyright (c) 2022, Robert Futrell
Copyright (c) 2023, Robert Futrell
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
Binary file not shown.
Binary file modified lib/rsyntaxtextarea/rsyntaxtextarea.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion src/org/infinity/RSyntaxTextArea.License.txt
@@ -1,4 +1,4 @@
Copyright (c) 2019, Robert Futrell
Copyright (c) 2023, Robert Futrell
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
6 changes: 5 additions & 1 deletion src/org/infinity/datatype/AreResourceRef.java
Expand Up @@ -9,6 +9,7 @@
import org.infinity.resource.Profile;
import org.infinity.resource.ResourceFactory;
import org.infinity.resource.are.AreResource;
import org.infinity.resource.key.BIFFEntry;
import org.infinity.resource.key.BIFFResourceEntry;
import org.infinity.resource.key.ResourceEntry;

Expand All @@ -26,7 +27,10 @@ public AreResourceRef(ByteBuffer buffer, int offset, String name, AreResource ar
.getResourceEntry(((ResourceRef) are.getAttribute(AreResource.ARE_WED_RESOURCE)).getResourceName());
String wedBIFF = "_dummy";
if (res instanceof BIFFResourceEntry) {
wedBIFF = ((BIFFResourceEntry) res).getBIFFEntry().getFileName();
BIFFEntry biffEntry = ((BIFFResourceEntry) res).getBIFFEntry();
if (biffEntry != null) {
wedBIFF = biffEntry.getFileName();
}
}
if (Profile.getEngine() == Profile.Engine.BG1) {
legalBIFs = new String[] { wedBIFF, "data/sfxsound.bif", "data/cresound.bif" };
Expand Down
1 change: 1 addition & 0 deletions src/org/infinity/datatype/TextEdit.java
Expand Up @@ -211,6 +211,7 @@ public ByteBuffer toBuffer() {
buffer.put((byte) 0);
}
}
buffer.position(0);
}
return buffer;
}
Expand Down
40 changes: 35 additions & 5 deletions src/org/infinity/gui/BrowserMenuBar.java
Expand Up @@ -117,7 +117,7 @@
import org.infinity.util.tuples.Couple;

public final class BrowserMenuBar extends JMenuBar implements KeyEventDispatcher {
public static final String VERSION = "v2.3-20221108";
public static final String VERSION = "v2.3-20230303";

public static final LookAndFeelInfo DEFAULT_LOOKFEEL =
new LookAndFeelInfo("Metal", "javax.swing.plaf.metal.MetalLookAndFeel");
Expand Down Expand Up @@ -292,6 +292,20 @@ public boolean showSysInfo() {
return optionsMenu.optionShowSystemInfo.isSelected();
}

/** Returns whether to show a dialog prompt whenever a bookmarked game is opened. */
public boolean showOpenBookmarksPrompt() {
return optionsMenu.optionOpenBookmarksPrompt.isSelected();
}

/**
* Controls whether to show a dialog prompt whenever a bookmarked game is opened.
*
* @param show {@code true} to show a dialog prompt, {@code false} to open bookmarked games without confirmation.
*/
public void setShowOpenBookmarksPrompt(boolean show) {
optionsMenu.optionOpenBookmarksPrompt.setSelected(show);
}

/** Returns whether scripts are automatically scanned for compile errors. */
public boolean autocheckBCS() {
return optionsMenu.optionAutocheckBCS.isSelected();
Expand Down Expand Up @@ -1087,9 +1101,18 @@ public void actionPerformed(ActionEvent event) {
e.printStackTrace();
}
if (!isEqual) {
String message = String.format("Open bookmarked game \"%s\"?", bookmark.getName());
int confirm = JOptionPane.showConfirmDialog(NearInfinity.getInstance(), message, "Open game",
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
int confirm = JOptionPane.YES_OPTION;
if (BrowserMenuBar.getInstance().showOpenBookmarksPrompt()) {
String message = String.format("Open bookmarked game \"%s\"?", bookmark.getName());
Couple<Integer, Boolean> result = StandardDialogs.showConfirmDialogExtra(NearInfinity.getInstance(),
message, "Open game", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,
StandardDialogs.Extra.with(StandardDialogs.Extra.MESSAGE_DO_NOT_SHOW_PROMPT,
"Confirmation prompt can be enabled or disabled in the options menu."));
if (result.getValue1()) {
BrowserMenuBar.getInstance().setShowOpenBookmarksPrompt(false);
}
confirm = result.getValue0();
}
if (confirm == JOptionPane.YES_OPTION) {
NearInfinity.getInstance().openGame(keyFile);
}
Expand Down Expand Up @@ -1850,6 +1873,7 @@ private static final class OptionsMenu extends JMenu implements ActionListener,
private static final String OPTION_SHOWCOLOREDSTRUCTURES = "ShowColoredStructures";
private static final String OPTION_SHOWHEXCOLORED = "ShowHexColored";
private static final String OPTION_SHOWSYSINFO = "ShowSysInfo";
private static final String OPTION_OPENBOOKMARKSPROMPT = "OpenBookmarksPrompt";
private static final String OPTION_KEEPVIEWONCOPY = "UpdateTreeOnCopy";
private static final String OPTION_SHOWTREESEARCHNAMES = "ShowTreeSearchNames";
private static final String OPTION_HIGHLIGHT_OVERRIDDEN = "HighlightOverridden";
Expand Down Expand Up @@ -1945,6 +1969,7 @@ private static final class OptionsMenu extends JMenu implements ActionListener,
private JCheckBoxMenuItem optionShowColoredStructures;
private JCheckBoxMenuItem optionShowHexColored;
private JCheckBoxMenuItem optionShowSystemInfo;
private JCheckBoxMenuItem optionOpenBookmarksPrompt;
private JCheckBoxMenuItem optionShowUnknownResources;
private JCheckBoxMenuItem optionKeepViewOnCopy;
private JCheckBoxMenuItem optionTreeSearchNames;
Expand Down Expand Up @@ -2058,8 +2083,12 @@ private OptionsMenu() {
optionShowHexColored = new JCheckBoxMenuItem("Show colored blocks in Raw tabs",
getPrefs().getBoolean(OPTION_SHOWHEXCOLORED, true));
add(optionShowHexColored);
optionShowSystemInfo = new JCheckBoxMenuItem("Display system information at startup", getPrefs().getBoolean(OPTION_SHOWSYSINFO, true));
optionShowSystemInfo = new JCheckBoxMenuItem("Display system information at startup",
getPrefs().getBoolean(OPTION_SHOWSYSINFO, true));
add(optionShowSystemInfo);
optionOpenBookmarksPrompt = new JCheckBoxMenuItem("Confirm opening bookmarked games",
getPrefs().getBoolean(OPTION_OPENBOOKMARKSPROMPT, true));
add(optionOpenBookmarksPrompt);

addSeparator();

Expand Down Expand Up @@ -2714,6 +2743,7 @@ private void storePreferences() {
getPrefs().putBoolean(OPTION_SHOWCOLOREDSTRUCTURES, optionShowColoredStructures.isSelected());
getPrefs().putBoolean(OPTION_SHOWHEXCOLORED, optionShowHexColored.isSelected());
getPrefs().putBoolean(OPTION_SHOWSYSINFO, optionShowSystemInfo.isSelected());
getPrefs().putBoolean(OPTION_OPENBOOKMARKSPROMPT, optionOpenBookmarksPrompt.isSelected());
getPrefs().putBoolean(OPTION_KEEPVIEWONCOPY, optionKeepViewOnCopy.isSelected());
getPrefs().putBoolean(OPTION_SHOWTREESEARCHNAMES, optionTreeSearchNames.isSelected());
getPrefs().putBoolean(OPTION_HIGHLIGHT_OVERRIDDEN, optionHighlightOverridden.isSelected());
Expand Down
2 changes: 1 addition & 1 deletion src/org/infinity/gui/InfinityAmp.java
Expand Up @@ -272,7 +272,7 @@ private void playMus(ResourceEntry musEntry) {
int nextnr = 0;
while (keepPlaying) {
AudioBuffer audio = entryList.get(nextnr).getAudioBuffer();
player.play(audio);
player.playContinuous(audio);
if (entryList.get(nextnr).getNextNr() <= nextnr || entryList.get(nextnr).getNextNr() >= entryList.size()) {
break;
}
Expand Down
23 changes: 14 additions & 9 deletions src/org/infinity/gui/RenderCanvas.java
Expand Up @@ -309,14 +309,12 @@ public void setComposite(Composite c) {
composite = (c != null) ? c : AlphaComposite.SrcOver;
}

protected void update() {
invalidate();
if (getParent() != null) {
getParent().repaint();
}
}

protected Rectangle getCanvasSize() {
/**
* Returns the actual placement of the image canvas within the {@code RenderCanvas} component.
*
* @return {@code Rectangle} of the canvas bounds relative to the {@code RenderCanvas} component.
*/
public Rectangle getCanvasBounds() {
Rectangle rect = new Rectangle();
if (currentImage != null) {
rect.width = currentImage.getWidth(null);
Expand Down Expand Up @@ -349,6 +347,13 @@ protected Rectangle getCanvasSize() {
return rect;
}

protected void update() {
invalidate();
if (getParent() != null) {
getParent().repaint();
}
}

/**
* Renders the image to the canvas.
*
Expand All @@ -359,7 +364,7 @@ protected void paintCanvas(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
Composite oldComposite = g2.getComposite();
g2.setComposite(getComposite());
Rectangle rect = getCanvasSize();
Rectangle rect = getCanvasBounds();
if (isScaling) {
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, interpolationType);
g2.drawImage(currentImage, rect.x, rect.y, rect.width, rect.height, null);
Expand Down

0 comments on commit a11d887

Please sign in to comment.