mirror of
https://github.com/bdnugget/IdleRSC.git
synced 2026-11-07 07:57:27 +00:00
Added script selector theming
This commit is contained in:
1 parent
d96e958fe7
commit
dd03350402
4 files changed
+176
-39
No files matched your search
@@ -3,12 +3,16 @@
|
||||

|
||||
|
||||
# IdleRSC
|
||||
[][launcher]
|
||||
[][launcher]
|
||||
|
||||
[][releases]
|
||||
[][commits]
|
||||
[][discord]
|
||||
|
||||
[][openrsc-wiki]
|
||||
[][wiki]
|
||||
[][api]
|
||||
|
||||
IdleRSC is a bot for the [OpenRSC][openrsc] coleslaw and uranium worlds that uses code injection and
|
||||
reflection. It has its own custom scripting API called IdleScript, as well as
|
||||
backwards compatibility with APOS and SBot scripts. It also provides staker
|
||||
@@ -287,6 +291,7 @@ If you would like to contribute to IdleRSC, but don't know where to start check
|
||||
</div>
|
||||
|
||||
[openrsc]: https://rsc.vet
|
||||
[openrsc-wiki]: https://rsc.vet/wiki/index.php/Open_RuneScape_Classic_Wiki
|
||||
[discord]: https://discord.gg/CutQxDZ8Np
|
||||
[commits]: https://gitlab.com/open-runescape-classic/idlersc/-/commits/master
|
||||
[repository]: https://gitlab.com/open-runescape-classic/idlersc
|
||||
@@ -296,5 +301,7 @@ If you would like to contribute to IdleRSC, but don't know where to start check
|
||||
[issue-tracker]: https://gitlab.com/open-runescape-classic/idlersc/-/issues
|
||||
[merge-requests]: https://gitlab.com/open-runescape-classic/idlersc/-/merge_requests
|
||||
[contributors]: https://gitlab.com/open-runescape-classic/idlersc/-/graphs/master?ref_type=heads
|
||||
[wiki]: https://gitlab.com/open-runescape-classic/idlersc/-/wikis/home
|
||||
[api]: https://open-runescape-classic.gitlab.io/idlersc/overview-summary.html
|
||||
[java8]: https://adoptium.net/temurin/releases/?version=8&package=jdk
|
||||
[jarfix]: https://johann.loefflmann.net/downloads/jarfix.exe
|
||||
@@ -33,7 +33,9 @@ import java.util.stream.Stream;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import javax.swing.table.JTableHeader;
|
||||
import javax.swing.table.TableRowSorter;
|
||||
import listeners.LoginListener;
|
||||
import listeners.WindowListener;
|
||||
@@ -929,16 +931,42 @@ public class Main {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
JTableHeader header = scriptTable.getTableHeader();
|
||||
header.setDefaultRenderer(
|
||||
new DefaultTableCellRenderer() {
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(
|
||||
JTable table,
|
||||
Object value,
|
||||
boolean isSelected,
|
||||
boolean hasFocus,
|
||||
int row,
|
||||
int column) {
|
||||
|
||||
JLabel label =
|
||||
(JLabel)
|
||||
super.getTableCellRendererComponent(
|
||||
table, value, isSelected, hasFocus, row, column);
|
||||
|
||||
label.setBorder(
|
||||
BorderFactory.createMatteBorder(
|
||||
0, 0, 0, column == 0 ? 1 : 0, UIManager.getColor("controlDkShadow")));
|
||||
|
||||
label.setFont(header.getFont().deriveFont(Font.BOLD, 15f));
|
||||
label.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
|
||||
return label;
|
||||
}
|
||||
});
|
||||
;
|
||||
|
||||
scriptTable.setSelectionMode(
|
||||
ListSelectionModel.SINGLE_SELECTION); // Only allow single row selected at a time
|
||||
scriptTable.setAutoCreateRowSorter(true); // Automatically create a table row sorter
|
||||
scriptTable.getTableHeader().setReorderingAllowed(false); // Disable reordering columns
|
||||
scriptTable.getTableHeader().setResizingAllowed(false); // Disable resizing columns
|
||||
scriptTable
|
||||
.getTableHeader()
|
||||
.setFont(scriptTable.getTableHeader().getFont().deriveFont(Font.BOLD, 15f));
|
||||
scriptTable.setBorder(BorderFactory.createEmptyBorder());
|
||||
|
||||
header.setReorderingAllowed(false); // Disable reordering columns
|
||||
header.setResizingAllowed(false); // Disable resizing columns
|
||||
final JScrollPane scriptScroller = new JScrollPane(scriptTable);
|
||||
|
||||
// Setup script args field
|
||||
@@ -1013,6 +1041,37 @@ public class Main {
|
||||
|
||||
// Setup layout
|
||||
scriptFrame.setLayout(new BoxLayout(scriptFrame.getContentPane(), BoxLayout.Y_AXIS));
|
||||
scriptFrame.setResizable(false);
|
||||
|
||||
// Script selector theme coloring
|
||||
|
||||
// Frame theming
|
||||
scriptFrame.getContentPane().setBackground(getThemeBackColor());
|
||||
scriptFrame.getContentPane().setForeground(getThemeTextColor());
|
||||
|
||||
// Script table theming
|
||||
header.setBorder(
|
||||
BorderFactory.createMatteBorder(0, 0, 1, 0, UIManager.getColor("controlDkShadow")));
|
||||
scriptTable.setBackground(getThemeBackColor().brighter());
|
||||
scriptTable.setForeground(getThemeTextColor());
|
||||
scriptScroller.setBorder(BorderFactory.createEmptyBorder());
|
||||
scriptScroller.setBackground(getThemeBackColor().brighter());
|
||||
scriptScroller.setForeground(getThemeTextColor());
|
||||
scriptScroller.getViewport().setBackground(getThemeBackColor().brighter());
|
||||
|
||||
// Text box theming
|
||||
scriptArgs.setBorder(BorderFactory.createMatteBorder(4, 0, 4, 0, getThemeBackColor()));
|
||||
scriptArgs.setBackground(getThemeBackColor().brighter());
|
||||
scriptArgs.setForeground(getThemeTextColor());
|
||||
scriptFilter.setBorder(BorderFactory.createMatteBorder(4, 0, 4, 0, getThemeBackColor()));
|
||||
scriptFilter.setBackground(getThemeBackColor().brighter());
|
||||
scriptFilter.setForeground(getThemeTextColor());
|
||||
|
||||
// Run button theming
|
||||
scriptButton.setBackground(getThemeBackColor().darker());
|
||||
scriptButton.setForeground(getThemeTextColor());
|
||||
|
||||
// Add components to frame
|
||||
scriptFrame.add(scriptFilter);
|
||||
scriptFrame.add(scriptScroller);
|
||||
scriptFrame.add(scriptArgs);
|
||||
@@ -1033,7 +1092,7 @@ public class Main {
|
||||
}
|
||||
|
||||
textField.setText("");
|
||||
textField.setForeground(Color.BLACK);
|
||||
textField.setForeground(getThemeTextColor());
|
||||
shouldFilter = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5869,6 +5869,22 @@ public class Controller {
|
||||
return this.getQuestStage(questId) == -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the amount of quest points the player has.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public int getQuestPoints() {
|
||||
try {
|
||||
Field f = mud.getClass().getDeclaredField("questPoints");
|
||||
f.setAccessible(true);
|
||||
return (int) f.get(mud);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a friend to the user's friend list.
|
||||
*
|
||||
|
||||
@@ -5,8 +5,8 @@ import models.entities.ItemId;
|
||||
import models.entities.SkillId;
|
||||
|
||||
public class CasketFisher extends IdleScript {
|
||||
int paintColors[] = {
|
||||
0xb74413, 0xcfdf1f, 0xffffff, 0xff0000
|
||||
int[] paintColors = {
|
||||
0xb74413, 0xcfdf1f, 0xffffff
|
||||
}; // wooden-ish, golden....-ish, casket amount, trash amounts
|
||||
|
||||
private final int[][] CATHERBY_BANK = {{437, 491}, {443, 496}};
|
||||
@@ -15,17 +15,26 @@ public class CasketFisher extends IdleScript {
|
||||
|
||||
final int casketId = ItemId.CASKET.getId();
|
||||
final int netId = ItemId.BIG_NET.getId();
|
||||
final int oysterId = ItemId.OYSTER.getId();
|
||||
final int pearlsId = ItemId.OYSTER_PEARLS.getId();
|
||||
final int pearlTipsId = ItemId.OYSTER_PEARL_BOLT_TIPS.getId();
|
||||
final int chiselId = ItemId.CHISEL.getId();
|
||||
final int[] trashIds = {
|
||||
ItemId.RAW_MACKEREL.getId(),
|
||||
ItemId.RAW_COD.getId(),
|
||||
ItemId.RAW_BASS.getId(),
|
||||
ItemId.EMPTY_OYSTER.getId(),
|
||||
ItemId.SEAWEED.getId(),
|
||||
ItemId.OYSTER.getId(),
|
||||
ItemId.LEATHER_GLOVES.getId(),
|
||||
ItemId.BOOTS.getId()
|
||||
};
|
||||
private int casketAmount = 0; // Caskets then trash items
|
||||
private int casketAmount = 0;
|
||||
private int bankedCaskets = 0;
|
||||
private int tipAmount = 0;
|
||||
private int bankedBoltTips = 0;
|
||||
|
||||
private final int casketsPerTrip = 10;
|
||||
private final int maxItemCount = 26;
|
||||
|
||||
public int start(String[] param) {
|
||||
paintBuilder.start(4, 18, 174);
|
||||
@@ -41,14 +50,16 @@ public class CasketFisher extends IdleScript {
|
||||
controller.stop();
|
||||
}
|
||||
|
||||
dropJunk();
|
||||
handleItems();
|
||||
if (controller.getInventoryItemCount(casketId) > 0
|
||||
|| controller.getInventoryItemCount(netId) == 0) bank();
|
||||
|| controller.getInventoryItemCount(pearlTipsId) > 0
|
||||
|| controller.getInventoryItemCount(netId) == 0
|
||||
|| controller.getInventoryItemCount(chiselId) == 0) bank();
|
||||
|
||||
while (controller.isRunning()) {
|
||||
if (controller.getNeedToMove()) controller.moveCharacter();
|
||||
if (controller.getShouldSleep()) controller.sleepHandler(true);
|
||||
if (controller.getInventoryItemCount(casketId) < 20) {
|
||||
if (controller.getInventoryItemCount(casketId) < casketsPerTrip) {
|
||||
while (controller.currentX() != 406
|
||||
&& controller.currentY() != 504
|
||||
&& controller.isRunning()
|
||||
@@ -58,7 +69,7 @@ public class CasketFisher extends IdleScript {
|
||||
controller.sleep(640);
|
||||
}
|
||||
|
||||
if (!controller.isBatching() && controller.getInventoryItemCount() < 26) {
|
||||
if (!controller.isBatching() && controller.getInventoryItemCount() < maxItemCount) {
|
||||
controller.setStatus("@cya@Fishing");
|
||||
controller.atObject(406, 505);
|
||||
controller.sleep(640);
|
||||
@@ -67,7 +78,7 @@ public class CasketFisher extends IdleScript {
|
||||
int x = controller.currentX();
|
||||
int y = controller.currentY();
|
||||
while (controller.isBatching() && controller.isRunning() && controller.isLoggedIn()) {
|
||||
if (controller.getInventoryItemCount() >= 26) {
|
||||
if (controller.getInventoryItemCount() >= maxItemCount) {
|
||||
controller.stopBatching();
|
||||
while (controller.currentY() != y - 1
|
||||
&& controller.isRunning()
|
||||
@@ -77,34 +88,59 @@ public class CasketFisher extends IdleScript {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!controller.isBatching() && controller.getInventoryItemCount() >= 26) dropJunk();
|
||||
if (!controller.isBatching() && controller.getInventoryItemCount() >= maxItemCount)
|
||||
handleItems();
|
||||
} else {
|
||||
dropJunk();
|
||||
handleItems();
|
||||
bank();
|
||||
}
|
||||
}
|
||||
controller.stop();
|
||||
casketAmount = 0;
|
||||
bankedCaskets = 0;
|
||||
tipAmount = 0;
|
||||
bankedBoltTips = 0;
|
||||
return 1000; // start() must return a int value now.
|
||||
}
|
||||
|
||||
public void dropJunk() {
|
||||
public void handleItems() {
|
||||
if (controller.isRunning()) {
|
||||
for (int i = 0; i < trashIds.length; i++) {
|
||||
if (controller.getInventoryItemCount(trashIds[i]) > 0
|
||||
|
||||
// Open oysters
|
||||
while (controller.getInventoryItemCount(oysterId) > 0 && controller.isRunning()) {
|
||||
controller.setStatus("@cya@Opening oysters");
|
||||
controller.itemCommand(oysterId);
|
||||
while (controller.isBatching() && controller.isRunning()) {
|
||||
if (controller.getInventoryItemCount(oysterId) == 0) controller.stopBatching();
|
||||
controller.sleep(640);
|
||||
}
|
||||
controller.sleep(640);
|
||||
}
|
||||
// Chisel pearls into bolt tips
|
||||
while (controller.getInventoryItemCount(pearlsId) > 0 && controller.isRunning()) {
|
||||
controller.setStatus("@cya@Chiseling oyster pearls");
|
||||
controller.useItemOnItemBySlot(
|
||||
controller.getInventoryItemSlotIndex(chiselId),
|
||||
controller.getInventoryItemSlotIndex(pearlsId));
|
||||
while (controller.isBatching() && controller.isRunning() && controller.isLoggedIn()) {
|
||||
if (controller.getInventoryItemCount(pearlsId) == 0) controller.stopBatching();
|
||||
controller.sleep(640);
|
||||
}
|
||||
controller.sleep(640);
|
||||
}
|
||||
|
||||
// Drop trash items
|
||||
for (int trashId : trashIds) {
|
||||
while (controller.getInventoryItemCount(trashId) > 0
|
||||
&& controller.isRunning()
|
||||
&& controller.isLoggedIn()) {
|
||||
controller.setStatus("@cya@Dropping Junk");
|
||||
String itemName = controller.getItemName(trashId).toLowerCase();
|
||||
itemName = itemName.substring(0, 1).toUpperCase() + itemName.substring(1);
|
||||
controller.setStatus("@cya@Dropping Item: " + itemName);
|
||||
controller.dropItem(
|
||||
controller.getInventoryItemSlotIndex(trashIds[i]),
|
||||
controller.getInventoryItemCount(trashIds[i]));
|
||||
controller.getInventoryItemSlotIndex(trashId),
|
||||
controller.getInventoryItemCount(trashId));
|
||||
controller.sleep(1280);
|
||||
while (controller.getInventoryItemCount(trashIds[i]) > 0
|
||||
&& controller.isRunning()
|
||||
&& controller.isLoggedIn()) {
|
||||
controller.sleep(640);
|
||||
}
|
||||
}
|
||||
}
|
||||
controller.sleep(640);
|
||||
@@ -132,21 +168,31 @@ public class CasketFisher extends IdleScript {
|
||||
controller.sleep(640);
|
||||
// Deposit all items but net
|
||||
bankedCaskets += controller.getInventoryItemCount(casketId);
|
||||
bankedBoltTips += controller.getInventoryItemCount(pearlTipsId);
|
||||
for (int i : controller.getInventoryItemIds()) {
|
||||
if (i != netId) {
|
||||
if (i != netId && i != chiselId) {
|
||||
controller.depositItem(i, controller.getInventoryItemCount(i));
|
||||
while (controller.getInventoryItemCount(i) > 0
|
||||
&& controller.isRunning()
|
||||
&& controller.isLoggedIn()) controller.sleep(640);
|
||||
}
|
||||
}
|
||||
// Withdraw a net if not already held or give an error if no net is found.
|
||||
if (controller.getInventoryItemCount(netId) < 1) {
|
||||
// Withdraw a net and chisel if not already held or give an error if they're not found.
|
||||
if (controller.getInventoryItemCount(netId) < 1
|
||||
|| controller.getInventoryItemCount(chiselId) < 1) {
|
||||
if (controller.getBankItemCount(netId) < 1) {
|
||||
controller.log("You are missing a big net.", "red");
|
||||
controller.stop();
|
||||
} else {
|
||||
controller.withdrawItem(netId, 1);
|
||||
controller.sleep(640);
|
||||
}
|
||||
if (controller.getBankItemCount(chiselId) < 1) {
|
||||
controller.log("You are missing a chisel.", "red");
|
||||
controller.stop();
|
||||
} else {
|
||||
controller.withdrawItem(chiselId, 1);
|
||||
controller.sleep(640);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,13 +214,10 @@ public class CasketFisher extends IdleScript {
|
||||
Arrays.sort(toSortY);
|
||||
int[][] sortedRectangle = {{toSortX[0], toSortY[0]}, {toSortX[1], toSortY[1]}};
|
||||
|
||||
if (controller.currentX() >= sortedRectangle[0][0]
|
||||
return controller.currentX() >= sortedRectangle[0][0]
|
||||
&& controller.currentX() <= sortedRectangle[1][0]
|
||||
&& controller.currentY() >= sortedRectangle[0][1]
|
||||
&& controller.currentY() <= sortedRectangle[1][1]) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
&& controller.currentY() <= sortedRectangle[1][1];
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -182,6 +225,7 @@ public class CasketFisher extends IdleScript {
|
||||
if (controller != null) {
|
||||
|
||||
casketAmount = bankedCaskets + controller.getInventoryItemCount(casketId);
|
||||
tipAmount = bankedBoltTips + controller.getInventoryItemCount(pearlTipsId);
|
||||
|
||||
paintBuilder.setBorderColor(0xBD93F9);
|
||||
paintBuilder.setBackgroundColor(0x282A36, 255);
|
||||
@@ -206,6 +250,17 @@ public class CasketFisher extends IdleScript {
|
||||
new int[] {paintColors[2], 0x00ff00},
|
||||
new int[] {36, 52},
|
||||
16));
|
||||
paintBuilder.addRow(
|
||||
rowBuilder.singleSpriteMultipleStringRow(
|
||||
pearlTipsId,
|
||||
80,
|
||||
25,
|
||||
new String[] {
|
||||
paintBuilder.stringFormatInt(tipAmount), paintBuilder.stringAmountPerHour(tipAmount)
|
||||
},
|
||||
new int[] {paintColors[2], 0x00ff00},
|
||||
new int[] {31, 52},
|
||||
12));
|
||||
paintBuilder.draw();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user