Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Questions about ListView in CE.

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
Dr.Disrespect
Grandmaster Cheater
Reputation: 3

Joined: 17 Feb 2016
Posts: 526

PostPosted: Tue Feb 28, 2017 10:42 am    Post subject: Questions about ListView in CE. Reply with quote

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 Very Happy

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. Very Happy
Back to top
View user's profile Send private message
DaSpamer
Grandmaster Cheater Supreme
Reputation: 52

Joined: 13 Sep 2011
Posts: 1578

PostPosted: Tue Feb 28, 2017 11:39 am    Post subject: This post has 2 review(s) Reply with quote

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.

_________________
HEY Hitler
Do you get lazy when making trainers?
Well no more!
My CETrainer will generate it for you in seconds, so you won't get lazy! Very Happy

http://forum.cheatengine.org/viewtopic.php?t=564919
Back to top
View user's profile Send private message
Dr.Disrespect
Grandmaster Cheater
Reputation: 3

Joined: 17 Feb 2016
Posts: 526

PostPosted: Tue Feb 28, 2017 11:57 am    Post subject: Reply with quote

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. Very Happy
Back to top
View user's profile Send private message
DaSpamer
Grandmaster Cheater Supreme
Reputation: 52

Joined: 13 Sep 2011
Posts: 1578

PostPosted: Tue Feb 28, 2017 9:41 pm    Post subject: Reply with quote

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
Code:
pairs()

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..

_________________
HEY Hitler
Do you get lazy when making trainers?
Well no more!
My CETrainer will generate it for you in seconds, so you won't get lazy! Very Happy

http://forum.cheatengine.org/viewtopic.php?t=564919


Last edited by DaSpamer on Tue Feb 28, 2017 9:48 pm; edited 1 time in total
Back to top
View user's profile Send private message
Dr.Disrespect
Grandmaster Cheater
Reputation: 3

Joined: 17 Feb 2016
Posts: 526

PostPosted: Tue Feb 28, 2017 9:45 pm    Post subject: Reply with quote

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
Code:
pairs()

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. Smile

_________________
**************

A simple example is better then ten links. Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites