├── .github └── workflows │ └── maven.yml ├── .gitignore ├── LICENSE ├── README.md ├── lib ├── cwlib-gl │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── cwlib │ │ │ └── gl │ │ │ ├── RenderJob.java │ │ │ ├── RenderJobManager.java │ │ │ ├── exporter │ │ │ └── SceneExporter.java │ │ │ ├── jobs │ │ │ ├── DecalBaker.java │ │ │ ├── MaterialBaker.java │ │ │ └── MultiMaterialBaker.java │ │ │ └── objects │ │ │ ├── GlProgram.java │ │ │ └── GlTexture.java │ │ └── resources │ │ └── shaders │ │ ├── bake.vs │ │ ├── decal.fs │ │ ├── decal.vs │ │ └── templates │ │ └── glsl │ │ ├── alphabake.fs │ │ └── bake.fs └── cwlib │ ├── README.md │ ├── pom.xml │ └── src │ └── main │ ├── java │ └── cwlib │ │ ├── CwlibConfiguration.java │ │ ├── enums │ │ ├── ArchiveType.java │ │ ├── AudioMaterial.java │ │ ├── BoneFlag.java │ │ ├── BoxType.java │ │ ├── Branch.java │ │ ├── BrdfPort.java │ │ ├── BuiltinType.java │ │ ├── CacheFlags.java │ │ ├── CameraType.java │ │ ├── CellGcmEnumForGtf.java │ │ ├── CellGcmPrimitive.java │ │ ├── CollideType.java │ │ ├── CommonMeshes.java │ │ ├── CompressionFlags.java │ │ ├── ContentsType.java │ │ ├── CostumePieceCategory.java │ │ ├── Crater.java │ │ ├── CurveType.java │ │ ├── DLCFileFlags.java │ │ ├── DatabaseType.java │ │ ├── DecalType.java │ │ ├── EnemyPart.java │ │ ├── FlipType.java │ │ ├── FunctionType.java │ │ ├── GameMode.java │ │ ├── GameProgressionStatus.java │ │ ├── GameShader.java │ │ ├── GameVersion.java │ │ ├── GameplayPartType.java │ │ ├── GfxMaterialFlags.java │ │ ├── GroupFlags.java │ │ ├── HairMorph.java │ │ ├── InstructionClass.java │ │ ├── InstructionType.java │ │ ├── InventoryItemFlags.java │ │ ├── InventoryObjectSubType.java │ │ ├── InventoryObjectType.java │ │ ├── InventorySortMode.java │ │ ├── LethalType.java │ │ ├── LevelType.java │ │ ├── MachineType.java │ │ ├── MappingMode.java │ │ ├── MaterialFlags.java │ │ ├── ModCompatibility.java │ │ ├── ModifierType.java │ │ ├── ParameterSubType.java │ │ ├── ParameterType.java │ │ ├── Part.java │ │ ├── PartHistory.java │ │ ├── PatchType.java │ │ ├── PlayMode.java │ │ ├── ResourceFlags.java │ │ ├── ResourceKeys.java │ │ ├── ResourceType.java │ │ ├── Revisions.java │ │ ├── ScriptObjectType.java │ │ ├── SerializationType.java │ │ ├── ShadowCastMode.java │ │ ├── ShadowType.java │ │ ├── ShapeFlags.java │ │ ├── SkeletonType.java │ │ ├── SlotType.java │ │ ├── State.java │ │ ├── SwitchBehavior.java │ │ ├── SwitchKeyType.java │ │ ├── SwitchLogicType.java │ │ ├── SwitchType.java │ │ ├── TextureType.java │ │ ├── TextureWrap.java │ │ ├── ToolType.java │ │ ├── TriggerType.java │ │ ├── TutorialLevel.java │ │ ├── TutorialState.java │ │ ├── VariableType.java │ │ └── VisibilityFlags.java │ │ ├── ex │ │ └── SerializationException.java │ │ ├── external │ │ └── DDSReader.java │ │ ├── io │ │ ├── FMOD.java │ │ ├── Resource.java │ │ ├── Serializable.java │ │ ├── ValueEnum.java │ │ ├── exports │ │ │ └── MeshExporter.java │ │ ├── gson │ │ │ ├── AudioMaterialSerializer.java │ │ │ ├── CreationHistorySerializer.java │ │ │ ├── FieldSerializer.java │ │ │ ├── GUIDSerializer.java │ │ │ ├── GsonResourceType.java │ │ │ ├── GsonRevision.java │ │ │ ├── GsonRevisions.java │ │ │ ├── Matrix4fSerializer.java │ │ │ ├── NetworkOnlineIDSerializer.java │ │ │ ├── NetworkPlayerIDSerializer.java │ │ │ ├── PatchSerializer.java │ │ │ ├── ResourceSerializer.java │ │ │ ├── SHA1Serializer.java │ │ │ ├── ScriptObjectSerializer.java │ │ │ ├── SlotIDSerializer.java │ │ │ ├── ThingSerializer.java │ │ │ ├── TranslationSerializer.java │ │ │ ├── TranslationTableSerializer.java │ │ │ ├── Vector2fSerializer.java │ │ │ ├── Vector3fSerializer.java │ │ │ ├── Vector4fSerializer.java │ │ │ └── WrappedResourceSerializer.java │ │ ├── imports │ │ │ ├── AnimationImporter.java │ │ │ └── ModelImporter.java │ │ ├── serializer │ │ │ ├── SerializationData.java │ │ │ └── Serializer.java │ │ └── streams │ │ │ ├── MemoryInputStream.java │ │ │ └── MemoryOutputStream.java │ │ ├── presets │ │ ├── PackPresets.java │ │ └── SlotPresets.java │ │ ├── resources │ │ ├── RAdventureCreateProfile.java │ │ ├── RAnimation.java │ │ ├── RBevel.java │ │ ├── RBigProfile.java │ │ ├── RDLC.java │ │ ├── RFontFace.java │ │ ├── RGfxMaterial.java │ │ ├── RGuidSubst.java │ │ ├── RInstrument.java │ │ ├── RJoint.java │ │ ├── RLevel.java │ │ ├── RLocalProfile.java │ │ ├── RMaterial.java │ │ ├── RMesh.java │ │ ├── RPacks.java │ │ ├── RPalette.java │ │ ├── RPins.java │ │ ├── RPlan.java │ │ ├── RQuest.java │ │ ├── RScript.java │ │ ├── RSlotList.java │ │ ├── RStaticMesh.java │ │ ├── RSyncedProfile.java │ │ ├── RTexture.java │ │ ├── RTranslationTable.java │ │ └── custom │ │ │ └── RBoneSet.java │ │ ├── singleton │ │ └── ResourceSystem.java │ │ ├── structs │ │ ├── adventure │ │ │ ├── PlanetArea.java │ │ │ └── SlotPhotoData.java │ │ ├── animation │ │ │ ├── AnimBone.java │ │ │ ├── AnimatedMorph.java │ │ │ └── Locator.java │ │ ├── bevel │ │ │ └── BevelVertex.java │ │ ├── custom │ │ │ └── Skeleton.java │ │ ├── dlc │ │ │ ├── DLCFile.java │ │ │ └── DLCGUID.java │ │ ├── font │ │ │ └── GlyphInfo.java │ │ ├── gmat │ │ │ ├── MaterialBox.java │ │ │ ├── MaterialParameterAnimation.java │ │ │ └── MaterialWire.java │ │ ├── instrument │ │ │ ├── Note.java │ │ │ └── Sample.java │ │ ├── inventory │ │ │ ├── ColorCorrection.java │ │ │ ├── CreationHistory.java │ │ │ ├── EyetoyData.java │ │ │ ├── InventoryItemDetails.java │ │ │ ├── InventoryItemPhotoData.java │ │ │ ├── PhotoMetadata.java │ │ │ ├── PhotoUser.java │ │ │ └── UserCreatedDetails.java │ │ ├── joint │ │ │ └── FCurve.java │ │ ├── level │ │ │ ├── AdventureData.java │ │ │ ├── AdventureItem.java │ │ │ ├── CachedInventoryData.java │ │ │ ├── PlayerRecord.java │ │ │ └── StartPoint.java │ │ ├── mesh │ │ │ ├── Bone.java │ │ │ ├── CullBone.java │ │ │ ├── ImplicitEllipsoid.java │ │ │ ├── ImplicitPlane.java │ │ │ ├── MeshShapeInfo.java │ │ │ ├── MeshShapeVertex.java │ │ │ ├── Morph.java │ │ │ ├── Primitive.java │ │ │ ├── SoftbodyCluster.java │ │ │ ├── SoftbodyClusterData.java │ │ │ ├── SoftbodySpring.java │ │ │ ├── SoftbodyVertEquivalence.java │ │ │ └── Submesh.java │ │ ├── profile │ │ │ ├── Challenge.java │ │ │ ├── CollectableData.java │ │ │ ├── CollectedBubble.java │ │ │ ├── DataLabel.java │ │ │ ├── DataLabelValue.java │ │ │ ├── GoPlayCache.java │ │ │ ├── InventoryCollection.java │ │ │ ├── InventoryItem.java │ │ │ ├── InventoryPage.java │ │ │ ├── InventoryView.java │ │ │ ├── LegacyInventoryCollection.java │ │ │ ├── MysteryPodEventSeen.java │ │ │ ├── PaintProperties.java │ │ │ ├── Pin.java │ │ │ ├── PinAward.java │ │ │ ├── PinProgress.java │ │ │ ├── PinsAwarded.java │ │ │ ├── PlayedLevelData.java │ │ │ ├── PlayerDataLabels.java │ │ │ ├── PlayerMetrics.java │ │ │ ├── SlotLink.java │ │ │ ├── SortString.java │ │ │ ├── StringLookupTable.java │ │ │ ├── Treasure.java │ │ │ ├── ViewedLevelData.java │ │ │ └── ViewedPlayerData.java │ │ ├── script │ │ │ ├── FieldDefinitionRow.java │ │ │ ├── FieldReferenceRow.java │ │ │ ├── FunctionDefinitionRow.java │ │ │ ├── FunctionReferenceRow.java │ │ │ ├── Instruction.java │ │ │ ├── LocalVariableDefinitionRow.java │ │ │ ├── PropertyDefinitionRow.java │ │ │ ├── TypeOffset.java │ │ │ ├── TypeReferenceRow.java │ │ │ └── instructions │ │ │ │ ├── ArgInstruction.java │ │ │ │ ├── BinaryInstruction.java │ │ │ │ ├── BranchInstruction.java │ │ │ │ ├── CallInstruction.java │ │ │ │ ├── CastInstruction.java │ │ │ │ ├── GetBuiltInMemberInstruction.java │ │ │ │ ├── GetElementInstruction.java │ │ │ │ ├── GetMemberInstruction.java │ │ │ │ ├── LoadConstInstruction.java │ │ │ │ ├── LoadConstInstructionBool.java │ │ │ │ ├── LoadConstInstructionChar.java │ │ │ │ ├── LoadConstInstructionFloat.java │ │ │ │ ├── LoadConstInstructionInt.java │ │ │ │ ├── LoadConstInstructionNullSafePtr.java │ │ │ │ ├── NewArrayInstruction.java │ │ │ │ ├── NewObjectInstruction.java │ │ │ │ ├── NopInstruction.java │ │ │ │ ├── ReturnInstruction.java │ │ │ │ ├── SetBuiltInMemberInstruction.java │ │ │ │ ├── SetElementInstruction.java │ │ │ │ ├── SetMemberInstruction.java │ │ │ │ ├── UnaryInstruction.java │ │ │ │ └── WriteInstruction.java │ │ ├── server │ │ │ ├── ServerPhotoData.java │ │ │ ├── ServerUserData.java │ │ │ └── SlotDescriptor.java │ │ ├── slot │ │ │ ├── Collectabubble.java │ │ │ ├── Label.java │ │ │ ├── Pack.java │ │ │ ├── Slot.java │ │ │ └── SlotID.java │ │ ├── staticmesh │ │ │ ├── StaticMeshInfo.java │ │ │ └── StaticPrimitive.java │ │ ├── streaming │ │ │ ├── ChunkFile.java │ │ │ ├── LevelData.java │ │ │ ├── QuestSwitch.java │ │ │ ├── QuestTracker.java │ │ │ ├── StreamingCheckpoint.java │ │ │ ├── StreamingID.java │ │ │ └── StreamingManager.java │ │ ├── texture │ │ │ └── CellGcmTexture.java │ │ └── things │ │ │ ├── Thing.java │ │ │ ├── components │ │ │ ├── CameraNode.java │ │ │ ├── CompactComponent.java │ │ │ ├── CostumePiece.java │ │ │ ├── Decoration.java │ │ │ ├── EggLink.java │ │ │ ├── EmittedObjectSource.java │ │ │ ├── GlobalThingDescriptor.java │ │ │ ├── HUDDecal.java │ │ │ ├── KeyLink.java │ │ │ ├── LevelSettings.java │ │ │ ├── RegionOverride.java │ │ │ ├── Value.java │ │ │ ├── decals │ │ │ │ ├── Decal.java │ │ │ │ └── PaintControlPoint.java │ │ │ ├── npc │ │ │ │ ├── ActingData.java │ │ │ │ ├── BehaviourAct.java │ │ │ │ ├── BehaviourBase.java │ │ │ │ ├── BehaviourFollow.java │ │ │ │ ├── Input.java │ │ │ │ ├── InputRecording.java │ │ │ │ ├── NpcBehavior.java │ │ │ │ ├── NpcJumpData.java │ │ │ │ ├── NpcJumpSolver.java │ │ │ │ └── NpcMoveCmd.java │ │ │ ├── poppet │ │ │ │ ├── DecorationInfo.java │ │ │ │ ├── ObjectState.java │ │ │ │ ├── PlacementBodyState.java │ │ │ │ ├── Poppet.java │ │ │ │ ├── PoppetEditState.java │ │ │ │ ├── PoppetMaterialOverride.java │ │ │ │ ├── PoppetMode.java │ │ │ │ ├── PoppetShapeOverride.java │ │ │ │ ├── PoppetTweakObjectPlacement.java │ │ │ │ ├── RaycastResults.java │ │ │ │ └── StickerInfo.java │ │ │ ├── script │ │ │ │ ├── FieldLayoutDetails.java │ │ │ │ ├── InstanceLayout.java │ │ │ │ ├── ScriptInstance.java │ │ │ │ └── ScriptObject.java │ │ │ ├── shapes │ │ │ │ ├── Contact.java │ │ │ │ ├── ContactCache.java │ │ │ │ └── Polygon.java │ │ │ ├── switches │ │ │ │ ├── SwitchOutput.java │ │ │ │ ├── SwitchSignal.java │ │ │ │ └── SwitchTarget.java │ │ │ └── world │ │ │ │ ├── BroadcastMicrochipEntry.java │ │ │ │ ├── CameraSettings.java │ │ │ │ ├── CutsceneCameraManager.java │ │ │ │ ├── EditorSelection.java │ │ │ │ ├── GameCamera.java │ │ │ │ ├── GlobalAudioSettings.java │ │ │ │ ├── GlobalSettings.java │ │ │ │ └── MoveCursor.java │ │ │ └── parts │ │ │ ├── PAnimation.java │ │ │ ├── PAnimationTweak.java │ │ │ ├── PAtmosphericTweak.java │ │ │ ├── PAudioWorld.java │ │ │ ├── PBody.java │ │ │ ├── PCameraTweak.java │ │ │ ├── PCheckpoint.java │ │ │ ├── PConnectorHook.java │ │ │ ├── PControlinator.java │ │ │ ├── PCostume.java │ │ │ ├── PCreature.java │ │ │ ├── PDecorations.java │ │ │ ├── PEffector.java │ │ │ ├── PEmitter.java │ │ │ ├── PEnemy.java │ │ │ ├── PFader.java │ │ │ ├── PGameplayData.java │ │ │ ├── PGeneratedMesh.java │ │ │ ├── PGroup.java │ │ │ ├── PHudElem.java │ │ │ ├── PInstrument.java │ │ │ ├── PJoint.java │ │ │ ├── PLevelSettings.java │ │ │ ├── PMaterialOverride.java │ │ │ ├── PMaterialTweak.java │ │ │ ├── PMetadata.java │ │ │ ├── PMicrochip.java │ │ │ ├── PNpc.java │ │ │ ├── PPhysicsTweak.java │ │ │ ├── PPocketItem.java │ │ │ ├── PPoppetPowerup.java │ │ │ ├── PPos.java │ │ │ ├── PPowerUp.java │ │ │ ├── PQuest.java │ │ │ ├── PRef.java │ │ │ ├── PRenderMesh.java │ │ │ ├── PScript.java │ │ │ ├── PScriptName.java │ │ │ ├── PSequencer.java │ │ │ ├── PShape.java │ │ │ ├── PSpriteLight.java │ │ │ ├── PStickers.java │ │ │ ├── PStreamingData.java │ │ │ ├── PStreamingHint.java │ │ │ ├── PSwitch.java │ │ │ ├── PSwitchInput.java │ │ │ ├── PSwitchKey.java │ │ │ ├── PTagSynchroniser.java │ │ │ ├── PTransition.java │ │ │ ├── PTrigger.java │ │ │ ├── PWindTweak.java │ │ │ ├── PWorld.java │ │ │ ├── PWormhole.java │ │ │ ├── PYellowHead.java │ │ │ └── depreciated │ │ │ └── PParticleEmitter2.java │ │ ├── types │ │ ├── ParamSFO.java │ │ ├── ResPtr.java │ │ ├── SerializedResource.java │ │ ├── archives │ │ │ ├── Fart.java │ │ │ ├── Fat.java │ │ │ ├── FileArchive.java │ │ │ ├── SaveArchive.java │ │ │ └── SaveKey.java │ │ ├── data │ │ │ ├── GUID.java │ │ │ ├── GatherData.java │ │ │ ├── NetworkOnlineID.java │ │ │ ├── NetworkPlayerID.java │ │ │ ├── OpenPSID.java │ │ │ ├── ResourceDescriptor.java │ │ │ ├── ResourceInfo.java │ │ │ ├── Revision.java │ │ │ ├── SHA1.java │ │ │ └── WrappedResource.java │ │ ├── databases │ │ │ ├── FileDB.java │ │ │ ├── FileDBRow.java │ │ │ ├── FileEntry.java │ │ │ └── RemapDB.java │ │ ├── mods │ │ │ ├── Mod.java │ │ │ ├── ModInfo.java │ │ │ └── patches │ │ │ │ ├── ModPatch.java │ │ │ │ └── TranslationPatch.java │ │ ├── save │ │ │ ├── BigSave.java │ │ │ └── SaveEntry.java │ │ └── swing │ │ │ ├── FileData.java │ │ │ ├── FileModel.java │ │ │ ├── FileNode.java │ │ │ └── SearchParameters.java │ │ └── util │ │ ├── Bytes.java │ │ ├── Colors.java │ │ ├── Compressor.java │ │ ├── Crypto.java │ │ ├── DDS.java │ │ ├── FileIO.java │ │ ├── GsonUtils.java │ │ ├── Images.java │ │ ├── Matcher.java │ │ ├── Morton2D.java │ │ ├── Nodes.java │ │ ├── Resources.java │ │ ├── Shader.java │ │ ├── Strings.java │ │ ├── XmlFormatter.java │ │ └── gfx │ │ ├── CgAssembler.java │ │ └── GfxAssembler.java │ └── resources │ ├── binary │ ├── characters.boneset │ └── template.anim │ ├── footer.txt │ ├── gmat_lbp1.txt │ ├── poppet_lbp1.txt │ └── shaders │ └── templates │ ├── cg │ └── brdf.cg │ └── glsl │ └── brdf.fs ├── nbactions.xml ├── pom.xml ├── toolkit ├── README.md ├── nbactions.xml ├── pom.xml └── src │ └── main │ ├── java │ ├── configurations │ │ ├── ApplicationFlags.java │ │ ├── Config.java │ │ └── Profile.java │ ├── executables │ │ ├── Bin2Plan.java │ │ ├── LevelMerger.java │ │ ├── PlanBackporter.java │ │ ├── Psyncer.java │ │ ├── Respec.java │ │ ├── ShapeAssembler.java │ │ ├── TexToPng.java │ │ └── gfx │ │ │ ├── GfxGUI.form │ │ │ ├── GfxGUI.java │ │ │ └── dialogues │ │ │ ├── ErrorDialogue.form │ │ │ ├── ErrorDialogue.java │ │ │ ├── TextureDialogue.form │ │ │ └── TextureDialogue.java │ └── toolkit │ │ ├── Launcher.java │ │ ├── dialogues │ │ ├── DescriptorDialogue.form │ │ ├── DescriptorDialogue.java │ │ ├── EntryDialogue.form │ │ └── EntryDialogue.java │ │ ├── functions │ │ ├── AlearCallbacks.java │ │ ├── ArchiveCallbacks.java │ │ ├── DatabaseCallbacks.java │ │ ├── DebugCallbacks.java │ │ ├── DependencyCallbacks.java │ │ ├── EditCallbacks.java │ │ ├── ExportCallbacks.java │ │ ├── FileCallbacks.java │ │ ├── LoadCallbacks.java │ │ ├── ModCallbacks.java │ │ ├── ProfileCallbacks.java │ │ ├── ReplacementCallbacks.java │ │ └── UtilityCallbacks.java │ │ ├── streams │ │ ├── CustomPrintStream.java │ │ └── TextAreaOutputStream.java │ │ ├── utilities │ │ ├── EasterEgg.java │ │ ├── FileChooser.java │ │ ├── SlowOp.java │ │ ├── Swing.java │ │ ├── TreeSelectionListener.java │ │ └── services │ │ │ ├── PlanService.java │ │ │ ├── ResourceService.java │ │ │ └── TextureService.java │ │ └── windows │ │ ├── BigProfileGUI.form │ │ ├── BigProfileGUI.java │ │ ├── ItemManagerApplet.form │ │ ├── ItemManagerApplet.java │ │ ├── Toolkit.form │ │ ├── Toolkit.java │ │ ├── bundlers │ │ ├── TextureImporter.form │ │ └── TextureImporter.java │ │ ├── managers │ │ ├── ArchiveManager.form │ │ ├── ArchiveManager.java │ │ ├── ItemManager.form │ │ ├── ItemManager.java │ │ ├── ModManager.form │ │ ├── ModManager.java │ │ ├── ProfileManager.form │ │ ├── ProfileManager.java │ │ ├── SettingsManager.form │ │ ├── SettingsManager.java │ │ ├── SlotManager.form │ │ └── SlotManager.java │ │ └── utilities │ │ ├── ArchiveSelector.form │ │ ├── ArchiveSelector.java │ │ ├── AssetExporter.form │ │ ├── AssetExporter.java │ │ ├── Compressinator.form │ │ ├── Compressinator.java │ │ ├── Dependinator.form │ │ ├── Dependinator.java │ │ ├── ResourcePicker.form │ │ ├── ResourcePicker.java │ │ ├── SlowOpGUI.form │ │ └── SlowOpGUI.java │ └── resources │ ├── icon.png │ ├── images │ └── slots │ │ ├── adventure.png │ │ ├── adventure_mask.png │ │ ├── backdrop.png │ │ ├── lbp1.png │ │ ├── lbp2.png │ │ ├── lbp3.png │ │ └── polaroid.png │ └── locked.txt └── tools ├── descriptor ├── README.md ├── pom.xml └── src │ └── main │ └── java │ └── Descriptor.java ├── jsoninator ├── README.md ├── pom.xml └── src │ └── main │ └── java │ └── Jsoninator.java └── sequencerdump ├── pom.xml └── src └── main └── java ├── MidiDumper.java ├── Sequence.java ├── SequencerDump.java ├── instrument ├── Instrument.java ├── StandardInstrument.java └── UnknownInstrument.java └── utils ├── MathUtils.java ├── MidiChannelStack.java ├── MidiUtils.java └── PositionUtils.java /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.nar 17 | *.ear 18 | *.zip 19 | *.tar.gz 20 | *.rar 21 | 22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 23 | hs_err_pid* 24 | **/target/ 25 | /workspace 26 | 27 | .vscode/ 28 | .idea/ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 ennuo 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Craftworld Toolkit 2 | 3 | ![Application](https://github.com/ennuo/toolkit/assets/67672427/b24a1bb0-eefc-4c5d-bc38-173e949e3154) 4 | 5 | # About 6 | 7 | Craftworld Toolkit is an extended version of [farctool2](https://github.com/philosophofee/farctool2) 8 | by [philosophofee](https://github.com/philosophofee/) designed to mod the mainline LittleBigPlanet 9 | series. 10 | 11 | # Features 12 | 13 | - Read and edit gamedata files and resources from every mainline LittleBigPlanet game 14 | - Texture viewing, exporting, and importing 15 | - Model exporting to either Wavefront OBJ or glTF 2.0 16 | - Convert inventory items, levels, and other common resources to/from JSON 17 | - Save editor, edit levels and items in your big profile 18 | - Pack/Slot editor for modifying story levels and extra content 19 | - Mod file install/export to both game and save data -------------------------------------------------------------------------------- /lib/cwlib-gl/README.md: -------------------------------------------------------------------------------- 1 | # cwlib-gl 2 | 3 | LWJGL based extensions for cwlib. 4 | Mainly contains texture baking and decal rendering. -------------------------------------------------------------------------------- /lib/cwlib-gl/src/main/java/cwlib/gl/RenderJob.java: -------------------------------------------------------------------------------- 1 | package cwlib.gl; 2 | 3 | import java.util.concurrent.CountDownLatch; 4 | import java.util.function.BiConsumer; 5 | 6 | public class RenderJob 7 | { 8 | /** 9 | * Job completion latch. 10 | */ 11 | public CountDownLatch latch = new CountDownLatch(1); 12 | 13 | /** 14 | * The job function to run. 15 | */ 16 | public BiConsumer function; 17 | 18 | /** 19 | * User argument provided to function. 20 | */ 21 | public Object userData; 22 | 23 | public RenderJob(BiConsumer function, Object userData) 24 | { 25 | this.function = function; 26 | this.userData = userData; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lib/cwlib-gl/src/main/resources/shaders/bake.vs: -------------------------------------------------------------------------------- 1 | #version 420 core 2 | 3 | layout (location = 0) in vec4 iUV; 4 | layout (location = 1) in vec2 iDecalUV; 5 | layout (location = 2) in vec2 iImageUV; 6 | 7 | out vec4 uv; 8 | out vec2 decal_uv; 9 | 10 | void main() { 11 | uv = iUV; 12 | decal_uv = iDecalUV; 13 | 14 | vec2 pos = 1.0 - (2.0 * iImageUV.xy); 15 | gl_Position = vec4(pos, 0.0, 1.0); 16 | } -------------------------------------------------------------------------------- /lib/cwlib-gl/src/main/resources/shaders/decal.fs: -------------------------------------------------------------------------------- 1 | #version 420 core 2 | 3 | in vec2 TexCoord; 4 | out vec4 FragColor; 5 | 6 | layout (binding = 0) uniform sampler2D s_Decal; 7 | 8 | void main(void) 9 | { 10 | FragColor = texture(s_Decal, TexCoord); 11 | } -------------------------------------------------------------------------------- /lib/cwlib-gl/src/main/resources/shaders/decal.vs: -------------------------------------------------------------------------------- 1 | #version 420 core 2 | layout (location = 0) in vec4 iVertex; 3 | 4 | out vec2 TexCoord; 5 | 6 | void main() 7 | { 8 | vec2 pos = 1.0 - (2.0 * iVertex.xy); 9 | gl_Position = vec4(pos, 0.0, 1.0); 10 | TexCoord = iVertex.zw; 11 | } -------------------------------------------------------------------------------- /lib/cwlib-gl/src/main/resources/shaders/templates/glsl/alphabake.fs: -------------------------------------------------------------------------------- 1 | #version 420 core 2 | 3 | #define SAMPLE_2D(smp, uv) texture(smp, uv) 4 | #define SAMPLE_2D_BIAS(smp, uv, bias) texture(smp, uv, bias) 5 | #define rsqrt(value) pow(value, -0.5) 6 | #define saturate(value) max(0, min(1, value)) 7 | #define lerp(a, b, w) (a + w * (b - a)) 8 | 9 | #define float1 float 10 | #define float2 vec2 11 | #define float3 vec3 12 | #define float4 vec4 13 | #define half vec 14 | 15 | in vec4 uv; 16 | in vec2 decal_uv; 17 | 18 | out vec4 PixelColor; 19 | 20 | const float AlphaTestLevel = ENV.ALPHA_TEST_LEVEL; 21 | const vec4 thing_color = vec4(1.0, 1.0, 1.0, 1.0); 22 | 23 | layout (binding = 0) uniform sampler2D s0; 24 | layout (binding = 1) uniform sampler2D s1; 25 | layout (binding = 2) uniform sampler2D s2; 26 | layout (binding = 3) uniform sampler2D s3; 27 | layout (binding = 4) uniform sampler2D s4; 28 | layout (binding = 5) uniform sampler2D s5; 29 | layout (binding = 6) uniform sampler2D s6; 30 | layout (binding = 7) uniform sampler2D s7; 31 | 32 | vec4 GetAlpha() 33 | { 34 | ENV.ALPHA_SETUP 35 | } 36 | 37 | vec4 GetSample() 38 | { 39 | ENV.SAMPLE_SETUP 40 | } 41 | 42 | void main() 43 | { 44 | if (GetAlpha().w < AlphaTestLevel) discard; 45 | PixelColor = GetSample(); 46 | } -------------------------------------------------------------------------------- /lib/cwlib-gl/src/main/resources/shaders/templates/glsl/bake.fs: -------------------------------------------------------------------------------- 1 | #version 420 core 2 | 3 | #define SAMPLE_2D(smp, uv) texture(smp, uv) 4 | #define SAMPLE_2D_BIAS(smp, uv, bias) texture(smp, uv, bias) 5 | #define rsqrt(value) pow(value, -0.5) 6 | #define saturate(value) max(0, min(1, value)) 7 | #define lerp(a, b, w) (a + w * (b - a)) 8 | 9 | #define float1 float 10 | #define float2 vec2 11 | #define float3 vec3 12 | #define float4 vec4 13 | #define half vec 14 | 15 | in vec4 uv; 16 | in vec2 decal_uv; 17 | 18 | out vec4 PixelColor; 19 | 20 | const vec4 thing_color = vec4(1.0, 1.0, 1.0, 1.0); 21 | 22 | layout (binding = 0) uniform sampler2D s0; 23 | layout (binding = 1) uniform sampler2D s1; 24 | layout (binding = 2) uniform sampler2D s2; 25 | layout (binding = 3) uniform sampler2D s3; 26 | layout (binding = 4) uniform sampler2D s4; 27 | layout (binding = 5) uniform sampler2D s5; 28 | layout (binding = 6) uniform sampler2D s6; 29 | layout (binding = 7) uniform sampler2D s7; 30 | 31 | vec4 GetSample() 32 | { 33 | ENV.SAMPLE_SETUP 34 | } 35 | 36 | void main() 37 | { 38 | PixelColor = GetSample(); 39 | } -------------------------------------------------------------------------------- /lib/cwlib/README.md: -------------------------------------------------------------------------------- 1 | # cwlib 2 | 3 | Library for working with LittleBigPlanet data. -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/ArchiveType.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | public enum ArchiveType 4 | { 5 | FARC, 6 | SAVE 7 | } 8 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/BoneFlag.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | public final class BoneFlag 4 | { 5 | public static final int NONE = 0x0; 6 | public static final int CAMERA = 0x1; 7 | public static final int DUMMY = 0x2; 8 | } 9 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/BoxType.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | /** 4 | * Types of material box nodes, incomplete list. 5 | */ 6 | public class BoxType 7 | { 8 | public static final int OUTPUT = 0; 9 | public static final int TEXTURE_SAMPLE = 1; 10 | public static final int THING_COLOR = 2; // u32 (8)? 11 | public static final int COLOR = 3; 12 | public static final int CONSTANT = 4; 13 | public static final int CONSTANT2 = 5; 14 | public static final int CONSTANT3 = 6; 15 | public static final int CONSTANT4 = 7; 16 | // 8 is not used in any shader 17 | public static final int MULTIPLY_ADD = 9; // Multiply by params[0], then add by params[1]. 18 | public static final int MULTIPLY = 10; 19 | public static final int ADD = 11; 20 | public static final int MIX = 12; 21 | public static final int MAKE_FLOAT2 = 13; 22 | public static final int MAKE_FLOAT3 = 14; 23 | public static final int MAKE_FLOAT4 = 15; 24 | public static final int BLEND = 16; 25 | // 17, something with fur 26 | // 18 ??? 27 | public static final int EXPONENT = 19; 28 | } -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/BrdfPort.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | public class BrdfPort 4 | { 5 | public static final int DIFFUSE = 0; 6 | public static final int ALPHA_CLIP = 1; 7 | public static final int SPECULAR = 2; 8 | public static final int BUMP = 3; 9 | public static final int GLOW = 4; 10 | public static final int REFLECTION = 6; 11 | public static final int UNKNOWN = 7; // 7, just adds tex * ambcol, to final color 12 | 13 | // 169 14 | public static final int ANISO = 170; 15 | public static final int TRANS = 171; 16 | public static final int COLOR_CORRECTION = 172; // ramp 17 | public static final int FUZZ = 173; 18 | public static final int BRDF_REFLECTANCE = 174; 19 | public static final int TOON_RAMP = 175; 20 | } -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/BuiltinType.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | import cwlib.io.ValueEnum; 4 | 5 | /** 6 | * Virtual types used in the Fish scripting environments. 7 | */ 8 | public enum BuiltinType implements ValueEnum 9 | { 10 | /** 11 | * If a type doesn't exist, or if it's associated 12 | * machine type is a reference, this type will be used. 13 | */ 14 | VOID(0x0), 15 | 16 | BOOL(0x1), 17 | CHAR(0x2), 18 | S32(0x3), 19 | F32(0x4), 20 | 21 | /* All the vector types are still vector4's natively */ 22 | 23 | V2(0x5), 24 | V3(0x6), 25 | V4(0x7), 26 | 27 | M44(0x8), 28 | 29 | /** 30 | * Functionally the same as a s32. 31 | */ 32 | GUID(0x9), 33 | 34 | S64(0xa), 35 | F64(0xb); 36 | 37 | private final int value; 38 | 39 | BuiltinType(int value) 40 | { 41 | this.value = value; 42 | } 43 | 44 | public Integer getValue() 45 | { 46 | return this.value; 47 | } 48 | 49 | public static BuiltinType fromValue(int value) 50 | { 51 | for (BuiltinType type : BuiltinType.values()) 52 | { 53 | if (type.value == value) 54 | return type; 55 | } 56 | return null; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/CacheFlags.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | /** 4 | * Cache flags in RShaderCache 5 | */ 6 | public class CacheFlags 7 | { 8 | public static final int NONE = 0; 9 | 10 | public static final int DIFFUSE = (1 << 0); 11 | public static final int SPECULAR = (1 << 1); 12 | public static final int BUMP = (1 << 2); 13 | public static final int GLOW = (1 << 3); 14 | public static final int REFLECTION = (1 << 4); 15 | public static final int ALPHA_CLIP = (1 << 5); 16 | public static final int DIRT = (1 << 9); 17 | @Deprecated 18 | public static final int PROCEDURAL = (1 << 6); 19 | 20 | public static final int DIFFUSE_COLOR = CacheFlags.DIFFUSE | (1 << 7); 21 | public static final int SPECULAR_COLOR = CacheFlags.SPECULAR | (1 << 8); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/CameraType.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | import cwlib.io.ValueEnum; 4 | 5 | public enum CameraType implements ValueEnum 6 | { 7 | CAMERA_ZONE(0), 8 | PHOTO_BOOTH(1), 9 | SPEECH_BUBBLE(2), 10 | CUTSCENE(3); 11 | 12 | private final int value; 13 | 14 | CameraType(int value) 15 | { 16 | this.value = value; 17 | } 18 | 19 | public Integer getValue() 20 | { 21 | return this.value; 22 | } 23 | 24 | public static CameraType fromValue(int value) 25 | { 26 | for (CameraType part : CameraType.values()) 27 | { 28 | if (part.value == value) 29 | return part; 30 | } 31 | return null; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/CellGcmEnumForGtf.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | public enum CellGcmEnumForGtf 4 | { 5 | B8(0x81), 6 | A1R5G5B5(0x82), 7 | A4R4G4B4(0x83), 8 | R5G6B5(0x84), 9 | A8R8G8B8(0x85), 10 | DXT1(0x86), 11 | DXT3(0x87), 12 | DXT5(0x88), 13 | G8B8(0x8b), 14 | R5G5B5(0x8f); 15 | 16 | private final int value; 17 | 18 | CellGcmEnumForGtf(int value) 19 | { 20 | this.value = value; 21 | } 22 | 23 | public int getValue() 24 | { 25 | return this.value; 26 | } 27 | 28 | public static CellGcmEnumForGtf fromValue(int value) 29 | { 30 | for (CellGcmEnumForGtf type : CellGcmEnumForGtf.values()) 31 | { 32 | if (type.value == value) 33 | return type; 34 | } 35 | return null; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/CellGcmPrimitive.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | import cwlib.io.ValueEnum; 4 | 5 | public enum CellGcmPrimitive implements ValueEnum 6 | { 7 | POINTS(1), 8 | LINES(2), 9 | LINE_LOOP(3), 10 | LINE_STRIP(4), 11 | TRIANGLES(5), 12 | TRIANGLE_STRIP(6), 13 | TRIANGLE_FAN(7), 14 | QUADS(8), 15 | QUAD_STRIP(9), 16 | POLYGON(10); 17 | 18 | private final byte value; 19 | 20 | CellGcmPrimitive(int value) 21 | { 22 | this.value = (byte) (value & 0xFF); 23 | } 24 | 25 | public Byte getValue() 26 | { 27 | return this.value; 28 | } 29 | 30 | public static CellGcmPrimitive fromValue(int value) 31 | { 32 | for (CellGcmPrimitive type : CellGcmPrimitive.values()) 33 | { 34 | if (type.value == value) 35 | return type; 36 | } 37 | return null; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/CollideType.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | public final class CollideType 4 | { 5 | public static final int NONE = 0x0; 6 | public static final int NORMAL = 0x1; 7 | public static final int COLLECTABLE = 0x2; 8 | public static final int PLAYER = 0x4; 9 | public static final int MAGIC_WALL = 0x8; 10 | public static final int PROJECTILE = 0x10; 11 | public static final int TEMPORARY = 0x20; 12 | } 13 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/CommonMeshes.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | import cwlib.types.data.GUID; 4 | 5 | public final class CommonMeshes 6 | { 7 | /** 8 | * GUID reference to the badge mesh used by level themes. 9 | */ 10 | public static final GUID POLAROID_GUID = new GUID(27162); 11 | 12 | /** 13 | * GUID reference to the badge mesh used by DLC packs. 14 | */ 15 | public static final GUID BUBBLE_GUID = new GUID(68653); 16 | 17 | /** 18 | * GUID reference to the badge mesh used by standard levels. 19 | */ 20 | public static final GUID LEVEL_BADGE_GUID = new GUID(16006); 21 | 22 | /** 23 | * GUID reference to the badge mesh used by adventure levels. 24 | */ 25 | public static final GUID ADVENTURE_BADGE_GUID = new GUID(642431); 26 | } 27 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/ContentsType.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | import cwlib.io.ValueEnum; 4 | import cwlib.types.data.GUID; 5 | import cwlib.types.data.ResourceDescriptor; 6 | 7 | /** 8 | * Represents a type of DLC content slot. 9 | */ 10 | public enum ContentsType implements ValueEnum 11 | { 12 | GROUP(0, CommonMeshes.POLAROID_GUID), 13 | PLANS(1, CommonMeshes.BUBBLE_GUID), 14 | LEVEL(2, CommonMeshes.LEVEL_BADGE_GUID), 15 | COSTUME(3, CommonMeshes.BUBBLE_GUID), 16 | ADVENTURE(5, CommonMeshes.ADVENTURE_BADGE_GUID); 17 | 18 | private final int value; 19 | 20 | /** 21 | * The default associated mesh associated 22 | * with this content type. 23 | */ 24 | private final GUID badgeMeshGUID; 25 | 26 | ContentsType(int value, GUID mesh) 27 | { 28 | this.value = value; 29 | this.badgeMeshGUID = mesh; 30 | } 31 | 32 | public Integer getValue() 33 | { 34 | return this.value; 35 | } 36 | 37 | public ResourceDescriptor getBadgeMesh() 38 | { 39 | return new ResourceDescriptor(this.badgeMeshGUID, ResourceType.MESH); 40 | } 41 | 42 | public static ContentsType fromValue(int value) 43 | { 44 | for (ContentsType type : ContentsType.values()) 45 | { 46 | if (type.value == value) 47 | return type; 48 | } 49 | return ContentsType.GROUP; 50 | } 51 | } -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/CurveType.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | import cwlib.io.ValueEnum; 4 | 5 | /** 6 | * Type of f-curve 7 | */ 8 | public enum CurveType implements ValueEnum 9 | { 10 | CONSTANT(0), 11 | LINEAR(1), 12 | QUADRATIC(2), 13 | CUBIC(3), 14 | WAVE(4), 15 | BOX(5), 16 | SAW(6), 17 | MAX(7); 18 | 19 | private final int value; 20 | 21 | CurveType(int value) 22 | { 23 | this.value = value; 24 | } 25 | 26 | public Integer getValue() 27 | { 28 | return this.value; 29 | } 30 | 31 | /** 32 | * Attempts to get a f-curve type from value. 33 | * 34 | * @param value curve type value 35 | * @return f-curve type 36 | */ 37 | public static CurveType fromValue(int value) 38 | { 39 | for (CurveType type : CurveType.values()) 40 | { 41 | if (type.value == value) 42 | return type; 43 | } 44 | return null; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/DLCFileFlags.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | public class DLCFileFlags 4 | { 5 | public static final int NONE = 0x0; 6 | public static final int OWNED = 0x1; 7 | public static final int AUTO_ADD_DISABLED = 0x2; 8 | public static final int IS_GOTY_GIVEAWAY = 0x4; 9 | public static final int IS_BETA = 0x8; 10 | } 11 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/DatabaseType.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | public enum DatabaseType 4 | { 5 | NONE(null, null, false, false), 6 | FILE_DATABASE("FileDB", "map", true, false), 7 | BIGFART("Big Profile", "", false, true), 8 | SAVE("Profile Data", null, false, true), 9 | MOD("Mod", "mod", true, true); 10 | 11 | /** 12 | * Whether or not this database type has entries 13 | * with GUIDs 14 | */ 15 | private final boolean hasGUIDs; 16 | private final boolean containsData; 17 | private final String name; 18 | private final String extension; 19 | 20 | DatabaseType(String name, String extension, boolean hasKeys, boolean hasData) 21 | { 22 | this.name = name; 23 | this.extension = extension; 24 | this.hasGUIDs = hasKeys; 25 | this.containsData = hasData; 26 | } 27 | 28 | public String getName() 29 | { 30 | return this.name; 31 | } 32 | 33 | public String getExtension() 34 | { 35 | return this.extension; 36 | } 37 | 38 | public boolean hasGUIDs() 39 | { 40 | return this.hasGUIDs; 41 | } 42 | 43 | public boolean containsData() 44 | { 45 | return this.containsData; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/DecalType.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | import cwlib.io.ValueEnum; 4 | 5 | /** 6 | * The type of decal rendered. 7 | */ 8 | public enum DecalType implements ValueEnum 9 | { 10 | STICKER(0), 11 | PAINT(1), 12 | EYETOY(2); 13 | 14 | private final byte value; 15 | 16 | DecalType(int value) 17 | { 18 | this.value = (byte) (value & 0xFF); 19 | } 20 | 21 | public Byte getValue() 22 | { 23 | return this.value; 24 | } 25 | 26 | public static DecalType fromValue(byte value) 27 | { 28 | for (DecalType type : DecalType.values()) 29 | { 30 | if (type.value == value) 31 | return type; 32 | } 33 | return null; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/EnemyPart.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | import cwlib.io.ValueEnum; 4 | 5 | public enum EnemyPart implements ValueEnum 6 | { 7 | LEG(0), 8 | EYE(1), 9 | BRAIN(2), 10 | WHEEL(3), 11 | ROCKET(4), 12 | PAINT(5); 13 | 14 | private final int value; 15 | 16 | EnemyPart(int value) 17 | { 18 | this.value = value; 19 | } 20 | 21 | public Integer getValue() 22 | { 23 | return this.value; 24 | } 25 | 26 | public static EnemyPart fromValue(int value) 27 | { 28 | for (EnemyPart part : EnemyPart.values()) 29 | { 30 | if (part.value == value) 31 | return part; 32 | } 33 | return null; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/FlipType.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | import cwlib.io.ValueEnum; 4 | 5 | /** 6 | * Refers to how a mirrored bone gets flipped. 7 | */ 8 | public enum FlipType implements ValueEnum 9 | { 10 | /** 11 | * X.pos, X.rot 12 | */ 13 | MAX(0), 14 | 15 | /** 16 | * Y.pos, Y.rot + prerot 17 | */ 18 | BIP_ROOT(1), 19 | 20 | /** 21 | * Z.pos, Z.rot + prerot 22 | */ 23 | BIP_PELVIS(2), 24 | 25 | /** 26 | * Z.pos, Z.rot 27 | */ 28 | BIP_BONE(3), 29 | 30 | /** 31 | * Z.pos, Z.rot + null prerot 32 | */ 33 | PARENT_WAS_BIP_BONE(4), 34 | 35 | /** 36 | * X.pos, X.rot + prerot 37 | */ 38 | GRANDPARENT_WAS_BIP_BONE(5), 39 | 40 | /** 41 | * No flip, straight copy from mirror bone. 42 | */ 43 | COPY(6); 44 | 45 | private final byte value; 46 | 47 | FlipType(int value) 48 | { 49 | this.value = (byte) (value & 0xFF); 50 | } 51 | 52 | public Byte getValue() 53 | { 54 | return this.value; 55 | } 56 | 57 | public static FlipType fromValue(int value) 58 | { 59 | for (FlipType type : FlipType.values()) 60 | { 61 | if (type.value == value) 62 | return type; 63 | } 64 | return null; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/FunctionType.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | import cwlib.io.ValueEnum; 4 | 5 | public enum FunctionType implements ValueEnum 6 | { 7 | NORMAL(0), 8 | GETTER(1), 9 | SETTER(2); 10 | 11 | private final byte value; 12 | 13 | FunctionType(int value) 14 | { 15 | this.value = (byte) value; 16 | } 17 | 18 | public Byte getValue() 19 | { 20 | return this.value; 21 | } 22 | 23 | public static FunctionType fromValue(int value) 24 | { 25 | for (FunctionType type : FunctionType.values()) 26 | { 27 | if (type.value == value) 28 | return type; 29 | } 30 | return null; 31 | } 32 | } -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/GameMode.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | import cwlib.io.ValueEnum; 4 | 5 | public enum GameMode implements ValueEnum 6 | { 7 | NORMAL(0), 8 | COMPETITIVE(1), 9 | CUT_SCENE(2), 10 | SINGLE_PLAYER(3), 11 | SOCIAL(4), 12 | TEAMS(5); 13 | 14 | // old enum 15 | // normal 0 16 | // competitive 1 17 | // teams 2 18 | // social 3 19 | 20 | private final int value; 21 | 22 | GameMode(int value) 23 | { 24 | this.value = value; 25 | } 26 | 27 | public Integer getValue() 28 | { 29 | return this.value; 30 | } 31 | 32 | /** 33 | * Attempts to get a GameMode from value. 34 | * 35 | * @param value Game mode value 36 | * @return GameMode 37 | */ 38 | public static GameMode fromValue(int value) 39 | { 40 | for (GameMode mode : GameMode.values()) 41 | { 42 | if (mode.value == value) 43 | return mode; 44 | } 45 | return GameMode.NORMAL; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/GameProgressionStatus.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | import cwlib.io.ValueEnum; 4 | 5 | /** 6 | * Status for story mode progression 7 | * in the original LittleBigPlanet. 8 | */ 9 | public enum GameProgressionStatus implements ValueEnum 10 | { 11 | NEW_GAME(0), 12 | POD_ARRIVAL(1), 13 | ENTERED_STORY_LEVEL(2), 14 | FIRST_LEVEL_COMPLETED(3), 15 | GAME_PROGRESSION_COMPLETED(4), 16 | FIRST_GROUP_COMPLETED(4); 17 | 18 | private final int value; 19 | 20 | GameProgressionStatus(int value) 21 | { 22 | this.value = value; 23 | } 24 | 25 | public Integer getValue() 26 | { 27 | return this.value; 28 | } 29 | 30 | /** 31 | * Attempts to get GameProgressionStatus from value. 32 | * 33 | * @param value Game progression status value 34 | * @return GameProgressionStatus 35 | */ 36 | public static GameProgressionStatus fromValue(int value) 37 | { 38 | for (GameProgressionStatus status : GameProgressionStatus.values()) 39 | { 40 | if (status.value == value) 41 | return status; 42 | } 43 | return GameProgressionStatus.NEW_GAME; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/GameShader.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | public enum GameShader 4 | { 5 | LBP1, 6 | LBP2_PRE_ALPHA, 7 | LBP2, 8 | LBP3_PS4 9 | } 10 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/GameVersion.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | import cwlib.types.data.Revision; 4 | 5 | public class GameVersion 6 | { 7 | public static final int LBP1 = (1 << 0); 8 | public static final int LBP2 = (1 << 1); 9 | public static final int LBP3 = (1 << 2); 10 | 11 | public static int getFlag(Revision revision) 12 | { 13 | if (revision.getVersion() <= 0x332) return GameVersion.LBP1; 14 | if (revision.isLBP3()) return GameVersion.LBP3; 15 | return GameVersion.LBP2; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/GameplayPartType.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | import cwlib.io.ValueEnum; 4 | 5 | public enum GameplayPartType implements ValueEnum 6 | { 7 | UNDEFINED(0), 8 | LEVEL_KEY(1), 9 | PRIZE_BUBBLE(2), 10 | SCORE_BUBBLE(3), 11 | COLLECTABUBBLE(4), 12 | POCKET_ITEM_BUBBLE(5), 13 | TREASURE_ITEM(6), 14 | OBJECT_SAVER(7), 15 | RUMBLER(8); 16 | 17 | private final int value; 18 | 19 | GameplayPartType(int value) 20 | { 21 | this.value = value; 22 | } 23 | 24 | public Integer getValue() 25 | { 26 | return this.value; 27 | } 28 | 29 | public static GameplayPartType fromValue(int value) 30 | { 31 | for (GameplayPartType part : GameplayPartType.values()) 32 | { 33 | if (part.value == value) 34 | return part; 35 | } 36 | return null; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/GfxMaterialFlags.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | public final class GfxMaterialFlags 4 | { 5 | public static final int TWO_SIDED = 0x1; 6 | public static final int FURRY = 0x2; 7 | public static final int WIRE = 0x4; 8 | public static final int MAX_PRIORITY = 0x8; 9 | public static final int SQUISHY = 0x10; 10 | public static final int NO_INSTANCE_TEXTURE = 0x20; 11 | public static final int RECEIVE_SHADOWS = 0x100; 12 | public static final int RECEIVE_SUN = 0x200; 13 | public static final int RECEIVE_SPRITELIGHTS = 0x400; 14 | public static final int ALPHA_CLIP = 0x800; // If this flag is set in LBP2, if color_out.w == 15 | // 0, the pixel will be discarded. 16 | 17 | // 0x2000, some flag in LBP3, unknown usage (Only a few materials DONT have this set) 18 | // 0x8000, some flag in LBP3, unknown usage (related to toon shading) 19 | 20 | // DEFAULT = 1800 21 | // DEFAULT_TWO_SIDED = 1801 22 | // DEFAULT_ALPHA_CLIP = 3848 23 | // DEFAULT_ALPHA_CLIP_TWO_SIDED = 3849 24 | 25 | public static final int DEFAULT = 26 | MAX_PRIORITY | RECEIVE_SHADOWS | RECEIVE_SUN | RECEIVE_SPRITELIGHTS; 27 | } 28 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/GroupFlags.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | public class GroupFlags 4 | { 5 | public static final int COPYRIGHT = 1; 6 | public static final int EDITABLE = 2; 7 | public static final int PICKUP_ALL_MEMBERS = 4; 8 | } 9 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/HairMorph.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | import cwlib.io.ValueEnum; 4 | 5 | public enum HairMorph implements ValueEnum 6 | { 7 | HAT(0), 8 | HELMET(1), 9 | FRINGE(2); 10 | 11 | private final int value; 12 | 13 | HairMorph(int value) 14 | { 15 | this.value = value; 16 | } 17 | 18 | public Integer getValue() 19 | { 20 | return this.value; 21 | } 22 | 23 | public static HairMorph fromValue(int value) 24 | { 25 | for (HairMorph morph : HairMorph.values()) 26 | { 27 | if (morph.value == value) 28 | return morph; 29 | } 30 | return null; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/InstructionClass.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | public enum InstructionClass 4 | { 5 | NOP, 6 | LOAD_CONST, 7 | CAST, 8 | UNARY, 9 | BINARY, 10 | GET_BUILTIN_MEMBER, 11 | SET_BUILTIN_MEMBER, 12 | GET_MEMBER, 13 | SET_MEMBER, 14 | GET_ELEMENT, 15 | SET_ELEMENT, 16 | NEW_OBJECT, 17 | NEW_ARRAY, 18 | WRITE, 19 | ARG, 20 | CALL, 21 | RETURN, 22 | BRANCH 23 | } 24 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/InventorySortMode.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | import cwlib.io.ValueEnum; 4 | 5 | public enum InventorySortMode implements ValueEnum 6 | { 7 | INVALID(-1), 8 | DATE_OLDEST(1), 9 | DATE_NEWEST(2), 10 | @Deprecated MOST_RECENTLY_USED(3), 11 | @Deprecated NUM_USES(4), 12 | LOCATION(5), 13 | CATEGORY(6), 14 | SIZE(7), 15 | COLOR(8), 16 | NAME(9), 17 | CREATOR(10); 18 | 19 | private final int value; 20 | 21 | InventorySortMode(int value) 22 | { 23 | this.value = value; 24 | } 25 | 26 | public Integer getValue() 27 | { 28 | return this.value; 29 | } 30 | 31 | public static InventorySortMode fromValue(int value) 32 | { 33 | for (InventorySortMode mode : InventorySortMode.values()) 34 | { 35 | if (mode.value == value) 36 | return mode; 37 | } 38 | return InventorySortMode.INVALID; 39 | } 40 | } -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/LethalType.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | import cwlib.io.ValueEnum; 4 | 5 | public enum LethalType implements ValueEnum 6 | { 7 | NOT(0), 8 | FIRE(1), 9 | ELECTRIC(2), 10 | @Deprecated ICE(3), 11 | CRUSH(4), 12 | SPIKE(5), 13 | GAS(6), 14 | GAS2(7), 15 | GAS3(8), 16 | GAS4(9), 17 | GAS5(10), 18 | GAS6(11), 19 | NO_STAND(12), 20 | BULLET(13), 21 | DROWNED(14); 22 | 23 | private final int value; 24 | 25 | LethalType(int value) 26 | { 27 | this.value = value; 28 | } 29 | 30 | public Integer getValue() 31 | { 32 | return this.value; 33 | } 34 | 35 | public static LethalType fromValue(int value) 36 | { 37 | for (LethalType type : LethalType.values()) 38 | { 39 | if (type.value == value) 40 | return type; 41 | } 42 | return null; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/LevelType.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | import cwlib.io.ValueEnum; 4 | 5 | public enum LevelType implements ValueEnum 6 | { 7 | MAIN_PATH(0), 8 | MINI_LEVEL(1), 9 | MINI_GAME(2), 10 | TUTORIAL(3), 11 | RANDOM_CRAP(4), 12 | BOSS(5), 13 | VERSUS(6), 14 | CUTSCENE(7), 15 | LBP2_DLC_HUB(8); 16 | 17 | private final int value; 18 | 19 | LevelType(int value) 20 | { 21 | this.value = value; 22 | } 23 | 24 | public Integer getValue() 25 | { 26 | return this.value; 27 | } 28 | 29 | /** 30 | * Attempts to get a LevelType from value. 31 | * 32 | * @param value Level type value 33 | * @return LevelType 34 | */ 35 | public static LevelType fromValue(int value) 36 | { 37 | for (LevelType type : LevelType.values()) 38 | { 39 | if (type.value == value) 40 | return type; 41 | } 42 | return LevelType.MAIN_PATH; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/MappingMode.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | import cwlib.io.ValueEnum; 4 | 5 | /** 6 | * UV mapping modes for bevel vertices, 7 | * Thanks to DokkeFyxen for figuring out what each do. 8 | */ 9 | public enum MappingMode implements ValueEnum 10 | { 11 | HIDDEN(0), 12 | 13 | /** 14 | * Standard XYZ UV Mapping. 15 | */ 16 | DAVE(1), 17 | 18 | /** 19 | * Wraps vertically; separate faces. 20 | */ 21 | CYLINDER_01(2), 22 | 23 | /** 24 | * Wraps vertical; all one face. 25 | */ 26 | CYLINDER(3), 27 | 28 | /** 29 | * Wraps vertically; seperate faces, stretches on Y axis. 30 | */ 31 | PLANARXZ_01(4), 32 | 33 | /** 34 | * Wraps vertically; all one face, stretches on Y axis. 35 | */ 36 | PLANARXZ(5); 37 | 38 | private final byte value; 39 | 40 | MappingMode(int value) 41 | { 42 | this.value = (byte) value; 43 | } 44 | 45 | public Byte getValue() 46 | { 47 | return this.value; 48 | } 49 | 50 | public static MappingMode fromValue(int value) 51 | { 52 | for (MappingMode mode : MappingMode.values()) 53 | { 54 | if (mode.value == value) 55 | return mode; 56 | } 57 | return null; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/MaterialFlags.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | public class MaterialFlags 4 | { 5 | public static final int HAS_DIFFUSE = (1 << 0); 6 | public static final int HAS_SPECULAR = (1 << 1); 7 | public static final int HAS_BUMP = (1 << 2); 8 | public static final int HAS_GLOW = (1 << 3); 9 | public static final int HAS_REFLECTION = (1 << 4); 10 | public static final int IS_SOLID_COLOR = (1 << 5); 11 | } 12 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/ModCompatibility.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | public enum ModCompatibility 4 | { 5 | 6 | LBP1(1), 7 | LBP2(2), 8 | LBP3(7 | 11), 9 | LBP3_PS3(7), 10 | LBP3_PS4(11), 11 | LBPV(16), 12 | PS3(7), 13 | PS4(8), 14 | ALL(31); 15 | 16 | private final int value; 17 | 18 | ModCompatibility(int value) 19 | { 20 | this.value = value; 21 | } 22 | 23 | public int getValue() 24 | { 25 | return this.value; 26 | } 27 | 28 | public static ModCompatibility fromValue(int value) 29 | { 30 | for (ModCompatibility type : ModCompatibility.values()) 31 | { 32 | if (type.value == value) 33 | return type; 34 | } 35 | return ModCompatibility.ALL; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/ParameterSubType.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | import cwlib.io.ValueEnum; 4 | 5 | public enum ParameterSubType implements ValueEnum 6 | { 7 | NONE(0x0), 8 | XY(0x1), 9 | ZW(0x2), 10 | Z(0x3); 11 | 12 | private final byte value; 13 | 14 | ParameterSubType(int value) 15 | { 16 | this.value = (byte) value; 17 | } 18 | 19 | public Byte getValue() 20 | { 21 | return this.value; 22 | } 23 | 24 | public static ParameterSubType fromValue(byte value) 25 | { 26 | for (ParameterSubType type : ParameterSubType.values()) 27 | { 28 | if (type.value == value) 29 | return type; 30 | } 31 | return null; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/ParameterType.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | import cwlib.io.ValueEnum; 4 | 5 | public enum ParameterType implements ValueEnum 6 | { 7 | INVALID(-1), 8 | TEXTURE0(0x0), 9 | TEXTURE1(0x1), 10 | TEXTURE2(0x2), 11 | TEXTURE3(0x3), 12 | TEXTURE4(0x4), 13 | TEXTURE5(0x5), 14 | TEXTURE6(0x6), 15 | TEXTURE7(0x7), 16 | ALPHA_TEST_LEVEL(0x8), 17 | BUMP_LEVEL(0x9), 18 | COSINE_POWER(0xa), 19 | SPECULAR_COLOR(0xb); 20 | 21 | private final byte value; 22 | 23 | ParameterType(int value) 24 | { 25 | this.value = (byte) value; 26 | } 27 | 28 | public Byte getValue() 29 | { 30 | return this.value; 31 | } 32 | 33 | public static ParameterType fromValue(byte value) 34 | { 35 | for (ParameterType type : ParameterType.values()) 36 | { 37 | if (type.value == value) 38 | return type; 39 | } 40 | return null; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/PatchType.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | public enum PatchType 4 | { 5 | TRANSLATION 6 | } 7 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/PlayMode.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | import cwlib.io.ValueEnum; 4 | 5 | public enum PlayMode implements ValueEnum 6 | { 7 | TRIGGER_BY_FALLOFF(0x0), 8 | TRIGGER_BY_IMPACT(0x1), 9 | TRIGGER_BY_DESTROY(0x2), 10 | TRIGGER_BY_SWITCH(0x3); 11 | 12 | private final int value; 13 | 14 | PlayMode(int value) 15 | { 16 | this.value = value; 17 | } 18 | 19 | public Integer getValue() 20 | { 21 | return this.value; 22 | } 23 | 24 | public static PlayMode fromValue(int value) 25 | { 26 | for (PlayMode mode : PlayMode.values()) 27 | { 28 | if (mode.value == value) 29 | return mode; 30 | } 31 | return null; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/ResourceFlags.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | /** 4 | * Flags that contain information about resource descriptors, 5 | * generally they aren't used often, if at all in serialization, 6 | * but they're still stored anyway. 7 | */ 8 | public final class ResourceFlags 9 | { 10 | public static final int NONE = 0x0; 11 | public static final int REF_COUNT_DIRTY = 0x2; 12 | public static final int CONTAINS_EYETOY = 0x80; 13 | public static final int DONT_SWIZZLE = 0x100; 14 | public static final int VOLTEX = 0x200; 15 | public static final int NOSRGB_TEX = 0x400; 16 | public static final int BUMP_TEX = 0x800; 17 | public static final int TEMPORARY = 0x2000; 18 | public static final int UNSHARED = 0x4000; 19 | public static final int MAX_MIPS_128 = 0x10000; 20 | } 21 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/ResourceKeys.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | /** 4 | * Commonly used resource keys in 5 | * File Entrys. 6 | */ 7 | public class ResourceKeys 8 | { 9 | public static final int RESOURCE_TYPE = 0; 10 | public static final int RESOURCE_REVISION = 1; 11 | public static final int COMPRESSION_FLAGS = 2; 12 | public static final int DEPENDENCY_MODEL = 3; 13 | public static final int DEPENDENCY_SET = 4; 14 | public static final int HAS_MISSING_DEPENDENCIES = 5; 15 | public static final int CAN_REPLACE_DECOMPRESSED = 6; 16 | 17 | public static final int MAX_ENTRIES = 10; 18 | } 19 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/ScriptObjectType.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | import cwlib.io.ValueEnum; 4 | 5 | public enum ScriptObjectType implements ValueEnum 6 | { 7 | NULL(0), 8 | ARRAY_BOOL(1), 9 | ARRAY_CHAR(2), 10 | ARRAY_S32(3), 11 | ARRAY_F32(4), 12 | ARRAY_VECTOR4(5), 13 | ARRAY_M44(6), 14 | ARRAY_STRING(7), 15 | ARRAY_RAW_PTR(8), 16 | ARRAY_REF_PTR(9), 17 | ARRAY_SAFE_PTR(10), 18 | ARRAY_OBJECT_REF(11), 19 | RESOURCE(12), 20 | INSTANCE(13), 21 | STRINGW(14), 22 | AUDIOHANDLE(15), 23 | STRINGA(16), 24 | POPPET(17), 25 | EXPOSED_COLLECTBUBBLE(18), 26 | ARRAY_S64(19), 27 | ARRAY_F64(20); 28 | 29 | private final int value; 30 | 31 | ScriptObjectType(int value) 32 | { 33 | this.value = value; 34 | } 35 | 36 | public Integer getValue() 37 | { 38 | return this.value; 39 | } 40 | 41 | public static ScriptObjectType fromValue(int value) 42 | { 43 | for (ScriptObjectType type : ScriptObjectType.values()) 44 | { 45 | if (type.value == value) 46 | return type; 47 | } 48 | return null; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/SerializationType.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | public enum SerializationType 4 | { 5 | UNKNOWN(null), 6 | BINARY("b"), 7 | TEXT("t"), 8 | ENCRYPTED_BINARY("e"), 9 | COMPRESSED_TEXTURE(" "), 10 | GTF_SWIZZLED("s"), 11 | GXT_SWIZZLED("S"); 12 | 13 | private final String value; 14 | 15 | SerializationType(String value) 16 | { 17 | this.value = value; 18 | } 19 | 20 | public String getValue() 21 | { 22 | return this.value; 23 | } 24 | 25 | public static SerializationType fromValue(String value) 26 | { 27 | for (SerializationType type : SerializationType.values()) 28 | { 29 | if (value.equals(type.value)) 30 | return type; 31 | } 32 | return SerializationType.UNKNOWN; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/ShadowCastMode.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | import cwlib.io.ValueEnum; 4 | 5 | public enum ShadowCastMode implements ValueEnum 6 | { 7 | OFF(0x0), 8 | ON(0x1), 9 | ALPHA(0x2); 10 | 11 | private final byte value; 12 | 13 | ShadowCastMode(int value) 14 | { 15 | this.value = (byte) (value & 0xFF); 16 | } 17 | 18 | public Byte getValue() 19 | { 20 | return this.value; 21 | } 22 | 23 | public static ShadowCastMode fromValue(byte value) 24 | { 25 | for (ShadowCastMode mode : ShadowCastMode.values()) 26 | { 27 | if (mode.value == value) 28 | return mode; 29 | } 30 | return null; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/ShadowType.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | import cwlib.io.ValueEnum; 4 | 5 | public enum ShadowType implements ValueEnum 6 | { 7 | ALWAYS(0), 8 | NEVER(1), 9 | IF_ON_SCREEN(2); 10 | 11 | private final byte value; 12 | 13 | ShadowType(int value) 14 | { 15 | this.value = (byte) (value & 0xFF); 16 | } 17 | 18 | public Byte getValue() 19 | { 20 | return this.value; 21 | } 22 | 23 | public static ShadowType fromValue(byte value) 24 | { 25 | for (ShadowType mode : ShadowType.values()) 26 | { 27 | if (mode.value == value) 28 | return mode; 29 | } 30 | return null; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/ShapeFlags.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | public class ShapeFlags 4 | { 5 | public static final int COLLIDABLE_GAME = 0x1; 6 | public static final int COLLIDABLE_POPPET = 0x2; 7 | public static final int COLLIDABLE_WITH_PARENT = 0x4; 8 | 9 | // 0x8 = Single Grab or Sticky 10 | 11 | public static final int DEFAULT_FLAGS = 0x7; 12 | } 13 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/SkeletonType.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | import cwlib.io.ValueEnum; 4 | 5 | /** 6 | * Refers to a specific character's 7 | * skeleton type in LittleBigPlanet 3 RMesh files. 8 | */ 9 | public enum SkeletonType implements ValueEnum 10 | { 11 | SACKBOY(0), 12 | GIANT(1), 13 | DWARF(2), 14 | BIRD(3), 15 | QUAD(4); 16 | 17 | private final byte value; 18 | 19 | SkeletonType(int value) 20 | { 21 | this.value = (byte) (value & 0xFF); 22 | } 23 | 24 | public Byte getValue() 25 | { 26 | return this.value; 27 | } 28 | 29 | public static SkeletonType fromValue(byte value) 30 | { 31 | for (SkeletonType type : SkeletonType.values()) 32 | { 33 | if (type.value == value) 34 | return type; 35 | } 36 | return null; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/State.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | public enum State 4 | { 5 | INIT, 6 | ERRORED, 7 | READY 8 | } 9 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/SwitchBehavior.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | import cwlib.io.ValueEnum; 4 | 5 | public enum SwitchBehavior implements ValueEnum 6 | { 7 | OFF_ON(0), 8 | SPEED_SCALE(1), 9 | DIRECTION(2), 10 | ONE_SHOT(3); 11 | 12 | private final int value; 13 | 14 | SwitchBehavior(int value) 15 | { 16 | this.value = value; 17 | } 18 | 19 | public Integer getValue() 20 | { 21 | return this.value; 22 | } 23 | 24 | public static SwitchBehavior fromValue(int value) 25 | { 26 | for (SwitchBehavior behavior : SwitchBehavior.values()) 27 | { 28 | if (behavior.value == value) 29 | return behavior; 30 | } 31 | return null; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/SwitchKeyType.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | import cwlib.io.ValueEnum; 4 | 5 | public enum SwitchKeyType implements ValueEnum 6 | { 7 | MAGNETIC(0), 8 | IMPACT(1); 9 | 10 | private final int value; 11 | 12 | SwitchKeyType(int value) 13 | { 14 | this.value = value; 15 | } 16 | 17 | public Integer getValue() 18 | { 19 | return this.value; 20 | } 21 | 22 | public static SwitchKeyType fromValue(int value) 23 | { 24 | for (SwitchKeyType type : SwitchKeyType.values()) 25 | { 26 | if (type.value == value) 27 | return type; 28 | } 29 | return null; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/SwitchLogicType.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | import cwlib.io.ValueEnum; 4 | 5 | public enum SwitchLogicType implements ValueEnum 6 | { 7 | AND(0), 8 | OR(1), 9 | XOR(2), 10 | NOT(3), 11 | NOP(4); 12 | 13 | private final int value; 14 | 15 | SwitchLogicType(int value) 16 | { 17 | this.value = value; 18 | } 19 | 20 | public Integer getValue() 21 | { 22 | return this.value; 23 | } 24 | 25 | public static SwitchLogicType fromValue(int value) 26 | { 27 | for (SwitchLogicType type : SwitchLogicType.values()) 28 | { 29 | if (type.value == value) 30 | return type; 31 | } 32 | return null; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/TextureType.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | /** 4 | * Texture types used in RShaderCache 5 | */ 6 | public class TextureType 7 | { 8 | public static final int DIFFUSE = 0; 9 | public static final int SPECULAR = 1; 10 | public static final int BUMP = 2; 11 | public static final int GLOW = 3; 12 | public static final int REFLECTION = 4; 13 | public static final int OCCLUSION = 5; 14 | public static final int ANISO = 6; 15 | public static final int FUZZ = 7; 16 | public static final int MASK = 8; 17 | public static final int DIRT = 9; 18 | 19 | public static final int MAX = 10; 20 | } 21 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/TextureWrap.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | import cwlib.io.ValueEnum; 4 | 5 | public enum TextureWrap implements ValueEnum 6 | { 7 | WRAP(1), 8 | MIRROR(2), 9 | CLAMP_TO_EDGE(3), 10 | BORDER(4), 11 | CLAMP(5), 12 | MIRROR_ONCE_CLAMP_TO_EDGE(6), 13 | MIRROR_ONCE_BORDER(7), 14 | MIRROR_ONCE_CLAMP(8); 15 | 16 | private final byte value; 17 | 18 | TextureWrap(int value) 19 | { 20 | this.value = (byte) (value & 0xFF); 21 | } 22 | 23 | public Byte getValue() 24 | { 25 | return this.value; 26 | } 27 | 28 | public static TextureWrap fromValue(byte value) 29 | { 30 | for (TextureWrap wrap : TextureWrap.values()) 31 | { 32 | if (wrap.value == value) 33 | return wrap; 34 | } 35 | return null; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/TriggerType.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | import cwlib.io.ValueEnum; 4 | 5 | public enum TriggerType implements ValueEnum 6 | { 7 | RADIUS(0), 8 | RECT(1), 9 | SWITCH(2), 10 | TOUCH(3), 11 | RADIUS_3D(4); 12 | 13 | private final byte value; 14 | 15 | TriggerType(int value) 16 | { 17 | this.value = (byte) value; 18 | } 19 | 20 | public Byte getValue() 21 | { 22 | return this.value; 23 | } 24 | 25 | public static TriggerType fromValue(int value) 26 | { 27 | for (TriggerType type : TriggerType.values()) 28 | { 29 | if (type.value == value) 30 | return type; 31 | } 32 | return null; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/TutorialState.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | import cwlib.io.ValueEnum; 4 | 5 | public enum TutorialState implements ValueEnum 6 | { 7 | UNPLAYED(0x0), 8 | SKIPPED(0x1), 9 | PLAYED(0x2), 10 | COMPLETED(0x3); 11 | 12 | private final int value; 13 | 14 | TutorialState(int value) 15 | { 16 | this.value = value; 17 | } 18 | 19 | public Integer getValue() 20 | { 21 | return this.value; 22 | } 23 | 24 | public static TutorialState fromValue(byte value) 25 | { 26 | for (TutorialState state : TutorialState.values()) 27 | { 28 | if (state.value == value) 29 | return state; 30 | } 31 | return TutorialState.UNPLAYED; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/VariableType.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | /** 4 | * Variable types used in reflection. 5 | */ 6 | public enum VariableType 7 | { 8 | NUL, 9 | S8, 10 | U8, 11 | S16, 12 | U16, 13 | S32, 14 | U32, 15 | U64, 16 | FLOAT, 17 | BOOL, 18 | FLOAT_IN_V2, 19 | V2, 20 | V4, 21 | M44, 22 | STRING, 23 | WSTRING, 24 | STRUCT, 25 | THING, 26 | THINGPTR, 27 | RESOURCEPTR, 28 | PTR, 29 | ARRAY, 30 | FCURVE, 31 | PLAN, 32 | PLANDESC, 33 | RESOURCE, 34 | DESCRIPTOR 35 | } 36 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/enums/VisibilityFlags.java: -------------------------------------------------------------------------------- 1 | package cwlib.enums; 2 | 3 | public final class VisibilityFlags 4 | { 5 | public static final int PLAY_MODE = 0x1; 6 | public static final int EDIT_MODE = 0x2; 7 | } 8 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/ex/SerializationException.java: -------------------------------------------------------------------------------- 1 | package cwlib.ex; 2 | 3 | /** 4 | * Exception thrown when an error occurs during (de)serialization. 5 | */ 6 | public class SerializationException extends RuntimeException 7 | { 8 | /** 9 | * Used for adding custom messages when throwing exceptions. 10 | * 11 | * @param message Message to display with exception 12 | */ 13 | public SerializationException(String message) 14 | { 15 | super(message); 16 | } 17 | 18 | /** 19 | * Used for wrapping exception in catch block. 20 | * 21 | * @param cause The cause of the exception 22 | */ 23 | public SerializationException(Throwable cause) 24 | { 25 | super(cause); 26 | } 27 | 28 | /** 29 | * Used when wrapping exception in catch block and adding custom messages. 30 | * 31 | * @param message Message to display with exception 32 | * @param cause The cause of the exception 33 | */ 34 | public SerializationException(String message, Throwable cause) 35 | { 36 | super(message, cause); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/io/Resource.java: -------------------------------------------------------------------------------- 1 | package cwlib.io; 2 | 3 | import cwlib.io.serializer.SerializationData; 4 | import cwlib.types.data.Revision; 5 | 6 | /** 7 | * Interface used to specify that an object 8 | * can be compressed to a resource. 9 | */ 10 | public interface Resource extends Serializable 11 | { 12 | /** 13 | * Builds this resource using specified revision and compression flags 14 | * and returns the data necessary to properly compress it. 15 | * 16 | * @param revision Revision of the resource 17 | * @param compressionFlags Compression flags used during resource serialization 18 | * @return Serialization data 19 | */ 20 | SerializationData build(Revision revision, byte compressionFlags); 21 | 22 | /** 23 | * Performs necessary fixes to a resource after serializing is finished. 24 | * 25 | * @param revision The revision of the loaded resource 26 | */ 27 | default void onLoadFinished(Revision revision) 28 | { 29 | // Using a default implementation since I'm not adding this to every resource right now. 30 | } 31 | 32 | /** 33 | * Performs necessary fixes to a resource for serialization for a specified revision. 34 | * 35 | * @param revision The target revision 36 | */ 37 | default void onStartSave(Revision revision) 38 | { 39 | // Using a default implementation since I'm not adding this to every resource right now. 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/io/Serializable.java: -------------------------------------------------------------------------------- 1 | package cwlib.io; 2 | 3 | import cwlib.io.serializer.Serializer; 4 | 5 | /** 6 | * Interface that specifies that an object 7 | * can be serialized as a pure data binary 8 | * structure. 9 | */ 10 | public interface Serializable 11 | { 12 | /** 13 | * (De)serializes a structure that implements Serializable. 14 | * 15 | * @param serializer Serializer instance 16 | */ 17 | void serialize(Serializer serializer); 18 | 19 | /** 20 | * Calculates the size necessary to store this structure 21 | * 22 | * @return Size of this structure 23 | */ 24 | int getAllocatedSize(); 25 | } 26 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/io/ValueEnum.java: -------------------------------------------------------------------------------- 1 | package cwlib.io; 2 | 3 | /** 4 | * Used in conjunction with enums for easily (de)serializing values. 5 | */ 6 | public interface ValueEnum 7 | { 8 | E getValue(); 9 | } -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/io/gson/AudioMaterialSerializer.java: -------------------------------------------------------------------------------- 1 | package cwlib.io.gson; 2 | 3 | import com.google.gson.*; 4 | import cwlib.enums.AudioMaterial; 5 | 6 | import java.lang.reflect.Type; 7 | 8 | public class AudioMaterialSerializer implements JsonSerializer, JsonDeserializer 9 | { 10 | @Override 11 | public Integer deserialize(JsonElement je, Type type, JsonDeserializationContext jdc) 12 | throws JsonParseException 13 | { 14 | JsonPrimitive prim = je.getAsJsonPrimitive(); 15 | if (prim.isString()) 16 | { 17 | try { return AudioMaterial.valueOf(prim.getAsString()).getValue(); } 18 | catch (Exception ex) { return 0; } 19 | } 20 | 21 | if (prim.isNumber()) 22 | return prim.getAsInt(); 23 | 24 | return 0; 25 | } 26 | 27 | @Override 28 | public JsonElement serialize(Integer value, Type type, JsonSerializationContext jsc) 29 | { 30 | AudioMaterial aum = AudioMaterial.fromValue(value); 31 | if (aum != null) 32 | return new JsonPrimitive(aum.name()); 33 | return new JsonPrimitive(value); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/io/gson/CreationHistorySerializer.java: -------------------------------------------------------------------------------- 1 | package cwlib.io.gson; 2 | 3 | import com.google.gson.*; 4 | import cwlib.structs.inventory.CreationHistory; 5 | 6 | import java.lang.reflect.Type; 7 | 8 | public class CreationHistorySerializer implements JsonSerializer, 9 | JsonDeserializer 10 | { 11 | @Override 12 | public CreationHistory deserialize(JsonElement je, Type type, JsonDeserializationContext jdc) 13 | throws JsonParseException 14 | { 15 | JsonArray array = je.getAsJsonArray(); 16 | CreationHistory history = new CreationHistory(); 17 | if (array.size() == 0) return null; 18 | history.creators = new String[array.size()]; 19 | for (int i = 0; i < array.size(); ++i) 20 | history.creators[i] = array.get(i).getAsString(); 21 | return history; 22 | } 23 | 24 | @Override 25 | public JsonElement serialize(CreationHistory history, Type type, JsonSerializationContext jsc) 26 | { 27 | if (history.creators == null || history.creators.length == 0) return null; 28 | JsonArray array = new JsonArray(history.creators.length); 29 | for (int i = 0; i < history.creators.length; ++i) 30 | array.add(history.creators[i]); 31 | return array; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/io/gson/GUIDSerializer.java: -------------------------------------------------------------------------------- 1 | package cwlib.io.gson; 2 | 3 | import com.google.gson.*; 4 | import cwlib.types.data.GUID; 5 | 6 | import java.lang.reflect.Type; 7 | 8 | public class GUIDSerializer implements JsonSerializer, JsonDeserializer 9 | { 10 | @Override 11 | public GUID deserialize(JsonElement je, Type type, JsonDeserializationContext jdc) 12 | throws JsonParseException 13 | { 14 | return new GUID(je.getAsInt()); 15 | } 16 | 17 | @Override 18 | public JsonElement serialize(GUID guid, Type type, JsonSerializationContext jsc) 19 | { 20 | return new JsonPrimitive(guid.getValue()); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/io/gson/GsonResourceType.java: -------------------------------------------------------------------------------- 1 | package cwlib.io.gson; 2 | 3 | import cwlib.enums.ResourceType; 4 | 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | 8 | @Retention(RetentionPolicy.RUNTIME) 9 | public @interface GsonResourceType 10 | { 11 | ResourceType value(); 12 | } 13 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/io/gson/GsonRevision.java: -------------------------------------------------------------------------------- 1 | package cwlib.io.gson; 2 | 3 | import java.lang.annotation.Repeatable; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | 7 | @Retention(RetentionPolicy.RUNTIME) 8 | @Repeatable(GsonRevisions.class) 9 | public @interface GsonRevision 10 | { 11 | int min() default -1; 12 | 13 | int max() default -1; 14 | 15 | int branch() default -1; 16 | 17 | boolean lbp3() default false; 18 | } 19 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/io/gson/GsonRevisions.java: -------------------------------------------------------------------------------- 1 | package cwlib.io.gson; 2 | 3 | import java.lang.annotation.Retention; 4 | import java.lang.annotation.RetentionPolicy; 5 | 6 | @Retention(RetentionPolicy.RUNTIME) 7 | public @interface GsonRevisions 8 | { 9 | GsonRevision[] value(); 10 | } 11 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/io/gson/Matrix4fSerializer.java: -------------------------------------------------------------------------------- 1 | package cwlib.io.gson; 2 | 3 | import com.google.gson.*; 4 | import org.joml.Matrix4f; 5 | 6 | import java.lang.reflect.Type; 7 | 8 | public class Matrix4fSerializer implements JsonSerializer, JsonDeserializer 9 | { 10 | @Override 11 | public Matrix4f deserialize(JsonElement je, Type type, JsonDeserializationContext jdc) 12 | throws JsonParseException 13 | { 14 | JsonArray array = je.getAsJsonArray(); 15 | if (array.size() != 16) 16 | throw new JsonParseException("Matrix4f serializable object must have 16 " + 17 | "elements!"); 18 | 19 | float[] values = new float[16]; 20 | for (int i = 0; i < 16; ++i) 21 | values[i] = array.get(i).getAsFloat(); 22 | 23 | Matrix4f matrix = new Matrix4f(); 24 | matrix.set(values); 25 | 26 | return matrix; 27 | } 28 | 29 | @Override 30 | public JsonElement serialize(Matrix4f matrix, Type type, JsonSerializationContext jsc) 31 | { 32 | 33 | JsonArray array = new JsonArray(16); 34 | float[] values = new float[16]; 35 | matrix.get(values); 36 | for (int i = 0; i < 16; ++i) 37 | array.add(values[i]); 38 | return array; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/io/gson/NetworkOnlineIDSerializer.java: -------------------------------------------------------------------------------- 1 | package cwlib.io.gson; 2 | 3 | import com.google.gson.*; 4 | import cwlib.types.data.NetworkOnlineID; 5 | 6 | import java.lang.reflect.Type; 7 | 8 | public class NetworkOnlineIDSerializer implements JsonSerializer, 9 | JsonDeserializer 10 | { 11 | @Override 12 | public NetworkOnlineID deserialize(JsonElement je, Type type, JsonDeserializationContext jdc) 13 | throws JsonParseException 14 | { 15 | return new NetworkOnlineID(je.getAsString()); 16 | } 17 | 18 | @Override 19 | public JsonElement serialize(NetworkOnlineID id, Type type, JsonSerializationContext jsc) 20 | { 21 | return new JsonPrimitive(id.toString()); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/io/gson/NetworkPlayerIDSerializer.java: -------------------------------------------------------------------------------- 1 | package cwlib.io.gson; 2 | 3 | import com.google.gson.*; 4 | import cwlib.types.data.NetworkPlayerID; 5 | 6 | import java.lang.reflect.Type; 7 | 8 | public class NetworkPlayerIDSerializer implements JsonSerializer, 9 | JsonDeserializer 10 | { 11 | @Override 12 | public NetworkPlayerID deserialize(JsonElement je, Type type, JsonDeserializationContext jdc) 13 | throws JsonParseException 14 | { 15 | return new NetworkPlayerID(je.getAsString()); 16 | } 17 | 18 | @Override 19 | public JsonElement serialize(NetworkPlayerID id, Type type, JsonSerializationContext jsc) 20 | { 21 | return new JsonPrimitive(id.toString()); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/io/gson/PatchSerializer.java: -------------------------------------------------------------------------------- 1 | package cwlib.io.gson; 2 | 3 | import com.google.gson.*; 4 | import cwlib.types.mods.patches.ModPatch; 5 | import cwlib.types.mods.patches.TranslationPatch; 6 | 7 | import java.lang.reflect.Type; 8 | 9 | public class PatchSerializer implements JsonDeserializer, JsonSerializer 10 | { 11 | @Override 12 | public ModPatch deserialize(JsonElement je, Type type, JsonDeserializationContext jdc) 13 | throws JsonParseException 14 | { 15 | String patchType = je.getAsJsonObject().get("type").getAsString().toLowerCase(); 16 | switch (patchType) 17 | { 18 | case "translation": 19 | return jdc.deserialize(je, TranslationPatch.class); 20 | default: 21 | return null; 22 | } 23 | } 24 | 25 | @Override 26 | public JsonElement serialize(ModPatch patch, Type type, JsonSerializationContext jsc) 27 | { 28 | switch (patch.getType()) 29 | { 30 | case TRANSLATION: 31 | { 32 | return jsc.serialize(patch, TranslationPatch.class); 33 | } 34 | default: 35 | return null; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/io/gson/SHA1Serializer.java: -------------------------------------------------------------------------------- 1 | package cwlib.io.gson; 2 | 3 | import com.google.gson.*; 4 | import cwlib.types.data.SHA1; 5 | 6 | import java.lang.reflect.Type; 7 | 8 | public class SHA1Serializer implements JsonSerializer, JsonDeserializer 9 | { 10 | @Override 11 | public SHA1 deserialize(JsonElement je, Type type, JsonDeserializationContext jdc) 12 | throws JsonParseException 13 | { 14 | return new SHA1(je.getAsString()); 15 | } 16 | 17 | @Override 18 | public JsonElement serialize(SHA1 hash, Type type, JsonSerializationContext jsc) 19 | { 20 | return new JsonPrimitive(hash.toString()); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/io/gson/SlotIDSerializer.java: -------------------------------------------------------------------------------- 1 | package cwlib.io.gson; 2 | 3 | import com.google.gson.*; 4 | import cwlib.enums.SlotType; 5 | import cwlib.structs.slot.SlotID; 6 | 7 | import java.lang.reflect.Type; 8 | 9 | public class SlotIDSerializer implements JsonSerializer, JsonDeserializer 10 | { 11 | @Override 12 | public SlotID deserialize(JsonElement je, Type type, JsonDeserializationContext jdc) 13 | throws JsonParseException 14 | { 15 | String id = je.getAsString().toUpperCase(); 16 | if (id.equals("NONE")) 17 | return new SlotID(); 18 | String[] fragments = je.getAsString().split(":"); 19 | return new SlotID(SlotType.valueOf(fragments[0]), Long.valueOf(fragments[1])); 20 | } 21 | 22 | @Override 23 | public JsonElement serialize(SlotID id, Type type, JsonSerializationContext jsc) 24 | { 25 | if (id.slotNumber == 0 && id.slotType == SlotType.DEVELOPER) 26 | return new JsonPrimitive("NONE"); 27 | return new JsonPrimitive(id.slotType.toString() + ":" + id.slotNumber); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/io/gson/TranslationTableSerializer.java: -------------------------------------------------------------------------------- 1 | package cwlib.io.gson; 2 | 3 | import com.google.gson.*; 4 | import cwlib.resources.RTranslationTable; 5 | 6 | import java.lang.reflect.Type; 7 | import java.util.Map.Entry; 8 | 9 | public class TranslationTableSerializer implements JsonDeserializer 10 | { 11 | @Override 12 | public RTranslationTable deserialize(JsonElement je, Type type, 13 | JsonDeserializationContext jdc) 14 | throws JsonParseException 15 | { 16 | RTranslationTable table = new RTranslationTable(); 17 | JsonObject object = je.getAsJsonObject(); 18 | for (Entry entry : object.entrySet()) 19 | { 20 | String key = entry.getKey(); 21 | JsonElement value = entry.getValue(); 22 | try 23 | { 24 | table.add(Long.parseLong(key), value.getAsString()); 25 | } 26 | catch (NumberFormatException ex) { table.add(key, value.getAsString()); } 27 | } 28 | return table; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/io/gson/Vector2fSerializer.java: -------------------------------------------------------------------------------- 1 | package cwlib.io.gson; 2 | 3 | import com.google.gson.*; 4 | import org.joml.Vector2f; 5 | 6 | import java.lang.reflect.Type; 7 | 8 | public class Vector2fSerializer implements JsonSerializer, JsonDeserializer 9 | { 10 | @Override 11 | public Vector2f deserialize(JsonElement je, Type type, JsonDeserializationContext jdc) 12 | throws JsonParseException 13 | { 14 | JsonArray array = je.getAsJsonArray(); 15 | if (array.size() != 2) 16 | throw new JsonParseException("Vector2f serializable object must have 2 " + 17 | "elements!"); 18 | return new Vector2f( 19 | array.get(0).getAsFloat(), 20 | array.get(1).getAsFloat() 21 | ); 22 | } 23 | 24 | @Override 25 | public JsonElement serialize(Vector2f vector, Type type, JsonSerializationContext jsc) 26 | { 27 | JsonArray array = new JsonArray(2); 28 | array.add(vector.x); 29 | array.add(vector.y); 30 | return array; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/io/gson/Vector3fSerializer.java: -------------------------------------------------------------------------------- 1 | package cwlib.io.gson; 2 | 3 | import com.google.gson.*; 4 | import org.joml.Vector3f; 5 | 6 | import java.lang.reflect.Type; 7 | 8 | public class Vector3fSerializer implements JsonSerializer, JsonDeserializer 9 | { 10 | @Override 11 | public Vector3f deserialize(JsonElement je, Type type, JsonDeserializationContext jdc) 12 | throws JsonParseException 13 | { 14 | JsonArray array = je.getAsJsonArray(); 15 | if (array.size() != 3) 16 | throw new JsonParseException("Vector3f serializable object must have 3 " + 17 | "elements!"); 18 | return new Vector3f( 19 | array.get(0).getAsFloat(), 20 | array.get(1).getAsFloat(), 21 | array.get(2).getAsFloat() 22 | ); 23 | } 24 | 25 | @Override 26 | public JsonElement serialize(Vector3f vector, Type type, JsonSerializationContext jsc) 27 | { 28 | JsonArray array = new JsonArray(3); 29 | array.add(vector.x); 30 | array.add(vector.y); 31 | array.add(vector.z); 32 | return array; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/io/gson/Vector4fSerializer.java: -------------------------------------------------------------------------------- 1 | package cwlib.io.gson; 2 | 3 | import com.google.gson.*; 4 | import org.joml.Vector4f; 5 | 6 | import java.lang.reflect.Type; 7 | 8 | public class Vector4fSerializer implements JsonSerializer, JsonDeserializer 9 | { 10 | @Override 11 | public Vector4f deserialize(JsonElement je, Type type, JsonDeserializationContext jdc) 12 | throws JsonParseException 13 | { 14 | JsonArray array = je.getAsJsonArray(); 15 | if (array.size() != 4) 16 | throw new JsonParseException("Vector4f serializable object must have 4 " + 17 | "elements!"); 18 | return new Vector4f( 19 | array.get(0).getAsFloat(), 20 | array.get(1).getAsFloat(), 21 | array.get(2).getAsFloat(), 22 | array.get(3).getAsFloat() 23 | ); 24 | } 25 | 26 | @Override 27 | public JsonElement serialize(Vector4f vector, Type type, JsonSerializationContext jsc) 28 | { 29 | JsonArray array = new JsonArray(4); 30 | array.add(vector.x); 31 | array.add(vector.y); 32 | array.add(vector.z); 33 | array.add(vector.w); 34 | return array; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/presets/SlotPresets.java: -------------------------------------------------------------------------------- 1 | package cwlib.presets; 2 | 3 | import cwlib.enums.Crater; 4 | import cwlib.enums.SlotType; 5 | import cwlib.structs.slot.Slot; 6 | import cwlib.structs.slot.SlotID; 7 | import cwlib.types.data.ResourceDescriptor; 8 | 9 | public class SlotPresets 10 | { 11 | 12 | public static Slot Crater(ResourceDescriptor level, int ID) 13 | { 14 | Slot slot = new Slot(); 15 | 16 | SlotID slotID = new SlotID(SlotType.USER_CREATED_STORED_LOCAL, ID); 17 | 18 | slot.id = slotID; 19 | slot.location = Crater.valueOf("SLOT_" + ID).getValue(); 20 | 21 | slot.root = level; 22 | 23 | return slot; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/resources/RGuidSubst.java: -------------------------------------------------------------------------------- 1 | package cwlib.resources; 2 | 3 | import java.util.HashMap; 4 | 5 | import cwlib.types.data.GUID; 6 | import cwlib.util.FileIO; 7 | import cwlib.util.Strings; 8 | 9 | public class RGuidSubst extends HashMap 10 | { 11 | public static RGuidSubst LBP2_TO_LBP1_PLANS = 12 | RGuidSubst.fromCSV(FileIO.getResourceFileAsString("/poppet_lbp1.txt")); 13 | public static RGuidSubst LBP2_TO_LBP1_GMATS = 14 | RGuidSubst.fromCSV(FileIO.getResourceFileAsString("/gmat_lbp1.txt")); 15 | 16 | public static RGuidSubst fromCSV(String data) 17 | { 18 | RGuidSubst subst = new RGuidSubst(); 19 | String[] lines = data.split("\n"); 20 | for (String line : lines) 21 | { 22 | line = line.replaceAll("\\s", ""); 23 | if (line.isEmpty() || line.startsWith("#")) continue; 24 | 25 | String[] row = line.split(","); 26 | subst.put(Strings.getGUID(row[0]), Strings.getGUID(row[1])); 27 | } 28 | return subst; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/resources/RPins.java: -------------------------------------------------------------------------------- 1 | package cwlib.resources; 2 | 3 | import java.util.ArrayList; 4 | 5 | import cwlib.enums.ResourceType; 6 | import cwlib.enums.SerializationType; 7 | import cwlib.io.Resource; 8 | import cwlib.io.serializer.SerializationData; 9 | import cwlib.io.serializer.Serializer; 10 | import cwlib.structs.profile.Pin; 11 | import cwlib.types.data.Revision; 12 | 13 | public class RPins implements Resource 14 | { 15 | public static final int BASE_ALLOCATION_SIZE = 0x10; 16 | 17 | public ArrayList pins = new ArrayList<>(); 18 | 19 | @Override 20 | public void serialize(Serializer serializer) 21 | { 22 | pins = serializer.arraylist(pins, Pin.class); 23 | } 24 | 25 | @Override 26 | public int getAllocatedSize() 27 | { 28 | return BASE_ALLOCATION_SIZE + pins.size() * Pin.BASE_ALLOCATION_SIZE; 29 | } 30 | 31 | @Override 32 | public SerializationData build(Revision revision, byte compressionFlags) 33 | { 34 | Serializer serializer = new Serializer(this.getAllocatedSize(), revision, 35 | compressionFlags); 36 | serializer.struct(this, RPins.class); 37 | return new SerializationData( 38 | serializer.getBuffer(), 39 | revision, 40 | compressionFlags, 41 | ResourceType.PINS, 42 | SerializationType.BINARY, 43 | serializer.getDependencies()); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/adventure/SlotPhotoData.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.adventure; 2 | 3 | import cwlib.enums.ResourceType; 4 | import cwlib.io.Serializable; 5 | import cwlib.io.serializer.Serializer; 6 | import cwlib.structs.slot.SlotID; 7 | import cwlib.types.data.ResourceDescriptor; 8 | 9 | public class SlotPhotoData implements Serializable 10 | { 11 | public static final int BASE_ALLOCATION_SIZE = 0x10; 12 | 13 | SlotID id; 14 | ResourceDescriptor[] photos; 15 | 16 | @Override 17 | public void serialize(Serializer serializer) 18 | { 19 | 20 | id = serializer.struct(id, SlotID.class); 21 | int numPhotos = serializer.i32(photos != null ? photos.length : 0); 22 | if (!serializer.isWriting()) 23 | photos = new ResourceDescriptor[numPhotos]; 24 | for (int i = 0; i < numPhotos; ++i) 25 | photos[i] = serializer.resource(photos[i], ResourceType.PLAN, true); 26 | } 27 | 28 | @Override 29 | public int getAllocatedSize() 30 | { 31 | int size = SlotPhotoData.BASE_ALLOCATION_SIZE; 32 | if (this.photos != null) 33 | size += (this.photos.length * 0x24); 34 | return size; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/animation/AnimatedMorph.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.animation; 2 | 3 | public class AnimatedMorph 4 | { 5 | public float value; 6 | public float[] values; 7 | 8 | public boolean isAnimated = false; 9 | 10 | public AnimatedMorph(float value, int count) 11 | { 12 | this.value = value; 13 | this.values = new float[count]; 14 | } 15 | 16 | public float getValueAtFrame(int frame) 17 | { 18 | if (values == null || !isAnimated) return value; 19 | if (frame < values.length) return values[frame]; 20 | return value; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/animation/Locator.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.animation; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.serializer.Serializer; 5 | import org.joml.Vector3f; 6 | 7 | public class Locator implements Serializable 8 | { 9 | public static final int BASE_ALLOCATION_SIZE = 0x12; 10 | 11 | public Vector3f position; 12 | public String name; 13 | public byte looping, type; 14 | 15 | @Override 16 | public void serialize(Serializer serializer) 17 | { 18 | position = serializer.v3(position); 19 | name = serializer.str(name); 20 | looping = serializer.i8(looping); 21 | type = serializer.i8(type); 22 | } 23 | 24 | @Override 25 | public int getAllocatedSize() 26 | { 27 | int size = BASE_ALLOCATION_SIZE; 28 | if (this.name != null) 29 | size += (this.name.length()); 30 | return size; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/bevel/BevelVertex.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.bevel; 2 | 3 | import cwlib.enums.MappingMode; 4 | import cwlib.io.Serializable; 5 | import cwlib.io.serializer.Serializer; 6 | 7 | import java.util.Locale; 8 | 9 | public class BevelVertex implements Serializable 10 | { 11 | public static final int BASE_ALLOCATION_SIZE = 0x10; 12 | 13 | public float y; 14 | public float z; 15 | public float rigidity = 1.0f; 16 | public byte smoothWithPrevious = 1; 17 | public byte gmatSlot; 18 | public MappingMode mappingMode = MappingMode.DAVE; 19 | 20 | @Override 21 | public void serialize(Serializer serializer) 22 | { 23 | y = serializer.f32(y); 24 | z = serializer.f32(z); 25 | rigidity = serializer.f32(rigidity); 26 | smoothWithPrevious = serializer.i8(smoothWithPrevious); 27 | gmatSlot = serializer.i8(gmatSlot); 28 | mappingMode = serializer.enum8(mappingMode); 29 | } 30 | 31 | @Override 32 | public int getAllocatedSize() 33 | { 34 | return BevelVertex.BASE_ALLOCATION_SIZE; 35 | } 36 | 37 | @Override 38 | public String toString() 39 | { 40 | return String.format(Locale.ROOT, "BevelVertex{v2(%f, %f), %s}", this.y, this.z, 41 | this.mappingMode); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/dlc/DLCGUID.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.dlc; 2 | 3 | import cwlib.enums.DLCFileFlags; 4 | import cwlib.io.Serializable; 5 | import cwlib.io.serializer.Serializer; 6 | import cwlib.types.data.GUID; 7 | 8 | public class DLCGUID implements Serializable 9 | { 10 | public static final int BASE_ALLOCATION_SIZE = 0x10; 11 | 12 | public GUID guid; 13 | public int flags = DLCFileFlags.NONE; 14 | 15 | @Override 16 | public void serialize(Serializer serializer) 17 | { 18 | guid = serializer.guid(guid); 19 | flags = serializer.i32(flags); 20 | } 21 | 22 | @Override 23 | public int getAllocatedSize() 24 | { 25 | return DLCGUID.BASE_ALLOCATION_SIZE; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/font/GlyphInfo.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.font; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.serializer.Serializer; 5 | 6 | public class GlyphInfo implements Serializable 7 | { 8 | public static final int BASE_ALLOCATION_SIZE = 0x10; 9 | 10 | public short character; 11 | public short advance; 12 | public byte boxLeft, boxTop; 13 | public byte boxW, boxH; 14 | public int offset; 15 | public short nextGlyph; 16 | 17 | public transient int cacheX, cacheY; 18 | 19 | @Override 20 | public void serialize(Serializer serializer) 21 | { 22 | character = serializer.i16(character); 23 | advance = serializer.i16(advance); 24 | boxLeft = serializer.i8(boxLeft); 25 | boxTop = serializer.i8(boxTop); 26 | boxW = serializer.i8(boxW); 27 | boxH = serializer.i8(boxH); 28 | offset = serializer.i32(offset); 29 | nextGlyph = serializer.i16(nextGlyph); 30 | } 31 | 32 | @Override 33 | public int getAllocatedSize() 34 | { 35 | return GlyphInfo.BASE_ALLOCATION_SIZE; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/instrument/Sample.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.instrument; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.serializer.Serializer; 5 | 6 | public class Sample implements Serializable 7 | { 8 | public static final int BASE_ALLOCATION_SIZE = 0x20; 9 | 10 | public int baseNote = 48; // MIDI NOTE NUMBERS -> https://www.inspiredacoustics.com/en/MIDI_note_numbers_and_center_frequencies 11 | 12 | public float baseBpm = 149.5f; 13 | public boolean pitched = true; 14 | public boolean fitBpm; 15 | public float fineTune; 16 | 17 | @Override 18 | public void serialize(Serializer serializer) 19 | { 20 | baseNote = serializer.s32(baseNote); 21 | baseBpm = serializer.f32(baseBpm); 22 | pitched = serializer.bool(pitched); 23 | 24 | // Don't know why this is here twice? They both write to the same variable. 25 | fitBpm = serializer.bool(fitBpm); 26 | fitBpm = serializer.bool(fitBpm); 27 | 28 | fineTune = serializer.f32(fineTune); 29 | } 30 | 31 | @Override 32 | public int getAllocatedSize() 33 | { 34 | return BASE_ALLOCATION_SIZE; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/inventory/ColorCorrection.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.inventory; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.serializer.Serializer; 5 | 6 | public class ColorCorrection implements Serializable 7 | { 8 | public static final int BASE_ALLOCATION_SIZE = 0x18; 9 | 10 | public float saturation = 1.0f; 11 | public float hueShift; 12 | public float brightness = 0.5f; 13 | public float contrast = 0.5f; 14 | public float tintHue, tintAmount; 15 | 16 | @Override 17 | public void serialize(Serializer serializer) 18 | { 19 | saturation = serializer.f32(saturation); 20 | hueShift = serializer.f32(hueShift); 21 | brightness = serializer.f32(brightness); 22 | contrast = serializer.f32(contrast); 23 | tintHue = serializer.f32(tintHue); 24 | tintAmount = serializer.f32(tintAmount); 25 | } 26 | 27 | @Override 28 | public int getAllocatedSize() 29 | { 30 | return BASE_ALLOCATION_SIZE; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/inventory/PhotoUser.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.inventory; 2 | 3 | import org.joml.Vector4f; 4 | 5 | import cwlib.io.Serializable; 6 | import cwlib.io.serializer.Serializer; 7 | 8 | public class PhotoUser implements Serializable 9 | { 10 | public static final int BASE_ALLOCATION_SIZE = 0x30; 11 | 12 | public String PSID; 13 | public String user; 14 | public Vector4f bounds = new Vector4f().zero(); 15 | 16 | public PhotoUser() { } 17 | 18 | public PhotoUser(String psid) 19 | { 20 | if (psid == null) return; 21 | if (psid.length() > 0x14) 22 | psid = psid.substring(0, 0x14); 23 | this.PSID = psid; 24 | this.user = psid; 25 | } 26 | 27 | @Override 28 | public void serialize(Serializer serializer) 29 | { 30 | PSID = serializer.str(PSID, 0x14); 31 | user = serializer.wstr(user); 32 | bounds = serializer.v4(bounds); 33 | } 34 | 35 | @Override 36 | public int getAllocatedSize() 37 | { 38 | int size = BASE_ALLOCATION_SIZE; 39 | if (this.user != null) 40 | size += (user.length() * 2); 41 | return size; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/inventory/UserCreatedDetails.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.inventory; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.serializer.Serializer; 5 | 6 | public class UserCreatedDetails implements Serializable 7 | { 8 | public static final int BASE_ALLOCATION_SIZE = 0x8; 9 | 10 | public String name = ""; 11 | public String description = ""; 12 | 13 | public UserCreatedDetails() { } 14 | 15 | public UserCreatedDetails(String name, String description) 16 | { 17 | this.name = name; 18 | this.description = description; 19 | } 20 | 21 | @Override 22 | public void serialize(Serializer serializer) 23 | { 24 | name = serializer.wstr(name); 25 | description = serializer.wstr(description); 26 | } 27 | 28 | @Override 29 | public int getAllocatedSize() 30 | { 31 | int size = BASE_ALLOCATION_SIZE; 32 | if (this.name != null) 33 | size += (this.name.length() * 2); 34 | if (this.description != null) 35 | size += (this.description.length() * 2); 36 | return size; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/joint/FCurve.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.joint; 2 | 3 | import cwlib.enums.CurveType; 4 | import cwlib.io.Serializable; 5 | import cwlib.io.serializer.Serializer; 6 | import org.joml.Vector4f; 7 | 8 | public class FCurve implements Serializable 9 | { 10 | public static final int BASE_ALLOCATION_SIZE = 0x40; 11 | 12 | public Vector4f x = new Vector4f().zero(); 13 | public Vector4f y = new Vector4f().zero(); 14 | public Vector4f p = new Vector4f().zero(); 15 | public CurveType type = CurveType.CONSTANT; 16 | 17 | @Override 18 | public void serialize(Serializer serializer) 19 | { 20 | x = serializer.v4(x); 21 | y = serializer.v4(y); 22 | p = serializer.v4(p); 23 | type = serializer.enum32(type); 24 | } 25 | 26 | @Override 27 | public int getAllocatedSize() 28 | { 29 | return FCurve.BASE_ALLOCATION_SIZE; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/level/AdventureItem.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.level; 2 | 3 | import cwlib.enums.ResourceType; 4 | import cwlib.io.Serializable; 5 | import cwlib.io.serializer.Serializer; 6 | import cwlib.types.data.ResourceDescriptor; 7 | 8 | public class AdventureItem implements Serializable 9 | { 10 | public static final int BASE_ALLOCATION_SIZE = 0x30; 11 | 12 | public int PUID; 13 | public ResourceDescriptor descriptor; 14 | public int flags; 15 | public int iconPUID; 16 | 17 | @Override 18 | public void serialize(Serializer serializer) 19 | { 20 | int subVersion = serializer.getRevision().getSubVersion(); 21 | 22 | PUID = serializer.i32(PUID); 23 | descriptor = serializer.resource(descriptor, ResourceType.PLAN, true); 24 | 25 | if (subVersion < 0xae) 26 | { 27 | serializer.u16(0); 28 | serializer.u8(0); 29 | serializer.f32(0); 30 | serializer.i32(0); 31 | } 32 | 33 | if (subVersion > 0xbe) 34 | flags = serializer.i32(flags); 35 | if (subVersion > 0xe0) 36 | iconPUID = serializer.i32(iconPUID); 37 | } 38 | 39 | @Override 40 | public int getAllocatedSize() 41 | { 42 | return AdventureItem.BASE_ALLOCATION_SIZE; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/level/CachedInventoryData.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.level; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.serializer.Serializer; 5 | 6 | public class CachedInventoryData implements Serializable 7 | { 8 | public static final int BASE_ALLOCATION_SIZE = 0x20; 9 | 10 | public long category, location; 11 | public int cachedToolType; 12 | // CachedUVs 13 | public byte U0, U1, V0, V1; 14 | 15 | @Override 16 | public void serialize(Serializer serializer) 17 | { 18 | int version = serializer.getRevision().getVersion(); 19 | 20 | category = serializer.u32(category); 21 | location = serializer.u32(location); 22 | if (version > 0x39d) 23 | { 24 | cachedToolType = serializer.i32(cachedToolType); 25 | 26 | U0 = serializer.i8(U0); 27 | U1 = serializer.i8(U1); 28 | V0 = serializer.i8(V0); 29 | V1 = serializer.i8(V1); 30 | } 31 | } 32 | 33 | @Override 34 | public int getAllocatedSize() 35 | { 36 | return CachedInventoryData.BASE_ALLOCATION_SIZE; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/level/StartPoint.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.level; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.serializer.Serializer; 5 | import cwlib.structs.slot.SlotID; 6 | import cwlib.structs.streaming.StreamingID; 7 | 8 | import java.util.ArrayList; 9 | 10 | public class StartPoint implements Serializable 11 | { 12 | public static final int BASE_ALLOCATION_SIZE = 0x10; 13 | 14 | public SlotID slot; 15 | public ArrayList ids = new ArrayList<>(); 16 | 17 | @Override 18 | public void serialize(Serializer serializer) 19 | { 20 | slot = serializer.struct(slot, SlotID.class); 21 | ids = serializer.arraylist(ids, StreamingID.class); 22 | } 23 | 24 | @Override 25 | public int getAllocatedSize() 26 | { 27 | int size = StartPoint.BASE_ALLOCATION_SIZE; 28 | if (this.ids != null) 29 | { 30 | for (StreamingID id : this.ids) 31 | size += id.getAllocatedSize(); 32 | } 33 | return size; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/mesh/CullBone.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.mesh; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.serializer.Serializer; 5 | import org.joml.Matrix4f; 6 | import org.joml.Vector4f; 7 | 8 | /** 9 | * Bones that control the render culling of a model. 10 | */ 11 | public class CullBone implements Serializable 12 | { 13 | public static final int BASE_ALLOCATION_SIZE = 0x60; 14 | 15 | public Matrix4f invSkinPoseMatrix; 16 | public Vector4f boundBoxMin; 17 | public Vector4f boundBoxMax; 18 | 19 | @Override 20 | public void serialize(Serializer serializer) 21 | { 22 | invSkinPoseMatrix = serializer.m44(invSkinPoseMatrix); 23 | boundBoxMin = serializer.v4(boundBoxMin); 24 | boundBoxMax = serializer.v4(boundBoxMax); 25 | } 26 | 27 | @Override 28 | public int getAllocatedSize() 29 | { 30 | return BASE_ALLOCATION_SIZE; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/mesh/ImplicitEllipsoid.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.mesh; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.serializer.Serializer; 5 | import org.joml.Matrix4f; 6 | 7 | public class ImplicitEllipsoid implements Serializable 8 | { 9 | public static final int BASE_ALLOCATION_SIZE = 0x50; 10 | 11 | public Matrix4f transform; 12 | public int parentBone, affectWorldOnly; 13 | 14 | @Override 15 | public void serialize(Serializer serializer) 16 | { 17 | transform = serializer.m44(transform); 18 | parentBone = serializer.i32(parentBone); 19 | affectWorldOnly = serializer.i32(affectWorldOnly); 20 | } 21 | 22 | @Override 23 | public int getAllocatedSize() 24 | { 25 | return BASE_ALLOCATION_SIZE; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/mesh/ImplicitPlane.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.mesh; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.serializer.Serializer; 5 | import org.joml.Vector4f; 6 | 7 | public class ImplicitPlane implements Serializable 8 | { 9 | public static final int BASE_ALLOCATION_SIZE = 0x30; 10 | 11 | public Vector4f planeNormal, pointInPlane; 12 | public int parentBone; 13 | 14 | @Override 15 | public void serialize(Serializer serializer) 16 | { 17 | planeNormal = serializer.v4(planeNormal); 18 | pointInPlane = serializer.v4(pointInPlane); 19 | parentBone = serializer.i32(parentBone); 20 | } 21 | 22 | @Override 23 | public int getAllocatedSize() 24 | { 25 | return BASE_ALLOCATION_SIZE; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/mesh/MeshShapeInfo.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.mesh; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.serializer.Serializer; 5 | 6 | public class MeshShapeInfo implements Serializable 7 | { 8 | public static final int BASE_ALLOCATION_SIZE = 0x8; 9 | 10 | public int numVerts; 11 | public boolean isPointCloud; 12 | 13 | @Override 14 | public void serialize(Serializer serializer) 15 | { 16 | numVerts = serializer.i32(numVerts); 17 | isPointCloud = serializer.intbool(isPointCloud); 18 | } 19 | 20 | @Override 21 | public int getAllocatedSize() 22 | { 23 | return BASE_ALLOCATION_SIZE; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/mesh/MeshShapeVertex.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.mesh; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.serializer.Serializer; 5 | import org.joml.Vector4f; 6 | 7 | public class MeshShapeVertex implements Serializable 8 | { 9 | public static final int BASE_ALLOCATION_SIZE = 0x24; 10 | 11 | public Vector4f localPos, localNormal; 12 | public int boneIndex; 13 | 14 | @Override 15 | public void serialize(Serializer serializer) 16 | { 17 | localPos = serializer.v4(localPos); 18 | localNormal = serializer.v4(localNormal); 19 | boneIndex = serializer.i32(boneIndex); 20 | } 21 | 22 | @Override 23 | public int getAllocatedSize() 24 | { 25 | return BASE_ALLOCATION_SIZE; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/mesh/Morph.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.mesh; 2 | 3 | import org.joml.Vector3f; 4 | 5 | /** 6 | * Represents mesh deformations. 7 | */ 8 | public class Morph 9 | { 10 | /** 11 | * Relative offset of each vertex. 12 | */ 13 | public Vector3f[] offsets; 14 | 15 | /** 16 | * New normals for each vertex. 17 | */ 18 | public Vector3f[] normals; 19 | 20 | /** 21 | * Creates a morph from offset and normal data. 22 | * 23 | * @param offsets Relative offsets of each vertex 24 | * @param normals New normals for each vertex 25 | */ 26 | public Morph(Vector3f[] offsets, Vector3f[] normals) 27 | { 28 | this.offsets = offsets; 29 | this.normals = normals; 30 | } 31 | 32 | public Vector3f[] getOffsets() 33 | { 34 | return this.offsets; 35 | } 36 | 37 | public Vector3f[] getNormals() 38 | { 39 | return this.normals; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/mesh/SoftbodySpring.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.mesh; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.serializer.Serializer; 5 | 6 | public class SoftbodySpring implements Serializable 7 | { 8 | public static final int BASE_ALLOCATION_SIZE = 0x10; 9 | 10 | public short A, B; 11 | public float restLengthSq; 12 | 13 | public SoftbodySpring() { } 14 | 15 | public SoftbodySpring(int a, int b, float restLengthSq) 16 | { 17 | this.A = (short) a; 18 | this.B = (short) b; 19 | this.restLengthSq = restLengthSq; 20 | } 21 | 22 | @Override 23 | public void serialize(Serializer serializer) 24 | { 25 | A = serializer.i16(A); 26 | B = serializer.i16(B); 27 | restLengthSq = serializer.f32(restLengthSq); 28 | } 29 | 30 | @Override 31 | public int getAllocatedSize() 32 | { 33 | return BASE_ALLOCATION_SIZE; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/mesh/SoftbodyVertEquivalence.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.mesh; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.serializer.Serializer; 5 | 6 | public class SoftbodyVertEquivalence implements Serializable 7 | { 8 | public static final int BASE_ALLOCATION_SIZE = 0x4; 9 | 10 | public short first, count; 11 | 12 | public SoftbodyVertEquivalence() { } 13 | 14 | public SoftbodyVertEquivalence(int first, int count) 15 | { 16 | this.first = (short) first; 17 | this.count = (short) count; 18 | } 19 | 20 | @Override 21 | public void serialize(Serializer serializer) 22 | { 23 | first = serializer.i16(first); 24 | count = serializer.i16(count); 25 | } 26 | 27 | @Override 28 | public int getAllocatedSize() 29 | { 30 | return BASE_ALLOCATION_SIZE; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/mesh/Submesh.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.mesh; 2 | 3 | import org.joml.Matrix4f; 4 | 5 | public class Submesh 6 | { 7 | public Matrix4f transform; 8 | public int locator; 9 | public boolean skinned; 10 | public Primitive[] primitives; 11 | } 12 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/profile/CollectableData.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.profile; 2 | 3 | import cwlib.enums.ResourceType; 4 | import cwlib.io.Serializable; 5 | import cwlib.io.serializer.Serializer; 6 | import cwlib.types.data.ResourceDescriptor; 7 | 8 | public class CollectableData implements Serializable 9 | { 10 | public static final int BASE_ALLOCATION_SIZE = 0x30; 11 | 12 | public ResourceDescriptor plan; 13 | public int source; 14 | 15 | // -1 =invalid 16 | // 0 = egg 17 | // 1 = award_complete 18 | // 2 = award_collect 19 | // 3 = award_ace 20 | 21 | @Override 22 | public void serialize(Serializer serializer) 23 | { 24 | if (serializer.getRevision().getVersion() >= 0x1c2) 25 | { 26 | plan = serializer.resource(plan, ResourceType.PLAN, true); 27 | source = serializer.s32(source); 28 | } 29 | } 30 | 31 | @Override 32 | public int getAllocatedSize() 33 | { 34 | return CollectableData.BASE_ALLOCATION_SIZE; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/profile/CollectedBubble.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.profile; 2 | 3 | import cwlib.enums.ResourceType; 4 | import cwlib.io.Serializable; 5 | import cwlib.io.serializer.Serializer; 6 | import cwlib.types.data.ResourceDescriptor; 7 | 8 | public class CollectedBubble implements Serializable 9 | { 10 | public static final int BASE_ALLOCATION_SIZE = 0x50; 11 | 12 | public ResourceDescriptor level; 13 | public int thingUID; 14 | public ResourceDescriptor plan; 15 | 16 | @Override 17 | public void serialize(Serializer serializer) 18 | { 19 | level = serializer.resource(level, ResourceType.LEVEL, true); 20 | thingUID = serializer.i32(thingUID); 21 | plan = serializer.resource(plan, ResourceType.PLAN, true); 22 | } 23 | 24 | @Override 25 | public int getAllocatedSize() 26 | { 27 | return CollectedBubble.BASE_ALLOCATION_SIZE; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/profile/DataLabel.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.profile; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.serializer.Serializer; 5 | 6 | public class DataLabel implements Serializable 7 | { 8 | public static final int BASE_ALLOCATION_SIZE = 0x8; 9 | 10 | public int labelIndex; 11 | public String name; 12 | 13 | @Override 14 | public void serialize(Serializer serializer) 15 | { 16 | labelIndex = serializer.i32(labelIndex); 17 | name = serializer.wstr(name); 18 | } 19 | 20 | @Override 21 | public int getAllocatedSize() 22 | { 23 | int size = DataLabel.BASE_ALLOCATION_SIZE; 24 | if (this.name != null) 25 | size += (this.name.length() * 2); 26 | return size; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/profile/GoPlayCache.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.profile; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.serializer.Serializer; 5 | import cwlib.structs.slot.SlotID; 6 | 7 | public class GoPlayCache implements Serializable 8 | { 9 | public static final int BASE_ALLOCATION_SIZE = 0x20; 10 | 11 | public SlotID levelID; 12 | public SlotID planetID; 13 | public byte numBubbleCollected; 14 | public byte awardLevelComplete; 15 | public byte awardCollectAll; 16 | public byte awardAcedLevel; 17 | 18 | @Override 19 | public void serialize(Serializer serializer) 20 | { 21 | levelID = serializer.struct(levelID, SlotID.class); 22 | planetID = serializer.struct(planetID, SlotID.class); 23 | 24 | numBubbleCollected = serializer.i8(numBubbleCollected); 25 | awardLevelComplete = serializer.i8(awardLevelComplete); 26 | awardCollectAll = serializer.i8(awardCollectAll); 27 | awardAcedLevel = serializer.i8(awardAcedLevel); 28 | } 29 | 30 | @Override 31 | public int getAllocatedSize() 32 | { 33 | return GoPlayCache.BASE_ALLOCATION_SIZE; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/profile/InventoryPage.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.profile; 2 | 3 | import cwlib.enums.InventorySortMode; 4 | import cwlib.io.Serializable; 5 | import cwlib.io.serializer.Serializer; 6 | 7 | public class InventoryPage implements Serializable 8 | { 9 | public static final int BASE_ALLOCATION_SIZE = 0x10; 10 | 11 | public int inventoryPageTitleKey; 12 | public InventorySortMode desiredSortMode = InventorySortMode.INVALID; 13 | 14 | @Override 15 | public void serialize(Serializer serializer) 16 | { 17 | inventoryPageTitleKey = serializer.i32(inventoryPageTitleKey); 18 | desiredSortMode = serializer.enum32(desiredSortMode); 19 | } 20 | 21 | @Override 22 | public int getAllocatedSize() 23 | { 24 | return InventoryPage.BASE_ALLOCATION_SIZE; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/profile/InventoryView.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.profile; 2 | 3 | import cwlib.enums.InventorySortMode; 4 | import cwlib.io.Serializable; 5 | import cwlib.io.serializer.Serializer; 6 | 7 | public class InventoryView implements Serializable 8 | { 9 | public static final int BASE_ALLOCATION_SIZE = 0x20; 10 | 11 | public int type; 12 | public int subType; 13 | public String title; 14 | public boolean heartedOnly; 15 | public int customID; 16 | public InventorySortMode currentSortMode = InventorySortMode.INVALID; 17 | public InventorySortMode desiredSortMode = InventorySortMode.INVALID; 18 | 19 | @Override 20 | public void serialize(Serializer serializer) 21 | { 22 | type = serializer.i32(type); 23 | subType = serializer.i32(subType); 24 | title = serializer.wstr(title); 25 | heartedOnly = serializer.bool(heartedOnly); 26 | customID = serializer.i32(customID); 27 | currentSortMode = serializer.enum32(currentSortMode); 28 | desiredSortMode = serializer.enum32(desiredSortMode); 29 | } 30 | 31 | @Override 32 | public int getAllocatedSize() 33 | { 34 | int size = InventoryView.BASE_ALLOCATION_SIZE; 35 | if (this.title != null) 36 | size += (this.title.length() * 2); 37 | return size; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/profile/LegacyInventoryCollection.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.profile; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.serializer.Serializer; 5 | 6 | public class LegacyInventoryCollection implements Serializable 7 | { 8 | public static final int BASE_ALLOCATION_SIZE = 0x10; 9 | 10 | public InventoryView[] inventoryViews; 11 | public int currentPageNumber; 12 | public int collectionID; 13 | public int actionOnItemSelect; 14 | 15 | @Override 16 | public void serialize(Serializer serializer) 17 | { 18 | inventoryViews = 19 | serializer.array(inventoryViews, InventoryView.class, true); 20 | 21 | currentPageNumber = serializer.i32(currentPageNumber); 22 | collectionID = serializer.i32(collectionID); 23 | actionOnItemSelect = serializer.i32(actionOnItemSelect); 24 | } 25 | 26 | @Override 27 | public int getAllocatedSize() 28 | { 29 | int size = LegacyInventoryCollection.BASE_ALLOCATION_SIZE; 30 | if (this.inventoryViews != null) 31 | for (InventoryView view : this.inventoryViews) 32 | size += view.getAllocatedSize(); 33 | return size; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/profile/MysteryPodEventSeen.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.profile; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.serializer.Serializer; 5 | 6 | /** 7 | * I don't think either of these variable 8 | * names or correct, or if this is actually some 9 | * other structure, but only place I've seen it used, 10 | * so whatever. 11 | */ 12 | public class MysteryPodEventSeen implements Serializable 13 | { 14 | public static final int BASE_ALLOCATION_SIZE = 0x10; 15 | 16 | public int id; 17 | public int type; 18 | 19 | @Override 20 | public void serialize(Serializer serializer) 21 | { 22 | id = serializer.i32(id); 23 | type = serializer.s32(type); 24 | } 25 | 26 | @Override 27 | public int getAllocatedSize() 28 | { 29 | return MysteryPodEventSeen.BASE_ALLOCATION_SIZE; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/profile/PaintProperties.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.profile; 2 | 3 | import cwlib.enums.ResourceType; 4 | import cwlib.enums.Revisions; 5 | import cwlib.io.Serializable; 6 | import cwlib.io.gson.GsonRevision; 7 | import cwlib.io.serializer.Serializer; 8 | import cwlib.types.data.ResourceDescriptor; 9 | 10 | public class PaintProperties implements Serializable 11 | { 12 | public static final int BASE_ALLOCATION_SIZE = 0x40; 13 | 14 | public int triggerOverride, stickerSaveSize; 15 | public boolean angleOverride, uiHidden; 16 | public ResourceDescriptor lastAutoSave; 17 | 18 | @GsonRevision(min = Revisions.PTG_USE_DEFAULT_BACKGROUND) 19 | public boolean useDefaultBackground; 20 | 21 | @Override 22 | public void serialize(Serializer serializer) 23 | { 24 | triggerOverride = serializer.i32(triggerOverride); 25 | stickerSaveSize = serializer.i32(stickerSaveSize); 26 | angleOverride = serializer.bool(angleOverride); 27 | uiHidden = serializer.bool(uiHidden); 28 | lastAutoSave = serializer.resource(lastAutoSave, 29 | ResourceType.PAINTING, true); 30 | if (serializer.getRevision().getVersion() >= Revisions.PTG_USE_DEFAULT_BACKGROUND) 31 | useDefaultBackground = serializer.bool(useDefaultBackground); 32 | } 33 | 34 | @Override 35 | public int getAllocatedSize() 36 | { 37 | return PaintProperties.BASE_ALLOCATION_SIZE; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/profile/PinAward.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.profile; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.serializer.Serializer; 5 | 6 | public class PinAward implements Serializable 7 | { 8 | public static final int BASE_ALLOCATION_SIZE = 0x10; 9 | 10 | public int pinID, awardCount; 11 | 12 | @Override 13 | public void serialize(Serializer serializer) 14 | { 15 | pinID = serializer.i32(pinID); 16 | awardCount = serializer.i32(awardCount); 17 | } 18 | 19 | @Override 20 | public int getAllocatedSize() 21 | { 22 | return PinAward.BASE_ALLOCATION_SIZE; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/profile/PinProgress.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.profile; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.serializer.Serializer; 5 | 6 | public class PinProgress implements Serializable 7 | { 8 | public static final int BASE_ALLOCATION_SIZE = 0x10; 9 | 10 | public int progressType, progressCount; 11 | 12 | @Override 13 | public void serialize(Serializer serializer) 14 | { 15 | progressType = serializer.i32(progressType); 16 | progressCount = serializer.i32(progressCount); 17 | } 18 | 19 | @Override 20 | public int getAllocatedSize() 21 | { 22 | return PinProgress.BASE_ALLOCATION_SIZE; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/profile/PlayerDataLabels.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.profile; 2 | 3 | import cwlib.enums.Branch; 4 | import cwlib.enums.Revisions; 5 | import cwlib.io.Serializable; 6 | import cwlib.io.serializer.Serializer; 7 | import cwlib.types.data.NetworkOnlineID; 8 | import cwlib.types.data.Revision; 9 | 10 | public class PlayerDataLabels implements Serializable 11 | { 12 | public static final int BASE_ALLOCATION_SIZE = 0x10; 13 | 14 | public DataLabelValue[] values; 15 | public NetworkOnlineID[] protectedIds; 16 | 17 | @Override 18 | public void serialize(Serializer serializer) 19 | { 20 | Revision revision = serializer.getRevision(); 21 | int head = revision.getVersion(); 22 | 23 | values = serializer.array(values, DataLabelValue.class); 24 | if (revision.has(Branch.DOUBLE11, Revisions.D1_PROTECTED_LABELS) || head >= Revisions.DATALABELS) 25 | protectedIds = serializer.array(protectedIds, NetworkOnlineID.class); 26 | } 27 | 28 | @Override 29 | public int getAllocatedSize() 30 | { 31 | int size = PlayerDataLabels.BASE_ALLOCATION_SIZE; 32 | if (this.values != null) 33 | for (DataLabelValue value : this.values) 34 | size += value.getAllocatedSize(); 35 | if (this.protectedIds != null) 36 | size += (this.protectedIds.length * NetworkOnlineID.BASE_ALLOCATION_SIZE); 37 | return size; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/profile/SlotLink.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.profile; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.serializer.Serializer; 5 | import cwlib.structs.slot.SlotID; 6 | 7 | public class SlotLink implements Serializable 8 | { 9 | public static final int BASE_ALLOCATION_SIZE = 0x10; 10 | 11 | public SlotID from = new SlotID(); 12 | public SlotID to = new SlotID(); 13 | 14 | @Override 15 | public void serialize(Serializer serializer) 16 | { 17 | from = serializer.struct(from, SlotID.class); 18 | to = serializer.struct(to, SlotID.class); 19 | } 20 | 21 | @Override 22 | public int getAllocatedSize() 23 | { 24 | return SlotLink.BASE_ALLOCATION_SIZE; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/profile/Treasure.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.profile; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.serializer.Serializer; 5 | 6 | public class Treasure implements Serializable 7 | { 8 | public static final int BASE_ALLOCATION_SIZE = 0x10; 9 | 10 | public int treasureID; 11 | public int planID; 12 | public int timestamp; 13 | 14 | @Override 15 | public void serialize(Serializer serializer) 16 | { 17 | treasureID = serializer.i32(treasureID); 18 | planID = serializer.i32(planID); 19 | timestamp = serializer.i32(timestamp); 20 | } 21 | 22 | @Override 23 | public int getAllocatedSize() 24 | { 25 | return Treasure.BASE_ALLOCATION_SIZE; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/profile/ViewedLevelData.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.profile; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.serializer.Serializer; 5 | import cwlib.structs.slot.SlotID; 6 | 7 | public class ViewedLevelData implements Serializable 8 | { 9 | public static final int BASE_ALLOCATION_SIZE = 0x30; 10 | 11 | public SlotID slotID; 12 | public int lastReviewCount; 13 | public int lastCommentCount; 14 | public int lastPhotoCount; 15 | public int lastAuthorPhotoCount; 16 | public long lastStreamEventTimestamp; 17 | public long lastViewedTimestamp; 18 | 19 | @Override 20 | public void serialize(Serializer serializer) 21 | { 22 | slotID = serializer.struct(slotID, SlotID.class); 23 | lastReviewCount = serializer.s32(lastReviewCount); 24 | lastCommentCount = serializer.s32(lastCommentCount); 25 | lastPhotoCount = serializer.s32(lastPhotoCount); 26 | lastAuthorPhotoCount = serializer.s32(lastAuthorPhotoCount); 27 | lastStreamEventTimestamp = serializer.s64(lastStreamEventTimestamp); 28 | lastViewedTimestamp = serializer.s64(lastViewedTimestamp); 29 | } 30 | 31 | @Override 32 | public int getAllocatedSize() 33 | { 34 | return ViewedLevelData.BASE_ALLOCATION_SIZE; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/script/FieldDefinitionRow.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.script; 2 | 3 | import cwlib.enums.ModifierType; 4 | import cwlib.io.Serializable; 5 | import cwlib.io.serializer.Serializer; 6 | 7 | import java.util.EnumSet; 8 | 9 | public class FieldDefinitionRow implements Serializable 10 | { 11 | public static final int BASE_ALLOCATION_SIZE = 0x20; 12 | 13 | public EnumSet modifiers = EnumSet.noneOf(ModifierType.class); 14 | public int typeReferenceIdx; 15 | public int nameStringIdx; 16 | 17 | @Override 18 | public void serialize(Serializer serializer) 19 | { 20 | int version = serializer.getRevision().getVersion(); 21 | if (serializer.isWriting()) 22 | { 23 | short flags = ModifierType.getFlags(modifiers); 24 | if (version >= 0x3d9) serializer.getOutput().i16(flags); 25 | else serializer.getOutput().i32(flags); 26 | } 27 | else 28 | { 29 | int flags = (version >= 0x3d9) ? serializer.getInput().i16() : 30 | serializer.getInput().i32(); 31 | modifiers = ModifierType.fromValue(flags); 32 | } 33 | 34 | typeReferenceIdx = serializer.i32(typeReferenceIdx); 35 | nameStringIdx = serializer.i32(nameStringIdx); 36 | } 37 | 38 | @Override 39 | public int getAllocatedSize() 40 | { 41 | return FieldDefinitionRow.BASE_ALLOCATION_SIZE; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/script/FieldReferenceRow.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.script; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.serializer.Serializer; 5 | 6 | public class FieldReferenceRow implements Serializable 7 | { 8 | public static final int BASE_ALLOCATION_SIZE = 0x10; 9 | 10 | public int typeReferenceIdx; 11 | public int nameStringIdx; 12 | 13 | @Override 14 | public void serialize(Serializer serializer) 15 | { 16 | typeReferenceIdx = serializer.i32(typeReferenceIdx); 17 | nameStringIdx = serializer.i32(nameStringIdx); 18 | } 19 | 20 | @Override 21 | public int getAllocatedSize() 22 | { 23 | return FieldReferenceRow.BASE_ALLOCATION_SIZE; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/script/FunctionReferenceRow.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.script; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.serializer.Serializer; 5 | 6 | public class FunctionReferenceRow implements Serializable 7 | { 8 | public static final int BASE_ALLOCATION_SIZE = 0x10; 9 | 10 | public int typeReferenceIdx; 11 | public int nameStringIdx; 12 | 13 | @Override 14 | public void serialize(Serializer serializer) 15 | { 16 | typeReferenceIdx = serializer.i32(typeReferenceIdx); 17 | nameStringIdx = serializer.i32(nameStringIdx); 18 | } 19 | 20 | @Override 21 | public int getAllocatedSize() 22 | { 23 | return FunctionReferenceRow.BASE_ALLOCATION_SIZE; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/script/Instruction.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.script; 2 | 3 | import cwlib.enums.InstructionClass; 4 | import cwlib.enums.InstructionType; 5 | 6 | public abstract class Instruction 7 | { 8 | private final InstructionType instruction; 9 | public transient boolean visited = false; 10 | 11 | protected Instruction(InstructionType type) 12 | { 13 | this.instruction = type; 14 | } 15 | 16 | public InstructionType getInstructionType() 17 | { 18 | return this.instruction; 19 | } 20 | 21 | public InstructionClass getInstructionClass() 22 | { 23 | return this.instruction.getInstructionClass(); 24 | } 25 | 26 | public abstract long getBits(); 27 | 28 | @Override 29 | public String toString() 30 | { 31 | return this.instruction.name(); 32 | } 33 | 34 | public static void main(String[] args) 35 | { 36 | System.out.println(InstructionType.ARRAY_ERASE.getInstructionClass()); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/script/TypeOffset.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.script; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.serializer.Serializer; 5 | 6 | public class TypeOffset implements Serializable 7 | { 8 | public static final int BASE_ALLOCATION_SIZE = 0x10; 9 | 10 | public int typeReferenceIdx; 11 | public int offset; 12 | 13 | @Override 14 | public void serialize(Serializer serializer) 15 | { 16 | typeReferenceIdx = serializer.i32(typeReferenceIdx); 17 | offset = serializer.i32(offset); 18 | } 19 | 20 | @Override 21 | public int getAllocatedSize() 22 | { 23 | return TypeOffset.BASE_ALLOCATION_SIZE; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/script/instructions/ArgInstruction.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.script.instructions; 2 | 3 | import cwlib.enums.InstructionType; 4 | import cwlib.enums.MachineType; 5 | import cwlib.structs.script.Instruction; 6 | 7 | public class ArgInstruction extends Instruction 8 | { 9 | /** 10 | * Address to store value in argument list. 11 | */ 12 | public short argument = -1; 13 | 14 | /** 15 | * Address of value in stack. 16 | */ 17 | public short source = -1; 18 | 19 | /** 20 | * Type of value being stored. 21 | */ 22 | public MachineType type = MachineType.VOID; 23 | 24 | public ArgInstruction(InstructionType type) 25 | { 26 | super(type); 27 | } 28 | 29 | public ArgInstruction(long bits) 30 | { 31 | super(InstructionType.fromValue((int) (bits & 0xff))); 32 | 33 | this.argument = (short) ((bits >>> 32) & 0xffff); 34 | this.source = (short) ((bits >>> 16) & 0xffff); 35 | this.type = MachineType.fromValue((int) ((bits >> 8) & 0xff)); 36 | } 37 | 38 | @Override 39 | public long getBits() 40 | { 41 | long arg = this.argument & 0xffff; 42 | long src = this.source & 0xffff; 43 | long type = this.type.getValue(); 44 | long op = this.getInstructionType().getValue(); 45 | 46 | return (arg << 32) | (src << 16) | (type << 8) | op; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/script/instructions/BinaryInstruction.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.script.instructions; 2 | 3 | import cwlib.enums.InstructionType; 4 | import cwlib.structs.script.Instruction; 5 | 6 | public class BinaryInstruction extends Instruction 7 | { 8 | /** 9 | * Address of B in stack 10 | */ 11 | public short b = -1; 12 | 13 | /** 14 | * Address of A in stack 15 | */ 16 | public short a = -1; 17 | 18 | /** 19 | * Address in stack to store result 20 | */ 21 | public short dest = -1; 22 | 23 | public BinaryInstruction(InstructionType type) 24 | { 25 | super(type); 26 | } 27 | 28 | public BinaryInstruction(long bits) 29 | { 30 | super(InstructionType.fromValue((int) (bits & 0xff))); 31 | 32 | int source = (int) (bits >>> 32); 33 | this.a = (short) (source & 0xffff); 34 | this.b = (short) ((source >>> 16) & 0xffff); 35 | 36 | this.dest = (short) ((bits >>> 16) & 0xffff); 37 | } 38 | 39 | @Override 40 | public long getBits() 41 | { 42 | return (((((long) this.b & 0xffff) << 16) | ((long) (this.a & 0xffff))) << 32) | 43 | (((long) (this.dest & 0xffff)) << 16) | 44 | ((long) (this.getInstructionType().getValue())); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/script/instructions/BranchInstruction.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.script.instructions; 2 | 3 | import cwlib.enums.InstructionType; 4 | import cwlib.structs.script.Instruction; 5 | 6 | public class BranchInstruction extends Instruction 7 | { 8 | /** 9 | * Relative offset to branch to 10 | */ 11 | public int offset; 12 | 13 | /** 14 | * Address of conditional result in stack. 15 | */ 16 | public short source; 17 | 18 | public BranchInstruction(InstructionType type) 19 | { 20 | super(type); 21 | } 22 | 23 | public BranchInstruction(long bits) 24 | { 25 | super(InstructionType.fromValue((int) (bits & 0xff))); 26 | 27 | this.offset = (int) (bits >>> 32); 28 | this.source = (short) ((bits >>> 16) & 0xffff); 29 | } 30 | 31 | @Override 32 | public long getBits() 33 | { 34 | return (((long) this.offset) << 32) | 35 | (((long) (this.source & 0xffff)) << 16) | 36 | ((long) (this.getInstructionType().getValue())); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/script/instructions/CallInstruction.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.script.instructions; 2 | 3 | import cwlib.enums.InstructionType; 4 | import cwlib.enums.MachineType; 5 | import cwlib.structs.script.Instruction; 6 | 7 | public class CallInstruction extends Instruction 8 | { 9 | /** 10 | * Index of function reference 11 | */ 12 | public short call; 13 | 14 | /** 15 | * Address in stack to store result 16 | */ 17 | public short dest; 18 | 19 | /** 20 | * Return type of function to call. 21 | */ 22 | public MachineType type; 23 | 24 | public CallInstruction(InstructionType type) 25 | { 26 | super(type); 27 | } 28 | 29 | public CallInstruction(long bits) 30 | { 31 | super(InstructionType.fromValue((int) (bits & 0xff))); 32 | 33 | this.call = (short) ((bits >>> 32) & 0xffff); 34 | this.dest = (short) ((bits >>> 16) & 0xffff); 35 | this.type = MachineType.fromValue((int) ((bits >>> 8) & 0xff)); 36 | } 37 | 38 | @Override 39 | public long getBits() 40 | { 41 | return (((long) this.call) << 32) | 42 | (((long) (this.dest & 0xffff)) << 16) | 43 | (((long) (this.type.getValue() & 0xff)) << 8) | 44 | ((long) (this.getInstructionType().getValue() & 0xff)); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/script/instructions/CastInstruction.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.script.instructions; 2 | 3 | import cwlib.enums.InstructionType; 4 | import cwlib.structs.script.Instruction; 5 | 6 | public class CastInstruction extends Instruction 7 | { 8 | /** 9 | * Index of type reference 10 | */ 11 | public short type; 12 | 13 | /** 14 | * Address of value in stack. 15 | */ 16 | public short source; 17 | 18 | /** 19 | * Address in stack to store result 20 | */ 21 | public short dest; 22 | 23 | public CastInstruction(InstructionType type) 24 | { 25 | super(type); 26 | } 27 | 28 | public CastInstruction(long bits) 29 | { 30 | super(InstructionType.fromValue((int) (bits & 0xff))); 31 | 32 | this.type = (short) ((bits >>> 48) & 0xffff); 33 | this.source = (short) ((bits >>> 32) & 0xffff); 34 | this.dest = (short) ((bits >>> 16) & 0xffff); 35 | } 36 | 37 | @Override 38 | public long getBits() 39 | { 40 | return (((long) this.type & 0xffff) << 48) | 41 | (((long) this.source & 0xffff) << 32) | 42 | (((long) (this.dest & 0xffff)) << 16) | 43 | ((long) (this.getInstructionType().getValue())); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/script/instructions/GetBuiltInMemberInstruction.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.script.instructions; 2 | 3 | import cwlib.enums.InstructionType; 4 | import cwlib.structs.script.Instruction; 5 | 6 | public class GetBuiltInMemberInstruction extends Instruction 7 | { 8 | /** 9 | * Address of value in stack. 10 | */ 11 | public short base; 12 | 13 | /** 14 | * Address in stack to store result 15 | */ 16 | public short dest; 17 | 18 | public GetBuiltInMemberInstruction(InstructionType type) 19 | { 20 | super(type); 21 | } 22 | 23 | public GetBuiltInMemberInstruction(long bits) 24 | { 25 | super(InstructionType.fromValue((int) (bits & 0xff))); 26 | 27 | this.base = (short) ((bits >>> 32) & 0xffff); 28 | this.dest = (short) ((bits >>> 16) & 0xffff); 29 | } 30 | 31 | @Override 32 | public long getBits() 33 | { 34 | return (((long) this.base & 0xffff) << 32) | 35 | (((long) (this.dest & 0xffff)) << 16) | 36 | ((long) (this.getInstructionType().getValue())); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/script/instructions/LoadConstInstruction.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.script.instructions; 2 | 3 | import cwlib.enums.InstructionType; 4 | import cwlib.structs.script.Instruction; 5 | 6 | public class LoadConstInstruction extends Instruction 7 | { 8 | /** 9 | * Index of constant. 10 | */ 11 | public int index; 12 | 13 | /** 14 | * Address in stack to store constant. 15 | */ 16 | public short dest; 17 | 18 | public LoadConstInstruction(InstructionType type) 19 | { 20 | super(type); 21 | } 22 | 23 | public LoadConstInstruction(long bits) 24 | { 25 | super(InstructionType.fromValue((int) (bits & 0xff))); 26 | 27 | this.index = (int) (bits >>> 32); 28 | this.dest = (short) ((bits >>> 16) & 0xffff); 29 | } 30 | 31 | @Override 32 | public long getBits() 33 | { 34 | return (((long) this.index) << 32) | 35 | (((long) (this.dest & 0xffff)) << 16) | 36 | ((long) (this.getInstructionType().getValue())); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/script/instructions/LoadConstInstructionBool.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.script.instructions; 2 | 3 | import cwlib.enums.InstructionType; 4 | import cwlib.structs.script.Instruction; 5 | 6 | public class LoadConstInstructionBool extends Instruction 7 | { 8 | /** 9 | * Constant value. 10 | */ 11 | public boolean value; 12 | 13 | /** 14 | * Address in stack to store constant. 15 | */ 16 | public short dest; 17 | 18 | public LoadConstInstructionBool(InstructionType type) 19 | { 20 | super(type); 21 | } 22 | 23 | public LoadConstInstructionBool(long bits) 24 | { 25 | super(InstructionType.fromValue((int) (bits & 0xff))); 26 | 27 | this.value = (bits >>> 63) != 0; 28 | this.dest = (short) ((bits >>> 16) & 0xffff); 29 | } 30 | 31 | @Override 32 | public long getBits() 33 | { 34 | return ((this.value ? 1L : 0L) << 63) | 35 | (((long) (this.dest & 0xffff)) << 16) | 36 | ((long) (this.getInstructionType().getValue())); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/script/instructions/LoadConstInstructionChar.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.script.instructions; 2 | 3 | import cwlib.enums.InstructionType; 4 | import cwlib.structs.script.Instruction; 5 | 6 | public class LoadConstInstructionChar extends Instruction 7 | { 8 | /** 9 | * Constant value. 10 | */ 11 | public char value; 12 | 13 | /** 14 | * Address in stack to store constant. 15 | */ 16 | public short dest; 17 | 18 | public LoadConstInstructionChar(InstructionType type) 19 | { 20 | super(type); 21 | } 22 | 23 | public LoadConstInstructionChar(long bits) 24 | { 25 | super(InstructionType.fromValue((int) (bits & 0xff))); 26 | 27 | this.value = (char) ((bits >>> 48) & 0xffff); 28 | this.dest = (short) ((bits >>> 16) & 0xffff); 29 | } 30 | 31 | @Override 32 | public long getBits() 33 | { 34 | return (((long) this.value & 0xffff) << 48) | 35 | (((long) (this.dest & 0xffff)) << 16) | 36 | ((long) (this.getInstructionType().getValue())); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/script/instructions/LoadConstInstructionFloat.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.script.instructions; 2 | 3 | import cwlib.enums.InstructionType; 4 | import cwlib.structs.script.Instruction; 5 | 6 | public class LoadConstInstructionFloat extends Instruction 7 | { 8 | /** 9 | * Constant value. 10 | */ 11 | public float value; 12 | 13 | /** 14 | * Address in stack to store constant. 15 | */ 16 | public short dest; 17 | 18 | public LoadConstInstructionFloat(InstructionType type) 19 | { 20 | super(type); 21 | } 22 | 23 | public LoadConstInstructionFloat(long bits) 24 | { 25 | super(InstructionType.fromValue((int) (bits & 0xff))); 26 | 27 | this.value = Float.intBitsToFloat((int) (bits >>> 32)); 28 | this.dest = (short) ((bits >>> 16) & 0xffff); 29 | } 30 | 31 | @Override 32 | public long getBits() 33 | { 34 | return (((long) Float.floatToIntBits(this.value)) << 32) | 35 | (((long) (this.dest & 0xffff)) << 16) | 36 | ((long) (this.getInstructionType().getValue())); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/script/instructions/LoadConstInstructionInt.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.script.instructions; 2 | 3 | import cwlib.enums.InstructionType; 4 | import cwlib.structs.script.Instruction; 5 | 6 | public class LoadConstInstructionInt extends Instruction 7 | { 8 | /** 9 | * Constant value. 10 | */ 11 | public int value; 12 | 13 | /** 14 | * Address in stack to store constant. 15 | */ 16 | public short dest; 17 | 18 | public LoadConstInstructionInt(InstructionType type) 19 | { 20 | super(type); 21 | } 22 | 23 | public LoadConstInstructionInt(long bits) 24 | { 25 | super(InstructionType.fromValue((int) (bits & 0xff))); 26 | 27 | this.value = (int) (bits >>> 32); 28 | this.dest = (short) ((bits >>> 16) & 0xffff); 29 | } 30 | 31 | @Override 32 | public long getBits() 33 | { 34 | return (((long) this.value) << 32) | 35 | (((long) (this.dest & 0xffff)) << 16) | 36 | ((long) (this.getInstructionType().getValue())); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/script/instructions/LoadConstInstructionNullSafePtr.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.script.instructions; 2 | 3 | import cwlib.enums.InstructionType; 4 | import cwlib.structs.script.Instruction; 5 | 6 | public class LoadConstInstructionNullSafePtr extends Instruction 7 | { 8 | /** 9 | * Address in stack to store constant. 10 | */ 11 | public short dest; 12 | 13 | public LoadConstInstructionNullSafePtr(InstructionType type) 14 | { 15 | super(type); 16 | } 17 | 18 | public LoadConstInstructionNullSafePtr(long bits) 19 | { 20 | super(InstructionType.fromValue((int) (bits & 0xff))); 21 | this.dest = (short) ((bits >>> 16) & 0xffff); 22 | } 23 | 24 | @Override 25 | public long getBits() 26 | { 27 | return (((long) (this.dest & 0xffff)) << 16) | 28 | ((long) (this.getInstructionType().getValue())); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/script/instructions/NewArrayInstruction.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.script.instructions; 2 | 3 | import cwlib.enums.InstructionType; 4 | import cwlib.structs.script.Instruction; 5 | 6 | public class NewArrayInstruction extends Instruction 7 | { 8 | /** 9 | * Index of type reference 10 | */ 11 | public short type; 12 | 13 | /** 14 | * Address of size value in stack. 15 | */ 16 | public short size; 17 | 18 | /** 19 | * Address in stack to store reference to created array. 20 | */ 21 | public short dest; 22 | 23 | public NewArrayInstruction(InstructionType type) 24 | { 25 | super(type); 26 | } 27 | 28 | public NewArrayInstruction(long bits) 29 | { 30 | super(InstructionType.fromValue((int) (bits & 0xff))); 31 | 32 | this.type = (short) ((bits >>> 48) & 0xffff); 33 | this.size = (short) ((bits >>> 32) & 0xffff); 34 | this.dest = (short) ((bits >>> 16) & 0xffff); 35 | } 36 | 37 | @Override 38 | public long getBits() 39 | { 40 | return (((long) this.type & 0xffff) << 48) | 41 | (((long) this.size & 0xffff) << 32) | 42 | (((long) (this.dest & 0xffff)) << 16) | 43 | ((long) (this.getInstructionType().getValue())); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/script/instructions/NewObjectInstruction.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.script.instructions; 2 | 3 | import cwlib.enums.InstructionType; 4 | import cwlib.structs.script.Instruction; 5 | 6 | public class NewObjectInstruction extends Instruction 7 | { 8 | /** 9 | * Index of type reference. 10 | */ 11 | public short type; 12 | 13 | /** 14 | * Address in stack to store reference to created object. 15 | */ 16 | public short dest; 17 | 18 | public NewObjectInstruction(InstructionType type) 19 | { 20 | super(type); 21 | } 22 | 23 | public NewObjectInstruction(long bits) 24 | { 25 | super(InstructionType.fromValue((int) (bits & 0xff))); 26 | 27 | this.type = (short) ((bits >>> 48) & 0xffff); 28 | this.dest = (short) ((bits >>> 16) & 0xffff); 29 | } 30 | 31 | @Override 32 | public long getBits() 33 | { 34 | return (((long) this.type & 0xffff) << 48) | 35 | (((long) (this.dest & 0xffff)) << 16) | 36 | ((long) (this.getInstructionType().getValue())); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/script/instructions/NopInstruction.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.script.instructions; 2 | 3 | import cwlib.enums.InstructionType; 4 | import cwlib.structs.script.Instruction; 5 | 6 | public class NopInstruction extends Instruction 7 | { 8 | public NopInstruction(InstructionType type) 9 | { 10 | super(type); 11 | } 12 | 13 | public NopInstruction(long bits) 14 | { 15 | super(InstructionType.fromValue((int) (bits & 0xff))); 16 | } 17 | 18 | @Override 19 | public long getBits() 20 | { 21 | return this.getInstructionType().getValue(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/script/instructions/ReturnInstruction.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.script.instructions; 2 | 3 | import cwlib.enums.InstructionType; 4 | import cwlib.enums.MachineType; 5 | import cwlib.structs.script.Instruction; 6 | 7 | public class ReturnInstruction extends Instruction 8 | { 9 | /** 10 | * Address of value in stack. 11 | */ 12 | public short source; 13 | 14 | /** 15 | * Internal type of source value 16 | */ 17 | public MachineType type = MachineType.VOID; 18 | 19 | public ReturnInstruction(InstructionType type) 20 | { 21 | super(type); 22 | } 23 | 24 | public ReturnInstruction(long bits) 25 | { 26 | super(InstructionType.fromValue((int) (bits & 0xff))); 27 | 28 | this.source = (short) ((bits >>> 32) & 0xffff); 29 | this.type = MachineType.fromValue((int) ((bits >>> 8) & 0xff)); 30 | } 31 | 32 | @Override 33 | public long getBits() 34 | { 35 | return (((long) this.source & 0xffff) << 32) | 36 | (((long) (this.type.getValue())) << 8) | 37 | ((long) (this.getInstructionType().getValue())); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/script/instructions/SetBuiltInMemberInstruction.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.script.instructions; 2 | 3 | import cwlib.enums.InstructionType; 4 | import cwlib.structs.script.Instruction; 5 | 6 | public class SetBuiltInMemberInstruction extends Instruction 7 | { 8 | /** 9 | * Address of object in stack. 10 | */ 11 | public short base; 12 | 13 | /** 14 | * Address of value in stack. 15 | */ 16 | public short source; 17 | 18 | public SetBuiltInMemberInstruction(InstructionType type) 19 | { 20 | super(type); 21 | } 22 | 23 | public SetBuiltInMemberInstruction(long bits) 24 | { 25 | super(InstructionType.fromValue((int) (bits & 0xff))); 26 | 27 | this.base = (short) ((bits >>> 32) & 0xffff); 28 | this.source = (short) ((bits >>> 16) & 0xffff); 29 | } 30 | 31 | @Override 32 | public long getBits() 33 | { 34 | return (((long) this.base & 0xffff) << 32) | 35 | (((long) (this.source & 0xffff)) << 16) | 36 | ((long) (this.getInstructionType().getValue())); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/script/instructions/UnaryInstruction.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.script.instructions; 2 | 3 | import cwlib.enums.InstructionType; 4 | import cwlib.structs.script.Instruction; 5 | 6 | public class UnaryInstruction extends Instruction 7 | { 8 | /** 9 | * Address of value in stack. 10 | */ 11 | public short source; 12 | 13 | /** 14 | * Address in stack to store result 15 | */ 16 | public short dest; 17 | 18 | public UnaryInstruction(InstructionType type) 19 | { 20 | super(type); 21 | } 22 | 23 | public UnaryInstruction(long bits) 24 | { 25 | super(InstructionType.fromValue((int) (bits & 0xff))); 26 | 27 | this.source = (short) ((bits >>> 32) & 0xffff); 28 | this.dest = (short) ((bits >>> 16) & 0xffff); 29 | } 30 | 31 | @Override 32 | public long getBits() 33 | { 34 | return (((long) this.source & 0xffff) << 32) | 35 | (((long) (this.dest & 0xffff)) << 16) | 36 | ((long) (this.getInstructionType().getValue())); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/script/instructions/WriteInstruction.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.script.instructions; 2 | 3 | import cwlib.enums.InstructionType; 4 | import cwlib.enums.MachineType; 5 | import cwlib.structs.script.Instruction; 6 | 7 | public class WriteInstruction extends Instruction 8 | { 9 | /** 10 | * Address of value in stack. 11 | */ 12 | public short source; 13 | 14 | /** 15 | * Internal type of source value 16 | */ 17 | public MachineType type = MachineType.VOID; 18 | 19 | public WriteInstruction(InstructionType type) 20 | { 21 | super(type); 22 | } 23 | 24 | public WriteInstruction(long bits) 25 | { 26 | super(InstructionType.fromValue((int) (bits & 0xff))); 27 | 28 | this.source = (short) ((bits >>> 32) & 0xffff); 29 | this.type = MachineType.fromValue((int) ((bits >>> 8) & 0xff)); 30 | } 31 | 32 | @Override 33 | public long getBits() 34 | { 35 | return (((long) this.source & 0xffff) << 32) | 36 | (((long) (this.type.getValue())) << 8) | 37 | ((long) (this.getInstructionType().getValue())); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/slot/Collectabubble.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.slot; 2 | 3 | import cwlib.enums.ResourceType; 4 | import cwlib.io.Serializable; 5 | import cwlib.io.serializer.Serializer; 6 | import cwlib.types.data.ResourceDescriptor; 7 | 8 | public class Collectabubble implements Serializable 9 | { 10 | public static final int BASE_ALLOCATION_SIZE = 0x30; 11 | 12 | public ResourceDescriptor plan; 13 | public int count; 14 | 15 | @Override 16 | public void serialize(Serializer serializer) 17 | { 18 | plan = serializer.resource(plan, ResourceType.PLAN, true); 19 | count = serializer.i32(count); 20 | } 21 | 22 | @Override 23 | public int getAllocatedSize() 24 | { 25 | return Collectabubble.BASE_ALLOCATION_SIZE; 26 | } 27 | } -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/slot/Label.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.slot; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.serializer.Serializer; 5 | 6 | /** 7 | * Represents a label tag that gets 8 | * assigned to a slot. 9 | */ 10 | public class Label implements Serializable 11 | { 12 | public static int BASE_ALLOCATION_SIZE = 0x8; 13 | 14 | public int key; 15 | public int order; 16 | 17 | public Label() { } 18 | 19 | public Label(int key, int order) 20 | { 21 | this.key = key; 22 | this.order = order; 23 | } 24 | 25 | @Override 26 | public void serialize(Serializer serializer) 27 | { 28 | key = serializer.i32(key); 29 | order = serializer.i32(order); 30 | } 31 | 32 | @Override 33 | public int getAllocatedSize() 34 | { 35 | return Label.BASE_ALLOCATION_SIZE; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/staticmesh/StaticPrimitive.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.staticmesh; 2 | 3 | import cwlib.enums.CellGcmPrimitive; 4 | import cwlib.enums.ResourceType; 5 | import cwlib.io.Serializable; 6 | import cwlib.io.serializer.Serializer; 7 | import cwlib.types.data.ResourceDescriptor; 8 | import org.joml.Vector4f; 9 | 10 | public class StaticPrimitive implements Serializable 11 | { 12 | public static final int BASE_ALLOCATION_SIZE = 0x60; 13 | 14 | public Vector4f min, max; 15 | public ResourceDescriptor gmat; 16 | public int vertexStart, indexStart; 17 | public int numIndices; 18 | public CellGcmPrimitive type = CellGcmPrimitive.TRIANGLES; 19 | 20 | /* Not actually serialized, just used for exporting */ 21 | public transient int numVerts; 22 | 23 | @Override 24 | public void serialize(Serializer serializer) 25 | { 26 | min = serializer.v4(min); 27 | max = serializer.v4(max); 28 | gmat = serializer.resource(gmat, ResourceType.GFX_MATERIAL); 29 | vertexStart = serializer.i32(vertexStart); 30 | indexStart = serializer.i32(indexStart); 31 | numIndices = serializer.i32(numIndices); 32 | type = serializer.enum8(type); 33 | } 34 | 35 | @Override 36 | public int getAllocatedSize() 37 | { 38 | return StaticPrimitive.BASE_ALLOCATION_SIZE; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/streaming/QuestSwitch.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.streaming; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.serializer.Serializer; 5 | 6 | public class QuestSwitch implements Serializable 7 | { 8 | public static final int BASE_ALLOCATION_SIZE = 0x10; 9 | 10 | public StreamingID questID; 11 | public int questAction; 12 | public int questKey; 13 | public int objectiveID; 14 | 15 | @Override 16 | public void serialize(Serializer serializer) 17 | { 18 | int subVersion = serializer.getRevision().getSubVersion(); 19 | 20 | if (subVersion > 0x118) 21 | { 22 | questID = serializer.struct(questID, StreamingID.class); 23 | questAction = serializer.i32(questAction); 24 | } 25 | 26 | if (subVersion > 0x140) 27 | questKey = serializer.i32(questKey); 28 | 29 | if (subVersion > 0x17a) 30 | objectiveID = serializer.i32(objectiveID); 31 | } 32 | 33 | @Override 34 | public int getAllocatedSize() 35 | { 36 | int size = QuestSwitch.BASE_ALLOCATION_SIZE; 37 | if (this.questID != null) 38 | size += this.questID.getAllocatedSize(); 39 | return size; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/streaming/StreamingID.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.streaming; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.serializer.Serializer; 5 | 6 | public class StreamingID implements Serializable 7 | { 8 | public static final int BASE_ALLOCATION_SIZE = 0x30; 9 | 10 | public String name; 11 | public int type; 12 | 13 | @Override 14 | public void serialize(Serializer serializer) 15 | { 16 | name = serializer.wstr(name); 17 | type = serializer.i32(type); 18 | } 19 | 20 | @Override 21 | public int getAllocatedSize() 22 | { 23 | int size = StreamingID.BASE_ALLOCATION_SIZE; 24 | if (this.name != null) 25 | size += (this.name.length() * 0x2); 26 | return size; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/things/components/CameraNode.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.things.components; 2 | 3 | import org.joml.Vector3f; 4 | import org.joml.Vector4f; 5 | 6 | import cwlib.io.Serializable; 7 | import cwlib.io.serializer.Serializer; 8 | 9 | public class CameraNode implements Serializable 10 | { 11 | public static final int BASE_ALLOCATION_SIZE = 0x30; 12 | 13 | public Vector4f targetBox; 14 | public Vector3f pitchAngle; 15 | public float zoomDistance; 16 | public boolean localSpaceRoll; 17 | 18 | @Override 19 | public void serialize(Serializer serializer) 20 | { 21 | targetBox = serializer.v4(targetBox); 22 | pitchAngle = serializer.v3(pitchAngle); 23 | zoomDistance = serializer.f32(zoomDistance); 24 | localSpaceRoll = serializer.bool(localSpaceRoll); 25 | } 26 | 27 | @Override 28 | public int getAllocatedSize() 29 | { 30 | return CameraNode.BASE_ALLOCATION_SIZE; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/things/components/CompactComponent.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.things.components; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.serializer.Serializer; 5 | import cwlib.structs.things.Thing; 6 | 7 | public class CompactComponent implements Serializable 8 | { 9 | public static final int BASE_ALLOCATION_SIZE = 0x20; 10 | 11 | public Thing thing; 12 | public float x, y, angle, scaleX = 1, scaleY = 1; 13 | public boolean flipped; 14 | 15 | @Override 16 | public void serialize(Serializer serializer) 17 | { 18 | thing = serializer.thing(thing); 19 | x = serializer.f32(x); 20 | y = serializer.f32(y); 21 | angle = serializer.f32(angle); 22 | scaleX = serializer.f32(scaleX); 23 | scaleY = serializer.f32(scaleY); 24 | flipped = serializer.bool(flipped); 25 | } 26 | 27 | @Override 28 | public int getAllocatedSize() 29 | { 30 | return CompactComponent.BASE_ALLOCATION_SIZE; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/things/components/GlobalThingDescriptor.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.things.components; 2 | 3 | import cwlib.enums.ResourceType; 4 | import cwlib.io.Serializable; 5 | import cwlib.io.serializer.Serializer; 6 | import cwlib.types.data.ResourceDescriptor; 7 | 8 | public class GlobalThingDescriptor implements Serializable 9 | { 10 | public static final int BASE_ALLOCATION_SIZE = 0x30; 11 | 12 | public ResourceDescriptor levelDesc; 13 | public int UID; 14 | 15 | @Override 16 | public void serialize(Serializer serializer) 17 | { 18 | levelDesc = serializer.resource(levelDesc, ResourceType.LEVEL, true 19 | , false, false); 20 | UID = serializer.i32(UID); 21 | } 22 | 23 | @Override 24 | public int getAllocatedSize() 25 | { 26 | return GlobalThingDescriptor.BASE_ALLOCATION_SIZE; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/things/components/HUDDecal.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.things.components; 2 | 3 | import org.joml.Vector4f; 4 | 5 | import cwlib.enums.ResourceType; 6 | import cwlib.io.Serializable; 7 | import cwlib.io.serializer.Serializer; 8 | import cwlib.types.data.ResourceDescriptor; 9 | 10 | public class HUDDecal implements Serializable 11 | { 12 | public static final int BASE_ALLOCATION_SIZE = 0x40; 13 | 14 | public ResourceDescriptor texture; 15 | public int frameNo, gpuColor; 16 | public Vector4f[] corners = new Vector4f[4]; 17 | 18 | @Override 19 | public void serialize(Serializer serializer) 20 | { 21 | if (serializer.getRevision().getSubVersion() < 0x24) 22 | return; 23 | 24 | texture = serializer.resource(texture, ResourceType.TEXTURE); 25 | frameNo = serializer.i32(frameNo); 26 | gpuColor = serializer.i32(gpuColor); 27 | for (int i = 0; i < 4; ++i) 28 | corners[i] = serializer.v4(corners[i]); 29 | } 30 | 31 | @Override 32 | public int getAllocatedSize() 33 | { 34 | return HUDDecal.BASE_ALLOCATION_SIZE; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/things/components/KeyLink.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.things.components; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.gson.GsonRevision; 5 | import cwlib.io.serializer.Serializer; 6 | import cwlib.structs.slot.SlotID; 7 | 8 | public class KeyLink implements Serializable 9 | { 10 | public static final int BASE_ALLOCATION_SIZE = 0x10; 11 | 12 | public SlotID slotID; 13 | 14 | @GsonRevision(max = 0x16e) 15 | @Deprecated 16 | public int unknown; 17 | 18 | @Override 19 | public void serialize(Serializer serializer) 20 | { 21 | slotID = serializer.struct(slotID, SlotID.class); 22 | if (serializer.getRevision().getVersion() < 0x16f) 23 | unknown = serializer.i32(unknown); 24 | } 25 | 26 | @Override 27 | public int getAllocatedSize() 28 | { 29 | return KeyLink.BASE_ALLOCATION_SIZE; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/things/components/decals/PaintControlPoint.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.things.components.decals; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.serializer.Serializer; 5 | 6 | /** 7 | * Squished paint positional data. 8 | */ 9 | public class PaintControlPoint implements Serializable 10 | { 11 | public static final int BASE_ALLOCATION_SIZE = 0x4; 12 | 13 | public byte x, y, startRadius, endRadius; 14 | 15 | @Override 16 | public void serialize(Serializer serializer) 17 | { 18 | x = serializer.i8(x); 19 | y = serializer.i8(y); 20 | startRadius = serializer.i8(startRadius); 21 | endRadius = serializer.i8(endRadius); 22 | } 23 | 24 | @Override 25 | public int getAllocatedSize() 26 | { 27 | return PaintControlPoint.BASE_ALLOCATION_SIZE; 28 | } 29 | } -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/things/components/npc/BehaviourAct.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.things.components.npc; 2 | 3 | import cwlib.io.serializer.Serializer; 4 | import cwlib.structs.things.Thing; 5 | 6 | public class BehaviourAct extends BehaviourBase 7 | { 8 | public static final int BASE_ALLOCATION_SIZE = 0x20; 9 | 10 | public Thing recordingPlayer; 11 | public InputRecording recording = new InputRecording(); 12 | public int currentFrame; 13 | 14 | @Override 15 | public void serialize(Serializer serializer) 16 | { 17 | super.serialize(serializer); 18 | if (serializer.getRevision().getVersion() <= 0x28f) return; 19 | 20 | recordingPlayer = serializer.thing(recordingPlayer); 21 | recording = serializer.struct(recording, InputRecording.class); 22 | currentFrame = serializer.i32(currentFrame); 23 | } 24 | 25 | @Override 26 | public int getAllocatedSize() 27 | { 28 | return BehaviourAct.BASE_ALLOCATION_SIZE; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/things/components/npc/BehaviourBase.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.things.components.npc; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.serializer.Serializer; 5 | import cwlib.structs.things.Thing; 6 | 7 | public class BehaviourBase implements Serializable 8 | { 9 | public static final int BASE_ALLOCATION_SIZE = 0x10; 10 | 11 | public Thing npc; 12 | public int type; 13 | public int attributes; 14 | 15 | @Override 16 | public void serialize(Serializer serializer) 17 | { 18 | npc = serializer.thing(npc); 19 | type = serializer.s32(type); 20 | attributes = serializer.i32(attributes); 21 | } 22 | 23 | @Override 24 | public int getAllocatedSize() 25 | { 26 | return BehaviourBase.BASE_ALLOCATION_SIZE; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/things/components/npc/BehaviourFollow.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.things.components.npc; 2 | 3 | import cwlib.io.serializer.Serializer; 4 | import cwlib.structs.things.Thing; 5 | 6 | public class BehaviourFollow extends BehaviourBase 7 | { 8 | public static final int BASE_ALLOCATION_SIZE = 0x20; 9 | 10 | public Thing followThing; 11 | public int lastFollowUpdate; 12 | 13 | @Override 14 | public void serialize(Serializer serializer) 15 | { 16 | super.serialize(serializer); 17 | 18 | followThing = serializer.thing(followThing); 19 | lastFollowUpdate = serializer.i32(lastFollowUpdate); 20 | } 21 | 22 | @Override 23 | public int getAllocatedSize() 24 | { 25 | return BehaviourFollow.BASE_ALLOCATION_SIZE; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/things/components/npc/NpcMoveCmd.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.things.components.npc; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.serializer.Serializer; 5 | 6 | public class NpcMoveCmd implements Serializable 7 | { 8 | public static final int BASE_ALLOCATION_SIZE = 0x10; 9 | 10 | public int buttons; 11 | public byte stickX, stickY; 12 | 13 | @Override 14 | public void serialize(Serializer serializer) 15 | { 16 | buttons = serializer.i32(buttons); 17 | stickX = serializer.i8(stickX); 18 | stickY = serializer.i8(stickY); 19 | if (serializer.getRevision().getVersion() < 0x280) 20 | serializer.u8(0); 21 | } 22 | 23 | @Override 24 | public int getAllocatedSize() 25 | { 26 | return NpcMoveCmd.BASE_ALLOCATION_SIZE; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/things/components/poppet/ObjectState.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.things.components.poppet; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.gson.GsonRevision; 5 | import cwlib.io.serializer.Serializer; 6 | import cwlib.structs.things.Thing; 7 | 8 | public class ObjectState implements Serializable 9 | { 10 | public static int BASE_ALLOCATION_SIZE = 0x20; 11 | 12 | public Thing thing; 13 | public int backZ; 14 | public int frontZ; 15 | 16 | @GsonRevision(min = 0x2bd) 17 | public int flags; 18 | 19 | @Override 20 | public void serialize(Serializer serializer) 21 | { 22 | int version = serializer.getRevision().getVersion(); 23 | 24 | thing = serializer.thing(thing); 25 | backZ = serializer.s32(backZ); 26 | frontZ = serializer.s32(frontZ); 27 | 28 | if (version < 0x2bd) serializer.bool(false); 29 | if (version > 0x147 && version < 0x2be) serializer.bool(false); 30 | 31 | if (version > 0x2bc) 32 | flags = serializer.i32(flags); 33 | else if (version > 0x25e) serializer.bool(false); 34 | } 35 | 36 | 37 | @Override 38 | public int getAllocatedSize() 39 | { 40 | return ObjectState.BASE_ALLOCATION_SIZE; 41 | } 42 | } -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/things/components/poppet/PlacementBodyState.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.things.components.poppet; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.serializer.Serializer; 5 | import cwlib.structs.things.Thing; 6 | 7 | public class PlacementBodyState implements Serializable 8 | { 9 | public static int BASE_ALLOCATION_SIZE = 0x10; 10 | 11 | public Thing thing; 12 | public Thing oldParent; 13 | public int frozen; 14 | 15 | @Override 16 | public void serialize(Serializer serializer) 17 | { 18 | thing = serializer.thing(thing); 19 | oldParent = serializer.thing(oldParent); 20 | frozen = serializer.i32(frozen); 21 | } 22 | 23 | 24 | @Override 25 | public int getAllocatedSize() 26 | { 27 | return PlacementBodyState.BASE_ALLOCATION_SIZE; 28 | } 29 | } -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/things/components/poppet/PoppetMode.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.things.components.poppet; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.serializer.Serializer; 5 | 6 | public class PoppetMode implements Serializable 7 | { 8 | public static int BASE_ALLOCATION_SIZE = 0x20; 9 | 10 | public int mode, subMode; 11 | 12 | @Override 13 | public void serialize(Serializer serializer) 14 | { 15 | int version = serializer.getRevision().getVersion(); 16 | 17 | mode = serializer.i32(mode); 18 | subMode = serializer.i32(subMode); 19 | 20 | if (version < 0x18b) serializer.i32(0); 21 | if (version > 0x1b7 && version < 0x1ba) 22 | { 23 | serializer.i32(0); 24 | serializer.i32(0); 25 | serializer.i32(0); 26 | serializer.i32(0); 27 | } 28 | } 29 | 30 | 31 | @Override 32 | public int getAllocatedSize() 33 | { 34 | return PoppetMode.BASE_ALLOCATION_SIZE; 35 | } 36 | 37 | 38 | } -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/things/components/poppet/RaycastResults.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.things.components.poppet; 2 | 3 | import org.joml.Vector4f; 4 | 5 | import cwlib.io.Serializable; 6 | import cwlib.io.serializer.Serializer; 7 | import cwlib.structs.things.Thing; 8 | 9 | public class RaycastResults implements Serializable 10 | { 11 | public static final int BASE_ALLOCATION_SIZE = 0x50; 12 | 13 | public Vector4f hitpoint, normal; 14 | public float baryU, baryV; 15 | public int triIndex; 16 | public Thing hitThing, refThing; 17 | public int onCostumePiece, decorationIdx; 18 | public boolean switchConnector; 19 | 20 | @Override 21 | public void serialize(Serializer serializer) 22 | { 23 | hitpoint = serializer.v4(hitpoint); 24 | normal = serializer.v4(normal); 25 | 26 | baryU = serializer.f32(baryU); 27 | baryV = serializer.f32(baryV); 28 | triIndex = serializer.i32(triIndex); 29 | 30 | hitThing = serializer.thing(hitThing); 31 | refThing = serializer.thing(refThing); 32 | 33 | onCostumePiece = serializer.s32(onCostumePiece); 34 | decorationIdx = serializer.i32(decorationIdx); 35 | switchConnector = serializer.bool(switchConnector); 36 | } 37 | 38 | @Override 39 | public int getAllocatedSize() 40 | { 41 | return RaycastResults.BASE_ALLOCATION_SIZE; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/things/components/shapes/Contact.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.things.components.shapes; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.serializer.Serializer; 5 | import cwlib.structs.things.parts.PShape; 6 | 7 | public class Contact implements Serializable 8 | { 9 | public static final int BASE_ALLOCATION_SIZE = 0x8; 10 | 11 | public PShape shape; 12 | public byte flags; 13 | 14 | @Override 15 | public void serialize(Serializer serializer) 16 | { 17 | shape = serializer.reference(shape, PShape.class); 18 | flags = serializer.i8(flags); 19 | } 20 | 21 | @Override 22 | public int getAllocatedSize() 23 | { 24 | int size = Contact.BASE_ALLOCATION_SIZE; 25 | if (this.shape != null) 26 | size += shape.getAllocatedSize(); 27 | return size; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/things/components/shapes/ContactCache.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.things.components.shapes; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.gson.GsonRevision; 5 | import cwlib.io.serializer.Serializer; 6 | 7 | public class ContactCache implements Serializable 8 | { 9 | public static final int BASE_ALLOCATION_SIZE = 0x8; 10 | 11 | public Contact[] contacts; 12 | public boolean contactsSorted; 13 | @GsonRevision(lbp3 = true, max = 0x46) 14 | public boolean cacheDirtyButRecomputed; 15 | 16 | @Override 17 | public void serialize(Serializer serializer) 18 | { 19 | contacts = serializer.array(contacts, Contact.class); 20 | contactsSorted = serializer.bool(contactsSorted); 21 | if (serializer.getRevision().getSubVersion() < 0x46) 22 | cacheDirtyButRecomputed = serializer.bool(cacheDirtyButRecomputed); 23 | } 24 | 25 | @Override 26 | public int getAllocatedSize() 27 | { 28 | int size = BASE_ALLOCATION_SIZE; 29 | if (this.contacts != null) 30 | for (Contact contact : this.contacts) 31 | size += contact.getAllocatedSize(); 32 | return size; 33 | } 34 | } -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/things/components/switches/SwitchOutput.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.things.components.switches; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.gson.GsonRevision; 5 | import cwlib.io.serializer.Serializer; 6 | 7 | public class SwitchOutput implements Serializable 8 | { 9 | public static final int BASE_ALLOCATION_SIZE = 0x20; 10 | 11 | public SwitchSignal activation = new SwitchSignal(); 12 | public SwitchTarget[] targetList; 13 | 14 | @GsonRevision(min = 0x34d) 15 | public String userDefinedName; 16 | 17 | @Override 18 | public void serialize(Serializer serializer) 19 | { 20 | int version = serializer.getRevision().getVersion(); 21 | 22 | activation = serializer.struct(activation, SwitchSignal.class); 23 | targetList = serializer.array(targetList, SwitchTarget.class); 24 | if (version >= 0x34d) 25 | userDefinedName = serializer.wstr(userDefinedName); 26 | } 27 | 28 | @Override 29 | public int getAllocatedSize() 30 | { 31 | int size = SwitchOutput.BASE_ALLOCATION_SIZE; 32 | if (this.userDefinedName != null) size += (this.userDefinedName.length() * 2); 33 | return size; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/things/components/switches/SwitchSignal.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.things.components.switches; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.gson.GsonRevision; 5 | import cwlib.io.serializer.Serializer; 6 | 7 | public class SwitchSignal implements Serializable 8 | { 9 | public static final int BASE_ALLOCATION_SIZE = 0x10; 10 | 11 | public float activation; 12 | @GsonRevision(min = 0x310) 13 | public int ternary; 14 | @GsonRevision(min = 0x2a3) 15 | public int player = -1; 16 | 17 | public SwitchSignal() { } 18 | 19 | public SwitchSignal(float activation) 20 | { 21 | this.activation = activation; 22 | } 23 | 24 | @Override 25 | public void serialize(Serializer serializer) 26 | { 27 | int version = serializer.getRevision().getVersion(); 28 | 29 | activation = serializer.f32(activation); 30 | if (version >= 0x310) 31 | ternary = serializer.s32(ternary); 32 | if (version >= 0x2a3) 33 | player = serializer.i32(player); 34 | } 35 | 36 | @Override 37 | public int getAllocatedSize() 38 | { 39 | return SwitchSignal.BASE_ALLOCATION_SIZE; 40 | } 41 | 42 | 43 | } 44 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/things/components/switches/SwitchTarget.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.things.components.switches; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.gson.GsonRevision; 5 | import cwlib.io.serializer.Serializer; 6 | import cwlib.structs.things.Thing; 7 | 8 | public class SwitchTarget implements Serializable 9 | { 10 | public static final int BASE_ALLOCATION_SIZE = 0x8; 11 | 12 | public Thing thing; 13 | 14 | @GsonRevision(min = 0x327) 15 | public int port; 16 | 17 | public SwitchTarget() { } 18 | 19 | public SwitchTarget(Thing thing) 20 | { 21 | this.thing = thing; 22 | } 23 | 24 | @Override 25 | public void serialize(Serializer serializer) 26 | { 27 | thing = serializer.thing(thing); 28 | if (serializer.getRevision().getVersion() > 0x326) 29 | port = serializer.i32(port); 30 | } 31 | 32 | @Override 33 | public int getAllocatedSize() 34 | { 35 | return SwitchTarget.BASE_ALLOCATION_SIZE; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/things/components/world/BroadcastMicrochipEntry.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.things.components.world; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.serializer.Serializer; 5 | import cwlib.structs.things.Thing; 6 | 7 | public class BroadcastMicrochipEntry implements Serializable 8 | { 9 | public static final int BASE_ALLOCATION_SIZE = 0x10; 10 | 11 | public Thing sourceMicrochip; 12 | public Thing clonedMicrochip; 13 | 14 | @Override 15 | public void serialize(Serializer serializer) 16 | { 17 | sourceMicrochip = serializer.thing(sourceMicrochip); 18 | clonedMicrochip = serializer.thing(clonedMicrochip); 19 | } 20 | 21 | 22 | @Override 23 | public int getAllocatedSize() 24 | { 25 | return BroadcastMicrochipEntry.BASE_ALLOCATION_SIZE; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/things/components/world/EditorSelection.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.things.components.world; 2 | 3 | import java.util.ArrayList; 4 | 5 | import cwlib.io.Serializable; 6 | import cwlib.io.serializer.Serializer; 7 | import cwlib.structs.things.Thing; 8 | 9 | public class EditorSelection implements Serializable 10 | { 11 | public static final int BASE_ALLOCATION_SIZE = 0x8; 12 | 13 | public String name; 14 | public ArrayList things = new ArrayList<>(); 15 | 16 | @Override 17 | public void serialize(Serializer serializer) 18 | { 19 | name = serializer.str(name); 20 | things = serializer.arraylist(things, Thing.class, true); 21 | } 22 | 23 | @Override 24 | public int getAllocatedSize() 25 | { 26 | int size = EditorSelection.BASE_ALLOCATION_SIZE; 27 | if (this.name != null) size += (this.name.length()); 28 | return size; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/things/components/world/GameCamera.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.things.components.world; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.serializer.Serializer; 5 | 6 | public class GameCamera implements Serializable 7 | { 8 | public static final int BASE_ALLOCATION_SIZE = 0x14; 9 | 10 | @Override 11 | public void serialize(Serializer serializer) 12 | { 13 | serializer.v4(null); // cameraTarget 14 | serializer.bool(false); // validCameraTarget 15 | } 16 | 17 | @Override 18 | public int getAllocatedSize() 19 | { 20 | return GameCamera.BASE_ALLOCATION_SIZE; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/things/components/world/GlobalSettings.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.things.components.world; 2 | 3 | import cwlib.enums.Branch; 4 | import cwlib.io.Serializable; 5 | import cwlib.io.gson.GsonRevision; 6 | import cwlib.io.serializer.Serializer; 7 | 8 | public class GlobalSettings implements Serializable 9 | { 10 | public static final int BASE_ALLOCATION_SIZE = 0x14; 11 | 12 | public float lightingFactor = 1.0f, colorCorrectionFactor, fogFactor, fogTintFactor, 13 | darknessFactor; 14 | 15 | @GsonRevision(branch = 0x4431, min = 0x78) 16 | public boolean nonLinearFog; // Vita 17 | 18 | @Override 19 | public void serialize(Serializer serializer) 20 | { 21 | lightingFactor = serializer.f32(lightingFactor); 22 | colorCorrectionFactor = serializer.f32(colorCorrectionFactor); 23 | fogFactor = serializer.f32(fogFactor); 24 | fogTintFactor = serializer.f32(fogTintFactor); 25 | darknessFactor = serializer.f32(darknessFactor); 26 | if (serializer.getRevision().has(Branch.DOUBLE11, 0x78)) 27 | nonLinearFog = serializer.bool(nonLinearFog); 28 | } 29 | 30 | @Override 31 | public int getAllocatedSize() 32 | { 33 | return GlobalSettings.BASE_ALLOCATION_SIZE; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/things/parts/PAnimation.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.things.parts; 2 | 3 | import cwlib.enums.ResourceType; 4 | import cwlib.io.Serializable; 5 | import cwlib.io.serializer.Serializer; 6 | import cwlib.types.data.ResourceDescriptor; 7 | 8 | public class PAnimation implements Serializable 9 | { 10 | public static final int BASE_ALLOCATION_SIZE = 0x30; 11 | 12 | public ResourceDescriptor animation; 13 | public float velocity, position; 14 | 15 | @Override 16 | public void serialize(Serializer serializer) 17 | { 18 | animation = serializer.resource(animation, ResourceType.ANIMATION); 19 | velocity = serializer.f32(velocity); 20 | position = serializer.f32(position); 21 | } 22 | 23 | @Override 24 | public int getAllocatedSize() 25 | { 26 | return BASE_ALLOCATION_SIZE; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/things/parts/PDecorations.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.things.parts; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.serializer.Serializer; 5 | import cwlib.structs.things.components.Decoration; 6 | 7 | public class PDecorations implements Serializable 8 | { 9 | public Decoration[] decorations; 10 | 11 | public PDecorations() { } 12 | 13 | public PDecorations(Decoration decor) 14 | { 15 | this.decorations = new Decoration[] { decor }; 16 | } 17 | 18 | @Override 19 | public void serialize(Serializer serializer) 20 | { 21 | decorations = serializer.array(decorations, Decoration.class); 22 | } 23 | 24 | // TODO: Actually implement 25 | @Override 26 | public int getAllocatedSize() 27 | { 28 | return 0; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/things/parts/PEffector.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.things.parts; 2 | 3 | import org.joml.Vector3f; 4 | 5 | import cwlib.io.Serializable; 6 | import cwlib.io.serializer.Serializer; 7 | 8 | /** 9 | * Part that works as the gravity of the world. 10 | */ 11 | public class PEffector implements Serializable 12 | { 13 | public static final int BASE_ALLOCATION_SIZE = 0x30; 14 | 15 | public Vector3f posVel; 16 | public float angVel, viscosity, density; 17 | public Vector3f gravity = new Vector3f(0.0f, -2.7f, 0.0f); 18 | public boolean pushBack, swimmable; 19 | public float viscosityCheap = 0.05f; 20 | public float modScale = 1.0f; 21 | 22 | @Override 23 | public void serialize(Serializer serializer) 24 | { 25 | posVel = serializer.v3(posVel); 26 | angVel = serializer.f32(angVel); 27 | viscosity = serializer.f32(viscosity); 28 | density = serializer.f32(density); 29 | gravity = serializer.v3(gravity); 30 | pushBack = serializer.bool(pushBack); 31 | swimmable = serializer.bool(swimmable); 32 | viscosityCheap = serializer.f32(viscosityCheap); 33 | modScale = serializer.f32(modScale); 34 | } 35 | 36 | @Override 37 | public int getAllocatedSize() 38 | { 39 | return BASE_ALLOCATION_SIZE; 40 | } 41 | } -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/things/parts/PScript.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.things.parts; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.serializer.Serializer; 5 | import cwlib.structs.things.components.script.ScriptInstance; 6 | import cwlib.types.data.GUID; 7 | import cwlib.types.data.ResourceDescriptor; 8 | 9 | public class PScript implements Serializable 10 | { 11 | public static final int BASE_ALLOCATION_SIZE = 0x30; 12 | 13 | public ScriptInstance instance = new ScriptInstance(); 14 | 15 | public PScript() { } 16 | 17 | public PScript(ResourceDescriptor script) 18 | { 19 | this.instance.script = script; 20 | } 21 | 22 | public boolean is(GUID guid) 23 | { 24 | if (instance == null || instance.script == null) return false; 25 | return instance.script.isGUID() && guid.equals(instance.script.getGUID()); 26 | } 27 | 28 | @Override 29 | public void serialize(Serializer serializer) 30 | { 31 | int version = serializer.getRevision().getVersion(); 32 | if (0x179 < version && version < 0x1a1) 33 | serializer.bool(false); // unknown 34 | instance = serializer.struct(instance, ScriptInstance.class); 35 | } 36 | 37 | @Override 38 | public int getAllocatedSize() 39 | { 40 | return PScript.BASE_ALLOCATION_SIZE; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/things/parts/PScriptName.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.things.parts; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.serializer.Serializer; 5 | 6 | /** 7 | * Part that just contains the name of the 8 | * script attached, unknown if it serves any current 9 | * purpose. 10 | */ 11 | public class PScriptName implements Serializable 12 | { 13 | public static final int BASE_ALLOCATION_SIZE = 0x4; 14 | 15 | public String name; 16 | 17 | public PScriptName() { } 18 | 19 | public PScriptName(String name) 20 | { 21 | this.name = name; 22 | } 23 | 24 | @Override 25 | public void serialize(Serializer serializer) 26 | { 27 | name = serializer.str(name); 28 | } 29 | 30 | @Override 31 | public int getAllocatedSize() 32 | { 33 | int size = PScriptName.BASE_ALLOCATION_SIZE; 34 | if (this.name != null) 35 | size += this.name.length(); 36 | return size; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/things/parts/PStreamingData.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.things.parts; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.gson.GsonRevision; 5 | import cwlib.io.serializer.Serializer; 6 | 7 | public class PStreamingData implements Serializable 8 | { 9 | public static final int BASE_ALLOCATION_SIZE = 0x4; 10 | 11 | public byte hidden; 12 | @GsonRevision(lbp3 = true, min = 0xde) 13 | public short originator; 14 | 15 | @Override 16 | public void serialize(Serializer serializer) 17 | { 18 | int subVersion = serializer.getRevision().getSubVersion(); 19 | 20 | hidden = serializer.i8(hidden); 21 | if (subVersion > 0xdd) 22 | originator = serializer.i16(originator); 23 | } 24 | 25 | @Override 26 | public int getAllocatedSize() 27 | { 28 | return PStreamingData.BASE_ALLOCATION_SIZE; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/things/parts/PStreamingHint.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.things.parts; 2 | 3 | import org.joml.Vector3f; 4 | 5 | import cwlib.io.Serializable; 6 | import cwlib.io.gson.GsonRevision; 7 | import cwlib.io.serializer.Serializer; 8 | import cwlib.structs.things.Thing; 9 | 10 | public class PStreamingHint implements Serializable 11 | { 12 | public static final int BASE_ALLOCATION_SIZE = 0x30; 13 | 14 | public int type; 15 | public Vector3f offset, size; 16 | 17 | @GsonRevision(lbp3 = true, min = 0x114) 18 | public Thing relativeToThing; 19 | 20 | @GsonRevision(lbp3 = true, min = 0x133) 21 | public Thing[] connected; 22 | 23 | @Override 24 | public void serialize(Serializer serializer) 25 | { 26 | int subVersion = serializer.getRevision().getSubVersion(); 27 | 28 | type = serializer.i32(type); 29 | offset = serializer.v3(offset); 30 | size = serializer.v3(size); 31 | 32 | if (subVersion > 0x113) 33 | relativeToThing = serializer.thing(relativeToThing); 34 | if (subVersion >= 0x133) 35 | connected = serializer.thingarray(connected); 36 | } 37 | 38 | 39 | @Override 40 | public int getAllocatedSize() 41 | { 42 | int size = PStreamingHint.BASE_ALLOCATION_SIZE; 43 | if (this.connected != null) 44 | size += (this.connected.length * 0x4); 45 | return size; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/things/parts/PTagSynchroniser.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.things.parts; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.gson.GsonRevision; 5 | import cwlib.io.serializer.Serializer; 6 | 7 | public class PTagSynchroniser implements Serializable 8 | { 9 | public static final int BASE_ALLOCATION_SIZE = 0x20; 10 | 11 | public int type, colorIndex; 12 | 13 | @GsonRevision(min = 0x2dc) 14 | public String name; 15 | 16 | public float radius, minRadius, scaleX, scaleY; 17 | public boolean useLayers, visible; 18 | 19 | @Override 20 | public void serialize(Serializer serializer) 21 | { 22 | type = serializer.s32(type); 23 | 24 | colorIndex = serializer.s32(colorIndex); 25 | if (serializer.getRevision().getVersion() >= 0x2dc) 26 | name = serializer.wstr(name); 27 | 28 | radius = serializer.f32(radius); 29 | minRadius = serializer.f32(minRadius); 30 | scaleX = serializer.f32(scaleX); 31 | scaleY = serializer.f32(scaleY); 32 | 33 | useLayers = serializer.bool(useLayers); 34 | visible = serializer.bool(visible); 35 | } 36 | 37 | @Override 38 | public int getAllocatedSize() 39 | { 40 | int size = PTagSynchroniser.BASE_ALLOCATION_SIZE; 41 | if (this.name != null) size += (this.name.length() * 0x2); 42 | return size; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/structs/things/parts/PWormhole.java: -------------------------------------------------------------------------------- 1 | package cwlib.structs.things.parts; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.gson.GsonRevision; 5 | import cwlib.io.serializer.Serializer; 6 | 7 | public class PWormhole implements Serializable 8 | { 9 | public static final int BASE_ALLOCATION_SIZE = 0x30; 10 | 11 | public int type; 12 | 13 | @GsonRevision(min = 0x111, lbp3 = true) 14 | public byte activeTypeForTwoWayHole; 15 | 16 | public int playerMode; 17 | public boolean audioEnabled, trigger, finished, activated; 18 | public int exitCount, exitDelay; 19 | 20 | @Override 21 | public void serialize(Serializer serializer) 22 | { 23 | type = serializer.s32(type); 24 | if (serializer.getRevision().getSubVersion() >= 0x111) 25 | activeTypeForTwoWayHole = serializer.i8(activeTypeForTwoWayHole); 26 | 27 | playerMode = serializer.s32(playerMode); 28 | audioEnabled = serializer.bool(audioEnabled); 29 | 30 | trigger = serializer.bool(trigger); 31 | finished = serializer.bool(finished); 32 | activated = serializer.bool(activated); 33 | 34 | exitCount = serializer.i32(exitCount); 35 | exitDelay = serializer.i32(exitDelay); 36 | } 37 | 38 | @Override 39 | public int getAllocatedSize() 40 | { 41 | return PWormhole.BASE_ALLOCATION_SIZE; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/types/ResPtr.java: -------------------------------------------------------------------------------- 1 | package cwlib.types; 2 | 3 | import java.lang.reflect.ParameterizedType; 4 | 5 | import com.google.gson.reflect.TypeToken; 6 | 7 | import cwlib.enums.ResourceType; 8 | import cwlib.io.Resource; 9 | import cwlib.resources.RMesh; 10 | import cwlib.types.data.GUID; 11 | import cwlib.types.data.ResourceDescriptor; 12 | import cwlib.types.data.SHA1; 13 | 14 | public class ResPtr 15 | { 16 | private T resource; 17 | private SerializedResource serializedResource; 18 | private final ResourceType type; 19 | private GUID guid; 20 | private final SHA1 loadedHash = SHA1.EMPTY; 21 | private int loadState; 22 | 23 | public ResPtr(ResourceDescriptor descriptor) 24 | { 25 | type = descriptor.getType(); 26 | } 27 | 28 | public ResPtr() 29 | { 30 | type = ResourceType.INVALID; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/types/archives/SaveKey.java: -------------------------------------------------------------------------------- 1 | package cwlib.types.archives; 2 | 3 | import cwlib.enums.ResourceType; 4 | import cwlib.types.data.SHA1; 5 | 6 | 7 | /** 8 | * Information about savedata stored in SaveFart. 9 | */ 10 | public class SaveKey 11 | { 12 | @SuppressWarnings("unused") 13 | private final int[] deprecated1 = new int[10]; 14 | private boolean copied; 15 | private ResourceType rootType = ResourceType.INVALID; 16 | @SuppressWarnings("unused") 17 | private final int[] deprecated2 = new int[3]; 18 | private SHA1 rootHash = new SHA1(); 19 | @SuppressWarnings("unused") 20 | private final int[] deprecated3 = new int[10]; 21 | 22 | public boolean getCopied() 23 | { 24 | return this.copied; 25 | } 26 | 27 | public ResourceType getRootType() 28 | { 29 | return this.rootType; 30 | } 31 | 32 | public SHA1 getRootHash() 33 | { 34 | return this.rootHash; 35 | } 36 | 37 | public void setCopied(boolean value) 38 | { 39 | this.copied = value; 40 | } 41 | 42 | public void setRootType(ResourceType value) 43 | { 44 | this.rootType = value; 45 | } 46 | 47 | public void setRootHash(SHA1 value) 48 | { 49 | this.rootHash = value; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/types/data/OpenPSID.java: -------------------------------------------------------------------------------- 1 | package cwlib.types.data; 2 | 3 | import cwlib.io.Serializable; 4 | import cwlib.io.serializer.Serializer; 5 | 6 | public class OpenPSID implements Serializable 7 | { 8 | public static final int BASE_ALLOCATION_SIZE = 0x8; 9 | 10 | private long high, low; 11 | 12 | public OpenPSID() { } 13 | 14 | public OpenPSID(long high, long low) 15 | { 16 | this.high = high; 17 | this.low = low; 18 | } 19 | 20 | @Override 21 | public void serialize(Serializer serializer) 22 | { 23 | high = serializer.u64(high); 24 | low = serializer.u64(low); 25 | } 26 | 27 | @Override 28 | public int getAllocatedSize() 29 | { 30 | return BASE_ALLOCATION_SIZE; 31 | } 32 | 33 | public long getHigh() 34 | { 35 | return this.high; 36 | } 37 | 38 | public long getLow() 39 | { 40 | return this.low; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/types/mods/ModInfo.java: -------------------------------------------------------------------------------- 1 | package cwlib.types.mods; 2 | 3 | public class ModInfo 4 | { 5 | public String ID = "sample"; 6 | public String type = "pack"; 7 | public String title = "Untitled Mod"; 8 | public String version = "1.0"; 9 | public String author = "Sackthing"; 10 | public String description = "No description was provided."; 11 | } 12 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/types/mods/patches/ModPatch.java: -------------------------------------------------------------------------------- 1 | package cwlib.types.mods.patches; 2 | 3 | import com.google.gson.annotations.JsonAdapter; 4 | import cwlib.enums.PatchType; 5 | import cwlib.io.gson.PatchSerializer; 6 | 7 | @JsonAdapter(PatchSerializer.class) 8 | public abstract class ModPatch 9 | { 10 | private final PatchType type; 11 | private String name; 12 | 13 | protected ModPatch(PatchType type) 14 | { 15 | if (type == null) 16 | throw new NullPointerException("Patch type cannot be null!"); 17 | this.type = type; 18 | } 19 | 20 | public PatchType getType() 21 | { 22 | return this.type; 23 | } 24 | 25 | public String getName() 26 | { 27 | return this.name; 28 | } 29 | 30 | public void setName(String name) 31 | { 32 | this.name = name; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/types/swing/FileModel.java: -------------------------------------------------------------------------------- 1 | package cwlib.types.swing; 2 | 3 | import javax.swing.tree.DefaultTreeModel; 4 | import javax.swing.tree.TreeNode; 5 | 6 | public class FileModel extends DefaultTreeModel 7 | { 8 | public FileModel(FileNode root) 9 | { 10 | super(root, false); 11 | } 12 | 13 | public Object getChild(Object parent, int index) 14 | { 15 | if (parent instanceof FileNode) 16 | return ((FileNode) parent).getChildAt(index, true); 17 | return ((TreeNode) parent).getChildAt(index); 18 | } 19 | 20 | public int getChildCount(Object parent) 21 | { 22 | if (parent instanceof FileNode) 23 | return ((FileNode) parent).getChildCount(true, false); 24 | return ((TreeNode) parent).getChildCount(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/types/swing/SearchParameters.java: -------------------------------------------------------------------------------- 1 | package cwlib.types.swing; 2 | 3 | import cwlib.enums.ResourceType; 4 | import cwlib.types.data.ResourceDescriptor; 5 | import cwlib.util.Strings; 6 | 7 | /** 8 | * Toolkit search filtering settings 9 | */ 10 | public class SearchParameters 11 | { 12 | /** 13 | * Path to search for 14 | */ 15 | private final String path; 16 | 17 | /** 18 | * Parsed resource reference from search query 19 | */ 20 | private final ResourceDescriptor resource; 21 | 22 | /** 23 | * Constructs search parameters from a query 24 | * 25 | * @param query Search query 26 | */ 27 | public SearchParameters(String query) 28 | { 29 | this.path = query.toLowerCase().replaceAll("\\s", ""); 30 | if (query.startsWith("res:")) 31 | { 32 | query = query.substring(4); 33 | if (Strings.isGUID(query) || Strings.isSHA1(query)) 34 | this.resource = new ResourceDescriptor(query, ResourceType.INVALID); 35 | else 36 | this.resource = null; 37 | } 38 | else this.resource = null; 39 | } 40 | 41 | public String getPath() 42 | { 43 | return this.path; 44 | } 45 | 46 | public ResourceDescriptor getResource() 47 | { 48 | return this.resource; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/util/Morton2D.java: -------------------------------------------------------------------------------- 1 | package cwlib.util; 2 | 3 | public class Morton2D 4 | { 5 | public static int decodeX(int x) 6 | { 7 | return Morton2D.compact1By1(x >> 0); 8 | } 9 | 10 | public static int decodeY(int y) 11 | { 12 | return Morton2D.compact1By1(y >> 1); 13 | } 14 | 15 | private static int compact1By1(int x) 16 | { 17 | x &= 0x55555555; 18 | x = (x ^ (x >> 1)) & 0x33333333; 19 | x = (x ^ (x >> 2)) & 0x0f0f0f0f; 20 | x = (x ^ (x >> 4)) & 0x00ff00ff; 21 | x = (x ^ (x >> 8)) & 0x0000ffff; 22 | return x; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/java/cwlib/util/Shader.java: -------------------------------------------------------------------------------- 1 | package cwlib.util; 2 | 3 | import cwlib.enums.BrdfPort; 4 | import cwlib.resources.RGfxMaterial; 5 | 6 | import java.awt.image.BufferedImage; 7 | 8 | public class Shader 9 | { 10 | public static BufferedImage render(RGfxMaterial material, BrdfPort port) 11 | { 12 | return null; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /lib/cwlib/src/main/resources/binary/characters.boneset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ennuo/toolkit/dc82bee57ab58e9f4bf35993d405529d4cbc7d00/lib/cwlib/src/main/resources/binary/characters.boneset -------------------------------------------------------------------------------- /lib/cwlib/src/main/resources/binary/template.anim: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ennuo/toolkit/dc82bee57ab58e9f4bf35993d405529d4cbc7d00/lib/cwlib/src/main/resources/binary/template.anim -------------------------------------------------------------------------------- /lib/cwlib/src/main/resources/gmat_lbp1.txt: -------------------------------------------------------------------------------- 1 | # LBP1 gmats that get remapped in LBP2 2 | # Used for handling backporter 3 | # from, to 4 | 5 | g106493, g106497 6 | g106492, g106496 7 | g154680, g38924 8 | g78865, g87096 9 | g77356, g66636 10 | g12719, g1124 11 | g92128, g66675 12 | g107287, g75897 13 | g3842, g2191 14 | g72428, g72883 15 | g5207, g16596 16 | g5190, g16601 17 | g125425, g8435 18 | g8436, g8468 19 | g3840, g16663 20 | g3843, g16664 21 | g3905, g16665 22 | g3841, g16666 23 | g3848, g16667 24 | g80432, g64840 25 | g80891, g81245 26 | g9493, g11669 27 | g158530, g9737 28 | g121620, g8742 29 | g105961, g5680 30 | g66129, g66127 31 | g81029, g67231 32 | g154680, g68259 33 | g3848, g2754 34 | g3850, g2759 35 | g81633, g81629 36 | g81634, g81631 37 | g77356, g26400 38 | g106491, g106495 -------------------------------------------------------------------------------- /lib/cwlib/src/main/resources/poppet_lbp1.txt: -------------------------------------------------------------------------------- 1 | # LBP1 plans that get remapped in LBP2 2 | # Used for handling backporter 3 | # from, to 4 | 5 | g83655, g31701 6 | g83656, g31703 7 | g83657, g31704 8 | g83658, g31706 9 | g83659, g31707 10 | g83660, g31710 11 | g83661, g31714 12 | g83662, g31715 13 | g83663, g31716 14 | g83664, g31717 15 | g83665, g31719 16 | g83694, g32768 17 | g83695, g32769 18 | g83696, g32770 19 | g83697, g32771 20 | g83667, g32799 21 | g83668, g32800 22 | g83669, g32801 23 | g83670, g32802 24 | g83671, g32803 25 | g83682, g33099 26 | g83683, g33100 27 | g83684, g33101 28 | g83685, g33103 29 | g83673, g33132 30 | g83674, g33133 31 | g83675, g33134 32 | g83676, g33135 33 | g83677, g33136 34 | g83679, g33137 35 | g83680, g33138 36 | g83681, g33139 37 | g83687, g33188 38 | g83688, g33189 39 | g83689, g33190 40 | g83690, g33191 41 | g83691, g33192 42 | g83692, g33193 43 | g83693, g33196 44 | g83678, g34541 45 | g83672, g34557 46 | g156367, g39747 47 | g83666, g45765 48 | g130012, g51309 49 | g156368, g52018 50 | g103727, g52020 51 | g124479, g52021 52 | g103723, g52030 53 | g103722, g52033 54 | g92667, g54695 55 | g83686, g56414 56 | g83666, g119449 -------------------------------------------------------------------------------- /nbactions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | run 5 | 6 | jar 7 | 8 | 9 | process-classes 10 | org.codehaus.mojo:exec-maven-plugin:3.0.0:exec 11 | 12 | 13 | 14 | ${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs} 15 | 16 | 17 | toolkit.Launcher 18 | java 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 4.0.0 7 | 8 | ennuo 9 | toolkit-parent 10 | 0.1 11 | pom 12 | 13 | 14 | lib/cwlib 15 | lib/cwlib-gl 16 | 17 | tools/jsoninator 18 | tools/descriptor 19 | tools/sequencerdump 20 | 21 | toolkit 22 | 23 | -------------------------------------------------------------------------------- /toolkit/README.md: -------------------------------------------------------------------------------- 1 | # Toolkit 2 | 3 | Swing-based toolkit for the LittleBigPlanet series. -------------------------------------------------------------------------------- /toolkit/nbactions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | run 5 | 6 | jar 7 | 8 | 9 | process-classes 10 | org.codehaus.mojo:exec-maven-plugin:3.1.0:exec 11 | 12 | 13 | 14 | ${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs} 15 | 16 | 17 | toolkit.Launcher 18 | java 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /toolkit/src/main/java/configurations/ApplicationFlags.java: -------------------------------------------------------------------------------- 1 | package configurations; 2 | 3 | import cwlib.CwlibConfiguration; 4 | 5 | /** 6 | * Flags controlling whether or not certain 7 | * features should be enabled or not, usually 8 | * for in-development features. 9 | */ 10 | public class ApplicationFlags 11 | { 12 | /** 13 | * Enables Ghostbusters resource loading. 14 | */ 15 | public static boolean ENABLE_GHOSTBUSTERS = false; 16 | 17 | /** 18 | * 3D is only supported on Windows (and maybe Linux) 19 | */ 20 | public static boolean CAN_USE_3D = CwlibConfiguration.IS_WINDOWS; 21 | 22 | /** 23 | * Whether or not Alear server operations are allowed. 24 | */ 25 | public static boolean ALEAR_INTEGRATION = false; 26 | } 27 | -------------------------------------------------------------------------------- /toolkit/src/main/java/configurations/Profile.java: -------------------------------------------------------------------------------- 1 | package configurations; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class Profile 7 | { 8 | public String name = "Unnamed Profile"; 9 | public List archives = new ArrayList<>(); 10 | public List databases = new ArrayList<>(); 11 | public List saves = new ArrayList<>(); 12 | public long language = 0; 13 | 14 | public Profile() { } 15 | 16 | public Profile(String name) 17 | { 18 | this.name = name; 19 | } 20 | 21 | @Override 22 | public String toString() 23 | { 24 | return this.name; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /toolkit/src/main/java/executables/TexToPng.java: -------------------------------------------------------------------------------- 1 | package executables; 2 | 3 | import cwlib.resources.RTexture; 4 | import cwlib.types.SerializedResource; 5 | 6 | import javax.imageio.ImageIO; 7 | import java.io.File; 8 | import java.io.IOException; 9 | 10 | public class TexToPng 11 | { 12 | public static void main(String[] args) 13 | throws IOException 14 | { 15 | byte[] data = System.in.readAllBytes(); 16 | RTexture texture = new RTexture(new SerializedResource(data)); 17 | ImageIO.write(texture.getImage(), "png", new File(args[0])); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /toolkit/src/main/java/toolkit/Launcher.java: -------------------------------------------------------------------------------- 1 | package toolkit; 2 | 3 | import com.github.weisj.darklaf.LafManager; 4 | import com.github.weisj.darklaf.theme.DarculaTheme; 5 | import configurations.Config; 6 | import cwlib.singleton.ResourceSystem; 7 | import toolkit.windows.Toolkit; 8 | 9 | import java.awt.*; 10 | 11 | public class Launcher 12 | { 13 | public static void main(String[] args) 14 | { 15 | Config.initialize(); 16 | LafManager.install(new DarculaTheme()); 17 | ResourceSystem.GUI_MODE = true; 18 | EventQueue.invokeLater(() -> 19 | { 20 | new Toolkit().run(args).setVisible(true); 21 | }); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /toolkit/src/main/java/toolkit/functions/LoadCallbacks.java: -------------------------------------------------------------------------------- 1 | package toolkit.functions; 2 | 3 | import cwlib.resources.RTranslationTable; 4 | import cwlib.singleton.ResourceSystem; 5 | 6 | import java.awt.event.ActionEvent; 7 | 8 | public class LoadCallbacks 9 | { 10 | public static void loadTranslationTable(ActionEvent event) 11 | { 12 | byte[] data = ResourceSystem.extract(ResourceSystem.getSelected().getEntry()); 13 | if (data == null) return; 14 | ResourceSystem.setLAMS(new RTranslationTable(data)); 15 | } 16 | 17 | public static void loadPalette3D(ActionEvent event) 18 | { 19 | } 20 | 21 | public static void loadLevel3D(ActionEvent event) 22 | { 23 | } 24 | 25 | public static void loadModel3D(ActionEvent event) 26 | { 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /toolkit/src/main/java/toolkit/functions/ModCallbacks.java: -------------------------------------------------------------------------------- 1 | package toolkit.functions; 2 | 3 | import cwlib.types.mods.Mod; 4 | import cwlib.util.Bytes; 5 | 6 | import java.io.File; 7 | import java.io.IOException; 8 | import java.io.RandomAccessFile; 9 | 10 | public class ModCallbacks 11 | { 12 | public static Mod loadMod(File file) 13 | { 14 | final int ZIP_HEADER = 1347093252; 15 | final int ENCRYPTED_MOD_HEADER = 1297040485; 16 | final int MOD_HEADER = 1297040482; 17 | 18 | int header = 0; 19 | try (RandomAccessFile raf = new RandomAccessFile(file, "r")) 20 | { 21 | byte[] magic = new byte[4]; 22 | raf.read(magic); 23 | header = Bytes.toIntegerBE(magic); 24 | } 25 | catch (IOException e) 26 | { 27 | System.err.println("An error occured accessing the file."); 28 | } 29 | if (header == ENCRYPTED_MOD_HEADER || header == MOD_HEADER) 30 | return Mod.fromLegacyMod(file); 31 | else if (header == ZIP_HEADER) return new Mod(file); 32 | return null; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /toolkit/src/main/java/toolkit/streams/CustomPrintStream.java: -------------------------------------------------------------------------------- 1 | package toolkit.streams; 2 | 3 | import java.io.OutputStream; 4 | import java.io.PrintStream; 5 | import java.text.DateFormat; 6 | import java.text.SimpleDateFormat; 7 | import java.util.Date; 8 | 9 | public class CustomPrintStream extends PrintStream 10 | { 11 | public CustomPrintStream(OutputStream out) 12 | { 13 | super(out); 14 | } 15 | 16 | public void println(String string) 17 | { 18 | Date date = new Date(); 19 | DateFormat df = new SimpleDateFormat("HH:mm:ss"); 20 | super.println("[" + df.format(date) + "] " + string); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /toolkit/src/main/java/toolkit/streams/TextAreaOutputStream.java: -------------------------------------------------------------------------------- 1 | package toolkit.streams; 2 | 3 | import java.io.IOException; 4 | import java.io.OutputStream; 5 | import javax.swing.JTextArea; 6 | 7 | public class TextAreaOutputStream extends OutputStream 8 | { 9 | private final JTextArea textControl; 10 | 11 | public TextAreaOutputStream(JTextArea control) 12 | { 13 | this.textControl = control; 14 | } 15 | 16 | public void write(int b) 17 | throws IOException 18 | { 19 | this.textControl.append(String.valueOf((char) b)); 20 | this.textControl.setCaretPosition(this.textControl.getDocument().getLength()); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /toolkit/src/main/java/toolkit/utilities/SlowOp.java: -------------------------------------------------------------------------------- 1 | package toolkit.utilities; 2 | 3 | import toolkit.windows.utilities.SlowOpGUI; 4 | 5 | public interface SlowOp 6 | { 7 | /** 8 | * Task to run in another thread. 9 | * 10 | * @return Error/Success code 11 | */ 12 | int run(SlowOpGUI state); 13 | } 14 | -------------------------------------------------------------------------------- /toolkit/src/main/java/toolkit/utilities/Swing.java: -------------------------------------------------------------------------------- 1 | package toolkit.utilities; 2 | 3 | import javax.swing.*; 4 | import java.awt.event.ActionListener; 5 | 6 | public class Swing 7 | { 8 | public static JMenuItem createMenuItem(String name, String tooltip, ActionListener event, 9 | JComponent parent) 10 | { 11 | JMenuItem item = Swing.createMenuItem(name, event, parent); 12 | item.setToolTipText(tooltip); 13 | return item; 14 | } 15 | 16 | public static JMenuItem createMenuItem(String name, ActionListener event, JComponent parent) 17 | { 18 | JMenuItem item = Swing.createMenuItem(name, event); 19 | parent.add(item); 20 | return item; 21 | } 22 | 23 | public static JMenuItem createMenuItem(String name, ActionListener event) 24 | { 25 | JMenuItem item = new JMenuItem(); 26 | item.setText(name); 27 | item.addActionListener(event); 28 | return item; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /toolkit/src/main/java/toolkit/utilities/services/ResourceService.java: -------------------------------------------------------------------------------- 1 | package toolkit.utilities.services; 2 | 3 | import cwlib.types.databases.FileEntry; 4 | 5 | import javax.swing.*; 6 | 7 | public interface ResourceService 8 | { 9 | void process(JTree tree, FileEntry entry, byte[] data); 10 | 11 | int[] getSupportedHeaders(); 12 | } 13 | -------------------------------------------------------------------------------- /toolkit/src/main/java/toolkit/utilities/services/TextureService.java: -------------------------------------------------------------------------------- 1 | package toolkit.utilities.services; 2 | 3 | import cwlib.resources.RTexture; 4 | import cwlib.types.databases.FileEntry; 5 | import toolkit.windows.Toolkit; 6 | 7 | import javax.swing.*; 8 | 9 | public class TextureService implements ResourceService 10 | { 11 | public static final int[] HEADERS = { 0x54455820, 0x47544620, 0x47544673, 0x47544653, 12 | 0x89504e47, 0xFFD8FFE0, 0x44445320 }; 13 | 14 | @Override 15 | public void process(JTree tree, FileEntry entry, byte[] data) 16 | { 17 | RTexture texture = entry.getInfo().getResource(); 18 | if (texture == null) 19 | { 20 | System.out.println("Failed to create Texture instance, is this an appropriate " + 21 | "resource?"); 22 | return; 23 | } 24 | 25 | ImageIcon icon = texture.getImageIcon(320, 320); 26 | if (icon != null) Toolkit.INSTANCE.setImage(icon); 27 | else System.out.println("Failed to set icon, it's null?"); 28 | } 29 | 30 | @Override 31 | public int[] getSupportedHeaders() 32 | { 33 | return HEADERS; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /toolkit/src/main/resources/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ennuo/toolkit/dc82bee57ab58e9f4bf35993d405529d4cbc7d00/toolkit/src/main/resources/icon.png -------------------------------------------------------------------------------- /toolkit/src/main/resources/images/slots/adventure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ennuo/toolkit/dc82bee57ab58e9f4bf35993d405529d4cbc7d00/toolkit/src/main/resources/images/slots/adventure.png -------------------------------------------------------------------------------- /toolkit/src/main/resources/images/slots/adventure_mask.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ennuo/toolkit/dc82bee57ab58e9f4bf35993d405529d4cbc7d00/toolkit/src/main/resources/images/slots/adventure_mask.png -------------------------------------------------------------------------------- /toolkit/src/main/resources/images/slots/backdrop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ennuo/toolkit/dc82bee57ab58e9f4bf35993d405529d4cbc7d00/toolkit/src/main/resources/images/slots/backdrop.png -------------------------------------------------------------------------------- /toolkit/src/main/resources/images/slots/lbp1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ennuo/toolkit/dc82bee57ab58e9f4bf35993d405529d4cbc7d00/toolkit/src/main/resources/images/slots/lbp1.png -------------------------------------------------------------------------------- /toolkit/src/main/resources/images/slots/lbp2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ennuo/toolkit/dc82bee57ab58e9f4bf35993d405529d4cbc7d00/toolkit/src/main/resources/images/slots/lbp2.png -------------------------------------------------------------------------------- /toolkit/src/main/resources/images/slots/lbp3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ennuo/toolkit/dc82bee57ab58e9f4bf35993d405529d4cbc7d00/toolkit/src/main/resources/images/slots/lbp3.png -------------------------------------------------------------------------------- /toolkit/src/main/resources/images/slots/polaroid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ennuo/toolkit/dc82bee57ab58e9f4bf35993d405529d4cbc7d00/toolkit/src/main/resources/images/slots/polaroid.png -------------------------------------------------------------------------------- /toolkit/src/main/resources/locked.txt: -------------------------------------------------------------------------------- 1 | # Controls which resources don't get exported as "hashed" 2 | # by default in the AssetExporter. 3 | # descriptor, path 4 | 5 | g9877, naked_to.mol -------------------------------------------------------------------------------- /tools/descriptor/README.md: -------------------------------------------------------------------------------- 1 | # Descriptor 2 | 3 | CLI Java utility for finding missing plan descriptors. -------------------------------------------------------------------------------- /tools/jsoninator/README.md: -------------------------------------------------------------------------------- 1 | # Jsoninator 2 | 3 | CLI Java utility for converting resources between JSON and binary formats. 4 | 5 | Supports (de)serialization of common resources, including but not limited to .plan, .bin, .mat, 6 | .anim, etc 7 | 8 | ## Notes 9 | 10 | Most common revisions for deploy, lbp1, lbp2, and lbp3 should be fully compatible. 11 | 12 | ## Usage 13 | 14 | ```bash 15 | # Convert a resource to JSON 16 | java -jar jsoninator.jar pal_fishsticks_4575.plan fishsticks.json 17 | 18 | # Convert back to a resource 19 | java -jar jsoninator.jar fishsticks.json pal_fishsticks_4575.plan 20 | ``` -------------------------------------------------------------------------------- /tools/sequencerdump/src/main/java/instrument/Instrument.java: -------------------------------------------------------------------------------- 1 | package instrument; 2 | 3 | import cwlib.types.data.GUID; 4 | 5 | public interface Instrument { 6 | GUID getGUID(); 7 | String getName(); 8 | 9 | static Instrument fromGUID(GUID guid) { 10 | for (StandardInstrument value : StandardInstrument.values()) { 11 | if (value.guid.equals(guid)) { 12 | return value; 13 | } 14 | } 15 | return new UnknownInstrument(guid, guid.getValue() + "_Unknown"); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tools/sequencerdump/src/main/java/instrument/UnknownInstrument.java: -------------------------------------------------------------------------------- 1 | package instrument; 2 | 3 | import cwlib.types.data.GUID; 4 | 5 | import java.util.Objects; 6 | 7 | public record UnknownInstrument(GUID guid, String name) implements Instrument { 8 | @Override 9 | public GUID getGUID() { 10 | return guid; 11 | } 12 | 13 | @Override 14 | public String getName() { 15 | return name; 16 | } 17 | 18 | @Override 19 | public boolean equals(Object o) { 20 | if (this == o) return true; 21 | if (!(o instanceof UnknownInstrument that)) return false; 22 | return Objects.equals(guid, that.guid); 23 | } 24 | 25 | @Override 26 | public int hashCode() { 27 | return Objects.hashCode(guid); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /tools/sequencerdump/src/main/java/utils/MathUtils.java: -------------------------------------------------------------------------------- 1 | package utils; 2 | 3 | public final class MathUtils { 4 | 5 | private MathUtils() { 6 | } 7 | 8 | public static float roundToFraction(float value, int fraction) { 9 | return (float) Math.round(value * fraction) / fraction; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /tools/sequencerdump/src/main/java/utils/PositionUtils.java: -------------------------------------------------------------------------------- 1 | package utils; 2 | 3 | import cwlib.enums.Part; 4 | import cwlib.structs.things.Thing; 5 | import cwlib.structs.things.parts.PPos; 6 | import org.joml.*; 7 | 8 | import java.util.Objects; 9 | 10 | public final class PositionUtils { 11 | 12 | private PositionUtils() { 13 | } 14 | 15 | public static Vector3f getRelativePosition(Thing container, Thing thing) { 16 | PPos containerPos = Objects.requireNonNull(container.getPart(Part.POS)); 17 | PPos thingPos = Objects.requireNonNull(thing.getPart(Part.POS)); 18 | return getRelativePosition(containerPos.worldPosition, thingPos.worldPosition); 19 | } 20 | 21 | public static Vector3f getRelativePosition(Matrix4f container, Matrix4f thing) { 22 | return thing 23 | .getTranslation(new Vector3f()) 24 | .sub(container.getTranslation(new Vector3f())) 25 | .rotate(thing.getNormalizedRotation(new Quaternionf()).invert()); 26 | } 27 | } 28 | --------------------------------------------------------------------------------