diff --git a/ogl_editor/src/Commands.c b/ogl_editor/src/Commands.c index 6ccb438..5c43b9c 100644 --- a/ogl_editor/src/Commands.c +++ b/ogl_editor/src/Commands.c @@ -582,7 +582,8 @@ static void toggleMute(void* userData) else { struct track_key defKey; - int i, keysSize = sizeof(struct track_key) * data->syncTrack->num_keys; + int i; + size_t keysSize = sizeof(struct track_key) * data->syncTrack->num_keys; float currentValue = (float)sync_get_val(data->syncTrack, data->row); data->track->disabled = true; diff --git a/ogl_editor/src/Editor.c b/ogl_editor/src/Editor.c index e965610..d9dd285 100644 --- a/ogl_editor/src/Editor.c +++ b/ogl_editor/src/Editor.c @@ -182,7 +182,7 @@ static inline int getActiveTrack() static inline int getTrackCount() { - return s_editorData.trackData.num_syncTracks; + return (int)s_editorData.trackData.num_syncTracks; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1631,7 +1631,7 @@ static void onPrevNextKey(bool prevKey, enum Selection selection) if (idx < 0) row = track->keys[0].row; - else if (idx > (int)track->num_keys - 2) + else if (idx > track->num_keys - 2) row = track->keys[track->num_keys - 1].row; else row = track->keys[idx + 1].row; diff --git a/ogl_editor/src/RemoteConnection.c b/ogl_editor/src/RemoteConnection.c index cd9c2d4..f2226b5 100644 --- a/ogl_editor/src/RemoteConnection.c +++ b/ogl_editor/src/RemoteConnection.c @@ -493,7 +493,7 @@ void RemoteConnection_sendKeyFrames(const char* name, struct sync_track* track) if (!RemoteConnection_connected() || track_id == -1) return; - for (i = 0; i < (int)track->num_keys; ++i) + for (i = 0; i < track->num_keys; ++i) sendSetKeyCommandIndex((uint32_t)track_id, &track->keys[i]); } diff --git a/ogl_editor/src/loadsave.c b/ogl_editor/src/loadsave.c index ab79a33..240da73 100644 --- a/ogl_editor/src/loadsave.c +++ b/ogl_editor/src/loadsave.c @@ -338,7 +338,7 @@ static void saveTrackData(mxml_node_t* track, struct track_key* keys, int count) for (i = 0; i < count; ++i) { mxml_node_t* key = mxmlNewElement(track, "key"); - setElementInt(key, "row", "%d", (int)keys[i].row); + setElementInt(key, "row", "%d", keys[i].row); setElementFloat(key, "value", keys[i].value); setElementInt(key, "interpolation", "%d", (int)keys[i].type); } @@ -428,7 +428,7 @@ int LoadSave_saveRocketXML(const text_t* path, TrackData* trackData) } else { - saveTrackData(track, t->keys, (int)t->num_keys); + saveTrackData(track, t->keys, t->num_keys); } } diff --git a/ogl_editor/src/macosx/FileDialog.m b/ogl_editor/src/macosx/FileDialog.m index f6b1f8f..6c7ade4 100644 --- a/ogl_editor/src/macosx/FileDialog.m +++ b/ogl_editor/src/macosx/FileDialog.m @@ -10,9 +10,9 @@ int Dialog_open(char* dest) NSOpenPanel* open = [NSOpenPanel openPanel]; [open setAllowsMultipleSelection:NO]; - int result = [open runModal]; + NSInteger result = [open runModal]; - if (result != NSOKButton) + if (result != NSModalResponseOK) return false; // Grab the first file @@ -35,9 +35,9 @@ int Dialog_save(char* dest) NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NSSavePanel* open = [NSSavePanel savePanel]; - int result = [open runModal]; + NSInteger result = [open runModal]; - if (result != NSOKButton) + if (result != NSModalResponseOK) return false; // Grab the first file @@ -149,7 +149,12 @@ void Dialog_showError(const text_t* text) NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; NSString* message = [[[NSString alloc] initWithUTF8String:text] autorelease];// convert - NSRunAlertPanel(@"Error", message, @"Ok", @"", @""); + NSAlert *alert = [[NSAlert alloc] init]; + [alert addButtonWithTitle:@"OK"]; + [alert setMessageText:message]; + [alert setAlertStyle:NSCriticalAlertStyle]; + [alert runModal]; + [alert release]; [pool drain]; } diff --git a/ogl_editor/src/macosx/delegate.h b/ogl_editor/src/macosx/RocketAppDelegate.h similarity index 100% rename from ogl_editor/src/macosx/delegate.h rename to ogl_editor/src/macosx/RocketAppDelegate.h diff --git a/ogl_editor/src/macosx/delegate.m b/ogl_editor/src/macosx/RocketAppDelegate.m similarity index 76% rename from ogl_editor/src/macosx/delegate.m rename to ogl_editor/src/macosx/RocketAppDelegate.m index f984153..f861b26 100644 --- a/ogl_editor/src/macosx/delegate.m +++ b/ogl_editor/src/macosx/RocketAppDelegate.m @@ -1,4 +1,4 @@ -#import "delegate.h" +#import "RocketAppDelegate.h" #include "../Editor.h" #include "../RemoteConnection.h" #include "rlog.h" @@ -15,23 +15,33 @@ void Window_buildMenu(); - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender { + NSUInteger exitcode = NSTerminateNow; + if (!Editor_needsSave()) - return NSTerminateNow; + return exitcode; - int ret = NSRunAlertPanel(@"Save before exit?", @"Do you want save the work?", @"Yes", @"Cancel", @"No"); + NSAlert *alert = [[NSAlert alloc] init]; + [alert addButtonWithTitle:@"Yes"]; + [alert addButtonWithTitle:@"No"]; + [alert addButtonWithTitle:@"Cancel"]; + [alert setMessageText:@"Save before exit?"]; + [alert setInformativeText:@"Do you want save the work?"]; + [alert setAlertStyle:NSWarningAlertStyle]; - if (ret == NSAlertDefaultReturn) + NSModalResponse ret = [alert runModal]; + + if (ret == NSAlertFirstButtonReturn) { if (!Editor_saveBeforeExit()) - return NSTerminateCancel; - - return NSTerminateNow; + exitcode = NSTerminateCancel; } - if (ret == NSAlertAlternateReturn) - return NSTerminateCancel; + if (ret == NSAlertThirdButtonReturn) + exitcode = NSTerminateCancel; - return NSTerminateNow; + [alert release]; + + return exitcode; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -87,6 +97,7 @@ void Window_buildMenu(); Editor_destroy(); RemoteConnection_close(); + [stringArray release]; } @end diff --git a/ogl_editor/src/macosx/RocketView.m b/ogl_editor/src/macosx/RocketView.m index 5486b38..16c98a6 100644 --- a/ogl_editor/src/macosx/RocketView.m +++ b/ogl_editor/src/macosx/RocketView.m @@ -7,8 +7,8 @@ #include #include -NSOpenGLContext* g_context = 0; -NSWindow* g_window = 0; +NSOpenGLContext* g_context = nil; +NSWindow* g_window = nil; void Window_setTitle(const char* title); @@ -52,13 +52,14 @@ void Window_setTitle(const char* title); if (self == nil) return nil; - NSOpenGLPixelFormatAttribute attributes[4]; - - attributes[0] = NSOpenGLPFADoubleBuffer; - attributes[1] = 0; + NSOpenGLPixelFormatAttribute attributes[] = { + NSOpenGLPFADoubleBuffer, + 0 + }; NSOpenGLPixelFormat* format = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes]; oglContext = [[NSOpenGLContext alloc] initWithFormat:format shareContext:nil]; + [format release]; [oglContext makeCurrentContext]; g_context = oglContext; @@ -185,6 +186,7 @@ static int getModifierFlags(int flags) owner:self userInfo:nil]; [self addTrackingArea:trackingArea]; + [trackingArea release]; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -296,7 +298,7 @@ CFStringRef createStringForKey(CGKeyCode keyCode) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -static int s_characterToKeyCode[] = +static CGKeyCode s_characterToKeyCode[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x27, // ''' @@ -383,11 +385,11 @@ NSString* convertKeyCodeToString(int key) case EMGUI_KEY_BACKSPACE : return [NSString stringWithFormat:@"%C",(uint16_t)0x232b]; case EMGUI_KEY_TAB : return [NSString stringWithFormat:@"%C",(uint16_t)0x21e4]; case EMGUI_KEY_PAGE_UP : return [NSString stringWithFormat:@"%C",(uint16_t)0x21de]; - case EMGUI_KEY_PAGE_DOWN : return [NSString stringWithFormat:@"%C",(uint16_t)0x21df]; + case EMGUI_KEY_PAGE_DOWN : return [NSString stringWithFormat:@"%C",(uint16_t)0x21df]; } } - return 0; + return nil; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -407,8 +409,8 @@ void buildSubMenu(NSMenu* menu, MenuDescriptor menuDesc[]) } else if (desc->id == EDITOR_MENU_SUB_MENU) { - MyMenuItem* newItem = [[MyMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:name action:NULL keyEquivalent:@""]; - NSMenu* newMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:name]; + MyMenuItem* newItem = [[MyMenuItem alloc] initWithTitle:name action:NULL keyEquivalent:@""]; + NSMenu* newMenu = [[NSMenu alloc] initWithTitle:name]; [newItem setSubmenu:newMenu]; [newMenu release]; [menu addItem:newItem]; @@ -416,7 +418,7 @@ void buildSubMenu(NSMenu* menu, MenuDescriptor menuDesc[]) } else { - int mask = 0; + NSUInteger mask = 0; MyMenuItem* newItem = [[MyMenuItem alloc] initWithTitle:name action:@selector(onMenuPress:) keyEquivalent:@""]; [newItem setTag:desc->id]; diff --git a/ogl_editor/src/macosx/main.m b/ogl_editor/src/macosx/main.m index bc3b4aa..41c4b04 100644 --- a/ogl_editor/src/macosx/main.m +++ b/ogl_editor/src/macosx/main.m @@ -1,7 +1,6 @@ -#import #import -int main(int argc, char *argv[]) +int main(int argc, const char * argv[]) { - return NSApplicationMain(argc, (const char **) argv); + return NSApplicationMain(argc, argv); }