|
|
@@ -18,12 +18,18 @@ UiContainer.MateriaMenu = {
|
|
|
--- ID of the character the menu is open for.
|
|
|
char_id = -1,
|
|
|
|
|
|
+ --- Cursor position in the materia list.
|
|
|
list_position = 1,
|
|
|
|
|
|
+ --- Max cursor postion in the materia list.
|
|
|
list_position_total = 10,
|
|
|
|
|
|
+ --- First visible position in the materia list
|
|
|
list_first_visible = 1,
|
|
|
|
|
|
+ --- Max materias in the list
|
|
|
+ list_size = 200,
|
|
|
+
|
|
|
--- Run when the menu is creaded.
|
|
|
--
|
|
|
-- It does nothing.
|
|
|
@@ -42,9 +48,11 @@ UiContainer.MateriaMenu = {
|
|
|
-- TODO: Handle L1/R1 (change character)
|
|
|
-- TODO: Handle square: Materia menu
|
|
|
if button == "Escape" and event == "Press" then
|
|
|
+ audio_manager:play_sound("Back")
|
|
|
UiContainer.current_menu = "main"
|
|
|
script:request_end_sync(Script.UI, "MateriaMenu", "hide", 0)
|
|
|
elseif button == "Down" then
|
|
|
+ audio_manager:play_sound("Cursor")
|
|
|
self.header_position_row = self.header_position_row + 1
|
|
|
if self.header_position_row > self.header_position_row_total then
|
|
|
self.header_position_row = 1
|
|
|
@@ -52,6 +60,7 @@ UiContainer.MateriaMenu = {
|
|
|
ui_manager:get_widget("MateriaMenu.Container.Character.Cursor"):set_default_animation("Position" .. self.header_position_row .. "-" .. self.header_position)
|
|
|
self.populate_details(self, false)
|
|
|
elseif button == "Up" then
|
|
|
+ audio_manager:play_sound("Cursor")
|
|
|
self.header_position_row = self.header_position_row - 1
|
|
|
if self.header_position_row < 1 then
|
|
|
self.header_position_row = self.header_position_row_total
|
|
|
@@ -59,6 +68,7 @@ UiContainer.MateriaMenu = {
|
|
|
ui_manager:get_widget("MateriaMenu.Container.Character.Cursor"):set_default_animation("Position" .. self.header_position_row .. "-" .. self.header_position)
|
|
|
self.populate_details(self, false)
|
|
|
elseif button == "Right" then
|
|
|
+ audio_manager:play_sound("Cursor")
|
|
|
self.header_position = self.header_position + 1
|
|
|
if self.header_position > self.header_position_total then
|
|
|
self.header_position = 1
|
|
|
@@ -66,6 +76,7 @@ UiContainer.MateriaMenu = {
|
|
|
ui_manager:get_widget("MateriaMenu.Container.Character.Cursor"):set_default_animation("Position" .. self.header_position_row .. "-" .. self.header_position)
|
|
|
self.populate_details(self, false)
|
|
|
elseif button == "Left" then
|
|
|
+ audio_manager:play_sound("Cursor")
|
|
|
self.header_position = self.header_position - 1
|
|
|
if self.header_position < 1 then
|
|
|
self.header_position = self.header_position_total
|
|
|
@@ -73,18 +84,89 @@ UiContainer.MateriaMenu = {
|
|
|
ui_manager:get_widget("MateriaMenu.Container.Character.Cursor"):set_default_animation("Position" .. self.header_position_row .. "-" .. self.header_position)
|
|
|
self.populate_details(self, false)
|
|
|
elseif button == "Enter" then
|
|
|
- --[[if self.equip_position == 1 then
|
|
|
- self.selecting_slot = Inventory.ITEM_TYPE.WEAPON
|
|
|
- elseif self.equip_position == 2 then
|
|
|
- self.selecting_slot = Inventory.ITEM_TYPE.ARMOR
|
|
|
- elseif self.equip_position == 3 then
|
|
|
- self.selecting_slot = Inventory.ITEM_TYPE.ACCESSORY
|
|
|
+ if self.header_position_row == 1 and self.header_position == 1 then
|
|
|
+ -- TODO: Command menu
|
|
|
+ elseif self.header_position_row == 2 and self.header_position == 1 then
|
|
|
+ -- TODO: Order menu
|
|
|
+ else
|
|
|
+ -- TODO: Check for avalid slot before entering list
|
|
|
+ if self.header_position_row == 1 and #(Game.Items[Characters[self.char_id].weapon.id].slots) > self.header_position - 2 then
|
|
|
+ self.submenu_list(self)
|
|
|
+ elseif self.header_position_row == 2 and #(Game.Items[Characters[self.char_id].armor.id].slots) > self.header_position -2 then
|
|
|
+ self.submenu_list(self)
|
|
|
+ else
|
|
|
+ audio_manager:play_sound("Error")
|
|
|
+ return 0
|
|
|
+ end
|
|
|
+ audio_manager:play_sound("Cursor")
|
|
|
end
|
|
|
- self.submenu_select(self)]]
|
|
|
-- TODO: Triangle->Remove
|
|
|
else
|
|
|
return 0
|
|
|
end
|
|
|
+ elseif UiContainer.current_submenu == "list" then
|
|
|
+ if button == "Down" then
|
|
|
+ if self.list_first_visible + self.list_position > self.list_size then
|
|
|
+ -- At the very end, do nothing
|
|
|
+ audio_manager:play_sound("Error")
|
|
|
+ return 0
|
|
|
+ end
|
|
|
+ audio_manager:play_sound("Cursor")
|
|
|
+ if self.list_position == self.list_position_total then
|
|
|
+ -- The cursor is at the end. Scroll page, but dont change cursor.
|
|
|
+ self.list_first_visible = self.list_first_visible + 1
|
|
|
+ self.populate_list(self)
|
|
|
+ else
|
|
|
+ -- The cursor is not at the end, move cursor down.
|
|
|
+ self.list_position = self.list_position + 1
|
|
|
+ end
|
|
|
+ ui_manager:get_widget("MateriaMenu.Container.List.Cursor"):set_default_animation("Position" .. self.list_position)
|
|
|
+ -- Show details
|
|
|
+ self.populate_details(self, true)
|
|
|
+ elseif button == "Up" then
|
|
|
+ if self.list_first_visible == 1 and self.list_position == 1 then
|
|
|
+ -- At the very begining, do nothing
|
|
|
+ audio_manager:play_sound("Error")
|
|
|
+ return 0
|
|
|
+ end
|
|
|
+ audio_manager:play_sound("Cursor")
|
|
|
+ if self.list_position == 1 then
|
|
|
+ -- The cursor is at the end. Scroll page, but dont change cursor.
|
|
|
+ self.list_first_visible = self.list_first_visible - 1
|
|
|
+ self.populate_list(self)
|
|
|
+ else
|
|
|
+ -- The cursor is not at the end, move cursor down.
|
|
|
+ self.list_position = self.list_position - 1
|
|
|
+ end
|
|
|
+ ui_manager:get_widget("MateriaMenu.Container.List.Cursor"):set_default_animation("Position" .. self.list_position)
|
|
|
+ -- Show details
|
|
|
+ self.populate_details(self, true)
|
|
|
+ elseif button == "PGDN" then -- TODO: Also, the bind to R1
|
|
|
+ if self.list_first_visible + self.list_position_total < self.list_size - self.list_position_total then
|
|
|
+ audio_manager:play_sound("Cursor")
|
|
|
+ self.list_first_visible = self.list_first_visible + self.list_position_total
|
|
|
+ self.populate_list(self)
|
|
|
+ self.populate_details(self, true)
|
|
|
+ else
|
|
|
+ audio_manager:play_sound("Error")
|
|
|
+ end
|
|
|
+ elseif button == "PGUP" then -- TODO: Also, the bind to L1
|
|
|
+ if self.list_first_visible - self.list_position_total > 1 then
|
|
|
+ audio_manager:play_sound("Cursor")
|
|
|
+ self.list_first_visible = self.list_first_visible - self.list_position_total
|
|
|
+ self.populate_list(self)
|
|
|
+ self.populate_details(self, true)
|
|
|
+ else
|
|
|
+ audio_manager:play_sound("Error")
|
|
|
+ end
|
|
|
+ elseif button == "Escape" and event == "Press" then
|
|
|
+ audio_manager:play_sound("Back")
|
|
|
+ self.submenu_none(self)
|
|
|
+ elseif button == "Enter" then
|
|
|
+ -- TODO: Replace for "Equip materia" sound.
|
|
|
+ audio_manager:play_sound("Cursor")
|
|
|
+ self.equip_materia(self)
|
|
|
+ end
|
|
|
end
|
|
|
end
|
|
|
return 0
|
|
|
@@ -100,7 +182,11 @@ UiContainer.MateriaMenu = {
|
|
|
UiContainer.current_submenu = ""
|
|
|
self.header_position_row = 1
|
|
|
self.header_position = 1
|
|
|
+ self.list_position = 1
|
|
|
+ self.list_first_visible = 1
|
|
|
+ self.populate_list(self)
|
|
|
self.submenu_none(self)
|
|
|
+ self.populate_commands(self)
|
|
|
return 0;
|
|
|
end,
|
|
|
|
|
|
@@ -111,33 +197,22 @@ UiContainer.MateriaMenu = {
|
|
|
ui_manager:get_widget("MateriaMenu.Container.Character.Portrait"):set_image("images/characters/" .. tostring(self.char_id) .. ".png")
|
|
|
self.populate_equip(self)
|
|
|
-- TODO: Do something for chars 9 and 10
|
|
|
-
|
|
|
-
|
|
|
- --[[self.load_availables(self)
|
|
|
+ ui_manager:get_widget("MateriaMenu.Container.Character.WpnIcon"):set_image("images/icons/item_weapon_" .. tostring(self.char_id) .. ".png")
|
|
|
+ ui_manager:get_widget("MateriaMenu.Container.List.Cursor"):set_visible(false)
|
|
|
+ --TODO: Uncomment when implemented: ui_manager:get_widget("MateriaMenu.Container.Order.Cursor"):set_visible(false)
|
|
|
+ ui_manager:get_widget("MateriaMenu.Container.Character.Cursor"):set_visible(true)
|
|
|
self.populate_details(self, false)
|
|
|
- self.populate_current_stats(self)
|
|
|
- self.calculate_stat_diffs(self)
|
|
|
- -- Hide stat arrows and difs
|
|
|
- ui_manager:get_widget("EquipMenu.Container.Stats.AtkDif"):set_visible(false)
|
|
|
- ui_manager:get_widget("EquipMenu.Container.Stats.AccDif"):set_visible(false)
|
|
|
- ui_manager:get_widget("EquipMenu.Container.Stats.DefDif"):set_visible(false)
|
|
|
- ui_manager:get_widget("EquipMenu.Container.Stats.EvaDif"):set_visible(false)
|
|
|
- ui_manager:get_widget("EquipMenu.Container.Stats.MAtkDif"):set_visible(false)
|
|
|
- ui_manager:get_widget("EquipMenu.Container.Stats.MDefDif"):set_visible(false)
|
|
|
- ui_manager:get_widget("EquipMenu.Container.Stats.MEvaDif"):set_visible(false)
|
|
|
- ui_manager:get_widget("EquipMenu.Container.Stats.AtkArw"):set_visible(false)
|
|
|
- ui_manager:get_widget("EquipMenu.Container.Stats.AccArw"):set_visible(false)
|
|
|
- ui_manager:get_widget("EquipMenu.Container.Stats.DefArw"):set_visible(false)
|
|
|
- ui_manager:get_widget("EquipMenu.Container.Stats.EvaArw"):set_visible(false)
|
|
|
- ui_manager:get_widget("EquipMenu.Container.Stats.MAtkArw"):set_visible(false)
|
|
|
- ui_manager:get_widget("EquipMenu.Container.Stats.MDefArw"):set_visible(false)
|
|
|
- ui_manager:get_widget("EquipMenu.Container.Stats.MEvaArw"):set_visible(false)
|
|
|
- ui_manager:get_widget("EquipMenu.Container.List.Cursor"):set_visible(false)
|
|
|
- for i = 1, self.list_position_total do
|
|
|
- ui_manager:get_widget("EquipMenu.Container.List.Item" .. tostring(i)):set_text("")
|
|
|
- end]]
|
|
|
end,
|
|
|
|
|
|
+ submenu_list = function(self)
|
|
|
+ UiContainer.current_submenu = "list"
|
|
|
+ ui_manager:get_widget("MateriaMenu.Container.List.Cursor"):set_visible(true)
|
|
|
+ self.populate_details(self, true)
|
|
|
+ end,
|
|
|
+
|
|
|
+ --- Populate the equipment section.
|
|
|
+ --
|
|
|
+ -- It fills the header with weapn and armor names, slots, and current materia.
|
|
|
populate_equip = function(self)
|
|
|
local weapon = Game.Items[Characters[self.char_id].weapon.id]
|
|
|
local armor = Game.Items[Characters[self.char_id].armor.id]
|
|
|
@@ -192,12 +267,53 @@ UiContainer.MateriaMenu = {
|
|
|
-- Must be called when the cursor goes into an empty slot
|
|
|
hide_details = function(self)
|
|
|
-- TODO
|
|
|
+ ui_manager:get_widget("MateriaMenu.Container.Details.Empty"):set_visible(true)
|
|
|
+ ui_manager:get_widget("MateriaMenu.Container.Details.Commands"):set_visible(false)
|
|
|
+ ui_manager:get_widget("MateriaMenu.Container.Details.EnemySkill"):set_visible(false)
|
|
|
+ ui_manager:get_widget("MateriaMenu.Container.Details.Materia"):set_visible(false)
|
|
|
+ ui_manager:get_widget("MateriaMenu.Container.Help.Help"):set_text("")
|
|
|
end,
|
|
|
|
|
|
--- Show details of an enemy skill materia.
|
|
|
--
|
|
|
- -- Must be called when the cursor goes into an empty slot
|
|
|
- populate_e_skill_details = function(self)
|
|
|
+ -- Must be called when the cursor goes over an enemy skill materia
|
|
|
+ --
|
|
|
+ -- @param materia Selected Enemy Skill materia.
|
|
|
+ populate_e_skill_details = function(self, materia)
|
|
|
+ if materia.id ~= Materia.ENEMY_SKILL_ID then
|
|
|
+ print("ERROR: Tried to get enemy skill info form non-enemy skill materia with ID " .. tostring(materia.id))
|
|
|
+ return 0
|
|
|
+ elseif materia.skills == nil then
|
|
|
+ print("ERROR: Enemy skill materia has no skill information")
|
|
|
+ --return 0
|
|
|
+ end
|
|
|
+ ui_manager:get_widget("MateriaMenu.Container.Help.Help"):set_text(Game.Materia[materia.id].description)
|
|
|
+ ui_manager:get_widget("MateriaMenu.Container.Details.EnemySkill.Name"):set_text(Game.Materia[materia.id].name)
|
|
|
+ ui_manager:get_widget("MateriaMenu.Container.Details.Empty"):set_visible(false)
|
|
|
+ ui_manager:get_widget("MateriaMenu.Container.Details.Commands"):set_visible(false)
|
|
|
+ ui_manager:get_widget("MateriaMenu.Container.Details.EnemySkill"):set_visible(true)
|
|
|
+ ui_manager:get_widget("MateriaMenu.Container.Details.Materia"):set_visible(false)
|
|
|
+ for s = 1, 24 do
|
|
|
+ if materia.skills[s] ~= nil and materia.skills[s] == true then
|
|
|
+ ui_manager:get_widget("MateriaMenu.Container.Details.EnemySkill.Stars.Star" .. tostring(s)):set_image("images/icons/materia_star_3.png")
|
|
|
+ ui_manager:get_widget("MateriaMenu.Container.Details.EnemySkill.Skills.Skill" .. tostring(s)):set_text(Game.Attacks[71 + s].name)
|
|
|
+ ui_manager:get_widget("MateriaMenu.Container.Details.EnemySkill.Skills.Skill" .. tostring(s)):set_visible(true)
|
|
|
+ else
|
|
|
+ ui_manager:get_widget("MateriaMenu.Container.Details.EnemySkill.Stars.Star" .. tostring(s)):set_image("images/icons/materia_star_empty_3.png")
|
|
|
+ ui_manager:get_widget("MateriaMenu.Container.Details.EnemySkill.Skills.Skill" .. tostring(s)):set_visible(false)
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
+
|
|
|
+ end,
|
|
|
+
|
|
|
+ --- Displays the command list in the details window
|
|
|
+ populate_commands = function(self)
|
|
|
+ ui_manager:get_widget("MateriaMenu.Container.Details.Empty"):set_visible(false)
|
|
|
+ ui_manager:get_widget("MateriaMenu.Container.Details.Commands"):set_visible(true)
|
|
|
+ ui_manager:get_widget("MateriaMenu.Container.Details.EnemySkill"):set_visible(false)
|
|
|
+ ui_manager:get_widget("MateriaMenu.Container.Details.Materia"):set_visible(false)
|
|
|
+ ui_manager:get_widget("MateriaMenu.Container.Help.Help"):set_text("")
|
|
|
-- TODO
|
|
|
end,
|
|
|
|
|
|
@@ -212,9 +328,16 @@ UiContainer.MateriaMenu = {
|
|
|
local level
|
|
|
local max_level
|
|
|
local master = false
|
|
|
- local materia
|
|
|
+ local materia -- Materia static information, as in Game.Materia[]
|
|
|
+ local materia_selected -- Materia instance information, as in Materia[]
|
|
|
if from_list == false then
|
|
|
+ -- Get data from equiped materia
|
|
|
if self.header_position_row == 1 then
|
|
|
+ -- "Check" highlighted
|
|
|
+ if self.header_position == 1 then
|
|
|
+ self.populate_commands(self)
|
|
|
+ return 0
|
|
|
+ end
|
|
|
-- Weapon materia
|
|
|
local weapon_id = Characters[self.char_id].weapon.id
|
|
|
local weapon = Game.Items[weapon_id]
|
|
|
@@ -223,10 +346,16 @@ UiContainer.MateriaMenu = {
|
|
|
self.hide_details(self)
|
|
|
return 0
|
|
|
end
|
|
|
+ materia_selected = Characters[self.char_id].weapon.materia[self.header_position - 2]
|
|
|
id = Characters[self.char_id].weapon.materia[self.header_position - 2].id
|
|
|
ap = Characters[self.char_id].weapon.materia[self.header_position - 2].ap
|
|
|
materia = Game.Materia[id]
|
|
|
elseif self.header_position_row == 2 then
|
|
|
+ -- "Order" highlighted
|
|
|
+ if self.header_position == 1 then
|
|
|
+ self.hide_details(self)
|
|
|
+ return 0
|
|
|
+ end
|
|
|
-- Armor materia
|
|
|
local armor_id = Characters[self.char_id].armor.id
|
|
|
local armor = Game.Items[armor_id]
|
|
|
@@ -235,6 +364,7 @@ UiContainer.MateriaMenu = {
|
|
|
self.hide_details(self)
|
|
|
return 0
|
|
|
end
|
|
|
+ materia_selected = Characters[self.char_id].armor.materia[self.header_position - 2]
|
|
|
id = Characters[self.char_id].armor.materia[self.header_position - 2].id
|
|
|
ap = Characters[self.char_id].armor.materia[self.header_position - 2].ap
|
|
|
materia = Game.Materia[id]
|
|
|
@@ -244,9 +374,36 @@ UiContainer.MateriaMenu = {
|
|
|
return 0
|
|
|
end
|
|
|
else
|
|
|
- -- TODO: Get materia data from list
|
|
|
+ --Get materia data from list.
|
|
|
+ local mat_position = self.list_first_visible + self.list_position - 1
|
|
|
+ if Materia[mat_position] == nil then
|
|
|
+ self.hide_details(self)
|
|
|
+ return 0
|
|
|
+ end
|
|
|
+ materia_selected = Materia[mat_position]
|
|
|
+ id = Materia[mat_position].id
|
|
|
+ ap = Materia[mat_position].ap
|
|
|
+ materia = Game.Materia[Materia[mat_position].id]
|
|
|
+ end
|
|
|
+
|
|
|
+ -- Materia should be set, but just in case, one last check.
|
|
|
+ if materia == nil then
|
|
|
+ self.hide_details(self)
|
|
|
+ return
|
|
|
+ end
|
|
|
+
|
|
|
+ -- Check for enemy skill. It is handled by another function.
|
|
|
+ if id == Materia.ENEMY_SKILL_ID then
|
|
|
+ self.populate_e_skill_details(self, materia_selected)
|
|
|
+ return 0
|
|
|
end
|
|
|
|
|
|
+ ui_manager:get_widget("MateriaMenu.Container.Details.Empty"):set_visible(false)
|
|
|
+ ui_manager:get_widget("MateriaMenu.Container.Details.Commands"):set_visible(false)
|
|
|
+ ui_manager:get_widget("MateriaMenu.Container.Details.EnemySkill"):set_visible(false)
|
|
|
+ ui_manager:get_widget("MateriaMenu.Container.Details.Materia"):set_visible(true)
|
|
|
+ ui_manager:get_widget("MateriaMenu.Container.Help.Help"):set_text(Game.Materia[id].description)
|
|
|
+
|
|
|
-- Get level and max level, and check for master.
|
|
|
level = 0
|
|
|
for lv, lv_ap in ipairs(materia.levels_ap) do
|
|
|
@@ -471,6 +628,87 @@ UiContainer.MateriaMenu = {
|
|
|
end
|
|
|
end,
|
|
|
|
|
|
+ --- Populates the materia list.
|
|
|
+ populate_list = function(self)
|
|
|
+ local pos = 1
|
|
|
+ for i = self.list_first_visible, self.list_first_visible + self.list_position_total - 1 do
|
|
|
+ if Materia[i] ~= nil then
|
|
|
+ local type = Game.Materia[Materia[i].id].type
|
|
|
+ local name = Game.Materia[Materia[i].id].name
|
|
|
+ ui_manager:get_widget("MateriaMenu.Container.List.Icon" .. tostring(pos)):set_image("images/icons/materia_" .. tostring(type) .. ".png")
|
|
|
+ ui_manager:get_widget("MateriaMenu.Container.List.Icon" .. tostring(pos)):set_visible(true)
|
|
|
+ ui_manager:get_widget("MateriaMenu.Container.List.Name" .. tostring(pos)):set_text(name)
|
|
|
+ ui_manager:get_widget("MateriaMenu.Container.List.Name" .. tostring(pos)):set_visible(true)
|
|
|
+ else
|
|
|
+ ui_manager:get_widget("MateriaMenu.Container.List.Icon" .. tostring(pos)):set_visible(false)
|
|
|
+ ui_manager:get_widget("MateriaMenu.Container.List.Name" .. tostring(pos)):set_visible(false)
|
|
|
+ end
|
|
|
+ pos = pos + 1
|
|
|
+ end
|
|
|
+ -- Set scroll bar position
|
|
|
+ local scroll = ui_manager:get_widget("MateriaMenu.Container.List.Scroll")
|
|
|
+ -- first_item_in_window == 1 then Top -> 0%3
|
|
|
+ -- first_item_in_window == inventory_size - first_item_in_window then top = 100%-21
|
|
|
+ local percent = math.floor((self.list_first_visible - 1) * 100 / (self.list_size - self.list_position_total))
|
|
|
+ local fixed = 3 + (-1 * math.floor(self.list_first_visible - 1) * 25 / (self.list_size - self.list_position_total))
|
|
|
+ scroll:set_y(percent, fixed)
|
|
|
+ end,
|
|
|
+
|
|
|
+ --- Equips the materia selected in the list at the currently selected slot.
|
|
|
+ --
|
|
|
+ -- It can also be used to swap or remove materia.
|
|
|
+ equip_materia = function(self)
|
|
|
+ local equip
|
|
|
+ local equip_slot = self.header_position - 2 -- 0-8
|
|
|
+ local list_pos = self.list_first_visible + self.list_position - 1
|
|
|
+ local materia_equip = {id = nil, ap = 0}
|
|
|
+ local materia_list = {id = nil, ap = 0}
|
|
|
+ --- Get info about the seleceted materias (equipped and in the list)
|
|
|
+ if self.header_position_row == 1 then
|
|
|
+ equip = Inventory.ITEM_TYPE.WEAPON
|
|
|
+ if equip_slot + 1 > #(Game.Items[Characters[self.char_id].weapon.id].slots) then
|
|
|
+ print("BEEP No slot " .. tostring(equip_slot) .. " in current weapon.")
|
|
|
+ return 0
|
|
|
+ end
|
|
|
+ if Characters[self.char_id].weapon.materia[equip_slot] ~= nil then
|
|
|
+ materia_equip = Characters[self.char_id].weapon.materia[equip_slot]
|
|
|
+ end
|
|
|
+ elseif self.header_position_row == 2 then
|
|
|
+ equip = Inventory.ITEM_TYPE.ARMOR
|
|
|
+ if equip_slot + 1 > #(Game.Items[Characters[self.char_id].armor.id].slots) then
|
|
|
+ print("BEEP No slot " .. tostring(equip_slot) .. " in current armor.")
|
|
|
+ return 0
|
|
|
+ end
|
|
|
+ if Characters[self.char_id].armor.materia[equip_slot] ~= nil then
|
|
|
+ materia_equip = Characters[self.char_id].armor.materia[equip_slot]
|
|
|
+ end
|
|
|
+ end
|
|
|
+ if Materia[list_pos] ~= nil then
|
|
|
+ materia_list = Materia[list_pos]
|
|
|
+ end
|
|
|
+ --- Equipped materia to the list (can be null)
|
|
|
+ Materia[list_pos] = materia_equip
|
|
|
+ if Materia[list_pos].id == nil then
|
|
|
+ Materia[list_pos] = nil
|
|
|
+ end
|
|
|
+ --- Materia from list to weapon or armor
|
|
|
+ if equip == Inventory.ITEM_TYPE.WEAPON then
|
|
|
+ Characters[self.char_id].weapon.materia[equip_slot] = materia_list
|
|
|
+ if Characters[self.char_id].weapon.materia[equip_slot].id == nil then
|
|
|
+ Characters[self.char_id].weapon.materia[equip_slot] = nil
|
|
|
+ end
|
|
|
+ elseif equip == Inventory.ITEM_TYPE.ARMOR then
|
|
|
+ Characters[self.char_id].armor.materia[equip_slot] = materia_list
|
|
|
+ if Characters[self.char_id].armor.materia[equip_slot].id == nil then
|
|
|
+ Characters[self.char_id].armor.materia[equip_slot] = nil
|
|
|
+ end
|
|
|
+ end
|
|
|
+ -- Reload character data and list.
|
|
|
+ self.populate_equip(self)
|
|
|
+ self.populate_list(self)
|
|
|
+ self.submenu_none(self)
|
|
|
+ end,
|
|
|
+
|
|
|
--- Hides the item menu and goes back to the main menu.
|
|
|
hide = function(self)
|
|
|
ui_manager:get_widget("MateriaMenu"):set_visible(false)
|