mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Remove SpriteWindowCursorRect & fix WindowCursorRect (#85)
* Remove SpriteWindowCursorRect * Fix WindowCursorRect - Use super - Don't overwrite getters for x, y etc. - Use self.x instead of @x, etc. * Fix needs_update? using zeroes * Rename WindowCursorRect#isEmpty? to #empty?
This commit is contained in:
@@ -1,59 +1,55 @@
|
|||||||
class WindowCursorRect < Rect
|
class WindowCursorRect < Rect
|
||||||
def initialize(window)
|
def initialize(window)
|
||||||
@window=window
|
super(0, 0, 0, 0)
|
||||||
@x=0
|
@window = window
|
||||||
@y=0
|
|
||||||
@width=0
|
|
||||||
@height=0
|
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_reader :x,:y,:width,:height
|
|
||||||
|
|
||||||
def empty
|
def empty
|
||||||
needupdate=@x!=0 || @y!=0 || @width!=0 || @height!=0
|
return unless needs_update?(0, 0, 0, 0)
|
||||||
if needupdate
|
|
||||||
@x=0
|
set(0, 0, 0, 0)
|
||||||
@y=0
|
|
||||||
@width=0
|
|
||||||
@height=0
|
|
||||||
@window.width=@window.width
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def isEmpty?
|
def empty?
|
||||||
return @x==0 && @y==0 && @width==0 && @height==0
|
return self.x == 0 && self.y == 0 && self.width == 0 && self.height == 0
|
||||||
end
|
end
|
||||||
|
|
||||||
def set(x,y,width,height)
|
def set(x, y, width, height)
|
||||||
needupdate=@x!=x || @y!=y || @width!=width || @height!=height
|
return unless needs_update?(x, y, width, height)
|
||||||
if needupdate
|
|
||||||
@x=x
|
super(x, y, width, height)
|
||||||
@y=y
|
|
||||||
@width=width
|
@window.width = @window.width
|
||||||
@height=height
|
|
||||||
@window.width=@window.width
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def height=(value)
|
def height=(value)
|
||||||
@height=value; @window.width=@window.width
|
super(value)
|
||||||
|
@window.width = @window.width
|
||||||
end
|
end
|
||||||
|
|
||||||
def width=(value)
|
def width=(value)
|
||||||
@width=value; @window.width=@window.width
|
super(value)
|
||||||
|
@window.width = @window.width
|
||||||
end
|
end
|
||||||
|
|
||||||
def x=(value)
|
def x=(value)
|
||||||
@x=value; @window.width=@window.width
|
super(value)
|
||||||
|
@window.width = @window.width
|
||||||
end
|
end
|
||||||
|
|
||||||
def y=(value)
|
def y=(value)
|
||||||
@y=value; @window.width=@window.width
|
super(value)
|
||||||
|
@window.width = @window.width
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def needs_update?(x, y, width, height)
|
||||||
|
return self.x != x || self.y != y || self.width != width || self.height != height
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Window
|
class Window
|
||||||
attr_reader :tone
|
attr_reader :tone
|
||||||
attr_reader :color
|
attr_reader :color
|
||||||
@@ -309,7 +305,7 @@ class Window
|
|||||||
@cursoropacity+=8
|
@cursoropacity+=8
|
||||||
@cursorblink=0 if @cursoropacity>=255
|
@cursorblink=0 if @cursoropacity>=255
|
||||||
end
|
end
|
||||||
mustchange=true if !@cursor_rect.isEmpty?
|
mustchange=true if !@cursor_rect.empty?
|
||||||
else
|
else
|
||||||
mustchange=true if @cursoropacity!=128
|
mustchange=true if @cursoropacity!=128
|
||||||
@cursoropacity=128
|
@cursoropacity=128
|
||||||
|
|||||||
@@ -1,62 +1,3 @@
|
|||||||
#===============================================================================
|
|
||||||
#
|
|
||||||
#===============================================================================
|
|
||||||
class SpriteWindowCursorRect < Rect
|
|
||||||
def initialize(window)
|
|
||||||
@window=window
|
|
||||||
@x=0
|
|
||||||
@y=0
|
|
||||||
@width=0
|
|
||||||
@height=0
|
|
||||||
end
|
|
||||||
|
|
||||||
attr_reader :x,:y,:width,:height
|
|
||||||
|
|
||||||
def empty
|
|
||||||
needupdate=@x!=0 || @y!=0 || @width!=0 || @height!=0
|
|
||||||
if needupdate
|
|
||||||
@x=0
|
|
||||||
@y=0
|
|
||||||
@width=0
|
|
||||||
@height=0
|
|
||||||
@window.width=@window.width
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def isEmpty?
|
|
||||||
return @x==0 && @y==0 && @width==0 && @height==0
|
|
||||||
end
|
|
||||||
|
|
||||||
def set(x,y,width,height)
|
|
||||||
needupdate=@x!=x || @y!=y || @width!=width || @height!=height
|
|
||||||
if needupdate
|
|
||||||
@x=x
|
|
||||||
@y=y
|
|
||||||
@width=width
|
|
||||||
@height=height
|
|
||||||
@window.width=@window.width
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def height=(value)
|
|
||||||
@height=value; @window.width=@window.width
|
|
||||||
end
|
|
||||||
|
|
||||||
def width=(value)
|
|
||||||
@width=value; @window.width=@window.width
|
|
||||||
end
|
|
||||||
|
|
||||||
def x=(value)
|
|
||||||
@x=value; @window.width=@window.width
|
|
||||||
end
|
|
||||||
|
|
||||||
def y=(value)
|
|
||||||
@y=value; @window.width=@window.width
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
# SpriteWindow is a class based on Window which emulates Window's functionality.
|
# SpriteWindow is a class based on Window which emulates Window's functionality.
|
||||||
# This class is necessary in order to change the viewport of windows (with
|
# This class is necessary in order to change the viewport of windows (with
|
||||||
@@ -156,7 +97,7 @@ class SpriteWindow < Window
|
|||||||
@blend_type=0
|
@blend_type=0
|
||||||
@contents_blend_type=0
|
@contents_blend_type=0
|
||||||
@contents_opacity=255
|
@contents_opacity=255
|
||||||
@cursor_rect=SpriteWindowCursorRect.new(self)
|
@cursor_rect=WindowCursorRect.new(self)
|
||||||
@cursorblink=0
|
@cursorblink=0
|
||||||
@cursoropacity=255
|
@cursoropacity=255
|
||||||
@pause=false
|
@pause=false
|
||||||
|
|||||||
Reference in New Issue
Block a user