Skip to content
This repository was archived by the owner on Aug 2, 2020. It is now read-only.

Commit a85db10

Browse files
Fixed Models Class And Added Simple Multiplayer (Now Doesn't Work)
Also: Fix File System (add some new ext) Reformat UI System (add ID for each component) Add Change FOV (change it by minus and plus buttons to view effect Dolly Zoom, need to move forwand and then hold the minus button or move backward and hold the plus button) Add Some New Models Fixed Release Build
1 parent 06f9c90 commit a85db10

File tree

134 files changed

+1493
-1798
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+1493
-1798
lines changed

Engine/Actor.cpp

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
#include "Actor.h"
33
#include "DebugDraw.h"
44

5+
class Engine;
6+
extern shared_ptr<Engine> Application;
7+
#include "Engine.h"
8+
#include "Camera.h"
9+
510
void Actor::Update(float Time)
611
{
712
if (Health == 0.0f && !IsGod)
@@ -18,23 +23,43 @@ void Actor::Update(float Time)
1823
}
1924

2025
extern bool DrawCamSphere;
26+
Vector2 Number = { 1.f, 0.f };
2127
void Actor::Render(float Time)
2228
{
2329
Update(Time);
2430

31+
auto P = Vector2::SmoothStep(Vector2(1.f, 0.f), Number, 10.f).x;
32+
Application->getCamera()->SetProjParams(P,
33+
((float)Application->getWorkAreaSize(Application->GetHWND()).x /
34+
(float)Application->getWorkAreaSize(Application->GetHWND()).y), 0.1f, 1000.f);
35+
2536
auto PosCCT = Application->getCamera()->GetCCT();
2637
if (PosCCT.operator bool() && DrawCamSphere)
2738
{
2839
BoundingSphere sphere(ToExtended(PosCCT->getController()->getPosition()), PosCCT->getController()->getRadius());
2940
Application->getDebugDraw()->Draw(sphere, (Vector4)Colors::DarkSlateBlue);
3041
}
42+
43+
Number.Clamp(Vector2(0.1f, 0.f), Vector2(1.f, 0.f));
44+
if (GetAsyncKeyState(0xBB))
45+
{
46+
Number.x += 0.005f;
47+
return;
48+
}
49+
else if (GetAsyncKeyState(0xBD))
50+
{
51+
Number.x -= 0.005f;
52+
return;
53+
}
3154
}
3255

3356
HRESULT Actor::Init()
3457
{
3558
Application->getCamera()->SetCameraControlButtons(false, true, false);
36-
Application->getCamera()->SetResetCursorAfterMove(false);
59+
Application->getCamera()->SetResetCursorAfterMove(true);
3760
Application->getCamera()->SetFreeMoveCam(true);
61+
Application->getCamera()->SetDrag(true);
62+
Application->getCamera()->Teleport(Vector3(5.5, 1.5, 0), Vector3(6, 0, 0));
3863

3964
InitClass = true;
4065
return S_OK;

Engine/Actor.h

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,11 @@
33
#define __ACTOR_H__
44
#include "pch.h"
55

6-
//#include "GameObjects.h"
7-
#include "Camera.h"
8-
#include "Dialogs.h"
6+
//#include "Dialogs.h"
97

10-
class Engine;
11-
extern shared_ptr<Engine> Application;
12-
#include "Engine.h"
13-
14-
class Actor : public Camera//, public Dialogs
8+
class Actor //, public Dialogs
159
{
1610
public:
17-
18-
Actor() {}
19-
~Actor() {}
20-
2111
bool isDead() { return IsDead; }
2212

2313
void ChangeHealth(float Value, char Char)
@@ -72,8 +62,6 @@ class Actor : public Camera//, public Dialogs
7262
bool IsDead = false, InitClass = false;
7363
float Health = 100.0f, FOV = 0.80f;
7464

75-
//**********
76-
Vector3 GetPostitionFromCamera() { return Application->getCamera()->GetEyePt(); }
7765

7866
//**********
7967
// This is a cheat

Engine/CCommands.cpp

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ void Commands::Work(shared_ptr<dialogs> &Console, string Text)
3333
return;
3434
}
3535
else
36-
Console->getComponents()->childs.back()->getComponent()->UText.back()->AddCLText(Type::Error,
37-
string(string("You're typed: ") + Text + string("\n[error]: Unknown command type Help for help!")));
36+
Console->getComponents()->FindComponentChild("ConsoleText")->getComponents().front()->
37+
FindComponentUText("##CText")->AddCLText(Type::Error, string(string("You're typed: ") + Text +
38+
string("\n[error]: Unknown command type Help for help!")));
3839

3940
File_system::AddTextToLog(string("\n> ") + Text + string("\n"), Type::Normal);
4041
}
@@ -67,7 +68,8 @@ void Commands::ExecCommand(shared_ptr<dialogs> &Console, shared_ptr<Command> &cm
6768
{
6869
if (cmd->CommandUnprocessed.empty())
6970
{
70-
Console->getComponents()->childs.back()->getComponent()->UText.back()->AddCLText(Type::Error,
71+
Console->getComponents()->FindComponentChild("ConsoleText")->getComponents().front()->
72+
FindComponentUText("##CText")->AddCLText(Type::Error,
7173
string(cmd->CommandStr + string(": No parameters found! You must add several parameters, such like: ") +
7274
cmd->CommandNeededParams));
7375
return;
@@ -94,14 +96,16 @@ void Commands::ExecCommand(shared_ptr<dialogs> &Console, shared_ptr<Command> &cm
9496
all.append(string(string("\n") + ListCommandsWithParams.at(i)));
9597
}
9698

97-
Console->getComponents()->childs.back()->getComponent()->UText.back()->AddCLText(
98-
Type::Information, string("#list of available commands: ") + all);
99+
Console->getComponents()->FindComponentChild("ConsoleText")->getComponents().front()->
100+
FindComponentUText("##CText")->AddCLText(Type::Information,
101+
string("#list of available commands: ") + all);
99102
}
100103
else if (contains(CMD, "quit"))
101104
Application->Quit();
102105
else if (contains(CMD, "clear"))
103106
{
104-
Console->getComponents()->childs.back()->getComponent()->UText.back()->ClearText();
107+
Console->getComponents()->FindComponentChild("ConsoleText")->getComponents().front()->
108+
FindComponentUText("##CText")->ClearBuffer();
105109
File_system::ClearLogs();
106110
return;
107111
}
@@ -117,7 +121,8 @@ void Commands::ExecCommand(shared_ptr<dialogs> &Console, shared_ptr<Command> &cm
117121
Application->getCamera()->GetEyePt().z), PxForceMode::eFORCE);
118122
}
119123
else
120-
Console->getComponents()->childs.back()->getComponent()->UText.back()->AddCLText(Type::Error,
124+
Console->getComponents()->FindComponentChild("ConsoleText")->getComponents().front()->
125+
FindComponentUText("##CText")->AddCLText(Type::Error,
121126
string(CMD + string(": GetPhysDynamicObject() return NULL!!!")));
122127
}
123128
else if (contains(CMD, "cleanphysbox"))
@@ -142,8 +147,8 @@ void Commands::ExecCommand(shared_ptr<dialogs> &Console, shared_ptr<Command> &cm
142147
//}
143148
}
144149

145-
Console->getComponents()->childs.back()->getComponent()->UText.back()->AddCLText(Type::Normal,
146-
string(cmd->CommandStr + string(" #Apply")));
150+
Console->getComponents()->FindComponentChild("ConsoleText")->getComponents().front()->
151+
FindComponentUText("##CText")->AddCLText(Type::Normal, string(cmd->CommandStr + string(" #Apply")));
147152

148153
for (size_t i = 0; i < History.size(); i++)
149154
{
@@ -213,8 +218,7 @@ void Commands::Command::CheckRequiredParam()
213218
}
214219
deleteWord(CommandUnprocessed, " ");
215220

216-
int i = 0;
217-
for (int i1 = 1; INT16_MAX; i1++)
221+
for (int i = 0; true; i++)
218222
{
219223
if (i == CommandNeededParams.length())
220224
break;

Engine/Camera.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,11 @@ void Camera::SetProjParams(float fFOV, float fAspect, float fNearPlane, float fF
5454

5555
void Camera::Teleport(Vector3 NewPos, Vector3 NewLook, bool NoTPPhysx)
5656
{
57-
if (C_CT.operator bool() && !NoTPPhysx)
57+
if (C_CT.operator bool() && !NoTPPhysx && (NewPos != Vector3::Zero))
5858
C_CT->getController()->setPosition(PxExtendedVec3(NewPos.x, NewPos.y, NewPos.z));
5959

60-
SetViewParams(NewPos, NewLook);
60+
if (NewPos != Vector3::Zero)
61+
SetViewParams(NewPos, NewLook);
6162
}
6263

6364
void Camera::SetNumberOfFramesToSmoothMouseData(int nFrames)
@@ -76,6 +77,11 @@ Matrix Camera::GetProjMatrix() const
7677
return m_mProj;
7778
}
7879

80+
Matrix Camera::GetRotMatrix() const
81+
{
82+
return mCameraRot;
83+
}
84+
7985
Vector3 Camera::GetLookAtPt() const
8086
{
8187
return m_vLookAt;
@@ -177,7 +183,7 @@ void Camera::UpdateMouseDelta()
177183
m_vRotVelocity = m_vMouseDelta * m_fRotationScaler;
178184
}
179185

180-
void Camera::UpdateVelocity(_In_ float fElapsedTime)
186+
void Camera::UpdateVelocity(float fElapsedTime)
181187
{
182188
Vector3 vGamePadRightThumb = XMVectorSet(m_vGamePadRightThumb.x, -m_vGamePadRightThumb.z, 0, 0),
183189

@@ -232,7 +238,7 @@ void Camera::Reset()
232238
Teleport(m_vDefaultEye, m_vDefaultLookAt);
233239
}
234240

235-
void Camera::FrameMove(_In_ float fElapsedTime)
241+
void Camera::FrameMove(float fElapsedTime)
236242
{
237243
if (Application->getKeyboard()->GetState().LeftShift)
238244
#if defined (DEBUG)

Engine/Camera.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,10 @@ class Camera: public Camera_Control
4444
void SetNumberOfFramesToSmoothMouseData(int nFrames);
4545
void SetResetCursorAfterMove(bool bResetCursorAfterMove) { m_bResetCursorAfterMove = bResetCursorAfterMove; }
4646

47-
void setDrawCursor(bool IsDraw) { ShowCursor(IsDraw); }
48-
4947
// Functions to get state
5048
Matrix GetViewMatrix() const;
5149
Matrix GetProjMatrix() const;
50+
Matrix GetRotMatrix() const;
5251
Vector3 GetLookAtPt() const;
5352
float GetNearClip() const;
5453
float GetFarClip() const;

Engine/Console.cpp

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,13 @@ HRESULT Console::Init()
2828

2929
for (size_t i = 0; i < Log.size(); i++)
3030
{
31+
auto Cmp = Dialog->getComponents()->FindComponentChild("ConsoleText")->getComponents().front();
3132
if (Log.at(i).find("[ERROR]") != string::npos)
32-
Dialog->getComponents()->childs.back()->getComponent()->UText.back()->AddCLText(Type::Error,
33-
Log.at(i));
33+
Cmp->FindComponentUText("##CText")->AddCLText(Type::Error, Log.at(i));
3434
else if (Log.at(i).find("[INFO]") != string::npos)
35-
Dialog->getComponents()->childs.back()->getComponent()->UText.back()->AddCLText(Type::Information,
36-
Log.at(i));
35+
Cmp->FindComponentUText("##CText")->AddCLText(Type::Information, Log.at(i));
3736
else
38-
Dialog->getComponents()->childs.back()->getComponent()->UText.back()->AddCLText(Type::Normal,
39-
Log.at(i));
37+
Cmp->FindComponentUText("##CText")->AddCLText(Type::Normal, Log.at(i));
4038
}
4139

4240
InitClass = true;
@@ -60,17 +58,18 @@ void Console::Render()
6058

6159
Dialog->Render();
6260

63-
auto IText = Dialog->getComponents()->Itext.back();
61+
auto IText = Dialog->getComponents()->FindComponentIText("##Console_CmdIText");
6462
auto text = IText->GetText();
6563
auto History = ProcessCommand->getHistoryCommands();
66-
auto TextList = Dialog->getComponents()->TList.back();
64+
auto TextList = Dialog->getComponents()->FindComponentTList("##HintCmd");
6765
if (text.empty() && !(IText->isPressUp() || IText->isPressDown()))
6866
{
6967
TextList->clearItems();
7068
return;
7169
}
7270

73-
if (!IText->isActive() && !History.empty() && (IText->isPressUp() || IText->isPressDown()))
71+
// History
72+
if (IText->getHistory() && !IText->isActive() && !History.empty() && (IText->isPressUp() || IText->isPressDown()))
7473
{
7574
int PosHistory = ProcessCommand->getPosHistory();
7675
if (PosHistory == -1 || PosHistory >= (int)History.size())
@@ -111,8 +110,7 @@ void Console::Render()
111110
if (!TextList->FindInItems(cmd->CommandStr))
112111
TextList->addItem(cmd->CommandStr);
113112
}
114-
else
115-
if (!TextList->FindInItems(cmd->CommandStr + string(" ") + cmd->CommandNeededParams))
113+
else if (!TextList->FindInItems(cmd->CommandStr + string(" ") + cmd->CommandNeededParams))
116114
TextList->addItem(cmd->CommandStr + string(" ") + cmd->CommandNeededParams);
117115
}
118116
else
@@ -122,7 +120,7 @@ void Console::Render()
122120

123121
const float footer_height_to_reserve = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing();
124122
if (!Dialog->getComponents()->childs.empty())
125-
Dialog->getComponents()->childs.back()->setSize(ImVec2(0, -footer_height_to_reserve));
123+
Dialog->getComponents()->FindComponentChild("ConsoleText")->setSize(ImVec2(0, -footer_height_to_reserve));
126124
}
127125

128126
void Console::OpenConsole()
@@ -158,14 +156,14 @@ void Console::LogError(string Msg)
158156
if (!ProcessCommand.operator bool() || !Dialog.operator bool() || !Application->getUI().operator bool()
159157
|| !Consl.operator bool()
160158
|| Consl->getComponents()->childs.empty()
161-
|| Consl->getComponents()->childs.back()->getComponent()->UText.empty())
159+
|| Consl->getComponents()->FindComponentChild("ConsoleText")->getComponents().front()->UText.empty())
162160
{
163161
File_system::AddTextToLog(Msg, Type::Error);
164162
return;
165163
}
166164

167-
Consl->getComponents()->childs.back()->getComponent()->UText.back()->AddCLText(
168-
Type::Error, Msg);
165+
Consl->getComponents()->FindComponentChild("ConsoleText")->getComponents().front()->FindComponentUText("##CText")->
166+
AddCLText(Type::Error, Msg);
169167

170168
File_system::AddTextToLog(Msg, Type::Error);
171169
}
@@ -179,14 +177,14 @@ void Console::LogInfo(string Msg)
179177
if (!ProcessCommand.operator bool() || !Dialog.operator bool() || !Application->getUI().operator bool()
180178
|| !Consl.operator bool()
181179
|| Consl->getComponents()->childs.empty()
182-
|| Consl->getComponents()->childs.back()->getComponent()->UText.empty())
180+
|| Consl->getComponents()->FindComponentChild("ConsoleText")->getComponents().front()->UText.empty())
183181
{
184182
File_system::AddTextToLog(Msg, Type::Information);
185183
return;
186184
}
187185

188-
Consl->getComponents()->childs.back()->getComponent()->UText.back()->AddCLText(
189-
Type::Information, Msg);
186+
Consl->getComponents()->FindComponentChild("ConsoleText")->getComponents().front()->FindComponentUText("##CText")->
187+
AddCLText(Type::Information, Msg);
190188

191189
File_system::AddTextToLog(Msg, Type::Information);
192190
}
@@ -200,14 +198,14 @@ void Console::LogNormal(string Msg)
200198
if (!ProcessCommand.operator bool() || !Dialog.operator bool() || !Application->getUI().operator bool()
201199
|| !Consl.operator bool()
202200
|| Consl->getComponents()->childs.empty()
203-
|| Consl->getComponents()->childs.back()->getComponent()->UText.empty())
201+
|| Consl->getComponents()->FindComponentChild("ConsoleText")->getComponents().front()->UText.empty())
204202
{
205203
File_system::AddTextToLog(Msg, Type::Normal);
206204
return;
207205
}
208206

209-
Consl->getComponents()->childs.back()->getComponent()->UText.back()->AddCLText(
210-
Type::Normal, Msg);
207+
Consl->getComponents()->FindComponentChild("ConsoleText")->getComponents().front()->FindComponentUText("##CText")->
208+
AddCLText(Type::Normal, Msg);
211209

212210
File_system::AddTextToLog(Msg, Type::Normal);
213211
}

0 commit comments

Comments
 (0)