Game Development Reference
In-Depth Information
wchar_t wideKey[64];
wchar_t wideText[1024];
AnsiToWideCch(wideKey, pKey, 64);
AnsiToWideCch(wideText, pText, 1024);
m_textResource[std::wstring(wideKey)] = std::wstring(wideText);
}
}
return true;
}
std::wstring GameCodeApp::GetString(std::wstring sID)
{
auto localizedString = m_textResource.find(sID);
if(localizedString == m_textResource.end())
{
GCC_ASSERT(0 &&
String not found!
);
return L
“”
;
}
return localizedString->second;
}
Your Script Manager and the Events System
The next section of the initialization sequence creates the script parser and event sys-
tem. The GameCode4 code base uses Lua, which is fairly easy to learn and popular.
if (!LuaStateManager::Create())
{
GCC_ERROR(
Failed to initialize Lua
);
return false;
}
// Register functions exported from C++
ScriptExports::Register();
ScriptProcess::RegisterScriptClass();
Once it is created, you could actually use a Lua initialization script to control the rest
of the initialization sequence. This can be a fantastic idea, as the script doesn
t add
very much additional time to the initialization sequence. What the programmer gets
in return is the capability to change the initialization sequence without recompiling
the game. The only other way to do this would be to throw some crazy options on
the command line, which can be unwieldy, even in a trivial case. A Lua script has
control mechanisms for evaluating expressions and looping
'
'
something you
ll come
to enjoy very quickly.
 
 
Search WWH ::




Custom Search