diff --git a/.gitignore b/.gitignore index c882fcd..e971033 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ /objectdb.xml /build -/dist/ -private +/dist/ \ No newline at end of file diff --git a/README.md b/README.md index ac515b6..f7138cc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,2 @@ # Whitehole -A level editor for Super Mario Galaxy 1 and 2. - -# Todo -- BCSV importing -- Path editing +Whitehole is a level editor for Super Mario Galaxy 1 and 2. \ No newline at end of file diff --git a/build.xml b/build.xml index bc602ed..d54b813 100644 --- a/build.xml +++ b/build.xml @@ -10,6 +10,9 @@ Builds, tests, and runs the project Whitehole. + + + - - + + @@ -76,7 +76,7 @@ is divided into following sections: - + @@ -156,6 +156,7 @@ is divided into following sections: + @@ -840,7 +841,7 @@ is divided into following sections: - + @@ -852,7 +853,7 @@ is divided into following sections: - + @@ -975,15 +976,15 @@ is divided into following sections: - + - + - + @@ -991,7 +992,7 @@ is divided into following sections: - + @@ -1186,7 +1187,7 @@ is divided into following sections: Must select one file in the IDE or set run.class - + Must select one file in the IDE or set applet.url diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties index a3ba1d2..3b15a65 100644 --- a/nbproject/genfiles.properties +++ b/nbproject/genfiles.properties @@ -4,5 +4,5 @@ build.xml.stylesheet.CRC32=8064a381@1.79.1.48 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. nbproject/build-impl.xml.data.CRC32=a7fc49e8 -nbproject/build-impl.xml.script.CRC32=d12a120c -nbproject/build-impl.xml.stylesheet.CRC32=05530350@1.79.1.48 +nbproject/build-impl.xml.script.CRC32=280dc19f +nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48 diff --git a/nbproject/private/private.properties b/nbproject/private/private.properties index 7d2a932..74a30ec 100644 --- a/nbproject/private/private.properties +++ b/nbproject/private/private.properties @@ -3,4 +3,4 @@ do.depend=false do.jar=true javac.debug=true javadoc.preview=true -user.properties.file=C:\\Users\\Aurum\\AppData\\Roaming\\NetBeans\\8.1\\build.properties +user.properties.file=C:\\Users\\Aurum\\AppData\\Roaming\\NetBeans\\8.2\\build.properties diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml index cd3e03d..c056ff8 100644 --- a/nbproject/private/private.xml +++ b/nbproject/private/private.xml @@ -3,6 +3,8 @@ - + + file:/C:/Users/Aurum/Documents/GitHub/Whitehole-1.4/src/com/aurum/whitehole/swing/GalaxyEditorForm.java + diff --git a/nbproject/project.properties b/nbproject/project.properties index c2c546b..69b1a10 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -57,7 +57,7 @@ file.reference.jogl.all.jar=lib/jogl/jogl.all.jar file.reference.xercesImpl.jar=lib\\jdom2\\lib\\xercesImpl.jar file.reference.xml-apis.jar=lib/jdom2/lib/xml-apis.jar includes=** -jar.compress=false +jar.compress=true javac.classpath=\ ${file.reference.xml-apis.jar}:\ ${file.reference.jdom-2.0.2.jar}:\ @@ -91,6 +91,7 @@ javac.classpath=\ # Space-separated list of extra javac options javac.compilerargs= javac.deprecation=false +javac.external.vm=false javac.processorpath=\ ${javac.classpath} javac.source=1.7 @@ -111,7 +112,7 @@ javadoc.splitindex=true javadoc.use=true javadoc.version=false javadoc.windowtitle= -main.class=whitehole.Whitehole +main.class=com.aurum.whitehole.Whitehole manifest.file=manifest.mf meta.inf.dir=${src.dir}/META-INF mkdist.disabled=false diff --git a/src/Resources/GeneralPos.txt b/src/Resources/GeneralPos.txt deleted file mode 100644 index c038fd0..0000000 --- a/src/Resources/GeneralPos.txt +++ /dev/null @@ -1,189 +0,0 @@ -いいえ選択移動位置 -アイテム惑星戻り -ウォーターバズーカマリオ位置 -エピローグマリオ -カメラ基準点 -ガード出現ポイント1 -キノピオメッセンジャー -キングトッシンデモ開始位置 -クッパ階段戦の砲弾出現 -クッパJrシップ戦マリオ位置 -グランドスター出現位置 -グランドスター出現 -グランドスター帰還リザルト -ゲート中心 -ゲーム終了位置 -ゲーム開始位置 -コア中心 -コンプリートエンディングデモ基準点 -コーチチュートリアル位置 -コーチレース終了後位置 -コーチ2回目位置 -ゴーストデモゴースト位置 -ゴーストデモマリオ位置 -ジュゲム突進点1 -ジュゲム突進点2 -スターゲットデモ座標 -スタートカメラマリオ座標 -スタート位置(サーフィン) -スピンドライバ初出基準点 -スピンドライバ初出終了位置 -タイムアタック前位置 -タイムアタック後位置 -ダウンデモ後(マリオ) -ダウンデモ -チュートリアル位置 -デモ中心 -デモ位置(クッパJr登場デモ) -ドドリュウ再セット -ドドリュウ岩 -ドーム中心 -ノーマルエンディングデモ基準点 -ハニークイーンとの会話位置 -バッタンキング基準位置 -バトラーデモ終了 -バトラーマップレクチャー -バトルシップ・タイムアタック前位置 -バトルシップ・タイムアタック後位置 -パマタリアンハンターデモ用 -パワーアップデモ(クッパ) -パワーアップデモ(マリオ) -パワーアップデモLv2(クッパ) -パワーアップデモLv2(マリオ) -パワーアップデモLv3(クッパ) -パワーアップデモLv3(マリオ) -ピーチャンレーサーレース終了後位置 -ピーチャン位置[スター渡し] -ピーチ登場デモ後(マリオ) -ピーチ誘拐デモ基準点 -ピーチ誘拐デモ終了位置 -プレイヤーデモ位置(ベビーディノパックン戦) -プレイヤーデモ位置(ベリードラゴン戦) -プレイヤー一時退避 -ベビチコ出会い点 -ベビーディノパックンデモ位置 -ペンギン移動後 -ボスジュゲムダウンデモ位置 -ボスジュゲムデモ位置 -ボスブッスン位置 -ボス戦デモ開始位置 -ポルタデモプレイヤー位置 -ポルタ開始デモプレイヤー位置 -マイスター位置[グランドスター帰還後] -マイスター位置[デフォルト] -マイスター位置[変化前] -マイスター位置[変化後] -マイスター位置[帰還後アイテム惑星] -マイスター位置[NPC紹介] -マリオイベント会話2 -マリオイベント会話3 -マリオイベント会話 -マリオデモ位置 -マリオボスべー対決 -マリオ位置 -マリオ位置00空01 -マリオ位置01空00 -マリオ位置02空03 -マリオ位置03空00 -マリオ位置04空03 -マリオ位置05空02 -マリオ位置06空02 -マリオ位置07空04 -マリオ位置08空01 -マリオ位置[でしゃばりルイージ] -マリオ位置[アイテム惑星移動後] -マリオ位置[グランドスター帰還後] -マリオ位置[デモ中] -マリオ位置[デモ後] -マリオ位置[ハラペコスターピースチコ] -マリオ位置[ファイルセレクトから] -マリオ位置[ワールドマップから] -マリオ位置[再スタート] -マリオ位置[変化前] -マリオ位置[変化後] -マリオ位置[帰還後アイテム惑星] -マリオ位置[帰還後位置上] -マリオ位置[帰還] -マリオ位置[郵便屋さんイベント] -マリオ位置[NPC紹介] -マリオ再セット位置 -マリオ再セット位置1 -マリオ再セット位置2 -マリオ再セット -マリオ再セット1 -マリオ再セット2 -マリオ再セット3 -マリオ再セット4 -マリオ最終デモ終了後位置 -マリオ最終戦開始位置 -マリオ移動後 -マリオ顔惑星煙突出口 -メラキンデモ後セット位置 -メラキンマリオ再セット位置 -モンテ投げターゲット位置 -ヨッシー出会いデモ基準点 -ヨッシー出会いデモ後マリオ位置 -リスタート -ルイージ帰還 -レース終了後位置テレサ -レース終了後位置 -レース開始時マリオ位置 -ロゼッタ状況説明マリオ -ワープ位置(サーフィン) -二脚ボス爆発デモ後座標 -合体ブロック故郷点 -図書室中心 -子連れカメムシデモ後ポイント -惑星中心 -惑星Lv2 -惑星Lv3 -戦闘開始(クッパ) -戦闘開始(マリオ) -朗読デモ終了 -未入力 -爆破デモ後マリオ -着弾点0 -着弾点1 -着弾点2 -着弾点3 -着弾点4 -着弾点5 -着弾点6 -着弾点7 -着弾点8 -着弾点9 -着弾点10 -絵本移動ポイント000 -絵本移動ポイント001 -絵本移動ポイント002 -落下点1 -落下点2 -落下点3 -落下点4 -落下点5 -負け時マリオ位置 -開始デモ -開始マリオ -階段の戦い0(クッパ) -階段の戦い1(クッパ) -階段の戦い2(クッパ) -隠れ位置 -Lv1終了(クッパ) -Lv1終了(マリオ) -Lv1開始(クッパ) -Lv1開始(マリオ) -Lv2終了(クッパ) -Lv2終了(マリオ) -Lv2開始(クッパ) -Lv2開始(マリオ) -Lv3内側(クッパ) -Lv3内側(マリオ) -Lv3外側(クッパ) -Lv3外側(マリオ) -MarioDemoPos -MarioDemoPos2 -MarioDemoPos3 -MarioDemoPos4 -TicoDemoPos1 -TicoDemoPos2 -TicoDemoPos3 \ No newline at end of file diff --git a/src/Resources/Hash.txt b/src/Resources/Hash.txt deleted file mode 100644 index a5d2324..0000000 --- a/src/Resources/Hash.txt +++ /dev/null @@ -1,599 +0,0 @@ -# 000113F5 - LightData -# 02BA7D47 - BackToEgg -# 043838B2 - PointPos -# 04C33057 - Shadow -# 04C33058 - Shadow -# 04C33059 - Shadow -# 059A5892 - LightData -# 0A71F2C8 - LightData -# 0B1C280F - LightData -# 0B1C2810 - LightData -# 0B1C2815 - LightData -# 0B1C2820 - LightData -# 0DB31919 - ActorStateWalk -# 0ECF2D59 - LightData -# 0ECF2D5A - LightData -# 0ECF2D5F - LightData -# 0ECF2D6A - LightData -# 0F67A990 - LightData -# 0F67A991 - LightData -# 0F67A996 - LightData -# 0F67A9A1 - LightData -# 15ADC947 - StageInfo -# 165C8F89 - LightData -# 17175211 - LightData -# 18916416 - Shadow -# 18916417 - Shadow -# 18916418 - Shadow -# 1BEEEC47 - LightData -# 267DEBC6 - DynamicJointCtrl -# 27D98908 - LightData -# 2EC2FBC8 - ActorAnimCtrl -# 33922D02 - ActionSound -# 36010F09 - ActorAnimCtrl -# 3C8BEA81 - LightData -# 3C8BEA82 - LightData -# 3C8BEA87 - LightData -# 3C8BEA92 - LightData -# 3E264686 - ActorAnimCtrl -# 40026350 - LightData -# 40026351 - LightData -# 40026356 - LightData -# 40026361 - LightData -# 433A5DB7 - SpaceParts -# 43B5689A - LightData -# 43B5689B - LightData -# 43B568A0 - LightData -# 43B568AB - LightData -# 43EA1591 - HeapSizeExcept -# 444DE4D1 - LightData -# 444DE4D2 - LightData -# 444DE4D7 - LightData -# 444DE4E2 - LightData -# 4D6DBDAE - SpaceParts -# 4D899144 - ActorAnimCtrl -# 4DB4F9C4 - InitSensor -# 50F5D5E6 - CubeCamera -# 528AC841 - InitSensor -# 55CFC442 - ChangeObj -# 5B36581D - ActorAnimCtrl -# 5FF07156 - LightData -# 5FF07157 - LightData -# 5FF07158 - LightData -# 5FFE88D7 - LightData -# 5FFE88D8 - LightData -# 5FFE88D9 - LightData -# 60CB6B62 - SoundIdToInstList -# 62746B5E - ActorAnimCtrl -# 6882CDE8 - ActorAnimCtrl -# 690EA42B - LightData -# 69B44F36 - LightData -# 69B44F37 - LightData -# 69B44F38 - LightData -# 69C266B7 - LightData -# 69C266B8 - LightData -# 69C266B9 - LightData -# 6A99A2DB - ActorAnimCtrl -# 6BEC7F26 - ActorAnimCtrl -# 6D52E4A8 - BackToEgg -# 6F563064 - ActorAnimCtrl -# 6F9CA5E9 - ActorAnimCtrl -# 7193684C - LightData -# 7232F698 - ActorAnimCtrl -# 75C8535F - LightData -# 75C85360 - LightData -# 75C85361 - LightData -# 75D66AE0 - LightData -# 75D66AE1 - LightData -# 75D66AE2 - LightData -# 77608395 - LightData -# 77608396 - LightData -# 77608397 - LightData -# 776DC061 - LightData -# 776DC062 - LightData -# 776DC067 - LightData -# 776DC072 - LightData -# 776E9B16 - LightData -# 776E9B17 - LightData -# 776E9B18 - LightData -# 77D9EB32 - ActorStateWalk -# 79D6BACA - LightData -# 79D6BACB - LightData -# 79D6BAD0 - LightData -# 79D6BADB - LightData -# 79FCED99 - ActorAnimCtrl -# 7CD48D69 - LightData -# 7D098080 - LightData -# 7D098081 - LightData -# 7D098086 - LightData -# 7D098091 - LightData -# 8451FAB6 - MarioFaceShipEventCastTable -# 8451FAB7 - MarioFaceShipEventCastTable -# 8451FAB8 - MarioFaceShipEventCastTable -# 8451FAB9 - MarioFaceShipEventCastTable -# 8451FABA - MarioFaceShipEventCastTable -# 8451FABB - MarioFaceShipEventCastTable -# 8451FABC - MarioFaceShipEventCastTable -# 8451FABD - MarioFaceShipEventCastTable -# 8451FABE - MarioFaceShipEventCastTable -# 8451FABF - MarioFaceShipEventCastTable -# 8BFDE078 - ActorAnimCtrl -# 8E5186E8 - LightData -# 912C1F84 - SpaceParts -# 93430C6E - SpaceParts -# 93430C6F - SpaceParts -# 93430C70 - SpaceParts -# 95CB4ED0 - PosShell -# 95CB4ED0 - ShotPos -# 95CB4ED0 - SpaceParts -# 95CB4ED1 - PosShell -# 95CB4ED1 - ShotPos -# 95CB4ED1 - SpaceParts -# 95CB4ED2 - PosShell -# 95CB4ED2 - ShotPos -# 95CB4ED2 - SpaceParts -# B5B9663D - PosShell -# B5B9663D - ShotPos -# B5B9663D - SpaceParts -# B5B9663E - PosShell -# B5B9663E - ShotPos -# B5B9663E - SpaceParts -# B5B9663F - PosShell -# B5B9663F - ShotPos -# B5B9663F - SpaceParts -# B7AB8F70 - LightData -# B7AB8F71 - LightData -# B7AB8F76 - LightData -# B7AB8F81 - LightData -# B812BAE6 - MarioFaceShipEventCastTable -# B812BAE7 - MarioFaceShipEventCastTable -# B812BAE8 - MarioFaceShipEventCastTable -# B812BAE9 - MarioFaceShipEventCastTable -# B812BAEA - MarioFaceShipEventCastTable -# B812BAEB - MarioFaceShipEventCastTable -# B812BAEC - MarioFaceShipEventCastTable -# B812BAED - MarioFaceShipEventCastTable -# B812BAEE - MarioFaceShipEventCastTable -# B812BAEF - MarioFaceShipEventCastTable -# B8713CCD - ActorAnimCtrl -# C4F73392 - ChangeObj -# C6672A7E - BackToEgg -# CDC4FEAD - CubeCamera -# D6C80400 - ScenarioData -# DB99E8F5 - LightData -# DE82372A - ChangeSceneListInfo -# E6759A6C - LightData -# EC91CAB1 - LightData -# EC91CAB2 - LightData -# EC91CAB7 - LightData -# EC91CAC2 - LightData -# F730F24A - ActorAnimCtrl -AccelRateToBckPos -ActionName -ActionSe -ActionType -ActorAnimName -Affect -AllSoundStopFrame -AnimCameraEndFrame -AnimCameraName -AnimCameraStartFrame -AnimName -AnimName -AppearPowerStarObj -AreaLightName -AreaShapeNo -BankProgNo -BckName -BckName -BckStartFrame -BeatRatio -BendMaxDegree -Bgm -BgmFadeStep -BgmIdName -BgmName -BgmStateNo -BgmWipeoutFrame -Binder -BloomFlag -BlurAlpha -BlurFadeInInStep -BlurFadeOutStep -BlurOffset -BlurTotalStep -CalcGravity -Callback -CameraSetId -CameraShakeName -CameraShakeNameFar -CameraShakeNameMiddle -CameraTargetCastID -CameraTargetName -Camera_id -Camera_through -CastID -CastId -CastName -CastNum -ChangeBgmIdName0 -ChangeBgmIdName1 -ChangeBgmIdName2 -ChangeBgmIdName3 -ChangeBgmIdName4 -ChangeBgmStage0 -ChangeBgmStage1 -ChangeBgmStage2 -ChangeBgmStage3 -ChangeBgmStage4 -ChildObjId -ClassName -ClippingGroupId -CloseGameFlag -CloseStageName -CloseStageScenarioNo -Collision -CollisionName -CollisionParts -ColorChange -Comet -CometAppearMedalNum -CometLimitTimer -CommonPath_ID -ContinueAnimEnd -CtrlJointNumMax -Data -DegreeMax -DegreeMaxVertical -DemoGroupId -DemoName -DemoSkip -DistanceFar -DistanceInvalid -DistanceMin -DistanceNear -Distant -DrawOrder -DropLength -DropStart -Dummy -EffectName -EnName -EndDirMaxDegree -EndFrame -EndLocalDirX -EndLocalDirY -EndLocalDirZ -EnvColor -EventNo -EventType -FaceCtrl -FarClip -FarLimitRate -FileCacheSize -FlagType -Floor_code -Follow -FollowId -FollowScale -FootNumMax -ForceLowScenarioName0 -ForceLowScenarioName1 -ForceLowScenarioName2 -ForceLowScenarioName3 -ForceLowScenarioName4 -ForceLowScenarioName5 -ForceLowScenarioName6 -ForceLowScenarioName7 -Friction -FrontSize -GalaxyName -GeneratorID -GrandStarNo -Gravity -Gravity_type -GroupId -GroupName -HitSensorNumMax -IconOffsetX -IconOffsetY -IndirectFlag -InitFunction -Interpolate -IntoBeat -InvalidateClipping -Inverse -IsBgmStop -IsBreakCrystal -IsColorChange -IsContinuous -IsFixRoot -IsHidden -IsPrepare -IsRight -IsSubRoute -ItemInfoName -Joint -JointName -LayerNo -LightAffectValue -LightID -LoopBeat -LoopEndSample -LoopStartSample -LowFlag -LuigiModeTimer -MainPartName -MainPartStep -MapParts_ID -MarioNo -MessageId -MiddleFlag -MiniatureName -ModelName -MoveConditionType -MultiBgmName -Name -NamePlatePosX -NamePlatePosY -NamePlatePosZ -NearLimitRate -No -ObjName -Obj_ID -Obj_arg0 -Obj_arg1 -Obj_arg2 -Obj_arg3 -Obj_arg4 -Obj_arg5 -Obj_arg6 -Obj_arg7 -OffsetX -OffsetY -OffsetY0 -OffsetY1 -OffsetZ -OrScenarioNo -OrStageName -PadRumbleName -PadRumbleNameFar -PadRumbleNameMiddle -Param00 -Param00F32 -Param00Int -Param00Str -Param00VecX -Param00VecY -Param00VecZ -Param01 -Param01F32 -Param02 -Param03 -ParamName -ParamScale -ParamType -ParentID -ParentId -ParentName -PartName -PartsIndex -PartsTypeName -Path_ID -PitchChangeArg1 -PitchChangeArg2 -PitchChangeArg3 -PitchChangeArg4 -PitchChangeType -PlanetName -PointIndex -PointIndexA -PointIndexB -PointPosIndex -PointPosX -PointPosY -PointPosZ -PosName -PosName -PosOffsetX -PosOffsetY -PosOffsetZ -Power -PowerStarId -PowerStarNum -PowerStarType -PressType -Priority -PrmColor -Radius -Range -RateValue -ResourceName -ReturnBgm -ReturnType -RotateAccelType -RotateAngle -RotateAxis -RotateSpeed -RotateStopTime -RotateType -SW_A -SW_APPEAR -SW_AWAKE -SW_B -SW_DEAD -SW_PARAM -SW_SLEEP -ScaleMax -ScaleMin -ScaleValue -ScenarioName -ScenarioNo -SceneNo -SensorName -SensorType -ShadowType -ShapeModelNo -ShowModel -SideOffset -SideSize -SignMotionType -SoundIdName -SoundLabel -SoundName -SoundType -Sound_code -StageName -StageScenarioNo -StageType -StartFrame -StartType -StateName -StateStep -StreamName -SubPartName -SubPartTotalStep -SubPoint -SuspendFlag -SwitchA -SwitchB -SwitchName -SwitchNo -SyncShow -SystemSe -TimeSheetName -TotalStep -TriggerName -TriggerType -Type -UniqueName -UpperFlag0 -UpperFlag1 -UseTimeKeepDemo -UseType -Valid -Validity -ViewGroupId -Visible -Volume -VolumeChangeArg1 -VolumeChangeArg2 -VolumeChangeArg3 -VolumeChangeArg4 -VolumeChangeType -VolumeCut -VolumeEnd -VolumeStart -WaitUserInputFlag -Wall_code -WatchedEventNo -WaterFlag -WipeFrame -WipeName -WipeType -WorldNo -ZoneName -angleA -angleB -attribute -axis.X -axis.Y -axis.Z -camendint -camera_id -camint -camtype -closed -dir_x -dir_y -dir_z -dist -eflag.enableEndErpFrame -eflag.enableErpFrame -en_name -end_frame -evfrm -evpriorit -flag.antibluroff -flag.collisionoff -flag.lofserpoff -flag.nofovy -flag.noreset -flag.subjectiveoff -fovy -gflag.camendint -gflag.enableEndErpFrame -gflag.thru -gndint -id -interpole -jp_name -l_id -loffset -loffsetv -lower -lplay -mGoods0 -mGoods1 -mGoodsJoint0 -mGoodsJoint1 -name -no -num1 -num2 -num_pnt -path_arg0 -path_arg1 -path_arg2 -path_arg3 -path_arg4 -path_arg5 -path_arg6 -path_arg7 -play_frame -pnt0_x -pnt0_y -pnt0_z -pnt1_x -pnt1_y -pnt1_z -pnt2_x -pnt2_y -pnt2_z -point_arg0 -point_arg1 -point_arg2 -point_arg3 -point_arg4 -point_arg5 -point_arg6 -point_arg7 -pos_x -pos_y -pos_z -pushdelay -pushdelaylow -roll -scale_x -scale_y -scale_z -start_frame -type -udown -up.X -up.Y -up.Z -uplay -upper -usage -version -vpanaxis.X -vpanaxis.Y -vpanaxis.Z -vpanuse -woffset.X -woffset.Y -woffset.Z -wpoint.X -wpoint.Y -wpoint.Z \ No newline at end of file diff --git a/src/Resources/ZoneHash.txt b/src/Resources/ZoneHash.txt deleted file mode 100644 index e788d2d..0000000 --- a/src/Resources/ZoneHash.txt +++ /dev/null @@ -1,762 +0,0 @@ -# SMG1 -AsteroidBlockZone -AstroDome -AstroGalaxy -AutumnMysteryRoomZone -BattleShipGalaxy -BattleShipKillerPlanetZone -BeamerRushZone -BeamGunChaindPlanetZone -BeltConveyerExGalaxy -BirthdayCakeZone -BlueStarZone -BombheiLectureZone -BombTimeAttack2Zone -BombTimeAttackZone -BossBazookaTowerZone -BreakDownPlanetGalaxy -BreakDownPlanetZone -BrokenKillerPlanetZone -CannonFleetGalaxy -CannonGCaptureZone -CanonTurnOverZone -CaveChangeSizeZone -CaveMysteryRoomZone -ChoConveyorZone -ClimbMysteryRoomZone -CocoonExGalaxy -CocoonEXZone -CocoPoihanaZone -CoCoTwinZone -ColdTwinFallZone -CosmosGardenGalaxy -CrossRingZone -CubeBubbleEXAZone -CubeBubbleEXBZone -CubeBubbleEXCZone -CubeBubbleExDZone -CubeBubbleExLv1Galaxy -CubeBubbleExLv2Galaxy -CubeBubbleExSZone -DandelionHillZone -DarknessRoomZone -DarkRoomGalaxy -DesertConvectionZone -DesertDiskZone -DesertInsideZone -DinoPackunBattleLv2Zone -DinoPackunBattleZone -DiskGardenZone -DorayakiFortressZone -DoughnutZone -DropOfWaterZone -EggStarFlipPanelZone -EggStarGalaxy -ElectricBegomanSpikeZone -ElectricUfoLevel2Zone -ElectricUfoZone -EpilogueDemoStage -EringiPlanetZone -FactoryGalaxy -FileSelect -FishTunnelGalaxy -FlagDiscZone -FlipPanelExGalaxy -FlipPanelExZone -FloaterLandZone -FloaterOtakingGalaxy -FlowerPlanetZone -FlowerRoadZone -ForestBossZone -ForestHomeZone -FortressCliffClimbZone -FortressEntranceZone -FortressJumpBeamerZone -GCaptureTutorialZone -GhostShipCaveZone -GlassyTwinsPlanetZone -HeavenlyBeachGalaxy -HeavenlyBeachZone -HeavensBlackHoleZone -HeavensDoorGalaxy -HeavensDoorInsideZone -HeavensDoorLargeZone -HeavensDoorMiddleZone -HeavensDoorMysteriousZone -HeavensDoorSmallZone -HellBallZone -HellGcapZone -HellHomeZone -HellJKillerZone -HellLavaBallRisingPlanetZone -HellLavaFloatingZone -HellMeteoZone -HellPoolAZone -HellPoolBZone -HellProminenceGalaxy -HellRotateGround2DPlanetZone -HellShellZone -HellTypeCDossunPlanetZone -HoneyBeeExGalaxy -HoneyBeeKingdomGalaxy -HoneyMysteryRoomZone -HoneyQueenZone -HopperBonusZone -HopperBottleZone -HopperTutorialZone -IceLavaIslandZone -IceMichihikiZone -IceMountainZone -IceRingAZone -IceRingBZone -IceVolcanoGalaxy -KoopaBattleVs1BossZone -KoopaBattleVs1Galaxy -KoopaBattleVs2BossZone -KoopaBattleVs2Galaxy -KoopaBattleVs3ArigaAZone -KoopaBattleVs3ArigaBZone -KoopaBattleVs3ArigaCZone -KoopaBattleVs3AZone -KoopaBattleVs3BossZone -KoopaBattleVs3BZone -KoopaBattleVs3CZone -KoopaBattleVs3DZone -KoopaBattleVs3Galaxy -KoopaBattleVs3StartZone -KoopaJrShipBattleLv1Tmp1Zone -KoopaJrShipLV1Galaxy -KuriboThirtyZone -LibraryRoom -MarblePlanetZone -MarioLancherLecture2Zone -MarioLancherLecture3Zone -MechanicKoopaZone -MiniKuriZone -MiniMechanicKoopaZone -MysteryGravityRoomZone -ObjNameTable -OceanFloaterLandGalaxy -OceanPhantomCaveGalaxy -OceanPuddingZone -OceanRingGalaxy -OceanRingZone -OceanTwinPiratesZone -OnimasuZone -OtaKingStageZone -PeachCastleFinalGalaxy -PeachCastleGardenGalaxy -PeanutZone -PhantomBossSpiderZone -PhantomDarknessRoomZone -PhantomGalaxy -PhantomIceMazeZone -PhantomNestZone -PhantomSpaceGraveyardZone -PoihanaPlanetZone -PoleUnizoZone -PoyoPoyoPlanetZone -PuffballBZone -PuffballCZone -PuffballZone -PukupukuGambolZone -QuestionBoxZone -QuestionFlowerGardenZone -QuickSand2DZone -RabbitMazeZone -RabbitMoonZone -ReverseForestHomeZone -ReverseGravityTowerZone -ReverseKingdomGalaxy -SandChangeSizeZone -SandClockGalaxy -SandIslandSamboZone -SandIslandZone -SandKillerZone -SandRingZone -SandStormJumpZone -SandStreamZone -SandTowerZone -SandUpDownZone -ScrewFleetZone -SeaVolcanoZone -SkullSharkGalaxy -SnowCapsuleGalaxy -SnowCapsuleZone -SoramameBZone -SoramameCZone -SoramameZone -SpaceMineGCaptureZone -SpaceStationZone -SphereInsideZone -SpringWaterPlanetZone -StarDustAssemblyBlockZone -StarDustGalaxy -StarEggRoadZone -SubmarineVolcanoPlanetZone -SurfingLV1Galaxy -SurfingLV1Zone -SurfingLv2Galaxy -SweetsAsteroidZone -TamakoroExAZone -TamakoroExBZone -TamakoroExLv1Galaxy -TamakoroExLv2Galaxy -TearDropGalaxy -TeresaHouseZone -TeresaMario2DGalaxy -TeresaRaceZone -ThrowTutorialZone -ToySphereInsideZone -TransformationExGalaxy -TridentZone -TriLegLV1Galaxy -TriPodBossZone -TwinFallLakeZone -TwinPeanutsZone -UfoBegomanChainedPlanetZone -UfoFleetLv1Zone -UfoFleetLv3Zone -UfoGravityTurnOverZone -UnderseaTunnelZone -VanVanVanishLv2Zone -VolcanoPlanetZone -VolMichihikiZone -VsHugeBattleShipLv2Zone -VsHugeBattleShipZone -WallClimbEXAZone -WallClimbEXBZone -WallClimbEXCZone -WaterRoadCaveExZone -WaterShellZone -WormEatenZone - -# SMG2 -AbekobeBlockZone -AbekobeDossunZone -AbekobeGalaxy -AbekobeLiftZone -AbekobePowerStarZone -AbekobeRoofActionZone -AbekobeStartZone -AbekobeWallActionZone -AncientExcavationGalaxy -AncientExcavationTest02Galaxy -AndoBonusTest -AndoPlanetJumpTest -AndoSwimTest -AndoYoshi2Test -AndoYoshiStage -AoyagiTest -AoyagiTestMore -AssemblyBlockCloudPlanetZone -AtomicTeresaCircleZone -BarrelBaloonTestZone -BarrelColonyZone -BarrelGravityConversionPlanetZone -BarrelTestZone -BellyDragonLv1StartZone -BellyDragonLv1Zone -BellyDragonLv2Zone -BigBigEndZone -BigGalaxy -BigHanachanZone -BigPeanutPlanetZone -BigTree2Galaxy -BigTreePlanetWideZone -BigWaterFallGalaxy -BlueStarLaserPlanetZone -BonusAZone -BossBussunZone -BossJugemZone -BossParadeGalaxy -BussunTestZone -ChallengeGliderGalaxy -Chaos2DAutoAthletics02Zone -Chaos2DAutoAthleticsZone -Chaos2DBegomanZone -Chaos2DBomb03Zone -Chaos2DBombAutoZone -Chaos2DJumpZone -Chaos2DMoveGravityTestZone -Chaos2DMoveGravityZone -Chaos2DTogeZone -ChaosBossBussunZone -ChaosGravityGalaxy -ChaosManHoleWanwanZone -ChaosManHoleZone -ChaosStartZone -ChildRoomGalaxy -ClipScrollPlanetZone -Cloud2DPlanetZone -CloudBossStinkBugZone -CloudGardenGalaxy -CloudMarioMax2DPlanetZone -CloudSliderPlanetZone -CoconutsGravityZone -CoinInfernoPlanetZone -CommonTshapeZone -ConfirmObj -CosmicBirdRoad -CreekPlanetTestZone -CutTimberPlanetZone -CylinderExplainTest -CylinderPlanetZone -DarknessRoomYoshiPlanetZone -DarkRainbowCubeZone -DarkRiverBombZone -DarkRiverCylinderLiftZone -DarkRiverDashZone -DarkRiverLiftMiniZone -DarkRiverMoveTwinLiftsZone -DarkRiverSanpoZone -DarkRiverTamaKoroZone -DarkRoadPlanetZone -DarkRoadTest02PlanetZone -DarkYosshiBalloonPlanetZone -DashRingSwimZone -DashYoshiBridgeSlopeZone -DashYoshiMoveClimbZone -DashYoshiTimerBridgeZone -DashYoshiWallClimbZone -DigMineGalaxy -DimensionBigCastleGalaxy -DimensionVrTest01PlanetZone -DinoPackunLv1Zone -DinoPackunZone -DodoryuZone -DrillAndWaterPlanetZone -DrillPearPlanetZone -DrillPlanetMazeZone -DrillUpDownHardPlanetZone -DrillUpDownPlanetZone -DrumActionPlanetZone -DrumBegomanHoleZone -DrumBombMazeZone -DrumCloudPlanetZone -E3MovAppearFleetZone -E3MovBigSmall -E3MovCloud2DPlanetZone -E3MovCloudGardenGalaxy -E3MovCloudSliderPlanetZone -E3MovCreekPlanetZone -E3MovCutTimberPlanetZone -E3MovDashYoshiZone -E3MovDigMineBossZone -E3MovDigMineInsideZone -E3MovDigMineStartZone -E3MovDrumCloudPlanetZone -E3MovFlowerBeeTutorial00Zone -E3MovFlowerGardenPlanetZone -E3MovFlowerHighlandGalaxy -E3MovFlowerJumpBallZone -E3MovFlowerPlantPole00Zone -E3MovFlowerSlider00Zone -E3MovFlowerWallJumpTutorial00Zone -E3MovHipDropMovePlanetZone -E3MovLightLabyrinthPlanetZone -E3MovMarioFacePlanetZone -E3MovMizutamaPlanetZone -E3MovMokuValleyEntPlanetDemoZone -E3MovMokuValleyEntPlanetZone -E3MovNailedUpHanaPlanetZone -E3MovOpeningCloudZone -E3MovPurpleCoinInfernoPlanetZone -E3MovRedBlueEx -E3MovSearchWanwan -E3MovSkyIslandBarrelPlanetZone -E3MovSkyIslandShipPlanetZone -E3MovSnowYukkinaZone -E3MovSnowZone -E3MovStartJourneyZone -E3MovTubeSliderTutorialGalaxy -E3MovYoshiPlanetZone -E3MovYoshiYCaptureZone -E3YoshiSpinDriver -EarthenPipeRoomA -EarthenPipeRoomAZone -EarthenPipeRoomBZone -EarthenPipeRoomCZone -EarthenPipeRoomDZone -EarthenPipeRoomEZone -EarthenPipeRoomFZone -EasyMoveBlockZone -EasyRedBlueBlockZone -EasySmallPlanetZone -FileSelect -FingerHeadTestZone -FireBarPlanet03Zone -FireWoodBoxPlanetLv2Zone -FireWoodBoxPlanetOrgZone -FireWoodBoxPlanetZone -FLDZAKOPRD -FlowerBeeTutorial00Zone -FlowerHighlandGalaxy -FlowerJumpBallZone -FlowerPlantAttack00Zone -FlowerPlantPole00Zone -FlowerSlider00Zone -FlowerSlider01Zone -FlowerSmallPlanetZone -FlowerWallJumpTutorial00Zone -FollowerDrillBossImageZone -FollowerDrillPlanetInsideZone -FollowerDrillTest1Zone -FracturePaperPlanetZone -GambleDiceTest01PlanetZone -GambleDiceTest02PlanetZone -GambleDiceTest03PlanetZone -GambleDiceTest04PlanetZone -GemAsteroidGalaxy -GhostConveyorGalaxy -GhostTownRoadZone -GiantRotationPlanetZone -GliderDangerCaveZone -GoharaTestA -GoroDashOrg01Zone -GoroDashZone -GoroMarioBossZone -GoroMarioCZone -GoroMarioHomeBZone -GoroMarioHomeZone -GoroRockGalaxy -GrandGalaxyMapZone -HashimotoTest23Map -HashimotoTest27Map -HashimotoTest42Map -HashimotoTestIZone -HayakawaBossTestSimpleStage -HayakawaBossTestStage -HayakawaHeadingPanelEasyStage -HayakawaHeadingPanelHardStage -HayakawaHeadingPanelSuperStage -HayakawaHeadingPanelUltraStage -HayakawaRideTestStage -HayakawaTestStage -HayashidaSwimTest -HayashidaTest -HipDropMovePlanetZone -HoleSphere2Zone -HoleSphere3Zone -HoleSphereZone -HomeCenterGalaxy -HomeCenterTest01Galaxy -HoneyBeeClimbEasyZone -HoneyBeeSmallVillageTest01Zone -HoneyBeeSmallVillageZone -HoneyBeeVillageGalaxy -HoneyBeeVillageHomeZone -IceMagmaSeaPlanetZone -IslandFleetCoinRoomPlanetZone -IslandFleetGalaxy -IslandFleetNewGavityZone -JungleGliderGalaxy -KachikochiLavaGalaxy -KachiRelayPlanetZone -KarakuriWanwanTest -KingOfKingsGalaxy -KingOtaKingZone -KingTossinTestZone -KoopaBattanGravityZone -KoopaBossLv1Zone -KoopaCastleGalaxy -KoopaFinalBattleZone -KoopaJrCastleZone -KoopaJrLv2Galaxy -KoopaJrRobotZone -KoopaLv1AZone -KoopaLv1BattleZone -KoopaLv1BZone -KoopaLv1CZone -KoopaLv1DZone -KoopaLv2BattleZone -KoopaLv3AZone -KoopaLv3BattleZone -KoopaLv3BZone -KoopaLv3CZone -KoopaVs1Galaxy -KoopaVs1Road02Zone -KoopaVs1RoadDossun01Zone -KyarKyarOutBreak -LargeActionPlanetAZone -LargeActionPlanetBZone -LargeActionPlanetZone -LaserFlipPanelPlanetZone -LavaBabble2D01Zone -LavaBallSlicesPlanetZone -LavaFluffFlyingPlanetZone -LavaFluffZone -LavaHammerBrosPlanetZone -LavaRelayPlanetZone -LavaSwimPlanetZone -LavaTowerZone -LeafBoardCoinPlanetZone -LightLabyrinthPlanetZone -LongFlowSandPlanetZone -LongForCastleGalaxy -MadnessOnimasuGalaxy -MagicBlueStarZone -MagicDarkMatterDrillZone -MagicDarkMatterGCapZone -MagicGalaxy -MagicLeafZone -MagicRelayPlanetZone -MagmaBoatPlanetZone -ManekuriAZone -Mario64Battan -MarioFaceGalaxy -MarioFacePlanetYokobe -MarioFaceShipGalaxy -MarioFaceShipNewTest03Zone -MarioFaceShipNewZone -MarioFaceShipTest02Zone -MarioFaceShipZone -MarioOnMarioGalaxy -MemoryRoadGalaxy -MessageCheck -MinetaStageObjTest -MiniGravityZone -MoguchiRestartZone -MokumokuValleyEndZone -MokumokuValleyGalaxy -MokuTowerPlanetZone -MotokuraSnowAZone -MotokuraTest2DEnemy -MotokuraTest2DSwim -MotokuraTest2DSwim2 -MotokuraTest2DSwimMap -MotokuraTest2DSwimTutorial -MotokuraTestBalloonYoshi -MotokuraTestFly -MotokuraTestJrLv2Boss -MotokuraTestMapObject -MotokuraTestNewCastle -MotokuraTestNigero -MotokuraTestPlanetShip -MotokuraTestSnowObject -MotokuraTestSwim -MotokuraTropicalPurple -MtEnemyPark01PlanetZone -MtEnemyPark02PlanetZone -MtEnemyPark03PlanetZone -MtFloaterLandZone -MuimuiPlanetZone -MuimuiScoreLv1PlanetZone -MuimuiScoreLv2PlanetZone -MurataTest -MysteryCandyCastlePlanetZone -MysteryCandyGalaxy -MysteryCandyPlanetZone -MysteryCandyTest01PlanetZone -NailedUpHanaPlanetZone -NewAquariumZone -NigeroLv2Test01PlanetZone -NigeroLv2Test02PlanetZone -NigeroPlanetZone -NoGravity2DTestZone -NoGravityYoshiBaloonZone -ObakeTowerPlanetZone -OmoteuLandDrillGravityMazeZone -OmoteuLandGalaxy -OmoteuLandManholeLift1014Zone -OmoteuLandManholeLiftZone -OnimasuPlanetZone -OpeningCloudZone -OtaTestGalaxy -PeachCastle2DMario1Zone -PeachCastle2DTest03Zone -PeachCastle2DTicoMeetsTest02Zone -PeachCastle2DTicoMeetsZone -PeachCastle2DZone -PeachCastle3DZone -PeachCastleFinalStartZone -PeachCastleGalaxy -PeachCastleInsideZone -PeachCastleTown3DOrgZone -PeachCastleTown3DZone -PeanutPlanetZone -PenginAquariumZone -PetitPorterAZone -PetoTest -PettanWalkPlanetZone -PicturePuzzlePlanetZone -PoltaZone -PusherWallPlanetZone -QuicksandDarumaSamboZone -QuickSandFireTestZone -QuicksandGalaxy -QuicksandLongSlopeZone -QuicksandUPlanetZone -RabbitSkateTestZone -RainbowGlassPlanetZone -RainbowRoadA -RedBlueBeamerPlanetZone -RedBlueEx -RedBlueExGalaxy -RedBlueExTest01Galaxy -ReflectDrillZone -RockBowlingLv1PlanetZone -RockBowlingLv1Test1PlanetZone -RollingDrumPlanetZone -RollingRockBowling -RosettaPlanetZone -RotateHummerPlanetZone -RotatePurpleCoin -RotateWoodChallengeTest01Zone -RotateWoodChallengeTest02Zone -RotateWoodChallengeZone -RoundBlockPlanetZone -SakasamaManHoleWanwanZone -SandyZone -SearchWanwanTest01PlanetZone -SecretAthleticGalaxy -SeesawCylinderTestZone -SeesawMoonPlanetZone -SeesawMoonTest03PlanetZone -SeesawMoonTest04PlanetZone -SequenceBeforeKoopaZone -SequenceNormalEndZone -SequenceStar120Zone -ShortSwimCaveZone -SmallBigMetboZone -SmallInOutDrillPlanetZone -SmallPlanetBridgeZone -SmallRedBlueClimbZone -SmallRingPlatformZone -SorajimaBossZone -SpinClimbTowerZone -SpinGravityChange2Test -SpinGravityChangeTest -SpinGravityChangeZone -SpringTowerPlanetZone -StaffRollGalaxy -StaffUnbabaHomePlanetZone -StarCaptureUnbabaZone -StarCreekGalaxy -StarCreekTshapeZone -StorybookDemoTest01Zone -StorybookDemoTest02Zone -StorybookTestGalaxy -StrangeWaterPlanetZone -SugawaraTest -Sumaki2DTest -SumakiEnemyTest -SumakiFlowerTest -SumakiNPCTest -SumakiSphereTest -SumakiTest -SumakiWaterTest -SurvivalCosmosGalaxy -SurvivalGrapyon02Zone -SurvivalGrapyonZone -SurvivalIceMerameraZone -SurvivalKabokuriZone -SurvivalKaninaZone -SurvivalKaronCubeZone -SurvivalMerameraZone -SurvivalMoguttiZone -SurvivalPetariZone -SurvivalPukupukuZone -SurvivalTeresa2DZone -SurvivalUnizoLandZone -SurvivalWanwanBonbonZone -SurvivalWanwanZone -SwitchMoveBlockGalaxy -SwitchMoveBlockTest -SwitchMoveBlockTest2 -TakeuchiNpcTestZone -TakeuchiObjTestZone -TakeuchiTestGalaxy -TakezawaTestA -TakezawaTestAGalaxy -TamakoroFlipPanel02Zone -TamakoroOnCylinderTestZone -tamakoroPanel02Zone -TamakoroPlanetGalaxy -TamakoroPlanetStartZone -TamakoroSliderGalaxy -TamakoroWithWanwanZone -TanakaTest -TeresaLabyrinthGalaxy -ThunderFleetGalaxy -ThunderFleetStartZone -TimberRelayPlanetZone -TimerSwitchingPlatformGalaxy -TimerSwitchingPlatformTest2Zone -TimingDrillZone -TogezoTutorialZone -TrialTamakoroPlanetZone -TropicalResortGalaxy -TsuntsunBirdPlanetZone -TubeSliderZone -TwisterTowerGalaxy -TwoLegsBossZone -TwoSidesMazeOrgZone -TwoSidesMazeZone -UnbabaHomePlanetZone -UnderGroundDangeonAZone -UnderGroundDangeonGalaxy -VSBossMenbosaPlanetZone -VsKokoopaShipLv1Zone -VsKoopaGravityGalaxy -VsKoopaJrLv1Galaxy -VsKoopaJrLv3AZone -VsKoopaJrLv3BZone -VsKoopaJrLv3Galaxy -VsKoopaLv1Galaxy -VsKoopaLv3Galaxy -VsOtaRockTankLv1Zone -VsOtaRockTankPlanetZone -WanwanFactoryAZone -WanwanFactoryBZone -WanwanFactoryCZone -WanwanFactoryDZone -WanwanFactoryGalaxy -WanwanSw01PlanetZone -WanwanSw02PlanetZone -WatanabeTestF -WatanabeTestH -WatanabeTestL -WatanabeTestO -WatanabeTestS -WatanabeTestT -WatanabeTestV -WaterFallNigeroPlanetZone -WaterFireBarZone -WhiteSnowAPlanetZone -WhiteSnowBlockTest01Zone -WhiteSnowBlockZone -WhiteSnowBPlanetZone -WhiteSnowCPlanetZone -WhiteSnowGalaxy -WhiteSnowMistZone -WhiteSnowStartZone -WoodCircleCutZone -WorldMap01Galaxy -WorldMap02Galaxy -WorldMap03Galaxy -WorldMap04Galaxy -WorldMap05Galaxy -WorldMap06Galaxy -WorldMap07Galaxy -WorldMap08Galaxy -YamaguchiTest01Zone -YamaguchiTest02Zone -YamaguchiTestGalaxy -YamaguchiTestItemDrill -YokobeRestZoneA -YokobeUsefulMapPartsStageA -YokotaSurfingPurpleCoinStage -YoshiCannonPlanetZone -YoshidaTestHammerBros -YoshidaTestHammerBrosSecond -YoshidaTestHammerBrosThird -YoshidaTestKoopa -YoshiHomeAPlanetZone -YoshiHomeBPlanetZone -YoshiHomeCPlanetZone -YoshiPullZone -YoshiTicoRescueZone -YosshiFacePlanetZone -YosshiHomeGalaxy -ZakoParadeGalaxy \ No newline at end of file diff --git a/src/whitehole/Iterator2Enumeration.java b/src/com/aurum/whitehole/AdaptedEnumeration.java similarity index 66% rename from src/whitehole/Iterator2Enumeration.java rename to src/com/aurum/whitehole/AdaptedEnumeration.java index 690cac8..0023efd 100644 --- a/src/whitehole/Iterator2Enumeration.java +++ b/src/com/aurum/whitehole/AdaptedEnumeration.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,30 +13,29 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole; +package com.aurum.whitehole; import java.util.Enumeration; import java.util.Iterator; -public class Iterator2Enumeration implements Enumeration -{ - public Iterator2Enumeration(Iterator it) - { - iterator = it; +public class AdaptedEnumeration implements Enumeration { + private final Iterator iterator; + + public AdaptedEnumeration(Iterator i) { + this.iterator = i; + } + + public Iterator getIterator() { + return iterator; } @Override - public boolean hasMoreElements() - { + public boolean hasMoreElements() { return iterator.hasNext(); } - + @Override - public Object nextElement() - { + public E nextElement() { return iterator.next(); } - - - private Iterator iterator; } \ No newline at end of file diff --git a/src/whitehole/ObjectDB.java b/src/com/aurum/whitehole/ObjectDB.java similarity index 54% rename from src/whitehole/ObjectDB.java rename to src/com/aurum/whitehole/ObjectDB.java index cdfd95b..23a09c8 100644 --- a/src/whitehole/ObjectDB.java +++ b/src/com/aurum/whitehole/ObjectDB.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,31 +13,27 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole; +package com.aurum.whitehole; import java.io.*; import java.util.*; import org.jdom2.*; import org.jdom2.input.*; -public class ObjectDB -{ - public static void initialize() - { +public class ObjectDB { + public static void init() { fallback = true; timestamp = 0; - categories = new LinkedHashMap<>(); - objects = new LinkedHashMap<>(); + categories = new LinkedHashMap(); + objects = new LinkedHashMap(); File odbfile = new File("objectdb.xml"); - if (!odbfile.exists()) return; + if (!(odbfile.exists() && odbfile.isFile())) + return; - try - { - SAXBuilder sxb = new SAXBuilder(); - Document doc = sxb.build(odbfile); - Element root = doc.getRootElement(); + try { + Element root = new SAXBuilder().build(odbfile).getRootElement(); timestamp = root.getAttribute("timestamp").getLongValue(); List catelems = root.getChild("categories").getChildren("category"); @@ -45,8 +41,7 @@ public static void initialize() categories.put(catelem.getAttribute("id").getIntValue(), catelem.getText()); List objelems = root.getChildren("object"); - for (Element objelem : objelems) - { + for (Element objelem : objelems) { Object entry = new Object(); entry.ID = objelem.getAttributeValue("id"); entry.name = objelem.getChildText("name"); @@ -59,26 +54,19 @@ public static void initialize() entry.known = flags.getAttribute("known").getIntValue(); entry.complete = flags.getAttribute("complete").getIntValue(); - // placeholder string if (entry.notes.isEmpty() || entry.notes.equals("")) entry.notes = "(No description found for this objects.)"; if (entry.type.isEmpty() || entry.notes.equals("")) entry.type = "Unknown"; - // get data files string - String dataFiles = objelem.getChildText("files"); - if (dataFiles.isEmpty() || dataFiles.equals("")) { - entry.dataFiles = "(None)"; - } - else { - for (String dataFile : dataFiles.split("\n")) { - entry.dataFiles += dataFile + "
"; - } + entry.files = new ArrayList(); + String files = objelem.getChildText("files"); + for (String file : files.split("\n")) { + entry.files.add(file); } - // get Obj_arg string List fields = objelem.getChildren("field"); - entry.fields = new HashMap<>(fields.size()); + entry.fields = new HashMap(fields.size()); if (!fields.isEmpty()) { for (Element field : fields) { Object.Field fielddata = new Object.Field(); @@ -89,63 +77,128 @@ public static void initialize() fielddata.values = field.getAttributeValue("values"); fielddata.notes = field.getAttributeValue("notes"); - if (!fielddata.values.isEmpty() || !fielddata.values.equals("")) - fielddata.values = ", " + fielddata.values; - if (!fielddata.notes.isEmpty() || !fielddata.notes.equals("")) - fielddata.notes = ", " + fielddata.notes; - - entry.dataFields += "Obj_arg" + fielddata.ID + " (" + fielddata.type + "): " + fielddata.name + fielddata.values + fielddata.notes + "
"; entry.fields.put(fielddata.ID, fielddata); } } - else { - entry.dataFields = "(None)
"; - } objects.put(entry.ID, entry); } } - catch (Exception ex) - { + catch (IOException | JDOMException ex) { timestamp = 0; return; } - + fallback = false; } - public static class Object - { - public static class Field - { + public static class Object { + public static class Field { public int ID; - public String type; public String name; public String values; public String notes; + + @Override + public String toString() { + return name.isEmpty() ? "Obj_arg" + ID : name; + } + + public String toFullString() { + String ret = "Obj_arg" + ID + " (" + type + "): " + name; + if (!values.isEmpty()) + ret += ", " + values; + if (!notes.isEmpty()) + ret += ", " + notes; + return ret; + } } - public String ID; public String name; - public int category; public int games; public int known; public int complete; - - public String dataFields = ""; - public String dataFiles = ""; public String type = ""; public String notes = ""; - + public List files; public HashMap fields; + + public Object() { + files = new ArrayList(); + fields = new LinkedHashMap(); + } + + @Override + public String toString() { + return name + " (" + ID + ")"; + } + + public String getGame() { + String ret = ""; + if ((games & 1) != 0) { + ret += "SMG1"; + } + if ((games & 2) != 0) { + if (!ret.isEmpty()) + ret += ", "; + ret += "SMG2"; + } + if ((games & 4) != 0) { + if (!ret.isEmpty()) + ret += ", "; + ret += "NMG"; + } + return ret; + } + + public String getStatus() { + int stat = known + complete; + switch(stat) { + default: return "(Unknown)"; + case 0: return "(This object's purpose is not known yet!)"; + case 1: return "(This object is not fully known!)"; + case 2: return "(This object has been fully documented!)"; + } + } + + public String getFieldString(int id) { + Field field = fields.get(id); + return field == null ? "Obj_arg" + id : field.name; + } + + public String getFieldsAsString() { + if (fields.isEmpty()) { + return "(None)\n"; + } + else { + String ret = ""; + for (Field field : fields.values()) { + ret += field.toFullString() + "\n"; + } + return ret; + } + } + + public String getFilesAsString() { + if (files.isEmpty()) { + return "(None)\n"; + } + else { + String ret = ""; + for (String file : files) { + ret += file + "\n"; + } + return ret; + } + } } public static boolean fallback; public static long timestamp; public static LinkedHashMap categories; public static LinkedHashMap objects; -} +} \ No newline at end of file diff --git a/src/whitehole/ObjectDBUpdater.java b/src/com/aurum/whitehole/ObjectDBUpdater.java similarity index 69% rename from src/whitehole/ObjectDBUpdater.java rename to src/com/aurum/whitehole/ObjectDBUpdater.java index 370cbca..2588a1c 100644 --- a/src/whitehole/ObjectDBUpdater.java +++ b/src/com/aurum/whitehole/ObjectDBUpdater.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,7 +13,7 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole; +package com.aurum.whitehole; import java.io.*; import java.net.*; @@ -23,26 +23,21 @@ import java.util.zip.GZIPInputStream; import javax.swing.JLabel; -public class ObjectDBUpdater extends Thread -{ - public ObjectDBUpdater(JLabel status) - { +public class ObjectDBUpdater extends Thread { + public ObjectDBUpdater(JLabel status) { statusLabel = status; } @Override - public void run() - { - try - { + public void run() { + try { String ts = String.format("&ts=%1$d", ObjectDB.timestamp); URL url = new URL (Settings.objectDB_url + "?whitehole&gzip" + ts); URLConnection conn = url.openConnection(); DataInputStream dis = new DataInputStream(conn.getInputStream()); int length = conn.getContentLength(); - if (length < 8) - { + if (length < 8) { statusLabel.setText("Failed to update object database: received invalid data."); return; } @@ -55,24 +50,23 @@ public void run() CharsetDecoder dec = charset.newDecoder(); String strdata = dec.decode(ByteBuffer.wrap(data, 0, 8)).toString(); - if (strdata.equals("noupdate")) - { + if (strdata.equals("noupdate")) { statusLabel.setText("Object database already up-to-date."); return; } - else if (data.length < 10) - { + else if (data.length < 10) { statusLabel.setText("Failed to update object database: received invalid data."); return; } CRC32 crc = new CRC32(); crc.update(data, 9, data.length-9); + long crcref; try { crcref = Long.parseLong(strdata, 16); } catch (NumberFormatException ex) { crcref = -1; } - if (crc.getValue() != crcref) - { + + if (crc.getValue() != crcref) { statusLabel.setText("Failed to update object database: received invalid data."); return; } @@ -80,35 +74,27 @@ else if (data.length < 10) File odbbkp = new File("objectdb.xml.bak"); File odb = new File("objectdb.xml"); - try - { - if (odb.exists()) - { + try { + if (odb.exists()) { odb.renameTo(odbbkp); odb.delete(); } - ByteArrayInputStream compstream = new ByteArrayInputStream(data, 9, data.length-9); - GZIPInputStream gzstream = new GZIPInputStream(compstream); - - odb.createNewFile(); - FileOutputStream odbstream = new FileOutputStream(odb); - - int curbyte; - while ((curbyte = gzstream.read()) != -1) - odbstream.write(curbyte); - - odbstream.flush(); - odbstream.close(); - - gzstream.close(); - compstream.close(); + try (ByteArrayInputStream compstream = new ByteArrayInputStream(data, 9, data.length-9); GZIPInputStream gzstream = new GZIPInputStream(compstream)) { + odb.createNewFile(); + try (FileOutputStream odbstream = new FileOutputStream(odb)) { + int curbyte; + while ((curbyte = gzstream.read()) != -1) + odbstream.write(curbyte); + + odbstream.flush(); + } + } if (odbbkp.exists()) odbbkp.delete(); } - catch (IOException ex) - { + catch (IOException ex) { statusLabel.setText("Failed to save new object database."); if (odbbkp.exists()) odbbkp.renameTo(odb); @@ -116,18 +102,16 @@ else if (data.length < 10) } statusLabel.setText("Object database updated."); - ObjectDB.initialize(); + ObjectDB.init(); } - catch (MalformedURLException ex) - { + catch (MalformedURLException ex) { statusLabel.setText("Failed to connect to update server."); } - catch (IOException ex) - { + catch (IOException ex) { statusLabel.setText("Failed to save new object database."); } } - private JLabel statusLabel; -} + private final JLabel statusLabel; +} \ No newline at end of file diff --git a/src/whitehole/Settings.java b/src/com/aurum/whitehole/Settings.java similarity index 79% rename from src/whitehole/Settings.java rename to src/com/aurum/whitehole/Settings.java index bad8d91..b7cbd80 100644 --- a/src/whitehole/Settings.java +++ b/src/com/aurum/whitehole/Settings.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,14 +13,12 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole; +package com.aurum.whitehole; import java.util.prefs.Preferences; -public class Settings -{ - public static void initialize() - { +public class Settings { + public static void init() { Preferences prefs = Preferences.userRoot(); objectDB_url = prefs.get("objectDB.url", "http://neomariogalaxy.bplaced.net/objectdb/smg_download.php"); objectDB_update = prefs.getBoolean("objectDB.update", true); @@ -32,8 +30,7 @@ public static void initialize() theme_system = prefs.getBoolean("theme.system", true); } - public static void save() - { + public static void save() { Preferences prefs = Preferences.userRoot(); prefs.put("objectDB.url", objectDB_url); prefs.putBoolean("objectDB.update", objectDB_update); @@ -45,13 +42,7 @@ public static void save() prefs.putBoolean("theme.system", theme_system); } - public static String objectDB_url; - public static boolean objectDB_update; - public static boolean arc_enc; - public static boolean editor_areas; - public static boolean editor_shaders; - public static boolean editor_fastDrag; - public static boolean editor_reverseRot; - public static boolean theme_system; + public static boolean objectDB_update, arc_enc, theme_system; + public static boolean editor_areas, editor_shaders, editor_fastDrag, editor_reverseRot; } \ No newline at end of file diff --git a/src/whitehole/StrictThreadGroup.java b/src/com/aurum/whitehole/StrictThreadGroup.java similarity index 73% rename from src/whitehole/StrictThreadGroup.java rename to src/com/aurum/whitehole/StrictThreadGroup.java index ff97c08..1cf0df3 100644 --- a/src/whitehole/StrictThreadGroup.java +++ b/src/com/aurum/whitehole/StrictThreadGroup.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,28 +13,25 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole; +package com.aurum.whitehole; import java.io.File; +import java.io.IOException; import java.io.PrintStream; import javax.swing.JOptionPane; -public class StrictThreadGroup extends ThreadGroup -{ - public StrictThreadGroup() - { +public class StrictThreadGroup extends ThreadGroup { + public StrictThreadGroup() { super("StrictThreadGroup"); } @Override - public void uncaughtException(Thread t, Throwable e) - { - if (e.getMessage().contains("Method 'gl") && e.getMessage().contains("' not available")) - { + public void uncaughtException(Thread t, Throwable e) { + if (e.getMessage().contains("Method 'gl") && e.getMessage().contains("' not available")) { JOptionPane.showMessageDialog(null, e.getMessage() + "\n\n" + "This error is likely caused by an outdated video driver. Update it if possible.", - Whitehole.fullName, JOptionPane.ERROR_MESSAGE); + Whitehole.NAME, JOptionPane.ERROR_MESSAGE); return; } @@ -42,21 +39,20 @@ public void uncaughtException(Thread t, Throwable e) JOptionPane.showMessageDialog(null, "An unhandled exception has occured: " + e.getMessage() + "\n" + "Whitehole may be unstable. It is recommended that you close it now. You can try to save your unsaved work before doing so, but at your own risks.\n\n" - + "You should report this crash at EggStarGalaxy ("+Whitehole.crashReportURL+"), providing the detailed report found in \"whiteholeCrash.txt\".", - Whitehole.fullName, JOptionPane.ERROR_MESSAGE); - - try - { + + "You should report this crash at EggStarGalaxy ("+Whitehole.CRASHURL+"), providing the detailed report found in \"whiteholeCrash.txt\".", + Whitehole.NAME, JOptionPane.ERROR_MESSAGE); + + try { File report = new File("whiteholeCrash.txt"); if (report.exists()) report.delete(); report.createNewFile(); PrintStream ps = new PrintStream(report); - ps.append(Whitehole.fullName + " crash report\r\n"); - ps.append("Please report this at EggStarGalaxy ("+Whitehole.websiteURL+") with all the details below\r\n"); + ps.append(Whitehole.NAME + " crash report\r\n"); + ps.append("Please report this at EggStarGalaxy ("+Whitehole.WEBURL+") with all the details below\r\n"); ps.append("--------------------------------------------------------------------------------\r\n\r\n"); e.printStackTrace(ps); ps.close(); } - catch (Exception ex) {} + catch (IOException ex) {} } -} +} \ No newline at end of file diff --git a/src/whitehole/SuperFastHash.java b/src/com/aurum/whitehole/SuperFastHash.java similarity index 89% rename from src/whitehole/SuperFastHash.java rename to src/com/aurum/whitehole/SuperFastHash.java index 17d1845..bf224a9 100644 --- a/src/whitehole/SuperFastHash.java +++ b/src/com/aurum/whitehole/SuperFastHash.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,32 +13,29 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole; +package com.aurum.whitehole; -public class SuperFastHash -{ - public static long calculate(byte[] data, long start, int offset, int len) - { +public class SuperFastHash { + public static long calculate(byte[] data, long start, int offset, int len) { long hash = start & 0xFFFFFFFF; long tmp; int rem; - if (len < 1) return hash; + if (len < 1) + return hash; rem = len & 3; len >>>= 2; int pos = offset; - for (; len > 0; len--) - { + for (; len > 0; len--) { hash += (data[pos++] | (data[pos++] << 8)); tmp = ((data[pos++] | (data[pos++] << 8)) << 11) ^ hash; hash = ((hash << 16) ^ tmp); hash += (hash >>> 11); } - switch (rem) - { + switch (rem) { case 3: hash += (data[pos++] | (data[pos++] << 8)); hash ^= (hash << 16); @@ -68,4 +65,4 @@ public static long calculate(byte[] data, long start, int offset, int len) return hash & 0xFFFFFFFF; } -} +} \ No newline at end of file diff --git a/src/com/aurum/whitehole/Whitehole.java b/src/com/aurum/whitehole/Whitehole.java new file mode 100644 index 0000000..a697ab3 --- /dev/null +++ b/src/com/aurum/whitehole/Whitehole.java @@ -0,0 +1,71 @@ +/* + © 2012 - 2017 - Whitehole Team + + Whitehole is free software: you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + Whitehole is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with Whitehole. If not, see http://www.gnu.org/licenses/. +*/ + +package com.aurum.whitehole; + +import com.aurum.whitehole.swing.MainFrame; +import java.nio.charset.Charset; +import java.util.prefs.Preferences; +import javax.media.opengl.GLProfile; +import javax.swing.JOptionPane; +import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; +import com.aurum.whitehole.rendering.cache.*; +import com.aurum.whitehole.smg.Bcsv; +import com.aurum.whitehole.smg.GameArchive; +import java.awt.Image; +import java.awt.Toolkit; + +public class Whitehole { + public static final String NAME = "Whitehole v1.4.3"; + public static final String WEBURL = "http://neomariogalaxy.bplaced.net/"; + public static final String CRASHURL = "http://neomariogalaxy.bplaced.net/?page=thread&id=148"; + public static final Image ICON = Toolkit.getDefaultToolkit().createImage(Whitehole.class.getResource("/res/icon.png")); + + public static GameArchive game; + public static int gameType; + + public class UncaughtExceptionHandler { + public void handle(Throwable throwable) { + System.out.println(throwable.getMessage()); + } + } + + public static void main(String[] args) { + if (!Charset.isSupported("SJIS")) { + if (!Preferences.userRoot().getBoolean("charset-alreadyWarned", false)) { + JOptionPane.showMessageDialog(null, "Shift-JIS encoding isn't supported.\nWhitehole will default to ASCII, which may cause certain strings to look corrupted.\n\nThis message appears only once.", + Whitehole.NAME, JOptionPane.WARNING_MESSAGE); + Preferences.userRoot().putBoolean("charset-alreadyWarned", true); + } + } + + Settings.init(); + TextureCache.init(); + ShaderCache.init(); + RendererCache.init(); + ObjectDB.init(); + Bcsv.populateHashTable(); + + try { + if (Settings.theme_system) UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + else UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); + } + catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {} + + GLProfile.initSingleton(); + new MainFrame().setVisible(true); + } +} \ No newline at end of file diff --git a/src/whitehole/fileio/ExternalFile.java b/src/com/aurum/whitehole/io/ExternalFile.java similarity index 99% rename from src/whitehole/fileio/ExternalFile.java rename to src/com/aurum/whitehole/io/ExternalFile.java index 09cc1bb..516b791 100644 --- a/src/whitehole/fileio/ExternalFile.java +++ b/src/com/aurum/whitehole/io/ExternalFile.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,7 +13,7 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.fileio; +package com.aurum.whitehole.io; import java.io.*; import java.nio.*; diff --git a/src/whitehole/fileio/ExternalFilesystem.java b/src/com/aurum/whitehole/io/ExternalFilesystem.java similarity index 97% rename from src/whitehole/fileio/ExternalFilesystem.java rename to src/com/aurum/whitehole/io/ExternalFilesystem.java index 2e06a3e..87bbe77 100644 --- a/src/whitehole/fileio/ExternalFilesystem.java +++ b/src/com/aurum/whitehole/io/ExternalFilesystem.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,7 +13,7 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.fileio; +package com.aurum.whitehole.io; import java.io.*; import java.util.*; diff --git a/src/whitehole/fileio/FileBase.java b/src/com/aurum/whitehole/io/FileBase.java similarity index 96% rename from src/whitehole/fileio/FileBase.java rename to src/com/aurum/whitehole/io/FileBase.java index 00dc7a7..c918d98 100644 --- a/src/whitehole/fileio/FileBase.java +++ b/src/com/aurum/whitehole/io/FileBase.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,7 +13,7 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.fileio; +package com.aurum.whitehole.io; import java.io.IOException; diff --git a/src/whitehole/fileio/FilesystemBase.java b/src/com/aurum/whitehole/io/FilesystemBase.java similarity index 94% rename from src/whitehole/fileio/FilesystemBase.java rename to src/com/aurum/whitehole/io/FilesystemBase.java index 40e496d..2abf86e 100644 --- a/src/whitehole/fileio/FilesystemBase.java +++ b/src/com/aurum/whitehole/io/FilesystemBase.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,7 +13,7 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.fileio; +package com.aurum.whitehole.io; import java.io.*; import java.util.List; diff --git a/src/whitehole/fileio/MemoryFile.java b/src/com/aurum/whitehole/io/MemoryFile.java similarity index 99% rename from src/whitehole/fileio/MemoryFile.java rename to src/com/aurum/whitehole/io/MemoryFile.java index bc43762..676bebc 100644 --- a/src/whitehole/fileio/MemoryFile.java +++ b/src/com/aurum/whitehole/io/MemoryFile.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,7 +13,7 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.fileio; +package com.aurum.whitehole.io; import java.io.IOException; import java.nio.ByteBuffer; diff --git a/src/whitehole/fileio/RarcFile.java b/src/com/aurum/whitehole/io/RarcFile.java similarity index 93% rename from src/whitehole/fileio/RarcFile.java rename to src/com/aurum/whitehole/io/RarcFile.java index 6c022d6..d751cde 100644 --- a/src/whitehole/fileio/RarcFile.java +++ b/src/com/aurum/whitehole/io/RarcFile.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,7 +13,7 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.fileio; +package com.aurum.whitehole.io; import java.io.IOException; diff --git a/src/whitehole/fileio/RarcFilesystem.java b/src/com/aurum/whitehole/io/RarcFilesystem.java similarity index 99% rename from src/whitehole/fileio/RarcFilesystem.java rename to src/com/aurum/whitehole/io/RarcFilesystem.java index ef056fe..d83df83 100644 --- a/src/whitehole/fileio/RarcFilesystem.java +++ b/src/com/aurum/whitehole/io/RarcFilesystem.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,7 +13,7 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.fileio; +package com.aurum.whitehole.io; import java.io.FileNotFoundException; import java.io.IOException; diff --git a/src/whitehole/fileio/Yaz0.java b/src/com/aurum/whitehole/io/Yaz0.java similarity index 98% rename from src/whitehole/fileio/Yaz0.java rename to src/com/aurum/whitehole/io/Yaz0.java index f4dbec1..947f932 100644 --- a/src/whitehole/fileio/Yaz0.java +++ b/src/com/aurum/whitehole/io/Yaz0.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,7 +13,7 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.fileio; +package com.aurum.whitehole.io; import java.util.Arrays; import java.util.LinkedList; diff --git a/src/whitehole/fileio/Yaz0File.java b/src/com/aurum/whitehole/io/Yaz0File.java similarity index 93% rename from src/whitehole/fileio/Yaz0File.java rename to src/com/aurum/whitehole/io/Yaz0File.java index ac8a299..5fb360c 100644 --- a/src/whitehole/fileio/Yaz0File.java +++ b/src/com/aurum/whitehole/io/Yaz0File.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,10 +13,10 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.fileio; +package com.aurum.whitehole.io; import java.io.IOException; -import whitehole.Settings; +import com.aurum.whitehole.Settings; public class Yaz0File extends MemoryFile { diff --git a/src/whitehole/rendering/BmdRenderer.java b/src/com/aurum/whitehole/rendering/BmdRenderer.java similarity index 87% rename from src/whitehole/rendering/BmdRenderer.java rename to src/com/aurum/whitehole/rendering/BmdRenderer.java index f0ca8ae..9b7472b 100644 --- a/src/whitehole/rendering/BmdRenderer.java +++ b/src/com/aurum/whitehole/rendering/BmdRenderer.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,98 +13,85 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.rendering; +package com.aurum.whitehole.rendering; +import com.aurum.whitehole.rendering.cache.TextureCache; +import com.aurum.whitehole.rendering.cache.ShaderCache; +import com.aurum.whitehole.vectors.*; +import com.aurum.whitehole.smg.Bva; +import com.aurum.whitehole.smg.Bmd; +import com.aurum.whitehole.SuperFastHash; +import com.aurum.whitehole.Settings; +import com.aurum.whitehole.Whitehole; import java.io.*; import java.nio.*; import java.nio.charset.*; import java.util.Locale; +import com.aurum.whitehole.io.RarcFilesystem; +import com.aurum.whitehole.smg.ImageUtils.FilterMode; +import com.aurum.whitehole.smg.ImageUtils.WrapMode; import javax.media.opengl.*; -import whitehole.*; -import whitehole.fileio.RarcFilesystem; -import whitehole.smg.*; -import whitehole.vectors.*; - -public class BmdRenderer extends GLRenderer -{ - private void uploadTexture(GL2 gl, int id) - { + +public class BmdRenderer extends GLRenderer { + private void uploadTexture(GL2 gl, int id) { Bmd.Texture tex = model.textures[id]; int hash = 0; for (int i = 0; i < tex.mipmapCount; i++) - hash = (int)SuperFastHash.calculate(tex.image[i], (long)hash, 0, tex.image[i].length); + hash = (int) SuperFastHash.calculate(tex.image[i], (long)hash, 0, tex.image[i].length); textures[id] = hash; - if (TextureCache.containsEntry(hash)) - { + if (TextureCache.containsEntry(hash)) { TextureCache.getEntry(hash); return; } - int[] wrapmodes = { GL2.GL_CLAMP_TO_EDGE, GL2.GL_REPEAT, GL2.GL_MIRRORED_REPEAT }; - int[] minfilters = { GL2.GL_NEAREST, GL2.GL_LINEAR, - GL2.GL_NEAREST_MIPMAP_NEAREST, GL2.GL_LINEAR_MIPMAP_NEAREST, - GL2.GL_NEAREST_MIPMAP_LINEAR, GL2.GL_LINEAR_MIPMAP_LINEAR }; - int[] magfilters = { GL2.GL_NEAREST, GL2.GL_LINEAR, - GL2.GL_NEAREST, GL2.GL_LINEAR, - GL2.GL_NEAREST, GL2.GL_LINEAR, }; - int[] texids = new int[1]; gl.glGenTextures(1, texids, 0); int texid = texids[0]; TextureCache.addEntry(hash, texid); - + gl.glBindTexture(GL2.GL_TEXTURE_2D, texid); - gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAX_LEVEL, tex.mipmapCount - 1); - gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, minfilters[tex.minFilter]); - gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAG_FILTER, magfilters[tex.magFilter]); - gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_S, wrapmodes[tex.wrapS]); - gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_T, wrapmodes[tex.wrapT]); - + gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, FilterMode.values()[tex.minFilter].get()); + gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAG_FILTER, FilterMode.values()[tex.magFilter].get()); + gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_S, WrapMode.values()[tex.wrapS].get()); + gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_T, WrapMode.values()[tex.wrapT].get()); + int ifmt, fmt; - switch (tex.format) - { + switch (tex.format) { case 0: case 1: ifmt = GL2.GL_INTENSITY; fmt = GL2.GL_LUMINANCE; break; - case 2: case 3: ifmt = GL2.GL_LUMINANCE8_ALPHA8; fmt = GL2.GL_LUMINANCE_ALPHA; break; - default: ifmt = 4; fmt = GL2.GL_BGRA; break; } - + int width = tex.width, height = tex.height; - for (int mip = 0; mip < tex.mipmapCount; mip++) - { + for (int mip = 0; mip < tex.mipmapCount; mip++) { gl.glTexImage2D(GL2.GL_TEXTURE_2D, mip, ifmt, width, height, 0, fmt, GL2.GL_UNSIGNED_BYTE, ByteBuffer.wrap(tex.image[mip])); width /= 2; height /= 2; } } - private int shaderHash(int matid) - { + private int shaderHash(int matid) { byte[] sigarray = new byte[200]; ByteBuffer sig = ByteBuffer.wrap(sigarray); Bmd.Material mat = model.materials[matid]; sig.put((byte)mat.numTexgens); - for (int i = 0; i < mat.numTexgens; i++) - { + for (int i = 0; i < mat.numTexgens; i++) { // TODO matrices sig.put(mat.texGen[i].src); } - for (int i = 0; i < 4; i++) - { + for (int i = 0; i < 4; i++) { sig.putShort((short)mat.colorS10[i].r); sig.putShort((short)mat.colorS10[i].g); sig.putShort((short)mat.colorS10[i].b); sig.putShort((short)mat.colorS10[i].a); } - for (int i = 0; i < 4; i++) - { + for (int i = 0; i < 4; i++) { sig.put((byte)mat.constColors[i].r); sig.put((byte)mat.constColors[i].g); sig.put((byte)mat.constColors[i].b); @@ -112,8 +99,7 @@ private int shaderHash(int matid) } sig.put((byte)mat.numTevStages); - for (int i = 0; i < mat.numTevStages; i++) - { + for (int i = 0; i < mat.numTevStages; i++) { sig.put(mat.constColorSel[i]); sig.put(mat.constAlphaSel[i]); sig.put(mat.tevOrder[i].texMap); @@ -125,8 +111,7 @@ private int shaderHash(int matid) sig.put(mat.tevStage[i].colorIn[1]); sig.put(mat.tevStage[i].colorIn[2]); sig.put(mat.tevStage[i].colorIn[3]); - if (mat.tevStage[i].colorOp < 2) - { + if (mat.tevStage[i].colorOp < 2) { sig.put(mat.tevStage[i].colorBias); sig.put(mat.tevStage[i].colorScale); } @@ -144,37 +129,30 @@ private int shaderHash(int matid) } } - if (mat.alphaComp.mergeFunc == 1 && (mat.alphaComp.func0 == 7 || mat.alphaComp.func1 == 7)) - { + if (mat.alphaComp.mergeFunc == 1 && (mat.alphaComp.func0 == 7 || mat.alphaComp.func1 == 7)) { sig.put((byte)0x77); } - else if (mat.alphaComp.mergeFunc == 0 && (mat.alphaComp.func0 == 0 || mat.alphaComp.func1 == 0)) - { + else if (mat.alphaComp.mergeFunc == 0 && (mat.alphaComp.func0 == 0 || mat.alphaComp.func1 == 0)) { sig.put((byte)0x00); } - else - { + else { int b2 = 3; - if (mat.alphaComp.mergeFunc == 1) - { + if (mat.alphaComp.mergeFunc == 1) { if (mat.alphaComp.func0 == 0) b2 = 2; else if (mat.alphaComp.func1 == 0) b2 = 1; } - else if (mat.alphaComp.mergeFunc == 0) - { + else if (mat.alphaComp.mergeFunc == 0) { if (mat.alphaComp.func0 == 7) b2 = 2; else if (mat.alphaComp.func1 == 7) b2 = 1; } - if ((b2 & 1) != 0) - { + if ((b2 & 1) != 0) { sig.put((byte)0x01); sig.put(mat.alphaComp.func0); sig.put((byte)mat.alphaComp.ref0); } - if ((b2 & 2) != 0) - { + if ((b2 & 2) != 0) { sig.put((byte)0x02); sig.put(mat.alphaComp.func1); sig.put((byte)mat.alphaComp.ref1); @@ -183,7 +161,7 @@ else if (mat.alphaComp.mergeFunc == 0) sig.put(mat.alphaComp.mergeFunc); } - return (int)SuperFastHash.calculate(sigarray, 0, 0, sig.position()); + return (int) SuperFastHash.calculate(sigarray, 0, 0, sig.position()); } private void generateShaders(GL2 gl, int matid) throws GLException @@ -530,55 +508,56 @@ else if (mat.alphaComp.mergeFunc == 0) } - public BmdRenderer() - { - container = null; - model = null; + public BmdRenderer() { + fallback = new ColorCubeRenderer(100F, new Color4(0.5F, 0.5F, 1F, 1F), new Color4(0F, 0F, 0.8F, 1F), true); } - public BmdRenderer(RenderInfo info, String modelname) throws GLException - { + public BmdRenderer(RenderInfo info, String modelname) throws GLException { + this(); ctor_loadModel(info, modelname); ctor_uploadData(info); } - protected final void ctor_loadModel(RenderInfo info, String modelname) throws GLException - { + protected final void ctor_loadModel(RenderInfo info, String modelname) throws GLException { container = null; model = null; + visible = null; + fallback = new ColorCubeRenderer(100F, new Color4(0.5F, 0.5F, 1F, 1F), new Color4(0F, 0F, 0.8F, 1F), true); - try - { - container = new RarcFilesystem(Whitehole.game.filesystem.openFile("/ObjectData/" + modelname + ".arc")); + // Load the BMD / BDL file + try { + String filepath = "/ObjectData/" + modelname + ".arc"; + container = new RarcFilesystem(Whitehole.game.filesystem.openFile(filepath)); if (container.fileExists("/" + modelname + "/" + modelname + ".bdl")) model = new Bmd(container.openFile("/" + modelname + "/" + modelname + ".bdl")); else if (container.fileExists("/" + modelname + "/" + modelname + ".bmd")) model = new Bmd(container.openFile("/" + modelname + "/" + modelname + ".bmd")); - else - throw new IOException("No suitable model file inside RARC"); } - catch (IOException ex) - { - if (container != null) try { container.close(); } catch (IOException ex2) { + catch (IOException ex) { + if (container != null) { + try { + container.close(); + } + catch (IOException ex2) {} } - - throw new GLException("Failed to load model "+modelname+": "+ex.getMessage()); - + return; } - bva = null; - try - { + // Load a BVA file + try { if (container.fileExists("/" + modelname + "/Wait.bva")) - bva = new Bva(container.openFile("/" + modelname + "/Wait.bva")); + visible = new Bva(container.openFile("/" + modelname + "/Wait.bva")); else if (container.fileExists("/" + modelname + "/Normal.bva")) - bva = new Bva(container.openFile("/" + modelname + "/Normal.bva")); + visible = new Bva(container.openFile("/" + modelname + "/Normal.bva")); } catch (IOException ex) {} } - protected final void ctor_uploadData(RenderInfo info) throws GLException - { + protected final void ctor_uploadData(RenderInfo info) throws GLException { + if (model == null) { + return; + } + GL2 gl = info.drawable.getGL().getGL2(); String extensions = gl.glGetString(GL2.GL_EXTENSIONS); @@ -592,17 +571,15 @@ protected final void ctor_uploadData(RenderInfo info) throws GLException for (int i = 0; i < model.textures.length; i++) uploadTexture(gl, i); - if (hasShaders) - { + if (hasShaders) { shaders = new Shader[model.materials.length]; - for (int i = 0; i < model.materials.length; i++) - { - try { generateShaders(gl, i); } - catch (GLException ex) - { + for (int i = 0; i < model.materials.length; i++) { + try { + generateShaders(gl, i); + } + catch (GLException ex) { // really ugly hack - if (ex.getMessage().charAt(0) == '!') - { + if (ex.getMessage().charAt(0) == '!') { //StringBuilder src = new StringBuilder(10000); int lolz; //gl.glGetShaderSource(shaders[i].FragmentShader, 10000, out lolz, src); //System.Windows.Forms.MessageBox.Show(ex.Message + "\n" + src.ToString()); @@ -614,27 +591,26 @@ protected final void ctor_uploadData(RenderInfo info) throws GLException } } } - + @Override - public void close(RenderInfo info) throws GLException - { + public void close(RenderInfo info) throws GLException { + if (model == null) { + return; + } + GL2 gl = info.drawable.getGL().getGL2(); - if (hasShaders) - { - for (Shader shader : shaders) - { + if (hasShaders) { + for (Shader shader : shaders) { if (!ShaderCache.removeEntry(shader.cacheKey)) continue; - if (shader.vertexShader > 0) - { + if (shader.vertexShader > 0) { gl.glDetachShader(shader.program, shader.vertexShader); gl.glDeleteShader(shader.vertexShader); } - if (shader.fragmentShader > 0) - { + if (shader.fragmentShader > 0) { gl.glDetachShader(shader.program, shader.fragmentShader); gl.glDeleteShader(shader.fragmentShader); } @@ -644,8 +620,7 @@ public void close(RenderInfo info) throws GLException } } - for (int tex : textures) - { + for (int tex : textures) { int theid = TextureCache.getTextureID(tex); if (!TextureCache.removeEntry(tex)) continue; @@ -653,34 +628,43 @@ public void close(RenderInfo info) throws GLException gl.glDeleteTextures(1, new int[] { theid }, 0); } - if (model != null) - { + if (model != null) { try { model.close(); container.close(); } catch (IOException ex) { } } } @Override - public void releaseStorage() - { - if (model != null) - { - try { model.close(); container.close(); } - catch (IOException ex) { } + public void releaseStorage() { + if (visible != null) { + try { + visible.close(); + } + catch (IOException ex) {} + } + if (model != null) { + try { + model.close(); + container.close(); + } + catch (IOException ex) {} model = null; + visible = null; container = null; } } @Override - public boolean gottaRender(RenderInfo info) throws GLException - { + public boolean gottaRender(RenderInfo info) throws GLException { + if (model == null) { + return fallback.gottaRender(info); + } + if (info.renderMode == RenderMode.PICKING) return true; - for (Bmd.Material mat : model.materials) - { + for (Bmd.Material mat : model.materials) { if (!((mat.drawFlag == 4) ^ (info.renderMode == RenderMode.TRANSLUCENT))) return true; } @@ -689,8 +673,12 @@ public boolean gottaRender(RenderInfo info) throws GLException } @Override - public void render(RenderInfo info) throws GLException - { + public void render(RenderInfo info) throws GLException { + if (model == null) { + fallback.render(info); + return; + } + GL2 gl = info.drawable.getGL().getGL2(); int[] blendsrc = { GL2.GL_ZERO, GL2.GL_ONE, @@ -710,18 +698,19 @@ public void render(RenderInfo info) throws GLException Matrix4[] lastmatrixtable = null; - // setup some default OpenGL state if (info.renderMode != RenderMode.PICKING) gl.glColor4f(1f, 1f, 1f, 1f); - - for (Bmd.SceneGraphNode node : model.sceneGraph) - { + + if (model == null) { + return; + } + + for (Bmd.SceneGraphNode node : model.sceneGraph) { if (node.nodeType != 0) continue; int shape = node.nodeID; - if (bva != null) - { - if (!bva.animData.get(shape).get(0)) + if (visible != null) { + if (!visible.animData.get(shape).get(0)) continue; } @@ -733,21 +722,18 @@ public void render(RenderInfo info) throws GLException // 4 - top part // 5 - (joint) - if (node.materialID != 0xFFFF) - { + if (node.materialID != 0xFFFF) { int[] cullmodes = { GL2.GL_FRONT, GL2.GL_BACK, GL2.GL_FRONT_AND_BACK }; int[] depthfuncs = { GL2.GL_NEVER, GL2.GL_LESS, GL2.GL_EQUAL, GL2.GL_LEQUAL, GL2.GL_GREATER, GL2.GL_NOTEQUAL, GL2.GL_GEQUAL, GL2.GL_ALWAYS }; Bmd.Material mat = model.materials[node.materialID]; - if (info.renderMode != RenderMode.PICKING) - { + if (info.renderMode != RenderMode.PICKING) { if ((mat.drawFlag == 4) ^ (info.renderMode == RenderMode.TRANSLUCENT)) continue; - if (hasShaders) - { + if (hasShaders) { // shader: handles multitexturing, color combination, alpha test gl.glUseProgram(shaders[node.materialID].program); @@ -770,8 +756,7 @@ public void render(RenderInfo info) throws GLException gl.glBindTexture(GL2.GL_TEXTURE_2D, texid); } } - else - { + else { int[] alphafunc = { GL2.GL_NEVER, GL2.GL_LESS, GL2.GL_EQUAL, GL2.GL_LEQUAL, GL2.GL_GREATER, GL2.GL_NOTEQUAL, GL2.GL_GEQUAL, GL2.GL_ALWAYS }; @@ -805,8 +790,7 @@ else if (mat.alphaComp.mergeFunc == 0 && (mat.alphaComp.func0 == 0 || mat.alphaC } } - switch (mat.blendMode.blendMode) - { + switch (mat.blendMode.blendMode) { case 0: gl.glDisable(GL2.GL_BLEND); gl.glDisable(GL2.GL_COLOR_LOGIC_OP); @@ -835,14 +819,12 @@ else if (mat.alphaComp.mergeFunc == 0 && (mat.alphaComp.func0 == 0 || mat.alphaC if (mat.cullMode == 0) gl.glDisable(GL2.GL_CULL_FACE); - else - { + else { gl.glEnable(GL2.GL_CULL_FACE); gl.glCullFace(cullmodes[mat.cullMode - 1]); } - if (mat.zMode.enableZTest) - { + if (mat.zMode.enableZTest) { gl.glEnable(GL2.GL_DEPTH_TEST); gl.glDepthFunc(depthfuncs[mat.zMode.func]); } @@ -851,8 +833,7 @@ else if (mat.alphaComp.mergeFunc == 0 && (mat.alphaComp.func0 == 0 || mat.alphaC gl.glDepthMask(mat.zMode.enableZWrite); } - else - { + else { //if (info.Mode != RenderMode.Opaque) continue; // if (m_HasShaders) gl.glUseProgram(0); throw new GLException(String.format("Material-less geometry node %1$d", node.nodeID)); @@ -860,36 +841,18 @@ else if (mat.alphaComp.mergeFunc == 0 && (mat.alphaComp.func0 == 0 || mat.alphaC Bmd.Batch batch = model.batches[shape]; - - /*if (batch.MatrixType == 1) - { - gl.glPushMatrix(); - gl.glCallList(info.BillboardDL); - } - else if (batch.MatrixType == 2) - { - gl.glPushMatrix(); - gl.glCallList(info.YBillboardDL); - }*/ - - for (Bmd.Batch.Packet packet : batch.packets) - { + + for (Bmd.Batch.Packet packet : batch.packets) { Matrix4[] mtxtable = new Matrix4[packet.matrixTable.length]; - int[] mtx_debug = new int[packet.matrixTable.length]; - for (int i = 0; i < packet.matrixTable.length; i++) - { - if (packet.matrixTable[i] == (short)0xFFFF) - { + for (int i = 0; i < packet.matrixTable.length; i++) { + if (packet.matrixTable[i] == (short)0xFFFF) { mtxtable[i] = lastmatrixtable[i]; - mtx_debug[i] = 2; } - else - { + else { Bmd.MatrixType mtxtype = model.matrixTypes[packet.matrixTable[i]]; - if (mtxtype.isWeighted) - { + if (mtxtype.isWeighted) { //throw new NotImplementedException("weighted matrix"); // code inspired from bmdview2, except doesn't work right @@ -918,34 +881,26 @@ else if (batch.MatrixType == 2) // seems fine in most cases // but hey, certainly not right, that data has to be used in some way mtxtable[i] = new Matrix4(); - - mtx_debug[i] = 1; } - else - { + else { mtxtable[i] = model.joints[mtxtype.index].finalMatrix; - mtx_debug[i] = 0; } } } lastmatrixtable = mtxtable; - for (Bmd.Batch.Packet.Primitive prim : packet.primitives) - { + for (Bmd.Batch.Packet.Primitive prim : packet.primitives) { int[] primtypes = { GL2.GL_QUADS, GL2.GL_POINTS, GL2.GL_TRIANGLES, GL2.GL_TRIANGLE_STRIP, GL2.GL_TRIANGLE_FAN, GL2.GL_LINES, GL2.GL_LINE_STRIP, GL2.GL_POINTS }; gl.glBegin(primtypes[(prim.primitiveType - 0x80) / 8]); //gl.glBegin(BeginMode.Points); - if (info.renderMode != RenderMode.PICKING) - { - for (int i = 0; i < prim.numIndices; i++) - { + if (info.renderMode != RenderMode.PICKING) { + for (int i = 0; i < prim.numIndices; i++) { if ((prim.arrayMask & (1 << 11)) != 0) { Color4 c = model.colorArray[0][prim.colorIndices[0][i]]; gl.glColor4f(c.r, c.g, c.b, c.a); } - if (hasShaders) - { + if (hasShaders) { if ((prim.arrayMask & (1 << 12)) != 0) { Color4 c = model.colorArray[1][prim.colorIndices[1][i]]; gl.glSecondaryColor3f(c.r, c.g, c.b); } if ((prim.arrayMask & (1 << 13)) != 0) { Vector2 t = model.texcoordArray[0][prim.texcoordIndices[0][i]]; gl.glMultiTexCoord2f(GL2.GL_TEXTURE0, t.x, t.y); } @@ -957,8 +912,7 @@ else if (batch.MatrixType == 2) if ((prim.arrayMask & (1 << 19)) != 0) { Vector2 t = model.texcoordArray[6][prim.texcoordIndices[6][i]]; gl.glMultiTexCoord2f(GL2.GL_TEXTURE6, t.x, t.y); } if ((prim.arrayMask & (1 << 20)) != 0) { Vector2 t = model.texcoordArray[7][prim.texcoordIndices[7][i]]; gl.glMultiTexCoord2f(GL2.GL_TEXTURE7, t.x, t.y); } } - else - { + else { if ((prim.arrayMask & (1 << 13)) != 0) { Vector2 t = model.texcoordArray[0][prim.texcoordIndices[0][i]]; gl.glTexCoord2f(t.x, t.y); } } @@ -970,10 +924,8 @@ else if (batch.MatrixType == 2) gl.glVertex3f(pos.x, pos.y, pos.z); } } - else - { - for (int i = 0; i < prim.numIndices; i++) - { + else { + for (int i = 0; i < prim.numIndices; i++) { Vector3 pos = new Vector3(model.positionArray[prim.positionIndices[i]]); if ((prim.arrayMask & 1) != 0) Vector3.transform(pos, mtxtable[prim.posMatrixIndices[i]], pos); else Vector3.transform(pos, mtxtable[0], pos); @@ -989,18 +941,16 @@ else if (batch.MatrixType == 2) // gl.glPopMatrix(); } } - - - protected class Shader - { + + protected class Shader { public int program, vertexShader, fragmentShader, cacheKey; } private RarcFilesystem container; + protected ColorCubeRenderer fallback; protected Bmd model; + protected Bva visible; + protected Shader[] shaders; protected int[] textures; protected boolean hasShaders; - protected Shader[] shaders; - - protected Bva bva; -} +} \ No newline at end of file diff --git a/src/com/aurum/whitehole/rendering/BmdRendererSingle.java b/src/com/aurum/whitehole/rendering/BmdRendererSingle.java new file mode 100644 index 0000000..f610b15 --- /dev/null +++ b/src/com/aurum/whitehole/rendering/BmdRendererSingle.java @@ -0,0 +1,64 @@ +/* + © 2012 - 2017 - Whitehole Team + + Whitehole is free software: you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + Whitehole is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with Whitehole. If not, see http://www.gnu.org/licenses/. +*/ + +package com.aurum.whitehole.rendering; + +import java.io.IOException; +import com.aurum.whitehole.vectors.Vector3; +import javax.media.opengl.*; + +public class BmdRendererSingle extends GLRenderer { + public BmdRendererSingle(RenderInfo info, String model, Vector3 trans, Vector3 rot, Vector3 scl) throws IOException { + renderer = new BmdRenderer(info, model); + translation = trans; + rotation = rot; + scale = scl; + } + + public BmdRendererSingle(RenderInfo info, String model, Vector3 trans, Vector3 rot) throws IOException { + this(info, model, trans, rot, new Vector3(1f,1f,1f)); + } + + public BmdRendererSingle(RenderInfo info, String model) throws IOException { + this(info, model, new Vector3(), new Vector3(), new Vector3(1f,1f,1f)); + } + + @Override + public void close(RenderInfo info) throws GLException { + renderer.close(info); + } + + @Override + public boolean gottaRender(RenderInfo info) throws GLException { + return renderer.gottaRender(info); + } + + @Override + public void render(RenderInfo info) throws GLException { + GL2 gl = info.drawable.getGL().getGL2(); + + if (renderer.gottaRender(info)) { + gl.glTranslatef(translation.x, translation.y, translation.z); + gl.glRotatef(rotation.x, 0f, 0f, 1f); + gl.glRotatef(rotation.y, 0f, 1f, 0f); + gl.glRotatef(rotation.z, 1f, 0f, 0f); + gl.glScalef(scale.x, scale.y, scale.z); + renderer.render(info); + } + } + + private final BmdRenderer renderer; + private final Vector3 translation, rotation, scale; +} \ No newline at end of file diff --git a/src/whitehole/rendering/BtiRenderer.java b/src/com/aurum/whitehole/rendering/BtiRenderer.java similarity index 68% rename from src/whitehole/rendering/BtiRenderer.java rename to src/com/aurum/whitehole/rendering/BtiRenderer.java index d8159e3..1e95ffb 100644 --- a/src/whitehole/rendering/BtiRenderer.java +++ b/src/com/aurum/whitehole/rendering/BtiRenderer.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,145 +13,120 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.rendering; +package com.aurum.whitehole.rendering; import java.io.IOException; import java.nio.ByteBuffer; -import javax.media.opengl.GL2; -import javax.media.opengl.GLException; -import whitehole.Whitehole; -import whitehole.fileio.RarcFilesystem; -import whitehole.smg.Bti; -import whitehole.vectors.Vector3; - -public class BtiRenderer extends GLRenderer -{ - private void uploadTexture(GL2 gl) - { - int[] wrapmodes = { GL2.GL_CLAMP_TO_EDGE, GL2.GL_REPEAT, GL2.GL_MIRRORED_REPEAT }; - int[] minfilters = { GL2.GL_NEAREST, GL2.GL_LINEAR, - GL2.GL_NEAREST_MIPMAP_NEAREST, GL2.GL_LINEAR_MIPMAP_NEAREST, - GL2.GL_NEAREST_MIPMAP_LINEAR, GL2.GL_LINEAR_MIPMAP_LINEAR }; - int[] magfilters = { GL2.GL_NEAREST, GL2.GL_LINEAR, - GL2.GL_NEAREST, GL2.GL_LINEAR, - GL2.GL_NEAREST, GL2.GL_LINEAR, }; - +import com.aurum.whitehole.Whitehole; +import com.aurum.whitehole.io.RarcFilesystem; +import com.aurum.whitehole.smg.Bti; +import com.aurum.whitehole.smg.ImageUtils.FilterMode; +import com.aurum.whitehole.smg.ImageUtils.WrapMode; +import com.aurum.whitehole.vectors.Vector3; +import javax.media.opengl.*; + +public class BtiRenderer extends GLRenderer { + public BtiRenderer(RenderInfo info, String name, Vector3 _pt1, Vector3 _pt2, boolean vert) { + GL2 gl = info.drawable.getGL().getGL2(); + + try { + container = new RarcFilesystem(Whitehole.game.filesystem.openFile("/ObjectData/" + name + ".arc")); + if (container.fileExists("/" + name + "/" + name + ".bti")) + bti = new Bti(container.openFile("/" + name + "/" + name + ".bti")); + else + throw new IOException("No suitable texture file inside RARC"); + } + catch (IOException ex) { + if (container != null) try { container.close(); } catch (IOException ex2) {} + + throw new GLException("Failed to load texture "+name+": "+ex.getMessage()); + } + + pt1 = _pt1; + pt2 = _pt2; + vertical = vert; + + uploadTexture(gl); + } + + private void uploadTexture(GL2 gl) { int[] texids = new int[1]; gl.glGenTextures(1, texids, 0); texID = texids[0]; gl.glBindTexture(GL2.GL_TEXTURE_2D, texID); - gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAX_LEVEL, bti.mipmapCount - 1); - gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, minfilters[bti.minFilter]); - gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAG_FILTER, magfilters[bti.magFilter]); - gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_S, wrapmodes[bti.wrapS]); - gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_T, wrapmodes[bti.wrapT]); + gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, FilterMode.values()[bti.minFilter].get()); + gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAG_FILTER, FilterMode.values()[bti.magFilter].get()); + gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_S, WrapMode.values()[bti.wrapS].get()); + gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_T, WrapMode.values()[bti.wrapT].get()); int ifmt, fmt; - switch (bti.format) - { + switch (bti.format) { case 0: case 1: ifmt = GL2.GL_INTENSITY; fmt = GL2.GL_LUMINANCE; break; - case 2: case 3: ifmt = GL2.GL_LUMINANCE8_ALPHA8; fmt = GL2.GL_LUMINANCE_ALPHA; break; - default: ifmt = 4; fmt = GL2.GL_BGRA; break; } int width = bti.width, height = bti.height; - for (int mip = 0; mip < bti.mipmapCount; mip++) - { + for (int mip = 0 ; mip < bti.mipmapCount ; mip++) { gl.glTexImage2D(GL2.GL_TEXTURE_2D, mip, ifmt, width, height, 0, fmt, GL2.GL_UNSIGNED_BYTE, ByteBuffer.wrap(bti.image[mip])); width /= 2; height /= 2; } } - public BtiRenderer(RenderInfo info, String name, Vector3 _pt1, Vector3 _pt2, boolean vert) - { - GL2 gl = info.drawable.getGL().getGL2(); - - container = null; - bti = null; - - try - { - container = new RarcFilesystem(Whitehole.game.filesystem.openFile("/ObjectData/" + name + ".arc")); - if (container.fileExists("/" + name + "/" + name + ".bti")) - bti = new Bti(container.openFile("/" + name + "/" + name + ".bti")); - else - throw new IOException("No suitable texture file inside RARC"); - } - catch (IOException ex) - { - if (container != null) try { container.close(); } catch (IOException ex2) {} - - throw new GLException("Failed to load texture "+name+": "+ex.getMessage()); - } - - pt1 = _pt1; - pt2 = _pt2; - vertical = vert; - - uploadTexture(gl); - } - @Override - public void close(RenderInfo info) throws GLException - { + public void close(RenderInfo info) throws GLException { GL2 gl = info.drawable.getGL().getGL2(); gl.glDeleteTextures(1, new int[] { texID }, 0); - if (bti != null) - { - try { bti.close(); container.close(); } - catch (IOException ex) { } + if (bti != null) { + try { + bti.close(); + container.close(); + } + catch (IOException ex) {} } } - @Override - public void releaseStorage() - { - if (bti != null) - { - try { bti.close(); container.close(); } - catch (IOException ex) { } + public void releaseStorage() { + if (bti != null) { + try { + bti.close(); + container.close(); + } + catch (IOException ex) {} bti = null; container = null; } } - @Override - public boolean gottaRender(RenderInfo info) throws GLException - { + public boolean gottaRender(RenderInfo info) throws GLException { return info.renderMode != RenderMode.TRANSLUCENT; } @Override - public void render(RenderInfo info) throws GLException - { - if (info.renderMode == RenderMode.TRANSLUCENT) return; + public void render(RenderInfo info) throws GLException { + if (info.renderMode == RenderMode.TRANSLUCENT) + return; GL2 gl = info.drawable.getGL().getGL2(); - if (info.renderMode != RenderMode.PICKING) - { - for (int i = 0; i < 8; i++) - { - try - { + if (info.renderMode != RenderMode.PICKING) { + for (int i = 0; i < 8; i++) { + try { gl.glActiveTexture(GL2.GL_TEXTURE0 + i); gl.glDisable(GL2.GL_TEXTURE_2D); } catch (GLException ex) {} } gl.glDisable(GL2.GL_TEXTURE_2D); - gl.glDepthFunc(GL2.GL_LEQUAL); gl.glDepthMask(true); gl.glColor4f(1f, 1f, 1f, 1f); @@ -159,19 +134,24 @@ public void render(RenderInfo info) throws GLException gl.glDisable(GL2.GL_BLEND); gl.glDisable(GL2.GL_COLOR_LOGIC_OP); gl.glDisable(GL2.GL_ALPHA_TEST); - try { gl.glUseProgram(0); } catch (GLException ex) { } - try { gl.glActiveTexture(GL2.GL_TEXTURE0); } catch (GLException ex) { } + try { + gl.glUseProgram(0); + } + catch (GLException ex) {} + try { + gl.glActiveTexture(GL2.GL_TEXTURE0); + } + catch (GLException ex) {} + gl.glEnable(GL2.GL_TEXTURE_2D); gl.glBindTexture(GL2.GL_TEXTURE_2D, texID); } gl.glDisable(GL2.GL_CULL_FACE); - gl.glBegin(GL2.GL_TRIANGLE_STRIP); - if (vertical) - { + if (vertical) { gl.glTexCoord2f(0f, 0f); gl.glVertex3f(pt1.x, pt1.y, pt1.z); gl.glTexCoord2f(1f, 0f); @@ -181,8 +161,7 @@ public void render(RenderInfo info) throws GLException gl.glTexCoord2f(1f, 1f); gl.glVertex3f(pt2.x, pt2.y, pt2.z); } - else - { + else { gl.glTexCoord2f(0f, 0f); gl.glVertex3f(pt1.x, pt1.y, pt1.z); gl.glTexCoord2f(1f, 0f); @@ -196,10 +175,9 @@ public void render(RenderInfo info) throws GLException gl.glEnd(); } - private RarcFilesystem container; private Bti bti; - private int texID; private Vector3 pt1, pt2; + private int texID; private boolean vertical; -} +} \ No newline at end of file diff --git a/src/whitehole/rendering/ColorCubeRenderer.java b/src/com/aurum/whitehole/rendering/ColorCubeRenderer.java similarity index 89% rename from src/whitehole/rendering/ColorCubeRenderer.java rename to src/com/aurum/whitehole/rendering/ColorCubeRenderer.java index 20ff175..026a963 100644 --- a/src/whitehole/rendering/ColorCubeRenderer.java +++ b/src/com/aurum/whitehole/rendering/ColorCubeRenderer.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,11 +13,10 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.rendering; +package com.aurum.whitehole.rendering; -import javax.media.opengl.GL2; -import javax.media.opengl.GLException; -import whitehole.vectors.*; +import com.aurum.whitehole.vectors.Color4; +import javax.media.opengl.*; public class ColorCubeRenderer extends GLRenderer { public ColorCubeRenderer(float size, Color4 border, Color4 fill, boolean axes) { @@ -28,8 +27,7 @@ public ColorCubeRenderer(float size, Color4 border, Color4 fill, boolean axes) { } @Override - public void close(RenderInfo info) throws GLException { - } + public void close(RenderInfo info) throws GLException {} @Override public boolean isScaled() { @@ -71,9 +69,6 @@ public void render(RenderInfo info) throws GLException { } } - // we do this because the cube rendering was copypasted from SM64DSe - // however Wii models have a different vertex order - // and we're too lazy to change our cube rendering code gl.glEnable(GL2.GL_CULL_FACE); gl.glCullFace(GL2.GL_FRONT); @@ -148,9 +143,8 @@ public void render(RenderInfo info) throws GLException { } } } - - - private float cubeSize; - private Color4 borderColor, fillColor; - private boolean showAxes; + + private final float cubeSize; + private final boolean showAxes; + private final Color4 borderColor, fillColor; } \ No newline at end of file diff --git a/src/whitehole/rendering/GLRenderer.java b/src/com/aurum/whitehole/rendering/GLRenderer.java similarity index 82% rename from src/whitehole/rendering/GLRenderer.java rename to src/com/aurum/whitehole/rendering/GLRenderer.java index f5780cd..d5e71fe 100644 --- a/src/whitehole/rendering/GLRenderer.java +++ b/src/com/aurum/whitehole/rendering/GLRenderer.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,23 +13,19 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.rendering; +package com.aurum.whitehole.rendering; import javax.media.opengl.*; -public class GLRenderer -{ - public GLRenderer() - { +public class GLRenderer { + public GLRenderer() { displayLists = null; } - public void close(RenderInfo info) throws GLException - { + public void close(RenderInfo info) throws GLException { GL2 gl = info.drawable.getGL().getGL2(); - if (displayLists != null) - { + if (displayLists != null) { gl.glDeleteLists(displayLists[0], 1); gl.glDeleteLists(displayLists[1], 1); gl.glDeleteLists(displayLists[2], 1); @@ -38,18 +34,16 @@ public void close(RenderInfo info) throws GLException } public void releaseStorage() {} - public boolean isScaled() { return true; } public boolean hasSpecialScaling() { return false; } public boolean boundToObjArg(int arg) { return false; } - public boolean boundToShapeModel() { return false; } - + public boolean boundToProperty() { return false; } public boolean gottaRender(RenderInfo info) throws GLException { return false; } public void render(RenderInfo info) throws GLException {} - public void compileDisplayLists(RenderInfo info) throws GLException - { - if (displayLists != null) return; + public void compileDisplayLists(RenderInfo info) throws GLException { + if (displayLists != null) + return; GL2 gl = info.drawable.getGL().getGL2(); RenderInfo info2 = new RenderInfo(); @@ -57,8 +51,7 @@ public void compileDisplayLists(RenderInfo info) throws GLException displayLists = new int[3]; info2.renderMode = RenderMode.PICKING; - if (gottaRender(info2)) - { + if (gottaRender(info2)) { displayLists[0] = gl.glGenLists(1); gl.glNewList(displayLists[0], GL2.GL_COMPILE); render(info2); @@ -68,8 +61,7 @@ public void compileDisplayLists(RenderInfo info) throws GLException displayLists[0] = 0; info2.renderMode = RenderMode.OPAQUE; - if (gottaRender(info2)) - { + if (gottaRender(info2)) { displayLists[1] = gl.glGenLists(1); gl.glNewList(displayLists[1], GL2.GL_COMPILE); render(info2); @@ -79,8 +71,7 @@ public void compileDisplayLists(RenderInfo info) throws GLException displayLists[1] = 0; info2.renderMode = RenderMode.TRANSLUCENT; - if (gottaRender(info2)) - { + if (gottaRender(info2)) { displayLists[2] = gl.glGenLists(1); gl.glNewList(displayLists[2], GL2.GL_COMPILE); render(info2); @@ -94,16 +85,14 @@ public void compileDisplayLists(RenderInfo info) throws GLException public int[] displayLists; - public static enum RenderMode - { + public static enum RenderMode { PICKING, OPAQUE, TRANSLUCENT } - public static class RenderInfo - { + public static class RenderInfo { public GLAutoDrawable drawable; public RenderMode renderMode; } -} +} \ No newline at end of file diff --git a/src/com/aurum/whitehole/rendering/MultiRenderer.java b/src/com/aurum/whitehole/rendering/MultiRenderer.java new file mode 100644 index 0000000..caa9f61 --- /dev/null +++ b/src/com/aurum/whitehole/rendering/MultiRenderer.java @@ -0,0 +1,44 @@ +/* + © 2012 - 2017 - Whitehole Team + + Whitehole is free software: you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + Whitehole is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with Whitehole. If not, see http://www.gnu.org/licenses/. +*/ + +package com.aurum.whitehole.rendering; + +public class MultiRenderer extends GLRenderer { + public MultiRenderer(GLRenderer ... renderers) { + this.renderers = renderers; + } + + @Override + public void close(RenderInfo info) { + for (GLRenderer renderer : renderers) + renderer.close(info); + } + + @Override + public boolean gottaRender(RenderInfo info) { + boolean ret = false; + for (GLRenderer renderer : renderers) + ret |= renderer.gottaRender(info); + return ret; + } + + @Override + public void render(RenderInfo info) { + for (GLRenderer renderer : renderers) + renderer.render(info); + } + + protected GLRenderer[] renderers; +} \ No newline at end of file diff --git a/src/com/aurum/whitehole/rendering/Substitutor.java b/src/com/aurum/whitehole/rendering/Substitutor.java new file mode 100644 index 0000000..382388e --- /dev/null +++ b/src/com/aurum/whitehole/rendering/Substitutor.java @@ -0,0 +1,603 @@ +/* + © 2012 - 2017 - Whitehole Team + + Whitehole is free software: you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + Whitehole is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with Whitehole. If not, see http://www.gnu.org/licenses/. +*/ + +package com.aurum.whitehole.rendering; + +import com.aurum.whitehole.rendering.object.ShapeRenderer; +import com.aurum.whitehole.rendering.object.AreaRenderer; +import com.aurum.whitehole.rendering.object.*; +import com.aurum.whitehole.smg.object.*; +import com.aurum.whitehole.vectors.Color4; +import com.aurum.whitehole.vectors.Vector3; +import java.io.IOException; +import com.aurum.whitehole.Settings; +import com.aurum.whitehole.rendering.object.AreaRenderer.Shape; +import com.aurum.whitehole.smg.ZoneArchive; + +public class Substitutor { + public static String substituteModelName(AbstractObj obj, String model) { + switch (obj.name) { + case "ArrowSwitchMulti": return "ArrowSwitch"; + case "AstroDomeBlueStar": return "GCaptureTarget"; + case "AttackRockFinal": + case "AttackRockTutorial": return "AttackRock"; + case "BenefitItemInvincible": return "PowerUpInvincible"; + case "BenefitItemLifeUp": return "KinokoLifeUp"; + case "BenefitItemOneUp": return "KinokoOneUp"; + case "BigBubbleGenerator": + case "BigObstructBubbleGenerator": return "AirBubbleGenerator"; + case "Bomb": return "BombHei"; + case "BombLauncher": return "BombHeiLauncher"; + case "BossKameck2": return "BossKameck"; + case "BreakableCageRotate": return "BreakableCage"; + case "ButlerExplain": + case "ButlerMap": return "Butler"; + case "CoinReplica": return "Coin"; + case "Creeper": return "CreeperFlower"; + case "CutBushGroup": return "CutBush"; + case "DemoKoopaJrShip": return "KoopaJrShip"; + case "DharmaSambo": return "DharmaSamboParts"; + case "FireBallBeamKameck": return "Kameck"; + case "FirePressureRadiate": return "FirePressure"; + case "FishGroupA": return "FishA"; + case "FishGroupB": return "FishB"; + case "FishGroupC": return "FishC"; + case "FishGroupD": return "FishD"; + case "FishGroupE": return "FishE"; + case "FishGroupF": return "FishF"; + case "FlowerBlueGroup": return "FlowerBlue"; + case "FlowerGroup": return "Flower"; + case "GhostPlayer": return "GhostMario"; + case "GliBirdNpc": return "GliBird"; + case "GoldenTurtle": return "KouraShine"; + case "Hanachan": return "HanachanHead"; + case "HanachanBig": return "HanachanHeadBig"; + case "DrillBullet": return "Horino"; + case "InstantInferno": return "InfernoMario"; + case "JetTurtle": return "Koura"; + case "KameckKuriboMini": + case "KameckMeramera": return "Kameck"; + case "Karikari": return "Karipon"; + case "KirairaRail": return "Kiraira"; + case "KoopaBattleMapCoinPlate": return "KoopaPlateCoin"; + case "KoopaBattleMapPlate": return "KoopaPlate"; + case "KoopaBattleMapStairturnAppear": return "KoopaBattleMapStairTurn"; + case "KoopaNpc": return "Koopa"; + case "KoopaStatueVomit": return "KoopaStatue"; + case "KoopaLv2": + case "KoopaLv3": + case "KoopaLv4": return "Koopa"; + case "LavaProminenceWithoutShadow": return "LavaProminence"; + case "SpinLeverSwitchForceAnim": return "SpinLeverSwitch"; + case "LuigiTalkNpc": + case "LuigiIntrusively": return "LuigiNpc"; + case "MagicBell": return "Bell"; + case "MameMuimuiAttackMan": return "ScoreAttackMan"; + case "MeteorCannon": + case "MeteorStrikeEnvironment": return "MeteorStrike"; + case "MiniKoopaBattleVs1Galaxy": + case "MiniKoopaBattleVs2Galaxy": + case "MiniKoopaBattleVs3Galaxy": return "MiniKoopaGalaxy"; + case "MorphItemCollectionBee": return "PowerUpBee"; + case "MorphItemCollectionCloud": return "PowerUpCloud"; + case "MorphItemCollectionDrill": return "ItemDrill"; + case "MorphItemCollectionFire": return "PowerUpFire"; + case "MorphItemCollectionHopper": return "PowerUpHopper"; + case "MorphItemCollectionTeresa": return "PowerUpTeresa"; + case "MorphItemCollectionRock": return "PowerUpRock"; + case "MorphItemNeoBee": return "PowerUpBee"; + case "MorphItemNeoFire": return "PowerUpFire"; + case "MorphItemNeoFoo": return "PowerUpFoo"; + case "MorphItemNeoHopper": return "PowerUpHopper"; + case "MorphItemNeoIce": return "PowerUpIce"; + case "MorphItemNeoTeresa": return "PowerUpTeresa"; + case "MorphItemRock": return "PowerUpRock"; + case "NoteFairy": return "Note"; + case "OnimasuPivot": return "Onimasu"; + case "PenguinSkater": + case "PenguinStudent": return "Penguin"; + case "Plant": return "PlantSeed"; + case "PlayAttackMan": return "ScoreAttackMan"; + case "PrologueDirector": return "DemoLetter"; + case "PukupukuWaterSurface": return "Pukupuku"; + case "Rabbit": return "MoonRabbit"; + case "RockCreator": return "Rock"; + case "RunawayRabbitCollect": return "TrickRabbit"; + case "SeaGullGroup": + case "SeaGullGroupMarioFace": return "SeaGull"; + case "ShellfishBlueChip": + case "ShellfishCoin": + case "ShellfishKinokoOneUp": + case "ShellfishYellowChip": return "Shellfish"; + case "SignBoardTamakoro": return "SignBoard"; + case "SkeletalFishBaby": return "SnakeFish"; + case "SpiderAttachPoint": return "SpiderThreadAttachPoint"; + case "SpiderCoin": return "Coin"; + case "SpinCloudItem": + case "SpinCloudMarioItem": return "PowerUpCloud"; + case "ItemBlockSwitch": + case "SplashCoinBlock": + case "SplashPieceBlock": + case "TimerCoinBlock": + case "TimerPieceBlock": return "CoinBlock"; + case "SuperDreamer": return "HelperWitch"; + case "SuperSpinDriverGreen": + case "SuperSpinDriverPink": return "SuperSpinDriver"; + case "SurpBeltConveyerExGalaxy": + case "SurpCocoonExGalaxy": + case "SurpCubeBubbleExLv2Galaxy": + case "SurpFishTunnelGalaxy": + case "SurpPeachCastleFinalGalaxy": + case "SurpSnowCapsuleGalaxy": + case "SurpSurfingLv2Galaxy": + case "SurpTamakoroExLv2Galaxy": + case "SurpTearDropGalaxy": + case "SurpTeresaMario2DGalaxy": + case "SurpTransformationExGalaxy": return "MiniSurprisedGalaxy"; + case "TalkSyati": return "Syati"; + case "TamakoroWithTutorial": return "Tamakoro"; + case "Teresa": + case "TeresaChief": return "TeresaWater"; + case "TicoAstro": + case "TicoDomeLecture": return "Tico"; + case "TicoFatCoin": + case "TicoFatStarPiece": + case "TicoGalaxy": return "TicoFat"; + case "TicoRail": + case "TicoReading": + case "TicoStarRing": return "Tico"; + case "TogepinAttackMan": return "ScoreAttackMan"; + case "Tongari2D": return "Tongari"; + case "TreasureBoxBlueChip": + case "TreasureBoxCoin": return "TreasureBox"; + case "TreasureBoxCrackedAirBubble": + case "TreasureBoxCrackedBlueChip": + case "TreasureBoxCrackedCoin": + case "TreasureBoxCrackedEmpty": + case "TreasureBoxCrackedKinokoLifeUp": + case "TreasureBoxCrackedKinokoOneUp": + case "TreasureBoxCrackedPowerStar": + case "TreasureBoxCrackedYellowChip": return "TreasureBoxCracked"; + case "TreasureBoxEmpty": return "TreasureBox"; + case "TreasureBoxGoldEmpty": return "TreasureBoxGold"; + case "TreasureBoxKinokoLifeUp": + case "TreasureBoxKinokoOneUp": + case "TreasureBoxYellowChip": return "TreasureBox"; + case "TrickRabbitFreeRun": + case "TrickRabbitFreeRunCollect": + case "TrickRabbitGhost": return "TrickRabbit"; + case "TripodBossCoin": return "Coin"; + case "TripodBossBottomKillerCannon": + case "TripodBossKillerGenerator": return "TripodBossKillerCannon"; + case "TripodBossKinokoOneUp": return "KinokoOneUp"; + case "TripodBossUnderKillerCannon": + case "TripodBossUpperKillerCannon": return "TripodBossKillerCannon"; + case "TubeSliderDamageObj": return "NeedlePlant"; + case "TubeSliderEnemy": return "Togezo"; + case "TubeSliderHana": return "HanachanHeadBig"; + case "TurtleBeamKameck": return "Kameck"; + case "TwoLegsBullet": return "Horino"; + case "WingBlockCoin": + case "WingBlockStarPiece": return "WingBlock"; + case "YoshiCapture": return "YCaptureTarget"; + } + return model; + } + + public static String substituteObjectKey(AbstractObj obj, String objectkey) { + switch (obj.name) { + case "PlantA": + case "PlantB": + case "PlantC": + case "PlantD": objectkey += String.format("_%1$d_%2$d", obj.data.get("ShapeModelNo"), obj.data.get("Obj_arg3")); break; + case "MarinePlant": objectkey += String.format("_%1$d_%2$d", obj.data.get("ShapeModelNo"), obj.data.get("Obj_arg1")); break; + case "Pole": + case "PoleSquare": + case "Pole2Way": objectkey += String.format("_%1$3f", obj.scale.y / obj.scale.x); break; + case "BlackHole": + case "BlackHoleCube": objectkey += String.format("_%1$d_%2$f_%3$f_%4$f", obj.data.getOrDefault("Obj_arg0", 1000), obj.scale.x, obj.scale.y, obj.scale.z); break; + case "Kinopio": + case "KinopioAstro": objectkey += String.format("_%1$d", obj.data.get("Obj_arg1")); break; + case "UFOKinoko": objectkey += String.format("_%1$d", obj.data.get("Obj_arg0")); break; + case "OtaKing": objectkey += String.format("_%1$d", obj.data.get("Obj_arg1")); break; + case "Coin": + case "PurpleCoin": objectkey += String.format("_%1$d", obj.data.get("Obj_arg7")); break; + case "AstroDome": + case "AstroDomeEntrance": + case "AstroDomeSky": + case "AstroStarPlate": objectkey += String.format("_%1$d", obj.data.get("Obj_arg0")); break; + case "BreakableCage": objectkey += String.format("_%1$d", obj.data.get("Obj_arg7")); break; + } + + if (ZoneArchive.game == 2) { + if (obj instanceof AreaObj) + objectkey = String.format("AreaShapeNo%1$d", obj.data.get("AreaShapeNo")); + if (obj instanceof CameraObj) + objectkey = String.format("CameraShapeNo%1$d", obj.data.get("AreaShapeNo")); + } + + if (obj instanceof GravityObj) { + objectkey += String.format("_%1$f_%2$f_%3$f_%4$f", obj.data.get("Range"), obj.scale.x, obj.scale.y, obj.scale.z); + } + + return objectkey; + } + + public static GLRenderer substituteRenderer(AbstractObj obj, GLRenderer.RenderInfo info) { + try { + // Specified object rendering + if (obj instanceof LevelObj || obj instanceof MapPartObj) { + switch (obj.name) { + // ShapeModel rendering + case "PlantA": + case "PlantB": + case "PlantC": + case "PlantD": return new ShapeRenderer(info, obj.name, (short)obj.data.get("ShapeModelNo")); + case "MarinePlant": return new ShapeRenderer(info, obj.name, (short)obj.data.get("ShapeModelNo")); + case "Pole": + case "PoleNoModel": return new PoleRenderer(info, obj.scale, "Pole"); + case "PoleSquare": + case "PoleSquareNoModel": + case "Pole2Way": return new PoleRenderer(info, obj.scale, "PoleSquare"); + + // Flag rendering + case "Flag": return new BtiRenderer(info, "Flag", new Vector3(0f,150f,0f), new Vector3(0f,-150f,600f), true); + case "FlagRaceA": return new BtiRenderer(info, "FlagRaceA", new Vector3(0f,75f,0f), new Vector3(0f,-75f,300f), true); + case "FlagSurfing": return new BtiRenderer(info, "FlagSurfing", new Vector3(0f,150f,0f), new Vector3(0f,-150f,600f), true); + case "FlagTamakoro": return new BtiRenderer(info, "FlagTamakoro", new Vector3(0f,150f,0f), new Vector3(0f,-150f,600f), true); + case "FlagPeachCastleA": return new BtiRenderer(info, "FlagPeachCastleA", new Vector3(0f,150f,0f), new Vector3(0f,-150f,600f), true); + case "FlagPeachCastleB": return new BtiRenderer(info, "FlagPeachCastleB", new Vector3(0f,150f,0f), new Vector3(0f,-150f,600f), true); + case "FlagPeachCastleC": return new BtiRenderer(info, "FlagPeachCastleC", new Vector3(0f,150f,0f), new Vector3(0f,-150f,600f), true); + case "FlagKoopaA": return new BtiRenderer(info, "FlagKoopaA", new Vector3(0f,150f,0f), new Vector3(0f,-150f,600f), true); + case "FlagKoopaB": return new BtiRenderer(info, "FlagKoopaB", new Vector3(0f,75f,0f), new Vector3(0f,-75f,600f), true); + case "FlagKoopaCastle": return new BtiRenderer(info, "FlagKoopaCastle", new Vector3(0f,150f,0f), new Vector3(0f,-150f,600f), true); + + // Comet Observatory objects + case "AstroStarPlate": + case "AstroDome": + case "AstroDomeEntrance": return new AstroRenderer(info, obj.name, (int)obj.data.get("Obj_arg0")); + case "AstroDomeSky": return new AstroSkyRenderer(info, obj.name, (int)obj.data.get("Obj_arg0")); + + // Black holes + case "BlackHole": return new BlackHoleRenderer(info, (int) obj.data.get("Obj_arg0"), obj.scale, Shape.SPHERE); + case "BlackHoleCube": return new BlackHoleRenderer(info, (int) obj.data.get("Obj_arg0"), obj.scale, Shape.CENTEREDCUBE); + + // Other + case "Coin": + case "PurpleCoin": return new ItemBubbleRenderer(info, obj.name, (int)obj.data.get("Obj_arg7")); + case "OtaKing": return new OtaKingRenderer(info, obj.name, (int)obj.data.get("Obj_arg1")); + case "Kinopio": + case "KinopioAstro": return new KinopioRenderer(info, (int)obj.data.get("Obj_arg1")); + case "KinopioBank": return new KinopioRenderer(info, 1); + case "KinopioPostman": return new KinopioRenderer(info, 2); + case "UFOKinoko": return new UFOKinokoRenderer(info, (int)obj.data.get("Obj_arg0")); + case "EarthenPipe": + case "EarthenPipeInWater": return new BmdRendererSingle(info, "EarthenPipe", new Vector3(0f,100f,0f), new Vector3()); + + // Multi-model rendering + case "Patakuri": return new MultiRenderer( + new BmdRendererSingle(info, "Kuribo"), + new BmdRendererSingle(info, "PatakuriWing", new Vector3(0f,15f,-25f), new Vector3()) + ); + case "PatakuriBig": return new MultiRenderer( + new BmdRendererSingle(info, "KuriboChief"), + new BmdRendererSingle(info, "PatakuriWingBig", new Vector3(0f,750f,200f), new Vector3(0f,90f,0f)) + ); + case "Nyoropon": return new MultiRenderer( + new BmdRendererSingle(info, "NyoroponBody"), + new BmdRendererSingle(info, "NyoroponHead", new Vector3(0f,500f,0f), new Vector3(90f,0f,0f)) + ); + case "StrayTico": return new MultiRenderer( + new BmdRendererSingle(info, "StrayTico"), + new BmdRendererSingle(info, "ItemBubble") + ); + case "HammerHeadPackun": return new MultiRenderer( + new BmdRendererSingle(info, "PackunFlower"), + new BmdRendererSingle(info, "PackunLeaf") + ); + case "HammerHeadPackunSpike": return new MultiRenderer( + new BmdRendererSingle(info, "PackunFlowerSpike"), + new BmdRendererSingle(info, "PackunLeafSpike") + ); + case "CocoSambo": return new MultiRenderer( + new BmdRendererSingle(info, "CocoSamboBody"), + new BmdRendererSingle(info, "CocoSamboHead", new Vector3(0f,325f,0f), new Vector3()) + ); + case "Kiraira": return new MultiRenderer( + new BmdRendererSingle(info, "Kiraira", new Vector3(0f,50f,0f), new Vector3()), + new BmdRendererSingle(info, "KirairaChain", new Vector3(0f,-160f,0f), new Vector3()), + new BmdRendererSingle(info, "KirairaFixPointBottom", new Vector3(0f,-15f,0f), new Vector3()) + ); + case "Torpedo": return new MultiRenderer( + new BmdRendererSingle(info, "Torpedo"), + new BmdRendererSingle(info, "TorpedoPropeller") + ); + case "BegomanSpike": return new MultiRenderer( + new BmdRendererSingle(info, "BegomanSpike"), + new BmdRendererSingle(info, "BegomanSpikeHead") + ); + case "BegomanSpring": + case "BegomanSpringHide": return new MultiRenderer( + new BmdRendererSingle(info, "BegomanSpring"), + new BmdRendererSingle(info, "BegomanSpringHead") + ); + case "JumpBeamer": return new MultiRenderer( + new BmdRendererSingle(info, "JumpBeamerBody"), + new BmdRendererSingle(info, "JumpBeamerHead") + ); + case "JumpGuarder": return new MultiRenderer( + new BmdRendererSingle(info, "JumpGuarder"), + new BmdRendererSingle(info, "JumpGuarderHeader") + ); + case "GliderBazooka": + case "GliderShooter": + case "KillerShooter": return new MultiRenderer( + new BmdRendererSingle(info, "MogucchiSpike"), + new BmdRendererSingle(info, "GliderBazooka") + ); + case "WaterBazooka": return new MultiRenderer( + new BmdRendererSingle(info, "WaterBazooka"), + new BmdRendererSingle(info, "WaterBazookaCapsule", new Vector3(0f, 475f, 0f), new Vector3()), + new BmdRendererSingle(info, "MogucchiShooter", new Vector3(0f,-160f,0f), new Vector3()) + ); + case "ElectricBazooka": return new MultiRenderer( + new BmdRendererSingle(info, "ElectricBazooka"), + new BmdRendererSingle(info, "WaterBazookaCapsule", new Vector3(0f, 475f, 0f), new Vector3()), + new BmdRendererSingle(info, "MogucchiShooter", new Vector3(0f,-160f,0f), new Vector3()) + ); + case "DinoPackun": + case "DinoPackunVs1": return new MultiRenderer( + new BmdRendererSingle(info, "DinoPackun"), + new BmdRendererSingle(info, "DinoPackunTailBall", new Vector3(0f,150f,-750f), new Vector3(0f,90f,0f)) + ); + case "DinoPackunVs2": return new MultiRenderer( + new BmdRendererSingle(info, "DinoPackun2"), + new BmdRendererSingle(info, "DinoPackunTailBall", new Vector3(0f,150f,-750f), new Vector3(0f,90f,0f)) + ); + case "BossBegoman": return new MultiRenderer( + new BmdRendererSingle(info, "BossBegoman"), + new BmdRendererSingle(info, "BossBegomanHead") + ); + case "BossJugem": return new MultiRenderer( + new BmdRendererSingle(info, "BossJugem"), + new BmdRendererSingle(info, "BossJugemCloud") + ); + case "KoopaJrRobot": return new MultiRenderer( + new BmdRendererSingle(info, "KoopaJrRobot"), + new BmdRendererSingle(info, "KoopaJrRobotPod", new Vector3(0f,1000f,0f), new Vector3()) + ); + case "KoopaJrCastle": return new MultiRenderer( + new BmdRendererSingle(info, "KoopaJrCastleBody"), + new BmdRendererSingle(info, "KoopaJrCastleHead", new Vector3(0f,2750f,0f), new Vector3()), + new BmdRendererSingle(info, "KoopaJrCastleCapsule", new Vector3(0f,700f,0f), new Vector3()) + ); + case "OtaRockTank": return new MultiRenderer( + new BmdRendererSingle(info, "OtaRockTank"), + new BmdRendererSingle(info, "OtaRockChief", new Vector3(0f, 500f, 0f), new Vector3()) + ); + case "TombSpider": return new MultiRenderer( + new BmdRendererSingle(info, "TombSpider"), + new BmdRendererSingle(info, "TombSpiderPlanet") + ); + case "SkeletalFishBoss": return new MultiRenderer( + new BmdRendererSingle(info, "SkeletalFishBoss"), + new BmdRendererSingle(info, "SkeletalFishBossHeadA") + ); + } + } + + if (obj instanceof AreaObj || obj instanceof CameraObj) { + if (Settings.editor_areas) { + if (ZoneArchive.game == 2) { + Shape shape; + switch((short) obj.data.get("AreaShapeNo")) { + case 0: + case 1: shape = Shape.CUBE; break; + case 2: shape = Shape.SPHERE; break; + case 3: shape = Shape.CYLINDER; break; + default: shape = Shape.UNDEFINED; + } + + if (shape == Shape.UNDEFINED) { + if (obj instanceof AreaObj) + return new ColorCubeRenderer (100f, new Color4(1f, 0.5f, 0.5f), new Color4(0.3f, 1f, 1f), true); + if (obj instanceof CameraObj) + return new ColorCubeRenderer (100f, new Color4(0.3f, 0f, 1f), new Color4(0.8f, 0f, 0f), true); + } + else { + if (obj instanceof AreaObj) + return new AreaRenderer(new Color4(0.3f, 1f, 1f), shape); + if (obj instanceof CameraObj) + return new AreaRenderer(new Color4(0.8f, 0f, 0f), shape); + } + } + else if (ZoneArchive.game == 1) { + switch(obj.name) { + // AreaObj cubic + case "AstroChangeStageCube": + case "AudioEffectCube": + case "BeeWallShortDistAreaCube": + case "BgmProhibitArea": + case "BigBubbleGoalAreaBox": + case "BigBubbleSwitchBox": + case "BindEndCube": + case "BlackHoleCube": + case "BloomCube": + case "BlueStarGuidanceCube": + case "ChangeBgmCube": + case "CollisionArea": + case "DarkMatterCube": + case "DeathCube": + case "DepthOfFieldCube": + case "ExtraWallCheckArea": + case "FallsCube": + case "ForbidJumpCube": + case "ForbidTriangleJumpCube": + case "ForbidWaterSearchCube": + case "ForceDashCube": + case "HazeCube": + case "HeavySteeringCube": + case "LensFlareArea": + case "LightCtrlCube": + case "MercatorCube": + case "MessageAreaCube": + case "MirrorAreaCube": + case "NonSleepCube": + case "PipeModeCube": + case "PlaneCircularModeCube": + case "PlaneCollisionCube": + case "PlanetModeCube": + case "PlayerSeCube": + case "PullBackCube": + case "QuakeEffectAreaCube": + case "RasterScrollCube": + case "RestartCube": + case "ScreenBlurCube": + case "SimpleBloomCube": + case "SmokeEffectColorAreaCube": + case "SoundEmitterCube": + case "SpinGuidanceCube": + case "SunLightAreaBox": + case "SwitchCube": + case "TamakoroJumpGuidanceCube": + case "TamakoroMoveGuidanceCube": + case "TicoSeedGuidanceCube": + case "TripodBossStepStartArea": + case "ViewGroupCtrlCube": + case "WaterCube": return new AreaRenderer(new Color4(0.3f, 1f, 1f), Shape.CUBE); + + // AreaObj spherical + case "AreaMoveSphere": + case "AudioEffectSphere": + case "BigBubbleGoalAreaSphere": + case "BigBubbleSwitchSphere": + case "BloomSphere": + case "CelestrialSphere": + case "DeathSphere": + case "DepthOfFieldSphere": + case "PlayerSeSphere": + case "SimpleBloomSphere": + case "SoundEmitterSphere": + case "ScreenBlurSphere": + case "SwitchSphere": return new AreaRenderer(new Color4(0.3f, 1f, 1f), Shape.SPHERE); + + // AreaObj cylindrical + case "AstroOverlookAreaCylinder": + case "AudioEffectCylinder": + case "BigBubbleGoalAreaCylinder": + case "BigBubbleSwitchCylinder": + case "BloomCylinder": + case "DarkMatterCylinder": + case "DashChargeCylinder": + case "DeathCylinder": + case "DepthOfFieldCylinder": + case "DodoryuClosedCylinder": + case "EffectCylinder": + case "ExtraWallCheckCylinder": + case "GlaringLightAreaCylinder": + case "LightCtrlCylinder": + case "MessageAreaCylinder": + case "PlayerSeCylinder": + case "PullBackCylinder": + case "ScreenBlurCylinder": + case "SimpleBloomCylinder": + case "SwitchCylinder": + case "TowerModeCylinder": + case "WaterCylinder": return new AreaRenderer(new Color4(0.3f, 1f, 1f), Shape.CYLINDER); + + // CubeCamera cubic + case "BigBubbleCameraAreaBox": + case "CubeCameraBox": return new AreaRenderer(new Color4(0.8f, 0f, 0f), Shape.CUBE); + + // CubeCamera spherical + case "BigBubbleCameraAreaSphere": + case "CameraRepulsiveSphere": + case "CubeCameraBowl": + case "CubeCameraSphere": return new AreaRenderer(new Color4(0.8f, 0f, 0f), Shape.SPHERE); + + // CubeCamera cylindrical + case "BigBubbleCameraAreaCylinder": + case "CameraRepulsiveCylinder": + case "CubeCameraCylinder": return new AreaRenderer(new Color4(0.8f, 0f, 0f), Shape.CYLINDER); + } + } + } + else { + if (obj instanceof AreaObj) + return new ColorCubeRenderer (100f, new Color4(1f, 0.5f, 0.5f), new Color4(0.3f, 1f, 1f), true); + + if (obj instanceof CameraObj) + return new ColorCubeRenderer (100f, new Color4(0.3f, 0f, 1f), new Color4(0.8f, 0f, 0f), true); + } + } + + // Planet rendering + if (obj instanceof GravityObj) { + if (Settings.editor_areas) { + switch(obj.name) { + // PlanetObj unfinished + case "GlobalDiskGravity": + case "GlobalDiskTorusGravity": + case "GlobalPlaneGravity": + case "GlobalSegmentGravity": + case "GlobalWireGravity": return new ColorCubeRenderer(100f, new Color4(1f, 1f, 1f), new Color4(0f,0.8f,0f), true); + + // PlanetObj cubic + case "GlobalCubeGravity": + case "GlobalPlaneGravityInBox": + case "ZeroGravityBox": return new GravityRenderer(obj.scale, (float) obj.data.get("Range"), Shape.CUBE); + + // PlanetObj spherical + case "GlobalPointGravity": + case "ZeroGravitySphere": return new GravityRenderer(obj.scale, (float) obj.data.get("Range"), Shape.SPHERE); + + // PlanetObj cylindrical + case "GlobalBarrelGravity": + case "GlobalPlaneGravityInCylinder": + case "ZeroGravityCylinder": return new GravityRenderer(obj.scale, (float) obj.data.get("Range"), Shape.CYLINDER); + + // PlanetObj cone + case "GlobalConeGravity": return new GravityRenderer(obj.scale, (float) obj.data.get("Range"), Shape.CONE); + } + } + else { + return new ColorCubeRenderer(100f, new Color4(1f, 1f, 1f), new Color4(0f,0.8f,0f), true); + } + } + + // Other object rendering + if (obj.getClass() == ChildObj.class) + return new ColorCubeRenderer (100f, new Color4(1f, 1f, 1f), new Color4(1f, 0.5f, 0.5f), true); + + if (obj.getClass() == CutsceneObj.class) + return new ColorCubeRenderer (100f, new Color4(1f, 0.5f, 0.5f), new Color4(1.0f, 1.0f, 0.3f), true); + + if (obj.getClass() == PositionObj.class) + return new ColorCubeRenderer (100f, new Color4(1f, 1f, 1f), new Color4(1f,0.5f,0f), true); + + if (obj.getClass() == SoundObj.class) + return new ColorCubeRenderer (100f, new Color4(1f, 1f, 1f), new Color4(1f, 0.5f, 1f), true); + + if (obj.getClass() == DebugObj.class) + return new ColorCubeRenderer (100f, new Color4(1f, 1f, 1f), new Color4(0.8f, 0.5f, 0.1f), true); + + if (obj.getClass() == ChangeObj.class) + return new ColorCubeRenderer (100f, new Color4(1f, 1f, 1f), new Color4(0.4f,0.6f,0.7f), true); + } + catch (IOException ex) {} + + return null; + } +} \ No newline at end of file diff --git a/src/whitehole/rendering/RendererCache.java b/src/com/aurum/whitehole/rendering/cache/RendererCache.java similarity index 50% rename from src/whitehole/rendering/RendererCache.java rename to src/com/aurum/whitehole/rendering/cache/RendererCache.java index ba75157..fc7553e 100644 --- a/src/whitehole/rendering/RendererCache.java +++ b/src/com/aurum/whitehole/rendering/cache/RendererCache.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,65 +13,61 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.rendering; +package com.aurum.whitehole.rendering.cache; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import javax.media.opengl.GLContext; -import javax.media.opengl.GLException; -import whitehole.Whitehole; -import whitehole.fileio.RarcFilesystem; -import whitehole.smg.Bcsv; -import whitehole.smg.LevelObject; -import whitehole.vectors.Color4; +import com.aurum.whitehole.Whitehole; +import com.aurum.whitehole.io.RarcFilesystem; +import com.aurum.whitehole.rendering.BmdRenderer; +import com.aurum.whitehole.rendering.GLRenderer; +import com.aurum.whitehole.rendering.object.PlanetRenderer; +import com.aurum.whitehole.rendering.Substitutor; +import com.aurum.whitehole.smg.Bcsv; +import com.aurum.whitehole.smg.object.AbstractObj; +import javax.media.opengl.*; -public class RendererCache -{ - public static void initialize() - { - cache = new HashMap<>(); +public class RendererCache { + public static void init() { + cache = new HashMap(); + planetList = null; refContext = null; contextCount = 0; - - planetList = null; } - public static void loadPlanetList() - { - if (planetList != null) return; + public static void loadPlanetList() { + if (planetList != null) + return; - try - { + try { RarcFilesystem arc = new RarcFilesystem(Whitehole.game.filesystem.openFile("/ObjectData/PlanetMapDataTable.arc")); Bcsv planetmap = new Bcsv(arc.openFile("/PlanetMapDataTable/PlanetMapDataTable.bcsv")); - planetList = new ArrayList<>(planetmap.entries.size()); - for (Bcsv.Entry entry : planetmap.entries) - planetList.add((String)entry.get("PlanetName")); + planetList = new ArrayList(planetmap.entries.size()); + for (Bcsv.Entry entry : planetmap.entries) { + if ((int) entry.get("WaterFlag") != 0) + planetList.add((String) entry.get("PlanetName")); + } planetmap.close(); arc.close(); } - catch (IOException ex) - { - planetList = new ArrayList<>(0); + catch (IOException ex) { + planetList = new ArrayList(); } } - public static GLRenderer getObjectRenderer(GLRenderer.RenderInfo info, LevelObject obj) - { + public static GLRenderer getObjectRenderer(GLRenderer.RenderInfo info, AbstractObj obj) { loadPlanetList(); - String modelname = obj.name; - modelname = Substitutor.substituteModelName(obj, modelname); + String modelname = Substitutor.substituteModelName(obj, obj.name); String key = "object_" + obj.name; key = Substitutor.substituteObjectKey(obj, key); - if (cache.containsKey(key)) - { + if (cache.containsKey(key)) { CacheEntry entry = cache.get(key); entry.refCount++; return entry.renderer; @@ -79,72 +75,57 @@ public static GLRenderer getObjectRenderer(GLRenderer.RenderInfo info, LevelObje CacheEntry entry = new CacheEntry(); entry.refCount = 1; - entry.renderer = Substitutor.substituteRenderer(obj, info); - // if no renderer substitution happened, load the default renderer - if (entry.renderer == null) - { - try - { - if (planetList.contains(obj.name)) - entry.renderer = new PlanetRenderer(info, obj.name); - else - entry.renderer = new BmdRenderer(info, modelname); + if (entry.renderer == null) { + try { + entry.renderer = planetList.contains(modelname) ? new PlanetRenderer(info, modelname) : new BmdRenderer(info, modelname); } - catch (GLException ex) - { - if (!ex.getMessage().contains("doesn't exist") && !ex.getMessage().contains("No suitable model file inside RARC")) - ex.printStackTrace(); - entry.renderer = null; + catch (GLException ex) { + System.out.println(ex); } } - // if everything else failed, load the failsafe colorcube renderer - if (entry.renderer == null) - entry.renderer = new ColorCubeRenderer(100F, new Color4(0.5F, 0.5F, 1F, 1F), new Color4(0F, 0F, 0.8F, 1F), true); - cache.put(key, entry); return entry.renderer; } - public static void closeObjectRenderer(GLRenderer.RenderInfo info, LevelObject obj) - { + public static void closeObjectRenderer(GLRenderer.RenderInfo info, AbstractObj obj) { String key = "object_" + obj.oldname; key = Substitutor.substituteObjectKey(obj, key); - if (!cache.containsKey(key)) return; + if (!cache.containsKey(key)) + return; CacheEntry entry = cache.get(key); entry.refCount--; - if (entry.refCount > 0) return; + if (entry.refCount > 0) + return; entry.renderer.close(info); cache.remove(key); } - public static void setRefContext(GLContext ctx) - { - if (refContext == null) refContext = ctx; + public static void setRefContext(GLContext ctx) { + if (refContext == null) + refContext = ctx; contextCount++; } - public static void clearRefContext() - { + public static void clearRefContext() { contextCount--; - if (contextCount < 1) refContext = null; + if (contextCount < 1) + refContext = null; } - public static class CacheEntry - { + public static class CacheEntry { public GLRenderer renderer; public int refCount; } public static HashMap cache; + public static List planetList; public static GLContext refContext; public static int contextCount; - - private static List planetList; -} +} \ No newline at end of file diff --git a/src/whitehole/rendering/ShaderCache.java b/src/com/aurum/whitehole/rendering/cache/ShaderCache.java similarity index 74% rename from src/whitehole/rendering/ShaderCache.java rename to src/com/aurum/whitehole/rendering/cache/ShaderCache.java index 734d688..4d0587f 100644 --- a/src/whitehole/rendering/ShaderCache.java +++ b/src/com/aurum/whitehole/rendering/cache/ShaderCache.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,31 +13,26 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.rendering; +package com.aurum.whitehole.rendering.cache; import java.util.HashMap; -public class ShaderCache -{ - public static void initialize() - { - cache = new HashMap<>(); +public class ShaderCache { + public static void init() { + cache = new HashMap(); } - public static boolean containsEntry(Object key) - { + public static boolean containsEntry(Object key) { return cache.containsKey(key); } - public static CacheEntry getEntry(Object key) - { + public static CacheEntry getEntry(Object key) { CacheEntry entry = cache.get(key); entry.refCount++; return entry; } - public static void addEntry(Object key, int vert, int frag, int prog) - { + public static void addEntry(Object key, int vert, int frag, int prog) { CacheEntry entry = new CacheEntry(); entry.vertexID = vert; entry.fragmentID = frag; @@ -46,22 +41,21 @@ public static void addEntry(Object key, int vert, int frag, int prog) cache.put(key, entry); } - public static boolean removeEntry(Object key) - { + public static boolean removeEntry(Object key) { CacheEntry entry = cache.get(key); entry.refCount--; - if (entry.refCount > 0) return false; + if (entry.refCount > 0) + return false; cache.remove(key); return true; } - public static class CacheEntry - { + public static class CacheEntry { public int vertexID, fragmentID, programID; public int refCount; } public static HashMap cache; -} +} \ No newline at end of file diff --git a/src/whitehole/rendering/TextureCache.java b/src/com/aurum/whitehole/rendering/cache/TextureCache.java similarity index 71% rename from src/whitehole/rendering/TextureCache.java rename to src/com/aurum/whitehole/rendering/cache/TextureCache.java index 8547466..3a19278 100644 --- a/src/whitehole/rendering/TextureCache.java +++ b/src/com/aurum/whitehole/rendering/cache/TextureCache.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,44 +13,37 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.rendering; +package com.aurum.whitehole.rendering.cache; import java.util.HashMap; -public class TextureCache -{ - public static void initialize() - { - cache = new HashMap<>(); +public class TextureCache { + public static void init() { + cache = new HashMap(); } - public static boolean containsEntry(Object key) - { + public static boolean containsEntry(Object key) { return cache.containsKey(key); } - public static CacheEntry getEntry(Object key) - { + public static CacheEntry getEntry(Object key) { CacheEntry entry = cache.get(key); entry.refCount++; return entry; } - public static int getTextureID(Object key) - { + public static int getTextureID(Object key) { return cache.get(key).textureID; } - public static void addEntry(Object key, int tex) - { + public static void addEntry(Object key, int tex) { CacheEntry entry = new CacheEntry(); entry.textureID = tex; entry.refCount = 1; cache.put(key, entry); } - public static boolean removeEntry(Object key) - { + public static boolean removeEntry(Object key) { CacheEntry entry = cache.get(key); entry.refCount--; if (entry.refCount > 0) return false; @@ -59,12 +52,10 @@ public static boolean removeEntry(Object key) return true; } - - public static class CacheEntry - { + public static class CacheEntry { public int textureID; public int refCount; } public static HashMap cache; -} +} \ No newline at end of file diff --git a/src/whitehole/rendering/AreaShapeRenderer.java b/src/com/aurum/whitehole/rendering/object/AreaRenderer.java similarity index 50% rename from src/whitehole/rendering/AreaShapeRenderer.java rename to src/com/aurum/whitehole/rendering/object/AreaRenderer.java index 216d924..58cf920 100644 --- a/src/whitehole/rendering/AreaShapeRenderer.java +++ b/src/com/aurum/whitehole/rendering/object/AreaRenderer.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,23 +13,21 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.rendering; +package com.aurum.whitehole.rendering.object; -import javax.media.opengl.GL2; -import javax.media.opengl.GLException; -import javax.media.opengl.glu.GLU; -import javax.media.opengl.glu.GLUquadric; -import whitehole.vectors.*; +import com.aurum.whitehole.rendering.GLRenderer; +import com.aurum.whitehole.vectors.Color4; +import javax.media.opengl.*; +import javax.media.opengl.glu.*; -public class AreaShapeRenderer extends GLRenderer { - public AreaShapeRenderer(Color4 color, short shape) { +public class AreaRenderer extends GLRenderer { + public AreaRenderer(Color4 color, Shape shape) { areaColor = color; areaShape = shape; } @Override - public void close(GLRenderer.RenderInfo info) throws GLException { - } + public void close(GLRenderer.RenderInfo info) throws GLException {} @Override public boolean isScaled() { @@ -54,8 +52,7 @@ public void render(GLRenderer.RenderInfo info) throws GLException { gl.glActiveTexture(GL2.GL_TEXTURE0 + i); gl.glDisable(GL2.GL_TEXTURE_2D); } - catch (GLException ex) { - } + catch (GLException ex) {} } gl.glDisable(GL2.GL_TEXTURE_2D); gl.glDepthFunc(GL2.GL_LEQUAL); @@ -63,94 +60,101 @@ public void render(GLRenderer.RenderInfo info) throws GLException { try { gl.glUseProgram(0); } - catch (GLException ex) { - } + catch (GLException ex) {} } - // Preparing area shape gl.glEnable(GL2.GL_DEPTH_TEST); gl.glCullFace(GL2.GL_FRONT); - gl.glLineWidth(3f); + gl.glLineWidth(4f); - // Make area shape switch(areaShape) { - case 0: // box - case 1: // box 2 - makeBox(info); - break; - case 2: // sphere - makeSphere(info); - break; - case 3: // cylinder - makeCylinder(info); - break; + case CUBE: makeBox(info, 500f); break; + case CENTEREDCUBE: makeBox(info, 0f); break; + case SPHERE: makeSphere(info); break; + case CYLINDER: makeCylinder(info); break; + case CONE: makeCone(info); break; } - // Reset line width gl.glLineWidth(1.5f); } - public void makeBox(GLRenderer.RenderInfo info) { + public void makeBox(GLRenderer.RenderInfo info, float ytrans) { GL2 gl = info.drawable.getGL().getGL2(); - gl.glTranslatef(0f, 500f, 0f); + gl.glTranslatef(0f, ytrans, 0f); gl.glBegin(GL2.GL_LINE_STRIP); - gl.glVertex3f(s, s, s); - gl.glVertex3f(-s, s, s); - gl.glVertex3f(-s, s, -s); - gl.glVertex3f(s, s, -s); - gl.glVertex3f(s, s, s); - gl.glVertex3f(s, -s, s); - gl.glVertex3f(-s, -s, s); - gl.glVertex3f(-s, -s, -s); - gl.glVertex3f(s, -s, -s); - gl.glVertex3f(s, -s, s); + gl.glVertex3f(SIZE, SIZE, SIZE); + gl.glVertex3f(-SIZE, SIZE, SIZE); + gl.glVertex3f(-SIZE, SIZE, -SIZE); + gl.glVertex3f(SIZE, SIZE, -SIZE); + gl.glVertex3f(SIZE, SIZE, SIZE); + gl.glVertex3f(SIZE, -SIZE, SIZE); + gl.glVertex3f(-SIZE, -SIZE, SIZE); + gl.glVertex3f(-SIZE, -SIZE, -SIZE); + gl.glVertex3f(SIZE, -SIZE, -SIZE); + gl.glVertex3f(SIZE, -SIZE, SIZE); gl.glEnd(); gl.glBegin(GL2.GL_LINES); - gl.glVertex3f(-s, s, s); - gl.glVertex3f(-s, -s, s); - gl.glVertex3f(-s, s, -s); - gl.glVertex3f(-s, -s, -s); - gl.glVertex3f(s, s, -s); - gl.glVertex3f(s, -s, -s); + gl.glVertex3f(-SIZE, SIZE, SIZE); + gl.glVertex3f(-SIZE, -SIZE, SIZE); + gl.glVertex3f(-SIZE, SIZE, -SIZE); + gl.glVertex3f(-SIZE, -SIZE, -SIZE); + gl.glVertex3f(SIZE, SIZE, -SIZE); + gl.glVertex3f(SIZE, -SIZE, -SIZE); gl.glEnd(); gl.glTranslatef(0f, 0f, 0f); } public void makeSphere(GLRenderer.RenderInfo info) { GL2 gl = info.drawable.getGL().getGL2(); + GLU glu = new GLU(); + GLUquadric sphere = glu.gluNewQuadric(); gl.glTranslatef(0f, 0f, 0f); - gl.glRotatef(0f,0f,0f,1f); - gl.glRotatef(0f,0f,1f,0f); - gl.glRotatef(90f,1f,0f,0f); + gl.glRotatef(90f, 1f, 0f, 0f); glu.gluQuadricDrawStyle(sphere, GLU.GLU_LINE); - glu.gluQuadricNormals(sphere, GLU.GLU_FLAT); - glu.gluQuadricOrientation(sphere, GLU.GLU_OUTSIDE); - glu.gluSphere(sphere, s, 24, 8); + glu.gluSphere(sphere, SIZE, 28, 8); glu.gluDeleteQuadric(sphere); gl.glTranslatef(0f, 0f, 0f); } public void makeCylinder(GLRenderer.RenderInfo info) { GL2 gl = info.drawable.getGL().getGL2(); + GLU glu = new GLU(); + GLUquadric cylinder = glu.gluNewQuadric(); gl.glTranslatef(0f, 1000f, 0f); - gl.glRotatef(0f,0f,0f,1f); - gl.glRotatef(0f,0f,1f,0f); - gl.glRotatef(90f,1f,0f,0f); + gl.glRotatef(90f, 1f, 0f, 0f); glu.gluQuadricDrawStyle(cylinder, GLU.GLU_LINE); - glu.gluQuadricNormals(cylinder, GLU.GLU_FLAT); - glu.gluQuadricOrientation(cylinder, GLU.GLU_OUTSIDE); - glu.gluCylinder(cylinder,s,s,s*2,24,1); + glu.gluCylinder(cylinder, SIZE, SIZE, SIZE * 2, 28, 1); glu.gluDeleteQuadric(cylinder); gl.glTranslatef(0f, 0f, 0f); } - - private Color4 areaColor; - private short areaShape = 0; - private float s = 500f; - private GLU glu = new GLU(); - private GLUquadric sphere = glu.gluNewQuadric(); - private GLUquadric cylinder = glu.gluNewQuadric(); + + public void makeCone(GLRenderer.RenderInfo info) { + GL2 gl = info.drawable.getGL().getGL2(); + GLU glu = new GLU(); + GLUquadric cylinder = glu.gluNewQuadric(); + + gl.glTranslatef(0f, 1000f, 0f); + gl.glRotatef(90f, 1f, 0f, 0f); + glu.gluQuadricDrawStyle(cylinder, GLU.GLU_LINE); + glu.gluCylinder(cylinder, 0, SIZE, SIZE * 2, 28, 1); + glu.gluDeleteQuadric(cylinder); + gl.glTranslatef(0f, 0f, 0f); + } + + private static final float SIZE = 500f; + private final Shape areaShape; + private final Color4 areaColor; + + public static enum Shape { + UNDEFINED, + CUBE, + CENTEREDCUBE, + SPHERE, + CYLINDER, + BOWL, + CONE; + } } \ No newline at end of file diff --git a/src/whitehole/rendering/object/ObjectAstroPart.java b/src/com/aurum/whitehole/rendering/object/AstroRenderer.java similarity index 66% rename from src/whitehole/rendering/object/ObjectAstroPart.java rename to src/com/aurum/whitehole/rendering/object/AstroRenderer.java index 068ccf0..f79772b 100644 --- a/src/whitehole/rendering/object/ObjectAstroPart.java +++ b/src/com/aurum/whitehole/rendering/object/AstroRenderer.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,24 +13,21 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.rendering.object; +package com.aurum.whitehole.rendering.object; -import whitehole.rendering.BmdRenderer; +import com.aurum.whitehole.rendering.BmdRenderer; -public class ObjectAstroPart extends BmdRenderer -{ - public ObjectAstroPart(RenderInfo info, String objname, int arg0) - { +public class AstroRenderer extends BmdRenderer { + public AstroRenderer(RenderInfo info, String objname, int arg0) { String[] parts = {"Observatory", "Well", "Kitchen", "BedRoom", "Machine", "Tower"}; - if (arg0 < 1 || arg0 > 6) arg0 = 1; + if (arg0 < 1 || arg0 > 6) + arg0 = 1; ctor_loadModel(info, objname + parts[arg0 - 1]); ctor_uploadData(info); } @Override - public boolean boundToObjArg(int arg) - { - if (arg == 0) return true; - return false; + public boolean boundToObjArg(int arg) { + return arg == 0; } -} +} \ No newline at end of file diff --git a/src/whitehole/rendering/object/ObjectAstroSky.java b/src/com/aurum/whitehole/rendering/object/AstroSkyRenderer.java similarity index 65% rename from src/whitehole/rendering/object/ObjectAstroSky.java rename to src/com/aurum/whitehole/rendering/object/AstroSkyRenderer.java index 333bbd2..d47d336 100644 --- a/src/whitehole/rendering/object/ObjectAstroSky.java +++ b/src/com/aurum/whitehole/rendering/object/AstroSkyRenderer.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,24 +13,21 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.rendering.object; +package com.aurum.whitehole.rendering.object; -import whitehole.rendering.BmdRenderer; +import com.aurum.whitehole.rendering.BmdRenderer; -public class ObjectAstroSky extends BmdRenderer -{ - public ObjectAstroSky(RenderInfo info, String objname, int arg0) - { +public class AstroSkyRenderer extends BmdRenderer { + public AstroSkyRenderer(RenderInfo info, String objname, int arg0) { String[] parts = {"A", "B", "C", "A", "B", "C"}; - if (arg0 < 1 || arg0 > 6) arg0 = 1; + if (arg0 < 1 || arg0 > 6) + arg0 = 1; ctor_loadModel(info, objname + parts[arg0 - 1]); ctor_uploadData(info); } @Override - public boolean boundToObjArg(int arg) - { - if (arg == 0) return true; - return false; + public boolean boundToObjArg(int arg) { + return arg == 0; } -} +} \ No newline at end of file diff --git a/src/com/aurum/whitehole/rendering/object/BlackHoleRenderer.java b/src/com/aurum/whitehole/rendering/object/BlackHoleRenderer.java new file mode 100644 index 0000000..e1206ab --- /dev/null +++ b/src/com/aurum/whitehole/rendering/object/BlackHoleRenderer.java @@ -0,0 +1,73 @@ +/* + © 2012 - 2017 - Whitehole Team + + Whitehole is free software: you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + Whitehole is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with Whitehole. If not, see http://www.gnu.org/licenses/. +*/ + +package com.aurum.whitehole.rendering.object; + +import com.aurum.whitehole.rendering.object.AreaRenderer.Shape; +import com.aurum.whitehole.rendering.BmdRenderer; +import com.aurum.whitehole.rendering.GLRenderer; +import com.aurum.whitehole.rendering.GLRenderer.RenderInfo; +import com.aurum.whitehole.vectors.Color4; +import com.aurum.whitehole.vectors.Vector3; +import javax.media.opengl.GL2; + +public class BlackHoleRenderer extends GLRenderer { + public BlackHoleRenderer(RenderInfo info, int arg0, Vector3 areascale, Shape shape) { + sclBlackHole = (arg0 < 0 ? 1000 : arg0) / 1000f; + sclArea = areascale; + renderBlackHole = new BmdRenderer(info, "BlackHole"); + renderAreaShape = new AreaRenderer(new Color4(1f, 0.7f, 0f) , shape); + } + + @Override + public boolean gottaRender(RenderInfo info) { + return renderBlackHole.gottaRender(info) || renderAreaShape.gottaRender(info); + } + + @Override + public void render(RenderInfo info) { + GL2 gl = info.drawable.getGL().getGL2(); + + gl.glPushMatrix(); + gl.glScalef(sclBlackHole, sclBlackHole, sclBlackHole); + renderBlackHole.render(info); + gl.glPopMatrix(); + + gl.glPushMatrix(); + gl.glScalef(sclArea.x, sclArea.y, sclArea.z); + renderAreaShape.render(info); + gl.glPopMatrix(); + } + + @Override + public boolean isScaled() { + return false; + } + + @Override + public boolean hasSpecialScaling() { + return true; + } + + @Override + public boolean boundToObjArg(int arg) { + return arg == 0; + } + + public BmdRenderer renderBlackHole; + public AreaRenderer renderAreaShape; + public Vector3 sclArea; + public float sclBlackHole; +} \ No newline at end of file diff --git a/src/com/aurum/whitehole/rendering/object/GravityRenderer.java b/src/com/aurum/whitehole/rendering/object/GravityRenderer.java new file mode 100644 index 0000000..0a1e0bc --- /dev/null +++ b/src/com/aurum/whitehole/rendering/object/GravityRenderer.java @@ -0,0 +1,73 @@ +/* + © 2012 - 2017 - Whitehole Team + + Whitehole is free software: you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + Whitehole is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with Whitehole. If not, see http://www.gnu.org/licenses/. +*/ + +package com.aurum.whitehole.rendering.object; + +import com.aurum.whitehole.rendering.GLRenderer; +import com.aurum.whitehole.rendering.GLRenderer.RenderInfo; +import com.aurum.whitehole.rendering.object.AreaRenderer.Shape; +import com.aurum.whitehole.vectors.Color4; +import com.aurum.whitehole.vectors.Vector3; +import javax.media.opengl.GL2; + +public class GravityRenderer extends GLRenderer { + public GravityRenderer(Vector3 scl, float rng, Shape shape) { + scale = scl; + range = (rng < 0 ? 1000 : rng) / 1000f; + + inner = new AreaRenderer(new Color4(0f, 0.8f, 0f), shape); + outer = new AreaRenderer(new Color4(0f, 0.4f, 0f), shape); + } + + @Override + public boolean gottaRender(RenderInfo info) { + return inner.gottaRender(info) || outer.gottaRender(info); + } + + @Override + public void render(RenderInfo info) { + GL2 gl = info.drawable.getGL().getGL2(); + + gl.glPushMatrix(); + gl.glScalef(scale.x, scale.y, scale.z); + inner.render(info); + gl.glPopMatrix(); + + gl.glPushMatrix(); + gl.glScalef(range, shape == Shape.SPHERE ? scale.y : range, range); + outer.render(info); + gl.glPopMatrix(); + } + + @Override + public boolean isScaled() { + return false; + } + + @Override + public boolean hasSpecialScaling() { + return true; + } + + @Override + public boolean boundToProperty() { + return true; + } + + public AreaRenderer inner, outer; + public Vector3 scale; + public Shape shape; + public float range; +} \ No newline at end of file diff --git a/src/com/aurum/whitehole/rendering/object/ItemBubbleRenderer.java b/src/com/aurum/whitehole/rendering/object/ItemBubbleRenderer.java new file mode 100644 index 0000000..97ddeee --- /dev/null +++ b/src/com/aurum/whitehole/rendering/object/ItemBubbleRenderer.java @@ -0,0 +1,39 @@ +/* + © 2012 - 2017 - Whitehole Team + + Whitehole is free software: you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + Whitehole is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with Whitehole. If not, see http://www.gnu.org/licenses/. +*/ + +package com.aurum.whitehole.rendering.object; + +import com.aurum.whitehole.rendering.BmdRendererSingle; +import com.aurum.whitehole.rendering.GLRenderer; +import com.aurum.whitehole.rendering.GLRenderer.RenderInfo; +import com.aurum.whitehole.rendering.MultiRenderer; +import com.aurum.whitehole.vectors.Vector3; +import java.io.IOException; + +public class ItemBubbleRenderer extends MultiRenderer { + public ItemBubbleRenderer(RenderInfo info, String modelname, int arg7) throws IOException { + boolean argIsUnique = arg7 != -1; + renderers = new GLRenderer[argIsUnique ? 2 : 1]; + + renderers[0] = new BmdRendererSingle(info, modelname); + if (argIsUnique) + renderers[1] = new BmdRendererSingle(info, "ItemBubble", new Vector3(0f,60f,0f), new Vector3()); + } + + @Override + public boolean boundToObjArg(int arg) { + return arg == 7; + } +} \ No newline at end of file diff --git a/src/whitehole/rendering/object/ObjectKinopio.java b/src/com/aurum/whitehole/rendering/object/KinopioRenderer.java similarity index 74% rename from src/whitehole/rendering/object/ObjectKinopio.java rename to src/com/aurum/whitehole/rendering/object/KinopioRenderer.java index 414c982..e34e3de 100644 --- a/src/whitehole/rendering/object/ObjectKinopio.java +++ b/src/com/aurum/whitehole/rendering/object/KinopioRenderer.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,20 +13,15 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.rendering.object; +package com.aurum.whitehole.rendering.object; -import whitehole.rendering.BmdRenderer; +import com.aurum.whitehole.rendering.BmdRenderer; -public class ObjectKinopio extends BmdRenderer -{ - public ObjectKinopio(RenderInfo info, int color) - { +public class KinopioRenderer extends BmdRenderer { + public KinopioRenderer(RenderInfo info, int color) { ctor_loadModel(info, "Kinopio"); - // mess with TEV parameters to recolor the Toad if needed (default color: red) - // this is a hack but knowing Nintendo I don't think the game does it much differently - switch (color) - { + switch (color) { case 0: // blue model.materials[0].colorS10[0].r = -103; model.materials[0].colorS10[0].g = -103; @@ -56,9 +51,7 @@ public ObjectKinopio(RenderInfo info, int color) } @Override - public boolean boundToObjArg(int arg) - { - if (arg == 1) return true; - return false; + public boolean boundToObjArg(int arg) { + return arg == 1; } -} +} \ No newline at end of file diff --git a/src/com/aurum/whitehole/rendering/object/OtaKingRenderer.java b/src/com/aurum/whitehole/rendering/object/OtaKingRenderer.java new file mode 100644 index 0000000..f756bca --- /dev/null +++ b/src/com/aurum/whitehole/rendering/object/OtaKingRenderer.java @@ -0,0 +1,34 @@ +/* + © 2012 - 2017 - Whitehole Team + + Whitehole is free software: you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + Whitehole is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with Whitehole. If not, see http://www.gnu.org/licenses/. +*/ + +package com.aurum.whitehole.rendering.object; + +import com.aurum.whitehole.rendering.BmdRendererSingle; +import com.aurum.whitehole.rendering.GLRenderer; +import com.aurum.whitehole.rendering.MultiRenderer; +import java.io.IOException; + +public class OtaKingRenderer extends MultiRenderer { + public OtaKingRenderer(RenderInfo info, String objname, int arg1) throws IOException { + renderers = new GLRenderer[2]; + renderers[0] = new BmdRendererSingle(info, arg1 != -1 ? "OtaKingLv2" : "OtaKing"); + renderers[1] = new BmdRendererSingle(info, "OtaKingMagma"); + } + + @Override + public boolean boundToObjArg(int arg) { + return arg == 1; + } +} \ No newline at end of file diff --git a/src/whitehole/rendering/PlanetRenderer.java b/src/com/aurum/whitehole/rendering/object/PlanetRenderer.java similarity index 54% rename from src/whitehole/rendering/PlanetRenderer.java rename to src/com/aurum/whitehole/rendering/object/PlanetRenderer.java index c3f29e2..d186f10 100644 --- a/src/whitehole/rendering/PlanetRenderer.java +++ b/src/com/aurum/whitehole/rendering/object/PlanetRenderer.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,51 +13,37 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.rendering; +package com.aurum.whitehole.rendering.object; -import javax.media.opengl.GLException; +import com.aurum.whitehole.rendering.BmdRenderer; +import com.aurum.whitehole.rendering.GLRenderer; +import javax.media.opengl.*; -public class PlanetRenderer extends GLRenderer -{ - public PlanetRenderer(RenderInfo info, String planet) throws GLException - { +public class PlanetRenderer extends GLRenderer { + public PlanetRenderer(RenderInfo info, String planet) throws GLException { rendMain = new BmdRenderer(info, planet); - - try { rendWater = new BmdRenderer(info, planet + "Water"); } - catch (GLException ex) { - rendWater = null; - } + rendWater = new BmdRenderer(info, planet + "Water"); } @Override - public void close(RenderInfo info) throws GLException - { + public void close(RenderInfo info) throws GLException { rendMain.close(info); - if (rendWater != null) rendWater.close(info); + rendWater.close(info); } - @Override - public boolean gottaRender(RenderInfo info) throws GLException - { - boolean render = rendMain.gottaRender(info); - - if (rendWater != null) - render = render || rendWater.gottaRender(info); - - return render; + public boolean gottaRender(RenderInfo info) throws GLException { + return rendMain.gottaRender(info) || rendWater.gottaRender(info); } @Override - public void render(RenderInfo info) throws GLException - { + public void render(RenderInfo info) throws GLException { if (rendMain.gottaRender(info)) rendMain.render(info); - if (rendWater != null && rendWater.gottaRender(info)) + if (rendWater.gottaRender(info)) rendWater.render(info); } - - private BmdRenderer rendMain, rendWater; -} + private final BmdRenderer rendMain, rendWater; +} \ No newline at end of file diff --git a/src/whitehole/rendering/object/ObjectPole.java b/src/com/aurum/whitehole/rendering/object/PoleRenderer.java similarity index 62% rename from src/whitehole/rendering/object/ObjectPole.java rename to src/com/aurum/whitehole/rendering/object/PoleRenderer.java index b613b02..183adf5 100644 --- a/src/whitehole/rendering/object/ObjectPole.java +++ b/src/com/aurum/whitehole/rendering/object/PoleRenderer.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,43 +13,36 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.rendering.object; +package com.aurum.whitehole.rendering.object; import java.io.IOException; +import com.aurum.whitehole.rendering.BmdRenderer; +import com.aurum.whitehole.vectors.Vector3; import javax.media.opengl.*; -import whitehole.rendering.BmdRenderer; -import whitehole.vectors.Vector3; -public class ObjectPole extends BmdRenderer -{ - public ObjectPole(RenderInfo info, Vector3 scale, String type) throws IOException - { +public class PoleRenderer extends BmdRenderer { + public PoleRenderer(RenderInfo info, Vector3 scale, String type) throws IOException { super(info, type); - myscale = scale; - + this.scale = scale; model.joints[1].finalMatrix.m[13] = 100f * scale.y / scale.x; } @Override - public boolean isScaled() - { + public boolean isScaled() { return false; } @Override - public boolean hasSpecialScaling() - { + public boolean hasSpecialScaling() { return true; } @Override - public void render(RenderInfo info) throws GLException - { + public void render(RenderInfo info) throws GLException { GL2 gl = info.drawable.getGL().getGL2(); - gl.glScalef(myscale.x, myscale.x, myscale.x); + gl.glScalef(scale.x, scale.x, scale.x); super.render(info); } - - private Vector3 myscale; -} + private final Vector3 scale; +} \ No newline at end of file diff --git a/src/whitehole/rendering/ShapeModelRenderer.java b/src/com/aurum/whitehole/rendering/object/ShapeRenderer.java similarity index 72% rename from src/whitehole/rendering/ShapeModelRenderer.java rename to src/com/aurum/whitehole/rendering/object/ShapeRenderer.java index 104309b..33de9c2 100644 --- a/src/whitehole/rendering/ShapeModelRenderer.java +++ b/src/com/aurum/whitehole/rendering/object/ShapeRenderer.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,11 +13,12 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.rendering; +package com.aurum.whitehole.rendering.object; -public class ShapeModelRenderer extends BmdRenderer { - - public ShapeModelRenderer(RenderInfo info, String objname, short modelno) { +import com.aurum.whitehole.rendering.BmdRenderer; + +public class ShapeRenderer extends BmdRenderer { + public ShapeRenderer(RenderInfo info, String objname, short modelno) { if (modelno < 100 && modelno > -1) { ctor_loadModel(info, objname + String.format("%1$02d",modelno)); ctor_uploadData(info); @@ -25,7 +26,7 @@ public ShapeModelRenderer(RenderInfo info, String objname, short modelno) { } @Override - public boolean boundToShapeModel() { + public boolean boundToProperty() { return true; } } \ No newline at end of file diff --git a/src/whitehole/rendering/object/ObjectUFOKinoko.java b/src/com/aurum/whitehole/rendering/object/UFOKinokoRenderer.java similarity index 86% rename from src/whitehole/rendering/object/ObjectUFOKinoko.java rename to src/com/aurum/whitehole/rendering/object/UFOKinokoRenderer.java index 310490c..5aee241 100644 --- a/src/whitehole/rendering/object/ObjectUFOKinoko.java +++ b/src/com/aurum/whitehole/rendering/object/UFOKinokoRenderer.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,20 +13,17 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.rendering.object; +package com.aurum.whitehole.rendering.object; -import whitehole.rendering.BmdRenderer; +import com.aurum.whitehole.rendering.BmdRenderer; -public class ObjectUFOKinoko extends BmdRenderer -{ - public ObjectUFOKinoko(RenderInfo info, int color) - { +public class UFOKinokoRenderer extends BmdRenderer { + public UFOKinokoRenderer(RenderInfo info, int color) { ctor_loadModel(info, "UFOKinoko"); // recolor the ship in the same fashion as we recolor Toads // except with different color values and material ID - switch (color) - { + switch (color) { case 1: // green model.materials[5].colorS10[0].r = 30; model.materials[5].colorS10[0].g = 220; @@ -68,9 +65,7 @@ public ObjectUFOKinoko(RenderInfo info, int color) } @Override - public boolean boundToObjArg(int arg) - { - if (arg == 0) return true; - return false; + public boolean boundToObjArg(int arg) { + return arg == 0; } -} +} \ No newline at end of file diff --git a/src/whitehole/smg/Bcsv.java b/src/com/aurum/whitehole/smg/Bcsv.java similarity index 75% rename from src/whitehole/smg/Bcsv.java rename to src/com/aurum/whitehole/smg/Bcsv.java index 8487de2..ac763af 100644 --- a/src/whitehole/smg/Bcsv.java +++ b/src/com/aurum/whitehole/smg/Bcsv.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,22 +13,17 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.smg; +package com.aurum.whitehole.smg; import java.io.BufferedReader; -import java.io.BufferedWriter; import java.io.File; import java.io.FileReader; -import java.io.FileWriter; import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; -import whitehole.Whitehole; -import whitehole.fileio.FileBase; +import com.aurum.whitehole.io.FileBase; public class Bcsv { @@ -285,8 +280,7 @@ public void removeField(String name) } - public static class Field - { + public static class Field { public int nameHash; public int mask; public short entryOffset; @@ -296,128 +290,75 @@ public static class Field public String name; } - public static class Entry extends LinkedHashMap - { - public Entry() - { super(); } - - public Object get(String key) - { + public static class Entry extends LinkedHashMap { + public Object get(String key) { return get(Bcsv.fieldNameToHash(key)); } - public void put(String key, Object val) - { + public Object getOrDefault(String key, Object val) { + return getOrDefault(Bcsv.fieldNameToHash(key), val); + } + + public void put(String key, Object val) { put(Bcsv.fieldNameToHash(key), val); } - public boolean containsKey(String key) - { + public boolean containsKey(String key) { return this.containsKey(Bcsv.fieldNameToHash(key)); } } private FileBase file; - public LinkedHashMap fields; public List entries; - - - // Field name hash support functions - // the hash->String table is meant for debugging purposes and - // shouldn't be used by proper code - - public static int fieldNameToHash(String field) - { + + public static int fieldNameToHash(String field) { int ret = 0; - for (char ch : field.toCharArray()) - { + for (char ch : field.toCharArray()) { ret *= 0x1F; ret += ch; } return ret; } - public static String hashToFieldName(int hash) - { - if (!hashTable.containsKey(hash)) + public static String hashToFieldName(int hash) { + if (!LOOKUP.containsKey(hash)) return String.format("[%1$08X]", hash); - return hashTable.get(hash); + return LOOKUP.get(hash); } - public static void addHash(String field) - { + public static void addHash(String field) { int hash = fieldNameToHash(field); - if (!hashTable.containsKey(hash)) - hashTable.put(hash, field); - } - - public static void createCustomHashFile() { - try { - File hashCustom = new File("AdditionalFieldNames.txt"); - hashCustom.createNewFile(); - FileWriter writeFile = new FileWriter(hashCustom.getAbsoluteFile()); - BufferedWriter writeLine = new BufferedWriter(writeFile); - writeLine.write("# Add new lines to create new field names\r\n"); - writeLine.write("# Lines that start with '#' are ignored.\r\n"); - writeLine.close(); - } - catch (Exception ex) { - } + if (!LOOKUP.containsKey(hash)) + LOOKUP.put(hash, field); } - public static void populateHashTable() - { - hashTable = new HashMap<>(); - + public static void populateHashTable() { try { - InputStream hash = Whitehole.class.getResourceAsStream("/Resources/Hash.txt"); - InputStream hashZone = Whitehole.class.getResourceAsStream("/Resources/ZoneHash.txt"); - - File hashCustom = new File("AdditionalFieldNames.txt"); - - if (!hashCustom.exists()) - createCustomHashFile(); - - BufferedReader reader = new BufferedReader(new InputStreamReader(hash)); - BufferedReader reader2 = new BufferedReader(new InputStreamReader(hashZone)); - BufferedReader reader3 = new BufferedReader(new FileReader(hashCustom)); - - String line; - while ((line = reader.readLine()) != null) { - line = line.trim(); - - if (line.length() == 0) continue; - if (line.charAt(0) == '#') continue; - - addHash(line); + if (!LOOKUPFILE.exists()) { + LOOKUPFILE.createNewFile(); + return; } - while ((line = reader2.readLine()) != null) { - line = line.trim(); - - if (line.length() == 0) continue; - if (line.charAt(0) == '#') continue; - - addHash(line); - } - - while ((line = reader3.readLine()) != null) { - line = line.trim(); - - if (line.length() == 0) continue; - if (line.charAt(0) == '#') continue; - - addHash(line); + try (BufferedReader br = new BufferedReader(new FileReader(LOOKUPFILE))) { + String line; + while ((line = br.readLine()) != null) { + line = line.trim(); + + if (line.length() == 0) + continue; + if (line.charAt(0) == '#') + continue; + + addHash(line); + } } - - hash.close(); - hashZone.close(); } catch (IOException ex) {} } - - public static HashMap hashTable; -} + + public static final File LOOKUPFILE = new File("hashlookup.txt"); + public static final HashMap LOOKUP = new HashMap(); +} \ No newline at end of file diff --git a/src/whitehole/smg/Bmd.java b/src/com/aurum/whitehole/smg/Bmd.java similarity index 99% rename from src/whitehole/smg/Bmd.java rename to src/com/aurum/whitehole/smg/Bmd.java index 7e2e29a..444c0ab 100644 --- a/src/whitehole/smg/Bmd.java +++ b/src/com/aurum/whitehole/smg/Bmd.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,13 +13,15 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.smg; +package com.aurum.whitehole.smg; +import com.aurum.whitehole.vectors.Matrix4; +import com.aurum.whitehole.vectors.Color4; +import com.aurum.whitehole.vectors.Vector3; +import com.aurum.whitehole.vectors.Vector2; +import com.aurum.whitehole.io.FileBase; import java.io.*; import java.util.*; -import whitehole.rendering.Helper; -import whitehole.fileio.*; -import whitehole.vectors.*; public class Bmd { @@ -441,7 +443,7 @@ private void readJNT1() throws IOException file.skip(2); jnt.translation = new Vector3(file.readFloat(), file.readFloat(), file.readFloat()); - jnt.matrix = Helper.SRTToMatrix(jnt.scale, jnt.rotation, jnt.translation); + jnt.matrix = Matrix4.SRTToMatrix(jnt.scale, jnt.rotation, jnt.translation); for (SceneGraphNode node : sceneGraph) { @@ -1097,7 +1099,7 @@ private void readTEX1() throws IOException file.skip(3); int dataoffset = file.readInt(); - tex.image = DataHelper.decodeTextureData(file, sectionstart + dataoffset + 0x20 + (0x20 * i), + tex.image = ImageUtils.decodeTextureData(file, sectionstart + dataoffset + 0x20 + (0x20 * i), tex.mipmapCount, tex.format, tex.width, tex.height); /*try diff --git a/src/com/aurum/whitehole/smg/Bti.java b/src/com/aurum/whitehole/smg/Bti.java new file mode 100644 index 0000000..5a63f01 --- /dev/null +++ b/src/com/aurum/whitehole/smg/Bti.java @@ -0,0 +1,67 @@ +/* + © 2012 - 2017 - Whitehole Team + + Whitehole is free software: you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + Whitehole is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with Whitehole. If not, see http://www.gnu.org/licenses/. +*/ + +package com.aurum.whitehole.smg; + +import java.io.IOException; +import com.aurum.whitehole.io.FileBase; + +public class Bti { + public Bti(FileBase f) throws IOException { + file = f; + file.setBigEndian(true); + + format = file.readByte(); + file.skip(0x1); + width = file.readShort(); + height = file.readShort(); + wrapS = file.readByte(); + wrapT = file.readByte(); + file.skip(0x1); + paletteFormat = file.readByte(); + paletteCount = file.readShort(); + paletteOffset = file.readInt(); + useMipmap = file.readByte() != 0x0; + file.skip(0x3); + minFilter = file.readByte(); + magFilter = file.readByte(); + minLod = file.readByte() * 0.125F; + maxLod = file.readByte() * 0.125F; + mipmapCount = file.readByte(); + file.skip(0x1); + lodBias = file.readShort() * 0.01F; + imageOffset = file.readInt(); + + image = ImageUtils.decodeTextureData(file, imageOffset, mipmapCount, format, width, height); + } + + public void save() throws IOException { + file.save(); + } + + public void close() throws IOException { + file.close(); + } + + private final FileBase file; + + public int paletteOffset, imageOffset; + public float minLod, maxLod, lodBias; + public boolean useMipmap; + public short width, height, paletteCount; + public byte format, paletteFormat, mipmapCount; + public byte wrapS, wrapT, minFilter, magFilter; + public byte[][] image; +} \ No newline at end of file diff --git a/src/com/aurum/whitehole/smg/Bva.java b/src/com/aurum/whitehole/smg/Bva.java new file mode 100644 index 0000000..1bf8039 --- /dev/null +++ b/src/com/aurum/whitehole/smg/Bva.java @@ -0,0 +1,62 @@ +/* + © 2012 - 2017 - Whitehole Team + + Whitehole is free software: you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + Whitehole is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with Whitehole. If not, see http://www.gnu.org/licenses/. +*/ + +package com.aurum.whitehole.smg; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import com.aurum.whitehole.io.FileBase; + +public class Bva { + public Bva(FileBase file) throws IOException { + this.file = file; + this.file.setBigEndian(true); + + file.position(0x2C); + short batchCount = file.readShort(); + file.skip(0x2); + + int offset1 = 0x20 + file.readInt(); + int offset2 = 0x20 + file.readInt(); + + animData = new ArrayList(batchCount); + + for (int b = 0; b < batchCount; b++) { + file.position(offset1 + (b * 4)); + short batchSize = file.readShort(); + short batchStart = file.readShort(); + + List list = new ArrayList(batchSize); + animData.add(list); + + file.position(offset2 + batchStart); + for (int i = 0; i < batchSize; i++) { + list.add(file.readByte() != 0x0); + } + } + } + + public void save() throws IOException { + file.save(); + } + + public void close() throws IOException { + file.close(); + } + + private final FileBase file; + public List> animData; +} \ No newline at end of file diff --git a/src/whitehole/smg/GalaxyArchive.java b/src/com/aurum/whitehole/smg/GalaxyArchive.java similarity index 80% rename from src/whitehole/smg/GalaxyArchive.java rename to src/com/aurum/whitehole/smg/GalaxyArchive.java index b6d492d..c1b5768 100644 --- a/src/whitehole/smg/GalaxyArchive.java +++ b/src/com/aurum/whitehole/smg/GalaxyArchive.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,54 +13,46 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.smg; +package com.aurum.whitehole.smg; +import com.aurum.whitehole.io.RarcFilesystem; +import com.aurum.whitehole.io.FilesystemBase; import java.util.*; import java.io.*; -import whitehole.fileio.*; -public class GalaxyArchive -{ - public GalaxyArchive(GameArchive arc, String name) throws IOException - { +public class GalaxyArchive { + public GalaxyArchive(GameArchive arc, String name) throws IOException { game = arc; filesystem = arc.filesystem; - galaxyName = name; - - zoneList = new ArrayList<>(); + zoneList = new ArrayList(); RarcFilesystem scenario = new RarcFilesystem(filesystem.openFile("/StageData/"+galaxyName+"/"+galaxyName+"Scenario.arc")); Bcsv zonesbcsv = new Bcsv(scenario.openFile(String.format("/%1$sScenario/ZoneList.bcsv", galaxyName))); - for (Bcsv.Entry entry : zonesbcsv.entries) - { + for (Bcsv.Entry entry : zonesbcsv.entries) { zoneList.add((String)entry.get("ZoneName")); } zonesbcsv.close(); Bcsv scenariobcsv = new Bcsv(scenario.openFile(String.format("/%1$sScenario/ScenarioData.bcsv", galaxyName))); scenarioData = scenariobcsv.entries; - scenariobcsv.close(); + scenariobcsv.close(); scenario.close(); } - public void close() - { - } + public void close() {} - public ZoneArchive openZone(String name) throws IOException - { + public ZoneArchive openZone(String name) throws IOException { if (!zoneList.contains(name)) return null; return new ZoneArchive(this, name); } - public GameArchive game; public FilesystemBase filesystem; public String galaxyName; public List zoneList; public List scenarioData; -} +} \ No newline at end of file diff --git a/src/whitehole/smg/GameArchive.java b/src/com/aurum/whitehole/smg/GameArchive.java similarity index 83% rename from src/whitehole/smg/GameArchive.java rename to src/com/aurum/whitehole/smg/GameArchive.java index c7afc44..05e5f3d 100644 --- a/src/whitehole/smg/GameArchive.java +++ b/src/com/aurum/whitehole/smg/GameArchive.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,15 +13,14 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.smg; +package com.aurum.whitehole.smg; import java.io.IOException; import java.util.*; -import whitehole.Whitehole; -import whitehole.fileio.FilesystemBase; +import com.aurum.whitehole.Whitehole; +import com.aurum.whitehole.io.FilesystemBase; -public class GameArchive -{ +public class GameArchive { public GameArchive(FilesystemBase fs) { filesystem = fs; } @@ -43,7 +42,8 @@ public boolean galaxyExists(String name) { } public GalaxyArchive openGalaxy(String name) throws IOException { - if (!galaxyExists(name)) return null; + if (!galaxyExists(name)) + return null; return new GalaxyArchive(this, name); } @@ -56,10 +56,10 @@ public void close() { } public List getGalaxies() { - List ret = new ArrayList<>(); + List ret = new ArrayList(); List stages = filesystem.getDirectories("/StageData"); - for (String stage : stages) - { + for (String stage : stages) { + Bcsv.addHash(stage); if (!galaxyExists(stage)) continue; diff --git a/src/whitehole/smg/DataHelper.java b/src/com/aurum/whitehole/smg/ImageUtils.java similarity index 79% rename from src/whitehole/smg/DataHelper.java rename to src/com/aurum/whitehole/smg/ImageUtils.java index b2387d3..08ba6a6 100644 --- a/src/whitehole/smg/DataHelper.java +++ b/src/com/aurum/whitehole/smg/ImageUtils.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,36 +13,62 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.smg; +package com.aurum.whitehole.smg; import java.io.IOException; -import whitehole.fileio.FileBase; +import com.aurum.whitehole.io.FileBase; +import static javax.media.opengl.GL2.*; + +public class ImageUtils { + public enum WrapMode { + CLAMP (GL_CLAMP_TO_EDGE), + REPEAT (GL_REPEAT), + MIRROR (GL_MIRRORED_REPEAT); + + private final int value; + private WrapMode(int val) { + this.value = val; + } -public class DataHelper -{ - public static byte[][] decodeTextureData(FileBase file, long offset, int mipmaps, int format, int width, int height) throws IOException - { + public int get() { + return value; + } + } + + public static enum FilterMode { + NEAR (GL_NEAREST), + LINEAR (GL_LINEAR), + NEAR_MIP_NEAR (GL_NEAREST_MIPMAP_NEAREST), + LIN_MIP_NEAR (GL_LINEAR_MIPMAP_NEAREST), + NEAR_MIP_LIN (GL_NEAREST_MIPMAP_LINEAR), + LIN_MIP_LIN (GL_LINEAR_MIPMAP_LINEAR); + + private final int value; + private FilterMode(int val) { + this.value = val; + } + + public int get() { + return value; + } + } + + public static byte[][] decodeTextureData(FileBase file, long offset, int mipmaps, int format, int width, int height) throws IOException { byte[][] ret = new byte[mipmaps][]; file.position(offset); - for (int mip = 0; mip < mipmaps; mip++) - { - byte[] image = null; + for (int mip = 0; mip < mipmaps; mip++) { + byte[] image; - switch (format) - { + switch (format) { case 0: // I4 { image = new byte[width * height]; - for (int by = 0; by < height; by += 8) - { - for (int bx = 0; bx < width; bx += 8) - { - for (int y = 0; y < 8; y++) - { - for (int x = 0; x < 8; x += 2) - { + for (int by = 0; by < height; by += 8) { + for (int bx = 0; bx < width; bx += 8) { + for (int y = 0; y < 8; y++) { + for (int x = 0; x < 8; x += 2) { int b = file.readByte() & 0xFF; int outp = (((by + y) * width) + (bx + x)); @@ -78,18 +104,14 @@ public static byte[][] decodeTextureData(FileBase file, long offset, int mipmaps } break; - case 2: // I4A4 + case 2: // IA4 { image = new byte[width * height * 2]; - for (int by = 0; by < height; by += 4) - { - for (int bx = 0; bx < width; bx += 8) - { - for (int y = 0; y < 4; y++) - { - for (int x = 0; x < 8; x++) - { + for (int by = 0; by < height; by += 4) { + for (int bx = 0; bx < width; bx += 8) { + for (int y = 0; y < 4; y++) { + for (int x = 0; x < 8; x++) { int b = file.readByte() & 0xFF; int outp = (((by + y) * width) + (bx + x)) * 2; @@ -102,18 +124,14 @@ public static byte[][] decodeTextureData(FileBase file, long offset, int mipmaps } break; - case 3: // I8A8 + case 3: // IA8 { image = new byte[width * height * 2]; - for (int by = 0; by < height; by += 4) - { - for (int bx = 0; bx < width; bx += 4) - { - for (int y = 0; y < 4; y++) - { - for (int x = 0; x < 4; x++) - { + for (int by = 0; by < height; by += 4) { + for (int bx = 0; bx < width; bx += 4) { + for (int y = 0; y < 4; y++) { + for (int x = 0; x < 4; x++) { byte a = file.readByte(); byte l = file.readByte(); @@ -131,14 +149,10 @@ public static byte[][] decodeTextureData(FileBase file, long offset, int mipmaps { image = new byte[width * height * 4]; - for (int by = 0; by < height; by += 4) - { - for (int bx = 0; bx < width; bx += 4) - { - for (int y = 0; y < 4; y++) - { - for (int x = 0; x < 4; x++) - { + for (int by = 0; by < height; by += 4) { + for (int bx = 0; bx < width; bx += 4) { + for (int y = 0; y < 4; y++) { + for (int x = 0; x < 4; x++) { int col = file.readShort() & 0xFFFF; int outp = (((by + y) * width) + (bx + x)) * 4; @@ -157,26 +171,20 @@ public static byte[][] decodeTextureData(FileBase file, long offset, int mipmaps { image = new byte[width * height * 4]; - for (int by = 0; by < height; by += 4) - { - for (int bx = 0; bx < width; bx += 4) - { - for (int y = 0; y < 4; y++) - { - for (int x = 0; x < 4; x++) - { + for (int by = 0; by < height; by += 4) { + for (int bx = 0; bx < width; bx += 4) { + for (int y = 0; y < 4; y++) { + for (int x = 0; x < 4; x++) { int col = file.readShort() & 0xFFFF; int outp = (((by + y) * width) + (bx + x)) * 4; - if ((col & 0x8000) != 0) - { + if ((col & 0x8000) != 0) { image[outp++] = (byte)(((col & 0x001F) << 3) | ((col & 0x001F) >>> 2)); image[outp++] = (byte)(((col & 0x03E0) >>> 3) | ((col & 0x03E0) >>> 8)); image[outp++] = (byte)(((col & 0x7C00) >>> 7) | ((col & 0x7C00) >>> 12)); image[outp ] = (byte)255; } - else - { + else { image[outp++] = (byte)(((col & 0x000F) << 4) | (col & 0x000F)); image[outp++] = (byte)((col & 0x00F0) | ((col & 0x00F0) >>> 4)); image[outp++] = (byte)(((col & 0x0F00) >>> 4) | ((col & 0x0F00) >>> 8)); @@ -189,18 +197,14 @@ public static byte[][] decodeTextureData(FileBase file, long offset, int mipmaps } break; - case 6: // RGBA8 + case 6: // RGBA32 { image = new byte[width * height * 4]; - for (int by = 0; by < height; by += 4) - { - for (int bx = 0; bx < width; bx += 4) - { - for (int y = 0; y < 4; y++) - { - for (int x = 0; x < 4; x++) - { + for (int by = 0; by < height; by += 4) { + for (int bx = 0; bx < width; bx += 4) { + for (int y = 0; y < 4; y++) { + for (int x = 0; x < 4; x++) { byte a = file.readByte(); byte r = file.readByte(); @@ -209,10 +213,8 @@ public static byte[][] decodeTextureData(FileBase file, long offset, int mipmaps image[outp+2] = r; } } - for (int y = 0; y < 4; y++) - { - for (int x = 0; x < 4; x++) - { + for (int y = 0; y < 4; y++) { + for (int x = 0; x < 4; x++) { byte g = file.readByte(); byte b = file.readByte(); @@ -226,18 +228,14 @@ public static byte[][] decodeTextureData(FileBase file, long offset, int mipmaps } break; - case 14: // DXT1 + case 14: // CMPR { image = new byte[width * height * 4]; - for (int by = 0; by < height; by += 8) - { - for (int bx = 0; bx < width; bx += 8) - { - for (int sby = 0; sby < 8; sby += 4) - { - for (int sbx = 0; sbx < 8; sbx += 4) - { + for (int by = 0; by < height; by += 8) { + for (int bx = 0; bx < width; bx += 8) { + for (int sby = 0; sby < 8; sby += 4) { + for (int sbx = 0; sbx < 8; sbx += 4) { int c1 = file.readShort() & 0xFFFF; int c2 = file.readShort() & 0xFFFF; int block = file.readInt(); @@ -252,8 +250,7 @@ public static byte[][] decodeTextureData(FileBase file, long offset, int mipmaps int[][] colors = new int[4][4]; colors[0][0] = 255; colors[0][1] = r1; colors[0][2] = g1; colors[0][3] = b1; colors[1][0] = 255; colors[1][1] = r2; colors[1][2] = g2; colors[1][3] = b2; - if (c1 > c2) - { + if (c1 > c2) { int r3 = ((r1 << 1) + r2) / 3; int g3 = ((g1 << 1) + g2) / 3; int b3 = ((b1 << 1) + b2) / 3; @@ -265,8 +262,7 @@ public static byte[][] decodeTextureData(FileBase file, long offset, int mipmaps colors[2][0] = 255; colors[2][1] = r3; colors[2][2] = g3; colors[2][3] = b3; colors[3][0] = 255; colors[3][1] = r4; colors[3][2] = g4; colors[3][3] = b4; } - else - { + else { colors[2][0] = 255; colors[2][1] = ((r1 + r2) / 2); colors[2][2] = ((g1 + g2) / 2); @@ -274,10 +270,8 @@ public static byte[][] decodeTextureData(FileBase file, long offset, int mipmaps colors[3][0] = 0; colors[3][1] = r2; colors[3][2] = g2; colors[3][3] = b2; } - for (int y = 0; y < 4; y++) - { - for (int x = 0; x < 4; x++) - { + for (int y = 0; y < 4; y++) { + for (int x = 0; x < 4; x++) { int c = block >>> 30; int outp = (((by + sby + y) * width) + (bx + sbx + x)) * 4; image[outp++] = (byte)(colors[c][3] | (colors[c][3] >>> 5)); @@ -299,8 +293,7 @@ public static byte[][] decodeTextureData(FileBase file, long offset, int mipmaps System.out.println(String.format("Unsupported texture type %1$d, generating solid color texture instead", format)); image = new byte[width * height * 4]; - for (int i = 0; i < width * height; i++) - { + for (int i = 0; i < width * height; i++) { int outp = i * 4; image[outp++] = (byte)255; image[outp++] = (byte)0; @@ -317,4 +310,4 @@ public static byte[][] decodeTextureData(FileBase file, long offset, int mipmaps return ret; } -} +} \ No newline at end of file diff --git a/src/whitehole/smg/ZoneArchive.java b/src/com/aurum/whitehole/smg/ZoneArchive.java similarity index 69% rename from src/whitehole/smg/ZoneArchive.java rename to src/com/aurum/whitehole/smg/ZoneArchive.java index 4097089..a87dde3 100644 --- a/src/whitehole/smg/ZoneArchive.java +++ b/src/com/aurum/whitehole/smg/ZoneArchive.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,49 +13,37 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.smg; +package com.aurum.whitehole.smg; -import whitehole.smg.object.PlanetObj; -import whitehole.smg.object.GeneralObject; -import whitehole.smg.object.MapPartObj; -import whitehole.smg.object.CameraCubeObj; -import whitehole.smg.object.DebugObj; -import whitehole.smg.object.AreaObj; -import whitehole.smg.object.PathObject; -import whitehole.smg.object.ChangeObj; -import whitehole.smg.object.GeneralPosObj; -import whitehole.smg.object.DemoObj; -import whitehole.smg.object.SoundObj; -import whitehole.smg.object.StartObj; -import whitehole.smg.object.ChildObj; -import whitehole.smg.object.StageObj; +import com.aurum.whitehole.smg.object.AbstractObj; +import com.aurum.whitehole.io.RarcFilesystem; +import com.aurum.whitehole.io.FilesystemBase; import java.io.*; import java.util.*; import javax.swing.JOptionPane; -import whitehole.Whitehole; -import whitehole.fileio.*; +import com.aurum.whitehole.Whitehole; +import com.aurum.whitehole.smg.object.*; public class ZoneArchive { public ZoneArchive(GalaxyArchive arc, String name) throws IOException { galaxy = arc; - game = arc.game; - filesystem = game.filesystem; + gameArc = arc.game; + filesystem = gameArc.filesystem; zoneName = name; if (filesystem.fileExists("/StageData/" + zoneName + "/" + zoneName + "Map.arc")) { - gameMask = 2; - zonefile = "/StageData/" + zoneName + "/" + zoneName + "Map.arc"; + game = 2; + zoneFile = "/StageData/" + zoneName + "/" + zoneName + "Map.arc"; } else { - gameMask = 1; - zonefile = "/StageData/" + zoneName + ".arc"; + game = 1; + zoneFile = "/StageData/" + zoneName + ".arc"; } loadZone(); } public void save() throws IOException { - saveObjects("Placement", "StageObjInfo"); saveObjects("MapParts", "MapPartsInfo"); saveObjects("Placement", "ObjInfo"); saveObjects("Start", "StartInfo"); @@ -65,7 +53,7 @@ public void save() throws IOException { saveObjects("Placement", "DemoObjInfo"); saveObjects("GeneralPos", "GeneralPosInfo"); saveObjects("Debug", "DebugMoveInfo"); - switch (gameMask) { + switch (game) { case 1: saveObjects("Placement", "SoundInfo"); saveObjects("ChildObj", "ChildObjInfo"); @@ -75,12 +63,12 @@ public void save() throws IOException { break; } savePaths(); - archive.save(); + mapArc.save(); } public void close() { try { - archive.close(); + mapArc.close(); } catch (IOException ex) { System.out.println(ex); @@ -90,9 +78,9 @@ public void close() { private void loadZone() { try { - objects = new HashMap<>(); - subZones = new HashMap<>(); - archive = new RarcFilesystem(filesystem.openFile(zonefile)); + objects = new HashMap(); + zones = new HashMap(); + mapArc = new RarcFilesystem(filesystem.openFile(zoneFile)); loadObjects("Placement", "StageObjInfo"); loadObjects("MapParts", "MapPartsInfo"); loadObjects("Placement", "ObjInfo"); @@ -103,7 +91,7 @@ private void loadZone() { loadObjects("Placement", "DemoObjInfo"); loadObjects("GeneralPos", "GeneralPosInfo"); loadObjects("Debug", "DebugMoveInfo"); - switch (gameMask) { + switch (game) { case 1: loadObjects("Placement", "SoundInfo"); loadObjects("ChildObj", "ChildObjInfo"); @@ -113,25 +101,24 @@ private void loadZone() { break; } loadPaths(); - loadSubZones(); } catch (NullPointerException ex) { - JOptionPane.showMessageDialog(null, "Can't open galaxy, because of missing zone files.\n\nIf you are modding SMG1, try to remove the unused zones from the galaxy's zone list.\nYou can use the BCSV editor to do this.", Whitehole.fullName, 0); + JOptionPane.showMessageDialog(null, "Can't open galaxy, because of missing zone files.\n\nIf you are modding SMG1, try to remove the unused zones from the galaxy's zone list.\nYou can use the BCSV editor to do this.", Whitehole.NAME, 0); } - catch (Exception ex) { + catch (IOException ex) { System.out.println(ex); } } private void loadObjects(String dir, String file) { - List layers = archive.getDirectories("/Stage/Jmp/" + dir); + List layers = mapArc.getDirectories("/Stage/Jmp/" + dir); for (String layer : layers) { addObjectsToList(dir + "/" + layer + "/" + file); } } private void saveObjects(String dir, String file) { - List layers = archive.getDirectories("/Stage/Jmp/" + dir); + List layers = mapArc.getDirectories("/Stage/Jmp/" + dir); for (String layer : layers) { saveObjectList(dir + "/" + layer + "/" + file); } @@ -143,16 +130,20 @@ private void addObjectsToList(String filepath) { String file = stuff[2].toLowerCase(); if (!objects.containsKey(layer)) { - objects.put(layer, new ArrayList()); + objects.put(layer, new ArrayList()); + } + + if (!zones.containsKey(layer)) { + zones.put(layer, new ArrayList()); } try { - Bcsv bcsv = new Bcsv(archive.openFile("/Stage/Jmp/" + filepath)); + Bcsv bcsv = new Bcsv(mapArc.openFile("/Stage/Jmp/" + filepath)); switch (file) { case "stageobjinfo": for (Bcsv.Entry entry : bcsv.entries) { - objects.get(layer).add(new StageObj(this, filepath, entry)); + zones.get(layer).add(new StageObj(this, filepath, entry)); } break; case "mappartsinfo": @@ -167,7 +158,7 @@ private void addObjectsToList(String filepath) { break; case "objinfo": for (Bcsv.Entry entry : bcsv.entries) { - objects.get(layer).add(new GeneralObject(this, filepath, entry)); + objects.get(layer).add(new LevelObj(this, filepath, entry)); } break; case "startinfo": @@ -177,7 +168,7 @@ private void addObjectsToList(String filepath) { break; case "planetobjinfo": for (Bcsv.Entry entry : bcsv.entries) { - objects.get(layer).add(new PlanetObj(this, filepath, entry)); + objects.get(layer).add(new GravityObj(this, filepath, entry)); } break; case "soundinfo": @@ -192,17 +183,17 @@ private void addObjectsToList(String filepath) { break; case "cameracubeinfo": for (Bcsv.Entry entry : bcsv.entries) { - objects.get(layer).add(new CameraCubeObj(this, filepath, entry)); + objects.get(layer).add(new CameraObj(this, filepath, entry)); } break; case "demoobjinfo": for (Bcsv.Entry entry : bcsv.entries) { - objects.get(layer).add(new DemoObj(this, filepath, entry)); + objects.get(layer).add(new CutsceneObj(this, filepath, entry)); } break; case "generalposinfo": for (Bcsv.Entry entry : bcsv.entries) { - objects.get(layer).add(new GeneralPosObj(this, filepath, entry)); + objects.get(layer).add(new PositionObj(this, filepath, entry)); } break; case "debugmoveinfo": @@ -220,8 +211,7 @@ private void addObjectsToList(String filepath) { } catch (IOException ex) { - System.out.println(ex.getMessage()); - ex.printStackTrace(); + System.out.println(ex); } } @@ -233,9 +223,9 @@ private void saveObjectList(String filepath) { return; try { - Bcsv bcsv = new Bcsv(archive.openFile("/Stage/Jmp/" + filepath)); + Bcsv bcsv = new Bcsv(mapArc.openFile("/Stage/Jmp/" + filepath)); bcsv.entries.clear(); - for (LevelObject obj : objects.get(layer)) { + for (AbstractObj obj : objects.get(layer)) { if (!dir.equals(obj.directory) || !file.equals(obj.file)) continue; @@ -246,17 +236,16 @@ private void saveObjectList(String filepath) { bcsv.close(); } catch (IOException ex) { - System.out.println(ex.getMessage()); - ex.printStackTrace(); + System.out.println(ex); } } private void loadPaths() { try { - Bcsv bcsv = new Bcsv(archive.openFile("/Stage/jmp/Path/CommonPathInfo")); + Bcsv bcsv = new Bcsv(mapArc.openFile("/Stage/jmp/Path/CommonPathInfo")); paths = new ArrayList<>(bcsv.entries.size()); for (Bcsv.Entry entry : bcsv.entries) - paths.add(new PathObject(this, entry)); + paths.add(new PathObj(this, entry)); bcsv.close(); } catch (IOException ex) { @@ -266,10 +255,10 @@ private void loadPaths() { private void savePaths() { try { - Bcsv bcsv = new Bcsv(archive.openFile("/Stage/jmp/Path/CommonPathInfo")); + Bcsv bcsv = new Bcsv(mapArc.openFile("/Stage/jmp/Path/CommonPathInfo")); bcsv.entries.clear(); - for (PathObject pobj : paths) { + for (PathObj pobj : paths) { pobj.save(); bcsv.entries.add(pobj.data); } @@ -281,31 +270,16 @@ private void savePaths() { } } - private void loadSubZones() { - List layers = archive.getDirectories("/Stage/Jmp/Placement"); - for (String layer : layers) { - try { - Bcsv bcsv = new Bcsv(archive.openFile("/Stage/Jmp/Placement/" + layer + "/StageObjInfo")); - subZones.put(layer.toLowerCase(), bcsv.entries); - bcsv.close(); - } - catch (IOException ex) { - System.out.println(ex.getMessage()); - ex.printStackTrace(); - } - } - } - public GalaxyArchive galaxy; - public GameArchive game; + public GameArchive gameArc; public FilesystemBase filesystem; - public String zonefile; - public RarcFilesystem archive; - + public RarcFilesystem mapArc; + public String zoneFile; public String zoneName; - public static int gameMask; - public HashMap> objects; - public List paths; - public HashMap> subZones; + public static int game; + + public HashMap> objects; + public HashMap> zones; + public List paths; } diff --git a/src/whitehole/smg/LevelObject.java b/src/com/aurum/whitehole/smg/object/AbstractObj.java similarity index 71% rename from src/whitehole/smg/LevelObject.java rename to src/com/aurum/whitehole/smg/object/AbstractObj.java index 6ca93e9..7fa4b8b 100644 --- a/src/whitehole/smg/LevelObject.java +++ b/src/com/aurum/whitehole/smg/object/AbstractObj.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,38 +13,34 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.smg; +package com.aurum.whitehole.smg.object; -import javax.media.opengl.GL2; -import whitehole.ObjectDB; -import whitehole.PropertyGrid; -import whitehole.rendering.GLRenderer; -import whitehole.rendering.RendererCache; -import whitehole.vectors.Vector3; +import com.aurum.whitehole.ObjectDB; +import com.aurum.whitehole.swing.PropertyGrid; +import com.aurum.whitehole.rendering.GLRenderer; +import com.aurum.whitehole.rendering.cache.RendererCache; +import com.aurum.whitehole.smg.Bcsv; +import com.aurum.whitehole.smg.ZoneArchive; +import com.aurum.whitehole.vectors.Vector3; +import javax.media.opengl.*; -public class LevelObject { - - public void save() { - } - +public abstract class AbstractObj { public final void loadDBInfo() { if (ObjectDB.objects.containsKey(name)) dbInfo = ObjectDB.objects.get(name); else { dbInfo = new ObjectDB.Object(); dbInfo.ID = name; - dbInfo.name = "("+name+")"; + dbInfo.name = "(" + name + ")"; dbInfo.category = 0; - dbInfo.games = 3; + dbInfo.games = 7; } } - public void getShapeModels() { - } - public void initRenderer(GLRenderer.RenderInfo info) { if (renderer != null) return; + renderer = RendererCache.getObjectRenderer(info, this); renderer.compileDisplayLists(info); renderer.releaseStorage(); @@ -53,6 +49,7 @@ public void initRenderer(GLRenderer.RenderInfo info) { public void closeRenderer(GLRenderer.RenderInfo info) { if (renderer == null) return; + RendererCache.closeObjectRenderer(info, this); renderer = null; } @@ -69,34 +66,25 @@ public void render(GLRenderer.RenderInfo info) { if (renderer.isScaled()) gl.glScalef(scale.x, scale.y, scale.z); - int dlid = -1; - switch (info.renderMode) { - case PICKING: dlid = 0; break; - case OPAQUE: dlid = 1; break; - case TRANSLUCENT: dlid = 2; break; - } - - gl.glCallList(renderer.displayLists[dlid]); + gl.glCallList(renderer.displayLists[info.renderMode.ordinal()]); gl.glPopMatrix(); } - public void getProperties(PropertyGrid panel) { - } + public abstract void save(); + public abstract void getProperties(PropertyGrid panel); @Override public String toString() { - return "LevelObject (did someone forget to override this?)"; + return "LevelObject"; } - - public ZoneArchive zone; public String directory, layer, file; public String name, oldname; public Bcsv.Entry data; public ObjectDB.Object dbInfo; + public Vector3 position, rotation, scale; public GLRenderer renderer; + public ZoneArchive zone; public int uniqueID; - - public Vector3 position, rotation, scale; -} +} \ No newline at end of file diff --git a/src/whitehole/smg/object/AreaObj.java b/src/com/aurum/whitehole/smg/object/AreaObj.java similarity index 60% rename from src/whitehole/smg/object/AreaObj.java rename to src/com/aurum/whitehole/smg/object/AreaObj.java index 0cb79d3..2a527da 100644 --- a/src/whitehole/smg/object/AreaObj.java +++ b/src/com/aurum/whitehole/smg/object/AreaObj.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,16 +13,14 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.smg.object; +package com.aurum.whitehole.smg.object; -import whitehole.PropertyGrid; -import whitehole.smg.Bcsv; -import whitehole.smg.LevelObject; -import whitehole.smg.ZoneArchive; -import whitehole.vectors.Vector3; +import com.aurum.whitehole.swing.PropertyGrid; +import com.aurum.whitehole.smg.Bcsv; +import com.aurum.whitehole.smg.ZoneArchive; +import com.aurum.whitehole.vectors.Vector3; -public class AreaObj extends LevelObject { - +public class AreaObj extends AbstractObj { public AreaObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) { this.zone = zone; String[] stuff = filepath.split("/"); @@ -32,12 +30,12 @@ public AreaObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) { data = entry; - name = (String)data.get("name"); - loadDBInfo(); + name = (String) data.get("name"); renderer = null; - uniqueID = -1; + loadDBInfo(); + position = new Vector3((float)data.get("pos_x"), (float)data.get("pos_y"), (float)data.get("pos_z")); rotation = new Vector3((float)data.get("dir_x"), (float)data.get("dir_y"), (float)data.get("dir_z")); scale = new Vector3((float)data.get("scale_x"), (float)data.get("scale_y"), (float)data.get("scale_z")); @@ -53,11 +51,11 @@ public AreaObj(ZoneArchive zone, String filepath, int game, String objname, Vect data = new Bcsv.Entry(); name = objname; - loadDBInfo(); renderer = null; - uniqueID = -1; + loadDBInfo(); + position = pos; rotation = new Vector3(0f, 0f, 0f); scale = new Vector3(1f, 1f, 1f); @@ -66,10 +64,6 @@ public AreaObj(ZoneArchive zone, String filepath, int game, String objname, Vect data.put("pos_x", position.x); data.put("pos_y", position.y); data.put("pos_z", position.z); data.put("dir_x", rotation.x); data.put("dir_y", rotation.y); data.put("dir_z", rotation.z); data.put("scale_x", scale.x); data.put("scale_y", scale.y); data.put("scale_z", scale.z); - - if (ZoneArchive.gameMask == 2) - data.put("Priority", 0); - data.put("Obj_arg0", -1); data.put("Obj_arg1", -1); data.put("Obj_arg2", -1); @@ -90,31 +84,16 @@ public AreaObj(ZoneArchive zone, String filepath, int game, String objname, Vect data.put("DemoGroupId", (short)-1); data.put("MapParts_ID", (short)-1); data.put("Obj_ID", (short)-1); - switch (ZoneArchive.gameMask) { - case 1: - data.put("SW_SLEEP", -1); - data.put("ChildObjId", (short)0); - break; - case 2: - data.put("SW_AWAKE", -1); - data.put("Priority", -1); - data.put("AreaShapeNo", (short)0); - break; + + if (ZoneArchive.game == 1) { + data.put("SW_SLEEP", -1); + data.put("ChildObjId", (short)0); } - } - - public String areaShape(short shape) { - switch(shape) { - case 0: - return "Cube"; - case 1: - return "Cube, alt."; - case 2: - return "Sphere"; - case 3: - return "Cylinder"; + if (ZoneArchive.game == 2) { + data.put("SW_AWAKE", -1); + data.put("Priority", 0); + data.put("AreaShapeNo", (short)0); } - return "Invalid"; } @Override @@ -127,7 +106,7 @@ public void save() { @Override public void getProperties(PropertyGrid panel) { - panel.addCategory("obj_position", "Position"); + panel.addCategory("obj_rendering", "Rendering"); panel.addField("pos_x", "X position", "float", null, position.x, "Default"); panel.addField("pos_y", "Y position", "float", null, position.y, "Default"); panel.addField("pos_z", "Z position", "float", null, position.z, "Default"); @@ -138,49 +117,61 @@ public void getProperties(PropertyGrid panel) { panel.addField("scale_y", "Y scale", "float", null, scale.y, "Default"); panel.addField("scale_z", "Z scale", "float", null, scale.z, "Default"); - panel.addCategory("obj_args", "Object arguments"); - panel.addField("Obj_arg0", "Obj_arg0", "int", null, data.get("Obj_arg0"), "Default"); - panel.addField("Obj_arg1", "Obj_arg1", "int", null, data.get("Obj_arg1"), "Default"); - panel.addField("Obj_arg2", "Obj_arg2", "int", null, data.get("Obj_arg2"), "Default"); - panel.addField("Obj_arg3", "Obj_arg3", "int", null, data.get("Obj_arg3"), "Default"); - panel.addField("Obj_arg4", "Obj_arg4", "int", null, data.get("Obj_arg4"), "Default"); - panel.addField("Obj_arg5", "Obj_arg5", "int", null, data.get("Obj_arg5"), "Default"); - panel.addField("Obj_arg6", "Obj_arg6", "int", null, data.get("Obj_arg6"), "Default"); - panel.addField("Obj_arg7", "Obj_arg7", "int", null, data.get("Obj_arg7"), "Default"); + panel.addCategory("obj_settings", "Settings"); + panel.addField("l_id", "ID", "int", null, data.get("l_id"), "Default"); + if (ZoneArchive.game == 2) { + panel.addField("Priority", "Priority", "int", null, data.get("Priority"), "Default"); + panel.addField("AreaShapeNo", "Shape No.", "int", null, data.get("AreaShapeNo"), "Default"); + } + panel.addField("CommonPath_ID", "Path ID", "int", null, data.get("CommonPath_ID"), "Default"); + + panel.addCategory("obj_args", "Arguments"); + panel.addField("Obj_arg0", dbInfo.getFieldString(0), "int", null, data.get("Obj_arg0"), "Default"); + panel.addField("Obj_arg1", dbInfo.getFieldString(1), "int", null, data.get("Obj_arg1"), "Default"); + panel.addField("Obj_arg2", dbInfo.getFieldString(2), "int", null, data.get("Obj_arg2"), "Default"); + panel.addField("Obj_arg3", dbInfo.getFieldString(3), "int", null, data.get("Obj_arg3"), "Default"); + panel.addField("Obj_arg4", dbInfo.getFieldString(4), "int", null, data.get("Obj_arg4"), "Default"); + panel.addField("Obj_arg5", dbInfo.getFieldString(5), "int", null, data.get("Obj_arg5"), "Default"); + panel.addField("Obj_arg6", dbInfo.getFieldString(6), "int", null, data.get("Obj_arg6"), "Default"); + panel.addField("Obj_arg7", dbInfo.getFieldString(7), "int", null, data.get("Obj_arg7"), "Default"); - panel.addCategory("obj_eventinfo", "Switches"); + panel.addCategory("obj_switches", "Switches"); panel.addField("SW_APPEAR", "SW_APPEAR", "int", null, data.get("SW_APPEAR"), "Default"); panel.addField("SW_A", "SW_A", "int", null, data.get("SW_A"), "Default"); panel.addField("SW_B", "SW_B", "int", null, data.get("SW_B"), "Default"); - if (ZoneArchive.gameMask == 1) + if (ZoneArchive.game == 1) panel.addField("SW_SLEEP", "SW_SLEEP", "int", null, data.get("SW_SLEEP"), "Default"); - if (ZoneArchive.gameMask == 2) + if (ZoneArchive.game == 2) panel.addField("SW_AWAKE", "SW_AWAKE", "int", null, data.get("SW_AWAKE"), "Default"); - panel.addCategory("obj_objinfo", "Other"); - panel.addField("l_id", "l_id", "int", null, data.get("l_id"), "Default"); - if (ZoneArchive.gameMask == 2) - panel.addField("Priority", "Priority", "int", null, data.get("Priority"), "Default"); - panel.addField("FollowId", "FollowId", "int", null, data.get("FollowId"), "Default"); - if (ZoneArchive.gameMask == 2) - panel.addField("AreaShapeNo", "AreaShapeNo", "int", null, data.get("AreaShapeNo"), "Default"); - panel.addField("CommonPath_ID", "CommonPath_ID", "int", null, data.get("CommonPath_ID"), "Default"); - panel.addField("ClippingGroupId", "ClippingGroupId", "int", null, data.get("ClippingGroupId"), "Default"); - panel.addField("GroupId", "GroupId", "int", null, data.get("GroupId"), "Default"); - panel.addField("DemoGroupId", "DemoGroupId", "int", null, data.get("DemoGroupId"), "Default"); - panel.addField("MapParts_ID", "MapParts_ID", "int", null, data.get("MapParts_ID"), "Default"); + panel.addCategory("obj_groups", "Groups"); + panel.addField("GroupId", "Group ID", "int", null, data.get("GroupId"), "Default"); + panel.addField("ClippingGroupId", "Clipping Group ID", "int", null, data.get("ClippingGroupId"), "Default"); + panel.addField("DemoGroupId", "Cutscene Group ID", "int", null, data.get("DemoGroupId"), "Default"); + panel.addField("MapParts_ID", "MapParts Group ID", "int", null, data.get("MapParts_ID"), "Default"); + panel.addField("FollowId", "Follow ID", "int", null, data.get("FollowId"), "Default"); + if (ZoneArchive.game == 1) + panel.addField("ChildObjId", "Child ID", "int", null, data.get("ChildObjId"), "Default"); panel.addField("Obj_ID", "Obj_ID", "int", null, data.get("Obj_ID"), "Default"); - if (ZoneArchive.gameMask == 1) - panel.addField("ChildObjId", "ChildObjId", "int", null, data.get("ChildObjId"), "Default"); } @Override public String toString() { String l = layer.equals("common") ? "Common" : "Layer"+layer.substring(5).toUpperCase(); - if (ZoneArchive.gameMask == 2) { - return dbInfo.name + " (" + areaShape((Short)data.get("AreaShapeNo")) + ")" + " [" + l + "]"; + + if (ZoneArchive.game == 2) { + String area; + switch((short) data.get("AreaShapeNo")) { + case 0: area = "Cube"; break; + case 1: area = "Cube, alt."; break; + case 2: area = "Sphere"; break; + case 3: area = "Cylinder"; break; + default: area = "Invalid"; + } + + return dbInfo.name + " (" + area + ")" + " [" + l + "]"; } else return dbInfo.name + " [" + l + "]"; } -} +} \ No newline at end of file diff --git a/src/whitehole/smg/object/CameraCubeObj.java b/src/com/aurum/whitehole/smg/object/CameraObj.java similarity index 64% rename from src/whitehole/smg/object/CameraCubeObj.java rename to src/com/aurum/whitehole/smg/object/CameraObj.java index b97f5fb..8153610 100644 --- a/src/whitehole/smg/object/CameraCubeObj.java +++ b/src/com/aurum/whitehole/smg/object/CameraObj.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,17 +13,15 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.smg.object; +package com.aurum.whitehole.smg.object; -import whitehole.PropertyGrid; -import whitehole.smg.Bcsv; -import whitehole.smg.LevelObject; -import whitehole.smg.ZoneArchive; -import whitehole.vectors.Vector3; +import com.aurum.whitehole.swing.PropertyGrid; +import com.aurum.whitehole.smg.Bcsv; +import com.aurum.whitehole.smg.ZoneArchive; +import com.aurum.whitehole.vectors.Vector3; -public class CameraCubeObj extends LevelObject { - - public CameraCubeObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) { +public class CameraObj extends AbstractObj { + public CameraObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) { this.zone = zone; String[] stuff = filepath.split("/"); directory = stuff[0]; @@ -32,18 +30,18 @@ public CameraCubeObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) { data = entry; - name = (String)data.get("name"); - loadDBInfo(); + name = (String) data.get("name"); renderer = null; - uniqueID = -1; + loadDBInfo(); + position = new Vector3((float)data.get("pos_x"), (float)data.get("pos_y"), (float)data.get("pos_z")); rotation = new Vector3((float)data.get("dir_x"), (float)data.get("dir_y"), (float)data.get("dir_z")); scale = new Vector3((float)data.get("scale_x"), (float)data.get("scale_y"), (float)data.get("scale_z")); } - public CameraCubeObj(ZoneArchive zone, String filepath, int game, String objname, Vector3 pos) { + public CameraObj(ZoneArchive zone, String filepath, int game, String objname, Vector3 pos) { this.zone = zone; String[] stuff = filepath.split("/"); directory = stuff[0]; @@ -53,11 +51,11 @@ public CameraCubeObj(ZoneArchive zone, String filepath, int game, String objname data = new Bcsv.Entry(); name = objname; - loadDBInfo(); renderer = null; - uniqueID = -1; + loadDBInfo(); + position = pos; rotation = new Vector3(0f, 0f, 0f); scale = new Vector3(1f, 1f, 1f); @@ -81,33 +79,18 @@ public CameraCubeObj(ZoneArchive zone, String filepath, int game, String objname data.put("Validity", "Valid"); data.put("l_id", 0); data.put("FollowId", -1); - data.put("MapParts_ID", (short) -1); - data.put("Obj_ID", (short) -1); - - switch (ZoneArchive.gameMask) { - case 1: - data.put("SW_SLEEP", -1); - data.put("ChildObjId", (short)-1); - break; - case 2: - data.put("SW_AWAKE", -1); - data.put("AreaShapeNo", (short) 0); - break; + data.put("MapParts_ID", (short)-1); + data.put("Obj_ID", (short)-1); + + if (ZoneArchive.game == 1) { + data.put("SW_SLEEP", -1); + data.put("ChildObjId", (short)0); } - } - - public String areaShape() { - switch((short)data.get("AreaShapeNo")) { - case 0: - return "Cube"; - case 1: - return "Cube, alt."; - case 2: - return "Sphere"; - case 3: - return "Cylinder"; + if (ZoneArchive.game == 2) { + data.put("SW_AWAKE", -1); + data.put("Priority", 0); + data.put("AreaShapeNo", (short)0); } - return "Invalid"; } @Override @@ -120,7 +103,7 @@ public void save() { @Override public void getProperties(PropertyGrid panel) { - panel.addCategory("obj_position", "Position"); + panel.addCategory("obj_rendering", "Rendering"); panel.addField("pos_x", "X position", "float", null, position.x, "Default"); panel.addField("pos_y", "Y position", "float", null, position.y, "Default"); panel.addField("pos_z", "Z position", "float", null, position.z, "Default"); @@ -131,44 +114,54 @@ public void getProperties(PropertyGrid panel) { panel.addField("scale_y", "Y scale", "float", null, scale.y, "Default"); panel.addField("scale_z", "Z scale", "float", null, scale.z, "Default"); - panel.addCategory("obj_args", "Object arguments"); - panel.addField("Obj_arg0", "Obj_arg0", "int", null, data.get("Obj_arg0"), "Default"); - panel.addField("Obj_arg1", "Obj_arg1", "int", null, data.get("Obj_arg1"), "Default"); - panel.addField("Obj_arg2", "Obj_arg2", "int", null, data.get("Obj_arg2"), "Default"); - panel.addField("Obj_arg3", "Obj_arg3", "int", null, data.get("Obj_arg3"), "Default"); - - panel.addCategory("obj_shit", "Unknown"); + panel.addCategory("obj_args", "Arguments"); + panel.addField("Obj_arg0", dbInfo.getFieldString(0), "int", null, data.get("Obj_arg0"), "Default"); + panel.addField("Obj_arg1", dbInfo.getFieldString(1), "int", null, data.get("Obj_arg1"), "Default"); + panel.addField("Obj_arg2", dbInfo.getFieldString(2), "int", null, data.get("Obj_arg2"), "Default"); + panel.addField("Obj_arg3", dbInfo.getFieldString(3), "int", null, data.get("Obj_arg3"), "Default"); + + panel.addCategory("obj_settings", "Settings"); + panel.addField("l_id", "ID", "int", null, data.get("l_id"), "Default"); + if (ZoneArchive.game == 2) + panel.addField("AreaShapeNo", "Shape No.", "int", null, data.get("AreaShapeNo"), "Default"); + panel.addField("Validity", "Validity", "text", null, data.get("Validity"), "Default"); panel.addField("0x50F5D5E6", "Unknown (50F5D5E6)", "int", null, data.get(0x50F5D5E6), "Default"); panel.addField("0xCDC4FEAD", "Unknown (CDC4FEAD)", "int", null, data.get(0xCDC4FEAD), "Default"); - panel.addCategory("obj_eventinfo", "Switches"); + panel.addCategory("obj_switches", "Switches"); panel.addField("SW_APPEAR", "SW_APPEAR", "int", null, data.get("SW_APPEAR"), "Default"); panel.addField("SW_A", "SW_A", "int", null, data.get("SW_A"), "Default"); panel.addField("SW_B", "SW_B", "int", null, data.get("SW_B"), "Default"); - if (ZoneArchive.gameMask == 1) + if (ZoneArchive.game == 1) panel.addField("SW_SLEEP", "SW_SLEEP", "int", null, data.get("SW_SLEEP"), "Default"); - if (ZoneArchive.gameMask == 2) + if (ZoneArchive.game == 2) panel.addField("SW_AWAKE", "SW_AWAKE", "int", null, data.get("SW_AWAKE"), "Default"); - panel.addCategory("obj_objinfo", "Other"); - panel.addField("l_id", "l_id", "int", null, data.get("l_id"), "Default"); - panel.addField("Validity", "Validity", "text", null, data.get("Validity"), "Default"); - panel.addField("FollowId", "FollowId", "int", null, data.get("FollowId"), "Default"); - if (ZoneArchive.gameMask == 2) - panel.addField("AreaShapeNo", "AreaShapeNo", "int", null, data.get("AreaShapeNo"), "Default"); - panel.addField("MapParts_ID", "MapParts_ID", "int", null, data.get("MapParts_ID"), "Default"); + panel.addCategory("obj_groups", "Groups"); + panel.addField("MapParts_ID", "MapParts Group ID", "int", null, data.get("MapParts_ID"), "Default"); + panel.addField("FollowId", "Follow ID", "int", null, data.get("FollowId"), "Default"); + if (ZoneArchive.game == 1) + panel.addField("ChildObjId", "Child ID", "int", null, data.get("ChildObjId"), "Default"); panel.addField("Obj_ID", "Obj_ID", "int", null, data.get("Obj_ID"), "Default"); - if (ZoneArchive.gameMask == 1) - panel.addField("ChildObjId", "ChildObjId", "int", null, data.get("ChildObjId"), "Default"); } @Override public String toString() { String l = layer.equals("common") ? "Common" : "Layer"+layer.substring(5).toUpperCase(); - if (ZoneArchive.gameMask == 2) { - return dbInfo.name + " (" + areaShape() + ")" + " [" + l + "]"; + + if (ZoneArchive.game == 2) { + String area; + switch((short) data.get("AreaShapeNo")) { + case 0: area = "Cube"; break; + case 1: area = "Cube, alt."; break; + case 2: area = "Sphere"; break; + case 3: area = "Cylinder"; break; + default: area = "Invalid"; + } + + return dbInfo.name + " (" + area + ")" + " [" + l + "]"; } else return dbInfo.name + " [" + l + "]"; } -} +} \ No newline at end of file diff --git a/src/whitehole/smg/object/ChangeObj.java b/src/com/aurum/whitehole/smg/object/ChangeObj.java similarity index 89% rename from src/whitehole/smg/object/ChangeObj.java rename to src/com/aurum/whitehole/smg/object/ChangeObj.java index efdd32f..7f663ea 100644 --- a/src/whitehole/smg/object/ChangeObj.java +++ b/src/com/aurum/whitehole/smg/object/ChangeObj.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,16 +13,14 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.smg.object; +package com.aurum.whitehole.smg.object; -import whitehole.PropertyGrid; -import whitehole.smg.Bcsv; -import whitehole.smg.LevelObject; -import whitehole.smg.ZoneArchive; -import whitehole.vectors.Vector3; +import com.aurum.whitehole.swing.PropertyGrid; +import com.aurum.whitehole.smg.Bcsv; +import com.aurum.whitehole.smg.ZoneArchive; +import com.aurum.whitehole.vectors.Vector3; -public class ChangeObj extends LevelObject { - +public class ChangeObj extends AbstractObj { public ChangeObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) { this.zone = zone; String[] stuff = filepath.split("/"); @@ -33,11 +31,11 @@ public ChangeObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) { data = entry; name = (String)data.get("name"); - loadDBInfo(); renderer = null; - uniqueID = -1; + loadDBInfo(); + position = new Vector3((float)data.get("pos_x"), (float)data.get("pos_y"), (float)data.get("pos_z")); rotation = new Vector3((float)data.get("dir_x"), (float)data.get("dir_y"), (float)data.get("dir_z")); scale = new Vector3((float)data.get("scale_x"), (float)data.get("scale_y"), (float)data.get("scale_z")); @@ -53,11 +51,11 @@ public ChangeObj(ZoneArchive zone, String filepath, int game, Vector3 pos) { data = new Bcsv.Entry(); name = "ChangeObj"; - loadDBInfo(); renderer = null; - uniqueID = -1; + loadDBInfo(); + position = pos; rotation = new Vector3(0f, 0f, 0f); scale = new Vector3(1f, 1f, 1f); @@ -87,7 +85,7 @@ public void save() { @Override public void getProperties(PropertyGrid panel) { - panel.addCategory("obj_position", "Position"); + panel.addCategory("obj_rendering", "Rendering"); panel.addField("pos_x", "X position", "float", null, position.x, "Default"); panel.addField("pos_y", "Y position", "float", null, position.y, "Default"); panel.addField("pos_z", "Z position", "float", null, position.z, "Default"); @@ -98,16 +96,16 @@ public void getProperties(PropertyGrid panel) { panel.addField("scale_y", "Y scale", "float", null, scale.y, "Default"); panel.addField("scale_z", "Z scale", "float", null, scale.z, "Default"); - panel.addCategory("obj_eventinfo", "Switches"); + panel.addCategory("obj_settings", "Settings"); + panel.addField("l_id", "ID", "int", null, data.get("l_id"), "Default"); + panel.addField("0x55CFC442", "Unknown (55CFC442)", "int", null, data.get(0x55CFC442), "Default"); + panel.addField("0xC4F73392", "Unknown (C4F73392)", "int", null, data.get(0xC4F73392), "Default"); + + panel.addCategory("obj_switches", "Switches"); panel.addField("SW_APPEAR", "SW_APPEAR", "int", null, data.get("SW_APPEAR"), "Default"); panel.addField("SW_DEAD", "SW_DEAD", "int", null, data.get("SW_DEAD"), "Default"); panel.addField("SW_A", "SW_A", "int", null, data.get("SW_A"), "Default"); panel.addField("SW_B", "SW_B", "int", null, data.get("SW_B"), "Default"); - - panel.addCategory("obj_objinfo", "Other"); - panel.addField("l_id", "l_id", "int", null, data.get("l_id"), "Default"); - panel.addField("0x55CFC442", "Unknown (55CFC442)", "int", null, data.get(0x55CFC442), "Default"); - panel.addField("0xC4F73392", "Unknown (C4F73392)", "int", null, data.get(0xC4F73392), "Default"); } @Override diff --git a/src/whitehole/smg/object/ChildObj.java b/src/com/aurum/whitehole/smg/object/ChildObj.java similarity index 82% rename from src/whitehole/smg/object/ChildObj.java rename to src/com/aurum/whitehole/smg/object/ChildObj.java index fe1a086..85855d2 100644 --- a/src/whitehole/smg/object/ChildObj.java +++ b/src/com/aurum/whitehole/smg/object/ChildObj.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,18 +13,15 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.smg.object; +package com.aurum.whitehole.smg.object; -import whitehole.PropertyGrid; -import whitehole.smg.Bcsv; -import whitehole.smg.LevelObject; -import whitehole.smg.ZoneArchive; -import whitehole.vectors.Vector3; +import com.aurum.whitehole.swing.PropertyGrid; +import com.aurum.whitehole.smg.Bcsv; +import com.aurum.whitehole.smg.ZoneArchive; +import com.aurum.whitehole.vectors.Vector3; -public class ChildObj extends LevelObject -{ - public ChildObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) - { +public class ChildObj extends AbstractObj { + public ChildObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) { this.zone = zone; String[] stuff = filepath.split("/"); directory = stuff[0]; @@ -34,18 +31,17 @@ public ChildObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) data = entry; name = (String)data.get("name"); - loadDBInfo(); renderer = null; - uniqueID = -1; + loadDBInfo(); + position = new Vector3((float)data.get("pos_x"), (float)data.get("pos_y"), (float)data.get("pos_z")); rotation = new Vector3((float)data.get("dir_x"), (float)data.get("dir_y"), (float)data.get("dir_z")); scale = new Vector3((float)data.get("scale_x"), (float)data.get("scale_y"), (float)data.get("scale_z")); } - public ChildObj(ZoneArchive zone, String filepath, int game, String objname, Vector3 pos) - { + public ChildObj(ZoneArchive zone, String filepath, int game, String objname, Vector3 pos) { this.zone = zone; String[] stuff = filepath.split("/"); directory = stuff[0]; @@ -55,11 +51,11 @@ public ChildObj(ZoneArchive zone, String filepath, int game, String objname, Vec data = new Bcsv.Entry(); name = objname; - loadDBInfo(); renderer = null; - uniqueID = -1; + loadDBInfo(); + position = pos; rotation = new Vector3(0f, 0f, 0f); scale = new Vector3(1f, 1f, 1f); @@ -99,8 +95,7 @@ public ChildObj(ZoneArchive zone, String filepath, int game, String objname, Vec } @Override - public void save() - { + public void save() { data.put("name", name); data.put("pos_x", position.x); data.put("pos_y", position.y); data.put("pos_z", position.z); data.put("dir_x", rotation.x); data.put("dir_y", rotation.y); data.put("dir_z", rotation.z); @@ -108,8 +103,7 @@ public void save() } @Override - public void getProperties(PropertyGrid panel) - { + public void getProperties(PropertyGrid panel) { panel.addCategory("obj_position", "Position"); panel.addField("pos_x", "X position", "float", null, position.x, "Default"); panel.addField("pos_y", "Y position", "float", null, position.y, "Default"); @@ -122,14 +116,14 @@ public void getProperties(PropertyGrid panel) panel.addField("scale_z", "Z scale", "float", null, scale.z, "Default"); panel.addCategory("obj_args", "Object arguments"); - panel.addField("Obj_arg0", "Obj_arg0", "int", null, data.get("Obj_arg0"), "Default"); - panel.addField("Obj_arg1", "Obj_arg1", "int", null, data.get("Obj_arg1"), "Default"); - panel.addField("Obj_arg2", "Obj_arg2", "int", null, data.get("Obj_arg2"), "Default"); - panel.addField("Obj_arg3", "Obj_arg3", "int", null, data.get("Obj_arg3"), "Default"); - panel.addField("Obj_arg4", "Obj_arg4", "int", null, data.get("Obj_arg4"), "Default"); - panel.addField("Obj_arg5", "Obj_arg5", "int", null, data.get("Obj_arg5"), "Default"); - panel.addField("Obj_arg6", "Obj_arg6", "int", null, data.get("Obj_arg6"), "Default"); - panel.addField("Obj_arg7", "Obj_arg7", "int", null, data.get("Obj_arg7"), "Default"); + panel.addField("Obj_arg0", dbInfo.getFieldString(0), "int", null, data.get("Obj_arg0"), "Default"); + panel.addField("Obj_arg1", dbInfo.getFieldString(1), "int", null, data.get("Obj_arg1"), "Default"); + panel.addField("Obj_arg2", dbInfo.getFieldString(2), "int", null, data.get("Obj_arg2"), "Default"); + panel.addField("Obj_arg3", dbInfo.getFieldString(3), "int", null, data.get("Obj_arg3"), "Default"); + panel.addField("Obj_arg4", dbInfo.getFieldString(4), "int", null, data.get("Obj_arg4"), "Default"); + panel.addField("Obj_arg5", dbInfo.getFieldString(5), "int", null, data.get("Obj_arg5"), "Default"); + panel.addField("Obj_arg6", dbInfo.getFieldString(6), "int", null, data.get("Obj_arg6"), "Default"); + panel.addField("Obj_arg7", dbInfo.getFieldString(7), "int", null, data.get("Obj_arg7"), "Default"); panel.addCategory("obj_eventinfo", "Switches"); panel.addField("SW_APPEAR", "SW_APPEAR", "int", null, data.get("SW_APPEAR"), "Default"); @@ -155,9 +149,8 @@ public void getProperties(PropertyGrid panel) } @Override - public String toString() - { + public String toString() { String l = layer.equals("common") ? "Common" : "Layer"+layer.substring(5).toUpperCase(); return dbInfo.name + " [" + l + "]"; } -} +} \ No newline at end of file diff --git a/src/whitehole/smg/object/DemoObj.java b/src/com/aurum/whitehole/smg/object/CutsceneObj.java similarity index 72% rename from src/whitehole/smg/object/DemoObj.java rename to src/com/aurum/whitehole/smg/object/CutsceneObj.java index ac70cc0..4532e6c 100644 --- a/src/whitehole/smg/object/DemoObj.java +++ b/src/com/aurum/whitehole/smg/object/CutsceneObj.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,18 +13,15 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.smg.object; +package com.aurum.whitehole.smg.object; -import whitehole.PropertyGrid; -import whitehole.smg.Bcsv; -import whitehole.smg.LevelObject; -import whitehole.smg.ZoneArchive; -import whitehole.vectors.Vector3; +import com.aurum.whitehole.swing.PropertyGrid; +import com.aurum.whitehole.smg.Bcsv; +import com.aurum.whitehole.smg.ZoneArchive; +import com.aurum.whitehole.vectors.Vector3; -public class DemoObj extends LevelObject -{ - public DemoObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) - { +public class CutsceneObj extends AbstractObj { + public CutsceneObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) { this.zone = zone; String[] stuff = filepath.split("/"); directory = stuff[0]; @@ -34,18 +31,17 @@ public DemoObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) data = entry; name = (String)data.get("name"); - loadDBInfo(); renderer = null; - uniqueID = -1; + loadDBInfo(); + position = new Vector3((float)data.get("pos_x"), (float)data.get("pos_y"), (float)data.get("pos_z")); rotation = new Vector3((float)data.get("dir_x"), (float)data.get("dir_y"), (float)data.get("dir_z")); scale = new Vector3((float)data.get("scale_x"), (float)data.get("scale_y"), (float)data.get("scale_z")); } - public DemoObj(ZoneArchive zone, String filepath, int game, String objname, Vector3 pos) - { + public CutsceneObj(ZoneArchive zone, String filepath, int game, String objname, Vector3 pos) { this.zone = zone; String[] stuff = filepath.split("/"); directory = stuff[0]; @@ -55,11 +51,11 @@ public DemoObj(ZoneArchive zone, String filepath, int game, String objname, Vect data = new Bcsv.Entry(); name = objname; - loadDBInfo(); renderer = null; - uniqueID = -1; + loadDBInfo(); + position = pos; rotation = new Vector3(0f, 0f, 0f); scale = new Vector3(1f, 1f, 1f); @@ -75,16 +71,15 @@ public DemoObj(ZoneArchive zone, String filepath, int game, String objname, Vect data.put("SW_B", -1); data.put("l_id", -1); - data.put("DemoName", "null"); - data.put("TimeSheetName", "null"); - if (ZoneArchive.gameMask == 2) - data.put("DemoSkip", (short)-1); + data.put("DemoName", "undefined"); + data.put("TimeSheetName", "undefined"); + if (ZoneArchive.game == 2) + data.put("DemoSkip", -1); } @Override - public void save() - { + public void save() { data.put("name", name); data.put("pos_x", position.x); data.put("pos_y", position.y); data.put("pos_z", position.z); data.put("dir_x", rotation.x); data.put("dir_y", rotation.y); data.put("dir_z", rotation.z); @@ -92,9 +87,8 @@ public void save() } @Override - public void getProperties(PropertyGrid panel) - { - panel.addCategory("obj_position", "Position"); + public void getProperties(PropertyGrid panel) { + panel.addCategory("obj_rendering", "Rendering"); panel.addField("pos_x", "X position", "float", null, position.x, "Default"); panel.addField("pos_y", "Y position", "float", null, position.y, "Default"); panel.addField("pos_z", "Z position", "float", null, position.z, "Default"); @@ -104,27 +98,26 @@ public void getProperties(PropertyGrid panel) panel.addField("scale_x", "X scale", "float", null, scale.x, "Default"); panel.addField("scale_y", "Y scale", "float", null, scale.y, "Default"); panel.addField("scale_z", "Z scale", "float", null, scale.z, "Default"); + + panel.addCategory("obj_settings", "Settings"); + panel.addField("l_id", "ID", "int", null, data.get("l_id"), "Default"); - panel.addCategory("obj_eventinfo", "Switches"); + panel.addCategory("obj_switches", "Switches"); panel.addField("SW_APPEAR", "SW_APPEAR", "int", null, data.get("SW_APPEAR"), "Default"); panel.addField("SW_DEAD", "SW_DEAD", "int", null, data.get("SW_DEAD"), "Default"); panel.addField("SW_A", "SW_A", "int", null, data.get("SW_A"), "Default"); panel.addField("SW_B", "SW_B", "int", null, data.get("SW_B"), "Default"); - panel.addCategory("obj_demosettings", "Cutscene Information"); - panel.addField("DemoName", "DemoName", "text", null, data.get("DemoName"), "Default"); - panel.addField("TimeSheetName", "TimeSheetName", "text", null, data.get("TimeSheetName"), "Default"); - if (ZoneArchive.gameMask == 2) - panel.addField("DemoSkip", "DemoSkip", "int", null, data.get("DemoSkip"), "Default"); - - panel.addCategory("obj_objinfo", "Other"); - panel.addField("l_id", "l_id", "int", null, data.get("l_id"), "Default"); + panel.addCategory("obj_cutscenes", "Cutscene"); + panel.addField("DemoName", "Cutscene Name", "text", null, data.get("DemoName"), "Default"); + panel.addField("TimeSheetName", "Sheet Name", "text", null, data.get("TimeSheetName"), "Default"); + if (ZoneArchive.game == 2) + panel.addField("DemoSkip", "Skipable", "bool", null, (int) data.get("DemoSkip") != -1, "Default"); } @Override - public String toString() - { + public String toString() { String l = layer.equals("common") ? "Common" : "Layer"+layer.substring(5).toUpperCase(); - return dbInfo.name + " ( " + data.get("DemoName") + " | " + data.get("TimeSheetName") + " ) " + " [" + l + "]"; + return dbInfo.name + " (" + data.get("DemoName") + " | " + data.get("TimeSheetName") + ") " + " [" + l + "]"; } -} +} \ No newline at end of file diff --git a/src/whitehole/smg/object/DebugObj.java b/src/com/aurum/whitehole/smg/object/DebugObj.java similarity index 82% rename from src/whitehole/smg/object/DebugObj.java rename to src/com/aurum/whitehole/smg/object/DebugObj.java index 37a95d9..95103d9 100644 --- a/src/whitehole/smg/object/DebugObj.java +++ b/src/com/aurum/whitehole/smg/object/DebugObj.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,18 +13,15 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.smg.object; +package com.aurum.whitehole.smg.object; -import whitehole.PropertyGrid; -import whitehole.smg.Bcsv; -import whitehole.smg.LevelObject; -import whitehole.smg.ZoneArchive; -import whitehole.vectors.Vector3; +import com.aurum.whitehole.swing.PropertyGrid; +import com.aurum.whitehole.smg.Bcsv; +import com.aurum.whitehole.smg.ZoneArchive; +import com.aurum.whitehole.vectors.Vector3; -public class DebugObj extends LevelObject -{ - public DebugObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) - { +public class DebugObj extends AbstractObj { + public DebugObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) { this.zone = zone; String[] stuff = filepath.split("/"); directory = stuff[0]; @@ -34,18 +31,17 @@ public DebugObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) data = entry; name = (String)data.get("name"); - loadDBInfo(); renderer = null; - uniqueID = -1; + loadDBInfo(); + position = new Vector3((float)data.get("pos_x"), (float)data.get("pos_y"), (float)data.get("pos_z")); rotation = new Vector3((float)data.get("dir_x"), (float)data.get("dir_y"), (float)data.get("dir_z")); scale = new Vector3((float)data.get("scale_x"), (float)data.get("scale_y"), (float)data.get("scale_z")); } - public DebugObj(ZoneArchive zone, String filepath, int game, String objname, Vector3 pos) - { + public DebugObj(ZoneArchive zone, String filepath, int game, String objname, Vector3 pos) { this.zone = zone; String[] stuff = filepath.split("/"); directory = stuff[0]; @@ -55,11 +51,11 @@ public DebugObj(ZoneArchive zone, String filepath, int game, String objname, Vec data = new Bcsv.Entry(); name = "DebugMovePos"; - loadDBInfo(); renderer = null; - uniqueID = -1; + loadDBInfo(); + position = pos; rotation = new Vector3(0f, 0f, 0f); scale = new Vector3(1f, 1f, 1f); @@ -73,8 +69,7 @@ public DebugObj(ZoneArchive zone, String filepath, int game, String objname, Vec } @Override - public void save() - { + public void save() { data.put("name", name); data.put("pos_x", position.x); data.put("pos_y", position.y); data.put("pos_z", position.z); data.put("dir_x", rotation.x); data.put("dir_y", rotation.y); data.put("dir_z", rotation.z); @@ -82,9 +77,8 @@ public void save() } @Override - public void getProperties(PropertyGrid panel) - { - panel.addCategory("obj_position", "Position"); + public void getProperties(PropertyGrid panel) { + panel.addCategory("obj_rendering", "Rendering"); panel.addField("pos_x", "X position", "float", null, position.x, "Default"); panel.addField("pos_y", "Y position", "float", null, position.y, "Default"); panel.addField("pos_z", "Z position", "float", null, position.z, "Default"); @@ -95,14 +89,13 @@ public void getProperties(PropertyGrid panel) panel.addField("scale_y", "Y scale", "float", null, scale.y, "Default"); panel.addField("scale_z", "Z scale", "float", null, scale.z, "Default"); - panel.addCategory("obj_objinfo", "Other"); - panel.addField("l_id", "l_id", "int", null, data.get("l_id"), "Default"); + panel.addCategory("obj_settings", "Settings"); + panel.addField("l_id", "ID", "int", null, data.get("l_id"), "Default"); } @Override - public String toString() - { + public String toString() { String l = layer.equals("common") ? "Common" : "Layer"+layer.substring(5).toUpperCase(); - return dbInfo.name + " [" + l + "]"; + return dbInfo.name + " No. " + data.get("l_id") + " [" + l + "]"; } -} +} \ No newline at end of file diff --git a/src/whitehole/smg/object/PlanetObj.java b/src/com/aurum/whitehole/smg/object/GravityObj.java similarity index 66% rename from src/whitehole/smg/object/PlanetObj.java rename to src/com/aurum/whitehole/smg/object/GravityObj.java index c7ea462..8238c5f 100644 --- a/src/whitehole/smg/object/PlanetObj.java +++ b/src/com/aurum/whitehole/smg/object/GravityObj.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,20 +13,17 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.smg.object; +package com.aurum.whitehole.smg.object; -import java.util.Arrays; import java.util.List; -import whitehole.PropertyGrid; -import whitehole.smg.Bcsv; -import whitehole.smg.LevelObject; -import whitehole.smg.ZoneArchive; -import whitehole.vectors.Vector3; +import com.aurum.whitehole.swing.PropertyGrid; +import com.aurum.whitehole.smg.Bcsv; +import com.aurum.whitehole.smg.ZoneArchive; +import com.aurum.whitehole.vectors.Vector3; +import java.util.ArrayList; -public class PlanetObj extends LevelObject -{ - public PlanetObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) - { +public class GravityObj extends AbstractObj { + public GravityObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) { this.zone = zone; String[] stuff = filepath.split("/"); directory = stuff[0]; @@ -36,18 +33,17 @@ public PlanetObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) data = entry; name = (String)data.get("name"); - loadDBInfo(); renderer = null; - uniqueID = -1; + loadDBInfo(); + position = new Vector3((float)data.get("pos_x"), (float)data.get("pos_y"), (float)data.get("pos_z")); rotation = new Vector3((float)data.get("dir_x"), (float)data.get("dir_y"), (float)data.get("dir_z")); scale = new Vector3((float)data.get("scale_x"), (float)data.get("scale_y"), (float)data.get("scale_z")); } - public PlanetObj(ZoneArchive zone, String filepath, int game, String objname, Vector3 pos) - { + public GravityObj(ZoneArchive zone, String filepath, int game, String objname, Vector3 pos) { this.zone = zone; String[] stuff = filepath.split("/"); directory = stuff[0]; @@ -57,11 +53,11 @@ public PlanetObj(ZoneArchive zone, String filepath, int game, String objname, Ve data = new Bcsv.Entry(); name = objname; - loadDBInfo(); renderer = null; - uniqueID = -1; + loadDBInfo(); + position = pos; rotation = new Vector3(0f, 0f, 0f); scale = new Vector3(1f, 1f, 1f); @@ -97,20 +93,16 @@ public PlanetObj(ZoneArchive zone, String filepath, int game, String objname, Ve data.put("MapParts_ID", (short)-1); data.put("Obj_ID", (short)-1); - switch (ZoneArchive.gameMask) { - case 1: - data.put("SW_SLEEP", -1); - data.put("ChildObjId", (short)-1); - break; - case 2: - data.put("SW_AWAKE", -1); - break; + if (ZoneArchive.game == 1) { + data.put("SW_SLEEP", -1); + data.put("ChildObjId", (short)-1); } + if (ZoneArchive.game == 2) + data.put("SW_AWAKE", -1); } @Override - public void save() - { + public void save() { data.put("name", name); data.put("pos_x", position.x); data.put("pos_y", position.y); data.put("pos_z", position.z); data.put("dir_x", rotation.x); data.put("dir_y", rotation.y); data.put("dir_z", rotation.z); @@ -118,9 +110,8 @@ public void save() } @Override - public void getProperties(PropertyGrid panel) - { - panel.addCategory("obj_position", "Position"); + public void getProperties(PropertyGrid panel) { + panel.addCategory("obj_rendering", "Rendering"); panel.addField("pos_x", "X position", "float", null, position.x, "Default"); panel.addField("pos_y", "Y position", "float", null, position.y, "Default"); panel.addField("pos_z", "Z position", "float", null, position.z, "Default"); @@ -131,7 +122,11 @@ public void getProperties(PropertyGrid panel) panel.addField("scale_y", "Y scale", "float", null, scale.y, "Default"); panel.addField("scale_z", "Z scale", "float", null, scale.z, "Default"); - panel.addCategory("obj_grav", "Gravity"); + panel.addCategory("obj_settings", "Settings"); + panel.addField("l_id", "ID", "int", null, data.get("l_id"), "Default"); + panel.addField("CommonPath_ID", "Path ID", "int", null, data.get("CommonPath_ID"), "Default"); + + panel.addCategory("obj_gravity", "Gravity"); panel.addField("Range", "Range", "float", null, data.get("Range"), "Default"); panel.addField("Distant", "Distance", "float", null, data.get("Distant"), "Default"); panel.addField("Priority", "Priority", "int", null, data.get("Priority"), "Default"); @@ -139,44 +134,39 @@ public void getProperties(PropertyGrid panel) panel.addField("Power", "Power", "list", choicesGravityPower, data.get("Power"), "Default"); panel.addField("Gravity_type", "Type", "list", choicesGravityType, data.get("Gravity_type"), "Default"); - panel.addCategory("obj_args", "Object arguments"); - panel.addField("Obj_arg0", "Obj_arg0", "int", null, data.get("Obj_arg0"), "Default"); - panel.addField("Obj_arg1", "Obj_arg1", "int", null, data.get("Obj_arg1"), "Default"); - panel.addField("Obj_arg2", "Obj_arg2", "int", null, data.get("Obj_arg2"), "Default"); - panel.addField("Obj_arg3", "Obj_arg3", "int", null, data.get("Obj_arg3"), "Default"); + panel.addCategory("obj_args", "Arguments"); + panel.addField("Obj_arg0", dbInfo.getFieldString(0), "int", null, data.get("Obj_arg0"), "Default"); + panel.addField("Obj_arg1", dbInfo.getFieldString(1), "int", null, data.get("Obj_arg1"), "Default"); + panel.addField("Obj_arg2", dbInfo.getFieldString(2), "int", null, data.get("Obj_arg2"), "Default"); + panel.addField("Obj_arg3", dbInfo.getFieldString(3), "int", null, data.get("Obj_arg3"), "Default"); - panel.addCategory("obj_eventinfo", "Switches"); + panel.addCategory("obj_switches", "Switches"); panel.addField("SW_APPEAR", "SW_APPEAR", "int", null, data.get("SW_APPEAR"), "Default"); panel.addField("SW_DEAD", "SW_DEAD", "int", null, data.get("SW_DEAD"), "Default"); panel.addField("SW_A", "SW_A", "int", null, data.get("SW_A"), "Default"); panel.addField("SW_B", "SW_B", "int", null, data.get("SW_B"), "Default"); - if (ZoneArchive.gameMask == 1) + if (ZoneArchive.game == 1) panel.addField("SW_SLEEP", "SW_SLEEP", "int", null, data.get("SW_SLEEP"), "Default"); - if (ZoneArchive.gameMask == 2) + if (ZoneArchive.game == 2) panel.addField("SW_AWAKE", "SW_AWAKE", "int", null, data.get("SW_AWAKE"), "Default"); - panel.addCategory("obj_objinfo", "Other"); - panel.addField("l_id", "l_id", "int", null, data.get("l_id"), "Default"); - panel.addField("FollowId", "FollowId", "int", null, data.get("FollowId"), "Default"); - panel.addField("CommonPath_ID", "CommonPath_ID", "int", null, data.get("CommonPath_ID"), "Default"); - panel.addField("ClippingGroupId", "ClippingGroupId", "int", null, data.get("ClippingGroupId"), "Default"); - panel.addField("GroupId", "GroupId", "int", null, data.get("GroupId"), "Default"); - panel.addField("DemoGroupId", "DemoGroupId", "int", null, data.get("DemoGroupId"), "Default"); - panel.addField("MapParts_ID", "MapParts_ID", "int", null, data.get("MapParts_ID"), "Default"); + panel.addCategory("obj_groups", "Groups"); + panel.addField("GroupId", "Group ID", "int", null, data.get("GroupId"), "Default"); + panel.addField("ClippingGroupId", "Clipping Group ID", "int", null, data.get("ClippingGroupId"), "Default"); + panel.addField("DemoGroupId", "Cutscene Group ID", "int", null, data.get("DemoGroupId"), "Default"); + panel.addField("MapParts_ID", "MapParts Group ID", "int", null, data.get("MapParts_ID"), "Default"); + panel.addField("FollowId", "Follow ID", "int", null, data.get("FollowId"), "Default"); + if (ZoneArchive.game == 1) + panel.addField("ChildObjId", "Child ID", "int", null, data.get("ChildObjId"), "Default"); panel.addField("Obj_ID", "Obj_ID", "int", null, data.get("Obj_ID"), "Default"); - if (ZoneArchive.gameMask == 1) - panel.addField("ChildObjId", "ChildObjId", "int", null, data.get("ChildObjId"), "Default"); } @Override - public String toString() - { + public String toString() { String l = layer.equals("common") ? "Common" : "Layer"+layer.substring(5).toUpperCase(); return dbInfo.name + " [" + l + "]"; } - private String[] gravityPowers = {"Normal","Light","Heavy"}; - private String[] gravityTypes = {"Normal","Shadow","Magnet"}; - private List choicesGravityPower = Arrays.asList(gravityPowers); - private List choicesGravityType = Arrays.asList(gravityTypes); -} + private static List choicesGravityPower = new ArrayList() {{ add("Normal"); add("Light"); add("Heavy"); }}; + private static List choicesGravityType = new ArrayList() {{ add("Normal"); add("Shadow"); add("Magnet"); }}; +} \ No newline at end of file diff --git a/src/whitehole/smg/object/GeneralObject.java b/src/com/aurum/whitehole/smg/object/LevelObj.java similarity index 53% rename from src/whitehole/smg/object/GeneralObject.java rename to src/com/aurum/whitehole/smg/object/LevelObj.java index 843411e..429e77c 100644 --- a/src/whitehole/smg/object/GeneralObject.java +++ b/src/com/aurum/whitehole/smg/object/LevelObj.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -12,21 +12,15 @@ You should have received a copy of the GNU General Public License along with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.smg.object; +package com.aurum.whitehole.smg.object; -import java.util.ArrayList; -import java.util.List; -import whitehole.PropertyGrid; -import whitehole.Whitehole; -import whitehole.smg.Bcsv; -import whitehole.smg.LevelObject; -import whitehole.smg.ZoneArchive; -import whitehole.vectors.Vector3; +import com.aurum.whitehole.swing.PropertyGrid; +import com.aurum.whitehole.smg.Bcsv; +import com.aurum.whitehole.smg.ZoneArchive; +import com.aurum.whitehole.vectors.Vector3; -public class GeneralObject extends LevelObject -{ - public GeneralObject(ZoneArchive zone, String filepath, Bcsv.Entry entry) - { +public class LevelObj extends AbstractObj { + public LevelObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) { this.zone = zone; String[] stuff = filepath.split("/"); directory = stuff[0]; @@ -36,18 +30,17 @@ public GeneralObject(ZoneArchive zone, String filepath, Bcsv.Entry entry) data = entry; name = (String)data.get("name"); - loadDBInfo(); renderer = null; - uniqueID = -1; + loadDBInfo(); + position = new Vector3((float)data.get("pos_x"), (float)data.get("pos_y"), (float)data.get("pos_z")); rotation = new Vector3((float)data.get("dir_x"), (float)data.get("dir_y"), (float)data.get("dir_z")); scale = new Vector3((float)data.get("scale_x"), (float)data.get("scale_y"), (float)data.get("scale_z")); } - public GeneralObject(ZoneArchive zone, String filepath, int game, String objname, Vector3 pos) - { + public LevelObj(ZoneArchive zone, String filepath, int game, String objname, Vector3 pos) { this.zone = zone; String[] stuff = filepath.split("/"); directory = stuff[0]; @@ -57,12 +50,11 @@ public GeneralObject(ZoneArchive zone, String filepath, int game, String objname data = new Bcsv.Entry(); name = objname; - loadDBInfo(); - getShapeModels(); renderer = null; - uniqueID = -1; + loadDBInfo(); + position = pos; rotation = new Vector3(0f, 0f, 0f); scale = new Vector3(1f, 1f, 1f); @@ -89,10 +81,7 @@ public GeneralObject(ZoneArchive zone, String filepath, int game, String objname data.put("CameraSetId", -1); data.put("CastId", -1); data.put("ViewGroupId", -1); - if (name.equals("PlantA") || name.equals("PlantB") || name.equals("PlantC")|| name.equals("PlantD") || name.equals("MarinePlant")) - data.put("ShapeModelNo", choicesShapeModelNo.get(0).shortValue()); - else - data.put("ShapeModelNo", (short)-1); + data.put("ShapeModelNo", (short)-1); data.put("CommonPath_ID", (short)-1); data.put("ClippingGroupId", (short)-1); data.put("GroupId", (short)-1); @@ -100,32 +89,19 @@ public GeneralObject(ZoneArchive zone, String filepath, int game, String objname data.put("MapParts_ID", (short)-1); data.put("MessageId", -1); - switch (ZoneArchive.gameMask) { - case 1: - data.put("SW_SLEEP", -1); - break; - case 2: - data.put("SW_AWAKE", -1); - data.put("SW_PARAM", -1); - data.put("ParamScale", 1f); - data.put("Obj_ID", (short)-1); - data.put("GeneratorID", (short)-1); - break; + if (ZoneArchive.game == 1) + data.put("SW_SLEEP", -1); + if (ZoneArchive.game == 2) { + data.put("SW_AWAKE", -1); + data.put("SW_PARAM", -1); + data.put("ParamScale", 1f); + data.put("Obj_ID", (short)-1); + data.put("GeneratorID", (short)-1); } } @Override - public void getShapeModels() { - choicesShapeModelNo = new ArrayList<>(); - for (int shapeno = 0 ; shapeno < 100 ; shapeno++) { - if (Whitehole.game.filesystem.fileExists("/ObjectData/" + name + String.format("%1$02d",shapeno) + ".arc")) - choicesShapeModelNo.add(shapeno); - } - } - - @Override - public void save() - { + public void save() { data.put("name", name); data.put("pos_x", position.x); data.put("pos_y", position.y); data.put("pos_z", position.z); data.put("dir_x", rotation.x); data.put("dir_y", rotation.y); data.put("dir_z", rotation.z); @@ -133,10 +109,8 @@ public void save() } @Override - public void getProperties(PropertyGrid panel) - { - getShapeModels(); - panel.addCategory("obj_position", "Position"); + public void getProperties(PropertyGrid panel) { + panel.addCategory("obj_rendering", "Rendering"); panel.addField("pos_x", "X position", "float", null, position.x, "Default"); panel.addField("pos_y", "Y position", "float", null, position.y, "Default"); panel.addField("pos_z", "Z position", "float", null, position.z, "Default"); @@ -146,59 +120,54 @@ public void getProperties(PropertyGrid panel) panel.addField("scale_x", "X scale", "float", null, scale.x, "Default"); panel.addField("scale_y", "Y scale", "float", null, scale.y, "Default"); panel.addField("scale_z", "Z scale", "float", null, scale.z, "Default"); - if (ZoneArchive.gameMask == 2) - panel.addField("ParamScale", "ParamScale", "float", null, data.get("ParamScale"), "Default"); + + panel.addCategory("obj_settings", "Settings"); + panel.addField("l_id", "ID", "int", null, data.get("l_id"), "Default"); + panel.addField("MessageId", "Message ID", "int", null, data.get("MessageId"), "Default"); + panel.addField("CameraSetId", "Camera ID", "int", null, data.get("CameraSetId"), "Default"); + panel.addField("CommonPath_ID", "Path ID", "int", null, data.get("CommonPath_ID"), "Default"); + panel.addField("ShapeModelNo", "Model No.", "int", null, data.get("ShapeModelNo"), "Default"); + if (ZoneArchive.game == 2) + panel.addField("ParamScale", "Speed Scale", "float", null, data.get("ParamScale"), "Default"); - panel.addCategory("obj_args", "Object arguments"); - panel.addField("Obj_arg0", "Obj_arg0", "int", null, data.get("Obj_arg0"), "Default"); - panel.addField("Obj_arg1", "Obj_arg1", "int", null, data.get("Obj_arg1"), "Default"); - panel.addField("Obj_arg2", "Obj_arg2", "int", null, data.get("Obj_arg2"), "Default"); - panel.addField("Obj_arg3", "Obj_arg3", "int", null, data.get("Obj_arg3"), "Default"); - panel.addField("Obj_arg4", "Obj_arg4", "int", null, data.get("Obj_arg4"), "Default"); - panel.addField("Obj_arg5", "Obj_arg5", "int", null, data.get("Obj_arg5"), "Default"); - panel.addField("Obj_arg6", "Obj_arg6", "int", null, data.get("Obj_arg6"), "Default"); - panel.addField("Obj_arg7", "Obj_arg7", "int", null, data.get("Obj_arg7"), "Default"); + panel.addCategory("obj_args", "Arguments"); + panel.addField("Obj_arg0", dbInfo.getFieldString(0), "int", null, data.get("Obj_arg0"), "Default"); + panel.addField("Obj_arg1", dbInfo.getFieldString(1), "int", null, data.get("Obj_arg1"), "Default"); + panel.addField("Obj_arg2", dbInfo.getFieldString(2), "int", null, data.get("Obj_arg2"), "Default"); + panel.addField("Obj_arg3", dbInfo.getFieldString(3), "int", null, data.get("Obj_arg3"), "Default"); + panel.addField("Obj_arg4", dbInfo.getFieldString(4), "int", null, data.get("Obj_arg4"), "Default"); + panel.addField("Obj_arg5", dbInfo.getFieldString(5), "int", null, data.get("Obj_arg5"), "Default"); + panel.addField("Obj_arg6", dbInfo.getFieldString(6), "int", null, data.get("Obj_arg6"), "Default"); + panel.addField("Obj_arg7", dbInfo.getFieldString(7), "int", null, data.get("Obj_arg7"), "Default"); panel.addCategory("obj_eventinfo", "Switches"); panel.addField("SW_APPEAR", "SW_APPEAR", "int", null, data.get("SW_APPEAR"), "Default"); panel.addField("SW_DEAD", "SW_DEAD", "int", null, data.get("SW_DEAD"), "Default"); panel.addField("SW_A", "SW_A", "int", null, data.get("SW_A"), "Default"); panel.addField("SW_B", "SW_B", "int", null, data.get("SW_B"), "Default"); - if (ZoneArchive.gameMask == 1) { + if (ZoneArchive.game == 1) panel.addField("SW_SLEEP", "SW_SLEEP", "int", null, data.get("SW_SLEEP"), "Default"); - } - if (ZoneArchive.gameMask == 2) { + if (ZoneArchive.game == 2) { panel.addField("SW_AWAKE", "SW_AWAKE", "int", null, data.get("SW_AWAKE"), "Default"); panel.addField("SW_PARAM", "SW_PARAM", "int", null, data.get("SW_PARAM"), "Default"); } - - panel.addCategory("obj_objinfo", "Other"); - panel.addField("l_id", "l_id", "int", null, data.get("l_id"), "Default"); - panel.addField("MessageId", "MessageId", "int", null, data.get("MessageId"), "Default"); - panel.addField("CameraSetId", "CameraSetId", "int", null, data.get("CameraSetId"), "Default"); - panel.addField("CastId", "CastId", "int", null, data.get("CastId"), "Default"); - panel.addField("ViewGroupId", "ViewGroupId", "int", null, data.get("ViewGroupId"), "Default"); - if (!choicesShapeModelNo.isEmpty()) - panel.addField("ShapeModelNo", "ShapeModelNo", "list", choicesShapeModelNo, data.get("ShapeModelNo"), "Default"); - else - panel.addField("ShapeModelNo", "ShapeModelNo", "int", null, data.get("ShapeModelNo"), "Default"); - panel.addField("CommonPath_ID", "CommonPath_ID", "int", null, data.get("CommonPath_ID"), "Default"); - panel.addField("ClippingGroupId", "ClippingGroupId", "int", null, data.get("ClippingGroupId"), "Default"); - panel.addField("GroupId", "GroupId", "int", null, data.get("GroupId"), "Default"); - panel.addField("DemoGroupId", "DemoGroupId", "int", null, data.get("DemoGroupId"), "Default"); - panel.addField("MapParts_ID", "MapParts_ID", "int", null, data.get("MapParts_ID"), "Default"); - if (ZoneArchive.gameMask == 2) { + + panel.addCategory("obj_groups", "Groups"); + panel.addField("GroupId", "Group ID", "int", null, data.get("GroupId"), "Default"); + panel.addField("ViewGroupId", "View Group ID", "int", null, data.get("ViewGroupId"), "Default"); + panel.addField("ClippingGroupId", "Clipping Group ID", "int", null, data.get("ClippingGroupId"), "Default"); + panel.addField("DemoGroupId", "Cutscene Group ID", "int", null, data.get("DemoGroupId"), "Default"); + panel.addField("CastId", "Cast Group ID", "int", null, data.get("CastId"), "Default"); + panel.addField("MapParts_ID", "MapParts Group ID", "int", null, data.get("MapParts_ID"), "Default"); + if (ZoneArchive.game == 2) { + panel.addField("GeneratorID", "Parent Group ID", "int", null, data.get("GeneratorID"), "Default"); panel.addField("Obj_ID", "Obj_ID", "int", null, data.get("Obj_ID"), "Default"); - panel.addField("GeneratorID", "GeneratorID", "int", null, data.get("GeneratorID"), "Default"); } } @Override - public String toString() - { + public String toString() { String l = layer.equals("common") ? "Common" : "Layer"+layer.substring(5).toUpperCase(); return dbInfo.name + " [" + l + "]"; } - - public List choicesShapeModelNo; -} +} \ No newline at end of file diff --git a/src/whitehole/smg/object/MapPartObj.java b/src/com/aurum/whitehole/smg/object/MapPartObj.java similarity index 69% rename from src/whitehole/smg/object/MapPartObj.java rename to src/com/aurum/whitehole/smg/object/MapPartObj.java index 198c914..147bd0a 100644 --- a/src/whitehole/smg/object/MapPartObj.java +++ b/src/com/aurum/whitehole/smg/object/MapPartObj.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,18 +13,15 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.smg.object; +package com.aurum.whitehole.smg.object; -import whitehole.PropertyGrid; -import whitehole.smg.Bcsv; -import whitehole.smg.LevelObject; -import whitehole.smg.ZoneArchive; -import whitehole.vectors.Vector3; +import com.aurum.whitehole.swing.PropertyGrid; +import com.aurum.whitehole.smg.Bcsv; +import com.aurum.whitehole.smg.ZoneArchive; +import com.aurum.whitehole.vectors.Vector3; -public class MapPartObj extends LevelObject -{ - public MapPartObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) - { +public class MapPartObj extends AbstractObj { + public MapPartObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) { this.zone = zone; String[] stuff = filepath.split("/"); directory = stuff[0]; @@ -34,18 +31,17 @@ public MapPartObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) data = entry; name = (String)data.get("name"); - loadDBInfo(); renderer = null; - uniqueID = -1; + loadDBInfo(); + position = new Vector3((float)data.get("pos_x"), (float)data.get("pos_y"), (float)data.get("pos_z")); rotation = new Vector3((float)data.get("dir_x"), (float)data.get("dir_y"), (float)data.get("dir_z")); scale = new Vector3((float)data.get("scale_x"), (float)data.get("scale_y"), (float)data.get("scale_z")); } - public MapPartObj(ZoneArchive zone, String filepath, int game, String objname, Vector3 pos) - { + public MapPartObj(ZoneArchive zone, String filepath, int game, String objname, Vector3 pos) { this.zone = zone; String[] stuff = filepath.split("/"); directory = stuff[0]; @@ -55,11 +51,11 @@ public MapPartObj(ZoneArchive zone, String filepath, int game, String objname, V data = new Bcsv.Entry(); name = objname; - loadDBInfo(); renderer = null; - uniqueID = -1; + loadDBInfo(); + position = pos; rotation = new Vector3(0f, 0f, 0f); scale = new Vector3(1f, 1f, 1f); @@ -97,27 +93,23 @@ public MapPartObj(ZoneArchive zone, String filepath, int game, String objname, V data.put("RotateType", 0); data.put("ShadowType", 0); data.put("SignMotionType", 0); - data.put("PressType", -1); + data.put("PressType", 0); data.put("FarClip", -1); - switch (ZoneArchive.gameMask) { - case 1: - data.put("SW_SLEEP", -1); - break; - case 2: - data.put("SW_AWAKE", -1); - data.put("SW_PARAM", -1); - data.put("ParamScale", 1f); - data.put("ParentId", (short)-1); - data.put("MapParts_ID", (short)-1); - data.put("Obj_ID", (short)-1); - break; + if (ZoneArchive.game == 1) + data.put("SW_SLEEP", -1); + if (ZoneArchive.game == 2) { + data.put("SW_AWAKE", -1); + data.put("SW_PARAM", -1); + data.put("ParamScale", 1f); + data.put("ParentId", (short)-1); + data.put("MapParts_ID", (short)-1); + data.put("Obj_ID", (short)-1); } } @Override - public void save() - { + public void save() { data.put("name", name); data.put("pos_x", position.x); data.put("pos_y", position.y); data.put("pos_z", position.z); data.put("dir_x", rotation.x); data.put("dir_y", rotation.y); data.put("dir_z", rotation.z); @@ -125,9 +117,8 @@ public void save() } @Override - public void getProperties(PropertyGrid panel) - { - panel.addCategory("obj_position", "Position"); + public void getProperties(PropertyGrid panel) { + panel.addCategory("obj_rendering", "Rendering"); panel.addField("pos_x", "X position", "float", null, position.x, "Default"); panel.addField("pos_y", "Y position", "float", null, position.y, "Default"); panel.addField("pos_z", "Z position", "float", null, position.z, "Default"); @@ -137,28 +128,16 @@ public void getProperties(PropertyGrid panel) panel.addField("scale_x", "X scale", "float", null, scale.x, "Default"); panel.addField("scale_y", "Y scale", "float", null, scale.y, "Default"); panel.addField("scale_z", "Z scale", "float", null, scale.z, "Default"); - if (ZoneArchive.gameMask == 2) + if (ZoneArchive.game == 2) panel.addField("ParamScale", "ParamScale", "float", null, data.get("ParamScale"), "Default"); - - panel.addCategory("obj_args", "Object arguments"); - panel.addField("Obj_arg0", "Obj_arg0", "int", null, data.get("Obj_arg0"), "Default"); - panel.addField("Obj_arg1", "Obj_arg1", "int", null, data.get("Obj_arg1"), "Default"); - panel.addField("Obj_arg2", "Obj_arg2", "int", null, data.get("Obj_arg2"), "Default"); - panel.addField("Obj_arg3", "Obj_arg3", "int", null, data.get("Obj_arg3"), "Default"); - panel.addCategory("obj_eventinfo", "Switches"); - panel.addField("SW_APPEAR", "SW_APPEAR", "int", null, data.get("SW_APPEAR"), "Default"); - panel.addField("SW_DEAD", "SW_DEAD", "int", null, data.get("SW_DEAD"), "Default"); - panel.addField("SW_A", "SW_A", "int", null, data.get("SW_A"), "Default"); - panel.addField("SW_B", "SW_B", "int", null, data.get("SW_B"), "Default"); - if (ZoneArchive.gameMask == 1) - panel.addField("SW_SLEEP", "SW_SLEEP", "int", null, data.get("SW_SLEEP"), "Default"); - if (ZoneArchive.gameMask == 2) { - panel.addField("SW_AWAKE", "SW_AWAKE", "int", null, data.get("SW_AWAKE"), "Default"); - panel.addField("SW_PARAM", "SW_PARAM", "int", null, data.get("SW_PARAM"), "Default"); - } + panel.addCategory("obj_settings", "Settings"); + panel.addField("l_id", "ID", "int", null, data.get("l_id"), "Default"); + panel.addField("CameraSetId", "Camera ID", "int", null, data.get("CameraSetId"), "Default"); + panel.addField("CommonPath_ID", "Path ID", "int", null, data.get("CommonPath_ID"), "Default"); + panel.addField("ShapeModelNo", "Model No.", "int", null, data.get("ShapeModelNo"), "Default"); - panel.addCategory("obj_mappartsinfo", "MapPart settings"); + panel.addCategory("obj_mappartsinfo", "MapPart"); panel.addField("MoveConditionType", "MoveConditionType", "int", null, data.get("MoveConditionType"), "Default"); panel.addField("RotateSpeed", "RotateSpeed", "int", null, data.get("RotateSpeed"), "Default"); panel.addField("RotateAngle", "RotateAngle", "int", null, data.get("RotateAngle"), "Default"); @@ -171,27 +150,40 @@ public void getProperties(PropertyGrid panel) panel.addField("PressType", "PressType", "int", null, data.get("PressType"), "Default"); panel.addField("FarClip", "FarClip", "int", null, data.get("FarClip"), "Default"); - panel.addCategory("obj_objinfo", "Other"); - panel.addField("l_id", "l_id", "int", null, data.get("l_id"), "Default"); - panel.addField("CameraSetId", "CameraSetId", "int", null, data.get("CameraSetId"), "Default"); - panel.addField("CastId", "CastId", "int", null, data.get("CastId"), "Default"); - panel.addField("ViewGroupId", "ViewGroupId", "int", null, data.get("ViewGroupId"), "Default"); - panel.addField("ShapeModelNo", "ShapeModelNo", "int", null, data.get("ShapeModelNo"), "Default"); - panel.addField("CommonPath_ID", "CommonPath_ID", "int", null, data.get("CommonPath_ID"), "Default"); - panel.addField("ClippingGroupId", "ClippingGroupId", "int", null, data.get("ClippingGroupId"), "Default"); - panel.addField("GroupId", "GroupId", "int", null, data.get("GroupId"), "Default"); - panel.addField("DemoGroupId", "DemoGroupId", "int", null, data.get("DemoGroupId"), "Default"); - if (ZoneArchive.gameMask == 2) { - panel.addField("MapParts_ID", "MapParts_ID", "int", null, data.get("MapParts_ID"), "Default"); + panel.addCategory("obj_args", "Arguments"); + panel.addField("Obj_arg0", dbInfo.getFieldString(0), "int", null, data.get("Obj_arg0"), "Default"); + panel.addField("Obj_arg1", dbInfo.getFieldString(1), "int", null, data.get("Obj_arg1"), "Default"); + panel.addField("Obj_arg2", dbInfo.getFieldString(2), "int", null, data.get("Obj_arg2"), "Default"); + panel.addField("Obj_arg3", dbInfo.getFieldString(3), "int", null, data.get("Obj_arg3"), "Default"); + + panel.addCategory("obj_switches", "Switches"); + panel.addField("SW_APPEAR", "SW_APPEAR", "int", null, data.get("SW_APPEAR"), "Default"); + panel.addField("SW_DEAD", "SW_DEAD", "int", null, data.get("SW_DEAD"), "Default"); + panel.addField("SW_A", "SW_A", "int", null, data.get("SW_A"), "Default"); + panel.addField("SW_B", "SW_B", "int", null, data.get("SW_B"), "Default"); + if (ZoneArchive.game == 1) + panel.addField("SW_SLEEP", "SW_SLEEP", "int", null, data.get("SW_SLEEP"), "Default"); + if (ZoneArchive.game == 2) { + panel.addField("SW_AWAKE", "SW_AWAKE", "int", null, data.get("SW_AWAKE"), "Default"); + panel.addField("SW_PARAM", "SW_PARAM", "int", null, data.get("SW_PARAM"), "Default"); + } + + panel.addCategory("obj_groups", "Groups"); + panel.addField("GroupId", "Group ID", "int", null, data.get("GroupId"), "Default"); + panel.addField("ViewGroupId", "View Group ID", "int", null, data.get("ViewGroupId"), "Default"); + panel.addField("ClippingGroupId", "Clipping Group ID", "int", null, data.get("ClippingGroupId"), "Default"); + panel.addField("DemoGroupId", "Cutscene Group ID", "int", null, data.get("DemoGroupId"), "Default"); + panel.addField("CastId", "Cast Group ID", "int", null, data.get("CastId"), "Default"); + if (ZoneArchive.game == 2) { + panel.addField("MapParts_ID", "MapParts Group ID", "int", null, data.get("MapParts_ID"), "Default"); + panel.addField("ParentId", "Parent Group ID", "int", null, data.get("ParentId"), "Default"); panel.addField("Obj_ID", "Obj_ID", "int", null, data.get("Obj_ID"), "Default"); - panel.addField("ParentId", "ParentId", "int", null, data.get("ParentId"), "Default"); } } @Override - public String toString() - { + public String toString() { String l = layer.equals("common") ? "Common" : "Layer"+layer.substring(5).toUpperCase(); return dbInfo.name + " [" + l + "]"; } -} +} \ No newline at end of file diff --git a/src/com/aurum/whitehole/smg/object/PathObj.java b/src/com/aurum/whitehole/smg/object/PathObj.java new file mode 100644 index 0000000..1ba549d --- /dev/null +++ b/src/com/aurum/whitehole/smg/object/PathObj.java @@ -0,0 +1,296 @@ +/* + © 2012 - 2017 - Whitehole Team + + Whitehole is free software: you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + Whitehole is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with Whitehole. If not, see http://www.gnu.org/licenses/. +*/ + +package com.aurum.whitehole.smg.object; + +import java.io.IOException; +import java.util.Iterator; +import java.util.LinkedHashMap; +import com.aurum.whitehole.rendering.GLRenderer; +import com.aurum.whitehole.smg.Bcsv; +import com.aurum.whitehole.smg.ZoneArchive; +import com.aurum.whitehole.vectors.Color4; +import com.aurum.whitehole.vectors.Vector3; +import java.util.Random; +import javax.media.opengl.*; + +public class PathObj { + public PathObj(ZoneArchive zone, int idx) { + this.zone = zone; + + data = new Bcsv.Entry(); + uniqueID = -1; + + index = idx; + pathID = 0; + + generateColor(); + + points = new LinkedHashMap(); + displayLists = null; + + name = "Path " + index; + data.put("name", name); + data.put("type", "Bezier"); + data.put("closed", "OPEN"); + data.put("num_pnt", 0); + data.put("l_id", pathID); + data.put("path_arg0", -1); + data.put("path_arg1", -1); + data.put("path_arg2", -1); + data.put("path_arg3", -1); + data.put("path_arg4", -1); + data.put("path_arg5", -1); + data.put("path_arg6", -1); + data.put("path_arg7", -1); + data.put("usage", "General"); + data.put("no", (short)index); + data.put("Path_ID", (short)-1); + } + + public PathObj(ZoneArchive zone, Bcsv.Entry entry) { + this.zone = zone; + + data = entry; + uniqueID = -1; + + name = (String) data.get("name"); + index = (short) data.get("no"); + pathID = (int) data.get("l_id"); + + generateColor(); + + try { + Bcsv pointsfile = new Bcsv(zone.mapArc.openFile(String.format("/Stage/Jmp/Path/CommonPathPointInfo.%1$d", index))); + + points = new LinkedHashMap(); + + for (Bcsv.Entry pt : pointsfile.entries) { + PathPointObj ptobj = new PathPointObj(this, pt); + points.put(ptobj.index, ptobj); + } + + pointsfile.close(); + } + catch (IOException ex) { + System.out.println(String.format("Failed to load path points for path %1$d: %2$s", index, ex.getMessage())); + points.clear(); + } + + this.displayLists = null; + } + + public void save() { + data.put("name", name); + data.put("no", (short) index); + data.put("l_id", pathID); + data.put("num_pnt", points.size()); + + try { + deleteStorage(); + createStorage(); + Bcsv pointsfile = new Bcsv(zone.mapArc.openFile(String.format("/Stage/Jmp/Path/CommonPathPointInfo.%1$d", index))); + pointsfile.entries.clear(); + for (PathPointObj ptobj : points.values()) { + ptobj.save(); + pointsfile.entries.add(ptobj.data); + } + pointsfile.save(); + pointsfile.close(); + } + catch (IOException ex) { + System.out.println(String.format("Failed to save path points for path %1$d: %2$s", index, ex.getMessage())); + } + } + + public void createStorage() { + String filename = String.format("/Stage/Jmp/Path/CommonPathPointInfo.%1$d", index); + if (this.zone.mapArc.fileExists(filename)) + return; + + try { + zone.mapArc.createFile(filename.substring(0, filename.lastIndexOf("/")), filename.substring(filename.lastIndexOf("/") + 1)); + Bcsv pointsfile = new Bcsv(zone.mapArc.openFile(filename)); + + pointsfile.addField("point_arg0", 36, 0, -1, 0, 0); + pointsfile.addField("point_arg1", 40, 0, -1, 0, 0); + pointsfile.addField("point_arg2", 44, 0, -1, 0, 0); + pointsfile.addField("point_arg3", 48, 0, -1, 0, 0); + pointsfile.addField("point_arg4", 52, 0, -1, 0, 0); + pointsfile.addField("point_arg5", 56, 0, -1, 0, 0); + pointsfile.addField("point_arg6", 60, 0, -1, 0, 0); + pointsfile.addField("point_arg7", 64, 0, -1, 0, 0); + pointsfile.addField("pnt0_x", 0, 2, -1, 0, 0f); + pointsfile.addField("pnt0_y", 4, 2, -1, 0, 0f); + pointsfile.addField("pnt0_z", 8, 2, -1, 0, 0f); + pointsfile.addField("pnt1_x", 12, 2, -1, 0, 0f); + pointsfile.addField("pnt1_y", 16, 2, -1, 0, 0f); + pointsfile.addField("pnt1_z", 20, 2, -1, 0, 0f); + pointsfile.addField("pnt2_x", 24, 2, -1, 0, 0f); + pointsfile.addField("pnt2_y", 28, 2, -1, 0, 0f); + pointsfile.addField("pnt2_z", 32, 2, -1, 0, 0f); + pointsfile.addField("id", 68, 4, 65535, 0, (short) 0); + + pointsfile.save(); + pointsfile.close(); + } + catch (IOException ex) { + System.out.println(String.format("Failed to create new storage for path %1$d: %2$s", index, ex.getMessage())); + } + } + + public void deleteStorage() { + String filename = String.format("/Stage/Jmp/Path/CommonPathPointInfo.%1$d", index); + if (zone.mapArc.fileExists(filename)) { + zone.mapArc.deleteFile(filename); + } + } + + public void prerender(GLRenderer.RenderInfo info) { + GL2 gl = info.drawable.getGL().getGL2(); + + if (displayLists == null) { + displayLists = new int[2]; + displayLists[0] = gl.glGenLists(1); + displayLists[1] = gl.glGenLists(1); + } + + gl.glNewList(displayLists[0], 4864); + info.renderMode = GLRenderer.RenderMode.PICKING; + + Color4 dummy = new Color4(); + for (PathPointObj point : points.values()) { + point.render(info, dummy, 1); + point.render(info, dummy, 2); + point.render(info, dummy, 0); + } + + gl.glEndList(); + gl.glNewList(this.displayLists[1], 4864); + info.renderMode = GLRenderer.RenderMode.OPAQUE; + + for (int i = 0; i < 8; i++) { + gl.glActiveTexture(33984 + i); + gl.glDisable(3553); + } + + gl.glDepthFunc(515); + gl.glDepthMask(true); + gl.glDisable(2896); + gl.glEnable(3042); + gl.glBlendFunc(768, 769); + gl.glDisable(3058); + gl.glDisable(3008); + + try { + gl.glUseProgram(0); + } + catch (GLException ex) {} + + gl.glEnable(2832); + gl.glHint(3153, 4354); + + for (PathPointObj point : points.values()) { + point.render(info, color, 1); + point.render(info, color, 2); + point.render(info, color, 0); + + gl.glColor4f(color.r, color.g, color.b, color.a); + gl.glLineWidth(1.0F); + gl.glBegin(3); + gl.glVertex3f(point.point1.x, point.point1.y, point.point1.z); + gl.glVertex3f(point.position.x, point.position.y, point.position.z); + gl.glVertex3f(point.point2.x, point.point2.y, point.point2.z); + gl.glEnd(); + } + + gl.glColor4f(color.r, color.g, color.b, color.a); + + if (!points.isEmpty()) { + gl.glLineWidth(1.5F); + gl.glBegin(3); + + int end = points.size(); + if (((String)data.get("closed")).equals("CLOSE")) + end++; + + Iterator thepoints = points.values().iterator(); + PathPointObj curpoint = (PathPointObj) thepoints.next(); + Vector3 start = curpoint.position; + gl.glVertex3f(start.x, start.y, start.z); + + for (int p = 1; p < end; p++) { + Vector3 p1 = curpoint.position; + Vector3 p2 = curpoint.point2; + + if (!thepoints.hasNext()) + thepoints = points.values().iterator(); + curpoint = (PathPointObj)thepoints.next(); + + Vector3 p3 = curpoint.point1; + Vector3 p4 = curpoint.position; + + if ((Vector3.roughlyEqual(p1, p2)) && (Vector3.roughlyEqual(p3, p4))) { + gl.glVertex3f(p4.x, p4.y, p4.z); + } + else { + float step = 0.01F; + + for (float t = step; t < 1.0F; t += step) { + float p1t = (1.0F - t) * (1.0F - t) * (1.0F - t); + float p2t = 3.0F * t * (1.0F - t) * (1.0F - t); + float p3t = 3.0F * t * t * (1.0F - t); + float p4t = t * t * t; + + gl.glVertex3f(p1.x * p1t + p2.x * p2t + p3.x * p3t + p4.x * p4t, p1.y * p1t + p2.y * p2t + p3.y * p3t + p4.y * p4t, p1.z * p1t + p2.z * p2t + p3.z * p3t + p4.z * p4t); + } + } + } + } + gl.glEnd(); + gl.glEndList(); + } + + public void render(GLRenderer.RenderInfo info) { + if (info.renderMode == GLRenderer.RenderMode.TRANSLUCENT) + return; + + GL2 gl = info.drawable.getGL().getGL2(); + gl.glCallList(displayLists[info.renderMode.ordinal()]); + } + + private void generateColor() { + int hex = (~RANDOM.nextInt() + index) & 0xFFFFFF; + float r = ((hex >> 16) & 0xFF) / 255f; + float g = ((hex >> 8) & 0xFF) / 255f; + float b = (hex & 0xFF) / 255f; + color = new Color4(r, g, b, 1f); + } + + @Override + public String toString() { + return String.format("[%1$d] %2$s", index, name); + } + + private static final Random RANDOM = new Random(); + + private Color4 color; + public ZoneArchive zone; + public Bcsv.Entry data; + public int[] displayLists; + public int uniqueID, index, pathID; + public String name; + public LinkedHashMap points; +} \ No newline at end of file diff --git a/src/com/aurum/whitehole/smg/object/PathPointObj.java b/src/com/aurum/whitehole/smg/object/PathPointObj.java new file mode 100644 index 0000000..8a0ab78 --- /dev/null +++ b/src/com/aurum/whitehole/smg/object/PathPointObj.java @@ -0,0 +1,180 @@ +/* + © 2012 - 2017 - Whitehole Team + + Whitehole is free software: you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + Whitehole is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with Whitehole. If not, see http://www.gnu.org/licenses/. +*/ + +package com.aurum.whitehole.smg.object; + +import com.aurum.whitehole.swing.PropertyGrid; +import com.aurum.whitehole.rendering.ColorCubeRenderer; +import com.aurum.whitehole.rendering.GLRenderer; +import com.aurum.whitehole.smg.Bcsv; +import com.aurum.whitehole.vectors.Color4; +import com.aurum.whitehole.vectors.Vector3; +import java.util.ArrayList; +import java.util.List; +import javax.media.opengl.*; + +public class PathPointObj extends AbstractObj { + public PathPointObj(PathObj path, int index, Vector3 pos) { + this.path = path; + this.index = index; + + zone = path.zone; + layer = "common"; + + data = new Bcsv.Entry(); + uniqueID = -1; + + position = pos; + point1 = (Vector3) pos.clone(); + point2 = (Vector3) pos.clone(); + + displayLists = null; + + data.put("point_arg0", -1); + data.put("point_arg1", -1); + data.put("point_arg2", -1); + data.put("point_arg3", -1); + data.put("point_arg4", -1); + data.put("point_arg5", -1); + data.put("point_arg6", -1); + data.put("point_arg7", -1); + + data.put("pnt0_x", position.x); data.put("pnt0_y", position.y); data.put("pnt0_z", position.z); + data.put("pnt1_x", point1.x); data.put("pnt1_y", point1.y); data.put("pnt1_z", point1.z); + data.put("pnt2_x", point2.x); data.put("pnt2_y", point2.y); data.put("pnt2_z", point2.z); + + data.put("id", (short)index); + } + + public PathPointObj(PathObj path, Bcsv.Entry entry) { + this.path = path; + + zone = path.zone; + layer = "common"; + + data = entry; + uniqueID = -1; + + index = (short)data.get("id"); + position = new Vector3((float)data.get("pnt0_x"), (float)data.get("pnt0_y"), (float)data.get("pnt0_z")); + point1 = new Vector3((float)data.get("pnt1_x"), (float)data.get("pnt1_y"), (float)data.get("pnt1_z")); + point2 = new Vector3((float)data.get("pnt2_x"), (float)data.get("pnt2_y"), (float)data.get("pnt2_z")); + + displayLists = null; + } + + @Override + public void save() { + data.put("id", (short) index); + data.put("pnt0_x", position.x); data.put("pnt0_y", position.y); data.put("pnt0_z", position.z); + data.put("pnt1_x", point1.x); data.put("pnt1_y", point1.y); data.put("pnt1_z", point1.z); + data.put("pnt2_x", point2.x); data.put("pnt2_y", point2.y); data.put("pnt2_z", point2.z); + } + + @Override + public void initRenderer(GLRenderer.RenderInfo info) {} + + @Override + public void closeRenderer(GLRenderer.RenderInfo info) {} + + public void render(GLRenderer.RenderInfo info, Color4 color, int pointno) { + if (info.renderMode == GLRenderer.RenderMode.TRANSLUCENT) return; + + GL2 gl = info.drawable.getGL().getGL2(); + + Vector3 pt; + switch (pointno) { + case 0: + pt = position; + break; + case 1: + pt = point1; + break; + default: + pt = point2; + break; + } + + if (info.renderMode == GLRenderer.RenderMode.PICKING) { + int uniqueid = (uniqueID << 3) + pointno; + gl.glColor4ub( + (byte)(uniqueid >>> 16), + (byte)(uniqueid >>> 8), + (byte)uniqueid, + (byte)0xFF); + } + + gl.glPushMatrix(); + gl.glTranslatef(pt.x, pt.y, pt.z); + + ColorCubeRenderer cube = new ColorCubeRenderer(pointno==0 ? 100f : 50f, new Color4(1f,1f,1f,1f), color, false); + cube.render(info); + + gl.glPopMatrix(); + } + + @Override + public void getProperties(PropertyGrid panel) { + panel.addCategory("path_settings", "Path settings"); + panel.addField("[P]num", "Path ID", "noedit", null, path.index, "Default"); + panel.addField("[P]l_id", "ID", "int", null, path.pathID, "Default"); + panel.addField("[P]closed", "Closed", "bool", null, path.data.get("closed").equals("CLOSE"), "Default"); + panel.addField("[P]usage", "Usage", "list", choiceUsage, path.data.get("usage"), "Default"); + panel.addField("[P]name", "Name", "text", null, path.data.get("name"), "Default"); + + panel.addCategory("path_args", "Path arguments"); + panel.addField("[P]path_arg0", "path_arg0", "int", null, path.data.get("path_arg0"), "Default"); + panel.addField("[P]path_arg1", "path_arg1", "int", null, path.data.get("path_arg1"), "Default"); + panel.addField("[P]path_arg2", "path_arg2", "int", null, path.data.get("path_arg2"), "Default"); + panel.addField("[P]path_arg3", "path_arg3", "int", null, path.data.get("path_arg3"), "Default"); + panel.addField("[P]path_arg4", "path_arg4", "int", null, path.data.get("path_arg4"), "Default"); + panel.addField("[P]path_arg5", "path_arg5", "int", null, path.data.get("path_arg5"), "Default"); + panel.addField("[P]path_arg6", "path_arg6", "int", null, path.data.get("path_arg6"), "Default"); + panel.addField("[P]path_arg7", "path_arg7", "int", null, path.data.get("path_arg7"), "Default"); + + panel.addCategory("point_coords", "Point coordinates"); + panel.addField("pnt0_x", "X", "float", null, position.x, "Default"); + panel.addField("pnt0_y", "Y", "float", null, position.y, "Default"); + panel.addField("pnt0_z", "Z", "float", null, position.z, "Default"); + panel.addField("pnt1_x", "Control 1 X", "float", null, point1.x, "Default"); + panel.addField("pnt1_y", "Control 1 Y", "float", null, point1.y, "Default"); + panel.addField("pnt1_z", "Control 1 Z", "float", null, point1.z, "Default"); + panel.addField("pnt2_x", "Control 2 X", "float", null, point2.x, "Default"); + panel.addField("pnt2_y", "Control 2 Y", "float", null, point2.y, "Default"); + panel.addField("pnt2_z", "Control 2 Z", "float", null, point2.z, "Default"); + + panel.addCategory("point_args", "Point arguments"); + panel.addField("point_arg0", "point_arg0", "int", null, data.get("point_arg0"), "Default"); + panel.addField("point_arg1", "point_arg1", "int", null, data.get("point_arg1"), "Default"); + panel.addField("point_arg2", "point_arg2", "int", null, data.get("point_arg2"), "Default"); + panel.addField("point_arg3", "point_arg3", "int", null, data.get("point_arg3"), "Default"); + panel.addField("point_arg4", "point_arg4", "int", null, data.get("point_arg4"), "Default"); + panel.addField("point_arg5", "point_arg5", "int", null, data.get("point_arg5"), "Default"); + panel.addField("point_arg6", "point_arg6", "int", null, data.get("point_arg6"), "Default"); + panel.addField("point_arg7", "point_arg7", "int", null, data.get("point_arg7"), "Default"); + } + + @Override + public String toString() { + return String.format("Point %1$d", index); + } + + public PathObj path; + public Vector3 point1, point2; + public int index; + public int[] displayLists; + + private static List choiceUsage = new ArrayList() {{ add("General"); add("Camera"); }}; +} \ No newline at end of file diff --git a/src/com/aurum/whitehole/smg/object/PositionObj.java b/src/com/aurum/whitehole/smg/object/PositionObj.java new file mode 100644 index 0000000..7ab613d --- /dev/null +++ b/src/com/aurum/whitehole/smg/object/PositionObj.java @@ -0,0 +1,295 @@ +/* + © 2012 - 2017 - Whitehole Team + + Whitehole is free software: you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + Whitehole is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with Whitehole. If not, see http://www.gnu.org/licenses/. +*/ + +package com.aurum.whitehole.smg.object; + +import com.aurum.whitehole.swing.PropertyGrid; +import com.aurum.whitehole.smg.Bcsv; +import com.aurum.whitehole.smg.ZoneArchive; +import com.aurum.whitehole.vectors.Vector3; +import java.util.List; +import java.util.ArrayList; + +public class PositionObj extends AbstractObj { + public PositionObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) { + this.zone = zone; + String[] stuff = filepath.split("/"); + directory = stuff[0]; + layer = stuff[1].toLowerCase(); + file = stuff[2]; + + data = entry; + + name = (String)data.get("name"); + renderer = null; + uniqueID = -1; + + loadDBInfo(); + + position = new Vector3((float)data.get("pos_x"), (float)data.get("pos_y"), (float)data.get("pos_z")); + rotation = new Vector3((float)data.get("dir_x"), (float)data.get("dir_y"), (float)data.get("dir_z")); + scale = new Vector3(1,1,1); + } + + public PositionObj(ZoneArchive zone, String filepath, int game, Vector3 pos) { + this.zone = zone; + String[] stuff = filepath.split("/"); + directory = stuff[0]; + layer = stuff[1].toLowerCase(); + file = stuff[2]; + + data = new Bcsv.Entry(); + + name = "GeneralPos"; + renderer = null; + uniqueID = -1; + + loadDBInfo(); + + position = pos; + rotation = new Vector3(0f, 0f, 0f); + scale = new Vector3(1f, 1f, 1f); + + data.put("name", name); + data.put("pos_x", position.x); data.put("pos_y", position.y); data.put("pos_z", position.z); + data.put("dir_x", rotation.x); data.put("dir_y", rotation.y); data.put("dir_z", rotation.z); + data.put("PosName", "undefined"); + data.put("Obj_ID", (short)-1); + if (ZoneArchive.game == 2) + data.put("ChildObjId", (short)-1); + } + + @Override + public void save() { + data.put("name", name); + data.put("pos_x", position.x); data.put("pos_y", position.y); data.put("pos_z", position.z); + data.put("dir_x", rotation.x); data.put("dir_y", rotation.y); data.put("dir_z", rotation.z); + } + + @Override + public void getProperties(PropertyGrid panel) { + panel.addCategory("obj_rendering", "Rendering"); + panel.addField("pos_x", "X position", "float", null, position.x, "Default"); + panel.addField("pos_y", "Y position", "float", null, position.y, "Default"); + panel.addField("pos_z", "Z position", "float", null, position.z, "Default"); + panel.addField("dir_x", "X rotation", "float", null, rotation.x, "Default"); + panel.addField("dir_y", "Y rotation", "float", null, rotation.y, "Default"); + panel.addField("dir_z", "Z rotation", "float", null, rotation.z, "Default"); + + panel.addCategory("obj_position", "Position"); + panel.addField("PosName", "Position Name", "textlist", choicesPosName, data.get("PosName"), "Default"); + panel.addField("Obj_ID", "Object ID", "int", null, data.get("Obj_ID"), "Default"); + if (ZoneArchive.game == 1) + panel.addField("ChildObjId", "Child ID", "int", null, data.get("ChildObjId"), "Default"); + } + + @Override + public String toString() { + String l = layer.equals("common") ? "Common" : "Layer" + layer.substring(5).toUpperCase(); + return dbInfo.name + " (" + data.get("PosName") + ") " + "[" + l + "]"; + } + + private static List choicesPosName = new ArrayList() {{ + add("いいえ選択移動位置"); + add("アイテム惑星戻り"); + add("ウォーターバズーカマリオ位置"); + add("エピローグマリオ"); + add("カメラ基準点"); + add("ガード出現ポイント1"); + add("キノピオメッセンジャー"); + add("キングトッシンデモ開始位置"); + add("クッパ階段戦の砲弾出現"); + add("クッパJrシップ戦マリオ位置"); + add("グランドスター出現位置"); + add("グランドスター出現"); + add("グランドスター帰還リザルト"); + add("ゲート中心"); + add("ゲーム終了位置"); + add("ゲーム開始位置"); + add("コア中心"); + add("コンプリートエンディングデモ基準点"); + add("コーチチュートリアル位置"); + add("コーチレース終了後位置"); + add("コーチ2回目位置"); + add("ゴーストデモゴースト位置"); + add("ゴーストデモマリオ位置"); + add("ジュゲム突進点1"); + add("ジュゲム突進点2"); + add("スターゲットデモ座標"); + add("スタートカメラマリオ座標"); + add("スタート位置(サーフィン)"); + add("スピンドライバ初出基準点"); + add("スピンドライバ初出終了位置"); + add("タイムアタック前位置"); + add("タイムアタック後位置"); + add("ダウンデモ後(マリオ)"); + add("ダウンデモ"); + add("チュートリアル位置"); + add("デモ中心"); + add("デモ位置(クッパJr登場デモ)"); + add("ドドリュウ再セット"); + add("ドドリュウ岩"); + add("ドーム中心"); + add("ノーマルエンディングデモ基準点"); + add("ハニークイーンとの会話位置"); + add("バッタンキング基準位置"); + add("バトラーデモ終了"); + add("バトラーマップレクチャー"); + add("バトルシップ・タイムアタック前位置"); + add("バトルシップ・タイムアタック後位置"); + add("パマタリアンハンターデモ用"); + add("パワーアップデモ(クッパ)"); + add("パワーアップデモ(マリオ)"); + add("パワーアップデモLv2(クッパ)"); + add("パワーアップデモLv2(マリオ)"); + add("パワーアップデモLv3(クッパ)"); + add("パワーアップデモLv3(マリオ)"); + add("ピーチャンレーサーレース終了後位置"); + add("ピーチャン位置[スター渡し]"); + add("ピーチ登場デモ後(マリオ)"); + add("ピーチ誘拐デモ基準点"); + add("ピーチ誘拐デモ終了位置"); + add("プレイヤーデモ位置(ベビーディノパックン戦)"); + add("プレイヤーデモ位置(ベリードラゴン戦)"); + add("プレイヤー一時退避"); + add("ベビチコ出会い点"); + add("ベビーディノパックンデモ位置"); + add("ペンギン移動後"); + add("ボスジュゲムダウンデモ位置"); + add("ボスジュゲムデモ位置"); + add("ボスブッスン位置"); + add("ボス戦デモ開始位置"); + add("ポルタデモプレイヤー位置"); + add("ポルタ開始デモプレイヤー位置"); + add("マイスター位置[グランドスター帰還後]"); + add("マイスター位置[デフォルト]"); + add("マイスター位置[変化前]"); + add("マイスター位置[変化後]"); + add("マイスター位置[帰還後アイテム惑星]"); + add("マイスター位置[NPC紹介]"); + add("マリオイベント会話2"); + add("マリオイベント会話3"); + add("マリオイベント会話"); + add("マリオデモ位置"); + add("マリオボスべー対決"); + add("マリオ位置"); + add("マリオ位置00空01"); + add("マリオ位置01空00"); + add("マリオ位置02空03"); + add("マリオ位置03空00"); + add("マリオ位置04空03"); + add("マリオ位置05空02"); + add("マリオ位置06空02"); + add("マリオ位置07空04"); + add("マリオ位置08空01"); + add("マリオ位置[でしゃばりルイージ]"); + add("マリオ位置[アイテム惑星移動後]"); + add("マリオ位置[グランドスター帰還後]"); + add("マリオ位置[デモ中]"); + add("マリオ位置[デモ後]"); + add("マリオ位置[ハラペコスターピースチコ]"); + add("マリオ位置[ファイルセレクトから]"); + add("マリオ位置[ワールドマップから]"); + add("マリオ位置[再スタート]"); + add("マリオ位置[変化前]"); + add("マリオ位置[変化後]"); + add("マリオ位置[帰還後アイテム惑星]"); + add("マリオ位置[帰還後位置上]"); + add("マリオ位置[帰還]"); + add("マリオ位置[郵便屋さんイベント]"); + add("マリオ位置[NPC紹介]"); + add("マリオ再セット位置"); + add("マリオ再セット位置1"); + add("マリオ再セット位置2"); + add("マリオ再セット"); + add("マリオ再セット1"); + add("マリオ再セット2"); + add("マリオ再セット3"); + add("マリオ再セット4"); + add("マリオ最終デモ終了後位置"); + add("マリオ最終戦開始位置"); + add("マリオ移動後"); + add("マリオ顔惑星煙突出口"); + add("メラキンデモ後セット位置"); + add("メラキンマリオ再セット位置"); + add("モンテ投げターゲット位置"); + add("ヨッシー出会いデモ基準点"); + add("ヨッシー出会いデモ後マリオ位置"); + add("リスタート"); + add("ルイージ帰還"); + add("レース終了後位置テレサ"); + add("レース終了後位置"); + add("レース開始時マリオ位置"); + add("ロゼッタ状況説明マリオ"); + add("ワープ位置(サーフィン)"); + add("二脚ボス爆発デモ後座標"); + add("合体ブロック故郷点"); + add("図書室中心"); + add("子連れカメムシデモ後ポイント"); + add("惑星中心"); + add("惑星Lv2"); + add("惑星Lv3"); + add("戦闘開始(クッパ)"); + add("戦闘開始(マリオ)"); + add("朗読デモ終了"); + add("未入力"); + add("爆破デモ後マリオ"); + add("着弾点0"); + add("着弾点1"); + add("着弾点2"); + add("着弾点3"); + add("着弾点4"); + add("着弾点5"); + add("着弾点6"); + add("着弾点7"); + add("着弾点8"); + add("着弾点9"); + add("着弾点10"); + add("絵本移動ポイント000"); + add("絵本移動ポイント001"); + add("絵本移動ポイント002"); + add("落下点1"); + add("落下点2"); + add("落下点3"); + add("落下点4"); + add("落下点5"); + add("負け時マリオ位置"); + add("開始デモ"); + add("開始マリオ"); + add("階段の戦い0(クッパ)"); + add("階段の戦い1(クッパ)"); + add("階段の戦い2(クッパ)"); + add("隠れ位置"); + add("Lv1終了(クッパ)"); + add("Lv1終了(マリオ)"); + add("Lv1開始(クッパ)"); + add("Lv1開始(マリオ)"); + add("Lv2終了(クッパ)"); + add("Lv2終了(マリオ)"); + add("Lv2開始(クッパ)"); + add("Lv2開始(マリオ)"); + add("Lv3内側(クッパ)"); + add("Lv3内側(マリオ)"); + add("Lv3外側(クッパ)"); + add("Lv3外側(マリオ)"); + add("MarioDemoPos"); + add("MarioDemoPos2"); + add("MarioDemoPos3"); + add("MarioDemoPos4"); + add("TicoDemoPos1"); + add("TicoDemoPos2"); + add("TicoDemoPos3"); + }}; +} \ No newline at end of file diff --git a/src/whitehole/smg/object/SoundObj.java b/src/com/aurum/whitehole/smg/object/SoundObj.java similarity index 76% rename from src/whitehole/smg/object/SoundObj.java rename to src/com/aurum/whitehole/smg/object/SoundObj.java index 7f4595d..f1b6b66 100644 --- a/src/whitehole/smg/object/SoundObj.java +++ b/src/com/aurum/whitehole/smg/object/SoundObj.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,18 +13,15 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.smg.object; +package com.aurum.whitehole.smg.object; -import whitehole.PropertyGrid; -import whitehole.smg.Bcsv; -import whitehole.smg.LevelObject; -import whitehole.smg.ZoneArchive; -import whitehole.vectors.Vector3; +import com.aurum.whitehole.swing.PropertyGrid; +import com.aurum.whitehole.smg.Bcsv; +import com.aurum.whitehole.smg.ZoneArchive; +import com.aurum.whitehole.vectors.Vector3; -public class SoundObj extends LevelObject -{ - public SoundObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) - { +public class SoundObj extends AbstractObj { + public SoundObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) { this.zone = zone; String[] stuff = filepath.split("/"); directory = stuff[0]; @@ -34,18 +31,17 @@ public SoundObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) data = entry; name = (String)data.get("name"); - loadDBInfo(); renderer = null; - uniqueID = -1; + loadDBInfo(); + position = new Vector3((float)data.get("pos_x"), (float)data.get("pos_y"), (float)data.get("pos_z")); rotation = new Vector3((float)data.get("dir_x"), (float)data.get("dir_y"), (float)data.get("dir_z")); scale = new Vector3((float)data.get("scale_x"), (float)data.get("scale_y"), (float)data.get("scale_z")); } - public SoundObj(ZoneArchive zone, String filepath, int game, String objname, Vector3 pos) - { + public SoundObj(ZoneArchive zone, String filepath, int game, String objname, Vector3 pos) { this.zone = zone; String[] stuff = filepath.split("/"); directory = stuff[0]; @@ -55,11 +51,11 @@ public SoundObj(ZoneArchive zone, String filepath, int game, String objname, Vec data = new Bcsv.Entry(); name = objname; - loadDBInfo(); renderer = null; - uniqueID = -1; + loadDBInfo(); + position = pos; rotation = new Vector3(0f, 0f, 0f); scale = new Vector3(1f, 1f, 1f); @@ -84,8 +80,7 @@ public SoundObj(ZoneArchive zone, String filepath, int game, String objname, Vec } @Override - public void save() - { + public void save() { data.put("name", name); data.put("pos_x", position.x); data.put("pos_y", position.y); data.put("pos_z", position.z); data.put("dir_x", rotation.x); data.put("dir_y", rotation.y); data.put("dir_z", rotation.z); @@ -93,9 +88,8 @@ public void save() } @Override - public void getProperties(PropertyGrid panel) - { - panel.addCategory("obj_position", "Position"); + public void getProperties(PropertyGrid panel) { + panel.addCategory("obj_rendering", "Rendering"); panel.addField("pos_x", "X position", "float", null, position.x, "Default"); panel.addField("pos_y", "Y position", "float", null, position.y, "Default"); panel.addField("pos_z", "Z position", "float", null, position.z, "Default"); @@ -106,26 +100,25 @@ public void getProperties(PropertyGrid panel) panel.addField("scale_y", "Y scale", "float", null, scale.y, "Default"); panel.addField("scale_z", "Z scale", "float", null, scale.z, "Default"); - panel.addCategory("obj_args", "Object arguments"); - panel.addField("Obj_arg0", "Obj_arg0", "int", null, data.get("Obj_arg0"), "Default"); - panel.addField("Obj_arg1", "Obj_arg1", "int", null, data.get("Obj_arg1"), "Default"); - panel.addField("Obj_arg2", "Obj_arg2", "int", null, data.get("Obj_arg2"), "Default"); - panel.addField("Obj_arg3", "Obj_arg3", "int", null, data.get("Obj_arg3"), "Default"); + panel.addCategory("obj_settings", "Settings"); + panel.addField("l_id", "ID", "int", null, data.get("l_id"), "Default"); + panel.addField("CommonPath_ID", "Path ID", "int", null, data.get("CommonPath_ID"), "Default"); + + panel.addCategory("obj_args", "Arguments"); + panel.addField("Obj_arg0", dbInfo.getFieldString(0), "int", null, data.get("Obj_arg0"), "Default"); + panel.addField("Obj_arg1", dbInfo.getFieldString(1), "int", null, data.get("Obj_arg1"), "Default"); + panel.addField("Obj_arg2", dbInfo.getFieldString(2), "int", null, data.get("Obj_arg2"), "Default"); + panel.addField("Obj_arg3", dbInfo.getFieldString(3), "int", null, data.get("Obj_arg3"), "Default"); - panel.addCategory("obj_eventinfo", "Switches"); + panel.addCategory("obj_switches", "Switches"); panel.addField("SW_APPEAR", "SW_APPEAR", "int", null, data.get("SW_APPEAR"), "Default"); panel.addField("SW_A", "SW_A", "int", null, data.get("SW_A"), "Default"); panel.addField("SW_B", "SW_B", "int", null, data.get("SW_B"), "Default"); - - panel.addCategory("obj_objinfo", "Other"); - panel.addField("l_id", "l_id", "int", null, data.get("l_id"), "Default"); - panel.addField("CommonPath_ID", "CommonPath_ID", "int", null, data.get("CommonPath_ID"), "Default"); } @Override - public String toString() - { + public String toString() { String l = layer.equals("common") ? "Common" : "Layer"+layer.substring(5).toUpperCase(); return dbInfo.name + " [" + l + "]"; } -} +} \ No newline at end of file diff --git a/src/whitehole/smg/object/StageObj.java b/src/com/aurum/whitehole/smg/object/StageObj.java similarity index 69% rename from src/whitehole/smg/object/StageObj.java rename to src/com/aurum/whitehole/smg/object/StageObj.java index 25fb7af..779a7a8 100644 --- a/src/whitehole/smg/object/StageObj.java +++ b/src/com/aurum/whitehole/smg/object/StageObj.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,16 +13,15 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.smg.object; +package com.aurum.whitehole.smg.object; -import whitehole.PropertyGrid; -import whitehole.smg.Bcsv; -import whitehole.smg.LevelObject; -import whitehole.smg.ZoneArchive; -import whitehole.vectors.Vector3; +import com.aurum.whitehole.swing.PropertyGrid; +import com.aurum.whitehole.rendering.GLRenderer.RenderInfo; +import com.aurum.whitehole.smg.Bcsv; +import com.aurum.whitehole.smg.ZoneArchive; +import com.aurum.whitehole.vectors.Vector3; -public class StageObj extends LevelObject { - +public class StageObj extends AbstractObj { public StageObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) { this.zone = zone; String[] stuff = filepath.split("/"); @@ -33,9 +32,7 @@ public StageObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) { data = entry; name = (String)data.get("name"); - loadDBInfo(); renderer = null; - uniqueID = -1; position = new Vector3((float)data.get("pos_x"), (float)data.get("pos_y"), (float)data.get("pos_z")); @@ -53,9 +50,7 @@ public StageObj(ZoneArchive zone, String filepath, int game, Vector3 pos) { data = new Bcsv.Entry(); name = ""; - loadDBInfo(); renderer = null; - uniqueID = -1; position = pos; @@ -74,19 +69,22 @@ public void save() { data.put("pos_x", position.x); data.put("pos_y", position.y); data.put("pos_z", position.z); data.put("dir_x", rotation.x); data.put("dir_y", rotation.y); data.put("dir_z", rotation.z); } - + + @Override + public void render(RenderInfo info) {} + @Override public void getProperties(PropertyGrid panel) { - panel.addCategory("obj_position", "Position"); - panel.addField("pos_x", "X position", "float_noedit", null, position.x, "Default"); - panel.addField("pos_y", "Y position", "float_noedit", null, position.y, "Default"); - panel.addField("pos_z", "Z position", "float_noedit", null, position.z, "Default"); - panel.addField("dir_x", "X rotation", "float_noedit", null, rotation.x, "Default"); - panel.addField("dir_y", "Y rotation", "float_noedit", null, rotation.y, "Default"); - panel.addField("dir_z", "Z rotation", "float_noedit", null, rotation.z, "Default"); + panel.addCategory("obj_rendering", "Rendering"); + panel.addField("pos_x", "X position", "float", null, position.x, "Default"); + panel.addField("pos_y", "Y position", "float", null, position.y, "Default"); + panel.addField("pos_z", "Z position", "float", null, position.z, "Default"); + panel.addField("dir_x", "X rotation", "float", null, rotation.x, "Default"); + panel.addField("dir_y", "Y rotation", "float", null, rotation.y, "Default"); + panel.addField("dir_z", "Z rotation", "float", null, rotation.z, "Default"); - panel.addCategory("obj_objinfo", "Other"); - panel.addField("l_id", "l_id", "noedit", null, data.get("l_id"), "Default"); + panel.addCategory("obj_settings", "Settings"); + panel.addField("l_id", "ID", "int", null, data.get("l_id"), "Default"); } @Override @@ -94,4 +92,4 @@ public String toString() { String l = layer.equals("common") ? "Common" : "Layer"+layer.substring(5).toUpperCase(); return name + " [" + l + "]"; } -} +} \ No newline at end of file diff --git a/src/whitehole/smg/object/StartObj.java b/src/com/aurum/whitehole/smg/object/StartObj.java similarity index 77% rename from src/whitehole/smg/object/StartObj.java rename to src/com/aurum/whitehole/smg/object/StartObj.java index e63cfdf..130eeb8 100644 --- a/src/whitehole/smg/object/StartObj.java +++ b/src/com/aurum/whitehole/smg/object/StartObj.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,18 +13,15 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.smg.object; +package com.aurum.whitehole.smg.object; -import whitehole.PropertyGrid; -import whitehole.smg.Bcsv; -import whitehole.smg.LevelObject; -import whitehole.smg.ZoneArchive; -import whitehole.vectors.Vector3; +import com.aurum.whitehole.swing.PropertyGrid; +import com.aurum.whitehole.smg.Bcsv; +import com.aurum.whitehole.smg.ZoneArchive; +import com.aurum.whitehole.vectors.Vector3; -public class StartObj extends LevelObject -{ - public StartObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) - { +public class StartObj extends AbstractObj { + public StartObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) { this.zone = zone; String[] stuff = filepath.split("/"); directory = stuff[0]; @@ -34,19 +31,17 @@ public StartObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) data = entry; name = (String)data.get("name"); - if (!name.equals("Mario")) System.out.println("NON-MARIO START OBJECT -- WHAT THE HELL ("+name+")"); - loadDBInfo(); renderer = null; - uniqueID = -1; + loadDBInfo(); + position = new Vector3((float)data.get("pos_x"), (float)data.get("pos_y"), (float)data.get("pos_z")); rotation = new Vector3((float)data.get("dir_x"), (float)data.get("dir_y"), (float)data.get("dir_z")); scale = new Vector3((float)data.get("scale_x"), (float)data.get("scale_y"), (float)data.get("scale_z")); } - public StartObj(ZoneArchive zone, String filepath, int game, Vector3 pos) - { + public StartObj(ZoneArchive zone, String filepath, int game, Vector3 pos) { this.zone = zone; String[] stuff = filepath.split("/"); directory = stuff[0]; @@ -56,11 +51,11 @@ public StartObj(ZoneArchive zone, String filepath, int game, Vector3 pos) data = new Bcsv.Entry(); name = "Mario"; - loadDBInfo(); renderer = null; - uniqueID = -1; + loadDBInfo(); + position = pos; rotation = new Vector3(0f, 0f, 0f); scale = new Vector3(1f, 1f, 1f); @@ -76,8 +71,7 @@ public StartObj(ZoneArchive zone, String filepath, int game, Vector3 pos) } @Override - public void save() - { + public void save() { data.put("name", name); data.put("pos_x", position.x); data.put("pos_y", position.y); data.put("pos_z", position.z); data.put("dir_x", rotation.x); data.put("dir_y", rotation.y); data.put("dir_z", rotation.z); @@ -85,9 +79,8 @@ public void save() } @Override - public void getProperties(PropertyGrid panel) - { - panel.addCategory("obj_position", "Position"); + public void getProperties(PropertyGrid panel) { + panel.addCategory("obj_rendering", "Rendering"); panel.addField("pos_x", "X position", "float", null, position.x, "Default"); panel.addField("pos_y", "Y position", "float", null, position.y, "Default"); panel.addField("pos_z", "Z position", "float", null, position.z, "Default"); @@ -98,18 +91,17 @@ public void getProperties(PropertyGrid panel) panel.addField("scale_y", "Y scale", "float", null, scale.y, "Default"); panel.addField("scale_z", "Z scale", "float", null, scale.z, "Default"); - panel.addCategory("obj_args", "Object arguments"); - panel.addField("Obj_arg0", "Obj_arg0", "int", null, data.get("Obj_arg0"), "Default"); + panel.addCategory("obj_args", "Arguments"); + panel.addField("Obj_arg0", dbInfo.getFieldString(0), "int", null, data.get("Obj_arg0"), "Default"); - panel.addCategory("obj_objinfo", "Other"); - panel.addField("MarioNo", "MarioNo", "int", null, data.get("MarioNo"), "Default"); - panel.addField("Camera_id", "Camera_id", "int", null, data.get("Camera_id"), "Default"); + panel.addCategory("obj_spawn", "Spawning"); + panel.addField("MarioNo", "Spawn ID", "int", null, data.get("MarioNo"), "Default"); + panel.addField("Camera_id", "Camera ID", "int", null, data.get("Camera_id"), "Default"); } @Override - public String toString() - { + public String toString() { String l = layer.equals("common") ? "Common" : "Layer"+layer.substring(5).toUpperCase(); - return String.format("Spawn point %1$d [%2$s]", (int)data.get("MarioNo"), l); + return String.format("Spawn %1$d [%2$s]", (int)data.get("MarioNo"), l); } -} +} \ No newline at end of file diff --git a/src/whitehole/AboutForm.form b/src/com/aurum/whitehole/swing/AboutForm.form similarity index 96% rename from src/whitehole/AboutForm.form rename to src/com/aurum/whitehole/swing/AboutForm.form index a822822..5bc9e14 100644 --- a/src/whitehole/AboutForm.form +++ b/src/com/aurum/whitehole/swing/AboutForm.form @@ -3,16 +3,18 @@
+ + + + + + - + - - - - diff --git a/src/whitehole/AboutForm.java b/src/com/aurum/whitehole/swing/AboutForm.java similarity index 85% rename from src/whitehole/AboutForm.java rename to src/com/aurum/whitehole/swing/AboutForm.java index 5c5eb47..9d6545e 100644 --- a/src/whitehole/AboutForm.java +++ b/src/com/aurum/whitehole/swing/AboutForm.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,26 +13,17 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole; +package com.aurum.whitehole.swing; +import com.aurum.whitehole.Whitehole; import java.awt.Toolkit; -public class AboutForm extends javax.swing.JFrame -{ - - /** - * Creates new form BcsvEditorForm - */ - public AboutForm() - { +public class AboutForm extends javax.swing.JFrame { + public AboutForm() { initComponents(); + this.setTitle("About " + Whitehole.NAME); } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ + @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { @@ -54,15 +45,9 @@ private void initComponents() { jLabel15 = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle("About " + Whitehole.NAME); + setIconImage(Whitehole.ICON); setResizable(false); - addWindowListener(new java.awt.event.WindowAdapter() { - public void windowClosing(java.awt.event.WindowEvent evt) { - formWindowClosing(evt); - } - public void windowOpened(java.awt.event.WindowEvent evt) { - formWindowOpened(evt); - } - }); jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N jLabel1.setText("Whitehole"); @@ -166,17 +151,8 @@ public void windowOpened(java.awt.event.WindowEvent evt) { ); pack(); + setLocationRelativeTo(null); }// //GEN-END:initComponents - - private void formWindowClosing(java.awt.event.WindowEvent evt)//GEN-FIRST:event_formWindowClosing - {//GEN-HEADEREND:event_formWindowClosing - - }//GEN-LAST:event_formWindowClosing - - private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened - this.setTitle("About " + Whitehole.fullName); - this.setIconImage(Toolkit.getDefaultToolkit().createImage(Whitehole.class.getResource("/Resources/icon.png"))); - }//GEN-LAST:event_formWindowOpened // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JLabel jLabel1; diff --git a/src/whitehole/BcsvEditorForm.form b/src/com/aurum/whitehole/swing/BcsvEditorForm.form similarity index 99% rename from src/whitehole/BcsvEditorForm.form rename to src/com/aurum/whitehole/swing/BcsvEditorForm.form index ad133ca..7134975 100644 --- a/src/whitehole/BcsvEditorForm.form +++ b/src/com/aurum/whitehole/swing/BcsvEditorForm.form @@ -573,6 +573,9 @@ + + + @@ -580,11 +583,10 @@ - + - diff --git a/src/whitehole/BcsvEditorForm.java b/src/com/aurum/whitehole/swing/BcsvEditorForm.java similarity index 98% rename from src/whitehole/BcsvEditorForm.java rename to src/com/aurum/whitehole/swing/BcsvEditorForm.java index b294db0..d10a7fc 100644 --- a/src/whitehole/BcsvEditorForm.java +++ b/src/com/aurum/whitehole/swing/BcsvEditorForm.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,8 +13,11 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole; +package com.aurum.whitehole.swing; +import com.aurum.whitehole.Whitehole; +import com.aurum.whitehole.io.FilesystemBase; +import com.aurum.whitehole.io.RarcFilesystem; import java.awt.Toolkit; import java.io.File; import java.io.IOException; @@ -22,16 +25,11 @@ import java.util.*; import javax.swing.JOptionPane; import javax.swing.table.*; -import whitehole.fileio.*; -import whitehole.smg.Bcsv; +import com.aurum.whitehole.smg.Bcsv; public class BcsvEditorForm extends javax.swing.JFrame { - /** - * Creates new form BcsvEditorForm - */ - public BcsvEditorForm() { initComponents(); @@ -87,7 +85,7 @@ private void bcsvOpen() { } catch (IOException ex) { - JOptionPane.showMessageDialog(this, "Can't open BCSV file: "+ ex.getMessage(), Whitehole.fullName, JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(this, "Can't open BCSV file: "+ ex.getMessage(), Whitehole.NAME, JOptionPane.ERROR_MESSAGE); try { if (bcsv != null) bcsv.close(); @@ -222,7 +220,7 @@ private void bcsvExport() { } pwriter.flush(); pwriter.close(); - JOptionPane.showMessageDialog(null, "The BCSV file has been exported.", Whitehole.fullName, JOptionPane.OK_CANCEL_OPTION); + JOptionPane.showMessageDialog(null, "The BCSV file has been exported.", Whitehole.NAME, JOptionPane.OK_CANCEL_OPTION); } catch (IOException e) { @@ -233,7 +231,7 @@ private void bcsvExport() { private void enterZoneName() { String s = (String)JOptionPane.showInputDialog(this, "Enter the name of the stage:", - Whitehole.fullName,JOptionPane.PLAIN_MESSAGE,null,null,null); + Whitehole.NAME,JOptionPane.PLAIN_MESSAGE,null,null,null); zoneName = s; } @@ -341,14 +339,12 @@ private void initComponents() { setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle("BCSV editor"); + setIconImage(Whitehole.ICON); setSize(new java.awt.Dimension(0, 0)); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { formWindowClosing(evt); } - public void windowOpened(java.awt.event.WindowEvent evt) { - formWindowOpened(evt); - } }); jToolBar1.setFloatable(false); @@ -1021,6 +1017,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { ); pack(); + setLocationRelativeTo(null); }// //GEN-END:initComponents private void btnAddRowActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnAddRowActionPerformed @@ -1063,17 +1060,13 @@ private void btnClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRS private void btnExportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExportActionPerformed if (tblBcsv.getColumnCount() == 0) { - JOptionPane.showMessageDialog(null, "No BCSV file opened.", Whitehole.fullName, JOptionPane.OK_CANCEL_OPTION); + JOptionPane.showMessageDialog(null, "No BCSV file opened.", Whitehole.NAME, JOptionPane.OK_CANCEL_OPTION); } else { bcsvExport(); } }//GEN-LAST:event_btnExportActionPerformed - private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened - this.setIconImage(Toolkit.getDefaultToolkit().createImage(Whitehole.class.getResource("/Resources/icon.png"))); - }//GEN-LAST:event_formWindowOpened - private void formWindowClosing(java.awt.event.WindowEvent evt)//GEN-FIRST:event_formWindowClosing {//GEN-HEADEREND:event_formWindowClosing try @@ -1095,7 +1088,7 @@ private void subSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST private void subExportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_subExportActionPerformed if (tblBcsv.getColumnCount() == 0) { - JOptionPane.showMessageDialog(null, "No BCSV file opened.", Whitehole.fullName, JOptionPane.OK_CANCEL_OPTION); + JOptionPane.showMessageDialog(null, "No BCSV file opened.", Whitehole.NAME, JOptionPane.OK_CANCEL_OPTION); } else { bcsvExport(); @@ -1635,4 +1628,4 @@ private void subURsound3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F private javax.swing.JTextField tbFileName; private javax.swing.JTable tblBcsv; // End of variables declaration//GEN-END:variables -} +} \ No newline at end of file diff --git a/src/com/aurum/whitehole/swing/CheckBoxList.java b/src/com/aurum/whitehole/swing/CheckBoxList.java new file mode 100644 index 0000000..052dffd --- /dev/null +++ b/src/com/aurum/whitehole/swing/CheckBoxList.java @@ -0,0 +1,76 @@ +/* + © 2012 - 2017 - Whitehole Team + + Whitehole is free software: you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + Whitehole is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with Whitehole. If not, see http://www.gnu.org/licenses/. +*/ + +/* + * CheckBoxList inspired from http://www.devx.com/tips/Tip/5342 + */ + +package com.aurum.whitehole.swing; + +import javax.swing.*; +import javax.swing.border.*; +import java.awt.*; +import java.awt.event.*; + +public class CheckBoxList extends JList { + protected static Border noFocusBorder = new EmptyBorder(1, 1, 1, 1); + + public CheckBoxList() { + setCellRenderer(new CellRenderer()); + addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + int index = locationToIndex(e.getPoint()); + if (index != -1) { + JCheckBox checkbox = (JCheckBox) getModel().getElementAt(index); + checkbox.setSelected(!checkbox.isSelected()); + + if (eventListener != null) + eventListener.checkBoxStatusChanged(index, checkbox.isSelected()); + + repaint(); + } + } + }); + + setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + eventListener = null; + } + + public void setEventListener(EventListener listener) { + eventListener = listener; + } + + protected class CellRenderer implements ListCellRenderer { + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + JCheckBox checkbox = (JCheckBox) value; + checkbox.setBackground(isSelected ? getSelectionBackground() : getBackground()); + checkbox.setForeground(isSelected ? getSelectionForeground() : getForeground()); + checkbox.setEnabled(isEnabled()); + checkbox.setFont(getFont()); + checkbox.setFocusPainted(false); + checkbox.setBorderPainted(true); + checkbox.setBorder(isSelected ? UIManager.getBorder("List.focusCellHighlightBorder") : noFocusBorder); + return checkbox; + } + } + + public interface EventListener { + public void checkBoxStatusChanged(int index, boolean status); + } + + private EventListener eventListener; +} \ No newline at end of file diff --git a/src/whitehole/GalaxyEditorForm.form b/src/com/aurum/whitehole/swing/GalaxyEditorForm.form similarity index 99% rename from src/whitehole/GalaxyEditorForm.form rename to src/com/aurum/whitehole/swing/GalaxyEditorForm.form index 3c54c1f..bad18cb 100644 --- a/src/whitehole/GalaxyEditorForm.form +++ b/src/com/aurum/whitehole/swing/GalaxyEditorForm.form @@ -138,17 +138,20 @@ - - + + + + + - - + + - + diff --git a/src/whitehole/GalaxyEditorForm.java b/src/com/aurum/whitehole/swing/GalaxyEditorForm.java similarity index 70% rename from src/whitehole/GalaxyEditorForm.java rename to src/com/aurum/whitehole/swing/GalaxyEditorForm.java index a1d60e4..efb6ba0 100644 --- a/src/whitehole/GalaxyEditorForm.java +++ b/src/com/aurum/whitehole/swing/GalaxyEditorForm.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,23 +13,17 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole; - -import whitehole.smg.object.PlanetObj; -import whitehole.smg.object.MapPartObj; -import whitehole.smg.object.GeneralObject; -import whitehole.smg.object.PathPointObject; -import whitehole.smg.object.CameraCubeObj; -import whitehole.smg.object.DebugObj; -import whitehole.smg.object.AreaObj; -import whitehole.smg.object.PathObject; -import whitehole.smg.object.ChangeObj; -import whitehole.smg.object.GeneralPosObj; -import whitehole.smg.object.DemoObj; -import whitehole.smg.object.SoundObj; -import whitehole.smg.object.ChildObj; -import whitehole.smg.object.StartObj; -import whitehole.smg.object.StageObj; +package com.aurum.whitehole.swing; + +import com.aurum.whitehole.Settings; +import com.aurum.whitehole.Whitehole; +import com.aurum.whitehole.vectors.*; +import com.aurum.whitehole.smg.object.*; +import com.aurum.whitehole.smg.Bcsv; +import com.aurum.whitehole.smg.GalaxyArchive; +import com.aurum.whitehole.smg.ZoneArchive; +import com.aurum.whitehole.rendering.GLRenderer; +import com.aurum.whitehole.rendering.cache.RendererCache; import java.io.*; import java.nio.*; import java.awt.*; @@ -42,39 +36,30 @@ import javax.swing.event.PopupMenuEvent; import javax.swing.event.PopupMenuListener; import javax.swing.tree.*; -import whitehole.vectors.*; -import whitehole.rendering.*; -import whitehole.smg.*; -import whitehole.smg.Bcsv; -public class GalaxyEditorForm extends javax.swing.JFrame - { - - private void initVariables() - { +public class GalaxyEditorForm extends javax.swing.JFrame { + private void initVariables() { maxUniqueID = 0; - globalObjList = new HashMap<>(); - globalPathList = new HashMap<>(); - globalPathPointList = new HashMap<>(); - treeNodeList = new HashMap<>(); + globalObjList = new HashMap(); + globalPathList = new HashMap(); + globalPathPointList = new HashMap(); + treeNodeList = new HashMap(); unsavedChanges = false; keyMask = 0; keyDelta = 0; } - public GalaxyEditorForm(String galaxy) - { + public GalaxyEditorForm(String galaxy) { initComponents(); initVariables(); - - subZoneData = new HashMap<>(); + + zoneEditors = new HashMap(); + subZoneData = new HashMap(); galaxyMode = true; parentForm = null; - childZoneEditors = new HashMap<>(); galaxyName = galaxy; - try - { + try { galaxyArc = Whitehole.game.openGalaxy(galaxyName); zoneArcs = new HashMap<>(galaxyArc.zoneList.size()); @@ -82,66 +67,47 @@ public GalaxyEditorForm(String galaxy) loadZone(zone); ZoneArchive mainzone = zoneArcs.get(galaxyName); - for (int i = 0; i < galaxyArc.scenarioData.size(); i++) - { - for (Bcsv.Entry subzone : mainzone.subZones.get("common")) - { - GalaxyEditorForm.SubZoneData data = new GalaxyEditorForm.SubZoneData(); - data.layer = "common"; - data.position = new Vector3((float)subzone.get("pos_x"), (float)subzone.get("pos_y"), (float)subzone.get("pos_z")); - data.rotation = new Vector3((float)subzone.get("dir_x"), (float)subzone.get("dir_y"), (float)subzone.get("dir_z")); - - String key = String.format("%1$d/%2$s", i, (String)subzone.get("name")); + for (int i = 0; i < galaxyArc.scenarioData.size(); i++) { + for (StageObj subzone : mainzone.zones.get("common")) { + String key = String.format("%1$d/%2$s", i, subzone.name); if (subZoneData.containsKey(key)) throw new IOException("Duplicate zone " + key); - subZoneData.put(key, data); + subZoneData.put(key, subzone); } int mainlayermask = (int)galaxyArc.scenarioData.get(i).get(galaxyName); - for (int l = 0; l < 16; l++) - { + for (int l = 0; l < 16; l++) { if ((mainlayermask & (1 << l)) == 0) continue; String layer = "layer" + ('a'+l); - if (!mainzone.subZones.containsKey(layer)) + if (!mainzone.zones.containsKey(layer)) continue; - for (Bcsv.Entry subzone : mainzone.subZones.get(layer)) - { - GalaxyEditorForm.SubZoneData data = new GalaxyEditorForm.SubZoneData(); - data.layer = layer; - data.position = new Vector3((float)subzone.get("pos_x"), (float)subzone.get("pos_y"), (float)subzone.get("pos_z")); - data.rotation = new Vector3((float)subzone.get("dir_x"), (float)subzone.get("dir_y"), (float)subzone.get("dir_z")); - - String key = String.format("%1$d/%2$s", i, (String)subzone.get("name")); + for (StageObj subzone : mainzone.zones.get(layer)) { + String key = String.format("%1$d/%2$s", i, subzone.name); if (subZoneData.containsKey(key)) throw new IOException("Duplicate zone " + key); - subZoneData.put(key, data); + subZoneData.put(key, subzone); } } } } - catch (IOException ex) - { - JOptionPane.showMessageDialog(null, "Failed to open the galaxy: "+ex.getMessage(), Whitehole.fullName, JOptionPane.ERROR_MESSAGE); + catch (IOException ex) { + JOptionPane.showMessageDialog(null, "Failed to open the galaxy: "+ex.getMessage(), Whitehole.NAME, JOptionPane.ERROR_MESSAGE); dispose(); return; } initGUI(); - // hax btnAddScenario.setVisible(false); btnEditScenario.setVisible(false); btnDeleteScenario.setVisible(false); btnAddZone.setVisible(false); btnDeleteZone.setVisible(false); - tpLeftPanel.remove(1); - } - public GalaxyEditorForm(GalaxyEditorForm gal_parent, ZoneArchive zone) - { + public GalaxyEditorForm(GalaxyEditorForm gal_parent, ZoneArchive zone) { initComponents(); initVariables(); @@ -150,17 +116,15 @@ public GalaxyEditorForm(GalaxyEditorForm gal_parent, ZoneArchive zone) galaxyMode = false; parentForm = gal_parent; - childZoneEditors = null; + zoneEditors = null; galaxyName = zone.zoneName; // hax - try - { + try { zoneArcs = new HashMap<>(1); zoneArcs.put(galaxyName, zone); loadZone(galaxyName); } - catch (IOException ex) - { - JOptionPane.showMessageDialog(null, "Failed to open the zone: "+ex.getMessage(), Whitehole.fullName, JOptionPane.ERROR_MESSAGE); + catch (IOException ex) { + JOptionPane.showMessageDialog(null, "Failed to open the zone: "+ex.getMessage(), Whitehole.NAME, JOptionPane.ERROR_MESSAGE); dispose(); return; } @@ -173,8 +137,7 @@ public GalaxyEditorForm(GalaxyEditorForm gal_parent, ZoneArchive zone) tpLeftPanel.remove(0); lbLayersList = new CheckBoxList(); - lbLayersList.setEventListener(new CheckBoxList.EventListener() - { + lbLayersList.setEventListener(new CheckBoxList.EventListener() { @Override public void checkBoxStatusChanged(int index, boolean status) { layerSelectChange(index, status); } @@ -188,14 +151,11 @@ public void checkBoxStatusChanged(int index, boolean status) cblayers[i] = new JCheckBox("Common"); cblayers[i].setSelected(true); i++; - for (int l = 0; l < 16; l++) - { + for (int l = 0; l < 16; l++) { String ls = String.format("Layer%1$c", 'A'+l); - if (curZoneArc.objects.containsKey(ls.toLowerCase())) - { + if (curZoneArc.objects.containsKey(ls.toLowerCase())) { cblayers[i] = new JCheckBox(ls); - if (i == 1) - { + if (i == 1) { cblayers[i].setSelected(true); zoneModeLayerBitmask |= (2 << l); } @@ -207,10 +167,8 @@ public void checkBoxStatusChanged(int index, boolean status) populateObjectList(zoneModeLayerBitmask); } - private void initGUI() - { - setTitle(galaxyName + " - " + Whitehole.fullName); - setIconImage(Toolkit.getDefaultToolkit().createImage(Whitehole.class.getResource("/Resources/icon.png"))); + private void initGUI() { + setTitle(galaxyName + " - " + Whitehole.NAME); tbObjToolbar.setLayout(new ToolbarFlowLayout(FlowLayout.LEFT, 0, 0)); tbObjToolbar.validate(); @@ -222,92 +180,52 @@ private void initGUI() pmnAddObjects = new JPopupMenu(); - if (ZoneArchive.gameMask == 2) { - String[] menuitems = new String[] {"Normal", "MapPart", "Gravity", "Starting point", "Area", "Camera Area", "Cutscene", "GeneralPos", "ChangeObj (Unused)", "Debug (Unused)", "Path", "Path point"}; - for (String item : menuitems) - { - JMenuItem mnuitem = new JMenuItem(item); - mnuitem.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - int i = 0; - while (!pmnAddObjects.getComponent(i).equals(e.getSource())) i++; - switch (i) - { - case 0: doAddObject("general"); break; - case 1: doAddObject("mappart"); break; - case 2: doAddObject("gravity"); break; - case 3: doAddObject("start"); break; - case 4: doAddObject("area"); break; - case 5: doAddObject("camera"); break; - case 6: doAddObject("demo"); break; - case 7: doAddObject("generalpos"); break; - case 8: doAddObject("change"); break; - case 9: doAddObject("debug"); break; - case 10: doAddObject("path"); break; - case 11: doAddObject("pathpoint"); break; - } + String[] smg1items = new String[] { "Normal", "Spawn", "Gravity", "Area", "Camera", "Sound", "Child", "MapPart", "Cutscene", "Position", "Debug", "Path", "Path point" }; + String[] smg2items = new String[] { "Normal", "Spawn", "Gravity", "Area", "Camera", "MapPart", "Cutscene", "Position", "Changer", "Debug", "Path", "Path point" }; + String[] items = ZoneArchive.game == 2 ? smg2items : smg1items; + + for (String item : items) { + JMenuItem menuitem = new JMenuItem(item); + menuitem.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + JMenuItem foo = (JMenuItem) e.getSource(); + switch(foo.getText()) { + case "Normal": setObjectBeingAdded("general"); break; + case "Spawn": setObjectBeingAdded("start"); break; + case "Gravity": setObjectBeingAdded("gravity"); break; + case "Area": setObjectBeingAdded("area"); break; + case "Camera": setObjectBeingAdded("camera"); break; + case "Sound": setObjectBeingAdded("sound"); break; + case "Child": setObjectBeingAdded("child"); break; + case "MapPart": setObjectBeingAdded("mappart"); break; + case "Cutscene": setObjectBeingAdded("cutscene"); break; + case "Position": setObjectBeingAdded("position"); break; + case "Changer": setObjectBeingAdded("change"); break; + case "Debug": setObjectBeingAdded("debug"); break; + case "Path": setObjectBeingAdded("path"); break; + case "Path point": setObjectBeingAdded("pathpoint"); break; } - }); - pmnAddObjects.add(mnuitem); - } - } - else { - String[] menuitems = new String[] {"Normal", "ChildObj", "MapPart", "Gravity", "Starting point", "Area", "Camera Area", "Sound", "Cutscene", "GeneralPos", "Debug (Unused)", "Path", "Path point"}; - for (String item : menuitems) - { - JMenuItem mnuitem = new JMenuItem(item); - mnuitem.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - int i = 0; - while (!pmnAddObjects.getComponent(i).equals(e.getSource())) i++; - switch (i) - { - case 0: doAddObject("general"); break; - case 1: doAddObject("child"); break; - case 2: doAddObject("mappart"); break; - case 3: doAddObject("gravity"); break; - case 4: doAddObject("start"); break; - case 5: doAddObject("area"); break; - case 6: doAddObject("camera"); break; - case 7: doAddObject("sound"); break; - case 8: doAddObject("demo"); break; - case 9: doAddObject("generalpos"); break; - case 10: doAddObject("debug"); break; - case 11: doAddObject("path"); break; - case 12: doAddObject("pathpoint"); break; - } - } - }); - pmnAddObjects.add(mnuitem); - } + } + }); + pmnAddObjects.add(menuitem); } - pmnAddObjects.addPopupMenuListener(new PopupMenuListener() - { + pmnAddObjects.addPopupMenuListener(new PopupMenuListener() { @Override - public void popupMenuWillBecomeVisible(PopupMenuEvent e) - { - } + public void popupMenuWillBecomeVisible(PopupMenuEvent e) {} @Override - public void popupMenuWillBecomeInvisible(PopupMenuEvent e) - { - if (!objectBeingAdded.isEmpty()) + public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { + if (!addingObject.isEmpty()) setStatusText(); else tgbAddObject.setSelected(false); } @Override - public void popupMenuCanceled(PopupMenuEvent e) - { - if (!objectBeingAdded.isEmpty()) + public void popupMenuCanceled(PopupMenuEvent e) { + if (!addingObject.isEmpty()) setStatusText(); else tgbAddObject.setSelected(false); @@ -330,30 +248,24 @@ public void popupMenuCanceled(PopupMenuEvent e) pnlObjectSettings.setEventListener(new PropertyGrid.EventListener() { @Override public void propertyChanged(String propname, Object value) { - propPanelPropertyChanged(propname, value); + propertyPanelPropertyChanged(propname, value); } }); glCanvas.requestFocusInWindow(); - - } - private void loadZone(String zone) throws IOException - { + private void loadZone(String zone) throws IOException { ZoneArchive arc; - if (galaxyMode) - { + if (galaxyMode) { arc = galaxyArc.openZone(zone); zoneArcs.put(zone, arc); } else arc = zoneArcs.get(zone); - for (java.util.List objlist : arc.objects.values()) - { - for (LevelObject obj : objlist) - { + for (java.util.List objlist : arc.objects.values()) { + for (AbstractObj obj : objlist) { globalObjList.put(maxUniqueID, obj); obj.uniqueID = maxUniqueID; @@ -361,28 +273,25 @@ private void loadZone(String zone) throws IOException } } - for (PathObject obj : arc.paths) - { + for (PathObj obj : arc.paths) { globalPathList.put(maxUniqueID, obj); obj.uniqueID = maxUniqueID; maxUniqueID++; - for (PathPointObject pt : obj.points.values()) - { + for (PathPointObj pt : obj.points.values()) { globalObjList.put(maxUniqueID, pt); + globalPathPointList.put(maxUniqueID, pt); pt.uniqueID = maxUniqueID; - maxUniqueID++; } } } - - public void updateZone(String zone) - { + public void updateZone(String zone) { rerenderTasks.add("zone:"+zone); glCanvas.repaint(); } + /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always @@ -453,8 +362,9 @@ private void initComponents() { itemControls = new javax.swing.JMenuItem(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); - setMinimumSize(new java.awt.Dimension(640, 480)); - setPreferredSize(new java.awt.Dimension(860, 640)); + setTitle(Whitehole.NAME); + setIconImage(Whitehole.ICON); + setMinimumSize(new java.awt.Dimension(960, 720)); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { formWindowClosing(evt); @@ -823,6 +733,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { setJMenuBar(jMenuBar1); pack(); + setLocationRelativeTo(null); }// //GEN-END:initComponents private void formWindowOpened(java.awt.event.WindowEvent evt)//GEN-FIRST:event_formWindowOpened @@ -842,13 +753,11 @@ private void formWindowOpened(java.awt.event.WindowEvent evt)//GEN-FIRST:event_f // }//GEN-LAST:event_formWindowOpened - public void selectionChanged() - { + public void selectionChanged() { displayedPaths.clear(); pnlObjectSettings.clear(); - if (selectedObjs.isEmpty()) - { + if (selectedObjs.isEmpty()) { lbStatusLabel.setText("Deselect object."); btnDeselect.setEnabled(false); @@ -861,32 +770,29 @@ public void selectionChanged() return; } - for (LevelObject obj : selectedObjs.values()) - { + for (AbstractObj obj : selectedObjs.values()) { int pathid = -1; - PathPointObject pathpoint = null; + PathPointObj pathpoint = null; - if (obj instanceof PathPointObject) - { - pathpoint = (PathPointObject)obj; - pathid = pathpoint.path.pathID; + if (obj instanceof PathPointObj) { + pathpoint = (PathPointObj) obj; + pathid = pathpoint.path.index; } else if (obj.data.containsKey("CommonPath_ID")) pathid = (int)(short)obj.data.get("CommonPath_ID"); - if (pathid == -1) continue; + if (pathid == -1) + continue; if (displayedPaths.get(pathid) == null) displayedPaths.put(pathid, pathpoint); } + // Check if the selected objects' classes are the same Class cls = null; boolean allthesame = true; - if (selectedObjs.size() > 1) - { - for (LevelObject selectedObj : selectedObjs.values()) - { - if (cls != null && cls != selectedObj.getClass()) - { + if (selectedObjs.size() > 1) { + for (AbstractObj selectedObj : selectedObjs.values()) { + if (cls != null && cls != selectedObj.getClass()) { allthesame = false; break; } @@ -895,96 +801,44 @@ else if (cls == null) } } - if (allthesame) - { - for (LevelObject selectedObj : selectedObjs.values()) - { - if (selectedObj instanceof PathPointObject) - { - PathPointObject selectedPathPoint = (PathPointObject)selectedObj; - PathObject path = selectedPathPoint.path; - LinkedList usagelist = new LinkedList<>(); - usagelist.add("General"); - usagelist.add("Camera"); + // If all selected objects are the same type, add all properties. + if (allthesame) { + for (AbstractObj selectedObj : selectedObjs.values()) { + if (selectedObj instanceof PathPointObj) { + PathPointObj selectedPathPoint = (PathPointObj)selectedObj; + PathObj path = selectedPathPoint.path; - lbStatusLabel.setText(String.format("Selected [%3$d] %1$s (%2$s), point %4$d", path.data.get("name"), path.zone.zoneName, path.pathID, selectedPathPoint.index)); + lbStatusLabel.setText(String.format("Selected [%3$d] %1$s (%2$s), point %4$d", path.data.get("name"), path.zone.zoneName, path.index, selectedPathPoint.index)); btnDeselect.setEnabled(true); - - pnlObjectSettings.addCategory("path_settings", "Path settings"); - if (galaxyMode) - pnlObjectSettings.addField("arzone", "Zone", "list", galaxyArc.zoneList, selectedPathPoint.path.zone.zoneName, "Default"); - pnlObjectSettings.addField("[P]l_id", "Path ID", "int", null, path.pathID, "Default"); - pnlObjectSettings.addField("[P]closed", "Closed", "bool", null, ((String)path.data.get("closed")).equals("CLOSE"), "Default"); - pnlObjectSettings.addField("[P]usage", "Usage", "list", usagelist, path.data.get("usage"), "Default"); - pnlObjectSettings.addField("[P]name", "Name", "text", null, path.data.get("name"), "Default"); - - pnlObjectSettings.addCategory("path_args", "Path arguments"); - pnlObjectSettings.addField("[P]path_arg0", "path_arg0", "int", null, path.data.get("path_arg0"), "Default"); - pnlObjectSettings.addField("[P]path_arg1", "path_arg1", "int", null, path.data.get("path_arg1"), "Default"); - pnlObjectSettings.addField("[P]path_arg2", "path_arg2", "int", null, path.data.get("path_arg2"), "Default"); - pnlObjectSettings.addField("[P]path_arg3", "path_arg3", "int", null, path.data.get("path_arg3"), "Default"); - pnlObjectSettings.addField("[P]path_arg4", "path_arg4", "int", null, path.data.get("path_arg4"), "Default"); - pnlObjectSettings.addField("[P]path_arg5", "path_arg5", "int", null, path.data.get("path_arg5"), "Default"); - pnlObjectSettings.addField("[P]path_arg6", "path_arg6", "int", null, path.data.get("path_arg6"), "Default"); - pnlObjectSettings.addField("[P]path_arg7", "path_arg7", "int", null, path.data.get("path_arg7"), "Default"); - - pnlObjectSettings.addCategory("point_coords", "Point coordinates"); - pnlObjectSettings.addField("pnt0_x", "X", "float", null, selectedPathPoint.position.x, "Default"); - pnlObjectSettings.addField("pnt0_y", "Y", "float", null, selectedPathPoint.position.y, "Default"); - pnlObjectSettings.addField("pnt0_z", "Z", "float", null, selectedPathPoint.position.z, "Default"); - pnlObjectSettings.addField("pnt1_x", "Control 1 X", "float", null, selectedPathPoint.point1.x, "Default"); - pnlObjectSettings.addField("pnt1_y", "Control 1 Y", "float", null, selectedPathPoint.point1.y, "Default"); - pnlObjectSettings.addField("pnt1_z", "Control 1 Z", "float", null, selectedPathPoint.point1.z, "Default"); - pnlObjectSettings.addField("pnt2_x", "Control 2 X", "float", null, selectedPathPoint.point2.x, "Default"); - pnlObjectSettings.addField("pnt2_y", "Control 2 Y", "float", null, selectedPathPoint.point2.y, "Default"); - pnlObjectSettings.addField("pnt2_z", "Control 2 Z", "float", null, selectedPathPoint.point2.z, "Default"); - - pnlObjectSettings.addCategory("point_args", "Point arguments"); - pnlObjectSettings.addField("point_arg0", "point_arg0", "int", null, selectedPathPoint.data.get("point_arg0"), "Default"); - pnlObjectSettings.addField("point_arg1", "point_arg1", "int", null, selectedPathPoint.data.get("point_arg1"), "Default"); - pnlObjectSettings.addField("point_arg2", "point_arg2", "int", null, selectedPathPoint.data.get("point_arg2"), "Default"); - pnlObjectSettings.addField("point_arg3", "point_arg3", "int", null, selectedPathPoint.data.get("point_arg3"), "Default"); - pnlObjectSettings.addField("point_arg4", "point_arg4", "int", null, selectedPathPoint.data.get("point_arg4"), "Default"); - pnlObjectSettings.addField("point_arg5", "point_arg5", "int", null, selectedPathPoint.data.get("point_arg5"), "Default"); - pnlObjectSettings.addField("point_arg6", "point_arg6", "int", null, selectedPathPoint.data.get("point_arg6"), "Default"); - pnlObjectSettings.addField("point_arg7", "point_arg7", "int", null, selectedPathPoint.data.get("point_arg7"), "Default"); + selectedPathPoint.getProperties(pnlObjectSettings); } - else - { + else { String layer = selectedObj.layer.equals("common") ? "Common" : "Layer"+selectedObj.layer.substring(5).toUpperCase(); lbStatusLabel.setText(String.format("Selected %1$s (%2$s, %3$s)", selectedObj.name, selectedObj.zone.zoneName, layer)); btnDeselect.setEnabled(true); - + LinkedList layerlist = new LinkedList(); layerlist.add("Common"); - for (int l = 0; l < 26; l++) - { - String ls = String.format("Layer%1$c", 'A'+l); - if (curZoneArc.objects.containsKey(ls.toLowerCase())) - layerlist.add(ls); + for (int l = 0; l < 26; l++) { + String layerstring = String.format("Layer$c", 'A'+l); + if (curZoneArc.objects.containsKey(layerstring.toLowerCase())) + layerlist.add(layerstring); } - - pnlObjectSettings.addCategory("obj_general", "General"); - if (selectedObj.getClass() != StageObj.class) { - if (selectedObj.name != null && selectedObj.getClass() != StartObj.class && selectedObj.getClass() != DebugObj.class && selectedObj.getClass() != ChangeObj.class) + + if (selectedObj.getClass() != PathPointObj.class) { + pnlObjectSettings.addCategory("obj_general", "General"); + if (selectedObj.getClass() != StartObj.class && selectedObj.getClass() != DebugObj.class && selectedObj.getClass() != ChangeObj.class) pnlObjectSettings.addField("name", "Object", "objname", null, selectedObj.name, "Default"); if (galaxyMode) pnlObjectSettings.addField("zone", "Zone", "list", galaxyArc.zoneList, selectedObj.zone.zoneName, "Default"); pnlObjectSettings.addField("layer", "Layer", "list", layerlist, layer, "Default"); } - else { - pnlObjectSettings.addField("name", "Object", "noedit", null, selectedObj.name, "Default"); - if (galaxyMode) - pnlObjectSettings.addField("zone", "Zone", "noedit", galaxyArc.zoneList, selectedObj.zone.zoneName, "Default"); - pnlObjectSettings.addField("layer", "Layer", "noedit", layerlist, layer, "Default"); - } selectedObj.getProperties(pnlObjectSettings); } } - if (selectedObjs.size() > 1) - { + if (selectedObjs.size() > 1) { pnlObjectSettings.removeField("pos_x"); pnlObjectSettings.removeField("pos_y"); pnlObjectSettings.removeField("pos_z"); pnlObjectSettings.removeField("pnt0_x"); pnlObjectSettings.removeField("pnt0_y"); pnlObjectSettings.removeField("pnt0_z"); pnlObjectSettings.removeField("pnt1_x"); pnlObjectSettings.removeField("pnt1_y"); pnlObjectSettings.removeField("pnt1_z"); @@ -1002,29 +856,23 @@ else if (cls == null) glCanvas.requestFocusInWindow(); } - private void setStatusText() - { - if (galaxyMode) - lbStatusLabel.setText("Editing scenario " + lbScenarioList.getSelectedValue() + ", zone " + curZone); - else - lbStatusLabel.setText("Editing zone " + curZone); + private void setStatusText() { + lbStatusLabel.setText(galaxyMode ? "Editing scenario " + lbScenarioList.getSelectedValue() + ", zone " + curZone : "Editing zone " + curZone); } - private void populateObjectSublist(int layermask, ObjListTreeNode objnode, Class type) - { - for (java.util.List objs : curZoneArc.objects.values()) - { - for (LevelObject obj : objs) - { + private void populateObjectSublist(int layermask, ObjListTreeNode objnode, Class type) { + for (java.util.List objs : curZoneArc.objects.values()) { + for (AbstractObj obj : objs) { if (obj.getClass() != type) continue; - if (!obj.layer.equals("common")) - { + if (!obj.layer.equals("common")) { int layernum = obj.layer.charAt(5) - 'a'; - if ((layermask & (2 << layernum)) == 0) continue; + if ((layermask & (2 << layernum)) == 0) + continue; } - else if ((layermask & 1) == 0) continue; + else if ((layermask & 1) == 0) + continue; TreeNode tn = objnode.addObject(obj); treeNodeList.put(obj.uniqueID, tn); @@ -1032,33 +880,85 @@ private void populateObjectSublist(int layermask, ObjListTreeNode objnode, Class } } - private void populateObjectList(int layermask) - { + private void populateObjectList(int layermask) { treeNodeList.clear(); DefaultTreeModel objlist = (DefaultTreeModel)tvObjectList.getModel(); DefaultMutableTreeNode root = new DefaultMutableTreeNode(curZone); objlist.setRoot(root); - ObjListTreeNode objnode; - objnode = new ObjListTreeNode(); objnode.setUserObject("General"); root.add(objnode); populateObjectSublist(layermask, objnode, GeneralObject.class); - if (ZoneArchive.gameMask==1) { objnode = new ObjListTreeNode(); objnode.setUserObject("ChildObj"); root.add(objnode); populateObjectSublist(layermask, objnode, ChildObj.class); } - objnode = new ObjListTreeNode(); objnode.setUserObject("MapParts"); root.add(objnode); populateObjectSublist(layermask, objnode, MapPartObj.class); - objnode = new ObjListTreeNode(); objnode.setUserObject("Gravity"); root.add(objnode); populateObjectSublist(layermask, objnode, PlanetObj.class); - objnode = new ObjListTreeNode(); objnode.setUserObject("Starting points"); root.add(objnode); populateObjectSublist(layermask, objnode, StartObj.class); - objnode = new ObjListTreeNode(); objnode.setUserObject("Areas"); root.add(objnode); populateObjectSublist(layermask, objnode, AreaObj.class); - objnode = new ObjListTreeNode(); objnode.setUserObject("Camera areas"); root.add(objnode); populateObjectSublist(layermask, objnode, CameraCubeObj.class); - if (ZoneArchive.gameMask==1) { objnode = new ObjListTreeNode(); objnode.setUserObject("Sound"); root.add(objnode); populateObjectSublist(layermask, objnode, SoundObj.class); } - objnode = new ObjListTreeNode(); objnode.setUserObject("Cutscenes"); root.add(objnode); populateObjectSublist(layermask, objnode, DemoObj.class); - objnode = new ObjListTreeNode(); objnode.setUserObject("GeneralPos"); root.add(objnode); populateObjectSublist(layermask, objnode, GeneralPosObj.class); - if (ZoneArchive.gameMask==2) { objnode = new ObjListTreeNode(); objnode.setUserObject("ChangeObj"); root.add(objnode); populateObjectSublist(layermask, objnode, ChangeObj.class); } - objnode = new ObjListTreeNode(); objnode.setUserObject("Debug"); root.add(objnode); populateObjectSublist(layermask, objnode, DebugObj.class); - objnode = new ObjListTreeNode(); objnode.setUserObject("Stages"); root.add(objnode); populateObjectSublist(layermask, objnode, StageObj.class); - - objnode = new ObjListTreeNode(); objnode.setUserObject("Paths"); root.add(objnode); - - for (PathObject obj : curZoneArc.paths) - { + + objnode = new ObjListTreeNode(); + objnode.setUserObject("General"); + root.add(objnode); + populateObjectSublist(layermask, objnode, LevelObj.class); + + if (ZoneArchive.game == 1) { + objnode = new ObjListTreeNode(); + objnode.setUserObject("ChildObj"); + root.add(objnode); + populateObjectSublist(layermask, objnode, ChildObj.class); + } + + objnode = new ObjListTreeNode(); + objnode.setUserObject("MapParts"); + root.add(objnode); + populateObjectSublist(layermask, objnode, MapPartObj.class); + + objnode = new ObjListTreeNode(); + objnode.setUserObject("Gravity"); + root.add(objnode); + populateObjectSublist(layermask, objnode, GravityObj.class); + + objnode = new ObjListTreeNode(); + objnode.setUserObject("Starting points"); + root.add(objnode); + populateObjectSublist(layermask, objnode, StartObj.class); + + objnode = new ObjListTreeNode(); + objnode.setUserObject("Areas"); + root.add(objnode); + populateObjectSublist(layermask, objnode, AreaObj.class); + + objnode = new ObjListTreeNode(); + objnode.setUserObject("Cameras"); + root.add(objnode); + populateObjectSublist(layermask, objnode, CameraObj.class); + + if (ZoneArchive.game == 1) { + objnode = new ObjListTreeNode(); + objnode.setUserObject("Sounds"); + root.add(objnode); + populateObjectSublist(layermask, objnode, SoundObj.class); + } + + objnode = new ObjListTreeNode(); + objnode.setUserObject("Cutscenes"); + root.add(objnode); + populateObjectSublist(layermask, objnode, CutsceneObj.class); + + objnode = new ObjListTreeNode(); + objnode.setUserObject("Positions"); + root.add(objnode); + populateObjectSublist(layermask, objnode, PositionObj.class); + + if (ZoneArchive.game == 2) { + objnode = new ObjListTreeNode(); + objnode.setUserObject("Changers"); + root.add(objnode); + populateObjectSublist(layermask, objnode, ChangeObj.class); + } + + objnode = new ObjListTreeNode(); + objnode.setUserObject("Debug"); + root.add(objnode); + populateObjectSublist(layermask, objnode, DebugObj.class); + + objnode = new ObjListTreeNode(); + objnode.setUserObject("Paths"); + root.add(objnode); + + for (PathObj obj : curZoneArc.paths) { ObjListTreeNode tn = (ObjListTreeNode)objnode.addObject(obj); treeNodeList.put(obj.uniqueID, tn); @@ -1067,8 +967,7 @@ private void populateObjectList(int layermask) } } - private void layerSelectChange(int index, boolean status) - { + private void layerSelectChange(int index, boolean status) { JCheckBox cbx = (JCheckBox)lbLayersList.getModel().getElementAt(index); int layer = cbx.getText().equals("Common") ? 1 : (2 << (cbx.getText().charAt(5) - 'A')); @@ -1083,7 +982,7 @@ private void layerSelectChange(int index, boolean status) private void btnDeselectActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnDeselectActionPerformed {//GEN-HEADEREND:event_btnDeselectActionPerformed - for (LevelObject obj : selectedObjs.values()) + for (AbstractObj obj : selectedObjs.values()) addRerenderTask("zone:"+obj.zone.zoneName); selectedObjs.clear(); @@ -1091,11 +990,8 @@ private void btnDeselectActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIR glCanvas.repaint(); }//GEN-LAST:event_btnDeselectActionPerformed - private void saveChanges() - { - - try - { + private void saveChanges() { + try { for (ZoneArchive zonearc : zoneArcs.values()) zonearc.save(); @@ -1103,16 +999,14 @@ private void saveChanges() if (!galaxyMode && parentForm != null) parentForm.updateZone(galaxyName); - else - { - for (GalaxyEditorForm form : childZoneEditors.values()) + else { + for (GalaxyEditorForm form : zoneEditors.values()) form.updateZone(form.galaxyName); } unsavedChanges = false; } - catch (IOException ex) - { + catch (IOException ex) { lbStatusLabel.setText("Failed to save changes: "+ex.getMessage()); ex.printStackTrace(); } @@ -1120,26 +1014,25 @@ private void saveChanges() private void formWindowClosing(java.awt.event.WindowEvent evt)//GEN-FIRST:event_formWindowClosing {//GEN-HEADEREND:event_formWindowClosing - if (galaxyMode) - { - for (GalaxyEditorForm form : childZoneEditors.values()) + if (galaxyMode) { + for (GalaxyEditorForm form : zoneEditors.values()) form.dispose(); } - if (unsavedChanges) - { - int res = JOptionPane.showConfirmDialog(this, "Save your changes?", - Whitehole.fullName, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); + if (unsavedChanges) { + int res = JOptionPane.showConfirmDialog(this, "Save your changes?", Whitehole.NAME, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (res == JOptionPane.CANCEL_OPTION) setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); - else - { + else { setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); if (res == JOptionPane.YES_OPTION) saveChanges(); } } + + for (ZoneArchive zonearc : zoneArcs.values()) + zonearc.close(); }//GEN-LAST:event_formWindowClosing private void btnShowPathsActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnShowPathsActionPerformed @@ -1176,10 +1069,10 @@ private void tvObjectListValueChanged(javax.swing.event.TreeSelectionEvent evt) continue; ObjTreeNode tnode = (ObjTreeNode)node; - if (!(tnode.object instanceof LevelObject)) + if (!(tnode.object instanceof AbstractObj)) continue; - LevelObject obj = (LevelObject)tnode.object; + AbstractObj obj = (AbstractObj)tnode.object; if (evt.isAddedPath(path)) { @@ -1203,8 +1096,8 @@ private void tgbDeleteObjectActionPerformed(java.awt.event.ActionEvent evt) {//G { if (tgbDeleteObject.isSelected()) { - Collection templist = ((HashMap)selectedObjs.clone()).values(); - for (LevelObject selectedObj : templist) + Collection templist = ((HashMap)selectedObjs.clone()).values(); + for (AbstractObj selectedObj : templist) { selectedObjs.remove(selectedObj.uniqueID); if (selectedObj.getClass() != StageObj.class) { @@ -1266,21 +1159,21 @@ private void lbZoneListValueChanged(javax.swing.event.ListSelectionEvent evt) {/ }//GEN-LAST:event_lbZoneListValueChanged private void btnEditZoneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEditZoneActionPerformed - if (childZoneEditors.containsKey(curZone)) + if (zoneEditors.containsKey(curZone)) { - if (!childZoneEditors.get(curZone).isVisible()) + if (!zoneEditors.get(curZone).isVisible()) { - childZoneEditors.remove(curZone); + zoneEditors.remove(curZone); } else { - childZoneEditors.get(curZone).toFront(); + zoneEditors.get(curZone).toFront(); return; } } GalaxyEditorForm form = new GalaxyEditorForm(this, curZoneArc); form.setVisible(true); - childZoneEditors.put(curZone, form); + zoneEditors.put(curZone, form); }//GEN-LAST:event_btnEditZoneActionPerformed private void lbScenarioListValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_lbScenarioListValueChanged @@ -1339,88 +1232,137 @@ private void itemCloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIR private void itemPositionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemPositionActionPerformed if (selectedObjs.size() == 1) { - for (LevelObject selectedObj : selectedObjs.values()) { - if (selectedObj.getClass() != PathPointObject.class) { - copyPos = new Vector3(selectedObj.position); - itemPositionPaste.setText("Position (" + copyPos.x + ", " + copyPos.y + ", " + copyPos.z + ")"); - lbStatusLabel.setText("Copy position " + copyPos.x + ", " + copyPos.y + ", " + copyPos.z); - } + for (AbstractObj selectedObj : selectedObjs.values()) { + copyPos = (Vector3) selectedObj.position.clone(); + itemPositionPaste.setText("Position (" + copyPos.x + ", " + copyPos.y + ", " + copyPos.z + ")"); + lbStatusLabel.setText("Copy position " + copyPos.x + ", " + copyPos.y + ", " + copyPos.z); } } }//GEN-LAST:event_itemPositionActionPerformed private void itemRotationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemRotationActionPerformed if (selectedObjs.size() == 1) { - for (LevelObject selectedObj : selectedObjs.values()) { - if (selectedObj.getClass() != PathPointObject.class) { - copyDir = new Vector3(selectedObj.rotation); - itemRotationPaste.setText("Rotation (" + copyDir.x + ", " + copyDir.y + ", " + copyDir.z + ")"); - lbStatusLabel.setText("Copy rotation " + copyDir.x + ", " + copyDir.y + ", " + copyDir.z); - } + for (AbstractObj selectedObj : selectedObjs.values()) { + if (selectedObj instanceof PathPointObj) + return; + + copyDir = (Vector3) selectedObj.rotation.clone(); + itemRotationPaste.setText("Rotation (" + copyDir.x + ", " + copyDir.y + ", " + copyDir.z + ")"); + lbStatusLabel.setText("Copy rotation " + copyDir.x + ", " + copyDir.y + ", " + copyDir.z); } } }//GEN-LAST:event_itemRotationActionPerformed private void itemScaleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemScaleActionPerformed if (selectedObjs.size() == 1) { - for (LevelObject selectedObj : selectedObjs.values()) { - if (selectedObj.getClass() != PathPointObject.class && selectedObj.getClass() != GeneralPosObj.class) { - copyScale = new Vector3(selectedObj.scale); - itemScalePaste.setText("Scale (" + copyScale.x + ", " + copyScale.y + ", " + copyScale.z + ")"); - lbStatusLabel.setText("Copy scale " + copyScale.x + ", " + copyScale.y + ", " + copyScale.z); - } + for (AbstractObj selectedObj : selectedObjs.values()) { + if (selectedObj instanceof PathPointObj || selectedObj instanceof PositionObj || selectedObj instanceof StageObj) + return; + + copyScale = (Vector3) selectedObj.scale.clone(); + itemScalePaste.setText("Scale (" + copyScale.x + ", " + copyScale.y + ", " + copyScale.z + ")"); + lbStatusLabel.setText("Copy scale " + copyScale.x + ", " + copyScale.y + ", " + copyScale.z); } } }//GEN-LAST:event_itemScaleActionPerformed private void itemScalePasteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemScalePasteActionPerformed - for (LevelObject selectedObj : selectedObjs.values()) { - if (selectedObj.getClass() != PathPointObject.class && selectedObj.getClass() != StageObj.class && selectedObj.getClass() != GeneralPosObj.class) { - selectedObj.scale = copyScale; - rerenderTasks.add("object:"+selectedObj.uniqueID); - rerenderTasks.add("zone:"+selectedObj.zone.zoneName); - pnlObjectSettings.setFieldValue("scale_x", selectedObj.scale.x); - pnlObjectSettings.setFieldValue("scale_y", selectedObj.scale.y); - pnlObjectSettings.setFieldValue("scale_z", selectedObj.scale.z); - pnlObjectSettings.repaint(); - glCanvas.repaint(); - lbStatusLabel.setText("Paste scale " + copyScale.x + ", " + copyScale.y + ", " + copyScale.z); - unsavedChanges = true; - } + for (AbstractObj selectedObj : selectedObjs.values()) { + if (selectedObj instanceof PathPointObj || selectedObj instanceof PositionObj || selectedObj instanceof StageObj) + return; + + selectedObj.scale = (Vector3) copyScale.clone(); + + pnlObjectSettings.setFieldValue("scale_x", selectedObj.scale.x); + pnlObjectSettings.setFieldValue("scale_y", selectedObj.scale.y); + pnlObjectSettings.setFieldValue("scale_z", selectedObj.scale.z); + pnlObjectSettings.repaint(); + + + rerenderTasks.add("object:"+selectedObj.uniqueID); + rerenderTasks.add("zone:"+selectedObj.zone.zoneName); + + glCanvas.repaint(); + lbStatusLabel.setText("Paste scale " + copyScale.x + ", " + copyScale.y + ", " + copyScale.z); + unsavedChanges = true; } }//GEN-LAST:event_itemScalePasteActionPerformed private void itemPositionPasteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemPositionPasteActionPerformed - for (LevelObject selectedObj : selectedObjs.values()) { - if (selectedObj.getClass() != PathPointObject.class && selectedObj.getClass() != StageObj.class) { - selectedObj.position = copyPos; - rerenderTasks.add("object:"+selectedObj.uniqueID); - rerenderTasks.add("zone:"+selectedObj.zone.zoneName); + for (AbstractObj selectedObj : selectedObjs.values()) { + if (selectedObj instanceof StageObj) + return; + + if (selectedObj instanceof PathPointObj) { + PathPointObj selectedPathPoint = (PathPointObj) selectedObj; + + Vector3 oldpos = (Vector3) selectedPathPoint.position.clone(); + Vector3 newpos = (Vector3) copyPos.clone(); + Vector3 pnt1pos = new Vector3( + (newpos.x - oldpos.x) + selectedPathPoint.point1.x, + (newpos.y - oldpos.y) + selectedPathPoint.point1.y, + (newpos.z - oldpos.z) + selectedPathPoint.point1.z + ); + Vector3 pnt2pos = new Vector3( + (newpos.x - oldpos.x) + selectedPathPoint.point2.x, + (newpos.y - oldpos.y) + selectedPathPoint.point2.y, + (newpos.z - oldpos.z) + selectedPathPoint.point2.z + ); + + selectedPathPoint.position = newpos; + selectedPathPoint.point1 = pnt1pos; + selectedPathPoint.point2 = pnt2pos; + + pnlObjectSettings.setFieldValue("pnt0_x", selectedPathPoint.position.x); + pnlObjectSettings.setFieldValue("pnt0_y", selectedPathPoint.position.y); + pnlObjectSettings.setFieldValue("pnt0_z", selectedPathPoint.position.z); + pnlObjectSettings.setFieldValue("pnt1_x", selectedPathPoint.point1.x); + pnlObjectSettings.setFieldValue("pnt1_y", selectedPathPoint.point1.y); + pnlObjectSettings.setFieldValue("pnt1_z", selectedPathPoint.point1.z); + pnlObjectSettings.setFieldValue("pnt2_x", selectedPathPoint.point2.x); + pnlObjectSettings.setFieldValue("pnt2_y", selectedPathPoint.point2.y); + pnlObjectSettings.setFieldValue("pnt2_z", selectedPathPoint.point2.z); + pnlObjectSettings.repaint(); + + rerenderTasks.add("path:" + selectedPathPoint.path.uniqueID); + rerenderTasks.add("zone:" + selectedPathPoint.zone.zoneName); + } + else { + selectedObj.position = (Vector3) copyPos.clone(); + pnlObjectSettings.setFieldValue("pos_x", selectedObj.position.x); pnlObjectSettings.setFieldValue("pos_y", selectedObj.position.y); pnlObjectSettings.setFieldValue("pos_z", selectedObj.position.z); pnlObjectSettings.repaint(); - glCanvas.repaint(); - lbStatusLabel.setText("Paste position " + copyPos.x + ", " + copyPos.y + ", " + copyPos.z); - unsavedChanges = true; + + rerenderTasks.add("object:" + selectedObj.uniqueID); + rerenderTasks.add("zone:" + selectedObj.zone.zoneName); } + + glCanvas.repaint(); + lbStatusLabel.setText("Paste position " + copyPos.x + ", " + copyPos.y + ", " + copyPos.z); + unsavedChanges = true; } }//GEN-LAST:event_itemPositionPasteActionPerformed private void itemRotationPasteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemRotationPasteActionPerformed - for (LevelObject selectedObj : selectedObjs.values()) { - if (selectedObj.getClass() != PathPointObject.class && selectedObj.getClass() != StageObj.class) { - selectedObj.rotation = copyDir; - rerenderTasks.add("object:"+selectedObj.uniqueID); - rerenderTasks.add("zone:"+selectedObj.zone.zoneName); - pnlObjectSettings.setFieldValue("dir_x", selectedObj.rotation.x); - pnlObjectSettings.setFieldValue("dir_y", selectedObj.rotation.y); - pnlObjectSettings.setFieldValue("dir_z", selectedObj.rotation.z); - pnlObjectSettings.repaint(); - glCanvas.repaint(); - lbStatusLabel.setText("Paste rotation " + copyDir.x + ", " + copyDir.y + ", " + copyDir.z); - unsavedChanges = true; - } + for (AbstractObj selectedObj : selectedObjs.values()) { + if (selectedObj.getClass() != PathPointObj.class) + return; + + selectedObj.rotation = (Vector3) copyDir.clone(); + + pnlObjectSettings.setFieldValue("dir_x", selectedObj.rotation.x); + pnlObjectSettings.setFieldValue("dir_y", selectedObj.rotation.y); + pnlObjectSettings.setFieldValue("dir_z", selectedObj.rotation.z); + pnlObjectSettings.repaint(); + + rerenderTasks.add("object:"+selectedObj.uniqueID); + rerenderTasks.add("zone:"+selectedObj.zone.zoneName); + + glCanvas.repaint(); + lbStatusLabel.setText("Paste rotation " + copyDir.x + ", " + copyDir.y + ", " + copyDir.z); + unsavedChanges = true; } }//GEN-LAST:event_itemRotationPasteActionPerformed @@ -1442,25 +1384,21 @@ private void itemControlsActionPerformed(java.awt.event.ActionEvent evt) {//GEN- "SHIFT + P: Paste position\r\n" + "SHIFT + R: Paste rotation\r\n" + "SHIFT + S: Paste scale", - Whitehole.fullName, JOptionPane.INFORMATION_MESSAGE); + Whitehole.NAME, JOptionPane.INFORMATION_MESSAGE); }//GEN-LAST:event_itemControlsActionPerformed - - public void addRerenderTask(String task) - { + public void addRerenderTask(String task) { if (!rerenderTasks.contains(task)) rerenderTasks.add(task); } - - public void applySubzoneRotation(Vector3 delta) - { - if (!galaxyMode) return; + public void applySubzoneRotation(Vector3 delta) { + if (!galaxyMode) + return; String szkey = String.format("%1$d/%2$s", curScenarioID, curZone); - if (subZoneData.containsKey(szkey)) - { - SubZoneData szdata = subZoneData.get(szkey); + if (subZoneData.containsKey(szkey)) { + StageObj szdata = subZoneData.get(szkey); float xcos = (float)Math.cos(-(szdata.rotation.x * Math.PI) / 180f); float xsin = (float)Math.sin(-(szdata.rotation.x * Math.PI) / 180f); @@ -1482,8 +1420,7 @@ public void applySubzoneRotation(Vector3 delta) } } - private Vector3 get3DCoords(Point pt, float depth) - { + private Vector3 get3DCoords(Point pt, float depth) { Vector3 ret = new Vector3( camPosition.x * scaledown, camPosition.y * scaledown, @@ -1504,16 +1441,12 @@ private Vector3 get3DCoords(Point pt, float depth) return ret; } - private void offsetSelectionBy(Vector3 delta) - { - for (LevelObject selectedObj : selectedObjs.values()) - { - if (selectedObj instanceof PathPointObject) - { - PathPointObject selectedPathPoint = (PathPointObject)selectedObj; + private void offsetSelectionBy(Vector3 delta) { + for (AbstractObj selectedObj : selectedObjs.values()) { + if (selectedObj instanceof PathPointObj) { + PathPointObj selectedPathPoint = (PathPointObj)selectedObj; - switch (selectionArg) - { + switch (selectionArg) { case 0: selectedPathPoint.position.x += delta.x; selectedPathPoint.position.y += delta.y; @@ -1550,170 +1483,228 @@ private void offsetSelectionBy(Vector3 delta) rerenderTasks.add(String.format("path:%1$d", selectedPathPoint.path.uniqueID)); rerenderTasks.add("zone:"+selectedPathPoint.path.zone.zoneName); } - else - { - if (selectedObj.getClass() != StageObj.class) { - selectedObj.position.x += delta.x; - selectedObj.position.y += delta.y; - selectedObj.position.z += delta.z; - pnlObjectSettings.setFieldValue("pos_x", selectedObj.position.x); - pnlObjectSettings.setFieldValue("pos_y", selectedObj.position.y); - pnlObjectSettings.setFieldValue("pos_z", selectedObj.position.z); - pnlObjectSettings.repaint(); - addRerenderTask("zone:"+selectedObj.zone.zoneName); - } + else { + if (selectedObj instanceof StageObj) + return; + + selectedObj.position.x += delta.x; + selectedObj.position.y += delta.y; + selectedObj.position.z += delta.z; + pnlObjectSettings.setFieldValue("pos_x", selectedObj.position.x); + pnlObjectSettings.setFieldValue("pos_y", selectedObj.position.y); + pnlObjectSettings.setFieldValue("pos_z", selectedObj.position.z); + pnlObjectSettings.repaint(); + addRerenderTask("zone:"+selectedObj.zone.zoneName); } glCanvas.repaint(); } } - private void rotationSelectionBy(Vector3 delta) - { - for (LevelObject selectedObj : selectedObjs.values()) { - if (selectedObj.getClass() != StageObj.class && selectedObj.getClass() != PathPointObject.class) { - selectedObj.rotation.x += delta.x; - selectedObj.rotation.y += delta.y; - selectedObj.rotation.z += delta.z; - pnlObjectSettings.setFieldValue("dir_x", selectedObj.rotation.x); - pnlObjectSettings.setFieldValue("dir_y", selectedObj.rotation.y); - pnlObjectSettings.setFieldValue("dir_z", selectedObj.rotation.z); - pnlObjectSettings.repaint(); - addRerenderTask("zone:"+selectedObj.zone.zoneName); - addRerenderTask("object:"+selectedObj.uniqueID); - glCanvas.repaint(); - } + private void rotationSelectionBy(Vector3 delta) { + for (AbstractObj selectedObj : selectedObjs.values()) { + if (selectedObj instanceof StageObj || selectedObj instanceof PositionObj || selectedObj instanceof PathPointObj) + return; + + selectedObj.rotation.x += delta.x; + selectedObj.rotation.y += delta.y; + selectedObj.rotation.z += delta.z; + pnlObjectSettings.setFieldValue("dir_x", selectedObj.rotation.x); + pnlObjectSettings.setFieldValue("dir_y", selectedObj.rotation.y); + pnlObjectSettings.setFieldValue("dir_z", selectedObj.rotation.z); + pnlObjectSettings.repaint(); + addRerenderTask("zone:"+selectedObj.zone.zoneName); + addRerenderTask("object:"+selectedObj.uniqueID); + glCanvas.repaint(); } } - private void scaleSelectionBy(Vector3 delta) - { - for (LevelObject selectedObj : selectedObjs.values()) { - if (selectedObj.getClass() != StageObj.class && selectedObj.getClass() != GeneralPosObj.class && selectedObj.getClass() != PathPointObject.class) { - selectedObj.scale.x += delta.x; - selectedObj.scale.y += delta.y; - selectedObj.scale.z += delta.z; - pnlObjectSettings.setFieldValue("scale_x", selectedObj.scale.x); - pnlObjectSettings.setFieldValue("scale_y", selectedObj.scale.y); - pnlObjectSettings.setFieldValue("scale_z", selectedObj.scale.z); - pnlObjectSettings.repaint(); - addRerenderTask("zone:"+selectedObj.zone.zoneName); - addRerenderTask("object:"+selectedObj.uniqueID); - glCanvas.repaint(); - } + private void scaleSelectionBy(Vector3 delta) { + for (AbstractObj selectedObj : selectedObjs.values()) { + if (selectedObj instanceof StageObj || selectedObj instanceof PositionObj || selectedObj instanceof PathPointObj) + return; + + selectedObj.scale.x += delta.x; + selectedObj.scale.y += delta.y; + selectedObj.scale.z += delta.z; + pnlObjectSettings.setFieldValue("scale_x", selectedObj.scale.x); + pnlObjectSettings.setFieldValue("scale_y", selectedObj.scale.y); + pnlObjectSettings.setFieldValue("scale_z", selectedObj.scale.z); + pnlObjectSettings.repaint(); + addRerenderTask("zone:"+selectedObj.zone.zoneName); + addRerenderTask("object:"+selectedObj.uniqueID); + glCanvas.repaint(); } } - private void addObject(Point where) - { + private void addObject(Point where) { Vector3 pos = get3DCoords(where, Math.min(pickingDepth, 1f)); - if (galaxyMode) - { + if (galaxyMode) { String szkey = String.format("%1$d/%2$s", curScenarioID, curZone); - if (subZoneData.containsKey(szkey)) - { - SubZoneData szdata = subZoneData.get(szkey); + if (subZoneData.containsKey(szkey)) { + StageObj szdata = subZoneData.get(szkey); Vector3.subtract(pos, szdata.position, pos); applySubzoneRotation(pos); } } - String objtype = objectBeingAdded.substring(0, objectBeingAdded.indexOf('|')); - String objname = objectBeingAdded.substring(objectBeingAdded.indexOf('|') + 1); + String objtype = addingObject.substring(0, addingObject.indexOf('|')); + String objname = addingObject.substring(addingObject.indexOf('|') + 1); + addingObjectOnLayer = addingObjectOnLayer.toLowerCase(); - LevelObject newobj = null; - int pnodeid = -1; - if (ZoneArchive.gameMask==2) { - switch (objtype) { - case "general": - newobj = new GeneralObject(curZoneArc, "Placement/" + addingOnLayer + "/ObjInfo", ZoneArchive.gameMask, objname, pos); - pnodeid = 0; - break; - case "mappart": - newobj = new MapPartObj(curZoneArc, "MapParts/" + addingOnLayer + "/MapPartsInfo", ZoneArchive.gameMask, objname, pos); - pnodeid = 1; - break; - case "gravity": - newobj = new PlanetObj(curZoneArc, "Placement/" + addingOnLayer + "/PlanetObjInfo", ZoneArchive.gameMask, objname, pos); - pnodeid = 2; - break; - case "start": - newobj = new StartObj(curZoneArc, "Start/" + addingOnLayer + "/StartInfo", ZoneArchive.gameMask, pos); - pnodeid = 3; - break; - case "area": - newobj = new AreaObj(curZoneArc, "Placement/" + addingOnLayer + "/AreaObjInfo", ZoneArchive.gameMask, objname, pos); - pnodeid = 4; - break; - case "camera": - newobj = new CameraCubeObj(curZoneArc, "Placement/" + addingOnLayer + "/CameraCubeInfo", ZoneArchive.gameMask, objname, pos); - pnodeid = 5; - break; - case "demo": - newobj = new DemoObj(curZoneArc, "Placement/" + addingOnLayer + "/DemoObjInfo", ZoneArchive.gameMask, objname, pos); - pnodeid = 6; - break; - case "generalpos": - newobj = new GeneralPosObj(curZoneArc, "GeneralPos/" + addingOnLayer + "/GeneralPosInfo", ZoneArchive.gameMask, pos); - pnodeid = 7; - break; - case "change": - newobj = new ChangeObj(curZoneArc, "Placement/" + addingOnLayer + "/ChangeObjInfo", ZoneArchive.gameMask, pos); - pnodeid = 8; - break; - case "debug": - newobj = new DebugObj(curZoneArc, "Debug/" + addingOnLayer + "/DebugMoveInfo", ZoneArchive.gameMask, objname, pos); - pnodeid = 9; - break; + int nodeid = -1; + + // If the requested object is a path or pathpoint, a special + // function is required to add them properly. + if (objtype.equals("path") || (objtype.equals("pathpoint"))) { + if (objtype.equals("path")) { + int newid = 0; + for (;;) { + boolean found = true; + for (PathObj pobj: curZoneArc.paths) { + if (pobj.index == newid) { + found = false; + break; + } + } + if (found) { + break; + } + newid++; + } + + PathObj thepath = new PathObj(curZoneArc, newid); + thepath.uniqueID = maxUniqueID++; + globalPathList.put(thepath.uniqueID, thepath); + curZoneArc.paths.add(thepath); + + thepath.createStorage(); + + PathPointObj thepoint = new PathPointObj(thepath, 0, pos); + thepoint.uniqueID = maxUniqueID; + maxUniqueID++; + globalObjList.put(thepoint.uniqueID, thepoint); + globalPathPointList.put(thepoint.uniqueID, thepoint); + thepath.points.put(thepoint.index, thepoint); + + DefaultTreeModel objlist = (DefaultTreeModel) tvObjectList.getModel(); + ObjListTreeNode listnode = (ObjListTreeNode) ((DefaultMutableTreeNode) objlist.getRoot()).getChildAt(ZoneArchive.game == 2 ? 10 : 11); + ObjListTreeNode newnode = (ObjListTreeNode) listnode.addObject(thepath); + objlist.nodesWereInserted(listnode, new int[] { listnode.getIndex(newnode) }); + treeNodeList.put(thepath.uniqueID, newnode); + + TreeNode newpointnode = newnode.addObject(thepoint); + objlist.nodesWereInserted(newnode, new int[] { newnode.getIndex(newpointnode) }); + treeNodeList.put(thepoint.uniqueID, newpointnode); + + rerenderTasks.add("path:" + thepath.uniqueID); + rerenderTasks.add("zone:" + curZone); + glCanvas.repaint(); + unsavedChanges = true; + } + else { + if (selectedObjs.size() > 1) + return; + + PathObj thepath = null; + for (AbstractObj obj : selectedObjs.values()) + thepath = ((PathPointObj) obj).path; + + if (thepath == null) + return; + + int newid = 0; + if (!thepath.points.isEmpty()) { + for (PathPointObj pt : thepath.points.values()) { + if (pt.index > newid) { + newid = pt.index; + } + } + newid++; + } + + PathPointObj thepoint = new PathPointObj(thepath, newid, pos); + thepoint.uniqueID = maxUniqueID; + maxUniqueID += 3; + globalObjList.put(thepoint.uniqueID, thepoint); + globalPathPointList.put(thepoint.uniqueID, thepoint); + thepath.points.put(thepoint.index, thepoint); + + DefaultTreeModel objlist = (DefaultTreeModel) tvObjectList.getModel(); + ObjListTreeNode listnode = (ObjListTreeNode) ((DefaultMutableTreeNode) objlist.getRoot()).getChildAt(ZoneArchive.game == 2 ? 10 : 11); + listnode = (ObjListTreeNode) listnode.children.get(thepath.uniqueID); + + TreeNode newnode = listnode.addObject(thepoint); + objlist.nodesWereInserted(listnode, new int[] { listnode.getIndex(newnode) }); + treeNodeList.put(thepoint.uniqueID, newnode); + + rerenderTasks.add("path:" + thepath.uniqueID); + rerenderTasks.add("zone:" + thepath.zone.zoneName); + glCanvas.repaint(); + unsavedChanges = true; } + return; } - else { - switch (objtype) { - case "general": - newobj = new GeneralObject(curZoneArc, "Placement/" + addingOnLayer + "/ObjInfo", ZoneArchive.gameMask, objname, pos); - pnodeid = 0; - break; - case "child": - newobj = new ChildObj(curZoneArc, "ChildObj/" + addingOnLayer + "/ChildObjInfo", ZoneArchive.gameMask, objname, pos); - pnodeid = 1; - break; - case "mappart": - newobj = new MapPartObj(curZoneArc, "MapParts/" + addingOnLayer + "/MapPartsInfo", ZoneArchive.gameMask, objname, pos); - pnodeid = 2; - break; - case "gravity": - newobj = new PlanetObj(curZoneArc, "Placement/" + addingOnLayer + "/PlanetObjInfo", ZoneArchive.gameMask, objname, pos); - pnodeid = 3; - break; - case "start": - newobj = new StartObj(curZoneArc, "Start/" + addingOnLayer + "/StartInfo", ZoneArchive.gameMask, pos); - pnodeid = 4; - break; - case "area": - newobj = new AreaObj(curZoneArc, "Placement/" + addingOnLayer + "/AreaObjInfo", ZoneArchive.gameMask, objname, pos); - pnodeid = 5; - break; - case "camera": - newobj = new CameraCubeObj(curZoneArc, "Placement/" + addingOnLayer + "/CameraCubeInfo", ZoneArchive.gameMask, objname, pos); - pnodeid = 6; + + AbstractObj newobj = null; + + switch (objtype) { + case "general": + newobj = new LevelObj(curZoneArc, "Placement/" + addingObjectOnLayer + "/ObjInfo", ZoneArchive.game, objname, pos); + nodeid = 0; + break; + case "mappart": + newobj = new MapPartObj(curZoneArc, "MapParts/" + addingObjectOnLayer + "/MapPartsInfo", ZoneArchive.game, objname, pos); + nodeid = 1; + break; + case "gravity": + newobj = new GravityObj(curZoneArc, "Placement/" + addingObjectOnLayer + "/PlanetObjInfo", ZoneArchive.game, objname, pos); + nodeid = 2; + break; + case "start": + newobj = new StartObj(curZoneArc, "Start/" + addingObjectOnLayer + "/StartInfo", ZoneArchive.game, pos); + nodeid = 3; + break; + case "area": + newobj = new AreaObj(curZoneArc, "Placement/" + addingObjectOnLayer + "/AreaObjInfo", ZoneArchive.game, objname, pos); + nodeid = 4; + break; + case "camera": + newobj = new CameraObj(curZoneArc, "Placement/" + addingObjectOnLayer + "/CameraCubeInfo", ZoneArchive.game, objname, pos); + nodeid = 5; + break; + case "cutscene": + newobj = new CutsceneObj(curZoneArc, "Placement/" + addingObjectOnLayer + "/DemoObjInfo", ZoneArchive.game, objname, pos); + nodeid = 6; + break; + case "position": + newobj = new PositionObj(curZoneArc, "GeneralPos/" + addingObjectOnLayer + "/GeneralPosInfo", ZoneArchive.game, pos); + nodeid = 7; + break; + case "child": + if (ZoneArchive.game == 2) break; - case "sound": - newobj = new SoundObj(curZoneArc, "Placement/" + addingOnLayer + "/SoundInfo", ZoneArchive.gameMask, objname, pos); - pnodeid = 7; + newobj = new ChildObj(curZoneArc, "ChildObj/" + addingObjectOnLayer + "/ChildObjInfo", ZoneArchive.game, objname, pos); + nodeid = 8; + break; + case "sound": + if (ZoneArchive.game == 2) break; - case "demo": - newobj = new DemoObj(curZoneArc, "Placement/" + addingOnLayer + "/DemoObjInfo", ZoneArchive.gameMask, objname, pos); - pnodeid = 8; - break; - case "generalpos": - newobj = new GeneralPosObj(curZoneArc, "GeneralPos/" + addingOnLayer + "/GeneralPosInfo", ZoneArchive.gameMask, pos); - pnodeid = 9; - break; - case "debug": - newobj = new DebugObj(curZoneArc, "Debug/" + addingOnLayer + "/DebugMoveInfo", ZoneArchive.gameMask, objname, pos); - pnodeid = 10; + newobj = new SoundObj(curZoneArc, "Placement/" + addingObjectOnLayer + "/SoundInfo", ZoneArchive.game, objname, pos); + nodeid = 9; + break; + case "change": + if (ZoneArchive.game == 1) break; - } + newobj = new ChangeObj(curZoneArc, "Placement/" + addingObjectOnLayer + "/ChangeObjInfo", ZoneArchive.game, pos); + nodeid = 8; + break; + case "debug": + newobj = new DebugObj(curZoneArc, "Debug/" + addingObjectOnLayer + "/DebugMoveInfo", ZoneArchive.game, objname, pos); + nodeid = ZoneArchive.game == 2 ? 9 : 10; + break; + default: + return; } int uid = 0; @@ -1721,15 +1712,16 @@ private void addObject(Point where) || globalPathList.containsKey(uid) || globalPathPointList.containsKey(uid)) uid++; - if (uid > maxUniqueID) maxUniqueID = uid; + if (uid > maxUniqueID) + maxUniqueID = uid; newobj.uniqueID = uid; globalObjList.put(uid, newobj); - curZoneArc.objects.get(addingOnLayer.toLowerCase()).add(newobj); + curZoneArc.objects.get(addingObjectOnLayer.toLowerCase()).add(newobj); DefaultTreeModel objlist = (DefaultTreeModel)tvObjectList.getModel(); - ObjListTreeNode listnode = (ObjListTreeNode)((DefaultMutableTreeNode)objlist.getRoot()).getChildAt(pnodeid); + ObjListTreeNode listnode = (ObjListTreeNode)((DefaultMutableTreeNode)objlist.getRoot()).getChildAt(nodeid); TreeNode newnode = listnode.addObject(newobj); objlist.nodesWereInserted(listnode, new int[] { listnode.getIndex(newnode) }); treeNodeList.put(uid, newnode); @@ -1740,58 +1732,53 @@ private void addObject(Point where) unsavedChanges = true; } - private void doAddObject(String type) - { + private void setObjectBeingAdded(String type) { switch (type) { case "start": - objectBeingAdded = "start|Mario"; - addingOnLayer = "common"; + addingObject = "start|Mario"; + addingObjectOnLayer = "common"; break; case "debug": - objectBeingAdded = "debug|DebugMovePos"; - addingOnLayer = "common"; + addingObject = "debug|DebugMovePos"; + addingObjectOnLayer = "common"; break; - case "generalpos": - objectBeingAdded = "generalpos|GeneralPos"; - addingOnLayer = "common"; + case "position": + addingObject = "position|GeneralPos"; + addingObjectOnLayer = "common"; break; case "change": - objectBeingAdded = "change|ChangeObj"; - addingOnLayer = "common"; + addingObject = "change|ChangeObj"; + addingObjectOnLayer = "common"; break; case "path": - JOptionPane.showMessageDialog(this, "Path adding isn't supported yet.", Whitehole.fullName, 0); - return; + addingObject = "path|null"; + break; case "pathpoint": - JOptionPane.showMessageDialog(this, "Path point adding isn't supported yet.", Whitehole.fullName, 0); - return; + addingObject = "pathpoint|null"; + break; default: - ObjectSelectForm form = new ObjectSelectForm(this, ZoneArchive.gameMask, null); + ObjectSelectForm form = new ObjectSelectForm(this, ZoneArchive.game, null); form.setVisible(true); - if (form.selectedObject.isEmpty()) - { + if (form.selectedObject.isEmpty()) { tgbAddObject.setSelected(false); return; } - objectBeingAdded = type+"|"+form.selectedObject; - addingOnLayer = form.selectedLayer; + addingObject = type+"|"+form.selectedObject; + addingObjectOnLayer = form.selectedLayer; break; } lbStatusLabel.setText("Click the level view to place your object. Hold Shift to place multiple objects. Right-click to abort."); } - private void deleteObject(int uid) - { - if (globalObjList.containsKey(uid)) - { - LevelObject obj = globalObjList.get(uid); + private void deleteObject(int uid) { + if (globalObjList.containsKey(uid)) { + AbstractObj obj = globalObjList.get(uid); obj.zone.objects.get(obj.layer).remove(obj); rerenderTasks.add(String.format("delobj:%1$d", uid)); rerenderTasks.add("zone:"+obj.zone.zoneName); - if (treeNodeList.containsKey(uid)) - { + if (treeNodeList.containsKey(uid)) { DefaultTreeModel objlist = (DefaultTreeModel)tvObjectList.getModel(); ObjTreeNode thenode = (ObjTreeNode)treeNodeList.get(uid); objlist.removeNodeFromParent(thenode); @@ -1799,21 +1786,18 @@ private void deleteObject(int uid) } } - else if (globalPathPointList.containsKey(uid)) - { - PathPointObject obj = globalPathPointList.get(uid); + if (globalPathPointList.containsKey(uid)) { + PathPointObj obj = globalPathPointList.get(uid); obj.path.points.remove(obj.index); globalPathPointList.remove(uid); - if (obj.path.points.isEmpty()) - { + if (obj.path.points.isEmpty()) { obj.path.zone.paths.remove(obj.path); obj.path.deleteStorage(); globalPathList.remove(obj.path.uniqueID); rerenderTasks.add("zone:"+obj.path.zone.zoneName); - if (treeNodeList.containsKey(obj.path.uniqueID)) - { + if (treeNodeList.containsKey(obj.path.uniqueID)) { DefaultTreeModel objlist = (DefaultTreeModel)tvObjectList.getModel(); ObjTreeNode thenode = (ObjTreeNode)treeNodeList.get(obj.path.uniqueID); objlist.removeNodeFromParent(thenode); @@ -1821,13 +1805,11 @@ else if (globalPathPointList.containsKey(uid)) treeNodeList.remove(uid); } } - else - { + else { rerenderTasks.add(String.format("path:%1$d", obj.path.uniqueID)); rerenderTasks.add("zone:"+obj.path.zone.zoneName); - if (treeNodeList.containsKey(uid)) - { + if (treeNodeList.containsKey(uid)) { DefaultTreeModel objlist = (DefaultTreeModel)tvObjectList.getModel(); ObjTreeNode thenode = (ObjTreeNode)treeNodeList.get(uid); objlist.removeNodeFromParent(thenode); @@ -1840,189 +1822,187 @@ else if (globalPathPointList.containsKey(uid)) unsavedChanges = true; } - public String objClassToString(LevelObject obj) { - String type = String.valueOf(obj.getClass().getSimpleName()); - switch (type) { - default: - return "Object"; - case "MapPartObj": - return "MapPart"; - case "ChildObj": - return "Child"; - case "AreaObj": - return "Area"; - case "CameraCubeObj": - return "Camera"; - case "StageObj": - return "Zone"; - case "PlanetObj": - return "Gravity"; - case "StartObj": - return "Start"; - case "SoundObj": - return "Sound"; - case "GeneralPosObj": - return "GeneralPos"; - case "DemoObj": - return "Cutscene"; - case "DebugObj": - return "Debug"; - case "ChangeObj": - return "Change"; - case "PathObject": - return "Path"; - case "PathPointObject": - return "Path point"; - } + /* + * The property changing events. These methods will update the data fields + * for the selected objects. + */ + + public void propertyChanged(String propname, Object value, Bcsv.Entry data) { + Object oldval = data.get(propname); + if (oldval.getClass() == String.class) data.put(propname, value); + else if (oldval.getClass() == Integer.class) data.put(propname, (int)value); + else if (oldval.getClass() == Short.class) data.put(propname, (short)(int)value); + else if (oldval.getClass() == Byte.class) data.put(propname, (byte)(int)value); + else if (oldval.getClass() == Float.class) data.put(propname, (float)value); + else throw new UnsupportedOperationException("UNSUPPORTED PROP TYPE: " +oldval.getClass().getName()); } - public void propPanelPropertyChanged(String propname, Object value) - { - for (LevelObject selectedObj : selectedObjs.values()) - { - if (propname.equals("name")) - { - selectedObj.name = (String)value; - selectedObj.loadDBInfo(); + public void propertyPanelPropertyChanged(String propname, Object value) { + for (AbstractObj selectedObj : selectedObjs.values()) { + + // Path point objects, as they work a bit differently + if (selectedObj instanceof PathPointObj) { + PathPointObj selectedPathPoint = (PathPointObj) selectedObj; - // updates the ShapeModelNo list when changing the object's name. - // derp coding, but for now it does the trick. - if (selectedObj.getClass() == GeneralObject.class) { - pnlObjectSettings.removeField("ShapeModelNo"); - pnlObjectSettings.removeField("CommonPath_ID"); - pnlObjectSettings.removeField("ClippingGroupId"); - pnlObjectSettings.removeField("GroupId"); - pnlObjectSettings.removeField("DemoGroupId"); - pnlObjectSettings.removeField("MapParts_ID"); - if (ZoneArchive.gameMask == 2) { - pnlObjectSettings.removeField("Obj_ID"); - pnlObjectSettings.removeField("GeneratorID"); + // Path point coordinates + if (propname.startsWith("pnt")) { + switch (propname) { + case "pnt0_x": selectedPathPoint.position.x = (float)value; break; + case "pnt0_y": selectedPathPoint.position.y = (float)value; break; + case "pnt0_z": selectedPathPoint.position.z = (float)value; break; + case "pnt1_x": selectedPathPoint.point1.x = (float)value; break; + case "pnt1_y": selectedPathPoint.point1.y = (float)value; break; + case "pnt1_z": selectedPathPoint.point1.z = (float)value; break; + case "pnt2_x": selectedPathPoint.point2.x = (float)value; break; + case "pnt2_y": selectedPathPoint.point2.y = (float)value; break; + case "pnt2_z": selectedPathPoint.point2.z = (float)value; break; } - selectedObj.getProperties(pnlObjectSettings); - } - - DefaultTreeModel objlist = (DefaultTreeModel)tvObjectList.getModel(); - objlist.nodeChanged(treeNodeList.get(selectedObj.uniqueID)); - - rerenderTasks.add("object:"+Integer.toString(selectedObj.uniqueID)); - rerenderTasks.add("zone:"+selectedObj.zone.zoneName); - glCanvas.repaint(); - } - else if (propname.equals("zone")) - { - String oldzone = selectedObj.zone.zoneName; - String newzone = (String)value; - int uid = selectedObj.uniqueID; - - selectedObj.zone = zoneArcs.get(newzone); - zoneArcs.get(oldzone).objects.get(selectedObj.layer).remove(selectedObj); - if (zoneArcs.get(newzone).objects.containsKey(selectedObj.layer)) - zoneArcs.get(newzone).objects.get(selectedObj.layer).add(selectedObj); - else - { - selectedObj.layer = "common"; - zoneArcs.get(newzone).objects.get(selectedObj.layer).add(selectedObj); + + rerenderTasks.add("zone:"+selectedObj.zone.zoneName); + glCanvas.repaint(); } - for (int z = 0; z < galaxyArc.zoneList.size(); z++) - { - if (!galaxyArc.zoneList.get(z).equals(newzone)) - continue; - lbZoneList.setSelectedIndex(z); - break; + // Path properties + else if (propname.startsWith("[P]")) { + String property = propname.substring(3); + switch (property) { + case "closed": + selectedPathPoint.path.data.put(property, (boolean) value ? "CLOSE" : "OPEN"); + rerenderTasks.add("path:" + selectedPathPoint.path.uniqueID); + glCanvas.repaint(); + break; + case "name": + selectedPathPoint.path.name = (String) value; + DefaultTreeModel objlist = (DefaultTreeModel)tvObjectList.getModel(); + objlist.nodeChanged(treeNodeList.get(selectedPathPoint.path.uniqueID)); + break; + default: + propertyChanged(property, value, selectedPathPoint.path.data); + break; + } } - if (treeNodeList.containsKey(uid)) - { - TreeNode tn = treeNodeList.get(uid); - TreePath tp = new TreePath(((DefaultTreeModel)tvObjectList.getModel()).getPathToRoot(tn)); - tvObjectList.setSelectionPath(tp); - tvObjectList.scrollPathToVisible(tp); + + else { + propertyChanged(propname, value, selectedPathPoint.data); } - - selectionChanged(); - rerenderTasks.add("zone:"+oldzone); - rerenderTasks.add("zone:"+newzone); - glCanvas.repaint(); } - else if (propname.equals("layer")) - { - String oldlayer = selectedObj.layer; - String newlayer = ((String)value).toLowerCase(); - - selectedObj.layer = newlayer; - curZoneArc.objects.get(oldlayer).remove(selectedObj); - curZoneArc.objects.get(newlayer).add(selectedObj); - - DefaultTreeModel objlist = (DefaultTreeModel)tvObjectList.getModel(); - objlist.nodeChanged(treeNodeList.get(selectedObj.uniqueID)); - - rerenderTasks.add("zone:"+selectedObj.zone.zoneName); - glCanvas.repaint(); + + // Also, zones. Not finished, though + else if (selectedObj instanceof StageObj) { + // todo } - else if (propname.startsWith("pos_") || propname.startsWith("dir_") || propname.startsWith("scale_")) - { - switch (propname) - { - case "pos_x": selectedObj.position.x = (float)value; break; - case "pos_y": selectedObj.position.y = (float)value; break; - case "pos_z": selectedObj.position.z = (float)value; break; - case "dir_x": selectedObj.rotation.x = (float)value; break; - case "dir_y": selectedObj.rotation.y = (float)value; break; - case "dir_z": selectedObj.rotation.z = (float)value; break; - case "scale_x": selectedObj.scale.x = (float)value; break; - case "scale_y": selectedObj.scale.y = (float)value; break; - case "scale_z": selectedObj.scale.z = (float)value; break; - } + + // Any other object + else { + if (propname.equals("name")) { + selectedObj.name = (String)value; + selectedObj.loadDBInfo(); + + DefaultTreeModel objlist = (DefaultTreeModel)tvObjectList.getModel(); + objlist.nodeChanged(treeNodeList.get(selectedObj.uniqueID)); - if (propname.startsWith("scale_") && selectedObj.renderer.hasSpecialScaling()) rerenderTasks.add("object:"+Integer.toString(selectedObj.uniqueID)); + rerenderTasks.add("zone:"+selectedObj.zone.zoneName); + glCanvas.repaint(); + } + else if (propname.equals("zone")) { + String oldzone = selectedObj.zone.zoneName; + String newzone = (String)value; + int uid = selectedObj.uniqueID; + + selectedObj.zone = zoneArcs.get(newzone); + zoneArcs.get(oldzone).objects.get(selectedObj.layer).remove(selectedObj); + if (zoneArcs.get(newzone).objects.containsKey(selectedObj.layer)) + zoneArcs.get(newzone).objects.get(selectedObj.layer).add(selectedObj); + else { + selectedObj.layer = "common"; + zoneArcs.get(newzone).objects.get(selectedObj.layer).add(selectedObj); + } - rerenderTasks.add("zone:"+selectedObj.zone.zoneName); - glCanvas.repaint(); - } - else - { - Object oldval = selectedObj.data.get(propname); - if (oldval.getClass() == String.class) - selectedObj.data.put(propname, value); - else if (oldval.getClass() == Integer.class) - selectedObj.data.put(propname, (int)value); - else if (oldval.getClass() == Short.class) - selectedObj.data.put(propname, (short)(int)value); - else if (oldval.getClass() == Float.class) - selectedObj.data.put(propname, (float)value); - else - throw new UnsupportedOperationException("UNSUPPORTED PROP TYPE: "+oldval.getClass().getName()); - - if (propname.startsWith("Obj_arg")) - { - int argnum = Integer.parseInt(propname.substring(7)); - if (selectedObj.renderer.boundToObjArg(argnum)) - { - rerenderTasks.add("object:"+Integer.toString(selectedObj.uniqueID)); - rerenderTasks.add("zone:"+selectedObj.zone.zoneName); - glCanvas.repaint(); + for (int z = 0; z < galaxyArc.zoneList.size(); z++) { + if (!galaxyArc.zoneList.get(z).equals(newzone)) + continue; + lbZoneList.setSelectedIndex(z); + break; } - } - else if (propname.equals("ShapeModelNo")) { - if (selectedObj.renderer.boundToShapeModel()) { - rerenderTasks.add("object:"+Integer.toString(selectedObj.uniqueID)); - rerenderTasks.add("zone:"+selectedObj.zone.zoneName); - glCanvas.repaint(); + if (treeNodeList.containsKey(uid)) { + TreeNode tn = treeNodeList.get(uid); + TreePath tp = new TreePath(((DefaultTreeModel)tvObjectList.getModel()).getPathToRoot(tn)); + tvObjectList.setSelectionPath(tp); + tvObjectList.scrollPathToVisible(tp); } + + selectionChanged(); + rerenderTasks.add("zone:"+oldzone); + rerenderTasks.add("zone:"+newzone); + glCanvas.repaint(); } - else if (propname.equals("AreaShapeNo")) { + else if (propname.equals("layer")) { + String oldlayer = selectedObj.layer; + String newlayer = ((String)value).toLowerCase(); + + selectedObj.layer = newlayer; + curZoneArc.objects.get(oldlayer).remove(selectedObj); + curZoneArc.objects.get(newlayer).add(selectedObj); + DefaultTreeModel objlist = (DefaultTreeModel)tvObjectList.getModel(); objlist.nodeChanged(treeNodeList.get(selectedObj.uniqueID)); - if (selectedObj.getClass() == AreaObj.class || selectedObj.getClass() == CameraCubeObj.class) { - rerenderTasks.add("object:"+Integer.toString(selectedObj.uniqueID)); - rerenderTasks.add("zone:"+selectedObj.zone.zoneName); - glCanvas.repaint(); + + rerenderTasks.add("zone:"+selectedObj.zone.zoneName); + glCanvas.repaint(); + } + else if (propname.startsWith("pos_") || propname.startsWith("dir_") || propname.startsWith("scale_")) { + switch (propname) { + case "pos_x": selectedObj.position.x = (float)value; break; + case "pos_y": selectedObj.position.y = (float)value; break; + case "pos_z": selectedObj.position.z = (float)value; break; + case "dir_x": selectedObj.rotation.x = (float)value; break; + case "dir_y": selectedObj.rotation.y = (float)value; break; + case "dir_z": selectedObj.rotation.z = (float)value; break; + case "scale_x": selectedObj.scale.x = (float)value; break; + case "scale_y": selectedObj.scale.y = (float)value; break; + case "scale_z": selectedObj.scale.z = (float)value; break; } + + if (propname.startsWith("scale_") && selectedObj.renderer.hasSpecialScaling()) + rerenderTasks.add("object:"+Integer.toString(selectedObj.uniqueID)); + + rerenderTasks.add("zone:"+selectedObj.zone.zoneName); + glCanvas.repaint(); } - else if (propname.equals("MarioNo") || propname.equals("PosName") || propname.equals("DemoName") || propname.equals("TimeSheetName")) { - DefaultTreeModel objlist = (DefaultTreeModel)tvObjectList.getModel(); - objlist.nodeChanged(treeNodeList.get(selectedObj.uniqueID)); + else if (propname.equals("DemoSkip")) { + propertyChanged(propname, (Boolean) value ? 1 : -1, selectedObj.data); + } + else { + propertyChanged(propname, value, selectedObj.data); + if (propname.startsWith("Obj_arg")) { + int argnum = Integer.parseInt(propname.substring(7)); + if (selectedObj.renderer.boundToObjArg(argnum)) { + rerenderTasks.add("object:"+Integer.toString(selectedObj.uniqueID)); + rerenderTasks.add("zone:"+selectedObj.zone.zoneName); + glCanvas.repaint(); + } + } + else if (propname.equals("ShapeModelNo") || propname.equals("Range")) { + if (selectedObj.renderer.boundToProperty()) { + rerenderTasks.add("object:"+Integer.toString(selectedObj.uniqueID)); + rerenderTasks.add("zone:"+selectedObj.zone.zoneName); + glCanvas.repaint(); + } + } + else if (propname.equals("AreaShapeNo")) { + DefaultTreeModel objlist = (DefaultTreeModel)tvObjectList.getModel(); + objlist.nodeChanged(treeNodeList.get(selectedObj.uniqueID)); + if (selectedObj.getClass() == AreaObj.class || selectedObj.getClass() == CameraObj.class) { + rerenderTasks.add("object:"+Integer.toString(selectedObj.uniqueID)); + rerenderTasks.add("zone:"+selectedObj.zone.zoneName); + glCanvas.repaint(); + } + } + else if (propname.equals("MarioNo") || propname.equals("PosName") || propname.equals("DemoName") || propname.equals("TimeSheetName")) { + DefaultTreeModel objlist = (DefaultTreeModel)tvObjectList.getModel(); + objlist.nodeChanged(treeNodeList.get(selectedObj.uniqueID)); + } } } } @@ -2046,13 +2026,13 @@ public void run() if (parentForm == null) { - for (LevelObject obj : globalObjList.values()) + for (AbstractObj obj : globalObjList.values()) { obj.initRenderer(renderinfo); obj.oldname = obj.name; } - for (PathObject obj : globalPathList.values()) + for (PathObj obj : globalPathList.values()) obj.prerender(renderinfo); } @@ -2092,8 +2072,8 @@ public void init(GLAutoDrawable glad) selectedObjs = new LinkedHashMap<>(); selectionArg = 0; displayedPaths = new LinkedHashMap<>(); - objectBeingAdded = ""; - addingOnLayer = ""; + addingObject = ""; + addingObjectOnLayer = ""; deletingObjects = false; renderinfo = new GLRenderer.RenderInfo(); @@ -2109,7 +2089,7 @@ public void init(GLAutoDrawable glad) ZoneArchive firstzone = zoneArcs.get(galaxyName); StartObj start = null; - for (LevelObject obj : firstzone.objects.get("common")) + for (AbstractObj obj : firstzone.objects.get("common")) { if (obj instanceof StartObj) { @@ -2153,7 +2133,7 @@ public void init(GLAutoDrawable glad) private void renderSelectHighlight(GL2 gl, String zone) { boolean gotany = false; - for (LevelObject obj : selectedObjs.values()) + for (AbstractObj obj : selectedObjs.values()) { if (obj.zone.zoneName.equals(zone)) { @@ -2191,9 +2171,9 @@ private void renderSelectHighlight(GL2 gl, String zone) renderinfo.renderMode = GLRenderer.RenderMode.PICKING; gl.glColor4f(1f, 1f, 0.75f, 0.3f); - for (LevelObject obj : selectedObjs.values()) + for (AbstractObj obj : selectedObjs.values()) { - if (obj.zone.zoneName.equals(zone) && !(obj instanceof PathPointObject)) + if (obj.zone.zoneName.equals(zone) && !(obj instanceof PathPointObj)) obj.render(renderinfo); } @@ -2283,7 +2263,7 @@ private void prerenderZone(GL2 gl, String zone) gl.glNewList(dl, GL2.GL_COMPILE); - for (LevelObject obj : zonearc.objects.get(layer)) + for (AbstractObj obj : zonearc.objects.get(layer)) { if (mode == 0) { @@ -2304,17 +2284,17 @@ private void prerenderZone(GL2 gl, String zone) // path rendering -- be lazy and hijack the display lists used for the Common objects if (layer.equalsIgnoreCase("common")) { - for (PathObject pobj : zonearc.paths) + for (PathObj pobj : zonearc.paths) { if (!btnShowPaths.isSelected() && // isSelected? intuitive naming ftw :/ - !displayedPaths.containsKey(pobj.pathID)) + !displayedPaths.containsKey(pobj.index)) continue; pobj.render(renderinfo); if (mode == 1) { - PathPointObject ptobj = displayedPaths.get(pobj.pathID); + PathPointObj ptobj = displayedPaths.get(pobj.index); if (ptobj != null) { Color4 selcolor = new Color4(1f, 1f, 0.5f, 1f); @@ -2355,15 +2335,15 @@ private void renderZone(GL2 gl, Bcsv.Entry scenario, String zone, int layermask, if (level < 5) { - for (Bcsv.Entry subzone : zoneArcs.get(zone).subZones.get("common")) + for (StageObj subzone : zoneArcs.get(zone).zones.get("common")) { gl.glPushMatrix(); - gl.glTranslatef((float)subzone.get("pos_x"), (float)subzone.get("pos_y"), (float)subzone.get("pos_z")); - gl.glRotatef((float)subzone.get("dir_z"), 0f, 0f, 1f); - gl.glRotatef((float)subzone.get("dir_y"), 0f, 1f, 0f); - gl.glRotatef((float)subzone.get("dir_x"), 1f, 0f, 0f); + gl.glTranslatef(subzone.position.x, subzone.position.y, subzone.position.z); + gl.glRotatef(subzone.rotation.x, 0f, 0f, 1f); + gl.glRotatef(subzone.rotation.y, 0f, 1f, 0f); + gl.glRotatef(subzone.rotation.z, 1f, 0f, 0f); - String zonename = (String)subzone.get("name"); + String zonename = subzone.name; renderZone(gl, scenario, zonename, (int)scenario.get(zonename), level + 1); gl.glPopMatrix(); @@ -2373,15 +2353,15 @@ private void renderZone(GL2 gl, Bcsv.Entry scenario, String zone, int layermask, { if ((layermask & (1 << l)) != 0) { - for (Bcsv.Entry subzone : zoneArcs.get(zone).subZones.get("layer" + alphabet.charAt(l))) + for (StageObj subzone : zoneArcs.get(zone).zones.get("layer" + alphabet.charAt(l))) { gl.glPushMatrix(); - gl.glTranslatef((float)subzone.get("pos_x"), (float)subzone.get("pos_y"), (float)subzone.get("pos_z")); - gl.glRotatef((float)subzone.get("dir_z"), 0f, 0f, 1f); - gl.glRotatef((float)subzone.get("dir_y"), 0f, 1f, 0f); - gl.glRotatef((float)subzone.get("dir_x"), 1f, 0f, 0f); + gl.glTranslatef(subzone.position.x, subzone.position.y, subzone.position.z); + gl.glRotatef(subzone.rotation.x, 0f, 0f, 1f); + gl.glRotatef(subzone.rotation.y, 0f, 1f, 0f); + gl.glRotatef(subzone.rotation.z, 1f, 0f, 0f); - String zonename = (String)subzone.get("name"); + String zonename = subzone.name; renderZone(gl, scenario, zonename, (int)scenario.get(zonename), level + 1); gl.glPopMatrix(); @@ -2414,7 +2394,7 @@ public void dispose(GLAutoDrawable glad) if (parentForm == null) { - for (LevelObject obj : globalObjList.values()) + for (AbstractObj obj : globalObjList.values()) obj.closeRenderer(renderinfo); } @@ -2439,7 +2419,7 @@ private void doRerenderTasks() case "object": { int objid = Integer.parseInt(task[1]); - LevelObject obj = globalObjList.get(objid); + AbstractObj obj = globalObjList.get(objid); obj.closeRenderer(renderinfo); obj.initRenderer(renderinfo); obj.oldname = obj.name; @@ -2449,7 +2429,7 @@ private void doRerenderTasks() case "addobj": { int objid = Integer.parseInt(task[1]); - LevelObject obj = globalObjList.get(objid); + AbstractObj obj = globalObjList.get(objid); obj.initRenderer(renderinfo); obj.oldname = obj.name; } @@ -2458,7 +2438,7 @@ private void doRerenderTasks() case "delobj": { int objid = Integer.parseInt(task[1]); - LevelObject obj = globalObjList.get(objid); + AbstractObj obj = globalObjList.get(objid); obj.closeRenderer(renderinfo); globalObjList.remove(obj.uniqueID); } @@ -2473,7 +2453,7 @@ private void doRerenderTasks() case "path": { int pathid = Integer.parseInt(task[1]); - PathObject pobj = globalPathList.get(pathid); + PathObj pobj = globalPathList.get(pathid); pobj.prerender(renderinfo); } break; @@ -2798,15 +2778,15 @@ public void mouseReleased(MouseEvent e) { if (objid != 0xFFFFFF && !globalObjList.containsKey(objid)) return; - LevelObject theobject = globalObjList.get(objid); + AbstractObj theobject = globalObjList.get(objid); int oldarg = selectionArg; selectionArg = 0; if (e.getButton() == MouseEvent.BUTTON3) { // right click: cancels current add/delete command - if (!objectBeingAdded.isEmpty()) { - objectBeingAdded = ""; + if (!addingObject.isEmpty()) { + addingObject = ""; tgbAddObject.setSelected(false); setStatusText(); } @@ -2819,10 +2799,10 @@ else if (deletingObjects) { else { // left click: places/deletes objects or selects shit - if (!objectBeingAdded.isEmpty()) { + if (!addingObject.isEmpty()) { addObject(lastMouseMove); if (!shiftpressed) { - objectBeingAdded = ""; + addingObject = ""; tgbAddObject.setSelected(false); setStatusText(); } @@ -2855,12 +2835,12 @@ else if (deletingObjects) { } } else { - LinkedHashMap oldsel = null; + LinkedHashMap oldsel = null; if (!selectedObjs.isEmpty() && arg == oldarg) { - oldsel = (LinkedHashMap)selectedObjs.clone(); + oldsel = (LinkedHashMap)selectedObjs.clone(); - for (LevelObject unselobj : oldsel.values()) { + for (AbstractObj unselobj : oldsel.values()) { if (treeNodeList.containsKey(unselobj.uniqueID)) { TreeNode tn = treeNodeList.get(unselobj.uniqueID); TreePath tp = new TreePath(((DefaultTreeModel)tvObjectList.getModel()).getPathToRoot(tn)); @@ -3157,11 +3137,11 @@ public void keyReleased(KeyEvent e) { public boolean galaxyMode; public String galaxyName; + public HashMap zoneArcs; + public HashMap zoneEditors; public GalaxyEditorForm parentForm; - public HashMap childZoneEditors; public GalaxyArchive galaxyArc; public GalaxyRenderer renderer; - public HashMap zoneArcs; public int curScenarioID; public Bcsv.Entry curScenario; @@ -3169,20 +3149,15 @@ public void keyReleased(KeyEvent e) { public ZoneArchive curZoneArc; public int maxUniqueID; - public HashMap globalObjList; - public HashMap globalPathList; - public HashMap globalPathPointList; - private HashMap objDisplayLists; - private HashMap zoneDisplayLists; - private LinkedHashMap displayedPaths; - public HashMap subZoneData; - private HashMap treeNodeList; - private LinkedHashMap selectedObjs; - - public class SubZoneData { - String layer; - Vector3 position, rotation; - } + public HashMap globalObjList; + public HashMap globalPathList; + public HashMap globalPathPointList; + public LinkedHashMap selectedObjs; + public LinkedHashMap displayedPaths; + public HashMap objDisplayLists; + public HashMap zoneDisplayLists; + public HashMap subZoneData; + public HashMap treeNodeList; private GLCanvas glCanvas; private boolean inited; @@ -3213,7 +3188,7 @@ public class SubZoneData { private int underCursor; private float depthUnderCursor; private int selectionArg; - private String objectBeingAdded, addingOnLayer; + private String addingObject, addingObjectOnLayer; private boolean deletingObjects; private CheckBoxList lbLayersList; @@ -3223,7 +3198,6 @@ public class SubZoneData { private Vector3 copyPos = new Vector3(0f, 0f, 0f); private Vector3 copyDir = new Vector3(0f, 0f, 0f); private Vector3 copyScale = new Vector3(1f, 1f, 1f); - // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btnAddScenario; @@ -3286,4 +3260,4 @@ public class SubZoneData { private javax.swing.JTabbedPane tpLeftPanel; private javax.swing.JTree tvObjectList; // End of variables declaration//GEN-END:variables -} +} \ No newline at end of file diff --git a/src/whitehole/HashForm.form b/src/com/aurum/whitehole/swing/HashForm.form similarity index 93% rename from src/whitehole/HashForm.form rename to src/com/aurum/whitehole/swing/HashForm.form index d0a9972..7823526 100644 --- a/src/whitehole/HashForm.form +++ b/src/com/aurum/whitehole/swing/HashForm.form @@ -3,16 +3,16 @@ + + + + - + - - - - diff --git a/src/whitehole/HashForm.java b/src/com/aurum/whitehole/swing/HashForm.java similarity index 72% rename from src/whitehole/HashForm.java rename to src/com/aurum/whitehole/swing/HashForm.java index 13ef0aa..d7548cb 100644 --- a/src/whitehole/HashForm.java +++ b/src/com/aurum/whitehole/swing/HashForm.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,32 +13,22 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole; +package com.aurum.whitehole.swing; -import java.awt.Toolkit; +import com.aurum.whitehole.Whitehole; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.PrintWriter; import javax.swing.JOptionPane; -import whitehole.smg.Bcsv; +import com.aurum.whitehole.smg.Bcsv; +import java.io.IOException; -public class HashForm extends javax.swing.JFrame -{ - - /** - * Creates new form BcsvEditorForm - */ - public HashForm() - { +public class HashForm extends javax.swing.JFrame { + public HashForm() { initComponents(); } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ + @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { @@ -50,15 +40,9 @@ private void initComponents() { btnAddTo = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle("Hash generator"); + setIconImage(Whitehole.ICON); setResizable(false); - addWindowListener(new java.awt.event.WindowAdapter() { - public void windowClosing(java.awt.event.WindowEvent evt) { - formWindowClosing(evt); - } - public void windowOpened(java.awt.event.WindowEvent evt) { - formWindowOpened(evt); - } - }); txtInput.addKeyListener(new java.awt.event.KeyAdapter() { public void keyReleased(java.awt.event.KeyEvent evt) { @@ -114,43 +98,32 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { ); pack(); + setLocationRelativeTo(null); }// //GEN-END:initComponents - private void formWindowClosing(java.awt.event.WindowEvent evt)//GEN-FIRST:event_formWindowClosing - {//GEN-HEADEREND:event_formWindowClosing - - }//GEN-LAST:event_formWindowClosing - - private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened - this.setTitle("Hash Generator"); - this.setIconImage(Toolkit.getDefaultToolkit().createImage(Whitehole.class.getResource("/Resources/icon.png"))); - }//GEN-LAST:event_formWindowOpened - private void txtInputKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtInputKeyReleased if (txtInput.getText().contains(" ")) { - JOptionPane.showMessageDialog(null, "You can not use any spaces!", Whitehole.fullName, JOptionPane.INFORMATION_MESSAGE); + JOptionPane.showMessageDialog(null, "You can not use any spaces!", Whitehole.NAME, JOptionPane.INFORMATION_MESSAGE); txtInput.setText(txtInput.getText().replaceAll(" ", "")); } else { - txtOutput.setText(String.format("%1$08X",Bcsv.fieldNameToHash(txtInput.getText()))); + txtOutput.setText(String.format("%1$08X", Bcsv.fieldNameToHash(txtInput.getText()))); } }//GEN-LAST:event_txtInputKeyReleased private void btnAddToActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddToActionPerformed try { - File hashCustom = new File("AdditionalFieldNames.txt"); - PrintWriter writeFile = new PrintWriter(new FileWriter(hashCustom, true)); - BufferedWriter writeLine = new BufferedWriter(writeFile); - - if (!hashCustom.exists()) - Bcsv.createCustomHashFile(); + File file = Bcsv.LOOKUPFILE; + if (!file.exists()) + file.createNewFile(); - writeLine.write("# " + txtOutput.getText() + "\r\n" + txtInput.getText() + "\r\n"); - writeLine.close(); + try (BufferedWriter bw = new BufferedWriter(new PrintWriter(new FileWriter(file, true)))) { + bw.write("# " + txtOutput.getText() + "\n" + txtInput.getText() + "\n"); + } } - catch (Exception ex) { + catch (IOException ex) { + System.out.println(ex); } - }//GEN-LAST:event_btnAddToActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables diff --git a/src/whitehole/MainFrame.form b/src/com/aurum/whitehole/swing/MainFrame.form similarity index 90% rename from src/whitehole/MainFrame.form rename to src/com/aurum/whitehole/swing/MainFrame.form index 47573ce..3acd81b 100644 --- a/src/whitehole/MainFrame.form +++ b/src/com/aurum/whitehole/swing/MainFrame.form @@ -14,14 +14,17 @@ + + + + + + - + - - - @@ -118,20 +121,7 @@ - - - - - - - - - - - - - - + @@ -144,7 +134,7 @@ - + diff --git a/src/whitehole/MainFrame.java b/src/com/aurum/whitehole/swing/MainFrame.java similarity index 81% rename from src/whitehole/MainFrame.java rename to src/com/aurum/whitehole/swing/MainFrame.java index 46b59e7..310b24d 100644 --- a/src/whitehole/MainFrame.java +++ b/src/com/aurum/whitehole/swing/MainFrame.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,37 +13,23 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole; +package com.aurum.whitehole.swing; -import whitehole.smg.GameArchive; -import java.awt.*; +import com.aurum.whitehole.Whitehole; +import com.aurum.whitehole.io.ExternalFilesystem; +import com.aurum.whitehole.smg.GameArchive; import java.util.prefs.Preferences; import javax.swing.*; import java.io.*; import java.util.HashMap; -import whitehole.fileio.*; -import whitehole.rendering.RendererCache; -import whitehole.rendering.ShaderCache; -import whitehole.rendering.TextureCache; +import com.aurum.whitehole.rendering.cache.*; public class MainFrame extends javax.swing.JFrame { - - /** - * Creates new form MainFrame - */ - public MainFrame() - { + public MainFrame() { initComponents(); - btnLayerGen.setVisible(false); - jSeparator6.setVisible(false); - galaxyEditors = new HashMap<>(); + galaxyEditors = new HashMap(); } - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { @@ -57,11 +43,9 @@ private void initComponents() { btnBcsvEditor = new javax.swing.JButton(); jSeparator3 = new javax.swing.JToolBar.Separator(); btnHashGen = new javax.swing.JButton(); - jSeparator5 = new javax.swing.JToolBar.Separator(); - btnLayerGen = new javax.swing.JButton(); - jSeparator6 = new javax.swing.JToolBar.Separator(); - btnSettings = new javax.swing.JButton(); jSeparator4 = new javax.swing.JToolBar.Separator(); + btnSettings = new javax.swing.JButton(); + jSeparator6 = new javax.swing.JToolBar.Separator(); btnAbout = new javax.swing.JButton(); lbStatusBar = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); @@ -70,11 +54,8 @@ private void initComponents() { jMenu1.setText("jMenu1"); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); - addWindowListener(new java.awt.event.WindowAdapter() { - public void windowOpened(java.awt.event.WindowEvent evt) { - formWindowOpened(evt); - } - }); + setTitle(Whitehole.NAME); + setIconImage(Whitehole.ICON); jToolBar1.setFloatable(false); jToolBar1.setRollover(true); @@ -128,19 +109,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { } }); jToolBar1.add(btnHashGen); - jToolBar1.add(jSeparator5); - - btnLayerGen.setText("Layer generator"); - btnLayerGen.setFocusable(false); - btnLayerGen.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); - btnLayerGen.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - btnLayerGen.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - btnLayerGenActionPerformed(evt); - } - }); - jToolBar1.add(btnLayerGen); - jToolBar1.add(jSeparator6); + jToolBar1.add(jSeparator4); btnSettings.setText("Settings"); btnSettings.setFocusable(false); @@ -152,7 +121,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { } }); jToolBar1.add(btnSettings); - jToolBar1.add(jSeparator4); + jToolBar1.add(jSeparator6); btnAbout.setText("About"); btnAbout.setFocusable(false); @@ -199,23 +168,9 @@ public void valueChanged(javax.swing.event.ListSelectionEvent evt) { ); pack(); + setLocationRelativeTo(null); }// //GEN-END:initComponents - private void formWindowOpened(java.awt.event.WindowEvent evt)//GEN-FIRST:event_formWindowOpened - {//GEN-HEADEREND:event_formWindowOpened - - this.setTitle(Whitehole.fullName); - this.setIconImage(Toolkit.getDefaultToolkit().createImage(Whitehole.class.getResource("/Resources/icon.png"))); - lbStatusBar.setText("Ready"); - - if (Settings.objectDB_update) - { - lbStatusBar.setText("Checking for object database updates..."); - ObjectDBUpdater updater = new ObjectDBUpdater(lbStatusBar); - updater.start(); - } - }//GEN-LAST:event_formWindowOpened - private void btnOpenGameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOpenGameActionPerformed JFileChooser fc = new JFileChooser(); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); @@ -232,12 +187,10 @@ private void btnOpenGameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F String seldir = fc.getSelectedFile().getPath(); Preferences.userRoot().put("lastGameDir", seldir); - try - { + try { Whitehole.game = new GameArchive(new ExternalFilesystem(seldir)); } - catch (IOException ex) - { + catch (IOException ex) { return; } @@ -298,23 +251,16 @@ private void GalaxyListValueChanged(javax.swing.event.ListSelectionEvent evt)//G btnOpenGalaxy.setEnabled(hasSelection); }//GEN-LAST:event_GalaxyListValueChanged - private void btnLayerGenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLayerGenActionPerformed - new LayerForm().setVisible(true); - }//GEN-LAST:event_btnLayerGenActionPerformed - - private void openGalaxy() - { - TextureCache.initialize(); - ShaderCache.initialize(); - RendererCache.initialize(); + private void openGalaxy() { + TextureCache.init(); + ShaderCache.init(); + RendererCache.init(); String gal = (String)GalaxyList.getSelectedValue(); - if (galaxyEditors.containsKey(gal)) - { + if (galaxyEditors.containsKey(gal)) { if (!galaxyEditors.get(gal).isVisible()) galaxyEditors.remove(gal); - else - { + else { galaxyEditors.get(gal).toFront(); return; } @@ -324,14 +270,13 @@ private void openGalaxy() form.setVisible(true); galaxyEditors.put(gal, form); } - private HashMap galaxyEditors; + private final HashMap galaxyEditors; // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JList GalaxyList; private javax.swing.JButton btnAbout; private javax.swing.JButton btnBcsvEditor; private javax.swing.JButton btnHashGen; - private javax.swing.JButton btnLayerGen; private javax.swing.JButton btnOpenGalaxy; private javax.swing.JButton btnOpenGame; private javax.swing.JButton btnSettings; @@ -341,9 +286,8 @@ private void openGalaxy() private javax.swing.JToolBar.Separator jSeparator2; private javax.swing.JToolBar.Separator jSeparator3; private javax.swing.JToolBar.Separator jSeparator4; - private javax.swing.JToolBar.Separator jSeparator5; private javax.swing.JToolBar.Separator jSeparator6; private javax.swing.JToolBar jToolBar1; private javax.swing.JLabel lbStatusBar; // End of variables declaration//GEN-END:variables -} +} \ No newline at end of file diff --git a/src/whitehole/ObjListTreeNode.java b/src/com/aurum/whitehole/swing/ObjListTreeNode.java similarity index 60% rename from src/whitehole/ObjListTreeNode.java rename to src/com/aurum/whitehole/swing/ObjListTreeNode.java index 6986de4..ad5ecb2 100644 --- a/src/whitehole/ObjListTreeNode.java +++ b/src/com/aurum/whitehole/swing/ObjListTreeNode.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,90 +13,78 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole; +package com.aurum.whitehole.swing; +import com.aurum.whitehole.AdaptedEnumeration; import java.util.Enumeration; import java.util.LinkedHashMap; import javax.swing.tree.MutableTreeNode; import javax.swing.tree.TreeNode; -import whitehole.smg.LevelObject; -import whitehole.smg.object.PathObject; -import whitehole.smg.object.PathPointObject; +import com.aurum.whitehole.smg.object.AbstractObj; +import com.aurum.whitehole.smg.object.PathObj; +import com.aurum.whitehole.smg.object.PathPointObj; -public class ObjListTreeNode extends ObjTreeNode -{ - public ObjListTreeNode() - { - children = new LinkedHashMap<>(); +public class ObjListTreeNode extends ObjTreeNode { + public ObjListTreeNode() { + children = new LinkedHashMap(); object = null; } - public ObjListTreeNode(PathObject obj) - { + public ObjListTreeNode(PathObj obj) { object = obj; uniqueID = obj.uniqueID; - children = new LinkedHashMap<>(); - for (PathPointObject ptobj : obj.points.values()) + children = new LinkedHashMap(); + for (PathPointObj ptobj : obj.points.values()) addObject(ptobj); } @Override - public void insert(MutableTreeNode child, int index) - { + public void insert(MutableTreeNode child, int index) { throw new UnsupportedOperationException("This is not how you add nodes to this kind of TreeNode."); } - + @Override - public void remove(int index) - { + public void remove(int index) { int key = (int)children.keySet().toArray()[index]; children.remove(key); } - + @Override - public void remove(MutableTreeNode node) - { + public void remove(MutableTreeNode node) { children.remove(((ObjTreeNode)node).uniqueID); } - + @Override - public void removeFromParent() - { + public void removeFromParent() { parent = null; System.out.println("[ObjListTreeNode] REMOVE FROM PARENT"); } - + @Override - public void setParent(MutableTreeNode newParent) - { + public void setParent(MutableTreeNode newParent) { parent = newParent; } - + @Override - public TreeNode getChildAt(int childIndex) - { + public TreeNode getChildAt(int childIndex) { return (TreeNode)children.values().toArray()[childIndex]; } - + @Override - public int getChildCount() - { + public int getChildCount() { return children.size(); } - + @Override - public TreeNode getParent() - { + public TreeNode getParent() { return parent; } - + @Override - public int getIndex(TreeNode node) - { + public int getIndex(TreeNode node) { int uid = ((ObjTreeNode)node).uniqueID; int i = 0; - for (TreeNode tn : children.values()) - { + for (TreeNode tn : children.values()) { if (((ObjTreeNode)tn).uniqueID == uid) return i; @@ -105,50 +93,35 @@ public int getIndex(TreeNode node) return -1; } - + @Override - public boolean getAllowsChildren() - { + public boolean getAllowsChildren() { return true; } - + @Override - public boolean isLeaf() - { + public boolean isLeaf() { return children.isEmpty(); } - - @Override - public Enumeration children() - { - return new Iterator2Enumeration(children.values().iterator()); - } - - public TreeNode addObject(LevelObject obj) - { - ObjTreeNode tn = new ObjTreeNode(obj); - children.put(obj.uniqueID, tn); - tn.setParent(this); - return tn; + @Override + public Enumeration children() { + return new AdaptedEnumeration(children.values().iterator()); } - public TreeNode addObject(PathPointObject obj) - { + public TreeNode addObject(AbstractObj obj) { ObjTreeNode tn = new ObjTreeNode(obj); children.put(obj.uniqueID, tn); tn.setParent(this); return tn; } - public TreeNode addObject(PathObject obj) - { + public TreeNode addObject(PathObj obj) { ObjListTreeNode tn = new ObjListTreeNode(obj); children.put(obj.uniqueID, tn); tn.setParent(this); return tn; } - LinkedHashMap children; } diff --git a/src/whitehole/ObjTreeNode.java b/src/com/aurum/whitehole/swing/ObjTreeNode.java similarity index 70% rename from src/whitehole/ObjTreeNode.java rename to src/com/aurum/whitehole/swing/ObjTreeNode.java index 26eba6e..affb1e2 100644 --- a/src/whitehole/ObjTreeNode.java +++ b/src/com/aurum/whitehole/swing/ObjTreeNode.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,113 +13,96 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole; +package com.aurum.whitehole.swing; import java.util.Enumeration; import javax.swing.tree.MutableTreeNode; import javax.swing.tree.TreeNode; -import whitehole.smg.LevelObject; -import whitehole.smg.object.PathPointObject; +import com.aurum.whitehole.smg.object.AbstractObj; +import com.aurum.whitehole.smg.object.PathPointObj; -public class ObjTreeNode implements MutableTreeNode -{ - public ObjTreeNode() - { +public class ObjTreeNode implements MutableTreeNode { + public ObjTreeNode() { this.parent = null; this.object = null; this.userObject = null; this.uniqueID = -1; } - public ObjTreeNode(LevelObject obj) - { + public ObjTreeNode(AbstractObj obj) { this.parent = null; this.object = obj; this.userObject = null; this.uniqueID = obj.uniqueID; } - public ObjTreeNode(PathPointObject obj) - { + public ObjTreeNode(PathPointObj obj) { this.parent = null; this.object = obj; this.userObject = null; this.uniqueID = obj.uniqueID; } - @Override public void insert(MutableTreeNode child, int index) {} @Override public void remove(int index) {} @Override public void remove(MutableTreeNode node) {} - + @Override - public void setUserObject(Object object) - { + public void setUserObject(Object object) { userObject = object; } - + @Override - public void removeFromParent() - { + public void removeFromParent() { parent = null; System.out.println("[ObjTreeNode] REMOVE FROM PARENT"); } - + @Override - public void setParent(MutableTreeNode newParent) - { + public void setParent(MutableTreeNode newParent) { parent = newParent; } - + @Override - public TreeNode getChildAt(int childIndex) - { + public TreeNode getChildAt(int childIndex) { return null; } - + @Override - public int getChildCount() - { + public int getChildCount() { return 0; } @Override - public TreeNode getParent() - { + public TreeNode getParent() { return parent; } @Override - public int getIndex(TreeNode node) - { + public int getIndex(TreeNode node) { return -1; } @Override - public boolean getAllowsChildren() - { + public boolean getAllowsChildren() { return false; } @Override - public boolean isLeaf() - { + public boolean isLeaf() { return true; } @Override - public Enumeration children() - { + public Enumeration children() { return null; } - @Override - public String toString() - { + public String toString() { if (userObject != null) return userObject.toString(); else if (object != null) @@ -128,9 +111,7 @@ else if (object != null) return "unknown node"; } - public TreeNode parent; - public Object object; - public Object userObject; + public Object object, userObject; public int uniqueID; -} +} \ No newline at end of file diff --git a/src/whitehole/ObjectSelectForm.form b/src/com/aurum/whitehole/swing/ObjectSelectForm.form similarity index 74% rename from src/whitehole/ObjectSelectForm.form rename to src/com/aurum/whitehole/swing/ObjectSelectForm.form index ee88ce7..f21dee0 100644 --- a/src/whitehole/ObjectSelectForm.form +++ b/src/com/aurum/whitehole/swing/ObjectSelectForm.form @@ -4,10 +4,13 @@ + + + - + @@ -27,23 +30,23 @@ - + - - - + + + - - - - - - + + + + + + @@ -67,7 +70,7 @@ - + @@ -106,21 +109,6 @@ - - - - - - - - - - - - - - - @@ -129,34 +117,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -169,22 +129,6 @@ - - - - - - - - - - - - - - - - @@ -209,5 +153,19 @@ + + + + + + + + + + + + + + diff --git a/src/whitehole/ObjectSelectForm.java b/src/com/aurum/whitehole/swing/ObjectSelectForm.java similarity index 64% rename from src/whitehole/ObjectSelectForm.java rename to src/com/aurum/whitehole/swing/ObjectSelectForm.java index 7d0349c..15c032e 100644 --- a/src/whitehole/ObjectSelectForm.java +++ b/src/com/aurum/whitehole/swing/ObjectSelectForm.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,67 +13,44 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole; +package com.aurum.whitehole.swing; -import java.awt.Toolkit; +import com.aurum.whitehole.Whitehole; +import com.aurum.whitehole.ObjectDB; import java.util.*; import java.util.Map.Entry; import javax.swing.DefaultComboBoxModel; import javax.swing.tree.*; -import whitehole.smg.ZoneArchive; +import com.aurum.whitehole.smg.ZoneArchive; -public class ObjectSelectForm extends javax.swing.JDialog -{ - /** - * Creates new form ObjectSelectForm - */ - public ObjectSelectForm(java.awt.Frame parent, int game, String selobj) - { +public class ObjectSelectForm extends javax.swing.JDialog { + public ObjectSelectForm(java.awt.Frame parent, int game, String selobj) { super(parent, true); - initComponents(); - setIconImage(Toolkit.getDefaultToolkit().createImage(Whitehole.class.getResource("/Resources/icon.png"))); + initComponents(); this.game = game; this.selectedObject = selobj; - if (selobj != null) - { - lblZone.setVisible(false); - cbxZone.setVisible(false); + if (selobj != null) { lblLayer.setVisible(false); cbxLayer.setVisible(false); - filler1.setVisible(false); - filler2.setVisible(false); - - selectedZone = "#lolz#"; selectedLayer = "#lolz#"; } - else - { - GalaxyEditorForm gal_parent = (GalaxyEditorForm)parent; - //if (!gal_parent.galaxyMode) - { - lblZone.setVisible(false); - cbxZone.setVisible(false); - filler1.setVisible(false); - - selectedZone = "#lolz#"; - } - - DefaultComboBoxModel layerlist = (DefaultComboBoxModel)cbxLayer.getModel(); + else { + GalaxyEditorForm galaxy = (GalaxyEditorForm) parent; + DefaultComboBoxModel layerlist = (DefaultComboBoxModel) cbxLayer.getModel(); layerlist.addElement("Common"); - for (int l = 0; l < 26; l++) - { - String ls = String.format("Layer%1$c", 'A'+l); - if (gal_parent.curZoneArc.objects.containsKey(ls.toLowerCase())) + + for (int i = 0; i < 26; i++) { + String ls = String.format("Layer%1$c", 'A'+i); + if (galaxy.curZoneArc.objects.containsKey(ls.toLowerCase())) layerlist.addElement(ls); } + selectedObject = ""; selectedLayer = "Common"; cbxLayer.setSelectedItem(selectedLayer); - - selectedObject = ""; } } @@ -90,21 +67,18 @@ private void initComponents() { jLabel1 = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); tvObjectList = new javax.swing.JTree(); - jScrollPane3 = new javax.swing.JScrollPane(); - epObjDescription = new javax.swing.JEditorPane(); jToolBar1 = new javax.swing.JToolBar(); - lblZone = new javax.swing.JLabel(); - cbxZone = new javax.swing.JComboBox(); - filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(10, 0), new java.awt.Dimension(10, 0), new java.awt.Dimension(10, 32767)); lblLayer = new javax.swing.JLabel(); cbxLayer = new javax.swing.JComboBox(); - filler2 = new javax.swing.Box.Filler(new java.awt.Dimension(8, 0), new java.awt.Dimension(8, 0), new java.awt.Dimension(8, 32767)); btnSelect = new javax.swing.JButton(); jLabel2 = new javax.swing.JLabel(); txtObject = new javax.swing.JTextField(); + jScrollPane2 = new javax.swing.JScrollPane(); + epObjDescription = new javax.swing.JTextPane(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle("Select object"); + setIconImage(Whitehole.ICON); addWindowListener(new java.awt.event.WindowAdapter() { public void windowOpened(java.awt.event.WindowEvent evt) { formWindowOpened(evt); @@ -135,24 +109,13 @@ public void valueChanged(javax.swing.event.TreeSelectionEvent evt) { }); jScrollPane1.setViewportView(tvObjectList); - epObjDescription.setEditable(false); - epObjDescription.setContentType("text/html"); // NOI18N - jScrollPane3.setViewportView(epObjDescription); - jToolBar1.setFloatable(false); jToolBar1.setRollover(true); - lblZone.setText("Zone: "); - jToolBar1.add(lblZone); - - jToolBar1.add(cbxZone); - jToolBar1.add(filler1); - lblLayer.setText("Layer: "); jToolBar1.add(lblLayer); jToolBar1.add(cbxLayer); - jToolBar1.add(filler2); btnSelect.setText("Select"); btnSelect.setEnabled(false); @@ -174,25 +137,28 @@ public void keyReleased(java.awt.event.KeyEvent evt) { } }); + epObjDescription.setEditable(false); + jScrollPane2.setViewportView(epObjDescription); + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jScrollPane1) - .addComponent(jScrollPane3, javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jScrollPane2) + .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jToolBar1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() + .addComponent(jLabel2) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(txtObject)) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(txtSearch, javax.swing.GroupLayout.PREFERRED_SIZE, 225, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(0, 261, Short.MAX_VALUE)) - .addGroup(layout.createSequentialGroup() - .addComponent(jLabel2) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(txtObject))) + .addGap(0, 261, Short.MAX_VALUE))) .addContainerGap()) ); layout.setVerticalGroup( @@ -211,53 +177,55 @@ public void keyReleased(java.awt.event.KeyEvent evt) { .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 301, Short.MAX_VALUE) + .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 301, Short.MAX_VALUE) .addContainerGap()) ); pack(); + setLocationRelativeTo(null); }// //GEN-END:initComponents private void formWindowOpened(java.awt.event.WindowEvent evt)//GEN-FIRST:event_formWindowOpened {//GEN-HEADEREND:event_formWindowOpened - DefaultTreeModel thelist = (DefaultTreeModel)tvObjectList.getModel(); - objList = new DefaultMutableTreeNode((ZoneArchive.gameMask == 2) ? "SMG2 objects" : "SMG1 objects"); - thelist.setRoot(objList); + objList = new DefaultMutableTreeNode((ZoneArchive.game == 2) ? "SMG2 objects" : "SMG1 objects"); + DefaultTreeModel list = (DefaultTreeModel)tvObjectList.getModel(); + list.setRoot(objList); - LinkedHashMap catlist = new LinkedHashMap<>(ObjectDB.categories.size()); - for (Entry cat : ObjectDB.categories.entrySet()) - { + HashMap catList = new LinkedHashMap(); + for (Entry cat : ObjectDB.categories.entrySet()) { DefaultMutableTreeNode tn = new DefaultMutableTreeNode(cat.getValue()); - catlist.put(cat.getKey(), tn); + catList.put(cat.getKey(), tn); } - LinkedHashMap tempnodelist = new LinkedHashMap<>(ObjectDB.objects.size()); - for (ObjectDB.Object obj : ObjectDB.objects.values()) - { - if ((obj.games & game) == 0) continue; - - DefaultMutableTreeNode tn = catlist.get(obj.category); - MyObjTreeNode objnode = new MyObjTreeNode(obj.ID); - tn.add(objnode); - tempnodelist.put(obj.ID, objnode); + HashMap tempList = new LinkedHashMap(); + for (ObjectDB.Object obj : ObjectDB.objects.values()) { + try { + if ((obj.games & game) == 0) + continue; + + DefaultMutableTreeNode tn = catList.get(obj.category); + MyObjTreeNode objnode = new MyObjTreeNode(obj.ID); + tn.add(objnode); + tempList.put(obj.ID, objnode); + } + catch (Exception ex) { + System.out.println(obj.name + " " + obj.category); + } } - for (DefaultMutableTreeNode catnode : catlist.values()) - { + for (DefaultMutableTreeNode catnode : catList.values()) { if (catnode.getChildCount() == 0) continue; objList.add(catnode); } - if (!selectedObject.isEmpty() && ObjectDB.objects.containsKey(selectedObject)) - { - TreePath path = new TreePath(((DefaultTreeModel)tvObjectList.getModel()).getPathToRoot(tempnodelist.get(selectedObject))); + if (!selectedObject.isEmpty() && ObjectDB.objects.containsKey(selectedObject)) { + TreePath path = new TreePath(((DefaultTreeModel)tvObjectList.getModel()).getPathToRoot(tempList.get(selectedObject))); tvObjectList.setSelectionPath(path); tvObjectList.scrollPathToVisible(path); } - else - { + else { TreePath path = new TreePath(((DefaultTreeModel)tvObjectList.getModel()).getPathToRoot(objList.getChildAt(0))); tvObjectList.scrollPathToVisible(path); } @@ -268,55 +236,34 @@ private void formWindowOpened(java.awt.event.WindowEvent evt)//GEN-FIRST:event_f private void tvObjectListValueChanged(javax.swing.event.TreeSelectionEvent evt)//GEN-FIRST:event_tvObjectListValueChanged {//GEN-HEADEREND:event_tvObjectListValueChanged MutableTreeNode tn = (MutableTreeNode)tvObjectList.getSelectionPath().getLastPathComponent(); - if (tn.getClass() != MyObjTreeNode.class || tvObjectList.getSelectionPath() == null) - { + if (tn.getClass() != MyObjTreeNode.class || tvObjectList.getSelectionPath() == null) { epObjDescription.setText(""); btnSelect.setEnabled(false); return; } - ObjectDB.Object dbinfo = ObjectDB.objects.get(((MyObjTreeNode)tn).objectID); - switch (dbinfo.games) { - default: objGame = "Unknown"; break; - case 1: objGame = "SMG1"; break; - case 2: objGame = "SMG2"; break; - case 3: objGame = "SMG1 & SMG2"; break; - } - - if (dbinfo.known == 0 && dbinfo.complete == 0) { - objStatus = "(This object's purpose is not known yet!)"; - } - else if ((dbinfo.known == 1 && dbinfo.complete == 0) || (dbinfo.known == 0 && dbinfo.complete == 1)) { - objStatus = "(This object is not fully known!)"; - } - else if (dbinfo.known == 1 && dbinfo.complete == 1) { - objStatus = "(This object has been fully documented!)"; - } - else { - objStatus = "(Unknown)"; - } + ObjectDB.Object dbinfo = ObjectDB.objects.get(((MyObjTreeNode)tn).objectID); - txtObject.setText(((MyObjTreeNode)tn).objectID); + txtObject.setText(((MyObjTreeNode) tn).objectID); epObjDescription.setText( - "" + dbinfo.name + " (" + dbinfo.ID + ")
" + - objStatus + "
" + - "Games: " + objGame + "
" + - "Type: " + dbinfo.type + "
" + - "
" + - dbinfo.notes + "
" + - "
" + - "Obj_args:
" + dbinfo.dataFields + "
" + - "Files:
" + dbinfo.dataFiles + "
" + dbinfo.toString() + "\n" + + "Status: " + dbinfo.getStatus() + "\n" + + "Games: " + dbinfo.getGame() + "\n" + + "Type: " + dbinfo.type + "\n" + + "\n" + + dbinfo.notes + "\n" + + "\n" + + "Obj_args:\n" + dbinfo.getFieldsAsString() + "\n" + + "Files:\n" + dbinfo.getFilesAsString() ); epObjDescription.setCaretPosition(0); + btnSelect.setEnabled(true); }//GEN-LAST:event_tvObjectListValueChanged private void btnSelectActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnSelectActionPerformed {//GEN-HEADEREND:event_btnSelectActionPerformed selectedObject = txtObject.getText(); - if (!selectedZone.equals("#lolz#")) - selectedZone = (String)cbxZone.getSelectedItem(); if (!selectedLayer.equals("#lolz#")) selectedLayer = (String)cbxLayer.getSelectedItem(); dispose(); @@ -325,17 +272,16 @@ private void btnSelectActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST private void txtSearchKeyReleased(java.awt.event.KeyEvent evt)//GEN-FIRST:event_txtSearchKeyReleased {//GEN-HEADEREND:event_txtSearchKeyReleased String search = txtSearch.getText().toLowerCase(); - if (search.isEmpty()) - { - ((DefaultTreeModel)tvObjectList.getModel()).setRoot(objList); + if (search.isEmpty()) { + ((DefaultTreeModel) tvObjectList.getModel()).setRoot(objList); } - else - { + else { searchList.removeAllChildren(); - for (ObjectDB.Object obj : ObjectDB.objects.values()) - { - if ((obj.games & game) == 0) continue; - if (!obj.ID.toLowerCase().contains(search) && !obj.name.toLowerCase().contains(search)) continue; + for (ObjectDB.Object obj : ObjectDB.objects.values()) { + if ((obj.games & game) == 0) + continue; + if (!obj.ID.toLowerCase().contains(search) && !obj.name.toLowerCase().contains(search)) + continue; MyObjTreeNode objnode = new MyObjTreeNode(obj.ID); searchList.add(objnode); @@ -344,7 +290,7 @@ private void txtSearchKeyReleased(java.awt.event.KeyEvent evt)//GEN-FIRST:event_ if (searchList.getChildCount() == 0) searchList.add(new DefaultMutableTreeNode("(no results)")); - ((DefaultTreeModel)tvObjectList.getModel()).setRoot(searchList); + ((DefaultTreeModel) tvObjectList.getModel()).setRoot(searchList); } }//GEN-LAST:event_txtSearchKeyReleased @@ -354,135 +300,108 @@ private void tvObjectListMouseClicked(java.awt.event.MouseEvent evt)//GEN-FIRST: return; MutableTreeNode tn = (MutableTreeNode)tvObjectList.getSelectionPath().getLastPathComponent(); + if (tn.getClass() != MyObjTreeNode.class) return; if (evt.getClickCount() < 2) return; - selectedObject = ((MyObjTreeNode)tn).objectID; + selectedObject = ((MyObjTreeNode) tn).objectID; dispose(); }//GEN-LAST:event_tvObjectListMouseClicked private void txtObjectKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtObjectKeyReleased - selectedObject = txtObject.getText(); - if (selectedObject.isEmpty()) { - btnSelect.setEnabled(false); - } - else { - btnSelect.setEnabled(true); - } + btnSelect.setEnabled(!(selectedObject = txtObject.getText()).isEmpty()); }//GEN-LAST:event_txtObjectKeyReleased - - public class MyObjTreeNode implements MutableTreeNode - { + public class MyObjTreeNode implements MutableTreeNode { public MyObjTreeNode(String objid) { this.parent = null; this.objectID = objid; } - - + @Override public void insert(MutableTreeNode child, int index) {} @Override public void remove(int index) {} @Override public void remove(MutableTreeNode node) {} - + @Override public void setUserObject(Object object) {} - + @Override - public void removeFromParent() - { + public void removeFromParent() { parent = null; - System.out.println("[MyObjTreeNode] REMOVE FROM PARENT"); } - + @Override - public void setParent(MutableTreeNode newParent) - { + public void setParent(MutableTreeNode newParent) { parent = newParent; } - + @Override - public TreeNode getChildAt(int childIndex) - { + public TreeNode getChildAt(int childIndex) { return null; } - + @Override - public int getChildCount() - { + public int getChildCount() { return 0; } - + @Override - public TreeNode getParent() - { + public TreeNode getParent() { return parent; } - + @Override - public int getIndex(TreeNode node) - { + public int getIndex(TreeNode node) { return -1; } - + @Override - public boolean getAllowsChildren() - { + public boolean getAllowsChildren() { return false; } - + @Override - public boolean isLeaf() - { + public boolean isLeaf() { return true; } - + @Override - public Enumeration children() - { + public Enumeration children() { return null; } - - + @Override - public String toString() - { + public String toString() { ObjectDB.Object dbinfo = ObjectDB.objects.get(objectID); return dbinfo.name + " (" + dbinfo.ID + ")"; } - - + public TreeNode parent; public String objectID; } - - private int game; - private String objGame, objStatus; - public String selectedObject, selectedZone, selectedLayer; + private final int game; private DefaultMutableTreeNode objList, searchList; + public String selectedObject, selectedLayer; // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btnSelect; private javax.swing.JComboBox cbxLayer; - private javax.swing.JComboBox cbxZone; - private javax.swing.JEditorPane epObjDescription; - private javax.swing.Box.Filler filler1; - private javax.swing.Box.Filler filler2; + private javax.swing.JTextPane epObjDescription; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JScrollPane jScrollPane1; - private javax.swing.JScrollPane jScrollPane3; + private javax.swing.JScrollPane jScrollPane2; private javax.swing.JToolBar jToolBar1; private javax.swing.JLabel lblLayer; - private javax.swing.JLabel lblZone; private javax.swing.JTree tvObjectList; private javax.swing.JTextField txtObject; private javax.swing.JTextField txtSearch; // End of variables declaration//GEN-END:variables -} +} \ No newline at end of file diff --git a/src/whitehole/PropertyGrid.java b/src/com/aurum/whitehole/swing/PropertyGrid.java similarity index 73% rename from src/whitehole/PropertyGrid.java rename to src/com/aurum/whitehole/swing/PropertyGrid.java index 82cd1e9..f1c07d5 100644 --- a/src/whitehole/PropertyGrid.java +++ b/src/com/aurum/whitehole/swing/PropertyGrid.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,8 +13,9 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole; +package com.aurum.whitehole.swing; +import com.aurum.whitehole.ObjectDB; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -34,10 +35,8 @@ import javax.swing.table.TableCellEditor; import javax.swing.table.TableCellRenderer; -public class PropertyGrid extends JTable -{ - public PropertyGrid(JFrame parent) - { +public class PropertyGrid extends JTable { + public PropertyGrid(JFrame parent) { labelRenderer = new LabelCellRenderer(); labelEditor = new LabelCellEditor(); @@ -47,17 +46,14 @@ public PropertyGrid(JFrame parent) eventListener = null; this.parent = parent; - this.setModel(new PGModel()); - this.setUI(new PGUI()); - + super.setModel(new PGModel()); + super.setUI(new PGUI()); + super.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); this.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); - - this.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); } - public void clear() - { + public void clear() { this.removeAll(); this.clearSelection(); @@ -65,13 +61,11 @@ public void clear() curRow = 0; } - public void setEventListener(EventListener listener) - { + public void setEventListener(EventListener listener) { eventListener = listener; } - public void addCategory(String name, String caption) - { + public void addCategory(String name, String caption) { if (fields.containsKey(name)) return; @@ -93,10 +87,8 @@ public void addCategory(String name, String caption) field.label.setHorizontalAlignment(SwingConstants.CENTER); } - public void addField(String name, String caption, String type, java.util.List choices, Object val, String info) - { - if (fields.containsKey(name)) - { + public void addField(String name, String caption, String type, java.util.List choices, Object val, String info) { + if (fields.containsKey(name)) { if (!val.equals(fields.get(name).value)) fields.get(name).value = null; @@ -105,37 +97,24 @@ public void addField(String name, String caption, String type, java.util.List ch Field field = new Field(); field.name = name; - field.row = curRow++; field.type = type; field.choices = choices; field.value = val; - field.label = new JLabel(caption); field.renderer = null; - field.tip = new JToolTip(); field.tip.setToolTipText(info); - switch (type) - { + switch (type) { case "text": case "int": - field.editor = new TextCellEditor(field, true); - break; - - case "noedit": - field.editor = new TextCellEditor(field, false); + field.editor = new TextCellEditor(field); break; case "float": field.renderer = new FloatCellRenderer(); - field.editor = new FloatCellEditor(field, true); - break; - - case "float_noedit": - field.renderer = new FloatCellRenderer(); - field.editor = new FloatCellEditor(field, false); + field.editor = new FloatCellEditor(field); break; case "list": @@ -162,8 +141,7 @@ public void addField(String name, String caption, String type, java.util.List ch fields.put(name, field); } - public void setFieldValue(String field, Object value) - { + public void setFieldValue(String field, Object value) { if (!fields.containsKey(field)) return; Field f = fields.get(field); @@ -171,8 +149,7 @@ public void setFieldValue(String field, Object value) f.value = value; } - public void removeField(String field) - { + public void removeField(String field) { if (!fields.containsKey(field)) return; @@ -183,15 +160,12 @@ public void removeField(String field) } @Override - public Rectangle getCellRect(int row, int col, boolean includeSpacing) - { + public Rectangle getCellRect(int row, int col, boolean includeSpacing) { Rectangle rect = super.getCellRect(row, col, includeSpacing); - try - { + try { Field field = (Field)fields.values().toArray()[row]; - if (field.type.equals("category")) - { + if (field.type.equals("category")) { if (col == 0) rect.width = this.getBounds().width; else @@ -204,54 +178,49 @@ public Rectangle getCellRect(int row, int col, boolean includeSpacing) } @Override - public TableCellRenderer getCellRenderer(int row, int col) - { + public TableCellRenderer getCellRenderer(int row, int col) { Field field = (Field)fields.values().toArray()[row]; - if (col == 0) return labelRenderer; - if (col == 1 && field.renderer != null) return field.renderer; + if (col == 0) + return labelRenderer; + if (col == 1 && field.renderer != null) + return field.renderer; return super.getCellRenderer(row, col); } @Override - public TableCellEditor getCellEditor(int row, int col) - { + public TableCellEditor getCellEditor(int row, int col) { Field field = (Field)fields.values().toArray()[row]; - if (col == 0) return labelEditor; - if (col == 1) return field.editor; + if (col == 0) + return labelEditor; + if (col == 1) + return field.editor; return super.getCellEditor(row, col); } - public class PGModel extends AbstractTableModel - { + public class PGModel extends AbstractTableModel { @Override - public int getRowCount() - { + public int getRowCount() { return fields.size(); } @Override - public int getColumnCount() - { + public int getColumnCount() { return 2; } @Override - public Object getValueAt(int row, int col) - { + public Object getValueAt(int row, int col) { Field field = (Field)fields.values().toArray()[row]; if (col == 0) return field.label.getText(); - else - { - if (!field.type.equals("category")) - { - //if (field.value == null) return ""; + else { + if (!field.type.equals("category")) { return field.value; } } @@ -260,26 +229,20 @@ public Object getValueAt(int row, int col) } @Override - public String getColumnName(int col) - { - if (col == 0) return "Property"; - return "Value"; + public String getColumnName(int col) { + return col == 0 ? "Property" : "Value"; } @Override - public boolean isCellEditable(int row, int col) - { - if (col == 0) return false; - return true; + public boolean isCellEditable(int row, int col) { + return col != 0; } } // based off http://code.google.com/p/spantable/source/browse/SpanTable/src/main/java/spantable/SpanTableUI.java - public class PGUI extends BasicTableUI - { + public class PGUI extends BasicTableUI { @Override - public void paint(Graphics g, JComponent c) - { + public void paint(Graphics g, JComponent c) { Rectangle r = g.getClipBounds(); int firstRow = table.rowAtPoint(new Point(r.x, r.y)); int lastRow = table.rowAtPoint(new Point(r.x, r.y + r.height)); @@ -290,28 +253,23 @@ public void paint(Graphics g, JComponent c) paintRow(row, g); } - private void paintRow(int row, Graphics g) - { + private void paintRow(int row, Graphics g) { Rectangle clipRect = g.getClipBounds(); - for (int col = 0; col < table.getColumnCount(); col++) - { + for (int col = 0; col < table.getColumnCount(); col++) { Rectangle cellRect = table.getCellRect(row, col, true); if (cellRect.width == 0) continue; - if (cellRect.intersects(clipRect)) - { + if (cellRect.intersects(clipRect)) { paintCell(row, col, g, cellRect); } } } - private void paintCell(int row, int column, Graphics g, Rectangle area) - { + private void paintCell(int row, int column, Graphics g, Rectangle area) { int verticalMargin = table.getRowMargin(); int horizontalMargin = table.getColumnModel().getColumnMargin(); Color c = g.getColor(); g.setColor(table.getGridColor()); - // Acmlmboard border method g.drawLine(area.x+area.width-1, area.y, area.x+area.width-1, area.y+area.height-1); g.drawLine(area.x, area.y+area.height-1, area.x+area.width-1, area.y+area.height-1); g.setColor(c); @@ -319,62 +277,51 @@ private void paintCell(int row, int column, Graphics g, Rectangle area) area.setBounds(area.x + horizontalMargin / 2, area.y + verticalMargin / 2, area.width - horizontalMargin, area.height - verticalMargin); - if (table.isEditing() && table.getEditingRow() == row && table.getEditingColumn() == column) - { + if (table.isEditing() && table.getEditingRow() == row && table.getEditingColumn() == column) { Component component = table.getEditorComponent(); component.setBounds(area); component.validate(); } - else - { + else { TableCellRenderer renderer = table.getCellRenderer(row, column); Component component = table.prepareRenderer(renderer, row, column); - if (renderer != null && component != null) - { + if (renderer != null && component != null) { if (component.getParent() == null) rendererPane.add(component); - rendererPane.paintComponent(g, component, table, area.x, area.y, - area.width, area.height, true); + rendererPane.paintComponent(g, component, table, area.x, area.y, area.width, area.height, true); } } } } - public class LabelCellRenderer implements TableCellRenderer - { + public class LabelCellRenderer implements TableCellRenderer { @Override - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) - { + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) { Field field = (Field)fields.values().toArray()[row]; - if (col == 0) return field.label; + if (col == 0) + return field.label; return null; } } - public class GeneralCellRenderer extends DefaultTableCellRenderer - { + public class GeneralCellRenderer extends DefaultTableCellRenderer { @Override - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) - { + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) { if (value == null) value = ""; return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col); } } - public class FloatCellRenderer extends DefaultTableCellRenderer - { + public class FloatCellRenderer extends DefaultTableCellRenderer { JLabel label; - public FloatCellRenderer() - { + public FloatCellRenderer() { label = new JLabel(); } @Override - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) - { - if (value == null) - { + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) { + if (value == null) { label.setText(""); return label; } @@ -389,18 +336,15 @@ public Component getTableCellRendererComponent(JTable table, Object value, boole } } - public class BoolCellRenderer extends DefaultTableCellRenderer - { + public class BoolCellRenderer extends DefaultTableCellRenderer { JCheckBox cb; - public BoolCellRenderer() - { + public BoolCellRenderer() { cb = new JCheckBox(); } @Override - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) - { + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) { if (value == null) { cb.getModel().setSelected(true); @@ -412,8 +356,7 @@ public Component getTableCellRendererComponent(JTable table, Object value, boole } } - public class LabelCellEditor implements TableCellEditor - { + public class LabelCellEditor implements TableCellEditor { @Override public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { return null; } @Override @@ -432,23 +375,18 @@ public void addCellEditorListener(CellEditorListener l) {} public void removeCellEditorListener(CellEditorListener l) {} } - public class FloatCellEditor extends AbstractCellEditor implements TableCellEditor - { + public class FloatCellEditor extends AbstractCellEditor implements TableCellEditor { JSpinner spinner; Field field; - public FloatCellEditor(Field f, boolean e) - { + public FloatCellEditor(Field f) { field = f; spinner = new JSpinner(); spinner.setModel(new SpinnerNumberModel(13.37f, -Float.MAX_VALUE, Float.MAX_VALUE, 1f)); - spinner.setEnabled(e); - spinner.addChangeListener(new ChangeListener() - { + spinner.addChangeListener(new ChangeListener() { @Override - public void stateChanged(ChangeEvent evt) - { + public void stateChanged(ChangeEvent evt) { // guarantee the value we're giving out is a Float. herp derp Object val = spinner.getValue(); float fval = (val instanceof Double) ? (float)(double)val : (float)val; @@ -459,52 +397,44 @@ public void stateChanged(ChangeEvent evt) } @Override - public Object getCellEditorValue() - { + public Object getCellEditorValue() { return spinner.getValue(); } @Override - public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int col) - { + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int col) { spinner.setValue(value == null ? 0f : value); return spinner; } } - public class TextCellEditor extends AbstractCellEditor implements TableCellEditor - { + public class TextCellEditor extends AbstractCellEditor implements TableCellEditor { JTextField textfield; Field field; boolean isInt; - public TextCellEditor(Field f, boolean e) - { + public TextCellEditor(Field f) { field = f; isInt = f.type.equals("int"); textfield = new JTextField(f.value.toString()); - textfield.setEnabled(e); - textfield.addKeyListener(new KeyListener() - { + textfield.addKeyListener(new KeyListener() { @Override public void keyPressed(KeyEvent evt) {} @Override public void keyTyped(KeyEvent evt) {} @Override - public void keyReleased(KeyEvent evt) - { + public void keyReleased(KeyEvent evt) { Object val = textfield.getText(); - try - { - if (isInt) val = Integer.parseInt((String)val); + try { + if (isInt) + val = Integer.parseInt((String)val); textfield.setForeground(Color.getColor("text")); field.value = val; eventListener.propertyChanged(field.name, val); } - catch (NumberFormatException ex) - { + catch (NumberFormatException ex) { textfield.setForeground(new Color(0xFF4040)); } } @@ -512,40 +442,33 @@ public void keyReleased(KeyEvent evt) } @Override - public Object getCellEditorValue() - { + public Object getCellEditorValue() { return textfield.getText(); } @Override - public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int col) - { + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int col) { if (value == null) value = isInt ? "0" : ""; textfield.setText(value.toString()); return textfield; } } - public class ListCellEditor extends AbstractCellEditor implements TableCellEditor - { + public class ListCellEditor extends AbstractCellEditor implements TableCellEditor { JComboBox combo; Field field; - public ListCellEditor(Field f, boolean e) - { + public ListCellEditor(Field f, boolean editable) { field = f; combo = new JComboBox(f.choices.toArray()); - combo.setEditable(e); - combo.addActionListener(new ActionListener() - { + combo.setEditable(editable); + combo.addActionListener(new ActionListener() { @Override - public void actionPerformed(ActionEvent evt) - { + public void actionPerformed(ActionEvent evt) { Object val = combo.getSelectedItem(); - if (!field.value.equals(val)) - { + if (!field.value.equals(val)) { field.value = val; eventListener.propertyChanged(field.name, val); } @@ -554,14 +477,12 @@ public void actionPerformed(ActionEvent evt) } @Override - public Object getCellEditorValue() - { + public Object getCellEditorValue() { return combo.getSelectedItem(); } @Override - public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int col) - { + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int col) { if (value == null) combo.setSelectedIndex(0); else @@ -570,21 +491,17 @@ public Component getTableCellEditorComponent(JTable table, Object value, boolean } } - public class BoolCellEditor extends AbstractCellEditor implements TableCellEditor - { + public class BoolCellEditor extends AbstractCellEditor implements TableCellEditor { JCheckBox checkbox; Field field; - public BoolCellEditor(Field f) - { + public BoolCellEditor(Field f) { field = f; checkbox = new JCheckBox(); - checkbox.addActionListener(new ActionListener() - { + checkbox.addActionListener(new ActionListener() { @Override - public void actionPerformed(ActionEvent evt) - { + public void actionPerformed(ActionEvent evt) { boolean val = checkbox.isSelected(); field.value = val; @@ -594,28 +511,24 @@ public void actionPerformed(ActionEvent evt) } @Override - public Object getCellEditorValue() - { + public Object getCellEditorValue() { return checkbox.isSelected(); } @Override - public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int col) - { + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int col) { checkbox.setSelected(value == null ? false : (boolean)value); return checkbox; } } - public class ObjectCellEditor extends AbstractCellEditor implements TableCellEditor - { + public class ObjectCellEditor extends AbstractCellEditor implements TableCellEditor { JPanel container; JTextField textfield; JButton button; Field field; - public ObjectCellEditor(Field f) - { + public ObjectCellEditor(Field f) { field = f; container = new JPanel(); @@ -623,19 +536,16 @@ public ObjectCellEditor(Field f) textfield = new JTextField(f.value.toString()); container.add(textfield, BorderLayout.CENTER); - textfield.addKeyListener(new KeyListener() - { + textfield.addKeyListener(new KeyListener() { @Override public void keyPressed(KeyEvent evt) {} @Override public void keyTyped(KeyEvent evt) {} @Override - public void keyReleased(KeyEvent evt) - { + public void keyReleased(KeyEvent evt) { String val = textfield.getText(); - textfield.setForeground(ObjectDB.objects.containsKey(val) - ? Color.getColor("text") : new Color(0xFF4040)); + textfield.setForeground(ObjectDB.objects.containsKey(val) ? Color.getColor("text") : new Color(0xFF4040)); field.value = val; eventListener.propertyChanged(field.name, val); @@ -644,20 +554,17 @@ public void keyReleased(KeyEvent evt) button = new JButton("..."); container.add(button, BorderLayout.EAST); - button.addActionListener(new ActionListener() - { + button.addActionListener(new ActionListener() { @Override - public void actionPerformed(ActionEvent evt) - { + public void actionPerformed(ActionEvent evt) { GalaxyEditorForm gform = (GalaxyEditorForm)parent; - ObjectSelectForm objsel = new ObjectSelectForm(gform, gform.zoneArcs.get(gform.galaxyName).gameMask, textfield.getText()); + ObjectSelectForm objsel = new ObjectSelectForm(gform, gform.zoneArcs.get(gform.galaxyName).game, textfield.getText()); objsel.setVisible(true); String val = objsel.selectedObject; textfield.setText(val); - textfield.setForeground(ObjectDB.objects.containsKey(val) - ? Color.getColor("text") : new Color(0xFF4040)); + textfield.setForeground(ObjectDB.objects.containsKey(val) ? Color.getColor("text") : new Color(0xFF4040)); field.value = val; eventListener.propertyChanged(field.name, val); @@ -667,28 +574,23 @@ public void actionPerformed(ActionEvent evt) int btnheight = button.getPreferredSize().height; button.setPreferredSize(new Dimension(btnheight, btnheight)); - textfield.setForeground(ObjectDB.objects.containsKey((String)field.value) - ? Color.getColor("text") : new Color(0xFF4040)); + textfield.setForeground(ObjectDB.objects.containsKey((String)field.value) ? Color.getColor("text") : new Color(0xFF4040)); } @Override - public Object getCellEditorValue() - { + public Object getCellEditorValue() { return textfield.getText(); } @Override - public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int col) - { + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int col) { textfield.setText(value == null ? "" : value.toString()); return container; } } - public class Field - { + public class Field { String name; - String type; int row; java.util.List choices; @@ -700,19 +602,15 @@ public class Field TableCellEditor editor; } - public interface EventListener - { + public interface EventListener { public void propertyChanged(String propname, Object value); } - public LinkedHashMap fields; - private int curRow; + private int curRow; private EventListener eventListener; - - private JFrame parent; - - private LabelCellRenderer labelRenderer; - private LabelCellEditor labelEditor; + private final JFrame parent; + private final LabelCellRenderer labelRenderer; + private final LabelCellEditor labelEditor; } \ No newline at end of file diff --git a/src/whitehole/SettingsForm.form b/src/com/aurum/whitehole/swing/SettingsForm.form similarity index 98% rename from src/whitehole/SettingsForm.form rename to src/com/aurum/whitehole/swing/SettingsForm.form index 7289bc5..9ca7965 100644 --- a/src/whitehole/SettingsForm.form +++ b/src/com/aurum/whitehole/swing/SettingsForm.form @@ -4,14 +4,14 @@ + + + - + - - - diff --git a/src/whitehole/SettingsForm.java b/src/com/aurum/whitehole/swing/SettingsForm.java similarity index 91% rename from src/whitehole/SettingsForm.java rename to src/com/aurum/whitehole/swing/SettingsForm.java index c0dd41f..8c6adab 100644 --- a/src/whitehole/SettingsForm.java +++ b/src/com/aurum/whitehole/swing/SettingsForm.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,21 +13,25 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole; +package com.aurum.whitehole.swing; -public class SettingsForm extends javax.swing.JDialog -{ - public SettingsForm(java.awt.Frame parent, boolean modal) - { +import com.aurum.whitehole.Settings; +import com.aurum.whitehole.Whitehole; + +public class SettingsForm extends javax.swing.JDialog { + public SettingsForm(java.awt.Frame parent, boolean modal) { super(parent, modal); initComponents(); + txtObjectDBUrl.setText(Settings.objectDB_url); + chkObjectDBUpdate.setSelected(Settings.objectDB_update); + chkAreaRender.setSelected(Settings.editor_areas); + chkUseShaders.setSelected(Settings.editor_shaders); + chkFastDrag.setSelected(Settings.editor_fastDrag); + chkYaz0.setSelected(Settings.arc_enc); + chkThemeSystem.setSelected(Settings.theme_system); + txtObjectDBUrl.setCaretPosition(0); } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ + @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { @@ -49,11 +53,7 @@ private void initComponents() { setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle("Settings"); - addWindowListener(new java.awt.event.WindowAdapter() { - public void windowOpened(java.awt.event.WindowEvent evt) { - formWindowOpened(evt); - } - }); + setIconImage(Whitehole.ICON); chkObjectDBUpdate.setText("Check for object database updates on startup"); chkObjectDBUpdate.setBorder(javax.swing.BorderFactory.createTitledBorder("")); @@ -162,23 +162,9 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { ); pack(); + setLocationRelativeTo(null); }// //GEN-END:initComponents - private void formWindowOpened(java.awt.event.WindowEvent evt)//GEN-FIRST:event_formWindowOpened - {//GEN-HEADEREND:event_formWindowOpened - // get settings - txtObjectDBUrl.setText(Settings.objectDB_url); - chkObjectDBUpdate.setSelected(Settings.objectDB_update); - chkAreaRender.setSelected(Settings.editor_areas); - chkUseShaders.setSelected(Settings.editor_shaders); - chkFastDrag.setSelected(Settings.editor_fastDrag); - chkYaz0.setSelected(Settings.arc_enc); - chkThemeSystem.setSelected(Settings.theme_system); - - // merp, one of those little details... - txtObjectDBUrl.setCaretPosition(0); - }//GEN-LAST:event_formWindowOpened - private void btnCancelActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnCancelActionPerformed {//GEN-HEADEREND:event_btnCancelActionPerformed dispose(); @@ -213,4 +199,4 @@ private void btnOkActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:eve private javax.swing.JLabel lblRendering; private javax.swing.JTextField txtObjectDBUrl; // End of variables declaration//GEN-END:variables -} +} \ No newline at end of file diff --git a/src/whitehole/ToolbarFlowLayout.java b/src/com/aurum/whitehole/swing/ToolbarFlowLayout.java similarity index 52% rename from src/whitehole/ToolbarFlowLayout.java rename to src/com/aurum/whitehole/swing/ToolbarFlowLayout.java index 862f5e4..4be818d 100644 --- a/src/whitehole/ToolbarFlowLayout.java +++ b/src/com/aurum/whitehole/swing/ToolbarFlowLayout.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,57 +13,46 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole; +package com.aurum.whitehole.swing; import java.awt.*; - public class ToolbarFlowLayout extends FlowLayout - { - public ToolbarFlowLayout() - { +public class ToolbarFlowLayout extends FlowLayout { + public ToolbarFlowLayout() { super(); } - - public ToolbarFlowLayout(int align) - { + + public ToolbarFlowLayout(int align) { super(align); } - public ToolbarFlowLayout(int align, int hgap, int vgap) - { + public ToolbarFlowLayout(int align, int hgap, int vgap) { super(align, hgap, vgap); } - + @Override - public Dimension minimumLayoutSize(Container target) - { - // Size of largest component, so we can resize it in - // either direction with something like a split-pane. + public Dimension minimumLayoutSize(Container target) { return computeMinSize(target); } - + @Override - public Dimension preferredLayoutSize(Container target) - { + public Dimension preferredLayoutSize(Container target) { return computeSize(target); } - - private Dimension computeSize(Container target) - { + + private Dimension computeSize(Container target) { synchronized (target.getTreeLock()) { int hgap = getHgap(); int vgap = getVgap(); int w = target.getWidth(); - // Let this behave like a regular FlowLayout (single row) - // if the container hasn't been assigned any size yet if (w == 0) { - w = Integer.MAX_VALUE; + w = Integer.MAX_VALUE; } Insets insets = target.getInsets(); if (insets == null){ - insets = new Insets(0, 0, 0, 0); + insets = new Insets(0, 0, 0, 0); } int reqdWidth = 0; @@ -74,54 +63,54 @@ private Dimension computeSize(Container target) int rowHeight = 0; for (int i = 0; i < n; i++) { - Component c = target.getComponent(i); - if (c.isVisible()) { - Dimension d = c.getPreferredSize(); - if ((x == 0) || ((x + d.width) <= maxwidth)) { - // fits in current row. - if (x > 0) { - x += hgap; + Component c = target.getComponent(i); + if (c.isVisible()) { + Dimension d = c.getPreferredSize(); + if ((x == 0) || ((x + d.width) <= maxwidth)) { + // fits in current row. + if (x > 0) { + x += hgap; + } + x += d.width; + rowHeight = Math.max(rowHeight, d.height); } - x += d.width; - rowHeight = Math.max(rowHeight, d.height); - } - else { - // Start of new row - x = d.width; - y += vgap + rowHeight; - rowHeight = d.height; + else { + // Start of new row + x = d.width; + y += vgap + rowHeight; + rowHeight = d.height; + } + reqdWidth = Math.max(reqdWidth, x); } - reqdWidth = Math.max(reqdWidth, x); - } } y += rowHeight; y += insets.bottom; return new Dimension(reqdWidth+insets.left+insets.right, y); } } - - private Dimension computeMinSize(Container target) - { + + private Dimension computeMinSize(Container target) { synchronized (target.getTreeLock()) { int minx = Integer.MAX_VALUE; int miny = Integer.MIN_VALUE; boolean found_one = false; int n = target.getComponentCount(); - + for (int i = 0; i < n; i++) { - Component c = target.getComponent(i); - if (c.isVisible()) { - found_one = true; - Dimension d = c.getPreferredSize(); - minx = Math.min(minx, d.width); - miny = Math.min(miny, d.height); - } + Component c = target.getComponent(i); + if (c.isVisible()) { + found_one = true; + Dimension d = c.getPreferredSize(); + minx = Math.min(minx, d.width); + miny = Math.min(miny, d.height); + } } + if (found_one) { - return new Dimension(minx, miny); + return new Dimension(minx, miny); } + return new Dimension(0, 0); } } - -} +} \ No newline at end of file diff --git a/src/whitehole/vectors/Color4.java b/src/com/aurum/whitehole/vectors/Color4.java similarity index 59% rename from src/whitehole/vectors/Color4.java rename to src/com/aurum/whitehole/vectors/Color4.java index 17c5fd7..f9a2f64 100644 --- a/src/whitehole/vectors/Color4.java +++ b/src/com/aurum/whitehole/vectors/Color4.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,31 +13,41 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.vectors; +package com.aurum.whitehole.vectors; -public class Color4 -{ - public Color4() - { +public class Color4 implements Cloneable { + public float r, g, b, a; + + public Color4() { r = g = b = a = 0f; } - public Color4(float r, float g, float b) - { + @Override + public String toString() { + return r + " | " + g + " | " + b + " | " + a; + } + + @Override + public Object clone() { + try { + return super.clone(); + } + catch(CloneNotSupportedException ex) { + return null; + } + } + + public Color4(float r, float g, float b) { this.r = r; this.g = g; this.b = b; a = 1f; } - public Color4(float r, float g, float b, float a) - { + public Color4(float r, float g, float b, float a) { this.r = r; this.g = g; this.b = b; this.a = a; } - - - public float r, g, b, a; -} +} \ No newline at end of file diff --git a/src/whitehole/vectors/Matrix4.java b/src/com/aurum/whitehole/vectors/Matrix4.java similarity index 81% rename from src/whitehole/vectors/Matrix4.java rename to src/com/aurum/whitehole/vectors/Matrix4.java index 24de9b1..345d211 100644 --- a/src/whitehole/vectors/Matrix4.java +++ b/src/com/aurum/whitehole/vectors/Matrix4.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,12 +13,10 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.vectors; +package com.aurum.whitehole.vectors; -public class Matrix4 -{ - public Matrix4() - { +public class Matrix4 { + public Matrix4() { m = new float[16]; m[0] = 1f; m[1] = 0f; m[2] = 0f; m[3] = 0f; m[4] = 0f; m[5] = 1f; m[6] = 0f; m[7] = 0f; @@ -29,8 +27,7 @@ public Matrix4() public Matrix4(float m0, float m1, float m2, float m3, float m4, float m5, float m6, float m7, float m8, float m9, float m10, float m11, - float m12, float m13, float m14, float m15) - { + float m12, float m13, float m14, float m15) { m = new float[16]; m[0] = m0; m[1] = m1; m[2] = m2; m[3] = m3; m[4] = m4; m[5] = m5; m[6] = m6; m[7] = m7; @@ -38,9 +35,7 @@ public Matrix4(float m0, float m1, float m2, float m3, m[12] = m12; m[13] = m13; m[14] = m14; m[15] = m15; } - - public static Matrix4 scale(float factor) - { + public static Matrix4 scale(float factor) { return new Matrix4( factor, 0f, 0f, 0f, 0f, factor, 0f, 0f, @@ -48,8 +43,7 @@ public static Matrix4 scale(float factor) 0f, 0f, 0f, 1f); } - public static Matrix4 scale(Vector3 factor) - { + public static Matrix4 scale(Vector3 factor) { return new Matrix4( factor.x, 0f, 0f, 0f, 0f, factor.y, 0f, 0f, @@ -57,9 +51,7 @@ public static Matrix4 scale(Vector3 factor) 0f, 0f, 0f, 1f); } - - public static Matrix4 createRotationX(float angle) - { + public static Matrix4 createRotationX(float angle) { float cos = (float)Math.cos(angle); float sin = (float)Math.sin(angle); @@ -70,8 +62,7 @@ public static Matrix4 createRotationX(float angle) 0f, 0f, 0f, 1f); } - public static Matrix4 createRotationY(float angle) - { + public static Matrix4 createRotationY(float angle) { float cos = (float)Math.cos(angle); float sin = (float)Math.sin(angle); @@ -82,8 +73,7 @@ public static Matrix4 createRotationY(float angle) 0f, 0f, 0f, 1f); } - public static Matrix4 createRotationZ(float angle) - { + public static Matrix4 createRotationZ(float angle) { float cos = (float)Math.cos(angle); float sin = (float)Math.sin(angle); @@ -94,9 +84,7 @@ public static Matrix4 createRotationZ(float angle) 0f, 0f, 0f, 1f); } - - public static Matrix4 createTranslation(Vector3 trans) - { + public static Matrix4 createTranslation(Vector3 trans) { return new Matrix4( 1f, 0f, 0f, 0f, 0f, 1f, 0f, 0f, @@ -104,9 +92,25 @@ public static Matrix4 createTranslation(Vector3 trans) trans.x, trans.y, trans.z, 1f); } + public static Matrix4 SRTToMatrix(Vector3 scale, Vector3 rot, Vector3 trans) { + Matrix4 ret = new Matrix4(); + + Matrix4 mscale = Matrix4.scale(scale); + Matrix4 mxrot = Matrix4.createRotationX(rot.x); + Matrix4 myrot = Matrix4.createRotationY(rot.y); + Matrix4 mzrot = Matrix4.createRotationZ(rot.z); + Matrix4 mtrans = Matrix4.createTranslation(trans); + + Matrix4.mult(ret, mscale, ret); + Matrix4.mult(ret, mxrot, ret); + Matrix4.mult(ret, myrot, ret); + Matrix4.mult(ret, mzrot, ret); + Matrix4.mult(ret, mtrans, ret); + + return ret; + } - public static void mult(Matrix4 left, Matrix4 right, Matrix4 out) - { + public static void mult(Matrix4 left, Matrix4 right, Matrix4 out) { float m0 = left.m[0] * right.m[0] + left.m[1] * right.m[4] + left.m[2] * right.m[8] + left.m[3] * right.m[12], m1 = left.m[0] * right.m[1] + left.m[1] * right.m[5] + left.m[2] * right.m[9] + left.m[3] * right.m[13], m2 = left.m[0] * right.m[2] + left.m[1] * right.m[6] + left.m[2] * right.m[10] + left.m[3] * right.m[14], @@ -134,8 +138,7 @@ public static void mult(Matrix4 left, Matrix4 right, Matrix4 out) } - public static Matrix4 lookAt(Vector3 eye, Vector3 target, Vector3 up) - { + public static Matrix4 lookAt(Vector3 eye, Vector3 target, Vector3 up) { Vector3 z = new Vector3(); Vector3.subtract(eye, target, z); Vector3.normalize(z, z); Vector3 x = new Vector3(); Vector3.cross(up, z, x); Vector3.normalize(x, x); Vector3 y = new Vector3(); Vector3.cross(z, x, y); Vector3.normalize(y, y); @@ -151,10 +154,8 @@ public static Matrix4 lookAt(Vector3 eye, Vector3 target, Vector3 up) return trans; } - // taken from OpenTK - public static Matrix4 invert(Matrix4 mat) - { + public static Matrix4 invert(Matrix4 mat) { int[] colIdx = { 0, 0, 0, 0 }; int[] rowIdx = { 0, 0, 0, 0 }; int[] pivotIdx = { -1, -1, -1, -1 }; @@ -168,28 +169,21 @@ public static Matrix4 invert(Matrix4 mat) int icol = 0; int irow = 0; - for (int i = 0; i < 4; i++) - { + for (int i = 0; i < 4; i++) { // Find the largest pivot value float maxPivot = 0.0f; - for (int j = 0; j < 4; j++) - { - if (pivotIdx[j] != 0) - { - for (int k = 0; k < 4; ++k) - { - if (pivotIdx[k] == -1) - { + for (int j = 0; j < 4; j++) { + if (pivotIdx[j] != 0) { + for (int k = 0; k < 4; ++k) { + if (pivotIdx[k] == -1) { float absVal = Math.abs(inverse.m[j*4 + k]); - if (absVal > maxPivot) - { + if (absVal > maxPivot) { maxPivot = absVal; irow = j; icol = k; } } - else if (pivotIdx[k] > 0) - { + else if (pivotIdx[k] > 0) { return mat; } } @@ -199,10 +193,8 @@ else if (pivotIdx[k] > 0) ++(pivotIdx[icol]); // Swap rows over so pivot is on diagonal - if (irow != icol) - { - for (int k = 0; k < 4; ++k) - { + if (irow != icol) { + for (int k = 0; k < 4; ++k) { float f = inverse.m[irow*4 + k]; inverse.m[irow*4 + k] = inverse.m[icol*4 + k]; inverse.m[icol*4 + k] = f; @@ -214,10 +206,8 @@ else if (pivotIdx[k] > 0) float pivot = inverse.m[icol*4 + icol]; // check for singular matrix - if (pivot == 0.0f) - { - throw new RuntimeException("Matrix is singular and cannot be inverted."); - //return mat; + if (pivot == 0.0f) { + throw new IllegalArgumentException("Matrix is singular and cannot be inverted."); } // Scale row so it has a unit diagonal @@ -227,11 +217,9 @@ else if (pivotIdx[k] > 0) inverse.m[icol*4 + k] *= oneOverPivot; // Do elimination of non-diagonal elements - for (int j = 0; j < 4; ++j) - { + for (int j = 0; j < 4; ++j) { // check this isn't on the diagonal - if (icol != j) - { + if (icol != j) { float f = inverse.m[j*4 + icol]; inverse.m[j*4 + icol] = 0.0f; for (int k = 0; k < 4; ++k) @@ -240,8 +228,7 @@ else if (pivotIdx[k] > 0) } } - for (int j = 3; j >= 0; --j) - { + for (int j = 3; j >= 0; --j) { int ir = rowIdx[j]; int ic = colIdx[j]; for (int k = 0; k < 4; ++k) @@ -255,6 +242,5 @@ else if (pivotIdx[k] > 0) return inverse; } - public float m[]; -} +} \ No newline at end of file diff --git a/src/whitehole/vectors/Vector2.java b/src/com/aurum/whitehole/vectors/Vector2.java similarity index 65% rename from src/whitehole/vectors/Vector2.java rename to src/com/aurum/whitehole/vectors/Vector2.java index af0e47a..6870e71 100644 --- a/src/whitehole/vectors/Vector2.java +++ b/src/com/aurum/whitehole/vectors/Vector2.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,43 +13,52 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.vectors; +package com.aurum.whitehole.vectors; -public class Vector2 -{ - public Vector2() - { +public class Vector2 implements Cloneable { + public float x, y; + + public Vector2() { x = y = 0f; } - public Vector2(float x, float y) - { + public Vector2(float x, float y) { this.x = x; this.y = y; } - public Vector2(Vector2 copy) - { + public Vector2(Vector2 copy) { this.x = copy.x; this.y = copy.y; } + @Override + public String toString() { + return x + " | " + y; + } + + @Override + public Object clone() { + try { + return super.clone(); + } + catch(CloneNotSupportedException ex) { + return null; + } + } - public static boolean roughlyEqual(Vector2 a, Vector2 b) - { + public static boolean roughlyEqual(Vector2 a, Vector2 b) { float epsilon = 0.00001f; if (Math.abs(a.x - b.x) > epsilon) return false; if (Math.abs(a.y - b.y) > epsilon) return false; return true; } - public float length() - { + public float length() { return (float)Math.sqrt(x * x + y * y); } - public static void normalize(Vector2 v, Vector2 out) - { + public static void normalize(Vector2 v, Vector2 out) { float len = v.length(); if (len < 0.000001f) len = 1f; float x = v.x / len, @@ -57,18 +66,13 @@ public static void normalize(Vector2 v, Vector2 out) out.x = x; out.y = y; } - public static void add(Vector2 a, Vector2 b, Vector2 out) - { + public static void add(Vector2 a, Vector2 b, Vector2 out) { out.x = a.x + b.x; out.y = a.y + b.y; } - public static void subtract(Vector2 a, Vector2 b, Vector2 out) - { + public static void subtract(Vector2 a, Vector2 b, Vector2 out) { out.x = a.x - b.x; out.y = a.y - b.y; } - - - public float x, y; -} +} \ No newline at end of file diff --git a/src/whitehole/vectors/Vector3.java b/src/com/aurum/whitehole/vectors/Vector3.java similarity index 72% rename from src/whitehole/vectors/Vector3.java rename to src/com/aurum/whitehole/vectors/Vector3.java index 20a336f..cba3832 100644 --- a/src/whitehole/vectors/Vector3.java +++ b/src/com/aurum/whitehole/vectors/Vector3.java @@ -1,5 +1,5 @@ /* - © 2012 - 2016 - Whitehole Team + © 2012 - 2017 - Whitehole Team Whitehole is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -13,32 +13,43 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.vectors; +package com.aurum.whitehole.vectors; -public class Vector3 -{ - public Vector3() - { +public class Vector3 implements Cloneable { + public float x, y, z; + + public Vector3() { x = y = z = 0f; } - public Vector3(float x, float y, float z) - { + public Vector3(float x, float y, float z) { this.x = x; this.y = y; this.z = z; } - public Vector3(Vector3 copy) - { + public Vector3(Vector3 copy) { this.x = copy.x; this.y = copy.y; this.z = copy.z; } + @Override + public String toString() { + return x + " | " + y + " | " + z; + } + + @Override + public Object clone() { + try { + return super.clone(); + } + catch(CloneNotSupportedException ex) { + return null; + } + } - public static boolean roughlyEqual(Vector3 a, Vector3 b) - { + public static boolean roughlyEqual(Vector3 a, Vector3 b) { float epsilon = 0.00001f; if (Math.abs(a.x - b.x) > epsilon) return false; if (Math.abs(a.y - b.y) > epsilon) return false; @@ -46,21 +57,18 @@ public static boolean roughlyEqual(Vector3 a, Vector3 b) return true; } - public static void transform(Vector3 v, Matrix4 m, Vector3 out) - { + public static void transform(Vector3 v, Matrix4 m, Vector3 out) { float x = v.x * m.m[0] + v.y * m.m[4] + v.z * m.m[8] + m.m[12], y = v.x * m.m[1] + v.y * m.m[5] + v.z * m.m[9] + m.m[13], z = v.x * m.m[2] + v.y * m.m[6] + v.z * m.m[10] + m.m[14]; out.x = x; out.y = y; out.z = z; } - public float length() - { + public float length() { return (float)Math.sqrt(x * x + y * y + z * z); } - public static void normalize(Vector3 v, Vector3 out) - { + public static void normalize(Vector3 v, Vector3 out) { float len = v.length(); if (len < 0.000001f) len = 1f; float x = v.x / len, @@ -69,28 +77,22 @@ public static void normalize(Vector3 v, Vector3 out) out.x = x; out.y = y; out.z = z; } - public static void add(Vector3 a, Vector3 b, Vector3 out) - { + public static void add(Vector3 a, Vector3 b, Vector3 out) { out.x = a.x + b.x; out.y = a.y + b.y; out.z = a.z + b.z; } - public static void subtract(Vector3 a, Vector3 b, Vector3 out) - { + public static void subtract(Vector3 a, Vector3 b, Vector3 out) { out.x = a.x - b.x; out.y = a.y - b.y; out.z = a.z - b.z; } - public static void cross(Vector3 a, Vector3 b, Vector3 out) - { + public static void cross(Vector3 a, Vector3 b, Vector3 out) { float x = a.y * b.z - a.z * b.y, y = a.z * b.x - a.x * b.z, z = a.x * b.y - a.y * b.x; out.x = x; out.y = y; out.z = z; } - - - public float x, y, z; -} +} \ No newline at end of file diff --git a/src/Resources/icon.png b/src/res/icon.png similarity index 100% rename from src/Resources/icon.png rename to src/res/icon.png diff --git a/src/whitehole/CheckBoxList.java b/src/whitehole/CheckBoxList.java deleted file mode 100644 index 754f225..0000000 --- a/src/whitehole/CheckBoxList.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - © 2012 - 2016 - Whitehole Team - - Whitehole is free software: you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - Whitehole is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with Whitehole. If not, see http://www.gnu.org/licenses/. -*/ - -/* - * CheckBoxList inspired from http://www.devx.com/tips/Tip/5342 - */ - -package whitehole; - -import javax.swing.*; -import javax.swing.border.*; -import java.awt.*; -import java.awt.event.*; - -public class CheckBoxList extends JList -{ - protected static Border noFocusBorder = - new EmptyBorder(1, 1, 1, 1); - - public CheckBoxList() - { - setCellRenderer(new CellRenderer()); - - addMouseListener(new MouseAdapter() - { - public void mousePressed(MouseEvent e) - { - int index = locationToIndex(e.getPoint()); - - if (index != -1) { - JCheckBox checkbox = (JCheckBox) - getModel().getElementAt(index); - checkbox.setSelected( - !checkbox.isSelected()); - - if (eventListener != null) - eventListener.checkBoxStatusChanged(index, checkbox.isSelected()); - - repaint(); - } - } - } - ); - - setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - eventListener = null; - } - - public void setEventListener(EventListener listener) - { - eventListener = listener; - } - - protected class CellRenderer implements ListCellRenderer - { - public Component getListCellRendererComponent( - JList list, Object value, int index, - boolean isSelected, boolean cellHasFocus) - { - JCheckBox checkbox = (JCheckBox) value; - checkbox.setBackground(isSelected ? - getSelectionBackground() : getBackground()); - checkbox.setForeground(isSelected ? - getSelectionForeground() : getForeground()); - checkbox.setEnabled(isEnabled()); - checkbox.setFont(getFont()); - checkbox.setFocusPainted(false); - checkbox.setBorderPainted(true); - checkbox.setBorder(isSelected ? - UIManager.getBorder( - "List.focusCellHighlightBorder") : noFocusBorder); - return checkbox; - } - } - - public interface EventListener - { - public void checkBoxStatusChanged(int index, boolean status); - } - - - private EventListener eventListener; -} \ No newline at end of file diff --git a/src/whitehole/LayerForm.form b/src/whitehole/LayerForm.form deleted file mode 100644 index 54008d1..0000000 --- a/src/whitehole/LayerForm.form +++ /dev/null @@ -1,99 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/src/whitehole/LayerForm.java b/src/whitehole/LayerForm.java deleted file mode 100644 index c209db4..0000000 --- a/src/whitehole/LayerForm.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - © 2012 - 2016 - Whitehole Team - - Whitehole is free software: you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - Whitehole is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with Whitehole. If not, see http://www.gnu.org/licenses/. -*/ - -package whitehole; - -import java.awt.Toolkit; -import java.awt.event.KeyEvent; - -public class LayerForm extends javax.swing.JFrame -{ - - /** - * Creates new form BcsvEditorForm - */ - public LayerForm() - { - initComponents(); - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - txtInput = new javax.swing.JTextField(); - lblInput = new javax.swing.JLabel(); - lblOutput = new javax.swing.JLabel(); - jLabel1 = new javax.swing.JLabel(); - txtOutput = new javax.swing.JTextField(); - - setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); - setResizable(false); - addWindowListener(new java.awt.event.WindowAdapter() { - public void windowClosing(java.awt.event.WindowEvent evt) { - formWindowClosing(evt); - } - public void windowOpened(java.awt.event.WindowEvent evt) { - formWindowOpened(evt); - } - }); - - txtInput.addKeyListener(new java.awt.event.KeyAdapter() { - public void keyReleased(java.awt.event.KeyEvent evt) { - txtInputKeyReleased(evt); - } - }); - - lblInput.setText("Input"); - - lblOutput.setText("Output"); - - jLabel1.setText("Common +"); - - txtOutput.setEditable(false); - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(txtOutput) - .addGroup(layout.createSequentialGroup() - .addGap(0, 11, Short.MAX_VALUE) - .addComponent(jLabel1) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(txtInput, javax.swing.GroupLayout.PREFERRED_SIZE, 209, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(lblInput) - .addComponent(lblOutput)) - .addGap(0, 0, Short.MAX_VALUE))) - .addContainerGap()) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addComponent(lblInput) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(txtInput, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel1)) - .addGap(18, 18, 18) - .addComponent(lblOutput) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(txtOutput, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); - - pack(); - }// //GEN-END:initComponents - - private void formWindowClosing(java.awt.event.WindowEvent evt)//GEN-FIRST:event_formWindowClosing - {//GEN-HEADEREND:event_formWindowClosing - - }//GEN-LAST:event_formWindowClosing - - private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened - this.setTitle("Layer Generator"); - this.setIconImage(Toolkit.getDefaultToolkit().createImage(Whitehole.class.getResource("/Resources/icon.png"))); - }//GEN-LAST:event_formWindowOpened - - private void txtInputKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtInputKeyReleased - if (txtInput.getText().contains("[A-P]")) { - getLayerNo(txtInput.getText()); - } - }//GEN-LAST:event_txtInputKeyReleased - - private void getLayerNo(String field) { - } - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JLabel jLabel1; - private javax.swing.JLabel lblInput; - private javax.swing.JLabel lblOutput; - private javax.swing.JTextField txtInput; - private javax.swing.JTextField txtOutput; - // End of variables declaration//GEN-END:variables -} \ No newline at end of file diff --git a/src/whitehole/Whitehole.java b/src/whitehole/Whitehole.java deleted file mode 100644 index d6f2edd..0000000 --- a/src/whitehole/Whitehole.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - © 2012 - 2016 - Whitehole Team - - Whitehole is free software: you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - Whitehole is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with Whitehole. If not, see http://www.gnu.org/licenses/. -*/ - -package whitehole; - -import java.nio.charset.Charset; -import java.util.prefs.Preferences; -import javax.media.opengl.GLProfile; -import javax.swing.JOptionPane; -import javax.swing.UIManager; -import javax.swing.UnsupportedLookAndFeelException; -import whitehole.rendering.RendererCache; -import whitehole.rendering.ShaderCache; -import whitehole.rendering.TextureCache; -import whitehole.smg.Bcsv; -import whitehole.smg.GameArchive; - -public class Whitehole -{ - - public static final String name = "Whitehole"; - public static final String version = "v1.4.2.3"; - public static final String status = ""; - public static String fullName = name + " " + version + status; - public static final String websiteURL = "http://neomariogalaxy.bplaced.net/"; - public static final String crashReportURL = "http://neomariogalaxy.bplaced.net/?page=thread&id=148"; - - public static GameArchive game; - public static int gameType; - - - public class UncaughtExceptionHandler - { - public void handle(Throwable throwable) - { - System.out.println(throwable.getMessage()); - } - } - - public static void doRun() - { - if (!Charset.isSupported("SJIS")) - { - if (!Preferences.userRoot().getBoolean("charset-alreadyWarned", false)) - { - JOptionPane.showMessageDialog(null, "Shift-JIS encoding isn't supported.\nWhitehole will default to ASCII, which may cause certain strings to look corrupted.\n\nThis message appears only once.", - Whitehole.fullName, JOptionPane.WARNING_MESSAGE); - Preferences.userRoot().putBoolean("charset-alreadyWarned", true); - } - } - - Settings.initialize(); - Bcsv.populateHashTable(); - TextureCache.initialize(); - ShaderCache.initialize(); - RendererCache.initialize(); - ObjectDB.initialize(); - - try - { - if (Settings.theme_system) { - UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); - } - else { - UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); - } - } - catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) - { - } - - GLProfile.initSingleton(); - new MainFrame().setVisible(true); - } - - public static void main(String[] args) - { - doRun(); - } -} diff --git a/src/whitehole/rendering/DoubleBmdRenderer.java b/src/whitehole/rendering/DoubleBmdRenderer.java deleted file mode 100644 index cb90aa9..0000000 --- a/src/whitehole/rendering/DoubleBmdRenderer.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - © 2012 - 2016 - Whitehole Team - - Whitehole is free software: you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - Whitehole is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with Whitehole. If not, see http://www.gnu.org/licenses/. -*/ - -package whitehole.rendering; - -import java.io.IOException; -import javax.media.opengl.GL2; -import javax.media.opengl.GLException; -import whitehole.vectors.Vector3; - -public class DoubleBmdRenderer extends GLRenderer -{ - public DoubleBmdRenderer(RenderInfo info, String model1, Vector3 pos1, String model2, Vector3 pos2) throws IOException - { - rend1 = new BmdRenderer(info, model1); - position1 = pos1; - rend2 = new BmdRenderer(info, model2); - position2 = pos2; - } - - @Override - public void close(RenderInfo info) throws GLException - { - rend1.close(info); - rend2.close(info); - } - - - @Override - public boolean gottaRender(RenderInfo info) throws GLException - { - return rend1.gottaRender(info) || rend2.gottaRender(info); - } - - @Override - public void render(RenderInfo info) throws GLException - { - GL2 gl = info.drawable.getGL().getGL2(); - - if (rend1.gottaRender(info)) - { - gl.glTranslatef(position1.x, position1.y, position1.z); - rend1.render(info); - } - if (rend2.gottaRender(info)) - { - gl.glTranslatef(position2.x, position2.y, position2.z); - rend2.render(info); - } - } - - - private BmdRenderer rend1, rend2; - private Vector3 position1, position2; -} diff --git a/src/whitehole/rendering/Helper.java b/src/whitehole/rendering/Helper.java deleted file mode 100644 index c4bc93e..0000000 --- a/src/whitehole/rendering/Helper.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - © 2012 - 2016 - Whitehole Team - - Whitehole is free software: you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - Whitehole is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with Whitehole. If not, see http://www.gnu.org/licenses/. -*/ - -package whitehole.rendering; - -import whitehole.vectors.*; - -public class Helper -{ - public static Matrix4 SRTToMatrix(Vector3 scale, Vector3 rot, Vector3 trans) - { - Matrix4 ret = new Matrix4(); - - Matrix4 mscale = Matrix4.scale(scale); - Matrix4 mxrot = Matrix4.createRotationX(rot.x); - Matrix4 myrot = Matrix4.createRotationY(rot.y); - Matrix4 mzrot = Matrix4.createRotationZ(rot.z); - Matrix4 mtrans = Matrix4.createTranslation(trans); - - Matrix4.mult(ret, mscale, ret); - Matrix4.mult(ret, mxrot, ret); - Matrix4.mult(ret, myrot, ret); - Matrix4.mult(ret, mzrot, ret); - Matrix4.mult(ret, mtrans, ret); - - return ret; - } -} diff --git a/src/whitehole/rendering/SingleBmdRenderer.java b/src/whitehole/rendering/SingleBmdRenderer.java deleted file mode 100644 index bcd8598..0000000 --- a/src/whitehole/rendering/SingleBmdRenderer.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - © 2012 - 2016 - Whitehole Team - - Whitehole is free software: you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - Whitehole is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with Whitehole. If not, see http://www.gnu.org/licenses/. -*/ - -package whitehole.rendering; - -import java.io.IOException; -import javax.media.opengl.GL2; -import javax.media.opengl.GLException; -import whitehole.vectors.Vector3; - -public class SingleBmdRenderer extends GLRenderer { - - public SingleBmdRenderer(RenderInfo info, String model, Vector3 pos) throws IOException { - rend = new BmdRenderer(info, model); - position = pos; - } - - @Override - public void close(RenderInfo info) throws GLException { - rend.close(info); - } - - @Override - public boolean gottaRender(RenderInfo info) throws GLException { - return rend.gottaRender(info); - } - - @Override - public void render(RenderInfo info) throws GLException { - GL2 gl = info.drawable.getGL().getGL2(); - - if (rend.gottaRender(info)) { - gl.glTranslatef(position.x, position.y, position.z); - rend.render(info); - } - } - - private BmdRenderer rend; - private Vector3 position; -} \ No newline at end of file diff --git a/src/whitehole/rendering/Substitutor.java b/src/whitehole/rendering/Substitutor.java deleted file mode 100644 index 52d0058..0000000 --- a/src/whitehole/rendering/Substitutor.java +++ /dev/null @@ -1,371 +0,0 @@ -/* - © 2012 - 2016 - Whitehole Team - - Whitehole is free software: you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - Whitehole is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with Whitehole. If not, see http://www.gnu.org/licenses/. -*/ - -package whitehole.rendering; - -import whitehole.rendering.object.ObjectKinopio; -import whitehole.rendering.object.ObjectAstroPart; -import whitehole.rendering.object.ObjectPole; -import whitehole.rendering.object.ObjectUFOKinoko; -import whitehole.rendering.object.ObjectSuperSpinDriver; -import whitehole.rendering.object.ObjectAstroSky; -import whitehole.rendering.object.ObjectPowerStar; -import whitehole.rendering.object.ObjectOtaKing; -import whitehole.smg.LevelObject; -import whitehole.smg.object.PlanetObj; -import whitehole.smg.object.AreaObj; -import whitehole.smg.object.CameraCubeObj; -import whitehole.smg.object.ChangeObj; -import whitehole.smg.object.ChildObj; -import whitehole.smg.object.DemoObj; -import whitehole.smg.object.DebugObj; -import whitehole.smg.object.SoundObj; -import whitehole.smg.object.GeneralPosObj; -import whitehole.smg.object.StageObj; -import whitehole.vectors.Color4; -import whitehole.vectors.Vector3; -import java.io.IOException; -import static whitehole.Settings.editor_areas; -import whitehole.smg.ZoneArchive; - -public class Substitutor { - - public static String substituteModelName(LevelObject obj, String modelname) { - switch (obj.name) { - case "ArrowSwitchMulti": return "ArrowSwitch"; - case "AstroDomeBlueStar": return "GCaptureTarget"; - case "AttackRockFinal": - case "AttackRockTutorial": return "AttackRock"; - case "BenefitItemInvincible": return "PowerUpInvincible"; - case "BenefitItemLifeUp": return "KinokoLifeUp"; - case "BenefitItemOneUp": return "KinokoOneUp"; - case "BigBubbleGenerator": - case "BigObstructBubbleGenerator": return "AirBubbleGenerator"; - case "Bomb": return "BombHei"; - case "BombLauncher": return "BombHeiLauncher"; - case "BossKameck2": return "BossKameck"; - case "BreakableCageRotate": return "BreakableCage"; - case "ButlerExplain": - case "ButlerMap": return "Butler"; - case "CoinReplica": return "Coin"; - case "Creeper": return "CreeperFlower"; - case "CutBushGroup": return "CutBush"; - case "DemoKoopaJrShip": return "KoopaJrShip"; - case "DharmaSambo": return "DharmaSamboParts"; - case "FireBallBeamKameck": return "Kameck"; - case "FirePressureRadiate": return "FirePressure"; - case "FishGroupA": return "FishA"; - case "FishGroupB": return "FishB"; - case "FishGroupC": return "FishC"; - case "FishGroupD": return "FishD"; - case "FishGroupE": return "FishE"; - case "FishGroupF": return "FishF"; - case "FlowerBlueGroup": return "FlowerBlue"; - case "FlowerGroup": return "Flower"; - case "GhostPlayer": return "GhostMario"; - case "GliBirdNpc": return "GliBird"; - case "GoldenTurtle": return "KouraShine"; - case "Hanachan": return "HanachanHead"; - case "HanachanBig": return "HanachanHeadBig"; - case "DrillBullet": return "Horino"; - case "InstantInferno": return "InfernoMario"; - case "ItemBlockSwitch": return "CoinBlock"; - case "JetTurtle": return "Koura"; - case "KameckKuriboMini": - case "KameckMeramera": return "Kameck"; - case "Karikari": return "Karipon"; - case "KirairaRail": return "Kiraira"; - case "KoopaBattleMapCoinPlate": return "KoopaPlateCoin"; - case "KoopaBattleMapPlate": return "KoopaPlate"; - case "KoopaBattleMapStairturnAppear": return "KoopaBattleMapStairTurn"; - case "KoopaNpc": return "Koopa"; - case "KoopaStatueVomit": return "KoopaStatue"; - case "KoopaLv2": - case "KoopaLv3": - case "KoopaLv4": return "Koopa"; - case "LavaProminenceWithoutShadow": return "LavaProminence"; - case "SpinLeverSwitchForceAnim": return "SpinLeverSwitch"; - case "LuigiTalkNpc": - case "LuigiIntrusively": return "LuigiNpc"; - case "MagicBell": return "Bell"; - case "MameMuimuiAttackMan": return "ScoreAttackMan"; - case "MeteorCannon": - case "MeteorStrikeEnvironment": return "MeteorStrike"; - case "MiniKoopaBattleVs1Galaxy": - case "MiniKoopaBattleVs2Galaxy": - case "MiniKoopaBattleVs3Galaxy": return "MiniKoopaGalaxy"; - case "MorphItemCollectionBee": return "PowerUpBee"; - case "MorphItemCollectionCloud": return "PowerUpCloud"; - case "MorphItemCollectionDrill": return "ItemDrill"; - case "MorphItemCollectionFire": return "PowerUpFire"; - case "MorphItemCollectionHopper": return "PowerUpHopper"; - case "MorphItemCollectionTeresa": return "PowerUpTeresa"; - case "MorphItemCollectionRock": return "PowerUpRock"; - case "MorphItemNeoBee": return "PowerUpBee"; - case "MorphItemNeoFire": return "PowerUpFire"; - case "MorphItemNeoFoo": return "PowerUpFoo"; - case "MorphItemNeoHopper": return "PowerUpHopper"; - case "MorphItemNeoIce": return "PowerUpIce"; - case "MorphItemNeoTeresa": return "PowerUpTeresa"; - case "MorphItemRock": return "PowerUpRock"; - case "NoteFairy": return "Note"; - case "OnimasuPivot": return "Onimasu"; - case "PenguinSkater": - case "PenguinStudent": return "Penguin"; - case "Plant": return "PlantSeed"; - case "PlayAttackMan": return "ScoreAttackMan"; - case "PrologueDirector": return "DemoLetter"; - case "PukupukuWaterSurface": return "Pukupuku"; - case "Rabbit": return "MoonRabbit"; - case "RockCreator": return "Rock"; - case "RunawayRabbitCollect": return "TrickRabbit"; - case "SeaGullGroup": - case "SeaGullGroupMarioFace": return "SeaGull"; - case "ShellfishBlueChip": - case "ShellfishCoin": - case "ShellfishKinokoOneUp": - case "ShellfishYellowChip": return "Shellfish"; - case "SignBoardTamakoro": return "SignBoard"; - case "SkeletalFishBaby": return "SnakeFish"; - case "SpiderAttachPoint": return "SpiderThreadAttachPoint"; - case "SpiderCoin": return "Coin"; - case "SpinCloudItem": - case "SpinCloudMarioItem": return "PowerUpCloud"; - case "SplashCoinBlock": - case "SplashPieceBlock": return "CoinBlock"; - case "SuperDreamer": return "HelperWitch"; - case "SuperSpinDriverGreen": - case "SuperSpinDriverPink": return "SuperSpinDriver"; - case "SurpBeltConveyerExGalaxy": - case "SurpCocoonExGalaxy": - case "SurpCubeBubbleExLv2Galaxy": - case "SurpFishTunnelGalaxy": - case "SurpPeachCastleFinalGalaxy": - case "SurpSnowCapsuleGalaxy": - case "SurpSurfingLv2Galaxy": - case "SurpTamakoroExLv2Galaxy": - case "SurpTearDropGalaxy": - case "SurpTeresaMario2DGalaxy": - case "SurpTransformationExGalaxy": return "MiniSurprisedGalaxy"; - case "TalkSyati": return "Syati"; - case "TamakoroWithTutorial": return "Tamakoro"; - case "Teresa": - case "TeresaChief": return "TeresaWater"; - case "TicoAstro": - case "TicoDomeLecture": return "Tico"; - case "TicoFatCoin": - case "TicoFatStarPiece": - case "TicoGalaxy": return "TicoFat"; - case "TicoRail": - case "TicoReading": - case "TicoStarRing": return "Tico"; - case "TimerCoinBlock": - case "TimerPieceBlock": return "CoinBlock"; - case "TogepinAttackMan": return "ScoreAttackMan"; - case "Tongari2D": return "Tongari"; - case "TreasureBoxBlueChip": - case "TreasureBoxCoin": return "TreasureBox"; - case "TreasureBoxCrackedAirBubble": - case "TreasureBoxCrackedBlueChip": - case "TreasureBoxCrackedCoin": - case "TreasureBoxCrackedEmpty": - case "TreasureBoxCrackedKinokoLifeUp": - case "TreasureBoxCrackedKinokoOneUp": - case "TreasureBoxCrackedPowerStar": - case "TreasureBoxCrackedYellowChip": return "TreasureBoxCracked"; - case "TreasureBoxEmpty": return "TreasureBox"; - case "TreasureBoxGoldEmpty": return "TreasureBoxGold"; - case "TreasureBoxKinokoLifeUp": - case "TreasureBoxKinokoOneUp": - case "TreasureBoxYellowChip": return "TreasureBox"; - case "TrickRabbitFreeRun": - case "TrickRabbitFreeRunCollect": - case "TrickRabbitGhost": return "TrickRabbit"; - case "TripodBossCoin": return "Coin"; - case "TripodBossBottomKillerCannon": - case "TripodBossKillerGenerator": return "TripodBossKillerCannon"; - case "TripodBossKinokoOneUp": return "KinokoOneUp"; - case "TripodBossUnderKillerCannon": - case "TripodBossUpperKillerCannon": return "TripodBossKillerCannon"; - case "TubeSliderDamageObj": return "NeedlePlant"; - case "TubeSliderEnemy": return "Togezo"; - case "TubeSliderHana": return "HanachanHeadBig"; - case "TurtleBeamKameck": return "Kameck"; - case "TwoLegsBullet": return "Horino"; - case "WingBlockCoin": - case "WingBlockStarPiece": return "WingBlock"; - case "YoshiCapture": return "YCaptureTarget"; - } - return modelname; - } - - public static String substituteObjectKey(LevelObject obj, String objectkey) { - switch (obj.name) { - case "PlantA": - case "PlantB": - case "PlantC": - case "PlantD": objectkey += String.format("_%1$d_%2$d", obj.data.get("ShapeModelNo"), obj.data.get("Obj_arg3")); break; - case "MarinePlant": objectkey += String.format("_%1$d_%2$d", obj.data.get("ShapeModelNo"), obj.data.get("Obj_arg1")); break; - case "Pole": - case "PoleSquare": - case "Pole2Way": objectkey += String.format("_%1$3f", obj.scale.y / obj.scale.x); break; - case "Kinopio": - case "KinopioAstro": objectkey += String.format("_%1$d", obj.data.get("Obj_arg1")); break; - case "UFOKinoko": objectkey += String.format("_%1$d", obj.data.get("Obj_arg0")); break; - case "OtaKing": objectkey += String.format("_%1$d", obj.data.get("Obj_arg1")); break; - case "AstroDome": - case "AstroDomeEntrance": - case "AstroDomeSky": - case "AstroStarPlate": objectkey += String.format("_%1$d", obj.data.get("Obj_arg0")); break; - } - - if (ZoneArchive.gameMask == 2) { - if (obj.getClass() == AreaObj.class || obj.getClass() == CameraCubeObj.class) - objectkey += String.format("_%1$d", obj.data.get("AreaShapeNo")); - } - - return objectkey; - } - - public static GLRenderer substituteRenderer(LevelObject obj, GLRenderer.RenderInfo info) { - short shapeno = 0; - - try { - if (obj.getClass() == AreaObj.class || obj.getClass() == CameraCubeObj.class) { - if (editor_areas) { - if (ZoneArchive.gameMask == 2) { - shapeno = (short)obj.data.get("AreaShapeNo"); - } - else { - if (obj.name.endsWith("Cube") || obj.name.endsWith("Box")) { - shapeno = 0; - } - else if (obj.name.endsWith("Sphere")) - shapeno = 2; - else if (obj.name.endsWith("Cylinder")) - shapeno = 3; - else - shapeno = 4; - } - if (obj.getClass() == AreaObj.class) - return new AreaShapeRenderer (new Color4(0.3f, 1f, 1f), shapeno); - if (obj.getClass() == CameraCubeObj.class) - return new AreaShapeRenderer (new Color4(0.8f, 0f, 0f), shapeno); - } - else { - if (obj.getClass() == AreaObj.class) - return new ColorCubeRenderer (100f, new Color4(1f, 0.5f, 0.5f), new Color4(0.3f, 1f, 1f), true); - if (obj.getClass() == CameraCubeObj.class) - return new ColorCubeRenderer (100f, new Color4(0.3f, 0f, 1f), new Color4(0.8f, 0f, 0f), true); - } - } - if (obj.getClass() == ChildObj.class) - return new ColorCubeRenderer (100f, new Color4(1f, 1f, 1f), new Color4(1f, 0.5f, 0.5f), true); - if (obj.getClass() == PlanetObj.class) - return new ColorCubeRenderer(100f, new Color4(1f, 0.5f, 0.5f), new Color4(0.8f, 0f, 0f), true); - if (obj.getClass() == DemoObj.class) - return new ColorCubeRenderer (100f, new Color4(1f, 0.5f, 0.5f), new Color4(1.0f, 1.0f, 0.3f), true); - if (obj.getClass() == GeneralPosObj.class) - return new ColorCubeRenderer (100f, new Color4(1f, 1f, 1f), new Color4(1f,0.5f,0f), true); - if (obj.getClass() == SoundObj.class) - return new ColorCubeRenderer (100f, new Color4(1f, 1f, 1f), new Color4(1f, 0.5f, 1f), true); - if (obj.getClass() == ChangeObj.class) - return new ColorCubeRenderer (100f, new Color4(1f, 1f, 1f), new Color4(0f,0.8f,0f), true); - if (obj.getClass() == DebugObj.class) - return new ColorCubeRenderer (100f, new Color4(1f, 1f, 1f), new Color4(0.8f, 0.5f, 0.1f), true); - if (obj.getClass() == StageObj.class) - return new ColorCubeRenderer (100f, new Color4(0.3f, 0f, 1f), new Color4(1f, 0.5f, 0f), true); - - switch (obj.name) { - case "PowerStar": return new ObjectPowerStar(info, 0); - case "GreenStar": return new ObjectPowerStar(info, 1); - case "SuperSpinDriverPink": return new ObjectSuperSpinDriver(info,0); - case "SuperSpinDriverGreen": return new ObjectSuperSpinDriver(info,1); - case "MameMuimuiScorer": return new TripleBmdRenderer(info, "MameMuimuiGreen", new Vector3(0f,50f,100f), "MameMuimuiSpike", new Vector3(100f,-50f,-200), "MameMuimuiYellow", new Vector3(-200,0f,0)); - case "MameMuimuiScorerLv2": return new TripleBmdRenderer(info, "MameMuimuiGreen", new Vector3(0f,50f,100f), "MameMuimuiYellow", new Vector3(100f,-50f,-200), "MameMuimuiSpike", new Vector3(-200,0f,0)); - - case "Kinopio": - case "KinopioAstro": return new ObjectKinopio(info, (int)obj.data.get("Obj_arg1")); - case "KinopioBank": return new ObjectKinopio(info, 1); - case "KinopioPostman": return new ObjectKinopio(info, 2); - case "UFOKinoko": return new ObjectUFOKinoko(info, (int)obj.data.get("Obj_arg0")); - case "PenguinRacer": return new DoubleBmdRenderer(info, "Penguin", new Vector3(), "PenguinGoodsSwimCap", new Vector3(0f,100f,0f)); - case "PenguinRacerLeader": return new TripleBmdRenderer(info, "Penguin", new Vector3(), "PenguinGoodsSwimCap", new Vector3(0f,100f,0f), "PenguinGoodsLeader", new Vector3()); - - case "PlantA": - case "PlantB": - case "PlantC": - case "PlantD": return new ShapeModelRenderer(info, obj.name, (short)obj.data.get("ShapeModelNo")); - case "MarinePlant": return new ShapeModelRenderer(info, obj.name, (short)obj.data.get("ShapeModelNo")); - - case "EarthenPipe": - case "EarthenPipeInWater": return new SingleBmdRenderer(info, "EarthenPipe", new Vector3(0f,100f,0f)); - case "Pole": return new ObjectPole(info, obj.scale, "Pole"); - case "PoleSquare": - case "Pole2Way": return new ObjectPole(info, obj.scale, "PoleSquare"); - case "RedBlueTurnBlock": return new DoubleBmdRenderer(info, "RedBlueTurnBlock", new Vector3(), "RedBlueTurnBlockBase", new Vector3()); - case "KoopaJrCastleWindUp": return new DoubleBmdRenderer(info, "Fan", new Vector3(), "FanWind", new Vector3()); - - case "Flag": return new BtiRenderer(info, "Flag", new Vector3(0f,150f,0f), new Vector3(0f,-150f,600f), true); - case "FlagRaceA": return new BtiRenderer(info, "FlagRaceA", new Vector3(0f,75f,0f), new Vector3(0f,-75f,300f), true); - case "FlagSurfing": return new BtiRenderer(info, "FlagSurfing", new Vector3(0f,150f,0f), new Vector3(0f,-150f,600f), true); - case "FlagTamakoro": return new BtiRenderer(info, "FlagTamakoro", new Vector3(0f,150f,0f), new Vector3(0f,-150f,600f), true); - case "FlagPeachCastleA": return new BtiRenderer(info, "FlagPeachCastleA", new Vector3(0f,150f,0f), new Vector3(0f,-150f,600f), true); - case "FlagPeachCastleB": return new BtiRenderer(info, "FlagPeachCastleB", new Vector3(0f,150f,0f), new Vector3(0f,-150f,600f), true); - case "FlagPeachCastleC": return new BtiRenderer(info, "FlagPeachCastleC", new Vector3(0f,150f,0f), new Vector3(0f,-150f,600f), true); - case "FlagKoopaA": return new BtiRenderer(info, "FlagKoopaA", new Vector3(0f,150f,0f), new Vector3(0f,-150f,600f), true); - case "FlagKoopaB": return new BtiRenderer(info, "FlagKoopaB", new Vector3(0f,75f,0f), new Vector3(0f,-75f,600f), true); - case "FlagKoopaCastle": return new BtiRenderer(info, "FlagKoopaCastle", new Vector3(0f,150f,0f), new Vector3(0f,-150f,600f), true); - - case "AstroStarPlate": - case "AstroDome": - case "AstroDomeEntrance": return new ObjectAstroPart(info, obj.name, (int)obj.data.get("Obj_arg0")); - case "AstroDomeSky": return new ObjectAstroSky(info, obj.name, (int)obj.data.get("Obj_arg0")); - - case "Patakuri": return new DoubleBmdRenderer(info, "Kuribo", new Vector3(), "PatakuriWing", new Vector3(0f,15f,-25f)); - case "HammerHeadPackun": return new DoubleBmdRenderer(info, "PackunFlower", new Vector3(), "PackunLeaf", new Vector3()); - case "HammerHeadPackunSpike": return new DoubleBmdRenderer(info, "PackunFlowerSpike", new Vector3(), "PackunLeafSpike", new Vector3()); - case "CocoSambo": return new DoubleBmdRenderer(info, "CocoSamboBody", new Vector3(), "CocoSamboHead", new Vector3(0f,325f,0f)); - case "Kiraira": return new TripleBmdRenderer(info, "Kiraira", new Vector3(0f,50f,0f), "KirairaChain", new Vector3(0f, -160f, 0f), "KirairaFixPointBottom", new Vector3(0f,-15f,0f)); - case "Torpedo": return new DoubleBmdRenderer(info, "Torpedo", new Vector3(), "TorpedoPropeller", new Vector3()); - case "BegomanSpike": return new DoubleBmdRenderer(info, "BegomanSpike", new Vector3(), "BegomanSpikeHead", new Vector3()); - case "BegomanSpring": - case "BegomanSpringHide": return new DoubleBmdRenderer(info, "BegomanSpring", new Vector3(), "BegomanSpringHead", new Vector3()); - case "JumpBeamer": return new DoubleBmdRenderer(info, "JumpBeamerBody", new Vector3(), "JumpBeamerHead", new Vector3(0f,-25f,0f)); - case "JumpGuarder": return new DoubleBmdRenderer(info, "JumpGuarder", new Vector3(), "JumpGuarderHead", new Vector3()); - case "GliderBazooka": - case "GliderShooter": return new DoubleBmdRenderer(info, "MogucchiSpike", new Vector3(), "GliderBazooka", new Vector3()); - case "KillerShooter": return new DoubleBmdRenderer(info, "MogucchiSpike", new Vector3(), "GliderBazooka", new Vector3()); - case "WaterBazooka": return new TripleBmdRenderer(info, "WaterBazooka", new Vector3(), "WaterBazookaCapsule", new Vector3(0f, 475f, 0f), "MogucchiShooter", new Vector3(0f,-160f,0f)); - case "ElectricBazooka": return new TripleBmdRenderer(info, "ElectricBazooka", new Vector3(), "WaterBazookaCapsule", new Vector3(0f, 475f, 0f), "MogucchiShooter", new Vector3(0f,-160f,0f)); - case "DinoPackun": - case "DinoPackunVs1": return new DoubleBmdRenderer(info, "DinoPackun", new Vector3(), "DinoPackunTailBall", new Vector3(0f,150f,-750f)); - case "DinoPackunVs2": return new DoubleBmdRenderer(info, "DinoPackun2", new Vector3(), "DinoPackunTailBall", new Vector3(0f,150f,-750f)); - case "BossBegoman": return new DoubleBmdRenderer(info, "BossBegoman", new Vector3(), "BossBegomanHead", new Vector3()); - case "BossJugem": return new DoubleBmdRenderer(info, "BossJugem", new Vector3(), "BossJugemCloud", new Vector3()); - case "KoopaJrRobot": return new DoubleBmdRenderer(info, "KoopaJrRobot", new Vector3(), "KoopaJrRobotPod", new Vector3(0f,1000f,0f)); - case "KoopaJrCastle": return new TripleBmdRenderer(info, "KoopaJrCastleBody", new Vector3(), "KoopaJrCastleHead", new Vector3(0f,2750f,0f), "KoopaJrCastleCapsule", new Vector3(0f,700f,0f)); - case "OtaKing": return new ObjectOtaKing(info, obj.name, (int)obj.data.get("Obj_arg1")); - case "OtaRockTank": return new DoubleBmdRenderer(info, "OtaRockTank", new Vector3(), "OtaRockChief", new Vector3(0f, 500f, 0f)); - case "TombSpider": return new TripleBmdRenderer(info, "TombSpider", new Vector3(), "TombSpiderPlanet", new Vector3(), "TombSpiderCocoon", new Vector3()); - case "SkeletalFishBoss": return new DoubleBmdRenderer(info, "SkeletalFishBoss", new Vector3(), "SkeletalFishBossHeadA", new Vector3()); - } - } - catch (IOException ex) { - } - - return null; - } -} \ No newline at end of file diff --git a/src/whitehole/rendering/TripleBmdRenderer.java b/src/whitehole/rendering/TripleBmdRenderer.java deleted file mode 100644 index 3a28419..0000000 --- a/src/whitehole/rendering/TripleBmdRenderer.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - © 2012 - 2016 - Whitehole Team - - Whitehole is free software: you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - Whitehole is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with Whitehole. If not, see http://www.gnu.org/licenses/. -*/ - -package whitehole.rendering; - -import java.io.IOException; -import javax.media.opengl.GL2; -import javax.media.opengl.GLException; -import whitehole.vectors.Vector3; - -public class TripleBmdRenderer extends GLRenderer -{ - public TripleBmdRenderer(RenderInfo info, String model1, Vector3 pos1, String model2, Vector3 pos2, String model3, Vector3 pos3) throws IOException - { - rend1 = new BmdRenderer(info, model1); - position1 = pos1; - rend2 = new BmdRenderer(info, model2); - position2 = pos2; - rend3 = new BmdRenderer(info, model3); - position3 = pos3; - } - - @Override - public void close(RenderInfo info) throws GLException - { - rend1.close(info); - rend2.close(info); - rend3.close(info); - } - - - @Override - public boolean gottaRender(RenderInfo info) throws GLException - { - return rend1.gottaRender(info) || rend2.gottaRender(info) || rend3.gottaRender(info); - } - - @Override - public void render(RenderInfo info) throws GLException - { - GL2 gl = info.drawable.getGL().getGL2(); - - if (rend1.gottaRender(info)) - { - gl.glTranslatef(position1.x, position1.y, position1.z); - rend1.render(info); - } - if (rend2.gottaRender(info)) - { - gl.glTranslatef(position2.x, position2.y, position2.z); - rend2.render(info); - } - if (rend3.gottaRender(info)) - { - gl.glTranslatef(position3.x, position3.y, position3.z); - rend3.render(info); - } - } - - - private BmdRenderer rend1, rend2, rend3; - private Vector3 position1, position2, position3; -} diff --git a/src/whitehole/rendering/object/ObjectOtaKing.java b/src/whitehole/rendering/object/ObjectOtaKing.java deleted file mode 100644 index 413211e..0000000 --- a/src/whitehole/rendering/object/ObjectOtaKing.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - © 2012 - 2016 - Whitehole Team - - Whitehole is free software: you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - Whitehole is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with Whitehole. If not, see http://www.gnu.org/licenses/. -*/ - -package whitehole.rendering.object; - -import whitehole.rendering.BmdRenderer; - -public class ObjectOtaKing extends BmdRenderer { - - public ObjectOtaKing(RenderInfo info, String objname, int arg1) { - if (arg1 == 0) { - ctor_loadModel(info, objname + "Lv2"); - } - else { - ctor_loadModel(info, objname); - } - ctor_uploadData(info); - } - - @Override - public boolean boundToObjArg(int arg) { - if (arg == 1) return true; - return false; - } -} diff --git a/src/whitehole/rendering/object/ObjectPowerStar.java b/src/whitehole/rendering/object/ObjectPowerStar.java deleted file mode 100644 index 206c0a0..0000000 --- a/src/whitehole/rendering/object/ObjectPowerStar.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - © 2012 - 2016 - Whitehole Team - - Whitehole is free software: you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - Whitehole is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with Whitehole. If not, see http://www.gnu.org/licenses/. -*/ - -package whitehole.rendering.object; - -import whitehole.rendering.BmdRenderer; - -public class ObjectPowerStar extends BmdRenderer -{ - public ObjectPowerStar(RenderInfo info, int type) - { - ctor_loadModel(info, "PowerStar"); - - switch (type) - { - case 0: // yellow - model.materials[0].colorS10[0].r = 211; - model.materials[0].colorS10[0].g = 211; - model.materials[0].colorS10[0].b = -103; - break; - case 1: // green - model.materials[0].colorS10[0].r = -113; - model.materials[0].colorS10[0].g = 211; - model.materials[0].colorS10[0].b = -113; - break; - } - ctor_uploadData(info); - } -} diff --git a/src/whitehole/rendering/object/ObjectSuperSpinDriver.java b/src/whitehole/rendering/object/ObjectSuperSpinDriver.java deleted file mode 100644 index 8114499..0000000 --- a/src/whitehole/rendering/object/ObjectSuperSpinDriver.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - © 2012 - 2016 - Whitehole Team - - Whitehole is free software: you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - Whitehole is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with Whitehole. If not, see http://www.gnu.org/licenses/. -*/ - -package whitehole.rendering.object; - -import whitehole.rendering.BmdRenderer; - -public class ObjectSuperSpinDriver extends BmdRenderer -{ - public ObjectSuperSpinDriver(RenderInfo info, int type) - { - ctor_loadModel(info, "SuperSpinDriver"); - - switch (type) - { - case 0: // blue - model.materials[0].colorS10[0].r = 211; - model.materials[0].colorS10[0].g = -103; - model.materials[0].colorS10[0].b = 211; - model.materials[1].colorS10[0].r = 211; - model.materials[1].colorS10[0].g = -103; - model.materials[1].colorS10[0].b = 211; - break; - - case 1: // green - model.materials[0].colorS10[0].r = -103; - model.materials[0].colorS10[0].g = 211; - model.materials[0].colorS10[0].b = -103; - model.materials[1].colorS10[0].r = -103; - model.materials[1].colorS10[0].g = 211; - model.materials[1].colorS10[0].b = -103; - break; - } - - ctor_uploadData(info); - } - - @Override - public boolean boundToObjArg(int arg) - { - if (arg == 1) return true; - return false; - } -} diff --git a/src/whitehole/smg/Bti.java b/src/whitehole/smg/Bti.java deleted file mode 100644 index 331f388..0000000 --- a/src/whitehole/smg/Bti.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - © 2012 - 2016 - Whitehole Team - - Whitehole is free software: you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - Whitehole is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with Whitehole. If not, see http://www.gnu.org/licenses/. -*/ - -package whitehole.smg; - -import java.io.IOException; -import whitehole.fileio.FileBase; - -public class Bti -{ - public Bti(FileBase _file) throws IOException - { - file = _file; - file.setBigEndian(true); - - readTexture(); - } - - public void save() throws IOException - { - file.save(); - } - - public void close() throws IOException - { - file.close(); - } - - - private void readTexture() throws IOException - { - format = file.readByte(); - file.skip(1); - width = file.readShort(); - height = file.readShort(); - - wrapS = file.readByte(); - wrapT = file.readByte(); - - file.skip(1); - - paletteFormat = file.readByte(); - short palnumentries = file.readShort(); - int paloffset = file.readInt(); - - file.skip(4); - - minFilter = file.readByte(); - magFilter = file.readByte(); - - file.skip(2); - - mipmapCount = file.readByte(); - - file.skip(3); - - int dataoffset = file.readInt(); - image = DataHelper.decodeTextureData(file, dataoffset, - mipmapCount, format, width, height); - } - - - private FileBase file; - - public byte format; - public short width, height; - public byte wrapS, wrapT; - public byte paletteFormat; - public byte minFilter, magFilter; - public byte mipmapCount; - public byte[][] image; -} diff --git a/src/whitehole/smg/Bva.java b/src/whitehole/smg/Bva.java deleted file mode 100644 index 87c241c..0000000 --- a/src/whitehole/smg/Bva.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - © 2012 - 2016 - Whitehole Team - - Whitehole is free software: you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - Whitehole is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with Whitehole. If not, see http://www.gnu.org/licenses/. -*/ - -package whitehole.smg; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import whitehole.fileio.FileBase; - -public class Bva -{ - public Bva(FileBase file) throws IOException - { - this.file = file; - this.file.setBigEndian(true); - - readData(); - } - - public void save() throws IOException - { - file.save(); - } - - public void close() throws IOException - { - file.close(); - } - - - private void readData() throws IOException - { - file.position(0x2C); - short nbatches = file.readShort(); - file.skip(2); - - int sec1offset = 0x20 + file.readInt(); - int sec2offset = 0x20 + file.readInt(); - - animData = new ArrayList<>(nbatches); - - for (int b = 0; b < nbatches; b++) - { - file.position(sec1offset + (b * 4)); - short bsize = file.readShort(); - short bstart = file.readShort(); - - List thislist = new ArrayList<>(bsize); - animData.add(thislist); - - file.position(sec2offset + bstart); - for (int i = 0; i < bsize; i++) - { - byte val = file.readByte(); - thislist.add(val == 0x01); - } - } - } - - - private FileBase file; - - public List> animData; -} diff --git a/src/whitehole/smg/object/GeneralPosObj.java b/src/whitehole/smg/object/GeneralPosObj.java deleted file mode 100644 index 2554d51..0000000 --- a/src/whitehole/smg/object/GeneralPosObj.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - © 2012 - 2016 - Whitehole Team - - Whitehole is free software: you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - Whitehole is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with Whitehole. If not, see http://www.gnu.org/licenses/. -*/ - -package whitehole.smg.object; - -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.List; -import whitehole.PropertyGrid; -import whitehole.Whitehole; -import whitehole.smg.Bcsv; -import whitehole.smg.LevelObject; -import whitehole.smg.ZoneArchive; -import whitehole.vectors.Vector3; - -public class GeneralPosObj extends LevelObject { - - public GeneralPosObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) { - this.zone = zone; - String[] stuff = filepath.split("/"); - directory = stuff[0]; - layer = stuff[1].toLowerCase(); - file = stuff[2]; - - data = entry; - - name = (String)data.get("name"); - loadDBInfo(); - renderer = null; - - uniqueID = -1; - - position = new Vector3((float)data.get("pos_x"), (float)data.get("pos_y"), (float)data.get("pos_z")); - rotation = new Vector3((float)data.get("dir_x"), (float)data.get("dir_y"), (float)data.get("dir_z")); - scale = new Vector3(1,1,1); - } - - public GeneralPosObj(ZoneArchive zone, String filepath, int game, Vector3 pos) { - this.zone = zone; - String[] stuff = filepath.split("/"); - directory = stuff[0]; - layer = stuff[1].toLowerCase(); - file = stuff[2]; - - data = new Bcsv.Entry(); - - name = "GeneralPos"; - loadDBInfo(); - renderer = null; - - uniqueID = -1; - - position = pos; - rotation = new Vector3(0f, 0f, 0f); - scale = new Vector3(1f, 1f, 1f); - - data.put("name", name); - data.put("pos_x", position.x); data.put("pos_y", position.y); data.put("pos_z", position.z); - data.put("dir_x", rotation.x); data.put("dir_y", rotation.y); data.put("dir_z", rotation.z); - data.put("PosName", "null"); - data.put("Obj_ID", (short)-1); - if (ZoneArchive.gameMask == 1) - data.put("ChildObjId", (short)-1); - } - - public void generalPosNames() { - choicesGeneralPosNames = new ArrayList(); - try { - BufferedReader reader = new BufferedReader(new InputStreamReader(Whitehole.class.getResourceAsStream("/Resources/GeneralPos.txt"))); - String line; - while ((line = reader.readLine()) != null) { - line = line.trim(); - - choicesGeneralPosNames.add(line); - } - } - catch (Exception ex) { - System.out.println(ex); - } - } - - @Override - public void save() { - data.put("name", name); - data.put("pos_x", position.x); data.put("pos_y", position.y); data.put("pos_z", position.z); - data.put("dir_x", rotation.x); data.put("dir_y", rotation.y); data.put("dir_z", rotation.z); - } - - @Override - public void getProperties(PropertyGrid panel) { - generalPosNames(); - panel.addCategory("obj_position", "Position"); - panel.addField("pos_x", "X position", "float", null, position.x, "Default"); - panel.addField("pos_y", "Y position", "float", null, position.y, "Default"); - panel.addField("pos_z", "Z position", "float", null, position.z, "Default"); - panel.addField("dir_x", "X rotation", "float", null, rotation.x, "Default"); - panel.addField("dir_y", "Y rotation", "float", null, rotation.y, "Default"); - panel.addField("dir_z", "Z rotation", "float", null, rotation.z, "Default"); - - panel.addCategory("obj_objinfo", "Other"); - panel.addField("PosName", "PosName", "textlist", choicesGeneralPosNames, data.get("PosName"), "Default"); - panel.addField("Obj_ID", "Obj_ID", "int", null, data.get("Obj_ID"), "Default"); - if (ZoneArchive.gameMask == 1) - panel.addField("ChildObjId", "ChildObjId", "int", null, data.get("ChildObjId"), "Default"); - } - - @Override - public String toString() { - String l = layer.equals("common") ? "Common" : "Layer"+layer.substring(5).toUpperCase(); - return dbInfo.name + " ( " + data.get("PosName") + " ) " + "[" + l + "]"; - } - - private List choicesGeneralPosNames; -} diff --git a/src/whitehole/smg/object/PathObject.java b/src/whitehole/smg/object/PathObject.java deleted file mode 100644 index 8d50abf..0000000 --- a/src/whitehole/smg/object/PathObject.java +++ /dev/null @@ -1,332 +0,0 @@ -/* - © 2012 - 2016 - Whitehole Team - - Whitehole is free software: you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - Whitehole is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with Whitehole. If not, see http://www.gnu.org/licenses/. -*/ - -package whitehole.smg.object; - -import java.io.IOException; -import java.util.Iterator; -import java.util.LinkedHashMap; -import javax.media.opengl.GL2; -import javax.media.opengl.GLException; -import whitehole.rendering.GLRenderer; -import whitehole.smg.Bcsv; -import whitehole.smg.ZoneArchive; -import whitehole.vectors.Color4; -import whitehole.vectors.Vector3; - -public class PathObject -{ - public PathObject(ZoneArchive zone, int idx) - { - this.zone = zone; - - this.data = new Bcsv.Entry(); - this.uniqueID = -1; - - this.index = idx; - this.pathID = 0; - - this.points = new LinkedHashMap(); - - this.displayLists = null; - - this.data.put("name", String.format("Path #%1$d", new Object[] { this.index })); - this.data.put("type", "Bezier"); - this.data.put("closed", "OPEN"); - this.data.put("num_pnt", 0); - this.data.put("l_id", this.pathID); - this.data.put("path_arg0", -1); - this.data.put("path_arg1", -1); - this.data.put("path_arg2", -1); - this.data.put("path_arg3", -1); - this.data.put("path_arg4", -1); - this.data.put("path_arg5", -1); - this.data.put("path_arg6", -1); - this.data.put("path_arg7", -1); - this.data.put("usage", "General"); - this.data.put("no", (short)this.index); - this.data.put("Path_ID", (short)-1); - } - - public PathObject(ZoneArchive zone, Bcsv.Entry entry) - { - this.zone = zone; - - this.data = entry; - this.uniqueID = -1; - - this.index = (Short)this.data.get("no"); - this.pathID = (Integer)this.data.get("l_id"); - - try - { - Bcsv pointsfile = new Bcsv(zone.archive.openFile(String.format("/Stage/jmp/Path/CommonPathPointInfo.%1$d", new Object[] { this.index }))); - - this.points = new LinkedHashMap(pointsfile.entries.size()); - - for (Bcsv.Entry pt : pointsfile.entries) - { - PathPointObject ptobj = new PathPointObject(this, pt); - this.points.put(ptobj.index, ptobj); - } - - pointsfile.close(); - } - catch (IOException ex) - { - System.out.println(String.format("Failed to load path points for path %1$d: %2$s", new Object[] { this.index, ex.getMessage() })); - this.points.clear(); - } - - this.displayLists = null; - } - - public void save() - { - this.data.put("no", Short.valueOf((short)this.index)); - this.data.put("l_id", Integer.valueOf(this.pathID)); - this.data.put("num_pnt", Integer.valueOf(this.points.size())); - - try - { - Bcsv pointsfile = new Bcsv(this.zone.archive.openFile(String.format("/Stage/jmp/Path/CommonPathPointInfo.%1$d", new Object[] { Integer.valueOf(this.index) }))); - pointsfile.entries.clear(); - for (PathPointObject ptobj : this.points.values()) - { - ptobj.save(); - pointsfile.entries.add(ptobj.data); - } - pointsfile.save(); - pointsfile.close(); - } - catch (IOException ex) - { - System.out.println(String.format("Failed to save path points for path %1$d: %2$s", new Object[] { Integer.valueOf(this.index), ex.getMessage() })); - } - } - - public void createStorage() - { - String filename = String.format("/Stage/jmp/Path/CommonPathPointInfo.%1$d", new Object[] { Integer.valueOf(this.index) }); - if (this.zone.archive.fileExists(filename)) { - return; - } - try - { - if (this.zone.gameMask == 1) filename = filename.toLowerCase(); - this.zone.archive.createFile(filename.substring(0, filename.lastIndexOf("/")), filename.substring(filename.lastIndexOf("/") + 1)); - Bcsv pointsfile = new Bcsv(this.zone.archive.openFile(filename)); - - pointsfile.addField("point_arg0", 36, 0, -1, 0, 0); - pointsfile.addField("point_arg1", 40, 0, -1, 0, 0); - pointsfile.addField("point_arg2", 44, 0, -1, 0, 0); - pointsfile.addField("point_arg3", 48, 0, -1, 0, 0); - pointsfile.addField("point_arg4", 52, 0, -1, 0, 0); - pointsfile.addField("point_arg5", 56, 0, -1, 0, 0); - pointsfile.addField("point_arg6", 60, 0, -1, 0, 0); - pointsfile.addField("point_arg7", 64, 0, -1, 0, 0); - pointsfile.addField("pnt0_x", 0, 2, -1, 0, 0f); - pointsfile.addField("pnt0_y", 4, 2, -1, 0, 0f); - pointsfile.addField("pnt0_z", 8, 2, -1, 0, 0f); - pointsfile.addField("pnt1_x", 12, 2, -1, 0, 0f); - pointsfile.addField("pnt1_y", 16, 2, -1, 0, 0f); - pointsfile.addField("pnt1_z", 20, 2, -1, 0, 0f); - pointsfile.addField("pnt2_x", 24, 2, -1, 0, 0f); - pointsfile.addField("pnt2_y", 28, 2, -1, 0, 0f); - pointsfile.addField("pnt2_z", 32, 2, -1, 0, 0f); - pointsfile.addField("id", 68, 4, 65535, 0, 0f); - - pointsfile.save(); - pointsfile.close(); - } - catch (IOException ex) - { - System.out.println(String.format("Failed to create new storage for path %1$d: %2$s", new Object[] { this.index, ex.getMessage() })); - } - } - - public void deleteStorage() - { - String filename = String.format("/Stage/jmp/Path/CommonPathPointInfo.%1$d", new Object[] { this.index }); - if (this.zone.archive.fileExists(filename)) { - this.zone.archive.deleteFile(filename); - } - } - - public void prerender(GLRenderer.RenderInfo info) - { - GL2 gl = info.drawable.getGL().getGL2(); - - if (this.displayLists == null) - { - this.displayLists = new int[2]; - this.displayLists[0] = gl.glGenLists(1); - this.displayLists[1] = gl.glGenLists(1); - } - - - - gl.glNewList(this.displayLists[0], 4864); - info.renderMode = GLRenderer.RenderMode.PICKING; - - Color4 dummy = new Color4(); - for (PathPointObject point : this.points.values()) - { - point.render(info, dummy, 1); - point.render(info, dummy, 2); - point.render(info, dummy, 0); - } - - gl.glEndList(); - gl.glNewList(this.displayLists[1], 4864); - info.renderMode = GLRenderer.RenderMode.OPAQUE; - - for (int i = 0; i < 8; i++) - { - gl.glActiveTexture(33984 + i); - gl.glDisable(3553); - } - - gl.glDepthFunc(515); - gl.glDepthMask(true); - gl.glDisable(2896); - gl.glEnable(3042); - gl.glBlendFunc(768, 769); - gl.glDisable(3058); - gl.glDisable(3008); - try { gl.glUseProgram(0); } catch (GLException ex) {} - gl.glEnable(2832); - gl.glHint(3153, 4354); - - Color4 pcolor = this.pathcolors[(this.index % this.pathcolors.length)]; - - for (PathPointObject point : this.points.values()) - { - point.render(info, pcolor, 1); - point.render(info, pcolor, 2); - point.render(info, pcolor, 0); - - gl.glColor4f(pcolor.r, pcolor.g, pcolor.b, pcolor.a); - gl.glLineWidth(1.0F); - gl.glBegin(3); - gl.glVertex3f(point.point1.x, point.point1.y, point.point1.z); - gl.glVertex3f(point.position.x, point.position.y, point.position.z); - gl.glVertex3f(point.point2.x, point.point2.y, point.point2.z); - gl.glEnd(); - } - - gl.glColor4f(pcolor.r, pcolor.g, pcolor.b, pcolor.a); - - if (!this.points.isEmpty()) - { - gl.glLineWidth(1.5F); - gl.glBegin(3); - int numpnt = this.points.size(); - int end = numpnt; - if (((String)this.data.get("closed")).equals("CLOSE")) { end++; - } - Iterator thepoints = this.points.values().iterator(); - PathPointObject curpoint = (PathPointObject)thepoints.next(); - Vector3 start = curpoint.position; - gl.glVertex3f(start.x, start.y, start.z); - for (int p = 1; p < end; p++) - { - Vector3 p1 = curpoint.position; - Vector3 p2 = curpoint.point2; - - if (!thepoints.hasNext()) - thepoints = this.points.values().iterator(); - curpoint = (PathPointObject)thepoints.next(); - - Vector3 p3 = curpoint.point1; - Vector3 p4 = curpoint.position; - - - if ((Vector3.roughlyEqual(p1, p2)) && (Vector3.roughlyEqual(p3, p4))) - { - gl.glVertex3f(p4.x, p4.y, p4.z); - } - else - { - float step = 0.01F; - - for (float t = step; t < 1.0F; t += step) - { - float p1t = (1.0F - t) * (1.0F - t) * (1.0F - t); - float p2t = 3.0F * t * (1.0F - t) * (1.0F - t); - float p3t = 3.0F * t * t * (1.0F - t); - float p4t = t * t * t; - - gl.glVertex3f(p1.x * p1t + p2.x * p2t + p3.x * p3t + p4.x * p4t, p1.y * p1t + p2.y * p2t + p3.y * p3t + p4.y * p4t, p1.z * p1t + p2.z * p2t + p3.z * p3t + p4.z * p4t); - } - } - } - } - gl.glEnd(); - gl.glEndList(); - } - - public void render(GLRenderer.RenderInfo info) - { - if (info.renderMode == GLRenderer.RenderMode.TRANSLUCENT) { return; - } - GL2 gl = info.drawable.getGL().getGL2(); - - int dlid = -1; - switch (info.renderMode) { - case PICKING: - dlid = 0; break; - case OPAQUE: dlid = 1; - } - - gl.glCallList(this.displayLists[dlid]); - } - - - public String toString() - { - return String.format("[%1$d] %2$s", new Object[] { this.pathID, this.data.get("name") }); - } - - - private final Color4[] pathcolors = { - new Color4(1f, 0.3f, 0.3f, 1f), - new Color4(0.3f, 1f, 0.3f, 1f), - new Color4(0.3f, 0.3f, 1f, 1f), - new Color4(1f, 1f, 0.3f, 1f), - new Color4(0.3f, 1f, 1f, 1f), - new Color4(1f, 0.3f, 1f, 1f), - new Color4(0.8f, 0.5f, 0.1f, 1f), - new Color4(0.9f, 0.4f, 0.7f, 1f), - new Color4(0.1f, 0.5f, 0.8f, 1f), - new Color4(0.7f, 0.4f, 0.9f, 1f), - new Color4(0.5f, 0.1f, 0.8f, 1f), - new Color4(0.4f, 0.7f, 0.9f, 1f), - new Color4(1f, 1f, 1f, 1f), - new Color4(0.5f, 0.5f, 0.5f, 1f), - new Color4(0.0f, 0.0f, 0.0f, 1f) - }; - - public ZoneArchive zone; - public Bcsv.Entry data; - public int[] displayLists; - - public int uniqueID; - - public int index; - public int pathID; - - public LinkedHashMap points; -} diff --git a/src/whitehole/smg/object/PathPointObject.java b/src/whitehole/smg/object/PathPointObject.java deleted file mode 100644 index d1d1a62..0000000 --- a/src/whitehole/smg/object/PathPointObject.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - © 2012 - 2016 - Whitehole Team - - Whitehole is free software: you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - Whitehole is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with Whitehole. If not, see http://www.gnu.org/licenses/. -*/ - -package whitehole.smg.object; - -import javax.media.opengl.GL2; -import whitehole.rendering.ColorCubeRenderer; -import whitehole.rendering.GLRenderer; -import whitehole.smg.Bcsv; -import whitehole.smg.LevelObject; -import whitehole.vectors.Color4; -import whitehole.vectors.Vector3; - -public class PathPointObject extends LevelObject -{ - public PathPointObject(PathObject path, int idx, Vector3 pos) - { - this.path = path; - - zone = path.zone; - layer = "common"; - - data = new Bcsv.Entry(); - uniqueID = -1; - - index = idx; - position = pos; - point1 = pos; - point2 = pos; - - displayLists = null; - - data.put("point_arg0", -1); - data.put("point_arg1", -1); - data.put("point_arg2", -1); - data.put("point_arg3", -1); - data.put("point_arg4", -1); - data.put("point_arg5", -1); - data.put("point_arg6", -1); - data.put("point_arg7", -1); - - data.put("pnt0_x", position.x); data.put("pnt0_y", position.y); data.put("pnt0_z", position.z); - data.put("pnt1_x", point1.x); data.put("pnt1_y", point1.y); data.put("pnt1_z", point1.z); - data.put("pnt2_x", point2.x); data.put("pnt2_y", point2.y); data.put("pnt2_z", point2.z); - - data.put("id", (short)index); - } - - public PathPointObject(PathObject path, Bcsv.Entry entry) - { - this.path = path; - - zone = path.zone; - layer = "common"; - - data = entry; - uniqueID = -1; - - index = (int)(short)data.get("id"); - position = new Vector3((float)data.get("pnt0_x"), (float)data.get("pnt0_y"), (float)data.get("pnt0_z")); - point1 = new Vector3((float)data.get("pnt1_x"), (float)data.get("pnt1_y"), (float)data.get("pnt1_z")); - point2 = new Vector3((float)data.get("pnt2_x"), (float)data.get("pnt2_y"), (float)data.get("pnt2_z")); - - displayLists = null; - } - - @Override - public void save() - { - data.put("id", (short)index); - data.put("pnt0_x", position.x); data.put("pnt0_y", position.y); data.put("pnt0_z", position.z); - data.put("pnt1_x", point1.x); data.put("pnt1_y", point1.y); data.put("pnt1_z", point1.z); - data.put("pnt2_x", point2.x); data.put("pnt2_y", point2.y); data.put("pnt2_z", point2.z); - } - - @Override - public void initRenderer(GLRenderer.RenderInfo info) - { - } - - @Override - public void closeRenderer(GLRenderer.RenderInfo info) - { - } - - public void render(GLRenderer.RenderInfo info, Color4 color, int what) - { - if (info.renderMode == GLRenderer.RenderMode.TRANSLUCENT) return; - - GL2 gl = info.drawable.getGL().getGL2(); - - Vector3 pt; - if (what == 0) pt = position; - else if (what == 1) pt = point1; - else pt = point2; - - if (info.renderMode == GLRenderer.RenderMode.PICKING) - { - int uniqueid = (uniqueID << 3) + what; - gl.glColor4ub( - (byte)(uniqueid >>> 16), - (byte)(uniqueid >>> 8), - (byte)uniqueid, - (byte)0xFF); - } - - gl.glPushMatrix(); - gl.glTranslatef(pt.x, pt.y, pt.z); - - ColorCubeRenderer cube = new ColorCubeRenderer(what==0 ? 100f : 50f, new Color4(1f,1f,1f,1f), color, false); - cube.render(info); - - gl.glPopMatrix(); - } - - @Override - public String toString() - { - return String.format("Point %1$d", index); - } - - - public PathObject path; - - public int index; - public Vector3 point1, point2; - - public int[] displayLists; - -}