Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Configurable Audience Window size

  • Loading branch information...
commit 2bdb007fbbab0a36c1553a57267bfeed7430ed14 1 parent 1880289
alexander rakoczy toothrot authored
17 lib/controllers/config_controller.rb
View
@@ -80,6 +80,17 @@ def appearance
@prefs['window_width'] = edit.text
end
end
+
+ stack(:margin => 10) do
+ inscription "audience window height (e.g. #{height.to_i - 100}):"
+ edit_line(@prefs['audience_window_height']) do |edit|
+ @prefs['audience_window_height'] = edit.text
+ end
+ inscription "audience window width (e.g. #{width.to_i - 50}):"
+ edit_line(@prefs['audience_window_width']) do |edit|
+ @prefs['audience_window_width'] = edit.text
+ end
+ end
end
end
stack do
@@ -314,8 +325,8 @@ def hardware
def save_button
button "Save!" do
@prefs['bikes'].compact!
- old_width = WIDTH
- old_height = HEIGHT
+ old_width, old_height = WIDTH, HEIGHT
+ old_audience_width, old_audience_height = WIDTH_AUDIENCE, HEIGHT_AUDIENCE
old_skin = SKIN
File.open(File.join(LIB_DIR,'opensprints_conf.yml'), 'w+') do |f|
f << @prefs.to_yaml
@@ -326,7 +337,7 @@ def save_button
load "lib/setup.rb"
alert('Preferences saved!')
- if(old_width!=WIDTH||old_height!=HEIGHT)
+ if(old_width!=WIDTH||old_height!=HEIGHT) || (old_audience_width!=WIDTH_AUDIENCE||old_audience_height!=HEIGHT_AUDIENCE)
if((PLATFORM =~ /linux/)&&!(`which opensprints`).empty?)
alert("window dimensions have changed, restarting...")
fork ? exit : exec("opensprints")
2  lib/controllers/race_controller.rb
View
@@ -57,7 +57,7 @@ def countdown(id)
button("Stop Countdown") { visit "/races/#{id}/ready" }
}
race_track(race)
- @countbox = flow(:attach => Window, :top => (HEIGHT/2 - 100), :left => (WIDTH/2 - 125), :width => 250, :height => 200) { }
+ @countbox = flow(:attach => Window, :top => (window_height/2 - 100), :left => (window_width/2 - 125), :width => 250, :height => 200) { }
@timer = animate(1) { |count|
if SENSOR.false_start
alert "False start by #{race.race_participations[SENSOR.false_start].racer.name}"
16 lib/helpers/audience_admin_seperation.rb
View
@@ -3,6 +3,22 @@ module InstanceMethods
def admin_window?; !owner; end
def audience_window?; !admin_window?; end
def audience_friendly_url?(url); $audience_visible_urls.any? { |re| url =~ re }; end
+
+ def window_height
+ if audience_window?
+ HEIGHT_AUDIENCE
+ else
+ HEIGHT
+ end
+ end
+
+ def window_width
+ if audience_window?
+ WIDTH_AUDIENCE
+ else
+ WIDTH
+ end
+ end
end
module ClassMethods
def audience_friendly_urls(*urls)
2  lib/setup.rb
View
@@ -78,6 +78,8 @@ class FalseStart < RuntimeError; end
height = options['window_height'].to_i.nonzero?||(height.to_i-100)
HEIGHT = [height,550].max
WIDTH = options['window_width'].to_i.nonzero?||(width.to_i-50)
+HEIGHT_AUDIENCE = options['audience_window_height'].to_i.nonzero? || HEIGHT
+WIDTH_AUDIENCE = options['audience_window_width'].to_i.nonzero? || WIDTH
if defined? Shoes
class String
2  opensprints.rb
View
@@ -71,7 +71,7 @@ def index
flow(:attach => Window, :top => (@center.height * 0.65).to_i, :left => (WIDTH / 2)-250) {
caption(link("AUDIENCE WINDOW", :click => lambda{
if !$child && !owner # if we are the parent, and we haven't yet created the child
- $child = window(:height => HEIGHT, :width => WIDTH, :scroll => false, :title => TITLE)
+ $child = window(:height => HEIGHT_AUDIENCE, :width => WIDTH_AUDIENCE, :scroll => false, :title => TITLE)
end
} ))
}
Please sign in to comment.
Something went wrong with that request. Please try again.