Permalink
Browse files

add: ScreenshotRepositoryBase, so one can set that path in the config…

… file
  • Loading branch information...
1 parent 337e8cb commit c1b00087a5be3ca993019c1a2c9701d23a2bb993 @SpiritQuaddicted committed Jan 22, 2011
@@ -98,6 +98,12 @@ private RepositoryDatabasePath() { super("repositoryDatabase",
"http://www.quaddicted.com/reviews/quaddicted_database.xml"); }
}
public final RepositoryDatabasePath RepositoryDatabasePath = new RepositoryDatabasePath();
+
+ public class ScreenshotRepositoryPath extends StringValue {
+ private ScreenshotRepositoryPath() { super("screenshotRepositoryPath",
+ "http://www.quaddicted.com/reviews/screenshots/"); }
+ }
+ public final ScreenshotRepositoryPath ScreenshotRepositoryPath = new ScreenshotRepositoryPath();
@SpiritQuaddicted

SpiritQuaddicted Jan 24, 2011

Owner

Simply copied the RepositoryDatabasePath block and changed it to ScreenshotRepositoryPath. Gives a default value.

public class ZipContentsDatabaseUrl extends StringValue {
private ZipContentsDatabaseUrl() { super("ZipContentsDatabaseUrl",
@@ -90,6 +90,8 @@
private BrowserLauncher launcher = null;
+ private String screenshotRepositoryPath;
+
/**
* Holds the currently valid screenshot url, for threading reasons
*/
@@ -109,8 +111,10 @@ private ImageIcon createImageIcon(String path, String description) {
}
- public PackageDetailPanel() {
+ public PackageDetailPanel(String screenshotRepositoryPath) {
@SpiritQuaddicted

SpiritQuaddicted Jan 24, 2011

Owner

We need to pass the screenshotRepositoryPath to this constructor or it would not know about it.

super(new GridBagLayout());
+
+ this.screenshotRepositoryPath = screenshotRepositoryPath;
@SpiritQuaddicted

SpiritQuaddicted Jan 24, 2011

Owner

Make it the screenshotRepositoryPath we passed to this object, otherwise we would get a nullpointer exception.

{
try {
@@ -267,9 +271,8 @@ private void refreshUi() {
image.setIcon(null);
-
- supposedImageUrl = "http://www.quaddicted.com/reviews/screenshots/" + current.getId()
- +"_injector.jpg";
+
+ supposedImageUrl = screenshotRepositoryPath + current.getId() + "_injector.jpg";
@SpiritQuaddicted

SpiritQuaddicted Jan 24, 2011

Owner

Changing the hardcoded URL to a variable.

current.getId() returns the currently selected packages' id, for example "gmsp3".

//load image in bg thread
new SwingWorker<ImageIcon,Void>() {
@@ -304,7 +307,7 @@ public void done() {
if (icon == null || icon.getImageLoadStatus() != java.awt.MediaTracker.COMPLETE) {
removeImage();
- System.err.println("Couldn't load image " + current.getId());
+ System.err.println("Couldn't load image " + supposedImageUrl);
@SpiritQuaddicted

SpiritQuaddicted Jan 24, 2011

Owner

I used this to debug. Since it is user-configurable now, it makes sense to log the full URL to stdout for troubleshooting.

}
else {
image.setIcon(icon);
@@ -149,7 +149,6 @@ public QuakeInjector() {
setMinimumSize(new Dimension(minWidth, minHeight));
- addMainPane(getContentPane());
addWindowListener(new QuakeInjectorWindowListener());
@@ -171,6 +170,7 @@ public QuakeInjector() {
//config needed here
setWindowSize();
+ addMainPane(getContentPane());
@SpiritQuaddicted

SpiritQuaddicted Jan 24, 2011

Owner

I had to move it down here, because config, a object holding the configuration values was not set earlier.

}
/**
@@ -195,7 +195,7 @@ public void actionPerformed(ActionEvent e) {
public void actionPerformed(ActionEvent e) {
setVisible(false);
dispose();
- }
+ }
};
ActionListener showEngineConfig = new ActionListener() {
@@ -353,7 +353,7 @@ private InputStream downloadDatabase(String databaseUrl) throws IOException {
}
catch (IOException e) {
//try reading the cached version if downloading fails
- System.err.println("Downloading the database failed.");
+ System.err.println("Downloading the database failed. "+databaseUrl);
if (cache.exists() && cache.canRead()) {
System.err.println("Using cached database file (" + cache + ") instead.");
db = new BufferedInputStream(new FileInputStream(cache));
@@ -708,8 +708,10 @@ private void filter() {
this.interactionPanel = new PackageInteractionPanel(this, installQueue);
JPanel infoPanel = new JPanel(new GridBagLayout());
-
- PackageDetailPanel details = new PackageDetailPanel();
+
+ Configuration config = getConfig();
@SpiritQuaddicted

SpiritQuaddicted Jan 24, 2011

Owner

Getting access to the configuration values.

+ PackageDetailPanel details = new PackageDetailPanel(config.ScreenshotRepositoryPath.get());
@SpiritQuaddicted

SpiritQuaddicted Jan 24, 2011

Owner

Creating the PackageDetailPanel, passing our ScreenshotRepositoryPath as parameter.

+
infoPanel.add(details, new GridBagConstraints() {{
anchor = PAGE_START;
fill = BOTH;

1 comment on commit c1b0008

mrg: spirits screenshot url cfg patch

Please sign in to comment.