-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from izawartka/development
1.17
- Loading branch information
Showing
19 changed files
with
1,029 additions
and
529 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include "pch.h" | ||
#include "CameraMoveBtn.h" | ||
|
||
BEGIN_MESSAGE_MAP(CameraMoveBtn, CButton) | ||
ON_WM_LBUTTONDOWN() | ||
ON_WM_LBUTTONUP() | ||
END_MESSAGE_MAP() | ||
|
||
void CameraMoveBtn::OnLButtonDown(UINT nFlags, CPoint point) | ||
{ | ||
CButton::OnLButtonDown(nFlags, point); | ||
|
||
GetParent()->SendMessage(WM_CAMERA_MOVE_BTN, GetDlgCtrlID(), TRUE); | ||
} | ||
|
||
void CameraMoveBtn::OnLButtonUp(UINT nFlags, CPoint point) | ||
{ | ||
CButton::OnLButtonUp(nFlags, point); | ||
|
||
GetParent()->SendMessage(WM_CAMERA_MOVE_BTN, GetDlgCtrlID(), FALSE); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#pragma once | ||
#include <afxwin.h> | ||
#include <afxext.h> | ||
|
||
#define WM_CAMERA_MOVE_BTN (WM_USER + 1000) | ||
|
||
class CameraMoveBtn : public CButton | ||
{ | ||
public: | ||
|
||
protected: | ||
afx_msg void OnLButtonDown(UINT nFlags, CPoint point); | ||
afx_msg void OnLButtonUp(UINT nFlags, CPoint point); | ||
|
||
DECLARE_MESSAGE_MAP() | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,206 @@ | ||
#include "pch.h" | ||
#include "gta2dll.h" | ||
#include "CameraWindow.h" | ||
#include "gta2-helper.h" | ||
|
||
CameraWindow* camWnd = nullptr; | ||
|
||
IMPLEMENT_DYNAMIC(CameraWindow, CDialogEx) | ||
|
||
CameraWindow::CameraWindow(CWnd* pParent /*=nullptr*/) | ||
: CDialogEx(IDD_PS, pParent) | ||
{ | ||
camWnd = this; | ||
} | ||
|
||
CameraWindow::~CameraWindow() | ||
{ | ||
|
||
} | ||
|
||
BEGIN_MESSAGE_MAP(CameraWindow, CDialogEx) | ||
ON_EN_CHANGE(IDC_CAM_X, &CameraWindow::OnPositionInput) | ||
ON_EN_CHANGE(IDC_CAM_Y, &CameraWindow::OnPositionInput) | ||
ON_EN_CHANGE(IDC_CAM_Z, &CameraWindow::OnPositionInput) | ||
ON_EN_CHANGE(IDC_CAM_ZOOM, &CameraWindow::OnPositionInput) | ||
ON_BN_CLICKED(IDC_CAM_SYNC, &CameraWindow::OnGoToTargetClick) | ||
ON_BN_CLICKED(IDC_CAM_FPL, &CameraWindow::OnCheckboxChange) | ||
ON_BN_CLICKED(IDC_CAM_ZL, &CameraWindow::OnCheckboxChange) | ||
ON_BN_CLICKED(IDC_CAM_ZOOML, &CameraWindow::OnCheckboxChange) | ||
ON_BN_CLICKED(IDC_CAM_TARL, &CameraWindow::OnCheckboxChange) | ||
ON_BN_CLICKED(IDC_CAM_TP, &CameraWindow::OnTeleport) | ||
ON_MESSAGE(WM_CAMERA_MOVE_BTN, &CameraWindow::OnMoveButton) | ||
ON_WM_HSCROLL() | ||
END_MESSAGE_MAP() | ||
|
||
|
||
void CameraWindow::DoDataExchange(CDataExchange* pDX) | ||
{ | ||
CDialogEx::DoDataExchange(pDX); | ||
DDX_Text(pDX, IDC_CAM_X, m_xPos); | ||
DDX_Text(pDX, IDC_CAM_Y, m_yPos); | ||
DDX_Text(pDX, IDC_CAM_Z, m_zPos); | ||
DDX_Text(pDX, IDC_CAM_ZOOM, m_zoom); | ||
DDX_Check(pDX, IDC_CAM_FPL, m_followPlayer); | ||
DDX_Check(pDX, IDC_CAM_ZL, m_lockZ); | ||
DDX_Check(pDX, IDC_CAM_ZOOML, m_lockZoom); | ||
DDX_Check(pDX, IDC_CAM_TARL, m_lockToTarget); | ||
DDX_Control(pDX, IDC_CAM_SEN, m_sensitivitySlider); | ||
} | ||
|
||
BOOL CameraWindow::OnInitDialog() | ||
{ | ||
CDialogEx::OnInitDialog(); | ||
|
||
m_moveBtns[0].SubclassDlgItem(IDC_CAM_UP, this); | ||
m_moveBtns[1].SubclassDlgItem(IDC_CAM_DOWN, this); | ||
m_moveBtns[2].SubclassDlgItem(IDC_CAM_LEFT, this); | ||
m_moveBtns[3].SubclassDlgItem(IDC_CAM_RIGHT, this); | ||
m_moveBtns[4].SubclassDlgItem(IDC_CAM_ZUP, this); | ||
m_moveBtns[5].SubclassDlgItem(IDC_CAM_ZDOWN, this); | ||
|
||
m_sensitivitySlider.SetRange(1, 100); | ||
m_sensitivitySlider.SetPos(m_sensitivity); | ||
|
||
return TRUE; | ||
} | ||
|
||
int CameraWindow::OnCreate(LPCREATESTRUCT lpCreateStruct) | ||
{ | ||
if (CDialogEx::OnCreate(lpCreateStruct) == -1) | ||
return -1; | ||
} | ||
|
||
void CameraWindow::OnPositionInput() | ||
{ | ||
if (!m_player) return; | ||
|
||
UpdateData(TRUE); | ||
|
||
m_player->ph1.cameraPos.x = FloatEncode(m_xPos); | ||
m_player->ph1.cameraPos.y = FloatEncode(m_yPos); | ||
m_player->ph1.cameraPos.z = FloatEncode(m_zPos); | ||
m_player->ph1.cameraPos.zoom = m_zoom; | ||
|
||
m_followPlayer = 0; | ||
m_player->ph1.followedPedID = 0; | ||
|
||
UpdateData(FALSE); | ||
} | ||
|
||
void CameraWindow::OnCheckboxChange() | ||
{ | ||
if (!m_player) return; | ||
|
||
UpdateData(TRUE); | ||
m_player->ph1.followedPedID = m_followPlayer == 1 ? 1 : 0; | ||
} | ||
|
||
void CameraWindow::OnGTAGameTick() | ||
{ | ||
if (!this->IsWindowVisible()) return; | ||
|
||
// Return if not in the game | ||
if (*(DWORD*)ptrToPedManager == 0) | ||
{ | ||
m_player = nullptr; | ||
return; | ||
} | ||
|
||
Game* pGame = (Game*)*(DWORD*)ptrToGame; | ||
if (!pGame) return; | ||
|
||
m_player = pGame->CurrentPlayer; | ||
if (!m_player) return; | ||
|
||
if (m_lockToTarget) { | ||
m_player->ph1.cameraPos = m_player->ph1.cameraPosTarget; | ||
} | ||
|
||
m_xPos = FloatDecode(m_player->ph1.cameraPos.x); | ||
m_yPos = FloatDecode(m_player->ph1.cameraPos.y); | ||
|
||
if (m_lockZ) { | ||
m_player->ph1.cameraPos.z = FloatEncode(m_zPos); | ||
} | ||
else { | ||
m_zPos = FloatDecode(m_player->ph1.cameraPos.z); | ||
} | ||
|
||
if (m_lockZoom) { | ||
m_player->ph1.cameraPos.zoom = m_zoom; | ||
} | ||
else { | ||
m_zoom = m_player->ph1.cameraPos.zoom; | ||
} | ||
|
||
m_followPlayer = m_player->ph1.followedPedID == 1 ? 1 : 0; | ||
|
||
UpdateData(FALSE); | ||
|
||
HandleButtonMove(); | ||
} | ||
|
||
void CameraWindow::HandleButtonMove() | ||
{ | ||
if (!m_player) return; | ||
if (m_btnMoveDirection == 0) return; | ||
float moveSpeed = m_sensitivity / 100.0f; | ||
|
||
switch (m_btnMoveDirection) | ||
{ | ||
case IDC_CAM_UP: | ||
m_yPos -= moveSpeed; | ||
break; | ||
case IDC_CAM_DOWN: | ||
m_yPos += moveSpeed; | ||
break; | ||
case IDC_CAM_LEFT: | ||
m_xPos -= moveSpeed; | ||
break; | ||
case IDC_CAM_RIGHT: | ||
m_xPos += moveSpeed; | ||
break; | ||
case IDC_CAM_ZUP: | ||
m_zPos += moveSpeed; | ||
break; | ||
case IDC_CAM_ZDOWN: | ||
m_zPos -= moveSpeed; | ||
break; | ||
} | ||
|
||
UpdateData(FALSE); | ||
OnPositionInput(); | ||
} | ||
|
||
void CameraWindow::OnGoToTargetClick() | ||
{ | ||
if (!m_player) return; | ||
|
||
m_player->ph1.cameraPos = m_player->ph1.cameraPosTarget; | ||
} | ||
|
||
|
||
void CameraWindow::OnTeleport() | ||
{ | ||
if (!m_player) return; | ||
|
||
fnDoTeleport(m_player, m_xPos, m_yPos); | ||
} | ||
|
||
void CameraWindow::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) | ||
{ | ||
if (pScrollBar->GetDlgCtrlID() == IDC_CAM_SEN) | ||
{ | ||
m_sensitivity = ((CSliderCtrl*)pScrollBar)->GetPos(); | ||
} | ||
|
||
CDialogEx::OnHScroll(nSBCode, nPos, pScrollBar); | ||
} | ||
|
||
LRESULT CameraWindow::OnMoveButton(WPARAM wParam, LPARAM lParam) | ||
{ | ||
m_btnMoveDirection = lParam == TRUE ? (int)wParam : 0; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#pragma once | ||
|
||
// Ped spawner dialog | ||
#include "gta2-helper.h" | ||
#include "CameraMoveBtn.h" | ||
#include <vector> | ||
|
||
extern class MainWindow; | ||
|
||
class CameraWindow : public CDialogEx | ||
{ | ||
DECLARE_DYNAMIC(CameraWindow) | ||
|
||
public: | ||
CameraWindow(CWnd* pParent = nullptr); // standard constructor | ||
virtual ~CameraWindow(); | ||
|
||
// Dialog Data | ||
#ifdef AFX_DESIGN_TIME | ||
enum { IDD = IDD_PS }; | ||
#endif | ||
|
||
protected: | ||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support | ||
virtual BOOL OnInitDialog(); | ||
|
||
DECLARE_MESSAGE_MAP() | ||
|
||
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); | ||
afx_msg void OnPositionInput(); | ||
afx_msg void OnCheckboxChange(); | ||
afx_msg void OnGoToTargetClick(); | ||
afx_msg void OnTeleport(); | ||
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); | ||
afx_msg LRESULT OnMoveButton(WPARAM wParam, LPARAM lParam); | ||
|
||
void HandleButtonMove(); | ||
|
||
public: | ||
void OnGTAGameTick(); | ||
|
||
bool m_active = false; | ||
MainWindow* m_mainWindow = nullptr; | ||
|
||
protected: | ||
Player* m_player = nullptr; | ||
|
||
double m_xPos = 0; | ||
double m_yPos = 0; | ||
double m_zPos = 0; | ||
int m_zoom = 0; | ||
int m_followPlayer = 1; | ||
int m_lockZ = 0; | ||
int m_lockZoom = 0; | ||
int m_lockToTarget = 0; | ||
CameraMoveBtn m_moveBtns[6]; | ||
UINT m_btnMoveDirection = 0; | ||
CSliderCtrl m_sensitivitySlider; | ||
int m_sensitivity = 10; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.