/* Returns a 0 if successful and a 1 if unsuccessful */ int Create_Logical_Drive_Interface() { long input=0; int drive_created=FALSE; int maximum_possible_percentage; int numeric_type; long maximum_partition_size_in_MB; Partition_Table *pDrive = &part_table[flags.drive_number-0x80]; Determine_Free_Space(); if(pDrive->ext_part_largest_free_space>=2) { do { if(flags.fprmt==TRUE) flags.fat32=TRUE; maximum_partition_size_in_MB = Max_Log_Part_Size_In_MB(); Clear_Screen(0); if(drive_created==TRUE) { cprintAt(4,22,"Logical DOS Drive created, drive letters changed or added"); } Print_Centered(1,"Create Logical DOS Drive in the Extended DOS Partition",BOLD); Display_Extended_Partition_Information_SS(); if('Z'==Determine_Drive_Letters()) { printAt(4,22," "); cprintAt(4,22,"Maximum number of Logical DOS Drives installed."); Input(0,0,0,ESC,0,0,ESCC,0,0,NULL,NULL); if(flags.fprmt==TRUE) flags.fat32=FALSE; return(1); } printAt(4,17,"Total Extended DOS Partition size is "); if( (flags.version==4) || (flags.version==5) || (flags.version==6) ) cprintf("%4d",pDrive->ext_part_size_in_MB); else Print_UL_B(pDrive->ext_part_size_in_MB); printf(" Mbytes (1 Mbyte = 1048576 bytes)"); printAt(4,18,"Maximum space available for partition is "); if( (flags.version==4) || (flags.version==5) || (flags.version==6) ) cprintf("%4d",maximum_partition_size_in_MB); else Print_UL_B(maximum_partition_size_in_MB); printf(" Mbytes "); maximum_possible_percentage = Convert_To_Percentage(maximum_partition_size_in_MB ,pDrive->ext_part_size_in_MB); cprintf("(%3d%%)",maximum_possible_percentage); printAt(4,20,"Enter logical drive size in Mbytes or percent of disk space (%)..."); flags.esc=FALSE; if( (flags.version==4) || (flags.version==5) || (flags.version==6) ) input=Input(4,70,20,NUMP,1,maximum_partition_size_in_MB,ESCR ,maximum_partition_size_in_MB,maximum_possible_percentage,NULL,NULL); else input=Input(6,70,20,NUMP,1,maximum_partition_size_in_MB,ESCR ,maximum_partition_size_in_MB,maximum_possible_percentage,NULL,NULL); if(flags.esc==TRUE) { if(flags.fprmt==TRUE) flags.fat32=FALSE; return(1); } if( (flags.fprmt==TRUE) && (input>=128) && (input<=2048) ) { printAt(4,21,"This drive is a FAT32 by default, switch to FAT16 (Y/N)? "); flags.fat32=!Input(1,61,21,YN,0,0,NONE,1,0,NULL,NULL); } numeric_type=6; numeric_type=Partition_Type_To_Create(input,numeric_type); Create_Logical_Drive(numeric_type,input); drive_created=TRUE; }while(pDrive->ext_part_largest_free_space>=2); } Clear_Screen(0); Print_Centered(1,"Create Logical DOS Drive in the Extended DOS Partition",BOLD); Display_Extended_Partition_Information_SS(); cprintAt(4,22,"All available space in the Extended DOS Partition"); cprintAt(4,23,"is assigned to logical drives."); Input(0,0,0,ESC,0,0,ESCC,0,0,NULL,NULL); if(flags.fprmt==TRUE) flags.fat32=FALSE; return(0); }
void CMenus::UiDoListboxStart(const void *pID, const CUIRect *pRect, float RowHeight, const char *pTitle, const char *pBottomText, int NumItems, int ItemsPerRow, int SelectedIndex, float ScrollValue) { CUIRect Scroll, Row; CUIRect View = *pRect; CUIRect Header, Footer; // draw header View.HSplitTop(ms_ListheaderHeight, &Header, &View); RenderTools()->DrawUIRect(&Header, vec4(1,1,1,0.25f), CUI::CORNER_T, 5.0f); UI()->DoLabel(&Header, pTitle, Header.h*ms_FontmodHeight, 0); // draw footers View.HSplitBottom(ms_ListheaderHeight, &View, &Footer); RenderTools()->DrawUIRect(&Footer, vec4(1,1,1,0.25f), CUI::CORNER_B, 5.0f); Footer.VSplitLeft(10.0f, 0, &Footer); UI()->DoLabel(&Footer, pBottomText, Header.h*ms_FontmodHeight, 0); // background RenderTools()->DrawUIRect(&View, vec4(0,0,0,0.15f), 0, 0); // prepare the scroll #if defined(__ANDROID__) View.VSplitRight(50, &View, &Scroll); #else View.VSplitRight(15, &View, &Scroll); #endif // setup the variables gs_ListBoxOriginalView = View; gs_ListBoxSelectedIndex = SelectedIndex; gs_ListBoxNewSelected = SelectedIndex; gs_ListBoxItemIndex = 0; gs_ListBoxRowHeight = RowHeight; gs_ListBoxNumItems = NumItems; gs_ListBoxItemsPerRow = ItemsPerRow; gs_ListBoxDoneEvents = 0; gs_ListBoxScrollValue = ScrollValue; gs_ListBoxItemActivated = false; // do the scrollbar View.HSplitTop(gs_ListBoxRowHeight, &Row, 0); int NumViewable = (int)(gs_ListBoxOriginalView.h/Row.h) + 1; int Num = (NumItems+gs_ListBoxItemsPerRow-1)/gs_ListBoxItemsPerRow-NumViewable+1; if(Num < 0) Num = 0; if(Num > 0) { if(Input()->KeyPresses(KEY_MOUSE_WHEEL_UP) && UI()->MouseInside(&View)) gs_ListBoxScrollValue -= 3.0f/Num; if(Input()->KeyPresses(KEY_MOUSE_WHEEL_DOWN) && UI()->MouseInside(&View)) gs_ListBoxScrollValue += 3.0f/Num; if(gs_ListBoxScrollValue < 0.0f) gs_ListBoxScrollValue = 0.0f; if(gs_ListBoxScrollValue > 1.0f) gs_ListBoxScrollValue = 1.0f; } Scroll.HMargin(5.0f, &Scroll); gs_ListBoxScrollValue = DoScrollbarV(pID, &Scroll, gs_ListBoxScrollValue); // the list gs_ListBoxView = gs_ListBoxOriginalView; gs_ListBoxView.VMargin(5.0f, &gs_ListBoxView); UI()->ClipEnable(&gs_ListBoxView); gs_ListBoxView.y -= gs_ListBoxScrollValue*Num*Row.h; }
void CMenus::RenderDemoList(CUIRect MainView) { static int s_Inited = 0; if(!s_Inited) { DemolistPopulate(); DemolistOnUpdate(true); s_Inited = 1; } char aFooterLabel[128] = {0}; if(m_DemolistSelectedIndex >= 0) { CDemoItem *Item = &m_lDemos[m_DemolistSelectedIndex]; if(str_comp(Item->m_aFilename, "..") == 0) str_copy(aFooterLabel, Localize("Parent Folder"), sizeof(aFooterLabel)); else if(m_DemolistSelectedIsDir) str_copy(aFooterLabel, Localize("Folder"), sizeof(aFooterLabel)); else { if(!Item->m_InfosLoaded) { char aBuffer[512]; str_format(aBuffer, sizeof(aBuffer), "%s/%s", m_aCurrentDemoFolder, Item->m_aFilename); Item->m_Valid = DemoPlayer()->GetDemoInfo(Storage(), aBuffer, Item->m_StorageType, &Item->m_Info); Item->m_InfosLoaded = true; } if(!Item->m_Valid) str_copy(aFooterLabel, Localize("Invalid Demo"), sizeof(aFooterLabel)); else str_copy(aFooterLabel, Localize("Demo details"), sizeof(aFooterLabel)); } } // render background RenderTools()->DrawUIRect(&MainView, ms_ColorTabbarActive, CUI::CORNER_ALL, 10.0f); MainView.Margin(10.0f, &MainView); CUIRect ButtonBar, RefreshRect, PlayRect, DeleteRect, RenameRect, ListBox; MainView.HSplitBottom(ms_ButtonHeight+5.0f, &MainView, &ButtonBar); ButtonBar.HSplitTop(5.0f, 0, &ButtonBar); ButtonBar.VSplitRight(130.0f, &ButtonBar, &PlayRect); ButtonBar.VSplitLeft(130.0f, &RefreshRect, &ButtonBar); ButtonBar.VSplitLeft(10.0f, 0, &ButtonBar); ButtonBar.VSplitLeft(120.0f, &DeleteRect, &ButtonBar); ButtonBar.VSplitLeft(10.0f, 0, &ButtonBar); ButtonBar.VSplitLeft(120.0f, &RenameRect, &ButtonBar); MainView.HSplitBottom(140.0f, &ListBox, &MainView); // render demo info MainView.VMargin(5.0f, &MainView); MainView.HSplitBottom(5.0f, &MainView, 0); RenderTools()->DrawUIRect(&MainView, vec4(0,0,0,0.15f), CUI::CORNER_B, 4.0f); if(!m_DemolistSelectedIsDir && m_DemolistSelectedIndex >= 0 && m_lDemos[m_DemolistSelectedIndex].m_Valid) { CUIRect Left, Right, Labels; MainView.Margin(20.0f, &MainView); MainView.VSplitMid(&Labels, &MainView); // left side Labels.HSplitTop(20.0f, &Left, &Labels); Left.VSplitLeft(150.0f, &Left, &Right); UI()->DoLabelScaled(&Left, Localize("Created:"), 14.0f, -1); char aTimestamp[256]; str_timestamp_ex(m_lDemos[m_DemolistSelectedIndex].m_Date, aTimestamp, sizeof(aTimestamp), "%Y-%m-%d %H:%M:%S"); UI()->DoLabelScaled(&Right, aTimestamp, 14.0f, -1); Labels.HSplitTop(5.0f, 0, &Labels); Labels.HSplitTop(20.0f, &Left, &Labels); Left.VSplitLeft(150.0f, &Left, &Right); UI()->DoLabelScaled(&Left, Localize("Type:"), 14.0f, -1); UI()->DoLabelScaled(&Right, m_lDemos[m_DemolistSelectedIndex].m_Info.m_aType, 14.0f, -1); Labels.HSplitTop(5.0f, 0, &Labels); Labels.HSplitTop(20.0f, &Left, &Labels); Left.VSplitLeft(150.0f, &Left, &Right); UI()->DoLabelScaled(&Left, Localize("Length:"), 14.0f, -1); int Length = ((m_lDemos[m_DemolistSelectedIndex].m_Info.m_aLength[0]<<24)&0xFF000000) | ((m_lDemos[m_DemolistSelectedIndex].m_Info.m_aLength[1]<<16)&0xFF0000) | ((m_lDemos[m_DemolistSelectedIndex].m_Info.m_aLength[2]<<8)&0xFF00) | (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aLength[3]&0xFF); char aBuf[64]; str_format(aBuf, sizeof(aBuf), "%d:%02d", Length/60, Length%60); UI()->DoLabelScaled(&Right, aBuf, 14.0f, -1); Labels.HSplitTop(5.0f, 0, &Labels); Labels.HSplitTop(20.0f, &Left, &Labels); Left.VSplitLeft(150.0f, &Left, &Right); UI()->DoLabelScaled(&Left, Localize("Version:"), 14.0f, -1); str_format(aBuf, sizeof(aBuf), "%d", m_lDemos[m_DemolistSelectedIndex].m_Info.m_Version); UI()->DoLabelScaled(&Right, aBuf, 14.0f, -1); // right side Labels = MainView; Labels.HSplitTop(20.0f, &Left, &Labels); Left.VSplitLeft(150.0f, &Left, &Right); UI()->DoLabelScaled(&Left, Localize("Map:"), 14.0f, -1); UI()->DoLabelScaled(&Right, m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapName, 14.0f, -1); Labels.HSplitTop(5.0f, 0, &Labels); Labels.HSplitTop(20.0f, &Left, &Labels); Left.VSplitLeft(20.0f, 0, &Left); Left.VSplitLeft(130.0f, &Left, &Right); UI()->DoLabelScaled(&Left, Localize("Size:"), 14.0f, -1); unsigned Size = (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapSize[0]<<24) | (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapSize[1]<<16) | (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapSize[2]<<8) | (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapSize[3]); if(Size > 1024*1024) str_format(aBuf, sizeof(aBuf), Localize("%.2f MiB"), float(Size)/(1024*1024)); else str_format(aBuf, sizeof(aBuf), Localize("%.2f KiB"), float(Size)/1024); UI()->DoLabelScaled(&Right, aBuf, 14.0f, -1); Labels.HSplitTop(5.0f, 0, &Labels); Labels.HSplitTop(20.0f, &Left, &Labels); Left.VSplitLeft(20.0f, 0, &Left); Left.VSplitLeft(130.0f, &Left, &Right); UI()->DoLabelScaled(&Left, Localize("Crc:"), 14.0f, -1); unsigned Crc = (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapCrc[0]<<24) | (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapCrc[1]<<16) | (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapCrc[2]<<8) | (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapCrc[3]); str_format(aBuf, sizeof(aBuf), "%08x", Crc); UI()->DoLabelScaled(&Right, aBuf, 14.0f, -1); Labels.HSplitTop(5.0f, 0, &Labels); Labels.HSplitTop(20.0f, &Left, &Labels); Left.VSplitLeft(150.0f, &Left, &Right); UI()->DoLabelScaled(&Left, Localize("Netversion:"), 14.0f, -1); UI()->DoLabelScaled(&Right, m_lDemos[m_DemolistSelectedIndex].m_Info.m_aNetversion, 14.0f, -1); } // demo list CUIRect Headers; ListBox.HSplitTop(ms_ListheaderHeight, &Headers, &ListBox); struct CColumn { int m_ID; int m_Sort; CLocConstString m_Caption; int m_Direction; float m_Width; int m_Flags; CUIRect m_Rect; CUIRect m_Spacer; }; enum { COL_ICON=0, COL_DEMONAME, COL_DATE, SORT_DEMONAME=0, SORT_DATE, }; static CColumn s_aCols[] = { {COL_ICON, -1, " ", -1, 14.0f, 0, {0}, {0}}, {COL_DEMONAME, SORT_DEMONAME, "Demo", 0, 0.0f, 0, {0}, {0}}, {COL_DATE, SORT_DATE, "Date", 1, 300.0f, 0, {0}, {0}}, }; RenderTools()->DrawUIRect(&Headers, vec4(0.0f,0,0,0.15f), 0, 0); int NumCols = sizeof(s_aCols)/sizeof(CColumn); // do layout for(int i = 0; i < NumCols; i++) { if(s_aCols[i].m_Direction == -1) { Headers.VSplitLeft(s_aCols[i].m_Width, &s_aCols[i].m_Rect, &Headers); if(i+1 < NumCols) { //Cols[i].flags |= SPACER; Headers.VSplitLeft(2, &s_aCols[i].m_Spacer, &Headers); } } } for(int i = NumCols-1; i >= 0; i--) { if(s_aCols[i].m_Direction == 1) { Headers.VSplitRight(s_aCols[i].m_Width, &Headers, &s_aCols[i].m_Rect); Headers.VSplitRight(2, &Headers, &s_aCols[i].m_Spacer); } } for(int i = 0; i < NumCols; i++) { if(s_aCols[i].m_Direction == 0) s_aCols[i].m_Rect = Headers; } // do headers for(int i = 0; i < NumCols; i++) { if(DoButton_GridHeader(s_aCols[i].m_Caption, s_aCols[i].m_Caption, g_Config.m_BrDemoSort == s_aCols[i].m_Sort, &s_aCols[i].m_Rect)) { if(s_aCols[i].m_Sort != -1) { if(g_Config.m_BrDemoSort == s_aCols[i].m_Sort) g_Config.m_BrDemoSortOrder ^= 1; else g_Config.m_BrDemoSortOrder = 0; g_Config.m_BrDemoSort = s_aCols[i].m_Sort; } DemolistPopulate(); DemolistOnUpdate(false); } } // scrollbar CUIRect Scroll; #if defined(__ANDROID__) ListBox.VSplitRight(50, &ListBox, &Scroll); #else ListBox.VSplitRight(15, &ListBox, &Scroll); #endif int Num = (int)(ListBox.h/s_aCols[0].m_Rect.h) + 1; static int s_ScrollBar = 0; static float s_ScrollValue = 0; Scroll.HMargin(5.0f, &Scroll); s_ScrollValue = DoScrollbarV(&s_ScrollBar, &Scroll, s_ScrollValue); int ScrollNum = m_lDemos.size()-Num+1; if(ScrollNum > 0) { if(m_ScrollOffset) { s_ScrollValue = (float)(m_ScrollOffset)/ScrollNum; m_ScrollOffset = 0; } if(Input()->KeyPresses(KEY_MOUSE_WHEEL_UP) && UI()->MouseInside(&ListBox)) s_ScrollValue -= 3.0f/ScrollNum; if(Input()->KeyPresses(KEY_MOUSE_WHEEL_DOWN) && UI()->MouseInside(&ListBox)) s_ScrollValue += 3.0f/ScrollNum; } else ScrollNum = 0; if(m_DemolistSelectedIndex > -1) { for(int i = 0; i < m_NumInputEvents; i++) { int NewIndex = -1; if(m_aInputEvents[i].m_Flags&IInput::FLAG_PRESS) { if(m_aInputEvents[i].m_Key == KEY_DOWN) NewIndex = m_DemolistSelectedIndex + 1; if(m_aInputEvents[i].m_Key == KEY_UP) NewIndex = m_DemolistSelectedIndex - 1; } if(NewIndex > -1 && NewIndex < m_lDemos.size()) { //scroll float IndexY = ListBox.y - s_ScrollValue*ScrollNum*s_aCols[0].m_Rect.h + NewIndex*s_aCols[0].m_Rect.h; int Scroll = ListBox.y > IndexY ? -1 : ListBox.y+ListBox.h < IndexY+s_aCols[0].m_Rect.h ? 1 : 0; if(Scroll) { if(Scroll < 0) { int NumScrolls = (ListBox.y-IndexY+s_aCols[0].m_Rect.h-1.0f)/s_aCols[0].m_Rect.h; s_ScrollValue -= (1.0f/ScrollNum)*NumScrolls; } else { int NumScrolls = (IndexY+s_aCols[0].m_Rect.h-(ListBox.y+ListBox.h)+s_aCols[0].m_Rect.h-1.0f)/s_aCols[0].m_Rect.h; s_ScrollValue += (1.0f/ScrollNum)*NumScrolls; } } m_DemolistSelectedIndex = NewIndex; str_copy(g_Config.m_UiDemoSelected, m_lDemos[NewIndex].m_aName, sizeof(g_Config.m_UiDemoSelected)); DemolistOnUpdate(false); } } } if(s_ScrollValue < 0) s_ScrollValue = 0; if(s_ScrollValue > 1) s_ScrollValue = 1; // set clipping UI()->ClipEnable(&ListBox); CUIRect OriginalView = ListBox; ListBox.y -= s_ScrollValue*ScrollNum*s_aCols[0].m_Rect.h; int NewSelected = -1; #if defined(__ANDROID__) int DoubleClicked = 0; #endif int ItemIndex = -1; for(sorted_array<CDemoItem>::range r = m_lDemos.all(); !r.empty(); r.pop_front()) { ItemIndex++; CUIRect Row; CUIRect SelectHitBox; ListBox.HSplitTop(ms_ListheaderHeight, &Row, &ListBox); SelectHitBox = Row; int Selected = ItemIndex == m_DemolistSelectedIndex; // make sure that only those in view can be selected if(Row.y+Row.h > OriginalView.y && Row.y < OriginalView.y+OriginalView.h) { if(Selected) { CUIRect r = Row; r.Margin(1.5f, &r); RenderTools()->DrawUIRect(&r, vec4(1,1,1,0.5f), CUI::CORNER_ALL, 4.0f); } // clip the selection if(SelectHitBox.y < OriginalView.y) // top { SelectHitBox.h -= OriginalView.y-SelectHitBox.y; SelectHitBox.y = OriginalView.y; } else if(SelectHitBox.y+SelectHitBox.h > OriginalView.y+OriginalView.h) // bottom SelectHitBox.h = OriginalView.y+OriginalView.h-SelectHitBox.y; if(UI()->DoButtonLogic(r.front().m_aName /* TODO: */, "", Selected, &SelectHitBox)) { NewSelected = ItemIndex; str_copy(g_Config.m_UiDemoSelected, r.front().m_aName, sizeof(g_Config.m_UiDemoSelected)); DemolistOnUpdate(false); #if defined(__ANDROID__) if(NewSelected == m_DoubleClickIndex) DoubleClicked = 1; #endif m_DoubleClickIndex = NewSelected; } } else { // don't render invisible items continue; } for(int c = 0; c < NumCols; c++) { CUIRect Button; Button.x = s_aCols[c].m_Rect.x; Button.y = Row.y; Button.h = Row.h; Button.w = s_aCols[c].m_Rect.w; int ID = s_aCols[c].m_ID; if (ID == COL_ICON) { DoButton_Icon(IMAGE_FILEICONS, r.front().m_IsDir?SPRITE_FILE_FOLDER:SPRITE_FILE_DEMO1, &Button); } else if(ID == COL_DEMONAME) { CTextCursor Cursor; TextRender()->SetCursor(&Cursor, Button.x, Button.y, 12.0f * UI()->Scale(), TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END); Cursor.m_LineWidth = Button.w; TextRender()->TextEx(&Cursor, r.front().m_aName, -1); } else if (ID == COL_DATE && !r.front().m_IsDir) { CTextCursor Cursor; TextRender()->SetCursor(&Cursor, Button.x, Button.y, 12.0f * UI()->Scale(), TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END); Cursor.m_LineWidth = Button.w; char aBuf[256]; str_timestamp_ex(r.front().m_Date, aBuf, sizeof(aBuf), "%Y-%m-%d %H:%M:%S"); TextRender()->TextEx(&Cursor, aBuf, -1); } } } UI()->ClipDisable(); bool Activated = false; #if defined(__ANDROID__) if (m_EnterPressed || (DoubleClicked && UI()->ActiveItem() == m_lDemos[m_DemolistSelectedIndex].m_aName)) #else if (m_EnterPressed || (Input()->MouseDoubleClick() && UI()->ActiveItem() == m_lDemos[m_DemolistSelectedIndex].m_aName)) #endif { UI()->SetActiveItem(0); Activated = true; } static int s_RefreshButton = 0; if(DoButton_Menu(&s_RefreshButton, Localize("Refresh"), 0, &RefreshRect)) { DemolistPopulate(); DemolistOnUpdate(false); } static int s_PlayButton = 0; if(DoButton_Menu(&s_PlayButton, m_DemolistSelectedIsDir?Localize("Open"):Localize("Play"), 0, &PlayRect) || Activated) { if(m_DemolistSelectedIndex >= 0) { if(m_DemolistSelectedIsDir) // folder { if(str_comp(m_lDemos[m_DemolistSelectedIndex].m_aFilename, "..") == 0) // parent folder fs_parent_dir(m_aCurrentDemoFolder); else // sub folder { char aTemp[256]; str_copy(aTemp, m_aCurrentDemoFolder, sizeof(aTemp)); str_format(m_aCurrentDemoFolder, sizeof(m_aCurrentDemoFolder), "%s/%s", aTemp, m_lDemos[m_DemolistSelectedIndex].m_aFilename); m_DemolistStorageType = m_lDemos[m_DemolistSelectedIndex].m_StorageType; } DemolistPopulate(); DemolistOnUpdate(true); } else // file { char aBuf[512]; str_format(aBuf, sizeof(aBuf), "%s/%s", m_aCurrentDemoFolder, m_lDemos[m_DemolistSelectedIndex].m_aFilename); const char *pError = Client()->DemoPlayer_Play(aBuf, m_lDemos[m_DemolistSelectedIndex].m_StorageType); if(pError) PopupMessage(Localize("Error"), str_comp(pError, "error loading demo") ? pError : Localize("Error loading demo"), Localize("Ok")); else { UI()->SetActiveItem(0); return; } } } } if(!m_DemolistSelectedIsDir) { static int s_DeleteButton = 0; if(DoButton_Menu(&s_DeleteButton, Localize("Delete"), 0, &DeleteRect) || m_DeletePressed) { if(m_DemolistSelectedIndex >= 0) { UI()->SetActiveItem(0); m_Popup = POPUP_DELETE_DEMO; return; } } static int s_RenameButton = 0; if(DoButton_Menu(&s_RenameButton, Localize("Rename"), 0, &RenameRect)) { if(m_DemolistSelectedIndex >= 0) { UI()->SetActiveItem(0); m_Popup = POPUP_RENAME_DEMO; str_copy(m_aCurrentDemoFile, m_lDemos[m_DemolistSelectedIndex].m_aFilename, sizeof(m_aCurrentDemoFile)); return; } } } }
void Zoltan2Interface<Scalar, LocalOrdinal, GlobalOrdinal, Node>::DeclareInput(Level& currentLevel) const { Input(currentLevel, "A"); Input(currentLevel, "Coordinates"); }
void solve(FILE *fin, FILE *fout) { Input(fin); int Ans = Work(); fprintf(fout, "%d\n", Ans); }
void input_init() { // Initialize input char controller[32]; for (int i = 0; i < NUMGAMEPADS; i++) { Input(emulator).AutoSelectController(i); switch(Input(emulator).GetConnectedController(i)) { case Input::UNCONNECTED: snprintf(controller, sizeof(controller), "%s", "Unconnected"); break; case Input::PAD1: case Input::PAD2: case Input::PAD3: case Input::PAD4: snprintf(controller, sizeof(controller), "%s", "Standard Pad"); break; case Input::ZAPPER: snprintf(controller, sizeof(controller), "%s", "Zapper"); break; case Input::PADDLE: snprintf(controller, sizeof(controller), "%s", "Arkanoid Paddle"); break; case Input::POWERPAD: snprintf(controller, sizeof(controller), "%s", "Power Pad"); break; case Input::POWERGLOVE: snprintf(controller, sizeof(controller), "%s", "Power Glove"); break; case Input::MOUSE: snprintf(controller, sizeof(controller), "%s", "Mouse"); break; case Input::ROB: snprintf(controller, sizeof(controller), "%s", "R.O.B."); break; case Input::FAMILYTRAINER: snprintf(controller, sizeof(controller), "%s", "Family Trainer"); break; case Input::FAMILYKEYBOARD: snprintf(controller, sizeof(controller), "%s", "Family Keyboard"); break; case Input::SUBORKEYBOARD: snprintf(controller, sizeof(controller), "%s", "Subor Keyboard"); break; case Input::DOREMIKKOKEYBOARD: snprintf(controller, sizeof(controller), "%s", "Doremikko Keyboard"); break; case Input::HORITRACK: snprintf(controller, sizeof(controller), "%s", "Hori Track"); break; case Input::PACHINKO: snprintf(controller, sizeof(controller), "%s", "Pachinko"); break; case Input::OEKAKIDSTABLET: snprintf(controller, sizeof(controller), "%s", "Oeka Kids Tablet"); break; case Input::KONAMIHYPERSHOT: snprintf(controller, sizeof(controller), "%s", "Konami Hypershot"); break; case Input::BANDAIHYPERSHOT: snprintf(controller, sizeof(controller), "%s", "Bandai Hypershot"); break; case Input::CRAZYCLIMBER: snprintf(controller, sizeof(controller), "%s", "Crazy Climber"); break; case Input::MAHJONG: snprintf(controller, sizeof(controller), "%s", "Mahjong"); break; case Input::EXCITINGBOXING: snprintf(controller, sizeof(controller), "%s", "Exciting Boxing"); break; case Input::TOPRIDER: snprintf(controller, sizeof(controller), "%s", "Top Rider"); break; case Input::POKKUNMOGURAA: snprintf(controller, sizeof(controller), "%s", "Pokkun Moguraa"); break; case Input::PARTYTAP: snprintf(controller, sizeof(controller), "%s", "PartyTap"); break; case Input::TURBOFILE: snprintf(controller, sizeof(controller), "%s", "Turbo File"); break; case Input::BARCODEWORLD: snprintf(controller, sizeof(controller), "%s", "Barcode World"); break; default: snprintf(controller, sizeof(controller), "%s", "Unknown"); break; } fprintf(stderr, "Port %d: %s\n", i + 1, controller); } video_set_cursor(); }
inline void solve(void) { Input(); Work(); }
// run void SAppBase::run() { if (!m_bInit) { // always do last SetWindowLongPtr(m_hWnd, GWL_USERDATA, (LONG)(DWORD_PTR)this); m_bInit = true; } if (!m_bRun) { m_bRun = true; ShowWindow(m_hWnd, SW_SHOW); } // setup startup dialog if not running because of exception if (!m_bException) { std::string cmdLineDlg = getCmdLineOption("d"); try { DialogMgr().add(cmdLineDlg); } catch (ExceptionDialogMgr&) { if (!m_defaultDlg.empty()) DialogMgr().add(m_defaultDlg); } DialogMgr().update(0.0001f); } // init timer timer().endFrame(); bool bNeedsUpdate = false; MSG msg; do { Critical(*m_criticalMainLoop); // windows message handling while( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) { if (msg.message == WM_QUIT) m_bExit = true; TranslateMessage( &msg ); DispatchMessage( &msg ); } if (m_bExit) break; // game update float delta = (float)(timer().realTime() - m_lastUpdateTime); bNeedsUpdate = m_updateLoopFreq == 0 || delta >= (1.0f / m_updateLoopFreq); if (bNeedsUpdate) { timer().endFrame(); double startFrameTime = timer().realTime(); m_lastUpdateTime = startFrameTime; delta = (float)timer().frame(); { Profile("Dialog Update"); Input().update(); DialogMgr().update(delta); } { Profile("Update"); update(delta); SteppableThreadHost::update(); } Input().clear(); { Profile("Render"); render(); } { Profile("Garbage"); ptrGCManager.garbage->collect(); } m_totalFrameTime = timer().realTime() - startFrameTime; Profiler().end(); Profiler().finalise(); Profiler().start("Total"); } } while (!m_bExit); m_bRun = false; }
void CoarseMapFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node, LocalMatOps>::DeclareInput(Level ¤tLevel) const { Input(currentLevel, "Aggregates"); Input(currentLevel, "Nullspace"); }
void Camera::Update() { Input(); //TODO: delete CalculateVPMatrix(); }
void SAppBase::init() { // setup logging dlog.add(new dlogprinterfile(Path::localSettings(Path("log.txt")))); derr.add(new dlogprinterfile(Path::localSettings(Path("errors.txt")))); loadConfig("options.ini", true); m_options = &config("options.ini"); loadConfig("ui.ini", true); m_ui = &config("ui.ini"); loadConfig("materials.ini"); m_materials = &config("materials.ini"); std::string uistylesConfigName = m_options->get("UI", "StyleFile", std::string("uistyles.ini")); loadConfig(uistylesConfigName); m_uiStyles = &config(uistylesConfigName); // Heap debugging if (hasCmdLineOption("heapdebug")) { #if IS_MSVC int tmpFlag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG ); tmpFlag |= _CRTDBG_CHECK_ALWAYS_DF; _CrtSetDbgFlag( tmpFlag ); #else throw("Heap debugging is only enabled in MSVC builds."); #endif } // create log dlog << m_appName << " - " << getCPUVendorID() << " " << getCPUTicksPerSecond() / 1000000.0f << " Mhz" << dlog.endl; // get default window icon, if available // tbd:mingw: fix //HICON groupIcon = LoadIcon(GetModuleHandle(0), "APP"); // Register the window class. WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, StaticMsgProc, 0L, sizeof(LONG), GetModuleHandle(NULL), /*groupIcon*/0, LoadCursor(0, IDC_ARROW), NULL, NULL, m_appName.c_str(), NULL }; RegisterClassEx( &wc ); //FreeResource(groupIcon); // Create the application's window. m_hWnd = CreateWindow( m_appName.c_str(), m_appName.c_str(), WS_OVERLAPPEDWINDOW, 0, 0, 640, 480, GetDesktopWindow(), NULL, wc.hInstance, NULL ); if (!m_hWnd) throwf("Couldn't create a window."); // setup device bool windowed = hasCmdLineOption("w"); Point2i fullscreenSize = options().get("Render", "FullscreenSize", Point2i(1024, 768)); Point2i windowedSize = options().get("Render", "WindowedSize", Point2i(640, 480)); D3D().newDevice( windowed, fullscreenSize.x, fullscreenSize.y, windowedSize.x, windowedSize.y ); createFonts(); // create dialog mgr m_pDlgMgrSingleton = new SDialogMgr; if (!Input().create(GetModuleHandle(NULL))) throwf("Couldn't create input"); if (!Input().createMouse(m_hWnd)) throwf("Couldn't create mouse"); // setup ui DialogMgr().create(); m_textureAnimation = new TextureAnimationManager("animations.ini"); m_particles = new ParticleFactory("particles.ini", m_textureAnimation->set("particles")); m_spriteFX = new SpriteFXFactory("spritefx.ini"); timer().restart(); m_updateLoopFreq = options().get("Game", "UpdateLoopFreq", 0.0f); // create sound std::string soundProvider = options().get("Sound", "Provider", std::string("FMODProvider")); dlog << "AppBase: Initialising sound provider '" << soundProvider << "'" << dlog.endl; m_sound = (ISoundProvider*)Base::newObject(soundProvider); if (!m_sound) throwf("Couldn't initialize sound provider '" + soundProvider + "'"); // music manager loadConfig("music.ini"); loadConfig("musicmanager.ini"); m_music = new MusicManager; // Add sounds path filesystem().addFileMethod(new FileMethodDiskRelative(pathResources() + m_options->get("Sound", "SoundsPath", std::string("media\\sounds")))); // make main loop update thread #if USE_FIBERS m_mainLoopStep = new ThreadStepper(ThreadStepper::Delegate(this, (ThreadStepper::Delegate::FuncType)&SAppBase::doMainLoopUpdate)); add(*m_mainLoopStep); #endif }
int main(int argc, char** argv) { if(argc == 3) { festring Arg = festring(argv[1]); if(Arg == "-l") { highscore Input(argv[2]); if(!Input.GetSize()) { std::cout << "No games. No winners.\n"; } std::cout << std::endl; for(festring::sizetype c = 0; c < Input.GetSize(); ++c) std::cout << c + 1 << " " << Input.GetEntry(c).CStr() << " " << Input.GetScore(c) << "\n"; return 0; } else if(Arg == "-h") { return OutputHTML(argv[2]); } else if(Arg == "-d") { if(!DebugDraw(argv[2])) { std::cout << "\nProblem showing version number\n"; return 1; } return 0; } else return 1; } if(argc == 4) { highscore Input; Input.Load(argv[1]); if(!Input.CheckVersion()) { std::cout << "Version check not ok with " << argv[1] << std::endl; return 2; } highscore Output; Output.Load(argv[2]); if(!Output.CheckVersion()) { std::cout << "Version check not ok with " << argv[2] << std::endl; return 2; } if(!Input.MergeToFile(&Output)) std::cout << "\n All entries also found in " << argv[2] << ". Oh well.\n"; Output.Save(argv[3]); return 0; } std::cout << "\nTo list scores in highscore file:\n" " mihail -l [filename]" "\n\nTo merge 2 files\n" " mihail [1st input filename] [2nd input filename] [output filename]" "\n\nTo give version number of highscore file\n" " mihail -d [filename]\n" "Notice that first filename in merges gives also version number\n"; return 1; }
/* Display Or Modify Logical Drive Information in the extended partition */ void Display_Or_Modify_Logical_Drive_Information() { char char_number[1]; int continue_loop; int index; int input; int input_ok; Partition_Table *pDrive = &part_table[flags.drive_number-0x80]; Beginning: Clear_Screen(NOEXTRAS); if(flags.extended_options_flag==FALSE) Print_Centered(1,"Display Logical DOS Drive Information",BOLD); else Print_Centered(1,"Display/Modify Logical DOS Drive Information",BOLD); Display_Extended_Partition_Information_SS(); if(flags.extended_options_flag==FALSE) Input(0,0,0,ESC,0,0,ESCC,0,0,NULL,NULL); else { printAt(4,18,"Enter the character of the logical drive you want to modify.....?"); Determine_Drive_Letters(); continue_loop=TRUE; do { flags.esc=FALSE; if( (flags.del_non_dos_log_drives==TRUE) && (pDrive->num_of_non_dos_log_drives>0) ) { if(pDrive->num_of_non_dos_log_drives>9) pDrive->num_of_non_dos_log_drives=9; itoa(pDrive->num_of_non_dos_log_drives,char_number,10); input=(int)Input(1,69,18,CHAR,68,90,ESCC,0,0,"1",char_number); } else input=(int)Input(1,69,18,CHAR,68,90,ESCC,0,0,NULL,NULL); if(flags.esc==FALSE) { /* Ensure that the entered character is legitimate. */ index=4; do { if( (drive_lettering_buffer[(flags.drive_number-128)] [index]>0) && (drive_lettering_buffer[(flags.drive_number-128)] [index]==input) ) { input=index-4; input_ok=TRUE; index=30; /* break out of the loop */ } index++; }while(index<=26); } if(input_ok==TRUE) continue_loop=FALSE; if(flags.esc==TRUE) continue_loop=FALSE; }while(continue_loop==TRUE); if( (input_ok==TRUE) && (flags.esc==FALSE) ) { Modify_Extended_Partition_Information(input); goto Beginning; } } }
/* Delete Logical Drive Interface */ int Delete_Logical_Drive_Interface() { char char_number[2]; int drive_to_delete=0; int index=0; int input=0; int input_ok; Partition_Table *pDrive = &part_table[flags.drive_number-0x80]; Clear_Screen(0); Print_Centered(1,"Delete Logical DOS Drive(s) in the Extended DOS Partition",BOLD); Display_Extended_Partition_Information_SS(); BlinkPrintAt(4,19,"WARNING!"); printf(" Data in a deleted Logical DOS Drive will be lost."); printAt (4,20,"What drive do you want to delete...............................? "); Determine_Drive_Letters(); //char drive_lettering_buffer[8] [27]; this line is for reference /* Place code to find the min and max drive letter here. */ input_ok=FALSE; do { flags.esc=FALSE; if( (flags.del_non_dos_log_drives==TRUE) && (pDrive->num_of_non_dos_log_drives>0) ) { if(pDrive->num_of_non_dos_log_drives>9) pDrive->num_of_non_dos_log_drives=9; itoa(pDrive->num_of_non_dos_log_drives,char_number,10); input=(int)Input(1,69,20,CHAR,67,90,ESCR,0,0,"1",char_number); } else input=(int)Input(1,69,20,CHAR,67,90,ESCR,0,0,NULL,NULL); /* Note: min_range and max_range will need adjusted!!!!! */ /* Changes will have to be made because the first logical drive letter */ /* on the selected drive may not be D:, the drive letters on the */ /* drive may not be sequential. */ if(flags.esc==TRUE) return(1); if(flags.esc==FALSE) { /* Ensure that the entered character is legitimate. */ index=4; do { if( (drive_lettering_buffer[(flags.drive_number-128)] [index]>0) && (drive_lettering_buffer[(flags.drive_number-128)] [index]==input) ) { input=index-4; input_ok=TRUE; index=30; /* break out of the loop */ } index++; }while(index<=26); } }while(input_ok==FALSE); drive_to_delete=input; printAt(4,22,"Are you sure (Y/N)..............................? "); flags.esc=FALSE; input=(int)Input(1,54,22,YN,0,0,ESCR,0,0,NULL,NULL); if( (input==TRUE) && (flags.esc==FALSE) ) { Delete_Logical_Drive(drive_to_delete); Clear_Screen(0); Print_Centered(1,"Delete Logical DOS Drive(s) in the Extended DOS Partition",BOLD); Display_Extended_Partition_Information_SS(); input=(int)Input(0,0,0,ESC,0,0,ESCC,0,0,NULL,NULL); } return(0); }
Average::Average(UniSim::Identifier name, QObject *parent) : Model(name, parent) { Input(QString, inputs, QString()); Output(double, value); }
void IsorropiaInterface<LocalOrdinal, GlobalOrdinal, Node, LocalMatOps>::DeclareInput(Level & currentLevel) const { Input(currentLevel, "A"); Input(currentLevel, "UnAmalgamationInfo"); }
/*主函数*/ void main() { int n = 0; for (;;) { switch (menu_select()) { case 1: printf("\n 添加记录到通讯录\n"); n = Input(pe, n); printf("添加完毕,按任意键返回"); __fpurge(stdin); getchar(); system("clear"); break; case 2: printf("\n 通讯录记录表\n"); Display(pe, n); printf("输出完毕,按任意键返回"); __fpurge(stdin); getchar(); system("clear"); break; case 3: printf("\n 从通讯录中删除记录\n"); n = Delete_a_record(pe, n); printf("删除完毕,按任意键返回"); __fpurge(stdin); getchar(); system("clear"); break; case 4: printf("\n 在通讯录中查找记录\n"); Query_a_record(pe, n); printf("查找完毕,按任意键返回"); __fpurge(stdin); getchar(); system("clear"); break; case 5: printf("\n 修改通讯录中的记录\n"); Change(pe, n); printf("修改完毕,按任意键返回"); __fpurge(stdin); getchar(); system("clear"); break; case 6: printf("\n 保存功能\n"); WritetoText(pe, n); printf("保存完毕,按任意键返回"); __fpurge(stdin); getchar(); system("clear"); break; case 7: printf("\n 默认数据\n"); DefaultData(pe, &n); printf("加载完毕,按任意键返回\n"); Display(pe, n); __fpurge(stdin); getchar(); system("clear"); break; case 0: printf("\n 谢谢使用,再见!\n"); __fpurge(stdin); getchar(); system("clear"); exit(0); } } }
function_reference_input_iterator(Function & f_, Input state_ = Input()) : function_pointer_input_iterator<Function*,Input>(&f_, state_) {}
void ConstraintFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node, LocalMatOps>::DeclareInput(Level &fineLevel, Level& coarseLevel) const { Input(fineLevel, "Nullspace", "FineNullspace"); Input(coarseLevel, "Nullspace", "CoarseNullspace"); Input(coarseLevel, "Ppattern"); }
function_pointer_input_iterator(Function &f_, Input state_ = Input()) : f(f_), state(state_) {}
void ZoltanInterface<LocalOrdinal, GlobalOrdinal, Node, LocalMatOps>::DeclareInput(Level & currentLevel) const { Input(currentLevel, "A"); Input(currentLevel, "Coordinates"); Input(currentLevel, "number of partitions"); } //DeclareInput()
TEST_P(VertexLoaderParamTest, PositionAll) { int addr, format, elements, frac; std::tie(addr, format, elements, frac) = GetParam(); this->m_vtx_desc.Position = addr; this->m_vtx_attr.g0.PosFormat = format; this->m_vtx_attr.g0.PosElements = elements; this->m_vtx_attr.g0.PosFrac = frac; this->m_vtx_attr.g0.ByteDequant = true; elements += 2; std::vector<float> values = { std::numeric_limits<float>::lowest(), std::numeric_limits<float>::denorm_min(), std::numeric_limits<float>::min(), std::numeric_limits<float>::max(), std::numeric_limits<float>::quiet_NaN(), std::numeric_limits<float>::infinity(), -0x8000, -0x80, -1, -0, 0, 1, 123, 0x7F, 0xFF, 0x7FFF, 0xFFFF, 12345678, }; ASSERT_EQ(0u, values.size() % 2); ASSERT_EQ(0u, values.size() % 3); int count = (int)values.size() / elements; u32 elem_size = 1 << (format / 2); size_t input_size = elements * elem_size; if (addr & MASK_INDEXED) { input_size = addr - 1; for (int i = 0; i < count; i++) if (addr == INDEX8) Input<u8>(i); else Input<u16>(i); VertexLoaderManager::cached_arraybases[ARRAY_POSITION] = m_src.GetPointer(); g_main_cp_state.array_strides[ARRAY_POSITION] = elements * elem_size; } CreateAndCheckSizes(input_size, elements * sizeof(float)); for (float value : values) { switch (format) { case FORMAT_UBYTE: Input((u8)value); break; case FORMAT_BYTE: Input((s8)value); break; case FORMAT_USHORT: Input((u16)value); break; case FORMAT_SHORT: Input((s16)value); break; case FORMAT_FLOAT: Input(value); break; } } RunVertices(count); float scale = 1.f / (1u << (format == FORMAT_FLOAT ? 0 : frac)); for (auto iter = values.begin(); iter != values.end();) { float f, g; switch (format) { case FORMAT_UBYTE: f = (u8)*iter++; g = (u8)*iter++; break; case FORMAT_BYTE: f = (s8)*iter++; g = (s8)*iter++; break; case FORMAT_USHORT: f = (u16)*iter++; g = (u16)*iter++; break; case FORMAT_SHORT: f = (s16)*iter++; g = (s16)*iter++; break; case FORMAT_FLOAT: f = *iter++; g = *iter++; break; } ExpectOut(f * scale); ExpectOut(g * scale); } }
std::string TestCase::Input() const { return Input(seed); }
void CGameConsole::OnRender() { CUIRect Screen = *UI()->Screen(); float ConsoleMaxHeight = Screen.h*3/5.0f; float ConsoleHeight; float Progress = (TimeNow()-(m_StateChangeEnd-m_StateChangeDuration))/float(m_StateChangeDuration); if (Progress >= 1.0f) { if (m_ConsoleState == CONSOLE_CLOSING) m_ConsoleState = CONSOLE_CLOSED; else if (m_ConsoleState == CONSOLE_OPENING) m_ConsoleState = CONSOLE_OPEN; Progress = 1.0f; } if (m_ConsoleState == CONSOLE_OPEN && g_Config.m_ClEditor) Toggle(CONSOLETYPE_LOCAL); if (m_ConsoleState == CONSOLE_CLOSED) return; if (m_ConsoleState == CONSOLE_OPEN) Input()->MouseModeAbsolute(); float ConsoleHeightScale; if (m_ConsoleState == CONSOLE_OPENING) ConsoleHeightScale = ConsoleScaleFunc(Progress); else if (m_ConsoleState == CONSOLE_CLOSING) ConsoleHeightScale = ConsoleScaleFunc(1.0f-Progress); else //if (console_state == CONSOLE_OPEN) ConsoleHeightScale = ConsoleScaleFunc(1.0f); ConsoleHeight = ConsoleHeightScale*ConsoleMaxHeight; Graphics()->MapScreen(Screen.x, Screen.y, Screen.w, Screen.h); // do console shadow Graphics()->TextureClear(); Graphics()->QuadsBegin(); IGraphics::CColorVertex Array[4] = { IGraphics::CColorVertex(0, 0,0,0, 0.5f), IGraphics::CColorVertex(1, 0,0,0, 0.5f), IGraphics::CColorVertex(2, 0,0,0, 0.0f), IGraphics::CColorVertex(3, 0,0,0, 0.0f)}; Graphics()->SetColorVertex(Array, 4); IGraphics::CQuadItem QuadItem(0, ConsoleHeight, Screen.w, 10.0f); Graphics()->QuadsDrawTL(&QuadItem, 1); Graphics()->QuadsEnd(); // do background Graphics()->TextureSet(g_pData->m_aImages[IMAGE_CONSOLE_BG].m_Id); Graphics()->QuadsBegin(); Graphics()->SetColor(0.2f, 0.2f, 0.2f,0.9f); if(m_ConsoleType == CONSOLETYPE_REMOTE) Graphics()->SetColor(0.4f, 0.2f, 0.2f,0.9f); Graphics()->QuadsSetSubset(0,-ConsoleHeight*0.075f,Screen.w*0.075f*0.5f,0); QuadItem = IGraphics::CQuadItem(0, 0, Screen.w, ConsoleHeight); Graphics()->QuadsDrawTL(&QuadItem, 1); Graphics()->QuadsEnd(); // do small bar shadow Graphics()->TextureClear(); Graphics()->QuadsBegin(); Array[0] = IGraphics::CColorVertex(0, 0,0,0, 0.0f); Array[1] = IGraphics::CColorVertex(1, 0,0,0, 0.0f); Array[2] = IGraphics::CColorVertex(2, 0,0,0, 0.25f); Array[3] = IGraphics::CColorVertex(3, 0,0,0, 0.25f); Graphics()->SetColorVertex(Array, 4); QuadItem = IGraphics::CQuadItem(0, ConsoleHeight-20, Screen.w, 10); Graphics()->QuadsDrawTL(&QuadItem, 1); Graphics()->QuadsEnd(); // do the lower bar Graphics()->TextureSet(g_pData->m_aImages[IMAGE_CONSOLE_BAR].m_Id); Graphics()->QuadsBegin(); Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.9f); Graphics()->QuadsSetSubset(0,0.1f,Screen.w*0.015f,1-0.1f); QuadItem = IGraphics::CQuadItem(0,ConsoleHeight-10.0f,Screen.w,10.0f); Graphics()->QuadsDrawTL(&QuadItem, 1); Graphics()->QuadsEnd(); ConsoleHeight -= 22.0f; CInstance *pConsole = CurrentConsole(); { float FontSize = 10.0f; float RowHeight = FontSize*1.25f; float x = 3; float y = ConsoleHeight - RowHeight - 5.0f; CRenderInfo Info; Info.m_pSelf = this; Info.m_WantedCompletion = pConsole->m_CompletionChosen; Info.m_EnumCount = 0; Info.m_Offset = pConsole->m_CompletionRenderOffset; Info.m_Width = Screen.w; Info.m_pCurrentCmd = pConsole->m_aCompletionBuffer; TextRender()->SetCursor(&Info.m_Cursor, x+Info.m_Offset, y+RowHeight+2.0f, FontSize, TEXTFLAG_RENDER); // render prompt CTextCursor Cursor; TextRender()->SetCursor(&Cursor, x, y, FontSize, TEXTFLAG_RENDER); const char *pPrompt = "> "; if(m_ConsoleType == CONSOLETYPE_REMOTE) { if(Client()->State() == IClient::STATE_ONLINE) { if(Client()->RconAuthed()) pPrompt = "rcon> "; else pPrompt = "ENTER PASSWORD> "; } else pPrompt = "NOT CONNECTED> "; } TextRender()->TextEx(&Cursor, pPrompt, -1); x = Cursor.m_X; //hide rcon password char aInputString[256]; str_copy(aInputString, pConsole->m_Input.GetString(), sizeof(aInputString)); if(m_ConsoleType == CONSOLETYPE_REMOTE && Client()->State() == IClient::STATE_ONLINE && !Client()->RconAuthed()) { for(int i = 0; i < pConsole->m_Input.GetLength(); ++i) aInputString[i] = '*'; } // render console input (wrap line) TextRender()->SetCursor(&Cursor, x, y, FontSize, 0); Cursor.m_LineWidth = Screen.w - 10.0f - x; TextRender()->TextEx(&Cursor, aInputString, pConsole->m_Input.GetCursorOffset()); TextRender()->TextEx(&Cursor, aInputString+pConsole->m_Input.GetCursorOffset(), -1); int Lines = Cursor.m_LineCount; y -= (Lines - 1) * FontSize; TextRender()->SetCursor(&Cursor, x, y, FontSize, TEXTFLAG_RENDER); Cursor.m_LineWidth = Screen.w - 10.0f - x; TextRender()->TextEx(&Cursor, aInputString, pConsole->m_Input.GetCursorOffset()); static float MarkerOffset = TextRender()->TextWidth(0, FontSize, "|", -1)/3; CTextCursor Marker = Cursor; Marker.m_X -= MarkerOffset; Marker.m_LineWidth = -1; TextRender()->TextEx(&Marker, "|", -1); TextRender()->TextEx(&Cursor, aInputString+pConsole->m_Input.GetCursorOffset(), -1); // render possible commands if(m_ConsoleType == CONSOLETYPE_LOCAL || Client()->RconAuthed()) { if(pConsole->m_Input.GetString()[0] != 0) { m_pConsole->PossibleCommands(pConsole->m_aCompletionBuffer, pConsole->m_CompletionFlagmask, m_ConsoleType != CGameConsole::CONSOLETYPE_LOCAL && Client()->RconAuthed() && Client()->UseTempRconCommands(), PossibleCommandsRenderCallback, &Info); pConsole->m_CompletionRenderOffset = Info.m_Offset; if(Info.m_EnumCount <= 0) { if(pConsole->m_IsCommand) { char aBuf[512]; str_format(aBuf, sizeof(aBuf), "Help: %s ", pConsole->m_aCommandHelp); TextRender()->TextEx(&Info.m_Cursor, aBuf, -1); TextRender()->TextColor(0.75f, 0.75f, 0.75f, 1); str_format(aBuf, sizeof(aBuf), "Syntax: %s %s", pConsole->m_aCommandName, pConsole->m_aCommandParams); TextRender()->TextEx(&Info.m_Cursor, aBuf, -1); } } } } TextRender()->TextColor(1,1,1,1); // render log (actual page, wrap lines) CInstance::CBacklogEntry *pEntry = pConsole->m_Backlog.Last(); float OffsetY = 0.0f; float LineOffset = 1.0f; for(int Page = 0; Page <= pConsole->m_BacklogActPage; ++Page, OffsetY = 0.0f) { while(pEntry) { // get y offset (calculate it if we haven't yet) if(pEntry->m_YOffset < 0.0f) { TextRender()->SetCursor(&Cursor, 0.0f, 0.0f, FontSize, 0); Cursor.m_LineWidth = Screen.w-10; TextRender()->TextEx(&Cursor, pEntry->m_aText, -1); pEntry->m_YOffset = Cursor.m_Y+Cursor.m_FontSize+LineOffset; } OffsetY += pEntry->m_YOffset; // next page when lines reach the top if(y-OffsetY <= RowHeight) break; // just render output from actual backlog page (render bottom up) if(Page == pConsole->m_BacklogActPage) { TextRender()->SetCursor(&Cursor, 0.0f, y-OffsetY, FontSize, TEXTFLAG_RENDER); Cursor.m_LineWidth = Screen.w-10.0f; TextRender()->TextEx(&Cursor, pEntry->m_aText, -1); } pEntry = pConsole->m_Backlog.Prev(pEntry); } // actual backlog page number is too high, render last available page (current checked one, render top down) if(!pEntry && Page < pConsole->m_BacklogActPage) { pConsole->m_BacklogActPage = Page; pEntry = pConsole->m_Backlog.First(); while(OffsetY > 0.0f && pEntry) { TextRender()->SetCursor(&Cursor, 0.0f, y-OffsetY, FontSize, TEXTFLAG_RENDER); Cursor.m_LineWidth = Screen.w-10.0f; TextRender()->TextEx(&Cursor, pEntry->m_aText, -1); OffsetY -= pEntry->m_YOffset; pEntry = pConsole->m_Backlog.Next(pEntry); } break; } } // render page char aBuf[128]; str_format(aBuf, sizeof(aBuf), Localize("-Page %d-"), pConsole->m_BacklogActPage+1); TextRender()->Text(0, 10.0f, 0.0f, FontSize, aBuf, -1); // render version str_format(aBuf, sizeof(aBuf), "v%s", GAME_VERSION); float Width = TextRender()->TextWidth(0, FontSize, aBuf, -1); TextRender()->Text(0, Screen.w-Width-10.0f, 0.0f, FontSize, aBuf, -1); } }
void CMenus::RenderDemoPlayer(CUIRect MainView) { const IDemoPlayer::CInfo *pInfo = DemoPlayer()->BaseInfo(); const float SeekBarHeight = 15.0f; const float ButtonbarHeight = 20.0f; const float NameBarHeight = 20.0f; const float Margins = 5.0f; float TotalHeight; static int64 LastSpeedChange = 0; // render popups if (m_DemoPlayerState == DEMOPLAYER_SLICE_SAVE) { CUIRect Screen = *UI()->Screen(); CUIRect Box, Part, Part2; Box = Screen; Box.VMargin(150.0f/UI()->Scale(), &Box); #if defined(__ANDROID__) Box.HMargin(100.0f/UI()->Scale(), &Box); #else Box.HMargin(150.0f/UI()->Scale(), &Box); #endif // render the box RenderTools()->DrawUIRect(&Box, vec4(0,0,0,0.5f), CUI::CORNER_ALL, 15.0f); Box.HSplitTop(20.f/UI()->Scale(), &Part, &Box); Box.HSplitTop(24.f/UI()->Scale(), &Part, &Box); UI()->DoLabelScaled(&Part, Localize("Select a name"), 24.f, 0); Box.HSplitTop(20.f/UI()->Scale(), &Part, &Box); Box.HSplitTop(24.f/UI()->Scale(), &Part, &Box); Part.VMargin(20.f/UI()->Scale(), &Part); UI()->DoLabelScaled(&Part, m_aDemoPlayerPopupHint, 24.f, 0); CUIRect Label, TextBox, Ok, Abort; Box.HSplitBottom(20.f, &Box, &Part); #if defined(__ANDROID__) Box.HSplitBottom(60.f, &Box, &Part); #else Box.HSplitBottom(24.f, &Box, &Part); #endif Part.VMargin(80.0f, &Part); Part.VSplitMid(&Abort, &Ok); Ok.VMargin(20.0f, &Ok); Abort.VMargin(20.0f, &Abort); static int s_RemoveChat = 0; static int s_ButtonAbort = 0; if(DoButton_Menu(&s_ButtonAbort, Localize("Abort"), 0, &Abort) || m_EscapePressed) m_DemoPlayerState = DEMOPLAYER_NONE; static int s_ButtonOk = 0; if(DoButton_Menu(&s_ButtonOk, Localize("Ok"), 0, &Ok) || m_EnterPressed) { if (str_comp(m_lDemos[m_DemolistSelectedIndex].m_aFilename, m_aCurrentDemoFile) == 0) str_copy(m_aDemoPlayerPopupHint, Localize("Please use a different name"), sizeof(m_aDemoPlayerPopupHint)); else { m_DemoPlayerState = DEMOPLAYER_NONE; int len = str_length(m_aCurrentDemoFile); if(len < 5 || str_comp_nocase(&m_aCurrentDemoFile[len-5], ".demo")) str_append(m_aCurrentDemoFile, ".demo", sizeof(m_aCurrentDemoFile)); char aPath[512]; str_format(aPath, sizeof(aPath), "%s/%s", m_aCurrentDemoFolder, m_aCurrentDemoFile); Client()->DemoSlice(aPath, s_RemoveChat); } } Box.HSplitBottom(60.f, &Box, &Part); Box.HSplitBottom(60.f, &Box, &Part2); #if defined(__ANDROID__) Box.HSplitBottom(60.f, &Box, &Part2); Box.HSplitBottom(60.f, &Box, &Part); #else Box.HSplitBottom(24.f, &Box, &Part2); Box.HSplitBottom(24.f, &Box, &Part); #endif Part2.VSplitLeft(60.0f, 0, &Label); if(DoButton_CheckBox(&s_RemoveChat, Localize("Remove chat"), s_RemoveChat, &Label)) { s_RemoveChat ^= 1; } Part.VSplitLeft(60.0f, 0, &Label); Label.VSplitLeft(120.0f, 0, &TextBox); TextBox.VSplitLeft(20.0f, 0, &TextBox); TextBox.VSplitRight(60.0f, &TextBox, 0); UI()->DoLabel(&Label, Localize("New name:"), 18.0f, -1); static float Offset = 0.0f; DoEditBox(&Offset, &TextBox, m_aCurrentDemoFile, sizeof(m_aCurrentDemoFile), 12.0f, &Offset); } // handle mousewheel independent of active menu if(Input()->KeyPresses(KEY_MOUSE_WHEEL_UP)) { if(pInfo->m_Speed < 0.1f) DemoPlayer()->SetSpeed(0.1f); else if(pInfo->m_Speed < 0.25f) DemoPlayer()->SetSpeed(0.25f); else if(pInfo->m_Speed < 0.5f) DemoPlayer()->SetSpeed(0.5f); else if(pInfo->m_Speed < 0.75f) DemoPlayer()->SetSpeed(0.75f); else if(pInfo->m_Speed < 1.0f) DemoPlayer()->SetSpeed(1.0f); else if(pInfo->m_Speed < 2.0f) DemoPlayer()->SetSpeed(2.0f); else if(pInfo->m_Speed < 4.0f) DemoPlayer()->SetSpeed(4.0f); else DemoPlayer()->SetSpeed(8.0f); LastSpeedChange = time_get(); } else if(Input()->KeyPresses(KEY_MOUSE_WHEEL_DOWN)) { if(pInfo->m_Speed > 4.0f) DemoPlayer()->SetSpeed(4.0f); else if(pInfo->m_Speed > 2.0f) DemoPlayer()->SetSpeed(2.0f); else if(pInfo->m_Speed > 1.0f) DemoPlayer()->SetSpeed(1.0f); else if(pInfo->m_Speed > 0.75f) DemoPlayer()->SetSpeed(0.75f); else if(pInfo->m_Speed > 0.5f) DemoPlayer()->SetSpeed(0.5f); else if(pInfo->m_Speed > 0.25f) DemoPlayer()->SetSpeed(0.25f); else if(pInfo->m_Speed > 0.1f) DemoPlayer()->SetSpeed(0.1f); else DemoPlayer()->SetSpeed(0.05f); LastSpeedChange = time_get(); } TotalHeight = SeekBarHeight+ButtonbarHeight+NameBarHeight+Margins*3; // render speed info if (g_Config.m_ClDemoShowSpeed && time_get() - LastSpeedChange < time_freq() * 1) { CUIRect Screen = *UI()->Screen(); char aSpeedBuf[256]; str_format(aSpeedBuf, sizeof(aSpeedBuf), "×%.2f", pInfo->m_Speed); TextRender()->Text(0, 120.0f, Screen.y+Screen.h - 120.0f - TotalHeight, 60.0f, aSpeedBuf, -1); } if(!m_MenuActive) return; MainView.HSplitBottom(TotalHeight, 0, &MainView); MainView.VSplitLeft(50.0f, 0, &MainView); MainView.VSplitLeft(450.0f, &MainView, 0); RenderTools()->DrawUIRect(&MainView, ms_ColorTabbarActive, CUI::CORNER_T, 10.0f); MainView.Margin(5.0f, &MainView); CUIRect SeekBar, ButtonBar, NameBar; int CurrentTick = pInfo->m_CurrentTick - pInfo->m_FirstTick; int TotalTicks = pInfo->m_LastTick - pInfo->m_FirstTick; MainView.HSplitTop(SeekBarHeight, &SeekBar, &ButtonBar); ButtonBar.HSplitTop(Margins, 0, &ButtonBar); ButtonBar.HSplitBottom(NameBarHeight, &ButtonBar, &NameBar); NameBar.HSplitTop(4.0f, 0, &NameBar); // do seekbar { static int s_SeekBarID = 0; void *id = &s_SeekBarID; char aBuffer[128]; // draw seek bar RenderTools()->DrawUIRect(&SeekBar, vec4(0,0,0,0.5f), CUI::CORNER_ALL, 5.0f); // draw filled bar float Amount = CurrentTick/(float)TotalTicks; CUIRect FilledBar = SeekBar; FilledBar.w = 10.0f + (FilledBar.w-10.0f)*Amount; RenderTools()->DrawUIRect(&FilledBar, vec4(1,1,1,0.5f), CUI::CORNER_ALL, 5.0f); // draw markers for(int i = 0; i < pInfo->m_NumTimelineMarkers; i++) { float Ratio = (pInfo->m_aTimelineMarkers[i]-pInfo->m_FirstTick) / (float)TotalTicks; Graphics()->TextureSet(-1); Graphics()->QuadsBegin(); Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f); IGraphics::CQuadItem QuadItem(SeekBar.x + (SeekBar.w-10.0f)*Ratio, SeekBar.y, UI()->PixelSize(), SeekBar.h); Graphics()->QuadsDrawTL(&QuadItem, 1); Graphics()->QuadsEnd(); } // draw slice markers // begin if (g_Config.m_ClDemoSliceBegin != -1) { float Ratio = (g_Config.m_ClDemoSliceBegin-pInfo->m_FirstTick) / (float)TotalTicks; Graphics()->TextureSet(-1); Graphics()->QuadsBegin(); Graphics()->SetColor(1.0f, 0.0f, 0.0f, 1.0f); IGraphics::CQuadItem QuadItem(10.0f + SeekBar.x + (SeekBar.w-10.0f)*Ratio, SeekBar.y, UI()->PixelSize(), SeekBar.h); Graphics()->QuadsDrawTL(&QuadItem, 1); Graphics()->QuadsEnd(); } // end if (g_Config.m_ClDemoSliceEnd != -1) { float Ratio = (g_Config.m_ClDemoSliceEnd-pInfo->m_FirstTick) / (float)TotalTicks; Graphics()->TextureSet(-1); Graphics()->QuadsBegin(); Graphics()->SetColor(1.0f, 0.0f, 0.0f, 1.0f); IGraphics::CQuadItem QuadItem(10.0f + SeekBar.x + (SeekBar.w-10.0f)*Ratio, SeekBar.y, UI()->PixelSize(), SeekBar.h); Graphics()->QuadsDrawTL(&QuadItem, 1); Graphics()->QuadsEnd(); } // draw time str_format(aBuffer, sizeof(aBuffer), "%d:%02d / %d:%02d", CurrentTick/SERVER_TICK_SPEED/60, (CurrentTick/SERVER_TICK_SPEED)%60, TotalTicks/SERVER_TICK_SPEED/60, (TotalTicks/SERVER_TICK_SPEED)%60); UI()->DoLabel(&SeekBar, aBuffer, SeekBar.h*0.70f, 0); // do the logic int Inside = UI()->MouseInside(&SeekBar); if(UI()->ActiveItem() == id) { if(!UI()->MouseButton(0)) UI()->SetActiveItem(0); else { static float PrevAmount = 0.0f; float Amount = (UI()->MouseX()-SeekBar.x)/(float)SeekBar.w; if(Input()->KeyPressed(KEY_LSHIFT) || Input()->KeyPressed(KEY_RSHIFT)) { Amount = PrevAmount + (Amount-PrevAmount) * 0.05f; if(Amount > 0.0f && Amount < 1.0f && absolute(PrevAmount-Amount) >= 0.0001f) { //PrevAmount = Amount; m_pClient->OnReset(); m_pClient->m_SuppressEvents = true; DemoPlayer()->SetPos(Amount); m_pClient->m_SuppressEvents = false; m_pClient->m_pMapLayersBackGround->EnvelopeUpdate(); m_pClient->m_pMapLayersForeGround->EnvelopeUpdate(); } } else { if(Amount > 0.0f && Amount < 1.0f && absolute(PrevAmount-Amount) >= 0.001f) { PrevAmount = Amount; m_pClient->OnReset(); m_pClient->m_SuppressEvents = true; DemoPlayer()->SetPos(Amount); m_pClient->m_SuppressEvents = false; m_pClient->m_pMapLayersBackGround->EnvelopeUpdate(); m_pClient->m_pMapLayersForeGround->EnvelopeUpdate(); } } } } else if(UI()->HotItem() == id) { if(UI()->MouseButton(0)) UI()->SetActiveItem(id); } if(Inside) UI()->SetHotItem(id); } if(CurrentTick == TotalTicks) { m_pClient->OnReset(); DemoPlayer()->Pause(); DemoPlayer()->SetPos(0); } bool IncreaseDemoSpeed = false, DecreaseDemoSpeed = false; // do buttons CUIRect Button; // combined play and pause button ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar); static int s_PlayPauseButton = 0; if(!pInfo->m_Paused) { if(DoButton_Sprite(&s_PlayPauseButton, IMAGE_DEMOBUTTONS, SPRITE_DEMOBUTTON_PAUSE, false, &Button, CUI::CORNER_ALL)) DemoPlayer()->Pause(); } else { if(DoButton_Sprite(&s_PlayPauseButton, IMAGE_DEMOBUTTONS, SPRITE_DEMOBUTTON_PLAY, false, &Button, CUI::CORNER_ALL)) DemoPlayer()->Unpause(); } // stop button ButtonBar.VSplitLeft(Margins, 0, &ButtonBar); ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar); static int s_ResetButton = 0; if(DoButton_Sprite(&s_ResetButton, IMAGE_DEMOBUTTONS, SPRITE_DEMOBUTTON_STOP, false, &Button, CUI::CORNER_ALL)) { m_pClient->OnReset(); DemoPlayer()->Pause(); DemoPlayer()->SetPos(0); } // slowdown ButtonBar.VSplitLeft(Margins, 0, &ButtonBar); ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar); static int s_SlowDownButton = 0; if(DoButton_Sprite(&s_SlowDownButton, IMAGE_DEMOBUTTONS, SPRITE_DEMOBUTTON_SLOWER, 0, &Button, CUI::CORNER_ALL) || Input()->KeyPresses(KEY_MOUSE_WHEEL_DOWN)) DecreaseDemoSpeed = true; // fastforward ButtonBar.VSplitLeft(Margins, 0, &ButtonBar); ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar); static int s_FastForwardButton = 0; if(DoButton_Sprite(&s_FastForwardButton, IMAGE_DEMOBUTTONS, SPRITE_DEMOBUTTON_FASTER, 0, &Button, CUI::CORNER_ALL)) IncreaseDemoSpeed = true; // speed meter ButtonBar.VSplitLeft(Margins*3, 0, &ButtonBar); char aBuffer[64]; if(pInfo->m_Speed >= 1.0f) str_format(aBuffer, sizeof(aBuffer), "×%.0f", pInfo->m_Speed); else str_format(aBuffer, sizeof(aBuffer), "×%.2f", pInfo->m_Speed); UI()->DoLabel(&ButtonBar, aBuffer, Button.h*0.7f, -1); // slice begin button ButtonBar.VSplitLeft(Margins*10, 0, &ButtonBar); ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar); static int s_SliceBeginButton = 0; if(DoButton_Sprite(&s_SliceBeginButton, IMAGE_DEMOBUTTONS2, SPRITE_DEMOBUTTON_SLICE_BEGIN, 0, &Button, CUI::CORNER_ALL)) Client()->DemoSliceBegin(); // slice end button ButtonBar.VSplitLeft(Margins, 0, &ButtonBar); ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar); static int s_SliceEndButton = 0; if(DoButton_Sprite(&s_SliceEndButton, IMAGE_DEMOBUTTONS2, SPRITE_DEMOBUTTON_SLICE_END, 0, &Button, CUI::CORNER_ALL)) Client()->DemoSliceEnd(); // slice save button ButtonBar.VSplitLeft(Margins, 0, &ButtonBar); ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar); static int s_SliceSaveButton = 0; if(DoButton_Sprite(&s_SliceSaveButton, IMAGE_FILEICONS, SPRITE_FILE_DEMO2, 0, &Button, CUI::CORNER_ALL)) { str_copy(m_aCurrentDemoFile, m_lDemos[m_DemolistSelectedIndex].m_aFilename, sizeof(m_aCurrentDemoFile)); m_aDemoPlayerPopupHint[0] = '\0'; m_DemoPlayerState = DEMOPLAYER_SLICE_SAVE; } // close button ButtonBar.VSplitRight(ButtonbarHeight*3, &ButtonBar, &Button); static int s_ExitButton = 0; if(DoButton_DemoPlayer(&s_ExitButton, Localize("Close"), 0, &Button)) { Client()->Disconnect(); DemolistPopulate(); DemolistOnUpdate(false); } // demo name char aDemoName[64] = {0}; DemoPlayer()->GetDemoName(aDemoName, sizeof(aDemoName)); char aBuf[128]; str_format(aBuf, sizeof(aBuf), Localize("Demofile: %s"), aDemoName); CTextCursor Cursor; TextRender()->SetCursor(&Cursor, NameBar.x, NameBar.y, Button.h*0.5f, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END); Cursor.m_LineWidth = MainView.w; TextRender()->TextEx(&Cursor, aBuf, -1); if(IncreaseDemoSpeed) { if(pInfo->m_Speed < 0.1f) DemoPlayer()->SetSpeed(0.1f); else if(pInfo->m_Speed < 0.25f) DemoPlayer()->SetSpeed(0.25f); else if(pInfo->m_Speed < 0.5f) DemoPlayer()->SetSpeed(0.5f); else if(pInfo->m_Speed < 0.75f) DemoPlayer()->SetSpeed(0.75f); else if(pInfo->m_Speed < 1.0f) DemoPlayer()->SetSpeed(1.0f); else if(pInfo->m_Speed < 2.0f) DemoPlayer()->SetSpeed(2.0f); else if(pInfo->m_Speed < 4.0f) DemoPlayer()->SetSpeed(4.0f); else DemoPlayer()->SetSpeed(8.0f); LastSpeedChange = time_get(); } else if(DecreaseDemoSpeed) { if(pInfo->m_Speed > 4.0f) DemoPlayer()->SetSpeed(4.0f); else if(pInfo->m_Speed > 2.0f) DemoPlayer()->SetSpeed(2.0f); else if(pInfo->m_Speed > 1.0f) DemoPlayer()->SetSpeed(1.0f); else if(pInfo->m_Speed > 0.75f) DemoPlayer()->SetSpeed(0.75f); else if(pInfo->m_Speed > 0.5f) DemoPlayer()->SetSpeed(0.5f); else if(pInfo->m_Speed > 0.25f) DemoPlayer()->SetSpeed(0.25f); else if(pInfo->m_Speed > 0.1f) DemoPlayer()->SetSpeed(0.1f); else DemoPlayer()->SetSpeed(0.05f); LastSpeedChange = time_get(); } }
int CALLBACK WinMain( _In_ HINSTANCE hInstance, _In_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nCmdShow) { int flags = 0; dfDeltaTime = 43.f; ScreenResolution.x = 800.f; ScreenResolution.y = 600.f; GameResolution.x = 640.f; GameResolution.y = 480.f; if( SDL_Init( SDL_INIT_VIDEO ) < 0 ) { printf( "Video initialization failed: %s\n", SDL_GetError( ) ); GameExit( 1 ); } if( SDL_Init( SDL_INIT_JOYSTICK ) < 0 ) { printf( "Input initialization failed: %s\n", SDL_GetError( ) ); GameExit( 1 ); } if( SDL_Init( SDL_INIT_GAMECONTROLLER ) < 0 ) { printf( "Input initialization failed: %s\n", SDL_GetError( ) ); GameExit( 1 ); } if( SDL_Init( SDL_INIT_AUDIO ) < 0 ) { printf( "Audio initialization failed: %s\n", SDL_GetError( ) ); GameExit( 1 ); } //Initialize SDL_mixer if( Mix_OpenAudio( 44100, MIX_DEFAULT_FORMAT, 2, 2048 ) < 0 ) { printf( "SDL_mixer could not initialize! SDL_mixer Error: %s\n", Mix_GetError() ); GameExit( 1 ); } SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 ); SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 ); SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 ); SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 ); SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); //flags = SDL_WINDOW_FULLSCREEN | SDL_WINDOW_OPENGL; flags = SDL_WINDOW_OPENGL; RenderSystem::window = SDL_CreateWindow("Dufresne", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, ScreenResolution.x, ScreenResolution.y, flags); flags = IMG_INIT_JPG | IMG_INIT_PNG; int initted = IMG_Init(flags); if(initted & flags != flags) { printf("Failed to Init SDL Image\n"); printf("IMG_Init: %s\n", IMG_GetError()); GameExit( 1 ); // handle error } // init gl SDL_GLContext glcontext; glcontext = SDL_GL_CreateContext(RenderSystem::window); GLint GlewInitResult = glewInit(); if (GlewInitResult != GLEW_OK) { printf("ERROR: %s\n",glewGetErrorString(GlewInitResult)); GameExit( 1 ); } glEnable(GL_TEXTURE_2D); tinyjson_init(); InitEngine(); assMan = AssetManager(); std::wstring path = L"fart\\"; assMan.CalculateLoosePackageSize(path); assMan.LoadLoosePackage(path); assMan.DebugTestWritePoolToFile(); sfxMan = SoundSystem(); sfxMan.Init(); sceneMan.Init(); input = Input(); input.Init(); dfScene* scene1 = sceneMan.CreateScene("scene-left"); dfScene* scene2 = sceneMan.CreateScene("scene-right"); scene1->setupFunc = &SetupScene1; scene2->setupFunc = &SetupScene2; sceneMan.LoadScene(scene1); Uint32 previousMiliseconds = 0; while(true) { Uint32 currentMiliseconds = SDL_GetTicks(); dfRandomFloat = dfRand(); dfTotalTime = currentMiliseconds / 1000.f; dfDeltaTime = (currentMiliseconds / 1000.f) - (previousMiliseconds / 1000.f); if(testDude->tf.rectangle.left > GameResolution.x) { sceneMan.LoadScene(scene2); } if(testDude->tf.rectangle.right < 0) { sceneMan.LoadScene(scene1); } if(input.keyboard.n1.tapped) { sceneMan.renderer.UpdateResolution(640, 480); } if(input.keyboard.n2.tapped) { sceneMan.renderer.UpdateResolution(300, 300); } if(input.keyboard.n3.tapped) { sceneMan.renderer.UpdateResolution(450, 300); } input.Update(); sceneMan.Update(); SDL_GL_SwapWindow(RenderSystem::window); } return 0; }
CMenus::CListboxItem CMenus::UiDoListboxNextItem(const void *pId, bool Selected, bool KeyEvents) { int ThisItemIndex = gs_ListBoxItemIndex; if(Selected) { if(gs_ListBoxSelectedIndex == gs_ListBoxNewSelected) gs_ListBoxNewSelected = ThisItemIndex; gs_ListBoxSelectedIndex = ThisItemIndex; } CListboxItem Item = UiDoListboxNextRow(); if(Item.m_Visible && UI()->DoButtonLogic(pId, "", gs_ListBoxSelectedIndex == gs_ListBoxItemIndex, &Item.m_HitRect)) gs_ListBoxNewSelected = ThisItemIndex; // process input, regard selected index if(gs_ListBoxSelectedIndex == ThisItemIndex) { if(!gs_ListBoxDoneEvents) { gs_ListBoxDoneEvents = 1; if(m_EnterPressed || (UI()->ActiveItem() == pId && Input()->MouseDoubleClick())) { gs_ListBoxItemActivated = true; UI()->SetActiveItem(0); } else if(KeyEvents) { for(int i = 0; i < m_NumInputEvents; i++) { int NewIndex = -1; if(m_aInputEvents[i].m_Flags&IInput::FLAG_PRESS) { if(m_aInputEvents[i].m_Key == KEY_DOWN) NewIndex = gs_ListBoxNewSelected + 1; if(m_aInputEvents[i].m_Key == KEY_UP) NewIndex = gs_ListBoxNewSelected - 1; } if(NewIndex > -1 && NewIndex < gs_ListBoxNumItems) { // scroll float Offset = (NewIndex/gs_ListBoxItemsPerRow-gs_ListBoxNewSelected/gs_ListBoxItemsPerRow)*gs_ListBoxRowHeight; int Scroll = gs_ListBoxOriginalView.y > Item.m_Rect.y+Offset ? -1 : gs_ListBoxOriginalView.y+gs_ListBoxOriginalView.h < Item.m_Rect.y+Item.m_Rect.h+Offset ? 1 : 0; if(Scroll) { int NumViewable = (int)(gs_ListBoxOriginalView.h/gs_ListBoxRowHeight) + 1; int ScrollNum = (gs_ListBoxNumItems+gs_ListBoxItemsPerRow-1)/gs_ListBoxItemsPerRow-NumViewable+1; if(Scroll < 0) { int Num = (gs_ListBoxOriginalView.y-Item.m_Rect.y-Offset+gs_ListBoxRowHeight-1.0f)/gs_ListBoxRowHeight; gs_ListBoxScrollValue -= (1.0f/ScrollNum)*Num; } else { int Num = (Item.m_Rect.y+Item.m_Rect.h+Offset-(gs_ListBoxOriginalView.y+gs_ListBoxOriginalView.h)+gs_ListBoxRowHeight-1.0f)/ gs_ListBoxRowHeight; gs_ListBoxScrollValue += (1.0f/ScrollNum)*Num; } if(gs_ListBoxScrollValue < 0.0f) gs_ListBoxScrollValue = 0.0f; if(gs_ListBoxScrollValue > 1.0f) gs_ListBoxScrollValue = 1.0f; } gs_ListBoxNewSelected = NewIndex; } } } } //selected_index = i; CUIRect r = Item.m_Rect; r.Margin(1.5f, &r); RenderTools()->DrawUIRect(&r, vec4(1,1,1,0.5f), CUI::CORNER_ALL, 4.0f); } return Item; }
Usage(USB_HID_KEYBOARD), Collection(USB_HID_APPLICATION), ReportID(1), // // Modifier keys. // 8 - 1 bit values indicating the modifier keys (ctrl, shift...) // ReportSize(1), ReportCount(8), UsagePage(USB_HID_USAGE_KEYCODES), UsageMinimum(224), UsageMaximum(231), LogicalMinimum(0), LogicalMaximum(1), Input(USB_HID_INPUT_DATA | USB_HID_INPUT_VARIABLE | USB_HID_INPUT_ABS), // // One byte of rsvd data required by HID spec. // ReportCount(1), ReportSize(8), Input(USB_HID_INPUT_CONSTANT), // // Keyboard LEDs. // 5 - 1 bit values. // ReportCount(5), ReportSize(1), UsagePage(USB_HID_USAGE_LEDS),
void CMapLayers::OnRender() { if(Client()->State() != IClient::STATE_ONLINE && Client()->State() != IClient::STATE_DEMOPLAYBACK) return; CUIRect Screen; Graphics()->GetScreen(&Screen.x, &Screen.y, &Screen.w, &Screen.h); vec2 Center = m_pClient->m_pCamera->m_Center; //float center_x = gameclient.camera->center.x; //float center_y = gameclient.camera->center.y; bool PassedGameLayer = false; for(int g = 0; g < m_pLayers->NumGroups(); g++) { CMapItemGroup *pGroup = m_pLayers->GetGroup(g); if(!g_Config.m_GfxNoclip && pGroup->m_Version >= 2 && pGroup->m_UseClipping) { // set clipping float Points[4]; MapScreenToGroup(Center.x, Center.y, m_pLayers->GameGroup()); Graphics()->GetScreen(&Points[0], &Points[1], &Points[2], &Points[3]); float x0 = (pGroup->m_ClipX - Points[0]) / (Points[2]-Points[0]); float y0 = (pGroup->m_ClipY - Points[1]) / (Points[3]-Points[1]); float x1 = ((pGroup->m_ClipX+pGroup->m_ClipW) - Points[0]) / (Points[2]-Points[0]); float y1 = ((pGroup->m_ClipY+pGroup->m_ClipH) - Points[1]) / (Points[3]-Points[1]); Graphics()->ClipEnable((int)(x0*Graphics()->ScreenWidth()), (int)(y0*Graphics()->ScreenHeight()), (int)((x1-x0)*Graphics()->ScreenWidth()), (int)((y1-y0)*Graphics()->ScreenHeight())); } MapScreenToGroup(Center.x, Center.y, pGroup); for(int l = 0; l < pGroup->m_NumLayers; l++) { CMapItemLayer *pLayer = m_pLayers->GetLayer(pGroup->m_StartLayer+l); bool Render = false; bool IsGameLayer = false; if(pLayer == (CMapItemLayer*)m_pLayers->GameLayer()) { IsGameLayer = true; PassedGameLayer = 1; } // skip rendering if detail layers if not wanted if(pLayer->m_Flags&LAYERFLAG_DETAIL && !g_Config.m_GfxHighDetail && !IsGameLayer) continue; if(m_Type == -1) Render = true; else if(m_Type == 0) { if(PassedGameLayer) return; Render = true; } else { if(PassedGameLayer && !IsGameLayer) Render = true; } if(Render && pLayer->m_Type == LAYERTYPE_TILES && Input()->KeyPressed(KEY_LCTRL) && Input()->KeyPressed(KEY_LSHIFT) && Input()->KeyDown(KEY_KP0)) { CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer; CTile *pTiles = (CTile *)m_pLayers->Map()->GetData(pTMap->m_Data); CServerInfo CurrentServerInfo; Client()->GetServerInfo(&CurrentServerInfo); char aFilename[256]; str_format(aFilename, sizeof(aFilename), "dumps/tilelayer_dump_%s-%d-%d-%dx%d.txt", CurrentServerInfo.m_aMap, g, l, pTMap->m_Width, pTMap->m_Height); IOHANDLE File = Storage()->OpenFile(aFilename, IOFLAG_WRITE, IStorage::TYPE_SAVE); if(File) { #if defined(CONF_FAMILY_WINDOWS) static const char Newline[] = "\r\n"; #else static const char Newline[] = "\n"; #endif for(int y = 0; y < pTMap->m_Height; y++) { for(int x = 0; x < pTMap->m_Width; x++) io_write(File, &(pTiles[y*pTMap->m_Width + x].m_Index), sizeof(pTiles[y*pTMap->m_Width + x].m_Index)); io_write(File, Newline, sizeof(Newline)-1); } io_close(File); } } if(Render && !IsGameLayer) { //layershot_begin(); if(pLayer->m_Type == LAYERTYPE_TILES) { CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer; if(pTMap->m_Image == -1) Graphics()->TextureSet(-1); else Graphics()->TextureSet(m_pClient->m_pMapimages->Get(pTMap->m_Image)); CTile *pTiles = (CTile *)m_pLayers->Map()->GetData(pTMap->m_Data); Graphics()->BlendNone(); RenderTools()->RenderTilemap(pTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, vec4(1,1,1,1), TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_OPAQUE); Graphics()->BlendNormal(); RenderTools()->RenderTilemap(pTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, vec4(1,1,1,1), TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_TRANSPARENT); } else if(pLayer->m_Type == LAYERTYPE_QUADS) { CMapItemLayerQuads *pQLayer = (CMapItemLayerQuads *)pLayer; if(pQLayer->m_Image == -1) Graphics()->TextureSet(-1); else Graphics()->TextureSet(m_pClient->m_pMapimages->Get(pQLayer->m_Image)); CQuad *pQuads = (CQuad *)m_pLayers->Map()->GetDataSwapped(pQLayer->m_Data); Graphics()->BlendNone(); RenderTools()->RenderQuads(pQuads, pQLayer->m_NumQuads, LAYERRENDERFLAG_OPAQUE, EnvelopeEval, this); Graphics()->BlendNormal(); RenderTools()->RenderQuads(pQuads, pQLayer->m_NumQuads, LAYERRENDERFLAG_TRANSPARENT, EnvelopeEval, this); } //layershot_end(); } } if(!g_Config.m_GfxNoclip) Graphics()->ClipDisable(); } if(!g_Config.m_GfxNoclip) Graphics()->ClipDisable(); // reset the screen like it was before Graphics()->MapScreen(Screen.x, Screen.y, Screen.w, Screen.h); }
/* Create DOS Partition Interface */ int Create_DOS_Partition_Interface(int type) { int numeric_type; int partition_created=FALSE; int partition_slot_just_used; long maximum_partition_size_in_MB; long maximum_possible_percentage; unsigned long input=0; Partition_Table *pDrive = &part_table[flags.drive_number-0x80]; maximum_partition_size_in_MB = Max_Pri_Part_Size_In_MB(type); if(type==PRIMARY) { Clear_Screen(0); Print_Centered(4,"Create Primary DOS Partition",BOLD); printAt(4,6,"Current fixed disk drive: "); cprintf("%d",(flags.drive_number-127)); printAt(4,8,"Do you wish to use the maximum available size for a Primary DOS Partition"); if((flags.drive_number-128)==0) { printAt(4,9,"and make the partition active (Y/N).....................? "); } else { printAt(4,9,"(Y/N)...................................................? "); } flags.esc=FALSE; input=Input(1,62,9,YN,0,0,ESCR,1,0,NULL,NULL); if(flags.esc==TRUE) return(1); if(input==1) { input=maximum_partition_size_in_MB; numeric_type=6; /* Set the numeric type to 6 so that it will be */ /* decided by Partition_Type_To_Create(). */ if( (flags.fprmt==TRUE) && (type==PRIMARY) && (input>=128) && (input<=2048) ) { printAt(4,22,"This drive is a FAT32 by default, switch to FAT16 (Y/N)? "); flags.fat32=!Input(1,61,22,YN,0,0,NONE,1,0,NULL,NULL); } /* Use the maximum available free space to create a DOS Partition */ /* Adjust numeric type depending upon partition size and the FDISK */ /* version emulated. */ numeric_type=Partition_Type_To_Create(input,numeric_type); partition_slot_just_used=Create_Primary_Partition(numeric_type,input); if((flags.drive_number-128)==0) Set_Active_Partition(partition_slot_just_used); partition_created=TRUE; } } if(partition_created==FALSE) { Clear_Screen(0); if(type==PRIMARY) Print_Centered(4,"Create Primary DOS Partition",BOLD); else Print_Centered(4,"Create Extended DOS Partition",BOLD); printAt(4,6,"Current fixed disk drive: "); cprintf("%d",(flags.drive_number-127)); Display_Primary_Partition_Information_SS(); printAt(4,15,"Maximum space available for partition is "); if( (flags.version==W95) || (flags.version==W95B) || (flags.version==W98) ) Print_UL_B(maximum_partition_size_in_MB); else cprintf("%4d",maximum_partition_size_in_MB); printf(" Mbytes "); maximum_possible_percentage = Convert_To_Percentage(maximum_partition_size_in_MB ,pDrive->total_hard_disk_size_in_MB); cprintf("(%3d%%)",maximum_possible_percentage); printAt(4,18,"Enter partition size in Mbytes or percent of disk space (%) to"); if(type==PRIMARY) printAt(4,19,"create a Primary DOS Partition.................................: "); else printAt(4,19,"create an Extended DOS Partition...............................: "); flags.esc=FALSE; if( (flags.version==4) || (flags.version==5) || (flags.version==6) ) input=Input(4,69,19,NUMP,1,maximum_partition_size_in_MB,ESCR ,maximum_partition_size_in_MB,maximum_possible_percentage,NULL,NULL); else input=Input(6,69,19,NUMP,1,maximum_partition_size_in_MB,ESCR ,maximum_partition_size_in_MB,maximum_possible_percentage,NULL,NULL); if(flags.esc==TRUE) return(1); if( (flags.fprmt==TRUE) && (type==PRIMARY) && (input>=128) && (input<=2048) ) { printAt(4,22,"This drive is a FAT32 by default, switch to FAT16 (Y/N)? "); flags.fat32=!Input(1,61,22,YN,0,0,NONE,1,0,NULL,NULL); } if(type==PRIMARY) numeric_type=Partition_Type_To_Create(input,0); else numeric_type=5; Create_Primary_Partition(numeric_type,input); } if(flags.fprmt==TRUE) flags.fat32=FALSE; Clear_Screen(0); if(type==PRIMARY) Print_Centered(4,"Create Primary DOS Partition",BOLD); else Print_Centered(4,"Create Extended DOS Partition",BOLD); printAt(4,6,"Current fixed disk drive: "); cprintf("%d",(flags.drive_number-127)); Display_Primary_Partition_Information_SS(); Position_Cursor(4,21); if(type==PRIMARY) cprintf("Primary DOS Partition created"); else cprintf("Extended DOS Partition created"); Input(0,0,0,ESC,0,0,ESCC,0,0,NULL,NULL); if(type==EXTENDED) Create_Logical_Drive_Interface(); return(0); }