コード例 #1
0
ファイル: downloaddialog.cpp プロジェクト: 86400/scummvm
DownloadDialog::DownloadDialog(uint32 storageId, LauncherDialog *launcher) :
	Dialog("GlobalOptions_Cloud_DownloadDialog"), _launcher(launcher), _close(false) {
	_backgroundType = GUI::ThemeEngine::kDialogBackgroundPlain;

	_browser = new BrowserDialog(_("Select directory where to download game data"), true);
	_remoteBrowser = new RemoteBrowserDialog(_("Select directory with game data"));

	_remoteDirectoryLabel = new StaticTextWidget(this, "GlobalOptions_Cloud_DownloadDialog.RemoteDirectory", _("From: "));
	_localDirectoryLabel = new StaticTextWidget(this, "GlobalOptions_Cloud_DownloadDialog.LocalDirectory", _("To: "));
	uint32 progress = (uint32)(100 * CloudMan.getDownloadingProgress());
	_progressBar = new SliderWidget(this, "GlobalOptions_Cloud_DownloadDialog.ProgressBar");
	_progressBar->setMinValue(0);
	_progressBar->setMaxValue(100);
	_progressBar->setValue(progress);
	_progressBar->setEnabled(false);
	_percentLabel = new StaticTextWidget(this, "GlobalOptions_Cloud_DownloadDialog.PercentText", Common::String::format("%u %%", progress));
	_downloadSizeLabel = new StaticTextWidget(this, "GlobalOptions_Cloud_DownloadDialog.DownloadSize", "");
	_downloadSpeedLabel = new StaticTextWidget(this, "GlobalOptions_Cloud_DownloadDialog.DownloadSpeed", "");
	if (g_system->getOverlayWidth() > 320)
		_cancelButton = new ButtonWidget(this, "GlobalOptions_Cloud_DownloadDialog.MainButton", _("Cancel download"), 0, kDownloadDialogButtonCmd);
	else
		_cancelButton = new ButtonWidget(this, "GlobalOptions_Cloud_DownloadDialog.MainButton", _c("Cancel download", "lowres"), 0, kDownloadDialogButtonCmd);

	_closeButton = new ButtonWidget(this, "GlobalOptions_Cloud_DownloadDialog.CloseButton", _("Hide"), 0, kCloseCmd);
	refreshWidgets();

	CloudMan.setDownloadTarget(this);
}
コード例 #2
0
void GameStateConfigBase::logic() {
	if (inpt->window_resized)
		refreshWidgets();

	if (defaults_confirm->visible) {
		// reset defaults confirmation
		logicDefaults();
		return;
	}
	else {
		if (!logicMain())
			return;
	}

	// tab contents
	active_tab = tab_control->getActiveTab();

	if (active_tab == AUDIO_TAB)
		logicAudio();
	else if (active_tab == INTERFACE_TAB) {
		logicInterface();

		// by default, hardware mouse cursor can not be turned off
		// that is because this class is used as-is on non-desktop platforms
		hardware_cursor_cb->Check();
		HARDWARE_CURSOR = true;
	}
	else if (active_tab == MODS_TAB)
		logicMods();
}
コード例 #3
0
void Scene::reset() {
	frame_counter = 0;
	pause_frames = 0;
	caption = "";
	clearArt();
	clearSound();
	delete caption_box;
	caption_box = NULL;
	vscroll_offset = 0;
	vscroll_y = 0;
	for (size_t i = 0; i < vscroll_components.size(); ++i) {
		if (vscroll_components[i].image)
			delete vscroll_components[i].image;
		if (vscroll_components[i].text)
			delete vscroll_components[i].text;
	}
	vscroll_components.clear();

	prev_sub_index = 0;
	if (sub_index > 0)
		prev_sub_index = sub_index - 1;

	sub_index = 0;

	refreshWidgets();
}
コード例 #4
0
ファイル: editWidget.cpp プロジェクト: askubis/RESpecTa
EditWidget::EditWidget(RESpecTa *parent, Model * newmod )
    : QStackedWidget(parent)
{
    this->setMinimumWidth(230);
stateWidget = new StateWidget(this, newmod);
    this->addWidget(stateWidget);//,tr("State"));
transWidget = new TransWidget(this, newmod);
    this->addWidget(transWidget);//, tr("Transition"));
subtaskWidget = new SubtaskWidget(this, newmod);
    this->addWidget(subtaskWidget);//, tr("Subtasks"));
this->addWidget(new QWidget());

    connect(this, SIGNAL(currentChanged(int)), this, SLOT(refreshWidget(int)));

    connect(subtaskWidget, SIGNAL(added(QString)), parent, SLOT(SubtaskAdded(QString)));
    connect(subtaskWidget, SIGNAL(changed(QString,QString)), parent, SLOT(SubtaskChanged(QString, QString)));
    connect(subtaskWidget, SIGNAL(removed(QString)), parent, SLOT(SubtaskRemoved(QString)));
    connect(subtaskWidget, SIGNAL(reportError(QString)), this, SLOT(forwardError(QString)));
    connect(subtaskWidget, SIGNAL(UncheckTasksAction()), parent, SLOT(HideTheSubtask()));

    //connect (stateWidget, SIGNAL(InsertState(BaseState*)), parent,SLOT(InsertState(BaseState*)));
    connect (stateWidget, SIGNAL(ReplaceState(BaseState * , BaseState * )), parent,SLOT(ReplaceState(BaseState * , BaseState * )));
    connect (stateWidget, SIGNAL(reportError(QString)), this, SLOT(forwardError(QString)));

    //connect (transWidget, SIGNAL(insertTransition(std::pair<QString,QString>)), parent,SLOT(insertTransition(std::pair<QString,QString>)));
    connect (transWidget, SIGNAL(reportError(QString)), this, SLOT(forwardError(QString)));

    connect(parent, SIGNAL(refreshWidgets()), this, SLOT(refreshAllWidgets()));
    connect(parent, SIGNAL(SignalDeleted()), this, SLOT(SignalDeleted()));
    this->setCurrentIndex(3);
}
コード例 #5
0
ファイル: GameStatePlay.cpp プロジェクト: fkeet/flare-engine
GameStatePlay::GameStatePlay()
	: GameState()
	, enemy(NULL)
	, loading(new WidgetLabel())
	, loading_bg(NULL)
	// Load the loading screen image (we currently use the confirm dialog background):
	, npc_id(-1)
	, eventDialogOngoing(false)
	, eventPendingDialog(false)
	, color_normal(font->getColor("menu_normal"))
	, nearest_npc(-1)
	, game_slot(0) {

	Image *graphics;
	hasMusic = true;
	has_background = false;
	// GameEngine scope variables

	graphics = render_device->loadImage("images/menus/confirm_bg.png");
	if (graphics) {
		loading_bg = graphics->createSprite();
		graphics->unref();
	}

	if (items == NULL)
		items = new ItemManager();

	loot = new LootManager();
	powers = new PowerManager(loot);
	camp = new CampaignManager();
	mapr = new MapRenderer();
	pc = new Avatar();
	enemies = new EnemyManager();
	enemyg = new EnemyGroupManager();
	hazards = new HazardManager();
	menu = new MenuManager(&pc->stats);
	npcs = new NPCManager(&pc->stats);
	quests = new QuestLog(menu->questlog);

	// LootManager needs hero StatBlock
	loot->hero = &pc->stats;

	// assign some object pointers after object creation, based on dependency order
	camp->carried_items = &menu->inv->inventory[CARRIED];
	camp->currency = &menu->inv->currency;
	camp->hero = &pc->stats;

	loading->set(0, 0, JUSTIFY_CENTER, VALIGN_CENTER, msg->get("Loading..."), color_normal);

	// load the config file for character titles
	loadTitles();

	refreshWidgets();
}
コード例 #6
0
void QReportWidgetResizer::setActiveItem(QReportWidgetBase *item)
{
    clear(true);
    _selectedWidgets.clear();
    _selectedWidgets.append(item);
    item->setSelected(true);

    refreshWidgets();

    selectionRect = item->childRect();
    resizeRect = item->childRect();
    setHandlesOnItem(selectionRect);
    setVisible();
}
コード例 #7
0
void Scene::render() {
	if (inpt->window_resized)
		refreshWidgets();

	if (art_scaled) {
		render_device->render(art_scaled);
	}
	else if (art) {
		render_device->render(art);
	}

	if (caption_box && caption != "") {
		caption_box->render();
	}
}
コード例 #8
0
ファイル: GameStateLoad.cpp プロジェクト: igorko/flare-engine
void GameStateLoad::updateButtons() {
	loadPortrait(selected_slot);

	// check status of New Game button
	if (!fileExists(mods->locate("maps/spawn.txt"))) {
		button_new->enabled = false;
		tablist.remove(button_new);
		button_new->tooltip = msg->get("Enable a story mod to continue");
	}

	if (selected_slot >= 0) {
		// slot selected: we can load/delete
		if (button_load->enabled == false) {
			button_load->enabled = true;
			tablist.add(button_load);
		}
		button_load->tooltip = "";

		if (button_delete->enabled == false) {
			button_delete->enabled = true;
			tablist.add(button_delete);
		}

		button_load->label = msg->get("Load Game");
		if (game_slots[selected_slot]->current_map == "") {
			if (!fileExists(mods->locate("maps/spawn.txt"))) {
				button_load->enabled = false;
				tablist.remove(button_load);
				button_load->tooltip = msg->get("Enable a story mod to continue");
			}
		}
	}
	else {
		// no slot selected: can't load/delete
		button_load->label = msg->get("Choose a Slot");
		button_load->enabled = false;
		tablist.remove(button_load);

		button_delete->enabled = false;
		tablist.remove(button_delete);
	}

	button_new->refresh();
	button_load->refresh();
	button_delete->refresh();

	refreshWidgets();
}
コード例 #9
0
GameStatePlay::GameStatePlay()
	: GameState()
	, enemy(NULL)
	, loading(new WidgetLabel())
	, loading_bg(NULL)
	// Load the loading screen image (we currently use the confirm dialog background):
	, npc_id(-1)
	, npc_from_map(true)
	, color_normal(font->getColor("menu_normal"))
	, nearest_npc(-1)
	, menu_enemy_timeout(MAX_FRAMES_PER_SEC*10)
{
	Image *graphics;
	hasMusic = true;
	has_background = false;
	// GameEngine scope variables

	graphics = render_device->loadImage("images/menus/confirm_bg.png");
	if (graphics) {
		loading_bg = graphics->createSprite();
		graphics->unref();
	}

	if (items == NULL)
		items = new ItemManager();

	loot = new LootManager();
	powers = new PowerManager();
	camp = new CampaignManager();
	mapr = new MapRenderer();
	pc = new Avatar();
	enemies = new EnemyManager();
	enemyg = new EnemyGroupManager();
	hazards = new HazardManager();
	menu = new MenuManager(&pc->stats);
	npcs = new NPCManager(&pc->stats);
	quests = new QuestLog(menu->questlog);

	// LootManager needs hero StatBlock
	loot->hero = &pc->stats;

	loading->set(0, 0, JUSTIFY_CENTER, VALIGN_CENTER, msg->get("Loading..."), color_normal);

	// load the config file for character titles
	loadTitles();

	refreshWidgets();
}
コード例 #10
0
void GameStateConfigDesktop::init() {
	VIDEO_TAB = 0;
	AUDIO_TAB = 1;
	INTERFACE_TAB = 2;
	INPUT_TAB = 3;
	KEYBINDS_TAB = 4;
	MODS_TAB = 5;

	tab_control->setTabTitle(VIDEO_TAB, msg->get("Video"));
	tab_control->setTabTitle(AUDIO_TAB, msg->get("Audio"));
	tab_control->setTabTitle(INTERFACE_TAB, msg->get("Interface"));
	tab_control->setTabTitle(INPUT_TAB, msg->get("Input"));
	tab_control->setTabTitle(KEYBINDS_TAB, msg->get("Keybindings"));
	tab_control->setTabTitle(MODS_TAB, msg->get("Mods"));
	tab_control->updateHeader();

	readConfig();

	// Allocate KeyBindings ScrollBox
	input_scrollbox = new WidgetScrollBox(scrollpane.w, scrollpane.h);
	input_scrollbox->setBasePos(scrollpane.x, scrollpane.y);
	input_scrollbox->bg.r = scrollpane_color.r;
	input_scrollbox->bg.g = scrollpane_color.g;
	input_scrollbox->bg.b = scrollpane_color.b;
	input_scrollbox->transparent = false;
	input_scrollbox->resize(scrollpane.w, scrollpane_contents);

	// Set positions of secondary key bindings
	for (unsigned int i = key_count; i < key_count*2; i++) {
		keybinds_btn[i]->pos.x = keybinds_btn[i-key_count]->pos.x + secondary_offset.x;
		keybinds_btn[i]->pos.y = keybinds_btn[i-key_count]->pos.y + secondary_offset.y;
	}

	// Set positions of joystick bindings
	for (unsigned int i = key_count*2; i < keybinds_btn.size(); i++) {
		keybinds_btn[i]->pos.x = keybinds_btn[i-(key_count*2)]->pos.x + (secondary_offset.x*2);
		keybinds_btn[i]->pos.y = keybinds_btn[i-(key_count*2)]->pos.y + (secondary_offset.y*2);
	}

	addChildWidgets();
	addChildWidgetsDesktop();
	setupTabList();

	refreshWidgets();

	update();
}
コード例 #11
0
ファイル: downloaddialog.cpp プロジェクト: 86400/scummvm
void DownloadDialog::handleTickle() {
	if (_close) {
		if (_launcher)
			_launcher->doGameDetection(_localDirectory);
		close();
		_close = false;
		return;
	}

	int32 progress = (int32)(100 * CloudMan.getDownloadingProgress());
	if (_progressBar->getValue() != progress) {
		refreshWidgets();
		draw();
	}

	Dialog::handleTickle();
}
コード例 #12
0
void GameStateConfigBase::init() {
	AUDIO_TAB = 0;
	INTERFACE_TAB = 1;
	MODS_TAB = 2;

	tab_control->setTabTitle(AUDIO_TAB, msg->get("Audio"));
	tab_control->setTabTitle(INTERFACE_TAB, msg->get("Interface"));
	tab_control->setTabTitle(MODS_TAB, msg->get("Mods"));
	tab_control->updateHeader();

	readConfig();

	addChildWidgets();
	setupTabList();

	refreshWidgets();

	update();
}
コード例 #13
0
void Scene::render() {
	if (inpt->window_resized)
		refreshWidgets();

	if (cutscene_type == CUTSCENE_STATIC) {
		if (art_scaled) {
			render_device->render(art_scaled);
		}
		else if (art) {
			render_device->render(art);
		}

		if (caption_box && caption != "") {
			caption_box->render();
		}
	}
	else if (cutscene_type == CUTSCENE_VSCROLL) {
		// Color color = font->getColor("widget_normal");

		for (size_t i = 0; i < vscroll_components.size(); ++i) {
			VScrollComponent& vsc = vscroll_components[i];

			if (vsc.text) {
				if (vsc.text->getBounds()->y <= settings->view_h && (vsc.text->getBounds()->y + vsc.text->getBounds()->h >= 0)) {
					vsc.text->render();
				}
			}
			else if (vsc.image) {
				Point dest(vsc.image->getDest());
				if (dest.y <= settings->view_h && (dest.y + vsc.image_size.y >= 0)) {
					render_device->render(vsc.image);
				}
			}
		}
	}

	// only display the back button if there's more than one scene or subscene
	bool only_scene = is_first_scene && is_last_scene;
	if (!only_scene || (only_scene && cutscene_type == CUTSCENE_STATIC && subscenes.size() > 1))
		button_prev->render();

	button_advance->render();
}
コード例 #14
0
ファイル: downloaddialog.cpp プロジェクト: 86400/scummvm
void DownloadDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
	switch (cmd) {
	case kDownloadDialogButtonCmd:
		{
			CloudMan.setDownloadTarget(nullptr);
			CloudMan.cancelDownload();
			close();
			break;
		}
	case kDownloadProgressCmd:
		if (!_close) {
			refreshWidgets();
			draw();
		}
		break;
	case kDownloadEndedCmd:
		_close = true;
		break;
	default:
		Dialog::handleCommand(sender, cmd, data);
	}
}
コード例 #15
0
void GameStateConfigDesktop::logic() {
	if (inpt->window_resized)
		refreshWidgets();

	if (defaults_confirm->visible) {
		// reset defaults confirmation
		logicDefaults();
		return;
	}
	else if (input_confirm->visible) {
		// assign a keybind
		input_confirm->logic();
		scanKey(input_key);
		input_confirm_ticks--;
		if (input_confirm_ticks == 0) input_confirm->visible = false;
		return;
	}
	else {
		if (!logicMain())
			return;
	}

	// tab contents
	active_tab = tab_control->getActiveTab();

	if (active_tab == VIDEO_TAB)
		logicVideo();
	else if (active_tab == AUDIO_TAB)
		logicAudio();
	else if (active_tab == INTERFACE_TAB)
		logicInterface();
	else if (active_tab == INPUT_TAB)
		logicInput();
	else if (active_tab == KEYBINDS_TAB)
		logicKeybinds();
	else if (active_tab == MODS_TAB)
		logicMods();
}
コード例 #16
0
void Scene::render() {
	if (inpt->window_resized)
		refreshWidgets();

	if (cutscene_type == CUTSCENE_STATIC) {
		if (art_scaled) {
			render_device->render(art_scaled);
		}
		else if (art) {
			render_device->render(art);
		}

		if (caption_box && caption != "") {
			caption_box->render();
		}
	}
	else if (cutscene_type == CUTSCENE_VSCROLL) {
		// Color color = font->getColor("widget_normal");

		for (size_t i = 0; i < vscroll_components.size(); ++i) {
			VScrollComponent& vsc = vscroll_components[i];

			if (vsc.text) {
				if (vsc.text->bounds.y <= VIEW_H && (vsc.text->bounds.y + vsc.text->bounds.h >= 0)) {
					vsc.text->render();
				}
			}
			else if (vsc.image) {
				Point dest = floor(vsc.image->getDest());
				if (dest.y <= VIEW_H && (dest.y + vsc.image_size.y >= 0)) {
					render_device->render(vsc.image);
				}
			}
		}
	}
}
コード例 #17
0
void GameStateConfigBase::logic() {
	if (inpt->window_resized)
		refreshWidgets();

	if (defaults_confirm->visible) {
		// reset defaults confirmation
		logicDefaults();
		return;
	}
	else {
		if (!logicMain())
			return;
	}

	// tab contents
	active_tab = tab_control->getActiveTab();

	if (active_tab == AUDIO_TAB) {
		tablist.setNextTabList(&tablist_audio);
		logicAudio();
	}
	else if (active_tab == INTERFACE_TAB) {
		tablist.setNextTabList(&tablist_interface);
		logicInterface();

		if (platform_options.force_hardware_cursor) {
			// for some platforms, hardware mouse cursor can not be turned off
			hardware_cursor_cb->Check();
			HARDWARE_CURSOR = true;
		}
	}
	else if (active_tab == MODS_TAB) {
		tablist.setNextTabList(&tablist_mods);
		logicMods();
	}
}
コード例 #18
0
/**
 * Process all actions for a single frame
 * This includes some message passing between child object
 */
void GameStatePlay::logic() {
	if (inpt->window_resized)
		refreshWidgets();

	checkCutscene();

	// check menus first (top layer gets mouse click priority)
	menu->logic();

	if (!isPaused()) {

		// these actions only occur when the game isn't paused
		if (pc->stats.alive) checkLoot();
		checkEnemyFocus();
		if (pc->stats.alive) {
			mapr->checkHotspots();
			mapr->checkNearestEvent();
			checkNPCInteraction();
		}
		checkTitle();

		menu->act->checkAction(action_queue);
		pc->logic(action_queue, restrictPowerUse(), npc_id != -1);

		// Transform powers change the actionbar layout,
		// so we need to prevent accidental clicks if a new power is placed under the slot we clicked on.
		// It's a bit hacky, but it works
		if (pc->isTransforming()) {
			menu->act->resetSlots();
		}

		// transfer hero data to enemies, for AI use
		if (pc->stats.get(STAT_STEALTH) > 100) enemies->hero_stealth = 100;
		else enemies->hero_stealth = pc->stats.get(STAT_STEALTH);

		enemies->logic();
		hazards->logic();
		loot->logic();
		enemies->checkEnemiesforXP();
		npcs->logic();

		snd->logic(pc->stats.pos);

		comb->logic(mapr->cam);
	}

	// close menus when the player dies, but still allow them to be reopened
	if (pc->close_menus) {
		pc->close_menus = false;
		menu->closeAll();
	}

	// these actions occur whether the game is paused or not.
	checkTeleport();
	checkLootDrop();
	checkLog();
	checkBook();
	checkEquipmentChange();
	checkUsedItems();
	checkStash();
	checkSaveEvent();
	checkNotifications();
	checkCancel();

	mapr->logic();
	mapr->enemies_cleared = enemies->isCleared();
	quests->logic();

	pc->checkTransform();

	// change hero powers on transformation
	if (pc->setPowers) {
		pc->setPowers = false;
		if (!pc->stats.humanoid && menu->pow->visible) menu->closeRight();
		// save ActionBar state and lock slots from removing/replacing power
		for (int i=0; i<ACTIONBAR_MAX ; i++) {
			menu->act->hotkeys_temp[i] = menu->act->hotkeys[i];
			menu->act->hotkeys[i] = 0;
		}
		int count = ACTIONBAR_MAIN;
		// put creature powers on action bar
		// TODO What if creature has more powers than the size of the action bar?
		for (size_t i=0; i<pc->charmed_stats->powers_ai.size(); i++) {
			if (pc->charmed_stats->powers_ai[i].id != 0 && powers->powers[pc->charmed_stats->powers_ai[i].id].beacon != true) {
				menu->act->hotkeys[count] = pc->charmed_stats->powers_ai[i].id;
				menu->act->locked[count] = true;
				count++;
			}
			if (count == ACTIONBAR_MAX) count = 0;
		}
		if (pc->stats.manual_untransform && pc->untransform_power > 0) {
			menu->act->hotkeys[count] = pc->untransform_power;
			menu->act->locked[count] = true;
		}
		else if (pc->stats.manual_untransform && pc->untransform_power == 0)
			logError("GameStatePlay: Untransform power not found, you can't untransform manually");

		menu->act->updated = true;

		// reapply equipment if the transformation allows it
		if (pc->stats.transform_with_equipment)
			menu->inv->applyEquipment(menu->inv->inventory[EQUIPMENT].storage);
	}
	// revert hero powers
	if (pc->revertPowers) {
		pc->revertPowers = false;

		// restore ActionBar state
		for (int i=0; i<ACTIONBAR_MAX; i++) {
			menu->act->hotkeys[i] = menu->act->hotkeys_temp[i];
			menu->act->locked[i] = false;
		}

		menu->act->updated = true;

		// also reapply equipment here, to account items that give bonuses to base stats
		menu->inv->applyEquipment(menu->inv->inventory[EQUIPMENT].storage);
	}

	// when the hero (re)spawns, reapply equipment & passive effects
	if (pc->respawn) {
		pc->stats.alive = true;
		pc->stats.corpse = false;
		pc->stats.cur_state = AVATAR_STANCE;
		menu->inv->applyEquipment(menu->inv->inventory[EQUIPMENT].storage);
		menu->inv->changed_equipment = true;
		checkEquipmentChange();
		powers->activatePassives(&pc->stats);
		pc->stats.logic();
		pc->stats.recalc();
		pc->respawn = false;
	}

	// use a normal mouse cursor is menus are open
	if (menu->menus_open) {
		curs->setCursor(CURSOR_NORMAL);
	}

	// update the action bar as it may have been changed by items
	if (menu->act->updated) {
		menu->act->updated = false;

		// set all hotkeys to their base powers
		for (unsigned i = 0; i < menu->act->slots_count; i++) {
			menu->act->hotkeys_mod[i] = menu->act->hotkeys[i];
		}

		updateActionBar();
	}

	// reload music if changed in the pause menu
	if (menu->exit->reload_music) {
		mapr->loadMusic();
		menu->exit->reload_music = false;
	}
}
コード例 #19
0
bool Scene::logic() {
	if (done) return false;

	bool skip = false;
	if (inpt->pressing[MAIN1] && (!inpt->lock[MAIN1] || cutscene_type == CUTSCENE_VSCROLL)) {
		inpt->lock[MAIN1] = true;
		skip = true;
	}
	if (inpt->pressing[ACCEPT] && (!inpt->lock[ACCEPT] || cutscene_type == CUTSCENE_VSCROLL)) {
		inpt->lock[ACCEPT] = true;
		skip = true;
	}
	if (inpt->pressing[CANCEL] && !inpt->lock[CANCEL]) {
		inpt->lock[CANCEL] = true;
		done = true;
	}

	if (cutscene_type == CUTSCENE_STATIC) {
		/* Pause until specified frame */
		if (!skip && pause_frames != 0 && frame_counter < pause_frames) {
			++frame_counter;
			return true;
		}

		/* parse scene components until next pause */
		while (!components.empty() && components.front().type != "pause") {

			if (components.front().type == "caption") {
				caption = components.front().s;
			}
			else if (components.front().type == "image") {
				if (art) {
					delete art;
					art = NULL;
				}
				if (art_scaled) {
					delete art_scaled;
					art_scaled = NULL;
				}
				Image *graphics = render_device->loadImage(components.front().s);
				if (graphics != NULL) {
					art = graphics->createSprite();
					art_size.x = art->getGraphicsWidth();
					art_size.y = art->getGraphicsHeight();
					graphics->unref();
				}
			}
			else if (components.front().type == "soundfx") {
				if (sid != 0)
					snd->unload(sid);

				sid = snd->load(components.front().s, "Cutscenes");
				snd->play(sid);
			}

			components.pop();
		}

		/* check if current scene has reached the end */
		if (components.empty())
			return false;

		/* setup frame pausing */
		frame_counter = 0;
		pause_frames = components.front().x;
		components.pop();

		refreshWidgets();
	}
	else if (cutscene_type == CUTSCENE_VSCROLL) {
		// populate the list of text/images from config file data
		int next_y = 0;
		while (!components.empty()) {
			if (components.front().type == "text") {
				VScrollComponent vsc;
				vsc.pos.x = VIEW_W/2;
				vsc.pos.y = VIEW_H/2 + next_y;

				vsc.text = new WidgetLabel();
				if (vsc.text) {
					vsc.text->set(vsc.pos.x, vsc.pos.y, JUSTIFY_CENTER, VALIGN_TOP, components.front().s, font->getColor("widget_normal"), "font_captions");
					next_y += vsc.text->bounds.h;
				}

				vscroll_components.push_back(vsc);
			}
			else if (components.front().type == "image") {
				VScrollComponent vsc;

				Image *graphics = render_device->loadImage(components.front().s);
				if (graphics != NULL) {
					vsc.image = graphics->createSprite();
					if (vsc.image) {
						vsc.image_size.x = vsc.image->getGraphicsWidth();
						vsc.image_size.y = vsc.image->getGraphicsHeight();

						vsc.pos.x = VIEW_W/2 - vsc.image_size.x/2;
						vsc.pos.y = VIEW_H/2 + next_y;

						next_y += vsc.image_size.y;

						vscroll_components.push_back(vsc);
					}
					graphics->unref();
				}
			}
			else if (components.front().type == "separator") {
				VScrollComponent vsc;
				vsc.pos.y = VIEW_H/2 + next_y + components.front().x/2;
				next_y += components.front().x;

				vscroll_components.push_back(vsc);
			}
			components.pop();
		}

		vscroll_offset = static_cast<int>(static_cast<float>(vscroll_ticks) * (settings.vscroll_speed * MAX_FRAMES_PER_SEC) / VIEW_H);
		if (skip)
			vscroll_ticks += 8;
		else
			vscroll_ticks++;

		refreshWidgets();

		// scroll has reached the end, quit the scene
		if (!vscroll_components.empty()) {
			VScrollComponent& vsc = vscroll_components.back();
			if (vsc.text && (vsc.text->bounds.y + vsc.text->bounds.h < 0)) {
				return false;
			}
			else if ((vsc.pos.y + vsc.separator_h) - vscroll_offset < 0) {
				return false;
			}
		}
	}

	return true;
}
コード例 #20
0
ファイル: GameStateLoad.cpp プロジェクト: igorko/flare-engine
GameStateLoad::GameStateLoad() : GameState()
	, background(NULL)
	, selection(NULL)
	, portrait_border(NULL)
	, portrait(NULL)
	, loading_requested(false)
	, loading(false)
	, loaded(false)
	, delete_items(true)
	, selected_slot(-1)
	, visible_slots(0)
	, scroll_offset(0)
	, has_scroll_bar(false)
	, game_slot_max(4)
	, text_trim_boundary(0) {

	if (items == NULL)
		items = new ItemManager();

	label_loading = new WidgetLabel();

	// Confirmation box to confirm deleting
	confirm = new MenuConfirm(msg->get("Delete Save"), msg->get("Delete this save?"));
	button_exit = new WidgetButton();
	button_exit->label = msg->get("Exit to Title");

	button_new = new WidgetButton();
	button_new->label = msg->get("New Game");
	button_new->enabled = true;

	button_load = new WidgetButton();
	button_load->label = msg->get("Choose a Slot");
	button_load->enabled = false;

	button_delete = new WidgetButton();
	button_delete->label = msg->get("Delete Save");
	button_delete->enabled = false;

	scrollbar = new WidgetScrollBar();

	// Set up tab list
	tablist = TabList(HORIZONTAL);
	tablist.add(button_exit);
	tablist.add(button_new);

	// Read positions from config file
	FileParser infile;

	// @CLASS GameStateLoad|Description of menus/gameload.txt
	if (infile.open("menus/gameload.txt")) {
		while (infile.next()) {
			// @ATTR button_new|int, int, alignment : X, Y, Alignment|Position of the "New Game" button.
			if (infile.key == "button_new") {
				int x = popFirstInt(infile.val);
				int y = popFirstInt(infile.val);
				ALIGNMENT a = parse_alignment(popFirstString(infile.val));
				button_new->setBasePos(x, y, a);
			}
			// @ATTR button_load|int, int, alignment : X, Y, Alignment|Position of the "Load Game" button.
			else if (infile.key == "button_load") {
				int x = popFirstInt(infile.val);
				int y = popFirstInt(infile.val);
				ALIGNMENT a = parse_alignment(popFirstString(infile.val));
				button_load->setBasePos(x, y, a);
			}
			// @ATTR button_delete|int, int, alignment : X, Y, Alignment|Position of the "Delete Save" button.
			else if (infile.key == "button_delete") {
				int x = popFirstInt(infile.val);
				int y = popFirstInt(infile.val);
				ALIGNMENT a = parse_alignment(popFirstString(infile.val));
				button_delete->setBasePos(x, y, a);
			}
			// @ATTR button_exit|int, int, alignment : X, Y, Alignment|Position of the "Exit to Title" button.
			else if (infile.key == "button_exit") {
				int x = popFirstInt(infile.val);
				int y = popFirstInt(infile.val);
				ALIGNMENT a = parse_alignment(popFirstString(infile.val));
				button_exit->setBasePos(x, y, a);
			}
			// @ATTR portrait|rectangle|Position and dimensions of the portrait image.
			else if (infile.key == "portrait") {
				portrait_dest = toRect(infile.val);
			}
			// @ATTR gameslot|rectangle|Position and dimensions of the first game slot.
			else if (infile.key == "gameslot") {
				gameslot_pos = toRect(infile.val);
			}
			// @ATTR name|label|The label for the hero's name. Position is relative to game slot position.
			else if (infile.key == "name") {
				name_pos = eatLabelInfo(infile.val);
			}
			// @ATTR level|label|The label for the hero's level. Position is relative to game slot position.
			else if (infile.key == "level") {
				level_pos = eatLabelInfo(infile.val);
			}
			// @ATTR class|label|The label for the hero's class. Position is relative to game slot position.
			else if (infile.key == "class") {
				class_pos = eatLabelInfo(infile.val);
			}
			// @ATTR map|label|The label for the hero's current location. Position is relative to game slot position.
			else if (infile.key == "map") {
				map_pos = eatLabelInfo(infile.val);
			}
			// @ATTR slot_number|label|The label for the save slot index. Position is relative to game slot position.
			else if (infile.key == "slot_number") {
				slot_number_pos = eatLabelInfo(infile.val);
			}
			// @ATTR loading_label|label|The label for the "Entering game world..."/"Loading saved game..." text.
			else if (infile.key == "loading_label") {
				loading_pos = eatLabelInfo(infile.val);
			}
			// @ATTR sprite|point|Position for the avatar preview image in each slot
			else if (infile.key == "sprite") {
				sprites_pos = toPoint(infile.val);
			}
			// @ATTR visible_slots|int|The maximum numbers of visible save slots.
			else if (infile.key == "visible_slots") {
				game_slot_max = toInt(infile.val);

				// can't have less than 1 game slot visible
				game_slot_max = std::max(game_slot_max, 1);
			}
			// @ATTR text_trim_boundary|int|The position of the right-side boundary where text will be shortened with an ellipsis. Position is relative to game slot position.
			else if (infile.key == "text_trim_boundary") {
				text_trim_boundary = toInt(infile.val);
			}
			else {
				infile.error("GameStateLoad: '%s' is not a valid key.", infile.key.c_str());
			}
		}
		infile.close();
	}

	// prevent text from overflowing on the right edge of game slots
	if (text_trim_boundary == 0 || text_trim_boundary > gameslot_pos.w)
		text_trim_boundary = gameslot_pos.w;

	button_new->refresh();
	button_load->refresh();
	button_delete->refresh();

	loadGraphics();
	readGameSlots();

	color_normal = font->getColor("menu_normal");

	refreshWidgets();
	updateButtons();

	// if we specified a slot to load at launch, load it now
	if (!LOAD_SLOT.empty()) {
		size_t load_slot_id = toInt(LOAD_SLOT) - 1;
		LOAD_SLOT.clear();

		if (load_slot_id < game_slots.size()) {
			setSelectedSlot(static_cast<int>(load_slot_id));
			loading_requested = true;
		}
	}

	render_device->setBackgroundColor(Color(0,0,0,0));
}
コード例 #21
0
int Scene::logic() {
	button_prev->enabled = !(is_first_scene && sub_index == 0);

	if (is_last_scene && (cutscene_type == CUTSCENE_VSCROLL || sub_index+1 >= subscenes.size()))
		button_advance = button_close;
	else
		button_advance = button_next;

	int skip = SKIP_NONE;
	if (button_prev->checkClick()) {
		skip = SKIP_PREV;
	}
	else if (button_advance->checkClick()) {
		skip = SKIP_NEXT;
	}
	else if (inpt->pressing[Input::MAIN1] && Utils::isWithinRect(button_prev->pos, inpt->mouse)) {
		inpt->lock[Input::MAIN1] = true;
	}

	if (!button_prev->pressed && !button_advance->pressed) {
		if (inpt->pressing[Input::MAIN1] && (!inpt->lock[Input::MAIN1] || cutscene_type == CUTSCENE_VSCROLL)) {
			inpt->lock[Input::MAIN1] = true;
			skip = SKIP_SUBSCENE;
		}
		else if (inpt->pressing[Input::ACCEPT] && (!inpt->lock[Input::ACCEPT] || cutscene_type == CUTSCENE_VSCROLL)) {
			inpt->lock[Input::ACCEPT] = true;
			skip = SKIP_SUBSCENE;
		}
		else if (inpt->pressing[Input::RIGHT] && !inpt->lock[Input::RIGHT]) {
			inpt->lock[Input::RIGHT] = true;
			skip = SKIP_NEXT;
		}
		else if (button_prev->enabled && inpt->pressing[Input::LEFT] && !inpt->lock[Input::LEFT]) {
			inpt->lock[Input::LEFT] = true;
			skip = SKIP_PREV;
		}
		else if (inpt->pressing[Input::CANCEL] && !inpt->lock[Input::CANCEL]) {
			inpt->lock[Input::CANCEL] = true;
			return DONE;
		}
		else if (cutscene_type == CUTSCENE_VSCROLL && inpt->pressing[Input::UP]) {
			vscroll_y -= VSCROLL_SPEED;
			if (vscroll_y < 0)
				vscroll_y = 0;
		}
		else if (cutscene_type == CUTSCENE_VSCROLL && inpt->pressing[Input::DOWN]) {
			vscroll_y += VSCROLL_SPEED;
		}
	}

	if (cutscene_type == CUTSCENE_STATIC) {
		if (skip == SKIP_PREV) {
			// Go to the previous subscene (or scene if we're on the first subscene)
			if (sub_index == 0) {
				reset();
				return PREV;
			}
			else {
				reset();
			}
		}
		else if (skip == SKIP_NONE && pause_frames != 0 && (frame_counter < pause_frames || pause_frames == -1)) {
			// Pause until specified frame
			// we use -1 to pause indefinitely
			if (pause_frames > 0)
				++frame_counter;
			return NO_CHANGE;
		}
		else if (skip == SKIP_SUBSCENE || skip == SKIP_NEXT || (pause_frames != 0 && frame_counter == pause_frames)) {
			// Go to the next subscene/scene
			sub_index++;
		}

		std::string image_filename;
		std::string sfx_filename;

		// parse scene components until next pause
		if (sub_index < subscenes.size()) {
			for (size_t i = subscenes[sub_index]; i < components.size(); ++i) {
				if (components[i].type == "caption") {
					caption = components[i].s;
				}
				else if (components[i].type == "image") {
					image_filename = components[i].s;
					art_scale_type = components[i].x;
				}
				else if (components[i].type == "soundfx") {
					sfx_filename = components[i].s;
				}
				else if (components[i].type == "pause") {
					if (sub_index < prev_sub_index) {
						// if the prev_sub_index > 0, we skip pauses until the sub_index catches up
						sub_index++;
					}
					else {
						// set the pause counter
						pause_frames = components[i].x;
						frame_counter = 0;
						break;
					}

					// reset the prev_sub_index when sub_index has caught up
					if (sub_index == prev_sub_index) {
						prev_sub_index = 0;
					}
				}
			}
		}

		// set subscene image
		if (!image_filename.empty()) {
			clearArt();

			Image *graphics = render_device->loadImage(image_filename, RenderDevice::ERROR_NORMAL);
			if (graphics != NULL) {
				art = graphics->createSprite();
				art_size.x = art->getGraphicsWidth();
				art_size.y = art->getGraphicsHeight();
				graphics->unref();
			}
		}

		// set subscene soundfx
		if (!sfx_filename.empty()) {
			clearSound();

			sid = snd->load(sfx_filename, "Cutscenes");
			snd->play(sid, snd->DEFAULT_CHANNEL, snd->NO_POS, !snd->LOOP);
		}

		// check if current scene has reached the end
		if (sub_index >= subscenes.size() || subscenes[sub_index] >= components.size())
			return NEXT;

		refreshWidgets();
	}
	else if (cutscene_type == CUTSCENE_VSCROLL) {
		if (skip == SKIP_PREV) {
			reset();
			return PREV;
		}

		if (vscroll_components.empty()) {
			// populate the list of text/images from config file data
			int next_y = 0;
			for (size_t i = 0; i < components.size(); ++i) {
				if (components[i].type == "text") {
					VScrollComponent vsc;
					vsc.pos.x = settings->view_w/2;
					vsc.pos.y = settings->view_h/2 + next_y;

					vsc.text = new WidgetLabel();
					if (vsc.text) {
						vsc.text->setPos(vsc.pos.x, vsc.pos.y);
						vsc.text->setJustify(FontEngine::JUSTIFY_CENTER);
						vsc.text->setText(components[i].s);
						vsc.text->setFont("font_captions");
						next_y += vsc.text->getBounds()->h;
					}

					vscroll_components.push_back(vsc);
				}
				else if (components[i].type == "image") {
					VScrollComponent vsc;

					Image *graphics = render_device->loadImage(components[i].s, RenderDevice::ERROR_NORMAL);
					if (graphics != NULL) {
						vsc.image = graphics->createSprite();
						if (vsc.image) {
							vsc.image_size.x = vsc.image->getGraphicsWidth();
							vsc.image_size.y = vsc.image->getGraphicsHeight();

							vsc.pos.x = settings->view_w/2 - vsc.image_size.x/2;
							vsc.pos.y = settings->view_h/2 + next_y;

							next_y += vsc.image_size.y;

							vscroll_components.push_back(vsc);
						}
						graphics->unref();
					}
				}
				else if (components[i].type == "separator") {
					VScrollComponent vsc;
					vsc.pos.y = settings->view_h/2 + next_y + components[i].x/2;
					next_y += components[i].x;

					vscroll_components.push_back(vsc);
				}
			}
		}

		vscroll_offset = static_cast<int>(static_cast<float>(vscroll_y) * (cutscene_settings.vscroll_speed * settings->max_frames_per_sec) / settings->view_h);
		if (skip == SKIP_NEXT)
			return NEXT;
		else if (skip == SKIP_SUBSCENE)
			vscroll_y += VSCROLL_SPEED;
		else
			vscroll_y++;

		refreshWidgets();

		// scroll has reached the end, quit the scene
		if (!vscroll_components.empty()) {
			VScrollComponent& vsc = vscroll_components.back();
			if (vsc.text && (vsc.text->getBounds()->y + vsc.text->getBounds()->h < 0)) {
				return NEXT;
			}
			else if ((vsc.pos.y + vsc.separator_h) - vscroll_offset < 0) {
				return NEXT;
			}
		}
	}

	return NO_CHANGE;
}
コード例 #22
0
ファイル: GameStateLoad.cpp プロジェクト: igorko/flare-engine
void GameStateLoad::logic() {

	if (inpt->window_resized)
		refreshWidgets();

	for (size_t i = 0; i < game_slots.size(); ++i) {
		if (static_cast<int>(i) == selected_slot) {
			if (game_slots[i]->preview_turn_ticks > 0)
				game_slots[i]->preview_turn_ticks--;

			if (game_slots[i]->preview_turn_ticks == 0) {
				game_slots[i]->preview_turn_ticks = GAMESLOT_PREVIEW_TURN_DURATION;

				game_slots[i]->stats.direction++;
				if (game_slots[i]->stats.direction > 7)
					game_slots[i]->stats.direction = 0;
			}
		}
		game_slots[i]->preview.logic();
	}

	if (!confirm->visible) {
		tablist.logic(true);
		if (button_exit->checkClick() || (inpt->pressing[CANCEL] && !inpt->lock[CANCEL])) {
			inpt->lock[CANCEL] = true;
			showLoading();
			setRequestedGameState(new GameStateTitle());
		}

		if (loading_requested) {
			loading = true;
			loading_requested = false;
			logicLoading();
		}

		bool outside_scrollbar = true;

		if (button_new->checkClick()) {
			// create a new game
			showLoading();
			GameStateNew* newgame = new GameStateNew();
			newgame->game_slot = (game_slots.empty() ? 1 : game_slots.back()->id+1);
			delete_items = false;
			setRequestedGameState(newgame);
		}
		else if (button_load->checkClick()) {
			loading_requested = true;
		}
		else if (button_delete->checkClick()) {
			// Display pop-up to make sure save should be deleted
			confirm->visible = true;
			confirm->render();
		}
		else if (game_slots.size() > 0) {
			Rect scroll_area = slot_pos[0];
			scroll_area.h = slot_pos[0].h * game_slot_max;

			if (isWithinRect(scroll_area, inpt->mouse)) {
				if (inpt->pressing[MAIN1] && !inpt->lock[MAIN1]) {
					for (int i=0; i<visible_slots; ++i) {
						if (isWithinRect(slot_pos[i], inpt->mouse)) {
							inpt->lock[MAIN1] = true;
							setSelectedSlot(i + scroll_offset);
							updateButtons();
							break;
						}
					}
				}
				else if (inpt->scroll_up) {
					scrollUp();
				}
				else if (inpt->scroll_down) {
					scrollDown();
				}
			}
			else if (has_scroll_bar) {
				switch (scrollbar->checkClick(inpt->mouse.x, inpt->mouse.y)) {
					case 1:
						scrollUp();
						outside_scrollbar = false;
						break;
					case 2:
						scrollDown();
						outside_scrollbar = false;
						break;
					case 3:
						scroll_offset = scrollbar->getValue();
						if (scroll_offset >= static_cast<int>(game_slots.size()) - visible_slots) {
							scroll_offset = static_cast<int>(game_slots.size()) - visible_slots;
						}
						outside_scrollbar = false;
						break;
					default:
						break;
				}
			}

			if (outside_scrollbar && inpt->pressing[MAIN1] && !inpt->lock[MAIN1]) {
				inpt->lock[MAIN1] = true;
				setSelectedSlot(-1);
				updateButtons();
			}

			// Allow characters to be navigateable via up/down keys
			if (inpt->pressing[UP] && !inpt->lock[UP]) {
				inpt->lock[UP] = true;
				setSelectedSlot((selected_slot - 1 < 0) ? static_cast<int>(game_slots.size()) - 1 : selected_slot - 1);
				scroll_offset = std::min(static_cast<int>(game_slots.size()) - visible_slots, selected_slot);
				updateButtons();
			}
			else if (inpt->pressing[DOWN] && !inpt->lock[DOWN]) {
				inpt->lock[DOWN] = true;
				setSelectedSlot((selected_slot + 1 == static_cast<int>(game_slots.size())) ? 0 : selected_slot + 1);
				scroll_offset = std::max(0, selected_slot-visible_slots+1);
				updateButtons();
			}
		}
	}
	else if (confirm->visible) {
		confirm->logic();
		if (confirm->confirmClicked) {
			removeSaveDir(game_slots[selected_slot]->id);

			delete game_slots[selected_slot];
			game_slots[selected_slot] = NULL;
			game_slots.erase(game_slots.begin()+selected_slot);

			visible_slots = (game_slot_max > static_cast<int>(game_slots.size()) ? static_cast<int>(game_slots.size()) : game_slot_max);
			setSelectedSlot(-1);

			while (scroll_offset + visible_slots > static_cast<int>(game_slots.size())) {
				scroll_offset--;
			}

			updateButtons();

			confirm->visible = false;
			confirm->confirmClicked = false;
		}
	}
}
コード例 #23
0
bool Scene::logic() {
	if (done) return false;

	bool skip = false;
	if (inpt->pressing[MAIN1] && !inpt->lock[MAIN1]) {
		inpt->lock[MAIN1] = true;
		skip = true;
	}
	if (inpt->pressing[ACCEPT] && !inpt->lock[ACCEPT]) {
		inpt->lock[ACCEPT] = true;
		skip = true;
	}
	if (inpt->pressing[CANCEL] && !inpt->lock[CANCEL]) {
		inpt->lock[CANCEL] = true;
		done = true;
	}

	/* Pause until specified frame */
	if (!skip && pause_frames != 0 && frame_counter < pause_frames) {
		++frame_counter;
		return true;
	}

	/* parse scene components until next pause */
	while (!components.empty() && components.front().type != "pause") {

		if (components.front().type == "caption") {
			caption = components.front().s;
		}
		else if (components.front().type == "image") {
			if (art) {
				delete art;
				art = NULL;
			}
			if (art_scaled) {
				delete art_scaled;
				art_scaled = NULL;
			}
			Image *graphics = render_device->loadImage(components.front().s);
			if (graphics != NULL) {
				art = graphics->createSprite();
				art_size.x = art->getGraphicsWidth();
				art_size.y = art->getGraphicsHeight();
				graphics->unref();
			}
		}
		else if (components.front().type == "soundfx") {
			if (sid != 0)
				snd->unload(sid);

			sid = snd->load(components.front().s, "Cutscenes");
			snd->play(sid);
		}

		components.pop();
	}

	/* check if current scene has reached the end */
	if (components.empty())
		return false;

	/* setup frame pausing */
	frame_counter = 0;
	pause_frames = components.front().x;
	components.pop();

	refreshWidgets();

	return true;
}
コード例 #24
0
ファイル: downloaddialog.cpp プロジェクト: 86400/scummvm
void DownloadDialog::reflowLayout() {
	Dialog::reflowLayout();
	refreshWidgets();
}
コード例 #25
0
ファイル: vineuralnetworkwidget.cpp プロジェクト: EQ4/Visore
void ViNeuralNetworkWidget::resizeEvent(QResizeEvent *event)
{
	refreshWidgets();
}