Skip to content

Commit 916bddd

Browse files
committed
d_jcam_editor mostly done
1 parent 1b6e53a commit 916bddd

File tree

7 files changed

+147
-24
lines changed

7 files changed

+147
-24
lines changed

include/JSystem/JStudio/JStudio/jstudio-object.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ class TObject : public stb::TObject {
120120
virtual void do_data(void const*, u32, void const*, u32);
121121

122122
TAdaptor* getAdaptor() const { return mpAdaptor; }
123+
124+
void setAdaptor(TAdaptor* pAdaptor) {
125+
mpAdaptor = pAdaptor;
126+
prepareAdaptor();
127+
}
128+
123129
TControl* getControl() { return (TControl*)stb::TObject::getControl(); }
124130
const TControl* getControl() const { return (const TControl*)stb::TObject::getControl(); }
125131

include/JSystem/JStudio/JStudioCameraEditor/control.h

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,20 +132,33 @@ namespace JStudioCameraEditor {
132132

133133
TControl();
134134

135-
void jstudio_setSecondPerFrame(double);
136-
void show_setRender(J2DOrthoGraph*, JUTFont*);
137-
void interface_setPad(const JUTGamePad*);
138-
void jstudio_setAdaptor(JStudio::TAdaptor_camera*);
139-
bool isEnabled() const;
135+
void jstudio_setSecondPerFrame(double param_0) {
136+
oJSTControl_.setSecondPerFrame(param_0);
137+
}
138+
139+
void show_setRender(J2DOrthoGraph* pOrthoGraph, JUTFont* pFont) {
140+
field_0x3cc.setRender(pOrthoGraph);
141+
oPrint_.setFont(pFont);
142+
}
143+
144+
void interface_setPad(const JUTGamePad* pPad) {
145+
oPad_.setPad(pPad);
146+
}
147+
148+
void jstudio_setAdaptor(JStudio::TAdaptor_camera* pAdaptor) {
149+
field_0x608.setAdaptor(pAdaptor);
150+
}
151+
152+
bool isEnabled() const { return bEnabled_; }
140153

141154
virtual void listenPropertyEvent(const JORPropertyEvent*);
142155
virtual void genMessage(JORMContext*);
143156

144157
virtual int JORAct(u32, const char*);
145158
virtual ~TControl();
146-
virtual void update(const Mtx);
159+
virtual void update();
147160
virtual void show2D();
148-
virtual void show3D();
161+
virtual void show3D(const Mtx);
149162
virtual int command(TECommand, const char*);
150163

151164
/* 0x018 */ JStudioToolLibrary::TConsole field_0x18;
@@ -196,7 +209,6 @@ namespace JStudioCameraEditor {
196209
/* 0x4CC */ JStudioToolLibrary::TColor_variable field_0x4cc;
197210
/* 0x4E0 */ u8 field_0x4E0[0x4F8 - 0x4E0];
198211
/* 0x4F8 */ JStudio::TControl oJSTControl_;
199-
/* 0x604 */ u8 field_0x604[0x608 - 0x604];
200212
/* 0x608 */ JStudio::TObject_camera field_0x608;
201213
/* 0x640 */ u8 field_0x640;
202214
};

include/JSystem/JStudio/JStudioToolLibrary/interface.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ namespace JStudioToolLibrary {
2323

2424
TPad();
2525

26-
void setPad(const JUTGamePad*);
26+
void setPad(const JUTGamePad* pPad) {
27+
pPad_ = pPad;
28+
}
29+
2730
bool isEnabled() const;
2831
void getData(TData*) const;
2932
f32 getAnalog_triggerR() const;

include/JSystem/JStudio/JStudioToolLibrary/visual.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ namespace JStudioToolLibrary {
2727
struct TDrawPrimitive2D {
2828
TDrawPrimitive2D();
2929

30-
void setRender(J2DOrthoGraph*);
30+
void setRender(J2DOrthoGraph* pOrthoGraph) {
31+
pOrthoGraph_ = pOrthoGraph;
32+
}
33+
3134
void fillRectangle(int, int, int, int);
3235
void setColor(const JUtility::TColor&);
3336
void prepare();
@@ -74,7 +77,11 @@ namespace JStudioToolLibrary {
7477

7578
int getY() const;
7679
int getX() const;
77-
void setFont(JUTFont*);
80+
81+
void setFont(JUTFont* pFont) {
82+
pFont_ = pFont;
83+
}
84+
7885
void setColor(const JUtility::TColor&);
7986
void locate(int, int);
8087
void prepare();

include/JSystem/JStudio/JStudio_JStage/control.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ struct TAdaptor_object_ {
3838
void adaptor_object_begin_() { pJSGObject_->JSGFEnableFlag(1); }
3939
void adaptor_object_end_() { pJSGObject_->JSGFDisableFlag(1); }
4040

41+
#if PLATFORM_SHIELD
42+
/* 0x0 */ const JStudio::TAdaptor* pAdaptor_;
43+
#endif
4144
/* 0x0 */ JStage::TSystem const* pJSGSystem_;
4245
/* 0x4 */ JStage::TObject* pJSGObject_;
4346
};

include/d/d_jcam_editor.h

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,39 @@
11
#ifndef D_JCAM_EDITOR_H
22
#define D_JCAM_EDITOR_H
33

4-
#include <dolphin/mtx.h>
54
#include "JSystem/JStudio/JStudioCameraEditor/control.h"
5+
#include "JSystem/JStudio/JStudio_JStage/object-camera.h"
6+
#include "JSystem/JUtility/JUTResFont.h"
7+
#include "JSystem/JKernel/JKRExpHeap.h"
68

7-
namespace JStage {
8-
class TSystem;
9-
}
10-
11-
class JKRExpHeap;
129
class JUTGamePad;
13-
class JUTResFont;
1410

1511
class dJcame_c {
1612
public:
1713
dJcame_c(const JStage::TSystem*, f32, JUTGamePad&);
14+
~dJcame_c();
1815

16+
void update();
1917
void show3D(Mtx);
2018
void show2D();
2119

20+
bool isEnabled() { return mControl->isEnabled(); }
21+
2222
static void create(const JStage::TSystem*, f32, JUTGamePad&);
23+
static void remove();
2324

2425
static dJcame_c* m_myObj;
2526

2627
static dJcame_c* get() { return m_myObj; }
2728

28-
/* 0x00 */ JStage::TSystem* field_0x0;
29-
/* 0x04 */ JUTResFont* field_0x4;
30-
/* 0x08 */ JKRExpHeap* mHeap;
31-
/* 0x0C */ JStudioCameraEditor::TControl* mControl;
32-
/* 0x10 */ int field_0x10;
33-
/* 0x14 */ u8 field_0x14;
29+
/* 0x00 */ const JStage::TSystem* mSystem;
30+
/* 0x04 */ J2DOrthoGraph* mOrthoGraph;
31+
/* 0x08 */ JUTResFont* mFont;
32+
/* 0x0C */ JKRExpHeap* mHeap;
33+
/* 0x10 */ JStudioCameraEditor::TControl* mControl;
34+
/* 0x14 */ JStudio_JStage::TAdaptor_camera* mAdaptor;
35+
/* 0x18 */ bool mIsAdaptorSet;
36+
/* 0x19 */ s8 mHioId;
3437
};
3538

3639
#endif /* D_JCAM_EDITOR_H */

src/d/d_jcam_editor.cpp

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#include "d/d_jcam_editor.h"
2+
#include "m_Do/m_Do_hostIO.h"
3+
#include "m_Do/m_Do_ext.h"
4+
5+
dJcame_c* dJcame_c::m_myObj;
6+
7+
dJcame_c::dJcame_c(const JStage::TSystem* i_system, f32 param_1, JUTGamePad& i_pad) {
8+
mOrthoGraph = new J2DOrthoGraph(0.0f, 0.0f, 608.0f, 448.0f, -1.0f, 1.0f);
9+
mFont = new JUTResFont((ResFONT*)JUTResFONT_Ascfont_fix12, NULL);
10+
11+
mHeap = JKRExpHeap::create(0x100000, JKRHeap::getRootHeap2(), false);
12+
JUT_ASSERT(54, mHeap != NULL);
13+
14+
mControl = new JStudioCameraEditor::TControl();
15+
mHioId = mDoHIO_createChild("JStudioCameraEditor", mControl);
16+
JUT_ASSERT(57, mControl != NULL);
17+
18+
i_pad.setButtonRepeat((PAD_BUTTON_A | PAD_BUTTON_UP | PAD_BUTTON_DOWN | PAD_BUTTON_LEFT | PAD_BUTTON_RIGHT), 30, 5);
19+
mControl->interface_setPad(&i_pad);
20+
mControl->show_setRender(mOrthoGraph, mFont);
21+
mControl->jstudio_setSecondPerFrame(param_1);
22+
23+
mAdaptor = NULL;
24+
mSystem = i_system;
25+
mIsAdaptorSet = false;
26+
27+
m_myObj = this;
28+
}
29+
30+
dJcame_c::~dJcame_c() {
31+
if (mAdaptor != NULL) {
32+
delete mAdaptor;
33+
}
34+
35+
mControl->jstudio_setAdaptor(NULL);
36+
mDoHIO_deleteChild(mHioId);
37+
38+
delete mControl;
39+
mHeap->destroy();
40+
delete mFont;
41+
delete mOrthoGraph;
42+
43+
m_myObj = NULL;
44+
}
45+
46+
void dJcame_c::create(const JStage::TSystem* i_system, f32 param_1, JUTGamePad& i_pad) {
47+
JUT_ASSERT(109, m_myObj == NULL);
48+
new dJcame_c(i_system, param_1, i_pad);
49+
JUT_ASSERT(111, m_myObj != NULL);
50+
}
51+
52+
void dJcame_c::remove() {
53+
JUT_ASSERT(126, m_myObj != NULL);
54+
delete m_myObj;
55+
}
56+
57+
void dJcame_c::update() {
58+
if (!mIsAdaptorSet) {
59+
if (mAdaptor == NULL) {
60+
JStage::TObject* object;
61+
int rt = mSystem->JSGFindObject(&object, "EditCam", JStage::OBJECT_CAMERA);
62+
if (object == NULL) {
63+
return;
64+
}
65+
66+
mAdaptor = new JStudio_JStage::TAdaptor_camera(mSystem, (JStage::TCamera*)object);
67+
JUT_ASSERT(155, mAdaptor != NULL);
68+
69+
mControl->jstudio_setAdaptor(mAdaptor);
70+
mIsAdaptorSet = true;
71+
}
72+
} else if (isEnabled()) {
73+
JKRHeap* heap = mDoExt_setCurrentHeap(mHeap);
74+
mControl->update();
75+
mDoExt_setCurrentHeap(heap);
76+
}
77+
}
78+
79+
void dJcame_c::show3D(Mtx i_mtx) {
80+
if (mIsAdaptorSet) {
81+
mControl->show3D(i_mtx);
82+
}
83+
}
84+
85+
void dJcame_c::show2D() {
86+
if (mIsAdaptorSet) {
87+
mControl->show2D();
88+
}
89+
}

0 commit comments

Comments
 (0)