void VegetationWidget::buildList()
{
	QStringList extList;
	extList << ".png" << ".tga" << ".osgb";
	std::string plantDir = g_SystemContext._workContextDir;
	plantDir.append(CONTEXT_DIR);
	plantDir.append("/Plant/");
	QString grassDir = chineseTextUTF8ToQString(plantDir + "Grass");
	QStringList returnList;
	findAllFilesByExt(grassDir, extList, returnList);
	QStandardItemModel* grassModel = qobject_cast<QStandardItemModel*>(_grassListView->model());
	grassModel->clear();
	for (int i = 0; i < returnList.size(); ++i)
	{
		QFileInfo fileInfo = returnList.at(i);
		QStandardItem* newItem = new QStandardItem(fileInfo.fileName());
		setupIcon(newItem, "grass");
		newItem->setCheckable(true);
		grassModel->appendRow(newItem);
	}
	QString treeDir = chineseTextUTF8ToQString(plantDir + "Tree");
	returnList.clear();
	findAllFilesByExt(treeDir, extList, returnList);
	QStandardItemModel* treeModel = qobject_cast<QStandardItemModel*>(_treeListView->model());
	treeModel->clear();
	for (int i = 0; i < returnList.size(); ++i)
	{
		QFileInfo fileInfo = returnList.at(i);
		QStandardItem* newItem = new QStandardItem(fileInfo.fileName());
		setupIcon(newItem, "tree");
		newItem->setCheckable(true);
		treeModel->appendRow(newItem);
	}
}
Example #2
0
EditEntryWidget::EditEntryWidget(QWidget* parent)
    : EditWidget(parent)
    , m_entry(Q_NULLPTR)
    , m_mainUi(new Ui::EditEntryWidgetMain())
    , m_advancedUi(new Ui::EditEntryWidgetAdvanced())
    , m_autoTypeUi(new Ui::EditEntryWidgetAutoType())
    , m_historyUi(new Ui::EditEntryWidgetHistory())
    , m_mainWidget(new QWidget())
    , m_advancedWidget(new QWidget())
    , m_iconsWidget(new EditWidgetIcons())
    , m_autoTypeWidget(new QWidget())
    , m_editWidgetProperties(new EditWidgetProperties())
    , m_historyWidget(new QWidget())
    , m_entryAttachments(new EntryAttachments(this))
    , m_attachmentsModel(new EntryAttachmentsModel(m_advancedWidget))
    , m_entryAttributes(new EntryAttributes(this))
    , m_attributesModel(new EntryAttributesModel(m_advancedWidget))
    , m_historyModel(new EntryHistoryModel(this))
    , m_sortModel(new QSortFilterProxyModel(this))
    , m_autoTypeAssoc(new AutoTypeAssociations(this))
    , m_autoTypeAssocModel(new AutoTypeAssociationsModel(this))
    , m_autoTypeDefaultSequenceGroup(new QButtonGroup(this))
    , m_autoTypeWindowSequenceGroup(new QButtonGroup(this))
{
    setupMain();
    setupAdvanced();
    setupIcon();
    setupAutoType();
    setupProperties();
    setupHistory();

    connect(this, SIGNAL(accepted()), SLOT(saveEntry()));
    connect(this, SIGNAL(rejected()), SLOT(cancel()));
}
void Ps2SaveFileManager::checkMainDirectory(void) {
	// verify that the main directory (scummvm config + icon) exists
	int ret, fd;
	_mcNeedsUpdate = true;
	ret = _mc->getDir("/ScummVM/*", 0, MAX_MC_ENTRIES, _mcDirList);
	printf("/ScummVM/* res = %d\n", ret);
	if (ret <= 0) { // assume directory doesn't exist
		printf("Dir doesn't exist\n");
		ret = _mc->mkDir("/ScummVM");
		if (ret >= 0) {
			fd = _mc->open("/ScummVM/scummvm.icn", O_WRONLY | O_CREAT);
			if (fd >= 0) {
				uint16 icoSize;
				uint16 *icoBuf = decompressIconData(&icoSize);
				ret = _mc->write(fd, icoBuf, icoSize * 2);
				_mc->close(fd);
				free(icoBuf);

				printf(".icn written\n");
				setupIcon("/ScummVM/icon.sys", "scummvm.icn", "ScummVM", "Configuration");
			} else
				printf("Can't create icon file: %d\n", fd);
		} else
			printf("can't create scummvm directory: %d\n", ret);
	}
}
Example #4
0
void OSystem_SDL::initBackend() {
	// Check if backend has not been initialized
	assert(!_inited);

	// Create the default event source, in case a custom backend
	// manager didn't provide one yet.
	if (_eventSource == 0)
		_eventSource = new SdlEventSource();

	int graphicsManagerType = 0;

	if (_graphicsManager == 0) {
		if (_graphicsManager == 0) {
			_graphicsManager = new SurfaceSdlGraphicsManager(_eventSource);
			graphicsManagerType = 0;
		}
	}

	if (_savefileManager == 0)
		_savefileManager = new DefaultSaveFileManager();

	if (_mixerManager == 0) {
		_mixerManager = new SdlMixerManager();
		// Setup and start mixer
		_mixerManager->init();
	}

#ifdef ENABLE_EVENTRECORDER
	g_eventRec.registerMixerManager(_mixerManager);

	g_eventRec.registerTimerManager(new SdlTimerManager());
#else
	if (_timerManager == 0)
		_timerManager = new SdlTimerManager();
#endif

	if (_audiocdManager == 0) {
		// Audio CD support was removed with SDL 1.3
#if SDL_VERSION_ATLEAST(1, 3, 0)
		_audiocdManager = new DefaultAudioCDManager();
#else
		_audiocdManager = new SdlAudioCDManager();
#endif

	}

	// Setup a custom program icon.
	setupIcon();

	_inited = true;

	ModularBackend::initBackend();

	// We have to initialize the graphics manager before the event manager
	// so the virtual keyboard can be initialized, but we have to add the
	// graphics manager as an event observer after initializing the event
	// manager.
	if (graphicsManagerType == 0)
		((SurfaceSdlGraphicsManager *)_graphicsManager)->initEventObserver();
}
Example #5
0
void Widget::onPrevious()
{
    m_visible.start();
    if (m_previousStack.size() < 1)
        return;
    Message m = m_previousStack.pop();
    m_messageQueue.push_front(m);
    loadDefaults();
    setupFont();
    setupColors();
    setupIcon();
    setupTitle();
    setupContent();
    connectForPosition(m_messageQueue.front().data["pos"]->toString());
    updateFinalWidth();
}
Common::OutSaveFile *Ps2SaveFileManager::openForSaving(const char *filename) {
	int res;
	char dir[256], name[256];

	_screen->wantAnim(true);
	splitPath(filename, dir, name);

	if (!mcReadyForDir(dir)) {
		if (_mcPresent) { // directory doesn't seem to exist yet
			char fullPath[256];
			sprintf(fullPath, "/ScummVM-%s", dir);
			res = _mc->mkDir(fullPath);

			char icoSysDest[256], saveDesc[256];
			sprintf(icoSysDest, "%s/icon.sys", fullPath);
			strcpy(saveDesc, dir);
			if ((saveDesc[0] >= 'a') && (saveDesc[0] <= 'z'))
				saveDesc[0] += 'A' - 'a';
			setupIcon(icoSysDest, "../ScummVM/scummvm.icn", saveDesc, "Savegames");
		}
	}

	if (_mcPresent) {
		char fullPath[256];
		sprintf(fullPath, "/ScummVM-%s/%s", dir, name);
		if (strstr(filename, ".s00") || strstr(filename, ".ASD") || strstr(filename, ".asd")) {
			// this is an autosave
			AutoSaveFile *file = new AutoSaveFile(this, fullPath);
			return file;
		} else {
			UclOutSaveFile *file = new UclOutSaveFile(fullPath, _system, _screen, _mc);
			if (!file->ioFailed()) {
				// we're creating a file, mc will have to be updated next time
				_mcNeedsUpdate = true;
				return file;
			} else
				delete file;
		}
	}

	_screen->wantAnim(false);
	return NULL;
}
Example #7
0
void Widget::onNext()
{
    m_visible.start();
    if (m_messageQueue.size() < 2)
        return;
    Message m = m_messageQueue.front();
    boost::optional<QVariant> tmpManual = m.data["manually_shown"];
    m.data["manually_shown"] = boost::optional<QVariant>(true);
    m_previousStack.push(m);
    m_messageQueue.pop_front();
    loadDefaults();
    setupFont();
    setupColors();
    setupIcon();
    setupTitle();
    setupContent();
    connectForPosition(m_messageQueue.front().data["pos"]->toString());
    updateFinalWidth();
    if (m_messageQueue.front().data["bounce"] && !tmpManual)
        startBounce();
}
Example #8
0
void Widget::processMessageQueue()
{
    if (m_messageQueue.empty()) {
        return;
    }

    if (m_animation.state() == QAbstractAnimation::Running ||
            m_visible.isActive()) {
       //(m_animation.totalDuration() - m_animation.currentTime()) < 50) {
        return;
    }

    QFont boldFont = font();
    boldFont.setBold(true);
    Message& m = m_messageQueue.front();
    loadDefaults();
    if (m.data["aot"]->toBool()) {
        setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint);
        raise();
    }
    setupFont();
    setupColors();
    setupIcon();
    setupTitle();
    setupContent();
    connectForPosition(m.data["pos"]->toString());
    m_animation.setDirection(QAnimationGroup::Forward);
    int width = computeWidth();
    qobject_cast<QPropertyAnimation*>(m_animation.animationAt(0))->setEasingCurve(QEasingCurve::Type(m_settings.get("gui/in_animation").toInt()));
    qobject_cast<QPropertyAnimation*>(m_animation.animationAt(0))->setStartValue(0);
    qobject_cast<QPropertyAnimation*>(m_animation.animationAt(0))->setEndValue(width);
    m_animation.start();
    QString soundCommand = m.data["sc"]->toString();
    if (!soundCommand.isEmpty())
        QProcess::startDetached(soundCommand);
   // m_shortcutGrabber.enableShortcuts();
}
Example #9
0
bool Widget::update(const Message &m)
{
    bool found = false;
    for (QQueue<Message>::iterator it = m_messageQueue.begin(); it != m_messageQueue.end(); ++it) {
        if (it->data["id"] && it->data["id"]->toInt() == m.data["id"]->toInt()) {
            it->data = m.data;
            found = true;
            break;
        }
    }
    if (found && !m_messageQueue.isEmpty() && m_messageQueue.front().data["id"]
        && m_messageQueue.front().data["id"]->toInt() == m.data["id"]->toInt()) {
        loadDefaults();
        setupFont();
        setupColors();
        setupIcon();
        setupTitle();
        setupContent();
        updateFinalWidth();
        connectForPosition(m_messageQueue.front().data["pos"]->toString());
        m_visible.start();
    }
    return found;
}
Example #10
0
void OSystem_SDL::initBackend() {
	assert(!_inited);

	int joystick_num = ConfMan.getInt("joystick_num");
	uint32 sdlFlags = SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER;

	if (ConfMan.hasKey("disable_sdl_parachute"))
		sdlFlags |= SDL_INIT_NOPARACHUTE;

#ifdef _WIN32_WCE
	if (ConfMan.hasKey("use_GDI") && ConfMan.getBool("use_GDI")) {
		SDL_VideoInit("windib", 0);
		sdlFlags ^= SDL_INIT_VIDEO;
	}
#endif

	if (joystick_num > -1)
		sdlFlags |= SDL_INIT_JOYSTICK;

	if (SDL_Init(sdlFlags) == -1) {
		error("Could not initialize SDL: %s", SDL_GetError());
	}

	_graphicsMutex = createMutex();

	SDL_ShowCursor(SDL_DISABLE);

	// Enable unicode support if possible
	SDL_EnableUNICODE(1);

	memset(&_oldVideoMode, 0, sizeof(_oldVideoMode));
	memset(&_videoMode, 0, sizeof(_videoMode));
	memset(&_transactionDetails, 0, sizeof(_transactionDetails));

	_cksumValid = false;
#if !defined(_WIN32_WCE) && !defined(__SYMBIAN32__) && !defined(DISABLE_SCALERS)
	_videoMode.mode = GFX_DOUBLESIZE;
	_videoMode.scaleFactor = 2;
	_videoMode.aspectRatioCorrection = ConfMan.getBool("aspect_ratio");
	_scalerProc = Normal2x;
#else // for small screen platforms
	_videoMode.mode = GFX_NORMAL;
	_videoMode.scaleFactor = 1;
	_videoMode.aspectRatioCorrection = false;
	_scalerProc = Normal1x;
#endif
	_scalerType = 0;
	_modeFlags = 0;

#if !defined(_WIN32_WCE) && !defined(__SYMBIAN32__)
	_videoMode.fullscreen = ConfMan.getBool("fullscreen");
#else
	_videoMode.fullscreen = true;
#endif

#if !defined(MACOSX) && !defined(__SYMBIAN32__)
	// Setup a custom program icon.
	// Don't set icon on OS X, as we use a nicer external icon there.
	// Don't for Symbian: it uses the EScummVM.aif file for the icon.
	setupIcon();
#endif

	// enable joystick
	if (joystick_num > -1 && SDL_NumJoysticks() > 0) {
		printf("Using joystick: %s\n", SDL_JoystickName(0));
		_joystick = SDL_JoystickOpen(joystick_num);
	}


	// Create the savefile manager, if none exists yet (we check for this to
	// allow subclasses to provide their own).
	if (_savefile == 0) {
#ifdef UNIX
	_savefile = new POSIXSaveFileManager();
#else
	_savefile = new DefaultSaveFileManager();
#endif
	}

	// Create and hook up the mixer, if none exists yet (we check for this to
	// allow subclasses to provide their own).
	if (_mixer == 0) {
		setupMixer();
	}

	// Create and hook up the timer manager, if none exists yet (we check for
	// this to allow subclasses to provide their own).
	if (_timer == 0) {
		// Note: We could implement a custom SDLTimerManager by using
		// SDL_AddTimer. That might yield better timer resolution, but it would
		// also change the semantics of a timer: Right now, ScummVM timers
		// *never* run in parallel, due to the way they are implemented. If we
		// switched to SDL_AddTimer, each timer might run in a separate thread.
		// However, not all our code is prepared for that, so we can't just
		// switch. Still, it's a potential future change to keep in mind.
		_timer = new DefaultTimerManager();
		_timerID = SDL_AddTimer(10, &timer_handler, _timer);
	}

	// Invoke parent implementation of this method
	OSystem::initBackend();

	_inited = true;
}
Example #11
0
File: sdl.cpp Project: 33d/scummvm
void OSystem_SDL::initBackend() {
	// Check if backend has not been initialized
	assert(!_inited);

	const int maxNameLen = 20;
	char sdlDriverName[maxNameLen];
	sdlDriverName[0] = '\0';
	SDL_VideoDriverName(sdlDriverName, maxNameLen);
	// Using printf rather than debug() here as debug()/logging
	// is not active by this point.
	debug(1, "Using SDL Video Driver \"%s\"", sdlDriverName);

	// Create the default event source, in case a custom backend
	// manager didn't provide one yet.
	if (_eventSource == 0)
		_eventSource = new SdlEventSource();

#ifdef USE_OPENGL
	// Query the desktop resolution. We simply hope nothing tried to change
	// the resolution so far.
	const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo();
	if (videoInfo && videoInfo->current_w > 0 && videoInfo->current_h > 0) {
		_desktopWidth  = videoInfo->current_w;
		_desktopHeight = videoInfo->current_h;
	}
#endif

	if (_graphicsManager == 0) {
#ifdef USE_OPENGL
		// Setup a list with both SDL and OpenGL graphics modes. We only do
		// this whenever the subclass did not already set up an graphics
		// manager yet. This is because we don't know the type of the graphics
		// manager of the subclass, thus we cannot easily switch between the
		// OpenGL one and the set up one. It also is to be expected that the
		// subclass does not want any switching of graphics managers anyway.
		setupGraphicsModes();

		if (ConfMan.hasKey("gfx_mode")) {
			// If the gfx_mode is from OpenGL, create the OpenGL graphics manager
			Common::String gfxMode(ConfMan.get("gfx_mode"));
			for (uint i = _firstGLMode; i < _graphicsModeIds.size(); ++i) {
				if (!scumm_stricmp(_graphicsModes[i].name, gfxMode.c_str())) {
					_graphicsManager = new OpenGLSdlGraphicsManager(_desktopWidth, _desktopHeight, _eventSource);
					_graphicsMode = i;
					break;
				}
			}
		}
#endif

		if (_graphicsManager == 0) {
			_graphicsManager = new SurfaceSdlGraphicsManager(_eventSource);
		}
	}

	if (_savefileManager == 0)
		_savefileManager = new DefaultSaveFileManager();

	if (_mixerManager == 0) {
		_mixerManager = new SdlMixerManager();
		// Setup and start mixer
		_mixerManager->init();
	}

#ifdef ENABLE_EVENTRECORDER
	g_eventRec.registerMixerManager(_mixerManager);

	g_eventRec.registerTimerManager(new SdlTimerManager());
#else
	if (_timerManager == 0)
		_timerManager = new SdlTimerManager();
#endif

	if (_audiocdManager == 0) {
		// Audio CD support was removed with SDL 1.3
#if SDL_VERSION_ATLEAST(1, 3, 0)
		_audiocdManager = new DefaultAudioCDManager();
#else
		_audiocdManager = new SdlAudioCDManager();
#endif

	}

	// Setup a custom program icon.
	setupIcon();

	_inited = true;

	ModularBackend::initBackend();

	// We have to initialize the graphics manager before the event manager
	// so the virtual keyboard can be initialized, but we have to add the
	// graphics manager as an event observer after initializing the event
	// manager.
	dynamic_cast<SdlGraphicsManager *>(_graphicsManager)->activateManager();
}
Example #12
0
void OSystem_SDL::initBackend() {
	// Check if backend has not been initialized
	assert(!_inited);

	const int maxNameLen = 20;
	char sdlDriverName[maxNameLen];
	sdlDriverName[0] = '\0';
	SDL_VideoDriverName(sdlDriverName, maxNameLen);
	// Using printf rather than debug() here as debug()/logging
	// is not active by this point.
	debug(1, "Using SDL Video Driver \"%s\"", sdlDriverName);

	// Create the default event source, in case a custom backend
	// manager didn't provide one yet.
	if (_eventSource == 0)
		_eventSource = new SdlEventSource();

	if (_graphicsManager == 0) {
		if (_graphicsManager == 0) {
			_graphicsManager = new SurfaceSdlGraphicsManager(_eventSource);
		}
	}

	if (_savefileManager == 0)
		_savefileManager = new DefaultSaveFileManager();

	if (_mixerManager == 0) {
		_mixerManager = new SdlMixerManager();
		// Setup and start mixer
		_mixerManager->init();
	}

#ifdef ENABLE_EVENTRECORDER
	g_eventRec.registerMixerManager(_mixerManager);

	g_eventRec.registerTimerManager(new SdlTimerManager());
#else
	if (_timerManager == 0)
		_timerManager = new SdlTimerManager();
#endif

	if (_audiocdManager == 0) {
		// Audio CD support was removed with SDL 1.3
#if SDL_VERSION_ATLEAST(1, 3, 0)
		_audiocdManager = new DefaultAudioCDManager();
#else
		_audiocdManager = new SdlAudioCDManager();
#endif

	}

	// Setup a custom program icon.
	setupIcon();

	_inited = true;

	ModularBackend::initBackend();

	// We have to initialize the graphics manager before the event manager
	// so the virtual keyboard can be initialized, but we have to add the
	// graphics manager as an event observer after initializing the event
	// manager.
	dynamic_cast<SdlGraphicsManager *>(_graphicsManager)->activateManager();
}
Example #13
0
void OSystem_SDL::initBackend() {
    // Check if backend has not been initialized
    assert(!_inited);

    // Create the default event source, in case a custom backend
    // manager didn't provide one yet.
    if (_eventSource == 0)
        _eventSource = new SdlEventSource();

    int graphicsManagerType = 0;

    if (_graphicsManager == 0) {
#ifdef USE_OPENGL
        if (ConfMan.hasKey("gfx_mode")) {
            Common::String gfxMode(ConfMan.get("gfx_mode"));
            bool use_opengl = false;
            const OSystem::GraphicsMode *mode = OpenGLSdlGraphicsManager::supportedGraphicsModes();
            while (mode->name) {
                if (scumm_stricmp(mode->name, gfxMode.c_str()) == 0)
                    use_opengl = true;

                mode++;
            }

            // If the gfx_mode is from OpenGL, create the OpenGL graphics manager
            if (use_opengl) {
                _graphicsManager = new OpenGLSdlGraphicsManager();
                graphicsManagerType = 1;
            }
        }
#endif
        if (_graphicsManager == 0) {
            _graphicsManager = new SdlGraphicsManager(_eventSource);
            graphicsManagerType = 0;
        }
    }

    // Creates the backend managers, if they don't exist yet (we check
    // for this to allow subclasses to provide their own).
    if (_eventManager == 0)
        _eventManager = new DefaultEventManager(_eventSource);

    // We have to initialize the graphics manager before the event manager
    // so the virtual keyboard can be initialized, but we have to add the
    // graphics manager as an event observer after initializing the event
    // manager.
    if (graphicsManagerType == 0)
        ((SdlGraphicsManager *)_graphicsManager)->initEventObserver();
#ifdef USE_OPENGL
    else if (graphicsManagerType == 1)
        ((OpenGLSdlGraphicsManager *)_graphicsManager)->initEventObserver();
#endif

    if (_savefileManager == 0)
        _savefileManager = new DefaultSaveFileManager();

    if (_mixerManager == 0) {
        _mixerManager = new SdlMixerManager();

        // Setup and start mixer
        _mixerManager->init();
    }

    if (_audiocdManager == 0)
        _audiocdManager = new SdlAudioCDManager();

    // Setup a custom program icon.
    setupIcon();

    _inited = true;
}
Example #14
0
void OSystem_SDL::initBackend() {
	// Check if backend has not been initialized
	assert(!_inited);

	// Create the default event source, in case a custom backend
	// manager didn't provide one yet.
	if (_eventSource == 0)
		_eventSource = new SdlEventSource();

	int graphicsManagerType = 0;

	if (_graphicsManager == 0) {
#ifdef USE_OPENGL
		if (ConfMan.hasKey("gfx_mode")) {
			Common::String gfxMode(ConfMan.get("gfx_mode"));
			bool use_opengl = false;
			const OSystem::GraphicsMode *mode = OpenGLSdlGraphicsManager::supportedGraphicsModes();
			int i = 0;
			while (mode->name) {
				if (scumm_stricmp(mode->name, gfxMode.c_str()) == 0) {
					_graphicsMode = i + _sdlModesCount;
					use_opengl = true;
				}

				mode++;
				++i;
			}

			// If the gfx_mode is from OpenGL, create the OpenGL graphics manager
			if (use_opengl) {
				_graphicsManager = new OpenGLSdlGraphicsManager(_eventSource);
				graphicsManagerType = 1;
			}
		}
#endif
		if (_graphicsManager == 0) {
			_graphicsManager = new SurfaceSdlGraphicsManager(_eventSource);
			graphicsManagerType = 0;
		}
	}

	if (_savefileManager == 0)
		_savefileManager = new DefaultSaveFileManager();

	if (_mixerManager == 0) {
		_mixerManager = new SdlMixerManager();

		// Setup and start mixer
		_mixerManager->init();
	}

	if (_audiocdManager == 0) {
		// Audio CD support was removed with SDL 1.3
#if SDL_VERSION_ATLEAST(1, 3, 0)
		_audiocdManager = new DefaultAudioCDManager();
#else
		_audiocdManager = new SdlAudioCDManager();
#endif

	}

	// Setup a custom program icon.
	setupIcon();

	_inited = true;

	ModularBackend::initBackend();

	// We have to initialize the graphics manager before the event manager
	// so the virtual keyboard can be initialized, but we have to add the
	// graphics manager as an event observer after initializing the event
	// manager.
	if (graphicsManagerType == 0)
		((SurfaceSdlGraphicsManager *)_graphicsManager)->initEventObserver();
#ifdef USE_OPENGL
	else if (graphicsManagerType == 1)
		((OpenGLSdlGraphicsManager *)_graphicsManager)->initEventObserver();
#endif

}