Skip to content

Commit

Permalink
rename namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
Pistonight committed Aug 11, 2024
1 parent 7190318 commit 6bbdf2a
Show file tree
Hide file tree
Showing 39 changed files with 299 additions and 364 deletions.
21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

2 changes: 1 addition & 1 deletion libs/botw-symbols
2 changes: 1 addition & 1 deletion link.ld
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ ksys_ui_showInfoOverlayWithString = 0x1238680 - 0x3483000;
ScreenMessageTipsRuntime_doShowMessageTip = 0x0119C750 - 0x3483000;
ksys_ui_screen_mgr_instance = 0x2CC2490 - 0x3483000;
/* botw_get_message_string = 0x123DEA0 - 0x3483000; */
ksys_ui_runtime_tips = 0x02CBA3B0 - 0x3483000;
ksys_ui_sRuntimeTips = 0x02CBA3B0 - 0x3483000;
28 changes: 13 additions & 15 deletions src/controller.cpp → src/core/controller.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Winvalid-offsetof"
#include <controller/seadController.h>
#include <controller/seadControllerMgr.h>
#pragma GCC diagnostic pop

#include "core/controller.hpp"
#include "util/message.hpp"
#include "named.h"
#include "./controller.hpp"
#include "util/named.h"

namespace botwsavs {
namespace botw::savs {

bool Controller::initialize() {
if (m_controller) {
Expand All @@ -27,14 +25,14 @@ bool Controller::initialize() {
return true;
}

void Controller::save_key_bindings(util::DataWriter& w) const {
void Controller::save_key_bindings(DataWriter& w) const {
w.write_integer(_named(m_key_save));
w.write_integer(_named(m_key_save_file));
w.write_integer(_named(m_key_restore));
w.write_integer(_named(m_key_restore_file));
}

void Controller::load_key_bindings(util::DataReader& r) {
void Controller::load_key_bindings(DataReader& r) {
u32 key_save = 0;
u32 key_save_file = 0;
u32 key_restore = 0;
Expand Down Expand Up @@ -79,9 +77,9 @@ bool Controller::has_held_keys_for(Key keys, u32 seconds) {

void Controller::start_configure_key(Key* key) {
clear_hold();
util::StringBuffer<30> key_name;
StringBuffer<30> key_name;
get_key_name(key_name, key);
util::msg::show_customf("Hold new %s key for 3 seconds", key_name.content());
msg::show_customf("Hold new %s key for 3 seconds", key_name.content());
m_key_being_configured = key;
m_configure_hold_counter = 0;
}
Expand Down Expand Up @@ -140,19 +138,19 @@ Command Controller::update_setting_mode() {
Key new_key = get_hold_keys();
switch (finish_configure_key(new_key)) {
case Controller::ConfigureResult::Success: {
util::StringBuffer<30> key_name;
StringBuffer<30> key_name;
get_key_name(key_name, m_key_being_configured);
util::StringBuffer<120> buffer;
StringBuffer<120> buffer;
get_key_string(new_key, buffer);
util::StringBuffer<200> msg;
StringBuffer<200> msg;
msg.appendf("%s key is now set to ", key_name.content());
msg.append(buffer.content());
util::msg::show_custom(msg.content());
msg::show_custom(msg.content());
m_key_being_configured = nullptr;
return Command::SaveOption;
}
case Controller::ConfigureResult::FailEmpty:
util::msg::show_custom("Key binding cannot be updated to none!");
msg::show_custom("Key binding cannot be updated to none!");
return Command::None;
default:
return Command::None;
Expand Down
10 changes: 5 additions & 5 deletions src/controller.hpp → src/core/controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace sead {
struct Controller;
}

namespace botwsavs {
namespace botw::savs {
enum Key : u32 {
None = 0,
A = 1,
Expand Down Expand Up @@ -39,7 +39,7 @@ constexpr Key KEY_INCREASE_LEVEL = static_cast<Key>(Key::R);
constexpr Key KEY_DECREASE_LEVEL = static_cast<Key>(L);

template <u32 L>
void get_key_string(u32 keys, util::StringBuffer<L>& out_buffer) {
void get_key_string(u32 keys, StringBuffer<L>& out_buffer) {
static_assert(L >= 100, "Key string buffer length should be at least 100");
out_buffer.clear();
if (keys == 0) {
Expand Down Expand Up @@ -122,8 +122,8 @@ class Controller {
bool initialize();
Command update();

void save_key_bindings(util::DataWriter& writer) const;
void load_key_bindings(util::DataReader& reader);
void save_key_bindings(DataWriter& writer) const;
void load_key_bindings(DataReader& reader);

Mode get_mode() const { return m_mode; }
private:
Expand All @@ -149,7 +149,7 @@ class Controller {
bool is_configuring_key() const { return m_key_being_configured != nullptr; }
void start_configure_key(Key* key);
ConfigureResult finish_configure_key(Key new_key);
void get_key_name(util::StringBuffer<30>& out_buffer, Key* key) const {
void get_key_name(StringBuffer<30>& out_buffer, Key* key) const {
out_buffer.clear();
if (key == &m_key_save) {
out_buffer.append("SaveToMem");
Expand Down
15 changes: 7 additions & 8 deletions src/state/lv_1.cpp → src/core/lv_1.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
#include <KingSystem/ActorSystem/actBaseProcMgr.h>
#include <KingSystem/ActorSystem/actBaseProc.h>

#include "raw_ptr.hpp"
#include "named.h"
#include "core/lv_1.hpp"
#include "core/reporter.hpp"
#include "impl/raw_ptr.hpp"
#include "util/named.h"
#include "util/data_reader.hpp"
#include "util/data_writer.hpp"

#include "./lv_1.hpp"
#include "./reporter.hpp"

namespace botwsavs::state {
namespace botw::savs {

void Lv1::read_from_game(Reporter& r) {
r.report("Health", raw_ptr::health().get(&m_health));
Expand Down Expand Up @@ -55,7 +54,7 @@ void Lv1::write_to_game(Reporter& r, bool hold) const {
// TODO: fall damage cancel
}

void Lv1::read_from_file(util::DataReader& r, Version version) {
void Lv1::read_from_file(DataReader& r, Version version) {
if (version < Version::v1) {
return;
}
Expand All @@ -68,7 +67,7 @@ void Lv1::read_from_file(util::DataReader& r, Version version) {
r.read_float(&m_camera_tilt);
}

void Lv1::write_to_file(util::DataWriter& w) const {
void Lv1::write_to_file(DataWriter& w) const {
w.write_integer(_named(m_health));
w.write_float(_named(m_stamina));
w.write_float_array(_named(m_havok_position), 3);
Expand Down
14 changes: 5 additions & 9 deletions src/state/lv_1.hpp → src/core/lv_1.hpp
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
#pragma once

#include <exl/types.h>
#include "./version.hpp"
#include "core/version.hpp"

namespace botw::savs {

namespace botwsavs::util {
class DataReader;
class DataWriter;
}


namespace botwsavs::state {

class Reporter;

class Lv1 {
public:
void read_from_game(Reporter& reporter);
void write_to_game(Reporter& reporter, bool hold) const;
void read_from_file(util::DataReader& reader, Version version);
void write_to_file(util::DataWriter& writer) const;
void read_from_file(DataReader& reader, Version version);
void write_to_file(DataWriter& writer) const;

private:
u32 m_health;
Expand Down
39 changes: 19 additions & 20 deletions src/state/lv_2.cpp → src/core/lv_2.cpp
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
#include <KingSystem/ActorSystem/actBaseProcMgr.h>
#include <KingSystem/ActorSystem/actBaseProc.h>
#include <Game/UI/uiPauseMenuDataMgr.h>

#include "raw_ptr.hpp"
#include "named.h"

#include "state/lv_2.hpp"
#include "state/reporter.hpp"
#include "impl/raw_ptr.hpp"
#include "impl/uiPauseMenuDataMgr.h"
#include "core/lv_2.hpp"
#include "core/reporter.hpp"
#include "util/data_reader.hpp"
#include "util/data_writer.hpp"
#include "util/named.h"

namespace botwsavs::state {
namespace botw::savs {

void read_inventory_equipment_durability(
const char* name,
const uking::ui::PouchItem* item,
util::NamedValue<u32, 64>& value,
NamedValue<u32, 64>& value,
Reporter& r
) {
if (util::ptr_looks_safe(item)) {
if (ptr_looks_safe(item)) {
value.set(item->getName(), item->getValue());
} else {
value.clear_name();
Expand All @@ -29,10 +28,10 @@ void read_inventory_equipment_durability(
void write_inventory_equipment_durability(
const char* name,
uking::ui::PouchItem* item,
const util::NamedValue<u32, 64>& value,
const NamedValue<u32, 64>& value,
Reporter& r
) {
if (util::ptr_looks_safe(item)) {
if (ptr_looks_safe(item)) {
if (value.name_matches(item->getName())) {
item->setValue(value.value());
}
Expand All @@ -43,9 +42,9 @@ void write_inventory_equipment_durability(

void read_overworld_equipment_durability(
const char* name,
const util::safe_ptr<ksys::act::BaseProc>& actor,
const util::safe_ptr<u32>& durability,
util::NamedValue<u32, 64>& value,
const safe_ptr<ksys::act::BaseProc>& actor,
const safe_ptr<u32>& durability,
NamedValue<u32, 64>& value,
Reporter& r
) {
ksys::act::BaseProc* safe_actor = nullptr;
Expand All @@ -65,9 +64,9 @@ void read_overworld_equipment_durability(

void write_overworld_equipment_durability(
const char* name,
const util::safe_ptr<ksys::act::BaseProc>& actor,
const util::safe_ptr<u32>& durability,
const util::NamedValue<u32, 64>& value,
const safe_ptr<ksys::act::BaseProc>& actor,
const safe_ptr<u32>& durability,
const NamedValue<u32, 64>& value,
Reporter& r
) {
ksys::act::BaseProc* safe_actor = nullptr;
Expand All @@ -92,7 +91,7 @@ void Lv2::read_from_game(Reporter& r) {
pmdm->updateEquippedItemArray();

// save arrow, weapon, bow, shield
auto* arrow = pmdm->getEquippedWeapon(uking::ui::PouchItemType::Arrow);
auto* arrow = pmdm->mEquippedWeapons[int(uking::ui::PouchItemType::Arrow)];
read_inventory_equipment_durability(
"ArrowCnt",
arrow,
Expand Down Expand Up @@ -204,7 +203,7 @@ void Lv2::write_to_game(Reporter& r, bool hold) const {
);
}

void Lv2::read_from_file(util::DataReader& r, Version version) {
void Lv2::read_from_file(DataReader& r, Version version) {
if (version < Version::v2) {
return;
}
Expand All @@ -218,7 +217,7 @@ void Lv2::read_from_file(util::DataReader& r, Version version) {
r.read_named_integer(m_overworld_equipped_shield_durability);
}

void Lv2::write_to_file(util::DataWriter& w) const {
void Lv2::write_to_file(DataWriter& w) const {
w.write_named_integer(_named(m_menu_equipped_arrow_count));
w.write_named_integer(_named(m_menu_equipped_weapon_durability));
w.write_named_integer(_named(m_menu_equipped_bow_durability));
Expand Down
30 changes: 30 additions & 0 deletions src/core/lv_2.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#pragma once

#include <exl/types.h>
#include "core/version.hpp"
#include "util/named_value.hpp"

namespace botw::savs {

class DataReader;
class DataWriter;
class Reporter;

class Lv2 {
public:
void read_from_game(Reporter& reporter);
void write_to_game(Reporter& reporter, bool hold) const;
void read_from_file(DataReader& reader, Version version);
void write_to_file(DataWriter& writer) const;

private:
NamedValue<u32, 64> m_menu_equipped_arrow_count{0};
NamedValue<u32, 64> m_menu_equipped_weapon_durability{0};
NamedValue<u32, 64> m_menu_equipped_bow_durability{0};
NamedValue<u32, 64> m_menu_equipped_shield_durability{0};
NamedValue<u32, 64> m_overworld_equipped_weapon_durability{0};
NamedValue<u32, 64> m_overworld_equipped_bow_durability{0};
NamedValue<u32, 64> m_overworld_equipped_shield_durability{0};
};

} // namespace botwsavs::core
4 changes: 2 additions & 2 deletions src/state/reporter.cpp → src/core/reporter.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "./reporter.hpp"
#include "core/reporter.hpp"

namespace botwsavs::state {
namespace botw::savs {

void Reporter::report(const char* field, bool success) {
if (success) {
Expand Down
8 changes: 4 additions & 4 deletions src/state/reporter.hpp → src/core/reporter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <exl/types.h>
#include <util/string.hpp>

namespace botwsavs::state {
namespace botw::savs {

class Reporter {
public:
Expand All @@ -14,7 +14,7 @@ class Reporter {
bool has_error() const { return m_error_count > 0; }

template<u32 L>
void get_fields_string(util::StringBuffer<L>& out) const {
void get_fields_string(StringBuffer<L>& out) const {
out.clear();
switch (m_error_count) {
case 0:
Expand All @@ -36,8 +36,8 @@ class Reporter {
}
private:
u32 m_error_count;
util::StringBuffer<64> m_first_field;
util::StringBuffer<64> m_second_field;
StringBuffer<64> m_first_field;
StringBuffer<64> m_second_field;


};
Expand Down
Loading

0 comments on commit 6bbdf2a

Please sign in to comment.