Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
# By BrunoDCC
# Via BrunoDCC
* https://github.com/BrunoDCC/forgottenmapeditor:
  Fixes Removed extra item
  10.22 support Fixed version on open Fixed core files Ctrl in pencil remove the atual item and selection remove all First commit of new categories Open file text
  • Loading branch information
asamy committed Nov 13, 2013
2 parents 659f469 + 68d1818 commit 3379136
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 15 deletions.
51 changes: 36 additions & 15 deletions modules/mapeditor_filebrowser/filebrowser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ end

local extensions = {
["otb"] = g_things.loadOtb,
["otbm"] = function(f) openMap() end,
["otbm"] = function(f) openMap(f) end,
["dat"] = loadDat,
["spr"] = g_sprites.loadSpr,
["xml"] = function(f) openXml(f) end
Expand All @@ -39,27 +39,47 @@ local supportedVersions = {
810, 853, 854, 860, 861, 862, 870,
910, 940, 944, 953, 954, 960, 961,
963, 970, 971, 973, 974, 973, 974,
975, 976, 977, 978, 979, 980, 1010
975, 976, 977, 978, 979, 980, 1010,
1022
}

function loadCoreFiles()
local currentOption = versionComboBox:getCurrentOption()
local currentVersion = tostring(currentOption.text)
if not currentVersion then
g_logger.debug("Invalid version specified, cannot load core files")
return
VERSION = tostring(currentOption.text)
VERSION_FOLDER = "/data/materials/"..VERSION.."/"
OTB_FILE = "/data/materials/"..VERSION.."/items.otb"
XML_FILE = "/data/materials/"..VERSION.."/items.xml"
MON_FILE = "/data/materials/"..VERSION.."/monster/monsters.xml"
NPC_FOLDER = "/data/materials/"..VERSION.."/npc"
DAT_FILE = "/data/materials/"..VERSION.."/Tibia.dat"
SPR_FILE = "/data/materials/"..VERSION.."/Tibia.spr"

if g_game.setClientVersion(VERSION) then
print("Error after load "..VERSION.." version.")
return false
end

for _, f in ipairs(fsCache) do
local v = f:getText()
if v:find(currentVersion) then
local extension = v:extension()
if extension ~= "otbm" then
extensions[extension] (v)
end
end
print("--> Loading cores with "..VERSION.."")
g_game.setProtocolVersion(VERSION)
if not g_resources.directoryExists(VERSION_FOLDER) then
print("---> Folder "..VERSION.." not found '"..VERSION_FOLDER.."'")
return false
end

print("---> "..VERSION.." Loaded")
print("--> Loading dat...")
g_things.loadDat(DAT_FILE)
print("--> Loading spr...")
g_sprites.loadSpr(SPR_FILE)
print("--> Loading OTB...")
g_things.loadOtb(OTB_FILE)
print("--> Loading XML...")
g_things.loadXml(XML_FILE)
print("--> Loading monsters...")
g_creatures.loadMonsters(MON_FILE)
print("--> Loading NPCs...")
g_creatures.loadNpcs(NPC_FOLDER)

ItemPalette.initData()
end

Expand All @@ -86,7 +106,7 @@ local function add(filename)
local file = g_ui.createWidget('FileLabel', fileList)
file:setText(filename)

file.onDoubleClick = function() openFile(filename) end
file.onDoubleClick = function() print("-> Loading "..filename.."...") openFile(filename) end
file.onMousePress = function() _G["selection"] = filename end

table.insert(fsCache, file)
Expand Down Expand Up @@ -210,6 +230,7 @@ function FileBrowser.init()

for _, proto in ipairs(supportedVersions) do
versionComboBox:addOption(proto)
versionComboBox:setCurrentOption(g_game.getProtocolVersion())
end

fileEdit.onTextChange = function(widget, newText, oldText)
Expand Down
11 changes: 11 additions & 0 deletions modules/mapeditor_interface/uieditablemap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ function UIEditableMap:resolve(pos)
g_map.removeThing(topThing)
return true
end
if g_keyboard.isCtrlPressed() then
if g_map.getTile(pos) then
g_map.cleanTile(pos)
end
end
end
end
return false
Expand All @@ -143,6 +148,12 @@ function UIEditableMap:resolve(pos)
self:doRender(Item.createOtb(itemType:getServerId()), {x = pos.x + x, y = pos.y + y, z = pos.z})
end
end

if g_keyboard.isCtrlPressed() then
if g_map.getTile(pos) then
g_map.removeThing()
end
end

return true
-- Paint Bucket Tool --
Expand Down

0 comments on commit 3379136

Please sign in to comment.