mirror of
https://github.com/2006-Scape/Script-Factory.git
synced 2026-07-02 16:49:10 +00:00
Update paint, Add XP per hour gained
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package scriptfactory;
|
||||
|
||||
import org.parabot.environment.api.utils.Timer;
|
||||
import scriptfactory.GUI.GUI;
|
||||
import scriptfactory.Strategies.RunLoop;
|
||||
import scriptfactory.Actions.Action;
|
||||
@@ -20,13 +21,14 @@ import static scriptfactory.VarsMethods.log;
|
||||
* Welcome to AIO AIO - ScriptFactory. Make your own scripts!
|
||||
*/
|
||||
|
||||
@ScriptManifest(author = "Before", name = "Script Factory 1.9", category = Category.OTHER, version = 1.9, description = "Create your own scripts!", servers = "All")
|
||||
@ScriptManifest(author = "Before", name = "Script Factory 1.10", category = Category.OTHER, version = 1.10, description = "Create your own scripts!", servers = "All")
|
||||
public class Core extends Script implements Paintable {
|
||||
|
||||
private ArrayList<Action> actions = new ArrayList<>();
|
||||
private ArrayList<Strategy> strategies = new ArrayList<>();
|
||||
|
||||
private GUI gui;
|
||||
public Timer SCRIPT_TIMER;
|
||||
|
||||
@Override
|
||||
public boolean onExecute() {
|
||||
@@ -45,12 +47,15 @@ public class Core extends Script implements Paintable {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!gui.scriptStarted)
|
||||
{
|
||||
gui.killAllGuis();
|
||||
VarsMethods.savescript(actions, new File(VarsMethods.CACHED_LOC));
|
||||
return false;
|
||||
}
|
||||
VarsMethods.calculateBaseXP();
|
||||
SCRIPT_TIMER = new Timer();
|
||||
|
||||
strategies.add(new RunLoop(actions));
|
||||
provide(strategies);
|
||||
@@ -59,20 +64,33 @@ public class Core extends Script implements Paintable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
try { g.setColor(Color.BLUE);
|
||||
g.fillRect(560, 310, 170, 70);
|
||||
public void paint(Graphics graphics) {
|
||||
try {
|
||||
Graphics2D g = (Graphics2D) graphics;
|
||||
Color c2 = new Color(44, 62, 80, 160);
|
||||
g.setColor(c2);
|
||||
g.setBackground(c2);
|
||||
g.fillRect(4, 232, 160, 20);
|
||||
|
||||
g.setColor(Color.YELLOW);
|
||||
g.setFont(new Font("Cordia New", Font.PLAIN, 16));
|
||||
g.drawString("Script Factory", 580, 330);
|
||||
g.setFont(new Font("Cordia New", Font.PLAIN, 12));
|
||||
g.drawString("Currently executing: ", 580, 347);
|
||||
g.drawString(VarsMethods.currentAction, 580, 360);
|
||||
g.drawString(VarsMethods.currentSubscript.equals("") ? "" : "Subscript " + VarsMethods.currentSubscript, 580, 373);}
|
||||
catch (Exception e)
|
||||
{
|
||||
log("Found it");
|
||||
Color c = new Color(44, 62, 80, 80);
|
||||
g.setColor(c);
|
||||
g.setBackground(c);
|
||||
g.fillRect(4, 252, 160, 85);
|
||||
|
||||
g.setColor(Color.WHITE);
|
||||
g.setFont(new Font("Arial", Font.BOLD, 14));
|
||||
g.drawString("Script Factory", 9, 247);
|
||||
g.setFont(new Font("Arial", Font.BOLD, 11));
|
||||
if (SCRIPT_TIMER == null) {
|
||||
g.drawString("Awaiting Start:", 9, 270);
|
||||
return;
|
||||
}
|
||||
g.drawString("Currently Executing:", 9, 270);
|
||||
g.drawString(VarsMethods.currentAction, 9, 290);
|
||||
g.drawString("EXP(P/H): " + VarsMethods.formatNumber((int) VarsMethods.gainedXP) + "(" + VarsMethods.formatNumber(SCRIPT_TIMER.getPerHour((int) VarsMethods.gainedXP)) + ")", 9, 310);
|
||||
g.drawString("Runtime: " + SCRIPT_TIMER.toString(), 9, 330);
|
||||
} catch (Exception e) {
|
||||
log("Paint Error");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package scriptfactory.Strategies;
|
||||
|
||||
import scriptfactory.Actions.Action;
|
||||
import org.parabot.environment.scripts.framework.Strategy;
|
||||
import scriptfactory.VarsMethods;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -25,6 +26,7 @@ public class RunLoop implements Strategy {
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
VarsMethods.calculateGainedXP();
|
||||
actionExecutor.execute();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package scriptfactory;
|
||||
|
||||
import org.parabot.core.ui.Logger;
|
||||
import org.rev317.min.api.methods.GroundItems;
|
||||
import org.rev317.min.api.methods.Items;
|
||||
import org.rev317.min.api.methods.Npcs;
|
||||
import org.rev317.min.api.methods.SceneObjects;
|
||||
import org.rev317.min.api.methods.*;
|
||||
import scriptfactory.Actions.Action;
|
||||
import scriptfactory.Actions.Logic.Endif;
|
||||
import scriptfactory.Actions.Logic.If;
|
||||
@@ -13,12 +10,15 @@ import scriptfactory.Actions.Logic.IfNot;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class VarsMethods {
|
||||
public static int tickSpeed = 1200;
|
||||
public static String currentAction = "";
|
||||
public static String currentSubscript = "";
|
||||
public static int baseXP = 0;
|
||||
public static int gainedXP = 0;
|
||||
|
||||
public final static String DEFAULT_DIR = System.getProperty("user.home") + System.getProperty("file.separator") + "Parabot" + System.getProperty("file.separator") + "Script Factory";
|
||||
public final static String CACHED_LOC = DEFAULT_DIR + System.getProperty("file.separator") + "Your Previous Script.txt";
|
||||
@@ -170,4 +170,31 @@ public class VarsMethods {
|
||||
return GroundItems.Option.valueOf(option);
|
||||
}
|
||||
}
|
||||
|
||||
public static String formatNumber(int number) {
|
||||
DecimalFormat nf = new DecimalFormat("0.0");
|
||||
double i = number;
|
||||
if (i >= 1000000) {
|
||||
return nf.format((i / 1000000)) + "M";
|
||||
}
|
||||
if (i >= 1000) {
|
||||
return nf.format((i / 1000)) + "K";
|
||||
}
|
||||
return "" + number;
|
||||
}
|
||||
|
||||
public static void calculateBaseXP(){
|
||||
baseXP = 0;
|
||||
for (Skill skill : Skill.values()){
|
||||
baseXP += skill.getExperience();
|
||||
}
|
||||
}
|
||||
|
||||
public static void calculateGainedXP(){
|
||||
gainedXP = 0;
|
||||
for (Skill skill : Skill.values()){
|
||||
gainedXP += skill.getExperience();
|
||||
}
|
||||
gainedXP -= baseXP;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user