Skip to content

Commit

Permalink
Fix AutoUpdater available plugins filter + improve load performance
Browse files Browse the repository at this point in the history
  • Loading branch information
alyssonrpg committed Apr 9, 2024
1 parent 9b6404a commit 6a2ac44
Show file tree
Hide file tree
Showing 8 changed files with 156 additions and 138 deletions.
171 changes: 95 additions & 76 deletions Plugins/TablesDock/AutoUpdater/AutoUpdater/AutoUpdater.lfm
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
if updaterSheet.toLoad <= updaterSheet.loaded then
self.loader.visible = false;
self.downloadedPluginsList:sort();
self.downloadedPluginsList:reorganize();
end;
if myNode ~= nil then
Expand All @@ -101,46 +101,57 @@
-- Limpa os recordList e carrega a lista de plugins instaladados
local installed = Firecast.Plugins.getInstalledPlugins();
local nodesDownloaded = NDB.getChildNodes(updaterSheet.downloadedPluginsList);
for i=1, #nodesDownloaded, 1 do
NDB.deleteNode(nodesDownloaded[i]);
end;
local nodesInstalled = NDB.getChildNodes(updaterSheet.installedPluginsList);
for i=1, #nodesInstalled, 1 do
NDB.deleteNode(nodesInstalled[i]);
end;
local macros = NDB.getChildNodes(updaterSheet.macroList);
for i=1, #macros, 1 do
NDB.deleteNode(macros[i]);
end;
NDB.beginUpdate(updaterSheet);
tryFinally(
function()
local nodesDownloaded = NDB.getChildNodes(updaterSheet.downloadedPluginsList);
for i=1, #nodesDownloaded, 1 do
NDB.deleteNode(nodesDownloaded[i]);
end;
local nodesInstalled = NDB.getChildNodes(updaterSheet.installedPluginsList);
for i=1, #nodesInstalled, 1 do
NDB.deleteNode(nodesInstalled[i]);
end;
local macros = NDB.getChildNodes(updaterSheet.macroList);
for i=1, #macros, 1 do
NDB.deleteNode(macros[i]);
end;
-- Adiciona os plugins instalados a lista
for i=1, #installed, 1 do
local item = self.installedPluginsList:append();
item.name = installed[i].name;
item.moduleId = installed[i].moduleId;
item.author = installed[i].author;
item.version = installed[i].version;
item.enabled = true;
item.description = installed[i].description;
item.contact = installed[i].contact;
end;
-- Adiciona o nome das colunas as listas.
local item = self.installedPluginsList:append();
item.name = tryTranslate("name")
item.moduleId = tryTranslate("id")
item.author = tryTranslate("author")
item.version = tryTranslate("installed")
item.versionAvailable = tryTranslate("available")
item.enabled = false;
-- Adiciona os plugins instalados a lista
for i=1, #installed, 1 do
local item = self.installedPluginsList:append();
item.name = installed[i].name;
item.moduleId = installed[i].moduleId;
item.author = installed[i].author;
item.version = installed[i].version;
item.enabled = true;
item.description = installed[i].description;
item.contact = installed[i].contact;
end;
-- Adiciona o nome das colunas as listas.
local item = self.installedPluginsList:append();
item.name = tryTranslate("name")
item.moduleId = tryTranslate("id")
item.author = tryTranslate("author")
item.version = tryTranslate("installed")
item.versionAvailable = tryTranslate("available")
item.enabled = false;
local item = self.downloadedPluginsList:append();
item.name = tryTranslate("name")
item.moduleId = tryTranslate("id")
item.author = tryTranslate("author")
item.version = tryTranslate("installed")
item.enabled = false;
end,
function()
NDB.endUpdate(updaterSheet);
end);
local item = self.downloadedPluginsList:append();
item.name = tryTranslate("name")
item.moduleId = tryTranslate("id")
item.author = tryTranslate("author")
item.version = tryTranslate("installed")
item.enabled = false;
self.installedPluginsList:sort();
Expand All @@ -155,27 +166,31 @@
end;
local file = VHD.openFile("plugins.xml", "w");
file:copyFrom(stream, stream.size);
setTimeout(
function ()
file:close();
local import = NDB.load("plugins.xml");
file:close();
local import = NDB.load("plugins.xml");
local list = NDB.getChildNodes(import);
local list = NDB.getChildNodes(import);
updaterSheet.loaded = 0;
updaterSheet.toLoad = #list;
updaterSheet.loading = tryTranslate("loading") .. "0/" .. updaterSheet.toLoad;
NDB.beginUpdate(updaterSheet);
tryFinally(
function()
updaterSheet.loaded = 0;
updaterSheet.toLoad = #list;
updaterSheet.loading = tryTranslate("loading") .. "0/" .. updaterSheet.toLoad;
for i=1, #list, 1 do
-- Verifica se tem updates em cada plugin
verifyUpdate(list[i]);
end;
self.downloadedPluginsList:sort();
for i=1, #list, 1 do
-- Verifica se tem updates em cada plugin
verifyUpdate(list[i]);
end;
end,
function()
NDB.endUpdate(updaterSheet);
end);
end,
1000
);
self.downloadedPluginsList:reorganize();
end,
function (errorMsg)
-- esta função será chamada quando ocorrer algum erro no download.
Expand All @@ -196,28 +211,32 @@
end;
local file = VHD.openFile("macros.xml", "w");
file:copyFrom(stream, stream.size);
setTimeout(
function ()
file:close();
local import = NDB.load("macros.xml");
local list = NDB.getChildNodes(import);
for i=1, #list, 1 do
-- Adiciona cada macro a lista de macros
local macro = self.macroList:append()
if macro then
macro.name = list[i].name
macro.path = (list[i].path):gsub("%%20", " ")
macro.link = list[i].link
end
end;
file:close();
local import = NDB.load("macros.xml");
self.macroList:sort();
local list = NDB.getChildNodes(import);
NDB.beginUpdate(updaterSheet);
tryFinally(
function()
for i=1, #list, 1 do
-- Adiciona cada macro a lista de macros
local macro = self.macroList:append()
if macro then
macro.name = list[i].name
macro.path = (list[i].path):gsub("%%20", " ")
macro.link = list[i].link
end
end;
end,
function()
NDB.endUpdate(updaterSheet);
end);
end,
1000
);
self.macroList:sort();
end,
function (errorMsg)
-- esta função será chamada quando ocorrer algum erro no download.
Expand Down
103 changes: 54 additions & 49 deletions Plugins/TablesDock/AutoUpdater/AutoUpdater/Available.lfm
Original file line number Diff line number Diff line change
@@ -1,62 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<form name="frmAvailable" align="client">
<scrollBox align="client">
<edit align="top" height="25" field="filter" textPrompt="Filtro">
<event name="onChange">
--write(self.scope.node);
if self.scope.node == nil then return end;
<script>
local currentFilterArgument = "";

local function prepareStrForFilter(inputStr)
return string.lower(Utils.removerAcentos(inputStr));
end;

local function executeFilterNow()
currentFilterArgument = prepareStrForFilter(self.edtAvailableFilter.text);
self.downloadedPluginsList:reorganize();
end;

local function checkNeedExecuteFilter()
local newFilterArgument = prepareStrForFilter(self.edtAvailableFilter.text);

if newFilterArgument ~= currentFilterArgument then
executeFilterNow();
end;
end;
</script>

local nodes = NDB.getChildNodes(self.scope.node.downloadedPluginsList);
--local mesa = Firecast.getMesaDe(self);
--local login = mesa.meuJogador.login;
local filter = string.lower(Utils.removerAcentos(self.scope.node.filter));

-- Deixe todos visiveis
if filter == nil or filter == "" then
for i = 1, #nodes, 1 do
nodes[i].priority = 0;
--NDB.setPermission(nodes[i], "user", login, "read", "allow");
end;
-- Deixe apenas os matchs visiveis
else
for i = 1, #nodes, 1 do
local name = string.lower(Utils.removerAcentos(nodes[i].name));
local moduleId = string.lower(Utils.removerAcentos(nodes[i].moduleId));
local author = string.lower(Utils.removerAcentos(nodes[i].author));

if string.find(name, filter) or string.find(moduleId, filter) or string.find(author, filter) then
nodes[i].priority = 1;
--NDB.setPermission(nodes[i], "user", login, "read", "allow");
else
nodes[i].priority = -1;
--NDB.setPermission(nodes[i], "user", login, "read", "deny");
--showMessage(NDB.getPermission(nodes[i], "user", login, "read"));
end;
end;
end;

</event>
</edit>
<recordList align="client" field="downloadedPluginsList" name="downloadedPluginsList" templateForm="frmDownloadedPlugin">
<timer name="tmrFilter" interval="1000" onTimer="checkNeedExecuteFilter()"/>
<edit g="row" g-min-height="25" textPrompt="Filtro" name="edtAvailableFilter" onChange="executeFilterNow()"/>

<scrollBox g="row" g-vert-tile="true">
<gridRecordList g="row" g-vert-tile="true" field="downloadedPluginsList" name="downloadedPluginsList" templateForm="frmDownloadedPlugin"
filterFields="{'priority', 'name', 'moduleId', 'author'}">
<event name="onCompare">
if nodeA.enabled and nodeB.enabled then
if (tonumber(nodeA.priority) or 0) > (tonumber(nodeB.priority) or 0) then
if left.enabled and right.enabled then
if (tonumber(left.priority) or 0) > (tonumber(right.priority) or 0) then
return -1;
elseif (tonumber(nodeB.priority) or 0) > (tonumber(nodeA.priority) or 0) then
elseif (tonumber(right.priority) or 0) > (tonumber(left.priority) or 0) then
return 1;
else
return Utils.compareStringPtBr(nodeA.name, nodeB.name);
return Utils.compareStringPtBr(left.name, right.name);
end;
elseif nodeA.enabled then
elseif left.enabled then
return 1;
elseif nodeB.enabled then
elseif right.enabled then
return -1;
end;
</event>
</recordList>
<layout align="bottom" height="25">
<label align="left" width="350" field="selectedDataType"/>
<progressBar align="client" field="downloadProgress" margins="{left=5,right=5,top=5,bottom=5}" max="1.0"/>
</layout>
</event>

<event name="onFilter">
if (currentFilterArgument == nil) or (currentFilterArgument == "") then
return true;
end;

local name = prepareStrForFilter(node.name) or "";
local moduleId = prepareStrForFilter(node.moduleId) or "";
local author = prepareStrForFilter(node.author) or "";

return (name ~= "" and string.find(name, currentFilterArgument, 1, true)) or
(moduleId ~= "" and string.find(moduleId, currentFilterArgument, 1, true)) or
(author ~= "" and string.find(author, currentFilterArgument, 1, true));

</event>
</gridRecordList>
</scrollBox>

<layout g="row" g-cnt-horz-align="between" g-cnt-min-grid-width-ft="0.33">
<label g="block" g-vert-tile="true" g-min-height="25" width="350" field="selectedDataType"/>
<progressBar g="col" g-width="12" g-min-height="15" g-vert-tile="true" field="downloadProgress" margins="{left=5,right=5,top=5,bottom=5}" max="1.0"/>
</layout>
</form>
12 changes: 2 additions & 10 deletions Plugins/TablesDock/AutoUpdater/AutoUpdater/DownloadedPlugin.lfm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<form name="frmDownloadedPlugin" height="50" margins="{top=1}">
<form name="frmDownloadedPlugin" height="50" margins="{top=1}" g="row" g-min-height="50" cacheMode="time">
<script>
local function tryTranslate(text)
local trans = Locale.tryLang(text);
Expand Down Expand Up @@ -49,6 +49,7 @@
"checkForModification");
end
</script>

<rectangle align="client" color="#212121">
<label align="left" field="name" horzTextAlign="center" textTrimming="none" wordWrap="true" name="pluginName" hitTest="true"/>
<label align="left" field="moduleId" horzTextAlign="center" textTrimming="none" wordWrap="true" name="moduleId" hitTest="true"/>
Expand Down Expand Up @@ -102,13 +103,4 @@
self.author.hint = sheet.contact;
</event>
</dataLink>

<dataLink fields="{'priority'}">
<event name="onChange">
if sheet==nil then return end;

local rcl = self:findControlByName("downloadedPluginsList");
if rcl ~= nil then rcl:sort() end;
</event>
</dataLink>
</form>
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@

NDB.copy(item, sheet)

rcl:sort()
rcl:reorganize()

NDB.deleteNode(sheet);
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<popupForm name="autoupdaterPopup" formType="undefined" dataType="ambesek.autoupdater" title="Auto Updater" width="720" height ="300">
<popupForm name="autoupdaterPopup" formType="undefined" dataType="ambesek.autoupdater" title="Auto Updater" width="720" height ="480">
<import file="AutoUpdater.lfm"/>
<event name="onShow">
init();
Expand Down
Binary file modified Plugins/TablesDock/AutoUpdater/output/AutoUpdater.rpk
Binary file not shown.
2 changes: 2 additions & 0 deletions Plugins/TablesDock/AutoUpdater/sdk/rrpgGUI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1301,6 +1301,8 @@ gui.GridRecordList.eves["onGroupShow"] = "id, header";
gui.GridRecordList.eves["onGroupHide"] = "id, header";
gui.GridRecordList.eves["onEmptyState"] = "";
gui.GridRecordList.eves["onPagingStateChange"] = "";
gui.GridRecordList.eves["onBeginOrganization"] = "";
gui.GridRecordList.eves["onEndOrganization"] = "";

--[[ Objeto GridRecordListPgCtrl ]]--

Expand Down
2 changes: 1 addition & 1 deletion Plugins/plugins.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
</dataType>
</dataTypes>
</element>
<element id="Ambesek.Auto.Updater" name="Plugin Auto Updater" url="https://github.com/rrpgfirecast/firecast/blob/master/Plugins/TablesDock/AutoUpdater/output/AutoUpdater.rpk?raw=true" fileName="AutoUpdater.rpk" repositoryPath="TablesDock/AutoUpdater/" author="Ambesek" description="Verifica seus plugins e macros, e encontra quais tem atualizações disponíveis no git do firecast. Também permite acesso a plugins não instalados do git." version="1.2" compilationDate="02042024204512" compilationDigest="52b335778373c18b14c65f7b3e1e461fbfbf4572">
<element id="Ambesek.Auto.Updater" name="Plugin Auto Updater" url="https://github.com/rrpgfirecast/firecast/blob/master/Plugins/TablesDock/AutoUpdater/output/AutoUpdater.rpk?raw=true" fileName="AutoUpdater.rpk" repositoryPath="TablesDock/AutoUpdater/" author="Ambesek" description="Verifica seus plugins e macros, e encontra quais tem atualizações disponíveis no git do firecast. Também permite acesso a plugins não instalados do git." version="1.2" compilationDate="09042024150153" compilationDigest="0a9256dc0aec2b38d66c6be4d84fcceeea776f2e">
<info lang="pt-BR" name="Plugin Auto Updater" description="Verifica seus plugins e macros, e encontra quais tem atualizações disponíveis no git do firecast. Também permite acesso a plugins não instalados do git." author="Ambesek" site="http://pt-br.rpgmeister.wikia.com/wiki/Main_Page"/>
<info lang="en" description="Check your plugins and macros, and find which ones have updates available in Firecast git. It also allows access to not installed git plugins."/>
<dataTypes>
Expand Down

0 comments on commit 6a2ac44

Please sign in to comment.