Added solar system browser.
This commit is contained in:
parent
1733a5884b
commit
09dc24d300
|
@ -53,6 +53,9 @@ BEGIN
|
|||
MENUITEM "&Center Selection", ID_NAVIGATION_CENTER
|
||||
MENUITEM "&Go to Selection", ID_NAVIGATION_GOTO
|
||||
MENUITEM "&Follow Selection", ID_NAVIGATION_FOLLOW
|
||||
MENUITEM "S&ync Orbit Selection", ID_NAVIGATION_SYNCORBIT
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Solar System &Browser...", ID_NAVIGATION_SSBROWSER
|
||||
END
|
||||
POPUP "&Time"
|
||||
BEGIN
|
||||
|
@ -210,6 +213,21 @@ BEGIN
|
|||
END
|
||||
|
||||
|
||||
IDD_SSBROWSER DIALOG DISCARDABLE 0, 0, 226, 194
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE
|
||||
CAPTION "Solar System Browser"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,169,154,50,14
|
||||
CONTROL "Solar System",IDC_SSBROWSER_TREE,"SysTreeView32",WS_BORDER | WS_TABSTOP | TVS_HASLINES | TVS_HASBUTTONS,
|
||||
7,26,153,161
|
||||
PUSHBUTTON "Center",IDC_BUTTON_CENTER,169,26,50,14
|
||||
PUSHBUTTON "Go To",IDC_BUTTON_GOTO,169,44,50,14
|
||||
LTEXT "Solar System Objects",IDC_STATIC,7,13,74,8
|
||||
END
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#define IDD_SETTIME 109
|
||||
#define IDD_GLINFO 110
|
||||
#define IDD_ADDLOCATION 111
|
||||
#define IDD_SSBROWSER 112
|
||||
#define IDC_FINDOBJECT_EDIT 1001
|
||||
#define IDC_LICENSE_TEXT 1004
|
||||
#define IDC_GLINFO_TEXT 1005
|
||||
|
@ -19,6 +20,9 @@
|
|||
#define IDC_TIMEPICKER 1007
|
||||
#define IDC_DATEPICKER 1008
|
||||
#define IDC_LOCATION_EDIT 1009
|
||||
#define IDC_SSBROWSER_TREE 1010
|
||||
#define IDC_BUTTON_CENTER 1011
|
||||
#define IDC_BUTTON_GOTO 1012
|
||||
#define ID_SELECTSOL 40001
|
||||
#define ID_GOTOSELECTION 40002
|
||||
#define ID_FOLLOWSELECTION 40003
|
||||
|
@ -61,6 +65,8 @@
|
|||
#define ID_RENDER_MORESTARS 40042
|
||||
#define ID_RENDER_FEWERSTARS 40043
|
||||
#define ID_RENDER_SHOWCELESTIALSPHERE 40044
|
||||
#define ID_NAVIGATION_SYNCORBIT 40045
|
||||
#define ID_NAVIGATION_SSBROWSER 40046
|
||||
|
||||
#define ID_LOCATIONS_FIRSTLOCATION 41000
|
||||
|
||||
|
@ -68,9 +74,9 @@
|
|||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 112
|
||||
#define _APS_NEXT_COMMAND_VALUE 40045
|
||||
#define _APS_NEXT_CONTROL_VALUE 1010
|
||||
#define _APS_NEXT_RESOURCE_VALUE 113
|
||||
#define _APS_NEXT_COMMAND_VALUE 40047
|
||||
#define _APS_NEXT_CONTROL_VALUE 1013
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
|
|
171
src/winmain.cpp
171
src/winmain.cpp
|
@ -47,6 +47,7 @@ static bool fullscreen = false;
|
|||
static bool bReady = false;
|
||||
|
||||
HINSTANCE appInstance;
|
||||
HWND ssBrowserWindow = 0;
|
||||
|
||||
static HMENU menuBar = 0;
|
||||
static HACCEL acceleratorTable = 0;
|
||||
|
@ -386,6 +387,164 @@ BOOL APIENTRY SetTimeProc(HWND hDlg,
|
|||
}
|
||||
|
||||
|
||||
HTREEITEM AddItemToTree(HWND hwndTV, LPSTR lpszItem, int nLevel, void* data)
|
||||
{
|
||||
TVITEM tvi;
|
||||
TVINSERTSTRUCT tvins;
|
||||
static HTREEITEM hPrev = (HTREEITEM) TVI_FIRST;
|
||||
static HTREEITEM hPrevRootItem = NULL;
|
||||
static HTREEITEM hPrevLev2Item = NULL;
|
||||
// HTREEITEM hti;
|
||||
|
||||
#if 0
|
||||
tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
|
||||
#endif
|
||||
tvi.mask = TVIF_TEXT | TVIF_PARAM;
|
||||
|
||||
// Set the text of the item.
|
||||
tvi.pszText = lpszItem;
|
||||
tvi.cchTextMax = lstrlen(lpszItem);
|
||||
|
||||
// Assume the item is not a parent item, so give it a
|
||||
// document image.
|
||||
// tvi.iImage = g_nDocument;
|
||||
// tvi.iSelectedImage = g_nDocument;
|
||||
|
||||
// Save the heading level in the item's application-defined
|
||||
// data area.
|
||||
tvi.lParam = (LPARAM) data;
|
||||
|
||||
tvins.item = tvi;
|
||||
tvins.hInsertAfter = hPrev;
|
||||
|
||||
// Set the parent item based on the specified level.
|
||||
if (nLevel == 1)
|
||||
tvins.hParent = TVI_ROOT;
|
||||
else if (nLevel == 2)
|
||||
tvins.hParent = hPrevRootItem;
|
||||
else
|
||||
tvins.hParent = hPrevLev2Item;
|
||||
|
||||
// Add the item to the tree view control.
|
||||
hPrev = (HTREEITEM) SendMessage(hwndTV, TVM_INSERTITEM, 0,
|
||||
(LPARAM) (LPTVINSERTSTRUCT) &tvins);
|
||||
|
||||
// Save the handle to the item.
|
||||
if (nLevel == 1)
|
||||
hPrevRootItem = hPrev;
|
||||
else if (nLevel == 2)
|
||||
hPrevLev2Item = hPrev;
|
||||
|
||||
#if 0
|
||||
// The new item is a child item. Give the parent item a
|
||||
// closed folder bitmap to indicate it now has child items.
|
||||
if (nLevel > 1)
|
||||
{
|
||||
hti = TreeView_GetParent(hwndTV, hPrev);
|
||||
tvi.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE;
|
||||
tvi.hItem = hti;
|
||||
// tvi.iImage = g_nClosed;
|
||||
// tvi.iSelectedImage = g_nClosed;
|
||||
TreeView_SetItem(hwndTV, &tvi);
|
||||
}
|
||||
#endif
|
||||
|
||||
return hPrev;
|
||||
}
|
||||
|
||||
|
||||
void AddPlanetarySystemToTree(const PlanetarySystem* sys, HWND treeView, int level)
|
||||
{
|
||||
for (int i = 0; i < sys->getSystemSize(); i++)
|
||||
{
|
||||
Body* world = sys->getBody(i);
|
||||
(void) AddItemToTree(treeView,
|
||||
const_cast<char*>(world->getName().c_str()),
|
||||
level,
|
||||
static_cast<void*>(world));
|
||||
|
||||
const PlanetarySystem* satellites = world->getSatellites();
|
||||
if (satellites != NULL)
|
||||
AddPlanetarySystemToTree(satellites, treeView, level + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BOOL APIENTRY SolarSystemBrowserProc(HWND hDlg,
|
||||
UINT message,
|
||||
UINT wParam,
|
||||
LONG lParam)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
HWND hwnd = GetDlgItem(hDlg, IDC_SSBROWSER_TREE);
|
||||
const SolarSystem* solarSys = appCore->getSimulation()->getNearestSolarSystem();
|
||||
if (solarSys != NULL)
|
||||
{
|
||||
HTREEITEM rootItem = AddItemToTree(hwnd, "Sun", 1, NULL);
|
||||
const PlanetarySystem* planets = solarSys->getPlanets();
|
||||
if (planets != NULL)
|
||||
AddPlanetarySystemToTree(planets, hwnd, 2);
|
||||
|
||||
SendMessage(hwnd, TVM_EXPAND, TVE_EXPAND, (LPARAM) rootItem);
|
||||
}
|
||||
}
|
||||
return(TRUE);
|
||||
|
||||
case WM_COMMAND:
|
||||
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
|
||||
{
|
||||
ssBrowserWindow = 0;
|
||||
EndDialog(hDlg, 0);
|
||||
return TRUE;
|
||||
}
|
||||
else if (LOWORD(wParam) == IDC_BUTTON_CENTER)
|
||||
{
|
||||
appCore->charEntered('C');
|
||||
}
|
||||
else if (LOWORD(wParam) == IDC_BUTTON_GOTO)
|
||||
{
|
||||
appCore->charEntered('G');
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_NOTIFY:
|
||||
{
|
||||
LPNMHDR hdr = (LPNMHDR) lParam;
|
||||
|
||||
if (hdr->code == TVN_SELCHANGED)
|
||||
{
|
||||
LPNMTREEVIEW nm = (LPNMTREEVIEW) lParam;
|
||||
Body* body = reinterpret_cast<Body*>(nm->itemNew.lParam);
|
||||
if (body != NULL)
|
||||
{
|
||||
appCore->getSimulation()->setSelection(Selection(body));
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
if (hdr->code == DTN_DATETIMECHANGE)
|
||||
{
|
||||
LPNMDATETIMECHANGE change = (LPNMDATETIMECHANGE) lParam;
|
||||
if (change->dwFlags == GDT_VALID)
|
||||
{
|
||||
astro::Date date(change->st.wYear, change->st.wMonth, change->st.wDay);
|
||||
newTime.year = change->st.wYear;
|
||||
newTime.month = change->st.wMonth;
|
||||
newTime.day = change->st.wDay;
|
||||
newTime.hour = change->st.wHour;
|
||||
newTime.minute = change->st.wMinute;
|
||||
newTime.seconds = change->st.wSecond + (double) change->st.wMilliseconds / 1000.0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
HMENU CreateMenuBar()
|
||||
{
|
||||
|
@ -495,6 +654,7 @@ VOID APIENTRY handlePopupMenu(HWND hwnd, POINT point,
|
|||
AppendMenu(hMenu, MF_SEPARATOR, 0, 0);
|
||||
AppendMenu(hMenu, MF_STRING, ID_NAVIGATION_GOTO, "&Goto");
|
||||
AppendMenu(hMenu, MF_STRING, ID_NAVIGATION_FOLLOW, "&Follow");
|
||||
AppendMenu(hMenu, MF_STRING, ID_NAVIGATION_SYNCORBIT, "S&ync Orbit");
|
||||
AppendMenu(hMenu, MF_STRING, ID_INFO, "&Info");
|
||||
|
||||
const PlanetarySystem* satellites = sel.body->getSatellites();
|
||||
|
@ -928,6 +1088,10 @@ LRESULT CALLBACK MainWindowProc(HWND hWnd,
|
|||
buttons |= CelestiaCore::RightButton;
|
||||
if ((wParam & MK_MBUTTON) != 0)
|
||||
buttons |= CelestiaCore::MiddleButton;
|
||||
if ((wParam & MK_SHIFT) != 0)
|
||||
buttons |= CelestiaCore::ShiftKey;
|
||||
if ((wParam & MK_CONTROL) != 0)
|
||||
buttons |= CelestiaCore::ControlKey;
|
||||
appCore->mouseMove(x - lastX, y - lastY, buttons);
|
||||
}
|
||||
break;
|
||||
|
@ -1029,12 +1193,19 @@ LRESULT CALLBACK MainWindowProc(HWND hWnd,
|
|||
case ID_NAVIGATION_FOLLOW:
|
||||
appCore->charEntered('F');
|
||||
break;
|
||||
case ID_NAVIGATION_SYNCORBIT:
|
||||
appCore->charEntered('Y');
|
||||
break;
|
||||
case ID_NAVIGATION_HOME:
|
||||
appCore->charEntered('H');
|
||||
break;
|
||||
case ID_NAVIGATION_SELECT:
|
||||
DialogBox(appInstance, MAKEINTRESOURCE(IDD_FINDOBJECT), hWnd, FindObjectProc);
|
||||
break;
|
||||
case ID_NAVIGATION_SSBROWSER:
|
||||
if (ssBrowserWindow == 0)
|
||||
ssBrowserWindow = CreateDialog(appInstance, MAKEINTRESOURCE(IDD_SSBROWSER), hWnd, SolarSystemBrowserProc);
|
||||
break;
|
||||
|
||||
case ID_RENDER_SHOWHUDTEXT:
|
||||
appCore->charEntered('V');
|
||||
|
|
Loading…
Reference in a new issue