Skip to content

Commit

Permalink
Merge pull request #1566 from Catrobat/release-0.6.18
Browse files Browse the repository at this point in the history
Release 0.6.18
  • Loading branch information
m-herold authored Jan 10, 2021
2 parents 09c1b2a + 66899bd commit 00b2a3b
Show file tree
Hide file tree
Showing 350 changed files with 8,281 additions and 816 deletions.
2 changes: 1 addition & 1 deletion src/.swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ whitelist_rules:
#- implicitly_unwrapped_optional
- is_disjoint
- joined_default_parameter
- large_tuple
#- large_tuple
- leading_whitespace
- legacy_cggeometry_functions
- legacy_constant
Expand Down
1,687 changes: 1,312 additions & 375 deletions src/Catty.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

71 changes: 71 additions & 0 deletions src/Catty/DataModel/Bricks/Sound/SetInstrumentBrick.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/**
* Copyright (C) 2010-2020 The Catrobat Team
* (http://developer.catrobat.org/credits)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* An additional term exception under section 7 of the GNU Affero
* General Public License, version 3, is available at
* (http://developer.catrobat.org/license_additional_term)
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*/

import Foundation

@objc(SetInstrumentBrick) class SetInstrumentBrick: Brick, BrickStaticChoiceProtocol {

public var instrument: Instrument

override required init() {
self.instrument = AudioEngineDefines.defaultInstrument
super.init()
}

func category() -> kBrickCategoryType { kBrickCategoryType.soundBrick }

override func getRequiredResources() -> Int { ResourceType.noResources.rawValue }

override func description() -> String! { ("SetInstrumentBrick: \(self.instrument.tag)") }

func setDefaultValues(for spriteObject: SpriteObject!) {
self.instrument = AudioEngineDefines.defaultInstrument
}

func choice(forLineNumber lineNumber: Int, andParameterNumber paramNumber: Int) -> String! {
self.instrument.localizedName
}

func setChoice(_ localizedName: String!, forLineNumber lineNumber: Int, andParameterNumber paramNumber: Int) {
self.instrument = Instrument.from(localizedName: localizedName) ?? AudioEngineDefines.defaultInstrument
}

func possibleChoices(forLineNumber lineNumber: Int, andParameterNumber paramNumber: Int) -> [String] {
Instrument.allCases.map { $0.localizedName }
}

@objc(isEqualToBrick:)
override func isEqual(to brick: Brick) -> Bool {
guard let setInstrumentBrick = brick as? SetInstrumentBrick else {
return false
}

return self.instrument == setInstrumentBrick.instrument
}

@objc(mutableCopyWithContext:)
override func mutableCopy(with context: CBMutableCopyContext) -> Any {
let brick = SetInstrumentBrick()
brick.instrument = self.instrument
return brick
}
}
3 changes: 2 additions & 1 deletion src/Catty/DataModel/Project/Project.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
- (NSArray<SpriteObject*>* _Nonnull)allObjects;
- (BOOL)isEqualToProject:(Project* _Nonnull)project;
- (NSInteger)getRequiredResources;
-(void)changeProjectOrientation;
- (void)changeProjectOrientation;
- (void)updateReferences;

+ (instancetype _Nonnull)lastUsedProject;
+ (void)updateLastModificationTimeForProjectWithName:(NSString* _Nonnull)projectName
Expand Down
14 changes: 14 additions & 0 deletions src/Catty/DataModel/Project/Project.m
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,20 @@ - (NSString*)description
return [ret copy];
}

- (void)updateReferences
{
NSArray <SpriteObject*> *allObjects = [[NSMutableArray alloc] initWithArray: self.allObjects];
for (SpriteObject *sprite in allObjects) {
sprite.scene.project = self;
for (Script *script in sprite.scriptList) {
script.object = sprite;
for (Brick *brick in script.brickList) {
brick.script = script;
}
}
}
}

#pragma mark - Manager

+ (NSString*)projectDirectoryNameForProjectName:(NSString*)projectName projectID:(NSString*)projectID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@
* along with this program. If not, see http://www.gnu.org/licenses/.
*/

#import "Project.h"
enum AudioEngineDefines {

@interface Project (CustomExtensions)
static let defaultInstrument = Instrument.piano

- (void)updateReferences;

@end
}
26 changes: 26 additions & 0 deletions src/Catty/Defines/LanguageTranslationDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@
#define kLocalizedStopAllSounds NSLocalizedString(@"Stop all sounds", nil)
#define kLocalizedSetVolumeTo NSLocalizedString(@"Set volume to", nil)
#define kLocalizedChangeVolumeBy NSLocalizedString(@"Change volume by", nil)
#define kLocalizedSetInstrumentTo NSLocalizedString(@"Set Instrument to", nil)
#define kLocalizedSay NSLocalizedString(@"Say", nil)
#define kLocalizedThink NSLocalizedString(@"Think", nil)
#define kLocalizedSpeak NSLocalizedString(@"Speak", nil)
Expand Down Expand Up @@ -794,6 +795,31 @@
#define kLocalizedUnexpectedErrorTitle NSLocalizedString(@"Unexpected Error", nil)
#define kLocalizedUnexpectedErrorMessage NSLocalizedString(@"Unexpected Error, please try again later.", nil)

//************************************************************************************************************
//************************************** Audio Engine *********************************************
//************************************************************************************************************

#define kLocalizedPiano NSLocalizedString(@"Piano", nil)
#define kLocalizedElectricPiano NSLocalizedString(@"Electric Piano", nil)
#define kLocalizedCello NSLocalizedString(@"Cello", nil)
#define kLocalizedFlute NSLocalizedString(@"Flute", nil)
#define kLocalizedVibraphone NSLocalizedString(@"Vibraphone", nil)
#define kLocalizedOrgan NSLocalizedString(@"Organ", nil)
#define kLocalizedGuitar NSLocalizedString(@"Guitar", nil)
#define kLocalizedElectricGuitar NSLocalizedString(@"Electric Guitar", nil)
#define kLocalizedBass NSLocalizedString(@"Bass", nil)
#define kLocalizedPizzicato NSLocalizedString(@"Pizzicato", nil)
#define kLocalizedSynthPad NSLocalizedString(@"Synth Pad", nil)
#define kLocalizedChoir NSLocalizedString(@"Choir", nil)
#define kLocalizedSynthLead NSLocalizedString(@"Synth Lead", nil)
#define kLocalizedWoodenFlute NSLocalizedString(@"Wooden Flute", nil)
#define kLocalizedTrombone NSLocalizedString(@"Trombone", nil)
#define kLocalizedSaxophone NSLocalizedString(@"Saxophone", nil)
#define kLocalizedBassoon NSLocalizedString(@"Bassoon", nil)
#define kLocalizedClarinet NSLocalizedString(@"Clarinet", nil)
#define kLocalizedMusicBox NSLocalizedString(@"Music Box", nil)
#define kLocalizedSteelDrum NSLocalizedString(@"Steel Drum", nil)
#define kLocalizedMarimba NSLocalizedString(@"Marimba", nil)
//************************************************************************************************************
//**************************************** Debug ************************************************
//************************************************************************************************************
Expand Down
26 changes: 26 additions & 0 deletions src/Catty/Defines/LanguageTranslationDefinesSwift.swift
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ let kLocalizedPlaySoundAndWait = NSLocalizedString("Start sound and wait", comme
let kLocalizedStopAllSounds = NSLocalizedString("Stop all sounds", comment: "")
let kLocalizedSetVolumeTo = NSLocalizedString("Set volume to", comment: "")
let kLocalizedChangeVolumeBy = NSLocalizedString("Change volume by", comment: "")
let kLocalizedSetInstrumentTo = NSLocalizedString("Set Instrument to", comment: "")
let kLocalizedSay = NSLocalizedString("Say", comment: "")
let kLocalizedThink = NSLocalizedString("Think", comment: "")
let kLocalizedSpeak = NSLocalizedString("Speak", comment: "")
Expand Down Expand Up @@ -794,6 +795,31 @@ let kLocalizedServerTimeoutIssueMessage = NSLocalizedString("Server is taking to
let kLocalizedUnexpectedErrorTitle = NSLocalizedString("Unexpected Error", comment: "")
let kLocalizedUnexpectedErrorMessage = NSLocalizedString("Unexpected Error, please try again later.", comment: "")

//************************************************************************************************************
//************************************** Audio Engine *********************************************
//************************************************************************************************************

let kLocalizedPiano = NSLocalizedString("Piano", comment: "")
let kLocalizedElectricPiano = NSLocalizedString("Electric Piano", comment: "")
let kLocalizedCello = NSLocalizedString("Cello", comment: "")
let kLocalizedFlute = NSLocalizedString("Flute", comment: "")
let kLocalizedVibraphone = NSLocalizedString("Vibraphone", comment: "")
let kLocalizedOrgan = NSLocalizedString("Organ", comment: "")
let kLocalizedGuitar = NSLocalizedString("Guitar", comment: "")
let kLocalizedElectricGuitar = NSLocalizedString("Electric Guitar", comment: "")
let kLocalizedBass = NSLocalizedString("Bass", comment: "")
let kLocalizedPizzicato = NSLocalizedString("Pizzicato", comment: "")
let kLocalizedSynthPad = NSLocalizedString("Synth Pad", comment: "")
let kLocalizedChoir = NSLocalizedString("Choir", comment: "")
let kLocalizedSynthLead = NSLocalizedString("Synth Lead", comment: "")
let kLocalizedWoodenFlute = NSLocalizedString("Wooden Flute", comment: "")
let kLocalizedTrombone = NSLocalizedString("Trombone", comment: "")
let kLocalizedSaxophone = NSLocalizedString("Saxophone", comment: "")
let kLocalizedBassoon = NSLocalizedString("Bassoon", comment: "")
let kLocalizedClarinet = NSLocalizedString("Clarinet", comment: "")
let kLocalizedMusicBox = NSLocalizedString("Music Box", comment: "")
let kLocalizedSteelDrum = NSLocalizedString("Steel Drum", comment: "")
let kLocalizedMarimba = NSLocalizedString("Marimba", comment: "")
//************************************************************************************************************
//**************************************** Debug ************************************************
//************************************************************************************************************
Expand Down
31 changes: 31 additions & 0 deletions src/Catty/Defines/LaunchArguments.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Copyright (C) 2010-2020 The Catrobat Team
* (http://developer.catrobat.org/credits)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* An additional term exception under section 7 of the GNU Affero
* General Public License, version 3, is available at
* (http://developer.catrobat.org/license_additional_term)
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*/

@objc
class LaunchArguments: NSObject {

static let UITests = "UITests"
static let disableAnimations = "disableAnimations"
static let restoreDefaultProject = "restoreDefaultProject"
@objc static let skipPrivacyPolicy = "skipPrivacyPolicy"

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#import "CBXMLParser.h"
#import "GDataXMLNode.h"
#import "Project+CBXMLHandler.h"
#import "Project+CustomExtensions.h"
#import "CBXMLParserContext.h"
#import "Util.h"
#import "Pocket_Code-Swift.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ + (instancetype)parseFromElement:(GDataXMLElement*)xmlElement withContext:(CBXML
- (GDataXMLElement*)xmlElementWithContext:(CBXMLSerializerContext*)context
{
GDataXMLElement *brick = [super xmlElementForBrickType:@"HideTextBrick" withContext:context];

Formula *formulaForCatroidCompatibility = [[Formula alloc] initWithZero];
GDataXMLElement *formulaList = [GDataXMLElement elementWithName:@"formulaList" context:context];
GDataXMLElement *formula = [formulaForCatroidCompatibility xmlElementWithContext:context];
[formula addAttribute:[GDataXMLElement attributeWithName:@"category" escapedStringValue:@"Y_POSITION"]];
[formulaList addChild:formula context:context];
formula = [formulaForCatroidCompatibility xmlElementWithContext:context];
[formula addAttribute:[GDataXMLElement attributeWithName:@"category" escapedStringValue:@"X_POSITION"]];
[formulaList addChild:formula context:context];
[brick addChild:formulaList context:context];

if (self.userVariable) {
[brick addChild:[self.userVariable xmlElementWithContext:context] context:context];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#import "FlashBrick+CBXMLHandler.h"
#import "GDataXMLElement+CustomExtensions.h"
#import "GDataXMLNode+CustomExtensions.h"
#import "CBXMLValidator.h"
#import "CBXMLParserHelper.h"
#import "CBXMLParserContext.h"
Expand All @@ -41,7 +42,16 @@ + (instancetype)parseFromElement:(GDataXMLElement*)xmlElement withContext:(CBXML
} else if([brickType rangeOfString:@"LedOnBrick"].location != NSNotFound){
flashBrick.flashChoice = 1;
} else if([brickType rangeOfString:@"FlashBrick"].location != NSNotFound){
[CBXMLParserHelper validateXMLElement:xmlElement forNumberOfChildNodes:2];
NSUInteger childCount = [[xmlElement childrenWithoutCommentsAndCommentedOutTag] count];

if (childCount != 1 && childCount != 2) {
[XMLError exceptionWithMessage:@"Wrong number of child elements for FlashBrick"];
} else if (childCount == 2) {
GDataXMLElement *spinnerValuesElement = [xmlElement childWithElementName:@"spinnerValues"];
[XMLError exceptionIfNil:spinnerValuesElement
message:@"FlashBrick element does not contain a spinnerValues child element!"];
}

GDataXMLElement *flashChoiceElement = [xmlElement childWithElementName:@"spinnerSelectionID"];
[XMLError exceptionIfNil:flashChoiceElement
message:@"FlashBrick element does not contain a spinnerSelectionID child element!"];
Expand Down Expand Up @@ -69,14 +79,8 @@ - (GDataXMLElement*)xmlElementWithContext:(CBXMLSerializerContext*)context

GDataXMLElement *brick = [super xmlElementForBrickType:@"FlashBrick" withContext:context];
GDataXMLElement *spinnerID = [GDataXMLElement elementWithName:@"spinnerSelectionID" stringValue:numberString context:context];
GDataXMLElement *offString = [GDataXMLElement elementWithName:@"string" stringValue:@"off" context:context];
GDataXMLElement *onString = [GDataXMLElement elementWithName:@"string" stringValue:@"on" context:context];
GDataXMLElement *spinnerValues = [GDataXMLElement elementWithName:@"spinnerValues" context:context];

[spinnerValues addChild:offString context:context];
[spinnerValues addChild:onString context:context];
[brick addChild:spinnerID context:context];
[brick addChild:spinnerValues context:context];
return brick;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ + (instancetype)parseFromElement:(GDataXMLElement*)xmlElement withContext:(CBXML
NSString *brickType = [xmlElement XMLRootElementAsString];
CameraBrick *cameraBrick = [self new];

if([brickType rangeOfString:@"CameraBrick"].location != NSNotFound){
if([brickType rangeOfString:@"CameraBrick"].location != NSNotFound) {

NSUInteger childCount = [[xmlElement childrenWithoutCommentsAndCommentedOutTag] count];

if (childCount != 1 && childCount != 2) {
[XMLError exceptionWithMessage:@"Camera Brick is faulty"];
[XMLError exceptionWithMessage:@"Wrong number of child elements for CameraBrick"];
} else if (childCount == 2) {
GDataXMLElement *spinnerValuesElement = [xmlElement childWithElementName:@"spinnerValues"];
[XMLError exceptionIfNil:spinnerValuesElement
Expand Down Expand Up @@ -75,16 +75,7 @@ - (GDataXMLElement*)xmlElementWithContext:(CBXMLSerializerContext*)context

NSString *numberString = [NSString stringWithFormat:@"%i", self.cameraChoice];
GDataXMLElement *spinnerID = [GDataXMLElement elementWithName:@"spinnerSelectionID" stringValue:numberString context:context];
GDataXMLElement *spinnerValues = [GDataXMLElement elementWithName:@"spinnerValues" context:context];

GDataXMLElement *off = [GDataXMLElement elementWithName:@"string" stringValue:@"off" context:context];
GDataXMLElement *on = [GDataXMLElement elementWithName:@"string" stringValue:@"on" context:context];

[spinnerValues addChild:off context:context];
[spinnerValues addChild:on context:context];

[brick addChild:spinnerID context:context];
[brick addChild:spinnerValues context:context];

return brick;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ + (instancetype)parseFromElement:(GDataXMLElement*)xmlElement withContext:(CBXML
NSUInteger childrenCount = [[xmlElement childrenWithoutCommentsAndCommentedOutTag] count];
if (childrenCount != 1 && childrenCount != 2) {
[XMLError exceptionWithMessage:@"Wrong number of child elements for ChooseCameraBrick"];
} else if (childrenCount == 2) {
GDataXMLElement *spinnerValuesElement = [xmlElement childWithElementName:@"spinnerValues"];
[XMLError exceptionIfNil:spinnerValuesElement
message:@"ChooseCameraBrick element does not contain a spinnerValues child element!"];
}

GDataXMLElement *cameraChoiceElement = [xmlElement childWithElementName:@"spinnerSelectionID"];
Expand Down Expand Up @@ -70,14 +74,8 @@ - (GDataXMLElement*)xmlElementWithContext:(CBXMLSerializerContext*)context

NSString *numberString = [NSString stringWithFormat:@"%i", self.cameraPosition];
GDataXMLElement *spinnerID = [GDataXMLElement elementWithName:@"spinnerSelectionID" stringValue:numberString context:context];
GDataXMLElement *backString = [GDataXMLElement elementWithName:@"string" stringValue:@"back" context:context];
GDataXMLElement *frontString = [GDataXMLElement elementWithName:@"string" stringValue:@"front" context:context];
GDataXMLElement *spinnerValues = [GDataXMLElement elementWithName:@"spinnerValues" context:context];

[spinnerValues addChild:backString context:context];
[spinnerValues addChild:frontString context:context];
[brick addChild:spinnerID context:context];
[brick addChild:spinnerValues context:context];

return brick;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,17 @@

extension AskBrick: CBXMLNodeProtocol {
static func parse(from xmlElement: GDataXMLElement, with context: CBXMLParserContext) -> Self {
CBXMLParserHelper.validate(xmlElement, forNumberOfChildNodes: 2, andFormulaListWithTotalNumberOfFormulas: 1)
let formula = CBXMLParserHelper.formula(in: xmlElement, forCategoryName: "ASK_QUESTION", with: context)
let xmlVariable = xmlElement.child(withElementName: "userVariable")
let userVariable = context.parse(from: xmlVariable, withClass: UserVariable.self)
CBXMLParserHelper.validate(xmlElement, forFormulaListWithTotalNumberOfFormulas: 1)

let brick = self.init()
let formula = CBXMLParserHelper.formula(in: xmlElement, forCategoryName: "ASK_QUESTION", with: context)
brick.question = formula
brick.userVariable = userVariable as? UserVariable

let xmlVariable = xmlElement.child(withElementName: "userVariable")
if xmlVariable != nil {
let userVariable = context.parse(from: xmlVariable, withClass: UserVariable.self)
brick.userVariable = userVariable as? UserVariable
}

return brick
}
Expand Down
Loading

0 comments on commit 00b2a3b

Please sign in to comment.