Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speedrun Timer Setting #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions scripts/Scene_Map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#==============================================================================

class Scene_Map
attr_accessor :in_game_timer
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
Expand Down Expand Up @@ -103,13 +104,13 @@ def main
#--------------------------------------------------------------------------
def update
if $game_temp.igt_timer_visible && (Graphics.frame_count != nil)
total_sec = Graphics.frame_count / Graphics.frame_rate
hour = total_sec / 60 / 60
min = total_sec / 60 % 60
sec = total_sec % 60
millisec = ((Graphics.frame_count * 1000) / Graphics.frame_rate) % 1000
time_string = sprintf("%02d:%02d:%02d.%03d", hour, min, sec, millisec)

total_sec = Graphics.frame_count.to_f / Graphics.frame_rate
time_string = sprintf("%02d:%02d:%02d.%03d",
total_sec / 3600,
total_sec / 60 % 60,
total_sec % 60,
total_sec * 1000 % 1000)
@in_game_timer.bitmap.fill_rect(0, 0, 140, 30, Color.new(0, 0, 0, 128))
@in_game_timer.bitmap.draw_text(8, 0, 132, 30, time_string)
end
Expand Down
16 changes: 6 additions & 10 deletions scripts/Scene_Title.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ def main
# Make system object
$game_system = Game_System.new

if File.exists?("igt.ini")
$game_temp.igt_timer_visible = true
end

# Skip title screen if debug mode (or demo, but not GDC)
if $debug || ($demo && !$GDC) || save_exists
$game_map.update
Expand All @@ -47,27 +43,27 @@ def main
load_perma_flags
Window_Settings.load_settings
Oneshot.allow_exit true

@window_settings_title = Window_Settings.new
# Make title graphic
@sprite = Sprite.new

# chinese has its own special title screen so check for it
translation_name = "#{$persistent.langcode}/#{$data_system.title_name}"
if File.exists?("Graphics/Titles/#{translation_name}.png")
@sprite.bitmap = RPG::Cache.title(translation_name)
else
@sprite.bitmap = RPG::Cache.title($data_system.title_name)
end

# check for debug file to add debug items
if File.exists?("debug_tester.dat")
# debug save
$game_party.gain_item(54, 1)
# plight skip
$game_party.gain_item(82, 1)
end

@sprite.zoom_x = 2.0
@sprite.zoom_y = 2.0
# Create/render menu options
Expand Down Expand Up @@ -151,7 +147,7 @@ def update
update_cursor = true
end
elsif Input.trigger?(Input::DOWN)

if $game_switches[160] && $game_switches[152]
if @cursor_pos < 3
@cursor_pos += 1
Expand Down Expand Up @@ -254,7 +250,7 @@ def command_shutdown
Oneshot.exiting true
$scene = nil
end

def command_settings
$game_system.se_play($data_system.decision_se)
@window_settings_title.open
Expand Down
86 changes: 51 additions & 35 deletions scripts/Window_Settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def save_settings
file.puts('colorblind_mode=' + $game_switches[252].to_s)
file.puts('automash_enabled=' + $game_switches[253].to_s)
file.puts('frameskip=' + Graphics.frameskip.to_s)
file.puts('in_game_timer=' + $game_temp.igt_timer_visible.to_s)
end
end

Expand Down Expand Up @@ -60,16 +61,20 @@ def self.load_settings
end
when "automash_enabled"
if vals[1] == "true"
$game_switches[253] = true
elsif vals[1] == "false"
$game_switches[253] = false
end
$game_switches[253] = true
elsif vals[1] == "false"
$game_switches[253] = false
end
when "frameskip"
if vals[1] == "true"
Graphics.frameskip = true
elsif vals[1] == "false"
Graphics.frameskip = false
end
Graphics.frameskip = true
elsif vals[1] == "false"
Graphics.frameskip = false
end
when "in_game_timer"
timer_enabled = vals[1] == "true"
$game_temp.igt_timer_visible = timer_enabled
$scene.in_game_timer.visible = timer_enabled if $scene.is_a?(Scene_Map)
end
end
end
Expand Down Expand Up @@ -128,6 +133,7 @@ def open
tr('Colorblind mode'),
tr('Skip Text (R)'),
tr('Frameskip'),
tr('In-Game Timer'),
tr('Language'),
tr('Configure Controls (Press F1)'),
]
Expand Down Expand Up @@ -203,10 +209,13 @@ def redraw_setting(spr, i)
else
spr.bitmap.draw_text(VALUE_MARGIN, 0, spr.bitmap.width, spr.bitmap.height, tr("OFF"))
end
when 7 # Language
l = Language::LANGUAGES[@lang_index] rescue Language::LANGUAGES[0]
spr.bitmap.draw_text(VALUE_MARGIN, 0, spr.bitmap.width, spr.bitmap.height, tr(l))
end
when 7 # In-game timer
text = tr($game_temp.igt_timer_visible ? "ON" : "OFF")
spr.bitmap.draw_text(VALUE_MARGIN, 0, spr.bitmap.width, spr.bitmap.height, text)
when 8 # Language
l = Language::LANGUAGES[@lang_index] rescue Language::LANGUAGES[0]
spr.bitmap.draw_text(VALUE_MARGIN, 0, spr.bitmap.width, spr.bitmap.height, tr(l))
end
end


Expand Down Expand Up @@ -414,34 +423,41 @@ def update

when 6 #frameskip
if Input.trigger?(Input::ACTION) || Input.trigger?(Input::LEFT) || Input.trigger?(Input::RIGHT)
$game_system.se_play($data_system.decision_se)
if Graphics.frameskip == true
Graphics.frameskip = false
else
Graphics.frameskip = true
end
redraw_setting_index(6)
end

when 7 # In-game timer
if Input.trigger?(Input::ACTION) || Input.trigger?(Input::LEFT) || Input.trigger?(Input::RIGHT)
$game_temp.igt_timer_visible = !$game_temp.igt_timer_visible
$scene.in_game_timer.visible = $game_temp.igt_timer_visible if $scene.is_a?(Scene_Map)
redraw_setting_index(7)
end

$game_system.se_play($data_system.decision_se)
if Graphics.frameskip == true
Graphics.frameskip = false
else
Graphics.frameskip = true
end
redraw_setting_index(6)
end

when 7 #language
when 8 #language
if Input.trigger?(Input::ACTION) || Input.trigger?(Input::RIGHT)
@lang_index += 1
if @lang_index >= Language::LANGUAGES.length
@lang_index = 0
end
$persistent.lang = Language::LANGUAGES[@lang_index]
redraw_all_settings()
end
if Input.trigger?(Input::LEFT)
@lang_index -= 1
if @lang_index < 0
@lang_index = Language::LANGUAGES.length - 1
@lang_index += 1
if @lang_index >= Language::LANGUAGES.length
@lang_index = 0
end
$persistent.lang = Language::LANGUAGES[@lang_index]
redraw_all_settings()
end

if Input.trigger?(Input::LEFT)
@lang_index -= 1
if @lang_index < 0
@lang_index = Language::LANGUAGES.length - 1
end
$persistent.lang = Language::LANGUAGES[@lang_index]
redraw_all_settings()
end
end
end
end

if Input.trigger?(Input::CANCEL)
$game_system.se_play($data_system.cancel_se)
Expand Down