/*! @brief ツリーメニュー選択イベント */ void CInspectUsefulToolsDlg::OnTvnSelchangedMenuTree(NMHDR *pNMHDR, LRESULT *pResult) { LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR); if(pNMTreeView->hdr.idFrom != IDC_MENU_TREE) return; switch(pNMTreeView->hdr.code){ case TVN_SELCHANGED: //ツリーアイテム選択変更時 { HTREEITEM hItem = pNMTreeView->itemNew.hItem; TCHAR pszText[256]; TVITEM ti; ti.mask = TVIF_TEXT | TVIF_CHILDREN; ti.hItem = hItem; ti.pszText = pszText; ti.cchTextMax = 256; if(m_inMenuTreeCtrl.GetItem(&ti)){ if (ti.cChildren == 0) { HideContents(); //ここで、pszTextに選択アイテムのラベルが入っている。 void *pDialog = NULL; if (m_mapInnerDlg.Lookup(ti.pszText, pDialog) == TRUE) { ShowContents((CDialog *) pDialog); } // タイトルの設定 CString strAppName = CString((LPCTSTR)IDS_APP_NAME); strAppName.Format(_T("%s - [%s]"), strAppName, pszText); this->SetWindowText(strAppName); } else { // 機能メニューではない場合は、トップ画面を表示 HideContents(); void *pDialog = NULL; if (m_mapInnerDlg.Lookup(CString((LPCTSTR) IDS_MENU_TOP), pDialog) == TRUE) { ShowContents((CDialog *) pDialog); } // タイトルの設定 CString strAppName = CString((LPCTSTR)IDS_APP_NAME); this->SetWindowText(strAppName); } } } break; } *pResult = 0; }
StarSystem::StarSystem(StellarGroup* a_pParent, bool a_IsHomeSystem) : DisplayableObject(DisplayableObject::STARSYSTEM, a_pParent) , mIsNebula(false) //, mAsteroidBelt(*new AsteroidBelt()) { m_ImageName = "../media/system.png"; m_BGImageName = "../media/starsystem_bg.png"; // m_Name = GetRandomName(DisplayableObject::STARSYSTEM); if(a_IsHomeSystem) { //create the starting planet mContents.push_back(new Planet(this, HabitableObject::PLANET_TERRAN)); GameManager::SetHomePlanet((Planet*)mContents.back()); GameManager::AddSettletPlanet((Planet*)mContents.back()); //create this system's planets GenerateContents(); ShowContents(false); //we're at the center of the entire playable area mRelPosition.x = 0.5f; mRelPosition.y = 0.5f; } else { GenerateContents(); //5% chance of being a nebula mIsNebula = iRand() > 95 ? true : false; mRelPosition.x = fRand(); mRelPosition.y = fRand(); /* //calculate a random position for this group in the stellar group //calculate random coords with an even distribution across the internal volume of a sphere float phi = fRand() * PI; float costheta = fRand() * 2 - 1; float u = fRand(); float theta = acos( costheta ); float R = 1.f; //distribution radius - just use 0-1 for easy distribution across screen space float r = R * curt( u ); //as we're treating everything as 2D for now, just drop the zPos mRelPosition.x = r * sin( theta) * cos( phi ); mRelPosition.y = r * sin( theta) * sin( phi ); //mRelPosition.z = r * cos( theta ); */ } }
MRESULT EXPENTRY ViceFileDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { switch (msg) { case WM_INITDLG: { FILEDLG *fdlg = (FILEDLG*)WinQueryWindowPtr(hwnd, QWL_USER); int i; char *szpath; const int action = fdlg->ulUser; const int nact = (action >> 8) & 0xff; const int nsact = (action) & 0xff; FillABox(hwnd, action ? nact - 1 : 0); FillSBox(hwnd, action ? nsact - 1 : 0); FillFBox(hwnd); NewFilter(hwnd); for (i = 0; i < numfonts; i++) { WinDlgLboxInsertItem(hwnd, DID_FONTNAME_LB, fnames[i]); } WinDlgLboxSelectItem(hwnd, DID_FONTNAME_LB, 0); if (action) { WinEnableControl(hwnd, DID_ACTION_CB, FALSE); WinEnableControl(hwnd, DID_SUBACTION_CB, FALSE); } if (action || fdlg->fl & FDS_SAVEAS_DIALOG) { WinEnableControl(hwnd, DID_AUTOSTART_PB, FALSE); } szpath = util_concat(fdlg->pszIDrive, fdlg->szFullFile, NULL); *(strrchr(szpath, '\\') + 1) = '\0'; WinSetDlgItemText(hwnd, DID_DIR_SELECTED, szpath); lib_free(szpath); szpath = util_concat(archdep_boot_path(), "\\vice2.dll", NULL); if (!GpiLoadFonts(WinQueryAnchorBlock(hwnd), szpath)) { log_debug("dlg-fileio.c: GpiLoadFonts('%s') failed.", szpath); WinEnableControl(hwnd, DID_FONTNAME_LB, FALSE); } lib_free(szpath); } return FALSE; case WM_DESTROY: { char *szpath = util_concat(archdep_boot_path(), "\\vice2.dll", NULL); LboxFreeContents(WinWindowFromID(hwnd, DID_CONTENTS_LB)); if (!GpiUnloadFonts(WinQueryAnchorBlock(hwnd), szpath)) { log_debug("dlg-fileio.c: GpiUnloadFonts('%s') failed.", szpath); } lib_free (szpath); } break; case WM_CONTROL: switch (SHORT1FROMMP(mp1)) { case DID_ACTION_CB: if (SHORT2FROMMP(mp1) == CBN_ENTER) { FillSBox(hwnd, 0); } case DID_SUBACTION_CB: if (SHORT2FROMMP(mp1) == CBN_ENTER) { FillFBox(hwnd); } case DID_FFILTER_CB: if (SHORT2FROMMP(mp1) == CBN_ENTER) { NewFilter(hwnd); } return FALSE; case DID_DIRECTORY_LB: WinDefFileDlgProc(hwnd, msg, mp1, mp2); if (SHORT2FROMMP(mp1) == LN_SELECT || SHORT2FROMMP(mp1) == LN_ENTER) { char szpath[CCHMAXPATH]; const int nr = WinQueryLboxSelectedItem((HWND)mp2); if (nr < 0) { return FALSE; } if (SHORT2FROMMP(mp1) == LN_SELECT && WinQueryFocus(HWND_DESKTOP) == (HWND)mp2) { return FALSE; } if (!GetLboxPath((HWND)mp2, nr, szpath)) { return FALSE; } WinSetDlgItemText(hwnd, DID_DIR_SELECTED, szpath); } return FALSE; case DID_FILENAME_ED: if (WinQueryButtonCheckstate(hwnd, DID_CONTENTS_CB) && SHORT2FROMMP(mp1) == EN_CHANGE) { char szpath[CCHMAXPATH]; if (GetFullFile(hwnd, szpath)) { ShowContents(hwnd, szpath); } } break; case DID_CONTENTS_CB: { const int state = WinQueryButtonCheckstate(hwnd, DID_CONTENTS_CB); WinEnableControl(hwnd, DID_CONTENTS_LB, state); WinEnableControl(hwnd, DID_FONTNAME_LB, state); if (state) { ContentsUpdate(hwnd); } else { LboxFreeContents(WinWindowFromID(hwnd, DID_CONTENTS_LB)); } } return FALSE; case DID_FONTNAME_LB: if (SHORT2FROMMP(mp1) != CBN_ENTER) { break; } ContentsUpdate(hwnd); return FALSE; } break; case WM_COMMAND: switch (SHORT1FROMMP(mp1)) { case DID_DIRUP: { const HWND name = WinWindowFromID(hwnd, DID_FILENAME_ED); const int pos = WinDlgLboxSelectedItem(hwnd, DID_DIRECTORY_LB); char szpath[CCHMAXPATH]; char *cpos; int len; if (!pos) { return FALSE; } WinQueryDlgItemText(hwnd, DID_DIR_SELECTED, CCHMAXPATH - 1, szpath); if (strlen(szpath) < 4) { return FALSE; } *strrchr(szpath, '\\') = '\0'; cpos = strrchr(szpath,'\\') + 1; len = cpos - szpath + 2; if (len == CCHMAXPATH - 1) { return FALSE; } WinQueryDlgItemText(hwnd, DID_FILENAME_ED, CCHMAXPATH - len - 1, cpos); WinSetWindowText(name, szpath); *cpos = '\0'; WinSetDlgItemText(hwnd, DID_DIR_SELECTED, szpath); // // set focus to entry field and simulate an Apply // WinSetFocus(HWND_DESKTOP, name); WinDefFileDlgProc(hwnd, WM_COMMAND, (MPARAM)DID_OK, MPFROM2SHORT(CMDSRC_PUSHBUTTON, TRUE)); } return FALSE; case DID_AUTOSTART_PB: { const int pos = WinDlgLboxSelectedItem(hwnd, DID_CONTENTS_LB); FILEDLG *fdlg = (FILEDLG*)WinQueryWindowPtr(hwnd, QWL_USER); size_t length; char szpath[CCHMAXPATH]; if (!GetFullFile(hwnd, szpath)) { return FALSE; } if (autostart_autodetect(szpath, NULL, pos < 0 ? 0 : pos, AUTOSTART_MODE_RUN)) { return FALSE; } length = strrchr(szpath, '\\') - szpath; fdlg->lReturn = DID_OK; if (length > 0) { fdlg->szFullFile[length] = 0; } } break; } break; case WM_MEASUREITEM: if (SHORT1FROMMP(mp1) == DID_CONTENTS_LB) { return MRFROM2SHORT(9, 9); } break; case WM_DRAWITEM: if (SHORT1FROMMP(mp1) == DID_CONTENTS_LB) { OWNERITEM *item = (OWNERITEM*)mp2; RECTL *rcl = &(item->rclItem); if (rcl->yTop-rcl->yBottom == 9) { image_contents_screencode_t *line = (image_contents_screencode_t *)WinLboxItemHandle(item->hwnd, item->idItem); if (line) { LboxDrawLine(hwnd, item, rcl, line); } item->fsState = item->fsStateOld = 0; } return (MRESULT)TRUE; } break; case FDM_VALIDATE: // mp1 = PSZ pszPathName // mp2 = USHORT Field name id // mr = TRUE -> Valid name { const int sact = WinDlgLboxSelectedItem(hwnd, DID_SUBACTION_CB); const int act = WinDlgLboxSelectedItem(hwnd, DID_ACTION_CB); const FILEDLG *fdlg = (FILEDLG*)WinQueryWindowPtr(hwnd, QWL_USER); char *szpath = (char*)mp1; int rc; char *slash; if (fdlg->fl & FDS_OPEN_DIALOG) { rc = FdmDoLoadAction(hwnd, szpath, act, sact); } else { rc = FdmDoSaveAction(hwnd, szpath, act, sact); } if (rc < 0) { const action_t *action = fdlg->fl & FDS_OPEN_DIALOG ? LoadAction : SaveAction; char *txt = util_concat("The following action couldn't be performed:\n", action[act].type, " ", action[act].subact[sact].action, NULL); HPOINTER hpt = WinLoadPointer(HWND_DESKTOP, NULLHANDLE, 0x101); #ifdef WATCOM_COMPILE struct _MB2D mbtemp; struct _MB2INFO mb; mb.cb = sizeof(MB2INFO); mb.hIcon = hpt; mb.cButtons = 1; mb.flStyle = MB_CUSTOMICON|WS_VISIBLE; mb.hwndNotify = NULLHANDLE; sprintf(mbtemp.achText," OK "); mbtemp.idButton = 0; mbtemp.flStyle = BS_DEFAULT; mb.mb2d[0] = mbtemp; #else MB2INFO mb = { sizeof(MB2INFO), hpt, 1, MB_CUSTOMICON | WS_VISIBLE, NULLHANDLE, " OK ", 0, BS_DEFAULT}; #endif WinMessageBox2(HWND_DESKTOP, hwnd, txt, "VICE/2 Error", 0, &mb); lib_free(txt); return FALSE; } // // FIXME! Better solution? // slash = strrchr(szpath, '\\'); if (slash) { *slash = '\0'; } chdir(szpath); } return (MRESULT)TRUE; } return WinDefFileDlgProc(hwnd, msg, mp1, mp2); }