Port Win32 frontend to the new EF API
parent
1d0b0abce0
commit
7472122e38
|
@ -114,38 +114,23 @@ void EclipseFinderDisplayItem(LPNMLVDISPINFOA nm)
|
|||
switch (nm->item.iSubItem)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
strncpy(callbackScratch, UTF8ToCurrentCP(_(eclipse->planete.c_str())).c_str(), sizeof(callbackScratch) - 1);
|
||||
nm->item.pszText = callbackScratch;
|
||||
}
|
||||
strncpy(callbackScratch, UTF8ToCurrentCP(_(eclipse->receiver->getName().c_str())).c_str(), sizeof(callbackScratch) - 1);
|
||||
nm->item.pszText = callbackScratch;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
{
|
||||
if (!strcmp(eclipse->planete.c_str(),"None"))
|
||||
{
|
||||
sprintf(callbackScratch,"");
|
||||
nm->item.pszText = callbackScratch;
|
||||
}
|
||||
else
|
||||
{
|
||||
strncpy(callbackScratch, UTF8ToCurrentCP(_(eclipse->sattelite.c_str())).c_str(), sizeof(callbackScratch) - 1);
|
||||
nm->item.pszText = callbackScratch;
|
||||
}
|
||||
}
|
||||
strncpy(callbackScratch, UTF8ToCurrentCP(_(eclipse->occulter->getName().c_str())).c_str(), sizeof(callbackScratch) - 1);
|
||||
nm->item.pszText = callbackScratch;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
{
|
||||
bind_textdomain_codeset("celestia", CurrentCP());
|
||||
astro::Date startDate(eclipse->startTime);
|
||||
if (!strcmp(eclipse->planete.c_str(),"None"))
|
||||
sprintf(callbackScratch,"");
|
||||
else
|
||||
sprintf(callbackScratch, "%2d %s %4d",
|
||||
startDate.day,
|
||||
_(MonthNames[startDate.month - 1]),
|
||||
startDate.year);
|
||||
sprintf(callbackScratch, "%2d %s %4d",
|
||||
startDate.day,
|
||||
_(MonthNames[startDate.month - 1]),
|
||||
startDate.year);
|
||||
nm->item.pszText = callbackScratch;
|
||||
bind_textdomain_codeset("celestia", "UTF8");
|
||||
}
|
||||
|
@ -154,31 +139,17 @@ void EclipseFinderDisplayItem(LPNMLVDISPINFOA nm)
|
|||
case 3:
|
||||
{
|
||||
astro::Date startDate(eclipse->startTime);
|
||||
if (!strcmp(eclipse->planete.c_str(),"None"))
|
||||
sprintf(callbackScratch,"");
|
||||
else
|
||||
{
|
||||
sprintf(callbackScratch, "%02d:%02d",
|
||||
startDate.hour, startDate.minute);
|
||||
}
|
||||
sprintf(callbackScratch, "%02d:%02d",
|
||||
startDate.hour, startDate.minute);
|
||||
nm->item.pszText = callbackScratch;
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
{
|
||||
if (!strcmp(eclipse->planete.c_str(),"None"))
|
||||
{
|
||||
sprintf(callbackScratch,"");
|
||||
nm->item.pszText = callbackScratch;
|
||||
}
|
||||
else
|
||||
{
|
||||
int minutes = (int) ((eclipse->endTime - eclipse->startTime) *
|
||||
24 * 60);
|
||||
sprintf(callbackScratch, "%02d:%02d", minutes / 60, minutes % 60);
|
||||
nm->item.pszText = callbackScratch;
|
||||
}
|
||||
int minutes = (int) ((eclipse->endTime - eclipse->startTime) * 24 * 60);
|
||||
sprintf(callbackScratch, "%02d:%02d", minutes / 60, minutes % 60);
|
||||
nm->item.pszText = callbackScratch;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -219,12 +190,11 @@ void InitDateControls(HWND hDlg, astro::Date& newTime, SYSTEMTIME& fromTime, SYS
|
|||
struct EclipseFinderSortInfo
|
||||
{
|
||||
int subItem;
|
||||
string planete;
|
||||
string sattelite;
|
||||
int32_t Year;
|
||||
int8_t Month;
|
||||
int8_t Day;
|
||||
int8_t Hour;
|
||||
int Type;
|
||||
};
|
||||
|
||||
|
||||
|
@ -238,13 +208,10 @@ int CALLBACK EclipseFinderCompareFunc(LPARAM lParam0, LPARAM lParam1,
|
|||
switch (sortInfo->subItem)
|
||||
{
|
||||
case 1:
|
||||
if (eclipse0->sattelite < eclipse1->sattelite)
|
||||
return -1;
|
||||
else if (eclipse1->sattelite < eclipse0->sattelite)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
if (sortInfo->Type == Eclipse::Solar)
|
||||
return eclipse0->occulter->getName(true).compare(eclipse1->occulter->getName(true));
|
||||
|
||||
return eclipse0->receiver->getName(true).compare(eclipse1->receiver->getName(true));
|
||||
case 4:
|
||||
{
|
||||
double duration0 = eclipse0->endTime - eclipse0->startTime;
|
||||
|
@ -314,7 +281,7 @@ BOOL APIENTRY EclipseFinderProc(HWND hDlg,
|
|||
|
||||
bind_textdomain_codeset("celestia", CurrentCP());
|
||||
CheckRadioButton(hDlg, IDC_SOLARECLIPSE, IDC_LUNARECLIPSE, IDC_SOLARECLIPSE);
|
||||
efd->bSolar = true;
|
||||
efd->type = Eclipse::Solar;
|
||||
|
||||
SendDlgItemMessage(hDlg, IDC_ECLIPSETARGET, CB_ADDSTRING, 0, (LPARAM)_("Earth"));
|
||||
SendDlgItemMessage(hDlg, IDC_ECLIPSETARGET, CB_ADDSTRING, 0, (LPARAM)_("Jupiter"));
|
||||
|
@ -366,12 +333,18 @@ BOOL APIENTRY EclipseFinderProc(HWND hDlg,
|
|||
astro::Date to(eclipseFinderDlg->toTime.wYear,
|
||||
eclipseFinderDlg->toTime.wMonth,
|
||||
eclipseFinderDlg->toTime.wDay);
|
||||
EclipseFinder ef(eclipseFinderDlg->appCore,
|
||||
eclipseFinderDlg->strPlaneteToFindOn,
|
||||
eclipseFinderDlg->bSolar ? Eclipse::Solar : Eclipse::Moon,
|
||||
(double) from,
|
||||
(double) to);
|
||||
eclipseList = ef.getEclipses();
|
||||
|
||||
const SolarSystem* sys = eclipseFinderDlg->appCore->getSimulation()->getNearestSolarSystem();
|
||||
if (sys != nullptr && sys->getStar()->getCatalogNumber() == 0)
|
||||
{
|
||||
Body* planete = sys->getPlanets()->find(eclipseFinderDlg->strPlaneteToFindOn);
|
||||
if (planete != nullptr)
|
||||
{
|
||||
EclipseFinder ef(planete);
|
||||
ef.findEclipses((double)from, (double)to, eclipseFinderDlg->type, eclipseList);
|
||||
}
|
||||
}
|
||||
|
||||
InitEclipseFinderItems(hwnd, eclipseList);
|
||||
SetMouseCursor(IDC_ARROW);
|
||||
break;
|
||||
|
@ -408,10 +381,10 @@ BOOL APIENTRY EclipseFinderProc(HWND hDlg,
|
|||
}
|
||||
break;
|
||||
case IDC_SOLARECLIPSE:
|
||||
eclipseFinderDlg->bSolar = true;
|
||||
eclipseFinderDlg->type = Eclipse::Solar;
|
||||
break;
|
||||
case IDC_LUNARECLIPSE:
|
||||
eclipseFinderDlg->bSolar = false;
|
||||
eclipseFinderDlg->type = Eclipse::Lunar;
|
||||
break;
|
||||
case IDC_ECLIPSETARGET:
|
||||
if(HIWORD(wParam) == CBN_SELCHANGE)
|
||||
|
@ -462,7 +435,10 @@ BOOL APIENTRY EclipseFinderProc(HWND hDlg,
|
|||
{
|
||||
eclipseFinderDlg->TimetoSet_ =
|
||||
(eclipse->startTime + eclipse->endTime) / 2.0f;
|
||||
eclipseFinderDlg->BodytoSet_ = eclipse->body;
|
||||
eclipseFinderDlg->BodytoSet_ =
|
||||
eclipseFinderDlg->type == Eclipse::Solar ?
|
||||
eclipse->receiver :
|
||||
eclipse->occulter;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -475,6 +451,7 @@ BOOL APIENTRY EclipseFinderProc(HWND hDlg,
|
|||
LPNMLISTVIEW nm = (LPNMLISTVIEW) lParam;
|
||||
EclipseFinderSortInfo sortInfo;
|
||||
sortInfo.subItem = nm->iSubItem;
|
||||
sortInfo.Type = eclipseFinderDlg->type;
|
||||
// sortInfo.sattelite = ;
|
||||
// sortInfo.pos = eclipseFinderDlg->pos;
|
||||
ListView_SortItems(hwnd, EclipseFinderCompareFunc,
|
||||
|
|
|
@ -31,7 +31,7 @@ class EclipseFinderDialog
|
|||
SYSTEMTIME fromTime, toTime;
|
||||
double TimetoSet_;
|
||||
Body* BodytoSet_;
|
||||
bool bSolar;
|
||||
int type;
|
||||
};
|
||||
|
||||
#endif // _WINECLIPSES_H_
|
||||
|
|
Loading…
Reference in New Issue