void ProjectConfigDialog::onSelectScriptFile(void) { char buff[MAX_PATH + 1] = {0}; char projdir[MAX_PATH + 1] = {0}; GetDlgItemTextA(m_hwndDialog, IDC_EDIT_PROJECT_DIR, projdir, MAX_PATH); OPENFILENAMEA ofn = {0}; ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = m_hwndDialog; ofn.lpstrFilter = "Lua Script File (*.lua)\0*.lua\0"; ofn.lpstrTitle = "Select Script File"; if (DirectoryExists(projdir)) { ofn.lpstrInitialDir = projdir; } ofn.Flags = OFN_DONTADDTORECENT | OFN_ENABLESIZING | OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST; ofn.lpstrFile = buff; ofn.nMaxFile = MAX_PATH; if (GetOpenFileNameA(&ofn)) { m_project.setScriptFile(buff); updateScriptFile(); } }
void ProjectConfigDialog::onSelectProjectDir(void) { string dir = browseFolder(m_project.getProjectDir()); if (dir.length() > 0) { m_project.setProjectDir(dir); updateProjectDir(); updateScriptFile(); updatePackagePath(); } }
ScriptEditorWidget::ScriptEditorWidget(QWidget *parent) :QWidget(parent, Qt::Tool) { setupUi(this); connect(m_pStartButton, SIGNAL(clicked(void)), this, SIGNAL(start(void))); connect(m_pStopButton, SIGNAL(clicked(void)), this, SIGNAL(stop(void))); QFile updateScriptFile("media\\scripts\\update.js"); if (updateScriptFile.open(QFile::ReadOnly)) { QTextStream stream(&updateScriptFile); m_pTextEdit->setPlainText(stream.readAll()); updateScriptFile.close(); } else { m_pTextEdit->setPlainText("////Failed to open file"); } }
void ProjectConfigDialog::onInitDialog(HWND hwndDialog) { SimulatorConfig *defaults = SimulatorConfig::sharedDefaults(); m_hwndDialog = hwndDialog; HWND list = GetDlgItem(m_hwndDialog, IDC_COMBO_SCREEN_SIZE); updateProjectDir(); updateScriptFile(); updatePackagePath(); BOOL isLandscape = FALSE; int currentSizeIndex = defaults->checkScreenSize(m_project.getFrameSize()); if (currentSizeIndex < 0) { currentSizeIndex = 0; } else { isLandscape = m_project.isLandscapeFrame(); } for (int i = 0; i < defaults->numScreenSize(); ++i) { const SimulatorScreenSize &size = defaults->getScreenSize(i); wstring title; title.assign(size.title.begin(), size.title.end()); ComboBox_AddString(list, title.c_str()); if (i == currentSizeIndex) { char buff[32]; sprintf_s(buff, "%d", isLandscape ? size.height : size.width); SetDlgItemTextA(m_hwndDialog, IDC_EDIT_SCREEN_WIDTH, buff); sprintf_s(buff, "%d", isLandscape ? size.width : size.height); SetDlgItemTextA(m_hwndDialog, IDC_EDIT_SCREEN_HEIGHT, buff); } } ComboBox_AddString(list, L"Custom Size"); ComboBox_SetCurSel(list, currentSizeIndex); Edit_LimitText(GetDlgItem(m_hwndDialog, IDC_EDIT_SCREEN_WIDTH), 4); Edit_LimitText(GetDlgItem(m_hwndDialog, IDC_EDIT_SCREEN_HEIGHT), 4); HWND direction = GetDlgItem(m_hwndDialog, IDC_RADIO_PORTRAIT); CheckRadioButton(m_hwndDialog, IDC_RADIO_PORTRAIT, IDC_RADIO_LANDSCAPE, isLandscape ? IDC_RADIO_LANDSCAPE : IDC_RADIO_PORTRAIT); Button_SetCheck(GetDlgItem(m_hwndDialog, IDC_CHECK_SHOW_DEBUG_CONSOLE), m_project.isShowConsole()); // set dialog caption, button caption SetWindowTextA(m_hwndDialog, m_dialogCaption.c_str()); SetDlgItemTextA(m_hwndDialog, IDOK, m_buttonCaption.c_str()); // center a dialog box within its owner window RECT rc, rcOwner, rcDlg; GetWindowRect(m_hwnd, &rcOwner); GetWindowRect(m_hwndDialog, &rcDlg); CopyRect(&rc, &rcOwner); OffsetRect(&rcDlg, -rcDlg.left, -rcDlg.top); OffsetRect(&rc, -rc.left, -rc.top); OffsetRect(&rc, -rcDlg.right, -rcDlg.bottom); SetWindowPos(m_hwndDialog, HWND_TOP, rcOwner.left + (rc.right / 2), rcOwner.top + (rc.bottom / 2), 0, 0, // Ignores size arguments. SWP_NOSIZE); }