Skip to content

Commit

Permalink
Merge pull request #2020 from RubenatorX/patch-1
Browse files Browse the repository at this point in the history
equipviewer image fit bugfix and new game_path option
  • Loading branch information
Chiaia authored Apr 16, 2021
2 parents ebcb44e + 05c8610 commit e894aa1
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 12 deletions.
3 changes: 2 additions & 1 deletion addons/equipviewer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
9. hideonzone: toggles hiding while crossing zone lines (default is on/true)
10. hideoncutscene: toggles hiding when in cutscene/npc menu/etc (default is on/true)
11. justify: toggles between ammo text being right or left justifed (default is right justified)
12. help: displays explanations of each command
12. game_path <path>: sets path to FFXI folder where you want dats extracted from. Defaults to the "Final Fantasy XI" folder next to the folder containing the launcher (ussually POL.exe).
13. help: displays explanations of each command

### Example Commands
```
Expand Down
31 changes: 26 additions & 5 deletions addons/equipviewer/equipviewer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
]]
_addon.name = 'Equipviewer'
_addon.version = '3.3.0'
_addon.version = '3.3.1'
_addon.author = 'Tako, Rubenator'
_addon.commands = { 'equipviewer', 'ev' }

Expand All @@ -38,7 +38,6 @@ local texts = require('texts')
local functions = require('functions')
local packets = require('packets')
local icon_extractor = require('icon_extractor')
--icon_extractor.ffxi_path('C:/Program Files (x86)/PlayOnline/SquareEnix/FINAL FANTASY XI')

local equipment_data = {
[0] = {slot_name = 'main', slot_id = 0, display_pos = 0, item_id = 0, image = nil},
Expand Down Expand Up @@ -108,6 +107,9 @@ local defaults = {
}
settings = config.load(defaults)
config.save(settings)
if settings.game_path then
icon_extractor.ffxi_path(settings.game_path)
end
local last_encumbrance_bitfield = 0

-- gets the currently equipped item data for the slot information provided
Expand Down Expand Up @@ -420,8 +422,27 @@ windower.register_event('addon command', function (...)
coroutine.sleep(0.5)
local cmd = (...) and (...):lower() or ''
local cmd_args = {select(2, ...)}
if cmd == "gamepath" or cmd == "game_path" then
if #cmd_args == 0 then
error("Must provide path.")
log('Current Path: %s':format(
"\""..settings.game_path.."\"" or "(Default): \""..windower.pol_path.."\/..\/FINAL FANTASY XI\""
))
return
end
local path = table.concat(cmd_args, " ")
if path:lower() == "default" then
settings.game_path = nil
else
settings.game_path = table.concat(cmd_args, " ")
end
config.save(settings)
icon_extractor.ffxi_path(settings.game_path)

setup_ui()

if cmd == 'position' or cmd == 'pos' then
log('game_path set to "%s"':format(path))
elseif cmd == 'position' or cmd == 'pos' then
if #cmd_args < 2 then
error('Not enough arguments.')
log('Current position: '..settings.pos.x..' '..settings.pos.y)
Expand Down Expand Up @@ -631,7 +652,7 @@ function refresh_ui_settings()
blue = settings.icon.blue,
},
texture = {
fit = true,
fit = false,
},
size = {
width = settings.size,
Expand All @@ -647,7 +668,7 @@ function refresh_ui_settings()
blue = settings.icon.blue,
},
texture = {
fit = true,
fit = false,
},
size = {
width = settings.size,
Expand Down
23 changes: 17 additions & 6 deletions addons/equipviewer/icon_extractor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
]]
-- icon_extractor v1.1.0
-- icon_extractor v1.1.1
-- Written by Rubenator of Leviathan
-- Base Extraction Code graciously provided by Trv of Windower discord
local icon_extractor = {}

local game_path = windower.pol_path..'\/..\/FINAL FANTASY XI'
local game_path_default = windower.pol_path..'\/..\/FINAL FANTASY XI'
local game_path = game_path_default

local string = require('string')
local io = require('io')
Expand Down Expand Up @@ -138,8 +139,11 @@ function open_dat(dat_stats)
error('ffxi_path must be set before using icon_extractor library')
end
filename = game_path .. '/ROM/' .. tostring(dat_stats.dat_path) .. '.DAT'
icon_file = io.open(filename, 'rb')
if not icon_file then return end
icon_file, err = io.open(filename, 'rb')
if not icon_file then
error(err)
return
end
dat_stats.file = icon_file
end
return icon_file
Expand Down Expand Up @@ -207,7 +211,8 @@ icon_extractor.buff_by_id = buff_by_id


local ffxi_path = function(location)
game_path = location
game_path = location or game_path_default
close_dats()
end
icon_extractor.ffxi_path = ffxi_path

Expand Down Expand Up @@ -239,17 +244,23 @@ function convert_buff_icon_to_bmp(data)
return header .. data
end

windower.register_event('unload', function()
function close_dats()
for _,dat in pairs(item_dat_map) do
if dat and dat.file then
dat.file:close()
dat.file = nil
end
end
for _,dat in pairs(buff_dat_map) do
if dat and dat.file then
dat.file:close()
dat.file = nil
end
end
end

windower.register_event('unload', function()
close_dats()
end);

return icon_extractor

0 comments on commit e894aa1

Please sign in to comment.