Skip to content

Commit

Permalink
Added filter bar to card list window
Browse files Browse the repository at this point in the history
  • Loading branch information
Gtaray committed Jun 3, 2023
1 parent 022f5aa commit 6629d50
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 23 deletions.
49 changes: 28 additions & 21 deletions deckbox/cardlist_viewer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,7 @@
<minimum width="300" height="400" />
<dynamic />
</sizelimits>
<script>
function onInit()
cards.setDatabaseNode(getDatabaseNode());
end
function setTitle(sTitle)
if (sTitle or "") == "" then
return;
end
title.setValue(string.format(Interface.getString("cardlist_title_formatted"), sTitle));
end
function setSource(sNodeName)
local sourcenode = getDatabaseNode().getChild(sNodeName);
if not sourcenode then
Debug.console("ERROR: cardlist_viewer.setSource(): " .. sNodeName .. " was not found.");
return
end

cards.setDatabaseNode(sourcenode);
end
</script>
<script file="deckbox/scripts/cardlist_viewer.lua" />
<sheetdata>
<windowtitlebar name="title">
<resource>cardlist_title</resource>
Expand All @@ -39,13 +20,39 @@
<anchored>
<top offset="60" />
<left offset="40" />
<bottom offset="-40"/>
<bottom offset="-70"/>
<right offset="-40"/>
</anchored>
<class>cardlist_viewer_item</class>
<columns width="105" fillwidth="true" />
<script>
function onFilter(item)
local sFilter = window.filter_name.getValue();

if sFilter == "" then
return true;
end

local sName = CardsManager.getCardName(item.getDatabaseNode());
return sName:upper():find(sFilter:upper(), 1, true);
end
</script>
</windowlist>

<filter name="filter_name">
<anchored height="20">
<bottom anchor="bottom" offset="-40" />
<right anchor="right" offset="-60" />
<left anchor="left" offset="60" />
</anchored>
<script>
function onValueChanged()
super.onValueChanged();
window.cards.applyFilter();
end
</script>
</filter>

<resize_partysheet />
<close_partysheet />
</sheetdata>
Expand Down
22 changes: 22 additions & 0 deletions deckbox/scripts/cardlist_viewer.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
local sFilter = "";

function onInit()
cards.setDatabaseNode(getDatabaseNode());
end

function setTitle(sTitle)
if (sTitle or "") == "" then
return;
end
title.setValue(string.format(Interface.getString("cardlist_title_formatted"), sTitle));
end

function setSource(sNodeName)
local sourcenode = getDatabaseNode().getChild(sNodeName);
if not sourcenode then
Debug.console("ERROR: cardlist_viewer.setSource(): " .. sNodeName .. " was not found.");
return
end

cards.setDatabaseNode(sourcenode);
end
4 changes: 2 additions & 2 deletions extension.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<root version="3.3" release="1.0">
<announcement text="Decked Out v2.1.2 by Saagael." icon="decked_out" font="emotefont" />
<announcement text="Decked Out v2.2.0 by Saagael." icon="decked_out" font="emotefont" />
<properties>
<name>Feature: Decked Out</name>
<version>2.1.2</version>
<version>2.2.0</version>
<author>Saagael</author>
<description>Adds decks of cards</description>
<loadorder>1000</loadorder>
Expand Down

0 comments on commit 6629d50

Please sign in to comment.