Skip to content

Commit c1d751b

Browse files
committed
Lots of TScene and TViewport implementiation
1 parent 20e71ad commit c1d751b

File tree

25 files changed

+745
-34
lines changed

25 files changed

+745
-34
lines changed

OpenJPOG/Source/ARenderer.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "ARenderer.h"
22
#include "main.h"
3+
#include "TRender/TScene.h"
34

45
//-----------------------------------------------------------------------------
56
// Enables memory debugging.
@@ -22,6 +23,8 @@ const TMatrix44 ARenderer::ms_mLightDir = TMatrix44();
2223
ARenderer::ARenderer()
2324
{
2425
m_pViewport = TNULL;
26+
m_pSkyScene = TNULL;
27+
m_pSkyViewport = TNULL;
2528
m_fFarClip = 160.0f;
2629
m_pcScreenCaptureBuffer = TNULL;
2730
m_eCaptureState = CAPTURESTATE_CREATE;
@@ -31,7 +34,12 @@ TBOOL ARenderer::OnCreate()
3134
{
3235
TRenderInterface *pRenderer = TRenderInterface::GetRenderer();
3336
//pRenderer->GetSystemResource(TRenderInterface::SYSRESOURCE_SHSYS);
34-
//pRenderer->GetSystemResource(TRenderInterface::SYSRESOURCE_SCENE);
37+
//TScene *pMainScene = static_cast<TScene *>(pRenderer->GetSystemResource(TRenderInterface::SYSRESOURCE_SCENE));
38+
//pMainScene->SetName("MainScene");
39+
//m_pViewport = pMainScene->CreateViewport("MainViewport", TNULL, TTRUE);
40+
m_pSkyScene = static_cast<TScene *>(pRenderer->CreateResource(&TGetClass(TScene), "SkyScene", TNULL));
41+
m_pSkyScene->Create();
42+
m_pSkyViewport = m_pSkyScene->CreateViewport("SkyViewport", TNULL, TTRUE);
3543
return TTask::OnCreate();
3644
}
3745

@@ -45,8 +53,11 @@ TBOOL ARenderer::OnUpdate(TFLOAT a_fDeltaTime)
4553
MoviePlayerState state = RenderMovie(a_fDeltaTime);
4654
if (state != MOVIEPLAYERSTATE_RUNNING) {
4755
// Render things
48-
if (m_eCaptureState != CAPTURESTATE_POLL) {
49-
56+
if (m_pSkyScene) {
57+
m_pSkyScene->Begin();
58+
m_pSkyScene->Update(a_fDeltaTime);
59+
m_pSkyScene->Render();
60+
m_pSkyScene->End();
5061
}
5162
}
5263
g_oTheApp.GetRootTask()->GetRenderInterface()->Update(a_fDeltaTime);

OpenJPOG/Source/ARenderer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ class ARenderer : public TTask
6060
TFLOAT m_fLastRenderTime; // 0x24
6161
TFLOAT m_fCurRenderTime; // 0x28
6262
TViewport *m_pViewport; // 0x2C
63+
TScene *m_pSkyScene; // 0x30
64+
TViewport *m_pSkyViewport; // 0x34
6365
TFLOAT m_fFarClip; // 0x38
6466
CaptureState m_eCaptureState; // 0x3C
6567
TRenderCapture *m_pCapture; // 0x40

OpenJPOG/Source/GUI/AGUISystem.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "AGUISystem.h"
22
#include "main.h"
33
#include "TSpriteShader/Include/D3D/TSpriteShaderD3D.h"
4+
#include "TRender/TScene.h"
45

56
//-----------------------------------------------------------------------------
67
// Enables memory debugging.
@@ -35,9 +36,21 @@ TBOOL AGUISystem::OnCreate()
3536
m_pGUIInterface->Create();
3637
m_pDisplayContext = new PGUITRDisplayContext();
3738
m_pDisplayContext->Create(g_oTheApp.GetRootTask()->GetRenderInterface(), m_pTextureFactory, m_pFontFactory);
39+
auto pDisplayParams = pRenderer->GetCurrentDisplayParams();
3840
m_pScreen = new TGUIScreen();
41+
m_pScreen->SetSize(TMIN(800, pDisplayParams->uiWidth), TMIN(600, pDisplayParams->uiHeight));
42+
m_pScreen->SetDisplayContext(m_pDisplayContext);
43+
m_pScreen->SetState(STATE_VISIBLE, STATE_VISIBLE);
44+
m_oScreenPaintListener.Connect(m_pScreen->GetPaintEmitter(), this, OnScreenPaint, -0x8000);
45+
for (TINT i = 0; i < 2; i++) {
46+
TCString sceneName = TCString().Format("Scene%d", i);
47+
m_pScenes[i] = static_cast<TScene *>(pRenderer->CreateResource(&TGetClass(TScene), sceneName, TNULL));
48+
m_pScenes[i]->Create();
49+
m_pScenes[i]->CreateViewport("GUIViewport", TNULL, TRUE);
50+
}
51+
// m_pScreen->SetAudioContext
52+
// m_pScreen->SetInputContext
3953
TCString guiTexturePath = TCString("data/gui/textures");
40-
//m_oPaintListener.Connect(*m_pScreen->GetPaintEmitter(), this, OnScreenPaint, -0x8000);
4154
m_pMatLibPic = new AGUIMatLibPicture();
4255
m_pMatLibPic->Create(guiTexturePath, m_pSpriteShader);
4356
return true;

OpenJPOG/Source/GUI/AGUISystem.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,14 @@ class AGUISystem : public Toshi::TTask
4646
static TBOOL OnScreenPaint(AGUISystem *a_pGUISystem, Toshi::TGUIScreen *a_pScreen, Toshi::TGUIScreenPaintEvent *a_pEvent);
4747

4848
private:
49-
Toshi::TManagedPtr<Toshi::TGUIInterface> m_pGUIInterface; // 0x24
50-
Toshi::TGUIScreen *m_pScreen; // 0x28
51-
PGUITRDisplayContext *m_pDisplayContext; // 0xA4
52-
AGUITextureFactory *m_pTextureFactory; // 0xA8
53-
PGUITRFontFactory *m_pFontFactory; // 0xAC
54-
Toshi::TListener<Toshi::TGUIScreen, Toshi::TGUIScreenPaintEvent, AGUISystem> m_oPaintListener; // 0x118
55-
Toshi::TNullResource *m_pNullResource; // 0x140
56-
Toshi::TSpriteShader *m_pSpriteShader; // 0x144
57-
AGUIMatLibPicture *m_pMatLibPic; // 0x19C
49+
Toshi::TManagedPtr<Toshi::TGUIInterface> m_pGUIInterface; // 0x24
50+
Toshi::TGUIScreen *m_pScreen; // 0x28
51+
PGUITRDisplayContext *m_pDisplayContext; // 0xA4
52+
AGUITextureFactory *m_pTextureFactory; // 0xA8
53+
PGUITRFontFactory *m_pFontFactory; // 0xAC
54+
Toshi::TListener<Toshi::TGUIScreen, Toshi::TGUIScreenPaintEvent, AGUISystem> m_oScreenPaintListener; // 0x118
55+
Toshi::TNullResource *m_pNullResource; // 0x140
56+
Toshi::TSpriteShader *m_pSpriteShader; // 0x144
57+
Toshi::TScene *m_pScenes[2]; // 0x190
58+
AGUIMatLibPicture *m_pMatLibPic; // 0x19C
5859
};

Toshi/Include/TGui/TGUIScreen.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
22
#include "TGuiWidget.h"
3+
#include "TGUIDisplayContext.h"
34
#include "TKernel/TEvent.h"
45

56
TOSHI_NAMESPACE_BEGIN
@@ -15,13 +16,22 @@ class TGUIINTERFACE_EXPORTS TGUIScreen : public TGUIWidget
1516
public:
1617
TGUIScreen();
1718

19+
void NotifyDescendantCantFocus(TGUIWidget *a_pWidget);
20+
void NotifyDescendantCanFocus(TGUIWidget *a_pWidget);
21+
22+
void SetDisplayContext(TGUIDisplayContext *a_pDisplayContext)
23+
{
24+
m_pDisplayContext = a_pDisplayContext;
25+
}
26+
1827
TEmitter<TGUIScreen, TGUIScreenPaintEvent> *GetPaintEmitter()
1928
{
2029
return &m_oPaintEmitter;
2130
}
2231

2332
private:
2433
TEmitter<TGUIScreen, TGUIScreenPaintEvent> m_oPaintEmitter;
34+
TGUIDisplayContext *m_pDisplayContext; // 0xC0
2535
};
2636

2737
TOSHI_NAMESPACE_END

Toshi/Include/TGui/TGuiWidget.h

Lines changed: 55 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,49 @@
55

66
TOSHI_NAMESPACE_BEGIN
77

8+
class TGUIScreen;
9+
10+
#define STATE_ENABLED 0x01
11+
#define STATE_FOCUSED 0x02
12+
#define STATE_VISIBLE 0x04
13+
#define STATE_ROLLOVER 0x08
14+
#define STATE_SELECTED 0x10
15+
#define STATE_ONSCREEN (STATE_ENABLED | STATE_VISIBLE)
16+
817
class TGUIINTERFACE_EXPORTS TGUIWidget : public TGUIDeserialisable
918
, public TNodeList<TGUIWidget>::TNode
1019
{
1120
DECLARE_DYNAMIC(TGUIWidget)
1221

13-
enum State
14-
{
15-
STATE_ENABLED = BITFIELD(0),
16-
STATE_FOCUSED = BITFIELD(1),
17-
STATE_VISIBLE = BITFIELD(2),
18-
STATE_ROLLOVER = BITFIELD(3),
19-
STATE_SELECTED = BITFIELD(4),
20-
};
21-
2222
public:
23+
24+
TGUIWidget();
25+
26+
// $TGUIInterface: FUNCTION 1001dd80
27+
void SetSize(TINT a_iWidth, TINT a_iHeight)
28+
{
29+
if (!m_iSizeModeHoriz && !m_iSizeModeVert) {
30+
return;
31+
}
32+
if (m_iWidth != a_iWidth || m_iHeight != a_iHeight) {
33+
m_bIsEnabled = TFALSE;
34+
}
35+
m_iWidth = a_iWidth;
36+
m_iHeight = a_iHeight;
37+
}
38+
void InvalidateComponentCache(TBOOL a_bRecursive);
39+
void SetState(TUINT a_iState, TUINT a_iState2);
40+
// $TGUIInterface: FUNCTION 1001e630
41+
TBOOL CanFocus()
42+
{
43+
for (TGUIWidget *widget = this; widget; widget = widget->m_pParentWidget) {
44+
if (!widget->IsState(STATE_ENABLED) || !widget->IsState(STATE_VISIBLE)) {
45+
return TFALSE;
46+
}
47+
}
48+
return TTRUE;
49+
}
50+
TGUIScreen *GetScreen();
2351
// $TGUIInterface: FUNCTION 100076c0
2452
TINT GetWidth() const
2553
{
@@ -30,10 +58,26 @@ class TGUIINTERFACE_EXPORTS TGUIWidget : public TGUIDeserialisable
3058
{
3159
return m_iHeight;
3260
}
61+
// $TGUIInterface: FUNCTION 10007550
62+
TBOOL IsState(TUINT a_iStateMask, TUINT a_iExpectedState) const
63+
{
64+
return (m_iState & a_iStateMask) == a_iExpectedState;
65+
}
66+
// $TGUIInterface: FUNCTION 10007570
67+
TBOOL IsState(TUINT a_iStateMask) const
68+
{
69+
return (m_iState & a_iStateMask) != 0;
70+
}
71+
3372

3473
private:
35-
TSHORT m_iWidth; // 0x70
36-
TSHORT m_iHeight; // 0x72
74+
TGUIWidget *m_pParentWidget; // 0x44
75+
TSHORT m_iWidth; // 0x70
76+
TSHORT m_iHeight; // 0x72
77+
TINT m_iSizeModeHoriz; // 0x74
78+
TINT m_iSizeModeVert; // 0x78
79+
TBOOL m_bIsEnabled; // 0x84
80+
TUINT m_iState; // 0x88
3781
};
3882

3983
TOSHI_NAMESPACE_END

Toshi/Include/TKernel/TEvent.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class TKERNELINTERFACE_EXPORTS TGenericEmitter
7474
void Destroy()
7575
{
7676
for (auto it = m_Listeners.Begin(); it != m_Listeners.End(); it++) {
77-
//it->Disconnect();
77+
it->Disconnect();
7878
}
7979

8080
m_pOwner = TNULL;
@@ -107,7 +107,7 @@ class TListener : public TGenericListener
107107
using t_CallerCallback = TBOOL (*)(Caller *a_pCaller, Owner *a_pOwner, Data *a_pData);
108108

109109
public:
110-
void Connect(TGenericEmitter &a_rEmitter, Caller *a_pCaller, t_CallerCallback a_pCallback, int a_iPriority)
110+
void Connect(TGenericEmitter *a_rEmitter, Caller *a_pCaller, t_CallerCallback a_pCallback, int a_iPriority)
111111
{
112112
TGenericListener::Connect(
113113
a_rEmitter,

Toshi/Include/TKernel/TMatrix44.h

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,79 @@ TOSHI_NAMESPACE_BEGIN
55

66
class TKERNELINTERFACE_EXPORTS TMatrix44
77
{
8+
public:
9+
10+
TMatrix44() = default;
11+
12+
TMatrix44(
13+
TFLOAT a_f11,
14+
TFLOAT a_f12,
15+
TFLOAT a_f13,
16+
TFLOAT a_f14,
17+
TFLOAT a_f21,
18+
TFLOAT a_f22,
19+
TFLOAT a_f23,
20+
TFLOAT a_f24,
21+
TFLOAT a_f31,
22+
TFLOAT a_f32,
23+
TFLOAT a_f33,
24+
TFLOAT a_f34,
25+
TFLOAT a_f41,
26+
TFLOAT a_f42,
27+
TFLOAT a_f43,
28+
TFLOAT a_f44)
29+
: m_f11(a_f11), m_f12(a_f12), m_f13(a_f13), m_f14(a_f14), m_f21(a_f21), m_f22(a_f22), m_f23(a_f23), m_f24(a_f24), m_f31(a_f31), m_f32(a_f32), m_f33(a_f33), m_f34(a_f34), m_f41(a_f41), m_f42(a_f42), m_f43(a_f43), m_f44(a_f44)
30+
{}
31+
32+
void Set(
33+
TFLOAT a_f11,
34+
TFLOAT a_f12,
35+
TFLOAT a_f13,
36+
TFLOAT a_f14,
37+
TFLOAT a_f21,
38+
TFLOAT a_f22,
39+
TFLOAT a_f23,
40+
TFLOAT a_f24,
41+
TFLOAT a_f31,
42+
TFLOAT a_f32,
43+
TFLOAT a_f33,
44+
TFLOAT a_f34,
45+
TFLOAT a_f41,
46+
TFLOAT a_f42,
47+
TFLOAT a_f43,
48+
TFLOAT a_f44)
49+
{
50+
m_f11 = a_f11;
51+
m_f12 = a_f12;
52+
m_f13 = a_f13;
53+
m_f14 = a_f14;
54+
m_f21 = a_f21;
55+
m_f22 = a_f22;
56+
m_f23 = a_f23;
57+
m_f24 = a_f24;
58+
m_f31 = a_f31;
59+
m_f32 = a_f32;
60+
m_f33 = a_f33;
61+
m_f34 = a_f34;
62+
m_f41 = a_f41;
63+
m_f42 = a_f42;
64+
m_f43 = a_f43;
65+
m_f44 = a_f44;
66+
}
67+
68+
void Identity()
69+
{
70+
*this = IDENTITY;
71+
}
72+
73+
private:
74+
75+
static const TMatrix44 IDENTITY;
76+
77+
TFLOAT m_f11, m_f12, m_f13, m_f14;
78+
TFLOAT m_f21, m_f22, m_f23, m_f24;
79+
TFLOAT m_f31, m_f32, m_f33, m_f34;
80+
TFLOAT m_f41, m_f42, m_f43, m_f44;
881
};
982

1083
TOSHI_NAMESPACE_END

0 commit comments

Comments
 (0)