added amb1666 - rehaul over the ml api so extensions can easily use translations
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%402132
This commit is contained in:
+10
-15
@@ -67,6 +67,7 @@ CPlugin::CPlugin(const char *file)
|
||||
m_FakeNativesMissing = false;
|
||||
m_LibraryMissing = false;
|
||||
m_bGotAllLoaded = false;
|
||||
m_pPhrases = g_Translator.CreatePhraseCollection();
|
||||
}
|
||||
|
||||
CPlugin::~CPlugin()
|
||||
@@ -111,6 +112,11 @@ CPlugin::~CPlugin()
|
||||
delete m_configs[i];
|
||||
}
|
||||
m_configs.clear();
|
||||
if (m_pPhrases != NULL)
|
||||
{
|
||||
m_pPhrases->Destroy();
|
||||
m_pPhrases = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void CPlugin::InitIdentity()
|
||||
@@ -128,7 +134,6 @@ unsigned int CPlugin::CalcMemUsage()
|
||||
unsigned int base_size =
|
||||
sizeof(CPlugin)
|
||||
+ sizeof(IdentityToken_t)
|
||||
+ (m_PhraseFiles.size() * sizeof(unsigned int))
|
||||
+ (m_dependents.size() * sizeof(CPlugin *))
|
||||
+ (m_dependsOn.size() * sizeof(CPlugin *))
|
||||
+ (m_fakeNatives.size() * (sizeof(FakeNative *) + sizeof(FakeNative)))
|
||||
@@ -710,19 +715,9 @@ void CPlugin::SetTimeStamp(time_t t)
|
||||
m_LastAccess = t;
|
||||
}
|
||||
|
||||
void CPlugin::AddLangFile(unsigned int index)
|
||||
IPhraseCollection *CPlugin::GetPhrases()
|
||||
{
|
||||
m_PhraseFiles.push_back(index);
|
||||
}
|
||||
|
||||
size_t CPlugin::GetLangFileCount()
|
||||
{
|
||||
return m_PhraseFiles.size();
|
||||
}
|
||||
|
||||
unsigned int CPlugin::GetLangFileByIndex(unsigned int index)
|
||||
{
|
||||
return m_PhraseFiles.at(index);
|
||||
return m_pPhrases;
|
||||
}
|
||||
|
||||
void CPlugin::DependencyDropped(CPlugin *pOwner)
|
||||
@@ -1488,8 +1483,8 @@ bool CPluginManager::RunSecondPass(CPlugin *pPlugin, char *error, size_t maxleng
|
||||
OnLibraryAction((*s_iter).c_str(), true, false);
|
||||
}
|
||||
|
||||
/* Finally, add the core language file */
|
||||
pPlugin->AddLangFile(g_pCorePhraseID);
|
||||
/* :TODO: optimize? does this even matter? */
|
||||
pPlugin->GetPhrases()->AddPhraseFile("core.phrases");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
#else
|
||||
#include "convar_sm.h"
|
||||
#endif
|
||||
#include "ITranslator.h"
|
||||
|
||||
using namespace SourceHook;
|
||||
|
||||
@@ -244,19 +245,9 @@ public:
|
||||
bool IsRunnable();
|
||||
|
||||
/**
|
||||
* Adds a language file index to the plugin's list.
|
||||
* Get languages info.
|
||||
*/
|
||||
void AddLangFile(unsigned int index);
|
||||
|
||||
/**
|
||||
* Get language file count for this plugin.
|
||||
*/
|
||||
size_t GetLangFileCount();
|
||||
|
||||
/**
|
||||
* Get language file index based on the vector index.
|
||||
*/
|
||||
unsigned int GetLangFileByIndex(unsigned int index);
|
||||
IPhraseCollection *GetPhrases();
|
||||
public:
|
||||
/**
|
||||
* Returns the modification time during last plugin load.
|
||||
@@ -300,7 +291,7 @@ private:
|
||||
IdentityToken_t *m_ident;
|
||||
Handle_t m_handle;
|
||||
bool m_WasRunning;
|
||||
CVector<unsigned int> m_PhraseFiles;
|
||||
IPhraseCollection *m_pPhrases;
|
||||
List<CPlugin *> m_dependents;
|
||||
List<CPlugin *> m_dependsOn;
|
||||
List<FakeNative *> m_fakeNatives;
|
||||
|
||||
Reference in New Issue
Block a user