Skip to content
This repository has been archived by the owner on Oct 6, 2018. It is now read-only.

Commit

Permalink
386
Browse files Browse the repository at this point in the history
  • Loading branch information
MightyPork committed May 10, 2014
1 parent c8d9342 commit a22859c
Show file tree
Hide file tree
Showing 13 changed files with 163 additions and 858 deletions.
3 changes: 3 additions & 0 deletions src/data/changelog/386.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Bugfixes
- Improved stability
- UI improvements
6 changes: 5 additions & 1 deletion src/data/tree/filtersVanilla.txt
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ root.image.gui = assets.minecraft.textures.gui.*

root.image.misc = assets.minecraft.textures.misc.* | assets.minecraft.textures.painting.* | assets.minecraft.textures.effect.*

root.image.entity.misc.chest = assets.minecraft.textures.entity.chest.*
root.image.entity.misc = assets.minecraft.textures.entity.endercrystal.* | assets.minecraft.textures.entity.arrow | assets.minecraft.textures.entity.beacon_beam | assets.minecraft.textures.entity.boat | assets.minecraft.textures.entity.end_portal | assets.minecraft.textures.entity.enchanting_table_book | assets.minecraft.textures.entity.experience_orb | assets.minecraft.textures.entity.lead_knot | assets.minecraft.textures.entity.minecart | assets.minecraft.textures.entity.sign

root.image.entity.armor = assets.minecraft.textures.models.armor.*
Expand All @@ -215,8 +214,13 @@ root.image.entity.mob.wolf = assets.minecraft.textures.entity.wolf.*
root.image.entity.mob.zombie = assets.minecraft.textures.entity.zombie.*
root.image.entity.mob = assets.minecraft.textures.entity.silverfish | assets.minecraft.textures.entity.bat | assets.minecraft.textures.entity.blaze | assets.minecraft.textures.entity.chicken | assets.minecraft.textures.entity.iron_golem | assets.minecraft.textures.entity.snowman | assets.minecraft.textures.entity.squid | assets.minecraft.textures.entity.witch | assets.minecraft.textures.entity.zombie_pigman | assets.minecraft.textures.entity.steve

# Chests moved to blocks to make it easier to find
root.image.block.chest = assets.minecraft.textures.entity.chest.*

root.image.entity = assets.minecraft.textures.entity.*



root.image.block.redstone.machines = assets.minecraft.textures.blocks.mob_spawner | assets.minecraft.textures.blocks.command_block | assets.minecraft.textures.blocks.dispenser_* | assets.minecraft.textures.blocks.dropper_* | assets.minecraft.textures.blocks.hopper_* | assets.minecraft.textures.blocks.jukebox_* | assets.minecraft.textures.blocks.noteblock | assets.minecraft.textures.blocks.piston_* | assets.minecraft.textures.blocks.redstone_lamp_* | assets.minecraft.textures.blocks.tnt_*
root.image.block.redstone.circuitry = assets.minecraft.textures.blocks.comparator_* | assets.minecraft.textures.blocks.daylight_detector_* | assets.minecraft.textures.blocks.lever | assets.minecraft.textures.blocks.redstone_dust_* | assets.minecraft.textures.blocks.redstone_torch_* | assets.minecraft.textures.blocks.repeater_* | assets.minecraft.textures.blocks.trip_wire*
root.image.block.redstone = NULL
Expand Down
3 changes: 1 addition & 2 deletions src/data/tree/groupsVanilla.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ root.image.entity.mob.wither = Wither
root.image.entity.mob.wolf = Wolf
root.image.entity.mob.zombie = Zombie
root.image.entity.misc = Other
root.image.entity.misc.chest = Chests
root.image.entity.misc.chest = Ender Crystal
root.image.block.chest = Chests
root.image.gui = Menu & Gui
root.image.gui.achievement = Achievement Screen
root.image.gui.map = Maps
Expand Down
2 changes: 1 addition & 1 deletion src/net/mightypork/rpw/Const.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

public class Const {

public static final int VERSION_SERIAL = 385;
public static final int VERSION_SERIAL = 386;

public static final String VERSION = VersionUtils.getVersionString(VERSION_SERIAL);
public static final int VERSION_MAJOR = VersionUtils.getVersionMajor(VERSION_SERIAL);
Expand Down
10 changes: 5 additions & 5 deletions src/net/mightypork/rpw/gui/Icons.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ public class Icons {
public static ImageIcon DIALOG_QUESTION;
public static ImageIcon DIALOG_WARNING;

private static ImageIcon IMAGE_ERROR_16;
private static ImageIcon IMAGE_ERROR_32;
private static ImageIcon IMAGE_ERROR_64;
private static ImageIcon IMAGE_ERROR_128;
public static ImageIcon IMAGE_ERROR_16;
public static ImageIcon IMAGE_ERROR_32;
public static ImageIcon IMAGE_ERROR_64;
public static ImageIcon IMAGE_ERROR_128;

private static ImageIcon IMAGE_NOT_FOUND;
public static ImageIcon IMAGE_NOT_FOUND;


public static void init()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class JPanelWithBackground extends JPanel {
private Image image;


public void setbackground(Image image)
public void setBackground(Image image)
{
this.image = image;
repaint();
Expand Down
96 changes: 62 additions & 34 deletions src/net/mightypork/rpw/gui/widgets/SidePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import net.mightypork.rpw.tree.assets.tree.AssetTreeNode;
import net.mightypork.rpw.utils.Utils;
import net.mightypork.rpw.utils.files.FileUtils;
import net.mightypork.rpw.utils.logging.Log;

import org.jdesktop.swingx.JXLabel;
import org.jdesktop.swingx.JXPanel;
Expand Down Expand Up @@ -77,7 +78,8 @@ public class SidePanel {
private Border previewBorder;


public SidePanel() {
public SidePanel()
{
panel = new JXPanel();
panel.setBorder(BorderFactory.createEmptyBorder(Gui.GAP, Gui.GAPL, Gui.GAP, Gui.GAPL));

Expand Down Expand Up @@ -331,18 +333,26 @@ private Box createProjectInfoBox()

hb = new HBox();
hb.glue();
hb.add(projectIconLabel = new JXLabel());

JPanel jPanel = new JPanel();

hb.add(jPanel);

jPanel.add(projectIconLabel = new JXLabel());

//@formatter:off
projectIconLabel.setBorder(
jPanel.setBorder(
BorderFactory.createTitledBorder(
new CompoundBorder(
BorderFactory.createLineBorder(new Color(0x666666)),
BorderFactory.createEmptyBorder(5, 5, 5, 5)
),
"Pack Icon"
)
);
);

jPanel.setMaximumSize(new Dimension(145, 165));
jPanel.setPreferredSize(new Dimension(145, 165));

projectIconLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

Expand Down Expand Up @@ -386,6 +396,7 @@ public void updateProjectInfo()
final ImageIcon ic = Icons.getIconFromFile(iconFile, new Dimension(128, 128));
projectIconLabel.setIcon(ic);


infoBox.setVisible(true);

} else {
Expand Down Expand Up @@ -419,41 +430,51 @@ public void updatePreview(AssetTreeNode selected)

displayedLeaf = leaf;

InputStream in;
InputStream in = null;

final EAsset type = leaf.getAssetType();

if (type.isImage()) {
// image asset
final String key = leaf.getAssetKey();
if (key.startsWith("assets.minecraft.textures.font.")) {
previewImageBg.setbackground(Icons.TRANSPARENT_FONTS.getImage());
previewImageBg.setBackground(Icons.TRANSPARENT_FONTS.getImage());
} else {
previewImageBg.setbackground(Icons.TRANSPARENT.getImage());
previewImageBg.setBackground(Icons.TRANSPARENT.getImage());
}

try {

in = Sources.getAssetStream(source, leaf.getAssetKey());
} catch (final IOException e) {
return;
}

if (in == null) {
previewImage.setIcon(null);
} else {
final ImageIcon i = Icons.getIconFromStream(in, new Dimension(256, 256));
if (in == null) {
previewImage.setIcon(null);
} else {
final ImageIcon i = Icons.getIconFromStream(in, new Dimension(256, 256));

previewImage.setIcon(i);

final String fn = Utils.cropStringAtEnd(fname, 25);

previewImageBorder.setTitle(fn + " (" + i.getDescription() + ")");
}

final boolean metaInProj = leaf.isMetaProvidedByProject();
btnMetaI.setIcon(metaInProj ? Icons.MENU_EDIT : Icons.MENU_NEW);

previewImage.setIcon(i);
previewCardLayout.show(previewPanel, IMAGE);

final String fn = Utils.cropStringAtEnd(fname, 25);

previewImageBorder.setTitle(fn + " (" + i.getDescription() + ")");
} catch (IOException e) {
Log.e(e);
return;
} finally {
try {
if (in != null) in.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}

final boolean metaInProj = leaf.isMetaProvidedByProject();
btnMetaI.setIcon(metaInProj ? Icons.MENU_EDIT : Icons.MENU_NEW);

previewCardLayout.show(previewPanel, IMAGE);

} else if (type.isText()) {
// text asset
Expand All @@ -462,21 +483,28 @@ public void updatePreview(AssetTreeNode selected)
try {
in = Sources.getAssetStream(leaf.resolveAssetSource(), leaf.getAssetKey());
text = FileUtils.streamToString(in, 100);
} catch (final Exception e) {
return;
}

if (in == null) {
previewText.setText("");
} else {
previewText.setText(text);
if (in == null) {
previewText.setText("");
} else {
previewText.setText(text);

previewTextBorder.setTitle(fname);
}

previewTextBorder.setTitle(fname);
previewText.setCaretPosition(0); // scroll to top

previewCardLayout.show(previewPanel, TEXT);
} catch (IOException e) {
Log.e(e);
return;
} finally {
try {
if (in != null) in.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}

previewText.setCaretPosition(0); // scroll to top

previewCardLayout.show(previewPanel, TEXT);

} else if (type.isSound()) {
// sound asset
Expand Down
3 changes: 2 additions & 1 deletion src/net/mightypork/rpw/project/Project.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,9 @@ public void reload()

saveToTmp();

} catch (final IOException e) {
} catch (final Exception e) {
Log.w(getLogPrefix() + "Project data files could not be loaded.");
Alerts.error(App.getFrame(), "An arror occured while loading the project.\nPlease, check the log for details.");
}

}
Expand Down
64 changes: 37 additions & 27 deletions src/net/mightypork/rpw/tasks/TaskExportProject.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.mightypork.rpw.tasks;


import java.awt.EventQueue;
import java.io.File;

import javax.swing.JOptionPane;
Expand All @@ -19,34 +20,43 @@ public static void showDialog()
{
if (!Projects.isOpen()) return;

final Project project = Projects.getActive();

final FileChooser fc = new FileChooser(App.getFrame(), FilePath.EXPORT, "Export project", FileChooser.ZIP, true, false, false);

final File dir = fc.getCurrentDirectory();
final File file = new File(dir, project.getName() + ".zip");
fc.setSelectedFile(file);

fc.showDialog("Export");
if (!fc.approved()) {
return;
}

final File f = fc.getSelectedFile();

if (f.exists()) {
//@formatter:off
final int overwrite = Alerts.askYesNoCancel(
App.getFrame(),
"File Exists",
"File \"" + f.getName() + "\" already exists.\n" +
"Do you want to overwrite it?"
);
//@formatter:on
EventQueue.invokeLater(new Runnable() {

if (overwrite != JOptionPane.YES_OPTION) return;
}
@Override
public void run()
{
final Project project = Projects.getActive();

final FileChooser fc = new FileChooser(App.getFrame(), FilePath.EXPORT, "Export project", FileChooser.ZIP, true, false, false);

final File dir = fc.getCurrentDirectory();
final File file = new File(dir, project.getName() + ".zip");
fc.setSelectedFile(file);

fc.showDialog("Export");
if (!fc.approved()) {
return;
}

final File f = fc.getSelectedFile();

if (f.exists()) {
//@formatter:off
final int overwrite = Alerts.askYesNoCancel(
App.getFrame(),
"File Exists",
"File \"" + f.getName() + "\" already exists.\n" +
"Do you want to overwrite it?"
);
//@formatter:on

if (overwrite != JOptionPane.YES_OPTION) return;
}

Tasks.taskExportProject(f, null);
}
});


Tasks.taskExportProject(f, null);
}
}
Loading

0 comments on commit a22859c

Please sign in to comment.