Exemplo n.º 1
0
void lobby_init() {
	lobby.line = d_render_line_new(1, 2);
	d_render_line_move(lobby.line, 0, config.platform.screen_w - 320, 0, config.platform.screen_w - 320, config.platform.screen_h);
	
	lobby.list_players = d_text_surface_color_new(config.font_std, 2048, 300, 64, 0);
	lobby.list_games = d_text_surface_color_new(config.font_std, 2048, 300, config.platform.screen_w - 300, 0);
	
	lobby_join.list_players = d_text_surface_color_new(config.font_std, 2048, 300, 64, 0);
	lobby_host.start_game = d_text_surface_color_new(config.font_std, 32, 300, 64, config.platform.screen_h - 96);
	d_text_surface_color_next(lobby_host.start_game, 255, 0, 0);
	d_text_surface_string_append(lobby_host.start_game, "Press enter to start game");
	
	update_lists(NULL, lobby_client.client);
	
	lobby_playername.text_playername = d_text_surface_new(config.font_std, 64, 1024, 64, 64);
	lobby_playername.inputfield_playername = d_menu_textinput_new(64, 128, config.font_std, config.player_name, PROTO_PLAYER_NAME - 1, config.platform.screen_w);
	
	d_text_surface_string_append(lobby_playername.text_playername, "Enter your player name:");
	
	lobby.selected_game = 0;
	lobby.selected_player = 0;
}
Exemplo n.º 2
0
gboolean run(void *data)
{
        update_lists();
        static int timeout_cnt = 0;
        static int next_timeout = 0;

        if (data) {
                timeout_cnt--;
        }

        if (displayed->length > 0 && !xctx.visible && !pause_display) {
            x_win_show();
        }

        if (xctx.visible && (pause_display || displayed->length == 0)) {
            x_win_hide();
        }

        if (xctx.visible) {
            x_win_draw();
        }

        if (xctx.visible) {
                int now = time(NULL);
                int sleep = get_sleep_time();

                if (sleep > 0) {
                        int timeout_at = now + sleep;
                        if (timeout_cnt == 0 || timeout_at < next_timeout) {
                                g_timeout_add_seconds(sleep, run, mainloop);
                                next_timeout = timeout_at;
                                timeout_cnt++;
                        }
                }
        }

        /* always return false to delete timers */
        return false;
}