mirror of
https://github.com/open-goal/jak-project.git
synced 2024-11-26 16:00:52 +00:00
game: move pc-encode-utf8-string
to common kmachine
code (#3742)
Some checks are pending
Build / 🖥️ Windows (push) Waiting to run
Build / 🐧 Linux (push) Waiting to run
Build / 🍎 MacOS (push) Waiting to run
Inform Pages Repo / Generate Documentation (push) Waiting to run
Lint / 📝 Formatting (push) Waiting to run
Lint / 📝 Required Checks (push) Waiting to run
Lint / 📝 Optional Checks (push) Waiting to run
Some checks are pending
Build / 🖥️ Windows (push) Waiting to run
Build / 🐧 Linux (push) Waiting to run
Build / 🍎 MacOS (push) Waiting to run
Inform Pages Repo / Generate Documentation (push) Waiting to run
Lint / 📝 Formatting (push) Waiting to run
Lint / 📝 Required Checks (push) Waiting to run
Lint / 📝 Optional Checks (push) Waiting to run
Also adds formatter rules for a couple of macros.
This commit is contained in:
parent
ba9085fee0
commit
10d7dabfd7
@ -168,6 +168,39 @@ static FormFormattingConfig new_deftype_rule(
|
||||
return cfg;
|
||||
}
|
||||
|
||||
static FormFormattingConfig new_defproc_rule(
|
||||
int start_index,
|
||||
int num_columns_to_compute_widths,
|
||||
const std::vector<int>& inlining_preventation_indices) {
|
||||
FormFormattingConfig cfg;
|
||||
cfg.has_constant_pairs = true;
|
||||
cfg.config_set = true;
|
||||
cfg.hang_forms = false;
|
||||
cfg.inline_until_index = [start_index](std::vector<std::string> curr_lines) {
|
||||
// if (curr_lines.size() >= 4 && curr_lines.at(3) == "()") {
|
||||
// return 4;
|
||||
// }
|
||||
return start_index;
|
||||
};
|
||||
for (const auto& index : inlining_preventation_indices) {
|
||||
auto temp_config = std::make_shared<FormFormattingConfig>();
|
||||
temp_config->config_set = true;
|
||||
temp_config->prevent_inlining = true;
|
||||
temp_config->hang_forms = false;
|
||||
temp_config->indentation_width = 1;
|
||||
auto temp_list_config = std::make_shared<FormFormattingConfig>();
|
||||
temp_list_config->force_inline = false;
|
||||
temp_list_config->hang_forms = false;
|
||||
temp_config->default_index_config = temp_list_config;
|
||||
if (index == 3) {
|
||||
temp_config->determine_column_widths_for_list_elements = true;
|
||||
temp_config->num_columns_to_compute_widths = num_columns_to_compute_widths;
|
||||
}
|
||||
cfg.index_configs.emplace(index, temp_config);
|
||||
}
|
||||
return cfg;
|
||||
}
|
||||
|
||||
static FormFormattingConfig new_binding_rule(int form_head_width) {
|
||||
FormFormattingConfig cfg;
|
||||
cfg.config_set = true;
|
||||
@ -253,6 +286,9 @@ const std::unordered_map<std::string, FormFormattingConfig> opengoal_form_config
|
||||
{"defmethod", new_defmethod_rule(3)},
|
||||
{"lambda", new_lambda_rule(2)},
|
||||
{"deftype", new_deftype_rule(3, 1, {3, 4, 5, 6})},
|
||||
{"defproc", new_defproc_rule(3, 1, {3, 4, 5, 6})},
|
||||
{"suspend-for", new_flow_rule(2)},
|
||||
{"spawn-proc", new_flow_rule(2)},
|
||||
{"defun", new_flow_rule(3)},
|
||||
{"defun-recursive", new_flow_rule(4)},
|
||||
{"defun-debug-recursive", new_flow_rule(4)},
|
||||
@ -281,12 +317,14 @@ const std::unordered_map<std::string, FormFormattingConfig> opengoal_form_config
|
||||
{"protect", new_binding_rule(4)},
|
||||
{"let*", new_binding_rule(5)},
|
||||
{"rlet", new_binding_rule(5)},
|
||||
{"mlet", new_binding_rule(5)},
|
||||
{"when", new_flow_rule(2)},
|
||||
{"unless", new_flow_rule(2)},
|
||||
{"with-profiler", new_flow_rule(2)},
|
||||
{"with-pc", new_flow_rule(0)},
|
||||
{"#unless", new_flow_rule(2)},
|
||||
{"#when", new_flow_rule(2)},
|
||||
{"#when-game", new_flow_rule(2)},
|
||||
{"countdown", new_flow_rule(2)},
|
||||
{"until", new_flow_rule(2)},
|
||||
{"loop", new_flow_rule(0)},
|
||||
|
@ -577,7 +577,7 @@ void setup_alpha_from_material(const tinygltf::Material& material, DrawMode* mod
|
||||
|
||||
void setup_draw_mode_from_sampler(const tinygltf::Sampler& sampler, DrawMode* mode) {
|
||||
if (sampler.magFilter == TINYGLTF_TEXTURE_FILTER_NEAREST) {
|
||||
ASSERT(sampler.minFilter == TINYGLTF_TEXTURE_FILTER_NEAREST);
|
||||
ASSERT(sampler.minFilter == TINYGLTF_TEXTURE_FILTER_NEAREST_MIPMAP_NEAREST);
|
||||
mode->set_filt_enable(false);
|
||||
} else {
|
||||
ASSERT(sampler.minFilter != TINYGLTF_TEXTURE_FILTER_NEAREST);
|
||||
|
@ -904,6 +904,15 @@ void pc_register_screen_shot_settings(u32 ptr) {
|
||||
register_screen_shot_settings(Ptr<ScreenShotSettings>(ptr).c());
|
||||
}
|
||||
|
||||
void pc_encode_utf8_string(u32 src_str_ptr, u32 str_dest_ptr) {
|
||||
auto str = std::string(Ptr<String>(src_str_ptr).c()->data());
|
||||
std::string version = version_to_game_name(g_game_version);
|
||||
const std::string font_bank_name = version == "jak1" ? "jak1-v2" : version;
|
||||
std::string converted =
|
||||
get_font_bank(get_text_version_from_name(font_bank_name))->convert_utf8_to_game(str);
|
||||
strcpy(Ptr<String>(str_dest_ptr).c()->data(), converted.c_str());
|
||||
}
|
||||
|
||||
/// Initializes all functions that are common across all game versions
|
||||
/// These functions have the same implementation and do not use any game specific functions (other
|
||||
/// than the one to create a function in the first place)
|
||||
@ -1005,6 +1014,9 @@ void init_common_pc_port_functions(
|
||||
// RNG
|
||||
make_func_symbol_func("pc-rand", (void*)pc_rand);
|
||||
|
||||
// text
|
||||
make_func_symbol_func("pc-encode-utf8-string", (void*)pc_encode_utf8_string);
|
||||
|
||||
// debugging tools
|
||||
make_func_symbol_func("pc-filter-debug-string?", (void*)pc_filter_debug_string);
|
||||
make_func_symbol_func("pc-screen-shot", (void*)pc_screen_shot);
|
||||
|
@ -541,7 +541,6 @@ void InitMachine_PCPort() {
|
||||
make_function_symbol_from_c("__pc-get-tex-remap", (void*)lookup_jak2_texture_dest_offset);
|
||||
make_function_symbol_from_c("pc-init-autosplitter-struct",
|
||||
(void*)kmachine_extras::init_autosplit_struct);
|
||||
make_function_symbol_from_c("pc-encode-utf8-string", (void*)kmachine_extras::encode_utf8_string);
|
||||
|
||||
// discord rich presence
|
||||
make_function_symbol_from_c("pc-discord-rpc-update", (void*)kmachine_extras::update_discord_rpc);
|
||||
|
@ -196,13 +196,6 @@ inline bool symbol_to_bool(const u32 symptr) {
|
||||
return symptr != s7.offset;
|
||||
}
|
||||
|
||||
// TODO - move to common
|
||||
void encode_utf8_string(u32 src_str_ptr, u32 str_dest_ptr) {
|
||||
auto str = std::string(Ptr<String>(src_str_ptr).c()->data());
|
||||
std::string converted = get_font_bank(GameTextVersion::JAK2)->convert_utf8_to_game(str);
|
||||
strcpy(Ptr<String>(str_dest_ptr).c()->data(), converted.c_str());
|
||||
}
|
||||
|
||||
void init_autosplit_struct() {
|
||||
g_auto_splitter_block_jak2.pointer_to_symbol =
|
||||
(u64)g_ee_main_mem + (u64)intern_from_c("*autosplit-info-jak2*")->value();
|
||||
|
@ -370,7 +370,6 @@ void InitMachine_PCPort() {
|
||||
(void*)kmachine_extras::pc_set_active_levels);
|
||||
make_function_symbol_from_c("__pc-get-tex-remap", (void*)lookup_jak3_texture_dest_offset);
|
||||
// make_function_symbol_from_c("pc-init-autosplitter-struct", (void*)init_autosplit_struct);
|
||||
make_function_symbol_from_c("pc-encode-utf8-string", (void*)kmachine_extras::encode_utf8_string);
|
||||
|
||||
// discord rich presence
|
||||
make_function_symbol_from_c("pc-discord-rpc-update", (void*)kmachine_extras::update_discord_rpc);
|
||||
|
@ -183,12 +183,5 @@ inline bool symbol_to_bool(const u32 symptr) {
|
||||
return symptr != s7.offset;
|
||||
}
|
||||
|
||||
// TODO - move to common
|
||||
void encode_utf8_string(u32 src_str_ptr, u32 str_dest_ptr) {
|
||||
auto str = std::string(Ptr<String>(src_str_ptr).c()->data());
|
||||
std::string converted = get_font_bank(GameTextVersion::JAK3)->convert_utf8_to_game(str);
|
||||
strcpy(Ptr<String>(str_dest_ptr).c()->data(), converted.c_str());
|
||||
}
|
||||
|
||||
} // namespace kmachine_extras
|
||||
} // namespace jak3
|
||||
|
@ -575,6 +575,8 @@
|
||||
|
||||
(define-extern pc-rand (function int))
|
||||
|
||||
(define-extern pc-encode-utf8-string (function string string none))
|
||||
|
||||
;; Constants generated within the C++ runtime
|
||||
(define-extern *pc-user-dir-base-path* string)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user