Skip to content

Commit 4760ca4

Browse files
author
Johannes Ekberg
committed
Fixed a TON of bugs in the Flag and Label system
the Flag and Variable system was completely broken, which effectively made every single game unplayable. Cross Channel didn't even launch when I tried it.
1 parent 6e4d69e commit 4760ca4

30 files changed

+590
-352
lines changed

Controller/ChoiceViewController.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ - (void)hide
7979

8080
- (void)actionSelectIndex:(NSInteger)index
8181
{
82-
Variable *var = [[Variable alloc] initWithKey:@"selected" value:[NSNumber numberWithInteger:index]];
82+
Variable *var = [[Variable alloc] initWithKey:@"selected" value:[NSNumber numberWithInteger:index] type:VNVariableTypeInt];
8383
[novel.currentState.vars setObject:var forKey:var.key];
8484
[var release];
8585
[delegate choiceClosed:self];
+46-31
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,57 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="7.10">
33
<data>
4-
<int key="IBDocument.SystemTarget">784</int>
5-
<string key="IBDocument.SystemVersion">10B500</string>
6-
<string key="IBDocument.InterfaceBuilderVersion">732</string>
7-
<string key="IBDocument.AppKitVersion">1038.2</string>
8-
<string key="IBDocument.HIToolboxVersion">437.00</string>
4+
<int key="IBDocument.SystemTarget">1280</int>
5+
<string key="IBDocument.SystemVersion">11C74</string>
6+
<string key="IBDocument.InterfaceBuilderVersion">1938</string>
7+
<string key="IBDocument.AppKitVersion">1138.23</string>
8+
<string key="IBDocument.HIToolboxVersion">567.00</string>
99
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
1010
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
11-
<string key="NS.object.0">62</string>
11+
<string key="NS.object.0">933</string>
1212
</object>
13-
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
13+
<object class="NSArray" key="IBDocument.IntegratedClassDependencies">
1414
<bool key="EncodedWithXMLCoder">YES</bool>
15-
<integer value="1"/>
15+
<string>IBProxyObject</string>
16+
<string>IBUIView</string>
1617
</object>
1718
<object class="NSArray" key="IBDocument.PluginDependencies">
1819
<bool key="EncodedWithXMLCoder">YES</bool>
1920
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
2021
</object>
2122
<object class="NSMutableDictionary" key="IBDocument.Metadata">
22-
<bool key="EncodedWithXMLCoder">YES</bool>
23-
<object class="NSArray" key="dict.sortedKeys" id="0">
24-
<bool key="EncodedWithXMLCoder">YES</bool>
25-
</object>
26-
<object class="NSMutableArray" key="dict.values">
27-
<bool key="EncodedWithXMLCoder">YES</bool>
28-
</object>
23+
<string key="NS.key.0">PluginDependencyRecalculationVersion</string>
24+
<integer value="1" key="NS.object.0"/>
2925
</object>
3026
<object class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
3127
<bool key="EncodedWithXMLCoder">YES</bool>
3228
<object class="IBProxyObject" id="372490531">
3329
<string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
30+
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
3431
</object>
3532
<object class="IBProxyObject" id="975951072">
3633
<string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
34+
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
3735
</object>
3836
<object class="IBUIView" id="191373211">
3937
<reference key="NSNextResponder"/>
4038
<int key="NSvFlags">274</int>
41-
<string key="NSFrameSize">{320, 460}</string>
39+
<string key="NSFrameSize">{480, 320}</string>
4240
<reference key="NSSuperview"/>
41+
<reference key="NSWindow"/>
42+
<reference key="NSNextKeyView"/>
4343
<object class="NSColor" key="IBUIBackgroundColor">
4444
<int key="NSColorSpace">3</int>
4545
<bytes key="NSWhite">MQA</bytes>
4646
<object class="NSColorSpace" key="NSCustomColorSpace">
4747
<int key="NSID">2</int>
4848
</object>
4949
</object>
50-
<object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/>
50+
<object class="IBUISimulatedOrientationMetrics" key="IBUISimulatedOrientationMetrics">
51+
<int key="IBUIInterfaceOrientation">3</int>
52+
<int key="interfaceOrientation">3</int>
53+
</object>
54+
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
5155
</object>
5256
</object>
5357
<object class="IBObjectContainer" key="IBDocument.Objects">
@@ -67,13 +71,18 @@
6771
<bool key="EncodedWithXMLCoder">YES</bool>
6872
<object class="IBObjectRecord">
6973
<int key="objectID">0</int>
70-
<reference key="object" ref="0"/>
74+
<object class="NSArray" key="object" id="0">
75+
<bool key="EncodedWithXMLCoder">YES</bool>
76+
</object>
7177
<reference key="children" ref="1000"/>
7278
<nil key="parent"/>
7379
</object>
7480
<object class="IBObjectRecord">
7581
<int key="objectID">1</int>
7682
<reference key="object" ref="191373211"/>
83+
<object class="NSMutableArray" key="children">
84+
<bool key="EncodedWithXMLCoder">YES</bool>
85+
</object>
7786
<reference key="parent" ref="0"/>
7887
</object>
7988
<object class="IBObjectRecord">
@@ -94,57 +103,63 @@
94103
<object class="NSArray" key="dict.sortedKeys">
95104
<bool key="EncodedWithXMLCoder">YES</bool>
96105
<string>-1.CustomClassName</string>
106+
<string>-1.IBPluginDependency</string>
97107
<string>-2.CustomClassName</string>
98-
<string>1.IBEditorWindowLastContentRect</string>
108+
<string>-2.IBPluginDependency</string>
99109
<string>1.IBPluginDependency</string>
100110
</object>
101111
<object class="NSMutableArray" key="dict.values">
102112
<bool key="EncodedWithXMLCoder">YES</bool>
103113
<string>ClassicChoiceViewController</string>
114+
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
104115
<string>UIResponder</string>
105-
<string>{{556, 412}, {320, 480}}</string>
116+
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
106117
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
107118
</object>
108119
</object>
109120
<object class="NSMutableDictionary" key="unlocalizedProperties">
110121
<bool key="EncodedWithXMLCoder">YES</bool>
111122
<reference key="dict.sortedKeys" ref="0"/>
112-
<object class="NSMutableArray" key="dict.values">
113-
<bool key="EncodedWithXMLCoder">YES</bool>
114-
</object>
123+
<reference key="dict.values" ref="0"/>
115124
</object>
116125
<nil key="activeLocalization"/>
117126
<object class="NSMutableDictionary" key="localizations">
118127
<bool key="EncodedWithXMLCoder">YES</bool>
119128
<reference key="dict.sortedKeys" ref="0"/>
120-
<object class="NSMutableArray" key="dict.values">
121-
<bool key="EncodedWithXMLCoder">YES</bool>
122-
</object>
129+
<reference key="dict.values" ref="0"/>
123130
</object>
124131
<nil key="sourceID"/>
125-
<int key="maxID">3</int>
132+
<int key="maxID">5</int>
126133
</object>
127134
<object class="IBClassDescriber" key="IBDocument.Classes">
128135
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
129136
<bool key="EncodedWithXMLCoder">YES</bool>
130137
<object class="IBPartialClassDescription">
131-
<string key="className">ClassicChoiceViewController</string>
138+
<string key="className">ChoiceViewController</string>
132139
<string key="superclassName">UIViewController</string>
133140
<object class="IBClassDescriptionSource" key="sourceIdentifier">
134141
<string key="majorKey">IBProjectSource</string>
135-
<string key="minorKey">ClassicChoiceViewController.h</string>
142+
<string key="minorKey">./Classes/ChoiceViewController.h</string>
143+
</object>
144+
</object>
145+
<object class="IBPartialClassDescription">
146+
<string key="className">ClassicChoiceViewController</string>
147+
<string key="superclassName">ChoiceViewController</string>
148+
<object class="IBClassDescriptionSource" key="sourceIdentifier">
149+
<string key="majorKey">IBProjectSource</string>
150+
<string key="minorKey">./Classes/ClassicChoiceViewController.h</string>
136151
</object>
137152
</object>
138153
</object>
139154
</object>
140155
<int key="IBDocument.localizationMode">0</int>
156+
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
141157
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
142158
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3</string>
143159
<integer value="3000" key="NS.object.0"/>
144160
</object>
145161
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
146-
<nil key="IBDocument.LastKnownRelativeProjectPath"/>
147162
<int key="IBDocument.defaultPropertyAccessControl">3</int>
148-
<string key="IBCocoaTouchPluginVersion">3.1</string>
163+
<string key="IBCocoaTouchPluginVersion">933</string>
149164
</data>
150165
</archive>

Controller/GameViewController.m

+12-13
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ - (void)viewDidLoad
7373
NSData *indexData = [[NSData alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"]];
7474
[textView loadData:indexData MIMEType:@"text/html" textEncodingName:@"utf-8" baseURL:[[NSBundle mainBundle] resourceURL]];
7575
[indexData release];
76-
//[textView loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"index" withExtension:@"html"]]];
7776

7877
interpreter = [[ScriptInterpreter alloc] initWithNovel:novel];
7978
interpreter.delegate = self;
@@ -113,9 +112,9 @@ - (void)dealloc
113112
- (void)interpreter:(ScriptInterpreter *)si processBGLOAD:(Command *)command
114113
{
115114
NSTimeInterval time = 0.16;
116-
if([command.parameters count] > 1)
117-
time = [[command.parameters objectAtIndex:2] integerValue]/100;
118-
NSString *path = [command.parameters objectAtIndex:0];
115+
if([command parameterCount] > 2)
116+
time = [[command parameterAtIndex:2 defaultValue:nil] integerValue]/100;
117+
NSString *path = [command parameterAtIndex:0 defaultValue:nil];
119118

120119
[self loadBackground:path fadeTime:time fromSave:NO];
121120
}
@@ -125,12 +124,12 @@ - (void)interpreter:(ScriptInterpreter *)si processSETIMG:(Command *)command
125124
//MTMark();
126125

127126
NSTimeInterval time = 0.16;
128-
if([command.parameters count] > 1)
129-
time = [[command.parameters objectAtIndex:2] integerValue]/100;
127+
if([command parameterCount] > 2)
128+
time = [[command parameterAtIndex:2 defaultValue:nil] integerValue]/100;
130129

131-
CGPoint point = CGPointMake([[command.parameters objectAtIndex:1] integerValue],
132-
[[command.parameters objectAtIndex:2] integerValue]);
133-
NSString *path = [@"foreground" stringByAppendingPathComponent:[command.parameters objectAtIndex:0]];
130+
CGPoint point = CGPointMake([[command parameterAtIndex:1 defaultValue:nil] integerValue],
131+
[[command parameterAtIndex:2 defaultValue:nil] integerValue]);
132+
NSString *path = [@"foreground" stringByAppendingPathComponent:[command parameterAtIndex:0 defaultValue:nil]];
134133
Sprite *sprite = [[Sprite alloc] initWithPath:path data:[novel contentsOfResource:path] point:point];
135134
[self addSprite:sprite fadeTime:time fromSave:NO];
136135
[sprite release];
@@ -139,15 +138,15 @@ - (void)interpreter:(ScriptInterpreter *)si processSETIMG:(Command *)command
139138
- (void)interpreter:(ScriptInterpreter *)si processSOUND:(Command *)command
140139
{
141140
//MTMark();
142-
[soundEngine playSound:[command.parameters objectAtIndex:0] onChannel:VNSoundChannelSound
143-
loops:([command.parameters count] > 1 ? [[command.parameters objectAtIndex:1] integerValue] : 0)];
141+
[soundEngine playSound:[command parameterAtIndex:0 defaultValue:nil] onChannel:VNSoundChannelSound
142+
loops:[[command parameterAtIndex:1 defaultValue:nil] integerValue]];
144143
}
145144

146145
- (void)interpreter:(ScriptInterpreter *)si processMUSIC:(Command *)command
147146
{
148147
//MTMark();
149-
[soundEngine playSound:[command.parameters objectAtIndex:0] onChannel:VNSoundChannelMusic
150-
loops:0];
148+
[soundEngine playSound:[command parameterAtIndex:0 defaultValue:nil]
149+
onChannel:VNSoundChannelMusic loops:0];
151150
}
152151

153152
- (void)interpreter:(ScriptInterpreter *)si processTEXT:(Command *)command

Controller/MainMenuViewController.m

+6-4
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,10 @@ - (void)collection:(Collection *)collection willUnzipFile:(NSString *)filename c
159159
- (void)collection:(Collection *)collection willUnzipFileNumber:(NSInteger)number outOf:(NSInteger)total from:(NSString *)from
160160
{
161161
MTLog(@"%d/%d", number, total);
162-
NSInteger padding = numdigits(total);
163162
dispatch_async(dispatch_get_main_queue(), ^{
164163
float progress = (float)number/(float)total;
164+
NSInteger padding = numdigits(total);
165+
165166
loadingVC.subtitleLabel.text = [NSString stringWithFormat:@"Decompressing file %*d/%-*d from %@... (%d%%)",
166167
padding, number, padding, total, [from lastPathComponent],
167168
(NSInteger)(progress*100)];
@@ -171,11 +172,12 @@ - (void)collection:(Collection *)collection willUnzipFileNumber:(NSInteger)numbe
171172
});
172173
}
173174

174-
- (void)collection:(Collection *)collection willReadSoundFromNovel:(NSString *)novel
175+
- (void)collection:(Collection *)collection willStartCleaningUpExtractionOfArchive:(NSString *)filename
175176
{
176-
MTLog(@"%@", novel);
177+
MTLog(@"Cleaning %@", filename);
177178
dispatch_async(dispatch_get_main_queue(), ^{
178-
loadingVC.subtitleLabel.text = [NSString stringWithFormat:@"Decompressing sound from '%@'...", novel];
179+
loadingVC.subtitleLabel.text = [NSString stringWithFormat:@"Finishing extraction of %@...", filename];
180+
loadingVC.progressBar.progress = 1;
179181
[loadingVC.view setNeedsDisplay];
180182
});
181183
}

Controller/ScriptInterpreter.h

+11-3
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,15 @@
4949
- (void)forwardSelector:(SEL)selector withCommand:(Command *)cmd;
5050

5151
/**
52-
* Jumps to the specified line number
52+
* Jumps to the specified command number
5353
*/
54-
- (void)jumpToPosition:(NSInteger)position;
54+
- (void)gotoPosition:(NSInteger)position;
55+
- (void)gotoLabel:(NSString *)label;
5556

5657
/**
5758
* Jumps to the specified file and position
5859
*/
59-
- (void)jumpToScript:(NSString *)script position:(NSInteger)position;
60+
- (void)jumpToScript:(NSString *)script label:(NSString *)label;
6061

6162
/**
6263
* Evaluates an IF-type command, and returns werther it's true or false
@@ -68,4 +69,11 @@
6869
*/
6970
- (void)saveLoaded:(Save *)save;
7071

72+
#if TARGET_IPHONE_SIMULATOR
73+
/**
74+
* Output a Debug Message in the text log
75+
*/
76+
- (void)debugLog:(NSString *)string;
77+
#endif
78+
7179
@end

0 commit comments

Comments
 (0)