--- a/hedgewars/PascalExports.pas Mon Oct 04 00:00:42 2010 +0200
+++ b/hedgewars/PascalExports.pas Wed Oct 06 02:31:04 2010 +0200
@@ -14,7 +14,7 @@
interface
uses uKeys, GLunit, uWorld, uMisc, uConsole, uTeams, uConsts, uChat,
- uGears, uSound, hwengine, uAmmos; // don't change the order!
+ uGears, uSound, hwengine, uAmmos, uLocale; // don't change the order!
{$INCLUDE "config.inc"}
@@ -260,10 +260,46 @@
end;
end;
+function HW_getWeaponNameByIndex(whichone: LongInt): PChar; cdecl; export;
+begin
+ exit (str2pchar(trammo[Ammoz[TAmmoType(whichone+1)].NameId]));
+end;
+
+function HW_getNumberOfWeapons:LongInt; cdecl; export;
+begin
+ exit(ord(high(TAmmoType)));
+end;
procedure HW_setWeapon(whichone: LongInt); cdecl; export;
begin
- SetWeapon(TAmmoType(whichone));
+ if (not CurrentTeam^.ExtDriven) and (CurrentTeam^.Hedgehogs[0].BotLevel = 0) then
+ SetWeapon(TAmmoType(whichone+1));
+end;
+
+function HW_getDelays: pByte; cdecl; export;
+var skipTurns : PByte;
+ a : TAmmoType;
+begin
+ GetMem(skipTurns,ord(High(TAmmoType)));
+ for a:= Low(TAmmoType) to High(TAmmoType) do
+ skipTurns[ord(a)-1]:= byte(Ammoz[a].SkipTurns);
+ exit(skipTurns);
+ // leak?
+end;
+
+function HW_getTurnsForCurrentTeam:LongInt; cdecl; export;
+begin
+ exit(CurrentTeam^.Clan^.TurnNumber);
+end;
+
+function HW_getMaxNumberOfHogs: LongInt; cdecl; export;
+begin
+ exit(cMaxHHIndex+1);
+end;
+
+function HW_getMaxNumberOfTeams: LongInt; cdecl; export;
+begin
+ exit(cMaxTeams);
end;
{$ENDIF}
--- a/hedgewars/uLocale.pas Mon Oct 04 00:00:42 2010 +0200
+++ b/hedgewars/uLocale.pas Wed Oct 06 02:31:04 2010 +0200
@@ -46,17 +46,16 @@
gidDamageModifier);
const MAX_EVENT_STRINGS = 100;
-var trammo: array[TAmmoStrId] of ansistring;
- trammoc: array[TAmmoStrId] of ansistring;
- trammod: array[TAmmoStrId] of ansistring;
- trmsg: array[TMsgStrId] of ansistring;
- trgoal: array[TGoalStrId] of ansistring;
+var trammo: array[TAmmoStrId] of ansistring; // name of the weapon
+ trammoc: array[TAmmoStrId] of ansistring; // caption of the weapon
+ trammod: array[TAmmoStrId] of ansistring; // description of the weapon
+ trmsg: array[TMsgStrId] of ansistring; // message of the event
+ trgoal: array[TGoalStrId] of ansistring; // message of the goal
procedure LoadLocale(FileName: shortstring);
-function Format(fmt: shortstring; var arg: shortstring): shortstring;
-function Format(fmt: ansistring; var arg: ansistring): ansistring;
-
-function GetEventString(e: TEventId): ansistring;
+function Format(fmt: shortstring; var arg: shortstring): shortstring;
+function Format(fmt: ansistring; var arg: ansistring): ansistring;
+function GetEventString(e: TEventId): ansistring;
implementation
uses uMisc, uRandom;
@@ -144,4 +143,9 @@
else Format:= copy(fmt, 1, i - 1) + arg + Format(copy(fmt, i + 2, Length(fmt) - i - 1), arg)
end;
+procedure LoadLocaleWrapper(str: pchar); cdecl; export;
+begin
+ LoadLocale(Strpas(str));
+end;
+
end.
--- a/project_files/HedgewarsMobile/Classes/CommodityFunctions.h Mon Oct 04 00:00:42 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/CommodityFunctions.h Wed Oct 06 02:31:04 2010 +0200
@@ -21,9 +21,6 @@
#import <Foundation/Foundation.h>
-#define MAX_HOGS 8
-#define CURRENT_AMMOSIZE 48 // also add a line in SingleWeaponViewController array
-
#define DOCUMENTS_FOLDER() [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]
#define SETTINGS_FILE() [DOCUMENTS_FOLDER() stringByAppendingString:@"/settings.plist"]
@@ -45,6 +42,7 @@
#define THEMES_DIRECTORY() [[[NSBundle mainBundle] resourcePath] stringByAppendingString:@"/Data/Themes/"]
#define MAPS_DIRECTORY() [[[NSBundle mainBundle] resourcePath] stringByAppendingString:@"/Data/Maps/"]
#define MISSIONS_DIRECTORY() [[[NSBundle mainBundle] resourcePath] stringByAppendingString:@"/Data/Missions/Maps/"]
+#define LOCALE_DIRECTORY() [[[NSBundle mainBundle] resourcePath] stringByAppendingString:@"/Data/Locale/"]
#define MSG_MEMCLEAN() DLog(@"has cleaned up some memory");
#define MSG_DIDUNLOAD() DLog(@"unloaded");
--- a/project_files/HedgewarsMobile/Classes/CommodityFunctions.m Mon Oct 04 00:00:42 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/CommodityFunctions.m Wed Oct 06 02:31:04 2010 +0200
@@ -25,6 +25,7 @@
#import <mach/mach.h>
#import <mach/mach_host.h>
#import "AudioToolbox/AudioToolbox.h"
+#import "PascalImports.h"
void createTeamNamed (NSString *nameWithoutExt) {
NSString *teamsDirectory = TEAMS_DIRECTORY();
@@ -36,9 +37,9 @@
error:NULL];
}
- NSMutableArray *hedgehogs = [[NSMutableArray alloc] initWithCapacity: MAX_HOGS];
+ NSMutableArray *hedgehogs = [[NSMutableArray alloc] initWithCapacity: HW_getMaxNumberOfHogs()];
- for (int i = 0; i < MAX_HOGS; i++) {
+ for (int i = 0; i < HW_getMaxNumberOfHogs(); i++) {
NSString *hogName = [[NSString alloc] initWithFormat:@"hedgehog %d",i];
NSDictionary *hog = [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:0],@"level",
hogName,@"hogname", @"NoHat",@"hat", nil];
@@ -73,7 +74,7 @@
switch (type) {
case 0: //default
theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys:
- [NSNumber numberWithInt:CURRENT_AMMOSIZE],@"version",
+ [NSNumber numberWithInt:HW_getNumberOfWeapons()],@"version",
@"939192942219912103223511100120100000021111010101",@"ammostore_initialqt",
@"040504054160065554655446477657666666615551010111",@"ammostore_probability",
@"000000000000020550000004000700400000000020000000",@"ammostore_delay",
@@ -81,7 +82,7 @@
break;
case 1: //crazy
theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys:
- [NSNumber numberWithInt:CURRENT_AMMOSIZE],@"version",
+ [NSNumber numberWithInt:HW_getNumberOfWeapons()],@"version",
@"999999999999999999299999999999999929999999990999",@"ammostore_initialqt",
@"111111011111111111111111111111111111111111110111",@"ammostore_probability",
@"000000000000000000000000000000000000000000000000",@"ammostore_delay",
@@ -89,7 +90,7 @@
break;
case 2: //pro mode
theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys:
- [NSNumber numberWithInt:CURRENT_AMMOSIZE],@"version",
+ [NSNumber numberWithInt:HW_getNumberOfWeapons()],@"version",
@"909000900000000000000900000000000000000000000000",@"ammostore_initialqt",
@"000000000000000000000000000000000000000000000000",@"ammostore_probability",
@"000000000000020550000004000700400000000020000000",@"ammostore_delay",
@@ -97,7 +98,7 @@
break;
case 3: //shoppa
theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys:
- [NSNumber numberWithInt:CURRENT_AMMOSIZE],@"version",
+ [NSNumber numberWithInt:HW_getNumberOfWeapons()],@"version",
@"000000990000000000000000000000000000000000000000",@"ammostore_initialqt",
@"444441004424440221011212122242200000000200040001",@"ammostore_probability",
@"000000000000000000000000000000000000000000000000",@"ammostore_delay",
@@ -105,7 +106,7 @@
break;
case 4: //basketball
theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys:
- [NSNumber numberWithInt:CURRENT_AMMOSIZE],@"version",
+ [NSNumber numberWithInt:HW_getNumberOfWeapons()],@"version",
@"939192942219912103223511100120100000021111010100",@"ammostore_initialqt",
@"000000000000000000000000000000000000000000000000",@"ammostore_probability",
@"000000000000000550000004000700400000000020000000",@"ammostore_delay",
@@ -113,7 +114,7 @@
break;
case 5: //minefield
theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys:
- [NSNumber numberWithInt:CURRENT_AMMOSIZE],@"version",
+ [NSNumber numberWithInt:HW_getNumberOfWeapons()],@"version",
@"000000990009000000030000000000000000000000000000",@"ammostore_initialqt",
@"000000000000000000000000000000000000000000000000",@"ammostore_probability",
@"000000000000020550000004000700400000000020000000",@"ammostore_delay",
--- a/project_files/HedgewarsMobile/Classes/GameConfigViewController.m Mon Oct 04 00:00:42 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/GameConfigViewController.m Wed Oct 06 02:31:04 2010 +0200
@@ -26,6 +26,7 @@
#import "HelpPageViewController.h"
#import "CommodityFunctions.h"
#import "UIImageExtra.h"
+#import "PascalImports.h"
@implementation GameConfigViewController
@synthesize hedgehogImage, imgContainer, helpPage;
@@ -152,7 +153,7 @@
return NO;
}
- if ([teamConfigViewController.listOfSelectedTeams count] > 6) {
+ if ([teamConfigViewController.listOfSelectedTeams count] > HW_getMaxNumberOfTeams()) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Too many teams",@"")
message:NSLocalizedString(@"Max six teams are allowed in the same game",@"")
delegate:nil
@@ -251,11 +252,11 @@
mapConfigViewController.view.frame = CGRectMake(0, 0, screen.size.height, screen.size.width);
if (teamConfigViewController == nil)
teamConfigViewController = [[TeamConfigViewController alloc] initWithStyle:UITableViewStyleGrouped];
- teamConfigViewController.view.frame = CGRectMake(362, 200, 328, 480);
+ teamConfigViewController.view.frame = CGRectMake(348, 200, 328, 480);
[mapConfigViewController.view addSubview:teamConfigViewController.view];
if (schemeWeaponConfigViewController == nil)
schemeWeaponConfigViewController = [[SchemeWeaponConfigViewController alloc] initWithStyle:UITableViewStyleGrouped];
- schemeWeaponConfigViewController.view.frame = CGRectMake(10, 70, 300, 550);
+ schemeWeaponConfigViewController.view.frame = CGRectMake(10, 70, 300, 600);
[mapConfigViewController.view addSubview:schemeWeaponConfigViewController.view];
} else {
// this is the visible controller
--- a/project_files/HedgewarsMobile/Classes/GameSetup.m Mon Oct 04 00:00:42 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/GameSetup.m Wed Oct 06 02:31:04 2010 +0200
@@ -123,7 +123,7 @@
NSString *update = @"";
// if we're loading an older version of ammos fill the engine message with 0s
- int diff = CURRENT_AMMOSIZE - [[ammoData objectForKey:@"version"] intValue];
+ int diff = HW_getNumberOfWeapons() - [[ammoData objectForKey:@"version"] intValue];
if (diff != 0)
update = [NSString stringWithCharacters:(const unichar*)"0000000000000000000000000000000000" length:diff];
--- a/project_files/HedgewarsMobile/Classes/HogButtonView.m Mon Oct 04 00:00:42 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/HogButtonView.m Wed Oct 06 02:31:04 2010 +0200
@@ -22,6 +22,7 @@
#import "HogButtonView.h"
#import "CommodityFunctions.h"
#import "UIImageExtra.h"
+#import "PascalImports.h"
@implementation HogButtonView
@synthesize singleHog, numberOfHogs, ownerDictionary;
@@ -51,13 +52,13 @@
-(void) drawManyHogs:(NSInteger) hogs {
if (numberOfHogs != hogs) {
- if (hogs <= MAX_HOGS && hogs >= 1)
+ if (hogs <= HW_getMaxNumberOfHogs() && hogs >= 1)
numberOfHogs = hogs;
else {
- if (hogs > MAX_HOGS)
+ if (hogs > HW_getMaxNumberOfHogs())
numberOfHogs = 1;
else
- numberOfHogs = MAX_HOGS;
+ numberOfHogs = HW_getMaxNumberOfHogs();
}
[ownerDictionary setObject:[NSNumber numberWithInt:numberOfHogs] forKey:@"number"];
--- a/project_files/HedgewarsMobile/Classes/InGameMenuViewController.m Mon Oct 04 00:00:42 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/InGameMenuViewController.m Wed Oct 06 02:31:04 2010 +0200
@@ -49,15 +49,30 @@
[array release];
// save the sdl window (!= uikit window) for future reference
- SDL_VideoDevice *_this = SDL_GetVideoDevice();
- SDL_VideoDisplay *display = &_this->displays[0];
- sdlwindow = display->windows;
+ SDL_VideoDevice *videoDevice = SDL_GetVideoDevice();
+ if (videoDevice) {
+ SDL_VideoDisplay *display = &videoDevice->displays[0];
+ if (display)
+ sdlwindow = display->windows;
+ }
+ [super viewDidLoad];
+}
- [super viewDidLoad];
+-(void) viewWillAppear:(BOOL)animated {
+ if (sdlwindow == NULL) {
+ SDL_VideoDevice *_this = SDL_GetVideoDevice();
+ if (_this) {
+ SDL_VideoDisplay *display = &_this->displays[0];
+ if (display)
+ sdlwindow = display->windows;
+ }
+ }
+ [super viewWillAppear:animated];
}
-(void) viewDidUnload {
self.menuList = nil;
+ sdlwindow = NULL;
MSG_DIDUNLOAD();
[super viewDidUnload];
}
--- a/project_files/HedgewarsMobile/Classes/MapConfigViewController.h Mon Oct 04 00:00:42 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/MapConfigViewController.h Wed Oct 06 02:31:04 2010 +0200
@@ -92,5 +92,6 @@
-(void) turnOffWidgets;
-(void) setLabelText:(NSString *)str;
-(void) updatePreview;
+-(void) loadDataSourceArray;
@end
--- a/project_files/HedgewarsMobile/Classes/MapConfigViewController.m Mon Oct 04 00:00:42 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/MapConfigViewController.m Wed Oct 06 02:31:04 2010 +0200
@@ -54,6 +54,8 @@
self.seedCommand = seedCmd;
[seedCmd release];
+ if (self.dataSourceArray == nil)
+ [self loadDataSourceArray];
NSArray *source = [self.dataSourceArray objectAtIndex:scIndex];
NSIndexPath *theIndex;
if (isRandomness()) {
@@ -111,6 +113,8 @@
}
-(NSInteger) tableView:(UITableView *)aTableView numberOfRowsInSection:(NSInteger) section {
+ if (self.dataSourceArray == nil)
+ [self loadDataSourceArray];
return [[self.dataSourceArray objectAtIndex:scIndex] count];
}
@@ -125,6 +129,8 @@
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
cell.textLabel.textColor = UICOLOR_HW_YELLOW_TEXT;
+ if (self.dataSourceArray == nil)
+ [self loadDataSourceArray];
NSArray *source = [self.dataSourceArray objectAtIndex:scIndex];
NSString *labelString = [source objectAtIndex:row];
@@ -150,6 +156,8 @@
// this set details for a static map (called by didSelectRowAtIndexPath)
-(void) setDetailsForStaticMap:(NSInteger) index {
+ if (self.dataSourceArray == nil)
+ [self loadDataSourceArray];
NSArray *source = [self.dataSourceArray objectAtIndex:scIndex];
NSString *fileCfg = [[NSString alloc] initWithFormat:@"%@/%@/map.cfg",
@@ -185,6 +193,8 @@
int oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1;
if (newRow != oldRow) {
+ if (self.dataSourceArray == nil)
+ [self loadDataSourceArray];
NSArray *source = [self.dataSourceArray objectAtIndex:scIndex];
if (isRandomness()) {
// just change the theme, don't update preview
@@ -461,6 +471,7 @@
-(void) didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
self.dataSourceArray = nil;
+ self.lastIndexPath = nil;
// maybe we can save some more
MSG_MEMCLEAN();
}
--- a/project_files/HedgewarsMobile/Classes/OverlayViewController.m Mon Oct 04 00:00:42 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/OverlayViewController.m Wed Oct 06 02:31:04 2010 +0200
@@ -588,10 +588,15 @@
UIWindow *theWindow = [[UIApplication sharedApplication] keyWindow];
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
indicator.tag = ACTIVITYINDICATOR_TAG;
+ int offset;
+ if ([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft)
+ offset = -120;
+ else
+ offset = 120;
if ([[UIScreen screens] count] > 1)
- indicator.center = CGPointMake(theWindow.frame.size.width/2, theWindow.frame.size.height/2 + 118);
+ indicator.center = CGPointMake(theWindow.frame.size.width/2, theWindow.frame.size.height/2 + offset);
else
- indicator.center = CGPointMake(theWindow.frame.size.width/2 + 118, theWindow.frame.size.height/2);
+ indicator.center = CGPointMake(theWindow.frame.size.width/2 + offset, theWindow.frame.size.height/2);
indicator.hidesWhenStopped = YES;
[indicator startAnimating];
[theWindow addSubview:indicator];
--- a/project_files/HedgewarsMobile/Classes/PascalImports.h Mon Oct 04 00:00:42 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/PascalImports.h Wed Oct 06 02:31:04 2010 +0200
@@ -32,7 +32,7 @@
void Game(const char *args[]);
void GenLandPreview(void);
-
+ void LoadLocaleWrapper(const char *filename);
void HW_versionInfo(short int *netProto, char **versionStr);
@@ -44,7 +44,7 @@
void HW_zoomOut(void);
void HW_zoomReset(void);
float HW_zoomFactor(void);
- int HW_zoomLevel(void);
+ int HW_zoomLevel(void);
void HW_walkingKeysUp(void);
void HW_otherKeysUp(void);
@@ -80,8 +80,15 @@
void HW_setGrenadeTime(int time);
void HW_setPianoSound(int snd);
+
void HW_setWeapon(int whichone);
-
+ unsigned char *HW_getDelays(void);
+ int HW_getTurnsForCurrentTeam(void);
+ int HW_getNumberOfWeapons(void);
+ char *HW_getWeaponNameByIndex(int whichone);
+ int HW_getMaxNumberOfHogs(void);
+ int HW_getMaxNumberOfTeams(void);
+
#ifdef __cplusplus
}
#endif
--- a/project_files/HedgewarsMobile/Classes/SingleTeamViewController.m Mon Oct 04 00:00:42 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/SingleTeamViewController.m Wed Oct 06 02:31:04 2010 +0200
@@ -28,6 +28,7 @@
#import "LevelViewController.h"
#import "CommodityFunctions.h"
#import "UIImageExtra.h"
+#import "PascalImports.h"
#define TEAMNAME_TAG 78789
@@ -148,7 +149,7 @@
rows = 1;
break;
case 1: // team members
- rows = MAX_HOGS;
+ rows = HW_getMaxNumberOfHogs();
break;
case 2: // team details
rows = [self.secondaryItems count];
--- a/project_files/HedgewarsMobile/Classes/SingleWeaponViewController.h Mon Oct 04 00:00:42 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/SingleWeaponViewController.h Wed Oct 06 02:31:04 2010 +0200
@@ -28,7 +28,6 @@
NSString *description;
UIImage *ammoStoreImage;
- NSArray *ammoNames;
char *quantity;
char *probability;
@@ -39,7 +38,6 @@
@property (nonatomic,retain) NSString *weaponName;
@property (nonatomic,retain) NSString *description;
@property (nonatomic,retain) UIImage *ammoStoreImage;
-@property (nonatomic,retain) NSArray *ammoNames;
-(void) saveAmmos;
--- a/project_files/HedgewarsMobile/Classes/SingleWeaponViewController.m Mon Oct 04 00:00:42 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/SingleWeaponViewController.m Wed Oct 06 02:31:04 2010 +0200
@@ -20,12 +20,12 @@
#import "SingleWeaponViewController.h"
-#import "WeaponCellView.h"
#import "CommodityFunctions.h"
#import "UIImageExtra.h"
+#import "PascalImports.h"
@implementation SingleWeaponViewController
-@synthesize weaponName, description, ammoStoreImage, ammoNames;
+@synthesize weaponName, description, ammoStoreImage;
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
return rotationManager(interfaceOrientation);
@@ -36,64 +36,14 @@
-(void) viewDidLoad {
[super viewDidLoad];
- // also increment CURRENT_AMMOSIZE in CommodityFunctions.h
- NSArray *array = [[NSArray alloc] initWithObjects:
- NSLocalizedString(@"Grenade",@""),
- NSLocalizedString(@"Cluster Bomb",@""),
- NSLocalizedString(@"Bazooka",@""),
- NSLocalizedString(@"Homing Bee",@""),
- NSLocalizedString(@"Shotgun",@""),
- NSLocalizedString(@"Pick Hammer",@""),
- NSLocalizedString(@"Skip",@""),
- NSLocalizedString(@"Rope",@""),
- NSLocalizedString(@"Mine",@""),
- NSLocalizedString(@"Deagle",@""),
- NSLocalizedString(@"Dynamite",@""),
- NSLocalizedString(@"Fire Punch",@""),
- NSLocalizedString(@"Slash",@""),
- NSLocalizedString(@"Baseball bat",@""),
- NSLocalizedString(@"Parachute",@""),
- NSLocalizedString(@"Air Attack",@""),
- NSLocalizedString(@"Mines Attack",@""),
- NSLocalizedString(@"Blow Torch",@""),
- NSLocalizedString(@"Construction",@""),
- NSLocalizedString(@"Teleport",@""),
- NSLocalizedString(@"Switch Hedgehog",@""),
- NSLocalizedString(@"Mortar",@""),
- NSLocalizedString(@"Kamikaze",@""),
- NSLocalizedString(@"Cake",@""),
- NSLocalizedString(@"Seduction",@""),
- NSLocalizedString(@"Watermelon Bomb",@""),
- NSLocalizedString(@"Hellish Hand Grenade",@""),
- NSLocalizedString(@"Napalm Attack",@""),
- NSLocalizedString(@"Drill Rocket",@""),
- NSLocalizedString(@"Ballgun",@""),
- NSLocalizedString(@"RC Plane",@""),
- NSLocalizedString(@"Low Gravity",@""),
- NSLocalizedString(@"Extra Damage",@""),
- NSLocalizedString(@"Invulnerable",@""),
- NSLocalizedString(@"Extra Time",@""),
- NSLocalizedString(@"Laser Sight",@""),
- NSLocalizedString(@"Vampirism",@""),
- NSLocalizedString(@"Sniper Rifle",@""),
- NSLocalizedString(@"Flying Saucer",@""),
- NSLocalizedString(@"Molotov Cocktail",@""),
- NSLocalizedString(@"Birdy",@""),
- NSLocalizedString(@"Portable Portal Device",@""),
- NSLocalizedString(@"Piano Attack",@""),
- NSLocalizedString(@"Old Limburger",@""),
- NSLocalizedString(@"Sine Gun",@""),
- NSLocalizedString(@"Flamethrower",@""),
- NSLocalizedString(@"Sticky Mine",@""),
- NSLocalizedString(@"Hammer",@""),
- nil];
- self.ammoNames = array;
- [array release];
+ NSString *trFilePath = [NSString stringWithFormat:@"%@/en.txt",LOCALE_DIRECTORY()];
+ // fill the data structure that we are going to read
+ LoadLocaleWrapper([trFilePath UTF8String]);
- quantity = (char *)malloc(sizeof(char)*(CURRENT_AMMOSIZE+1));
- probability = (char *)malloc(sizeof(char)*(CURRENT_AMMOSIZE+1));
- delay = (char *)malloc(sizeof(char)*(CURRENT_AMMOSIZE+1));
- crateness = (char *)malloc(sizeof(char)*(CURRENT_AMMOSIZE+1));
+ quantity = (char *)malloc(sizeof(char)*(HW_getNumberOfWeapons()+1));
+ probability = (char *)malloc(sizeof(char)*(HW_getNumberOfWeapons()+1));
+ delay = (char *)malloc(sizeof(char)*(HW_getNumberOfWeapons()+1));
+ crateness = (char *)malloc(sizeof(char)*(HW_getNumberOfWeapons()+1));
NSString *str = [NSString stringWithFormat:@"%@/AmmoMenu/Ammos.png",GRAPHICS_DIRECTORY()];
UIImage *img = [[UIImage alloc] initWithContentsOfFile:str];
@@ -126,7 +76,7 @@
delay[i] = tmp3[i];
crateness[i] = tmp4[i];
}
- for (int i = oldlen; i < CURRENT_AMMOSIZE; i++) {
+ for (int i = oldlen; i < HW_getNumberOfWeapons(); i++) {
quantity[i] = '0';
probability[i] = '0';
delay[i] = '0';
@@ -142,10 +92,10 @@
}
-(void) saveAmmos {
- quantity[CURRENT_AMMOSIZE] = '\0';
- probability[CURRENT_AMMOSIZE] = '\0';
- delay[CURRENT_AMMOSIZE] = '\0';
- crateness[CURRENT_AMMOSIZE] = '\0';
+ quantity[HW_getNumberOfWeapons()] = '\0';
+ probability[HW_getNumberOfWeapons()] = '\0';
+ delay[HW_getNumberOfWeapons()] = '\0';
+ crateness[HW_getNumberOfWeapons()] = '\0';
NSString *quantityStr = [NSString stringWithUTF8String:quantity];
NSString *probabilityStr = [NSString stringWithUTF8String:probability];
@@ -153,7 +103,7 @@
NSString *cratenessStr = [NSString stringWithUTF8String:crateness];
NSDictionary *weapon = [[NSDictionary alloc] initWithObjectsAndKeys:
- [NSNumber numberWithInt:CURRENT_AMMOSIZE],@"version",
+ [NSNumber numberWithInt:HW_getNumberOfWeapons()],@"version",
quantityStr,@"ammostore_initialqt",
probabilityStr,@"ammostore_probability",
delayStr,@"ammostore_delay",
@@ -177,7 +127,7 @@
if (section == 0)
return 2;
else
- return CURRENT_AMMOSIZE;
+ return HW_getNumberOfWeapons();
}
// Customize the appearance of table view cells.
@@ -220,7 +170,7 @@
UIImage *img = [[self.ammoStoreImage cutAt:CGRectMake(x, y, 32, 32)] makeRoundCornersOfSize:CGSizeMake(7, 7)];
weaponCell.weaponIcon.image = img;
- weaponCell.weaponName.text = [ammoNames objectAtIndex:row];
+ weaponCell.weaponName.text = [NSString stringWithUTF8String:HW_getWeaponNameByIndex(row)];
weaponCell.tag = row;
[weaponCell.initialSli setValue:[[NSString stringWithFormat:@"%c",quantity[row]] intValue] animated:NO];
@@ -306,7 +256,6 @@
self.description = nil;
self.weaponName = nil;
self.ammoStoreImage = nil;
- self.ammoNames = nil;
MSG_DIDUNLOAD();
[super viewDidUnload];
}
@@ -316,7 +265,6 @@
[weaponName release];
[description release];
[ammoStoreImage release];
- [ammoNames release];
[super dealloc];
}