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_actortarget.h"
20 #include "game_actor.h"
21 #include "game_party.h"
22 #include "bitmap.h"
23 #include "player.h"
24
Window_ActorTarget(int ix,int iy,int iwidth,int iheight)25 Window_ActorTarget::Window_ActorTarget(int ix, int iy, int iwidth, int iheight) :
26 Window_Selectable(ix, iy, iwidth, iheight) {
27
28 SetContents(Bitmap::Create(width - 16, height - 16));
29
30 Refresh();
31 }
32
Refresh()33 void Window_ActorTarget::Refresh() {
34 contents->Clear();
35
36 item_max = Main_Data::game_party->GetActors().size();
37
38 int y = 0;
39 for (int i = 0; i < item_max; ++i) {
40 const Game_Actor& actor = *(Main_Data::game_party->GetActors()[i]);
41
42 DrawActorFace(actor, 0, i * 48 + y);
43 DrawActorName(actor, 48 + 8, i * 48 + 2 + y);
44 DrawActorLevel(actor, 48 + 8, i * 48 + 2 + 16 + y);
45 DrawActorState(actor, 48 + 8, i * 48 + 2 + 16 + 16 + y);
46 int digits = (actor.MaxHpValue() >= 1000 || actor.MaxSpValue() >= 1000) ? 4 : 3;
47 int x_offset = 48 + 8 + 46 + (digits == 3 ? 12 : 0);
48 DrawActorHp(actor, x_offset, i * 48 + 2 + 16 + y, digits);
49 DrawActorSp(actor, x_offset, i * 48 + 2 + 16 + 16 + y, digits);
50
51 y += 10;
52 }
53 }
54
UpdateCursorRect()55 void Window_ActorTarget::UpdateCursorRect() {
56 if (index < -10) { // Entire Party
57 cursor_rect = { 48 + 4, 0, 120, item_max * (48 + 10) - 10 };
58 } else if (index < 0) { // Fixed to one
59 cursor_rect = { 48 + 4, (-index - 1) * (48 + 10), 120, 48 };
60 } else {
61 cursor_rect = { 48 + 4, index * (48 + 10), 120, 48 };
62 }
63 }
64
GetActor()65 Game_Actor* Window_ActorTarget::GetActor() {
66 int ind = GetIndex();
67 if (ind >= -10 && ind < 0) {
68 ind = -ind - 1;
69 }
70 else if (ind == -100) {
71 return nullptr;
72 }
73
74 return &(*Main_Data::game_party)[ind];
75 }
76