From 800235999edec10d7c8da541762784efee7e8280 Mon Sep 17 00:00:00 2001 From: SunakazeKun Date: Sun, 25 Sep 2016 00:22:10 +0200 Subject: [PATCH] v1.4.2.3 --- nbproject/private/private.xml | 4 +- nbproject/project.properties | 10 +- src/Resources/GeneralPos.txt | 189 +++ src/whitehole/GalaxyEditorForm.form | 226 +++- src/whitehole/GalaxyEditorForm.java | 1104 +++++++++++------ src/whitehole/LayerForm.java | 5 +- src/whitehole/MainFrame.java | 2 +- src/whitehole/ObjectDBUpdater.java | 2 +- src/whitehole/PropertyGrid.java | 28 +- src/whitehole/Settings.java | 53 +- src/whitehole/SettingsForm.form | 106 +- src/whitehole/SettingsForm.java | 120 +- src/whitehole/Whitehole.java | 10 +- src/whitehole/fileio/Yaz0File.java | 2 +- src/whitehole/rendering/AreaCubeRenderer.java | 144 --- .../rendering/AreaShapeRenderer.java | 156 +++ src/whitehole/rendering/BmdRenderer.java | 6 +- .../rendering/ColorCubeRenderer.java | 42 +- src/whitehole/rendering/GLRenderer.java | 1 + src/whitehole/rendering/RendererCache.java | 8 +- .../rendering/ShapeModelRenderer.java | 31 + .../rendering/SingleBmdRenderer.java | 52 + ...ModelSubstitutor.java => Substitutor.java} | 157 ++- .../ObjectAstroPart.java} | 6 +- .../ObjectAstroSky.java} | 6 +- .../ObjectKinopio.java} | 6 +- .../rendering/object/ObjectOtaKing.java | 37 + .../Pole.java => object/ObjectPole.java} | 6 +- .../ObjectPowerStar.java} | 6 +- .../ObjectSuperSpinDriver.java} | 6 +- .../ObjectUFOKinoko.java} | 6 +- src/whitehole/smg/LevelObject.java | 40 +- src/whitehole/smg/ZoneArchive.java | 141 +-- src/whitehole/smg/object/AreaObj.java | 39 +- src/whitehole/smg/object/CameraCubeObj.java | 40 +- src/whitehole/smg/object/ChangeObj.java | 24 +- src/whitehole/smg/object/ChildObj.java | 1 - src/whitehole/smg/object/DebugObj.java | 3 +- src/whitehole/smg/object/DemoObj.java | 1 - src/whitehole/smg/object/GeneralObject.java | 27 +- src/whitehole/smg/object/GeneralPosObj.java | 50 +- src/whitehole/smg/object/PlanetObj.java | 11 +- src/whitehole/smg/object/StageObj.java | 33 +- 43 files changed, 1914 insertions(+), 1033 deletions(-) create mode 100644 src/Resources/GeneralPos.txt delete mode 100644 src/whitehole/rendering/AreaCubeRenderer.java create mode 100644 src/whitehole/rendering/AreaShapeRenderer.java create mode 100644 src/whitehole/rendering/ShapeModelRenderer.java create mode 100644 src/whitehole/rendering/SingleBmdRenderer.java rename src/whitehole/rendering/{ObjectModelSubstitutor.java => Substitutor.java} (73%) rename src/whitehole/rendering/{objRenderer/AstroPart.java => object/ObjectAstroPart.java} (86%) rename src/whitehole/rendering/{objRenderer/AstroSky.java => object/ObjectAstroSky.java} (86%) rename src/whitehole/rendering/{objRenderer/Kinopio.java => object/ObjectKinopio.java} (93%) create mode 100644 src/whitehole/rendering/object/ObjectOtaKing.java rename src/whitehole/rendering/{objRenderer/Pole.java => object/ObjectPole.java} (88%) rename src/whitehole/rendering/{objRenderer/PowerStar.java => object/ObjectPowerStar.java} (89%) rename src/whitehole/rendering/{objRenderer/SuperSpinDriver.java => object/ObjectSuperSpinDriver.java} (91%) rename src/whitehole/rendering/{objRenderer/UFOKinoko.java => object/ObjectUFOKinoko.java} (94%) diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml index 3ddf11e..cd3e03d 100644 --- a/nbproject/private/private.xml +++ b/nbproject/private/private.xml @@ -3,8 +3,6 @@ - - file:/C:/Users/Aurum/Documents/GitHub/Whitehole/src/whitehole/Whitehole.java - + diff --git a/nbproject/project.properties b/nbproject/project.properties index 2dde70a..c2c546b 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -39,7 +39,7 @@ file.reference.gluegen-rt-natives-windows-amd64.jar=lib/jogl/gluegen-rt-natives- file.reference.gluegen-rt-natives-windows-i586.jar=lib/jogl/gluegen-rt-natives-windows-i586.jar file.reference.gluegen-rt.jar=lib/jogl/gluegen-rt.jar file.reference.gluegen.jar=lib/jogl/gluegen.jar -file.reference.jaxen-1.1.3.jar=lib/jdom2/lib/jaxen-1.1.3.jar +file.reference.jaxen-1.1.3.jar=lib\\jdom2\\lib\\jaxen-1.1.3.jar file.reference.jdom-2.0.2.jar=lib/jdom2/jdom-2.0.2.jar file.reference.jogl-all-natives-android-armv7.jar=lib/jogl/jogl-all-natives-android-armv7.jar file.reference.jogl-all-natives-linux-amd64.jar=lib/jogl/jogl-all-natives-linux-amd64.jar @@ -54,13 +54,11 @@ file.reference.jogl-all-natives-windows-i586.jar=lib/jogl/jogl-all-natives-windo file.reference.jogl.all-mobile.jar=lib/jogl/jogl.all-mobile.jar file.reference.jogl.all-noawt.jar=lib/jogl/jogl.all-noawt.jar file.reference.jogl.all.jar=lib/jogl/jogl.all.jar -file.reference.xercesImpl.jar=lib/jdom2/lib/xercesImpl.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 javac.classpath=\ - ${file.reference.jaxen-1.1.3.jar}:\ - ${file.reference.xercesImpl.jar}:\ ${file.reference.xml-apis.jar}:\ ${file.reference.jdom-2.0.2.jar}:\ ${file.reference.gluegen-rt.jar}:\ @@ -87,7 +85,9 @@ javac.classpath=\ ${file.reference.jogl-all-natives-windows-amd64.jar}:\ ${file.reference.jogl-all-natives-windows-i586.jar}:\ ${file.reference.jogl.all-mobile.jar}:\ - ${file.reference.jogl.all-noawt.jar} + ${file.reference.jogl.all-noawt.jar}:\ + ${file.reference.jaxen-1.1.3.jar}:\ + ${file.reference.xercesImpl.jar} # Space-separated list of extra javac options javac.compilerargs= javac.deprecation=false diff --git a/src/Resources/GeneralPos.txt b/src/Resources/GeneralPos.txt new file mode 100644 index 0000000..c038fd0 --- /dev/null +++ b/src/Resources/GeneralPos.txt @@ -0,0 +1,189 @@ +いいえ選択移動位置 +アイテム惑星戻り +ウォーターバズーカマリオ位置 +エピローグマリオ +カメラ基準点 +ガード出現ポイント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/whitehole/GalaxyEditorForm.form b/src/whitehole/GalaxyEditorForm.form index 3d5044b..3c54c1f 100644 --- a/src/whitehole/GalaxyEditorForm.form +++ b/src/whitehole/GalaxyEditorForm.form @@ -1,10 +1,152 @@
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -22,56 +164,15 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - @@ -120,44 +221,59 @@ - + - + - + - + - + - + - + + + + + + + + + + + + + + + - + - + - + - + + - + diff --git a/src/whitehole/GalaxyEditorForm.java b/src/whitehole/GalaxyEditorForm.java index 44b398d..a1d60e4 100644 --- a/src/whitehole/GalaxyEditorForm.java +++ b/src/whitehole/GalaxyEditorForm.java @@ -27,7 +27,9 @@ 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; import java.io.*; import java.nio.*; import java.awt.*; @@ -43,9 +45,7 @@ import whitehole.vectors.*; import whitehole.rendering.*; import whitehole.smg.*; -import whitehole.fileio.*; import whitehole.smg.Bcsv; -import whitehole.smg.object.ChildObj; public class GalaxyEditorForm extends javax.swing.JFrame { @@ -215,7 +215,7 @@ private void initGUI() tbObjToolbar.setLayout(new ToolbarFlowLayout(FlowLayout.LEFT, 0, 0)); tbObjToolbar.validate(); - tgbReverseRot.setSelected(Settings.reverseRot); + tgbReverseRot.setSelected(Settings.editor_reverseRot); Font bigfont = lbStatusLabel.getFont().deriveFont(Font.BOLD, 12f); lbStatusLabel.setFont(bigfont); @@ -327,11 +327,11 @@ public void popupMenuCanceled(PopupMenuEvent e) pnlObjectSettings = new PropertyGrid(this); scpObjSettingsContainer.setViewportView(pnlObjectSettings); scpObjSettingsContainer.getVerticalScrollBar().setUnitIncrement(16); - pnlObjectSettings.setEventListener(new PropertyGrid.EventListener() - { + pnlObjectSettings.setEventListener(new PropertyGrid.EventListener() { @Override - public void propertyChanged(String propname, Object value) - { propPanelPropertyChanged(propname, value); } + public void propertyChanged(String propname, Object value) { + propPanelPropertyChanged(propname, value); + } }); glCanvas.requestFocusInWindow(); @@ -392,20 +392,18 @@ public void updateZone(String zone) // //GEN-BEGIN:initComponents private void initComponents() { - jToolBar1 = new javax.swing.JToolBar(); - btnSave = new javax.swing.JButton(); - jSeparator1 = new javax.swing.JToolBar.Separator(); - btnClose = new javax.swing.JButton(); jSplitPane1 = new javax.swing.JSplitPane(); pnlGLPanel = new javax.swing.JPanel(); jToolBar2 = new javax.swing.JToolBar(); btnDeselect = new javax.swing.JButton(); - jSeparator2 = new javax.swing.JToolBar.Separator(); - btnShowAllPaths = new javax.swing.JToggleButton(); jSeparator3 = new javax.swing.JToolBar.Separator(); - tgbShowFake = new javax.swing.JToggleButton(); - jSeparator5 = new javax.swing.JToolBar.Separator(); tgbReverseRot = new javax.swing.JToggleButton(); + jSeparator5 = new javax.swing.JToolBar.Separator(); + btnShowPaths = new javax.swing.JToggleButton(); + jSeparator6 = new javax.swing.JToolBar.Separator(); + tgbShowAxis = new javax.swing.JToggleButton(); + jSeparator7 = new javax.swing.JToolBar.Separator(); + tgbShowFake = new javax.swing.JToggleButton(); lbStatusLabel = new javax.swing.JLabel(); tpLeftPanel = new javax.swing.JTabbedPane(); pnlScenarioZonePanel = new javax.swing.JSplitPane(); @@ -438,9 +436,25 @@ private void initComponents() { jScrollPane3 = new javax.swing.JScrollPane(); tvObjectList = new javax.swing.JTree(); scpObjSettingsContainer = new javax.swing.JScrollPane(); + jMenuBar1 = new javax.swing.JMenuBar(); + mnuSave = new javax.swing.JMenu(); + itemSave = new javax.swing.JMenuItem(); + itemClose = new javax.swing.JMenuItem(); + mnuEdit = new javax.swing.JMenu(); + subCopy = new javax.swing.JMenu(); + itemPosition = new javax.swing.JMenuItem(); + itemRotation = new javax.swing.JMenuItem(); + itemScale = new javax.swing.JMenuItem(); + subPaste = new javax.swing.JMenu(); + itemPositionPaste = new javax.swing.JMenuItem(); + itemRotationPaste = new javax.swing.JMenuItem(); + itemScalePaste = new javax.swing.JMenuItem(); + mnuHelp = new javax.swing.JMenu(); + itemControls = new javax.swing.JMenuItem(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); - setPreferredSize(new java.awt.Dimension(900, 700)); + setMinimumSize(new java.awt.Dimension(640, 480)); + setPreferredSize(new java.awt.Dimension(860, 640)); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { formWindowClosing(evt); @@ -450,38 +464,8 @@ public void windowOpened(java.awt.event.WindowEvent evt) { } }); - jToolBar1.setFloatable(false); - jToolBar1.setRollover(true); - - btnSave.setText("Save"); - btnSave.setToolTipText(""); - btnSave.setFocusable(false); - btnSave.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); - btnSave.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - btnSave.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - btnSaveActionPerformed(evt); - } - }); - jToolBar1.add(btnSave); - jToolBar1.add(jSeparator1); - - btnClose.setText("Close"); - btnClose.setFocusable(false); - btnClose.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); - btnClose.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - btnClose.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - btnCloseActionPerformed(evt); - } - }); - jToolBar1.add(btnClose); - - getContentPane().add(jToolBar1, java.awt.BorderLayout.PAGE_START); - - jSplitPane1.setDividerLocation(300); + jSplitPane1.setDividerLocation(335); jSplitPane1.setFocusable(false); - jSplitPane1.setLastDividerLocation(300); pnlGLPanel.setMinimumSize(new java.awt.Dimension(10, 30)); pnlGLPanel.setLayout(new java.awt.BorderLayout()); @@ -500,19 +484,45 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { } }); jToolBar2.add(btnDeselect); - jToolBar2.add(jSeparator2); + jToolBar2.add(jSeparator3); + + tgbReverseRot.setText("Reverse rotation"); + tgbReverseRot.setFocusable(false); + tgbReverseRot.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + tgbReverseRot.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + tgbReverseRot.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + tgbReverseRotActionPerformed(evt); + } + }); + jToolBar2.add(tgbReverseRot); + jToolBar2.add(jSeparator5); - btnShowAllPaths.setText("Show all paths"); - btnShowAllPaths.setFocusable(false); - btnShowAllPaths.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); - btnShowAllPaths.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - btnShowAllPaths.addActionListener(new java.awt.event.ActionListener() { + btnShowPaths.setText("Show paths"); + btnShowPaths.setFocusable(false); + btnShowPaths.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + btnShowPaths.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + btnShowPaths.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { - btnShowAllPathsActionPerformed(evt); + btnShowPathsActionPerformed(evt); } }); - jToolBar2.add(btnShowAllPaths); - jToolBar2.add(jSeparator3); + jToolBar2.add(btnShowPaths); + jToolBar2.add(jSeparator6); + + tgbShowAxis.setSelected(true); + tgbShowAxis.setText("Show axis"); + tgbShowAxis.setActionCommand("Show 'Fake Color'"); + tgbShowAxis.setFocusable(false); + tgbShowAxis.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + tgbShowAxis.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + tgbShowAxis.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + tgbShowAxisActionPerformed(evt); + } + }); + jToolBar2.add(tgbShowAxis); + jToolBar2.add(jSeparator7); tgbShowFake.setText("Show 'fake color'"); tgbShowFake.setActionCommand("Show 'Fake Color'"); @@ -525,18 +535,6 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { } }); jToolBar2.add(tgbShowFake); - jToolBar2.add(jSeparator5); - - tgbReverseRot.setText("Reverse rotation"); - tgbReverseRot.setFocusable(false); - tgbReverseRot.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); - tgbReverseRot.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - tgbReverseRot.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - tgbReverseRotActionPerformed(evt); - } - }); - jToolBar2.add(tgbReverseRot); pnlGLPanel.add(jToolBar2, java.awt.BorderLayout.NORTH); @@ -722,6 +720,108 @@ public void valueChanged(javax.swing.event.TreeSelectionEvent evt) { getContentPane().add(jSplitPane1, java.awt.BorderLayout.CENTER); + mnuSave.setText("File"); + + itemSave.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK)); + itemSave.setText("Save"); + itemSave.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + itemSaveActionPerformed(evt); + } + }); + mnuSave.add(itemSave); + + itemClose.setText("Close"); + itemClose.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + itemCloseActionPerformed(evt); + } + }); + mnuSave.add(itemClose); + + jMenuBar1.add(mnuSave); + + mnuEdit.setText("Edit"); + + subCopy.setText("Copy"); + + itemPosition.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, java.awt.event.InputEvent.ALT_MASK)); + itemPosition.setText("Position"); + itemPosition.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + itemPositionActionPerformed(evt); + } + }); + subCopy.add(itemPosition); + + itemRotation.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_R, java.awt.event.InputEvent.ALT_MASK)); + itemRotation.setText("Rotation"); + itemRotation.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + itemRotationActionPerformed(evt); + } + }); + subCopy.add(itemRotation); + + itemScale.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.ALT_MASK)); + itemScale.setText("Scale"); + itemScale.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + itemScaleActionPerformed(evt); + } + }); + subCopy.add(itemScale); + + mnuEdit.add(subCopy); + + subPaste.setText("Paste"); + + itemPositionPaste.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, java.awt.event.InputEvent.SHIFT_MASK)); + itemPositionPaste.setText("Position (0.0, 0.0, 0.0)"); + itemPositionPaste.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + itemPositionPasteActionPerformed(evt); + } + }); + subPaste.add(itemPositionPaste); + + itemRotationPaste.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_R, java.awt.event.InputEvent.SHIFT_MASK)); + itemRotationPaste.setText("Rotation (0.0, 0.0, 0.0)"); + itemRotationPaste.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + itemRotationPasteActionPerformed(evt); + } + }); + subPaste.add(itemRotationPaste); + + itemScalePaste.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.SHIFT_MASK)); + itemScalePaste.setText("Scale (1.0, 1.0, 1.0)"); + itemScalePaste.setToolTipText(""); + itemScalePaste.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + itemScalePasteActionPerformed(evt); + } + }); + subPaste.add(itemScalePaste); + + mnuEdit.add(subPaste); + + jMenuBar1.add(mnuEdit); + + mnuHelp.setText("Help"); + + itemControls.setText("Controls"); + itemControls.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + itemControlsActionPerformed(evt); + } + }); + mnuHelp.add(itemControls); + + jMenuBar1.add(mnuHelp); + + setJMenuBar(jMenuBar1); + pack(); }// //GEN-END:initComponents @@ -812,7 +912,7 @@ else if (cls == null) pnlObjectSettings.addCategory("path_settings", "Path settings"); if (galaxyMode) - pnlObjectSettings.addField("[P]zone", "Zone", "list", galaxyArc.zoneList, selectedPathPoint.path.zone.zoneName, "Default"); + 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"); @@ -865,11 +965,19 @@ else if (cls == null) } pnlObjectSettings.addCategory("obj_general", "General"); - if (selectedObj.name != null && 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"); + if (selectedObj.getClass() != StageObj.class) { + if (selectedObj.name != null && 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); } @@ -945,6 +1053,8 @@ private void populateObjectList(int layermask) 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) @@ -1032,17 +1142,17 @@ private void formWindowClosing(java.awt.event.WindowEvent evt)//GEN-FIRST:event_ } }//GEN-LAST:event_formWindowClosing - private void btnShowAllPathsActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnShowAllPathsActionPerformed - {//GEN-HEADEREND:event_btnShowAllPathsActionPerformed + private void btnShowPathsActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnShowPathsActionPerformed + {//GEN-HEADEREND:event_btnShowPathsActionPerformed for (String zone : zoneArcs.keySet()) rerenderTasks.add("zone:" + zone); glCanvas.repaint(); - }//GEN-LAST:event_btnShowAllPathsActionPerformed + }//GEN-LAST:event_btnShowPathsActionPerformed private void tgbReverseRotActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_tgbReverseRotActionPerformed {//GEN-HEADEREND:event_tgbReverseRotActionPerformed - Settings.reverseRot = tgbReverseRot.isSelected(); + Settings.editor_reverseRot = tgbReverseRot.isSelected(); Settings.save(); }//GEN-LAST:event_tgbReverseRotActionPerformed @@ -1053,14 +1163,6 @@ private void tgbShowFakeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F glCanvas.repaint(); }//GEN-LAST:event_tgbShowFakeActionPerformed - private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveActionPerformed - saveChanges(); - }//GEN-LAST:event_btnSaveActionPerformed - - private void btnCloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCloseActionPerformed - dispose(); - }//GEN-LAST:event_btnCloseActionPerformed - private void tpLeftPanelStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_tpLeftPanelStateChanged // useless }//GEN-LAST:event_tpLeftPanelStateChanged @@ -1105,10 +1207,13 @@ private void tgbDeleteObjectActionPerformed(java.awt.event.ActionEvent evt) {//G for (LevelObject selectedObj : templist) { selectedObjs.remove(selectedObj.uniqueID); - deleteObject(selectedObj.uniqueID); + if (selectedObj.getClass() != StageObj.class) { + deleteObject(selectedObj.uniqueID); + } } selectionChanged(); } + tvObjectList.setSelectionRow(0); tgbDeleteObject.setSelected(false); } else @@ -1219,6 +1324,126 @@ private void lbScenarioListValueChanged(javax.swing.event.ListSelectionEvent evt private void btnAddScenarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddScenarioActionPerformed }//GEN-LAST:event_btnAddScenarioActionPerformed + + private void tgbShowAxisActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tgbShowAxisActionPerformed + glCanvas.repaint(); + }//GEN-LAST:event_tgbShowAxisActionPerformed + + private void itemSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemSaveActionPerformed + saveChanges(); + }//GEN-LAST:event_itemSaveActionPerformed + + private void itemCloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemCloseActionPerformed + dispose(); + }//GEN-LAST:event_itemCloseActionPerformed + + 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); + } + } + } + }//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); + } + } + } + }//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); + } + } + } + }//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; + } + } + }//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); + 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; + } + } + }//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; + } + } + }//GEN-LAST:event_itemRotationPasteActionPerformed + + private void itemControlsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemControlsActionPerformed + JOptionPane.showMessageDialog(null, + "Left mouse button: De/select object\r\n" + + "Right mouse button: Camera angle\r\n" + + "Mouse wheel: Camera zoom\r\n" + + "Arrow keys: Move camera\r\n" + + "\r\n" + + "P + arrow keys: Move position\r\n" + + "R + arrow keys: Rotate object\r\n" + + "S + arrow keys: Scale object\r\n" + + "\r\n" + + "ALT + P: Copy position\r\n" + + "ALT + R: Copy rotation\r\n" + + "ALT + S: Copy scale\r\n" + + "\r\n" + + "SHIFT + P: Paste position\r\n" + + "SHIFT + R: Paste rotation\r\n" + + "SHIFT + S: Paste scale", + Whitehole.fullName, JOptionPane.INFORMATION_MESSAGE); + }//GEN-LAST:event_itemControlsActionPerformed public void addRerenderTask(String task) @@ -1327,15 +1552,53 @@ private void offsetSelectionBy(Vector3 delta) } else { - 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); + 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); + } + } + 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 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(); } } } @@ -1361,99 +1624,97 @@ private void addObject(Point where) LevelObject newobj = null; int pnodeid = -1; if (ZoneArchive.gameMask==2) { - switch (objtype) - { + 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; - } + 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; } - 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; - break; - case "sound": - newobj = new SoundObj(curZoneArc, "Placement/" + addingOnLayer + "/SoundInfo", ZoneArchive.gameMask, objname, pos); - pnodeid = 7; - 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; - break; - } + } + 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; + break; + case "sound": + newobj = new SoundObj(curZoneArc, "Placement/" + addingOnLayer + "/SoundInfo", ZoneArchive.gameMask, objname, pos); + pnodeid = 7; + 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; + break; } + } int uid = 0; while (globalObjList.containsKey(uid) @@ -1462,6 +1723,7 @@ private void addObject(Point where) uid++; if (uid > maxUniqueID) maxUniqueID = uid; newobj.uniqueID = uid; + globalObjList.put(uid, newobj); curZoneArc.objects.get(addingOnLayer.toLowerCase()).add(newobj); @@ -1510,7 +1772,8 @@ private void doAddObject(String type) { tgbAddObject.setSelected(false); return; - } objectBeingAdded = type+"|"+form.selectedObject; + } + objectBeingAdded = type+"|"+form.selectedObject; addingOnLayer = form.selectedLayer; break; } @@ -1577,6 +1840,41 @@ 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"; + } + } public void propPanelPropertyChanged(String propname, Object value) { @@ -1586,6 +1884,22 @@ public void propPanelPropertyChanged(String propname, Object value) { selectedObj.name = (String)value; selectedObj.loadDBInfo(); + + // 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"); + } + selectedObj.getProperties(pnlObjectSettings); + } DefaultTreeModel objlist = (DefaultTreeModel)tvObjectList.getModel(); objlist.nodeChanged(treeNodeList.get(selectedObj.uniqueID)); @@ -1690,8 +2004,23 @@ else if (oldval.getClass() == Float.class) glCanvas.repaint(); } } - else if (propname.equals("MarioNo")) - { + else if (propname.equals("ShapeModelNo")) { + if (selectedObj.renderer.boundToShapeModel()) { + 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() == CameraCubeObj.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)); } @@ -1766,7 +2095,6 @@ public void init(GLAutoDrawable glad) objectBeingAdded = ""; addingOnLayer = ""; deletingObjects = false; - duplicatingObjects = false; renderinfo = new GLRenderer.RenderInfo(); renderinfo.drawable = glad; @@ -1978,7 +2306,7 @@ private void prerenderZone(GL2 gl, String zone) { for (PathObject pobj : zonearc.paths) { - if (!btnShowAllPaths.isSelected() && // isSelected? intuitive naming ftw :/ + if (!btnShowPaths.isSelected() && // isSelected? intuitive naming ftw :/ !displayedPaths.containsKey(pobj.pathID)) continue; @@ -2205,7 +2533,6 @@ public void display(GLAutoDrawable glad) gl.glReadPixels(lastMouseMove.x - 1, glad.getHeight() - lastMouseMove.y + 1, 3, 3, GL2.GL_BGRA, GL2.GL_UNSIGNED_INT_8_8_8_8_REV, pickingFrameBuffer); gl.glReadPixels(lastMouseMove.x, glad.getHeight() - lastMouseMove.y, 1, 1, GL2.GL_DEPTH_COMPONENT, GL2.GL_FLOAT, pickingDepthBuffer); pickingDepth = -(zFar * zNear / (pickingDepthBuffer.get(0) * (zFar - zNear) - zFar)); - //lbStatusLabel.setText(String.format("%1$f", pickingDepth)); if (tgbShowFake.isSelected()) { @@ -2226,7 +2553,7 @@ public void display(GLAutoDrawable glad) gl.glEnable(GL2.GL_TEXTURE_2D); - if (Settings.fastDrag) + if (Settings.editor_fastDrag) { if (isDragging) { @@ -2256,17 +2583,19 @@ public void display(GLAutoDrawable glad) gl.glDisable(GL2.GL_BLEND); gl.glDisable(GL2.GL_ALPHA_TEST); - gl.glBegin(GL2.GL_LINES); - gl.glColor4f(1f, 0f, 0f, 1f); - gl.glVertex3f(0f, 0f, 0f); - gl.glVertex3f(100000f, 0f, 0f); - gl.glColor4f(0f, 1f, 0f, 1f); - gl.glVertex3f(0f, 0f, 0f); - gl.glVertex3f(0, 100000f, 0f); - gl.glColor4f(0f, 0f, 1f, 1f); - gl.glVertex3f(0f, 0f, 0f); - gl.glVertex3f(0f, 0f, 100000f); - gl.glEnd(); + if (tgbShowAxis.isSelected()) { + gl.glBegin(GL2.GL_LINES); + gl.glColor4f(1f, 0f, 0f, 1f); + gl.glVertex3f(0f, 0f, 0f); + gl.glVertex3f(100000f, 0f, 0f); + gl.glColor4f(0f, 1f, 0f, 1f); + gl.glVertex3f(0f, 0f, 0f); + gl.glVertex3f(0, 100000f, 0f); + gl.glColor4f(0f, 0f, 1f, 1f); + gl.glVertex3f(0f, 0f, 0f); + gl.glVertex3f(0f, 0f, 100000f); + gl.glEnd(); + } glad.swapBuffers(); @@ -2301,13 +2630,11 @@ public void updateCamera() { Vector3 up; - if (Math.cos(camRotation.y) < 0f) - { + if (Math.cos(camRotation.y) < 0f) { upsideDown = true; up = new Vector3(0f, -1f, 0f); } - else - { + else { upsideDown = false; up = new Vector3(0f, 1f, 0f); } @@ -2324,15 +2651,13 @@ public void updateCamera() @Override - public void mouseDragged(MouseEvent e) - { + public void mouseDragged(MouseEvent e) { if (!inited) return; float xdelta = e.getX() - lastMouseMove.x; float ydelta = e.getY() - lastMouseMove.y; - if (!isDragging && (Math.abs(xdelta) >= 3f || Math.abs(ydelta) >= 3f)) - { + if (!isDragging && (Math.abs(xdelta) >= 3f || Math.abs(ydelta) >= 3f)) { pickingCapture = true; isDragging = true; } @@ -2340,8 +2665,7 @@ public void mouseDragged(MouseEvent e) if (!isDragging) return; - if (pickingCapture) - { + if (pickingCapture) { underCursor = pickingFrameBuffer.get(4) & 0xFFFFFF; depthUnderCursor = pickingDepth; pickingCapture = false; @@ -2349,10 +2673,8 @@ public void mouseDragged(MouseEvent e) lastMouseMove = e.getPoint(); - if (!selectedObjs.isEmpty() && selectedObjs.containsKey(underCursor >>> 3)) - { - if (mouseButton == MouseEvent.BUTTON1) - { + if (!selectedObjs.isEmpty() && selectedObjs.containsKey(underCursor >>> 3)) { + if (mouseButton == MouseEvent.BUTTON1) { float objz = depthUnderCursor; xdelta *= pixelFactorX * objz * scaledown; @@ -2368,28 +2690,23 @@ public void mouseDragged(MouseEvent e) unsavedChanges = true; } } - else - { - if (mouseButton == MouseEvent.BUTTON3) - { + else { + if (mouseButton == MouseEvent.BUTTON3) { if (upsideDown) xdelta = -xdelta; - if (tgbReverseRot.isSelected()) - { + if (tgbReverseRot.isSelected()) { xdelta = -xdelta; - ydelta = -ydelta; + ydelta = -ydelta ; } - if (underCursor == 0xFFFFFF || depthUnderCursor > camDistance) - { + if (underCursor == 0xFFFFFF || depthUnderCursor > camDistance) { xdelta *= 0.002f; ydelta *= 0.002f; camRotation.x -= xdelta; camRotation.y -= ydelta; } - else - { + else { xdelta *= 0.002f; ydelta *= 0.002f; @@ -2406,15 +2723,12 @@ public void mouseDragged(MouseEvent e) camTarget.z -= diff * Math.sin(camRotation.x) * Math.cos(camRotation.y); } } - else if (mouseButton == MouseEvent.BUTTON1) - { - if (underCursor == 0xFFFFFF) - { + else if (mouseButton == MouseEvent.BUTTON1) { + if (underCursor == 0xFFFFFF) { xdelta *= 0.005f; ydelta *= 0.005f; } - else - { + else { xdelta *= Math.min(0.005f, pixelFactorX * depthUnderCursor); ydelta *= Math.min(0.005f, pixelFactorY * depthUnderCursor); } @@ -2432,21 +2746,18 @@ else if (mouseButton == MouseEvent.BUTTON1) } @Override - public void mouseMoved(MouseEvent e) - { + public void mouseMoved(MouseEvent e) { if (!inited) return; lastMouseMove = e.getPoint(); } @Override - public void mouseClicked(MouseEvent e) - { + public void mouseClicked(MouseEvent e) { } @Override - public void mousePressed(MouseEvent e) - { + public void mousePressed(MouseEvent e) { if (!inited) return; if (mouseButton != MouseEvent.NOBUTTON) return; @@ -2459,8 +2770,7 @@ public void mousePressed(MouseEvent e) } @Override - public void mouseReleased(MouseEvent e) - { + public void mouseReleased(MouseEvent e) { if (!inited) return; if (e.getButton() != mouseButton) return; @@ -2469,10 +2779,9 @@ public void mouseReleased(MouseEvent e) boolean shiftpressed = e.isShiftDown(); boolean ctrlpressed = e.isControlDown(); - if (isDragging) - { + if (isDragging) { isDragging = false; - if (Settings.fastDrag) e.getComponent().repaint(); + if (Settings.editor_fastDrag) e.getComponent().repaint(); return; } @@ -2493,49 +2802,40 @@ public void mouseReleased(MouseEvent e) int oldarg = selectionArg; selectionArg = 0; - if (e.getButton() == MouseEvent.BUTTON3) - { + if (e.getButton() == MouseEvent.BUTTON3) { // right click: cancels current add/delete command - if (!objectBeingAdded.isEmpty()) - { + if (!objectBeingAdded.isEmpty()) { objectBeingAdded = ""; tgbAddObject.setSelected(false); setStatusText(); } - else if (deletingObjects) - { + else if (deletingObjects) { deletingObjects = false; tgbDeleteObject.setSelected(false); setStatusText(); } } - else - { + else { // left click: places/deletes objects or selects shit - if (!objectBeingAdded.isEmpty()) - { + if (!objectBeingAdded.isEmpty()) { addObject(lastMouseMove); - if (!shiftpressed) - { + if (!shiftpressed) { objectBeingAdded = ""; tgbAddObject.setSelected(false); setStatusText(); } } - else if (deletingObjects) - { + else if (deletingObjects) { deleteObject(objid); - if (!shiftpressed) - { + if (!shiftpressed) { deletingObjects = false; tgbDeleteObject.setSelected(false); setStatusText(); } } - else - { + else { // multiselect behavior // Ctrl not pressed: // * clicking an object selects/deselects it @@ -2546,30 +2846,22 @@ else if (deletingObjects) boolean wasselected = false; - if (ctrlpressed) - { + if (ctrlpressed) { if (selectedObjs.containsKey(objid)) selectedObjs.remove(objid); - else - { + else { selectedObjs.put(objid, theobject); wasselected = true; } } - else - { + else { LinkedHashMap oldsel = null; - if (!selectedObjs.isEmpty() && arg == oldarg) - { - LevelObject oldobj = (LevelObject)selectedObjs.values().toArray()[0]; - + if (!selectedObjs.isEmpty() && arg == oldarg) { oldsel = (LinkedHashMap)selectedObjs.clone(); - for (LevelObject unselobj : oldsel.values()) - { - if (treeNodeList.containsKey(unselobj.uniqueID)) - { + for (LevelObject unselobj : oldsel.values()) { + if (treeNodeList.containsKey(unselobj.uniqueID)) { TreeNode tn = treeNodeList.get(unselobj.uniqueID); TreePath tp = new TreePath(((DefaultTreeModel)tvObjectList.getModel()).getPathToRoot(tn)); tvObjectList.removeSelectionPath(tp); @@ -2582,8 +2874,7 @@ else if (deletingObjects) selectedObjs.clear(); } - if (oldsel == null || !oldsel.containsKey(theobject.uniqueID) || arg != oldarg) - { + if (oldsel == null || !oldsel.containsKey(theobject.uniqueID) || arg != oldarg) { selectedObjs.put(theobject.uniqueID, theobject); wasselected = true; } @@ -2591,12 +2882,9 @@ else if (deletingObjects) addRerenderTask("zone:"+theobject.zone.zoneName); - if (wasselected) - { - if (selectedObjs.size() == 1) - { - if (galaxyMode) - { + if (wasselected) { + if (selectedObjs.size() == 1) { + if (galaxyMode) { String zone = selectedObjs.values().iterator().next().zone.zoneName; lbZoneList.setSelectedValue(zone, true); } @@ -2607,30 +2895,25 @@ else if (deletingObjects) // if the object is in the TreeView, all we have to do is tell the TreeView to select it // and the rest will be handled there - if (treeNodeList.containsKey(objid)) - { + if (treeNodeList.containsKey(objid)) { TreeNode tn = treeNodeList.get(objid); TreePath tp = new TreePath(((DefaultTreeModel)tvObjectList.getModel()).getPathToRoot(tn)); if (ctrlpressed) tvObjectList.addSelectionPath(tp); else tvObjectList.setSelectionPath(tp); tvObjectList.scrollPathToVisible(tp); } - else - { + else { addRerenderTask("zone:"+theobject.zone.zoneName); selectionChanged(); } } - else - { - if (treeNodeList.containsKey(objid)) - { + else { + if (treeNodeList.containsKey(objid)) { TreeNode tn = treeNodeList.get(objid); TreePath tp = new TreePath(((DefaultTreeModel)tvObjectList.getModel()).getPathToRoot(tn)); tvObjectList.removeSelectionPath(tp); } - else - { + else { addRerenderTask("zone:"+theobject.zone.zoneName); selectionChanged(); } @@ -2677,8 +2960,7 @@ public void mouseWheelMoved(MouseWheelEvent e) unsavedChanges = true; } - else - { + else { float delta = (float)(e.getPreciseWheelRotation() * Math.min(0.1f, pickingDepth / 10f)); Vector3 vdelta = new Vector3( @@ -2704,102 +2986,161 @@ public void mouseWheelMoved(MouseWheelEvent e) } @Override - public void keyTyped(KeyEvent e) - { + public void keyTyped(KeyEvent e) { } @Override - public void keyPressed(KeyEvent e) - { + public void keyPressed(KeyEvent e) { int oldmask = keyMask; - switch (e.getKeyCode()) - { + switch (e.getKeyCode()) { case KeyEvent.VK_LEFT: - case KeyEvent.VK_NUMPAD4: keyMask |= 1; break; + case KeyEvent.VK_NUMPAD4: + keyMask |= 1; + break; case KeyEvent.VK_RIGHT: - case KeyEvent.VK_NUMPAD6: keyMask |= (1 << 1); break; + case KeyEvent.VK_NUMPAD6: + keyMask |= (1 << 1); + break; case KeyEvent.VK_UP: - case KeyEvent.VK_NUMPAD8: keyMask |= (1 << 2); break; + case KeyEvent.VK_NUMPAD8: + keyMask |= (1 << 2); + break; case KeyEvent.VK_DOWN: - case KeyEvent.VK_NUMPAD2: keyMask |= (1 << 3); break; + case KeyEvent.VK_NUMPAD2: + keyMask |= (1 << 3); + break; case KeyEvent.VK_PAGE_UP: - case KeyEvent.VK_NUMPAD9: keyMask |= (1 << 4); break; + case KeyEvent.VK_NUMPAD9: + keyMask |= (1 << 4); + break; case KeyEvent.VK_PAGE_DOWN: - case KeyEvent.VK_END: case KeyEvent.VK_NUMPAD3: - case KeyEvent.VK_NUMPAD1: keyMask |= (1 << 5); break; + keyMask |= (1 << 5); + break; + case KeyEvent.VK_P: + keyMask |= (1 << 6); + break; + case KeyEvent.VK_R: + keyMask |= (1 << 7); + break; + case KeyEvent.VK_S: + keyMask |= (1 << 8); + break; } - if ((keyMask & 0x3F) != 0) - { + if ((keyMask & 0x3F) != 0) { Vector3 delta = new Vector3(); - Vector3 finaldelta; - - if (oldmask != keyMask) keyDelta = 0; - + Vector3 deltaPos = new Vector3(); + Vector3 deltaDir = new Vector3(); + Vector3 deltaSize = new Vector3(); + Vector3 finaldelta = new Vector3(); int disp; - /*if (keyDelta > 500) disp = 100; - else*/ if (keyDelta > 50) disp = 10; - else disp = 1; - - if ((keyMask & 1) != 0) delta.x = disp; - else if ((keyMask & (1 << 1)) != 0) delta.x = -disp; - if ((keyMask & (1 << 2)) != 0) delta.y = disp; - else if ((keyMask & (1 << 3)) != 0) delta.y = -disp; - if ((keyMask & (1 << 4)) != 0) delta.z = -disp; - else if ((keyMask & (1 << 5)) != 0) delta.z = disp; - if (e.isControlDown()) - finaldelta = delta; + if (oldmask != keyMask) + keyDelta = 0; + + if (keyDelta > 50) + disp = 10; else - { - finaldelta = new Vector3(); - - finaldelta.x = (float)(-(delta.x * Math.sin(camRotation.x)) - - (delta.y * Math.cos(camRotation.x) * Math.sin(camRotation.y)) - + (delta.z * Math.cos(camRotation.x) * Math.cos(camRotation.y))); - finaldelta.y = (float)((delta.y * Math.cos(camRotation.y)) - + (delta.z * Math.sin(camRotation.y))); - finaldelta.z = (float)((delta.x * Math.cos(camRotation.x)) - - (delta.y * Math.sin(camRotation.x) * Math.sin(camRotation.y)) - + (delta.z * Math.sin(camRotation.x) * Math.cos(camRotation.y))); + disp = 1; + + if ((keyMask & 1) != 0) { + delta.x = disp; + deltaPos.x += 100; + deltaDir.x += 5; + deltaSize.x += 1; + } + else if ((keyMask & (1 << 1)) != 0) { + delta.x = -disp; + deltaPos.x += -100; + deltaDir.x += -5; + deltaSize.x += -1; + } + if ((keyMask & (1 << 2)) != 0) { + delta.y = disp; + deltaPos.y += 100; + deltaDir.y += 5; + deltaSize.y += 1; + } + else if ((keyMask & (1 << 3)) != 0) { + delta.y = -disp; + deltaPos.y += -100; + deltaDir.y += -5; + deltaSize.y += -1; + } + if ((keyMask & (1 << 4)) != 0) { + delta.z = -disp; + deltaPos.z += -100; + deltaDir.z += -5; + deltaSize.z += -1; + } + else if ((keyMask & (1 << 5)) != 0) { + delta.z = disp; + deltaPos.z += 100; + deltaDir.z += 5; + deltaSize.z += 1; } - if (!selectedObjs.isEmpty()) - offsetSelectionBy(finaldelta); - else - { + if (!selectedObjs.isEmpty()) { + unsavedChanges = true; + if ((keyMask & (1 << 6)) != 0) + offsetSelectionBy(deltaPos); + else if ((keyMask & (1 << 7)) != 0) + rotationSelectionBy(deltaDir); + else if ((keyMask & (1 << 8)) != 0) + scaleSelectionBy(deltaSize); + } + else { + finaldelta.x = (float)(-(delta.x * Math.sin(camRotation.x)) - (delta.y * Math.cos(camRotation.x) * Math.sin(camRotation.y)) + (delta.z * Math.cos(camRotation.x) * Math.cos(camRotation.y))); + finaldelta.y = (float)((delta.y * Math.cos(camRotation.y)) + (delta.z * Math.sin(camRotation.y))); + finaldelta.z = (float)((delta.x * Math.cos(camRotation.x)) - (delta.y * Math.sin(camRotation.x) * Math.sin(camRotation.y)) + (delta.z * Math.sin(camRotation.x) * Math.cos(camRotation.y))); camTarget.x += finaldelta.x * 0.005f; camTarget.y += finaldelta.y * 0.005f; camTarget.z += finaldelta.z * 0.005f; updateCamera(); e.getComponent().repaint(); } - keyDelta += disp; } } @Override - public void keyReleased(KeyEvent e) - { - switch (e.getKeyCode()) - { + public void keyReleased(KeyEvent e) { + switch (e.getKeyCode()) { case KeyEvent.VK_LEFT: - case KeyEvent.VK_NUMPAD4: keyMask &= ~1; break; + case KeyEvent.VK_NUMPAD4: + keyMask &= ~1; + break; case KeyEvent.VK_RIGHT: - case KeyEvent.VK_NUMPAD6: keyMask &= ~(1 << 1); break; + case KeyEvent.VK_NUMPAD6: + keyMask &= ~(1 << 1); + break; case KeyEvent.VK_UP: - case KeyEvent.VK_NUMPAD8: keyMask &= ~(1 << 2); break; + case KeyEvent.VK_NUMPAD8: + keyMask &= ~(1 << 2); + break; case KeyEvent.VK_DOWN: - case KeyEvent.VK_NUMPAD2: keyMask &= ~(1 << 3); break; + case KeyEvent.VK_NUMPAD2: + keyMask &= ~(1 << 3); + break; case KeyEvent.VK_PAGE_UP: - case KeyEvent.VK_NUMPAD9: keyMask &= ~(1 << 4); break; + case KeyEvent.VK_NUMPAD9: + keyMask &= ~(1 << 4); + break; case KeyEvent.VK_PAGE_DOWN: - case KeyEvent.VK_END: case KeyEvent.VK_NUMPAD3: - case KeyEvent.VK_NUMPAD1: keyMask &= ~(1 << 5); break; + keyMask &= ~(1 << 5); + break; + case KeyEvent.VK_P: + keyMask &= ~(1 << 6); + break; + case KeyEvent.VK_R: + keyMask &= ~(1 << 7); + break; + case KeyEvent.VK_S: + keyMask &= ~(1 << 8); + break; } if ((keyMask & 0x3F) == 0) @@ -2830,26 +3171,25 @@ public void keyReleased(KeyEvent e) 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; - - public class SubZoneData - { + private LinkedHashMap selectedObjs; + + public class SubZoneData { String layer; - Vector3 position; - Vector3 rotation; + Vector3 position, rotation; } - public HashMap subZoneData; - private GLCanvas glCanvas; private boolean inited; private boolean unsavedChanges; private GLRenderer.RenderInfo renderinfo; - private HashMap objDisplayLists; - private HashMap zoneDisplayLists; - public HashMap globalPathPointList; private Queue rerenderTasks; private int zoneModeLayerBitmask; @@ -2872,48 +3212,54 @@ public class SubZoneData private int underCursor; private float depthUnderCursor; - private LinkedHashMap selectedObjs; private int selectionArg; - private LinkedHashMap displayedPaths; private String objectBeingAdded, addingOnLayer; private boolean deletingObjects; - private boolean duplicatingObjects; private CheckBoxList lbLayersList; private JPopupMenu pmnAddObjects; - private JPopupMenu pmnAddScenario; - private FilesystemBase archive; - private Bcsv bcsv; private PropertyGrid pnlObjectSettings; + 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; private javax.swing.JButton btnAddZone; - private javax.swing.JButton btnClose; private javax.swing.JButton btnDeleteScenario; private javax.swing.JButton btnDeleteZone; private javax.swing.JButton btnDeselect; private javax.swing.JButton btnEditScenario; private javax.swing.JButton btnEditZone; - private javax.swing.JButton btnSave; - private javax.swing.JToggleButton btnShowAllPaths; + private javax.swing.JToggleButton btnShowPaths; + private javax.swing.JMenuItem itemClose; + private javax.swing.JMenuItem itemControls; + private javax.swing.JMenuItem itemPosition; + private javax.swing.JMenuItem itemPositionPaste; + private javax.swing.JMenuItem itemRotation; + private javax.swing.JMenuItem itemRotationPaste; + private javax.swing.JMenuItem itemSave; + private javax.swing.JMenuItem itemScale; + private javax.swing.JMenuItem itemScalePaste; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; + private javax.swing.JMenuBar jMenuBar1; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel3; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JScrollPane jScrollPane3; - private javax.swing.JToolBar.Separator jSeparator1; - 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.Separator jSeparator7; private javax.swing.JSplitPane jSplitPane1; private javax.swing.JSplitPane jSplitPane4; - private javax.swing.JToolBar jToolBar1; private javax.swing.JToolBar jToolBar2; private javax.swing.JToolBar jToolBar3; private javax.swing.JToolBar jToolBar4; @@ -2921,15 +3267,21 @@ public class SubZoneData private javax.swing.JList lbScenarioList; private javax.swing.JLabel lbStatusLabel; private javax.swing.JList lbZoneList; + private javax.swing.JMenu mnuEdit; + private javax.swing.JMenu mnuHelp; + private javax.swing.JMenu mnuSave; private javax.swing.JPanel pnlGLPanel; private javax.swing.JPanel pnlLayersPanel; private javax.swing.JSplitPane pnlScenarioZonePanel; private javax.swing.JScrollPane scpLayersList; private javax.swing.JScrollPane scpObjSettingsContainer; + private javax.swing.JMenu subCopy; + private javax.swing.JMenu subPaste; private javax.swing.JToolBar tbObjToolbar; private javax.swing.JToggleButton tgbAddObject; private javax.swing.JToggleButton tgbDeleteObject; private javax.swing.JToggleButton tgbReverseRot; + private javax.swing.JToggleButton tgbShowAxis; private javax.swing.JToggleButton tgbShowFake; private javax.swing.JTabbedPane tpLeftPanel; private javax.swing.JTree tvObjectList; diff --git a/src/whitehole/LayerForm.java b/src/whitehole/LayerForm.java index e409219..c209db4 100644 --- a/src/whitehole/LayerForm.java +++ b/src/whitehole/LayerForm.java @@ -16,6 +16,7 @@ package whitehole; import java.awt.Toolkit; +import java.awt.event.KeyEvent; public class LayerForm extends javax.swing.JFrame { @@ -118,7 +119,9 @@ private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event }//GEN-LAST:event_formWindowOpened private void txtInputKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtInputKeyReleased - getLayerNo(txtInput.getText()); + if (txtInput.getText().contains("[A-P]")) { + getLayerNo(txtInput.getText()); + } }//GEN-LAST:event_txtInputKeyReleased private void getLayerNo(String field) { diff --git a/src/whitehole/MainFrame.java b/src/whitehole/MainFrame.java index 915dc94..46b59e7 100644 --- a/src/whitehole/MainFrame.java +++ b/src/whitehole/MainFrame.java @@ -208,7 +208,7 @@ private void formWindowOpened(java.awt.event.WindowEvent evt)//GEN-FIRST:event_f this.setIconImage(Toolkit.getDefaultToolkit().createImage(Whitehole.class.getResource("/Resources/icon.png"))); lbStatusBar.setText("Ready"); - if (Settings.objectDBUpdate) + if (Settings.objectDB_update) { lbStatusBar.setText("Checking for object database updates..."); ObjectDBUpdater updater = new ObjectDBUpdater(lbStatusBar); diff --git a/src/whitehole/ObjectDBUpdater.java b/src/whitehole/ObjectDBUpdater.java index d570886..370cbca 100644 --- a/src/whitehole/ObjectDBUpdater.java +++ b/src/whitehole/ObjectDBUpdater.java @@ -36,7 +36,7 @@ public void run() try { String ts = String.format("&ts=%1$d", ObjectDB.timestamp); - URL url = new URL ("http://neomariogalaxy.bplaced.net/board/objectdb/smg_download.php?whitehole&gzip" + ts); + URL url = new URL (Settings.objectDB_url + "?whitehole&gzip" + ts); URLConnection conn = url.openConnection(); DataInputStream dis = new DataInputStream(conn.getInputStream()); diff --git a/src/whitehole/PropertyGrid.java b/src/whitehole/PropertyGrid.java index a39c7d8..82cd1e9 100644 --- a/src/whitehole/PropertyGrid.java +++ b/src/whitehole/PropertyGrid.java @@ -121,16 +121,29 @@ public void addField(String name, String caption, String type, java.util.List ch { case "text": case "int": - field.editor = new TextCellEditor(field); + field.editor = new TextCellEditor(field, true); + break; + + case "noedit": + field.editor = new TextCellEditor(field, false); break; case "float": field.renderer = new FloatCellRenderer(); - field.editor = new FloatCellEditor(field); + field.editor = new FloatCellEditor(field, true); + break; + + case "float_noedit": + field.renderer = new FloatCellRenderer(); + field.editor = new FloatCellEditor(field, false); break; case "list": - field.editor = new ListCellEditor(field); + field.editor = new ListCellEditor(field, false); + break; + + case "textlist": + field.editor = new ListCellEditor(field, true); break; case "bool": @@ -424,12 +437,13 @@ public class FloatCellEditor extends AbstractCellEditor implements TableCellEdit JSpinner spinner; Field field; - public FloatCellEditor(Field f) + public FloatCellEditor(Field f, boolean e) { 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() { @Override @@ -464,12 +478,13 @@ public class TextCellEditor extends AbstractCellEditor implements TableCellEdito Field field; boolean isInt; - public TextCellEditor(Field f) + public TextCellEditor(Field f, boolean e) { field = f; isInt = f.type.equals("int"); textfield = new JTextField(f.value.toString()); + textfield.setEnabled(e); textfield.addKeyListener(new KeyListener() { @Override @@ -516,11 +531,12 @@ public class ListCellEditor extends AbstractCellEditor implements TableCellEdito JComboBox combo; Field field; - public ListCellEditor(Field f) + public ListCellEditor(Field f, boolean e) { field = f; combo = new JComboBox(f.choices.toArray()); + combo.setEditable(e); combo.addActionListener(new ActionListener() { @Override diff --git a/src/whitehole/Settings.java b/src/whitehole/Settings.java index 77165c0..bad8d91 100644 --- a/src/whitehole/Settings.java +++ b/src/whitehole/Settings.java @@ -22,39 +22,36 @@ public class Settings public static void initialize() { Preferences prefs = Preferences.userRoot(); - objectDBUpdate = prefs.getBoolean("ObjectDBUpdate", true); - yaz0enc = prefs.getBoolean("Yaz0Enc", true); - - useShaders = prefs.getBoolean("UseShaders", true); - fastDrag = prefs.getBoolean("FastDrag", false); - reverseRot = prefs.getBoolean("ReverseRot", false); - - themeMetal = prefs.getBoolean("ThemeMetal", false); - themeSystem = prefs.getBoolean("ThemeSystem", true); + objectDB_url = prefs.get("objectDB.url", "http://neomariogalaxy.bplaced.net/objectdb/smg_download.php"); + objectDB_update = prefs.getBoolean("objectDB.update", true); + arc_enc = prefs.getBoolean("arc.enc", true); + editor_areas = prefs.getBoolean("editor.areas", false); + editor_shaders = prefs.getBoolean("editor.shaders", true); + editor_fastDrag = prefs.getBoolean("editor.fastDrag", false); + editor_reverseRot = prefs.getBoolean("editor.reverseRot", false); + theme_system = prefs.getBoolean("theme.system", true); } public static void save() { Preferences prefs = Preferences.userRoot(); - prefs.putBoolean("ObjectDBUpdate", objectDBUpdate); - prefs.putBoolean("Yaz0enc", yaz0enc); - - prefs.putBoolean("UseShaders", useShaders); - prefs.putBoolean("FastDrag", fastDrag); - prefs.putBoolean("ReverseRot", reverseRot); - - prefs.putBoolean("ThemeMetal", themeMetal); - prefs.putBoolean("ThemeSystem", themeSystem); + prefs.put("objectDB.url", objectDB_url); + prefs.putBoolean("objectDB.update", objectDB_update); + prefs.putBoolean("arc.enc", arc_enc); + prefs.putBoolean("editor.areas", editor_areas); + prefs.putBoolean("editor.shaders", editor_shaders); + prefs.putBoolean("editor.fastDrag", editor_fastDrag); + prefs.putBoolean("editor.reverseRot", editor_reverseRot); + prefs.putBoolean("theme.system", theme_system); } - public static boolean objectDBUpdate; - public static boolean yaz0enc; - - public static boolean useShaders; - public static boolean fastDrag; - public static boolean reverseRot; - - public static boolean themeMetal; - public static boolean themeSystem; -} + 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; +} \ No newline at end of file diff --git a/src/whitehole/SettingsForm.form b/src/whitehole/SettingsForm.form index 112b50b..7289bc5 100644 --- a/src/whitehole/SettingsForm.form +++ b/src/whitehole/SettingsForm.form @@ -1,12 +1,6 @@ - - - - - - @@ -34,45 +28,37 @@ - + + + + + + + + + + + + + + + + + + - - - - - - - - + + - - - - - - - - - - - - - - - - - - - @@ -81,12 +67,19 @@ + + - + - + - + + + + + + @@ -95,10 +88,8 @@ - - - - + + @@ -169,22 +160,6 @@ - - - - - - - - - - - - - - - - @@ -198,5 +173,22 @@ + + + + + + + + + + + + + + + + + diff --git a/src/whitehole/SettingsForm.java b/src/whitehole/SettingsForm.java index 65601fe..c0dd41f 100644 --- a/src/whitehole/SettingsForm.java +++ b/src/whitehole/SettingsForm.java @@ -32,8 +32,6 @@ public SettingsForm(java.awt.Frame parent, boolean modal) // //GEN-BEGIN:initComponents private void initComponents() { - buttonGroup1 = new javax.swing.ButtonGroup(); - buttonGroup2 = new javax.swing.ButtonGroup(); chkObjectDBUpdate = new javax.swing.JCheckBox(); chkUseShaders = new javax.swing.JCheckBox(); chkFastDrag = new javax.swing.JCheckBox(); @@ -42,10 +40,12 @@ private void initComponents() { lblObjectDatabase = new javax.swing.JLabel(); lblRendering = new javax.swing.JLabel(); lblObjectDatabase1 = new javax.swing.JLabel(); - radThemeSys = new javax.swing.JRadioButton(); - radThemeJava = new javax.swing.JRadioButton(); jLabel1 = new javax.swing.JLabel(); chkYaz0 = new javax.swing.JCheckBox(); + jLabel2 = new javax.swing.JLabel(); + txtObjectDBUrl = new javax.swing.JTextField(); + chkThemeSystem = new javax.swing.JCheckBox(); + chkAreaRender = new javax.swing.JCheckBox(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle("Settings"); @@ -85,51 +85,47 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { lblObjectDatabase1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N lblObjectDatabase1.setText("Theme"); - buttonGroup2.add(radThemeSys); - radThemeSys.setText("System"); - - buttonGroup2.add(radThemeJava); - radThemeJava.setText("Java L&F"); - jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N jLabel1.setText("Saving"); chkYaz0.setText("Yaz0 encode when saving"); + jLabel2.setText("Update URL"); + + chkThemeSystem.setText("System"); + + chkAreaRender.setText("Show area size"); + 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(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(btnOk) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(btnCancel)) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(lblRendering) + .addComponent(chkUseShaders) + .addComponent(chkFastDrag) + .addComponent(chkAreaRender) + .addComponent(lblObjectDatabase) + .addComponent(chkThemeSystem) + .addComponent(chkYaz0) + .addComponent(lblObjectDatabase1) + .addComponent(jLabel1) .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addComponent(lblObjectDatabase)) - .addGroup(layout.createSequentialGroup() - .addGap(10, 10, 10) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(chkUseShaders) - .addComponent(chkFastDrag)))) - .addGap(0, 0, Short.MAX_VALUE)) - .addGroup(layout.createSequentialGroup() - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(btnOk) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(btnCancel))) + .addComponent(jLabel2) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(txtObjectDBUrl, javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(chkObjectDBUpdate)) + .addGap(0, 0, Short.MAX_VALUE))) .addContainerGap()) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(chkYaz0) - .addComponent(radThemeJava) - .addComponent(radThemeSys) - .addComponent(chkObjectDBUpdate) - .addComponent(lblRendering) - .addComponent(lblObjectDatabase1) - .addComponent(jLabel1)) - .addGap(0, 8, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -137,12 +133,18 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addGap(17, 17, 17) .addComponent(lblRendering) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(chkAreaRender) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(chkUseShaders, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(chkFastDrag) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(lblObjectDatabase) - .addGap(1, 1, 1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel2) + .addComponent(txtObjectDBUrl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(chkObjectDBUpdate) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel1) @@ -151,10 +153,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(lblObjectDatabase1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(radThemeSys) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(radThemeJava) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(chkThemeSystem) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(btnCancel) .addComponent(btnOk)) @@ -166,12 +166,17 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { private void formWindowOpened(java.awt.event.WindowEvent evt)//GEN-FIRST:event_formWindowOpened {//GEN-HEADEREND:event_formWindowOpened - chkObjectDBUpdate.setSelected(Settings.objectDBUpdate); - chkUseShaders.setSelected(Settings.useShaders); - chkFastDrag.setSelected(Settings.fastDrag); - chkYaz0.setSelected(Settings.yaz0enc); - radThemeSys.setSelected(Settings.themeSystem); - radThemeJava.setSelected(Settings.themeMetal); + // 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 @@ -181,12 +186,13 @@ private void btnCancelActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST private void btnOkActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnOkActionPerformed {//GEN-HEADEREND:event_btnOkActionPerformed - Settings.objectDBUpdate = chkObjectDBUpdate.isSelected(); - Settings.useShaders = chkUseShaders.isSelected(); - Settings.fastDrag = chkFastDrag.isSelected(); - Settings.yaz0enc = chkYaz0.isSelected(); - Settings.themeSystem = radThemeSys.isSelected(); - Settings.themeMetal = radThemeJava.isSelected(); + Settings.objectDB_url = txtObjectDBUrl.getText(); + Settings.objectDB_update = chkObjectDBUpdate.isSelected(); + Settings.editor_areas = chkAreaRender.isSelected(); + Settings.editor_shaders = chkUseShaders.isSelected(); + Settings.editor_fastDrag = chkFastDrag.isSelected(); + Settings.arc_enc = chkYaz0.isSelected(); + Settings.theme_system = chkThemeSystem.isSelected(); Settings.save(); dispose(); }//GEN-LAST:event_btnOkActionPerformed @@ -194,17 +200,17 @@ private void btnOkActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:eve // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btnCancel; private javax.swing.JButton btnOk; - private javax.swing.ButtonGroup buttonGroup1; - private javax.swing.ButtonGroup buttonGroup2; + private javax.swing.JCheckBox chkAreaRender; private javax.swing.JCheckBox chkFastDrag; private javax.swing.JCheckBox chkObjectDBUpdate; + private javax.swing.JCheckBox chkThemeSystem; private javax.swing.JCheckBox chkUseShaders; private javax.swing.JCheckBox chkYaz0; private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; private javax.swing.JLabel lblObjectDatabase; private javax.swing.JLabel lblObjectDatabase1; private javax.swing.JLabel lblRendering; - private javax.swing.JRadioButton radThemeJava; - private javax.swing.JRadioButton radThemeSys; + private javax.swing.JTextField txtObjectDBUrl; // End of variables declaration//GEN-END:variables } diff --git a/src/whitehole/Whitehole.java b/src/whitehole/Whitehole.java index 97a66de..d6f2edd 100644 --- a/src/whitehole/Whitehole.java +++ b/src/whitehole/Whitehole.java @@ -31,7 +31,7 @@ public class Whitehole { public static final String name = "Whitehole"; - public static final String version = "v1.4.2.2"; + 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/"; @@ -63,18 +63,18 @@ public static void doRun() Settings.initialize(); Bcsv.populateHashTable(); - ObjectDB.initialize(); TextureCache.initialize(); ShaderCache.initialize(); RendererCache.initialize(); + ObjectDB.initialize(); try { - if (Settings.themeMetal) { - UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); + if (Settings.theme_system) { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } else { - UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); } } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) diff --git a/src/whitehole/fileio/Yaz0File.java b/src/whitehole/fileio/Yaz0File.java index c84a289..ac8a299 100644 --- a/src/whitehole/fileio/Yaz0File.java +++ b/src/whitehole/fileio/Yaz0File.java @@ -34,7 +34,7 @@ public Yaz0File(FileBase backendfile) throws IOException public void save() throws IOException { byte[] compbuffer; - if (Settings.yaz0enc) { + if (Settings.arc_enc) { compbuffer = Yaz0.compress(buffer); } else { diff --git a/src/whitehole/rendering/AreaCubeRenderer.java b/src/whitehole/rendering/AreaCubeRenderer.java deleted file mode 100644 index 2fb6827..0000000 --- a/src/whitehole/rendering/AreaCubeRenderer.java +++ /dev/null @@ -1,144 +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 javax.media.opengl.GL2; -import javax.media.opengl.GLException; -import whitehole.vectors.*; - -public class AreaCubeRenderer extends GLRenderer -{ - public AreaCubeRenderer(float size, Color4 border, Color4 fill, boolean axes) - { - cubeSize = size; - borderColor = border; - fillColor = fill; - } - - @Override - public void close(GLRenderer.RenderInfo info) throws GLException - { - } - - @Override - public boolean isScaled() - { - return true; - } - - @Override - public boolean gottaRender(GLRenderer.RenderInfo info) throws GLException - { - return info.renderMode != GLRenderer.RenderMode.TRANSLUCENT; - } - - @Override - public void render(GLRenderer.RenderInfo info) throws GLException - { - if (info.renderMode == GLRenderer.RenderMode.TRANSLUCENT) return; - - float s = cubeSize / 0.2f; - GL2 gl = info.drawable.getGL().getGL2(); - - if (info.renderMode != GLRenderer.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(fillColor.r, fillColor.g, fillColor.b, fillColor.a); - gl.glDisable(GL2.GL_LIGHTING); - 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) { } - } - - // 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); - - gl.glBegin(GL2.GL_TRIANGLE_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.glEnd(); - - gl.glBegin(GL2.GL_TRIANGLE_STRIP); - gl.glVertex3f(-s, s, -s); - gl.glVertex3f(-s, s, s); - gl.glVertex3f(s, s, -s); - gl.glVertex3f(s, s, s); - gl.glEnd(); - - gl.glBegin(GL2.GL_TRIANGLE_STRIP); - gl.glVertex3f(-s, -s, -s); - gl.glVertex3f(s, -s, -s); - gl.glVertex3f(-s, -s, s); - gl.glVertex3f(s, -s, s); - gl.glEnd(); - - if (info.renderMode != GLRenderer.RenderMode.PICKING) - { - gl.glLineWidth(1.5f); - gl.glColor4f(borderColor.r, borderColor.g, borderColor.b, borderColor.a); - - 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.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.glEnd(); - } - } - - - private float cubeSize; - private Color4 borderColor, fillColor; -} diff --git a/src/whitehole/rendering/AreaShapeRenderer.java b/src/whitehole/rendering/AreaShapeRenderer.java new file mode 100644 index 0000000..216d924 --- /dev/null +++ b/src/whitehole/rendering/AreaShapeRenderer.java @@ -0,0 +1,156 @@ +/* + © 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 javax.media.opengl.GL2; +import javax.media.opengl.GLException; +import javax.media.opengl.glu.GLU; +import javax.media.opengl.glu.GLUquadric; +import whitehole.vectors.*; + +public class AreaShapeRenderer extends GLRenderer { + public AreaShapeRenderer(Color4 color, short shape) { + areaColor = color; + areaShape = shape; + } + + @Override + public void close(GLRenderer.RenderInfo info) throws GLException { + } + + @Override + public boolean isScaled() { + return true; + } + + @Override + public boolean gottaRender(GLRenderer.RenderInfo info) throws GLException { + return info.renderMode != GLRenderer.RenderMode.TRANSLUCENT; + } + + @Override + public void render(GLRenderer.RenderInfo info) throws GLException { + if (info.renderMode == GLRenderer.RenderMode.TRANSLUCENT) + return; + + GL2 gl = info.drawable.getGL().getGL2(); + + if (info.renderMode != GLRenderer.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.glColor3f(areaColor.r, areaColor.g, areaColor.b); + try { + gl.glUseProgram(0); + } + catch (GLException ex) { + } + } + + // Preparing area shape + gl.glEnable(GL2.GL_DEPTH_TEST); + gl.glCullFace(GL2.GL_FRONT); + gl.glLineWidth(3f); + + // 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; + } + + // Reset line width + gl.glLineWidth(1.5f); + } + + public void makeBox(GLRenderer.RenderInfo info) { + GL2 gl = info.drawable.getGL().getGL2(); + + gl.glTranslatef(0f, 500f, 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.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.glEnd(); + gl.glTranslatef(0f, 0f, 0f); + } + + public void makeSphere(GLRenderer.RenderInfo info) { + GL2 gl = info.drawable.getGL().getGL2(); + + gl.glTranslatef(0f, 0f, 0f); + gl.glRotatef(0f,0f,0f,1f); + gl.glRotatef(0f,0f,1f,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.gluDeleteQuadric(sphere); + gl.glTranslatef(0f, 0f, 0f); + } + + public void makeCylinder(GLRenderer.RenderInfo info) { + GL2 gl = info.drawable.getGL().getGL2(); + + gl.glTranslatef(0f, 1000f, 0f); + gl.glRotatef(0f,0f,0f,1f); + gl.glRotatef(0f,0f,1f,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.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(); +} \ No newline at end of file diff --git a/src/whitehole/rendering/BmdRenderer.java b/src/whitehole/rendering/BmdRenderer.java index 72be9ae..f0ca8ae 100644 --- a/src/whitehole/rendering/BmdRenderer.java +++ b/src/whitehole/rendering/BmdRenderer.java @@ -559,9 +559,11 @@ else if (container.fileExists("/" + modelname + "/" + modelname + ".bmd")) } catch (IOException ex) { - if (container != null) try { container.close(); } catch (IOException ex2) {} + if (container != null) try { container.close(); } catch (IOException ex2) { + } throw new GLException("Failed to load model "+modelname+": "+ex.getMessage()); + } bva = null; @@ -584,7 +586,7 @@ protected final void ctor_uploadData(RenderInfo info) throws GLException extensions.contains("GL_ARB_shader_objects") && extensions.contains("GL_ARB_vertex_shader") && extensions.contains("GL_ARB_fragment_shader"); - hasShaders = hasShaders && Settings.useShaders; + hasShaders = hasShaders && Settings.editor_shaders; textures = new int[model.textures.length]; for (int i = 0; i < model.textures.length; i++) diff --git a/src/whitehole/rendering/ColorCubeRenderer.java b/src/whitehole/rendering/ColorCubeRenderer.java index 56a846a..20ff175 100644 --- a/src/whitehole/rendering/ColorCubeRenderer.java +++ b/src/whitehole/rendering/ColorCubeRenderer.java @@ -19,10 +19,8 @@ import javax.media.opengl.GLException; import whitehole.vectors.*; -public class ColorCubeRenderer extends GLRenderer -{ - public ColorCubeRenderer(float size, Color4 border, Color4 fill, boolean axes) - { +public class ColorCubeRenderer extends GLRenderer { + public ColorCubeRenderer(float size, Color4 border, Color4 fill, boolean axes) { cubeSize = size; borderColor = border; fillColor = fill; @@ -30,43 +28,35 @@ 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() - { + public boolean isScaled() { return false; } @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 - { + public void render(RenderInfo info) throws GLException { if (info.renderMode == RenderMode.TRANSLUCENT) return; float s = cubeSize / 2f; 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(fillColor.r, fillColor.g, fillColor.b, fillColor.a); @@ -74,7 +64,11 @@ 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.glUseProgram(0); + } + catch (GLException ex) { + } } // we do this because the cube rendering was copypasted from SM64DSe @@ -110,8 +104,7 @@ public void render(RenderInfo info) throws GLException gl.glVertex3f(s, -s, s); gl.glEnd(); - if (info.renderMode != RenderMode.PICKING) - { + if (info.renderMode != RenderMode.PICKING) { gl.glLineWidth(1.5f); gl.glColor4f(borderColor.r, borderColor.g, borderColor.b, borderColor.a); @@ -137,8 +130,7 @@ public void render(RenderInfo info) throws GLException gl.glVertex3f(s, -s, -s); gl.glEnd(); - if (showAxes) - { + if (showAxes) { gl.glBegin(GL2.GL_LINES); gl.glColor3f(1.0f, 0.0f, 0.0f); gl.glVertex3f(0.0f, 0.0f, 0.0f); @@ -161,4 +153,4 @@ public void render(RenderInfo info) throws GLException private float cubeSize; private Color4 borderColor, fillColor; private boolean showAxes; -} +} \ No newline at end of file diff --git a/src/whitehole/rendering/GLRenderer.java b/src/whitehole/rendering/GLRenderer.java index c59e6d9..f5780cd 100644 --- a/src/whitehole/rendering/GLRenderer.java +++ b/src/whitehole/rendering/GLRenderer.java @@ -42,6 +42,7 @@ 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 gottaRender(RenderInfo info) throws GLException { return false; } public void render(RenderInfo info) throws GLException {} diff --git a/src/whitehole/rendering/RendererCache.java b/src/whitehole/rendering/RendererCache.java index ca2ee4a..ba75157 100644 --- a/src/whitehole/rendering/RendererCache.java +++ b/src/whitehole/rendering/RendererCache.java @@ -65,10 +65,10 @@ public static GLRenderer getObjectRenderer(GLRenderer.RenderInfo info, LevelObje loadPlanetList(); String modelname = obj.name; - modelname = ObjectModelSubstitutor.substituteModelName(obj, modelname); + modelname = Substitutor.substituteModelName(obj, modelname); String key = "object_" + obj.name; - key = ObjectModelSubstitutor.substituteObjectKey(obj, key); + key = Substitutor.substituteObjectKey(obj, key); if (cache.containsKey(key)) { @@ -80,7 +80,7 @@ public static GLRenderer getObjectRenderer(GLRenderer.RenderInfo info, LevelObje CacheEntry entry = new CacheEntry(); entry.refCount = 1; - entry.renderer = ObjectModelSubstitutor.substituteRenderer(obj, info); + entry.renderer = Substitutor.substituteRenderer(obj, info); // if no renderer substitution happened, load the default renderer if (entry.renderer == null) @@ -111,7 +111,7 @@ public static GLRenderer getObjectRenderer(GLRenderer.RenderInfo info, LevelObje public static void closeObjectRenderer(GLRenderer.RenderInfo info, LevelObject obj) { String key = "object_" + obj.oldname; - key = ObjectModelSubstitutor.substituteObjectKey(obj, key); + key = Substitutor.substituteObjectKey(obj, key); if (!cache.containsKey(key)) return; CacheEntry entry = cache.get(key); diff --git a/src/whitehole/rendering/ShapeModelRenderer.java b/src/whitehole/rendering/ShapeModelRenderer.java new file mode 100644 index 0000000..104309b --- /dev/null +++ b/src/whitehole/rendering/ShapeModelRenderer.java @@ -0,0 +1,31 @@ +/* + © 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; + +public class ShapeModelRenderer extends BmdRenderer { + + public ShapeModelRenderer(RenderInfo info, String objname, short modelno) { + if (modelno < 100 && modelno > -1) { + ctor_loadModel(info, objname + String.format("%1$02d",modelno)); + ctor_uploadData(info); + } + } + + @Override + public boolean boundToShapeModel() { + return true; + } +} \ No newline at end of file diff --git a/src/whitehole/rendering/SingleBmdRenderer.java b/src/whitehole/rendering/SingleBmdRenderer.java new file mode 100644 index 0000000..bcd8598 --- /dev/null +++ b/src/whitehole/rendering/SingleBmdRenderer.java @@ -0,0 +1,52 @@ +/* + © 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/ObjectModelSubstitutor.java b/src/whitehole/rendering/Substitutor.java similarity index 73% rename from src/whitehole/rendering/ObjectModelSubstitutor.java rename to src/whitehole/rendering/Substitutor.java index 3564538..52d0058 100644 --- a/src/whitehole/rendering/ObjectModelSubstitutor.java +++ b/src/whitehole/rendering/Substitutor.java @@ -15,13 +15,14 @@ package whitehole.rendering; -import whitehole.rendering.objRenderer.AstroPart; -import whitehole.rendering.objRenderer.AstroSky; -import whitehole.rendering.objRenderer.Pole; -import whitehole.rendering.objRenderer.PowerStar; -import whitehole.rendering.objRenderer.Kinopio; -import whitehole.rendering.objRenderer.SuperSpinDriver; -import whitehole.rendering.objRenderer.UFOKinoko; +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; @@ -36,13 +37,13 @@ import whitehole.vectors.Color4; import whitehole.vectors.Vector3; import java.io.IOException; +import static whitehole.Settings.editor_areas; +import whitehole.smg.ZoneArchive; -public class ObjectModelSubstitutor -{ - public static String substituteModelName(LevelObject obj, String modelname) - { - switch (obj.name) - { +public class Substitutor { + + public static String substituteModelName(LevelObject obj, String modelname) { + switch (obj.name) { case "ArrowSwitchMulti": return "ArrowSwitch"; case "AstroDomeBlueStar": return "GCaptureTarget"; case "AttackRockFinal": @@ -63,7 +64,6 @@ public static String substituteModelName(LevelObject obj, String modelname) case "CutBushGroup": return "CutBush"; case "DemoKoopaJrShip": return "KoopaJrShip"; case "DharmaSambo": return "DharmaSamboParts"; - case "EarthenPipeInWater": return "EarthenPipe"; case "FireBallBeamKameck": return "Kameck"; case "FirePressureRadiate": return "FirePressure"; case "FishGroupA": return "FishA"; @@ -124,6 +124,7 @@ public static String substituteModelName(LevelObject obj, String modelname) 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"; @@ -210,59 +211,110 @@ public static String substituteModelName(LevelObject obj, String modelname) return modelname; } - public static String substituteObjectKey(LevelObject obj, String objectkey) - { - switch (obj.name) - { + 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("object_Kinopio_%1$d", obj.data.get("Obj_arg1")); break; - case "UFOKinoko": objectkey = String.format("object_UFOKinoko_%1$d", obj.data.get("Obj_arg0")); break; + 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) - { - try - { - 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); + 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 PowerStar(info, 0); - case "GreenStar": return new PowerStar(info, 1); - case "SuperSpinDriverPink": return new SuperSpinDriver(info,0); - case "SuperSpinDriverGreen": return new SuperSpinDriver(info,1); + 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 Kinopio(info, (int)obj.data.get("Obj_arg1")); - case "KinopioBank": return new Kinopio(info, 1); - case "KinopioPostman": return new Kinopio(info, 2); - case "UFOKinoko": return new UFOKinoko(info, (int)obj.data.get("Obj_arg0")); + 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 "Pole": return new Pole(info, obj.scale, "Pole"); - case "PoleSquare": return new Pole(info, obj.scale, "PoleSquare"); - case "Pole2Way": return new Pole(info, obj.scale, "PoleSquare"); + 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()); @@ -279,8 +331,8 @@ public static GLRenderer substituteRenderer(LevelObject obj, GLRenderer.RenderIn case "AstroStarPlate": case "AstroDome": - case "AstroDomeEntrance": return new AstroPart(info, obj.name, (int)obj.data.get("Obj_arg0")); - case "AstroDomeSky": return new AstroSky(info, obj.name, (int)obj.data.get("Obj_arg0")); + 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()); @@ -305,14 +357,15 @@ public static GLRenderer substituteRenderer(LevelObject obj, GLRenderer.RenderIn 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) {} + catch (IOException ex) { + } return null; - } -} +} \ No newline at end of file diff --git a/src/whitehole/rendering/objRenderer/AstroPart.java b/src/whitehole/rendering/object/ObjectAstroPart.java similarity index 86% rename from src/whitehole/rendering/objRenderer/AstroPart.java rename to src/whitehole/rendering/object/ObjectAstroPart.java index 4ec2229..068ccf0 100644 --- a/src/whitehole/rendering/objRenderer/AstroPart.java +++ b/src/whitehole/rendering/object/ObjectAstroPart.java @@ -13,13 +13,13 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.rendering.objRenderer; +package whitehole.rendering.object; import whitehole.rendering.BmdRenderer; -public class AstroPart extends BmdRenderer +public class ObjectAstroPart extends BmdRenderer { - public AstroPart(RenderInfo info, String objname, int arg0) + public ObjectAstroPart(RenderInfo info, String objname, int arg0) { String[] parts = {"Observatory", "Well", "Kitchen", "BedRoom", "Machine", "Tower"}; if (arg0 < 1 || arg0 > 6) arg0 = 1; diff --git a/src/whitehole/rendering/objRenderer/AstroSky.java b/src/whitehole/rendering/object/ObjectAstroSky.java similarity index 86% rename from src/whitehole/rendering/objRenderer/AstroSky.java rename to src/whitehole/rendering/object/ObjectAstroSky.java index e9283bb..333bbd2 100644 --- a/src/whitehole/rendering/objRenderer/AstroSky.java +++ b/src/whitehole/rendering/object/ObjectAstroSky.java @@ -13,13 +13,13 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.rendering.objRenderer; +package whitehole.rendering.object; import whitehole.rendering.BmdRenderer; -public class AstroSky extends BmdRenderer +public class ObjectAstroSky extends BmdRenderer { - public AstroSky(RenderInfo info, String objname, int arg0) + public ObjectAstroSky(RenderInfo info, String objname, int arg0) { String[] parts = {"A", "B", "C", "A", "B", "C"}; if (arg0 < 1 || arg0 > 6) arg0 = 1; diff --git a/src/whitehole/rendering/objRenderer/Kinopio.java b/src/whitehole/rendering/object/ObjectKinopio.java similarity index 93% rename from src/whitehole/rendering/objRenderer/Kinopio.java rename to src/whitehole/rendering/object/ObjectKinopio.java index 9efb958..414c982 100644 --- a/src/whitehole/rendering/objRenderer/Kinopio.java +++ b/src/whitehole/rendering/object/ObjectKinopio.java @@ -13,13 +13,13 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.rendering.objRenderer; +package whitehole.rendering.object; import whitehole.rendering.BmdRenderer; -public class Kinopio extends BmdRenderer +public class ObjectKinopio extends BmdRenderer { - public Kinopio(RenderInfo info, int color) + public ObjectKinopio(RenderInfo info, int color) { ctor_loadModel(info, "Kinopio"); diff --git a/src/whitehole/rendering/object/ObjectOtaKing.java b/src/whitehole/rendering/object/ObjectOtaKing.java new file mode 100644 index 0000000..413211e --- /dev/null +++ b/src/whitehole/rendering/object/ObjectOtaKing.java @@ -0,0 +1,37 @@ +/* + © 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/objRenderer/Pole.java b/src/whitehole/rendering/object/ObjectPole.java similarity index 88% rename from src/whitehole/rendering/objRenderer/Pole.java rename to src/whitehole/rendering/object/ObjectPole.java index 0c24903..b613b02 100644 --- a/src/whitehole/rendering/objRenderer/Pole.java +++ b/src/whitehole/rendering/object/ObjectPole.java @@ -13,16 +13,16 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.rendering.objRenderer; +package whitehole.rendering.object; import java.io.IOException; import javax.media.opengl.*; import whitehole.rendering.BmdRenderer; import whitehole.vectors.Vector3; -public class Pole extends BmdRenderer +public class ObjectPole extends BmdRenderer { - public Pole(RenderInfo info, Vector3 scale, String type) throws IOException + public ObjectPole(RenderInfo info, Vector3 scale, String type) throws IOException { super(info, type); myscale = scale; diff --git a/src/whitehole/rendering/objRenderer/PowerStar.java b/src/whitehole/rendering/object/ObjectPowerStar.java similarity index 89% rename from src/whitehole/rendering/objRenderer/PowerStar.java rename to src/whitehole/rendering/object/ObjectPowerStar.java index fac878b..206c0a0 100644 --- a/src/whitehole/rendering/objRenderer/PowerStar.java +++ b/src/whitehole/rendering/object/ObjectPowerStar.java @@ -13,13 +13,13 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.rendering.objRenderer; +package whitehole.rendering.object; import whitehole.rendering.BmdRenderer; -public class PowerStar extends BmdRenderer +public class ObjectPowerStar extends BmdRenderer { - public PowerStar(RenderInfo info, int type) + public ObjectPowerStar(RenderInfo info, int type) { ctor_loadModel(info, "PowerStar"); diff --git a/src/whitehole/rendering/objRenderer/SuperSpinDriver.java b/src/whitehole/rendering/object/ObjectSuperSpinDriver.java similarity index 91% rename from src/whitehole/rendering/objRenderer/SuperSpinDriver.java rename to src/whitehole/rendering/object/ObjectSuperSpinDriver.java index d2a65fd..8114499 100644 --- a/src/whitehole/rendering/objRenderer/SuperSpinDriver.java +++ b/src/whitehole/rendering/object/ObjectSuperSpinDriver.java @@ -13,13 +13,13 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.rendering.objRenderer; +package whitehole.rendering.object; import whitehole.rendering.BmdRenderer; -public class SuperSpinDriver extends BmdRenderer +public class ObjectSuperSpinDriver extends BmdRenderer { - public SuperSpinDriver(RenderInfo info, int type) + public ObjectSuperSpinDriver(RenderInfo info, int type) { ctor_loadModel(info, "SuperSpinDriver"); diff --git a/src/whitehole/rendering/objRenderer/UFOKinoko.java b/src/whitehole/rendering/object/ObjectUFOKinoko.java similarity index 94% rename from src/whitehole/rendering/objRenderer/UFOKinoko.java rename to src/whitehole/rendering/object/ObjectUFOKinoko.java index e563e02..310490c 100644 --- a/src/whitehole/rendering/objRenderer/UFOKinoko.java +++ b/src/whitehole/rendering/object/ObjectUFOKinoko.java @@ -13,13 +13,13 @@ with Whitehole. If not, see http://www.gnu.org/licenses/. */ -package whitehole.rendering.objRenderer; +package whitehole.rendering.object; import whitehole.rendering.BmdRenderer; -public class UFOKinoko extends BmdRenderer +public class ObjectUFOKinoko extends BmdRenderer { - public UFOKinoko(RenderInfo info, int color) + public ObjectUFOKinoko(RenderInfo info, int color) { ctor_loadModel(info, "UFOKinoko"); diff --git a/src/whitehole/smg/LevelObject.java b/src/whitehole/smg/LevelObject.java index 259ce2e..6ca93e9 100644 --- a/src/whitehole/smg/LevelObject.java +++ b/src/whitehole/smg/LevelObject.java @@ -22,17 +22,15 @@ import whitehole.rendering.RendererCache; import whitehole.vectors.Vector3; -public class LevelObject -{ - public void save() {} +public class LevelObject { + public void save() { + } - public final void loadDBInfo() - { + public final void loadDBInfo() { if (ObjectDB.objects.containsKey(name)) dbInfo = ObjectDB.objects.get(name); - else - { + else { dbInfo = new ObjectDB.Object(); dbInfo.ID = name; dbInfo.name = "("+name+")"; @@ -41,23 +39,25 @@ public final void loadDBInfo() } } - public void initRenderer(GLRenderer.RenderInfo info) - { - if (renderer != null) return; + public void getShapeModels() { + } + + public void initRenderer(GLRenderer.RenderInfo info) { + if (renderer != null) + return; renderer = RendererCache.getObjectRenderer(info, this); renderer.compileDisplayLists(info); renderer.releaseStorage(); } - public void closeRenderer(GLRenderer.RenderInfo info) - { - if (renderer == null) return; + public void closeRenderer(GLRenderer.RenderInfo info) { + if (renderer == null) + return; RendererCache.closeObjectRenderer(info, this); renderer = null; } - public void render(GLRenderer.RenderInfo info) - { + public void render(GLRenderer.RenderInfo info) { GL2 gl = info.drawable.getGL().getGL2(); gl.glPushMatrix(); @@ -70,23 +70,21 @@ public void render(GLRenderer.RenderInfo info) gl.glScalef(scale.x, scale.y, scale.z); int dlid = -1; - switch (info.renderMode) - { + switch (info.renderMode) { case PICKING: dlid = 0; break; case OPAQUE: dlid = 1; break; case TRANSLUCENT: dlid = 2; break; } gl.glCallList(renderer.displayLists[dlid]); - gl.glPopMatrix(); } - public void getProperties(PropertyGrid panel) {} + public void getProperties(PropertyGrid panel) { + } @Override - public String toString() - { + public String toString() { return "LevelObject (did someone forget to override this?)"; } diff --git a/src/whitehole/smg/ZoneArchive.java b/src/whitehole/smg/ZoneArchive.java index 361f5ce..4097089 100644 --- a/src/whitehole/smg/ZoneArchive.java +++ b/src/whitehole/smg/ZoneArchive.java @@ -27,18 +27,17 @@ 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 java.io.*; import java.util.*; import javax.swing.JOptionPane; import whitehole.Whitehole; import whitehole.fileio.*; -import whitehole.smg.object.ChildObj; -import whitehole.smg.object.StageObj; -public class ZoneArchive -{ - public ZoneArchive(GalaxyArchive arc, String name) throws IOException - { +public class ZoneArchive { + + public ZoneArchive(GalaxyArchive arc, String name) throws IOException { galaxy = arc; game = arc.game; filesystem = game.filesystem; @@ -55,8 +54,8 @@ public ZoneArchive(GalaxyArchive arc, String name) throws IOException loadZone(); } - public void save() throws IOException - { + public void save() throws IOException { + saveObjects("Placement", "StageObjInfo"); saveObjects("MapParts", "MapPartsInfo"); saveObjects("Placement", "ObjInfo"); saveObjects("Start", "StartInfo"); @@ -79,67 +78,66 @@ public void save() throws IOException archive.save(); } - public void close() - { - try { archive.close(); } - catch (IOException ex) {} + public void close() { + try { + archive.close(); + } + catch (IOException ex) { + System.out.println(ex); + } } - private void loadZone() - { + private void loadZone() { try { objects = new HashMap<>(); subZones = new HashMap<>(); archive = new RarcFilesystem(filesystem.openFile(zonefile)); - loadObjects("MapParts", "MapPartsInfo"); - loadObjects("Placement", "ObjInfo"); - loadObjects("Start", "StartInfo"); - loadObjects("Placement", "PlanetObjInfo"); - loadObjects("Placement", "AreaObjInfo"); - loadObjects("Placement", "CameraCubeInfo"); - loadObjects("Placement", "DemoObjInfo"); - loadObjects("GeneralPos", "GeneralPosInfo"); - loadObjects("Debug", "DebugMoveInfo"); - switch (gameMask) { - case 1: - loadObjects("Placement", "SoundInfo"); - loadObjects("ChildObj", "ChildObjInfo"); - break; - case 2: - loadObjects("Placement", "ChangeObjInfo"); - break; - } - loadPaths(); - loadSubZones(); + loadObjects("Placement", "StageObjInfo"); + loadObjects("MapParts", "MapPartsInfo"); + loadObjects("Placement", "ObjInfo"); + loadObjects("Start", "StartInfo"); + loadObjects("Placement", "PlanetObjInfo"); + loadObjects("Placement", "AreaObjInfo"); + loadObjects("Placement", "CameraCubeInfo"); + loadObjects("Placement", "DemoObjInfo"); + loadObjects("GeneralPos", "GeneralPosInfo"); + loadObjects("Debug", "DebugMoveInfo"); + switch (gameMask) { + case 1: + loadObjects("Placement", "SoundInfo"); + loadObjects("ChildObj", "ChildObjInfo"); + break; + case 2: + loadObjects("Placement", "ChangeObjInfo"); + 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); } catch (Exception ex) { - + System.out.println(ex); } } - - private void loadObjects(String dir, String file) - { + private void loadObjects(String dir, String file) { List layers = archive.getDirectories("/Stage/Jmp/" + dir); for (String layer : layers) { addObjectsToList(dir + "/" + layer + "/" + file); } } - private void saveObjects(String dir, String file) - { + private void saveObjects(String dir, String file) { List layers = archive.getDirectories("/Stage/Jmp/" + dir); for (String layer : layers) { saveObjectList(dir + "/" + layer + "/" + file); } } - private void addObjectsToList(String filepath) - { + private void addObjectsToList(String filepath) { String[] stuff = filepath.split("/"); String layer = stuff[1].toLowerCase(); String file = stuff[2].toLowerCase(); @@ -148,12 +146,10 @@ private void addObjectsToList(String filepath) objects.put(layer, new ArrayList()); } - try - { + try { Bcsv bcsv = new Bcsv(archive.openFile("/Stage/Jmp/" + filepath)); - switch (file) - { + switch (file) { case "stageobjinfo": for (Bcsv.Entry entry : bcsv.entries) { objects.get(layer).add(new StageObj(this, filepath, entry)); @@ -218,32 +214,28 @@ private void addObjectsToList(String filepath) for (Bcsv.Entry entry : bcsv.entries) { objects.get(layer).add(new ChangeObj(this, filepath, entry)); } - break; + break; } bcsv.close(); } - catch (IOException ex) - { + catch (IOException ex) { System.out.println(ex.getMessage()); ex.printStackTrace(); } } - private void saveObjectList(String filepath) - { + private void saveObjectList(String filepath) { String[] stuff = filepath.split("/"); String dir = stuff[0], file = stuff[2]; String layer = stuff[1].toLowerCase(); if (!objects.containsKey(layer)) return; - try - { + try { Bcsv bcsv = new Bcsv(archive.openFile("/Stage/Jmp/" + filepath)); bcsv.entries.clear(); - for (LevelObject obj : objects.get(layer)) - { + for (LevelObject obj : objects.get(layer)) { if (!dir.equals(obj.directory) || !file.equals(obj.file)) continue; @@ -253,72 +245,57 @@ private void saveObjectList(String filepath) bcsv.save(); bcsv.close(); } - catch (IOException ex) - { - // TODO better error handling, really + catch (IOException ex) { System.out.println(ex.getMessage()); ex.printStackTrace(); } } - private void loadPaths() - { - try - { + private void loadPaths() { + try { Bcsv bcsv = new Bcsv(archive.openFile("/Stage/jmp/Path/CommonPathInfo")); paths = new ArrayList<>(bcsv.entries.size()); for (Bcsv.Entry entry : bcsv.entries) paths.add(new PathObject(this, entry)); bcsv.close(); } - catch (IOException ex) - { + catch (IOException ex) { System.out.println(zoneName+": Failed to load paths: "+ex.getMessage()); } } - - private void savePaths() - { - try - { + private void savePaths() { + try { Bcsv bcsv = new Bcsv(archive.openFile("/Stage/jmp/Path/CommonPathInfo")); bcsv.entries.clear(); - for (PathObject pobj : paths) - { + for (PathObject pobj : paths) { pobj.save(); bcsv.entries.add(pobj.data); } bcsv.save(); bcsv.close(); } - catch (IOException ex) - { + catch (IOException ex) { System.out.println(zoneName+": Failed to save paths: "+ex.getMessage()); } } - private void loadSubZones() - { + private void loadSubZones() { List layers = archive.getDirectories("/Stage/Jmp/Placement"); - for (String layer : layers) - { - try - { + 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) - { + catch (IOException ex) { System.out.println(ex.getMessage()); ex.printStackTrace(); } } } - public GalaxyArchive galaxy; public GameArchive game; public FilesystemBase filesystem; diff --git a/src/whitehole/smg/object/AreaObj.java b/src/whitehole/smg/object/AreaObj.java index 2d29df1..0cb79d3 100644 --- a/src/whitehole/smg/object/AreaObj.java +++ b/src/whitehole/smg/object/AreaObj.java @@ -21,10 +21,9 @@ import whitehole.smg.ZoneArchive; import whitehole.vectors.Vector3; -public class AreaObj extends LevelObject -{ - public AreaObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) - { +public class AreaObj extends LevelObject { + + public AreaObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) { this.zone = zone; String[] stuff = filepath.split("/"); directory = stuff[0]; @@ -44,8 +43,7 @@ public AreaObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) scale = new Vector3((float)data.get("scale_x"), (float)data.get("scale_y"), (float)data.get("scale_z")); } - public AreaObj(ZoneArchive zone, String filepath, int game, String objname, Vector3 pos) - { + public AreaObj(ZoneArchive zone, String filepath, int game, String objname, Vector3 pos) { this.zone = zone; String[] stuff = filepath.split("/"); directory = stuff[0]; @@ -105,9 +103,22 @@ public AreaObj(ZoneArchive zone, String filepath, int game, String objname, Vect } } + public String areaShape(short shape) { + switch(shape) { + case 0: + return "Cube"; + case 1: + return "Cube, alt."; + case 2: + return "Sphere"; + case 3: + return "Cylinder"; + } + return "Invalid"; + } + @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); @@ -115,8 +126,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"); @@ -165,9 +175,12 @@ 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 + "]"; + if (ZoneArchive.gameMask == 2) { + return dbInfo.name + " (" + areaShape((Short)data.get("AreaShapeNo")) + ")" + " [" + l + "]"; + } + else + return dbInfo.name + " [" + l + "]"; } } diff --git a/src/whitehole/smg/object/CameraCubeObj.java b/src/whitehole/smg/object/CameraCubeObj.java index 2a685f3..b97f5fb 100644 --- a/src/whitehole/smg/object/CameraCubeObj.java +++ b/src/whitehole/smg/object/CameraCubeObj.java @@ -21,10 +21,9 @@ import whitehole.smg.ZoneArchive; import whitehole.vectors.Vector3; -public class CameraCubeObj extends LevelObject -{ - public CameraCubeObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) - { +public class CameraCubeObj extends LevelObject { + + public CameraCubeObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) { this.zone = zone; String[] stuff = filepath.split("/"); directory = stuff[0]; @@ -44,8 +43,7 @@ public CameraCubeObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) 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 CameraCubeObj(ZoneArchive zone, String filepath, int game, String objname, Vector3 pos) { this.zone = zone; String[] stuff = filepath.split("/"); directory = stuff[0]; @@ -98,19 +96,30 @@ public CameraCubeObj(ZoneArchive zone, String filepath, int game, String objname } } + 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"; + } + return "Invalid"; + } + @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); data.put("scale_x", scale.x); data.put("scale_y", scale.y); data.put("scale_z", scale.z); } - @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"); @@ -154,9 +163,12 @@ 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 + "]"; + if (ZoneArchive.gameMask == 2) { + return dbInfo.name + " (" + areaShape() + ")" + " [" + l + "]"; + } + else + return dbInfo.name + " [" + l + "]"; } } diff --git a/src/whitehole/smg/object/ChangeObj.java b/src/whitehole/smg/object/ChangeObj.java index 0c984e8..efdd32f 100644 --- a/src/whitehole/smg/object/ChangeObj.java +++ b/src/whitehole/smg/object/ChangeObj.java @@ -21,10 +21,9 @@ import whitehole.smg.ZoneArchive; import whitehole.vectors.Vector3; -public class ChangeObj extends LevelObject -{ - public ChangeObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) - { +public class ChangeObj extends LevelObject { + + public ChangeObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) { this.zone = zone; String[] stuff = filepath.split("/"); directory = stuff[0]; @@ -44,8 +43,7 @@ public ChangeObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) scale = new Vector3((float)data.get("scale_x"), (float)data.get("scale_y"), (float)data.get("scale_z")); } - public ChangeObj(ZoneArchive zone, String filepath, int game, Vector3 pos) - { + public ChangeObj(ZoneArchive zone, String filepath, int game, Vector3 pos) { this.zone = zone; String[] stuff = filepath.split("/"); directory = stuff[0]; @@ -80,18 +78,15 @@ public ChangeObj(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); data.put("scale_x", scale.x); data.put("scale_y", scale.y); data.put("scale_z", scale.z); } - @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"); @@ -116,9 +111,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 name + " [" + l + "]"; + return dbInfo.name + " [" + l + "]"; } -} +} \ No newline at end of file diff --git a/src/whitehole/smg/object/ChildObj.java b/src/whitehole/smg/object/ChildObj.java index 378be7b..fe1a086 100644 --- a/src/whitehole/smg/object/ChildObj.java +++ b/src/whitehole/smg/object/ChildObj.java @@ -107,7 +107,6 @@ public void save() data.put("scale_x", scale.x); data.put("scale_y", scale.y); data.put("scale_z", scale.z); } - @Override public void getProperties(PropertyGrid panel) { diff --git a/src/whitehole/smg/object/DebugObj.java b/src/whitehole/smg/object/DebugObj.java index 2c50af5..37a95d9 100644 --- a/src/whitehole/smg/object/DebugObj.java +++ b/src/whitehole/smg/object/DebugObj.java @@ -81,7 +81,6 @@ public void save() data.put("scale_x", scale.x); data.put("scale_y", scale.y); data.put("scale_z", scale.z); } - @Override public void getProperties(PropertyGrid panel) { @@ -104,6 +103,6 @@ public void getProperties(PropertyGrid panel) public String toString() { String l = layer.equals("common") ? "Common" : "Layer"+layer.substring(5).toUpperCase(); - return name + " [" + l + "]"; + return dbInfo.name + " [" + l + "]"; } } diff --git a/src/whitehole/smg/object/DemoObj.java b/src/whitehole/smg/object/DemoObj.java index 282d526..ac70cc0 100644 --- a/src/whitehole/smg/object/DemoObj.java +++ b/src/whitehole/smg/object/DemoObj.java @@ -91,7 +91,6 @@ public void save() data.put("scale_x", scale.x); data.put("scale_y", scale.y); data.put("scale_z", scale.z); } - @Override public void getProperties(PropertyGrid panel) { diff --git a/src/whitehole/smg/object/GeneralObject.java b/src/whitehole/smg/object/GeneralObject.java index 541cc8d..843411e 100644 --- a/src/whitehole/smg/object/GeneralObject.java +++ b/src/whitehole/smg/object/GeneralObject.java @@ -14,7 +14,10 @@ */ package 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; @@ -55,6 +58,7 @@ public GeneralObject(ZoneArchive zone, String filepath, int game, String objname name = objname; loadDBInfo(); + getShapeModels(); renderer = null; uniqueID = -1; @@ -85,7 +89,10 @@ public GeneralObject(ZoneArchive zone, String filepath, int game, String objname data.put("CameraSetId", -1); data.put("CastId", -1); data.put("ViewGroupId", -1); - data.put("ShapeModelNo", (short)-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("CommonPath_ID", (short)-1); data.put("ClippingGroupId", (short)-1); data.put("GroupId", (short)-1); @@ -107,6 +114,15 @@ public GeneralObject(ZoneArchive zone, String filepath, int game, String objname } } + @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() { @@ -116,10 +132,10 @@ public void save() data.put("scale_x", scale.x); data.put("scale_y", scale.y); data.put("scale_z", scale.z); } - @Override public void getProperties(PropertyGrid panel) { + getShapeModels(); 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"); @@ -162,7 +178,10 @@ public void getProperties(PropertyGrid panel) 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"); + 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"); @@ -180,4 +199,6 @@ public String toString() String l = layer.equals("common") ? "Common" : "Layer"+layer.substring(5).toUpperCase(); return dbInfo.name + " [" + l + "]"; } + + public List choicesShapeModelNo; } diff --git a/src/whitehole/smg/object/GeneralPosObj.java b/src/whitehole/smg/object/GeneralPosObj.java index ee58f1d..2554d51 100644 --- a/src/whitehole/smg/object/GeneralPosObj.java +++ b/src/whitehole/smg/object/GeneralPosObj.java @@ -15,16 +15,20 @@ 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) - { +public class GeneralPosObj extends LevelObject { + + public GeneralPosObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) { this.zone = zone; String[] stuff = filepath.split("/"); directory = stuff[0]; @@ -44,8 +48,7 @@ public GeneralPosObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) scale = new Vector3(1,1,1); } - public GeneralPosObj(ZoneArchive zone, String filepath, int game, Vector3 pos) - { + public GeneralPosObj(ZoneArchive zone, String filepath, int game, Vector3 pos) { this.zone = zone; String[] stuff = filepath.split("/"); directory = stuff[0]; @@ -73,18 +76,32 @@ public GeneralPosObj(ZoneArchive zone, String filepath, int game, Vector3 pos) 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() - { + 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) - { + 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"); @@ -94,16 +111,17 @@ public void getProperties(PropertyGrid panel) panel.addField("dir_z", "Z rotation", "float", null, rotation.z, "Default"); panel.addCategory("obj_objinfo", "Other"); - panel.addField("PosName", "PosName", "text", null, data.get("PosName"), "Default"); + 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", "text", null, data.get("ChildObjId"), "Default"); + 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 name + " ( " + data.get("PosName") + " ) " + "[" + l + "]"; + return dbInfo.name + " ( " + data.get("PosName") + " ) " + "[" + l + "]"; } + + private List choicesGeneralPosNames; } diff --git a/src/whitehole/smg/object/PlanetObj.java b/src/whitehole/smg/object/PlanetObj.java index 65fbf9a..c7ea462 100644 --- a/src/whitehole/smg/object/PlanetObj.java +++ b/src/whitehole/smg/object/PlanetObj.java @@ -15,6 +15,8 @@ package whitehole.smg.object; +import java.util.Arrays; +import java.util.List; import whitehole.PropertyGrid; import whitehole.smg.Bcsv; import whitehole.smg.LevelObject; @@ -134,8 +136,8 @@ public void getProperties(PropertyGrid panel) panel.addField("Distant", "Distance", "float", null, data.get("Distant"), "Default"); panel.addField("Priority", "Priority", "int", null, data.get("Priority"), "Default"); panel.addField("Inverse", "Inverse", "int", null, data.get("Inverse"), "Default"); - panel.addField("Power", "Power", "text", null, data.get("Power"), "Default"); - panel.addField("Gravity_type", "Type", "text", null, data.get("Gravity_type"), "Default"); + 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"); @@ -172,4 +174,9 @@ 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); } diff --git a/src/whitehole/smg/object/StageObj.java b/src/whitehole/smg/object/StageObj.java index f0a719b..25fb7af 100644 --- a/src/whitehole/smg/object/StageObj.java +++ b/src/whitehole/smg/object/StageObj.java @@ -21,10 +21,9 @@ import whitehole.smg.ZoneArchive; import whitehole.vectors.Vector3; -public class StageObj extends LevelObject -{ - public StageObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) - { +public class StageObj extends LevelObject { + + public StageObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) { this.zone = zone; String[] stuff = filepath.split("/"); directory = stuff[0]; @@ -44,8 +43,7 @@ public StageObj(ZoneArchive zone, String filepath, Bcsv.Entry entry) scale = new Vector3(1,1,1); } - public StageObj(ZoneArchive zone, String filepath, int game, Vector3 pos) - { + public StageObj(ZoneArchive zone, String filepath, int game, Vector3 pos) { this.zone = zone; String[] stuff = filepath.split("/"); directory = stuff[0]; @@ -71,31 +69,28 @@ public StageObj(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); } @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"); - 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.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_objinfo", "Other"); - panel.addField("l_id", "l_id", "int", null, data.get("l_id"), "Default"); + panel.addField("l_id", "l_id", "noedit", 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 name + " [" + l + "]"; }