Skip to content

Commit

Permalink
Add world map functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
GregHib committed May 30, 2024
1 parent fb5dd43 commit 8d428c0
Show file tree
Hide file tree
Showing 14 changed files with 157 additions and 30 deletions.
6 changes: 6 additions & 0 deletions data/definitions/interfaces.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2186,6 +2186,12 @@ world_map:
type: full_screen
components:
close: 44
order: 54
marker: 42
key_list:
id: 49
options:
Select: 0
chat_model_text: 757
canoe_travel:
id: 758
Expand Down
8 changes: 4 additions & 4 deletions data/definitions/parameters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ ammo_group: 21
secondary_use_level: 23
unbankable: 59
quest_list_enum: 61
world_sprite_1: 130
world_sprite_2: 131
world_sprite_3: 134
world_sprite_4: 135
world_map_marker_sprite_icon: 130
world_map_marker_sprite: 131
world_map_marker_sprite_horizontal: 134
world_map_marker_sprite_diagonal: 135
quest_list_interface: 152
quest_list_scroll: 153
construction_required_item_id_1: 211
Expand Down
5 changes: 4 additions & 1 deletion data/definitions/structs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -503,4 +503,7 @@ you_could_just_knock_task: 1621
honestly_its_not_a_purse_task: 1622
almost_made_in_ardougne_task: 1623
# Elsewhere... None
no_task_available_task: 1642
no_task_available_task: 1642
world_map_blue_marker: 972
world_map_grave_marker: 0
world_map_default_marker: 280
7 changes: 6 additions & 1 deletion data/definitions/variables-client-string.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,9 @@ equipment_name: 321
equipment_titles: 322
equipment_names: 323
equipment_stats: 324
comparison_stats: 325
comparison_stats: 325
world_map_marker_text_1: 53
world_map_marker_text_2: 54
world_map_marker_text_3: 55
world_map_marker_text_4: 56
world_map_marker_text_5: 190
32 changes: 25 additions & 7 deletions data/definitions/variables-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,6 @@ tab:
format: list
default: Inventory
values: [ CombatStyles, TaskSystem, Stats, QuestJournals, Inventory, WornEquipment, PrayerList, MagicSpellbook, FriendsList, FriendsChat, ClanChat, Options, Emotes, MusicPlayer, Notes ]
world_map_centre:
id: 622
format: int
world_map_player:
id: 674
format: int
equipment_emote:
id: 779
default: 1426
Expand Down Expand Up @@ -395,4 +389,28 @@ task_popup_summary:
task_disable_popups:
id: 1429
format: boolean
persist: true
persist: true
world_map_zoom_level:
id: 172
format: int
world_map_centre:
id: 622
format: int
world_map_marker_player:
id: 674
format: int
world_map_marker_1:
id: 623
format: int
world_map_marker_2:
id: 625
format: int
world_map_marker_3:
id: 627
format: int
world_map_marker_4:
id: 629
format: int
world_map_marker_5:
id: 940
format: int
29 changes: 28 additions & 1 deletion data/definitions/variables-player-bit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2665,4 +2665,31 @@ honestly_its_not_a_purse_task:
almost_made_in_ardougne_task:
id: 6662
format: boolean
persist: true
persist: true
world_map_hide_player_location:
id: 6174
format: boolean
persist: true
world_map_hide_links:
id: 6175
format: boolean
persist: true
world_map_hide_labels:
id: 6176
format: boolean
persist: true
world_map_hide_tooltips:
id: 6177
format: boolean
persist: true
world_map_list_order:
id: 5367
format: map
default: categorised
values:
categorised: 0
traditional: 1
alphabetical: 2
show_daemonheim_map:
id: 6090
format: boolean
5 changes: 5 additions & 0 deletions data/definitions/variables-player.yml
Original file line number Diff line number Diff line change
Expand Up @@ -609,3 +609,8 @@ task_reward_items:
stat_advance_selected_skill:
id: 261
format: int
world_map_marker_custom:
id: 1159
format: int
persist: true

Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class InstructionHandlers(
private val interactInterfaceItem = InterfaceOnInterfaceOptionHandler(handler)
private val interactInterfaceFloorItem = InterfaceOnFloorItemOptionHandler(items, handler)
private val walk = WalkHandler()
private val worldMapClick = WorldMapClickHandler()
private val finishRegionLoad = FinishRegionLoadHandler()
private val executeCommand = ExecuteCommandHandler()
private val enterString = EnterStringHandler()
Expand Down Expand Up @@ -81,6 +82,7 @@ class InstructionHandlers(
is ExamineObject -> examineObject.validate(player, instruction)
is ChangeDisplayMode -> changeDisplayMode.validate(player, instruction)
is Walk -> walk.validate(player, instruction)
is WorldMapClick -> worldMapClick.validate(player, instruction)
is FinishRegionLoad -> finishRegionLoad.validate(player, instruction)
is ExecuteCommand -> executeCommand.validate(player, instruction)
is EnterString -> enterString.validate(player, instruction)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package world.gregs.voidps.engine.client.instruction.handle

import world.gregs.voidps.engine.client.instruction.InstructionHandler
import world.gregs.voidps.engine.client.variable.hasClock
import world.gregs.voidps.engine.client.variable.start
import world.gregs.voidps.engine.entity.character.player.Player
import world.gregs.voidps.network.client.instruction.WorldMapClick

class WorldMapClickHandler : InstructionHandler<WorldMapClick>() {

override fun validate(player: Player, instruction: WorldMapClick) {
if (player.hasClock("world_map_double_click") && player["previous_world_map_click", 0] == instruction.tile) {
player["world_map_marker_custom"] = instruction.tile
}
player["previous_world_map_click"] = instruction.tile
player.start("world_map_double_click", 1)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package world.gregs.voidps.world.interact.entity.player.display.map

import world.gregs.voidps.engine.client.ui.event.interfaceOpen
import world.gregs.voidps.engine.client.ui.interfaceOption
import world.gregs.voidps.engine.client.ui.interfaceSlot
import world.gregs.voidps.engine.client.ui.open
import world.gregs.voidps.engine.data.definition.InterfaceDefinitions
import world.gregs.voidps.engine.entity.character.mode.move.move
Expand All @@ -13,6 +14,45 @@ val definitions: InterfaceDefinitions by inject()

interfaceOpen("world_map") { player ->
updateMap(player)
player.sendVariable("world_map_hide_player_location")
player.sendVariable("world_map_hide_links")
player.sendVariable("world_map_hide_labels")
player.sendVariable("world_map_hide_tooltips")
player.sendVariable("world_map_marker_custom")
player.interfaceOptions.unlockAll("world_map", "key_list", 0..182)
}

interfaceOption("Re-sort key", "order", "world_map") {
player["world_map_list_order"] = when (player["world_map_list_order", "categorised"]) {
"categorised" -> "traditional"
"traditional" -> "alphabetical"
"alphabetical" -> "categorised"
else -> "categorised"
}
}

interfaceSlot("key_list", "world_map", 1) {
player.toggle("world_map_hide_player_location")
}

interfaceSlot("key_list", "world_map", 4) {
player.toggle("world_map_hide_links")
}

interfaceSlot("key_list", "world_map", 12) {
player.toggle("world_map_hide_labels")
}

interfaceSlot("key_list", "world_map", 16) {
player.toggle("world_map_hide_tooltips")
}

interfaceSlot("key_list", "world_map", 19) {
player["world_map_marker_custom"] = 0
}

interfaceOption("Clear marker", "marker", "world_map") {
player["world_map_marker_custom"] = 0
}

interfaceOption(component = "world_map", id = "toplevel*") {
Expand All @@ -32,5 +72,5 @@ move({ it.interfaces.contains("world_map") }) { player ->
fun updateMap(player: Player) {
val tile = player.tile.id
player["world_map_centre"] = tile
player["world_map_player"] = tile
player["world_map_marker_player"] = tile
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package world.gregs.voidps.network.client.instruction

import world.gregs.voidps.network.client.Instruction

data class WorldMapClick(val tile: Int) : Instruction
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ fun decoders(huffman: Huffman): Array<Decoder?> {
array[67] = HyperlinkDecoder()
array[75] = LobbyOnlineStatusDecoder()
array[30] = LobbyWorldListRefreshDecoder()
array[58] = WorldMapCloseDecoder()
array[58] = WorldMapClickDecoder()
array[74] = ClanChatRankDecoder()
array[77] = ReflectionResponseDecoder()
array[76] = SecondaryTeleportDecoder()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package world.gregs.voidps.network.login.protocol.decode

import io.ktor.utils.io.core.*
import world.gregs.voidps.network.client.instruction.WorldMapClick
import world.gregs.voidps.network.login.protocol.Decoder

class WorldMapClickDecoder : Decoder(4) {

override suspend fun decode(packet: ByteReadPacket) = WorldMapClick(packet.readInt())

}

This file was deleted.

0 comments on commit 8d428c0

Please sign in to comment.