/**
 * SET: show/hide console (while running, or 10 seconds after finished)
 * 
 */
static unsigned int script_keypress_cbr(unsigned int key)
{
    if (gui_menu_shown()) return 1;
    
    if (script_state == SCRIPT_RUNNING)
    {
        //~ if (handle_picoc_lib_keys(event)==0) return 0;
    }
    
    //~ extern int console_visible;

    if (script_state != SCRIPT_IDLE) // toggle show/hide
    {
        if (key == MODULE_KEY_PRESS_SET && display_idle())
        {
            console_toggle();
            return 0;
        }   
    }
    /*
    if (script_state == SCRIPT_JUST_FINISHED) // after script finished, hide the console on first key press
    {
        if (key == MODULE_KEY_UNPRESS_SET)
        {
            return 0;
        }   
        if (console_visible)
        {
            console_hide();
            return 1;
        }
    }*/
    return 1;
}
Exemple #2
0
/**
 *
 *  rct2: 0x006E3B43
 */
void title_handle_keyboard_input()
{
	rct_window *w;
	int key;

	if (gOpenRCT2Headless) {
		return;
	}

	if (!gConsoleOpen) {
		// Handle modifier keys and key scrolling
		gInputPlaceObjectModifier = PLACE_OBJECT_MODIFIER_NONE;
		if (RCT2_GLOBAL(0x009E2B64, uint32) != 1) {
			if (gKeysState[SDL_SCANCODE_LSHIFT] || gKeysState[SDL_SCANCODE_RSHIFT])
				gInputPlaceObjectModifier |= PLACE_OBJECT_MODIFIER_SHIFT_Z;
			if (gKeysState[SDL_SCANCODE_LCTRL] || gKeysState[SDL_SCANCODE_RCTRL])
				gInputPlaceObjectModifier |= PLACE_OBJECT_MODIFIER_COPY_Z;
			if (gKeysState[SDL_SCANCODE_LALT] || gKeysState[SDL_SCANCODE_RALT])
				gInputPlaceObjectModifier |= 4;
#ifdef __MACOSX__
			if (gKeysState[SDL_SCANCODE_LGUI] || gKeysState[SDL_SCANCODE_RGUI]) {
				gInputPlaceObjectModifier |= 8;
			}
#endif
		}
	}

	while ((key = get_next_key()) != 0) {
		if (key == 255)
			continue;

		// Reserve backtick for console
		if (key == SDL_SCANCODE_GRAVE) {
			if (gConfigGeneral.debugging_tools || gConsoleOpen) {
				window_cancel_textbox();
				console_toggle();
			}
			continue;
		} else if (gConsoleOpen) {
			console_input(key);
			continue;
		}

		key |= gInputPlaceObjectModifier << 8;

		w = window_find_by_class(WC_CHANGE_KEYBOARD_SHORTCUT);
		if (w != NULL) {
			keyboard_shortcut_set(key);
		} else {
			w = window_find_by_class(WC_TEXTINPUT);
			if (w != NULL) {
				window_text_input_key(w, key);
			}
			
			if (key == gShortcutKeys[SHORTCUT_SCREENSHOT]) {
				keyboard_shortcut_handle_command(SHORTCUT_SCREENSHOT);
			}
		}
	}
}
Exemple #3
0
void server_enter(int state)
{
	if(!state)
		return;
	
	pthread_mutex_lock(&servers_mutex);
	
	struct found_server_t *cserver = found_servers;
	int i = 0;
		
	while(cserver)
	{
		if(i == selected_server)
		{
			if(!r_DrawConsole)
				console_toggle();
			
			em_connect(cserver->ip, cserver->port);
			goto end;
		}
		
		LL_NEXT(cserver);
		i++;
	}
		
	end:

	pthread_mutex_unlock(&servers_mutex);
}
Exemple #4
0
void control_escape(int state)
{
	if(!state)
		return;
	
	if(server_discovery_started)
	{
		stop_server_discovery();
		console_toggle();
	}
	else
	{
		if(r_DrawConsole)
			console_toggle();
		else
			start_server_discovery();
	}
}
Exemple #5
0
/**
 * SET: show/hide console (while running, or 10 seconds after finished)
 * 
 */
int handle_picoc_keys(struct event * event)
{
    if (IS_FAKE(event)) return 1; // only process real buttons, not emulated presses

    if (gui_menu_shown()) return 1;
    
    if (script_state == SCRIPT_RUNNING)
    {
        //~ if (handle_picoc_lib_keys(event)==0) return 0;
    }
    
    extern int console_visible;

    if (script_state != SCRIPT_IDLE) // toggle show/hide
    {
        if (event->param == BGMT_PRESS_SET && display_idle())
        {
            console_toggle();
            return 0;
        }   
    }
    if (script_state == SCRIPT_JUST_FINISHED) // after script finished, hide the console on first key press
    {
        if (event->param == BGMT_UNPRESS_SET)
        {
            return 0;
        }   
        if (console_visible && 
            event->param != GMT_OLC_INFO_CHANGED &&
            #ifdef GMT_GUICMD_PRESS_BUTTON_SOMETHING
            event->param != GMT_GUICMD_PRESS_BUTTON_SOMETHING &&
            #endif
           1)
        {
            console_hide();
            return 1;
        }
    }
    return 1;
}
Exemple #6
0
void input_handle_keyboard(bool isTitle)
{
    if (gOpenRCT2Headless)
    {
        return;
    }

    if (!gConsoleOpen)
    {
        if (!isTitle)
        {
            // Handle mouse scrolling
            if (input_get_state() == INPUT_STATE_NORMAL && gConfigGeneral.edge_scrolling)
            {
                if (!(gInputPlaceObjectModifier & (PLACE_OBJECT_MODIFIER_SHIFT_Z | PLACE_OBJECT_MODIFIER_COPY_Z)))
                {
                    game_handle_edge_scroll();
                }
            }
        }

        // Handle modifier keys and key scrolling
        gInputPlaceObjectModifier = PLACE_OBJECT_MODIFIER_NONE;
        const uint8 * keysState   = context_get_keys_state();
        if (keysState[SDL_SCANCODE_LSHIFT] || keysState[SDL_SCANCODE_RSHIFT])
        {
            gInputPlaceObjectModifier |= PLACE_OBJECT_MODIFIER_SHIFT_Z;
        }
        if (keysState[SDL_SCANCODE_LCTRL] || keysState[SDL_SCANCODE_RCTRL])
        {
            gInputPlaceObjectModifier |= PLACE_OBJECT_MODIFIER_COPY_Z;
        }
        if (keysState[SDL_SCANCODE_LALT] || keysState[SDL_SCANCODE_RALT])
        {
            gInputPlaceObjectModifier |= 4;
        }
#ifdef __MACOSX__
        if (keysState[SDL_SCANCODE_LGUI] || keysState[SDL_SCANCODE_RGUI])
        {
            gInputPlaceObjectModifier |= 8;
        }
#endif
        if (!isTitle)
        {
            game_handle_key_scroll();
        }
    }

    if (gConfigGeneral.use_virtual_floor)
    {
        if (gInputPlaceObjectModifier & (PLACE_OBJECT_MODIFIER_COPY_Z | PLACE_OBJECT_MODIFIER_SHIFT_Z))
            virtual_floor_enable();
        else
            virtual_floor_disable();
    }

    // Handle key input
    sint32 key;
    while (!gOpenRCT2Headless && (key = get_next_key()) != 0)
    {
        if (key == 255)
            continue;

        // Reserve backtick for console
        if (key == SDL_SCANCODE_GRAVE)
        {
            if ((gConfigGeneral.debugging_tools && !context_is_input_active()) || gConsoleOpen)
            {
                window_cancel_textbox();
                console_toggle();
            }
            continue;
        }
        else if (gConsoleOpen)
        {
            input_handle_console(key);
            continue;
        }
        else if (!isTitle && gChatOpen)
        {
            input_handle_chat(key);
            continue;
        }

        key |= gInputPlaceObjectModifier << 8;

        rct_window * w = window_find_by_class(WC_TEXTINPUT);
        if (w != nullptr)
        {
            char keychar = input_scancode_to_rct_keycode(key & 0xFF);
            window_text_input_key(w, keychar);
        }
        else if (!gUsingWidgetTextBox)
        {
            w = window_find_by_class(WC_CHANGE_KEYBOARD_SHORTCUT);
            if (w != nullptr)
            {
                keyboard_shortcuts_set(key);
                window_close_by_class(WC_CHANGE_KEYBOARD_SHORTCUT);
                window_invalidate_by_class(WC_KEYBOARD_SHORTCUT_LIST);
            }
            else
            {
                keyboard_shortcut_handle(key);
            }
        }
    }
}
Exemple #7
0
/**
 *
 *  rct2: 0x006E3B43
 */
void game_handle_keyboard_input()
{
	rct_window *w;
	sint32 key;

	if (!gConsoleOpen) {
		// Handle mouse scrolling
		if (_inputState == INPUT_STATE_NORMAL && gConfigGeneral.edge_scrolling) {
			if (!(gInputPlaceObjectModifier & (PLACE_OBJECT_MODIFIER_SHIFT_Z | PLACE_OBJECT_MODIFIER_COPY_Z))) {
				game_handle_edge_scroll();
			}
		}

		// Handle modifier keys and key scrolling
		gInputPlaceObjectModifier = PLACE_OBJECT_MODIFIER_NONE;
		if (gKeysState[SDL_SCANCODE_LSHIFT] || gKeysState[SDL_SCANCODE_RSHIFT]) {
			gInputPlaceObjectModifier |= PLACE_OBJECT_MODIFIER_SHIFT_Z;
		}
		if (gKeysState[SDL_SCANCODE_LCTRL] || gKeysState[SDL_SCANCODE_RCTRL]) {
			gInputPlaceObjectModifier |= PLACE_OBJECT_MODIFIER_COPY_Z;
		}
		if (gKeysState[SDL_SCANCODE_LALT] || gKeysState[SDL_SCANCODE_RALT]) {
			gInputPlaceObjectModifier |= 4;
		}
#ifdef __MACOSX__
		if (gKeysState[SDL_SCANCODE_LGUI] || gKeysState[SDL_SCANCODE_RGUI]) {
			gInputPlaceObjectModifier |= 8;
		}
#endif
		game_handle_key_scroll();
	}


	// Handle key input
	while (!gOpenRCT2Headless && (key = get_next_key()) != 0) {
		if (key == 255)
			continue;

		// Reserve backtick for console
		if (key == SDL_SCANCODE_GRAVE) {
			if ((gConfigGeneral.debugging_tools && !platform_is_input_active()) || gConsoleOpen) {
				window_cancel_textbox();
				console_toggle();
			}
			continue;
		} else if (gConsoleOpen) {
			console_input(key);
			continue;
		} else if (gChatOpen) {
			chat_input(key);
			continue;
		}

		key |= gInputPlaceObjectModifier << 8;

		w = window_find_by_class(WC_CHANGE_KEYBOARD_SHORTCUT);
		if (w != NULL) {
			keyboard_shortcut_set(key);
		} else {
			w = window_find_by_class(WC_TEXTINPUT);
			if (w != NULL) {
				window_text_input_key(w, key);
			} else if (!gUsingWidgetTextBox) {
				keyboard_shortcut_handle(key);
			}
		}
	}
}