int MenuFolder::initialize(Folder *folder, bool filter) { if (mapFolder != nullptr) delete mapFolder; mapFolder = folder; mMin = mCursor = 0; if (filter) { mapFolder->executeRemoveFiles([](File &f) { // Filter files based on file name if ((f.getName().length() > 4) && (f.getName().compare(f.getName().length() - 4, 4, ".phd") != 0) && (f.getName().compare(f.getName().length() - 4, 4, ".tr2") != 0) && (f.getName().compare(f.getName().length() - 4, 4, ".tr4") != 0) && (f.getName().compare(f.getName().length() - 4, 4, ".trc") != 0)) { return true; // delete file from list } // Check maps for validity Loader::LoaderVersion version = Loader::checkFile(f.getPath()); if (version == Loader::TR_UNKNOWN) { getConsole() << "Error: pak file '" << f.getName().c_str() << "' invalid" << Console::endl; return true; // delete file from list } return false; // keep file on list }); } if ((mapFolder->fileCount() + mapFolder->folderCount()) > 0) mCursor = 1; // Don't select ".." by default return 0; }
int stopBeep (void) { FILE *console = getConsole(); if (console) { if (ioctl(fileno(console), KIOCSOUND, 0) != -1) return 1; logSystemError("ioctl KIOCSOUND"); } return 0; }
int startBeep (unsigned short frequency) { FILE *console = getConsole(); if (console) { if (ioctl(fileno(console), KIOCSOUND, BEEP_DIVIDEND/frequency) != -1) return 1; logSystemError("ioctl KIOCSOUND"); } return 0; }
int asynchronousBeep (unsigned short frequency, unsigned short milliseconds) { FILE *console = getConsole(); if (console) { if (ioctl(fileno(console), KDMKTONE, ((milliseconds << 0X10) | (BEEP_DIVIDEND / frequency))) != -1) return 1; logSystemError("ioctl KDMKTONE"); } return 0; }
bool AppDelegate::applicationDidFinishLaunching() { // initialize director auto director = Director::getInstance(); auto glview = director->getOpenGLView(); if(!glview) { glview = GLViewImpl::create("Beat up the face!"); director->setOpenGLView(glview); auto set_resolution = [glview](float x, float y) { glview->setFrameSize(x, y); glview->setDesignResolutionSize(x, y, ResolutionPolicy::SHOW_ALL); }; //720p // set_resolution(1280, 720); //1080p // set_resolution(1920, 1080); //nexus 9 //set_resolution(2048 , 1536); //ouch //1024 x 600 // set_resolution(1024, 600); } // turn on display FPS // director->setDisplayStats(true); director->setDisplayStats(false); // set FPS. the default value is 1.0/60 if you don't call this director->setAnimationInterval(1.0 / 60); #ifdef __ANDROID__ #else system("xcopy \"C:\\Users\\Primary\\workspace\\beatupisis\\proj.win32\\..\\Resources\" \"C:\\Users\\Primary\\workspace\\beatupisis\\proj.win32\\Debug.win32\\\" /E /I /F /Y /D /K "); #endif this->preload_all(); Scene* scene = Scene::create(); MainMenu* main_menu = MainMenu::create(); scene->addChild(main_menu); Beatup::main_menu_scene = scene; Beatup::main_menu_scene->retain(); auto console = director->getConsole(); console->listenOnTCP(1234); // run director->runWithScene(scene); return true; }
void TIGLViewerWindow::contextMenuEvent(QContextMenuEvent *event) { QMenu menu(this); bool OneOrMoreIsSelected = false; for (myScene->getContext()->InitCurrent(); myScene->getContext()->MoreCurrent (); myScene->getContext()->NextCurrent ()) { if (myScene->getContext()->IsDisplayed(myScene->getContext()->Current())) { OneOrMoreIsSelected=true; } } if (OneOrMoreIsSelected) { QAction *eraseAct; eraseAct = new QAction(tr("&Erase"), this); eraseAct->setStatusTip(tr("Erase selected components")); menu.addAction(eraseAct); connect(eraseAct, SIGNAL(triggered()), myOCC, SLOT(eraseSelected())); QAction *transparencyAct; transparencyAct = new QAction(tr("&Transparency"), this); transparencyAct->setStatusTip(tr("Component Transparency")); menu.addAction(transparencyAct); connect(transparencyAct, SIGNAL(triggered()), myOCC, SLOT(setTransparency())); QAction *wireframeAct; wireframeAct = new QAction(tr("&Wireframe"), this); wireframeAct->setStatusTip(tr("Component Wireframe")); menu.addAction(wireframeAct); connect(wireframeAct, SIGNAL(triggered()), myOCC, SLOT(setObjectsWireframe())); QAction *shadingAct; shadingAct = new QAction(tr("&Shading"), this); shadingAct->setStatusTip(tr("Component Shading")); menu.addAction(shadingAct); connect(shadingAct, SIGNAL(triggered()), myOCC, SLOT(setObjectsShading())); QAction *colorAct; colorAct = new QAction(tr("&Color"), this); colorAct->setStatusTip(tr("Component Color")); menu.addAction(colorAct); connect(colorAct, SIGNAL(triggered()), myOCC, SLOT(setObjectsColor())); QAction *materialAct; materialAct = new QAction(tr("&Material"), this); materialAct->setStatusTip(tr("Component Material")); menu.addAction(materialAct); connect(materialAct, SIGNAL(triggered()), myOCC, SLOT(setObjectsMaterial())); } TIGLViewerScopedCommand command(getConsole(), false); Q_UNUSED(command); menu.exec(event->globalPos()); }
static int getVirtualTerminal (void) { int vt = -1; #ifdef HAVE_LINUX_VT_H FILE *console = getConsole(); if (console) { int consoleDescriptor = fileno(console); struct vt_stat state; if (ioctl(consoleDescriptor, VT_GETSTATE, &state) != -1) { vt = state.v_active; } } #endif /* HAVE_LINUX_VT_H */ return vt; }
void Menu::showDialog(std::string msg, std::string btn1, std::string btn2, std::function<int (bool state)> callback) { // Only show one dialog at a time assert(dialogText.length() == 0); assert(dialogButton1.length() == 0); assert(dialogButton2.length() == 0); assert(msg.length() > 0); assert(btn1.length() > 0); dialogText = msg; dialogButton1 = btn1; dialogButton2 = btn2; dialogState = false; dialogFunction = callback; getConsole() << dialogText << Console::endl; }
static void setVirtualTerminal (int vt) { #ifdef HAVE_LINUX_VT_H FILE *console = getConsole(); if (console) { int consoleDescriptor = fileno(console); logMessage(LOG_DEBUG, "switching to virtual terminal %d", vt); if (ioctl(consoleDescriptor, VT_ACTIVATE, vt) != -1) { if (ioctl(consoleDescriptor, VT_WAITACTIVE, vt) != -1) { logMessage(LOG_INFO, "switched to virtual terminal %d", vt); } else { logSystemError("virtual console wait"); } } else { logSystemError("virtual console activate"); } } #endif /* HAVE_LINUX_VT_H */ }
int writeConsole (const unsigned char *bytes, size_t count) { FILE *console = getConsole(); if (!console) return 0; while (count) { size_t result = fwrite(bytes, 1, count, console); if (!ferror(console)) fflush(console); if (ferror(console)) { logSystemError("console write"); return 0; } bytes += result; count -= result; } return 1; }
void TIGLViewerWindow::save() { QString fileName; statusBar()->showMessage(tr("Invoked File|Save")); fileName = QFileDialog::getSaveFileName(this, tr("Save as..."), myLastFolder, tr("IGES Geometry (*.igs);;") + tr("STEP Geometry (*.stp);;") + tr("STL Triangulation (*.stl);;") + tr("BRep Geometry (*.brep)")); if (!fileName.isEmpty()) { TIGLViewerScopedCommand command(getConsole()); Q_UNUSED(command); saveFile(fileName); QFileInfo fileInfo; fileInfo.setFile(fileName); myLastFolder = fileInfo.absolutePath(); } }
static void openVisualDisplay (void) { #ifdef HAVE_LINUX_VT_H if (displayDescriptor == -1) { FILE *console = getConsole(); if (console) { int consoleDescriptor = fileno(console); if (ioctl(consoleDescriptor, VT_OPENQRY, &displayTerminal) != -1) { char path[0X20]; snprintf(path, sizeof(path), "/dev/tty%d", displayTerminal); if ((displayDescriptor = open(path, O_WRONLY)) != -1) { logMessage(LOG_INFO, "visual display is %s", path); } } } } if (displayDescriptor != -1) { setVirtualTerminal(displayTerminal); } #endif /* HAVE_LINUX_VT_H */ }
//----------------------------------------------------------------- void ConsoleInput::specKey(int keyIndex) { //TODO: simulate key repeat in console switch (keyIndex) { case KEY_HISTORY: getConsole()->setInput(m_history); break; case KEY_BACKSPACE: { std::string input = getConsole()->getInput(); if (!input.empty()) { input.erase(input.end() - 1); getConsole()->setInput(input); } } break; case KEY_CLEAR: getConsole()->setInput(""); break; case KEY_ENTER: { std::string input = getConsole()->getInput(); if (!input.empty()) { if (getConsole()->sendCommand()) { m_history = input; getConsole()->setInput(""); } } else { quitState(); } } break; default: StateInput::specKey(keyIndex); break; } }
static int gpmOpenConnection (void) { switch (gpmConnectionState) { case GCS_CLOSED: { Gpm_Connect options = { .eventMask = GPM_MOVE, .defaultMask = ~0, .minMod = 0, .maxMod = ~0 }; gpm_tried = 0; gpm_zerobased = 1; if (Gpm_Open(&options, -1) == -1) { logMessage(GPM_LOG_LEVEL, "GPM open error: %s", strerror(errno)); asyncSetAlarmIn(NULL, 5000, gpmResetConnection, NULL); gpmConnectionState = GCS_FAILED; return 0; } logMessage(GPM_LOG_LEVEL, "GPM opened: fd=%d con=%d", gpm_fd, gpm_consolefd); gpmConnectionState = GCS_OPENED; } case GCS_OPENED: return 1; } return 0; } static void gpmCloseConnection (int alreadyClosed) { if (gpmConnectionState == GCS_OPENED) { if (!alreadyClosed) Gpm_Close(); logMessage(GPM_LOG_LEVEL, "GPM closed"); } gpmConnectionState = GCS_CLOSED; } #endif /* HAVE_LIBGPM */ static int routeCursor_RealScreen (int column, int row, int screen) { return startRouting(column, row, screen); } static int highlightRegion_RealScreen (int left, int right, int top, int bottom) { FILE *console = getConsole(); if (console) { #ifdef HAVE_LIBGPM if (gpmOpenConnection() && (gpm_fd >= 0)) { if (Gpm_DrawPointer(left, top, fileno(console)) != -1) return 1; if (errno != EINVAL) { logMessage(GPM_LOG_LEVEL, "Gpm_DrawPointer error: %s", strerror(errno)); gpmCloseConnection(0); return 0; } } #endif /* HAVE_LIBGPM */ } return 0; }
void TIGLViewerWindow::openFile(const QString& fileName) { QString fileType; QFileInfo fileInfo; TIGLViewerInputOutput::FileFormat format; TIGLViewerInputOutput reader; bool triangulation = false; bool success = false; TIGLViewerScopedCommand command(getConsole()); Q_UNUSED(command); statusBar()->showMessage(tr("Invoked File|Open")); if (!fileName.isEmpty()) { fileInfo.setFile(fileName); fileType = fileInfo.suffix(); if (fileType.toLower() == tr("xml")) { TIGLViewerDocument* config = new TIGLViewerDocument(this); TiglReturnCode tiglRet = config->openCpacsConfiguration(fileInfo.absoluteFilePath()); if (tiglRet != TIGL_SUCCESS) { delete config; return; } delete cpacsConfiguration; cpacsConfiguration = config; connectConfiguration(); updateMenus(); success = true; } else { if (fileType.toLower() == tr("brep")) { format = TIGLViewerInputOutput::FormatBREP; } if (fileType.toLower() == tr("step") || fileType.toLower() == tr("stp")) { format = TIGLViewerInputOutput::FormatSTEP; } if (fileType.toLower() == tr("iges") || fileType.toLower() == tr("igs")) { format = TIGLViewerInputOutput::FormatIGES; } if (fileType.toLower() == tr("stl")) { format = TIGLViewerInputOutput::FormatSTL; } if (fileType.toLower() == tr("mesh")) { format = TIGLViewerInputOutput::FormatMESH; triangulation = true; } if (triangulation) { success = reader.importTriangulation( fileInfo.absoluteFilePath(), format, *getScene() ); } else { success = reader.importModel ( fileInfo.absoluteFilePath(), format, *getScene() ); } } watcher = new QFileSystemWatcher(); watcher->addPath(fileInfo.absoluteFilePath()); QObject::connect(watcher, SIGNAL(fileChanged(QString)), openTimer, SLOT(start())); myLastFolder = fileInfo.absolutePath(); if (success) { setCurrentFile(fileName); myOCC->viewAxo(); myOCC->fitAll(); } else { displayErrorMessage("Error opening file " + fileName, "Error"); } } }
int canBeep (void) { enableBeeps(); return !!getConsole(); }
bool AppDelegate::applicationDidFinishLaunching() { // As an example, load config file // XXX: This should be loaded before the Director is initialized, // XXX: but at this point, the director is already initialized Configuration::getInstance()->loadConfigFile("configs/config-example.plist"); // initialize director auto director = Director::getInstance(); auto glview = director->getOpenGLView(); if(!glview) { glview = GLView::create("Cpp Tests"); director->setOpenGLView(glview); } director->setDisplayStats(true); director->setAnimationInterval(1.0 / 60); auto screenSize = glview->getFrameSize(); auto designSize = Size(480, 320); auto fileUtils = FileUtils::getInstance(); std::vector<std::string> searchPaths; if (screenSize.height > 320) { auto resourceSize = Size(960, 640); searchPaths.push_back("hd"); searchPaths.push_back("ccs-res/hd"); searchPaths.push_back("ccs-res/hd/scenetest"); searchPaths.push_back("ccs-res/hd/scenetest/ArmatureComponentTest"); searchPaths.push_back("ccs-res/hd/scenetest/AttributeComponentTest"); searchPaths.push_back("ccs-res/hd/scenetest/BackgroundComponentTest"); searchPaths.push_back("ccs-res/hd/scenetest/EffectComponentTest"); searchPaths.push_back("ccs-res/hd/scenetest/LoadSceneEdtiorFileTest"); searchPaths.push_back("ccs-res/hd/scenetest/ParticleComponentTest"); searchPaths.push_back("ccs-res/hd/scenetest/SpriteComponentTest"); searchPaths.push_back("ccs-res/hd/scenetest/TmxMapComponentTest"); searchPaths.push_back("ccs-res/hd/scenetest/UIComponentTest"); searchPaths.push_back("ccs-res/hd/scenetest/TriggerTest"); searchPaths.push_back("ccs-res"); director->setContentScaleFactor(resourceSize.height/designSize.height); } else { searchPaths.push_back("ccs-res"); searchPaths.push_back("ccs-res/scenetest/ArmatureComponentTest"); searchPaths.push_back("ccs-res/scenetest/AttributeComponentTest"); searchPaths.push_back("ccs-res/scenetest/BackgroundComponentTest"); searchPaths.push_back("ccs-res/scenetest/EffectComponentTest"); searchPaths.push_back("ccs-res/scenetest/LoadSceneEdtiorFileTest"); searchPaths.push_back("ccs-res/scenetest/ParticleComponentTest"); searchPaths.push_back("ccs-res/scenetest/SpriteComponentTest"); searchPaths.push_back("ccs-res/scenetest/TmxMapComponentTest"); searchPaths.push_back("ccs-res/scenetest/UIComponentTest"); searchPaths.push_back("ccs-res/scenetest/TriggerTest"); } fileUtils->setSearchPaths(searchPaths); #if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) // a bug in DirectX 11 level9-x on the device prevents ResolutionPolicy::NO_BORDER from working correctly glview->setDesignResolutionSize(designSize.width, designSize.height, ResolutionPolicy::SHOW_ALL); #else glview->setDesignResolutionSize(designSize.width, designSize.height, ResolutionPolicy::NO_BORDER); #endif auto scene = Scene::create(); auto layer = new TestController(); #if (CC_TARGET_PLATFORM != CC_PLATFORM_WP8) && (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) layer->addConsoleAutoTest(); #endif layer->autorelease(); layer->addConsoleAutoTest(); scene->addChild(layer); director->runWithScene(scene); // Enable Remote Console #if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) auto console = director->getConsole(); console->listenOnTCP(5678); Configuration *conf = Configuration::getInstance(); bool isAutoRun = conf->getValue("cocos2d.x.testcpp.autorun", Value(false)).asBool(); if(isAutoRun) { layer->startAutoRun(); } #endif return true; }
bool AppDelegate::applicationDidFinishLaunching() { // As an example, load config file // FIXME:: This should be loaded before the Director is initialized, // FIXME:: but at this point, the director is already initialized Configuration::getInstance()->loadConfigFile("configs/config-example.plist"); // initialize director auto director = Director::getInstance(); auto glview = director->getOpenGLView(); if(!glview) { glview = GLViewImpl::create("Cpp Tests"); director->setOpenGLView(glview); } director->setDisplayStats(true); director->setAnimationInterval(1.0 / 60); auto screenSize = glview->getFrameSize(); auto designSize = Size(480, 320); auto fileUtils = FileUtils::getInstance(); std::vector<std::string> searchPaths; if (screenSize.height > 320) { auto resourceSize = Size(960, 640); searchPaths.push_back("hd"); searchPaths.push_back("ccs-res/hd"); searchPaths.push_back("ccs-res/hd/scenetest"); searchPaths.push_back("ccs-res/hd/scenetest/ArmatureComponentTest"); searchPaths.push_back("ccs-res/hd/scenetest/AttributeComponentTest"); searchPaths.push_back("ccs-res/hd/scenetest/BackgroundComponentTest"); searchPaths.push_back("ccs-res/hd/scenetest/EffectComponentTest"); searchPaths.push_back("ccs-res/hd/scenetest/LoadSceneEdtiorFileTest"); searchPaths.push_back("ccs-res/hd/scenetest/ParticleComponentTest"); searchPaths.push_back("ccs-res/hd/scenetest/SpriteComponentTest"); searchPaths.push_back("ccs-res/hd/scenetest/TmxMapComponentTest"); searchPaths.push_back("ccs-res/hd/scenetest/UIComponentTest"); searchPaths.push_back("ccs-res/hd/scenetest/TriggerTest"); searchPaths.push_back("ccs-res"); searchPaths.push_back("Manifests"); director->setContentScaleFactor(resourceSize.height/designSize.height); searchPaths.push_back("ccs-res/hd/cocosui/UIEditorTest/UIButton"); searchPaths.push_back("ccs-res/hd/cocosui/UIEditorTest/UICheckBox"); searchPaths.push_back("ccs-res/hd/cocosui/UIEditorTest/UIImageView"); searchPaths.push_back("ccs-res/hd/cocosui/UIEditorTest/UILabel"); searchPaths.push_back("ccs-res/hd/cocosui/UIEditorTest/UILabelBMFont"); searchPaths.push_back("ccs-res/hd/cocosui/UIEditorTest/UILayout/BackgroundImage"); searchPaths.push_back("ccs-res/hd/cocosui/UIEditorTest/UILayout/Color"); searchPaths.push_back("ccs-res/hd/cocosui/UIEditorTest/UILayout/Layout"); searchPaths.push_back("ccs-res/hd/cocosui/UIEditorTest/UILayout/Gradient_Color"); searchPaths.push_back("ccs-res/hd/cocosui/UIEditorTest/UILayout/Scale9_BackgroundImage"); searchPaths.push_back("ccs-res/hd/cocosui/UIEditorTest/UILayout/LayoutComponent"); searchPaths.push_back("ccs-res/hd/cocosui/UIEditorTest/UILoadingBar"); searchPaths.push_back("ccs-res/hd/cocosui/UIEditorTest/UIPageView"); searchPaths.push_back("ccs-res/hd/cocosui/UIEditorTest/UIScrollView/Both"); searchPaths.push_back("ccs-res/hd/cocosui/UIEditorTest/UIScrollView/Horizontal"); searchPaths.push_back("ccs-res/hd/cocosui/UIEditorTest/UIScrollView/Vertical"); searchPaths.push_back("ccs-res/hd/cocosui/UIEditorTest/UISlider"); searchPaths.push_back("ccs-res/hd/cocosui/UIEditorTest/UITextField"); searchPaths.push_back("ccs-res/hd/cocosui/UIEditorTest/UIWidgetAddNode"); searchPaths.push_back("ccs-res/hd/cocosui/UIEditorTest/UIListView/New"); searchPaths.push_back("ccs-res/hd/cocosui/CustomTest/CustomWidgetCallbackBindTest"); searchPaths.push_back("hd/ActionTimeline"); searchPaths.push_back("ccs-res/hd/armature"); } else { searchPaths.push_back("ccs-res"); searchPaths.push_back("ccs-res/scenetest/ArmatureComponentTest"); searchPaths.push_back("ccs-res/scenetest/AttributeComponentTest"); searchPaths.push_back("ccs-res/scenetest/BackgroundComponentTest"); searchPaths.push_back("ccs-res/scenetest/EffectComponentTest"); searchPaths.push_back("ccs-res/scenetest/LoadSceneEdtiorFileTest"); searchPaths.push_back("ccs-res/scenetest/ParticleComponentTest"); searchPaths.push_back("ccs-res/scenetest/SpriteComponentTest"); searchPaths.push_back("ccs-res/scenetest/TmxMapComponentTest"); searchPaths.push_back("ccs-res/scenetest/UIComponentTest"); searchPaths.push_back("ccs-res/scenetest/TriggerTest"); searchPaths.push_back("ccs-res/cocosui/UIEditorTest/UIButton"); searchPaths.push_back("ccs-res/cocosui/UIEditorTest/UICheckBox"); searchPaths.push_back("ccs-res/cocosui/UIEditorTest/UIImageView"); searchPaths.push_back("ccs-res/cocosui/UIEditorTest/UILabel"); searchPaths.push_back("ccs-res/cocosui/UIEditorTest/UILabelBMFont"); searchPaths.push_back("ccs-res/cocosui/UIEditorTest/UILayout/BackgroundImage"); searchPaths.push_back("ccs-res/cocosui/UIEditorTest/UILayout/Color"); searchPaths.push_back("ccs-res/cocosui/UIEditorTest/UILayout/Layout"); searchPaths.push_back("ccs-res/cocosui/UIEditorTest/UILayout/Gradient_Color"); searchPaths.push_back("ccs-res/cocosui/UIEditorTest/UILayout/Scale9_BackgroundImage"); searchPaths.push_back("ccs-res/cocosui/UIEditorTest/UILayout/LayoutComponent"); searchPaths.push_back("ccs-res/cocosui/UIEditorTest/UILoadingBar"); searchPaths.push_back("ccs-res/cocosui/UIEditorTest/UIPageView"); searchPaths.push_back("ccs-res/cocosui/UIEditorTest/UIScrollView/Both"); searchPaths.push_back("ccs-res/cocosui/UIEditorTest/UIScrollView/Horizontal"); searchPaths.push_back("ccs-res/cocosui/UIEditorTest/UIScrollView/Vertical"); searchPaths.push_back("ccs-res/cocosui/UIEditorTest/UISlider"); searchPaths.push_back("ccs-res/cocosui/UIEditorTest/UITextField"); searchPaths.push_back("ccs-res/cocosui/UIEditorTest/UIWidgetAddNode"); searchPaths.push_back("ccs-res/cocosui/UIEditorTest/UIListView/New"); searchPaths.push_back("ccs-res/cocosui/CustomTest/CustomWidgetCallbackBindTest"); searchPaths.push_back("ActionTimeline"); searchPaths.push_back("ccs-res/armature"); } fileUtils->setSearchPaths(searchPaths); glview->setDesignResolutionSize(designSize.width, designSize.height, ResolutionPolicy::SHOW_ALL); // Enable Remote Console auto console = director->getConsole(); console->listenOnTCP(5678); _testController = TestController::getInstance(); return true; }