本文整理汇总了C++中ConfigManager类的典型用法代码示例。如果您正苦于以下问题:C++ ConfigManager类的具体用法?C++ ConfigManager怎么用?C++ ConfigManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConfigManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PEG_METHOD_ENTER
SSLContext* CIMServer::_getSSLContext()
{
PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::_getSSLContext()");
static const String PROPERTY_NAME__SSL_CERT_FILEPATH =
"sslCertificateFilePath";
static const String PROPERTY_NAME__SSL_KEY_FILEPATH = "sslKeyFilePath";
static const String PROPERTY_NAME__SSL_TRUST_STORE = "sslTrustStore";
static const String PROPERTY_NAME__SSL_CRL_STORE = "crlStore";
static const String PROPERTY_NAME__SSL_CLIENT_VERIFICATION =
"sslClientVerificationMode";
static const String PROPERTY_NAME__SSL_AUTO_TRUST_STORE_UPDATE =
"enableSSLTrustStoreAutoUpdate";
static const String PROPERTY_NAME__SSL_TRUST_STORE_USERNAME =
"sslTrustStoreUserName";
static const String PROPERTY_NAME__HTTP_ENABLED =
"enableHttpConnection";
static const String PROPERTY_NAME__SSL_CIPHER_SUITE = "sslCipherSuite";
static const String PROPERTY_NAME__SSL_COMPATIBILITY =
"sslBackwardCompatibility";
String verifyClient;
String trustStore;
SSLContext* sslContext = 0;
//
// Get a config manager instance
//
ConfigManager* configManager = ConfigManager::getInstance();
// Note that if invalid values were set for either sslKeyFilePath,
// sslCertificateFilePath, crlStore or sslTrustStore, the invalid
// paths would have been detected in SecurityPropertyOwner and
// terminated the server startup. This happens regardless of whether
// or not HTTPS is enabled (not a great design, but that seems to
// be how other properties are validated as well)
//
// Get the sslClientVerificationMode property from the Config
// Manager.
//
verifyClient = configManager->getCurrentValue(
PROPERTY_NAME__SSL_CLIENT_VERIFICATION);
//
// Get the sslTrustStore property from the Config Manager.
//
trustStore = configManager->getCurrentValue(
PROPERTY_NAME__SSL_TRUST_STORE);
if (trustStore != String::EMPTY)
{
trustStore = ConfigManager::getHomedPath(trustStore);
}
PEG_TRACE((TRC_SERVER, Tracer::LEVEL4,"Server trust store name: %s",
(const char*)trustStore.getCString()));
//
// Get the sslTrustStoreUserName property from the Config Manager.
//
String trustStoreUserName;
trustStoreUserName = configManager->getCurrentValue(
PROPERTY_NAME__SSL_TRUST_STORE_USERNAME);
if (!String::equal(verifyClient, "disabled"))
{
//
// 'required' and 'optional' settings must have a valid truststore
//
if (trustStore == String::EMPTY)
{
MessageLoaderParms parms(
"Pegasus.Server.SSLContextManager."
"SSL_CLIENT_VERIFICATION_EMPTY_TRUSTSTORE",
"The \"sslTrustStore\" configuration property must be set "
"if \"sslClientVerificationMode\" is 'required' or "
"'optional'.");
PEG_METHOD_EXIT();
throw SSLException(parms);
}
#ifdef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
//
// ATTN: 'required' setting must have http port enabled.
// If only https is enabled, and a call to shutdown the
// cimserver is given, the call will hang and a forced shutdown
// will ensue. This is because the CIMClient::connectLocal call
// cannot specify a certificate for authentication against
// the local server. This limitation is being investigated.
// See Bugzilla 2995.
//
if (String::equal(verifyClient, "required"))
{
if (!ConfigManager::parseBooleanValue(
configManager->getCurrentValue(
PROPERTY_NAME__HTTP_ENABLED)))
{
MessageLoaderParms parms(
"Pegasus.Server.SSLContextManager."
"INVALID_CONF_HTTPS_REQUIRED",
//.........这里部分代码省略.........
示例2: m_workspace
MainWindow::MainWindow() :
m_workspace( NULL ),
m_templatesMenu( NULL ),
m_recentlyOpenedProjectsMenu( NULL ),
m_toolsMenu( NULL ),
m_autoSaveTimer( this ),
m_viewMenu( NULL ),
m_metronomeToggle( 0 ),
m_session( Normal )
{
setAttribute( Qt::WA_DeleteOnClose );
QWidget * main_widget = new QWidget( this );
QVBoxLayout * vbox = new QVBoxLayout( main_widget );
vbox->setSpacing( 0 );
vbox->setMargin( 0 );
QWidget * w = new QWidget( main_widget );
QHBoxLayout * hbox = new QHBoxLayout( w );
hbox->setSpacing( 0 );
hbox->setMargin( 0 );
SideBar * sideBar = new SideBar( Qt::Vertical, w );
QSplitter * splitter = new QSplitter( Qt::Horizontal, w );
splitter->setChildrenCollapsible( false );
ConfigManager* confMgr = ConfigManager::inst();
emit initProgress(tr("Preparing plugin browser"));
sideBar->appendTab( new PluginBrowser( splitter ) );
emit initProgress(tr("Preparing file browsers"));
sideBar->appendTab( new FileBrowser(
confMgr->userProjectsDir() + "*" +
confMgr->factoryProjectsDir(),
"*.mmp *.mmpz *.xml *.mid",
tr( "My Projects" ),
embed::getIconPixmap( "project_file" ).transformed( QTransform().rotate( 90 ) ),
splitter, false, true ) );
sideBar->appendTab( new FileBrowser(
confMgr->userSamplesDir() + "*" +
confMgr->factorySamplesDir(),
"*", tr( "My Samples" ),
embed::getIconPixmap( "sample_file" ).transformed( QTransform().rotate( 90 ) ),
splitter, false, true ) );
sideBar->appendTab( new FileBrowser(
confMgr->userPresetsDir() + "*" +
confMgr->factoryPresetsDir(),
"*.xpf *.cs.xml *.xiz",
tr( "My Presets" ),
embed::getIconPixmap( "preset_file" ).transformed( QTransform().rotate( 90 ) ),
splitter , false, true ) );
sideBar->appendTab( new FileBrowser( QDir::homePath(), "*",
tr( "My Home" ),
embed::getIconPixmap( "home" ).transformed( QTransform().rotate( 90 ) ),
splitter, false, false ) );
QStringList root_paths;
QString title = tr( "Root directory" );
bool dirs_as_items = false;
#ifdef LMMS_BUILD_APPLE
title = tr( "Volumes" );
root_paths += "/Volumes";
#elif defined(LMMS_BUILD_WIN32)
title = tr( "My Computer" );
dirs_as_items = true;
#endif
#if ! defined(LMMS_BUILD_APPLE)
QFileInfoList drives = QDir::drives();
for( const QFileInfo & drive : drives )
{
root_paths += drive.absolutePath();
}
#endif
sideBar->appendTab( new FileBrowser( root_paths.join( "*" ), "*", title,
embed::getIconPixmap( "computer" ).transformed( QTransform().rotate( 90 ) ),
splitter, dirs_as_items) );
m_workspace = new QMdiArea( splitter );
// Load background
emit initProgress(tr("Loading background artwork"));
QString bgArtwork = ConfigManager::inst()->backgroundArtwork();
QImage bgImage;
if( !bgArtwork.isEmpty() )
{
bgImage = QImage( bgArtwork );
}
if( !bgImage.isNull() )
{
m_workspace->setBackground( bgImage );
}
else
{
m_workspace->setBackground( Qt::NoBrush );
}
//.........这里部分代码省略.........
示例3: Load
void SEditorColourSet::Load()
{
// no need for syntax highlighting if batch building
if (Manager::IsBatchBuild())
return;
static bool s_notifiedUser = false;
wxString key;
ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("editor"));
// read the theme name
m_Name = cfg->Read(_T("/colour_sets/") + m_Name + _T("/name"), m_Name);
int x = 0;
for (SOptionSetsMap::iterator it = m_Sets.begin(); it != m_Sets.end(); ++it)
{
if (it->first == HL_NONE || it->first == HL_AUTO)
continue;
// look for old-style configuration
key.Clear();
key << _T("/colour_sets/") << m_Name << _T("/set") << wxString::Format(_T("%d"), x++);
if (cfg->Exists(key + _T("/name")))
{
// old-style configuration
// delete it and tell the user about it
cfg->DeleteSubPath(key);
if (!s_notifiedUser)
{
cbMessageBox(_("The way editor syntax highlighting configuration is saved, has changed.\n"
"Syntax highlighting for all supported languages will revert to defaults now.\n"
"We 're sorry for the inconvenience..."),
_("Information"),
wxICON_INFORMATION);
s_notifiedUser = true;
}
continue;
}
// make sure we didn't create it accidentally
cfg->DeleteSubPath(key);
// new-style configuration key
key.Clear();
key << _T("/colour_sets/") << m_Name << _T('/') << it->first;
if (!cfg->Exists(key + _T("/name")))
{
// make sure we didn't create it accidentally
cfg->DeleteSubPath(key);
continue;
}
for (unsigned int i = 0; i < it->second.m_Colours.GetCount(); ++i)
{
SOptionColour* opt = it->second.m_Colours.Item(i);
if (!opt)
continue;
wxString tmpKey;
tmpKey << key << _T("/style") << wxString::Format(_T("%d"), i);
if (cfg->Exists(tmpKey + _T("/name")))
opt->name = cfg->Read(tmpKey + _T("/name"));
else
{
// make sure we didn't create it accidentally
cfg->DeleteSubPath(tmpKey);
continue;
}
if (cfg->Exists(tmpKey + _T("/fore")))
opt->fore = cfg->ReadColour(tmpKey + _T("/fore"), opt->fore);
if (cfg->Exists(tmpKey + _T("/back")))
opt->back = cfg->ReadColour(tmpKey + _T("/back"), opt->back);
if (cfg->Exists(tmpKey + _T("/bold")))
opt->bold = cfg->ReadBool(tmpKey + _T("/bold"), opt->bold);
if (cfg->Exists(tmpKey + _T("/italics")))
opt->italics = cfg->ReadBool(tmpKey + _T("/italics"), opt->italics);
if (cfg->Exists(tmpKey + _T("/underlined")))
opt->underlined = cfg->ReadBool(tmpKey + _T("/underlined"), opt->underlined);
if (cfg->Exists(tmpKey + _T("/isStyle")))
opt->isStyle = cfg->ReadBool(tmpKey + _T("/isStyle"), opt->isStyle);
}
wxString tmpkey;
for (int i = 0; i <= wxSCI_KEYWORDSET_MAX; ++i)
{
tmpkey.Printf(_T("%s/editor/keywords/set%d"), key.c_str(), i);
if (cfg->Exists(tmpkey))
it->second.m_Keywords[i] = cfg->Read(tmpkey, wxEmptyString);
}
tmpkey.Printf(_T("%s/editor/filemasks"), key.c_str());
if (cfg->Exists(tmpkey))
it->second.m_FileMasks = GetArrayFromString(cfg->Read(tmpkey, wxEmptyString), _T(","));
}
}
示例4: memcpy
bool EncodingDetector::DetectEncoding(const wxByte* buffer, size_t size, bool ConvertToWxString)
{
ConfigManager* cfgMgr = Manager::Get()->GetConfigManager(_T("editor"));
wxString encname = cfgMgr->Read(_T("/default_encoding"));
if (cfgMgr->ReadInt(_T("/default_encoding/use_option"), 0) == 1)
{
// Bypass C::B's auto-detection
m_Encoding = wxFontMapper::Get()->CharsetToEncoding(encname, false);
if(m_UseLog)
{
wxString msg;
msg.Printf(_T("Warning: bypassing E::B's auto-detection!\n"
"Encoding requested is: %s (ID: %d)"),
wxFontMapper::Get()->GetEncodingDescription(m_Encoding).c_str(),
m_Encoding);
Manager::Get()->GetLogManager()->DebugLog(msg);
}
}
else
{
if (!buffer)
return false;
if (size >= 4)
{
// BOM is max 4 bytes
char buff[4] = {'\0'};
memcpy(buff, buffer, 4);
if (memcmp(buff, "\xEF\xBB\xBF", 3) == 0)
{
m_UseBOM = true;
m_BOMSizeInBytes = 3;
m_Encoding = wxFONTENCODING_UTF8;
}
else if (memcmp(buff, "\x00\x00\xFE\xFF", 4) == 0)
{
m_UseBOM = true;
m_BOMSizeInBytes = 4;
m_Encoding = wxFONTENCODING_UTF32BE;
}
else if (memcmp(buff, "\x00\x00\xFF\xFE", 4) == 0)
{
// 00 00 FF FE UCS-4, unusual octet order BOM (2143)
// X-ISO-10646-UCS-4-2143 can not (yet) be handled by wxWidgets
m_Encoding = (wxFontEncoding)-1;
}
else if (memcmp(buff, "\xFF\xFE\x00\x00", 4) == 0)
{
m_UseBOM = true;
m_BOMSizeInBytes = 4;
m_Encoding = wxFONTENCODING_UTF32LE;
}
else if (memcmp(buff, "\xFE\xFF\x00\x00", 4) == 0)
{
// FE FF 00 00 UCS-4, unusual octet order BOM (3412)
// X-ISO-10646-UCS-4-3412 can not (yet) be handled by wxWidgets
m_Encoding = (wxFontEncoding)-1;
}
else if (memcmp(buff, "\xFE\xFF", 2) == 0)
{
m_UseBOM = true;
m_BOMSizeInBytes = 2;
m_Encoding = wxFONTENCODING_UTF16BE;
}
else if (memcmp(buff, "\xFF\xFE", 2) == 0)
{
m_UseBOM = true;
m_BOMSizeInBytes = 2;
m_Encoding = wxFONTENCODING_UTF16LE;
}
}
if (m_UseBOM)
{
if(m_UseLog)
{
wxString msg;
msg.Printf(_T("Detected encoding via BOM: %s (ID: %d)"),
wxFontMapper::Get()->GetEncodingDescription(m_Encoding).c_str(),
m_Encoding);
Manager::Get()->GetLogManager()->DebugLog(msg);
}
}
// Try our own detection for UTF-16 and UTF-32, the mozilla-version does not work without BOM
else if ( !DetectUTF16((wxByte*)buffer, size) &&
!DetectUTF32((wxByte*)buffer, size) )
{
// if we still have no results try mozilla's detection
m_Encoding = wxFontMapper::Get()->CharsetToEncoding(DoIt((char*)buffer, size), false);
if(m_Encoding == wxFONTENCODING_DEFAULT)
{
wxString enc_name = Manager::Get()->GetConfigManager(_T("editor"))->Read(_T("/default_encoding"), wxLocale::GetSystemEncodingName());
m_Encoding = wxFontMapper::GetEncodingFromName(enc_name);
if(m_UseLog)
{
wxString msg;
msg.Printf(_T("Text seems to be pure ASCII!\n"
//.........这里部分代码省略.........
示例5: return
uint64_t Creature::getGainedExperience(Creature* attacker) const
{
return (uint64_t)std::floor(getDamageRatio(attacker) * getLostExperience() * g_config.getNumber(ConfigManager::RATE_EXPERIENCE));
}
示例6: MirrorCurrentSettings
void Compiler::LoadSettings(const wxString& baseKey)
{
// before loading any compiler settings, keep the current settings safe
// so we can compare them when saving: this way we can only save what's
// different from the defaults
MirrorCurrentSettings();
ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("compiler"));
// read settings version
wxString version = cfg->Read(_T("settings_version"));
bool versionMismatch = version != CompilerSettingsVersion;
wxString tmp;
// if using old-style keys (using integer IDs), notify user about the changes
static bool saidAboutCompilerIDs = false;
tmp.Printf(_T("%s/set%3.3d"), baseKey.c_str(), CompilerFactory::GetCompilerIndex(this) + 1);
if (cfg->Exists(tmp + _T("/name")))
{
if (!saidAboutCompilerIDs)
{
saidAboutCompilerIDs = true;
cbMessageBox(_("Compilers now use unique names instead of integer IDs.\n"
"Projects will be updated accordingly on load, mostly automatic."),
_("Information"),
wxICON_INFORMATION);
}
// at this point, we 'll be using the old style configuration to load settings
}
else // it's OK to use new style
tmp.Printf(_T("%s/%s"), baseKey.c_str(), m_ID.c_str());
if (!cfg->Exists(tmp + _T("/name")))
return;
wxString sep = wxFileName::GetPathSeparator();
m_Name = cfg->Read(tmp + _T("/name"), m_Name);
m_MasterPath = cfg->Read(tmp + _T("/master_path"), m_MasterPath);
m_ExtraPaths = MakeUniqueArray(GetArrayFromString(cfg->Read(tmp + _T("/extra_paths"), _T("")), _T(";")), true);
m_Programs.C = cfg->Read(tmp + _T("/c_compiler"), m_Programs.C);
m_Programs.CPP = cfg->Read(tmp + _T("/cpp_compiler"), m_Programs.CPP);
m_Programs.LD = cfg->Read(tmp + _T("/linker"), m_Programs.LD);
m_Programs.LIB = cfg->Read(tmp + _T("/lib_linker"), m_Programs.LIB);
m_Programs.WINDRES = cfg->Read(tmp + _T("/res_compiler"), m_Programs.WINDRES);
m_Programs.MAKE = cfg->Read(tmp + _T("/make"), m_Programs.MAKE);
m_Programs.DBG = cfg->Read(tmp + _T("/debugger"), m_Programs.DBG);
// set member variable containing the version string with the configurated toolchain executables, not only
// with the default ones, otherwise we might have an empty version-string
// Some MinGW installations do not includee "mingw32-gcc" !!
SetVersionString();
SetCompilerOptions (GetArrayFromString(cfg->Read(tmp + _T("/compiler_options"), wxEmptyString)));
SetLinkerOptions (GetArrayFromString(cfg->Read(tmp + _T("/linker_options"), wxEmptyString)));
SetIncludeDirs (GetArrayFromString(cfg->Read(tmp + _T("/include_dirs"), wxEmptyString)));
SetResourceIncludeDirs(GetArrayFromString(cfg->Read(tmp + _T("/res_include_dirs"), wxEmptyString)));
SetLibDirs (GetArrayFromString(cfg->Read(tmp + _T("/library_dirs"), wxEmptyString)));
SetLinkLibs (GetArrayFromString(cfg->Read(tmp + _T("/libraries"), wxEmptyString)));
SetCommandsBeforeBuild(GetArrayFromString(cfg->Read(tmp + _T("/commands_before"), wxEmptyString)));
SetCommandsAfterBuild (GetArrayFromString(cfg->Read(tmp + _T("/commands_after"), wxEmptyString)));
for (int i = 0; i < ctCount; ++i)
{
wxArrayString keys = cfg->EnumerateSubPaths(tmp + _T("/macros/") + CommandTypeDescriptions[i]);
for (size_t n = 0; n < keys.size(); ++n)
{
unsigned long index = 0;
if (keys[n].Mid(4).ToULong(&index)) // skip 'tool'
{
while (index >= m_Commands[i].size())
m_Commands[i].push_back(CompilerTool());
CompilerTool& tool = m_Commands[i][index];
wxString key = wxString::Format(_T("%s/macros/%s/tool%lu/"), tmp.c_str(), CommandTypeDescriptions[i].c_str(), index);
tool.command = cfg->Read(key + _T("command"));
tool.extensions = cfg->ReadArrayString(key + _T("extensions"));
tool.generatedFiles = cfg->ReadArrayString(key + _T("generatedFiles"));
}
}
}
// switches
m_Switches.includeDirs = cfg->Read(tmp + _T("/switches/includes"), m_Switches.includeDirs);
m_Switches.libDirs = cfg->Read(tmp + _T("/switches/libs"), m_Switches.libDirs);
m_Switches.linkLibs = cfg->Read(tmp + _T("/switches/link"), m_Switches.linkLibs);
m_Switches.defines = cfg->Read(tmp + _T("/switches/define"), m_Switches.defines);
m_Switches.genericSwitch = cfg->Read(tmp + _T("/switches/generic"), m_Switches.genericSwitch);
m_Switches.objectExtension = cfg->Read(tmp + _T("/switches/objectext"), m_Switches.objectExtension);
m_Switches.needDependencies = cfg->ReadBool(tmp + _T("/switches/deps"), m_Switches.needDependencies);
m_Switches.forceCompilerUseQuotes = cfg->ReadBool(tmp + _T("/switches/forceCompilerQuotes"), m_Switches.forceCompilerUseQuotes);
m_Switches.forceLinkerUseQuotes = cfg->ReadBool(tmp + _T("/switches/forceLinkerQuotes"), m_Switches.forceLinkerUseQuotes);
m_Switches.logging = (CompilerLoggingType)cfg->ReadInt(tmp + _T("/switches/logging"), m_Switches.logging);
m_Switches.libPrefix = cfg->Read(tmp + _T("/switches/libPrefix"), m_Switches.libPrefix);
m_Switches.libExtension = cfg->Read(tmp + _T("/switches/libExtension"), m_Switches.libExtension);
m_Switches.linkerNeedsLibPrefix = cfg->ReadBool(tmp + _T("/switches/linkerNeedsLibPrefix"), m_Switches.linkerNeedsLibPrefix);
m_Switches.linkerNeedsLibExtension = cfg->ReadBool(tmp + _T("/switches/linkerNeedsLibExtension"), m_Switches.linkerNeedsLibExtension);
m_Switches.forceFwdSlashes = cfg->ReadBool(tmp + _T("/switches/forceFwdSlashes"), m_Switches.forceFwdSlashes);
//.........这里部分代码省略.........
示例7: ApplyTo
void FormatterSettings::ApplyTo(astyle::ASFormatter& formatter)
{
ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("astyle"));
int style = cfg->ReadInt(_T("/style"), 0);
switch (style)
{
case aspsAllman: // Allman (ANSI)
formatter.setFormattingStyle(astyle::STYLE_ALLMAN);
break;
case aspsJava: // Java
formatter.setFormattingStyle(astyle::STYLE_JAVA);
break;
case aspsKr: // K&R
formatter.setFormattingStyle(astyle::STYLE_KandR);
break;
case aspsStroustrup: // Stroustrup
formatter.setFormattingStyle(astyle::STYLE_STROUSTRUP);
break;
case aspsWhitesmith: // Whitesmith
formatter.setFormattingStyle(astyle::STYLE_WHITESMITH);
break;
case aspsBanner: // Banner
formatter.setFormattingStyle(astyle::STYLE_BANNER);
break;
case aspsGnu: // GNU
formatter.setFormattingStyle(astyle::STYLE_GNU);
break;
case aspsLinux: // Linux
formatter.setFormattingStyle(astyle::STYLE_LINUX);
break;
case aspsHorstmann: // Horstmann
formatter.setFormattingStyle(astyle::STYLE_HORSTMANN);
break;
default: // Custom
{
bool value = cfg->ReadBool(_T("/force_tabs"));
int spaceNum = cfg->ReadInt(_T("/indentation"), 4);
if (cfg->ReadBool(_T("/use_tabs")))
{
formatter.setTabIndentation(spaceNum, value);
}
else
{
formatter.setSpaceIndentation(spaceNum);
}
formatter.setClassIndent(cfg->ReadBool(_T("/indent_classes")));
formatter.setSwitchIndent(cfg->ReadBool(_T("/indent_switches")));
formatter.setCaseIndent(cfg->ReadBool(_T("/indent_case")));
formatter.setBracketIndent(cfg->ReadBool(_T("/indent_brackets")));
formatter.setBlockIndent(cfg->ReadBool(_T("/indent_blocks")));
formatter.setNamespaceIndent(cfg->ReadBool(_T("/indent_namespaces")));
formatter.setLabelIndent(cfg->ReadBool(_T("/indent_labels")));
formatter.setPreprocessorIndent(cfg->ReadBool(_T("/indent_preprocessor")));
wxString brackedFormatMode = cfg->Read(_T("/bracket_format_mode"));
if (brackedFormatMode == _T("Attach"))
{
formatter.setBracketFormatMode(astyle::ATTACH_MODE);
}
else if (brackedFormatMode == _T("Break"))
{
formatter.setBracketFormatMode(astyle::BREAK_MODE);
}
else if (brackedFormatMode == _T("Linux"))
{
formatter.setBracketFormatMode(astyle::LINUX_MODE);
}
else if (brackedFormatMode == _T("Stroustrup"))
{
formatter.setBracketFormatMode(astyle::STROUSTRUP_MODE);
}
else
{
formatter.setBracketFormatMode(astyle::NONE_MODE);
}
wxString pointerAlign = cfg->Read(_T("/pointer_align"));
if (pointerAlign == _T("Type"))
{
formatter.setPointerAlignment(astyle::ALIGN_TYPE);
}
else if (pointerAlign == _T("Middle"))
{
formatter.setPointerAlignment(astyle::ALIGN_MIDDLE);
}
//.........这里部分代码省略.........
示例8: lua_pushnumber
void ValueCallback::getMinMaxValues(Player* player, int32_t& min, int32_t& max, bool useCharges) const
{
//"onGetPlayerMinMaxValues"(...)
if (m_scriptInterface->reserveScriptEnv())
{
ScriptEnviroment* env = m_scriptInterface->getScriptEnv();
lua_State* L = m_scriptInterface->getLuaState();
if (!env->setCallbackId(m_scriptId, m_scriptInterface))
{
return;
}
uint32_t cid = env->addThing(player);
m_scriptInterface->pushFunction(m_scriptId);
lua_pushnumber(L, cid);
int32_t parameters = 1;
bool isMagicFormula = false;
switch (type)
{
case FORMULA_LEVELMAGIC:
{
//"onGetPlayerMinMaxValues"(cid, level, maglevel)
lua_pushnumber(L, player->getLevel());
lua_pushnumber(L, player->getMagicLevel());
parameters += 2;
isMagicFormula = true;
break;
}
case FORMULA_SKILL:
{
//"onGetPlayerMinMaxValues"(cid, attackSkill, attackValue, attackFactor)
Item* tool = player->getWeapon();
int32_t attackSkill = player->getWeaponSkill(tool);
int32_t attackValue = 7;
if (tool)
{
attackValue = tool->getAttack();
if (useCharges && tool->hasCharges() && g_config.getNumber(ConfigManager::REMOVE_WEAPON_CHARGES))
{
int32_t newCharge = std::max(0, tool->getCharges() - 1);
g_game.transformItem(tool, tool->getID(), newCharge);
}
}
float attackFactor = player->getAttackFactor();
lua_pushnumber(L, attackSkill);
lua_pushnumber(L, attackValue);
lua_pushnumber(L, attackFactor);
parameters += 3;
break;
}
default:
std::cout << "ValueCallback::getMinMaxValues - unknown callback type" << std::endl;
return;
break;
}
int size0 = lua_gettop(L);
if (lua_pcall(L, parameters, 2 /*nReturnValues*/, 0) != 0)
{
LuaScriptInterface::reportError(NULL, LuaScriptInterface::popString(L));
}
else
{
max = LuaScriptInterface::popNumber(L);
min = LuaScriptInterface::popNumber(L);
Vocation* vocation = player->getVocation();
if (isMagicFormula && vocation)
{
if (max > 0 && min > 0 && vocation->getHealingBaseDamage() != 1.0)
{
min = int32_t(min * vocation->getHealingBaseDamage());
max = int32_t(max * vocation->getHealingBaseDamage());
}
else if (max < 0 && min < 0 && vocation->getMagicBaseDamage() != 1.0)
{
min = int32_t(min * vocation->getMagicBaseDamage());
max = int32_t(max * vocation->getMagicBaseDamage());
}
}
}
if ((lua_gettop(L) + parameters /*nParams*/ + 1) != size0)
{
LuaScriptInterface::reportError(NULL, "Stack size changed!");
}
env->resetCallback();
m_scriptInterface->releaseScriptEnv();
}
else
{
std::cout << "[Error] Call stack overflow. ValueCallback::getMinMaxValues" << std::endl;
return;
//.........这里部分代码省略.........
示例9: isDatabaseSetup
bool DatabaseManager::isDatabaseSetup()
{
Database* db = Database::getInstance();
std::ostringstream query;
query << "SELECT `TABLE_NAME` FROM `information_schema`.`tables` WHERE `TABLE_SCHEMA` = " << db->escapeString(g_config.getString(ConfigManager::MYSQL_DB));
DBResult* result = db->storeQuery(query.str());
if (!result) {
return false;
}
db->freeResult(result);
return true;
}
示例10: XRCCTRL
void PluginsConfigurationDlg::OnExport(wxCommandEvent& /*event*/)
{
wxListCtrl* list = XRCCTRL(*this, "lstPlugins", wxListCtrl);
if (list->GetSelectedItemCount() == 0)
return;
ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("plugins_configuration"));
wxDirDialog dd(this, _("Select directory to export plugin"), cfg->Read(_T("/last_export_path")), wxDD_NEW_DIR_BUTTON);
if (dd.ShowModal() != wxID_OK)
return;
cfg->Write(_T("/last_export_path"), dd.GetPath());
wxBusyCursor busy;
wxProgressDialog pd(_("Exporting plugin(s)"),
_T("A description wide enough for the dialog ;)"),
list->GetSelectedItemCount(),
this,
wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_CAN_ABORT |
wxPD_ELAPSED_TIME | wxPD_ESTIMATED_TIME | wxPD_REMAINING_TIME);
int count = 0;
long sel = -1;
bool skip = false;
bool confirmed = false;
wxString failure;
wxArrayString files; // avoid exporting different plugins from the same file twice
while (true)
{
sel = list->GetNextItem(sel, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
if (sel == -1)
break;
const PluginElement* elem = (const PluginElement*)list->GetItemData(sel);
if (!elem && !elem->plugin)
{
failure << list->GetItemText(sel) << _T('\n');
continue;
}
// avoid duplicates
if (files.Index(elem->fileName) != wxNOT_FOUND)
continue;
files.Add(elem->fileName);
// normalize version
wxString version = elem->info.version;
version.Replace(_T("/"), _T("_"), true);
version.Replace(_T("\\"), _T("_"), true);
version.Replace(_T("?"), _T("_"), true);
version.Replace(_T("*"), _T("_"), true);
version.Replace(_T(">"), _T("_"), true);
version.Replace(_T("<"), _T("_"), true);
version.Replace(_T(" "), _T("_"), true);
version.Replace(_T("\t"), _T("_"), true);
version.Replace(_T("|"), _T("_"), true);
wxFileName fname;
fname.SetPath(dd.GetPath());
fname.SetName(wxFileName(elem->fileName).GetName() + _T('-') + version);
fname.SetExt(_T("cbplugin"));
pd.Update(++count,
wxString::Format(_("Exporting \"%s\"..."), elem->info.title.c_str()),
&skip);
if (skip)
break;
wxString filename = fname.GetFullPath();
if (!confirmed && wxFileExists(filename))
{
AnnoyingDialog dlg(_("Confirmation"),
wxString::Format(_("%s already exists.\n"
"Are you sure you want to overwrite it?"), filename.c_str()),
wxART_QUESTION,
AnnoyingDialog::THREE_BUTTONS,
1,
true,
_("&Yes"), _("Yes to &all"), _("&No"));
switch (dlg.ShowModal())
{
case 3:
continue;
break;
case 2:
confirmed = true;
break;
default:
break;
}
}
if (!Manager::Get()->GetPluginManager()->ExportPlugin(elem->plugin, filename))
failure << list->GetItemText(sel) << _T('\n');
}
if (!failure.IsEmpty())
cbMessageBox(_("Failed exporting one or more plugins:\n\n") + failure, _("Warning"), wxICON_WARNING, this);
//.........这里部分代码省略.........
示例11: optimizeTables
bool DatabaseManager::optimizeTables()
{
Database* db = Database::getInstance();
std::ostringstream query;
query << "SELECT `TABLE_NAME` FROM `information_schema`.`TABLES` WHERE `TABLE_SCHEMA` = " << db->escapeString(g_config.getString(ConfigManager::MYSQL_DB)) << " AND `DATA_FREE` > 0";
DBResult* result = db->storeQuery(query.str());
if (!result) {
return false;
}
do {
std::string tableName = result->getDataString("TABLE_NAME");
std::cout << "> Optimizing table " << tableName << "..." << std::flush;
query.str("");
query << "OPTIMIZE TABLE `" << tableName << '`';
if (db->executeQuery(query.str())) {
std::cout << " [success]" << std::endl;
} else {
std::cout << " [failed]" << std::endl;
}
} while (result->next());
db->freeResult(result);
return true;
}
示例12: mainLoader
void mainLoader(int argc, char* argv[], ServiceManager* services)
{
//dispatcher thread
g_game.setGameState(GAME_STATE_STARTUP);
srand((unsigned int)OTSYS_TIME());
#ifdef WIN32
SetConsoleTitle(STATUS_SERVER_NAME);
#endif
std::cout << STATUS_SERVER_NAME << " - Version " << STATUS_SERVER_VERSION << std::endl;
std::cout << "Compilied on " << __DATE__ << " " << __TIME__ << " for arch ";
#if defined(__amd64__) || defined(_M_X64)
std::cout << "x64" << std::endl;
#elif defined(__i386__) || defined(_M_IX86) || defined(_X86_)
std::cout << "x86" << std::endl;
#else
std::cout << "unk" << std::endl;
#endif
std::cout << std::endl;
std::cout << "A server developed by " << STATUS_SERVER_DEVELOPERS << std::endl;
std::cout << "Visit our forum for updates, support, and resources: http://otland.net/." << std::endl;
std::cout << std::endl;
// read global config
std::cout << ">> Loading config" << std::endl;
if (!g_config.loadFile("config.lua")) {
startupErrorMessage("Unable to load config.lua!");
return;
}
#ifdef WIN32
std::string defaultPriority = asLowerCaseString(g_config.getString(ConfigManager::DEFAULT_PRIORITY));
if (defaultPriority == "realtime") {
SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS);
} else if (defaultPriority == "high") {
SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
} else if (defaultPriority == "higher") {
SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS);
}
std::ostringstream mutexName;
mutexName << "forgottenserver_" << g_config.getNumber(ConfigManager::LOGIN_PORT);
CreateMutex(NULL, FALSE, mutexName.str().c_str());
if (GetLastError() == ERROR_ALREADY_EXISTS) {
startupErrorMessage("Another instance of The Forgotten Server is already running with the same login port, please shut it down first or change ports for this one.");
return;
}
#endif
//set RSA key
const char* p("14299623962416399520070177382898895550795403345466153217470516082934737582776038882967213386204600674145392845853859217990626450972452084065728686565928113");
const char* q("7630979195970404721891201847792002125535401292779123937207447574596692788513647179235335529307251350570728407373705564708871762033017096809910315212884101");
const char* d("46730330223584118622160180015036832148732986808519344675210555262940258739805766860224610646919605860206328024326703361630109888417839241959507572247284807035235569619173792292786907845791904955103601652822519121908367187885509270025388641700821735345222087940578381210879116823013776808975766851829020659073");
g_RSA.setKey(p, q, d);
std::cout << ">> Establishing database connection..." << std::flush;
Database* db = Database::getInstance();
if (!db->connect()) {
startupErrorMessage("Failed to connect to database.");
return;
}
std::cout << " MySQL " << db->getClientVersion() << std::endl;
// run database manager
std::cout << ">> Running database manager" << std::endl;
DatabaseManager* dbManager = DatabaseManager::getInstance();
if (!dbManager->isDatabaseSetup()) {
startupErrorMessage("The database you have specified in config.lua is empty, please import the schema to the database.");
return;
}
for (uint32_t version = dbManager->updateDatabase(); version != 0; version = dbManager->updateDatabase()) {
std::cout << "> Database has been updated to version " << version << "." << std::endl;
}
dbManager->checkTriggers();
dbManager->checkEncryption();
if (g_config.getBoolean(ConfigManager::OPTIMIZE_DATABASE) && !dbManager->optimizeTables()) {
std::cout << "> No tables were optimized." << std::endl;
}
//load vocations
std::cout << ">> Loading vocations" << std::endl;
if (!g_vocations.loadFromXml()) {
startupErrorMessage("Unable to load vocations!");
return;
}
//load commands
std::cout << ">> Loading commands" << std::endl;
//.........这里部分代码省略.........
示例13: mainLoader
void mainLoader(int, char*[], ServiceManager* services)
{
//dispatcher thread
g_game.setGameState(GAME_STATE_STARTUP);
srand(static_cast<unsigned int>(OTSYS_TIME()));
#ifdef _WIN32
SetConsoleTitle(STATUS_SERVER_NAME);
#endif
std::cout << STATUS_SERVER_NAME << " - Version " << STATUS_SERVER_VERSION << std::endl;
std::cout << "Compiled with " << BOOST_COMPILER << std::endl;
std::cout << "Compiled on " << __DATE__ << ' ' << __TIME__ << " for platform ";
#if defined(__amd64__) || defined(_M_X64)
std::cout << "x64" << std::endl;
#elif defined(__i386__) || defined(_M_IX86) || defined(_X86_)
std::cout << "x86" << std::endl;
#elif defined(__arm__)
std::cout << "ARM" << std::endl;
#else
std::cout << "unknown" << std::endl;
#endif
std::cout << std::endl;
std::cout << "A server developed by " << STATUS_SERVER_DEVELOPERS << std::endl;
std::cout << "Visit our forum for updates, support, and resources: http://otland.net/." << std::endl;
std::cout << std::endl;
// read global config
std::cout << ">> Loading config" << std::endl;
if (!g_config.load()) {
startupErrorMessage("Unable to load config.lua!");
return;
}
#ifdef _WIN32
const std::string& defaultPriority = g_config.getString(ConfigManager::DEFAULT_PRIORITY);
if (strcasecmp(defaultPriority.c_str(), "high") == 0) {
SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
} else if (strcasecmp(defaultPriority.c_str(), "above-normal") == 0) {
SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS);
}
#endif
//set RSA key
const char* p("14299623962416399520070177382898895550795403345466153217470516082934737582776038882967213386204600674145392845853859217990626450972452084065728686565928113");
const char* q("7630979195970404721891201847792002125535401292779123937207447574596692788513647179235335529307251350570728407373705564708871762033017096809910315212884101");
g_RSA.setKey(p, q);
std::cout << ">> Establishing database connection..." << std::flush;
Database* db = Database::getInstance();
if (!db->connect()) {
startupErrorMessage("Failed to connect to database.");
return;
}
std::cout << " MySQL " << Database::getClientVersion() << std::endl;
// run database manager
std::cout << ">> Running database manager" << std::endl;
if (!DatabaseManager::isDatabaseSetup()) {
startupErrorMessage("The database you have specified in config.lua is empty, please import the schema.sql to your database.");
return;
}
g_databaseTasks.start();
DatabaseManager::updateDatabase();
if (g_config.getBoolean(ConfigManager::OPTIMIZE_DATABASE) && !DatabaseManager::optimizeTables()) {
std::cout << "> No tables were optimized." << std::endl;
}
//load vocations
std::cout << ">> Loading vocations" << std::endl;
if (!g_vocations.loadFromXml()) {
startupErrorMessage("Unable to load vocations!");
return;
}
// load item data
std::cout << ">> Loading items" << std::endl;
if (Item::items.loadFromOtb("data/items/items.otb") != ERROR_NONE) {
startupErrorMessage("Unable to load items (OTB)!");
return;
}
if (!Item::items.loadFromXml()) {
startupErrorMessage("Unable to load items (XML)!");
return;
}
std::cout << ">> Loading script systems" << std::endl;
if (!ScriptingManager::getInstance()->loadScriptSystems()) {
startupErrorMessage("Failed to load script systems");
return;
}
std::cout << ">> Loading monsters" << std::endl;
//.........这里部分代码省略.........
示例14: Create
cbDiffConfigPanel::cbDiffConfigPanel(wxWindow* parent)
{
//(*Initialize(cbDiffConfigPanel)
wxStaticBoxSizer* StaticBoxSizer2;
wxStaticBoxSizer* StaticBoxSizer5;
wxBoxSizer* BoxSizer2;
wxStaticText* StaticText1;
wxStaticBoxSizer* StaticBoxSizer3;
wxStaticBoxSizer* StaticBoxSizer4;
wxBoxSizer* BoxSizer1;
wxStaticText* StaticText2;
wxStaticBoxSizer* StaticBoxSizer1;
Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("wxID_ANY"));
BoxSizer1 = new wxBoxSizer(wxVERTICAL);
StaticBoxSizer2 = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Added Lines:"));
BColAdd = new wxButton(this, ID_BUTTON2, _("Colour"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON2"));
StaticBoxSizer2->Add(BColAdd, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
StaticText1 = new wxStaticText(this, ID_STATICTEXT1, _("Alpha:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT1"));
StaticBoxSizer2->Add(StaticText1, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
SLAddAlpha = new wxSlider(this, ID_SLIDER1, 50, 0, 255, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_SLIDER1"));
StaticBoxSizer2->Add(SLAddAlpha, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
BoxSizer1->Add(StaticBoxSizer2, 0, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
StaticBoxSizer1 = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Removed Lines:"));
BColRem = new wxButton(this, ID_BUTTON1, _("Colour"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON1"));
StaticBoxSizer1->Add(BColRem, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
StaticText2 = new wxStaticText(this, ID_STATICTEXT2, _("Alpha:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT2"));
StaticBoxSizer1->Add(StaticText2, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
SLRemAlpha = new wxSlider(this, ID_SLIDER2, 50, 0, 255, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_SLIDER2"));
StaticBoxSizer1->Add(SLRemAlpha, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
BoxSizer1->Add(StaticBoxSizer1, 0, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
StaticBoxSizer3 = new wxStaticBoxSizer(wxVERTICAL, this, _("Caret Line:"));
CHCaret = new wxChoice(this, ID_CHOICE1, wxDefaultPosition, wxDefaultSize, 0, 0, 0, wxDefaultValidator, _T("ID_CHOICE1"));
CHCaret->SetSelection( CHCaret->Append(_("Underline")) );
CHCaret->Append(_("Background"));
StaticBoxSizer3->Add(CHCaret, 0, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
BoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
BColCar = new wxButton(this, ID_BUTTON3, _("Colour"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON3"));
BoxSizer2->Add(BColCar, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
StaticText3 = new wxStaticText(this, ID_STATICTEXT3, _("Alpha:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT3"));
BoxSizer2->Add(StaticText3, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
SLCarAlpha = new wxSlider(this, ID_SLIDER3, 50, 0, 255, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_SLIDER3"));
BoxSizer2->Add(SLCarAlpha, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
StaticBoxSizer3->Add(BoxSizer2, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0);
BoxSizer1->Add(StaticBoxSizer3, 0, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
StaticBoxSizer4 = new wxStaticBoxSizer(wxVERTICAL, this, _("Default values:"));
wxString __wxRadioBoxChoices_1[3] =
{
_("Tabular"),
_("Unified Diff"),
_("Side by side")
};
RBViewing = new wxRadioBox(this, ID_RADIOBOX1, _("Displaytype:"), wxDefaultPosition, wxDefaultSize, 3, __wxRadioBoxChoices_1, 1, wxRA_VERTICAL, wxDefaultValidator, _T("ID_RADIOBOX1"));
RBViewing->SetSelection(0);
StaticBoxSizer4->Add(RBViewing, 0, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
StaticBoxSizer5 = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Language:"));
CHHLang = new wxChoice(this, ID_CHOICE2, wxDefaultPosition, wxDefaultSize, 0, 0, 0, wxDefaultValidator, _T("ID_CHOICE2"));
StaticBoxSizer5->Add(CHHLang, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
StaticBoxSizer4->Add(StaticBoxSizer5, 0, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
BoxSizer1->Add(StaticBoxSizer4, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
SetSizer(BoxSizer1);
BoxSizer1->Fit(this);
BoxSizer1->SetSizeHints(this);
Connect(ID_BUTTON2,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&cbDiffConfigPanel::OnColAddClick);
Connect(ID_BUTTON1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&cbDiffConfigPanel::OnColRemClick);
Connect(ID_BUTTON3,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&cbDiffConfigPanel::OnColCarClick);
Connect(ID_RADIOBOX1,wxEVT_COMMAND_RADIOBOX_SELECTED,(wxObjectEventFunction)&cbDiffConfigPanel::OnViewModeChange);
Connect(ID_CHOICE2,wxEVT_COMMAND_CHOICE_SELECTED,(wxObjectEventFunction)&cbDiffConfigPanel::OnHLangChange);
//*)
BColAdd->SetBackgroundColour(wxColour(0,255,0,50));
BColRem->SetBackgroundColour(wxColour(255,0,0,50));
CHCaret->SetSelection(0);
BColCar->SetBackgroundColour(wxColour(122,122,0));
CHHLang->Append(cbDiffUtils::GetAllHighlightLanguages());
ConfigManager *cfg = Manager::Get()->GetConfigManager(_T("cbdiffsettings"));
if (cfg)
{
BColAdd->SetBackgroundColour(cfg->ReadColour(_T("addedlines"), wxColour(0,255,0,50)));
SLAddAlpha->SetValue(cfg->ReadInt(_T("addedlinesalpha"), 50));
BColRem->SetBackgroundColour(cfg->ReadColour(_T("removedlines"), wxColour(255,0,0,50)));
SLRemAlpha->SetValue(cfg->ReadInt(_T("removedlinesalpha"),50));
CHCaret->SetSelection(cfg->ReadInt(_T("caretlinetype")));
BColCar->SetBackgroundColour(cfg->ReadColour(_T("caretline"), wxColor(122,122,0)));
SLCarAlpha->SetValue(cfg->ReadInt(_T("caretlinealpha"), 50));
RBViewing->SetSelection(cfg->ReadInt(_T("viewmode"), 0));
if(RBViewing->GetSelection() == 1)
CHHLang->Enable(false);
CHHLang->SetStringSelection(cfg->Read(_T("hlang"), _("Plain Text")));
}
BColAdd->SetLabel(BColAdd->GetBackgroundColour().GetAsString());
BColRem->SetLabel(BColRem->GetBackgroundColour().GetAsString());
BColCar->SetLabel(BColCar->GetBackgroundColour().GetAsString());
}
示例15: isBlocking
void MagicField::onStepInField(Creature* creature, bool purposeful/*= true*/)
{
//remove magic walls/wild growth
if (id == ITEM_MAGICWALL_SAFE || id == ITEM_WILDGROWTH_SAFE ||
id == ITEM_MAGICWALL || id == ITEM_WILDGROWTH)
{
bool isBlockingVar = isBlocking(creature);
bool config = g_config.getBoolean(ConfigManager::MW_DISAPPEAR_ON_WALK);
if (isBlockingVar || (!isBlockingVar && config))
{
g_game.internalRemoveItem(this, 1);
}
}
else
{
const ItemType& it = items[getID()];
if (it.condition)
{
if (canOwnerHarm(creature))
{
Condition* conditionCopy = it.condition->clone();
uint32_t ownerId = getOwner();
if (ownerId != 0 && purposeful)
{
Creature* owner = g_game.getCreatureByID(ownerId);
if (owner && (owner != creature))
{
if ((OTSYS_TIME() - createTime <= g_config.getNumber(ConfigManager::FIELD_OWNERSHIP_DURATION)) ||
owner->hasBeenAttacked(ownerId))
{
conditionCopy->setParam(CONDITIONPARAM_OWNER, ownerId);
}
}
}
if (Player* player = creature->getPlayer())
{
if (ConditionDamage* conditionDamage = static_cast<ConditionDamage*>(conditionCopy))
{
Item* tmpItem = NULL;
for (int32_t i = SLOT_FIRST; i <= SLOT_LAST; i++)
{
if ((tmpItem = player->getInventoryItem((slots_t)i)))
{
if (tmpItem->getWieldPosition() != i)
{
continue;
}
const ItemType& it = items[tmpItem->getID()];
std::map<uint16_t, int16_t>::const_iterator id = it.abilities.absorbFieldDamage.find(getID());
if (id != it.abilities.absorbFieldDamage.end())
{
int32_t index = 0, length = conditionDamage->getLength();
std::list<IntervalInfo> damageList;
for (; index < length; index++)
{
IntervalInfo info = conditionDamage->popFrontDamage();
info.value = (int32_t)std::floor((double)info.value * (100 - id->second) / 100.);
damageList.push_back(info);
conditionDamage->setTicks(conditionDamage->getTicks() - info.interval);
}
index = 0;
length -= it.abilities.conditionCount;
conditionDamage->clearDamageList();
for (std::list<IntervalInfo>::iterator itt = damageList.begin(); itt != damageList.end(); ++itt)
{
conditionDamage->addDamage(1, itt->interval, itt->value);
if (++index == length)
{
break;
}
}
}
}
}
if (conditionDamage->getTotalDamage() > 0)
{
conditionDamage->setParam(CONDITIONPARAM_FORCEUPDATE, true);
}
creature->addCondition(conditionDamage);
return;
}
}
creature->addCondition(conditionCopy);
}
//.........这里部分代码省略.........