Method: Core::GUI::Window#update

Defined in:
lib/gui/base.rb

#updateObject



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/gui/base.rb', line 78

def update
  @elements.each_value { |el|
    el.update
    if el.remove?
      @elements.delete(@elements.key(el))
    end
  }
  if @close
    @close.x, @close.y, @close.zoff = @x+@w-24, @y, @zoff
    @close.update
  end
  if @move
    m = [Core.window.mouse_x, Core.window.mouse_y]
    if Core.inside?(m.x, m.y, @x, @y, @x+@w-24, @y+24) or @dragging
      if Core.window.button_down?(Gosu::MsLeft)
        if !@dragging
          @dragging = true
          @dragx = m.x - @x
          @dragy = m.y - @y
        else
          @x = m.x - @dragx
          @y = m.y - @dragy
        end
      else
        @dragging = false
      end
    end
  end
  if @dragging
    if @x > 1024 - @w
      @x = 1024 - @w
    elsif @x < 0
      @x = 0
    end
    if @y > 744
      @y = 744
    elsif @y < 0
      @y = 0
    end
  end
  if @save_pos
    Core.config[@xsym] = @x
    Core.config[@ysym] = @y
  end
end