mirror of
https://github.com/cyberarm/i-mic-fps.git
synced 2025-12-15 15:42:35 +00:00
Clean up window initialization a little bit, prevent window from being resizable if fullscreen: 'fixes' gosu believing that the window is smaller than it is
This commit is contained in:
18
i-mic-fps.rb
18
i-mic-fps.rb
@@ -31,6 +31,7 @@ include GLU
|
|||||||
|
|
||||||
def require_all(directory)
|
def require_all(directory)
|
||||||
files = Dir["#{directory}/**/*.rb"].sort!
|
files = Dir["#{directory}/**/*.rb"].sort!
|
||||||
|
file_order = []
|
||||||
|
|
||||||
loop do
|
loop do
|
||||||
failed = []
|
failed = []
|
||||||
@@ -39,6 +40,7 @@ def require_all(directory)
|
|||||||
files.each do |file|
|
files.each do |file|
|
||||||
begin
|
begin
|
||||||
require_relative file
|
require_relative file
|
||||||
|
file_order << file
|
||||||
rescue NameError => e
|
rescue NameError => e
|
||||||
failed << file
|
failed << file
|
||||||
first_name_error ||= e
|
first_name_error ||= e
|
||||||
@@ -52,6 +54,8 @@ def require_all(directory)
|
|||||||
end
|
end
|
||||||
break if failed.empty?
|
break if failed.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# pp file_order.map { |f| f.gsub(".rb", "")}
|
||||||
end
|
end
|
||||||
|
|
||||||
require_all "lib"
|
require_all "lib"
|
||||||
@@ -87,5 +91,17 @@ elsif ARGV.join.include?("--profile")
|
|||||||
puts "ruby-prof not installed!"
|
puts "ruby-prof not installed!"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
IMICFPS::Window.new.show
|
native = ARGV.join.include?("--native")
|
||||||
|
fps_target = ARGV.first.to_i != 0 ? ARGV.first.to_i : 60
|
||||||
|
window_width = native ? Gosu.screen_width : 1280
|
||||||
|
window_height = native ? Gosu.screen_height : 720
|
||||||
|
window_fullscreen = native ? true : false
|
||||||
|
|
||||||
|
IMICFPS::Window.new(
|
||||||
|
width: window_width,
|
||||||
|
height: window_height,
|
||||||
|
fullscreen: window_fullscreen,
|
||||||
|
resizable: !window_fullscreen,
|
||||||
|
update_interval: 1000.0 / fps_target
|
||||||
|
).show
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -5,14 +5,7 @@ class IMICFPS
|
|||||||
attr_accessor :number_of_vertices, :needs_cursor
|
attr_accessor :number_of_vertices, :needs_cursor
|
||||||
attr_reader :renderer, :scene, :config, :director, :console, :delta_time
|
attr_reader :renderer, :scene, :config, :director, :console, :delta_time
|
||||||
|
|
||||||
def initialize(window_width = 1280, window_height = 720, fullscreen = false)
|
def setup
|
||||||
fps_target = ARGV.first.to_i != 0 ? ARGV.first.to_i : 60
|
|
||||||
if ARGV.join.include?("--native")
|
|
||||||
super(width: Gosu.screen_width, height: Gosu.screen_height, fullscreen: true, resizable: true, update_interval: 1000.0 / fps_target)
|
|
||||||
else
|
|
||||||
super(width: window_width, height: window_height, fullscreen: fullscreen, resizable: true, update_interval: 1000.0 / fps_target)
|
|
||||||
end
|
|
||||||
$window = self
|
|
||||||
I18n.load_path << Dir["#{GAME_ROOT_PATH}/locales/*.yml"]
|
I18n.load_path << Dir["#{GAME_ROOT_PATH}/locales/*.yml"]
|
||||||
I18n.default_locale = :en
|
I18n.default_locale = :en
|
||||||
language = Gosu.language.split("_").first.to_sym
|
language = Gosu.language.split("_").first.to_sym
|
||||||
@@ -43,7 +36,7 @@ class IMICFPS
|
|||||||
@config.save!
|
@config.save!
|
||||||
end
|
end
|
||||||
|
|
||||||
push_state(Boot)
|
push_state(CyberarmEngine::IntroState, forward: Boot)
|
||||||
|
|
||||||
@delta_time = Gosu.milliseconds
|
@delta_time = Gosu.milliseconds
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user