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 


How do I customize the look of Buttons ect?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
LastExceed
Expert Cheater
Reputation: 1

Joined: 05 Nov 2014
Posts: 130

PostPosted: Wed Nov 04, 2015 10:19 am    Post subject: How do I customize the look of Buttons ect? Reply with quote

I don't know how it's called in lua, but in java there was "look and feel" which allowed you to pick a preset of graphics for UI elements or to create your own. Is it possible to customize them here too? if yes how? (sfmbe)
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Wed Nov 04, 2015 11:04 am    Post subject: Reply with quote

No (well, you could rip out the manifest from the exe and make the gui look like a windows 95 screen, but those are the two options)

if you want customizable buttons, you have to draw them yourself. (use the canvas and handle mousedown and mouseup as a click)

_________________
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
LastExceed
Expert Cheater
Reputation: 1

Joined: 05 Nov 2014
Posts: 130

PostPosted: Wed Nov 04, 2015 11:47 am    Post subject: Reply with quote

Dark Byte wrote:
No (well, you could rip out the manifest from the exe and make the gui look like a windows 95 screen, but those are the two options)

if you want customizable buttons, you have to draw them yourself. (use the canvas and handle mousedown and mouseup as a click)


I'm fine with 'drawing' them myself, but i didn't quite understand how to use the custom graphics. Can you explain that a little more precisely please?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Wed Nov 04, 2015 2:28 pm    Post subject: Reply with quote

here is a crappy button example.
Code:

f=createForm()
pb=createPaintBox(f)

--"button" code
down=false
pb.Width=100;
pb.Height=25;
pb.OnPaint=function (s)
  local buttontext="Click me"

  if down then
    s.Canvas.Brush.Color=0x00ff00
  else
    s.Canvas.Brush.Color=0xff0000
  end
  s.Canvas.fillRect(0,0,s.Width, s.Height)
  s.Canvas.Font.Color=0

  local tw=s.Canvas.getTextWidth(buttontext)
  local th=s.Canvas.getTextHeight(buttontext)
  local xpos=math.floor((s.width/2.0)-(tw/2.0))
  local ypos=math.floor((s.height/2.0)-(th/2.0))

  pb.Canvas.textOut(xpos,ypos,buttontext)
end

pb.OnMouseDown=function(s)
  down=true
  s.OnPaint(s)
end

pb.OnMouseUp=function(s)
  down=false
  s.OnPaint(s)
end

pb.OnClick=function(s)
  print("handle my click")
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
LastExceed
Expert Cheater
Reputation: 1

Joined: 05 Nov 2014
Posts: 130

PostPosted: Wed Nov 04, 2015 2:30 pm    Post subject: Reply with quote

Dark Byte wrote:
here is a crappy button example.
Code:

f=createForm()
pb=createPaintBox(f)

--"button" code
down=false
pb.Width=100;
pb.Height=25;
pb.OnPaint=function (s)
  local buttontext="Click me"

  if down then
    s.Canvas.Brush.Color=0x00ff00
  else
    s.Canvas.Brush.Color=0xff0000
  end
  s.Canvas.fillRect(0,0,s.Width, s.Height)
  s.Canvas.Font.Color=0

  local tw=s.Canvas.getTextWidth(buttontext)
  local th=s.Canvas.getTextHeight(buttontext)
  local xpos=math.floor((s.width/2.0)-(tw/2.0))
  local ypos=math.floor((s.height/2.0)-(th/2.0))

  pb.Canvas.textOut(xpos,ypos,buttontext)
end

pb.OnMouseDown=function(s)
  down=true
  s.OnPaint(s)
end

pb.OnMouseUp=function(s)
  down=false
  s.OnPaint(s)
end

pb.OnClick=function(s)
  print("handle my click")
end


so all i can do is change the color?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Wed Nov 04, 2015 2:44 pm    Post subject: Reply with quote

this is just an example. You can also draw bitmaps and other stuff, but the basis is the same. A paintbox that draws the image and mouse events that do 'special' things, like drawing a different bitmap

Look up the Canvas class

_________________
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
LastExceed
Expert Cheater
Reputation: 1

Joined: 05 Nov 2014
Posts: 130

PostPosted: Wed Nov 04, 2015 3:02 pm    Post subject: Reply with quote

Dark Byte wrote:
this is just an example. You can also draw bitmaps and other stuff, but the basis is the same. A paintbox that draws the image and mouse events that do 'special' things, like drawing a different bitmap

Look up the Canvas class


alright, thanks.
Back to top
View user's profile Send private message
DaSpamer
Grandmaster Cheater Supreme
Reputation: 52

Joined: 13 Sep 2011
Posts: 1578

PostPosted: Thu Dec 03, 2015 10:57 am    Post subject: Reply with quote

I make custom buttons by using the image class.
onMouseLeave = basic sprite
onMouseEnter = loading a different sprite into the image object

You may also add another sprite onMouseDown which will make the image look as if it was a button.

_________________
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
LastExceed
Expert Cheater
Reputation: 1

Joined: 05 Nov 2014
Posts: 130

PostPosted: Thu Dec 03, 2015 11:00 am    Post subject: Reply with quote

DaSpamer wrote:
I make custom buttons by using the image class.
onMouseLeave = basic sprite
onMouseEnter = loading a different sprite into the image object

You may also add another sprite onMouseDown which will make the image look as if it was a button.


So you simply use images as buttons that changes to a picture of a specific button state depending on your mouse actions?
Back to top
View user's profile Send private message
DaSpamer
Grandmaster Cheater Supreme
Reputation: 52

Joined: 13 Sep 2011
Posts: 1578

PostPosted: Sat Dec 05, 2015 9:13 am    Post subject: Reply with quote

Yes, exactly.
Once mouse is hovering, it'd change to different pic, when it's not, return to default, while mouse is holding change state to different pic and on release return to hovering state.
I prefer that method over drawing manually.

_________________
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
LastExceed
Expert Cheater
Reputation: 1

Joined: 05 Nov 2014
Posts: 130

PostPosted: Sat Dec 05, 2015 9:44 am    Post subject: Reply with quote

DaSpamer wrote:
Yes, exactly.
Once mouse is hovering, it'd change to different pic, when it's not, return to default, while mouse is holding change state to different pic and on release return to hovering state.
I prefer that method over drawing manually.


Sounds quite simple, thanks for the idea!
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