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 


Adding a background picture.

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Fluffer_Nutter
Advanced Cheater
Reputation: 0

Joined: 26 Feb 2015
Posts: 67

PostPosted: Thu Feb 26, 2015 5:26 pm    Post subject: Adding a background picture. Reply with quote

Hello. I have a Lua Script for a hack i am working on. I was wondering if i can add a background image to the trainer. I have been trying for a while now and just cant figure it out.

Thanks in advance!

Code:


REMOVED THANK YOU FOR THE HELP! SEE FINAL CODE BELOW.


Last edited by Fluffer_Nutter on Mon Jun 01, 2015 4:04 pm; edited 1 time in total
Back to top
View user's profile Send private message
panraven
Grandmaster Cheater
Reputation: 55

Joined: 01 Oct 2008
Posts: 942

PostPosted: Thu Feb 26, 2015 8:42 pm    Post subject: Reply with quote

Here CEImage1 is a image control loaded with a 181x181 *.jpg, but place outside the visible form UDF1.

The OnPaint callback of form UDF1 will be called whenever it need to paint how it should be draw. There the canvas of the form is draw with the bitmap object obtained from the CEImage1 control. So the image from the CEImage1 became/copied as the form background. It should be work similar with other control eg. button.

I don't know how to scale the bitmap yet.

Code:
local img = UDF1.CEImage1.getPicture().getBitmap()
UDF1.height=181
UDF1.width=181
UDF1.OnPaint = function(sender)
  local c = sender.getCanvas()
  c.draw(0,0,img)
end

UDF1.show()



ceform_bitmap.jpg
 Description:
ceform bitmap demo
 Filesize:  31.22 KB
 Viewed:  7752 Time(s)

ceform_bitmap.jpg


Back to top
View user's profile Send private message
Fluffer_Nutter
Advanced Cheater
Reputation: 0

Joined: 26 Feb 2015
Posts: 67

PostPosted: Thu Feb 26, 2015 9:25 pm    Post subject: Reply with quote

Hello Panraven.

Thank you for the reply.
I see that code calls to open a new CE forum. I already have the entire trainer codded in only Lua script. And not sure how to convert it into a forum so i can use your method.

I stripped the entire code so all it does is open a blank window. The only option I have seen in the code is to change the color but not add a picture. Here is the bare code that i execute from the Lua Script scree.

Code:
orange2="0x00F21200"
--------------
MainGUI     = {}
MainGUI[1]  = createForm(false)
---------------
-- Main GUI --
control_setSize(MainGUI[1], 425, 512)
-------------
setProperty(MainGUI[1] , "color", orange2)
-------------
form_show(MainGUI[1])


Or I might just not understand how to use your code inside of a Lua Forum Window.
Back to top
View user's profile Send private message
panraven
Grandmaster Cheater
Reputation: 55

Joined: 01 Oct 2008
Posts: 942

PostPosted: Thu Feb 26, 2015 10:11 pm    Post subject: Reply with quote

I make it a function and use TableFile:
Code:
function attachBackground(wc,tblFile)
  local p = createPicture()
  p.loadFromStream(findTableFile(tblFile).Stream)
  wc.OnPaint = function(sender)
    local c = sender.getCanvas()
    local bitmap = p.getBitmap()
    c.draw(0,0,bitmap)
  end
end
attachBackground(UDF1,[[soulhacker.png]])
UDF1.show()


Try from your Table menu add an image file, say abc.jpg

then in your code, this should attach abc.jpg as your form background:

Code:
attachBackground(MainGUI[1] ,[[abc.jpg]])



ceform_bitmap2.jpg
 Description:
demo 2
 Filesize:  72.28 KB
 Viewed:  7740 Time(s)

ceform_bitmap2.jpg


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