Beispiel #1
0
void LvlMusPlay::updateMusic()
{
    int w_id = MainWinConnect::pMainWin->activeChildWindow();

    switch(w_id)
    {
    case 0:
        setNoMusic();
        updatePlayerState(false);
        break;
    case 1:
        MainWinConnect::pMainWin->dock_LvlSectionProps->loadMusic();
        break;
    case 2:
        setNoMusic();
        updatePlayerState(false);
        break;
    case 3:
        {
            WorldEdit *w = MainWinConnect::pMainWin->activeWldEditWin();
            if(!w) return;
            setMusic(LvlMusPlay::WorldMusic, w->currentMusic, w->currentCustomMusic);
            updatePlayerState(true);
        }
        break;
    default: break;
    }

}
Beispiel #2
0
Common::Error TeenAgentEngine::loadGameState(int slot) {
	debug(0, "loading from slot %d", slot);
	Common::ScopedPtr<Common::InSaveFile> 
		in(_saveFileMan->openForLoading(Common::String::format("teenagent.%02d", slot)));
	if (!in)
		in.reset(_saveFileMan->openForLoading(Common::String::format("teenagent.%d", slot)));

	if (!in)
		return Common::kReadPermissionDenied;

	Resources *res = Resources::instance();

	assert(res->dseg.size() >= 0x6478 + 0x777a);
	char data[0x777a];
	in->seek(0);
	if (in->read(data, 0x777a) != 0x777a) {
		return Common::kReadingFailed;
	}

	memcpy(res->dseg.ptr(0x6478), data, sizeof(data));

	scene->clear();
	inventory->activate(false);
	inventory->reload();

	setMusic(Resources::instance()->dseg.get_byte(0xDB90));

	int id = res->dseg.get_byte(0xB4F3);
	uint16 x = res->dseg.get_word(0x64AF), y = res->dseg.get_word(0x64B1);
	scene->loadObjectData();
	scene->init(id, Common::Point(x, y));
	scene->setPalette(4);
	scene->intro = false;
	return Common::kNoError;
}
Beispiel #3
0
void		Engine::Animation()
{
  if (!setMusic(M_MENU))
    std::cerr << "Warning: cannot load the music" << std::endl;
  this->engine->doAnimation();
  mode = MENU;
}
Beispiel #4
0
void ADLPlayer::toggleSound()
{
	if(musicOn == false) {
		musicOn = true;
		currentMusicType = MUSIC_RANDOM;
		changeMusic(MUSIC_PEACE);
	} else {
		setMusic(false);
	}
}
Beispiel #5
0
void		Engine::OptionMenu()
{
  switch (engine->getEnum<Opt, Opt::e_enum>())
    {
    case Opt::SINGLE_NOSOUND:
      engine->setSingle(0);
      setMusic(M_NONE);
      break;
    case Opt::SINGLE_SOUND:
      engine->setSingle(0);
      setMusic(M_MENU, true);
      break;
    case Opt::MULTI_NOSOUND:
      engine->setSingle(1);
      setMusic(M_NONE);
      break;
    default:
      engine->setSingle(1);
      setMusic(M_MENU, true);
    }
  mode = MENU;
}
Beispiel #6
0
void		Engine::Game()
{
  if (!setMusic(M_GAME))
    std::cerr << "Warning: cannot load the music" << std::endl;
  while (engine->hasScreen() && engine->update())
    this->engine->draw();
  
  if (engine->getSig() == false)
    {
      engine->setSig(true);
      mode = START;
    }
  else
    mode = OPTION_GAME;  
}
Beispiel #7
0
void		Engine::Menu()
{
  if (!setMusic(M_MENU))
    std::cerr << "Warning: cannot load the music" << std::endl;
  switch (engine->getEnum<MenuStart, MenuStart::e_pos>())
    {
    case MenuStart::NEW_GAME:
      mode = NEW_GAME;
      break;
    case MenuStart::LOAD:
      mode = LOAD;
      break;
    case MenuStart::OPTIONS:
      mode = OPTION_MENU;
      break;
    case MenuStart::HIGHSCORE:
      mode = HIGHSCORE;
      break;
    default:
      mode = QUIT;
    }
}
Beispiel #8
0
//Reload opened file data
void MainWindow::on_actionReload_triggered()
{
    if(_is_reloading) return;
    _is_reloading=true;
    BoolReseter rst(&_is_reloading);
    Q_UNUSED(rst);

    QString filePath;
    QRect wnGeom;

    if (activeChildWindow()==1)
    {
        LevelData FileData;
        filePath = activeLvlEditWin()->curFile;

        if(activeLvlEditWin()->isUntitled)
        {
                    QMessageBox::warning(this, tr("File not saved"),
                    tr("File doesn't saved on disk."), QMessageBox::Ok);
                        return;
        }

        if (!QFileInfo(filePath).exists() ) {
            QMessageBox::critical(this, tr("File open error"),
            tr("Can't open the file.\nFile not exist."), QMessageBox::Ok);
                return;
        }

        if(activeLvlEditWin()->LvlData.modified)
        {
            QMessageBox::StandardButton ret = QMessageBox::question(this, tr("Reload file and custom stuff"),
            tr("Do you want to save before reload stuff?"), QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel);
            if((ret==QMessageBox::Cancel)||(ret==0))
                return;
            else
              if(ret==QMessageBox::Yes)
                save();
        }

        //Open level file
        FileData = FileFormats::OpenLevelFile(filePath);

        if( !FileData.ReadFileValid ){
            statusBar()->showMessage(tr("Reloading error"), 2000);
            return;}

        FileData.playmusic = GlobalSettings::autoPlayMusic;
        activeLvlEditWin()->LvlData.modified = false;

        QFile file(filePath+".meta");
        if(QFileInfo(filePath+".meta").exists())
        {
            if (file.open(QIODevice::ReadOnly))
            {
                QString metaRaw;
                QTextStream meta(&file);
                meta.setCodec("UTF-8");
                metaRaw = meta.readAll();
                if(FileData.metaData.script)
                {
                    delete FileData.metaData.script;
                    FileData.metaData.script = NULL;
                }
                FileData.metaData = FileFormats::ReadNonSMBX64MetaData(metaRaw, filePath+".meta");
            }
            else
            {
                QMessageBox::critical(this, tr("File open error"),
                tr("Can't open the file."), QMessageBox::Ok);
            }
        }

        //Remember last section ID and positions!
        int lastSection=0;
        QMap<int, QPair<long, long> > sectionPoss;
        lastSection = activeLvlEditWin()->LvlData.CurSection;
        SetCurrentLevelSection(lastSection);//Need to remember position of current section
        for(int i=0; i<activeLvlEditWin()->LvlData.sections.size(); i++)
        {
            LevelSection sct = activeLvlEditWin()->LvlData.sections[i];
            sectionPoss[sct.id]=QPair<long, long >(sct.PositionX, sct.PositionY);
        }

        activeLvlEditWin()->close();//Close old widget without closing of sub-window

        //Get pointer to current sub-window
        QMdiSubWindow *window = ui->centralWidget->activeSubWindow();

        //Get geometry of current subwindow
        wnGeom = ui->centralWidget->activeSubWindow()->geometry();
        //delete window->widget();
        LevelEdit *chLvlWin = new LevelEdit(window);
        connect(chLvlWin, SIGNAL(forceReload()), this, SLOT(on_actionReload_triggered()));
        window->setWidget(chLvlWin);
        GraphicsWorkspace* gr = static_cast<GraphicsWorkspace *>(chLvlWin->getGraphicsView());
        connect(gr, SIGNAL(zoomValueChanged(QString)), zoom, SLOT(setText(QString)));

        //ui->centralWidget->activeSubWindow()->close();
        LevelEdit *child = chLvlWin;//createLvlChild();
        LvlMusPlay::setNoMusic();
        setMusic(false);
        if ((bool) (child->loadFile(filePath, FileData, configs, GlobalSettings::LvlOpts)))
        {
            child->show();
            ui->centralWidget->activeSubWindow()->setGeometry(wnGeom);
            child->updateGeometry();
            child->ResetPosition();
            statusBar()->showMessage(tr("Level file reloaded"), 2000);
            LvlMusPlay::musicForceReset=true; //reset musics
            updateMenus(true);

            child->setFocus();
            //Restore saved section positions
            for(int i=0; i<child->LvlData.sections.size(); i++)
            {
                if(sectionPoss.contains(child->LvlData.sections[i].id))
                {
                    child->LvlData.sections[i].PositionX=sectionPoss[child->LvlData.sections[i].id].first;
                    child->LvlData.sections[i].PositionY=sectionPoss[child->LvlData.sections[i].id].second;
                }
            }

            SetCurrentLevelSection(lastSection);

            if(GlobalSettings::autoPlayMusic) ui->actionPlayMusic->setChecked(true);
        } else {
                WriteToLog(QtDebugMsg, ">>File loading aborted");
            child->show();
                WriteToLog(QtDebugMsg, ">>Window showed");
            if(activeChildWindow()==1) activeLvlEditWin()->LvlData.modified = false;
                WriteToLog(QtDebugMsg, ">>Option set");
            ui->centralWidget->activeSubWindow()->close();
                WriteToLog(QtDebugMsg, ">>Windows closed");
        }
    }
    else
    if (activeChildWindow()==2)
    {
        filePath = activeNpcEditWin()->curFile;
        QFile fileIn(filePath);

        if(activeNpcEditWin()->isUntitled)
        {
                    QMessageBox::warning(this, tr("File not saved"),
                    tr("File doesn't saved on disk."), QMessageBox::Ok);
                        return;
        }

        if(activeNpcEditWin()->isModyfied)
        {
            QMessageBox::StandardButton ret = QMessageBox::question(this, tr("Reload file and custom stuff"),
            tr("Do you want to save before reload stuff?"), QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel);
            if((ret==QMessageBox::Cancel)||(ret==0))
                return;
            else
              if(ret==QMessageBox::Yes)
                save();
        }

        if (!fileIn.open(QIODevice::ReadOnly)) {
        QMessageBox::critical(this, tr("File open error"),
        tr("Can't open the file."), QMessageBox::Ok);
            return;
        }

        NPCConfigFile FileData = FileFormats::ReadNpcTXTFile(fileIn);
        if( !FileData.ReadFileValid ) return;
        wnGeom = ui->centralWidget->activeSubWindow()->geometry();
        activeNpcEditWin()->isModyfied = false;
        activeNpcEditWin()->close();
        //NpcEdit *child = createNPCChild();

        QMdiSubWindow *npcWindow = ui->centralWidget->activeSubWindow();
        NpcEdit *child = new NpcEdit(&configs, npcWindow);
        npcWindow->setWidget(child);

        if (child->loadFile(filePath, FileData)) {
            statusBar()->showMessage(tr("NPC Config reloaded"), 2000);
            child->show();
            ui->centralWidget->activeSubWindow()->setGeometry(wnGeom);
            updateMenus(true);
        } else {
            child->close();
            npcWindow->close();
        }
    }
    else
    if (activeChildWindow()==3)
    {
        WorldData FileData;
        filePath = activeWldEditWin()->curFile;

        if(activeWldEditWin()->isUntitled)
        {
                    QMessageBox::warning(this, tr("File not saved"),
                    tr("File doesn't saved on disk."), QMessageBox::Ok);
                        return;
        }

        if (!QFileInfo(filePath).exists() ) {
            QMessageBox::critical(this, tr("File open error"),
            tr("Can't open the file.\nFile not exist."), QMessageBox::Ok);
                return;
        }

        if(activeWldEditWin()->WldData.modified){
            QMessageBox::StandardButton ret = QMessageBox::question(this, tr("Reload file and custom stuff"),
            tr("Do you want to save before reload stuff?"), QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel);
            if((ret==QMessageBox::Cancel)||(ret==0))
                return;
            else
              if(ret==QMessageBox::Yes)
                save();
        }

        FileData = FileFormats::OpenWorldFile(filePath);

        if( !FileData.ReadFileValid ){
            statusBar()->showMessage(tr("Reloading error"), 2000);
            return;}

        FileData.filename = QFileInfo(filePath).baseName();
        FileData.path = QFileInfo(filePath).absoluteDir().absolutePath();
        FileData.playmusic = GlobalSettings::autoPlayMusic;
        activeWldEditWin()->WldData.modified = false;

        QFile file(filePath+".meta");
        if(QFileInfo(filePath+".meta").exists())
        {
            if (file.open(QIODevice::ReadOnly))
            {
                QString metaRaw;
                QTextStream meta(&file);
                meta.setCodec("UTF-8");
                metaRaw = meta.readAll();
                FileData.metaData = FileFormats::ReadNonSMBX64MetaData(metaRaw, filePath+".meta");
            }
            else
            {
                QMessageBox::critical(this, tr("File open error"),
                tr("Can't open the file."), QMessageBox::Ok);
            }
        }

        wnGeom = ui->centralWidget->activeSubWindow()->geometry();
        QMdiSubWindow *worldWindow = ui->centralWidget->activeSubWindow();
        long posX = activeWldEditWin()->scene->_viewPort->horizontalScrollBar()->value();
        long posY = activeWldEditWin()->scene->_viewPort->verticalScrollBar()->value();

        activeWldEditWin()->close();

        WorldEdit *child = new WorldEdit(worldWindow);
        connect(child, SIGNAL(forceReload()), this, SLOT(on_actionReload_triggered()));
        worldWindow->setWidget(child);
        GraphicsWorkspace* gr = static_cast<GraphicsWorkspace *>(child->getGraphicsView());

        connect(gr, SIGNAL(zoomValueChanged(QString)), zoom, SLOT(setText(QString)));
        if ( (bool)(child->loadFile(filePath, FileData, configs, GlobalSettings::LvlOpts)) ) {
            child->show();
            ui->centralWidget->activeSubWindow()->setGeometry(wnGeom);
            child->updateGeometry();
            child->ResetPosition();
            updateMenus(true);
            dock_WldSettingsBox->setCurrentWorldSettings();
            if(FileData.HubStyledWorld)
            {
                dock_WldSettingsBox->setVisible(true);
                dock_WldSettingsBox->raise();
            }

            child->scene->_viewPort->horizontalScrollBar()->setValue(posX);
            child->scene->_viewPort->verticalScrollBar()->setValue(posY);

            statusBar()->showMessage(tr("World map file loaded"), 2000);
        } else {
            WriteToLog(QtDebugMsg, ">>File loading aborted");
            child->show();
            WriteToLog(QtDebugMsg, ">>Window showed");
            if(activeChildWindow()==3) activeWldEditWin()->WldData.modified = false;
            WriteToLog(QtDebugMsg, ">>Option set");
            ui->centralWidget->activeSubWindow()->close();
            WriteToLog(QtDebugMsg, ">>Windows closed");
        }

    }

    dock_LvlItemBox->clearFilter();
}
Beispiel #9
0
Common::Error TeenAgentEngine::run() {
	Resources *res = Resources::instance();
	if (!res->loadArchives(_gameDescription))
		return Common::kUnknownError;

	Common::EventManager *_event = _system->getEventManager();

	initGraphics(320, 200, false);

	scene = new Scene;
	inventory = new Inventory;
	console = new Console(this);

	scene->init(this, _system);
	inventory->init(this);

	init();

	CursorMan.pushCursor(res->dseg.ptr(0x00da), 8, 12, 0, 0, 1);

	syncSoundSettings();

	_mixer->playStream(Audio::Mixer::kMusicSoundType, &_musicHandle, music, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, false);
	setMusic(1);
	music->start();

	int load_slot = Common::ConfigManager::instance().getInt("save_slot");
	if (load_slot >= 0) {
		loadGameState(load_slot);
	} else {
		if (!showCDLogo())
			return Common::kNoError;
		if (!showLogo())
			return Common::kNoError;
		if (!showMetropolis())
			return Common::kNoError;
		scene->intro = true;
		scene_busy = true;
		processCallback(0x24c);
	}

	CursorMan.showMouse(true);

	uint32 game_timer = 0;
	uint32 mark_timer = 0;

	Common::Event event;
	Common::Point mouse;
	uint32 timer = _system->getMillis();

	do {
		Object *current_object = scene->findObject(mouse);

		while (_event->pollEvent(event)) {
			if (event.type == Common::EVENT_RTL) {
				deinit();
				return Common::kNoError;
			}

			if ((!scene_busy && inventory->processEvent(event)) || scene->processEvent(event))
				continue;

			//debug(0, "event");
			switch (event.type) {
			case Common::EVENT_KEYDOWN:
				if ((event.kbd.hasFlags(Common::KBD_CTRL) && event.kbd.keycode == Common::KEYCODE_d) ||
					event.kbd.ascii == '~' || event.kbd.ascii == '#') {
					console->attach();
				} else if (event.kbd.hasFlags(0) && event.kbd.keycode == Common::KEYCODE_F5) {
					openMainMenuDialog();
				} if (event.kbd.hasFlags(Common::KBD_CTRL) && event.kbd.keycode == Common::KEYCODE_f) {
					_mark_delay = _mark_delay == 80? 40: 80;
					debug(0, "mark_delay = %u", _mark_delay);
				}
				break;
			case Common::EVENT_LBUTTONDOWN:
				if (scene->getId() < 0)
					break;
				examine(event.mouse, current_object);
				break;
			case Common::EVENT_RBUTTONDOWN:
				//if (current_object)
				//	debug(0, "%d, %s", current_object->id, current_object->name.c_str());
				if (scene->getId() < 0)
					break;

				if (current_object == NULL)
					break;

				if (res->dseg.get_byte(0) == 3 && current_object->id == 1) {
					processCallback(0x5189); //boo!
					break;
				}
				if (res->dseg.get_byte(0) == 4 && current_object->id == 5) {
					processCallback(0x99e0); //getting an anchor
					break;
				}
				use(current_object);
				break;
			case Common::EVENT_MOUSEMOVE:
				mouse = event.mouse;
				break;
			default:
				;
			}
		}

		//game delays: slow 16, normal 11, fast 5, crazy 1
		//mark delays: 4 * (3 - hero_speed), normal == 1
		//game delays in 1/100th of seconds
		uint32 new_timer = _system->getMillis();
		uint32 delta = new_timer - timer;
		timer = new_timer;

		bool tick_game = game_timer <= delta;
		if (tick_game)
			game_timer = _game_delay - ((delta - game_timer) % _game_delay);
		else
			game_timer -= delta;

		bool tick_mark = mark_timer <= delta;
		if (tick_mark)
			mark_timer = _mark_delay - ((delta - mark_timer) % _mark_delay);
		else
			mark_timer -= delta;

		if (tick_game || tick_mark) {
			bool b = scene->render(tick_game, tick_mark, delta);
			if (!inventory->active() && !b && action != kActionNone) {
				processObject();
				action = kActionNone;
				dst_object = NULL;
			}
			scene_busy = b;
		}
		_system->showMouse(scene->getMessage().empty() && !scene_busy);

		bool busy = inventory->active() || scene_busy;

		Graphics::Surface *surface = _system->lockScreen();

		if (!busy) {
			InventoryObject *selected_object = inventory->selectedObject();
			if (current_object || selected_object) {
				Common::String name;
				if (selected_object) {
					name += selected_object->name;
					name += " & ";
				}
				if (current_object)
					name += current_object->name;

				uint w = res->font7.render(NULL, 0, 0, name, 0xd1);
				res->font7.render(surface, (320 - w) / 2, 180, name, 0xd1, true);
#if 0
				if (current_object) {
					current_object->rect.render(surface, 0x80);
					current_object->actor_rect.render(surface, 0x81);
				}
#endif
			}
		}

		inventory->render(surface, tick_game? 1: 0);

		_system->unlockScreen();

		_system->updateScreen();

		console->onFrame();

		uint32 next_tick = MIN(game_timer, mark_timer);
		if (next_tick > 0) {
			_system->delayMillis(next_tick > 40? 40: next_tick);
		}
	} while (!shouldQuit());

	deinit();
	return Common::kNoError;
}
Beispiel #10
0
/**
 * Returns to the MENU
 */
void Menu::returnToMenu() {
	mode = MENU_MODE;
	currentScreen = TITLE_SCREEN;
	setMusic("menu");
}
Beispiel #11
0
void MainWindow::on_actionPlayMusic_triggered(bool checked)
{
    LogDebug("Clicked play music button");
    setMusic(checked);
}
Beispiel #12
0
ADLPlayer::~ADLPlayer() {
    setMusic(false);
}
Beispiel #13
0
//Reload opened file data
void MainWindow::on_actionReload_triggered()
{
    if(m_isFileReloading) return;

    m_isFileReloading = true;
    BoolReseter rst(&m_isFileReloading);
    Q_UNUSED(rst);
    QString filePath;
    QRect wnGeom;
    int activeWindow = activeChildWindow(LastActiveSubWindow);

    if(activeWindow == WND_Level)
    {
        LevelEdit *lvlEdit = activeLvlEditWin(LastActiveSubWindow);
        LevelData FileData;
        filePath = lvlEdit->curFile;

        if(lvlEdit->isUntitled)
        {
            QMessageBox::warning(this, tr("File not saved"),
                                 tr("File doesn't saved on disk."), QMessageBox::Ok);
            return;
        }

        if(!QFileInfo(filePath).exists())
        {
            QMessageBox::critical(this, tr("File open error"),
                                  tr("Can't open the file!\nFile not exist."), QMessageBox::Ok);
            return;
        }

        if(lvlEdit->LvlData.meta.modified)
        {
            QMessageBox::StandardButton ret = QMessageBox::question(this, tr("Reload file and custom stuff"),
                                              tr("Do you want to save before reload stuff?"), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);

            if((ret == QMessageBox::Cancel) || (ret == 0))
                return;
            else if(ret == QMessageBox::Yes)
                save();
        }

        //Open level file
        if(!FileFormats::OpenLevelFile(filePath, FileData))
        {
            formatErrorMsgBox(filePath, FileData.meta.ERROR_info, FileData.meta.ERROR_linenum, FileData.meta.ERROR_linedata);
            statusBar()->showMessage(tr("Reloading error"), 2000);
            return;
        }

        FileData.playmusic = GlobalSettings::autoPlayMusic;
        lvlEdit->LvlData.meta.modified = false;
        //Remember last section ID and positions!
        int lastSection = 0;
        QHash<int, QPair<long, long> > sectionPoss;
        lastSection = lvlEdit->LvlData.CurSection;
        SetCurrentLevelSection(lastSection); //Need to remember position of current section

        for(int i = 0; i < lvlEdit->LvlData.sections.size(); i++)
        {
            LevelSection sct = lvlEdit->LvlData.sections[i];
            sectionPoss[sct.id] = QPair<long, long >(sct.PositionX, sct.PositionY);
        }

        long posX = lvlEdit->scene->m_viewPort->horizontalScrollBar()->value();
        long posY = lvlEdit->scene->m_viewPort->verticalScrollBar()->value();
        lvlEdit->close();//Close old widget without closing of sub-window
        //Get geometry of current subwindow
        wnGeom = LastActiveSubWindow->geometry();
        //delete window->widget();
        LevelEdit *chLvlWin = new LevelEdit(this, LastActiveSubWindow);
        connect(chLvlWin, SIGNAL(forceReload()), this, SLOT(on_actionReload_triggered()));
        LastActiveSubWindow->setWidget(chLvlWin);
        GraphicsWorkspace *gr = static_cast<GraphicsWorkspace *>(chLvlWin->getGraphicsView());
        connect(gr, SIGNAL(zoomValueChanged(QString)), zoom, SLOT(setText(QString)));
        //LastActiveSubWindow->close();
        LevelEdit *child = chLvlWin;//createLvlChild();
        LvlMusPlay::setNoMusic();
        setMusic();

        if(static_cast<bool>(child->loadFile(filePath, FileData, configs, GlobalSettings::LvlOpts)))
        {
            child->show();
            LastActiveSubWindow->setGeometry(wnGeom);
            child->updateGeometry();
            child->ResetPosition();
            statusBar()->showMessage(tr("Level file reloaded"), 2000);
            LvlMusPlay::musicForceReset = true; //reset musics
            updateMenus(LastActiveSubWindow, true);
            child->setFocus();

            //Restore saved section positions
            for(int i = 0; i < child->LvlData.sections.size(); i++)
            {
                if(sectionPoss.contains(child->LvlData.sections[i].id))
                {
                    QPair<long, long> &sct = sectionPoss[child->LvlData.sections[i].id];
                    child->LvlData.sections[i].PositionX = sct.first;
                    child->LvlData.sections[i].PositionY = sct.second;
                }
            }

            SetCurrentLevelSection(lastSection);
            child->scene->m_viewPort->horizontalScrollBar()->setValue(static_cast<int>(posX));
            child->scene->m_viewPort->verticalScrollBar()->setValue(static_cast<int>(posY));

            if(GlobalSettings::autoPlayMusic)
                ui->actionPlayMusic->setChecked(true);

            child->showCustomStuffWarnings();
        }
        else
        {
            LogDebug(">>File loading aborted");
            LogDebug(">>Window showed");
            child->LvlData.meta.modified = false;
            LogDebug(">>Option set");
            LastActiveSubWindow->close();
            LogDebug(">>Windows closed");
        }
    }
    else if(activeWindow == WND_NpcTxt)
    {
        NpcEdit *npcEdit = activeNpcEditWin(LastActiveSubWindow);
        filePath = npcEdit->curFile;

        if(npcEdit->isUntitled)
        {
            QMessageBox::warning(this, tr("File not saved"),
                                 tr("File doesn't saved on disk."), QMessageBox::Ok);
            return;
        }

        if(npcEdit->isModyfied)
        {
            QMessageBox::StandardButton ret = QMessageBox::question(this, tr("Reload file and custom stuff"),
                                              tr("Do you want to save before reload stuff?"), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);

            if((ret == QMessageBox::Cancel) || (ret == 0))
                return;
            else if(ret == QMessageBox::Yes)
                save();
        }

        //        if (!fileIn.open(QIODevice::ReadOnly)) {
        //        QMessageBox::critical(this, tr("File open error"),
        //        tr("Can't open the file!"), QMessageBox::Ok);
        //            return;
        //        }
        NPCConfigFile FileData;

        if(!FileFormats::ReadNpcTXTFileF(filePath, FileData))
        {
            QMessageBox::critical(this, QObject::tr("File open error"), tr("Can't read the file"), QMessageBox::Ok);
            return;
        }

        wnGeom = LastActiveSubWindow->geometry();
        npcEdit->isModyfied = false;
        npcEdit->close();
        //NpcEdit *child = createNPCChild();
        //QMdiSubWindow *npcWindow = LastActiveSubWindow;
        NpcEdit *child = new NpcEdit(&configs, LastActiveSubWindow);
        LastActiveSubWindow->setWidget(child);

        if(child->loadFile(filePath, FileData))
        {
            statusBar()->showMessage(tr("NPC Config reloaded"), 2000);
            child->show();
            LastActiveSubWindow->setGeometry(wnGeom);
            updateMenus(LastActiveSubWindow, true);
        }
        else
        {
            child->close();
            LastActiveSubWindow->close();
        }
    }
    else if(activeWindow == WND_World)
    {
        WorldEdit *wldEdit = activeWldEditWin(LastActiveSubWindow);
        WorldData FileData;
        filePath = wldEdit->curFile;

        if(wldEdit->isUntitled)
        {
            QMessageBox::warning(this, tr("File not saved"),
                                 tr("File doesn't saved on disk."), QMessageBox::Ok);
            return;
        }

        if(!QFileInfo(filePath).exists())
        {
            QMessageBox::critical(this, tr("File open error"),
                                  tr("Can't open the file!\nFile not exist."), QMessageBox::Ok);
            return;
        }

        if(wldEdit->WldData.meta.modified)
        {
            QMessageBox::StandardButton ret = QMessageBox::question(this, tr("Reload file and custom stuff"),
                                              tr("Do you want to save before reload stuff?"), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);

            if((ret == QMessageBox::Cancel) || (ret == 0))
                return;
            else if(ret == QMessageBox::Yes)
                save();
        }

        if(!FileFormats::OpenWorldFile(filePath, FileData))
        {
            formatErrorMsgBox(filePath, FileData.meta.ERROR_info, FileData.meta.ERROR_linenum, FileData.meta.ERROR_linedata);
            statusBar()->showMessage(tr("Reloading error"), 2000);
            return;
        }

        QFileInfo finfo(filePath);
        FileData.meta.filename = util::getBaseFilename(finfo.fileName());
        FileData.meta.path = finfo.absoluteDir().absolutePath();
        FileData.playmusic = GlobalSettings::autoPlayMusic;
        wldEdit->WldData.meta.modified = false;
        wnGeom = LastActiveSubWindow->geometry();
        QMdiSubWindow *worldWindow = LastActiveSubWindow;
        long posX = wldEdit->scene->m_viewPort->horizontalScrollBar()->value();
        long posY = wldEdit->scene->m_viewPort->verticalScrollBar()->value();
        wldEdit->close();
        WorldEdit *child = new WorldEdit(this, worldWindow);
        connect(child, &WorldEdit::forceReload, this, &MainWindow::on_actionReload_triggered);
        worldWindow->setWidget(child);
        GraphicsWorkspace *gr = static_cast<GraphicsWorkspace *>(child->getGraphicsView());
        connect(gr, SIGNAL(zoomValueChanged(QString)), zoom, SLOT(setText(QString)));

        if(bool(child->loadFile(filePath, FileData, configs, GlobalSettings::LvlOpts)))
        {
            child->show();
            LastActiveSubWindow->setGeometry(wnGeom);
            child->updateGeometry();
            child->ResetPosition();
            updateMenus(LastActiveSubWindow, true);
            dock_WldSettingsBox->setCurrentWorldSettings();

            if(FileData.HubStyledWorld)
            {
                dock_WldSettingsBox->setVisible(true);
                dock_WldSettingsBox->raise();
            }

            child->scene->m_viewPort->horizontalScrollBar()->setValue(static_cast<int>(posX));
            child->scene->m_viewPort->verticalScrollBar()->setValue(static_cast<int>(posY));
            statusBar()->showMessage(tr("World map file loaded"), 2000);
            child->showCustomStuffWarnings();
        }
        else
        {
            LogDebug(">>File loading aborted");
            //child->show();
            LogDebug(">>Window showed");
            child->WldData.meta.modified = false;
            LogDebug(">>Option set");
            LastActiveSubWindow->close();
            LogDebug(">>Windows closed");
        }
    }

    dock_LvlItemBox->clearFilter();
}