-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDSACharacterMultiSelectionWindowController.m
More file actions
162 lines (135 loc) · 5.25 KB
/
DSACharacterMultiSelectionWindowController.m
File metadata and controls
162 lines (135 loc) · 5.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/*
Project: DSA-SpielHelfer
Copyright (C) 2025 Free Software Foundation
Author: Sebastian Reitenbach
Created: 2025-05-31 22:15:14 +0200 by sebastia
This application is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This application is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
*/
#import "DSACharacterMultiSelectionWindowController.h"
#import "DSACharacter.h"
@implementation DSACharacterMultiSelectionWindowController
- (void)windowDidLoad {
[super windowDidLoad];
NSInteger i = 0;
for (DSACharacter *character in self.characters) {
NSString *fieldName = [NSString stringWithFormat: @"switchCharacter%li", (unsigned long)i];
NSLog(@"DSACharacterMultiSelectionWindowController character: %@", character.name);
NSButton *switchfield = [self valueForKey: fieldName];
[switchfield setHidden: NO];
[switchfield setEnabled: YES];
[switchfield setTitle: character.name];
i++;
}
for (; i < 9; i++) {
NSString *fieldName = [NSString stringWithFormat: @"switchCharacter%li", (unsigned long)i];
NSButton *switchfield = [self valueForKey: fieldName];
[switchfield setHidden: YES];
[switchfield setEnabled: NO];
}
[self.buttonSelect setEnabled: NO];
}
/*
for (NSInteger i=0; i< 20; i++)
{
NSString *fieldName = [NSString stringWithFormat: @"switchMagicalDabbler%li", i];
[[self valueForKey: fieldName] setHidden: YES];
[[self valueForKey: fieldName] setEnabled: NO];
}
- (IBAction) buttonMagicalDabblerFinish: (id)sender
{
NSLog(@"buttonMagicalDabblerFinish have to do the magical dabbler thing on the generated character...");
if (self.magicalDabblerDiceResult >= 1 && self.magicalDabblerDiceResult <= 15)
{
[self.magicalDabblerInfo setObject: @[_(@"Schutzgeist"), _(@"Magisches Meisterhandwerk")] forKey: @"specialTalents"];
NSMutableArray *newSpells = [[NSMutableArray alloc] init];
for (NSInteger i=0; i <= 19; i++)
{
NSString *fieldName = [NSString stringWithFormat: @"switchMagicalDabbler%li", i];
NSButton *button = [self valueForKey: fieldName];
if ([button state] == 1)
{
NSLog(@"testing spell: %@", [button title]);
[newSpells addObject: [button title]];
}
}
[self.magicalDabblerInfo setObject: newSpells forKey: @"spells"];
}
else if (self.magicalDabblerDiceResult >= 16 && self.magicalDabblerDiceResult <= 19)
{
[self.magicalDabblerInfo setObject: @[_(@"Schutzgeist"), _(@"Magisches Meisterhandwerk")] forKey: @"specialTalents"];
}
else if (self.magicalDabblerDiceResult == 20)
{
for (NSInteger i=0; i< 2; i++)
{
NSString *fieldName = [NSString stringWithFormat: @"switchMagicalDabbler%li", i];
NSButton *button = [self valueForKey: fieldName];
if ([button state] == 1)
{
[self.magicalDabblerInfo setObject: @[[button title]] forKey: @"specialTalents"];
break;
}
}
}
NSLog(@"Going to create the character!");
[self createCharacter:sender];
NSLog(@"Going to close the magical dabbler window");
[self.windowMagicalDabbler close];
NSLog(@"going to complete character generation");
[self completeCharacterGeneration];
}
*/
- (IBAction) characterSwitchToggled: (id)sender
{
NSLog(@"switchMagicalDabblerSelected called %@", [sender title]);
NSInteger counter = 0;
for (NSInteger i=0; i<= 8; i++)
{
NSString *fieldName = [NSString stringWithFormat: @"switchCharacter%li", (unsigned long)i];
if ([[self valueForKey: fieldName] state] == 1)
{
counter++;
}
}
// second test, due to that it doesn't make sense to move all characters to a new group...
if (counter > 0 && counter < [self.characters count])
{
[self.buttonSelect setEnabled: YES];
}
else
{
[self.buttonSelect setEnabled: NO];
}
}
- (IBAction)selectAction:(id)sender {
NSMutableArray *selectedCharacters = [[NSMutableArray alloc] init];
for (NSInteger i=0; i<= 8; i++)
{
NSString *fieldName = [NSString stringWithFormat: @"switchCharacter%li", (unsigned long)i];
if ([[self valueForKey: fieldName] state] == 1)
{
[selectedCharacters addObject: self.characters[i]];
}
}
if (selectedCharacters.count > 0) {
if (self.completionHandler) {
self.completionHandler(selectedCharacters);
}
}
// Close the sheet
[NSApp endSheet:self.window];
}
- (IBAction)cancelAction:(id)sender {
[NSApp endSheet:self.window];
}
@end