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

Method DrawItemValue

src/window_varlist.cpp:78–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76}
77
78void Window_VarList::DrawItemValue(int index){
79 if (!DataIsValid(first_var+index)) {
80 return;
81 }
82 const int y = menu_item_height * index * LINE_COUNT / GetItemCount() + 2;
83 switch (mode) {
84 case eSwitch:
85 {
86 auto value = Main_Data::game_switches->Get(first_var + index);
87 auto font = (!value) ? Font::ColorCritical : Font::ColorDefault;
88 contents->TextDraw(GetWidth() - 16, y, font, value ? "[ON]" : "[OFF]", Text::AlignRight);
89 }
90 break;
91 case eVariable:
92 {
93 auto value = Main_Data::game_variables->Get(first_var + index);
94 auto font = (value < 0) ? Font::ColorCritical : Font::ColorDefault;
95 contents->TextDraw(GetWidth() - 16, y, font, std::to_string(value), Text::AlignRight);
96 }
97 break;
98 case eItem:
99 {
100 auto value = Main_Data::game_party->GetItemCount(first_var + index);
101 auto font = (value == 0) ? Font::ColorCritical : Font::ColorDefault;
102 contents->TextDraw(GetWidth() - 16, y, font, std::to_string(value), Text::AlignRight);
103 }
104 break;
105 case eTroop:
106 case eMap:
107 case eHeal:
108 case eCommonEvent:
109 case eMapEvent:
110 {
111 contents->TextDraw(GetWidth() - 16, y, Font::ColorDefault, "", Text::AlignRight);
112 }
113 break;
114 case eLevel:
115 {
116 auto value = Main_Data::game_party->GetActors()[first_var + index - 1]->GetLevel();
117 contents->TextDraw(GetWidth() - 16, y, Font::ColorDefault, std::to_string(value), Text::AlignRight);
118 }
119 break;
120 case eString:
121 DrawStringVarItem(index, y);
122 break;
123 case eNone:
124 break;
125 }
126}
127
128void Window_VarList::UpdateList(int first_value){
129 static std::stringstream ss;

Callers

nothing calls this directly

Calls 5

TextDrawMethod · 0.80
GetLevelMethod · 0.80
GetMethod · 0.45
GetItemCountMethod · 0.45
GetActorsMethod · 0.45

Tested by

no test coverage detected