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 


Help me finish my listview please
Goto page 1, 2, 3, 4  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
happyreadygo
Advanced Cheater
Reputation: 1

Joined: 14 Sep 2011
Posts: 87

PostPosted: Sun Sep 30, 2012 2:01 am    Post subject: Help me finish my listview please Reply with quote

sorry to bother you again but I have no idea now.
I made a listview called CEListView1(CETrainer_CEListView1) by drag and drop in Form designer.
After that I assigned onChange event with my combobox to call an updatelistviewitem function.

the first time I called the function by changed the combobox , everything is ok , the listview1 displayed perfectly. It had 4 columns.
the problem is when I refreshed the listview by changed the combobox the second time . Now, the listview1 had 8 columns. And it keeps added more column everytime like 12,16,20..
everytime I called the function.

I only want 4 columns. I was using listbox_clear(listbox) but it did nothing in this case.

Code:
function updatelistviewitem()
        lv=CETrainer_CEListView1
        setProperty(lv, 'ViewStyle', 'vsReport') --non lua exported property but you can access it with this
        setProperty(lv, 'RowSelect', 'True')
        setProperty(lv, 'ReadOnly', 'True')
        lvc=listview_getColumns(lv)
        listview_clear(lv)

        column1=listcolumns_add(lvc)
        column2=listcolumns_add(lvc)
        column3=listcolumns_add(lvc)
        column4=listcolumns_add(lvc)

        listcolumn_setCaption(column1, 'Slot#')
        listcolumn_setCaption(column2, 'Category')
        listcolumn_setCaption(column3, 'Item name')
        listcolumn_setCaption(column4, 'Total')
        listcolumn_setWidth(column1,40)
        listcolumn_setWidth(column2,80)
        listcolumn_setWidth(column3,110)
        listcolumn_setWidth(column4,60)

        lvi=listview_getItems(lv);

        --row1=listitems_add(lvi)
        --listitem_setCaption(row1, 'Row 1'); --rw 1 column a
        --row1_subitems=listitem_getSubItems(row1) --returns a Strings object
        --strings_add(row1_subitems, 'r1_cb') --row 1 column b

        local row={}
        itemBaseAddress=0x00dc0234
        currentItemAddress=itemBaseAddress

        for i=1,320 do
            itemName,itemCategory,itemAmount=getItem(currentItemAddress)
            if  not itemName == [[-]] then
               itemName=itemName..i
            end
            row[i]=listitems_add(lvi)
            listitem_setCaption(row[i],i)
            row_subitems=listitem_getSubItems(row[i])
            strings_add(row_subitems,itemCategory)
            strings_add(row_subitems,itemName)
            strings_add(row_subitems,itemAmount)
            currentItemAddress=currentItemAddress+2
        end
end
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25296
Location: The netherlands

PostPosted: Sun Sep 30, 2012 3:37 am    Post subject: Reply with quote

You know you can just add the columns in the designer? (Just click on the 3 dots of the "columns" property (same for style etc...)

Anyhow, listview_clear() only removes the items from the list, not the columns (You'd have to use collection_delete() on each column of the ListColumns class object, but really, there are easier ways)

The easiest method is just add the columns once and never add them again

So, instead of having
Code:

        column1=listcolumns_add(lvc)
        column2=listcolumns_add(lvc)
        column3=listcolumns_add(lvc)
        column4=listcolumns_add(lvc)

inside the updatelistviewitem move it outside so it gets executed when the script runs (or put it in the form create)

But if you insist on adding it only when updated, add a variable that when set skips the adding of columns
e.g:
Code:

        if hasColumns~=true then
          column1=listcolumns_add(lvc)
          column2=listcolumns_add(lvc)
          column3=listcolumns_add(lvc)
          column4=listcolumns_add(lvc)
          hasColumns=true
       end

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
happyreadygo
Advanced Cheater
Reputation: 1

Joined: 14 Sep 2011
Posts: 87

PostPosted: Sun Sep 30, 2012 4:56 am    Post subject: Reply with quote

Thank you darkbyte
Dark Byte wrote:
You know you can just add the columns in the designer? (Just click on the 3 dots of the "columns" property (same for style etc...)


I don't know it before , That's very handy . but it not work in my case , There are
another function .updatelistviewmateria and updatelistviewitem are using the same listview.
so I have to add columns dynamically. It can't be fixed column.

Dark Byte wrote:

Anyhow, listview_clear() only removes the items from the list, not the columns (You'd have to use collection_delete() on each column of the ListColumns class object, but really, there are easier ways)

Collection_delete() seems to work in my case , I am browsing for more info about it , thank you.


**update**
finally,I have founded that collection_clear(lvc) solve my problem.

However , I have something I am not sure to ask.



If I want to update Items of CEComboBox2,CEComboBox3 and CEComboBox4(the one on the right side) everytime I change listview item. which event should I use?

I am thinking of using OnClick event of the CEListView1. But are there any better event in this case?

Can we use event of the listviewitem?

Thank you again
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25296
Location: The netherlands

PostPosted: Sun Sep 30, 2012 6:55 pm    Post subject: Reply with quote

For comboboxes I recommend onSelect (although it doesn't matter here as it's a readonly combobox so onChange will work too)

For selection of the listview just go with onclick and onKeyPress for now.
There is an internal selectionChange property, but it's not published and the code generator/lua interface doesn't know how to call that yet (I'll add this one for next version)

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
happyreadygo
Advanced Cheater
Reputation: 1

Joined: 14 Sep 2011
Posts: 87

PostPosted: Sun Sep 30, 2012 8:41 pm    Post subject: Reply with quote

Thank you again Very Happy
Back to top
View user's profile Send private message
happyreadygo
Advanced Cheater
Reputation: 1

Joined: 14 Sep 2011
Posts: 87

PostPosted: Tue Oct 02, 2012 7:20 am    Post subject: Reply with quote

When I select a listview item in the listview , the listview item got focus.(blue color which highlight the selected row in listview)

but When I click botton1 , The listview lost focus.

Code:
lvIndex=listview_getItemIndex(lv)


When I using this code , It shown that the listview still have an index of the listview item. Although, the listview item already lost focus.

Can we get the item to be focused again , after click botton1.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25296
Location: The netherlands

PostPosted: Tue Oct 02, 2012 8:21 am    Post subject: Reply with quote

Set the "HideSelection" property to false so that the selection stays visible when it loses focus
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
happyreadygo
Advanced Cheater
Reputation: 1

Joined: 14 Sep 2011
Posts: 87

PostPosted: Tue Oct 02, 2012 9:03 am    Post subject: Reply with quote

thank you dark byte Wink
Back to top
View user's profile Send private message
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Thu Jan 17, 2013 10:35 pm    Post subject: Reply with quote

Dark Byte wrote:
You know you can just add the columns in the designer? (Just click on the 3 dots of the "columns" property (same for style etc...)
...

This must be different in 6.2 because don't see a colums modify in the designer panel, items but no colums.

What I'm trying to do is to list the levels and required experience-1 to get to that level. Have labels at the top "Level", "Experience" (Readonly=true) then change the experience when a particular line is selected(or has focus?) not sure which is the appropriate way to go. Anyway have the experience as a param that is used to write to an AOB for the experience in the game. Syntax for the experience will be somewhat difficult as it is contained as usual backwards
Back to top
View user's profile Send private message Yahoo Messenger
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25296
Location: The netherlands

PostPosted: Fri Jan 18, 2013 3:35 am    Post subject: Reply with quote

Columns is under ColumnClick and above Constraints
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Fri Jan 18, 2013 3:44 pm    Post subject: Reply with quote

I must have a bad copy then, because the only items in the combo box above Constraints are
Color
CharCase
BorderSpacing
BidiMode
AutoSize
AutoSelect
AutoDropDown
AutoCompleteText
AutoComplete
ArrowKeysTraverseList
Anchors
Align
Back to top
View user's profile Send private message Yahoo Messenger
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25296
Location: The netherlands

PostPosted: Fri Jan 18, 2013 5:33 pm    Post subject: Reply with quote

a combobox doesn't have columns
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Fri Jan 18, 2013 6:35 pm    Post subject: Reply with quote

The comb boxes I have used(not CE of course) had colums selected with an KeyID that when selected showed the data associated with that KeyID.
However, when I added the list box, there wasn't a 3 dot "build" feature in the colums property, Color, Font, Hint and Items (I'm guessing this was the one you referring), had one.
You select 2 columns and give one a label of Level and the other a label of experience? Nope that didn't work.
Tried one column and put two values with comma seperator, they all listed but no lablels at the top. Then add values with code to populate??
Totally not understanding this one
Back to top
View user's profile Send private message Yahoo Messenger
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25296
Location: The netherlands

PostPosted: Fri Jan 18, 2013 6:48 pm    Post subject: Reply with quote

a combobox in cheat engine is just a list of strings that you can pull down and select from
you then check which itemindex is selected and act accordingly
e.g have a second table with itemindexes and the associated data

perhaps you mean the listview? (set to report style)

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Fri Jan 18, 2013 9:46 pm    Post subject: Reply with quote

Now that might work, thanks for the re-direct. It seems everytime I select something on the properties box I get error statements like access violation, improper filter etc.
Anyway finally got it to accept what was selected and looks like this. Now I want to add static values such as:
Level Experience
1 999
2 1999
etc
When a row of data is selected then the exp becomes a param used to update an AOB. Would something like this work?
for x, 20 do
ListItem(1,999)
ListItem(2,1999)
...
ListItem(20, 999999)
end;
Then on the OnClick event
set a variable equal to row selected exp and then code in a writeQword to a selected address?



CETListView.png
 Description:
 Filesize:  563.42 KB
 Viewed:  15643 Time(s)

CETListView.png


Back to top
View user's profile Send private message Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Goto page 1, 2, 3, 4  Next
Page 1 of 4

 
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