# HG changeset patch # User koda # Date 1286760495 -7200 # Node ID d6412423da459022eb0d359d2a6c8187259c554e # Parent 296cbdd85e50bc2069384e76ed2358d7ad27e1d2 moved some utilities to a separate column with round buttons some improvements to rotation handling, overlay appears later so device shouldn't be stressed removed some code and autoset to default only when textfield is empty (for weaps and schemes) diff -r 296cbdd85e50 -r d6412423da45 hedgewars/PascalExports.pas --- a/hedgewars/PascalExports.pas Mon Oct 11 00:08:48 2010 +0200 +++ b/hedgewars/PascalExports.pas Mon Oct 11 03:28:15 2010 +0200 @@ -179,11 +179,16 @@ y^:= CursorPoint.Y; end; -function HW_isAmmoOpen: boolean; cdecl; export; +function HW_isAmmoMenuOpen: boolean; cdecl; export; begin exit(bShowAmmoMenu); end; +function HW_isAmmoMenuNotAllowed: boolean; cdecl; export; +begin; + exit ( (TurnTimeLeft = 0) or (not CurrentTeam^.ExtDriven and (((CurAmmoGear = nil) or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) = 0)) and hideAmmoMenu)) ); +end; + function HW_isPaused: boolean; cdecl; export; begin exit( isPaused ); @@ -265,6 +270,11 @@ SetWeapon(TAmmoType(whichone+1)); end; +function HW_isWeaponAnEffect(whichone: LongInt): boolean; cdecl; export; +begin + exit(Ammoz[TAmmoType(whichone+1)].Ammo.Propz and ammoprop_Effect <> 0) +end; + function HW_getAmmoCounts(counts: PLongInt): LongInt; cdecl; export; var a : PHHAmmo; slot, index: LongInt; diff -r 296cbdd85e50 -r d6412423da45 hedgewars/uAmmos.pas --- a/hedgewars/uAmmos.pas Mon Oct 11 00:08:48 2010 +0200 +++ b/hedgewars/uAmmos.pas Mon Oct 11 03:28:15 2010 +0200 @@ -248,7 +248,7 @@ end end end; -perfExt_NewTurnBeginning; +perfExt_AmmoUpdate; end; function HHHasAmmo(var Hedgehog: THedgehog; Ammo: TAmmoType): boolean; @@ -357,7 +357,6 @@ ShowCrosshair:= (Propz and ammoprop_NoCrosshair) = 0; end end; -perfExt_NewTurnBeginning; end; procedure SwitchNotHeldAmmo(var Hedgehog: THedgehog); diff -r 296cbdd85e50 -r d6412423da45 hedgewars/uMobile.pas --- a/hedgewars/uMobile.pas Mon Oct 11 00:08:48 2010 +0200 +++ b/hedgewars/uMobile.pas Mon Oct 11 03:28:15 2010 +0200 @@ -41,7 +41,7 @@ procedure perfExt_SaveFinishedSynching; inline; implementation -uses uTeams; +uses uTeams, uConsole; function isPhone: Boolean; inline; begin diff -r 296cbdd85e50 -r d6412423da45 hedgewars/uTeams.pas --- a/hedgewars/uTeams.pas Mon Oct 11 00:08:48 2010 +0200 +++ b/hedgewars/uTeams.pas Mon Oct 11 03:28:15 2010 +0200 @@ -225,7 +225,6 @@ until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil); CurrentHedgehog:= @(CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]); -perfExt_AmmoUpdate end; procedure AfterSwitchHedgehog; @@ -297,7 +296,9 @@ if TurnTimeLeft > 0 then PlaySound(sndIllGetYou, CurrentTeam^.voicepack); ReadyTimeLeft:= 0 - end + end; + +perfExt_NewTurnBeginning(); end; function AddTeam(TeamColor: Longword): PTeam; diff -r 296cbdd85e50 -r d6412423da45 hedgewars/uWorld.pas --- a/hedgewars/uWorld.pas Mon Oct 11 00:08:48 2010 +0200 +++ b/hedgewars/uWorld.pas Mon Oct 11 03:28:15 2010 +0200 @@ -190,7 +190,8 @@ Slot, Pos, STurns: LongInt; Ammo: PHHAmmo; begin -if (TurnTimeLeft = 0) or (not CurrentTeam^.ExtDriven and (((CurAmmoGear = nil) or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) = 0)) and hideAmmoMenu)) then bShowAmmoMenu:= false; +if (TurnTimeLeft = 0) or (not CurrentTeam^.ExtDriven and (((CurAmmoGear = nil) or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) = 0)) and hideAmmoMenu)) then + bShowAmmoMenu:= false; if bShowAmmoMenu then begin FollowGear:= nil; diff -r 296cbdd85e50 -r d6412423da45 project_files/HedgewarsMobile/Classes/AmmoMenuViewController.m --- a/project_files/HedgewarsMobile/Classes/AmmoMenuViewController.m Mon Oct 11 00:08:48 2010 +0200 +++ b/project_files/HedgewarsMobile/Classes/AmmoMenuViewController.m Mon Oct 11 03:28:15 2010 +0200 @@ -25,6 +25,8 @@ #import "UIImageExtra.h" #import "PascalImports.h" +#define BTNS_PER_ROW 9 + @implementation AmmoMenuViewController @synthesize weaponsImage, buttonsArray, isVisible; @@ -46,7 +48,8 @@ self.view.layer.borderWidth = 1.3f; [self.view.layer setCornerRadius:10]; [self.view.layer setMasksToBounds:YES]; - + self.view.autoresizingMask = UIViewAutoresizingNone; + self.isVisible = NO; delay = (uint8_t *) calloc(HW_getNumberOfWeapons(), sizeof(uint8_t)); HW_getAmmoDelays(delay); @@ -62,7 +65,15 @@ -(void) appearInView:(UIView *)container { [self viewWillAppear:YES]; [container addSubview:self.view]; - self.view.center = CGPointMake(container.center.y, container.center.x); + if (IS_DUALHEAD() == NO) + self.view.center = CGPointMake(container.center.y, container.center.x); + else { + UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; + if (orientation == UIDeviceOrientationLandscapeLeft || orientation == UIDeviceOrientationLandscapeRight) + self.view.center = CGPointMake(container.center.y, container.center.x); + else + self.view.center = CGPointMake(container.center.x, container.center.y); + } self.isVisible = YES; } @@ -83,18 +94,33 @@ [ammoStoreImage release]; NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity:HW_getNumberOfWeapons()]; - for (int i = 0; i < HW_getNumberOfWeapons(); i++) { - int x_dst = 10+(i%10)*44; - int y_dst = 10+(i/10)*44; + int i, j, e; + for (i = 0, j = 0, e = 0; i < HW_getNumberOfWeapons(); i++) { + int x, y; + float w, radius; - if (i / 10 % 2 != 0) - x_dst += 20; + // move utilities aside and make 'em rounded + if (HW_isWeaponAnEffect(i)) { + x = 432; + y = 20 + 48*e++; + w = 1.5; + radius = 22; + } else { + x = 10+(j%BTNS_PER_ROW)*44; + y = 10+(j/BTNS_PER_ROW)*44; + if (j / BTNS_PER_ROW % 2 != 0) + x += 20; + w = 1; + radius = 6; + j++; + } + UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; - button.frame = CGRectMake(x_dst, y_dst, 40, 40); + button.frame = CGRectMake(x, y, 40, 40); button.tag = i; - button.layer.borderWidth = 1; button.layer.borderColor = [UICOLOR_HW_YELLOW_TEXT CGColor]; - [button.layer setCornerRadius:6]; + button.layer.borderWidth = w; + [button.layer setCornerRadius:radius]; [button.layer setMasksToBounds:YES]; [button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside]; [button setTitleColor:UICOLOR_HW_YELLOW_TEXT forState:UIControlStateNormal]; @@ -106,6 +132,7 @@ button.titleLabel.layer.borderWidth = 1; [self.view addSubview:button]; [array addObject:button]; + } [self performSelectorOnMainThread:@selector(setButtonsArray:) withObject:array waitUntilDone:NO]; [array release]; diff -r 296cbdd85e50 -r d6412423da45 project_files/HedgewarsMobile/Classes/OverlayViewController.m --- a/project_files/HedgewarsMobile/Classes/OverlayViewController.m Mon Oct 11 00:08:48 2010 +0200 +++ b/project_files/HedgewarsMobile/Classes/OverlayViewController.m Mon Oct 11 03:28:15 2010 +0200 @@ -61,21 +61,33 @@ switch (orientation) { case UIDeviceOrientationLandscapeLeft: if (IS_DUALHEAD() == NO) - sdlView.transform = CGAffineTransformMakeRotation(degreesToRadians(0)); + sdlView.transform = CGAffineTransformMakeRotation(degreesToRadians(180)); self.view.transform = CGAffineTransformMakeRotation(degreesToRadians(90)); break; case UIDeviceOrientationLandscapeRight: if (IS_DUALHEAD() == NO) - sdlView.transform = CGAffineTransformMakeRotation(degreesToRadians(180)); + sdlView.transform = CGAffineTransformMakeRotation(degreesToRadians(0)); self.view.transform = CGAffineTransformMakeRotation(degreesToRadians(-90)); break; + case UIDeviceOrientationPortrait: + if (IS_DUALHEAD()) + self.view.transform = CGAffineTransformMakeRotation(degreesToRadians(0)); + break; + case UIDeviceOrientationPortraitUpsideDown: + if (IS_DUALHEAD()) + self.view.transform = CGAffineTransformMakeRotation(degreesToRadians(180)); + break; default: // a debug log would spam too much break; } + if (self.amvc.isVisible) + [self.amvc appearInView:self.view]; self.view.frame = usefulRect; - //sdlView.frame = usefulRect; [UIView commitAnimations]; + + // for single screens only landscape mode is supported + // for dual screen mode the sdlview is not modified, but you can rotate the pad in any direction } #pragma mark - @@ -93,6 +105,26 @@ initialScreenCount = [[UIScreen screens] count]; + if (IS_DUALHEAD()) { + // set initial orientation wrt the controller orientation + switch (self.interfaceOrientation) { + case UIDeviceOrientationLandscapeLeft: + self.view.transform = CGAffineTransformMakeRotation(degreesToRadians(90)); + break; + case UIDeviceOrientationLandscapeRight: + self.view.transform = CGAffineTransformMakeRotation(degreesToRadians(-90)); + break; + case UIDeviceOrientationPortrait: + self.view.transform = CGAffineTransformMakeRotation(degreesToRadians(0)); + break; + case UIDeviceOrientationPortraitUpsideDown: + self.view.transform = CGAffineTransformMakeRotation(degreesToRadians(180)); + break; + default: + DLog(@"Nope"); + break; + } + } CGRect screenRect = [[UIScreen mainScreen] bounds]; self.view.frame = CGRectMake(0, 0, screenRect.size.width, screenRect.size.height); @@ -103,7 +135,7 @@ userInfo:nil repeats:YES]; - // add timer too runloop, otherwise it doesn't work + // add timer to runloop, otherwise it doesn't work [[NSRunLoop currentRunLoop] addTimer:dimTimer forMode:NSDefaultRunLoopMode]; [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; @@ -323,13 +355,15 @@ if (IS_DUALHEAD() || self.useClassicMenu == NO) { if (self.amvc == nil) self.amvc = [[AmmoMenuViewController alloc] init]; - + if (self.amvc.isVisible) { doDim(); [self.amvc disappear]; } else { - doNotDim(); - [self.amvc appearInView:self.view]; + if (HW_isAmmoMenuNotAllowed() == NO) { + doNotDim(); + [self.amvc appearInView:self.view]; + } } } else { HW_ammoMenu(); @@ -452,7 +486,7 @@ switch ([allTouches count]) { case 1: // if we're in the menu we just click in the point - if (HW_isAmmoOpen()) { + if (HW_isAmmoMenuOpen()) { HW_setCursor(HWXZ(currentPosition.x), HWYZ(currentPosition.y)); // this click doesn't need any wrapping because the ammoMenu already limits the cursor HW_click(); @@ -560,7 +594,7 @@ touch = [[allTouches allObjects] objectAtIndex:0]; CGPoint currentPosition = [touch locationInView:self.view]; - if (HW_isAmmoOpen()) { + if (HW_isAmmoMenuOpen()) { // no zoom consideration for this HW_setCursor(HWXZ(currentPosition.x), HWYZ(currentPosition.y)); } else diff -r 296cbdd85e50 -r d6412423da45 project_files/HedgewarsMobile/Classes/PascalImports.h --- a/project_files/HedgewarsMobile/Classes/PascalImports.h Mon Oct 11 00:08:48 2010 +0200 +++ b/project_files/HedgewarsMobile/Classes/PascalImports.h Mon Oct 11 03:28:15 2010 +0200 @@ -70,7 +70,8 @@ void HW_setCursor(int x, int y); void HW_getCursor(int *x, int *y); - BOOL HW_isAmmoOpen(void); + BOOL HW_isAmmoMenuOpen(void); + BOOL HW_isAmmoMenuNotAllowed(void); BOOL HW_isPaused(void); BOOL HW_isWeaponRequiringClick(void); BOOL HW_isWeaponTimerable(void); @@ -81,11 +82,14 @@ void HW_setPianoSound(int snd); void HW_setWeapon(int whichone); - void HW_getAmmoDelays(unsigned char *); - int HW_getAmmoCounts(int *); + BOOL HW_isWeaponAnEffect(int whichone); + char *HW_getWeaponNameByIndex(int whichone); + + void HW_getAmmoDelays(unsigned char *pointer); + int HW_getAmmoCounts(int *pointer); + + int HW_getNumberOfWeapons(void); int HW_getTurnsForCurrentTeam(void); - int HW_getNumberOfWeapons(void); - char *HW_getWeaponNameByIndex(int whichone); int HW_getMaxNumberOfHogs(void); int HW_getMaxNumberOfTeams(void); diff -r 296cbdd85e50 -r d6412423da45 project_files/HedgewarsMobile/Classes/SDL_uikitappdelegate.m --- a/project_files/HedgewarsMobile/Classes/SDL_uikitappdelegate.m Mon Oct 11 00:08:48 2010 +0200 +++ b/project_files/HedgewarsMobile/Classes/SDL_uikitappdelegate.m Mon Oct 11 03:28:15 2010 +0200 @@ -129,7 +129,7 @@ // since the sdlwindow is not yet created, we add the overlayController with a delay NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:isNetGameNum,@"net",menuStyle,@"menu",nil]; - [self performSelector:@selector(displayOverlayLater:) withObject:dict afterDelay:0.1]; + [self performSelector:@selector(displayOverlayLater:) withObject:dict afterDelay:1]; // this is the pascal fuction that starts the game (wrapped around isInGame) isInGame = YES; diff -r 296cbdd85e50 -r d6412423da45 project_files/HedgewarsMobile/Classes/SchemeWeaponConfigViewController.m --- a/project_files/HedgewarsMobile/Classes/SchemeWeaponConfigViewController.m Mon Oct 11 00:08:48 2010 +0200 +++ b/project_files/HedgewarsMobile/Classes/SchemeWeaponConfigViewController.m Mon Oct 11 03:28:15 2010 +0200 @@ -53,15 +53,15 @@ NSArray *contentsOfDir = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:SCHEMES_DIRECTORY() error:NULL]; self.listOfSchemes = contentsOfDir; - if ([listOfSchemes containsObject:@"Default.plist"]) - self.selectedScheme = @"Default.plist"; - + if ([self.selectedScheme isEqualToString:@""] && [listOfSchemes containsObject:@"Default.plist"]) + self.selectedScheme = @"Default.plist"; + contentsOfDir = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:WEAPONS_DIRECTORY() error:NULL]; self.listOfWeapons = contentsOfDir; - - if ([listOfWeapons containsObject:@"Default.plist"]) - self.selectedWeapon = @"Default.plist"; - + + if ([self.selectedWeapon isEqualToString:@""] && [listOfWeapons containsObject:@"Default.plist"]) + self.selectedWeapon = @"Default.plist"; + [self.tableView reloadData]; }