# HG changeset patch # User koda # Date 1279795652 -7200 # Node ID 8c28abf427f50a16fe7e1a7c6db3dafceb796b32 # Parent a44406f4369b4002ccade64bc74392a67ea6c852 reduce the number of keywords used and switch to BMP format for screenshots fixed a few little things from previous commit diff -r a44406f4369b -r 8c28abf427f5 hedgewars/CCHandlers.inc --- a/hedgewars/CCHandlers.inc Thu Jul 22 03:08:17 2010 +0200 +++ b/hedgewars/CCHandlers.inc Thu Jul 22 12:47:32 2010 +0200 @@ -439,10 +439,6 @@ Message:= Message or gm_Switch end; -{$IFDEF IPHONEOS} -procedure clearView; cdecl; external; -{$ENDIF} - procedure chNextTurn(var s: shortstring); begin s:= s; // avoid compiler hint diff -r a44406f4369b -r 8c28abf427f5 hedgewars/SDLh.pas --- a/hedgewars/SDLh.pas Thu Jul 22 03:08:17 2010 +0200 +++ b/hedgewars/SDLh.pas Thu Jul 22 12:47:32 2010 +0200 @@ -840,6 +840,13 @@ procedure SDLNet_Write32(value: LongWord; buf: pointer); function SDLNet_Read16(buf: pointer): Word; function SDLNet_Read32(buf: pointer): LongWord; + +{$IFDEF IPHONEOS} +(* iPhone related calls *) +procedure clearView; cdecl; external; +procedure startSpinning; cdecl; external; +procedure stopSpinning; cdecl; external; +{$ENDIF} implementation function SDL_MustLock(Surface: PSDL_Surface): Boolean; diff -r a44406f4369b -r 8c28abf427f5 hedgewars/hwengine.pas --- a/hedgewars/hwengine.pas Thu Jul 22 03:08:17 2010 +0200 +++ b/hedgewars/hwengine.pas Thu Jul 22 12:47:32 2010 +0200 @@ -49,9 +49,7 @@ //////////////////////////////// procedure DoTimer(Lag: LongInt); -{$IFNDEF IPHONEOS} var s: shortstring; -{$ENDIF} begin if not isPaused then inc(RealTicks, Lag); @@ -108,7 +106,6 @@ {$ELSE} SDL_GL_SwapBuffers(); {$ENDIF} -{$IFNDEF IPHONEOS} // not going to make captures on the iPhone if flagMakeCapture then begin @@ -118,7 +115,6 @@ MakeScreenshot(s); //SDL_SaveBMP_RW(SDLPrimSurface, SDL_RWFromFile(Str2PChar(s), 'wb'), 1) end; -{$ENDIF} end; //////////////////// @@ -157,6 +153,8 @@ KeyPressChat(event.key.keysym.sym); {$ELSE} KeyPressChat(event.key.keysym.unicode); + SDL_MOUSEBUTTONDOWN: if event.button.button = SDL_BUTTON_WHEELDOWN then uKeys.wheelDown:= true; + SDL_MOUSEBUTTONUP: if event.button.button = SDL_BUTTON_WHEELUP then uKeys.wheelUp:= true; {$ENDIF} {$IFDEF SDL13} SDL_WINDOWEVENT: @@ -167,10 +165,6 @@ if (event.active.state and SDL_APPINPUTFOCUS) <> 0 then cHasFocus:= event.active.gain = 1; {$ENDIF} -{$IFNDEF IPHONEOS} - SDL_MOUSEBUTTONDOWN: if event.button.button = SDL_BUTTON_WHEELDOWN then uKeys.wheelDown:= true; - SDL_MOUSEBUTTONUP: if event.button.button = SDL_BUTTON_WHEELUP then uKeys.wheelUp:= true; -{$ENDIF} SDL_JOYAXISMOTION: ControllerAxisEvent(event.jaxis.which, event.jaxis.axis, event.jaxis.value); SDL_JOYHATMOTION: ControllerHatEvent(event.jhat.which, event.jhat.hat, event.jhat.value); SDL_JOYBUTTONDOWN: ControllerButtonEvent(event.jbutton.which, event.jbutton.button, true); diff -r a44406f4369b -r 8c28abf427f5 hedgewars/uGame.pas --- a/hedgewars/uGame.pas Thu Jul 22 03:08:17 2010 +0200 +++ b/hedgewars/uGame.pas Thu Jul 22 12:47:32 2010 +0200 @@ -62,9 +62,7 @@ end; gmtSave: begin RestoreTeamsFromSave; -{$IFNDEF IPHONEOS} SetBinds(CurrentTeam^.Binds); -{$ENDIF} //CurrentHedgehog^.Gear^.Message:= 0; <- produces bugs with further save restoring and demos isSoundEnabled:= isSEBackup; GameType:= gmtLocal diff -r a44406f4369b -r 8c28abf427f5 hedgewars/uKeys.pas --- a/hedgewars/uKeys.pas Thu Jul 22 03:08:17 2010 +0200 +++ b/hedgewars/uKeys.pas Thu Jul 22 12:47:32 2010 +0200 @@ -354,7 +354,11 @@ procedure SetBinds(var binds: TBinds); begin +{$IFDEF IPHONEOS} + CurrentBinds:= DefaultBinds; +{$ELSE} CurrentBinds:= binds; +{$ENDIF} end; procedure SetDefaultBinds; @@ -408,13 +412,13 @@ procedure ControllerInit; var i, j: Integer; begin -{$IFNDEF IPHONEOS} -SDL_InitSubSystem(SDL_INIT_JOYSTICK); +ControllerEnabled:= 0; +{$IFDEF IPHONEOS} +exit; // joystick subsystem disabled on iPhone {$ENDIF} -ControllerEnabled:= 0; +SDL_InitSubSystem(SDL_INIT_JOYSTICK); ControllerNumControllers:= SDL_NumJoysticks(); - if ControllerNumControllers > 6 then ControllerNumControllers:= 6; WriteLnToConsole('Number of game controllers: ' + inttostr(ControllerNumControllers)); diff -r a44406f4369b -r 8c28abf427f5 hedgewars/uMisc.pas --- a/hedgewars/uMisc.pas Thu Jul 22 03:08:17 2010 +0200 +++ b/hedgewars/uMisc.pas Thu Jul 22 12:47:32 2010 +0200 @@ -177,9 +177,7 @@ procedure AddFileLog(s: shortstring); function RectToStr(Rect: TSDL_Rect): shortstring; {$ENDIF} -{$IFNDEF IPHONEOS} procedure MakeScreenshot(filename: shortstring); -{$ENDIF} implementation uses uConsole, uStore, uIO, uSound, typinfo, sysutils; @@ -560,15 +558,10 @@ byte(DecodeBase64[0]):= t - 1 end; -{$IFNDEF IPHONEOS} procedure MakeScreenshot(filename: shortstring); var p: Pointer; size: Longword; f: file; -{$IFNDEF WIN32} - // TGA Header - head: array[0..8] of Word = (0, 2, 0, 0, 0, 0, 0, 0, 24); -{$ELSE} // Windows Bitmap Header head: array[0..53] of Byte = ( $42, $4D, // identifier ("BM") @@ -587,7 +580,6 @@ 0, 0, 0, 0, // number of colors (all) 0, 0, 0, 0 // number of important colors ); -{$ENDIF} begin playSound(sndShutter); @@ -600,12 +592,7 @@ p:= GetMem(size); // update header information and file name -{$IFNDEF WIN32} -filename:= ParamStr(1) + '/Screenshots/' + filename + '.tga'; -head[6]:= cScreenWidth; -head[7]:= cScreenHeight; -{$ELSE} filename:= ParamStr(1) + '/Screenshots/' + filename + '.bmp'; head[$02]:= (size + 54) and $ff; @@ -624,10 +611,9 @@ head[$23]:= (size shr 8) and $ff; head[$24]:= (size shr 16) and $ff; head[$25]:= (size shr 24) and $ff; -{$ENDIF} //remember that opengles operates on a single surface, so GL_FRONT *should* be implied -glReadBuffer(GL_FRONT); +//glReadBuffer(GL_FRONT); glReadPixels(0, 0, cScreenWidth, cScreenHeight, GL_BGR, GL_UNSIGNED_BYTE, p); {$I-} @@ -643,7 +629,6 @@ FreeMem(p) end; -{$ENDIF} {$IFDEF DEBUGFILE} procedure AddFileLog(s: shortstring); diff -r a44406f4369b -r 8c28abf427f5 hedgewars/uStore.pas --- a/hedgewars/uStore.pas Thu Jul 22 03:08:17 2010 +0200 +++ b/hedgewars/uStore.pas Thu Jul 22 12:47:32 2010 +0200 @@ -1235,10 +1235,6 @@ end; //////////////////////////////////////////////////////////////////////////////// -{$IFDEF IPHONEOS} -procedure startSpinning; cdecl; external; -procedure stopSpinning; cdecl; external; -{$ENDIF} procedure AddProgress; var r: TSDL_Rect; texsurf: PSDL_Surface; diff -r a44406f4369b -r 8c28abf427f5 hedgewars/uTeams.pas --- a/hedgewars/uTeams.pas Thu Jul 22 03:08:17 2010 +0200 +++ b/hedgewars/uTeams.pas Thu Jul 22 12:47:32 2010 +0200 @@ -268,9 +268,7 @@ {$IFDEF DEBUGFILE}AddFileLog('Wind = '+FloatToStr(cWindSpeed));{$ENDIF} ApplyAmmoChanges(CurrentHedgehog^); -{$IFNDEF IPHONEOS} if not CurrentTeam^.ExtDriven then SetBinds(CurrentTeam^.Binds); -{$ENDIF} bShowFinger:= true; diff -r a44406f4369b -r 8c28abf427f5 hedgewars/uWorld.pas --- a/hedgewars/uWorld.pas Thu Jul 22 03:08:17 2010 +0200 +++ b/hedgewars/uWorld.pas Thu Jul 22 12:47:32 2010 +0200 @@ -379,11 +379,10 @@ end else FreeWeaponTooltip; +if (WeaponTooltipTex <> nil) and (AMxShift = 0) then {$IFDEF IPHONEOS} -if (WeaponTooltipTex <> nil) and (AMxShift = 0) then ShowWeaponTooltip(x - WeaponTooltipTex^.w - 3, AMyOffset - 1); {$ELSE} -if (WeaponTooltipTex <> nil) and (AMxShift = 0) then ShowWeaponTooltip(x - WeaponTooltipTex^.w - 3, min(y + 1, cScreenHeight - WeaponTooltipTex^.h - 40)); {$ENDIF} diff -r a44406f4369b -r 8c28abf427f5 project_files/HedgewarsMobile/Classes/FortsViewController.m --- a/project_files/HedgewarsMobile/Classes/FortsViewController.m Thu Jul 22 03:08:17 2010 +0200 +++ b/project_files/HedgewarsMobile/Classes/FortsViewController.m Thu Jul 22 12:47:32 2010 +0200 @@ -150,7 +150,7 @@ } --(void) ealloc { +-(void) dealloc { [teamDictionary release]; [lastIndexPath release]; [fortArray release]; diff -r a44406f4369b -r 8c28abf427f5 project_files/HedgewarsMobile/Classes/GeneralSettingsViewController.m --- a/project_files/HedgewarsMobile/Classes/GeneralSettingsViewController.m Thu Jul 22 03:08:17 2010 +0200 +++ b/project_files/HedgewarsMobile/Classes/GeneralSettingsViewController.m Thu Jul 22 12:47:32 2010 +0200 @@ -21,15 +21,15 @@ #pragma mark View Lifecycle -(void) viewDidLoad { [super viewDidLoad]; - - NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] initWithContentsOfFile:SETTINGS_FILE()]; - self.settingsDictionary = dictionary; - [dictionary release]; } -(void) viewWillAppear:(BOOL)animated { [self.tableView setContentOffset:CGPointMake(0,0) animated:NO]; + NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] initWithContentsOfFile:SETTINGS_FILE()]; + self.settingsDictionary = dictionary; + [dictionary release]; + [super viewWillAppear:animated]; } diff -r a44406f4369b -r 8c28abf427f5 project_files/HedgewarsMobile/Classes/SDL_uikitappdelegate.m --- a/project_files/HedgewarsMobile/Classes/SDL_uikitappdelegate.m Thu Jul 22 03:08:17 2010 +0200 +++ b/project_files/HedgewarsMobile/Classes/SDL_uikitappdelegate.m Thu Jul 22 12:47:32 2010 +0200 @@ -140,8 +140,7 @@ } -(void) applicationDidReceiveMemoryWarning:(UIApplication *)application { - //if (self.mainViewController.view.superview == nil) - // self.mainViewController = nil; + // don't clean mainMenuViewController here!!! MSG_MEMCLEAN(); print_free_memory(); } diff -r a44406f4369b -r 8c28abf427f5 project_files/HedgewarsMobile/Hedgewars_Prefix.pch --- a/project_files/HedgewarsMobile/Hedgewars_Prefix.pch Thu Jul 22 03:08:17 2010 +0200 +++ b/project_files/HedgewarsMobile/Hedgewars_Prefix.pch Thu Jul 22 12:47:32 2010 +0200 @@ -22,6 +22,13 @@ #define ZAssert(condition, ...) do { if (!(condition)) { ALog(__VA_ARGS__); }} while(0) +// by http://blog.coriolis.ch/2009/01/05/macros-for-xcode/ +#define START_TIMER NSTimeInterval start = [NSDate timeIntervalSinceReferenceDate]; +#define END_TIMER(msg) NSTimeInterval stop = [NSDate timeIntervalSinceReferenceDate]; CMLog([NSString stringWithFormat:@"%@ Time = %f", msg, stop-start]); + +#define releaseAndNil(x) [x release], x = nil; + + #if !__IPHONE_3_2 typedef enum { UIUserInterfaceIdiomPhone, // iPhone and iPod touch style UI