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 


Is there a way to mark a CEImage by clicking on it?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Razi
Expert Cheater
Reputation: 1

Joined: 17 Jan 2018
Posts: 202

PostPosted: Tue Mar 19, 2019 3:52 pm    Post subject: Is there a way to mark a CEImage by clicking on it? Reply with quote

50 CEImages on the form. How to make that if clicked on one CEImage then it is highlighted, and others are not, like with radio buttons in RadioGroup? If clicked on other CEImage2 then only CEImage2 highlighted.
Or how to do, if we click on one of the CEImages, then CEImage Stretch property is true UDF1['CEImage'..1].Stretch = true, then other CEImages are not (Stretch = false) ? Or how to mark CEImage as if it is selected?
Code:
if CeImage1.Stretch = true then
CeImage2.Stretch = false
CeImage3.Stretch = false
CeImage4.Stretch = false
...
CeImage50.Stretch = false
end

How not to write this method 50 times?
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Wed Mar 20, 2019 5:52 am    Post subject: Reply with quote

Not sure what exactly you wanted, but below is a sample 'Image Preview' design using primitive way.

Code:
picturestbl = {
{pic='corroder.jpg'},
{pic='teaser_1.jpg'},
{pic='pict1.jpg'}
}

function hglight(sender)
 local x, y = getMousePos()
 f2.Left = x
 f2.Top = y
 f2.width = 300
 f2.height = 300
 f2.color = '0x87ceeb'
 f2.BorderStyle = 'bsNone'
 ImgCopy.left = 10
 ImgCopy.top = 10
 ImgCopy.width = 280
 ImgCopy.height = 280
 ImgCopy.stretch = true
 pname = sender.Name
 if sender.Name == pname then
 i = tonumber(string.sub(pname,-1))
 index = picturestbl[i]
 ImgCopy.Picture.loadFromStream(findTableFile(index.pic).Stream)
 selected = ImgCopy.Picture
 f2.show()
 end
end

function hgPanelDestroy()
 f2.hide()
end

f = createForm()
f.Width = 400
f.Height = 200
f.Position = 'poScreenCenter'
f.Color = '0xfffffff'
f.BorderStyle = 'bsToolWindow'
f.Caption = 'CRDR Test Image Viewer'

img1 = createImage(f)
img1.left = 5
img1.top = 5
img1.height = 190
img1.width = 130
img1.stretch = false
img1.Picture.loadFromStream(findTableFile('corroder.jpg').Stream)
img1.Name = 'img1'

img2 = createImage(f)
img2.left = img1.left + img1.width
img2.top = 5
img2.height = 190
img2.width = 130
img2.stretch = false
img2.Picture.loadFromStream(findTableFile('teaser_1.jpg').Stream)
img2.Name = 'img2'

img3 = createImage(f)
img3.left = img2.left + img2.width
img3.top = 5
img3.height = 190
img3.width = 130
img3.stretch = false
img3.Picture.loadFromStream(findTableFile('pict1.jpg').Stream)
img3.Name = 'img3'

f2 = createForm()
ImgCopy = createImage(f2)
f2.hide()

f.Show()

img1.onMouseEnter =  hglight
img2.onMouseEnter =  hglight
img3.onMouseEnter =  hglight
img1.onMouseLeave =  hgPanelDestroy
img2.onMouseLeave =  hgPanelDestroy
img3.onMouseLeave =  hgPanelDestroy



Capture.JPG
 Description:
Seem like this..
 Filesize:  43.78 KB
 Viewed:  7917 Time(s)

Capture.JPG



_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
Razi
Expert Cheater
Reputation: 1

Joined: 17 Jan 2018
Posts: 202

PostPosted: Wed Mar 20, 2019 9:04 am    Post subject: Reply with quote

I'm trying to make a Materia editor like in Final Fantasy 7. I want to make it so that when you click on one CEImage1, it will be highlighted with an orange square, when you click on CEImage2, it will be highlighted or marked with an orange square, as in this examples: screenshots 8.jpg, 9.jpg, 10.jpg
(CEImage can be marked with an orange square or a blue square, or it can be marked with a black frame or in some other way)
Each CEImage in my Form looks like the first screenshot 7.jpg.



7.JPG
 Description:
 Filesize:  1.08 KB
 Viewed:  7913 Time(s)

7.JPG



8.JPG
 Description:
 Filesize:  28.92 KB
 Viewed:  7913 Time(s)

8.JPG



9.JPG
 Description:
 Filesize:  6.37 KB
 Viewed:  7913 Time(s)

9.JPG



10.JPG
 Description:
 Filesize:  2.54 KB
 Viewed:  7914 Time(s)

10.JPG


Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Wed Mar 20, 2019 9:08 am    Post subject: Reply with quote

Easiest is using transparent property of the TImage class
It picks the bottom left pixel as transparent pixel and every pixel of that color will then be transparent.
Then just change the background color of the object the image is on (e.g a panel without border)
alternatively, have the image 1 pixel inside a panel, and then change the panel color so it will look like a frame around it

_________________
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
AylinCE
Grandmaster Cheater Supreme
Reputation: 30

Joined: 16 Feb 2017
Posts: 1227

PostPosted: Wed Mar 20, 2019 12:33 pm    Post subject: Reply with quote

(DarkByte) example:
(But if there are many pictures:
In each code, to give panel colors,
will replicate the existing code.)


Code:
form = createForm(true)
form.Position = poDesktopCenter
form.Width = 200
form.Height = 80

p1 = createPanel(form)
p1.Height = 36
p1.Left = 45
p1.Top = 15
p1.Width = 36
p1.Color = "0xF0F0F0"

p2 = createPanel(form)
p2.Height = 36
p2.Left = 81
p2.Top = 15
p2.Width = 36
p2.Color = "0xF0F0F0"

p3 = createPanel(form)
p3.Height = 36
p3.Left = 117
p3.Top = 15
p3.Width = 36
p3.Color = "0xF0F0F0"

i1 = createImage(p1)
i1.Height = 36
i1.Left = 0
i1.Top = 0
i1.Width = 36
int = getInternet()
local logostr=int.getURL("http://i65.tinypic.com/2vagu8l.png")
int.destroy ()
local ss=createStringStream(logostr)
i1.Picture.loadFromStream(ss)
ss.destroy()
i2 = createImage(p2)
i2.Height = 36
i2.Left = 0
i2.Top = 0
i2.Width = 36
int = getInternet()
local logostr=int.getURL("http://i65.tinypic.com/2vagu8l.png")
int.destroy ()
local ss=createStringStream(logostr)
i2.Picture.loadFromStream(ss)
ss.destroy()

i3 = createImage(p3)
i3.Height = 36
i3.Left = 0
i3.Top = 0
i3.Width = 36
int = getInternet()
local logostr=int.getURL("http://i65.tinypic.com/2vagu8l.png")
int.destroy ()
local ss=createStringStream(logostr)
i3.Picture.loadFromStream(ss)
ss.destroy()

-----------function----------
i1.OnClick = function()
p1.color="2714879"
p2.Color = "0xF0F0F0"
p3.Color = "0xF0F0F0"
end

i2.OnClick = function()
p2.color="2714879"
p1.Color = "0xF0F0F0"
p3.Color = "0xF0F0F0"
--p4
--p5
-- etc.
end

i3.OnClick = function()
p3.color="2714879"
p2.Color = "0xF0F0F0"
p1.Color = "0xF0F0F0"
end

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Razi
Expert Cheater
Reputation: 1

Joined: 17 Jan 2018
Posts: 202

PostPosted: Wed Mar 20, 2019 4:43 pm    Post subject: Reply with quote

Thanks for answer. I forgot to say that on the form I want to make a 144 CEImages.
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Wed Mar 20, 2019 8:22 pm    Post subject: This post has 1 review(s) Reply with quote

Try this :
Code:
---- Corroder tested to highlighted a picture when selected [21-03-2019]
form = createForm(true)
form.Position = poDesktopCenter
form.Width = 200
form.Height = 80

-- ================================================= Pictures Table Here
int_path='http://i65.tinypic.com/'
int_images={'2vagu8l', '2vagu8l','2vagu8l'}
imgstrs = {}
int = getInternet()
---- Set default color for hi-lighted image
in_color="2714879"
---- Set default space for first panel
local cleft=5
---- Assign variable for count counting how many images on Pictures Table
local i
---- Create Panel on Form with global name as 'p' + i = Pictures number
for i=1,#int_images do
  local panel_name='p'..i
  local p=createPanel(form)
  _G[panel_name]=p
  p.Top = 10
  p.Left = cleft
  p.Width = 42
  p.Color = form.Color
  cleft = cleft + 40
---- Assign a variable for captured Picture from internet
  local in_image
---- Add captured picture to temporary table
  if imgstrs[i] then
  in_image=imgstrs[i]
  else
---- Set captured pictures to each panels
  local p_image = createImage(p)
  in_image=int.getURL(int_path..int_images[i]..'.png')
  imgstrs[i]=in_image
  local ss=createStringStream(in_image)
  p_image.Picture.loadFromStream(ss)
---- Clearing memory
  ss.destroy()
---- Apply a function to hi-lighting picture bg when mouse enter on it
  p_image.OnMouseMove = function()
  p.Color = in_color
  end
---- Apply a function to normalizing picture bg when mouse leave on it
  p_image.OnMouseLeave = function()
  p.Color = form.Color
 end
 end
end
---- Close intenet connection
int.destroy ()
---- Show the form
form.show()

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
Razi
Expert Cheater
Reputation: 1

Joined: 17 Jan 2018
Posts: 202

PostPosted: Thu Mar 21, 2019 4:46 am    Post subject: Reply with quote

Since the form must have a 144 CEImages, it may be better to change the position of the CEPanel1? When clicked on CEImage1 then position of the CEPanel1 will be changed, but CEPanel1 covers up CEImages and they are not visible. Is it possible to make a transparent object in the form of a square or frame, which will not cover other CEImages when this object is above CEImages?
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Thu Mar 21, 2019 5:13 am    Post subject: Reply with quote

@razi : .....better to change the position of the CEPanel1 ?.
which script you used ?. My last code doesn't have object name CEPanel1.

if you have 144 images then also make 144 panels. Each image placed on one panel. Every image need set 'stretch = true', so when the mouse enters or leave one image to another image, it only changes panel color. No effect with images.

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
Razi
Expert Cheater
Reputation: 1

Joined: 17 Jan 2018
Posts: 202

PostPosted: Thu Mar 21, 2019 6:03 am    Post subject: Reply with quote

@Corroder: I created a new form for testing and put the CEPanel1 there. I thought it would be easier to create an object (for example: paintbox that looks like square frame) and only change its position when we click on different CEImages, as in the screenshot 10.jpg above.
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Thu Mar 21, 2019 7:13 am    Post subject: Reply with quote

Razi wrote:
@Corroder: I created a new form for testing and put the CEPanel1 there. I thought it would be easier to create an object (for example: paintbox that looks like square frame) and only change its position when we click on different CEImages, as in the screenshot 10.jpg above.


Ok, I see. Then you need test if possible to put CEPanel as image background when that panel moves from one image to another image. I imagine like this :

1. Create a Panel on your form (only one panel)
2. Create 2 images or more on your form with the same size
3. Put image no.1 on your panel (so now your panel as image background)
4. Then when mouse leave from image no.1 and enter to image no.2, this panel will adjust to image no.2 position

Is it right?

My Question :

1. What you do with image no.1 when mouse leave it ?.
2. What you do with image no.2 when panel position as same on it ?

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 30

Joined: 16 Feb 2017
Posts: 1227

PostPosted: Thu Mar 21, 2019 8:10 am    Post subject: This post has 1 review(s) Reply with quote

A little shorter and without the panel color.
But for each row: the form must have a secret confirmation picture.
Example: If you have 30 rows, you need 30 pieces of background confirmation.
This will give you: 144 + 30 Wink

Example:
Code:
form = createForm(true)
form.Position = poDesktopCenter
form.Width = 236
form.Height = 80


i4 = createImage(form)
i4.Height = 36
i4.Width = 36
i4.Left = 153
i4.Top = 15
i4.visible=false
i4.sendToBack()
int = getInternet()
local logostr=int.getURL("http://i67.tinypic.com/2q2e7aq.jpg")
int.destroy ()
local ss=createStringStream(logostr)
i4.Picture.loadFromStream(ss)
ss.destroy()

i1 = createImage(form)
i1.Height = 36
i1.Left = 45
i1.Top = 15
i1.Width = 36
i1.bringToFront()
int = getInternet()
local logostr=int.getURL("http://i65.tinypic.com/2vagu8l.png")
int.destroy ()
local ss=createStringStream(logostr)
i1.Picture.loadFromStream(ss)
ss.destroy()

i2 = createImage(form)
i2.Height = 36
i2.Left = 81
i2.Top = 15
i2.Width = 36
i2.bringToFront()
int = getInternet()
local logostr=int.getURL("http://i65.tinypic.com/2vagu8l.png")
int.destroy ()
local ss=createStringStream(logostr)
i2.Picture.loadFromStream(ss)
ss.destroy()

i3 = createImage(form)
i3.Height = 36
i3.Left = 117
i3.Top = 15
i3.Width = 36
i3.bringToFront()
int = getInternet()
local logostr=int.getURL("http://i65.tinypic.com/2vagu8l.png")
int.destroy ()
local ss=createStringStream(logostr)
i3.Picture.loadFromStream(ss)
ss.destroy()

-----------function----------
i1.OnClick = function()
i4.visible=true
i4.setPosition(i1.Left, i1.Top)
end

i2.OnClick = function()
i4.visible=true
i4.setPosition(i2.Left, i2.Top)
end

i3.OnClick = function()
i4.visible=true
i4.setPosition(i3.Left, i3.Top)
end


and UDF..:

Code:
UDF1.background1.visible=false
--UDF1.background1.sendToBack()

function CEImage1Click(sender)
UDF1.background1.visible=true
UDF1.background1.setPosition(UDF1.CEImage1.Left, UDF1.CEImage1.Top)
end

function CEImage2Click(sender)
UDF1.background1.visible=true
UDF1.background1.setPosition(UDF1.CEImage2.Left, UDF1.CEImage2.Top)
end


etc.

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Thu Mar 21, 2019 8:52 am    Post subject: Reply with quote

I just can't imagine you create 144 images one by one with name i1..i144 and make 144 functions for images onClick. Superb.. Shocked Shocked
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
Razi
Expert Cheater
Reputation: 1

Joined: 17 Jan 2018
Posts: 202

PostPosted: Thu Mar 21, 2019 9:39 am    Post subject: Reply with quote

Corroder wrote:
1. What you do with image no.1 when mouse leave it ?.
2. What you do with image no.2 when panel position as same on it ?

1. Nothing. No need to do anything on the movement of the mouse. Panel must change position only if we click on the different CEImages.
2. That's the problem, the panel with the CEImage1 on it, overlaps(covers up) the second CEImage2, and we can not click on it and can not see CEImage2, but we need to see CEImage2. CEImages are often different, they are not the same, because they often change, between linked and unlinked slots, it depends on the data in the game. If we click on the CEImage1 then read from address1, if we click on the CEImage2, then read from address2.
Code:
for x = 0, 143 do
  UDF1['CEImage'..1+x].onClick = function(sender1)
  UDF1['CEComboBox'..1].ItemIndex = readBytes(0x009E8664+x*4)
  UDF1['CEEdit'..1].Text = bAnd(0xFFFFFF, readInteger(0x009E8665+x*4))
  end
  end

It remains only to show the visual part, so that the user can see on which CEImage picture he is now, after mouse click. Only need to show that the currently selected CEImage is marked.
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Thu Mar 21, 2019 10:49 am    Post subject: Reply with quote

This is the short version for @Aylin script. Not using a panel.
In this sample, all pictures save as CE Table file (not from the internet).
Hope you get a better idea from this script below.


Code:
-- add your pictures image name here until 144 images, image type is png image
image_table={'pic001','pic002','pic003','pic004','pic005'}
imgstrs ={}

----- adjust your form size for 144 images
form = createForm(true)
form.Position = poDesktopCenter
form.Width = 236   
form.Height = 80
form.Caption = 'CRDR Hi-light'

hglight = createImage(form)
hglight.Height = 40
hglight.Width = 40
hglight.Left = 15
hglight.Top = 20
hglight.visible=false
hglight.sendToBack()
hglight.stretch=true
hglight.Picture.loadFromStream(findTableFile('hglight.jpg').Stream)

local cleft=15
local i
---- Create images on Form with global name as 'p' + i = Pictures number
for i=1,#image_table do
  local img_name='img'..i
  local img=createImage(form)
  _G[img_name]=img
  img.Top = 20
  img.Left = cleft
  img.Width = 40
  img.Height = 40
  img.stretch = true
  cleft = cleft + 40

---- Assign a variable for captured Picture from table file
  local in_image

---- Add captured picture to temporary table
  if imgstrs[i] then
  in_image=imgstrs[i]
  else

---- Set captured pictures to each panels
  img.Picture.loadFromStream(findTableFile(image_table[i]..'.png').Stream)
  imgstrs[i]=img
---- Apply a function to hi-lighting picture bg when mouse enter on it
  img.OnMouseMove = function()   ---- change to onClick if you wish to use mouse click
  hglight.visible=true
  hglight.setPosition(img.Left, img.Top)
  end
---- Apply a function to normalizing picture bg when mouse leave on it
  img.OnMouseLeave = function()
  hglight.visible=false
 end
 end
end

---- Show the form
form.show()



Hi-Light Selected Picture.JPG
 Description:
Will look like this
 Filesize:  15.97 KB
 Viewed:  7799 Time(s)

Hi-Light Selected Picture.JPG



_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
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 Lua Scripting All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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