module GGLib $initthemes = false module Themes class BlueSteelTheme < ImageTheme @@button = nil def initialize image = ThemeImageGroup.new( $gglroot+"/media/bluesteel/generic/menusmall.png", $gglroot+"/media/bluesteel/generic/menusmall.png", $gglroot+"/media/bluesteel/generic/menusmall.png" ) font = ThemeFontGroup.new( Gosu::Font.new($window, Gosu::default_font_name, 17), Gosu::Font.new($window, Gosu::default_font_name, 25), Gosu::Font.new($window, Gosu::default_font_name, 20)) super("BlueSteel.Generic", font, image) end def request(obj) if @@button == nil #Can't initialize atglobal scope because $window may not have been set @@button = ImageTheme.new("BlueSteel.Button", ThemeFontGroup.new( Gosu::Font.new($window, Gosu::default_font_name, 17), Gosu::Font.new($window, Gosu::default_font_name, 25), Gosu::Font.new($window, Gosu::default_font_name, 20)), ThemeImageGroup.new( $gglroot+"/media/bluesteel/button/button.png", $gglroot+"/media/bluesteel/button/buttonup.png" , $gglroot+"/media/bluesteel/button/buttonup.png" )) @@textbox = ImageTheme.new("BlueSteel.TextBox", ThemeFontGroup.new( Gosu::Font.new($window, Gosu::default_font_name, 17), Gosu::Font.new($window, Gosu::default_font_name, 25), Gosu::Font.new($window, Gosu::default_font_name, 20)), ThemeImageGroup.new( $gglroot+"/media/bluesteel/textbox/textbox.png", $gglroot+"/media/bluesteel/textbox/textboxactive.png" , $gglroot+"/media/bluesteel/textbox/textboxactive.png" )) @@label = ImageTheme.new("BlueSteel.Label", ThemeFontGroup.new( Gosu::Font.new($window, Gosu::default_font_name, 17), Gosu::Font.new($window, Gosu::default_font_name, 25), Gosu::Font.new($window, Gosu::default_font_name, 20)), ThemeImageGroup.new( $gglroot+"/null.png", $gglroot+"/null.png" , $gglroot+"/null.png" ) ) end if obj.kind_of?(Button) return @@button elsif obj.kind_of?(TextBox) return @@textbox elsif obj.kind_of?(Label) return @@label end return self end end class RubygooTheme < DrawnTheme @@textbox = nil def initialize font = ThemeFontGroup.new( Gosu::Font.new($window, Gosu::default_font_name, 17), Gosu::Font.new($window, Gosu::default_font_name, 25), Gosu::Font.new($window, Gosu::default_font_name, 20), 0xff000000, 0xff848484) super("Rubygoo.Generic", font) end def request(obj) if @@textbox == nil #Can't initialize atglobal scope because $window may not have been set @@textbox = RubygooTextTheme.new @@label = RubygooLabelTheme.new end if obj.kind_of?(TextBox) return @@textbox elsif obj.kind_of?(Label) return @@label end return self end def draw(x1,y1, x2, y2, state) if state == 1 $window.draw_quad(x1, y1, 0xffb22222, x2, y1, 0xffb22222, x1, y2, 0xffb22222, x2, y2, 0xffb22222, ZOrder::Widget) $window.draw_quad(x1+1, y1+1, 0xff6e6e6e, x2-1, y1+1, 0xff6e6e6e, x1+1, y2-1, 0xff6e6e6e, x2-1, y2-1, 0xff6e6e6e, ZOrder::Widget) else $window.draw_quad(x1, y1, 0xffb22222, x2, y1, 0xffb22222, x1, y2, 0xffb22222, x2, y2, 0xffb22222, ZOrder::Widget) $window.draw_quad(x1+1, y1+1, 0xff808080, x2-1, y1+1, 0xff808080, x1+1, y2-1, 0xff808080, x2-1, y2-1, 0xff808080, ZOrder::Widget) end end end class RubygooTextTheme < DrawnTheme @@textbox = nil def initialize font = ThemeFontGroup.new( Gosu::Font.new($window, Gosu::default_font_name, 17), Gosu::Font.new($window, Gosu::default_font_name, 25), Gosu::Font.new($window, Gosu::default_font_name, 20), 0xff000000, 0xffb22222) super("Rubygoo.TextBox", font) end def draw(x1,y1, x2, y2, state) if state == 1 $window.draw_quad(x1, y1, 0xff6e6e6e, x2, y1, 0xff6e6e6e, x1, y2, 0xff6e6e6e, x2, y2, 0xff6e6e6e, ZOrder::Widget) $window.draw_quad(x1+2, y1+2, 0xff000000, x2-2, y1+2, 0xff000000, x1+2, y2-2, 0xff000000, x2-2, y2-2, 0xff000000, ZOrder::Widget) $window.draw_quad(x1+3, y1+3, 0xff6e6e6e, x2-3, y1+3, 0xff6e6e6e, x1+3, y2-3, 0xff6e6e6e, x2-3, y2-3, 0xff6e6e6e, ZOrder::Widget) else $window.draw_quad(x1, y1, 0xff808080, x2, y1, 0xff808080, x1, y2, 0xff808080, x2, y2, 0xff808080, ZOrder::Widget) $window.draw_quad(x1+2, y1+2, 0xff000000, x2-2, y1+2, 0xff000000, x1+2, y2-2, 0xff000000, x2-2, y2-2, 0xff000000, ZOrder::Widget) $window.draw_quad(x1+3, y1+3, 0xff808080, x2-3, y1+3, 0xff808080, x1+3, y2-3, 0xff808080, x2-3, y2-3, 0xff808080, ZOrder::Widget) end end end class RubygooLabelTheme < DrawnTheme @@textbox = nil def initialize font = ThemeFontGroup.new( Gosu::Font.new($window, Gosu::default_font_name, 17), Gosu::Font.new($window, Gosu::default_font_name, 25), Gosu::Font.new($window, Gosu::default_font_name, 20), 0xff000000, 0xffb22222) super("Rubygoo.Label", font) end end class ShadeTheme < DrawnTheme @@label = nil def initialize font = ThemeFontGroup.new( Gosu::Font.new($window, Gosu::default_font_name, 17), Gosu::Font.new($window, Gosu::default_font_name, 25), Gosu::Font.new($window, Gosu::default_font_name, 20), 0xffe6e6e6, 0xffb22222) super("Shade.Generic", font) end def request(obj) if @@label == nil #Can't initialize atglobal scope because $window may not have been set @@label = ShadeLabelTheme.new end if obj.kind_of?(Label) return @@label end return self end def draw(x1,y1, x2, y2, state) if state == 1 $window.draw_quad(x1, y1, 0xff2e2e2e, x2, y1, 0xff2e2e2e, x1, y2, 0xff2e2e2e, x2, y2, 0xff2e2e2e, ZOrder::Widget) $window.draw_quad(x1+2, y1+2, 0xffbdbdbd, x2-2, y1+2, 0xffbdbdbd, x1+2, y2-2, 0xffbdbdbd, x2-2, y2-2, 0xffbdbdbd, ZOrder::Widget) $window.draw_quad(x1+3, y1+3, 0xff2e2e2e, x2-3, y1+3, 0xff2e2e2e, x1+3, y2-3, 0xff2e2e2e, x2-3, y2-3, 0xff2e2e2e, ZOrder::Widget) else $window.draw_quad(x1, y1, 0xff2e2e2e, x2, y1, 0xff2e2e2e, x1, y2, 0xff2e2e2e, x2, y2, 0xff2e2e2e, ZOrder::Widget) $window.draw_quad(x1+2, y1+2, 0xffffffff, x2-2, y1+2, 0xffffffff, x1+2, y2-2, 0xffffffff, x2-2, y2-2, 0xffffffff, ZOrder::Widget) $window.draw_quad(x1+3, y1+3, 0xff2e2e2e, x2-3, y1+3, 0xff2e2e2e, x1+3, y2-3, 0xff2e2e2e, x2-3, y2-3, 0xff2e2e2e, ZOrder::Widget) end end end class ShadeLabelTheme < DrawnTheme @@textbox = nil def initialize font = ThemeFontGroup.new( Gosu::Font.new($window, Gosu::default_font_name, 17), Gosu::Font.new($window, Gosu::default_font_name, 25), Gosu::Font.new($window, Gosu::default_font_name, 20), 0xffe6e6e6, 0xff848484) super("Shade.Label", font) end end class WindowsTheme < ImageTheme @@button = nil def initialize image = ThemeImageGroup.new( $gglroot+"/media/windows/generic/menusmall.png", $gglroot+"/media/bluesteel/generic/menusmall.png", $gglroot+"/media/bluesteel/generic/menusmall.png" ) font = ThemeFontGroup.new( Gosu::Font.new($window, Gosu::default_font_name, 17), Gosu::Font.new($window, Gosu::default_font_name, 25), Gosu::Font.new($window, Gosu::default_font_name, 20)) super("Windows.Generic", font, image) end def request(obj) if @@button == nil #Can't initialize atglobal scope because $window may not have been set @@button = ImageTheme.new("Windows.Button", ThemeFontGroup.new( Gosu::Font.new($window, Gosu::default_font_name, 17), Gosu::Font.new($window, Gosu::default_font_name, 25), Gosu::Font.new($window, Gosu::default_font_name, 20)), ThemeImageGroup.new( $gglroot+"/media/windows/button/button.png", $gglroot+"/media/windows/button/buttonup.png" , $gglroot+"/media/windows/button/buttondown.png" )) @@textbox = ImageTheme.new("Windows.TextBox", ThemeFontGroup.new( Gosu::Font.new($window, Gosu::default_font_name, 17), Gosu::Font.new($window, Gosu::default_font_name, 25), Gosu::Font.new($window, Gosu::default_font_name, 20)), ThemeImageGroup.new( $gglroot+"/media/windows/textbox/textbox.png", $gglroot+"/media/windows/textbox/textboxup.png" , $gglroot+"/media/windows/textbox/textboxup.png" )) @@label = ImageTheme.new("Windows.Label", ThemeFontGroup.new( Gosu::Font.new($window, Gosu::default_font_name, 17), Gosu::Font.new($window, Gosu::default_font_name, 25), Gosu::Font.new($window, Gosu::default_font_name, 20)), ThemeImageGroup.new( $gglroot+"/null.png", $gglroot+"/null.png" , $gglroot+"/null.png" ) ) end if obj.kind_of?(Button) return @@button elsif obj.kind_of?(TextBox) return @@textbox elsif obj.kind_of?(Label) return @@label end return self end end $theme_init_hook = Proc.new { unless $initthemes Themes.const_set("BlueSteel", BlueSteelTheme.new) Themes.const_set("Rubygoo", RubygooTheme.new) Themes.const_set("Shade", ShadeTheme.new) Themes.const_set("Windows", WindowsTheme.new) $initthemes = true end } end #module Themes end #module GGLib