Skip to content

Commit

Permalink
OBD v3 should be available only for outfits with frame groups, change…
Browse files Browse the repository at this point in the history
…d extra name for exporting obd files, version 0.5.1
  • Loading branch information
whiteblXK committed Mar 24, 2021
1 parent e6ce1a8 commit 42bf2df
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 64 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
### 0.5.1

Features:

* Better extra name for exporting OBD

Bug Fixes:

* Client without frame groups will not be able to use new OBD v3

### 0.5.0

Features:
Expand Down
3 changes: 3 additions & 0 deletions locale/en_US/strings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,9 @@ spriteCannotBeReplaced=Sprite 0 cannot be replaced.
accessDenied=You don't have the permission to save in selected folder. Please select another folder.
folderNotExistOrCannotBeRead=The specified folder does not exist or cannot be read.
selectAClientFolder=Select a folder containing the asset files.
cannotImportThingFrameGroup=Cannot import thing into client without frame groups.
cannotReplaceThingFrameGroup=Cannot replace thing in client without frame groups.


# Licence
licence=THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\
Expand Down
2 changes: 2 additions & 0 deletions locale/es_ES/strings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,8 @@ spriteCannotBeReplaced=Sprite 0 no puede ser reemplazado.
accessDenied=No tienes permiso para guardar en la carpeta seleccionada. Por favor seleccione otra carpeta.
folderNotExistOrCannotBeRead=El carpeta que eligio no existe o no se puede leer.
selectAClientFolder=Seleccione un carpeta que contenga archivos del cliente.
cannotImportThingFrameGroup=No se puede importar algo en el cliente sin grupos de marcos.
cannotReplaceThingFrameGroup=No se puede reemplazar algo en el cliente sin grupos de marcos.

# Licence
licence=THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\
Expand Down
2 changes: 2 additions & 0 deletions locale/pt_BR/strings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,8 @@ spriteCannotBeReplaced=Sprite 0 cannot be replaced.
accessDenied=Você não tem permissão para salvar na pasta selecionada. Por favor, selecione outra pasta.
folderNotExistOrCannotBeRead=A pasta especificada não existe ou não pode ser lida.
selectAClientFolder=Selecione uma pasta contendo os arquivos do cliente.
cannotImportThingFrameGroup=Não é possível importar coisas para o cliente sem grupos de quadros.
cannotReplaceThingFrameGroup=Não é possível substituir coisa no cliente sem grupos de quadros.

# Licence
licence=THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\
Expand Down
4 changes: 2 additions & 2 deletions src/ObjectBuilder-app.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<id>com.mignari.ObjectBuilder</id>
<filename>ObjectBuilder</filename>
<name>Object Builder</name>
<versionNumber>0.5.0</versionNumber>
<versionLabel>0.5.0</versionLabel>
<versionNumber>0.5.1</versionNumber>
<versionLabel>0.5.1</versionLabel>
<copyright>
<![CDATA[Copyright (c) 2014-2021 <a href="https://github.com/Mignari/ObjectBuilder/graphs/contributors">Contributors</a>]]>
</copyright>
Expand Down
9 changes: 5 additions & 4 deletions src/ObjectBuilder.mxml
Original file line number Diff line number Diff line change
Expand Up @@ -1181,16 +1181,16 @@ THE SOFTWARE.
var queue:FileQueueHelper = new FileQueueHelper();
queue.parent = this;
queue.addEventListener(Event.COMPLETE, completeHandler);
var changeName:Boolean = (fileName.indexOf("_") == -1);
var versionName:String = "";
var extra:String = "";
if(format == OTFormat.OBD)
versionName = "-v" + obdVersion.toString().substring(0, 1);
extra = "-" + clientVersion.toString() + "-v" + obdVersion.toString().substring(0, 1);
var length:uint = things.length;
for (var i:uint = 0; i < length; i++) {
var id:uint = things[i].id;
var name:String = !changeName ? fileName : (name = fileName + "_" + id) + versionName;
var name:String = fileName + "_" + id.toString() + extra.replace(" ", "").replace(".", "");
queue.addFile(id, name, format, directory);
}
queue.start();
Expand Down Expand Up @@ -1830,6 +1830,7 @@ THE SOFTWARE.
window.version = version;
window.transparentBackground = _settings.exportWithTransparentBackground;
window.jpegQuality = _settings.jpegQuality;
window.obdV3 = thingData.category == ThingCategory.OUTFIT && _clientInfo.frameGroups;
window.addEventListener(Event.CLOSE, windowCloseHandler);
window.open(this);
Expand Down
51 changes: 42 additions & 9 deletions src/ObjectBuilderWorker.as
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,9 @@ package
if(thingData)
{
_things.dispatchEvent(new ProgressEvent(ProgressEvent.CONVERT, ProgressBarID.CONVERT, thingType.id, _things.outfitsCount));
thingData.convertFrameGroups(improvedAnimations, frameGroups);

if(frameGroups)
thingData.convertFrameGroups(improvedAnimations);
}
}
}
Expand Down Expand Up @@ -777,6 +779,7 @@ package
throw new NullArgumentError("list");
}

var denyIds:Dictionary = new Dictionary();
var length:uint = list.length;
if (length == 0) return;

Expand All @@ -787,7 +790,16 @@ package
var spritesIds:Vector.<uint> = new Vector.<uint>();
for (var i:uint = 0; i < length; i++) {
var thingData:ThingData = list[i];
thingData.convertFrameGroups(_improvedAnimations, _frameGroups);

if(!_frameGroups && thingData.obdVersion == OBDVersions.OBD_VERSION_3)
{
denyIds[i] = true;
Log.error(Resources.getString("cannotReplaceThingFrameGroup"));
continue;
}

if(_frameGroups)
thingData.convertFrameGroups(_improvedAnimations);

var thing:ThingType = thingData.thing;
for (var groupType:uint = FrameGroupType.DEFAULT; groupType <= FrameGroupType.WALKING; groupType++)
Expand Down Expand Up @@ -821,12 +833,19 @@ package
//============================================================================
// Replace things

var thingsToReplace:Vector.<ThingType> = new Vector.<ThingType>(length, true);
var thingsIds:Vector.<uint> = new Vector.<uint>(length, true);
var thingsToReplace:Vector.<ThingType> = new Vector.<ThingType>();
var thingsIds:Vector.<uint> = new Vector.<uint>();
for (i = 0; i < length; i++) {
thingsToReplace[i] = list[i].thing;
thingsIds[i] = list[i].id;
if(!denyIds[i])
{
thingsToReplace[thingsToReplace.length] = list[i].thing;
thingsIds[thingsIds.length] = list[i].id;
}
}

if(thingsToReplace.length == 0)
return;

result = _things.replaceThings(thingsToReplace);
if (!result.done) {
Log.error(result.message);
Expand Down Expand Up @@ -906,6 +925,7 @@ package
throw new NullArgumentError("list");
}

var denyIds:Dictionary = new Dictionary();
var length:uint = list.length;
if (length == 0) return;

Expand All @@ -916,7 +936,15 @@ package
var spritesIds:Vector.<uint> = new Vector.<uint>();
for (var i:uint = 0; i < length; i++) {
var thingData:ThingData = list[i];
thingData.convertFrameGroups(_improvedAnimations, _frameGroups);
if(!_frameGroups && thingData.obdVersion == OBDVersions.OBD_VERSION_3)
{
denyIds[i] = true;
Log.error(Resources.getString("cannotImportThingFrameGroup"));
continue;
}

if(_frameGroups)
thingData.convertFrameGroups(_improvedAnimations);

var thing:ThingType = thingData.thing;
for (var groupType:uint = FrameGroupType.DEFAULT; groupType <= FrameGroupType.WALKING; groupType++)
Expand Down Expand Up @@ -950,10 +978,15 @@ package
//============================================================================
// Add things

var thingsToAdd:Vector.<ThingType> = new Vector.<ThingType>(length, true);
var thingsToAdd:Vector.<ThingType> = new Vector.<ThingType>();
for (i = 0; i < length; i++) {
thingsToAdd[i] = list[i].thing;
if(!denyIds[i])
thingsToAdd[thingsToAdd.length] = list[i].thing;
}

if(thingsToAdd.length == 0)
return;

result = _things.addThings(thingsToAdd);
if (!result.done) {
Log.error(result.message);
Expand Down
58 changes: 27 additions & 31 deletions src/otlib/components/ExportWindow.mxml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ THE SOFTWARE.
height="270"
fontSize="11"
title="@Resource(key='export', bundle='strings')"
preinitialize="preinitializeHandler(event)">
preinitialize="preinitializeHandler(event)"
creationComplete="creationCompleteHandler(event)">

<fx:Metadata>
[ResourceBundle("strings")]
Expand All @@ -45,16 +46,16 @@ THE SOFTWARE.
<![CDATA[
import com.mignari.skins.PixeledBorderContainerSkin;
import com.mignari.utils.DialogDetail;
import mx.collections.ArrayCollection;
import mx.events.FlexEvent;
import spark.events.IndexChangeEvent;
import spark.events.TextOperationEvent;
import nail.image.ImageFormat;
import nail.utils.isNullOrEmpty;
import otlib.core.Version;
import otlib.core.VersionStorage;
import otlib.events.FileTextInputEvent;
Expand All @@ -71,8 +72,12 @@ THE SOFTWARE.
[Bindable]
public var jpegQuality:Number = 100;
[Bindable]
public var obdV3:Boolean = false;
[Bindable]
private var _versionCollection:ArrayCollection;
private var _obdVersionCollection:ArrayCollection;
private var _fileName:String;
private var _fileNameChanged:Boolean;
private var _directory:File;
Expand All @@ -83,7 +88,7 @@ THE SOFTWARE.
private var _enableObdFormatChanged:Boolean;
private var _version:Version;
private var _versionChanged:Boolean;
private var _obdVersion:uint = OBDVersions.OBD_VERSION_3;
private var _obdVersion:uint;
private var _obdVersionChanged:Boolean;
private var _detail:uint;
Expand Down Expand Up @@ -151,7 +156,6 @@ THE SOFTWARE.
{
if (_obdVersion != value) {
_obdVersion = value;
_obdVersionChanged = true;
invalidateProperties();
}
}
Expand Down Expand Up @@ -199,17 +203,6 @@ THE SOFTWARE.
_versionChanged = false;
check();
}
if (_obdVersionChanged) {
if (_obdVersion == OBDVersions.OBD_VERSION_3)
obdVersionDropDownList.selectedIndex = 0;
else if (_obdVersion == OBDVersions.OBD_VERSION_2)
obdVersionDropDownList.selectedIndex = 1;
else if (_obdVersion == OBDVersions.OBD_VERSION_1)
obdVersionDropDownList.selectedIndex = 2;
_obdVersionChanged = false;
}
}
//--------------------------------------
Expand Down Expand Up @@ -255,6 +248,19 @@ THE SOFTWARE.
_versionCollection = new ArrayCollection( VersionStorage.getInstance().getList() );
}
protected function creationCompleteHandler(event:FlexEvent):void
{
_obdVersionCollection = new ArrayCollection();
if(obdV3)
_obdVersionCollection.addItem({label: "v3", version: OBDVersions.OBD_VERSION_3});
_obdVersionCollection.addItem({label: "v2", version: OBDVersions.OBD_VERSION_2});
_obdVersionCollection.addItem({label: "v1", version: OBDVersions.OBD_VERSION_1});
obdVersionDropDownList.dataProvider = _obdVersionCollection;
obdVersion = obdV3 ? OBDVersions.OBD_VERSION_3 : OBDVersions.OBD_VERSION_2;
}
protected function nameTextInputChangeHandler(event:TextOperationEvent):void
{
fileName = nameTextInput.text;
Expand Down Expand Up @@ -290,12 +296,9 @@ THE SOFTWARE.
protected function obdVersionDropDownListChangeHandler(event:IndexChangeEvent):void
{
if (obdVersionDropDownList.selectedIndex == 0)
obdVersion = OBDVersions.OBD_VERSION_3;
else if (obdVersionDropDownList.selectedIndex == 1)
obdVersion = OBDVersions.OBD_VERSION_2;
else if (obdVersionDropDownList.selectedIndex == 2)
obdVersion = OBDVersions.OBD_VERSION_1;
obdVersion = obdVersionDropDownList.selectedItem.version;
trace(obdVersion);
}
protected function confirmButtonClickHandler(event:MouseEvent):void
Expand Down Expand Up @@ -419,13 +422,6 @@ THE SOFTWARE.
requireSelection="true"
enabled="{obdFormatRadioButton.selected}"
change="obdVersionDropDownListChangeHandler(event)">
<s:dataProvider>
<s:ArrayList>
<fx:String>3</fx:String>
<fx:String>2</fx:String>
<fx:String>1</fx:String>
</s:ArrayList>
</s:dataProvider>
</s:DropDownList>
</s:NavigatorContent>
</mx:ViewStack>
Expand Down
23 changes: 5 additions & 18 deletions src/otlib/things/ThingData.as
Original file line number Diff line number Diff line change
Expand Up @@ -569,29 +569,16 @@ package otlib.things
this.m_sprites = spritesGroup;
}

public function convertFrameGroups(improvedAnimations:Boolean, frameGroups:Boolean):void
public function convertFrameGroups(improvedAnimations:Boolean):void
{
if(this.m_thing.animateAlways || this.category != ThingCategory.OUTFIT)
return;

if(frameGroups)
{
if(this.m_thing.frameGroups.length > 1)
return;

this.m_thing.addFrameGroupState(improvedAnimations);
this.addFrameGroupSprites();
}
else
{
if(this.m_thing.frameGroups.length < 2)
return;

//TODO remove frame groups
//this.m_thing.removeFrameGroupState(improvedAnimations);
//this.removeFrameGroupSprites();
}
if(this.m_thing.frameGroups.length > 1)
return;

this.m_thing.addFrameGroupState(improvedAnimations);
this.addFrameGroupSprites();
return;
}

Expand Down
6 changes: 6 additions & 0 deletions src/otlib/things/ThingTypeStorage.as
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,9 @@ package otlib.things

for (var i:uint = 0; i < length; i++) {
var thing:ThingType = things[i];
if(!thing)
continue;

var added:ChangeResult = internalAddThing(thing, thing.category, CHANGE_RESULT_HELPER);
if (!added.done) {
var message:String = Resources.getString(
Expand Down Expand Up @@ -798,6 +801,9 @@ package otlib.things

for (var i:uint = 0; i < length; i++) {
var thing:ThingType = things[i];
if(!thing)
continue;

var replaced:ChangeResult = internalReplaceThing(thing,
thing.category,
thing.id,
Expand Down

0 comments on commit 42bf2df

Please sign in to comment.