bool UI::InitUI() { if (m_uiInitialized) { RenderThreadInitProducts(); RenderThreadInitReceipts(); SetDirections(); return true; } #define NUM_FONTS 2 static NvBool fontsSplit[NUM_FONTS] = {1,1}; /* all are split */ static const char *fontFiles[NUM_FONTS] = { "courier+lucida_256.dds", "utahcond+bold_1024.dds" }; if (NVBFInitialize(NUM_FONTS, (const char**)fontFiles, fontsSplit, 0)) { LOGW("Could not initialize NvBitFont"); return false; } SetupLabel((void**)&m_uiLabelFetch, 2, 32, NVBF_COLORSTR_WHITE ""); SetupLabel((void**)&m_uiLabelDirections, 2, 32, NVBF_COLORSTR_WHITE "Directions:"); SetupLabel((void**)&m_uiLabelMessage, 2, 32, NVBF_COLORSTR_WHITE "Message:"); m_uiRequestGamerUUID.Setup(2, 32, NVBF_COLORSTR_GREEN "[Get GamerUUID]", NVBF_COLORSTR_WHITE "Get GamerUUID"); m_uiRequestProducts.Setup(2, 32, NVBF_COLORSTR_GREEN "[Get Products]", NVBF_COLORSTR_WHITE "Get Products"); m_uiRequestPurchase.Setup(2, 32, NVBF_COLORSTR_GREEN "[Purchase]", NVBF_COLORSTR_WHITE "Purchase"); m_uiRequestReceipts.Setup(2, 32, NVBF_COLORSTR_GREEN "[Get Receipts]", NVBF_COLORSTR_WHITE "Get Receipts"); m_uiPause.Setup(2, 32, NVBF_COLORSTR_GREEN "[Pause]", NVBF_COLORSTR_WHITE "Pause"); m_uiRequestGamerUUID.Down = &m_uiRequestReceipts; m_uiRequestGamerUUID.Left = &m_uiRequestProducts; m_uiRequestProducts.Down = &m_uiRequestPurchase; m_uiRequestProducts.Right = &m_uiRequestGamerUUID; m_uiRequestPurchase.Up = &m_uiRequestProducts; m_uiRequestPurchase.Right = &m_uiRequestReceipts; m_uiRequestReceipts.Left = &m_uiRequestPurchase; m_uiRequestReceipts.Up = &m_uiRequestGamerUUID; m_uiPause.Up = &m_uiRequestReceipts; m_selectedButton = &m_uiPause; m_uiPause.SetActive(true); m_uiInitialized = true; return true; }
nuiPadGestureRecognizer::nuiPadGestureRecognizer(nuiGestureDirection direction) : nuiGestureRecognizer(), mSink(this) { mClicked = false; mLastX = 0; mLastY = 0; mFriction = 0.1; SetDirections(direction); mRecognizedDirection = nuiGestureDirectionNull; nuiTimer* pTimer = nuiAnimation::AcquireTimer(); mSink.Connect(pTimer->Tick, &nuiPadGestureRecognizer::UpdateForces); }
void EIEdgeImage::Read(LFLineFitter &lf) { SafeRelease(); width_ = lf.rWidth(); height_ = lf.rHeight(); nLines_ = lf.rNLineSegments(); LFLineSegment* lineSegmentMap = lf.rOutputEdgeMap(); lines_ = new LFLineSegment[nLines_]; for (int i=0 ; i<nLines_ ; i++) lines_[i] = lineSegmentMap[i]; SetLines2Grid(); SetDirections(); }
void EIEdgeImage::Read(const char* fileName) { FILE* fin=NULL; fin = fopen(fileName, "r"); //AKANSEL: FIX NEEDED FOR FILES CREATED IN WINDOWS // jiaming hu modified //string prelude = "./"; string prelude = "/home/jiaming/catkin_ws/"; string fileName_str(fileName); std::string combo = prelude + fileName_str; if (!combo.empty() && combo[combo.size() - 1] == '\r') { combo.erase(combo.size() - 1); } const char* fileName_fixed = combo.c_str(); ////////// fin = fopen(fileName_fixed, "r"); std::cout << "FILE NAME: "<<fileName_fixed << std::endl; if(fileName_fixed==NULL || fin == NULL) { cerr<<"[ERROR] Cannot read file "<<fileName_fixed<<"!!!\n"; perror("fopen"); exit(0); } fscanf(fin, "%d %d", &width_, &height_); //std::cout<<"width: "<<width_<<"height: "<<height_<<std::endl; fscanf(fin, "%d", &nLines_); lines_ = new LFLineSegment[nLines_]; for (int i=0 ; i<nLines_ ; i++) { lines_[i].Read(fin); } SetLines2Grid(); SetDirections(); fclose(fin); }
void EIEdgeImage::Read(const char* fileName) { FILE* fin=NULL; fin = fopen(fileName, "r"); if(fileName==NULL) { cerr<<"[ERROR] Cannot read file "<<fileName<<"\n!!!"; exit(0); } fscanf(fin, "%d %d", &width_, &height_); fscanf(fin, "%d", &nLines_); lines_ = new LFLineSegment[nLines_]; for (int i=0 ; i<nLines_ ; i++) { lines_[i].Read(fin); } SetLines2Grid(); SetDirections(); fclose(fin); }
void UI::HandleInput(int keyCode, int action) { if (action == AMOTION_EVENT_ACTION_UP && keyCode == OuyaSDK::Controller::BUTTON_MENU) { if (m_selectedButton && std::find(m_products.begin(), m_products.end(), m_selectedButton) == m_products.end()) { m_selectedButton->SetActive(false); } m_selectedButton = &m_uiPause; m_uiPause.SetActive(true); SetDirections(); LOGI("Key event, hack, regaining focus...\r\n"); Application::m_app->activity->callbacks->onWindowFocusChanged(Application::m_app->activity, true); LOGI("Key event, hack complete***\r\n"); } else if (action == AMOTION_EVENT_ACTION_UP && keyCode == OuyaSDK::Controller::BUTTON_DPAD_LEFT) { if (m_selectedButton && m_selectedButton->Left) { m_selectedButton->SetActive(false); m_selectedButton = m_selectedButton->Left; m_selectedButton->SetActive(true); SetDirections(); } } else if (action == AMOTION_EVENT_ACTION_UP && keyCode == OuyaSDK::Controller::BUTTON_DPAD_RIGHT) { if (m_selectedButton && m_selectedButton->Right) { if (std::find(m_products.begin(), m_products.end(), m_selectedButton) == m_products.end()) { m_selectedButton->SetActive(false); } m_selectedButton = m_selectedButton->Right; m_selectedButton->SetActive(true); SetDirections(); } } else if (action == AMOTION_EVENT_ACTION_UP && keyCode == OuyaSDK::Controller::BUTTON_DPAD_UP) //dpad up { if (m_selectedButton && m_selectedButton->Up) { m_selectedButton->SetActive(false); m_selectedButton = m_selectedButton->Up; m_selectedButton->SetActive(true); if (std::find(m_products.begin(), m_products.end(), m_selectedButton) != m_products.end()) { m_selectedProduct = m_selectedButton; m_uiRequestProducts.Left = m_selectedProduct; m_uiRequestPurchase.Left = m_selectedProduct; } SetDirections(); } } else if (action == AMOTION_EVENT_ACTION_UP && keyCode == OuyaSDK::Controller::BUTTON_DPAD_DOWN) { if (m_selectedButton && m_selectedButton->Down) { m_selectedButton->SetActive(false); m_selectedButton = m_selectedButton->Down; m_selectedButton->SetActive(true); if (std::find(m_products.begin(), m_products.end(), m_selectedButton) != m_products.end()) { m_selectedProduct = m_selectedButton; m_uiRequestProducts.Left = m_selectedProduct; m_uiRequestPurchase.Left = m_selectedProduct; } SetDirections(); } } else if(action == AMOTION_EVENT_ACTION_UP && keyCode == OuyaSDK::Controller::BUTTON_O) { if (m_selectedButton) { LOGI("Executing action"); if (m_selectedButton == &m_uiRequestGamerUUID) { SetMessage("Fetching gamer uuid..."); Application::m_pluginOuya.AsyncOuyaFetchGamerUUID(&m_callbacksFetchGamerUUID); } if (m_selectedButton == &m_uiRequestProducts) { SetMessage("Requesting products..."); Application::m_pluginOuya.AsyncOuyaRequestProducts(&m_callbacksRequestProducts, m_productIds); } if (m_selectedButton == &m_uiRequestPurchase) { if (NULL == m_selectedProduct) { SetMessage("No product selected."); } else { OuyaSDK::Product* product = (OuyaSDK::Product*)m_selectedProduct->DataContext; if (NULL == product) { SetMessage("No product selected."); } else { SetMessage("Requesting purchase..."); Application::m_pluginOuya.AsyncOuyaRequestPurchase(&m_callbacksRequestPurchase, product->Identifier); } } } if (m_selectedButton == &m_uiRequestReceipts) { SetMessage("Requesting receipts..."); Application::m_pluginOuya.AsyncOuyaRequestReceipts(&m_callbacksRequestReceipts); } } } }