SCALE_FONT_STORE_STRONGHOLD_LIST = 0.8
Store_stronghold_doc_handle = -1
local THREE_COUNT = 1
local NUKEPLANT = 2
local BROTHEL = 3
local POWDER = 4
local STRONGHOLD_POPULATE_TITLE = 0
local STRONGHOLD_POPULATE_FIXED = 1
local STRONGHOLD_POPULATE_REWARDS = 2
local STORE_STRONGHOLD_POPUP_X = 134
local STORE_STRONGHOLD_POPUP_Y = 170
local STORE_STRONGHOLD_INFO_RESPONDER = "store_stronghold_populate"
local Stronghold_image_data = {
[THREE_COUNT] = { "ui_stronghold_3count_02", "ui_stronghold_3count_02", "ui_stronghold_3count_03" },
[NUKEPLANT] = { "ui_stronghold_nuke_02", "ui_stronghold_nuke_02", "ui_stronghold_nuke_03" },
[BROTHEL] = { "ui_stronghold_bdsm_02", "ui_stronghold_bdsm_02", "ui_stronghold_bdsm_03" },
[POWDER] = { "ui_stronghold_3count_02", "ui_stronghold_3count_02", "ui_stronghold_3count_03" },
}
Store_stronghold_top_menu = {}
-- Hint bar and store header vdo's.
local Store_logo1
local Store_logo2
local Not_popup_grp
local Detail_grp
local Reward_image
local Store_stronghold_in_anim
local Rewards_data = {}
local Stronghold_id
local Stronghold_input_tracker = {}
local Stronghold_gang_h
local Store_stronghold_max_level = 0
local Store_stronghold_upgrades_ready = false
local Store_stronghold_kill_list_mouse = false
local REWARD_SPACING = 26
-- We used this as a reference to the current submenu we are building.
local Store_stronghold_building_menu = {}
-- keeps track of which selection we were on when leaving to a sub-document
local Store_stronghold_current_menu_selection = 1
local Stronghold_hint_bar_mouse_input_tracker
local Stronghold_full_screen_mouse_input_tracker
local Game_platform
local Store_title_name = nil
---------------------------------------------------------------------------
-- Initialize crib Store (Customization)
---------------------------------------------------------------------------
function store_stronghold_init()
Store_common_current_highlight_color = COLOR_STORE_REWARDS_PRIMARY
Game_platform = game_get_platform()
Store_stronghold_doc_handle = vint_document_find("store_stronghold")
local store_group = vint_object_find("screen_grp",0,Store_common_doc_handle)
vint_set_property(store_group,"visible",false)
-- Set up some callbacks for the common store script
Store_common_populate_list_cb = store_stronghold_populate_list
Store_common_exit_cb = store_stronghold_exit
-- Subscribe to the button presses we need, Input_tracker is created in store_common.lua
Input_tracker:subscribe(false)
vint_dataresponder_request(STORE_STRONGHOLD_INFO_RESPONDER, "store_stronghold_populate_title", 0, STRONGHOLD_POPULATE_TITLE)
vint_dataresponder_request(STORE_STRONGHOLD_INFO_RESPONDER, "store_stronghold_populate_data", 0, STRONGHOLD_POPULATE_FIXED)
vint_dataresponder_request(STORE_STRONGHOLD_INFO_RESPONDER, "store_stronghold_populate_rewards", 0, STRONGHOLD_POPULATE_REWARDS)
--Set background for "bg_saints"
bg_saints_set_type(BG_TYPE_STRONGHOLD)
--Set Mask
local cell_mask = Vdo_base_object:new("cell_mask", 0, Store_common_doc_handle)
cell_mask:set_visible(true)
cell_mask:set_property("mask", true)
cell_mask:set_property("screen_size",488,600)
--cell_mask:set_anchor(344,360)
--Setup Button Hints
local hint_data = {
{CTRL_MENU_BUTTON_B, "MENU_BACK"},
}
Store_common_hint_bar:set_hints(hint_data)
Store_common_hint_bar:set_visible(true)
if game_is_active_input_gamepad() then
local hint_rotate_data = {
{CTRL_BUTTON_RS, "STORE_ZOOM_ROTATE"},
}
Store_common_rotate_hint:set_hints(hint_rotate_data)
Store_common_rotate_hint:set_visible(false)
end
if Game_platform == "PC" then
Mouse_input_tracker:subscribe(false)
local bg_image_h = vint_object_find("stronghold_image")
Stronghold_hint_bar_mouse_input_tracker = Vdo_input_tracker:new()
Store_common_hint_bar:add_mouse_inputs("store_stronghold", Stronghold_hint_bar_mouse_input_tracker)
Stronghold_hint_bar_mouse_input_tracker:subscribe(true)
Stronghold_full_screen_mouse_input_tracker = Vdo_input_tracker:new()
Stronghold_full_screen_mouse_input_tracker:add_mouse_input("mouse_click", "store_stronghold_button_a", 0, bg_image_h)
Stronghold_full_screen_mouse_input_tracker:subscribe(false)
end
-- Set Store Header colors
Store_header:set_color(COLOR_STORE_REWARDS_PRIMARY, COLOR_STORE_REWARDS_SECONDARY, COLOR_STORE_REWARDS_TERTIARY)
Store_header:set_visible(true)
--Store_header:enable_price_respect(true)
Store_header:push_title( nil, Store_title_name )
Active_list:set_highlight_color(COLOR_STORE_REWARDS_PRIMARY, COLOR_STORE_REWARDS_SECONDARY)
-- Everything that is not in the popup so we can fade it when the popup is active
Not_popup_grp = Vdo_base_object:new("not_popup_grp", 0, Store_common_doc_handle)
Detail_grp = Vdo_base_object:new("detail_group",0,Store_stronghold_doc_handle)
-- Setup purchase popup
Store_common_popup:set_visible(false)
Store_common_popup:set_color(COLOR_STORE_REWARDS_PRIMARY, COLOR_STORE_REWARDS_SECONDARY, COLOR_STORE_REWARDS_TERTIARY)
Store_common_popup:set_size(STORE_COMMON_LIST_SIZE, (LIST_BUTTON_HEIGHT * 5) + (LIST_BUTTON_SPACE * 5))
Store_common_popup:set_anchor(STORE_STRONGHOLD_POPUP_X,STORE_STRONGHOLD_POPUP_Y)
vint_set_property(Crib_title,"visible",false)
-- Pass the table data to the megalist vdo.
Menu_data = Store_stronghold_top_menu
-- Pass the table data to the megalist vdo.
store_stronghold_populate_list(Menu_data, Store_stronghold_current_menu_selection)
-- set up flyby input tracker
Stronghold_input_tracker = Vdo_input_tracker:new()
Stronghold_input_tracker:add_input("select", "store_stronghold_button_a", 100)
Stronghold_gang_h = vint_object_find("stronghold_gang", 0, Store_stronghold_doc_handle)
local detail_anim_h = vint_object_find("stronghold_detail_anim")
vint_apply_start_values(detail_anim_h)
store_unlock_controls()
end
function store_stronghold_load_complete(stronghold_icon_name)
-- Jason, this changed to stronghold_icon_name, which is a string
local gang_name = ""
if stronghold_icon_name == "Crib_3Count" then
Stronghold_id = THREE_COUNT
gang_name = "HUMAN_TEAM_LUCHADORES"
elseif stronghold_icon_name == "Crib_BDSM" then
Stronghold_id = BROTHEL
gang_name = "HUMAN_TEAM_MORNINGSTAR"
elseif stronghold_icon_name == "Crib_Nuke" then
Stronghold_id = NUKEPLANT
gang_name = "HUMAN_TEAM_DECKERS"
else
Stronghold_id = THREE_COUNT
gang_name = "HUMAN_TEAM_LUCHADORES"
end
vint_set_property(Stronghold_gang_h, "visible", true)
vint_set_property(Stronghold_gang_h, "text_tag", gang_name)
local image = Stronghold_image_data[Stronghold_id]
game_peg_load_with_cb("store_stronghold_bg_anim", 3, image[1],image[2],image[3])
end
-- Cleanup function called on document unload.
--
function store_stronghold_cleanup()
--unload the full screen images
local image = Stronghold_image_data[Stronghold_id]
game_peg_unload(image[1])
game_peg_unload(image[2])
game_peg_unload(image[3])
-- Some things need to be cleaned up right away when a store doc is unloading, particular disabled inputs which have
-- callbacks to the script that is unloading.
store_common_cleanup_current_store()
end
-- Called when this interface becomes the top one on the stack again.
--
function store_stronghold_gained_focus()
Store_common_current_highlight_color = COLOR_STORE_REWARDS_PRIMARY
-- Reset our header
--Store_header:clear_titles()
-- make background so it covers up the world
bg_saints_set_background(false)
Input_tracker:subscribe(true)
store_stronghold_enable_mouse(true)
-- Need to clear out menu and menu stacks
store_common_stack_clear_menu()
store_common_stack_clear_id()
store_common_stack_clear_index()
-- Pass the table data to the megalist vdo.
Menu_data = Store_stronghold_top_menu
-- Pass the table data to the megalist vdo.
store_stronghold_populate_list(Menu_data, Store_stronghold_current_menu_selection)
end
function store_stronghold_bg_anim()
Store_stronghold_in_anim = Vdo_anim_object:new("store_stronghold_slide_in_anim", 0, Store_common_doc_handle)
local twn = vint_object_find("end_event_twn_1",0,Store_common_doc_handle)
--vint_set_property(twn,"start_time",0)
--vint_set_property(twn,"start_value",500,-6)
--vint_set_property(twn,"end_value",-30,-6)
twn = vint_object_find("strong_main_anchor_twn",0,Store_common_doc_handle)
--vint_set_property(twn,"start_value",500,-95)
--vint_set_property(twn,"end_value",-30,-95)
vint_apply_start_values(Store_stronghold_in_anim.handle)
Store_stronghold_in_anim:play()
local detail_anim_h = vint_object_find("stronghold_detail_anim")
lua_play_anim(detail_anim_h, 0, Store_stronghold_doc_handle)
vint_apply_start_values(detail_anim_h)
store_stronghold_refresh_rewards()
local store_group = vint_object_find("screen_grp",0,Store_common_doc_handle)
vint_set_property(store_group,"visible",true)
end
function store_lock_controls()
Input_tracker:subscribe(false)
store_stronghold_enable_mouse(false)
end
function store_unlock_controls()
Input_tracker:subscribe(true)
store_stronghold_enable_mouse(true)
end
-- Called when player requests exiting store.
--
function store_stronghold_exit()
--we may not have to do a destructive action popup since we are going back to the crib menu
--[[Store_common_popup:populate_list(Yes_no_choices, 1, STORE_COMMON_LIST_SIZE, 2)
Store_common_popup:set_title("MENU_TITLE_WARNING")
Store_common_popup:set_text("STORE_EXIT_WARNING_BODY")
Store_common_popup:nav_enable(true, "store_stronghold_exit_final", "store_stronghold_popup_nav")
Not_popup_grp:set_alpha(.5)]]
store_lock_controls()
-- clear out the price
Store_header:set_price(nil)
local anim = vint_object_find("stronghold_detail_out_anim",0,Store_stronghold_doc_handle)
local twn = vint_object_find("new_tween1_1",0,Store_stronghold_doc_handle)
--set up the end event to pop the screen when the anim is done
vint_set_property(twn,"end_event","store_stronghold_anim_complete")
lua_play_anim(anim,0)
anim = vint_object_find("store_stronghold_slide_in_anim",0,Store_common_doc_handle)
twn = vint_object_find("end_event_twn_1",0,Store_common_doc_handle)
--vint_set_property(twn,"start_time",0)
--vint_set_property(twn,"start_value",-30,-6)
--vint_set_property(twn,"end_value",500,-6)
twn = vint_object_find("strong_main_anchor_twn",0,Store_common_doc_handle)
--vint_set_property(twn,"start_value",-30,-95)
--vint_set_property(twn,"end_value",500,-95)
lua_play_anim(anim,0)
end
function store_stronghold_anim_complete()
--force a screen pop to the crib menu
pop_screen()
end
--[[
-- No need for second exit (JMH 4/1/2011)
--
-- Called when player has responded to store exit confirmation dialog.
--
-- event: input response from the player
--
function store_stronghold_exit_final(event)
Store_common_popup:nav_enable(false, nil, nil)
-- The user hit the B button and is exiting
-- This is redundant to selecting "No" in the list
if event == "back" then
game_UI_audio_play("UI_Main_Menu_Nav_Back")
Not_popup_grp:set_alpha(1)
Detail_grp:set_alpha(1)
store_stronghold_enable_mouse(true)
return
end
game_UI_audio_play("UI_Main_Menu_Select")
-- Did we select yes? This assumes yes is the first item
if Store_common_popup:get_selected_data() ~= 1 then
Not_popup_grp:set_alpha(1)
Detail_grp:set_alpha(1)
store_stronghold_enable_mouse(true)
return
end
--Not_popup_grp:set_alpha(0)
local exit_anim = vint_object_find("stronghold_anim_out")
lua_play_anim(exit_anim)
-- exit the interface
pop_screen()
end
]]
-- Populate the active megalist menu, and hide the previous menu
--
-- list_data: this table contains the data to populate the megalist
-- current_index: the current index in the menu that's selected
--
function store_stronghold_populate_list(list_data, current_index)
Active_list:draw_items(list_data, current_index, STORE_COMMON_LIST_SIZE, 10, SCALE_FONT_STORE_STRONGHOLD_LIST)
Active_list:set_visible(true)
if Game_platform == "PC" then
Mouse_input_tracker:remove_all()
Active_list:set_store("store_stronghold")
Active_list:add_mouse_inputs("store_common", Mouse_input_tracker)
Mouse_input_tracker:subscribe(true)
end
end
-- Clears the price and respect values from the store header.
--
function store_stronghold_header_revert(menu_data)
Store_header:set_price(nil)
Store_header:set_respect(nil)
end
-- Handles navigation of any popups
function store_stronghold_popup_nav(event, value)
if event == "nav_up" then
Store_common_popup.list:move_cursor(-1)
elseif event == "nav_down" then
Store_common_popup.list:move_cursor(1)
elseif event == "mouse_move" then
-- value contains the target_handle in this case
local new_index = Store_common_popup.list:get_button_index(value)
if new_index ~= 0 then
Store_common_popup.list:set_selection(new_index)
Store_common_popup.list:move_cursor(0, true)
end
else
--do nothing
end
end
-- Starts the flow of purchasing an upgrade
--
function store_stronghold_purchase_upgrade()
--get the current highlight index
local current_item = Active_list:get_selection()
Store_stronghold_current_menu_selection = current_item
--make a shortcut to the main data table
local data = Store_stronghold_top_menu[current_item]
if current_item > Store_stronghold_max_level + 1 then
Input_tracker:subscribe(false)
Store_common_popup:populate_list(Ok_choice, 1, STORE_COMMON_LIST_SIZE, 1)
Store_common_popup:set_title("MENU_TITLE_NOTICE")
Store_common_popup:set_text("MENU_STRONGHOLD_PREVIOUS_UPGRADE")
Store_common_popup:nav_enable(true, "store_stronghold_fail_msg", "store_stronghold_popup_nav")
Not_popup_grp:set_alpha(.5)
Detail_grp:set_alpha(.5)
store_stronghold_enable_mouse(false)
return
elseif Store_common_player_cash >= data.price and data.equipped == false then
local insert = { [0] = data.label, [1] = format_cash(data.price) }
local body = vint_insert_values_in_string("VCUST_PURCHASE_PROMPT", insert)
local heading = "MENU_TITLE_CONFIRM"
Input_tracker:subscribe(false)
Store_common_popup:populate_list(Yes_no_choices, 1, STORE_COMMON_LIST_SIZE, 2)
Store_common_popup:set_title(heading)
Store_common_popup:set_text(body)
Store_common_popup:nav_enable(true, "store_stronghold_upgrade_confirm", "store_stronghold_popup_nav")
Not_popup_grp:set_alpha(.5)
Detail_grp:set_alpha(.5)
store_stronghold_enable_mouse(false)
elseif not data.is_purchased then
Input_tracker:subscribe(false)
Store_common_popup:populate_list(Ok_choice, 1, STORE_COMMON_LIST_SIZE, 1)
Store_common_popup:set_title("MENU_TITLE_NOTICE")
Store_common_popup:set_text("HUD_SHOP_INSUFFICIENT_FUNDS")
Store_common_popup:nav_enable(true, "store_stronghold_fail_msg", "store_stronghold_popup_nav")
Not_popup_grp:set_alpha(.5)
Detail_grp:set_alpha(.5)
store_stronghold_enable_mouse(false)
end
end
function store_stronghold_fail_msg(event)
Store_common_popup:nav_enable(false, nil, nil)
Not_popup_grp:set_alpha(1)
Detail_grp:set_alpha(1)
game_UI_audio_play("UI_Main_Menu_Select")
store_stronghold_enable_mouse(true)
Input_tracker:subscribe(true)
end
function store_stronghold_upgrade_confirm(event)
Store_common_popup:nav_enable(false, nil, nil)
Not_popup_grp:set_alpha(1)
Detail_grp:set_alpha(1)
store_stronghold_enable_mouse(true)
Input_tracker:subscribe(true)
-- The user hit the B button and is exiting
-- This is redundant to selecting "No" in the list
if event == "back" then
game_UI_audio_play("UI_Main_Menu_Nav_Back")
return
end
--game_UI_audio_play("UI_Main_Menu_Select")
-- Did we select yes? This assumes yes is the first item
if Store_common_popup:get_selected_data() ~= 1 then
return
end
game_UI_audio_play("UI_Buy_Building_Screen")
--get the current highlight index
local current_item = Active_list:get_selection()
--make a shortcut to the main data table
local data = Store_stronghold_top_menu[current_item]
Store_stronghold_max_level = Store_stronghold_max_level + 1
--SET THE UPGRADE AS OWNED IN SCRIPT
data.equipped = true
data.is_purchased = true
data.price = 0
Store_stronghold_kill_list_mouse = true
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(false)
end
--if Hint_bar_mouse_input_tracker ~= nil then
--Hint_bar_mouse_input_tracker:subscribe(false)
--end
if Store_stronghold_current_menu_selection < 3 then
Store_stronghold_current_menu_selection = Store_stronghold_current_menu_selection + 1
end
local exit_anim = Vdo_anim_object:new("store_stronghold_purchase_anim", 0, Store_common_doc_handle)
vint_apply_start_values(exit_anim.handle)
exit_anim:play()
exit_anim = vint_object_find("stronghold_anim_out", 0, Store_stronghold_doc_handle)
vint_apply_start_values(exit_anim)
lua_play_anim(exit_anim, 0, Store_stronghold_doc_handle)
--Store_common_hint_bar:set_visible(false)
bg_saints_stronghold_drop_out()
--subtract player cash
--do player upgrades immediately.
--NOTE: we will do reward screens after the flyby, but we need to ensure the rewards are given
-- then begin fade that precedes the flyby
store_stronghold_game_purchase_upgrade()
--It looks like the chunk swap are quick so we should not need to have a load screen.
store_stronghold_setup_flyby()
end
--C code calls this after the gun wipe is complete
--Camera flyby begins and input processing is enabled (A to cancel flyby)
function store_stronghold_wipe_complete()
--start custom input for continue
Stronghold_input_tracker:subscribe(true)
Stronghold_hint_bar_mouse_input_tracker:subscribe(true)
Stronghold_full_screen_mouse_input_tracker:subscribe(true)
--show the continue hint
local hint_data = {
{CTRL_MENU_BUTTON_A, "COMPLETION_CONTINUE"},
}
Store_common_hint_bar:set_hints(hint_data)
--local bg_group = vint_object_find("bg_group")
--vint_set_property(bg_group,"visible",false)
--kill the header and the list
Store_header:set_visible(false)
Active_list:set_visible(false)
vint_set_property(Stronghold_gang_h, "visible", false)
--show the large purchased text
local stronghold_purchased_h = vint_object_find("stronghold_purchased")
vint_set_property(stronghold_purchased_h, "visible", true)
local exit_anim = Vdo_anim_object:new("store_stronghold_purchase_anim", 0, Store_common_doc_handle)
vint_apply_start_values(exit_anim.handle)
local detail_anim_h = vint_object_find("stronghold_purchase_anim")
lua_play_anim(detail_anim_h)
local anim = vint_object_find("store_stronghold_slide_in_anim", 0, Store_common_doc_handle)
local twn = vint_object_find("end_event_twn_1", anim)
vint_set_property(twn, "start_time", 5.0)
vint_set_property(twn, "end_event", "store_stronghold_hints_done")
vint_apply_start_values(anim)
vint_apply_start_values(Store_stronghold_in_anim.handle)
bg_saints_animate()
Store_stronghold_in_anim:play()
end
function store_stronghold_setup_flyby()
--kill normal input
Input_tracker:subscribe(false)
end
function store_stronghold_hints_done()
Store_stronghold_upgrades_ready = true
local anim = vint_object_find("store_stronghold_slide_in_anim", 0, Store_common_doc_handle)
local twn = vint_object_find("end_event_twn_1", anim)
vint_set_property(twn, "start_time", 0)
vint_set_property(twn, "end_event", nil)
end
--This is called when we want to stop flyby
--After this is called, kick off awards
function store_stronghold_button_a()
if Store_stronghold_upgrades_ready then
Store_stronghold_upgrades_ready = false
Store_stronghold_kill_list_mouse = false
Stronghold_full_screen_mouse_input_tracker:subscribe(false)
if Mouse_input_tracker ~= nil then
Mouse_input_tracker:subscribe(true)
end
--if Hint_bar_mouse_input_tracker ~= nil then
-- Hint_bar_mouse_input_tracker:subscribe(true)
--end
-- reset input tracker
Stronghold_input_tracker:subscribe(false)
Input_tracker:subscribe(true)
store_stronghold_upgrade_end_flyby()
store_lock_controls()
--Don't want to reset stronghold purchase screens yet. We'll hide that change behind
--the reward screens.
end
end
--reset stronghold store UI while on rewards screen
function store_stronghold_mid_awards_reset()
--enable input tracking
Input_tracker:subscribe(true)
--RESET UI HERE.
--hide the large purchased text
local stronghold_purchased_h = vint_object_find("stronghold_purchased")
vint_set_property(stronghold_purchased_h,"visible",false)
local bg_group = vint_object_find("bg_group")
vint_set_property(bg_group,"alpha",1.0)
local stronghold_line = vint_object_find("stronghold_line")
vint_set_property(stronghold_line,"alpha",1.0)
vint_set_property(Stronghold_gang_h, "visible", true)
Store_header:set_visible(true)
Active_list:set_visible(true)
-- Pass the table data to the megalist vdo.
store_stronghold_populate_list(Menu_data, Store_stronghold_current_menu_selection)
store_stronghold_refresh_rewards()
--Store_header:clear_titles()
--Store_header:push_title( nil, Store_title_name )
--set the new image
local bg_image_h = vint_object_find("stronghold_image")
vint_set_property( bg_image_h, "image", Stronghold_image_data[Stronghold_id][Store_stronghold_current_menu_selection])
local hint_data = {
{CTRL_MENU_BUTTON_B, "MENU_BACK"},
}
Store_common_hint_bar:set_hints(hint_data)
store_unlock_controls()
end
-- Refreshes the rewards list based on the current highlight
--
function store_stronghold_refresh_rewards()
--get the current highlight index
local current_item = Active_list:get_selection()
--make a shortcut to the main data table
local data = Store_stronghold_top_menu[current_item]
--set the cost of the upgrade
if data.price <= 0 or data.is_purchased then
Store_header:set_price(nil)
else
Store_header:set_price(data.price)
end
local reward_text_h = vint_object_find("stronghold_reward_label_1")
vint_set_property(reward_text_h, "visible", false)
--check if we have set rewards before
--if so kill everything
if #Rewards_data > 0 then
for i = 1, #Rewards_data do
vint_object_destroy( Rewards_data[i] )
end
Rewards_data = {}
end
--draw the new rewards strings
for i = 1, #data.rewards do
Rewards_data[i] = vint_object_clone(reward_text_h)
vint_set_property(Rewards_data[i],"visible",true)
vint_set_property(Rewards_data[i], "text_tag", data.rewards[i])
local x, y = vint_get_property( Rewards_data[i], "anchor")
vint_set_property(Rewards_data[i], "anchor", x, y + (i * REWARD_SPACING))
end
--set the new title
local title_h = vint_object_find("stronghold_title")
vint_set_property(title_h, "text_tag", data.label)
local bg_image_h = vint_object_find("stronghold_image")
vint_set_property( bg_image_h, "image", Stronghold_image_data[Stronghold_id][current_item])
end
function store_stronghold_populate_title(title_text)
Store_title_name = title_text
end
function store_stronghold_populate_data(label, is_purchased, price)
-- label = string value for the button and title
-- is_purchased = bool for whether or not the stronghold upgrade has been purchased
-- price = price of the upgrade
-- rewards = table of strings for the rewards the player will get
local current_index = #Store_stronghold_top_menu + 1
Store_stronghold_top_menu[current_index] =
{ label = label,
type = TYPE_BUTTON,
on_select = store_stronghold_purchase_upgrade,
id = current_index,
is_purchased = is_purchased,
equipped = is_purchased,
owned = true,
price = price,
on_nav = store_stronghold_refresh_rewards,
num_rewards = 0,
rewards = {}
}
if Store_stronghold_top_menu[current_index].equipped == true then
Store_stronghold_max_level = current_index
end
end
function store_stronghold_populate_rewards(upgrade_level, reward_text)
-- valid upgrade level
upgrade_level = upgrade_level + 1
local cur_top_menu = Store_stronghold_top_menu[upgrade_level]
if cur_top_menu == nil or reward_text == nil then
return
end
cur_top_menu.num_rewards = cur_top_menu.num_rewards + 1
cur_top_menu.rewards[cur_top_menu.num_rewards] = reward_text
end
--Menu Options...
-- =====================================
-- Mouse Specific Functions
-- =====================================
function store_stronghold_enable_mouse(enable)
if Game_platform == "PC" and enable ~= nil then
if Mouse_input_tracker ~= 0 then
Mouse_input_tracker:subscribe(enable)
end
if Stronghold_hint_bar_mouse_input_tracker ~= nil then
Stronghold_hint_bar_mouse_input_tracker:subscribe(enable)
end
end
end
function store_stronghold_mouse_click(event, target_handle)
local hint_index = Store_common_hint_bar:get_hint_index(target_handle)
if hint_index ~= 0 then
if Store_stronghold_upgrades_ready then
store_stronghold_button_a()
return
end
store_common_button_b()
end
end
function store_stronghold_mouse_move(event, target_handle)
-- Reset all highlights
Store_common_hint_bar:set_highlight(0)
-- Check if the mouse is over the hint bar buttons
local hint_index = Store_common_hint_bar:get_hint_index(target_handle)
if hint_index ~= 0 then
Store_common_hint_bar:set_highlight(hint_index, Store_common_current_highlight_color)
return
end
-- Check if the mouse is over a button on the mega list
if Store_stronghold_kill_list_mouse == false then
local old_index = Active_list:get_selection()
local new_index = Active_list:get_button_index(target_handle)
if new_index ~= 0 and new_index ~= old_index then
Active_list:set_selection(new_index)
Active_list:move_cursor(0, true)
-- If the item has a callback for navigation, do it (such as putting clothes on)
local data_item = Active_list:return_selected_data()
if data_item.on_nav ~= nil then
data_item.on_nav(data_item)
end
return
end
end
end
function store_stronghold_mouse_scroll(event, target_handle, mouse_x, mouse_y, scroll_lines)
end
function store_stronghold_mouse_drag(event, target_handle, mouse_x, mouse_y)
end
function store_stronghold_mouse_drag_release(event, target_handle, mouse_x, mouse_y)
end