bool Archive::Open(std::string filename,bool bWriteMode) { if (Loading() || Saving()) Close(); this->bWriteMode = bWriteMode; this->bTextMode = Utils::ToLower(filename).find(".xml")!=std::string::npos; bool bZip = Utils::ToLower(filename).find( ".gz")!=std::string::npos; std::string smode=std::string(bWriteMode?"w":"r") + std::string((bTextMode && !bZip)?"t":"b") ; this->file=0; this->gzfile=0; if (!bZip) { this->file=fopen(filename.c_str(),smode.c_str()); if (!this->file) return false; } else { this->gzfile=gzopen(filename.c_str(),smode.c_str()); if (!this->gzfile) return false; } //if xml output, prepare the XML document if (bTextMode) { TiXmlDocument* xml_doc =new TiXmlDocument; if (Saving()) { xml_doc->LinkEndChild( new TiXmlDeclaration( "1.0", "", "" ) ); xml_doc->LinkEndChild( new TiXmlElement("root") ); } if (Loading()) { unsigned long filesize; unsigned char* content=FileSystem::ReadFile(filename.c_str(),filesize,true); if (!xml_doc->Parse((const char*)content)) { Log::printf("Failed of open_xml for file %s ErrorRow(%d) ErrorCol(%d) ErrorDesc(%s)",filename.c_str(),(int)xml_doc->ErrorRow(),(int)xml_doc->ErrorCol(),xml_doc->ErrorDesc()); Close(); return false; } } StackItem stack_doc ={"xml_doc",xml_doc ,0};xml_objects.push(stack_doc ); StackItem stack_root={"root" ,xml_doc->FirstChildElement("root"),0};xml_objects.push(stack_root); } return true; }
void Archive::Push(std::string name) { if (bTextMode && Saving()) { TiXmlElement * xml_element = new TiXmlElement(name.c_str()); CURNODE->LinkEndChild(xml_element); StackItem stack_item={name,xml_element,0}; xml_objects.push(stack_item); return; } if (bTextMode && Loading()) { StackItem& current=xml_objects.top(); TiXmlNode* xml_child=((TiXmlNode*)current.first)->IterateChildren((TiXmlNode*)current.second); current.second=xml_child; StackItem stack_item={name,xml_child,0}; xml_objects.push(stack_item); return; } }
/************************************************* Function:主函数 Description: 调用各模块 Calls: // 被本函数调用的函数清单 Called By: // 调用本函数的函数清单 Input: // 输入参数说明,包括每个参数的作 // 用、取值说明及参数间关系。 Output: // 对输出参数的说明。 Return: // 函数返回值的说明 Others: *************************************************/ void main() { WorData *alphabet[26]={NULL}; int chioce=1; int loaded = NO; SetUp *setinfo=NULL; //参数要初始化 INTERFACE_COLOR_3; system("title MyPowerWord LinSoft"); system("mode con cols=90 lines=35"); if (Loading(alphabet) == NO) { printf("\nLoading Error 000"); return; } else { loaded = YES; } setinfo=LoadSetup(); if (setinfo->autoinsearch==YES) { system("cls"); printf("\nDo you want to set?(y/n):[ ]\b\b"); if (YesOrNo() == YES) { SetupModule(setinfo); } if (loaded == NO) { if (Loading(alphabet) == NO) { printf("\nLoading Error 001"); return; } } SearchMoulde(alphabet,setinfo); } else { while (1) //5.26 add { system("cls"); printf("\n\n\n1.Search\n2.Set up\n3.exit\n"); printf("Input you chioce:"); chioce=Select(1,3); switch(chioce) { case 1: { SearchMoulde(alphabet,setinfo); return; } case 2: { SetupModule(setinfo); break; } case 3:return; } } } //Destroy(alphabet); }
Archive::~Archive() { if (Saving() || Loading()) this->Close(); }
INT WINAPI wWinMain( HINSTANCE hInst, HINSTANCE, LPWSTR, INT ) // 프로그램 진입점 { WNDCLASSEX wc = // 윈도우 클래스 정의,등록 { sizeof( WNDCLASSEX ), CS_CLASSDC, MsgProc, 0L, 0L, GetModuleHandle( NULL ), NULL, NULL, NULL, NULL, "ProG", NULL }; RegisterClassEx( &wc ); HWND hWnd = CreateWindow( "ProG", "ProG", // 윈도우 생성 WS_BORDER | WS_SYSMENU, 0, 0, 1680, 1030, //// 좌표 변수 처리 NULL, NULL, wc.hInstance, NULL ); CDevice::GetInstance()->Init(hWnd, 1680, 1030); if( SUCCEEDED( InitD3D( hWnd ) ) ) // Direct3D초기화 { ShowWindow( hWnd, SW_SHOWDEFAULT ); // 윈도우 출력 UpdateWindow( hWnd ); MSG msg; while(true) // 메시지 루프 { if(PeekMessage(&msg, NULL,NULL, NULL, PM_REMOVE)) { TranslateMessage( &msg ); DispatchMessage( &msg ); } else { first_time = GetTickCount(); if(g_Load.Logo_Start == true) { Loading(); if(g_Load.Out_Exit() == true) { PostQuitMessage( 0 ); } } if(g_Load.Logo_Start == false) { Update(); Destroy(); Active(); Collision(); Create(); Stage1(); EL(); World_Time = World_Time + tick; } Render(); tick = (float)(GetTickCount() - first_time)/(float)1000; } if(msg.message == WM_QUIT) { break; } } } Cleanup(); UnregisterClass( "ProG", wc.hInstance ); // 등록된 클래스 소거 return 0; }
int main() { if(!ALLEGRO5_INIT) allegro5_init(); short int option; char options_list[][50] = { "Start", "Exit", "Help", "-" }; volatile int i = 0; long int life = 100; char key_char[50]; bool terminou = false, redraw = true; LifeBar lifeBar; Font global_font; ALLEGRO_EVENT ev; lifeBar.open(200, 0, 0, SCREEN_W/2, 50, "resource\\LifeBars\\001.bmp", INVISIBLE); global_font.open("resource\\Font\\impressedMetal.ttf", 32, 0, WHITE); log.append("Font...OK"); Loading(global_font); option = StartGame( "resource\\StartGame\\Sprites\\intro.bmp", "resource\\StartGame\\Snd\\background.wav", "resource\\StartGame\\Sprites\\csr.bmp", "resource\\StartGame\\Snd\\csr.wav", "resource\\Font\\impressedMetal.ttf", options_list); log.append("\t\tLoop principal"); al_start_timer(global_timer); al_clear_to_color(BLACK); al_flip_display(); while(!terminou) { al_wait_for_event(eventos_globais, &ev); switch(ev.type) { case ALLEGRO_EVENT_DISPLAY_CLOSE: terminou = true; break; case ALLEGRO_EVENT_TIMER: if(ev.timer.source == global_timer) redraw = true; break; case KEY_DOWN: strcpy(key_char, al_keycode_to_name(ev.keyboard.keycode)); if( StringCompareNoCase(key_char, "escape") ) terminou = true; else if( StringCompareNoCase(key_char, "down") ){ } else if( StringCompareNoCase(key_char, "up") ){ } else if( StringCompareNoCase(key_char, "right") ){ } else if( StringCompareNoCase(key_char, "left") ){ } break; /************************** Soltou uma tecla ***************************/ case KEY_UP: strcpy(key_char, al_keycode_to_name(ev.keyboard.keycode)); break; } if(redraw && al_is_event_queue_empty(eventos_globais) && !terminou) { redraw = false; al_set_target_bitmap(al_get_backbuffer(display)); lifeBar.print(life); if(life > 0)life--; else life = 200; global_font.print(0, SCREEN_H/2, "Teste"); al_flip_display(); al_clear_to_color(BLACK); } } al_stop_samples(); Fim("resource\\Font\\Resident_Evil_Large.ttf"); al_destroy_display(display); al_destroy_event_queue(eventos_globais); al_destroy_timer(global_timer); log.append("\t\tLoop principal...OK"); log.append("[FIM]"); log.close(); }