OSDN Git Service

ver0.631
[awarsiii/AwarsIV.git] / Awars III / UnitChipList.m
index 22d0842..3ef4b69 100644 (file)
@@ -50,6 +50,9 @@
     [commandListTV setTarget:self];
     [commandListTV setAction:@selector(ClickCMD:)];
     
+    [comboListTV setTarget:self];
+    [comboListTV setAction:@selector(ClickCMB:)];
+    
     [self addPUBEquipList];
     equipItemMA = [NSMutableArray new];
     attackListMA = [NSMutableArray new];
     return self;
 }
 
+-(void)ClickCMB:(id)sender{
+    CMBrow = (int)[comboListTV clickedRow];
+}
+
 -(void)ClickCMD:(id)sender{
     CMDrow = (int)[commandListTV clickedRow];
 }
@@ -733,7 +740,7 @@ bool InitialFlag;
     
     [PUPtEquip addItemWithTitle:@"装備リスト"];
     for (int i = 0; i < eItemNum; i++) {
-        [PUPtEquip addItemWithTitle:EQ[i].name];
+        [PUPtEquip addItemWithTitle:EQ[i].nameRecognition];
     }
 }
 
@@ -2951,7 +2958,7 @@ bool eHandLFlag = false;
             fileData = [[fileData stringByAppendingString:[NSString stringWithFormat:@"%d", UC[i].A->dmgExtend]] stringByAppendingString:@","];
             fileData = [[fileData stringByAppendingString:[NSString stringWithFormat:@"%d", UC[i].A->imagine]] stringByAppendingString:@"\n"];
         
-            fileData = [[fileData stringByAppendingString:[NSString stringWithFormat:@"%@", UC[i].A->cmd]] stringByAppendingString:@"\n"];
+            fileData = [[fileData stringByAppendingString:[NSString stringWithFormat:@"%@,%d", UC[i].A->cmd, UC[i].A->hasei]] stringByAppendingString:@"\n"];
             fileData = [[fileData stringByAppendingString:[NSString stringWithFormat:@"%@,%d", UC[i].A->AN.movName, UC[i].A->AN.frame]] stringByAppendingString:@"\n"];
             if(UC[i].A->msg){
                 fileData = [[fileData stringByAppendingString:[NSString stringWithFormat:@"####"]] stringByAppendingString:@"\n"];
@@ -3077,7 +3084,7 @@ bool eHandLFlag = false;
             fileData = [[fileData stringByAppendingString:[NSString stringWithFormat:@"%d", LC[i].A->dmgExtend]] stringByAppendingString:@","];
             fileData = [[fileData stringByAppendingString:[NSString stringWithFormat:@"%d", LC[i].A->imagine]] stringByAppendingString:@"\n"];
             
-            fileData = [[fileData stringByAppendingString:[NSString stringWithFormat:@"%@", LC[i].A->cmd]] stringByAppendingString:@"\n"];
+            fileData = [[fileData stringByAppendingString:[NSString stringWithFormat:@"%@,%d", LC[i].A->cmd, LC[i].A->hasei]] stringByAppendingString:@"\n"];
             
             if(LC[i].A->msg){
                 fileData = [[fileData stringByAppendingString:[NSString stringWithFormat:@"####"]] stringByAppendingString:@"\n"];
@@ -3206,7 +3213,7 @@ bool eHandLFlag = false;
             fileData = [[fileData stringByAppendingString:[NSString stringWithFormat:@"%d", EQ[i].A->dmgExtend]] stringByAppendingString:@","];
             fileData = [[fileData stringByAppendingString:[NSString stringWithFormat:@"%d", EQ[i].A->imagine]] stringByAppendingString:@"\n"];
             
-            fileData = [[fileData stringByAppendingString:[NSString stringWithFormat:@"%@", EQ[i].A->cmd]] stringByAppendingString:@"\n"];
+            fileData = [[fileData stringByAppendingString:[NSString stringWithFormat:@"%@,%d", EQ[i].A->cmd, EQ[i].A->hasei]] stringByAppendingString:@"\n"];
             fileData = [[fileData stringByAppendingString:[NSString stringWithFormat:@"%@,%d", EQ[i].A->AN.movName, EQ[i].A->AN.frame]] stringByAppendingString:@"\n"];
             if(EQ[i].A->msg){
                 fileData = [[fileData stringByAppendingString:[NSString stringWithFormat:@"####"]] stringByAppendingString:@"\n"];
@@ -3446,20 +3453,28 @@ bool eHandLFlag = false;
     NSString *fileData = nil;
     
     
-    comboItemNumb = 2;
+    fileData = [NSString stringWithContentsOfFile:pathCL encoding:NSUTF8StringEncoding error:nil];
+    fileDataArray = [fileData componentsSeparatedByString:@"\n"];
+    int instantNum = [[fileDataArray objectAtIndex:0] intValue];
+    
+    comboItemNumb = instantNum;
+    CLN = (int)comboItemNumb;
     if(!InitialData){
         [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil];
         [[NSFileManager defaultManager] createFileAtPath:pathCL contents:nil attributes:nil];
+        [[NSString stringWithFormat:@"%d", UCN] writeToFile:pathCL atomically:YES encoding:NSUTF8StringEncoding error:nil];
         
-        NSString *data1 = @"0,1,2,3\n####\n236A,0,0\n####\nA>A>A\nA>A>B";
+        comboItemNumb = UCN;
+        CLN = (int)comboItemNumb;
+        NSString *data1 = @"A>A>A\nA>A>B";
         
-        NSString *data2 = @"0,1,2,3\n####\n236A,0,0\n####\nA>A>A\nA>A>B";
+        NSString *data2 = @"A>A>B\nA>A>C";
         
-        for (int i=1; i<=comboItemNumb; i++) {
+        for (int i=1; i<=UCN; i++) {
             NSString *fdata = @"data/ComboList/CLdata";
             
             fdata = [fdata stringByAppendingFormat:@"%d.txt", i];
-            
+            /*
             switch (i) {
                 case 1:
                     [data1 writeToFile:fdata atomically:YES encoding:NSUTF8StringEncoding error:nil];
@@ -3470,15 +3485,13 @@ bool eHandLFlag = false;
                 default:
                     
                     break;
-            }
-            
+            }*/
+            [@"" writeToFile:fdata atomically:YES encoding:NSUTF8StringEncoding error:nil];
         }
-        
     }
     
     NSArray *fileDataArray2;
-    for (int i = 0; i< itemNumb; i++){
-        COMMANDS *CStop = UC[i].CM.cs;
+    for (int i = 0; i< CLN; i++){
         COMBO *COtop = UC[i].CM.co;
         
         NSString *fdata = @"data/ComboList/CLdata";
@@ -3486,47 +3499,16 @@ bool eHandLFlag = false;
         fdata = [fdata stringByAppendingFormat:@"%d.txt", i+1];
         
         fileData = [NSString stringWithContentsOfFile:fdata encoding:NSUTF8StringEncoding error:nil];
-        fileDataArray2 = [fileData componentsSeparatedByString:@"\n####\n"];
-        
-        NSArray *items = [[fileDataArray2 objectAtIndex:0] componentsSeparatedByString:@","];
-        
-        /*
-        UC[i].CM.A = [[items objectAtIndex:0] intValue];
-        UC[i].CM.B = [[items objectAtIndex:1] intValue];
-        UC[i].CM.C = [[items objectAtIndex:2] intValue];
-        UC[i].CM.D = [[items objectAtIndex:3] intValue];
-        */
-        fileDataArray = [[fileDataArray2 objectAtIndex:1] componentsSeparatedByString:@"\n"];
-        
-        for(int k = 0;k < [fileDataArray count];k++){
-            if (k == 0) {
-                UC[i].CM.cs = calloc(1, sizeof(COMMANDS));
-                CStop = UC[i].CM.cs;
-            }
-            items = [[fileDataArray objectAtIndex:k] componentsSeparatedByString:@","];
-            
-            NSLog(@"%@", UC[i].CM.cs->cmd);
-            
-            UC[i].CM.cs->cmd = [[items objectAtIndex:0] retain];
-            UC[i].CM.cs->waza = [[items objectAtIndex:1] intValue];
-            UC[i].CM.cs->hasei = [[items objectAtIndex:2] retain];
-            
-            UC[i].CM.cs->next = calloc(1, sizeof(COMMANDS));
-            UC[i].CM.cs = UC[i].CM.cs->next;
-        }
-        UC[i].CM.cs = NULL;
+        fileDataArray2 = [fileData componentsSeparatedByString:@"\n"];
         
-        fileDataArray = [[fileDataArray2 objectAtIndex:2] componentsSeparatedByString:@"\n"];
         
-        
-        for(int k = 0;k < [fileDataArray count];k++){
+        for(int k = 0;k < [fileDataArray2 count] && ![[fileDataArray2 objectAtIndex:k] isEqualToString:@""];k++){
             if (k == 0) {
                 UC[i].CM.co = calloc(1, sizeof(COMBO));
                 COtop = UC[i].CM.co;
             }
-            items = [[fileDataArray objectAtIndex:k] componentsSeparatedByString:@","];
             
-            UC[i].CM.co->mbo = [[items objectAtIndex:0] retain];
+            UC[i].CM.co->mbo = [[fileDataArray2 objectAtIndex:k] retain];
             
             UC[i].CM.co->next = calloc(1, sizeof(COMBO));
             UC[i].CM.co = UC[i].CM.co->next;
@@ -3535,12 +3517,46 @@ bool eHandLFlag = false;
         
         
         UC[i].CM.co = COtop;
-        UC[i].CM.cs = CStop;
     }
 
 
 }
 
+-(void)saveDataCL{
+
+    NSString *directoryPath;
+    
+    directoryPath = [[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent];
+    [[NSFileManager defaultManager] changeCurrentDirectoryPath:directoryPath];
+    
+    char *cwd;
+    cwd = getcwd(NULL, 0);
+    
+    
+    
+    for (int i=0; i<CLN; i++) {
+        NSString *fdata = @"data/ComboList/CLdata";
+        fdata = [fdata stringByAppendingFormat:@"%d.txt", i+1];
+        
+        NSString *fileData = @"";
+        
+        COMBO *cTop = UC[i].CM.co;
+        int p = 0;
+        while(UC[i].CM.co){
+            if(p > 0)
+                fileData = [fileData stringByAppendingString:@"\n"];
+
+        fileData = [fileData stringByAppendingString:[NSString stringWithFormat:@"%@", UC[i].CM.co->mbo]];
+            
+            p++;
+            UC[i].CM.co = UC[i].CM.co->next;
+        }UC[i].CM.co = cTop;
+
+        [fileData writeToFile:fdata atomically:YES encoding:NSUTF8StringEncoding error:nil];
+    }
+
+}
+
 -(void)initFileDirectoryAttack{
     NSString *directoryPath;
     
@@ -3668,7 +3684,11 @@ bool eHandLFlag = false;
         UC[i].A->dmgExtend = [[items objectAtIndex:4] intValue];
         UC[i].A->imagine = [[items objectAtIndex:5] intValue];
         
-        UC[i].A->cmd = [[fileDataArray objectAtIndex:5] retain];
+        items = [[fileDataArray objectAtIndex:5] componentsSeparatedByString:@","];
+            
+        UC[i].A->cmd = [[items objectAtIndex:0] retain];
+        if([items count] >= 2)
+            UC[i].A->hasei = [[items objectAtIndex:1] intValue];
             
         items = [[fileDataArray objectAtIndex:6] componentsSeparatedByString:@","];
         
@@ -3993,7 +4013,11 @@ bool eHandLFlag = false;
             LC[i].A->dmgExtend = [[items objectAtIndex:4] intValue];
             LC[i].A->imagine = [[items objectAtIndex:5] intValue];
             
-            LC[i].A->cmd = [[fileDataArray objectAtIndex:5] retain];
+            items = [[fileDataArray objectAtIndex:5] componentsSeparatedByString:@","];
+            
+            LC[i].A->cmd = [[items objectAtIndex:0] retain];
+            if([items count] >= 2)
+                LC[i].A->hasei = [[items objectAtIndex:1] intValue];
             LC[i].A->msg = @"";
             
             //[self AddDAMAGE:&UC[i].A->D :0];
@@ -4319,7 +4343,11 @@ bool eHandLFlag = false;
             EQ[i].A->AN.movName = [[items objectAtIndex:0] retain];
             else EQ[i].A->AN.movName = @"";
             EQ[i].A->AN.frame = [[items objectAtIndex:1] intValue];
-            EQ[i].A->cmd = [[fileDataArray objectAtIndex:5] retain];
+            items = [[fileDataArray objectAtIndex:5] componentsSeparatedByString:@","];
+            
+            EQ[i].A->cmd = [[items objectAtIndex:0] retain];
+            if([items count] >= 2)
+                EQ[i].A->hasei = [[items objectAtIndex:1] intValue];
             EQ[i].A->msg = @"";
             
             //[self AddDAMAGE:&UC[i].A->D :0];
@@ -5895,12 +5923,7 @@ bool eHandLFlag = false;
     }
     
 }
--(IBAction)insertComboList:(id)sender{
 
-}
--(IBAction)removeComboList:(id)sender{
-    
-}
 
 -(IBAction)submitAttackList:(id)sender{
     
@@ -7109,6 +7132,12 @@ int omfgErase() {
     [comboListMA removeAllObjects];
     [self didChangeValueForKey:@"comboListMA"];
     
+    
+    [AMbtnA addItemWithTitle:@"なし"];
+    [AMbtnB addItemWithTitle:@"なし"];
+    [AMbtnC addItemWithTitle:@"なし"];
+    [AMbtnD addItemWithTitle:@"なし"];
+    
     ATTACK *Atop = UC[clickIndex].A;
     while (UC[clickIndex].A != NULL) {
         if(UC[clickIndex].A->name != NULL){
@@ -7154,8 +7183,7 @@ int omfgErase() {
     
     
     COMBO *Ctop = UC[clickIndex].CM.co;
-    if(UC[clickIndex].CM.co != NULL)
-    while (UC[clickIndex].CM.co->mbo != NULL) {
+    while (UC[clickIndex].CM.co != NULL) {
         NSMutableDictionary* dict = [NSMutableDictionary new];
         [dict setValue:[NSString stringWithFormat:@"%@", UC[clickIndex].CM.co->mbo] forKey:@"name"];
         [self willChangeValueForKey:@"comboListMA"];
@@ -7166,10 +7194,10 @@ int omfgErase() {
     UC[clickIndex].CM.co = Ctop;
     
     
-    [AMbtnA selectItemAtIndex:UC[clickIndex].CM.A];
-    [AMbtnB selectItemAtIndex:UC[clickIndex].CM.B];
-    [AMbtnC selectItemAtIndex:UC[clickIndex].CM.C];
-    [AMbtnD selectItemAtIndex:UC[clickIndex].CM.D];
+    [AMbtnA selectItemAtIndex:UC[clickIndex].CM.A+1];
+    [AMbtnB selectItemAtIndex:UC[clickIndex].CM.B+1];
+    [AMbtnC selectItemAtIndex:UC[clickIndex].CM.C+1];
+    [AMbtnD selectItemAtIndex:UC[clickIndex].CM.D+1];
     
     
     
@@ -7197,10 +7225,10 @@ int omfgErase() {
 
 -(IBAction)attackListTotalSubmit:(id)sender{
     
-    UC[clickIndex].CM.A = (int)[AMbtnA indexOfSelectedItem];
-    UC[clickIndex].CM.B = (int)[AMbtnB indexOfSelectedItem];
-    UC[clickIndex].CM.C = (int)[AMbtnC indexOfSelectedItem];
-    UC[clickIndex].CM.D = (int)[AMbtnD indexOfSelectedItem];
+    UC[clickIndex].CM.A = (int)[AMbtnA indexOfSelectedItem]-1;
+    UC[clickIndex].CM.B = (int)[AMbtnB indexOfSelectedItem]-1;
+    UC[clickIndex].CM.C = (int)[AMbtnC indexOfSelectedItem]-1;
+    UC[clickIndex].CM.D = (int)[AMbtnD indexOfSelectedItem]-1;
     
     ATTACK *aTop2 = UC[clickIndex].A;
     while (UC[clickIndex].A) {
@@ -7220,7 +7248,27 @@ int omfgErase() {
         
         UC[clickIndex].A = aTop;
     }
+    
+    COMBO *cTop = UC[clickIndex].CM.co;
+    for(int i = 0;i < [comboListMA count];i++){
+        if (i == 0) {
+            UC[clickIndex].CM.co =calloc(1, sizeof(COMBO));
+            cTop = UC[clickIndex].CM.co;
+        }
+        UC[clickIndex].CM.co->mbo = [[comboListMA[i] valueForKeyPath:@"name"] retain];
+        
+        if(i+1 < [comboListMA count]){
+            UC[clickIndex].CM.co->next =calloc(1, sizeof(COMBO));
+        }
+        UC[clickIndex].CM.co = UC[clickIndex].CM.co->next;
+    }UC[clickIndex].CM.co = cTop;
+    
+    
+    
+    
+    [self saveDataCL];
     [UCLPanelAttackList close];
+    
 }
 -(IBAction)attackListOpenBtn:(id)sender{
     clickedRowAT = -1;
@@ -7332,8 +7380,82 @@ int omfgErase() {
 
 
 }
--(IBAction)comboListAdd:(id)sender{}
--(IBAction)comboListRemove:(id)sender{}
+-(IBAction)comboListAdd:(id)sender{
+    if(1){
+        NSMutableDictionary *dict = [NSMutableDictionary new];
+        
+        if([comboListMA count] == 0){
+            
+            [self willChangeValueForKey:@"comboListMA"];
+            [comboListMA insertObject:dict atIndex:[comboListMA count]];
+            [self didChangeValueForKey:@"comboListMA"];
+            [comboListAC setSelectionIndex:999];
+        }else if(CMBrow == -1){
+            
+            [self willChangeValueForKey:@"comboListMA"];
+            [comboListMA insertObject:dict atIndex:[comboListMA count]];
+            [self didChangeValueForKey:@"comboListMA"];
+            [comboListAC setSelectionIndex:999];
+            
+        }else if(CMBrow > 0){
+            
+            [self willChangeValueForKey:@"comboListMA"];
+            [comboListMA insertObject:dict atIndex:CMDrow];
+            [self didChangeValueForKey:@"comboListMA"];
+            [comboListAC setSelectionIndex:999];
+            
+        }else{
+            
+            [self willChangeValueForKey:@"comboListMA"];
+            [comboListMA insertObject:dict atIndex:comboListMA];
+            [self didChangeValueForKey:@"comboListMA"];
+            [comboListAC setSelectionIndex:999];
+        }
+        
+        
+    }
+
+
+
+
+
+}
+-(IBAction)comboListRemove:(id)sender{
+
+    if(1){
+        if([comboListMA count] == 0){
+            return;
+        }else if(CMBrow == -1){
+            
+            [self willChangeValueForKey:@"comboListMA"];
+            [comboListMA removeObjectAtIndex:[comboListMA count]-1];
+            [self didChangeValueForKey:@"comboListMA"];
+            [comboListAC setSelectionIndex:999];
+            
+        }else if(CMBrow > 0){
+            
+            [self willChangeValueForKey:@"comboListMA"];
+            [comboListMA removeObjectAtIndex:CMBrow];
+            [self didChangeValueForKey:@"comboListMA"];
+            [comboListAC setSelectionIndex:999];
+            
+            
+        }else{
+            
+            [self willChangeValueForKey:@"comboListMA"];
+            [comboListMA removeObjectAtIndex:CMBrow];
+            [self didChangeValueForKey:@"comboListMA"];
+            [comboListAC setSelectionIndex:999];
+            
+            
+        }
+        
+    }
+    
+    CMBrow = -1;
+
+
+}
 
 
 -(IBAction)addSubjMark:(id)sender{