RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
SkillGuides.java
1package com.osroyale.content.skill.guides;
2
3import com.osroyale.game.world.entity.mob.player.Player;
4import com.osroyale.game.world.items.Item;
5import com.osroyale.net.packet.out.SendInterface;
6import com.osroyale.net.packet.out.SendItemOnInterface;
7import com.osroyale.net.packet.out.SendScrollbar;
8import com.osroyale.net.packet.out.SendString;
9import com.osroyale.util.Utility;
10
41
42public class SkillGuides {
43
44 public static final int INTERFACE_ID = 42550;
45 private static final int TITLE_ID = 42557;
46 private static final int CATEGORY_ID = 42558;
47 private static final int RIGHT_OPTIONS_START = 42559;
48 private static final int SCROLL_LAYER = 42573;
49 private static final int ITEMS_ID = 42574;
50 private static final int TEXT_LAYER_START = 42575;
51
52
53 public static void openInterface(Player player, int skillId, int optionId, boolean update) {
54 if(player.menuOpened == skillId && player.optionOpened == optionId) return;
55
56 GuideData data = GuideData.values()[skillId];
57
58 player.send(new SendString(Utility.capitalizeSentence(data.name().toLowerCase()), TITLE_ID));
59 player.send(new SendString(data.options[optionId], CATEGORY_ID));
60
61 int menuLength = data.options.length, length = data.menus[optionId].option.length;
62 for(int index = 0; index < menuLength; index++)
63 player.send(new SendString(data.options[index], RIGHT_OPTIONS_START + index));
64
65
66 Item[] items = new Item[length];
67 for(int i = 0; i < length; i++)
68 items[i] = new Item(data.menus[optionId].option[i].itemId);
69
70 for(int i = 0, id = TEXT_LAYER_START; i < length; i++, id += 2) {
71 String level = data.menus[optionId].option[i].level == -1 ? "" : data.menus[optionId].option[i].level + "";
72 System.out.println("id: " + id);
73 System.out.println("level: " + level);
74 System.out.println("data.menus[optionId].option[i].name: " + data.menus[optionId].option[i].name);
75 player.send(new SendString(data.menus[optionId].option[i].name, id));
76 player.send(new SendString(level, id + 1));
77 }
78
79 player.send(new SendItemOnInterface(ITEMS_ID, items));
80
81 cleanInterface(player, menuLength, length);
82
83 int scrollMax = 1;
84 if(length == 58) scrollMax = ((length + 3) * 33) + 1;
85 else if(length >= 7) scrollMax = (length * 33) + 1;
86 player.send(new SendScrollbar(SCROLL_LAYER, scrollMax));
87
88 player.menuOpened = skillId;
89 player.optionOpened = optionId;
90
91 if(!update) player.send(new SendInterface(INTERFACE_ID));
92 }
93
94 private static void cleanInterface(Player player, int menuLength, int start) {
98 for(int index = menuLength; index < 14; index++) {
99 System.out.println("RIGHT_OPTIONS_START + index: " + (RIGHT_OPTIONS_START + index));
100 player.send(new SendString("", RIGHT_OPTIONS_START + index));
101 }
102 //for(int index = 2, child = RIGHT_OPTIONS_START + menuLength; index < 12; index++, child++)
103 // player.send(new SendString("", child));
104
105 if(start < 7) {
106 for (int index = 0, id = TEXT_LAYER_START + (2 * start); index < 7; index++, id += 2) {
107 player.send(new SendString("", id));
108 player.send(new SendString("", id + 1));
109 }
110 }
111 /*for(int index = 0, id = TEXT_LAYER_START + (2 * length) + 1; index < 7; index++, id += 2) {
112 player.send(new SendString("", id));
113 player.send(new SendString("", id + 1));
114 }*/
115 }
116
117}
static String capitalizeSentence(final String string)
Definition Utility.java:136