Example #1
0
bool CVarManager::RegCVar(CVar* var)
{
	CVar* temp = findItem(var->getName());
	
	if (temp)
		return false;

	addItem(var);

	if ((var->getFlags() & CFLAG_USER) && m_bUserLoaded)
		loadUser(var);
	else if ((var->getFlags() & CFLAG_WINUSER) && m_bWinUserLoaded)
		loadWinUser(var);
	else if (m_bNormalLoaded)
		loadNormal(var);

	return true;
}
Example #2
0
void CGEEngine::runGame() {
	if (_quitFlag)
		return;

	loadHeroXY();

	_sceneLight->_flags._tran = true;
	_vga->_showQ->append(_sceneLight);
	_sceneLight->_flags._hide = false;

	const Seq pocSeq[] = {
		{ 0, 0, 0, 0, 20 },
		{ 1, 2, 0, 0,  4 },
		{ 2, 3, 0, 0,  4 },
		{ 3, 4, 0, 0, 16 },
		{ 2, 5, 0, 0,  4 },
		{ 1, 6, 0, 0,  4 },
		{ 0, 1, 0, 0, 16 },
	};
	Seq *seq = (Seq *)malloc(7 * sizeof(Seq));
	Common::copy(pocSeq, pocSeq + 7, seq);
	_pocLight->setSeq(seq);

	_pocLight->_flags._tran = true;
	_pocLight->_time = 1;
	_pocLight->_z = 120;
	_vga->_showQ->append(_pocLight);
	selectPocket(-1);

	_vga->_showQ->append(_mouse);

	loadUser();

	if ((_sprite = _vga->_spareQ->locate(121)) != NULL)
		_commandHandlerTurbo->addCommand(kCmdSeq, -1, _vga->_mono, _sprite);
	if ((_sprite = _vga->_spareQ->locate(122)) != NULL)
		_sprite->step(_music);
	_commandHandlerTurbo->addCommand(kCmdSeq, -1, _music, _sprite);
	if (!_music)
		_midiPlayer->killMidi();

	if (_resman->exist("MINI.SPR")) {
		_miniShp = new BitmapPtr[2];
		_miniShp[0] = _miniShp[1] = NULL;

		loadSprite("MINI", -1, 0, kMiniX, kMiniY);
		expandSprite(_miniScene = _sprite);  // NULL is ok
		if (_miniScene) {
			_miniScene->_flags._kill = false;
			_miniScene->_flags._hide = true;
			_miniShp[0] = new Bitmap(this, *_miniScene->shp());
			_miniShpList = _miniScene->setShapeList(_miniShp);
			postMiniStep(-1);
		}
	}

	if (_hero) {
		expandSprite(_hero);
		_hero->gotoxy(_heroXY[_now - 1].x, _heroXY[_now - 1].y);
		if (_resman->exist("00SHADOW.SPR")) {
			loadSprite("00SHADOW", -1, 0, _hero->_x + 14, _hero->_y + 51);
			delete _shadow;
			if ((_shadow = _sprite) != NULL) {
				_shadow->_ref = 2;
				_shadow->_flags._tran = true;
				_shadow->_flags._kill = false;
				_hero->_flags._shad = true;
				_vga->_showQ->insert(_vga->_spareQ->remove(_shadow), _hero);
			}
		}
	}

	_infoLine->gotoxy(kInfoX, kInfoY);
	_infoLine->_flags._tran = true;
	_infoLine->update(NULL);
	_vga->_showQ->insert(_infoLine);

	_debugLine->_z = 126;
	_vga->_showQ->insert(_debugLine);

	if (_horzLine) {
		_horzLine->_y = kMapTop - (kMapTop > 0);
		_horzLine->_z = 126;
		_vga->_showQ->insert(_horzLine);
	}

	_mouse->_busy = _vga->_spareQ->locate(kBusyRef);
	if (_mouse->_busy)
		expandSprite(_mouse->_busy);

	_startupMode = 0;

	_commandHandler->addCommand(kCmdLevel, -1, _oldLev, &_sceneLight);
	_sceneLight->gotoxy(kSceneX + ((_now - 1) % kSceneNx) * kSceneDx + kSceneSX,
	                  kSceneY + ((_now - 1) / kSceneNx) * kSceneDy + kSceneSY);
	sceneUp();

	_keyboard->setClient(_sys);
	// main loop
	while (!_endGame && !_quitFlag) {
		if (_flag[3]) // Flag FINIS
			_commandHandler->addCallback(kCmdExec,  -1, 0, kQGame);
		mainLoop();
	}

	// If finishing game due to closing ScummVM window, explicitly save the game
	if (!_endGame && canSaveGameStateCurrently())
		qGame();

	_keyboard->setClient(NULL);
	_commandHandler->addCommand(kCmdClear, -1, 0, NULL);
	_commandHandlerTurbo->addCommand(kCmdClear, -1, 0, NULL);
	_mouse->off();
	_vga->_showQ->clear();
	_vga->_spareQ->clear();
	_hero = NULL;
	_shadow = NULL;
}
Example #3
0
void MainWindow::eventTick() {
  if (torrents_enabled) {
    if (torrent_refresh_time == 0) {
      refreshTorrentListing();
    }

    torrent_refresh_time--;

    ui->refreshButton->setText(
        tr("Refresh (%1)").arg(QString::number(torrent_refresh_time)));
  } else {
    ui->refreshButton->setText(tr("Refresh"));
  }

  if (user_refresh_time == 0) {
    user_refresh_time =
        settings->getValue(Settings::UserRefreshTime, D_USER_REFRESH_TIME)
            .toInt();
    loadUser();
  }

  for (int i = 0; i < airing_anime.count(); i++) {
    AiringAnime *aa = airing_anime.at(i);

    if (!aa->getAnime()->needsLoad()) aa->tick();
  }

  user_refresh_time--;

  qint64 seconds = uptime_timer->elapsed() / 1000;
  int minutes = seconds / 60;
  int hours = seconds / 60.0 / 60;
  int days = seconds / 60.0 / 60.0 / 24;

  seconds %= 60;
  minutes %= 60;
  hours %= 24;

  QString format = "";
  QString comma = "";

  if (days > 1) {
    format += QString::number(days) + tr(" days");
  } else if (days > 0) {
    format += QString::number(days) + tr(" day");
  }

  if (days > 0) comma = ", ";

  if (hours > 1) {
    format += comma + QString::number(hours) + tr(" hours");
  } else if (hours > 0) {
    format += comma + QString::number(hours) + tr(" hour");
  }

  if (hours > 0) comma = ", ";

  if (days == 0) {
    if (minutes > 1) {
      format += comma + QString::number(minutes) + tr(" minutes");
    } else if (minutes > 0) {
      format += comma + QString::number(minutes) + tr(" minute");
    }
  }

  if (minutes > 0) comma = ", ";

  if (hours == 0) {
    if (seconds == 1) {
      format += comma + QString::number(seconds) + tr(" second");
    } else {
      format += comma + QString::number(seconds) + tr(" seconds");
    }
  }

  ui->lblUptime->setText(format);
}
Example #4
0
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent), ui(new Ui::MainWindow) {
  ui->setupUi(this);

  QFile styleFile(":/style.css");
  styleFile.open(QFile::ReadOnly);
  QString styleSheet = QLatin1String(styleFile.readAll());
  qApp->setStyleSheet(styleSheet);

  QPixmap window_icon;
  QFile iconFile(":/icon.png");
  iconFile.open(QFile::ReadOnly);
  QByteArray icon_data = iconFile.readAll();
  window_icon.loadFromData(icon_data);
  qApp->setWindowIcon(QIcon(window_icon));

  awesome = new QtAwesome(qApp);
  settings = new Settings(this);
  window_watcher = new WindowWatcher(this);
  anitomy = new AnitomyWrapper();
  event_timer = new QTimer(this);
  watch_timer = new QTimer(this);
  uptime_timer = new QElapsedTimer;
  progress_bar = new QProgressBar(ui->statusBar);
  over = new Overlay(this);
  torrent_refresh_time = 0;
  user_refresh_time =
      settings->getValue(Settings::UserRefreshTime, D_USER_REFRESH_TIME)
          .toInt();
  download_rule = 0;
  download_count = 0;
  hasUser = false;

  uptime_timer->start();
  watch_timer->setSingleShot(true);

  awesome->initFontAwesome();

  bool check_for_updates =
      settings->getValue(Settings::CheckUpdates, D_CHECK_FOR_UPDATES).toBool();

  if (check_for_updates) {
    connect(FvUpdater::sharedUpdater(), &FvUpdater::restartRequested,
            [&]() {  // NOLINT
              QString app = QApplication::applicationFilePath();
              QStringList arguments = QApplication::arguments();
              QString wd = QDir::currentPath();
              QProcess::startDetached(app, arguments, wd);
              elegantClose(true);
            });

    FvUpdater::sharedUpdater()->CheckForUpdatesSilent();
  }

  QFont font = ui->listTabs->tabBar()->font();
  font.setCapitalization(QFont::Capitalize);
  ui->listTabs->tabBar()->setFont(font);

  int currentYear = QDate::currentDate().year();
  int lowerYear = currentYear - 10;

  while (currentYear > lowerYear) {
    ui->comboYear->addItem(QString::number(currentYear));
    currentYear--;
  }

  QWidget *container = new QWidget(ui->scrollArea);
  layout = new FlowLayout(container);
  ui->scrollArea->setWidget(container);
  container->setLayout(layout);

  QWidget *container2 = new QWidget(ui->scrollArea_2);
  layout2 = new FlowLayout(container2);
  layout2->disableSort();
  ui->scrollArea_2->setWidget(container2);
  container2->setLayout(layout2);

  QVariantMap black;
  black.insert("color", QColor(0, 0, 0));
  black.insert("color-active", QColor(0, 0, 0));
  black.insert("color-disabled", QColor(0, 0, 0));
  black.insert("color-selected", QColor(0, 0, 0));

  ui->airingButton->setIcon(awesome->icon(fa::clocko, black));
  ui->torrentsButton->setIcon(awesome->icon(fa::rss, black));
  ui->animeButton->setIcon(awesome->icon(fa::bars, black));
  ui->seasonsButton->setIcon(awesome->icon(fa::th, black));
  ui->statisticsButton->setIcon(awesome->icon(fa::piechart, black));

  ui->tabWidget->tabBar()->hide();
  ui->tabWidget->setCurrentIndex(UserTabs::tAnime);
  ui->listTabs->setCurrentIndex(0);

  ui->statusBar->addWidget(progress_bar);
  ui->statusBar->layout()->setContentsMargins(1, 0, 0, 0);
  progress_bar->setRange(0, 100);
  progress_bar->setValue(5);
  progress_bar->setFormat("Authorizing");

  QSettings s;
  restoreGeometry(s.value("mainWindowGeometry").toByteArray());
  restoreState(s.value("mainWindowState").toByteArray());

  connect(&user_future_watcher, SIGNAL(finished()), SLOT(userLoaded()));
  connect(&user_list_future_watcher, SIGNAL(finished()),
          SLOT(userListLoaded()));

  connect(ui->animeButton, SIGNAL(clicked()), SLOT(showAnimeTab()));
  connect(ui->airingButton, SIGNAL(clicked()), SLOT(showAiringTab()));
  connect(ui->torrentsButton, SIGNAL(clicked()), SLOT(showTorrentsTab()));
  connect(ui->seasonsButton, SIGNAL(clicked()), SLOT(showBrowseTab()));
  connect(ui->actionSettings, SIGNAL(triggered()), SLOT(showSettings()));
  connect(ui->statisticsButton, SIGNAL(clicked()), SLOT(showStatisticsTab()));

  connect(ui->actionExit, &QAction::triggered, [&, this]() {  // NOLINT
    this->elegantClose();
  });

  connect(ui->actionAbout, &QAction::triggered, [&, this]() {  // NOLINT
    About *about = new About(this);
    about->show();
  });

  connect(ui->actionHelp, &QAction::triggered, [&, this]() {  // NOLINT
    QDesktopServices::openUrl(QUrl("http://app.shinjiru.me/support.php"));
  });

  connect(ui->actionRL, &QAction::triggered, [&, this]() {  // NOLINT
    loadUser();
  });

  connect(ui->actionAS, &QAction::triggered, [&]() {  // NOLINT
    SearchPanel *sp = new SearchPanel(this);
    sp->show();
  });

  connect(ui->actionARR, &QAction::triggered, [&, this]() {  // NOLINT
    SettingsDialog *s = new SettingsDialog(this);
    s->showSmartTitles();

    connect(s, &QDialog::accepted, [&, this]() {  // NOLINT
      Settings set;

      toggleAnimeRecognition(
          set.getValue(Settings::AnimeRecognitionEnabled, D_ANIME_RECOGNITION)
              .toBool());

      torrents_enabled =
          set.getValue(Settings::TorrentsEnabled, D_TORRENTS_ENABLED).toBool();

      reloadSmartTitles();
      reloadRules();
    });
  });

  connect(qApp, SIGNAL(aboutToQuit()), SLOT(elegantClose()));

  connect(ui->actionVAL, SIGNAL(triggered()), SLOT(viewAnimeList()));
  connect(ui->actionVD, SIGNAL(triggered()), SLOT(viewDashboard()));
  connect(ui->actionVP, SIGNAL(triggered()), SLOT(viewProfile()));
  connect(ui->actionEAR, SIGNAL(triggered(bool)),
          SLOT(toggleAnimeRecognition(bool)));
  connect(ui->actionExport, SIGNAL(triggered()), SLOT(exportListJSON()));
  connect(ui->actionUpdate, SIGNAL(triggered()), FvUpdater::sharedUpdater(),
          SLOT(CheckForUpdatesNotSilent()));

  connect(window_watcher, SIGNAL(title_found(QString)), SLOT(watch(QString)));
  connect(watch_timer, SIGNAL(timeout()), SLOT(updateEpisode()));
  connect(event_timer, SIGNAL(timeout()), SLOT(eventTick()));

  connect(ui->torrentTable, SIGNAL(customContextMenuRequested(QPoint)),
          SLOT(torrentContextMenu(QPoint)));
  connect(ui->torrentFilter, SIGNAL(textChanged(QString)),
          SLOT(filterTorrents(QString)));
  connect(ui->chkHideUnknown, SIGNAL(toggled(bool)),
          SLOT(filterTorrents(bool)));
  connect(ui->refreshButton, SIGNAL(clicked()), SLOT(refreshTorrentListing()));

  connect(ui->actionEAR, SIGNAL(toggled(bool)), SLOT(applyEAR()));

  connect(ui->tabWidget, &QTabWidget::currentChanged, [&, this](  // NOLINT
                                                          int tab) {
    if (tab != 0) {
      this->over->removeDrawing("blank_table");
      this->over->removeDrawing("no anime");
      ui->listTabs->show();
      ui->listFilterLineEdit->show();
    } else {
      this->filterList(3);

      if (hasUser && (User::sharedUser()->getAnimeList().count() == 0)) {
        this->addNoAnimePrompt();
      }
    }
  });

  ui->actionEAR->setChecked(
      settings->getValue(Settings::AnimeRecognitionEnabled, D_ANIME_RECOGNITION)
          .toBool());

  this->toggleAnimeRecognition(ui->actionEAR->isChecked());

  QString genrelist =
      "Action, Adult, Adventure, Cars, Comedy, Dementia, Demons, Doujinshi, "
      "Drama, Ecchi, Fantasy, Game, Gender Bender, Harem, Hentai, Historical, "
      "Horror, Josei, Kids, Magic, Martial Arts, Mature, Mecha, Military, "
      "Motion Comic, Music, Mystery, Mythological , Parody, Police, "
      "Psychological, Romance, Samurai, School, Sci-Fi, Seinen, Shoujo, Shoujo "
      "Ai, Shounen, Shounen Ai, Slice of Life, Space, Sports, Super Power, "
      "Supernatural, Thriller, Tragedy, Vampire, Yaoi, Yuri";
  QStringList genres = genrelist.split(", ");

  for (QString genre : genres) {
    QCheckBox *chk = new QCheckBox();

    chk->setText(genre);
    chk->setTristate(true);

    ui->genreList->addWidget(chk);
  }

  connect(ui->listFilterLineEdit, SIGNAL(textChanged(QString)),
          SLOT(filterList(QString)));
  connect(ui->listFilterLineEdit, SIGNAL(returnPressed()), SLOT(showSearch()));
  connect(ui->listTabs, SIGNAL(currentChanged(int)), SLOT(filterList(int)));

  connect(ui->browseButton, SIGNAL(clicked()), SLOT(loadBrowserData()));

  this->show();
  createActions();
  initTray();
  trayIcon->show();

  int result = API::sharedAPI()->verifyAPI();

  if (result == AniListAPI::OK) {
    connect(API::sharedAPI()->sharedAniListAPI(), &AniListAPI::access_granted,
            [&, this]() {  // NOLINT
              progress_bar->setValue(10);
              progress_bar->setFormat("Access granted");
              loadUser();

              event_timer->start(1000);
            });

    connect(API::sharedAPI()->sharedAniListAPI(), &AniListAPI::access_denied,
            [&, this](QString error) {  // NOLINT
              qCritical() << error;

              if (isVisible()) {
                QMessageBox::critical(this, "Shinjiru", tr("Error: ") + error);
              }
            });
  } else if (result == AniListAPI::NO_CONNECTION) {
    qDebug() << "Starting Shinjiru in offline mode";
    hasUser = User::sharedUser()->loadLocal();
  }

  reloadRules();
}