Пример #1
0
void init_boe(int argc, char* argv[]) {
	init_directories(argv[0]);
	init_menubar(); // Do this first of all because otherwise a default File and Window menu will be seen
	sync_prefs();
	init_graph_tool();
	init_snd_tool();
	
	cDialog::init();
	init_sbar(text_sbar, sbar_rect, 58, 11, 58);
	init_sbar(item_sbar, item_sbar_rect, 16, 8);
	init_sbar(shop_sbar, shop_sbar_rect, 16, 8);
	init_btn(done_btn, BTN_DONE);
	init_btn(help_btn, BTN_HELP);
	
	adjust_window_mode();
	// If we don't do this now it'll flash white to start with
	mainPtr.clear(sf::Color::Black);
	mainPtr.display();
	
	make_cursor_watch();
	boost::thread init_thread([]() {
		init_buf();
		check_for_intel();
		srand(time(nullptr));
		init_screen_locs();
		Set_up_win();
		init_startup();
		flushingInput = true;
	});
	show_logo();
	if(get_bool_pref("ShowStartupSplash", true))
		plop_fancy_startup();
	init_thread.join();
	
	cUniverse::print_result = iLiving::print_result = add_string_to_buf;
	cPlayer::give_help = give_help;
	set_up_apple_events(argc, argv);
	init_fileio();
	init_spell_menus();
	init_mini_map();
	redraw_screen(REFRESH_NONE);
	showMenuBar();
}
Пример #2
0
void pick_preferences()
{
    get_reg_data();
	cur_display_mode = display_mode;

	SetCursor(sword_curs);

	cd_create_dialog(1099,mainPtr);

	cd_set_led(1099,4 + cur_display_mode,1);

	cd_set_led(1099,18,(party.stuff_done[SFD_NO_MAPS] != 0) ? 1 : 0);
	cd_set_led(1099,20,(play_sounds == false) ? 1 : 0);
	cd_set_led(1099,22,(party.stuff_done[SDF_NO_FRILLS] != 0) ? 1 : 0);
	cd_set_led(1099,24,(party.stuff_done[SDF_ROOM_DESCS_AGAIN] != 0) ? 1 : 0);
	cd_set_led(1099,27,(party.stuff_done[SDF_NO_INSTANT_HELP] != 0) ? 1 : 0);
	cd_set_led(1099,38,(party.stuff_done[SDF_EASY_MODE] != 0) ? 1 : 0);
	cd_set_led(1099,40,(party.stuff_done[SDF_LESS_WANDER_ENC] != 0) ? 1 : 0);
	cd_set_led(1099,43,(party.stuff_done[SDF_NO_TER_ANIM] != 0) ? 1 : 0);
	cd_set_led(1099,45,(party.stuff_done[SDF_NO_SHORE_FRILLS] != 0) ? 1 : 0);
	cd_set_led(1099,50,(party.stuff_done[SDF_NO_TARGET_LINE] != 0) ? 1 : 0);
	cd_set_led(1099,52,(party.stuff_done[SDF_LESS_SOUND] != 0) ? 1 : 0);
	cd_set_led(1099,54,(play_startup != false) ? 1 : 0);
	cd_set_led(1099,56,(party.stuff_done[SDF_FASTER_BOOM_SPACES] != 0) ? 1 : 0);
	cd_set_led(1099,58,(party.stuff_done[SDF_USE_DARKER_GRAPHICS] != 0) ? 1 : 0);
	cd_set_led(1099,60,(party.stuff_done[SDF_ASK_ABOUT_TEXT_BOX] != 0) ? 1 : 0);// talk edit box appearing ?
		cd_set_flag(1099,3,1);
	if (PSD[SDF_GAME_SPEED] == 3)
		cd_set_led(1099,47,1);
		else cd_set_led(1099,32 + PSD[SDF_GAME_SPEED] * 2,1);

	if (party.help_received[55] == 0) {
		cd_initial_draw(1099);
		give_help(55,0,1099);
		}

	while (dialog_not_toast)
		ModalDialog();
	cd_kill_dialog(1099,0);
	adjust_window_mode();
}
Пример #3
0
void Handle_One_Event() {
	static const long twentyTicks = time_in_ticks(20).asMilliseconds();
	static const long fortyTicks = time_in_ticks(40).asMilliseconds();
	
	through_sending();
	Handle_Update();
	
	//(cur_time - last_anim_time > 42)
	if((animTimer.getElapsedTime().asMilliseconds() >= fortyTicks) && (overall_mode != MODE_STARTUP) && (anim_onscreen) && get_bool_pref("DrawTerrainAnimation", true)
	   && (!gInBackground)) {
		animTimer.restart();
		draw_terrain();
	}
	if((animTimer.getElapsedTime().asMilliseconds() > twentyTicks) && (overall_mode == MODE_STARTUP)) {
		animTimer.restart();
		draw_startup_anim(true);
	}
	
	clear_sound_memory();
	
	if(map_visible && mini_map.pollEvent(event)){
		if(event.type == sf::Event::Closed) {
			mini_map.setVisible(false);
			map_visible = false;
		} else if(event.type == sf::Event::GainedFocus)
			makeFrontWindow(mainPtr);
	}
	if(!mainPtr.pollEvent(event)) {
		if(changed_display_mode) {
			changed_display_mode = false;
			adjust_window_mode();
		}
		flushingInput = false;
		redraw_screen(REFRESH_NONE);
		return;
	}
	switch(event.type) {
		case sf::Event::KeyPressed:
			if(flushingInput) return;
			if(!(event.key.*systemKey))
				handle_keystroke(event);
			
			break;
			
		case sf::Event::MouseButtonPressed:
			if(flushingInput) return;
			Mouse_Pressed();
			break;
			
		case sf::Event::MouseLeft:
			// Make sure we don't have an arrow cursor when it's outside the window
			make_cursor_sword();
			break;
			
		case sf::Event::GainedFocus:
			Handle_Update();
			makeFrontWindow(mainPtr);
		case sf::Event::MouseMoved:
			if(!gInBackground) {
				location where(event.mouseMove.x, event.mouseMove.y);
				change_cursor(where);
			}
			break;
			
		case sf::Event::MouseWheelMoved:
			if(flushingInput) return;
			handle_scroll(event);
			break;
			
		case sf::Event::Closed:
			if(overall_mode == MODE_STARTUP) {
				if(party_in_memory) {
					std::string choice = cChoiceDlog("quit-confirm-save", {"save","quit","cancel"}).show();
					if(choice == "cancel") break;
					if(choice == "save") {
						fs::path file = nav_put_party();
						if(!file.empty()) break;
						save_party(file, univ);
					}
				}
				All_Done = true;
				break;
			}
			if(overall_mode > MODE_TOWN){
				std::string choice = cChoiceDlog("quit-confirm-nosave", {"quit", "cancel"}).show();
				if(choice == "cancel")
					break;
			}
			else {
				std::string choice = cChoiceDlog("quit-confirm-save", {"save", "quit", "cancel"}).show();
				if(choice == "cancel")
					break;
				if(choice == "save")
					save_party(univ.file, univ);
			}
			All_Done = true;
		default:
			break; // There's several events we don't need to handle at all
	}
	flushingInput = false; // TODO: Could there be a case when the key and mouse input that needs to be flushed has other events interspersed?
}
Пример #4
0
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    PAINTSTRUCT ps;
    POINT press;
    HMENU menu;
    RECT dlg_rect;
    RECT wind_rect;

    short handled = 0;
    short store_ulx;
    short store_uly;
    short sbar_pos;
    short which_sbar;
    short old_setting;
    short smin;
    short smax;

// First, handle window size
    GetWindowRect(mainPtr,&wind_rect);

    switch (display_mode) { //case 0 is center
    case 1:
        store_ulx = 0;
        store_uly = 0;
        break;
    case 2:
        store_ulx = wind_rect.right - 550 - 21;
        store_uly = 0;
        break;
    case 3:
        store_ulx = 0;
        store_uly = wind_rect.bottom - 422 - 24 - 21;
        break;
    case 4:
        store_ulx = wind_rect.right - 550 - 21;
        store_uly = wind_rect.bottom - 422 - 24 - 21;
        break;
    case 5:
        store_ulx = 0;
        store_uly = 0;
        break;
    default:
        store_ulx = ((wind_rect.right - wind_rect.left) - 536) / 2 - 30;
        store_uly = ((wind_rect.bottom - wind_rect.top) - 478) / 2 + 8;
        break;
    }

    store_ulx -= store_ulx % 8;
    store_uly -= store_uly % 8;

    if ((store_ulx != ulx) || (store_uly != uly))
    {
        ulx = store_ulx;
        uly = store_uly;
        adjust_window_mode();
    }

    switch (message) {
    case WM_KEYDOWN:
        if (hwnd != mainPtr)
            check_cd_event(hwnd,message,wParam,lParam);
        else {
            cursor_go();
            All_Done = handle_syskeystroke(wParam,lParam,&handled);
            check_game_done();
        }
        if (handled == 1)
            FlushEvents(0);

        return 0;

    case WM_CHAR:
        if (hwnd != mainPtr)
            check_cd_event(hwnd,message,wParam,lParam);
        else {
            cursor_go();
            All_Done = handle_keystroke(wParam,lParam);
            check_game_done();
        }
        return 0;

    case WM_LBUTTONDOWN:
        cursor_stay();
        if (hwnd != mainPtr) check_cd_event(hwnd,message,wParam,lParam);
        else {
            SetFocus(hwnd);
            press = MAKEPOINT(lParam);
            if (in_startup_mode == false)
                All_Done = handle_action(press, wParam,lParam);
            else 	All_Done = handle_startup_press(press);
            change_cursor(press);
            check_game_done();
        }
        return 0;
        break;

    case WM_RBUTTONDOWN:
        cursor_stay();
        if (hwnd != mainPtr)
            check_cd_event(hwnd,message,wParam,lParam);
        else {
            SetFocus(hwnd);
            press = MAKEPOINT(lParam);
            if (in_startup_mode == false)
                All_Done = handle_action(press, wParam,-2);
            else All_Done = handle_startup_press(press);
            change_cursor(press);
            check_game_done();
        }
        return 0;
        break;

    case WM_ACTIVATE:
        if (hwnd == mainPtr)
        {
            WORD fActive = LOWORD(wParam);

            if ((fActive == WA_ACTIVE) ||(fActive == WA_CLICKACTIVE))
            {
                window_in_front = true;
                GetClientRect(hwnd,&dlg_rect);
                InvalidateRect(hwnd,&dlg_rect,false);
            }

            if (fActive == WA_INACTIVE)
            {
                cursor_stay();
                anim_onscreen = false;
                window_in_front = false;
            }
        }
        return 0;

    case WM_ERASEBKGND:
        if (hwnd != mainPtr) break;
        block_erase = false;
        return 1;

    case WM_MOUSEMOVE:
        if (store_mouse != lParam) cursor_stay();
        store_mouse = lParam;
        press = MAKEPOINT(lParam);
        if (hwnd == mainPtr) {
            change_cursor(press);
            if ((overall_mode > MODE_COMBAT) && (overall_mode < MODE_TALKING))
                draw_targeting_line(press);
        }
        return 0;

    case WM_PAINT:
        if ((block_erase == true) && (hwnd == mainPtr)) {
            block_erase = false;
        }
        BeginPaint(hwnd,&ps);
        EndPaint(hwnd,&ps);

        if (hwnd != mainPtr)
            check_cd_event(hwnd,message,wParam,lParam);
        else {
            string_added = true;
            reset_text_bar();
            if (in_startup_mode == true) draw_startup(0);
            else if (first_update == true)
            {
                first_update = false;
                if (overall_mode == MODE_OUTDOORS) redraw_screen(0);
                if ((overall_mode > MODE_OUTDOORS) & (overall_mode < MODE_COMBAT)) redraw_screen(1);
                // 1st update never combat
            }
            else refresh_screen(overall_mode);
        }
        return 0;

    case WM_TIMER:
        switch(wParam) {
        case 1:
            if ((in_startup_mode == false) && (anim_onscreen == true)
                    && (window_in_front == true) && (give_delays == false)) {
                if(PSD[SDF_NO_TER_ANIM] != 1)
                    anim_ticks++;
                initiate_redraw();
            }
            break;
        case 2:
            if ((overall_mode > MODE_COMBAT) && (overall_mode < MODE_TALKING)) {
                GetCursorPos(&press);
                press.x -= wind_rect.left + 3;
                press.y -= wind_rect.top + 41;
                draw_targeting_line(press);
            }
            if ((in_startup_mode == true) && (window_in_front == true))
                draw_startup_anim();
            break;
        }
        return 0;

    case WM_COMMAND:    // 1006 is dummy event
        // creation events 2000 spend xp 2001 pick graphic 2002 finish up
        if (hwnd == mainPtr) {
            menu = GetMenu(mainPtr);
            All_Done = handle_menu((short) LOWORD(wParam), menu);
            check_game_done();
        }
        else check_cd_event(hwnd,message,wParam,lParam);

        return 0;

    case WM_VSCROLL:
        which_sbar = GetWindowLong((HWND) lParam, GWL_ID);
        switch (which_sbar) {// 1 text  2 items  3 shop
        case 1:
            sbar_pos = GetScrollPos(text_sbar,SB_CTL);
            switch (wParam ) {
            case SB_PAGEDOWN:
                sbar_pos += 11;
                break;
            case SB_LINEDOWN:
                sbar_pos++;
                break;
            case SB_PAGEUP:
                sbar_pos -= 11;
                break;
            case SB_LINEUP:
                sbar_pos--;
                break;
            case SB_TOP:
                sbar_pos = 0;
                break;
            case SB_BOTTOM:
                sbar_pos = 57;
                break;
            case SB_THUMBPOSITION:
            case SB_THUMBTRACK:
                sbar_pos = LOWORD(lParam);
                break;
            }
            if (sbar_pos < 0) sbar_pos = 0;
            if (sbar_pos > 58) sbar_pos = 58;
            {
//				SetScrollPos(text_sbar,SB_CTL,sbar_pos,true);
                lpsi.nPos = sbar_pos;
                lpsi.fMask = SIF_POS;
                SetScrollInfo(text_sbar,SB_CTL,&lpsi,true);
            }
            string_added = true;
            print_buf();
            break;
        case 2:
            old_setting = sbar_pos = GetScrollPos(item_sbar,SB_CTL);
            GetScrollRange(item_sbar,SB_CTL,(int *) &smin,(int *) &smax);
            switch (wParam ) {
            case SB_PAGEDOWN:
                sbar_pos += (stat_window == 7) ? 2 : 8;
                break;
            case SB_LINEDOWN:
                sbar_pos++;
                break;
            case SB_PAGEUP:
                sbar_pos -= (stat_window == 7) ? 2 : 8;
                break;
            case SB_LINEUP:
                sbar_pos--;
                break;
            case SB_TOP:
                sbar_pos = 0;
                break;
            case SB_BOTTOM:
                sbar_pos = smax;
                break;
            case SB_THUMBPOSITION:
            case SB_THUMBTRACK:
                sbar_pos = LOWORD(lParam);
                break;
            }
            if (sbar_pos < 0) sbar_pos = 0;
            if (sbar_pos > smax) sbar_pos = smax;
            {
//				SetScrollPos(item_sbar,SB_CTL,sbar_pos,true);
                lpsi.nPos = sbar_pos;
                lpsi.fMask = SIF_POS;
                SetScrollInfo(item_sbar,SB_CTL,&lpsi,true);
            }
            if (sbar_pos != old_setting)
                put_item_screen(stat_window,1);
            break;
        case 3:
            old_setting = sbar_pos = GetScrollPos(shop_sbar,SB_CTL);
            GetScrollRange(shop_sbar,SB_CTL,(int *) &smin,(int *) &smax);
            switch (wParam ) {
            case SB_PAGEDOWN:
                sbar_pos += 8;
                break;
            case SB_LINEDOWN:
                sbar_pos++;
                break;
            case SB_PAGEUP:
                sbar_pos -= 8;
                break;
            case SB_LINEUP:
                sbar_pos--;
                break;
            case SB_TOP:
                sbar_pos = 0;
                break;
            case SB_BOTTOM:
                sbar_pos = smax;
                break;
            case SB_THUMBPOSITION:
            case SB_THUMBTRACK:
                sbar_pos = LOWORD(lParam);
                break;
            }
            if (sbar_pos < 0) sbar_pos = 0;
            if (sbar_pos > smax) sbar_pos = smax;
            {
//				SetScrollPos(shop_sbar,SB_CTL,sbar_pos,true);
                lpsi.nPos = sbar_pos;
                lpsi.fMask = SIF_POS;
                SetScrollInfo(shop_sbar,SB_CTL,&lpsi,true);
            }
            if (sbar_pos != old_setting)
                draw_shop_graphics(0,shop_sbar_rect);
            break;
        }

        SetFocus(mainPtr);
        return 0;

    case WM_DESTROY:
    case WM_CLOSE:
        if (hwnd == mainPtr)
        {
            lose_graphics();
            PostQuitMessage(0);
        }
        return 0;
    case WM_QUIT:
        if (hwnd == mainPtr)
            lose_graphics();
        break;
    }

    return DefWindowProc(hwnd,message,wParam,lParam);
}
Пример #5
0
int WINAPI WinMain(HINSTANCE hInstance,	HINSTANCE hPrevInstance, LPSTR, int	nCmdShow)
{
    MSG msg;
    WNDCLASS wndclass, wndclass2;
    RECT windRECT;
    HINSTANCE boeSoundsDLL;

    wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_BYTEALIGNWINDOW;
    wndclass.lpfnWndProc = WndProc;
    wndclass.cbClsExtra = 0;
    wndclass.cbWndExtra = 0;
    wndclass.hInstance = hInstance;
    wndclass.hIcon = LoadIcon(hInstance,MAKEINTRESOURCE(10));
    wndclass.hCursor = NULL;
    wndclass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
    wndclass.lpszMenuName = MAKEINTRESOURCE(1);
    wndclass.lpszClassName = szAppName;

    RegisterClass(&wndclass);

    wndclass2.style = CS_HREDRAW | CS_VREDRAW | CS_BYTEALIGNWINDOW;
    wndclass2.lpfnWndProc = WndProc;
    wndclass2.cbClsExtra = 0;
    wndclass2.cbWndExtra = 0;
    wndclass2.hInstance = hInstance;
    wndclass2.hIcon = LoadIcon(hInstance,MAKEINTRESOURCE(10));
    wndclass2.hCursor = NULL;
    wndclass2.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
    wndclass2.lpszMenuName = NULL;
    wndclass2.lpszClassName = szWinName;

    RegisterClass(&wndclass2);

    mainPtr = CreateWindow (szAppName, "Classic Blades of Exile",
                            WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
                            0,
                            0,
                            588,
                            478,
                            NULL,
                            NULL,
                            hInstance,
                            NULL);

    if (!hPrevInstance)
    {   // initialize
        Get_Path(file_path_name);

        store_hInstance = hInstance;
        accel = LoadAccelerators(hInstance, MAKEINTRESOURCE(1));

        boeSoundsDLL = LoadLibrary("./boesounds.dll");

        if (!boeSoundsDLL)
        {
            MessageBox(mainPtr, "BOESOUNDS.DLL not found", "Error", MB_OK | MB_ICONEXCLAMATION);
            return (-1);
        }

        load_sounds(boeSoundsDLL);
        loadFonts();
        loadCursors();

        SetCursor(sword_curs);
        current_cursor = 124;
        /* cursors loaded */

        data_store = new piles_of_stuff_dumping_type;
        data_store3 = new piles_of_stuff_dumping_type3;
        data_store4 = new piles_of_stuff_dumping_type4;
        data_store5 = new piles_of_stuff_dumping_type5;
        scen_item_list = new scen_item_data_type;

        srand(GetCurrentTime());

        get_reg_data();

        if (display_mode != 5)
            max_window(mainPtr);
        else {
            GetWindowRect(GetDesktopWindow(),&windRECT);
            MoveWindow(mainPtr,(windRECT.right - (588 + 10)) / 2,
                       (windRECT.bottom - (425 + 52)) / 2 ,
                       588 + 10,425 + 52,true);
        }

        shop_sbar = CreateWindow("scrollbar",NULL,
                                 WS_CHILD | WS_TABSTOP | SBS_VERT, shop_sbar_rect.left,shop_sbar_rect.top,shop_sbar_rect.right,shop_sbar_rect.bottom,
                                 mainPtr,(HMENU) 3, store_hInstance,NULL);
        lpsi.fMask = SIF_RANGE;
        lpsi.nMax = 16;
        SetScrollInfo(shop_sbar,SB_CTL,&lpsi,false);
//		SetScrollRange(shop_sbar,SB_CTL,0,16,false);

        ShowWindow(mainPtr, nCmdShow);

        plop_fancy_startup();

        init_screen_locs();

        FlushEvents(2);

        SetTimer(mainPtr,1,620,NULL);
        SetTimer(mainPtr,2,200,NULL);

        file_initialize();

        if (GetDeviceCaps(main_dc,BITSPIXEL) * GetDeviceCaps(main_dc,PLANES) < 8)
        {
            MessageBox(mainPtr,"Blades of Exile is designed for 256 colors. The current graphics device is set for less. Exile 3 is playable with less colors, but will look somewhat odd."	,
                       "Not 256 colors!",MB_OK | MB_ICONEXCLAMATION);
            MessageBox(mainPtr,"For tips on how to get 256 colors, hit F1 for help, and then select 'Getting 256 Colors' from the table of contents."	,
                       "Not 256 colors!",MB_OK | MB_ICONEXCLAMATION);
        }

        menu_activate(0);
        cursor_stay();
        showcursor(true);
        reset_text_bar();

        adjust_window_mode();

        cd_init_dialogs();

        if (game_run_before == false) {
            FCD(986,0);
            WritePrivateProfileString("Blades of Exile", "game_run_before", "1", "./blades.ini");
        }
        else if (give_intro_hint == true) tip_of_day();

    }
    event_handled = false;

    while(GetMessage(&msg,NULL,0,0))
    {
        if (event_handled == false)
        {
            if (!TranslateAccelerator(mainPtr, accel, &msg))
            {
                TranslateMessage(&msg);
                DispatchMessage(&msg);
            }
        }
    }

    delete scen_item_list;
    delete data_store5;
    delete data_store4;
    delete data_store3;
    if(data_store2 != NULL)
        delete[] data_store2;
    if(scen_headers != NULL)
        delete[] scen_headers;
    delete data_store;

    lose_graphics();

    FreeLibrary((HMODULE) boeSoundsDLL);

    return msg.wParam;
}