mirror of
https://github.com/scp-fs2open/fs2open.github.com.git
synced 2026-11-07 08:15:59 -10:00
add CalcRelativeCoords dlg
This commit is contained in:
1 parent
77f96638d7
commit
d195c1333c
8 files changed
+253
-1
No files matched your search
@@ -23,6 +23,8 @@ set(FRED2_SOURCES
|
||||
bgbitmapdlg.h
|
||||
briefingeditordlg.cpp
|
||||
briefingeditordlg.h
|
||||
calcrelativecoordsdlg.cpp
|
||||
calcrelativecoordsdlg.h
|
||||
campaigneditordlg.cpp
|
||||
campaigneditordlg.h
|
||||
campaignfilelistbox.cpp
|
||||
|
||||
@@ -0,0 +1,168 @@
|
||||
// CalcRelativeCoordDlg.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "FRED.h"
|
||||
#include "calcrelativecoordsdlg.h"
|
||||
#include "orienteditor.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
calc_relative_coords_dlg::calc_relative_coords_dlg(CWnd *pParent /*=nullptr*/)
|
||||
: CDialog(calc_relative_coords_dlg::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(calc_relative_coords_dlg)
|
||||
m_distance = _T("");
|
||||
m_orientation_p = _T("");
|
||||
m_orientation_b = _T("");
|
||||
m_orientation_h = _T("");
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
void calc_relative_coords_dlg::DoDataExchange(CDataExchange *pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(calc_relative_coords_dlg)
|
||||
DDX_Control(pDX, IDC_ORIGIN_LIST, m_origin_list);
|
||||
DDX_Control(pDX, IDC_SATELLITE_LIST, m_satellite_list);
|
||||
DDX_Text(pDX, IDC_DISTANCE, m_distance);
|
||||
DDX_Text(pDX, IDC_ORIENTATION_P, m_orientation_p);
|
||||
DDX_Text(pDX, IDC_ORIENTATION_B, m_orientation_b);
|
||||
DDX_Text(pDX, IDC_ORIENTATION_H, m_orientation_h);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
BEGIN_MESSAGE_MAP(calc_relative_coords_dlg, CDialog)
|
||||
//{{AFX_MSG_MAP(calc_relative_coords_dlg)
|
||||
ON_LBN_SELCHANGE(IDC_ORIGIN_LIST, OnSelchangeOriginList)
|
||||
ON_LBN_SELCHANGE(IDC_SATELLITE_LIST, OnSelchangeSatelliteList)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
BOOL calc_relative_coords_dlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
m_origin_list.ResetContent();
|
||||
m_satellite_list.ResetContent();
|
||||
m_object_indexes.clear();
|
||||
|
||||
bool marked_satellite = false;
|
||||
|
||||
for (auto ptr = GET_FIRST(&obj_used_list); ptr != END_OF_LIST(&obj_used_list); ptr = GET_NEXT(ptr))
|
||||
{
|
||||
bool added = false;
|
||||
|
||||
if (ptr->type == OBJ_START || ptr->type == OBJ_SHIP)
|
||||
{
|
||||
m_origin_list.AddString(Ships[ptr->instance].ship_name);
|
||||
m_satellite_list.AddString(Ships[ptr->instance].ship_name);
|
||||
|
||||
added = true;
|
||||
}
|
||||
else if (ptr->type == OBJ_WAYPOINT)
|
||||
{
|
||||
SCP_string text;
|
||||
int waypoint_num;
|
||||
|
||||
auto wp_list = find_waypoint_list_with_instance(ptr->instance, &waypoint_num);
|
||||
Assert(wp_list != nullptr);
|
||||
sprintf(text, "%s:%d", wp_list->get_name(), waypoint_num + 1);
|
||||
m_origin_list.AddString(text.c_str());
|
||||
m_satellite_list.AddString(text.c_str());
|
||||
|
||||
added = true;
|
||||
}
|
||||
|
||||
if (added)
|
||||
{
|
||||
int objnum = OBJ_INDEX(ptr);
|
||||
|
||||
if (ptr->flags[Object::Object_Flags::Marked])
|
||||
{
|
||||
int list_size = (int)m_object_indexes.size();
|
||||
|
||||
if (cur_object_index == objnum)
|
||||
{
|
||||
m_origin_list.SetCurSel(list_size);
|
||||
}
|
||||
else if (!marked_satellite)
|
||||
{
|
||||
m_satellite_list.SetCurSel(list_size);
|
||||
marked_satellite = true;
|
||||
}
|
||||
}
|
||||
|
||||
m_object_indexes.push_back(objnum);
|
||||
}
|
||||
}
|
||||
|
||||
if (marked_satellite)
|
||||
update_coords();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void calc_relative_coords_dlg::OnSelchangeOriginList()
|
||||
{
|
||||
update_coords();
|
||||
}
|
||||
|
||||
void calc_relative_coords_dlg::OnSelchangeSatelliteList()
|
||||
{
|
||||
update_coords();
|
||||
}
|
||||
|
||||
void calc_relative_coords_dlg::update_coords()
|
||||
{
|
||||
int origin_index = m_origin_list.GetCurSel();
|
||||
int satellite_index = m_satellite_list.GetCurSel();
|
||||
|
||||
if (origin_index < 0 || satellite_index < 0)
|
||||
{
|
||||
m_distance = _T("0.0");
|
||||
m_orientation_p = _T("");
|
||||
m_orientation_b = _T("");
|
||||
m_orientation_h = _T("");
|
||||
|
||||
UpdateData(FALSE);
|
||||
return;
|
||||
}
|
||||
|
||||
int origin_objnum = m_object_indexes[origin_index];
|
||||
int satellite_objnum = m_object_indexes[satellite_index];
|
||||
|
||||
if (origin_objnum == satellite_objnum)
|
||||
{
|
||||
m_distance = _T("0.0");
|
||||
m_orientation_p = _T("");
|
||||
m_orientation_b = _T("");
|
||||
m_orientation_h = _T("");
|
||||
|
||||
UpdateData(FALSE);
|
||||
return;
|
||||
}
|
||||
|
||||
auto origin_pos = Objects[origin_objnum].pos;
|
||||
auto satellite_pos = Objects[satellite_objnum].pos;
|
||||
|
||||
// distance
|
||||
m_distance.Format("%.01f", vm_vec_dist(&origin_pos, &satellite_pos));
|
||||
|
||||
// calc change in orientation
|
||||
vec3d relative_vec;
|
||||
matrix relative_m;
|
||||
vm_vec_sub(&relative_vec, &satellite_pos, &origin_pos);
|
||||
vm_vector_2_matrix(&relative_m, &relative_vec, &Objects[origin_objnum].orient.vec.uvec);
|
||||
|
||||
angles ang;
|
||||
vm_extract_angles_matrix(&ang, &relative_m);
|
||||
m_orientation_p.Format("%.01f", orient_editor::to_degrees(ang.p));
|
||||
m_orientation_b.Format("%.01f", orient_editor::to_degrees(ang.b));
|
||||
m_orientation_h.Format("%.01f", orient_editor::to_degrees(ang.h));
|
||||
|
||||
UpdateData(FALSE);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
// CalcRelativeCoordsDlg.h : header file
|
||||
|
||||
#ifndef _CALCRELATIVECOORDSDLG_H
|
||||
#define _CALCRELATIVECOORDSDLG_H
|
||||
|
||||
class calc_relative_coords_dlg : public CDialog
|
||||
{
|
||||
public:
|
||||
calc_relative_coords_dlg(CWnd *pParent = nullptr);
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(calc_relative_coords_dlg)
|
||||
enum { IDD = IDD_CALC_RELATIVE_COORDS };
|
||||
CListBox m_origin_list;
|
||||
CListBox m_satellite_list;
|
||||
CString m_distance;
|
||||
CString m_orientation_p;
|
||||
CString m_orientation_b;
|
||||
CString m_orientation_h;
|
||||
//}}AFX_DATA
|
||||
|
||||
SCP_vector<int> m_object_indexes;
|
||||
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
|
||||
|
||||
//{{AFX_MSG(calc_relative_coords_dlg)
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnSelchangeOriginList();
|
||||
afx_msg void OnSelchangeSatelliteList();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
void update_coords();
|
||||
};
|
||||
#endif // _CALCRELATIVECOORDSDLG_H
|
||||
@@ -364,6 +364,7 @@ BEGIN
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Mark Wing\tW", 33038
|
||||
MENUITEM "Adjust Grid", 33032
|
||||
MENUITEM "Calculate Relative Coordinates", 33030
|
||||
MENUITEM "Move Ships When Undocking", 33098, CHECKED
|
||||
MENUITEM "Mission Statistics\tCtrl+Shift+D", 33067
|
||||
MENUITEM SEPARATOR
|
||||
@@ -1804,6 +1805,25 @@ BEGIN
|
||||
LTEXT "X Level",IDC_STATIC,69,50,25,8
|
||||
END
|
||||
|
||||
IDD_CALC_RELATIVE_COORDS DIALOG 0, 0, 311, 155
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Calculate Relative Coordinates"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
LTEXT "Origin",IDC_STATIC,7,7,30,10
|
||||
LISTBOX IDC_ORIGIN_LIST,7,17,98,131,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "Satellite",IDC_STATIC,112,7,30,10
|
||||
LISTBOX IDC_SATELLITE_LIST,112,17,98,131,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "Distance:",IDC_STATIC,222,19,30,10
|
||||
EDITTEXT IDC_DISTANCE,255,17,49,14,ES_READONLY | WS_TABSTOP
|
||||
LTEXT "P:",IDC_STATIC,245,51,8,8
|
||||
EDITTEXT IDC_ORIENTATION_P,255,49,49,14,ES_READONLY | WS_TABSTOP
|
||||
LTEXT "B:",IDC_STATIC,245,67,8,8
|
||||
EDITTEXT IDC_ORIENTATION_B,255,65,49,14,ES_READONLY | WS_TABSTOP
|
||||
LTEXT "H:",IDC_STATIC,245,83,8,8
|
||||
EDITTEXT IDC_ORIENTATION_H,255,81,49,14,ES_READONLY | WS_TABSTOP
|
||||
END
|
||||
|
||||
IDD_SHIELD_SYS DIALOG 0, 0, 192, 106
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Shield System Editor"
|
||||
@@ -2517,6 +2537,14 @@ BEGIN
|
||||
BOTTOMMARGIN, 87
|
||||
END
|
||||
|
||||
IDD_CALC_RELATIVE_COORDS, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 146
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 87
|
||||
END
|
||||
|
||||
IDD_SHIELD_SYS, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
@@ -3254,6 +3282,7 @@ END
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
ID_LOOKAT_OBJ "Rotate camera around selected object\nRotate around object (Alt+R)"
|
||||
ID_CALC_RELATIVE_COORDS "Calculate orientation and distance relative to an origin object"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
#include "species_defs/species_defs.h"
|
||||
#include "sound/audiostr.h"
|
||||
#include "mission/missiongrid.h"
|
||||
#include "calcrelativecoordsdlg.h"
|
||||
|
||||
#include "osapi/osapi.h"
|
||||
|
||||
@@ -301,6 +302,7 @@ BEGIN_MESSAGE_MAP(CFREDView, CView)
|
||||
ON_COMMAND(ID_LOOKAT_OBJ, OnLookatObj)
|
||||
ON_UPDATE_COMMAND_UI(ID_LOOKAT_OBJ, OnUpdateLookatObj)
|
||||
ON_COMMAND(ID_EDITORS_ADJUST_GRID, OnEditorsAdjustGrid)
|
||||
ON_COMMAND(ID_CALC_RELATIVE_COORDS, OnCalcRelativeCoords)
|
||||
ON_COMMAND(ID_EDITORS_SHIELD_SYS, OnEditorsShieldSys)
|
||||
ON_COMMAND(ID_LEVEL_OBJ, OnLevelObj)
|
||||
ON_COMMAND(ID_ALIGN_OBJ, OnAlignObj)
|
||||
@@ -4145,6 +4147,13 @@ void CFREDView::OnEditorsAdjustGrid()
|
||||
Update_window = 1;
|
||||
}
|
||||
|
||||
void CFREDView::OnCalcRelativeCoords()
|
||||
{
|
||||
calc_relative_coords_dlg dlg;
|
||||
|
||||
dlg.DoModal();
|
||||
}
|
||||
|
||||
void CFREDView::OnEditorsShieldSys()
|
||||
{
|
||||
shield_sys_dlg dlg;
|
||||
|
||||
@@ -264,6 +264,7 @@ protected:
|
||||
afx_msg void OnLookatObj();
|
||||
afx_msg void OnUpdateLookatObj(CCmdUI* pCmdUI);
|
||||
afx_msg void OnEditorsAdjustGrid();
|
||||
afx_msg void OnCalcRelativeCoords();
|
||||
afx_msg void OnEditorsShieldSys();
|
||||
afx_msg void OnLevelObj();
|
||||
afx_msg void OnAlignObj();
|
||||
|
||||
@@ -23,6 +23,8 @@ public:
|
||||
void OnOK();
|
||||
orient_editor(CWnd* pParent = NULL); // standard constructor
|
||||
|
||||
static float to_degrees(float radians);
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(orient_editor)
|
||||
enum { IDD = IDD_ORIENT_EDITOR };
|
||||
@@ -65,10 +67,10 @@ protected:
|
||||
afx_msg void OnClose();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
private:
|
||||
float convert(const CString &str);
|
||||
bool close(float val, const CString &str);
|
||||
float to_degrees(float radians);
|
||||
int total;
|
||||
int index[MAX_OBJECTS];
|
||||
void actually_point_object(object *ptr);
|
||||
|
||||
@@ -77,6 +77,7 @@
|
||||
#define IDR_ASTEROID_FIELD_MENU 232
|
||||
#define IDR_CPGN_VIEW_OFF 233
|
||||
#define IDR_CPGN_VIEW_ON 234
|
||||
#define IDD_CALC_RELATIVE_COORDS 235
|
||||
#define IDD_INITIAL_SHIPS 238
|
||||
#define IDB_CHAINED 239
|
||||
#define IDD_CMD_BRIEF 242
|
||||
@@ -1165,6 +1166,9 @@
|
||||
#define IDC_CONTAINER_CAMPAIGN_PERSIST 1668
|
||||
#define IDC_CONTAINER_ETERNAL_PERSIST 1669
|
||||
#define IDC_RENAME_CONTAINER 1670
|
||||
#define IDC_ORIGIN_LIST 1671
|
||||
#define IDC_SATELLITE_LIST 1672
|
||||
#define IDC_DISTANCE 1673
|
||||
#define ID_FILE_MISSIONNOTES 32771
|
||||
#define ID_DUPLICATE 32774
|
||||
#define ID_VIEW_ROTATE 32775
|
||||
@@ -1386,6 +1390,7 @@
|
||||
#define ID_SET_GROUP7 33027
|
||||
#define ID_SET_GROUP8 33028
|
||||
#define ID_SET_GROUP9 33029
|
||||
#define ID_CALC_RELATIVE_COORDS 33030
|
||||
#define ID_END_EDIT 33031
|
||||
#define ID_EDITORS_ADJUST_GRID 33032
|
||||
#define ID_EDITORS_SHIELD_SYS 33033
|
||||
|
||||
Reference in new issue
Block a user