June 6, 2016♦
EVR.Sound.Controls.Button.Volume.Deamplify = function(container)
{
EVR.Sound.Controls.Button.Volume.call(
this, container, ALIGN_LEFT, SOUND_DEAMPLIFY_ICON);
this.set_attributes();
this.append();
}
EVR.Sound.Controls.Button.Volume.Deamplify.prototype =
new EVR.Sound.Controls.Button.Volume;
EVR.Sound.Controls.Button.Volume.Deamplify.prototype.respond = function()
{
this.audio.decrease_volume();
EVR.Sound.Controls.Button.Volume.prototype.respond.call(this);
}
EVR.Sound.Controls.Button.Volume.Deamplify.prototype.update = function()
{
if (this.audio.volume <= 0)
{
this.focused_opacity = this.unfocused_opacity;
}
else
{
this.focused_opacity = SOUND_CONTROLS_FOUCUSED_OPACITY;
}
this.set_opacity();
}
EVR.Sound.Controls.Button.Volume.Deamplify.prototype.toString = function()
{
return "[object EVR.Sound.Controls.Button.Volume.Deamplify]";
}
EVR.include("sound/controls/button/volume/Amplify.js");
EVR.include("sound/controls/button/volume/Deamplify.js");
EVR.Sound.Controls.Button.Volume = function(container, alignment, icon)
{
EVR.Sound.Controls.Button.call(this, container, alignment);
this.icon = icon;
this.disable_selection();
}
EVR.Sound.Controls.Button.Volume.prototype = new EVR.Sound.Controls.Button;
EVR.Sound.Controls.Button.Volume.prototype.disable_selection = function()
{
if (!!this.element)
{
var element = this.element;
element.onselectstart = function() { return false };
element.onmousedown = function() { return false };
}
}
EVR.Sound.Controls.Button.Volume.prototype.set_attributes = function()
{
this.set_color(SOUND_BUTTON_BACKGROUND);
this.set_proportions(SOUND_BUTTON_WIDTH, SOUND_BUTTON_HEIGHT);
this.set_text();
this.css.cursor = "default";
}
EVR.Sound.Controls.Button.Volume.prototype.set_text = function()
{
var font = SOUND_CONTROLS_FONT_FAMILY;
var color = SOUND_CONTROLS_FONT_COLOR;
var size = SOUND_CONTROLS_FONT_SIZE;
EVR.Sound.Controls.Button.prototype.set_text.call(
this, this.icon, font, color, size);
}
EVR.Sound.Controls.Button.Volume.prototype.toString = function()
{
return "[object EVR.Sound.Controls.Button.Volume]";
}
EVR.Sound.Controls.Button.Volume.Amplify = function(container)
{
EVR.Sound.Controls.Button.Volume.call(
this, container, ALIGN_RIGHT, SOUND_AMPLIFY_ICON);
this.set_attributes();
this.append();
}
EVR.Sound.Controls.Button.Volume.Amplify.prototype =
new EVR.Sound.Controls.Button.Volume;
EVR.Sound.Controls.Button.Volume.Amplify.prototype.respond = function()
{
this.audio.increase_volume();
EVR.Sound.Controls.Button.Volume.prototype.respond.call(this);
}
EVR.Sound.Controls.Button.Volume.Amplify.prototype.update = function()
{
if (this.audio.volume >= 1)
{
this.focused_opacity = this.unfocused_opacity;
}
else
{
this.focused_opacity = SOUND_CONTROLS_FOUCUSED_OPACITY;
}
this.set_opacity();
}
EVR.Sound.Controls.Button.Volume.Amplify.prototype.toString = function()
{
return "[object EVR.Sound.Controls.Button.Volume.Amplify]";
}
var SOURCE_PATH = "src/game/stable/src/";
window.onload = function()
{
document.body.removeChild(document.getElementById("loading_animation"));
new EVR();
}
EVR = function()
{
this.populate();
this.add_listeners();
}
EVR.prototype.populate = function()
{
window.console = new EVR.Console();
console.write(SOURCE_PATH);
console.write(document.cookie);
this.field = new EVR.Field(document.body);
this.sound = new EVR.Sound(this.field, INTRODUCTION_SONG);
this.emoticon = new EVR.Emoticon(this.field);
this.title = new EVR.Title(this.field);
this.history = new EVR.History(this.field);
this.start_introduction();
this.delegate = new EVR.Delegate(this);
}
EVR.prototype.start_introduction = function()
{
this.introduction = new EVR.Animation.Introduction(
this.field, this.emoticon, this.title);
}
EVR.prototype.add_listeners = function()
{
var current = this;
window.onresize = function(event)
{
current.delegate.handle_resize_event(event)
};
this.enable_key_listeners();
}
EVR.prototype.enable_key_listeners = function()
{
var current = this;
document.onkeydown = function(event)
{
current.delegate.handle_key_down(event)
};
document.onkeyup = function(event)
{
current.delegate.handle_key_up(event)
};
document.onkeypress = function(event)
{
current.delegate.handle_key_press(event)
};
}
EVR.prototype.repopulate = function()
{
this.field.repopulate();
!!this.introduction && this.introduction.redraw();
this.emoticon.draw();
this.sound.draw();
!!this.menu && this.menu.attached && this.menu.draw();
!!this.current_level && this.current_level.draw();
!!this.instructions && this.instructions.draw();
!!this.about && this.about.draw();
this.history.attached && this.history.draw();
!!this.ending && this.ending.draw();
}
EVR.prototype.build_start_menu = function()
{
if (!!this.introduction && !this.introduction.cleared)
{
this.introduction.clear();
}
if (!!!this.menu)
{
this.menu = new EVR.Menu(this, this.field, this.emoticon);
this.delegate.menu = this.menu;
// this.field.fader.play();
}
}
EVR.prototype.load_level = function(id, practice)
{
if (!!this.current_level)
{
this.current_level.remove();
}
this.current_level = new EVR.Level(this, this.field, id, practice);
this.delegate.level = this.current_level;
this.destroy_start_menu();
this.title.attached && this.title.remove();
}
EVR.prototype.destroy_start_menu = function()
{
!!this.menu && this.menu.attached && this.menu.remove();
this.delegate.menu = null;
this.menu = null;
}
EVR.prototype.unload_level = function()
{
this.current_level.remove();
this.title.append();
this.build_start_menu();
this.current_level = null;
this.delegate.level = null;
this.sound.set_song(INTRODUCTION_SONG);
this.reset_field_color();
}
EVR.prototype.reset_field_color = function()
{
this.field.set_color(FIELD_COLORS[0]);
}
EVR.prototype.load_album = function(index)
{
if (!!!this.album)
{
this.album = new EVR.Album(this.field);
this.delegate.album = this.album;
}
this.menu.remove();
this.album.append(index);
this.sound.hide();
this.sound.set_song(ALBUM_SONG);
}
EVR.prototype.unload_album = function()
{
!!this.album && this.album.remove();
this.menu.append();
this.sound.show();
this.sound.set_song(INTRODUCTION_SONG);
}
EVR.prototype.load_instructions = function()
{
if (!!!this.instructions)
{
this.instructions = new EVR.Instructions(this.field);
this.delegate.instructions = this.instructions;
}
this.menu.remove();
this.instructions.append();
}
EVR.prototype.unload_instructions = function()
{
this.instructions.remove();
this.menu.append();
}
EVR.prototype.load_history = function()
{
this.menu.remove();
this.history.append();
}
EVR.prototype.unload_history = function()
{
this.history.remove();
this.menu.append();
}
EVR.prototype.load_about = function()
{
if (!!!this.about)
{
this.about = new EVR.About(this);
this.delegate.about = this.about;
}
this.menu.remove();
this.about.append();
}
EVR.prototype.unload_about = function()
{
this.about.remove();
this.menu.append();
}
EVR.prototype.load_ending = function()
{
if (!!this.current_level)
{
this.unload_level();
}
this.title.attached && this.title.remove();
this.menu.attached && this.menu.remove();
if (!!!this.ending)
{
this.ending = new EVR.Animation.Ending(this);
this.delegate.ending = this.ending;
}
this.sound.set_song(ENDING_SONG);
this.ending.play();
}
EVR.prototype.unload_ending = function()
{
this.ending.clear();
this.menu.append();
this.title.append();
this.sound.set_song(INTRODUCTION_SONG);
}
EVR.prototype.load_account = function()
{
if (!!!this.account)
{
this.account = new EVR.Account(this);
this.delegate.account = this.account;
}
this.disable_key_listeners();
this.menu.remove();
this.account.append();
}
EVR.prototype.disable_key_listeners = function()
{
document.onkeydown = null;
document.onkeyup = null;
document.onkeypress = null;
}
EVR.prototype.unload_account = function()
{
this.enable_key_listeners();
this.account.remove();
this.destroy_start_menu();
this.build_start_menu();
}
EVR.prototype.toggle_sound = function()
{
var sound = this.sound;
sound.audio.mute();
sound.controls.update();
}
EVR.prototype.log_in = function()
{
if (this.account.attached)
{
this.unload_account();
}
this.history.load();
}
EVR.prototype.log_out = function()
{
document.cookie = "hash=;expiration=0;path=/";
this.destroy_start_menu();
this.build_start_menu();
this.history.load();
!!this.album && this.album.initialize_pages();
}
EVR.inherit = function(child, parent)
{
for (var method in parent.prototype)
{
if (method != "toString")
{
child.prototype[method] = parent.prototype[method];
}
}
}
EVR.include = function(file_path)
{
var tag = "<script language=\"javascript\" type=\"text/javascript\"";
tag += " src=\"" + SOURCE_PATH + file_path + "\"></script>";
document.write(tag);
}
EVR.prototype.toString = function()
{
return "[object EVR]";
}
EVR.include("definitions.js");
EVR.include("Math.js");
EVR.include("Color.js");
EVR.include("time/Time.js");
EVR.include("Requester.js");
EVR.include("element/Element.js");
EVR.include("element/Component.js");
EVR.include("element/Table.js");
EVR.include("element/graphic/Graphic.js");
EVR.include("element/graphic/Aligner.js");
EVR.include("element/pop_up/Pop_Up.js");
EVR.include("Console.js");
EVR.include("Prompt.js");
EVR.include("animation/Animation.js");
EVR.include("field/Field.js");
EVR.include("sound/Sound.js");
EVR.include("emoticon/Emoticon.js");
EVR.include("title/Title.js");
EVR.include("history/History.js");
EVR.include("menu/Menu.js");
EVR.include("level/Level.js");
EVR.include("album/Album.js");
EVR.include("account/Account.js");
EVR.include("instructions/Instructions.js");
EVR.include("about/About.js");
EVR.include("delegate/Delegate.js");