Skip to content

Commit e35a093

Browse files
whiteblXKwhiteblXK
authored andcommitted
punkice3407#7, added feature to remove frame groups from new outfits, fixes...
1 parent 301aecd commit e35a093

7 files changed

Lines changed: 129 additions & 38 deletions

File tree

src/ObjectBuilderWorker.as

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -818,9 +818,9 @@ package
818818
for (var i:uint = 0; i < length; i++) {
819819
var thingData:ThingData = list[i];
820820
if(_frameGroups && thingData.obdVersion < OBDVersions.OBD_VERSION_3)
821-
ThingUtils.convertFrameGroups(thingData, ThingUtils.ADD_FRAME_GROUPS, _improvedAnimations, _settings.getDefaultDuration(thingData.category));
821+
ThingUtils.convertFrameGroups(thingData, ThingUtils.ADD_FRAME_GROUPS, _improvedAnimations, _settings.getDefaultDuration(thingData.category), _version.value < 870);
822822
else if (!_frameGroups && thingData.obdVersion >= OBDVersions.OBD_VERSION_3)
823-
ThingUtils.convertFrameGroups(thingData, ThingUtils.REMOVE_FRAME_GROUPS, _improvedAnimations, _settings.getDefaultDuration(thingData.category));
823+
ThingUtils.convertFrameGroups(thingData, ThingUtils.REMOVE_FRAME_GROUPS, _improvedAnimations, _settings.getDefaultDuration(thingData.category), _version.value < 870);
824824

825825
var thing:ThingType = thingData.thing;
826826
for (var groupType:uint = FrameGroupType.DEFAULT; groupType <= FrameGroupType.WALKING; groupType++)
@@ -958,9 +958,9 @@ package
958958
for (var i:uint = 0; i < length; i++) {
959959
var thingData:ThingData = list[i];
960960
if(_frameGroups && thingData.obdVersion < OBDVersions.OBD_VERSION_3)
961-
ThingUtils.convertFrameGroups(thingData, ThingUtils.ADD_FRAME_GROUPS, _improvedAnimations, _settings.getDefaultDuration(thingData.category));
961+
ThingUtils.convertFrameGroups(thingData, ThingUtils.ADD_FRAME_GROUPS, _improvedAnimations, _settings.getDefaultDuration(thingData.category), _version.value < 870);
962962
else if (!_frameGroups && thingData.obdVersion >= OBDVersions.OBD_VERSION_3)
963-
ThingUtils.convertFrameGroups(thingData, ThingUtils.REMOVE_FRAME_GROUPS, _improvedAnimations, _settings.getDefaultDuration(thingData.category));
963+
ThingUtils.convertFrameGroups(thingData, ThingUtils.REMOVE_FRAME_GROUPS, _improvedAnimations, _settings.getDefaultDuration(thingData.category), _version.value < 870);
964964

965965
var thing:ThingType = thingData.thing;
966966
for (var groupType:uint = FrameGroupType.DEFAULT; groupType <= FrameGroupType.WALKING; groupType++)

src/ob/components/CompileAssetsWindow.mxml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,6 @@ THE SOFTWARE.
222222
if (done) {
223223
m_extended = (m_extended || m_version.value >= 960);
224224
m_improvedAnimations = (m_improvedAnimations || m_version.value >= 1050);
225-
m_frameGroups = (m_frameGroups || m_version.value >= 1057);
226-
227225
extendedCheckBox.enabled = (m_version.value < 960);
228226
transparencyCheckBox.enabled = true;
229227
improvedAnimationsCheckBox.enabled = (m_version.value < 1050);

src/ob/components/FrameGroupsConverterWindow.mxml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,16 @@ THE SOFTWARE.
5151
//--------------------------------------------------------------------------
5252
5353
private var m_application:IObjectBuilder;
54+
private var m_communicator:IWorkerCommunicator;
5455
5556
[Bindable]
5657
private var m_frameGroups:Boolean;
5758
5859
[Bindable]
5960
private var m_inProgress:Boolean;
6061
61-
private var m_communicator:IWorkerCommunicator;
62+
[Bindable]
63+
private var m_version:uint;
6264
6365
//--------------------------------------
6466
// Getters / Setters
@@ -110,6 +112,7 @@ THE SOFTWARE.
110112
{
111113
m_application = FlexGlobals.topLevelApplication as IObjectBuilder;
112114
m_frameGroups = m_application.clientInfo.frameGroups;
115+
m_version = m_application.version.value;
113116
}
114117
115118
private function closingHandler(event:Event):void
@@ -145,7 +148,7 @@ THE SOFTWARE.
145148
</mg:layout>
146149

147150
<s:CheckBox id="frameGroupsCheckBox" width="100%" label="@Resource(key='addRemoveFrameGroups', bundle='strings')" selected="{!m_frameGroups}"/>
148-
<s:CheckBox id="mountsCheckBox" width="100%" label="@Resource(key='removeMounts', bundle='strings')"/>
151+
<s:CheckBox id="mountsCheckBox" width="100%" label="@Resource(key='removeMounts', bundle='strings')" enabled="{m_version >= 870}"/>
149152

150153
</mg:GroupBox>
151154

src/otlib/things/ThingData.as

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -549,20 +549,15 @@ package otlib.things
549549
var spritesGroup:Dictionary = new Dictionary();
550550
for (var groupType:uint = FrameGroupType.DEFAULT; groupType <= FrameGroupType.WALKING; groupType++)
551551
{
552-
var frameGroup:FrameGroup = this.m_thing.getFrameGroup(groupType);
552+
var frameGroup:FrameGroup = m_thing.getFrameGroup(groupType);
553553
if(!frameGroup)
554554
continue;
555555

556556
var _length:uint = frameGroup.spriteIndex.length;
557557
spritesGroup[groupType] = new Vector.<SpriteData>(_length, true);
558558

559-
var sprites:Vector.<SpriteData> = this.sprites[FrameGroupType.DEFAULT];
560-
for (var sprite:uint = 0; sprite < sprites.length; sprite++)
559+
for each (var spriteData:SpriteData in m_sprites[FrameGroupType.DEFAULT])
561560
{
562-
var spriteData:SpriteData = sprites[sprite];
563-
if(!spriteData)
564-
continue;
565-
566561
for (var index:uint = 0; index < _length; index++)
567562
{
568563
var spriteIndex:uint = frameGroup.spriteIndex[index];
@@ -572,9 +567,34 @@ package otlib.things
572567
}
573568
}
574569

575-
this.m_sprites = spritesGroup;
570+
m_sprites = spritesGroup;
576571
}
577572

573+
public function removeFrameGroupSprites():void
574+
{
575+
var spritesGroup:Dictionary = new Dictionary();
576+
var frameGroup:FrameGroup = m_thing.getFrameGroup(FrameGroupType.DEFAULT);
577+
if(!frameGroup)
578+
return;
579+
580+
var _length:uint = frameGroup.spriteIndex.length;
581+
spritesGroup[FrameGroupType.DEFAULT] = new Vector.<SpriteData>(_length, true);
582+
583+
for (var groupType:uint = FrameGroupType.DEFAULT; groupType <= FrameGroupType.WALKING; groupType++)
584+
{
585+
for each (var spriteData:SpriteData in m_sprites[groupType])
586+
{
587+
for (var index:uint = 0; index < _length; index++)
588+
{
589+
if(frameGroup.spriteIndex[index] == spriteData.id)
590+
spritesGroup[FrameGroupType.DEFAULT][index] = spriteData.clone();
591+
}
592+
}
593+
}
594+
595+
m_sprites = spritesGroup;
596+
}
597+
578598
//--------------------------------------------------------------------------
579599
// STATIC
580600
//--------------------------------------------------------------------------

src/otlib/things/ThingType.as

Lines changed: 84 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ package otlib.things
3333
import otlib.things.FrameGroupType;
3434
import ob.core.IObjectBuilder;
3535
import mx.core.FlexGlobals;
36+
import otlib.utils.SpriteExtent;
37+
import flash.utils.Dictionary;
3638

3739
public class ThingType
3840
{
@@ -171,12 +173,10 @@ package otlib.things
171173

172174
public function addFrameGroupState(improvedAnimations:Boolean, duration:uint):void
173175
{
174-
var normal:FrameGroup = this.getFrameGroup(FrameGroupType.DEFAULT);
176+
var normal:FrameGroup = getFrameGroup(FrameGroupType.DEFAULT);
175177
if(!normal || normal.frames < 3)
176178
return;
177179

178-
var frameId:uint;
179-
180180
var idle:FrameGroup = normal.clone();
181181
idle.frames = 1;
182182

@@ -201,25 +201,98 @@ package otlib.things
201201
walking.loopCount = 0;
202202
walking.startFrame = 0;
203203

204-
for (frameId = 0; frameId < walking.frames; frameId++) {
204+
for (var frameId:uint = 0; frameId < walking.frames; frameId++) {
205205
if (improvedAnimations && normal.frameDurations[frameId])
206206
walking.frameDurations[frameId] = normal.frameDurations[frameId].clone();
207207
else
208208
walking.frameDurations[frameId] = new FrameDuration(duration, duration);
209209
}
210210

211-
this.setFrameGroup(FrameGroupType.DEFAULT, idle);
212-
this.setFrameGroup(FrameGroupType.WALKING, walking);
211+
setFrameGroup(FrameGroupType.DEFAULT, idle);
212+
setFrameGroup(FrameGroupType.WALKING, walking);
213+
}
214+
215+
private function countSpritesInFrame(frameGroup:FrameGroup, frame:uint):uint
216+
{
217+
var sprites:uint = 0;
218+
for (var z:uint = 0; z < frameGroup.patternZ; z++)
219+
{
220+
for (var y:uint = 0; y < frameGroup.patternY; y++)
221+
{
222+
for (var x:uint = 0; x < frameGroup.patternX; x++)
223+
{
224+
for (var l:uint = 0; l < frameGroup.layers; l++)
225+
{
226+
for (var w:uint = 0; w < frameGroup.width; w++)
227+
{
228+
for (var h:uint = 0; h < frameGroup.height; h++)
229+
sprites++;
230+
}
231+
}
232+
}
233+
}
234+
}
235+
236+
return sprites;
213237
}
214238

215-
public function removeFrameGroupState(improvedAnimations:Boolean, duration:uint):void
239+
public function removeFrameGroupState(improvedAnimations:Boolean, duration:uint, removeMounts:Boolean):void
216240
{
217-
var idle:FrameGroup = this.getFrameGroup(FrameGroupType.DEFAULT);
218-
var walking:FrameGroup = this.getFrameGroup(FrameGroupType.WALKING);
219-
if(!idle || !walking)
241+
var idle:FrameGroup = getFrameGroup(FrameGroupType.DEFAULT);
242+
var walking:FrameGroup = getFrameGroup(FrameGroupType.WALKING);
243+
if(!normal && !walking)
220244
return;
245+
246+
if (removeMounts)
247+
{
248+
idle.patternZ = 1
249+
walking.patternZ = 1
250+
}
251+
252+
var normal:FrameGroup = idle.clone();
253+
normal.frames = 3;
254+
255+
var spriteIndex:Vector.<uint> = new Vector.<uint>();
221256

222-
//TODO
257+
var frameSpriteLength:uint = countSpritesInFrame(idle, 0);
258+
for (var spriteId:uint = 0; spriteId < frameSpriteLength; spriteId++)
259+
spriteIndex.push(idle.spriteIndex[spriteId])
260+
261+
for (spriteId = 0; spriteId < frameSpriteLength; spriteId++)
262+
spriteIndex.push(walking.spriteIndex[spriteId])
263+
264+
var walkingFramesLength:uint = walking.spriteIndex.length
265+
if (walkingFramesLength > frameSpriteLength * 4)
266+
{
267+
// Check for fourth frame in walking
268+
for (spriteId = frameSpriteLength * 4; spriteId < (frameSpriteLength * 4) + frameSpriteLength; spriteId++)
269+
spriteIndex.push(walking.spriteIndex[spriteId])
270+
}
271+
else if (walkingFramesLength > frameSpriteLength)
272+
{
273+
// Check for second frame in walking
274+
for (spriteId = frameSpriteLength; spriteId < frameSpriteLength + frameSpriteLength; spriteId++)
275+
spriteIndex.push(walking.spriteIndex[spriteId])
276+
}
277+
else
278+
{
279+
// Add first frame in walking
280+
for (spriteId = 0; spriteId < frameSpriteLength; spriteId++)
281+
spriteIndex.push(walking.spriteIndex[spriteId])
282+
}
283+
284+
normal.spriteIndex = spriteIndex;
285+
normal.isAnimation = true;
286+
normal.frameDurations = new Vector.<FrameDuration>(normal.frames, true);
287+
normal.animationMode = AnimationMode.ASYNCHRONOUS;
288+
normal.loopCount = 0;
289+
normal.startFrame = 0;
290+
291+
for (var frameId:uint = 0; frameId < normal.frames; frameId++)
292+
normal.frameDurations[frameId] = new FrameDuration(duration, duration);
293+
294+
frameGroups = [];
295+
frameGroups[FrameGroupType.DEFAULT] = normal;
223296
}
224297

225298
//--------------------------------------------------------------------------

src/otlib/utils/FrameGroupsConverter.as

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ package otlib.utils
6262
private var m_sprites:SpriteStorage;
6363
private var m_finished:Boolean;
6464
private var m_frameGroups:Boolean;
65-
private var m_mounts:Boolean;
65+
private var m_removeMounts:Boolean;
6666
private var m_clientVersion:uint;
6767
private var m_improvedAnimations:Boolean;
6868
private var m_defaultDuration:uint;
@@ -72,15 +72,15 @@ package otlib.utils
7272
// CONSTRUCTOR
7373
//--------------------------------------------------------------------------
7474

75-
public function FrameGroupsConverter(objects:ThingTypeStorage, sprites:SpriteStorage, frameGroups:Boolean, mounts:Boolean, clientVersion:uint, improvedAnimations:Boolean, duration:uint)
75+
public function FrameGroupsConverter(objects:ThingTypeStorage, sprites:SpriteStorage, frameGroups:Boolean, removeMounts:Boolean, clientVersion:uint, improvedAnimations:Boolean, duration:uint)
7676
{
7777
if (!objects)
7878
throw new NullArgumentError("objects");
7979

8080
m_objects = objects;
8181
m_sprites = sprites;
8282
m_frameGroups = frameGroups;
83-
m_mounts = mounts;
83+
m_removeMounts = removeMounts;
8484
m_clientVersion = clientVersion;
8585
m_improvedAnimations = improvedAnimations;
8686
m_defaultDuration = duration
@@ -113,7 +113,7 @@ package otlib.utils
113113
if (m_frameGroups)
114114
frameGroups = ThingUtils.ADD_FRAME_GROUPS;
115115

116-
ThingUtils.convertFrameGroups(thingData, frameGroups, m_improvedAnimations, m_defaultDuration);
116+
ThingUtils.convertFrameGroups(thingData, frameGroups, m_improvedAnimations, m_defaultDuration, m_removeMounts);
117117
}
118118
}
119119

src/otlib/utils/ThingUtils.as

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,19 +98,18 @@ package otlib.utils
9898
return false;
9999
}
100100

101-
public static function convertFrameGroups(thingData:ThingData, frameGroups:uint, improvedAnimations:Boolean, duration:uint):void
101+
public static function convertFrameGroups(thingData:ThingData, frameGroups:uint, improvedAnimations:Boolean, duration:uint, removeMounts:Boolean):void
102102
{
103103
if(thingData.thing.animateAlways || thingData.category != ThingCategory.OUTFIT)
104104
return;
105105

106106
if (frameGroups == REMOVE_FRAME_GROUPS)
107107
{
108108
if(thingData.thing.frameGroups.length <= 1)
109-
return;
109+
return;
110110

111-
//thingData.thing.removeFrameGroupState(improvedAnimations, duration);
112-
//this.removeFrameGroupSprites();
113-
trace("removeFrameGroups TODO")
111+
thingData.thing.removeFrameGroupState(improvedAnimations, duration, removeMounts);
112+
thingData.removeFrameGroupSprites();
114113
}
115114
else if (frameGroups == ADD_FRAME_GROUPS)
116115
{
@@ -119,8 +118,6 @@ package otlib.utils
119118

120119
thingData.thing.addFrameGroupState(improvedAnimations, duration);
121120
thingData.addFrameGroupSprites();
122-
123-
trace("addFrameGroup")
124121
}
125122

126123
return;

0 commit comments

Comments
 (0)