Skip to content

Commit

Permalink
Application: Miscellaneous fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadelessFox committed Jul 1, 2024
1 parent 90fb556 commit bfa0837
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public ProgramPanel(@NotNull HwShader.Entry entry) {
this.entry = entry;

final JTextArea area = new JTextArea("// No decompiled data");
area.setFont(new Font(Font.MONOSPACED, area.getFont().getStyle(), area.getFont().getSize()));
area.setFont(UIUtils.getMonospacedFont());
area.setEditable(false);

final JButton button = new JButton("Decompile");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public HexEditor(@NotNull HexModel model) {
setCaret(new DefaultHexCaret());
setDividerSize(4);
setRowLength(16);
setFont(new Font(Font.MONOSPACED, Font.PLAIN, UIUtils.getDefaultFontSize()));
setFont(UIUtils.getMonospacedFont());
setAutoscrolls(true);
setFocusable(true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import static com.shade.decima.ui.menu.MenuConstants.*;

@MenuItemRegistration(parent = CTX_MENU_AUDIO_PLAYER_ID, name = "Export &All Tracks\u2026", icon = "Action.exportIcon", group = CTX_MENU_AUDIO_PLAYER_GROUP_GENERAL, order = 1000)
@MenuItemRegistration(parent = CTX_MENU_AUDIO_PLAYER_ID, name = "Export &All Tracks\u2026", icon = "Action.exportIcon", group = CTX_MENU_AUDIO_PLAYER_GROUP_GENERAL, order = 2000)
public class ExportAllTracksItem extends MenuItem {
private static final Logger log = LoggerFactory.getLogger(ExportAllTracksItem.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import static com.shade.decima.ui.menu.MenuConstants.*;

@MenuItemRegistration(parent = CTX_MENU_AUDIO_PLAYER_ID, name = "Export &Selected Tracks\u2026", icon = "Action.exportIcon", group = CTX_MENU_AUDIO_PLAYER_GROUP_GENERAL, order = 2000)
@MenuItemRegistration(parent = CTX_MENU_AUDIO_PLAYER_ID, name = "Export &Selected Tracks\u2026", icon = "Action.exportIcon", group = CTX_MENU_AUDIO_PLAYER_GROUP_GENERAL, order = 1000)
public class ExportSelectedTracksItem extends ExportAllTracksItem {
@NotNull
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,8 @@ public JComponent createComponent(@NotNull PropertyChangeListener listener) {
tools.add(new JLabel("ffmpeg executable:"));
tools.add(ffmpegPath);

final JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
panel.add(new JLabel(UIManager.getIcon("Action.informationIcon")));
panel.add(UIUtils.createBrowseText("You can download individual entries from the following links: <a href=\"https://github.com/hcs64/ww2ogg\">ww2ogg</a>, <a href=\"https://hydrogenaud.io/index.php/topic,64328.0.html\">revorb</a>, and <a href=\"https://ffmpeg.org/\">ffmpeg</a>"));

tools.add(panel, "span");
tools.add(UIUtils.createInfoText("You can download individual entries from the following links: <a href=\"https://github.com/hcs64/ww2ogg\">ww2ogg</a>, <a href=\"https://hydrogenaud.io/index.php/topic,64328.0.html\">revorb</a>, and <a href=\"https://ffmpeg.org/\">ffmpeg</a>"), "span");
tools.add(UIUtils.createInfoLabel("If you get inaudible results, try picking a different codebooks file"), "span");

return tools;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,14 @@ protected JComponent createContentsPane() {
JEditorPane changelog = UIUtils.createBrowseText(info.contents());
changelog.setPreferredSize(new Dimension(800, 500));

JPanel center = new JPanel();
center.setLayout(new MigLayout("ins dialog"));
center.add(UIUtils.createBorderlessScrollPane(changelog));

JPanel root = new JPanel();
root.setLayout(new BorderLayout());
root.add(header, BorderLayout.NORTH);
root.add(UIUtils.createBorderlessScrollPane(changelog), BorderLayout.CENTER);
root.add(center, BorderLayout.CENTER);

return root;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public static class Settings {
private static final HttpClient client = HttpClient.newHttpClient();

private static final String REPOSITORY_NAME = "ShadelessFox/decima";
private static final String CURRENT_TAG = "v" + BuildConfig.APP_VERSION;
private static final long CHECK_PERIOD = Duration.ofDays(1).toMinutes();

private Settings settings = new Settings();
Expand Down Expand Up @@ -155,7 +156,7 @@ private UpdateInfo fetchUpdateInfo(@NotNull ProgressMonitor monitor) throws Exce
}

String latestTag = release.get("tag_name").getAsString();
if (latestTag.equals("v" + BuildConfig.APP_VERSION)) {
if (latestTag.equals(CURRENT_TAG)) {
// No updates available
return null;
}
Expand All @@ -178,7 +179,7 @@ private static JsonObject fetchLatestRelease() throws IOException, InterruptedEx
HttpRequest.newBuilder()
.uri(URI.create("https://api.github.com" + "/repos/" + REPOSITORY_NAME + "/releases/latest"))
.build(),
info1 -> HttpResponse.BodySubscribers.mapping(
info -> HttpResponse.BodySubscribers.mapping(
HttpResponse.BodySubscribers.ofString(StandardCharsets.UTF_8),
body -> JsonParser.parseString(body).getAsJsonObject()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class FileChooser extends JFileChooser {
public void approveSelection() {
final File file = getSelectedFile();

if (file != null && file.exists() && getDialogType() == SAVE_DIALOG) {
if (file != null && file.exists() && getFileSelectionMode() == FILES_ONLY && getDialogType() == SAVE_DIALOG) {
final int result = JOptionPane.showConfirmDialog(
this,
"File '%s' already exists. Do you want to overwrite it?".formatted(file.getName()),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.shade.platform.ui.dialogs;

import com.shade.platform.ui.controls.LabeledSeparator;
import com.shade.platform.ui.util.UIUtils;
import com.shade.util.NotNull;
import net.miginfocom.swing.MigLayout;

Expand Down Expand Up @@ -29,7 +30,7 @@ protected JComponent createContentsPane() {

{
final JTextArea view = new JTextArea(throwable.getMessage());
view.setFont(new Font(Font.MONOSPACED, view.getFont().getStyle(), view.getFont().getSize()));
view.setFont(UIUtils.getMonospacedFont());
view.setEditable(false);
view.setLineWrap(true);

Expand All @@ -39,7 +40,7 @@ protected JComponent createContentsPane() {

{
final JTextArea view = new JTextArea(getStackTrace(throwable));
view.setFont(new Font(Font.MONOSPACED, view.getFont().getStyle(), view.getFont().getSize()));
view.setFont(UIUtils.getMonospacedFont());
view.setEditable(false);

panel.add(new LabeledSeparator("Stack trace"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,12 @@ private UIUtils() {

@NotNull
public static Font getDefaultFont() {
Font font = UIManager.getFont("defaultFont");

if (font == null) {
font = UIManager.getFont("Label.font");
}
return UIManager.getFont("Label.font");
}

return font;
@NotNull
public static Font getMonospacedFont() {
return UIManager.getFont("monospaced.font");
}

public static int getDefaultFontSize() {
Expand Down Expand Up @@ -536,6 +535,16 @@ public static JLabel createInfoLabel(@NotNull String text) {
return label;
}

@NotNull
public static JPanel createInfoText(@NotNull String text) {
JLabel icon = new JLabel(UIManager.getIcon("Action.informationIcon"));
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout(icon.getIconTextGap(), 0));
panel.add(icon, BorderLayout.WEST);
panel.add(UIUtils.createBrowseText(text));
return panel;
}

@NotNull
public static JEditorPane createBrowseText(@NotNull String text) {
return createText(text, new HyperlinkAdapter() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Button.toolbar.spacingInsets = 2,2,2,2
Button.toolbar.margin = 2,2,2,2
Button.margin = 4,14,4,14
ToolTip.border = 4,8,4,8
EditorPane.margin = 0,0,0,0

Component.error.borderColor = #fad4d8
Component.error.background = lighten($Component.error.borderColor, 4%)
Expand Down

0 comments on commit bfa0837

Please sign in to comment.