mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-08 00:38:38 +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;
|
package org.parabot.core;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import javax.swing.JFileChooser;
|
import javax.swing.JFileChooser;
|
||||||
import javax.swing.filechooser.FileSystemView;
|
|
||||||
|
|
||||||
import org.parabot.environment.OperatingSystem;
|
import org.parabot.environment.OperatingSystem;
|
||||||
|
|
||||||
@@ -18,67 +19,88 @@ import org.parabot.environment.OperatingSystem;
|
|||||||
*/
|
*/
|
||||||
public class Directories {
|
public class Directories {
|
||||||
|
|
||||||
/**
|
private static Map<String, File> cached = new HashMap<String, File>();
|
||||||
* Gets default user directory
|
|
||||||
* @return default user director
|
static {
|
||||||
*/
|
|
||||||
public static File getDefaultDirectory() {
|
|
||||||
switch (OperatingSystem.getOS()) {
|
switch (OperatingSystem.getOS()) {
|
||||||
case WINDOWS:
|
case WINDOWS:
|
||||||
JFileChooser fr = new JFileChooser();
|
cached.put("Root", new JFileChooser().getFileSystemView().getDefaultDirectory());
|
||||||
FileSystemView fw = fr.getFileSystemView();
|
break;
|
||||||
return fw.getDefaultDirectory();
|
|
||||||
default:
|
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
|
* Returns the root directory outside of the main Parabot folder.
|
||||||
* @return workspace of bot
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static File getDefaultDirectory() {
|
||||||
|
return cached.get("Root");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Parabot folder.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
public static File getWorkspace() {
|
public static File getWorkspace() {
|
||||||
return new File(getDefaultDirectory(), "/Parabot/");
|
return cached.get("Workspace");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get script sources path
|
* Returns the script sources folder.
|
||||||
* @return script sources path
|
*
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
public static File getScriptSourcesPath() {
|
public static File getScriptSourcesPath() {
|
||||||
return new File(getDefaultDirectory(), "/Parabot/scripts/sources/");
|
return cached.get("Sources");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get script compiled path
|
* Returns the compiled scripts folder.
|
||||||
* @return script compiled path
|
*
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
public static File getScriptCompiledPath() {
|
public static File getScriptCompiledPath() {
|
||||||
return new File(getDefaultDirectory(), "/Parabot/scripts/compiled/");
|
return cached.get("Compiled");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get script compiled path
|
* Returns the scripts resources folder.
|
||||||
* @return script compiled path
|
*
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
public static File getResourcesPath() {
|
public static File getResourcesPath() {
|
||||||
return new File(getDefaultDirectory(), "/Parabot/scripts/resources/");
|
return cached.get("Resources");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets settings directory
|
* Returns the Parabot settings folder.
|
||||||
* @return settings directory
|
*
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
public static File getSettingsPath() {
|
public static File getSettingsPath() {
|
||||||
return new File(getDefaultDirectory(), "/Parabot/settings/");
|
return cached.get("Settings");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets servers directory
|
* Returns the Parabot servers folder.
|
||||||
* @return servers directory
|
*
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
public static File getServerPath() {
|
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;
|
private static File temp = null;
|
||||||
|
|
||||||
public static File getTempDirectory() {
|
public static File getTempDirectory() {
|
||||||
if (temp != null) {
|
if (temp != null) {
|
||||||
return temp;
|
return temp;
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ public class BotUI extends JFrame implements ActionListener {
|
|||||||
y += iGameHeight;
|
y += iGameHeight;
|
||||||
|
|
||||||
JScrollPane scrlConsole = LogArea.getInstance();
|
JScrollPane scrlConsole = LogArea.getInstance();
|
||||||
scrlConsole.setPreferredSize(new Dimension(765, iLogHeight));
|
scrlConsole.setPreferredSize(new Dimension(765, iLogHeight - 15));
|
||||||
toolbar.setLocation(x, y);
|
toolbar.setLocation(x, y);
|
||||||
|
|
||||||
panel.add(toolbar);
|
panel.add(toolbar);
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import javax.swing.JScrollPane;
|
|||||||
|
|
||||||
import org.parabot.core.desc.ServerDescription;
|
import org.parabot.core.desc.ServerDescription;
|
||||||
import org.parabot.core.parsers.ServerManifestParser;
|
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.utils.SwingUtil;
|
||||||
import org.parabot.core.ui.widgets.ServerWidget;
|
import org.parabot.core.ui.widgets.ServerWidget;
|
||||||
|
|
||||||
@@ -58,6 +57,7 @@ public class ServerSelector extends JFrame {
|
|||||||
|
|
||||||
JScrollPane scrlInterior = new JScrollPane(interior);
|
JScrollPane scrlInterior = new JScrollPane(interior);
|
||||||
scrlInterior.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
scrlInterior.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
||||||
|
scrlInterior.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
|
||||||
|
|
||||||
this.panel.add(scrlInterior, BorderLayout.CENTER);
|
this.panel.add(scrlInterior, BorderLayout.CENTER);
|
||||||
this.add(panel);
|
this.add(panel);
|
||||||
@@ -68,9 +68,12 @@ public class ServerSelector extends JFrame {
|
|||||||
|
|
||||||
public Queue<ServerWidget> getServers() {
|
public Queue<ServerWidget> getServers() {
|
||||||
final Queue<ServerWidget> widgets = new LinkedList<ServerWidget>();
|
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));
|
widgets.add(new ServerWidget(desc));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return widgets;
|
return widgets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user