TitleTemplateDlg::TitleTemplateDlg(CWnd* pParent /*=NULL*/) : CDialogEx(TitleTemplateDlg::IDD, pParent) , m_curTitle(0), m_titleShowDlg(this) { InitTitle(); }
CAppMenu::CAppMenu(const std::string &caption) { m_font.loadFromFile("res/Ubuntu-R.ttf"); m_shape.setFillColor(MENU_BACK_COLOR); m_popup.setFillColor(POPUP_BACK_COLOR); InitTitle(caption); SetFrame(m_title.getLocalBounds()); }
/***************************************************************** 関数名 : GameTitle 機能 : タイトルの処理 引数 : なし 出力 : ゲームの状態 *****************************************************************/ int GameTitle() { InitTitle(); while(gState == GAME_TITLE) { InputKey(); DrawTitle(); } return gState; }
void Form::InitFormInfo(){ //フォーム情報の初期化 if(this->info_ != NULL){ throw std::runtime_error("ポインタがNULLではありません、既に初期化されている可能性があります"); } this->info_ = boost::make_shared<ControlInfo>(); //this->info_ = boost::shared_ptr<ControlInfo>(new ControlInfo); //タイトルの初期化 InitTitle(); }
// Disconnect void _Menu::HandleDisconnect(bool WasSinglePlayer) { if(WasSinglePlayer) { InitTitle(); } else { InitConnect(true); _Label *Label = Assets.Labels["label_menu_connect_message"]; Label->Color = COLOR_RED; Label->Text = "Disconnected from server"; } }
Form::Form(WindowType wt) { //ウィンドウタイプの設定 this->wt_ = wt; //フォーム情報の初期化 InitFormInfo(); //インスタンスハンドルの取得 this->info_->hInst = GetModuleHandle(NULL); //タイトルの初期化 InitTitle(); //ウィンドウクラスの登録 RgWndClass(); // ウィンドウの生成 this->CreateWnd(); //現在のウィンドウの数を増やす this->form_n_++; }
// Handle mouse event void _Menu::MouseEvent(const _MouseEvent &MouseEvent) { if(State == STATE_NONE) return; if(!CurrentLayout) return; if(MouseEvent.Button == SDL_BUTTON_LEFT) CurrentLayout->HandleInput(MouseEvent.Pressed); // Get clicked element _Element *Clicked = CurrentLayout->GetClickedElement(); if(Clicked) { bool DoubleClick = false; if(PreviousClick == Clicked && PreviousClickTimer < MENU_DOUBLECLICK_TIME) { PreviousClick = nullptr; DoubleClick = true; } else PreviousClick = Clicked; PreviousClickTimer = 0.0; switch(State) { case STATE_TITLE: { if(Clicked->Identifier == "button_title_play") { PlayState.Connect(true); } else if(Clicked->Identifier == "button_title_joinserver") { InitConnect(true); } else if(Clicked->Identifier == "button_title_mapeditor") { InitEditor(); } else if(Clicked->Identifier == "button_title_exit") { Framework.Done = true; } } break; case STATE_CHARACTERS: { if(CharactersState == CHARACTERS_NONE) { if(Clicked->Identifier == "button_characters_delete") { size_t SelectedSlot = GetSelectedCharacter(); if(SelectedSlot < CharacterSlots.size() && CharacterSlots[SelectedSlot].Used) { _Buffer Packet; Packet.Write<PacketType>(PacketType::CHARACTERS_DELETE); Packet.Write<uint8_t>((uint8_t)SelectedSlot); PlayState.Network->SendPacket(Packet); } } else if(Clicked->Identifier == "button_characters_play") { size_t SelectedSlot = GetSelectedCharacter(); if(SelectedSlot < CharacterSlots.size() && CharacterSlots[SelectedSlot].Used) { PlayCharacter(SelectedSlot); } } else if(Clicked->Identifier == "button_characters_back") { PlayState.Network->Disconnect(); } else if(Clicked->Identifier.substr(0, CharacterButtonPrefix.size()) == CharacterButtonPrefix) { // Deselect slots _Element *CharactersElement = Assets.Elements["element_menu_characters"]; for(auto &Element : CharactersElement->Children) { if(Element->Identifier.substr(0, CharacterButtonPrefix.size()) == CharacterButtonPrefix) { _Button *Button = (_Button *)Element; Button->Checked = false; } } // Set selection size_t SelectedSlot = (size_t)(intptr_t)Clicked->UserData; CharacterSlots[SelectedSlot].Button->Checked = true; // Open new character screen if(!CharacterSlots[SelectedSlot].Used) InitNewCharacter(); UpdateCharacterButtons(); if(DoubleClick && SelectedSlot < CharacterSlots.size()) { PlayCharacter(SelectedSlot); } } } else if(CharactersState == CHARACTERS_CREATE) { if(Clicked->Identifier == NewCharacterPortraitPrefix || Clicked->Identifier == NewCharacterBuildPrefix) { size_t SelectedID = (size_t)(intptr_t)Clicked->UserData; // Unselect all portraits and select the clicked element for(auto &Element : Clicked->Parent->Children) { _Button *Button = (_Button *)Element; Button->Checked = false; if((size_t)(intptr_t)Button->UserData == SelectedID) { _TextBox *Name = Assets.TextBoxes["textbox_newcharacter_name"]; FocusedElement = Name; Name->ResetCursor(); Button->Checked = true; } } ValidateCreateCharacter(); } else if(Clicked->Identifier == "button_newcharacter_create") { CreateCharacter(); } else if(Clicked->Identifier == "button_newcharacter_cancel") { RequestCharacterList(); } } } break; case STATE_CONNECT: { if(Clicked->Identifier == "button_connect_connect") { if(!PlayState.Network->IsDisconnected()) { PlayState.Network->Disconnect(true); InitConnect(false); } else ConnectToHost(); } else if(Clicked->Identifier == "button_connect_back") { InitTitle(true); } } break; case STATE_ACCOUNT: { if(Clicked->Identifier == "button_account_login") { SendAccountInfo(); } else if(Clicked->Identifier == "button_account_create") { SendAccountInfo(true); } else if(Clicked->Identifier == "button_account_back") { InitConnect(true); } } break; case STATE_INGAME: { if(Clicked->Identifier == "button_ingame_resume") { InitPlay(); } else if(Clicked->Identifier == "button_ingame_disconnect") { PlayState.Network->Disconnect(); } } break; default: break; } } }
// Handle key event void _Menu::KeyEvent(const _KeyEvent &KeyEvent) { if(State == STATE_NONE) return; switch(State) { case STATE_TITLE: { if(KeyEvent.Pressed && !KeyEvent.Repeat) { if(KeyEvent.Scancode == SDL_SCANCODE_ESCAPE) Framework.Done = true; else if(KeyEvent.Scancode == SDL_SCANCODE_RETURN) { PlayState.Connect(true); } } } break; case STATE_CHARACTERS: { if(CharactersState == CHARACTERS_NONE) { if(KeyEvent.Pressed && !KeyEvent.Repeat) { if(KeyEvent.Scancode == SDL_SCANCODE_ESCAPE) PlayState.Network->Disconnect(); else if(KeyEvent.Scancode == SDL_SCANCODE_RETURN) { size_t SelectedSlot = GetSelectedCharacter(); if(SelectedSlot >= CharacterSlots.size()) SelectedSlot = 0; if(CharacterSlots[SelectedSlot].Used) { PlayCharacter(SelectedSlot); } } } } else if(CharactersState == CHARACTERS_CREATE){ ValidateCreateCharacter(); if(KeyEvent.Pressed) { if(KeyEvent.Scancode == SDL_SCANCODE_ESCAPE) RequestCharacterList(); else if(KeyEvent.Scancode == SDL_SCANCODE_RETURN) CreateCharacter(); } } } break; case STATE_CONNECT: { if(KeyEvent.Pressed && !KeyEvent.Repeat) { if(KeyEvent.Scancode == SDL_SCANCODE_ESCAPE) InitTitle(true); else if(KeyEvent.Scancode == SDL_SCANCODE_RETURN) ConnectToHost(); else if(KeyEvent.Scancode == SDL_SCANCODE_TAB) FocusNextElement(); } } break; case STATE_ACCOUNT: { if(KeyEvent.Pressed && !KeyEvent.Repeat) { if(KeyEvent.Scancode == SDL_SCANCODE_ESCAPE) InitConnect(true); else if(KeyEvent.Scancode == SDL_SCANCODE_RETURN) SendAccountInfo(); else if(KeyEvent.Scancode == SDL_SCANCODE_TAB) FocusNextElement(); } } break; case STATE_INGAME: { } break; default: break; } }
/** * DSP command loop * @return MCAPI_SUCCESS/ error code */ mcapi_status_t dsp_command_loop(void) { FILE *fp1; uint32_t FrameNumber = 0; mcapi_status_t status = MCAPI_ERR_GENERAL; mcapi_uint32_t command = DSP_READY,nCurrContourCount=0; mcapi_uint32_t rx_size = 0; MT9M114_VIDEO_BUF *pVideoBuff; uint32_t *pTemp = (uint32_t *)&buffer[0]; while (command != DSP_TERMINATE) { status = receive_dsp_cmd(&command); #ifdef DEBUG_INFO if (MCAPI_SUCCESS != status) { fprintf(stdout, "[%s] %d status: %d receive_dsp_cmd failure\n", __FILE__, __LINE__, status); exit(1); } #endif switch (command) { case DSP_DATA: #ifdef DEBUG_INFO printf("[CORE B]: Received command (DSP_DATA)\n"); #endif status = receive_dsp_data(buffer, &rx_size); #ifdef DEBUG_INFO if (MCAPI_SUCCESS != status) { fprintf(stdout, "[%s] %d status: %d receive_dsp_data failure\n", __FILE__, __LINE__, status); exit(1); } #endif #ifdef DEBUG_INFO printf("[CORE B]: Received data\n"); #endif break; case DSP_CODE: #ifdef DEBUG_INFO printf("[CORE B]: Received command (DSP_CODE)\n"); #endif break; case DSP_INIT: /* Tell DSP to Execute – Assume code writes to result_buffer */ #ifdef DEBUG_INFO printf("[CORE B]: Received command (DSP_INIT)\n"); #endif InitTitle((void*)(*pTemp)); #ifdef DEBUG_INFO printf("[CORE B]: Processing complete\n"); printf("[CORE B]: Sending data\n"); #endif status = send_dsp_data(buffer, rx_size); #ifdef DEBUG_INFO if (MCAPI_SUCCESS != status) { fprintf(stdout, "[%s] %d status: %d send_dsp_data failure\n", __FILE__, __LINE__, status); exit(1); } #endif #ifdef DEBUG_INFO printf("[CORE B]: Sending data complete\n"); #endif break; case DSP_GFXCONTOUR: /* Tell CORE B to find contour & update dot count */ #ifdef DEBUG_INFO printf("[CORE B]: Received command (DSP_GFXCONTOUR)\n"); #endif pGFxBuff =(VIDEO_BUF *) pInfo->pBuf2; if(pInfo->pBuf1 != NULL) { if((nCurrContourCount = ADI_FindContours(pInfo->pBuf1, pInfo->nWidth,pInfo->nHeight))!= 0XFFFFFFFF) { CONTOURCount =nCurrContourCount; #if 0 // EMG start if( (FrameNumber++ > 20) && (CONTOURCount != 72) ) { // Moved here for dropbox indication fp1=fopen( "FindContours.dat","wb"); printf( "Capturing data - \n" ); fwrite( pInfo->pBuf1, 1, (720*480), fp1); fclose(fp1); printf( "Data Captured\n" ); while(1); } // EMGend #endif } } #if defined(BF609_VSK_SHOW_LIGHTING_ON_MONITOR) Illumination = pInfo->nIllumination; #endif update_contour_count(); /* Mark the buffer valid for submitting to display.*/ pVideoBuff = (MT9M114_VIDEO_BUF *)pInfo->pBuf2; pVideoBuff->eStatus = CONTOUR_COUNT_BUFFER_READY; pInfo->nCompletionFlag = 1; /* to indicate that core B has completed processing */ #ifdef DEBUG_INFO printf("[CORE B]: Processing complete\n"); printf("[CORE B]: Sending data\n"); #endif status = send_dsp_data(buffer, rx_size); #ifdef DEBUG_INFO if (MCAPI_SUCCESS != status) { fprintf(stdout, "[%s] %d status: %d send_dsp_data failure\n", __FILE__, __LINE__, status); exit(1); } #endif #ifdef DEBUG_INFO printf("[CORE B]: Sending data complete\n"); #endif break; case DSP_TERMINATE: #ifdef DEBUG_INFO printf("[CORE B]: Received command (DSP_TERMINATE)\n"); #endif status = dsp_shutdown(); #ifdef DEBUG_INFO if (MCAPI_SUCCESS != status) { fprintf(stdout, "[%s] %d status: %d dsp_shutdown failure\n", __FILE__, __LINE__, status); exit(1); } #endif break; default: break; } } return status; }
void main(void) { uint32_t nResult= SUCCESS; /* Buffer pointer used to get the frames with data */ void *pVideoBuffer=NULL; uint32_t *pTemp = (uint32_t *)&buffer[0]; //MT9M114_VIDEO_BUF *pBufTemp; //uint32_t *pBuf; //int32_t nSize; /* Initialize the ADI components such as pin muxing etc */ adi_initComponents(); /* auto-generated code */ /* Initialize DMC */ adi_DMCamInit(); /* By default, Graphics is not used to draw the bounding rectangle around the detected dot */ InitTitle((void*)(*pTemp)); nBoundingRectFlag = 0; #if defined(FINBOARD) nIllumination = prevIllumination = 1; #endif /* Registering the MDMA callback for Channel-1(Dest) with Interrupt ID 91 (page 219, HRM) * to Core-B since it is used to mark the canny output */ //nSize = sizeof(uint32_t); /******************************************************/ /*mcapi_finalize(&mcapi_status); if (MCAPI_SUCCESS != mcapi_status) { exit(1); }*/ #ifdef DEBUG_INFO printf("[CORE A]: BF609_MCAPI_msg: %s\n", retVal == PASS ? "All done" : "Error..."); #endif /******************************************************/ do { /* Initialize the power services*/ if (adi_pwr_Init (PROC_CLOCK_IN, PROC_MAX_CORE_CLOCK, PROC_MAX_SYS_CLOCK, PROC_MIN_VCO_CLOCK) != ADI_PWR_SUCCESS) { printf ("Failed to initialize Power service\n"); nResult= FAILURE; break; } /* Set the required core clock and system clock */ if(adi_pwr_SetFreq(PROC_REQ_CORE_CLOCK, PROC_REQ_SYS_CLOCK)!= ADI_PWR_SUCCESS ) { printf ("Failed to initialize Power service\n"); nResult= FAILURE; break; } /* Initialize the GPIO for enabling/disabling the PB1 which inturn control the graphics to draw the rectangle around the detected dots */ if(Init_GPIO()!= SUCCESS) { printf("\n GPIO initialization failed \n"); nResult= FAILURE; break; } #if !defined(FINBOARD) /* Configure the Software controlled switches on BF609 EZ-Board */ ConfigSoftSwitches_BF609(); #else // !defined(FINBOARD) FINBOARD_CLK_Synth_Restore(); // restore firmware settings FINBOARD_LED_Drivers_Init(); FINBOARD_LED_Drivers_Config( nIllumination ); #endif // defined(FINBOARD) /* Configure the sensor */ if(ConfigureSensor() != SUCCESS) { printf("Failed to configure Sensor \n"); nResult= FAILURE; break; } /* Configure the sensor for display */ if(ConfigureEncoder() != SUCCESS) { printf("Failed to configure LCD \n"); nResult= FAILURE; break; } #if defined(FINBOARD) FINBOARD_ADV7511_16bit_Mode(); #endif /* Submit the first frame for filling */ if(SubmitEmptyVideoFrame() != SUCCESS) { printf("Failed to submit empty video frame to the sensor \n"); nResult= FAILURE; break; } /* Submit the second frame for filling */ if(SubmitEmptyVideoFrame() != SUCCESS) { printf("Failed to submit empty video frame to the sensor \n"); nResult= FAILURE; break; } /* Submit first buffer to encoder */ if(SubmitEncBuf(pEncDispStartBuf) != SUCCESS) { printf("Failed to submit video frame to the encoder \n"); nResult= FAILURE; break; } /* Submit same buffer since we will be waiting for the first frame from the sensor */ if(SubmitEncBuf(pEncDispStartBuf) != SUCCESS) { printf("Failed to submit video frame to the encoder \n"); nResult= FAILURE; break; } /* Wait till the first frame is captured */ /* Enable the sensor to capture the frames */ if(EnableDisplay(true) != SUCCESS) { printf("Failed to enable video encoder \n"); nResult= FAILURE; break; } if(EnableSensor(true) != SUCCESS) { printf("Failed to enable sensor \n"); nResult= FAILURE; break; } /* Start the display */ while( NumFramesCaptured == 0 ); }while(0); printf( "\nVersion: %s-%s\n", __DATE__, __TIME__); /* A while loop to timeout the example*/ while(NumFramesCaptured < EXAMPLE_TIMEOUT && nResult == SUCCESS ) { /* Get the video display frame */ pVideoBuffer = NULL; while(pVideoBuffer == NULL) { GetProcessedSensorBuf (&pVideoBuffer); } if(pVideoBuffer != NULL ) { #if defined(FINBOARD) if ( prevIllumination != nIllumination ) { prevIllumination = nIllumination; FINBOARD_LED_Drivers_Config( nIllumination ); } #endif } /* Increment the counter */ NumFilledFrames++; } /* end of while loop */ if(nResult == SUCCESS) { printf("All done \n"); } else { printf("Failed to run dot count application.\n"); } }