Navigation Menu

Skip to content

Commit

Permalink
Fix battle terrain handling for "Frame". Fixes #789
Browse files Browse the repository at this point in the history
This also adds a transparent flag for the background frame because with transparent flag graphical artifacts are visible.
  • Loading branch information
Ghabry committed Apr 3, 2016
1 parent 8f15127 commit 53d15ba
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
28 changes: 15 additions & 13 deletions src/background.cpp
Expand Up @@ -48,23 +48,25 @@ Background::Background(int terrain_id) :

const RPG::Terrain& terrain = Data::terrains[terrain_id - 1];

if (!terrain.background_name.empty()) {
if (terrain.background_type == 0) {
FileRequestAsync* request = AsyncHandler::RequestFile("Backdrop", terrain.background_name);
request_id = request->Bind(&Background::OnBackgroundGraphicReady, this);
request->Start();
return;
}

FileRequestAsync* request = AsyncHandler::RequestFile("Frame", terrain.background_a_name);
// Either background or frame
if (terrain.background_type == RPG::Terrain::BGAssociation_background && !terrain.background_name.empty()) {
FileRequestAsync* request = AsyncHandler::RequestFile("Backdrop", terrain.background_name);
request_id = request->Bind(&Background::OnBackgroundGraphicReady, this);
request->Start();
return;
}

bg_hscroll = terrain.background_a_scrollh ? terrain.background_a_scrollh_speed : 0;
bg_vscroll = terrain.background_a_scrollv ? terrain.background_a_scrollv_speed : 0;
// Frame
if (!terrain.background_a_name.empty()) {
FileRequestAsync* request = AsyncHandler::RequestFile("Frame", terrain.background_a_name);
request_id = request->Bind(&Background::OnBackgroundGraphicReady, this);
request->Start();

bg_hscroll = terrain.background_a_scrollh ? terrain.background_a_scrollh_speed : 0;
bg_vscroll = terrain.background_a_scrollv ? terrain.background_a_scrollv_speed : 0;
}

if (terrain.background_b) {
if (terrain.background_b && !terrain.background_b_name.empty()) {
FileRequestAsync* request = AsyncHandler::RequestFile("Frame", terrain.background_b_name);
request_id = request->Bind(&Background::OnForegroundFrameGraphicReady, this);
request->Start();
Expand All @@ -79,7 +81,7 @@ void Background::OnBackgroundGraphicReady(FileRequestResult* result) {
bg_bitmap = Cache::Backdrop(result->file);
}
else if (result->directory == "Frame") {
bg_bitmap = Cache::Frame(result->file);
bg_bitmap = Cache::Frame(result->file, false);
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/cache.cpp
Expand Up @@ -224,11 +224,14 @@ namespace {
cache(Monster)
cache(Panorama)
cache(System2)
cache(Frame)
cache(Title)
cache(System)
#undef cache

BitmapRef Cache::Frame(const std::string& f, bool trans) {
return LoadBitmap<Material::Frame>(f, trans);
}

BitmapRef Cache::Picture(const std::string& f, bool trans) {
return LoadBitmap<Material::Picture>(f, trans);
}
Expand Down
2 changes: 1 addition & 1 deletion src/cache.h
Expand Up @@ -39,7 +39,7 @@ namespace Cache {
BitmapRef Charset(const std::string& filename);
BitmapRef Exfont();
BitmapRef Faceset(const std::string& filename);
BitmapRef Frame(const std::string& filename);
BitmapRef Frame(const std::string& filename, bool transparent = true);
BitmapRef Gameover(const std::string& filename);
BitmapRef Monster(const std::string& filename);
BitmapRef Panorama(const std::string& filename);
Expand Down
1 change: 0 additions & 1 deletion src/game_interpreter_map.cpp
Expand Up @@ -1254,7 +1254,6 @@ bool Game_Interpreter_Map::CommandEnemyEncounter(RPG::EventCommand const& com) {
break;
case 2:
Game_Battle::SetTerrainId(com.parameters[8]);
Game_Temp::battle_background = Data::terrains[com.parameters[8] - 1].background_name;
break;
default:
return false;
Expand Down

0 comments on commit 53d15ba

Please sign in to comment.