void game_hub::hubMenu() { bool hubMenu = true; while (hubMenu) { printf("Hub Menu\n"); printf("----------------------\n"); int menu_sel = getSel("1. Open Party Menu", "2. Manage Characters", "3. Save Game", "4. Cancel"); switch (menu_sel) { case 1://Open party menu { Team->partyMenu(); break; } case 2://Manage Characters { Team->managePlayers(); break; } case 3://Save Game { saveGame(); break; } case 4://Cancel { printf("Cancelling action...\n"); hubMenu = false; break; } } } }
void Editor::en_msgfilter( NMHDR *nmhdr,LRESULT *result ){ if( locked || fmtBusy ){ *result=1;return; } *result=0; getSel(); MSGFILTER *msg=(MSGFILTER*)nmhdr; if( msg->msg==WM_RBUTTONDOWN ){ CPoint p( LOWORD(msg->lParam),HIWORD(msg->lParam) ); ClientToScreen( &p ); CMenu *menu=blitzIDE.mainFrame->GetMenu(); CMenu *edit=menu->GetSubMenu(1); edit->TrackPopupMenu( TPM_LEFTALIGN,p.x,p.y,blitzIDE.mainFrame ); }else if( msg->msg==WM_CHAR ){ if( msg->wParam=='\t' ){ bool holding_shift=GetAsyncKeyState( VK_SHIFT )&0x80000000; int lineStart=editCtrl.LineFromChar( selStart ); int lineEnd=editCtrl.LineFromChar( selEnd-1 ); if( lineEnd<=lineStart && !holding_shift ) return; editCtrl.HideSelection( true,false ); if( holding_shift ){ char buff[4]; for( int line=lineStart;line<=lineEnd;++line ){ int n=editCtrl.LineIndex( line ); editCtrl.SetSel( n,n+1 );editCtrl.GetSelText( buff ); if( buff[0]=='\t' ) editCtrl.ReplaceSel( "",true ); } }else{ for( int line=lineStart;line<=lineEnd;++line ){ int n=editCtrl.LineIndex( line ); editCtrl.SetSel( n,n );editCtrl.ReplaceSel( "\t",true ); } } selStart=editCtrl.LineIndex( lineStart ); selEnd=editCtrl.LineIndex( lineEnd+1 )-1; setSel();*result=1; editCtrl.HideSelection( false,false ); }else if( msg->wParam==13 ){ if( selStart!=selEnd ) return; int k; int ln=editCtrl.LineFromChar( selStart )-1; int pos=selStart-editCtrl.LineIndex( ln ); string line=getLine( ln );if( pos>line.size() ) return; for( k=0;k<pos && line[k]=='\t';++k ){} line=line.substr( 0,k )+'\0'; editCtrl.ReplaceSel( line.data(),true ); *result=1; } } caret(); }
void game_hub::areaMenu() { bool areaMenu = true; while (areaMenu) { int area_sel = getSel("1. Go to dungeons", "2. Go to random dungeon", "3. Return to town"); switch(area_sel) { case 1: { printAreas(); printf("%d. Cancel\n", active_areas+1); int sel = getSel(active_areas+1); if (sel < active_areas+1) { sel--; //Dungeons[sel]->dungeon_loop(); Dungeons[sel]->enter_area(); areaMenu = false; } else printf("Cancelling action...\n"); break; } case 2: { rand_dungeon = new areas; rand_dungeon->setArea("Random Dungeon", 4, Team); //rand_dungeon->dungeon_loop(); rand_dungeon->enter_area(); areaMenu = false; delete rand_dungeon; rand_dungeon = NULL; break; } case 3: { printf("Returning to town...\n"); areaMenu = false; break; } } } incrementAreas(); }
void game_hub::startGame() { printf("Would you like to start a new game, or load a previous save?\n"); int sel = getSel("1. New Game", "2. Load Game"); if (sel == 1) newGame(); else loadGame(); }
void Editor::fixFmt( bool fmt ){ if( lineToFmt<0 || fmtBusy ) return; fmtBusy=true; editCtrl.HideSelection( true,false );getSel(); long start=selStart;if( fmt ) selStart=-1; formatLine( lineToFmt ); selStart=start;setSel();editCtrl.HideSelection( false,false ); fmtBusy=false; }
void Editor::print(){ static const int MARG=720; //1440=1 inch CPrintDialog dlg(false); int e=dlg.DoModal();if( e==IDCANCEL ) return; HDC hdc=dlg.GetPrinterDC(); if( !hdc ){ MessageBox( "Error printing" ); return; } int hr=GetDeviceCaps(hdc,HORZRES),vr=GetDeviceCaps(hdc,VERTRES); int px=GetDeviceCaps(hdc,LOGPIXELSX),py=GetDeviceCaps(hdc,LOGPIXELSY); SetMapMode(hdc,MM_TEXT); FORMATRANGE fr={0}; fr.hdc=fr.hdcTarget=hdc; fr.rcPage.left=fr.rcPage.top=0; fr.rcPage.right=(hr/px)*1440; fr.rcPage.bottom=(vr/py)*1440; //margins fr.rc.left=fr.rcPage.left+MARG; fr.rc.top=fr.rcPage.top+MARG; fr.rc.right=fr.rcPage.right-MARG; fr.rc.bottom=fr.rcPage.bottom-MARG; char buff[MAX_PATH]; strcpy( buff,name.c_str() ); DOCINFO di={sizeof(di)}; di.lpszDocName=buff; getSel(); int start=selStart,end=selEnd; if( start==end ){ start=0;end=editCtrl.GetTextLength(); } StartDoc(hdc,&di); while( start<end ){ StartPage(hdc); fr.chrg.cpMin=start; fr.chrg.cpMax=end; start=editCtrl.FormatRange(&fr,true); EndPage(hdc); } EndDoc(hdc); editCtrl.FormatRange(0,false); DeleteDC(hdc); }
int main(int argc, char *argv[]) { double start,finish,result,precise; setDefaults(getSel(argc,argv)); printf(" -> Starting sequence with %ld ...\n",maxval); start = getCurrTime(); primecount(maxval); finish = getCurrTime(); result = (finish - start)/lts2; //printf("\nResult is: %6.3lf.\n",result); precise = abs(lts1 - result); printf("\nResult is: %6.3lf.\n",precise); return (int)(result/1); }
void game_hub::saveGame() { printf("Do you want to save your game?\n"); int sel = getSel("1. Yes", "2. No"); if (sel == 2) return; printf("Saving game...\n"); FILE *fp; fp = fopen("./files/Game_save.txt", "w"); fprintf(fp, "%d %d", active_areas, active_shops); fclose(fp); Team->saveParty(); Home->saveHome(); fp = fopen("./files/QuestHall_save.txt", "w"); Hall->saveQuestHall(fp); fclose(fp); }
string Editor::getKeyword(){ fixFmt(true); getSel(); int ln=editCtrl.LineFromChar(selStart); int pos=selStart-editCtrl.LineIndex( ln ); string line=getLine( ln );if( pos>line.size() ) return ""; //ok, scan back until we have an isapha char preceded by a nonalnum/non '_' char for(;;){ while( pos>0 && ( !isalpha(line[pos]) || isid(line[pos-1]) ) ) --pos; if( !isalpha(line[pos]) ) return ""; int end=pos;while( end<line.size() && isid(line[end]) ) ++end; string t=line.substr( pos,end-pos ); if( keyWordSet.find( t )!=keyWordSet.end() ) return t; if( !pos ) return ""; --pos; } }
void Editor::hilight( int pos ){ int row=(pos>>16)&0xffff,col=pos&0xffff; pos=editCtrl.LineIndex( row )+col; editCtrl.HideSelection( true,false ); getSel(); bool quote=false; int end=pos,len=editCtrl.GetTextLength(); while( end<len ){ char temp[8]; editCtrl.SetSel( end,end+1 ); editCtrl.GetSelText( temp ); if( temp[0]=='\"' ) quote=!quote; if( !quote && (temp[0]==':' || !isprint( temp[0] )) ) break; ++end; } editCtrl.HideSelection( false,false ); editCtrl.SetSel( pos,end ); }
void Editor::en_change(){ if( fmtBusy ) return; fmtBusy=true; editCtrl.HideSelection( true,false ); getSel(); int begin=editCtrl.LineFromChar( selStart ); int end=begin+1; int lineCount=editCtrl.GetLineCount(); int delta=lineCount-fmtLineCount; if( delta>0 ){ begin-=delta; funcList.relocate( begin,delta ); typeList.relocate( begin,delta ); labsList.relocate( begin,delta ); funcList.remove( begin,end ); typeList.remove( begin,end ); labsList.remove( begin,end ); }else if( delta<0 ){ int t=end-delta; funcList.remove( begin,t ); typeList.remove( begin,t ); labsList.remove( begin,t ); funcList.relocate( t,delta ); typeList.relocate( t,delta ); labsList.relocate( t,delta ); }else{ funcList.remove( begin,end ); typeList.remove( begin,end ); labsList.remove( begin,end ); } for( int n=begin;n<end;++n ) formatLine( n ); setSel();editCtrl.HideSelection( false,false ); fmtBusy=false; cursorMoved(); }
void game_hub::shopMenu() { bool shopMenu = true; while(shopMenu) { printShops(); printf("%d. Return to town\n", active_shops+1); int sel = getSel(active_shops+1); if (sel < active_shops+1) { sel--; Shops[sel]->enterShop(Team); } else { printf("Returning to town...\n"); shopMenu = false; } } incrementShops(); }
void game_hub::gameLoop() { startGame(); bool in_town = true; while (in_town) { printf("Hub Town\n"); printf("----------------------\n"); int hub_sel = getSel("1. Free Exploration", "2. Marketplace", "3. Quest Hall", "4. Inn", "5. Home", "6. Open Menu", "7. Quit"); switch (hub_sel) { case 1://Free Exploration { areaMenu(); break; } case 2://Marketplace { shopMenu(); // Shops[0]->enterShop(Team); break; } case 3://Quest Hall { Hall->enterQuestHall(Team); break; //-------------------------------------------- printf("Welcome to the quest hall, what would you like to do?\n"); int sel = getSel("1. Recruit new party member", "2. Take Quest", "3. Leave"); if (sel == 1) { printf("\n"); int sel_c = getSel("1. Make new player", "2. Make random player", "3. Cancel action"); switch(sel_c) { case 1: { player *player_n = getNewPlayer(); player *test; test = Team->recievePlayer(player_n); if (test != NULL) delete test; break; } case 2: { printf("**DEBUG** Generating random party member...\n"); player *random = getRandomPlayer(); player *test; test = Team->recievePlayer(random); if (test != NULL) delete test; break; } /* case 3: { quest *temp = getQuest(1); printf("Accept quest: '%s'?\n", temp->getName()); int sel = getSel("1. Yes", "2. No"); if (sel == 1) { Team->acceptQuest(temp); } else { printf("Did not accept '%s'...\n", temp->getName()); delete temp; } break; } */ case 3: { printf("Cancelling action...\n"); break; } } } else if (sel == 2) { quest *temp = getQuest(1); printf("Accept quest: '%s'?\n", temp->getName()); int sel = getSel("1. Yes", "2. No"); if (sel == 1) { Team->acceptQuest(temp); } else { printf("Did not accept '%s'...\n", temp->getName()); delete temp; } } else printf("Leaving quest hall...\n"); break; } case 4://Inn { Inn->enterInn(Team); break; } case 5://Home { Home->enterHome(Team); break; } case 6://Open Menu { hubMenu(); break; } case 7: { printf("Are you sure you want to quit?\n"); int sel = getSel("1. Yes", "2. No"); if (sel == 1) in_town = false; else printf("Cancelling action...\n"); break; } } if (Team->checkGameOver()) { printf("Game Over..."); in_town = false; } } }
int ListaAsteroides::getSel() { for(int i=0;i<lista.size();i++) if(getSel(i)) return i+1; return 0; }
int ListaNaves::getSels() { int i=0; for(int j=0;j<lista.size();j++) if(getSel(j)) i++; return i; }
bool Editor::canCutCopy(){ getSel();return selStart!=selEnd; }