Ejemplo n.º 1
0
void MudGameView::onStart()
{
    if (!loadModules())
        msgBox(m_hWnd, IDS_ERROR_MODULES, MB_OK | MB_ICONSTOP);
   updateProps();
   loadPlugins();
}
Ejemplo n.º 2
0
bool MudGameView::newProfile(const Profile& profile)
{
    saveClientWindowPos();
    savePluginWindowPos();
    unloadPlugins();
    if (!m_manager.saveProfile())
    {
        msgBox(m_hWnd, IDS_ERROR_CURRENTSAVEPROFILE_FAILED, MB_OK | MB_ICONSTOP);
        loadPlugins();
        loadClientWindowPos();
        return false;
    }

    Profile current(m_manager.getProfile());
    bool successed = true;
    if (!m_manager.createEmptyProfile(profile)) {
        msgBox(m_hWnd, IDS_ERROR_NEWPROFILE_FAILED, MB_OK | MB_ICONSTOP);
        successed = false;
    }  
    if (!successed) {
        tstring error;
        m_manager.loadProfile(current, &error);
    }
    updateProps();
    loadClientWindowPos();
    loadPlugins();
    m_bar.reset();
    return successed;
}
Ejemplo n.º 3
0
bool MudGameView::copyProfile(bool fromzip, const Profile& profile, const Profile& src)
{
    saveClientWindowPos();
    savePluginWindowPos();
    unloadPlugins();
    if (!m_manager.saveProfile())
    {
        msgBox(m_hWnd, IDS_ERROR_CURRENTSAVEPROFILE_FAILED, MB_OK | MB_ICONSTOP);
        loadPlugins();
        loadClientWindowPos();
        return false;
    }
    Profile current(m_manager.getProfile());
    bool successed = true;
    tstring error;
    if (fromzip)
    {
        CopyProfileFromZipHelper zip;
        successed = zip.copyProfile("resources\\profiles.pak", src, profile);
        if (!successed)
            error = L"Can't create new profile";
        if (successed) {
            successed = m_manager.loadProfile(profile, &error);
        }
    }
    else
    {
        successed = m_manager.copyProfile(src, profile, &error);
    }

    if (!successed)
    {
        msgBox(m_hWnd, IDS_ERROR_COPYPROFILE_FAILED, error, MB_OK | MB_ICONSTOP); 
    }    
    if (!successed) 
    {
        tstring error;
        m_manager.loadProfile(current, &error);
    }    
    updateProps();
    loadClientWindowPos();
    loadPlugins();
    m_bar.reset();
    return successed;
}
Ejemplo n.º 4
0
void MudGameView::loadProfile(const tstring& name, const tstring& group, tstring* error)
{
    assert(error);
    Profile current(m_manager.getProfile());
    if ((current.group == group || group.empty()) && current.name == name)
    {
        error->assign(L"Попытка загрузить текущий профиль.");
        return;
    }
    Profile profile;
    profile.name = name;
    profile.group = current.group;
    if (!group.empty())
        profile.group = group;
    if (!m_manager.checkProfile(profile))
    {
        error->assign(L"Нет такого профиля.");
        return;
    }
    saveClientWindowPos();
    savePluginWindowPos();
    unloadPlugins();
    if (!m_manager.saveProfile())
    {
        error->assign(L"Не получилось сохранить текущий профиль, чтобы загрузить новый.");
        loadClientWindowPos();
        loadPlugins();
        return;
    }
    if (!m_manager.loadProfile(profile, error))
    {
        //error->assign(L"Не получилось загрузить профиль.");
        tstring dummy;
        m_manager.loadProfile(current, &dummy);
    }
    updateProps();
    loadClientWindowPos();
    loadPlugins();
    m_bar.reset();
}
Ejemplo n.º 5
0
bool MudGameView::loadProfile(const Profile& profile)
{
    bool reload_same_profile = false;
    Profile current(m_manager.getProfile());
    if (current.group == profile.group && current.name == profile.name)
    {
        int result = msgBox(m_hWnd, L"Вы действительно хотите перечитать текущий профиль ?", MB_YESNO|MB_ICONQUESTION);
        if (result != IDYES)
            return false;
        reload_same_profile = true;
    }

    saveClientWindowPos();
    savePluginWindowPos();
    unloadPlugins();
    if (!reload_same_profile)
    {
        if (!m_manager.saveProfile())
        {
            msgBox(m_hWnd, IDS_ERROR_CURRENTSAVEPROFILE_FAILED, MB_OK|MB_ICONSTOP);
            loadClientWindowPos();
            loadPlugins();
            return false;
        }
    }
    tstring error;
    if (!m_manager.loadProfile(profile, &error))
    {
        msgBox(m_hWnd, IDS_ERROR_LOADPROFILE_FAILED, error, MB_OK|MB_ICONSTOP);
        if (!reload_same_profile)
            m_manager.loadProfile(current, &error);
    }
    updateProps();
    if (!reload_same_profile)
       loadClientWindowPos();
    loadPlugins();
    m_bar.reset();
    return (error.empty());
}
Ejemplo n.º 6
0
void SearchReplace::slotDoReplace()
{
	if (m_itemMode)
	{
		QString repl, sear;
		int cs, cx;
		int textLen = 0;
		if (RText->isChecked())
		{
			repl = RTextVal->text();
			sear = STextVal->text();
			textLen = m_item->itemText.lengthOfSelection();
			if (textLen == repl.length())
			{
				for (cs = 0; cs < textLen; ++cs)
					m_item->itemText.replaceChar(m_replStart+cs, repl[cs]);
			}
			else
			{
				if (textLen < repl.length())
				{
					for (cs = 0; cs < textLen; ++cs)
						m_item->itemText.replaceChar(m_replStart+cs, repl[cs]);
					for (cx = cs; cx < repl.length(); ++cx)
						m_item->itemText.insertChars(m_replStart+cx, repl.mid(cx,1), true);
				}
				else
				{
					for (cs = 0; cs < repl.length(); ++cs)
						m_item->itemText.replaceChar(m_replStart+cs, repl[cs]);
					m_item->itemText.removeChars(m_replStart+cs, textLen - cs);
				}
			}
			m_item->itemText.deselectAll();
			if (repl.length() > 0)
			{
				m_item->itemText.select(m_replStart, repl.length());
				m_item->itemText.setCursorPosition(m_replStart + repl.length());
			}
		}
		if (RStyle->isChecked())
		{
			int oldMode = m_doc->appMode;
			m_doc->appMode = modeEdit;
			m_doc->itemSelection_SetNamedParagraphStyle(m_doc->paragraphStyles()[RStyleVal->currentIndex()].name());
			m_doc->appMode = oldMode;
		}
		if (RAlign->isChecked())
		{
			int oldMode = m_doc->appMode;
			m_doc->appMode = modeEdit;
			m_doc->itemSelection_SetAlignment(RAlignVal->currentIndex());
			m_doc->appMode = oldMode;
		}
		if (RFill->isChecked())
			m_doc->itemSelection_SetFillColor(RFillVal->currentText());
		if (RFillS->isChecked())
			m_doc->itemSelection_SetFillShade(RFillSVal->getValue());
		if (RStroke->isChecked())
			m_doc->itemSelection_SetStrokeColor(RStrokeVal->currentText());
		if (RStrokeS->isChecked())
			m_doc->itemSelection_SetStrokeShade(RStrokeSVal->getValue());
		if (RFont->isChecked())
			m_doc->itemSelection_SetFont(RFontVal->currentText());
		if (RSize->isChecked())
			m_doc->itemSelection_SetFontSize(qRound(RSizeVal->value() * 10.0));
		if (REffect->isChecked() && (m_item->itemText.lengthOfSelection() > 0))
		{
			int s = REffVal->getStyle() & ScStyle_UserStyles;
			m_doc->currentStyle.charStyle().setFeatures(static_cast<StyleFlag>(s).featureList()); // ???
			for (int a = 0; a < m_item->itemText.length(); ++a)
			{
				if (m_item->itemText.selected(a))
				{
//                    StyleFlag fl = m_item->itemText.charStyle(a).effects();
//					fl &= static_cast<StyleFlag>(~1919);
//					fl |= static_cast<StyleFlag>(s);
//					m_item->itemText.item(a)->setFeatures(fl.featureList());
					CharStyle newFeatures;
					newFeatures.setFeatures(static_cast<StyleFlag>(s).featureList());
					m_item->itemText.applyCharStyle(a, 1, newFeatures);
				}
			}
		}
		m_item->itemText.deselectAll();
	}
	else if (m_doc->scMW()->CurrStED != NULL)
	{
		StoryEditor* se = m_doc->scMW()->CurrStED;
		if (RText->isChecked())
		{
			disconnect(se->Editor, SIGNAL(cursorPositionChanged()), se, SLOT(updateProps()));
			int SelStart = se->Editor->textCursor().selectionStart();
			int SelEnd = se->Editor->textCursor().selectionEnd();
//			se->Editor->insChars(RTextVal->text());
			se->Editor->textCursor().setPosition(SelStart);
			se->Editor->textCursor().setPosition(SelEnd, QTextCursor::KeepAnchor);
			se->Editor->textCursor().removeSelectedText();
//FIXME		se->Editor->setEffects(se->Editor->CurrentEffects);
			QString newText = RTextVal->text();
			se->Editor->insertPlainText(newText);
			if (newText.length() > 0)
			{
				QTextCursor textCursor = se->Editor->textCursor();
				textCursor.setPosition(SelStart);
				textCursor.setPosition(SelStart + newText.length(), QTextCursor::KeepAnchor);
				se->Editor->setTextCursor(textCursor);
			}
			connect(se->Editor, SIGNAL(cursorPositionChanged()), se, SLOT(updateProps()));
//			se->newAlign(se->Editor->currentParaStyle);
		}
		if (RStyle->isChecked())
			se->newStyle(m_doc->paragraphStyles()[RStyleVal->currentIndex()].name());
		if (RAlign->isChecked())
			se->newAlign(RAlignVal->currentIndex());
		if (RFill->isChecked())
			se->newTxFill(RFillVal->currentIndex(), -1);
		if (RFillS->isChecked())
			se->newTxFill(-1, RFillSVal->getValue());
		if (RStroke->isChecked())
			se->newTxStroke(RStrokeVal->currentIndex(), -1);
		if (RStrokeS->isChecked())
			se->newTxStroke(-1, RStrokeSVal->getValue());
		if (RFont->isChecked())
			se->newTxFont(RFontVal->currentText());
		if (RSize->isChecked())
			se->newTxSize(RSizeVal->value());
		if (REffect->isChecked())
			se->newTxStyle(REffVal->getStyle());

		QTextCursor textCursor = se->Editor->textCursor();
		int selStart = textCursor.selectionStart();
		int selEnd   = textCursor.selectionEnd();
		int selPos   = qMax(selStart, selEnd);
		textCursor.setPosition(selPos);
		se->Editor->setTextCursor(textCursor);
	}
	DoReplace->setEnabled(false);
	AllReplace->setEnabled(false);
	slotDoSearch();
}