Refactor hex string handling: replace UppercaseHex functions with Hex equivalents

This commit is contained in:
scawful
2024-12-30 09:48:19 -05:00
parent f13ce9d6fd
commit 59e59f8a38
11 changed files with 37 additions and 37 deletions

View File

@@ -328,7 +328,7 @@ void DungeonEditor::DrawRoomSelector() {
for (const auto each_room_name : zelda3::kRoomNames) {
rom()->resource_label()->SelectableLabelWithNameEdit(
current_room_id_ == i, "Dungeon Room Names",
core::UppercaseHexByte(i), each_room_name.data());
core::HexByte(i), each_room_name.data());
if (ImGui::IsItemClicked()) {
// TODO: Jump to tab if room is already open
current_room_id_ = i;
@@ -402,7 +402,7 @@ void DungeonEditor::DrawEntranceSelector() {
for (int i = 0; i < 0x85 + 7; i++) {
rom()->resource_label()->SelectableLabelWithNameEdit(
current_entrance_id_ == i, "Dungeon Entrance Names",
core::UppercaseHexByte(i),
core::HexByte(i),
zelda3::kEntranceNames[i].data());
if (ImGui::IsItemClicked()) {

View File

@@ -355,7 +355,7 @@ void EditorManager::DrawInfoPopup() {
if (BeginPopupModal("ROM Information", nullptr,
ImGuiWindowFlags_AlwaysAutoResize)) {
Text("Title: %s", rom()->title().c_str());
Text("ROM Size: %s", core::UppercaseHexLongLong(rom()->size()).c_str());
Text("ROM Size: %s", core::HexLongLong(rom()->size()).c_str());
if (Button("Close", gui::kDefaultModalSize) ||
IsKeyPressed(ImGuiKey_Escape)) {

View File

@@ -167,7 +167,7 @@ absl::Status ScreenEditor::LoadDungeonMaps() {
gdata[j] = rom()->data()[pc_ptr_gfx++];
}
std::string label = core::UppercaseHexByte(rdata[j]);
std::string label = core::HexByte(rdata[j]);
dungeon_map_labels_[d][i][j] = label;
}
@@ -318,7 +318,7 @@ void ScreenEditor::DrawDungeonMapsTabs() {
std::string label =
dungeon_map_labels_[selected_dungeon][floor_number][j];
screen_canvas_.DrawText(label, (posX * 2), (posY * 2));
std::string gfx_id = core::UppercaseHexByte(tile16_id);
std::string gfx_id = core::HexByte(tile16_id);
screen_canvas_.DrawText(gfx_id, (posX * 2), (posY * 2) + 16);
}
}

View File

@@ -59,7 +59,7 @@ absl::Status Tile16Editor::InitBlockset(
RETURN_IF_ERROR(LoadTile8());
ImVector<std::string> tile16_names;
for (int i = 0; i < 0x200; ++i) {
std::string str = core::UppercaseHexByte(all_tiles_types_[i]);
std::string str = core::HexByte(all_tiles_types_[i]);
tile16_names.push_back(str);
}

View File

@@ -88,7 +88,7 @@ absl::Status MessageEditor::Initialize() {
for (const auto& each_message : list_of_texts_) {
std::cout << "Message #" << each_message.ID << " at address "
<< core::UppercaseHexLong(each_message.Address) << std::endl;
<< core::HexLong(each_message.Address) << std::endl;
std::cout << " " << each_message.RawString << std::endl;
// Each string has a [:XX] char encoded
@@ -173,7 +173,7 @@ void MessageEditor::DrawMessageList() {
for (const auto& message : list_of_texts_) {
TableNextColumn();
if (Button(core::UppercaseHexWord(message.ID).c_str())) {
if (Button(core::HexWord(message.ID).c_str())) {
current_message_ = message;
DrawMessagePreview();
}
@@ -182,7 +182,7 @@ void MessageEditor::DrawMessageList() {
TableNextColumn();
TextWrapped(
"%s",
core::UppercaseHexLong(list_of_texts_[message.ID].Address).c_str());
core::HexLong(list_of_texts_[message.ID].Address).c_str());
}
EndTable();
@@ -252,7 +252,7 @@ void MessageEditor::DrawDictionary() {
for (const auto& dictionary : all_dictionaries_) {
TableNextColumn();
Text("%s", core::UppercaseHexWord(dictionary.ID).c_str());
Text("%s", core::HexWord(dictionary.ID).c_str());
TableNextColumn();
Text("%s", dictionary.Contents.c_str());
}
@@ -332,7 +332,7 @@ void MessageEditor::ReadAllTextDataV2() {
current_raw_message.append("[");
current_raw_message.append(DICTIONARYTOKEN);
current_raw_message.append(":");
current_raw_message.append(core::UppercaseHexWord(dictionary));
current_raw_message.append(core::HexWord(dictionary));
current_raw_message.append("]");
uint32_t address = core::Get24LocalFromPC(
@@ -432,7 +432,7 @@ void MessageEditor::ReadAllTextData() {
current_message_raw.append("[");
current_message_raw.append(DICTIONARYTOKEN);
current_message_raw.append(":");
current_message_raw.append(core::UppercaseHexWord(dictionary));
current_message_raw.append(core::HexWord(dictionary));
current_message_raw.append("]");
uint32_t address = core::Get24LocalFromPC(

View File

@@ -91,7 +91,7 @@ void HandleEntityDragging(zelda3::GameEntity *entity, ImVec2 canvas_p0,
ImGui::SetDragDropPayload("ENTITY_PAYLOAD", &entity,
sizeof(zelda3::GameEntity));
Text("Moving %s ID: %s", entity_type.c_str(),
core::UppercaseHexByte(entity->entity_id_).c_str());
core::HexByte(entity->entity_id_).c_str());
ImGui::EndDragDropSource();
}
MoveEntityOnGrid(dragged_entity, canvas_p0, scrolling, free_movement);

View File

@@ -789,7 +789,7 @@ void OverworldEditor::DrawOverworldEntrances(ImVec2 canvas_p0, ImVec2 scrolling,
color = ImVec4(255, 255, 255, 200);
}
ow_map_canvas_.DrawRect(each.x_, each.y_, 16, 16, color);
std::string str = core::UppercaseHexByte(each.entrance_id_);
std::string str = core::HexByte(each.entrance_id_);
if (current_mode == EditingMode::ENTRANCES) {
HandleEntityDragging(&each, canvas_p0, scrolling, is_dragging_entity_,
@@ -872,7 +872,7 @@ void OverworldEditor::DrawOverworldExits(ImVec2 canvas_p0, ImVec2 scrolling) {
}
}
std::string str = core::UppercaseHexByte(i);
std::string str = core::HexByte(i);
ow_map_canvas_.DrawText(str, each.x_, each.y_);
}
i++;
@@ -1367,7 +1367,7 @@ absl::Status OverworldEditor::UpdateUsageStats() {
ImGuiWindowFlags_HorizontalScrollbar)) {
for (int i = 0; i < 0x81; i++) {
auto entrance_name = rom()->resource_label()->GetLabel(
"Dungeon Entrance Names", core::UppercaseHexByte(i));
"Dungeon Entrance Names", core::HexByte(i));
std::string str = absl::StrFormat("%#x - %s", i, entrance_name);
if (Selectable(str.c_str(), selected_entrance_ == i,
overworld_.entrances().at(i).deleted

View File

@@ -190,7 +190,7 @@ void SpriteEditor::DrawSpritesList() {
int i = 0;
for (const auto each_sprite_name : zelda3::kSpriteDefaultNames) {
rom()->resource_label()->SelectableLabelWithNameEdit(
current_sprite_id_ == i, "Sprite Names", core::UppercaseHexByte(i),
current_sprite_id_ == i, "Sprite Names", core::HexByte(i),
zelda3::kSpriteDefaultNames[i].data());
if (ImGui::IsItemClicked()) {
current_sprite_id_ = i;