update refresh logic, rearrange message editor

This commit is contained in:
scawful
2024-07-29 18:24:46 -04:00
parent ba90505d22
commit a5a1e183fa
2 changed files with 33 additions and 41 deletions

View File

@@ -611,6 +611,36 @@ string MessageEditor::ParseTextDataByte(uint8_t value) {
return ""; return "";
} }
void MessageEditor::DrawTileToPreview(int x, int y, int srcx, int srcy, int pal,
bool mirror_x, bool mirror_y, int sizex,
int sizey) {
int drawid = srcx + (srcy * 32);
for (int yl = 0; yl < sizey * 8; yl++) {
for (int xl = 0; xl < 4; xl++) {
int mx = xl;
int my = yl;
// Formula information to get tile index position in the array.
// ((ID / nbrofXtiles) * (imgwidth/2) + (ID - ((ID/16)*16) ))
int tx = ((drawid / 16) * 512) + ((drawid - ((drawid / 16) * 16)) * 4);
uint8_t pixel = font_gfx16_data[tx + (yl * 64) + xl];
// nx,ny = object position, xx,yy = tile position, xl,yl = pixel
// position
int index = x + (y * 172) + (mx * 2) + (my * 172);
if ((pixel & 0x0F) != 0) {
current_font_gfx16_data_[index + 1] =
(uint8_t)((pixel & 0x0F) + (0 * 4));
}
if (((pixel >> 4) & 0x0F) != 0) {
current_font_gfx16_data_[index + 0] =
(uint8_t)(((pixel >> 4) & 0x0F) + (0 * 4));
}
}
}
}
void MessageEditor::DrawStringToPreview(string str) { void MessageEditor::DrawStringToPreview(string str) {
for (const auto c : str) { for (const auto c : str) {
DrawCharacterToPreview(c); DrawCharacterToPreview(c);
@@ -690,36 +720,6 @@ void MessageEditor::DrawMessagePreview() // From Parsing.
shown_lines = 0; shown_lines = 0;
} }
void MessageEditor::DrawTileToPreview(int x, int y, int srcx, int srcy, int pal,
bool mirror_x, bool mirror_y, int sizex,
int sizey) {
int drawid = srcx + (srcy * 32);
for (int yl = 0; yl < sizey * 8; yl++) {
for (int xl = 0; xl < 4; xl++) {
int mx = xl;
int my = yl;
// Formula information to get tile index position in the array.
// ((ID / nbrofXtiles) * (imgwidth/2) + (ID - ((ID/16)*16) ))
int tx = ((drawid / 16) * 512) + ((drawid - ((drawid / 16) * 16)) * 4);
uint8_t pixel = font_gfx16_data[tx + (yl * 64) + xl];
// nx,ny = object position, xx,yy = tile position, xl,yl = pixel
// position
int index = x + (y * 172) + (mx * 2) + (my * 172);
if ((pixel & 0x0F) != 0) {
current_font_gfx16_data_[index + 1] =
(uint8_t)((pixel & 0x0F) + (0 * 4));
}
if (((pixel >> 4) & 0x0F) != 0) {
current_font_gfx16_data_[index + 0] =
(uint8_t)(((pixel >> 4) & 0x0F) + (0 * 4));
}
}
}
}
std::string MessageEditor::DisplayTextOverflowError(int pos, bool bank) { std::string MessageEditor::DisplayTextOverflowError(int pos, bool bank) {
int space = bank ? kTextDataEnd - kTextData : kTextData2End - kTextData2; int space = bank ? kTextDataEnd - kTextData : kTextData2End - kTextData2;
string bankSTR = bank ? "1st" : "2nd"; string bankSTR = bank ? "1st" : "2nd";

View File

@@ -11,15 +11,8 @@ void OverworldEditor::RefreshChildMap(int map_index) {
status_ = overworld_.mutable_overworld_map(map_index)->BuildTiles16Gfx( status_ = overworld_.mutable_overworld_map(map_index)->BuildTiles16Gfx(
overworld_.tiles16().size()); overworld_.tiles16().size());
PRINT_IF_ERROR(status_); PRINT_IF_ERROR(status_);
OWBlockset blockset; status_ = overworld_.mutable_overworld_map(map_index)->BuildBitmap(
if (current_world_ == 0) { overworld_.GetMapTiles(current_world_));
blockset = overworld_.map_tiles().light_world;
} else if (current_world_ == 1) {
blockset = overworld_.map_tiles().dark_world;
} else {
blockset = overworld_.map_tiles().special_world;
}
status_ = overworld_.mutable_overworld_map(map_index)->BuildBitmap(blockset);
maps_bmp_[map_index].set_data( maps_bmp_[map_index].set_data(
overworld_.mutable_overworld_map(map_index)->bitmap_data()); overworld_.mutable_overworld_map(map_index)->bitmap_data());
maps_bmp_[map_index].set_modified(true); maps_bmp_[map_index].set_modified(true);
@@ -64,8 +57,7 @@ void OverworldEditor::RefreshOverworldMap() {
absl::Status OverworldEditor::RefreshMapPalette() { absl::Status OverworldEditor::RefreshMapPalette() {
RETURN_IF_ERROR( RETURN_IF_ERROR(
overworld_.mutable_overworld_map(current_map_)->LoadPalette()); overworld_.mutable_overworld_map(current_map_)->LoadPalette());
const auto current_map_palette = const auto current_map_palette = overworld_.AreaPalette();
overworld_.overworld_map(current_map_)->current_palette();
if (overworld_.overworld_map(current_map_)->is_large_map()) { if (overworld_.overworld_map(current_map_)->is_large_map()) {
// We need to update the map and its siblings if it's a large map // We need to update the map and its siblings if it's a large map