/// /// 设置指定列表里某个变量的值 /// /// ret = SetVar( operType, "$varName", val, pos ) /// @param operType:VT_SCRIPT, VT_SRCSHAPE, VT_DESTSHAPE, VT_GLOBAL /// @param varName 变量名 /// @param val 变量值 /// @param pos [可选]数组索引 /// static int SetVar( lua_State *L ) { Script *script = GetInst( ScriptSys ).GetScript( L ); long operType = (long) tolua_tonumber( L, 1, 0 ); VariableList *varList = ( script != NULL ? script->GetVarList( operType ) : NULL ); bool ret = false; if( varList != NULL ) { ret = true; long index = (long) tolua_tonumber( L, 4, 0 ); const char *varName = TOLUA_TOSTRING( varName, L, 2, "" ); long varType = VarList::VarType( varName ); if( varType == VariableList::VAR_NUM ) { VariableList::Number val = (VariableList::Number) tolua_tonumber( L, 3, 0 ); varList->SetVarValue( varName, val, index ); if( operType == Script::VT_GLOBAL ) { ScriptUtils::UpdateValToWS( varName, val, index ); } } else if( varType == VariableList::VAR_STRING ) { const char *val = TOLUA_TOSTRING( val, L, 3, "" ); varList->SetVarValue( varName, tString( val ), index ); if( operType == Script::VT_GLOBAL ) { ScriptUtils::UpdateValToWS( varName, tString( val ), index ); } } else if( varType == VariableList::VAR_GUID ) { const CGUID *val = TOLUA_TOGUID( val, L, 3, &NULL_GUID ); varList->SetVarValue( varName, *val, index ); if( operType == Script::VT_GLOBAL ) { ScriptUtils::UpdateValToWS( varName, *val, index ); } } else { // argument error ret = false; } } else { // pop the arguments. int top = lua_gettop( L ); lua_settop( L, top - 3 ); } lua_pushboolean( L, ret ? 1 : 0 ); return 1; }
// encode a string for safe inclusion into an URL tString nKrawall::EncodeString( tString const & original ) { std::istringstream in( static_cast< char const * >( original ) ); std::ostringstream out; char c = in.get(); while ( !in.eof() ) { if ( c == ' ' ) { out.put( '+' ); } else if ( isalnum( c ) ) { out.put( c ); } else { out.put('%'); out << std::uppercase; sn_WriteHexByte( out, c ); } c = in.get(); } return tString( out.str().c_str() ); }
// called on the master server when the league message is received void nKrawall::ReceiveLeagueMessage(const tString& message) { // con << message; if (message[0] == 'K') { tString killer(message.c_str()+1); tString victim(message.c_str()+1+killer.Len()); MasterFrag(killer, victim); } else if (message[0] == 'R') { tString numP(message.c_str()+1); int pos = 1 + numP.Len(); int numPlayers = atoi(numP); tArray<tString> players(numPlayers); for (int i = numPlayers-1; i>=0; i--) { players(i) = tString(message.c_str()+pos); pos += players(i).Len(); } MasterRoundEnd(&players[0], numPlayers); } }
// does standard replacements to prefix and suffix; // %u -> username static tString sn_Replace( nKrawall::nScrambleInfo const & info, tString const & original ) { std::istringstream in( static_cast< char const * >( original ) ); std::ostringstream out; char s = in.get(); while ( !in.eof() ) { if ( s != '%' || in.eof() ) { out.put(s); } else { s = in.get(); if ( s == 'u' ) { out << info.username; } else { out << '%' << s; } } s = in.get(); } return tString( out.str().c_str() ); }
tWString GetSystemSpecialPath(eSystemPath aPathType) { #if defined(WIN32) int type; switch(aPathType) { case eSystemPath_Personal: type = CSIDL_PERSONAL; break; default: return _W(""); } TCHAR sPath[1024]; if(SUCCEEDED(SHGetFolderPath(NULL, type | CSIDL_FLAG_CREATE, NULL,0,sPath))) { return tWString(sPath); } else { return _W(""); } #else switch (aPathType) { case eSystemPath_Personal: { const char *home = getenv("HOME"); return cString::To16Char(tString(home)); } default: return _W(""); } #endif }
// encode scrambled passwords and salts as hexcode strings tString nKrawall::EncodeScrambledPassword( nScrambledPassword const & scrambled ) { std::ostringstream s; for( int i = 0; i < 16; ++i ) { unsigned int val = scrambled[i]; sn_WriteHexByte( s, val ); } return tString( s.str().c_str() ); }
cAnimationTrack* cAnimation::GetTrackByName(const tString &asName) { for(size_t i=0; i< mvTracks.size(); ++i) { if(asName == tString(mvTracks[i]->GetName())) { return mvTracks[i]; } } return NULL; }
// from two strings of supported-method-lists, select the best one tString nKrawall::nMethod::BestMethod( tString const & a, tString const & b ) { tString ret; // iterate through methods, starting from best, and return the first that fits std::vector< tString > methods; sn_GetSupportedMethods( methods); for( std::vector< tString >::iterator iter = methods.begin(); iter != methods.end(); ++iter ) { if ( sn_BothHave( a, b, *iter ) ) { return *iter; } } return tString(""); }
bool CRestoreObjectDlg::OnClicked(CItemBase* pItem) { sswitch(pItem->m_strItemId.c_str()) stcase(Restore) Restore(); sbreak; stcase(SaveAss) if( Root()->BrowseFile(*this, LoadLocString(tString(), STRID_BROWSEOBJRESTORE), NULL, m_pStruct->m_strObjectName, true) ) Restore(); sbreak; stcase(Skip) Close(); sbreak; send; return true; }
// supported authentication methods of this client in a comma separated list tString nKrawall::nMethod::SupportedMethods() { std::ostringstream s; std::vector< tString > methods; sn_GetSupportedMethods( methods); bool first = false; for( std::vector< tString >::iterator iter = methods.begin(); iter != methods.end(); ++iter ) { if ( !first ) { s << ", "; } s << *iter; first = false; } return tString( s.str().c_str() ); }
std::string parseRequest(int skt) { std::vector<char*> headers; GetHeaderLines(headers,skt,0); std::string requestedResource = ""; //parse index headers for(int i = 0; i < headers.size(); i++) { std::cout << headers[i] << std::endl; std::string tString(headers[i]); int idx; //find requested resource in request headers if((idx = tString.find("HTTP_GET")) >= 0) { std::cout << "FOUND! at index " << idx << std::endl; int sidx, eidx; sidx = tString.find(" ") + 1; eidx = tString.find(" ", sidx); requestedResource = tString.substr(sidx, eidx - sidx); std::cout << requestedResource << std::endl; return requestedResource; } } return STAT_404; }
tString ChatDialog::GetSkinFolder() { return tString(CPaintManagerUI::GetInstancePath()) + _T("skin\\"); }
constexpr char *GetEngineVersionString() { return tString("Andromeda TPR-A" + std::to_string(ENGINE_VERSION_MINOR) + std::to_string(ENGINE_VERSION_REV)).c_str(); };
nsresult TextEditRules::WillSetText(Selection& aSelection, bool* aCancel, bool* aHandled, const nsAString* aString, int32_t aMaxLength) { MOZ_ASSERT(aCancel); MOZ_ASSERT(aHandled); MOZ_ASSERT(aString); CANCEL_OPERATION_IF_READONLY_OR_DISABLED *aHandled = false; *aCancel = false; if (NS_WARN_IF(!mTextEditor)) { return NS_ERROR_FAILURE; } RefPtr<TextEditor> textEditor = mTextEditor; if (!IsPlaintextEditor() || textEditor->IsIMEComposing() || aMaxLength != -1) { // SetTextImpl only supports plain text editor without IME. return NS_OK; } if (IsPasswordEditor() && LookAndFeel::GetEchoPassword() && !DontEchoPassword()) { // Echo password timer will implement on InsertText. return NS_OK; } WillInsert(aSelection, aCancel); // we want to ignore result of WillInsert() *aCancel = false; RefPtr<Element> rootElement = textEditor->GetRoot(); uint32_t count = rootElement->GetChildCount(); // handles only when there is only one node and it's a text node, or empty. if (count > 1) { return NS_OK; } nsAutoString tString(*aString); if (IsPasswordEditor()) { mPasswordText.Assign(tString); FillBufWithPWChars(&tString, tString.Length()); } else if (IsSingleLineEditor()) { HandleNewLines(tString, textEditor->mNewlineHandling); } if (!count) { if (tString.IsEmpty()) { *aHandled = true; return NS_OK; } RefPtr<nsIDocument> doc = textEditor->GetDocument(); if (NS_WARN_IF(!doc)) { return NS_OK; } RefPtr<nsTextNode> newNode = EditorBase::CreateTextNode(*doc, tString); if (NS_WARN_IF(!newNode)) { return NS_OK; } nsresult rv = textEditor->InsertNode(*newNode, *rootElement, 0); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } *aHandled = true; ASSERT_PASSWORD_LENGTHS_EQUAL(); return NS_OK; } nsINode* curNode = rootElement->GetFirstChild(); if (NS_WARN_IF(!EditorBase::IsTextNode(curNode))) { return NS_OK; } // don't change my selection in subtransactions AutoTransactionsConserveSelection dontChangeMySelection(textEditor); // Even if empty text, we don't remove text node and set empty text // for performance nsresult rv = textEditor->SetTextImpl(aSelection, tString, *curNode->GetAsText()); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } *aHandled = true; ASSERT_PASSWORD_LENGTHS_EQUAL(); return NS_OK; }
nsresult TextEditRules::WillInsertText(EditAction aAction, Selection* aSelection, bool* aCancel, bool* aHandled, const nsAString* inString, nsAString* outString, int32_t aMaxLength) { if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; } if (inString->IsEmpty() && aAction != EditAction::insertIMEText) { // HACK: this is a fix for bug 19395 // I can't outlaw all empty insertions // because IME transaction depend on them // There is more work to do to make the // world safe for IME. *aCancel = true; *aHandled = false; return NS_OK; } // initialize out param *aCancel = false; *aHandled = true; // handle docs with a max length // NOTE, this function copies inString into outString for us. bool truncated = false; nsresult rv = TruncateInsertionIfNeeded(aSelection, inString, outString, aMaxLength, &truncated); NS_ENSURE_SUCCESS(rv, rv); // If we're exceeding the maxlength when composing IME, we need to clean up // the composing text, so we shouldn't return early. if (truncated && outString->IsEmpty() && aAction != EditAction::insertIMEText) { *aCancel = true; return NS_OK; } uint32_t start = 0; uint32_t end = 0; // handle password field docs if (IsPasswordEditor()) { NS_ENSURE_STATE(mTextEditor); nsContentUtils::GetSelectionInTextControl(aSelection, mTextEditor->GetRoot(), start, end); } // if the selection isn't collapsed, delete it. bool bCollapsed; rv = aSelection->GetIsCollapsed(&bCollapsed); NS_ENSURE_SUCCESS(rv, rv); if (!bCollapsed) { NS_ENSURE_STATE(mTextEditor); rv = mTextEditor->DeleteSelection(nsIEditor::eNone, nsIEditor::eStrip); NS_ENSURE_SUCCESS(rv, rv); } WillInsert(*aSelection, aCancel); // initialize out param // we want to ignore result of WillInsert() *aCancel = false; // handle password field data // this has the side effect of changing all the characters in aOutString // to the replacement character if (IsPasswordEditor() && aAction == EditAction::insertIMEText) { RemoveIMETextFromPWBuf(start, outString); } // People have lots of different ideas about what text fields // should do with multiline pastes. See bugs 21032, 23485, 23485, 50935. // The six possible options are: // 0. paste newlines intact // 1. paste up to the first newline (default) // 2. replace newlines with spaces // 3. strip newlines // 4. replace with commas // 5. strip newlines and surrounding whitespace // So find out what we're expected to do: if (IsSingleLineEditor()) { nsAutoString tString(*outString); NS_ENSURE_STATE(mTextEditor); HandleNewLines(tString, mTextEditor->mNewlineHandling); outString->Assign(tString); } if (IsPasswordEditor()) { // manage the password buffer mPasswordText.Insert(*outString, start); if (LookAndFeel::GetEchoPassword() && !DontEchoPassword()) { HideLastPWInput(); mLastStart = start; mLastLength = outString->Length(); if (mTimer) { mTimer->Cancel(); } else { mTimer = do_CreateInstance("@mozilla.org/timer;1", &rv); NS_ENSURE_SUCCESS(rv, rv); } mTimer->InitWithCallback(this, LookAndFeel::GetPasswordMaskDelay(), nsITimer::TYPE_ONE_SHOT); } else { FillBufWithPWChars(outString, outString->Length()); } } // get the (collapsed) selection location NS_ENSURE_STATE(aSelection->GetRangeAt(0)); nsCOMPtr<nsINode> selNode = aSelection->GetRangeAt(0)->GetStartContainer(); int32_t selOffset = aSelection->GetRangeAt(0)->StartOffset(); NS_ENSURE_STATE(selNode); // don't put text in places that can't have it NS_ENSURE_STATE(mTextEditor); if (!EditorBase::IsTextNode(selNode) && !mTextEditor->CanContainTag(*selNode, *nsGkAtoms::textTagName)) { return NS_ERROR_FAILURE; } // we need to get the doc NS_ENSURE_STATE(mTextEditor); nsCOMPtr<nsIDocument> doc = mTextEditor->GetDocument(); NS_ENSURE_TRUE(doc, NS_ERROR_NOT_INITIALIZED); if (aAction == EditAction::insertIMEText) { NS_ENSURE_STATE(mTextEditor); // Find better insertion point to insert text. mTextEditor->FindBetterInsertionPoint(selNode, selOffset); // If there is one or more IME selections, its minimum offset should be // the insertion point. int32_t IMESelectionOffset = mTextEditor->GetIMESelectionStartOffsetIn(selNode); if (IMESelectionOffset >= 0) { selOffset = IMESelectionOffset; } rv = mTextEditor->InsertTextImpl(*outString, address_of(selNode), &selOffset, doc); NS_ENSURE_SUCCESS(rv, rv); } else { // aAction == EditAction::insertText; find where we are nsCOMPtr<nsINode> curNode = selNode; int32_t curOffset = selOffset; // don't change my selection in subtransactions NS_ENSURE_STATE(mTextEditor); AutoTransactionsConserveSelection dontChangeMySelection(mTextEditor); rv = mTextEditor->InsertTextImpl(*outString, address_of(curNode), &curOffset, doc); NS_ENSURE_SUCCESS(rv, rv); if (curNode) { // Make the caret attach to the inserted text, unless this text ends with a LF, // in which case make the caret attach to the next line. bool endsWithLF = !outString->IsEmpty() && outString->Last() == nsCRT::LF; aSelection->SetInterlinePosition(endsWithLF); aSelection->Collapse(curNode, curOffset); } } ASSERT_PASSWORD_LENGTHS_EQUAL() return NS_OK; }
tString MainFrame::GetSkinFolder() { return tString(CPaintManagerUI::GetInstancePath()); }
nsresult nsTextEditRules::WillInsertText(PRInt32 aAction, nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled, const nsAString *inString, nsAString *outString, PRInt32 aMaxLength) { if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; } if (inString->IsEmpty() && (aAction != kInsertTextIME)) { // HACK: this is a fix for bug 19395 // I can't outlaw all empty insertions // because IME transaction depend on them // There is more work to do to make the // world safe for IME. *aCancel = PR_TRUE; *aHandled = PR_FALSE; return NS_OK; } // initialize out param *aCancel = PR_FALSE; *aHandled = PR_TRUE; // handle docs with a max length // NOTE, this function copies inString into outString for us. PRBool truncated = PR_FALSE; nsresult res = TruncateInsertionIfNeeded(aSelection, inString, outString, aMaxLength, &truncated); NS_ENSURE_SUCCESS(res, res); if (truncated && outString->IsEmpty()) { *aCancel = PR_TRUE; return NS_OK; } PRUint32 start = 0; PRUint32 end = 0; // handle password field docs if (IsPasswordEditor()) { res = mEditor->GetTextSelectionOffsets(aSelection, start, end); NS_ASSERTION((NS_SUCCEEDED(res)), "getTextSelectionOffsets failed!"); NS_ENSURE_SUCCESS(res, res); } // if the selection isn't collapsed, delete it. PRBool bCollapsed; res = aSelection->GetIsCollapsed(&bCollapsed); NS_ENSURE_SUCCESS(res, res); if (!bCollapsed) { res = mEditor->DeleteSelection(nsIEditor::eNone); NS_ENSURE_SUCCESS(res, res); } res = WillInsert(aSelection, aCancel); NS_ENSURE_SUCCESS(res, res); // initialize out param // we want to ignore result of WillInsert() *aCancel = PR_FALSE; // handle password field data // this has the side effect of changing all the characters in aOutString // to the replacement character if (IsPasswordEditor()) { if (aAction == kInsertTextIME) { res = RemoveIMETextFromPWBuf(start, outString); NS_ENSURE_SUCCESS(res, res); } } // People have lots of different ideas about what text fields // should do with multiline pastes. See bugs 21032, 23485, 23485, 50935. // The six possible options are: // 0. paste newlines intact // 1. paste up to the first newline (default) // 2. replace newlines with spaces // 3. strip newlines // 4. replace with commas // 5. strip newlines and surrounding whitespace // So find out what we're expected to do: if (IsSingleLineEditor()) { nsAutoString tString(*outString); HandleNewLines(tString, mEditor->mNewlineHandling); outString->Assign(tString); } if (IsPasswordEditor()) { // manage the password buffer mPasswordText.Insert(*outString, start); nsCOMPtr<nsILookAndFeel> lookAndFeel = do_GetService(kLookAndFeelCID); if (lookAndFeel->GetEchoPassword() && !DontEchoPassword()) { HideLastPWInput(); mLastStart = start; mLastLength = outString->Length(); if (mTimer) { mTimer->Cancel(); } else { mTimer = do_CreateInstance("@mozilla.org/timer;1", &res); NS_ENSURE_SUCCESS(res, res); } mTimer->InitWithCallback(this, 600, nsITimer::TYPE_ONE_SHOT); } else { res = FillBufWithPWChars(outString, outString->Length()); NS_ENSURE_SUCCESS(res, res); } } // get the (collapsed) selection location nsCOMPtr<nsIDOMNode> selNode; PRInt32 selOffset; res = mEditor->GetStartNodeAndOffset(aSelection, getter_AddRefs(selNode), &selOffset); NS_ENSURE_SUCCESS(res, res); // don't put text in places that can't have it if (!mEditor->IsTextNode(selNode) && !mEditor->CanContainTag(selNode, NS_LITERAL_STRING("#text"))) return NS_ERROR_FAILURE; // we need to get the doc nsCOMPtr<nsIDOMDocument>doc; res = mEditor->GetDocument(getter_AddRefs(doc)); NS_ENSURE_SUCCESS(res, res); NS_ENSURE_TRUE(doc, NS_ERROR_NULL_POINTER); if (aAction == kInsertTextIME) { res = mEditor->InsertTextImpl(*outString, address_of(selNode), &selOffset, doc); NS_ENSURE_SUCCESS(res, res); } else // aAction == kInsertText { // find where we are nsCOMPtr<nsIDOMNode> curNode = selNode; PRInt32 curOffset = selOffset; // don't spaz my selection in subtransactions nsAutoTxnsConserveSelection dontSpazMySelection(mEditor); res = mEditor->InsertTextImpl(*outString, address_of(curNode), &curOffset, doc); NS_ENSURE_SUCCESS(res, res); if (curNode) { // Make the caret attach to the inserted text, unless this text ends with a LF, // in which case make the caret attach to the next line. PRBool endsWithLF = !outString->IsEmpty() && outString->Last() == nsCRT::LF; nsCOMPtr<nsISelectionPrivate>selPrivate(do_QueryInterface(aSelection)); selPrivate->SetInterlinePosition(endsWithLF); aSelection->Collapse(curNode, curOffset); } } ASSERT_PASSWORD_LENGTHS_EQUAL() return res; }
bool CEngineCore::Init(const char *asGameFolder, const char *asCmdLine, bool abDedicated, CreateInterfaceFn afnLauncherFactory) { // Already initialized if(mbInitialized) { DevWarning("Called core init while it's already initialized!"); return true; }; LogMsg("Initializing the core module..."); //LogMsg("\t%s Magenta (build %i) started at %s"/*, s_wcd.title, ENGINE_BUILD, Q_timestamp(TIME_FULL)*/); DevMsg("Magenta Core\nVersion %d.%d.%d/%s (%s)", ENGINE_VERSION_MAJOR, ENGINE_VERSION_MINOR, ENGINE_VERSION_REV, ENGINE_VERSION_STRING, asGameFolder); DevMsg("Exe build: " __TIME__ " " __DATE__ " (%04d)", ENGINE_BUILD /*build_number()*/); //DevMsg("Protocol version: %d", GetProtocolVersion()); // 30 frames cap by default int nFrameCount = 30; // 100 frames for dedicated mode (equals to sys_ticrate 100) if(abDedicated) nFrameCount = 100; //============================================================================================= mpLogicTimer = std::make_unique<CLogicTimer>(nFrameCount); mpUpdater = std::make_unique<CUpdater>(); //mpConsole = std::make_unique<CNullConsole>(); //mpGameInfo = std::make_shared<CNullGameInfo>(); //mpGameInfoHandler = std::make_unique<CNullGameInfoHandler>(); //mpHost = std::make_unique<CEngineHost>(); mpPluginManager = std::make_unique<CPluginManager>(afnLauncherFactory); mpGame = std::make_unique<CGameRef>(); mpInput = std::make_unique<CInput>(); /* mpGameServer = std::make_unique<CGameServer>(); mpEdictHandler = std::make_unique<CEdictHandler>(); mpEngineFuncs = std::make_unique<CEngineFuncs>(nullptr, nullptr, mpEdictHandler.get()); if(!mpGameServer->Init()) return false; */ //============================================================================================= //if(!abDedicated) // Init client side mpPluginManager->LoadPluginList("plugins"); mpEventManager->PostEvent(eEngineEvent::Init); mpLogicTimer->Reset(); tString sFailReason = ""; bool bInitFailed = false; //if(!mpConsole->Init()) //{ //sFailReason += "\t- Couldn't init console module!\n"; //return false; //}; if(!mpGame->LoadFromFile(std::move(tString(asGameFolder) + "/bin/game") /*mpGameInfo->msGameDLLPath*/)) return false; if(!mpGame->Init()) return false; // Allow mice or other external controllers to add commands if(!abDedicated) mpUpdater->AddGlobalUpdate(mpInput.release()); //mpUpdater->AddGlobalUpdate(mpNetwork.release()); //mpUpdater->AddGlobalUpdate(mpPhysics.release()); //mpUpdater->AddGlobalUpdate(mpScene.release()); mpUpdater->AddGlobalUpdate(mpGame.release()); mpUpdater->AddContainer("Default"); mpUpdater->SetContainer("Default"); /* IBaseInterface *pInterface = ModuleInit::TryInit(NETWORK_INTERFACE_VERSION, nullptr); IBaseInterface *ModuleInit::TryInit(const char *asInterfaceName, int &retval) { IBaseInterface *pInterface; if(!(pInterface = afnLauncherFactory(asInterfaceName, retval))) { sFailReason += "\t- Can't get " + asInterfaceName + " module!\n"; // if not failed yet - now is the time if(!mbInitFailed) mbInitFailed = true; }; }; */ //if(ModuleInit::IsInitFailed()) //return false; /*if(!(mpNetwork = (INetwork*)afnLauncherFactory(NETWORK_INTERFACE_VERSION, nullptr))) { sFailReason += "\t- Can't get network module!\n"; bInitFailed = true; }; if(!(mpFileSystem = (IFileSystem*)afnLauncherFactory(FILESYSTEM_INTERFACE_VERSION, nullptr))) { sFailReason += "\t- Can't get filesystem module!\n"; bInitFailed = true; };*/ /* if(!(mpPhysics = (IPhysics*)afnLauncherFactory(PHYSICS_INTERFACE_VERSION, nullptr))) // is this needed here? { sFailReason += "\t- Can't get physics module!\n"; //bInitFailed = true; }; */ if(bInitFailed) { DevError("Can't init the core module!\n(Reason(s):\n%s", sFailReason.c_str()); return false; }; msGameFolder = asGameFolder; // Convert liblist.gam file into gameinfo.txt if exist (presume that gameinfo.txt is exist) //if(mpFileSystem->IsFileExists(msGameFolder + "/gameinfo.txt") //mpGameInfo->LoadFromFile(msGameFolder + "/gameinfo.txt"); //else if(mpFileSystem->IsFileExists(msGameFolder + "/liblist.gam")) //mpGameInfoHandler->ConvertToGameInfo(msGameFolder + "/liblist.gam"); //if(!pLowLevelFileSystem->IsFileExist(msGameFolder + "/gameinfo.txt") && pLowLevelFileSystem->IsFileExist(msGameFolder + "/liblist.gam")) //mpGameInfoHandler->ConvertToGameInfo(msGameFolder + "/liblist.gam"); //else //mpGameInfoHandler->CreateDefaultGameInfo()->SaveToFile(msGameFolder + "/gameinfo.txt"); // Todo: check if file exist inside LoadFromFile method //mpGameInfo->LoadFromFile(msGameFolder + "/gameinfo.txt"); mpEventManager->PostEvent(eEngineEvent::PostInit); // Broadcast mbInitialized = true; return true; };
tString CColorPicker::GetSkinFolder() { return tString(CPaintManagerUI::GetInstancePath()) + _T("skin\\"); }
std::string typeString(identifier *id) { return tString(id->type, id->stype); }
std::string typeString(expr *exp) { return tString(ssimple_type, exp->value.stype);//support only simple type now }
tString WindowImplBase::GetSkinFolder() { return tString(CPaintManagerUI::GetInstancePath()); //+ _T("skin\\"); }
tString Emotionlist::GetSkinFolder() { return tString(CPaintManagerUI::GetInstancePath()) + _T("skin\\QQRes\\"); }
//----- errorReport() ------------------------------------------------------- static void HK_CALL errorReport(const char* msg, void* userArgGivenToInit) { CString tString("Havok System returns error:\r\n\r\n"); AfxMessageBox(tString += msg); }
nsresult nsTextEditRules::WillInsertText(PRInt32 aAction, nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled, const nsAString *inString, nsAString *outString, PRInt32 aMaxLength) { if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; } if (inString->IsEmpty() && (aAction != kInsertTextIME)) { // HACK: this is a fix for bug 19395 // I can't outlaw all empty insertions // because IME transaction depend on them // There is more work to do to make the // world safe for IME. *aCancel = PR_TRUE; *aHandled = PR_FALSE; return NS_OK; } // initialize out param *aCancel = PR_FALSE; *aHandled = PR_TRUE; // handle docs with a max length // NOTE, this function copies inString into outString for us. nsresult res = TruncateInsertionIfNeeded(aSelection, inString, outString, aMaxLength); NS_ENSURE_SUCCESS(res, res); PRUint32 start = 0; PRUint32 end = 0; // handle password field docs if (IsPasswordEditor()) { res = mEditor->GetTextSelectionOffsets(aSelection, start, end); NS_ASSERTION((NS_SUCCEEDED(res)), "getTextSelectionOffsets failed!"); NS_ENSURE_SUCCESS(res, res); } // if the selection isn't collapsed, delete it. PRBool bCollapsed; res = aSelection->GetIsCollapsed(&bCollapsed); NS_ENSURE_SUCCESS(res, res); if (!bCollapsed) { res = mEditor->DeleteSelection(nsIEditor::eNone); NS_ENSURE_SUCCESS(res, res); } res = WillInsert(aSelection, aCancel); NS_ENSURE_SUCCESS(res, res); // initialize out param // we want to ignore result of WillInsert() *aCancel = PR_FALSE; // handle password field data // this has the side effect of changing all the characters in aOutString // to the replacement character if (IsPasswordEditor()) { if (aAction == kInsertTextIME) { res = RemoveIMETextFromPWBuf(start, outString); NS_ENSURE_SUCCESS(res, res); } } // People have lots of different ideas about what text fields // should do with multiline pastes. See bugs 21032, 23485, 23485, 50935. // The six possible options are: // 0. paste newlines intact // 1. paste up to the first newline (default) // 2. replace newlines with spaces // 3. strip newlines // 4. replace with commas // 5. strip newlines and surrounding whitespace // So find out what we're expected to do: if (IsSingleLineEditor()) { nsAutoString tString(*outString); HandleNewLines(tString, mEditor->mNewlineHandling); outString->Assign(tString); } if (IsPasswordEditor()) { // manage the password buffer mPasswordText.Insert(*outString, start); nsCOMPtr<nsILookAndFeel> lookAndFeel = do_GetService(kLookAndFeelCID); if (lookAndFeel->GetEchoPassword() && !DontEchoPassword()) { HideLastPWInput(); mLastStart = start; mLastLength = outString->Length(); if (mTimer) { mTimer->Cancel(); } else { mTimer = do_CreateInstance("@mozilla.org/timer;1", &res); NS_ENSURE_SUCCESS(res, res); } mTimer->InitWithCallback(this, 600, nsITimer::TYPE_ONE_SHOT); } else { res = FillBufWithPWChars(outString, outString->Length()); NS_ENSURE_SUCCESS(res, res); } } // get the (collapsed) selection location nsCOMPtr<nsIDOMNode> selNode; PRInt32 selOffset; res = mEditor->GetStartNodeAndOffset(aSelection, getter_AddRefs(selNode), &selOffset); NS_ENSURE_SUCCESS(res, res); // don't put text in places that can't have it if (!mEditor->IsTextNode(selNode) && !mEditor->CanContainTag(selNode, NS_LITERAL_STRING("#text"))) return NS_ERROR_FAILURE; // we need to get the doc nsCOMPtr<nsIDOMDocument>doc; res = mEditor->GetDocument(getter_AddRefs(doc)); NS_ENSURE_SUCCESS(res, res); NS_ENSURE_TRUE(doc, NS_ERROR_NULL_POINTER); if (aAction == kInsertTextIME) { res = mEditor->InsertTextImpl(*outString, address_of(selNode), &selOffset, doc); NS_ENSURE_SUCCESS(res, res); } else // aAction == kInsertText { // find where we are nsCOMPtr<nsIDOMNode> curNode = selNode; PRInt32 curOffset = selOffset; // is our text going to be PREformatted? // We remember this so that we know how to handle tabs. PRBool isPRE; res = mEditor->IsPreformatted(selNode, &isPRE); NS_ENSURE_SUCCESS(res, res); // don't spaz my selection in subtransactions nsAutoTxnsConserveSelection dontSpazMySelection(mEditor); nsString tString(*outString); const PRUnichar *unicodeBuf = tString.get(); nsCOMPtr<nsIDOMNode> unused; PRInt32 pos = 0; // for efficiency, break out the pre case separately. This is because // it's a lot cheaper to search the input string for only newlines than // it is to search for both tabs and newlines. if (isPRE) { while (unicodeBuf && (pos != -1) && ((PRUint32)pos < tString.Length())) { PRInt32 oldPos = pos; PRInt32 subStrLen; pos = tString.FindChar(nsCRT::LF, oldPos); if (pos != -1) { subStrLen = pos - oldPos; // if first char is newline, then use just it if (subStrLen == 0) subStrLen = 1; } else { subStrLen = tString.Length() - oldPos; pos = tString.Length(); } nsDependentSubstring subStr(tString, oldPos, subStrLen); // is it a return? if (subStr.EqualsLiteral(LFSTR)) { if (IsSingleLineEditor()) { NS_ASSERTION((mEditor->mNewlineHandling == nsIPlaintextEditor::eNewlinesPasteIntact), "Newline improperly getting into single-line edit field!"); res = mEditor->InsertTextImpl(subStr, address_of(curNode), &curOffset, doc); } else { res = mEditor->CreateBRImpl(address_of(curNode), &curOffset, address_of(unused), nsIEditor::eNone); // If the newline is the last character in the string, and the BR we // just inserted is the last node in the content tree, we need to add // a mozBR so that a blank line is created. if (NS_SUCCEEDED(res) && curNode && pos == (PRInt32)(tString.Length() - 1)) { nsCOMPtr<nsIDOMNode> nextChild = mEditor->GetChildAt(curNode, curOffset); if (!nextChild) { // We must be at the end since there isn't a nextChild. // // curNode and curOffset should be set to the position after // the BR we added above, so just create a mozBR at that position. // // Note that we don't update curOffset after we've created/inserted // the mozBR since we never want the selection to be placed after it. res = CreateMozBR(curNode, curOffset, address_of(unused)); } } } pos++; } else { res = mEditor->InsertTextImpl(subStr, address_of(curNode), &curOffset, doc); } NS_ENSURE_SUCCESS(res, res); } } else { char specialChars[] = {TAB, nsCRT::LF, 0}; while (unicodeBuf && (pos != -1) && ((PRUint32)pos < tString.Length())) { PRInt32 oldPos = pos; PRInt32 subStrLen; pos = tString.FindCharInSet(specialChars, oldPos); if (pos != -1) { subStrLen = pos - oldPos; // if first char is newline, then use just it if (subStrLen == 0) subStrLen = 1; } else { subStrLen = tString.Length() - oldPos; pos = tString.Length(); } nsDependentSubstring subStr(tString, oldPos, subStrLen); // is it a tab? if (subStr.EqualsLiteral("\t")) { res = mEditor->InsertTextImpl(NS_LITERAL_STRING(" "), address_of(curNode), &curOffset, doc); pos++; } // is it a return? else if (subStr.EqualsLiteral(LFSTR)) { res = mEditor->CreateBRImpl(address_of(curNode), &curOffset, address_of(unused), nsIEditor::eNone); pos++; } else { res = mEditor->InsertTextImpl(subStr, address_of(curNode), &curOffset, doc); } NS_ENSURE_SUCCESS(res, res); } } outString->Assign(tString); if (curNode) { aSelection->Collapse(curNode, curOffset); // Make the caret attach to the inserted text, unless this text ends with a LF, // in which case make the caret attach to the next line. PRBool endsWithLF = !tString.IsEmpty() && tString.get()[tString.Length() - 1] == nsCRT::LF; nsCOMPtr<nsISelectionPrivate>selPrivate(do_QueryInterface(aSelection)); selPrivate->SetInterlinePosition(endsWithLF); } } ASSERT_PASSWORD_LENGTHS_EQUAL() return res; }
tString CMainWindow::GetSkinFolder() { return tString(CPaintManagerUI::GetInstancePath()) + _T("skin\\"); }
tString CPicBarDlg::GetSkinFolder() { return tString(CPaintManagerUI::GetInstancePath()) + _T("skin\\"); }