mirror of
https://github.com/zeldaret/botw
synced 2026-08-17 21:13:01 -04:00
ksys: Start adding PlayReport
This commit is contained in:
@@ -7,6 +7,10 @@ target_sources(uking PRIVATE
|
||||
OverlayArenaSystem.h
|
||||
OverlayArenaSystemS1.h
|
||||
OverlayArenaSystemS2.h
|
||||
PlayReportMgr.cpp
|
||||
PlayReportMgr.h
|
||||
ProductReporter.cpp
|
||||
ProductReporter.h
|
||||
StringBoard.h
|
||||
SystemPauseMgr.cpp
|
||||
SystemPauseMgr.h
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
#include "KingSystem/System/PlayReportMgr.h"
|
||||
#include <nn/account.h>
|
||||
#include <nn/prepo.h>
|
||||
#include "KingSystem/System/Account.h"
|
||||
#include "KingSystem/System/ProductReporter.h"
|
||||
|
||||
namespace ksys {
|
||||
|
||||
SEAD_SINGLETON_DISPOSER_IMPL(PlayReportMgr)
|
||||
|
||||
PlayReportMgr::~PlayReportMgr() {
|
||||
if (mReporter)
|
||||
delete mReporter;
|
||||
}
|
||||
|
||||
bool PlayReport::setEventId(sead::BufferedSafeString& event_id) {
|
||||
if (!mHasNinPrepoReport)
|
||||
return false;
|
||||
|
||||
event_id.replaceCharList("ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz");
|
||||
return mNinPlayReport->SetEventId(event_id.cstr()).IsSuccess();
|
||||
}
|
||||
|
||||
bool PlayReport::add(const sead::SafeString& key, u32 value) {
|
||||
return mHasNinPrepoReport && mNinPlayReport->Add(key.cstr(), s64(value)).IsSuccess();
|
||||
}
|
||||
|
||||
bool PlayReport::add(const sead::SafeString& key, s32 value) {
|
||||
return mHasNinPrepoReport && mNinPlayReport->Add(key.cstr(), s64(value)).IsSuccess();
|
||||
}
|
||||
|
||||
bool PlayReport::add(const sead::SafeString& key, f32 value) {
|
||||
return mHasNinPrepoReport && mNinPlayReport->Add(key.cstr(), value).IsSuccess();
|
||||
}
|
||||
|
||||
bool PlayReport::add(const sead::SafeString& key, const sead::SafeString& value) {
|
||||
return mHasNinPrepoReport && mNinPlayReport->Add(key.cstr(), value.cstr()).IsSuccess();
|
||||
}
|
||||
|
||||
bool PlayReport::save() {
|
||||
if (!mHasNinPrepoReport)
|
||||
return false;
|
||||
|
||||
nn::account::Uid uid;
|
||||
Account::instance()->getUserId(&uid);
|
||||
if (uid.IsValid()) {
|
||||
static_cast<void>(mNinPlayReport->GetCount());
|
||||
return mNinPlayReport->Save(uid).IsSuccess();
|
||||
}
|
||||
static_cast<void>(ProductReporter::getSomeBool());
|
||||
static_cast<void>(mNinPlayReport->GetCount());
|
||||
return mNinPlayReport->Save().IsSuccess();
|
||||
}
|
||||
|
||||
void PlayReport::init(s32 num_entries, sead::Heap* heap) {
|
||||
if (mHasNinPrepoReport)
|
||||
return;
|
||||
|
||||
auto* report = new (heap) nn::prepo::PlayReport;
|
||||
const u32 buffer_size = nn::prepo::PlayReport::CalcBufferSize(num_entries);
|
||||
mNinPlayReport = report;
|
||||
if (buffer_size > 0 && mBuffer.tryAllocBuffer(buffer_size, heap)) {
|
||||
mNinPlayReport->SetBuffer(mBuffer.getBufferPtr(), buffer_size);
|
||||
mHasNinPrepoReport = true;
|
||||
}
|
||||
}
|
||||
|
||||
PlayReport::~PlayReport() {
|
||||
if (!mHasNinPrepoReport)
|
||||
return;
|
||||
|
||||
if (mNinPlayReport) {
|
||||
delete mNinPlayReport;
|
||||
mNinPlayReport = nullptr;
|
||||
}
|
||||
|
||||
if (mHasNinPrepoReport)
|
||||
mBuffer.freeBuffer();
|
||||
|
||||
mHasNinPrepoReport = false;
|
||||
}
|
||||
|
||||
} // namespace ksys
|
||||
@@ -0,0 +1,68 @@
|
||||
#pragma once
|
||||
|
||||
#include <container/seadBuffer.h>
|
||||
#include <heap/seadDisposer.h>
|
||||
#include <prim/seadSafeString.h>
|
||||
#include "KingSystem/Utils/Types.h"
|
||||
|
||||
namespace nn::prepo {
|
||||
class PlayReport;
|
||||
}
|
||||
|
||||
namespace ksys {
|
||||
|
||||
namespace act {
|
||||
class PlayerLink;
|
||||
}
|
||||
|
||||
class ProductReporter;
|
||||
|
||||
class PlayReportMgr {
|
||||
SEAD_SINGLETON_DISPOSER(PlayReportMgr)
|
||||
virtual ~PlayReportMgr();
|
||||
|
||||
public:
|
||||
void init(sead::Heap* heap);
|
||||
|
||||
void calc();
|
||||
|
||||
ProductReporter* getReporter() const { return mReporter; }
|
||||
|
||||
bool get30() const { return _30; }
|
||||
void set30(bool arg_30) { _30 = arg_30; }
|
||||
|
||||
private:
|
||||
ProductReporter* mReporter = nullptr;
|
||||
bool _30 = false;
|
||||
act::PlayerLink* mPlayerLink = nullptr;
|
||||
};
|
||||
KSYS_CHECK_SIZE_NX150(PlayReportMgr, 0x40);
|
||||
|
||||
class PlayReport {
|
||||
public:
|
||||
PlayReport(const sead::SafeString& event_id, s32 num_entries, sead::Heap* heap) {
|
||||
init(num_entries, heap);
|
||||
sead::FixedSafeString<32> event_id_;
|
||||
event_id_.cutOffCopy(event_id);
|
||||
setEventId(event_id_);
|
||||
}
|
||||
|
||||
~PlayReport();
|
||||
|
||||
bool setEventId(sead::BufferedSafeString& event_id);
|
||||
bool add(const sead::SafeString& key, u32 value);
|
||||
bool add(const sead::SafeString& key, s32 value);
|
||||
bool add(const sead::SafeString& key, f32 value);
|
||||
bool add(const sead::SafeString& key, const sead::SafeString& value);
|
||||
bool save();
|
||||
|
||||
private:
|
||||
void init(s32 num_entries, sead::Heap* heap);
|
||||
|
||||
bool mHasNinPrepoReport = false;
|
||||
nn::prepo::PlayReport* mNinPlayReport = nullptr;
|
||||
sead::Buffer<u8> mBuffer;
|
||||
};
|
||||
KSYS_CHECK_SIZE_NX150(PlayReport, 0x20);
|
||||
|
||||
} // namespace ksys
|
||||
@@ -0,0 +1 @@
|
||||
#include "KingSystem/System/ProductReporter.h"
|
||||
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
namespace ksys {
|
||||
|
||||
// FIXME: incomplete; requires GameData
|
||||
class ProductReporter {
|
||||
public:
|
||||
ProductReporter() = default;
|
||||
virtual ~ProductReporter();
|
||||
|
||||
static bool getSomeBool();
|
||||
};
|
||||
|
||||
} // namespace ksys
|
||||
Reference in New Issue
Block a user