//////////////////////////////////////////////////////////////////////// // Procedure DrawScene is called whenever the scene needs to be drawn. void DrawScene( Scene &scene, int width, int height ) { // Choose OpenGL or student rendering here. The decision can be // based on useOpenGLRendering, useFastRendering, or both: if (scene.UseOpenGLRendering) { BeginDefaultDraw( width, height ); glEnable(GL_DEPTH_TEST); DrawSceneWithOpenGL(scene, width, height); glDisable(GL_DEPTH_TEST); DrawMessage("Rendered by OpenGL (toggle with 'g')", width, height); } else { static std::stringstream cmsg; cmsg.str( "" ); Scene sceneNew = scene; cmsg << "Occluded Objects: " << RemoveOccludedObjects( sceneNew, width, height ); glEnable( GL_DEPTH_TEST ); BeginDraw( scene, width, height ); size_t nObjs = sceneNew.objects.size(); for ( size_t i = 0; i < nObjs; ++i ) DrawObject( sceneNew.objects[i], !sceneNew.objects[i].occluder ); glDisable( GL_DEPTH_TEST ); DrawMessage( (char *)cmsg.str().c_str(), width, height ); ERRCHECK( "end (uncaught)" ); } }
void DeadVideoLink::Draw() { float size[2]; GetSize(size); Uint32 now = SDL_GetTicks(); if (now - m_created < 1500) { glBegin(GL_QUADS); glColor3f(0,0,0); glVertex2f(0,0); glVertex2f(0,size[1]); glVertex2f(size[0],size[1]); glVertex2f(size[0],0); glEnd(); m_message->SetText(Lang::VID_CONNECTING); DrawMessage(); return; } m_message->SetText(Lang::VID_LINK_DOWN); UpdateWhiteNoise(); m_quad->Draw(Gui::Screen::GetRenderer(), vector2f(0.0f), vector2f(size[0],size[1])); DrawMessage(); }
void RemoteIconView::Paint( const Rect& cUpdateRect ) { if( m_pcServer == NULL ) { /* Draw a message if we aren't connected to a server */ DrawMessage( "Not connected!\nEnter a server in the toolbar above and hit 'Connect'." ); /* TODO: localised strings */ } else if( m_bUpdatePending && GetIconCount() == 0 ) { /* Draw a 'Waiting for server' message */ DrawMessage( "Waiting for server..." ); /* TODO: localised strings */ } else { IconView::Paint( cUpdateRect ); } }
eOSState cPlexSdOsd::ProcessKey(eKeys Key) { eOSState state = eOSState::osContinue; if (m_detailsActive) { state = ProcessKeyDetailView(Key); } else { //check if some plexservers are online if (plexclient::plexgdm::GetInstance().GetFirstServer() == NULL || (plexclient::plexgdm::GetInstance().GetFirstServer() && plexclient::plexgdm::GetInstance().GetFirstServer()->Offline) ) { DrawMessage(std::string(tr("No Plex Media Server found."))); switch (Key & ~k_Repeat) { case kOk: case kBack: return eOSState::osEnd; default: return eOSState::osContinue; } } state = ProcessKeyBrowserView(Key); } return state; }
//--------------------------------------------------------------------------- void __fastcall TClockAdjDlg::PaintCursor(void) { PaintBox->Canvas->Pen->Color = clLime; PaintBox->Canvas->Pen->Style = psDot; PaintBox->Canvas->MoveTo(m_CursorX, 0); int rop = ::SetROP2(PaintBox->Canvas->Handle, R2_MASKPENNOT); PaintBox->Canvas->LineTo(m_CursorX, pBitmap->Height - 1); ::SetROP2(PaintBox->Canvas->Handle, rop); if( m_Point ){ PaintBox->Canvas->Pen->Color = clYellow; PaintBox->Canvas->Pen->Style = psSolid; PaintBox->Canvas->MoveTo(m_PointX, m_PointY); ::SetROP2(PaintBox->Canvas->Handle, R2_MASKPENNOT); PaintBox->Canvas->LineTo(m_PointX2, m_PointY2); ::SetROP2(PaintBox->Canvas->Handle, rop); char bf[256]; if( MsgEng ){ sprintf( bf, "OK : Left button, Cancel : Right button Clock=%.2lf", GetPointSamp()); } else { sprintf( bf, "決定 : 左ボタン, 中止 : 右ボタン Clock=%.2lf", GetPointSamp()); } DrawMessage(bf); if( PaintBox->Cursor != crCross ) PaintBox->Cursor = crCross; } else { if( PaintBox->Cursor != crDefault ) PaintBox->Cursor = crDefault; } }
void DrawMessages() { if (!SConfig::GetInstance().bOnScreenDisplayMessages) return; { std::lock_guard<std::mutex> lock(s_messages_mutex); const u32 now = Common::Timer::GetTimeMs(); float current_x = LEFT_MARGIN * ImGui::GetIO().DisplayFramebufferScale.x; float current_y = TOP_MARGIN * ImGui::GetIO().DisplayFramebufferScale.y; int index = 0; auto it = s_messages.begin(); while (it != s_messages.end()) { const Message& msg = it->second; const int time_left = static_cast<int>(msg.timestamp - now); current_y += DrawMessage(index++, msg, ImVec2(current_x, current_y), time_left); if (time_left <= 0) it = s_messages.erase(it); else ++it; } } }
void CChessGUI::DrawScrean() { DrawBackground(); DrawGameBoard(); DrawPieces(); DrawTurn(); DrawMessage(); }
/** Draw a confirm dialog. */ void DrawConfirmDialog(DialogType *dp) { Assert(dp); DrawMessage(dp); DrawButtons(dp); }
static void ProcessGameOver(struct BALL *Ball, struct PADDLE *Paddle) { char OutBuf[255]; snprintf(OutBuf, sizeof OutBuf, "GAME OVER! Score is %d. Hit ESC to exit or space to play again.", Score); Lives = 0; DrawStats(); Lives = 3; Score = 0; DrawMessage(OutBuf); cbreak(); AskAgain: switch (getch()) { case 27: /*27 is ESC.*/ endwin(); exit(0); break; case ' ': break; default: goto AskAgain; } halfdelay(1); DeleteMessage(); DeleteBall(Ball); DeletePaddle(Paddle); DeleteAllBricks(); DeleteAllCharms(); SetLevel(1); /*Set back to the default level again.*/ ResetPaddle(Paddle); ResetBricks(); DrawPaddle(Paddle); DrawAllBricks(); DrawStats(); /*Assume they want to play again.*/ WaitForUserLaunch(); ResetBall(Ball); DrawBall(Ball); DrawAllBricks(); /*Redraw to fix WaitForUserLaunch() goofing.*/ }
void APlatformerHUD::DisplayRoundTimer() { APlatformerGameMode* GI = GetWorld()->GetAuthGameMode<APlatformerGameMode>(); if (GI) { const float RoundDuration = GI->GetRoundDuration(); const bool bIncludeSign = false; FString RoundDurationText = FString(TEXT("Time: ")) + UPlatformerBlueprintLibrary::DescribeTime(RoundDuration, bIncludeSign); DrawMessage(RoundDurationText, 0.5f, 0.1f, 1.0f, FLinearColor::White); } }
void GVSearchListBox::DrawItem(LPDRAWITEMSTRUCT lpdis) { std::lock_guard<std::recursive_mutex> l(mutex_); switch (lpdis->itemAction) { case ODA_DRAWENTIRE: { if (lpdis->itemState & ODS_SELECTED) { DrawSelected(lpdis); } else { DrawEntire(lpdis); } } break; case ODA_SELECT: { if (lpdis->itemState & ODS_SELECTED) { DrawSelected(lpdis); } else { DrawEntire(lpdis); } } break; default: break; } RECT rect(lpdis->rcItem); HPEN hpen = CreatePen(PS_SOLID, 1, RGB(248, 248, 248)); HBRUSH hbrush = CreateSolidBrush(RGB(248, 248, 248)); SelectObject(lpdis->hDC, hpen); SelectObject(lpdis->hDC, hbrush); Rectangle(lpdis->hDC, rect.left + 12, rect.bottom - 1, rect.right - 12, rect.bottom); DeleteObject(hpen); DeleteObject(hbrush); DrawAvatar(lpdis); DrawMessage(lpdis); DrawVia(lpdis); }
void APlatformerHUD::DisplayRoundTimeModification() { const float ModificationDisplayDuration = 0.5f; const float CurrTime = GetWorld()->GetTimeSeconds(); if (RoundTimeModification != 0.0f && CurrTime - RoundTimeModificationTime <= ModificationDisplayDuration) { FString DisplayText = UPlatformerBlueprintLibrary::DescribeTime(RoundTimeModification, true); const float Delta = FMath::Clamp((CurrTime - RoundTimeModificationTime) / ModificationDisplayDuration, 0.0f, 1.0f); const float PosY = 0.11f + Delta * 0.24f; DrawMessage(DisplayText, 0.5f, PosY, 1.0f, FLinearColor::White); } }
void TUI::Redraw (int drawFlags) { // Redraw the "static" background if (simpleMode) { DrawSimple (); return; } // Clear if (drawFlags & TUI_DRAW_CLEAR) csPrintf (CS_ANSI_CLEAR_SCREEN); // Screen layout (keep to 80x25...) if (drawFlags & TUI_DRAW_STATIC) DrawStatic (); // Draw progress if (drawFlags & TUI_DRAW_PROGRESS) DrawProgress (); // Draw messages if (drawFlags & TUI_DRAW_MESSAGES) DrawMessage (); // Draw RayCore stats if (drawFlags & TUI_DRAW_RAYCORE) DrawRayCore (); // Draw photonmapper stats if (drawFlags & TUI_DRAW_PMCORE) DrawPMCore (); // Draw global settings if (drawFlags & TUI_DRAW_SETTINGS) DrawSettings (); // Draw global stats if (drawFlags & TUI_DRAW_STATS) DrawStats (); if (drawFlags & TUI_DRAW_SWAPCACHE) DrawSwapCacheStats (); /* Linux: output is buffered, and the UI may appear "incomplete" if not * flushed */ fflush (stdout); }
void APlatformerHUD::DrawActiveMessages() { const float CurrTime = GetWorld()->GetTimeSeconds(); for (int32 i = ActiveMessages.Num() - 1; i >= 0; --i) { const FPlatformerMessageData& Message = ActiveMessages[i]; const bool bIsActive = (CurrTime < Message.DisplayDuration + Message.DisplayStartTime); if (bIsActive) { DrawMessage(Message.Message, Message.PosX, Message.PosY, Message.TextScale, FLinearColor::White, Message.bRedBorder); } else { ActiveMessages.RemoveAt(i); } } }
static void WaitForUserLaunch(void) { int Key; DrawMessage("Hit L to launch."); while ((Key = getch()) != 'l' && Key != 'L' && Key != 27); DeleteMessage(); if (Key == 27) /*ESC*/ { endwin(); exit(0); } }
void CCatchScreenDlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); // Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon dc.DrawIcon(x, y, m_hIcon); } else { //************************************************************************** CPaintDC dc(this); //显示截取矩形大小信息 if(m_bShowMsg&&m_bFirstDraw) { //得到当前矩形大小 CRect rect; m_rectTracker.GetTrueRect(&rect); final_rect = rect; //传递CPaintDC 是为了不在了窗口上画信息 DrawMessage(rect,&dc); } //画出像皮筋矩形 if(m_bFirstDraw) { m_rectTracker.Draw(&dc); } //************************************************************************* CDialog::OnPaint(); } }
void FaceVideoLink::Draw() { float size[2]; GetSize(size); Uint32 now = SDL_GetTicks(); if (now - m_created < 1500) { glBegin(GL_QUADS); glColor3f(0,0,0); glVertex2f(0,0); glVertex2f(0,size[1]); glVertex2f(size[0],size[1]); glVertex2f(size[0],0); glEnd(); m_message->SetText(Lang::VID_CONNECTING); DrawMessage(); return; } glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, m_tex); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glBegin(GL_QUADS); float w = float(FACE_WIDTH) / ceil_pow2(FACE_WIDTH); float h = float(FACE_HEIGHT) / ceil_pow2(FACE_HEIGHT); glColor3f(0,0,0); glTexCoord2f(0,h); glVertex2f(0,size[1]); glTexCoord2f(w,h); glVertex2f(size[0],size[1]); glTexCoord2f(w,0); glVertex2f(size[0],0); glTexCoord2f(0,0); glVertex2f(0,0); glEnd(); glDisable(GL_TEXTURE_2D); glPushMatrix(); glTranslatef(0.f, size[1]- size[1] * 0.16f, 0.f); m_characterInfo->Draw(); glPopMatrix(); }
void CCatchScreenDlg::DoPaint(CDC& dc) { CRect rect; GetClientRect(&rect); CDC dcMem; dcMem.CreateCompatibleDC(&dc); HBITMAP hBitmap = CreateCompatibleBitmap(dc.GetSafeHdc(), rect.Width(), rect.Height()); // 把新位图选到内存设备描述表中 HBITMAP hOldBitmap = (HBITMAP)dcMem.SelectObject( hBitmap); //用整个桌面填充全屏对话框背景 if (m_BackgroundBitmap.GetSafeHandle()) { BITMAP bmp; m_BackgroundBitmap.GetBitmap(&bmp); CDC dcCompatible; dcCompatible.CreateCompatibleDC(&dcMem); dcCompatible.SelectObject(m_BackgroundBitmap); CRect rect; GetClientRect(&rect); dcMem.BitBlt(0,0,rect.Width(),rect.Height(),&dcCompatible,0,0,SRCCOPY); } //画出像皮筋矩形 if(m_bDrawTracker) { //画出橡皮筋里面的原始图像 DrawOrgRect(&dcMem,m_rectTracker.m_rect); m_rectTracker.Draw(&dcMem); //显示截取矩形大小信息 if(m_bShowMsg) { CRect rect; m_rectTracker.m_rect.NormalizeRect(); DrawMessage(dcMem,m_rectTracker.m_rect); } } dc.BitBlt(0,0,rect.Width(),rect.Height(),&dcMem, 0, 0, SRCCOPY); hBitmap = (HBITMAP)dcMem.SelectObject( hOldBitmap); dcMem.DeleteDC(); DeleteObject(hBitmap); }
void GVSearchListBox::DrawEntire(LPDRAWITEMSTRUCT lpdis) { RECT rect(lpdis->rcItem); HPEN hpen = CreatePen(PS_SOLID, 1, RGB(255, 255, 255)); HBRUSH hbrush = CreateSolidBrush(RGB(255, 255, 255)); SelectObject(lpdis->hDC, hpen); SelectObject(lpdis->hDC, hbrush); Rectangle(lpdis->hDC, rect.left, rect.top, rect.right, rect.bottom); DeleteObject(hpen); DeleteObject(hbrush); DrawAvatar(lpdis); DrawMessage(lpdis); DrawVia(lpdis); }
// 출력 void Draw() { if(!(refresh_object || refresh_message || refresh_status || refresh_time)) { return; } if(refresh_object) { refresh_object = 0; DrawFloor(map_id); DrawObjects(); } if(refresh_message) { refresh_message = 0; DrawMessage(); } if(refresh_status) { refresh_status = 0; DrawStatus(); } if(refresh_time) { refresh_time = 0; DrawTime(); } mvaddch(22, 78, ' '); refresh(); }
static LONG_PTR WINAPI DlgProc(HANDLE hDlg,int Msg,int Param1,LONG_PTR Param2) { static TCHAR Filter[MAX_PATH]; static TCHAR spFilter[MAX_PATH]; static FarListTitles ListTitle; switch(Msg) { case DN_RESIZECONSOLE: { Info.SendDlgMessage(hDlg,DM_ENABLEREDRAW,FALSE,0); ResizeDialog(hDlg); Info.SendDlgMessage(hDlg,DM_ENABLEREDRAW,TRUE,0); } return TRUE; case DMU_UPDATE: { int OldPos = static_cast<int>(Info.SendDlgMessage(hDlg,DM_LISTGETCURPOS,LIST_BOX,0)); if (Param1) UpDateInfo(); ListSize = 0; int NewPos = -1; if (OldPos >= 0 && OldPos < nCount) { if (!*Filter || strstri(p[OldPos].Keys[DisplayName],Filter)) //без учета регистра в OEM кодировке NewPos = OldPos; } for (int i = 0; i < nCount; i++) { const TCHAR* DispName = p[i].Keys[DisplayName], *Find; if (*Filter) Find = strstri(DispName,Filter); else Find = DispName; if (Find != nullptr) //без учета регистра в OEM кодировке { FLI[i].Flags &= ~LIF_HIDDEN; if (Param2 && (i == OldPos)) { if (FLI[i].Flags & LIF_CHECKED) { FLI[i].Flags &= ~LIF_CHECKED; } else { FLI[i].Flags |= LIF_CHECKED; } } //без учета регистра - а кодировка ANSI if (NewPos == -1 && Find == DispName) NewPos = i; ListSize++; } else FLI[i].Flags |= LIF_HIDDEN; } if (Param1 == 0 && Param2) { // Снятие или установка пометки (Ins) if (Param2 == 1) { for (int i = (OldPos+1); i < nCount; i++) { if (!(FLI[i].Flags & LIF_HIDDEN)) { OldPos = i; break; } } NewPos = OldPos; } // Снятие или установка пометки (RClick) else if (Param2 == 2) { NewPos = OldPos; } } else if (NewPos == -1) { NewPos = OldPos; } Info.SendDlgMessage(hDlg,DM_ENABLEREDRAW,FALSE,0); Info.SendDlgMessage(hDlg,DM_LISTSET,LIST_BOX,reinterpret_cast<LONG_PTR>(&FL)); StringCchPrintf(spFilter,ARRAYSIZE(spFilter), GetMsg(MFilter),Filter,ListSize,nCount); ListTitle.Title = spFilter; ListTitle.TitleLen = lstrlen(spFilter); Info.SendDlgMessage(hDlg,DM_LISTSETTITLES,LIST_BOX,reinterpret_cast<LONG_PTR>(&ListTitle)); ResizeDialog(hDlg); struct FarListPos FLP; FLP.SelectPos = NewPos; FLP.TopPos = -1; Info.SendDlgMessage(hDlg,DM_LISTSETCURPOS,LIST_BOX,reinterpret_cast<LONG_PTR>(&FLP)); Info.SendDlgMessage(hDlg,DM_ENABLEREDRAW,TRUE,0); } break; case DN_INITDIALOG: { StringCchCopy(Filter,ARRAYSIZE(Filter),_T("")); ListTitle.Bottom = const_cast<TCHAR*>(GetMsg(MBottomLine)); ListTitle.BottomLen = lstrlen(GetMsg(MBottomLine)); //подстраиваемся под размеры консоли Info.SendDlgMessage(hDlg,DM_ENABLEREDRAW,FALSE,0); ResizeDialog(hDlg); Info.SendDlgMessage(hDlg,DM_ENABLEREDRAW,TRUE,0); //заполняем диалог Info.SendDlgMessage(hDlg,DMU_UPDATE,1,0); } break; case DN_MOUSECLICK: { if (Param1 == LIST_BOX) { MOUSE_EVENT_RECORD *mer = (MOUSE_EVENT_RECORD *)Param2; if (mer->dwButtonState == FROM_LEFT_1ST_BUTTON_PRESSED) { // find list on-screen coords (excluding frame and border) SMALL_RECT list_rect; Info.SendDlgMessage(hDlg, DM_GETDLGRECT, 0, reinterpret_cast<LONG_PTR>(&list_rect)); list_rect.Left += 2; list_rect.Top += 1; list_rect.Right -= 2; list_rect.Bottom -= 1; if ((mer->dwEventFlags == 0) && (mer->dwMousePosition.X > list_rect.Left) && (mer->dwMousePosition.X < list_rect.Right) && (mer->dwMousePosition.Y > list_rect.Top) && (mer->dwMousePosition.Y < list_rect.Bottom)) { DlgProc(hDlg, DN_KEY, LIST_BOX, KEY_ENTER); return TRUE; } // pass message to scrollbar if needed if ((mer->dwMousePosition.X == list_rect.Right) && (mer->dwMousePosition.Y > list_rect.Top) && (mer->dwMousePosition.Y < list_rect.Bottom)) return FALSE; return TRUE; } else if (mer->dwButtonState == RIGHTMOST_BUTTON_PRESSED) { Info.SendDlgMessage(hDlg,DMU_UPDATE,0,2); return TRUE; } } } break; case DN_KEY: switch (Param2) { case KEY_F8: { if (ListSize) { TCHAR DlgText[MAX_PATH + 200]; StringCchPrintf(DlgText, ARRAYSIZE(DlgText), GetMsg(MConfirm), p[Info.SendDlgMessage(hDlg,DM_LISTGETCURPOS,LIST_BOX,NULL)].Keys[DisplayName]); if (EMessage((const TCHAR * const *) DlgText, 0, 2) == 0) { if (!DeleteEntry(static_cast<int>(Info.SendDlgMessage(hDlg,DM_LISTGETCURPOS,LIST_BOX,NULL)))) DrawMessage(FMSG_WARNING, 1, "%s",GetMsg(MPlugIn),GetMsg(MDelRegErr),GetMsg(MBtnOk),NULL); Info.SendDlgMessage(hDlg,DMU_UPDATE,1,0); } } } return TRUE; case (KEY_F9|KEY_SHIFT|KEY_ALT): case (KEY_F9): { Configure(0); } return TRUE; case KEY_CTRLR: { Info.SendDlgMessage(hDlg,DMU_UPDATE,1,0); } return TRUE; case KEY_INS: { Info.SendDlgMessage(hDlg,DMU_UPDATE,0,1); } return TRUE; case KEY_ENTER: case KEY_SHIFTENTER: { if (ListSize) { int liChanged = 0; int liSelected = 0, liFirst = -1; for (int i = 0; i < nCount; i++) { if (FLI[i].Flags & LIF_CHECKED) { if (liFirst == -1) liFirst = i; liSelected++; } } if (liSelected <= 1) { int liAction = (Param2 == KEY_ENTER) ? Opt.EnterAction : Opt.ShiftEnterAction; int pos = (liFirst == -1) ? static_cast<int>(Info.SendDlgMessage(hDlg,DM_LISTGETCURPOS,LIST_BOX,NULL)) : liFirst; liChanged = ExecuteEntry(pos, liAction, (Opt.RunLowPriority!=0)); } else { int liAction = (Param2 == KEY_ENTER) ? Opt.EnterAction : Opt.ShiftEnterAction; bool LowPriority = (Opt.RunLowPriority!=0); // Обязательно ожидание - два инсталлятора сразу недопускаются if (liAction == Action_Menu) { if (EntryMenu(0, liAction, LowPriority, liSelected) < 0) return TRUE; } else if (liAction == Action_Uninstall) liAction = Action_UninstallWait; else if (liAction == Action_Modify) liAction = Action_ModifyWait; else if (liAction == Action_Repair) liAction = Action_RepairWait; for (int pos = 0; pos < nCount; pos++) { if (!(FLI[pos].Flags & LIF_CHECKED)) continue; struct FarListPos FLP; FLP.SelectPos = pos; FLP.TopPos = -1; Info.SendDlgMessage(hDlg,DM_LISTSETCURPOS,LIST_BOX,reinterpret_cast<LONG_PTR>(&FLP)); int li = ExecuteEntry(pos, liAction, LowPriority); if (li == -1) break; // отмена if (li == 1) liChanged = 1; } } if (liChanged == 1) { Info.SendDlgMessage(hDlg,DMU_UPDATE,1,0); } } } return TRUE; case KEY_SHIFTINS: case KEY_CTRLV: { TCHAR * bufP = FSF.PasteFromClipboard(); static TCHAR bufData[MAX_PATH]; if (bufP) { StringCchCopy(bufData,ARRAYSIZE(bufData),bufP); FSF.DeleteBuffer(bufP); unQuote(bufData); FSF.LStrlwr(bufData); for (int i = lstrlen(bufData); i >= 1; i--) for (int j = 0; j < nCount; j++) if (strnstri(p[j].Keys[DisplayName],bufData,i)) { lstrcpyn(Filter,bufData,i+1); Info.SendDlgMessage(hDlg,DMU_UPDATE,0,0); return TRUE; } } } return TRUE; case KEY_DEL: { if (lstrlen(Filter) > 0) { StringCchCopy(Filter,ARRAYSIZE(Filter),_T("")); Info.SendDlgMessage(hDlg,DMU_UPDATE,0,0); } } return TRUE; case KEY_F3: case KEY_F4: { if (ListSize) { DisplayEntry(static_cast<int>(Info.SendDlgMessage(hDlg,DM_LISTGETCURPOS,LIST_BOX,NULL))); Info.SendDlgMessage(hDlg,DM_REDRAW,NULL,NULL); } } return TRUE; case KEY_F2: { Opt.SortByDate = !Opt.SortByDate; Info.SendDlgMessage(hDlg,DMU_UPDATE,1,0); } return TRUE; case KEY_BS: { if (lstrlen(Filter)) { Filter[lstrlen(Filter)-1] = '\0'; Info.SendDlgMessage(hDlg,DMU_UPDATE,0,0); } } return TRUE; default: { if (Param2 >= KEY_SPACE && Param2 < KEY_FKEY_BEGIN) { struct FarListInfo ListInfo; Info.SendDlgMessage(hDlg,DM_LISTINFO,LIST_BOX,reinterpret_cast<LONG_PTR>(&ListInfo)); if ((lstrlen(Filter) < sizeof(Filter)) && ListInfo.ItemsNumber) { int filterL = lstrlen(Filter); Filter[filterL] = FSF.LLower(static_cast<unsigned>(Param2)); Filter[filterL+1] = '\0'; Info.SendDlgMessage(hDlg,DMU_UPDATE,0,0); return TRUE; } } } } return FALSE; case DN_CTLCOLORDIALOG: return Info.AdvControl(Info.ModuleNumber,ACTL_GETCOLOR,(void *)COL_MENUTEXT); case DN_CTLCOLORDLGLIST: if (Param1 == LIST_BOX) { FarListColors *Colors = (FarListColors *)Param2; int ColorIndex[] = { COL_MENUBOX, COL_MENUBOX, COL_MENUTITLE, COL_MENUTEXT, COL_MENUHIGHLIGHT, COL_MENUBOX, COL_MENUSELECTEDTEXT, COL_MENUSELECTEDHIGHLIGHT, COL_MENUSCROLLBAR, COL_MENUDISABLEDTEXT, COL_MENUARROWS, COL_MENUARROWSSELECTED, COL_MENUARROWSDISABLED }; int Count = ARRAYSIZE(ColorIndex); if (Count > Colors->ColorCount) Count = Colors->ColorCount; for (int i = 0; i < Count; i++) Colors->Colors[i] = static_cast<BYTE>(Info.AdvControl(Info.ModuleNumber, ACTL_GETCOLOR, reinterpret_cast<void *>(ColorIndex[i]))); return TRUE; } break; } return Info.DefDlgProc(hDlg,Msg,Param1,Param2); }
void FCEU_PutImage(void) { if(dosnapsave==2) //Save screenshot as, currently only flagged & run by the Win32 build. //TODO SDL: implement this? { char nameo[512]; strcpy(nameo,FCEUI_GetSnapshotAsName().c_str()); if (nameo[0]) { SaveSnapshot(nameo); FCEU_DispMessage("Snapshot Saved.",0); } dosnapsave=0; } if(GameInfo->type==GIT_NSF) { DrawNSF(XBuf); //Save snapshot after NSF screen is drawn. Why would we want to do it before? if(dosnapsave==1) { ReallySnap(); dosnapsave=0; } } else { //Save backbuffer before overlay stuff is written. if(!FCEUI_EmulationPaused()) memcpy(XBackBuf, XBuf, 256*256); //Some messages need to be displayed before the avi is dumped DrawMessage(true); #ifdef _S9XLUA_H // Lua gui should draw before the avi is dumped. FCEU_LuaGui(XBuf); #endif //Save snapshot if(dosnapsave==1) { ReallySnap(); dosnapsave=0; } if (!FCEUI_AviEnableHUDrecording()) snapAVI(); if(GameInfo->type==GIT_VSUNI) FCEU_VSUniDraw(XBuf); FCEU_DrawSaveStates(XBuf); FCEU_DrawMovies(XBuf); FCEU_DrawLagCounter(XBuf); FCEU_DrawNTSCControlBars(XBuf); FCEU_DrawRecordingStatus(XBuf); ShowFPS(); } if(FCEUD_ShouldDrawInputAids()) FCEU_DrawInput(XBuf); //Fancy input display code if(input_display) { extern uint32 JSAutoHeld; uint32 held; int controller, c, ci, color; int i, j; uint32 on = FCEUMOV_Mode(MOVIEMODE_PLAY) ? 0x90:0xA7; //Standard, or Gray depending on movie mode uint32 oni = 0xA0; //Color for immediate keyboard buttons uint32 blend = 0xB6; //Blend of immiate and last held buttons uint32 ahold = 0x87; //Auto hold uint32 off = 0xCF; uint8 *t = XBuf+(FSettings.LastSLine-9)*256 + 20; //mbg merge 7/17/06 changed t to uint8* if(input_display > 4) input_display = 4; for(controller = 0; controller < input_display; controller++, t += 56) { for(i = 0; i < 34;i++) for(j = 0; j <9 ; j++) t[i+j*256] = (t[i+j*256] & 0x30) | 0xC1; for(i = 3; i < 6; i++) for(j = 3; j< 6; j++) t[i+j*256] = 0xCF; c = cur_input_display >> (controller * 8); // This doesn't work in anything except windows for now. // It doesn't get set anywhere in other ports. #if defined(WIN32) && !defined(DINGUX) if (!oldInputDisplay) ci = FCEUMOV_Mode(MOVIEMODE_PLAY) ? 0:GetGamepadPressedImmediate() >> (controller * 8); else ci = 0; if (!oldInputDisplay && !FCEUMOV_Mode(MOVIEMODE_PLAY)) held = (JSAutoHeld >> (controller * 8)); else held = 0; #else // Put other port info here ci = 0; held = 0; #endif //adelikat: I apologize to anyone who ever sifts through this color assignment //A if (held&1) { //If auto-hold if (!(ci&1) ) color = ahold; else color = (c&1) ? on : off; //If the button is pressed down (immediate) that negates auto hold, however it is only off if the previous frame the button wasn't pressed! } else { if (c&1) color = (ci&1) ? blend : on; //If immedaite buttons are pressed and they match the previous frame, blend the colors else color = (ci&1) ? oni : off; } for(i=0; i < 4; i++) { for(j = 0; j < 4; j++) { if(i%3==0 && j %3 == 0) continue; t[30+4*256+i+j*256] = color; } } //B if (held&2) { //If auto-hold if (!(ci&2) ) color = ahold; else color = (c&2) ? on : off; //If the button is pressed down (immediate) that negates auto hold, however it is only off if the previous frame the button wasn't pressed! } else { if (c&2) color = (ci&2) ? blend : on; //If immedaite buttons are pressed and they match the previous frame, blend the colors else color = (ci&2) ? oni : off; } for(i=0; i < 4; i++) { for(j = 0; j < 4; j++) { if(i%3==0 && j %3 == 0) continue; t[24+4*256+i+j*256] = color; } } //Select if (held&4) { //If auto-hold if (!(ci&4) ) color = ahold; else color = (c&4) ? on : off; //If the button is pressed down (immediate) that negates auto hold, however it is only off if the previous frame the button wasn't pressed! } else { if (c&4) color = (ci&4) ? blend : on; //If immedaite buttons are pressed and they match the previous frame, blend the colors else color = (ci&4) ? oni : off; } for(i = 0; i < 4; i++) { t[11+5*256+i] = color; t[11+6*256+i] = color; } //Start if (held&8) { //If auto-hold if (!(ci&8) ) color = ahold; else color = (c&8) ? on : off; //If the button is pressed down (immediate) that negates auto hold, however it is only off if the previous frame the button wasn't pressed! } else { if (c&8) color = (ci&8) ? blend : on; //If immedaite buttons are pressed and they match the previous frame, blend the colors else color = (ci&8) ? oni : off; } for(i = 0; i < 4; i++) { t[17+5*256+i] = color; t[17+6*256+i] = color; } //Up if (held&16) { //If auto-hold if (!(ci&16) ) color = ahold; else color = (c&16) ? on : off; //If the button is pressed down (immediate) that negates auto hold, however it is only off if the previous frame the button wasn't pressed! } else { if (c&16) color = (ci&16) ? blend : on; //If immedaite buttons are pressed and they match the previous frame, blend the colors else color = (ci&16) ? oni : off; } for(i = 0; i < 3; i++) { for(j = 0; j < 3; j++) { t[3+i+256*j] = color; } } //Down if (held&32) { //If auto-hold if (!(ci&32) ) color = ahold; else color = (c&32) ? on : off; //If the button is pressed down (immediate) that negates auto hold, however it is only off if the previous frame the button wasn't pressed! } else { if (c&32) color = (ci&32) ? blend : on; //If immedaite buttons are pressed and they match the previous frame, blend the colors else color = (ci&32) ? oni : off; } for(i = 0; i < 3; i++) { for(j = 0; j < 3; j++) { t[3+i+256*j+6*256] = color; } } //Left if (held&64) { //If auto-hold if (!(ci&64) ) color = ahold; else color = (c&64) ? on : off; //If the button is pressed down (immediate) that negates auto hold, however it is only off if the previous frame the button wasn't pressed! } else { if (c&64) color = (ci&64) ? blend : on; //If immedaite buttons are pressed and they match the previous frame, blend the colors else color = (ci&64) ? oni : off; } for(i = 0; i < 3; i++) { for(j = 0; j < 3; j++) { t[3*256+i+256*j] = color; } } //Right if (held&128) { //If auto-hold if (!(ci&128) ) color = ahold; else color = (c&128) ? on : off; //If the button is pressed down (immediate) that negates auto hold, however it is only off if the previous frame the button wasn't pressed! } else { if (c&128) color = (ci&128) ? blend : on; //If immedaite buttons are pressed and they match the previous frame, blend the colors else color = (ci&128) ? oni : off; } for(i = 0; i < 3; i++) { for(j = 0; j < 3; j++) { t[6+3*256+i+256*j] = color; } } }
/* * <DESCRIPTION> * Calls DrawMessage(RenderWindow *window, float elapsedTime, Transform transformation) * with an empty Transform object. * * @PARAMS * window: pointer to the game window object * elapsedTime: float value representing the amount of seconds passed during * this iteration of the game loop. */ void GameMessage::DrawMessage(RenderWindow *window, float elapsedTime){ Transform trans; DrawMessage(window, elapsedTime, trans); }
static void GameLoop(struct BALL *const Ball, struct PADDLE *const Paddle) { /*Primary loop where most events get processed.*/ struct BRICKSTRIKE Strike; int Key = 0; int SecTick = 0; Bool PaddleMovedLastTick; DirectionX PaddleMoveDir; int Inc = 0; Bool Flip = false; int SlowBallTicks = 0, BallNukeTicks = 0; while ((Key = getch()) != 27) /*27 is ESC*/ { if (SecTick == 10) { /*We get score every second for just surviving.*/ Score += 2; DrawStats(); SecTick = 0; } ++SecTick; if (Ball->Y == 1) { /*We hit the ceiling.*/ BounceBallY(Ball, DOWN); } else if (Ball->Y >= BRICKTICK_MAX_Y - 2) { /*More happens when we hit the floor.*/ if (!CheckBallHitPaddle(Ball, Paddle)) { DeleteBall(Ball); Ball->Y = BRICKTICK_MAX_Y - 1; DrawBall(Ball); if (Lives == 1) { /*We ran out of lives.*/ ProcessGameOver(Ball, Paddle); } else { --Lives; DrawStats(); WaitForUserLaunch(); DeleteBall(Ball); DeletePaddle(Paddle); ResetBall(Ball); ResetPaddle(Paddle); DrawPaddle(Paddle); DrawBall(Ball); /*Redraw but don't reset.*/ DrawAllBricks(); } } else { BounceBallY(Ball, UP); if (PaddleMovedLastTick) { /*We can "whack" the ball with our Paddle->*/ Ball->DirX = PaddleMoveDir; } else { /*We cut the paddle into thirds for the X direction after bounce.*/ #define PADDLE_THIRD (Paddle->Length / 3) if (Ball->X <= Paddle->X + PADDLE_THIRD) { Ball->DirX = LEFT; } else if (Ball->X > Paddle->X + PADDLE_THIRD && Ball->X <= Paddle->X + (PADDLE_THIRD * 2)) { /*Make whether we hit up or not as a chance.*/ Bool StraightUp = rand() & 1; if (StraightUp) Ball->DirX = X_NEUTRAL; } else { Ball->DirX = RIGHT; } } } } PaddleMovedLastTick = false; /*Bounce off left and right walls.*/ if (Ball->X >= BRICKTICK_MAX_X - 1) { Ball->X = BRICKTICK_MAX_X - 1; BounceBallX(Ball, LEFT); } else if (Ball->X <= 0) { Ball->X = 0; BounceBallX(Ball, RIGHT); } /*Check if a charm hit the paddle.*/ for (Inc = 0; Inc < BRICK_MAX_NUMLINES * BRICK_MAX_PERLINE; ++Inc) { if (Charms[Inc].Type == CHARM_NONE || !Charms[Inc].Dropped || Charms[Inc].Y != BRICKTICK_MAX_Y - 2) continue; if (CheckCharmHitPaddle(Paddle, Charms + Inc)) { void *Ptr = NULL; const char *const Strings[] = { "+1,000 Score", "+1 Lives", "10 Second Slow Ball", "3 second nuke mode" }; switch (Charms[Inc].Type) { case CHARM_SCORE: Ptr = &Score; break; case CHARM_LIFE: Ptr = &Lives; break; case CHARM_SLOW: Ptr = &SlowBallTicks; break; case CHARM_NUKE: Ptr = &BallNukeTicks; break; default: break; } if (Charms[Inc].Type != CHARM_NONE) { /*Show a message on what type of charm we have here.*/ DrawMessage(Strings[Charms[Inc].Type - 1]); fflush(NULL); usleep(500000); DeleteMessage(); DrawAllBricks(); DrawStats(); } /*Do the thing the charm does.*/ ProcessCharmAction(Charms + Inc, Ptr); } /*In any case, we're done with it.*/ DeleteCharm(Charms + Inc); Charms[Inc].Type = CHARM_NONE; } /*We hit a brick.*/ if (BallStruckBrick(Ball, &Strike)) { if (BallNukeTicks == 0) /*Nuclear ball passes through.*/ { switch (Strike.StrikeV) { case STRIKE_TOP: Ball->DirY = UP; break; case STRIKE_BOTTOM: Ball->DirY = DOWN; break; default: break; } switch (Strike.StrikeH) { case STRIKE_LEFT: Ball->DirX = LEFT; break; case STRIKE_RIGHT: Ball->DirX = RIGHT; break; default: { if (Ball->DirX != X_NEUTRAL) break; else { Bool Dir = rand() & 1; Ball->DirX = (DirectionX)Dir; } break; } } } DeleteBrick(Strike.Brick); Score += 100; DrawStats(); if (!BricksLeft()) { /*Move to next level.*/ if (SetLevel(Level + 1)) { /*We have more levels to go before we win.*/ DeleteAllBricks(); DeleteAllCharms(); DeleteBall(Ball); DeletePaddle(Paddle); DrawStats(); Score += 1000; /*Reward for making it this far.*/ Lives = BRICKTICK_NUMLIVES; ResetBall(Ball); ResetPaddle(Paddle); ResetBricks(); DrawAllBricks(); DrawPaddle(Paddle); WaitForUserLaunch(); DrawBall(Ball); DrawAllBricks(); /*Redraw to fix WaitForUserLaunch() goofing.*/ } else { /*WE WON!!!!*/ char WonBuf[256]; snprintf(WonBuf, sizeof WonBuf, "You Won! Score is %d! Hit ESC to exit or space to play again.", Score); DrawMessage(WonBuf); WinRegetch: switch (getch()) { case 27: /*27 is ESC*/ endwin(); exit(0); break; case ' ': { DeleteMessage(); SetLevel(1); Lives = BRICKTICK_NUMLIVES; Score = 0; DeleteAllBricks(); DeleteAllCharms(); DeleteBall(Ball); DeletePaddle(Paddle); DrawStats(); ResetBall(Ball); ResetPaddle(Paddle); ResetBricks(); DrawAllBricks(); DrawPaddle(Paddle); WaitForUserLaunch(); DrawBall(Ball); DrawAllBricks(); /*Redraw to fix WaitForUserLaunch() goofing.*/ continue; /*For the loop we are in.*/ } default: goto WinRegetch; } } continue; } else { /*Charm drops.*/ struct CHARM *Charm = GetCharmByBrick(Strike.Brick); if (Charm) { /*We DO have a charm for this brick.*/ PerformCharmDrop(Charm); /*Mark it dropped.*/ /*Now draw the charm.*/ DrawCharm(Charm); } } } switch (Key) { /*Paddle movement.*/ case KEY_LEFT: MovePaddle(Paddle, LEFT); PaddleMovedLastTick = true; PaddleMoveDir = LEFT; break; case KEY_RIGHT: MovePaddle(Paddle, RIGHT); PaddleMovedLastTick = true; PaddleMoveDir = RIGHT; break; case 's': /*They want to save the game.*/ if (SaveGame(Ball, Paddle)) { DrawMessage("Game saved."); } else { DrawMessage("Failed to save game."); } fflush(NULL); usleep(500000); DeleteMessage(); DrawAllBricks(); /*Redraw bricks if damaged.*/ break; case 'o': /*They want us to load a game.*/ { const Bool LoadedOk = LoadGame(Ball, Paddle); if (LoadedOk) { /*Restore the state.*/ clear(); DrawBorders(); /*Need to redraw these after clearing the screen.*/ DrawBall(Ball); DrawPaddle(Paddle); DrawStats(); DrawAllBricks(); DrawMessage("Game loaded."); } else { DrawMessage("Failed to load game."); } fflush(NULL); usleep(500000); DeleteMessage(); DrawAllBricks(); break; } case ' ': { DrawMessage("PAUSED"); cbreak(); PauseRegetch: switch (getch()) { case ' ': DeleteMessage(); DrawAllBricks(); /*Redraw to fix what deleting the message messed up.*/ halfdelay(1); break; case 27: /*27 is ESC*/ endwin(); exit(0); break; default: goto PauseRegetch; } } default: break; } Flip = !Flip; /*Ball movement, obviously. Flip is used to keep it at half speed if we got a 'slow' charm.*/ if (Flip || SlowBallTicks == 0) MoveBall(Ball); /*Decrement slow ball ticks until zero, then the ball goes fast again.*/ if (SlowBallTicks > 0) --SlowBallTicks; /*Decrement nuclear ball until ticks hit zero.*/ if (BallNukeTicks > 0) --BallNukeTicks; /*Charm movement.*/ for (Inc = 0; Inc < BRICK_MAX_NUMLINES * BRICK_MAX_PERLINE; ++Inc) { if (Charms[Inc].Type == CHARM_NONE || !Charms[Inc].Dropped) continue; if (Flip) MoveCharm(Charms + Inc); } /*Redraw borders in case of terminal resize.*/ DrawBorders(); } }
int main(int argc, char **argv) { int Inc = 1; struct BALL Ball = { 0 }; struct PADDLE Paddle = { 0 }; Bool DoLoadGame = false; int GotoLevel = 0; for (; Inc < argc; ++Inc) { /*Argument parsing.*/ if (!strcmp("--nocolor", argv[Inc])) { UseColor = false; } else if (!strcmp("--version", argv[Inc])) { printf("Bricktick brick breaker v" BRICKTICK_VERSION "\n" "By Subsentient.\n"); fflush(NULL); exit(0); } else if (!strcmp("--help", argv[Inc])) { printf("Command line options:\n\t" "--help: Show this help.\n\t" "--nocolor: Run Bricktick with no color.\n\t" "--version: Display version and exit.\n"); fflush(NULL); exit(0); } else if (!strncmp("--level=", argv[Inc], sizeof "--level=" - 1)) { GotoLevel = atoi(argv[Inc] + sizeof "--level=" - 1); if (GotoLevel > sizeof Levels / sizeof *Levels) { fprintf(stderr, "The maximum level is %d.\n", sizeof Levels / sizeof *Levels); fflush(NULL); exit(1); } } else { fprintf(stderr, "Bad command line argument \"%s\".\n" "Use --help for command line options.\n", argv[Inc]); exit(1); } } initscr(); /*Fire up ncurses.*/ if (COLS < BRICKTICK_MAX_X || LINES < BRICKTICK_MAX_Y) { endwin(); fprintf(stderr, "Please use a console with a resolution of at least %dx%d.\n", BRICKTICK_MAX_X, BRICKTICK_MAX_Y); exit(1); } /*Color not supported.*/ if (!has_colors()) UseColor = false; /*Various ncurses things.*/ noecho(); if (UseColor) { /*Color fireup.*/ start_color(); init_pair(1, COLOR_CYAN, COLOR_BLACK); init_pair(2, COLOR_GREEN, COLOR_BLACK); init_pair(3, COLOR_BLACK, COLOR_WHITE); init_pair(4, COLOR_BLUE, COLOR_BLACK); init_pair(5, COLOR_GREEN, COLOR_BLACK); init_pair(6, COLOR_YELLOW, COLOR_BLACK); init_pair(7, COLOR_RED, COLOR_BLACK); /*Fire up colors for the bricks.*/ init_pair(BRICK_COLORS_START, COLOR_GREEN, COLOR_BLACK); init_pair(BRICK_COLORS_START + 1, COLOR_BLUE, COLOR_BLACK); init_pair(BRICK_COLORS_START + 2, COLOR_YELLOW, COLOR_BLACK); init_pair(BRICK_COLORS_START + 3, COLOR_MAGENTA, COLOR_BLACK); init_pair(BRICK_COLORS_START + 4, COLOR_CYAN, COLOR_BLACK); init_pair(BRICK_COLORS_END, COLOR_RED, COLOR_BLACK); } /*Draw borders for consoles bigger than our 80x24 playing area.*/ DrawBorders(); /*Greeting.*/ GreetAsk: if (!GotoLevel) { /*If they specified a level let them go straigth to game start.*/ DrawGreeting(); switch (getch()) { case 27: /*27 is ESC key*/ endwin(); exit(0); break; case ' ': clear(); /*Wipe the message from the screen.*/ DrawBorders(); /*Redraw borders.*/ break; case 'o': clear(); DrawBorders(); DoLoadGame = true; LoadGame(&Ball, &Paddle); break; default: goto GreetAsk; } } else { clear(); DrawBorders(); } halfdelay(1); keypad(stdscr, true); #if NCURSES_VERSION_MAJOR >= 5 && NCURSES_VERSION_MINOR >=4 set_escdelay(25); #endif curs_set(0); if (DoLoadGame) { DrawStats(); DrawBall(&Ball); DrawPaddle(&Paddle); DrawAllBricks(); } else { /*Show our initial lives count.*/ DrawStats(); /*Reset to level 1 if we haven't specified a level.*/ SetLevel(GotoLevel ? GotoLevel : 1); ResetBall(&Ball); ResetPaddle(&Paddle); DrawBall(&Ball); DrawPaddle(&Paddle); ResetBricks(); DrawAllBricks(); } /*Wait for L key.*/ WaitForUserLaunch(); DrawAllBricks(); /*Redraw to fix goofing by WaitForUserLaunch().*/ /*Set up the number generator.*/ srand(time(NULL)); /** * Main loop for the game! **/ Reloop: GameLoop(&Ball, &Paddle); DrawMessage("Really quit Bricktick? y/n"); cbreak(); /*When the game loop exits.*/ switch (getch()) { case 'y': case 'Y': break; default: DeleteMessage(); refresh(); halfdelay(1); DrawAllBricks(); /*Fix damage to brick display resulting from the message.*/ goto Reloop; break; } DeleteBall(&Ball); DeletePaddle(&Paddle); endwin(); return 0; }
void VendorEncounter::SellingItemsLoop() { string Message = "How can I help you, " + player.GetName() + "?"; unsigned i=0; for(int y=0; y<13; ++y) { for(int x=0; x<4; ++x) { if(i<player.GetItems().size()) { ItemGrid[y][x] = i; } else { ItemGrid[y][x] = -1; } ++i; } } int IterX = 0, IterY = 0; ArrowX = 0; ArrowY = 70; ArrowSprite.setPosition(ArrowX, ArrowY); while(Window.isOpen()) { while(Window.pollEvent(Event)) { if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Up)) { if(IterY != 0) { --IterY; ArrowY -= 32; ArrowSprite.setPosition(ArrowX, ArrowY); } } else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Down)) { if(IterY != 12) { ++IterY; ArrowY += 32; ArrowSprite.setPosition(ArrowX, ArrowY); } } else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Right)) { if(IterX != 3) { ++IterX; ArrowX += 81; ArrowSprite.setPosition(ArrowX, ArrowY); } } else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Left)) { if(IterX != 0) { --IterX; ArrowX -= 81; ArrowSprite.setPosition(ArrowX, ArrowY); } } else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Return)) { switch(player.GetItems()[ItemGrid[IterY][IterX]].Type) { case ITEM_QUEST: Message = "I don't want that item."; break; default: player.SetWealth(player.GetWealth() + player.GetItems()[ItemGrid[IterY][IterX]].SellPrice); player.RemoveItem(ItemGrid[IterY][IterX]); MoneyText.setString(IntToString(player.GetWealth())); break; } } else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Escape)) { return; } } Window.clear(); Window.draw(GUISprite); Window.draw(ArrowSprite); Window.draw(sf::Sprite(ScreenTexture)); DrawItems(); DrawMessage(Message); Window.draw(MoneySprite); Window.draw(MoneyText); if(ItemGrid[IterY][IterX] != -1) { ItemSprite.setTexture(player.GetItems()[ItemGrid[IterY][IterX]].ItemTexture); switch(player.GetItems()[ItemGrid[IterY][IterX]].Type) //PH { case ITEM_FOOD: ItemName.setString (player.GetItems()[ItemGrid[IterY][IterX]].Name + '\n' + "Regenrates " + IntToString(player.GetItems()[ItemGrid[IterY][IterX]].Value) + " health." + '\n' + "Cannot be used in combat" + '\n' + "Buy Price: " + IntToString(player.GetItems()[ItemGrid[IterY][IterX]].BuyPrice) + '\n' + "Sell Price: " + IntToString(player.GetItems()[ItemGrid[IterY][IterX]].SellPrice)); break; case ITEM_POWER_POTION: ItemName.setString (player.GetItems()[ItemGrid[IterY][IterX]].Name + '\n' + "Regenrates " + IntToString(player.GetItems()[ItemGrid[IterY][IterX]].Value) + " power." + '\n' + "Can be used in combat" + '\n' + "Buy Price: " + IntToString(player.GetItems()[ItemGrid[IterY][IterX]].BuyPrice) + '\n' + "Sell Price: " + IntToString(player.GetItems()[ItemGrid[IterY][IterX]].SellPrice)); break; case ITEM_HEALTH_POTION: ItemName.setString (player.GetItems()[ItemGrid[IterY][IterX]].Name + '\n' + "Regenrates " + IntToString(player.GetItems()[ItemGrid[IterY][IterX]].Value) + " health." + '\n' + "Can be used in combat" + '\n' + "Buy Price: " + IntToString(player.GetItems()[ItemGrid[IterY][IterX]].BuyPrice) + '\n' + "Sell Price: " + IntToString(player.GetItems()[ItemGrid[IterY][IterX]].SellPrice)); break; } Window.draw(ItemName); Window.draw(ItemSprite); } Window.display(); } }
void VendorEncounter::MainLoop() { Font.loadFromFile("Graphics/papyrus.ttf"); BuyItem.setString("Buy Item"); SellItem.setString("Sell Item"); YourItems.setString("Your items: "); VendorItems.setString("Vendors items: "); Return.setString("Back to Game"); DrawTexture(); MoneyText.setString(IntToString(player.GetWealth())); MoneyText.setStyle(sf::Text::Bold); MoneyText.setColor(sf::Color::Black); MoneyText.setPosition(410.0f, 20.0f); sf::Texture ArrowTexture, GUITexture, MoneyTexture; MoneyTexture.loadFromFile("Items/Money.png"); MoneyText.setFont(Font); MoneySprite.setTexture(MoneyTexture); MoneySprite.setPosition(380.0f, 20.0f); ArrowTexture.loadFromFile("Graphics/Arrow2.png"); GUITexture.loadFromFile("Graphics/VendorScreen.png"); ArrowSprite.setTexture(ArrowTexture); ArrowSprite.setPosition(ArrowX, ArrowY); GUISprite.setTexture(GUITexture); int Command = 0; while(Window.isOpen()) { while(Window.pollEvent(Event)) { if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Up)) { if(Command != 0) { --Command; ArrowY -= 35; ArrowSprite.setPosition(ArrowX, ArrowY); } } else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Down)) { if(Command != 2) { ++Command; ArrowY += 35; ArrowSprite.setPosition(ArrowX, ArrowY); } } else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Return)) { switch(Command) { case 0: BuyingItemsLoop(); break; case 1: SellingItemsLoop(); break; case 2: return; } Command = 0; ArrowX = 405.0f; ArrowY = 370.0f; ArrowSprite.setPosition(ArrowX, ArrowY); } } Window.clear(); Window.draw(GUISprite); DrawItems(); Window.draw(sf::Sprite(ScreenTexture)); Window.draw(ArrowSprite); DrawMessage("How can I help you, " + player.GetName() + "?"); Window.draw(MoneySprite); Window.draw(MoneyText); Window.display(); } }
void VendorEncounter::BuyingItemsLoop() { string Message = "How can I help you, " + player.GetName() + "?"; unsigned i=0; for(int y=0; y<13; ++y) { for(int x=0; x<4; ++x) { if(i < vendor.Items.size()) { ItemGrid[y][x] = i; } else { ItemGrid[y][x] = -1; } ++i; } } int IterX = 0, IterY = 0; ArrowX = 636; ArrowY = 70; ArrowSprite.setPosition(ArrowX, ArrowY); while(Window.isOpen()) { while(Window.pollEvent(Event)) { if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Up)) { if(IterY != 0) { --IterY; ArrowY -= 32; ArrowSprite.setPosition(ArrowX, ArrowY); } } else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Down)) { if(IterY != 12) { ++IterY; ArrowY += 32; ArrowSprite.setPosition(ArrowX, ArrowY); } } else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Right)) { if(IterX != 3) { ++IterX; ArrowX += 81; ArrowSprite.setPosition(ArrowX, ArrowY); } } else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Left)) { if(IterX != 0) { --IterX; ArrowX -= 81; ArrowSprite.setPosition(ArrowX, ArrowY); } } else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Return)) { if(player.GetWealth() < vendor.Items[ItemGrid[IterY][IterX]].BuyPrice) { Message = "You cannot afford that item!"; continue; } if(player.GetItems().size() == MAX_ITEMS) { Message = "You cannot carry any more items"; continue; } player.SetWealth(player.GetWealth() - vendor.Items[ItemGrid[IterY][IterX]].BuyPrice); player.AddItem(vendor.Items[ItemGrid[IterY][IterX]]); Message = "It's been pleasure trading with you, " + player.GetName(); MoneyText.setString(IntToString(player.GetWealth())); } else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Escape)) { return; } } Window.clear(); Window.draw(GUISprite); Window.draw(ArrowSprite); Window.draw(sf::Sprite(ScreenTexture)); DrawMessage(Message); DrawItems(); Window.draw(MoneySprite); Window.draw(MoneyText); if(ItemGrid[IterY][IterX] != -1) { ItemSprite.setTexture(vendor.Items[ItemGrid[IterY][IterX]].ItemTexture); switch(vendor.Items[ItemGrid[IterY][IterX]].Type) //PH { case ITEM_FOOD: ItemName.setString (vendor.Items[ItemGrid[IterY][IterX]].Name + '\n' + "Regenrates " + IntToString(vendor.Items[ItemGrid[IterY][IterX]].Value) + " health." + '\n' + "Cannot be used in combat" + '\n' + "Buy Price: " + IntToString(vendor.Items[ItemGrid[IterY][IterX]].BuyPrice) + '\n' + "Sell Price: " + IntToString(vendor.Items[ItemGrid[IterY][IterX]].SellPrice)); break; case ITEM_MANA_FOOD: ItemName.setString (vendor.Items[ItemGrid[IterY][IterX]].Name + '\n' + "Regenrates " + IntToString(vendor.Items[ItemGrid[IterY][IterX]].Value) + " power." + '\n' + "Cannot be used in combat" + '\n' + "Buy Price: " + IntToString(vendor.Items[ItemGrid[IterY][IterX]].BuyPrice) + '\n' + "Sell Price: " + IntToString(vendor.Items[ItemGrid[IterY][IterX]].SellPrice)); break; case ITEM_POWER_POTION: ItemName.setString (vendor.Items[ItemGrid[IterY][IterX]].Name + '\n' + "Regenrates " + IntToString(vendor.Items[ItemGrid[IterY][IterX]].Value) + " power." + '\n' + "Can be used in combat" + '\n' + "Buy Price: " + IntToString(vendor.Items[ItemGrid[IterY][IterX]].BuyPrice) + '\n' + "Sell Price: " + IntToString(vendor.Items[ItemGrid[IterY][IterX]].SellPrice)); break; case ITEM_HEALTH_POTION: ItemName.setString (vendor.Items[ItemGrid[IterY][IterX]].Name + '\n' + "Regenrates " + IntToString(vendor.Items[ItemGrid[IterY][IterX]].Value) + " health." + '\n' + "Can be used in combat" + '\n' + "Buy Price: " + IntToString(vendor.Items[ItemGrid[IterY][IterX]].BuyPrice) + '\n' + "Sell Price: " + IntToString(vendor.Items[ItemGrid[IterY][IterX]].SellPrice)); break; } Window.draw(ItemSprite); Window.draw(ItemName); } Window.display(); } }
void APlatformerHUD::DrawHUD() { if ( GEngine && GEngine->GameViewport ) { FVector2D ViewportSize; GEngine->GameViewport->GetViewportSize(ViewportSize); UIScale = ViewportSize.X / 2048.0f; } Super::DrawHUD(); APlatformerGameMode* MyGame = GetWorld()->GetAuthGameMode<APlatformerGameMode>(); if (MyGame) { // active messages DrawActiveMessages(); // round timer EGameState::Type GameState = MyGame->GetGameState(); if (GameState == EGameState::Playing) { DisplayRoundTimer(); DisplayRoundTimeModification(); } //When game is finished, draw the summary screen when picture is shown from Blueprints if (GameState == EGameState::Finished && MyGame->PlatformerPicture && MyGame->PlatformerPicture->IsVisible()) { const float SizeX = Canvas->ClipX * 0.75f; const float SizeY = Canvas->ClipY * 0.7f; const float DrawX = (Canvas->ClipX - SizeX) / 2.0f; const float DrawY = (Canvas->ClipY - SizeY) / 2.0f; DrawBorder(DrawX, DrawY, SizeX, SizeY, 1.0f, MyGame->IsRoundWon() ? BlueBorder : RedBorder); MyGame->PlatformerPicture->Tick(Canvas); if (EndingMessages.Num() > 0) { //First message with total time const float EndingMessagesScale = 1.6f; const float TextMargin = 0.03f; float StrSizeX, StrSizeY; Canvas->StrLen(HUDFont, EndingMessages[0].Message, StrSizeX, StrSizeY); StrSizeX = StrSizeX * EndingMessagesScale * UIScale; StrSizeY = StrSizeY * EndingMessagesScale * UIScale; FCanvasTextItem TextItem( FVector2D( (Canvas->ClipX - StrSizeX) / 2.0f, DrawY + SizeY * TextMargin ), FText::FromString( EndingMessages[0].Message ), HUDFont, FLinearColor::White ); TextItem.Scale = FVector2D( EndingMessagesScale * UIScale, EndingMessagesScale * UIScale ); TextItem.EnableShadow( FLinearColor::Transparent ); Canvas->DrawItem( TextItem ); //2nd message will only be shown after making at least 2 runs //displays time difference + NEW RECORD! or TRY AGAIN if (EndingMessages.Num() > 1) { Canvas->StrLen(HUDFont, EndingMessages[1].Message, StrSizeX, StrSizeY); StrSizeX = StrSizeX * EndingMessagesScale * UIScale; StrSizeY = StrSizeY * EndingMessagesScale * UIScale; TextItem.Position = FVector2D( (Canvas->ClipX - StrSizeX) / 2.0f , DrawY + SizeY * (1.0f-TextMargin) - StrSizeY ); TextItem.Text = FText::FromString( EndingMessages[1].Message ); Canvas->DrawItem( TextItem ); } } } // game state related messages, make it pulse 1 Hz if (GameState == EGameState::Waiting || MyGame->CanBeRestarted()) { const int32 GameTime = FMath::TruncToInt(1.0f * GetWorld()->GetTimeSeconds()); const bool bShowInputMessage = (GameTime % 2) == 0; if (bShowInputMessage) { FString InputMessage = TEXT("Jump or Slide"); switch (GameState) { case EGameState::Waiting: InputMessage += TEXT(" to start running"); break; case EGameState::Finished: InputMessage += TEXT(" to play again"); break; } DrawMessage(InputMessage, 0.5f, 0.9f, 1.0f, FLinearColor::White); } } if (GameState == EGameState::Finished) { if (bEnterNamePromptActive) { DrawHighscoreEntryPrompt(); } if (bHighscoreActive) { DrawHighscore(); } } } }
static void DrawAndBlit(void) { // Change the view size if needed if (setsizeneeded) { R_ExecuteSetViewSize(); } // Do buffered drawing switch (gamestate) { case GS_LEVEL: if (!gametic) { break; } if (automapactive) { AM_Drawer(); } else { R_RenderPlayerView(&players[displayplayer]); } CT_Drawer(); UpdateState |= I_FULLVIEW; SB_Drawer(); break; case GS_INTERMISSION: IN_Drawer(); break; case GS_FINALE: F_Drawer(); break; case GS_DEMOSCREEN: PageDrawer(); break; } if (testcontrols) { V_DrawMouseSpeedBox(testcontrols_mousespeed); } if (paused && !MenuActive && !askforquit) { if (!netgame) { V_DrawPatch(160, viewwindowy + 5, W_CacheLumpName("PAUSED", PU_CACHE)); } else { V_DrawPatch(160, 70, W_CacheLumpName("PAUSED", PU_CACHE)); } } // Draw current message DrawMessage(); // Draw Menu MN_Drawer(); // Send out any new accumulation NetUpdate(); // Flush buffered stuff to screen I_FinishUpdate(); }