RuneHive-Game
Loading...
Searching...
No Matches
SkillGuides.java
Go to the documentation of this file.
1package com.runehive.content.skill.guides;
2
3import com.runehive.game.world.entity.mob.player.Player;
4import com.runehive.game.world.items.Item;
5import com.runehive.net.packet.out.SendInterface;
6import com.runehive.net.packet.out.SendItemOnInterface;
7import com.runehive.net.packet.out.SendScrollbar;
8import com.runehive.net.packet.out.SendString;
9import com.runehive.util.Utility;
10
11public class SkillGuides {
12
13 public static final int INTERFACE_ID = 42550;
14 private static final int TITLE_ID = 42557;
15 private static final int CATEGORY_ID = 42558;
16 private static final int RIGHT_OPTIONS_START = 42559;
17 private static final int SCROLL_LAYER = 42573;
18 private static final int ITEMS_ID = 42574;
19 private static final int TEXT_LAYER_START = 42575;
20
21
22 public static void openInterface(Player player, int skillId, int optionId, boolean update) {
23 if(player.menuOpened == skillId && player.optionOpened == optionId) return;
24
25 GuideData data = GuideData.values()[skillId];
26
27 player.send(new SendString(Utility.capitalizeSentence(data.name().toLowerCase()), TITLE_ID));
28 player.send(new SendString(data.options[optionId], CATEGORY_ID));
29
30 int menuLength = data.options.length, length = data.menus[optionId].option.length;
31 for(int index = 0; index < menuLength; index++)
32 player.send(new SendString(data.options[index], RIGHT_OPTIONS_START + index));
33
34
35 Item[] items = new Item[length];
36 for(int i = 0; i < length; i++)
37 items[i] = new Item(data.menus[optionId].option[i].itemId);
38
39 for(int i = 0, id = TEXT_LAYER_START; i < length; i++, id += 2) {
40 String level = data.menus[optionId].option[i].level == -1 ? "" : data.menus[optionId].option[i].level + "";
41 System.out.println("id: " + id);
42 System.out.println("level: " + level);
43 System.out.println("data.menus[optionId].option[i].name: " + data.menus[optionId].option[i].name);
44 player.send(new SendString(data.menus[optionId].option[i].name, id));
45 player.send(new SendString(level, id + 1));
46 }
47
48 player.send(new SendItemOnInterface(ITEMS_ID, items));
49
50 cleanInterface(player, menuLength, length);
51
52 int scrollMax = 1;
53 if(length == 58) scrollMax = ((length + 3) * 33) + 1;
54 else if(length >= 7) scrollMax = (length * 33) + 1;
55 player.send(new SendScrollbar(SCROLL_LAYER, scrollMax));
56
57 player.menuOpened = skillId;
58 player.optionOpened = optionId;
59
60 if(!update) player.send(new SendInterface(INTERFACE_ID));
61 }
62
63 private static void cleanInterface(Player player, int menuLength, int start) {
64 /**
65 * Cleans the right side
66 */
67 for(int index = menuLength; index < 14; index++) {
68 System.out.println("RIGHT_OPTIONS_START + index: " + (RIGHT_OPTIONS_START + index));
69 player.send(new SendString("", RIGHT_OPTIONS_START + index));
70 }
71 //for(int index = 2, child = RIGHT_OPTIONS_START + menuLength; index < 12; index++, child++)
72 // player.send(new SendString("", child));
73
74 if(start < 7) {
75 for (int index = 0, id = TEXT_LAYER_START + (2 * start); index < 7; index++, id += 2) {
76 player.send(new SendString("", id));
77 player.send(new SendString("", id + 1));
78 }
79 }
80 /*for(int index = 0, id = TEXT_LAYER_START + (2 * length) + 1; index < 7; index++, id += 2) {
81 player.send(new SendString("", id));
82 player.send(new SendString("", id + 1));
83 }*/
84 }
85
86}
static void openInterface(Player player, int skillId, int optionId, boolean update)
static void cleanInterface(Player player, int menuLength, int start)
This class represents a character controlled by a player.
Definition Player.java:125
The container class that represents an item that can be interacted with.
Definition Item.java:21
The OutgoingPacket that opens an itemcontainer for Player.
The OutgoingPacket that sends a string to a Players itemcontainer in the client.
Handles miscellaneous methods.
Definition Utility.java:27
static String capitalizeSentence(final String string)
Capitalize each letter after .
Definition Utility.java:99