Skip to content

Bug fixes #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file renamed HPL2/dependencies.zip → HPL2/dependencies.rar
Binary file not shown.
551 changes: 551 additions & 0 deletions HPL2/tests/Common/SimpleCamera.cpp

Large diffs are not rendered by default.

94 changes: 94 additions & 0 deletions HPL2/tests/Common/SimpleCamera.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
* Copyright © 2011-2020 Frictional Games
*
* This file is part of Amnesia: A Machine For Pigs.
*
* Amnesia: A Machine For Pigs 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.

* Amnesia: A Machine For Pigs is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Amnesia: A Machine For Pigs. If not, see <https://www.gnu.org/licenses/>.
*/

#include "hpl.h"

using namespace hpl;

class cSimpleCamera : public iUpdateable
{
public:
cSimpleCamera(const tString& asAppName,cEngine *apGame, cWorld *apWorld, float afSpeed,cVector3f avStartPos,bool abShowFPS, bool abLoadSkin=true);
~cSimpleCamera();

void Update(float afFrameTime);

void OnDraw(float afFrameTime);

void OnPostRender(float afFrameTime);

void AppGotMouseFocus();
void AppLostMouseFocus();

void SetActive(bool abX){ mbActive = abX;}

cGuiSet* GetSet(){ return mpGuiSet;}

cCamera* GetCamera(){ return mpCamera;}
cViewport* GetViewport(){ return mpViewport;}

iFontData* GetFont(){ return mpFont; }

float GetSpeed(){ return mfSpeed;}
void SetSpeed(float afSpeed){ mfSpeed = afSpeed;}

void SetDrawFPS(bool abX){ mbDrawFPS =abX;}

void SetMouseMode(bool abActive);
bool GetMouseMode(){ return mbMouseActive;}

void SetCameraInMouseMode(bool abX){ mbCameraInMouseMode=abX;}
void SetMatrixFlyCamera(bool abX);

void ListContainerNodeData(iRenderableContainerNode *apNode, int alLevel);

cMatrixf m_mtxLastView;
private:
void CalculateMouseCamera();

cEngine *mpEngine;

tString msAppName;

cGui *mpGui;
cGuiSet *mpGuiSet;
cGuiSkin *mpGuiSkin;

cGuiGfxElement *mpTestGfx;

iFontData* mpFont;
cCamera* mpCamera;
cViewport *mpViewport;

cVector3f mvMouseCameraPos;
cVector3f mvMouseCameraAngles;
float mfMouseCameraDistance;

float mfSpeed;
bool mbActive;
bool mbMouseActive;
bool mbCameraInMouseMode;
bool mbMatrixFlyCamera;

bool mbDrawFPS;

std::list<float> mlstFrameTimes;
float mfTakeFrameTimeCount;
float mfAvgFrameTime;
};
27 changes: 27 additions & 0 deletions HPL2/tests/Common/stdafx.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright © 2011-2020 Frictional Games
*
* This file is part of Amnesia: A Machine For Pigs.
*
* Amnesia: A Machine For Pigs 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.

* Amnesia: A Machine For Pigs is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Amnesia: A Machine For Pigs. If not, see <https://www.gnu.org/licenses/>.
*/

// stdafx.cpp : source file that includes just the standard includes
// simple3d.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information

#include "stdafx.h"

// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
40 changes: 40 additions & 0 deletions HPL2/tests/Common/stdafx.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright © 2011-2020 Frictional Games
*
* This file is part of Amnesia: A Machine For Pigs.
*
* Amnesia: A Machine For Pigs 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.

* Amnesia: A Machine For Pigs is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Amnesia: A Machine For Pigs. If not, see <https://www.gnu.org/licenses/>.
*/

// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//

#pragma once

#ifdef WIN32
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
#include <windows.h>
#endif
// C RunTime Header Files
#include <stdlib.h>
#include <memory.h>
#ifdef WIN32
#include <malloc.h>
#include <tchar.h>
#endif

#include "hpl.h"
2 changes: 1 addition & 1 deletion HPL2/tools/editors/common/EditorBaseClasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ cEngine* iEditorBase::Init(cEngine* apEngine, bool abDestroyEngineOnExit)

mpEngine = CreateHPLEngine(eHplAPI_OpenGL, eHplSetup_All, &vars);
mpEngine->GetInput()->GetLowLevel()->LockInput(false);
gpEngine->GetInput()->GetLowLevel()->RelativeMouse(false);
mpEngine->GetInput()->GetLowLevel()->RelativeMouse(false);

mpEngine->GetResources()->GetMaterialManager()->SetTextureSizeDownScaleLevel(cString::ToInt(GetSetting("TexQuality").c_str(), 0));

Expand Down
3 changes: 3 additions & 0 deletions HPL2/tools/editors/leveleditor/LevelEditorWindowGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,15 @@ void cLevelEditorWindowGroup::OnInitLayout()
mpListGroups = mpSet->CreateWidgetListBox(cVector3f(10,50,1), cVector2f(250,340), mpWindow);
mpListGroups->SetDefaultFontSize(vTextSize);
mpListGroups->AddCallback(eGuiMessage_SelectionChange, this, kGuiCallback(GroupList_OnSelectionChange));
AddWidget(mpListGroups);

mpListGroupEntities = mpSet->CreateWidgetMultiPropertyListBox(cVector3f(270,50,1), cVector2f(340,340), mpWindow);
mpListGroupEntities->SetDefaultFontSize(vTextSize);
mpListGroupEntities->SetAllowMultiSelection(true);
mpListGroupEntities->AddCallback(eGuiMessage_SelectionChange, this, kGuiCallback(EntityList_OnSelectionChange));
mpListGroupEntities->AddColumn("Name", 0);
mpListGroupEntities->SetColumnWidth(0,340);
AddWidget(mpListGroupEntities);

cWidgetLabel* pLabelParams = mpSet->CreateWidgetLabel(cVector3f(10,400,0.1f), 0, _W("Group parameters"), mpWindow);
pLabelParams->SetDefaultFontSize(vTextSize);
Expand All @@ -241,6 +243,7 @@ void cLevelEditorWindowGroup::OnInitLayout()
mpCheckBoxGroupVisibility = mpSet->CreateWidgetCheckBox(cVector3f(10,450,0.1f), 0, _W("Visible"),mpWindow);
mpCheckBoxGroupVisibility->SetDefaultFontSize(vTextSize);
mpCheckBoxGroupVisibility->AddCallback(eGuiMessage_CheckChange, this, kGuiCallback(VisibilityCheckBox_OnChange));
AddWidget(mpCheckBoxGroupVisibility);

mpEditor->SetLayoutNeedsUpdate(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ void cLevelEditorWindowLevelSettings::OnInitLayout()
mpWindow->SetText(_W("Level Settings"));

cWidgetTabFrame* pTabFrame = mpSet->CreateWidgetTabFrame(cVector3f(10,35,0.1f), mvSize-cVector2f(20,40), _W(""), mpWindow);
AddWidget(pTabFrame);

////////////////////////////////////////////////////////
// SkyBox parameters tab
Expand Down Expand Up @@ -123,7 +124,7 @@ void cLevelEditorWindowLevelSettings::OnInitLayout()
vPos.x += mpInpGlobalMaxDecalTris->GetSize().x + 15;
mpBResetDecals = mpSet->CreateWidgetButton(vPos, cVector2f(100,20), _W("Reset created decals"), pTab);
mpBResetDecals->AddCallback(eGuiMessage_ButtonPressed, this, kGuiCallback(ResetDecals));

AddWidget(mpBResetDecals);
}

//---------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,15 +529,15 @@ bool cModelEditorWindowPhysicsTest::OnViewportUpdate(const cGuiMessageData& aDat
mpSet->SetAttentionWidget(mpImgViewport);

pInput->GetLowLevel()->LockInput(true);
pInput->GetLowLevel()->MouseRelative(true);
pInput->GetLowLevel()->RelativeMouse(true);
}
else if(mbViewMode==false && mpSet->GetAttentionWidget()==mpImgViewport)
{
mpSet->SetAttentionWidget(mpPrevAttention);
mpPrevAttention = NULL;

pInput->GetLowLevel()->LockInput(false);
pInput->GetLowLevel()->MouseRelative(false);
pInput->GetLowLevel()->RelativeMouse(false);

mCamera.SetTumbleActive(false);
mCamera.SetTrackActive(false);
Expand Down Expand Up @@ -651,7 +651,7 @@ bool cModelEditorWindowPhysicsTest::OnViewportMouseUp(const cGuiMessageData& aDa
}

pInput->GetLowLevel()->LockInput(false);
pInput->GetLowLevel()->MouseRelative(false);
pInput->GetLowLevel()->RelativeMouse(false);

if(mbViewMode)
{
Expand Down
4 changes: 3 additions & 1 deletion HPL2/tools/mapview/MapView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,8 @@ class cSimpleUpdate : public iUpdateable
gpSimpleCamera->GetViewport()->AddRendererCallback(&renderCallback);

gpSimpleCamera->SetMouseMode(true);
gpEngine->GetInput()->GetLowLevel()->LockInput(false);
gpEngine->GetInput()->GetLowLevel()->RelativeMouse(false);

//pSettings->mbLog = true;

Expand Down Expand Up @@ -2032,7 +2034,7 @@ int hplMain(const tString &asCommandline)
vars.mGraphics.mbFullscreen = gpConfig->GetBool("Screen","FullScreen", false);
gpEngine = CreateHPLEngine(eHplAPI_OpenGL, eHplSetup_All, &vars);
gpEngine->SetLimitFPS(false);
gpEngine->GetGraphics()->GetLowLevel()->SetVsyncActive(false);
gpEngine->GetGraphics()->GetLowLevel()->SetVsyncActive(false, false);
gpEngine->SetWaitIfAppOutOfFocus(true);

gsNodeCont_Name = gpConfig->GetString("NodeCont","Name", "MapViewTest");
Expand Down
5 changes: 3 additions & 2 deletions HPL2/tools/modelview/ModelView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@ class cSimpleUpdate : public iUpdateable
void SetupView()
{
gpEngine->GetInput()->GetLowLevel()->LockInput(false);
gpEngine->GetInput()->GetLowLevel()->RelativeMouse(false);

cRenderSettings *pSettings = gpSimpleCamera->GetViewport()->GetRenderSettings();
gpSimpleCamera->GetViewport()->AddRendererCallback(&renderCallback);
Expand Down Expand Up @@ -979,7 +980,7 @@ class cSimpleUpdate : public iUpdateable
else
SetPhysicsActive(gbPhysicsActive);

cPlatform::SetWindowCaption("ModelView - "+cString::GetFileName(asFileName));
mpLowLevelGraphics->SetWindowCaption("ModelView - "+cString::GetFileName(asFileName));

Log("--------- MODEL INFO ------------------\n");

Expand Down Expand Up @@ -2396,7 +2397,7 @@ int hplMain(const tString &asCommandline)
//vars.mGraphics.mvWindowPosition = cVector2l(0,0);
gpEngine = CreateHPLEngine(eHplAPI_OpenGL, eHplSetup_All, &vars);
gpEngine->SetLimitFPS(false);
gpEngine->GetGraphics()->GetLowLevel()->SetVsyncActive(false);
gpEngine->GetGraphics()->GetLowLevel()->SetVsyncActive(false, false);
gpEngine->SetWaitIfAppOutOfFocus(true);


Expand Down