|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
Dr.Disrespect Grandmaster Cheater Reputation: 3
Joined: 17 Feb 2016 Posts: 526
|
Posted: Tue Feb 28, 2017 10:42 am Post subject: Questions about ListView in CE. |
|
|
First of all, I'm so glad the forum has come back online, I almost died when I thought it would be gone forever. #CEForLife
Then, my questions about ListView in CE are:
1. When multi-selection is enabled, how to get all the selected row index? Is it possible?
2. Since editing cells in ListView is not possible, how to pass data from a row to a newly created form for further editing besides using global variables?
3. How to sort the data before loading it into the ListView? Such as, setting SorColumn, SortDirection, SortType in Lua.
Thanks a lot.
_________________
**************
A simple example is better then ten links. |
|
Back to top |
|
|
DaSpamer Grandmaster Cheater Supreme Reputation: 52
Joined: 13 Sep 2011 Posts: 1578
|
Posted: Tue Feb 28, 2017 11:39 am Post subject: |
|
|
1. Loop list view items from 0 to max index and check if 'Selected' is set to true
Code: |
(...)
function trainer:getMultiSelect(sender)
local selection = {}; -- table that holds all selected items ids
for i=0,sender.Items.Count-1 do
if (sender.Selected[i]) then
selection[#selection+1] = i+1; -- i prefer indexes to start from 1 and not from 0...
end
end
return selection;
end |
2. 'Since editing cells in ListView is not possible...', you mean editing cells as if it were excel? use an edit box (if created after listvw, should be visible above it) or get user input
3. one way to sort data before you load it into the list view, is to store your data in a table and then using table.sort, afterwards parsing the table into your listview.
_________________
|
|
Back to top |
|
|
Dr.Disrespect Grandmaster Cheater Reputation: 3
Joined: 17 Feb 2016 Posts: 526
|
Posted: Tue Feb 28, 2017 11:57 am Post subject: |
|
|
DaSpamer wrote: | 1. Loop list view items from 0 to max index and check if 'Selected' is set to true
Code: |
(...)
function trainer:getMultiSelect(sender)
local selection = {}; -- table that holds all selected items ids
for i=0,sender.Items.Count-1 do
if (sender.Selected[i]) then
selection[#selection+1] = i+1; -- i prefer indexes to start from 1 and not from 0...
end
end
return selection;
end |
2. 'Since editing cells in ListView is not possible...', you mean editing cells as if it were excel? use an edit box (if created after listvw, should be visible above it) or get user input
3. one way to sort data before you load it into the list view, is to store your data in a table and then using table.sort, afterwards parsing the table into your listview. |
Thanks for the reply, that helped a lot.
A follow up question for 3:
I am not very familiar with Lua, so, if I have a simple data set:
Quote: |
John 100 80
Mary 90 70
|
The first number in each row is the hp of the player, the second one is the mana.
How do I put this data set in a table and sort them based on hp? Thanks a lot.
_________________
**************
A simple example is better then ten links. |
|
Back to top |
|
|
DaSpamer Grandmaster Cheater Supreme Reputation: 52
Joined: 13 Sep 2011 Posts: 1578
|
Posted: Tue Feb 28, 2017 9:41 pm Post subject: |
|
|
Here's an example
Code: | myTable = {}
table.insert(myTable,{name = "Mary", hp = 90, mana = 70});
myTable[#myTable+1] = {}
myTable[#myTable].name = "John"
myTable[#myTable].hp = 100
myTable[#myTable].mana = 80
-- print_r(myTable)
--
-- [1]=>Table{
-- [name]=>Mary
-- [mana]=>70
-- [hp]=>90
-- }
-- [2]=>Table{
-- [name]=>John
-- [mana]=>80
-- [hp]=>100
-- }
table.sort(myTable, function (a,b) return a.hp > b.hp end);
--print_r(myTable)
--
-- [1]=>Table{
-- [name]=>John
-- [mana]=>80
-- [hp]=>100
-- }
-- [2]=>Table{
-- [name]=>Mary
-- [mana]=>70
-- [hp]=>90
-- } |
of course you can always sort it the way you want, using
you can iterate over the whole table and fetch it up the way you want.
Lear tables and love them,
http://lua-users.org/wiki/TablesTutorial
http://lua-users.org/wiki/TableLibraryTutorial methods and such..
_________________
Last edited by DaSpamer on Tue Feb 28, 2017 9:48 pm; edited 1 time in total |
|
Back to top |
|
|
Dr.Disrespect Grandmaster Cheater Reputation: 3
Joined: 17 Feb 2016 Posts: 526
|
Posted: Tue Feb 28, 2017 9:45 pm Post subject: |
|
|
DaSpamer wrote: | Here's an example
Code: | myTable = {}
table.insert(myTable,{name = "Mary", hp = 90, mana = 70});
myTable[#myTable+1] = {}
myTable[#myTable].name = "John"
myTable[#myTable].hp = 100
myTable[#myTable].mana = 80
-- print_r(myTable)
--
-- [1]=>Table{
-- [name]=>Mary
-- [mana]=>70
-- [hp]=>90
-- }
-- [2]=>Table{
-- [name]=>John
-- [mana]=>80
-- [hp]=>100
-- }
table.sort(myTable, function (a,b) return a.hp > b.hp end);
--print_r(myTable)
--
-- [1]=>Table{
-- [name]=>John
-- [mana]=>80
-- [hp]=>100
-- }
-- [2]=>Table{
-- [name]=>Mary
-- [mana]=>70
-- [hp]=>90
-- } |
of course you can always sort it the way you want, using
you can iterate over the whole table and fetch it up the way you want. |
Thank you so much for the detailed example. Much appreciated.
_________________
**************
A simple example is better then ten links. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|