MCPcopy Create free account
hub / github.com/EasyRPG/Player / Draw

Method Draw

src/sprite_picture.cpp:64–175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62
63
64void Sprite_Picture::Draw(Bitmap& dst) {
65 const auto& pic = Main_Data::game_pictures->GetPicture(pic_id);
66 const auto& data = pic.data;
67
68 auto& bitmap = GetBitmap();
69
70 if (!bitmap) {
71 return;
72 }
73
74 if (data.easyrpg_type == lcf::rpg::SavePicture::EasyRpgType_window) {
75 // Paint the Window on the Picture
76 const auto& window = Main_Data::game_windows->GetWindow(pic_id);
77 window.window->Draw(*bitmap.get());
78 }
79
80 const bool is_battle = Game_Battle::IsBattleRunning();
81
82 if (is_battle ? !pic.IsOnBattle() : !pic.IsOnMap()) {
83 return;
84 }
85
86 // RPG Maker 2k3 1.12: Spritesheets
87 if (feature_spritesheet
88 && pic.NumSpriteSheetFrames() > 1
89 && last_spritesheet_frame != data.spritesheet_frame)
90 {
91 last_spritesheet_frame = data.spritesheet_frame;
92
93 const int sw = bitmap->GetWidth() / data.spritesheet_cols;
94 const int sh = bitmap->GetHeight() / data.spritesheet_rows;
95 const int sx = sw * ((data.spritesheet_frame) % data.spritesheet_cols);
96 const int sy = sh * ((data.spritesheet_frame) / data.spritesheet_cols % data.spritesheet_rows);
97
98 SetSrcRect(Rect{ sx, sy, sw, sh });
99 }
100
101 int x = data.current_x;
102 int y = data.current_y;
103 if (data.flags.affected_by_shake) {
104 x -= Main_Data::game_screen->GetShakeOffsetX();
105 y -= Main_Data::game_screen->GetShakeOffsetY();
106 }
107
108 if (Player::game_config.fake_resolution.Get()) {
109 SetX(x + Player::menu_offset_x);
110 SetY(y + Player::menu_offset_y);
111 } else {
112 SetX(x);
113 SetY(y);
114 }
115
116 SetZoomX(data.current_magnify / 100.0);
117 SetZoomY(data.current_magnify / 100.0);
118 if (Player::IsPatchManiac()) {
119 SetZoomY(data.maniac_current_magnify_height / 100.0);
120 }
121

Callers

nothing calls this directly

Calls 15

BlendFunction · 0.85
GetWindowMethod · 0.80
IsOnBattleMethod · 0.80
IsOnMapMethod · 0.80
NumSpriteSheetFramesMethod · 0.80
GetShakeOffsetXMethod · 0.80
GetShakeOffsetYMethod · 0.80
ToneClass · 0.70
ColorClass · 0.70
getMethod · 0.45
GetWidthMethod · 0.45
GetHeightMethod · 0.45

Tested by

no test coverage detected