2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-09 02:27:43 +00:00

Initial integration on cook tool

This commit is contained in:
Jack Andersen
2015-09-29 20:23:07 -10:00
parent a3586c9b5a
commit 63a432090c
8 changed files with 474 additions and 170 deletions

View File

@@ -22,7 +22,7 @@ struct ToolPassInfo
HECL::SystemString cwd;
std::list<HECL::SystemString> args;
HECL::SystemString output;
HECL::Database::Project* project = NULL;
HECL::Database::Project* project = nullptr;
unsigned verbosityLevel = 0;
bool force = false;
};
@@ -210,4 +210,87 @@ public:
}
};
void ToolPrintProgress(const HECL::SystemChar* message, const HECL::SystemChar* submessage,
int lidx, float factor, int& lineIdx)
{
factor = std::max(0.0f, std::min(1.0f, factor));
int iFactor = factor * 100.0;
if (XTERM_COLOR)
HECL::Printf(_S("" HIDE_CURSOR ""));
if (lidx > lineIdx)
{
HECL::Printf(_S("\n "));
lineIdx = lidx;
}
else
HECL::Printf(_S(" "));
int width = HECL::ConsoleWidth();
int half = width / 2 - 2;
if (!message)
message = _S("");
size_t messageLen = HECL::StrLen(message);
if (!submessage)
submessage = _S("");
size_t submessageLen = HECL::StrLen(submessage);
if (half - messageLen < submessageLen-2)
submessageLen = 0;
if (submessageLen)
{
if (messageLen > half-submessageLen-1)
HECL::Printf(_S("%.*s... "), half-int(submessageLen)-4, message);
else
{
HECL::Printf(_S("%s"), message);
for (int i=half-messageLen-submessageLen-1 ; i>=0 ; --i)
HECL::Printf(_S(" "));
HECL::Printf(_S("%s "), submessage);
}
}
else
{
if (messageLen > half)
HECL::Printf(_S("%.*s... "), half-3, message);
else
{
HECL::Printf(_S("%s"), message);
for (int i=half-messageLen ; i>=0 ; --i)
HECL::Printf(_S(" "));
}
}
if (XTERM_COLOR)
{
size_t blocks = half - 7;
size_t filled = blocks * factor;
size_t rem = blocks - filled;
HECL::Printf(_S("" BOLD "%3d%% ["), iFactor);
for (int b=0 ; b<filled ; ++b)
HECL::Printf(_S("#"));
for (int b=0 ; b<rem ; ++b)
HECL::Printf(_S("-"));
HECL::Printf(_S("]" NORMAL ""));
}
else
{
size_t blocks = half - 7;
size_t filled = blocks * factor;
size_t rem = blocks - filled;
HECL::Printf(_S("%3d%% ["), iFactor);
for (int b=0 ; b<filled ; ++b)
HECL::Printf(_S("#"));
for (int b=0 ; b<rem ; ++b)
HECL::Printf(_S("-"));
HECL::Printf(_S("]"));
}
HECL::Printf(_S("\r"));
if (XTERM_COLOR)
HECL::Printf(_S("" SHOW_CURSOR ""));
fflush(stdout);
}
#endif // CTOOL_BASE