Console now will resize when window is resized

This commit is contained in:
2020-05-16 07:10:10 -05:00
parent fbdea30015
commit 94c3dea7b9

View File

@@ -7,12 +7,13 @@ class IMICFPS
attr_reader :text_input
def initialize
@text_input = Gosu::TextInput.new
@width = window.width / 4 * 3
@height = window.height / 4 * 3
@input = Text.new("", x: 4, y: window.height / 4 * 3 - (PADDING * 2), z: Console::Z + 1)
@input = Text.new("", x: 4, y: @height - (PADDING * 2), z: Console::Z + 1)
@input.y -= @input.height
@history_height = window.height / 4 * 3 - (PADDING * 2 + @input.textobject.height)
@history = Text.new("=== #{IMICFPS::NAME} v#{IMICFPS::VERSION} (#{IMICFPS::RELEASE_NAME}) ===\n\n", x: 4, y: @history_height, z: Console::Z + 1)
@history = Text.new("=== #{IMICFPS::NAME} v#{IMICFPS::VERSION} (#{IMICFPS::RELEASE_NAME}) ===\n\n", x: 4, z: Console::Z + 1)
update_history_y
@command_history = []
@@ -32,9 +33,6 @@ class IMICFPS
@caret_interval = 250
@caret_color = Gosu::Color::WHITE
@selection_color = Gosu::Color.new(0x5522ff22)
@width = window.width / 4 * 3
@height = window.height / 4 * 3
end
def draw
@@ -86,6 +84,14 @@ class IMICFPS
@show_caret = !@show_caret
end
if @width != window.width || @height != @height
@width = window.width / 4 * 3
@height = window.height / 4 * 3
@input.y = @height - (PADDING * 2 + @input.height)
update_history_y
end
@input.text = @text_input.text
end
@@ -190,7 +196,7 @@ class IMICFPS
end
def update_history_y
@history.y = @history_height - (@history.text.lines.count * (@history.textobject.height))
@history.y = @height - (PADDING * 2) - @input.height - (@history.text.lines.count * (@history.textobject.height))
end
def handle_command