1 /*
2  * This file is part of EasyRPG Player.
3  *
4  * EasyRPG Player is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * EasyRPG Player is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with EasyRPG Player. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 // Headers
19 #include "window_menustatus.h"
20 #include "cache.h"
21 #include "game_party.h"
22 #include "player.h"
23 #include "bitmap.h"
24 
Window_MenuStatus(int ix,int iy,int iwidth,int iheight)25 Window_MenuStatus::Window_MenuStatus(int ix, int iy, int iwidth, int iheight) :
26 	Window_Selectable(ix, iy, iwidth, iheight) {
27 
28 	if (Player::IsRPG2k3()) {
29 		SetContents(Bitmap::Create(width - 12, height - 16));
30 		SetBorderX(4);
31 		text_offset = 4;
32 	} else {
33 		SetContents(Bitmap::Create(width - 16, height - 16));
34 	}
35 
36 	Refresh();
37 }
38 
Refresh()39 void Window_MenuStatus::Refresh() {
40 	contents->Clear();
41 
42 	item_max = Main_Data::game_party->GetActors().size();
43 
44 	int y = 0;
45 	for (int i = 0; i < item_max; ++i) {
46 		// The party always contains valid battlers
47 		const Game_Actor& actor = *(Main_Data::game_party->GetActors()[i]);
48 
49 		int face_x = 0;
50 		if (Player::IsRPG2k3()) {
51 			face_x = actor.GetBattleRow() == Game_Actor::RowType::RowType_back ? 8 : 0;
52 		}
53 		DrawActorFace(actor, face_x, i*48 + y);
54 
55 		DrawActorName(actor, 48 + 8 + text_offset, i*48 + 2 + y);
56 		DrawActorTitle(actor, 48 + 8 + 88 + text_offset, i*48 + 2 + y);
57 		DrawActorLevel(actor, 48 + 8 + text_offset, i*48 + 2 + 16 + y);
58 		DrawActorState(actor, 48 + 8 + 42 + text_offset, i*48 + 2 + 16 + y);
59 		DrawActorExp(actor, 48 + 8 + text_offset, i*48 + 2 + 16 + 16 + y);
60 		int digits = (actor.MaxHpValue() >= 1000 || actor.MaxSpValue() >= 1000) ? 4 : 3;
61 		DrawActorHp(actor, 48 + 8 + 106 + text_offset - (digits == 3 ? 0 : 12), i * 48 + 2 + 16 + y, digits);
62 		DrawActorSp(actor, 48 + 8 + 106 + text_offset - (digits == 3 ? 0 : 12), i * 48 + 2 + 16 + 16 + y, digits);
63 
64 		y += 10;
65 	}
66 }
67 
UpdateCursorRect()68 void Window_MenuStatus::UpdateCursorRect()
69 {
70 	if (index < 0) {
71 		cursor_rect = { 0, 0, 0, 0 };
72 	} else {
73 		cursor_rect = { 48 + 4 + text_offset, index * (48 + 10), 168, 48 };
74 	}
75 }
76 
GetActor() const77 Game_Actor* Window_MenuStatus::GetActor() const {
78 	return &(*Main_Data::game_party)[GetIndex()];
79 }
80