mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-10-01 02:17:22 +00:00
Directories Cached +
Resized the JScrollPane for the LogArea in the BotUI since it was being cut off and Clispy is too lazy to do it. As well as ticked the vertical bar in the ServerSelector to always be there.
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
package org.parabot.core;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.filechooser.FileSystemView;
|
||||
|
||||
import org.parabot.environment.OperatingSystem;
|
||||
|
||||
@@ -18,67 +19,88 @@ import org.parabot.environment.OperatingSystem;
|
||||
*/
|
||||
public class Directories {
|
||||
|
||||
/**
|
||||
* Gets default user directory
|
||||
* @return default user director
|
||||
*/
|
||||
public static File getDefaultDirectory() {
|
||||
private static Map<String, File> cached = new HashMap<String, File>();
|
||||
|
||||
static {
|
||||
|
||||
switch (OperatingSystem.getOS()) {
|
||||
case WINDOWS:
|
||||
JFileChooser fr = new JFileChooser();
|
||||
FileSystemView fw = fr.getFileSystemView();
|
||||
return fw.getDefaultDirectory();
|
||||
cached.put("Root", new JFileChooser().getFileSystemView().getDefaultDirectory());
|
||||
break;
|
||||
default:
|
||||
return new File(System.getProperty("user.home"));
|
||||
cached.put("Root", new File(System.getProperty("user.home")));
|
||||
}
|
||||
|
||||
cached.put("Root", getDefaultDirectory());
|
||||
cached.put("Workspace", new File(cached.get("Root"), "/Parabot/"));
|
||||
cached.put("Sources", new File(cached.get("Root"), "/Parabot/scripts/sources/"));
|
||||
cached.put("Compiled", new File(cached.get("Root"), "/Parabot/scripts/compiled/"));
|
||||
cached.put("Resources", new File(cached.get("Root"), "/Parabot/scripts/resources/"));
|
||||
cached.put("Settings", new File(cached.get("Root"), "/Parabot/settings/"));
|
||||
cached.put("Servers", new File(cached.get("Root"), "/Parabot/servers/"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets bot workspace
|
||||
* @return workspace of bot
|
||||
* Returns the root directory outside of the main Parabot folder.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static File getDefaultDirectory() {
|
||||
return cached.get("Root");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Parabot folder.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static File getWorkspace() {
|
||||
return new File(getDefaultDirectory(), "/Parabot/");
|
||||
return cached.get("Workspace");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get script sources path
|
||||
* @return script sources path
|
||||
* Returns the script sources folder.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static File getScriptSourcesPath() {
|
||||
return new File(getDefaultDirectory(), "/Parabot/scripts/sources/");
|
||||
return cached.get("Sources");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get script compiled path
|
||||
* @return script compiled path
|
||||
* Returns the compiled scripts folder.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static File getScriptCompiledPath() {
|
||||
return new File(getDefaultDirectory(), "/Parabot/scripts/compiled/");
|
||||
return cached.get("Compiled");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get script compiled path
|
||||
* @return script compiled path
|
||||
* Returns the scripts resources folder.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static File getResourcesPath() {
|
||||
return new File(getDefaultDirectory(), "/Parabot/scripts/resources/");
|
||||
return cached.get("Resources");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets settings directory
|
||||
* @return settings directory
|
||||
* Returns the Parabot settings folder.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static File getSettingsPath() {
|
||||
return new File(getDefaultDirectory(), "/Parabot/settings/");
|
||||
return cached.get("Settings");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets servers directory
|
||||
* @return servers directory
|
||||
* Returns the Parabot servers folder.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static File getServerPath() {
|
||||
return new File(getDefaultDirectory(), "/Parabot/servers/");
|
||||
return cached.get("Servers");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -105,6 +127,7 @@ public class Directories {
|
||||
}
|
||||
|
||||
private static File temp = null;
|
||||
|
||||
public static File getTempDirectory() {
|
||||
if (temp != null) {
|
||||
return temp;
|
||||
|
||||
@@ -76,7 +76,7 @@ public class BotUI extends JFrame implements ActionListener {
|
||||
y += iGameHeight;
|
||||
|
||||
JScrollPane scrlConsole = LogArea.getInstance();
|
||||
scrlConsole.setPreferredSize(new Dimension(765, iLogHeight));
|
||||
scrlConsole.setPreferredSize(new Dimension(765, iLogHeight - 15));
|
||||
toolbar.setLocation(x, y);
|
||||
|
||||
panel.add(toolbar);
|
||||
|
||||
@@ -11,7 +11,6 @@ import javax.swing.JScrollPane;
|
||||
|
||||
import org.parabot.core.desc.ServerDescription;
|
||||
import org.parabot.core.parsers.ServerManifestParser;
|
||||
import org.parabot.core.ui.utils.AwtUtil;
|
||||
import org.parabot.core.ui.utils.SwingUtil;
|
||||
import org.parabot.core.ui.widgets.ServerWidget;
|
||||
|
||||
@@ -58,6 +57,7 @@ public class ServerSelector extends JFrame {
|
||||
|
||||
JScrollPane scrlInterior = new JScrollPane(interior);
|
||||
scrlInterior.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
scrlInterior.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
|
||||
|
||||
this.panel.add(scrlInterior, BorderLayout.CENTER);
|
||||
this.add(panel);
|
||||
@@ -68,9 +68,12 @@ public class ServerSelector extends JFrame {
|
||||
|
||||
public Queue<ServerWidget> getServers() {
|
||||
final Queue<ServerWidget> widgets = new LinkedList<ServerWidget>();
|
||||
for (ServerDescription desc : new ServerManifestParser().getDescriptions()) {
|
||||
ServerDescription[] servers = new ServerManifestParser().getDescriptions();
|
||||
if (servers != null) {
|
||||
for (ServerDescription desc : servers) {
|
||||
widgets.add(new ServerWidget(desc));
|
||||
}
|
||||
}
|
||||
return widgets;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user