mirror of
https://github.com/rvtr/ctr_Repair.git
synced 2025-10-31 13:51:08 -04:00
git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@792 385bec56-5757-e545-9c3a-d8741f4650f1
176 lines
5.8 KiB
C++
176 lines
5.8 KiB
C++
/*---------------------------------------------------------------------------*
|
|
Project: Horizon
|
|
File: DrawSystemState.cpp
|
|
|
|
Copyright 2009 Nintendo. All rights reserved.
|
|
|
|
These coded instructions, statements, and computer programs contain
|
|
proprietary information of Nintendo of America Inc. and/or Nintendo
|
|
Company Ltd., and are protected by Federal copyright law. They may
|
|
not be disclosed to third parties or copied or duplicated in any form,
|
|
in whole or in part, without the prior written consent of Nintendo.
|
|
|
|
$Rev$
|
|
*---------------------------------------------------------------------------*/
|
|
|
|
#include "DrawSystemState.h"
|
|
#include "ResFont.h"
|
|
#include "version.h"
|
|
#include "Util.h"
|
|
|
|
#include <nn/nwm.h>
|
|
|
|
const u16 PROGRESS_MAX_LINES = 129;
|
|
|
|
namespace common
|
|
{
|
|
|
|
namespace
|
|
{
|
|
u8 s_CupMajor;
|
|
u8 s_CupMinor;
|
|
u8 s_CupMicro;
|
|
u8 s_NupMajor;
|
|
nn::cfg::CTR::CfgRegionCode s_Region;
|
|
u8 s_BatteryRemain;
|
|
std::string s_AdapterState;
|
|
u8 s_Progress;
|
|
OperationMessage* s_OperationMessage;
|
|
bool s_IsWifiOn;
|
|
|
|
}
|
|
|
|
void SetTextWriterCore()
|
|
{
|
|
GetTextWriter()->SetTextColor(nn::util::Color8(255, 255, 255, 255));
|
|
GetTextWriter()->Print("\n");
|
|
|
|
f32 cursorX = GetTextWriter()->GetCursorX();
|
|
f32 cursorY = GetTextWriter()->GetCursorY();
|
|
GetTextWriter()->Printf("System Ver. %d.%d.%d-%d\n", s_CupMajor, s_CupMinor, s_CupMicro, s_NupMajor);
|
|
GetTextWriter()->SetCursorX(cursorX);
|
|
GetTextWriter()->SetCursorY(cursorY);
|
|
if(s_IsWifiOn)
|
|
{
|
|
GetTextWriter()->Printf(" WiFi ON\n");
|
|
}
|
|
else
|
|
{
|
|
GetTextWriter()->SetTextColor(nn::util::Color8(80, 80, 80, 255));
|
|
GetTextWriter()->Printf(" WiFi OFF\n");
|
|
GetTextWriter()->SetTextColor(nn::util::Color8(255, 255, 255, 255));
|
|
}
|
|
GetTextWriter()->Printf("System Region %s\n", nn::cfg::CTR::GetRegionCodeA3(s_Region));
|
|
GetTextWriter()->Printf("Battery %d%%\n", s_BatteryRemain);
|
|
GetTextWriter()->Printf("AC Adapter %s\n", s_AdapterState.c_str());
|
|
GetTextWriter()->Printf("Progress %02d%%\n", s_Progress);
|
|
GetTextWriter()->Print("\n");
|
|
|
|
for (u32 i = 0; i < s_OperationMessage->GetSize(); i++)
|
|
{
|
|
GetTextWriter()->SetTextColor(s_OperationMessage->At(i).color);
|
|
GetTextWriter()->Printf("%s\n", s_OperationMessage->At(i).str.c_str());
|
|
}
|
|
|
|
|
|
}
|
|
|
|
void DrawSystemState
|
|
(
|
|
const char* toolName,
|
|
demo::RenderSystemDrawing& renderSystem,
|
|
nn::util::FloatColor titleColor,
|
|
bool flip,
|
|
std::string& adapterState,
|
|
u8 cupMajorVersion,
|
|
u8 cupMinorVersion,
|
|
u8 cupMicroVersion,
|
|
u8 nupVersion,
|
|
u8 batteryRemain,
|
|
u32 progress,
|
|
bool isProcessFailed,
|
|
bool isProcessSucceeded,
|
|
bool isProcessWarning,
|
|
OperationMessage& operationMessage,
|
|
nn::cfg::CTR::CfgRegionCode region,
|
|
bool isWifiOn
|
|
|
|
)
|
|
{
|
|
// パラメータ保存
|
|
s_AdapterState = adapterState;
|
|
s_CupMajor = cupMajorVersion;
|
|
s_CupMinor = cupMinorVersion;
|
|
s_CupMicro = cupMicroVersion;
|
|
s_NupMajor = nupVersion;
|
|
s_BatteryRemain = batteryRemain;
|
|
s_Progress = progress;
|
|
s_Region = region;
|
|
s_OperationMessage = &operationMessage;
|
|
s_IsWifiOn = isWifiOn;
|
|
|
|
|
|
// デフォルトで上画面に描画するもの
|
|
renderSystem.SetRenderTarget(Util::GetRenderTarget(NN_GX_DISPLAY0, flip));
|
|
if (isProcessSucceeded)
|
|
{
|
|
renderSystem.SetClearColor(Util::GetRenderTarget(NN_GX_DISPLAY0, flip), SUCCESS_COLOR);
|
|
}
|
|
else if (isProcessWarning)
|
|
{
|
|
renderSystem.SetClearColor(Util::GetRenderTarget(NN_GX_DISPLAY0, flip), WARN_COLOR);
|
|
}
|
|
else if (isProcessFailed)
|
|
{
|
|
renderSystem.SetClearColor(Util::GetRenderTarget(NN_GX_DISPLAY0, flip), FAIL_COLOR);
|
|
}
|
|
else
|
|
{
|
|
renderSystem.SetClearColor(Util::GetRenderTarget(NN_GX_DISPLAY0, flip), NORMAL_COLOR);
|
|
}
|
|
|
|
|
|
renderSystem.Clear();
|
|
renderSystem.SetColor(1.f, 1.f, 1.f);
|
|
u32 line = 0;
|
|
|
|
size_t fontwidth = 8;
|
|
size_t fontheight = fontwidth + 2;
|
|
|
|
SetDrawTextHandler(SetTextWriterCore);
|
|
DrawResFont(Util::GetRenderTarget(NN_GX_DISPLAY0, flip));
|
|
|
|
renderSystem.SetFontSize(fontwidth);
|
|
|
|
// ツール名、ハイライト
|
|
renderSystem.DrawText(0, line++ * fontheight, "%s %s-%s-%s", toolName, CONSOLE_REPAIR_VERSION_MAJOR,
|
|
CONSOLE_REPAIR_VERSION_MINOR, CONSOLE_REPAIR_VERSION_MICRO);
|
|
renderSystem.SetColor(titleColor.r, titleColor.g, titleColor.b);
|
|
renderSystem.FillRectangle(0, (line - 1) * fontheight, 400, fontheight);
|
|
renderSystem.SetColor(1.f, 1.f, 1.f);
|
|
renderSystem.DrawText(0, line++ * fontheight, "");
|
|
|
|
// プログレスバー
|
|
fontwidth = 8;
|
|
fontheight = 14;
|
|
line += 5;
|
|
|
|
const u8 offset = 19;
|
|
const u8 diff = 8;
|
|
renderSystem.SetColor(0.f, 0.2f, 0.f);
|
|
renderSystem.DrawLine(offset * fontwidth, (line - 1) * fontheight - diff, offset * fontwidth + PROGRESS_MAX_LINES, (line - 1)
|
|
* fontheight - diff);
|
|
renderSystem.DrawLine(offset * fontwidth, (line - 1) * fontheight - diff, offset * fontwidth, (line) * fontheight - diff);
|
|
renderSystem.DrawLine(offset * fontwidth, (line) * fontheight - diff, offset * fontwidth + PROGRESS_MAX_LINES, (line) * fontheight - diff);
|
|
renderSystem.DrawLine(offset * fontwidth + PROGRESS_MAX_LINES, (line - 1) * fontheight - diff, offset * fontwidth
|
|
+ PROGRESS_MAX_LINES, (line) * fontheight + 1 - diff);
|
|
renderSystem.SetColor(0.f, 0.5f, 0.f);
|
|
renderSystem.FillRectangle(offset * fontwidth, (line - 1) * fontheight - diff, progress * PROGRESS_MAX_LINES / 100 + 1,
|
|
fontheight);
|
|
|
|
renderSystem.SetColor(1.f, 1.f, 1.f);
|
|
renderSystem.DrawText(0, line++ * fontheight, "");
|
|
}
|
|
|
|
}
|