void playsingle_controller::init_gui()
{
	uint32_t start = SDL_GetTicks();
	LOG_NG << "Initializing GUI... " << (SDL_GetTicks() - ticks_) << "\n";
	play_controller::init_gui();
	
	uint32_t end_parent_init_gui = SDL_GetTicks();
	posix_print("playsingle_controller::init_gui, play_controller::init_gui(), used time: %u ms\n", end_parent_init_gui - start);
	
	if (human_team_ != -1) {
		gui_->scroll_to_tile(map_.starting_position(human_team_ + 1), game_display::WARP);
	}
	gui_->scroll_to_tile(map_.starting_position(1), game_display::WARP);
	if (tent::mode != TOWER_MODE) {
		gui_->set_current_list_type(game_display::taccess_list::TROOP); 
	} else {
		gui_->set_current_list_type(game_display::taccess_list::HERO);
	}
		
	uint32_t end_scroll_to_tile = SDL_GetTicks();
	posix_print("playsingle_controller::init_gui, scroll_to_tile, used time: %u ms\n", end_scroll_to_tile - end_parent_init_gui);

	update_locker lock_display(gui_->video(),recorder.is_skipping());
	events::raise_draw_event();
	gui_->draw();
	for(std::vector<team>::iterator t = teams_.begin(); t != teams_.end(); ++t) {
		::clear_shroud(t - teams_.begin() + 1);
	}

	uint32_t end_draw = SDL_GetTicks();
	posix_print("playsingle_controller::init_gui, gui_->draw, used time: %u ms\n", end_draw - end_scroll_to_tile);
}
Exemplo n.º 2
0
void playsingle_controller::init_gui(){
	LOG_NG << "Initializing GUI... " << (SDL_GetTicks() - ticks()) << "\n";
	play_controller::init_gui();

	// Scroll to the starting position of the first team. If there is a
	// human team, use that team; otherwise use team 1. If the map defines
	// a starting position for the selected team, scroll to that tile. Note
	// this often does not matter since many scenario start with messages,
	// which will usually scroll to the speaker. Also note that the map
	// does not necessarily define the starting positions. While usually
	// best to use the map, the scenarion may explicitly set the positions,
	// overriding those found in the map (if any).
	{
		int scroll_team = gamestate().first_human_team_ + 1;
		if (scroll_team == 0) {
			scroll_team = 1;
		}
		map_location loc(gamestate().board_.map().starting_position(scroll_team));
		if ((loc.x >= 0) && (loc.y >= 0)) {
			gui_->scroll_to_tile(loc, game_display::WARP);
		}
	}

	update_locker lock_display(gui_->video(), is_skipping_replay());
	gui_->draw();
	get_hotkey_command_executor()->set_button_state();
	events::raise_draw_event();
}
void playsingle_controller::init_gui()
{
	uint32_t start = SDL_GetTicks();
	LOG_NG << "Initializing GUI... " << (SDL_GetTicks() - ticks_) << "\n";
	play_controller::init_gui();
	
	uint32_t end_parent_init_gui = SDL_GetTicks();
	posix_print("playsingle_controller::init_gui, play_controller::init_gui(), used time: %u ms\n", end_parent_init_gui - start);
	
	if (human_team_ != -1) {
		gui_->scroll_to_tile(map_.starting_position(human_team_ + 1), game_display::WARP);
	}
	gui_->scroll_to_tile(map_.starting_position(1), game_display::WARP);
	if (tent::mode == mode_tag::TOWER || tent::mode == mode_tag::LAYOUT) {
		gui_->set_current_list_type(game_display::taccess_list::HERO);
	} else {
		gui_->set_current_list_type(game_display::taccess_list::TROOP);
	}

	{
		int ii = 0;
		// gui_->set_current_list_type(game_display::taccess_list::TROOP);
	}

	uint32_t end_scroll_to_tile = SDL_GetTicks();
	posix_print("playsingle_controller::init_gui, scroll_to_tile, used time: %u ms\n", end_scroll_to_tile - end_parent_init_gui);

	update_locker lock_display(gui_->video(),recorder.is_skipping());
	events::raise_draw_event();

	gui_->draw();

	for(std::vector<team>::iterator t = teams_.begin(); t != teams_.end(); ++t) {
		::clear_shroud(t - teams_.begin() + 1);
	}

	gui_->refresh_access_troops(human_team_, game_display::REFRESH_RELOAD);

	uint32_t end_draw = SDL_GetTicks();
	posix_print("playsingle_controller::init_gui, gui_->draw, used time: %u ms\n", end_draw - end_scroll_to_tile);

	if (tent::mode == mode_tag::SIEGE) {
		refresh_endturn_button(*gui_, "buttons/ctrl-pause2.png");
		gui_->set_theme_object_active("endturn", true);

		teams_[human_team_].set_objectives_changed(false);
	}

	if (lobby->chat.ready()) {
		refresh_chat_button(*gui_, "misc/network-disconnected.png");
	}
	tlobby::thandler::join();
}
Exemplo n.º 4
0
void playsingle_controller::init_gui(){
	LOG_NG << "Initializing GUI... " << (SDL_GetTicks() - ticks_) << "\n";
	play_controller::init_gui();

	if(first_human_team_ != -1) {
		gui_->scroll_to_tile(map_.starting_position(first_human_team_ + 1), game_display::WARP);
	}
	gui_->scroll_to_tile(map_.starting_position(1), game_display::WARP);

	update_locker lock_display(gui_->video(),recorder.is_skipping());
	events::raise_draw_event();
	gui_->draw();
}
Exemplo n.º 5
0
void playsingle_controller::init_gui(){
	LOG_NG << "Initializing GUI... " << (SDL_GetTicks() - ticks()) << "\n";
	play_controller::init_gui();

	if(gamestate().first_human_team_ != -1) {
		gui_->scroll_to_tile(gamestate().board_.map().starting_position(gamestate().first_human_team_ + 1), game_display::WARP);
	}
	gui_->scroll_to_tile(gamestate().board_.map().starting_position(1), game_display::WARP);

	update_locker lock_display(gui_->video(), is_skipping_replay());
	gui_->draw();
	get_hotkey_command_executor()->set_button_state();
	events::raise_draw_event();
}
void replay_controller::init_gui(){
	DBG_NG << "Initializing GUI... " << (SDL_GetTicks() - ticks_) << "\n";
	play_controller::init_gui();

	if (show_team_)
		gui_->set_team(show_team_ - 1, show_everything_);
	else
		gui_->set_team(0, show_everything_);

	gui_->scroll_to_leader(units_, player_number_, display::WARP);
	update_locker lock_display((*gui_).video(),false);
	for(std::vector<team>::iterator t = teams_.begin(); t != teams_.end(); ++t) {
		t->reset_objectives_changed();
	}
}
Exemplo n.º 7
0
void playsingle_controller::init_gui(){
	LOG_NG << "Initializing GUI... " << (SDL_GetTicks() - ticks_) << "\n";
	play_controller::init_gui();

	if(first_human_team_ != -1) {
		gui_->scroll_to_tile(map_.starting_position(first_human_team_ + 1), game_display::WARP);
	}
	gui_->scroll_to_tile(map_.starting_position(1), game_display::WARP);

	update_locker lock_display(gui_->video(),recorder.is_skipping());
	events::raise_draw_event();
	gui_->draw();
	for(std::vector<team>::iterator t = teams_.begin(); t != teams_.end(); ++t) {
		::clear_shroud(t - teams_.begin() + 1);
	}
}
void replay_controller::init_gui(){
	DBG_NG << "Initializing GUI... " << (SDL_GetTicks() - ticks_) << "\n";
	play_controller::init_gui();

	if (show_team_)
		gui_->set_team(show_team_ - 1, show_everything_);
	else
		gui_->set_team(0, show_everything_);

	gui_->scroll_to_leader(player_number_, display::WARP);
	update_locker lock_display((*gui_).video(),false);
	BOOST_FOREACH(const team & t, gamestate_.board_.teams()) {
		t.reset_objectives_changed();
	}
	update_replay_ui();
}
Exemplo n.º 9
0
void play_controller::fire_prestart()
{
    // pre-start events must be executed before any GUI operation,
    // as those may cause the display to be refreshed.
    update_locker lock_display(gui_->video());
    gamestate().gamedata_.set_phase(game_data::PRESTART);

    // Fire these right before prestart events, to catch only the units sides
    // have started with.
    for (const unit& u : gamestate().board_.units()) {
        pump().fire("unit_placed", map_location(u.get_location()));
    }

    pump().fire("prestart");
    // prestart event may modify start turn with WML, reflect any changes.
    gamestate().gamedata_.get_variable("turn_number") = int(turn());
}
Exemplo n.º 10
0
static void _clippy_copy_to_sys(int do_sel)
{
        int j;
        char *dst;
        char *freeme;
#if defined(__QNXNTO__)
        PhClipboardHdr clheader = {Ph_CLIPBOARD_TYPE_TEXT, 0, NULL};
        char *tmp;
        int *cldata;
        int status;
#endif

        freeme = NULL;
        if (!_current_selection) {
                dst = NULL;
                j = 0;
        } else
#if defined(WIN32)
        j = strlen(_current_selection);
#else
        if (has_sys_clip) {
                int i;
                /* convert to local */
                freeme = dst = malloc(strlen(_current_selection)+4);
                if (!dst) return;
                for (i = j = 0; _current_selection[i]; i++) {
                        dst[j] = _current_selection[i];
                        if (dst[j] != '\r') j++;
                }
                dst[j] = '\0';
        } else {
                dst = NULL;
                j = 0;
        }
#endif
#if defined(USE_X11)
        if (has_sys_clip) {
                lock_display();
                if (!dst) dst = (char *) ""; /* blah */
                if (j < 0) j = 0;
                if (do_sel) {
                        if (XGetSelectionOwner(SDL_Display, XA_PRIMARY) != SDL_Window) {
                                XSetSelectionOwner(SDL_Display, XA_PRIMARY, SDL_Window, CurrentTime);
                        }
                        XChangeProperty(SDL_Display,
                                DefaultRootWindow(SDL_Display),
                                XA_CUT_BUFFER1, XA_STRING, 8,
                                PropModeReplace, (unsigned char *)dst, j);
                } else {
                        if (XGetSelectionOwner(SDL_Display, atom_clip) != SDL_Window) {
                                XSetSelectionOwner(SDL_Display, atom_clip, SDL_Window, CurrentTime);
                        }
                        XChangeProperty(SDL_Display,
                                DefaultRootWindow(SDL_Display),
                                XA_CUT_BUFFER0, XA_STRING, 8,
                                PropModeReplace, (unsigned char *)dst, j);
                        XChangeProperty(SDL_Display,
                                DefaultRootWindow(SDL_Display),
                                XA_CUT_BUFFER1, XA_STRING, 8,
                                PropModeReplace, (unsigned char *)dst, j);
                }
                unlock_display();
        }
#elif defined(WIN32)
        if (!do_sel && OpenClipboard(SDL_Window)) {
                _hmem = GlobalAlloc((GMEM_MOVEABLE|GMEM_DDESHARE), j+1);
                if (_hmem) {
                        dst = (char *)GlobalLock(_hmem);
                        if (dst) {
                                /* this seems wrong, but msdn does this */
                                memcpy(dst, _current_selection, j);
                                dst[j] = '\0';
                                GlobalUnlock(_hmem);
                                EmptyClipboard();
                                SetClipboardData(CF_TEXT, _hmem);
                        }
                }
                CloseClipboard();
                _hmem = NULL;
                dst = 0;
        }
#elif defined(__QNXNTO__)
        if (!do_sel) {
                tmp = (char *)malloc(j+4);
                if (!tmp) {
                        cldata=(int*)tmp;
                        *cldata = Ph_CL_TEXT;
                        if (dst) memcpy(tmp+4, dst, j);
                        clheader.data = tmp;
#if (NTO_VERSION < 620)
                        if (clheader.length > 65535) clheader.length=65535;
#endif
                        clheader.length = j + 4;
#if (NTO_VERSION < 620)
                        PhClipboardCopy(inputgroup, 1, &clheader);
#else
                        PhClipboardWrite(inputgroup, 1, &clheader);
#endif
                        free(tmp);
                }
        }
#elif defined(MACOSX)
        if (!do_sel) macosx_clippy_put(_current_clipboard);
#else
        // some other system -- linux without x11, maybe
        // pretend we used the param to silence warnings
        (void) do_sel;
#endif
        if (freeme)
                free(freeme);
}
Exemplo n.º 11
0
static char *_internal_clippy_paste(int cb)
{
#if defined(MACOSX)
        char *src;
#endif
#if defined(USE_X11)
        Window owner;
        int getme;
#elif defined(WIN32)
        char *src;
        int clen;
#elif defined(__QNXNTO__)
        void *clhandle;
        PhClipHeader *clheader;
        int *cldata;
#endif

        if (has_sys_clip) {
#if defined(USE_X11)
                if (cb == CLIPPY_SELECT) {
                        getme = XA_PRIMARY;
                } else {
                        getme = atom_clip;
                }
                lock_display();
                owner = XGetSelectionOwner(SDL_Display, getme);
                unlock_display();
                if (owner == None || owner == SDL_Window) {
                        /* fall through to default implementation */
                } else {
                        lock_display();
                        XConvertSelection(SDL_Display, getme, XA_STRING, atom_sel, SDL_Window,
                                                        CurrentTime);
                        /* at some point in the near future, we'll get a SelectionNotify
                        see _x11_clip_filter for more details;

                        because of this (otherwise) oddity, we take the selection immediately...
                        */
                        unlock_display();
                        return NULL;
                }
#else
                if (cb == CLIPPY_BUFFER) {
#if defined(WIN32)
                        if (IsClipboardFormatAvailable(CF_TEXT) && OpenClipboard(SDL_Window)) {
                                _hmem  = GetClipboardData(CF_TEXT);
                                if (_hmem) {
                                        if (_current_selection != _current_clipboard) {
                                                free(_current_clipboard);
                                        }
                                        _current_clipboard = NULL;
                                        src = (char*)GlobalLock(_hmem);
                                        if (src) {
                                                clen = GlobalSize(_hmem);
                                                if (clen > 0) {
                                                        _current_clipboard = mem_alloc(clen+1);
                                                        memcpy(_current_clipboard, src, clen);
                                                        _current_clipboard[clen] = '\0';
                                                }
                                                GlobalUnlock(_hmem);
                                        }
                                }
                                CloseClipboard();
                                _hmem = NULL;
                        }
#elif defined(__QNXNTO__)
                        if (_current_selection != _current_clipboard) {
                                free(_current_clipboard);
                        }
                        _current_clipboard = NULL;
#if (NTO_VERSION < 620)
                        clhandle = PhClipboardPasteStart(inputgroup);
                        if (clhandle) {
                                clheader = PhClipboardPasteType(clhandle,
                                                                Ph_CLIPBOARD_TYPE_TEXT);
                                if (clheader) {
                                        cldata = clheader->data;
                                        if (clheader->length > 4 && *cldata == Ph_CL_TEXT) {
                                                src = ((char *)clheader->data)+4;
                                                clen = clheader->length - 4;
                                                _current_clipboard = mem_alloc(clen+1);
                                                memcpy(_current_clipboard, src, clen);
                                                _current_clipboard[clen] = '\0';

                                        }
                                        PhClipboardPasteFinish(clhandle);
                                }
                        }
#else
                        /* argh! qnx */
                        clheader = PhClipboardRead(inputgroup, Ph_CLIPBOARD_TYPE_TEXT);
                        if (clheader) {
                                cldata = clheader->data;
                                if (clheader->length > 4 && *cldata == Ph_CL_TEXT) {
                                        src = ((char *)clheader->data)+4;
                                        clen = clheader->length - 4;
                                        _current_clipboard = mem_alloc(clen+1);
                                        memcpy(_current_clipboard, src, clen);
                                        _current_clipboard[clen] = '\0';
                                }
                        }
#endif /* NTO version selector */
                /* okay, we either own the buffer, or it's a selection for folks without */
#endif /* win32/qnx */
                }
#endif /* x11/others */
                /* fall through; the current window owns it */
        }
        if (cb == CLIPPY_SELECT) return _current_selection;
#ifdef MACOSX
        if (cb == CLIPPY_BUFFER) {
                src = str_dup(macosx_clippy_get());
                if (_current_clipboard != _current_selection) {
                        free(_current_clipboard);
                }
                _current_clipboard = src;
                if (!src) return (char *) ""; /* FIXME: de-const-ing is bad */
                return _current_clipboard;
        }
#else
        if (cb == CLIPPY_BUFFER) return _current_clipboard;
#endif
        return NULL;
}
Exemplo n.º 12
0
static int _x11_clip_filter(const SDL_Event *ev)
{
        XSelectionRequestEvent *req;
        XEvent sevent;
        Atom seln_type;
        int seln_format;
        unsigned long nbytes;
        unsigned long overflow;
        unsigned char *seln_data;
        unsigned char *src;

        if (ev->type != SDL_SYSWMEVENT) return 1;
        if (ev->syswm.msg->event.xevent.type == SelectionNotify) {
                sevent = ev->syswm.msg->event.xevent;
                if (sevent.xselection.requestor == SDL_Window) {
                        lock_display();
                        src = NULL;
                        if (XGetWindowProperty(SDL_Display, SDL_Window, atom_sel,
                                                0, 9000, False, XA_STRING,
                                                (Atom *)&seln_type,
                                                (int *)&seln_format,
                                                (unsigned long *)&nbytes,
                                                (unsigned long *)&overflow,
                                                (unsigned char **)&src) == Success) {
                                if (seln_type == XA_STRING) {
                                        if (_current_selection != _current_clipboard) {
                                                free(_current_clipboard);
                                        }
                                        _current_clipboard = mem_alloc(nbytes+1);
                                        memcpy(_current_clipboard, (char*)src, nbytes);
                                        _current_clipboard[nbytes] = 0;
                                        _string_paste(CLIPPY_BUFFER, _current_clipboard);
                                        _widget_owner[CLIPPY_BUFFER]
                                                        = _widget_owner[CLIPPY_SELECT];
                                }
                                XFree(src);
                        }
                        unlock_display();
                }
                return 1;
        } else if (ev->syswm.msg->event.xevent.type == PropertyNotify) {
                sevent = ev->syswm.msg->event.xevent;
                return 1;

        } else if (ev->syswm.msg->event.xevent.type != SelectionRequest) {
                return 1;
        }

        req = &ev->syswm.msg->event.xevent.xselectionrequest;
        sevent.xselection.type = SelectionNotify;
        sevent.xselection.display = req->display;
        sevent.xselection.selection = req->selection;
        sevent.xselection.target = None;
        sevent.xselection.property = None;
        sevent.xselection.requestor = req->requestor;
        sevent.xselection.time = req->time;
        if (XGetWindowProperty(SDL_Display, DefaultRootWindow(SDL_Display),
                        XA_CUT_BUFFER0, 0, 9000, False, req->target,
                        &sevent.xselection.target, &seln_format,
                        &nbytes, &overflow, &seln_data) == Success) {
                if (sevent.xselection.target == req->target) {
                        if (sevent.xselection.target == XA_STRING) {
                                if (nbytes && seln_data[nbytes-1] == '\0')
                                        nbytes--;
                        }
                        XChangeProperty(SDL_Display, req->requestor, req->property,
                                sevent.xselection.target, seln_format, PropModeReplace,
                                seln_data, nbytes);
                        sevent.xselection.property = req->property;
                }
                XFree(seln_data);
        }
        XSendEvent(SDL_Display,req->requestor,False,0,&sevent);
        XSync(SDL_Display, False);
        return 1;
}