Fix toasts

This commit is contained in:
momo5502 2016-06-24 15:15:18 +02:00
parent 75af2aa24e
commit 545d6458c8
4 changed files with 26 additions and 28 deletions

View File

@ -250,23 +250,6 @@ namespace Components
// DB_AddXAsset
Utils::Hook(0x5BB650, AssetHandler::AddAssetStub, HOOK_JUMP).Install()->Quick();
Command::Add("listassets", [] (Command::Params params)
{
if (params.Length() < 2) return;
Game::XAssetType type = Game::DB_GetXAssetNameType(params[1]);
if (type != Game::XAssetType::ASSET_TYPE_INVALID)
{
Game::DB_EnumXAssets(type, [] (Game::XAssetHeader header, void* data)
{
Game::XAssetType type = *static_cast<Game::XAssetType*>(data);
Game::XAsset asset = { type, header };
Logger::Print("%s\n", Game::DB_GetXAssetName(&asset));
}, &type, false);
}
});
// Register asset interfaces
AssetHandler::RegisterInterface(new Assets::IXModel());
AssetHandler::RegisterInterface(new Assets::IMapEnts());

View File

@ -34,17 +34,29 @@ namespace Components
void Command::Add(const char* name, Command::Callback* callback)
{
Command::FunctionMap[Utils::StrToLower(name)] = callback;
Command::AddRaw(name, Command::MainCallback);
std::string command = Utils::StrToLower(name);
if (Command::FunctionMap.find(command) == Command::FunctionMap.end())
{
Command::AddRaw(name, Command::MainCallback);
}
Command::FunctionMap[command] = callback;
}
void Command::AddSV(const char* name, Command::Callback* callback)
{
Command::FunctionMapSV[Utils::StrToLower(name)] = callback;
Command::AddRawSV(name, Command::MainCallbackSV);
std::string command = Utils::StrToLower(name);
// If the main command is registered as Cbuf_AddServerText, the command will be redirected to the SV handler
Command::AddRaw(name, Game::Cbuf_AddServerText);
if (Command::FunctionMapSV.find(command) == Command::FunctionMapSV.end())
{
Command::AddRawSV(name, Command::MainCallbackSV);
// If the main command is registered as Cbuf_AddServerText, the command will be redirected to the SV handler
Command::AddRaw(name, Game::Cbuf_AddServerText);
}
Command::FunctionMapSV[command] = callback;
}
void Command::AddRaw(const char* name, void(*callback)())

View File

@ -14,8 +14,6 @@ namespace Components
void Toast::Draw(UIToast* toast)
{
#pragma warning(push)
#pragma warning(disable: 4244)
if (!toast) return;
int width = Renderer::Width();
@ -50,7 +48,7 @@ namespace Components
int diffH = Renderer::Height() / 5;
int diff = Game::Com_Milliseconds() - startTime;
double scale = 1.0 - ((1.0 * diff) / (1.0 * slideTime));
diffH *= scale;
diffH = static_cast<int>(diffH* scale);
height += diffH;
}
@ -63,7 +61,7 @@ namespace Components
int diffH = Renderer::Height() / 5;
int diff = (startTime + duration) - Game::Com_Milliseconds();
double scale = 1.0 - ((1.0 * diff) / (1.0 * slideTime));
diffH *= scale;
diffH = static_cast<int>(diffH* scale);
height += diffH;
}
@ -88,6 +86,9 @@ namespace Components
bWidth += (bWidth % 2);
bHeight += (bHeight % 2);
#pragma warning(push)
#pragma warning(disable: 4244)
// Corners
Game::R_AddCmdDrawStretchPic(width / 2 - bWidth / 2, height - bHeight / 2, cornerSize, cornerSize, 0, 0, 0.5f, 0.5f, color, circle); // Top-Left
Game::R_AddCmdDrawStretchPic(width / 2 + bWidth / 2 - cornerSize, height - bHeight / 2, cornerSize, cornerSize, 0.5f, 0, 0, 0.5f, color, circle); // Top-Right
@ -111,6 +112,7 @@ namespace Components
int rightText = width / 2 + bWidth / 2 - cornerSize - aCorners - iOffsetLeft;
Game::R_AddCmdDrawText(toast->Title.data(), 0x7FFFFFFF, font, leftText + (rightText - leftText) / 2 - titleSize / 2 + cornerSize, height - bHeight / 2 + cornerSize * 2 + 7, 1.0f, 1.0f, 0, wColor, 0); // Title
Game::R_AddCmdDrawText(toast->Desc.data(), 0x7FFFFFFF, font, leftText + (rightText - leftText) / 2 - descrSize / 2 + cornerSize, height - bHeight / 2 + cornerSize * 2 + 33, 1.0f, 1.0f, 0, wColor, 0); // Description
#pragma warning(pop)
}

View File

@ -582,7 +582,8 @@ namespace Components
{
Game::DB_EnumXAssets(type, [] (Game::XAssetHeader header, void* data)
{
Logger::Print("%s\n", Game::DB_GetXAssetNameHandlers[*(Game::XAssetType*)data](&header));
Game::XAsset asset = { *reinterpret_cast<Game::XAssetType*>(data), header };
Logger::Print("%s\n", Game::DB_GetXAssetName(&asset));
}, &type, false);
}
});