本文整理汇总了C++中BitmapRef::GetRect方法的典型用法代码示例。如果您正苦于以下问题:C++ BitmapRef::GetRect方法的具体用法?C++ BitmapRef::GetRect怎么用?C++ BitmapRef::GetRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitmapRef
的用法示例。
在下文中一共展示了BitmapRef::GetRect方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleErrorOutput
static void HandleErrorOutput(const std::string& err) {
#ifdef EMSCRIPTEN
// Do not execute any game logic after an error happened
emscripten_cancel_main_loop();
#endif
// Drawing directly on the screen because message_overlay is not visible
// when faded out
BitmapRef surface = DisplayUi->GetDisplaySurface();
surface->FillRect(surface->GetRect(), Color(255, 0, 0, 128));
std::string error = "Error:\n";
error += err;
error += "\n\nEasyRPG Player will close now.\nPress [ENTER] key to exit...";
Text::Draw(*surface, 11, 11, Color(0, 0, 0, 255), error);
Text::Draw(*surface, 10, 10, Color(255, 255, 255, 255), error);
DisplayUi->UpdateDisplay();
if (ignore_pause) { return; }
Input::ResetKeys();
while (!Input::IsAnyPressed()) {
DisplayUi->Sleep(1);
DisplayUi->ProcessEvents();
if (Player::exit_flag) break;
Input::Update();
}
}
示例2: HandleErrorOutput
static void HandleErrorOutput(const std::string& err) {
// Drawing directly on the screen because message_overlay is not visible
// when faded out
BitmapRef surface = DisplayUi->GetDisplaySurface();
surface->FillRect(surface->GetRect(), Color(255, 0, 0, 128));
std::string error = "Error:\n";
error += err;
error += "\n\nEasyRPG Player will close now. Press any key...";
Text::Draw(*surface, 11, 11, Color(0, 0, 0, 255), error);
Text::Draw(*surface, 10, 10, Color(255, 255, 255, 255), error);
DisplayUi->UpdateDisplay();
if (ignore_pause) { return; }
Input::ResetKeys();
while (!Input::IsAnyPressed()) {
DisplayUi->Sleep(1);
DisplayUi->ProcessEvents();
if (Player::exit_flag) break;
Input::Update();
}
Input::ResetKeys();
Graphics::FrameReset();
DisplayUi->UpdateDisplay();
}
示例3: EffectsBlit
// Waver, Zoom, Split Opacity
void Bitmap::EffectsBlit(int x, int y, Bitmap const& src, Rect const& src_rect,
int top_opacity, int bottom_opacity, int opacity_split,
double zoom_x, double zoom_y,
int waver_depth, double waver_phase) {
int zoomed_width = (int)(src_rect.width * zoom_x);
int zoomed_height = (int)(src_rect.height * zoom_y);
BitmapRef draw = src.Resample(zoomed_width, zoomed_height, src_rect);
EffectsBlit(x, y, *draw, draw->GetRect(),
top_opacity, bottom_opacity, (int) (opacity_split * zoom_y),
waver_depth, waver_phase);
}
示例4: Refresh
void Window_ShopParty::Refresh() {
contents->Clear();
BitmapRef system = Cache::System();
if (item_id <= 0 || item_id > static_cast<int>(Data::items.size()))
return;
const std::vector<Game_Actor*>& actors = Main_Data::game_party->GetActors();
for (size_t i = 0; i < actors.size() && i < 4; i++) {
Game_Actor *actor = actors[i];
int phase = (cycle / anim_rate) % 4;
if (phase == 3) {
phase = 1;
}
bool usable = actor->IsEquippable(item_id);
BitmapRef bm = bitmaps[i][usable ? phase : 1][usable ? 1 : 0];
if (bm) {
contents->Blit(i * 32, 0, *bm, bm->GetRect(), 255);
}
// (Shop) items are guaranteed to be valid
const auto* new_item = ReaderUtil::GetElement(Data::items, item_id);
bool equippable = usable && IsEquipment(new_item);
if (equippable) {
// check if item is equipped by each member
bool is_equipped = false;
for (int j = 1; j <= 5; ++j) {
const RPG::Item* item = actor->GetEquipment(j);
if (item) {
is_equipped |= (item->ID == item_id);
}
}
if (is_equipped)
contents->Blit(i * 32 + 20, 24, *system, Rect(128 + 8 * phase, 24, 8, 8), 255);
else {
int cmp = CmpEquip(actor, new_item);
if (cmp > 0) {
contents->Blit(i * 32 + 20, 24, *system, Rect(128 + 8 * phase, 0, 8, 8), 255);
}
else if (cmp < 0) {
contents->Blit(i * 32 + 20, 24, *system, Rect(128 + 8 * phase, 16, 8, 8), 255);
}
else {
contents->Blit(i * 32 + 20, 24, *system, Rect(128 + 8 * phase, 8, 8, 8), 255);
}
}
}
}
}
示例5: RefreshBackground
void Window::RefreshBackground() {
background_needs_refresh = false;
BitmapRef bitmap = Bitmap::Create(width, height, false);
if (stretch) {
bitmap->StretchBlit(*windowskin, Rect(0, 0, 32, 32), 255);
} else {
bitmap->TiledBlit(Rect(0, 0, 16, 16), *windowskin, bitmap->GetRect(), 255);
}
background->SetBitmap(bitmap);
}
示例6: Sprite
void Battle::Enemy::CreateSprite() {
BitmapRef graphic = Cache::Monster(rpg_enemy->battler_name);
bool hue_change = rpg_enemy->battler_hue != 0;
if (hue_change) {
BitmapRef new_graphic = Bitmap::Create(graphic->GetWidth(), graphic->GetHeight());
new_graphic->HueChangeBlit(0, 0, *graphic, graphic->GetRect(), rpg_enemy->battler_hue);
graphic = new_graphic;
}
sprite.reset(new Sprite());
sprite->SetBitmap(graphic);
sprite->SetOx(graphic->GetWidth() / 2);
sprite->SetOy(graphic->GetHeight() / 2);
sprite->SetX(member->x);
sprite->SetY(member->y);
sprite->SetZ(member->y);
sprite->SetVisible(!game_enemy->IsHidden());
}
示例7: Rect
BitmapScreen::BitmapScreen(BitmapRef const& bitmap) :
bitmap(bitmap),
bitmap_effects_valid(false),
bitmap_scale_valid(false) {
ClearEffects();
bitmap_changed = true;
current_tone = tone_effect;
current_zoom_x = zoom_x_effect;
current_zoom_y = zoom_y_effect;
current_flip_x = flipx_effect;
current_flip_y = flipy_effect;
current_flash = flash_effect;
bitmap_effects_src_rect = Rect();
bitmap_scale_src_rect = Rect();
if (bitmap != NULL) {
src_rect_effect = bitmap->GetRect();
bitmap->AttachBitmapScreen(this);
}
}
示例8: Draw
//.........这里部分代码省略.........
(shadow_color.blue == 0) ) {
if (text_surface->bytes() >= 3) {
shadow_color.blue++;
} else {
shadow_color.blue += 8;
}
}
// Where to draw the next glyph (x pos)
int next_glyph_pos = 0;
// The current char is an exfont
bool is_exfont = false;
// This loops always renders a single char, color blends it and then puts
// it onto the text_surface (including the drop shadow)
for (boost::u8_to_u32_iterator<std::string::const_iterator>
c(text.begin(), text.begin(), text.end()),
end(text.end(), text.begin(), text.end()); c != end; ++c) {
Rect next_glyph_rect(next_glyph_pos, 0, 0, 0);
boost::u8_to_u32_iterator<std::string::const_iterator> next_c_it = boost::next(c);
uint32_t const next_c = std::distance(c, end) > 1? *next_c_it : 0;
// ExFont-Detection: Check for A-Z or a-z behind the $
if (*c == '$' && std::isalpha(next_c)) {
int exfont_value = -1;
// Calculate which exfont shall be rendered
if (islower(next_c)) {
exfont_value = 26 + next_c - 'a';
} else if (isupper(next_c)) {
exfont_value = next_c - 'A';
} else {
assert(false);
}
is_exfont = true;
BitmapRef mask = Bitmap::Create(12, 12, true);
// Get exfont from graphic
Rect const rect_exfont((exfont_value % 13) * 12, (exfont_value / 13) * 12, 12, 12);
// Create a mask
mask->Clear();
mask->Blit(0, 0, *exfont, rect_exfont, 255);
// Get color region from system graphic
Rect clip_system(8+16*(color%10), 4+48+16*(color/10), 6, 12);
BitmapRef char_surface = Bitmap::Create(mask->GetWidth(), mask->GetHeight(), true);
char_surface->SetTransparentColor(dest.GetTransparentColor());
char_surface->Clear();
// Blit gradient color background (twice because of full glyph)
char_surface->Blit(0, 0, *system, clip_system, 255);
char_surface->Blit(6, 0, *system, clip_system, 255);
// Blit mask onto background
char_surface->MaskBlit(0, 0, *mask, mask->GetRect());
BitmapRef char_shadow = Bitmap::Create(mask->GetWidth(), mask->GetHeight(), true);
char_shadow->SetTransparentColor(dest.GetTransparentColor());
char_shadow->Clear();
// Blit solid color background
char_shadow->Fill(shadow_color);
// Blit mask onto background
char_shadow->MaskBlit(0, 0, *mask, mask->GetRect());
// Blit first shadow and then text
text_surface->Blit(next_glyph_rect.x + 1, next_glyph_rect.y + 1, *char_shadow, char_shadow->GetRect(), 255);
text_surface->Blit(next_glyph_rect.x, next_glyph_rect.y, *char_surface, char_surface->GetRect(), 255);
} else { // Not ExFont, draw normal text
font->Render(*text_surface, next_glyph_rect.x, next_glyph_rect.y, *system, color, *c);
}
// If it's a full size glyph, add the size of a half-size glypth twice
if (is_exfont) {
is_exfont = false;
next_glyph_pos += 12;
// Skip the next character
++c;
} else {
std::string const glyph(c.base(), next_c_it.base());
next_glyph_pos += Font::Default()->GetSize(glyph).width;
}
}
BitmapRef text_bmp = Bitmap::Create(*text_surface, text_surface->GetRect());
Rect src_rect(0, 0, dst_rect.width, dst_rect.height);
int iy = dst_rect.y;
if (dst_rect.height > text_bmp->GetHeight()) {
iy += ((dst_rect.height - text_bmp->GetHeight()) / 2);
}
int ix = dst_rect.x;
dest.Blit(ix, iy, *text_bmp, src_rect, 255);
}
示例9: Refresh
void Window_ShopParty::Refresh() {
contents->Clear();
BitmapRef system = Cache::System();
if (item_id <= 0 || item_id > Data::items.size())
return;
const std::vector<Game_Actor*>& actors = Main_Data::game_party->GetActors();
for (size_t i = 0; i < actors.size() && i < 4; i++) {
Game_Actor *actor = actors[i];
int phase = (cycle / anim_rate) % 4;
if (phase == 3) {
phase = 1;
}
bool equippable = actor->IsEquippable(item_id);
BitmapRef bm = bitmaps[i][equippable ? phase : 1][equippable ? 1 : 0];
if (bm) {
contents->Blit(i * 32, 0, *bm, bm->GetRect(), 255);
}
if (equippable) {
//check if item is equipped by each member
bool is_equipped = false;
for (int j = 0; j < 5; ++j) {
const RPG::Item* item = actor->GetEquipment(j);
if (item) {
is_equipped |= (item->ID == item_id);
}
}
if (is_equipped)
contents->Blit(i * 32 + 20, 24, *system, Rect(128 + 8 * phase, 24, 8, 8), 255);
else {
RPG::Item* new_item = &Data::items[item_id - 1];
int item_type = new_item->type;
RPG::Item* current_item = NULL;
switch (item_type) {
//get the current equipped item
case RPG::Item::Type_weapon:
if (actor->GetWeaponId() > 0)
current_item = &Data::items[actor->GetWeaponId() - 1];
else
current_item = &Data::items[0];
break;
case RPG::Item::Type_helmet:
if (actor->GetHelmetId() > 0)
current_item = &Data::items[actor->GetHelmetId() - 1];
else
current_item = &Data::items[0];
break;
case RPG::Item::Type_shield:
if (actor->GetShieldId() > 0)
current_item = &Data::items[actor->GetShieldId() - 1];
else
current_item = &Data::items[0];
break;
case RPG::Item::Type_armor:
if (actor->GetArmorId() > 0)
current_item = &Data::items[actor->GetArmorId() - 1];
else
current_item = &Data::items[0];
break;
case RPG::Item::Type_accessory:
if (actor->GetAccessoryId() > 0)
current_item = &Data::items[actor->GetAccessoryId() -1];
else
current_item = &Data::items[0];
break;
}
if (current_item != NULL) {
int diff_atk = new_item->atk_points1 - current_item->atk_points1;
int diff_def = new_item->def_points1 - current_item->def_points1;
int diff_spi = new_item->spi_points1 - current_item->spi_points1;
int diff_agi = new_item->agi_points1 - current_item->agi_points1;
if (diff_atk > 0 || diff_def > 0 || diff_spi > 0 || diff_agi > 0)
contents->Blit(i * 32 + 20, 24, *system, Rect(128 + 8 * phase, 0, 8, 8), 255);
else if (diff_atk < 0 || diff_def < 0 || diff_spi < 0 || diff_agi < 0)
contents->Blit(i * 32 + 20, 24, *system, Rect(128 + 8 * phase, 16, 8, 8), 255);
else
contents->Blit(i * 32 + 20, 24, *system, Rect(128 + 8 * phase, 8, 8, 8), 255);
}
}
}
}
}