pane_Store = { name = "Store", agent = "ui_menu_paneStore" } Pane( pane_Store ) local mbRemoveStateActive = false local mbOwnsSeasonPass = false local mbPurchaseInProgress = false local function GetComingSoonDateString( num ) local year, month, day = EpisodeStatus_GetEpisodeReleaseDate( num ) if year == nil then return "??/??/????" else return month .. "/" .. day .. "/" .. year end end local function HasNoInteractivity() return EpisodeStatus_IsEpisodeInstalled( "102" ) and EpisodeStatus_IsEpisodeInstalled( "103" ) and EpisodeStatus_IsEpisodeInstalled( "104" ) and EpisodeStatus_IsEpisodeInstalled( "105" ) end local function UpdateLeftPanel() if Platform_IsPS3() and mbOwnsSeasonPass then AgentSetSelectable( "ui_menu_store_buttonFullSeason", false ) AgentSetProperty( "ui_menu_store_buttonFullSeason", "Text Dialog 2.0 Node Name", "textStoreButtonSeasonPurchased" ) AgentHide( "ui_menu_store_labelTheme", true ) end if AgentExists( "ui_menu_store_leftPanel" ) and ( not Platform_IsPS3() or pane_Store.mCurrentSelected ~= AgentFind( "ui_menu_store_buttonFullSeason" ) ) and pane_Store.mCurrentSelected ~= nil then local group = AgentGetProperty( pane_Store.mCurrentSelected, "Menu Control - Group" ) local texture = "ui_menu_store_leftPanel_WD" .. string.sub( group, -1 ) .. ".d3dtx" ShaderOverrideAllTextures( "ui_menu_store_leftPanel", texture ) end end local function UpdateEpisodeStatus( num ) if num == "101" then local button = pane_Store.mControlGroups[ "Episode 101" ][ "Button" ] AgentHide( button, IsRegistered() ) if Platform_IsPS3() then if EpisodeStatus_IsEpisodePurchased( "101" ) then AgentSetProperty( button, "Text Dialog 2.0 Node Name", "textEpisodeGet" ) else AgentSetProperty( button, "Text Dialog 2.0 Node Name", "textStoreButtonBuy" ) end end else local status = pane_Store.mControlGroups[ "Episode " .. num ][ "Status" ] local button = pane_Store.mControlGroups[ "Episode " .. num ][ "Button" ] if mbOwnsSeasonPass then if EpisodeStatus_IsEpisodeInstalled( num ) then Menu_Print( "pane_Store:UpdateEpisodeStatus", "seasonpass episode %s is installed", num ) AgentSetProperty( status, "Text Dialog 2.0 Node Name", "textStoreInstalled" ) AgentHide( button, true ) elseif EpisodeStatus_IsEpisodeAvailable( num ) then Menu_Print( "pane_Store:UpdateEpisodeStatus", "season pass episode %s is available", num ) AgentSetProperty( status, "Text Dialog 2.0 Node Name", "textStorePurchased" ) AgentHide( button, not IsRegistered() ) AgentSetProperty( button, "Text Dialog 2.0 Node Name", "textStoreButtonInstall" ) else Menu_Print( "pane_Store:UpdateEpisodeStatus", "season pass episode %s is coming soon", num ) AgentHide( button, true ) AgentSetProperty( status, "Text Dialog 2.0 Node Name", "textStoreComing" ) end elseif EpisodeStatus_IsEpisodeInstalled( num ) then Menu_Print( "pane_Store:UpdateEpisodeStatus", "episode %s is installed", num ) AgentSetProperty( status, "Text Dialog 2.0 Node Name", "textStoreInstalled" ) AgentHide( button, true ) elseif not EpisodeStatus_IsEpisodeAvailable( num ) then -- Coming soon! Menu_Print( "pane_Store:UpdateEpisodeStatus", "episode %s is coming soon", num ) AgentSetProperty( status, "Text Dialog 2.0 Node Name", "textStoreComing" ) AgentHide( button, true ) elseif EpisodeStatus_IsEpisodePurchased( num ) then Menu_Print( "pane_Store:UpdateEpisodeStatus", "episode %s is purchased", num ) AgentSetProperty( status, "Text Dialog 2.0 Node Name", "textStorePurchased" ) AgentHide( button, not IsRegistered() ) AgentSetProperty( button, "Text Dialog 2.0 Node Name", "textStoreButtonInstall" ) else Menu_Print( "pane_Store:UpdateEpisodeStatus", "episode %s is available", num ) AgentSetProperty( status, "Text Dialog 2.0 Node Name", "textStoreAvailable" ) AgentHide( button, not IsRegistered() ) AgentSetProperty( button, "Text Dialog 2.0 Node Name", "textStoreButtonBuy" ) end end end local function EditMode( num ) local button = pane_Store.mControlGroups[ "Episode " .. num ][ "Button" ] if mbRemoveStateActive then if EpisodeStatus_IsEpisodeInstalled( num ) then AgentSetProperty( button, "Text Color", { r = 1, g = 0, b = 0, a = 1 } ) AgentSetProperty( button, "Text Dialog 2.0 Node Name", "textStoreButtonRemove" ) AgentHide( button, false ) else AgentHide( button, true ) end else AgentSetProperty( button, "Text Color", { r = 0, g = 0, b = 0, a = 1 } ) UpdateEpisodeStatus( num ) end pane_Store.mSelectedIndex = 1 pane_Store:Focus() end local function IsContentRemovable() return false end function pane_Store:Focus() if Menu_UsingJoystick() then if Platform_IsPS3() and not IsRegistered() and not mbOwnsSeasonPass then if self.mCurrentSelected == nil then self:UpdateSelection( self.mCurrentSelected, nil ) self.mCurrentSelected = AgentFind( "ui_menu_store_buttonFullSeason" ) ChorePlayAndWait( AgentGetProperty( self.mCurrentSelected, "Menu Button - Chore Select" ) ) --else --self:UpdateSelection( nil, self.mIndexedControls[ 1 ] ) end else local i = self.mSelectedIndex for i = self.mSelectedIndex, #( self.mIndexedControls ) do if self:IsActiveControl( self.mIndexedControls[ i ] ) then self.mSelectedIndex = i Menu_Print( self.name .. ":Focus", "selected index is %d", i ) self:UpdateSelection( nil, self.mIndexedControls[ i ] ) break end end end end self.mbFocused = true --Menu_Refresh( MenuPanes ) end function pane_Store:Refresh() MenuLegend_Refresh() UpdateEpisodeStatus( "101" ) UpdateEpisodeStatus( "102" ) UpdateEpisodeStatus( "103" ) UpdateEpisodeStatus( "104" ) UpdateEpisodeStatus( "105" ) UpdateLeftPanel() if IsRegistered() and HasNoInteractivity() then MenuLegend_Configure( { "B" } ) MenuLegend_Refresh() end end function pane_Store:Open() MenuLegend_Attach( "ui_menu_store_legendAnchor" ) if IsEnginePS3() then print( "Calling IsDlcPurchased with key: " .. PurchaseKeys_GetPS3SeasonPassCode() ) --mbOwnsSeasonPass = EpisodeStatus_IsDlcPurchased( PurchaseKeys_GetPS3SeasonPassCode() ) mbOwnsSeasonPass = true local region = PlatformGetRegion() --[[ if region == "EUROPE" or region == "EUROPE_REST" then mbOwnsSeasonPass = mbOwnsSeasonPass or EpisodeStatus_IsDlcPurchased( "EP2026-NPEB00957_00-PTHEWALKIN000005" ) mbOwnsSeasonPass = mbOwnsSeasonPass or EpisodeStatus_IsDlcPurchased( "EP2026-NPEB00957_00-PTHEWALKIN000007" ) end ]] print( "mbOwnsSeasonPass is " .. tostring( mbOwnsSeasonPass ) ) end --[[ if IsEnginePS3() or IsEngineXbox360() then --on consoles refreshing episode states actually takes a server call local textNode = DlgNodeGetNextNode( "ui_menu.dlog", "txt_cms_updatingStatus" ) local text = DlgGetTextNodeText( "ui_menu.dlog", textNode[ "Node ID" ] ) EpisodeStatus_RefreshEpisodeStates( true, text ) else EpisodeStatus_RefreshEpisodeStates( true ) end]] if IsEngineXbox360() then EpisodeStatus_RefreshEpisodeInstalledState() end Yield() if Platform_IsPS3() then ShaderOverrideTexture( "ui_menu_store_leftPanel_selected", "ui_menu_store_leftPanel.d3dtx", "ui_menu_store_leftPanel_selected.d3dtx" ) end if IsContentRemovable() then MenuLegend_Configure( { "A", "B", "X" } ) MenuLegend_SetTextNode( "X", "textLegendEditEpisodes" ) elseif IsRegistered() and HasNoInteractivity() then MenuLegend_Configure( { "B" } ) else MenuLegend_Configure() end --self:Focus() self:Refresh() ChorePlay( "ui_menu_store_open.chore" ) ChorePlay( "ui_menu_store_leftpanel_open.chore" ) end function OnPurchaseComplete( success ) Menu_Print( "OnPurchaseComplete", "purchase success is %s", tostring( success ) ) if not success then InGameMessenger_ShowDialogOK( kInGameMessenger_Error_PurchaseFailed ) end local textNode = DlgNodeGetNextNode( "ui_menu.dlog", "txt_cms_updatingStatus" ) local text = DlgGetTextNodeText( "ui_menu.dlog", textNode[ "Node ID" ] ) EpisodeStatus_RefreshEpisodeStates( true, text ) if IsEnginePS3() then --mbOwnsSeasonPass = EpisodeStatus_IsDlcPurchased( PurchaseKeys_GetPS3SeasonPassCode() ) end pane_Store:Refresh() mbPurchaseInProgress = false end function OnDownloadComplete( success ) Menu_Print( "OnDownloadComplete", "purchase success is %s", tostring( success ) ) EpisodeStatus_RefreshEpisodeStates( true ) pane_Store:Refresh() end function pane_Store:OnMouseLUp( event ) local button = self.mCurrentSelected or event.agent Menu_Print( self.name .. ":OnMouseLUp", "button is %s", AgentGetName( button ) ) if self:IsActiveControl( button ) or AgentGetName( button ) == "ui_menu_store_buttonFullSeason" then local group = AgentGetProperty( button, "Menu Control - Group" ) local episode = string.sub( group, -3 ) if mbRemoveStateActive then else if not Platform_IsPS3() then if not PlatformIsConnectedToInternet() then MessageBox_Display( "ui_menu.dlog", "textGeneralRequiresInternet", "textGeneralOk", "" ) return end end Print( "episode is " .. episode ) if AgentGetName( button ) == "ui_menu_store_buttonFullSeason" then Menu_Print( self.name .. ":OnMouseLUp", "purchasing full season pass" ) mbPurchaseInProgress = true SetPurchaseCompletedCallback( "OnPurchaseComplete" ) if IsEnginePS3() then Print( "purchasing UP2026-NPUB30741_00-WD1CSN0000000000" ) PurchaseManager_PurchaseDLC( PurchaseKeys_GetPS3SeasonPassCode() ) elseif IsEngineXbox360() then Print( "purchasing 0x584111DE00000001" ) PurchaseManager_PurchaseDLC( "0x584111DE00000001" ) end -- Doesn't make any sense to have this here, if the episode is installed a button won't be shown. --elseif EpisodeStatus_IsEpisodeInstalled( episode ) then --ChorePlayOnAgent( AgentGetProperty( button, "Menu Button - Chore Activate" ), AgentGetName( button ) ) --ProjectSwitcher_SetAutoloadFlag( true ) --ProjectSwitcher_ChangeEpisode( episode ) elseif not IsRegistered() and episode ~= "101" then MessageBox_Display( "ui_menu.dlog", "textStoreUnlockFullGameWarning", "textGeneralOk", "" ) else ChorePlayOnAgent( AgentGetProperty( button, "Menu Button - Chore Activate" ), AgentGetName( button ) ) mbPurchaseInProgress = true --TODO: this should be rolled into the PurchaseManager, which should take in a purchase callback and a download callback --the problem is we are mixing string function names and function references, making the whole thing confusing as fuck --since we are shipping tomorrow, keep it simple for now -- So, for 101, don't rely on this callback because internally, it's a blocking call -- This should very much be moved into the purchase manager itself. if episode ~= "101" then SetPurchaseCompletedCallback( "OnPurchaseComplete" ) end PurchaseManager_PurchaseEpisode( episode, OnDownloadComplete ) if episode ~= "101" then while mbPurchaseInProgress do Yield() end end --maybe check PlatformIsConnectedToInternet to see if the user yoinked the cable here SystemMessenger_HideMessage() end end end end function pane_Store:OnX() if not IsContentRemovable() then return end mbRemoveStateActive = not mbRemoveStateActive EditMode( "102" ) EditMode( "103" ) EditMode( "104" ) EditMode( "105" ) end function pane_Store:OnUp() if Platform_IsPS3() and self.mCurrentSelected == AgentFind( "ui_menu_store_buttonFullSeason" ) then return end self:SelectNext( -1 ) end function pane_Store:OnDown() if Platform_IsPS3() and self.mCurrentSelected == AgentFind( "ui_menu_store_buttonFullSeason" ) then return end self:SelectNext( 1 ) end function pane_Store:OnLeft() if not Platform_IsPS3() or mbOwnsSeasonPass then--or self.mCurrentSelected == AgentFind( "ui_menu_store_buttonFullSeason" ) then return end if AgentGetProperty( "ui_menu_store_buttonFullSeason", "Game Selectable" ) then self:UpdateSelection( self.mCurrentSelected, nil ) self.mCurrentSelected = AgentFind( "ui_menu_store_buttonFullSeason" ) ChorePlayAndWait( AgentGetProperty( self.mCurrentSelected, "Menu Button - Chore Select" ) ) end end function pane_Store:OnRight() if not Platform_IsPS3() or AgentGetName( self.mCurrentSelected ) ~= "ui_menu_store_buttonFullSeason" then return end ChorePlayAndWait( AgentGetProperty( self.mCurrentSelected, "Menu Button - Chore Deselect" ) ) for i = 1, 5 do if not AgentIsHidden( self.mIndexedControls[ i ] ) then self:UpdateSelection( nil, self.mIndexedControls[ i ] ) break end end --self:Focus() --self:UpdateSelection( self.mCurrentSelected, nil ) --self.mCurrentSelected = AgentFind( "ui_menu_store_leftPanel_buttonFullSeason" ) end function pane_Store:SelectNext( delta ) if IsScriptObject( self.mCurrentSelected ) and Pane_IsIndexed( self.mCurrentSelected ) then local index = self.mSelectedIndex + delta local startIndex = index local neighbor = self.mIndexedControls[ index ] while neighbor and AgentIsHidden( neighbor ) do index = index + delta neighbor = self.mIndexedControls[ index ] if index == startIndex then break end end if neighbor and not AgentIsHidden( neighbor ) and AgentIsOnScreen( neighbor ) and AgentGetProperty( neighbor, "Game Selectable" ) then self:UpdateSelection( self.mCurrentSelected, neighbor ) self.mSelectedIndex = index Menu_SoundPlay( AgentGetProperty( neighbor, "Menu Button - Sound Select" ) ) else Menu_Print( self.name .. ":SelectNext", "no neighbor at index %d", self.mSelectedIndex + delta ) end end end