示例#1
0
文件: cc.cpp 项目: ndilday/virtualu
static void demo_screen() {
    //------- display screen -----------//

    int dataSize;
    File* filePtr = image_interface.get_file("DEMOSCR", dataSize);

    if (filePtr->file_get_short() != -1 ) {         // use common color palette
	filePtr->file_seek(filePtr->file_pos() - sizeof(short));
	vga_back.put_large_bitmap(0, 0, filePtr);
    }
    else {                                          // use own color palette
	unsigned char palette[256 * 3];
	short *remapTable;
	filePtr->file_read(palette, 256 * 3);
	PalDesc palDesc(palette, 3, 256, 6);
	ColorTable colorTable;
	colorTable.generate_table_fast(MAX_BRIGHTNESS_ADJUST_DEGREE, palDesc, ColorTable::bright_func);
	remapTable = (short *) colorTable.get_table(0);
	vga_back.put_large_bitmap(0, 0, filePtr, remapTable);
    }

    vga.blt_buf(0,0,VGA_WIDTH-1,VGA_HEIGHT-1);
    sys.blt_virtual_buf();

    //-------- detect button --------//

    int highlightButton=0;

    while(1) {
	MSG msg;

	if (PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE)) {
	    if (!GetMessage( &msg, NULL, 0, 0)) {
		return;
	    }

	    TranslateMessage(&msg);
	    DispatchMessage(&msg);
	    continue;
	}
	else if( sys.paused_flag || !sys.active_flag ) {
	    WaitMessage();
	    continue;
	}

	//---------- detect menu option buttons -----------//

	sys.yield();
	mouse.get_event();

	DemoButton* buttonPtr = demo_button_array;

	for( int i=0 ; i<DEMO_BUTTON_COUNT ; i++, buttonPtr++ ) {
	    //----- has clicked on a button -------//

	    if(  mouse.single_click( buttonPtr->x1, buttonPtr->y1,
				     buttonPtr->x1+buttonPtr->width-1, buttonPtr->y1+buttonPtr->height-1, 0 ) ) {
		audio.play_wav("BEEPS-1",audio.int_to_DsVolume(config.sound_effect_volume));

		switch(i) {
		case 0:
		    open_http( "anker.url", "http://www.ankerpub.com" );
		    return;

		case 1:
		    open_http( "vu.url", "http://www.virtual-u.org" );
		    return;

		case 2:
		    return;
		}
	    }

	    //---- if the mouse cursor is in the area ----//

	    if(  mouse.in_area( buttonPtr->x1, buttonPtr->y1,
				buttonPtr->x1+buttonPtr->width-1, buttonPtr->y1+buttonPtr->height-1 ) ) {
		if( highlightButton != i+1 ) {
		    highlightButton = i+1;

		    // restore original image first
		    vga.blt_buf(0,0,VGA_WIDTH-1,VGA_HEIGHT-1);

		    mouse.hide_area(buttonPtr->x1, buttonPtr->y1,
				    buttonPtr->x1+buttonPtr->width-1,  buttonPtr->y1+buttonPtr->height-1);

		    image_interface.put_front( buttonPtr->x1, buttonPtr->y1, buttonPtr->file_name );

		    mouse.show_area();

		    sys.blt_virtual_buf();
		}
		break;
	    }
	}

	//------- the mouse cursor is not on any of the buttons ------//

	if( i==DEMO_BUTTON_COUNT ) {
	    if( highlightButton != 0 ) {
		vga.blt_buf(0,0,VGA_WIDTH-1,VGA_HEIGHT-1);// restore original image
		highlightButton = 0;
	    }
	}
    }
}
示例#2
0
文件: cc.cpp 项目: ndilday/virtualu
//---------- Begin of function WinMain ----------//
//!
//! WinMain - initialization, message loop
//!
//! Compilation constants:
//!
//! DEBUG  - normal debugging
//!
//! DEMO  - demo version
//! ADMIN - administrator version
//! NO_CDCHECK - no CD check
//! NO_AUTOSAVE - no autosave
//!
//! Release version defines:
//! Standard version: DEBUG, NO_MEM_CLASS
//! Administrator version: DEBUG, NO_MEM_CLASS, ADMIN
//! Demo version: DEBUG, NO_MEM_CLASS, DEMO
//!
int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
		    LPSTR lpCmdLine, int nCmdShow) {
    //------ set game directory and check CD ------//

    sys.set_game_dir();

#ifndef NO_CDCHECK

#ifndef DEMO
    if( !sys.cdrom_drive ) {
#ifdef ADMIN
	char* msg = "Please insert Virtual U - Administrator Version CDROM and try again.";
#else
	char* msg = "Please insert Virtual U CDROM and try again.";
#endif

	MessageBox(sys.main_hwnd, msg, WIN_TITLE, MB_OK | MB_ICONERROR);
	return 0;
    }
#endif
#endif

    //----------- play movie ---------------//

    OSVERSIONINFO osVersion;
    memset( &osVersion, 0, sizeof(osVersion) );
    // do not play movie in Win2000
    osVersion.dwOSVersionInfoSize = sizeof(osVersion);

    if( !m.is_file_exist("SKIPAVI.SYS")
	&& GetVersionEx(&osVersion) && osVersion.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ) {
	play_video(hInstance, 0);
    }

    config.init();

  //--------------------------------------//

    if( !sys.init(hInstance) )
	return FALSE;

    err.set_extra_handler( extra_error_handler );   // set extra error handler, save the game when a error happens

#ifdef DEBUG
    // break at exception, for debugging
    if( sys.debug_session ) {
	// directX may change fpu control word, so change after sys.init
	// all exception but no inexact, underflow and denormal number exception
	_control87( _EM_INEXACT | _EM_UNDERFLOW | _EM_DENORMAL, _MCW_EM );
    }
#endif                                          // DEBUG

#ifdef DEMO
    audio.play_wav("DEMOOPEN",audio.int_to_DsVolume(config.sound_effect_volume));
#endif

    game.main_menu();

#ifdef DEMO
    demo_screen();
#endif

    sys.deinit();

    return 0;
}