mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-08 13:44:59 +00:00
Add support for timing using delta clocks (#97)
* Small correction to getConstantName. I swear this didn't work before, but now it does. * Support delta timing in mkxp-z * refresh Graphics.delta time at the start of update * Speed up load_data * Replace Input.count calls with Input.time?
This commit is contained in:
@@ -50,14 +50,14 @@ def pbPrintException(e)
|
|||||||
|
|
||||||
print("#{message}\r\nThis exception was logged in #{errorlogline}.\r\nHold Ctrl after closing this message to copy it to the clipboard.")
|
print("#{message}\r\nThis exception was logged in #{errorlogline}.\r\nHold Ctrl after closing this message to copy it to the clipboard.")
|
||||||
# Give a ~500ms coyote time to start holding Control
|
# Give a ~500ms coyote time to start holding Control
|
||||||
(Graphics.frame_rate / 2).ceil.times{
|
t = System.delta
|
||||||
Graphics.update
|
until (System.delta - t) >= 500000
|
||||||
Input.update
|
Input.update
|
||||||
if Input.press?(Input::CTRL)
|
if Input.press?(Input::CTRL)
|
||||||
Input.clipboard = message
|
Input.clipboard = message
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
}
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbCriticalCode
|
def pbCriticalCode
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ end
|
|||||||
def getConstantName(mod,value)
|
def getConstantName(mod,value)
|
||||||
mod = Object.const_get(mod) if mod.is_a?(Symbol)
|
mod = Object.const_get(mod) if mod.is_a?(Symbol)
|
||||||
for c in mod.constants
|
for c in mod.constants
|
||||||
return c if mod.const_get(c.to_sym).to_s==value
|
return c if mod.const_get(c.to_sym)==value
|
||||||
end
|
end
|
||||||
raise _INTL("Value {1} not defined by a constant in {2}",value,mod.name)
|
raise _INTL("Value {1} not defined by a constant in {2}",value,mod.name)
|
||||||
end
|
end
|
||||||
@@ -120,7 +120,7 @@ end
|
|||||||
def getConstantNameOrValue(mod,value)
|
def getConstantNameOrValue(mod,value)
|
||||||
mod = Object.const_get(mod) if mod.is_a?(Symbol)
|
mod = Object.const_get(mod) if mod.is_a?(Symbol)
|
||||||
for c in mod.constants
|
for c in mod.constants
|
||||||
return c if mod.const_get(c.to_sym).to_s==value
|
return c if mod.const_get(c.to_sym)==value
|
||||||
end
|
end
|
||||||
return value.inspect
|
return value.inspect
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -263,6 +263,7 @@ class AnimationWindow < SpriteWrapper
|
|||||||
right.x+=self.x
|
right.x+=self.x
|
||||||
right.y+=self.y
|
right.y+=self.y
|
||||||
swatchrects=[]
|
swatchrects=[]
|
||||||
|
repeattime = Input.time?(Input::MOUSELEFT) / 1000
|
||||||
for i in 0...NUMFRAMES
|
for i in 0...NUMFRAMES
|
||||||
swatchrects.push(Rect.new(arrowwidth+i*96+self.x,self.y,96,96))
|
swatchrects.push(Rect.new(arrowwidth+i*96+self.x,self.y,96,96))
|
||||||
end
|
end
|
||||||
@@ -276,7 +277,7 @@ class AnimationWindow < SpriteWrapper
|
|||||||
end
|
end
|
||||||
# Left arrow
|
# Left arrow
|
||||||
if left.contains(mousepos[0],mousepos[1])
|
if left.contains(mousepos[0],mousepos[1])
|
||||||
if Input.count(Input::MOUSELEFT)>30
|
if repeattime>750
|
||||||
@start-=3
|
@start-=3
|
||||||
else
|
else
|
||||||
@start-=1
|
@start-=1
|
||||||
@@ -286,7 +287,7 @@ class AnimationWindow < SpriteWrapper
|
|||||||
end
|
end
|
||||||
# Right arrow
|
# Right arrow
|
||||||
if right.contains(mousepos[0],mousepos[1])
|
if right.contains(mousepos[0],mousepos[1])
|
||||||
if Input.count(Input::MOUSELEFT)>30
|
if repeattime>750
|
||||||
@start+=3
|
@start+=3
|
||||||
else
|
else
|
||||||
@start+=1
|
@start+=1
|
||||||
|
|||||||
@@ -396,12 +396,13 @@ class Slider < UIControl
|
|||||||
left=toAbsoluteRect(@leftarrow)
|
left=toAbsoluteRect(@leftarrow)
|
||||||
right=toAbsoluteRect(@rightarrow)
|
right=toAbsoluteRect(@rightarrow)
|
||||||
oldvalue=self.curvalue
|
oldvalue=self.curvalue
|
||||||
|
repeattime = Input.time?(Input::MOUSELEFT) / 1000
|
||||||
# Left arrow
|
# Left arrow
|
||||||
if left.contains(mousepos[0],mousepos[1])
|
if left.contains(mousepos[0],mousepos[1])
|
||||||
if Input.count(Input::MOUSELEFT)>100
|
if repeattime>2500
|
||||||
self.curvalue-=10
|
self.curvalue-=10
|
||||||
self.curvalue=self.curvalue.floor
|
self.curvalue=self.curvalue.floor
|
||||||
elsif Input.count(Input::MOUSELEFT)>50
|
elsif repeattime>1250
|
||||||
self.curvalue-=5
|
self.curvalue-=5
|
||||||
self.curvalue=self.curvalue.floor
|
self.curvalue=self.curvalue.floor
|
||||||
else
|
else
|
||||||
@@ -413,10 +414,10 @@ class Slider < UIControl
|
|||||||
end
|
end
|
||||||
#Right arrow
|
#Right arrow
|
||||||
if right.contains(mousepos[0],mousepos[1])
|
if right.contains(mousepos[0],mousepos[1])
|
||||||
if Input.count(Input::MOUSELEFT)>100
|
if repeattime>2500
|
||||||
self.curvalue+=10
|
self.curvalue+=10
|
||||||
self.curvalue=self.curvalue.floor
|
self.curvalue=self.curvalue.floor
|
||||||
elsif Input.count(Input::MOUSELEFT)>50
|
elsif repeattime>1250
|
||||||
self.curvalue+=5
|
self.curvalue+=5
|
||||||
self.curvalue=self.curvalue.floor
|
self.curvalue=self.curvalue.floor
|
||||||
else
|
else
|
||||||
@@ -644,11 +645,12 @@ class TextSlider < UIControl
|
|||||||
left=toAbsoluteRect(@leftarrow)
|
left=toAbsoluteRect(@leftarrow)
|
||||||
right=toAbsoluteRect(@rightarrow)
|
right=toAbsoluteRect(@rightarrow)
|
||||||
oldvalue=self.curvalue
|
oldvalue=self.curvalue
|
||||||
|
repeattime = Input.time?(Input::MOUSELEFT) / 1000
|
||||||
# Left arrow
|
# Left arrow
|
||||||
if left.contains(mousepos[0],mousepos[1])
|
if left.contains(mousepos[0],mousepos[1])
|
||||||
if Input.count(Input::MOUSELEFT)>100
|
if repeattime>2500
|
||||||
self.curvalue-=10
|
self.curvalue-=10
|
||||||
elsif Input.count(Input::MOUSELEFT)>50
|
elsif repeattime>1250
|
||||||
self.curvalue-=5
|
self.curvalue-=5
|
||||||
else
|
else
|
||||||
self.curvalue-=1
|
self.curvalue-=1
|
||||||
@@ -658,9 +660,9 @@ class TextSlider < UIControl
|
|||||||
end
|
end
|
||||||
# Right arrow
|
# Right arrow
|
||||||
if right.contains(mousepos[0],mousepos[1])
|
if right.contains(mousepos[0],mousepos[1])
|
||||||
if Input.count(Input::MOUSELEFT)>100
|
if repeattime>2500
|
||||||
self.curvalue+=10
|
self.curvalue+=10
|
||||||
elsif Input.count(Input::MOUSELEFT)>50
|
elsif repeattime>1250
|
||||||
self.curvalue+=5
|
self.curvalue+=5
|
||||||
else
|
else
|
||||||
self.curvalue+=1
|
self.curvalue+=1
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class ControlPointSprite < SpriteWrapper
|
|||||||
end
|
end
|
||||||
|
|
||||||
def mouseover
|
def mouseover
|
||||||
if Input.count(Input::MOUSELEFT)==0 || !@dragging
|
if Input.time?(Input::MOUSELEFT)==0 || !@dragging
|
||||||
@dragging=false
|
@dragging=false
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -389,7 +389,7 @@ def pbDefinePath(canvas)
|
|||||||
window.text = (mousepos) ? sprintf("(%d,%d)",mousepos[0],mousepos[1]) : "(??,??)"
|
window.text = (mousepos) ? sprintf("(%d,%d)",mousepos[0],mousepos[1]) : "(??,??)"
|
||||||
Graphics.update
|
Graphics.update
|
||||||
Input.update
|
Input.update
|
||||||
if Input.triggerex?(:ESCAPE) || Input.count(Input::MOUSELEFT)==0
|
if Input.triggerex?(:ESCAPE) || Input.time?(Input::MOUSELEFT)==0
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user