Skip to content

Commit

Permalink
Created a new translation window. Will commit more frequently in the …
Browse files Browse the repository at this point in the history
…future. Check comments for explanations
  • Loading branch information
Benjamin Koatz committed Jun 18, 2014
1 parent 7b2699f commit 76a3633
Show file tree
Hide file tree
Showing 14 changed files with 1,804 additions and 2,280 deletions.
31 changes: 31 additions & 0 deletions SpriteBuilder/SpriteBuilder.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@
77E1995D13858DE0006C361B /* TabNewMetalRollover.png in Resources */ = {isa = PBXBuildFile; fileRef = 77E1995113858DE0006C361B /* TabNewMetalRollover.png */; };
77E7D04B138F777A00E8EE67 /* CCBModalSheetController.m in Sources */ = {isa = PBXBuildFile; fileRef = 77E7D04A138F777A00E8EE67 /* CCBModalSheetController.m */; };
77E7D04F138F78F600E8EE67 /* StageSizeWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 77E7D04E138F78F600E8EE67 /* StageSizeWindow.m */; };
7B5135C21947CC2500DE177D /* LocalizationInAppPurchasesPIDs.plist in Resources */ = {isa = PBXBuildFile; fileRef = 7B5135C11947CC2500DE177D /* LocalizationInAppPurchasesPIDs.plist */; };
7BCC1C0D194904190062DF38 /* StoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7BCC1C0C194904190062DF38 /* StoreKit.framework */; };
7BF55303193F8A7500183F09 /* LocalizationTranslateWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7BF55302193F8A7500183F09 /* LocalizationTranslateWindow.xib */; };
7BF55307193F912200183F09 /* LocalizationTranslateWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 7BF55306193F912200183F09 /* LocalizationTranslateWindow.m */; };
80271CCC1862478D00917BC0 /* InspectorStringSimple.m in Sources */ = {isa = PBXBuildFile; fileRef = 8076F94D18624318003C4153 /* InspectorStringSimple.m */; };
80279C7F183A8EAB005C6050 /* WarningCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 80E97F6318370F400052647D /* WarningCell.m */; };
8045F136183ADA900082BD94 /* seq-visible.png in Resources */ = {isa = PBXBuildFile; fileRef = 8045F12C183AD6D30082BD94 /* seq-visible.png */; };
Expand Down Expand Up @@ -1239,6 +1243,11 @@
77E7D04A138F777A00E8EE67 /* CCBModalSheetController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCBModalSheetController.m; sourceTree = "<group>"; };
77E7D04D138F78F600E8EE67 /* StageSizeWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StageSizeWindow.h; sourceTree = "<group>"; };
77E7D04E138F78F600E8EE67 /* StageSizeWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = StageSizeWindow.m; sourceTree = "<group>"; };
7B5135C11947CC2500DE177D /* LocalizationInAppPurchasesPIDs.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = LocalizationInAppPurchasesPIDs.plist; path = ../ccBuilder/LocalizationInAppPurchasesPIDs.plist; sourceTree = "<group>"; };
7BCC1C0C194904190062DF38 /* StoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = StoreKit.framework; path = System/Library/Frameworks/StoreKit.framework; sourceTree = SDKROOT; };
7BF55302193F8A7500183F09 /* LocalizationTranslateWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = LocalizationTranslateWindow.xib; sourceTree = "<group>"; };
7BF55305193F912100183F09 /* LocalizationTranslateWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LocalizationTranslateWindow.h; sourceTree = "<group>"; };
7BF55306193F912200183F09 /* LocalizationTranslateWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LocalizationTranslateWindow.m; sourceTree = "<group>"; };
800C005E1846A40D00544BD2 /* select-scale.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "select-scale.png"; sourceTree = "<group>"; };
800C006F1848178D00544BD2 /* select-crosshair.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "select-crosshair.png"; sourceTree = "<group>"; };
8045F12C183AD6D30082BD94 /* seq-visible.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "seq-visible.png"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2255,6 +2264,7 @@
7789ABE8133AB10500CEFCC7 /* ApplicationServices.framework in Frameworks */,
7789ABC3133AA82000CEFCC7 /* Cocoa.framework in Frameworks */,
E3AF6CDF15F0CF8B0048DB2A /* libMMMarkdown-Mac.a in Frameworks */,
7BCC1C0D194904190062DF38 /* StoreKit.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -3035,6 +3045,7 @@
7789ABC1133AA82000CEFCC7 /* Frameworks */ = {
isa = PBXGroup;
children = (
7BCC1C0C194904190062DF38 /* StoreKit.framework */,
D35E589D18E391DA008571EC /* GLKit.framework */,
D2E0168418D783C900927430 /* AppleScriptKit.framework */,
DC68033A189168390060BE39 /* SpriteKit.framework */,
Expand Down Expand Up @@ -3152,6 +3163,7 @@
7789ACEB133AB6A700CEFCC7 /* Resources */ = {
isa = PBXGroup;
children = (
7B5135C11947CC2500DE177D /* LocalizationInAppPurchasesPIDs.plist */,
DC0A8D3E18C8C274009A619D /* SpriteKitTextureAtlasToolPath.txt */,
B7AC69DB17A9D9700041B8BD /* defaultTemplates.zip */,
E390C780170A371E003E9E92 /* Generated */,
Expand Down Expand Up @@ -3394,6 +3406,9 @@
children = (
B7083DF717B1CBC8006628C7 /* LocalizationEditorHandler.h */,
B7083DF817B1CBC8006628C7 /* LocalizationEditorHandler.m */,
7BF55302193F8A7500183F09 /* LocalizationTranslateWindow.xib */,
7BF55305193F912100183F09 /* LocalizationTranslateWindow.h */,
7BF55306193F912200183F09 /* LocalizationTranslateWindow.m */,
B7083DF217B1C363006628C7 /* LocalizationEditorWindow.xib */,
B7083DF417B1CB88006628C7 /* LocalizationEditorWindow.h */,
B7083DF517B1CB88006628C7 /* LocalizationEditorWindow.m */,
Expand Down Expand Up @@ -5181,6 +5196,9 @@
7789ABBD133AA82000CEFCC7 = {
DevelopmentTeam = U2K5E32W7G;
SystemCapabilities = {
com.apple.InAppPurchase = {
enabled = 1;
};
com.apple.Sandbox = {
enabled = 1;
};
Expand Down Expand Up @@ -5434,6 +5452,7 @@
92F0960818F8851300D47A94 /* inspector-body-remove-hi.png in Resources */,
E35A2D8F1540111A00F78B72 /* position-2.png in Resources */,
E35A2D901540111A00F78B72 /* position-3.png in Resources */,
7B5135C21947CC2500DE177D /* LocalizationInAppPurchasesPIDs.plist in Resources */,
921EEADC18A5760700D864C2 /* joint-pivot.png in Resources */,
E3EDBC1615483EE000EEF1F3 /* ResolutionSettingsWindow.xib in Resources */,
E370BA0C1549B2460048ED73 /* scale-0.png in Resources */,
Expand Down Expand Up @@ -5604,6 +5623,7 @@
B7AC69B217A1969E0041B8BD /* header-bg2.png in Resources */,
B7AC69B417A1A2040041B8BD /* header-bg2-crop.png in Resources */,
B72D1DC0186125E80091252F /* Requirements.plist in Resources */,
7BF55303193F8A7500183F09 /* LocalizationTranslateWindow.xib in Resources */,
B7AC69C917A70A4B0041B8BD /* inspector-codeconnections.png in Resources */,
92D9D48318F8AB3800F167C1 /* [email protected] in Resources */,
926D13C918B5778300582959 /* [email protected] in Resources */,
Expand Down Expand Up @@ -6174,6 +6194,7 @@
E525FBA4E26414A8E6EBA77C /* PublishCCBOperation.m in Sources */,
E525F2C0B3311DCAEC86C6B0 /* PublishImageOperation.m in Sources */,
E525F3B510C25EE6D73F2C68 /* DateCache.m in Sources */,
7BF55307193F912200183F09 /* LocalizationTranslateWindow.m in Sources */,
E525F4E581031BFDE7E6DC9A /* NSString+Publishing.m in Sources */,
E525FA5D4791EB730859BF2C /* ProjectSettings+Convenience.m in Sources */,
E525F2137095DF73409AC768 /* PublishGeneratedFilesOperation.m in Sources */,
Expand Down Expand Up @@ -6842,6 +6863,9 @@
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_ENABLE_OBJC_ARC = YES;
CODE_SIGN_ENTITLEMENTS = SpriteBuilder.entitlements;
CODE_SIGN_IDENTITY = "Mac Developer";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Mac Developer";
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
Expand Down Expand Up @@ -6869,8 +6893,10 @@
"\"$(SRCROOT)/libs/Tupac\"",
"\"$(SRCROOT)/libs/PVRTexTool\"",
);
"OTHER_CODE_SIGN_FLAGS[sdk=*]" = "--deep";
OTHER_LDFLAGS = "-all_load";
PRODUCT_NAME = SpriteBuilder;
PROVISIONING_PROFILE = "3C61F300-140F-4802-AB93-852E91DF6DEB";
WRAPPER_EXTENSION = app;
};
name = Debug;
Expand All @@ -6881,6 +6907,9 @@
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_ENABLE_OBJC_ARC = YES;
CODE_SIGN_ENTITLEMENTS = SpriteBuilder.entitlements;
CODE_SIGN_IDENTITY = "Mac Developer";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Mac Developer";
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
Expand Down Expand Up @@ -6908,8 +6937,10 @@
"\"$(SRCROOT)/libs/Tupac\"",
"\"$(SRCROOT)/libs/PVRTexTool\"",
);
"OTHER_CODE_SIGN_FLAGS[sdk=*]" = "--deep";
OTHER_LDFLAGS = "-all_load";
PRODUCT_NAME = SpriteBuilder;
PROVISIONING_PROFILE = "3C61F300-140F-4802-AB93-852E91DF6DEB";
WRAPPER_EXTENSION = app;
};
name = Release;
Expand Down
1 change: 1 addition & 0 deletions SpriteBuilder/ccBuilder/LocalizationEditorHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
@property (nonatomic,readonly) NSMutableArray* languages;
@property (nonatomic,readonly) NSMutableArray* activeLanguages;
@property (nonatomic,readonly) NSMutableArray* translations;
@property (nonatomic,readonly) LocalizationEditorLanguage* currentLanguage;
@property (nonatomic,readonly) LocalizationEditorWindow* windowController;
@property (nonatomic,copy) NSString* managedFile;

Expand Down
1 change: 1 addition & 0 deletions SpriteBuilder/ccBuilder/LocalizationEditorHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

@implementation LocalizationEditorHandler

@synthesize currentLanguage;
@synthesize languages;
@synthesize activeLanguages;
@synthesize translations;
Expand Down
2 changes: 1 addition & 1 deletion SpriteBuilder/ccBuilder/LocalizationEditorLanguage.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#import <Foundation/Foundation.h>

@interface LocalizationEditorLanguage : NSObject
@interface LocalizationEditorLanguage : NSObject <NSCopying>

@property (nonatomic,copy) NSString* isoLangCode;
@property (nonatomic,copy) NSString* name;
Expand Down
26 changes: 26 additions & 0 deletions SpriteBuilder/ccBuilder/LocalizationEditorLanguage.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,31 @@ - (id) initWithIsoLangCode:(NSString*)code
return self;
}

/*
* Implemented in order to allow these languages to populate a mutable dictionary with
* the setObject:forKey: method
*/
-(id)copyWithZone:(NSZone *)zone{
LocalizationEditorLanguage* newLang = [[[self class] allocWithZone:zone] init];
newLang->_isoLangCode = _isoLangCode;
newLang->_name = _name;
newLang->_quickEdit = _quickEdit;
return newLang;
}

/*
* The two functions below were reimplemented in order to make comparing languages
* easier since we're only going to care if their name is the same.
*/
-(BOOL)isEqual:(id)object{
if([((LocalizationEditorLanguage *) object).name isEqualToString:self.name]){
return YES;
}
return NO;
}
- (NSUInteger)hash
{
return [_name hash];
}

@end
3 changes: 2 additions & 1 deletion SpriteBuilder/ccBuilder/LocalizationEditorTranslation.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
@interface LocalizationEditorTranslation : NSObject <NSPasteboardWriting>
{
NSMutableDictionary* _translations;
NSMutableArray* _languagesDownloading;
}

- (id) initWithSerialization:(id)ser;

@property (nonatomic,copy) NSString* key;
@property (nonatomic,copy) NSString* comment;

@property (nonatomic,copy) NSMutableArray* languagesDownloading;
@property (nonatomic,readonly) NSMutableDictionary* translations;

- (BOOL) hasTranslationsForLanguages:(NSArray*)languages;
Expand Down
4 changes: 2 additions & 2 deletions SpriteBuilder/ccBuilder/LocalizationEditorTranslation.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
@implementation LocalizationEditorTranslation

@synthesize translations = _translations;

@synthesize languagesDownloading = _languagesDownloading;
- (id) init
{
self = [super init];
if (!self) return NULL;

_translations = [[NSMutableDictionary alloc] init];

_languagesDownloading = [[NSMutableArray alloc] init];
return self;
}

Expand Down
3 changes: 3 additions & 0 deletions SpriteBuilder/ccBuilder/LocalizationEditorWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

#import <Foundation/Foundation.h>
@class LocalizationTranslateWindow;

@interface LocalizationEditorWindow : NSWindowController <NSTableViewDataSource, NSTableViewDelegate, NSTextViewDelegate, NSSplitViewDelegate>
{
Expand All @@ -15,6 +16,7 @@
IBOutlet NSPopUpButton* popLanguageAdd;
IBOutlet NSPopUpButton* popCurrentLanguage;
IBOutlet NSTextView* textInspectorKey;
LocalizationTranslateWindow* _ltw;
}

@property (nonatomic,assign) BOOL inspectorEnabled;
Expand All @@ -27,6 +29,7 @@

- (IBAction)pressedAdd:(id)sender;
- (IBAction)pressedAddGroup:(id)sender;
- (IBAction)pressedTranslate:(id)sender;

- (IBAction)selectedAddLanguage:(id)sender;
- (void)removeLanguagesAtIndexes:(NSIndexSet*)idxs;
Expand Down
38 changes: 36 additions & 2 deletions SpriteBuilder/ccBuilder/LocalizationEditorWindow.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
//
//

#import "LocalizationTranslateWindow.h"
#import "LocalizationEditorWindow.h"
#import "LocalizationEditorLanguage.h"
#import "LocalizationEditorHandler.h"
#import "LocalizationEditorTranslation.h"
#import "LocalizationEditorLanguageTableView.h"
#import "AppDelegate.h"
#import "CCBTextFieldCell.h"
#import "NSPasteboard+CCB.h"

@implementation LocalizationEditorWindow

#pragma mark Init and Updating stuff
Expand All @@ -26,6 +27,7 @@ - (void) awakeFromNib
[self updateLanguageSelectionMenu];
[self addLanguageColumns];
[self updateQuickEditLangs];

}

- (void) populateLanguageAddMenu
Expand Down Expand Up @@ -197,6 +199,19 @@ - (IBAction)pressedAdd:(id)sender
- (IBAction)pressedAddGroup:(id)sender
{}

/*
* Just displays a translate window.
* TODO Make the window key and main
*/
- (IBAction)pressedTranslate:(id)sender {
_ltw = [[LocalizationTranslateWindow alloc] initWithWindowNibName:@"LocalizationTranslateWindow"];
[[_ltw window] makeKeyAndOrderFront:nil];
}

/*
* If a language is added, do what is shown here but also reload the langauge menu on the
* language translation window if there is one open.
*/
- (IBAction)selectedAddLanguage:(id)sender
{
NSString* name = popLanguageAdd.selectedItem.title;
Expand All @@ -208,6 +223,8 @@ - (IBAction)selectedAddLanguage:(id)sender
[self updateLanguageSelectionMenu];
[self updateQuickEditLangs];
[self updateInspector];
if(_ltw)
[_ltw reloadLanguageMenu];

[handler setEdited];
}
Expand All @@ -234,6 +251,10 @@ - (void)removeLanguagesAtIndexes:(NSIndexSet*)idxs
- (IBAction)selectedCurrentLanguage:(id)sender
{
[self updateInspector];
}
- (void)alertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo {


}

- (void)removeTranslationsAtIndexes:(NSIndexSet*)idxs
Expand Down Expand Up @@ -411,13 +432,23 @@ - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColu
}
else
{
return [translation.translations objectForKey:aTableColumn.identifier];
if([translation.languagesDownloading containsObject:aTableColumn.identifier]){
[[aTableColumn dataCellForRow:rowIndex] setEnabled:0];
return @"Downloading...";
}else{
[[aTableColumn dataCellForRow:rowIndex] setEnabled:1];
return [translation.translations objectForKey:aTableColumn.identifier];
}
}
}

return NULL;
}

/*
* If a translation is updated, update the tableView in the translation window if there
* is one open.
*/
- (void) tableView:(NSTableView *)tableView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
LocalizationEditorHandler* handler = [AppDelegate appDelegate].localizationEditorHandler;
Expand Down Expand Up @@ -481,6 +512,8 @@ - (void) tableView:(NSTableView *)tableView setObjectValue:(id)object forTableCo
[tableTranslations reloadDataForRowIndexes:[NSIndexSet indexSetWithIndex:row] columnIndexes:[NSIndexSet indexSetWithIndex:0]];
[handler setEdited];
}
if(_ltw)
[_ltw reloadCost];
}

[self updateInspector];
Expand Down Expand Up @@ -602,6 +635,7 @@ - (void) textDidEndEditing:(NSNotification *)notification
{
[handler setEdited];
}

}

#pragma mark Split view delegate
Expand Down
Loading

0 comments on commit 76a3633

Please sign in to comment.