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 


Double Gauge Custom Progress Bar

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Mon Oct 19, 2020 2:07 am    Post subject: Double Gauge Custom Progress Bar Reply with quote

Interest to this topic:
https://forum.cheatengine.org/viewtopic.php?p=5766195#5766195

I try make a custom double gauge progress bar function using a paintbox.

The question is how to connect the gauge value and color to a progress value, i.e a track bar position, so the gauge value and color will follows the track bar position. I want make it as general function.


Code:
if f then f.destroy() end

f = createForm()
f.setSize(600,150)
f.Position = 'poScreenCenter'
f.Caption = 'Test Custom Progressbar'

pb = createPaintBox(f)
pb.setSize(580,80)
pb.setPosition(10,10)

tb = createTrackBar(f)
tb.setSize(580, 40)
tb.Left = 10
tb.Top = 100
tb.Min = 0
tb.Max = 100
tb.Step = 1
tb.Value = 0

function DrawDoubleGauge(s, BackgroundColor, BorderColor, Color1, Color2, Value1, Value2, MaxValue)
 local Width, Width1, Width2
 s.Canvas.Brush.Color = BackgroundColor
 s.Canvas.Pen.Color = BorderColor
 s.Canvas.Rect(0, 0, s.Width, s.Height)

 if MaxValue ~= 0 then
    Width = s.Width - 1
    Width1 = (Width * Value1) / MaxValue
    Width2 = (Width * Value2) / MaxValue
    s.Canvas.Brush.Color = Color2

    if math.abs(Value2) < math.abs(MaxValue) then
       s.Canvas.fillRect(1, 1, Width2, s.Height - 1)
       s.Canvas.Brush.Color = Color1

    if math.abs(Value1) < math.abs(Value2) then
       s.Canvas.gradientFill(1, 1, Width1, s.Height - 1, Color1, Color2, 1)
    end
    end
 end
end

pb.OnPaint = function()
 DrawDoubleGauge(pb, 16119285, 0, 7346457,    13850042, 60, 90, 100)
end

f.Show()


The custom progress bar trigger by OnPaint event.



Capture.JPG
 Description:
 Filesize:  25.45 KB
 Viewed:  981 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
Lynxz Gaming
Expert Cheater
Reputation: 4

Joined: 01 Jul 2017
Posts: 208
Location: help

PostPosted: Mon Oct 19, 2020 2:29 am    Post subject: Re: Double Gauge Custom Progress Bar Reply with quote

maybe not good as expected
Code:
if f then f.destroy() end

f = createForm()
f.setSize(600,150)
f.Position = 'poScreenCenter'
f.Caption = 'Test Custom Progressbar'

pb = createPaintBox(f)
pb.setSize(580,80)
pb.setPosition(10,10)

tb = createTrackBar(f)
tb.setSize(580, 40)
tb.Left = 10
tb.Top = 100
tb.Min = 0
tb.Max = 100
tb.Step = 1
tb.position = 0

function DrawDoubleGauge(s, BackgroundColor, BorderColor, Color1, Color2, Value1, Value2, MaxValue)
 local Width, Width1, Width2
 s.Canvas.Brush.Color = BackgroundColor
 s.Canvas.Pen.Color = BorderColor
 s.Canvas.Rect(0, 0, s.Width, s.Height)

 if MaxValue ~= 0 then
    Width = s.Width - 1
    Width1 = (Width * Value1) / MaxValue
    Width2 = (Width * Value2) / MaxValue
    s.Canvas.Brush.Color = Color2

    if math.abs(Value2) < math.abs(MaxValue) then
       s.Canvas.fillRect(1, 1, Width2, s.Height - 1)
       s.Canvas.Brush.Color = Color1

    if math.abs(Value1) < math.abs(Value2) then
       s.Canvas.gradientFill(1, 1, Width1, s.Height - 1, Color1, Color2, 1)
    end
    end
 end
end

pb.OnPaint = function()
 DrawDoubleGauge(pb, 16119285, 0, 7346457,    13850042, 60, 90, 100)
end

local down = false

pb.OnMouseDown = function()
 down = true
end
pb.OnMouseUp = function()
 down = false
end

pb.OnMouseMove = function(sender,x,y)
 if down then
  DrawDoubleGauge(pb, 16119285, 0, 7346457,    13850042, 60, x/pb.Width*100, 100)
  tb.position = x/pb.Width*100
 end
end

tb.OnChange = function()
  DrawDoubleGauge(pb, 16119285, 0, 7346457,    13850042, 60, tb.position, 100)
end

f.Show()

_________________
my english is bad
discord : rynx#9828
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Mon Oct 19, 2020 5:45 am    Post subject: Reply with quote

I think this function is enough, without mouse events and the track bar here made to test the progress bar logic.

Code:
tb.OnChange = function()
  DrawDoubleGauge(pb, 16119285, 0, 7346457,    13850042, 60, tb.position, 100)
end


Now, after find the logic, we able to implementing the progress bar logic to a game value, i.e player HP or others, etc, something like this:

Code:
DrawDoubleGauge(pb, 16119285, 0, 7346457,  13850042, currentHP, criticalHP, playerMaxHP)


Thanks for tried the logic.

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