[gd_scene load_steps=9 format=2] [ext_resource path="res://nodes/label.tscn" type="PackedScene" id=1] [ext_resource path="res://fonts/Lingo.tres" type="DynamicFont" id=2] [ext_resource path="res://nodes/button.tscn" type="PackedScene" id=3] [ext_resource path="user://maps/Archipelago/settings_buttons.gd" type="Script" id=4] [ext_resource path="user://maps/Archipelago/settings_screen.gd" type="Script" id=5] [ext_resource path="res://fonts/Lingo35.tres" type="DynamicFont" id=6] [sub_resource type="StyleBoxFlat" id=1] bg_color = Color( 0, 0, 0, 0 ) [sub_resource type="StyleBoxFlat" id=2] bg_color = Color( 1, 1, 1, 1 ) border_width_left = 1 border_width_top = 1 border_width_right = 1 border_width_bottom = 1 border_color = Color( 1, 1, 0, 1 ) border_blend = true corner_radius_top_left = 3 corner_radius_top_right = 3 corner_radius_bottom_right = 3 corner_radius_bottom_left = 3 expand_margin_left = 5.0 expand_margin_right = 5.0 expand_margin_top = 5.0 expand_margin_bottom = 5.0 [node name="settings_screen" type="Spatial"] script = ExtResource( 5 ) [node name="Panel" type="Panel" parent="."] margin_right = 1920.0 margin_bottom = 1080.0 [node name="title" parent="Panel" instance=ExtResource( 1 )] margin_left = 0.0 margin_top = 75.0 margin_right = 1920.0 margin_bottom = 225.0 custom_fonts/font = ExtResource( 2 ) text = "ARCHIPELAGO" valign = 1 [node name="credit" parent="Panel" instance=ExtResource( 1 )] visible = false margin_left = 1278.0 margin_top = 974.0 margin_right = 1868.0 margin_bottom = 1034.0 custom_fonts/font = ExtResource( 2 ) text = "Brenton Wildes" [node name="connect_button" parent="Panel" instance=ExtResource( 3 )] margin_left = 255.0 margin_top = 875.0 margin_right = 891.0 margin_bottom = 1025.0 custom_colors/font_color_hover = Color( 1, 0.501961, 0, 1 ) custom_fonts/font = ExtResource( 2 ) text = "CONNECT" script = ExtResource( 4 ) [node name="quit_button" parent="Panel" instance=ExtResource( 3 )] margin_left = 1102.0 margin_top = 875.0 margin_right = 1738.0 margin_bottom = 1025.0 custom_colors/font_color_hover = Color( 1, 0, 0, 1 ) custom_fonts/font = ExtResource( 2 ) text = "BACK" script = ExtResource( 4 ) [node name="credit2" parent="Panel" instance=ExtResource( 1 )] margin_left = 75.0 margin_top = 346.0 margin_right = 665.0 margin_bottom = 410.0 custom_fonts/font = ExtResource( 2 ) custom_styles/normal = SubResource( 1 ) text = "SERVER" align = 2 [node name="credit3" parent="Panel" instance=ExtResource( 1 )] margin_left = 75.0 margin_top = 519.0 margin_right = 665.0 margin_bottom = 583.0 custom_fonts/font = ExtResource( 2 ) custom_styles/normal = SubResource( 1 ) text = "PLAYER" align = 2 [node name="credit4" parent="Panel" instance=ExtResource( 1 )] margin_left = 75.0 margin_top = 704.0 margin_right = 665.0 margin_bottom = 768.0 custom_fonts/font = ExtResource( 2 ) custom_styles/normal = SubResource( 1 ) text = "PASSWORD" align = 2 [node name="server_box" type="LineEdit" parent="Panel"] margin_left = 682.0 margin_top = 295.0 margin_right = 1324.0 margin_bottom = 445.0 custom_colors/selection_color = Color( 0.482353, 0, 0, 1 ) custom_colors/cursor_color = Color( 0, 0, 0, 1 ) custom_colors/font_color = Color( 0, 0, 0, 1 ) custom_styles/focus = SubResource( 2 ) align = 1 caret_blink = true [node name="player_box" type="LineEdit" parent="Panel"] margin_left = 682.0 margin_top = 477.0 margin_right = 1324.0 margin_bottom = 627.0 custom_colors/selection_color = Color( 0.482353, 0, 0, 1 ) custom_colors/cursor_color = Color( 0, 0, 0, 1 ) custom_colors/font_color = Color( 0, 0, 0, 1 ) custom_styles/focus = SubResource( 2 ) align = 1 caret_blink = true [node name="password_box" type="LineEdit" parent="Panel"] margin_left = 682.0 margin_top = 659.0 margin_right = 1324.0 margin_bottom = 809.0 custom_colors/selection_color = Color( 0.482353, 0, 0, 1 ) custom_colors/cursor_color = Color( 0, 0, 0, 1 ) custom_colors/font_color = Color( 0, 0, 0, 1 ) custom_styles/focus = SubResource( 2 ) align = 1 caret_blink = true [node name="AcceptDialog" type="AcceptDialog" parent="Panel"] margin_right = 83.0 margin_bottom = 58.0 [connection signal="pressed" from="Panel/connect_button" to="Panel/connect_button" method="_connect_pressed"] [connection signal="pressed" from="Panel/quit_button" to="Panel/quit_button" method="_back_pressed"] 6 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220
/*
Copyright (c) 2010 Steve Oldmeadow
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
$Id$
*/
#import "SimpleAudioEngine.h"
@implementation SimpleAudioEngine
static SimpleAudioEngine *sharedEngine = nil;
static CDSoundEngine* soundEngine = nil;
static CDAudioManager *am = nil;
static CDBufferManager *bufferManager = nil;
// Init
+ (SimpleAudioEngine *) sharedEngine
{
@synchronized(self) {
if (!sharedEngine)
sharedEngine = [[SimpleAudioEngine alloc] init];
}
return sharedEngine;
}
+ (id) alloc
{
@synchronized(self) {
NSAssert(sharedEngine == nil, @"Attempted to allocate a second instance of a singleton.");
return [super alloc];
}
return nil;
}
-(id) init
{
if((self=[super init])) {
am = [CDAudioManager sharedManager];
soundEngine = am.soundEngine;
bufferManager = [[CDBufferManager alloc] initWithEngine:soundEngine];
mute_ = NO;
enabled_ = YES;
}
return self;
}
// Memory
- (void) dealloc
{
am = nil;
soundEngine = nil;
bufferManager = nil;
[super dealloc];
}
+(void) end
{
am = nil;
[CDAudioManager end];
[bufferManager release];
[sharedEngine release];
sharedEngine = nil;
}
#pragma mark SimpleAudioEngine - background music
-(void) preloadBackgroundMusic:(NSString*) filePath {
[am preloadBackgroundMusic:filePath];
}
-(void) playBackgroundMusic:(NSString*) filePath
{
[am playBackgroundMusic:filePath loop:TRUE];
}
-(void) playBackgroundMusic:(NSString*) filePath loop:(BOOL) loop
{
[am playBackgroundMusic:filePath loop:loop];
}
-(void) stopBackgroundMusic
{
[am stopBackgroundMusic];
}
-(void) pauseBackgroundMusic {
[am pauseBackgroundMusic];
}
-(void) resumeBackgroundMusic {
[am resumeBackgroundMusic];
}
-(void) rewindBackgroundMusic {
[am rewindBackgroundMusic];
}
-(BOOL) isBackgroundMusicPlaying {
return [am isBackgroundMusicPlaying];
}
-(BOOL) willPlayBackgroundMusic {
return [am willPlayBackgroundMusic];
}
#pragma mark SimpleAudioEngine - sound effects
-(ALuint) playEffect:(NSString*) filePath
{
return [self playEffect:filePath pitch:1.0f pan:0.0f gain:1.0f];
}
-(ALuint) playEffect:(NSString*) filePath pitch:(Float32) pitch pan:(Float32) pan gain:(Float32) gain
{
int soundId = [bufferManager bufferForFile:filePath create:YES];
if (soundId != kCDNoBuffer) {
return [soundEngine playSound:soundId sourceGroupId:0 pitch:pitch pan:pan gain:gain loop:false];
} else {
return CD_MUTE;
}
}
-(void) stopEffect:(ALuint) soundId {
[soundEngine stopSound:soundId];
}
-(void) preloadEffect:(NSString*) filePath
{
int soundId = [bufferManager bufferForFile:filePath create:YES];
if (soundId == kCDNoBuffer) {
CDLOG(@"Denshion::SimpleAudioEngine sound failed to preload %@",filePath);
}
}
-(void) unloadEffect:(NSString*) filePath
{
CDLOGINFO(@"Denshion::SimpleAudioEngine unloadedEffect %@",filePath);
[bufferManager releaseBufferForFile:filePath];
}
#pragma mark Audio Interrupt Protocol
-(BOOL) mute
{
return mute_;
}
-(void) setMute:(BOOL) muteValue
{
if (mute_ != muteValue) {
mute_ = muteValue;
am.mute = mute_;
}
}
-(BOOL) enabled
{
return enabled_;
}
-(void) setEnabled:(BOOL) enabledValue
{
if (enabled_ != enabledValue) {
enabled_ = enabledValue;
am.enabled = enabled_;
}
}
#pragma mark SimpleAudioEngine - BackgroundMusicVolume
-(float) backgroundMusicVolume
{
return am.backgroundMusic.volume;
}
-(void) setBackgroundMusicVolume:(float) volume
{
am.backgroundMusic.volume = volume;
}
#pragma mark SimpleAudioEngine - EffectsVolume
-(float) effectsVolume
{
return am.soundEngine.masterGain;
}
-(void) setEffectsVolume:(float) volume
{
am.soundEngine.masterGain = volume;
}
-(CDSoundSource *) soundSourceForFile:(NSString*) filePath {
int soundId = [bufferManager bufferForFile:filePath create:YES];
if (soundId != kCDNoBuffer) {
CDSoundSource *result = [soundEngine soundSourceForSound:soundId sourceGroupId:0];
CDLOGINFO(@"Denshion::SimpleAudioEngine sound source created for %@",filePath);
return result;
} else {
return nil;
}
}
@end