| 
			
				|  | Cheat Engine The Official Site of Cheat Engine
 
 
 |  
 
	
		| View previous topic :: View next topic |  
		| Author | Message |  
		| Corroder Grandmaster Cheater Supreme
 
  Reputation: 75 
 Joined: 10 Apr 2015
 Posts: 1668
 
 
 | 
			
				|  Posted: Thu Mar 02, 2017 8:42 am    Post subject: Menu Slider Using Panel and Timer |   |  
				| 
 |  
				| Hi there, 
 This is new topic but in connection to : http://forum.cheatengine.org/viewtopic.php?t=603236
 
 I've made a Menu Slider :
 
 
  	  | Code: |  	  | f = createForm(true) f.Width = 400
 f.Height = 300
 p = createPanel(f)
 p.Left = 0
 p.Width = 50
 p.Height = 300
 p.Color = clGray
 
 function showMenu()
 p.Width = 50
 a = 45
 while(a<155)
 do
 p.Width = a
 a = a+1
 end
 end
 
 function closeMenu()
 while(a>50)
 do
 p.Width = a
 a = a-1
 end
 end
 
 p.onMouseEnter = showMenu
 p.onMouseLeave =closeMenu
 | 
 
 Script above is work properly. But I want make it (show / close) more slower or smooth by adding timer function. I can do this easy in VB Net, like shown on attached image.
 How do that with lua ?
 
 Thanks
 
 Edit :
 On VB Net, Timer Interval = 1
 
 
 
 
	
		
	 
		| Description: | 
			
				| VB Net script for Menu Slider using Panel |  |  
		| Filesize: | 67.36 KB |  
		| Viewed: | 7720 Time(s) |  
		| 
  
 
 |  
 |  |  
		| Back to top |  |  
		|  |  
		| akumakuja28 Master Cheater
 
  Reputation: 16 
 Joined: 28 Jun 2015
 Posts: 432
 
 
 | 
			
				|  Posted: Thu Mar 02, 2017 9:24 am    Post subject: |   |  
				| 
 |  
				|  	  | Code: |  	  | f = createForm(true)
 f.Width = 400
 f.Height = 300
 f.Color = '0x00808080'
 
 p = createPanel(f)
 p.Left = 0
 p.Width = 50
 p.Height = 300
 p.Color = '0x00454545'
 
 
 --------------------------------------------------------------------------------
 
 
 Speed = 5
 Direction = ''
 PanelExpandSize = 155
 PanelBaseSize = 50
 
 
 function PanelPop()
 
 if Direction == 'out'
 then
 
 if p.Width >= PanelExpandSize
 then
 Timer.Enabled = false
 else
 p.Width = p.Width + Speed
 p.Color = p.Color + Speed
 end
 
 else  --- Direction == 'in'
 
 if p.Width <= PanelBaseSize
 then
 Timer.Enabled = false
 else
 p.Width = p.Width - Speed
 p.Color = p.Color - Speed
 end
 
 end
 
 end
 
 function showMenu()
 Direction = 'out'
 Timer.Enabled = true
 end
 
 function closeMenu()
 Direction = 'in'
 Timer.Enabled = true
 end
 
 Timer = createTimer(f)  -- create in Form
 Timer.Interval = 1   --- 1/1000 second
 Timer.Enabled = false
 Timer.OnTimer = PanelPop
 
 
 
 p.onMouseEnter = showMenu
 p.onMouseLeave = closeMenu
 
 
 
 | 
 
 
 
 
 Now my Question is where is DaSpammer to tell us how to do this in a canvas.
 
 
 
 It has some STRANGE mouseleave behavior tho. If ou leave the form to the left or bottom it stays open. STRANGE
 _________________
 
 |  |  
		| Back to top |  |  
		|  |  
		| daspamer Grandmaster Cheater Supreme
 
  Reputation: 54 
 Joined: 13 Sep 2011
 Posts: 1588
 
 
 | 
			
				|  Posted: Thu Mar 02, 2017 3:02 pm    Post subject: |   |  
				| 
 |  
				| Currently at work, tomorrow will write example, generally its as simple as the method yoube shown, the only difference is you have handle drawning along with it. _________________
 
 I'm rusty and getting older, help me re-learn lua. |  |  
		| Back to top |  |  
		|  |  
		| panraven Grandmaster Cheater
 
 ![]() Reputation: 62 
 Joined: 01 Oct 2008
 Posts: 958
 
 
 | 
			
				|  Posted: Sat Mar 04, 2017 6:49 am    Post subject: |   |  
				| 
 |  
				| Using a Tween module ?   
  	  | Code: |  	  | local frm = createForm()
 frm.Name = "TestAnim"
 frm.Width,frm.Height = 300,200
 frm.OnClose = function()return caFree end
 local pnl = createPanel(frm)
 pnl.Align,pnl.Width,pnl.Color = alLeft,20,0xff8888
 
 local tween = require'tween'
 --  https://github.com/kikito/tween.lua
 
 local wTween
 
 local timer = createTimer(pnl)
 timer.Interval = 10
 timer.OnTimer = function(tm)
 if wTween then
 local dt = tm.Interval / 1000.0
 if wTween:update(dt) then tm.Enabled = false ; wTween = nil ; end
 end
 end
 
 function open()
 wTween = tween.new(0.3, pnl, {Width=155}, 'outBounce')
 timer.Enabled = true              ---^ difference
 end
 function close()
 wTween = tween.new(0.9, pnl, {Width=20},  'outBounce')
 timer.Enabled = true              ---^ difference
 end
 
 pnl.OnMouseEnter, pnl.OnMouseLeave = open, close
 
 | 
 
 wTween:update(dt) return true when dt update the internal clock pass the duration.
 
 bye~
 _________________
 
 - Retarded. |  |  
		| Back to top |  |  
		|  |  
		| Corroder Grandmaster Cheater Supreme
 
  Reputation: 75 
 Joined: 10 Apr 2015
 Posts: 1668
 
 
 | 
			
				|  Posted: Sat Mar 04, 2017 7:26 am    Post subject: |   |  
				| 
 |  
				|  	  | akumakuja28 wrote: |  	  | to tell us how to do this in a canvas..... 
 It has some STRANGE mouseleave behavior tho. If ou leave the form to the left or bottom it stays open. STRANGE
 | 
 
 1. I tried drawing in canvas :
 
 
  	  | Code: |  	  | local f = createForm(true) f.Width = 150
 f.Height = 50
 f.Position = 'poScreenCenter'
 
 local bmp = createBitmap()
 bmp.Width = 120
 bmp.Height = 30
 bmp.Left = 15
 bmp.Top = 10
 bmp.Canvas.gradientFill(0,10,bmp.width,bmp.height,0x0090FF,0x00CCCC,1)   -- Shadow effect on foreground
 
 pbx = createPaintBox(f)
 pbx.Width = 120
 pbx.Height = 30
 pbx.Top=10
 pbx.Left=15
 
 Bitmap = createBitmap(pbx.Width, pbx.Height)
 Bitmap.TransparentColor = 0
 Bitmap.Transparent = true
 Bitmap.Canvas.Font.Name = 'Comic Sans MS'
 Bitmap.Canvas.Font.CharSet= 255;
 Bitmap.Canvas.Font.Color = 0xffff00
 Bitmap.Canvas.Brush.Color = 0xFF0000;
 Bitmap.Canvas.Brush.Style=0
 Bitmap.Canvas.Pen.Style=7
 Bitmap.Canvas.Pen.Mode=4
 
 local function updateBitM()
 Bitmap.Canvas.clear();
 Bitmap.Canvas.fillRect(0,0,pbx.Width,pbx.Height);
 Bitmap.Canvas.Draw(0,0, bmp)
 local t=createBitmap()
 t.Canvas.Brush.Color=0xffffff
 t.Canvas.Pen.Color=0xffffff
 t.transparent=true
 t.TransparentColor=0xffff00
 t.Width=120
 t.Height=20
 t.Top=10
 t.Left=15
 t.Canvas.Font.Name = 'Comic Sans MS'
 t.Canvas.Font.Style = 'fsBold'
 t.Canvas.Font.CharSet= 255
 t.Canvas.Font.Color = 0xffff00
 t.Canvas.Brush.Color = 0xFF0000
 t.Canvas.fillRect(0,0,pbx.Width, pbx.Height)   -- Like shadow effect
 local data = "Corroder"
 local width,height = t.Canvas.getTextWidth(data),Bitmap.Canvas.getTextHeight(data);
 t.Canvas.textOut(math.ceil((t.width-width)/2),math.ceil((t.height-height)/2),data);
 Bitmap.Canvas.Draw(0,0,t)   -- change 0,0 as coordinate to get effect
 t.destroy()
 end
 
 pbx.onPaint = function ()
 updateBitM()
 pbx.Canvas.clear()
 pbx.Canvas.draw(0,0,Bitmap);
 local r = pbx.Canvas.getClipRect();
 pbx.Canvas.drawWithMask(r.Left,r.Top,r.Right, r.Bottom,Bitmap,r.Left, r.Top,r.Right,r.Bottom)
 end
 
 pbx.onClick = function ()
 pbx.repaint()
 end
 
 | 
 
 
 2.  ...it has some STRANGE mouseleave behavior ...
 I am not get this STRANGE, your script just work properly. Thanks and appreciated for your kinds of help.
 Anyhow for some reason, I did panel menu slider without using timer.
 
 
 panraven bro : "Using a Tween module ?"
 Thanks for info and suggesting to use Tween.lua, but also for some reasons, specially I don't want use "require" and plan to make my launcher pad as stand alone CE Trainer, so I let the panel menu slider as original without using timer or any module.
 Anyhow, I have download Tween module from the link you've provided and will testing it for other project.
 
 Mean while, my test for CE game launcher pad almost finish. Just need adding "open hacks" event and functions and about how to force closing an opened process, I still not satisfied with this script :
 
 
  	  | Code: |  	  | function getProcessNameFromID(processId) local processName = nil
 local list = createStringlist()
 getProcesslist(list)
 for i = 0, list.Count-1 do
 local id, name = list.String[i]:match("(.*)-(.*)")
 if processId == tonumber(id, 16) then
 processName = name
 break
 end
 end
 return processName
 end
 
 function KillPro()
 local id = getOpenedProcessID()
 local name = getProcessNameFromID(id)
 if tostring(name) == "" then
 showMessage("Process not found...")
 return
 end
 os.execute("taskkill -im "..name)
 -- id.Destroy()
 -- name.Destroy()
 list.clear()
 UDF1.Label_Attach.Caption = "There are no processes have opened"
 UDF1.Label_Attach.Font.Color = '0x00E4FBFC'
 end
 
 | 
 
 with KiilPro function, it I will close opened process / task by CMD command. But in Cheat Engine Main Form, it's look still open and another case is Windows displaying CMD black (about 2 seconds) screen while executing "os.execute".  I tried use /c with os.execute to avoid black screen displaying, but not work.
 
 Next case is to add mouse hold event when click scrolling button for game icon area.
 My game launcher test as images attach..
 
 
 
 
	
		
	 
		| Description: |  |  
		| Filesize: | 78.18 KB |  
		| Viewed: | 7639 Time(s) |  
		| 
  
 
 |  
 
 
	
		
	 
		| Description: |  |  
		| Filesize: | 74.11 KB |  
		| Viewed: | 7639 Time(s) |  
		| 
  
 
 |  
 |  |  
		| Back to top |  |  
		|  |  
		|  |  
  
	| 
 
 | 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
 
 |  |