5 // Created by Killery on 2013/01/28.
6 // Copyright (c) 2013年 Killery. All rights reserved.
9 #import "ScenarioEditor.h"
12 #import "FieldScene.h"
14 @implementation ScenarioEditor
17 [textListTV setTarget:self];
18 [textListTV setAction:@selector(ClickTL:)];
19 [lineListTV setTarget:self];
20 [lineListTV setAction:@selector(ClickLL:)];
21 [lineListTV setDoubleAction:@selector(DoubleClickLL:)];
23 [standListTV setTarget:self];
24 [standListTV setAction:@selector(ClickSTAND:)];
25 [standListTV setDoubleAction:@selector(DoubleClickSTAND:)];
27 [baseListTV setTarget:self];
28 [baseListTV setAction:@selector(ClickBASE:)];
29 [baseListTV setDoubleAction:@selector(DoubleClickBASE:)];
31 [layerListTV setTarget:self];
32 [layerListTV setAction:@selector(ClickLAYER:)];
33 [layerListTV setDoubleAction:@selector(DoubleClickLAYER:)];
35 standListMA = [NSMutableArray new];
36 baseListMA = [NSMutableArray new];
37 layerListMA = [NSMutableArray new];
38 //textListMA = [NSMutableArray new];
39 //lineListMA = [NSMutableArray new];
41 [SETV1 setTarget:self];
42 [SETV1 setAction:@selector(ClickSETV1:)];
43 [SETV2 setTarget:self];
44 [SETV2 setAction:@selector(ClickSETV2:)];
45 [SETV3 setTarget:self];
46 [SETV3 setAction:@selector(ClickSETV3:)];
48 SEMA1 = [NSMutableArray new];
49 SEMA2 = [NSMutableArray new];
50 SEMA3 = [NSMutableArray new];
54 [TV1 setAction:@selector(TV1sgl:)];
56 MA1 = [NSMutableArray new];
59 [TV2 setAction:@selector(TV2sgl:)];
61 MA2 = [NSMutableArray new];
66 [SETV setTarget:self];
67 [SETV setAction:@selector(ClickSETV:)];
69 SEMA = [NSMutableArray new];
71 deletedName = [NSMutableArray new];
72 baseListDC = @{@"1":baseListMA};
80 scheduledTimerWithTimeInterval:0.1
81 target:self selector:@selector(EventLoop2:)
82 userInfo:nil repeats:YES
85 testScenarioEditor = self;
89 textListMA = [NSMutableArray new];
90 lineListMA = [NSMutableArray new];
92 StringText *stringText = [[StringText alloc] init];
94 for(int i = 0;i<255;i++){
95 [stringText AddString:&TX[i].S :0];
98 for(int i = 0;i <TEXTMAX;i++){
99 TX[i].fileName = NULL;
100 TXCPY[i].fileName = NULL;
106 [self initFileDirectory];
107 [self loadStandData];
113 [textListAC setSelectionIndex:9999];
126 b->L->visibleInstant = b->L->visible;
144 [SEstandWindow close];
151 -(void)ClickSETV:(id)sender{
152 [self willChangeValueForKey:@"SEMA1"];
153 [SEMA1 removeAllObjects];
154 [self didChangeValueForKey:@"SEMA1"];
155 [self willChangeValueForKey:@"SEMA2"];
156 [SEMA2 removeAllObjects];
157 [self didChangeValueForKey:@"SEMA2"];
158 [self willChangeValueForKey:@"SEMA3"];
159 [SEMA3 removeAllObjects];
160 [self didChangeValueForKey:@"SEMA3"];
161 [SEIV setImage:NULL];
166 SEMArow = [SETV clickedRow];
168 TX[st].S = STRtop[st];
169 for(int i = 0;i < sl;i++){
170 TX[st].S = TX[st].S->next;
174 TX[st].S = STRtop[st];
178 for(int i = 0;i < SEMArow;i++){
179 TX[st].S->i = TX[st].S->i->next;
184 NSMutableDictionary *dict = [NSMutableDictionary new];
186 [dict setValue:[NSString stringWithFormat:@"%@", I->name] forKey:@"name"];
189 [self willChangeValueForKey:@"SEMA1"];
190 [SEMA1 addObject:dict];
191 [self didChangeValueForKey:@"SEMA1"];
198 if(TX[st].S->i->SEMA1row-1 < 0){
199 [SEAC1 setSelectionIndex:9999];
200 [SEAC2 setSelectionIndex:9999];
201 [SEAC3 setSelectionIndex:9999];
203 TX[st].S = STRtop[st];
209 [SEAC1 setSelectionIndex:9999];
210 [SEAC2 setSelectionIndex:9999];
211 [SEAC3 setSelectionIndex:9999];
213 TX[st].S = STRtop[st];
219 for(int i = 0;i < TX[st].S->i->SEMA1row-1;i++){
228 NSMutableDictionary *dict = [NSMutableDictionary new];
230 [dict setValue:[NSString stringWithFormat:@"%@", b->name] forKey:@"name"];
233 [self willChangeValueForKey:@"SEMA2"];
234 [SEMA2 addObject:dict];
235 [self didChangeValueForKey:@"SEMA2"];
245 if(TX[st].S->i->SEMA2row-1 < 0){
246 [SEAC1 setSelectionIndex:9999];
247 [SEAC2 setSelectionIndex:9999];
248 [SEAC3 setSelectionIndex:9999];
250 TX[st].S = STRtop[st];
255 [SEAC1 setSelectionIndex:9999];
256 [SEAC2 setSelectionIndex:9999];
257 [SEAC3 setSelectionIndex:9999];
259 TX[st].S = STRtop[st];
265 for(int i = 0;i < TX[st].S->i->SEMA1row-1;i++){
270 for(int i = 0;i < TX[st].S->i->SEMA2row-1;i++){
275 if(!TX[st].S->i->SEMA3flag) TX[st].S->i->SEMA3flag = calloc(999, sizeof(int));
278 NSMutableDictionary *dict = [NSMutableDictionary new];
280 int value = *(TX[st].S->i->SEMA3flag + i0) - 1;
282 if(value < 0) value = 0;
284 [dict setValue:[NSString stringWithFormat:@"%@", b->L->name] forKey:@"name"];
285 [dict setValue:[NSString stringWithFormat:@"%d", value] forKey:@"v"];
287 [self willChangeValueForKey:@"SEMA3"];
288 [SEMA3 addObject:dict];
289 [self didChangeValueForKey:@"SEMA3"];
291 b->L->visibleInstant = value;
302 [SEAC1 setSelectionIndex:TX[st].S->i->SEMA1row-1];
303 [SEAC2 setSelectionIndex:TX[st].S->i->SEMA2row-1];
304 SEMA1row = TX[st].S->i->SEMA1row-1;
305 SEMA2row = TX[st].S->i->SEMA2row-1;
306 //[SEstandTF setStringValue:[NSString stringWithFormat:@"x:%d y:%d", TX[st].S->i->standX, TX[st].S->i->standY]];
307 [SEstandTFx setStringValue:[NSString stringWithFormat:@"%d", TX[st].S->i->standX]];
308 [SEstandTFy setStringValue:[NSString stringWithFormat:@"%d", TX[st].S->i->standY]];
310 [SEAC1 setSelectionIndex:9999];
311 [SEAC2 setSelectionIndex:9999];
315 [SEAC3 setSelectionIndex:9999];
318 TX[st].S = STRtop[st];
321 -(void)ClickSETV1:(id)sender{
322 SEMA1row = [SETV1 clickedRow];
326 TX[st].S = STRtop[st];
327 for(int i = 0;i < sl;i++){
328 TX[st].S = TX[st].S->next;
332 TX[st].S = STRtop[st];
336 for(int i = 0;i < SEMArow;i++){
337 TX[st].S->i = TX[st].S->i->next;
340 TX[st].S->i->SEMA1row = (int)SEMA1row + 1;
344 [self willChangeValueForKey:@"SEMA2"];
345 [SEMA2 removeAllObjects];
346 [self didChangeValueForKey:@"SEMA2"];
347 [self willChangeValueForKey:@"SEMA3"];
348 [SEMA3 removeAllObjects];
349 [self didChangeValueForKey:@"SEMA3"];
358 TX[st].S = STRtop[st];
362 for(int i = 0;i < SEMA1row;i++){
370 TX[st].S = STRtop[st];
381 NSMutableDictionary *dict2 = [NSMutableDictionary new];
382 [dict2 setValue:[NSString stringWithFormat:@"%@", b->name] forKeyPath:@"name"];
384 [self willChangeValueForKey:@"SEMA2"];
385 [SEMA2 addObject:dict2];
386 [self didChangeValueForKey:@"SEMA2"];
390 TX[st].S->i->SEMA3flag = calloc(999, sizeof(int));
391 while(b->L && !first){
392 NSMutableDictionary *dict2 = [NSMutableDictionary new];
393 [dict2 setValue:[NSString stringWithFormat:@"%@", b->L->name] forKeyPath:@"name"];
394 [dict2 setValue:[NSString stringWithFormat:@"%d", b->L->visible] forKeyPath:@"v"];
396 b->L->visibleInstant = true;
397 *(TX[st].S->i->SEMA3flag+i0) = b->L->visible;
400 [self willChangeValueForKey:@"SEMA3"];
401 [SEMA3 addObject:dict2];
402 [self didChangeValueForKey:@"SEMA3"];
416 TX[st].S = STRtop[st];
422 [SEAC2 setSelectionIndex:9999];
423 [SEAC3 setSelectionIndex:9999];
426 -(void)ClickSETV2:(id)sender{
427 SEMA2row = [SETV2 clickedRow];
430 TX[st].S = STRtop[st];
431 for(int i = 0;i < sl;i++){
432 TX[st].S = TX[st].S->next;
436 TX[st].S = STRtop[st];
440 for(int i = 0;i < SEMArow;i++){
441 TX[st].S->i = TX[st].S->i->next;
444 TX[st].S->i->SEMA2row = (int)SEMA2row + 1;
447 [self willChangeValueForKey:@"SEMA3"];
448 [SEMA3 removeAllObjects];
449 [self didChangeValueForKey:@"SEMA3"];
455 TX[st].S = STRtop[st];
461 for(int i = 0;i < SEMA1row;i++){
471 for(int i = 0;i < SEMA2row;i++){
479 TX[st].S->i->SEMA3flag = calloc(999, sizeof(int));
481 NSMutableDictionary *dict2 = [NSMutableDictionary new];
482 [dict2 setValue:[NSString stringWithFormat:@"%@", b->L->name] forKeyPath:@"name"];
483 [dict2 setValue:[NSString stringWithFormat:@"%d", b->L->visible] forKeyPath:@"v"];
485 b->L->visibleInstant = b->L->visible;
487 *(TX[st].S->i->SEMA3flag+i0) = b->L->visible;
489 [self willChangeValueForKey:@"SEMA3"];
490 [SEMA3 addObject:dict2];
491 [self didChangeValueForKey:@"SEMA3"];
501 TX[st].S = STRtop[st];
507 [SEAC3 setSelectionIndex:9999];
510 -(void)ClickSETV3:(id)sender{
511 SEMA3row = [SETV3 clickedRow];
514 -(void)TV1sgl:(id)sender{
516 static NSInteger postClicedrow;
517 postClicedrow = TVCrow1;
522 for(int i = 0;i < Irow;i++){
533 TVCrow1 = [TV1 clickedRow];
534 TVCrow2 = [TV2 clickedRow];
536 [self willChangeValueForKey:@"MA2"];
537 [MA2 removeAllObjects];
538 [self didChangeValueForKey:@"MA2"];
543 for (int i = 0;i < TVCrow1;i++) {
546 if(TVCrow1 >= 0 && b){
551 NSMutableDictionary *dict2 = [NSMutableDictionary new];
552 [dict2 setValue:[NSString stringWithFormat:@"%@", b->L->name] forKeyPath:@"name"];
553 [dict2 setValue:[NSString stringWithFormat:@"%d", b->L->z] forKeyPath:@"z"];
554 [dict2 setValue:[NSString stringWithFormat:@"%d", b->L->visible] forKeyPath:@"v"];
555 [dict2 setValue:b->L->img forKey:@"img"];
557 [self willChangeValueForKey:@"MA2"];
558 [MA2 addObject:dict2];
559 [self didChangeValueForKey:@"MA2"];
569 if(TVCrow1 != postClicedrow) layerLoadOver = true;
572 -(void)TV2sgl:(id)sender{
574 TVCrow2 = [TV2 clickedRow];
582 -(void)DoubleClickSTAND:(id)sender{
585 if(![standListMA[Irow] valueForKey:@"file"])
587 if([[standListMA[Irow] valueForKey:@"file"] isEqualToString:@""])
589 if([[standListMA[Irow] valueForKey:@"file"] isEqualToString:@"(null)"])
591 [self initLineBaseLayer];
594 [baseListAC setSelectionIndex:9999];
595 [layerListAC setSelectionIndex:9999];
597 [self saveStandData];
599 [self loadStandData];
602 [standEditorPanel makeKeyAndOrderFront:nil];
605 -(void)ClickSTAND:(id)sender{
606 Irow = (int)[standListTV clickedRow];
609 -(void)DoubleClickBASE:(id)sender{
612 [baseListAC setSelectionIndex:9999];
613 [baseListAC setSelectionIndex:-1];
617 -(void)ClickBASE:(id)sender{
619 IBrow = (int)[baseListTV clickedRow];
620 [layerListAC setSelectionIndex:9999];
624 for (int i = 0;i < Irow;i++) {
629 for (int i = 0;i < IBrow;i++) {
633 [NSIV setImage:I->B->img];
634 I->B->z = [[[baseListMA objectAtIndex:IBrow] valueForKeyPath:@"pref"] intValue];
635 I->B->name = [[baseListMA objectAtIndex:IBrow] valueForKeyPath:@"name"];
644 [self initLineLayer];
648 -(void)DoubleClickLAYER:(id)sender{
651 [layerListAC setSelectionIndex:9999];
652 [layerListAC setSelectionIndex:-1];
656 -(void)ClickLAYER:(id)sender{
658 IBLrow = (int)[layerListTV clickedRow];
663 for (int i = 0;i < Irow;i++) {
668 for (int i = 0;i < IBrow;i++) {
673 for (int i = 0;i < IBLrow;i++) {
674 I->B->L = I->B->L->next;
678 oops = [[layerListMA objectAtIndex:IBLrow] valueForKeyPath:@"visible"];
679 oops = oops>>4 & 0xf;
684 if(oops == 3 || oops == 14){
690 I->B->L->visible = oops;
691 I->B->L->z = [[[layerListMA objectAtIndex:IBLrow] valueForKeyPath:@"pref"] intValue];
692 I->B->L->name = [[layerListMA objectAtIndex:IBLrow] valueForKeyPath:@"name"];
694 [NSIV2 setImage:I->B->L->img];
708 IBLrow = (int)[layerListTV clickedRow];
713 for (int i = 0;i < Irow;i++) {
718 for (int i = 0;i < IBrow;i++) {
724 for (int i = 0;i < IBLrow;i++) {
725 I->B->L = I->B->L->next;
730 oops = [[layerListMA objectAtIndex:IBLrow] valueForKeyPath:@"visible"];
731 oops = oops>>4 & 0xf;
736 if(oops == 3 || oops == 14){
742 I->B->L->visible = oops;
744 I->B->L->z = [[[layerListMA objectAtIndex:IBLrow] valueForKeyPath:@"pref"] intValue];
745 I->B->L->name = [[layerListMA objectAtIndex:IBLrow] valueForKeyPath:@"name"];
750 [NSIV2 setImage:I->B->L->img];
761 -(void)DoubleClickLL:(id)sender{
763 [lineListAC setSelectionIndex:9999];
764 [lineListAC setSelectionIndex:-1];
768 -(void)ClickTL:(id)sender{
771 st = [textListTV selectedRow];
774 [self willChangeValueForKey:@"lineListMA"];
775 [lineListMA removeAllObjects];
776 [self didChangeValueForKey:@"lineListMA"];
779 [Dname setStringValue:@""];
780 [Dstring setStringValue:@""];
781 [dialogName setStringValue:@""];
782 [dialogString setStringValue:@""];
783 [dialogImage setImage:NULL];
788 [self willChangeValueForKey:@"lineListMA"];
789 [lineListMA removeAllObjects];
790 [self didChangeValueForKey:@"lineListMA"];
793 STRtop[st] = TX[st].S;
795 if(TX[st].S != NULL){
796 [Dname setStringValue:TX[st].S->name];
797 [Dstring setStringValue:TX[st].S->string];
798 [dialogName setStringValue:TX[st].S->name];
799 [dialogString setStringValue:TX[st].S->string];
800 [dialogImage setImage:TX[st].S->img];
801 while(TX[st].S != NULL){
802 NSMutableDictionary* dict = [NSMutableDictionary new];
804 [dict setValue:[NSString stringWithFormat:@"%@:%@", TX[st].S->name, TX[st].S->string] forKey:@"name"];
805 [self willChangeValueForKey:@"lineListMA"];
806 [lineListMA addObject:dict];
807 [self didChangeValueForKey:@"lineListMA"];
808 [lineListAC setSelectionIndex:sl];
810 TX[st].S = TX[st].S->next;
813 TX[st].S = STRtop[st];
816 -(void)ClickLL:(id)sender{
818 sl = [lineListTV selectedRow];
822 LLrow = (int)[lineListTV selectedRow];
824 STRtop[st] = TX[st].S;
826 for(int k = 0;k < LLrow;k++) {
827 if(TX[st].S->next != NULL) TX[st].S = TX[st].S->next;
830 [Dname setStringValue:TX[st].S->name];
831 if([[TX[st].S->string substringWithRange:NSMakeRange([TX[st].S->string length]-1, 1)] isEqualToString:@"\n"]){
832 [Dstring setStringValue:[NSString stringWithFormat:@"%@", [TX[st].S->string substringToIndex:[TX[st].S->string length]-1 ]]];
834 [Dstring setStringValue:[NSString stringWithFormat:@"%@", TX[st].S->string]];
837 //NSLog(@"[%@]", [TX[st].S->string substringWithRange:NSMakeRange([TX[st].S->string length]-1, 1)]);
839 [dialogName setStringValue:TX[st].S->name];
840 [dialogString setStringValue:TX[st].S->string];
841 [dialogImage setImage:TX[st].S->img];
842 TX[st].S = STRtop[st];
846 -(IBAction)SEstandXsubmit:(id)sender{
851 TX[st].S = STRtop[st];
852 for(int i = 0;i < sl;i++){
853 TX[st].S = TX[st].S->next;
856 for(int i = 0;i < SEMArow;i++){
857 TX[st].S->i = TX[st].S->i->next;
859 TX[st].S->i->standX = [SEstandTFx intValue];
862 TX[st].S = STRtop[st];
866 -(IBAction)SEstandYsubmit:(id)sender{
871 TX[st].S = STRtop[st];
872 for(int i = 0;i < sl;i++){
873 TX[st].S = TX[st].S->next;
876 for(int i = 0;i < SEMArow;i++){
877 TX[st].S->i = TX[st].S->i->next;
879 TX[st].S->i->standY = [SEstandTFy intValue];
882 TX[st].S = STRtop[st];
884 [SEstandTFx intValue];
887 -(void)EventLoop2:(NSTimer *)timer{
890 [SESTIV setImage:SEstandImgST];
895 for(int i = 0;i < Irow;i++){
909 for (int i = 0; i < TVCrow1; i++) {
913 if(TVCrow1 == -1) TVCrow2 = -1;
914 if(TVCrow1 >= 0 && b && [MA1 count] > 0){
915 int value = [[[MA1 objectAtIndex:TVCrow1] valueForKeyPath:@"z"] intValue];
918 NSString *value2 = [[MA1 objectAtIndex:TVCrow1] valueForKeyPath:@"name"];
919 b->name = [value2 retain];
921 b->img = [IV1 image];
924 if(TVCrow2 == -1) {b = bTop; return;}
928 for (int i = 0; i < TVCrow2; i++) {
936 if(TVCrow2 >= 0 && b->L && [MA2 count] > 0){
938 NSString *value = [[MA2 objectAtIndex:TVCrow2] valueForKeyPath:@"name"];
939 b->L->name = [value retain];
941 int value2 = [[[MA2 objectAtIndex:TVCrow2] valueForKeyPath:@"z"] intValue];
944 int flag = [[[MA2 objectAtIndex:TVCrow2] valueForKeyPath:@"v"] intValue];
945 //flag = flag>>4 & 0xf;
948 b->L->img = [IV2 image];
952 b->L->visible = true;
956 b->L->visible = false;
968 layerLoadOver = false;
971 STRtop[st] = STRtop[st];
974 [self willChangeValueForKey:@"SEMA1"];
975 [SEMA1 removeAllObjects];
976 [self didChangeValueForKey:@"SEMA1"];
977 [self willChangeValueForKey:@"SEMA2"];
978 [SEMA2 removeAllObjects];
979 [self didChangeValueForKey:@"SEMA2"];
980 [self willChangeValueForKey:@"SEMA3"];
981 [SEMA3 removeAllObjects];
982 [self didChangeValueForKey:@"SEMA3"];
992 STRtop[st] = STRtop[st];
996 STRtop[st] = STRtop[st];
998 TX[st].S = STRtop[st];
999 for(int i = 0;i < sl;i++){
1000 TX[st].S = TX[st].S->next;
1005 TX[st].S = STRtop[st];
1009 SItop = TX[st].S->i;
1010 for(int i = 0;i < SEMArow;i++){
1011 TX[st].S->i = TX[st].S->i->next;
1016 TX[st].S->i->SEMA1row = (int)SEMA1row + 1;
1017 TX[st].S->i->SEMA2row = (int)SEMA2row + 1;
1025 for(int i = 0;i < SEMA1row;i++){
1031 TX[st].S->i = SItop;
1032 TX[st].S = STRtop[st];
1041 for (int i = 0; i < SEMA2row; i++) {
1050 if(i0 == SEMA3row && TX[st].S->i->SEMA3flag){
1051 b->L->visibleInstant = [[SEMA3[SEMA3row] valueForKey:@"v"] intValue];
1052 *(TX[st].S->i->SEMA3flag+i0) = [[SEMA3[SEMA3row] valueForKey:@"v"] intValue]+1;
1071 TX[st].S->i = SItop;
1072 TX[st].S = STRtop[st];
1076 STRtop[st] = STRtop[st];
1081 SEIV.image = SEstandImg;
1084 -(void)saveDataStand{
1086 NSString *directoryPath;
1088 directoryPath = [[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent];
1089 [[NSFileManager defaultManager] changeCurrentDirectoryPath:directoryPath];
1096 NSString *fdata = @"data/StandList/STD";
1097 fdata = [fdata stringByAppendingFormat:@"%d.txt", std];
1099 NSString *Sdata = @"data/StandList/img/S";
1100 Sdata = [Sdata stringByAppendingFormat:@"%d", std];
1102 NSString *fileData = @"";
1104 fileData = [[fileData stringByAppendingString:[NSString stringWithFormat:@"%@", I->name]] stringByAppendingString:@"\n"];
1107 NSString *Bdata = [Sdata stringByAppendingFormat:@"B%d", Bcnt];
1109 fileData = [[fileData stringByAppendingString:[NSString stringWithFormat:@"----"]] stringByAppendingString:@"\n"];
1110 fileData = [[fileData stringByAppendingString:[NSString stringWithFormat:@"%@", I->B->name]] stringByAppendingString:@","];
1111 fileData = [[fileData stringByAppendingString:[NSString stringWithFormat:@"%d", I->B->x]] stringByAppendingString:@","];
1112 fileData = [[fileData stringByAppendingString:[NSString stringWithFormat:@"%d", I->B->y]] stringByAppendingString:@","];
1113 fileData = [[fileData stringByAppendingString:[NSString stringWithFormat:@"%d", I->B->z]] stringByAppendingString:@"\n"];
1118 NSString *Ldata = [Bdata stringByAppendingFormat:@"L%d", Lcnt];
1120 fileData = [[fileData stringByAppendingString:[NSString stringWithFormat:@"%@", I->B->L->name]] stringByAppendingString:@","];
1121 fileData = [[fileData stringByAppendingString:[NSString stringWithFormat:@"%d", I->B->L->x]] stringByAppendingString:@","];
1122 fileData = [[fileData stringByAppendingString:[NSString stringWithFormat:@"%d", I->B->L->y]] stringByAppendingString:@","];
1123 fileData = [[fileData stringByAppendingString:[NSString stringWithFormat:@"%d", I->B->L->z]] stringByAppendingString:@"\n"];
1125 NSData *f2IMGdata = [I->B->L->img TIFFRepresentation];
1126 NSBitmapImageRep *brep = [NSBitmapImageRep imageRepWithData:f2IMGdata];
1127 f2IMGdata = [brep representationUsingType:NSPNGFileType properties:nil];
1129 [f2IMGdata writeToFile:Ldata atomically:YES];
1131 I->B->L = I->B->L->next;
1134 NSData *fIMGdata = [I->B->img TIFFRepresentation];
1135 NSBitmapImageRep *brep = [NSBitmapImageRep imageRepWithData:fIMGdata];
1136 fIMGdata = [brep representationUsingType:NSPNGFileType properties:nil];
1138 [fIMGdata writeToFile:Bdata atomically:YES];
1143 [fileData writeToFile:fdata atomically:YES encoding:NSUTF8StringEncoding error:nil];
1152 -(void)initFileDirectory{
1153 NSString *directoryPath;
1155 directoryPath = [[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent];
1156 [[NSFileManager defaultManager] changeCurrentDirectoryPath:directoryPath];
1159 cwd = getcwd(NULL, 0);
1161 ///// S1B1L1 の用に記述する
1162 ///// STD1 の用にデータファイルはなる
1165 ///// ベース名前 ベースxy 優先度
1166 ///// レイヤー名前 レイヤーxy 優先度 可視
1167 ///// レイヤー名前 レイヤーxy 優先度 可視
1168 ///// レイヤー名前 レイヤーxy 優先度 可視
1170 ///// ベース名前 ベースxy 優先度
1171 ///// レイヤー名前 レイヤーxy 優先度 可視
1172 ///// レイヤー名前 レイヤーxy 優先度 可視
1173 ///// レイヤー名前 レイヤーxy 優先度 可視
1174 ///// レイヤー名前 レイヤーxy 優先度 可視
1177 NSData *InitialData = [NSData dataWithContentsOfFile:@"data/StandList/preset.txt"];
1178 NSString *pathSL = @"data/StandList/img";
1179 NSString *pathDATA2 = @"data/StandList/preset.txt";
1180 NSString *pathSLP = @"data/StandList/preset.txt";
1181 NSString *fileData = nil;
1184 [[NSFileManager defaultManager] createDirectoryAtPath:pathSL withIntermediateDirectories:YES attributes:nil error:nil];
1185 [[NSFileManager defaultManager] createFileAtPath:pathDATA2 contents:nil attributes:nil];
1187 [[NSFileManager defaultManager] createFileAtPath:pathSLP contents:nil attributes:nil];
1192 I = calloc(1, sizeof(STAND));
1193 I->B = calloc(1, sizeof(BASE));
1194 I->B->L = calloc(1, sizeof(LAYER));
1196 for (int i = 0;i < 9999;i++) {
1197 NSString *fdata = @"data/StandList/STD";
1198 fdata = [fdata stringByAppendingFormat:@"%d.txt",i+1];
1199 fileData = [NSString stringWithContentsOfFile:fdata encoding:NSUTF8StringEncoding error:nil];
1203 I->next = calloc(1, sizeof(STAND));
1208 fileDataArray = [fileData componentsSeparatedByString:@"\n"];
1209 I->name = [[fileDataArray objectAtIndex:0] retain];
1210 NSString *imagePath = @"data/StandList/img/S";
1211 imagePath = [imagePath stringByAppendingFormat:@"%d", i+1];
1213 bool initialStrFlag = false;
1216 for(int k= 2;k < [fileDataArray count];k++){
1217 NSString *str = [fileDataArray objectAtIndex:k];
1218 NSRange rangeSearch;
1219 NSArray *rangeArray;
1220 NSString *imagePathB = [imagePath stringByAppendingFormat:@"B%d", Bcnt];
1221 rangeArray = [str componentsSeparatedByString:@","];
1222 rangeSearch = [str rangeOfString:@"----"];
1224 if(!initialStrFlag){
1225 I->B = calloc(1, sizeof(BASE));
1226 I->B->name = [[rangeArray objectAtIndex:0] retain];
1227 I->B->x = [[rangeArray objectAtIndex:1] intValue];
1228 I->B->y = [[rangeArray objectAtIndex:2] intValue];
1229 I->B->z = [[rangeArray objectAtIndex:3] intValue];
1230 NSData *imgData = [NSData dataWithContentsOfFile:imagePathB];
1231 if(imgData) I->B->img = [[NSImage alloc] initWithData:[[NSFileHandle fileHandleForReadingAtPath:imagePathB] readDataToEndOfFile]];
1233 initialStrFlag = true;
1236 if(rangeSearch.location != NSNotFound){
1237 I->B->next = calloc(1, sizeof(BASE));
1239 initialStrFlag = false;
1241 }else if([rangeArray count] > 2){
1242 NSString *imagePathL = [imagePathB stringByAppendingFormat:@"L%d", Lcnt];
1243 I->B->L = calloc(1, sizeof(LAYER));
1245 I->B->L->name = [[rangeArray objectAtIndex:0] intValue];
1246 I->B->L->x = [[rangeArray objectAtIndex:1] intValue];
1247 I->B->L->y = [[rangeArray objectAtIndex:2] intValue];
1248 I->B->L->z = [[rangeArray objectAtIndex:3] intValue];
1249 NSData *imgData = [NSData dataWithContentsOfFile:imagePathL];
1250 if(imgData) I->B->L->img = [[NSImage alloc] initWithData:[[NSFileHandle fileHandleForReadingAtPath:imagePathL] readDataToEndOfFile]];
1252 I->B->L->next = calloc(1, sizeof(LAYER));
1253 I->B->L = I->B->L->next;
1266 -(IBAction)stringData:(id)sender{
1270 -(void)submitLineList{
1273 [Dname setStringValue:@""];
1274 [Dstring setStringValue:@""];
1275 [dialogName setStringValue:@""];
1276 [dialogString setStringValue:@""];
1277 [dialogImage setImage:NULL];
1283 TX[st].S = STRtop[st];
1286 if(TX[st].S != NULL){
1287 for(int k = 0;k < LLrow ;k++) {
1288 TX[st].S = TX[st].S->next;
1291 TX[st].S->name = [[Dname stringValue] retain];
1292 TX[st].S->string = [[Dstring stringValue] retain];
1294 [dialogName setStringValue:TX[st].S->name];
1295 [dialogString setStringValue:TX[st].S->string];
1296 [dialogImage setImage:TX[st].S->img];
1298 [lineListAC setValue:[NSString stringWithFormat:@"%@:%@", TX[st].S->name, TX[st].S->string] forKeyPath:@"selection.name"];
1303 TX[st].S = STRtop[st];
1309 NSString *directoryPath = [[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent];
1310 [[NSFileManager defaultManager] changeCurrentDirectoryPath:directoryPath];
1313 NSData *InitialData = [NSData dataWithContentsOfFile:@"data/StringList/preset.txt"];
1314 NSString *pathFOLDER = @"data/StringList";
1317 [[NSFileManager defaultManager] createDirectoryAtPath:pathFOLDER withIntermediateDirectories:YES attributes:nil error:nil];
1320 NSArray *Farray = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:pathFOLDER error:nil];
1322 NSMutableArray *MA = [NSMutableArray new];
1323 for (int i = 0;i < [Farray count];i++) {
1324 if([[Farray objectAtIndex:i] isEqualToString:@"img"])
1326 else if([[Farray objectAtIndex:i] isEqualToString:@"preset.txt"])
1328 else if([[Farray objectAtIndex:i] isEqualToString:@".DS_Store"])
1331 [MA addObject:[Farray objectAtIndex:i]];
1336 for (int i = 0; i < textNumb;i++) {
1337 TX[i].fileName = [[MA objectAtIndex:i] retain];
1338 //NSLog(@"%@", TX[i].fileName);
1341 for(int i = 0; i< textNumb;i++){
1344 NSMutableDictionary* dict = [NSMutableDictionary new];
1347 [dict setValue:[NSString stringWithFormat:@"%@", TX[i].fileName] forKey:@"name"];
1348 [self willChangeValueForKey:@"textListMA"];
1349 [textListMA addObject:dict];
1350 [self didChangeValueForKey:@"textListMA"];
1353 [textListAC setSelectionIndex:9999];
1354 ///NSLog(@"%@", textListMA);
1360 st = [textListTV selectedRow];
1361 NSArray *fileDataArray;
1362 for(int i = 0;i < textNumb;i++){
1363 NSString *tfD = @"data/StringList/";
1364 tfD = [tfD stringByAppendingFormat:@"%@", TX[i].fileName];
1365 NSString *textFileData = [NSString stringWithContentsOfFile:tfD encoding:NSUTF8StringEncoding error:nil];
1366 fileDataArray = [textFileData componentsSeparatedByString:@"\n"];
1368 STRtop[i] = TX[i].S;
1370 for(int j = 0;j<[fileDataArray count];j++){
1371 NSString *str = [fileDataArray objectAtIndex:j];
1372 NSRange range = NSMakeRange(2, str.length - 2);
1373 NSRange rangeSearch;
1374 NSRange rangeSearch2;
1375 NSRange rangeSearch3;
1376 NSArray *rangeArray;
1377 NSRange rangeSearch4;
1378 NSArray *rangeArray2;
1379 NSRange rangeSearch5;
1380 NSArray *rangeArray3;
1381 bool commentSwitch = false;
1382 rangeSearch = [str rangeOfString:@"##"];
1383 rangeSearch2 = [str rangeOfString:@"####"];
1384 rangeSearch3 = [str rangeOfString:@"##" options:NSBackwardsSearch];
1385 rangeArray = [str componentsSeparatedByString:@"##"];
1386 rangeArray2 = [str componentsSeparatedByString:@"%%"];
1387 rangeSearch4 = [str rangeOfString:@"%%"];
1388 rangeSearch5 = [str rangeOfString:@"$$"];
1389 rangeArray3 = [str componentsSeparatedByString:@"$$"];
1391 if (rangeSearch2.location != NSNotFound) {commentSwitch = true;
1393 }else if (rangeSearch.location != NSNotFound) {commentSwitch = false;
1395 StringText *stringText = [[StringText alloc] init];
1397 [stringText AddString:&TX[i].S :TX[i].S->index];
1398 //TX[i].S->next->iNameWall =TX[i].S->iNameWall;
1399 //TX[i].S->next->imgWall = TX[i].S->imgWall;
1400 //TX[i].S->next->wallFadeOut = TX[i].S->wallFadeOut;
1401 //TX[i].S->next->iNameStand =TX[i].S->iNameStand;
1402 //TX[i].S->next->imgStand = TX[i].S->imgStand;
1403 //TX[i].S->next->standPossition =TX[i].S->standPossition;
1405 if(SItop) TX[i].S->i = SItop;
1408 TX[i].S = TX[i].S->next;
1409 TX[i].S->name = [[str substringWithRange:range] retain];
1410 TX[i].S->name = [[rangeArray objectAtIndex:1] retain];
1411 TX[i].S->string = @"";
1412 if(rangeSearch3.location != NSNotFound && [rangeArray count] > 2){
1414 TX[i].S->iName = [[rangeArray objectAtIndex:2] retain];
1415 TX[i].S->img = [NSImage imageNamed:TX[i].S->iName];
1417 NSString *iPath = @"data/StringList/img/";
1418 iPath = [iPath stringByAppendingString:TX[i].S->iName];
1419 NSData *iData = [NSData dataWithContentsOfFile:iPath];
1421 NSImage *iImg = [[NSImage alloc] initWithContentsOfFile:iPath];
1422 TX[i].S->img = iImg;
1425 }else if(rangeSearch4.location != NSNotFound){
1426 TX[i].S->iNameWall = [[str substringWithRange:range] retain];
1427 TX[i].S->iNameWall = [[rangeArray2 objectAtIndex:1] retain];
1428 TX[i].S->iNameWallSort = [[rangeArray2 objectAtIndex:2] retain];
1429 TX[i].S->imgWall = [NSImage imageNamed:TX[i].S->iNameWall];
1431 TX[i].S->wallChanged = true;
1434 NSString *iPath = @"data/StringList/img/";
1435 iPath = [iPath stringByAppendingString:TX[i].S->iNameWall];
1436 NSData *iData = [NSData dataWithContentsOfFile:iPath];
1438 NSImage *iImg = [[NSImage alloc] initWithContentsOfFile:iPath];
1439 TX[i].S->imgWall = iImg;
1441 if(rangeSearch4.location != NSNotFound && [rangeArray2 count] > 2){
1443 if ([[rangeArray2 objectAtIndex:2] isEqualToString:@"FI"]) {
1444 TX[i].S->wallFadeIn = true;
1445 }else if([[rangeArray2 objectAtIndex:2] isEqualToString:@"FO"]){
1446 TX[i].S->wallFadeOut = true;
1447 }else if([[rangeArray2 objectAtIndex:2] isEqualToString:@"FIO"]){
1448 TX[i].S->wallFadeIn = true;
1449 TX[i].S->wallFadeOut = true;
1453 }else if(rangeSearch5.location != NSNotFound){
1455 if([rangeArray3 count] >= 5){
1458 TX[i].S->i = calloc(1, sizeof(STANDIMAGE));
1460 }else if(siCnt > 0){
1461 TX[i].S->i->next = calloc(1, sizeof(STANDIMAGE));
1462 if(siCnt == 1) SItop = TX[i].S->i;
1463 TX[i].S->i = TX[i].S->i->next;
1465 NSArray *sArray = [[rangeArray3 objectAtIndex:1] componentsSeparatedByString:@"["];
1466 NSArray *sArray2 = [sArray[1] componentsSeparatedByString:@","];
1468 TX[i].S->i->name = [sArray[0] retain];
1469 TX[i].S->i->standX = [sArray2[0] intValue];
1470 TX[i].S->i->standY = [sArray2[1] intValue];
1471 TX[i].S->i->SEMA1row = [[rangeArray3 objectAtIndex:2] intValue] + 1;
1472 TX[i].S->i->SEMA2row = [[rangeArray3 objectAtIndex:3] intValue] + 1;
1474 if(TX[i].S->i->SEMA1row < 0){
1475 TX[i].S->i->SEMA1row = 0;
1477 if(TX[i].S->i->SEMA2row < 0){
1478 TX[i].S->i->SEMA1row = 0;
1481 if(![[rangeArray3 objectAtIndex:4] isEqualToString:@""]){
1482 NSArray *sArray3 = [[rangeArray3 objectAtIndex:4] componentsSeparatedByString:@","];
1483 TX[i].S->i->SEMA3flag = calloc(999, sizeof(int));
1485 for (NSString *ary in sArray3) {
1486 *(TX[i].S->i->SEMA3flag + i0) = [ary intValue] + 1;
1487 NSLog(@"SEMA3[%d]%d", i0, *(TX[i].S->i->SEMA3flag + i0));
1493 }else if(!commentSwitch){
1494 TX[i].S->string = [[TX[i].S->string stringByAppendingString:str] retain];
1496 if([fileDataArray count] > 1 && [fileDataArray count] > j){
1497 NSString *str2 = [fileDataArray objectAtIndex:j];
1498 NSRange rangeSearchA = [str2 rangeOfString:@"##"];
1499 NSRange rangeSearchB = [str2 rangeOfString:@"%%"];
1500 NSRange rangeSearchC = [str2 rangeOfString:@"$$"];
1501 if (rangeSearchA.location == NSNotFound && rangeSearchB.location == NSNotFound && rangeSearchC.location == NSNotFound)
1502 TX[i].S->string = [[TX[i].S->string stringByAppendingString:@"\n"] retain];
1506 STRtop[i] = STRtop[i]->next;
1507 TX[i].S = STRtop[i];
1511 NSLog(@"fN:%@\nNM:%@\nST:%@", TX[3].fileName, TX[3].S->name, TX[3].S->string);
1512 TX[3].S = TX[3].S->next;
1513 NSLog(@"fN:%@\nNM:%@\nST:%@", TX[3].fileName, TX[3].S->name, TX[3].S->string);
1514 TX[3].S = TX[3].S->next;
1515 NSLog(@"fN:%@\nNM:%@\nST:%@", TX[3].fileName, TX[3].S->name, TX[3].S->string);
1523 -(IBAction)titleBtn:(id)sender{
1525 [scenarioEditorWindow close];
1526 [titleWindow makeKeyAndOrderFront:nil];
1529 -(IBAction)insertLine:(id)sender{
1531 NSMutableDictionary *dict = [NSMutableDictionary new];
1532 [dict setValue:[NSString stringWithFormat:@"oops"] forKey:@"name"];
1534 STRtop[st] = TX[st].S;
1537 TX[st].S = STRtop[st];
1538 if([lineListMA count] == 0){
1539 TX[st].S = calloc(1, sizeof(STRING));
1541 TX[st].S->name = @"";
1542 TX[st].S->string = @"";
1543 TX[st].S->next = NULL;
1544 STRtop[st] = TX[st].S;
1546 while(TX[st].S->next) TX[st].S = TX[st].S->next;
1547 TX[st].S->next = calloc(1, sizeof(STRING));
1548 TX[st].S = TX[st].S->next;
1550 TX[st].S->name = @"";
1551 TX[st].S->string = @"";
1552 TX[st].S->next = NULL;
1553 TX[st].S = STRtop[st];
1556 [dict setValue:[NSString stringWithFormat:@":"] forKey:@"name"];
1558 [self willChangeValueForKey:@"lineListMA"];
1559 [lineListMA insertObject:dict atIndex:[lineListMA count]];
1560 [self didChangeValueForKey:@"lineListMA"];
1561 [lineListAC setSelectionIndex:9999];
1564 TX[st].S = STRtop[st];
1565 if([lineListMA count] == 0){
1566 TX[st].S = calloc(1, sizeof(STRING));
1568 TX[st].S->name = @"";
1569 TX[st].S->string = @"";
1570 TX[st].S->next = NULL;
1571 STRtop[st] = TX[st].S;
1572 }else if(LLrow > 0){
1573 for (int i = 0; i < LLrow-1;i++)
1574 TX[st].S = TX[st].S->next;
1575 STRING *tmp = calloc(1, sizeof(STRING));
1576 *tmp = *TX[st].S->next;
1577 TX[st].S->next = calloc(1, sizeof(STRING));
1578 TX[st].S->next->next = tmp;
1579 TX[st].S->next->name = @"";
1580 TX[st].S->next->string = @"";
1581 TX[st].S = TX[st].S->next;
1582 TX[st].S = STRtop[st];
1584 STRING *tmp = calloc(1, sizeof(STRING));
1585 tmp->next = TX[st].S;
1586 // INIT 処理[self InitAttack:tmp];
1590 TX[st].S = STRtop[st];
1593 [dict setValue:[NSString stringWithFormat:@":"] forKey:@"name"];
1595 [self willChangeValueForKey:@"lineListMA"];
1596 [lineListMA insertObject:dict atIndex:LLrow];
1597 [self didChangeValueForKey:@"lineListMA"];
1598 [lineListAC setSelectionIndex:LLrow];
1601 [Dname setStringValue:TX[st].S->name];
1602 [Dstring setStringValue:TX[st].S->string];
1603 [dialogName setStringValue:TX[st].S->name];
1604 [dialogString setStringValue:TX[st].S->string];
1605 [dialogImage setImage:TX[st].S->img];
1607 TX[st].S = STRtop[st];
1609 -(IBAction)removeLine:(id)sender{
1611 STRtop[st] = TX[st].S;
1614 LLrow = (int)[lineListMA count] - 1;
1617 if([lineListMA count] > 0){
1620 TX[st].S = STRtop[st];
1621 TX[st].S = TX[st].S->next;
1622 STRtop[st] = TX[st].S;
1623 }else if(LLrow == [lineListMA count] - 1){
1624 TX[st].S = STRtop[st];
1625 while(TX[st].S->next->next){
1626 TX[st].S = TX[st].S->next;
1628 TX[st].S->next = NULL;
1630 TX[st].S = STRtop[st];
1631 for (int i = 0; i < LLrow - 1;i++)
1632 TX[st].S = TX[st].S->next;
1633 TX[st].S->next = TX[st].S->next->next;
1636 [self willChangeValueForKey:@"lineListMA"];
1637 [lineListMA removeObjectAtIndex:LLrow];
1638 [self didChangeValueForKey:@"lineListMA"];
1639 [lineListAC setSelectionIndex:LLrow-1];
1640 if(LLrow < 0) [lineListAC setSelectionIndex:[lineListMA count]-1];
1641 if(LLrow == 0) [lineListAC setSelectionIndex:0];
1644 [Dname setStringValue:TX[st].S->name];
1645 [Dstring setStringValue:TX[st].S->string];
1646 [dialogName setStringValue:TX[st].S->name];
1647 [dialogString setStringValue:TX[st].S->string];
1648 [dialogImage setImage:TX[st].S->img];
1652 if(TX[st].S->name) [Dname setStringValue:TX[st].S->name];
1653 else [Dname setStringValue:@""];
1656 if(TX[st].S->string) [Dstring setStringValue:TX[st].S->string];
1657 else [Dstring setStringValue:@""];
1661 if(TX[st].S->name) [dialogName setStringValue:TX[st].S->name];
1662 else [dialogName setStringValue:@""];
1666 if(TX[st].S->string) [dialogString setStringValue:TX[st].S->string];
1667 else [dialogString setStringValue:@""];
1671 [dialogImage setImage:TX[st].S->img];
1673 TX[st].S = STRtop[st];
1678 -(void)saveLineDataFnc{
1679 NSString *directoryPath = [[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent];
1680 [[NSFileManager defaultManager] changeCurrentDirectoryPath:directoryPath];
1682 NSString *saveDataPath = @"data/StringList/";
1684 saveDataPath = [saveDataPath stringByAppendingFormat:@"%@", TX[st].fileName];
1686 NSString *fileData = @"";
1689 STRtop[st] = TX[st].S;
1691 if(!TX[st].S) return;
1692 if(TX[st].S->string == NULL) return;
1693 //if(TX[st].S->next != NULL) return;
1695 fileData = [fileData stringByAppendingString:[NSString stringWithFormat:@"##"]];
1696 fileData = [fileData stringByAppendingString:[NSString stringWithFormat:@"%@", TX[st].S->name]];
1697 if(TX[st].S->iName != NULL) {
1698 fileData = [fileData stringByAppendingString:[NSString stringWithFormat:@"##"]];
1699 fileData = [fileData stringByAppendingString:[NSString stringWithFormat:@"%@", TX[st].S->iName]];
1701 fileData = [fileData stringByAppendingString:[NSString stringWithFormat:@"\n"]];
1703 fileData = [fileData stringByAppendingString:[NSString stringWithFormat:@"%@", TX[st].S->string]];
1705 NSString *omfgBR = @"";
1706 if([TX[st].S->string length] > 0){
1707 omfgBR = [TX[st].S->string substringFromIndex:[TX[st].S->string length]-1];
1709 if(![omfgBR isEqualToString:@"\n"]){
1710 fileData = [fileData stringByAppendingString:[NSString stringWithFormat:@"\n"]];
1713 SItop = TX[st].S->i;
1714 while(TX[st].S->i) {
1715 fileData = [fileData stringByAppendingString:[NSString stringWithFormat:@"$$"]];
1716 fileData = [fileData stringByAppendingString:[NSString stringWithFormat:@"%@[%d,%d]", TX[st].S->i->name, TX[st].S->i->standX, TX[st].S->i->standY]];
1717 fileData = [fileData stringByAppendingString:[NSString stringWithFormat:@"$$"]];
1718 fileData = [fileData stringByAppendingString:[NSString stringWithFormat:@"%d", TX[st].S->i->SEMA1row - 1]];
1719 fileData = [fileData stringByAppendingString:[NSString stringWithFormat:@"$$"]];
1720 fileData = [fileData stringByAppendingString:[NSString stringWithFormat:@"%d", TX[st].S->i->SEMA2row - 1]];
1721 fileData = [fileData stringByAppendingString:[NSString stringWithFormat:@"$$"]];
1725 for(int i = 0;i < SEMA1row;i++){
1732 for(int i = 0;i < SEMA2row;i++){
1737 if(TX[st].S->i->SEMA3flag)
1738 for(int i = 0;*(TX[st].S->i->SEMA3flag + i) > 0;i++){
1740 fileData = [fileData stringByAppendingString:@","];
1741 fileData = [fileData stringByAppendingString:[NSString stringWithFormat:@"%d", *(TX[st].S->i->SEMA3flag + i)-1]];
1750 fileData = [fileData stringByAppendingString:[NSString stringWithFormat:@"\n"]];
1752 TX[st].S->i = TX[st].S->i->next;
1753 }TX[st].S->i = SItop;
1755 if(TX[st].S->imgWall != NULL) {
1756 fileData = [fileData stringByAppendingString:[NSString stringWithFormat:@"%%%%"]];
1757 fileData = [fileData stringByAppendingString:[NSString stringWithFormat:@"%@", TX[st].S->iNameWall]];
1758 if (TX[st].S->wallFadeIn && TX[st].S->wallFadeOut) {
1759 fileData = [fileData stringByAppendingString:[NSString stringWithFormat:@"%%%%"]];
1760 fileData = [fileData stringByAppendingString:[NSString stringWithFormat:@"FIO"]];
1762 else if(TX[st].S->wallFadeIn) {
1763 fileData = [fileData stringByAppendingString:[NSString stringWithFormat:@"%%%%"]];
1764 fileData = [fileData stringByAppendingString:[NSString stringWithFormat:@"FI"]];
1766 else if(TX[st].S->wallFadeOut) {
1767 fileData = [fileData stringByAppendingString:[NSString stringWithFormat:@"%%%%"]];
1768 fileData = [fileData stringByAppendingString:[NSString stringWithFormat:@"FO"]];
1770 fileData = [fileData stringByAppendingString:[NSString stringWithFormat:@"%%%%"]];
1771 fileData = [fileData stringByAppendingString:[NSString stringWithFormat:@"NULL"]];
1773 if(TX[st].S->iNameWallSort){
1774 fileData = [fileData stringByAppendingString:[NSString stringWithFormat:@"%%%%"]];
1775 fileData = [fileData stringByAppendingString:[NSString stringWithFormat:@"%@",TX[st].S->iNameWallSort]];
1777 fileData = [fileData stringByAppendingString:[NSString stringWithFormat:@"\n"]];
1779 NSString *path = @"data/StringList/img/";
1780 NSData *data = [TX[st].S->img TIFFRepresentation];
1781 NSBitmapImageRep *brep = [NSBitmapImageRep imageRepWithData:data];
1782 data = [brep representationUsingType:NSPNGFileType properties:nil];
1784 path = [path stringByAppendingString:TX[st].S->iName];
1786 [data writeToFile:path atomically:YES];
1787 }if(TX[st].S->imgWall){
1788 NSString *path = @"data/StringList/img/";
1789 NSData *data = [TX[st].S->imgWall TIFFRepresentation];
1790 NSBitmapImageRep *brep = [NSBitmapImageRep imageRepWithData:data];
1791 data = [brep representationUsingType:NSPNGFileType properties:nil];
1793 path = [path stringByAppendingString:TX[st].S->iNameWall];
1795 [data writeToFile:path atomically:YES];
1800 TX[st].S = TX[st].S->next;
1801 }while(TX[st].S != NULL);
1803 [fileData writeToFile:saveDataPath atomically:YES encoding:NSUTF8StringEncoding error:nil];
1806 TX[st].S = STRtop[st];
1809 -(IBAction)saveLineData:(id)sender{
1812 [self saveLineDataFnc];
1815 -(IBAction)detailBtn:(id)sender{
1822 for(int i = 0;i < sl;i++){
1823 TX[st].S = TX[st].S->next;
1827 [IVface setImage:TX[st].S->img];
1828 [IVwall setImage:TX[st].S->imgWall];
1831 [TFface setStringValue:TX[st].S->iName];
1833 [TFface setStringValue:@""];
1835 if(TX[st].S->iNameWall)
1836 [TFwall setStringValue:TX[st].S->iNameWall];
1838 [TFwall setStringValue:@""];
1841 [SEstandTFx setStringValue:[NSString stringWithFormat:@"0"]];
1842 [SEstandTFy setStringValue:[NSString stringWithFormat:@"0"]];
1844 //NSLog(@"[%@]",[TFface stringValue]);
1846 [FIbtn setState:TX[st].S->wallFadeIn];
1847 [FObtn setState:TX[st].S->wallFadeOut];
1850 SEMA1row = TX[st].S->i->SEMA1row - 1;
1851 SEMA2row = TX[st].S->i->SEMA2row - 1;
1860 [self willChangeValueForKey:@"SEMA"];
1861 [SEMA removeAllObjects];
1862 [self didChangeValueForKey:@"SEMA"];
1866 SItop = TX[st].S->i;
1867 while (TX[st].S->i) {
1868 NSMutableDictionary *dict = [NSMutableDictionary new];
1870 [dict setValue:[NSString stringWithFormat:@"%@", TX[st].S->i->name] forKey:@"name"];
1872 [self willChangeValueForKey:@"SEMA"];
1873 [SEMA addObject:dict];
1874 [self didChangeValueForKey:@"SEMA"];
1876 TX[st].S->i = TX[st].S->i->next;
1877 }TX[st].S->i = SItop;
1880 [SEAC setSelectionIndex:9999];
1882 TX[st].S = STRtop[st];
1885 [SEAC1 setSelectionIndex:9999];
1887 [SEAC1 setSelectionIndex:SEMA1row];
1889 [SEAC2 setSelectionIndex:9999];
1891 [SEAC2 setSelectionIndex:SEMA2row];
1892 [SEAC3 setSelectionIndex:9999];
1894 STRtop[st] = STRtop[st];
1895 standChoiceFlag = true;
1897 [detailWindow makeKeyAndOrderFront:nil];
1900 -(IBAction)standBtn:(id)sender{
1902 [self loadStandData];
1907 standEditorFlag = true;
1909 [standPanel makeKeyAndOrderFront:nil];
1912 -(IBAction)backStand:(id)sender{
1913 [self saveStandData];
1915 [self loadStandData];
1918 standEditorFlag = false;
1921 [scenarioEditorWindow makeKeyAndOrderFront:nil];
1925 -(IBAction)submitStand:(id)sender{
1926 [standEditorPanel close];
1927 //[self saveDataStand];
1928 [self saveStandData];
1929 [self loadStandData];
1932 [standPanel makeKeyAndOrderFront:nil];
1936 -(IBAction)insertLineStand:(id)sender{
1937 NSMutableDictionary *dict = [NSMutableDictionary new];
1938 [dict setValue:[NSString stringWithFormat:@"新規立ち絵"] forKey:@"name"];
1944 if([standListMA count] == 0){
1945 I = calloc(1, sizeof(STAND));
1950 I->name = [@"新規立ち絵" retain];
1954 while(I->next) I = I->next;
1955 I->next = calloc(1, sizeof(STAND));
1960 I->name = [@"新規立ち絵" retain];
1967 [self willChangeValueForKey:@"standListMA"];
1968 [standListMA insertObject:dict atIndex:[standListMA count]];
1969 [self didChangeValueForKey:@"standListMA"];
1970 [standListAC setSelectionIndex:9999];
1975 if([standListMA count] == 0){
1976 I = calloc(1, sizeof(STAND));
1980 I->name = [@"新規立ち絵" retain];
1984 for (int i = 0; i < Irow-1;i++)
1986 STAND *tmp = calloc(1, sizeof(STAND));
1988 I->next = calloc(1, sizeof(STAND));
1989 I->next->next = tmp;
1994 I->name = [@"新規立ち絵" retain];
1997 STAND *tmp = calloc(1, sizeof(STAND));
1999 // INIT 処理[self InitAttack:tmp];
2001 tmp->registerNum = 0;
2002 tmp->name = [@"新規立ち絵" retain];
2009 [self willChangeValueForKey:@"standListMA"];
2010 [standListMA insertObject:dict atIndex:Irow];
2011 [self didChangeValueForKey:@"standListMA"];
2012 [standListAC setSelectionIndex:Irow];
2016 [self saveDataStand];
2018 [self initLineBaseLayer];
2025 NSMutableDictionary *dict = [NSMutableDictionary new];
2026 if([standListMA count] == 0){
2028 Itop = calloc(1, sizeof(STAND));
2030 I->name = [@"新規立ち絵" retain];
2032 [dict setValue:[NSString stringWithFormat:@"%@", I->name] forKey:@"name"];
2034 [self willChangeValueForKey:@"standListMA"];
2035 [standListMA insertObject:dict atIndex:[standListMA count]];
2036 [self didChangeValueForKey:@"standListMA"];
2037 [standListAC setSelectionIndex:999];
2038 }else if(Irow == -1){
2042 I->next = calloc(1, sizeof(STAND));
2044 I->name = [@"新規立ち絵" retain];
2046 [dict setValue:[NSString stringWithFormat:@"%@", I->name] forKey:@"name"];
2048 [self willChangeValueForKey:@"standListMA"];
2049 [standListMA insertObject:dict atIndex:[standListMA count]];
2050 [self didChangeValueForKey:@"standListMA"];
2051 [standListAC setSelectionIndex:999];
2054 for (int i = 0; i < Irow-1; i++) {
2057 STAND *tmp = (STAND*)malloc(sizeof(STAND));
2059 I->next = (STAND*)malloc(sizeof(STAND));
2060 I->next->next = tmp;
2062 I->name = [@"新規立ち絵" retain];
2064 [dict setValue:[NSString stringWithFormat:@"%@", I->name] forKey:@"name"];
2065 [self willChangeValueForKey:@"standListMA"];
2066 [standListMA insertObject:dict atIndex:Irow];
2067 [self didChangeValueForKey:@"standListMA"];
2068 [standListAC setSelectionIndex:999];
2074 I->name = [@"新規立ち絵" retain];
2076 I->next = calloc(1, sizeof(STAND));
2081 [dict setValue:[NSString stringWithFormat:@"%@", I->name] forKey:@"name"];
2083 [self willChangeValueForKey:@"standListMA"];
2084 [standListMA insertObject:dict atIndex:Irow];
2085 [self didChangeValueForKey:@"standListMA"];
2086 [standListAC setSelectionIndex:999];
2095 [self saveStandData];
2097 [self loadStandData];
2099 //[self initLineBaseLayer];
2102 -(IBAction)removeLineStand:(id)sender{
2108 Irow = (int)[standListMA count] - 1;
2111 if([standListMA count] > 0){
2117 }else if(Irow == [standListMA count] - 1){
2119 while(I->next->next){
2125 for (int i = 0; i < Irow - 1;i++)
2127 I->next = I->next->next;
2130 [self willChangeValueForKey:@"standListMA"];
2131 [standListMA removeObjectAtIndex:Irow];
2132 [self didChangeValueForKey:@"standListMA"];
2133 [standListAC setSelectionIndex:Irow-1];
2134 if(Irow < 0) [standListAC setSelectionIndex:[standListMA count]-1];
2135 if(Irow == 0) [standListAC setSelectionIndex:0];
2136 if(Irow > 0) Irow--;
2142 NSString *directoryPath = [[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent];
2143 [[NSFileManager defaultManager] changeCurrentDirectoryPath:directoryPath];
2145 NSString *path = @"data/Scenario/";
2150 if([standListMA count] == 0){
2152 }else if(Irow == -1){
2153 for(int i = 0;i < [standListMA count]-1;i++){
2155 if(i == [standListMA count] - 2)
2161 if([standListMA count] > 1) {
2162 path = [path stringByAppendingFormat:@"%@",I->next->fName];
2165 [[NSFileManager defaultManager] removeItemAtPath:path error:nil];
2169 path = [path stringByAppendingFormat:@"%@",Itop->fName];
2171 [[NSFileManager defaultManager] removeItemAtPath:path error:nil];
2175 [self willChangeValueForKey:@"standListMA"];
2176 [standListMA removeObjectAtIndex:[standListMA count]-1];
2177 [self didChangeValueForKey:@"standListMA"];
2178 [standListAC setSelectionIndex:999];
2181 for (int i = 0; i < Irow-1; i++) {
2186 path = [path stringByAppendingFormat:@"%@",I->next->fName];
2188 [[NSFileManager defaultManager] removeItemAtPath:path error:nil];
2190 I->next = I->next->next;
2192 [self willChangeValueForKey:@"standListMA"];
2193 [standListMA removeObjectAtIndex:Irow];
2194 [self didChangeValueForKey:@"standListMA"];
2195 [standListAC setSelectionIndex:999];
2198 path = [path stringByAppendingFormat:@"%@",Itop->fName];
2200 [[NSFileManager defaultManager] removeItemAtPath:path error:nil];
2204 [self willChangeValueForKey:@"standListMA"];
2205 [standListMA removeObjectAtIndex:Irow];
2206 [self didChangeValueForKey:@"standListMA"];
2207 [standListAC setSelectionIndex:999];
2215 [self saveStandData];
2217 [self loadStandData];
2219 // [self initMA1MA2];
2224 -(IBAction)insertLineBase:(id)sender{
2226 NSMutableDictionary *dict = [NSMutableDictionary new];
2227 [dict setValue:[NSString stringWithFormat:@"新規ベース"] forKey:@"name"];
2230 for (int i = 0; i < Irow; i++) {
2239 if([baseListMA count] == 0){
2240 I->B = calloc(1, sizeof(BASE));
2245 I->B->name = [@"新規ベース" retain];
2251 while(I->B->next) I->B = I->B->next;
2252 I->B->next = calloc(1, sizeof(BASE));
2257 I->B->name = [@"新規ベース" retain];
2264 [dict setValue:[NSString stringWithFormat:@"%d", I->B->z] forKey:@"pref"];
2266 [self willChangeValueForKey:@"baseListMA"];
2267 [baseListMA insertObject:dict atIndex:[baseListMA count]];
2268 [self didChangeValueForKey:@"baseListMA"];
2269 [baseListAC setSelectionIndex:9999];
2273 if([baseListMA count] == 0){
2274 I->B = calloc(1, sizeof(BASE));
2278 I->B->name = [@"新規ベース" retain];
2283 }else if(IBrow > 0){
2284 for (int i = 0; i < IBrow-1;i++)
2286 BASE *tmp = calloc(1, sizeof(BASE));
2288 I->B->next = calloc(1, sizeof(BASE));
2289 I->B->next->next = tmp;
2295 I->B->name = [@"新規ベース" retain];
2299 BASE *tmp = calloc(1, sizeof(BASE));
2301 // INIT 処理[self InitAttack:tmp];
2304 tmp->name = [@"新規ベース" retain];
2311 [dict setValue:[NSString stringWithFormat:@"%d", I->B->z] forKey:@"pref"];
2313 [self willChangeValueForKey:@"baseListMA"];
2314 [baseListMA insertObject:dict atIndex:IBrow];
2315 [self didChangeValueForKey:@"baseListMA"];
2316 [baseListAC setSelectionIndex:IBrow];
2324 -(IBAction)removeLineBase:(id)sender{
2327 IBrow = (int)[baseListMA count] - 1;
2331 for (int i = 0; i < Irow; i++) {
2336 if([baseListMA count] > 0){
2343 }else if(IBrow == [baseListMA count] - 1){
2345 while(I->B->next->next){
2352 for (int i = 0; i < IBrow - 1;i++)
2354 I->B->next = I->B->next->next;
2358 [self willChangeValueForKey:@"baseListMA"];
2359 [baseListMA removeObjectAtIndex:IBrow];
2360 [self didChangeValueForKey:@"baseListMA"];
2361 [baseListAC setSelectionIndex:IBrow-1];
2362 if(IBrow < 0) [baseListAC setSelectionIndex:[baseListMA count]-1];
2363 if(IBrow == 0) [baseListAC setSelectionIndex:0];
2364 if(IBrow > 0) IBrow--;
2371 [self initLineLayer];
2375 -(void)initLineBaseLayer{
2377 [self willChangeValueForKey:@"baseListMA"];
2378 [baseListMA removeAllObjects];
2379 [self didChangeValueForKey:@"baseListMA"];
2381 [self willChangeValueForKey:@"layerListMA"];
2382 [layerListMA removeAllObjects];
2383 [self didChangeValueForKey:@"layerListMA"];
2386 for (int i = 0; i < Irow; i++) {
2391 NSMutableDictionary *dict = [NSMutableDictionary new];
2392 [dict setValue:[NSString stringWithFormat:@"%@", I->B->name] forKey:@"name"];
2393 [dict setValue:[NSString stringWithFormat:@"%d", I->B->z] forKey:@"pref"];
2395 [self willChangeValueForKey:@"baseListMA"];
2396 [baseListMA addObject:dict];
2397 [self didChangeValueForKey:@"baseListMA"];
2405 -(void)initLineLayer{
2407 [self willChangeValueForKey:@"layerListMA"];
2408 [layerListMA removeAllObjects];
2409 [self didChangeValueForKey:@"layerListMA"];
2411 if(IBrow < 0) return;
2414 for (int i = 0; i < Irow; i++) {
2419 for (int i = 0; i < IBrow; i++) {
2427 NSMutableDictionary *dict = [NSMutableDictionary new];
2428 [dict setValue:[NSString stringWithFormat:@"%@", I->B->L->name] forKey:@"name"];
2429 [dict setValue:[NSString stringWithFormat:@"%d", I->B->L->z] forKey:@"pref"];
2430 [dict setValue:[NSString stringWithFormat:@"%d", I->B->L->visible] forKey:@"visible"];
2432 [self willChangeValueForKey:@"layerListMA"];
2433 [layerListMA addObject:dict];
2434 [self didChangeValueForKey:@"layerListMA"];
2435 I->B->L = I->B->L->next;
2446 -(IBAction)insertLineLayer:(id)sender{
2448 if(IBrow < 0) return;
2451 NSMutableDictionary *dict = [NSMutableDictionary new];
2452 [dict setValue:[NSString stringWithFormat:@"新規レイヤー"] forKey:@"name"];
2454 for (int i = 0; i < Irow; i++) {
2459 for (int i = 0; i < IBrow; i++) {
2468 if([layerListMA count] == 0){
2469 I->B->L = calloc(1, sizeof(LAYER));
2474 I->B->L->name = [@"新規レイヤー" retain];
2475 I->B->L->next = NULL;
2478 while(I->B->L->next) I->B->L = I->B->L->next;
2479 I->B->L->next = calloc(1, sizeof(LAYER));
2480 I->B->L = I->B->L->next;
2484 I->B->L->name = [@"新規レイヤー" retain];
2485 I->B->L->next = NULL;
2489 [dict setValue:[NSString stringWithFormat:@"%d", I->B->L->z] forKey:@"pref"];
2491 [self willChangeValueForKey:@"layerListMA"];
2492 [layerListMA insertObject:dict atIndex:[layerListMA count]];
2493 [self didChangeValueForKey:@"layerListMA"];
2494 [layerListAC setSelectionIndex:9999];
2498 if([layerListMA count] == 0){
2499 I->B->L = calloc(1, sizeof(LAYER));
2503 I->B->L->name = [@"新規レイヤー" retain];
2504 I->B->L->next = NULL;
2506 }else if(IBLrow > 0){
2507 for (int i = 0; i < IBLrow-1;i++)
2508 I->B->L = I->B->L->next;
2509 LAYER *tmp = calloc(1, sizeof(LAYER));
2510 *tmp = *I->B->L->next;
2511 I->B->L->next = calloc(1, sizeof(LAYER));
2512 I->B->L->next->next = tmp;
2513 I->B->L = I->B->L->next;
2517 I->B->L->name = [@"新規レイヤー" retain];
2520 LAYER *tmp = calloc(1, sizeof(LAYER));
2521 tmp->next = I->B->L;
2522 // INIT 処理[self InitAttack:tmp];
2525 tmp->name = [@"新規レイヤー" retain];
2530 [dict setValue:[NSString stringWithFormat:@"%d", I->B->L->z] forKey:@"pref"];
2532 [self willChangeValueForKey:@"layerListMA"];
2533 [layerListMA insertObject:dict atIndex:IBLrow];
2534 [self didChangeValueForKey:@"layerListMA"];
2535 [layerListAC setSelectionIndex:IBLrow];
2543 -(IBAction)removeLineLayer:(id)sender{
2545 if(IBrow < 0) return;
2549 IBLrow = (int)[layerListMA count] - 1;
2553 for (int i = 0; i < Irow; i++) {
2558 for (int i = 0; i < IBrow; i++) {
2563 if([layerListMA count] > 0){
2567 I->B->L = I->B->L->next;
2570 }else if(IBLrow == [layerListMA count] - 1){
2572 while(I->B->L->next->next){
2573 I->B->L = I->B->L->next;
2576 I->B->L->next = NULL;
2579 for (int i = 0; i < IBLrow - 1;i++)
2580 I->B->L = I->B->L->next;
2581 I->B->L->next = I->B->L->next->next;
2585 [self willChangeValueForKey:@"layerListMA"];
2586 [layerListMA removeObjectAtIndex:IBLrow];
2587 [self didChangeValueForKey:@"layerListMA"];
2588 [layerListAC setSelectionIndex:IBrow-1];
2589 if(IBLrow < 0) [layerListAC setSelectionIndex:[layerListMA count]-1];
2590 if(IBLrow == 0) [layerListAC setSelectionIndex:0];
2591 if(IBLrow > 0) IBLrow--;
2604 -(IBAction)detailClose:(id)sender{
2606 TX[st].S = STRtop[st];
2607 for(int i = 0;i < sl;i++){
2608 TX[st].S = TX[st].S->next;
2611 SItop = TX[st].S->i;
2614 TX[st].S->img = [[IVface image] retain];
2615 TX[st].S->imgWall = [[IVwall image] retain];
2617 if(SEMA1row < 0 || SEMA2row < 0){
2618 TX[st].S->i->imgStand = NULL;
2620 //TX[st].S->i->imgStand = [[SEIV image] retain];
2622 if([TFface stringValue]) TX[st].S->iName = [[TFface stringValue] retain];
2623 if([TFwall stringValue]) TX[st].S->iNameWall = [[TFwall stringValue] retain];
2626 NSString *directoryPath;
2628 directoryPath = [[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent];
2629 [[NSFileManager defaultManager] changeCurrentDirectoryPath:directoryPath];
2631 TX[st].S->wallFadeIn = [FIbtn state];
2632 TX[st].S->wallFadeOut = [FObtn state];
2635 TX[st].S->i = SItop;
2636 TX[st].S = STRtop[st];
2638 [self saveLineDataFnc];
2639 standChoiceFlag = false;
2640 [detailWindow close];
2644 TX[st].S->i = SItop;
2645 TX[st].S = STRtop[st];
2647 [self saveLineDataFnc];
2648 standChoiceFlag = false;
2649 [detailWindow close];
2653 TX[st].S->i = TX[st].S->i->next;
2655 TX[st].S->i = SItop;
2657 TX[st].S = STRtop[st];
2659 standChoiceFlag = false;
2662 [self saveLineDataFnc];
2664 [detailWindow close];
2668 -(IBAction)addTextList:(id)sender{
2670 NSMutableDictionary *dict = [NSMutableDictionary new];
2671 [dict setValue:[NSString stringWithFormat:@"新規ファイル%ld",[textListMA count]] forKey:@"name"];
2673 [self willChangeValueForKey:@"textListMA"];
2674 [textListMA addObject:dict];
2675 [self didChangeValueForKey:@"textListMA"];
2677 TX[st].fileName = [[NSString stringWithFormat:@"新規ファイル%ld", [textListMA count]-1] retain];
2679 -(IBAction)removeTextList:(id)sender{
2681 NSString *directoryPath;
2683 directoryPath = [[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent];
2684 [[NSFileManager defaultManager] changeCurrentDirectoryPath:directoryPath];
2686 NSString *path = @"data/StringList/";
2688 path = [path stringByAppendingString:TX[st].fileName];
2690 [[NSFileManager defaultManager] removeItemAtPath:path error:nil];
2692 TX[st].fileName = NULL;
2695 [self willChangeValueForKey:@"textListMA"];
2696 [textListAC setSelectionIndex:st];
2697 [textListAC setValue:@"Deleted" forKey:@"name"];
2698 [self didChangeValueForKey:@"textListMA"];
2705 -(IBAction)insert1:(id)sender{
2710 for(int i = 0;i < Irow;i++){
2719 NSMutableDictionary *dict = [NSMutableDictionary new];
2720 if([MA1 count] == 0){
2722 bTop = calloc(1, sizeof(BASE));
2724 b->name = [@"新キャラ" retain];
2728 [dict setValue:[NSString stringWithFormat:@"%@", b->name] forKey:@"name"];
2729 [dict setValue:[NSString stringWithFormat:@"%d", b->z] forKey:@"z"];
2731 [self willChangeValueForKey:@"MA1"];
2732 [MA1 insertObject:dict atIndex:[MA1 count]];
2733 [self didChangeValueForKey:@"MA1"];
2734 [AC1 setSelectionIndex:999];
2735 }else if(TVCrow1 == -1){
2739 b->next = calloc(1, sizeof(BASE));
2741 b->name = [@"新キャラ" retain];
2745 [dict setValue:[NSString stringWithFormat:@"%@", b->name] forKey:@"name"];
2746 [dict setValue:[NSString stringWithFormat:@"%d", b->z] forKey:@"z"];
2748 [self willChangeValueForKey:@"MA1"];
2749 [MA1 insertObject:dict atIndex:[MA1 count]];
2750 [self didChangeValueForKey:@"MA1"];
2751 [AC1 setSelectionIndex:999];
2753 }else if(TVCrow1 > 0){
2754 for (int i = 0; i < TVCrow1-1; i++) {
2758 BASE *tmp = (BASE*)malloc(sizeof(BASE));
2760 b->next = (BASE*)malloc(sizeof(BASE));
2761 b->next->next = tmp;
2763 b->name = [@"新キャラ" retain];
2767 [dict setValue:[NSString stringWithFormat:@"%@", b->name] forKey:@"name"];
2768 [dict setValue:[NSString stringWithFormat:@"%d", b->z] forKey:@"z"];
2770 [self willChangeValueForKey:@"MA1"];
2771 [MA1 insertObject:dict atIndex:TVCrow1];
2772 [self didChangeValueForKey:@"MA1"];
2773 [AC1 setSelectionIndex:999];
2779 //LAYER *tmp2 = (LAYER*)malloc(sizeof(LAYER));
2780 b->name = [@"新キャラ" retain];
2784 b->next = calloc(1, sizeof(BASE));
2789 [dict setValue:[NSString stringWithFormat:@"%@", b->name] forKey:@"name"];
2790 [dict setValue:[NSString stringWithFormat:@"%d", b->z] forKey:@"z"];
2792 [self willChangeValueForKey:@"MA1"];
2793 [MA1 insertObject:dict atIndex:TVCrow1];
2794 [self didChangeValueForKey:@"MA1"];
2795 [AC1 setSelectionIndex:999];
2805 -(IBAction)insert2:(id)sender{
2809 for(int i = 0;i < Irow;i++){
2815 if(!b || TVCrow1 == -1) return;
2818 for(int i = 0;i < TVCrow1;i++){
2821 LAYER *blTop = b->L;
2823 for(int i = 0;i < TVCrow2;i++){
2830 if(TVCrow1 == -1) return;
2833 NSMutableDictionary *dict = [NSMutableDictionary new];
2834 if([MA2 count] == 0){
2836 blTop = calloc(1, sizeof(LAYER));
2838 l->name = [@"新規レイヤー" retain];
2842 [dict setValue:[NSString stringWithFormat:@"%@", l->name] forKey:@"name"];
2843 [dict setValue:[NSString stringWithFormat:@"%d", l->z] forKey:@"z"];
2845 [self willChangeValueForKey:@"MA2"];
2846 [MA2 insertObject:dict atIndex:[MA2 count]];
2847 [self didChangeValueForKey:@"MA2"];
2848 [AC2 setSelectionIndex:999];
2849 }else if(TVCrow2 == -1){
2853 l->next = calloc(1, sizeof(LAYER));
2855 l->name = [@"新規レイヤー" retain];
2859 [dict setValue:[NSString stringWithFormat:@"%@", l->name] forKey:@"name"];
2860 [dict setValue:[NSString stringWithFormat:@"%d", l->z] forKey:@"z"];
2862 [self willChangeValueForKey:@"MA2"];
2863 [MA2 insertObject:dict atIndex:[MA2 count]];
2864 [self didChangeValueForKey:@"MA2"];
2865 [AC2 setSelectionIndex:999];
2867 }else if(TVCrow2 > 0){
2868 for (int i = 0; i < TVCrow2-1; i++) {
2872 LAYER *tmp = (LAYER*)malloc(sizeof(LAYER));
2874 l->next = (LAYER*)malloc(sizeof(LAYER));
2875 l->next->next = tmp;
2877 l->name = [@"新規レイヤー" retain];
2880 [dict setValue:[NSString stringWithFormat:@"%@", l->name] forKey:@"name"];
2881 [dict setValue:[NSString stringWithFormat:@"%d", l->z] forKey:@"z"];
2883 [self willChangeValueForKey:@"MA2"];
2884 [MA2 insertObject:dict atIndex:TVCrow2];
2885 [self didChangeValueForKey:@"MA2"];
2886 [AC2 setSelectionIndex:999];
2891 l->next = calloc(1, sizeof(LAYER));
2892 l->name = [@"新規レイヤー" retain];
2898 [dict setValue:[NSString stringWithFormat:@"%@", l->name] forKey:@"name"];
2899 [dict setValue:[NSString stringWithFormat:@"%d", l->z] forKey:@"z"];
2901 [self willChangeValueForKey:@"MA2"];
2902 [MA2 insertObject:dict atIndex:TVCrow2];
2903 [self didChangeValueForKey:@"MA2"];
2904 [AC2 setSelectionIndex:999];
2921 -(IBAction)remove1:(id)sender{
2927 for(int i = 0;i < Irow;i++){
2940 LAYER *llTop = b->L;
2951 for (int i = 0; i < [MA1 count]-1; i++){
2953 if(i >= [MA1 count]-1) break;
2954 LAYER *llTop = b->L;
2967 if([MA1 count] == 0){
2969 }else if(TVCrow1 == -1){
2970 for(int i = 0;i < [MA1 count]-1;i++){
2971 if(i == [MA1 count]- 2){
2973 [deletedName addObject:[b->next->name stringByAppendingFormat:@"%d", cnt]];
2975 if(i == [MA1 count] - 2)
2979 if([MA1 count] > 1) {
2984 [deletedName addObject:[b->name stringByAppendingFormat:@"%d", cnt]];
2988 [self willChangeValueForKey:@"MA1"];
2989 [MA1 removeObjectAtIndex:[MA1 count]-1];
2990 [self didChangeValueForKey:@"MA1"];
2991 [AC1 setSelectionIndex:999];
2993 [self willChangeValueForKey:@"MA2"];
2994 [MA2 removeAllObjects];
2995 [self didChangeValueForKey:@"MA2"];
2996 [AC2 setSelectionIndex:999];
2998 }else if(TVCrow1 > 0){
2999 for (int i = 0; i < TVCrow1-1; i++) {
3004 [deletedName addObject:[b->next->name stringByAppendingFormat:@"%d", cnt]];
3005 b->next = b->next->next;
3007 [self willChangeValueForKey:@"MA1"];
3008 [MA1 removeObjectAtIndex:TVCrow1];
3009 [self didChangeValueForKey:@"MA1"];
3010 [AC1 setSelectionIndex:999];
3012 [self willChangeValueForKey:@"MA2"];
3013 [MA2 removeAllObjects];
3014 [self didChangeValueForKey:@"MA2"];
3015 [AC2 setSelectionIndex:999];
3019 [deletedName addObject:[bTop->name stringByAppendingFormat:@"%d", cnt]];
3022 [self willChangeValueForKey:@"MA1"];
3023 [MA1 removeObjectAtIndex:TVCrow1];
3024 [self didChangeValueForKey:@"MA1"];
3025 [AC1 setSelectionIndex:999];
3027 [self willChangeValueForKey:@"MA2"];
3028 [MA2 removeAllObjects];
3029 [self didChangeValueForKey:@"MA2"];
3030 [AC2 setSelectionIndex:999];
3050 -(IBAction)remove2:(id)sender{
3056 for(int i = 0;i < Irow;i++){
3068 LAYER *llTop = b->L;
3082 LAYER *llTop = b->L;
3092 for(int i = 0;i < TVCrow1;i++){
3096 LAYER *blTop = b->L;
3098 for(int i = 0;i < TVCrow2;i++){
3106 if([MA2 count] == 0){
3108 }else if(TVCrow2 == -1){
3109 for(int i = 0;i < [MA2 count]-1;i++){
3111 if(i == [MA2 count]-2){
3114 [deletedName addObject:[l->next->name stringByAppendingFormat:@"%d", cnt]];
3116 if(i == [MA2 count] - 2)
3120 if([MA2 count] > 1) {
3125 [deletedName addObject:[l->name stringByAppendingFormat:@"%d", cnt]];
3128 [self willChangeValueForKey:@"MA2"];
3129 [MA2 removeObjectAtIndex:[MA2 count]-1];
3130 [self didChangeValueForKey:@"MA2"];
3131 [AC2 setSelectionIndex:999];
3133 }else if(TVCrow2 > 0){
3134 for (int i = 0; i < TVCrow2-1; i++) {
3140 [deletedName addObject:[l->next->name stringByAppendingFormat:@"%d", cnt]];
3141 l->next = l->next->next;
3143 [self willChangeValueForKey:@"MA2"];
3144 [MA2 removeObjectAtIndex:TVCrow2];
3145 [self didChangeValueForKey:@"MA2"];
3146 [AC2 setSelectionIndex:999];
3150 [deletedName addObject:[blTop->name stringByAppendingFormat:@"%d", cnt]];
3153 [self willChangeValueForKey:@"MA2"];
3154 [MA2 removeObjectAtIndex:TVCrow2];
3155 [self didChangeValueForKey:@"MA2"];
3156 [AC2 setSelectionIndex:999];
3169 -(IBAction)saveBtn:(id)sender{
3175 NSString *directoryPath;
3177 directoryPath = [[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent];
3178 [[NSFileManager defaultManager] changeCurrentDirectoryPath:directoryPath];
3181 NSString *fdata = @"data/Scenario/";
3182 NSString *direct = @"data/Scenario/";
3185 [[NSFileManager defaultManager] createDirectoryAtPath:direct
3186 withIntermediateDirectories:YES
3190 NSString *fileData = @"";
3191 for(int i = 0;i < [deletedName count];i++){
3193 NSString *dlPath = @"data/Scenario/img/";
3194 dlPath = [dlPath stringByAppendingFormat:@"%@", [deletedName objectAtIndex:i]];
3195 [[NSFileManager defaultManager] removeItemAtPath:dlPath error:nil];
3198 deletedName = [NSMutableArray new];
3204 for(int i = 0;i < Irow;i++){
3224 if(!I->fName) return;
3225 if([I->fName isEqualToString:@""]) return;
3227 fdata = [fdata stringByAppendingFormat:@"%@", I->fName];
3234 while(b){Standcount++;
3235 fileData = [[fileData stringByAppendingString:[NSString stringWithFormat:@"%@,%d, %d, %d"
3236 , b->name, b->z, b->x, b->y]]
3237 stringByAppendingString:@"\n"];
3239 NSData *f2Data = [b->img TIFFRepresentation];
3240 NSBitmapImageRep *brep = [NSBitmapImageRep imageRepWithData:f2Data];
3241 f2Data = [brep representationUsingType:NSPNGFileType properties:nil];
3243 NSString *dlPath = @"data/Scenario/img/";
3244 dlPath = [dlPath stringByAppendingFormat:@"%@#%d", b->postName, Standcount];
3246 [[NSFileManager defaultManager] removeItemAtPath:dlPath error:nil];
3248 NSString *bcPath = @"data/Scenario/img/";
3249 bcPath = [bcPath stringByAppendingFormat:@"%@#%d", b->name, Standcount];
3251 [f2Data writeToFile:bcPath atomically:YES];
3253 b->postName = b->name;
3254 fileData = [fileData stringByAppendingString:[NSString stringWithFormat:@"####\n"]];
3258 while(b->L){Standcount++;
3259 fileData = [[fileData stringByAppendingString:[NSString stringWithFormat:@"%@,%d,%d, %d, %d"
3260 , b->L->name, b->L->z, b->L->visible, b->L->x, b->L->y]] stringByAppendingString:@"\n"];
3262 NSData *f2Data = [b->L->img TIFFRepresentation];
3263 NSBitmapImageRep *brep = [NSBitmapImageRep imageRepWithData:f2Data];
3264 f2Data = [brep representationUsingType:NSPNGFileType properties:nil];
3266 NSString *dlPath = @"data/Scenario/img/";
3267 dlPath = [dlPath stringByAppendingFormat:@"%@#%d", b->L->postName, Standcount];
3269 [[NSFileManager defaultManager] removeItemAtPath:dlPath error:nil];
3271 NSString *bcPath = @"data/Scenario/img/";
3272 bcPath = [bcPath stringByAppendingFormat:@"%@#%d", b->L->name, Standcount];
3274 [f2Data writeToFile:bcPath atomically:YES];
3277 b->L->postName = b->L->name;
3281 fileData = [fileData stringByAppendingString:[NSString stringWithFormat:@"$$$$\n"]];
3291 [fileData writeToFile:fdata atomically:YES encoding:NSUTF8StringEncoding error:nil];
3296 if(!I->fName) return;
3297 if([I->fName isEqualToString:@""]) return;
3299 fdata = [@"data/Scenario/" retain];
3301 fileData = [@"" retain];
3303 fdata = [fdata stringByAppendingFormat:@"%@", I->fName];
3309 while(b){Standcount++;
3310 fileData = [[fileData stringByAppendingString:[NSString stringWithFormat:@"%@,%d, %d, %d"
3311 , b->name, b->z, b->x, b->y]]
3312 stringByAppendingString:@"\n"];
3314 NSData *f2Data = [b->img TIFFRepresentation];
3315 NSBitmapImageRep *brep = [NSBitmapImageRep imageRepWithData:f2Data];
3316 f2Data = [brep representationUsingType:NSPNGFileType properties:nil];
3318 NSString *dlPath = @"data/Scenario/img/";
3319 dlPath = [dlPath stringByAppendingFormat:@"%@#%d", b->postName, Standcount];
3321 [[NSFileManager defaultManager] removeItemAtPath:dlPath error:nil];
3323 NSString *bcPath = @"data/Scenario/img/";
3324 bcPath = [bcPath stringByAppendingFormat:@"%@#%d", b->name, Standcount];
3326 [f2Data writeToFile:bcPath atomically:YES];
3328 b->postName = b->name;
3329 fileData = [fileData stringByAppendingString:[NSString stringWithFormat:@"####\n"]];
3333 while(b->L){Standcount++;
3334 fileData = [[fileData stringByAppendingString:[NSString stringWithFormat:@"%@,%d,%d, %d, %d"
3335 , b->L->name, b->L->z, b->L->visible, b->L->x, b->L->y]] stringByAppendingString:@"\n"];
3337 NSData *f2Data = [b->L->img TIFFRepresentation];
3338 NSBitmapImageRep *brep = [NSBitmapImageRep imageRepWithData:f2Data];
3339 f2Data = [brep representationUsingType:NSPNGFileType properties:nil];
3341 NSString *dlPath = @"data/Scenario/img/";
3342 dlPath = [dlPath stringByAppendingFormat:@"%@#%d", b->L->postName, Standcount];
3344 [[NSFileManager defaultManager] removeItemAtPath:dlPath error:nil];
3346 NSString *bcPath = @"data/Scenario/img/";
3347 bcPath = [bcPath stringByAppendingFormat:@"%@#%d", b->L->name, Standcount];
3349 [f2Data writeToFile:bcPath atomically:YES];
3352 b->L->postName = b->L->name;
3356 fileData = [fileData stringByAppendingString:[NSString stringWithFormat:@"$$$$\n"]];
3363 [fileData writeToFile:fdata atomically:YES encoding:NSUTF8StringEncoding error:nil];
3373 -(void)saveStandData{
3378 for (int i = 0;i < Inumb && I && [standListMA count] > 0;i++) {
3379 I->name = [standListMA[i] valueForKey:@"name"];
3380 I->fName = [standListMA[i] valueForKey:@"file"];
3392 NSString *directoryPath = [[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent];
3393 [[NSFileManager defaultManager] changeCurrentDirectoryPath:directoryPath];
3395 NSString *pathI = @"data/Scenario/preset2.txt";
3396 NSString *string = @"";
3398 for (int i = 0;i < Inumb;i++) {
3399 string = [string stringByAppendingFormat:@"%@,%@", I->name, I->fName];
3400 string = [string stringByAppendingFormat:@"\n"];
3404 [string writeToFile:pathI atomically:YES encoding:NSUTF8StringEncoding error:nil];
3408 -(void)loadStandData{
3410 NSString *directoryPath;
3412 directoryPath = [[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent];
3413 [[NSFileManager defaultManager] changeCurrentDirectoryPath:directoryPath];
3415 NSArray *fileDataArrayFirst;
3416 NSString *fileData = @"";
3418 NSString *pathI = @"data/Scenario/preset2.txt";
3419 NSString *pathID = @"data/Scenario/";
3424 if(![[NSFileManager defaultManager] fileExistsAtPath:pathI]){
3425 [[NSFileManager defaultManager] createFileAtPath:pathI contents:nil attributes:nil];
3429 NSArray *IList = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:pathID error:nil];
3432 for(NSString *path in IList){
3434 if([path isEqualToString:@".DS_Store"]){
3438 if([path isEqualToString:@"preset.txt"]){
3442 if([path isEqualToString:@"preset2.txt"]){
3446 if([path isEqualToString:@"img"]){
3450 static int eTopFlag = 0;
3453 I = calloc(1, sizeof(STAND));
3461 I->next = calloc(1, sizeof(STAND));
3472 fileData = [NSString stringWithContentsOfFile:pathI encoding:NSUTF8StringEncoding error:nil];
3473 fileDataArrayFirst = [fileData componentsSeparatedByString:@"\n"];
3476 for(int i = 0;i < [fileDataArrayFirst count] - 1;i++){
3479 I = calloc(1, sizeof(STAND));
3482 I->next = calloc(1, sizeof(STAND));
3489 if([fileDataArrayFirst[0] isEqualToString:@""])
3493 for(int i = 0;i < Inumb && I;i++){
3494 NSArray *firstArray = [[fileDataArrayFirst[i] componentsSeparatedByString:@","] retain];
3496 if([firstArray count] > 1){
3497 I->name = [firstArray[0] retain];
3498 I->fName = [firstArray[1] retain];
3507 [self willChangeValueForKey:@"standListMA"];
3508 [standListMA removeAllObjects];
3509 [self didChangeValueForKey:@"standListMA"];
3512 NSMutableDictionary *dict = [NSMutableDictionary new];
3514 [dict setValue:[NSString stringWithFormat:@"%@", I->name] forKey:@"name"];
3515 [dict setValue:[NSString stringWithFormat:@"%@", I->fName] forKey:@"file"];
3517 [self willChangeValueForKey:@"standListMA"];
3518 [standListMA addObject:dict];
3519 [self didChangeValueForKey:@"standListMA"];
3525 [standListAC setSelectionIndex:9999];
3531 NSString *directoryPath;
3533 directoryPath = [[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent];
3534 [[NSFileManager defaultManager] changeCurrentDirectoryPath:directoryPath];
3536 NSArray *fileDataArrayFirst;
3537 NSString *fileData = @"";
3539 NSString *pathI = @"data/Scenario/preset2.txt";
3541 NSArray *fileDataArray;
3552 NSString *pathID = @"data/Scenario/";
3554 pathID = [pathID stringByAppendingFormat:@"%@", I->fName];
3556 if(![[NSFileManager defaultManager] fileExistsAtPath:pathID]){
3561 fileData = [NSString stringWithContentsOfFile:pathID encoding:NSUTF8StringEncoding error:nil];
3562 fileDataArray = [fileData componentsSeparatedByString:@"\n"];
3566 for(int i = 0;i < [fileDataArray count]-1;i++){
3567 NSString *str = [fileDataArray objectAtIndex:i];
3568 NSRange rangeSearch;
3569 NSRange rangeSearch2;
3570 NSArray *rangeArray;
3571 NSArray *rangeArray2;
3572 static bool firstFlag = true;
3573 static bool nextIsBASEflag = true;
3574 static bool nextIsLAYERflag = false;
3575 rangeSearch = [str rangeOfString:@"####"];
3576 rangeSearch2 = [str rangeOfString:@"$$$$"];
3577 rangeArray = [str componentsSeparatedByString:@","];
3579 if (rangeSearch.location != NSNotFound){
3581 nextIsLAYERflag = true;
3582 nextIsBASEflag = false;
3584 }else if(rangeSearch2.location != NSNotFound){
3585 nextIsLAYERflag = false;
3586 nextIsBASEflag = true;
3588 }else if(nextIsBASEflag && !nextIsLAYERflag){Standcount++;
3591 bTop = calloc(1, sizeof(BASE));
3593 b->name = [[rangeArray objectAtIndex:0] retain];
3594 b->postName = b->name;
3595 b->z = [[rangeArray objectAtIndex:1] intValue];
3596 b->x = [[rangeArray objectAtIndex:2] intValue];
3597 b->y = [[rangeArray objectAtIndex:3] intValue];
3600 NSString *iPath = @"data/Scenario/img/";
3601 iPath = [iPath stringByAppendingFormat:@"%@#%d", b->name, Standcount];
3602 NSData *iData = [NSData dataWithContentsOfFile:iPath];
3604 NSImage *iImg = [[NSImage alloc] initWithContentsOfFile:iPath];
3610 b->next = calloc(1, sizeof(BASE));
3612 b->name = [[rangeArray objectAtIndex:0] retain];
3613 b->postName = b->name;
3614 b->z = [[rangeArray objectAtIndex:1] intValue];
3615 b->x = [[rangeArray objectAtIndex:2] intValue];
3616 b->y = [[rangeArray objectAtIndex:3] intValue];
3619 NSString *iPath = @"data/Scenario/img/";
3620 iPath = [iPath stringByAppendingFormat:@"%@#%d", b->name, Standcount];
3621 NSData *iData = [NSData dataWithContentsOfFile:iPath];
3623 NSImage *iImg = [[NSImage alloc] initWithContentsOfFile:iPath];
3628 }else if(!nextIsBASEflag && nextIsLAYERflag){Standcount++;
3631 b->L = calloc(1, sizeof(LAYER));
3633 b->L->name = [[rangeArray objectAtIndex:0] retain];
3634 b->L->postName = b->L->name;
3635 b->L->z = [[rangeArray objectAtIndex:1] intValue];
3636 b->L->visible = [[rangeArray objectAtIndex:2] intValue];
3637 b->L->x = [[rangeArray objectAtIndex:3] intValue];
3638 b->L->y = [[rangeArray objectAtIndex:4] intValue];
3640 NSString *iPath = @"data/Scenario/img/";
3641 iPath = [iPath stringByAppendingFormat:@"%@#%d", b->L->name, Standcount];
3642 NSData *iData = [NSData dataWithContentsOfFile:iPath];
3644 NSImage *iImg = [[NSImage alloc] initWithContentsOfFile:iPath];
3649 b->L->next = calloc(1, sizeof(LAYER));
3651 b->L->name = [[rangeArray objectAtIndex:0] retain];
3652 b->L->postName = b->L->name;
3653 b->L->z = [[rangeArray objectAtIndex:1] intValue];
3654 b->L->visible = [[rangeArray objectAtIndex:2] intValue];
3655 b->L->x = [[rangeArray objectAtIndex:3] intValue];
3656 b->L->y = [[rangeArray objectAtIndex:4] intValue];
3658 NSString *iPath = @"data/Scenario/img/";
3659 iPath = [iPath stringByAppendingFormat:@"%@#%d", b->L->name, Standcount];
3660 NSData *iData = [NSData dataWithContentsOfFile:iPath];
3662 NSImage *iImg = [[NSImage alloc] initWithContentsOfFile:iPath];
3671 if(i+1 == [fileDataArray count]-1){
3673 nextIsBASEflag = true;
3674 nextIsLAYERflag = false;
3689 for(int i = 0;i < Irow;i++){
3697 [self willChangeValueForKey:@"MA1"];
3698 [MA1 removeAllObjects];
3699 [self didChangeValueForKey:@"MA1"];
3700 [self willChangeValueForKey:@"MA2"];
3701 [MA2 removeAllObjects];
3702 [self didChangeValueForKey:@"MA2"];
3709 NSMutableDictionary *dict2 = [NSMutableDictionary new];
3710 [dict2 setValue:[NSString stringWithFormat:@"%@", b->name] forKeyPath:@"name"];
3711 [dict2 setValue:[NSString stringWithFormat:@"%d", b->z] forKeyPath:@"z"];
3712 [dict2 setValue:b->img forKey:@"img"];
3714 [self willChangeValueForKey:@"MA1"];
3715 [MA1 addObject:dict2];
3716 [self didChangeValueForKey:@"MA1"];
3719 while(b->L && !first){
3720 NSMutableDictionary *dict2 = [NSMutableDictionary new];
3721 [dict2 setValue:[NSString stringWithFormat:@"%@", b->L->name] forKeyPath:@"name"];
3722 [dict2 setValue:[NSString stringWithFormat:@"%d", b->L->z] forKeyPath:@"z"];
3723 [dict2 setValue:[NSString stringWithFormat:@"%d", b->L->visible] forKeyPath:@"v"];
3724 [dict2 setValue:b->L->img forKey:@"img"];
3726 [self willChangeValueForKey:@"MA2"];
3727 [MA2 addObject:dict2];
3728 [self didChangeValueForKey:@"MA2"];
3747 [self willChangeValueForKey:@"SEMA1"];
3748 [SEMA1 removeAllObjects];
3749 [self didChangeValueForKey:@"SEMA1"];
3752 for(int i = 0;i < Inumb;i++){
3753 NSMutableDictionary *dict = [NSMutableDictionary new];
3754 [dict setValue:[NSString stringWithFormat:@"%@", I->name] forKeyPath:@"name"];
3756 [self willChangeValueForKey:@"SEMA1"];
3757 [SEMA1 addObject:dict];
3758 [self didChangeValueForKey:@"SEMA1"];
3769 [SEAC1 setSelectionIndex:9999];
3770 [SEAC2 setSelectionIndex:9999];
3771 [SEAC3 setSelectionIndex:9999];
3775 for(int i = 0;i < SEMA1row;i++){
3783 [self willChangeValueForKey:@"SEMA2"];
3784 [SEMA2 removeAllObjects];
3785 [self didChangeValueForKey:@"SEMA2"];
3786 [self willChangeValueForKey:@"SEMA3"];
3787 [SEMA3 removeAllObjects];
3788 [self didChangeValueForKey:@"SEMA3"];
3795 NSMutableDictionary *dict2 = [NSMutableDictionary new];
3796 [dict2 setValue:[NSString stringWithFormat:@"%@", b->name] forKeyPath:@"name"];
3798 [self willChangeValueForKey:@"SEMA2"];
3799 [SEMA2 addObject:dict2];
3800 [self didChangeValueForKey:@"SEMA2"];
3804 while(b->L && !first){
3805 NSMutableDictionary *dict2 = [NSMutableDictionary new];
3806 [dict2 setValue:[NSString stringWithFormat:@"%@", b->L->name] forKeyPath:@"name"];
3807 if(TX[st].S->i->SEMA3flag) {
3808 [dict2 setValue:[NSString stringWithFormat:@"%d", *(TX[st].S->i->SEMA3flag + i0) - 1 ] forKeyPath:@"v"];
3809 b->L->visibleInstant = *(TX[st].S->i->SEMA3flag + i0) - 1;
3810 }else [dict2 setValue:[NSString stringWithFormat:@"%d", b->L->visibleInstant] forKeyPath:@"v"];
3812 [self willChangeValueForKey:@"SEMA3"];
3813 [SEMA3 addObject:dict2];
3814 [self didChangeValueForKey:@"SEMA3"];
3839 -(IBAction)SEstand:(id)sender{
3841 TX[st].S = STRtop[st];
3842 for(int i = 0;i < sl;i++){
3843 TX[st].S = TX[st].S->next;
3846 SItop = TX[st].S->i;
3847 for(int i = 0;i < SEMArow;i++){
3848 TX[st].S->i = TX[st].S->i->next;
3851 TX[st].S->i->imgStand = [SEIV image];
3852 TX[st].S->i->name = [[SEMA[SEMArow] valueForKey:@"name"] retain];
3854 TX[st].S->i = SItop;
3856 TX[st].S = STRtop[st];
3857 [SEstandViewTestWindow makeKeyAndOrderFront:nil];
3862 -(IBAction)SEstandSubmit:(id)sender{
3865 TX[st].S = STRtop[st];
3866 for(int i = 0;i < sl;i++){
3867 TX[st].S = TX[st].S->next;
3869 SItop = TX[st].S->i;
3870 for(int i = 0;i < SEMArow;i++){
3871 TX[st].S->i = TX[st].S->i->next;
3873 [SEstandTFx setStringValue:[NSString stringWithFormat:@"%d", TX[st].S->i->standX]];
3874 [SEstandTFy setStringValue:[NSString stringWithFormat:@"%d", TX[st].S->i->standY]];
3876 TX[st].S->i = SItop;
3877 TX[st].S = STRtop[st];
3878 [SEstandViewTestWindow close];
3883 -(IBAction)SEstandSEclear:(id)sender{
3885 if(![SEstandTF0 stringValue]){
3887 }else if([[SEstandTF0 stringValue] isEqualToString:@""]){
3889 }else if([[SEstandTF0 stringValue] isEqualToString:@"(null)"]){
3893 NSArray *SECHK = [[SEMA[SEMArow] valueForKey:@"name"] componentsSeparatedByString:@"new"];
3894 if([SECHK count] >= 2){
3900 for(int i = 0;i < [SEMA count];i++){theMA++;
3901 if([[SEMA[i] valueForKey:@"name"] isEqualToString:[SEstandTF0 stringValue]])
3907 TX[st].S = STRtop[st];
3908 for(int i = 0;i < sl;i++){
3909 TX[st].S = TX[st].S->next;
3914 for(int i = 0;i < theMA;i++) {
3918 NSArray *siArray = [si->name componentsSeparatedByString:@"(clear)"];
3920 if([siArray count] < 2) {
3921 [self willChangeValueForKey:@"SEMA"];
3922 [SEMA[theMA] setValue:[NSString stringWithFormat:@"%@(clear)", si->name] forKey:@"name"];
3923 [self didChangeValueForKey:@"SEMA"];
3925 si->name = [[si->name stringByAppendingFormat:@"(clear)"] retain];
3928 }else if([siArray count] >= 2) {
3929 [self willChangeValueForKey:@"SEMA"];
3930 [SEMA[theMA] setValue:[NSString stringWithFormat:@"%@", si->name] forKey:@"name"];
3931 [self didChangeValueForKey:@"SEMA"];
3933 si->name = [[si->name substringToIndex:[si->name length] - [@"(clear)" length]] retain];
3938 TX[st].S = STRtop[st];
3943 -(IBAction)SEstandSEadd:(id)sender{
3945 if(![SEstandTF0 stringValue]){
3947 }else if([[SEstandTF0 stringValue] isEqualToString:@""]){
3949 }else if([[SEstandTF0 stringValue] isEqualToString:@"(null)"]){
3951 }else if([[SEstandTF0 stringValue] isEqualToString:@"(new)"]){
3953 }else if([[SEstandTF0 stringValue] isEqualToString:@"(clear)"]){
3958 NSArray *SECHK = [[SEMA[SEMArow] valueForKey:@"name"] componentsSeparatedByString:@"claer"];
3959 if([SECHK count] >= 2){
3965 for(int i = 0;i < [SEMA count];i++){
3966 if([[SEMA[i] valueForKey:@"name"] isEqualToString:[SEstandTF0 stringValue]])
3968 if([[SEMA[i] valueForKey:@"name"] isEqualToString:[NSString stringWithFormat:@"%@(new)", [SEstandTF0 stringValue]]])
3970 if([[SEMA[i] valueForKey:@"name"] isEqualToString:[NSString stringWithFormat:@"%@(clear)", [SEstandTF0 stringValue]]])
3974 TX[st].S = STRtop[st];
3975 for(int i = 0;i < sl;i++){
3976 TX[st].S = TX[st].S->next;
3982 NSMutableDictionary *dict = [NSMutableDictionary new];
3983 if([SEMA count] == 0){
3985 SItop = calloc(1, sizeof(STANDIMAGE));
3987 si->name = [[NSString stringWithFormat:@"%@", [SEstandTF0 stringValue]] retain];
3988 STANDADDSTRING = si->name;
3993 [dict setValue:[NSString stringWithFormat:@"%@", [SEstandTF0 stringValue]] forKey:@"name"];
3994 [TX[st].SIarray insertObject:[NSString stringWithFormat:@"%@", [SEstandTF0 stringValue]] atIndex:[SEMA count]];
3996 [self willChangeValueForKey:@"SEMA"];
3997 [SEMA insertObject:dict atIndex:[SEMA count]];
3998 [self didChangeValueForKey:@"SEMA"];
3999 [SEAC setSelectionIndex:999];
4001 }else if(SEMArow == -1){
4005 si->next = calloc(1, sizeof(BASE));
4007 si->name = [[NSString stringWithFormat:@"%@", [SEstandTF0 stringValue]] retain];
4008 STANDADDSTRING = si->name;
4013 [dict setValue:[NSString stringWithFormat:@"%@", [SEstandTF0 stringValue]] forKey:@"name"];
4014 [TX[st].SIarray insertObject:[NSString stringWithFormat:@"%@", [SEstandTF0 stringValue]] atIndex:[SEMA count]];
4017 [self willChangeValueForKey:@"SEMA"];
4018 [SEMA insertObject:dict atIndex:[SEMA count]];
4019 [self didChangeValueForKey:@"SEMA"];
4020 [SEAC setSelectionIndex:999];
4022 }else if(SEMArow > 0){
4023 for (int i = 0; i < TVCrow1-1; i++) {
4027 STANDIMAGE *tmp = (STANDIMAGE*)malloc(sizeof(STANDIMAGE));
4029 si->next = (STANDIMAGE*)malloc(sizeof(STANDIMAGE));
4030 si->next->next = tmp;
4032 si->name = [[NSString stringWithFormat:@"%@", [SEstandTF0 stringValue]] retain];
4033 STANDADDSTRING = si->name;
4038 [dict setValue:[NSString stringWithFormat:@"%@", [SEstandTF0 stringValue]] forKey:@"name"];
4039 [TX[st].SIarray insertObject:[NSString stringWithFormat:@"%@", [SEstandTF0 stringValue]] atIndex:SEMArow];
4042 [self willChangeValueForKey:@"SEMA"];
4043 [SEMA insertObject:dict atIndex:SEMArow];
4044 [self didChangeValueForKey:@"SEMA"];
4045 [SEAC setSelectionIndex:999];
4051 si->name = [[NSString stringWithFormat:@"%@", [SEstandTF0 stringValue]] retain];
4052 STANDADDSTRING = si->name;
4056 si->next = calloc(1, sizeof(STANDIMAGE));
4060 [dict setValue:[NSString stringWithFormat:@"%@", [SEstandTF0 stringValue]] forKey:@"name"];
4061 [TX[st].SIarray insertObject:[NSString stringWithFormat:@"%@", [SEstandTF0 stringValue]] atIndex:SEMArow];
4063 [self willChangeValueForKey:@"SEMA"];
4064 [SEMA insertObject:dict atIndex:SEMArow];
4065 [self didChangeValueForKey:@"SEMA"];
4066 [SEAC setSelectionIndex:999];
4080 TX[st].S = STRtop[st];
4083 TX[st].S = STRtop[st];
4084 for(int i = 0;i < sl;i++){
4085 TX[st].S = TX[st].S->next;
4088 SItop = TX[st].S->i;
4089 for(int i = 0;i < SEMArow;i++){
4090 TX[st].S->i = TX[st].S->i->next;
4092 STANDIMAGE *zOMG = TX[st].S->i;
4094 TX[st].S->i = SItop;
4098 STRING *OMFG = TX[st].S->next;
4099 STRING *OMFGGE = OMFG;
4103 STANDIMAGE *OMFGcrnt0 = OMFG->i;
4105 for(int i = 0;OMFG->i;i++){
4107 OMFG->i = OMFG->i->next;
4108 }OMFG->i = OMFGcrnt0;
4111 STANDIMAGE *LOL = OMFG->i;
4114 NSArray *hiThere = [zOMG->name componentsSeparatedByString:@"(new)"];
4115 NSArray *helloMan = [OMFG->i->name componentsSeparatedByString:@"(clear)"];
4116 STANDIMAGE *OMFGcrnt = OMFG->i;
4117 if([hiThere[0] isEqualToString:helloMan[0]]){
4123 }else if(MatchCnt == OMFGcnt){
4124 for(int i = 0;i < OMFGcnt-1;i++){
4125 if(i == OMFGcnt- 2){
4128 if(i == OMFGcnt - 2)
4130 OMFG->i = OMFG->i->next;
4133 OMFG->i->next = NULL;
4141 }else if(MatchCnt > 0){
4142 for (int i = 0; i < MatchCnt-1; i++) {
4144 OMFG->i = OMFG->i->next;
4147 OMFG->i->next = OMFG->i->next->next;
4151 LOL = OMFG->i->next;
4165 OMFG->i = OMFG->i->next;
4174 TX[st].S->next = OMFG;
4178 TX[st].S = STRtop[st];
4188 TX[st].S = STRtop[st];
4190 for(int i = 0;i < sl;i++){
4191 TX[st].S = TX[st].S->next;
4196 STANDIMAGE *ICRNT = TX[st].S->i;
4199 NSArray *siNew = [STANDADDSTRING componentsSeparatedByString:@"(new)"];
4200 NSString *siNewL = [STANDADDSTRING substringToIndex:[STANDADDSTRING length] - [@"(new)" length]];
4201 if([siNew count] >= 2){
4203 bool breakFlagOfLoop = false;
4205 STRING *ST1 = TX[st].S;
4206 STANDIMAGE *STI1 = NULL;
4208 STI1->name = siNewL;
4211 TX[st].S = TX[st].S->next;
4214 STANDIMAGE *STI2 = TX[st].S->i;
4217 TX[st].S->i = calloc(1, sizeof(STANDIMAGE));
4218 *TX[st].S->i = *STI1;
4221 NSArray *woot = [STANDADDSTRING componentsSeparatedByString:@"(clear)"];
4223 if([woot count] >= 2){
4224 if([STI1->name isEqualToString:woot[0]]){
4225 breakFlagOfLoop = true;
4231 if([STANDADDSTRING isEqualToString:siNewL]){
4232 breakFlagOfLoop = true;
4238 NSArray *SINew = [TX[st].S->i->name componentsSeparatedByString:@"(new)"];
4239 NSArray *SIClear = [TX[st].S->i->name componentsSeparatedByString:@"(clear)"];
4241 if([SINew count] >= 2){
4242 TX[st].S->i = TX[st].S->i->next;
4246 if([SIClear count] >= 2){
4247 TX[st].S->i = TX[st].S->i->next;
4252 TX[st].S->i = TX[st].S->i->next;
4257 TX[st].S->i = calloc(1, sizeof(STANDIMAGE));
4262 if(breakFlagOfLoop){
4265 TX[st].S = TX[st].S->next;
4271 TX[st].S->i = ICRNT;
4275 TX[st].S = TX[st].S->next;
4279 TX[st].S = STRtop[st];
4295 TX[st].S = STRtop[st];
4298 TX[st].S = STRtop[st];
4299 for(int i = 0;i < sl;i++){
4300 TX[st].S = TX[st].S->next;
4306 STRSItop = TX[st].S;
4309 if(TX[st].S->i == (STANDIMAGE*)0x1){
4311 SItop = TX[st].S->i;
4315 STANDIMAGE *siNextTop;
4316 STANDIMAGE *siSubTop = TX[st].S->next->i;
4317 const STANDIMAGE *siSub = TX[st].S->next->i;
4322 STANDIMAGE *ICRNT = TX[st].S->i;
4324 TX[st].S = TX[st].S->next;
4326 NSArray *sisi = [STANDADDSTRING componentsSeparatedByString:@"(new)"];
4329 if([sisi count] >= 2){
4330 siChk3 = [STANDADDSTRING substringToIndex:[STANDADDSTRING length] - [@"(new)" length]];
4332 bool breakFlagOfLoop = false;
4334 STRING *oioihonto = TX[st].S;
4335 STANDIMAGE *oioihonto3 = NULL;
4337 oioihonto3 = STANDADD;
4338 oioihonto3->name = siChk3;
4339 oioihonto3->next = NULL;
4341 TX[st].S = TX[st].S->next;
4346 STANDIMAGE *oioihonto2 = TX[st].S->i;
4348 TX[st].S->i = calloc(1, sizeof(STANDIMAGE));
4349 *TX[st].S->i = *oioihonto3;
4350 oioihonto2 = TX[st].S->i;
4352 while (TX[st].S->i) {
4353 NSArray *woot = [STANDADDSTRING componentsSeparatedByString:@"(clear)"];
4355 if([woot count] >= 2){
4356 if([oioihonto3->name isEqualToString:woot[0]]){
4357 breakFlagOfLoop = true;
4363 if([STANDADDSTRING isEqualToString:siChk3]){
4364 breakFlagOfLoop = true;
4370 NSArray *siNew = [TX[st].S->i->name componentsSeparatedByString:@"(new)"];
4371 NSArray *siClear = [TX[st].S->i->name componentsSeparatedByString:@"(clear)"];
4373 if([siNew count] >= 2){
4374 TX[st].S->i = TX[st].S->i->next;
4378 if([siClear count] >= 2){
4379 TX[st].S->i = TX[st].S->i->next;
4384 TX[st].S->i = TX[st].S->i->next;
4388 TX[st].S->i = calloc(1, sizeof(STANDIMAGE));
4389 TX[st].S->i = oioihonto3;
4390 oioihonto2 = TX[st].S->i;
4392 TX[st].S->i = oioihonto2;
4393 if(breakFlagOfLoop){
4396 TX[st].S = TX[st].S->next;
4397 }TX[st].S = oioihonto;
4402 TX[st].S->i = ICRNT;
4404 STANDADDSTRING = NULL;
4407 STANDIMAGE *SItop2 = TX[st].S->next->i;
4408 SItop = TX[st].S->i;
4412 STANDIMAGE *siTop = si;
4413 siNextTop = TX[st].S->next->i;
4414 STANDIMAGE *siCurrent = si;
4416 while(TX[st].S->next->i){
4423 bool dblFlag = false;
4429 STANDIMAGE *mouWakewakaran = TX[st].S->next->i;
4430 TX[st].S->next->i = siNextTop;
4431 while (TX[st].S->next->i) {
4433 STANDIMAGE *iikagennishiro = TX[st].S->i;
4434 TX[st].S->i = SItop;
4435 while (TX[st].S->i) {
4437 if([TX[st].S->i->name isEqualToString:TX[st].S->next->i->name] && !dblFlag){
4440 TX[st].S->i = TX[st].S->i->next;
4441 }TX[st].S->i= iikagennishiro;;
4444 siChk = [TX[st].S->next->i->name stringByAppendingFormat:@"(new)"];
4445 siChk2 = [TX[st].S->next->i->name stringByAppendingFormat:@"(clear)"];
4446 if([TX[st].S->i->name isEqualToString:siChk]){
4451 if([TX[st].S->i->name isEqualToString:siChk2]){
4457 iikagennishiro = TX[st].S->i;
4459 STANDIMAGE *SIsemiTop = TX[st].S->i;
4460 while (TX[st].S->i) {
4461 NSArray *sisi = [TX[st].S->i->name componentsSeparatedByString:@"(new)"];
4462 NSArray *sisi2 = [TX[st].S->i->name componentsSeparatedByString:@"(clear)"];
4464 if([sisi count] >= 2){
4465 siChk3 = [TX[st].S->i->name substringToIndex:[TX[st].S->i->name length] - [@"(new)" length]];
4467 if([sisi2 count] >= 2){
4468 siChk4 = [TX[st].S->i->name substringToIndex:[TX[st].S->i->name length] - [@"(clear)" length]];
4470 STANDIMAGE *oos = TX[st].S->i;
4472 NSArray *sisi = [TX[st].S->i->name componentsSeparatedByString:@"(new)"];
4473 NSArray *sisi2 = [TX[st].S->i->name componentsSeparatedByString:@"(clear)"];
4476 NSArray *sisi3 = [TX[st].S->next->i->name componentsSeparatedByString:@"(new)"];
4477 NSArray *sisi4 = [TX[st].S->next->i->name componentsSeparatedByString:@"(clear)"];
4479 if([sisi count] >= 2 && [sisi3 count] >= 2){
4481 TX[st].S->next->i->delNew = true;
4484 if([sisi2 count] >= 2 && [sisi4 count] >= 2){
4486 TX[st].S->next->i->delClear = true;
4489 if([sisi2 count] >= 2 && [sisi3 count] >= 2){
4491 TX[st].S->next->i->delNew = false;
4492 TX[st].S->i = iikagennishiro;
4497 if([sisi count] >= 2 && [sisi4 count] >= 2){
4499 TX[st].S->next->i->delClear = false;
4500 TX[st].S->i = iikagennishiro;
4505 TX[st].S->i = TX[st].S->i->next;
4510 STANDIMAGE *moukanben = TX[st].S->next->i;
4511 TX[st].S->next->i = siNextTop;
4512 while(TX[st].S->next->i){
4513 if([TX[st].S->next->i->name isEqualToString:siChk]){
4518 TX[st].S->next->i = TX[st].S->next->i->next;
4520 TX[st].S->next->i = moukanben;
4527 moukanben = TX[st].S->next->i;
4528 TX[st].S->next->i = siNextTop;
4529 while(TX[st].S->next->i){
4530 if([TX[st].S->next->i->name isEqualToString:siChk2]){
4535 TX[st].S->next->i = TX[st].S->next->i->next;
4537 TX[st].S->next->i = moukanben;
4542 TX[st].S->i = TX[st].S->i->next;
4543 }TX[st].S->i = iikagennishiro;
4545 TX[st].S->i = SIsemiTop;
4547 if(!dblFlag && TX[st].S->next->i->next)
4549 TX[st].S->next->i = TX[st].S->next->i->next;
4556 //TX[st].S->next->i= mouWakewakaran;
4561 if(TX[st].S->next->i){
4562 siChk = [TX[st].S->next->i->name retain];
4563 siChk2 = [TX[st].S->next->i->name retain];
4574 //TX[st].S->next->i= mouWakewakaran;
4578 STRtop[st] = STRtop[st];
4581 if(!dblFlag) siFlag = false;
4582 while (si && TX[st].S->next->i && !dblFlag) {
4587 if([si->name isEqualToString:TX[st].S->next->i->name] && !dblFlag){
4595 TX[st].S->next->i = TX[st].S->next->i->next;
4598 }TX[st].S->next->i= mouWakewakaran;
4602 if(TX[st].S->next->i){
4603 siChk = [TX[st].S->next->i->name retain];
4604 siChk2 = [TX[st].S->next->i->name retain];
4613 TX[st].S->next->i= mouWakewakaran;
4619 si = calloc(1, sizeof(STANDIMAGE));
4622 }else if(siCntdbl > 0){
4623 si->next = calloc(1, sizeof(STANDIMAGE));
4632 }else if(![TX[st].S->i->name isEqualToString:siChk2]){
4635 si = calloc(1, sizeof(STANDIMAGE));
4638 }else if(siCntdbl > 0){
4639 si->next = calloc(1, sizeof(STANDIMAGE));
4650 TX[st].S->i = TX[st].S->i->next;
4651 }TX[st].S->i = SItop;
4653 TX[st].S->next->i = TX[st].S->next->i->next;
4654 }TX[st].S->next->i = siNextTop;
4659 STRtop[st] = STRtop[st];
4661 siSubTop = TX[st].S->next->i;
4662 siSub = TX[st].S->next->i;
4663 STANDIMAGE *ouiHey = TX[st].S->i;
4671 if(TX[st].S->i) SIcpy= *(TX[st].S->i);
4674 NSArray *siChk = [NSArray arrayWithObjects:@"", nil];
4675 NSArray *siChk2 = [NSArray arrayWithObjects:@"", nil];
4677 siChk = [TX[st].S->i->name componentsSeparatedByString:@"(new)"];
4678 siChk2 = [TX[st].S->i->name componentsSeparatedByString:@"(clear)"];
4679 if([siChk count] >= 2){
4680 SIcpy.name= siChk[0];
4682 if([siChk2 count] >= 2){
4683 SIcpy.name = siChk2[0];
4686 NSArray *siChk3 = [NSArray arrayWithObjects:@"", nil];;
4687 NSArray *siChk4 = [NSArray arrayWithObjects:@"", nil];;
4689 siChk3 = [siSub->name componentsSeparatedByString:@"(new)"];
4690 siChk4 = [siSub->name componentsSeparatedByString:@"(clear)"];
4699 SIcpy2 = calloc(1, sizeof(STANDIMAGE));
4705 TX[st].S->next->i = calloc(1, sizeof(STANDIMAGE));
4706 if([siChk count] >= 2 && ![siChk[0] isEqualToString:TX[st].S->next->i->name]){
4707 *(TX[st].S->next->i) = SIcpy;
4708 }else if([siChk2 count] >= 2 && ![siChk2[0] isEqualToString:TX[st].S->next->i->name]){
4709 *(TX[st].S->next->i) = SIcpy;
4710 }else if([siChk count] < 2 && [siChk2 count] < 2){
4713 *(TX[st].S->next->i) = SIcpy2;
4715 *(TX[st].S->next->i) = SIcpy;
4717 SItop2 = TX[st].S->next->i;
4723 if([siChk2 count] >= 2){
4730 if([siChk2 count] >= 2 && [siChk3 count] >= 2){
4736 if(TX[st].S->i && TX[st].S->next->i)
4737 if([TX[st].S->next->i->name isEqualToString:TX[st].S->i->name]){
4741 //NSLog(@"%@, %@, %@, %@, %@", siChk,siChk2,siChk3,siChk4, siSub->name);
4745 TX[st].S->next->i = calloc(1, sizeof(STANDIMAGE));
4746 SItop2 = TX[st].S->next->i;
4748 if(TX[st].S->next->i){
4749 if(!TX[st].S->next->i->next){
4750 if(siCnt >= 1) TX[st].S->next->i->next = calloc(1, sizeof(STANDIMAGE));
4751 if(siCnt == 1) SItop2 = TX[st].S->next->i;
4756 if(siCnt >= 1 && TX[st].S->next->i) TX[st].S->next->i = TX[st].S->next->i->next;
4759 if([siChk4 count] >= 2 && [siChk count] >= 2){
4760 *(TX[st].S->next->i) = *SIcpy2;
4761 }else if([siChk count] >= 2 && ![siChk[0] isEqualToString:siChk[0]]){
4762 *(TX[st].S->next->i) = SIcpy;
4763 }else if([siChk2 count] >= 2 && ![siChk2[0] isEqualToString:siChk2[0]]){
4764 *(TX[st].S->next->i) = SIcpy;
4765 }else if([siChk count] < 2 && [siChk2 count] < 2){
4767 *(TX[st].S->next->i) = *SIcpy2;
4768 //TX[st].S->next->i->SEMA1row = SIcpy2->SEMA1row;
4771 *(TX[st].S->next->i) = SIcpy;
4773 }else if(siSub && [siChk count] >= 2 && [siChk[0] isEqualToString:siSub->name]){
4775 *(TX[st].S->next->i) = *SIcpy2;}
4777 *(TX[st].S->next->i) = SIcpy;}
4778 }else if([siChk2[0] isEqualToString:siChk3[0]]){
4780 *(TX[st].S->next->i) = *SIcpy2;}
4782 *(TX[st].S->next->i) = SIcpy;}
4783 }else if([siChk[0] isEqualToString:siChk4[0]]){
4785 *(TX[st].S->next->i) = *SIcpy2;}
4787 *(TX[st].S->next->i) = SIcpy;}
4790 *(TX[st].S->next->i) = *SIcpy2;}
4792 *(TX[st].S->next->i) = SIcpy;}
4798 if(TX[st].S->i) TX[st].S->i = TX[st].S->i->next;
4799 //if(!TX[st].S->i) TX[st].S->next->i = NULL;
4801 if(siSub) siSub = siSub->next;
4803 TX[st].S->i = ouiHey;
4804 //if(siSub) siSub = siSub->next;
4806 if(TX[st].S->next->i) TX[st].S->next->i->next = NULL;
4812 si->delClear = false;
4813 NSArray *siChk = [si->name componentsSeparatedByString:@"(new)"];
4814 NSArray *siChk2 = [si->name componentsSeparatedByString:@"(clear)"];
4815 if([siChk count] >= 2){
4818 if([siChk2 count] >= 2){
4819 si->delClear = true;
4823 STANDIMAGE SIcpy = *si;
4825 TX[st].S->next->i = calloc(1, sizeof(STANDIMAGE));
4826 *(TX[st].S->next->i) = SIcpy;
4829 TX[st].S->next->i->next = calloc(1, sizeof(STANDIMAGE));
4830 TX[st].S->next->i = TX[st].S->next->i->next;
4831 *(TX[st].S->next->i) = SIcpy;
4840 TX[st].S->i = SItop;
4841 TX[st].S->next->i = SItop2;
4842 STRtop[st] = STRtop[st];
4846 STRING *kusodana = TX[st].S;
4848 STANDIMAGE *faggotomfg = TX[st].S->i;
4850 if(TX[st].S->next) {
4851 STANDIMAGE *majikuso = TX[st].S->next->i;
4852 while(TX[st].S->next->i){
4853 TX[st].S->next->i->delNew = false;
4854 TX[st].S->next->i->delClear = false;
4855 NSArray *siChk = [TX[st].S->next->i->name componentsSeparatedByString:@"(new)"];
4856 NSArray *siChk2 = [TX[st].S->next->i->name componentsSeparatedByString:@"(clear)"];
4857 if([siChk count] >= 2){
4858 TX[st].S->next->i->delNew = true;
4860 if([siChk2 count] >= 2){
4861 TX[st].S->next->i->delClear = true;
4863 TX[st].S->next->i = TX[st].S->next->i->next;
4865 TX[st].S->next->i = majikuso;
4867 TX[st].S->i = TX[st].S->i->next;
4868 }TX[st].S->i = faggotomfg;
4869 TX[st].S = TX[st].S->next;
4870 }TX[st].S = kusodana;
4872 STRING *majika = TX[st].S;
4874 STANDIMAGE *tukareta = TX[st].S->i;
4876 if(TX[st].S->next) {
4877 STANDIMAGE *majikuso = TX[st].S->next->i;
4879 while(TX[st].S->next->i){
4880 NSArray *sisi = [TX[st].S->i->name componentsSeparatedByString:@"(new)"];
4881 NSArray *sisi2 = [TX[st].S->i->name componentsSeparatedByString:@"(clear)"];
4882 NSArray *sisi3 = [TX[st].S->next->i->name componentsSeparatedByString:@"(new)"];
4883 NSArray *sisi4 = [TX[st].S->next->i->name componentsSeparatedByString:@"(clear)"];
4886 if([sisi count] < 2 && [sisi4 count] >= 2){
4887 TX[st].S->next->i->delClear = false;
4890 if([sisi2 count] >= 2 && [sisi3 count] >= 2){
4891 TX[st].S->next->i->delNew = false;
4892 TX[st].S->i->delClear = false;
4896 if([sisi count] >= 2 && [sisi4 count] >= 2){
4897 TX[st].S->next->i->delClear = false;
4901 if(([sisi3 count] >= 2) && ![sisi[0] isEqualToString:sisi3[0]]){
4902 TX[st].S->next->i->delNew = false;
4906 if([sisi2 count] >= 2 && [sisi3 count] < 2 && [sisi2[0] isEqualToString:sisi4[0]]){
4907 TX[st].S->next->i->delClear = true;
4908 STRING *gochagocha = TX[st].S;
4909 TX[st].S = TX[st].S->next;
4911 STANDIMAGE *moukusoyan = TX[st].S->i;
4914 if([sisi2[0] isEqualToString:TX[st].S->i->name]){
4915 TX[st].S->i->delClear = true;
4916 }else if([[sisi2[0] stringByAppendingString:@"(new)"] isEqualToString:TX[st].S->i->name]){
4919 TX[st].S->i = TX[st].S->i->next;
4920 }TX[st].S->i = moukusoyan;
4921 TX[st].S = TX[st].S->next;
4922 }TX[st].S = gochagocha;
4925 TX[st].S->next->i = TX[st].S->next->i->next;
4927 TX[st].S->next->i = majikuso;
4929 TX[st].S->i = TX[st].S->i->next;
4930 }TX[st].S->i = tukareta;
4931 TX[st].S = TX[st].S->next;
4937 TX[st].S = TX[st].S;
4938 STRtop[st] = STRtop[st];
4951 STANDIMAGE *siPostTop = siPost;
4953 STRtop[st] = STRtop[st];
4956 if(siPost && WTF == 0){
4957 NSArray *siChk = [siPost->name componentsSeparatedByString:@"(new)"];
4958 NSArray *siChk2 = [siPost->name componentsSeparatedByString:@"(clear)"];
4959 if([siChk count] >= 2 && siPost->delNew){
4960 siPost->name = [siChk[0] retain];
4963 if(siPost->delClear){
4966 if(siPostTop == siPost){
4967 siPost = siPost->next;
4970 STANDIMAGE sifix = *siPost->next;
4978 if(TX[st].S->i->next == (STANDIMAGE*)0x1){
4986 STRtop[st] = STRtop[st];
4989 while(siPost->next){
4990 NSArray *siChk = [siPost->next->name componentsSeparatedByString:@"(new)"];
4991 NSArray *siChk2 = [siPost->next->name componentsSeparatedByString:@"(clear)"];
4993 if([siChk count] >= 2 && siPost->next->delNew){
4994 siPost->next->name = [siChk[0] retain];
4997 if(siPost->next->delClear){
4999 if(siPostTop == siPost->next){
5000 siPost->next = siPost->next->next;
5002 }else if(siPost->next){
5003 if(siPost->next->next){
5004 STANDIMAGE sifix = *siPost->next->next;
5005 *siPost->next = sifix;
5007 siPost->next = NULL;
5016 siPost = siPost->next;
5018 siPost = siPost->next;
5019 STRtop[st] = STRtop[st];
5022 STRSI->i = siPostTop;
5024 STRtop[st] = STRtop[st];
5030 TX[st].S = TX[st].S->next;
5036 //wtf instant bug fix
5037 TX[st].S = STRtop[st];
5039 SItop = TX[st].S->i;
5042 if(TX[st].S->i->next){
5044 if(TX[st].S->i->next->name == nil){
5045 TX[st].S->i->next = NULL;
5050 TX[st].S->i = TX[st].S->i->next;
5051 }TX[st].S->i = SItop;
5052 TX[st].S = TX[st].S->next;
5055 TX[st].S = STRtop[st];
5061 -(IBAction)SEstandSEremove:(id)sender{
5066 NSLog(@"[%@]",[SEstandTF0 stringValue]);
5067 if(![[SEMA[SEMArow] valueForKey:@"name"] isEqualToString:[NSString stringWithFormat:@"%@", [SEstandTF0 stringValue]]])
5072 TX[st].S = STRtop[st];
5073 for(int i = 0;i < sl;i++){
5074 TX[st].S = TX[st].S->next;
5080 if([SEMA count] == 0){
5082 }else if(SEMArow == -1){
5083 for(int i = 0;i < [MA1 count]-1;i++){
5084 if(i == [SEMA count]- 2){
5087 if(i == [SEMA count] - 2)
5091 if([SEMA count] > 1) {
5100 [TX[st].SIarray removeObjectAtIndex:[SEMA count]-1];
5101 [self willChangeValueForKey:@"SEMA"];
5102 [SEMA removeObjectAtIndex:[SEMA count]-1];
5103 [self didChangeValueForKey:@"SEMA"];
5104 [SEAC setSelectionIndex:999];
5107 }else if(SEMArow > 0){
5108 for (int i = 0; i < SEMArow-1; i++) {
5113 si->next = si->next->next;
5115 [TX[st].SIarray removeObjectAtIndex:SEMArow];
5116 [self willChangeValueForKey:@"SEMA"];
5117 [SEMA removeObjectAtIndex:SEMArow];
5118 [self didChangeValueForKey:@"SEMA"];
5119 [SEAC setSelectionIndex:999];
5127 [TX[st].SIarray removeObjectAtIndex:SEMArow];
5128 [self willChangeValueForKey:@"SEMA"];
5129 [SEMA removeObjectAtIndex:SEMArow];
5130 [self didChangeValueForKey:@"SEMA"];
5131 [SEAC setSelectionIndex:999];
5137 TX[st].S = STRtop[st];
5146 [testIV setImage:SEstandImgST];
5153 @implementation SEstandView
5156 - (id)initWithFrame:(NSRect)frame
5158 self = [super initWithFrame:frame];
5161 scheduledTimerWithTimeInterval:0.05f
5163 selector:@selector(EventLoopSV:)
5172 -(void)EventLoopSV:(NSTimer*)time{
5175 [self setNeedsDisplay:YES];
5177 [self GetImageFromImageView];
5181 -(void)GetImageFromImageView{
5182 NSString *directoryPath;
5184 directoryPath = [[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent];
5185 [[NSFileManager defaultManager] changeCurrentDirectoryPath:directoryPath];
5188 NSBitmapImageRep* rep = [self bitmapImageRepForCachingDisplayInRect:self.bounds];
5189 [self cacheDisplayInRect:self.bounds toBitmapImageRep:rep];
5192 NSMutableData* data = [rep representationUsingType:NSPNGFileType properties:nil];
5194 NSMutableData* fdata = [NSMutableData dataWithCapacity:sizeof(data)];
5195 [fdata appendData:data];
5197 NSString* pth1 = @"data/Others/SECPY";
5199 char *binary = fdata.mutableBytes;
5202 [fdata writeToFile:pth1 atomically:YES];
5206 NSMutableData* data2 = [[NSMutableData alloc] initWithData:[[NSFileHandle fileHandleForReadingAtPath:pth1] readDataToEndOfFile]];
5208 NSMutableData* fdata2 = [NSMutableData dataWithCapacity:sizeof(data)];
5209 [fdata2 appendData:data2];
5211 char *binary2 = fdata2.mutableBytes;
5215 SEstandImg = [[NSImage alloc] initWithData:fdata2];
5222 -(NSImage*)LoadImage:(NSString*)name{
5223 NSImage *image = [NSImage imageNamed:name];
5224 if(image == nil) return nil;
5229 -(void)DrawImage:(NSImage*)image x:(float)x y:(float)y{
5231 frRect.size.height = image.size.height;
5232 frRect.size.width = image.size.width;
5234 frRect.origin.x = 0;
5235 frRect.origin.y = 0;
5238 drRect.origin.x = x;
5239 drRect.origin.y = y;
5240 drRect.size.height = image.size.height;
5241 drRect.size.width = image.size.width;
5243 [image drawInRect:drRect fromRect:frRect operation:NSCompositeSourceOver fraction:1.0f respectFlipped:YES hints:nil];
5248 - (void)drawRect:(NSRect)dirtyRect
5257 for(int i = 0;i < SEMA1row;i++){
5265 while(layerIndex <= 999){
5267 for (int i = 0;b && i <= SEMA2row; i++) {
5271 if(layerIndex == b->z && b->img) [self DrawImage:b->img x:b->x y:b->y];
5277 if(l->visibleInstant){
5279 if(layerIndex == l->z && l->img)
5280 [self DrawImage:l->img x:l->x y:l->y];
5320 @implementation SEstandViewTest
5322 - (id)initWithFrame:(NSRect)frame
5324 self = [super initWithFrame:frame];
5327 scheduledTimerWithTimeInterval:0.05f
5329 selector:@selector(EventLoopSV:)
5344 -(void)EventLoopSV:(NSTimer*)time{
5347 [self setNeedsDisplay:YES];
5351 -(void)mouseDown:(NSEvent *)theEvent{
5353 TX[st].S = STRtop[st];
5354 for(int i = 0;i < sl;i++){
5355 TX[st].S = TX[st].S->next;
5358 SItop = TX[st].S->i;
5359 for(int i = 0;i < SEMArow;i++){
5360 TX[st].S->i = TX[st].S->i->next;
5363 imgSGx = TX[st].S->i->standX;
5364 imgSGy = TX[st].S->i->standY;
5367 startPoint = [self convertPoint:[theEvent locationInWindow] fromView:nil];
5369 startPoint.x = startPoint.x - imgSGx;
5370 startPoint.y = startPoint.y - imgSGy;
5372 TX[st].S->i = SItop;
5374 TX[st].S = STRtop[st];
5376 [self setNeedsDisplay:YES];
5379 -(void)mouseDragged:(NSEvent *)theEvent{
5381 TX[st].S = STRtop[st];
5382 for(int i = 0;i < sl;i++){
5383 TX[st].S = TX[st].S->next;
5386 SItop = TX[st].S->i;
5387 for(int i = 0;i < SEMArow;i++){
5388 TX[st].S->i = TX[st].S->i->next;
5391 endPoint = [self convertPoint:[theEvent locationInWindow] fromView:nil];
5393 imgSGx = endPoint.x - startPoint.x;
5394 imgSGy = endPoint.y - startPoint.y;
5397 TX[st].S->i->standX = imgSGx;
5398 TX[st].S->i->standY = imgSGy;
5401 [self setNeedsDisplay:YES];
5402 TX[st].S->i = SItop;
5403 TX[st].S = STRtop[st];
5407 - (void)drawRect:(NSRect)dirtyRect
5411 TX[st].S = STRtop[st];
5412 for(int i = 0;i < sl;i++){
5413 TX[st].S = TX[st].S->next;
5416 SItop = TX[st].S->i;
5417 for(int i = 0;i < SEMArow;i++){
5418 TX[st].S->i = TX[st].S->i->next;
5421 [self DrawImage:TX[st].S->i->imgStand x:TX[st].S->i->standX y:TX[st].S->i->standY];
5422 TX[st].S->i = SItop;
5424 TX[st].S = STRtop[st];
5428 -(void)DrawImage:(NSImage*)image x:(float)x y:(float)y{
5430 frRect.size.height = image.size.height;
5431 frRect.size.width = image.size.width;
5433 frRect.origin.x = 0;
5434 frRect.origin.y = 0;
5437 drRect.origin.x = x;
5438 drRect.origin.y = y;
5439 drRect.size.height = image.size.height;
5440 drRect.size.width = image.size.width;
5442 [image drawInRect:drRect fromRect:frRect operation:NSCompositeSourceOver fraction:1.0f respectFlipped:YES hints:nil];
5458 @implementation SEstandViewST: NSView
5460 - (id)initWithFrame:(NSRect)frame
5462 self = [super initWithFrame:frame];
5465 scheduledTimerWithTimeInterval:0.01f
5467 selector:@selector(EventLoopSV:)
5476 -(void)EventLoopSV:(NSTimer*)time{
5480 static int omfg = 0;
5484 for(int i= 0;i < TEXTMAX;i++){
5490 [self setNeedsDisplay:YES];
5493 [self GetImageFromImageView2];
5501 [self setNeedsDisplay:YES];
5507 static int TXCPYS0 = 0;
5508 static int TXCPYSI0 = 0;
5512 TXCPY[STSNUM] = TX[STSNUM];
5513 TXCPYStop = TXCPY[STSNUM].S;
5516 if(TXCPY[STSNUM].S){
5519 TXCPYSItop = TXCPY[STSNUM].S->i;
5522 if(TXCPY[STSNUM].S->i){
5523 TXCPY[STSNUM].S->i = TXCPY[STSNUM].S->i->next;
5526 TXCPY[STSNUM].S->i = TXCPYSItop;
5527 TXCPY[STSNUM].S = TXCPY[STSNUM].S->next;
5532 TXCPY[STSNUM].S = TXCPYStop;
5535 for(int i = 0;i < TEXTMAX;i++){
5543 if(!TXCPY[STSNUM].fileName){
5546 NSLog(@"TXCPY LoadComplete");
5547 }else if(STSNUM > TEXTMAX){
5550 NSLog(@"TXCPY LoadComplete");
5554 TXCPY[STSNUM] = TXCPY[STSNUM];
5557 -(void)GetImageFromImageView2{
5559 if(!TXCPY[STSNUM].fileName)
5561 if(!TXCPY[STSNUM].S)
5563 if(!TXCPY[STSNUM].S->i)
5565 NSString *directoryPath;
5567 directoryPath = [[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent];
5568 [[NSFileManager defaultManager] changeCurrentDirectoryPath:directoryPath];
5571 NSBitmapImageRep* rep = [self bitmapImageRepForCachingDisplayInRect:self.bounds];
5572 [self cacheDisplayInRect:self.bounds toBitmapImageRep:rep];
5575 NSMutableData* data = [rep representationUsingType:NSPNGFileType properties:nil];
5577 NSMutableData* fdata = [NSMutableData dataWithCapacity:sizeof(data)];
5578 [fdata appendData:data];
5580 NSString* pth1 = @"data/Others/SECPYST";
5582 char *binary = fdata.mutableBytes;
5585 [fdata writeToFile:pth1 atomically:YES];
5589 NSMutableData* data2 = [[NSMutableData alloc] initWithData:[[NSFileHandle fileHandleForReadingAtPath:pth1] readDataToEndOfFile]];
5591 NSMutableData* fdata2 = [NSMutableData dataWithCapacity:sizeof(data)];
5592 [fdata2 appendData:data2];
5594 char *binary2 = fdata2.mutableBytes;
5598 SEstandImgST = [[NSImage alloc] initWithData:fdata2];
5600 TXCPY[STSNUM].S->i->imgStand = SEstandImgST;
5602 [testScenarioEditor testSEtest];
5610 -(NSImage*)LoadImage:(NSString*)name{
5611 NSImage *image = [NSImage imageNamed:name];
5612 if(image == nil) return nil;
5617 -(void)DrawImage:(NSImage*)image x:(float)x y:(float)y{
5619 frRect.size.height = image.size.height;
5620 frRect.size.width = image.size.width;
5622 frRect.origin.x = 0;
5623 frRect.origin.y = 0;
5626 drRect.origin.x = x;
5627 drRect.origin.y = y;
5628 drRect.size.height = image.size.height;
5629 drRect.size.width = image.size.width;
5631 [image drawInRect:drRect fromRect:frRect operation:NSCompositeSourceOver fraction:1.0f respectFlipped:YES hints:nil];
5636 - (void)drawRect:(NSRect)dirtyRect
5640 if(TXCPY[STSNUM].fileName)
5642 if(TXCPY[STSNUM].S->i){
5644 if(TXCPY[STSNUM].S->i->SEMA1row-1 < 0)
5646 if(TXCPY[STSNUM].S->i->SEMA2row-1 < 0)
5650 for(int i = 0;i < TXCPY[STSNUM].S->i->SEMA1row-1;i++){
5658 while(layerIndex <= 999){
5660 for (int i = 0;b && i <= TXCPY[STSNUM].S->i->SEMA2row-1; i++) {
5662 if(i == TXCPY[STSNUM].S->i->SEMA2row-1){
5664 if(layerIndex == b->z && b->img) [self DrawImage:b->img x:b->x y:b->y];
5671 if(l->visibleInstant){
5674 if(TXCPY[STSNUM].S->i->SEMA3flag)
5675 if(*(TXCPY[STSNUM].S->i->SEMA3flag + i0) > 1)
5676 if(layerIndex == l->z && l->img)
5677 [self DrawImage:l->img x:l->x y:l->y];