ctr_Repair/branches/1stNUP_for_2ndNUP/sources/common/DrawSystemState.cpp
N2614 bfcd9f164d リビジョン 731-742 を trunk/ConsoleDataMigration からマージ:
CTR、SPRより後のモデルではXボタンで無線ON/OFFを切り替えられるように。ビルドにはnwm_ExtAPI.cppを差し替える必要がある
........
バージョンを更新
........
Xボタンによる無線トグル機能を削除
........
リンクエラーを修正
........
Backup起動時に無線OFF、Restore起動時に無線ON、Restoreの終了ステートで無線OFFするように
........
trunkからコピーしたpl_SharedDataTitleId.hを追加
ビルド時の注意を更新
........
リビジョン 716 を trunk/ConsoleDataMigration からマージ:
コメント追加。aes鍵設定の警告メッセージを削除
........

........
nwmのパッチを追加
........
ビルド環境を更新
........
リリースしないのでConsoleRestoreをビルド対象から外す
........
ビルド環境を更新
........
無線トグル機能の削除忘れ
........


git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@743 385bec56-5757-e545-9c3a-d8741f4650f1
2013-05-27 04:22:50 +00:00

226 lines
7.2 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 <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_SerialNo[nn::cfg::CTR::CFG_SECURE_INFO_SERIAL_NO_LEN + 1];
bit64 s_DeviceId;
char8 s_MacAddress[nn::nwm::Mac::MAC_STRING_SIZE];
u64 s_FriendCode;
u8 s_BatteryRemain;
std::string s_AdapterState;
u8 s_Progress;
::std::vector<std::string>* s_OperationMessage;
bool s_ReadFriendCode;
bool s_IsWifiOn;
}
u32 GetRenderTarget(u32 target, bool flip)
{
if(flip)
{
if(target == NN_GX_DISPLAY0)
{
return NN_GX_DISPLAY1;
}
else
{
return NN_GX_DISPLAY0;
}
}
else
{
return target;
}
}
void SetTextWriterCore()
{
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("Serial No. %s\n", s_SerialNo);
GetTextWriter()->Printf("Device ID %llu\n", s_DeviceId);
GetTextWriter()->Printf("MAC Address %s\n", s_MacAddress);
if (s_ReadFriendCode)
{
GetTextWriter()->Printf("Friend Code %04u-%04u-%04u\n",
static_cast<u32>(s_FriendCode / 100000000ULL % 10000ULL), static_cast<u32> (s_FriendCode / 10000ULL % 10000ULL),
static_cast<u32> (s_FriendCode % 10000ULL));
}
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");
::std::vector<std::string>::iterator it;
for (it = s_OperationMessage->begin(); it != s_OperationMessage->end(); it++)
{
GetTextWriter()->Printf("%s\n", it->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,
u64 deviceId,
u64 friendCode,
u32 progress,
bool isProcessFailed,
bool isProcessSucceeded,
bool isProcessWarning,
char8* macAddress,
::std::vector<std::string>& operationMessage,
nn::cfg::CTR::CfgRegionCode region,
u8* serialNo,
bool readFriendCode,
bool isWifiOn
)
{
// パラメータ保存
s_AdapterState = adapterState;
s_CupMajor = cupMajorVersion;
s_CupMinor = cupMinorVersion;
s_CupMicro = cupMicroVersion;
s_NupMajor = nupVersion;
s_BatteryRemain = batteryRemain;
s_DeviceId = deviceId;
s_FriendCode = friendCode;
s_Progress = progress;
std::memcpy(s_MacAddress, macAddress, sizeof(s_MacAddress));
s_Region = region;
std::memcpy(s_SerialNo, serialNo, sizeof(s_SerialNo));
s_SerialNo[nn::cfg::CTR::CFG_SECURE_INFO_SERIAL_NO_LEN] = '\0';
s_OperationMessage = &operationMessage;
s_ReadFriendCode = readFriendCode;
s_IsWifiOn = isWifiOn;
// デフォルトで上画面に描画するもの
renderSystem.SetRenderTarget(GetRenderTarget(NN_GX_DISPLAY0, flip));
if (isProcessSucceeded)
{
renderSystem.SetClearColor(GetRenderTarget(NN_GX_DISPLAY0, flip), SUCCESS_COLOR);
}
else if (isProcessWarning)
{
renderSystem.SetClearColor(GetRenderTarget(NN_GX_DISPLAY0, flip), WARN_COLOR);
}
else if (isProcessFailed)
{
renderSystem.SetClearColor(GetRenderTarget(NN_GX_DISPLAY0, flip), FAIL_COLOR);
}
else
{
renderSystem.SetClearColor(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(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;
if(readFriendCode)
{
line += 9;
}
else
{
line += 8;
}
const u8 offset = 19;
const u8 diff = 4;
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, "");
}
}