Skip to content

Commit 14cac99

Browse files
committed
Item Messages not being displayed on non-simplified mode, corrected.
Initial language support.
1 parent 5b1726a commit 14cac99

8 files changed

Lines changed: 68 additions & 38 deletions

File tree

configuration.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ local settings = T{
22
-- TODO; Language support yet not implemented
33
lang = T{
44
object = 1, -- 0 = Default, 1 = English, 2 = Japanese
5-
internal = 0, -- 0 = Default, 1 = Japanese, 2 = English
5+
internal = 2, -- 0 = Default, 1 = Japanese, 2 = English
66
msg_text = 'en', -- 'en' = English, 'jp' = Japanese
77
},
88
mode = T{

lib/actionhandlers.lua

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ actionhandlers.SpellParse = function (act)
933933
if abil_ID < 256 then
934934
spell.data = get_weapon_skill[abil_ID] -- May have to correct for charmed pets some day, but I'm not sure there are any monsters with TP moves that give no message.
935935
else
936-
spell.data = get_mon_ability[abil_ID]
936+
spell.data = get_mon_ability[abil_ID][gProfileSettings.lang.object]
937937
end
938938
elseif T{5, 9}:contains(act['category']) then
939939
spell.data = get_item[abil_ID]
@@ -962,7 +962,7 @@ actionhandlers.SpellParse = function (act)
962962
end
963963
elseif fields.weapon_skill then
964964
if abil_ID > 256 then -- WZ_RECOVER_ALL is used by chests in Limbus
965-
spell.data = get_mon_ability[abil_ID]
965+
spell.data = get_mon_ability[abil_ID][gProfileSettings.lang.object]
966966
if not spell.data then
967967
spell.data = {Name = {1, 2}}
968968
spell.data.Name[1] = 'Special Attack'
@@ -1010,22 +1010,23 @@ actionhandlers.SpellParse = function (act)
10101010
if fields.item then
10111011
if T{125,593,594,595,596,597,598,599}:contains(msg_ID) then
10121012
local item_article = not gProfileSettings.mode.simplify and gFuncs.AddItemArticle(effect_val) or ''
1013-
spell.item = gFuncs.ColorIt(item_article..get_item[effect_val].LogNameSingular[gProfileSettings.lang.object], gProfileColor.itemcol)
1013+
1014+
spell.item = gFuncs.ColorIt(get_item[effect_val].LogNameSingular[gProfileSettings.lang.object] and item_article..get_item[effect_val].LogNameSingular[gProfileSettings.lang.object] or item_article..get_item[effect_val].Name[gProfileSettings.lang.object], gProfileColor.itemcol)
10141015
spell.item_id = abil_ID
10151016
else
10161017
spell.data = get_item[abil_ID]
10171018
local item_article = not gProfileSettings.mode.simplify and gFuncs.AddItemArticle(spell.data.Id) or ''
10181019
if spell.data then
1019-
spell.name = gFuncs.ColorIt(item_article..spell.data.LogNameSingular[gProfileSettings.lang.object], gProfileColor.itemcol)
1020-
spell.item = gFuncs.ColorIt(item_article..spell.data.LogNameSingular[gProfileSettings.lang.object], gProfileColor.itemcol)
1020+
spell.name = gFuncs.ColorIt(spell.data.LogNameSingular[gProfileSettings.lang.object] and item_article..spell.data.LogNameSingular[gProfileSettings.lang.object] or item_article..spell.data.Name[gProfileSettings.lang.object], gProfileColor.itemcol)
1021+
spell.item = gFuncs.ColorIt(spell.data.LogNameSingular[gProfileSettings.lang.object] and item_article..spell.data.LogNameSingular[gProfileSettings.lang.object] or item_article..spell.data.Name[gProfileSettings.lang.object], gProfileColor.itemcol)
10211022
spell.item_id = abil_ID
10221023
end
10231024
end
10241025
end
10251026

10261027
if fields.item2 then
10271028
local item_article = not gProfileSettings.mode.simplify and gFuncs.AddItemArticle(effect_val) or ''
1028-
local tempspell = (msg_ID == 377 or msg_ID == 674) and get_item[effect_val] and get_item[effect_val].LogNamePlural[gProfileSettings.lang.object] or item_article..get_item[effect_val].LogNameSingular[gProfileSettings.lang.object]
1029+
local tempspell = (msg_ID == 377 or msg_ID == 674) and get_item[effect_val] and get_item[effect_val].LogNamePlural[gProfileSettings.lang.object] and get_item[effect_val].LogNamePlural[gProfileSettings.lang.object] or get_item[effect_val].LogNameSingular[gProfileSettings.lang.object] and item_article..get_item[effect_val].LogNameSingular[gProfileSettings.lang.object] or item_article..get_item[effect_val].Name[gProfileSettings.lang.object]
10291030
spell.item2 = gFuncs.ColorIt(tempspell, gProfileColor.itemcol)
10301031
spell.item2_id = effect_val
10311032
if fields.number then

lib/constants.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ item_quantity = {id = 0, count = ''}
99
multi_targs = {}
1010
multi_actor = {}
1111
multi_msg = {}
12-
static_settings = false
12+
static_config = false
1313
initial_load = true
1414

1515

@@ -640,6 +640,7 @@ static_filters = T{
640640

641641
get_weapon_skill = nil
642642
get_job_ability = nil
643+
get_mon_skill = nil
643644
get_mon_ability = nil
644645
get_spell = nil
645646
get_item = nil

lib/filetools.lua

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,21 @@ local SaveChanges = function (path, mod_table, file_type)
7777

7878
for i, v in pairs(mod_table) do
7979
for n, m in pairs(mod_table[i]) do
80-
if i ~= 'text' and i ~= 'lang' then
80+
if i == 'lang' then
81+
local file_value = file_data:match(tostring(n)..'[%s%S]-[=][%s%S]-[,]')
82+
:gsub(tostring(n)..'[%s%S]-[=][%s%S]-', '')
83+
:gsub('"', '')
84+
:gsub('[,]', '')
85+
:gsub(' ', '')
86+
87+
if tostring(file_value) ~= tostring(mod_table[i][n]) then
88+
if type(mod_table[i][n]) == "number" then
89+
file_data = string.gsub(file_data, tostring(n)..'[%s%S]-[=][%s%S]-[,]', tostring(n)..' = '..tostring(mod_table[i][n])..',', 1)
90+
elseif type(mod_table[i][n]) == "string" then
91+
file_data = string.gsub(file_data, tostring(n)..'[%s%S]-[=][%s%S]-[,]', tostring(n)..' = '..'"'..tostring(mod_table[i][n])..'",', 1)
92+
end
93+
end
94+
elseif i == 'mode' then
8195
local file_value = file_data:match(tostring(n)..'[%s%S]-[=][%s%S]-[,]')
8296
:gsub(tostring(n)..'[%s%S]-[=][%s%S]-', '')
8397
:gsub('[,]', '')

lib/functions.lua

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ local PopulateSkills = function()
88
local t1 = {}
99
local t2 = {}
1010
local t3 = {}
11+
local t4 = {}
1112

1213
local index = 1
1314
for i = 1, 4116, 1 do
@@ -43,7 +44,22 @@ local PopulateSkills = function()
4344
break
4445
end
4546
end
46-
get_mon_ability = t3
47+
get_mon_skill = t3
48+
49+
index = 0x101
50+
for i = 1, 4116, 1 do
51+
local j_ability_en = AshitaCore:GetResourceManager():GetString('monsters.abilities', i, 2)
52+
local j_ability_jp = AshitaCore:GetResourceManager():GetString('monsters.abilities', i, 1)
53+
if j_ability_en then
54+
t4[index] = {1, 2}
55+
t4[index][1] = j_ability_en
56+
t4[index][2] = j_ability_jp
57+
index = index + 1
58+
else
59+
break
60+
end
61+
end
62+
get_mon_ability = t4
4763
end
4864

4965
local PopulateSpells = function()
@@ -442,6 +458,7 @@ local ItemArticleFix = function (id, id2, msg)
442458
end
443459
end
444460
end
461+
return msg
445462
end
446463

447464
local AddItemArticle = function(item_id)

lib/packethandlers.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ packethandlers.HandleIncomingPacket = function(e)
203203
if not get_item[am.param_1] then
204204
e.blocked = false
205205
end
206-
item = get_item[am.param_1].LogNameSingular[gProfileSettings.lang.object]
206+
item = get_item[am.param_1].LogNameSingular[gProfileSettings.lang.object] and get_item[am.param_1].LogNameSingular[gProfileSettings.lang.object] or get_item[am.param_1].Name[gProfileSettings.lang.object]
207207
end
208208

209209
if fields.number then

lib/profilehandler.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ status.LoadProfile = function(profilePath, profileType)
7171
gProfileSettings = static_settings;
7272
print(chat.header('SimpleLog') .. chat.error('Failed to load configuration file: ') .. chat.color1(2, shortFileName)..chat.error('\nSaving will be disabled.'));
7373
print(chat.header('SimpleLog') .. chat.error(loadError));
74+
static_config = true
7475
return;
7576
end
7677
gProfileSettings = success();
@@ -89,6 +90,7 @@ status.LoadProfile = function(profilePath, profileType)
8990
gProfileFilter = static_filters;
9091
print(chat.header('SimpleLog') .. chat.error('Failed to load filters profile: ') .. chat.color1(2, 'default_filters.lua')..chat.error('\nSaving will be disabled.'));
9192
print(chat.header('SimpleLog') .. chat.error(default_loadError));
93+
static_config = true
9294
return
9395
end
9496
gProfileFilter = default_success();
@@ -108,6 +110,7 @@ status.LoadProfile = function(profilePath, profileType)
108110
gProfileColor = static_colors;
109111
print(chat.header('SimpleLog') .. chat.error('Failed to load colors profile: ') .. chat.color1(2, shortFileName)..chat.error('\nSaving will be disabled.'));
110112
print(chat.header('SimpleLog') .. chat.error(loadError));
113+
static_config = true
111114
return;
112115
end
113116
gProfileColor = success();

lib/ui.lua

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -251,31 +251,26 @@ ui.render_config = function(toggle)
251251
imgui.BeginChild('conf_box', { imgui.GetWindowWidth()-16, imgui.GetWindowHeight()-120 }, true)
252252
imgui.PopStyleColor()
253253
if ui.state.tab == 0 then
254-
-- local lang_choices = {'Default', 'English', 'Japanese'}
255-
256-
-- -- Language support yet not implemented
257-
-- imgui.TextColored(header_text_col, ' Language')
258-
-- imgui.ShowHelp('Language Configuration:\nChanges the language of output messages.', true)
259-
260-
-- -- Language support yet not implemented
261-
-- if imgui.BeginCombo('', lang_choices[gProfileSettings.lang.object + 1]) then
262-
-- if imgui.Selectable('Default', choice == 1) then
263-
-- gProfileSettings.lang.object = 0
264-
-- gProfileSettings.lang.internal = 0
265-
-- gProfileSettings.lang.msg_text = 'en'
266-
-- end
267-
-- if imgui.Selectable('English', choice == 2) then
268-
-- gProfileSettings.lang.object = 1
269-
-- gProfileSettings.lang.internal = 2
270-
-- gProfileSettings.lang.msg_text = 'en'
271-
-- end
272-
-- if imgui.Selectable('Japanese', choice == 3) then
273-
-- gProfileSettings.lang.object = 2
274-
-- gProfileSettings.lang.internal = 1
275-
-- gProfileSettings.lang.msg_text = 'jp'
276-
-- end
277-
-- imgui.EndCombo()
278-
-- end
254+
local lang_choices = {'English', 'Japanese'}
255+
256+
-- Language support yet not fully implemented
257+
imgui.PushTextWrapPos(0)
258+
imgui.TextColored(theme.desc_text_col, 'Language Option:\nSwitch between English or Japanese message outputs.')
259+
-- Temp Warning
260+
imgui.TextColored({1.0, 0.0, 0.0, 1.0}, 'EXPERIMENTAL')
261+
if imgui.BeginCombo('', lang_choices[gProfileSettings.lang.object]) then
262+
if imgui.Selectable('English', choice == 1) then
263+
gProfileSettings.lang.object = 1
264+
gProfileSettings.lang.internal = 2
265+
gProfileSettings.lang.msg_text = 'en'
266+
end
267+
if imgui.Selectable('Japanese', choice == 2) then
268+
gProfileSettings.lang.object = 2
269+
gProfileSettings.lang.internal = 1
270+
gProfileSettings.lang.msg_text = 'en'
271+
end
272+
imgui.EndCombo()
273+
end
279274

280275
imgui.PushTextWrapPos(0)
281276
imgui.TextColored(theme.desc_text_col, 'General Options:\nChange different modes of how the addon output messages.')
@@ -822,7 +817,7 @@ ui.render_config = function(toggle)
822817
end
823818
imgui.EndChild()
824819
if imgui.Button('\xef\x95\xaf Save Changes', {imgui.GetWindowWidth()-16, 20}) then
825-
if not static_settings then
820+
if not static_config then
826821
ui.save_changes()
827822
else
828823
gFuncs.Error('Saving is Disabled.')
@@ -831,7 +826,6 @@ ui.render_config = function(toggle)
831826
imgui.TextDisabled(('\xef\x83\x81 %s'):fmt(addon.link))
832827
imgui.TextDisabled(('\xef\x87\xb9 2022 by %s'):fmt(addon.author))
833828
imgui.EndGroup()
834-
--print('settings open')
835829
end
836830
imgui.End()
837831
end

0 commit comments

Comments
 (0)