📄 stock.luac.lua
字号:
-- Decompiled using luadec 0.6 by sztupy (http://winmo.sztupy.hu)
-- Command line was: -l ;;;;;;0,0,12,27;;;46,50,55;;;;;;;0,0,47;;41;;;;0,4,13,17;;;;;0,40;;4,11,13; 3090435e_manila.luac
-- Couldnt decompile 24/103 and 15/65 properly, but semantically the file is the same as the original
-- Error was: original has R3 < K25, mine has K25 > R3. These conditions are the same.
-- The two places are shown as XXX in this script
trace("===stock.lua ===")
require("stock_svc")
require("hitfeedback")
require("InforUpdating")
require("common")
require("Stock_Thumbnail")
require("Stock_chart")
UserNoAutoDownload = false
_application.Store:SetIntValue(Lifetime_Application, "StockData.OnPressUpdate", 0)
OnChartLoadingTimeOut = function(l_1_0)
loading.Rotation.z = loading.Rotation.z - 36
if loading.Rotation.z < 0 then
loading.Rotation.z = loading.Rotation.z + 360
end
end
ShowChartLoadingIndicator = function()
trace("[Stock] Show Updating Indicator\n")
loading.Opacity:Interpolate(100, 5, 0, Interpolate_EaseInQuad, nil)
if ChartLoadingTimer == nil then
ChartLoadingTimer = timer(0.099990844726563)
ChartLoadingTimer.OnElapsed:connect(OnChartLoadingTimeOut)
else
ChartLoadingTimer:Start()
end
end
StopChartLoadingIndicator = function()
loading.Opacity:Interpolate(0, 5, 0, Interpolate_EaseInQuad, nil)
if ChartLoadingTimer ~= nil then
ChartLoadingTimer:Stop()
end
end
RoamingDialogReturned = function(l_4_0)
error_log = false
l_4_0.OnExit:disconnect(RoamingDialogReturned)
if l_4_0.Result.ExitType ~= DialogExitType_Cancel then
trace("Click OK")
UserRoamingOK = true
onPressUpdate()
else
trace("Click Cancel")
SetupTimeUpdator()
end
end
DialogReturned = function(l_5_0)
error_log = false
l_5_0.OnExit:disconnect(DialogReturned)
if l_5_0.Result.ExitType ~= DialogExitType_Cancel then
trace("[stock] Click OK")
onPressUpdate()
else
trace("[stock] Click Cancel")
UserNoAutoDownload = true
SetupTimeUpdator()
end
end
error_log = false
show_error = function(l_6_0, l_6_1)
trace("[stock] show_error() ")
if error_log == true then
return
end
error_log = true
local l_6_2 = URL("Manila://Confirmation.dialog")
l_6_2.Parameters:AddParameter("Title", l_6_0)
l_6_2.Parameters:AddParameter("ContentString", l_6_1)
local l_6_3 = _application.DialogManager:GetDialog(l_6_2)
l_6_3.OnExit:connect(function(l_1_0)
DialogReturned(l_1_0)
end)
l_6_3:Show()
end
Rightsoftkey = function()
onPressUpdate()
end
Rightsoftkey_Quote = function()
StockManager:SaveSearchResult()
_application.Navigation:Navigate(URL("Manila://inforwidget/stockadd/stockadd.page"), true)
end
Leftsoftkey = function()
if ThumbnailList:HasGenerator() and ThumbnailList:GetGenerator().SelectedIndex >= 0 then
if ThumbnailList:GetGenerator().Collection:GetCount() < 21 and ThumbnailList:GetGenerator().SelectedIndex == 0 then
StockManager:CancelAllRequests()
_application.Navigation:Navigate(URL("Manila://inforwidget/stockview/myportfolio.page"), true)
return
end
local l_9_0 = ThumbnailList:GetGenerator():GetItem(ThumbnailList:GetGenerator().SelectedIndex)
local l_9_1 = l_9_0.Namespace:FindName("Symbol")
local l_9_2 = string.byte(l_9_1.String, 1)
if l_9_2 == 94 then
StockManager:CancelAllRequests()
_application.Navigation:Navigate(URL("Manila://inforwidget/stockview/marketsummary.page"), true)
else
StockManager:CancelAllRequests()
_application.Navigation:Navigate(URL("Manila://inforwidget/stockview/myportfolio.page"), true)
end
end
end
ResetStatus = function()
UpdateTime.String = FormateTime(StockManager:GetPassThroughTime())
StopTimerUpdator()
StopHttpTimer()
StopChartTimer()
StockManager:CancelAllRequests()
StopChartLoadingIndicator()
end
HTTPTimeout = function()
trace("[Stock] HTTPTimeout()")
ResetStatus()
show_error(Locale:GetString("IDS_INFOR_ERROR_TITLE"), Locale:GetString("IDS_INFOR_CONNECTION_ERROR"))
end
StartHTTPRequestTimer = function()
trace("[Stock] StartHTTPRequestTimer()")
if HTTPTimer == nil then
HTTPTimer = timer(60)
HTTPTimer.OnElapsed:connect(HTTPTimeout)
HTTPTimer:Start()
else
HTTPTimer:Start()
end
end
TimerTimeout = function()
trace("TimerTimeout()")
UpdateTime.String = FormateTime(StockManager:GetPassThroughTime())
if autoDownloadOn and (StockManager:GetPassThroughTime() >= nInterval or StockManager:GetPassThroughTime() < 0) then
onPressUpdate()
end
end
SetupTimeUpdator = function()
trace("SetupTimeUpdator()")
remainTime = nInterval
if TimerUpdate == nil then
TimerUpdate = timer(60)
TimerUpdate.OnElapsed:connect(TimerTimeout)
TimerUpdate:Start()
else
TimerUpdate:Start()
end
end
StopTimerUpdator = function()
trace("StopTimerUpdator()!")
if TimerUpdate ~= nil then
TimerUpdate:Stop()
end
end
OnChartIsReady = function(l_16_0, l_16_1)
trace("[stock] OnChartIsReady()")
StopChartLoadingIndicator()
if UpdateTime.String ~= Locale:GetString("IDS_UPDATING") then
StopHttpTimer()
end
if l_16_0 == false then
ResetStatus()
show_error(Locale:GetString("IDS_INFOR_ERROR_TITLE"), Locale:GetString("IDS_INFOR_CONNECTION_ERROR"))
return
end
if l_16_1:len() == 0 then
trace("[stock] _symbol length is 0")
return
end
trace("[stock] chart is ready: " .. l_16_1)
local l_16_2 = StockChartListView:GetGenerator().SelectedIndex
trace("[stock] chart SelectedIndex=" .. l_16_2)
-- XXX --
if ThumbnailList:GetGenerator().SelectedIndex ~= 0 or ThumbnailList:GetGenerator().Collection:GetCount() >= 21 then
local gd = StockChartListView:GetGenerator():GetData(l_16_2)
trace("[stock] SelectedIndex=" .. gd.Symbol)
if gd.Symbol:upper() == l_16_1:upper() then
trace("[stock] GetChartFromFile")
local xxx = StockManager:GetChartFromFile(l_16_1, ChartFormat_CF_DAY, 1, ChartStyle_CS_BLUE)
if xxx ~= nil then
trace("[stock] ready to settexture")
local item = StockChartListView:GetGenerator():GetItem(l_16_2)
local chart = item.Namespace:FindName("Chart")
chart:SetTexture(xxx)
xxx:Clear()
chart._visible = true
chart = chart.Namespace:FindName("ChartGroup")
chart.Position:Interpolate(Vector3(chart.Position.x, 331, chart.Position.z), 10, 0, Interpolate_EaseOutQuad, nil)
chart.Opacity:Interpolate(100, 10, 0, Interpolate_EaseInQuad, nil)
end
end
end
SetupTimeUpdator()
end
first_time = true
updatechart = function(l_17_0, l_17_1, l_17_2)
trace("[stock] start to update chart: " .. l_17_0)
if first_time == true then
first_time = false
end
StartHTTPRequestTimer()
ShowChartLoadingIndicator()
StockManager:Chart(l_17_0, StockType_AllStocks, l_17_1, l_17_2, true)
end
ChartTimerTimeout = function()
trace("[stock] ChartTimerTimeout")
ChartTimer:Stop()
if ThumbnailList:HasGenerator() and ThumbnailList:GetGenerator().SelectedIndex >= 0 then
if ThumbnailList:GetGenerator().Collection:GetCount() < 21 and ThumbnailList:GetGenerator().SelectedIndex == 0 then
return
end
local l_18_0 = ThumbnailList:GetGenerator():GetData(ThumbnailList:GetGenerator().SelectedIndex)
if StockManager:IsChartNeedUpdate(l_18_0.Symbol, ChartFormat_CF_DAY, 1) then
onPressUpdate(nil, nil, true)
end
end
end
StartChartTimer = function()
if ChartTimer == nil then
ChartTimer = timer(2)
ChartTimer.OnElapsed:connect(ChartTimerTimeout)
ChartTimer:Start()
else
ChartTimer:Start()
end
end
StopChartTimer = function()
if ChartTimer ~= nil then
ChartTimer:Stop()
end
end
StopHttpTimer = function()
if HTTPTimer ~= nil then
HTTPTimer:Stop()
end
end
showchart = function(l_22_0)
local l_22_1 = l_22_0.Namespace:FindName("Symbol")
StopChartLoadingIndicator()
local l_22_2 = StockManager:GetChartFromFile(l_22_1.String, ChartFormat_CF_DAY, 1, ChartStyle_CS_BLUE)
local l_22_3 = l_22_0.Namespace:FindName("Chart")
l_22_3:SetTexture(l_22_2)
l_22_2:Clear()
l_22_3._visible = true
JustUpdate = _application.Store:GetIntValue(Lifetime_Application, "StockData.OnPressUpdate") == 1
if JustUpdate then
_application.Store:SetIntValue(Lifetime_Application, "StockData.OnPressUpdate", 0)
end
if not JustUpdate and autoDownloadOn then
StartChartTimer()
end
end
HandleVisibilityChanged = function()
if _application.Visibility == true then
UpdateTime.String = FormateTime(StockManager:GetPassThroughTime())
SetupTimeUpdator()
else
StopTimerUpdator()
end
end
OnQuoteComplete = function(l_24_0, l_24_1)
trace("[stock] OnQuoteComplete()")
StopHttpTimer()
UpdateTime.String = FormateTime(StockManager:GetPassThroughTime())
if l_24_0 == false then
ResetStatus()
show_error(Locale:GetString("IDS_INFOR_ERROR_TITLE"), Locale:GetString("IDS_INFOR_CONNECTION_ERROR"))
return
end
StockManager:Commit()
SetupTimeUpdator()
end
onPressUpdate = function(l_25_0, l_25_1, l_25_2)
trace("[stock] onPressUpdate")
if l_25_1 ~= nil then
l_25_1.value = true
end
if l_25_2 == nil and UpdateTime.String == Locale:GetString("IDS_UPDATING") then
trace("[stock] onPressUpdate return")
return
end
ResetStatus()
if not UserRoamingOK then
trace("no UserRoamingOK")
if StockManager:IsRoaming() == true and not DownloadWhenRoaming then
if error_log == true then
return
end
error_log = true
local url = URL("Manila://Confirmation.dialog")
url.Parameters:AddParameter("Title", Locale:GetString("IDS_ROAM_UPDATE_DLG_TITLE"))
url.Parameters:AddParameter("ContentString", Locale:GetString("IDS_ROAM_UPDATE_DLG_MSG"))
local dlg = _application.DialogManager:GetDialog(url)
dlg.OnExit:connect(function(l_1_0)
RoamingDialogReturned(l_1_0)
end)
dlg:Show()
return
end
end
UpdateTime.String = Locale:GetString("IDS_UPDATING")
StartHTTPRequestTimer()
ShowChartLoadingIndicator()
_application.Store:SetIntValue(Lifetime_Application, "StockData.OnPressUpdate", 1)
-- XXX --
if ThumbnailList:GetGenerator().SelectedIndex ~= 0 or (ThumbnailList:GetGenerator().Collection:GetCount() >= 21) then
local gg = ThumbnailList:GetGenerator():GetData(ThumbnailList:GetGenerator().SelectedIndex)
StockManager:Chart(gg.Symbol, StockType_AllStocks, ChartFormat_CF_DAY, 1, true)
end
StockManager:Update(StockType_AllStocks, true)
end
OnPressRelatedHitTarget = function(l_26_0)
HitTargetGroup:Press()
orgPressY = l_26_0._ymouse
end
OnReleaseRelatedHitTarget = function(l_27_0)
HitTargetGroup:Release()
if math.abs(orgPressY - l_27_0._ymouse) < 20 then
StockManager:CancelAllRequests()
if ThumbnailList:GetGenerator().SelectedIndex == 0 and ThumbnailList:GetGenerator().Collection:GetCount() ~= 21 then
OnPressScrubBarWhenNoStock()
else
local l_27_1 = ThumbnailList:GetGenerator():GetData(ThumbnailList:GetGenerator().SelectedIndex)
_application.Navigation:Navigate(URL("Manila://inforwidget/stockdetail/stockdetail.page?symbol=" .. l_27_1.Symbol), true)
end
end
end
OnReleaseOutsideRelatedHitTarget = function()
HitTargetGroup:Release()
end
OnPressScrubBarWhenNoStock = function()
local l_29_0 = StockManager:GetStockItemList(StockType_AllStocks)
StockManager:LoadSearchResult()
local l_29_1 = StockManager:GetStockItemList(StockType_Unknown)
local l_29_2 = SymbolCollection()
for i1 = 0, l_29_1:GetCount() - 1 do
local l_29_7 = l_29_1:GetItem(i1)
local l_29_8 = true
for i2 = 0, l_29_0:GetCount() - 1 do
local item = l_29_0:GetItem(i2)
if item.Symbol == l_29_7.Symbol then
l_29_8 = false
break
end
end
if l_29_8 then
l_29_2:AddItem(l_29_7.Symbol)
end
end
StockManager:DeleteChart(l_29_2)
l_29_1:DeleteAll()
StockManager:SaveSearchResult()
_application.Navigation:Navigate(URL("Manila://inforwidget/stockadd/stockadd.page"), true)
end
autoDownloadOn = _application.Store:GetIntValue(Lifetime_Permanent, "StockData.AutoDownloadOff") == 0
nInterval = _application.Store:GetIntValue(Lifetime_Permanent, "StockManagerAUMInterval")
DownloadWhenRoaming = _application.Store:GetIntValue(Lifetime_Permanent, "StockData.DownloadWhenRoaming") == 1
RedIsUP = _application.Store:GetIntValue(Lifetime_Permanent, "StockData.RedIsUP") == 1
NewAddedSymbol = _application.Store:GetStringValue(Lifetime_Application, "Stock.NewAddedSymbol")
StockManager = CStockManager(_application.Store)
mixStockList = StockManager:GetStockItemList(StockType_AllStocks)
subtitlebk._visible = false
UserRoamingOK = false
orgPressY = nil
HitTargetGroup = HitFeedback(Group3D)
HitTarget.onPress:connect(OnPressRelatedHitTarget)
HitTarget.onRelease:connect(OnReleaseRelatedHitTarget)
HitTarget.onReleaseOutside:connect(OnReleaseOutsideRelatedHitTarget)
StockManager.OnChartUpdateComplete:connect(OnChartIsReady)
StockManager.OnQuoteComplete:connect(OnQuoteComplete)
BuildChartListview(mixStockList, showchart)
BuildThumbnailList(mixStockList)
if mixStockList:GetCount() ~= 0 then
UpdateHitArea.onPress:connect(onPressUpdate)
UpdateTime.String = FormateTime(StockManager:GetPassThroughTime())
SetupTimeUpdator()
_application:SetLeftSoftkey(Softkey(Locale:GetString("IDS_UPDATENOW"), Rightsoftkey))
_application:SetRightSoftkey(Softkey(Locale:GetString("IDS_INFOR_VIEWALL"), Leftsoftkey))
else
_application:SetLeftSoftkey(Softkey("", nil))
_application:SetRightSoftkey(Softkey("", nil))
end
_application.OnVisibilityChanged:connect(HandleVisibilityChanged)
if NewAddedSymbol ~= nil and NewAddedSymbol:len() > 0 then
_application.Store:SetStringValue(Lifetime_Application, "Stock.NewAddedSymbol", "")
onPressUpdate()
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -