ログ画面の文字色を指定できるように

git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@410 385bec56-5757-e545-9c3a-d8741f4650f1
This commit is contained in:
N2614 2011-07-28 07:33:38 +00:00
parent 1cec2aa598
commit 6cf2de9f4c
4 changed files with 71 additions and 16 deletions

View File

@ -82,6 +82,11 @@ void CommonLogger::ClearSdLog()
GetSdInstance()->Clear();
}
void CommonLogger::SetTextColor(f32 red, f32 green, f32 blue, f32 alpha)
{
GetConsoleInstance()->SetTextColor(red, green, blue, alpha);
}
void CommonLogger::ScrollUp()
{
GetConsoleInstance()->ScrollUp();

View File

@ -22,6 +22,18 @@
#include "SdLogger.h"
#define COMMON_LOGGER( ... ) (void)common::Logger::GetLoggerInstance()->Print(__VA_ARGS__)
#define COMMON_LOGGER_WARN( ... ) \
(void)common::Logger::GetLoggerInstance()->SetTextColor(1.0f, 1.0f, 0.f, 1.f); \
(void)common::Logger::GetLoggerInstance()->Print(__VA_ARGS__); \
(void)common::Logger::GetLoggerInstance()->SetTextColor(1.0f, 1.0f, 1.f, 1.f); \
#define COMMON_LOGGER_ERROR( ... ) \
(void)common::Logger::GetLoggerInstance()->SetTextColor(1.0f, 0.2f, 0.2f, 1.f); \
(void)common::Logger::GetLoggerInstance()->Print(__VA_ARGS__); \
(void)common::Logger::GetLoggerInstance()->SetTextColor(1.0f, 1.0f, 1.f, 1.f); \
#define COMMON_LOGGER_RESULT(result, func) \
NN_DBG_PRINT_RESULT(result); \
(void)common::Logger::GetLoggerInstance()->PrintResultSdLog("Func = %s\n", func); \
@ -122,6 +134,9 @@ public:
// SDカードのログファイルを消去する
void ClearSdLog();
// 下画面ログのフォントカラーを設定する
void SetTextColor(f32 red, f32 green, f32 blue, f32 alpha);
// 下画面ログを上スクロールする
void ScrollUp();

View File

@ -44,9 +44,13 @@ void LogConsole::Initialize(u32 width, u32 height, u32 maxLine, demo::RenderSyst
m_Width = width;
m_Height = height;
m_MaxLine = maxLine;
m_RenderSystem = renderSystem;
m_pRenderSystem = renderSystem;
m_CurrentViewLine = 0;
m_LineNum = 0;
m_ColorRed = 1.0f;
m_ColorGreen = 1.0f;
m_ColorBlue = 1.0f;
m_ColorAlpha = 1.0f;
}
void LogConsole::AddText(const char* fmt, ::std::va_list arg)
@ -64,7 +68,7 @@ void LogConsole::AddText(const char* fmt, ::std::va_list arg)
if(m_LineNum >= m_MaxLine)
{
// 満杯なので先頭を削除する
::std::vector<std::string>::iterator it;
::std::vector<LogText>::iterator it;
it = m_Log.begin();
m_Log.erase(it);
m_LineNum--;
@ -93,6 +97,14 @@ void LogConsole::AddText(const char* fmt, ::std::va_list arg)
}
}
void LogConsole::SetTextColor(f32 red, f32 green, f32 blue, f32 alpha)
{
m_ColorRed = red;
m_ColorGreen = green;
m_ColorBlue = blue;
m_ColorAlpha = alpha;
}
void LogConsole::ScrollUp()
{
if(m_CurrentViewLine > 0)
@ -131,7 +143,7 @@ void LogConsole::ScrollToEnd()
void LogConsole::Print()
{
::std::vector<std::string>::iterator it;
::std::vector<LogText>::iterator it;
it = m_Log.begin();
it += m_CurrentViewLine;
@ -139,7 +151,8 @@ void LogConsole::Print()
u32 count = 0;
for(; it != m_Log.end() && count < m_Height && count < m_MaxLine; it++)
{
m_RenderSystem->DrawText(0, count++ * 10, "%s", it->c_str());
m_pRenderSystem->SetColor(it->m_Red, it->m_Green, it->m_Blue, it->m_Alpha);
m_pRenderSystem->DrawText(0, count++ * 10, "%s", it->m_Text.c_str());
}
if(m_LineNum > m_Height)
@ -151,22 +164,22 @@ void LogConsole::Print()
void LogConsole::AddWrapedText(const char* str)
{
m_Log.push_back(::std::string(str));
m_Log.push_back(LogText(::std::string(str), m_ColorRed, m_ColorGreen, m_ColorBlue, m_ColorAlpha));
}
void LogConsole::DrawScrollBar()
{
m_RenderSystem->SetColor(0.4f, 0.4f, 0.4f);
m_RenderSystem->DrawLine((m_Width + 1) * FONT_WIDTH, 0, (m_Width + 2) * FONT_WIDTH - 1, 0);
m_RenderSystem->DrawLine((m_Width + 1)* FONT_WIDTH, 0, (m_Width + 1)* FONT_WIDTH, m_Height * FONT_HEIGHT);
m_RenderSystem->DrawLine((m_Width + 2) * FONT_WIDTH - 1, 0, (m_Width + 2) * FONT_WIDTH - 1, m_Height * FONT_HEIGHT);
m_RenderSystem->DrawLine((m_Width + 1)* FONT_WIDTH, m_Height * FONT_HEIGHT - 1, (m_Width + 2) * FONT_WIDTH - 1, m_Height * FONT_HEIGHT - 1);
m_pRenderSystem->SetColor(0.4f, 0.4f, 0.4f);
m_pRenderSystem->DrawLine((m_Width + 1) * FONT_WIDTH, 0, (m_Width + 2) * FONT_WIDTH - 1, 0);
m_pRenderSystem->DrawLine((m_Width + 1)* FONT_WIDTH, 0, (m_Width + 1)* FONT_WIDTH, m_Height * FONT_HEIGHT);
m_pRenderSystem->DrawLine((m_Width + 2) * FONT_WIDTH - 1, 0, (m_Width + 2) * FONT_WIDTH - 1, m_Height * FONT_HEIGHT);
m_pRenderSystem->DrawLine((m_Width + 1)* FONT_WIDTH, m_Height * FONT_HEIGHT - 1, (m_Width + 2) * FONT_WIDTH - 1, m_Height * FONT_HEIGHT - 1);
u32 y = (m_Height * FONT_HEIGHT - 2) * m_CurrentViewLine / m_MaxLine;
m_RenderSystem->SetColor(0.7f, 0.7f, 0.7f);
m_RenderSystem->FillRectangle((m_Width + 1) * FONT_WIDTH, y + 1, FONT_WIDTH - 1, FONT_HEIGHT - 4);
m_pRenderSystem->SetColor(0.7f, 0.7f, 0.7f);
m_pRenderSystem->FillRectangle((m_Width + 1) * FONT_WIDTH, y + 1, FONT_WIDTH - 1, FONT_HEIGHT - 4);
m_RenderSystem->SetColor(1.f, 1.f, 1.f);
m_pRenderSystem->SetColor(1.f, 1.f, 1.f);
}
} //namespace ConsoleBackup

View File

@ -24,6 +24,21 @@
namespace common
{
struct LogText
{
LogText(std::string text, f32 red, f32 green, f32 blue, f32 alpha) :
m_Text(text), m_Red(red), m_Green(green), m_Blue(blue), m_Alpha(alpha)
{
}
std::string m_Text;
f32 m_Red;
f32 m_Green;
f32 m_Blue;
f32 m_Alpha;
};
//! @brief 画面にテキストコンソールを描画します
class LogConsole
{
@ -37,6 +52,9 @@ public:
// コンソールに描画する文字列を追加する
void AddText(const char* fmt, ::std::va_list arg);
// コンソールに描画する文字を変更する
void SetTextColor(f32 red, f32 green, f32 blue, f32 alpha);
// 上スクロールする
void ScrollUp();
@ -56,7 +74,7 @@ private:
void AddWrapedText(const char* str);
void DrawScrollBar();
::std::vector<std::string> m_Log;
::std::vector<LogText> m_Log;
//! @brief コンソールの列数
u32 m_Width;
@ -65,12 +83,16 @@ private:
//! @brief コンソールのログの最大行数
u32 m_MaxLine;
//! @brief 描画のためのRenderSystemDrawingへのポインタ
demo::RenderSystemDrawing* m_RenderSystem;
demo::RenderSystemDrawing* m_pRenderSystem;
//! @brief 追加したログの行数
u32 m_LineNum;
//! @brief 表示を開始するログの行数
u32 m_CurrentViewLine;
//! @描画フォントの色
f32 m_ColorRed;
f32 m_ColorGreen;
f32 m_ColorBlue;
f32 m_ColorAlpha;
};