void CBitmapUi::DrawCurrentScreenState() const { EScreenState currentScreenState = GetScreenState(); switch(currentScreenState) { case eSS_InGameScreen: DrawCrosshair(); break; case eSS_LoadingScreen: DrawFullscreenQuad(m_iTexLoadingScreen); break; case eSS_StartScreen: DrawFullscreenQuad(m_iTexStartScreen); break; case eSS_PausedScreen: DrawFullscreenQuad(m_iTexPauseScreen); break; default: assert(false); break; } }
void CBitmapUi::UpdateCurrentState() { // TODO: Remove this function once we add a listener/event for game pause. assert(m_pGameFramework != NULL); EScreenState currentScreenState = GetScreenState(); if(currentScreenState == eSS_InGameScreen) { bool isGamePaused = m_pGameFramework->IsGamePaused(); if(isGamePaused) { SetScreenState(eSS_PausedScreen); } return; } if(currentScreenState == eSS_PausedScreen) { bool isGamePaused = m_pGameFramework->IsGamePaused(); if(! isGamePaused) { SetScreenState(eSS_InGameScreen); } return; } }
/* Create the buttons if the screen state has changed. buttonsCreated is changed in the message handler. Load the buttons based on the current screenstate. @return void */ void ButtonHandler::CreateButtons() { if (!buttonsCreated) { buttonStorage.clear(); LoadButtons(GetScreenState()); buttonsCreated = true; } }
void ChannelChange::Draw() { if (fade_counter_ < 120) { SetDrawBlendMode(DX_BLENDMODE_ALPHA, 255 * fade_counter_ / 120); int width, height; GetScreenState(&width, &height, nullptr); DrawBox(0, 0, width, height, GetColor(0, 0, 0), TRUE); SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0); } }
void CBitmapUi::OnLoadingProgress( ILevelInfo* pLevel, int progressAmount ) { EScreenState currentScreenState = GetScreenState(); if ( currentScreenState == eSS_LoadingScreen ) { // 3d Engine notifies of loading progress too when already in game ( eg. texture startup streaming finish ), // so we'll only draw a full frame when we're sure we're in loading state. DrawFullFrame(); } }
int Effekseer_InitDistortion(float scale) { int sizeX, sizeY, colorBitDepth; if (GetScreenState(&sizeX, &sizeY, &colorBitDepth) != 0) return -1; sizeX = static_cast<int32_t>(sizeX * scale); sizeY = static_cast<int32_t>(sizeY * scale); LPDIRECT3DDEVICE9 dx9_device = (LPDIRECT3DDEVICE9) GetUseDirect3DDevice9(); ID3D11Device* dx11_device = (ID3D11Device*)GetUseDirect3D11Device(); ID3D11DeviceContext* dx11_device_context = (ID3D11DeviceContext*)GetUseDirect3D11DeviceContext(); if (dx9_device != NULL) { ES_SAFE_RELEASE(g_dx9_backgroundTexture); ES_SAFE_RELEASE(g_dx9_backgroundSurface); HRESULT hr; hr = dx9_device->CreateTexture( sizeX, sizeY, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &g_dx9_backgroundTexture, NULL ); if (FAILED(hr)) { return -1; } g_backgroundWidth = sizeX; g_backgroundHeight = sizeY; g_dx9_backgroundTexture->GetSurfaceLevel(0, &g_dx9_backgroundSurface); } else if(dx11_device != NULL) { g_backgroundWidth = sizeX; g_backgroundHeight = sizeY; PrepareTexture_DX11(g_backgroundWidth, g_backgroundHeight, DXGI_FORMAT_R8G8B8A8_UNORM); } g_isDistortionEnabled = true; return 0; }
int DX_Init(bool window_state,int& zx,int& zy,int& check){ int zerox, zeroy, temp; SetGraphMode(Window_Spec::W_WIDTH, Window_Spec::W_HEIGHT, Window_Spec::W_COLOR);//ウィンドウサイズ変更 ChangeWindowMode(window_state);//ウィンドウモード変更 GetScreenState(&zerox, &zeroy, &temp);//画面のサイズを取得 SetDrawScreen(DX_SCREEN_BACK);//描画を裏画面に設定 if (DxLib_Init() == -1) // DXライブラリ初期化処理 { check = -1;// エラーが起きたら直ちに終了 } zx = zerox / 2, zy = zeroy / 2; return zx, zy,check; }
void Input::Draw() { { int alpha = active() ? 255 : 150; if (reverse_color_) { SetDrawBlendMode(DX_BLENDMODE_INVSRC, alpha); } else { SetDrawBlendMode(DX_BLENDMODE_ALPHA, alpha); } DrawGraph(x_, y_, *input_bg_image_handle_[0], TRUE); DrawGraph(x_ + width_ - 12, y_, *input_bg_image_handle_[1], TRUE); DrawGraph(x_, y_ + height_ - 12, *input_bg_image_handle_[2], TRUE); DrawGraph(x_ + width_ - 12, y_ + height_ - 12, *input_bg_image_handle_[3], TRUE); DrawRectExtendGraphF(x_ + 12, y_, x_ + width_ - 12, y_ + 12, 0, 0, 1, 12, *input_bg_image_handle_[1], TRUE); DrawRectExtendGraphF(x_ + 12, y_ + height_ - 12, x_ + width_ - 12, y_ + height_, 0, 0, 1, 12, *input_bg_image_handle_[3], TRUE); DrawRectExtendGraphF(x_, y_ + 12, x_ + 12, y_ + height_ - 12, 0, 0, 12, 1, *input_bg_image_handle_[2], TRUE); DrawRectExtendGraphF(x_ + width_ - 12, y_ + 12, x_ + width_, y_ + height_ - 12, 0, 0, 12, 1, *input_bg_image_handle_[3], TRUE); DrawRectExtendGraphF(x_ + 12, y_ + 12, x_ + width_ - 12, y_ + height_ - 12, 0, 0, 1, 1, *input_bg_image_handle_[3], TRUE); SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0); } { int internal_x = x_ + INPUT_MARGIN_X; int internal_y = y_ + INPUT_MARGIN_Y; // int internal_width = width_ - INPUT_MARGIN * 2; // int internal_height = height_ - INPUT_MARGIN * 2; // 選択範囲の背景を描画 //int current_line = 0; //for (auto it = selecting_lines_.begin(); it != selecting_lines_.end(); ++it) { // auto line = *it; // if (line.first < line.second) { // SetDrawBlendMode(DX_BLENDMODE_ALPHA, 100); // DrawBox(internal_x + line.first, // internal_y + current_line * font_height_, // internal_x + line.second, // internal_y + (current_line + 1) * font_height_, // GetColor(255, 0, 255), TRUE); // SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0); // } // current_line++; //} int current_line = 0; for (auto it = clause_lines_.begin(); it != clause_lines_.end(); ++it) { auto line = *it; if (line.first < line.second) { SetDrawBlendMode(DX_BLENDMODE_ALPHA, 100); DrawBox(internal_x + line.first, internal_y + current_line * font_height_, internal_x + line.second, internal_y + (current_line + 1) * font_height_, GetColor(0, 255, 255), TRUE); SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0); } current_line++; } current_line = 0; candidate_x_ = -1, candidate_y_ = -1; for (auto it = selecting_clause_lines_.begin(); it != selecting_clause_lines_.end(); ++it) { auto line = *it; if (line.first < line.second) { SetDrawBlendMode(DX_BLENDMODE_ALPHA, 100); DrawBox(internal_x + line.first, internal_y + current_line * font_height_, internal_x + line.second, internal_y + (current_line + 1) * font_height_, GetColor(255, 0, 255), TRUE); SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0); if (candidate_x_ < 0) { candidate_x_ = line.first; candidate_y_ = (current_line + 1) * font_height_; } } current_line++; } int text_color = reverse_color_ ? GetColor(255, 255, 255) : GetColor(0, 0, 0); current_line = 0; if (message_lines_.size() > 0) { for (auto it = message_lines_.begin(); it != message_lines_.end(); ++it) { auto line = *it; SetDrawBlendMode(DX_BLENDMODE_ALPHA, 140); DrawStringToHandle(internal_x, internal_y + current_line * font_height_ - 3, line.c_str(), text_color, font_handle_); SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0); current_line++; } } for (auto it = lines_.begin(); it != lines_.end(); ++it) { auto line = *it; DrawStringToHandle(internal_x, internal_y + current_line * font_height_, line.c_str(), text_color, font_handle_); current_line++; } // カーソルを描画 if (clause_lines_.size() <= 0 && active() && blink_count_ < 30) { DrawBox(internal_x + cursor_x_, internal_y + cursor_y_, internal_x + cursor_x_ + 2, internal_y + cursor_y_ + font_height_, text_color, TRUE); } } { int internal_x = x_ + INPUT_MARGIN_X; int internal_y = y_ + INPUT_MARGIN_Y; if (selecting_candidate_ >= 0) { int start_index = (selecting_candidate_ / IME_MAX_PAGE_SIZE) * IME_MAX_PAGE_SIZE; int end_index = std::min(start_index + IME_MAX_PAGE_SIZE, static_cast<int>(candidates_.size() - 1)); int x = candidate_x_; int y; int width = IME_MIN_WIDTH; int height = (end_index - start_index) * font_height_; for (int i = start_index; i < end_index; i++) { auto candidate = candidates_[i]; width = std::max(width, GetDrawStringWidthToHandle(candidate.c_str(), candidate.size(), font_handle_)); } int screen_height; GetScreenState(nullptr, &screen_height, nullptr); if (internal_y + height + candidate_x_ >= screen_height - IME_MARGIN_Y * 2) { y = candidate_y_ - font_height_ - height - IME_MARGIN_Y; } else { y = candidate_y_ + IME_MARGIN_Y; } if (height > 0) { int base_x = internal_x + x - IME_MARGIN_BASE; int base_y = internal_y + y - IME_MARGIN_BASE; int base_width = width + IME_MARGIN_BASE * 2; int base_height = height + IME_MARGIN_BASE * 2; DrawGraph(base_x, base_y, *ime_image_handle_[0], TRUE); DrawGraph(base_x + base_width - 12, base_y, *ime_image_handle_[1], TRUE); DrawGraph(base_x, base_y + base_height - 12, *ime_image_handle_[2], TRUE); DrawGraph(base_x + base_width - 12, base_y + base_height - 12, *ime_image_handle_[3], TRUE); DrawRectExtendGraphF(base_x + 12, base_y, base_x + base_width - 12, base_y + 12, 0, 0, 1, 12, *ime_image_handle_[1], TRUE); DrawRectExtendGraphF(base_x + 12, base_y + base_height - 12, base_x + base_width - 12, base_y + base_height, 0, 0, 1, 12, *ime_image_handle_[3], TRUE); DrawRectExtendGraphF(base_x, base_y + 12, base_x + 12, base_y + base_height - 12, 0, 0, 12, 1, *ime_image_handle_[2], TRUE); DrawRectExtendGraphF(base_x + base_width - 12, base_y + 12, base_x + base_width, base_y + base_height - 12, 0, 0, 12, 1, *ime_image_handle_[3], TRUE); DrawRectExtendGraphF(base_x + 12, base_y + 12, base_x + base_width - 12, base_y + base_height - 12, 0, 0, 1, 1, *ime_image_handle_[3], TRUE); } int line_top = 0; for (int i = start_index; i < end_index; i++) { if (i == selecting_candidate_) { SetDrawBlendMode(DX_BLENDMODE_ALPHA, 100); DrawBox(internal_x + x - 2, internal_y + line_top + y, internal_x + x + width + 2, internal_y + line_top + y + font_height_, GetColor(255, 0, 255), TRUE); SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0); } DrawStringToHandle(internal_x + x, internal_y + line_top + y, candidates_[i].c_str(), GetColor(0, 0, 0), font_handle_); line_top += font_height_; } } } }