{"name":"mapmod","enabled":true,"description":"Adjust the mapper.","type":"group","id":1,"items":[{"type":"function","name":"Read_Me","enabled":true,"id":4,"code":"/* \n\nMapmod v1.0.7\nby: Zahan of Achaea\n\n\nWhat does this even do:\n* Adjust map window size\n* Set default zoom\n* Shrink player-Flag\n* Shrink wilderness/sea map\n* Center wilderness/sea map\n* Display area name\n* Fixes broken unmapped-area display\n\n\nUse MAPMOD in-game for options, settings, and syntaxes.\n\nExamples of resizing commands:\n MAPMOD COLUM_WIDTHS 30 50 20\n MAPMOD HEIGHTS_RIGHT 58 42\n\n\nIf you have any problems or questions, send me a msg in the game or on the forum.\n\n\nThis plugin is provided for free but donations to Zahan (achaea) are always appreciated, no matter how small!\n\n\n\n\n\nVersion notes:\n- fixed bug of mapmod not working at all\n\n*/"},{"type":"alias","name":"","enabled":true,"id":6,"matching":"exact","whole_words":false,"case_sensitive":false,"prefix_suffix":true,"actions":[{"action":"script","script":"// for some reason, nexus doesn't run onLoad when you install. so, load if needed\nif (typeof mapmod === \"undefined\") \n send_command(\"mapmod on\");\n\nconsole.log(mapmod);\n\nvar version = \"1.0.7\";\n\nvar overall = 75;\n\nvar check_on = function (setting) {\n var status;\n if (!mapmod[setting])\n status = \"off\";\n else\n status = \"on\";\n return status;\n};\n\nmapmod.help = {\n Main: {\n OFF: \"- turn off and restore interface\",\n ON: \"- load mapmod\",\n DEFAULT: \"- restore default settings\",\n \"OUTPUT_MSG OFF|ON\": \"= \"+check_on(\"output_msg\")+\"\",\n },\n \"Standard Map\": {\n \"ZOOM <#>\": \"= \"+mapmod.zoom+\"; stock is 10\",\n \"FLAG_SIZE <#>\": \"= \"+mapmod.flag_size+\"; stock is 30\",\n \"SHOW_AREA OFF|ON\": \"= \"+check_on(\"show_area\")+\"\",\n },\n \"Wilderness Map\": {\n \"RESIZE_MAP OFF|ON\": \"= \"+check_on(\"resize_map\")+\"\",\n \"FONT_SIZE <#>\": \"= \"+mapmod.font_size+\"; controls width\",\n \"LINE_HEIGHT <#>\": \"= \"+mapmod.line_height+\"; controls height\",\n },\n \"Miniwindows\": {\n \"RESIZE_WINDOWS OFF|ON\": \"= \"+check_on(\"resize_windows\")+\"\",\n \"COLUMN_WIDTHS <% % %>\": \"= \"+mapmod.left_column+\" \"+mapmod.middle_column+\" \"+mapmod.right_column+\"; sum must equal 100\",\n \"HEIGHTS_LEFT <% %>\": \"= \"+mapmod.left_top+\" \"+mapmod.left_bottom+\"; sum must equal 100\",\n \"HEIGHTS_RIGHT <% %>\": \"= \"+mapmod.right_top+\" \"+mapmod.right_bottom+\"; sum must equal 100\",\n }\n};\n\nvar line = \"+------------------------\";\nline += \" Mapmod v\"+version+\" \";\nline += \" by Zahan \";\nline += \"------------------------+\";\now_Write(\"#output_main\", \"

\"+line+\"

\");\n\nfor (let header in mapmod.help) {\n var spaces = overall - header.length - 4;\n var space = \"\";\n for (let i=0; i| \" + header + \":\"+space+\"|

\");\n for (let command in mapmod.help[header]) {\n var spaces = 25 - command.length;\n var space = \"\";\n for (let i=0; i|\" + line + endsp + \"|

\");\n }\n var spaces = overall - 2;\n var space = \"\";\n for (let i=0; i|\" + space + \"|

\");\n}\n\now_Write(\"#output_main\", \"

+-------------------------------------------------------------------------+

\");\nclient.print(\" \");"}],"text":"mapmod"},{"type":"group","name":"Functions","enabled":true,"id":17,"items":[{"type":"function","name":"onLoad","enabled":true,"id":15,"code":"// initialize the table\nif (typeof mapmod == \"undefined\")\n mapmod = {old:{}};\n\n// prevent loading on mobile\nif (client.mobile)\n return;\n\n\n// defaults - use the alias MAPMOD in-game to change the settings\nmapmod.settings = {\n on: true,\n output_msg: 1,\n // regular map\n zoom: 8,\n flag_size: 17,\n show_area: 1,\n // wilderness map\n resize_map: 1,\n font_size: 11,\n line_height: 11,\n // ui\n resize_windows: 1,\n left_column: 25,\n middle_column: 50,\n right_column: 25,\n left_top: 55,\n left_bottom: 45,\n right_top: 50,\n right_bottom: 50,\n};\n\n\nmapmod.save_settings = function () {\n var mapmod_settings = {};\n for (let key in mapmod.settings)\n mapmod_settings[key] = mapmod[key];\n set_variable(\"mapmod\", mapmod_settings);\n};\n\n\nmapmod.set_defaults = function () {\n for (let key in mapmod.settings)\n mapmod[key] = mapmod.settings[key];\n};\nmapmod.set_defaults();\n\n\n// load settings\nmapmod.saved = get_variable(\"mapmod\");\nif (mapmod.saved) {\n if (typeof lootpet.saved === \"string\") {\n // break apart variable\n var mapmod_set = mapmod.saved.split(\", \");\n for (let i = 0; i < mapmod_set.length; i++) {\n mapmod_set[i] = mapmod_set[i].split(\":\");\n mapmod[mapmod_set[i][0]] = mapmod_set[i][1];\n }\n mapmod.save_settings();\n }\n else {\n // set from variable\n for (let key in mapmod.saved)\n mapmod[key] = mapmod.saved[key];\n }\n}\n\n\nmapmod.msg = function (text) {\n if (!mapmod.output_msg)\n return;\n ow_Write(\"#output_main\", \"

[Mapmod]: \"+text+\"

\");\n send_command(\" \");\n};\n\n\nif (!mapmod.on) return;\n//////////////////////////////////////////////////////\n\n// redraw_interface\nif (mapmod.old.redraw_interface)\n redraw_interface = mapmod.old.redraw_interface;\nelse\n mapmod.old.redraw_interface = redraw_interface;\n\nredraw_interface = (function() {\n var cached_function = redraw_interface;\n return function() {\n var result = cached_function.apply(this, arguments);\n if (!mapmod.resize_windows) \n return result;\n // redraw widths\n $(\"#box_2\").css(\"width\", mapmod.left_column+\"%\");\n $(\"#box_3\").css(\"width\", mapmod.middle_column+\"%\");\n $(\"#box_4\").css(\"width\", mapmod.right_column+\"%\");\n\n // redraw heights\n var dims = [\"left_top\", \"left_bottom\", \"right_top\", \"right_bottom\"];\n var total = $(\"#box_4\").css(\"height\");\n for (let i = 0; i < dims.length; i++) { \n var box = dims[i];\n if (mapmod[box]) {\n var cur = $(\"#container_\"+(i+1)).css(\"height\");\n if (cur != total) {\n $(\"#container_\"+(i+1)).css(\"height\", mapmod[box]+\"%\");\n }\n }\n }\n\n // fix buggy style swapping and move history arrow\n var style = client.css_style;\n var ih = $(\"#user_input\").height();\n //if (style == \"standard\" && ih < 18) {\n if (style == \"standard\") {\n $(\"#user_input\").css(\"height\", \"42px\");\n $(\"#command_history\").css(\"top\", \"9px\").css(\"right\", \"3px\");\n }\n //else if (style == \"minimal\" && ih > 28) {\n else if (style == \"minimal\") {\n $(\"#user_input\").css(\"height\", \"28px\");\n $(\"#command_history\").css(\"top\", \"9px\").css(\"right\", \"-7px\");\n }\n\n return result;\n };\n})();\n\n\n// force_single_line_input\nif (mapmod.old.force_single_line_input)\n force_single_line_input = mapmod.old.force_single_line_input;\nelse\n mapmod.old.force_single_line_input = force_single_line_input;\n\nforce_single_line_input = function () {\n // i tried to play nice but we have to cancel the multi-line input\n return true;\n};\n\n//////////\n\n// update_canvas\nif (mapmod.old.update_canvas)\n Map.update_canvas = mapmod.old.update_canvas;\nelse\n mapmod.old.update_canvas = Map.update_canvas;\n\nMap.update_canvas = (function() {\n var cached_function = Map.update_canvas;\n return function() {\n\n var result = cached_function.apply(this, arguments);\n\n // fix broken container positioning\n var con_width = $(\"#map_container\").width();\n var can_width = $(\"#map_canvas\").width();\n if (can_width < con_width) {\n var diff = (con_width - can_width) / 2;\n $(\"#map_canvas\").css(\"left\", \"-\"+diff+\"px\");\n }\n else\n $(\"#map_canvas\").css(\"left\", \"0px\");\n\n // fix unmapped area display on redraw\n if (mapmod.lost) {\n var top = ($(\"#map_container\").height() - $(\"#map_nomap\").height()) / 2;\n $(\"#map_nomap\").css(\"display\", \"block\").css(\"width\", \"100%\").css(\"top\", top+\"px\");\n }\n\n // set flag_size\n $(\"#marker_char_current\").css(\"background-size\", mapmod.flag_size+\"px\").css(\"background-repeat\", \"no-repeat\").css(\"background-position\", \"left bottom\");\n\n return result;\n };\n})();\n\n\n// display_overhead_map\nif (mapmod.old.display_overhead_map)\n Map.display_overhead_map = mapmod.old.display_overhead_map;\nelse\n mapmod.old.display_overhead_map = Map.display_overhead_map;\n\nMap.display_overhead_map = (function() {\n var cached_function = Map.display_overhead_map;\n return function(text) {\n\n var result = cached_function.apply(this, arguments);\n\n // hide the \"no map\" window since it doesn't update properly and it's ugly\n $(\"#map_nomap\").css(\"visibility\", \"hidden\");\n\n if (!mapmod.resize_map) \n return result;\n\n //set wilderness map font size and line height\n $(\"#map_overhead_content\").css(\"font-size\", mapmod.font_size+\"px\");\n $(\"#map_overhead\").css(\"line-height\", mapmod.line_height+\"px\");\n\n // center wilderness map if smaller than map window\n var ttl = Number($(\"#map_overhead\").css(\"height\").replace(\"px\", \"\"));\n var inn = Number($(\"#map_overhead_content\").css(\"height\").replace(\"px\", \"\"));\n if ((ttl - inn) > 2) {\n var diff = (ttl - inn) / 2;\n $(\"#map_overhead\").css(\"margin-top\", diff+\"px\"); \n }\n\n return result;\n };\n})();\n\n\n// draw_exits_string\nif (mapmod.old.draw_exits_string)\n Map.draw_exits_string = mapmod.old.draw_exits_string;\nelse\n mapmod.old.draw_exits_string = Map.draw_exits_string;\n\nMap.draw_exits_string = (function() {\n var cached_function = Map.draw_exits_string;\n return function() {\n\n var result = cached_function.apply(this, arguments);\n\n if (!mapmod.show_area) \n return result;\n\n // replace 2nd room name with area name\n var area = this.cAreaName;\n if (area == null) \n area = \"Area Name Unknown\";\n var area_piece = area.match(/, [A-Za-z0-9 ]+/);\n area = area.replace(area_piece, \" \");\n area_piece = String(String(area_piece).replace(/, /, \"\"))\n area_piece = area_piece.charAt(0).toUpperCase()+area_piece.slice(1); \n if (area_piece != \"Null\") // we're in too deep just roll with it\n area = area_piece+\" \"+area;\n\n if (mapmod.area_line) \n area = mapmod.area_line;\n\n $(\"#map_room_name\").html(\"\"+area+\"\").css(\"font-size\", \"14px\").css(\"text-align\", \"center\");\n\n return result;\n };\n})();\n\n\n// Normally we can just prepend/append the client functions, to get it to do what we want.\n// This one is being funky though, so we're just rewriting the entire function.\n// If something breaks, check here first and compare it to the function from the client's map.js file.\n\n// load_map_data\nif (mapmod.old.load_map_data)\n Map.load_map_data = mapmod.old.load_map_data;\nelse\n mapmod.old.load_map_data = Map.load_map_data;\n\nMap.load_map_data = function (options) {\n var map = this;\n\n map.map_data_xml = \"\";\n map.map_data = [];\n map.map_rooms = [];\n map.map_buildings = [];\n map.minX = map.maxX = map.minY = map.maxY = map.minZ = map.maxZ = 0;\n //map.zoom = 10; // <- IRE code\n map.zoom = Number(mapmod.zoom); // <- Mapmod code\n var loadArea = map.cArea;\n\n var opt = options;\n\n // if we already have the map in the cache, grab it from there\n if (map.map_cache[loadArea])\n {\n map.loadingArea = 0;\n return map.load_xml_map(map.map_cache[loadArea], options);\n }\n\n // otherwise we need to grab the map from the server\n $(\"#map_nomap\").width($(\"#map_container\").width());\n $(\"#map_nomap\").show();\n $(\"#map_nomap\").html(\"LOADING THE MAP\");\n $(\"#marker_char_current\").css('display', 'none');\n $(\"#map_canvas\").hide();\n\n map.loadingArea = map.cArea;\n\n $.get(map.xmlScript, {url: map.map_host, protocol: map.map_protocol, area: loadArea}, function (data) {\n // If we started loading something else in the meantime, bail out here.\n // Prevents the map from being corrupted on fast movement.\n if (map.loadingArea != loadArea) return;\n map.loadingArea = 0;\n map.map_cache[loadArea] = data;\n\n return map.load_xml_map(data, options);\n }); \n};\n\n\nsend_command(\"quicklook\");\nmapmod.activated = 1;"},{"type":"function","name":"onGMCP","enabled":true,"id":14,"code":"if (args.gmcp_method === \"Room.Info\") {\n if (client.mobile)\n return;\n if (typeof mapmod == \"undefined\")\n return;\n\n var map = args.gmcp_args.map;\n var area = args.gmcp_args.area;\n var env = args.gmcp_args.environment;\n var ohmap = args.gmcp_args.ohmap;\n delete mapmod.area_line;\n\n // fix broken unmapped area display\n if (map.match(\"lost.png\") && !mapmod.lost) {\n mapmod.lost = 1;\n area = area.charAt(0).toUpperCase()+area.slice(1);\n mapmod.area_line = area;\n client.mapper.handle_redraw();\n }\n else if (mapmod.lost && !map.match(\"lost.png\")) {\n delete mapmod.lost;\n delete mapmod.area_line;\n $(\"#map_nomap\").hide();\n window.setTimeout(function(){Map.center_map($(\"#marker_char_current\"));}, 0);\n }\n\n // force nomap window to display\n if (map.match(\"lost.png\") && env != \"Vessel\")\n window.setTimeout(function(){$(\"#map_nomap\").css(\"display\", \"block\").css(\"width\", \"100%\");}, 0);\n\n // set area name if on vessel\n if (env === \"Vessel\")\n mapmod.area_line = \"The Ocean\";\n else if (!area) {\n if (ohmap)\n mapmod.area_line = \"The Wilderness\";\n else\n mapmod.area_line = \"Unknown Area\";\n }\n}","items":[]}],"actions":[]},{"type":"group","name":"Aliases","enabled":true,"id":16,"items":[{"type":"alias","name":"","enabled":true,"id":18,"matching":"exact","whole_words":false,"case_sensitive":false,"prefix_suffix":true,"actions":[{"action":"function","fn":"onLoad"},{"action":"script","script":"redraw_interface();"}],"text":"mapmod reload"},{"type":"alias","name":"","enabled":true,"id":3,"matching":"exact","whole_words":false,"case_sensitive":false,"prefix_suffix":true,"actions":[{"action":"script","script":"var gmcp = client.reflex_find_by_name(\"function\", \"onGMCP\", true, false, \"Mapmod\");\nreflex_enable(gmcp);\n\nmapmod.on = true;\nmapmod.save_settings();\n\nmapmod.msg(\"You load the interface modifications.\");"},{"action":"function","fn":"onLoad"},{"action":"script","script":"redraw_interface();"}],"text":"mapmod on"},{"type":"alias","name":"","enabled":true,"id":5,"matching":"exact","whole_words":false,"case_sensitive":false,"prefix_suffix":true,"actions":[{"action":"script","script":"// restore original functions\nforce_single_line_input = mapmod.old.force_single_line_input;\nredraw_interface = mapmod.old.redraw_interface;\nMap.update_canvas = mapmod.old.update_canvas;\nMap.display_overhead_map = mapmod.old.display_overhead_map;\nMap.draw_exits_string = mapmod.old.draw_exits_string;\nMap.load_map_data = mapmod.old.load_map_data;\nredraw_interface();\n\n// turn off gmcp\nvar gmcp = client.reflex_find_by_name(\"function\", \"onGMCP\", true, false, \"Mapmod\");\nreflex_disable(gmcp);\n\nmapmod.on = false;\nmapmod.save_settings();\n\nmapmod.msg(\"You unload the interface modifications.\");"}],"text":"mapmod off"},{"type":"alias","name":"","enabled":true,"id":12,"matching":"exact","whole_words":false,"case_sensitive":false,"prefix_suffix":true,"actions":[{"action":"script","script":"mapmod.set_defaults();\nredraw_interface();\n\nmapmod.msg(\"You revert all settings to mapmod defaults.\");\nmapmod.save_settings();"}],"text":"mapmod default"},{"type":"alias","name":"","enabled":true,"id":8,"matching":"regexp","whole_words":false,"case_sensitive":false,"prefix_suffix":true,"actions":[{"action":"script","script":"var name = args[1].toLowerCase();\nvar value;\nif (args[2] == \"on\")\n value = 1;\nelse\n value = 0;\nmapmod[name] = value;\nredraw_interface();\n\nmapmod.msg(\"You set \"+name.toUpperCase()+\" to \"+args[2].toUpperCase()+\".\");\nmapmod.save_settings();"}],"text":"^mapmod (output_msg|show_area|resize_map|resize_windows) (on|off)$"},{"type":"alias","name":"","enabled":true,"id":9,"matching":"regexp","whole_words":false,"case_sensitive":false,"prefix_suffix":true,"actions":[{"action":"script","script":"var name = args[1].toLowerCase();\nvar value = args[2];\nmapmod[name] = value;\nredraw_interface();\n\nmapmod.msg(\"You set the \"+name.toUpperCase()+\" to \"+value+\".\");\nmapmod.save_settings();"}],"text":"^mapmod (zoom|flag_size|font_size|line_height) (\\d+)$"},{"type":"alias","name":"","enabled":true,"id":10,"matching":"regexp","whole_words":false,"case_sensitive":false,"prefix_suffix":true,"actions":[{"action":"script","script":"var w1 = Number(args[1]);\nvar w2 = Number(args[2]);\nvar w3 = Number(args[3]);\nif ((w1+w2+w3) != 100) {\n mapmod.msg(\"Resize failed. The sum must be 100.\");\n return;\n}\n\nmapmod.left_column = w1;\nmapmod.middle_column = w2;\nmapmod.right_column = w3;\nredraw_interface();\n\nvar values = w1+\" \"+w2+\" \"+w3;\nmapmod.msg(\"You set the COLUMN_WIDTHS to \"+values+\".\");\nmapmod.save_settings();"}],"text":"^mapmod column_widths (\\d+) (\\d+) (\\d+)$"},{"type":"alias","name":"","enabled":true,"id":11,"matching":"regexp","whole_words":false,"case_sensitive":false,"prefix_suffix":true,"actions":[{"action":"script","script":"var side = args[1].toLowerCase();\nvar h1 = Number(args[2]);\nvar h2 = Number(args[3]);\nif ((h1+h2) != 100) {\n mapmod.msg(\"Resize failed. The sum must be 100.\");\n return;\n}\n\nmapmod[side+\"_top\"] = h1;\nmapmod[side+\"_bottom\"] = h2;\nredraw_interface();\n\nvar values = h1+\" \"+h2;\nmapmod.msg(\"You set the HEIGHTS_\"+side.toUpperCase()+\" to \"+values+\".\");\nmapmod.save_settings();"}],"text":"^mapmod heights_(left|right) (\\d+) (\\d+)$"}],"actions":[]}]}